]>
diplodocus.org Git - nmh/blob - docs/historical/SRI-NOSC/pr.c
3 * print file with headings
4 * precl[2]+head+2+page[56]+endl[5]
8 * NOTE: Defaults are set in the routine dflts()
9 * and not in these declares.
15 int ncol
1; /* number of columns */
16 char *header
; /* header text */
24 int line
; /* current line on page */
25 int linum
; /* current text line */
26 int ftext
; /* first text line on page */
28 int nofile
; /* number of current file */
31 int swval
; /* value for next switch */
32 int fpage
; /* first page to print */
33 int page
; /* current page number */
34 int oheadr
; /* use old header format */
35 int colw
; /* column width */
37 int width
65; /* line width */
38 int pwidth
65; /* width of physical line */
39 int length
66; /* length of physical page */
40 int plength
61; /* last print line */
42 int prone
1; /* print header on page one */
43 int ntflg
; /* no header or trailer */
44 int nuflg
; /* not header line */
46 int tabc
; /* print this as column separator */
49 int precl
2; /* # blank lines preceding hdr */
50 int endl
5; /* min # blank lines end of page */
51 int indent
; /* spaces preceding each line */
52 int ff
; /* use ff, not blank lines */
53 int wasff
; /* page break caused by ff */
54 int blankl
; /* # blank lines between lines */
55 int count
; /* whether to count linums */
56 int tab2sp
; /* change tabs => spaces */
57 int queeze
; /* squeeze blank lines from top */
59 int jnamflg
; /* print just file and not path */
60 int rapflg
; /* wrap-around line overflow */
61 int spaftfil
0; /* space between files */
89 if ((signal (2, 1) & 01) == 0)
93 for (nfdone
= 0; argc
> 1; argc
--)
98 swval
= 1; /* default to on */
103 blankl
= getn (++*argv
);
115 endl
= getn (++*argv
);
131 indent
= getn (++*argv
);
139 length
= getn (++*argv
);
156 precl
= getn (++*argv
);
168 spaftfil
= getn( ++*argv
);
180 width
= getn (++*argv
);
199 fpage
= getn (++*argv
);
231 tty
[8] = ttyn (fout
);
233 mode
= sbuf
.flags
& 0777;
242 ncol
= 1; /* number of columns */
243 width
= 65; /* line width */
244 length
= 60; /* length of physical page */
245 plength
= 61; /* last print line */
247 precl
= 1; /* # blank lines preceding hdr */
248 endl
= 5; /* min # blank lines end of page */
249 indent
= 5; /* spaces preceding each line */
250 ff
= 1; /* use ff, not blank lines */
251 blankl
= 0; /* # blank lines between lines */
252 count
= 0; /* whether to count linums */
253 prone
= 0; /* print header on page one */
254 tab2sp
= 0; /* change tabs into spaces */
255 queeze
= 1; /* squeeze beginning of pages */
256 jnamflg
= 0; /* print full pathname */
257 rapflg
= 1; /* wrap around long lines */
258 oheadr
= 0; /* nothin' but the best... */
262 ncol
= 1; /* number of columns */
263 width
= 77; /* line width */
264 length
= 60; /* length of physical page */
265 plength
= 61; /* last print line */
267 precl
= 2; /* # blank lines preceding hdr */
268 endl
= 5; /* min # blank lines end of page */
269 indent
= 5; /* spaces preceding each line */
270 ff
= 1; /* use ff, not blank lines */
271 blankl
= 0; /* # blank lines between lines */
272 count
= 0; /* whether to count linums */
273 prone
= 1; /* print header on page one */
274 tab2sp
= 0; /* change tabs into spaces */
275 queeze
= 0; /* preserve start of each page */
276 jnamflg
= 0; /* print full pathname */
277 rapflg
= 1; /* wrap around long lines */
278 oheadr
= 0; /* nothin' but the best... */
282 ncol
= 1; /* number of columns */
283 width
= 80; /* line width */
284 length
= 60; /* length of physical page */
285 plength
= 61; /* last print line */
287 precl
= 2; /* # blank lines preceding hdr */
288 endl
= 5; /* min # blank lines end of page */
289 indent
= 5; /* spaces preceding each line */
290 ff
= 1; /* use ff, not blank lines */
291 blankl
= 0; /* # blank lines between lines */
292 count
= 1; /* whether to count linums */
293 prone
= 1; /* print header on page one */
294 tab2sp
= 0; /* don't change tabs into spaces */
295 queeze
= 0; /* preserve start of each page */
296 jnamflg
= 0; /* print full pathname */
297 rapflg
= 1; /* wrap around long lines */
298 oheadr
= 0; /* nothin' but the best... */
303 ncol
= 0; /* number of columns */
304 width
= 72; /* line width */
305 length
= 66; /* length of physical page */
306 plength
= 61; /* last print line */
308 precl
= 2; /* # blank lines preceding hdr */
309 endl
= 5; /* min # blank lines end of page */
310 indent
= 0; /* spaces preceding each line */
311 ff
= 0; /* use ff, not blank lines */
312 blankl
= 0; /* # blank lines between lines */
313 count
= 0; /* whether to count linums */
314 prone
= 1; /* print header on page one */
315 tab2sp
= 0; /* don't change tabs into spaces */
316 queeze
= 0; /* preserve start of each page */
317 jnamflg
= 1; /* don't print full pathname */
318 rapflg
= 0; /* don't wrap around long lines */
319 oheadr
= 1; /* nothin' but the worst... */
340 margin
= precl
+ endl
+ (nuflg
? 0 : 3);
341 if (length
<= margin
)
345 if (ncol
> 72 || ncol
> width
)
347 write (2, "Very funny.\n", 12);
360 plength
= length
- endl
;
361 pwidth
= width
+ indent
;
373 errrpt (fp
, sys_errlst
[errno
]);
383 if ((header
== 0) && (file
!= 0))
384 header
= jnamflg
? fp
386 cbuf
= ctime (sbuf
.mtime
);
391 colp
[ncol
] = bufp
= buffer
;
394 while (mflg
&& nofile
|| (!mflg
) && tpgetc (ncol
) > 0)
399 if (colp
[ncol
] < buffer
)
400 colp
[ncol
] = &buffer
[BUFS
];
405 for (tmp1
= precl
; tmp1
--;)
408 (prone
|| (page
> 1)))
410 for (tmp1
= indent
; tmp1
--;)
412 if (!oheadr
&& header
)
432 while (col
< (pwidth
- 9));
441 ftext
= line
; /* # of first text line */
448 while (line
< length
)
452 if ( (ntflg
!= 0) && (spaftfil
> 0))
453 for (tmp1
= spaftfil
; tmp1
--;)
468 while ((p1
= *p
++) && p1
!= -1)
470 isclosed
[nofile
] = fopen (p1
, &buffer
[2 * 259 * nofile
]);
473 write (2, "Too many args.\n", 15);
481 register int lastcol
,
488 i
= 1; /* always starting on new line */
489 while (c
= pgetc (0))
491 if (i
) /* new line */
504 for (i
= indent
; i
--;)
520 for ((i
= (blankl
+ 1)); i
--;)
529 i
= 1; /* signal new line */
538 colp
[0] = colp
[ncol
];
540 for (i
= 1; i
<= ncol
; i
++)
542 colp
[i
] = colp
[i
- 1];
543 for (j
= margin
; j
< length
; j
++)
544 while ((c
= tpgetc (i
)) != '\n')
548 while (line
< plength
)
550 for (i
= indent
; i
--;)
552 lastcol
= colw
+ indent
;
553 for (i
= 0; i
< ncol
; i
++)
555 while ((c
= pgetc (i
)) && c
!= '\n')
556 if (col
< lastcol
|| tabc
!= 0)
563 while (col
< lastcol
)
567 while ((c
= pgetc (ncol
)) && c
!= '\n')
576 register char *rbufp
;
579 n
= &buffer
[BUFS
] - rbufp
;
582 if ((n
= read (file
, rbufp
, n
)) <= 0)
587 if (rbufp
>= &buffer
[BUFS
])
603 if ((c
= getc (&buffer
[2 * 259 * i
])) < 0)
605 if (isclosed
[i
] == 0)
613 if (c
== FF
&& ncol
> 0)
618 c
= **(p
= &colp
[i
]) & 0377;
627 if (*p
>= &buffer
[BUFS
])
652 if ((icol
& 07) != 0)
681 for (mag
= 1000; ((mag
> 1) && (mag
> an
)); mag
=/ 10)
724 /* nspace =& 0177770;
750 if (rapflg
&& (col
>= 84)) /* overflow */
755 col
= nspace
= 62; /* 84 - 22 */
759 col
=+ (2 + (nspace
= tspace
));
774 if ((c
!= '\n') && (c
!= FF
))
780 (col
> (ns
= ((col
- nspace
) | 07)))
783 nspace
= col
- ns
- 1;
803 if ((*p
< '0') || (*p
> '9'))
804 errrpt (p
, "in parameter is supposed to be a number");
806 while ((c
= *p
++) >= '0' && c
<= '9')
807 n
= n
* 10 + c
- '0';
829 printf ("pr: \"%s\" %s.\n", str1
, str2
);
863 fulpath
= filestr
; /* already a full name */
867 fulpath
= alloc (1); /* got to start somewhere */
871 if (*fulpath
) /* been here before ? */
873 chdir (fulpath
); /* get back to original dir */
875 dircat ("", fulpath
));
877 dircat (fulpath
, filestr
));
884 if ((gpfile
= open (DOTDOT
, 0)) < 0)
888 if ((n
= read (gpfile
, &y
, 16)) < 16)
890 /* printf("y.name = %s\n",y.name); */
892 while (y
.jnum
!= x
.inum
);
894 /* printf("y.jnum = %d\n",y.jnum); */
896 ckroot (y
.name
, &fulpath
);
899 dircat (y
.name
, fulpath
));
900 /* printf("fulpath = %s\n",fulpath); */
905 ckroot (name
, fulpath
)
925 if ((n
= stat (name
, &x
)) < 0)
929 if (((n
= chdir (ROOT
)) < 0) ||
930 ((gpfile
= open (ROOT
, 0)) < 0))
933 /* printf("fulpath = %s\n",*fulpath); */
936 if ((n
= read (gpfile
, &y
, 16)) < 16)
940 if ((n
= stat (y
.name
, &x
)) < 0)
945 if (x
.i
[0] != 040000)
947 if ((strequ (y
.name
, ".")) ||
948 (strequ (y
.name
, "..")))
950 /* printf("y.name = %s\n",y.name); */
952 dircat (y
.name
, *fulpath
));
953 /* printf("fulpath = %s\n",*fulpath); */
960 /* Return the length of the given string. This length */
961 /* does not include the terminating null character. */
966 register char *rstring
;
967 register int rlength
; /* length of string */
971 for (rlength
= 0; *rstring
++ != 0; ++rlength
);
977 /* Copy the given string to the given location. */
984 register char *rfrom
,
990 while (*rto
++ = *rfrom
++);
994 /* Concatenate the first given string the the second */
997 dircat (prefix
, suffix
)
1001 register char *rprefix
,
1007 alloc (pstrlen (rprefix
= prefix
) +
1008 pstrlen (rsuffix
= suffix
) + 2))
1011 write (1, "No more string storage!\n", 24);
1014 while (*ptr
++ = *rprefix
++);
1018 while (*ptr
++ = *rsuffix
++);
1023 /* Determine if the two given strings are equivalent. */
1030 register char *rstr1
,
1036 while (*rstr1
== *rstr2
++)
1042 rplstr (oldstr
, newstr
)
1046 /* printf("oldstr = %s\nnewstr =
1047 %s\n",*oldstr,newstr); */