w32tex
About: TeX Live provides a comprehensive TeX system including all the major TeX-related programs, macro packages, and fonts that are free software. Windows sources.
  Fossies Dox: w32tex-src.tar.xz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

dvi2tty.c
Go to the documentation of this file.
1 /*
2  * dvi2tty
3  * Copyright (C) 2003 Marcel J.E. Mol <marcel@mesa.nl>
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18  *
19  */
20 
21 /*
22  * Include files
23  */
24 
25 #include "dvi2tty.h"
26 #if defined(VMS)
27 # include unixio
28 #endif
29 #if defined(THINK_C)
30 # include <unix.h>
31 # include "macintosh.h"
32 #endif
33 
34 #if defined(WIN32) && defined(KPATHSEA)
35 #undef fopen
36 #define fopen fsyscp_fopen
37 #endif
38 
39 
40 /*
41  * Constant definitons
42  */
43  /*-----------------------------------------------------------------------*/
44  /* The following constants may be toggled before compilation to */
45  /* customize the default behaviour of the program for your site. */
46  /* Whichever their settings are, the defaults can be overridden at */
47  /* runtime. */
48  /*-----------------------------------------------------------------------*/
49 
50 #define DEFSCAND FALSE /* default is not Scandinavian, toggle this if */
51  /* you have terminals with Scand. nat. chars */
52 #define DEFLATIN1 FALSE /* default is no latin1, toggle this if you */
53  /* have terminals with latin1 chars */
54 #define WANTPAGER TRUE /* default: try to pipe through a pager (like */
55  /* more) if stdout is tty and no -o switch */
56 #define DEFPAGER "more" /* CHANGE TO YOUR LOCAL PAGER */
57 
58  /*------------------ end of customization constants ---------------------*/
59 
60 #if defined(MSDOS) || defined(VMS) || defined(AMIGA)
61 #define OPTSET "haJweEpPousltvbcANUC" /* legal options */
62 #define OPTWARG "weEpPovb" /* options with argument */
63 #else
64 #define OPTSET "haJweEpPousqlfFtvbcANUC" /* legal options */
65 #define OPTWARG "weEpPoFvb" /* options with argument */
66 #endif
67 
68 /*
69  * USAGE CODES
70  */
71 
72 #define wrnge 1 /* width switch arg out of range */
73 #define ign 2 /* ignore cause, print 'Usage:..' */
74 #define nan 3 /* not a number where one expected */
75 #define gae 4 /* garbage at end */
76 #define bdlst 5 /* bad page-numberlist */
77 #define onef 6 /* only one dvifile allowed */
78 #define bdopt 7 /* bad option */
79 #define onepp 8 /* only one page list allowed */
80 #define noarg 9 /* argument expected */
81 #define confl 10 /* -J, -N, -A, and -U conflict */
82 #define incone 11 /* inconsistent output encoding */
83 #if defined(THINK_C)
84 #define nored 100 /* if no input file, redirect stdin */
85 #endif
86 
87 
88 /*
89  * Variable definitions
90  */
91 
92 const char *dvi2tty = "@(#) dvi2tty.c " VERSION " 20160305 M.J.E. Mol (c) 1989-2010, and contributors (c) -2016";
93 
94 
95 printlisttype * currentpage; /* current page to print */
96 printlisttype * firstpage; /* first page selected */
97 printlisttype * lastpage; /* last page selected */
98 
101 bool outputtofile; /* tells if output goes to file or stdout */
102 #if defined(THINK_C)
103 bool inputfromfile; /* tells if input comes from file or stdin */
104 #endif
105 int ttywidth; /* max nr of chars per printed line */
106 int espace; /* to fake calcs with ttywidth */
107 
108 long foo; /* utility variable, "register" */
109 #if !defined(MSDOS) && !defined(VMS) && !defined(THINK_C) && !defined(AMIGA)
110 bool pager; /* tells if output is piped to a pager */
111 const char * path; /* name of the pager to run */
112 #endif
113 char * progname; /* our name */
114 int Argc;
115 char ** Argv;
116 char * DVIfilename;
117 const char * OUTfilename;
118 char optch; /* for option handling */
119 
120 
121 
122 /*
123  * Function declarations
124  */
125 
126 #if defined(MSDOS)
127 void setoption (const char *);
128 void getargs (void);
129 void getpages (int, const char *);
130 void plcnxt (int);
131 void getfname (const char *);
132 int getinteger(int *, int *, const char *);
133 int getlong (long *, int *, const char *);
134 void usage (int);
135 #else
136 
137 # if defined(VMS)
138  main (int argc, char ** argv);
139 # endif
140 void setoption (const char * optarg);
141 void getargs (void);
142 void getpages (int j, const char * str);
143 void plcnxt (int pagnr);
144 void getfname (const char * str);
145 int getinteger(int * dest, int * j, const char * str);
146 int getlong (long * dest, int * j, const char * str);
147 void usage (int uerr);
148 #endif
149 
150 
151 /****************************************************************************/
152 /* */
153 /* M A I N */
154 /* */
155 /****************************************************************************/
156 
157 #if defined(VMS)
158 main(int argc, char **argv)
159 #else
160 int main(int argc, char **argv)
161 #endif
162 {
163 #if defined(WIN32) && defined(KPATHSEA)
164  char *enc;
165 #endif
166 
167 #if defined(THINK_C)
168  argc = process_dvi_command_line(&argv);
169 #endif
170 
171  progname = *argv;
172  Argc = argc;
173  Argv = argv;
174 #if defined(WIN32) && defined(KPATHSEA)
175  kpse_set_program_name(argv[0], "dvi2tty");
176  enc = kpse_var_value("command_line_encoding");
177  get_command_line_args_utf8(enc, &Argc, &Argv);
178 #endif
179 
180 #ifdef WIN32
181  set_enc_string ("sjis", "default");
182  _setmode (fileno(stdout), _O_BINARY);
183 #else
184  set_enc_string (NULL, "default");
185 #endif
186  getargs(); /* read command line arguments */
187 #if defined(THINK_C)
188  if (inputfromfile) {
189 #endif
190 #if defined(MSDOS) || defined(WIN32)
191  if ((DVIfile = fopen(DVIfilename, "rb")) == NULL)
192 #else
193 # if defined(VMS)
194  if ((DVIfile = fopen(DVIfilename, "r","ctx=rec")) == NULL)
195 # else
196  if ((DVIfile = fopen(DVIfilename, "r")) == NULL)
197 # endif
198 #endif
199  errorexit(filop); /* can't open dvifile */
200 #if defined(THINK_C)
201  }
202  else
203  DVIfile = stdin;
204 #endif
205 
206  if (outputtofile) { /* open the outfile, if needed */
207  if ((output = fopen(OUTfilename, "wb")) == NULL)
208  errorexit(filcr);
209 #if defined(THINK_C)
210  else
211  set_creator((unsigned char*) OUTfilename);
212 #endif
213 
214 #if !defined(MSDOS) && !defined(VMS) && !defined(THINK_C)
215  pager = FALSE;
216 #endif
217  }
218  else {
219  output = stdout;
220 #if !defined(MSDOS) && !defined(VMS) && !defined(THINK_C)
221  if (pager && isatty(fileno(output))) { /* try to pipe to a pager */
222  if ((output = popen(path, "w")) == NULL) /* get pipe to pager */
223  errorexit(pipcr); /* make output to output */
224  }
225  else
226  pager = FALSE;
227 #endif
228  }
229 
230  dvimain();
231 
232 #if !defined(MSDOS) && !defined(VMS) && !defined(THINK_C)
233  if (pager)
234  pclose(output); /* close pipe to pager */
235 #endif
236 
237  exit(0);
238 
239 } /* main */
240 
241 
242 
243 /*
244  * GETARGS -- Process options from command line and from environment.
245  */
246 
247 void getargs(void)
248 {
249  const char *str;
250  char *envp;
251  bool DVIfound; /* if a dvi filename found */
252 
253 #if !defined(THINK_C)
254  if (Argc <= 1)
255  usage(ign);
256 #endif
257 
258  pageswitchon = FALSE; /* show all pages */
259  sequenceon = FALSE; /* selected pages are TeX-numbered */
260  outputtofile = FALSE; /* write to stdout */
261 #if defined(THINK_C)
262  inputfromfile = FALSE; /* read from stdin */
263 #endif
264 #if !defined(MSDOS) && !defined(VMS) && !defined (THINK_C) && !defined(AMIGA)
265  pager = WANTPAGER; /* want paging, compile time option */
266 #endif
267  accent = TRUE; /* show all accent etc. as extra char */
268  ttfont = FALSE; /* assume tt font (verbatim mode) */
269  noffd = FALSE; /* print formfeed between pages */
270  scascii = DEFSCAND; /* scandinavian, compile time option */
271  latin1 = DEFLATIN1; /* latin1 support, compile time option */
272  utf8 = FALSE; /* print by utf encoding */
273  noligaturefi = FALSE; /* do not use ligature for ff,fi,fl,ffi,ffl */
274  ttywidth = 80; /* default terminal width */
275  espace = 0; /* to fake ttywith calcs */
276  DVIfound = FALSE;
277  printfont = FALSE; /* do not print font switches */
278  compose = TRUE; /* try to compose a combining character sequence */
279  allchar = FALSE; /* do not put out all characters */
280 
281 #if !defined(MSDOS) && !defined(VMS) && !defined(THINK_C) && !defined(AMIGA)
282  if ((path = getenv("PAGER")) == NULL) /* find default pathname of page */
283  path = DEFPAGER; /* program in case paging is wanted */
284 #endif
285 
286  /*
287  *
288  * With VAX-C under VMS getenv normally searches the environment array
289  * looking for the variables HOME, TERM, PATH, and USER. In certain
290  * situations getenv attempts to first perform a logical name translation
291  * if none of the environment array strings are matched and then trying
292  * to translate a CLI symbol. Unfortunately we need a CLI symbol defined
293  * as;
294  *
295  * dvi2tty :== $path:dvi2tty.exe
296  *
297  * to invoke dvi2tty with command line arguments as it would be invoked
298  * under Unix. So we use the logical DVI$DVI2TYY as the environment
299  * variable from which options may be set.
300  *
301  */
302 
303  /*
304  * First process environment variable.
305  */
306 
307 #if defined(VMS)
308  if ((envp = getenv("DVI$DVI2TTY")) != NULL) {
309 #else
310  if ((envp = getenv("DVI2TTY")) != NULL) { /* } keep vi happy */
311 #endif
312  while (*envp == ' ')
313  envp++;
314  while (*envp) { /* environment var args */
315  if (strchr(OPTSET, optch = *envp++) != NULL) {
316  /*
317  * we always pass one option, and arrange for optarg ourselfes,
318  * so setoption does not mesh up Argv
319  */
320  if (strchr(OPTWARG, optch) != NULL) {
321  while (*envp == ' ')
322  envp++;
323  if (*envp == '\0')
324  usage(noarg);
325  str = envp; /* str points to optarg */
326  while ((*envp != ' ') && (*envp != '\0'))
327  envp++; /* set envp just after optarg */
328  if (*envp != '\0')
329  *envp++ = '\0'; /* end optarg string */
330  }
331  else
332  str = "";
333  setoption(str);
334  }
335  else
336  usage(bdopt);
337  while (*envp == ' ')
338  envp++;
339  }
340  }
341 
342  /*
343  * Now process command line options.
344  */
345 
346  while (--Argc > 0) { /* command line args */
347  str = *++Argv;
348  if (*str != '-') { /* argument is not an option */
349  if (DVIfound) /* only one dvi file allowed */
350  usage(onef);
351  getfname(str);
352 #if defined(THINK_C)
353  inputfromfile =
354 #endif
355  DVIfound = TRUE;
356  }
357  else if (strchr(OPTSET, optch = *++str) != NULL) {
358  str++; /* point to rest of argument if any */
359  if ((strchr(OPTWARG, optch) != NULL) && (*str == '\0')) {
360  if (--Argc <= 0)
361  usage(noarg);
362  str = *++Argv;
363  }
364  setoption(str);
365  }
366  else
367  usage(bdopt);
368  }
369 
370  if (!DVIfound)
371 #if defined(THINK_C) /* Allow use of stdin for */
372  if (isatty(fileno(stdin)))
373  usage(nored); /* Mac, if redirected */
374 #else
375  usage(ign);
376 #endif
377 
378  return;
379 
380 } /* getargs */
381 
382 
383 
384 /*
385  * SETOPTION -- Process an option.
386  */
387 
388 void setoption(const char *optarg)
389 {
390  int j = 0;
391 
392  while (strchr(OPTSET, optch) != NULL) {
393  switch (optch) {
394  case 'h' : usage(ign); break;
395 #if !defined(MSDOS) && !defined(VMS) && !defined(THINK_C) && !defined(AMIGA)
396  case 'q' : pager = FALSE; break;
397  case 'f' : pager = TRUE; break;
398  case 'F' : pager = TRUE;
399  path = optarg;
400  j = strlen(optarg);
401  break;
402 #endif
403  case 'J' : jautodetect = TRUE; break;
404  case 'U' : uptex = TRUE; japan = TRUE; /* upTeX */
405  jautodetect = FALSE;
406  enable_UPTEX(true);
408  break;
409  case 'A' : asciip = TRUE; japan = TRUE; /* ASCII pTeX */
410  jautodetect = FALSE;
412  break;
413  case 'N' : nttj = TRUE; japan = TRUE; /* NTT jTeX */
414  jautodetect = FALSE;
416  break;
417  case 'E' :
418  switch (optarg[0]) {
419  case 'e' :
420  set_enc_string ("euc", NULL); break;
421  case 's' :
422  set_enc_string ("sjis", NULL); break;
423  case 'j' :
424  set_enc_string ("jis", NULL); break;
425  case 'u' :
426  utf8 = TRUE;
427  set_enc_string ("utf8", NULL);
428  if (optarg[1]=='1') {
429  noligaturefi = TRUE; j++;
430  }
431  break;
432  default :
433  usage(noarg);
434  }
435  j++;
436  break;
437  case 't' : ttfont = TRUE; break;
438  case 'l' : noffd = TRUE; break;
439  case 's' : scascii ^= 1; break;
440  case 'u' : latin1 ^= 1; break;
441  case 'a' : accent = FALSE; break;
442  case 'C' : compose = FALSE; break;
443  case 'c' : allchar = TRUE; break;
444  case 'P' : sequenceon = TRUE; /* fall through */
445  case 'p' : if (pageswitchon)
446  usage(onepp);
447  getpages(j, optarg);
448  break;
449  case 'w' : if (getinteger(&ttywidth, &j, optarg))
450  usage(nan);
451  if (optarg[j] != '\0')
452  usage(gae);
453  if ((ttywidth < 16) || (ttywidth > MAXTERMWIDTH))
454  usage(wrnge);
455  break;
456  case 'e' : if (getinteger(&espace, &j, optarg))
457  usage(nan);
458  if (optarg[j] != '\0')
459  usage(gae);
460  break;
461  case 'v' : if (getlong(&lineheight, &j, optarg))
462  usage(nan);
463  if (optarg[j] != '\0')
464  usage(gae);
465  /* lineheight *= 65536L; */
466  /* want to specify in pt, but have no getfloat */
467  break;
468  case 'o' : OUTfilename = optarg;
469  outputtofile = TRUE;
470  j = strlen(optarg);
471  break;
472  case 'b' : printfont = TRUE;
473  delim = optarg;
474  if (!strlen(optarg))
475  printfont = FALSE;
476  break;
477  default : usage(bdopt);
478  }
479  if ((optch = optarg[j++]) == '\0')
480  break;
481  if ( (optarg[j] == '\0') && (strchr(OPTWARG, optch) != NULL) ) {
482  if (--Argc <= 0)
483  usage(noarg);
484  optarg = *++Argv;
485  j = 0;
486  }
487  }
488 
489  /* Option conflict */
490  if ((asciip && uptex) ||
491  (nttj && (asciip || uptex)) ||
492  (jautodetect && (nttj || asciip || uptex))) {
493  usage(confl);
494  }
495  if (((jautodetect || asciip || uptex || nttj || utf8)
496  && (scascii || latin1)) ||
497  (scascii && latin1)) {
498  usage(incone);
499  }
500 
501  return;
502 
503 } /* setoption */
504 
505 
506 
507 /*
508  * GETPAGES -- Getr a list of pages to print.
509  */
510 
511 void getpages(int j, const char *str)
512 {
513  int i, c;
514  int num;
515 
516  pageswitchon = TRUE;
517  if ((firstpage = (printlisttype *) malloc(sizeof(printlisttype))) == NULL) {
518  perror("firstpage");
519  exit(1);
520  }
521  firstpage->all = FALSE;
522  firstpage->nxt = nil;
523  firstpage->pag = 0;
526  if (getinteger(&num, &j, str))
527  usage(nan);
528  plcnxt((int) num);
529  while (str[j]) {
530  c = str[j];
531  if (c == ',' || c == ':') {
532  j++;
533  if (getinteger(&num, &j, str))
534  usage(nan);
535  }
536  else
537  break;
538  if (c == ',')
539  plcnxt(num);
540  else {
541  if (currentpage->pag < 0) {
542  if (num > 0) {
543  currentpage->all = TRUE;
544  plcnxt(num);
545  }
546  else if (num < currentpage->pag)
547  for (i = currentpage->pag - 1; i >= num; i--)
548  plcnxt(i);
549  else
550  usage(bdlst);
551  }
552  else {
553  if (num < currentpage->pag)
554  usage(bdlst);
555  for (i = currentpage->pag + 1; i <= num; i++)
556  plcnxt(i);
557  }
558  }
559  }
560  if ((str[j] != ' ') && (str[j] != '\0')) {
561  usage(gae);
562  }
564 
565  return;
566 
567 } /* getpages */
568 
569 
570 
571 /*
572  * PLCNXT -- Place page-nr next in list.
573  */
574 
575 void plcnxt(int pagnr)
576 {
577 
579  currentpage->pag = pagnr;
580  if ((lastpage = (printlisttype *) malloc(sizeof(printlisttype))) == NULL) {
581  perror("lastpage");
582  exit(1);
583  }
584  lastpage->all = FALSE;
585  lastpage->nxt = nil;
586  lastpage->pag = 0;
588 
589  return;
590 
591 } /* plcnxt */
592 
593 
594 
595 /*
596  * GETFNAME -- {Make sure we have a .dvi filename.
597  */
598 
599 void getfname(const char *str)
600 {
601  int i;
602 
603  i = strlen(str);
604  if (i == 0)
605  usage(ign);
606  if ((DVIfilename = (char *) malloc(i+5)) == NULL) {
607  perror("DVIfilename");
608  exit(1);
609  }
611 #ifdef KPATHSEA
612  if (!kpse_readable_file(DVIfilename))
613 #else
614  if ((i < 5) || strcmp(str+i-4, ".dvi"))
615 #endif
616  strcat(DVIfilename, ".dvi");
617 
618  return;
619 
620 } /* getfname */
621 
622 
623 
624 
625 /*
626  * GETINTEGER -- Convert ascii to an integer. I'm sure there is a library
627  * call for it.
628  */
629 
630 int getinteger(int *dest, int *j, const char *str)
631 {
632  int cum;
633  int sgn;
634  char ch;
635 
636  ch = str[*j];
637  if (ch == '-') {
638  sgn = -1;
639  ch = str[++(*j)];
640  }
641  else
642  sgn = 1;
643 
644  if ((ch >= '0') && (ch <= '9')) {
645  cum = 0;
646  while ((ch >= '0') && (ch <= '9')) {
647  cum = cum*10 + ch - '0';
648  ch = str[++(*j)];
649  }
650  *dest = sgn * cum;
651 
652  return 0; /* return ok */
653  }
654 
655  return 1; /* return error */
656 
657 } /* getinteger */
658 
659 
660 
661 /*
662  * GETLONG -- Convert ascii to a long. I'm sure there is a library
663  * call for it.
664  */
665 
666 int getlong(long *dest, int *j, const char *str)
667 {
668  long cum;
669  int sgn;
670  char ch;
671 
672  ch = str[*j];
673  if (ch == '-') {
674  sgn = -1;
675  ch = str[++(*j)];
676  }
677  else
678  sgn = 1;
679 
680  if ((ch >= '0') && (ch <= '9')) {
681  cum = 0;
682  while ((ch >= '0') && (ch <= '9')) {
683  cum = cum*10L + ch - '0';
684  ch = str[++(*j)];
685  }
686  *dest = (long) sgn * cum;
687 
688  return 0; /* return ok */
689  }
690 
691  return 1; /* return error */
692 
693 } /* getinteger */
694 
695 
696 
697 /*
698  * ERROREXIT -- Exit program with an erro message.
699  */
700 
701 void errorexit(int errorcode)
702 {
703 
704  fprintf(stderr, "%s: ", progname);
705  switch (errorcode) {
706  case illop : fprintf(stderr, "Illegal op-code found: %d\n", opcode);
707  break;
708  case stkof : fprintf(stderr, "Stack overflow\n");
709  break;
710  case stkuf : fprintf(stderr, "Stack underflow\n");
711  break;
712  case stkrq : fprintf(stderr, "Cannot create dvi stack\n");
713  break;
714  case lnerq : fprintf(stderr, "Cannot allocate memory\n");
715  break;
716  case badid : fprintf(stderr, "Id-byte is not correct: %d\n ", opcode);
717  break;
718  case bdsgn : fprintf(stderr, "Bad signature: %d (not 223)\n",
719  (int) foo);
720  break;
721  case fwsgn : fprintf(stderr, "%d signature bytes (min. 4)\n",
722  (int) foo);
723  break;
724  case nopre : fprintf(stderr, "Missing preamble\n");
725  break;
726  case nobop : fprintf(stderr, "Missing beginning-of-page command\n");
727  break;
728  case nopp : fprintf(stderr, "Missing post-post command\n");
729  break;
730  case bdpre : fprintf(stderr, "Preamble occured inside a page\n");
731  break;
732  case bdbop : fprintf(stderr, "BOP-command occured inside a page\n");
733  break;
734  case bdpst : fprintf(stderr, "Postamble occured before end-of-page\n");
735  break;
736  case bdpp : fprintf(stderr, "Postpost occured before post-command\n");
737  break;
738  case nopst : fprintf(stderr, "Missing postamble\n");
739  break;
740  case illch : fprintf(stderr, "Character code out of range, 0..127\n");
741  break;
742  case filop : fprintf(stderr, "Cannot open dvifile\n");
743  break;
744  case filcr : fprintf(stderr, "Cannot create outfile\n");
745  break;
746 #if !defined(MSDOS) && !defined(VMS) && !defined(THINK_C) && !defined(AMIGA)
747  case pipcr : fprintf(stderr, "Cannot create pipe to pager\n");
748  break;
749 #endif
750  default : fprintf(stderr, "Unkown error code\n");
751  break;
752  };
753  if (outputtofile)
754 #if defined(VMS)
756 #else
758 #endif
759 
760  exit(errorcode);
761 
762 } /* errorexit */
763 
764 
765 
766 /*
767  * USAGE -- Print the usage info. Also print a warning/error message
768  * if needed.
769  */
770 
771 void usage(int uerr)
772 {
773 
774  if (jautodetect || nttj || asciip || uptex)
775  fprintf(stderr, "%s (%s) %s", Progname, get_enc_string(), Copyright);
776  else
777  fprintf(stderr, "%s %s", Progname, Copyright);
778 
779  if (uerr != ign) {
780  fprintf(stderr,"\n%s: ", progname);
781  switch (uerr) {
782  case wrnge : fprintf(stderr, "width arg out of range:16-%d",
783  MAXTERMWIDTH);
784  break;
785  case nan : fprintf(stderr,
786  "numeric argument expected for option %c",
787  optch);
788  break;
789  case gae : fprintf(stderr, "garbage in argument for option %c",
790  optch);
791  break;
792  case bdlst : fprintf(stderr, "mal-formed list of pagenumbers");
793  break;
794  case onef : fprintf(stderr, "only one infile argument allowed");
795  break;
796  case noarg : fprintf(stderr,
797  "option argument expected for option %c",
798  optch);
799  break;
800  case bdopt : fprintf(stderr, "bad option %c", optch);
801  break;
802  case onepp : fprintf(stderr, "only one pagelist allowed");
803  break;
804  case confl : fprintf(stderr, "-J, -N, -A, and -U are mutually exclusive");
805  break;
806  case incone : fprintf(stderr, "output encoding is not consistent");
807  break;
808 #if defined(THINK_C)
809  case nored : fprintf(stderr, "\nIf no input file is given in\
810  command string,\n\Standard Input must be redirected with the radio button.");
811  break;
812 #endif
813  default : fprintf(stderr, "unknown usage error");
814  break;
815  }
816  fprintf(stderr, "\n");
817  }
818 
819  fprintf(stderr, "\n%s\n\n", dvi2tty);
820 #if defined(THINK_C)
821  fprintf(stderr, "Usage: %s [ options ] [<dvi-file>[.dvi]]\n", progname);
822  fprintf(stderr, "Read input from <dvi-file>, else read from Standard Input,\
823 \nwhich must be redirected by means of the radio button.\n");
824 #else
825  fprintf(stderr, "Usage: %s [ options ] <dvi-file>[.dvi]\n", progname);
826 #endif
827  fprintf(stderr, "Options are:\n");
828  fprintf(stderr,
829  " -ofile Write output to file, else write to stdout.\n");
830  fprintf(stderr,
831  " -plist Print pages whose TeX-page-number are in list.\n");
832  fprintf(stderr,
833  " -Plist Print pages whose sequential number are in list.\n");
834  fprintf(stderr,
835  " -wn Print the lines with width n characters, default 80.\n");
836  fprintf(stderr,
837  " -vn Use n for vertical line height, default 450000.\n");
838  fprintf(stderr,
839  " -evalue Add/Substract this value for spacing (-20..20)\n");
840 #if !defined(MSDOS) && !defined(VMS) && !defined(THINK_C) && !defined(AMIGA)
841  fprintf(stderr, " -f Try to pipe to a pager if output is a tty");
842  if (WANTPAGER)
843  fprintf(stderr, " (default).\n");
844  else
845  fprintf(stderr, ".\n");
846  fprintf(stderr, " -q Don't try to pipe to a pager");
847  if (WANTPAGER)
848  fprintf(stderr, ".\n");
849  else
850  fprintf(stderr, " (default).\n");
851  fprintf(stderr, " -Fprog Pipe output to pager prog.\n");
852 #endif
853  fprintf(stderr,
854  " -a Remove accents grave etc. from output: \\'{e} -> e.\n");
855  fprintf(stderr,
856  " -t Assuming that document was made with tt fonts\n");
857  fprintf(stderr,
858  " -l Write ''^L'' instead of formfeed between pages.\n");
859  fprintf(stderr,
860  " -s Toggle National Swedish/Finnish characters printed as aaoAAO (default %s).\n", DEFSCAND ? "off" : "on");
861  fprintf(stderr,
862  " -u Toggle latin1 support (default %s).\n", DEFLATIN1 ? "on" : "off");
863  fprintf(stderr,
864  " -J Enable auto detect for NTT JTeX, ASCII pTeX, and upTeX (japanese fonts).\n");
865  fprintf(stderr,
866  " -N Support NTT JTeX dvi.\n");
867  fprintf(stderr,
868  " -A Support ASCII pTeX dvi.\n");
869  fprintf(stderr,
870  " -U Support upTeX dvi.\n");
871  fprintf(stderr,
872  " -Eenc Output multibyte encoding. u:UTF8, e:EUC-JP s:Shift_JIS j:JIS\n"
873  " u1:UTF8 (do not use ligature for ff,fi,fl,ffi,ffl).\n");
874  fprintf(stderr,
875  " -C Don't try to compose a combining character sequence.\n");
876  fprintf(stderr,
877  " -c Override -a -u -s and print all characters 0-255.\n");
878  fprintf(stderr,
879  " -bdelim Print font switch as text: delimcmr10miled\n");
880  fprintf(stderr, " -h This help message.\n");
881  fprintf(stderr, "\n If you like this code and want to support is feel free\n to donate at Paypal marcel@mesa.nl. Thanks.\n\n");
882 
883 
884  exit(uerr);
885 
886 } /* usage */
887 
void __cdecl perror(char const *_ErrMsg)
#define accent
Definition: aptex-macros.h:403
Definition: miscutil.h:192
@ FALSE
Definition: dd.h:101
@ TRUE
Definition: dd.h:102
#define fopen
Definition: xxstdio.h:21
#define bdlst
Definition: dvi2tty.c:76
FILE * DVIfile
Definition: dvi2tty.c:99
#define gae
Definition: dvi2tty.c:75
#define bdopt
Definition: dvi2tty.c:78
int getinteger(int *dest, int *j, const char *str)
Definition: dvi2tty.c:630
bool outputtofile
Definition: dvi2tty.c:101
#define OPTSET
Definition: dvi2tty.c:64
int Argc
Definition: dvi2tty.c:114
#define OPTWARG
Definition: dvi2tty.c:65
int espace
Definition: dvi2tty.c:106
const char * path
Definition: dvi2tty.c:111
void usage(int uerr)
Definition: dvi2tty.c:771
int main(int argc, char **argv)
Definition: dvi2tty.c:160
const char * OUTfilename
Definition: dvi2tty.c:117
void errorexit(int errorcode)
Definition: dvi2tty.c:701
printlisttype * lastpage
Definition: dvi2tty.c:97
int getlong(long *dest, int *j, const char *str)
Definition: dvi2tty.c:666
void plcnxt(int pagnr)
Definition: dvi2tty.c:575
#define ign
Definition: dvi2tty.c:73
void getfname(const char *str)
Definition: dvi2tty.c:599
int ttywidth
Definition: dvi2tty.c:105
#define DEFLATIN1
Definition: dvi2tty.c:52
bool pager
Definition: dvi2tty.c:110
#define nan
Definition: dvi2tty.c:74
long foo
Definition: dvi2tty.c:108
#define onef
Definition: dvi2tty.c:77
#define noarg
Definition: dvi2tty.c:80
void getpages(int j, const char *str)
Definition: dvi2tty.c:511
printlisttype * currentpage
Definition: dvi2tty.c:95
#define WANTPAGER
Definition: dvi2tty.c:54
#define wrnge
Definition: dvi2tty.c:72
void getargs(void)
Definition: dvi2tty.c:247
char ** Argv
Definition: dvi2tty.c:115
char * progname
Definition: dvi2tty.c:113
void setoption(const char *optarg)
Definition: dvi2tty.c:388
char * DVIfilename
Definition: dvi2tty.c:116
#define confl
Definition: dvi2tty.c:81
const char * dvi2tty
Definition: dvi2tty.c:92
printlisttype * firstpage
Definition: dvi2tty.c:96
#define onepp
Definition: dvi2tty.c:79
#define incone
Definition: dvi2tty.c:82
#define DEFSCAND
Definition: dvi2tty.c:50
#define DEFPAGER
Definition: dvi2tty.c:56
FILE * output
Definition: dvi2tty.c:100
char optch
Definition: dvi2tty.c:118
bool scascii
Definition: dvistuff.c:143
#define illch
Definition: dvi2tty.h:93
#define nopre
Definition: dvi2tty.h:85
#define pipcr
Definition: dvi2tty.h:97
#define Progname
Definition: dvi2tty.h:23
bool printfont
Definition: dvistuff.c:160
#define bdpst
Definition: dvi2tty.h:90
#define fwsgn
Definition: dvi2tty.h:84
bool noffd
Definition: dvistuff.c:158
#define nopst
Definition: dvi2tty.h:92
#define lnerq
Definition: dvi2tty.h:81
bool noligaturefi
Definition: dvistuff.c:146
bool allchar
Definition: dvistuff.c:162
#define Copyright
Definition: dvi2tty.h:24
#define JTEX_INTERNAL_ENC
Definition: dvi2tty.h:65
#define bdsgn
Definition: dvi2tty.h:83
#define illop
Definition: dvi2tty.h:77
#define stkof
Definition: dvi2tty.h:78
bool sequenceon
Definition: dvistuff.c:142
#define nil
Definition: dvi2tty.h:53
long lineheight
Definition: dvistuff.c:177
#define bdpp
Definition: dvi2tty.h:91
#define stkrq
Definition: dvi2tty.h:80
#define badid
Definition: dvi2tty.h:82
#define stkuf
Definition: dvi2tty.h:79
bool jautodetect
Definition: dvistuff.c:154
bool asciip
Definition: dvistuff.c:151
#define nopp
Definition: dvi2tty.h:87
bool pageswitchon
Definition: dvistuff.c:141
#define PTEX_INTERNAL_ENC
Definition: dvi2tty.h:68
#define nobop
Definition: dvi2tty.h:86
bool uptex
Definition: dvistuff.c:152
#define filcr
Definition: dvi2tty.h:95
bool nttj
Definition: dvistuff.c:150
#define UPTEX_INTERNAL_ENC
Definition: dvi2tty.h:71
bool japan
Definition: dvistuff.c:153
#define bdpre
Definition: dvi2tty.h:88
#define bdbop
Definition: dvi2tty.h:89
bool ttfont
Definition: dvistuff.c:148
#define filop
Definition: dvi2tty.h:94
void dvimain(void)
Definition: dvistuff.c:286
#define MAXTERMWIDTH
Definition: dvi2tty.h:59
bool compose
Definition: dvistuff.c:161
const char * delim
Definition: dvistuff.c:159
bool latin1
Definition: dvistuff.c:144
int strcmp()
Definition: coll.cpp:143
char * strcpy()
@ VERSION
Definition: genrb.cpp:69
int sgn(const __gmp_expr< T, U > &expr)
Definition: gmpxx.h:3350
#define c(n)
Definition: gpos-common.c:150
#define strchr
Definition: gsftopk.c:59
#define NULL
Definition: ftobjs.h:61
small capitals from c petite p scientific i
Definition: afcover.h:80
void exit()
char * optarg
Definition: getopt.c:42
char * getenv()
int num
Definition: disdvi.c:621
#define unlink(file)
Definition: config.h:413
#define popen(cmd, mode)
Definition: mingw32.h:91
#define fileno
Definition: win32lib.h:72
#define pclose(file)
Definition: win32lib.h:271
#define isatty
Definition: win32lib.h:80
#define fprintf
Definition: mendex.h:64
FILE * enc
Definition: encoding.c:64
const_string get_enc_string(void)
Definition: ptexenc.c:171
void enable_UPTEX(boolean enable)
Definition: ptexenc.c:149
boolean set_enc_string(const_string file_str, const_string internal_str)
Definition: ptexenc.c:185
#define malloc
Definition: alloca.c:91
#define dest
int remove()
#define _O_BINARY
Definition: lfs.c:127
int foo
Definition: printf.c:190
utf< uint8 > utf8
Definition: UtfCodec.h:249
#define str(s)
Definition: sh6.c:399
Definition: output.h:18
Definition: tpic.c:45
int pag
Definition: dvi2tty.h:109
struct prlistptr * nxt
Definition: dvi2tty.h:112
bool all
Definition: dvi2tty.h:110
#define FILE
Definition: t1stdio.h:34
ch
Definition: t4ht.c:1443
int j
Definition: t4ht.c:1589
*job_name strlen((char *) job_name) - 4)
#define argv
Definition: xmain.c:270
#define argc
Definition: xmain.c:269