ODInEx1.c 91 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541
  1. /* OpenDoors Online Software Programming Toolkit
  2. * (C) Copyright 1991 - 1999 by Brian Pirie.
  3. *
  4. * Oct-2001 door32.sys/socket modifications by Rob Swindell (www.synchro.net)
  5. *
  6. * This library is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 2 of the License, or (at your option) any later version.
  10. *
  11. * This library is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with this library; if not, write to the Free Software
  18. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  19. *
  20. *
  21. * File: ODInEx1.c
  22. *
  23. * Description: Performs OpenDoors initialization and shutdown operations
  24. * (od_init() and od_exit()), including drop file I/O. This
  25. * module is broken into two files, ODInEx1.c and ODInEx2.c.
  26. *
  27. * Revisions: Date Ver Who Change
  28. * ---------------------------------------------------------------
  29. * Oct 13, 1994 6.00 BP New file header format.
  30. * Oct 19, 1994 6.00 BP Default paging hours 8:00-22:00.
  31. * Oct 21, 1994 6.00 BP Further isolated com routines.
  32. * Oct 29, 1994 6.00 BP Properly read dorinfo?.def BBS name.
  33. * Oct 31, 1994 6.00 BP Only use dorinfo?.def /w exitinfo.bbs.
  34. * Dec 09, 1994 6.00 BP Standardized coding style.
  35. * Dec 31, 1994 6.00 BP Remove call to _mt_init().
  36. * Dec 31, 1994 6.00 BP Add call to ODPlatInit().
  37. * Jul 30, 1995 6.00 BP Split up od_init().
  38. * Nov 11, 1995 6.00 BP Removed register keyword.
  39. * Nov 14, 1995 6.00 BP Added include of odscrn.h.
  40. * Nov 14, 1995 6.00 BP New default for od_colour_char is 0.
  41. * Nov 16, 1995 6.00 BP Removed oddoor.h, added odcore.h.
  42. * Nov 17, 1995 6.00 BP Use new input queue mechanism.
  43. * Nov 23, 1995 6.00 BP Moved Pascal conversion to odutil.c.
  44. * Dec 21, 1995 6.00 BP Add ability to use already open port.
  45. * Dec 22, 1995 6.00 BP Added od_connect_speed.
  46. * Dec 30, 1995 6.00 BP Added ODCALL for calling convention.
  47. * Dec 30, 1995 6.00 BP Only use comm idle func under DOS.
  48. * Jan 01, 1996 6.00 BP Added od_disable_dtr.
  49. * Jan 01, 1996 6.00 BP Raise DTR after opening serial port.
  50. * Jan 02, 1996 6.00 BP Use printf() in ODInitError().
  51. * Jan 03, 1996 6.00 BP Display connect speed with %lu.
  52. * Jan 19, 1996 6.00 BP Don't use atexit() under Win32.
  53. * Jan 19, 1996 6.00 BP Make ODInitError() a shared function.
  54. * Jan 20, 1996 6.00 BP Prompt for user name if force_local.
  55. * Jan 23, 1996 6.00 BP Added od_exiting and OD_TEXTMODE.
  56. * Jan 31, 1996 6.00 BP Added DIS_NAME_PROMPT.
  57. * Jan 31, 1996 6.00 BP Support new SFDOORS.DAT format.
  58. * Feb 02, 1996 6.00 BP Added RA 2.50 EXITINFO.BBS support.
  59. * Feb 06, 1996 6.00 BP Added od_silent_mode.
  60. * Feb 08, 1996 6.00 BP Recognize SFSYSOP.DAT.
  61. * Feb 09, 1996 6.00 BP Correctly translate RA 2.x sex field.
  62. * Feb 09, 1996 6.00 BP Made default outbound buffer 3072.
  63. * Feb 19, 1996 6.00 BP Changed version number to 6.00.
  64. * Feb 20, 1996 6.00 BP Added bParsedCmdLine.
  65. * Feb 21, 1996 6.00 BP Don't override command line options.
  66. * Feb 21, 1996 6.00 BP Change od_always_clear default to on.
  67. * Feb 23, 1996 6.00 BP Changed default DTR disable string.
  68. * Mar 03, 1996 6.10 BP Begin version 6.10.
  69. * Mar 06, 1996 6.10 BP Added TRIBBS.SYS support.
  70. * Mar 06, 1996 6.10 BP Initial support for Door32 interface.
  71. * Mar 13, 1996 6.10 BP Added od_local_win_col.
  72. * Mar 17, 1996 6.10 BP Reset text color after local login.
  73. * Mar 19, 1996 6.10 BP MSVC15 source-level compatibility.
  74. * Apr 08, 1996 6.10 BP Store local login name in user_handle.
  75. * Jan 13, 1997 6.10 BP Fixes for Door32 support.
  76. * Oct 19, 2001 6.20 RS Added door32.sys and socket support.
  77. * Aug 10, 2003 6.23 SH *nix support
  78. */
  79. #define BUILDING_OPENDOORS
  80. #include <stdio.h>
  81. #include <stdlib.h>
  82. #include <stdarg.h>
  83. #include <string.h>
  84. #include <ctype.h>
  85. #include <time.h>
  86. #include "OpenDoor.h"
  87. #ifdef ODPLAT_NIX
  88. #include <termios.h>
  89. #include <unistd.h>
  90. #include <sys/types.h>
  91. #include <pwd.h>
  92. #endif
  93. #include "ODStr.h"
  94. #include "ODCore.h"
  95. #include "ODGen.h"
  96. #include "ODScrn.h"
  97. #include "ODInQue.h"
  98. #include "ODKrnl.h"
  99. #include "ODInEx.h"
  100. #include "ODUtil.h"
  101. #ifdef ODPLAT_WIN32
  102. #include "ODFrame.h"
  103. #include "ODRes.h"
  104. #endif /* ODPLAT_WIN32 */
  105. /* Default size of local/remote combined keyboard buffer. */
  106. #define DEFAULT_EVENT_QUEUE_SIZE 128
  107. /* Local private helper functions. */
  108. static void ODInitReadExitInfo(void);
  109. static void ODInitPartTwo(void);
  110. static BOOL ODInitReadSFDoorsDAT(void);
  111. static void ODInitPartTwo(void);
  112. /* Private variables. */
  113. static BYTE btRAStatusToSet = 0;
  114. #ifndef ODPLAT_WIN32
  115. static BOOL bPreset = TRUE;
  116. #endif /* !ODPLAT_WIN32 */
  117. static char szIFTemp[256];
  118. /* Configuration file keywords. */
  119. static char *apszConfigText[] =
  120. {
  121. "Node",
  122. "BBSDir",
  123. "DoorDir",
  124. "LogFileName",
  125. "DisableLogging",
  126. "SundayPagingHours",
  127. "MondayPagingHours",
  128. "TuesdayPagingHours",
  129. "WednesdayPagingHours",
  130. "ThursdayPagingHours",
  131. "FridayPagingHours",
  132. "SaturdayPagingHours",
  133. "MaximumDoorTime",
  134. "SysopName",
  135. "SystemName",
  136. "SwappingDisable",
  137. "SwappingDir",
  138. "SwappingNoEMS",
  139. "LockedBPS",
  140. "SerialPort",
  141. "CustomFileName",
  142. "CustomFileLine",
  143. "InactivityTimeout",
  144. "PageDuration",
  145. "ChatUserColour",
  146. "ChatSysopColour",
  147. "FileListTitleColour",
  148. "FileListNameColour",
  149. "FileListSizeColour",
  150. "FileListDescriptionColour",
  151. "FileListOfflineColour",
  152. "Personality",
  153. "NoFossil",
  154. "PortAddress",
  155. "PortIRQ",
  156. "ReceiveBuffer",
  157. "TransmitBuffer",
  158. "PagePromptColour",
  159. "LocalMode",
  160. "PopupMenuTitleColour",
  161. "PopupMenuBorderColour",
  162. "PopupMenuTextColour",
  163. "PopupMenuKeyColour",
  164. "PopupMenuHighlightColour",
  165. "PopupMenuHighKeyColour",
  166. "NoFIFO",
  167. "FIFOTriggerSize",
  168. "DisableDTR",
  169. "NoDTRDisable",
  170. };
  171. /* Custom drop file keywords. */
  172. static char *apszConfigLines[] =
  173. {
  174. "Ignore",
  175. "ComPort",
  176. "FossilPort",
  177. "ModemBPS",
  178. "LocalMode",
  179. "UserName",
  180. "UserFirstName",
  181. "UserLastName",
  182. "Alias",
  183. "HoursLeft",
  184. "MinutesLeft",
  185. "SecondsLeft",
  186. "ANSI",
  187. "AVATAR",
  188. "PagePausing",
  189. "ScreenLength",
  190. "ScreenClearing",
  191. "Security",
  192. "City",
  193. "Node",
  194. "SysopName",
  195. "SysopFirstName",
  196. "SysopLastName",
  197. "SystemName",
  198. "RIP",
  199. };
  200. /* Logfile messages. */
  201. static char *apszLogMessages[] =
  202. {
  203. "Carrier lost, exiting door",
  204. "System operator terminating call, exiting door",
  205. "User's time limit expired, exiting door",
  206. "User keyboard inactivity time limit exceeded, exiting door",
  207. "System operator returning user to BBS, exiting door",
  208. "Exiting door with errorlevel %d",
  209. "Invoking operating system shell",
  210. "Returning from operating system shell",
  211. "User paging system operator",
  212. "Entering sysop chat mode",
  213. "Terminating sysop chat mode",
  214. "%s entering door",
  215. "Reason for chat: %s",
  216. "Exiting door",
  217. };
  218. /* Color name strings. */
  219. static char *apszColorNames[] =
  220. {
  221. "BLACK",
  222. "BLUE",
  223. "GREEN",
  224. "CYAN",
  225. "RED",
  226. "MAGENTA",
  227. "YELLOW",
  228. "WHITE",
  229. "BROWN",
  230. "GREY",
  231. "BRIGHT",
  232. "FLASHING",
  233. };
  234. /* Array of door information (drop) file names to search for. */
  235. static char *apszDropFileNames[] =
  236. {
  237. "exitinfo.bbs",
  238. "dorinfo1.def",
  239. "chain.txt",
  240. "sfdoors.dat",
  241. "door.sys",
  242. "callinfo.bbs",
  243. "sfmain.dat",
  244. "sffile.dat",
  245. "sfmess.dat",
  246. "sfsysop.dat",
  247. "tribbs.sys",
  248. "door32.sys",
  249. };
  250. /* Array of door information (drop) file numbers
  251. * (corresponding to apszDropFileNames)
  252. */
  253. enum {
  254. FOUND_EXITINFO_BBS,
  255. FOUND_DORINFO1_DEF,
  256. FOUND_CHAIN_TXT,
  257. FOUND_SFDOORS_DAT,
  258. FOUND_DOOR_SYS,
  259. FOUND_CALLINFO_BBS,
  260. FOUND_SFMAIN_DAT,
  261. FOUND_SFFILE_DAT,
  262. FOUND_SFMESS_DAT,
  263. FOUND_SFSYSOP_DAT,
  264. FOUND_TRIBBS_SYS,
  265. FOUND_DOOR32_SYS,
  266. };
  267. #define FOUND_NONE -1
  268. /* Global variables. */
  269. WORD wODNodeNumber = 65535U;
  270. BOOL bIsCoSysop;
  271. BOOL bIsSysop;
  272. char *apszDropFileInfo[25];
  273. BYTE btExitReason = 0;
  274. DWORD dwForcedBPS = 1;
  275. INT nForcedPort = -1;
  276. DWORD dwFileBPS;
  277. char szDropFilePath[120];
  278. char szExitinfoBBSPath[120];
  279. INT16 nInitialElapsed;
  280. char *szOriginalDir = NULL;
  281. BYTE btDoorSYSLock = 0;
  282. time_t nStartupUnixTime;
  283. INT16 nInitialRemaining;
  284. BOOL bSysopNameSet = FALSE;
  285. char szForcedSysopName[40];
  286. BOOL bSystemNameSet = FALSE;
  287. char szForcedSystemName[40];
  288. BOOL bUserFull = FALSE;
  289. BOOL bCalledFromConfig = FALSE;
  290. tRA2ExitInfoRecord *pRA2ExitInfoRecord = NULL;
  291. tExitInfoRecord *pExitInfoRecord = NULL;
  292. tExtendedExitInfo *pExtendedExitInfo = NULL;
  293. struct _pcbsys *pPCBoardSysRecord = NULL;
  294. struct _userssyshdr *pUserSysHeader = NULL;
  295. struct _userssysrec *pUserSysRecord = NULL;
  296. BOOL bPreOrExit = FALSE;
  297. BOOL bRAStatus;
  298. BOOL bPromptForUserName = FALSE;
  299. BOOL bParsedCmdLine = FALSE;
  300. WORD wPreSetInfo = 0;
  301. #ifdef ODPLAT_WIN32
  302. tODThreadHandle hFrameThread;
  303. #endif /* ODPLAT_WIN32 */
  304. static void strcopydate(char *dest, char *src) {
  305. if (strlen(src) == 9) {
  306. strcpy(dest, src);
  307. } else if (strlen(src) == 11) {
  308. dest[0] = src[0];
  309. dest[1] = src[1];
  310. dest[2] = src[2];
  311. dest[3] = src[3];
  312. dest[4] = src[4];
  313. dest[5] = src[5];
  314. dest[6] = src[9];
  315. dest[7] = src[10];
  316. dest[8] = '\0';
  317. } else {
  318. strcpy(dest, "01-01-71");
  319. }
  320. }
  321. /* ----------------------------------------------------------------------------
  322. * od_init()
  323. *
  324. * Starts up OpenDoors. Initializes various members of od_control, reads the
  325. * BBS door information (drop file), initializes the serial port and carries
  326. * out other operations that must be done at initialization time. May be
  327. * explicitly called by the user, or called as a result of the first call to
  328. * some other OpenDoors API function.
  329. *
  330. * Parameters: none
  331. *
  332. * Return: void
  333. */
  334. ODAPIDEF void ODCALL od_init(void)
  335. {
  336. BYTE btCount;
  337. FILE *pfDropFile=NULL;
  338. char *pointer;
  339. INT nFound = FOUND_NONE;
  340. #ifdef _WIN32
  341. float forcefloats;
  342. forcefloats=1.1;
  343. #endif
  344. /* Log function entry if running in trace mode. */
  345. TRACE(TRACE_API, "od_init()");
  346. /* If a callback function is active, then don't do anything. */
  347. if(bIsCallbackActive) return;
  348. /* If we are not being called from within ODConfigInit(). */
  349. if(!bCalledFromConfig)
  350. {
  351. /* If OpenDoors has already been initialized, then return without */
  352. /* doing anything. */
  353. if(bODInitialized) return;
  354. /* Otherwise, set the initialized flag so that od_init() won't be */
  355. /* run again. */
  356. bODInitialized = TRUE;
  357. /* Initialize program name string. */
  358. if(od_control.od_prog_name[0] == '\0')
  359. {
  360. strcpy(od_control.od_prog_name, OD_VER_SHORTNAME);
  361. }
  362. /* Initialize color name strings in od_control. */
  363. for(btCount = 0; btCount < DIM(apszColorNames); ++btCount)
  364. {
  365. if(!*od_control.od_color_names[btCount])
  366. {
  367. strcpy(od_control.od_color_names[btCount],
  368. apszColorNames[btCount]);
  369. }
  370. }
  371. /* Initialize custom drop file strings in od_control. */
  372. for(btCount = 0; btCount < LINES_SIZE; ++btCount)
  373. {
  374. if(!*od_control.od_cfg_lines[btCount])
  375. {
  376. strcpy(od_control.od_cfg_lines[btCount], apszConfigLines[btCount]);
  377. }
  378. }
  379. /* Initialize configuration keyword strings in od_control. */
  380. for(btCount = 0; btCount < TEXT_SIZE; ++btCount)
  381. {
  382. if(!*od_control.od_cfg_text[btCount])
  383. {
  384. strcpy(od_control.od_cfg_text[btCount], apszConfigText[btCount]);
  385. }
  386. }
  387. /* Enable multiple personality system if it has been installed. */
  388. #ifdef OD_TEXTMODE
  389. if(od_control.od_mps != NULL)
  390. {
  391. (*(OD_COMPONENT_CALLBACK *)od_control.od_mps)();
  392. }
  393. #endif /* !OD_TEXTMODE */
  394. /* If baud rate has been set in od_control, then remember the forced */
  395. /* rate for later use. */
  396. if(od_control.baud != 0)
  397. {
  398. dwForcedBPS = od_control.baud;
  399. }
  400. /* If the serial port number has already been set in od_control, then */
  401. /* remember the forced port number for later use. */
  402. if(od_control.port != 0)
  403. {
  404. nForcedPort = od_control.port;
  405. }
  406. /* If the configuration file system has been installed, then allow */
  407. /* the configuration file initialization routine take over */
  408. /* initialization from here. Once it has read the configuration file */
  409. /* it will call od_init() again, at which time od_init() will carry */
  410. /* on from this point in the code. */
  411. if(od_control.config_file != NULL)
  412. {
  413. (*(OD_COMPONENT_CALLBACK *)od_control.config_file)();
  414. return;
  415. }
  416. }
  417. /* Initialize the OpenDoors platform-specific utility functions. */
  418. ODPlatInit();
  419. /* Store the time of door startup. */
  420. time(&nStartupUnixTime);
  421. /* Allocate the set of strings that are used to store certain parts */
  422. /* of drop files for rewriting at od_exit() time. */
  423. for(btCount = 0; btCount < DIM(apszDropFileInfo); ++btCount)
  424. {
  425. if((apszDropFileInfo[btCount] = (char *)malloc(81)) == NULL)
  426. {
  427. malloc_error:
  428. ODInitError("Insufficient memory available to start up program.");
  429. exit(od_control.od_errorlevel[1]);
  430. }
  431. }
  432. /* Determine the current node number. */
  433. if((pointer=getenv("TASK")) != NULL)
  434. {
  435. od_control.od_node = atoi(pointer);
  436. }
  437. else if((pointer=getenv("SBBSNNUM")) != NULL)
  438. {
  439. od_control.od_node = atoi(pointer);
  440. }
  441. else if(wODNodeNumber != 65535U)
  442. {
  443. od_control.od_node = wODNodeNumber;
  444. }
  445. else if(od_control.od_node == 0)
  446. {
  447. od_control.od_node = 1;
  448. }
  449. /* If a custom drop file format is not being used, then set certain */
  450. /* od_control members to their default values. In the case where */
  451. /* a custom drop file format is being used, these values will already */
  452. /* have been set, and so we don't want to touch them. */
  453. if(od_control.od_info_type != CUSTOM)
  454. {
  455. od_control.user_avatar = FALSE;
  456. od_control.user_rip = FALSE;
  457. od_control.user_attribute = 0x06;
  458. od_control.user_screen_length = 23;
  459. od_control.user_screenwidth = 80;
  460. od_control.od_page_pausing = TRUE;
  461. od_control.od_page_len = 15;
  462. }
  463. else
  464. {
  465. /* When a custom drop file is being used, there are certain */
  466. /* variables that we must initialize if they weren't already set */
  467. /* when the custom drop file was read. */
  468. if(od_control.user_timelimit == 0) od_control.user_timelimit = 60;
  469. #ifdef ODPLAT_NIX
  470. if(od_control.port == -1) od_control.baud = 1L;
  471. #else
  472. if(od_control.port == -1) od_control.baud = 0L;
  473. #endif
  474. }
  475. /* Setup inbound local/remote buffer. */
  476. if(ODInQueueAlloc(&hODInputQueue, od_control.od_in_buf_size == 0 ?
  477. DEFAULT_EVENT_QUEUE_SIZE : od_control.od_in_buf_size) != kODRCSuccess)
  478. {
  479. goto malloc_error;
  480. }
  481. /* Enable user's keyboard by default. */
  482. od_control.od_user_keyboard_on = TRUE;
  483. /* If door information (drop) file reading has been disabled, then */
  484. /* don't attempt to read any drop file. */
  485. if(od_control.od_disable & DIS_INFOFILE)
  486. {
  487. od_control.od_info_type = NO_DOOR_FILE;
  488. }
  489. /* Otherwise, if the local mode override has been explicitly asked for, */
  490. /* setup od_control for default local mode operation. */
  491. else if(od_control.od_force_local)
  492. {
  493. force_local:
  494. /* No door information file is being used. */
  495. od_control.od_info_type = NO_DOOR_FILE;
  496. /* Operate in local mode. */
  497. #ifdef ODPLAT_NIX
  498. od_control.baud = 1L;
  499. #else
  500. od_control.baud = 0L;
  501. #endif
  502. if(!bParsedCmdLine)
  503. {
  504. /* Enable ANSI mode. */
  505. od_control.user_ansi = TRUE;
  506. /* Default to 60 minutes of time available. */
  507. od_control.user_timelimit = 60;
  508. }
  509. /* Choose the appropriate system name. */
  510. if(bSystemNameSet)
  511. {
  512. strcpy(od_control.user_location, szForcedSystemName);
  513. }
  514. else if(od_control.system_name[0] != '\0')
  515. {
  516. strcpy(od_control.user_location, od_control.system_name);
  517. }
  518. else
  519. {
  520. strcpy(od_control.user_location, "Unknown Location");
  521. }
  522. }
  523. /* If drop file reading isn't disable, if a custom format drop file */
  524. /* hasn't already been read and automatic local mode hasn't been */
  525. /* specified, then attempt to find and read a standard drop file. */
  526. else if(od_control.od_info_type != CUSTOM)
  527. {
  528. /* Generate the name of the dorinfox.def file for this node. */
  529. if(od_control.od_node > 35)
  530. {
  531. apszDropFileNames[1] = (char *)"dorinfo1.def";
  532. }
  533. else if(od_control.od_node > 9)
  534. {
  535. sprintf(szIFTemp, "dorinfo%c.def", od_control.od_node + 55);
  536. apszDropFileNames[1] = (char *)szIFTemp;
  537. }
  538. else
  539. {
  540. sprintf(szIFTemp, "dorinfo%d.def", od_control.od_node);
  541. apszDropFileNames[1] = (char *)szIFTemp;
  542. }
  543. nFound = FOUND_NONE;
  544. if(!ODFileAccessMode(od_control.info_path, 4))
  545. {
  546. /* Check for a DORINFOx.DEF filename. */
  547. if(ODStringHasTail(od_control.info_path, ".def") &&
  548. strlen(od_control.info_path) >= strlen(apszDropFileNames[2]) &&
  549. strnicmp((char *)&od_control.info_path +
  550. (strlen(od_control.info_path) - 12), "dorinfo", 7) == 0)
  551. {
  552. nFound = FOUND_DORINFO1_DEF;
  553. strcpy(szDropFilePath, od_control.info_path);
  554. }
  555. else
  556. {
  557. /* Check filenames other than DORINFOx.DEF */
  558. for(btCount = 0; btCount < DIM(apszDropFileNames); ++btCount)
  559. {
  560. if(ODStringHasTail(od_control.info_path,
  561. apszDropFileNames[btCount]))
  562. {
  563. strcpy(szDropFilePath, od_control.info_path);
  564. nFound = btCount;
  565. break;
  566. }
  567. }
  568. }
  569. }
  570. /* Search for a door information file. */
  571. if(nFound == FOUND_NONE)
  572. {
  573. nFound = ODSearchForDropFile((char **)&apszDropFileNames,
  574. DIM(apszDropFileNames), (char *)&szDropFilePath,
  575. (char *)&szExitinfoBBSPath);
  576. }
  577. if(nFound == FOUND_EXITINFO_BBS)
  578. {
  579. od_control.od_info_type = NO_DOOR_FILE;
  580. ODInitReadExitInfo();
  581. if(od_control.od_info_type == NO_DOOR_FILE)
  582. {
  583. goto DropFileFail;
  584. }
  585. ODMakeFilename(szODWorkString, szExitinfoBBSPath, "dorinfo1.def",
  586. sizeof(szExitinfoBBSPath));
  587. if((pfDropFile = fopen(szODWorkString, "r")) == NULL)
  588. {
  589. goto DropFileFail;
  590. }
  591. goto read_dorinfox;
  592. }
  593. else if(nFound==FOUND_DORINFO1_DEF)
  594. {
  595. /* Open DORINFO?.DEF. */
  596. if((pfDropFile = fopen(szDropFilePath, "r")) == NULL) goto DropFileFail;
  597. /* Set door type to DORINFO. */
  598. od_control.od_info_type = DORINFO1;
  599. read_dorinfox:
  600. /* If not able to read first line. */
  601. if(fgets(szIFTemp, 255, pfDropFile) == NULL)
  602. {
  603. goto DropFileFail;
  604. }
  605. if(szIFTemp[strlen(szIFTemp) - 1] == '\n')
  606. {
  607. szIFTemp[strlen(szIFTemp) - 1] = '\0';
  608. }
  609. if(szIFTemp[strlen(szIFTemp) - 1] == '\r')
  610. {
  611. szIFTemp[strlen(szIFTemp) - 1] = '\0';
  612. }
  613. strncpy(od_control.system_name, szIFTemp, 39);
  614. od_control.system_name[39] = '\0';
  615. /* get sysop name from DORINFO1.DEF */
  616. if(fgets(szIFTemp, 255, pfDropFile) == NULL) goto DropFileFail;
  617. ODStringToName(szIFTemp);
  618. strncpy(od_control.sysop_name, szIFTemp, 19);
  619. /* get sysop's last name */
  620. if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
  621. ODStringToName(szIFTemp);
  622. if(strlen(szIFTemp))
  623. {
  624. strcat(od_control.sysop_name," ");
  625. strncat(od_control.sysop_name,szIFTemp,19);
  626. }
  627. /* get com port that modem is connected to */
  628. if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
  629. od_control.port=szIFTemp[3]-'1';
  630. /* determine BPS rate of connection */
  631. if(fgets((char *)apszDropFileInfo[0],255,pfDropFile)==NULL) goto DropFileFail;
  632. #ifdef ODPLAT_NIX
  633. od_control.baud= (od_control.port == -1) ? 1 : atol((char *)apszDropFileInfo[0]);
  634. #else
  635. od_control.baud= (od_control.port == -1) ? 0 : atol((char *)apszDropFileInfo[0]);
  636. #endif
  637. if(fgets((char *)apszDropFileInfo[1],80,pfDropFile)==NULL) goto DropFileFail;
  638. /* get user's first name */
  639. if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
  640. ODStringToName(szIFTemp);
  641. strncpy(od_control.user_name,szIFTemp,17);
  642. /* get user's last name */
  643. if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
  644. ODStringToName(szIFTemp);
  645. if(strlen(szIFTemp))
  646. {
  647. strcat(od_control.user_name," ");
  648. strncat(od_control.user_name,szIFTemp,17);
  649. }
  650. /* get user's location */
  651. if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
  652. ODStringToName(szIFTemp);
  653. strncpy(od_control.user_location,szIFTemp,25);
  654. /* get ANSI mode settings */
  655. if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
  656. if(szIFTemp[0]=='0') od_control.user_ansi=FALSE;
  657. else od_control.user_ansi=TRUE;
  658. /* get user security level */
  659. if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
  660. od_control.user_security=atoi(szIFTemp);
  661. /* get time left in door */
  662. if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
  663. od_control.user_timelimit=atoi(szIFTemp);
  664. fclose(pfDropFile);
  665. }
  666. /* Read CHAIN.TXT */
  667. else if(nFound==FOUND_CHAIN_TXT)
  668. {
  669. if((pfDropFile=fopen(szDropFilePath,"r"))==NULL) goto DropFileFail;
  670. od_control.od_info_type=CHAINTXT;
  671. if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
  672. od_control.user_num=atoi(szIFTemp);
  673. if(fgets((char *)&od_control.user_handle,35,pfDropFile)==NULL) goto DropFileFail;
  674. ODStringToName(od_control.user_handle);
  675. if(fgets((char *)&od_control.user_name,35,pfDropFile)==NULL) goto DropFileFail;
  676. ODStringToName(od_control.user_name);
  677. if(fgets((char *)&od_control.user_callsign,12,pfDropFile)==NULL) goto DropFileFail;
  678. ODStringToName(od_control.user_callsign);
  679. if(fgets((char *)apszDropFileInfo[0],80,pfDropFile)==NULL) goto DropFileFail;
  680. if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
  681. od_control.user_sex=szIFTemp[0];
  682. if(fgets((char *)apszDropFileInfo[1],80,pfDropFile)==NULL) goto DropFileFail;
  683. if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
  684. strncpy(od_control.user_lastdate,szIFTemp,8);
  685. if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
  686. od_control.user_screenwidth=atoi(szIFTemp);
  687. if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
  688. od_control.user_screen_length=atoi(szIFTemp);
  689. if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
  690. od_control.user_security=atoi(szIFTemp);
  691. if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
  692. bIsSysop=atoi(szIFTemp);
  693. if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
  694. bIsCoSysop=atoi(szIFTemp);
  695. if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
  696. od_control.user_ansi=atoi(szIFTemp);
  697. if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail; /* non-zero if remote */
  698. if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
  699. od_control.user_timelimit=atoi(szIFTemp);
  700. od_control.user_timelimit/=60;
  701. if(fgets((char *)apszDropFileInfo[3],80,pfDropFile)==NULL) goto DropFileFail;
  702. if(fgets((char *)apszDropFileInfo[4],80,pfDropFile)==NULL) goto DropFileFail;
  703. if(fgets((char *)apszDropFileInfo[5],80,pfDropFile)==NULL) goto DropFileFail;
  704. if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
  705. if(strcmp(szIFTemp,"KB")==0)
  706. {
  707. #ifdef ODPLAT_NIX
  708. od_control.baud=1;
  709. #else
  710. od_control.baud=0;
  711. #endif
  712. }
  713. else
  714. {
  715. od_control.baud=atol(szIFTemp);
  716. }
  717. if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
  718. od_control.port=atoi(szIFTemp)-1;
  719. if(fgets((char *)apszDropFileInfo[6],80,pfDropFile)==NULL) goto DropFileFail;
  720. if(fgets((char *)&od_control.user_password,15,pfDropFile)==NULL) goto DropFileFail;
  721. ODStringToName(od_control.user_password);
  722. if(fgets((char *)apszDropFileInfo[2],80,pfDropFile)==NULL) goto DropFileFail;
  723. if(fgets((char *)apszDropFileInfo[7],80,pfDropFile)==NULL) goto DropFileFail;
  724. if(fgets((char *)apszDropFileInfo[8],80,pfDropFile)==NULL) goto DropFileFail;
  725. if(fgets((char *)apszDropFileInfo[9],80,pfDropFile)==NULL) goto DropFileFail;
  726. if(fgets((char *)apszDropFileInfo[10],80,pfDropFile)==NULL) goto DropFileFail;
  727. if(fgets((char *)apszDropFileInfo[11],80,pfDropFile)==NULL) goto DropFileFail;
  728. if(fgets((char *)apszDropFileInfo[12],80,pfDropFile)==NULL) goto DropFileFail;
  729. fclose(pfDropFile);
  730. }
  731. else if(nFound == FOUND_SFDOORS_DAT
  732. || nFound == FOUND_SFMAIN_DAT
  733. || nFound == FOUND_SFFILE_DAT
  734. || nFound == FOUND_SFMESS_DAT
  735. || nFound == FOUND_SFSYSOP_DAT)
  736. {
  737. od_control.od_info_type = SFDOORSDAT;
  738. if(!ODInitReadSFDoorsDAT())
  739. {
  740. goto DropFileFail;
  741. }
  742. }
  743. else if(nFound==FOUND_DOOR_SYS)
  744. {
  745. if((pfDropFile=fopen(szDropFilePath,"r"))==NULL) goto DropFileFail;
  746. /* Read line 1. */
  747. if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
  748. if(szIFTemp[0]=='C' && szIFTemp[1]=='O' && szIFTemp[2]=='M' && szIFTemp[4]==':')
  749. { /* GAP style DOOR.SYS */
  750. od_control.od_info_type=DOORSYS_GAP;
  751. od_control.port=szIFTemp[3]-'1';
  752. /* Check for COM0:STDIO */
  753. if(!strncmp(szIFTemp,"COM0:STDIO",10))
  754. od_control.od_com_method=COM_STDIO;
  755. /* Check for COM0:SOCKET### */
  756. if(!strncmp(szIFTemp,"COM0:SOCKET",11)) {
  757. od_control.od_com_method=COM_SOCKET;
  758. od_control.od_use_socket = TRUE;
  759. od_control.od_open_handle=atoi(szIFTemp+11);
  760. }
  761. /* Check for COM0:HANDLE### */
  762. if(!strncmp(szIFTemp,"COM0:HANDLE",11)) {
  763. od_control.od_com_method=COM_WIN32;
  764. od_control.od_open_handle=atoi(szIFTemp+11);
  765. }
  766. /* Read line 2. */
  767. if(fgets((char *)apszDropFileInfo[0], 80, pfDropFile) == NULL)
  768. {
  769. goto DropFileFail;
  770. }
  771. od_control.od_connect_speed = atol(apszDropFileInfo[0]);
  772. /* Read line 3. */
  773. if(fgets((char *)apszDropFileInfo[1],80,pfDropFile)==NULL) goto DropFileFail;
  774. /* Read line 4. */
  775. if(fgets(szIFTemp, 255, pfDropFile) == NULL) goto DropFileFail;
  776. od_control.od_node = atoi(szIFTemp);
  777. /* Read line 5. */
  778. if(fgets(szIFTemp, 255, pfDropFile) == NULL) goto DropFileFail;
  779. strupr(szIFTemp);
  780. if(strchr(szIFTemp, 'N') != NULL)
  781. {
  782. btDoorSYSLock = 1;
  783. od_control.baud = atol(apszDropFileInfo[0]);
  784. }
  785. else if(strchr(szIFTemp, 'Y') != NULL)
  786. {
  787. btDoorSYSLock = 2;
  788. od_control.baud = 19200;
  789. }
  790. else
  791. {
  792. od_control.baud = atol(szIFTemp);
  793. }
  794. #ifdef ODPLAT_NIX
  795. if(od_control.port == -1) od_control.baud = 1L;
  796. #else
  797. if(od_control.port == -1) od_control.baud = 0L;
  798. #endif
  799. /* Read line 6. */
  800. if(fgets((char *)apszDropFileInfo[3],80,pfDropFile)==NULL) goto DropFileFail;
  801. /* Read line 7. */
  802. if(fgets((char *)apszDropFileInfo[4],80,pfDropFile)==NULL) goto DropFileFail;
  803. /* Read line 8. */
  804. if(fgets((char *)apszDropFileInfo[5],80,pfDropFile)==NULL) goto DropFileFail;
  805. /* Read line 9. */
  806. if(fgets((char *)apszDropFileInfo[22],80,pfDropFile)==NULL) goto DropFileFail;
  807. /* Read line 10. */
  808. if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
  809. szIFTemp[35]='\0';
  810. ODStringToName(szIFTemp);
  811. strcpy(od_control.user_name,szIFTemp);
  812. /* Read line 11. */
  813. if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
  814. szIFTemp[25]='\0';
  815. if(szIFTemp[strlen(szIFTemp)-1]=='\n') szIFTemp[strlen(szIFTemp)-1]='\0';
  816. if(szIFTemp[strlen(szIFTemp)-1]=='\r') szIFTemp[strlen(szIFTemp)-1]='\0';
  817. strcpy(od_control.user_location,szIFTemp);
  818. /* Read line 12. */
  819. if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
  820. szIFTemp[15]='\0';
  821. ODStringToName(szIFTemp);
  822. strcpy(od_control.user_homephone,szIFTemp);
  823. /* Read line 13. */
  824. if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
  825. szIFTemp[15]='\0';
  826. ODStringToName(szIFTemp);
  827. strcpy(od_control.user_dataphone,szIFTemp);
  828. /* Read line 14. */
  829. if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
  830. szIFTemp[15]='\0';
  831. if(szIFTemp[strlen(szIFTemp)-1]=='\n') szIFTemp[strlen(szIFTemp)-1]='\0';
  832. if(szIFTemp[strlen(szIFTemp)-1]=='\r') szIFTemp[strlen(szIFTemp)-1]='\0';
  833. strcpy(od_control.user_password,szIFTemp);
  834. /* Read line 15. */
  835. if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
  836. od_control.user_security=atoi(szIFTemp);
  837. /* Read line 16. */
  838. if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
  839. od_control.user_numcalls=atoi(szIFTemp);
  840. /* Read line 17. */
  841. if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
  842. szIFTemp[15]='\0';
  843. ODStringToName(szIFTemp);
  844. strcopydate(od_control.user_lastdate,szIFTemp);
  845. /* Read line 18. */
  846. if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
  847. /* Read line 19. */
  848. if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
  849. od_control.user_timelimit=atoi(szIFTemp);
  850. /* Read line 20. */
  851. if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
  852. strupr(szIFTemp);
  853. if(!strcmp(szIFTemp,"RIP"))
  854. {
  855. od_control.user_rip=TRUE;
  856. od_control.user_ansi=TRUE;
  857. }
  858. else if(szIFTemp[0]=='G')
  859. {
  860. od_control.user_rip=FALSE;
  861. od_control.user_ansi=TRUE;
  862. }
  863. else
  864. {
  865. od_control.user_rip=FALSE;
  866. od_control.user_ansi=FALSE;
  867. }
  868. /* Read line 21. */
  869. if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
  870. od_control.user_screen_length=atoi(szIFTemp);
  871. /* Read line 22. */
  872. if(fgets((char *)apszDropFileInfo[8],80,pfDropFile)==NULL) goto DropFileFail;
  873. /* Read line 23. */
  874. if(fgets((char *)apszDropFileInfo[9],80,pfDropFile)==NULL) goto DropFileFail;
  875. if(apszDropFileInfo[9][strlen(apszDropFileInfo[9])-1]!='\n')
  876. {
  877. int ch;
  878. apszDropFileInfo[9][strlen(apszDropFileInfo[9])-1]='\n';
  879. do
  880. {
  881. ch = fgetc(pfDropFile);
  882. } while(ch != '\n' && ch != EOF);
  883. }
  884. /* Read line 24. */
  885. again:
  886. if(fgets((char *)apszDropFileInfo[10],80,pfDropFile)==NULL) goto DropFileFail;
  887. if(strchr(apszDropFileInfo[10],',')!=NULL) goto again;
  888. /* Read line 25. */
  889. if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
  890. szIFTemp[15]='\0';
  891. ODStringToName(szIFTemp);
  892. strcopydate(od_control.user_subdate,szIFTemp);
  893. /* Read line 26. */
  894. if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
  895. od_control.user_num=atoi(szIFTemp);
  896. /* Read line 27. */
  897. if(fgets((char *)apszDropFileInfo[6],80,pfDropFile)==NULL) goto DropFileFail;
  898. /* Read line 28. */
  899. if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
  900. od_control.user_uploads=atoi(szIFTemp);
  901. /* Read line 29. */
  902. if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
  903. od_control.user_downloads=atoi(szIFTemp);
  904. /* Read line 30. */
  905. if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
  906. od_control.user_todayk=atoi(szIFTemp);
  907. /* Read line 31. */
  908. if(fgets((char *)apszDropFileInfo[21],80,pfDropFile)==NULL) goto DropFileFail;
  909. /* Beginning of extending DOOR.SYS data */
  910. /* Read line 32. */
  911. fgets((char *)apszDropFileInfo[7],80,pfDropFile);
  912. /* Read line 33. */
  913. fgets((char *)apszDropFileInfo[11],80,pfDropFile);
  914. /* Read line 34. */
  915. fgets((char *)apszDropFileInfo[12],80,pfDropFile);
  916. /* Read line 35. */
  917. fgets((char *)apszDropFileInfo[13],80,pfDropFile);
  918. /* Read line 36. */
  919. if(fgets((char *)apszDropFileInfo[14],80,pfDropFile)!=NULL)
  920. {
  921. /* Read line 37. */
  922. strcopydate(od_control.user_birthday,apszDropFileInfo[7]);
  923. /* Read line 38. */
  924. strncpy(od_control.sysop_name,apszDropFileInfo[13],39);
  925. od_control.sysop_name[39]='\0';
  926. ODStringToName(od_control.sysop_name);
  927. /* Read line 39. */
  928. strncpy(od_control.user_handle,apszDropFileInfo[14],35);
  929. od_control.user_handle[35]='\0';
  930. ODStringToName(od_control.user_handle);
  931. /* Read line 40. */
  932. if(fgets(szIFTemp,255,pfDropFile)==NULL) goto finished;
  933. strncpy(od_control.event_starttime, szIFTemp, 5);
  934. od_control.event_starttime[5] = '\0';
  935. /* Read line 41. */
  936. if(fgets(szIFTemp,255,pfDropFile)==NULL) goto finished;
  937. if(szIFTemp[0]=='y' || szIFTemp[0]=='Y')
  938. od_control.user_error_free=TRUE;
  939. else
  940. od_control.user_error_free=FALSE;
  941. /* Read line 42. */
  942. if(fgets((char *)apszDropFileInfo[7],80,pfDropFile)==NULL) goto finished;
  943. /* Read line 43. */
  944. if(fgets((char *)apszDropFileInfo[13],80,pfDropFile)==NULL) goto finished;
  945. /* Read line 44. */
  946. if(fgets((char *)apszDropFileInfo[14],80,pfDropFile)==NULL) goto finished;
  947. /* Read line 45. */
  948. if(fgets((char *)apszDropFileInfo[15],80,pfDropFile)==NULL) goto finished;
  949. /* Read line 46. */
  950. if(fgets((char *)apszDropFileInfo[16],80,pfDropFile)==NULL) goto finished;
  951. /* Read line 47. */
  952. if(fgets(szIFTemp,255,pfDropFile)==NULL) goto finished;
  953. strncpy(od_control.user_logintime,szIFTemp,5);
  954. od_control.user_logintime[5]='\0';
  955. /* Read line 48. */
  956. if(fgets(szIFTemp,255,pfDropFile)==NULL) goto finished;
  957. strncpy(od_control.user_lasttime,szIFTemp,5);
  958. od_control.user_lasttime[5]='\0';
  959. /* Read line 49. */
  960. if(fgets((char *)apszDropFileInfo[18],80,pfDropFile)==NULL) goto finished;
  961. /* Read line 50. */
  962. if(fgets((char *)apszDropFileInfo[19],80,pfDropFile)==NULL) goto finished;
  963. /* Read line 51. */
  964. if(fgets(szIFTemp,255,pfDropFile)==NULL) goto finished;
  965. od_control.user_upk=atoi(szIFTemp);
  966. /* Read line 52. */
  967. if(fgets(szIFTemp,255,pfDropFile)==NULL) goto finished;
  968. od_control.user_downk=atoi(szIFTemp);
  969. /* Read line 53. */
  970. if(fgets(szIFTemp,255,pfDropFile)==NULL) goto finished;
  971. strncpy(od_control.user_comment,szIFTemp,79);
  972. od_control.user_comment[79]='\0';
  973. if(od_control.user_comment[strlen(od_control.user_comment)-1]=='\n')
  974. od_control.user_comment[strlen(od_control.user_comment)-1]='\0';
  975. if(od_control.user_comment[strlen(od_control.user_comment)-1]=='\r')
  976. od_control.user_comment[strlen(od_control.user_comment)-1]='\0';
  977. /* Read line 54. */
  978. if(fgets((char *)apszDropFileInfo[20],80,pfDropFile)==NULL) goto finished;
  979. /* Read line 55. */
  980. if(fgets(szIFTemp,255,pfDropFile)==NULL) goto finished;
  981. od_control.user_messages=atoi(szIFTemp);
  982. od_control.od_info_type=DOORSYS_WILDCAT;
  983. }
  984. }
  985. else /* DoorWay style DOOR.SYS */
  986. {
  987. od_control.od_info_type=DOORSYS_DRWY;
  988. szIFTemp[35]='\0';
  989. ODStringToName(szIFTemp);
  990. strcpy(od_control.user_name,szIFTemp);
  991. if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
  992. od_control.port=szIFTemp[0]-'1';
  993. if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
  994. if(od_control.port==-1)
  995. {
  996. #ifdef ODPLAT_NIX
  997. od_control.baud=1L;
  998. #else
  999. od_control.baud=0L;
  1000. #endif
  1001. }
  1002. else
  1003. {
  1004. od_control.baud=atol(szIFTemp);
  1005. }
  1006. if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
  1007. od_control.user_timelimit=atoi(szIFTemp);
  1008. if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
  1009. if(szIFTemp[0]=='G')
  1010. {
  1011. od_control.user_ansi=TRUE;
  1012. }
  1013. else
  1014. {
  1015. od_control.user_ansi=FALSE;
  1016. }
  1017. }
  1018. finished:
  1019. fclose(pfDropFile);
  1020. }
  1021. else if(nFound==FOUND_CALLINFO_BBS)
  1022. {
  1023. if((pfDropFile=fopen(szDropFilePath,"r"))==NULL) goto DropFileFail;
  1024. od_control.od_info_type=CALLINFO;
  1025. if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
  1026. szIFTemp[35]='\0';
  1027. ODStringToName(szIFTemp);
  1028. strcpy(od_control.user_name,szIFTemp);
  1029. if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
  1030. if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
  1031. szIFTemp[25]='\0';
  1032. ODStringToName(szIFTemp);
  1033. strcpy(od_control.user_location,szIFTemp);
  1034. if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
  1035. od_control.user_security=atoi(szIFTemp);
  1036. if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
  1037. od_control.user_timelimit=atoi(szIFTemp);
  1038. if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
  1039. if(szIFTemp[0]=='M')
  1040. {
  1041. od_control.user_ansi=FALSE;
  1042. }
  1043. else
  1044. {
  1045. od_control.user_ansi=TRUE;
  1046. }
  1047. if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
  1048. szIFTemp[15]='\0';
  1049. ODStringToName(szIFTemp);
  1050. strcpy(od_control.user_password,szIFTemp);
  1051. if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
  1052. if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
  1053. if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
  1054. if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
  1055. if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
  1056. if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
  1057. if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
  1058. if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
  1059. if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
  1060. if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
  1061. szIFTemp[15]='\0';
  1062. ODStringToName(szIFTemp);
  1063. strcpy(od_control.user_homephone,szIFTemp);
  1064. if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
  1065. if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
  1066. if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
  1067. if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
  1068. if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
  1069. if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
  1070. od_control.user_screen_length=atoi(szIFTemp);
  1071. if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
  1072. if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
  1073. if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
  1074. if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
  1075. if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
  1076. if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
  1077. od_control.port=szIFTemp[3]-'1';
  1078. if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
  1079. if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
  1080. od_control.baud=atol(szIFTemp);
  1081. fclose(pfDropFile);
  1082. }
  1083. else if(nFound == FOUND_TRIBBS_SYS)
  1084. {
  1085. /* We have found reading a TRIBBS.SYS file. */
  1086. /* Attempt to open the file. */
  1087. if((pfDropFile = fopen(szDropFilePath, "r")) == NULL)
  1088. {
  1089. goto DropFileFail;
  1090. }
  1091. /* Record the drop file type being used. */
  1092. od_control.od_info_type = TRIBBSSYS;
  1093. /* Read line 1: User's number. */
  1094. if(fgets(szIFTemp, 255, pfDropFile) == NULL) goto DropFileFail;
  1095. od_control.user_num = atoi(szIFTemp);
  1096. /* Read line 2: User's name. */
  1097. if(fgets((char *)&od_control.user_name, 35, pfDropFile) == NULL)
  1098. {
  1099. goto DropFileFail;
  1100. }
  1101. ODStringToName(od_control.user_name);
  1102. /* Read line 3: User's password. */
  1103. if(fgets((char *)&od_control.user_password, 15, pfDropFile) == NULL)
  1104. {
  1105. goto DropFileFail;
  1106. }
  1107. /* Read line 4: User's security level. */
  1108. if(fgets(szIFTemp, 255, pfDropFile) == NULL) goto DropFileFail;
  1109. od_control.user_security = atoi(szIFTemp);
  1110. /* Read line 5: "Y" for expert mode, "N" for novice mode. */
  1111. if(fgets(szIFTemp, 255, pfDropFile) == NULL) goto DropFileFail;
  1112. od_control.user_expert = (szIFTemp[0] == 'Y');
  1113. /* Read line 6: "Y" for ANSI, "N" for TTY. */
  1114. if(fgets(szIFTemp, 255, pfDropFile) == NULL) goto DropFileFail;
  1115. od_control.user_ansi = (szIFTemp[0] == 'Y');
  1116. /* Read line 7: Minutes remaining for this call. */
  1117. if(fgets(szIFTemp, 255, pfDropFile) == NULL) goto DropFileFail;
  1118. od_control.user_timelimit = atoi(szIFTemp);
  1119. /* Read line 8: User's phone number. */
  1120. if(fgets(szIFTemp, 255, pfDropFile) == NULL) goto DropFileFail;
  1121. szIFTemp[15] = '\0';
  1122. ODStringToName(szIFTemp);
  1123. strcpy(od_control.user_homephone, szIFTemp);
  1124. /* Read line 9: User's location. */
  1125. if(fgets(szIFTemp, 255, pfDropFile) == NULL) goto DropFileFail;
  1126. ODStringToName(szIFTemp);
  1127. strncpy(od_control.user_location, szIFTemp, 25);
  1128. /* Read line 10: User's birthday. */
  1129. if(fgets(szIFTemp, 255, pfDropFile) == NULL) goto DropFileFail;
  1130. strncpy(od_control.user_birthday, szIFTemp, 8);
  1131. od_control.user_birthday[8] = '\0';
  1132. od_control.user_birthday[2] = '-';
  1133. od_control.user_birthday[5] = '-';
  1134. /* Read line 11: Node number. */
  1135. if(fgets(szIFTemp, 255, pfDropFile) == NULL) goto DropFileFail;
  1136. od_control.od_node = atoi(szIFTemp);
  1137. /* Read line 12: Serial port. */
  1138. if(fgets(szIFTemp, 255, pfDropFile) == NULL) goto DropFileFail;
  1139. od_control.port = atoi(szIFTemp) - 1;
  1140. /* Read line 13: Baud rate. */
  1141. if(fgets(szIFTemp, 255, pfDropFile) == NULL) goto DropFileFail;
  1142. od_control.od_connect_speed =
  1143. (od_control.port == -1) ? 0 : atol(szIFTemp);
  1144. /* Read line 14: Locked baud rate or 0 for unlocked port. */
  1145. if(fgets(szIFTemp, 255, pfDropFile) == NULL) goto DropFileFail;
  1146. od_control.baud = atol(szIFTemp);
  1147. if(od_control.baud == 0)
  1148. {
  1149. od_control.baud = od_control.od_connect_speed;
  1150. }
  1151. /* Read line 15: "Y" for RTS/CTS handshaking, "N" for none. */
  1152. if(fgets(szIFTemp, 255, pfDropFile) == NULL) goto DropFileFail;
  1153. od_control.od_com_flow_control = (szIFTemp[0] == 'Y')
  1154. ? COM_RTSCTS_FLOW : COM_NO_FLOW;
  1155. /* Read line 16: "Y" for error free connection, "N" otherwise. */
  1156. if(fgets(szIFTemp, 255, pfDropFile) == NULL) goto DropFileFail;
  1157. od_control.user_error_free = (szIFTemp[0] == 'Y');
  1158. /* Read line 17: BBS name. */
  1159. if(fgets(szIFTemp, 255, pfDropFile) == NULL) goto DropFileFail;
  1160. ODStringCopy(od_control.system_name, szIFTemp, 40);
  1161. ODStringToName(od_control.system_name);
  1162. /* Read line 18: Sysop's name. */
  1163. if(fgets(szIFTemp, 255, pfDropFile) == NULL) goto DropFileFail;
  1164. ODStringCopy(od_control.sysop_name, szIFTemp, 40);
  1165. ODStringToName(od_control.sysop_name);
  1166. /* Read line 19: User's alias. */
  1167. if(fgets((char *)&od_control.user_handle, 35, pfDropFile) == NULL)
  1168. {
  1169. goto DropFileFail;
  1170. }
  1171. ODStringToName(od_control.user_handle);
  1172. /* Read line 20: "Y" for RIP mode, "N" for no RIP mode. */
  1173. if(fgets(szIFTemp, 255, pfDropFile) == NULL) goto DropFileFail;
  1174. od_control.user_rip = (szIFTemp[0] == 'Y');
  1175. /* Now, close the TRIBBS.SYS file. */
  1176. fclose(pfDropFile);
  1177. }
  1178. else if(nFound == FOUND_DOOR32_SYS)
  1179. {
  1180. /* We have found a DOOR32.SYS file. */
  1181. /* Attempt to open the file. */
  1182. if((pfDropFile = fopen(szDropFilePath, "r")) == NULL)
  1183. {
  1184. goto DropFileFail;
  1185. }
  1186. /* Record the drop file type being used. */
  1187. od_control.od_info_type = DOOR32SYS;
  1188. /* Read line 1: Comm type. */
  1189. if(fgets(szIFTemp, 255, pfDropFile) == NULL) goto DropFileFail;
  1190. switch(atoi(szIFTemp)) {
  1191. case 0: /* local */
  1192. od_control.od_force_local = TRUE; /* Is this the right way? */
  1193. break;
  1194. case 1: /* serial */
  1195. break;
  1196. case 2: /* telnet */
  1197. od_control.od_use_socket = TRUE;
  1198. break;
  1199. }
  1200. /* Read line 2: Comm or Socket handle. */
  1201. if(fgets(szIFTemp, 255, pfDropFile) == NULL) goto DropFileFail;
  1202. od_control.od_open_handle = atoi(szIFTemp);
  1203. /* Read line 3: Baud rate */
  1204. if(fgets((char *)apszDropFileInfo[0],255,pfDropFile)==NULL) goto DropFileFail;
  1205. #ifdef ODPLAT_NIX
  1206. od_control.baud= (od_control.port == -1) ? 1 : atol((char *)apszDropFileInfo[0]);
  1207. #else
  1208. od_control.baud= (od_control.port == -1) ? 0 : atol((char *)apszDropFileInfo[0]);
  1209. #endif
  1210. /* Read line 4: BBS Software name and version - unused. */
  1211. if(fgets(szIFTemp, 255, pfDropFile) == NULL) goto DropFileFail;
  1212. /* Read line 5: User's number. */
  1213. if(fgets(szIFTemp, 255, pfDropFile) == NULL) goto DropFileFail;
  1214. od_control.user_num = atoi(szIFTemp);
  1215. /* Read line 6: User's real name. */
  1216. if(fgets((char *)&od_control.user_name, 35, pfDropFile) == NULL)
  1217. {
  1218. goto DropFileFail;
  1219. }
  1220. ODStringToName(od_control.user_name);
  1221. /* Read line 7: User's alias. */
  1222. if(fgets((char *)&od_control.user_handle, 35, pfDropFile) == NULL)
  1223. {
  1224. goto DropFileFail;
  1225. }
  1226. ODStringToName(od_control.user_handle);
  1227. /* Read line 8: User's security level */
  1228. if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
  1229. od_control.user_security=atoi(szIFTemp);
  1230. /* Read line 9: Minutes remaining for this call. */
  1231. if(fgets(szIFTemp, 255, pfDropFile) == NULL) goto DropFileFail;
  1232. od_control.user_timelimit = atoi(szIFTemp);
  1233. /* Read line 10: User's Terminal type */
  1234. if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
  1235. od_control.user_ansi=TRUE;
  1236. switch(atoi(szIFTemp)) {
  1237. case 0: /* ASCII */
  1238. od_control.user_ansi=FALSE;
  1239. break;
  1240. case 1: /* ANSI */
  1241. od_control.user_ansi=TRUE;
  1242. break;
  1243. case 2: /* AVATAR */
  1244. od_control.user_avatar=TRUE;
  1245. break;
  1246. case 3: /* RIP */
  1247. od_control.user_rip=TRUE;
  1248. break;
  1249. }
  1250. /* Read line 11: Current Node number. */
  1251. if(fgets(szIFTemp, 255, pfDropFile) == NULL) goto DropFileFail;
  1252. od_control.od_node = atoi(szIFTemp);
  1253. /* Now, close the DOOR32.SYS file. */
  1254. fclose(pfDropFile);
  1255. }
  1256. else
  1257. {
  1258. DropFileFail:
  1259. if(pfDropFile!=NULL) /* Let's not leave the file open */
  1260. fclose(pfDropFile);
  1261. od_control.od_info_type = NO_DOOR_FILE;
  1262. if(od_control.od_no_file_func != NULL)
  1263. {
  1264. (*od_control.od_no_file_func)();
  1265. }
  1266. /* Check whether force local has been turned on by the no */
  1267. /* file function. */
  1268. if(od_control.od_force_local)
  1269. {
  1270. goto force_local;
  1271. }
  1272. /* Exit with failure if the no file function has not read a */
  1273. /* door information file itself. */
  1274. if(od_control.od_info_type == NO_DOOR_FILE
  1275. && (wPreSetInfo & PRESET_REQUIRED) != PRESET_REQUIRED)
  1276. {
  1277. ODInitError("Unable to read door information (drop) file.");
  1278. exit(od_control.od_errorlevel[1]);
  1279. }
  1280. }
  1281. }
  1282. ODInitPartTwo();
  1283. }
  1284. /* ----------------------------------------------------------------------------
  1285. * ODInitReadSFDoorsDAT() *** PRIVATE FUNCTION ***
  1286. *
  1287. * Reads an SFDOORS.DAT format drop file.
  1288. *
  1289. * Parameters: none
  1290. *
  1291. * Return: TRUE on success or FALSE on failure.
  1292. */
  1293. static BOOL ODInitReadSFDoorsDAT(void)
  1294. {
  1295. FILE *pfDropFile;
  1296. if((pfDropFile=fopen(szDropFilePath,"r"))==NULL) return(FALSE);
  1297. /* Line 1: User number. */
  1298. if(fgets(szIFTemp,255,pfDropFile)==NULL) return(FALSE);
  1299. od_control.user_num=atoi(szIFTemp);
  1300. /* Line 2: User name. */
  1301. if(fgets(szIFTemp,255,pfDropFile)==NULL) return(FALSE);
  1302. szIFTemp[35]='\0';
  1303. ODStringToName(szIFTemp);
  1304. strcpy(od_control.user_name,szIFTemp);
  1305. /* Line 3: User password. */
  1306. if(fgets(szIFTemp,255,pfDropFile)==NULL) return(FALSE);
  1307. szIFTemp[15]='\0';
  1308. ODStringToName(szIFTemp);
  1309. strcpy(od_control.user_password,szIFTemp);
  1310. /* Line 4: Unused. */
  1311. if(fgets((char *)apszDropFileInfo[0],80,pfDropFile)==NULL) return(FALSE);
  1312. /* Line 5: Modem <-> Serial port bps rate. */
  1313. if(fgets(szIFTemp,255,pfDropFile)==NULL) return(FALSE);
  1314. od_control.baud=atol(szIFTemp);
  1315. /* Line 6: Serial port number. */
  1316. if(fgets(szIFTemp,255,pfDropFile)==NULL) return(FALSE);
  1317. od_control.port=atoi(szIFTemp)-1;
  1318. /* Line 7: User's time remaining. */
  1319. if(fgets(szIFTemp,255,pfDropFile)==NULL) return(FALSE);
  1320. od_control.user_timelimit=atoi(szIFTemp);
  1321. /* Line 8: Unused. */
  1322. if(fgets((char *)apszDropFileInfo[13],80,pfDropFile)==NULL) return(FALSE);
  1323. /* Line 9: Unused. */
  1324. if(fgets((char *)apszDropFileInfo[14],80,pfDropFile)==NULL) return(FALSE);
  1325. /* Line 10: User's ANSI mode setting. */
  1326. if(fgets(szIFTemp,255,pfDropFile)==NULL) return(FALSE);
  1327. strupr(szIFTemp);
  1328. od_control.user_ansi=(szIFTemp[0]=='T');
  1329. /* Line 11: User's security level. */
  1330. if(fgets(szIFTemp,255,pfDropFile)==NULL) return(FALSE);
  1331. od_control.user_security=atoi(szIFTemp);
  1332. /* Line 12: User's upload count. */
  1333. if(fgets(szIFTemp,255,pfDropFile)==NULL) return(FALSE);
  1334. od_control.user_uploads=atoi(szIFTemp);
  1335. /* Line 13: User's download count. */
  1336. if(fgets(szIFTemp,255,pfDropFile)==NULL) return(FALSE);
  1337. od_control.user_downloads=atoi(szIFTemp);
  1338. /* Line 14: Unused. */
  1339. if(fgets((char *)apszDropFileInfo[1],80,pfDropFile)==NULL) return(FALSE);
  1340. /* Line 15: User's login time. */
  1341. if(fgets((char *)apszDropFileInfo[2],255,pfDropFile)==NULL) return(FALSE);
  1342. sprintf(od_control.user_logintime, "%02d:%02d",
  1343. atoi((char *)apszDropFileInfo[2]) % 60,
  1344. atoi((char *)apszDropFileInfo[2]) / 60);
  1345. /* Line 16: Unused. */
  1346. if(fgets((char *)apszDropFileInfo[3],80,pfDropFile)==NULL) return(FALSE);
  1347. /* Line 17: Sysop next flag. */
  1348. if(fgets(szIFTemp,255,pfDropFile)==NULL) return(FALSE);
  1349. strupr(szIFTemp);
  1350. od_control.sysop_next=(szIFTemp[0]=='T');
  1351. /* Line 18: Unused. */
  1352. if(fgets((char *)apszDropFileInfo[4],80,pfDropFile)==NULL) return(FALSE);
  1353. /* Line 19: Unused. */
  1354. if(fgets((char *)apszDropFileInfo[5],80,pfDropFile)==NULL) return(FALSE);
  1355. /* Line 20: Unused. */
  1356. if(fgets((char *)apszDropFileInfo[6],80,pfDropFile)==NULL) return(FALSE);
  1357. /* Line 21: Error free connection flag. */
  1358. if(fgets(szIFTemp,255,pfDropFile)==NULL) return(FALSE);
  1359. strupr(szIFTemp);
  1360. od_control.user_error_free=(szIFTemp[0]=='T');
  1361. /* Line 22: Current message area. */
  1362. if(fgets(szIFTemp,255,pfDropFile)==NULL) return(FALSE);
  1363. od_control.user_msg_area=atoi(szIFTemp);
  1364. /* Line 23: Current file area. */
  1365. if(fgets(szIFTemp,255,pfDropFile)==NULL) return(FALSE);
  1366. od_control.user_file_area=atoi(szIFTemp);
  1367. /* Line 24: Current node number. */
  1368. if(fgets(szIFTemp,255,pfDropFile)==NULL) return(FALSE);
  1369. od_control.od_node=atoi(szIFTemp);
  1370. /* Line 25: Unused. */
  1371. if(fgets((char *)apszDropFileInfo[10],80,pfDropFile)==NULL) return(FALSE);
  1372. /* Line 26: Unused. */
  1373. if(fgets((char *)apszDropFileInfo[11],80,pfDropFile)==NULL) return(FALSE);
  1374. /* Line 27: Unused. */
  1375. if(fgets((char *)apszDropFileInfo[12],80,pfDropFile)==NULL) return(FALSE);
  1376. /* Line 28: Kilobytes downloaded today. */
  1377. if(fgets(szIFTemp,255,pfDropFile)==NULL) return(FALSE);
  1378. od_control.user_todayk=atoi(szIFTemp);
  1379. /* Line 29: Kilobytes uploaded in total. */
  1380. if(fgets(szIFTemp,255,pfDropFile)==NULL) return(FALSE);
  1381. od_control.user_upk=atoi(szIFTemp);
  1382. /* Line 30: Kilobytes downloaded in total. */
  1383. if(fgets(szIFTemp,255,pfDropFile)==NULL) return(FALSE);
  1384. od_control.user_downk=atoi(szIFTemp);
  1385. /* Line 31: User's home phone number. */
  1386. if(fgets(szIFTemp,255,pfDropFile)==NULL) return(FALSE);
  1387. szIFTemp[15]='\0';
  1388. ODStringToName(szIFTemp);
  1389. strcpy(od_control.user_homephone,szIFTemp);
  1390. /* Line 32: User's home location. */
  1391. if(fgets(szIFTemp,255,pfDropFile)==NULL) return(FALSE);
  1392. szIFTemp[25]='\0';
  1393. ODStringToName(szIFTemp);
  1394. strcpy(od_control.user_location,szIFTemp);
  1395. /* Line 33: Unused. */
  1396. if(fgets((char *)apszDropFileInfo[15],80,pfDropFile)==NULL)
  1397. {
  1398. apszDropFileInfo[15][0]='\0';
  1399. }
  1400. /* Line 34: RIP mode. */
  1401. if(fgets(szIFTemp,255,pfDropFile) != NULL)
  1402. {
  1403. strupr(szIFTemp);
  1404. od_control.user_rip = (szIFTemp[0] == 'T');
  1405. }
  1406. /* line 35: User wants chat. */
  1407. if(fgets(szIFTemp,255,pfDropFile) != NULL)
  1408. {
  1409. strupr(szIFTemp);
  1410. od_control.user_wantchat = (szIFTemp[0] == 'T');
  1411. }
  1412. /* Line 36: Unused. */
  1413. if(fgets((char *)apszDropFileInfo[17],80,pfDropFile)==NULL)
  1414. {
  1415. apszDropFileInfo[17][0]='\0';
  1416. }
  1417. /* Line 37: IRQ number. */
  1418. if(fgets(szIFTemp,255,pfDropFile) != NULL)
  1419. {
  1420. od_control.od_com_irq = atoi(szIFTemp);
  1421. }
  1422. /* Line 38: Serial port address. */
  1423. if(fgets(szIFTemp,255,pfDropFile) != NULL)
  1424. {
  1425. od_control.od_com_address = atoi(szIFTemp);
  1426. }
  1427. /* Line 39: Unused. */
  1428. if(fgets((char *)apszDropFileInfo[18],80,pfDropFile)==NULL)
  1429. {
  1430. apszDropFileInfo[18][0]='\0';
  1431. }
  1432. fclose(pfDropFile);
  1433. return(TRUE);
  1434. }
  1435. /* ----------------------------------------------------------------------------
  1436. * ODInitReadExitInfo() *** PRIVATE FUNCTION ***
  1437. *
  1438. * Reads an EXITINFO.BBS format drop file.
  1439. *
  1440. * Parameters: none
  1441. *
  1442. * Return: void
  1443. */
  1444. static void ODInitReadExitInfo(void)
  1445. {
  1446. DWORD dwFileSize;
  1447. FILE *pfDropFile;
  1448. BYTE btCount;
  1449. od_control.od_extended_info=FALSE;
  1450. od_control.od_ra_info=FALSE;
  1451. /* Try to open EXITINFO.BBS. */
  1452. ODMakeFilename(szODWorkString, szExitinfoBBSPath, "exitinfo.bbs",
  1453. sizeof(szExitinfoBBSPath));
  1454. if((pfDropFile = fopen(szODWorkString, "rb")) != NULL)
  1455. {
  1456. dwFileSize = ODFileSize(pfDropFile);
  1457. if(dwFileSize >= 2363)
  1458. {
  1459. if((pRA2ExitInfoRecord=malloc(sizeof(tRA2ExitInfoRecord)))!=NULL)
  1460. {
  1461. if(fread(pRA2ExitInfoRecord,1,2363,pfDropFile)==2363)
  1462. {
  1463. od_control.od_ra_info=TRUE;
  1464. od_control.od_extended_info=TRUE;
  1465. od_control.od_info_type=RA2EXITINFO;
  1466. od_control.baud=(long)pRA2ExitInfoRecord->baud;
  1467. od_control.system_calls=pRA2ExitInfoRecord->num_calls;
  1468. ODStringPascalToC(od_control.system_last_caller,pRA2ExitInfoRecord->last_caller,35);
  1469. ODStringPascalToC(od_control.system_last_handle,pRA2ExitInfoRecord->sLastHandle,35);
  1470. ODStringPascalToC(od_control.timelog_start_date,pRA2ExitInfoRecord->start_date,8);
  1471. memcpy(&od_control.timelog_busyperhour,&pRA2ExitInfoRecord->busyperhour,62);
  1472. ODStringPascalToC(od_control.user_name,pRA2ExitInfoRecord->name,35);
  1473. ODStringPascalToC(od_control.user_location,pRA2ExitInfoRecord->location,25);
  1474. ODStringPascalToC(od_control.user_org,pRA2ExitInfoRecord->organisation,50);
  1475. for(btCount=0;btCount<3;++btCount)
  1476. ODStringPascalToC(od_control.user_address[btCount],pRA2ExitInfoRecord->address[btCount],50);
  1477. ODStringPascalToC(od_control.user_handle,pRA2ExitInfoRecord->handle,35);
  1478. ODStringPascalToC(od_control.user_comment,pRA2ExitInfoRecord->comment,80);
  1479. od_control.user_pwd_crc=pRA2ExitInfoRecord->password_crc;
  1480. ODStringPascalToC(od_control.user_dataphone,pRA2ExitInfoRecord->dataphone,15);
  1481. ODStringPascalToC(od_control.user_homephone,pRA2ExitInfoRecord->homephone,15);
  1482. ODStringPascalToC(od_control.user_lasttime,pRA2ExitInfoRecord->lasttime,5);
  1483. ODStringPascalToC(od_control.user_lastdate,pRA2ExitInfoRecord->lastdate,8);
  1484. od_control.user_attribute=pRA2ExitInfoRecord->attrib;
  1485. od_control.user_attrib2=pRA2ExitInfoRecord->attrib2;
  1486. memcpy(&od_control.user_flags,&pRA2ExitInfoRecord->flags,14);
  1487. od_control.user_security=pRA2ExitInfoRecord->sec;
  1488. od_control.user_lastread=pRA2ExitInfoRecord->lastread;
  1489. memcpy(&od_control.user_numcalls,&pRA2ExitInfoRecord->nocalls,29);
  1490. od_control.user_group=pRA2ExitInfoRecord->group;
  1491. memcpy(&od_control.user_combinedrecord,&pRA2ExitInfoRecord->combinedrecord,200);
  1492. ODStringPascalToC(od_control.user_firstcall,pRA2ExitInfoRecord->firstcall,8);
  1493. ODStringPascalToC(od_control.user_birthday,pRA2ExitInfoRecord->birthday,8);
  1494. ODStringPascalToC(od_control.user_subdate,pRA2ExitInfoRecord->subdate,8);
  1495. od_control.user_screenwidth=pRA2ExitInfoRecord->screenwidth;
  1496. od_control.user_language=pRA2ExitInfoRecord->language;
  1497. od_control.user_date_format=pRA2ExitInfoRecord->dateformat;
  1498. ODStringPascalToC(od_control.user_forward_to,pRA2ExitInfoRecord->forwardto,35);
  1499. memcpy(&od_control.user_msg_area,&pRA2ExitInfoRecord->msgarea,15);
  1500. od_control.user_sex = (pRA2ExitInfoRecord->sex == 1) ? 'M' : 'F';
  1501. od_control.user_attrib3=pRA2ExitInfoRecord->btAttribute3;
  1502. ODStringPascalToC(od_control.user_password,pRA2ExitInfoRecord->sPassword,15);
  1503. od_control.event_status=pRA2ExitInfoRecord->status;
  1504. ODStringPascalToC(od_control.event_starttime,pRA2ExitInfoRecord->starttime,5);
  1505. memcpy(&od_control.event_errorlevel,&pRA2ExitInfoRecord->errorlevel,3);
  1506. ODStringPascalToC(od_control.event_last_run,pRA2ExitInfoRecord->lasttimerun,8);
  1507. memcpy(&od_control.user_netmailentered,&pRA2ExitInfoRecord->netmailentered,2);
  1508. ODStringPascalToC(od_control.user_logintime,pRA2ExitInfoRecord->logintime,5);
  1509. ODStringPascalToC(od_control.user_logindate,pRA2ExitInfoRecord->logindate,8);
  1510. memcpy(&od_control.user_timelimit,&pRA2ExitInfoRecord->timelimit,6);
  1511. memcpy(&od_control.user_num,&pRA2ExitInfoRecord->userrecord,8);
  1512. ODStringPascalToC(od_control.user_timeofcreation,pRA2ExitInfoRecord->timeofcreation,5);
  1513. od_control.user_logon_pwd_crc=pRA2ExitInfoRecord->logonpasswordcrc;
  1514. od_control.user_wantchat=pRA2ExitInfoRecord->wantchat;
  1515. od_control.user_deducted_time=pRA2ExitInfoRecord->deducted_time;
  1516. for(btCount=0;btCount<50;++btCount)
  1517. ODStringPascalToC(od_control.user_menustack[btCount],pRA2ExitInfoRecord->menustack[btCount],8);
  1518. od_control.user_menustackpointer=pRA2ExitInfoRecord->menustackpointer;
  1519. memcpy(&od_control.user_error_free,&pRA2ExitInfoRecord->error_free,3);
  1520. ODStringPascalToC(od_control.user_emsi_crtdef,pRA2ExitInfoRecord->emsi_crtdef,40);
  1521. ODStringPascalToC(od_control.user_emsi_protocols,pRA2ExitInfoRecord->emsi_protocols,40);
  1522. ODStringPascalToC(od_control.user_emsi_capabilities,pRA2ExitInfoRecord->emsi_capabilities,40);
  1523. ODStringPascalToC(od_control.user_emsi_requests,pRA2ExitInfoRecord->emsi_requests,40);
  1524. ODStringPascalToC(od_control.user_emsi_software,pRA2ExitInfoRecord->emsi_software,40);
  1525. memcpy(&od_control.user_hold_attr1,&pRA2ExitInfoRecord->hold_attr1,3);
  1526. ODStringPascalToC(od_control.user_reasonforchat,pRA2ExitInfoRecord->page_reason,77);
  1527. btRAStatusToSet = pRA2ExitInfoRecord->status_line-1;
  1528. ODStringPascalToC(od_control.user_last_cost_menu,pRA2ExitInfoRecord->last_cost_menu,8);
  1529. od_control.user_menu_cost=pRA2ExitInfoRecord->menu_cost_per_min;
  1530. od_control.user_rip=pRA2ExitInfoRecord->has_rip;
  1531. od_control.user_rip_ver=pRA2ExitInfoRecord->btRIPVersion;
  1532. od_control.user_ansi=od_control.user_attribute&8;
  1533. od_control.user_avatar=od_control.user_attrib2&2;
  1534. }
  1535. else
  1536. {
  1537. free(pRA2ExitInfoRecord);
  1538. }
  1539. }
  1540. }
  1541. else if(dwFileSize>=1493)
  1542. {
  1543. if(ODReadExitInfoPrimitive(pfDropFile,476))
  1544. {
  1545. if((pExtendedExitInfo=malloc(sizeof(tExtendedExitInfo)))!=NULL)
  1546. {
  1547. if(fread(pExtendedExitInfo,1,sizeof(tExtendedExitInfo), pfDropFile)==sizeof(tExtendedExitInfo))
  1548. { /* transfer info into od_control struct */
  1549. ODStringPascalToC(od_control.user_timeofcreation,pExitInfoRecord->bbs.ra.timeofcreation,5);
  1550. ODStringPascalToC(od_control.user_logonpassword,pExitInfoRecord->bbs.ra.logonpassword,15);
  1551. od_control.user_wantchat=pExitInfoRecord->bbs.ra.wantchat;
  1552. od_control.user_deducted_time=pExtendedExitInfo->deducted_time;
  1553. for(btCount=0;btCount<50;++btCount)
  1554. {
  1555. ODStringPascalToC(od_control.user_menustack[btCount],pExtendedExitInfo->menustack[btCount],8);
  1556. }
  1557. od_control.user_menustackpointer=pExtendedExitInfo->menustackpointer;
  1558. ODStringPascalToC(od_control.user_handle,pExtendedExitInfo->userhandle,35);
  1559. ODStringPascalToC(od_control.user_comment,pExtendedExitInfo->comment,80);
  1560. ODStringPascalToC(od_control.user_firstcall,pExtendedExitInfo->firstcall,8);
  1561. memcpy(od_control.user_combinedrecord,pExtendedExitInfo->combinedrecord,25);
  1562. ODStringPascalToC(od_control.user_birthday,pExtendedExitInfo->birthday,8);
  1563. ODStringPascalToC(od_control.user_subdate,pExtendedExitInfo->subdate,8);
  1564. od_control.user_screenwidth=pExtendedExitInfo->screenwidth;
  1565. od_control.user_msg_area=pExtendedExitInfo->msgarea;
  1566. od_control.user_file_area=pExtendedExitInfo->filearea;
  1567. od_control.user_language=pExtendedExitInfo->language;
  1568. od_control.user_date_format=pExtendedExitInfo->dateformat;
  1569. ODStringPascalToC(od_control.user_forward_to,pExtendedExitInfo->forwardto,35);
  1570. memcpy(&od_control.user_error_free,&pExtendedExitInfo->error_free,3);
  1571. ODStringPascalToC(od_control.user_emsi_crtdef,pExtendedExitInfo->emsi_crtdef,40);
  1572. ODStringPascalToC(od_control.user_emsi_protocols,pExtendedExitInfo->emsi_protocols,40);
  1573. ODStringPascalToC(od_control.user_emsi_capabilities,pExtendedExitInfo->emsi_capabilities,40);
  1574. ODStringPascalToC(od_control.user_emsi_requests,pExtendedExitInfo->emsi_requests,40);
  1575. ODStringPascalToC(od_control.user_emsi_software,pExtendedExitInfo->emsi_software,40);
  1576. memcpy(&od_control.user_hold_attr1,&pExtendedExitInfo->hold_attr1,3);
  1577. od_control.od_ra_info=TRUE;
  1578. od_control.od_extended_info=TRUE;
  1579. od_control.od_info_type=RA1EXITINFO;
  1580. }
  1581. }
  1582. }
  1583. }
  1584. else if(dwFileSize>476)
  1585. {
  1586. if(dwFileSize > sizeof(tExitInfoRecord))
  1587. {
  1588. dwFileSize = sizeof(tExitInfoRecord);
  1589. }
  1590. if(ODReadExitInfoPrimitive(pfDropFile,(int)dwFileSize))
  1591. {
  1592. od_control.user_wantchat=pExitInfoRecord->bbs.qbbs.qwantchat;
  1593. for(btCount=0;btCount<pExitInfoRecord->bbs.qbbs.gosublevel;++btCount)
  1594. {
  1595. ODStringPascalToC(od_control.user_menustack[btCount],pExitInfoRecord->bbs.qbbs.menustack[btCount],8);
  1596. }
  1597. od_control.user_menustackpointer=pExitInfoRecord->bbs.qbbs.gosublevel;
  1598. ODStringPascalToC(od_control.user_menustack[od_control.user_menustackpointer],pExitInfoRecord->bbs.qbbs.menu,8);
  1599. od_control.od_extended_info=TRUE;
  1600. od_control.od_info_type=QBBS275EXITINFO;
  1601. nInitialElapsed=pExitInfoRecord->elapsed;
  1602. od_control.user_rip = pExitInfoRecord->bbs.qbbs.ripactive;
  1603. }
  1604. }
  1605. else if(dwFileSize>=452)
  1606. {
  1607. if(ODReadExitInfoPrimitive(pfDropFile,(int)dwFileSize))
  1608. {
  1609. ODStringPascalToC(od_control.user_timeofcreation,pExitInfoRecord->bbs.ra.timeofcreation,5);
  1610. ODStringPascalToC(od_control.user_logonpassword,pExitInfoRecord->bbs.ra.logonpassword,15);
  1611. od_control.user_wantchat=pExitInfoRecord->bbs.ra.wantchat;
  1612. od_control.od_extended_info=TRUE;
  1613. od_control.od_info_type=EXITINFO;
  1614. }
  1615. }
  1616. od_control.od_page_pausing=od_control.user_attribute&0x04;
  1617. fclose(pfDropFile);
  1618. }
  1619. }
  1620. /* ----------------------------------------------------------------------------
  1621. * ODInitPartTwo() *** PRIVATE FUNCTION ***
  1622. *
  1623. * Called by od_init() to carry on with second stage of OpenDoors
  1624. * initialization. The sole reason that this function exists is because some
  1625. * compilers were unable to compile this file with a huge od_init() function
  1626. * that had this code in the main od_init() body.
  1627. *
  1628. * Parameters: none
  1629. *
  1630. * Return: void
  1631. */
  1632. static void ODInitPartTwo(void)
  1633. {
  1634. BYTE btCount;
  1635. #ifdef ODPLAT_NIX
  1636. struct termios term;
  1637. struct passwd *uinfo;
  1638. #endif
  1639. /* Initialize any colors that haven't already been set. */
  1640. if(!od_control.od_list_title_col) od_control.od_list_title_col = 0x0f;
  1641. if(!od_control.od_continue_col) od_control.od_continue_col = 0x0f;
  1642. if(!od_control.od_list_name_col) od_control.od_list_name_col = 0x0e;
  1643. if(!od_control.od_list_size_col) od_control.od_list_size_col = 0x0d;
  1644. if(!od_control.od_list_comment_col) od_control.od_list_comment_col = 0x03;
  1645. if(!od_control.od_list_offline_col) od_control.od_list_offline_col = 0x0c;
  1646. if(!od_control.od_local_win_col) od_control.od_local_win_col = 0x19;
  1647. if(!od_control.od_menu_title_col) od_control.od_menu_title_col = 0x74;
  1648. if(!od_control.od_menu_border_col) od_control.od_menu_border_col = 0x70;
  1649. if(!od_control.od_menu_text_col) od_control.od_menu_text_col = 0x70;
  1650. if(!od_control.od_menu_key_col) od_control.od_menu_key_col = 0x7f;
  1651. if(!od_control.od_menu_highkey_col) od_control.od_menu_highkey_col = 0x0f;
  1652. if(!od_control.od_menu_highlight_col)
  1653. {
  1654. od_control.od_menu_highlight_col = 0x07;
  1655. }
  1656. /* Color sequence delimiter characters. */
  1657. od_control.od_color_char = '\0';
  1658. od_control.od_color_delimiter = '`';
  1659. /* Enable sysop paging between the hours of 8:00am and 10:00pm. */
  1660. od_control.od_okaytopage = PAGE_USE_HOURS;
  1661. od_control.od_pagestartmin = 480;
  1662. od_control.od_pageendmin = 1320;
  1663. /* Default maximum user inactivity is 200 seconds. */
  1664. od_control.od_inactivity = 200;
  1665. /* Screen clearing is on by default. */
  1666. od_control.od_always_clear = TRUE;
  1667. od_control.od_inactive_warning = 10;
  1668. od_control.od_cur_attrib = -1;
  1669. /* Enable screen clearing on door exit. */
  1670. od_control.od_clear_on_exit = TRUE;
  1671. /* RA/QBBS control codes are now disabled by default. */
  1672. od_control.od_no_ra_codes = TRUE;
  1673. if(od_control.od_chat_color1 == 0) od_control.od_chat_color1 = 0x0c;
  1674. if(od_control.od_chat_color2 == 0) od_control.od_chat_color2 = 0x0f;
  1675. /* Set default messages and prompts. */
  1676. od_control.od_before_shell = "\n\rPlease wait a moment...\n\r";
  1677. od_control.od_after_shell = "\n\r...Thanks for waiting\n\r\n\r";
  1678. od_control.od_help_text = " Alt: [C]hat [H]angup [L]ockout [J]Dos [K]eyboard-Off [D]rop to BBS ";
  1679. od_control.od_before_chat = "\n\rThe system operator has placed you in chat mode to talk with you:\n\r\n\r";
  1680. od_control.od_after_chat = "\n\rChat mode ended.\n\r\n\r";
  1681. od_control.od_inactivity_timeout = "\n\rMaximum user inactivity time has elapsed, please call again.\n\r\n\r";
  1682. od_control.od_inactivity_warning = "\n\rWARNING: Inactivity timeout in 10 seconds, press a key now to remain online.\n\r\n\r";
  1683. od_control.od_time_warning = "\n\rWARNING: You only have %d minute(s) remaining for this session.\n\r\n\r";
  1684. od_control.od_time_left = "%d mins ";
  1685. od_control.od_sysop_next = "[SN] ";
  1686. od_control.od_no_keyboard = "[Keyboard]";
  1687. od_control.od_want_chat = "[Want-Chat]";
  1688. od_control.od_no_time = "\n\rSorry, you have used up of your time for this session.\n\r\n\r";
  1689. od_control.od_no_sysop = "\n\rSorry, the system operator is not available at this time.\n\r";
  1690. od_control.od_press_key = "Press [Enter] to continue";
  1691. od_control.od_chat_reason = " Why would you like to chat? (Blank line to cancel)\n\r";
  1692. od_control.od_paging = "\n\rPaging system operator for chat";
  1693. od_control.od_no_response = " No response.\n\r\n\r";
  1694. od_control.od_status_line[0] = " [Node: ";
  1695. od_control.od_status_line[1] = "%s of %s at %lu BPS";
  1696. od_control.od_status_line[2] = "Security: Time: [F9]=Help ";
  1697. od_control.od_month[0] = "Jan";
  1698. od_control.od_month[1] = "Feb";
  1699. od_control.od_month[2] = "Mar";
  1700. od_control.od_month[3] = "Apr";
  1701. od_control.od_month[4] = "May";
  1702. od_control.od_month[5] = "Jun";
  1703. od_control.od_month[6] = "Jul";
  1704. od_control.od_month[7] = "Aug";
  1705. od_control.od_month[8] = "Sep";
  1706. od_control.od_month[9] = "Oct";
  1707. od_control.od_month[10] = "Nov";
  1708. od_control.od_month[11] = "Dec";
  1709. od_control.od_day[0] = "Sun";
  1710. od_control.od_day[1] = "Mon";
  1711. od_control.od_day[2] = "Tue";
  1712. od_control.od_day[3] = "Wed";
  1713. od_control.od_day[4] = "Thu";
  1714. od_control.od_day[5] = "Fri";
  1715. od_control.od_day[6] = "Sat";
  1716. od_control.od_offline = "[OFFLINE] ";
  1717. od_control.od_continue = "Continue? [Y/n/=]";
  1718. od_control.od_continue_yes = 'y';
  1719. od_control.od_continue_no = 'n';
  1720. od_control.od_continue_nonstop = '=';
  1721. od_control.od_help_text2 = OD_VER_STATUSLINE;
  1722. od_control.od_sending_rip = "Sending RIP file: ";
  1723. od_control.od_hanging_up = "Ending call...";
  1724. od_control.od_exiting = "Program is exiting...";
  1725. if(strlen(od_control.od_disable_dtr) == 0)
  1726. {
  1727. strcpy(od_control.od_disable_dtr, "~+++~ AT&D0| ATO|");
  1728. }
  1729. nInitialRemaining = od_control.user_timelimit;
  1730. if(od_control.od_maxtime > 0 && od_control.od_maxtime <= 1440)
  1731. {
  1732. if(od_control.user_timelimit > (INT)od_control.od_maxtime)
  1733. {
  1734. od_control.od_maxtime_deduction
  1735. = od_control.user_timelimit-od_control.od_maxtime;
  1736. od_control.user_timelimit
  1737. = od_control.od_maxtime;
  1738. }
  1739. }
  1740. /* If sysop name is unkown, then use the word "Sysop". */
  1741. if(strlen(od_control.sysop_name) == 0)
  1742. {
  1743. strcpy(od_control.sysop_name, "Sysop");
  1744. }
  1745. /* If in foced local mode and user name has not yet been set. */
  1746. if(od_control.od_force_local && od_control.user_name[0] == '\0')
  1747. {
  1748. /* If name prompting is not disabled, then turn on flag to prompt for */
  1749. /* user's name. */
  1750. if(!(od_control.od_disable & DIS_NAME_PROMPT))
  1751. {
  1752. bPromptForUserName = TRUE;
  1753. }
  1754. /* Use sysop's name as default user name. */
  1755. if(bSysopNameSet)
  1756. {
  1757. strcpy(od_control.user_name, szForcedSysopName);
  1758. }
  1759. else
  1760. {
  1761. strcpy(od_control.user_name, od_control.sysop_name);
  1762. }
  1763. }
  1764. dwFileBPS = od_control.baud;
  1765. /* Determine desired BPS rate. */
  1766. if(dwForcedBPS != 1)
  1767. {
  1768. if(od_control.od_disable & DIS_LOCAL_OVERRIDE || od_control.baud != 0)
  1769. {
  1770. od_control.baud = dwForcedBPS;
  1771. }
  1772. }
  1773. /* If we are not operating in local mode, then setup for serial I/O. */
  1774. #ifndef ODPLAT_NIX
  1775. if(od_control.baud != 0)
  1776. #endif
  1777. {
  1778. tComMethod ComMethod;
  1779. /* Attempt to allocate an OpenDoors port object. */
  1780. if(ODComAlloc(&hSerialPort) != kODRCSuccess)
  1781. {
  1782. malloc_error:
  1783. ODInitError("Insufficient memory available to start up program.");
  1784. exit(od_control.od_errorlevel[1]);
  1785. }
  1786. /* Set socket I/O method, if specified by user. */
  1787. if(od_control.od_use_socket)
  1788. {
  1789. ODComSetPreferredMethod(hSerialPort, kComMethodSocket);
  1790. }
  1791. #if defined ODPLAT_WIN32 || defined ODPLAT_NIX
  1792. /* Check whether a handle has been provided by the caller. */
  1793. if(od_control.od_open_handle != 0)
  1794. {
  1795. if(ODComOpenFromExistingHandle(hSerialPort, od_control.od_open_handle)
  1796. != kODRCSuccess)
  1797. {
  1798. ODInitError("Unable to use provided serial port handle.");
  1799. exit(od_control.od_errorlevel[1]);
  1800. }
  1801. }
  1802. else
  1803. #endif /* ODPLAT_WIN32 */
  1804. {
  1805. /* Set flow control type. */
  1806. switch(od_control.od_com_flow_control)
  1807. {
  1808. case COM_NO_FLOW:
  1809. ODComSetFlowControl(hSerialPort, FLOW_NONE);
  1810. break;
  1811. case COM_RTSCTS_FLOW:
  1812. ODComSetFlowControl(hSerialPort, FLOW_RTSCTS);
  1813. break;
  1814. case COM_DEFAULT_FLOW:
  1815. /* Don't say anything to the serial I/O module about flow */
  1816. /* control. */
  1817. break;
  1818. default:
  1819. /* We should never get here. */
  1820. ASSERT(FALSE);
  1821. }
  1822. /* Determine desired port. */
  1823. if(nForcedPort != -1) od_control.port=nForcedPort;
  1824. /* Set port number. */
  1825. ODComSetPort(hSerialPort, (BYTE)od_control.port);
  1826. /* If serial port address has been explicitly set, then set user's */
  1827. /* port address in serial port object. */
  1828. if(od_control.od_com_address != 0)
  1829. {
  1830. ODComSetPortAddress(hSerialPort, od_control.od_com_address);
  1831. }
  1832. /* If serial port IRQ line number has been explicitly set, then */
  1833. /* set user's setting in serial port object. */
  1834. if(od_control.od_com_irq >= 1 && od_control.od_com_irq < 15)
  1835. {
  1836. ODComSetIRQ(hSerialPort, od_control.od_com_irq);
  1837. }
  1838. /* Set BPS rate, if this is not disabled. */
  1839. if(!(od_control.od_disable&DIS_BPS_SETTING))
  1840. {
  1841. ODComSetSpeed(hSerialPort, od_control.baud);
  1842. }
  1843. else
  1844. {
  1845. ODComSetSpeed(hSerialPort, SPEED_UNSPECIFIED);
  1846. }
  1847. /* Set serial I/O method, if specified by user. */
  1848. if(od_control.od_no_fossil)
  1849. {
  1850. ODComSetPreferredMethod(hSerialPort, kComMethodUART);
  1851. }
  1852. /* Establish default buffer sizes */
  1853. if(od_control.od_com_rx_buf == 0)
  1854. od_control.od_com_rx_buf = 256;
  1855. if(od_control.od_com_tx_buf == 0)
  1856. od_control.od_com_tx_buf = 3072;
  1857. /* Set buffer sizes for serial port. */
  1858. ODComSetRXBuf(hSerialPort, od_control.od_com_rx_buf);
  1859. ODComSetTXBuf(hSerialPort, od_control.od_com_tx_buf);
  1860. /* Set FIFO enabled/disabled and trigger size */
  1861. if(od_control.od_com_no_fifo)
  1862. {
  1863. /* Disable UART FIFO buffers. */
  1864. ODComSetFIFO(hSerialPort, FIFO_DISABLE);
  1865. }
  1866. else
  1867. {
  1868. /* Enable FIFO, setting size of FIFO trigger. */
  1869. switch(od_control.od_com_fifo_trigger)
  1870. {
  1871. case 1:
  1872. ODComSetFIFO(hSerialPort, FIFO_ENABLE | FIFO_TRIGGER_1);
  1873. break;
  1874. case 4:
  1875. ODComSetFIFO(hSerialPort, FIFO_ENABLE | FIFO_TRIGGER_4);
  1876. break;
  1877. case 8:
  1878. ODComSetFIFO(hSerialPort, FIFO_ENABLE | FIFO_TRIGGER_8);
  1879. break;
  1880. case 14:
  1881. ODComSetFIFO(hSerialPort, FIFO_ENABLE | FIFO_TRIGGER_14);
  1882. break;
  1883. default:
  1884. od_control.od_com_fifo_trigger = 4;
  1885. ODComSetFIFO(hSerialPort, FIFO_ENABLE | FIFO_TRIGGER_4);
  1886. }
  1887. }
  1888. #ifdef ODPLAT_DOS
  1889. /* Set od_kernel() to be idle function. */
  1890. ODComSetIdleFunction(hSerialPort, od_kernel);
  1891. #endif /* ODPLAT_DOS */
  1892. /* Open serial port. */
  1893. switch(ODComOpen(hSerialPort))
  1894. {
  1895. case kODRCSuccess:
  1896. /* Serial port open succeeded, so proceed with OpenDoors */
  1897. /* initialization. */
  1898. break;
  1899. case kODRCNoMemory:
  1900. goto malloc_error;
  1901. case kODRCNoPortAddress:
  1902. ODInitError("Serial port address is unknown, cannot continue.");
  1903. exit(od_control.od_errorlevel[1]);
  1904. break;
  1905. case kODRCNoUART:
  1906. ODInitError("No UART at specified port address, cannot continue.\n");
  1907. exit(od_control.od_errorlevel[1]);
  1908. break;
  1909. default:
  1910. ODInitError("Unable to access serial port, cannot continue.\n");
  1911. exit(od_control.od_errorlevel[1]);
  1912. break;
  1913. }
  1914. }
  1915. /* Raise DTR signal. */
  1916. ODComSetDTR(hSerialPort, TRUE);
  1917. /* Get serial I/O method actually being used. */
  1918. ODComGetMethod(hSerialPort, (tComMethod *)&ComMethod);
  1919. switch(ComMethod)
  1920. {
  1921. case kComMethodFOSSIL:
  1922. od_control.od_com_method = COM_FOSSIL;
  1923. break;
  1924. case kComMethodUART:
  1925. od_control.od_com_method = COM_INTERNAL;
  1926. break;
  1927. case kComMethodWin32:
  1928. od_control.od_com_method = COM_WIN32;
  1929. break;
  1930. case kComMethodDoor32:
  1931. od_control.od_com_method = COM_DOOR32;
  1932. break;
  1933. case kComMethodSocket:
  1934. od_control.od_com_method = COM_SOCKET; /* Why are using doubling up constants here? */
  1935. break;
  1936. case kComMethodStdIO:
  1937. od_control.od_com_method = COM_STDIO;
  1938. break;
  1939. default:
  1940. ODInitError("No method of accessing serial port, cannot continue.\n");
  1941. exit(od_control.od_errorlevel[1]);
  1942. break;
  1943. }
  1944. }
  1945. /* If we are operating in local mode, then disable silent mode. */
  1946. if(od_control.baud == 0)
  1947. {
  1948. od_control.od_silent_mode = FALSE;
  1949. }
  1950. /* Setup local screen. */
  1951. ODScrnInitialize();
  1952. #ifdef OD_TEXTMODE
  1953. ODScrnSetBoundary(1, 1, 80, 23);
  1954. #else /* !OD_TEXTMODE */
  1955. ODScrnSetBoundary(1, 1, 80, 25);
  1956. #endif /* !OD_TEXTMODE */
  1957. #ifndef ODPLAT_WIN32
  1958. if(bPreset)
  1959. {
  1960. atexit(ODAtExitCallback);
  1961. bPreset = FALSE;
  1962. }
  1963. #endif /* !ODPLAT_WIN32 */
  1964. /* Setup remote terminal for ANSI graphics if operating in RIP mode. */
  1965. if(od_control.user_rip)
  1966. {
  1967. od_clr_scr();
  1968. }
  1969. #ifdef ODPLAT_WIN32
  1970. /* Startup the OpenDoors frame window, if we are not operating in silent */
  1971. /* mode. */
  1972. if(!od_control.od_silent_mode)
  1973. {
  1974. #ifdef OD_DLL
  1975. ODFrameStart(GetModuleHandle(OD_DLL_NAME), &hFrameThread);
  1976. #else /* !OD_DLL */
  1977. ODFrameStart(GetModuleHandle(NULL), &hFrameThread);
  1978. #endif /* !OD_DLL */
  1979. }
  1980. #endif /* ODPLAT_WIN32 */
  1981. /* Initialize the OpenDoors kernel. */
  1982. ODKrnlInitialize();
  1983. #ifndef ODPLAT_WIN32
  1984. #ifdef ODPLAT_NIX
  1985. if(bPromptForUserName)
  1986. {
  1987. od_control.od_com_method=COM_STDIO;
  1988. od_control.baud=19200;
  1989. gethostname(od_control.system_name,sizeof(od_control.system_name));
  1990. od_control.system_name[sizeof(od_control.system_name)-1]=0;
  1991. if (isatty(STDIN_FILENO)) {
  1992. tcgetattr(STDIN_FILENO,&term);
  1993. od_control.baud=cfgetispeed(&term);
  1994. if(!od_control.baud)
  1995. od_control.baud=cfgetispeed(&term);
  1996. if(!od_control.baud)
  1997. od_control.baud=19200;
  1998. }
  1999. uinfo=getpwuid(getuid());
  2000. if (uinfo == NULL) {
  2001. ODStringCopy(od_control.user_handle, "unknown",sizeof(od_control.user_handle));
  2002. ODStringCopy(od_control.user_name, "unknown",sizeof(od_control.user_name));
  2003. } else {
  2004. ODStringCopy(od_control.user_handle, uinfo->pw_name,sizeof(od_control.user_handle));
  2005. ODStringCopy(od_control.user_name, uinfo->pw_gecos,sizeof(od_control.user_name));
  2006. };
  2007. }
  2008. #else
  2009. if(bPromptForUserName)
  2010. {
  2011. void *pWindow = ODScrnCreateWindow(10, 8, 70, 15,
  2012. od_control.od_local_win_col, od_control.od_prog_name,
  2013. od_control.od_local_win_col);
  2014. if(pWindow != NULL)
  2015. {
  2016. ODScrnSetCursorPos(12, 9);
  2017. ODScrnDisplayString("This program has been started in local mode,");
  2018. ODScrnSetCursorPos(12, 10);
  2019. ODScrnDisplayString("independently of a BBS system. When operating in this");
  2020. ODScrnSetCursorPos(12, 11);
  2021. ODScrnDisplayString("mode, you may specify what name you should be known to");
  2022. ODScrnSetCursorPos(12, 12);
  2023. ODScrnDisplayString("the program by.");
  2024. ODScrnSetCursorPos(12, 14);
  2025. ODScrnDisplayString("Your name:");
  2026. ODScrnLocalInput(23, 14, od_control.user_name, 35);
  2027. ODStringCopy(od_control.user_handle, od_control.user_name,
  2028. sizeof(od_control.user_name));
  2029. ODScrnDestroyWindow(pWindow);
  2030. ODScrnSetCursorPos(1, 1);
  2031. ODScrnSetAttribute(0x07);
  2032. }
  2033. }
  2034. #endif /* !ODPLAT_NIX */
  2035. #endif /* !ODPLAT_WIN32 */
  2036. #ifdef OD_TEXTMODE
  2037. /* Setup sysop status line/function key personality. */
  2038. if(pfSetPersonality == NULL)
  2039. {
  2040. no_default:
  2041. if (od_control.od_default_personality == NULL)
  2042. {
  2043. pfCurrentPersonality = pdef_opendoors;
  2044. }
  2045. else
  2046. {
  2047. pfCurrentPersonality = od_control.od_default_personality;
  2048. }
  2049. (*pfCurrentPersonality)(20);
  2050. if(bRAStatus)
  2051. {
  2052. od_set_statusline(btRAStatusToSet);
  2053. }
  2054. else
  2055. {
  2056. od_set_statusline(0);
  2057. }
  2058. }
  2059. else
  2060. {
  2061. if(!((*pfSetPersonality)(szDesiredPersonality)))
  2062. {
  2063. goto no_default;
  2064. }
  2065. }
  2066. #endif /* OD_TEXTMODE */
  2067. /* If connect speed has not been set yet, then set it to the */
  2068. /* serial port speed. */
  2069. if(od_control.od_connect_speed == 0)
  2070. {
  2071. od_control.od_connect_speed = od_control.baud;
  2072. }
  2073. /* Initialize the array of characters to use for drawing boxes, */
  2074. /* window and menu boarders, etc. */
  2075. od_control.od_box_chars[0] = 218U;
  2076. od_control.od_box_chars[1] = 196U;
  2077. od_control.od_box_chars[2] = 191U;
  2078. od_control.od_box_chars[3] = 179U;
  2079. od_control.od_box_chars[4] = 192U;
  2080. od_control.od_box_chars[5] = 217U;
  2081. /* Enable pausing and stoping of listing. */
  2082. od_control.od_list_stop = TRUE;
  2083. od_control.od_list_pause = TRUE;
  2084. /* Initialize array of logfile messages. */
  2085. for(btCount = 0; btCount < DIM(apszLogMessages); ++btCount)
  2086. {
  2087. if(od_control.od_logfile_messages[btCount] == NULL)
  2088. {
  2089. od_control.od_logfile_messages[btCount]
  2090. = apszLogMessages[btCount];
  2091. }
  2092. }
  2093. /* Set log file name to default, if none has been specified already. */
  2094. if(strlen(od_control.od_logfile_name) == 0)
  2095. {
  2096. strcpy(od_control.od_logfile_name, "DOOR.LOG");
  2097. }
  2098. /* If OpenDoors log file system is installed, then start it up. */
  2099. if(od_control.od_logfile != NULL)
  2100. {
  2101. (*(OD_COMPONENT_CALLBACK *)od_control.od_logfile)();
  2102. }
  2103. }
  2104. /* ----------------------------------------------------------------------------
  2105. * ODInitError()
  2106. *
  2107. * Called to display an error message when OpenDoors initialization fails,
  2108. * forcing the program to exit.
  2109. *
  2110. * Parameters: pszErrorText - Pointer to the error message explaining the
  2111. * reason for failure.
  2112. *
  2113. * Return: void
  2114. */
  2115. void ODInitError(char *pszErrorText)
  2116. {
  2117. #ifdef ODPLAT_DOS
  2118. printf("%s: %s\n", od_control.od_prog_name, pszErrorText);
  2119. if(bParsedCmdLine)
  2120. {
  2121. printf("Use the -HELP command line option for help, or -LOCAL for local mode.\n");
  2122. }
  2123. #endif
  2124. #ifdef ODPLAT_WIN32
  2125. char *pszMessage;
  2126. if(!bParsedCmdLine ||
  2127. (pszMessage = malloc(strlen(pszErrorText) + 80)) == NULL)
  2128. {
  2129. MessageBox(NULL, pszErrorText, od_control.od_prog_name,
  2130. MB_ICONSTOP | MB_OK | MB_TASKMODAL);
  2131. }
  2132. else
  2133. {
  2134. sprintf(pszMessage,
  2135. "%s\nUse the -HELP command line option for help, or -LOCAL for local mode.",
  2136. pszErrorText);
  2137. MessageBox(NULL, pszMessage, od_control.od_prog_name,
  2138. MB_ICONSTOP | MB_OK | MB_TASKMODAL);
  2139. free(pszMessage);
  2140. }
  2141. #endif
  2142. #ifdef ODPLAT_NIX
  2143. fwrite(pszErrorText,strlen(pszErrorText),1,stderr);
  2144. #endif
  2145. }
  2146. /* ----------------------------------------------------------------------------
  2147. * ODInitLoginDlgProc()
  2148. *
  2149. * Dialog box proceedure for the local mode login dialog box.
  2150. *
  2151. * Parameters: hwndDlg - Window handle to the dialog box.
  2152. *
  2153. * uMsg - Message ID.
  2154. *
  2155. * wParam - First message parameter.
  2156. *
  2157. * lParam - Second message parameter.
  2158. *
  2159. * Return: TRUE if message is processed, FALSE otherwise.
  2160. */
  2161. #ifdef ODPLAT_WIN32
  2162. BOOL CALLBACK ODInitLoginDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam,
  2163. LPARAM lParam)
  2164. {
  2165. switch(uMsg)
  2166. {
  2167. case WM_INITDIALOG:
  2168. ODFrameCenterWindowInParent(hwndDlg);
  2169. /* Set the title of the dialog box to the name of this program. */
  2170. SetWindowText(hwndDlg, od_control.od_prog_name);
  2171. /* The initial text in the user name dialog box should be the */
  2172. /* default user name. */
  2173. SetWindowText(GetDlgItem(hwndDlg, IDC_USER_NAME),
  2174. od_control.user_name);
  2175. /* Limit the number of characters that may be entered as the */
  2176. /* user's name to the maximum size of the string. */
  2177. SendMessage(GetDlgItem(hwndDlg, IDC_USER_NAME), EM_LIMITTEXT,
  2178. sizeof(od_control.user_name), 0L);
  2179. return(TRUE);
  2180. case WM_COMMAND:
  2181. /* If a command has been chosen. */
  2182. switch(LOWORD(wParam))
  2183. {
  2184. case IDOK:
  2185. /* If the OK button has been pressed, obtain the entered */
  2186. /* user name. */
  2187. GetWindowText(GetDlgItem(hwndDlg, IDC_USER_NAME),
  2188. od_control.user_name, sizeof(od_control.user_name));
  2189. ODStringCopy(od_control.user_handle, od_control.user_name,
  2190. sizeof(od_control.user_name));
  2191. /* Now close the dialog. */
  2192. EndDialog(hwndDlg, IDOK);
  2193. break;
  2194. case IDCANCEL:
  2195. /* If the Cancel button has benn pressed, close the dialog. */
  2196. EndDialog(hwndDlg, IDCANCEL);
  2197. break;
  2198. }
  2199. return(TRUE);
  2200. default:
  2201. /* Otherwise, indicate that this message has not been processed. */
  2202. return(FALSE);
  2203. }
  2204. }
  2205. #endif /* ODPLAT_WIN32 */