From 3e9f89c7239ae0cf1599277cc879a03cdf33b7c8 Mon Sep 17 00:00:00 2001 From: Kaleb Keithley Date: Mon, 17 Nov 2003 19:03:47 +0000 Subject: merge XFree86 4.3.0.1 to -CURRENT --- bmtoa.c | 40 ++++++++++++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 10 deletions(-) (limited to 'bmtoa.c') diff --git a/bmtoa.c b/bmtoa.c index e7c1e06..145ab10 100644 --- a/bmtoa.c +++ b/bmtoa.c @@ -26,6 +26,7 @@ other dealings in this Software without prior written authorization from The Open Group. */ +/* $XFree86: xc/programs/bitmap/bmtoa.c,v 3.7 2001/12/14 20:00:41 dawes Exp $ */ /* * bmtoa - bitmap to ascii filter @@ -39,13 +40,19 @@ from The Open Group. #include -extern char *malloc(); +#include +#include +#ifndef HAS_MKSTEMP extern char *mktemp(); +#endif char *ProgramName; +static void print_scanline (unsigned int width, unsigned int height, + unsigned char *data, char *chars); -static void usage () +static void +usage (void) { fprintf (stderr, "usage: %s [-options ...] [filename]\n\n", ProgramName); @@ -57,7 +64,8 @@ static void usage () exit (1); } -static char *copy_stdin () +static char * +copy_stdin (void) { #ifdef WIN32 static char tmpfilename[] = "/temp/bmtoa.XXXXXX"; @@ -68,6 +76,7 @@ static char *copy_stdin () FILE *fp; int nread, nwritten; +#ifndef HAS_MKSTEMP if (mktemp (tmpfilename) == NULL) { fprintf (stderr, "%s: unable to genererate temporary file name for stdin.\n", @@ -75,6 +84,17 @@ static char *copy_stdin () exit (1); } fp = fopen (tmpfilename, "w"); +#else + int fd; + + if ((fd = mkstemp(tmpfilename)) < 0) { + fprintf (stderr, + "%s: unable to genererate temporary file name for stdin.\n", + ProgramName); + exit (1); + } + fp = fdopen(fd, "w"); +#endif while (1) { buf[0] = '\0'; nread = fread (buf, 1, sizeof buf, stdin); @@ -93,9 +113,8 @@ static char *copy_stdin () return tmpfilename; } -main (argc, argv) - int argc; - char **argv; +int +main (int argc, char *argv[]) { char *filename = NULL; int isstdin = 0; @@ -153,10 +172,11 @@ main (argc, argv) exit (0); } -print_scanline (width, height, data, chars) - unsigned int width, height; - unsigned char *data; - char *chars; +static void +print_scanline (unsigned int width, + unsigned int height, + unsigned char *data, + char *chars) { char *scanline = (char *) malloc (width + 1); unsigned char *dp = data; -- cgit v1.2.3