"Fossies" - the Fresh Open Source Software Archive

Member "grace-5.1.25/src/buildinfo.c" (14 Feb 2015, 3408 Bytes) of package /linux/misc/grace-5.1.25.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "buildinfo.c" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 5.1.24_vs_5.1.25.

    1 /* buildinfo.c */
    2 
    3 #include <config.h>
    4 
    5 #include <stdlib.h>
    6 #include <stdio.h>
    7 #include <string.h>
    8 #include <sys/types.h>
    9 #include <sys/utsname.h>
   10 #include <time.h>
   11 #ifndef NONE_GUI
   12 #  include <Xm/Xm.h>
   13 #  include <Xbae/patchlevel.h>
   14 #endif
   15 
   16 #include <t1lib.h>
   17 #ifdef HAVE_LIBPNG
   18 #include <png.h>
   19 #endif
   20 #ifdef HAVE_LIBJPEG
   21 #include <jpeglib.h>
   22 #endif
   23 #ifdef HAVE_LIBPDF
   24 #include <pdflib.h>
   25 #endif
   26 
   27 #define MAJOR_REV 5
   28 #define MINOR_REV 1
   29 #define PATCHLEVEL 25
   30 /* #define BETA_VER "dev" */
   31 
   32 #ifndef GRACE_HOME
   33 #  define GRACE_HOME "/usr/local/grace"
   34 #endif
   35 
   36 #ifndef GRACE_PRINT_CMD
   37 #  define GRACE_PRINT_CMD ""
   38 #endif
   39 
   40 #ifndef GRACE_EDITOR
   41 #  define GRACE_EDITOR "xterm -e vi"
   42 #endif
   43 
   44 #ifndef GRACE_HELPVIEWER
   45 #  define GRACE_HELPVIEWER "mozilla -remote openURL\\\\(%s,new-window\\\\) >>/dev/null 2>&1 || mozilla %s"
   46 #endif
   47 
   48 
   49 static void VersionInfo(FILE *outfile)
   50 {
   51 
   52     struct utsname u_info;
   53     time_t time_info;
   54     char *ctime_string;
   55 
   56     fprintf(outfile, "#define BI_VERSION_ID %d\n",
   57             MAJOR_REV*10000 + MINOR_REV*100 + PATCHLEVEL);
   58 #ifdef BETA_VER
   59     fprintf(outfile, "#define BI_VERSION \"Grace-%d.%d.%d %s\"\n",
   60         MAJOR_REV, MINOR_REV, PATCHLEVEL, BETA_VER);
   61 #else
   62     fprintf(outfile, "#define BI_VERSION \"Grace-%d.%d.%d\"\n",
   63         MAJOR_REV, MINOR_REV, PATCHLEVEL);
   64 #endif
   65 
   66 /* We don't want to reproduce the complete config.h,
   67    but those settings which may be related to problems at runtime */
   68 
   69 #ifdef NONE_GUI
   70     fprintf(outfile, "#define BI_GUI \"none\"\n");
   71 #else
   72     fprintf(outfile, "#define BI_GUI \"%s\"\n", XmVERSION_STRING);
   73     fprintf(outfile, "#define BI_GUI_XBAE \"%i\"\n", XbaeVersion);
   74 #endif
   75     
   76     fprintf(outfile, "#define BI_T1LIB \"%s\"\n",
   77         T1_GetLibIdent());
   78 
   79 #ifdef HAVE_LIBPNG
   80     fprintf(outfile, "#define BI_PNGLIB \"%s\"\n",
   81         PNG_LIBPNG_VER_STRING);
   82 #else
   83     fprintf(outfile, "#define BI_PNGLIB \"\"\n");
   84 #endif
   85 
   86 #ifdef HAVE_LIBJPEG
   87     fprintf(outfile, "#define BI_LIBJPEG \"%i\"\n",
   88         JPEG_LIB_VERSION);
   89 #else
   90     fprintf(outfile, "#define BI_LIBJPEG \"\"\n");
   91 #endif
   92 
   93 #ifdef HAVE_LIBPDF
   94     fprintf(outfile, "#define BI_LIBPDF \"%s\"\n",
   95         PDFLIB_VERSIONSTRING);
   96 #else
   97     fprintf(outfile, "#define BI_LIBPDF \"\"\n");
   98 #endif
   99 
  100     fprintf(outfile, "#define BI_CCOMPILER \"%s\"\n",
  101         CCOMPILER);
  102     
  103     uname(&u_info);
  104     fprintf(outfile, "#define BI_SYSTEM \"%s %s %s %s\"\n",
  105         u_info.sysname, u_info.version, u_info.release, u_info.machine);
  106 
  107     time_info = time(NULL);
  108     ctime_string = ctime(&time_info);
  109     if (ctime_string[strlen(ctime_string) - 1] == '\n') {
  110         ctime_string[strlen(ctime_string) - 1] = '\0';
  111     }
  112     fprintf(outfile, "#define BI_DATE \"%s\"\n", ctime_string);
  113 
  114     fprintf(outfile, "\n");
  115 
  116     fprintf(outfile, "#define GRACE_HOME \"%s\"\n", GRACE_HOME);
  117     fprintf(outfile, "#define GRACE_EDITOR \"%s\"\n", GRACE_EDITOR);
  118     fprintf(outfile, "#define GRACE_PRINT_CMD \"%s\"\n", GRACE_PRINT_CMD);
  119     fprintf(outfile, "#define GRACE_HELPVIEWER \"%s\"\n", GRACE_HELPVIEWER);
  120 
  121     return;
  122 }
  123 
  124 
  125 int main(int argc, char *argv[])
  126 {
  127     FILE *outfile;
  128 
  129     if (argc == 1) {
  130     outfile = stdout;
  131     } else {
  132         if (!(outfile = fopen(argv[1], "w"))) {
  133             fprintf(stderr, "Failed to open %s for writing!\a\n", argv[1]);
  134             exit(1);
  135         }
  136     }
  137 
  138     VersionInfo(outfile);
  139    
  140     if (outfile != stdout) {
  141         fclose(outfile);
  142     }
  143     exit(0);
  144 }