home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / misc / volume36 / chiaro / part12 < prev    next >
Encoding:
Text File  |  1993-03-25  |  55.2 KB  |  1,637 lines

  1. Newsgroups: comp.sources.misc
  2. From: jwbirdsa@picarefy.picarefy.com (James W. Birdsall)
  3. Subject: v36i082:  chiaro - Image Utilities, Part12/18
  4. Message-ID: <1993Mar26.202831.14773@sparky.imd.sterling.com>
  5. X-Md4-Signature: 9695f50e3725082a8f6fa0cb9b14d584
  6. Date: Fri, 26 Mar 1993 20:28:31 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: jwbirdsa@picarefy.picarefy.com (James W. Birdsall)
  10. Posting-number: Volume 36, Issue 82
  11. Archive-name: chiaro/part12
  12. Environment: UNIX, Sun, DECstation, 3B1
  13.  
  14. #! /bin/sh
  15. # This is a shell archive.  Remove anything before this line, then feed it
  16. # into a shell via "sh file" or similar.  To overwrite existing files,
  17. # type "sh file -c".
  18. # Contents:  src/bmp.c src/gifcheck.1
  19. # Wrapped by kent@sparky on Thu Mar 25 11:20:05 1993
  20. PATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:/usr/lbin ; export PATH
  21. echo If this archive is complete, you will see the following message:
  22. echo '          "shar: End of archive 12 (of 18)."'
  23. if test -f 'src/bmp.c' -a "${1}" != "-c" ; then 
  24.   echo shar: Will not clobber existing file \"'src/bmp.c'\"
  25. else
  26.   echo shar: Extracting \"'src/bmp.c'\" \(19928 characters\)
  27.   sed "s/^X//" >'src/bmp.c' <<'END_OF_FILE'
  28. X/***************************************************************************
  29. X*   BMP.C                                                                  *
  30. X*   MODULE:  BMP                                                           *
  31. X*   OS:      UNIX                                                          *
  32. X*                                                                          *
  33. X*   Copyright (c) 1993 James W. Birdsall. All Rights Reserved.             *
  34. X*                                                                          *
  35. X*   $Id: bmp.c,v 1.2 1993/03/02 00:52:42 jwbirdsa Exp $
  36. X*                                                                          *
  37. X*   This file contains functions to process BMP format files.              *
  38. X*   Functions:                                                             *
  39. X*      bmp_verify    - checks filename to see if it is an BMP file         *
  40. X*      bmp_getheader - extracts header data from BMP file                  *
  41. X*                                                                          *
  42. X*      bmp_errstring - converts error code into message                    *
  43. X*                                                                          *
  44. X***************************************************************************/
  45. X
  46. X#include "config.h"
  47. X
  48. X/*
  49. X** system includes <>
  50. X*/
  51. X
  52. X#include <stdio.h>
  53. X#ifndef NO_STR_INC
  54. X#ifdef STRING_PLURAL
  55. X#include <strings.h>
  56. X#else
  57. X#include <string.h>
  58. X#endif
  59. X#endif
  60. X
  61. X
  62. X/*
  63. X** custom includes ""
  64. X*/
  65. X
  66. X#include "depend.h"
  67. X#include "formats.h"
  68. X#include "bmp.h"
  69. X
  70. X
  71. X/*
  72. X** local #defines
  73. X*/
  74. X
  75. X/*
  76. X** misc: copyright strings, version macros, etc.
  77. X*/
  78. X
  79. X/*
  80. X** typedefs
  81. X*/
  82. X
  83. X/*
  84. X** global variables
  85. X*/
  86. X
  87. X/*
  88. X** static globals
  89. X*/
  90. X
  91. Xstatic char CONST rcsid[] = "$Id: bmp.c,v 1.2 1993/03/02 00:52:42 jwbirdsa Exp $";
  92. X
  93. X
  94. X/*
  95. X** function prototypes
  96. X*/
  97. X
  98. X#ifdef NO_STR_INC
  99. Xextern char *strrchr();
  100. Xextern int strcmp();
  101. X#endif
  102. X
  103. X
  104. X/*
  105. X** functions
  106. X*/
  107. X
  108. X
  109. X/***************************************************************************
  110. X*   FUNCTION:    bmp_verify                                                *
  111. X*                                                                          *
  112. X*   DESCRIPTION:                                                           *
  113. X*                                                                          *
  114. X*       Verifies that a file is an BMP file by checking filename against   *
  115. X*       list of extensions. Reads BMP magic number from start of file.     *
  116. X*                                                                          *
  117. X*   ENTRY:                                                                 *
  118. X*                                                                          *
  119. X*       filename - name of file to be verified                             *
  120. X*       version  - pointer to unsigned long in which format/version value  *
  121. X*                  is returned                                             *
  122. X*       exts     - array of string pointers, list of extensions for BMP    *
  123. X*                  files                                                   *
  124. X*                                                                          *
  125. X*   EXIT:                                                                  *
  126. X*                                                                          *
  127. X*       Returns an error/status code.                                      *
  128. X*                                                                          *
  129. X*   CONSTRAINTS/SIDE EFFECTS:                                              *
  130. X*                                                                          *
  131. X***************************************************************************/
  132. XULONG
  133. X#ifdef __STDC__
  134. Xbmp_verify(char *filename, ULONG *version, char **exts)
  135. X#else
  136. Xbmp_verify(filename, version, exts)
  137. Xchar *filename;
  138. XULONG *version;
  139. Xchar **exts;
  140. X#endif
  141. X{
  142. X    char *extptr;
  143. X    int loop;
  144. X    int magic;
  145. X    FILE *bmpfile;
  146. X    char buffer[4];
  147. X    ULONG infolen;
  148. X    ULONG retval;
  149. X
  150. X    /* Search for '.' marking extension. */
  151. X
  152. X    extptr = strrchr(filename, '.');
  153. X    if (NULL == extptr)
  154. X    {
  155. X        /* No extension, cannot classify. */
  156. X
  157. X        *version = BMP_NOT;
  158. X        return 0;
  159. X    }
  160. X    extptr++;
  161. X
  162. X    /* Now we have the extension, check against list. */
  163. X
  164. X    for (loop = 0; exts[loop] != NULL; loop++)
  165. X    {
  166. X        /* Case-sensitive string compare. */
  167. X
  168. X        if (strcmp(extptr, exts[loop]) == 0)
  169. X        {
  170. X            /* Match, so break out of loop. */
  171. X
  172. X            break;
  173. X        }
  174. X    }
  175. X
  176. X    /* Check exit from loop. */
  177. X
  178. X    if (NULL == exts[loop])
  179. X    {
  180. X        /* No match, return. */
  181. X
  182. X        *version = BMP_NOT;
  183. X        return 0;
  184. X    }
  185. X
  186. X    /* Extension is valid for type BMP, so process accordingly. */
  187. X
  188. X    if ((bmpfile = fopen(filename, FOPEN_READ_BINARY)) == (FILE *) NULL)
  189. X    {
  190. X        return BMP_FILEERR_E;
  191. X    }
  192. X
  193. X    /* Read magic number. */
  194. X
  195. X    if ((magic = fgetc(bmpfile)) == EOF)
  196. X    {
  197. X        *version = BMP_NOT;
  198. X        retval = (feof(bmpfile) ? ST_SUCCESS : BMP_FILEERR_E);
  199. X        fclose(bmpfile);
  200. X        return retval;
  201. X    }
  202. X    if (2 == magic)
  203. X    {
  204. X        *version = BMP_WIN2;
  205. X    }
  206. X    else if ('B' == magic)
  207. X    {
  208. X        /* Read more magic number. */
  209. X
  210. X        if (((magic = fgetc(bmpfile)) == EOF) || (magic != 'M'))
  211. X        {
  212. X            *version = BMP_NOT;
  213. X            retval = (feof(bmpfile) ? ST_SUCCESS : BMP_FILEERR_E);
  214. X            fclose(bmpfile);
  215. X            return retval;
  216. X        }
  217. X
  218. X        if (fseek(bmpfile, (long) BMP_HDR_INFOLEN_OFF, SEEK_SET))
  219. X        {
  220. X            *version = BMP_NOT;
  221. X            fclose(bmpfile);
  222. X            return BMP_FILEERR_E;
  223. X        }
  224. X
  225. X        if (fread(buffer, sizeof(char), 4, bmpfile) != 4)
  226. X        {
  227. X            *version = BMP_NOT;
  228. X            retval = (feof(bmpfile) ? ST_SUCCESS : BMP_FILEERR_E);
  229. X            fclose(bmpfile);
  230. X            return retval;
  231. X        }
  232. X
  233. X        if ((infolen = CONSTRUCT_I_ULONG(buffer)) >= MKLONG(65536))
  234. X        {
  235. X            *version = BMP_NOT;
  236. X            return (fclose(bmpfile) ? BMP_FILEERR_E : ST_SUCCESS);
  237. X        }
  238. X        switch ((int)(infolen))
  239. X        {
  240. X            case BMP_HDR11_INFOLEN_VAL:
  241. X                *version = BMP_OS2_11;
  242. X                break;
  243. X
  244. X            case BMP_HDR3_INFOLEN_VAL:
  245. X                *version = BMP_WIN3;
  246. X                break;
  247. X
  248. X            case BMP_HDR20_INFOLEN_VAL:
  249. X                *version = BMP_OS2_20;
  250. X                break;
  251. X
  252. X            default:
  253. X                *version = (((infolen > BMP_HDR3_INFOLEN_VAL) &&
  254. X                             (infolen < BMP_HDR20_INFOLEN_VAL)) ?
  255. X                            BMP_OS2_20 : BMP_NOT);
  256. X                break;
  257. X        }
  258. X    }            
  259. X
  260. X    /* Close file. */
  261. X
  262. X    if (fclose(bmpfile))
  263. X    {
  264. X        return BMP_FILEERR_E;
  265. X    }
  266. X
  267. X    /* Return OK. */
  268. X
  269. X    return 0;
  270. X} /* end of bmp_verify() */
  271. X
  272. X
  273. X/***************************************************************************
  274. X*   FUNCTION:    bmp_getheader                                             *
  275. X*                                                                          *
  276. X*   DESCRIPTION:                                                           *
  277. X*                                                                          *
  278. X*       Assumes that file is an BMP file. Reads header from file, extracts *
  279. X*       data into BMP_HDR structure.                                       *
  280. X*                                                                          *
  281. X*   ENTRY:                                                                 *
  282. X*                                                                          *
  283. X*       infile  - file to be processed                                     *
  284. X*       results - pointer to BMP_HDR structure in which data from header   *
  285. X*                 is returned                                              *
  286. X*                                                                          *
  287. X*   EXIT:                                                                  *
  288. X*                                                                          *
  289. X*       Returns an error/status code.                                      *
  290. X*                                                                          *
  291. X*   CONSTRAINTS/SIDE EFFECTS:                                              *
  292. X*                                                                          *
  293. X*       Leaves file pointing to beginning of image data.                   *
  294. X*                                                                          *
  295. X***************************************************************************/
  296. XULONG
  297. X#ifdef __STDC__
  298. Xbmp_getheader(FILE *infile, BMP_HDR *results)
  299. X#else
  300. Xbmp_getheader(infile, results)
  301. XFILE *infile;
  302. XBMP_HDR *results;
  303. X#endif
  304. X{
  305. X    UCHAR rawhdr[BMP_HDR20_LEN];
  306. X    int validbytes;
  307. X    ULONG infolen;
  308. X
  309. X    /* Make sure we're at beginning of file. */
  310. X
  311. X    if (fseek(infile, 0L, SEEK_SET))
  312. X    {
  313. X        return BMP_FILEERR_E;
  314. X    }
  315. X
  316. X    /* Read raw bytes into buffer. */
  317. X
  318. X    if ((validbytes = fread(rawhdr, sizeof(UCHAR), BMP_HDR20_LEN, infile)) <
  319. X        BMP_HDR2_LEN)
  320. X    {
  321. X        return (feof(infile) ? BMP_UNEOF_E : BMP_FILEERR_E);
  322. X    }
  323. X
  324. X    /* Extract version from raw header. */
  325. X
  326. X    if (2 == *(rawhdr + BMP_HDR2_MAGIC_OFF))
  327. X    {
  328. X        /* Is a WIN2 BMP, very different. */
  329. X
  330. X        results->version = BMP_WIN2;
  331. X    }
  332. X    else if (('B' == *(rawhdr + BMP_HDR_MAGIC_OFF)) &&
  333. X             ('M' == *(rawhdr + BMP_HDR_MAGIC_OFF + 1)) &&
  334. X             (validbytes >= BMP_HDR11_LEN))
  335. X    {
  336. X        /* Is one of the OS2 or WIN3 BMPs. */
  337. X
  338. X        switch (infolen = CONSTRUCT_I_ULONG(rawhdr + BMP_HDR_INFOLEN_OFF))
  339. X        {
  340. X            case BMP_HDR11_INFOLEN_VAL:
  341. X                results->version = BMP_OS2_11;
  342. X                break;
  343. X
  344. X            case BMP_HDR3_INFOLEN_VAL:
  345. X                results->version = BMP_WIN3;
  346. X                break;
  347. X
  348. X            case BMP_HDR20_INFOLEN_VAL:
  349. X                results->version = BMP_OS2_20;
  350. X                break;
  351. X
  352. X            default:
  353. X                results->version = (((infolen > BMP_HDR3_INFOLEN_VAL) &&
  354. X                                     (infolen < BMP_HDR20_INFOLEN_VAL)) ?
  355. X                                    BMP_OS2_20 : BMP_NOT);
  356. X                break;
  357. X        }
  358. X        if (BMP_NOT == results->version)
  359. X        {
  360. X            return BMP_NOTBMP_E;
  361. X        }
  362. X    }
  363. X    else
  364. X    {
  365. X        results->version = BMP_NOT;
  366. X        return BMP_NOTBMP_E;
  367. X    }
  368. X
  369. X    switch (FORMAT_VERS(results->version))
  370. X    {
  371. X        case FORMAT_VERS(BMP_WIN2):
  372. X            results->imwid = (ULONG)CONSTRUCT_I_UINT(rawhdr+BMP_HDR2_IMWID_OFF);
  373. X            results->imhi = (ULONG)CONSTRUCT_I_UINT(rawhdr + BMP_HDR2_IMHI_OFF);
  374. X            results->planes = CONSTRUCT_I_UINT(rawhdr + BMP_HDR2_PLANES_OFF);
  375. X            results->pixbits = CONSTRUCT_I_UINT(rawhdr + BMP_HDR2_BITS_OFF);
  376. X            results->dataoffset = 16;
  377. X            if ((results->more = ((VOID *) malloc(sizeof(BMP_H2)))) != NULL)
  378. X            {
  379. X                ((BMP_H2 *) results->more)->discardable = 
  380. X                                          (int)(*(rawhdr + BMP_HDR2_DISC_OFF));
  381. X            }
  382. X            break;
  383. X
  384. X        case FORMAT_VERS(BMP_OS2_11):
  385. X            results->imwid = (ULONG) 
  386. X                             CONSTRUCT_I_UINT(rawhdr+BMP_HDR11_IMWID_OFF);
  387. X            results->imhi = (ULONG)
  388. X                            CONSTRUCT_I_UINT(rawhdr + BMP_HDR11_IMHI_OFF);
  389. X            results->planes = CONSTRUCT_I_UINT(rawhdr + BMP_HDR11_PLANES_OFF);
  390. X            results->pixbits = CONSTRUCT_I_UINT(rawhdr + BMP_HDR11_BITS_OFF); 
  391. X            results->dataoffset = CONSTRUCT_I_ULONG(rawhdr + BMP_HDR_HLEN_OFF);
  392. X            if ((results->more = ((VOID *) malloc(sizeof(BMP_H11)))) != NULL)
  393. X            {
  394. X                ((BMP_H11 *) results->more)->filesize =
  395. X                                 CONSTRUCT_I_ULONG(rawhdr + BMP_HDR_FSIZE_OFF);
  396. X            }
  397. X            break;
  398. X
  399. X        case FORMAT_VERS(BMP_WIN3):
  400. X            results->imwid = (ULONG)CONSTRUCT_I_UINT(rawhdr+BMP_HDR3_IMWID_OFF);
  401. X            results->imhi = (ULONG)CONSTRUCT_I_UINT(rawhdr + BMP_HDR3_IMHI_OFF);
  402. X            results->planes = CONSTRUCT_I_UINT(rawhdr + BMP_HDR3_PLANES_OFF);
  403. X            results->pixbits = CONSTRUCT_I_UINT(rawhdr + BMP_HDR3_BITS_OFF); 
  404. X            results->dataoffset = CONSTRUCT_I_ULONG(rawhdr + BMP_HDR_HLEN_OFF);
  405. X            if ((results->more = ((VOID *) malloc(sizeof(BMP_H3)))) != NULL)
  406. X            {
  407. X                BMP_H3 *more = (BMP_H3 *) results->more;
  408. X
  409. X                more->more.filesize = 
  410. X                                 CONSTRUCT_I_ULONG(rawhdr + BMP_HDR_FSIZE_OFF);
  411. X                more->compression =
  412. X                                 CONSTRUCT_I_ULONG(rawhdr + BMP_HDR3_COMPR_OFF);
  413. X                more->compsize = CONSTRUCT_I_ULONG(rawhdr + BMP_HDR3_CSIZE_OFF);
  414. X                more->xres = CONSTRUCT_I_ULONG(rawhdr + BMP_HDR3_XRES_OFF);
  415. X                more->yres = CONSTRUCT_I_ULONG(rawhdr + BMP_HDR3_YRES_OFF);
  416. X                more->clrused =CONSTRUCT_I_ULONG(rawhdr + BMP_HDR3_CLRUSED_OFF);
  417. X                more->clrimp = CONSTRUCT_I_ULONG(rawhdr + BMP_HDR3_CLRIMP_OFF);
  418. X            }
  419. X            break;
  420. X
  421. X        case FORMAT_VERS(BMP_OS2_20):
  422. X            results->imwid = (ULONG)CONSTRUCT_I_UINT(rawhdr+BMP_HDR3_IMWID_OFF);
  423. X            results->imhi = (ULONG)CONSTRUCT_I_UINT(rawhdr + BMP_HDR3_IMHI_OFF);
  424. X            results->planes = CONSTRUCT_I_UINT(rawhdr + BMP_HDR3_PLANES_OFF);
  425. X            results->pixbits = CONSTRUCT_I_UINT(rawhdr + BMP_HDR3_BITS_OFF); 
  426. X            results->dataoffset = CONSTRUCT_I_ULONG(rawhdr + BMP_HDR_HLEN_OFF);
  427. X            if ((results->more = ((VOID *) malloc(sizeof(BMP_H20)))) != NULL)
  428. X            {
  429. X                BMP_H20 *more = (BMP_H20 *) results->more;
  430. X
  431. X                more->more.more.filesize = 
  432. X                                 CONSTRUCT_I_ULONG(rawhdr + BMP_HDR_FSIZE_OFF);
  433. X
  434. X                /*
  435. X                ** At last! A real use for fall-through in a switch.
  436. X                ** The header of an OS/2 2.0 bitmap may be truncated anywhere
  437. X                ** after the bits per pixel field. So we zero out all fields
  438. X                ** in the structure and use fall-through to collect whatever
  439. X                ** ones are present.
  440. X                */
  441. X
  442. X                more->more.compression = 0;
  443. X                more->more.compsize = 0;
  444. X                more->more.xres = 0;
  445. X                more->more.yres = 0;
  446. X                more->more.clrused = 0;
  447. X                more->more.clrimp = 0;
  448. X                more->resunits = 0;
  449. X                more->origin = 0;
  450. X                more->halfalg = 0;
  451. X                more->half1 = 0;
  452. X                more->half2 = 0;
  453. X                more->clrencode = 0;
  454. X                more->appdata = 0;
  455. X
  456. X                switch (infolen + BMP_HDR_INFOLEN_OFF)
  457. X                {
  458. X                    case BMP_HDR20_APPDATA_OFF:
  459. X                        more->appdata = 
  460. X                              CONSTRUCT_I_ULONG(rawhdr + BMP_HDR20_APPDATA_OFF);
  461. X                    case BMP_HDR20_CLRENC_OFF:
  462. X                        more->clrencode =
  463. X                               CONSTRUCT_I_ULONG(rawhdr + BMP_HDR20_CLRENC_OFF);
  464. X                    case BMP_HDR20_HALF2_OFF:
  465. X                        more->half2 =
  466. X                               CONSTRUCT_I_ULONG(rawhdr + BMP_HDR20_HALF2_OFF);
  467. X                    case BMP_HDR20_HALF1_OFF:
  468. X                        more->half1 =
  469. X                               CONSTRUCT_I_ULONG(rawhdr + BMP_HDR20_HALF1_OFF);
  470. X                    case BMP_HDR20_HALFALG_OFF:
  471. X                        more->halfalg =
  472. X                               CONSTRUCT_I_UINT(rawhdr + BMP_HDR20_HALFALG_OFF);
  473. X                    case BMP_HDR20_ORIENT_OFF:
  474. X                        more->origin =
  475. X                               CONSTRUCT_I_UINT(rawhdr + BMP_HDR20_ORIENT_OFF);
  476. X                    case BMP_HDR20_RESUNITS_OFF:
  477. X                        more->resunits =
  478. X                              CONSTRUCT_I_UINT(rawhdr + BMP_HDR20_RESUNITS_OFF);
  479. X                    case BMP_HDR3_CLRIMP_OFF:
  480. X                        more->more.clrimp =
  481. X                               CONSTRUCT_I_ULONG(rawhdr + BMP_HDR3_CLRIMP_OFF);
  482. X                    case BMP_HDR3_CLRUSED_OFF:
  483. X                        more->more.clrused =
  484. X                               CONSTRUCT_I_ULONG(rawhdr + BMP_HDR3_CLRUSED_OFF);
  485. X                    case BMP_HDR3_YRES_OFF:
  486. X                        more->more.yres =
  487. X                               CONSTRUCT_I_ULONG(rawhdr + BMP_HDR3_YRES_OFF);
  488. X                    case BMP_HDR3_XRES_OFF:
  489. X                        more->more.xres =
  490. X                               CONSTRUCT_I_ULONG(rawhdr + BMP_HDR3_XRES_OFF);
  491. X                    case BMP_HDR3_CSIZE_OFF:
  492. X                        more->more.compsize =
  493. X                               CONSTRUCT_I_ULONG(rawhdr + BMP_HDR3_CSIZE_OFF);
  494. X                    case BMP_HDR3_COMPR_OFF:
  495. X                        more->more.compression =
  496. X                               CONSTRUCT_I_ULONG(rawhdr + BMP_HDR3_COMPR_OFF);
  497. X                        break;
  498. X
  499. X                    default:
  500. X                        /* Something very bad has happened. */
  501. X
  502. X                        results->version = BMP_NOT;
  503. X                        return BMP_NOTBMP_E;
  504. X                        break;
  505. X                }
  506. X            }
  507. X            break;
  508. X
  509. X        default:
  510. X            /* Something very bad has happened. */
  511. X
  512. X            results->version = BMP_NOT;
  513. X            return BMP_NOTBMP_E;
  514. X            break;
  515. X    }
  516. X
  517. X    /* Set file to point to start of colormap or data. */
  518. X
  519. X    if (fseek(infile, 
  520. X              ((BMP_WIN2 == results->version) ?
  521. X               16L : (long)(infolen + BMP_HDR_INFOLEN_OFF)), SEEK_SET))
  522. X    {
  523. X        return BMP_FILEERR_E;
  524. X    }
  525. X
  526. X    /* Return OK. */
  527. X
  528. X    return 0;
  529. X} /* end of bmp_getheader() */
  530. X
  531. X
  532. X/***************************************************************************
  533. X*   FUNCTION: bmp_errstring                                                *
  534. X*                                                                          *
  535. X*   DESCRIPTION:                                                           *
  536. X*                                                                          *
  537. X*      Returns a string corresponding to an error code.                    *
  538. X*                                                                          *
  539. X*   ENTRY:                                                                 *
  540. X*                                                                          *
  541. X*      errcode - error code to be translated                               *
  542. X*                                                                          *
  543. X*   EXIT:                                                                  *
  544. X*                                                                          *
  545. X*      Returns a pointer to the appropriate string, or NULL if there is    *
  546. X*      no appropriate string.                                              *
  547. X*                                                                          *
  548. X*   CONSTRAINTS/SIDE EFFECTS:                                              *
  549. X*                                                                          *
  550. X***************************************************************************/
  551. Xchar *
  552. X#ifdef __STDC__
  553. Xbmp_errstring(ULONG errcode)
  554. X#else
  555. Xbmp_errstring(errcode)
  556. XULONG errcode;
  557. X#endif
  558. X{
  559. X    char *temp;
  560. X
  561. X    /* If error code not from this module, return NULL. */
  562. X
  563. X    if ((errcode & ST_MOD_MASK) != BMP_MODULE)
  564. X    {
  565. X        return NULL;
  566. X    }
  567. X
  568. X    /* Process by code. */
  569. X
  570. X    switch (ERRSEV(errcode))
  571. X    {
  572. X        case ERRSEV(BMP_NOTBMP_E):
  573. X            temp = "File is not a BMP format file.";
  574. X            break;
  575. X        case ERRSEV(BMP_FILEERR_E):
  576. X            temp = "Error accessing file.";
  577. X            break;
  578. X        case ERRSEV(BMP_UNEOF_E):
  579. X            temp = "Unexpected End of File";
  580. X            break;
  581. X
  582. X        default:
  583. X            temp = NULL;
  584. X            break;
  585. X    }
  586. X
  587. X    return temp;
  588. X} /* end of bmp_errstring() */
  589. X
  590. END_OF_FILE
  591.   if test 19928 -ne `wc -c <'src/bmp.c'`; then
  592.     echo shar: \"'src/bmp.c'\" unpacked with wrong size!
  593.   fi
  594.   # end of 'src/bmp.c'
  595. fi
  596. if test -f 'src/gifcheck.1' -a "${1}" != "-c" ; then 
  597.   echo shar: Will not clobber existing file \"'src/gifcheck.1'\"
  598. else
  599.   echo shar: Extracting \"'src/gifcheck.1'\" \(32803 characters\)
  600.   sed "s/^X//" >'src/gifcheck.1' <<'END_OF_FILE'
  601. X.\" 
  602. X.\" $Id: gifcheck.1,v 1.3 1993/03/13 02:58:49 jwbirdsa Exp $
  603. X.\"
  604. X.TH GIFCHECK 1 "$Date: 1993/03/13 02:58:49 $
  605. X.PD 1
  606. X.SH NAME
  607. Xgifcheck \- GIF file analysis and verification
  608. X.SH SYNOPSIS
  609. X.B gifcheck
  610. X[
  611. X.B \-v
  612. X][
  613. X.B \-H
  614. X][
  615. X.B \-c
  616. X][
  617. X.B \-dn
  618. X][
  619. X.B \-en
  620. X][
  621. X.B \-b
  622. X][
  623. X.B \-r
  624. X][
  625. X.B \-\-
  626. X][
  627. X.B \-l
  628. X][
  629. X.B \-f
  630. X][
  631. X.B \-h
  632. X] target [ target... ]
  633. X.br
  634. X.SH DESCRIPTION
  635. X.I Gifcheck
  636. Xperforms complete analysis and verification of GIF-format images
  637. Xand displays the information it finds. It can also be used in shell scripts
  638. Xto determine whether GIF files are valid, and if they need to be passed
  639. Xthrough the
  640. X.I gifstrip
  641. Xprogram to remove excess characters.
  642. X.SH TARGETS
  643. XA target is a filename or directory. Multiple targets may be specified on
  644. Xthe command line. If a target is a directory, all files in that directory
  645. Xwill be processed. If no targets are specified on the command line, a usage
  646. Xmessage will be printed.
  647. X.SH OPTIONS
  648. XOptions may not be combined. In the case of the
  649. X.B \-dn
  650. Xand
  651. X.B \-en
  652. Xoptions, there cannot be a space between the option and the argument to the
  653. Xoption.
  654. X.TP
  655. X.B \-v
  656. XOutput is in a more verbose format. No additional data is displayed.
  657. X.TP
  658. X.B \-H
  659. XPlain Text Extensions and Comment Extensions are displayed in hex dump
  660. Xformat instead of as text.
  661. X.TP
  662. X.B \-c
  663. XAll color tables in the file are dumped as decimal RGB triplets of the form
  664. XRRR/GGG/BBB.
  665. X.TP
  666. X.B \-dn
  667. XSets display warning level (see DIAGNOSTICS below for an explanation of the
  668. Xtypes):
  669. X.RS 10
  670. X.PP
  671. X.nf
  672. X-d0             display anomalies and violations
  673. X-d1 (default)   display anomalies, violations,
  674. X                 and fascinatings
  675. X-d2             display all (anomalies, violations,
  676. X                 fascinatings, nitpicks)
  677. X.fi
  678. X.RE
  679. X.TP
  680. X.B \-en
  681. XSet exit warning level, at which processing of an image is stopped and 
  682. X.I gifcheck
  683. Xskips to the next image (see DIAGNOSTICS below for an explanation of the
  684. Xtypes):
  685. X.RS 10
  686. X.PP
  687. X.nf
  688. X-e0             skip on anomalies only
  689. X-e1 (default)   skip on anomalies and violations
  690. X-e2             skip on anomalies, violations,
  691. X                 and fascinatings
  692. X.fi
  693. X.RE
  694. X.TP
  695. X.B \-b
  696. XOperate in batch mode. All output is suppressed. This option should be
  697. Xfirst on the command line or other options may generate output before this
  698. Xoption is found. When in batch mode,
  699. X.I gifcheck
  700. Xadjusts its status return to reflect the results of processing. The status
  701. Xmay be:
  702. X.RS 10
  703. X.PP
  704. X.nf
  705. X0     the file is GIF format and did not need
  706. X       stripping
  707. X1     file is not GIF format
  708. X2     an unexpected EOF was encountered
  709. X       (usually indicates a corrupt file)
  710. X3     any other error
  711. X4     file is GIF format and needs stripping
  712. X5     file is GIF format and needs to be
  713. X       stripped with the -m option
  714. X.fi
  715. X.RE
  716. X.RS 5
  717. X.PP
  718. XNote that the status reflects the result of only the last file processed.
  719. XTherefore, in batch mode only one file should be specified on the command
  720. Xline.
  721. X.RE
  722. X.TP
  723. X.B \-r
  724. XRedirects error messages to stderr.
  725. X.TP
  726. X.B \-\-
  727. XRead targets from stdin. The list of targets must have only one target per
  728. Xline. Targets which are directories will be expanded as usual, but
  729. Xwildcards will not be expanded. Targets on the command line will be
  730. Xignored.
  731. XFor use with the
  732. X.B \-f
  733. Xoption of
  734. X.I
  735. Xchils.
  736. X.TP
  737. X.B \-l
  738. XDisables check for excess characters at the beginning of the file. By
  739. Xdefault,
  740. X.I gifcheck
  741. Xwill search through a file looking for the GIF signature if the file does
  742. Xnot begin with that signature. This option will disable that search.
  743. X.TP
  744. X.B \-f
  745. XDisables image decompression. This can be a slow process for large files.
  746. XHowever, an image cannot be completely verified if it is not decompressed,
  747. Xand some information can only be obtained by decompressing the image data.
  748. X.TP
  749. X.B \-p
  750. XIf
  751. X.I gifcheck
  752. Xwas compiled with the PROGRESS_IND option enabled, it will by default print
  753. Xa progress indicator when decompressing an image. This option turns off the
  754. Xprogress indicator. Note that this option is not valid if
  755. X.I gifcheck
  756. Xwas not complied with the PROGRESS_IND option enabled. Check the help 
  757. X(-h) to see if this option is listed and hence valid.
  758. X.TP
  759. X.B \-h
  760. XPrints a usage message. No files are processed and all other options are
  761. Xignored.
  762. X.SH OUTPUT
  763. X.I Gifcheck
  764. Xrecognizes eight different types of blocks within a GIF file: file headers,
  765. Ximages, and five types of extension block: generic extensions, Graphic
  766. XControl Extensions, Plain Text Extensions, Comment Extensions, and
  767. XApplication Extensions (the last four are found only in GIF89a-format
  768. Xfiles).
  769. X.PP
  770. XData from each type of block is output in a different format, which may
  771. Xchange according to the settings of the output format options. The various
  772. Xdisplays are explained below.
  773. X.RS 3
  774. X.SS "FILE HEADER"
  775. XThe default file header display, with no options, looks like this:
  776. X.RS 3
  777. X.PP
  778. X.nf
  779. XProcessing junk2/devil.gif...
  780. XFILE junk2/devil.gif   GIF87a      11209 bytes
  781. X   logical screen:    640 x   480
  782. X   8 bits per color available on source
  783. XGLOBAL COLOR TABLE:
  784. X   6 bits (64 colors)   bg index 0 (000/000/000)
  785. X   59 unique colors.
  786. X.fi
  787. X.RE
  788. X.PP
  789. XThe first line gives the filename, in case an error is encountered
  790. Ximmediately. The second line repeats the filename and displays the
  791. Xformat and filesize. The third line gives the size, in pixels, of the
  792. Xlogical screen on which all images in the file will be displayed. The
  793. Xfourth line displays how many bits per color (R,G,B) were available on
  794. Xthe machine on which the file was created. This value is frequently set
  795. Xincorrectly and may generally be ignored.
  796. X.PP
  797. XThe global color table, if present, has a subsection to itself. The
  798. Xsixth line indicates how large the global color table is. It also
  799. Xdisplays the background color index and the RGB value corresponding to
  800. Xthat index. While the background color index is actually part of the
  801. Xfile header proper, it is meaningless unless a global color table is
  802. Xpresent, so it is displayed in the global color table section. If the
  803. Xfile is a GIF89a-format image, this line also indicates whether the
  804. Xglobal color table is sorted. Finally, the seventh line indicates how
  805. Xmany unique colors are present in the global color table.
  806. X.PP
  807. XIf no global color table is present, a line stating this is displayed
  808. Xinstead.
  809. X.PP
  810. XIf the
  811. X.B \-v
  812. Xoption is in effect, the file header display looks like this:
  813. X.RS 3
  814. X.PP
  815. X.nf
  816. XProcessing junk2/devil.gif...
  817. XFILE junk2/devil.gif is GIF version GIF87a:
  818. X   file size (bytes):    11209
  819. X   logical screen size (pixels, width x height):   640 x   480
  820. X   8 bits per color available on source
  821. X   This file has a global color table.
  822. XGLOBAL COLOR TABLE:
  823. X   6 bits per index for a table size of 64
  824. X   background index 0, RGB value 000/000/000
  825. X   59 unique colors.
  826. X.fi
  827. X.RE
  828. X.PP
  829. XThe data displayed is the same, but more explanatory text is
  830. Xincluded.
  831. X.PP
  832. XIf the
  833. X.B \-c
  834. Xoption is in effect, the file header display looks like this:
  835. X.RS 3
  836. X.PP
  837. X.nf
  838. XProcessing junk2/devil.gif...
  839. XFILE junk2/devil.gif   GIF87a      11209 bytes
  840. X   logical screen:    640 x   480
  841. X   8 bits per color available on source
  842. XGLOBAL COLOR TABLE:
  843. X   6 bits (64 colors)   bg index 0 (000/000/000)
  844. X   59 unique colors.
  845. X   000/000/000   255/197/197   255/156/156   255/189/189   255/131/131
  846. X   255/180/180   255/148/148   255/205/205   041/000/000   255/123/123
  847. X   255/172/172   255/074/074   082/000/000   255/057/057   255/090/090
  848. X   255/115/115   008/000/000   049/000/000   255/164/164   024/000/000
  849. X   131/000/000   255/049/049   074/000/000   255/082/082   123/000/000
  850. X   255/139/139   065/000/000   148/000/000   255/041/041   016/000/000
  851. X   255/016/016   230/024/024   255/032/032   115/000/000   164/000/000
  852. X   057/000/000   255/106/106   106/000/000   156/000/000   255/008/008
  853. X   032/000/000   255/065/065   139/000/000   180/000/000   255/024/024
  854. X   098/000/000   090/000/000   238/000/000   189/000/000   230/000/000
  855. X   213/000/000   172/000/000   205/000/000   197/000/000   246/000/000
  856. X   222/000/000   230/016/016   255/000/000   255/098/098   000/000/000
  857. X   000/000/000   000/000/000   000/000/000   000/000/000
  858. X.fi
  859. X.RE
  860. X.PP
  861. XThe standard or verbose display is followed by a listing, in decimal,
  862. Xof the raw RGB values found in the global color map.
  863. X.SS IMAGE
  864. XThe default image display, with no options, looks like this:
  865. X.RS 3
  866. X.PP
  867. X.nf
  868. XIMAGE 1:
  869. X   size   640 x   480   corner     0,     0   sequentially
  870. X   This image uses the global color table (no local color table).
  871. X   IMAGE DATA FOR IMAGE 1:
  872. X   code size 6 bits
  873. X   Reached end of codes in block 42
  874. X   totals: 7906 codes packed into 10948 bytes in 43 blocks
  875. X        307200 pixels extracted
  876. X        code table cleared 2 times
  877. X        compressed data is 4% of the size of uncompressed image
  878. X        59 colors referenced (59 unique)
  879. X.fi
  880. X.RE
  881. X.PP
  882. XEach image in the file is numbered by 
  883. X.I gifcheck
  884. Xstarting at 1 and has
  885. Xa section to itself. The first line gives the image number. The second
  886. Xline indicates the size, in pixels, of the image; the location, in
  887. Xpixels, of the upper left corner, and how the image is stored
  888. X("sequentially" or "interlaced").
  889. X.PP
  890. XThe third line indicates whether there is a local color table, and
  891. Xwhether the image uses the global or local color table. If there is a
  892. Xlocal color table, the third line is followed by a color table display
  893. Xsimilar to the one for global color tables, including a dump of
  894. Xthe raw RGB values if the
  895. X.B \-c
  896. Xcolor dump option is in effect. Very few images have local color tables.
  897. X.PP
  898. XImage data is stored compressed, and the compressed data is further
  899. Xbroken up into blocks (which are numbered by 
  900. X.I gifcheck
  901. Xstarting at 0).
  902. XThe fifth line indicates the minimum code size for the image. The sixth
  903. Xline indicates the block in which the end-of-information (EOI) code was
  904. Xencountered. The seventh line indicates the number of codes extracted,
  905. Xthe number of bytes which those codes occupied, and how many blocks
  906. Xthose bytes were divided into. The eighth line indicates how many pixels
  907. Xwere generated when the codes were decompressed, and the ninth line
  908. Xindicates how many times the table-clear code was encountered.
  909. X.PP
  910. XThe tenth line indicates the size of the compressed data as a
  911. Xpercentage of the size of the uncompressed image. The size of the
  912. Xcompressed data is the size of the data only, not including block
  913. Xheaders, image headers, or any other non-image data, so the compression
  914. Xratio is accurate. The size of the uncompressed image is calculated by
  915. Xmultiplying the height and the width to get the total number of pixels
  916. Xin the image, then multiplying by the number of bits required to
  917. Xrepresent the global or local color table, depending on which one is
  918. Xused by the image. Finally, the eleventh line indicates how many colors
  919. Xwere referenced by the image data, and how many of the colors referenced
  920. Xare unique.
  921. X.PP
  922. XIf the
  923. X.B \-v
  924. Xoption is in effect, the image display looks like this:
  925. X.RS 3
  926. X.PP
  927. X.nf
  928. XIMAGE 1:
  929. X   image size (pixels, width x height):   640 x   480
  930. X   image upper left corner (column, row):     0,     0
  931. X   image is stored sequentially
  932. X   This image uses the global color table (no local color table).
  933. X   IMAGE DATA FOR IMAGE 1:
  934. X   code size 6 bits
  935. X   Reached end of codes in block 42
  936. X   totals: 7906 codes packed into 10948 bytes in 43 blocks
  937. X        307200 pixels extracted
  938. X        code table cleared 2 times
  939. X        compressed data is 4% of the size of uncompressed image
  940. X        59 colors referenced (59 unique)
  941. X.fi
  942. X.RE
  943. X.PP
  944. XThe data displayed is the same, but more explanatory text is included.
  945. X.PP
  946. XIf the
  947. X.B \-f
  948. Xoption is in effect, the image display looks like this:
  949. X.RS 3
  950. X.PP
  951. X.nf
  952. XIMAGE 1:
  953. X   size   640 x   480   corner     0,     0   sequentially
  954. X   This image uses the global color table (no local color table).
  955. X   IMAGE DATA FOR IMAGE 1:
  956. X   code size 6 bits
  957. X   totals: 10948 bytes in 43 blocks
  958. X        compressed data is 4% of the size of uncompressed image
  959. X.fi
  960. X.RE
  961. X.PP
  962. XSince the compressed image data is not decompressed under this
  963. Xoption, less information is available.
  964. X.SS "GENERIC EXTENSIONS"
  965. XIf the format is GIF87a, or the format is GIF89a but the type
  966. Xidentifier is not one of the four dedicated types, the "generic
  967. Xextension" format is used. It looks like this:
  968. X.RS 3
  969. X.PP
  970. X.nf
  971. XGENERIC EXTENSION BLOCK 1:
  972. X   extension block type 255
  973. X   BLOCK 0 (11 bytes):
  974. XG 47    I 49    F 46    L 4C    I 49    T 54    E 45      20
  975. X  20      20      20
  976. X   BLOCK 1 (6 bytes):
  977. X  01    ) 29    p 70      0E      02      00
  978. X   totals: 17 bytes of data in 2 blocks
  979. X.fi
  980. X.RE
  981. X.PP
  982. XGeneric extension blocks are numbered sequentially by 
  983. X.I gifcheck
  984. Xstarting at 1. The
  985. Xfirst line indicates that it is a generic extension block and gives the
  986. Xsequence number. The second line shows the type identifier value. The
  987. Xnext lines display the data in hex dump format (generic extensions are
  988. Xalways displayed in hex dump format, regardless of the setting of the
  989. X.B \-H
  990. Xoption). Each data block is numbered sequentially by 
  991. X.I gifcheck
  992. Xstarting at 0. A line giving the data block number and the number of
  993. Xbytes in the block is shown. Then the data bytes themselves are
  994. Xdisplayed, eight per line. If the byte is a printable character, the
  995. Xcharacter is printed, followed by the hex value of the byte; otherwise a
  996. Xspace is printed, followed by the hex value. Finally, a totals line is
  997. Xprinted, indicating the total number of data bytes and the total number
  998. Xof data blocks.
  999. X.PP
  1000. XThe
  1001. X.B \-v
  1002. Xoption has no effect on generic extension displays.
  1003. X.SS "GRAPHIC CONTROL EXTENSION"
  1004. XGraphic Control Extensions (GCEs) are one of the GIF89a dedicated
  1005. Xextension types. When encountered, they are displayed like this:
  1006. X.RS 3
  1007. X.PP
  1008. X.nf
  1009. XGRAPHIC CONTROL EXTENSION BLOCK 1:
  1010. X   Disposal method: 0 (none)
  1011. X   User input is not expected
  1012. X   Transparency enabled (index 3)
  1013. X   No delay time specified
  1014. X.fi
  1015. X.RE
  1016. X.PP
  1017. XGCEs are numbered sequentially (by 
  1018. X.I gifcheck).
  1019. XThe first line
  1020. Xindicates that it is a GCE and gives the sequence number. The second
  1021. Xline shows the disposal method (which applies to the next graphic --
  1022. Xi.e. image or Plain Text Extension -- in the file). This can be: "none",
  1023. X"leave in place", "restore to background", or "restore to previous".
  1024. X.PP
  1025. XThe third line indicates whether user input is expected before the
  1026. Xnext graphic will be displayed. The fourth line indicates whether a
  1027. Xtransparency color index (which indicates that pixels of the given color
  1028. Xshould be rendered "transparent" -- i.e., not drawn) has been specified,
  1029. Xand if so, what the transparency index is. The last line indicates
  1030. Xwhether a delay time (delay before the next graphic is displayed) has
  1031. Xbeen specified, and if so what the delay value is.
  1032. X.PP
  1033. XThe
  1034. X.B \-v
  1035. Xoption has no effect on GCE displays.
  1036. X.SS "PLAIN TEXT EXTENSION"
  1037. XPlain Text Extensions (PTEs) are one of the GIF89a dedicated
  1038. Xextension types. When encountered, they are displayed like this:
  1039. X.RS 3
  1040. X.PP
  1041. X.nf
  1042. XPLAIN TEXT EXTENSION BLOCK 1:
  1043. X   char cell   8 x  28, grid  96( 12) x  28(  1) at     0,   112
  1044. X   Foreground color index 0 (RGB 016/016/014)
  1045. X   Background color index 3 (RGB 113/110/232)
  1046. X   START TEXT (12 characters):
  1047. X Cass Berry
  1048. X   END TEXT.
  1049. X.fi
  1050. X.RE
  1051. X.PP
  1052. XPTEs are numbered sequentially by 
  1053. X.I gifcheck
  1054. Xstarting at 1. The first line
  1055. Xindicates that it is a PTE and gives the sequence number. The second
  1056. Xline shows: the size of the character cell, in pixels; the size of the
  1057. Xcharacter grid, in pixels and cells (cells in parentheses); and the
  1058. Xlocation of the upper left corner of the grid. The third line shows the
  1059. Xindex and RGB values of the foreground text color, and the fourth line
  1060. Xshows the same for the background color.
  1061. X.PP
  1062. XThe fifth line indicates the start of the text, and how many
  1063. Xcharacters of text are present. It is followed by the text itself, which
  1064. Xis in turn followed by an "END TEXT." marker on the next line.
  1065. X.PP
  1066. XIf the
  1067. X.B \-v
  1068. Xoption is in effect, PTEs are displayed like this:
  1069. X.RS 3
  1070. X.PP
  1071. X.nf
  1072. XPLAIN TEXT EXTENSION BLOCK 1:
  1073. X   Character cell grid upper left corner (column, row):     0,   112
  1074. X   Character cell size (pixels, width x height):   8 x  28
  1075. X   Character grid size (pixels, width x height):  96 x  28
  1076. X   Character grid size (chars, width x height):  12 x   1
  1077. X   Foreground color index 0 (RGB 016/016/014)
  1078. X   Background color index 3 (RGB 113/110/232)
  1079. X   START TEXT (12 characters):
  1080. X Cass Berry
  1081. X   END TEXT.
  1082. X.fi
  1083. X.RE
  1084. X.PP
  1085. XThe same information is displayed, but more explanatory text is included.
  1086. X.PP
  1087. XIf the
  1088. X.B \-H
  1089. Xoption is in effect, the text is displayed in hex dump format, like this:
  1090. X.RS 3
  1091. X.PP
  1092. X.nf
  1093. XPLAIN TEXT EXTENSION BLOCK 1:
  1094. X   char cell   8 x  28, grid  96( 12) x  28(  1) at     0,   112
  1095. X   Foreground color index 0 (RGB 016/016/014)
  1096. X   Background color index 3 (RGB 113/110/232)
  1097. X   START TEXT (12 characters):
  1098. X   LINE 1:
  1099. X  20    C 43    a 61    s 73    s 73      20    B 42    e 65
  1100. Xr 72    r 72    y 79      20
  1101. X   END TEXT.
  1102. X.fi
  1103. X.RE
  1104. X.PP
  1105. XInstead of simply displaying the text, each character is displayed
  1106. Xindividually, followed by its hex value.
  1107. X.SS "COMMENT EXTENSION"
  1108. XComment Extensions are one of the GIF89a dedicated extension types.
  1109. XWhen encountered, they are displayed like this:
  1110. X.RS 3
  1111. X.PP
  1112. X.nf
  1113. XCOMMENT EXTENSION BLOCK 1:
  1114. X   START TEXT (161 characters):
  1115. X+-------------------------------------------------+
  1116. X| Multi-image GIF89a created with CompuMake Tools |
  1117. X+-------------------------------------------------+
  1118. X
  1119. X   END TEXT.
  1120. X   0 unprintable characters.
  1121. X.fi
  1122. X.RE
  1123. X.PP
  1124. XComment Extensions are numbered sequentially by 
  1125. X.I gifcheck
  1126. Xstarting at 1. The first
  1127. Xline indicates that it is a Comment Extension and gives the sequence
  1128. Xnumber. The second line indicates the start of the text and how many
  1129. Xcharacters of text are present. It is followed by the text itself, which
  1130. Xis in turn followed by an "END TEXT." marker on the next line. The last
  1131. Xline indicates how many unprintable characters were found in the text.
  1132. X.PP
  1133. XThe
  1134. X.B \-v
  1135. Xoption has no effect on Comment Extension displays.
  1136. X.PP
  1137. XIf the
  1138. X.B \-H
  1139. Xoption is in effect, the text is displayed in hex dump format, like this:
  1140. X.RS 3
  1141. X.PP
  1142. X.nf
  1143. XCOMMENT EXTENSION BLOCK 1:
  1144. X   START TEXT (161 characters):
  1145. X+ 2B    - 2D    - 2D    - 2D    - 2D    - 2D    - 2D    - 2D
  1146. X- 2D    - 2D    - 2D    - 2D    - 2D    - 2D    - 2D    - 2D
  1147. X- 2D    - 2D    - 2D    - 2D    - 2D    - 2D    - 2D    - 2D
  1148. X- 2D    - 2D    - 2D    - 2D    - 2D    - 2D    - 2D    - 2D
  1149. X- 2D    - 2D    - 2D    - 2D    - 2D    - 2D    - 2D    - 2D
  1150. X- 2D    - 2D    - 2D    - 2D    - 2D    - 2D    - 2D    - 2D
  1151. X- 2D    - 2D    + 2B      0D      0A    | 7C      20    M 4D
  1152. Xu 75    l 6C    t 74    i 69    - 2D    i 69    m 6D    a 61
  1153. Xg 67    e 65      20    G 47    I 49    F 46    8 38    9 39
  1154. Xa 61      20    c 63    r 72    e 65    a 61    t 74    e 65
  1155. Xd 64      20    w 77    i 69    t 74    h 68      20    C 43
  1156. Xo 6F    m 6D    p 70    u 75    M 4D    a 61    k 6B    e 65
  1157. X  20    T 54    o 6F    o 6F    l 6C    s 73      20    | 7C
  1158. X  0D      0A    + 2B    - 2D    - 2D    - 2D    - 2D    - 2D
  1159. X- 2D    - 2D    - 2D    - 2D    - 2D    - 2D    - 2D    - 2D
  1160. X- 2D    - 2D    - 2D    - 2D    - 2D    - 2D    - 2D    - 2D
  1161. X- 2D    - 2D    - 2D    - 2D    - 2D    - 2D    - 2D    - 2D
  1162. X- 2D    - 2D    - 2D    - 2D    - 2D    - 2D    - 2D    - 2D
  1163. X- 2D    - 2D    - 2D    - 2D    - 2D    - 2D    - 2D    - 2D
  1164. X- 2D    - 2D    - 2D    - 2D    + 2B      0D      0A      0D
  1165. X  0A
  1166. X   END TEXT.
  1167. X   0 unprintable characters.
  1168. X.fi
  1169. X.RE
  1170. X.PP
  1171. XInstead of simply displaying the text, each character is displayed
  1172. Xindividually, followed by its hex value.
  1173. X.SS "APPLICATION EXTENSION"
  1174. XApplication Extensions are one of the GIF89a dedicated extension
  1175. Xtypes. When encountered, they are displayed like this:
  1176. X.RS 3
  1177. X.PP
  1178. X.nf
  1179. XAPPLICATION EXTENSION BLOCK 1:
  1180. X   application identifier:
  1181. Xf 66    r 72    a 61    c 63    t 74    i 69    n 6E    t 74
  1182. X   application authentication code:
  1183. X0 30    0 30    1 31
  1184. X   246 bytes of application data.
  1185. XF 46    r 72    a 61    c 63    t 74    a 61    l 6C      00
  1186. X  96      00      07      00      00      00      00    h 68
  1187. X  D8      FB      0C    @ 40      00      00      00      20
  1188. X  0B      FF      0C    @ 40      00      00      00      00
  1189. X  00      E9    I 49    ? 3F      00      00      00      00
  1190. X  F0    = 3D      89    ? 3F      00      00      00      00
  1191. X  00      00      00      00      00      00      00      00
  1192. X  00      00      00      00      00      00      00      00
  1193. X  00      00      00      00      1B      00      80      02
  1194. X  E0      01      00      01      04      00      00      00
  1195. X  00      00      00      00      00      00      00      00
  1196. X  00      00      00      00      00      00      00      00
  1197. X  00      00      00      00      00      00      FF      FF
  1198. X  01      00      01      00      00      00      00      00
  1199. X  00      00      00      00      00      00      00      00
  1200. X  00      00      00      00      E7      03      00      00
  1201. XZ 5A      00      09      01      00      00    x 78      00
  1202. X  8C      00    ( 28      00      00      00      02      00
  1203. Xn 6E      00      00      00      00      00      01      00
  1204. X  FF      FF      01      00      00      00      14      00
  1205. X  00      00      00      00      04      00      00      00
  1206. X  00      00      04      00    P 50      00    d 64      00
  1207. X  00      00      00      00      00      00      FF      FF
  1208. X  00      00      00    h 68      D8      FB      0C    @ 40
  1209. X  00      00      00      00      00      E9    I 49    ? 3F
  1210. Xg 67      00      04      00      06      01      00      00
  1211. X  00      00      00      00      00      00      D8      A7
  1212. X  00      00      00      06      02      03      00      00
  1213. X  00      00      00      00      00      00      00      00
  1214. X  00      00      00      00      00      00      00      00
  1215. X  01      00      00      00      00      00
  1216. X.fi
  1217. X.RE
  1218. X.PP
  1219. XApplication Extensions are numbered sequentially by 
  1220. X.I gifcheck
  1221. Xstarting at 1. The
  1222. Xfirst line indicates that it is an Application Extension and gives the
  1223. Xsequence number. The second line introduces the eight-byte application
  1224. Xidentifier and is followed on the third line by the application
  1225. Xidentifier itself, in hex dump format. The fourth line introduces the
  1226. Xthree-byte application authentication code and is followed on the fifth
  1227. Xline by the application authentication code itself, in hex dump format.
  1228. XThe sixth line indicates how many bytes of application data are present,
  1229. Xand is followed by the application data itself in hex dump format. All
  1230. Xdata in Application Extensions is always displayed in hex dump format,
  1231. Xregardless of the setting of the
  1232. X.B \-H
  1233. Xoption.
  1234. X.PP
  1235. XThe
  1236. X.B \-v
  1237. Xoption has no effect on Application Extension displays.
  1238. X.SS TERMINATOR
  1239. XWhen the GIF terminator block is encountered,
  1240. X.I gifcheck
  1241. Xprints this line:
  1242. X.RS 3
  1243. X.PP
  1244. X.nf
  1245. XGIF TERMINATOR
  1246. X.fi
  1247. X.RE
  1248. X.SH DIAGNOSTICS
  1249. X.I Gifcheck
  1250. Xcan produce a variety of diagnostic messages. Some indicate
  1251. Xproblems within the GIF file. Others indicate malfunctions of
  1252. X.I gifcheck
  1253. Xor the computer. Messages beginning with "ANOMALY", "VIOLATION",
  1254. X"FASCINATING", and "NITPICK" indicate problems within the GIF file.
  1255. XMessages beginning "FATAL ERROR", "ERROR", or "WARNING" indicate
  1256. Xmalfunctions. Messages beginning "STRIP" indicate that the file should
  1257. Xbe processed by the
  1258. X.I gifstrip
  1259. Xprogram to remove excess characters.
  1260. X.RS 3
  1261. X.SS ANOMALIES
  1262. XAnomalies are radical violations of the GIF specification. Anomalies
  1263. Xmay be caused by massive corruption of the file, to the extent that
  1264. X.I gifcheck
  1265. Xcannot determine how to proceed with processing of the file, or
  1266. Xby individual values that make no sense. In either case, an image with
  1267. Xanomalies will probably be rejected by most GIF viewers. Anomalies are
  1268. Xalways displayed and always cause
  1269. X.I gifcheck
  1270. Xto skip immediately to the next file to be processed.
  1271. X.PP
  1272. XThe various anomalies that
  1273. X.I gifcheck
  1274. Xcan detect are explained below.
  1275. X.HP 9
  1276. XANOMALY: end of data reached before end of codes
  1277. X.RS 5
  1278. X.PD 0
  1279. X.PP
  1280. X.I gifcheck
  1281. Xreached the end of the packed image data
  1282. Xwithout encountering an End-of-Information code, which
  1283. Xsignals the end of the image.
  1284. X.RE
  1285. X.PD 1
  1286. X.HP 9
  1287. XANOMALY: decompression error in block xxx at offset yyy
  1288. X.RS 5
  1289. X.PD 0
  1290. X.PP
  1291. X.I gifcheck
  1292. Xfound a bad code in the packed image data. This
  1293. Xindicates that the file has been corrupted, and most
  1294. Xlikely the rest of the file is trash.
  1295. X.RE
  1296. X.PD 1
  1297. X.HP 9
  1298. XANOMALY: foreground color index off end of global color table
  1299. X.RS 5
  1300. X.PD 0
  1301. X.PP
  1302. XThe color index specified for the foreground in a GIF89a
  1303. XPlain Text Extension is invalid (PTEs always use the
  1304. Xglobal color table).
  1305. X.RE
  1306. X.PD 1
  1307. X.HP 9
  1308. XANOMALY: background color index off end of global color table
  1309. X.RS 5
  1310. X.PD 0
  1311. X.PP
  1312. XThe color index specified for the background in a GIF89a
  1313. XPlain Text Extension is invalid (PTEs always use the
  1314. Xglobal color table).
  1315. X.RE
  1316. X.PD 1
  1317. X.HP 9
  1318. XANOMALY: an undefined disposal method (x) is given
  1319. X.RS 5
  1320. X.PD 0
  1321. X.PP
  1322. XThe value in the disposal method of a Graphic Control
  1323. XExtension is undefined.
  1324. X.RE
  1325. X.PD 1
  1326. X.HP 9
  1327. XANOMALY: a ... cannot follow a ...
  1328. X.RS 5
  1329. X.PD 0
  1330. X.PP
  1331. XWhere "..." is a block type. The GIF89a specification
  1332. Xincludes a grammar which indicates which types of blocks
  1333. Xcan follow which other types of blocks (in the simpler
  1334. XGIF87a specification, there was no need). This grammar
  1335. Xhas been violated.
  1336. X.PD 1
  1337. X.RE
  1338. X.SS VIOLATIONS
  1339. XViolations are major violations of the GIF specification. Violations
  1340. Xmay be caused by corruption of the file or by individual values that
  1341. Xmake no sense. In either case, an image with violations may be rejected
  1342. Xby some viewers and displayed with difficulty by others. Violations are
  1343. Xalways displayed, and by default cause
  1344. X.I gifcheck
  1345. Xto skip immediately to the next file to be processed.
  1346. X.PP
  1347. XThe various violations that
  1348. X.I gifcheck
  1349. Xcan detect are explained below.
  1350. X.HP 11
  1351. XVIOLATION: image does not fit on logical screen
  1352. X.PD 0
  1353. X.RS 5
  1354. X.PP
  1355. XEither the size of the image given in the image header
  1356. Xis greater in one or both dimensions than the size of
  1357. Xthe logical screen given in the file header, or the
  1358. Xposition of the image given in the image header causes
  1359. Xparts of the image to extend beyond the boundaries of
  1360. Xthe logical screen.
  1361. X.RE
  1362. X.PD 1
  1363. X.HP 11
  1364. XVIOLATION: bad transparency index (x)
  1365. X.PD 0
  1366. X.RS 5
  1367. X.PP
  1368. XIf processing a Plain Text Extension, indicates that the
  1369. Xtransparency index specified by a preceeding Graphic
  1370. XControl Extension is off the end of the global color
  1371. Xtable (PTEs always use the global color table). If
  1372. Xprocessing an image, indicates that the transparency
  1373. Xindex is off the end of either the global or local color
  1374. Xtable, depending on which one the image uses.
  1375. X.RE
  1376. X.PD 1
  1377. X.HP 11
  1378. XVIOLATION: character grid does not fit on logical screen
  1379. X.PD 0
  1380. X.RS 5
  1381. X.PP
  1382. XEither the size of the character grid given in the Plain
  1383. XText Extension is greater in one or both dimensions than
  1384. Xthe size of the logical screen given in the file header,
  1385. Xor the position of the character grid causes parts of it
  1386. Xto extend beyond the boundaries of the logical screen.
  1387. X.RE
  1388. X.PD 1
  1389. X.HP 11
  1390. XVIOLATION: text is too long to fit into character grid
  1391. X.PD 0
  1392. X.RS 5
  1393. X.PP
  1394. XThe text given in the Plain Text Extension contains more
  1395. Xcharacters than there are character cells in the
  1396. Xcharacter grid.
  1397. X.RE
  1398. X.PD 1
  1399. X.HP 11
  1400. XVIOLATION: xxx garbage characters found between blocks
  1401. X.PD 0
  1402. X.RS 5
  1403. X.PP
  1404. XThere should be no garbage characters between blocks.
  1405. XWhile this can theoretically be solved by using the
  1406. X.I gifstrip
  1407. Xprogram, it probably indicates that the file
  1408. Xhas been corrupted.
  1409. X.PD 1
  1410. X.RE
  1411. X.SS FASCINATINGS
  1412. XFascinatings are not always violations of the GIF specification.
  1413. XFascinatings are unusual conditions which most viewers can cope with, but
  1414. Xare still worthy of note. Fascinatings are displayed by default, and by
  1415. Xdefault do NOT cause
  1416. X.I gifcheck
  1417. Xto skip.
  1418. X.PP
  1419. XThe various fascinatings that
  1420. X.I gifcheck
  1421. Xcan detect are explained below.
  1422. X.HP 13
  1423. XFASCINATING: this file does not contain a global color table
  1424. X.PD 0
  1425. X.RS 5
  1426. X.PP
  1427. XThe GIF specification allows for files without global
  1428. Xcolor tables; they are to be displayed using the global
  1429. Xcolor table from a previous file, or a default table
  1430. Xchosen by the viewer if no previous global color table
  1431. Xis available. Files without global color tables are
  1432. Xextremely rare. This message is displayed when an image
  1433. Xwhich uses the global color table is encountered in a
  1434. Xfile which has none.
  1435. X.RE
  1436. X.PD 1
  1437. X.HP 13
  1438. XFASCINATING: xxx extra blocks on end of image
  1439. X.PD 0
  1440. X.RS 5
  1441. X.PP
  1442. XThe packed image data continued for one or more blocks
  1443. Xafter the block in which the End-of-Information (EOI)
  1444. Xcode was found. While this condition is suspicious, the
  1445. Xdata before the EOI decompressed correctly (otherwise an
  1446. XANOMALY would have occurred), so there's no concrete
  1447. Xevidence that the image is bad.
  1448. X.RE
  1449. X.PD 1
  1450. X.HP 13
  1451. XFASCINATING: too few pixels extracted (xxx lines found, yyy pixels missing)
  1452. X.PD 0
  1453. X.RS 5
  1454. X.PP
  1455. XWhen the End-of-Information code was encountered, too
  1456. Xfew pixels had been extracted to fill the image (e.g,
  1457. Xfor a 320 by 200 image, which should have 64,000 pixels,
  1458. Xonly 63,999 were extracted). Typically only one or two
  1459. Xare missing. Viewers seem to cope with this condition
  1460. XOK.
  1461. X.RE
  1462. X.PD 1
  1463. X.HP 13
  1464. XFASCINATING: too many pixels extracted (xxx extra)
  1465. X.PD 0
  1466. X.RS 5
  1467. X.PP
  1468. XWhen the End-of-Information code was encountered, more
  1469. Xpixels than necessary had been extracted (e.g., for a
  1470. X320 by 200 image, which should have 64,000 pixels,
  1471. X64,001 were extracted). Typically only one or two extras
  1472. Xare present. Viewers seem to cope with this condition
  1473. XOK.
  1474. X.RE
  1475. X.PD 1
  1476. X.HP 13
  1477. XFASCINATING: code table never cleared
  1478. X.PD 0
  1479. X.RS 5
  1480. X.PP
  1481. XWhile this is technically OK, it is recommended practice
  1482. Xto clear the decompression code table (via a clear code
  1483. Xin the compressed image data) immediately at the
  1484. Xbeginning of the image. If the code table was never
  1485. Xcleared, this initial clear never occurred.
  1486. X.RE
  1487. X.PD 1
  1488. X.HP 13
  1489. XFASCINATING: this file has no Global Color Table (GCT is used by PTE)
  1490. X.PD 0
  1491. X.RS 5
  1492. X.PP
  1493. XThe GIF specification allows for files without global
  1494. Xcolor tables; they are to be displayed using the global
  1495. Xcolor table from a previous file, or a default table
  1496. Xchosen by the viewer if no previous global color table
  1497. Xis available. Files without global color tables are
  1498. Xextremely rare. This message is displayed when a Plain
  1499. XText Extension (PTEs always use the global color table)
  1500. Xis encountered in a file which has no global color table.
  1501. X.RE
  1502. X.PD 1
  1503. X.HP 13 
  1504. XFASCINATING: transparency index does not match either foreground or background
  1505. X.PD 0
  1506. X.RS 5
  1507. X.PP
  1508. XThis message is displayed when processing a Plain Text
  1509. XExtension and the transparency index specified by a
  1510. Xpreceeding Graphic Control Extension does not match
  1511. Xeither the foreground or the background color indices of
  1512. Xthe PTE. This renders the transparency index
  1513. Xmeaningless, since it only applies to the next graphic
  1514. X(image or PTE) following the GCE. Nothing is technically
  1515. Xwrong, but it's weird.
  1516. X.PD 1
  1517. X.RE
  1518. X.SS NITPICKS
  1519. XNitpicks are minor technical violations of the GIF specification.
  1520. XSome are very common, and they should not cause problems when viewing
  1521. Xthe file. Nitpicks are by default NOT displayed, and never cause
  1522. X.I gifcheck
  1523. Xto skip.
  1524. X.PP
  1525. XThe various nitpicks that
  1526. X.I gifcheck
  1527. Xcan detect are explained below.
  1528. XMost of these messages are self-explanatory, so no detailed explanation
  1529. Xis given.
  1530. X.HP 9
  1531. XNITPICK: byte 6 of the logical screen descriptor should be 0 for GIF87A
  1532. X.HP 9
  1533. XNITPICK: bit 3, byte 4 of logical screen descriptor should be 0 for GIF87A
  1534. X.HP 9
  1535. XNITPICK: bits 3 and 4, byte 9 of image descriptor should be 0
  1536. X.HP 9
  1537. XNITPICK: bit 5, byte 9 of image descriptor should be 0 for GIF87A
  1538. X.HP 9
  1539. XNITPICK: bits 5-7, byte 1 of graphic control extension should be 0
  1540. X.HP 9
  1541. XNITPICK: local color table size is nonzero
  1542. X.PD 0
  1543. X.RS 5
  1544. X.PP
  1545. XThe image does not have a local color table, but the
  1546. Xlocal color table size is nonzero.
  1547. X.PD 1
  1548. X.RE
  1549. X.HP 9
  1550. XNITPICK: character grid not an integral number of character cells wide
  1551. X.PD 0
  1552. X.RS 5
  1553. X.PP
  1554. XThe horizontal size of the character grid in a Plain
  1555. XText Extension is not evenly divisible by the horizontal
  1556. Xsize of a character cell.
  1557. X.PD 1
  1558. X.RE
  1559. X.HP 9
  1560. XNITPICK: character grid not an integral number of character cells high
  1561. X.PD 0
  1562. X.RS 5
  1563. X.PP
  1564. XThe vertical size of the character grid in a Plain Text
  1565. XExtension is not evenly divisible by the vertical size
  1566. Xof a character cell.
  1567. X.PD 1
  1568. X.RE
  1569. X.HP 9
  1570. XNITPICK: xxx unprintable characters in text
  1571. X.PD 0
  1572. X.RS 5
  1573. X.PP
  1574. XPlain Text Extensions are supposed to contain only
  1575. X"7-bit printable ASCII characters".
  1576. X.PD 1
  1577. X.RE
  1578. X.SS MISCELLANEOUS
  1579. X.I Gifcheck
  1580. Xcan also produce messages beginning with "FATAL ERROR",
  1581. X"ERROR", "WARNING", and "STRIP". The first three indicate malfunctions
  1582. Xof
  1583. X.I gifcheck
  1584. Xor the computer, and typically cause
  1585. X.I gifcheck
  1586. Xto exit
  1587. Ximmediately. Messages beginning with "STRIP" indicate that the file
  1588. Xshould be processed by the
  1589. X.I gifstrip
  1590. Xprogram to remove excess characters,
  1591. Xand are simply for the user's information. Processing of the file is not
  1592. Xaffected.
  1593. X.RE
  1594. X.SH COPYRIGHT
  1595. X.I Gifcheck
  1596. Xis copyright 1993 by James W. Birdsall, all rights reserved.
  1597. X.PP
  1598. XThe Graphics Interchange Format(c) is the Copyright property of CompuServe
  1599. XIncorporated. GIF(sm) is a Service Mark property of CompuServe
  1600. XIncorporated.
  1601. X.SH AUTHOR
  1602. XJames W. Birdsall
  1603. X.RS 3
  1604. X.nf
  1605. Xsupport@picarefy.com
  1606. Xuunet!uw-coco!amc-gw!picarefy!support
  1607. XCompuServe: 71261,1731
  1608. XGEnie: J.BIRDSALL2
  1609. X.fi
  1610. X.RE
  1611. X.SH "SEE ALSO"
  1612. Xchils(1),
  1613. Xgifstrip(1)
  1614. END_OF_FILE
  1615.   if test 32803 -ne `wc -c <'src/gifcheck.1'`; then
  1616.     echo shar: \"'src/gifcheck.1'\" unpacked with wrong size!
  1617.   fi
  1618.   # end of 'src/gifcheck.1'
  1619. fi
  1620. echo shar: End of archive 12 \(of 18\).
  1621. cp /dev/null ark12isdone
  1622. MISSING=""
  1623. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 ; do
  1624.     if test ! -f ark${I}isdone ; then
  1625.     MISSING="${MISSING} ${I}"
  1626.     fi
  1627. done
  1628. if test "${MISSING}" = "" ; then
  1629.     echo You have unpacked all 18 archives.
  1630.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1631. else
  1632.     echo You still must unpack the following archives:
  1633.     echo "        " ${MISSING}
  1634. fi
  1635. exit 0
  1636. exit 0 # Just in case...
  1637.