home *** CD-ROM | disk | FTP | other *** search
Wrap
/* LOGDISP.C Novell Utility Purpose: Program to Display a File if a certain amount of time has passed since the last login. Usage - To limit system information/news files to once a day displays Input - 1st Parameter is time passed in minutes 2nd Parameter is file spec of file to be displayed 3rd Parameter is optional wait time after display Output- Will display text file if time duration has passed or file date is newer than the last login date. * Author - Wm Stackpole, Code 114.4, Puget Sound Naval Shipyard for the public domain * Date - 08/29/90 * Written in MSC v5.1 * Requires Novell Netware C Interface-DOS * Command line: cl /AM logdisp.c /link MNIT.LIB */ /* Portions of this code are the copyrighted property of William Stackpole and Precision Data Consultants. Used with permission. */ /* Update Log */ /* v1.1 Creates LST$LOG.DAT file because LAST_LOGIN property couldn't be used */ /* Added -n No Update option for LST$LOG.DAT file */ /* Notes Suggested Parameters -cNN Number of columns for word wrap -lNN Number of lines for pause */ #include <stdio.h> #include <ctype.h> #include <dos.h> #include <string.h> #include <nit.h> #include <niterror.h> #include <time.h> #include <conio.h> #include <bios.h> #include <sys/types.h> #include <sys/stat.h> #define inc "Puget Sound Naval Shipyard, Wm Stackpole, 1990" #define prg "LOGDISP" #define ver "1.1" #define FALSE 0 #define TRUE 1 #define DEBUG FALSE #define MAXDUR 32768 /* Maximum duration 3+ weeks */ union REGS Regs; struct SREGS Segs; /* Prototype functions */ int NAttach(void); /* See if user is attached to Novell network */ void Help(void); /* Display help */ long int DateToMinutes(int,int,int,int,int); /*Convert date to minutes */ int WaitOne(int); /* Pause with a timeout */ int IsOption(char*); /*Test of argv option */ void ErrExit(int,int); /*Exit with Error Message */ void ExitThisPrgm(int); /*Exit with Error Code */ void DisplayFile(FILE*,int,int); /*Display a file with word wrap and page pause */ /* Global variables */ char *HelpMess[] ={ "-Display a file if a certain amount of time has passed", "since the user's last login.", " Usage: LOGDISP [nnn] [d:][\\path\\]filename.ext [-w[tt]] [-n]", "Where nnn is the time to have passed in minutes (Default is 240)", "d: is the drive letter or volume name, \\path\\ is the directory", "path and filename.ext is the name of the text file, -n prevents", "login time update, -w is a program pause of 20 seconds (or key press)", "and tt is an optional pause time in seconds (0 = wait for key press).", "Returns ERRORLEVEL 1 for fatal errors.", inc, }; int HelpLen=10; char *ErrorMess[]={ "Unknown option.", "Bad or missing command line parameter.", "Invalid time parameter (1-32768).", "Opening display file.", "Bad or missing file specification.", "Opening LST$LOG.DAT file.", "Reading LST$LOG.DAT file.", "Writing LST$LOG.DAT file.", }; int ErrLen=8; int completionCode; BYTE securityAccessLevel; long objectID; char objectName[48]; WORD objectType; char propertyName[16]; int segmentNumber=1; BYTE propertyValue[128]; BYTE moreSegments; BYTE propertyFlags; main(argc,argv) int argc; char *argv[]; { int haveDuration=FALSE; int haveFileName=FALSE; int duration=240; int updateLog=TRUE; long int currentTime, lastLogTime=0; int i; FILE *fp; char dateAndTime[7]; char ans[8]; static char fileName[128]="\0"; static char filePath[128]="\0"; char c; struct stat buf; int fh, result; struct tm *newtime; int waitTime=-1; int pageWidth=-1; int pageLength=-1; /* Parse the arguments */ if(argc<2) Help(); for(i=1;i<argc;i++) /* Scan each arguement for for ; ntsntsnthe nthe nt╣╣╣th weco"P/ tNace ace acAAAhahah32323S lpd PaExi; st; st;DUDUD╘ogLSLSLpagepageps lpolinussL E E e,e,e MC vi;i;i l diooutoutokskskRUE */ */ C C C╠udeφφφLengLengL", ve ve v*/ i*/ */ *strustrus] [gs;gs;gMiMiM.cÉios in in 99RU27; i; i;e <se <sethe ntthe ntt─de <nman. *. *.eys.h>mmion.ion.ifine fine fupdMi /objHn'n'ninc,inc,idateAdateAd I I .cdateek d d ╙de <bafd wrd wrdstrustrus7687687isiisiid Nd Ndpagpagpten ten j s."s."sfpfpfermstrusstrussedudes[p ,1 s."s s