Synchronet now requires the libarchive development package (e.g. libarchive-dev on Debian-based Linux distros, libarchive.org for more info) to build successfully.

ODInEx1.c 88.1 KB
Newer Older
rswindell's avatar
rswindell committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
/* OpenDoors Online Software Programming Toolkit
 * (C) Copyright 1991 - 1999 by Brian Pirie.
 *
 * Oct-2001 door32.sys/socket modifications by Rob Swindell (www.synchro.net)
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 *
 *        File: ODInEx1.c
 *
 * Description: Performs OpenDoors initialization and shutdown operations
 *              (od_init() and od_exit()), including drop file I/O. This
 *              module is broken into two files, ODInEx1.c and ODInEx2.c.
 *
 *   Revisions: Date          Ver   Who  Change
 *              ---------------------------------------------------------------
 *              Oct 13, 1994  6.00  BP   New file header format.
 *              Oct 19, 1994  6.00  BP   Default paging hours 8:00-22:00.
 *              Oct 21, 1994  6.00  BP   Further isolated com routines.
 *              Oct 29, 1994  6.00  BP   Properly read dorinfo?.def BBS name.
 *              Oct 31, 1994  6.00  BP   Only use dorinfo?.def /w exitinfo.bbs.
 *              Dec 09, 1994  6.00  BP   Standardized coding style.
 *              Dec 31, 1994  6.00  BP   Remove call to _mt_init().
 *              Dec 31, 1994  6.00  BP   Add call to ODPlatInit().
 *              Jul 30, 1995  6.00  BP   Split up od_init().
 *              Nov 11, 1995  6.00  BP   Removed register keyword.
 *              Nov 14, 1995  6.00  BP   Added include of odscrn.h.
 *              Nov 14, 1995  6.00  BP   New default for od_colour_char is 0.
 *              Nov 16, 1995  6.00  BP   Removed oddoor.h, added odcore.h.
 *              Nov 17, 1995  6.00  BP   Use new input queue mechanism.
 *              Nov 23, 1995  6.00  BP   Moved Pascal conversion to odutil.c.
 *              Dec 21, 1995  6.00  BP   Add ability to use already open port.
 *              Dec 22, 1995  6.00  BP   Added od_connect_speed.
 *              Dec 30, 1995  6.00  BP   Added ODCALL for calling convention.
 *              Dec 30, 1995  6.00  BP   Only use comm idle func under DOS.
 *              Jan 01, 1996  6.00  BP   Added od_disable_dtr.
 *              Jan 01, 1996  6.00  BP   Raise DTR after opening serial port.
 *              Jan 02, 1996  6.00  BP   Use printf() in ODInitError().
 *              Jan 03, 1996  6.00  BP   Display connect speed with %lu.
 *              Jan 19, 1996  6.00  BP   Don't use atexit() under Win32.
 *              Jan 19, 1996  6.00  BP   Make ODInitError() a shared function.
 *              Jan 20, 1996  6.00  BP   Prompt for user name if force_local.
 *              Jan 23, 1996  6.00  BP   Added od_exiting and OD_TEXTMODE.
 *              Jan 31, 1996  6.00  BP   Added DIS_NAME_PROMPT.
 *              Jan 31, 1996  6.00  BP   Support new SFDOORS.DAT format.
 *              Feb 02, 1996  6.00  BP   Added RA 2.50 EXITINFO.BBS support.
 *              Feb 06, 1996  6.00  BP   Added od_silent_mode.
 *              Feb 08, 1996  6.00  BP   Recognize SFSYSOP.DAT.
 *              Feb 09, 1996  6.00  BP   Correctly translate RA 2.x sex field.
 *              Feb 09, 1996  6.00  BP   Made default outbound buffer 3072.
 *              Feb 19, 1996  6.00  BP   Changed version number to 6.00.
 *              Feb 20, 1996  6.00  BP   Added bParsedCmdLine.
 *              Feb 21, 1996  6.00  BP   Don't override command line options.
 *              Feb 21, 1996  6.00  BP   Change od_always_clear default to on.
 *              Feb 23, 1996  6.00  BP   Changed default DTR disable string.
 *              Mar 03, 1996  6.10  BP   Begin version 6.10.
 *              Mar 06, 1996  6.10  BP   Added TRIBBS.SYS support.
 *              Mar 06, 1996  6.10  BP   Initial support for Door32 interface.
 *              Mar 13, 1996  6.10  BP   Added od_local_win_col.
 *              Mar 17, 1996  6.10  BP   Reset text color after local login.
 *              Mar 19, 1996  6.10  BP   MSVC15 source-level compatibility.
 *              Apr 08, 1996  6.10  BP   Store local login name in user_handle.
 *              Jan 13, 1997  6.10  BP   Fixes for Door32 support.
 *              Oct 19, 2001  6.20  RS   Added door32.sys and socket support.
77
 *              Aug 10, 2003  6.23  SH   *nix support
rswindell's avatar
rswindell committed
78 79 80 81 82 83 84 85 86 87 88 89
 */

#define BUILDING_OPENDOORS

#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <ctype.h>
#include <time.h>

#include "OpenDoor.h"
90 91 92 93 94 95
#ifdef ODPLAT_NIX
#include <termios.h>
#include <unistd.h>
#include <sys/types.h>
#include <pwd.h>
#endif
96
#include "ODStr.h"
rswindell's avatar
rswindell committed
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249
#include "ODCore.h"
#include "ODGen.h"
#include "ODScrn.h"
#include "ODInQue.h"
#include "ODKrnl.h"
#include "ODInEx.h"
#include "ODUtil.h"
#ifdef ODPLAT_WIN32
#include "ODFrame.h"
#include "ODRes.h"
#endif /* ODPLAT_WIN32 */

/* Default size of local/remote combined keyboard buffer. */
#define DEFAULT_EVENT_QUEUE_SIZE    128


/* Local private helper functions. */
static void ODInitReadExitInfo(void);
static void ODInitPartTwo(void);
static BOOL ODInitReadSFDoorsDAT(void);
static void ODInitPartTwo(void);


/* Private variables. */
static BYTE btRAStatusToSet = 0;
#ifndef ODPLAT_WIN32
static BOOL bPreset = TRUE;
#endif /* !ODPLAT_WIN32 */
static char szIFTemp[256];

/* Configuration file keywords. */
static char *apszConfigText[] =
{
   "Node",
   "BBSDir",
   "DoorDir",
   "LogFileName",
   "DisableLogging",
   "SundayPagingHours",
   "MondayPagingHours",
   "TuesdayPagingHours",
   "WednesdayPagingHours",
   "ThursdayPagingHours",
   "FridayPagingHours",
   "SaturdayPagingHours",
   "MaximumDoorTime",
   "SysopName",
   "SystemName",
   "SwappingDisable",
   "SwappingDir",
   "SwappingNoEMS",
   "LockedBPS",
   "SerialPort",
   "CustomFileName",
   "CustomFileLine",
   "InactivityTimeout",
   "PageDuration",
   "ChatUserColour",
   "ChatSysopColour",
   "FileListTitleColour",
   "FileListNameColour",
   "FileListSizeColour",
   "FileListDescriptionColour",
   "FileListOfflineColour",
   "Personality",
   "NoFossil",
   "PortAddress",
   "PortIRQ",
   "ReceiveBuffer",
   "TransmitBuffer",
   "PagePromptColour",
   "LocalMode",
   "PopupMenuTitleColour",
   "PopupMenuBorderColour",
   "PopupMenuTextColour",
   "PopupMenuKeyColour",
   "PopupMenuHighlightColour",
   "PopupMenuHighKeyColour",
   "NoFIFO",
   "FIFOTriggerSize",
   "DisableDTR",
   "NoDTRDisable",
};

/* Custom drop file keywords. */
static char *apszConfigLines[] =
{
   "Ignore",
   "ComPort",
   "FossilPort",
   "ModemBPS",
   "LocalMode",
   "UserName",
   "UserFirstName",
   "UserLastName",
   "Alias",
   "HoursLeft",
   "MinutesLeft",
   "SecondsLeft",
   "ANSI",
   "AVATAR",
   "PagePausing",
   "ScreenLength",
   "ScreenClearing",
   "Security",
   "City",
   "Node",
   "SysopName",
   "SysopFirstName",
   "SysopLastName",
   "SystemName",
   "RIP",
};

/* Logfile messages. */
static char *apszLogMessages[] = 
{
   "Carrier lost, exiting door",
   "System operator terminating call, exiting door",
   "User's time limit expired, exiting door",
   "User keyboard inactivity time limit exceeded, exiting door",
   "System operator returning user to BBS, exiting door",
   "Exiting door with errorlevel %d",
   "Invoking operating system shell",
   "Returning from operating system shell",
   "User paging system operator",
   "Entering sysop chat mode",
   "Terminating sysop chat mode",
   "%s entering door",
   "Reason for chat: %s",
   "Exiting door",
};

/* Color name strings. */
static char *apszColorNames[] =
{
   "BLACK",
   "BLUE",
   "GREEN",
   "CYAN",
   "RED",
   "MAGENTA",
   "YELLOW",
   "WHITE",
   "BROWN",
   "GREY",
   "BRIGHT",
   "FLASHING",
};

