home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 2 BBS / 02-BBS.zip / MAXP201B.LZH / MAX_U.H < prev    next >
C/C++ Source or Header  |  1992-02-29  |  13KB  |  241 lines

  1. /*# name=Maximus USER.BBS structure definition
  2. */
  3.  
  4.  
  5. /* NOTE:  This structure is semi-stable.  Although it is still compatible  *
  6.  * with the old Opus 1.03 structure, don't expect it to stay that way      *
  7.  * for long.  In a future version, Maximus will be using a dymaic-sized    *
  8.  * user record, making it possible to make additions without breaking      *
  9.  * preexisting software.  You can start to code for this now in your       *
  10.  * software, as the usr.struct_len variable indicates the length of the    *
  11.  * current user structure, divided by twenty.  This allows us to build up  *
  12.  * a base of utilities, and be able to switch to a new format (while still *
  13.  * not breaking anything) in the future.  Also, if usr.sruct_len==0, then  *
  14.  * you MUST assume that the length of the structure is actually 180 bytes  *
  15.  * long, as Opus (and Maximus v1.00 only) did not use this field.  In      *
  16.  * other words:                                                            *
  17.  *                                                                         *
  18.  * len_of_struct=(usr.struct_len ? (usr.struct_len*20) : 180)              *
  19.  *                                                                         *
  20.  * In addition, you can assume that all user records in the user file are  *
  21.  * the SAME size...  ie. You can just read the first user record out of    *
  22.  * the file, and you are assured that the rest of the records in the file  *
  23.  * area also the same size.                                                *
  24.  *                                                                         *
  25.  *                                                                         *
  26.  * Example for reading in the dynamic-sized user structure:                *
  27.  *                                                                         *
  28.  *    {                                                                    *
  29.  *      struct _usr users[MAX_USERS];                                      *
  30.  *                                                                         *
  31.  *      int x,                                                             *
  32.  *          userfile,                                                      *
  33.  *          s_len;                                                         *
  34.  *                                                                         *
  35.  *      if ((userfile=open(ufile_name,O_RDONLY | O_BINARY))==-1)           *
  36.  *        Error();                                                         *
  37.  *                                                                         *
  38.  *      read(userfile,&users[0],sizeof(struct _usr));                      *
  39.  *                                                                         *
  40.  *      s_len=users[0].struct_len ? users[0].struct_len*20 : 180;          *
  41.  *                                                                         *
  42.  *      for (x=0;x < MAX_USERS;x++)                                        *
  43.  *      {                                                                  *
  44.  *        lseek(userfile,(long)x*(long)s_len,SEEK_SET);                    *
  45.  *        read(userfile,&users[x],sizeof(struct _usr));                    *
  46.  *      }                                                                  *
  47.  *                                                                         *
  48.  *      close(userfile);                                                   *
  49.  *    }                                                                    *
  50.  *                                                                         *
  51.  * If anything is added to the user structure, it will be appended to the  *
  52.  * END of the structure, so you can be assured that the offsets of each    *
  53.  * individual variable will NOT change.                                    *
  54.  *                                                                         *
  55.  * Also, when ADDING or DELETING users, certain special operations have    *
  56.  * to be performed, mainly those related to the lastread pointers.  When   *
  57.  * adding a user, the procedure is fairly simple; just make sure that      *
  58.  * usr.lastread_ptr is a unique number, different from all others in       *
  59.  * USER.BBS.  Although Max uses a somewhat complicated algorithm to        *
  60.  * fill gaps in the user file, most utility programs can just read through *
  61.  * USER.BBS, and keep a running tally of the HIGHEST usr.struct_len        *
  62.  * variable.  Once you have that, increment it by one, and stuff it into   *
  63.  * the usr.struct_len of the user to be added.                             *
  64.  *                                                                         *
  65.  * When DELETING users, you must go through the process of "cleansing"     *
  66.  * the lastread pointers for the user you deleted.  The procedure for this *
  67.  * is simple:  For every area listed in AREAS.CTL, open the LASTREAD.BBS   *
  68.  * file for that area, and seek to the offset...                           *
  69.  *                                                                         *
  70.  *    usr.lastread_ptr*(long)sizeof(int)                                   *
  71.  *                                                                         *
  72.  * ...and write *two* NUL bytes (ASCII 00).                                *
  73.  *                                                                         *
  74.  * Please note that you do NOT need to do anything special to sort the     *
  75.  * user file...  Since the lastread offset is stored in usr.lastread_ptr,  *
  76.  * you can sort the user file with impunity, and even use old Opus 1.03    *
  77.  * sort utilities.                                                         */
  78.  
  79.  
  80.  
  81. #include "typedefs.h"
  82. #include "stamp.h"
  83.  
  84.  
  85. #define MAX_ALEN         10     /* Max length of usr.msg[] and usr.files[]  */
  86.  
  87.  
  88. /* Masks for usr.bits1, below */
  89.  
  90. #define BITS_HOTKEYS     0x0001 /* Hotkeys, independent of HOTFLASH level   */
  91. #define BITS_NOTAVAIL    0x0002 /* If set, user is NOT normally available   *
  92.                                  * for chat.                                */
  93. #define BITS_FSR         0x0004 /* Full-screen reading in msg areas         */
  94. #define BITS_NERD        0x0008 /* Yelling makes no noise on sysop console  */
  95. #define BITS_NOULIST     0x0010 /* Don't display name in userlist           */
  96. #define BITS_TABS        0x0020 /* Reserved                                 */
  97. #define BITS_BIT6        0x0040 /* Reserved                                 */
  98. #define BITS_BIT7        0x0080 /* Reserved                                 */
  99.  
  100.  
  101. /* Masks for usr.bits2, below */
  102.  
  103. #define BITS2_BADLOGON   0x0001 /* MAX: if user's last logon attempt was bad*/
  104. #define BITS2_IBMCHARS   0x0002 /* MAX: if user can receive high-bit chars  */
  105. #define BITS2_RSVD1      0x0004 /* MAX: *obsolete* 1.02 avatar flag         */
  106. #define BITS2_BORED      0x0008 /* Use the line-oriented editor             */
  107. #define BITS2_MORE       0x0010 /* Wants the "MORE?" prompt                 */
  108. #define BITS2_RSVD2      0x0020 /* OPUS: set=wants Ansi                     */
  109. #define BITS2_CONFIGURED 0x0040 /* OPUS: set=used Maximus before            */
  110. #define BITS2_CLS        0x0080 /* OPUS: set=transmit ^L, clear=ignore ^L   */
  111. #define BITS2_BIT8       0x0100 /* used to be 'usr.keys'                    */
  112. #define BITS2_BIT9       0x0200 /* used to be 'usr.keys'                    */
  113. #define BITS2_BITA       0x0400 /* used to be 'usr.keys'                    */
  114. #define BITS2_BITB       0x0800 /* used to be 'usr.keys'                    */
  115. #define BITS2_BITC       0x1000 /* used to be 'usr.keys'                    */
  116. #define BITS2_BITD       0x2000 /* used to be 'usr.keys'                    */
  117. #define BITS2_BITE       0x4000 /* used to be 'usr.keys'                    */
  118. #define BITS2_BITF       0x8000 /* used to be 'usr.keys'                    */
  119.  
  120.  
  121. /* Masks for usr.delflag, below */
  122.  
  123. #define UFLAG_DEL   0x01
  124. #define UFLAG_PERM  0x02
  125.  
  126. /* Masks for usr.xp_flag, below */
  127.  
  128. #define XFLAG_EXPDATE    0x0001 /* Use the xp_date to control access        */
  129. #define XFLAG_EXPMINS    0x0002 /* Use the xp_mins number to control access */
  130. #define XFLAG_DEMOTE     0x0004 /* Demote user to priv level in usr.xp_priv */
  131. #define XFLAG_AXE        0x0008 /* Just hang up on user                     */
  132.  
  133. /* Constants for usr.video, below */
  134.  
  135. #define GRAPH_TTY         0x00 /* The current user's graphics setting...    */
  136. #define GRAPH_ANSI        0x01 
  137. #define GRAPH_AVATAR      0x02
  138.  
  139.  
  140. struct   _usr
  141.    {
  142.       byte name[36];        /* Caller's name                                */
  143.       byte city[36];        /* Caller's location                            */
  144.  
  145.       byte alias[21];       /* MAX: user's alias (handle)                   */
  146.       byte phone[15];       /* MAX: user's phone number                     */
  147.  
  148.       word lastread_ptr;    /* MAX: a num which points to offset in LASTREAD*/
  149.                             /* file -- Offset of lastread pointer will be   */
  150.                             /* lastread_ptr*sizeof(int).                    */
  151.  
  152.       word timeremaining;   /* MAX: time left for current call (xtern prog) */
  153.  
  154.       byte pwd[16];         /* Password                                     */
  155.       word times;           /* Number of previous calls to this system      */
  156.       byte help;            /* Help level                                   */
  157. /**/  byte rsvd1[2];        /* Reserved by Maximus for future use           */
  158.       byte video;           /* user's video mode (see GRAPH_XXXX)           */
  159.       byte nulls;           /* Number of Nulls (delays) after <cr>          */
  160.  
  161.       byte bits;            /* Bit flags for user (number 1)                */
  162.  
  163. /**/  word rsvd2;           /* Reserved by Maximus for future use           */
  164.  
  165.       word bits2;           /* Bit flags for user (number 2)                */
  166.  
  167.       sword priv;           /* Access level                                 */
  168. /**/  byte rsvd3[19];       /* Reserved by Maximus for future use           */
  169.       byte struct_len;      /* len of struct, divided by 20. SEE ABOVE!     */
  170.       word time;            /* Time on-line so far today                    */
  171.  
  172.       word delflag;         /* Used to hold baud rate for O)utside command  */
  173.                             /* In USER.BBS, usr.flag uses the constants     */
  174.                             /* UFLAG_xxx, defined earlier in this file.     */
  175.       
  176. /**/  byte rsvd4[8];        /* Reserved by Maximus for future use           */
  177.  
  178.       byte width;           /* Width of the caller's screen                 */
  179.       byte len;             /* Height of the caller's screen                */
  180.       word credit;          /* Matrix credit, in cents                      */
  181.       word debit;           /* Current matrix debit, in cents               */
  182.  
  183.       word  xp_priv;        /* Priv to demote to, when time or minutes run  */
  184.                             /* out.                                         */
  185.  
  186.       union stamp_combo xp_date;  /* Bit-mapped date of when user expires.  */
  187.                                   /* If zero, then no expiry date.          */
  188.  
  189.       dword xp_mins;        /* How many minutes the user has left before    *
  190.                              * expiring.                                    */
  191.  
  192.       byte  xp_flag;        /* Flags for expiry.  See above XFLAG_XXX defs. */
  193.       byte  xp_rsvd;
  194.  
  195.       union stamp_combo ludate;   /* Bit-mapped date of user's last call    */
  196.  
  197.       dword xkeys;          /* User's keys (all 32 of 'em)                  */
  198.       byte  lang;           /* The user's current language #                */
  199.       sbyte def_proto;      /* Default file-transfer protocol               */
  200.  
  201.       dword up;             /* K-bytes uploaded, all calls                  */
  202.       dword down;           /* K-bytes downloaded, all calls                */
  203.       dword downtoday;      /* K-bytes downloaded, today                    */
  204.  
  205.       byte msg[MAX_ALEN];   /* User's last msg area (string)                */
  206.       byte files[MAX_ALEN]; /* User's last file area (string)               */
  207.  
  208.       byte compress;        /* Default compression program to use           */
  209.  
  210. /**/  byte rsvd5;
  211.       dword extra;
  212.  
  213. #if 0
  214.       dword msgs_posted;
  215.       dword msgs_read;
  216.  
  217.       SCOMBO date_1stcall;
  218.       SCOMBO date_newfile;
  219.       SCOMBO date_pwd_chg;
  220.  
  221.       word last_pwd_crc;
  222.  
  223.       byte  dob_day;    /* sigh */
  224.       byte  dob_month;
  225.       word  dob_year;
  226.  
  227.       char dataphone[16];
  228.  
  229.       dword nup;
  230.       dword ndown;
  231.       dword ndowntoday;
  232.  
  233.       word time_added_by_add_to_time;
  234.       word group;
  235.       char space[22];
  236.  
  237.       /* user macros?  user address?  custom question? */
  238. #endif
  239.    };
  240.  
  241.