home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 1 / 1661 < prev    next >
Encoding:
Internet Message Format  |  1990-12-28  |  45.4 KB

  1. From: ajcd@cs.ed.ac.uk (Angus Duggan)
  2. Newsgroups: alt.sources
  3. Subject: libpbm.a required for pbmtopk
  4. Message-ID: <164@skye.cs.ed.ac.uk>
  5. Date: 11 Aug 90 18:25:13 GMT
  6.  
  7. By (not very) popular demand, here's the pbm library required for pbmtopk.
  8. This is exactly as it came off our X11R4 distribution, except that only the
  9. files required for pbmtopk are in here; the Imakefile is not supplied, because
  10. if you were using Imake, you'd have X11 anyway :-)
  11.  
  12. This code is all by Jef Poskanzer:
  13.  
  14. # Copyright (C) 1989 by Jef Poskanzer.
  15. #
  16. # Permission to use, copy, modify, and distribute this software and its
  17. # documentation for any purpose and without fee is hereby granted, provided
  18. # that the above copyright notice appear in all copies and that both that
  19. # copyright notice and this permission notice appear in supporting
  20. # documentation.  This software is provided "as is" without express or
  21. # implied warranty.
  22.  
  23. ==
  24. Angus Duggan, Department of Computer Science,    | Ignorance of the manual is
  25. University of Edinburgh, JCMB,            | no excuse.
  26. The King's Buildings, Mayfield Road,        | JANET:  ajcd@uk.ac.ed.lfcs
  27. Edinburgh, EH9 3JZ, Scotland.    | OR:  ajcd%lfcs.ed.ac.uk@nsfnet-relay.ac.uk
  28.  
  29. #! /bin/sh
  30. # This is a shell archive.  Remove anything before this line, then unpack
  31. # it by saving it into a file and typing "sh file".  To overwrite existing
  32. # files, type "sh file -c".  You can also feed this as standard input via
  33. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  34. # will see the following message at the end:
  35. #        "End of archive 1 (of 1)."
  36. # Contents:  ../pbmplus.h Makefile libpbm.3 libpbm.h libpbm1.c
  37. #   libpbm2.c libpbm3.c libpbm4.c libpbm5.c pbm.5 pbm.h rast.h
  38. # Wrapped by ajcd@harpo on Sat Aug 11 19:13:48 1990
  39. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  40. if test -f ../pbmplus.h -a "${1}" != "-c" ; then 
  41.   echo shar: Will not over-write existing file \"../pbmplus.h\"
  42. else
  43. echo shar: Extracting \"../pbmplus.h\" \(4252 characters\)
  44. sed "s/^X//" >../pbmplus.h <<'END_OF_../pbmplus.h'
  45. X/* pbmplus.h - header file for PBM, PGM, PPM, and PNM
  46. X*/
  47. X
  48. X#ifndef _PBMPLUS_H_
  49. X#define _PBMPLUS_H_
  50. X
  51. X#if ! ( defined(BSD) || defined(SYSV) )
  52. X/* CONFIGURE: If your system is >= 4.2BSD, set the BSD option; if you're a
  53. X** System V site, set the SYSV option.  If you're an ANSI C site, you're
  54. X** probably better off setting SYSV.  This mostly has to do with string
  55. X** functions.
  56. X*/
  57. X#define BSD
  58. X/* #define SYSV */
  59. X#endif
  60. X
  61. X/* CONFIGURE: If you want to enable writing "raw" files, set this option.
  62. X** "Raw" files are smaller, and much faster to read and write, but you
  63. X** must have a filesystem that allows all 256 ASCII characters to be read
  64. X** and written.  Also, you will no longer be able to mail P?M files without 
  65. X** using uuencode or the equivalent.  Note that reading "raw" files works
  66. X** whether writing is enabled or not.
  67. X*/
  68. X#define PBMPLUS_RAWBITS
  69. X
  70. X/* CONFIGURE: On some systems, the putc() macro is broken and will return
  71. X** EOF when you write out a 255.  For example, ULTRIX does this.  This
  72. X** only matters if you have defined RAWBITS.  To test whether your system
  73. X** is broken this way, go ahead and compile things with RAWBITS defined,
  74. X** and then try "pbmmake -b 8 1 > file".  If it works, fine.  If not,
  75. X** define BROKENPUTC1 and try again - if that works, good.  Otherwise,
  76. X** BROKENPUTC2 is guaranteed to work, although it's 1.9 times slower.
  77. X*/
  78. X/* #define PBMPLUS_BROKENPUTC1 */
  79. X/* #define PBMPLUS_BROKENPUTC2 */
  80. X
  81. X#ifdef PBMPLUS_BROKENPUTC1
  82. X#undef putc
  83. X/* This is a fixed version of putc() that should work on most Unix systems. */
  84. X#define putc(x,p) (--(p)->_cnt>=0? ((int)(unsigned char)(*(p)->_ptr++=(unsigned char)(x))) :
  85. _flsbuf((unsigned char)(x),p))
  86. X#endif /*PBMPLUS_BROKENPUTC1*/
  87. X#ifdef PBMPLUS_BROKENPUTC2
  88. X#undef putc
  89. X/* For this one, putc() becomes a function, defined in pbm/libpbm1.c. */
  90. X#endif /*PBMPLUS_BROKENPUTC2*/
  91. X
  92. X/* CONFIGURE: PGM can store gray values as either bytes or shorts.  For most
  93. X** applications, bytes will be big enough, and the memory savings can be
  94. X** substantial.  However, if you need more than 8 bits of resolution, then
  95. X** define this symbol.
  96. X**
  97. X** If you are not making PGM, you can ignore this.
  98. X*/
  99. X/* #define PGM_BIGGRAYS */
  100. X
  101. X/* CONFIGURE: Normally, PPM handles a pixel as a struct of three grays.
  102. X** It can also be configured to pack the three values into a single longword,
  103. X** 10 bits each.  If you have configured PGM with the PGM_BIGGRAYS option
  104. X** (store grays as shorts), AND you don't need more than 10 bits for each
  105. X** color component, AND you care more about memory use than speed, then
  106. X** this option might be a win.  Under these circumstances it will make
  107. X** some of the programs use 1.5 times less space,  but all of the programs
  108. X** will run about 1.4 times slower.
  109. X**
  110. X** If you are not using PGM_BIGGRAYS, then this option is useless -- it
  111. X** doesn't save any space, but it still slows things down.
  112. X**
  113. X** If you are not making PPM, you can ignore this.
  114. X*/
  115. X/* #define PPM_PACKCOLORS */
  116. X
  117. X/* CONFIGURE: uncomment this to enable debugging checks. */
  118. X/* #define DEBUG */
  119. X
  120. X/* End of configurable definitions. */
  121. X
  122. X/* Variable-sized arrays definitions. */
  123. X
  124. Xchar **pm_allocarray( /* int cols, int rows, size */ );
  125. Xchar *pm_allocrow( /* int cols, size */);
  126. Xvoid pm_freearray( /* char **its, int rows */ );
  127. Xvoid pm_freerow( /* char *itrow */ );
  128. X
  129. X/* Error handling definitions. */
  130. X
  131. Xextern char *pm_progname;    /* every main() must assign argv[0] to this */
  132. Xvoid pm_message( /* char *fmt, arg, arg, arg, arg, arg */ );
  133. Xvoid pm_error( /* char *fmt, arg, arg, arg, arg, arg */ ); /* doesn't return */
  134. Xvoid pm_perror( /* char *reason */ );            /* doesn't return */
  135. Xvoid pm_usage( /* char *usage */ );            /* doesn't return */
  136. X
  137. X/* File open/close that handles "-" as stdin and checks errors. */
  138. X
  139. XFILE *pm_openr( /* char *name */ );
  140. Xvoid pm_close( /* FILE *f */ );
  141. X
  142. X/* Endian I/O. */
  143. X
  144. Xint pm_readbigshort( /* FILE *in, short *sP */ );
  145. Xint pm_writebigshort( /* FILE *out, short s */ );
  146. Xint pm_readbiglong( /* FILE *in, long *lP */ );
  147. Xint pm_writebiglong( /* FILE *out, long l */ );
  148. Xint pm_readlittleshort( /* FILE *in, short *sP */ );
  149. Xint pm_writelittleshort( /* FILE *out, short s */ );
  150. Xint pm_readlittlelong( /* FILE *in, long *lP */ );
  151. Xint pm_writelittlelong( /* FILE *out, long l */ );
  152. X
  153. X#endif /*_PBMPLUS_H_*/
  154. END_OF_../pbmplus.h
  155. if test 4252 -ne `wc -c <../pbmplus.h`; then
  156.     echo shar: \"../pbmplus.h\" unpacked with wrong size!
  157. fi
  158. # end of overwriting check
  159. fi
  160. if test -f Makefile -a "${1}" != "-c" ; then 
  161.   echo shar: Will not over-write existing file \"Makefile\"
  162. else
  163. echo shar: Extracting \"Makefile\" \(4089 characters\)
  164. sed "s/^X//" >Makefile <<'END_OF_Makefile'
  165. X# Makefile for pbm tools.
  166. X#
  167. X# Copyright (C) 1989 by Jef Poskanzer.
  168. X#
  169. X# Permission to use, copy, modify, and distribute this software and its
  170. X# documentation for any purpose and without fee is hereby granted, provided
  171. X# that the above copyright notice appear in all copies and that both that
  172. X# copyright notice and this permission notice appear in supporting
  173. X# documentation.  This software is provided "as is" without express or
  174. X# implied warranty.
  175. X
  176. X# Default values, usually overridden by top-level Makefile.
  177. X# CC =        cc
  178. XCC =        gcc -fcombine-regs
  179. X# CFLAGS =    
  180. X# CFLAGS =    -g
  181. XCFLAGS =    -O
  182. X# CFLAGS =    -g -O
  183. XLDFLAGS =    -s
  184. X# LDFLAGS =    
  185. XINSTALLBINARIES =    /usr/new/pbm
  186. XINSTALLMANUALS1 =    /usr/man/mann
  187. XINSTALLMANUALS3 =    /usr/man/mann
  188. XINSTALLMANUALS5 =    /usr/man/mann
  189. X
  190. XSHELL =        /bin/sh
  191. XALLCFLAGS =    $(CFLAGS)
  192. XLIBPBM =    libpbm.a
  193. X
  194. XBINARIES =    brushtopbm cmuwmtopbm g3topbm icontopbm gemtopbm macptopbm \
  195. X        mgrtopbm pbmlife pbmmake pbmmask pbmpaste pbmreduce \
  196. X        pbmtoascii pbmtobbnbg pbmtocmuwm pbmtog3 pbmtogo pbmtoicon \
  197. X        pbmtolj pbmtomacp pbmtomgr pbmtoptx pbmtorast pbmtox10bm \
  198. X        pbmtoxbm pbmtoxwd pbmupc pcxtopbm picttopbm rasttopbm xbmtopbm \
  199. X        xwdtopbm
  200. X
  201. XMANUALS1 =    brushtopbm.1 cmuwmtopbm.1 g3topbm.1 icontopbm.1 \
  202. X        gemtopbm.1 macptopbm.1 mgrtopbm.1 \
  203. X        pbmlife.1 pbmmake.1 pbmmask.1 pbmpaste.1 \
  204. X        pbmreduce.1 pbmtoascii.1 pbmtobbnbg.1 pbmtocmuwm.1 pbmtog3.1 \
  205. X        pbmtogo.1 pbmtoicon.1 pbmtolj.1 pbmtomacp.1 pbmtomgr.1 \
  206. X        pbmtoptx.1 pbmtorast.1 pbmtox10bm.1 pbmtoxbm.1 \
  207. X        pbmtoxwd.1 pbmupc.1 pcxtopbm.1 picttopbm.1 rasttopbm.1 \
  208. X        xbmtopbm.1 xwdtopbm.1
  209. XMANUALS3 =    libpbm.3
  210. XMANUALS5 =    pbm.5
  211. X
  212. Xall:        binaries
  213. X
  214. Xinstall:    installbinaries installmanuals
  215. X# install:    installbinaries
  216. X
  217. Xbinaries:    $(BINARIES)
  218. X
  219. Xinstallbinaries:    binaries
  220. X    cp $(BINARIES) $(INSTALLBINARIES)
  221. X
  222. Xinstallmanuals:
  223. X    cp $(MANUALS1) $(INSTALLMANUALS1)
  224. X    cp $(MANUALS3) $(INSTALLMANUALS3)
  225. X    cp $(MANUALS5) $(INSTALLMANUALS5)
  226. X
  227. X# Rule for plain programs.
  228. X$(BINARIES):    pbm.h ../pbmplus.h $(LIBPBM)
  229. X    $(CC) $(ALLCFLAGS) $(LDFLAGS) -o $@ $@.c $(LIBPBM)
  230. X
  231. X# And library.
  232. X$(LIBPBM):    libpbm1.o libpbm2.o libpbm3.o libpbm4.o libpbm5.o
  233. X    -rm $(LIBPBM)
  234. X    ar rc $(LIBPBM) libpbm1.o libpbm2.o libpbm3.o libpbm4.o libpbm5.o
  235. X    -ranlib $(LIBPBM)
  236. X
  237. Xlibpbm1.o:    pbm.h ../pbmplus.h libpbm.h libpbm1.c
  238. X    $(CC) $(ALLCFLAGS) -c libpbm1.c
  239. Xlibpbm2.o:    pbm.h ../pbmplus.h libpbm.h libpbm2.c
  240. X    $(CC) $(ALLCFLAGS) -c libpbm2.c
  241. Xlibpbm3.o:    pbm.h ../pbmplus.h libpbm.h libpbm3.c
  242. X    $(CC) $(ALLCFLAGS) -c libpbm3.c
  243. Xlibpbm4.o:    pbm.h ../pbmplus.h libpbm.h libpbm4.c
  244. X    $(CC) $(ALLCFLAGS) -c libpbm4.c
  245. Xlibpbm5.o:    pbm.h ../pbmplus.h rast.h libpbm5.c
  246. X    $(CC) $(ALLCFLAGS) -c libpbm5.c
  247. X
  248. X# Other dependencies.
  249. Xbrushtopbm:    brushtopbm.c
  250. Xcmuwmtopbm:    cmuwmtopbm.c cmuwm.h
  251. Xg3topbm:    g3topbm.c g3.h
  252. Xicontopbm:    icontopbm.c
  253. Xgemtopbm:    gemtopbm.c
  254. Xmacptopbm:    macptopbm.c macp.h
  255. Xmgrtopbm:    mgrtopbm.c mgr.h
  256. Xpbmlife:    pbmlife.c
  257. Xpbmmake:    pbmmake.c
  258. Xpbmmask:    pbmmask.c
  259. Xpbmpaste:    pbmpaste.c
  260. Xpbmreduce:    pbmreduce.c
  261. Xpbmtoascii:    pbmtoascii.c
  262. Xpbmtobbnbg:    pbmtobbnbg.c
  263. Xpbmtocmuwm:    pbmtocmuwm.c cmuwm.h
  264. Xpbmtog3:    pbmtog3.c g3.h
  265. Xpbmtogo:    pbmtogo.c
  266. Xpbmtoicon:    pbmtoicon.c
  267. Xpbmtolj:    pbmtolj.c
  268. Xpbmtomacp:    pbmtomacp.c macp.h
  269. Xpbmtomgr:    pbmtomgr.c mgr.h
  270. Xpbmtoptx:    pbmtoptx.c
  271. Xpbmtorast:    pbmtorast.c rast.h
  272. Xpbmtox10bm:    pbmtox10bm.c
  273. Xpbmtoxbm:    pbmtoxbm.c
  274. Xpbmtoxwd:    pbmtoxwd.c x11wd.h
  275. Xpbmupc:        pbmupc.c
  276. Xpcxtopbm:    pcxtopbm.c
  277. Xpicttopbm:    picttopbm.c pict.h
  278. Xrasttopbm:    rasttopbm.c rast.h
  279. Xxbmtopbm:    xbmtopbm.c
  280. Xxwdtopbm:    xwdtopbm.c x11wd.h x10wd.h
  281. X
  282. Xclean:
  283. X    -rm -f *.o *.a *.cat core $(BINARIES)
  284. X
  285. X
  286. X# Imakefile stuff.  Ignore if you're not an X11 type.
  287. X
  288. X            TOP = ../../../../../../usr/src/new/X11
  289. X
  290. X             RM = rm -f
  291. X             MV = mv
  292. X        UTILSRC = $(TOP)/util
  293. X       IMAKESRC = $(UTILSRC)/imake
  294. X       IRULESRC = $(UTILSRC)/imake.includes
  295. X          IMAKE = $(IMAKESRC)/imake
  296. X  IMAKE_DEFINES =
  297. X      IMAKE_CMD = $(NEWTOP)$(IMAKE) -TImake.tmpl -I$(NEWTOP)$(IRULESRC) \
  298. X            -s Makefile $(IMAKE_DEFINES)
  299. XMakefile: Imakefile
  300. X    -@if [ -f Makefile ]; then \
  301. X    echo "$(RM) Makefile.bak; $(MV) Makefile Makefile.bak"; \
  302. X    $(RM) Makefile.bak; $(MV) Makefile Makefile.bak; \
  303. X    else exit 0; fi
  304. X    $(IMAKE_CMD) -DTOPDIR=$(TOP)
  305. X
  306. XMakefiles:
  307. END_OF_Makefile
  308. if test 4089 -ne `wc -c <Makefile`; then
  309.     echo shar: \"Makefile\" unpacked with wrong size!
  310. fi
  311. # end of overwriting check
  312. fi
  313. if test -f libpbm.3 -a "${1}" != "-c" ; then 
  314.   echo shar: Will not over-write existing file \"libpbm.3\"
  315. else
  316. echo shar: Extracting \"libpbm.3\" \(2403 characters\)
  317. sed "s/^X//" >libpbm.3 <<'END_OF_libpbm.3'
  318. X.de Ss
  319. X.    sp
  320. X.    ft CW
  321. X.    nf
  322. X..
  323. X.de Se
  324. X.    fi
  325. X.    ft P
  326. X.    sp
  327. X..
  328. X.TH pbm 3
  329. X.SH NAME
  330. Xpbm - functions to support portable bitmap programs
  331. X.SH SYNOPSIS
  332. X.Ss
  333. X#include <pbm.h>
  334. Xcc ... libpbm.a
  335. X.Se
  336. X.SH DESCRIPTION
  337. X.SS TYPES AND CONSTANTS
  338. X.Ss
  339. Xtypedef unsigned char bit;
  340. X#define PBM_WHITE 0
  341. X#define PBM_BLACK 1
  342. X.Se
  343. XEach
  344. X.IR bit
  345. Xshould contain only the values of
  346. X.IR white
  347. Xor
  348. X.IR black .
  349. X.SS PBM MEMORY MANAGEMENT
  350. X.Ss
  351. Xbit **pbm_allocarray(int cols, int rows)
  352. X.Se
  353. XAllocate an array of bits.
  354. X.Ss
  355. Xbit *pbm_allocrow( int cols )
  356. X.Se
  357. XAllocate a row of the given number of bits.
  358. X.Ss
  359. Xvoid pbm_freearray( bitrow, rows )
  360. X.Se
  361. XFree the array allocated with
  362. X.IR pbm_allocarray()
  363. Xcontaining the given number
  364. Xof rows.
  365. X.Ss
  366. Xpbm_freerow( bitrow )
  367. X.Se
  368. XFree a row of bits.
  369. X.SS READING PBM FILES
  370. X.Ss
  371. Xvoid
  372. Xpbm_readpbminit( file, colsP, rowsP, formatP )
  373. XFILE *file;
  374. Xint *colsP, *rowsP, *formatP;
  375. X.Se
  376. XRead the header from a pbm file, filling in the rows, cols and format
  377. Xvariables.
  378. X.Ss
  379. Xvoid
  380. Xpbm_readpbmrow( file, bitrow, cols, format )
  381. XFILE *file;
  382. Xbit *bitrow;
  383. Xint cols, format;
  384. X.Se
  385. XRead a row of bits into the bitrow array.
  386. XFormat and cols were filled in by
  387. X.IR pbm_readpbminit() .
  388. X.Ss
  389. Xbit **
  390. Xpbm_readpbm( file, colsP, rowsP )
  391. XFILE *file;
  392. Xint *colsP, *rowsP;
  393. X.Se
  394. XRead an entire bitmap file into memory, returning the allocated array and
  395. Xfilling in the rows and cols variables.
  396. XThis function combines
  397. X.IR pbm_readpbminit() ,
  398. X.IR pbm_allocarray()
  399. Xand
  400. X.IR pbm_readpbmrow() .
  401. X.SS WRITING PBM FILES
  402. X.Ss
  403. Xvoid
  404. Xpbm_writepbminit( file, cols, rows )
  405. XFILE *file;
  406. Xint cols, rows;
  407. X.Se
  408. XWrite the header for a portable bitmap file.
  409. X.Ss
  410. Xvoid
  411. Xpbm_writepbmrow( file, bitrow, cols )
  412. XFILE *file;
  413. Xbit *bitrow;
  414. Xint cols;
  415. X.Se
  416. XWrite a row from a portable bitmap.
  417. X.Ss
  418. Xvoid
  419. Xpbm_writepbm( file, bits, cols, rows )
  420. XFILE *file;
  421. Xbit **bits;
  422. Xint cols, rows;
  423. X.Se
  424. XWrite the header and all data for a portable bitmap.
  425. XThis function combines
  426. X.IR pbm_writepbminit()
  427. Xand
  428. X.IR pbm_writepbmrow() .
  429. X.SH "SEE ALSO"
  430. Xpgm(3), ppm(3)
  431. X.SH AUTHOR
  432. XManual by Tony Hansen.
  433. X
  434. XCopyright (C) 1989 by Jef Poskanzer.
  435. X
  436. XPermission to use, copy, modify, and distribute this software and its
  437. Xdocumentation for any purpose and without fee is hereby granted, provided
  438. Xthat the above copyright notice appear in all copies and that both that
  439. Xcopyright notice and this permission notice appear in supporting
  440. Xdocumentation.  This software is provided "as is" without express or
  441. Ximplied warranty.
  442. END_OF_libpbm.3
  443. if test 2403 -ne `wc -c <libpbm.3`; then
  444.     echo shar: \"libpbm.3\" unpacked with wrong size!
  445. fi
  446. # end of overwriting check
  447. fi
  448. if test -f libpbm.h -a "${1}" != "-c" ; then 
  449.   echo shar: Will not over-write existing file \"libpbm.h\"
  450. else
  451. echo shar: Extracting \"libpbm.h\" \(636 characters\)
  452. sed "s/^X//" >libpbm.h <<'END_OF_libpbm.h'
  453. X/* libpbm.h - internal header file for libpbm portable bitmap library
  454. X*/
  455. X
  456. X#ifndef _LIBPBM_H_
  457. X#define _LIBPBM_H_
  458. X
  459. X/* Magic constants. */
  460. X
  461. X#define PBM_MAGIC1 'P'
  462. X#define PBM_MAGIC2 '1'
  463. X#define RPBM_MAGIC2 '4'
  464. X#define PBM_FORMAT (PBM_MAGIC1 * 256 + PBM_MAGIC2)
  465. X#define RPBM_FORMAT (PBM_MAGIC1 * 256 + RPBM_MAGIC2)
  466. X
  467. X/* And here are some routines internal to the pbm library. */
  468. X
  469. Xchar pbm_getc( /* FILE *file */ );
  470. Xunsigned char pbm_getrawbyte( /* FILE *file */ );
  471. Xint pbm_getint( /* FILE *file */ );
  472. X
  473. Xint pbm_readmagicnumber( /* FILE *file */ );
  474. X
  475. Xvoid pbm_readpbminitrest( /* FILE *file, int *colsP, int *rowsP */ );
  476. X
  477. X#endif /*_LIBPBM_H_*/
  478. END_OF_libpbm.h
  479. if test 636 -ne `wc -c <libpbm.h`; then
  480.     echo shar: \"libpbm.h\" unpacked with wrong size!
  481. fi
  482. # end of overwriting check
  483. fi
  484. if test -f libpbm1.c -a "${1}" != "-c" ; then 
  485.   echo shar: Will not over-write existing file \"libpbm1.c\"
  486. else
  487. echo shar: Extracting \"libpbm1.c\" \(5536 characters\)
  488. sed "s/^X//" >libpbm1.c <<'END_OF_libpbm1.c'
  489. X/* libpbm1.c - pbm utility library part 1
  490. X**
  491. X** Copyright (C) 1988 by Jef Poskanzer.
  492. X**
  493. X** Permission to use, copy, modify, and distribute this software and its
  494. X** documentation for any purpose and without fee is hereby granted, provided
  495. X** that the above copyright notice appear in all copies and that both that
  496. X** copyright notice and this permission notice appear in supporting
  497. X** documentation.  This software is provided "as is" without express or
  498. X** implied warranty.
  499. X*/
  500. X
  501. X#include <stdio.h>
  502. X#include <varargs.h>
  503. X#include "pbm.h"
  504. X#include "libpbm.h"
  505. X
  506. X/* Variable-sized arrays. */
  507. X
  508. Xchar *
  509. Xpm_allocrow( cols, size )
  510. Xint cols;
  511. X    {
  512. X    register char *itrow;
  513. X
  514. X    itrow = (char *) malloc( cols * size );
  515. X    if ( itrow == (char *) 0 )
  516. X    pm_error( "out of memory allocating a row", 0,0,0,0,0 );
  517. X    return itrow;
  518. X    }
  519. X
  520. Xvoid
  521. Xpm_freerow( itrow )
  522. Xchar *itrow;
  523. X    {
  524. X    free( itrow );
  525. X    }
  526. X
  527. X
  528. Xchar **
  529. Xpm_allocarray( cols, rows, size )
  530. Xint cols, rows;
  531. Xint size;
  532. X    {
  533. X    char **its;
  534. X    int i;
  535. X
  536. X    its = (char **) malloc( rows * sizeof(char *) );
  537. X    if ( its == (char **) 0 )
  538. X    pm_error( "out of memory allocating an array", 0,0,0,0,0 );
  539. X    its[0] = (char *) malloc( rows * cols * size );
  540. X    if ( its[0] == (char *) 0 )
  541. X    pm_error( "out of memory allocating an array", 0,0,0,0,0 );
  542. X    for ( i = 1; i < rows; i++ )
  543. X    its[i] = &(its[0][i * cols * size]);
  544. X    return its;
  545. X    }
  546. X
  547. Xvoid
  548. Xpm_freearray( its, rows )
  549. Xchar **its;
  550. Xint rows;
  551. X    {
  552. X    free( its[0] );
  553. X    free( its );
  554. X    }
  555. X
  556. X
  557. X/* Error handling. */
  558. X
  559. Xchar *pm_progname;
  560. X
  561. X/* I'd use varargs here, but it can't be done portably, because (a) vfprintf()
  562. X** is not very widespread, and (b) varargs itself is not powerful enough to
  563. X** allow me to include a portable vfprintf().
  564. X**
  565. X** So instead, we have the gross hack of a fixed number of args.
  566. X*/
  567. X
  568. Xvoid
  569. Xpm_message( fmt, v1, v2, v3, v4, v5 )
  570. Xchar *fmt;
  571. Xchar *v1, *v2, *v3, *v4, *v5;
  572. X    {
  573. X    fprintf( stderr, "%s: ", pm_progname );
  574. X    fprintf( stderr, fmt, v1, v2, v3, v4, v5 );
  575. X    fputc( '\n', stderr );
  576. X    }
  577. X
  578. Xvoid
  579. Xpm_error( fmt, v1, v2, v3, v4, v5 )
  580. Xchar *fmt;
  581. Xchar *v1, *v2, *v3, *v4, *v5;
  582. X    {
  583. X    pm_message( fmt, v1, v2, v3, v4, v5 );
  584. X    exit( 1 );
  585. X    }
  586. X
  587. Xvoid
  588. Xpm_perror( reason )
  589. Xchar *reason;
  590. X    {
  591. X    extern char *sys_errlist[];
  592. X    extern int errno;
  593. X    char *e;
  594. X
  595. X    if ( errno == 0 )
  596. X    e = "end of file";    /* not particularly kosher */
  597. X    else
  598. X    e = sys_errlist[errno];
  599. X
  600. X    if ( reason != 0 && reason[0] != '\0' )
  601. X    pm_error( "%s - %s", reason, e, 0,0,0 );
  602. X    else
  603. X    pm_error( "%s", e, 0,0,0,0 );
  604. X    }
  605. X
  606. Xvoid
  607. Xpm_usage( usage )
  608. Xchar *usage;
  609. X    {
  610. X    fprintf( stderr, "usage:  %s %s\n", pm_progname, usage );
  611. X    exit( 1 );
  612. X    }
  613. X
  614. X
  615. X/* File open/close that handles "-" as stdin and checks errors. */
  616. X
  617. XFILE *
  618. Xpm_openr( name )
  619. Xchar *name;
  620. X    {
  621. X    FILE *f;
  622. X
  623. X    if ( strcmp( name, "-" ) == 0 )
  624. X    f = stdin;
  625. X    else
  626. X    {
  627. X    f = fopen( name, "r" );
  628. X    if ( f == NULL )
  629. X        {
  630. X        pm_perror( name );
  631. X        exit( 1 );
  632. X        }
  633. X    }
  634. X    return f;
  635. X    }
  636. X
  637. Xvoid
  638. Xpm_close( f )
  639. XFILE *f;
  640. X    {
  641. X    if ( f != stdin )
  642. X    if ( fclose( f ) != 0 )
  643. X        pm_perror( 0 );
  644. X    }
  645. X
  646. X/* Broken putc() fix. */
  647. X
  648. X#ifdef PBMPLUS_BROKENPUTC2
  649. Xint
  650. Xputc( c, stream )
  651. Xchar c;
  652. XFILE *stream;
  653. X    {
  654. X    return fwrite( &c, 1, 1, stream ) == 1 ? c : EOF;
  655. X    }
  656. X#endif /*PBMPLUS_BROKENPUTC2*/
  657. X
  658. X/* Endian I/O.
  659. X*/
  660. X
  661. Xint
  662. Xpm_readbigshort( in, sP )
  663. XFILE *in;
  664. Xshort *sP;
  665. X    {
  666. X    int c;
  667. X
  668. X    if ( (c = getc( in )) == EOF )
  669. X    return -1;
  670. X    *sP = ( c & 0xff ) << 8;
  671. X    if ( (c = getc( in )) == EOF )
  672. X    return -1;
  673. X    *sP |= c & 0xff;
  674. X    return 0;
  675. X    }
  676. X
  677. Xint
  678. Xpm_writebigshort( out, s )
  679. XFILE *out;
  680. Xshort s;
  681. X    {
  682. X    if ( putc( ( s >> 8 ) & 0xff, out ) == EOF )
  683. X    return -1;
  684. X    if ( putc( s & 0xff, out ) == EOF )
  685. X    return -1;
  686. X    return 0;
  687. X    }
  688. X
  689. Xint
  690. Xpm_readbiglong( in, lP )
  691. XFILE *in;
  692. Xlong *lP;
  693. X    {
  694. X    int c;
  695. X
  696. X    if ( (c = getc( in )) == EOF )
  697. X    return -1;
  698. X    *lP = ( c & 0xff ) << 24;
  699. X    if ( (c = getc( in )) == EOF )
  700. X    return -1;
  701. X    *lP |= ( c & 0xff ) << 16;
  702. X    if ( (c = getc( in )) == EOF )
  703. X    return -1;
  704. X    *lP |= ( c & 0xff ) << 8;
  705. X    if ( (c = getc( in )) == EOF )
  706. X    return -1;
  707. X    *lP |= c & 0xff;
  708. X    return 0;
  709. X    }
  710. X
  711. Xint
  712. Xpm_writebiglong( out, l )
  713. XFILE *out;
  714. Xlong l;
  715. X    {
  716. X    if ( putc( ( l >> 24 ) & 0xff, out ) == EOF )
  717. X    return -1;
  718. X    if ( putc( ( l >> 16 ) & 0xff, out ) == EOF )
  719. X    return -1;
  720. X    if ( putc( ( l >> 8 ) & 0xff, out ) == EOF )
  721. X    return -1;
  722. X    if ( putc( l & 0xff, out ) == EOF )
  723. X    return -1;
  724. X    return 0;
  725. X    }
  726. X
  727. Xint
  728. Xpm_readlittleshort( in, sP )
  729. XFILE *in;
  730. Xshort *sP;
  731. X    {
  732. X    int c;
  733. X
  734. X    if ( (c = getc( in )) == EOF )
  735. X    return -1;
  736. X    *sP = c & 0xff;
  737. X    if ( (c = getc( in )) == EOF )
  738. X    return -1;
  739. X    *sP |= ( c & 0xff ) << 8;
  740. X    return 0;
  741. X    }
  742. X
  743. Xint
  744. Xpm_writelittleshort( out, s )
  745. XFILE *out;
  746. Xshort s;
  747. X    {
  748. X    if ( putc( s & 0xff, out ) == EOF )
  749. X    return -1;
  750. X    if ( putc( ( s >> 8 ) & 0xff, out ) == EOF )
  751. X    return -1;
  752. X    return 0;
  753. X    }
  754. X
  755. Xint
  756. Xpm_readlittlelong( in, lP )
  757. XFILE *in;
  758. Xlong *lP;
  759. X    {
  760. X    int c;
  761. X
  762. X    if ( (c = getc( in )) == EOF )
  763. X    return -1;
  764. X    *lP = c & 0xff;
  765. X    if ( (c = getc( in )) == EOF )
  766. X    return -1;
  767. X    *lP |= ( c & 0xff ) << 8;
  768. X    if ( (c = getc( in )) == EOF )
  769. X    return -1;
  770. X    *lP |= ( c & 0xff ) << 16;
  771. X    if ( (c = getc( in )) == EOF )
  772. X    return -1;
  773. X    *lP |= ( c & 0xff ) << 24;
  774. X    return 0;
  775. X    }
  776. X
  777. Xint
  778. Xpm_writelittlelong( out, l )
  779. XFILE *out;
  780. Xlong l;
  781. X    {
  782. X    if ( putc( l & 0xff, out ) == EOF )
  783. X    return -1;
  784. X    if ( putc( ( l >> 8 ) & 0xff, out ) == EOF )
  785. X    return -1;
  786. X    if ( putc( ( l >> 16 ) & 0xff, out ) == EOF )
  787. X    return -1;
  788. X    if ( putc( ( l >> 24 ) & 0xff, out ) == EOF )
  789. X    return -1;
  790. X    return 0;
  791. X    }
  792. END_OF_libpbm1.c
  793. if test 5536 -ne `wc -c <libpbm1.c`; then
  794.     echo shar: \"libpbm1.c\" unpacked with wrong size!
  795. fi
  796. # end of overwriting check
  797. fi
  798. if test -f libpbm2.c -a "${1}" != "-c" ; then 
  799.   echo shar: Will not over-write existing file \"libpbm2.c\"
  800. else
  801. echo shar: Extracting \"libpbm2.c\" \(2705 characters\)
  802. sed "s/^X//" >libpbm2.c <<'END_OF_libpbm2.c'
  803. X/* libpbm2.c - pbm utility library part 2
  804. X**
  805. X** Copyright (C) 1988 by Jef Poskanzer.
  806. X**
  807. X** Permission to use, copy, modify, and distribute this software and its
  808. X** documentation for any purpose and without fee is hereby granted, provided
  809. X** that the above copyright notice appear in all copies and that both that
  810. X** copyright notice and this permission notice appear in supporting
  811. X** documentation.  This software is provided "as is" without express or
  812. X** implied warranty.
  813. X*/
  814. X
  815. X#include <stdio.h>
  816. X#include "pbm.h"
  817. X#include "libpbm.h"
  818. X
  819. Xstatic bit
  820. Xpbm_getbit( file )
  821. XFILE *file;
  822. X    {
  823. X    register char ch;
  824. X
  825. X    do
  826. X    {
  827. X    ch = pbm_getc( file );
  828. X    }
  829. X    while ( ch == ' ' || ch == '\t' || ch == '\n' );
  830. X
  831. X    if ( ch != '0' && ch != '1' )
  832. X    pm_error( "junk in file where bits should be", 0,0,0,0,0 );
  833. X
  834. X    return ( ch == '1' ) ? 1 : 0;
  835. X    }
  836. X
  837. Xint
  838. Xpbm_readmagicnumber( file )
  839. XFILE *file;
  840. X    {
  841. X    int ich1, ich2;
  842. X
  843. X    ich1 = getc( file );
  844. X    if ( ich1 == EOF )
  845. X    pm_error( "premature EOF reading magic number", 0,0,0,0,0 );
  846. X    ich2 = getc( file );
  847. X    if ( ich2 == EOF )
  848. X    pm_error( "premature EOF reading magic number", 0,0,0,0,0 );
  849. X    return ich1 * 256 + ich2;
  850. X    }
  851. X
  852. Xvoid
  853. Xpbm_readpbminitrest( file, colsP, rowsP )
  854. XFILE *file;
  855. Xint *colsP, *rowsP;
  856. X    {
  857. X    /* Read size. */
  858. X    *colsP = pbm_getint( file );
  859. X    *rowsP = pbm_getint( file );
  860. X    }
  861. X
  862. Xvoid
  863. Xpbm_readpbminit( file, colsP, rowsP, formatP )
  864. XFILE *file;
  865. Xint *colsP, *rowsP, *formatP;
  866. X    {
  867. X    /* Check magic number. */
  868. X    *formatP = pbm_readmagicnumber( file );
  869. X    switch ( *formatP )
  870. X    {
  871. X        case PBM_FORMAT:
  872. X        case RPBM_FORMAT:
  873. X    pbm_readpbminitrest( file, colsP, rowsP );
  874. X    break;
  875. X
  876. X    default:
  877. X    pm_error( "bad magic number - not a pbm file", 0,0,0,0,0 );
  878. X    }
  879. X    }
  880. X
  881. Xvoid
  882. Xpbm_readpbmrow( file, bitrow, cols, format )
  883. XFILE *file;
  884. Xbit *bitrow;
  885. Xint cols, format;
  886. X    {
  887. X    register int col, bitshift;
  888. X    register unsigned char item;
  889. X    register bit *bP;
  890. X
  891. X    switch ( format )
  892. X    {
  893. X    case PBM_FORMAT:
  894. X    for ( col = 0, bP = bitrow; col < cols; col++, bP++ )
  895. X        *bP = pbm_getbit( file );
  896. X    break;
  897. X
  898. X    case RPBM_FORMAT:
  899. X    bitshift = -1;
  900. X    for ( col = 0, bP = bitrow; col < cols; col++, bP++ )
  901. X        {
  902. X        if ( bitshift == -1 )
  903. X        {
  904. X        item = pbm_getrawbyte( file );
  905. X        bitshift = 7;
  906. X        }
  907. X        *bP = ( item >> bitshift ) & 1;
  908. X        bitshift--;
  909. X        }
  910. X    break;
  911. X
  912. X    default:
  913. X    pm_error( "can't happen", 0,0,0,0,0 );
  914. X    }
  915. X    }
  916. X
  917. Xbit **
  918. Xpbm_readpbm( file, colsP, rowsP )
  919. XFILE *file;
  920. Xint *colsP, *rowsP;
  921. X    {
  922. X    register bit **bits;
  923. X    int format, row;
  924. X
  925. X    pbm_readpbminit( file, colsP, rowsP, &format );
  926. X
  927. X    bits = pbm_allocarray( *colsP, *rowsP );
  928. X
  929. X    for ( row = 0; row < *rowsP; row++ )
  930. X    pbm_readpbmrow( file, bits[row], *colsP, format );
  931. X
  932. X    return bits;
  933. X    }
  934. END_OF_libpbm2.c
  935. if test 2705 -ne `wc -c <libpbm2.c`; then
  936.     echo shar: \"libpbm2.c\" unpacked with wrong size!
  937. fi
  938. # end of overwriting check
  939. fi
  940. if test -f libpbm3.c -a "${1}" != "-c" ; then 
  941.   echo shar: Will not over-write existing file \"libpbm3.c\"
  942. else
  943. echo shar: Extracting \"libpbm3.c\" \(2076 characters\)
  944. sed "s/^X//" >libpbm3.c <<'END_OF_libpbm3.c'
  945. X/* libpbm3.c - pbm utility library part 3
  946. X**
  947. X** Copyright (C) 1988 by Jef Poskanzer.
  948. X**
  949. X** Permission to use, copy, modify, and distribute this software and its
  950. X** documentation for any purpose and without fee is hereby granted, provided
  951. X** that the above copyright notice appear in all copies and that both that
  952. X** copyright notice and this permission notice appear in supporting
  953. X** documentation.  This software is provided "as is" without express or
  954. X** implied warranty.
  955. X*/
  956. X
  957. X#include <stdio.h>
  958. X#include "pbm.h"
  959. X#include "libpbm.h"
  960. X
  961. Xvoid
  962. Xpbm_writepbminit( file, cols, rows )
  963. XFILE *file;
  964. Xint cols, rows;
  965. X    {
  966. X#ifdef PBMPLUS_RAWBITS
  967. X    fprintf( file, "%c%c\n%d %d\n", PBM_MAGIC1, RPBM_MAGIC2, cols, rows );
  968. X#else /*PBMPLUS_RAWBITS*/
  969. X    fprintf( file, "%c%c\n%d %d\n", PBM_MAGIC1, PBM_MAGIC2, cols, rows );
  970. X#endif /*PBMPLUS_RAWBITS*/
  971. X    }
  972. X
  973. Xvoid
  974. Xpbm_writepbmrow( file, bitrow, cols )
  975. XFILE *file;
  976. Xbit *bitrow;
  977. Xint cols;
  978. X    {
  979. X#ifdef PBMPLUS_RAWBITS
  980. X    register int col, bitshift;
  981. X    register unsigned char item;
  982. X    register bit *bP;
  983. X
  984. X    bitshift = 7;
  985. X    item = 0;
  986. X    for ( col = 0, bP = bitrow; col < cols; col++, bP++ )
  987. X    {
  988. X    if ( *bP )
  989. X        item += 1 << bitshift;
  990. X    bitshift--;
  991. X    if ( bitshift == -1 )
  992. X        {
  993. X        if ( putc( item, file ) == EOF )
  994. X        pm_perror( 0 );
  995. X        bitshift = 7;
  996. X        item = 0;
  997. X        }
  998. X    }
  999. X    if ( bitshift != 7 )
  1000. X    if ( putc( item, file ) == EOF )
  1001. X        pm_perror( 0 );
  1002. X#else /*PBMPLUS_RAWBITS*/
  1003. X    register int col, charcount;
  1004. X    register bit *bP;
  1005. X
  1006. X    charcount = 0;
  1007. X    for ( col = 0, bP = bitrow; col < cols; col++, bP++ )
  1008. X    {
  1009. X    if ( charcount >= 70 )
  1010. X        {
  1011. X        if ( putc( '\n', file ) == EOF )
  1012. X        pm_perror( 0 );
  1013. X        charcount = 0;
  1014. X        }
  1015. X    if ( putc( *bP ? '1' : '0', file ) == EOF )
  1016. X        pm_perror( 0 );
  1017. X    charcount++;
  1018. X    }
  1019. X    if ( putc( '\n', file ) == EOF )
  1020. X    pm_perror( 0 );
  1021. X#endif /*PBMPLUS_RAWBITS*/
  1022. X    }
  1023. X
  1024. Xvoid
  1025. Xpbm_writepbm( file, bits, cols, rows )
  1026. XFILE *file;
  1027. Xbit **bits;
  1028. Xint cols, rows;
  1029. X    {
  1030. X    int row;
  1031. X
  1032. X    pbm_writepbminit( file, cols, rows );
  1033. X
  1034. X    for ( row = 0; row < rows; row++ )
  1035. X    pbm_writepbmrow( file, bits[row], cols );
  1036. X    }
  1037. END_OF_libpbm3.c
  1038. if test 2076 -ne `wc -c <libpbm3.c`; then
  1039.     echo shar: \"libpbm3.c\" unpacked with wrong size!
  1040. fi
  1041. # end of overwriting check
  1042. fi
  1043. if test -f libpbm4.c -a "${1}" != "-c" ; then 
  1044.   echo shar: Will not over-write existing file \"libpbm4.c\"
  1045. else
  1046. echo shar: Extracting \"libpbm4.c\" \(1553 characters\)
  1047. sed "s/^X//" >libpbm4.c <<'END_OF_libpbm4.c'
  1048. X/* libpbm4.c - pbm utility library part 4
  1049. X**
  1050. X** Copyright (C) 1988 by Jef Poskanzer.
  1051. X**
  1052. X** Permission to use, copy, modify, and distribute this software and its
  1053. X** documentation for any purpose and without fee is hereby granted, provided
  1054. X** that the above copyright notice appear in all copies and that both that
  1055. X** copyright notice and this permission notice appear in supporting
  1056. X** documentation.  This software is provided "as is" without express or
  1057. X** implied warranty.
  1058. X*/
  1059. X
  1060. X#include <stdio.h>
  1061. X#include "pbm.h"
  1062. X#include "libpbm.h"
  1063. X
  1064. Xchar
  1065. Xpbm_getc( file )
  1066. XFILE *file;
  1067. X    {
  1068. X    register int ich;
  1069. X    register char ch;
  1070. X
  1071. X    ich = getc( file );
  1072. X    if ( ich == EOF )
  1073. X    pm_error( "premature EOF", 0,0,0,0,0 );
  1074. X    ch = (char) ich;
  1075. X    
  1076. X    if ( ch == '#' )
  1077. X    {
  1078. X    do
  1079. X        {
  1080. X        ich = getc( file );
  1081. X        if ( ich == EOF )
  1082. X        pm_error( "premature EOF", 0,0,0,0,0 );
  1083. X        ch = (char) ich;
  1084. X        }
  1085. X    while ( ch != '\n' );
  1086. X    }
  1087. X
  1088. X    return ch;
  1089. X    }
  1090. X
  1091. Xunsigned char
  1092. Xpbm_getrawbyte( file )
  1093. XFILE *file;
  1094. X    {
  1095. X    register int iby;
  1096. X
  1097. X    iby = getc( file );
  1098. X    if ( iby == EOF )
  1099. X    pm_error( "premature EOF", 0,0,0,0,0 );
  1100. X    return (unsigned char) iby;
  1101. X    }
  1102. X
  1103. Xint
  1104. Xpbm_getint( file )
  1105. XFILE *file;
  1106. X    {
  1107. X    register char ch;
  1108. X    register int i;
  1109. X
  1110. X    do
  1111. X    {
  1112. X    ch = pbm_getc( file );
  1113. X    }
  1114. X    while ( ch == ' ' || ch == '\t' || ch == '\n' );
  1115. X
  1116. X    if ( ch < '0' || ch > '9' )
  1117. X    pm_error( "junk in file where an integer should be", 0,0,0,0,0 );
  1118. X
  1119. X    i = 0;
  1120. X    do
  1121. X    {
  1122. X    i = i * 10 + ch - '0';
  1123. X    ch = pbm_getc( file );
  1124. X        }
  1125. X    while ( ch >= '0' && ch <= '9' );
  1126. X
  1127. X    return i;
  1128. X    }
  1129. END_OF_libpbm4.c
  1130. if test 1553 -ne `wc -c <libpbm4.c`; then
  1131.     echo shar: \"libpbm4.c\" unpacked with wrong size!
  1132. fi
  1133. # end of overwriting check
  1134. fi
  1135. if test -f libpbm5.c -a "${1}" != "-c" ; then 
  1136.   echo shar: Will not over-write existing file \"libpbm5.c\"
  1137. else
  1138. echo shar: Extracting \"libpbm5.c\" \(9432 characters\)
  1139. sed "s/^X//" >libpbm5.c <<'END_OF_libpbm5.c'
  1140. X/* libpbm5.c - pbm utility library part 5
  1141. X**
  1142. X** Copyright (C) 1988 by Jef Poskanzer.
  1143. X**
  1144. X** Permission to use, copy, modify, and distribute this software and its
  1145. X** documentation for any purpose and without fee is hereby granted, provided
  1146. X** that the above copyright notice appear in all copies and that both that
  1147. X** copyright notice and this permission notice appear in supporting
  1148. X** documentation.  This software is provided "as is" without express or
  1149. X** implied warranty.
  1150. X*/
  1151. X
  1152. X#include <stdio.h>
  1153. X#include "pbm.h"
  1154. X#include "rast.h"
  1155. X
  1156. X/*
  1157. X** Semi-work-alike versions of some Sun pixrect routines.  Just enough
  1158. X** for rasterfile reading and writing to work.
  1159. X*/
  1160. X
  1161. Xstruct pixrect *
  1162. Xmem_create( w, h, depth )
  1163. Xint w, h, depth;
  1164. X    {
  1165. X    struct pixrect *p;
  1166. X    struct mpr_data *m;
  1167. X
  1168. X    p = (struct pixrect *) malloc( sizeof(struct pixrect) );
  1169. X    if ( p == NULL )
  1170. X    return NULL;
  1171. X    p->pr_ops = NULL;
  1172. X    p->pr_size.x = w;
  1173. X    p->pr_size.y = h;
  1174. X    p->pr_depth = depth;
  1175. X    m = p->pr_data = (struct mpr_data *) malloc( sizeof(struct mpr_data) );
  1176. X    if ( m == NULL )
  1177. X    {
  1178. X    free( p );
  1179. X    return NULL;
  1180. X    }
  1181. X    /* According to the documentation, linebytes is supposed to be rounded
  1182. X    ** up to a longword (except on 386 boxes).  However, this turns out
  1183. X    ** not to be the case.  In reality, all of Sun's code rounds up to
  1184. X    ** a short, not a long.
  1185. X    */
  1186. X    m->md_linebytes = ( w * depth + 15 ) / 16 * 2;
  1187. X    m->md_offset.x = 0;
  1188. X    m->md_offset.y = 0;
  1189. X    m->md_flags = 0;
  1190. X    m->md_image = (unsigned char *) malloc( m->md_linebytes * h );
  1191. X    if ( m->md_image == NULL )
  1192. X    {
  1193. X    free( m );
  1194. X    free( p );
  1195. X    return NULL;
  1196. X    }
  1197. X
  1198. X    return p;
  1199. X    }
  1200. X
  1201. Xvoid
  1202. Xmem_free( p )
  1203. Xstruct pixrect *p;
  1204. X    {
  1205. X    free( p->pr_data->md_image );
  1206. X    free( p->pr_data );
  1207. X    free( p );
  1208. X    }
  1209. X
  1210. Xint
  1211. Xpr_dump( p, out, colormap, type, copy_flag )
  1212. Xstruct pixrect *p;
  1213. XFILE *out;
  1214. Xcolormap_t *colormap;
  1215. Xint type, copy_flag;
  1216. X    {
  1217. X    struct rasterfile h;
  1218. X    int size, besize, count;
  1219. X    unsigned char *beimage, *bp, c, pc;
  1220. X    int i, j;
  1221. X
  1222. X    h.ras_magic = RAS_MAGIC;
  1223. X    h.ras_width = p->pr_size.x;
  1224. X    h.ras_height = p->pr_size.y;
  1225. X    h.ras_depth = p->pr_depth;
  1226. X
  1227. X    h.ras_type = type;
  1228. X    switch ( type )
  1229. X    {
  1230. X    case RT_OLD:
  1231. X    pm_error( "old rasterfile type is not supported", 0,0,0,0,0 );
  1232. X
  1233. X    case RT_STANDARD:
  1234. X    h.ras_length = p->pr_size.y * p->pr_data->md_linebytes;
  1235. X    break;
  1236. X
  1237. X    case RT_BYTE_ENCODED:
  1238. X    size = p->pr_size.y * p->pr_data->md_linebytes;
  1239. X    bp = p->pr_data->md_image;
  1240. X    beimage = (unsigned char *) malloc( size * 3 / 2 );    /* worst case */
  1241. X    if ( beimage == NULL )
  1242. X        return PIX_ERR;
  1243. X    besize = 0;
  1244. X    count = 0;
  1245. X    for ( i = 0; i < size; ++i )
  1246. X        {
  1247. X        c = *bp++;
  1248. X        if ( count > 0 )
  1249. X        {
  1250. X        if ( pc != c )
  1251. X            {
  1252. X            if ( count == 1 && pc == 128 )
  1253. X            {
  1254. X            beimage[besize++] = 128;
  1255. X            beimage[besize++] = 0;
  1256. X            count = 0;
  1257. X            }
  1258. X            else if ( count > 2 || pc == 128 )
  1259. X            {
  1260. X            beimage[besize++] = 128;
  1261. X            beimage[besize++] = count - 1;
  1262. X            beimage[besize++] = pc;
  1263. X            count = 0;
  1264. X            }
  1265. X            else
  1266. X            {
  1267. X            for ( j = 0; j < count; ++j )
  1268. X                beimage[besize++] = pc;
  1269. X            count = 0;
  1270. X            }
  1271. X            }
  1272. X        }
  1273. X        pc = c;
  1274. X        ++count;
  1275. X        if ( count == 256 )
  1276. X        {
  1277. X        beimage[besize++] = 128;
  1278. X        beimage[besize++] = count - 1;
  1279. X        beimage[besize++] = c;
  1280. X        count = 0;
  1281. X        }
  1282. X        }
  1283. X    if ( count > 0 )
  1284. X        {
  1285. X        if ( count == 1 && c == 128 )
  1286. X        {
  1287. X        beimage[besize++] = 128;
  1288. X        beimage[besize++] = 0;
  1289. X        }
  1290. X        if ( count > 2 || c == 128 )
  1291. X        {
  1292. X        beimage[besize++] = 128;
  1293. X        beimage[besize++] = count - 1;
  1294. X        beimage[besize++] = c;
  1295. X        }
  1296. X        else
  1297. X        {
  1298. X        for ( j = 0; j < count; ++j )
  1299. X            beimage[besize++] = c;
  1300. X        }
  1301. X        }
  1302. X    h.ras_length = besize;
  1303. X    break;
  1304. X
  1305. X    default:
  1306. X    pm_error( "unknown rasterfile type", 0,0,0,0,0 );
  1307. X    }
  1308. X
  1309. X    if ( colormap == NULL )
  1310. X    {
  1311. X    h.ras_maptype = RMT_NONE;
  1312. X    h.ras_maplength = 0;
  1313. X    }
  1314. X    else
  1315. X    {
  1316. X    h.ras_maptype = colormap->type;
  1317. X    switch ( colormap->type )
  1318. X        {
  1319. X        case RMT_EQUAL_RGB:
  1320. X        h.ras_maplength = colormap->length * 3;
  1321. X        break;
  1322. X
  1323. X        case RMT_RAW:
  1324. X        h.ras_maplength = colormap->length;
  1325. X        break;
  1326. X
  1327. X        default:
  1328. X        pm_error( "unknown colormap type", 0,0,0,0,0 );
  1329. X        }
  1330. X    }
  1331. X
  1332. X    if ( pm_writebiglong( out, h.ras_magic ) == -1 )
  1333. X    return PIX_ERR;
  1334. X    if ( pm_writebiglong( out, h.ras_width ) == -1 )
  1335. X    return PIX_ERR;
  1336. X    if ( pm_writebiglong( out, h.ras_height ) == -1 )
  1337. X    return PIX_ERR;
  1338. X    if ( pm_writebiglong( out, h.ras_depth ) == -1 )
  1339. X    return PIX_ERR;
  1340. X    if ( pm_writebiglong( out, h.ras_length ) == -1 )
  1341. X    return PIX_ERR;
  1342. X    if ( pm_writebiglong( out, h.ras_type ) == -1 )
  1343. X    return PIX_ERR;
  1344. X    if ( pm_writebiglong( out, h.ras_maptype ) == -1 )
  1345. X    return PIX_ERR;
  1346. X    if ( pm_writebiglong( out, h.ras_maplength ) == -1 )
  1347. X    return PIX_ERR;
  1348. X
  1349. X    if ( colormap != NULL )
  1350. X    {
  1351. X    switch ( colormap->type )
  1352. X        {
  1353. X        case RMT_EQUAL_RGB:
  1354. X        if ( fwrite( colormap->map[0], 1, colormap->length, out ) !=
  1355. X         colormap->length )
  1356. X        return PIX_ERR;
  1357. X        if ( fwrite( colormap->map[1], 1, colormap->length, out ) !=
  1358. X         colormap->length )
  1359. X        return PIX_ERR;
  1360. X        if ( fwrite( colormap->map[2], 1, colormap->length, out ) !=
  1361. X         colormap->length )
  1362. X        return PIX_ERR;
  1363. X        break;
  1364. X
  1365. X        case RMT_RAW:
  1366. X        if ( fwrite( colormap->map[0], 1, colormap->length, out ) !=
  1367. X         colormap->length )
  1368. X        return PIX_ERR;
  1369. X        break;
  1370. X        }
  1371. X    }
  1372. X
  1373. X    switch ( type )
  1374. X    {
  1375. X    case RT_STANDARD:
  1376. X    if ( fwrite( p->pr_data->md_image, 1, h.ras_length, out ) !=
  1377. X         h.ras_length )
  1378. X        return PIX_ERR;
  1379. X    break;
  1380. X
  1381. X    case RT_BYTE_ENCODED:
  1382. X    if ( fwrite( beimage, 1, besize, out ) != besize )
  1383. X        {
  1384. X        free( beimage );
  1385. X        return PIX_ERR;
  1386. X        }
  1387. X    free( beimage );
  1388. X    break;
  1389. X    }
  1390. X
  1391. X    return 0;
  1392. X    }
  1393. X
  1394. Xint
  1395. Xpr_load_header( in, hP )
  1396. XFILE *in;
  1397. Xstruct rasterfile *hP;
  1398. X    {
  1399. X    if ( pm_readbiglong( in, &(hP->ras_magic) ) == -1 )
  1400. X    return PIX_ERR;
  1401. X    if ( hP->ras_magic != RAS_MAGIC )
  1402. X    return PIX_ERR;
  1403. X    if ( pm_readbiglong( in, &(hP->ras_width) ) == -1 )
  1404. X    return PIX_ERR;
  1405. X    if ( pm_readbiglong( in, &(hP->ras_height) ) == -1 )
  1406. X    return PIX_ERR;
  1407. X    if ( pm_readbiglong( in, &(hP->ras_depth) ) == -1 )
  1408. X    return PIX_ERR;
  1409. X    if ( pm_readbiglong( in, &(hP->ras_length) ) == -1 )
  1410. X    return PIX_ERR;
  1411. X    if ( pm_readbiglong( in, &(hP->ras_type) ) == -1 )
  1412. X    return PIX_ERR;
  1413. X    if ( pm_readbiglong( in, &(hP->ras_maptype) ) == -1 )
  1414. X    return PIX_ERR;
  1415. X    if ( pm_readbiglong( in, &(hP->ras_maplength) ) == -1 )
  1416. X    return PIX_ERR;
  1417. X    return 0;
  1418. X    }
  1419. X
  1420. Xint
  1421. Xpr_load_colormap( in, hP, colormap )
  1422. XFILE *in;
  1423. Xstruct rasterfile *hP;
  1424. Xcolormap_t *colormap;
  1425. X    {
  1426. X    if ( colormap == NULL || hP->ras_maptype == RMT_NONE )
  1427. X    {
  1428. X    char junk[30000];
  1429. X
  1430. X    if ( fread( junk, 1, hP->ras_maplength, in ) != hP->ras_maplength )
  1431. X        return PIX_ERR;
  1432. X    }
  1433. X    else
  1434. X    {
  1435. X    colormap->type = hP->ras_maptype;
  1436. X    switch ( hP->ras_maptype )
  1437. X        {
  1438. X        case RMT_EQUAL_RGB:
  1439. X        colormap->length = hP->ras_maplength / 3;
  1440. X        colormap->map[0] = (unsigned char *) malloc( colormap->length );
  1441. X        if ( colormap->map[0] == NULL )
  1442. X        return PIX_ERR;
  1443. X        colormap->map[1] = (unsigned char *) malloc( colormap->length );
  1444. X        if ( colormap->map[1] == NULL )
  1445. X        {
  1446. X        free( colormap->map[0] );
  1447. X        return PIX_ERR;
  1448. X        }
  1449. X        colormap->map[2] = (unsigned char *) malloc( colormap->length );
  1450. X        if ( colormap->map[2] == NULL )
  1451. X        {
  1452. X        free( colormap->map[0] );
  1453. X        free( colormap->map[1] );
  1454. X        return PIX_ERR;
  1455. X        }
  1456. X        if ( fread( colormap->map[0], 1, colormap->length, in ) != colormap->length ||
  1457. X             fread( colormap->map[1], 1, colormap->length, in ) != colormap->length ||
  1458. X             fread( colormap->map[2], 1, colormap->length, in ) != colormap->length )
  1459. X        {
  1460. X        free( colormap->map[0] );
  1461. X        free( colormap->map[1] );
  1462. X        free( colormap->map[2] );
  1463. X        return PIX_ERR;
  1464. X        }
  1465. X        break;
  1466. X
  1467. X        case RMT_RAW:
  1468. X        colormap->length = hP->ras_maplength;
  1469. X        colormap->map[0] = (unsigned char *) malloc( colormap->length );
  1470. X        if ( colormap->map[0] == NULL )
  1471. X        return PIX_ERR;
  1472. X        colormap->map[2] = colormap->map[1] = colormap->map[0];
  1473. X        if ( fread( colormap->map[0], 1, hP->ras_maplength, in ) != hP->ras_maplength )
  1474. X        {
  1475. X        free( colormap->map[0] );
  1476. X        return PIX_ERR;
  1477. X        }
  1478. X        break;
  1479. X
  1480. X        default:
  1481. X        pm_error( "unknown colormap type", 0,0,0,0,0 );
  1482. X        }
  1483. X    }
  1484. X    return 0;
  1485. X    }
  1486. X
  1487. Xstruct pixrect *
  1488. Xpr_load_image( in, hP, colormap )
  1489. XFILE *in;
  1490. Xstruct rasterfile *hP;
  1491. Xcolormap_t *colormap;
  1492. X    {
  1493. X    struct pixrect *p;
  1494. X    unsigned char *beimage;
  1495. X    register unsigned char *bep, *bp, c;
  1496. X    int i;
  1497. X    register int j, count;
  1498. X
  1499. X    p = mem_create( hP->ras_width, hP->ras_height, hP->ras_depth );
  1500. X    if ( p == NULL )
  1501. X    return NULL;
  1502. X
  1503. X    switch ( hP->ras_type )
  1504. X    {
  1505. X    case RT_OLD:
  1506. X    pm_error( "old rasterfile type is not supported", 0,0,0,0,0 );
  1507. X
  1508. X    case RT_STANDARD:
  1509. X    if ( fread( p->pr_data->md_image, 1, hP->ras_length, in ) !=
  1510. X         hP->ras_length )
  1511. X        {
  1512. X        mem_free( p );
  1513. X        return NULL;
  1514. X        }
  1515. X    break;
  1516. X
  1517. X    case RT_BYTE_ENCODED:
  1518. X    beimage = (unsigned char *) malloc( hP->ras_length );
  1519. X    if ( beimage == NULL )
  1520. X        {
  1521. X        mem_free( p );
  1522. X        return NULL;
  1523. X        }
  1524. X    if ( fread( beimage, 1, hP->ras_length, in ) != hP->ras_length )
  1525. X        {
  1526. X        mem_free( p );
  1527. X        free( beimage );
  1528. X        return NULL;
  1529. X        }
  1530. X    bep = beimage;
  1531. X    bp = p->pr_data->md_image;
  1532. X    for ( i = 0; i < hP->ras_length; )
  1533. X        {
  1534. X        c = *bep++;
  1535. X        if ( c == 128 )
  1536. X        {
  1537. X        count = ( *bep++ ) + 1;
  1538. X        if ( count == 1 )
  1539. X            {
  1540. X            *bp++ = 128;
  1541. X            i += 2;
  1542. X            }
  1543. X        else
  1544. X            {
  1545. X            c = *bep++;
  1546. X            for ( j = 0; j < count; ++j )
  1547. X            *bp++ = c;
  1548. X            i += 3;
  1549. X            }
  1550. X        }
  1551. X        else
  1552. X        {
  1553. X        *bp++ = c;
  1554. X        ++i;
  1555. X        }
  1556. X        }
  1557. X    free( beimage );
  1558. X    break;
  1559. X
  1560. X    default:
  1561. X    pm_error( "unknown rasterfile type", 0,0,0,0,0 );
  1562. X    }
  1563. X
  1564. X    return p;
  1565. X    }
  1566. END_OF_libpbm5.c
  1567. if test 9432 -ne `wc -c <libpbm5.c`; then
  1568.     echo shar: \"libpbm5.c\" unpacked with wrong size!
  1569. fi
  1570. # end of overwriting check
  1571. fi
  1572. if test -f pbm.5 -a "${1}" != "-c" ; then 
  1573.   echo shar: Will not over-write existing file \"pbm.5\"
  1574. else
  1575. echo shar: Extracting \"pbm.5\" \(2961 characters\)
  1576. sed "s/^X//" >pbm.5 <<'END_OF_pbm.5'
  1577. X.TH pbm 5 "21 September 1989"
  1578. X.SH NAME
  1579. Xpbm - portable bitmap file format
  1580. X.SH DESCRIPTION
  1581. XThe portable bitmap format is a lowest common denominator monochrome
  1582. Xfile format.
  1583. XIt was originally designed to make it reasonable to mail bitmaps
  1584. Xbetween different types of machines using the typical stupid network
  1585. Xmailers we have today.
  1586. XNow it serves as the common language of a large family of bitmap
  1587. Xconversion filters.
  1588. XThe definition is as follows:
  1589. X.IP - 2
  1590. XA "magic number" for identifying the file type.
  1591. XA pbm file's magic number is the two characters "P1".
  1592. X.IP - 2
  1593. XWhitespace (blanks, TABs, CRs, LFs).
  1594. X.IP - 2
  1595. XA width, formatted as ASCII characters in decimal.
  1596. X.IP - 2
  1597. XWhitespace.
  1598. X.IP - 2
  1599. XA height, again in ASCII decimal.
  1600. X.IP - 2
  1601. XWhitespace.
  1602. X.IP - 2
  1603. XWidth * height bits, each either '1' or '0', starting at the top-left
  1604. Xcorner of the bitmap, proceding in normal English reading order.
  1605. X.IP - 2
  1606. XThe character '1' means black, '0' means white.
  1607. X.IP - 2
  1608. XWhitespace in the bits section is ignored.
  1609. X.IP - 2
  1610. XCharacters from a "#" to the next end-of-line are ignored (comments).
  1611. X.IP - 2
  1612. XNo line should be longer than 70 characters.
  1613. X.PP
  1614. XHere is an example of a small bitmap in this format:
  1615. X.PP
  1616. X.nf
  1617. XP1
  1618. X# feep.pbm
  1619. X24 7
  1620. X0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
  1621. X0 1 1 1 1 0 0 1 1 1 1 0 0 1 1 1 1 0 0 1 1 1 1 0
  1622. X0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 1 0
  1623. X0 1 1 1 0 0 0 1 1 1 0 0 0 1 1 1 0 0 0 1 1 1 1 0
  1624. X0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0
  1625. X0 1 0 0 0 0 0 1 1 1 1 0 0 1 1 1 1 0 0 1 0 0 0 0
  1626. X0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
  1627. X.fi
  1628. X.PP
  1629. XPrograms that read this format should be as lenient as possible,
  1630. Xaccepting anything that looks remotely like a bitmap.
  1631. X.PP
  1632. XThere is also a variant on the format, available
  1633. Xby setting the RAWBITS option at compile time.  This variant is
  1634. Xdifferent in the following ways:
  1635. X.IP - 2
  1636. XThe "magic number" is "P4" instead of "P1".
  1637. X.IP - 2
  1638. XThe bits are stored eight per byte, high bit first low bit last.
  1639. X.IP - 2
  1640. XNo whitespace is allowed in the bits section.
  1641. X.IP - 2
  1642. XThe files are eight times smaller and many times faster to read and write.
  1643. X.SH "SEE ALSO"
  1644. Xbrushtopbm(1), cmuwmtopbm(1), g3topbm(1), icontopbm(1), gemtopbm(1),
  1645. Xmacptopbm(1), mgrtopbm(1), pbmlife(1),
  1646. Xpbmmake(1), pbmmask(1), pbmpaste(1), pbmreduce(1), pbmtoascii(1),
  1647. Xpbmtobbnbg(1), pbmtocmuwm(1), pbmtog3(1), pbmtogo(1), pbmtoicon(1), pbmtolj(1),
  1648. Xpbmtomacp(1), pbmtomgr(1), pbmtoptx(1), pbmtorast(1), pbmtox10bm(1),
  1649. Xpbmtoxbm(1), pbmtoxwd(1), pbmupc(1), pcxtopbm(1), picttopbm(1), rasttopbm(1),
  1650. Xxbmtopbm(1), xwdtopbm(1),
  1651. Xpnm(5), pgm(5), ppm(5)
  1652. X.SH AUTHOR
  1653. XCopyright (C) 1989 by Jef Poskanzer.
  1654. X
  1655. XPermission to use, copy, modify, and distribute this software and its
  1656. Xdocumentation for any purpose and without fee is hereby granted, provided
  1657. Xthat the above copyright notice appear in all copies and that both that
  1658. Xcopyright notice and this permission notice appear in supporting
  1659. Xdocumentation.  This software is provided "as is" without express or
  1660. Ximplied warranty.
  1661. END_OF_pbm.5
  1662. if test 2961 -ne `wc -c <pbm.5`; then
  1663.     echo shar: \"pbm.5\" unpacked with wrong size!
  1664. fi
  1665. # end of overwriting check
  1666. fi
  1667. if test -f pbm.h -a "${1}" != "-c" ; then 
  1668.   echo shar: Will not over-write existing file \"pbm.h\"
  1669. else
  1670. echo shar: Extracting \"pbm.h\" \(940 characters\)
  1671. sed "s/^X//" >pbm.h <<'END_OF_pbm.h'
  1672. X/* pbm.h - header file for libpbm portable bitmap library
  1673. X*/
  1674. X
  1675. X#ifndef _PBM_H_
  1676. X#define _PBM_H_
  1677. X
  1678. X#include "../pbmplus.h"
  1679. X
  1680. Xtypedef unsigned char bit;
  1681. X#define PBM_WHITE 0
  1682. X#define PBM_BLACK 1
  1683. X
  1684. X/* Declarations of routines. */
  1685. X
  1686. X#define pbm_allocarray( cols, rows ) ((bit **) pm_allocarray( cols, rows, sizeof(bit) ))
  1687. X#define pbm_allocrow( cols ) ((bit *) pm_allocrow( cols, sizeof(bit) ))
  1688. X#define pbm_freearray( bitrow, rows ) pm_freearray( bitrow, rows )
  1689. X#define pbm_freerow( bitrow ) pm_freerow( bitrow )
  1690. X
  1691. Xbit **pbm_readpbm( /* FILE *file, int *colsP, int *rowsP */ );
  1692. Xvoid pbm_readpbminit( /* FILE *file, int *colsP, int *rowsP, int *formatP */ );
  1693. Xvoid pbm_readpbmrow( /* FILE *file, bit *bitrow, int cols, int format */ );
  1694. X
  1695. Xvoid pbm_writepbm( /* FILE *file, bit **bits, int cols, int rows */ );
  1696. Xvoid pbm_writepbminit( /* FILE *file, int cols, int rows */ );
  1697. Xvoid pbm_writepbmrow( /* FILE *file, bit *bitrow, int cols */ );
  1698. X
  1699. X#endif /*_PBM_H_*/
  1700. END_OF_pbm.h
  1701. if test 940 -ne `wc -c <pbm.h`; then
  1702.     echo shar: \"pbm.h\" unpacked with wrong size!
  1703. fi
  1704. # end of overwriting check
  1705. fi
  1706. if test -f rast.h -a "${1}" != "-c" ; then 
  1707.   echo shar: Will not over-write existing file \"rast.h\"
  1708. else
  1709. echo shar: Extracting \"rast.h\" \(1904 characters\)
  1710. sed "s/^X//" >rast.h <<'END_OF_rast.h'
  1711. X/* rast.h - header file for Sun raster files
  1712. X*/
  1713. X
  1714. X#ifndef _RAST_H_
  1715. X#define _RAST_H_
  1716. X
  1717. X#define PIX_ERR        -1
  1718. X
  1719. Xstruct rasterfile {
  1720. X    int ras_magic;
  1721. X#define    RAS_MAGIC    0x59a66a95
  1722. X    int ras_width;
  1723. X    int ras_height;
  1724. X    int ras_depth;
  1725. X    int ras_length;
  1726. X    int ras_type;
  1727. X#define RT_OLD        0
  1728. X#define RT_STANDARD    1
  1729. X#define RT_BYTE_ENCODED    2
  1730. X#define RT_EXPERIMENTAL 0xffff
  1731. X    int ras_maptype;
  1732. X#define RMT_NONE    0
  1733. X#define RMT_EQUAL_RGB    1
  1734. X#define RMT_RAW        2
  1735. X    int ras_maplength;
  1736. X    };
  1737. X
  1738. Xstruct pixrectops {
  1739. X    int    (*pro_rop)();
  1740. X    int    (*pro_stencil)();
  1741. X    int    (*pro_batchrop)();
  1742. X    int    (*pro_nop)();
  1743. X    int    (*pro_destroy)();
  1744. X    int    (*pro_get)();
  1745. X    int    (*pro_put)();
  1746. X    int    (*pro_vector)();
  1747. X    struct pixrect *(*pro_region)();
  1748. X    int    (*pro_putcolormap)();
  1749. X    int    (*pro_getcolormap)();
  1750. X    int    (*pro_putattributes)();
  1751. X    int    (*pro_getattributes)();
  1752. X    };
  1753. X
  1754. Xstruct pr_size {
  1755. X    int x, y;
  1756. X    };
  1757. Xstruct pr_pos {
  1758. X    int x, y;
  1759. X    };
  1760. X
  1761. Xstruct pixrect {
  1762. X    struct pixrectops *pr_ops;
  1763. X    struct pr_size pr_size;
  1764. X    int pr_depth;
  1765. X    struct mpr_data *pr_data;    /* work-alike only handles memory pixrects */
  1766. X    };
  1767. X
  1768. Xstruct mpr_data {
  1769. X    int md_linebytes;
  1770. X    unsigned char *md_image;    /* note, byte not short -- avoid pr_flip() */
  1771. X    struct pr_pos md_offset;
  1772. X    short md_primary;
  1773. X    short md_flags;
  1774. X    };
  1775. X
  1776. Xtypedef struct {
  1777. X    int type;
  1778. X    int length;
  1779. X    unsigned char *map[3];
  1780. X    } colormap_t;
  1781. X
  1782. X/* And the routine definitions. */
  1783. X
  1784. Xstruct pixrect *mem_create( /* int w, int h, int depth */ );
  1785. Xvoid mem_free( /* struct pixrect *p */ );
  1786. X
  1787. Xint pr_dump( /* struct pixrect *p, FILE *out, colormap_t *colormap, int type, int copy_flag */ );
  1788. X
  1789. Xint pr_load_header( /* FILE *in, struct rasterfile *hP */ );
  1790. X
  1791. Xint pr_load_colormap( /* FILE *in, struct rasterfile *hP, colormap_t *colormap */ );
  1792. X
  1793. Xstruct pixrect *pr_load_image( /* FILE *in, struct rasterfile *hP, colormap_t *colormap */ );
  1794. X
  1795. X#endif /*_RAST_H_*/
  1796. END_OF_rast.h
  1797. if test 1904 -ne `wc -c <rast.h`; then
  1798.     echo shar: \"rast.h\" unpacked with wrong size!
  1799. fi
  1800. # end of overwriting check
  1801. fi
  1802. echo shar: End of archive 1 \(of 1\).
  1803. cp /dev/null ark1isdone
  1804. MISSING=""
  1805. for I in 1 ; do
  1806.     if test ! -f ark${I}isdone ; then
  1807.     MISSING="${MISSING} ${I}"
  1808.     fi
  1809. done
  1810. if test "${MISSING}" = "" ; then
  1811.     echo You have unpacked all 1 archives.
  1812.     rm -f ark[1-9]isdone
  1813. else
  1814.     echo You still need to unpack the following archives:
  1815.     echo "        " ${MISSING}
  1816. fi
  1817. ##  End of shell archive.
  1818. exit 0
  1819.