Search:

Return to previous page

Contents of file 'dvlabel/dvlabel.c':



    1   /*5:*/
    2   #line 411 "./dvlabel.w"
    3   
    4   #include <time.h> 
    5   #include <sys/time.h> 
    6   #include <stdio.h> 
    7   #include <stdarg.h> 
    8   #include <stdlib.h> 
    9   #include <string.h> 
   10   #include <ctype.h> 
   11   
   12   #define VERSION "1.6" 
   13   #define DEFAULT_DVIPSOPTS "-ta4 -D1200" 
   14   #define DEFAULT_LINETHICKNESS (0.5) 
   15   #define DEFAULT_CROPLINETHICKNESS (0.15) 
   16   #define DEFAULT_EDGESEPARATION (1.0)
   17   #define MAXCHAR (128) 
   18   
   19   #define SUCCESS (0) 
   20   #define FAILURE (1) 
   21   
   22   #define INSTREAM (infile_specified?infile:stdin)
   23   #define OUTSTREAM (outfile_specified?outfile:stdout)
   24   
   25   #define log(...) log_printf(__func__, __VA_ARGS__)
   26   
   27   /*6:*/
   28   #line 482 "./dvlabel.w"
   29   
   30   extern char*optarg;
   31   char*progname;
   32   
   33   /*:6*/
   34   #line 435 "./dvlabel.w"
   35   
   36   /*7:*/
   37   #line 488 "./dvlabel.w"
   38   
   39   /*8:*/
   40   #line 514 "./dvlabel.w"
   41   
   42   void log_printf(const char*function_name,const char*format,...){
   43   va_list args;
   44   time_t time0;
   45   struct tm lt;
   46   struct timeval tv;
   47   char logentry[1024];
   48   
   49   gettimeofday(&tv,NULL);
   50   time(&time0);
   51   lt= *localtime(&time0);
   52   sprintf(logentry,"%02u%02u%02u %02u:%02u:%02u.%03d ",
   53   lt.tm_year-100,lt.tm_mon+1,lt.tm_mday,
   54   lt.tm_hour,lt.tm_min,lt.tm_sec,tv.tv_usec/1000);
   55   sprintf(logentry+strlen(logentry),"(%s) ",function_name);
   56   va_start(args,format);
   57   vsprintf(logentry+strlen(logentry),format,args);
   58   va_end(args);
   59   sprintf(logentry+strlen(logentry),"\n");
   60   fprintf(stdout,"%s",logentry);
   61   return;
   62   }
   63   
   64   /*:8*/
   65   #line 489 "./dvlabel.w"
   66   
   67   /*9:*/
   68   #line 539 "./dvlabel.w"
   69   
   70   /*10:*/
   71   #line 607 "./dvlabel.w"
   72   
   73   void hl(const char*format,...){
   74   va_list args;
   75   char line[1024];
   76   
   77   va_start(args,format);
   78   vsprintf(line,format,args);
   79   va_end(args);
   80   sprintf(line+strlen(line),"\n");
   81   fprintf(stdout,"%s",line);
   82   return;
   83   }
   84   
   85   /*:10*/
   86   #line 540 "./dvlabel.w"
   87   
   88   void showsomehelp(void){
   89   hl("Usage: %s [options]",progname);
   90   hl("When invoked without any command line options, this program enters");
   91   hl("interactive mode.");
   92   hl("Options:");
   93   hl(" -i, --inputfile <str>");
   94   hl("    Specifies the file where to read the label text strings, entered in");
   95   hl("    a format corresponding to the input order as would have been");
   96   hl("    entered in interactive mode.");
   97   hl(" -o, --outputfile <str>");
   98   hl("    Specifies the file where to save the generated TeX source code for");
   99   hl("    the label. whenever this option is omitted, the generated source");
  100   hl("    code will be written to standard terminal output instead. Notice");
  101   hl("    that the name specified using this option is used as the *base");
  102   hl("    name* for the generated output; this means that the TeX file");
  103   hl("    automatically will get .tex as suffix, the DVIfile .dvi, etc.");
  104   hl("    For example, if you want to have your TeX output stored into a file");
  105   hl("    named, say, 'foo.tex', just specify '-o foo'.");
  106   hl(" -H, --headline");
  107   hl("    Toggle display of generation time and input source in page header");
  108   hl("    of the generated TeX code. Default: off");
  109   hl(" -C, --cropmarks");
  110   hl("    Toggle display of crop marks (alignment marks) in the generated TeX");
  111   hl("    code. Default: off");
  112   hl(" -t, --linethick <f>");
  113   hl("    Use linethickness of <f> typographic points in generating the boxes");
  114   hl("    of the label. (One point, or pt, equals to 1/72.27 inch.)");
  115   hl(" -s, --edgeseparation <f>");
  116   hl("    Insert extra space of <f> typographic points between the text boxes");
  117   hl("    at the folded edges of the label. This is useful when, for example,");
  118   hl("    thick paper is used. By changing the line thickness, the internal");
  119   hl("    margins of the label are also changed, since the inner edge-to-edge");
  120   hl("    distance between the lines of the inner and outer boxes are linked");
  121   hl("    to be twice the value of the line thickness. The correction of");
  122   hl("    inner bounding boxes of the label text is automatically adjusted so");
  123   hl("    as to ensure that the overall outer dimensions of the label are");
  124   hl("    unchanged.");
  125   hl(" -c, --compile");
  126   hl("    Try to compile the generated TeX code. This requires DVIPS to be");
  127   hl("    installed on your system, see www.radicaleye.com for further info.");
  128   hl(" -e, --eps");
  129   hl("    When compiling the generated TeX code, generate Encapsulated");
  130   hl("    PostScript (EPS) instead of the default regular PostScript.");
  131   hl(" -d, --dvipsopts <str>");
  132   hl("    When compiling the generated TeX code, use <str> as options to be");
  133   hl("    supplied to DVIPS. In order to parse for an arbitrary number of");
  134   hl("    DVIPS options at the command line, it is important to enclose the");
  135   hl("    list of DVIPS options by quotes. Hence, for example, to force DVIPS");
  136   hl("    to generate output pages of US letter format and at a resolution of");
  137   hl("    720 dpi one could invoke DVLABEL with");
  138   hl("          dvlabel --dvipsopts \"-tletter -D720\"");
  139   hl("    The quotes are only necessary if the number of DVIPS options are");
  140   hl("    two or more. Default: -D1200 -ta4 (1200 DPI on A4 paper).");
  141   hl(" -v, --verbose");
  142   hl("    Toggle verbose mode. Default: off");
  143   hl(" -h, --help");
  144   hl("    Display this help message and exit clean.");
  145   hl("\nCopyright (C) 2003-2011 Fredrik Jonsson <http://jonsson.eu>");
  146   }
  147   
  148   /*:9*/
  149   #line 490 "./dvlabel.w"
  150   
  151   /*11:*/
  152   #line 628 "./dvlabel.w"
  153   
  154   short newlabel(FILE*instream){
  155   char ch;
  156   fprintf(stdout,"Create new label record or quit?\n");
  157   fprintf(stdout,"['n'=new label / 'q'=quit]:\n");
  158   fprintf(stdout,"**");
  159   while((ch= fgetc(instream))==' ');
  160   if(ch=='n'){
  161   while((ch= fgetc(instream))!='\n');
  162   return(1);
  163   }else if(ch=='q'){
  164   while((ch= fgetc(instream))!='\n');
  165   return(0);
  166   }else{
  167   log("%s: Error: Unrecognized input stream control character '%c'.\n",
  168   progname,ch);
  169   exit(FAILURE);
  170   }
  171   }
  172   
  173   /*:11*/
  174   #line 491 "./dvlabel.w"
  175   
  176   /*12:*/
  177   #line 660 "./dvlabel.w"
  178   
  179   /*13:*/
  180   #line 674 "./dvlabel.w"
  181   
  182   short pathcharacter(int ch){
  183   return(isalnum(ch)||(ch=='.')||(ch=='/')||(ch=='\\')||(ch=='_')||
  184   (ch=='-')||(ch=='+'));
  185   }
  186   
  187   /*:13*/
  188   #line 661 "./dvlabel.w"
  189   
  190   char*strip_away_path(char filename[]){
  191   int j,k= 0;
  192   while(pathcharacter(filename[k]))k++;
  193   j= (--k);
  194   while(isalnum((int)(filename[j])))j--;
  195   j++;
  196   return(&filename[j]);
  197   }
  198   
  199   /*:12*/
  200   #line 492 "./dvlabel.w"
  201   
  202   
  203   /*:7*/
  204   #line 436 "./dvlabel.w"
  205   
  206   
  207   int main(int argc,char*argv[])
  208   {
  209   /*14:*/
  210   #line 685 "./dvlabel.w"
  211   
  212   time_t now= time(NULL);
  213   long j,k,n,num_address_lines,num_toc_lines,num_labels,num_labels_per_page= 4;
  214   int no_arg,tmpch;
  215   FILE*infile= NULL,*outfile= NULL;
  216   char inputfilename[MAXCHAR]= "",outputfilename[MAXCHAR]= "",tmpstr[MAXCHAR];
  217   char dvipsopts[MAXCHAR]= DEFAULT_DVIPSOPTS;
  218   char timestamp[MAXCHAR]= "\today",title[MAXCHAR]= "";
  219   char author[MAXCHAR]= "",email[MAXCHAR]= "";
  220   char address[10*MAXCHAR]= "",toc[50*MAXCHAR]= "";
  221   short done,verbose= 0,compile= 0,eps_output= 0;
  222   short headline= 1,generate_crop_marks= 1;
  223   short infile_specified= 0,outfile_specified= 0,dvipsopts_specified= 0;
  224   float linethickness= DEFAULT_LINETHICKNESS;
  225   float clthick= DEFAULT_CROPLINETHICKNESS;
  226   float edgeseparation= DEFAULT_EDGESEPARATION;
  227   float facewidth,faceheight,spineheight,flapheight;
  228   float ifacewidth,ifaceheight,ispineheight,iflapheight;
  229   
  230   
  231   /*:14*/
  232   #line 440 "./dvlabel.w"
  233   
  234   /*15:*/
  235   #line 711 "./dvlabel.w"
  236   
  237   {
  238   progname= strip_away_path(argv[0]);
  239   no_arg= argc;
  240   while(--argc){
  241   if(!strcmp(argv[no_arg-argc],"-o")||
  242   !strcmp(argv[no_arg-argc],"--outputfile")){
  243   --argc;
  244   strcpy(outputfilename,argv[no_arg-argc]);
  245   outfile_specified= 1;
  246   }else if(!strcmp(argv[no_arg-argc],"-i")||
  247   !strcmp(argv[no_arg-argc],"--inputfile")){
  248   --argc;
  249   strcpy(inputfilename,argv[no_arg-argc]);
  250   infile_specified= 1;
  251   }else if(!strcmp(argv[no_arg-argc],"-v")||
  252   !strcmp(argv[no_arg-argc],"--verbose")){
  253   verbose= (verbose?0:1);
  254   }else if(!strcmp(argv[no_arg-argc],"-h")||
  255   !strcmp(argv[no_arg-argc],"--help")){
  256   showsomehelp();
  257   exit(SUCCESS);
  258   }else if(!strcmp(argv[no_arg-argc],"-H")||
  259   !strcmp(argv[no_arg-argc],"--headline")){
  260   headline= (headline?0:1);
  261   }else if(!strcmp(argv[no_arg-argc],"-C")||
  262   !strcmp(argv[no_arg-argc],"--cropmarks")){
  263   generate_crop_marks= (generate_crop_marks?0:1);
  264   }else if(!strcmp(argv[no_arg-argc],"-t")||
  265   !strcmp(argv[no_arg-argc],"--linethick")){
  266   --argc;
  267   if(!sscanf(argv[no_arg-argc],"%f",&linethickness)){
  268   log("Error in linethickness argument.");
  269   exit(1);
  270   }
  271   }else if(!strcmp(argv[no_arg-argc],"-s")||
  272   !strcmp(argv[no_arg-argc],"--edgeseparation")){
  273   --argc;
  274   if(!sscanf(argv[no_arg-argc],"%f",&edgeseparation)){
  275   log("Error in edgeseparation argument.");
  276   exit(1);
  277   }
  278   }else if(!strcmp(argv[no_arg-argc],"-c")||
  279   !strcmp(argv[no_arg-argc],"--compile")){
  280   compile= (compile?0:1);
  281   }else if(!strcmp(argv[no_arg-argc],"-e")||
  282   !strcmp(argv[no_arg-argc],"--eps")){
  283   eps_output= (eps_output?0:1);
  284   }else if(!strcmp(argv[no_arg-argc],"-d")||
  285   !strcmp(argv[no_arg-argc],"--dvipsopts")){
  286   --argc;
  287   strcpy(dvipsopts,argv[no_arg-argc]);
  288   dvipsopts_specified= 1;
  289   }else{
  290   log("Error: Unknown option '%s'.",argv[no_arg-argc]);
  291   showsomehelp();
  292   exit(FAILURE);
  293   }
  294   }
  295   if(verbose&&!outfile_specified){
  296   fprintf(stdout,
  297   "You have specified verbose mode without any specification of\n"
  298   "a file where to save the generated TeX source code. This means\n"
  299   "that any program comments that appear, due to the verbose mode,\n"
  300   "will be mixed with the source code. It is highly recommended that\n"
  301   "you either turn off verbose mode or specify a file where to save\n"
  302   "the generated output (using the -o or --outputfile option).\n");
  303   fprintf(stdout,
  304   "In order to make a clean output, the TeX code is separately\n"
  305   "enclosed in the blocks below.\n");
  306   }
  307   if(verbose&&dvipsopts_specified){
  308   fprintf(stdout,"Specified options for later use with DVIPS: ");
  309   fprintf(stdout,"%s\n",dvipsopts);
  310   }
  311   }
  312   
  313   /*:15*/
  314   #line 441 "./dvlabel.w"
  315   
  316   /*16:*/
  317   #line 790 "./dvlabel.w"
  318   
  319   {
  320   fprintf(stdout,"This is %s, Version %s\n",progname,VERSION);
  321   }
  322   
  323   /*:16*/
  324   #line 442 "./dvlabel.w"
  325   
  326   /*18:*/
  327   #line 808 "./dvlabel.w"
  328   
  329   {
  330   if(infile_specified){
  331   if((infile= fopen(inputfilename,"r"))==NULL){
  332   if((infile= fopen(strcat(inputfilename,".dvl"),"r"))==NULL){
  333   log("Could not open file %s for reading!",inputfilename);
  334   exit(FAILURE);
  335   }
  336   }
  337   fseek(infile,0L,SEEK_SET);
  338   if(verbose){
  339   log("Opened input file %s for reading.",inputfilename);
  340   }
  341   }else{
  342   if(verbose)
  343   log("No input filename specified (Entering interactive mode).");
  344   }
  345   }
  346   
  347   /*:18*/
  348   #line 443 "./dvlabel.w"
  349   
  350   /*19:*/
  351   #line 829 "./dvlabel.w"
  352   
  353   {
  354   if(outfile_specified){
  355   sprintf(tmpstr,"%s.tex",outputfilename);
  356   if((outfile= fopen(tmpstr,"w"))==NULL){
  357   log("Could not open file %s for writing!",tmpstr);
  358   exit(FAILURE);
  359   }
  360   fseek(outfile,0L,SEEK_SET);
  361   if(verbose){
  362   log("Opened output file %s for writing.",outputfilename);
  363   }
  364   }else{
  365   if(verbose){
  366   log("No output filename specified.");
  367   log("Will write generated TeX output to standard terminal output.");
  368   }
  369   }
  370   }
  371   
  372   /*:19*/
  373   #line 444 "./dvlabel.w"
  374   
  375   /*29:*/
  376   #line 1075 "./dvlabel.w"
  377   
  378   {
  379   facewidth= 190.6+3.0*72.27/25.4;
  380   faceheight= 133.7;
  381   spineheight= 35.6;
  382   flapheight= 41.3;
  383   ifacewidth= facewidth-14.0*linethickness;
  384   ifaceheight= faceheight-11.0*linethickness-0.5*edgeseparation;
  385   ispineheight= spineheight-8.0*linethickness-edgeseparation;
  386   iflapheight= flapheight-11.0*linethickness-0.5*edgeseparation;
  387   if(!outfile_specified)
  388   fprintf(OUTSTREAM,"%%-------- TEX CODE BEGINS HERE -----------------\n");
  389   fprintf(OUTSTREAM,"%% File: %s.tex\n",outputfilename);
  390   fprintf(OUTSTREAM,"%% TeX code generated by %s, v.%s, %s",
  391   progname,VERSION,ctime(&now));
  392   fprintf(OUTSTREAM,"%% Copyright (C) Fredrik Jonsson, 2003-2005\n%%\n");
  393   fprintf(OUTSTREAM,"\\hoffset=-35pt\\voffset=-25pt\n");
  394   fprintf(OUTSTREAM,"\\hsize=175mm\\vsize=254mm\n");
  395   fprintf(OUTSTREAM,"\\font\\eightcmssqeight=cmssq8\n");
  396   fprintf(OUTSTREAM,"\\font\\sevencmtt=cmtt7\n");
  397   fprintf(OUTSTREAM,"\\font\\tencmssqten=cmssq8 at 10 truept\n");
  398   fprintf(OUTSTREAM,"\\font\\deffacefont=cmr7\n");
  399   fprintf(OUTSTREAM,"\\font\\deftimestampfont=cmtt8 at 7 truept\n");
  400   fprintf(OUTSTREAM,"\\font\\defspinefont=cmr9\n");
  401   fprintf(OUTSTREAM,"\\font\\defflapfont=cmr7\n");
  402   fprintf(OUTSTREAM,"\\def\\monthname{\\ifcase\\month%%\n");
  403   fprintf(OUTSTREAM," \\or Jan\\or Feb\\or Mar\\or Apr\\or May\\or Jun%%\n");
  404   fprintf(OUTSTREAM," \\or Jul\\or Aug\\or Sep\\or Oct\\or Nov\\or Dec%%\n");
  405   fprintf(OUTSTREAM," \\fi}\n");
  406   fprintf(OUTSTREAM,"\\def\\fullmonthname{\\ifcase\\month%%\n");
  407   fprintf(OUTSTREAM," \\or January\\or February\\or March\\or April%%\n");
  408   fprintf(OUTSTREAM," \\or May\\or June\\or July\\or August\\or September\n");
  409   fprintf(OUTSTREAM," \\or October\\or November\\or December\\fi}\n");
  410   fprintf(OUTSTREAM,"\\def\\today{\\fullmonthname\\space\\number\\day,%%\n");
  411   fprintf(OUTSTREAM,"  \\space\\number\\year}\n");
  412   fprintf(OUTSTREAM,"\\def\\dvby{Digital Video by\\ }\n");
  413   fprintf(OUTSTREAM,"\\parindent 0pt\n");
  414   fprintf(OUTSTREAM,"\\newdimen\\facewidth\n");
  415   fprintf(OUTSTREAM,"\\newdimen\\faceheight\n");
  416   fprintf(OUTSTREAM,"\\newdimen\\spineheight\n");
  417   fprintf(OUTSTREAM,"\\newdimen\\flapheight\n");
  418   fprintf(OUTSTREAM,"\\newdimen\\linethick\n");
  419   fprintf(OUTSTREAM,"\\newdimen\\spacethick\n");
  420   fprintf(OUTSTREAM,"\\newdimen\\edgeseparation\n");
  421   fprintf(OUTSTREAM,"\\newdimen\\cropthick\n");
  422   fprintf(OUTSTREAM,"\\facewidth=%1.3fpt\n",facewidth);
  423   fprintf(OUTSTREAM,"\\faceheight=%1.3fpt\n",faceheight);
  424   fprintf(OUTSTREAM,"\\spineheight=%1.3fpt\n",spineheight);
  425   fprintf(OUTSTREAM,"\\flapheight=%1.3fpt\n",flapheight);
  426   fprintf(OUTSTREAM,"\\linethick=%1.3fpt\n",linethickness);
  427   fprintf(OUTSTREAM,"\\spacethick=%1.3fpt\n",2.0*linethickness);
  428   fprintf(OUTSTREAM,"\\edgeseparation=%1.3fpt\n",edgeseparation);
  429   fprintf(OUTSTREAM,"\\cropthick=%1.3fpt\n",clthick);
  430   if(headline){
  431   fprintf(OUTSTREAM,"\\headline={\\hfill{\\tt dvlabel output");
  432   fprintf(OUTSTREAM," %s",ctime(&now));
  433   fprintf(OUTSTREAM," [%s]}}\n",(infile_specified?inputfilename:"stdin"));
  434   fprintf(OUTSTREAM,"\\footline={\\hfill\\folio\\hfill}\n");
  435   }else{
  436   fprintf(OUTSTREAM,"\\headline={\\hfil}\n");
  437   fprintf(OUTSTREAM,"\\nopagenumbers\n");
  438   }
  439   fprintf(OUTSTREAM,"\\def\\boxit#1{\\vbox{\\hrule height\\linethick%%\n");
  440   fprintf(OUTSTREAM,"  \\hbox{\\vrule width\\linethick\\kern\\spacethick%%\n");
  441   fprintf(OUTSTREAM,"  \\vbox{\\kern\\spacethick#1\\kern\\spacethick}%%\n");
  442   fprintf(OUTSTREAM,"  \\kern\\spacethick\\vrule width\\linethick}%%\n");
  443   fprintf(OUTSTREAM,"  \\hrule height\\linethick}}%%\n");
  444   }
  445   
  446   /*:29*/
  447   #line 445 "./dvlabel.w"
  448   
  449   num_labels= 0;
  450   while(newlabel(INSTREAM)){
  451   num_labels++;
  452   /*22:*/
  453   #line 876 "./dvlabel.w"
  454   
  455   {
  456   /*23:*/
  457   #line 893 "./dvlabel.w"
  458   
  459   {
  460   fprintf(stdout,"Specify table of contents of the DV tape\n");
  461   fprintf(stdout,"[Enter text and finish with single dot on blank line]:\n");
  462   done= 0;
  463   n= 0;
  464   num_toc_lines= 0;
  465   while(!done){
  466   fprintf(stdout,"**");
  467   while((tmpch= fgetc(INSTREAM))==' ');
  468   ungetc(tmpch,INSTREAM);
  469   k= 0;
  470   while((tmpstr[k++]= fgetc(INSTREAM))!='\n');
  471   if(k> 1){
  472   if((tmpstr[0]=='.')&&(tmpstr[1]=='\n')){
  473   done= 1;
  474   }else{
  475   for(j= 0;j<k;j++)toc[n+j]= tmpstr[j];
  476   if(1==0)toc[n+j]= '\n';
  477   n= n+j;
  478   num_toc_lines++;
  479   }
  480   }else{
  481   toc[n]= '\n';
  482   }
  483   }
  484   if(verbose){
  485   fprintf(stdout,"%s: Counted %ld number of table-of-contents lines.\n",
  486   progname,num_toc_lines);
  487   fprintf(stdout,"Table of contents:\n");
  488   n= 0;
  489   for(k= 1;k<=num_toc_lines;k++){
  490   for(j= n;toc[j]!='\n';j++)fprintf(stdout,"%c",toc[j]);
  491   fprintf(stdout,"\n");
  492   n= j+1;
  493   }
  494   }
  495   }
  496   
  497   /*:23*/
  498   #line 878 "./dvlabel.w"
  499   
  500   /*24:*/
  501   #line 934 "./dvlabel.w"
  502   
  503   {
  504   fprintf(stdout,"Specify time stamp of DV tape. This is typically\n");
  505   fprintf(stdout,"the last date that appears as time stamp in the\n");
  506   fprintf(stdout,"recorded tape. [Press enter to use the current date]\n");
  507   fprintf(stdout,"**");
  508   while((tmpch= fgetc(INSTREAM))==' ');
  509   ungetc(tmpch,INSTREAM);
  510   k= 0;
  511   while((tmpstr[k++]= fgetc(INSTREAM))!='\n');
  512   if(k> 1)
  513   for(j= 0;j<k;j++)timestamp[j]= tmpstr[j];
  514   else
  515   for(j= 0;j<7;j++)timestamp[j]= "\\today\n"[j];
  516   if(verbose){
  517   fprintf(stdout,"Time stamp: ");
  518   for(j= 0;timestamp[j]!='\n';j++)fprintf(stdout,"%c",timestamp[j]);
  519   fprintf(stdout,"\n");
  520   }
  521   }
  522   
  523   /*:24*/
  524   #line 879 "./dvlabel.w"
  525   
  526   /*25:*/
  527   #line 957 "./dvlabel.w"
  528   
  529   {
  530   fprintf(stdout,
  531   "Specify title of the DV tape [Press enter to leave blank title]:\n");
  532   fprintf(stdout,"**");
  533   while((tmpch= fgetc(INSTREAM))==' ');
  534   ungetc(tmpch,INSTREAM);
  535   k= 0;
  536   while((tmpstr[k++]= fgetc(INSTREAM))!='\n');
  537   if(k> 1)
  538   for(j= 0;j<k;j++)title[j]= tmpstr[j];
  539   else
  540   title[0]= '\n';
  541   if(verbose){
  542   fprintf(stdout,"Title: ");
  543   for(j= 0;title[j]!='\n';j++)fprintf(stdout,"%c",title[j]);
  544   fprintf(stdout,"\n");
  545   }
  546   }
  547   
  548   /*:25*/
  549   #line 880 "./dvlabel.w"
  550   
  551   /*26:*/
  552   #line 979 "./dvlabel.w"
  553   
  554   {
  555   fprintf(stdout,
  556   "Specify author of the DV tape [Press enter to leave blank]:\n");
  557   fprintf(stdout,"**");
  558   while((tmpch= fgetc(INSTREAM))==' ');
  559   ungetc(tmpch,INSTREAM);
  560   k= 0;
  561   while((tmpstr[k++]= fgetc(INSTREAM))!='\n');
  562   if(k> 1)
  563   for(j= 0;j<k;j++)author[j]= tmpstr[j];
  564   else
  565   author[0]= '\n';
  566   if(verbose){
  567   fprintf(stdout,"Author: ");
  568   for(j= 0;author[j]!='\n';j++)fprintf(stdout,"%c",author[j]);
  569   fprintf(stdout,"\n");
  570   }
  571   }
  572   
  573   /*:26*/
  574   #line 881 "./dvlabel.w"
  575   
  576   /*27:*/
  577   #line 1006 "./dvlabel.w"
  578   
  579   {
  580   fprintf(stdout,"Specify address of author of the DV tape\n");
  581   fprintf(stdout,"[Enter text and finish with single dot on blank line]:\n");
  582   fprintf(stdout,"**");
  583   done= 0;
  584   n= 0;
  585   num_address_lines= 0;
  586   while(!done){
  587   while((tmpch= fgetc(INSTREAM))==' ');
  588   ungetc(tmpch,INSTREAM);
  589   k= 0;
  590   while((tmpstr[k++]= fgetc(INSTREAM))!='\n');
  591   if(k> 1){
  592   if((tmpstr[0]=='.')&&(tmpstr[1]=='\n')){
  593   done= 1;
  594   }else{
  595   for(j= 0;j<k;j++)address[n+j]= tmpstr[j];
  596   if(1==0)address[n+j]= '\n';
  597   n= n+j;
  598   num_address_lines++;
  599   }
  600   }else{
  601   address[n]= '\n';
  602   }
  603   fprintf(stdout,"**");
  604   }
  605   if(verbose){
  606   fprintf(stdout,"%s: Counted %ld address lines.\n",
  607   progname,num_address_lines);
  608   fprintf(stdout,"Address:\n");
  609   n= 0;
  610   for(k= 1;k<=num_address_lines;k++){
  611   for(j= n;address[j]!='\n';j++)fprintf(stdout,"%c",address[j]);
  612   fprintf(stdout,"\n");
  613   n= j+1;
  614   }
  615   }
  616   }
  617   
  618   /*:27*/
  619   #line 882 "./dvlabel.w"
  620   
  621   /*28:*/
  622   #line 1048 "./dvlabel.w"
  623   
  624   {
  625   fprintf(stdout,
  626   "Specify email of author of the DV tape [Press enter to leave blank]:\n");
  627   fprintf(stdout,"**");
  628   while((tmpch= fgetc(INSTREAM))==' ');
  629   ungetc(tmpch,INSTREAM);
  630   k= 0;
  631   while((tmpstr[k++]= fgetc(INSTREAM))!='\n');
  632   if(k> 1)
  633   for(j= 0;j<k;j++)email[j]= tmpstr[j];
  634   else
  635   email[0]= '\n';
  636   if(verbose){
  637   fprintf(stdout,"Email: ");
  638   for(j= 0;email[j]!='\n';j++)fprintf(stdout,"%c",email[j]);
  639   fprintf(stdout,"\n");
  640   }
  641   }
  642   
  643   /*:28*/
  644   #line 883 "./dvlabel.w"
  645   
  646   }
  647   
  648   /*:22*/
  649   #line 449 "./dvlabel.w"
  650   
  651   if(num_labels==1){
  652   if(generate_crop_marks){
  653   /*32:*/
  654   #line 1216 "./dvlabel.w"
  655   
  656   {
  657   fprintf(OUTSTREAM,"\\hskip %1.3fpt\\vrule height20pt width%1.3fpt%%\n",
  658   20.0-clthick/2.0,clthick);
  659   fprintf(OUTSTREAM,"\\hbox to%1.3fpt{\\hfil",facewidth-clthick);
  660   fprintf(OUTSTREAM,"$\\matrix{{%1.3f{\\rm\\ pt}/%1.3f{\\rm\\ mm}}"
  661   "\\cr{}\\cr}$\\hfil}%%\n",facewidth,facewidth*(25.4/72.27));
  662   fprintf(OUTSTREAM,"\\vrule height20pt width%1.3fpt%%\n",clthick);
  663   fprintf(OUTSTREAM,"\\hbox to %1.3fpt{\\hfil",facewidth-clthick);
  664   fprintf(OUTSTREAM,"$\\matrix{{%1.3f{\\rm\\ pt}/%1.3f{\\rm\\ mm}}"
  665   "\\cr{}\\cr}$\\hfil}%%\n",facewidth,facewidth*(25.4/72.27));
  666   fprintf(OUTSTREAM,"\\vrule height20pt width%1.3fpt\\par\\nointerlineskip\n",
  667   clthick);
  668   }
  669   
  670   /*:32*/
  671   #line 452 "./dvlabel.w"
  672   
  673   /*33:*/
  674   #line 1235 "./dvlabel.w"
  675   
  676   {
  677   fprintf(OUTSTREAM,"\\vskip\\linethick\n");
  678   fprintf(OUTSTREAM,"\\vrule height%1.3fpt width20pt",clthick);
  679   fprintf(OUTSTREAM,"\\hskip %1.3fpt",2.0*facewidth);
  680   fprintf(OUTSTREAM,"\\vrule height%1.3fpt width20pt\\par\\nointerlineskip\n",
  681   clthick);
  682   fprintf(OUTSTREAM,"\\vskip\\linethick\n");
  683   }
  684   
  685   /*:33*/
  686   #line 453 "./dvlabel.w"
  687   
  688   }
  689   }
  690   /*30:*/
  691   #line 1146 "./dvlabel.w"
  692   
  693   {
  694   fprintf(OUTSTREAM,"\\def\\timestamp{");
  695   for(j= 0;timestamp[j]!='\n';j++)fprintf(OUTSTREAM,"%c",timestamp[j]);
  696   fprintf(OUTSTREAM,"}%%\n");
  697   fprintf(OUTSTREAM,"\\def\\title{");
  698   for(j= 0;title[j]!='\n';j++)fprintf(OUTSTREAM,"%c",title[j]);
  699   fprintf(OUTSTREAM,"}%%\n");
  700   fprintf(OUTSTREAM,"\\def\\author{");
  701   for(j= 0;author[j]!='\n';j++)fprintf(OUTSTREAM,"%c",author[j]);
  702   fprintf(OUTSTREAM,"}%%\n");
  703   fprintf(OUTSTREAM,"\\def\\email{");
  704   for(j= 0;email[j]!='\n';j++)fprintf(OUTSTREAM,"%c",email[j]);
  705   fprintf(OUTSTREAM,"}%%\n");
  706   fprintf(OUTSTREAM,"%% Define the outline of the face of the label\n");
  707   fprintf(OUTSTREAM,"\\setbox1=\\hbox to %1.3fpt{{%%\n",ifacewidth);
  708   fprintf(OUTSTREAM,"  \\vbox to \\faceheight{%%\n");
  709   fprintf(OUTSTREAM,"    \\hbox{\\deffacefont\\timestamp\\hfil}%%\n");
  710   n= 0;
  711   for(k= 1;k<=num_toc_lines;k++){
  712   fprintf(OUTSTREAM,"    \\vskip -3pt\\hbox{\\deffacefont ");
  713   for(j= n;toc[j]!='\n';j++)fprintf(OUTSTREAM,"%c",toc[j]);
  714   fprintf(OUTSTREAM,"\\hfil}%%\n");
  715   n= j+1;
  716   }
  717   fprintf(OUTSTREAM,"  \\vfil}}\\hfil}%%\n");
  718   fprintf(OUTSTREAM,"%% Define the outline of the spine of the label\n");
  719   fprintf(OUTSTREAM,"\\setbox2=\\hbox to %1.3fpt{{%%\n",ifacewidth);
  720   fprintf(OUTSTREAM,"  \\vbox to %1.3fpt{%%\n",ispineheight);
  721   fprintf(OUTSTREAM,"    \\hbox{\\deftimestampfont\\timestamp\\hfil}%%\n");
  722   fprintf(OUTSTREAM,"    \\hbox{\\defspinefont\\title\\hfil}%%\n");
  723   fprintf(OUTSTREAM,"  \\vfil}}\\hfil}%%\n");
  724   fprintf(OUTSTREAM,"%% Define the outline of the flap of the label\n");
  725   fprintf(OUTSTREAM,"\\setbox3=\\hbox to %1.3fpt{{%%\n",ifacewidth);
  726   fprintf(OUTSTREAM,"  \\vbox to %1.3fpt{%%\n",iflapheight);
  727   fprintf(OUTSTREAM,"    \\hbox{\\defflapfont\\dvby\\author\\hfil}%%\n");
  728   n= 0;
  729   for(k= 1;k<=num_address_lines;k++){
  730   fprintf(OUTSTREAM,"    \\vskip -3pt\\hbox{\\defflapfont ");
  731   for(j= n;address[j]!='\n';j++)fprintf(OUTSTREAM,"%c",address[j]);
  732   fprintf(OUTSTREAM,"\\hfil}\n");
  733   n= j+1;
  734   }
  735   fprintf(OUTSTREAM,"    \\vskip -3pt\\hbox{\\defflapfont\\email\\hfil}%%\n");
  736   fprintf(OUTSTREAM,"  \\vfil}}\\hfil}%%\n");
  737   fprintf(OUTSTREAM,"\\def\\dvlabel{\\hskip\\linethick\\boxit{%%\n");
  738   fprintf(OUTSTREAM,"  \\boxit{\\box1}\\vskip\\edgeseparation%%\n");
  739   fprintf(OUTSTREAM,"  \\boxit{\\box2}\\vskip\\edgeseparation%%\n");
  740   fprintf(OUTSTREAM,"  \\boxit{\\box3}}\\hskip\\linethick}%%\n");
  741   if((num_labels==1)||(num_labels==3))fprintf(OUTSTREAM,"\\hskip %1.3fpt",
  742   (20.0));
  743   fprintf(OUTSTREAM,"\\dvlabel\n");
  744   if((num_labels==2)||(num_labels==4)||(num_labels==6)){
  745   fprintf(OUTSTREAM,"\\par\\nointerlineskip\n");
  746   }
  747   }
  748   
  749   /*:30*/
  750   #line 456 "./dvlabel.w"
  751   
  752   if(num_labels==2){
  753   if(generate_crop_marks){
  754   /*33:*/
  755   #line 1235 "./dvlabel.w"
  756   
  757   {
  758   fprintf(OUTSTREAM,"\\vskip\\linethick\n");
  759   fprintf(OUTSTREAM,"\\vrule height%1.3fpt width20pt",clthick);
  760   fprintf(OUTSTREAM,"\\hskip %1.3fpt",2.0*facewidth);
  761   fprintf(OUTSTREAM,"\\vrule height%1.3fpt width20pt\\par\\nointerlineskip\n",
  762   clthick);
  763   fprintf(OUTSTREAM,"\\vskip\\linethick\n");
  764   }
  765   
  766   /*:33*/
  767   #line 459 "./dvlabel.w"
  768   
  769   }
  770   }
  771   if(num_labels==num_labels_per_page){
  772   if(generate_crop_marks){
  773   /*33:*/
  774   #line 1235 "./dvlabel.w"
  775   
  776   {
  777   fprintf(OUTSTREAM,"\\vskip\\linethick\n");
  778   fprintf(OUTSTREAM,"\\vrule height%1.3fpt width20pt",clthick);
  779   fprintf(OUTSTREAM,"\\hskip %1.3fpt",2.0*facewidth);
  780   fprintf(OUTSTREAM,"\\vrule height%1.3fpt width20pt\\par\\nointerlineskip\n",
  781   clthick);
  782   fprintf(OUTSTREAM,"\\vskip\\linethick\n");
  783   }
  784   
  785   /*:33*/
  786   #line 464 "./dvlabel.w"
  787   
  788   /*32:*/
  789   #line 1216 "./dvlabel.w"
  790   
  791   {
  792   fprintf(OUTSTREAM,"\\hskip %1.3fpt\\vrule height20pt width%1.3fpt%%\n",
  793   20.0-clthick/2.0,clthick);
  794   fprintf(OUTSTREAM,"\\hbox to%1.3fpt{\\hfil",facewidth-clthick);
  795   fprintf(OUTSTREAM,"$\\matrix{{%1.3f{\\rm\\ pt}/%1.3f{\\rm\\ mm}}"
  796   "\\cr{}\\cr}$\\hfil}%%\n",facewidth,facewidth*(25.4/72.27));
  797   fprintf(OUTSTREAM,"\\vrule height20pt width%1.3fpt%%\n",clthick);
  798   fprintf(OUTSTREAM,"\\hbox to %1.3fpt{\\hfil",facewidth-clthick);
  799   fprintf(OUTSTREAM,"$\\matrix{{%1.3f{\\rm\\ pt}/%1.3f{\\rm\\ mm}}"
  800   "\\cr{}\\cr}$\\hfil}%%\n",facewidth,facewidth*(25.4/72.27));
  801   fprintf(OUTSTREAM,"\\vrule height20pt width%1.3fpt\\par\\nointerlineskip\n",
  802   clthick);
  803   }
  804   
  805   /*:32*/
  806   #line 465 "./dvlabel.w"
  807   
  808   }
  809   /*31:*/
  810   #line 1207 "./dvlabel.w"
  811   
  812   {
  813   fprintf(OUTSTREAM,"\\vfill\\eject\n");
  814   }
  815   
  816   /*:31*/
  817   #line 467 "./dvlabel.w"
  818   
  819   num_labels= 0;
  820   }
  821   }
  822   /*34:*/
  823   #line 1247 "./dvlabel.w"
  824   
  825   {
  826   if((num_labels!=2)&&(num_labels!=4)){
  827   fprintf(OUTSTREAM,"\\par\\nointerlineskip\n");
  828   }
  829   if(num_labels!=num_labels_per_page){
  830   if(num_labels!=0){
  831   if(generate_crop_marks){
  832   /*33:*/
  833   #line 1235 "./dvlabel.w"
  834   
  835   {
  836   fprintf(OUTSTREAM,"\\vskip\\linethick\n");
  837   fprintf(OUTSTREAM,"\\vrule height%1.3fpt width20pt",clthick);
  838   fprintf(OUTSTREAM,"\\hskip %1.3fpt",2.0*facewidth);
  839   fprintf(OUTSTREAM,"\\vrule height%1.3fpt width20pt\\par\\nointerlineskip\n",
  840   clthick);
  841   fprintf(OUTSTREAM,"\\vskip\\linethick\n");
  842   }
  843   
  844   /*:33*/
  845   #line 1255 "./dvlabel.w"
  846   
  847   /*32:*/
  848   #line 1216 "./dvlabel.w"
  849   
  850   {
  851   fprintf(OUTSTREAM,"\\hskip %1.3fpt\\vrule height20pt width%1.3fpt%%\n",
  852   20.0-clthick/2.0,clthick);
  853   fprintf(OUTSTREAM,"\\hbox to%1.3fpt{\\hfil",facewidth-clthick);
  854   fprintf(OUTSTREAM,"$\\matrix{{%1.3f{\\rm\\ pt}/%1.3f{\\rm\\ mm}}"
  855   "\\cr{}\\cr}$\\hfil}%%\n",facewidth,facewidth*(25.4/72.27));
  856   fprintf(OUTSTREAM,"\\vrule height20pt width%1.3fpt%%\n",clthick);
  857   fprintf(OUTSTREAM,"\\hbox to %1.3fpt{\\hfil",facewidth-clthick);
  858   fprintf(OUTSTREAM,"$\\matrix{{%1.3f{\\rm\\ pt}/%1.3f{\\rm\\ mm}}"
  859   "\\cr{}\\cr}$\\hfil}%%\n",facewidth,facewidth*(25.4/72.27));
  860   fprintf(OUTSTREAM,"\\vrule height20pt width%1.3fpt\\par\\nointerlineskip\n",
  861   clthick);
  862   }
  863   
  864   /*:32*/
  865   #line 1256 "./dvlabel.w"
  866   
  867   }
  868   }
  869   /*31:*/
  870   #line 1207 "./dvlabel.w"
  871   
  872   {
  873   fprintf(OUTSTREAM,"\\vfill\\eject\n");
  874   }
  875   
  876   /*:31*/
  877   #line 1259 "./dvlabel.w"
  878   
  879   }
  880   fprintf(OUTSTREAM,"\\bye\n");
  881   if(!outfile_specified)
  882   fprintf(OUTSTREAM,"%%-------- TEX CODE ENDS HERE -----------------\n");
  883   }
  884   
  885   /*:34*/
  886   #line 471 "./dvlabel.w"
  887   
  888   /*20:*/
  889   #line 851 "./dvlabel.w"
  890   
  891   {
  892   if(infile_specified)fclose(infile);
  893   if(outfile_specified)fclose(outfile);
  894   }
  895   
  896   /*:20*/
  897   #line 472 "./dvlabel.w"
  898   
  899   /*35:*/
  900   #line 1278 "./dvlabel.w"
  901   
  902   {
  903   if(compile){
  904   if(verbose){
  905   fprintf(stdout,"%s: Compiling the TeX source code into PostScript.\n",
  906   progname);
  907   }
  908   if(outfile_specified){
  909   if(eps_output){
  910   sprintf(tmpstr,"tex %s; dvips %s %s -E -o %s.eps",
  911   outputfilename,dvipsopts,outputfilename,outputfilename);
  912   }else{
  913   sprintf(tmpstr,"tex %s; dvips %s %s -o %s.ps",
  914   outputfilename,dvipsopts,outputfilename,outputfilename);
  915   }
  916   system(tmpstr);
  917   }else{
  918   fprintf(stdout,"Compiling terminal output: Not implemented yet.\n");
  919   exit(FAILURE);
  920   }
  921   }
  922   }
  923   
  924   /*:35*/
  925   #line 473 "./dvlabel.w"
  926   
  927   return(SUCCESS);
  928   }
  929   
  930   /*:5*/
  931   

Return to previous page

Generated by ::viewsrc::

Last modified Wednesday 15 Feb 2023