.TH libpbm 3 .SH NAME libpbm - functions to support portable bitmap programs .SH SYNOPSIS .de Ss .sp .ft CW .nf .. .de Se .fi .ft P .sp .. .Ss #include cc ... libpbm.a .Se .SH DESCRIPTION - PACKAGE-WIDE ROUTINES .SS KEYWORD MATCHING .Ss int pm_keymatch( char* str, char* keyword, int minchars ) .Se Does a case-insensitive match of .BR str against .BR keyword . .BR str can be a leading sunstring of .BR keyword , but at least .BR minchars must be present. .SS LOG BASE TWO .Ss int pm_maxvaltobits( int maxval ) int pm_bitstomaxval( int bits ) .Se Convert between a maxval and the minimum number of bits required to hold it. .SS MESSAGES AND ERRORS .Ss void pm_message( char* fmt, ... ) .Se .BR printf() style routine to write an informational message. .Ss void pm_error( char* fmt, ... ) .Se .BR printf() style routine to write an error message and abort. .Ss void pm_usage( char* usage ) .Se Write a usage message. The string should indicate what arguments are to be provided to the program. .SS GENERIC FILE MANAGEMENT .Ss FILE* pm_openr( char* name ) .Se Open the given file for reading, with appropriate error checking. A filename of "-" is taken as equivalent to stdin. .Ss FILE* pm_openw( char* name ) .Se Open the given file for writing, with appropriate error checking. .Ss void pm_close( FILE* fp ) .Se Close the file descriptor, with appropriate error checking. .SS ENDIAN I/O .Ss int pm_readbigshort( FILE* in, short* sP ) int pm_writebigshort( FILE* out, short s ) int pm_readbiglong( FILE* in, long* lP ) int pm_writebiglong( FILE* out, long l ) int pm_readlittleshort( FILE* in, short* sP ) int pm_writelittleshort( FILE* out, short s ) int pm_readlittlelong( FILE* in, long* lP ) int pm_writelittlelong( FILE* out, long l ) .Se Routines to read and write short and long ints in either big- or little-endian byte order. .SH DESCRIPTION - PBM-SPECIFIC ROUTINES .SS TYPES AND CONSTANTS .Ss typedef ... bit; #define PBM_WHITE ... #define PBM_BLACK ... .Se each .BR bit should contain only the values of .BR PBM_WHITE or .BR PBM_BLACK . .Ss #define PBM_FORMAT ... #define RPBM_FORMAT ... #define PBM_TYPE PBM_FORMAT #define PBM_FORMAT_TYPE(f) ... .Se For distinguishing different file formats and types. .SS INITIALIZATION .Ss void pbm_init( int* argcP, char* argv[] ) .Se All PBM programs must call this routine. .SS MEMORY MANAGEMENT .Ss bit** pbm_allocarray( int cols, int rows ) .Se Allocate an array of bits. .Ss bit* pbm_allocrow( int cols ) .Se Allocate a row of the given number of bits. .Ss void pbm_freearray( bit** bits, int rows ) .Se Free the array allocated with .BR pbm_allocarray() containing the given number of rows. .Ss void pbm_freerow( bit* bitrow ) .Se Free a row of bits. .SS READING FILES .Ss void pbm_readpbminit( FILE* fp, int* colsP, int* rowsP, int* formatP ) .Se Read the header from a PBM file, filling in the rows, cols and format variables. .Ss void pbm_readpbmrow( FILE* fp, bit* bitrow, int cols, int format ) .Se Read a row of bits into the bitrow array. Format and cols were filled in by .BR pbm_readpbminit() . .Ss bit** pbm_readpbm( FILE* fp, int* colsP, int* rowsP ) .Se Read an entire bitmap file into memory, returning the allocated array and filling in the rows and cols variables. This function combines .BR pbm_readpbminit() , .BR pbm_allocarray() and .BR pbm_readpbmrow() . .SS WRITING FILES .Ss void pbm_writepbminit( FILE* fp, int cols, int rows, int forceplain ) .Se Write the header for a portable bitmap file. The forceplain flag forces a plain-format file to be written, as opposed to a raw-format one. .Ss void pbm_writepbmrow( FILE* fp, bit* bitrow, int cols, int forceplain ) .Se Write a row from a portable bitmap. .Ss void pbm_writepbm( FILE* fp, bit** bits, int cols, int rows, int forceplain ) .Se Write the header and all data for a portable bitmap. This function combines .BR pbm_writepbminit() and .BR pbm_writepbmrow() . .SH "SEE ALSO" libpgm(3), libppm(3), libpnm(3) .SH AUTHOR Copyright (C) 1989, 1991 by Tony Hansen and Jef Poskanzer. .\" Permission to use, copy, modify, and distribute this software and its .\" documentation for any purpose and without fee is hereby granted, provided .\" that the above copyright notice appear in all copies and that both that .\" copyright notice and this permission notice appear in supporting .\" documentation. This software is provided "as is" without express or .\" implied warranty.