Unit BBSGlbls;



interface

{***************************************************************************}

{***************************************************************************}

Uses

  Globals;



const

  MaxSessions   = 1;

  NumPorts      = 2;

  AreaMaxStack     = 10;

  VarByteMaxStack  = 3;

  VarStrMaxStack   = 4;

  VarTextMaxStack  = 3;

  SublimRangeMax   = 20;

  BSALen           = 38;   {* length of datum in a BSA File *}



type

  StrBSA = string[BSALen];

  BSAFile = file of StrBSA;



type

  AreaType = (Zero,

              WaitRing,

              WaitConnect,

              GetName,

              GetName_1,

              GetName_2,

              UserInput,

              Register,

              Register_1,

              PasswordGood,

              PasswordGood_1,

              Welcome,

              Menu,

              Prompt,

              Prompt_1,

              LogOff,

              LogOff_1,

              Disconnect,

              Chat,

              BullPost,

              BullPost_1,

              BullRead,

              BullRead_1,

              Bulletins,

              BullDel,

              BullDel_1,

              BullPrompt,

              BullPrompt_1,

              BullMenu,

              BullSubMake,

              BullSubMake_1,

              BullSubKill,

              BullSubKill_1,

              BullSubCon,

              BullSubCon_1,

              BullSubCon_2,

              BullSubDown,

              BullSubDown_1,

              BullSubUp,

              BullSubUp_1,

              BullPickedChild,

              BullPickedChild_1,

              BullPickedParent,

              BullPickedParent_1,

              BullPickedBull,

              BullPickedBull_1,

              Statistics,

              Statistics_1,

              DataMenu,

              MailMenu,

              EMail,

              EMail_1,

              EMailSend,

              EMailSend_1,

              EMailSend_2,

              EMailSend_3,

              EMailSend_4,

              EMailRead,

              MakePassword,

              MakePassword_1,

              MakePassword_2,

              Feedback,

              Feedback_1,

              Feedback_2,

              FileLineEdit,

              FileLineEdit_1,

              FileShow,

              UpDown,

              AddOn,

              AddOnMenu,

              AddOnPrompt,

              AddOnPrompt_1

             );



var

  Area    : array[1..MaxSessions, 1..AreaMaxStack] of AreaType;

  AreaTOS : array[1..MaxSessions] of integer;

  BullAreaDir : array[1..MaxSessions] of W10k;

  BullAreaID  : array[1..MaxSessions] of W10k;

  BullAreaSubj: array[1..MaxSessions] of StrBSA;

  VarByte   : array[1..MaxSessions, 1..VarByteMaxStack] of byte;

  VarByteTOS: array[1..MaxSessions] of integer;

  VarStr    : array[1..MaxSessions, 1..VarStrMaxStack] of string;

  VarStrTOS : array[1..MaxSessions] of integer;

  VarText   : array[1..MaxSessions, 1..VarTextMaxStack] of text;

  VarTextTOS: array[1..MaxSessions] of integer;

  UserName: array[1..MaxSessions] of string;

  UserID  : array[1..MaxSessions] of integer;

  Now     : integer;

  SaveX   : array[1..MaxSessions] of integer;

  SaveY   : array[1..MaxSessions] of integer;

  WinX1,

  WinX2,

  WinY1,

  WinY2: array[1..MaxSessions] of integer;



  SessInStr : array[1..MaxSessions] of string;

  PortOutStr: array[0..NumPorts] of string;

  InputFrom: array[1..MaxSessions, 0..NumPorts] of boolean;

  OutputTo : array[1..MaxSessions, 0..NumPorts] of boolean;

  Echo: array[1..MaxSessions] of boolean;

  InStrMaxLen: array[1..MaxSessions] of byte;



  BeepTime: array[1..MaxSessions] of real;

  InputDeadLine: array[1..MaxSessions] of double;

  TimeLeft,

  DateLogOut,

  TimeLogOut: array[1..MaxSessions] of longint;

  UserPrivs: array[1..MaxSessions] of longint;



  ActiveSession: integer;

  BeepOn: boolean;



  LinesPerPage: array[1..MaxSessions] of integer;



  Password1,

  Password2: string; {* Required by DoMakePassword *}



  SublimRange: integer;

  Sublim: array[1..SublimRangeMax] of string;



