1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
/*
* Hand-coded routines for C TeX.
* This module should contain any system-dependent code.
*/
#define CATCHINT /* Catch ^C's */
#define EXTERN /* Actually instantiate globals here */
#include <signal.h>
#include <time.h>
#include <stdio.h>
#include "site.h"
#define BUF_SIZE 100 /* should agree with tangle.web */
extern char buffer[]; /* 0..BUF_SIZE. Input goes here */
extern char outbuf[]; /* 0..OUT_BUF_SIZE. Output from here */
extern char xord[], xchr[]; /* character translation arrays */
extern int limit;
#ifdef SYSV
#define index strchr /* Sys V compatibility */
extern int sprintf();
#else
extern char *sprintf();
#endif
/* C library stuff that we're going to use */
extern char *strcpy(), *strcat(), *malloc(), *index(), *getenv();
/* Local stuff */
static int gargc;
integer argc;
static char **gargv;
#define TRUE 1
#define FALSE 0
/*
* Get things going under Unix: set up for rescanning the command line,
* then call the main body.
*/
main(iargc, iargv)
int iargc;
char *iargv[];
{
gargc=argc=iargc;
gargv=iargv;
main_body();
}
/* Return the nth argument into the string s (which is indexed starting at 1) */
argv(n,s)
integer n;
char s[];
{
(void) sprintf(s+1, "%s ", gargv[n]);
}
/* Same as in Pascal --- return TRUE if EOF or next char is newline */
eoln(f)
FILE *f;
{
register int c;
if (feof(f)) return(TRUE);
c = getc(f);
if (c != EOF)
(void) ungetc(c, f);
return (c == '\n' || c == EOF);
}
/* Open a file; don't return if error */
FILE *openf(name, mode)
char *name, *mode;
{
FILE *result;
char *index(), *cp;
cp = index(name, ' ');
if (cp) *cp = '\0';
result = fopen(name, mode);
if (result) return(result);
perror(name);
exit(1);
/*NOTREACHED*/
}
|