/* Array of door information (drop) file names to search for. */
static char *apszDropFileNames[] = 
{
250 251 252 253 254 255 256 257 258 259 260 261
   "exitinfo.bbs",
   "dorinfo1.def",
   "chain.txt",
   "sfdoors.dat",
   "door.sys",
   "callinfo.bbs",
   "sfmain.dat",
   "sffile.dat",
   "sfmess.dat",
   "sfsysop.dat",
   "tribbs.sys",
   "door32.sys",
rswindell's avatar
rswindell committed
262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541
};

/* Array of door information (drop) file numbers 
 * (corresponding to apszDropFileNames) 
 */
static enum {
   FOUND_EXITINFO_BBS,
   FOUND_DORINFO1_DEF,
   FOUND_CHAIN_TXT,
   FOUND_SFDOORS_DAT,
   FOUND_DOOR_SYS,
   FOUND_CALLINFO_BBS,
   FOUND_SFMAIN_DAT,
   FOUND_SFFILE_DAT,
   FOUND_SFMESS_DAT,
   FOUND_SFSYSOP_DAT,
   FOUND_TRIBBS_SYS,
   FOUND_DOOR32_SYS,
};

#define FOUND_NONE -1


/* Global variables. */
WORD wODNodeNumber = 65535U;
BOOL bIsCoSysop;
BOOL bIsSysop;
char *apszDropFileInfo[25];
BYTE btExitReason = 0;
DWORD dwForcedBPS = 1;
INT nForcedPort = -1;
DWORD dwFileBPS;
char szDropFilePath[120];
char szExitinfoBBSPath[120];
INT16 nInitialElapsed;
char *szOriginalDir = NULL;
BYTE btDoorSYSLock = 0;
time_t nStartupUnixTime;
INT16 nInitialRemaining;
BOOL bSysopNameSet = FALSE;
char szForcedSysopName[40];
BOOL bSystemNameSet = FALSE;
char szForcedSystemName[40];
BOOL bUserFull = FALSE;
BOOL bCalledFromConfig = FALSE;
tRA2ExitInfoRecord *pRA2ExitInfoRecord = NULL;
tExitInfoRecord *pExitInfoRecord = NULL;
tExtendedExitInfo *pExtendedExitInfo = NULL;
struct _pcbsys *pPCBoardSysRecord = NULL;
struct _userssyshdr *pUserSysHeader = NULL;
struct _userssysrec *pUserSysRecord = NULL;
BOOL bPreOrExit = FALSE;
BOOL bRAStatus;
BOOL bPromptForUserName = FALSE;
BOOL bParsedCmdLine = FALSE;
WORD wPreSetInfo = 0;
#ifdef ODPLAT_WIN32
tODThreadHandle hFrameThread;
#endif /* ODPLAT_WIN32 */


/* ----------------------------------------------------------------------------
 * od_init()
 *
 * Starts up OpenDoors. Initializes various members of od_control, reads the
 * BBS door information (drop file), initializes the serial port and carries
 * out other operations that must be done at initialization time. May be
 * explicitly called by the user, or called as a result of the first call to
 * some other OpenDoors API function.
 *
 * Parameters: none
 *
 *     Return: void
 */
