Date: Thu, 30 Apr 87 11:31:26 edt From: David Krowitz Subject: new version of the CKMAIL program for Apollo workstations Here is a slightly modified version of the CKMAIL program which runs correctly under AEGIS version SR9.5. I have included the SR9.2 source as well. The change was necessary because of the difference in the way that arrays are passed to system calls in the new version of the operating system. -- David Krowitz Use /bin/sh to unpack the following shar file ------------------------------------------------------------------------------- #! /bin/sh # This is a shell archive, meaning: # 1. Remove everything above the #! /bin/sh line. # 2. Save the resulting text in a file. # 3. Execute the file with /bin/sh (not csh) to create the files: # ckmail.dir # This archive created: Thu Apr 30 11:26:42 1987 export PATH; PATH=/bin:$PATH if test ! -d 'ckmail.dir' then mkdir 'ckmail.dir' fi cd 'ckmail.dir' if test -f 'ckmail.c' then echo shar: will not over-write existing file "'ckmail.c'" else cat << \SHAR_EOF > 'ckmail.c' /*********************************************************************** * * * University of Utah - Jim Schimpf System Support Code * * Copyright 1986 University of Utah * * * * MAIL CHECK PROGRAM * * * * Module: ckmail.c * * * * Version Date Person Description * *----------------------------------------------------------------------* * 0.1 20-Apr-86 J.Schimpf Initial Version * * 0.2 22-Apr-86 J.Schimpf New Options * * 0.3 30-Jul-86 M.Hucka Added -f option * * * DESCRIPTION: * * This program checks for new mail and if received it * * will inform the user of this change in status * * * * SYNTAX: ckmail [-r []] [-b [S]] [-S] * * * * -r [] - Run the program every * * continuously * * If omitted run every minute * * -b [S] - If present program will create a * * window with messages on mail status * * If not present uses STDOUT * * If S present then pop up windows will * * always appear in the same spot * * (Upper left corner) of screen * * -S - If present and b is not selected then * * stdout will not output NO MAIL MSGS * * -f - Uses as the user's mail file * * instead of the default mail file, * * /usr/spool/mail/. * * * * Procedures: * * * * Written+ Name Description * *----------------------------------------------------------------------* * y get_usr_name() Get the user's name from sid * * y check_mail() Check mailbox status * * y send_window() Send message to created window * * y send_out() Send message to stdout * * * * + (N - no; Y - yes (y - untested); P - partially written) * * * ***********************************************************************/ /********* Include Files ********/ #include #include #include "/sys/ins/base.ins.c" #include "/sys/ins/pad.ins.c" #include "/sys/ins/streams.ins.c" #include #include /********* Program Constants **/ #define TRUE 0xff #define FALSE 0 #define OK 0 #define BAD -1 #define SCREEN_MAX 800 /* Std apollo screen height */ #define MAIL_STAT "~/user_data/mail.stat" /* Prev Mail status */ #define MAIL_FILE "/usr/spool/mail/" /* Default mail spool file append usr name */ #define REPEAT "-r" #define REPEAT_U "-R" #define REPEAT_TM_DEF 60 #define WINDOW_OUT "-b" #define WINDOW_OUT_U "-B" #define WINDOW_STATIC 'S' #define STD_OUT_SILENCE "-S" #define ALT_MAIL_FILE "-f" #define BEEP_TIME_H 0x2 /* ~ 1/4 second */ #define BEEP_TIME_L 0 #define BUF_SZ 256 /*********************************************************************** * * MAIN(ARGS) * * INPUT: Command line arguments * * OUTPUT: Check user mail file * ***********************************************************************/ main(argc,argv) int argc; char *argv[]; { int alt_mail_file = FALSE; /* Use alternate mail file */ int repeat = FALSE; /* Repeat parameters */ int repeat_time = REPEAT_TM_DEF; int window_out = FALSE; /* Output to stdout */ int window_static = FALSE; /* Hold windows in place */ int out_once = FALSE; /* Stdout continuous output */ char *uname,*get_usr_name(); /* File & user id values */ FILE *mstat,*mail,*fopen(); char mail_file[BUF_SZ]; time_t last_time; /* Previous mail values */ int last_size; char in [BUF_SZ]; /* Useful stuff */ int i; int status; /* *** Parse Command line (if none repeat values are set OK). Get repeat and time (if any) Get if we are to use windows */ for( i=1; i SCREEN_MAX ) win_psn_top = 0; } /* Do a TLW window command to the DM to get back */ strcpy(fname,"TLW;TI"); fnsize = strlen(fname); pad_$dm_cmd(window_stream,fname,fnsize,status); /* Close the window so we can re-use it */ stream_$close(window_stream,status); } /*********************************************************************** * * SEND_OUT(out) * * INPUT: out - Message to be sent to user * * OUTPUT: Output with bell to stdout * ***********************************************************************/ send_out(out) char out[]; { time_$clock_t tone_time; /* Beep at the user */ tone_time.high = BEEP_TIME_H; tone_time.low = BEEP_TIME_L; tone_$time( &tone_time ); /* Output the message and a newline */ printf("%s\n",out); } /*********************************************************************** * * MY_TIME(tim) * * INPUT: tim - Pointer to time_t value * * OUTPUT: String with time converted to ASCII with no * ***********************************************************************/ char *my_time(tim) time_t *tim; { char *tim_val; int psn; tim_val = ctime( tim ); /* Now remove the \n at the end of the string */ psn = strlen(tim_val); tim_val[psn-1] = '\0'; return( tim_val ); } SHAR_EOF chmod +x 'ckmail.c' fi # end of overwriting check if test -f 'ckmail.hlp' then echo shar: will not over-write existing file "'ckmail.hlp'" else cat << \SHAR_EOF > 'ckmail.hlp' Name: ckmail - Notify user of mail arrival Keys: mail alarm biff SYNOPSIS ckmail [-r []] [-b [S]] [-S] [-f ] DESCRIPTION This program checks for mail arrival and will notify the user if present. It can be run once and any outstanding mail will be noted. If run in repeat mode it will notify user of mail arrival during his session. Two methods of notification are available, standard out and pop up windows. In the first messages will be printed to the window where it is run. The second method is used when ckmail is run without windows. In this mode when it has a notice it will pop up a small window on the screen. -r [] If present program will run periodically If a number follows it will sleep between runs. If not present the default is 60 seconds. -b [S] If present notifications will be via pop up windows. If not present [DEFAULT] it will output to stdout. If 'S' is present then pop up windows will always appear at the same spot on the screen (top left corner) -S Used with stdout (i.e. -b NOT present) Will output NO message if no mail is present -f Take as the user's mail file. This allows one to specify alternate mail files (such as on other machines). USE These three examples are from startup_dm.19l scripts. In the first the user wishes pop up window notices and mail check every 5 minutes. # Start up mail checker cpo ~/bin/ckmail -n mail_check -r 300 -b In the second, the user wants the same as above, but using the mail file on a remote machine (on utah-cs in this case): # Start up mail checker cpo ~/bin/ckmail -n mail_check -r 300 -b -f /cs/usr/spool/mail/user In the third, the user wants stdout messages in a small dedicated window positioned as shown. Checking is done at the default period of 60 seconds. # Start up mail checker (0115,0000) dr;(0411,0070) cp /com/sh -n mail_check -c '~/bin/ckmail -r' BUGS Won't run in crp'd on window AUTHOR J. Schimpf & M. Hucka FILES ~/user_data/mail.stat - Keeps latest mail status SHAR_EOF chmod +x 'ckmail.hlp' fi # end of overwriting check if test -f 'makefile' then echo shar: will not over-write existing file "'makefile'" else cat << \SHAR_EOF > 'makefile' # # MAKE FILE for ckmail # J.Schimpf # CC = /bin/cc CFLAGS = -g -c OFLAGS = -o SRC = ckmail.c OBJ = ckmail.o HDR = # Main dependency ckmail : $(SRC) $(OBJ) $(HDR) $(CC) $(OFLAGS) ckmail $(OBJ) # Build the parts ckmail.o : ckmail.c $(CC) $(CFLAGS) ckmail.c SHAR_EOF chmod +x 'makefile' fi # end of overwriting check if test -f 'ckmail.install' then echo shar: will not over-write existing file "'ckmail.install'" else cat << \SHAR_EOF > 'ckmail.install' von cpf -du -r -f ckmail //bert/com/ckmail cpf -du -r -f ckmail //ernie/com/ckmail cpf -du -r -f ckmail //tigger/com/ckmail cpf -du -r -f ckmail //bertha/com/ckmail cpf -du -r -f ckmail //piggy/com/ckmail cpf -du -r -f ckmail //winnie/com/ckmail cpf -du -r -f ckmail //oscar/com/ckmail cpf -du -r -f ckmail //eeyore/com/ckmail cpf -du -r -f ckmail //milo/com/ckmail cpf -du -r -f ckmail //opus/com/ckmail cpf -du -r -f ckmail //zeno/com/ckmail cpf -du -r -f ckmail.hlp //bert/sys/help/ckmail.hlp cpf -du -r -f ckmail.hlp //ernie/sys/help/ckmail.hlp cpf -du -r -f ckmail.hlp //tigger/sys/help/ckmail.hlp cpf -du -r -f ckmail.hlp //bertha/sys/help/ckmail.hlp cpf -du -r -f ckmail.hlp //piggy/sys/help/ckmail.hlp cpf -du -r -f ckmail.hlp //winnie/sys/help/ckmail.hlp cpf -du -r -f ckmail.hlp //oscar/sys/help/ckmail.hlp cpf -du -r -f ckmail.hlp //eeyore/sys/help/ckmail.hlp cpf -du -r -f ckmail.hlp //milo/sys/help/ckmail.hlp cpf -du -r -f ckmail.hlp //opus/sys/help/ckmail.hlp cpf -du -r -f ckmail.hlp //zeno/sys/help/ckmail.hlp voff SHAR_EOF chmod +x 'ckmail.install' fi # end of overwriting check if test -f 'ckmail.wbak' then echo shar: will not over-write existing file "'ckmail.wbak'" else cat << \SHAR_EOF > 'ckmail.wbak' von wbak -f 1 -dev f0 ckmail ckmail.hlp ckmail.c ckmail.o makefile voff SHAR_EOF chmod +x 'ckmail.wbak' fi # end of overwriting check if test -f 'ckmail.c_sr9.5' then echo shar: will not over-write existing file "'ckmail.c_sr9.5'" else cat << \SHAR_EOF > 'ckmail.c_sr9.5' /*********************************************************************** * * * University of Utah - Jim Schimpf System Support Code * * Copyright 1986 University of Utah * * * * MAIL CHECK PROGRAM * * * * Module: ckmail.c * * * * Version Date Person Description * *----------------------------------------------------------------------* * 0.1 20-Apr-86 J.Schimpf Initial Version * * 0.2 22-Apr-86 J.Schimpf New Options * * 0.3 30-Jul-86 M.Hucka Added -f option * * * DESCRIPTION: * * This program checks for new mail and if received it * * will inform the user of this change in status * * * * SYNTAX: ckmail [-r []] [-b [S]] [-S] * * * * -r [] - Run the program every * * continuously * * If omitted run every minute * * -b [S] - If present program will create a * * window with messages on mail status * * If not present uses STDOUT * * If S present then pop up windows will * * always appear in the same spot * * (Upper left corner) of screen * * -S - If present and b is not selected then * * stdout will not output NO MAIL MSGS * * -f - Uses as the user's mail file * * instead of the default mail file, * * /usr/spool/mail/. * * * * Procedures: * * * * Written+ Name Description * *----------------------------------------------------------------------* * y get_usr_name() Get the user's name from sid * * y check_mail() Check mailbox status * * y send_window() Send message to created window * * y send_out() Send message to stdout * * * * + (N - no; Y - yes (y - untested); P - partially written) * * * ***********************************************************************/ /********* Include Files ********/ #include #include #include "/sys/ins/base.ins.c" #include "/sys/ins/pad.ins.c" #include "/sys/ins/streams.ins.c" #include #include /********* Program Constants **/ #define TRUE 0xff #define FALSE 0 #define OK 0 #define BAD -1 #define SCREEN_MAX 800 /* Std apollo screen height */ #define MAIL_STAT "~/user_data/mail.stat" /* Prev Mail status */ #define MAIL_FILE "/usr/spool/mail/" /* Default mail spool file append usr name */ #define REPEAT "-r" #define REPEAT_U "-R" #define REPEAT_TM_DEF 60 #define WINDOW_OUT "-b" #define WINDOW_OUT_U "-B" #define WINDOW_STATIC 'S' #define STD_OUT_SILENCE "-S" #define ALT_MAIL_FILE "-f" #define BEEP_TIME_H 0x2 /* ~ 1/4 second */ #define BEEP_TIME_L 0 #define BUF_SZ 256 /*********************************************************************** * * MAIN(ARGS) * * INPUT: Command line arguments * * OUTPUT: Check user mail file * ***********************************************************************/ main(argc,argv) int argc; char *argv[]; { int alt_mail_file = FALSE; /* Use alternate mail file */ int repeat = FALSE; /* Repeat parameters */ int repeat_time = REPEAT_TM_DEF; int window_out = FALSE; /* Output to stdout */ int window_static = FALSE; /* Hold windows in place */ int out_once = FALSE; /* Stdout continuous output */ char *uname,*get_usr_name(); /* File & user id values */ FILE *mstat,*mail,*fopen(); char mail_file[BUF_SZ]; time_t last_time; /* Previous mail values */ int last_size; char in [BUF_SZ]; /* Useful stuff */ int i; int status; /* *** Parse Command line (if none repeat values are set OK). Get repeat and time (if any) Get if we are to use windows */ for( i=1; i SCREEN_MAX ) win_psn_top = 0; } /* Do a TLW window command to the DM to get back */ strcpy(fname,"TLW;TI"); fnsize = strlen(fname); pad_$dm_cmd(window_stream,fname,fnsize,status); /* Close the window so we can re-use it */ stream_$close(window_stream,status); } /*********************************************************************** * * SEND_OUT(out) * * INPUT: out - Message to be sent to user * * OUTPUT: Output with bell to stdout * ***********************************************************************/ send_out(out) char out[]; { time_$clock_t tone_time; /* Beep at the user */ tone_time.high = BEEP_TIME_H; tone_time.low = BEEP_TIME_L; tone_$time( &tone_time ); /* Output the message and a newline */ printf("%s\n",out); } /*********************************************************************** * * MY_TIME(tim) * * INPUT: tim - Pointer to time_t value * * OUTPUT: String with time converted to ASCII with no * ***********************************************************************/ char *my_time(tim) time_t *tim; { char *tim_val; int psn; tim_val = ctime( tim ); /* Now remove the \n at the end of the string */ psn = strlen(tim_val); tim_val[psn-1] = '\0'; return( tim_val ); } SHAR_EOF chmod +x 'ckmail.c_sr9.5' fi # end of overwriting check if test -f 'ckmail.c_sr9.2' then echo shar: will not over-write existing file "'ckmail.c_sr9.2'" else cat << \SHAR_EOF > 'ckmail.c_sr9.2' /*********************************************************************** * * * University of Utah - Jim Schimpf System Support Code * * Copyright 1986 University of Utah * * * * MAIL CHECK PROGRAM * * * * Module: ckmail.c * * * * Version Date Person Description * *----------------------------------------------------------------------* * 0.1 20-Apr-86 J.Schimpf Initial Version * * 0.2 22-Apr-86 J.Schimpf New Options * * 0.3 30-Jul-86 M.Hucka Added -f option * * * DESCRIPTION: * * This program checks for new mail and if received it * * will inform the user of this change in status * * * * SYNTAX: ckmail [-r []] [-b [S]] [-S] * * * * -r [] - Run the program every * * continuously * * If omitted run every minute * * -b [S] - If present program will create a * * window with messages on mail status * * If not present uses STDOUT * * If S present then pop up windows will * * always appear in the same spot * * (Upper left corner) of screen * * -S - If present and b is not selected then * * stdout will not output NO MAIL MSGS * * -f - Uses as the user's mail file * * instead of the default mail file, * * /usr/spool/mail/. * * * * Procedures: * * * * Written+ Name Description * *----------------------------------------------------------------------* * y get_usr_name() Get the user's name from sid * * y check_mail() Check mailbox status * * y send_window() Send message to created window * * y send_out() Send message to stdout * * * * + (N - no; Y - yes (y - untested); P - partially written) * * * ***********************************************************************/ /********* Include Files ********/ #include #include #include "/sys/ins/base.ins.c" #include "/sys/ins/pad.ins.c" #include "/sys/ins/streams.ins.c" #include #include /********* Program Constants **/ #define TRUE 0xff #define FALSE 0 #define OK 0 #define BAD -1 #define SCREEN_MAX 800 /* Std apollo screen height */ #define MAIL_STAT "~/user_data/mail.stat" /* Prev Mail status */ #define MAIL_FILE "/usr/spool/mail/" /* Default mail spool file append usr name */ #define REPEAT "-r" #define REPEAT_U "-R" #define REPEAT_TM_DEF 60 #define WINDOW_OUT "-b" #define WINDOW_OUT_U "-B" #define WINDOW_STATIC 'S' #define STD_OUT_SILENCE "-S" #define ALT_MAIL_FILE "-f" #define BEEP_TIME_H 0x2 /* ~ 1/4 second */ #define BEEP_TIME_L 0 #define BUF_SZ 256 /*********************************************************************** * * MAIN(ARGS) * * INPUT: Command line arguments * * OUTPUT: Check user mail file * ***********************************************************************/ main(argc,argv) int argc; char *argv[]; { int alt_mail_file = FALSE; /* Use alternate mail file */ int repeat = FALSE; /* Repeat parameters */ int repeat_time = REPEAT_TM_DEF; int window_out = FALSE; /* Output to stdout */ int window_static = FALSE; /* Hold windows in place */ int out_once = FALSE; /* Stdout continuous output */ char *uname,*get_usr_name(); /* File & user id values */ FILE *mstat,*mail,*fopen(); char mail_file[BUF_SZ]; time_t last_time; /* Previous mail values */ int last_size; char in [BUF_SZ]; /* Useful stuff */ int i; int status; /* *** Parse Command line (if none repeat values are set OK). Get repeat and time (if any) Get if we are to use windows */ for( i=1; i SCREEN_MAX ) win_psn_top = 0; } /* Do a TLW window command to the DM to get back */ strcpy(fname,"TLW;TI"); fnsize = strlen(fname); pad_$dm_cmd(window_stream,fname,fnsize,status); /* Close the window so we can re-use it */ stream_$close(window_stream,status); } /*********************************************************************** * * SEND_OUT(out) * * INPUT: out - Message to be sent to user * * OUTPUT: Output with bell to stdout * ***********************************************************************/ send_out(out) char out[]; { time_$clock_t tone_time; /* Beep at the user */ tone_time.high = BEEP_TIME_H; tone_time.low = BEEP_TIME_L; tone_$time( &tone_time ); /* Output the message and a newline */ printf("%s\n",out); } /*********************************************************************** * * MY_TIME(tim) * * INPUT: tim - Pointer to time_t value * * OUTPUT: String with time converted to ASCII with no * ***********************************************************************/ char *my_time(tim) time_t *tim; { char *tim_val; int psn; tim_val = ctime( tim ); /* Now remove the \n at the end of the string */ psn = strlen(tim_val); tim_val[psn-1] = '\0'; return( tim_val ); } SHAR_EOF chmod +x 'ckmail.c_sr9.2' fi # end of overwriting check cd .. # End of shell archive exit 0