"Fossies" - the Fresh Open Source Software Archive

Member "cposthdr.org" (9 May 1995, 15390 Bytes) of package /linux/misc/old/cpost.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Emacs Org-Mode source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 /*------------------------------------------------------------------
    2  * cposthdr.h : default postscript header for cPost output
    3  *------------------------------------------------------------------
    4  * 02-01-93 originally by Patrick J. Mueller
    5  *------------------------------------------------------------------*/
    6 
    7 static char *Header_1[] =
    8    {
    9    "%%-----------------------------------------------------------------",
   10    "%% font names and sizes",
   11    "%%-----------------------------------------------------------------",
   12    "",
   13    "/Inch { 72    mul } def",
   14    "/Cm   { 28.35 mul } def",
   15    "/Mm   { 2.835 mul } def",
   16    "",
   17    "/nFontName /Courier              def % font name for normal text",
   18    "/kFontName /Times-BoldItalic     def % font name for keywords",
   19    "/iFontName /Courier              def % font name for identifiers",
   20    "/fFontName /Times-Bold           def % font name for functions",
   21    "/dFontName /Times-Bold           def % font name for function definitions",
   22    "/cFontName /Courier-Oblique      def % font name for comments",
   23    "/pFontName /Helvetica            def % font name for preprocessor",
   24    "/lFontName /Courier              def % font name for line numbers",
   25    "",
   26    "/nFontSize  8                    def % font size for normal text",
   27    "/kFontSize  8                    def % font size for keywords",
   28    "/iFontSize  8                    def % font size for identifiers",
   29    "/fFontSize 11                    def % font size for functions",
   30    "/dFontSize 11                    def % font size for function definitions",
   31    "/cFontSize  8                    def % font size for comments",
   32    "/pFontSize 11                    def % font size for preprocessor",
   33    "/lFontSize  7                    def % font size for line numbers",
   34    "",
   35    "%%-----------------------------------------------------------------",
   36    "%% colors",
   37    "%%-----------------------------------------------------------------",
   38    "/nColor [ 0 0 0 ]                def % color for normal text",
   39    "/kColor [ 0 0 0 ]                def % color for keywords",
   40    "/iColor [ 0 0 0 ]                def % color for identifiers",
   41    "/fColor [ 0 0 0 ]                def % color for functions",
   42    "/dColor [ 0 0 0 ]                def % color for function definitions",
   43    "/cColor [ 0 0 0 ]                def % color for comments",
   44    "/pColor [ 0 0 0 ]                def % color for preprocessor",
   45    "/lColor [ 0 0 0 ]                def % color for line numbers",
   46    "",
   47    "",
   48    "%%------------------------------------------------------------------",
   49    "%% page size, margin size",
   50    "%%------------------------------------------------------------------",
   51    "/pLength   11     Inch           def % page length",
   52    "/pWidth     8.5   Inch           def % page width",
   53    "",
   54    "/lMargin     .5   Inch           def % margin: left",
   55    "/rMargin     .5   Inch           def % margin: right",
   56    "/tMargin     .75  Inch           def % margin: top",
   57    "/bMargin     .75  Inch           def % margin: bottom",
   58    "",
   59    "%%------------------------------------------------------------------",
   60    "%% header (and footer) info",
   61    "%%------------------------------------------------------------------",
   62    "/yh1 pLength .65 Inch sub def",
   63    "/yh2 pLength .5  Inch sub def",
   64    "/yh3 .65  Inch def",
   65    "/yh4 .45  Inch def",
   66    "",
   67    "%%------------------------------------------------------------------",
   68    "%% print a header and footer for odd numbered pages",
   69    "%%------------------------------------------------------------------",
   70    "/header1",
   71    "   {",
   72    "   lColor aload pop setrgbcolor",
   73    "   newpath",
   74    "      lMargin            yh1 moveto",
   75    "      pWidth rMargin sub yh1 lineto",
   76    "   stroke",
   77    "",
   78    "   /Times-Roman findfont 14 scalefont setfont",
   79    "",
   80    "   lMargin yh2 moveto",
   81    "   currFunc show",
   82    "",
   83    "   /numberBuffer 10 string def",
   84    "   pWidth rMargin                           sub",
   85    "   pageNum numberBuffer cvs stringwidth pop sub",
   86    "   (page ) stringwidth pop                  sub",
   87    "   yh2 moveto",
   88    "   (page ) show numberBuffer show",
   89    "",
   90    "   newpath",
   91    "      lMargin yh3 moveto",
   92    "      pWidth rMargin sub yh3 lineto",
   93    "   stroke",
   94    "",
   95    "   /Helvetica findfont 7 scalefont setfont",
   96    "",
   97    "   lMargin yh4 moveto",
   98    "   (Print date: ) show",
   99    "   printDate show",
  100    "",
  101    "   lMargin 2 Inch add yh4 moveto",
  102    "   (File date: ) show",
  103    "   fileDateTime show",
  104    "",
  105    "   /Times-Roman findfont 14 scalefont setfont",
  106    "",
  107    "   pWidth rMargin           sub",
  108    "   fileName stringwidth pop sub",
  109    "",
  110    "   yh4 moveto",
  111    "   fileName show",
  112    "   }",
  113    "   def",
  114    "",
  115    "%%------------------------------------------------------------------",
  116    "%% print a header and footer for even numbered pages",
  117    "%%------------------------------------------------------------------",
  118    "/header2",
  119    "   {",
  120    "   lColor aload pop setrgbcolor",
  121    "   newpath",
  122    "      lMargin            yh1 moveto",
  123    "      pWidth rMargin sub yh1 lineto",
  124    "   stroke",
  125    "",
  126    "   /Times-Roman findfont 14 scalefont setfont",
  127    "",
  128    "   pWidth rMargin           sub",
  129    "   currFunc stringwidth pop sub",
  130    "   yh2 moveto",
  131    "   currFunc show",
  132    "",
  133    "   /numberBuffer 10 string def",
  134    "   pageNum numberBuffer cvs pop",
  135    "   lMargin yh2 moveto",
  136    "   (page ) show numberBuffer show",
  137    "",
  138    "   newpath",
  139    "      lMargin yh3 moveto",
  140    "      pWidth rMargin sub yh3 lineto",
  141    "   stroke",
  142    "",
  143    "   /Helvetica findfont 7 scalefont setfont",
  144    "",
  145    "   4 Inch yh4 moveto",
  146    "   (Print date: ) show",
  147    "   printDate show",
  148    "",
  149    "   6 Inch yh4 moveto",
  150    "   (File date: ) show",
  151    "   fileDateTime show",
  152    "",
  153    "   /Times-Roman findfont 14 scalefont setfont",
  154    "",
  155    "   lMargin yh4 moveto",
  156    "   fileName show",
  157    "   }",
  158    "   def",
  159    "",
  160    "%%------------------------------------------------------------------",
  161    "%% user defined from imbed file",
  162    "%%------------------------------------------------------------------",
  163    "",
  164    };
  165 
  166 static char *Header_2[] =
  167    {
  168    "",
  169    "%%------------------------------------------------------------------",
  170    "%% define actual header procs to use",
  171    "%%------------------------------------------------------------------",
  172    "/Header1 { header1 } def",
  173    "/Header2 { oDuplex { header2 } { header1 } ifelse } def",
  174    "",
  175    "%%------------------------------------------------------------------",
  176    "%% define our fonts to shorter names",
  177    "%%------------------------------------------------------------------",
  178    "/nFont nFontName findfont nFontSize scalefont def",
  179    "/kFont kFontName findfont kFontSize scalefont def",
  180    "/iFont iFontName findfont iFontSize scalefont def",
  181    "/fFont fFontName findfont fFontSize scalefont def",
  182    "/dFont dFontName findfont dFontSize scalefont def",
  183    "/cFont cFontName findfont cFontSize scalefont def",
  184    "/pFont pFontName findfont pFontSize scalefont def",
  185    "/lFont lFontName findfont lFontSize scalefont def",
  186    "",
  187    "%%------------------------------------------------------------------",
  188    "%% define our fonts to REAL short names",
  189    "%%------------------------------------------------------------------",
  190    "/n { nColor nFont nFontSize } def",
  191    "/k { kColor kFont kFontSize } def",
  192    "/i { iColor iFont iFontSize } def",
  193    "/f { fColor fFont fFontSize } def",
  194    "/d { dColor dFont dFontSize } def",
  195    "/c { cColor cFont cFontSize } def",
  196    "/p { pColor pFont pFontSize } def",
  197    "/l { lColor lFont lFontSize } def",
  198    "",
  199    "%%-----------------------------------------------------------------",
  200    "%% max function",
  201    "%%-----------------------------------------------------------------",
  202    "/max",
  203    "   {",
  204    "   2 copy",
  205    "   lt { exch } if",
  206    "   pop",
  207    "   } def",
  208    "",
  209    "%%-----------------------------------------------------------------",
  210    "%% maximum line height",
  211    "%%-----------------------------------------------------------------",
  212    "/maxLineHeight",
  213    "   nFontSize",
  214    "   kFontSize max",
  215    "   iFontSize max",
  216    "   fFontSize max",
  217    "   dFontSize max",
  218    "   cFontSize max",
  219    "   pFontSize max",
  220    "   lFontSize max",
  221    "   def",
  222    "",
  223    "%%------------------------------------------------------------------",
  224    "%% see if x lines will fit on the page",
  225    "%%------------------------------------------------------------------",
  226    "/linesFit",
  227    "   {",
  228    "   maxLineHeight mul currY exch sub bMargin sub",
  229    "   0 lt",
  230    "   { showPage } if",
  231    "   } def",
  232    "",
  233    "%%-----------------------------------------------------------------",
  234    "%% print stack",
  235    "%%-----------------------------------------------------------------",
  236    "/Stack",
  237    "   {",
  238    "   (°°°°°°°°°°°°°°°°°°°°stack°°°°°°°°(bottom->top)°°°°°°°°) print <0D0A> print",
  239    "   pstack",
  240    "   } def",
  241    "",
  242    "%%------------------------------------------------------------------",
  243    "%% width of one space in normal font",
  244    "%%------------------------------------------------------------------",
  245    "/spaceWidth",
  246    "   nFont setfont ( ) stringwidth pop",
  247    "   def",
  248    "",
  249    "%%------------------------------------------------------------------",
  250    "%% width of line number information",
  251    "%%------------------------------------------------------------------",
  252    "/lineNoWidth",
  253    "   oNumber",
  254    "      { lFont setfont (12345678) stringwidth pop }",
  255    "      { 0 }",
  256    "      ifelse",
  257    "   def",
  258    "",
  259    "%%------------------------------------------------------------------",
  260    "%% take a column, return an X offset from left margin",
  261    "%%------------------------------------------------------------------",
  262    "/getXfromCol",
  263    "   {",
  264    "   spaceWidth mul                % size of column number of spaces",
  265    "   lMargin  lineNoWidth add add  % left margin and size of line no info",
  266    "   spaceWidth oSpace mul add     % add spaces",
  267    "   } def",
  268    "",
  269    "%%------------------------------------------------------------------",
  270    "%% given the text/font array from showLine, calculate line height",
  271    "%%------------------------------------------------------------------",
  272    "/calcLineHeight",
  273    "   {",
  274    "   /lineHeight lFontSize def",
  275    "",
  276    "   lineArray aload",
  277    "",
  278    "   length 4 idiv",
  279    "      {",
  280    "      pop",
  281    "      pop",
  282    "",
  283    "      dup",
  284    "      lineHeight gt",
  285    "         {",
  286    "         /lineHeight exch def",
  287    "         }",
  288    "         {",
  289    "         pop",
  290    "         } ifelse",
  291    "",
  292    "      pop",
  293    "      } repeat",
  294    "",
  295    "   } def",
  296    "",
  297    "%%------------------------------------------------------------------",
  298    "%% reverse contents of an array",
  299    "%%------------------------------------------------------------------",
  300    "/reverseLineArray",
  301    "   {",
  302    "",
  303    "   /Ind1 0                 def",
  304    "   /Ind2 numElements 1 sub def",
  305    "",
  306    "   numElements 2 idiv",
  307    "      {",
  308    "      /Item1 lineArray Ind1 get def",
  309    "      /Item2 lineArray Ind2 get def",
  310    "",
  311    "      lineArray Ind1 Item2 put",
  312    "      lineArray Ind2 Item1 put",
  313    "",
  314    "      /Ind1 Ind1 1 add def",
  315    "      /Ind2 Ind2 1 sub def",
  316    "      } repeat",
  317    "",
  318    "   } def",
  319    "",
  320    "%%------------------------------------------------------------------",
  321    "%% given an array of text/font info, print it",
  322    "%%------------------------------------------------------------------",
  323    "/showLine",
  324    "   {",
  325    "   /lineArray exch def",
  326    "   /numElements lineArray length def",
  327    "",
  328    "   reverseLineArray",
  329    "",
  330    "   calcLineHeight",
  331    "",
  332    "   currY lineHeight sub bMargin le",
  333    "      {",
  334    "      showPage",
  335    "      } if",
  336    "",
  337    "   /currY currY lineHeight sub def",
  338    "",
  339    "",
  340    "   oNumber",
  341    "      {",
  342    "      lColor aload pop setrgbcolor",
  343    "      lMargin currY moveto",
  344    "",
  345    "      lFont setfont",
  346    "",
  347    "      /numberBuffer 8 string def",
  348    "      lineNum numberBuffer cvs stringwidth pop",
  349    "      lineNoWidth exch sub 0 rmoveto",
  350    "",
  351    "      numberBuffer show",
  352    "      } if",
  353    "",
  354    "   0 getXfromCol currY moveto",
  355    "",
  356    "   lineArray aload pop",
  357    "",
  358    "   numElements 4 idiv",
  359    "     {",
  360    "     aload pop setrgbcolor",
  361    "     setfont",
  362    "     pop",
  363    "     show",
  364    "     } repeat",
  365    "",
  366    "   /lineNum lineNum 1 add def",
  367    "",
  368    "   } def",
  369    "",
  370    "%%------------------------------------------------------------------",
  371    "%% end of page reached",
  372    "%%------------------------------------------------------------------",
  373    "/showPage",
  374    "   {",
  375    "   pageNum 2 mod 1 eq { Header1 } { Header2 } ifelse",
  376    "   showpage",
  377    "   oXlate",
  378    "   /pageNum pageNum 1 add def",
  379    "   /currY pLength tMargin sub def",
  380    "   } def",
  381    "",
  382    "%%------------------------------------------------------------------",
  383    "%% start a new source file",
  384    "%%------------------------------------------------------------------",
  385    "/startFile",
  386    "   {",
  387    "   /fileDateTime exch def",
  388    "   /fileName     exch def",
  389    "   /pageNum         1 def",
  390    "   /lineNum         1 def",
  391    "   /currFunc       () def",
  392    "   /currY     pLength tMargin sub def",
  393    "   oXlate",
  394    "   } def",
  395    "",
  396    "%%------------------------------------------------------------------",
  397    "%% end a source file",
  398    "%%------------------------------------------------------------------",
  399    "/endFile",
  400    "   {",
  401    "   oDuplex { pageNum 2 mod 1 eq { showPage } if } if",
  402    "   showPage",
  403    "   } def",
  404    "",
  405    "%%------------------------------------------------------------------",
  406    "%% middle bracket",
  407    "%%------------------------------------------------------------------",
  408    "/mB",
  409    "   {",
  410    "   1 sub getXfromCol /currX exch def",
  411    "   gsave",
  412    "   newpath",
  413    "",
  414    "   currX currY moveto",
  415    "   0 lineHeight rlineto",
  416    "",
  417    "   .2 setlinewidth",
  418    "   stroke",
  419    "   grestore",
  420    "   } def",
  421    "",
  422    "%%------------------------------------------------------------------",
  423    "%% upper bracket",
  424    "%%------------------------------------------------------------------",
  425    "/uB",
  426    "   {",
  427    "   1 sub getXfromCol /currX exch def",
  428    "   gsave",
  429    "   newpath",
  430    "",
  431    "   currX currY moveto",
  432    "",
  433    "   currX                currY lineHeight .4 mul add",
  434    "   currX spaceWidth add currY lineHeight .4 mul add",
  435    "   spaceWidth 2 div arcto 4 { pop } repeat",
  436    "",
  437    "   .2 setlinewidth",
  438    "   stroke",
  439    "   grestore",
  440    "   } def",
  441    "",
  442    "%%------------------------------------------------------------------",
  443    "%% lower bracket",
  444    "%%------------------------------------------------------------------",
  445    "/lB",
  446    "   {",
  447    "   1 sub getXfromCol /currX exch def",
  448    "   gsave",
  449    "   newpath",
  450    "",
  451    "   currX currY lineHeight add moveto",
  452    "",
  453    "   currX                currY lineHeight .4 mul add",
  454    "   currX spaceWidth add currY lineHeight .4 mul add",
  455    "   spaceWidth 2 div arcto 4 { pop } repeat",
  456    "",
  457    "   .2 setlinewidth",
  458    "   stroke",
  459    "   grestore",
  460    "   } def",
  461    "",
  462    "%%-----------------------------------------------------------------",
  463    "%% now the actual file data",
  464    "%%-----------------------------------------------------------------",
  465    };