ODAPIDEF void ODCALL od_init(void)
{
   BYTE btCount;
   FILE *pfDropFile=NULL;
   char *pointer;
   INT nFound = FOUND_NONE;

   /* Log function entry if running in trace mode. */
   TRACE(TRACE_API, "od_init()");

   /* If a callback function is active, then don't do anything. */
   if(bIsCallbackActive) return;

   /* If we are not being called from within ODConfigInit(). */
   if(!bCalledFromConfig)
   {
      /* If OpenDoors has already been initialized, then return without */
      /* doing anything.                                                */
      if(bODInitialized) return;

      /* Otherwise, set the initialized flag so that od_init() won't be */
      /* run again.                                                     */
      bODInitialized = TRUE;

      /* Initialize program name string. */
      if(od_control.od_prog_name[0] == '\0')
      {
         strcpy(od_control.od_prog_name, OD_VER_SHORTNAME);
      }

      /* Initialize color name strings in od_control. */
      for(btCount = 0; btCount < DIM(apszColorNames); ++btCount)
      {
         if(!*od_control.od_color_names[btCount])
         {
            strcpy(od_control.od_color_names[btCount],
               apszColorNames[btCount]);
         }
      }

      /* Initialize custom drop file strings in od_control. */
      for(btCount = 0; btCount < LINES_SIZE; ++btCount)
      {
         if(!*od_control.od_cfg_lines[btCount])
         {
            strcpy(od_control.od_cfg_lines[btCount], apszConfigLines[btCount]);
         }
      }

      /* Initialize configuration keyword strings in od_control. */
      for(btCount = 0; btCount < TEXT_SIZE; ++btCount)
      {
         if(!*od_control.od_cfg_text[btCount])
         {
            strcpy(od_control.od_cfg_text[btCount], apszConfigText[btCount]);
         }
      }

      /* Enable multiple personality system if it has been installed. */
#ifdef OD_TEXTMODE
      if(od_control.od_mps != NULL)
      {
         (*(OD_COMPONENT_CALLBACK *)od_control.od_mps)();
      }
#endif /* !OD_TEXTMODE */

      /* If baud rate has been set in od_control, then remember the forced */
      /* rate for later use.                                               */
      if(od_control.baud != 0)
      {
         dwForcedBPS = od_control.baud;
      }

      /* If the serial port number has already been set in od_control, then */
      /* remember the forced port number for later use.                     */
      if(od_control.port != 0)
      {
         nForcedPort = od_control.port;
      }

      /* If the configuration file system has been installed, then allow   */
      /* the configuration file initialization routine take over           */
      /* initialization from here. Once it has read the configuration file */
      /* it will call od_init() again, at which time od_init() will carry  */
      /* on from this point in the code.                                  */
      if(od_control.config_file != NULL)
      {
         (*(OD_COMPONENT_CALLBACK *)od_control.config_file)();
         return;
      }
   }

   /* Initialize the OpenDoors platform-specific utility functions. */
   ODPlatInit();

   /* Store the time of door startup. */
   time(&nStartupUnixTime);

   /* Allocate the set of strings that are used to store certain parts */
   /* of drop files for rewriting at od_exit() time.                   */
   for(btCount = 0; btCount < DIM(apszDropFileInfo); ++btCount)
   {
      if((apszDropFileInfo[btCount] = (char *)malloc(81)) == NULL)
      {
malloc_error:
         ODInitError("Insufficient memory available to start up program.");
         exit(od_control.od_errorlevel[1]);
      }
   }

   /* Determine the current node number. */ 
   if((pointer=getenv("TASK")) != NULL)
   {
      od_control.od_node = atoi(pointer);
   }
   else if(wODNodeNumber != 65535U)
   {
      od_control.od_node = wODNodeNumber;
   }
   else if(od_control.od_node == 0)
   {
      od_control.od_node = 1;
   }

   /* If a custom drop file format is not being used, then set certain   */
   /* od_control members to their default values. In the case where      */
   /* a custom drop file format is being used, these values will already */
   /* have been set, and so we don't want to touch them.                 */
   if(od_control.od_info_type != CUSTOM)
   {
      od_control.user_avatar = FALSE;
      od_control.user_rip = FALSE;
      od_control.user_attribute = 0x06;
      od_control.user_screen_length = 23;
      od_control.od_page_pausing = TRUE;
      od_control.od_page_len = 15;
   }
   else
   {
      /* When a custom drop file is being used, there are certain      */
      /* variables that we must initialize if they weren't already set */
      /* when the custom drop file was read.                           */
      if(od_control.user_timelimit == 0) od_control.user_timelimit = 60;
      if(od_control.port == -1) od_control.baud = 0L;
   }

   /* Setup inbound local/remote buffer. */
   if(ODInQueueAlloc(&hODInputQueue, od_control.od_in_buf_size == 0 ?
      DEFAULT_EVENT_QUEUE_SIZE : od_control.od_in_buf_size) != kODRCSuccess)
   {
      goto malloc_error;
   }

   /* Enable user's keyboard by default. */
   od_control.od_user_keyboard_on = TRUE;

   /* If door information (drop) file reading has been disabled, then */
   /* don't attempt to read any drop file.                            */
   if(od_control.od_disable & DIS_INFOFILE)
   {
      od_control.od_info_type = NO_DOOR_FILE;
   }

   /* Otherwise, if the local mode override has been explicitly asked for, */
   /* setup od_control for default local mode operation.                   */
   else if(od_control.od_force_local)
   {
force_local:
      /* No door information file is being used. */
      od_control.od_info_type = NO_DOOR_FILE;

      /* Operate in local mode. */
      od_control.baud = 0L;

      if(!bParsedCmdLine)
      {
         /* Enable ANSI mode. */
         od_control.user_ansi = TRUE;

         /* Default to 60 minutes of time available. */
         od_control.user_timelimit = 60;
      }

      /* Choose the appropriate system name. */
      if(bSystemNameSet)
      {
         strcpy(od_control.user_location, szForcedSystemName);
      }
      else if(od_control.system_name[0] != '\0')
      {
         strcpy(od_control.user_location, od_control.system_name);
      }
      else
      {
         strcpy(od_control.user_location, "Unknown Location");
      }
   }

   /* If drop file reading isn't disable, if a custom format drop file */
   /* hasn't already been read and automatic local mode hasn't been    */
   /* specified, then attempt to find and read a standard drop file.   */
   else if(od_control.od_info_type != CUSTOM)
   {
      /* Generate the name of the dorinfox.def file for this node. */
      if(od_control.od_node > 35)
      {
542
         apszDropFileNames[1] = (char *)"dorinfo1.def";
rswindell's avatar
rswindell committed
543 544 545
      }
      else if(od_control.od_node > 9)
      {
546
         sprintf(szIFTemp, "dorinfo%c.def", od_control.od_node + 55);
rswindell's avatar
rswindell committed
547 548 549 550
         apszDropFileNames[1] = (char *)szIFTemp;
      }
      else
      {
551
         sprintf(szIFTemp, "dorinfo%d.def", od_control.od_node);
rswindell's avatar
rswindell committed
552 553 554 555 556 557 558 559
         apszDropFileNames[1] = (char *)szIFTemp;
      }

      nFound = FOUND_NONE;

      if(!ODFileAccessMode(od_control.info_path, 4))
      {
         /* Check for a DORINFOx.DEF filename. */
560
         if(ODStringHasTail(od_control.info_path, ".def") &&
rswindell's avatar
rswindell committed
561 562
            strlen(od_control.info_path) >= strlen(apszDropFileNames[2]) &&
            strnicmp((char *)&od_control.info_path +
563
            (strlen(od_control.info_path) - 12), "dorinfo", 7) == 0)
rswindell's avatar
rswindell committed
564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600
         {
            nFound = FOUND_DORINFO1_DEF;
            strcpy(szDropFilePath, od_control.info_path);
         }
         else
         {
            /* Check filenames other than DORINFOx.DEF */
            for(btCount = 0; btCount < DIM(apszDropFileNames); ++btCount)
            {
               if(ODStringHasTail(od_control.info_path,
                  apszDropFileNames[btCount]))
               {
                  strcpy(szDropFilePath, od_control.info_path);
                  nFound = btCount;
                  break;
               }
            }
         }
      }

      /* Search for a door information file. */
      if(nFound == FOUND_NONE)
      {
         nFound = ODSearchForDropFile((char **)&apszDropFileNames,
            DIM(apszDropFileNames), (char *)&szDropFilePath,
            (char *)&szExitinfoBBSPath);
      }

      if(nFound == FOUND_EXITINFO_BBS)
      {
         od_control.od_info_type = NO_DOOR_FILE;
         ODInitReadExitInfo();
         if(od_control.od_info_type == NO_DOOR_FILE)
         {
            goto DropFileFail;
         }

601
         ODMakeFilename(szODWorkString, szExitinfoBBSPath, "dorinfo1.def",
rswindell's avatar
rswindell committed
602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629
            sizeof(szExitinfoBBSPath));
         if((pfDropFile = fopen(szODWorkString, "r")) == NULL)
         {
            goto DropFileFail;
         }

         goto read_dorinfox;
      }

      else if(nFound==FOUND_DORINFO1_DEF)
      {
          /* Open DORINFO?.DEF. */
          if((pfDropFile = fopen(szDropFilePath, "r")) == NULL) goto DropFileFail;

          /* Set door type to DORINFO. */
          od_control.od_info_type = DORINFO1;

read_dorinfox:
          /* If not able to read first line. */
          if(fgets(szIFTemp, 255, pfDropFile) == NULL)
          {
             goto DropFileFail;
          }

          if(szIFTemp[strlen(szIFTemp) - 1] == '\n')
          {
            szIFTemp[strlen(szIFTemp) - 1] = '\0';
          }
          strncpy(od_control.system_name, szIFTemp, 39);
          od_control.system_name[39] = '\0';

          /* get sysop name from DORINFO1.DEF */
          if(fgets(szIFTemp, 255, pfDropFile) == NULL) goto DropFileFail;
          ODStringToName(szIFTemp);
          strncpy(od_control.sysop_name, szIFTemp, 19);

                                          /* get sysop's last name */
          if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
          ODStringToName(szIFTemp);
          if(strlen(szIFTemp))
          {
             strcat(od_control.sysop_name," ");
             strncat(od_control.sysop_name,szIFTemp,19);
          }
                                   /* get com port that modem is connected to */
          if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
          od_control.port=szIFTemp[3]-'1';
                                          /* determine BPS rate of connection */
          if(fgets((char *)apszDropFileInfo[0],255,pfDropFile)==NULL) goto DropFileFail;
          od_control.baud= (od_control.port == -1) ? 0 : atol((char *)apszDropFileInfo[0]);

          if(fgets((char *)apszDropFileInfo[1],80,pfDropFile)==NULL) goto DropFileFail;

                                          /* get user's first name */
          if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
          ODStringToName(szIFTemp);
          strncpy(od_control.user_name,szIFTemp,17);
                                          /* get user's last name */
          if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
          ODStringToName(szIFTemp);
          if(strlen(szIFTemp))
          {
             strcat(od_control.user_name," ");
             strncat(od_control.user_name,szIFTemp,17);
          }
                                          /* get user's location */
          if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
          ODStringToName(szIFTemp);
          strncpy(od_control.user_location,szIFTemp,25);
                                          /* get ANSI mode settings */
          if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
          if(szIFTemp[0]=='0') od_control.user_ansi=FALSE;
          else od_control.user_ansi=TRUE;
                                          /* get user security level */
          if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
          od_control.user_security=atoi(szIFTemp);
                                          /* get time left in door */
          if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
          od_control.user_timelimit=atoi(szIFTemp);
          fclose(pfDropFile);
       }
                                       /* Read CHAIN.TXT */
       else if(nFound==FOUND_CHAIN_TXT)
       {
          if((pfDropFile=fopen(szDropFilePath,"r"))==NULL) goto DropFileFail;

          od_control.od_info_type=CHAINTXT;

          if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
          od_control.user_num=atoi(szIFTemp);

          if(fgets((char *)&od_control.user_handle,35,pfDropFile)==NULL) goto DropFileFail;
          ODStringToName(od_control.user_handle);

          if(fgets((char *)&od_control.user_name,35,pfDropFile)==NULL) goto DropFileFail;
          ODStringToName(od_control.user_name);

          if(fgets((char *)&od_control.user_callsign,12,pfDropFile)==NULL) goto DropFileFail;
          ODStringToName(od_control.user_callsign);

          if(fgets((char *)apszDropFileInfo[0],80,pfDropFile)==NULL) goto DropFileFail;

          if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
          od_control.user_sex=szIFTemp[0];

          if(fgets((char *)apszDropFileInfo[1],80,pfDropFile)==NULL) goto DropFileFail;

          if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
          strncpy(od_control.user_lastdate,szIFTemp,8);

          if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
          od_control.user_screenwidth=atoi(szIFTemp);

          if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
          od_control.user_screen_length=atoi(szIFTemp);

          if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
          od_control.user_security=atoi(szIFTemp);

          if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
          bIsSysop=atoi(szIFTemp);

          if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
          bIsCoSysop=atoi(szIFTemp);

          if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
          od_control.user_ansi=atoi(szIFTemp);

          if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;    /* non-zero if remote */

          if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
          od_control.user_timelimit=atoi(szIFTemp);
          od_control.user_timelimit/=60;

          if(fgets((char *)apszDropFileInfo[3],80,pfDropFile)==NULL) goto DropFileFail;

          if(fgets((char *)apszDropFileInfo[4],80,pfDropFile)==NULL) goto DropFileFail;

          if(fgets((char *)apszDropFileInfo[5],80,pfDropFile)==NULL) goto DropFileFail;

          if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
          if(strcmp(szIFTemp,"KB")==0)
          {
             od_control.baud=0;
          }
          else
          {
             od_control.baud=atol(szIFTemp);
          }

          if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
          od_control.port=atoi(szIFTemp)-1;

          if(fgets((char *)apszDropFileInfo[6],80,pfDropFile)==NULL) goto DropFileFail;

          if(fgets((char *)&od_control.user_password,15,pfDropFile)==NULL) goto DropFileFail;
          ODStringToName(od_control.user_password);

          if(fgets((char *)apszDropFileInfo[2],80,pfDropFile)==NULL) goto DropFileFail;
          if(fgets((char *)apszDropFileInfo[7],80,pfDropFile)==NULL) goto DropFileFail;
          if(fgets((char *)apszDropFileInfo[8],80,pfDropFile)==NULL) goto DropFileFail;
          if(fgets((char *)apszDropFileInfo[9],80,pfDropFile)==NULL) goto DropFileFail;
          if(fgets((char *)apszDropFileInfo[10],80,pfDropFile)==NULL) goto DropFileFail;
          if(fgets((char *)apszDropFileInfo[11],80,pfDropFile)==NULL) goto DropFileFail;
          if(fgets((char *)apszDropFileInfo[12],80,pfDropFile)==NULL) goto DropFileFail;

          fclose(pfDropFile);
       }

       else if(nFound == FOUND_SFDOORS_DAT 
			 || nFound == FOUND_SFMAIN_DAT 
			 || nFound == FOUND_SFFILE_DAT 
			 || nFound == FOUND_SFMESS_DAT
          || nFound == FOUND_SFSYSOP_DAT)
       {
          od_control.od_info_type = SFDOORSDAT;

          if(!ODInitReadSFDoorsDAT())
          {
             goto DropFileFail;
          }
       }

       else if(nFound==FOUND_DOOR_SYS)
       {
          if((pfDropFile=fopen(szDropFilePath,"r"))==NULL) goto DropFileFail;

          /* Read line 1. */
          if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;

          if(szIFTemp[0]=='C' && szIFTemp[1]=='O' && szIFTemp[2]=='M' && szIFTemp[4]==':')
          {                            /* GAP style DOOR.SYS */
             od_control.od_info_type=DOORSYS_GAP;

             od_control.port=szIFTemp[3]-'1';

             /* Read line 2. */
             if(fgets((char *)apszDropFileInfo[0], 80, pfDropFile) == NULL)
             {
               goto DropFileFail;
             }
             od_control.od_connect_speed = atol(apszDropFileInfo[0]);

             /* Read line 3. */
             if(fgets((char *)apszDropFileInfo[1],80,pfDropFile)==NULL) goto DropFileFail;

             /* Read line 4. */
             if(fgets(szIFTemp, 255, pfDropFile) == NULL) goto DropFileFail;
             od_control.od_node = atoi(szIFTemp);

             /* Read line 5. */
             if(fgets(szIFTemp, 255, pfDropFile) == NULL) goto DropFileFail;
             strupr(szIFTemp);
             if(strchr(szIFTemp, 'N') != NULL)
             {
                btDoorSYSLock = 1;
                od_control.baud = atol(apszDropFileInfo[0]);
             }
             else if(strchr(szIFTemp, 'Y') != NULL)
             {
                btDoorSYSLock = 2;
                od_control.baud = 19200;
             }
             else
             {
                od_control.baud = atol(szIFTemp);
             }

             if(od_control.port == -1) od_control.baud = 0L;

             /* Read line 6. */
             if(fgets((char *)apszDropFileInfo[3],80,pfDropFile)==NULL) goto DropFileFail;

             /* Read line 7. */
             if(fgets((char *)apszDropFileInfo[4],80,pfDropFile)==NULL) goto DropFileFail;

             /* Read line 8. */
             if(fgets((char *)apszDropFileInfo[5],80,pfDropFile)==NULL) goto DropFileFail;

             /* Read line 9. */
             if(fgets((char *)apszDropFileInfo[22],80,pfDropFile)==NULL) goto DropFileFail;

             /* Read line 10. */
             if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
             szIFTemp[35]='\0';
             ODStringToName(szIFTemp);
             strcpy(od_control.user_name,szIFTemp);

             /* Read line 11. */
             if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
             szIFTemp[25]='\0';
             if(szIFTemp[strlen(szIFTemp)-1]=='\n') szIFTemp[strlen(szIFTemp)-1]='\0';
             strcpy(od_control.user_location,szIFTemp);

             /* Read line 12. */
             if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
             szIFTemp[15]='\0';
             ODStringToName(szIFTemp);
             strcpy(od_control.user_homephone,szIFTemp);

             /* Read line 13. */
             if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
             szIFTemp[15]='\0';
             ODStringToName(szIFTemp);
             strcpy(od_control.user_dataphone,szIFTemp);

             /* Read line 14. */
             if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
             szIFTemp[15]='\0';
             if(szIFTemp[strlen(szIFTemp)-1]=='\n') szIFTemp[strlen(szIFTemp)-1]='\0';
             strcpy(od_control.user_password,szIFTemp);

             /* Read line 15. */
             if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
             od_control.user_security=atoi(szIFTemp);

             /* Read line 16. */
             if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
             od_control.user_numcalls=atoi(szIFTemp);

             /* Read line 17. */
             if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
             szIFTemp[15]='\0';
             ODStringToName(szIFTemp);
             strcpy(od_control.user_lastdate,szIFTemp);

             /* Read line 18. */
             if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;

             /* Read line 19. */
             if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
             od_control.user_timelimit=atoi(szIFTemp);

             /* Read line 20. */
             if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
             strupr(szIFTemp);
             if(!strcmp(szIFTemp,"RIP"))
             {
                od_control.user_rip=TRUE;
                od_control.user_ansi=TRUE;
             }
             else if(szIFTemp[0]=='G')
             {
                od_control.user_rip=FALSE;
                od_control.user_ansi=TRUE;
             }
             else
             {
                od_control.user_rip=FALSE;
                od_control.user_ansi=FALSE;
             }

             /* Read line 21. */
             if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
             od_control.user_screen_length=atoi(szIFTemp);

             /* Read line 22. */
             if(fgets((char *)apszDropFileInfo[8],80,pfDropFile)==NULL) goto DropFileFail;

             /* Read line 23. */
             if(fgets((char *)apszDropFileInfo[9],80,pfDropFile)==NULL) goto DropFileFail;
             if(apszDropFileInfo[9][strlen(apszDropFileInfo[9])-1]!='\n')
             {
                int ch;
                apszDropFileInfo[9][strlen(apszDropFileInfo[9])-1]='\n';
                do
                {
                   ch = fgetc(pfDropFile);
                } while(ch != '\n' && ch != EOF);
             }

             /* Read line 24. */
again:
             if(fgets((char *)apszDropFileInfo[10],80,pfDropFile)==NULL) goto DropFileFail;
             if(strchr(apszDropFileInfo[10],',')!=NULL) goto again;

             /* Read line 25. */
             if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
             szIFTemp[15]='\0';
             ODStringToName(szIFTemp);
             strcpy(od_control.user_subdate,szIFTemp);

             /* Read line 26. */
             if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
             od_control.user_num=atoi(szIFTemp);

             /* Read line 27. */
             if(fgets((char *)apszDropFileInfo[6],80,pfDropFile)==NULL) goto DropFileFail;

             /* Read line 28. */
             if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
             od_control.user_uploads=atoi(szIFTemp);

             /* Read line 29. */
             if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
             od_control.user_downloads=atoi(szIFTemp);

             /* Read line 30. */
             if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
             od_control.user_todayk=atoi(szIFTemp);

             /* Read line 31. */
             if(fgets((char *)apszDropFileInfo[21],80,pfDropFile)==NULL) goto DropFileFail;


                                        /* Beginning of extending DOOR.SYS data */
             /* Read line 32. */
             fgets((char *)apszDropFileInfo[7],80,pfDropFile);
             /* Read line 33. */
             fgets((char *)apszDropFileInfo[11],80,pfDropFile);
             /* Read line 34. */
             fgets((char *)apszDropFileInfo[12],80,pfDropFile);
             /* Read line 35. */
             fgets((char *)apszDropFileInfo[13],80,pfDropFile);
             /* Read line 36. */
             if(fgets((char *)apszDropFileInfo[14],80,pfDropFile)!=NULL)
             {
                /* Read line 37. */
                strncpy(od_control.user_birthday,apszDropFileInfo[7],8);
                od_control.user_birthday[8]='\0';

                /* Read line 38. */
                strncpy(od_control.sysop_name,apszDropFileInfo[13],39);
                od_control.sysop_name[39]='\0';
                ODStringToName(od_control.sysop_name);

                /* Read line 39. */
                strncpy(od_control.user_handle,apszDropFileInfo[14],35);
                od_control.user_handle[35]='\0';
                ODStringToName(od_control.user_handle);

                /* Read line 40. */
                if(fgets(szIFTemp,255,pfDropFile)==NULL) goto finished;
                strncpy(od_control.event_starttime, szIFTemp, 5);
                od_control.event_starttime[5] = '\0';

                /* Read line 41. */
                if(fgets(szIFTemp,255,pfDropFile)==NULL) goto finished;
                if(szIFTemp[0]=='y' || szIFTemp[0]=='Y')
                   od_control.user_error_free=TRUE;
                else
                   od_control.user_error_free=FALSE;

                /* Read line 42. */
                if(fgets((char *)apszDropFileInfo[7],80,pfDropFile)==NULL) goto finished;
                /* Read line 43. */
                if(fgets((char *)apszDropFileInfo[13],80,pfDropFile)==NULL) goto finished;
                /* Read line 44. */
                if(fgets((char *)apszDropFileInfo[14],80,pfDropFile)==NULL) goto finished;
                /* Read line 45. */
                if(fgets((char *)apszDropFileInfo[15],80,pfDropFile)==NULL) goto finished;
                /* Read line 46. */
                if(fgets((char *)apszDropFileInfo[16],80,pfDropFile)==NULL) goto finished;

                /* Read line 47. */
                if(fgets(szIFTemp,255,pfDropFile)==NULL) goto finished;
                strncpy(od_control.user_logintime,szIFTemp,5);
                od_control.user_logintime[5]='\0';

                /* Read line 48. */
                if(fgets(szIFTemp,255,pfDropFile)==NULL) goto finished;
                strncpy(od_control.user_lasttime,szIFTemp,5);
                od_control.user_lasttime[5]='\0';

                /* Read line 49. */
                if(fgets((char *)apszDropFileInfo[18],80,pfDropFile)==NULL) goto finished;

                /* Read line 50. */
                if(fgets((char *)apszDropFileInfo[19],80,pfDropFile)==NULL) goto finished;

                /* Read line 51. */
                if(fgets(szIFTemp,255,pfDropFile)==NULL) goto finished;
                od_control.user_upk=atoi(szIFTemp);

                /* Read line 52. */
                if(fgets(szIFTemp,255,pfDropFile)==NULL) goto finished;
                od_control.user_downk=atoi(szIFTemp);

                /* Read line 53. */
                if(fgets(szIFTemp,255,pfDropFile)==NULL) goto finished;
                strncpy(od_control.user_comment,szIFTemp,79);
                od_control.user_comment[79]='\0';
                if(od_control.user_comment[strlen(od_control.user_comment)-1]=='\n')
                   od_control.user_comment[strlen(od_control.user_comment)-1]='\0';

                /* Read line 54. */
                if(fgets((char *)apszDropFileInfo[20],80,pfDropFile)==NULL) goto finished;

                /* Read line 55. */
                if(fgets(szIFTemp,255,pfDropFile)==NULL) goto finished;
                od_control.user_messages=atoi(szIFTemp);


                od_control.od_info_type=DOORSYS_WILDCAT;
             }
          }

          else                            /* DoorWay style DOOR.SYS */
          {
             od_control.od_info_type=DOORSYS_DRWY;

             szIFTemp[35]='\0';
             ODStringToName(szIFTemp);
             strcpy(od_control.user_name,szIFTemp);

             if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
             od_control.port=szIFTemp[0]-'1';

             if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
             if(od_control.port==-1)
             {
                od_control.baud=0L;
             }
             else
             {
                od_control.baud=atol(szIFTemp);
             }

             if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
             od_control.user_timelimit=atoi(szIFTemp);

             if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
             if(szIFTemp[0]=='G')
             {
                od_control.user_ansi=TRUE;
             }
             else
             {
                od_control.user_ansi=FALSE;
             }
          }
finished:
          fclose(pfDropFile);
       }

       else if(nFound==FOUND_CALLINFO_BBS)
       {
          if((pfDropFile=fopen(szDropFilePath,"r"))==NULL) goto DropFileFail;

          od_control.od_info_type=CALLINFO;

          if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
          szIFTemp[35]='\0';
          ODStringToName(szIFTemp);
          strcpy(od_control.user_name,szIFTemp);

          if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;

          if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
          szIFTemp[25]='\0';
          ODStringToName(szIFTemp);
          strcpy(od_control.user_location,szIFTemp);

          if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
          od_control.user_security=atoi(szIFTemp);

          if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
          od_control.user_timelimit=atoi(szIFTemp);

          if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
          if(szIFTemp[0]=='M')
          {
             od_control.user_ansi=FALSE;
          }
          else
          {
             od_control.user_ansi=TRUE;
          }

          if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
          szIFTemp[15]='\0';
          ODStringToName(szIFTemp);
          strcpy(od_control.user_password,szIFTemp);

          if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
          if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
          if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
          if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
          if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
          if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
          if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
          if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
          if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;

          if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
          szIFTemp[15]='\0';
          ODStringToName(szIFTemp);
          strcpy(od_control.user_homephone,szIFTemp);

          if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
          if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
          if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
          if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
          if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;

          if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
          od_control.user_screen_length=atoi(szIFTemp);

          if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
          if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
          if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
          if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
          if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;

          if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
          od_control.port=szIFTemp[3]-'1';

          if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;

          if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
          od_control.baud=atol(szIFTemp);

          fclose(pfDropFile);
       }
       else if(nFound == FOUND_TRIBBS_SYS)
       {
          /* We have found reading a TRIBBS.SYS file. */

          /* Attempt to open the file. */
          if((pfDropFile = fopen(szDropFilePath, "r")) == NULL)
          {
             goto DropFileFail;
          }

          /* Record the drop file type being used. */
          od_control.od_info_type = TRIBBSSYS;

          /* Read line 1: User's number. */
          if(fgets(szIFTemp, 255, pfDropFile) == NULL) goto DropFileFail;
          od_control.user_num = atoi(szIFTemp);

          /* Read line 2: User's name. */
          if(fgets((char *)&od_control.user_name, 35, pfDropFile) == NULL)
          {
             goto DropFileFail;
          }
          ODStringToName(od_control.user_name);

          /* Read line 3: User's password. */
          if(fgets((char *)&od_control.user_password, 15, pfDropFile) == NULL)
          {
             goto DropFileFail;
          }

          /* Read line 4: User's security level. */
          if(fgets(szIFTemp, 255, pfDropFile) == NULL) goto DropFileFail;
          od_control.user_security = atoi(szIFTemp);

          /* Read line 5: "Y" for expert mode, "N" for novice mode. */
          if(fgets(szIFTemp, 255, pfDropFile) == NULL) goto DropFileFail;
          od_control.user_expert = (szIFTemp[0] == 'Y');

          /* Read line 6: "Y" for ANSI, "N" for TTY. */
          if(fgets(szIFTemp, 255, pfDropFile) == NULL) goto DropFileFail;
          od_control.user_ansi = (szIFTemp[0] == 'Y');

          /* Read line 7: Minutes remaining for this call. */
          if(fgets(szIFTemp, 255, pfDropFile) == NULL) goto DropFileFail;
          od_control.user_timelimit = atoi(szIFTemp);

          /* Read line 8: User's phone number. */
          if(fgets(szIFTemp, 255, pfDropFile) == NULL) goto DropFileFail;
          szIFTemp[15] = '\0';
          ODStringToName(szIFTemp);
          strcpy(od_control.user_homephone, szIFTemp);

          /* Read line 9: User's location. */
          if(fgets(szIFTemp, 255, pfDropFile) == NULL) goto DropFileFail;
          ODStringToName(szIFTemp);
          strncpy(od_control.user_location, szIFTemp, 25);

          /* Read line 10: User's birthday. */
          if(fgets(szIFTemp, 255, pfDropFile) == NULL) goto DropFileFail;
          strncpy(od_control.user_birthday, szIFTemp, 8);
          od_control.user_birthday[8] = '\0';
          od_control.user_birthday[2] = '-';
          od_control.user_birthday[5] = '-';

          /* Read line 11: Node number. */
          if(fgets(szIFTemp, 255, pfDropFile) == NULL) goto DropFileFail;
          od_control.od_node = atoi(szIFTemp);

          /* Read line 12: Serial port. */
          if(fgets(szIFTemp, 255, pfDropFile) == NULL) goto DropFileFail;
          od_control.port = atoi(szIFTemp) - 1;

          /* Read line 13: Baud rate. */
          if(fgets(szIFTemp, 255, pfDropFile) == NULL) goto DropFileFail;
          od_control.od_connect_speed =
             (od_control.port == -1) ? 0 : atol(szIFTemp);

          /* Read line 14: Locked baud rate or 0 for unlocked port. */
          if(fgets(szIFTemp, 255, pfDropFile) == NULL) goto DropFileFail;
          od_control.baud = atol(szIFTemp);
          if(od_control.baud == 0)
          {
             od_control.baud = od_control.od_connect_speed;
          }

          /* Read line 15: "Y" for RTS/CTS handshaking, "N" for none. */
          if(fgets(szIFTemp, 255, pfDropFile) == NULL) goto DropFileFail;
          od_control.od_com_flow_control = (szIFTemp[0] == 'Y')
             ? COM_RTSCTS_FLOW : COM_NO_FLOW;

          /* Read line 16: "Y" for error free connection, "N" otherwise. */
          if(fgets(szIFTemp, 255, pfDropFile) == NULL) goto DropFileFail;
          od_control.user_error_free = (szIFTemp[0] == 'Y');

          /* Read line 17: BBS name. */
          if(fgets(szIFTemp, 255, pfDropFile) == NULL) goto DropFileFail;
          ODStringCopy(od_control.system_name, szIFTemp, 40);
          ODStringToName(od_control.system_name);

          /* Read line 18: Sysop's name. */
          if(fgets(szIFTemp, 255, pfDropFile) == NULL) goto DropFileFail;
          ODStringCopy(od_control.sysop_name, szIFTemp, 40);
          ODStringToName(od_control.sysop_name);

          /* Read line 19: User's alias. */
          if(fgets((char *)&od_control.user_handle, 35, pfDropFile) == NULL)
          {
             goto DropFileFail;
          }
          ODStringToName(od_control.user_handle);

          /* Read line 20: "Y" for RIP mode, "N" for no RIP mode. */
          if(fgets(szIFTemp, 255, pfDropFile) == NULL) goto DropFileFail;
          od_control.user_rip = (szIFTemp[0] == 'Y');

          /* Now, close the TRIBBS.SYS file. */
          fclose(pfDropFile);
       }
       else if(nFound == FOUND_DOOR32_SYS)
       {
          /* We have found a DOOR32.SYS file. */

          /* Attempt to open the file. */
          if((pfDropFile = fopen(szDropFilePath, "r")) == NULL)
          {
             goto DropFileFail;
          }

          /* Record the drop file type being used. */
          od_control.od_info_type = DOOR32SYS;

          /* Read line 1: Comm type. */
          if(fgets(szIFTemp, 255, pfDropFile) == NULL) goto DropFileFail;
          switch(atoi(szIFTemp)) {
				case 0: /* local */
					od_control.od_force_local = TRUE;	/* Is this the right way? */
					break;
				case 1: /* serial */
					break;
				case 2: /* telnet */
					od_control.od_use_socket = TRUE;
					break;
			 }
			 /* Read line 2: Comm or Socket handle. */
          if(fgets(szIFTemp, 255, pfDropFile) == NULL) goto DropFileFail;
          od_control.od_open_handle	= atoi(szIFTemp);

			 /* Read line 3: Baud rate */
          if(fgets((char *)apszDropFileInfo[0],255,pfDropFile)==NULL) goto DropFileFail;
          od_control.baud= (od_control.port == -1) ? 0 : atol((char *)apszDropFileInfo[0]);

			 /* Read line 4: BBS Software name and version - unused. */
          if(fgets(szIFTemp, 255, pfDropFile) == NULL) goto DropFileFail;

          /* Read line 5: User's number. */
          if(fgets(szIFTemp, 255, pfDropFile) == NULL) goto DropFileFail;
          od_control.user_num = atoi(szIFTemp);

          /* Read line 6: User's real name. */
          if(fgets((char *)&od_control.user_name, 35, pfDropFile) == NULL)
          {
             goto DropFileFail;
          }
          ODStringToName(od_control.user_name);

          /* Read line 7: User's alias. */
          if(fgets((char *)&od_control.user_handle, 35, pfDropFile) == NULL)
          {
             goto DropFileFail;
          }
          ODStringToName(od_control.user_handle);

          /* Read line 8: User's security level */
          if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
          od_control.user_security=atoi(szIFTemp);

          /* Read line 9: Minutes remaining for this call. */
          if(fgets(szIFTemp, 255, pfDropFile) == NULL) goto DropFileFail;
          od_control.user_timelimit = atoi(szIFTemp);

          /* Read line 10: User's Terminal type  */
          if(fgets(szIFTemp,255,pfDropFile)==NULL) goto DropFileFail;
    		 od_control.user_ansi=TRUE;
			 switch(atoi(szIFTemp)) {
					case 0: /* ASCII */
						od_control.user_ansi=FALSE;
						break;
					case 1: /* ANSI */
						od_control.user_ansi=TRUE;
						break;
					case 2: /* AVATAR */
						od_control.user_avatar=TRUE;
						break;
					case 3: /* RIP */
						od_control.user_rip=TRUE;
						break;
			 }

          /* Read line 11: Current Node number. */
          if(fgets(szIFTemp, 255, pfDropFile) == NULL) goto DropFileFail;
          od_control.od_node = atoi(szIFTemp);

          /* Now, close the DOOR32.SYS file. */
          fclose(pfDropFile);
       }
       else
       {
DropFileFail:
			 if(pfDropFile!=NULL)	/* Let's not leave the file open */
				 fclose(pfDropFile);

          od_control.od_info_type = NO_DOOR_FILE;

          if(od_control.od_no_file_func != NULL)
          {
             (*od_control.od_no_file_func)();
          }

          /* Check whether force local has been turned on by the no */
          /* file function.                                         */
          if(od_control.od_force_local)
          {
             goto force_local;
          }

          /* Exit with failure if the no file function has not read a */
          /* door information file itself.                            */
          if(od_control.od_info_type == NO_DOOR_FILE
            && (wPreSetInfo & PRESET_REQUIRED) != PRESET_REQUIRED)
          {
             ODInitError("Unable to read door information (drop) file.");
             exit(od_control.od_errorlevel[1]);
          }
       }
   }

   ODInitPartTwo();
}


