Back to index

tetex-bin  3.0
Defines | Functions
vmsbbfig.c File Reference
#include <stdio.h>
#include <ssdef.h>
#include <unixlib>

Go to the source code of this file.

Defines

#define BBFIG_HEADER   "tex_disk:[tex.dvips.header_files]bb.ps"

Functions

 main (int argc, char **argv)
static error (char *s1, char *s2)

Define Documentation

#define BBFIG_HEADER   "tex_disk:[tex.dvips.header_files]bb.ps"

Definition at line 12 of file vmsbbfig.c.


Function Documentation

static error ( char *  s1,
char *  s2 
) [static]

Definition at line 106 of file vmsbbfig.c.

{
       /* Notice that the first argument (s1) contains the formatting
        * information for fprintf. 
        */
       fprintf(stderr, "bbfig: "); fprintf(stderr, s1, s2); exit(0x10000000);
}

Here is the call graph for this function:

main ( int  argc,
char **  argv 
)

Definition at line 14 of file vmsbbfig.c.

{
        FILE *infp, *libfp, *outfp;
       char outfile[1024], buf[BUFSIZ], line[512], *cptr;

       if (argc < 2) { error("Usage: bbfig psfile [> outfile]\n"); }
       if ( !strcmp(argv[1], "-help") || !strcmp(argv[1], "-HELP") )
       {
              fprintf(stderr, "bbfig: usage: bbfig psfile [> outfile]\n");
              fflush(stderr); fprintf(stderr, 
"If no output file specified, output file is bbfig_out.ps\n");
              fflush(stderr); fprintf(stderr, 
"Output file shows figure surrounded by box made of dashes\n");
              fflush(stderr); fprintf(stderr, 
"Output file also shows bounding box in default coordinates for use as\n");
              fflush(stderr); fprintf(stderr, 
"Bounding Box comment as second line of PostScript file.\n");
              exit(SS$_NORMAL);
       }
        if ( (libfp = fopen(BBFIG_HEADER,"r")) == NULL)
        {
              error("ABNORMAL EXIT:\nCan't open PostScript macro file %s\n", 
                                   BBFIG_HEADER);
        }
        if ( (infp = fopen(*++argv,"r")) == NULL)
        {
              error("ABNORMAL EXIT:\nCan't open user PostScript file %s\n", 
                     *argv);
        }
       if (argc >=3)
       {
              argv++;
              if ( (*argv)[0] ==  '>')
              {
                     if ((*argv)[1])
                     /* We had bbfig file  >outfile */
                     {
                            cptr = &(*argv)[1];
                            (void) sprintf(outfile,"%s", cptr);
                     }
                     else if (*(++argv) != NULL) 
                     /* We had bbfig psfile > outfile */
                     { 
                            cptr = *argv;
                            (void) sprintf(outfile,"%s", cptr);
                     }
                     else
                     {
                            error("%s: no filename with '>' option\n",
                                          "ABNORMAL EXIT");
                     }
              }
              else
              {
                     error("ABNORMAL EXIT: unknown option %c\n",
                                   (*argv)[0]);
              }
       }
       else
       {
              /* Default filename is "bbfig_out.ps" */
              sprintf(outfile, "bbfig_out.ps");
       }
       /* Make a standard variable length record file
       * with carriage return carriage control. 
       */
        if ( (outfp = fopen(outfile,"w", "rat=cr", "rfm=var")) == NULL)
        {
              error("ABNORMAL EXIT: can't create text file %s\n", 
                     outfile);
        }
       while (fgets(line, 511, libfp))
       {
                        fputs(line, outfp); fflush(outfp);
        }
        (void) fclose (libfp);
       while (fgets(line, 511, infp))
       {
                        fputs(line, outfp); fflush(outfp);
        }
        (void) fclose (infp); (void) fclose (outfp);
       fprintf(stderr, "Output file showing bounding box is %s;\n", outfile);
       fflush(stderr);
       fprintf(stderr, 
"You may print it by lpr to a PostScript printer or\n"); fflush(stderr);
       fprintf(stderr, 
"preview it by gs (ghostscript) on a X11 display ...\n"); fflush(stderr);
       exit(SS$_NORMAL);
}

Here is the call graph for this function: