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");
410 print_binaries =
TRUE;
439 print_binaries =
FALSE;
462 only_printable =
TRUE;
484 lpr_opt = (
char *)malloc(strlen(arg)+1);
485 strcpy(lpr_opt, arg);
501 #ifdef RECTO_VERSO_PRINTING
516 if (arg[2] ==
NUL || (column_width = atoi(arg+2)) <= 0)
522 only_printable =
FALSE;
563 if (sscanf(&arg[2],
"%d", &copies) != 1 || copies <= 0)
564 fprintf(stderr,
"Bad number of copies: '%s'. Ignored\n", &arg[2]);
566 copies_number = copies;
567 printf(
"/#copies %d def\n", copies_number);
572 new_twinpages =
FALSE;
577 new_twinpages =
TRUE;
586 if (arg[2] ==
NUL || sscanf(&arg[2],
"%f", &size) != 1 || size == 0.0) {
587 fprintf(stderr,
"Wrong value for option -F: '%s'. Ignored\n",
598 new_landscape =
TRUE;
604 if (sscanf(&arg[2],
"%d", &lines) != 1
607 fprintf(stderr,
"Wrong value for option -l: '%s'. Ignored\n",
611 new_linesrequest = lines;
629 #if defined(SYSV) || defined(BSD)
635 new_landscape =
FALSE;
638 new_linesrequest = 0;
644 new_landscape =
TRUE;
650 filename_footer =
FALSE;
659 new_landscape =
FALSE;
683 #define BUFFER_SIZE 512
695 size = strlen((
char *)buffer);
696 if (size <
BUFFER_SIZE && buffer[size-1] !=
'\n') {
698 buffer[++size] =
'\0';
702 if (buffer[curr+1] !=
'\b')
703 return buffer[curr++];
707 if (c == buffer[curr+1] &&
708 buffer[curr] == buffer[curr+2] &&
709 c == buffer[curr+3] &&
710 buffer[curr] == buffer[curr+4] &&
725 if (chars > 120 || pages > 1) {
727 if (chars && !print_binaries && (nonprinting_chars*100 / chars) >= 60) {
728 fprintf(stderr,
"%s is a binary file: printing aborted\n", name);
744 strcpy(new_name, old_name);
747 p = old_name + (i-1);
758 else if (p >= old_name)
759 while (p >= old_name && *p !=
DIR_SEP) p--;
761 for (i = 0, p++; *p !=
NUL; i++)
771 if (c >=
' ' && c < 0177) {
772 if (c ==
'(' || c ==
')' || c ==
'\\')
778 if (ISOlatin1 && (c > 0177)) {
783 if (only_printable) {
794 if ((c = c +
'@') ==
'(' || c ==
')' || c ==
'\\')
801 if (c ==
'(' || c ==
')' || c ==
'\\')
813 if (twinpages ==
FALSE || sheetside == 0) {
814 printf(
"%%%%Page: %d %d\n", sheets+1, sheets+1);
815 printf(
"/pagesave save def\n");
828 if (++line >= linesperpage) {
850 while ((c =
mygetc(&status)) != EOF && c !=
'\n' && c !=
'\f') ;
865 printf(
"/sd 0 def\n");
866 if (no_border ==
FALSE)
867 printf(
"%d sn\n", sheets - (restart ? old_sheets : 0));
870 if (filename_footer && landscape)
872 #if defined(SYSV) || defined(BSD)
876 printf(
"pagesave restore\n");
877 printf(
"showpage\n");
885 if (sheetside == 0) {
886 #ifdef RECTO_VERSO_PRINTING
887 if (rectoverso && (sheets & 0x1)) {
889 printf(
"rm neg 0 translate\n");
893 printf(
"sw 0 translate\n");
894 printf(
"90 rotate\n");
898 if (no_header ==
FALSE)
899 printf(
"%d hp\n", pages - old_pages);
900 if (no_border ==
FALSE) {
902 if (no_header ==
FALSE)
905 printf(
"/x0 x %d get bm add def\n", sheetside);
906 printf(
"/y0 y %d get bm bfs add %s add sub def\n",
907 sheetside, no_header ?
"0" :
"hs");
908 printf(
"x0 y0 moveto\n");
909 printf(
"bf setfont\n");
916 if (twinpages && sheetside == 1)
918 #ifdef RECTO_VERSO_PRINTING
919 if (!twinfiles && rectoverso && (sheets & 0x1) != 0) {
922 printf(
"%%%%Page: %d %d\n", sheets, sheets);
923 printf(
"showpage\n");
933 if (twinpages && sheetside == 0) {
935 printf(
"/sd 1 def\n");
950 int new_format, new_font;
957 if (pages > 0 && !twinfiles)
962 if (new_landscape != landscape || new_twinpages != twinpages) {
969 if (no_header && name == title)
972 if (landscape || twinpages)
987 if (lines_requested != new_linesrequest) {
988 if ((lines_requested = new_linesrequest) != 0) {
1002 if (new_format || new_font) {
1019 if (lines_requested > 0)
1021 if (linesperpage <= 0 || columnsperline <= 0) {
1022 fprintf(stderr,
"Font %g too big !!\n",
fontsize);
1028 if (fstat(fileno(stdin), &statbuf) == -1) {
1029 fprintf(stderr,
"Error getting file modification time\n");
1033 if (S_ISFIFO(statbuf.st_mode))
1034 strcpy(filedate, currentdate);
1036 string = ctime(&statbuf.st_mtime);
1037 sprintf(filedate,
"%.6s %.4s %.5s",
string+4,
string+20,
string+11);
1049 printf(
"/twp %s def\n", twinpages ?
"true" :
"false");
1050 printf(
"/fnfs %d def\n", landscape ? 11 : twinpages ? 10 : 15);
1051 printf(
"/dfs fnfs 0.8 mul def\n");
1052 printf(
"/df /Helvetica dfs getfont def\n");
1053 printf(
"/dw df setfont td stringwidth pop def\n");
1054 printf(
"/sfnf filenmfontname fnfs getfont def\n");
1055 printf(
"/hm fnfs 0.25 mul def\n");
1058 printf(
"/hs 0.0 def\n");
1060 printf(
"/hs %g inch def\n",
1064 printf(
"/bdf /Courier-Bold bfs getfont def\n");
1065 printf(
"/bm bfs 0.7 mul def\n");
1066 printf(
"/bf %s bfs getfont def\n",
1069 printf(
"/l %d def\n", linesperpage);
1070 printf(
"/c %d def\n", columnsperline);
1072 printf(
" bf setfont (0) stringwidth pop c mul bm dup add add\n");
1075 printf(
" bfs l mul bm dup add add hs add\n");
1079 printf(
" fnfs 4 mul dw add (Page 999) stringwidth pop add\n");
1082 printf(
"/tm margin twp {3} {2} ifelse div def\n");
1083 printf(
"/sd %d def\n", side);
1085 printf(
"/y [ rm ph add bm add\n");
1086 printf(
" dup ] def\n");
1087 printf(
"/sny dfs dfs add def\n");
1088 printf(
"/snx sh tm dfs add sub def\n");
1089 printf(
"/dy sny def\n");
1090 printf(
"/dx tm dfs add def\n");
1092 printf(
"/x [ tm %% left page\n");
1093 printf(
" dup 2 mul pw add %% right page\n");
1097 printf(
"/x [ tm dup ] def\n");
1099 printf(
"/scx sh 2 div def\n");
1102 printf(
"/x [ lm dup ] def\n");
1103 printf(
"/sny tm dfs 2 mul sub def\n");
1104 printf(
"/snx sw rm sub dfs sub def\n");
1105 printf(
"/dy sny def\n");
1106 printf(
"/dx lm def\n");
1108 printf(
"/y [ tm ph add 2 mul %% up\n");
1109 printf(
" tm ph add %% down\n");
1113 printf(
"\n%% Only one logical page\n");
1114 printf(
"/y [ sh tm sub dup ] def\n");
1116 printf(
"/scx sw 2 div def\n");
1118 printf(
"/fny dy def\n");
1119 printf(
"/fnx scx def\n");
1120 printf(
"/ly fnfs 2 div y sd get add def\n");
1121 printf(
"/lx snx def\n");
1122 printf(
"/d (%s) def\n", filedate);
1123 printf(
"( %s ) fn\n", current_filename);
1132 int start_line, start_page;
1141 if (twinfiles && sheetside == 1)
1157 nonprinting_chars = chars = 0;
1161 line = line_number = 0;
1164 prefix_width = numbering ? 6 : 1;
1186 if (c ==
'\f' && interpret) {
1203 if ((c =
mygetc(&new_status)) == EOF)
1215 printf(
"(%4d|", ++line_number);
1224 if (status != new_status) {
1226 printf(
"%s", status ==
IS_ROMAN ?
"b" :
"st");
1228 status = new_status;
1248 if (++line >= linesperpage) {
1258 continue_exit =
FALSE;
1260 if (++column + prefix_width > columnsperline) {
1267 continue_exit =
TRUE;
1272 }
while (column % column_width);
1279 if (only_printable) {
1282 else if (! ISOlatin1) {
1283 nchars = c > 0177 ? 2 : 0;
1284 nchars += (c&0177) <
' ' || (c&0177) == 0177 ? 2 : 1;
1287 nchars = c < ' ' || (c >= 0177 && c < 144) ? 2 : 1;
1327 #if defined(SYSV) || defined(BSD)
1328 char *logname, *host;
1332 struct utsname snames;
1336 #if defined(__STDC__)
1339 if (time(&date) == -1) {
1340 fprintf(stderr,
"Error calculating time\n");
1343 datestring = ctime(&date);
1346 struct timeval date;
1349 (void) gettimeofday(&date, (
struct timezone *)0);
1350 p = localtime(&date.tv_sec);
1351 datestring = asctime(p);
1357 datestring = ctime(&date.time);
1360 datestring =
"--- --- -- --:--:-- ----";
1365 #if defined(SYSV) || defined(BSD)
1371 if ((rt = uname(&snames)) == -1 || !snames.nodename[0]) {
1376 strcpy(host, snames.nodename);
1389 else if ((f = fopen(prologue,
"r"))) {
1391 while ((c = getc(f)) != EOF)
1395 fprintf(stderr,
"Postscript header missing: %s\n", prologue);
1400 printf(
"\n%% Initialize page description variables.\n");
1401 printf(
"/x0 0 def\n");
1402 printf(
"/y0 0 def\n");
1403 printf(
"/sh %g inch def\n", (
double)
HEIGHT);
1404 printf(
"/sw %g inch def\n", (
double)
WIDTH);
1405 printf(
"/margin %g inch def\n", (
double)
MARGIN);
1406 printf(
"/rm margin 3 div def\n");
1407 printf(
"/lm margin 2 mul 3 div def\n");
1408 printf(
"/d () def\n");
1411 sprintf(currentdate,
"%.6s %.4s %.5s",
1412 datestring+4, datestring+20, datestring+11);
1413 printf(
"/td (%s) def\n", currentdate);
1415 #if defined(SYSV) || defined(BSD)
1417 if (logname || host) {
1418 if (logname && host)
1419 printf(
"/lg (Printed by %s from %s) def\n", logname, host);
1421 printf(
"/lg (Printed by %s) def\n", logname);
1423 printf(
"/lg (Printed from %s) def\n", host);
1432 printf(
"%%%%EndProlog\n\n");
1435 printf(
"/docsave save def\n");
1443 printf(
"%%!PS-Adobe-3.0\n");
1444 printf(
"%%%%Creator: A2ps version %s\n",
VERSION);
1445 printf(
"%%%%CreationDate: %.24s\n", datestring);
1446 printf(
"%%%%Pages: (atend)\n");
1447 printf(
"%%%%DocumentFonts: Courier Courier-Bold Helvetica Helvetica-Bold\n");
1448 printf(
"%%%%EndComments\n");
1449 printf(
"%% Copyright (c) 1993, 1994, Miguel Santana, M.Santana@frgu.bull.fr\n");
1450 printf(
"\n/$a2psdict 100 dict def\n");
1451 printf(
"$a2psdict begin\n");
1452 printf(
"\n%% General macros.\n");
1453 printf(
"/xdef {exch def} bind def\n");
1454 printf(
"/getfont {exch findfont exch scalefont} bind def\n");
1457 printf(
"\n%% Set up ISO Latin 1 character encoding\n");
1458 printf(
"/reencodeISO {\n");
1459 printf(
" dup dup findfont dup length dict begin\n");
1460 printf(
" { 1 index /FID ne { def }{ pop pop } ifelse\n");
1461 printf(
" } forall\n");
1462 printf(
" /Encoding ISOLatin1Encoding def\n");
1463 printf(
" currentdict end definefont\n");
1465 printf(
"/Helvetica-Bold reencodeISO def\n");
1466 printf(
"/Helvetica reencodeISO def\n");
1467 printf(
"/Courier reencodeISO def\n");
1468 printf(
"/Courier-Bold reencodeISO def\n");
1471 printf(
"\n%% Create Courier backspace font\n");
1472 printf(
"/backspacefont {\n");
1473 printf(
" /Courier findfont dup length dict begin\n");
1474 printf(
" { %% forall\n");
1475 printf(
" 1 index /FID eq { pop pop } { def } ifelse\n");
1476 printf(
" } forall\n");
1477 printf(
" currentdict /UniqueID known { %% if\n");
1478 printf(
" /UniqueID UniqueID 16#800000 xor def\n");
1480 printf(
" CharStrings length 1 add dict begin\n");
1481 printf(
" CharStrings { def } forall\n");
1482 printf(
" /backspace { -600 0 0 0 0 0 setcachedevice } bind def\n");
1483 printf(
" currentdict\n");
1485 printf(
" /CharStrings exch def\n");
1486 printf(
" /Encoding Encoding 256 array copy def\n");
1487 printf(
" Encoding 8 /backspace put\n");
1488 printf(
" currentdict\n");
1490 printf(
" definefont pop\n");
1491 printf(
"} bind def\n");
1493 printf(
"\n%% FUNCTIONS\n");
1494 printf(
"\n%% Function filename: Initialize file printing.\n");
1496 printf(
"{ /filenm xdef\n");
1497 printf(
" /filenmwidth filenm stringwidth pop def\n");
1498 printf(
" /filenmfont\n");
1499 printf(
" filenmwidth fns gt\n");
1501 printf(
" filenmfontname\n");
1502 printf(
" fnfs fns mul filenmwidth div\n");
1503 printf(
" getfont\n");
1505 printf(
" { sfnf }\n");
1506 printf(
" ifelse\n");
1508 printf(
"} bind def\n");
1509 printf(
"\n%% Function header: prints page header. no page\n");
1510 printf(
"%% is passed as argument.\n");
1512 printf(
" { x sd get y sd get hs sub 1 add moveto\n");
1513 printf(
" df setfont\n");
1515 printf(
" x sd get y sd get moveto\n");
1516 printf(
" 0 hs 2 div neg rmoveto \n");
1517 printf(
" hs setlinewidth\n");
1518 printf(
" 0.95 setgray\n");
1519 printf(
" pw 0 rlineto stroke\n");
1520 printf(
" grestore\n");
1522 printf(
" dfs hm rmoveto\n");
1523 printf(
" d show %% date/hour\n");
1524 printf(
" grestore\n");
1526 printf(
" pnum cvs pop %% page pop up\n");
1527 printf(
" pw (Page 999) stringwidth pop sub\n");
1529 printf(
" rmoveto\n");
1530 printf(
" (Page ) show pnum show %% page number\n");
1531 printf(
" grestore\n");
1532 printf(
" empty pnum copy pop\n");
1534 printf(
" filenmfont setfont\n");
1535 printf(
" fns filenm stringwidth pop sub 2 div dw add\n");
1536 printf(
" bm 2 mul \n");
1539 printf(
" rmoveto\n");
1540 printf(
" filenm show %% file name\n");
1541 printf(
" grestore\n");
1542 printf(
" } bind def\n");
1543 printf(
"\n%% Function border: prints border page\n");
1544 printf(
"/border \n");
1545 printf(
"{ x sd get y sd get moveto\n");
1546 printf(
" gsave %% print four sides\n");
1547 printf(
" 0.7 setlinewidth %% of the square\n");
1548 printf(
" pw 0 rlineto\n");
1549 printf(
" 0 ph neg rlineto\n");
1550 printf(
" pw neg 0 rlineto\n");
1551 printf(
" closepath stroke\n");
1552 printf(
" grestore\n");
1553 printf(
"} bind def\n");
1554 printf(
"\n%% Function hborder: completes border of the header.\n");
1555 printf(
"/hborder \n");
1556 printf(
"{ gsave\n");
1557 printf(
" 0.7 setlinewidth\n");
1558 printf(
" 0 hs neg rmoveto\n");
1559 printf(
" pw 0 rlineto\n");
1560 printf(
" stroke\n");
1561 printf(
" grestore\n");
1562 printf(
"} bind def\n");
1563 printf(
"\n%% Function sheetnumber: prints the sheet number.\n");
1565 printf(
" { snx sny moveto\n");
1566 printf(
" df setfont\n");
1567 printf(
" pnum cvs\n");
1568 printf(
" dup stringwidth pop (0) stringwidth pop sub neg 0 rmoveto show\n");
1569 printf(
" empty pnum copy pop\n");
1570 printf(
" } bind def\n");
1571 printf(
"\n%% Function loginprint: prints the login id of the requestor.\n");
1573 printf(
" { lx ly moveto\n");
1574 printf(
" df setfont\n");
1575 printf(
" dup stringwidth pop neg 0 rmoveto show\n");
1576 printf(
" } bind def\n");
1577 printf(
"\n%% Function currentdate: prints the current date.\n");
1579 printf(
" { dx dy moveto\n");
1580 printf(
" df setfont\n");
1581 printf(
" (Printed: ) show\n");
1582 printf(
" td show\n");
1583 printf(
" } bind def\n");
1584 printf(
"\n%% Function filename_footer: prints the file name at bottom of page.\n");
1586 printf(
" { fnx fny moveto\n");
1587 printf(
" df setfont\n");
1588 printf(
" filenm center show\n");
1589 printf(
" } bind def\n");
1590 printf(
"\n%% Function center: centers text.\n");
1591 printf(
"/center\n");
1592 printf(
" { dup stringwidth pop\n");
1593 printf(
" 2 div neg 0 rmoveto\n");
1594 printf(
" } bind def\n");
1595 printf(
"\n%% Function s: print a source line\n");
1596 printf(
"/s { show\n");
1597 printf(
" /y0 y0 bfs sub def\n");
1598 printf(
" x0 y0 moveto\n");
1599 printf(
" } bind def\n");
1600 printf(
"\n%% Functions b and st: change to bold or standard font\n");
1601 printf(
"/b { show\n");
1602 printf(
" bdf setfont\n");
1603 printf(
" } bind def\n");
1604 printf(
"/st { show\n");
1605 printf(
" bf setfont\n");
1606 printf(
" } bind def\n");
1607 printf(
"\n%% Strings used to make easy printing numbers\n");
1608 printf(
"/pnum 12 string def\n");
1609 printf(
"/empty 12 string def\n");
1610 printf(
"\n%% Global initializations\n");
1611 printf(
"\n/CourierBack backspacefont\n");
1612 printf(
"/filenmfontname /Helvetica-Bold def\n");
1613 printf(
"/inch {72 mul} bind def\n");
1616 printf(
"%% Meaning of some variables and functions (coded names)\n");
1618 printf(
"%% twp: twinpages?\n");
1619 printf(
"%% sd: sheet side\n");
1620 printf(
"%% l: line counter\n");
1621 printf(
"%% c: column counter\n");
1622 printf(
"%% d: date\n");
1623 printf(
"%% td: current date (for today)\n");
1624 printf(
"%% lg: login name\n");
1625 printf(
"%% fn: filename printing function\n");
1626 printf(
"%% sn: sheetnumber printing function\n");
1627 printf(
"%% cd: current date printing function\n");
1628 printf(
"%% fnf: filename footer printing function\n");
1629 printf(
"%% lgp: login printing function\n");
1630 printf(
"%% hp: header printing function\n");
1631 printf(
"%% y: y coordinate for the logical page\n");
1632 printf(
"%% x: x coordinate for the logical page\n");
1633 printf(
"%% sny: y coordinate for the sheet number\n");
1634 printf(
"%% snx: x coordinate for the sheet number\n");
1635 printf(
"%% dy: y coordinate for the date\n");
1636 printf(
"%% dx: x coordinate for the date\n");
1637 printf(
"%% ly: y coordinate for the login\n");
1638 printf(
"%% lx: x coordinate for the login\n");
1639 printf(
"%% scx: x coordinate for the sheet center\n");
1640 printf(
"%% fny: y coordinate for the filename (footer)\n");
1641 printf(
"%% fnx: x coordinate for the filename (footer)\n");
1642 printf(
"%% fnfs: filename font size\n");
1643 printf(
"%% bfs: body font size\n");
1644 printf(
"%% dfs: date font size\n");
1645 printf(
"%% bfs: body font size\n");
1646 printf(
"%% df: date font\n");
1647 printf(
"%% bf: body font\n");
1648 printf(
"%% bdf: bold font\n");
1649 printf(
"%% sfnf: standard filename font\n");
1650 printf(
"%% dw: date width\n");
1651 printf(
"%% pw: page width\n");
1652 printf(
"%% sw: sheet width\n");
1653 printf(
"%% ph: page height\n");
1654 printf(
"%% sh: sheet height\n");
1655 printf(
"%% hm: header margin\n");
1656 printf(
"%% tm: top margin\n");
1657 printf(
"%% bm: body margin\n");
1658 printf(
"%% rm: right margin\n");
1659 printf(
"%% lm: left margin\n");
1660 printf(
"%% hs: header size\n");
1661 printf(
"%% fns: filename size\n");
1669 char **argv = (
char**)cargv;
1675 const char *lpr_args[10];
1680 arg = argv[narg = 1];
1681 while (narg < argc) {
1690 if (pipe(fd) != 0) {
1691 fprintf(stderr,
"Could not create pipe (Reason: %s)\n", strerror(errno));
1697 close(fd[0]); close(fd[1]);
1705 #ifdef RECTO_VERSO_PRINTING
1707 lpr_args[narg++] = TWOSIDED;
1709 lpr_args[narg++] = ONESIDED;
1711 lpr_args[narg] = (
char *)0;
1713 fprintf(stderr,
"Error starting lpr process \n");
1723 landscape = twinpages = -1;
1732 arg = argv[narg = 1];
1733 while (narg < argc) {
1734 if (arg[0] !=
NUL) {
1738 if (!freopen(arg,
"r", stdin)) {
1739 fprintf(stderr,
"Error opening %s\n", arg);
1741 printf(
"\n%%%%Trailer\ndocsave restore end\n\4");
1748 if (twinfiles && twinpages)
1757 if (no_summary ==
FALSE) {
1759 fprintf(stderr,
"[%s: %d page%s on ", arg,
1760 total, total == 1 ?
"" :
"s");
1761 total = sheets - old_sheets +
sheetside;
1762 #ifdef RECTO_VERSO_PRINTING
1764 total = (total+1) / 2;
1766 fprintf(stderr,
"%d sheet%s]\n", total, total == 1 ?
"" :
"s");
1779 if (no_summary ==
FALSE && pages != old_pages) {
1780 fprintf(stderr,
"[Total: %d page%s on ", pages, pages == 1 ?
"" :
"s");
1782 #ifdef RECTO_VERSO_PRINTING
1784 total = (total+1) / 2;
1786 fprintf(stderr,
"%d sheet%s]\n", total, total == 1 ?
"" :
"s");
1791 printf(
"\n%%%%Trailer\n");
1792 printf(
"%%%%Pages: %d\n", sheets + sheetside);
1793 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