/* ----------------------------------------------------------------------------
 * ODInitReadSFDoorsDAT()                              *** PRIVATE FUNCTION ***
 *
 * Reads an SFDOORS.DAT format drop file.
 *
 * Parameters: none
 *
 *     Return: TRUE on success or FALSE on failure.
 */
static BOOL ODInitReadSFDoorsDAT(void)
{
   FILE *pfDropFile;

   if((pfDropFile=fopen(szDropFilePath,"r"))==NULL) return(FALSE);

   /* Line 1: User number. */
   if(fgets(szIFTemp,255,pfDropFile)==NULL) return(FALSE);
   od_control.user_num=atoi(szIFTemp);

   /* Line 2: User name. */
   if(fgets(szIFTemp,255,pfDropFile)==NULL) return(FALSE);
   szIFTemp[35]='\0';
   ODStringToName(szIFTemp);
   strcpy(od_control.user_name,szIFTemp);

   /* Line 3: User password. */
   if(fgets(szIFTemp,255,pfDropFile)==NULL) return(FALSE);
   szIFTemp[15]='\0';
   ODStringToName(szIFTemp);
   strcpy(od_control.user_password,szIFTemp);

   /* Line 4: Unused. */
   if(fgets((char *)apszDropFileInfo[0],80,pfDropFile)==NULL) return(FALSE);

   /* Line 5: Modem <-> Serial port bps rate. */
   if(fgets(szIFTemp,255,pfDropFile)==NULL) return(FALSE);
   od_control.baud=atol(szIFTemp);

   /* Line 6: Serial port number. */
   if(fgets(szIFTemp,255,pfDropFile)==NULL) return(FALSE);
   od_control.port=atoi(szIFTemp)-1;

   /* Line 7: User's time remaining. */
   if(fgets(szIFTemp,255,pfDropFile)==NULL) return(FALSE);
   od_control.user_timelimit=atoi(szIFTemp);

   /* Line 8: Unused. */
   if(fgets((char *)apszDropFileInfo[13],80,pfDropFile)==NULL) return(FALSE);

   /* Line 9: Unused. */
   if(fgets((char *)apszDropFileInfo[14],80,pfDropFile)==NULL) return(FALSE);

   /* Line 10: User's ANSI mode setting. */
   if(fgets(szIFTemp,255,pfDropFile)==NULL) return(FALSE);
   strupr(szIFTemp);
   od_control.user_ansi=(szIFTemp[0]=='T');

   /* Line 11: User's security level. */
   if(fgets(szIFTemp,255,pfDropFile)==NULL) return(FALSE);
   od_control.user_security=atoi(szIFTemp);

   /* Line 12: User's upload count. */
   if(fgets(szIFTemp,255,pfDropFile)==NULL) return(FALSE);
   od_control.user_uploads=atoi(szIFTemp);

   /* Line 13: User's download count. */
   if(fgets(szIFTemp,255,pfDropFile)==NULL) return(FALSE);
   od_control.user_downloads=atoi(szIFTemp);

   /* Line 14: Unused. */
   if(fgets((char *)apszDropFileInfo[1],80,pfDropFile)==NULL) return(FALSE);

   /* Line 15: User's login time. */
   if(fgets((char *)apszDropFileInfo[2],255,pfDropFile)==NULL) return(FALSE);
   sprintf(od_control.user_logintime, "%02.2d:%02.2d",
      atoi((char *)apszDropFileInfo[2]) % 60,
      atoi((char *)apszDropFileInfo[2]) / 60);

   /* Line 16: Unused. */
   if(fgets((char *)apszDropFileInfo[3],80,pfDropFile)==NULL) return(FALSE);

   /* Line 17: Sysop next flag. */
   if(fgets(szIFTemp,255,pfDropFile)==NULL) return(FALSE);
   strupr(szIFTemp);
   od_control.sysop_next=(szIFTemp[0]=='T');

   /* Line 18: Unused. */
   if(fgets((char *)apszDropFileInfo[4],80,pfDropFile)==NULL) return(FALSE);

   /* Line 19: Unused. */
   if(fgets((char *)apszDropFileInfo[5],80,pfDropFile)==NULL) return(FALSE);

   /* Line 20: Unused. */
   if(fgets((char *)apszDropFileInfo[6],80,pfDropFile)==NULL) return(FALSE);

   /* Line 21: Error free connection flag. */
   if(fgets(szIFTemp,255,pfDropFile)==NULL) return(FALSE);
   strupr(szIFTemp);
   od_control.user_error_free=(szIFTemp[0]=='T');

   /* Line 22: Current message area. */
   if(fgets(szIFTemp,255,pfDropFile)==NULL) return(FALSE);
   od_control.user_msg_area=atoi(szIFTemp);

   /* Line 23: Current file area. */
   if(fgets(szIFTemp,255,pfDropFile)==NULL) return(FALSE);
   od_control.user_file_area=atoi(szIFTemp);

   /* Line 24: Current node number. */
   if(fgets(szIFTemp,255,pfDropFile)==NULL) return(FALSE);
   od_control.od_node=atoi(szIFTemp);

   /* Line 25: Unused. */
   if(fgets((char *)apszDropFileInfo[10],80,pfDropFile)==NULL) return(FALSE);

   /* Line 26: Unused. */
   if(fgets((char *)apszDropFileInfo[11],80,pfDropFile)==NULL) return(FALSE);

   /* Line 27: Unused. */
   if(fgets((char *)apszDropFileInfo[12],80,pfDropFile)==NULL) return(FALSE);

   /* Line 28: Kilobytes downloaded today. */
   if(fgets(szIFTemp,255,pfDropFile)==NULL) return(FALSE);
   od_control.user_todayk=atoi(szIFTemp);

   /* Line 29: Kilobytes uploaded in total. */
   if(fgets(szIFTemp,255,pfDropFile)==NULL) return(FALSE);
   od_control.user_upk=atoi(szIFTemp);

   /* Line 30: Kilobytes downloaded in total. */
   if(fgets(szIFTemp,255,pfDropFile)==NULL) return(FALSE);
   od_control.user_downk=atoi(szIFTemp);

   /* Line 31: User's home phone number. */
   if(fgets(szIFTemp,255,pfDropFile)==NULL) return(FALSE);
   szIFTemp[15]='\0';
   ODStringToName(szIFTemp);
   strcpy(od_control.user_homephone,szIFTemp);

   /* Line 32: User's home location. */
   if(fgets(szIFTemp,255,pfDropFile)==NULL) return(FALSE);
   szIFTemp[25]='\0';
   ODStringToName(szIFTemp);
   strcpy(od_control.user_location,szIFTemp);

   /* Line 33: Unused. */
   if(fgets((char *)apszDropFileInfo[15],80,pfDropFile)==NULL)
   {
      apszDropFileInfo[15][0]='\0';
   }

   /* Line 34: RIP mode. */
   if(fgets(szIFTemp,255,pfDropFile) != NULL)
   {
      strupr(szIFTemp);
      od_control.user_rip = (szIFTemp[0] == 'T');
   }

   /* line 35: User wants chat. */
   if(fgets(szIFTemp,255,pfDropFile) != NULL)
   {
      strupr(szIFTemp);
      od_control.user_wantchat = (szIFTemp[0] == 'T');
   }

   /* Line 36: Unused. */
   if(fgets((char *)apszDropFileInfo[17],80,pfDropFile)==NULL)
   {
      apszDropFileInfo[17][0]='\0';
   }

   /* Line 37: IRQ number. */
   if(fgets(szIFTemp,255,pfDropFile) != NULL)
   {
      od_control.od_com_irq = atoi(szIFTemp);
   }

   /* Line 38: Serial port address. */
   if(fgets(szIFTemp,255,pfDropFile) != NULL)
   {
      od_control.od_com_address = atoi(szIFTemp);
   }

   /* Line 39: Unused. */
   if(fgets((char *)apszDropFileInfo[18],80,pfDropFile)==NULL)
   {
      apszDropFileInfo[18][0]='\0';
   }

   fclose(pfDropFile);

   return(TRUE);
}


