cdjpeg.c File Reference

#include "cdjpeg.h"
#include <ctype.h>

Go to the source code of this file.

Functions

 keymatch (char *arg, const char *keyword, int minchars)
 read_stdin (void)
 write_stdout (void)


Function Documentation

keymatch ( char *  arg,
const char *  keyword,
int  minchars 
)

Definition at line 122 of file cdjpeg.c.

References FALSE, and TRUE.

Referenced by main(), and parse_switches().

00123 {
00124   register int ca, ck;
00125   register int nmatched = 0;
00126 
00127   while ((ca = *arg++) != '\0') {
00128     if ((ck = *keyword++) == '\0')
00129       return FALSE;     /* arg longer than keyword, no good */
00130     if (isupper(ca))        /* force arg to lcase (assume ck is already) */
00131       ca = tolower(ca);
00132     if (ca != ck)
00133       return FALSE;     /* no good */
00134     nmatched++;         /* count matched characters */
00135   }
00136   /* reached end of argument; fail if it's too short for unique abbrev */
00137   if (nmatched < minchars)
00138     return FALSE;
00139   return TRUE;          /* A-OK */
00140 }

read_stdin ( void   ) 

Definition at line 149 of file cdjpeg.c.

References EXIT_FAILURE, and READ_BINARY.

Referenced by main().

00150 {
00151   FILE * input_file = stdin;
00152 
00153 #ifdef USE_SETMODE      /* need to hack file mode? */
00154   setmode(fileno(stdin), O_BINARY);
00155 #endif
00156 #ifdef USE_FDOPEN       /* need to re-open in binary mode? */
00157   if ((input_file = fdopen(fileno(stdin), READ_BINARY)) == NULL) {
00158     fprintf(stderr, "Cannot reopen stdin\n");
00159     exit(EXIT_FAILURE);
00160   }
00161 #endif
00162   return input_file;
00163 }

write_stdout ( void   ) 

Definition at line 167 of file cdjpeg.c.

References EXIT_FAILURE, and WRITE_BINARY.

Referenced by main().

00168 {
00169   FILE * output_file = stdout;
00170 
00171 #ifdef USE_SETMODE      /* need to hack file mode? */
00172   setmode(fileno(stdout), O_BINARY);
00173 #endif
00174 #ifdef USE_FDOPEN       /* need to re-open in binary mode? */
00175   if ((output_file = fdopen(fileno(stdout), WRITE_BINARY)) == NULL) {
00176     fprintf(stderr, "Cannot reopen stdout\n");
00177     exit(EXIT_FAILURE);
00178   }
00179 #endif
00180   return output_file;
00181 }


Generated on Fri Feb 19 02:31:01 2010 for AVR32 - IJG JPEG Decoder Example by  doxygen 1.5.5