home *** CD-ROM | disk | FTP | other *** search
- #include <bdscio.h>
-
- /* This program lists files to the printer. Wildcards and
- argument lists are supported.
- */
-
- int kill;
-
- main(argc,argv)
-
- int argc;
- char *argv[];
- {
- int i;
- kill = FALSE;
- if (argc < 2)
- {
- printf("Usage: list <arglist> \n");
- exit(1);
- }
- else
- {
- expand(&argc,&argv);
- for ( i = 1; i < argc; i++)
- {
- if(kill) break;
- lst(argv[i]);
- }
- }
- feed();
- }
-
-
- /* Subroutine to display a file on the printer. The argument
- must not be a wildcard name.
- */
- lst(name)
-
- char *name;
- {
- char ibuf[BUFSIZ], line[MAXLINE];
- int pagecnt, linecnt;
-
- if(openr(name,ibuf) == ERROR)
- return;
-
- /* Set up printer tab stops */
-
- settabs();
-
- /* Begin page loop */
-
- kill = abort();
- pagecnt = 1;
- while(fgets(line,ibuf) && !kill)
- {
- fprintf(2,"\t%s\t\t\t\t\t\t\tPAGE %d\n\n",
- name,pagecnt);
- fprintf(2,"\t%s",line);
- linecnt = 1;
-
- /* Begin line loop */
-
- while((fgets(line,ibuf)) && !kill)
- {
- kill = abort();
- fprintf(2,"\t%s",line);
- if(++linecnt >= 55) break;
- }
- pagecnt++;
- feed();
- }
- fclose(ibuf);
- }
-
- list(c)
- char c;
- {
- putc(c,2);
- }
-
- feed()
-
- #define FF 0x0c
- {
- list(FF);
- }
-
- settabs()
- {
- int n;
- #define ESC 0x1b
-
- list(ESC);
- list('D');
- for( n = 4 ; n < 81 ; n = n + 8)
- list(n);
- list(0);
- }
-
- abort()
- {
- int c;
-
- c = bdos(6, 0xff);
- if (c == 3)
- return(TRUE);
- else
- return(FALSE);
- }