/* ----------------------------------------------------------------------------
 * ODInitReadExitInfo()                                *** PRIVATE FUNCTION ***
 *
 * Reads an EXITINFO.BBS format drop file.
 *
 * Parameters: none
 *
 *     Return: void
 */
static void ODInitReadExitInfo(void)
{
   DWORD dwFileSize;
   FILE *pfDropFile;
   BYTE btCount;

   od_control.od_extended_info=FALSE;
   od_control.od_ra_info=FALSE;

   /* Try to open EXITINFO.BBS. */
1630
   ODMakeFilename(szODWorkString, szExitinfoBBSPath, "exitinfo.bbs",
rswindell's avatar
rswindell committed
1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829
      sizeof(szExitinfoBBSPath));
   if((pfDropFile = fopen(szODWorkString, "rb")) != NULL)
   {
      dwFileSize = ODFileSize(pfDropFile);

      if(dwFileSize >= 2363)
      {
         if((pRA2ExitInfoRecord=malloc(sizeof(tRA2ExitInfoRecord)))!=NULL)
         {
            if(fread(pRA2ExitInfoRecord,1,2363,pfDropFile)==2363)
            {
               od_control.od_ra_info=TRUE;
               od_control.od_extended_info=TRUE;
               od_control.od_info_type=RA2EXITINFO;

               od_control.baud=(long)pRA2ExitInfoRecord->baud;
               od_control.system_calls=pRA2ExitInfoRecord->num_calls;
               ODStringPascalToC(od_control.system_last_caller,pRA2ExitInfoRecord->last_caller,35);
               ODStringPascalToC(od_control.system_last_handle,pRA2ExitInfoRecord->sLastHandle,35);
               ODStringPascalToC(od_control.timelog_start_date,pRA2ExitInfoRecord->start_date,8);
               memcpy(&od_control.timelog_busyperhour,&pRA2ExitInfoRecord->busyperhour,62);
               ODStringPascalToC(od_control.user_name,pRA2ExitInfoRecord->name,35);
               ODStringPascalToC(od_control.user_location,pRA2ExitInfoRecord->location,25);
               ODStringPascalToC(od_control.user_org,pRA2ExitInfoRecord->organisation,50);
               for(btCount=0;btCount<3;++btCount)
                  ODStringPascalToC(od_control.user_address[btCount],pRA2ExitInfoRecord->address[btCount],50);
               ODStringPascalToC(od_control.user_handle,pRA2ExitInfoRecord->handle,35);
               ODStringPascalToC(od_control.user_comment,pRA2ExitInfoRecord->comment,80);
               od_control.user_pwd_crc=pRA2ExitInfoRecord->password_crc;
               ODStringPascalToC(od_control.user_dataphone,pRA2ExitInfoRecord->dataphone,15);
               ODStringPascalToC(od_control.user_homephone,pRA2ExitInfoRecord->homephone,15);
               ODStringPascalToC(od_control.user_lasttime,pRA2ExitInfoRecord->lasttime,5);
               ODStringPascalToC(od_control.user_lastdate,pRA2ExitInfoRecord->lastdate,8);
               od_control.user_attribute=pRA2ExitInfoRecord->attrib;
               od_control.user_attrib2=pRA2ExitInfoRecord->attrib2;
               memcpy(&od_control.user_flags,&pRA2ExitInfoRecord->flags,14);
               od_control.user_security=pRA2ExitInfoRecord->sec;
               od_control.user_lastread=pRA2ExitInfoRecord->lastread;
               memcpy(&od_control.user_numcalls,&pRA2ExitInfoRecord->nocalls,29);
               od_control.user_group=pRA2ExitInfoRecord->group;
               memcpy(&od_control.user_combinedrecord,&pRA2ExitInfoRecord->combinedrecord,200);
               ODStringPascalToC(od_control.user_firstcall,pRA2ExitInfoRecord->firstcall,8);
               ODStringPascalToC(od_control.user_birthday,pRA2ExitInfoRecord->birthday,8);
               ODStringPascalToC(od_control.user_subdate,pRA2ExitInfoRecord->subdate,8);
               od_control.user_screenwidth=pRA2ExitInfoRecord->screenwidth;
               od_control.user_language=pRA2ExitInfoRecord->language;
               od_control.user_date_format=pRA2ExitInfoRecord->dateformat;
               ODStringPascalToC(od_control.user_forward_to,pRA2ExitInfoRecord->forwardto,35);
               memcpy(&od_control.user_msg_area,&pRA2ExitInfoRecord->msgarea,15);
               od_control.user_sex = (pRA2ExitInfoRecord->sex == 1) ? 'M' : 'F';
               od_control.user_attrib3=pRA2ExitInfoRecord->btAttribute3;
               ODStringPascalToC(od_control.user_password,pRA2ExitInfoRecord->sPassword,15);
               od_control.event_status=pRA2ExitInfoRecord->status;
               ODStringPascalToC(od_control.event_starttime,pRA2ExitInfoRecord->starttime,5);
               memcpy(&od_control.event_errorlevel,&pRA2ExitInfoRecord->errorlevel,3);
               ODStringPascalToC(od_control.event_last_run,pRA2ExitInfoRecord->lasttimerun,8);
               memcpy(&od_control.user_netmailentered,&pRA2ExitInfoRecord->netmailentered,2);
               ODStringPascalToC(od_control.user_logintime,pRA2ExitInfoRecord->logintime,5);
               ODStringPascalToC(od_control.user_logindate,pRA2ExitInfoRecord->logindate,8);
               memcpy(&od_control.user_timelimit,&pRA2ExitInfoRecord->timelimit,6);
               memcpy(&od_control.user_num,&pRA2ExitInfoRecord->userrecord,8);
               ODStringPascalToC(od_control.user_timeofcreation,pRA2ExitInfoRecord->timeofcreation,5);
               od_control.user_logon_pwd_crc=pRA2ExitInfoRecord->logonpasswordcrc;
               od_control.user_wantchat=pRA2ExitInfoRecord->wantchat;
               od_control.user_deducted_time=pRA2ExitInfoRecord->deducted_time;
               for(btCount=0;btCount<50;++btCount)
                  ODStringPascalToC(od_control.user_menustack[btCount],pRA2ExitInfoRecord->menustack[btCount],8);
               od_control.user_menustackpointer=pRA2ExitInfoRecord->menustackpointer;
               memcpy(&od_control.user_error_free,&pRA2ExitInfoRecord->error_free,3);
               ODStringPascalToC(od_control.user_emsi_crtdef,pRA2ExitInfoRecord->emsi_crtdef,40);
               ODStringPascalToC(od_control.user_emsi_protocols,pRA2ExitInfoRecord->emsi_protocols,40);
               ODStringPascalToC(od_control.user_emsi_capabilities,pRA2ExitInfoRecord->emsi_capabilities,40);
               ODStringPascalToC(od_control.user_emsi_requests,pRA2ExitInfoRecord->emsi_requests,40);
               ODStringPascalToC(od_control.user_emsi_software,pRA2ExitInfoRecord->emsi_software,40);
               memcpy(&od_control.user_hold_attr1,&pRA2ExitInfoRecord->hold_attr1,3);
               ODStringPascalToC(od_control.user_reasonforchat,pRA2ExitInfoRecord->page_reason,77);
               btRAStatusToSet = pRA2ExitInfoRecord->status_line-1;
               ODStringPascalToC(od_control.user_last_cost_menu,pRA2ExitInfoRecord->last_cost_menu,8);
               od_control.user_menu_cost=pRA2ExitInfoRecord->menu_cost_per_min;
               od_control.user_rip=pRA2ExitInfoRecord->has_rip;
               od_control.user_rip_ver=pRA2ExitInfoRecord->btRIPVersion;

               od_control.user_ansi=od_control.user_attribute&8;
               od_control.user_avatar=od_control.user_attrib2&2;
            }

            else
            {
               free(pRA2ExitInfoRecord);
            }
         }
      }

      else if(dwFileSize>=1493)
      {
         if(ODReadExitInfoPrimitive(pfDropFile,476))
         {
            if((pExtendedExitInfo=malloc(sizeof(tExtendedExitInfo)))!=NULL)
            {
               if(fread(pExtendedExitInfo,1,sizeof(tExtendedExitInfo), pfDropFile)==sizeof(tExtendedExitInfo))
               {                 /* transfer info into od_control struct */
                  ODStringPascalToC(od_control.user_timeofcreation,pExitInfoRecord->bbs.ra.timeofcreation,5);
                  ODStringPascalToC(od_control.user_logonpassword,pExitInfoRecord->bbs.ra.logonpassword,15);
                  od_control.user_wantchat=pExitInfoRecord->bbs.ra.wantchat;

                  od_control.user_deducted_time=pExtendedExitInfo->deducted_time;
                  for(btCount=0;btCount<50;++btCount)
                  {
                     ODStringPascalToC(od_control.user_menustack[btCount],pExtendedExitInfo->menustack[btCount],8);
                  }
                  od_control.user_menustackpointer=pExtendedExitInfo->menustackpointer;
                  ODStringPascalToC(od_control.user_handle,pExtendedExitInfo->userhandle,35);
                  ODStringPascalToC(od_control.user_comment,pExtendedExitInfo->comment,80);
                  ODStringPascalToC(od_control.user_firstcall,pExtendedExitInfo->firstcall,8);
                  memcpy(od_control.user_combinedrecord,pExtendedExitInfo->combinedrecord,25);
                  ODStringPascalToC(od_control.user_birthday,pExtendedExitInfo->birthday,8);
                  ODStringPascalToC(od_control.user_subdate,pExtendedExitInfo->subdate,8);
                  od_control.user_screenwidth=pExtendedExitInfo->screenwidth;
                  od_control.user_msg_area=pExtendedExitInfo->msgarea;
                  od_control.user_file_area=pExtendedExitInfo->filearea;
                  od_control.user_language=pExtendedExitInfo->language;
                  od_control.user_date_format=pExtendedExitInfo->dateformat;
                  ODStringPascalToC(od_control.user_forward_to,pExtendedExitInfo->forwardto,35);
                  memcpy(&od_control.user_error_free,&pExtendedExitInfo->error_free,3);
                  ODStringPascalToC(od_control.user_emsi_crtdef,pExtendedExitInfo->emsi_crtdef,40);
                  ODStringPascalToC(od_control.user_emsi_protocols,pExtendedExitInfo->emsi_protocols,40);
                  ODStringPascalToC(od_control.user_emsi_capabilities,pExtendedExitInfo->emsi_capabilities,40);
                  ODStringPascalToC(od_control.user_emsi_requests,pExtendedExitInfo->emsi_requests,40);
                  ODStringPascalToC(od_control.user_emsi_software,pExtendedExitInfo->emsi_software,40);
                  memcpy(&od_control.user_hold_attr1,&pExtendedExitInfo->hold_attr1,3);

                  od_control.od_ra_info=TRUE;
                  od_control.od_extended_info=TRUE;
                  od_control.od_info_type=RA1EXITINFO;
               }
            }
         }
      }

      else if(dwFileSize>476)
      {
         if(dwFileSize > sizeof(tExitInfoRecord))
         {
            dwFileSize = sizeof(tExitInfoRecord);
         }

         if(ODReadExitInfoPrimitive(pfDropFile,(int)dwFileSize))
         {
            od_control.user_wantchat=pExitInfoRecord->bbs.qbbs.qwantchat;
            for(btCount=0;btCount<pExitInfoRecord->bbs.qbbs.gosublevel;++btCount)
            {
               ODStringPascalToC(od_control.user_menustack[btCount],pExitInfoRecord->bbs.qbbs.menustack[btCount],8);
            }
            od_control.user_menustackpointer=pExitInfoRecord->bbs.qbbs.gosublevel;
            ODStringPascalToC(od_control.user_menustack[od_control.user_menustackpointer],pExitInfoRecord->bbs.qbbs.menu,8);

            od_control.od_extended_info=TRUE;
            od_control.od_info_type=QBBS275EXITINFO;
            nInitialElapsed=pExitInfoRecord->elapsed;

            od_control.user_rip = pExitInfoRecord->bbs.qbbs.ripactive;
         }
      }

      else if(dwFileSize>=452)
      {
         if(ODReadExitInfoPrimitive(pfDropFile,(int)dwFileSize))
         {
            ODStringPascalToC(od_control.user_timeofcreation,pExitInfoRecord->bbs.ra.timeofcreation,5);
            ODStringPascalToC(od_control.user_logonpassword,pExitInfoRecord->bbs.ra.logonpassword,15);
            od_control.user_wantchat=pExitInfoRecord->bbs.ra.wantchat;

            od_control.od_extended_info=TRUE;
            od_control.od_info_type=EXITINFO;
         }
      }

      od_control.od_page_pausing=od_control.user_attribute&0x04;

      fclose(pfDropFile);
   }
}