const

  ModemDelay   = 1000;

  NewUserTime  = 15*60;

  LogInTime    = 30; {* normally 30 *}

  InputTime    = 30*10;

  RegisterTime = 30; {* normally 30 *}



  LineLen = 78;



  InitOutputTo: array[1..MaxSessions, 1..NumPorts] of boolean =

    ((false, false));

  InitInputFrom: array[1..MaxSessions, 0..NumPorts] of boolean =

    ((true, false, true));

  PortOn:  array[1..NumPorts] of boolean = (false, true);



  TrashDir = 'BBSTrash';

  UsersDir = 'BBSUsers.BBS';

  StatsDir = 'BBSystem';

  StatFile = StatsDir + '\BBSStats.BBS';

  UsersLog = UsersDir + '\UsersLog.BBS';

  ErrorLog = StatsDir + '\ErrorLog.BBS';

  TempFile = TrashDir + '\TempFile.BBS';

  EMailBox = 'EMailBox.BBS';

  SubliminalFile = StatsDir + '\Sublims.BBS';



  BullFileChildrenLines = 2;

  BullFileParentsLines = 2;

  BullFileSubjectsLines = 3;



  ManagerPassword = 'Jabberwocky';

  PasswordMinLen = 6;

  BullTopSubjectStr: StrBSA = 'TOP LEVEL SUBJECT AREA                ';



  {* privileges based on a 32-bit longint *}

  AllPrivs         = -1;

  ChangePrivsPriv  = (MaxLongInt + 1) div 2; {* MSB only I assume *}

  NewUserPrivs     = 1 + 2 + 8;

  BullReadPriv     = 1;

  BullPostPriv     = 2;

  BullKillPriv     = 4;

  BullAllPrivs     = 7;

  BullAreaMakePriv = 8;

  BullAreaKillPriv = 16;



var

  ExitSave: pointer;



Procedure InitBBSGlbls;

Procedure InitSessionVariables(Session: integer);



implementation

{***************************************************************************}

{***************************************************************************}

uses

  Dos,

  IOPorts;



Procedure InitBBSGlbls;

{***************************************************************************}

var

  alpha: integer;

begin

  for alpha := 1 to MaxSessions do

    InitSessionVariables(alpha);

  for alpha := 1 to NumPorts do

    PortOutStr[alpha] := '';

  Now := 1;

end;



procedure InitSessionVariables(Session: integer);

{***************************************************************************}

var

  alpha: integer;

begin

  InStrMaxLen[Session] := LineLen;

  Echo[Session] := true;

  UserID[Session] := 0;

  UserName[Session] := '';

  TimeLogOut[Session] := Infinity;

  for alpha := 1 to AreaMaxStack do

    Area[Session, alpha] := Zero;

  AreaTOS[Session] := 1;

  for alpha := 1 to VarByteMaxStack do

    VarByte[Session, alpha] := 0;

  VarByteTOS[Session] := 1;

  for alpha := 1 to VarStrMaxStack do

    VarStr[Session, alpha] := '';

  VarStrTOS[Session] := 1;

  VarTextTOS[Session] := 1;

  Area[Session, AreaTOS[Session]] := WaitRing;

  LinesPerPage[Session] := 23;

  SessInStr[Session] := '';

  for alpha := 1 to NumPorts do

    OutputTo[Session, alpha] := InitOutputTo[Session, alpha];

  for alpha := 0 to NumPorts do

    InputFrom[Session, alpha] := InitInputFrom[Session, alpha];

end;



{***************************************************************************}

{***************************************************************************}

{***************************************************************************}

begin

end.