15 #define JPEG_CJPEG_DJPEG 38 #ifdef DONT_USE_B_MODE 39 #define READ_BINARY "r" 40 #define WRITE_BINARY "w" 43 #define READ_BINARY "rb", "ctx=stm" 44 #define WRITE_BINARY "wb", "ctx=stm" 46 #define READ_BINARY "rb" 47 #define WRITE_BINARY "wb" 52 #define EXIT_FAILURE 1 56 #define EXIT_SUCCESS 1 58 #define EXIT_SUCCESS 0 66 #ifndef MAX_COM_LENGTH 67 #define MAX_COM_LENGTH 65000L 79 #define NEXTBYTE() getc(infile) 84 #define PUTBYTE(x) putc((x), outfile) 88 #define ERREXIT(msg) (fprintf(stderr, "%s\n", msg), exit(EXIT_FAILURE)) 99 ERREXIT(
"Premature EOF in JPEG file");
112 ERREXIT(
"Premature EOF in JPEG file");
115 ERREXIT(
"Premature EOF in JPEG file");
116 return (((
unsigned int) c1) << 8) + ((
unsigned int) c2);
191 int discarded_bytes = 0;
206 if (discarded_bytes != 0) {
207 fprintf(
stderr,
"Warning: garbage data found in JPEG file\n");
229 if (c1 != 0xFF || c2 !=
M_SOI)
255 ERREXIT(
"Erroneous JPEG marker length");
274 ERREXIT(
"Erroneous JPEG marker length");
296 ERREXIT(
"Expected SOI marker first");
322 ERREXIT(
"SOS without prior SOFn");
355 fprintf(
stderr,
"wrjpgcom inserts a textual comment in a JPEG file.\n");
356 fprintf(
stderr,
"You can add to or replace any existing comment(s).\n");
359 #ifdef TWO_FILE_COMMANDLINE 367 fprintf(
stderr,
" -comment \"text\" Insert comment with given text\n");
368 fprintf(
stderr,
" -cfile name Read comment from named file\n");
369 fprintf(
stderr,
"Notice that you must put quotes around the comment text\n");
371 fprintf(
stderr,
"If you do not give either -comment or -cfile on the command line,\n");
372 fprintf(
stderr,
"then the comment text is read from standard input.\n");
373 fprintf(
stderr,
"It can be multiple lines, up to %u characters total.\n",
375 #ifndef TWO_FILE_COMMANDLINE 376 fprintf(
stderr,
"You must specify an input JPEG file name when supplying\n");
391 register int nmatched = 0;
393 while ((
ca = *
arg++) !=
'\0') {
419 char * comment_arg =
NULL;
421 unsigned int comment_length = 0;
434 for (argn = 1; argn <
argc; argn++) {
449 comment_arg =
argv[argn];
453 if (comment_arg[0] ==
'"') {
455 if (comment_arg ==
NULL)
456 ERREXIT(
"Insufficient memory");
464 comment_length = (
unsigned int)
strlen(comment_arg);
465 if (comment_length > 0 && comment_arg[comment_length-1] ==
'"') {
466 comment_arg[comment_length-1] =
'\0';
470 ERREXIT(
"Missing ending quote mark");
485 comment_length = (
unsigned int)
strlen(comment_arg);
491 if (comment_arg !=
NULL && comment_file !=
NULL)
496 if (comment_arg ==
NULL && comment_file ==
NULL && argn >=
argc)
521 #ifdef TWO_FILE_COMMANDLINE 523 if (argn !=
argc-2) {
524 fprintf(
stderr,
"%s: must name one input and one output file\n",
553 if (comment_arg ==
NULL) {
558 if (comment_arg ==
NULL)
559 ERREXIT(
"Insufficient memory");
561 src_file = (comment_file !=
NULL ? comment_file :
stdin);
562 while ((
c =
getc(src_file)) !=
EOF) {
568 comment_arg[comment_length++] = (
char)
c;
570 if (comment_file !=
NULL)
582 if (comment_length > 0) {
585 while (comment_length > 0) {
static int scan_JPEG_header(int keep_COM)
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
char * strcat(char *DstString, const char *SrcString)
ACPI_SIZE strlen(const char *String)
static const char * progname
_Check_return_ _CRTIMP int __cdecl getc(_Inout_ FILE *_File)
static void write_1_byte(int c)
static void write_2_bytes(unsigned int val)
static void skip_variable(void)
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
GLenum GLuint GLenum GLsizei length
static void write_marker(int marker)
static int next_marker(void)
static int read_1_byte(void)
_Check_return_ _CRTIMP int __cdecl fileno(_In_ FILE *_File)
int main(int argc, char **argv)
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)
_Check_return_ _CRTIMP FILE *__cdecl fopen(_In_z_ const char *_Filename, _In_z_ const char *_Mode)
_Check_return_ _CRTIMP int __cdecl setmode(_In_ int _FileHandle, _In_ int _Mode)
static void copy_rest_of_file(void)
_Check_return_ _CRTIMP FILE *__cdecl fdopen(_In_ int _FileHandle, _In_z_ const char *_Format)
static int first_marker(void)
static void copy_variable(void)
char * strcpy(char *DstString, const char *SrcString)
static unsigned int read_2_bytes(void)
static int keymatch(char *arg, const char *keyword, int minchars)
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *