-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPUPMAIN.C
182 lines (147 loc) · 5.16 KB
/
PUPMAIN.C
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
#include <puppy.h>
#include <ascii.h>
#include <driver.h> /* MSDOS */
struct _pup pup; /* main system file */
struct _clr caller; /* current caller logged in */
struct _msg *msg; /* msg base index */
FLAG test; /* 1 == test mode, (no modem) */
FLAG localin; /* 1 == simultaneous keyboards */
BYTE lmtstate; /* 0 - 2, caller time limit warning state */
int limit; /* time limit in force, or 0 for no limit */
int klimit; /* download limit in force */
/* Local system shit */
FLAG abort; /* True if ^C typed. */
FLAG doscode; /* DOS error code */
char column; /* column number, */
char line;
char months[13][4] = { /* table of month names */
"Eh?","Jan","Feb","Mar","Apr","May","Jun","Jul",
"Aug","Sep","Oct","Nov","Dec"
};
/* XMODEM protocol module */
int totl_files; /* how many failed, */
int totl_errors; /* error count, soft errors incl */
int totl_blocks; /* number blocks sent, */
char crcmode; /* 1 if CRC mode, */
char filemode; /* transfer type; XMODEM, MODEM7, TELINK */
/* Modem variables */
WORD linkrate; /* baud rate to/from modem */
WORD datarate; /* baud rate to/from caller */
FLAG cd_flag; /* true == ignore CD line */
extern WORD cd_bit; /* MSDOS driver: bit to test for Carrier Detect, */
extern WORD iodev; /* MSDOS driver: serial channel number */
/* Local text buffer */
char *text; /* work buffer */
unsigned textsize; /* and its size */
extern long sizmem(); /* MSDOS */
extern char *getmem(); /* MSDOS */
/*************************************************************
These are DUMMIES so I can leave out the
FidoNet code until it is working.
**************************************************************/
get_pkt() {} /* dummy */
put_pkt() {} /* dummy */
main(argc,argv)
int argc;
char **argv;
{
int i,n;
FLAG evtmsg; /* 1 == we announced upcoming event */
FLAG rdymsg; /* 1 == we announced "waiting ... " */
FLAG mdmmsg; /* 1 == we initialized the modem */
printf("Pup bulletin board, version 2a, 23 Dec 87\r\n");
printf("Tom Jennings, 164 Shipley\r\n");
printf("San Francisco CA 94107 USA\r\n");
printf("(k) all rights reversed\r\n");
test= 0; /* not test mode */
i= open("puppy.sys",0); /* load the system file */
if (i == -1) {
printf("Can't find PUPPY.SYS\r\n");
exit(1);
}
read(i,&pup,sizeof(struct _pup)); /* read it in, */
close(i);
iodev= pup.iodev; /* MSDOS stuff the drivers */
cd_bit= pup.cd_bit; /* MSDOS with setup info */
allmem(); /* MSDOS get all available memory */
textsize= sizmem(); /* MSDOS how much mem we have */
text= getmem(textsize); /* MSDOS get it all, */
i= pup.messages * sizeof(struct _msg);
if (i > textsize) { /* allocate room for msg index */
printf("You have too many messages!\r\n");
exit(1);
}
msg= (struct _msg *) text; /* ptr to message file index */
textsize -= i; /* account for it, */
text += i; /* advance the pointer */
if (pup.msgsize > textsize) { /* room for message entry */
printf("Message-size is too big!\r\n");
exit(1);
}
/*
*************** The Big Loop. **************
*/
set_clk(); /* install clock */
init(); /* start up hardware, */
evtmsg= 0; /* no event warning yet */
rdymsg= 0; /* no ready message yet */
mdmmsg= 0; /* no modem init */
while (doscode == 0) { /* exit-to-DOS code */
switch (keyhit()) { /* poll the keyboard */
case '?':
printf("\"L\" Login to Pup\r\n");
printf("\"I\" Init the modem\r\n");
printf("^C Return to DOS\r\n");
rdymsg= 0;
break;
case ETX: doscode= 1; break;
case 'i': case 'I': /* Init modem */
mdmmsg= 0;
rdymsg= 0;
break;
case 'l': case 'L': /* Local Login */
test= 1; /* do test mode */
puppy(); /* take the pup for a WOC */
test= 0;
rdymsg= 0;
break;
}
if (doscode) break;
i= til_sched('?',0,0); /* ask the scheduler whats up */
if (i != -1) { /* if an event NOW */
if (pup.sched[i].tag == 'X') {
doscode= pup.sched[i].len;
markevt(i); /* flag it as run */
printf("Pup says: \"Event #%d X ERRORLEVEL %d\"\r\n",i,doscode);
break; /* terminate Big Loop */
}
printf("Pup says: \"FidoNet %c\"\r\n",pup.sched[i].tag);
evtmsg= 0; /* need messages */
rdymsg= 0;
mdmmsg= 0;
continue; /* check for more events, etc */
}
i= til_sched('?',10,0); /* ask the scheduler whats up */
if (i != -1) { /* if an event within 10 minutes */
if (! evtmsg) printf("Pup says: \"Event within 10 minutes\"\r\n");
evtmsg= 1;
continue; /* no modem/caller stuff */
}
if (! mdmmsg) {
mdmmsg= 1;
rdymsg= 0;
init_modem(pup.mdmstr); /* wake up the modem */
}
if (! rdymsg) printf("Pup says: \"Waiting for something to do (?=help)\"\r\n");
rdymsg= 1;
/* OK, no events etc. If the phone rings, answer it. If TSYNC is received
during the signon process, it drops into Incoming Mail. */
if (answer() > 0) { /* if an incoming call, */
puppy();
rdymsg= 0;
}
}
reset_clk(); /* turn off clock, */
if (! test) uninit(); /* always ints off, etc */
exit(doscode); /* back to DOS */
}