rs - a personal reminder system
Don Joslyn
don at novavax.UUCP
Fri Jul 4 06:04:34 AEST 1986
rs is a personal reminder system.
Enjoy,
-------------------
Don Joslyn, Manager
Nova University, Computer Center, Fort Lauderdale, FL
UUCP: ...{codas|ucf-cs|allegra|usfvax2}!novavax!don
-----Cut Here-----
#! /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:
# rs.man
# README
# Makefile
# rs.c
# rs.1
# This archive created: Thu Jul 3 15:58:03 1986
# By: Don Joslyn (Nova University, Fort Lauderdale, Florida)
export PATH; PATH=/bin:/usr/bin:$PATH
echo shar: "extracting 'rs.man'" '(6439 characters)'
if test -f 'rs.man'
then
echo shar: "will not over-write existing file 'rs.man'"
else
sed 's/^XX//' << \SHAR_EOF > 'rs.man'
XX
XX
XX
XXRS(1) UNIX Programmer's Manual RS(1)
XX
XX
XX
XXNAME
XX rs - reminder system
XX
XXSYNOPSIS
XX rs [ -Aacknpv ] [ -s string ] [ -d # #-# ]
XX
XXDESCRIPTION
XX rs is a personal reminder system. Reminders can be
XX displayed every time you log into the system by placing the
XX rs command in your .login or .profile file. The reminder
XX system includes three reminder files:
XX
XX
XX 1. Reminders ($HOME/.reminders)
XX 2. Notes ($HOME/.rsnotes)
XX 3. User defined by setting the RSALT environment variable.
XX (Defaults to $HOME/.phone_numbers)
XX
XX Options:
XX
XX rs With no options, print reminder list to terminal.
XX
XX -A Work with alternate reminder file. The name of the
XX alternate file is user defined by setting the RSALT
XX environment variable. (If RSALT is not set, the alter-
XX nate file defaults to 'phone_numbers'.)
XX
XX -a Add reminders/notes/alternates. You are prompted to
XX add reminders/notes/alternates. Appending a ^G
XX (Control-G) at the end of a reminder will cause rs to
XX mark it (Highlight) during display. (See RSINIT
XX below.)
XX
XX -c Add entries to calendar system. You are prompted to
XX add calendar entries. See calendar(1).
XX
XX -d Delete reminders/notes/alternates. This option, fol-
XX lowed by a number or numbers, causes rs to delete the
XX specified reminders/notes/alternates. More than one
XX number may be placed on the same command line separated
XX by blanks. A range of numbers may also be specified.
XX
XX -e Edit reminders/notes/alternates file. If the EDITOR
XX environment variable is set, the specified EDITOR is
XX used. If not, vi is used by default. (-v may be used
XX in place of -e)
XX
XX -k Kill (delete) all reminders/notes/alternates.
XX
XX -n Work on notes file.
XX
XX -p Print reminders/notes/alternates. (By default, does an
XX
XX
XX
XXPrinted 7/3/86 3 July 1986 1
XX
XX
XX
XX
XX
XX
XXRS(1) UNIX Programmer's Manual RS(1)
XX
XX
XX
XX lpr of reminder file.)
XX
XX -s Search for reminders/notes/alternates that match the
XX given string.
XX
XX More than one option may follow a single "-", for example:
XX
XX rs -na The command for "add note."
XX
XXNOTES
XX To mark a reminder (Highlight), append a ^G (Control-G) to
XX the reminder. rs will mark the reminder during display
XX using one of the following:
XX
XX
XX Standout
XX Underscore.
XX Bold
XX Asterisk
XX
XX as defined in RSINIT.
XX
XX rs looks in the environment variable RSINIT for additional
XX configuration options. Options are:
XX
XX
XX A Display notes/alternates/calendar after additions.
XX D Display notes/alternates/calendar after deletions.
XX a Display reminders after additions.
XX d Display reminders after deletions.
XX I Ignore TERMCAP info during startup.
XX (Default number of columns is 80, no mark capability)
XX
XX Default mark is standout mode.
XX ('so' and 'se' must be defined in termcap entry.)
XX
XX U Use underscore (underline) to mark reminders.
XX ('us' and 'ue' must be defined in termcap entry.)
XX B Use Bold to mark reminders.
XX ('bo' and 'be' must be defined in termcap entry.)
XX S Use '*' to mark reminders.
XX (Terminal must have 'bs'.)
XX
XX For example, if you prefer to view your
XX reminders/notes/alternates after additions/deletions, the
XX csh command:
XX
XX
XX setenv RSINIT 'aAdD'
XX
XX causes rs to display your reminders/notes/alternates after
XX additions/deletions. The above command sequence may be
XX
XX
XX
XXPrinted 7/3/86 3 July 1986 2
XX
XX
XX
XX
XX
XX
XXRS(1) UNIX Programmer's Manual RS(1)
XX
XX
XX
XX placed in your .login file.
XX
XX Reminders/notes/alternates may be from one to 255 characters
XX long. If a reminder is longer than one line (As defined in
XX termcap 'co'), rs does automatic word wrap. To add a
XX reminder/note/alternate longer than one line, type in the
XX entire reminder/note/alternate and end with a single car-
XX riage return. Do not insert carriage returns before the end
XX of a reminder/note/alternate. A single carriage return
XX always indicates the end of a reminder.
XX
XXEXAMPLES
XX rs -d 1 5 8
XX Delete reminders 1, 5, 8.
XX
XX rs -n -d 1-5 8
XX Delete notes 1, 2, 3, 4, 5, 8.
XX
XX rs -k
XX Kill all reminders.
XX
XXEXAMPLE USE OF ALTERNATE REMINDER FILE
XX If you would like to have a list of phone numbers that can
XX be accessed by the reminder system, you can do the follow-
XX ing:
XX
XX Set the RSALT environment variable to phone-numbers by
XX including the following command line in your .login file:
XX
XX setenv RSALT 'phone-numbers'
XX
XX Use the reminder system command:
XX
XX rs -A [options]
XX
XX to work on the phone-numbers reminder file.
XX
XXEXAMPLE COMMANDS FOR PHONE-NUMBERS REMINDER FILE
XX rs -A -a
XX Add phone numbers to the phone-numbers reminder file.
XX
XX rs -A -s Joslyn
XX Search for Joslyn's phone number.
XX
XX rs -A -e
XX Edit phone-numbers.
XX
XX rs -A -p
XX Print phone-numbers on the line printer.
XX
XX rs -A -d 1
XX Delete the first line from phone-numbers.
XX
XX
XX
XXPrinted 7/3/86 3 July 1986 3
XX
XX
XX
XX
XX
XX
XXRS(1) UNIX Programmer's Manual RS(1)
XX
XX
XX
XXTIPS
XX To make use of the notes/alternates easier, the author
XX defines two aliases:
XX
XX alias rsn 'rs -n' Use rsn to work with notes file.
XX alias rsa 'rs -A' Use rsa to work with alternate file.
XX
XXFILES
XX $HOME/.reminders User's reminders.
XX $HOME/.rsnotes User's notes.
XX /tmp/.rs* Used during reminder deletion.
XX $HOME/.? Other reminder file(s) defined by RSALT.
XX
XXSEE ALSO
XX calendar(1), csh(1), environ(7), lpr(1), vi(1)
XX
XXAUTHOR
XX Don Joslyn, Manager
XX Nova University Computer Center
XX 3301 College Avenue
XX Fort Lauderdale, Florida 33314
XX (305) 475-7678
XX {codas, allegra, ucf-cs}!novavax!don
XX
XXPrinted 7/3/86 3 July 1986 4
SHAR_EOF
if test 6439 -ne "`wc -c < 'rs.man'`"
then
echo shar: "error transmitting 'rs.man'" '(should have been 6439 characters)'
fi
fi
echo shar: "extracting 'README'" '(1568 characters)'
if test -f 'README'
then
echo shar: "will not over-write existing file 'README'"
else
sed 's/^XX//' << \SHAR_EOF > 'README'
XXrs - a reminder system, by:
XX
XX Don Joslyn, Manager
XX Nova University Computer Center
XX 3301 College Avenue
XX Fort Lauderdale, Florida 33314
XX (305) 475-7678
XX ...{codas, allegra, ucf-cs}!novavax!don
XX
XXThis directory contains the source and manual entry for the rs program.
XXSee the manual entry for more information on the use of rs.
XX
XXTo Install:
XX
XX1) Look at rs.c and change any #defines needed.
XX Defaults:
XX
XX CALENDAR "/calendar" users calendar file.
XX RSFILE "/.reminders" users reminder file.
XX RSNOTES "/.rsnotes" users notes file.
XX
XX LPR "/usr/ucb/lpr" location of lpr command.
XX EDITOR "/usr/ucb/vi" default editor.
XX
XX MAXLINES 500 Max. number of lines (reminders)
XX MAXLEN 256 Max. len of a single line.
XX
XX If your /tmp directory is somewhere else, change rstmp.
XX Default: char rstmp[] = "/tmp/rsXXXXX"
XX
XX2) Edit the Makefile.
XX
XX Change target directory for the rs executable and manual entry
XX if you wish.
XX
XX Defaults:
XX
XX DEST = /usr/local rs program >> /usr/local
XX MDEST = /usr/man/manl rs manual >> /usr/man/manl
XX
XX If you have something other than termcap, make the change to LIBS.
XX
XX If you are not a BSD site, take '-DBSD' out of the Makefile so that
XX strnchr and <string.h> will be used in place of rindex and <strings.h>
XX
XX3) Run 'make install' which will make and install the executables and the
XX manual entries.
XX If you want to compile the rs program in the current directory,
XX run 'make program'.
XX
XX------------------
XXMail questions to:
XX
XX ...{codas, allegra, ucf-cs}!novavax!don
XX
XXThe main purpose of the rs command, is to make remembering easy!
SHAR_EOF
if test 1568 -ne "`wc -c < 'README'`"
then
echo shar: "error transmitting 'README'" '(should have been 1568 characters)'
fi
fi
echo shar: "extracting 'Makefile'" '(513 characters)'
if test -f 'Makefile'
then
echo shar: "will not over-write existing file 'Makefile'"
else
sed 's/^XX//' << \SHAR_EOF > 'Makefile'
XXDEST = /usr/local
XX
XXMDEST = /usr/man/manl/rs.l
XX
XXLDFLAGS = -DBSD -O -w
XX
XXLIBS = -ltermcap
XX
XXLINKER = cc
XX
XXMANUAL = rs.1
XX
XXPROGRAM = rs
XX
XXSRCS = rs.c
XX
XXall: $(PROGRAM)
XX
XX$(PROGRAM):
XX @echo -n "Loading rs ..."
XX @$(LINKER) $(LDFLAGS) $(SRCS) $(LIBS) -o $(PROGRAM)
XX @echo "done."
XX
XXinstall: $(PROGRAM)
XX @echo Installing $(PROGRAM) in $(DEST)
XX @install -s $(PROGRAM) $(DEST)
XX @echo Installing manual in $(MDEST)
XX @cp $(MANUAL) $(MDEST)
XX
XXprogram: $(PROGRAM)
SHAR_EOF
if test 513 -ne "`wc -c < 'Makefile'`"
then
echo shar: "error transmitting 'Makefile'" '(should have been 513 characters)'
fi
fi
echo shar: "extracting 'rs.c'" '(13652 characters)'
if test -f 'rs.c'
then
echo shar: "will not over-write existing file 'rs.c'"
else
sed 's/^XX//' << \SHAR_EOF > 'rs.c'
XXstatic char rcsid[] = "$Header: rs.c,v 3.3 86/07/03 14:24:34 don Exp $";
XX
XX/* $Log: rs.c,v $
XX * Revision 3.3 86/07/03 14:24:34 don
XX * 1. MAX_LINE (# columns on a line) now defined by termcap entry for TERM.
XX * 2. Misc. Optimizations.
XX * 3. Reminders can now be "marked", by appending ^G to reminder, to have
XX * reminder highlighted during display. "Highlight" options can be defined
XX * in the RSINIT environment variable.
XX * U - Underscore, B - Bold, S - Asterisk. (Default is standout)
XX * I - Ignore termcap entry.
XX *
XX * Revision 3.2 85/08/26 14:55:42 don
XX * Adding Mike's enhancements. Thanks Mike! :-)
XX * Revision 3.2 & 3.3 by Mike Spitzer @ (pur-ee!mjs)
XX *
XX * Revision 3.2 85/08/05 13:10:52 mjs
XX * -added new print_line which doesn't barf on long words
XX * -added #define for place to break up lines(MAX_LINE)
XX * -print_line is always called now, test for strlen(line) < MAX_LINE
XX * is now made there.
XX *
XX * MIke Spitzer
XX * pur-ee!mjs
XX *
XX * Revision 3.1 85/07/26 20:48:06 mjs
XX * "rs" now recognizes the $EDITOR variable. "vi" will be used if
XX * $EDITOR is undefined.
XX *
XX * added "-e" flag... does the same thing as "-v"
XX *
XX * -mjs
XX *
XX * Revision 2.2 85/02/25 10:35:48 don
XX * 1. Optimized kill and line wrap routines.
XX * 2. Added defines for LPR & VI.
XX * 3. Added more RSINIT options. (A & D)
XX * 4. Deleted add_calendar routine, now uses add_reminders.
XX * 5. Added comments.
XX *
XX * Revision 2.1 85/01/28 17:03:56 don
XX * 1. Added new notes file - .rsnotes | command rs -n
XX * 2. Added new alternate file - user defined via setenv RSALT | command rs -A
XX * 3. Added environment variable RSINIT.
XX * setenv RSINIT 'ad' | a = display after add | d = display after delete.
XX * 4. Lines may now be 256 char. long.
XX * 5. Long lines will automatically wrap like 'vi'.
XX * 6. Added search command. | rs -s 'search string'
XX * 7. Help deleted, replaced with 'usage' message.
XX * 8. Misc. optimizations.
XX *
XX * Revision 1.3 85/01/15 09:17:57 don
XX * 1. Added $Log line for RCS.
XX * 2. Fixed help message.
XX * 3. Coded in range deletion.
XX * */
XX
XX/* Program written by: Don Joslyn
XX * Nova University Computer Center
XX * 3301 College Avenue
XX * Fort Lauderdale, Florida 33314
XX * (305) 475-7630 (novavax!don)
XX *
XX * Notice: No Copyright.
XX *
XX*/
XX
XX#include <stdio.h>
XX#include <ctype.h>
XX#ifdef BSD
XX#include <strings.h>
XX#else
XX#include <string.h>
XX#define rindex strnchr
XX#endif BSD
XX
XX#define MAXLEN 256 /* Max. Length of a single line */
XX#define MAXLINES 500 /* Max. number of lines (reminders) */
XX
XX#define CALENDAR "/calendar" /* calendar file */
XX#define RSFILE "/.reminders" /* reminder file */
XX#define RSNOTES "/.rsnotes" /* notes file */
XX
XX#define LPR "/usr/ucb/lpr" /* location of lpr */
XX#define EDITOR "/usr/ucb/vi" /* default editor */
XX
XX/*#define BIGHELP /* Define if you want verbose help message */
XX
XXFILE *fp,
XX *fptmp;
XX
XXchar fname[128], /* Filename tmp */
XX on[32], /* string used to turn "mark" on */
XX off[32], /* string used to turn "mark" off */
XX buff[1024], /* Holds termcap entry for TERM */
XX s[MAXLEN], /* Tmp string and line storage */
XX sstr[80], /* Search string */
XX cmd[256]; /* cmd for system call */
XX
XXchar *a,
XX *editor, /* Hold for EDITOR environment variable */
XX *entity = "Reminders", /* Entity working on */
XX *env, /* Hold for RSINIT environment variable */
XX *fun, /* Used in arg processing */
XX *mark_on = "so", /* Default mark is Standout mode */
XX *mark_off = "se"; /* Standout end */
XX
XX
XXchar *getenv(),
XX *malloc(),
XX *mktemp();
XX
XXchar rstmp[]= "/tmp/rsXXXXXX"; /* name of temp. file during delete */
XX
XXint adisplay = 0, /* display reminders after additions (default = no) */
XX ddisplay = 0, /* display reminders after deletions (default = no) */
XX Adisplay = 0, /* display notes/alt after additions (default = no) */
XX Ddisplay = 0, /* display notes/alt after deletions (default = no) */
XX columns = 80, /* Number of columns in a line. */
XX len = 0, /* Length of line */
XX mark = 0, /* Mark the line (High Priority) */
XX tcap = 1, /* Read Termcap stuff. */
XX tcapok = 0, /* TERM found in Termcap file. */
XX rem_work = 1, /* working on reminder file by default */
XX search = 0, /* search option seen on command line */
XX status; /* Hold status returned by sys calls and such */
XX
XXmain(argc, argv)
XXint argc;
XXchar *argv[];
XX{
XX
XX/* Get RSINIT environment variable to find options desired */
XX
XXenv = getenv("RSINIT");
XX
XXwhile (*env) {
XX switch(*env++) {
XX case 'a' : adisplay++; break;
XX case 'd' : ddisplay++; break;
XX case 'A' : Adisplay++; break;
XX case 'D' : Ddisplay++; break;
XX case 'I' : tcap = 0; break;
XX case 'U' :
XX mark_on = "us";
XX mark_off = "ue";
XX break;
XX case 'B' :
XX mark_on = "bo";
XX mark_off = "be";
XX break;
XX case 'S' :
XX mark_on = "ss";
XX mark_off = "ss";
XX break;
XX }
XX}
XX
XX
XX/* Get users HOME directory and construct default name for reminder file */
XX
XXsprintf(fname, "%s%s", getenv("HOME"), RSFILE);
XX
XX/* Find out what the user wants to do */
XX
XXwhile ( --argc > 0 && (*++argv)[0] == '-')
XX for (fun = argv[0]+1; *fun != '\0'; fun++)
XX switch(*fun) {
XX case 'A' : /* Work on Alternate reminder file */
XX env = getenv("RSALT");
XX if (!env)
XX env = "phone_numbers";
XX
XX sprintf(fname, "%s/.%s", getenv("HOME"), env);
XX entity = env;
XX if (islower(entity[0]))
XX entity[0] = toupper(entity[0]);
XX rem_work = 0;
XX break;
XX
XX case 'a' : /* Add reminder(s)/note(s)/alternate(s) */
XX add_reminder();
XX exit(0);
XX
XX case 'c' : /* Add entries to calendar file */
XX sprintf(fname, "%s%s", getenv("HOME"), CALENDAR);
XX entity = "Calendar commands";
XX rem_work = 0;
XX add_reminder();
XX exit(0);
XX
XX case 'd' : /* Delete reminder(s)/note(s)/alternate(s) */
XX delete_reminder(argc, argv);
XX exit(0);
XX
XX case 'k' : /* Kill all reminders/notes/alternates */
XX if ( unlink(fname) == 0) {
XX printf("%s killed.\n", entity);
XX }
XX exit(0);
XX
XX case 'n' : /* Work on notes file */
XX sprintf(fname, "%s%s", getenv("HOME"), RSNOTES);
XX entity = "Notes";
XX rem_work = 0;
XX break;
XX
XX case 'p' : /* print reminders/notes/alternates */
XX sprintf(cmd, "%s %s", LPR, fname);
XX status = system(cmd);
XX
XX if (status == 0) {
XX printf("%s will be printed.\n", entity);
XX exit(0);
XX }
XX else {
XX printf("%s can't be printed, sorry\n", entity);
XX exit(1);
XX }
XX
XX case 's' : /* search for string in reminders/notes/alts */
XX argc--;
XX argv++;
XX sprintf(sstr, "%s", argv[0]);
XX search++;
XX break;
XX case 'e' : /* -e and -v are equivilent */
XX case 'v' : /* Edit reminders/notes/alternates with editor */
XX editor = getenv("EDITOR");
XX if (!editor)
XX editor = EDITOR;
XX sprintf(cmd, "%s %s",editor,fname);
XX system(cmd);
XX exit(0);
XX default: /* Give em some help */
XX#ifndef BIGHELP
XX printf("Usage: rs [ -Aaceknpv ] [ -s search_string ] [ -d # ] [ -d #-# ]\n");
XX printf("For additional information type: man rs\n");
XX#else
XX /* You can enable this stuff if you want! */
XX printf("Reminder Service commands:\n\n");
XX printf("-A\tWork on Alternate reminder file.\n");
XX printf("-a\tAdd reminder(s)/note(s)/Alt(s).\n");
XX printf("-c\tAdd line(s) to the calendar file.\n");
XX printf("-d\tDelete reminder(s)/note(s)/Alt(s).\n");
XX printf("-k\tKill all reminders/notes/Alternate.\n");
XX printf("-n\tWork on notes.\n");
XX printf("-p\tPrint reminders/notes/Alternates.\n");
XX printf("-s\tSearch for string.\n");
XX printf("-e\tEdit reminders/notes/Alt.\n\n");
XX printf("rs with no option will display reminders.\n");
XX printf("SEE ALSO rs(1)\n");
XX#endif BIGHELP
XX exit(0);
XX }
XX
XXprint_reminders();
XX
XX}
XX
XX
XX/* ADD REMINDERS */
XX/* This routine uses cat to add lines to the reminder/note/alternate file */
XX/* If you don't like it, add your own getline routine! */
XX
XXadd_reminder()
XX{
XX printf("Enter %s then ^d to exit:\n", entity);
XX
XX sprintf(cmd, "%s %s","/bin/cat >>",fname);
XX system(cmd);
XX if ( (adisplay && rem_work) || (Adisplay && !rem_work) )
XX print_reminders();
XX}
XX
XX
XX/* DELETE REMINDERS/NOTES/ALTERNATES */
XX
XXdelete_reminder(argc, argv)
XX int argc;
XX char *argv[];
XX{
XX int begin,
XX end,
XX delete_line[MAXLINES];
XX
XX char a[4], b[4];
XX
XX register int i = 0,
XX j = 0,
XX deleted = 0,
XX line_number = 0,
XX printed = 0;
XX
XX argc--, argv++;
XX for (;argc > 0; argc--, argv++) {
XX if (alldigits(*argv)) {
XX delete_line[atoi(*argv)] = 1;
XX }
XX else {
XX i = rindex(*argv, '-');
XX sscanf(i+1, "%s", b );
XX j = ( strlen(*argv) - strlen(b) ) - 1;
XX strncpy(a, *argv, j);
XX a[j]='\0';
XX begin = atoi(a);
XX end = atoi(b);
XX
XX if (begin < end) {
XX for (j = begin ; j < end+1 ; j++)
XX delete_line[j] = 1;
XX }
XX else {
XX printf("Illegal range specified.\n");
XX exit(1);
XX }
XX }
XX }
XX
XX mktemp(rstmp);
XX if ((fptmp = fopen(rstmp,"w")) == NULL) {
XX print_open_error_exit(rstmp);
XX }
XX
XX if ((fp = fopen(fname,"r")) == NULL) {
XX print_open_error_exit(fname);
XX }
XX
XX while (getline(s, MAXLEN) > 0) {
XX if (delete_line[++line_number] != 1) {
XX fprintf(fptmp,"%s",s);
XX printed++;
XX }
XX else {
XX deleted++;
XX }
XX }
XX
XX fclose(fp);
XX fclose(fptmp);
XX
XX status = unlink(fname);
XX if (status != 0) {
XX printf("Can't remove file - %s", fname);
XX exit(1);
XX }
XX
XX if (printed) {
XX if ((fp = fopen(fname,"w")) == NULL) {
XX print_open_error_exit(fname);
XX }
XX
XX if ((fptmp = fopen(rstmp,"r")) == NULL) {
XX print_open_error_exit(rstmp);
XX }
XX
XX while (fgets(s, MAXLEN, fptmp) != NULL) {
XX fputs(s, fp);
XX }
XX }
XX
XX fclose(fp);
XX fclose(fptmp);
XX status = unlink(rstmp);
XX
XX if (deleted)
XX printf("%d %s deleted.\n", deleted, entity );
XX
XX if ( (ddisplay && rem_work) || (Ddisplay && !rem_work) )
XX print_reminders();
XX}
XX
XX
XX/* PRINT REMINDERS/NOTES/ALTERNATES */
XX/* This routine will print reminders/notes/alternates */
XX/* print_line is called to do the printing with */
XX/* auto wrap. If a search argument was given, only lines that contain the */
XX/* search string will be printed. */
XX
XXprint_reminders()
XX{
XX register int line_number = 0;
XX
XX if ((fp = fopen(fname,"r")) == NULL) {
XX exit(0);
XX }
XX
XX if (tcap) {
XX if (tgetent(buff, getenv("TERM")) == 1) {
XX tcapok++;
XX columns = tgetnum("co");
XX if (columns <= 0)
XX columns = 80;
XX columns -= 6;
XX a = on;
XX tgetstr(mark_on, &a);
XX a = off;
XX tgetstr(mark_off, &a);
XX if (!strlen(on)) {
XX if (tgetflag("bs"))
XX strcpy(on, "\010*");
XX else {
XX a = on;
XX tgetstr("bc", &a);
XX }
XX }
XX }
XX }
XX
XX printf("\n%s:\n", entity);
XX
XX while ((len = getline(s, MAXLEN)) > 0) {
XX if (search) {
XX if (instr(s, sstr) != -1) {
XX printf("%3d. ", ++line_number);
XX if (tcapok)
XX find_mark();
XX if (mark)
XX printf("%s", on);
XX print_line(s, columns);
XX if (mark) {
XX printf("%s", off);
XX mark = 0;
XX }
XX }
XX else
XX line_number++;
XX }
XX else {
XX printf("%3d. ", ++line_number);
XX if (tcapok)
XX find_mark();
XX if (mark)
XX printf("%s", on);
XX print_line(s, columns);
XX if (mark) {
XX printf("%s", off);
XX mark = 0;
XX }
XX }
XX }
XX
XX printf("\n");
XX
XX fclose(fp);
XX}
XX
XXgetline(s, lim)
XXchar s[];
XXint lim;
XX{
XX register int i = 0;
XX register int c;
XX
XX while (--lim > 0 && (c=getc(fp)) != EOF && c != '\n')
XX s[i++] = c;
XX
XX if (c == '\n')
XX s[i++] = c;
XX
XX s[i] = '\0';
XX
XX return(i);
XX}
XX
XXalldigits(s)
XXregister char *s;
XX{
XX register c = *s++;
XX
XX do {
XX if (!isdigit(c))
XX return(0);
XX }
XX while (c = *s++);
XX
XX return(1);
XX}
XX
XXinstr(s, t)
XXchar s[], t[];
XX{
XX register int i, j, k;
XX
XX for (i = 0; s[i] != '\0' ; i++) {
XX for (j=i, k=0 ; t[k] != '\0' && s[j]==t[k] ; j++ , k++)
XX ;
XX if (t[k] == '\0')
XX return(i);
XX }
XX return(-1);
XX}
XX
XXprint_open_error_exit(file_name)
XXchar file_name[];
XX{
XX printf("Can't open file - %s\n",file_name);
XX exit(1);
XX}
XX
XX/* This routine will wrap lines greater than 75 characters long. */
XX/* An attempt is made to break the line up after a word. If a "word" */
XX/* is greater than 75 characters, the word will be split. */
XX/* pur-ee!mjs */
XX
XX#define SPACE ' '
XXint print_line (line, maxlen)
XXchar line[]; /* string to be printed */
XXunsigned int maxlen; /* longest line permitted for output */
XX{
XX register int index, /* used in for loops */
XX breaking_pt,/* index in line[] at point to break line
XX */
XX nospace = 0,/* set to TRUE if no space is found */
XX last_br_pt = 0,/* last breaking point */
XX line_len, /* number of characters in line[] */
XX done = 0; /* set to TRUE if finished */
XX
XX /* if line[] isn't longer than the longest line permitted, we can just
XX print it, and return. */
XX
XX line_len = strlen (line);
XX
XX if (strlen (line) <= maxlen) {
XX printf ("%s", line);
XX return;
XX }
XX
XX do {
XX /* set breaking_pt at point in line[] where we should break the line.
XX Do this by start looking backwards from maxlen until a space is
XX found. */
XX
XX for (index = (maxlen + last_br_pt); line[index] != SPACE; --index) {
XX if (index == last_br_pt) {
XX nospace = 1;
XX break;
XX }
XX if (index >= line_len) {
XX index = line_len - 1; /* 1 gets added to it below */
XX done = 1;
XX break;
XX }
XX }
XX breaking_pt = index + 1;
XX
XX /* if there is no space found, set breaking point to MAXLEN */
XX
XX if (nospace == 1) {
XX breaking_pt = maxlen + last_br_pt;
XX nospace = 0; /* reset flag */
XX }
XX /* print line[] up to breaking point */
XX
XX for (index = last_br_pt; index < breaking_pt; ++index)
XX putchar (line[index]);
XX
XX
XX if (last_br_pt == 0) /* this is our first time through */
XX maxlen -= 5; /* for indenting */
XX if (!done) {
XX if (mark)
XX printf("%s", off);
XX
XX printf("\n "); /* indent */
XX
XX if (mark)
XX printf("%s", on);
XX }
XX
XX last_br_pt = breaking_pt;
XX } while (!done);
XX}
XXfind_mark()
XX{
XX if (s[len-2] == '\07') {
XX mark = 1;
XX s[len-2] = '\n';
XX s[len-1] = '\0';
XX }
XX}
SHAR_EOF
if test 13652 -ne "`wc -c < 'rs.c'`"
then
echo shar: "error transmitting 'rs.c'" '(should have been 13652 characters)'
fi
fi
echo shar: "extracting 'rs.1'" '(5288 characters)'
if test -f 'rs.1'
then
echo shar: "will not over-write existing file 'rs.1'"
else
sed 's/^XX//' << \SHAR_EOF > 'rs.1'
XX.TH RS 1 "3 July 1986"
XX.ad b
XX.SH NAME
XXrs \- reminder system
XX.SH SYNOPSIS
XX.B rs
XX[
XX.B \-Aacknpv
XX] [
XX.B \-s
XX.I string
XX] [
XX.BI \-d \0# \0#-#
XX]
XX.SH DESCRIPTION
XX.I rs
XXis a personal reminder system.
XXReminders can be displayed every time you log into the system
XXby placing the
XX.I rs
XXcommand in your
XX.I .login
XXor
XX.I .profile
XXfile.
XXThe reminder system includes three reminder files:
XX.nf
XX
XX
XX 1. Reminders ($HOME/.reminders)
XX 2. Notes ($HOME/.rsnotes)
XX 3. User defined by setting the RSALT environment variable.
XX (Defaults to $HOME/.phone_numbers)
XX.fi
XX.PP
XX.I Options:
XX.TP
XX.I rs
XXWith no options, print reminder list to terminal.
XX.TP
XX.B \-A
XXWork with
XX.I alternate
XXreminder file.
XXThe name of the alternate file is user defined by setting the
XX.I RSALT
XXenvironment variable. (If
XX.I RSALT
XXis not set, the alternate file defaults to 'phone_numbers'.)
XX.TP
XX.B \-a
XXAdd reminders/notes/alternates.
XXYou are prompted to add reminders/notes/alternates. Appending a ^G (Control-G)
XXat the end of a reminder will cause rs to mark it (Highlight) during display. (See
XX.I RSINIT
XXbelow.)
XX.TP
XX.B \-c
XXAdd entries to calendar system. You are prompted to add calendar entries.
XXSee
XX.I calendar(1).
XX.TP
XX.B \-d
XXDelete reminders/notes/alternates. This option, followed by a number or
XXnumbers, causes
XX.I rs
XXto delete the specified reminders/notes/alternates.
XXMore than one number may be placed on the same command line separated by
XXblanks.
XXA range of numbers may also be specified.
XX.TP
XX.B \-e
XXEdit reminders/notes/alternates file. If the EDITOR environment variable is
XXset, the specified EDITOR is used. If not, vi is used by default. (-v may be
XXused in place of -e)
XX.TP
XX.B \-k
XXKill (delete) all reminders/notes/alternates.
XX.TP
XX.B \-n
XXWork on
XX.I notes
XXfile.
XX.TP
XX.B \-p
XXPrint reminders/notes/alternates.
XX(By default, does an
XX.I lpr
XXof reminder file.)
XX.TP
XX.B \-s
XXSearch for reminders/notes/alternates that match the given string.
XX.PP
XXMore than one option may follow a single "\-", for example:
XX.nf
XX.RS
XX
XXrs -na The command for "add note."
XX.RE
XX.fi
XX.PP
XX.SH NOTES
XXTo mark a reminder (Highlight), append a ^G (Control-G) to the reminder.
XX.I rs
XXwill mark the reminder during display using one of the following:
XX.nf
XX
XX
XX Standout
XX Underscore.
XX Bold
XX Asterisk
XX
XX.fi
XXas defined in
XX.I RSINIT.
XX.PP
XX.I rs
XXlooks in the environment variable
XX.I RSINIT
XXfor additional configuration options. Options are:
XX.nf
XX
XX
XXA Display notes/alternates/calendar after additions.
XXD Display notes/alternates/calendar after deletions.
XXa Display reminders after additions.
XXd Display reminders after deletions.
XXI Ignore TERMCAP info during startup.
XX (Default number of columns is 80, no mark capability)
XX
XXDefault mark is standout mode.
XX ('so' and 'se' must be defined in termcap entry.)
XX
XXU Use underscore (underline) to mark reminders.
XX ('us' and 'ue' must be defined in termcap entry.)
XXB Use Bold to mark reminders.
XX ('bo' and 'be' must be defined in termcap entry.)
XXS Use '*' to mark reminders.
XX (Terminal must have 'bs'.)
XX.fi
XX.PP
XXFor example,
XXif you prefer to view your reminders/notes/alternates after
XXadditions/deletions, the
XX.I csh
XXcommand:
XX.nf
XX
XX
XX setenv RSINIT 'aAdD'
XX
XX.fi
XXcauses
XX.I rs
XXto display your reminders/notes/alternates after additions/deletions.
XXThe above command sequence may be placed in your
XX.I .login
XXfile.
XX.PP
XXReminders/notes/alternates may be from one to 255 characters long.
XXIf a reminder is longer than one line (As defined in termcap 'co'),
XX.I rs
XXdoes automatic word wrap.
XXTo add a reminder/note/alternate longer than one line,
XXtype in the entire reminder/note/alternate and end with a single carriage
XXreturn.
XXDo
XX.B not
XXinsert carriage returns before the end of a reminder/note/alternate.
XXA single carriage return
XX.B always
XXindicates the
XX.B end
XXof a reminder.
XX.SH EXAMPLES
XX.TP
XXrs -d 1 5 8
XXDelete reminders 1, 5, 8.
XX.TP
XXrs -n -d 1-5 8
XXDelete notes 1, 2, 3, 4, 5, 8.
XX.TP
XXrs -k
XXKill all reminders.
XX.SH EXAMPLE USE OF ALTERNATE REMINDER FILE
XX.PP
XXIf you would like to have a list of phone numbers that can be accessed by the
XXreminder system, you can do the following:
XX.PP
XXSet the
XX.I RSALT
XXenvironment variable to
XX.I phone-numbers
XXby including the following command line in your
XX.I .login
XXfile:
XX.TP
XX.I " setenv RSALT 'phone-numbers'"
XX.TP
XXUse the reminder system command:
XX.TP
XX.I " rs -A [options]"
XX.TP
XXto work on the phone-numbers reminder file.
XX.SH EXAMPLE COMMANDS FOR PHONE-NUMBERS REMINDER FILE
XX.TP
XXrs \-A \-a
XXAdd phone numbers to the phone-numbers reminder file.
XX.TP
XXrs \-A \-s Joslyn
XXSearch for Joslyn's phone number.
XX.TP
XXrs \-A \-e
XXEdit phone-numbers.
XX.TP
XXrs \-A \-p
XXPrint phone-numbers on the line printer.
XX.TP
XXrs \-A \-d 1
XXDelete the first line from phone-numbers.
XX.SH TIPS
XXTo make use of the notes/alternates easier, the author defines two aliases:
XX.nf
XX
XXalias rsn 'rs -n' Use rsn to work with notes file.
XXalias rsa 'rs -A' Use rsa to work with alternate file.
XX.fi
XX.SH FILES
XX.nf
XX
XX$HOME/.reminders User's reminders.
XX$HOME/.rsnotes User's notes.
XX/tmp/.rs* Used during reminder deletion.
XX$HOME/.? Other reminder file(s) defined by RSALT.
XX.fi
XX.SH SEE ALSO
XXcalendar(1), csh(1), environ(7), lpr(1), vi(1)
XX.SH AUTHOR
XX.nf
XXDon Joslyn, Manager
XXNova University Computer Center
XX3301 College Avenue
XXFort Lauderdale, Florida 33314
XX(305) 475-7678
XX{codas, allegra, ucf-cs}!novavax!don
XX.fi
SHAR_EOF
if test 5288 -ne "`wc -c < 'rs.1'`"
then
echo shar: "error transmitting 'rs.1'" '(should have been 5288 characters)'
fi
fi
exit 0
# End of shell archive
More information about the Comp.sources.unix
mailing list