~cosme/ubuntu/precise/freeimage/freeimage-3.15.1

« back to all changes in this revision

Viewing changes to Source/LibJPEG/rdjpgcom.c

  • Committer: Bazaar Package Importer
  • Author(s): Cosme Domínguez Díaz
  • Date: 2010-07-20 13:42:15 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20100720134215-xt1454zaedv3b604
Tags: 3.13.1-0ubuntu1
* New upstream release. Closes: (LP: #607800)
 - Updated debian/freeimage-get-orig-source script.
 - Removing no longer necessary debian/patches/* and
   the patch system in debian/rules.
 - Updated debian/rules to work with the new Makefiles.
 - Drop from -O3 to -O2 and use lzma compression saves
   ~10 MB of free space. 
* lintian stuff
 - fixed debhelper-but-no-misc-depends
 - fixed ldconfig-symlink-missing-for-shlib

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 * rdjpgcom.c
3
3
 *
4
4
 * Copyright (C) 1994-1997, Thomas G. Lane.
 
5
 * Modified 2009 by Bill Allombert, Guido Vollbeding.
5
6
 * This file is part of the Independent JPEG Group's software.
6
7
 * For conditions of distribution and use, see the accompanying README file.
7
8
 *
14
15
#define JPEG_CJPEG_DJPEG        /* to get the command-line config symbols */
15
16
#include "jinclude.h"           /* get auto-config symbols, <stdio.h> */
16
17
 
 
18
#ifdef HAVE_LOCALE_H
 
19
#include <locale.h>             /* Bill Allombert: use locale for isprint */
 
20
#endif
17
21
#include <ctype.h>              /* to declare isupper(), tolower() */
18
22
#ifdef USE_SETMODE
19
23
#include <fcntl.h>              /* to declare setmode()'s parameter macros */
218
222
 */
219
223
 
220
224
static void
221
 
process_COM (void)
 
225
process_COM (int raw)
222
226
{
223
227
  unsigned int length;
224
228
  int ch;
225
229
  int lastch = 0;
226
230
 
 
231
  /* Bill Allombert: set locale properly for isprint */
 
232
#ifdef HAVE_LOCALE_H
 
233
  setlocale(LC_CTYPE, "");
 
234
#endif
 
235
 
227
236
  /* Get the marker parameter length count */
228
237
  length = read_2_bytes();
229
238
  /* Length includes itself, so must be at least 2 */
233
242
 
234
243
  while (length > 0) {
235
244
    ch = read_1_byte();
 
245
    if (raw) {
 
246
      putc(ch, stdout);
236
247
    /* Emit the character in a readable form.
237
248
     * Nonprintables are converted to \nnn form,
238
249
     * while \ is converted to \\.
239
250
     * Newlines in CR, CR/LF, or LF form will be printed as one newline.
240
251
     */
241
 
    if (ch == '\r') {
 
252
    } else if (ch == '\r') {
242
253
      printf("\n");
243
254
    } else if (ch == '\n') {
244
255
      if (lastch != '\r')
254
265
    length--;
255
266
  }
256
267
  printf("\n");
 
268
 
 
269
  /* Bill Allombert: revert to C locale */
 
270
#ifdef HAVE_LOCALE_H
 
271
  setlocale(LC_CTYPE, "C");
 
272
#endif
257
273
}
258
274
 
259
275
 
321
337
 */
322
338
 
323
339
static int
324
 
scan_JPEG_header (int verbose)
 
340
scan_JPEG_header (int verbose, int raw)
325
341
{
326
342
  int marker;
327
343
 
362
378
      return marker;
363
379
 
364
380
    case M_COM:
365
 
      process_COM();
 
381
      process_COM(raw);
366
382
      break;
367
383
 
368
384
    case M_APP12:
371
387
       */
372
388
      if (verbose) {
373
389
        printf("APP12 contains:\n");
374
 
        process_COM();
 
390
        process_COM(raw);
375
391
      } else
376
392
        skip_variable();
377
393
      break;
398
414
  fprintf(stderr, "Usage: %s [switches] [inputfile]\n", progname);
399
415
 
400
416
  fprintf(stderr, "Switches (names may be abbreviated):\n");
 
417
  fprintf(stderr, "  -raw        Display non-printable characters in comments (unsafe)\n");
401
418
  fprintf(stderr, "  -verbose    Also display dimensions of JPEG image\n");
402
419
 
403
420
  exit(EXIT_FAILURE);
438
455
{
439
456
  int argn;
440
457
  char * arg;
441
 
  int verbose = 0;
 
458
  int verbose = 0, raw = 0;
442
459
 
443
460
  /* On Mac, fetch a command line. */
444
461
#ifdef USE_CCOMMAND
457
474
    arg++;                      /* advance over '-' */
458
475
    if (keymatch(arg, "verbose", 1)) {
459
476
      verbose++;
 
477
    } else if (keymatch(arg, "raw", 1)) {
 
478
      raw = 1;
460
479
    } else
461
480
      usage();
462
481
  }
488
507
  }
489
508
 
490
509
  /* Scan the JPEG headers. */
491
 
  (void) scan_JPEG_header(verbose);
 
510
  (void) scan_JPEG_header(verbose, raw);
492
511
 
493
512
  /* All done. */
494
513
  exit(EXIT_SUCCESS);