home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / TPTOOL3.ZIP / LOOKUSER.INC < prev    next >
Encoding:
Text File  |  1987-04-26  |  2.5 KB  |  106 lines

  1.  
  2. (*
  3.  * lookuser.inc - lookup complete information for current user under GT-host
  4.  *
  5.  * For use with GT PowerComm 12.xx HOST-MODE.
  6.  *
  7.  * S.H.Smith, 6-apr-87 (rev. 26-apr-87)
  8.  *
  9.  * This program is provided courtesy of:
  10.  *         The Tool Shop
  11.  *         Phoenix, Az
  12.  *         (602) 279-2673
  13.  *
  14.  * This program uses many of the building-blocks in the Tool Shop Library,
  15.  * which is available for download from the Tool Shop.   Compile using
  16.  * TSHELL 1.1, also avaliable from the Tool Shop.
  17.  *
  18.  *)
  19.  
  20. (* layout of the user control file records for gt12.10 *)
  21.  
  22. type
  23.    user_record = record
  24.       dead:          boolean;
  25.       name:          string[30];
  26.       lastread:      integer;
  27.       date:          string[10];
  28.       time:          string[10];
  29.       total_calls:   integer;
  30.       banned:        boolean;
  31.       xpert:         boolean;
  32.       nonstp:        boolean;
  33.       city:          string[30];
  34.       passwd:        string[20];
  35.       phone:         string[10];
  36.       level:         char;
  37.       calls:         integer;
  38.       m3:            byte;
  39.    end;
  40.  
  41. var
  42.    user:  user_record;
  43.  
  44.  
  45.  
  46. procedure lookup_user_info;
  47.    {lookup information for currently logged user; sets 'user' fields
  48.     according to the best information available.
  49.     call get_maildir_list first}
  50. var
  51.    user_name:  anystring;
  52.    fname:      anystring;
  53.    fd:         text;
  54.    ctlfd:      file of user_record;
  55.  
  56. begin
  57.    writeln(con,'Loading user information');
  58.  
  59.    user.name := 'Unknown';
  60.    user.level := 'Z';
  61.  
  62.    fname := locate_file_env('gtuser.bbs','GTPATH=');
  63.    if exists(fname)=false then
  64.    begin
  65.       writeln(con,whoami,': Missing file: ',fname);
  66.       writeln(con,'Check setting of GTPATH environment.');
  67.       exit;
  68.    end;
  69.  
  70.    assign(fd,fname);
  71.    reset(fd);
  72.    readln(fd,user_name);
  73.    user_name := copy(user_name,3,99);
  74.    close(fd);
  75.  
  76.    writeln('Welcome, ',user_name);
  77.    flush(output);
  78.  
  79.    fname := maildir[1]+'gtmail.ctl';
  80.    if exists(fname)=false then
  81.    begin
  82.       writeln(con,whoami,': Missing file: ',fname);
  83.       writeln(con,'Check setting of GTPATH environment.');
  84.       exit;
  85.    end;
  86.  
  87.    assign(ctlfd,fname);
  88.    reset(ctlfd);
  89.    read(ctlfd,user);
  90.  
  91.    while not eof(ctlfd) do
  92.    begin
  93.        read(ctlfd,user);
  94.  
  95.        if user.name = user_name then
  96.        begin
  97.           close(ctlfd);
  98.           exit;
  99.        end;
  100.    end;
  101.  
  102.    close(ctlfd);
  103.    writeln(con,whoami,': Can''t find "',user_name,'" in control file ',fname);
  104. end;
  105.  
  106.