1 /*
2  *  INIT.C
3  *
4  *  Written on 10-Jul-94 by John Dennis and released to the public domain.
5  *
6  *  Handles sub-system initialisation for Msged.
7  */
8 
9 #include <stdio.h>
10 #include <stdlib.h>
11 #include <string.h>
12 #include <time.h>
13 #include "addr.h"
14 #include "nedit.h"
15 #include "msged.h"
16 #include "fido.h"
17 #include "quick.h"
18 #ifdef USE_MSGAPI
19 #include "msg.h"
20 #endif
21 #include "winsys.h"
22 #define INCL_MAIN
23 #include "main.h"
24 #include "memextra.h"
25 
26 struct _sv *string_vars;
27 struct _swv *switch_vars;
28 
29 msghandle msgdo[] =
30 {
31     {
32         FidoMsgReadHeader,
33         FidoMsgReadText,
34         FidoMsgWriteHeader,
35         FidoMsgWriteText,
36         FidoMsgDelete,
37         FidoAreaSetLast,
38         FidoMsgAreaOpen,
39         FidoMsgAreaClose,
40         FidoMsgClose,
41         FidoUidToMsgn,
42         FidoMsgnToUid,
43         FidoMsgLock,
44         FidoMsgUnlock
45     },
46     {
47         QuickMsgReadHeader,
48         QuickMsgReadText,
49         QuickMsgWriteHeader,
50         QuickMsgWriteText,
51         QuickMsgDelete,
52         QuickAreaSetLast,
53         QuickMsgAreaOpen,
54         QuickMsgAreaClose,
55         QuickMsgClose,
56         QuickUidToMsgn,
57         QuickMsgnToUid,
58         QuickMsgLock,
59         QuickMsgUnlock
60     }
61 #ifdef USE_MSGAPI
62     ,
63     {
64         SquishMsgReadHeader,
65         SquishMsgReadText,
66         SquishMsgWriteHeader,
67         SquishMsgWriteText,
68         SquishMsgDelete,
69         SquishAreaSetLast,
70         SquishMsgAreaOpen,
71         SquishMsgAreaClose,
72         SquishMsgClose,
73         SquishUidToMsgn,
74         SquishMsgnToUid,
75         SquishMsgLock,
76         SquishMsgUnlock
77     },
78     {                           /* JAM uses same routines as Squish,     */
79                                 /* because both are handled by the SMAPI */
80         SquishMsgReadHeader,
81         SquishMsgReadText,
82         SquishMsgWriteHeader,
83         JamMsgWriteText,
84         SquishMsgDelete,
85         SquishAreaSetLast,
86         SquishMsgAreaOpen,
87         SquishMsgAreaClose,
88         JamMsgClose,
89         SquishUidToMsgn,
90         SquishMsgnToUid,
91         SquishMsgLock,
92         SquishMsgUnlock
93     }
94 
95 #endif
96 };
97 
98 D_LIST *node_lists = NULL;      /* the nodelists recognized by the system */
99 AREA *arealist = NULL;          /* list of areas */
100 ALIAS *aliaslist = NULL;        /* list of aliases */
101 FIDO_ADDRESS *domain_list = NULL; /* list of domain-gates */
102 FIDO_ADDRESS *alias = NULL;     /* list of akas */
103 msg *message = NULL;            /* current message */
104 char **templates = NULL;        /* templates in system */
105 char **origins = NULL;          /* origins for the origin shuffler */
106 int n_origins = 0;              /* number of origins */
107 USER user_list[MAXUSERS];       /* list of users */
108 FIDO_ADDRESS uucp_gate;         /* the uucp gate */
109 
110 unsigned int *macros[41];       /* function key macros + 1 for autostart */
111 int maxx = 80;                  /* maximum screen columns */
112 int maxy = 25;                  /* maximum screen rows */
113 int maxx_force = 0;
114 int maxy_force = 0;
115 int rot13;
116 int stripSoft = 0;
117 int softcrxlat = 0;
118 
119 #ifndef READMAPSDAT
120 #ifdef UNIX
121 #define READMAPSDAT "~/.msged.readmaps"
122 #define WRITMAPSDAT "~/.msged.writmaps"
123 #else
124 #define READMAPSDAT "readmaps.dat"
125 #define WRITMAPSDAT "writmaps.dat"
126 #endif
127 #endif
128 
InitVars(void)129 int InitVars(void)
130 {
131     /* Allocate some memory & initialize it. */
132 
133     msgbuf = xmalloc(BUFLEN);
134 
135     string_vars = xmalloc(sizeof(struct _sv));
136     switch_vars = xmalloc(sizeof(struct _swv));
137 
138     memset(string_vars, 0, sizeof(struct _sv));
139     memset(switch_vars, 0, sizeof(struct _swv));
140     memset(user_list, 0, sizeof(user_list));
141     memset(macros, 0, sizeof(macros));
142 
143     /* Initialize all the variables to default values. */
144 
145     SW->gate = GASK;
146     SW->orgrm = 0x7FFF; /* allow any margin */
147     SW->orgqm = 75;     /* don't make quote lines too large */
148     SW->tabsize = 4;
149     SW->use_lastr = YES;
150     SW->qquote = YES;
151     SW->msgids = YES;
152     SW->opusdate = NO;
153     SW->shownotes = NO;
154     SW->showseenbys = NO;
155     SW->showorigins = YES;
156     SW->showtearlines = YES;
157     SW->confirmations = YES;
158     SW->datearrived = YES;
159     SW->redraw = YES;
160     SW->showaddr = YES;
161     SW->rawcc = YES;
162     SW->savecc = YES;
163     SW->hardquote = YES;
164     SW->chopquote = NO;
165     SW->showcr = NO;
166     SW->showeol = NO;
167     SW->showrealmsgn = NO;
168     SW->usemouse = YES;
169     SW->tabexpand = YES;
170     SW->editcronly = NO;
171     SW->usepid = NO;
172     SW->soteot = NO;
173     SW->showtime = NO;
174     SW->importfn = YES;
175     SW->dmore = NO;
176     SW->statbar = YES;
177     SW->rquote = MT_QUO;
178     SW->rotharea = MT_QUO | MT_ARC;
179     SW->rfollow = MT_QUO | MT_FOL;
180     SW->rextra = MT_QUO | MT_FOL | MT_ARC;
181     SW->showsystem = YES;
182     SW->extformat = YES;
183     SW->arealistexactmatch = YES;
184     SW->echoflags = YES;
185     SW->netmailvia = YES;
186     SW->domainorigin = YES;
187     SW->rightnextunreadarea = NO;
188     SW->usetearlines = YES;
189     SW->useoriginlines = YES;
190     SW->edittearlines = NO;
191     SW->editoriginlines = NO;
192     SW->squish_lock = NO;
193     SW->lowercase = NO;
194     SW->adaptivecase = NO;
195     SW->receiveallnames = YES;
196     SW->receivealladdr  = YES;
197     SW->carthy = YES;
198     SW->direct_list = NO;
199     SW->areadesc = DSCTAGASIS | DSCDESCASIS;
200     SW->areadefinesuser = NO;
201     SW->group = 0;
202     SW->groupareas = 0;
203     SW->groupseparators = YES;
204     SW->areafilegroups = 1;
205     SW->domainmsgid = 1;
206     SW->tzutc = 1;
207     SW->xxltearline = 0;
208 
209 #ifndef UNIX
210     ST->comspec = getenv("COMSPEC");
211 #else
212     ST->comspec = getenv("SHELL");
213 #endif
214     ST->outfile = xstrdup("msged.txt");
215     ST->infile  = NULL;
216     ST->quotestr = xstrdup(" > ");
217     ST->echotoss = xstrdup("echotoss.log");
218     ST->lastread = xstrdup("lastread");
219     ST->cfgfile = xstrdup("msged.cfg");
220     ST->uucpgate = xstrdup("UUCP");
221     ST->editorName = NULL;
222     ST->quickbbs = NULL;
223     ST->nodebase = NULL;
224     ST->sysop = NULL;
225     ST->output_charset = NULL;
226     ST->input_charset = NULL;
227     ST->enforced_charset = NULL;
228     ST->sort_criteria = NULL;
229     ST->freqarea = NULL;
230     ST->special_characters = NULL;
231     ST->uucpreplyto = NULL;
232     ST->freqflags = NULL;
233     ST->printer = NULL;
234     ST->readmap  = xstrdup(READMAPSDAT);
235     ST->writemap = xstrdup(WRITMAPSDAT);
236 
237     uucp_gate.notfound = 1;
238 
239     return OK;
240 }
241 
DeinitMem(void)242 void DeinitMem(void)
243 {
244     release(origins);
245     n_origins = 0;
246 
247     if (string_vars != NULL)
248     {
249         release(string_vars->readmap);
250         release(string_vars->writemap);
251     }
252     release(switch_vars);
253     release(string_vars);
254 
255     release(msgbuf);
256 }
257 
258