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

  1. Newsgroups: comp.sources.misc
  2. From: jwbirdsa@picarefy.picarefy.com (James W. Birdsall)
  3. Subject: v36i081:  chiaro - Image Utilities, Part11/18
  4. Message-ID: <1993Mar26.202816.14695@sparky.imd.sterling.com>
  5. X-Md4-Signature: 3112b7f12fc074979e59a201fdf25c66
  6. Date: Fri, 26 Mar 1993 20:28:16 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 81
  11. Archive-name: chiaro/part11
  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/blocproc.c.B src/formats.c src/gifstrip.man
  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 11 (of 18)."'
  23. if test -f 'src/blocproc.c.B' -a "${1}" != "-c" ; then 
  24.   echo shar: Will not clobber existing file \"'src/blocproc.c.B'\"
  25. else
  26.   echo shar: Extracting \"'src/blocproc.c.B'\" \(34266 characters\)
  27.   sed "s/^X//" >'src/blocproc.c.B' <<'END_OF_FILE'
  28. X        if (dlevel >= DLEVEL_FASCINATING)
  29. X        {
  30. X            fprintf(outstr, "\nFASCINATING: code table never cleared\n");
  31. X        }
  32. X        if (elevel >= ELEVEL_FASCINATING)
  33. X        {
  34. X            fb_close(infile);
  35. X            if (imd->lct_flag)
  36. X            {
  37. X                free(ctable);
  38. X            }
  39. X            return EXIT_NOTGIF;
  40. X        }
  41. X    }
  42. X    cratio = ((long)imd->im_wid * (long)imd->im_hi) *
  43. X              (long)((0 == imd->lct_flag) ? globsize : imd->lct_size);
  44. X    cratio = (blockbytes * 800L) / cratio;
  45. X    fprintf(outstr, "        compressed data is %ld%% of the size of uncompressed image\n", cratio);
  46. X    if (decomp != 0)
  47. X    {
  48. X        fprintf(outstr, "        %d colors referenced ", gld_colors);
  49. X
  50. X        if ((chandle = col_open()) != 0)
  51. X        {
  52. X            fprintf(outerr, "\nERROR: Cannot open color hash table.\n");
  53. X            fb_close(infile);
  54. X            if (imd->lct_flag)
  55. X            {
  56. X                free(ctable);
  57. X            }
  58. X            return EXIT_ERROR;
  59. X        }
  60. X        for (loop = 0; loop < (imd->lct_flag ? colors : globcolors); loop++)
  61. X        {
  62. X            if (gld_indused[loop] != 0)
  63. X            {
  64. X                if (col_enter(chandle, (imd->lct_flag ? &(ctable[loop]) : 
  65. X                                                        &(gct[loop]))) != 0)
  66. X                {
  67. X                    fprintf(outerr, 
  68. X                            "\nERROR: Error entering in color hash table.\n");
  69. X                    col_close(chandle, (HASHIT **) NULL);
  70. X                    fb_close(infile);
  71. X                    if (imd->lct_flag)
  72. X                    {
  73. X                        free(ctable);
  74. X                    }
  75. X                    return EXIT_ERROR;
  76. X                }
  77. X            }
  78. X        }
  79. X        if (col_getstat(chandle, &uniques, &entries) != 0)
  80. X        {
  81. X            fprintf(outerr,
  82. X                    "\nERROR: Error retrieving from color hash table.\n");
  83. X            col_close(chandle, (HASHIT **) NULL);
  84. X            fb_close(infile);
  85. X            if (imd->lct_flag)
  86. X            {
  87. X                free(ctable);
  88. X            }
  89. X            return EXIT_ERROR;
  90. X        }
  91. X        if (col_close(chandle, (HASHIT **) NULL) != 0)
  92. X        {
  93. X            fprintf(outerr, "\nERROR: Error closing color hash table.\n");
  94. X            fb_close(infile);
  95. X            if (imd->lct_flag)
  96. X            {
  97. X                free(ctable);
  98. X            }
  99. X            return EXIT_ERROR;
  100. X        }
  101. X        if (entries != gld_colors)
  102. X        {
  103. X            fprintf(outerr, "\nERROR: Unique color count returned by decomp does not match index count.\n");
  104. X            fb_close(infile);
  105. X            if (imd->lct_flag)
  106. X            {
  107. X                free(ctable);
  108. X            }
  109. X            return EXIT_ERROR;
  110. X        }
  111. X        fprintf(outstr, "(%ld unique)\n", uniques);
  112. X    }
  113. X
  114. X    /* If local color table, clean up. */
  115. X
  116. X    if (imd->lct_flag)
  117. X    {
  118. X        free(ctable);
  119. X    }
  120. X
  121. X    /* Return OK. */
  122. X
  123. X    return EXIT_OK;
  124. X} /* end of image_printout() */
  125. X
  126. X
  127. X/***************************************************************************
  128. X*   FUNCTION: PTE_PRINTOUT                                                 *
  129. X*                                                                          *
  130. X*   DESCRIPTION:                                                           *
  131. X*                                                                          *
  132. X*       Prints out info from Plain Text Extension.                         *
  133. X*                                                                          *
  134. X*   ENTRY:                                                                 *
  135. X*                                                                          *
  136. X*       infile - handle of file                                            *
  137. X*       ptes   - number of this Plain Text Extension                       *
  138. X*                                                                          *
  139. X*   EXIT:                                                                  *
  140. X*                                                                          *
  141. X*       Returns an errorlevel code.                                        *
  142. X*                                                                          *
  143. X*   CONSTRAINTS/SIDE EFFECTS:                                              *
  144. X*                                                                          *
  145. X***************************************************************************/
  146. Xint 
  147. X#ifdef __STDC__
  148. Xpte_printout(FB *infile, int ptes)
  149. X#else
  150. Xpte_printout(infile, ptes)
  151. XFB *infile;
  152. Xint ptes;
  153. X#endif
  154. X{
  155. X    ULONG status;
  156. X    GIF_PTE pte;
  157. X    int charhi, charwid;
  158. X    int loop;
  159. X    int unprint = 0;
  160. X    unsigned int fillcount;
  161. X    char toprint;
  162. X    unsigned int linecount;
  163. X
  164. X    fprintf(outstr, "PLAIN TEXT EXTENSION BLOCK %d:\n", ptes);
  165. X
  166. X    /* Check order. */
  167. X
  168. X    if ((status = follow(STATE_PTE)) != EXIT_OK)
  169. X    {
  170. X        fb_close(infile);
  171. X        return (int) status;
  172. X    }
  173. X
  174. X    /* Read extension. */
  175. X
  176. X    if ((status = gif_plaintextext(infile, &pte)) != ST_SUCCESS)
  177. X    {
  178. X        fprintf(outerr, "%s\n", errxlate(status));
  179. X        fb_close(infile);
  180. X        return EXIT_ERROR;
  181. X    }
  182. X
  183. X    /* Dump info. */
  184. X
  185. X    if (((RGB_TRIPLET *) NULL) == gct)
  186. X    {
  187. X        if (dlevel >= DLEVEL_FASCINATING)
  188. X        {
  189. X            fprintf(outstr, "\nFASCINATING: this file has no Global Color Table (GCT is used by PTE)\n");
  190. X        }
  191. X        if (elevel >= ELEVEL_FASCINATING)
  192. X        {
  193. X            fb_close(infile);
  194. X            free(pte.text);
  195. X            return EXIT_NOTGIF;
  196. X        }
  197. X    }
  198. X    charhi = pte.hi / pte.cellhi;
  199. X    charwid = pte.wid / pte.cellwid;
  200. X    if (verbose != 0)
  201. X    {
  202. X        fprintf(outstr,
  203. X          "   Character cell grid upper left corner (column, row): %5u, %5u\n",
  204. X          pte.left, pte.top);
  205. X        fprintf(outstr,
  206. X                "   Character cell size (pixels, width x height): %3u x %3u\n",
  207. X                pte.cellwid, pte.cellhi);
  208. X        fprintf(outstr,
  209. X                "   Character grid size (pixels, width x height): %3u x %3u\n",
  210. X                pte.wid, pte.hi);
  211. X        fprintf(outstr,
  212. X                "   Character grid size (chars, width x height): %3u x %3u\n",
  213. X                charwid, charhi);
  214. X    }
  215. X    else
  216. X    {
  217. X        fprintf(outstr,
  218. X              "   char cell %3u x %3u, grid %3u(%3u) x %3u(%3u) at %5u, %5u\n",
  219. X              pte.cellwid, pte.cellhi, pte.wid, charwid, pte.hi, charhi,
  220. X              pte.left, pte.top);
  221. X    }
  222. X
  223. X    if (((pte.left + pte.wid) > logwid) || ((pte.top + pte.hi) > loghi))
  224. X    {
  225. X        if (dlevel >= DLEVEL_VIOLATION)
  226. X        {
  227. X            fprintf(outstr, "\nVIOLATION: character grid does not fit on logical screen\n");
  228. X        }
  229. X        if (elevel >= ELEVEL_VIOLATION)
  230. X        {
  231. X            fb_close(infile);
  232. X            free(pte.text);
  233. X            return EXIT_NOTGIF;
  234. X        }
  235. X    }
  236. X
  237. X    if (((pte.wid % pte.cellwid) != 0) && (dlevel >= DLEVEL_NITPICK))
  238. X    {
  239. X        fprintf(outstr, "\nNITPICK: character grid not an integral number of character cells wide\n");
  240. X    }
  241. X    if (((pte.hi % pte.cellhi) != 0) && (dlevel >= DLEVEL_NITPICK))
  242. X    {
  243. X        fprintf(outstr, "\nNITPICK: character grid not an integral number of character cells high\n");
  244. X    }
  245. X    fprintf(outstr, "   Foreground color index %d ", pte.forecolor);
  246. X    if (gct != (RGB_TRIPLET *) NULL)
  247. X    {
  248. X        if (pte.forecolor > globcolors)
  249. X        {
  250. X            fprintf(outstr, "\nANOMALY: foreground color index off end of global color table.\n");
  251. X            fb_close(infile);
  252. X            free(pte.text);
  253. X            return EXIT_NOTGIF;
  254. X        }
  255. X        else
  256. X        {
  257. X            fprintf(outstr, "(RGB %03d/%03d/%03d)", gct[pte.forecolor].red,
  258. X                    gct[pte.forecolor].green, gct[pte.forecolor].blue);
  259. X        }
  260. X    }
  261. X    fprintf(outstr, "\n   Background color index %d ", pte.backcolor);
  262. X    if (gct != (RGB_TRIPLET *) NULL)
  263. X    {
  264. X        if (pte.backcolor > globcolors)
  265. X        {
  266. X            fprintf(outstr, "\nANOMALY: background color index off end of global color table.\n");
  267. X            fb_close(infile);
  268. X            free(pte.text);
  269. X            return EXIT_NOTGIF;
  270. X        }
  271. X        else
  272. X        {
  273. X            fprintf(outstr, "(RGB %03d/%03d/%03d)", gct[pte.backcolor].red,
  274. X                    gct[pte.backcolor].green, gct[pte.backcolor].blue);
  275. X        }
  276. X    }
  277. X    fprintf(outstr, "\n");
  278. X    if (transparent != -1)
  279. X    {
  280. X        if (transparent > globcolors)
  281. X        {
  282. X            if (dlevel >= DLEVEL_VIOLATION)
  283. X            {
  284. X                fprintf(outstr, "\nVIOLATION: bad transparency index(%d)\n",
  285. X                                                                  transparent);
  286. X            }
  287. X            if (elevel >= ELEVEL_VIOLATION)
  288. X            {
  289. X                fb_close(infile);
  290. X                free(pte.text);
  291. X                return EXIT_NOTGIF;
  292. X            }
  293. X        }
  294. X        if ((transparent != pte.backcolor) && (transparent != pte.forecolor))
  295. X        {
  296. X            if (dlevel >= DLEVEL_FASCINATING)
  297. X            {
  298. X                fprintf(outstr, "\nFASCINATING: transparency index does not match either foreground or background\n");
  299. X            }
  300. X            if (elevel >= ELEVEL_FASCINATING)
  301. X            {
  302. X                fb_close(infile);
  303. X                free(pte.text);
  304. X                return EXIT_NOTGIF;
  305. X            }
  306. X        }
  307. X    }
  308. X    transparent = -1;
  309. X
  310. X    unprint = count_unprint((UCHAR *) pte.text, pte.textln);
  311. X    fprintf(outstr, "   START TEXT (%u characters):\n", pte.textln);
  312. X    if (0 == do_hexdump)
  313. X    {
  314. X        for (loop = 0; loop < pte.textln; loop++)
  315. X        {
  316. X            if ((pte.text[loop] & 0x80) != 0)
  317. X            {
  318. X                toprint = ' ';
  319. X            }
  320. X            else if (isprint(pte.text[loop]))
  321. X            {
  322. X                toprint = pte.text[loop];
  323. X            }
  324. X            else
  325. X            {
  326. X                toprint = ' ';
  327. X            }
  328. X            fputc(toprint, outstr);
  329. X            if (((loop + 1) % charwid) == 0)
  330. X            {
  331. X                fputc('\n', outstr);
  332. X            }
  333. X        }
  334. X        if ((loop % charwid) != 0)
  335. X        {
  336. X            fputc('\n', outstr);
  337. X        }
  338. X    }
  339. X    else
  340. X    {
  341. X        for (linecount = 0, fillcount = pte.textln; fillcount != 0; linecount++)
  342. X        {
  343. X            fprintf(outstr, "   LINE %u:\n", (linecount + 1));
  344. X            hexdump((UCHAR *) (pte.text + (linecount * charwid)),
  345. X                    ((fillcount > charwid) ? charwid : fillcount));
  346. X            fillcount -= ((fillcount > charwid) ? charwid : fillcount);
  347. X        }
  348. X    }
  349. X    fprintf(outstr, "   END TEXT.\n");
  350. X
  351. X    if ((unprint != 0) && (dlevel >= DLEVEL_NITPICK))
  352. X    {
  353. X        fprintf(outstr, "\nNITPICK: %d unprintable characters in text\n",
  354. X                unprint);
  355. X    }
  356. X
  357. X    if (pte.textln > (charhi * charwid))
  358. X    {
  359. X        if (dlevel >= DLEVEL_VIOLATION)
  360. X        {
  361. X            fprintf(outstr, "VIOLATION: text is too long to fit into character grid\n");
  362. X        }
  363. X        if (elevel >= ELEVEL_VIOLATION)
  364. X        {
  365. X            fb_close(infile);
  366. X            free(pte.text);
  367. X            return EXIT_NOTGIF;
  368. X        }
  369. X    }
  370. X
  371. X    /* Clean up. */
  372. X
  373. X    free(pte.text);
  374. X
  375. X    return EXIT_OK;
  376. X} /* end of pte_printout() */
  377. X
  378. X
  379. X/***************************************************************************
  380. X*   FUNCTION: GCE_PRINTOUT                                                 *
  381. X*                                                                          *
  382. X*   DESCRIPTION:                                                           *
  383. X*                                                                          *
  384. X*       Prints out info from Graphic Control Extension.                    *
  385. X*                                                                          *
  386. X*   ENTRY:                                                                 *
  387. X*                                                                          *
  388. X*       infile - handle of file                                            *
  389. X*       gces   - number of this Graphic Control Extension                  *
  390. X*                                                                          *
  391. X*   EXIT:                                                                  *
  392. X*                                                                          *
  393. X*       Returns an errorlevel code.                                        *
  394. X*                                                                          *
  395. X*   CONSTRAINTS/SIDE EFFECTS:                                              *
  396. X*                                                                          *
  397. X***************************************************************************/
  398. Xint 
  399. X#ifdef __STDC__
  400. Xgce_printout(FB *infile, int gces)
  401. X#else
  402. Xgce_printout(infile, gces)
  403. X#endif
  404. X{
  405. X    ULONG status;
  406. X    GIF_GCE gce;
  407. X
  408. X    fprintf(outstr, "GRAPHIC CONTROL EXTENSION BLOCK %d:\n", gces);
  409. X
  410. X    /* Check order. */
  411. X
  412. X    if ((status = follow(STATE_GCE)) != EXIT_OK)
  413. X    {
  414. X        fb_close(infile);
  415. X        return (int) status;
  416. X    }
  417. X
  418. X    /* Read the graphic control extension. */
  419. X
  420. X    if ((status = gif_grafctrlext(infile, &gce)) != ST_SUCCESS)
  421. X    {
  422. X        fprintf(outerr, "%s\n", errxlate(status));
  423. X        fb_close(infile);
  424. X        return EXIT_ERROR;
  425. X    }
  426. X
  427. X    /* Dump info. */
  428. X
  429. X    if ((gce.raw_packed & 0xE0) != 0)
  430. X    {
  431. X        if (dlevel >= DLEVEL_NITPICK)
  432. X        {
  433. X            fprintf(outstr, "NITPICK: bits 5-7, byte 1 of graphic control extension should be 0\n");
  434. X        }
  435. X    }
  436. X    if (gce.disposal > 3)
  437. X    {
  438. X        fprintf(outstr,
  439. X                "ANOMALY: an undefined disposal method (%d) is given.\n",
  440. X                gce.disposal);
  441. X        fb_close(infile);
  442. X        return EXIT_NOTGIF;
  443. X    }
  444. X    else
  445. X    {
  446. X        fprintf(outstr, "   Disposal method: %d (", gce.disposal);
  447. X        switch (gce.disposal)
  448. X        {
  449. X            case 0:
  450. X                fprintf(outstr, "none");
  451. X                break;
  452. X
  453. X            case 1:
  454. X                fprintf(outstr, "leave in place");
  455. X                break;
  456. X
  457. X            case 2:
  458. X                fprintf(outstr, "restore to background");
  459. X                break;
  460. X
  461. X            case 3:
  462. X                fprintf(outstr, "restore to previous");
  463. X                break;
  464. X
  465. X            default:
  466. X                fprintf(outstr, "SANITY CHECK FAILED");
  467. X                break;
  468. X        }
  469. X        fprintf(outstr, ")\n");
  470. X    }
  471. X    fprintf(outstr, "   User input is %sexpected\n",
  472. X            ((0 == gce.userinflag) ? "not " : ""));
  473. X    if (0 == gce.transflag)
  474. X    {
  475. X        fprintf(outstr, "   Transparency disabled\n");
  476. X        transparent = -1;
  477. X    }
  478. X    else
  479. X    {
  480. X        fprintf(outstr, "   Transparency enabled (index %d)\n",
  481. X                gce.transparent);
  482. X        transparent = gce.transparent;
  483. X    }
  484. X    if (0 == gce.delay)
  485. X    {
  486. X        fprintf(outstr, "   No delay time specified\n");
  487. X    }
  488. X    else
  489. X    {
  490. X        fprintf(outstr, "   Delay time %d.%02d seconds\n", (gce.delay / 100),
  491. X                (gce.delay % 100));
  492. X    }
  493. X
  494. X    /* Return OK. */
  495. X
  496. X    return EXIT_OK;
  497. X} /* end of gce_printout() */
  498. X
  499. X
  500. X/***************************************************************************
  501. X*   FUNCTION: GENEXT_PRINTOUT                                              *
  502. X*                                                                          *
  503. X*   DESCRIPTION:                                                           *
  504. X*                                                                          *
  505. X*       Prints out info from a generic extension.                          *
  506. X*                                                                          *
  507. X*   ENTRY:                                                                 *
  508. X*                                                                          *
  509. X*       infile - handle of file                                            *
  510. X*       gens   - number of this generic extension                          *
  511. X*                                                                          *
  512. X*   EXIT:                                                                  *
  513. X*                                                                          *
  514. X*       Returns an errorlevel code.                                        *
  515. X*                                                                          *
  516. X*   CONSTRAINTS/SIDE EFFECTS:                                              *
  517. X*                                                                          *
  518. X***************************************************************************/
  519. Xint 
  520. X#ifdef __STDC__
  521. Xgenext_printout(FB *infile, int extype, int gens)
  522. X#else
  523. Xgenext_printout(infile, extype, gens)
  524. XFB *infile;
  525. Xint extype;
  526. Xint gens;
  527. X#endif
  528. X{
  529. X    ULONG status;
  530. X    ULONG blockbytes;
  531. X    unsigned int blocks;
  532. X
  533. X    UCHAR *data;
  534. X    int datalen;
  535. X
  536. X    fprintf(outstr, "GENERIC EXTENSION BLOCK %d:\n", gens);
  537. X    fprintf(outstr, "   extension block type %d\n", extype);
  538. X
  539. X    /* Check order. */
  540. X
  541. X    if ((status = follow(STATE_GENEXT)) != EXIT_OK)
  542. X    {
  543. X        fb_close(infile);
  544. X        return (int) status;
  545. X    }
  546. X
  547. X    /* Read data blocks until done. */
  548. X
  549. X    blockbytes = 0;
  550. X    blocks = 0;
  551. X    while (1)
  552. X    {
  553. X        /* Read block. */
  554. X
  555. X        if ((status = gif_readblock(infile, &data, &datalen)) != ST_SUCCESS)
  556. X        {
  557. X            fprintf(outerr, "%s\n", errxlate(status));
  558. X            fb_close(infile);
  559. X            return ((GIF_UNEOF_E == status) ? EXIT_UNEOF : EXIT_ERROR);
  560. X        }
  561. X
  562. X        /* Check length. */
  563. X
  564. X        if (0 == datalen)
  565. X        {
  566. X            /* If zero length, at end. */
  567. X
  568. X            break;
  569. X        }
  570. X
  571. X        /* Dump. */
  572. X
  573. X        fprintf(outstr, "   BLOCK %d (%d bytes):\n", blocks, datalen);
  574. X        hexdump(data, datalen);
  575. X
  576. X        /* Update. */
  577. X
  578. X        blockbytes += (ULONG) datalen;
  579. X        blocks++;
  580. X
  581. X        /* Free block. */
  582. X
  583. X        free(data);
  584. X    }
  585. X
  586. X    /* Print more info. */
  587. X
  588. X    fprintf(outstr, "   totals: %lu bytes of data in %u blocks\n", blockbytes,
  589. X            blocks);
  590. X
  591. X    /* Return OK. */
  592. X
  593. X    return EXIT_OK;
  594. X} /* end of genext_printout() */
  595. X
  596. X
  597. X/***************************************************************************
  598. X*   FUNCTION: COMMENT_PRINTOUT                                             *
  599. X*                                                                          *
  600. X*   DESCRIPTION:                                                           *
  601. X*                                                                          *
  602. X*       Prints out info from a comment extension.                          *
  603. X*                                                                          *
  604. X*   ENTRY:                                                                 *
  605. X*                                                                          *
  606. X*       infile   - handle of file                                          *
  607. X*       comments - number of this comment extension                        *
  608. X*                                                                          *
  609. X*   EXIT:                                                                  *
  610. X*                                                                          *
  611. X*       Returns an errorlevel code.                                        *
  612. X*                                                                          *
  613. X*   CONSTRAINTS/SIDE EFFECTS:                                              *
  614. X*                                                                          *
  615. X***************************************************************************/
  616. Xint 
  617. X#ifdef __STDC__
  618. Xcomment_printout(FB *infile, int comments)
  619. X#else
  620. Xcomment_printout(infile, comments)
  621. XFB *infile;
  622. Xint comments;
  623. X#endif
  624. X{
  625. X    char *text;
  626. X    unsigned int textln;
  627. X    unsigned int loop;
  628. X    unsigned int unprint;
  629. X    char toprint;
  630. X    ULONG status;
  631. X
  632. X    fprintf(outstr, "COMMENT EXTENSION BLOCK %d:\n", comments);
  633. X
  634. X    /* Check order. */
  635. X
  636. X    if ((status = follow(STATE_COMMENT)) != EXIT_OK)
  637. X    {
  638. X        fb_close(infile);
  639. X        return (int) status;
  640. X    }
  641. X
  642. X    /* Read the comment extension. */
  643. X
  644. X    if ((status = gif_commentext(infile, &text, &textln)) != ST_SUCCESS)
  645. X    {
  646. X        fprintf(outerr, "%s\n", errxlate(status));
  647. X        fb_close(infile);
  648. X        return EXIT_ERROR;
  649. X    }
  650. X
  651. X    fprintf(outstr, "   START TEXT (%u characters):\n", textln);
  652. X
  653. X    unprint = count_unprint((UCHAR *) text, textln);
  654. X    if (0 == do_hexdump)
  655. X    {
  656. X        for (loop = 0; loop < textln; loop++)
  657. X        {
  658. X            if ((text[loop] & 0x80) != 0)
  659. X            {
  660. X                toprint = ' ';
  661. X            }
  662. X            else if ((isprint(text[loop])) || (0x0A == text[loop]))
  663. X            {
  664. X                toprint = text[loop];
  665. X            }
  666. X            else
  667. X            {
  668. X                toprint = ' ';
  669. X            }
  670. X            fputc(toprint, outstr);
  671. X        }
  672. X        if ((toprint != 0x0D) && (toprint != 0x0A))
  673. X        {
  674. X            fputc('\n', outstr);
  675. X        }
  676. X    }
  677. X    else
  678. X    {
  679. X        hexdump((UCHAR *) text, textln);
  680. X    }
  681. X    fprintf(outstr, "   END TEXT.\n");
  682. X
  683. X    fprintf(outstr, "   %u unprintable characters.\n", unprint);
  684. X
  685. X    /* Clean up. */
  686. X
  687. X    free(text);
  688. X
  689. X    /* Return OK. */
  690. X
  691. X    return EXIT_OK;
  692. X} /* end of comment_printout() */
  693. X
  694. X
  695. X/***************************************************************************
  696. X*   FUNCTION: APP_PRINTOUT                                                 *
  697. X*                                                                          *
  698. X*   DESCRIPTION:                                                           *
  699. X*                                                                          *
  700. X*       Prints out info from an application-specific extension             *
  701. X*                                                                          *
  702. X*   ENTRY:                                                                 *
  703. X*                                                                          *
  704. X*       infile - handle of file                                            *
  705. X*       apps   - number of this application-specific extension             *
  706. X*                                                                          *
  707. X*   EXIT:                                                                  *
  708. X*                                                                          *
  709. X*       Returns an errorlevel code.                                        *
  710. X*                                                                          *
  711. X*   CONSTRAINTS/SIDE EFFECTS:                                              *
  712. X*                                                                          *
  713. X***************************************************************************/
  714. Xint 
  715. X#ifdef __STDC__
  716. Xapp_printout(FB *infile, int apps)
  717. X#else
  718. Xapp_printout(infile, apps)
  719. XFB *infile;
  720. Xint apps;
  721. X#endif
  722. X{
  723. X    GIF_APPL appl;
  724. X    ULONG status;
  725. X
  726. X    fprintf(outstr, "APPLICATION EXTENSION BLOCK %d:\n", apps);
  727. X
  728. X    /* Check order. */
  729. X
  730. X    if ((status = follow(STATE_APP)) != EXIT_OK)
  731. X    {
  732. X        fb_close(infile);
  733. X        return (int) status;
  734. X    }
  735. X
  736. X    /* Read the application extension. */
  737. X
  738. X    if ((status = gif_applext(infile, &appl)) != ST_SUCCESS)
  739. X    {
  740. X        fprintf(outerr, "%s\n", errxlate(status));
  741. X        fb_close(infile);
  742. X        return EXIT_ERROR;
  743. X    }
  744. X
  745. X    fprintf(outstr, "   application identifier:\n");
  746. X    hexdump((unsigned char *) appl.appl_id, GIF_APPL_APPLID_LEN);
  747. X
  748. X    fprintf(outstr, "   application authentication code:\n");
  749. X    hexdump(appl.appl_auth, GIF_APPL_AUTH_LEN);
  750. X
  751. X    fprintf(outstr, "   %d bytes of application data.\n", appl.appldatlen);
  752. X    hexdump(appl.appldata, appl.appldatlen);
  753. X
  754. X    /* Clean up. */
  755. X
  756. X    free(appl.appldata);
  757. X
  758. X    /* Return OK. */
  759. X
  760. X    return EXIT_OK;
  761. X} /* end of app_printout() */
  762. X
  763. X
  764. X/***************************************************************************
  765. X*   FUNCTION: FOLLOW                                                       *
  766. X*                                                                          *
  767. X*   DESCRIPTION:                                                           *
  768. X*                                                                          *
  769. X*       Determines whether a given block can legally follow the preceding  *
  770. X*       block.                                                             *
  771. X*                                                                          *
  772. X*   ENTRY:                                                                 *
  773. X*                                                                          *
  774. X*       state - type of next block                                         *
  775. X*                                                                          *
  776. X*   EXIT:                                                                  *
  777. X*                                                                          *
  778. X*       Returns EXIT_OK if next block can follow last block, EXIT_NOTGIF   *
  779. X*       otherwise.                                                         *
  780. X*                                                                          *
  781. X*   CONSTRAINTS/SIDE EFFECTS:                                              *
  782. X*                                                                          *
  783. X*       Requires type of last block in global laststate. Updates laststate *
  784. X*       with type of next block.                                           *
  785. X*                                                                          *
  786. X***************************************************************************/
  787. Xint 
  788. X#ifdef __STDC__
  789. Xfollow(int state)
  790. X#else
  791. Xfollow(state)
  792. Xint state;
  793. X#endif
  794. X{
  795. X    /* Can the given state follow the last state? */
  796. X
  797. X    if (0 == state_trans[laststate][state])
  798. X    {
  799. X        fprintf(outstr, "ANOMALY: a %s cannot follow a %s\n",
  800. X                state_names[state], state_names[laststate]);
  801. X        return EXIT_NOTGIF;
  802. X    }
  803. X
  804. X    /* Save current state. */
  805. X
  806. X    laststate = state;
  807. X
  808. X    /* Return OK. */
  809. X
  810. X    return EXIT_OK;
  811. X} /* end of follow() */
  812. X
  813. X
  814. X/***************************************************************************
  815. X*   FUNCTION: COUNT_UNPRINT  (STATIC)                                      *
  816. X*                                                                          *
  817. X*   DESCRIPTION:                                                           *
  818. X*                                                                          *
  819. X*       Counts unprintable characters in a string. Unprintable characters  *
  820. X*       are those > 127 and those for whom isprint() returns 0, except     *
  821. X*       CR and LF.                                                         *
  822. X*                                                                          *
  823. X*   ENTRY:                                                                 *
  824. X*                                                                          *
  825. X*       data - pointer to data to be checked                               *
  826. X*       len  - length of data to be checked                                *
  827. X*                                                                          *
  828. X*   EXIT:                                                                  *
  829. X*                                                                          *
  830. X*       Returns number of unprintable characters found.                    *
  831. X*                                                                          *
  832. X*   CONSTRAINTS/SIDE EFFECTS:                                              *
  833. X*                                                                          *
  834. X***************************************************************************/
  835. Xstatic unsigned int 
  836. X#ifdef __STDC__
  837. Xcount_unprint(UCHAR *data, unsigned int len)
  838. X#else
  839. Xcount_unprint(data, len)
  840. XUCHAR *data;
  841. Xunsigned int len;
  842. X#endif
  843. X{
  844. X    unsigned int loop;
  845. X    unsigned int unprint;
  846. X
  847. X    unprint = 0;
  848. X    for (loop = 0; loop < len; loop++)
  849. X    {
  850. X        if (((data[loop] & 0x80) != 0) ||
  851. X            ((isprint(data[loop]) == 0) && (data[loop] != 0x0D) &&
  852. X             (data[loop] != 0x0A)))
  853. X        {
  854. X            unprint++;
  855. X        }
  856. X    }
  857. X
  858. X    return unprint;
  859. X} /* end of static count_unprint() */
  860. X
  861. X
  862. X/***************************************************************************
  863. X*   FUNCTION: HEXDUMP  (STATIC)                                            *
  864. X*                                                                          *
  865. X*   DESCRIPTION:                                                           *
  866. X*                                                                          *
  867. X*       Does a hex/ASCII dump of a block of data.                          *
  868. X*                                                                          *
  869. X*   ENTRY:                                                                 *
  870. X*                                                                          *
  871. X*       data - pointer to data to be dumped                                *
  872. X*       len  - length of data to be dumped                                 *
  873. X*                                                                          *
  874. X*   EXIT:                                                                  *
  875. X*                                                                          *
  876. X*       Void.                                                              *
  877. X*                                                                          *
  878. X*   CONSTRAINTS/SIDE EFFECTS:                                              *
  879. X*                                                                          *
  880. X***************************************************************************/
  881. Xstatic VOID 
  882. X#ifdef __STDC__
  883. Xhexdump(UCHAR *data, unsigned int len)
  884. X#else
  885. Xhexdump(data, len)
  886. XUCHAR *data;
  887. Xunsigned int len;
  888. X#endif
  889. X{
  890. X    unsigned int loop;
  891. X    UCHAR toprint;
  892. X
  893. X    for (loop = 0; loop < len; loop++)
  894. X    {
  895. X        if ((data[loop] & 0x80) != 0)
  896. X        {
  897. X            toprint = ' ';
  898. X        }
  899. X        else if (isgraph(data[loop]))
  900. X        {
  901. X            toprint = data[loop];
  902. X        }
  903. X        else
  904. X        {
  905. X            toprint = ' ';
  906. X        }
  907. X        fprintf(outstr, "%c %02X    ", toprint, (int) data[loop]);
  908. X        if (((loop + 1) % HEXLINELEN) == 0)
  909. X        {
  910. X            fprintf(outstr, "\n");
  911. X        }
  912. X    }
  913. X    if ((loop % HEXLINELEN) != 0)
  914. X    {
  915. X        fprintf(outstr, "\n");
  916. X    }
  917. X
  918. X    return;
  919. X} /* end of static hexdump() */
  920. X
  921. X
  922. X/***************************************************************************
  923. X*   FUNCTION: COLORDUMP  (STATIC)                                          *
  924. X*                                                                          *
  925. X*   DESCRIPTION:                                                           *
  926. X*                                                                          *
  927. X*       Dumps RGB values from a color table.                               *
  928. X*                                                                          *
  929. X*   ENTRY:                                                                 *
  930. X*                                                                          *
  931. X*       ctable - pointer to color table to be dumped                       *
  932. X*       colors - length of color table, in colors                          *
  933. X*                                                                          *
  934. X*   EXIT:                                                                  *
  935. X*                                                                          *
  936. X*       Void.                                                              *
  937. X*                                                                          *
  938. X*   CONSTRAINTS/SIDE EFFECTS:                                              *
  939. X*                                                                          *
  940. X***************************************************************************/
  941. Xstatic VOID
  942. X#ifdef __STDC__
  943. Xcolordump(RGB_TRIPLET *ctable, int colors)
  944. X#else
  945. Xcolordump(ctable, colors)
  946. XRGB_TRIPLET *ctable;
  947. Xint colors;
  948. X#endif
  949. X{
  950. X    int loop;
  951. X
  952. X    for (loop = 0; loop < colors; loop++)
  953. X    {
  954. X        fprintf(outstr, "   %03d/%03d/%03d", ctable[loop].red,
  955. X                ctable[loop].green, ctable[loop].blue);
  956. X        if (((loop + 1) % COLORLINELEN) == 0)
  957. X        {
  958. X            fputc('\n', outstr);
  959. X        }
  960. X    }
  961. X    if ((loop % COLORLINELEN) != 0)
  962. X    {
  963. X        fputc('\n', outstr);
  964. X    }
  965. X
  966. X    return;
  967. X} /* end of static colordump() */
  968. X
  969. X
  970. X/***************************************************************************
  971. X*   FUNCTION: CALLBACK  (STATIC)                                           *
  972. X*                                                                          *
  973. X*   DESCRIPTION:                                                           *
  974. X*                                                                          *
  975. X*       The callback function required by the GLD module.                  *
  976. X*                                                                          *
  977. X*   ENTRY:                                                                 *
  978. X*                                                                          *
  979. X*       donelen  - number of bytes already placed in buffer by GLD module  *
  980. X*       buffer   - pointer to pointer-to-buffer variable within GLD        *
  981. X*                  module, so this function can change it if necessary     *
  982. X*       availlen - pointer to buffer-length variable within GLD module,    *
  983. X*                  so this function can change it if necessary             *
  984. X*       bufpos   - pointer to index-in-buffer variable within GLD module,  *
  985. X*                  so this function can change it if necessary             *
  986. X*                                                                          *
  987. X*   EXIT:                                                                  *
  988. X*                                                                          *
  989. X*       Nothing.                                                           *
  990. X*                                                                          *
  991. X*   CONSTRAINTS/SIDE EFFECTS:                                              *
  992. X*                                                                          *
  993. X***************************************************************************/
  994. Xstatic VOID
  995. X#ifdef __STDC__
  996. Xcallback(long donelen, UCHAR **buffer, long *availlen, long *bufpos)
  997. X#else
  998. Xcallback(donelen, buffer, availlen, bufpos)
  999. Xlong donelen;
  1000. XUCHAR **buffer;
  1001. Xlong *availlen;
  1002. Xlong *bufpos;
  1003. X#endif
  1004. X{
  1005. X    return;
  1006. X} /* end of static callback() */
  1007. X
  1008. END_OF_FILE
  1009.   if test 34266 -ne `wc -c <'src/blocproc.c.B'`; then
  1010.     echo shar: \"'src/blocproc.c.B'\" unpacked with wrong size!
  1011.   elif test -f 'src/blocproc.c.A'; then
  1012.     echo shar: Combining  \"'src/blocproc.c'\" \(64047 characters\)
  1013.     cat 'src/blocproc.c.A' 'src/blocproc.c.B' > 'src/blocproc.c'
  1014.     if test 64047 -ne `wc -c <'src/blocproc.c'`; then
  1015.       echo shar: \"'src/blocproc.c'\" combined with wrong size!
  1016.     else 
  1017.       rm src/blocproc.c.A src/blocproc.c.B
  1018.     fi 
  1019.   fi 
  1020.   # end of 'src/blocproc.c.B'
  1021. fi
  1022. if test -f 'src/formats.c' -a "${1}" != "-c" ; then 
  1023.   echo shar: Will not clobber existing file \"'src/formats.c'\"
  1024. else
  1025.   echo shar: Extracting \"'src/formats.c'\" \(5999 characters\)
  1026.   sed "s/^X//" >'src/formats.c' <<'END_OF_FILE'
  1027. X/***************************************************************************
  1028. X*   FORMATS.C                                                              *
  1029. X*   MODULE:  FM (FORMATS)                                                  *
  1030. X*   OS:      UNIX                                                          *
  1031. X*                                                                          *
  1032. X*   Copyright (c) 1993 James W. Birdsall. All Rights Reserved.             *
  1033. X*                                                                          *
  1034. X*   The Graphics Interchange Format(c) is the Copyright property of        *
  1035. X*   CompuServe Incorporated. GIF(sm) is a Service Mark property of         *
  1036. X*   CompuServe Incorporated.                                               *
  1037. X*                                                                          *
  1038. X*   $Id: formats.c,v 1.0 1993/02/10 01:50:36 jwbirdsa Exp $
  1039. X*                                                                          *
  1040. X*   Contains format table.                                                 *
  1041. X*                                                                          *
  1042. X***************************************************************************/
  1043. X
  1044. X#include "config.h"
  1045. X
  1046. X/*
  1047. X** system includes <>
  1048. X*/
  1049. X
  1050. X#include <stdio.h>
  1051. X
  1052. X/*
  1053. X** custom includes ""
  1054. X*/
  1055. X
  1056. X#include "depend.h"
  1057. X
  1058. X#include "fb.h"
  1059. X#include "formats.h"
  1060. X#include "gif.h"
  1061. X#include "img.h"
  1062. X#include "jfif.h"
  1063. X#include "sr.h"
  1064. X#include "tga.h"
  1065. X#include "pnm.h"
  1066. X#include "xbm.h"
  1067. X#include "bmp.h"
  1068. X#include "pcx.h"
  1069. X
  1070. X
  1071. X/*
  1072. X** local #defines
  1073. X*/
  1074. X
  1075. X/*
  1076. X** misc: copyright strings, version macros, etc.
  1077. X*/
  1078. X
  1079. Xstatic char CONST rcsid[] = "$Id: formats.c,v 1.0 1993/02/10 01:50:36 jwbirdsa Exp $";
  1080. X
  1081. X
  1082. X/*
  1083. X** typedefs
  1084. X*/
  1085. X
  1086. X/*
  1087. X** global variables
  1088. X*/
  1089. X
  1090. Xfsearch formatsearch[] =
  1091. X{ { GIF_MAIN,  { FORMAT_TYPE_MASK,                      FORMAT_GIF,  NULL } },
  1092. X  { "GIF87A",  { (FORMAT_TYPE_MASK | FORMAT_VERS_MASK), GIF_87A,     NULL } },
  1093. X  { "GIF89A",  { (FORMAT_TYPE_MASK | FORMAT_VERS_MASK), GIF_89A,     NULL } },
  1094. X  { IMG_MAIN,  { FORMAT_TYPE_MASK,                      FORMAT_IMG,  NULL } },
  1095. X  { "IMG_1",   { (FORMAT_TYPE_MASK | FORMAT_VERS_MASK), IMG_VER1,    NULL } },
  1096. X  { JFIF_MAIN, { FORMAT_TYPE_MASK,                      FORMAT_JFIF, NULL } },
  1097. X  { "JFIF101", { (FORMAT_TYPE_MASK | FORMAT_VERS_MASK), JFIF_VER101, NULL } },
  1098. X  { SR_MAIN,   { (FORMAT_TYPE_MASK | FORMAT_VERS_MASK), SR_1,        NULL } },
  1099. X  { TGA_MAIN,  { (FORMAT_TYPE_MASK | FORMAT_VERS_MASK), TGA_1,       NULL } },
  1100. X  { PBM_MAIN,  { FORMAT_TYPE_MASK,                      FORMAT_PBM,  NULL } },
  1101. X  { "PBM_NORM",{ (FORMAT_TYPE_MASK | FORMAT_VERS_MASK), PBM_NORM,    NULL } },
  1102. X  { "PBM_RAW", { (FORMAT_TYPE_MASK | FORMAT_VERS_MASK), PBM_RAW,     NULL } },
  1103. X  { PGM_MAIN,  { FORMAT_TYPE_MASK,                      FORMAT_PGM,  NULL } },
  1104. X  { "PGM_NORM",{ (FORMAT_TYPE_MASK | FORMAT_VERS_MASK), PGM_NORM,    NULL } },
  1105. X  { "PGM_RAW", { (FORMAT_TYPE_MASK | FORMAT_VERS_MASK), PGM_RAW,     NULL } },
  1106. X  { PPM_MAIN,  { FORMAT_TYPE_MASK,                      FORMAT_PPM,  NULL } },
  1107. X  { "PPM_NORM",{ (FORMAT_TYPE_MASK | FORMAT_VERS_MASK), PPM_NORM,    NULL } },
  1108. X  { "PPM_RAW", { (FORMAT_TYPE_MASK | FORMAT_VERS_MASK), PPM_RAW,     NULL } },
  1109. X  { XBM_MAIN,  { (FORMAT_TYPE_MASK | FORMAT_VERS_MASK), XBM_1,       NULL } },
  1110. X  { BMP_MAIN,  { FORMAT_TYPE_MASK,                      FORMAT_BMP,  NULL } },
  1111. X  { "WIN2BMP", { (FORMAT_TYPE_MASK | FORMAT_VERS_MASK), BMP_WIN2,    NULL } },
  1112. X  { "OS2BMP11",{ (FORMAT_TYPE_MASK | FORMAT_VERS_MASK), BMP_OS2_11,  NULL } },
  1113. X  { "WIN3BMP", { (FORMAT_TYPE_MASK | FORMAT_VERS_MASK), BMP_WIN3,    NULL } },
  1114. X  { "OS2BMP20",{ (FORMAT_TYPE_MASK | FORMAT_VERS_MASK), BMP_OS2_20,  NULL } },
  1115. X  { PCX_MAIN,  { FORMAT_TYPE_MASK,                      FORMAT_PCX,  NULL } },
  1116. X  { "PCX_25",  { (FORMAT_TYPE_MASK | FORMAT_VERS_MASK), PCX_VER25,   NULL } },
  1117. X  { "PCX_28",  { (FORMAT_TYPE_MASK | FORMAT_VERS_MASK), PCX_VER28,   NULL } },
  1118. X  { "PCX_28P", { (FORMAT_TYPE_MASK | FORMAT_VERS_MASK), PCX_VER28P,  NULL } },
  1119. X  { "PCX_30",  { (FORMAT_TYPE_MASK | FORMAT_VERS_MASK), PCX_VER30,   NULL } },
  1120. X  { "",        { 0,                                     0,           NULL } }
  1121. X};
  1122. X
  1123. X
  1124. X/*
  1125. X** function prototypes
  1126. X*/
  1127. X
  1128. X/*
  1129. X** functions
  1130. X*/
  1131. X
  1132. X
  1133. X/***************************************************************************
  1134. X*   FUNCTION:  fm_name                                                     *
  1135. X*                                                                          *
  1136. X*   DESCRIPTION:                                                           *
  1137. X*                                                                          *
  1138. X*       Searches in the formatsearch[] table for an entry with a matching  *
  1139. X*       format ID and returns the string associated.                       *
  1140. X*                                                                          *
  1141. X*   ENTRY:                                                                 *
  1142. X*                                                                          *
  1143. X*       format - format ID to match                                        *
  1144. X*                                                                          *
  1145. X*   EXIT:                                                                  *
  1146. X*                                                                          *
  1147. X*       Returns pointer to string or NULL.                                 *
  1148. X*                                                                          *
  1149. X*   CONSTRAINTS/SIDE EFFECTS:                                              *
  1150. X*                                                                          *
  1151. X***************************************************************************/
  1152. Xchar *
  1153. X#ifdef __STDC__
  1154. Xfm_name(ULONG format)
  1155. X#else
  1156. Xfm_name(format)
  1157. XULONG format;
  1158. X#endif
  1159. X{
  1160. X    int loop;
  1161. X
  1162. X    for (loop = 0; formatsearch[loop].name[0] != '\0'; loop++)
  1163. X    {
  1164. X        if (formatsearch[loop].value.value == format)
  1165. X        {
  1166. X            return formatsearch[loop].name;
  1167. X        }
  1168. X    }
  1169. X
  1170. X    return NULL;
  1171. X} /* end of fm_name() */
  1172. X
  1173. END_OF_FILE
  1174.   if test 5999 -ne `wc -c <'src/formats.c'`; then
  1175.     echo shar: \"'src/formats.c'\" unpacked with wrong size!
  1176.   fi
  1177.   # end of 'src/formats.c'
  1178. fi
  1179. if test -f 'src/gifstrip.man' -a "${1}" != "-c" ; then 
  1180.   echo shar: Will not clobber existing file \"'src/gifstrip.man'\"
  1181. else
  1182.   echo shar: Extracting \"'src/gifstrip.man'\" \(12508 characters\)
  1183.   sed "s/^X//" >'src/gifstrip.man' <<'END_OF_FILE'
  1184. X
  1185. X
  1186. X
  1187. XGIFSTRIP(1)              USER COMMANDS                GIFSTRIP(1)
  1188. X
  1189. X
  1190. X
  1191. XNAME
  1192. X     gifstrip - GIF file rebuilder
  1193. X
  1194. XSYNOPSIS
  1195. X     gifstrip [ -b ][ -r ][ -- ][ -f ][ -n ][ -m ][ -o ][  -h  ][
  1196. X     -c ][ -d ][ -s ][ -tpath ] target [ target... ]
  1197. X
  1198. XDESCRIPTION
  1199. X     Gifstrip is used to remove excess characters from the begin-
  1200. X     ning  and/or  end  of  a  GIF  file (usually the end). These
  1201. X     excess characters may be added in a variety of ways, includ-
  1202. X     ing XMODEM-protocol file transfers or transfer from a Macin-
  1203. X     tosh computer.  Gifstrip also does some basic file  analysis
  1204. X     and  enforces  a few format requirements which are sometimes
  1205. X     ignored. For temporary storage, it can use memory  or  disk.
  1206. X     By default, it uses memory first and only uses disk space to
  1207. X     make up the shortfall if there  is  not  enough  memory.  By
  1208. X     default,  gifstrip also keeps the original file around until
  1209. X     the new file has been  written  to  disk  successfully,  and
  1210. X     attempts  to  preserve the timestamp, owner, and permissions
  1211. X     of the original file.
  1212. X
  1213. XTARGETS
  1214. X     A target is a filename or directory. Multiple targets may be
  1215. X     specified  on  the command line. If a target is a directory,
  1216. X     all files in that directory will be processed. If no targets
  1217. X     are  specified  on the command line, a usage message will be
  1218. X     printed.
  1219. X
  1220. XOPTIONS
  1221. X     Options may not be combined. In the case of the  -t  option,
  1222. X     there  cannot be a space between the option and the argument
  1223. X     to the option.
  1224. X
  1225. X     -b   Operate in batch mode. All output is  suppressed.  This
  1226. X          option  should  be  first  on the command line or other
  1227. X          options may  generate  output  before  this  option  is
  1228. X          found.  When in batch mode, gifstrip adjusts its status
  1229. X          return to reflect the results of processing. The status
  1230. X          may be:
  1231. X
  1232. X               0     the file is GIF format and did not need
  1233. X                      stripping, or was stripped OK
  1234. X               1     file is not GIF format
  1235. X               2     an unexpected EOF was encountered
  1236. X                      (usually indicates a corrupt file)
  1237. X               3     any other error
  1238. X
  1239. X          Note that the status reflects the result  of  only  the
  1240. X          last file processed.  Therefore, in batch mode only one
  1241. X          file should be specified on the command line.
  1242. X
  1243. X
  1244. X
  1245. X
  1246. XSun Release Last change: $Date: 1993/03/02 00:44:17 $           1
  1247. X
  1248. X
  1249. X
  1250. X
  1251. X
  1252. X
  1253. XGIFSTRIP(1)              USER COMMANDS                GIFSTRIP(1)
  1254. X
  1255. X
  1256. X
  1257. X     --   Read targets from stdin. The list of targets must  have
  1258. X          only one target per line. Targets which are directories
  1259. X          will be expanded as usual, but wildcards  will  not  be
  1260. X          expanded.  Targets on the command line will be ignored.
  1261. X          For use with the -f option of chils.
  1262. X
  1263. X     -r   Redirects error messages to stderr.
  1264. X
  1265. X     -f   Forces gifstrip to rebuild the  file.  Normally,  files
  1266. X          are  rebuilt only when extra characters are found or if
  1267. X          the file does not meet strict format requirements  (see
  1268. X          the -n option below).
  1269. X
  1270. X     -m   Enables the stripping of files which have excess  char-
  1271. X          acters at the beginning. Ordinarily, such files are not
  1272. X          recognized as GIF  format  files.   With  this  option,
  1273. X          gifstrip  searches through the file looking for the GIF
  1274. X          format signature, and starts rebuilding the  file  when
  1275. X          it  finds  it.  Files  without excess characters at the
  1276. X          beginning will be processed normally.
  1277. X
  1278. X     -n   Disables strict format checking. Normally, the  follow-
  1279. X          ing violations are checked for, and the file rebuilt if
  1280. X          any are found:
  1281. X
  1282. X               (GIF87a only)    Global or local color table sorted
  1283. X                                 flag set
  1284. X               (GIF87a only)    Aspect ratio value nonzero
  1285. X               (GIF87a, GIF89a) Local color table size given but local
  1286. X                                 color table flag not set (no local
  1287. X                                 color table)
  1288. X               (GIF89a only)    Local color table sorted flag set but
  1289. X                                 local color table flag not set (no
  1290. X                                 local color table)
  1291. X
  1292. X          If the -n option is used, these violations are ignored.
  1293. X          If  the  file  is rebuilt due to excess characters, any
  1294. X          violations will be propagated into the rebuilt file.
  1295. X
  1296. X     -o   Erases the original file  before  writing  the  rebuilt
  1297. X          file.  By  default,  gifstrip retains the original file
  1298. X          until the rebuilt file has been completely  written  to
  1299. X          disk.  Thus, in case of error, either the original file
  1300. X          or the rebuilt file will exist on disk no  matter  when
  1301. X          gifstrip  is  aborted, providing a measure of security.
  1302. X          However, sometimes it is necessary to  process  a  file
  1303. X          which is on a nearly-full drive, with insufficient room
  1304. X          for a second copy of the file. This option  allows  for
  1305. X          that case.
  1306. X
  1307. X     -h   Prints a usage message. No files are processed and  all
  1308. X          other options are ignored.
  1309. X
  1310. X
  1311. X
  1312. XSun Release Last change: $Date: 1993/03/02 00:44:17 $           2
  1313. X
  1314. X
  1315. X
  1316. X
  1317. X
  1318. X
  1319. XGIFSTRIP(1)              USER COMMANDS                GIFSTRIP(1)
  1320. X
  1321. X
  1322. X
  1323. X     -c   Disables use of memory for temporary storage. Cannot be
  1324. X          combined with the -d option.
  1325. X
  1326. X     -d   Disables use of disk for temporary storage.  Cannot  be
  1327. X          combined with the -c option.
  1328. X
  1329. X     -s   Equivalent to -c.
  1330. X
  1331. X     -tpath
  1332. X          Specifies a path for the  disk  temporary  file.  There
  1333. X          must not be space between the "-t" and the path.
  1334. X
  1335. XOUTPUT
  1336. X     Gifstrip produces at least two  lines  of  output  for  each
  1337. X     file. In some cases, it may produce several pages of output.
  1338. X
  1339. X     For each file specified, gifstrip outputs the line "Process-
  1340. X     ing  filename...   ".  If the file is not a GIF format file,
  1341. X     gifstrip then outputs the message "ERROR: File is not a  GIF
  1342. X     format file." and proceeds to the next file.
  1343. X
  1344. X  FILE HEADER LINE
  1345. X     GIF87A  G--   21463    250 x   200 @ 128   junk/vla.gif
  1346. X     GIF89A  G-A   34256    320 x   200 @ 256   junk/glass.gif
  1347. X
  1348. X     The columns from left to right are:
  1349. X        +  the format identifier (GIF87A or GIF89A)
  1350. X        +  G file has a global color table
  1351. X           - file does not have a global color table
  1352. X        +  S global color table is sorted
  1353. X           - global color table is not sorted
  1354. X        +  A aspect ratio is specified
  1355. X           - no aspect ratio
  1356. X        +  the file size
  1357. X        +  the width in pixels of the logical screen
  1358. X        +  the height in pixels of the logical screen
  1359. X        +  the number of colors in the global color table (--- if
  1360. X             no global color table)
  1361. X        +  the filename
  1362. X
  1363. X     If gifstrip encounters in the file header one of the  format
  1364. X     violations  listed under the -n option, and the -n option is
  1365. X     not in effect, it will print a message describing the viola-
  1366. X     tion  after  the  file  header line. This message will start
  1367. X     with "FYI:".
  1368. X
  1369. X  IMAGE LINE
  1370. X     G-S  (  0,  0)    250 x   200 @ 128   20970BY    83BL
  1371. X
  1372. X     The columns from left to right are:
  1373. X        +  G image uses global color table
  1374. X
  1375. X
  1376. X
  1377. X
  1378. XSun Release Last change: $Date: 1993/03/02 00:44:17 $           3
  1379. X
  1380. X
  1381. X
  1382. X
  1383. X
  1384. X
  1385. XGIFSTRIP(1)              USER COMMANDS                GIFSTRIP(1)
  1386. X
  1387. X
  1388. X
  1389. X           L image uses local color table
  1390. X        +  S local color table is sorted
  1391. X           - local color table is not sorted
  1392. X        +  S image is stored sequentially
  1393. X           I image is stored interlaced
  1394. X        +  offset of upper left corner of the image on the  logi-
  1395. X             cal screen, (horizontal,vertical)
  1396. X        +  the width in pixels of the image
  1397. X        +  the height in pixels of the image
  1398. X        +  the number of colors in either  the  global  or  local
  1399. X             color table, whichever the image uses
  1400. X        +  the number of data bytes in the image
  1401. X        +  the number of blocks into which  the  data  bytes  are
  1402. X             broken up
  1403. X
  1404. X     If gifstrip encounters in an image one of the format  viola-
  1405. X     tions  listed  under the -n option, and the -n option is not
  1406. X     in effect, it will print a mesasge describing the  violation
  1407. X     BEFORE it prints the image line for that image. This message
  1408. X     will start with "FYI:".
  1409. X
  1410. X  EXTENSION BLOCK LINE
  1411. X     When an extension block is encountered, gifstrip will  print
  1412. X     one of several lines. If the format is GIF87a, or the exten-
  1413. X     sion block is not one of the four dedicated types defined in
  1414. X     GIF89a, gifstrip prints:
  1415. X
  1416. X        Type xxx Extension Block
  1417. X
  1418. X     where xxx is the type number given in  the  extension  block
  1419. X     header.  If it is one of the four dedicated types defined in
  1420. X     GIF89a, gifstrip prints:
  1421. X
  1422. X        Plain Text Extension Block
  1423. X        Graphic Control Extension Block
  1424. X        Comment Extension Block
  1425. X        Application Extension Block
  1426. X
  1427. X     as appropriate.
  1428. X
  1429. X     After identifying the extenion  type,  gifstrip  prints  the
  1430. X     number of data bytes and data blocks in the extension block,
  1431. X     on the same line, in the same format as for an image.
  1432. X
  1433. X  TERMINATOR LINE
  1434. X     If the file is not corrupt, gifstrip will eventually come to
  1435. X     the  GIF  format  terminator  character.  When it encounters
  1436. X     this, it prints:
  1437. X
  1438. X        GIF Terminator
  1439. X
  1440. X
  1441. X
  1442. X
  1443. X
  1444. XSun Release Last change: $Date: 1993/03/02 00:44:17 $           4
  1445. X
  1446. X
  1447. X
  1448. X
  1449. X
  1450. X
  1451. XGIFSTRIP(1)              USER COMMANDS                GIFSTRIP(1)
  1452. X
  1453. X
  1454. X
  1455. X     and ceases processing the original file. It then  determines
  1456. X     whether the file needs to be rebuilt or not.
  1457. X
  1458. X  NO REBUILD
  1459. X     If the file does not have excess characters  on  either  the
  1460. X     beginning  or  the  end, and either does not have any format
  1461. X     violations or the -n option is in effect, and the -f  option
  1462. X     is  not  in  effect, the file will not be rebuilt.  Gifstrip
  1463. X     prints:
  1464. X
  1465. X        No work to be done. File unchanged.
  1466. X
  1467. X     and proceeds to the next file.
  1468. X
  1469. X  REBUILD
  1470. X     If the file does need to be rebuilt, gifstrip prints:
  1471. X
  1472. X         New size:    xxx   Bytes removed:    yyy
  1473. X     Recopying... done.
  1474. X
  1475. X     where xxx is the size in bytes of the rebuilt file, and  yyy
  1476. X     is  the difference between the size of the original file and
  1477. X     the size of the rebuilt file. The next line ("Recopying...")
  1478. X     is simply to indicate that gifstrip is doing something. When
  1479. X     gifstrip prints "done." it is finished writing  the  rebuilt
  1480. X     file  and  proceeds  to the next file. The timestamp, owner,
  1481. X     and permissions of the original file are preserved  as  well
  1482. X     as possible in the rebuilt file.
  1483. X
  1484. X  OTHER LINES
  1485. X     Gifstrip may issue error messages at any  time.  These  will
  1486. X     begin with "WARNING:", "ERROR:", or "FATAL ERROR:".
  1487. X
  1488. X     There are two other messages that gifstrip may issue:
  1489. X
  1490. X     If gifstrip is used with the -m option and encounters excess
  1491. X     characters  at  the beginning of a file, it prints an "FYI:"
  1492. X     message stating that leading junk bytes  have  been  skipped
  1493. X     over  and  gives  the  number of bytes skipped. This message
  1494. X     appears before the file header line.
  1495. X
  1496. X     If gifstrip encounters extraneous  characters  between  sec-
  1497. X     tions, it will issue an "FYI:" message describing the viola-
  1498. X     tion and giving the number of  extraneous  characters.  This
  1499. X     message appears between the lines describing the sections on
  1500. X     either side of the extraneous characters.  This  is  an  FYI
  1501. X     message  because, technically, gifstrip can fix the problem.
  1502. X     However, extraneous characters between sections are  forbid-
  1503. X     den by the format specification. If present, they indicate a
  1504. X     serious problem in the encoder which produced the image, or,
  1505. X     more likely, a corrupt GIF file.
  1506. X
  1507. X
  1508. X
  1509. X
  1510. XSun Release Last change: $Date: 1993/03/02 00:44:17 $           5
  1511. X
  1512. X
  1513. X
  1514. X
  1515. X
  1516. X
  1517. XGIFSTRIP(1)              USER COMMANDS                GIFSTRIP(1)
  1518. X
  1519. X
  1520. X
  1521. XCOPYRIGHT
  1522. X     Gifstrip is copyright 1993 by James W. Birdsall, all  rights
  1523. X     reserved.
  1524. X
  1525. X     The Graphics Interchange Format(c) is the Copyright property
  1526. X     of  CompuServe  Incorporated. GIF(sm) is a Service Mark pro-
  1527. X     perty of CompuServe Incorporated.
  1528. X
  1529. XAUTHOR
  1530. X     James W. Birdsall
  1531. X        support@picarefy.com
  1532. X        uunet!uw-coco!amc-gw!picarefy!support
  1533. X        CompuServe: 71261,1731
  1534. X        GEnie: J.BIRDSALL2
  1535. X
  1536. XSEE ALSO
  1537. X     chils(1), gifcheck(1)
  1538. X
  1539. X
  1540. X
  1541. X
  1542. X
  1543. X
  1544. X
  1545. X
  1546. X
  1547. X
  1548. X
  1549. X
  1550. X
  1551. X
  1552. X
  1553. X
  1554. X
  1555. X
  1556. X
  1557. X
  1558. X
  1559. X
  1560. X
  1561. X
  1562. X
  1563. X
  1564. X
  1565. X
  1566. X
  1567. X
  1568. X
  1569. X
  1570. X
  1571. X
  1572. X
  1573. X
  1574. X
  1575. X
  1576. XSun Release Last change: $Date: 1993/03/02 00:44:17 $           6
  1577. X
  1578. X
  1579. X
  1580. END_OF_FILE
  1581.   if test 12508 -ne `wc -c <'src/gifstrip.man'`; then
  1582.     echo shar: \"'src/gifstrip.man'\" unpacked with wrong size!
  1583.   fi
  1584.   # end of 'src/gifstrip.man'
  1585. fi
  1586. echo shar: End of archive 11 \(of 18\).
  1587. cp /dev/null ark11isdone
  1588. MISSING=""
  1589. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 ; do
  1590.     if test ! -f ark${I}isdone ; then
  1591.     MISSING="${MISSING} ${I}"
  1592.     fi
  1593. done
  1594. if test "${MISSING}" = "" ; then
  1595.     echo You have unpacked all 18 archives.
  1596.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1597. else
  1598.     echo You still must unpack the following archives:
  1599.     echo "        " ${MISSING}
  1600. fi
  1601. exit 0
  1602. exit 0 # Just in case...
  1603.