Back to index

tetex-bin  3.0
printversion.c
Go to the documentation of this file.
00001 /* printversion.c: Output for the standard GNU option --version.
00002 
00003    Written in 1996 by K. Berry.  Public domain.  */
00004 
00005 #include "config.h"
00006 
00007 /* We're passed in the original WEB banner string, which has the form
00008 This is PROGRAM, Version VERSION-NUMBER
00009    We parse the PROGRAM and VERSION-NUMBER out of this.
00010    
00011    If COPYRIGHT_HOLDER is specified and AUTHOR isn't, then use the
00012    former for the latter.  If AUTHOR is specified and COPYRIGHT_HOLDER
00013    isn't, it means the original program is public domain.
00014    
00015    Maybe I should have just done it all inline in each individual
00016    program, but tangle doesn't allow multiline string constants ...  */
00017 
00018 void
00019 printversionandexit P3C(const_string, banner,
00020                         const_string, copyright_holder,  const_string, author)
00021 {
00022   extern string versionstring;           /* from web2c/lib/version.c */
00023   extern KPSEDLL string kpathsea_version_string;/* from kpathsea/version.c */
00024   string prog_name;
00025   unsigned len;
00026   const_string prog_name_end = strchr (banner, ',');
00027   const_string prog_version = strrchr (banner, ' ');
00028   assert (prog_name_end && prog_version);
00029   prog_version++;
00030   
00031   len = prog_name_end - banner - sizeof ("This is");
00032   prog_name = (string)xmalloc (len + 1);
00033   strncpy (prog_name, banner + sizeof ("This is"), len);
00034   prog_name[len] = 0;
00035 
00036   /* The Web2c version string starts with a space.  */
00037   printf ("%s %s%s\n", prog_name, prog_version, versionstring);
00038   puts (kpathsea_version_string);
00039 
00040   if (copyright_holder) {
00041     printf ("Copyright (C) 1997-2004 %s.\n", copyright_holder);
00042     if (!author)
00043       author = copyright_holder;
00044   }
00045 
00046   puts ("Kpathsea is copyright (C) 1997-2004 Free Software Foundation, Inc.");
00047 
00048   puts ("There is NO warranty.  Redistribution of this software is");
00049   fputs ("covered by the terms of ", stdout);
00050   /* DVIcopy is GPL'd, so no additional words needed. */
00051   if (/*copyright_holder && */!STREQ (prog_name, "DVIcopy")) {
00052     printf ("both the %s copyright and\n", prog_name);
00053   }
00054   puts ("the GNU General Public License.");
00055   puts ("For more information about these matters, see the files");
00056   printf ("named COPYING and the %s source.\n", prog_name);
00057   printf ("Primary author of %s: %s.\n", prog_name, author);
00058   puts ("Kpathsea written by Karl Berry and others.\n");
00059 
00060   uexit (0);
00061 }