home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / TPUSYS11.ZIP / USERSYS.PAS next >
Encoding:
Pascal/Delphi Source File  |  1990-10-16  |  13.8 KB  |  315 lines

  1. {************************************************************************}
  2. { USERSYS.PAS Access To PCBoard 14.5 USERS.SYS File. Coded 1990 B Walter }
  3. {************************************************************************}
  4. {                                                                        }
  5. { All I ask if you use this code is that I am included in the credits!   }
  6. { Hope the code helps and if you have any questions I can be reached on  }
  7. { Salt Air Developers Conference, the SmartNet Pascal Conference or on   }
  8. { my own system 530 Hudson Street.                                       }
  9. {                                                                        }
  10. { Hudson Street Public Access (201) 891-3721.  Ask about Visiting SysOp  }
  11. { privileges...                                                          }
  12. {                                                                        }
  13. { This unit is obviously not heavily commented,  but is fairly simple to }
  14. { follow.  The calls are issued as follows:                              }
  15. {                                                                        }
  16. {************************************************************************}
  17. {                                                                        }
  18. { PROCEDURE GetUserSysInfo ( SysPath : String; VAR Result : Integer );   }
  19. {                                                                        }
  20. { This function loads all USERS.SYS data into the supplied variables     }
  21. {                                                                        }
  22. { Parameters:                                                            }
  23. {   SysPath - Complete Path To USERS.SYS                                 }
  24. {   Result  - Returns 0 for successful or a DOS error code for any error }
  25. {                                                                        }
  26. { Sample usage:                                                          }
  27. {   GetUserSysInfo ('C:\PCB\USERS.SYS',Result);                          }
  28. {   IF Result <> 0 THEN                                                  }
  29. {     BEGIN                                                              }
  30. {       Writeln ('Error ',Result,' reading USERS.SYS!');                 }
  31. {       Halt;                                                            }
  32. {     END;                                                               }
  33. {                                                                        }
  34. {************************************************************************}
  35. {                                                                        }
  36. { PROCEDURE PutUserSysInfo ( SysPath : String; VAR Result : Integer );   }
  37. {                                                                        }
  38. { This function saves all variables into an updated USERS.SYS.  It is    }
  39. { the programmers responsibilty to set the UPDATED flag if the record    }
  40. { has been modified. (IMPORTANT!)                                        }
  41. {                                                                        }
  42. { Parameters:                                                            }
  43. {   SysPath - Complete Path To USERS.SYS                                 }
  44. {   Result  - Returns 0 for successful or a DOS error code for any error }
  45. {                                                                        }
  46. { Sample usage:                                                          }
  47. {   PutUserSysInfo ('C:\PCB\USERS.SYS',Result);                          }
  48. {   IF Result <> 0 THEN                                                  }
  49. {     BEGIN                                                              }
  50. {       Writeln ('Error ',Result,' writing USERS.SYS!');                 }
  51. {       Halt;                                                            }
  52. {     END;                                                               }
  53. {                                                                        }
  54. {************************************************************************}
  55. {                                                                        }
  56. { FUNCTION GetFlag ( MapNo : Byte; ConfNo : Word ) : Boolean;            }
  57. {                                                                        }
  58. { This function returns the value of a specified conference bit          }
  59. {                                                                        }
  60. { Parameters:                                                            }
  61. {   MapNo  - This is the map you wish to inquire about.  Map names are   }
  62. {            preset to existing known values (ie: Map_MailWaiting = 1)   }
  63. {            as specified by CDC.                                        }
  64. {   ConfNo - This is the conference that you wish to check the bit value }
  65. {            of.  Any calls for conferences above the number specified   }
  66. {            as active in PCBSetup will be ignored!                      }
  67. {                                                                        }
  68. { Sample usage:                                                          }
  69. {   IF GetFlag (Map_MailWaiting,0) THEN                                  }
  70. {     Writeln ('You have mail waiting in the main board!');              }
  71. {                                                                        }
  72. {************************************************************************}
  73. {                                                                        }
  74. { PROCEDURE PutFlag ( MapNo : Byte; ConfNo : Word; Flag : Boolean );     }
  75. {                                                                        }
  76. { This function sets the value of a specified conference bit             }
  77. {                                                                        }
  78. { Parameters:                                                            }
  79. {   MapNo  - This is the map you wish to set.  Map names are preset to   }
  80. {            existing known values (ie: Map_MailWaiting = 1) as          }
  81. {            specified by CDC.                                           }
  82. {   ConfNo - This is the conference that you wish to set the bit value   }
  83. {            of.  Any calls for conferences above the number specified   }
  84. {            as active in PCBSetup will be ignored!                      }
  85. {   Flag   - This is the value you want the conference bit set to        }
  86. {                                                                        }
  87. { Sample usage:                                                          }
  88. {   PutFlag (Map_ConfSysop,44,TRUE);                                     }
  89. {   Writeln ('You now have conference sysop status in conference #44!'); }
  90. {                                                                        }
  91. {************************************************************************}
  92.  
  93. {$I-}
  94. UNIT UserSys;
  95.  
  96. INTERFACE
  97.  
  98. TYPE
  99.   Char6     = Array[1..6]  OF Char;    { These types can be moved into a }
  100.   Char13    = Array[1..13] OF Char;    { central unit for global usage   }
  101.   Char14    = Array[1..14] OF Char;
  102.   Char15    = Array[1..15] OF Char;
  103.   Char25    = Array[1..25] OF Char;
  104.   Char26    = Array[1..26] OF Char;
  105.   Char31    = Array[1..31] OF Char;
  106.  
  107.   BitMapPtr = ^BitMap;                 { Bitmap,  Message and TPA info   }
  108.   BitMap    = Array[0..0]  OF Byte;    { is stored on the heap due to    }
  109.                                        { it's dynamic nature             }
  110.   MsgPtrPtr = ^MsgPtr;
  111.   MsgPtr    = Array[0..0]  OF LongInt;
  112.  
  113.   TPARecPtr = ^TpaRec;
  114.   TPARec    = Array[0..0]  OF Char;
  115.  
  116.   SysHeader =                          { Documentation for SysHeader and }
  117.     RECORD                             { and SysRecord fields can be     }
  118.       Version         : Word;          { found in the DEVELOP.ZIP file   }
  119.       RecNo           : LongInt;
  120.       RecSize         : Word;
  121.       NumConfs        : Word;
  122.       NumBitMaps      : Word;
  123.       BitMapSize      : Word;
  124.       AppName         : Char15;
  125.       AppVersion      : Word;
  126.       AppStaticSize   : Word;
  127.       AppDynamicSize  : Word;
  128.       AppDataOffset   : LongInt;
  129.       Updated         : Boolean;
  130.     END;
  131.  
  132.   SysRecord =
  133.     RECORD
  134.       UserName        : Char26;
  135.       City            : Char25;
  136.       Password        : Char13;
  137.       BusinessPhone   : Char14;
  138.       VoicePhone      : Char14;
  139.       LastDateOn      : Word;
  140.       LastTimeOn      : Char6;
  141.       Expert          : Boolean;
  142.       Protocol        : Char;
  143.       UserFlags       : Byte;
  144.       LastDirScan     : Word;
  145.       Security        : Integer;
  146.       TimesOn         : Word;
  147.       PageLength      : Byte;
  148.       FilesUploaded   : Word;
  149.       FilesDownloaded : Word;
  150.       DailyDLBytes    : LongInt;
  151.       UserComment     : Char31;
  152.       SysopComment    : Char31;
  153.       ElapsedTimeOn   : Integer;
  154.       ExpirationDate  : Word;
  155.       ExpiredSecurity : Integer;
  156.       LastConference  : Word;
  157.       BytesDownloaded : LongInt;
  158.       BytesUploaded   : LongInt;
  159.       Delete          : Boolean;
  160.       INFRecNo        : LongInt;
  161.       CurConfH        : Byte;       (* PRODOOR *)
  162.       ExtUserRecNo    : Word;       (* PRODOOR *)
  163.       ProdoorFlags    : Byte;       (* PRODOOR *)
  164.       MailConf        : Byte;       (* PRODOOR *)
  165.       ScratchNum      : Byte;       (* PRODOOR *)
  166.       ProdoorUsed     : Byte;       (* PRODOOR *)
  167.       EarnedDLBytes   : Word;       (* PRODOOR *)
  168.       MessagesRead    : LongInt;
  169.       MessagesLeft    : LongInt;
  170.     END;
  171.  
  172. CONST
  173.   Map_Registered   = 1;
  174.   Map_Expired      = 2;
  175.   Map_Scan         = 3;
  176.   Map_ConfSysop    = 4;
  177.   Map_MailWaiting  = 5;
  178.   Map_JoinedToday  = 6;
  179.   Map_ScannedToday = 7;
  180.  
  181. VAR
  182.   SysHead : SysHeader;  { These variables provide access to the USERS.SYS  }
  183.   SysUser : SysRecord;  { info.  BitArea is manipulated through GetFlag    }
  184.   BitArea : BitMapPtr;  { and PutFlag and should NOT be directly accessed! }
  185.   HighMsg : MsgPtrPtr;  { HighMsg^[x] is the LongInt Hi Message Number for }
  186.   TPAInfo : TPARecPtr;  { conf x.  TPAInfo^[x] contains the current TPA    }
  187.                         { record for the online user and is up to YOU to   }
  188.                         { handle since you are writing the door!  <GRIN>   }
  189.  
  190. PROCEDURE GetUserSysInfo ( SysPath : String; VAR Result : Word );
  191. PROCEDURE PutUserSysInfo ( SysPath : String; VAR Result : Word );
  192. FUNCTION  GetFlag        ( MapNo : Byte; ConfNo : Word ) : Boolean;
  193. PROCEDURE PutFlag        ( MapNo : Byte; ConfNo : Word; Flag : Boolean );
  194.  
  195. IMPLEMENTATION
  196.  
  197. PROCEDURE GetUserSysInfo ( SysPath : String; VAR Result : Word );
  198.   VAR
  199.     SysF : File;
  200.     NumR : Word;
  201.     Size : LongInt;
  202.   BEGIN
  203.     Assign (SysF,SysPath);
  204.     Reset  (SysF,1);
  205.     Result := IoResult;
  206.     IF Result <> 0 THEN
  207.       Exit;
  208.     BlockRead (SysF,SysHead,SizeOf (SysHead),NumR);
  209.     Result := IoResult;
  210.     IF Result = 0 THEN
  211.       BEGIN
  212.         BlockRead (SysF,SysUser,SysHead.RecSize,NumR);
  213.         Result := IoResult;
  214.         IF Result = 0 THEN
  215.           BEGIN
  216.             Size := SysHead.NumConfs * SizeOf (LongInt);
  217.             GetMem (HighMsg,Size);
  218.             BlockRead (SysF,HighMsg^,SysHead.NumConfs * SizeOf (LongInt),NumR);
  219.             Result := IoResult;
  220.             IF Result = 0 THEN
  221.               BEGIN
  222.                 Size := SysHead.NumBitMaps * SysHead.BitMapSize;
  223.                 GetMem (BitArea,Size);
  224.                 BlockRead (SysF,BitArea^,Size,NumR);
  225.                 Result := IoResult;
  226.                 IF Result = 0 THEN
  227.                   BEGIN
  228.                     Size := SysHead.AppStaticSize + SysHead.AppDynamicSize;
  229.                     GetMem (TPAInfo,Size);
  230.                     BlockRead (SysF,TPAInfo^,Size,NumR);
  231.                     Result := IoResult;
  232.                   END;
  233.               END;
  234.           END;
  235.       END;
  236.     Close (SysF);
  237.   END;
  238.  
  239. PROCEDURE PutUserSysInfo ( SysPath : String; VAR Result : Word );
  240.   VAR
  241.     SysF : File;
  242.     NumW : Word;
  243.     Size : LongInt;
  244.   BEGIN
  245.     Assign (SysF,SysPath);
  246.     Rewrite (SysF,1);
  247.     Result := IoResult;
  248.     IF Result <> 0 THEN
  249.       Exit;
  250.     BlockWrite (SysF,SysHead,SizeOf (SysHead),NumW);
  251.     Result := IoResult;
  252.     IF Result = 0 THEN
  253.       BEGIN
  254.         BlockWrite (SysF,SysUser,SysHead.RecSize,NumW);
  255.         Result := IoResult;
  256.         IF Result = 0 THEN
  257.           BEGIN
  258.             Size := SysHead.NumConfs * SizeOf (LongInt);
  259.             BlockWrite (SysF,HighMsg^,SysHead.NumConfs * SizeOf (LongInt),NumW);
  260.             Result := IoResult;
  261.             IF Result = 0 THEN
  262.               BEGIN
  263.                 Size := SysHead.NumBitMaps * SysHead.BitMapSize;
  264.                 BlockWrite (SysF,BitArea^,Size,NumW);
  265.                 Result := IoResult;
  266.                 IF Result = 0 THEN
  267.                   BEGIN
  268.                     Size := SysHead.AppStaticSize + SysHead.AppDynamicSize;
  269.                     BlockWrite (SysF,TPAInfo^,Size,NumW);
  270.                     Result := IoResult;
  271.                   END;
  272.               END;
  273.           END;
  274.       END;
  275.     Close (SysF);
  276.   END;
  277.  
  278. FUNCTION  GetFlag ( MapNo : Byte; ConfNo : Word ) : Boolean;
  279.   VAR
  280.     Offset : Word;
  281.     ByteNo : Word;
  282.     BitNo  : Word;
  283.     TBool  : Boolean;
  284.   BEGIN
  285.     TBool := FALSE;
  286.     IF ConfNo < SysHead.NumConfs THEN
  287.       BEGIN
  288.         Offset  := (MapNo - 1) * SysHead.BitMapSize;
  289.         ByteNo  := ConfNo SHR 3;
  290.         BitNo   := ConfNo MOD 8;
  291.         TBool   := Odd (BitArea^[Offset + ByteNo] SHR BitNo);
  292.       END;
  293.     GetFlag := TBool;
  294.   END;
  295.  
  296. PROCEDURE PutFlag ( MapNo : Byte; ConfNo : Word; Flag : Boolean );
  297.   VAR
  298.     Offset : Word;
  299.     ByteNo : Word;
  300.     BitNo  : Word;
  301.   BEGIN
  302.     IF ConfNo >= SysHead.NumConfs THEN
  303.       Exit;
  304.     Offset  := (MapNo - 1) * SysHead.BitMapSize;
  305.     ByteNo  := ConfNo SHR 3;
  306.     BitNo   := ConfNo MOD 8;
  307.     IF Flag THEN
  308.       BitArea^[Offset + ByteNo] := BitArea^[Offset + ByteNo] OR (1 SHL BitNo)
  309.     ELSE
  310.       BitArea^[Offset + ByteNo] := BitArea^[Offset + ByteNo] AND (255 - (1 SHL BitNo));
  311.   END;
  312.  
  313. BEGIN
  314. END.
  315.