home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / vile-src.zip / vile-8.1 / version.c < prev    next >
C/C++ Source or Header  |  1998-09-03  |  5KB  |  170 lines

  1. /*
  2.  * version & usage-messages for vile
  3.  *
  4.  * $Header: /usr/build/vile/vile/RCS/version.c,v 1.41 1998/09/03 10:15:12 cmorgan Exp $
  5.  *
  6.  */
  7.  
  8. #include    "estruct.h"    /* global structures and defines */
  9. #include    "edef.h"    /* global definitions */
  10. #include    "patchlev.h"
  11.  
  12. static    char    version_string[NSTRING];
  13.  
  14. void
  15. print_usage (void)
  16. {
  17.     static    const char *const options[] = {
  18.     "-h             to get help on startup",
  19.     "-gNNN          or simply +NNN to go to line NNN",
  20. #if SYS_WINNT && defined(DISP_NTWIN)
  21.     "-fn fontspec   to change font",
  22.     "-geometry CxR  to set initial size to R rows and C columns",
  23. #endif
  24. #if SYS_WINNT && defined(VILE_OLE) && defined(DISP_NTWIN)
  25.     "-Oa            invoke as an OLE Automation server",
  26.     "-Or            register ole automation interface and exit",
  27.     "-Ou            unregister ole automation interface and exit",
  28.     "-invisible     OLE Automation server does not initially show a window",
  29.     "-multiple      multiple instances of OLE Automation server permitted",
  30. #endif
  31.     "-sstring       or +/string to search for \"string\"",
  32. #if OPT_TAGS
  33.     "-ttagname      to look up a tag",
  34. #endif
  35.     "-v             to edit in \"view\" mode -- no changes permitted",
  36.     "-R             to edit files \"read-only\" -- no writes permitted",
  37. #if OPT_ENCRYPT
  38.     "-kcryptkey     for encrypted files (same as -K)",
  39. #endif
  40. #if DISP_X11
  41.     "-name name     to change program name for X resources",
  42.     "-wm name       to set name in title bar",
  43.     "-fg color      to change foreground color",
  44.     "-bg color      to change background color",
  45.     "-fn fontname   to change font",
  46.     "-fork          to spawn xvile immediately on startup",
  47.     "+fork          to force xvile to not spawn on startup",
  48.     "-display       displayname to change the default display",
  49.     "-rv            for reverse video",
  50.     "-geometry CxR  to set initial size to R rows and C columns",
  51.     "-xrm Resource  to change an xvile resource",
  52.     "-leftbar       Put scrollbar(s) on left",
  53.     "-rightbar      Put scrollbar(s) on right (default)",
  54. #endif
  55. #if DISP_IBMPC || DISP_BORLAND
  56.     "-2             25-line mode",
  57.     "-4             43-line mode",
  58.     "-5             50-line mode",
  59. #if SYS_OS2
  60.     "-6             60-line mode",
  61. #endif
  62.     "(see help file for more screen resolutions)",
  63. #endif
  64.     "-V             for version info",
  65.     "use @cmdfile to run cmdfile as commands (this will suppress .vilerc)"
  66.     };
  67.     register SIZE_T    j;
  68.  
  69.     ttclean(TRUE);
  70. #if DISP_NTWIN
  71.     gui_usage(prog_arg, options, TABLESIZE(options));
  72. #else
  73.     (void)fprintf(stderr, "usage: %s [-flags] [@cmdfile] files...\n",
  74.         prog_arg);
  75.     for (j = 0; j < TABLESIZE(options); j++)
  76.         (void)fprintf(stderr, "\t%s\n", options[j]);
  77. #endif
  78.     ExitProgram(BADEXIT);
  79. }
  80.  
  81. const char *
  82. getversion(void)
  83. {
  84.     if (*version_string)
  85.         return version_string;
  86. #if SYS_UNIX || SYS_VMS
  87.     /*
  88.      * We really would like to have the date at which this program was
  89.      * linked, but a.out doesn't have that in general.  COFF files do.
  90.      * Getting the executable's modification-time is a reasonable
  91.      * compromise.
  92.      */
  93.     (void) lsprintf(version_string, "%s %s%s for %s",
  94.                 prognam, version, PATCHLEVEL, opersys);
  95.     {
  96.         char *s;
  97.         if ((s = flook(prog_arg,
  98.                 (FL_EXECDIR|FL_PATH)|FL_EXECABLE)) != NULL) {
  99.             time_t mtime = file_modified(s);
  100.             if (mtime != 0) {
  101.                 (void)strcat(version_string, ", installed ");
  102.                 (void)strcat(version_string, ctime(&mtime));
  103.                 /* trim the newline */
  104.                 version_string[strlen(version_string)-1] = EOS;
  105.             }
  106.         }
  107.     }
  108. #else
  109. # if SYS_MSDOS || SYS_OS2 || SYS_WINNT
  110. #  if defined(__DATE__) && !SMALLER
  111.     (void)lsprintf(version_string,"%s %s%s for %s, built %s %s with %s",
  112.         prognam, version, PATCHLEVEL, opersys, __DATE__, __TIME__,
  113. #   if CC_WATCOM
  114.         "Watcom C/386"
  115. #   endif
  116. #   if CC_DJGPP
  117. #    if __DJGPP__ >= 2
  118.         "DJGPP v2"
  119. #    else
  120.         "DJGPP"
  121. #    endif
  122. #   endif
  123. #   if CC_TURBO
  124. #    ifdef __BORLANDC__
  125.         "Borland C++"
  126. #    else
  127.                 "Turbo C"
  128. #    endif
  129. #   endif
  130. #   if CC_CSETPP
  131. #    if __IBMC__ >= 300
  132.         "VisualAge C++"
  133. #    else
  134.         "IBM C Set ++"
  135. #    endif
  136. #   endif
  137. #   if CC_MSVC
  138.         "Visual C++"
  139. #   endif
  140.     );
  141. #  endif
  142. # endif /* SYS_MSDOS || SYS_OS2 || SYS_WINNT */
  143. #endif /* not SYS_UNIX or SYS_VMS */
  144.     return version_string;
  145. }
  146.  
  147. /* ARGSUSED */
  148. int
  149. showversion(int f GCC_UNUSED, int n GCC_UNUSED)
  150. {
  151.     mlforce(getversion());
  152.     return TRUE;
  153. }
  154.  
  155.  
  156. /*
  157.  * Returns the special string consisting of program name + version, used to
  158.  * fill in the filename-field for scratch buffers that are not associated with
  159.  * an external file.
  160.  */
  161. const char *
  162. non_filename(void)
  163. {
  164.     static    char    buf[80];
  165.     if (buf[0] == EOS)
  166.         (void)lsprintf(buf, "       %s   %s%s",
  167.                 prognam, version, PATCHLEVEL);
  168.     return buf;
  169. }
  170.