home *** CD-ROM | disk | FTP | other *** search
/ C!T ROM 2 / ctrom_ii_b.zip / ctrom_ii_b / PROGRAM / C / LASTCA3S / USER.H < prev   
C/C++ Source or Header  |  1991-12-07  |  15KB  |  317 lines

  1. /* Portability declarations */
  2.  
  3. #if defined(__386__) || defined(__FLAT__)
  4.   typedef unsigned      bit;
  5.  
  6.   typedef unsigned char byte;
  7.   typedef signed char   sbyte;
  8.  
  9.   typedef unsigned short word;
  10.   typedef signed short   sword;
  11.  
  12.   typedef unsigned int  dword;
  13.   typedef signed int    sdword;
  14.  
  15.   typedef unsigned short ushort;
  16.   typedef   signed short sshort;
  17.  
  18.   typedef unsigned long  ulong;
  19.   typedef   signed long  slong;
  20. #else
  21.   typedef unsigned      bit;
  22.  
  23.   typedef unsigned char byte;
  24.   typedef signed char   sbyte;
  25.  
  26.   typedef unsigned int  word;
  27.   typedef signed int    sword;
  28.  
  29.   typedef unsigned long dword;
  30.   typedef signed long   sdword;
  31.  
  32.   typedef unsigned short ushort;
  33.   typedef   signed short sshort;
  34.  
  35.   typedef unsigned long  ulong;
  36.   typedef   signed long  slong;
  37. #endif
  38.  
  39.  
  40. /* DOS-style bitmapped datestamp */
  41. struct _stamp
  42. {
  43.   struct
  44.   {
  45.     unsigned int da : 5;
  46.     unsigned int mo : 4;
  47.     unsigned int yr : 7;
  48.   } date;
  49.  
  50.   struct
  51.   {
  52.     unsigned int ss : 5;
  53.     unsigned int mm : 6;
  54.     unsigned int hh : 5;
  55.   } time;
  56. };
  57.  
  58.  
  59. struct _dos_st
  60. {
  61.   word date;
  62.   word time;
  63. };
  64.  
  65. /* Union so we can access stamp as "int" or by individual components */
  66.  
  67. union stamp_combo   
  68. {
  69.   dword ldate;
  70.   struct _stamp msg_st;
  71.   struct _dos_st dos_st;
  72. };
  73.  
  74. typedef union stamp_combo SCOMBO;
  75.  
  76. /* Access levels, as used in user file, PRM file, and others. */
  77.  
  78. #define  TWIT        -2 /* 0xFFFE */
  79. #define  DISGRACE    0x0000
  80. #define  LIMITED     0x0001  /**/
  81. #define  NORMAL      0x0002
  82. #define  WORTHY      0x0003  /**/
  83. #define  PRIVIL      0x0004
  84. #define  FAVORED     0x0005  /**/
  85. #define  EXTRA       0x0006
  86. #define  CLERK       0x0007  /**/
  87. #define  ASSTSYSOP   0x0008
  88. #define  SYSOP       0x000A
  89. #define  HIDDEN      0x000b
  90.  
  91. #define MAX_KEYS           32
  92. #define MAX_ALEN           10   /* Max length of usr.msg[] and usr.files[]  */
  93. #define MAX_OVR            16   /* Maximum # of override privs per area     */
  94. #define NUM_MENU          256   /* Max. # of options in a menu file         */
  95. #define PATHLEN           120   /* Max. length of a path                    */
  96. #define MAX_MENUNAME  PATHLEN   /* Max. length of menuname[].               */
  97. #define MAXEXPAND          30   /* max wildcard expansion                   */
  98. #define CHAR_BITS           8   /* Number of bits in a `char' variable      */
  99. #define MAX_AREAS        1296   /* Maximum number of total areas -- obsolete*/
  100.  
  101.  
  102. /* Structure for USER.BBS and LASTUSER.BBS */
  103.  
  104. /* NOTE:  This structure is semi-stable.  Although it is still compatible  *
  105.  * with the old Opus 1.03 structure, don't expect it to stay that way      *
  106.  * for long.  In a future version, Maximus will be using a dymaic-sized    *
  107.  * user record, making it possible to make additions without breaking      *
  108.  * preexisting software.  You can start to code for this now in your       *
  109.  * software, as the usr.struct_len variable indicates the length of the    *
  110.  * current user structure, divided by twenty.  This allows us to build up  *
  111.  * a base of utilities, and be able to switch to a new format (while still *
  112.  * not breaking anything) in the future.  Also, if usr.sruct_len==0, then  *
  113.  * you MUST assume that the length of the structure is actually 180 bytes  *
  114.  * long, as Opus (and Maximus v1.00 only) did not use this field.  In      *
  115.  * other words:                                                            *
  116.  *                                                                         *
  117.  * len_of_struct=(usr.struct_len ? (usr.struct_len*20) : 180)              *
  118.  *                                                                         *
  119.  * In addition, you can assume that all user records in the user file are  *
  120.  * the SAME size...  ie. You can just read the first user record out of    *
  121.  * the file, and you are assured that the rest of the records in the file  *
  122.  * area also the same size.                                                *
  123.  *                                                                         *
  124.  *                                                                         *
  125.  * Example for reading in the dynamic-sized user structure:                *
  126.  *                                                                         *
  127.  *    {                                                                    *
  128.  *      struct _usr users[MAX_USERS];                                      *
  129.  *                                                                         *
  130.  *      int x,                                                             *
  131.  *          userfile,                                                      *
  132.  *          s_len;                                                         *
  133.  *                                                                         *
  134.  *      if ((userfile=open(ufile_name,O_RDONLY | O_BINARY))==-1)           *
  135.  *        Error();                                                         *
  136.  *                                                                         *
  137.  *      read(userfile,&users[0],sizeof(struct _usr));                      *
  138.  *                                                                         *
  139.  *      s_len=users[0].struct_len ? users[0].struct_len*20 : 180;          *
  140.  *                                                                         *
  141.  *      for (x=0;x < MAX_USERS;x++)                                        *
  142.  *      {                                                                  *
  143.  *        lseek(userfile,(long)x*(long)s_len,SEEK_SET);                    *
  144.  *        read(userfile,&users[x],sizeof(struct _usr));                    *
  145.  *      }                                                                  *
  146.  *                                                                         *
  147.  *      close(userfile);                                                   *
  148.  *    }                                                                    *
  149.  *                                                                         *
  150.  * If anything is added to the user structure, it will be appended to the  *
  151.  * END of the structure, so you can be assured that the offsets of each    *
  152.  * individual variable will NOT change.                                    *
  153.  *                                                                         *
  154.  * Also, when ADDING or DELETING users, certain special operations have    *
  155.  * to be performed, mainly those related to the lastread pointers.  When   *
  156.  * adding a user, the procedure is fairly simple; just make sure that      *
  157.  * usr.lastread_ptr is a unique number, different from all others in       *
  158.  * USER.BBS.  Although Max uses a somewhat complicated algorithm to        *
  159.  * fill gaps in the user file, most utility programs can just read through *
  160.  * USER.BBS, and keep a running tally of the HIGHEST usr.struct_len        *
  161.  * variable.  Once you have that, increment it by one, and stuff it into   *
  162.  * the usr.struct_len of the user to be added.                             *
  163.  *                                                                         *
  164.  * When DELETING users, you must go through the process of "cleansing"     *
  165.  * the lastread pointers for the user you deleted.  The procedure for this *
  166.  * is simple:  For every area listed in AREAS.CTL, open the LASTREAD.BBS   *
  167.  * file for that area, and seek to the offset...                           *
  168.  *                                                                         *
  169.  *    usr.lastread_ptr*(long)sizeof(int)                                   *
  170.  *                                                                         *
  171.  * ...and write *two* NUL bytes (ASCII 00).                                *
  172.  *                                                                         *
  173.  * Please note that you do NOT need to do anything special to sort the     *
  174.  * user file...  Since the lastread offset is stored in usr.lastread_ptr,  *
  175.  * you can sort the user file with impunity, and even use old Opus 1.03    *
  176.  * sort utilities.                                                         */
  177.  
  178.  
  179.  
  180. /* Masks for usr.bits1, below */
  181.  
  182. #define BITS_HOTKEYS     0x0001 /* Hotkeys, independent of HOTFLASH level   */
  183. #define BITS_NOTAVAIL    0x0002 /* If set, user is NOT normally available   *
  184.                                  * for chat.                                */
  185. #define BITS_FSR         0x0004 /* Full-screen reading in msg areas         */
  186. #define BITS_NERD        0x0008 /* Yelling makes no noise on sysop console  */
  187. #define BITS_NOULIST     0x0010 /* Don't display name in userlist           */
  188. #define BITS_TABS        0x0020 /* Reserved                                 */
  189. #define BITS_BIT6        0x0040 /* Reserved                                 */
  190. #define BITS_BIT7        0x0080 /* Reserved                                 */
  191. #define BITS_BIT8        0x0100 /* Used to be 'usr.msg'                     */
  192. #define BITS_BIT9        0x0200 /* Used to be 'usr.msg'                     */
  193. #define BITS_BITA        0x0400 /* Used to be 'usr.msg'                     */
  194. #define BITS_BITB        0x0800 /* Used to be 'usr.msg'                     */
  195. #define BITS_BITC        0x1000 /* Used to be 'usr.msg'                     */
  196. #define BITS_BITD        0x2000 /* Used to be 'usr.msg'                     */
  197. #define BITS_BITE        0x4000 /* Used to be 'usr.msg'                     */
  198. #define BITS_BITF        0x8000 /* Used to be 'usr.msg'                     */
  199.  
  200.  
  201. /* Masks for usr.bits2, below */
  202.  
  203. #define BITS2_BADLOGON   0x0001 /* MAX: if user's last logon attempt was bad*/
  204. #define BITS2_IBMCHARS   0x0002 /* MAX: if user can receive high-bit chars  */
  205. #define BITS2_RSVD1      0x0004 /* MAX: *obsolete* 1.02 avatar flag         */
  206. #define BITS2_BORED      0x0008 /* Use the line-oriented editor             */
  207. #define BITS2_MORE       0x0010 /* Wants the "MORE?" prompt                 */
  208. #define BITS2_RSVD2      0x0020 /* OPUS: set=wants Ansi                     */
  209. #define BITS2_CONFIGURED 0x0040 /* OPUS: set=used Maximus before            */
  210. #define BITS2_CLS        0x0080 /* OPUS: set=transmit ^L, clear=ignore ^L   */
  211. #define BITS2_BIT8       0x0100 /* used to be 'usr.keys'                    */
  212. #define BITS2_BIT9       0x0200 /* used to be 'usr.keys'                    */
  213. #define BITS2_BITA       0x0400 /* used to be 'usr.keys'                    */
  214. #define BITS2_BITB       0x0800 /* used to be 'usr.keys'                    */
  215. #define BITS2_BITC       0x1000 /* used to be 'usr.keys'                    */
  216. #define BITS2_BITD       0x2000 /* used to be 'usr.keys'                    */
  217. #define BITS2_BITE       0x4000 /* used to be 'usr.keys'                    */
  218. #define BITS2_BITF       0x8000 /* used to be 'usr.keys'                    */
  219.  
  220.  
  221. /* Masks for usr.delflag, below */
  222.  
  223. #define UFLAG_DEL   0x01
  224. #define UFLAG_PERM  0x02
  225.  
  226. /* Masks for usr.xp_flag, below */
  227.  
  228. #define XFLAG_EXPDATE    0x0001 /* Use the xp_date to control access        */
  229. #define XFLAG_EXPMINS    0x0002 /* Use the xp_mins number to control access */
  230. #define XFLAG_DEMOTE     0x0004 /* Demote user to priv level in usr.xp_priv */
  231. #define XFLAG_AXE        0x0008 /* Just hang up on user                     */
  232.  
  233. /* Constants for usr.video, below */
  234.  
  235. #define GRAPH_TTY         0x00 /* The current user's graphics setting...    */
  236. #define GRAPH_ANSI        0x01 
  237. #define GRAPH_AVATAR      0x02
  238.  
  239.  
  240. struct   _usr
  241.    {
  242.       byte name[36];        /* Caller's name                                */
  243.       byte city[36];        /* Caller's location                            */
  244.  
  245.       byte alias[21];       /* MAX: user's alias (handle)                   */
  246.       byte phone[15];       /* MAX: user's phone number                     */
  247.  
  248.       word lastread_ptr;    /* MAX: a num which points to offset in LASTREAD*/
  249.                             /* file -- Offset of lastread pointer will be   */
  250.                             /* lastread_ptr*sizeof(int).                    */
  251.  
  252.       word timeremaining;   /* MAX: time left for current call (xtern prog) */
  253.  
  254.       byte pwd[16];         /* Password                                     */
  255.       word times;           /* Number of previous calls to this system      */
  256.       byte help;            /* Help level                                   */
  257. /**/  byte rsvd1[2];        /* Reserved by Maximus for future use           */
  258.       byte video;           /* user's video mode (see GRAPH_XXXX)           */
  259.       byte nulls;           /* Number of Nulls (delays) after <cr>          */
  260.  
  261.       byte bits;            /* Bit flags for user (number 1)                */
  262.  
  263. /**/  word rsvd2;           /* Reserved by Maximus for future use           */
  264.  
  265.       word bits2;           /* Bit flags for user (number 2)                */
  266.  
  267.       sword priv;           /* Access level                                 */
  268. /**/  byte rsvd3[19];       /* Reserved by Maximus for future use           */
  269.       byte struct_len;      /* len of struct, divided by 20. SEE ABOVE!     */
  270.       word time;            /* Time on-line so far today                    */
  271.  
  272.       word delflag;         /* Used to hold baud rate for O)utside command  */
  273.                             /* In USER.BBS, usr.flag uses the constants     */
  274.                             /* UFLAG_xxx, defined earlier in this file.     */
  275.       
  276. /**/  byte rsvd4[8];        /* Reserved by Maximus for future use           */
  277.  
  278.       byte width;           /* Width of the caller's screen                 */
  279.       byte len;             /* Height of the caller's screen                */
  280.       word credit;          /* Matrix credit, in cents                      */
  281.       word debit;           /* Current matrix debit, in cents               */
  282.  
  283.       word  xp_priv;        /* Priv to demote to, when time or minutes run  */
  284.                             /* out.                                         */
  285.  
  286.       union stamp_combo xp_date;  /* Bit-mapped date of when user expires.  */
  287.                                   /* If zero, then no expiry date.          */
  288.  
  289.       dword xp_mins;        /* How many minutes the user has left before    *
  290.                              * expiring.                                    */
  291.  
  292.       byte  xp_flag;        /* Flags for expiry.  See above XFLAG_XXX defs. */
  293.       byte  xp_rsvd;
  294.  
  295.       union stamp_combo ludate;   /* Bit-mapped date of user's last call    */
  296.  
  297.       dword xkeys;          /* User's keys (all 32 of 'em)                  */
  298.       byte  lang;           /* The user's current language #                */
  299.       sbyte def_proto;      /* Default file-transfer protocol               */
  300.  
  301.       dword up;             /* K-bytes uploaded, all calls                  */
  302.       dword down;           /* K-bytes downloaded, all calls                */
  303.       dword downtoday;      /* K-bytes downloaded, today                    */
  304.       
  305.       byte msg[MAX_ALEN];   /* User's last msg area (string)                */
  306.       byte files[MAX_ALEN]; /* User's last file area (string)               */
  307.  
  308.       byte compress;        /* Default compression program to use           */
  309.  
  310. /**/  byte rsvd5;
  311.       dword extra;
  312.    };
  313.  
  314.  
  315.  
  316.  
  317.