X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=zic2xpm.c;h=12545baebf64b3b12504e1514138a4ebea438e8b;hb=b9c6b5e9fcd6321336ec28f25833530db79b928d;hp=b96817f3fb7c8caf84c8e88ee118a0ec8b17a686;hpb=91d8e5853ca580769cc130aa6ea004869118d171;p=xboard.git diff --git a/zic2xpm.c b/zic2xpm.c index b96817f..12545ba 100644 --- a/zic2xpm.c +++ b/zic2xpm.c @@ -4,7 +4,7 @@ Program to convert pieces from ZIICS format to XPM & XIM format. (C version) By Frank McIngvale . - Copyright (C) 1996,2009 Free Software Foundation, Inc. + Copyright (C) 1996, 2009, 2010, 2011, 2012 Free Software Foundation, Inc. NOTICE: The piece images distributed with ZIICS are copyrighted works of their original creators. Images @@ -115,6 +115,7 @@ typedef struct { } z2xpm; #define NR_ZIICS_COLORS 4 +#define BUFLEN 100 /* SHOWSETS.PAS (from ZIICS) states that images may only use color numbers 0, 2, 14, and 15 */ @@ -131,15 +132,15 @@ z2xpm z2xpm_tab[NR_ZIICS_COLORS] = { { 14, '*', "light_square", "gray" }, { 2, '.', "dark_square", "green" } }; -void fatal( str ) - char *str; +void +fatal (char *str) { printf("Fatal error: %s\n", str ); exit(1); } -z2xim *lookup_xim_color( color ) - int color; +z2xim * +lookup_xim_color (int color) { int i; @@ -155,8 +156,8 @@ z2xim *lookup_xim_color( color ) return NULL; /* Make compiler happy */ } -z2xpm *lookup_xpm_color( color ) - int color; +z2xpm * +lookup_xpm_color (int color) { int i; @@ -174,8 +175,8 @@ z2xpm *lookup_xpm_color( color ) char *src_name; -int up8( i ) - int i; +int +up8 (int i) { int r; @@ -186,8 +187,8 @@ int up8( i ) return i + 8 - r; } -unsigned int vga_imagesize( w, h ) - int w, h; +unsigned int +vga_imagesize (int w, int h) { int w8; unsigned int s; @@ -199,9 +200,8 @@ unsigned int vga_imagesize( w, h ) return s; } -unsigned char *decode_byte( dest, b, w ) - unsigned char *dest, *b; - int w; +unsigned char * +decode_byte (unsigned char *dest, unsigned char *b, int w) { int i, j; unsigned char byte, bit; @@ -231,9 +231,8 @@ unsigned char *decode_byte( dest, b, w ) SRC is in packed pixel format. DEST is filled with 1 BYTE per PIXEL. */ -unsigned char *decode_line( dest, src, w ) - unsigned char *dest, *src; - int w; +unsigned char * +decode_line (unsigned char *dest, unsigned char *src, int w) { unsigned int w8; unsigned int bpp; @@ -265,9 +264,8 @@ unsigned char *decode_line( dest, src, w ) return (src + bpp * 4); } -int write_xim_header( fp, w, h ) - FILE *fp; - int w, h; +int +write_xim_header (FILE *fp, int w, int h) { fputc( w, fp ); fputc( h, fp ); @@ -275,9 +273,8 @@ int write_xim_header( fp, w, h ) return 0; } -int write_xpm_header( fp, w, h ) - FILE *fp; - int w, h; +int +write_xpm_header (FILE *fp, int w, int h) { int i; z2xpm *cv; @@ -307,10 +304,8 @@ int write_xpm_header( fp, w, h ) return 0; } -void create_piece_xim( outname, fpin, W, H ) - char *outname; - FILE *fpin; - int W, H; +void +create_piece_xim (char *outname, FILE *fpin, int W, int H) { FILE *fpout; int w, h, i, j, c; @@ -365,10 +360,8 @@ void create_piece_xim( outname, fpin, W, H ) fclose( fpout ); } -void create_piece_xpm( outname, fpin, W, H ) - char *outname; - FILE *fpin; - int W, H; +void +create_piece_xpm (char *outname, FILE *fpin, int W, int H) { FILE *fpout; int w, h, i, j, c; @@ -434,14 +427,14 @@ char *pname[] = { "Pawn", "Rook", "King", "Queen", "Bishop", "Knight" }; /* The suborder - Light/Light, Light/Dark, etc. */ char *prefixes[] = { "ll", "ld", "dl", "dd" }; -int process_file_xim( filename ) - char *filename; +int +process_file_xim (char *filename) { int w, h, piece, kind, c; int nr_pieces = 6; int nr_kinds = 4; FILE *fp; - char buf[100]; + char buf[BUFLEN]; src_name = filename; @@ -478,18 +471,18 @@ int process_file_xim( filename ) { printf( "." ); /* Form output filename -- .xim */ - sprintf(buf, "%c%s%d.xim", pieces[piece], prefixes[kind], w); + snprintf(buf, BUFLEN, "%c%s%d.xim", pieces[piece], prefixes[kind], w); create_piece_xim( buf, fp, w, h ); } printf("\n"); } /* Write the light & dark squares */ - sprintf( buf, "lsq%d.xim", w ); + snprintf( buf, BUFLEN, "lsq%d.xim", w ); printf("Light Square" ); create_piece_xim( buf, fp, w, h ); - sprintf( buf, "dsq%d.xim", w ); + snprintf( buf, BUFLEN, "dsq%d.xim", w ); printf("\nDark Square" ); create_piece_xim( buf, fp, w, h ); printf("\n"); @@ -501,14 +494,14 @@ int process_file_xim( filename ) return 0; } -int process_file_xpm( filename ) - char *filename; +int +process_file_xpm (char *filename) { int w, h, piece, kind, c; int nr_pieces = 6; int nr_kinds = 4; FILE *fp; - char buf[100]; + char buf[BUFLEN]; src_name = filename; @@ -545,18 +538,18 @@ int process_file_xpm( filename ) { printf( "." ); /* Form output filename -- .xpm */ - sprintf(buf, "%c%s%d.xpm", pieces[piece], prefixes[kind], w); + snprintf(buf, BUFLEN, "%c%s%d.xpm", pieces[piece], prefixes[kind], w); create_piece_xpm( buf, fp, w, h ); } printf("\n"); } /* Write the light & dark squares */ - sprintf( buf, "lsq%d.xpm", w ); + snprintf( buf, BUFLEN, "lsq%d.xpm", w ); printf("Light Square" ); create_piece_xpm( buf, fp, w, h ); - sprintf( buf, "dsq%d.xpm", w ); + snprintf( buf, BUFLEN, "dsq%d.xpm", w ); printf("\nDark Square" ); create_piece_xpm( buf, fp, w, h ); printf("\n"); @@ -568,9 +561,8 @@ int process_file_xpm( filename ) return 0; } -int main( argc, argv ) - int argc; - char *argv[]; +int +main (int argc, char **argv) { int i;