113 #include <sys/types.h>
114 #include <sys/stat.h>
124 #include <sys/timeb.h>
126 #include <sys/utsname.h>
131 #include <sys/time.h>
154 #define EXIT_SUCCESS 0
157 #define EXIT_FAILURE 1
164 #define VERSION "4.3"
197 #define LPR_COMMAND "lpr"
204 #if defined(ONESIDED) && defined(TWOSIDED)
205 #define RECTO_VERSO_PRINTING
206 #ifndef TWOSIDED_DFLT
207 #define TWOSIDED_DFLT TRUE
217 #define PORTRAIT_HEADER 0.29
218 #define LANDSCAPE_HEADER 0.22
219 #define PIXELS_INCH 72
220 #define MAXFILENAME 32
221 #define MAX_LINES 320 // max. lines per page
222 #define MAN_LINES 66 // no lines for a man
223 #define IS_ROMAN 0 // normal font
224 #define IS_BOLD 1 // bold sequence flag
225 #if defined(SYSV) || defined(BSD)
226 #define MAX_HOSTNAME 40
252 #if defined(SYSV) || defined(BSD)
280 #if defined(SYSV) || defined(BSD)
285 #ifdef RECTO_VERSO_PRINTING
286 int rectoverso = TWOSIDED_DFLT;
327 #if defined(SYSV) || defined(BSD)
349 fprintf(stderr,
"A2ps v%s usage: %s [pos. or global options] [ f1 [ [pos. options] f2 ...] ]\n",
VERSION, command);
350 fprintf(stderr,
"pos. = -#num\t\tnumber of copies to print\n");
351 fprintf(stderr,
" -1\t\tone page per sheet\n");
352 fprintf(stderr,
" -2\t\tTWIN PAGES per sheet\n");
353 fprintf(stderr,
" -d\t-nd\tprint (DON'T PRINT) current date at the bottom\n");
354 fprintf(stderr,
" -Fnum\t\tfont size, num is a float number\n");
355 fprintf(stderr,
" -Hstr\t\tuse str like header title for subsequent files\n");
356 #if defined(SYSV) || defined(BSD)
357 fprintf(stderr,
" \t-nL\tdon't print login ID on top of page\n");
359 fprintf(stderr,
" -l\t\tprint in LANDSCAPE mode\n");
360 fprintf(stderr,
" -lnum\t\tuse num lines per page\n");
361 fprintf(stderr,
" -m\t\tprocess the file as a man\n");
362 fprintf(stderr,
" -n\t-nn\tNUMBER (don't number) line files\n");
363 fprintf(stderr,
" -p\t\tprint in portrait mode\n");
364 fprintf(stderr,
" -q\t\tprint in quiet mode (no summary)\n");
365 fprintf(stderr,
" -s\t-ns\tPRINT (don't print) surrounding borders\n");
366 fprintf(stderr,
"\n");
367 fprintf(stderr,
"global = -?\t\tprint this information\n");
368 fprintf(stderr,
" -B\t-nB\tprint (DON'T PRINT) in bold font\n");
369 fprintf(stderr,
" -b\t-nb\tforce (DON'T FORCE) binary printing\n");
370 fprintf(stderr,
" -c\t-nc\tallow (DON'T ALLOW) two files on the same sheet\n");
371 fprintf(stderr,
" -f\t-nf\tFOLD (don't fold) lines\n");
372 fprintf(stderr,
" \t-nH\tdon't print any header\n");
373 fprintf(stderr,
" -h\t\tprint this information\n");
374 fprintf(stderr,
" -Ifile\tinclude this file as a2ps prologue\n");
375 fprintf(stderr,
" -i\t-ni\tINTERPRET (don't interpret) tab, bs and ff chars\n");
377 fprintf(stderr,
" -Pprinter -nP\tSEND (don't send) directly to the printer");
380 fprintf(stderr,
"\n\t\t\t(with options '%s' and -Pprinter)",
LPR_OPT);
382 fprintf(stderr,
"\n");
384 fprintf(stderr,
" -r\t-nr\tRESTART (don't restart) page number after each file\n");
385 #ifdef RECTO_VERSO_PRINTING
387 fprintf(stderr,
" -s1\t-s2\tone-sided (TWO-SIDED) printing\n");
389 fprintf(stderr,
" -s1\t-s2\tONE-SIDED (two-sided) printing\n");
392 fprintf(stderr,
" -tnum\t\tset tab size to n\n");
393 fprintf(stderr,
" \t-nu\tdon't print a filename footer\n");
394 fprintf(stderr,
" -v\t-nv\tVISIBLE (blank) display of unprintable chars\n");
395 fprintf(stderr,
" -8\t-n8\tdisplay (DON'T DISPLAY) 8-bit chars\n");
411 print_binaries =
TRUE;
440 print_binaries =
FALSE;
463 only_printable =
TRUE;
485 lpr_opt = (
char *)malloc(strlen(arg)+1);
486 strcpy(lpr_opt, arg);
502 #ifdef RECTO_VERSO_PRINTING
517 if (arg[2] ==
NUL || (column_width = atoi(arg+2)) <= 0)
523 only_printable =
FALSE;
564 if (sscanf(&arg[2],
"%d", &copies) != 1 || copies <= 0)
565 fprintf(stderr,
"Bad number of copies: '%s'. Ignored\n", &arg[2]);
567 copies_number = copies;
568 printf(
"/#copies %d def\n", copies_number);
573 new_twinpages =
FALSE;
578 new_twinpages =
TRUE;
587 if (arg[2] ==
NUL || sscanf(&arg[2],
"%f", &size) != 1 || size == 0.0) {
588 fprintf(stderr,
"Wrong value for option -F: '%s'. Ignored\n",
599 new_landscape =
TRUE;
605 if (sscanf(&arg[2],
"%d", &lines) != 1
608 fprintf(stderr,
"Wrong value for option -l: '%s'. Ignored\n",
612 new_linesrequest = lines;
630 #if defined(SYSV) || defined(BSD)
636 new_landscape =
FALSE;
639 new_linesrequest = 0;
645 new_landscape =
TRUE;
651 filename_footer =
FALSE;
660 new_landscape =
FALSE;
684 #define BUFFER_SIZE 512
696 size = strlen((
char *)buffer);
697 if (size <
BUFFER_SIZE && buffer[size-1] !=
'\n') {
699 buffer[++size] =
'\0';
703 if (buffer[curr+1] !=
'\b')
704 return buffer[curr++];
708 if (c == buffer[curr+1] &&
709 buffer[curr] == buffer[curr+2] &&
710 c == buffer[curr+3] &&
711 buffer[curr] == buffer[curr+4] &&
726 if (chars > 120 || pages > 1) {
728 if (chars && !print_binaries && (nonprinting_chars*100 / chars) >= 60) {
729 fprintf(stderr,
"%s is a binary file: printing aborted\n", name);
745 strcpy(new_name, old_name);
748 p = old_name + (i-1);
759 else if (p >= old_name)
760 while (p >= old_name && *p !=
DIR_SEP) p--;
762 for (i = 0, p++; *p !=
NUL; i++)
772 if (c >=
' ' && c < 0177) {
773 if (c ==
'(' || c ==
')' || c ==
'\\')
779 if (ISOlatin1 && (c > 0177)) {
784 if (only_printable) {
795 if ((c = c +
'@') ==
'(' || c ==
')' || c ==
'\\')
802 if (c ==
'(' || c ==
')' || c ==
'\\')
814 if (twinpages ==
FALSE || sheetside == 0) {
815 printf(
"%%%%Page: %d %d\n", sheets+1, sheets+1);
816 printf(
"/pagesave save def\n");
829 if (++line >= linesperpage) {
851 while ((c =
mygetc(&status)) != EOF && c !=
'\n' && c !=
'\f') ;
866 printf(
"/sd 0 def\n");
867 if (no_border ==
FALSE)
868 printf(
"%d sn\n", sheets - (restart ? old_sheets : 0));
871 if (filename_footer && landscape)
873 #if defined(SYSV) || defined(BSD)
877 printf(
"pagesave restore\n");
878 printf(
"showpage\n");
886 if (sheetside == 0) {
887 #ifdef RECTO_VERSO_PRINTING
888 if (rectoverso && (sheets & 0x1)) {
890 printf(
"rm neg 0 translate\n");
894 printf(
"sw 0 translate\n");
895 printf(
"90 rotate\n");
899 if (no_header ==
FALSE)
900 printf(
"%d hp\n", pages - old_pages);
901 if (no_border ==
FALSE) {
903 if (no_header ==
FALSE)
906 printf(
"/x0 x %d get bm add def\n", sheetside);
907 printf(
"/y0 y %d get bm bfs add %s add sub def\n",
908 sheetside, no_header ?
"0" :
"hs");
909 printf(
"x0 y0 moveto\n");
910 printf(
"bf setfont\n");
917 if (twinpages && sheetside == 1)
919 #ifdef RECTO_VERSO_PRINTING
920 if (!twinfiles && rectoverso && (sheets & 0x1) != 0) {
923 printf(
"%%%%Page: %d %d\n", sheets, sheets);
924 printf(
"showpage\n");
934 if (twinpages && sheetside == 0) {
936 printf(
"/sd 1 def\n");
951 int new_format, new_font;
958 if (pages > 0 && !twinfiles)
963 if (new_landscape != landscape || new_twinpages != twinpages) {
970 if (no_header && name == title)
973 if (landscape || twinpages)
988 if (lines_requested != new_linesrequest) {
989 if ((lines_requested = new_linesrequest) != 0) {
1003 if (new_format || new_font) {
1020 if (lines_requested > 0)
1022 if (linesperpage <= 0 || columnsperline <= 0) {
1023 fprintf(stderr,
"Font %g too big !!\n",
fontsize);
1029 if (fstat(fileno(stdin), &statbuf) == -1) {
1030 fprintf(stderr,
"Error getting file modification time\n");
1034 if (S_ISFIFO(statbuf.st_mode))
1035 strcpy(filedate, currentdate);
1037 string = ctime(&statbuf.st_mtime);
1038 sprintf(filedate,
"%.6s %.4s %.5s",
string+4,
string+20,
string+11);
1050 printf(
"/twp %s def\n", twinpages ?
"true" :
"false");
1051 printf(
"/fnfs %d def\n", landscape ? 11 : twinpages ? 10 : 15);
1052 printf(
"/dfs fnfs 0.8 mul def\n");
1053 printf(
"/df /Helvetica dfs getfont def\n");
1054 printf(
"/dw df setfont td stringwidth pop def\n");
1055 printf(
"/sfnf filenmfontname fnfs getfont def\n");
1056 printf(
"/hm fnfs 0.25 mul def\n");
1059 printf(
"/hs 0.0 def\n");
1061 printf(
"/hs %g inch def\n",
1065 printf(
"/bdf /Courier-Bold bfs getfont def\n");
1066 printf(
"/bm bfs 0.7 mul def\n");
1067 printf(
"/bf %s bfs getfont def\n",
1070 printf(
"/l %d def\n", linesperpage);
1071 printf(
"/c %d def\n", columnsperline);
1073 printf(
" bf setfont (0) stringwidth pop c mul bm dup add add\n");
1076 printf(
" bfs l mul bm dup add add hs add\n");
1080 printf(
" fnfs 4 mul dw add (Page 999) stringwidth pop add\n");
1083 printf(
"/tm margin twp {3} {2} ifelse div def\n");
1084 printf(
"/sd %d def\n", side);
1086 printf(
"/y [ rm ph add bm add\n");
1087 printf(
" dup ] def\n");
1088 printf(
"/sny dfs dfs add def\n");
1089 printf(
"/snx sh tm dfs add sub def\n");
1090 printf(
"/dy sny def\n");
1091 printf(
"/dx tm dfs add def\n");
1093 printf(
"/x [ tm %% left page\n");
1094 printf(
" dup 2 mul pw add %% right page\n");
1098 printf(
"/x [ tm dup ] def\n");
1100 printf(
"/scx sh 2 div def\n");
1103 printf(
"/x [ lm dup ] def\n");
1104 printf(
"/sny tm dfs 2 mul sub def\n");
1105 printf(
"/snx sw rm sub dfs sub def\n");
1106 printf(
"/dy sny def\n");
1107 printf(
"/dx lm def\n");
1109 printf(
"/y [ tm ph add 2 mul %% up\n");
1110 printf(
" tm ph add %% down\n");
1114 printf(
"\n%% Only one logical page\n");
1115 printf(
"/y [ sh tm sub dup ] def\n");
1117 printf(
"/scx sw 2 div def\n");
1119 printf(
"/fny dy def\n");
1120 printf(
"/fnx scx def\n");
1121 printf(
"/ly fnfs 2 div y sd get add def\n");
1122 printf(
"/lx snx def\n");
1123 printf(
"/d (%s) def\n", filedate);
1124 printf(
"( %s ) fn\n", current_filename);
1133 int start_line, start_page;
1142 if (twinfiles && sheetside == 1)
1158 nonprinting_chars = chars = 0;
1162 line = line_number = 0;
1165 prefix_width = numbering ? 6 : 1;
1187 if (c ==
'\f' && interpret) {
1204 if ((c =
mygetc(&new_status)) == EOF)
1216 printf(
"(%4d|", ++line_number);
1225 if (status != new_status) {
1227 printf(
"%s", status ==
IS_ROMAN ?
"b" :
"st");
1229 status = new_status;
1249 if (++line >= linesperpage) {
1259 continue_exit =
FALSE;
1261 if (++column + prefix_width > columnsperline) {
1268 continue_exit =
TRUE;
1273 }
while (column % column_width);
1281 if (only_printable) {
1284 else if (! ISOlatin1) {
1285 nchars = c > 0177 ? 2 : 0;
1286 nchars += (c&0177) <
' ' || (c&0177) == 0177 ? 2 : 1;
1289 nchars = c < ' ' || (c >= 0177 && c < 144) ? 2 : 1;
1329 #if defined(SYSV) || defined(BSD)
1330 char *logname, *host;
1334 struct utsname snames;
1338 #if defined(__STDC__)
1341 if (time(&date) == -1) {
1342 fprintf(stderr,
"Error calculating time\n");
1345 datestring = ctime(&date);
1348 struct timeval date;
1351 (void) gettimeofday(&date, (
struct timezone *)0);
1352 p = localtime(&date.tv_sec);
1353 datestring = asctime(p);
1359 datestring = ctime(&date.time);
1362 datestring =
"--- --- -- --:--:-- ----";
1367 #if defined(SYSV) || defined(BSD)
1373 if ((rt = uname(&snames)) == -1 || !snames.nodename[0]) {
1378 strcpy(host, snames.nodename);
1391 else if ((f = fopen(prologue,
"r"))) {
1393 while ((c = getc(f)) != EOF)
1397 fprintf(stderr,
"Postscript header missing: %s\n", prologue);
1402 printf(
"\n%% Initialize page description variables.\n");
1403 printf(
"/x0 0 def\n");
1404 printf(
"/y0 0 def\n");
1405 printf(
"/sh %g inch def\n", (
double)
HEIGHT);
1406 printf(
"/sw %g inch def\n", (
double)
WIDTH);
1407 printf(
"/margin %g inch def\n", (
double)
MARGIN);
1408 printf(
"/rm margin 3 div def\n");
1409 printf(
"/lm margin 2 mul 3 div def\n");
1410 printf(
"/d () def\n");
1413 sprintf(currentdate,
"%.6s %.4s %.5s",
1414 datestring+4, datestring+20, datestring+11);
1415 printf(
"/td (%s) def\n", currentdate);
1417 #if defined(SYSV) || defined(BSD)
1419 if (logname || host) {
1420 if (logname && host)
1421 printf(
"/lg (Printed by %s from %s) def\n", logname, host);
1423 printf(
"/lg (Printed by %s) def\n", logname);
1425 printf(
"/lg (Printed from %s) def\n", host);
1434 printf(
"%%%%EndProlog\n\n");
1437 printf(
"/docsave save def\n");
1445 printf(
"%%!PS-Adobe-3.0\n");
1446 printf(
"%%%%Creator: A2ps version %s\n",
VERSION);
1447 printf(
"%%%%CreationDate: %.24s\n", datestring);
1448 printf(
"%%%%Pages: (atend)\n");
1449 printf(
"%%%%DocumentFonts: Courier Courier-Bold Helvetica Helvetica-Bold\n");
1450 printf(
"%%%%EndComments\n");
1451 printf(
"%% Copyright (c) 1993, 1994, Miguel Santana, M.Santana@frgu.bull.fr\n");
1452 printf(
"\n/$a2psdict 100 dict def\n");
1453 printf(
"$a2psdict begin\n");
1454 printf(
"\n%% General macros.\n");
1455 printf(
"/xdef {exch def} bind def\n");
1456 printf(
"/getfont {exch findfont exch scalefont} bind def\n");
1459 printf(
"\n%% Set up ISO Latin 1 character encoding\n");
1460 printf(
"/reencodeISO {\n");
1461 printf(
" dup dup findfont dup length dict begin\n");
1462 printf(
" { 1 index /FID ne { def }{ pop pop } ifelse\n");
1463 printf(
" } forall\n");
1464 printf(
" /Encoding ISOLatin1Encoding def\n");
1465 printf(
" currentdict end definefont\n");
1467 printf(
"/Helvetica-Bold reencodeISO def\n");
1468 printf(
"/Helvetica reencodeISO def\n");
1469 printf(
"/Courier reencodeISO def\n");
1470 printf(
"/Courier-Bold reencodeISO def\n");
1473 printf(
"\n%% Create Courier backspace font\n");
1474 printf(
"/backspacefont {\n");
1475 printf(
" /Courier findfont dup length dict begin\n");
1476 printf(
" { %% forall\n");
1477 printf(
" 1 index /FID eq { pop pop } { def } ifelse\n");
1478 printf(
" } forall\n");
1479 printf(
" currentdict /UniqueID known { %% if\n");
1480 printf(
" /UniqueID UniqueID 16#800000 xor def\n");
1482 printf(
" CharStrings length 1 add dict begin\n");
1483 printf(
" CharStrings { def } forall\n");
1484 printf(
" /backspace { -600 0 0 0 0 0 setcachedevice } bind def\n");
1485 printf(
" currentdict\n");
1487 printf(
" /CharStrings exch def\n");
1488 printf(
" /Encoding Encoding 256 array copy def\n");
1489 printf(
" Encoding 8 /backspace put\n");
1490 printf(
" currentdict\n");
1492 printf(
" definefont pop\n");
1493 printf(
"} bind def\n");
1495 printf(
"\n%% FUNCTIONS\n");
1496 printf(
"\n%% Function filename: Initialize file printing.\n");
1498 printf(
"{ /filenm xdef\n");
1499 printf(
" /filenmwidth filenm stringwidth pop def\n");
1500 printf(
" /filenmfont\n");
1501 printf(
" filenmwidth fns gt\n");
1503 printf(
" filenmfontname\n");
1504 printf(
" fnfs fns mul filenmwidth div\n");
1505 printf(
" getfont\n");
1507 printf(
" { sfnf }\n");
1508 printf(
" ifelse\n");
1510 printf(
"} bind def\n");
1511 printf(
"\n%% Function header: prints page header. no page\n");
1512 printf(
"%% is passed as argument.\n");
1514 printf(
" { x sd get y sd get hs sub 1 add moveto\n");
1515 printf(
" df setfont\n");
1517 printf(
" x sd get y sd get moveto\n");
1518 printf(
" 0 hs 2 div neg rmoveto \n");
1519 printf(
" hs setlinewidth\n");
1520 printf(
" 0.95 setgray\n");
1521 printf(
" pw 0 rlineto stroke\n");
1522 printf(
" grestore\n");
1524 printf(
" dfs hm rmoveto\n");
1525 printf(
" d show %% date/hour\n");
1526 printf(
" grestore\n");
1528 printf(
" pnum cvs pop %% page pop up\n");
1529 printf(
" pw (Page 999) stringwidth pop sub\n");
1531 printf(
" rmoveto\n");
1532 printf(
" (Page ) show pnum show %% page number\n");
1533 printf(
" grestore\n");
1534 printf(
" empty pnum copy pop\n");
1536 printf(
" filenmfont setfont\n");
1537 printf(
" fns filenm stringwidth pop sub 2 div dw add\n");
1538 printf(
" bm 2 mul \n");
1541 printf(
" rmoveto\n");
1542 printf(
" filenm show %% file name\n");
1543 printf(
" grestore\n");
1544 printf(
" } bind def\n");
1545 printf(
"\n%% Function border: prints border page\n");
1546 printf(
"/border \n");
1547 printf(
"{ x sd get y sd get moveto\n");
1548 printf(
" gsave %% print four sides\n");
1549 printf(
" 0.7 setlinewidth %% of the square\n");
1550 printf(
" pw 0 rlineto\n");
1551 printf(
" 0 ph neg rlineto\n");
1552 printf(
" pw neg 0 rlineto\n");
1553 printf(
" closepath stroke\n");
1554 printf(
" grestore\n");
1555 printf(
"} bind def\n");
1556 printf(
"\n%% Function hborder: completes border of the header.\n");
1557 printf(
"/hborder \n");
1558 printf(
"{ gsave\n");
1559 printf(
" 0.7 setlinewidth\n");
1560 printf(
" 0 hs neg rmoveto\n");
1561 printf(
" pw 0 rlineto\n");
1562 printf(
" stroke\n");
1563 printf(
" grestore\n");
1564 printf(
"} bind def\n");
1565 printf(
"\n%% Function sheetnumber: prints the sheet number.\n");
1567 printf(
" { snx sny moveto\n");
1568 printf(
" df setfont\n");
1569 printf(
" pnum cvs\n");
1570 printf(
" dup stringwidth pop (0) stringwidth pop sub neg 0 rmoveto show\n");
1571 printf(
" empty pnum copy pop\n");
1572 printf(
" } bind def\n");
1573 printf(
"\n%% Function loginprint: prints the login id of the requestor.\n");
1575 printf(
" { lx ly moveto\n");
1576 printf(
" df setfont\n");
1577 printf(
" dup stringwidth pop neg 0 rmoveto show\n");
1578 printf(
" } bind def\n");
1579 printf(
"\n%% Function currentdate: prints the current date.\n");
1581 printf(
" { dx dy moveto\n");
1582 printf(
" df setfont\n");
1583 printf(
" (Printed: ) show\n");
1584 printf(
" td show\n");
1585 printf(
" } bind def\n");
1586 printf(
"\n%% Function filename_footer: prints the file name at bottom of page.\n");
1588 printf(
" { fnx fny moveto\n");
1589 printf(
" df setfont\n");
1590 printf(
" filenm center show\n");
1591 printf(
" } bind def\n");
1592 printf(
"\n%% Function center: centers text.\n");
1593 printf(
"/center\n");
1594 printf(
" { dup stringwidth pop\n");
1595 printf(
" 2 div neg 0 rmoveto\n");
1596 printf(
" } bind def\n");
1597 printf(
"\n%% Function s: print a source line\n");
1598 printf(
"/s { show\n");
1599 printf(
" /y0 y0 bfs sub def\n");
1600 printf(
" x0 y0 moveto\n");
1601 printf(
" } bind def\n");
1602 printf(
"\n%% Functions b and st: change to bold or standard font\n");
1603 printf(
"/b { show\n");
1604 printf(
" bdf setfont\n");
1605 printf(
" } bind def\n");
1606 printf(
"/st { show\n");
1607 printf(
" bf setfont\n");
1608 printf(
" } bind def\n");
1609 printf(
"\n%% Strings used to make easy printing numbers\n");
1610 printf(
"/pnum 12 string def\n");
1611 printf(
"/empty 12 string def\n");
1612 printf(
"\n%% Global initializations\n");
1613 printf(
"\n/CourierBack backspacefont\n");
1614 printf(
"/filenmfontname /Helvetica-Bold def\n");
1615 printf(
"/inch {72 mul} bind def\n");
1618 printf(
"%% Meaning of some variables and functions (coded names)\n");
1620 printf(
"%% twp: twinpages?\n");
1621 printf(
"%% sd: sheet side\n");
1622 printf(
"%% l: line counter\n");
1623 printf(
"%% c: column counter\n");
1624 printf(
"%% d: date\n");
1625 printf(
"%% td: current date (for today)\n");
1626 printf(
"%% lg: login name\n");
1627 printf(
"%% fn: filename printing function\n");
1628 printf(
"%% sn: sheetnumber printing function\n");
1629 printf(
"%% cd: current date printing function\n");
1630 printf(
"%% fnf: filename footer printing function\n");
1631 printf(
"%% lgp: login printing function\n");
1632 printf(
"%% hp: header printing function\n");
1633 printf(
"%% y: y coordinate for the logical page\n");
1634 printf(
"%% x: x coordinate for the logical page\n");
1635 printf(
"%% sny: y coordinate for the sheet number\n");
1636 printf(
"%% snx: x coordinate for the sheet number\n");
1637 printf(
"%% dy: y coordinate for the date\n");
1638 printf(
"%% dx: x coordinate for the date\n");
1639 printf(
"%% ly: y coordinate for the login\n");
1640 printf(
"%% lx: x coordinate for the login\n");
1641 printf(
"%% scx: x coordinate for the sheet center\n");
1642 printf(
"%% fny: y coordinate for the filename (footer)\n");
1643 printf(
"%% fnx: x coordinate for the filename (footer)\n");
1644 printf(
"%% fnfs: filename font size\n");
1645 printf(
"%% bfs: body font size\n");
1646 printf(
"%% dfs: date font size\n");
1647 printf(
"%% bfs: body font size\n");
1648 printf(
"%% df: date font\n");
1649 printf(
"%% bf: body font\n");
1650 printf(
"%% bdf: bold font\n");
1651 printf(
"%% sfnf: standard filename font\n");
1652 printf(
"%% dw: date width\n");
1653 printf(
"%% pw: page width\n");
1654 printf(
"%% sw: sheet width\n");
1655 printf(
"%% ph: page height\n");
1656 printf(
"%% sh: sheet height\n");
1657 printf(
"%% hm: header margin\n");
1658 printf(
"%% tm: top margin\n");
1659 printf(
"%% bm: body margin\n");
1660 printf(
"%% rm: right margin\n");
1661 printf(
"%% lm: left margin\n");
1662 printf(
"%% hs: header size\n");
1663 printf(
"%% fns: filename size\n");
1671 char **argv = (
char**)cargv;
1677 const char *lpr_args[10];
1682 arg = argv[narg = 1];
1683 while (narg < argc) {
1692 if (pipe(fd) != 0) {
1693 fprintf(stderr,
"Could not create pipe (Reason: %s)\n", strerror(errno));
1699 close(fd[0]); close(fd[1]);
1707 #ifdef RECTO_VERSO_PRINTING
1709 lpr_args[narg++] = TWOSIDED;
1711 lpr_args[narg++] = ONESIDED;
1713 lpr_args[narg] = (
char *)0;
1715 fprintf(stderr,
"Error starting lpr process \n");
1725 landscape = twinpages = -1;
1734 arg = argv[narg = 1];
1735 while (narg < argc) {
1736 if (arg[0] !=
NUL) {
1740 if (!freopen(arg,
"r", stdin)) {
1741 fprintf(stderr,
"Error opening %s\n", arg);
1743 printf(
"\n%%%%Trailer\ndocsave restore end\n\4");
1750 if (twinfiles && twinpages)
1759 if (no_summary ==
FALSE) {
1761 fprintf(stderr,
"[%s: %d page%s on ", arg,
1762 total, total == 1 ?
"" :
"s");
1763 total = sheets - old_sheets +
sheetside;
1764 #ifdef RECTO_VERSO_PRINTING
1766 total = (total+1) / 2;
1768 fprintf(stderr,
"%d sheet%s]\n", total, total == 1 ?
"" :
"s");
1781 if (no_summary ==
FALSE && pages != old_pages) {
1782 fprintf(stderr,
"[Total: %d page%s on ", pages, pages == 1 ?
"" :
"s");
1784 #ifdef RECTO_VERSO_PRINTING
1786 total = (total+1) / 2;
1788 fprintf(stderr,
"%d sheet%s]\n", total, total == 1 ?
"" :
"s");
1793 printf(
"\n%%%%Trailer\n");
1794 printf(
"%%%%Pages: %d\n", sheets + sheetside);
1795 printf(
"docsave restore end\n");
return string(buffer, length)
static int lines_requested
static int new_linesrequest
static void print_page_prologue(int side)
static char currentdate[18]
static int only_printable
static void print_prologue()
static void print_standard_prologue(char *datestring)
static void print_file(char *name, char *header)
int gethostname(char *name, int namelen)
static int printchar(unsigned char c)
static void set_positional_option(char *arg)
static char current_filename[MAXFILENAME+1]
char buffer[MESSAGE_BUFFERSIZE]
int ARB_main(int argc, char *cargv[])
static int nonprinting_chars
static int is_binaryfile(char *name)
static void cut_filename(char *old_name, char *new_name)
static char * header_text
static int print_binaries
static int columnsperline
static BasicStatus status
static void usage(int failure)
static float new_fontsize
static double page_height
static void init_file_printing(char *name, char *title)
static int filename_footer
static int fold_line(char *name)
static void set_global_option(char *arg)
static int mygetc(int *statusp)
static WEIGHT new_fontweight
struct PT_short_chain_header __attribute__