ReactOS  0.4.14-dev-608-gd495a4f
cdjpeg.c File Reference
#include "cdjpeg.h"
#include <ctype.h>
Include dependency graph for cdjpeg.c:

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()

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

Definition at line 122 of file cdjpeg.c.

123 {
124  register int ca, ck;
125  register int nmatched = 0;
126 
127  while ((ca = *arg++) != '\0') {
128  if ((ck = *keyword++) == '\0')
129  return FALSE; /* arg longer than keyword, no good */
130  if (isupper(ca)) /* force arg to lcase (assume ck is already) */
131  ca = tolower(ca);
132  if (ca != ck)
133  return FALSE; /* no good */
134  nmatched++; /* count matched characters */
135  }
136  /* reached end of argument; fail if it's too short for unique abbrev */
137  if (nmatched < minchars)
138  return FALSE;
139  return TRUE; /* A-OK */
140 }
#define TRUE
Definition: types.h:120
const char int minchars
Definition: cdjpeg.h:152
#define isupper(c)
Definition: acclib.h:71
static const WCHAR ca[]
Definition: main.c:455
int tolower(int c)
Definition: utclib.c:902

Referenced by parse_switches().

◆ read_stdin()

read_stdin ( void  )

Definition at line 149 of file cdjpeg.c.

150 {
151  FILE * input_file = stdin;
152 
153 #ifdef USE_SETMODE /* need to hack file mode? */
155 #endif
156 #ifdef USE_FDOPEN /* need to re-open in binary mode? */
157  if ((input_file = fdopen(fileno(stdin), READ_BINARY)) == NULL) {
158  fprintf(stderr, "Cannot reopen stdin\n");
160  }
161 #endif
162  return input_file;
163 }
#define READ_BINARY
Definition: jmemdos.c:77
FILE * stdin
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
smooth NULL
Definition: ftsmooth.c:416
_Check_return_ _CRTIMP int __cdecl fileno(_In_ FILE *_File)
#define EXIT_FAILURE
Definition: jerror.c:33
_Check_return_ _CRTIMP int __cdecl setmode(_In_ int _FileHandle, _In_ int _Mode)
#define O_BINARY
Definition: acwin.h:109
_Check_return_ _CRTIMP FILE *__cdecl fdopen(_In_ int _FileHandle, _In_z_ const char *_Format)
FILE * stderr
void exit(int exitcode)
Definition: _exit.c:33

Referenced by main().

◆ write_stdout()

write_stdout ( void  )

Definition at line 167 of file cdjpeg.c.

168 {
169  FILE * output_file = stdout;
170 
171 #ifdef USE_SETMODE /* need to hack file mode? */
173 #endif
174 #ifdef USE_FDOPEN /* need to re-open in binary mode? */
175  if ((output_file = fdopen(fileno(stdout), WRITE_BINARY)) == NULL) {
176  fprintf(stderr, "Cannot reopen stdout\n");
178  }
179 #endif
180  return output_file;
181 }
FILE * stdout
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
smooth NULL
Definition: ftsmooth.c:416
_Check_return_ _CRTIMP int __cdecl fileno(_In_ FILE *_File)
#define EXIT_FAILURE
Definition: jerror.c:33
_Check_return_ _CRTIMP int __cdecl setmode(_In_ int _FileHandle, _In_ int _Mode)
#define WRITE_BINARY
Definition: wrjpgcom.c:47
#define O_BINARY
Definition: acwin.h:109
_Check_return_ _CRTIMP FILE *__cdecl fdopen(_In_ int _FileHandle, _In_z_ const char *_Format)
FILE * stderr
void exit(int exitcode)
Definition: _exit.c:33

Referenced by main().