home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 9 Archive / 09-Archive.zip / zip22.zip / unix / unix.c < prev    next >
C/C++ Source or Header  |  1997-08-24  |  17KB  |  647 lines

  1. /*
  2.  
  3.  Copyright (C) 1990-1997 Mark Adler, Richard B. Wales, Jean-loup Gailly,
  4.  Kai Uwe Rommel, Onno van der Linden and Igor Mandrichenko.
  5.  Permission is granted to any individual or institution to use, copy, or
  6.  redistribute this software so long as all of the original files are included,
  7.  that it is not sold for profit, and that this copyright notice is retained.
  8.  
  9. */
  10.  
  11. #include "zip.h"
  12.  
  13. #ifndef UTIL    /* the companion #endif is a bit of ways down ... */
  14.  
  15. #include <time.h>
  16.  
  17. #ifdef MINIX
  18. #  ifdef S_IWRITE
  19. #    undef S_IWRITE
  20. #  endif /* S_IWRITE */
  21. #  define S_IWRITE S_IWUSR
  22. #endif /* S_IWUSR */
  23.  
  24. #define MATCH shmatch
  25.  
  26. #if defined(HAVE_DIRENT_H) || defined(_POSIX_VERSION)
  27. #  include <dirent.h>
  28. #else /* !HAVE_DIRENT_H */
  29. #  ifdef HAVE_NDIR_H
  30. #    include <ndir.h>
  31. #  endif /* HAVE_NDIR_H */
  32. #  ifdef HAVE_SYS_NDIR_H
  33. #    include <sys/ndir.h>
  34. #  endif /* HAVE_SYS_NDIR_H */
  35. #  ifdef HAVE_SYS_DIR_H
  36. #    include <sys/dir.h>
  37. #  endif /* HAVE_SYS_DIR_H */
  38. #  ifndef dirent
  39. #    define dirent direct
  40. #  endif
  41. #endif /* HAVE_DIRENT_H || _POSIX_VERSION */
  42.  
  43. #define PAD 0
  44. #define PATH_END '/'
  45.  
  46. /* Library functions not in (most) header files */
  47.  
  48. #ifdef _POSIX_VERSION
  49. #  include <utime.h>
  50. #else
  51.    int utime OF((char *, time_t *));
  52. #endif
  53.  
  54. extern char *label;
  55. local ulg label_time = 0;
  56. local ulg label_mode = 0;
  57. local time_t label_utim = 0;
  58.  
  59. /* Local functions */
  60. local char *readd OF((DIR *));
  61.  
  62.  
  63. #ifdef NO_DIR                    /* for AT&T 3B1 */
  64. #include <sys/dir.h>
  65. #ifndef dirent
  66. #  define dirent direct
  67. #endif
  68. typedef FILE DIR;
  69. /*
  70. **  Apparently originally by Rich Salz.
  71. **  Cleaned up and modified by James W. Birdsall.
  72. */
  73.  
  74. #define opendir(path) fopen(path, "r")
  75.  
  76. struct dirent *readdir(dirp)
  77. DIR *dirp;
  78. {
  79.   static struct dirent entry;
  80.  
  81.   if (dirp == NULL)
  82.     return NULL;
  83.   for (;;)
  84.     if (fread (&entry, sizeof (struct dirent), 1, dirp) == 0)
  85.       return NULL;
  86.     else if (entry.d_ino)
  87.       return (&entry);
  88. } /* end of readdir() */
  89.  
  90. #define closedir(dirp) fclose(dirp)
  91. #endif /* NO_DIR */
  92.  
  93.  
  94. local char *readd(d)
  95. DIR *d;                 /* directory stream to read from */
  96. /* Return a pointer to the next name in the directory stream d, or NULL if
  97.    no more entries or an error occurs. */
  98. {
  99.   struct dirent *e;
  100.  
  101.   e = readdir(d);
  102.   return e == NULL ? (char *) NULL : e->d_name;
  103. }
  104.  
  105. int procname(n)
  106. char *n;                /* name to process */
  107. /* Process a name or sh expression to operate on (or exclude).  Return
  108.    an error code in the ZE_ class. */
  109. {
  110.   char *a;              /* path and name for recursion */
  111.   DIR *d;               /* directory stream from opendir() */
  112.   char *e;              /* pointer to name from readd() */
  113.   int m;                /* matched flag */
  114.   char *p;              /* path for recursion */
  115.   struct stat s;        /* result of stat() */
  116.   struct zlist far *z;  /* steps through zfiles list */
  117.  
  118.   if (strcmp(n, "-") == 0)   /* if compressing stdin */
  119.     return newname(n, 0);
  120.   else if (LSSTAT(n, &s))
  121.   {
  122.     /* Not a file or directory--search for shell expression in zip file */
  123.     p = ex2in(n, 0, (int *)NULL);       /* shouldn't affect matching chars */
  124.     m = 1;
  125.     for (z = zfiles; z != NULL; z = z->nxt) {
  126.       if (MATCH(p, z->iname))
  127.       {
  128.         z->mark = pcount ? filter(z->zname) : 1;
  129.         if (verbose)
  130.             fprintf(mesg, "zip diagnostic: %scluding %s\n",
  131.                z->mark ? "in" : "ex", z->name);
  132.         m = 0;
  133.       }
  134.     }
  135.     free((zvoid *)p);
  136.     return m ? ZE_MISS : ZE_OK;
  137.   }
  138.  
  139.   /* Live name--use if file, recurse if directory */
  140.   if ((s.st_mode & S_IFDIR) == 0)
  141.   {
  142.     /* add or remove name of file */
  143.     if ((m = newname(n, 0)) != ZE_OK)
  144.       return m;
  145.   } else {
  146.     /* Add trailing / to the directory name */
  147.     if ((p = malloc(strlen(n)+2)) == NULL)
  148.       return ZE_MEM;
  149.     if (strcmp(n, ".") == 0) {
  150.       *p = '\0';  /* avoid "./" prefix and do not create zip entry */
  151.     } else {
  152.       strcpy(p, n);
  153.       a = p + strlen(p);
  154.       if (a[-1] != '/')
  155.         strcpy(a, "/");
  156.       if (dirnames && (m = newname(p, 1)) != ZE_OK) {
  157.         free((zvoid *)p);
  158.         return m;
  159.       }
  160.     }
  161.     /* recurse into directory */
  162.     if (recurse && (d = opendir(n)) != NULL)
  163.     {
  164.       while ((e = readd(d)) != NULL) {
  165.         if (strcmp(e, ".") && strcmp(e, ".."))
  166.         {
  167.           if ((a = malloc(strlen(p) + strlen(e) + 1)) == NULL)
  168.           {
  169.             closedir(d);
  170.             free((zvoid *)p);
  171.             return ZE_MEM;
  172.           }
  173.           strcat(strcpy(a, p), e);
  174.           if ((m = procname(a)) != ZE_OK)   /* recurse on name */
  175.           {
  176.             if (m == ZE_MISS)
  177.               zipwarn("name not matched: ", a);
  178.             else
  179.               ziperr(m, a);
  180.           }
  181.           free((zvoid *)a);
  182.         }
  183.       }
  184.       closedir(d);
  185.     }
  186.     free((zvoid *)p);
  187.   } /* (s.st_mode & S_IFDIR) == 0) */
  188.   return ZE_OK;
  189. }
  190.  
  191. char *ex2in(x, isdir, pdosflag)
  192. char *x;                /* external file name */
  193. int isdir;              /* input: x is a directory */
  194. int *pdosflag;          /* output: force MSDOS file attributes? */
  195. /* Convert the external file name to a zip file name, returning the malloc'ed
  196.    string or NULL if not enough memory. */
  197. {
  198.   char *n;              /* internal file name (malloc'ed) */
  199.   char *t;              /* shortened name */
  200.   int dosflag;
  201.  
  202.   dosflag = dosify;  /* default for non-DOS and non-OS/2 */
  203.  
  204.   /* Find starting point in name before doing malloc */
  205.   for (t = x; *t == '/'; t++)
  206.     ;
  207.  
  208.   /* Make changes, if any, to the copied name (leave original intact) */
  209.   if (!pathput)
  210.     t = last(t, PATH_END);
  211.  
  212.   /* Malloc space for internal name and copy it */
  213.   if ((n = malloc(strlen(t) + 1)) == NULL)
  214.     return NULL;
  215.   strcpy(n, t);
  216.  
  217.   if (isdir == 42) return n;      /* avoid warning on unused variable */
  218.  
  219.   if (dosify)
  220.     msname(n);
  221.  
  222.   /* Returned malloc'ed name */
  223.   if (pdosflag)
  224.     *pdosflag = dosflag;
  225.   return n;
  226. }
  227.  
  228. char *in2ex(n)
  229. char *n;                /* internal file name */
  230. /* Convert the zip file name to an external file name, returning the malloc'ed
  231.    string or NULL if not enough memory. */
  232. {
  233.   char *x;              /* external file name */
  234.  
  235.   if ((x = malloc(strlen(n) + 1 + PAD)) == NULL)
  236.     return NULL;
  237.   strcpy(x, n);
  238.   return x;
  239. }
  240.  
  241. /*
  242.  * XXX use ztimbuf in both POSIX and non POSIX cases ?
  243.  */
  244. void stamp(f, d)
  245. char *f;                /* name of file to change */
  246. ulg d;                  /* dos-style time to change it to */
  247. /* Set last updated and accessed time of file f to the DOS time d. */
  248. {
  249. #ifdef _POSIX_VERSION
  250.   struct utimbuf u;     /* argument for utime()  const ?? */
  251. #else
  252.   time_t u[2];          /* argument for utime() */
  253. #endif
  254.  
  255.   /* Convert DOS time to time_t format in u */
  256. #ifdef _POSIX_VERSION
  257.   u.actime = u.modtime = dos2unixtime(d);
  258.   utime(f, &u);
  259. #else
  260.   u[0] = u[1] = dos2unixtime(d);
  261.   utime(f, u);
  262. #endif
  263.  
  264. }
  265.  
  266. ulg filetime(f, a, n, t)
  267. char *f;                /* name of file to get info on */
  268. ulg *a;                 /* return value: file attributes */
  269. long *n;                /* return value: file size */
  270. iztimes *t;             /* return value: access, modific. and creation times */
  271. /* If file *f does not exist, return 0.  Else, return the file's last
  272.    modified date and time as an MSDOS date and time.  The date and
  273.    time is returned in a long with the date most significant to allow
  274.    unsigned integer comparison of absolute times.  Also, if a is not
  275.    a NULL pointer, store the file attributes there, with the high two
  276.    bytes being the Unix attributes, and the low byte being a mapping
  277.    of that to DOS attributes.  If n is not NULL, store the file size
  278.    there.  If t is not NULL, the file's access, modification and creation
  279.    times are stored there as UNIX time_t values.
  280.    If f is "-", use standard input as the file. If f is a device, return
  281.    a file size of -1 */
  282. {
  283.   struct stat s;        /* results of stat() */
  284.   char name[FNMAX];
  285.   int len = strlen(f);
  286.  
  287.   if (f == label) {
  288.     if (a != NULL)
  289.       *a = label_mode;
  290.     if (n != NULL)
  291.       *n = -2L; /* convention for a label name */
  292.     if (t != NULL)
  293.       t->atime = t->mtime = t->ctime = label_utim;
  294.     return label_time;
  295.   }
  296.   strcpy(name, f);
  297.   if (name[len - 1] == '/')
  298.     name[len - 1] = '\0';
  299.   /* not all systems allow stat'ing a file with / appended */
  300.   if (strcmp(f, "-") == 0) {
  301.     if (fstat(fileno(stdin), &s) != 0)
  302.       error("fstat(stdin)");
  303.   }
  304.   else if (LSSTAT(name, &s) != 0)
  305.     /* Accept about any file kind including directories
  306.      * (stored with trailing / with -r option)
  307.      */
  308.     return 0;
  309.  
  310.   if (a != NULL) {
  311.     *a = ((ulg)s.st_mode << 16) | !(s.st_mode & S_IWRITE);
  312.     if ((s.st_mode & S_IFMT) == S_IFDIR) {
  313.       *a |= MSDOS_DIR_ATTR;
  314.     }
  315.   }
  316.   if (n != NULL)
  317.     *n = (s.st_mode & S_IFMT) == S_IFREG ? s.st_size : -1L;
  318.   if (t != NULL) {
  319.     t->atime = s.st_atime;
  320.     t->mtime = s.st_mtime;
  321.     t->ctime = t->mtime;   /* best guess, (s.st_ctime: last status change!!) */
  322.   }
  323.   return unix2dostime(&s.st_mtime);
  324. }
  325.  
  326.  
  327. #ifndef QLZIP /* QLZIP Unix2QDOS cross-Zip supplies an extended variant */
  328.  
  329. int set_extra_field(z, z_utim)
  330.   struct zlist far *z;
  331.   iztimes *z_utim;
  332.   /* store full data in local header but just modification time stamp info
  333.      in central header */
  334. {
  335.   struct stat s;
  336.  
  337.   /* For the full sized UT local field including the UID/GID fields, we
  338.    * have to stat the file again. */
  339.   if (LSSTAT(z->name, &s))
  340.     return ZE_OPEN;
  341.  
  342. #define EB_L_UT_SIZE    (EB_HEADSIZE + EB_UT_LEN(2))
  343. #define EB_C_UT_SIZE    (EB_HEADSIZE + EB_UT_LEN(1))
  344. #define EB_L_UX2_SIZE   (EB_HEADSIZE + EB_UX2_MINLEN)
  345. #define EB_C_UX2_SIZE   EB_HEADSIZE
  346. #define EF_L_UNIX_SIZE  (EB_L_UT_SIZE + EB_L_UX2_SIZE)
  347. #define EF_C_UNIX_SIZE  (EB_C_UT_SIZE + EB_C_UX2_SIZE)
  348.  
  349.   if ((z->extra = (char *)malloc(EF_L_UNIX_SIZE)) == NULL)
  350.     return ZE_MEM;
  351.   if ((z->cextra = (char *)malloc(EF_C_UNIX_SIZE)) == NULL)
  352.     return ZE_MEM;
  353.  
  354.   z->extra[0]  = 'U';
  355.   z->extra[1]  = 'T';
  356.   z->extra[2]  = EB_UT_LEN(2);          /* length of data part of local e.f. */
  357.   z->extra[3]  = 0;
  358.   z->extra[4]  = EB_UT_FL_MTIME | EB_UT_FL_ATIME;    /* st_ctime != creation */
  359.   z->extra[5]  = (char)(s.st_mtime);
  360.   z->extra[6]  = (char)(s.st_mtime >> 8);
  361.   z->extra[7]  = (char)(s.st_mtime >> 16);
  362.   z->extra[8]  = (char)(s.st_mtime >> 24);
  363.   z->extra[9]  = (char)(s.st_atime);
  364.   z->extra[10] = (char)(s.st_atime >> 8);
  365.   z->extra[11] = (char)(s.st_atime >> 16);
  366.   z->extra[12] = (char)(s.st_atime >> 24);
  367.   z->extra[13] = 'U';
  368.   z->extra[14] = 'x';
  369.   z->extra[15] = EB_UX2_MINLEN;         /* length of data part of local e.f. */
  370.   z->extra[16]  = 0;
  371.   z->extra[17] = (char)(s.st_uid);
  372.   z->extra[18] = (char)(s.st_uid >> 8);
  373.   z->extra[19] = (char)(s.st_gid);
  374.   z->extra[20] = (char)(s.st_gid >> 8);
  375.   z->ext = EF_L_UNIX_SIZE;
  376.  
  377.   memcpy(z->cextra, z->extra, EB_C_UT_SIZE);
  378.   z->cextra[EB_LEN] = EB_UT_LEN(1);
  379.   memcpy(z->cextra+EB_C_UT_SIZE, z->extra+EB_L_UT_SIZE, EB_C_UX2_SIZE);
  380.   z->cextra[EB_LEN+EB_C_UT_SIZE] = 0;
  381.   z->cext = EF_C_UNIX_SIZE;
  382.  
  383. #if 0  /* UID/GID presence is now signaled by central EF_IZUNIX2 field ! */
  384.   /* lower-middle external-attribute byte (unused until now):
  385.    *   high bit        => (have GMT mod/acc times) >>> NO LONGER USED! <<<
  386.    *   second-high bit => have Unix UID/GID info
  387.    * NOTE: The high bit was NEVER used in any official Info-ZIP release,
  388.    *       but its future use should be avoided (if possible), since it
  389.    *       was used as "GMT mod/acc times local extra field" flags in Zip beta
  390.    *       versions 2.0j up to 2.0v, for about 1.5 years.
  391.    */
  392.   z->atx |= 0x4000;
  393. #endif /* never */
  394.   return ZE_OK;
  395. }
  396.  
  397. #endif /* !QLZIP */
  398.  
  399.  
  400. int deletedir(d)
  401. char *d;                /* directory to delete */
  402. /* Delete the directory *d if it is empty, do nothing otherwise.
  403.    Return the result of rmdir(), delete(), or system().
  404.    For VMS, d must be in format [x.y]z.dir;1  (not [x.y.z]).
  405.  */
  406. {
  407. # ifdef NO_RMDIR
  408.     /* code from Greg Roelofs, who horked it from Mark Edwards (unzip) */
  409.     int r, len;
  410.     char *s;              /* malloc'd string for system command */
  411.  
  412.     len = strlen(d);
  413.     if ((s = malloc(len + 34)) == NULL)
  414.       return 127;
  415.  
  416.     sprintf(s, "IFS=\" \t\n\" /bin/rmdir %s 2>/dev/null", d);
  417.     r = system(s);
  418.     free(s);
  419.     return r;
  420. # else /* !NO_RMDIR */
  421.     return rmdir(d);
  422. # endif /* ?NO_RMDIR */
  423. }
  424.  
  425. #endif /* !UTIL */
  426.  
  427.  
  428. /******************************/
  429. /*  Function version_local()  */
  430. /******************************/
  431.  
  432. #if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__386BSD__) || \
  433.     defined(__bsdi__)
  434. #include <sys/param.h> /* for the BSD4_4 define */
  435. #endif
  436. /*
  437.  * XXX sysctl should be used for all the 4.4BSD derivatives
  438.  */
  439. #if defined(__NetBSD__) && (BSD4_4 == 1)
  440. #include <sys/sysctl.h>
  441. #endif
  442.  
  443. void version_local()
  444. {
  445.     static ZCONST char CompiledWith[] = "Compiled with %s%s for %s%s%s%s.\n\n";
  446. #if defined(CRAY) || defined(NX_CURRENT_COMPILER_RELEASE) || defined(NetBSD)
  447.     char buf1[40];
  448. #if defined(CRAY) || defined(NX_CURRENT_COMPILER_RELEASE)
  449.     char buf2[40];
  450. #endif
  451. #endif
  452. #ifdef __NetBSD__
  453.     static ZCONST char *netbsd[] = { "_ALPHA", "", "A", "B" };
  454.     int mib[] = { CTL_KERN, KERN_OSRELEASE };
  455.     size_t len = sizeof(buf1) - sizeof("NetBSD ");
  456. #endif
  457.  
  458.     /* Pyramid, NeXT have problems with huge macro expansion, too:  no Info() */
  459.     printf(CompiledWith,
  460.  
  461. #ifdef __GNUC__
  462. #  ifdef NX_CURRENT_COMPILER_RELEASE
  463.       (sprintf(buf1, "NeXT DevKit %d.%02d ", NX_CURRENT_COMPILER_RELEASE/100,
  464.         NX_CURRENT_COMPILER_RELEASE%100), buf1),
  465.       (strlen(__VERSION__) > 8)? "(gcc)" :
  466.         (sprintf(buf2, "(gcc %s)", __VERSION__), buf2),
  467. #  else
  468.       "gcc ", __VERSION__,
  469. #  endif
  470. #else
  471. #  if defined(CRAY) && defined(_RELEASE)
  472.       "cc ", (sprintf(buf1, "version %d", _RELEASE), buf1),
  473. #  else
  474. #  ifdef __VERSION__
  475.       "cc ", __VERSION__,
  476. #  else
  477.       "cc", "",
  478. #  endif
  479. #  endif
  480. #endif
  481.  
  482.       "Unix",
  483.  
  484. #if defined(sgi) || defined(__sgi)
  485.       " (Silicon Graphics IRIX)",
  486. #else
  487. #ifdef sun
  488. #  ifdef sparc
  489. #    ifdef __SVR4
  490.       " (Sun Sparc/Solaris)",
  491. #    else /* may or may not be SunOS */
  492.       " (Sun Sparc)",
  493. #    endif
  494. #  else
  495. #  if defined(sun386) || defined(i386)
  496.       " (Sun 386i)",
  497. #  else
  498. #  if defined(mc68020) || defined(__mc68020__)
  499.       " (Sun 3)",
  500. #  else /* mc68010 or mc68000:  Sun 2 or earlier */
  501.       " (Sun 2)",
  502. #  endif
  503. #  endif
  504. #  endif
  505. #else
  506. #ifdef __hpux
  507.       " (HP/UX)",
  508. #else
  509. #ifdef __osf__
  510.       " (DEC OSF/1)",
  511. #else
  512. #ifdef _AIX
  513.       " (IBM AIX)",
  514. #else
  515. #ifdef aiws
  516.       " (IBM RT/AIX)",
  517. #else
  518. #if defined(CRAY) || defined(cray)
  519. #  ifdef _UNICOS
  520.       (sprintf(buf2, " (Cray UNICOS release %d)", _UNICOS), buf2),
  521. #  else
  522.       " (Cray UNICOS)",
  523. #  endif
  524. #else
  525. #if defined(uts) || defined(UTS)
  526.       " (Amdahl UTS)",
  527. #else
  528. #ifdef NeXT
  529. #  ifdef mc68000
  530.       " (NeXTStep/black)",
  531. #  else
  532.       " (NeXTStep for Intel)",
  533. #  endif
  534. #else              /* the next dozen or so are somewhat order-dependent */
  535. #if defined(linux) || defined(__linux__)
  536. #  ifdef __ELF__
  537.       " (Linux ELF)",
  538. #  else
  539.       " (Linux a.out)",
  540. #  endif
  541. #else
  542. #ifdef MINIX
  543.       " (Minix)",
  544. #else
  545. #ifdef M_UNIX
  546.       " (SCO Unix)",
  547. #else
  548. #ifdef M_XENIX
  549.       " (SCO Xenix)",
  550. #else
  551. #ifdef __NetBSD__
  552. #  ifdef NetBSD0_8
  553.      (sprintf(buf1, " (NetBSD 0.8%s)", netbsd[NetBSD0_8]), buf1),
  554. #  else
  555. #  ifdef NetBSD0_9
  556.      (sprintf(buf1, " (NetBSD 0.9%s)", netbsd[NetBSD0_9]), buf1),
  557. #  else
  558. #  ifdef NetBSD1_0
  559.      (sprintf(buf1, " (NetBSD 1.0%s)", netbsd[NetBSD1_0]), buf1),
  560. #  else
  561.      (strcpy(buf1, " (NetBSD "), sysctl(mib, 2, &buf1[9], &len, NULL, 0),
  562.       strcat(buf1,")")),
  563. #  endif /* NetBSD1_0 */
  564. #  endif /* NetBSD0_9 */
  565. #  endif /* NetBSD0_8 */
  566. #else
  567. #ifdef __FreeBSD__
  568.       (BSD4_4 == 0.5)? " (FreeBSD 1.x)" : " (FreeBSD 2.0 or later)",
  569. #else
  570. #ifdef __bsdi__
  571.       (BSD4_4 == 0.5)? " (BSD/386 1.0)" : " (BSD/386 1.1 or later)",
  572. #else
  573. #ifdef __386BSD__
  574.       (BSD4_4 == 1)? " (386BSD, post-4.4 release)" : " (386BSD)",
  575. #else
  576. #if defined(i486) || defined(__i486) || defined(__i486__)
  577.       " (Intel 486)",
  578. #else
  579. #if defined(i386) || defined(__i386) || defined(__i386__)
  580.       " (Intel 386)",
  581. #else
  582. #ifdef pyr
  583.       " (Pyramid)",
  584. #else
  585. #if defined(ultrix) || defined(__ultrix)
  586. #  if defined(mips) || defined(__mips)
  587.       " (DEC/MIPS)",
  588. #  else
  589. #  if defined(vax) || defined(__vax)
  590.       " (DEC/VAX)",
  591. #  else /* __alpha? */
  592.       " (DEC/Alpha)",
  593. #  endif
  594. #  endif
  595. #else
  596. #ifdef gould
  597.       " (Gould)",
  598. #else
  599. #ifdef MTS
  600.       " (MTS)",
  601. #else
  602. #ifdef __convexc__
  603.       " (Convex)",
  604. #else
  605. #ifdef __QNX__
  606.       " (QNX 4)",
  607. #else
  608. #ifdef __QNXNTO__
  609.       " (QNX Neutrino)",
  610. #else
  611.       "",
  612. #endif /* QNX Neutrino */
  613. #endif /* QNX 4 */
  614. #endif /* Convex */
  615. #endif /* MTS */
  616. #endif /* Gould */
  617. #endif /* DEC */
  618. #endif /* Pyramid */
  619. #endif /* 386 */
  620. #endif /* 486 */
  621. #endif /* 386BSD */
  622. #endif /* BSDI BSD/386 */
  623. #endif /* NetBSD */
  624. #endif /* FreeBSD */
  625. #endif /* SCO Xenix */
  626. #endif /* SCO Unix */
  627. #endif /* Minix */
  628. #endif /* Linux */
  629. #endif /* NeXT */
  630. #endif /* Amdahl */
  631. #endif /* Cray */
  632. #endif /* RT/AIX */
  633. #endif /* AIX */
  634. #endif /* OSF/1 */
  635. #endif /* HP/UX */
  636. #endif /* Sun */
  637. #endif /* SGI */
  638.  
  639. #ifdef __DATE__
  640.       " on ", __DATE__
  641. #else
  642.       "", ""
  643. #endif
  644.     );
  645.  
  646. } /* end function version_local() */
  647.