-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathODInEx1.c
2519 lines (2184 loc) · 90 KB
/
ODInEx1.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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* OpenDoors Online Software Programming Toolkit
* (C) Copyright 1991 - 1999 by Brian Pirie.
*
* Oct-2001 door32.sys/socket modifications by Rob Swindell (www.synchro.net)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*
* File: ODInEx1.c
*
* Description: Performs OpenDoors initialization and shutdown operations
* (od_init() and od_exit()), including drop file I/O. This
* module is broken into two files, ODInEx1.c and ODInEx2.c.
*
* Revisions: Date Ver Who Change
* ---------------------------------------------------------------
* Oct 13, 1994 6.00 BP New file header format.
* Oct 19, 1994 6.00 BP Default paging hours 8:00-22:00.
* Oct 21, 1994 6.00 BP Further isolated com routines.
* Oct 29, 1994 6.00 BP Properly read dorinfo?.def BBS name.
* Oct 31, 1994 6.00 BP Only use dorinfo?.def /w exitinfo.bbs.
* Dec 09, 1994 6.00 BP Standardized coding style.
* Dec 31, 1994 6.00 BP Remove call to _mt_init().
* Dec 31, 1994 6.00 BP Add call to ODPlatInit().
* Jul 30, 1995 6.00 BP Split up od_init().
* Nov 11, 1995 6.00 BP Removed register keyword.
* Nov 14, 1995 6.00 BP Added include of odscrn.h.
* Nov 14, 1995 6.00 BP New default for od_colour_char is 0.
* Nov 16, 1995 6.00 BP Removed oddoor.h, added odcore.h.
* Nov 17, 1995 6.00 BP Use new input queue mechanism.
* Nov 23, 1995 6.00 BP Moved Pascal conversion to odutil.c.
* Dec 21, 1995 6.00 BP Add ability to use already open port.
* Dec 22, 1995 6.00 BP Added od_connect_speed.
* Dec 30, 1995 6.00 BP Added ODCALL for calling convention.
* Dec 30, 1995 6.00 BP Only use comm idle func under DOS.
* Jan 01, 1996 6.00 BP Added od_disable_dtr.
* Jan 01, 1996 6.00 BP Raise DTR after opening serial port.
* Jan 02, 1996 6.00 BP Use printf() in ODInitError().
* Jan 03, 1996 6.00 BP Display connect speed with %lu.
* Jan 19, 1996 6.00 BP Don't use atexit() under Win32.
* Jan 19, 1996 6.00 BP Make ODInitError() a shared function.
* Jan 20, 1996 6.00 BP Prompt for user name if force_local.
* Jan 23, 1996 6.00 BP Added od_exiting and OD_TEXTMODE.
* Jan 31, 1996 6.00 BP Added DIS_NAME_PROMPT.
* Jan 31, 1996 6.00 BP Support new SFDOORS.DAT format.
* Feb 02, 1996 6.00 BP Added RA 2.50 EXITINFO.BBS support.
* Feb 06, 1996 6.00 BP Added od_silent_mode.
* Feb 08, 1996 6.00 BP Recognize SFSYSOP.DAT.
* Feb 09, 1996 6.00 BP Correctly translate RA 2.x sex field.
* Feb 09, 1996 6.00 BP Made default outbound buffer 3072.
* Feb 19, 1996 6.00 BP Changed version number to 6.00.
* Feb 20, 1996 6.00 BP Added bParsedCmdLine.
* Feb 21, 1996 6.00 BP Don't override command line options.
* Feb 21, 1996 6.00 BP Change od_always_clear default to on.
* Feb 23, 1996 6.00 BP Changed default DTR disable string.
* Mar 03, 1996 6.10 BP Begin version 6.10.
* Mar 06, 1996 6.10 BP Added TRIBBS.SYS support.
* Mar 06, 1996 6.10 BP Initial support for Door32 interface.
* Mar 13, 1996 6.10 BP Added od_local_win_col.
* Mar 17, 1996 6.10 BP Reset text color after local login.
* Mar 19, 1996 6.10 BP MSVC15 source-level compatibility.
* Apr 08, 1996 6.10 BP Store local login name in user_handle.
* Jan 13, 1997 6.10 BP Fixes for Door32 support.
* Oct 19, 2001 6.20 RS Added door32.sys and socket support.
* Aug 10, 2003 6.23 SH *nix support
*/
#define BUILDING_OPENDOORS
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <ctype.h>
#include <time.h>
#include "OpenDoor.h"
#ifdef ODPLAT_NIX
#include <termios.h>
#include <unistd.h>
#include <sys/types.h>
#include <pwd.h>
#endif
#include "ODStr.h"
#include "ODCore.h"
#include "ODGen.h"
#include "ODScrn.h"
#include "ODInQue.h"
#include "ODKrnl.h"
#include "ODInEx.h"
#include "ODUtil.h"
#ifdef ODPLAT_WIN32
#include "ODFrame.h"
#include "ODRes.h"
#endif /* ODPLAT_WIN32 */
/* Default size of local/remote combined keyboard buffer. */
#define DEFAULT_EVENT_QUEUE_SIZE 128
/* Local private helper functions. */
static void ODInitReadExitInfo(void);
static void ODInitPartTwo(void);
static BOOL ODInitReadSFDoorsDAT(void);
static void ODInitPartTwo(void);
/* Private variables. */
static BYTE btRAStatusToSet = 0;
#ifndef ODPLAT_WIN32
static BOOL bPreset = TRUE;
#endif /* !ODPLAT_WIN32 */
static char szIFTemp[256];
/* Configuration file keywords. */
static char *apszConfigText[] =
{
"Node",
"BBSDir",
"DoorDir",
"LogFileName",
"DisableLogging",
"SundayPagingHours",
"MondayPagingHours",
"TuesdayPagingHours",
"WednesdayPagingHours",
"ThursdayPagingHours",
"FridayPagingHours",
"SaturdayPagingHours",
"MaximumDoorTime",
"SysopName",
"SystemName",
"SwappingDisable",
"SwappingDir",
"SwappingNoEMS",
"LockedBPS",
"SerialPort",
"CustomFileName",
"CustomFileLine",
"InactivityTimeout",
"PageDuration",
"ChatUserColour",
"ChatSysopColour",
"FileListTitleColour",
"FileListNameColour",
"FileListSizeColour",
"FileListDescriptionColour",
"FileListOfflineColour",
"Personality",
"NoFossil",
"PortAddress",
"PortIRQ",
"ReceiveBuffer",
"TransmitBuffer",
"PagePromptColour",
"LocalMode",
"PopupMenuTitleColour",
"PopupMenuBorderColour",
"PopupMenuTextColour",
"PopupMenuKeyColour",
"PopupMenuHighlightColour",
"PopupMenuHighKeyColour",
"NoFIFO",
"FIFOTriggerSize",
"DisableDTR",
"NoDTRDisable",
};
/* Custom drop file keywords. */
static char *apszConfigLines[] =
{
"Ignore",
"ComPort",
"FossilPort",
"ModemBPS",
"LocalMode",
"UserName",
"UserFirstName",
"UserLastName",
"Alias",
"HoursLeft",
"MinutesLeft",
"SecondsLeft",
"ANSI",
"AVATAR",
"PagePausing",
"ScreenLength",
"ScreenClearing",
"Security",
"City",
"Node",
"SysopName",
"SysopFirstName",
"SysopLastName",
"SystemName",
"RIP",
};
/* Logfile messages. */
static char *apszLogMessages[] =
{
"Carrier lost, exiting door",
"System operator terminating call, exiting door",
"User's time limit expired, exiting door",
"User keyboard inactivity time limit exceeded, exiting door",
"System operator returning user to BBS, exiting door",
"Exiting door with errorlevel %d",
"Invoking operating system shell",
"Returning from operating system shell",
"User paging system operator",
"Entering sysop chat mode",
"Terminating sysop chat mode",
"%s entering door",
"Reason for chat: %s",
"Exiting door",
};
/* Color name strings. */
static char *apszColorNames[] =
{
"BLACK",
"BLUE",
"GREEN",
"CYAN",
"RED",
"MAGENTA",
"YELLOW",
"WHITE",
"BROWN",
"GREY",
"BRIGHT",
"FLASHING",
};
/* Array of door information (drop) file names to search for. */
static char *apszDropFileNames[] =
{
"exitinfo.bbs",
"dorinfo1.def",
"chain.txt",
"sfdoors.dat",
"door.sys",
"callinfo.bbs",
"sfmain.dat",
"sffile.dat",
"sfmess.dat",
"sfsysop.dat",
"tribbs.sys",
"door32.sys",
};
/* Array of door information (drop) file numbers
* (corresponding to apszDropFileNames)
*/
enum {
FOUND_EXITINFO_BBS,
FOUND_DORINFO1_DEF,
FOUND_CHAIN_TXT,
FOUND_SFDOORS_DAT,
FOUND_DOOR_SYS,
FOUND_CALLINFO_BBS,
FOUND_SFMAIN_DAT,
FOUND_SFFILE_DAT,
FOUND_SFMESS_DAT,
FOUND_SFSYSOP_DAT,
FOUND_TRIBBS_SYS,
FOUND_DOOR32_SYS,
};
#define FOUND_NONE -1
/* Global variables. */
WORD wODNodeNumber = 65535U;
BOOL bIsCoSysop;
BOOL bIsSysop;
char *apszDropFileInfo[25];
BYTE btExitReason = 0;
DWORD dwForcedBPS = 1;
INT nForcedPort = -1;
DWORD dwFileBPS;
char szDropFilePath[120];
char szExitinfoBBSPath[120];
INT16 nInitialElapsed;
char *szOriginalDir = NULL;
BYTE btDoorSYSLock = 0;
time_t nStartupUnixTime;
INT16 nInitialRemaining;
BOOL bSysopNameSet = FALSE;
char szForcedSysopName[40];
BOOL bSystemNameSet = FALSE;
char szForcedSystemName[40];
BOOL bUserFull = FALSE;
BOOL bCalledFromConfig = FALSE;
tRA2ExitInfoRecord *pRA2ExitInfoRecord = NULL;
tExitInfoRecord *pExitInfoRecord = NULL;
tExtendedExitInfo *pExtendedExitInfo = NULL;
struct _pcbsys *pPCBoardSysRecord = NULL;
struct _userssyshdr *pUserSysHeader = NULL;
struct _userssysrec *pUserSysRecord = NULL;
BOOL bPreOrExit = FALSE;
BOOL bRAStatus;
BOOL bPromptForUserName = FALSE;
BOOL bParsedCmdLine = FALSE;
WORD wPreSetInfo = 0;
#ifdef ODPLAT_WIN32
tODThreadHandle hFrameThread;
#endif /* ODPLAT_WIN32 */
/* ----------------------------------------------------------------------------
* od_init()
*
* Starts up OpenDoors. Initializes various members of od_control, reads the
* BBS door information (drop file), initializes the serial port and carries
* out other operations that must be done at initialization time. May be
* explicitly called by the user, or called as a result of the first call to
* some other OpenDoors API function.
*
* Parameters: none
*
* Return: void
*/
ODAPIDEF void ODCALL od_init(void)
{
BYTE btCount;
FILE *pfDropFile=NULL;
char *pointer;
INT nFound = FOUND_NONE;
#ifdef _WIN32
float forcefloats;
forcefloats=1.1;
#endif
/* Log function entry if running in trace mode. */
TRACE(TRACE_API, "od_init()");
/* If a callback function is active, then don't do anything. */
if(bIsCallbackActive) return;
/* If we are not being called from within ODConfigInit(). */
if(!bCalledFromConfig)
{
/* If OpenDoors has already been initialized, then return without */
/* doing anything. */
if(bODInitialized) return;
/* Otherwise, set the initialized flag so that od_init() won't be */
/* run again. */
bODInitialized = TRUE;
/* Initialize program name string. */
if(od_control.od_prog_name[0] == '\0')
{
strcpy(od_control.od_prog_name, OD_VER_SHORTNAME);
}
/* Initialize color name strings in od_control. */
for(btCount = 0; btCount < DIM(apszColorNames); ++btCount)
{
if(!*od_control.od_color_names[btCount])
{
strcpy(od_control.od_color_names[btCount],
apszColorNames[btCount]);
}
}
/* Initialize custom drop file strings in od_control. */
for(btCount = 0; btCount < LINES_SIZE; ++btCount)
{
if(!*od_control.od_cfg_lines[btCount])
{
strcpy(od_control.od_cfg_lines[btCount], apszConfigLines[btCount]);
}
}
/* Initialize configuration keyword strings in od_control. */
for(btCount = 0; btCount < TEXT_SIZE; ++btCount)
{
if(!*od_control.od_cfg_text[btCount])
{
strcpy(od_control.od_cfg_text[btCount], apszConfigText[btCount]);
}
}
/* Enable multiple personality system if it has been installed. */
#ifdef OD_TEXTMODE
if(od_control.od_mps != NULL)
{
(*(OD_COMPONENT_CALLBACK *)od_control.od_mps)();
}
#endif /* !OD_TEXTMODE */
/* If baud rate has been set in od_control, then remember the forced */
/* rate for later use. */
if(od_control.baud != 0)
{
dwForcedBPS = od_control.baud;
}
/* If the serial port number has already been set in od_control, then */
/* remember the forced port number for later use. */
if(od_control.port != 0)
{
nForcedPort = od_control.port;
}
/* If the configuration file system has been installed, then allow */
/* the configuration file initialization routine take over */
/* initialization from here. Once it has read the configuration file */
/* it will call od_init() again, at which time od_init() will carry */
/* on from this point in the code. */
if(od_control.config_file != NULL)
{
(*(OD_COMPONENT_CALLBACK *)od_control.config_file)();
return;
}
}
/* Initialize the OpenDoors platform-specific utility functions. */
ODPlatInit();
/* Store the time of door startup. */
time(&nStartupUnixTime);
/* Allocate the set of strings that are used to store certain parts */
/* of drop files for rewriting at od_exit() time. */
for(btCount = 0; btCount < DIM(apszDropFileInfo); ++btCount)
{
if((apszDropFileInfo[btCount] = (char *)malloc(81)) == NULL)
{
malloc_error:
ODInitError("Insufficient memory available to start up program.");
exit(od_control.od_errorlevel[1]);
}
}
/* Determine the current node number. */
if((pointer=getenv("TASK")) != NULL)
{
od_control.od_node = atoi(pointer);
}
else if((pointer=getenv("SBBSNNUM")) != NULL)
{
od_control.od_node = atoi(pointer);
}
else if(wODNodeNumber != 65535U)
{
od_control.od_node = wODNodeNumber;
}
else if(od_control.od_node == 0)
{
od_control.od_node = 1;
}
/* If a custom drop file format is not being used, then set certain */
/* od_control members to their default values. In the case where */
/* a custom drop file format is being used, these values will already */
/* have been set, and so we don't want to touch them. */
if(od_control.od_info_type != CUSTOM)
{
od_control.user_avatar = FALSE;
od_control.user_rip = FALSE;
od_control.user_attribute = 0x06;
od_control.user_screen_length = 23;
od_control.user_screenwidth = 80;
od_control.od_page_pausing = TRUE;
od_control.od_page_len = 15;
}
else
{
/* When a custom drop file is being used, there are certain */
/* variables that we must initialize if they weren't already set */
/* when the custom drop file was read. */
if(od_control.user_timelimit == 0) od_control.user_timelimit = 60;
#ifdef ODPLAT_NIX
if(od_control.port == -1) od_control.baud = 1L;
#else
if(od_control.port == -1) od_control.baud = 0L;
#endif
}
/* Setup inbound local/remote buffer. */
if(ODInQueueAlloc(&hODInputQueue, od_control.od_in_buf_size == 0 ?
DEFAULT_EVENT_QUEUE_SIZE : od_control.od_in_buf_size) != kODRCSuccess)
{
goto malloc_error;
}
/* Enable user's keyboard by default. */
od_control.od_user_keyboard_on = TRUE;
/* If door information (drop) file reading has been disabled, then */
/* don't attempt to read any drop file. */
if(od_control.od_disable & DIS_INFOFILE)
{
od_control.od_info_type = NO_DOOR_FILE;
}
/* Otherwise, if the local mode override has been explicitly asked for, */
/* setup od_control for default local mode operation. */
else if(od_control.od_force_local)
{
force_local:
/* No door information file is being used. */
od_control.od_info_type = NO_DOOR_FILE;
/* Operate in local mode. */
#ifdef ODPLAT_NIX
od_control.baud = 1L;
#else
od_control.baud = 0L;
#endif
if(!bParsedCmdLine)
{
/* Enable ANSI mode. */
od_control.user_ansi = TRUE;
/* Default to 60 minutes of time available. */
od_control.user_timelimit = 60;
}
/* Choose the appropriate system name. */
if(bSystemNameSet)
{
strcpy(od_control.user_location, szForcedSystemName);
}
else if(od_control.system_name[0] != '\0')
{
strcpy(od_control.user_location, od_control.system_name);
}
else
{
strcpy(od_control.user_location, "Unknown Location");
}
}
/* If drop file reading isn't disable, if a custom format drop file */
/* hasn't already been read and automatic local mode hasn't been */
/* specified, then attempt to find and read a standard drop file. */
else if(od_control.od_info_type != CUSTOM)
{
/* Generate the name of the dorinfox.def file for this node. */
if(od_control.od_node > 35)
{
apszDropFileNames[1] = (char *)"dorinfo1.def";
}
else if(od_control.od_node > 9)
{
sprintf(szIFTemp, "dorinfo%c.def", od_control.od_node + 55);
apszDropFileNames[1] = (char *)szIFTemp;
}
else
{
sprintf(szIFTemp, "dorinfo%d.def", od_control.od_node);
apszDropFileNames[1] = (char *)szIFTemp;
}
nFound = FOUND_NONE;
if(!ODFileAccessMode(od_control.info_path, 4))
{
/* Check for a DORINFOx.DEF filename. */
if(ODStringHasTail(od_control.info_path, ".def") &&
strlen(od_control.info_path) >= strlen(apszDropFileNames[2]) &&
strnicmp((char *)&od_control.info_path +
(strlen(od_control.info_path) - 12), "dorinfo", 7) == 0)
{
nFound = FOUND_DORINFO1_DEF;
strcpy(szDropFilePath, od_control.info_path);
}
else
{
/* Check filenames other than DORINFOx.DEF */
for(btCount = 0; btCount < DIM(apszDropFileNames); ++btCount)
{
if(ODStringHasTail(od_control.info_path,
apszDropFileNames[btCount]))
{
strcpy(szDropFilePath, od_control.info_path);
nFound = btCount;
break;
}
}
}
}
/* Search for a door information file. */
if(nFound == FOUND_NONE)
{
nFound = ODSearchForDropFile((char **)&apszDropFileNames,
DIM(apszDropFileNames), (char *)&szDropFilePath,
(char *)&szExitinfoBBSPath);
}
if(nFound == FOUND_EXITINFO_BBS)
{
od_control.od_info_type = NO_DOOR_FILE;
ODInitReadExitInfo();
if(od_control.od_info_type == NO_DOOR_FILE)
{
goto DropFileFail;
}
ODMakeFilename(szODWorkString, szExitinfoBBSPath, "dorinfo1.def",
sizeof(szExitinfoBBSPath));
if((pfDropFile = fopen(szODWorkString, "r")) == NULL)
{
goto DropFileFail;
}
goto read_dorinfox;
}
else if(nFound==FOUND_DORINFO1_DEF)
{
/* Open DORINFO?.DEF. */
if((pfDropFile = fopen(szDropFilePath, "r")) == NULL) goto DropFileFail;
/* Set door type to DORINFO. */
od_control.od_info_type = DORINFO1;
read_dorinfox:
/* If not able to read first line. */
if(fgets(szIFTemp, 255, pfDropFile) == NULL)
{
goto DropFileFail;
}
if(szIFTemp[strlen(szIFTemp) - 1] == '\n')
{
szIFTemp[strlen(szIFTemp) - 1] = '\0';
}
if(szIFTemp[strlen(szIFTemp) - 1] == '\r')
{
szIFTemp[strlen(szIFTemp) - 1] = '\0';
}
strncpy(od_control.system_name, szIFTemp, 39);
od_control.system_name[39] = '\0';
/* get sysop name from DORINFO1.DEF */
if(fgets(szIFTemp, 255, pfDropFile) == NULL) goto DropFileFail;
ODStringToName(szIFTemp);
strncpy(od_control.sysop_name, szIFTemp, 19);
/* get sysop's last name */
if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
ODStringToName(szIFTemp);
if(strlen(szIFTemp))
{
strcat(od_control.sysop_name," ");
strncat(od_control.sysop_name,szIFTemp,19);
}
/* get com port that modem is connected to */
if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
od_control.port=szIFTemp[3]-'1';
/* determine BPS rate of connection */
if(fgets((char *)apszDropFileInfo[0],255,pfDropFile)==NULL) goto DropFileFail;
#ifdef ODPLAT_NIX
od_control.baud= (od_control.port == -1) ? 1 : atol((char *)apszDropFileInfo[0]);
#else
od_control.baud= (od_control.port == -1) ? 0 : atol((char *)apszDropFileInfo[0]);
#endif
if(fgets((char *)apszDropFileInfo[1],80,pfDropFile)==NULL) goto DropFileFail;
/* get user's first name */
if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
ODStringToName(szIFTemp);
strncpy(od_control.user_name,szIFTemp,17);
/* get user's last name */
if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
ODStringToName(szIFTemp);
if(strlen(szIFTemp))
{
strcat(od_control.user_name," ");
strncat(od_control.user_name,szIFTemp,17);
}
/* get user's location */
if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
ODStringToName(szIFTemp);
strncpy(od_control.user_location,szIFTemp,25);
/* get ANSI mode settings */
if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
if(szIFTemp[0]=='0') od_control.user_ansi=FALSE;
else od_control.user_ansi=TRUE;
/* get user security level */
if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
od_control.user_security=atoi(szIFTemp);
/* get time left in door */
if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
od_control.user_timelimit=atoi(szIFTemp);
fclose(pfDropFile);
}
/* Read CHAIN.TXT */
else if(nFound==FOUND_CHAIN_TXT)
{
if((pfDropFile=fopen(szDropFilePath,"r"))==NULL) goto DropFileFail;
od_control.od_info_type=CHAINTXT;
if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
od_control.user_num=atoi(szIFTemp);
if(fgets((char *)&od_control.user_handle,35,pfDropFile)==NULL) goto DropFileFail;
ODStringToName(od_control.user_handle);
if(fgets((char *)&od_control.user_name,35,pfDropFile)==NULL) goto DropFileFail;
ODStringToName(od_control.user_name);
if(fgets((char *)&od_control.user_callsign,12,pfDropFile)==NULL) goto DropFileFail;
ODStringToName(od_control.user_callsign);
if(fgets((char *)apszDropFileInfo[0],80,pfDropFile)==NULL) goto DropFileFail;
if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
od_control.user_sex=szIFTemp[0];
if(fgets((char *)apszDropFileInfo[1],80,pfDropFile)==NULL) goto DropFileFail;
if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
strncpy(od_control.user_lastdate,szIFTemp,8);
if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
od_control.user_screenwidth=atoi(szIFTemp);
if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
od_control.user_screen_length=atoi(szIFTemp);
if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
od_control.user_security=atoi(szIFTemp);
if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
bIsSysop=atoi(szIFTemp);
if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
bIsCoSysop=atoi(szIFTemp);
if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
od_control.user_ansi=atoi(szIFTemp);
if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail; /* non-zero if remote */
if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
od_control.user_timelimit=atoi(szIFTemp);
od_control.user_timelimit/=60;
if(fgets((char *)apszDropFileInfo[3],80,pfDropFile)==NULL) goto DropFileFail;
if(fgets((char *)apszDropFileInfo[4],80,pfDropFile)==NULL) goto DropFileFail;
if(fgets((char *)apszDropFileInfo[5],80,pfDropFile)==NULL) goto DropFileFail;
if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
if(strcmp(szIFTemp,"KB")==0)
{
#ifdef ODPLAT_NIX
od_control.baud=1;
#else
od_control.baud=0;
#endif
}
else
{
od_control.baud=atol(szIFTemp);
}
if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
od_control.port=atoi(szIFTemp)-1;
if(fgets((char *)apszDropFileInfo[6],80,pfDropFile)==NULL) goto DropFileFail;
if(fgets((char *)&od_control.user_password,15,pfDropFile)==NULL) goto DropFileFail;
ODStringToName(od_control.user_password);
if(fgets((char *)apszDropFileInfo[2],80,pfDropFile)==NULL) goto DropFileFail;
if(fgets((char *)apszDropFileInfo[7],80,pfDropFile)==NULL) goto DropFileFail;
if(fgets((char *)apszDropFileInfo[8],80,pfDropFile)==NULL) goto DropFileFail;
if(fgets((char *)apszDropFileInfo[9],80,pfDropFile)==NULL) goto DropFileFail;
if(fgets((char *)apszDropFileInfo[10],80,pfDropFile)==NULL) goto DropFileFail;
if(fgets((char *)apszDropFileInfo[11],80,pfDropFile)==NULL) goto DropFileFail;
if(fgets((char *)apszDropFileInfo[12],80,pfDropFile)==NULL) goto DropFileFail;
fclose(pfDropFile);
}
else if(nFound == FOUND_SFDOORS_DAT
|| nFound == FOUND_SFMAIN_DAT
|| nFound == FOUND_SFFILE_DAT
|| nFound == FOUND_SFMESS_DAT
|| nFound == FOUND_SFSYSOP_DAT)
{
od_control.od_info_type = SFDOORSDAT;
if(!ODInitReadSFDoorsDAT())
{
goto DropFileFail;
}
}
else if(nFound==FOUND_DOOR_SYS)
{
if((pfDropFile=fopen(szDropFilePath,"r"))==NULL) goto DropFileFail;
/* Read line 1. */
if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
if(szIFTemp[0]=='C' && szIFTemp[1]=='O' && szIFTemp[2]=='M' && szIFTemp[4]==':')
{ /* GAP style DOOR.SYS */
od_control.od_info_type=DOORSYS_GAP;
od_control.port=szIFTemp[3]-'1';
/* Check for COM0:STDIO */
if(!strncmp(szIFTemp,"COM0:STDIO",10))
od_control.od_com_method=COM_STDIO;
/* Check for COM0:SOCKET### */
if(!strncmp(szIFTemp,"COM0:SOCKET",11)) {
od_control.od_com_method=COM_SOCKET;
od_control.od_use_socket = TRUE;
od_control.od_open_handle=atoi(szIFTemp+11);
}
/* Check for COM0:HANDLE### */
if(!strncmp(szIFTemp,"COM0:HANDLE",11)) {
od_control.od_com_method=COM_WIN32;
od_control.od_open_handle=atoi(szIFTemp+11);
}
/* Read line 2. */
if(fgets((char *)apszDropFileInfo[0], 80, pfDropFile) == NULL)
{
goto DropFileFail;
}
od_control.od_connect_speed = atol(apszDropFileInfo[0]);
/* Read line 3. */
if(fgets((char *)apszDropFileInfo[1],80,pfDropFile)==NULL) goto DropFileFail;
/* Read line 4. */
if(fgets(szIFTemp, 255, pfDropFile) == NULL) goto DropFileFail;
od_control.od_node = atoi(szIFTemp);
/* Read line 5. */
if(fgets(szIFTemp, 255, pfDropFile) == NULL) goto DropFileFail;
strupr(szIFTemp);
if(strchr(szIFTemp, 'N') != NULL)
{
btDoorSYSLock = 1;
od_control.baud = atol(apszDropFileInfo[0]);
}
else if(strchr(szIFTemp, 'Y') != NULL)
{
btDoorSYSLock = 2;
od_control.baud = 19200;
}
else
{
od_control.baud = atol(szIFTemp);
}
#ifdef ODPLAT_NIX
if(od_control.port == -1) od_control.baud = 1L;
#else
if(od_control.port == -1) od_control.baud = 0L;
#endif
/* Read line 6. */
if(fgets((char *)apszDropFileInfo[3],80,pfDropFile)==NULL) goto DropFileFail;
/* Read line 7. */
if(fgets((char *)apszDropFileInfo[4],80,pfDropFile)==NULL) goto DropFileFail;
/* Read line 8. */
if(fgets((char *)apszDropFileInfo[5],80,pfDropFile)==NULL) goto DropFileFail;
/* Read line 9. */
if(fgets((char *)apszDropFileInfo[22],80,pfDropFile)==NULL) goto DropFileFail;
/* Read line 10. */
if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
szIFTemp[35]='\0';
ODStringToName(szIFTemp);
strcpy(od_control.user_name,szIFTemp);
/* Read line 11. */
if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
szIFTemp[25]='\0';
if(szIFTemp[strlen(szIFTemp)-1]=='\n') szIFTemp[strlen(szIFTemp)-1]='\0';
if(szIFTemp[strlen(szIFTemp)-1]=='\r') szIFTemp[strlen(szIFTemp)-1]='\0';
strcpy(od_control.user_location,szIFTemp);
/* Read line 12. */
if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
szIFTemp[15]='\0';
ODStringToName(szIFTemp);
strcpy(od_control.user_homephone,szIFTemp);
/* Read line 13. */
if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
szIFTemp[15]='\0';
ODStringToName(szIFTemp);
strcpy(od_control.user_dataphone,szIFTemp);
/* Read line 14. */
if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
szIFTemp[15]='\0';
if(szIFTemp[strlen(szIFTemp)-1]=='\n') szIFTemp[strlen(szIFTemp)-1]='\0';
if(szIFTemp[strlen(szIFTemp)-1]=='\r') szIFTemp[strlen(szIFTemp)-1]='\0';
strcpy(od_control.user_password,szIFTemp);
/* Read line 15. */
if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
od_control.user_security=atoi(szIFTemp);
/* Read line 16. */
if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
od_control.user_numcalls=atoi(szIFTemp);
/* Read line 17. */
if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
szIFTemp[15]='\0';
ODStringToName(szIFTemp);
strcpy(od_control.user_lastdate,szIFTemp);
/* Read line 18. */
if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
/* Read line 19. */
if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
od_control.user_timelimit=atoi(szIFTemp);
/* Read line 20. */
if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
strupr(szIFTemp);
if(!strcmp(szIFTemp,"RIP"))
{
od_control.user_rip=TRUE;
od_control.user_ansi=TRUE;
}
else if(szIFTemp[0]=='G')
{
od_control.user_rip=FALSE;
od_control.user_ansi=TRUE;
}
else
{
od_control.user_rip=FALSE;
od_control.user_ansi=FALSE;
}
/* Read line 21. */
if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
od_control.user_screen_length=atoi(szIFTemp);
/* Read line 22. */
if(fgets((char *)apszDropFileInfo[8],80,pfDropFile)==NULL) goto DropFileFail;
/* Read line 23. */
if(fgets((char *)apszDropFileInfo[9],80,pfDropFile)==NULL) goto DropFileFail;
if(apszDropFileInfo[9][strlen(apszDropFileInfo[9])-1]!='\n')
{
int ch;
apszDropFileInfo[9][strlen(apszDropFileInfo[9])-1]='\n';
do
{
ch = fgetc(pfDropFile);
} while(ch != '\n' && ch != EOF);
}
/* Read line 24. */
again:
if(fgets((char *)apszDropFileInfo[10],80,pfDropFile)==NULL) goto DropFileFail;
if(strchr(apszDropFileInfo[10],',')!=NULL) goto again;
/* Read line 25. */
if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
szIFTemp[15]='\0';
ODStringToName(szIFTemp);
strcpy(od_control.user_subdate,szIFTemp);
/* Read line 26. */
if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
od_control.user_num=atoi(szIFTemp);