/* ----------------------------------------------------------------------------
 * ODInitPartTwo()                                     *** PRIVATE FUNCTION ***
 *
 * Called by od_init() to carry on with second stage of OpenDoors
 * initialization. The sole reason that this function exists is because some
 * compilers were unable to compile this file with a huge od_init() function
 * that had this code in the main od_init() body.
 *
 * Parameters: none
 *
 *     Return: void
 */
static void ODInitPartTwo(void)
{
   BYTE btCount;
1830 1831 1832 1833
#ifdef ODPLAT_NIX
   struct termios term;
   struct passwd  *uinfo;
#endif
rswindell's avatar
rswindell committed
1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986

   /* Initialize any colors that haven't already been set. */
   if(!od_control.od_list_title_col) od_control.od_list_title_col = 0x0f;
   if(!od_control.od_continue_col) od_control.od_continue_col = 0x0f;
   if(!od_control.od_list_name_col) od_control.od_list_name_col = 0x0e;
   if(!od_control.od_list_size_col) od_control.od_list_size_col = 0x0d;
   if(!od_control.od_list_comment_col) od_control.od_list_comment_col = 0x03;
   if(!od_control.od_list_offline_col) od_control.od_list_offline_col = 0x0c;
   if(!od_control.od_local_win_col) od_control.od_local_win_col = 0x19;
   if(!od_control.od_menu_title_col) od_control.od_menu_title_col = 0x74;
   if(!od_control.od_menu_border_col) od_control.od_menu_border_col = 0x70;
   if(!od_control.od_menu_text_col) od_control.od_menu_text_col = 0x70;
   if(!od_control.od_menu_key_col) od_control.od_menu_key_col = 0x7f;
   if(!od_control.od_menu_highkey_col) od_control.od_menu_highkey_col = 0x0f;
   if(!od_control.od_menu_highlight_col)
   {
      od_control.od_menu_highlight_col = 0x07;
   }

   /* Color sequence delimiter characters. */
   od_control.od_color_char = '\0';
   od_control.od_color_delimiter = '`';

   /* Enable sysop paging between the hours of 8:00am and 10:00pm. */
   od_control.od_okaytopage = PAGE_USE_HOURS;
   od_control.od_pagestartmin = 480;
   od_control.od_pageendmin = 1320;