home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / TPDOOR.ZIP / DOORLOGR.INC < prev   
Encoding:
Text File  |  1986-10-15  |  8.4 KB  |  209 lines

  1. {----------------------------------------------------------------------}
  2. {                                                                      }
  3. { Library:    DOORLOGR.INC                                             }
  4. { Purpose:    RBBS-PC DOORS Application Program Usage Logging Library  }
  5. { Language:   Borland Turbo Pascal Version 3.00                        }
  6. {                                                                      }
  7. { Author:     Richard L. Tremmel, GTE/Florida                          }
  8. {             General Service - Electronic Operations Support          }
  9. {             610 Zack St. MC-20, Tampa, FL 33601  Voice: 813-224-7127 }
  10. {             GTE Telenet: GTFL.EOS or contact me on the following:    }
  11. {             SUNSHINE RBBS 813-887-3984 or TAMIAMI RBBS 813-793-2392  }
  12. {                                                                      }
  13. { Notice:     This library is placed in the public domain and may be   }
  14. {             freely used by anyone for any purpose.  When using this  }
  15. {             code, please give credit to the original author and to   }
  16. {             anyone who has subsequently improved or modified it.     }
  17. {                                                                      }
  18. { History:    Version 1.00, 08/30/85 - Original by Richard L. Tremmel  }
  19. {                                                                      }
  20. { Narrative:  This Turbo Pascal include library provides a means of    }
  21. {             logging the usage and activity of RBBS-PC "Doors"        }
  22. {             application programs.  Generalized logon and logoff pro- }
  23. {             cedures are included along with a routine to log any     }
  24. {             messages passed from the application program to the log  }
  25. {             file.                                                    }
  26. {                                                                      }
  27. { Required:   The DOORLOGR.INC library requires the DOORIO.INC and     }
  28. {             DATETIME.INC libraries to be previously "included".      }
  29. {                                                                      }
  30. {             The DOORLOGR.INC library requires the following type     }
  31. {             definition:                                              }
  32. {                                                                      }
  33. {                 STRING60 : string[60]; (used for log file messages)  }
  34. {                                                                      }
  35. {             The DOORLOG.INC library requires the following variables }
  36. {             or constants to be defined:                              }
  37. {                                                                      }
  38. {                 PNAM      : string  (application program name)       }
  39. {                                                                      }
  40. {                 PVER      : string  (application program version)    }
  41. {                                                                      }
  42. {                 PORTN     : integer (async port number to use)       }
  43. {                                                                      }
  44. {                 TIMELIMIT : integer (input time-out in seconds)      }
  45. {                                                                      }
  46. {----------------------------------------------------------------------}
  47.  
  48. const
  49.     RBBSNAME         = 'System-SIX';                {RBBS-PC Name      }
  50.     LOGFILENAME      = 'C:\SIX\DOORS\RBBSDOOR.LOG'; {Door log file name}
  51.     MESSAGESFILENAME = 'C:\SIX\MESSAGES';           {RBBS-PC MESSAGES  }
  52.                                                     {file name         }
  53.  
  54. {.PA}
  55. {This procedure is used internally by the DOORLOGR.INC library to get  }
  56. {the name of the last logged on user and the status of the printer.    }
  57. {NOTE - this routine assumes only a single user RBBS system (only one  }
  58. {node.  I will leave it up to someone else to hassle with multiple     }
  59. {node RBBS's.                                                          }
  60.  
  61. procedure GETDOORUSER(var DOORUSER:STRING60; var PRINTER:boolean);
  62.  
  63. type
  64.     MESSAGESTYPE     = array [1..128] of char;
  65.  
  66. var
  67.     MESSAGESFILE     : file of MESSAGESTYPE;
  68.     MESSAGESREC      : MESSAGESTYPE;
  69.  
  70. begin {GETDOORUSER}
  71.  
  72.   assign(MESSAGESFILE,MESSAGESFILENAME);
  73.   {$I-} reset(MESSAGESFILE);            {$I+}
  74.   {$I-} seek(MESSAGESFILE,1);           {$I+} {skip checkpoint record}
  75.   {$I-} read(MESSAGESFILE,MESSAGESREC); {$I+} {get node record #1}
  76.   PRINTER := false;
  77.   if ioresult = 0
  78.     then
  79.       begin
  80.         if copy(MESSAGESREC,38,2) = '-1'
  81.           then
  82.             PRINTER := true;
  83.         DOORUSER := MESSAGESREC;
  84.         DOORUSER[0] := chr(31) {force string length to 31}
  85.       end
  86.     else
  87.       DOORUSER := 'Error Reading '+MESSAGESFILENAME;
  88.   close(MESSAGESFILE)
  89. end; {GETDOORUSER}
  90. {.PA}
  91. {This procedure will write a 'LOGINFO' message along with date and time}
  92. {stamp to the door log file and also echo the message to the line      }
  93. {printer if it is on-line per RBBS (LPT flag).  If the Door log file   }
  94. {does not exist, it will be created.                                   }
  95.  
  96. procedure LOGDOOR(LOGINFO:STRING60);
  97.  
  98. const
  99.     LOGGEDIN    : boolean = false;
  100.     PRINTERON   : boolean = false;
  101.  
  102. var
  103.     LOGFILE     : text;
  104.     DATE,TIME   : STRING8;
  105.     DOORUSER    : STRING60;
  106.  
  107. begin {LOGDOOR}
  108.   DATETIME(DATE,TIME);
  109.   if not LOGGEDIN
  110.     then
  111.       GETDOORUSER(DOORUSER,PRINTERON);
  112.   assign(LOGFILE,LOGFILENAME);
  113.   {$I-} append(LOGFILE); {$I+}
  114.   if ioresult <> 0
  115.     then
  116.       begin
  117.         rewrite(LOGFILE);
  118.         write  (LOGFILE,DATE,' @ ',TIME);
  119.         writeln(LOGFILE,' Log File ',LOGFILENAME,' Initialized');
  120.         if PRINTERON
  121.           then
  122.             writeln(lst,' ':8,'Log File ',LOGFILENAME,' Initialized')
  123.       end;
  124.   if not LOGGEDIN
  125.     then
  126.       begin
  127.         write  (LOGFILE,DATE,' @ ',TIME,' ',PNAM,' ',PVER);
  128.         writeln(LOGFILE,' run by ',DOORUSER);
  129.         LOGGEDIN := true;
  130.         if PRINTERON
  131.           then
  132.             writeln(lst,' ':8,PNAM,' ',PVER,' run by ',DOORUSER)
  133.       end;
  134.   if length(LOGINFO) > 0
  135.     then
  136.       begin
  137.         writeln(LOGFILE,' ':11,TIME,' ',LOGINFO);
  138.         if PRINTERON
  139.           then
  140.             writeln(lst,' ':8,LOGINFO)
  141.       end;
  142.   close(LOGFILE)
  143. end; {LOGDOOR}
  144. {.PA}
  145. {This procedure is a simple Door application logon routine to issue an }
  146. {initial welcome message to the user and write a message to the log    }
  147. {file indicating the name, version, and time the application program   }
  148. {started running.  It also provides the user with some basic program   }
  149. {information.                                                          }
  150.  
  151. procedure LOGON(LOGINFO:STRING60);
  152.  
  153. var
  154.     LOGONTEMP : string[2];
  155.  
  156. begin {LOGON}
  157.   LOGDOOR('');
  158.   COLN('');
  159.   COLN(PNAM+' '+PVER);
  160.   str(TIMELIMIT div 60:2,LOGONTEMP);
  161.   COLN('');
  162.   COLN('Input time-out set to '+LOGONTEMP+' minutes.');
  163.   COLN('Hit BackSpace to delete previous character.');
  164.   COLN('Hit Control-X to cancel current input line.');
  165.   if ABORTABLE
  166.     then
  167.       COLN('Hit Control-C to abort program.');
  168.   COLN('');
  169.   COLN(LOGINFO)
  170. end; {LOGON}
  171. {.PA}
  172. {This procedure is a simple Door application logoff routine to issue a }
  173. {message to the log file to indicate the program has terminated and    }
  174. {additionally will force a line disconnect or return to the RBBS at the}
  175. {user's option.                                                        }
  176.  
  177. procedure LOGOFF;
  178.  
  179. const
  180.     COM_RESET_MASK                    = $04;           {reset modem    }
  181.     COM_ENABLE_MASK                   = $01;           {enable modem   }
  182.     COM_MCR : array [1..2] of integer = ($03FC,$02FC); {modem control  }
  183.  
  184. var
  185.     LOGOFFTEMP : LINETYPE;
  186.  
  187. begin {LOGOFF}
  188.   COLN('');
  189.   COLN(PNAM+' Done.');
  190.   COLN('');
  191.   COL ('Do you want to return to '+RBBSNAME+' (Y/N) ? ');
  192.   CILN(LOGOFFTEMP);
  193.   COLN('');
  194.   if upcase(LOGOFFTEMP[1]) <> 'Y'
  195.     then
  196.       begin
  197.         COLN('Good-bye.');
  198.         COLN('');
  199.         port[COM_MCR[PORTN]] := $04; {reset Smartmodem - drop data link}
  200.         delay(1000);                 {wait 1 second}
  201.         port[COM_MCR[PORTN]] := $01; {enable Smartmodem}
  202.         LOGDOOR('Normal Program Termination - User Logged Off');
  203.         halt
  204.       end;
  205.   COLN('Returning to '+RBBSNAME+', please wait...');
  206.   COLN('');
  207.   LOGDOOR('Normal Program Termination - Returned to '+RBBSNAME)
  208. end; {LOGOFF}
  209.