home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 11 Util / 11-Util.zip / file39a.zip / src / patches.os2 < prev    next >
Text File  |  1993-08-05  |  37KB  |  1,310 lines

  1. Only in src: _getname.c
  2. diff -cr old/apprentice.c src/apprentice.c
  3. *** old/apprentice.c    Thu Aug 05 16:20:38 1993
  4. --- src/apprentice.c    Sat Apr 10 20:29:06 1993
  5. ***************
  6. *** 43,51 ****
  7.   static int getvalue __P((struct magic *, char **));
  8.   static int hextoint __P((int));
  9.   static char *getstr __P((char *, char *, int, int *));
  10.   static int parse    __P((char *, int *, int));
  11.   static int maxmagic = 0;
  12.   
  13.   int
  14.   apprentice(fn, check)
  15. --- 43,55 ----
  16.   static int getvalue __P((struct magic *, char **));
  17.   static int hextoint __P((int));
  18.   static char *getstr __P((char *, char *, int, int *));
  19. + #ifdef OS2
  20. + static int parse    __P((char *, unsigned int *, int));
  21. + static unsigned int maxmagic = 0;
  22. + #else
  23.   static int parse    __P((char *, int *, int));
  24.   static int maxmagic = 0;
  25. + #endif
  26.   
  27.   int
  28.   apprentice(fn, check)
  29. ***************
  30. *** 100,114 ****
  31.   static int
  32.   parse(l, ndx, check)
  33.   char *l;
  34. ! int *ndx, check;
  35.   {
  36. !     int i = 0, nd = *ndx;
  37.       struct magic *m;
  38.       char *t, *s;
  39.   
  40.       if (nd+1 >= maxmagic){
  41.           maxmagic += 20;
  42. !         if ((magic = (struct magic *) realloc(magic, 
  43.                             sizeof(struct magic) * 
  44.                             maxmagic)) == NULL) {
  45.           (void) fprintf(stderr, "%s: Out of memory.\n", progname);
  46. --- 104,140 ----
  47.   static int
  48.   parse(l, ndx, check)
  49.   char *l;
  50. ! #ifdef OS2
  51. ! unsigned int *ndx;
  52. ! #else
  53. ! int *ndx;
  54. ! #endif
  55. ! int check;
  56.   {
  57. !     int i = 0;
  58. ! #ifdef OS2
  59. !     unsigned int nd = *ndx;
  60. ! #else
  61. !     int nd = *ndx;
  62. ! #endif
  63.       struct magic *m;
  64.       char *t, *s;
  65.   
  66.       if (nd+1 >= maxmagic){
  67. + #ifdef MSC                         /* 16-bit int */
  68. +         if (maxmagic >= MAXMAGIC) {
  69. +             (void) fprintf(stderr, "%s: magic file too large.\n", progname);
  70. +             if (check)
  71. +                 return -1;
  72. +             else
  73. +                 exit(1);
  74. +         }
  75. +         else
  76. +             maxmagic = min(maxmagic + 20, MAXMAGIC);
  77. + #else
  78.           maxmagic += 20;
  79. ! #endif
  80. !         if ( (magic = (struct magic *) realloc(magic, 
  81.                             sizeof(struct magic) * 
  82.                             maxmagic)) == NULL) {
  83.           (void) fprintf(stderr, "%s: Out of memory.\n", progname);
  84. ***************
  85. *** 286,291 ****
  86. --- 312,334 ----
  87.           m->nospflag = 1;
  88.       } else
  89.           m->nospflag = 0;
  90. + #ifdef OS2
  91. + #ifndef min
  92. + #define min(a,b) (((a) < (b)) ? (a) : (b))
  93. + #endif
  94. +     i = min(strlen(l) + 1, MAXDESC);
  95. +     if ((m->desc = (char *) malloc((size_t) i)) == NULL) {
  96. +         (void) fprintf(stderr, "%s: Out of memory.\n", progname);
  97. +         if (check)
  98. +             return -1;
  99. +         else
  100. +             exit(1);
  101. +     }
  102. +     m->desc[i-1] = '\0';
  103. +     i = 0;
  104. + #endif
  105.       while ((m->desc[i++] = *l++) != '\0' && i<MAXDESC)
  106.           /* NULLBODY */;
  107.   
  108. ***************
  109. *** 333,339 ****
  110. --- 376,391 ----
  111.               case LONG:
  112.               case BELONG:
  113.               case LELONG:
  114. + #ifdef OS2        /* bugfix, not OS/2-specific (?) */
  115. + /*    strtol() in EMX/gcc and MSC lib returns LONG_MAX on overflow.
  116. +     Use strtoul() or the supplied localsrc/strtol.c. */
  117. +                 slen = (**p == '-') ? (-1) : (1);
  118. +                 if (**p == '-' || **p == '+')
  119. +                     *p++;
  120. +                 m->value.l = (long) strtoul(*p, p, 0) * slen;
  121. + #else
  122.                   m->value.l = (long) strtol(*p,p,0);
  123. + #endif
  124.                   break;
  125.               default:
  126.                   magwarn("can't happen: m->type=%d\n", m->type);
  127. Only in src: apptype.c
  128. diff -cr old/ascmagic.c src/ascmagic.c
  129. *** old/ascmagic.c    Thu Aug 05 16:20:40 1993
  130. --- src/ascmagic.c    Mon Apr 05 19:55:30 1993
  131. ***************
  132. *** 30,36 ****
  133. --- 30,38 ----
  134.   #include <string.h>
  135.   #include <ctype.h>
  136.   #include <stdlib.h>
  137. + #ifndef MSC
  138.   #include <unistd.h>
  139. + #endif
  140.   #include "file.h"
  141.   #include "names.h"
  142.   
  143. ***************
  144. *** 79,86 ****
  145. --- 81,93 ----
  146.   
  147.       /* look for tokens from names.h - this is expensive! */
  148.       /* make a copy of the buffer here because strtok() will destroy it */
  149. + #ifdef OS2            /* bugfix, not OS/2 specific */
  150. +     s = (unsigned char*) memcpy(nbuf, buf, nbytes);
  151. +     has_escapes = (memchr(s, '\033', nbytes) != NULL);
  152. + #else
  153.       s = (unsigned char*) memcpy(nbuf, buf, HOWMANY);
  154.       has_escapes = (memchr(s, '\033', HOWMANY) != NULL);
  155. + #endif
  156.       while ((token = strtok((char*)s, " \t\n\r\f")) != NULL) {
  157.           s = NULL;    /* make strtok() keep on tokin' */
  158.           for (p = names; p < names + NNAMES; p++) {
  159. diff -cr old/compress.c src/compress.c
  160. *** old/compress.c    Thu Aug 05 16:20:40 1993
  161. --- src/compress.c    Thu Apr 08 18:38:30 1993
  162. ***************
  163. *** 6,14 ****
  164. --- 6,22 ----
  165.    */
  166.   #include <stdio.h>
  167.   #include <stdlib.h>
  168. + #ifndef MSC
  169.   #include <unistd.h>
  170. + #endif
  171.   #include <string.h>
  172. + #ifdef OS2
  173. + #include <fcntl.h>
  174. + #include <io.h>
  175. + #include <process.h>
  176. + #else
  177.   #include <sys/wait.h>
  178. + #endif
  179.   
  180.   #include "file.h"
  181.   
  182. ***************
  183. *** 30,35 ****
  184. --- 38,44 ----
  185.       return *(p+2) & 0x1f;
  186.   }
  187.   
  188.   int
  189.   uncompress(old, newch, n)
  190.   const unsigned char *old;
  191. ***************
  192. *** 36,41 ****
  193. --- 45,101 ----
  194.   unsigned char **newch;
  195.   int n;
  196.   {
  197. + #ifdef NO_PIPE      /* Use tempnam() */
  198. +     FILE    *fp;
  199. +     char    *tempname, filename[_MAX_PATH];
  200. +     int    p;
  201. +     if ((tempname = tempnam("./", "tmp")) == NULL) {
  202. +         error("cannot create temporary file (%s).\n", strerror(errno));    
  203. +         /*NOTREACHED*/
  204. +     }
  205. +     /* uncompress needs ".Z"; new filename must not exist */
  206. +     sprintf(filename, "%s.Z", tempname);
  207. +     if (access(filename, 0) == 0 || (fp = fopen(filename, "wb")) == NULL)
  208. +         error("cannot open tmp file %s (%s).\n", filename, strerror(errno));
  209. +     if (fwrite(old, 1, n, fp) != n) {
  210. +         error("write failed (%s).\n", strerror(errno));
  211. +         /*NOTREACHED*/
  212. +         }
  213. +     (void) fclose(fp);
  214. +     
  215. +     /* It appears that DOS wants "compress -d", not argv[0]=uncompress */
  216. +     if (p = spawnlp(P_WAIT, "compress", "compress", "-d", filename, NULL)) {
  217. +         unlink(filename);
  218. +         if (p == -1)
  219. +             error("could not execute `uncompress' (%s).\n",  strerror(errno));
  220. +         else
  221. +             error("uncompress has failed on `%s'.\n", filename);
  222. +     }
  223. +     if ((*newch = (unsigned char *) malloc(n)) == NULL) {
  224. +         error("out of memory.\n");
  225. +         /*NOTREACHED*/
  226. +     }
  227. +     if ((fp = fopen(tempname, "rb")) == NULL) {
  228. +         error("cannot open tmp file %s (%s).\n", tempname, strerror(errno));
  229. +         /*NOTREACHED*/
  230. +     }
  231. +     if ((n = fread(*newch, 1, n, fp)) == 0) {
  232. +         free(*newch);
  233. +         error("read failed (%s).\n", strerror(errno));
  234. +         /*NOTREACHED*/
  235. +     }
  236. +     fclose(fp);
  237. +     unlink(tempname);
  238. +     free(tempname);
  239. +     return n;
  240. + #else
  241. + #ifdef USE_FORK
  242.       int fdin[2], fdout[2];
  243.   
  244.       if (pipe(fdin) == -1 || pipe(fdout) == -1) {
  245. ***************
  246. *** 83,86 ****
  247. --- 143,206 ----
  248.           (void) wait(NULL);
  249.           return n;
  250.       }
  251. + #else
  252. +     int fdin[2], fdout[2];
  253. +     int handle[3], i, p;
  254. + #ifdef MSC
  255. + #define pipe(handles) _pipe(handles, 1024, O_BINARY)
  256. + #endif
  257. +     if (pipe(fdin) == -1 || pipe(fdout) == -1) {
  258. +         error("cannot create pipe (%s).\n", strerror(errno));    
  259. +         /*NOTREACHED*/
  260. +     }
  261. + #ifdef OS2
  262. +     setmode(fdin[1], O_BINARY);
  263. +     setmode(fdout[0], O_BINARY);
  264. + #endif
  265. +     if (write(fdin[1], old, n) != n) {
  266. +         error("write failed (%s).\n", strerror(errno));
  267. +         /*NOTREACHED*/
  268. +         }
  269. +     (void) close(fdin[1]);
  270. +     for (i = 0; i <= 2; i++) 
  271. +         handle[i] = dup(i);
  272. +     dup2(fdin[0], 0);
  273. +     dup2(fdout[1], 1);
  274. +     dup2(fdout[1], 2);
  275. +     close(fdin[0]); close(fdout[1]);
  276. +     p = spawnlp(P_NOWAIT, "compress", "uncompress", "-c", NULL);
  277. +     for (i = 0; i <= 2; i++) {
  278. +         dup2(handle[i], i); close(handle[i]);
  279. +     }
  280. +     if (p == -1)
  281. +         error("could not execute `uncompress' (%s).\n",  strerror(errno));
  282. +     if ((*newch = (unsigned char *) malloc(n)) == NULL) {
  283. +         error("out of memory.\n");
  284. +         /*NOTREACHED*/
  285. +     }
  286. +     if ((n = read(fdout[0], *newch, n)) <= 0) {
  287. +         free(*newch);
  288. +         error("read failed (%s).\n", strerror(errno));
  289. +         /*NOTREACHED*/
  290. +     }
  291. + #ifdef MSC                /* Clear the pipe. There must be a better way... */
  292. +     { 
  293. +     char buf[256];
  294. +     while (read(fdout[0], buf, 256) > 0 )
  295. +         ;
  296. +     }
  297. + #endif
  298. +     (void) close(fdout[0]);
  299. +     (void) wait(NULL);
  300. +     return n; 
  301. + #endif
  302. + #endif
  303.   }
  304. Only in src: fapptyp.h
  305. Only in src: file-32.def
  306. Only in old: file.1
  307. diff -cr old/file.c src/file.c
  308. *** old/file.c    Thu Aug 05 16:20:42 1993
  309. --- src/file.c    Fri Jul 30 14:55:20 1993
  310. ***************
  311. *** 33,43 ****
  312. --- 33,52 ----
  313.   #include <stdlib.h>
  314.   #include <string.h>
  315.   #include <sys/types.h>
  316. + #ifndef MSC
  317.   #include <sys/param.h>    /* for MAXPATHLEN */
  318. + #endif
  319.   #include <sys/stat.h>
  320.   #include <fcntl.h>    /* for open() */
  321. + #ifdef OS2
  322. + #include <io.h>
  323. + #include <sys/utime.h>
  324. + #else
  325.   #include <utime.h>
  326. + #endif
  327. + #ifndef MSC
  328.   #include <unistd.h>    /* for read() */
  329. + #endif
  330.   
  331.   #include "file.h"
  332.   
  333. ***************
  334. *** 79,89 ****
  335. --- 88,109 ----
  336.   {
  337.       int c;
  338.       int check = 0, didsomefiles = 0, errflg = 0, ret = 0;
  339. + #ifdef OS2
  340. +     char    path[_MAX_PATH], drive[_MAX_DRIVE], dir[_MAX_DIR], *p;
  341. + #endif
  342. + #ifdef EMX
  343. +     _wildcard(&argc, &argv);
  344. + #endif
  345.   
  346. + #ifdef OS2
  347. +     progname = _getname(argv[0]);
  348. + #else
  349.       if ((progname = strrchr(argv[0], '/')) != NULL)
  350.           progname++;
  351.       else
  352.           progname = argv[0];
  353. + #endif
  354.   
  355.       while ((c = getopt(argc, argv, "cdf:Lm:z")) != EOF)
  356.           switch (c) {
  357. ***************
  358. *** 118,128 ****
  359. --- 138,168 ----
  360.           exit(2);
  361.       }
  362.   
  363. + #ifdef OS2
  364. +     if (access(magicfile, 4)) {
  365. +         _splitpath(argv[0], drive, dir, NULL, NULL);     /* Try dir of exe */
  366. +         sprintf(path, "%s%s%s", drive, dir, p = _getname(magicfile));
  367. +         if (access(path, 4)) {       
  368. +             _searchenv(p, "PATH", path);                    /* next, try PATH */
  369. +             if (*path == '\0') 
  370. +                 _searchenv(p, "DPATH", path);                 /* finally, try DPATH */
  371. +         }
  372. +         if (*path)
  373. +             magicfile = path;
  374. +     }
  375. + #endif
  376.       ret = apprentice(magicfile, check);
  377.       if (check)
  378.           exit(ret);
  379.   
  380.       if (optind == argc) {
  381. + #ifdef OS2
  382. +         if (!isatty(fileno(stdin))) {    /* Do stdin */
  383. +             process("-", 1);
  384. +             ++didsomefiles;
  385. +         }
  386. + #endif
  387.           if (!didsomefiles) {
  388.               (void)fprintf(stderr, USAGE, progname);
  389.               exit(2);
  390. ***************
  391. *** 176,181 ****
  392. --- 216,225 ----
  393.   }
  394.   
  395.   
  396. + #ifdef OS2
  397. + static    const char    *apptypeName;
  398. + #endif
  399.   /*
  400.    * process - process input file
  401.    */
  402. ***************
  403. *** 191,196 ****
  404. --- 235,244 ----
  405.       struct stat    sb;
  406.       int nbytes = 0;    /* number of bytes read from a datafile */
  407.   
  408. + #ifdef OS2
  409. +     apptypeName = inname;
  410. + #endif
  411.       if (strcmp("-", inname) == 0) {
  412.           if (fstat(0, &sb)<0) {
  413.               error("cannot fstat `%s' (%s).\n", stdname, 
  414. ***************
  415. *** 198,203 ****
  416. --- 246,256 ----
  417.               /*NOTREACHED*/
  418.           }
  419.           inname = stdname;
  420. + #ifdef OS2
  421. +         if (wid < strlen(inname))        /* bugfix (?), not OS/2-specific */
  422. +             wid = strlen(inname);
  423. +         apptypeName = NULL;
  424. + #endif
  425.       }
  426.   
  427.       if (wid > 0)
  428. ***************
  429. *** 222,227 ****
  430. --- 275,283 ----
  431.           }
  432.       }
  433.   
  434. + #ifdef OS2
  435. +     setmode(fd, O_BINARY);
  436. + #endif
  437.   
  438.       /*
  439.        * try looking at the first HOWMANY bytes
  440. ***************
  441. *** 244,251 ****
  442. --- 300,312 ----
  443.            */
  444.           utbuf.actime = sb.st_atime;
  445.           utbuf.modtime = sb.st_mtime;
  446. + #ifdef OS2    /* OS/2 wants file closed before utime. MSC utime is broken. */
  447. +         close(fd);
  448. +         (void) utime((char *) inname, &utbuf); /* don't care if loses */
  449. + #else
  450.           (void) utime(inname, &utbuf); /* don't care if loses */
  451.           (void) close(fd);
  452. + #endif
  453.       }
  454.       (void) putchar('\n');
  455.   }
  456. ***************
  457. *** 256,261 ****
  458. --- 317,331 ----
  459.   unsigned char *buf;
  460.   int nb;
  461.   {
  462. + #ifdef OS2
  463. +     /*
  464. +      * try DosQueryAppType tests; best chances with complete file
  465. +      */
  466. +     const    char    *p = apptypeName;
  467. +     apptypeName = NULL;
  468. +     if (apptype(p, buf, nb) != 1)
  469. + #endif
  470.       /*
  471.        * try tests in /etc/magic (or surrogate magic file)
  472.        */
  473. Only in src: file.def
  474. diff -cr old/file.h src/file.h
  475. *** old/file.h    Thu Aug 05 16:20:44 1993
  476. --- src/file.h    Wed Apr 07 21:50:42 1993
  477. ***************
  478. *** 27,33 ****
  479. --- 27,38 ----
  480.    */
  481.   
  482.   #define HOWMANY    1024        /* how much of the file to look at */
  483. + #ifdef MSC        /* 16-bit int */
  484. + #define MAXMAGIC (0xff00 / sizeof(struct magic)) /* max entries in magicfile */
  485. + #define MAXMAGIS MAXMAGIC                                 /* initial allocation */
  486. + #else
  487.   #define MAXMAGIS 1000        /* max entries in /etc/magic */
  488. + #endif
  489.   #define MAXDESC    50        /* max leng of text description */
  490.   #define MAXstring 32        /* max leng of "string" types */
  491.   
  492. ***************
  493. *** 65,71 ****
  494. --- 70,80 ----
  495.       } value;        /* either number or string */
  496.       long mask;        /* mask before comparison with value */
  497.       char nospflag;        /* supress space character */
  498. + #ifdef OS2
  499. +     char *desc;            /* description */
  500. + #else
  501.       char desc[MAXDESC];    /* description */
  502. + #endif
  503.   };
  504.   
  505.   #include <stdio.h>    /* Include that here, to make sure __P gets defined */
  506. ***************
  507. *** 97,104 ****
  508.   extern void  ckfprintf        __P((FILE *, const char *, ...));
  509.   
  510.   
  511.   extern int errno;        /* Some unixes don't define this..    */
  512.   
  513.   extern char *progname;        /* the program name             */
  514.   extern char *magicfile;        /* name of the magic file        */
  515. --- 106,114 ----
  516.   extern void  ckfprintf        __P((FILE *, const char *, ...));
  517.   
  518.   
  519. ! #ifndef OS2
  520.   extern int errno;        /* Some unixes don't define this..    */
  521. + #endif
  522.   
  523.   extern char *progname;        /* the program name             */
  524.   extern char *magicfile;        /* name of the magic file        */
  525. ***************
  526. *** 123,127 ****
  527. --- 133,145 ----
  528.   #endif
  529.   
  530.   #ifndef MAXPATHLEN
  531. + #ifdef OS2
  532. + #define    MAXPATHLEN    _MAX_PATH
  533. + #else
  534.   #define    MAXPATHLEN    512
  535. + #endif
  536. + #endif
  537. + #ifdef MSC
  538. + char    *_getname(char *);
  539.   #endif
  540. diff -cr old/fsmagic.c src/fsmagic.c
  541. *** old/fsmagic.c    Thu Aug 05 16:20:44 1993
  542. --- src/fsmagic.c    Mon Apr 05 22:03:52 1993
  543. ***************
  544. *** 29,39 ****
  545. --- 29,46 ----
  546.   #include <string.h>
  547.   #include <sys/types.h>
  548.   #include <sys/stat.h>
  549. + #ifndef MSC
  550.   #include <unistd.h>
  551. + #endif
  552.   #include <stdlib.h>
  553.   #ifndef    major            /* if `major' not defined in types.h, */
  554. + #ifdef OS2              /* These will always return 0 in EMX */
  555. + #define major(x) ((int) x & 0xffff) /* will return driver in MSC */
  556. + #define minor(x) ((int) x >> 16)
  557. + #else
  558.   #include <sys/sysmacros.h>    /* try this one. */
  559.   #endif
  560. + #endif
  561.   #ifndef    major    /* still not defined? give up, manual intervention needed */
  562.           /* If cc tries to compile this, read and act on it. */
  563.           /* On most systems cpp will discard it automatically */
  564. ***************
  565. *** 49,54 ****
  566. --- 56,81 ----
  567.       "@(#)$Id: fsmagic.c,v 1.22 93/02/19 12:09:04 ian Exp $";
  568.   #endif    /* lint */
  569.   
  570. + #ifdef MSC            /* MSC stat() is broken on directories ending with '/' */
  571. + int    Stat(fn, sb)
  572. + const char *fn;
  573. + struct stat *sb;
  574. + {
  575. +     char    path[_MAX_PATH], dir[_MAX_DIR], fname[_MAX_FNAME];
  576. +     char     *p;
  577. +     strcpy(path, fn);
  578. +     _splitpath(path, NULL, dir, fname, NULL);
  579. +     if (*fname == '\0') 
  580. +         if (strlen(dir) > 1)
  581. +             if ( *(p = path + strlen(path) -1) == '/' || *p == '\\')
  582. +                 *p = '\0';
  583. +     return(stat(path, sb));
  584. + }
  585. + #endif
  586.   int
  587.   fsmagic(fn, sb)
  588.   const char *fn;
  589. ***************
  590. *** 65,71 ****
  591. --- 92,102 ----
  592.           ret = lstat(fn, sb);
  593.       else
  594.   #endif
  595. + #ifdef MSC
  596. +     ret = Stat(fn, sb);    /* don't merge into if; see "ret =" above */
  597. + #else
  598.       ret = stat(fn, sb);    /* don't merge into if; see "ret =" above */
  599. + #endif
  600.   
  601.       if (ret) {
  602.           ckfprintf(stdout,
  603. ***************
  604. *** 75,83 ****
  605. --- 106,116 ----
  606.           return 1;
  607.       }
  608.   
  609. + #ifdef S_ISUID
  610.       if (sb->st_mode & S_ISUID) ckfputs("setuid ", stdout);
  611.       if (sb->st_mode & S_ISGID) ckfputs("setgid ", stdout);
  612.       if (sb->st_mode & S_ISVTX) ckfputs("sticky ", stdout);
  613. + #endif
  614.       
  615.       switch (sb->st_mode & S_IFMT) {
  616.       case S_IFDIR:
  617. ***************
  618. *** 87,96 ****
  619. --- 120,131 ----
  620.           (void) printf("character special (%d/%d)",
  621.               major(sb->st_rdev), minor(sb->st_rdev));
  622.           return 1;
  623. + #ifdef S_IFBLK
  624.       case S_IFBLK:
  625.           (void) printf("block special (%d/%d)",
  626.               major(sb->st_rdev), minor(sb->st_rdev));
  627.           return 1;
  628. + #endif
  629.       /* TODO add code to handle V7 MUX and Blit MUX files */
  630.   #ifdef    S_IFIFO
  631.       case S_IFIFO:
  632. diff -cr old/localsrc/strtol.c src/localsrc/strtol.c
  633. *** old/localsrc/strtol.c    Thu Aug 05 16:20:46 1993
  634. --- src/localsrc/strtol.c    Sat Apr 10 18:51:14 1993
  635. ***************
  636. *** 16,22 ****
  637.   char    *s, **p;
  638.   int    b;
  639.   {
  640. !     int    base = 10, n = 0, sign = 1, valid = 1;
  641.   
  642.       /*
  643.        * leading sign?
  644. --- 16,23 ----
  645.   char    *s, **p;
  646.   int    b;
  647.   {
  648. !     int    base = 10, sign = 1, valid = 1;
  649. !     long    n = 0;
  650.   
  651.       /*
  652.        * leading sign?
  653. diff -cr old/Magdir/ar src/Magdir/ar
  654. *** old/Magdir/ar    Thu Aug 05 16:20:46 1993
  655. --- src/Magdir/ar    Sun Aug 01 09:51:34 1993
  656. ***************
  657. *** 55,66 ****
  658.   #
  659.   0    string        -h-        Software Tools format archive text
  660.   # "arc" archiver
  661. ! 0    byte        26        'arc' archive
  662. ! >1    byte        0        (empty)
  663. ! >1    byte        1        (old format)
  664. ! # Rahul Dhesi's zoo archive format, from keith@cerberus.uchicago.edu.
  665. ! 20    long        0xdca7c4fd    Rahul Dhesi's "zoo" archive
  666. ! # ZIP archiver
  667. ! 0    string        PK        zip archive file 
  668. ! >2    byte        >0        - version [%d
  669. ! >3    byte        >0        %d]
  670. --- 55,154 ----
  671.   #
  672.   0    string        -h-        Software Tools format archive text
  673.   # "arc" archiver
  674. ! #0    byte        26        'arc' archive
  675. ! #>1    byte        0        (empty)
  676. ! #>1    byte        1        (old format)
  677. ! #
  678. ! # >>>>> ARJ archiver <<<<< (source: arj 2.39a beta)
  679. ! #     ARJ archives contains two types of header blocks:
  680. ! #
  681. ! #    Archive main header - This is located at the head of the archive
  682. ! #    Local file header   - This is located before each archived file
  683. ! #
  684. ! #     Structure of main header (low order byte first):
  685. ! #
  686. ! #     Bytes Description
  687. ! #     ----- -------------------------------------------------------------------
  688. ! #       2   header id (main and local file) = 0xEA60 or 60000U
  689. ! #       2   basic header size (from 'first_hdr_size' thru 'comment' below)
  690. ! #         = first_hdr_size + strlen(filename) + 1 + strlen(comment) + 1
  691. ! #         = 0 if end of archive
  692. ! #
  693. ! #       1   first_hdr_size (size up to and including 'extra data')
  694. ! #       1   archiver version number [2.30==v4 ?  2.39==v5 ?]
  695. ! #       1   minimum archiver version to extract
  696. ! #       1   host OS   (0 = MSDOS, 1 = PRIMOS, 2 = UNIX, 3 = AMIGA, 4 = MAC-OS)
  697. ! #             (5 = OS/2, 6 = APPLE GS, 7 = ATARI ST, 8 = NEXT)
  698. ! #             (9 = VAX VMS)
  699. ! # [text deleted]
  700. ! 0    short        0xea60        arj archive
  701. ! #
  702. ! # >>>>> ARC <<<<<  (source: Greg Roelofs roe2@midway.uchicago.edu)
  703. ! #
  704. ! 0    string        \032\010        Arc archive
  705. ! # 0    short        0x1a08            Arc archive
  706. ! # 0    short        0x081a            Arc archive
  707. ! #
  708. ! # >>>>> LHARC/LHA <<<<<  (source: Greg Roelofs roe2@midway.uchicago.edu)
  709. ! #
  710. ! 2    string        -lh0-            Lharc 1.x archive
  711. ! 2    string        -lh1-            Lharc 1.x archive
  712. ! 2    string        -lz4-            Lharc 1.x archive
  713. ! 2    string        -lz5-            Lharc 1.x archive
  714. ! #    [never seen any but the last:]
  715. ! 2    string        -lzs-            LHa 2.x? archive [lzs]
  716. ! 2    string        -lh\ -        LHa 2.x? archive [lh ]
  717. ! 2    string        -lhd-            LHa 2.x? archive [lhd]
  718. ! 2    string        -lh2-            Lha 2.x? archive [lh2]
  719. ! 2    string        -lh3-            LHa 2.x? archive [lh3]
  720. ! 2    string        -lh4-            LHa 2.x? archive [lh4]
  721. ! 2    string        -lh5-            LHa (2.x) archive
  722. ! #
  723. ! # >>>>> ZIP <<<<<  (source: Greg Roelofs roe2@midway.uchicago.edu)
  724. ! # [extract ver is from 1st file only]
  725. ! #
  726. ! 0    string        PK\003\004        Zip archive
  727. ! >4    string        \011            (at least v0.9 to extract)
  728. ! >4    string        \012            (at least v1.0 to extract)
  729. ! >4    string        \013            (at least v1.1 to extract)
  730. ! >4    string        \024            (at least v2.0 to extract)
  731. ! #
  732. ! # >>>>> ZOO <<<<<  (source: Greg Roelofs roe2@midway.uchicago.edu)
  733. ! #
  734. ! # [GRR:  don't know if all of these versions exist, or if some missing...]
  735. ! #0        string        ZOO             Zoo archive
  736. ! # [DH: Use GRR's alternate identifiers]
  737. ! 0x2a    string   \xdc\xa7\xc4\xfd
  738. ! >0 string         >0          %.16s
  739. ! # >4    string        1.00            (v%4s)
  740. ! # >4    string        1.10            (v%4s)
  741. ! # >4    string        1.20            (v%4s)
  742. ! # >4    string        1.30            (v%4s)
  743. ! # >4    string        1.40            (v%4s)
  744. ! # >4    string        1.50            (v%4s)
  745. ! # >4    string        1.60            (v%4s)
  746. ! # >4    string        1.70            (v%4s)
  747. ! # >4    string        1.71            (v%4s)
  748. ! # >4    string        2.00            (v%4s)
  749. ! # >4    string        2.01            (v%4s)
  750. ! # >4    string        2.10            (v%4s)
  751. ! >32    string        \001\000        (modify: v1.0+)
  752. ! >32    string        \001\004        (modify: v1.4+)
  753. ! >32    string        \002\000        (modify: v2.0+)
  754. ! >70    string        \001\000        (extract: v1.0+)
  755. ! >70    string        \002\001        (extract: v2.1+)
  756. ! 0        string        ZOO             Zoo archive
  757. ! # [GRR:  the following are alternate identifiers]
  758. ! #0x2a    long        0xdca7c4fd        Zoo archive
  759. ! #0x2a    long        0xc4fddca7        Zoo archive
  760. ! #
  761. ! # >>>>> HPACK <<<<<  (source: Peter Gutmann pgut1@cs.aukuni.ac.nz)
  762. ! # Here's the entry from the local magic file - it's for Ultrix, the format
  763. ! # may not be 100% the same as everyone else's.  Basically the ID bytes are a
  764. ! # 4-byte string 'HPAK' at the start.  Anything after that is indeterminate,
  765. ! # since for example if the archive is encrypted the entire thing will be one
  766. ! # big block of white noise - it's only the 4-byte ID you can rely on 100%. 
  767. ! # Once the ISO approves ISO 8824 and 8825 I'll use that format, which will
  768. ! # provide a lot more information, but that will probably still take awhile....
  769. ! #   4       string          HPAK            1,1     HPACK archive
  770. ! 0    string    HPAK    HPACK archive
  771. Only in old/Magdir: ar.orig
  772. diff -cr old/Magdir/audio src/Magdir/audio
  773. *** old/Magdir/audio    Mon Apr 05 14:39:32 1993
  774. --- src/Magdir/audio    Wed Aug 04 19:56:48 1993
  775. ***************
  776. *** 25,27 ****
  777. --- 25,33 ----
  778.   >19     string          L               and a EL hash tabl
  779.   >19     string          B               and a EB hash tabl
  780.   >22     string          X               -- out of date
  781. + # sound files from OS/2 (these are guesses)
  782. + 0  string      RIFF     
  783. + >8 string      WAVE     sound
  784. + 0  string      MThd\0   MIDI sound
  785. diff -cr old/Magdir/commands src/Magdir/commands
  786. *** old/Magdir/commands    Mon Apr 05 14:39:38 1993
  787. --- src/Magdir/commands    Sat Jul 31 08:37:10 1993
  788. ***************
  789. *** 15,22 ****
  790.   0    string         #!\ /usr/local/tcsh    Tenex C Shell script text
  791.   0    string        #!/usr/local/bin/tcsh    Tenex C Shell script text
  792.   0    string        #!\ /usr/local/bin/tcsh    Tenex C Shell script text
  793. ! 0    string        #!/bin/awk        Awk Commands text
  794. ! 0    string        #!\ /bin/awk        Awk Commands text
  795.   0    string        #!\ /            a
  796.   >3    string        >\0            %s script
  797.   0    string        #!/            a
  798. --- 15,28 ----
  799.   0    string         #!\ /usr/local/tcsh    Tenex C Shell script text
  800.   0    string        #!/usr/local/bin/tcsh    Tenex C Shell script text
  801.   0    string        #!\ /usr/local/bin/tcsh    Tenex C Shell script text
  802. ! 0    string        #!/bin/zsh        Z Shell script text
  803. ! 0    string        #!\ /bin/zsh     Z Shell script text
  804. ! 0    string        #!/bin/awk        Awk commands text
  805. ! 0    string        #!\ /bin/awk     Awk commands text
  806. ! 0  string        #!/bin/nawk        new Awk commands text
  807. ! 0     string        #!\ /bin/nawk    new Awk commands text
  808. ! 0    string        #!/bin/gawk        GNU Awk commands text        
  809. ! 0    string        #!\ /bin/gawk    GNU Awk commands text        
  810.   0    string        #!\ /            a
  811.   >3    string        >\0            %s script
  812.   0    string        #!/            a
  813. ***************
  814. *** 30,32 ****
  815. --- 36,45 ----
  816.   0    string        #!/bin/perl    perl commands text
  817.   0    string        #!\ /bin/perl    perl commands text
  818.   0    string        eval\ "exec\ /bin/perl    perl commands text
  819. + # OS/2 EXTPROC uses specified program to process script
  820. + #
  821. + 0  string        EXTPROC            OS/2 ExtProc commands text
  822. + >8 string      >\0                for %s
  823. + 0  string        extproc            OS/2 ExtProc commands text
  824. + >8 string      >\0                for %s
  825. diff -cr old/Magdir/compress src/Magdir/compress
  826. *** old/Magdir/compress    Mon Apr 05 14:39:38 1993
  827. --- src/Magdir/compress    Fri Jul 30 14:45:00 1993
  828. ***************
  829. *** 46,52 ****
  830.   >3    byte        &0x10        encrypted,
  831.   >4    date        x        last modified: %s,
  832.   >8    byte        x        extra-flags: %x,
  833. ! >9    byte        =0x00        os: MS/DOS
  834.   >9    byte        =0x01        os: Amiga
  835.   >9    byte        =0x02        os: VMS
  836.   >9    byte        =0x03        os: Unix
  837. --- 46,52 ----
  838.   >3    byte        &0x10        encrypted,
  839.   >4    date        x        last modified: %s,
  840.   >8    byte        x        extra-flags: %x,
  841. ! >9    byte        =0x00        os: DOS
  842.   >9    byte        =0x01        os: Amiga
  843.   >9    byte        =0x02        os: VMS
  844.   >9    byte        =0x03        os: Unix
  845. ***************
  846. *** 53,57 ****
  847.   >9    byte        =0x05        os: Atari
  848.   >9    byte        =0x06        os: OS/2
  849.   >9    byte        =0x07        os: MacOS
  850. ! >9    byte        =0x0A        os: Tops/20
  851.   >9    byte        =0x0B        os: Win/32
  852. --- 53,57 ----
  853.   >9    byte        =0x05        os: Atari
  854.   >9    byte        =0x06        os: OS/2
  855.   >9    byte        =0x07        os: MacOS
  856. ! >9    byte        =0x0A        os: TOPS-20
  857.   >9    byte        =0x0B        os: Win/32
  858. Only in src/Magdir: emacs
  859. diff -cr old/Magdir/images src/Magdir/images
  860. *** old/Magdir/images    Thu Aug 05 16:20:46 1993
  861. --- src/Magdir/images    Wed Aug 04 19:56:54 1993
  862. ***************
  863. *** 26,33 ****
  864.   
  865.   # GIF
  866.   0    string        GIF        GIF picture
  867. ! >3    string        87a        - version %s
  868. ! >3    string        89a        - version %s
  869.   >6    short        >0        %d x
  870.   >8    short        >0        %d,
  871.   >10    byte        &0x40        interlaced,
  872. --- 26,33 ----
  873.   
  874.   # GIF
  875.   0    string        GIF        GIF picture
  876. ! >3    string        87a        - version %.3s
  877. ! >3    string        89a        - version %.3s
  878.   >6    short        >0        %d x
  879.   >8    short        >0        %d,
  880.   >10    byte        &0x40        interlaced,
  881. ***************
  882. *** 52,56 ****
  883.   0    string        GKSM            GKS Metafile
  884.   8    string        ILBM            IFF ILBM file
  885.   0    string        yz            MGR bitmap
  886. - 6    string        JFIF            JPEG picture
  887.   0       string          ARF_BEGARF          PHIGS clear text archive
  888. --- 52,85 ----
  889.   0    string        GKSM            GKS Metafile
  890.   8    string        ILBM            IFF ILBM file
  891.   0    string        yz            MGR bitmap
  892.   0       string          ARF_BEGARF          PHIGS clear text archive
  893. + 0    string        \0\0\1\263        MPEG Paris
  894. + # PCX formats (source: Selke's filetype program, 1991)
  895. + 0    string    \x0A\x00    PCX image (Paintbrush version 2.5)
  896. + 0    string    \x0A\x02    PCX image (Paintbrush version 2.8, with palette)
  897. + 0    string    \x0A\x03    PCX image (Paintbrush version 2.8, without palette)
  898. + 0  string    \x0A\x05    PCX image (Paintbrush version 3.0)
  899. + # JPEG (source: Cameron Simpson cameron@cs.unsw.oz.au,
  900. + #               John Adams J.Adams@ucl.ac.uk)
  901. + 0    long        0xffd8ffe0        JPEG image, big endian
  902. + 0    long        0xe0ffd8ff        JPEG image, little endian
  903. + 0    string        hsi1            HSI1 image (wrapper for JPEG?)
  904. + 6    string        JFIF            JPEG JFIF
  905. + #
  906. + # >>>>> BMP, etc. <<<<< (source: Greg Roelofs roe2@midway.uchicago.edu)
  907. + # [GRR: The >14 entries should really be strings of length four]
  908. + #
  909. + 0    string        BM            bitmap
  910. + >14    byte        12            (OS/2 1.x format)
  911. + >14    byte        64            (OS/2 2.x format)
  912. + >14    byte        40            (Windows 3.x format)
  913. + # [GRR says the following are untested]
  914. + 0    string        IC            icon
  915. + 0    string        PI            pointer
  916. + 0    string        CI            color icon
  917. + 0    string        CP            color pointer
  918. + 0    string        BA            bitmap array
  919. + # movie files from OS/2 (these are guesses)
  920. + 0  string      RIFF     
  921. + >8 string      AVI      movie
  922. Only in old/Magdir: images.orig
  923. diff -cr old/Magdir/ispell src/Magdir/ispell
  924. *** old/Magdir/ispell    Mon Apr 05 14:39:58 1993
  925. --- src/Magdir/ispell    Wed Aug 04 20:28:20 1993
  926. ***************
  927. *** 3,9 ****
  928.   #
  929.   # XXX - byte order?
  930.   #
  931. ! 0    short    0xffff9601    ispell hash file
  932.   >2    short    0x00    - 8-bit, no capitalization, 26 flags
  933.   >2    short    0x01    - 7-bit, no capitalization, 26 flags 
  934.   >2    short    0x02    - 8-bit, capitalization, 26 flags
  935. --- 3,10 ----
  936.   #
  937.   # XXX - byte order?
  938.   #
  939. ! #0    short    0xffff9601    ispell hash file
  940. ! 0    short    0x9601    ispell hash file
  941.   >2    short    0x00    - 8-bit, no capitalization, 26 flags
  942.   >2    short    0x01    - 7-bit, no capitalization, 26 flags 
  943.   >2    short    0x02    - 8-bit, capitalization, 26 flags
  944. diff -cr old/Magdir/Makefile src/Magdir/Makefile
  945. *** old/Magdir/Makefile    Thu Aug 05 16:20:48 1993
  946. --- src/Magdir/Makefile    Thu Apr 08 19:32:12 1993
  947. ***************
  948. *** 1,16 ****
  949. ! #
  950. ! # Makefile for /etc/magic file for Ian Darwin's file(1) command.
  951. ! # Copyright (c) 1989 Ian F. Darwin, Toronto, Canada.
  952. ! # $Id: Makefile,v 1.8 93/01/05 13:22:31 ian Exp $
  953. ! #
  954. ! #
  955.   SHELL        = /bin/sh
  956.   HEADER        = Header
  957.   LOCALSTUFF    = Localstuff
  958.   
  959. ! ALL        =  $(HEADER) $(LOCALSTUFF) [a-z]*
  960.   
  961.   install:    ../magic
  962.   ../magic:    $(ALL)
  963. !         echo "# Magic file created `date` by `who am i`" > $@
  964.           cat $(ALL) >> $@
  965. --- 1,12 ----
  966. ! # Makefile for OS/2 and dmake 3.8, adapted from the supplied Makefile.
  967.   SHELL        = /bin/sh
  968.   HEADER        = Header
  969.   LOCALSTUFF    = Localstuff
  970.   
  971. ! ALL        =  $(HEADER) $(LOCALSTUFF) $(shell ls [a-z]*)
  972.   
  973.   install:    ../magic
  974.   ../magic:    $(ALL)
  975. !         echo "# Magic file created `date` by `whoami`" > $@
  976.           cat $(ALL) >> $@
  977. Only in src/Magdir: Makefile.orig
  978. diff -cr old/Magdir/ms-dos src/Magdir/ms-dos
  979. *** old/Magdir/ms-dos    Mon Apr 05 14:40:08 1993
  980. --- src/Magdir/ms-dos    Wed Aug 04 17:36:22 1993
  981. ***************
  982. *** 1,8 ****
  983.   #
  984. ! # Various MS-DOS magic numbers
  985.   #
  986. ! 0    string        MZ        DOS executable (EXE)
  987. ! 0    string        LZ        DOS executable (built-in)
  988. ! 0    byte        0xe9        DOS executable (COM)
  989. ! 0    byte        0xeb        DOS executable (COM)
  990. ! 0    byte        0xf0        MS-DOS program library
  991. --- 1,29 ----
  992.   #
  993. ! # Various MS-DOS (and OS/2) magic numbers
  994.   #
  995. ! # Contributions: Jouni Miettunen jon@stekt.oulu.fi
  996. ! #                Greg Roelofs roe2@midway.uchicago.edu 
  997. ! #                Darrel Hankerson hankedr@mail.auburn.edu
  998. ! #
  999. ! 0  string      MZ             DOS executable
  1000. ! >24   string   @              (OS/2 or Windows format)
  1001. ! # DH: OS/2 lh 2.22
  1002. ! >>0xe7 string  LH/2\ Self-Extract  (%s)
  1003. ! # DH: OS/2 PKZip 1.01
  1004. ! >>0xe9 string  PKSFX2         (%s)
  1005. ! >0x19 string   \x0\x0\x0LZ91  (lzexe compressed)
  1006. ! >0x1c string   RJSX\xff\xff   (ARJ SFX)
  1007. ! >0x1c string   diet\xf9\x9c   (diet compressed)
  1008. ! >0x1e string   Copyright\ 1989-1990\ PKWARE\ Inc.  (PKSFX)
  1009. ! # JM: 0x1e "PKLITE Copr. 1990-92 PKWARE Inc. All Rights Reserved\7\0\0\0"
  1010. ! >0x1e string   PKLITE\ Copr.  (%.6s compressed)
  1011. ! >0x24 string   LHa's\ SFX     (%.15s) 
  1012. ! >0x24 string   LHA's\ SFX     (%.15s)
  1013. ! 0  string      LZ             DOS executable (built-in)
  1014. ! 0  byte     0xe9              DOS executable (COM)
  1015. ! >6 string   SFX\ of\ LHarc    (%s)
  1016. ! 0  byte     0xeb              DOS executable (COM)
  1017. ! 0  byte     0xf0              MS-DOS program library
  1018. ! 0  string   ?_\3\0            Windows HLP
  1019. Only in src/Magdir: os2
  1020. diff -cr old/Magdir/psdbms src/Magdir/psdbms
  1021. *** old/Magdir/psdbms    Mon Apr 05 14:40:16 1993
  1022. --- src/Magdir/psdbms    Wed Aug 04 20:16:52 1993
  1023. ***************
  1024. *** 1,6 ****
  1025.   #
  1026.   # magic.ps: psdatabase magic
  1027.   #
  1028. ! 0    byte    0126    ps database
  1029. ! >1    string    >\0    - version %s
  1030. ! >4    string    >\0    from kernel %s
  1031. --- 1,6 ----
  1032.   #
  1033.   # magic.ps: psdatabase magic
  1034.   #
  1035. ! #0    byte    0126    ps database
  1036. ! #>1    string    >\0    - version %s
  1037. ! #>4    string    >\0    from kernel %s
  1038. diff -cr old/Magdir/tex src/Magdir/tex
  1039. *** old/Magdir/tex    Thu Aug 05 16:20:48 1993
  1040. --- src/Magdir/tex    Sat Jul 31 19:50:04 1993
  1041. ***************
  1042. *** 3,11 ****
  1043.   #
  1044.   # XXX - needs byte-endian stuff (big-endian and little-endian DVI?)
  1045.   #
  1046. ! 0    short    0173402    DVI File
  1047. ! >16    string    >\0    (%s)
  1048. ! 0    short    0173531    Packed TeX Font
  1049. ! >4    string    >\0    (%s)
  1050. ! 2    string    \000\022    Metafont Font Metric
  1051. ! >34    string    >\0    (%s)
  1052. --- 3,27 ----
  1053.   #
  1054.   # XXX - needs byte-endian stuff (big-endian and little-endian DVI?)
  1055.   #
  1056. ! #0  short   0173402 DVI File
  1057. ! 0   string  \xf7\x02\x01\x83        DVI
  1058. ! >16 string  >\0             (%s)
  1059. ! # PK files and font lib entries from dvips
  1060. ! 0  string   \xf7\x59             TeX PK
  1061. ! >3 string   >\0                  (%s)
  1062. ! # font lib has string length (short) preceding comment
  1063. ! 0  string   FLIB\2\0             emTeX font lib
  1064. ! >12 short   >0
  1065. ! >>14 string >\0                  (%s)
  1066. ! 0   short   0173531 Packed TeX Font
  1067. ! >4  string  >\0 (%s)
  1068. ! 2   string  \000\022    Metafont Font Metric
  1069. ! >33 string  >\0 (%s)
  1070. ! # TeX vf entries from dvips: pre,id,len. String need not be asciiz.
  1071. ! 0  string   \xf7\xca TeX vf
  1072. ! >3 string   >\0      (%s)
  1073. ! #
  1074. ! 0  string   This\ is\ Info\ file  TeX Info text
  1075. ! >18 string   >\0                  (%s)
  1076. ! 0  string   Info\ file            TeX Info text
  1077. ! >10 string   >\0                  (%s)
  1078. Only in old/Magdir: tex.orig
  1079. diff -cr old/Magdir/uuencode src/Magdir/uuencode
  1080. *** old/Magdir/uuencode    Mon Apr 05 14:40:30 1993
  1081. --- src/Magdir/uuencode    Sun Aug 01 10:27:18 1993
  1082. ***************
  1083. *** 1,3 ****
  1084. --- 1,9 ----
  1085.   0    string        begin         uuencoded mail text
  1086.   # Btoa(1) is an alternative to uuencode that requires less space.
  1087.   0    string        xbtoa\ Begin    btoa'd text
  1088. + # ship is used by INFO-Zip
  1089. + 0  string   $\015\012ship     ship mail text
  1090. + >8 string   >\0               (%s)
  1091. + 0  string   $\012ship         ship mail text
  1092. + >7 string   >\0               (%s)
  1093. Only in old: magic
  1094. Only in old: magic.4
  1095. Only in src: Makefile.os2
  1096. Only in src: notes.os2
  1097. Only in src: notes2.os2
  1098. diff -cr old/print.c src/print.c
  1099. *** old/print.c    Thu Aug 05 16:20:50 1993
  1100. --- src/print.c    Fri Jul 30 14:57:42 1993
  1101. ***************
  1102. *** 34,40 ****
  1103. --- 34,42 ----
  1104.   # include <varargs.h>
  1105.   #endif
  1106.   #include <stdlib.h>
  1107. + #ifndef MSC
  1108.   #include <unistd.h>
  1109. + #endif
  1110.   #include "file.h"
  1111.   
  1112.   #ifndef lint
  1113. ***************
  1114. *** 52,66 ****
  1115.                    "long", "string", "date", "beshort",
  1116.                    "belong", "bedate", "leshort", "lelong",
  1117.                    "ledate" };
  1118.       (void) fprintf(stderr, "[%s,%d,%s,%s%c,",
  1119.           (m->flag >= 0 && m->flag < 4 ? offs[m->flag]: "*bad*"),
  1120.           m->offset,
  1121. !         (m->type >= 0 && m->type < 7 ? 
  1122.                   typ[(unsigned char) m->type] : "*bad*"),
  1123.           m->reln & MASK ? "&" : "",
  1124.           m->reln & ~MASK);
  1125. !     if (m->flag & INDIR)
  1126.           (void) fprintf(stderr, "(%s,%d)",
  1127.           (m->in.type >= 0 && 
  1128.           m->in.type < 6 ? typ[(unsigned char) m->in.type] : "*bad*"),
  1129.           m->in.offset);
  1130. --- 54,81 ----
  1131.                    "long", "string", "date", "beshort",
  1132.                    "belong", "bedate", "leshort", "lelong",
  1133.                    "ledate" };
  1134. + #ifdef MSC
  1135. +     (void) fprintf(stderr, "[%s,%ld,%s,%s%c,",
  1136. + #else
  1137.       (void) fprintf(stderr, "[%s,%d,%s,%s%c,",
  1138. + #endif
  1139.           (m->flag >= 0 && m->flag < 4 ? offs[m->flag]: "*bad*"),
  1140.           m->offset,
  1141. ! #ifdef OS2         /* bugfix, not OS/2 specific */
  1142. !         (m->type >= 0 && m->type < sizeof(typ)/sizeof(typ[0]) ?
  1143. ! #else
  1144. !         (m->type >= 0 && m->type < 7 ?
  1145. ! #endif
  1146.                   typ[(unsigned char) m->type] : "*bad*"),
  1147.           m->reln & MASK ? "&" : "",
  1148.           m->reln & ~MASK);
  1149. !         if (m->flag & INDIR)
  1150. ! #ifdef MSC
  1151. !         (void) fprintf(stderr, "(%s,%ld)",
  1152. ! #else
  1153.           (void) fprintf(stderr, "(%s,%d)",
  1154. + #endif
  1155.           (m->in.type >= 0 && 
  1156.           m->in.type < 6 ? typ[(unsigned char) m->in.type] : "*bad*"),
  1157.           m->in.offset);
  1158. diff -cr old/softmagic.c src/softmagic.c
  1159. *** old/softmagic.c    Thu Aug 05 16:20:50 1993
  1160. --- src/softmagic.c    Fri Jul 30 15:18:16 1993
  1161. ***************
  1162. *** 162,174 ****
  1163.       return 0;                /* no match at all */
  1164.   }
  1165.   
  1166.   static void
  1167.   mprint(m, s)
  1168.   struct magic *m;
  1169.   unsigned char *s;
  1170.   {
  1171.       register union VALUETYPE *p = (union VALUETYPE *)(s+m->offset);
  1172. !     char *pp, *rt;
  1173.   
  1174.         switch (m->type) {
  1175.         case BYTE:
  1176. --- 162,196 ----
  1177.       return 0;                /* no match at all */
  1178.   }
  1179.   
  1180. + #ifdef OS2
  1181.   static void
  1182. + printf_eol(fmt, str)
  1183. + char *fmt, *str;
  1184. + {
  1185. +     char    *rt, *nl;
  1186. +     if ((nl = strchr(str, '\n')) != NULL)
  1187. +         *nl = '\0';
  1188. +     if ((rt = strrchr(str, '\r')) != NULL)
  1189. +         *rt = '\0';
  1190. +     (void) printf(fmt, str);
  1191. +     if (rt)
  1192. +         *rt = '\r';
  1193. +     if (nl)
  1194. +         *nl = '\n';
  1195. + }
  1196. + #endif
  1197. + static void
  1198.   mprint(m, s)
  1199.   struct magic *m;
  1200.   unsigned char *s;
  1201.   {
  1202.       register union VALUETYPE *p = (union VALUETYPE *)(s+m->offset);
  1203. !     char *pp;
  1204. ! #ifndef OS2
  1205. !     char *rt;
  1206. ! #endif
  1207.   
  1208.         switch (m->type) {
  1209.         case BYTE:
  1210. ***************
  1211. *** 188,208 ****
  1212. --- 210,238 ----
  1213.                      (m->reln & MASK) ? p->l & m->mask : p->l);
  1214.             break;
  1215.         case STRING:
  1216. + #ifdef OS2                /* handle both "\r\n" and "\n" */
  1217. +         (void) printf_eol(m->desc, p->s);
  1218. + #else        
  1219.           if ((rt=strchr(p->s, '\n')) != NULL)
  1220.               *rt = '\0';
  1221.           (void) printf(m->desc, p->s);
  1222.           if (rt)
  1223.               *rt = '\n';
  1224. + #endif
  1225.           break;
  1226.       case DATE:
  1227.       case BEDATE:
  1228.       case LEDATE:
  1229.           pp = ctime((time_t*) &p->l);
  1230. + #ifdef OS2                /* handle both "\r\n" and "\n" */
  1231. +         (void) printf_eol(m->desc, pp);
  1232. + #else        
  1233.           if ((rt = strchr(pp, '\n')) != NULL)
  1234.               *rt = '\0';
  1235.           (void) printf(m->desc, pp);
  1236.           if (rt)
  1237.               *rt = '\n';
  1238. + #endif
  1239.           break;
  1240.       default:
  1241.           error("invalid m->type (%d) in mprint().\n", m->type);
  1242. ***************
  1243. *** 262,268 ****
  1244. --- 292,302 ----
  1245.       case BELONG:
  1246.       case BEDATE:
  1247.           v = (long)
  1248. + #ifdef MSC        /* bugfix, required for 16-bit int */
  1249. +             (((long) p->hl[0]<<24)|((long) p->hl[1]<<16)|(p->hl[2]<<8)|(p->hl[3]));
  1250. + #else
  1251.               ((p->hl[0]<<24)|(p->hl[1]<<16)|(p->hl[2]<<8)|(p->hl[3]));
  1252. + #endif
  1253.           break;
  1254.       case LESHORT:
  1255.           v = (short)((p->hs[1]<<8)|(p->hs[0]));
  1256. ***************
  1257. *** 270,276 ****
  1258. --- 304,314 ----
  1259.       case LELONG:
  1260.       case LEDATE:
  1261.           v = (long)
  1262. + #ifdef MSC        /* bugfix, required for 16-bit int */
  1263. +             (((long) p->hl[3]<<24)|((long) p->hl[2]<<16)|(p->hl[1]<<8)|(p->hl[0]));
  1264. + #else
  1265.               ((p->hl[3]<<24)|(p->hl[2]<<16)|(p->hl[1]<<8)|(p->hl[0]));
  1266. + #endif
  1267.           break;
  1268.       default:
  1269.           error("invalid type %d in mcheck().\n", m->type);
  1270.