📄 part01
字号:
X set recno = `awk '{ print $2 }' ${tmpfile} | sort -u`X cat /dev/null > ${tmpfile}Xgrepno:X foreach rec (${recno})X bm "${rec}" ${libfile} | awk 'NF>2' | \X grep "^#[${outsel}]" >> ${tmpfile}X echo "---------------------------" >> ${tmpfile}X endX less -pcu ${tmpfile}X endifX goto loopX#---------------------------------------------------------------#X# add a new record to library file #X#---------------------------------------------------------------#Xlibadd:X if ( "${user}" != "secrtary" && "${user}" != "chicca" && ${user} != "lew" ) thenXerr:X echo -n '...Sorry, only secretary can update library info'X goto getretX breakswX endifX if ( "${title}" == "" ) thenX echo "...You can not add a record without title..."X sleep 1X goto loopX endifX @ rec = `tail -1 ${libfile} | awk '{print $2}'`X @ rec ++X set recno = "${rec}"X if ( $rec < 1000 ) set recno = "0${recno}"X if ( $rec < 100 ) set recno = "0${recno}"X if ( $rec < 10 ) set recno = "0${recno}"X cat >> ${libfile} << cat_eofXX#K ${recno} ${keyword}X#A ${recno} ${author}X#P ${recno} ${pub}X#T ${recno} ${title}X#N ${recno} ${bookid}X#D ${recno} ${pdate}X#S ${recno} ${size}X#R ${recno} `date`Xcat_eofX echo "Record ${recno} has been added successfully"X sleep 1X goto loopX#---------------------------------------------------------------#X# show all new books since last check #X#---------------------------------------------------------------#Xlibnew:X if ( ! -e ~/.gsgbook ) thenX @ old = 0X elseX @ old = `cat ~/.gsgbook`X endifX grep '^#T' ${libfile} | awk \X 'BEGIN { p = 0 } \X p == 1 { print } \X $2 ~ /'"${old}"'/ { p = 1 }' | less -pcuX tail -1 ${libfile} | awk '{ print $2 }' > ~/.gsgbookX goto loopX#---------------------------------------------------------------#X# display all possible keyword defined #X#---------------------------------------------------------------#Xlibkeyword:X (echo "...Possible Keywords List in Library..."; \X grep '^#K' ${libfile} | awk \X '{ for (i=3; i<=NF; i++) { \X print $i; \X } \X }') | sort -u | awk \X 'NR == 1 { print } \X NR > 1 { \X printf "%-18s", $0; \X if (++i % 4 == 0) printf "\n"; \X } \X END { if (i % 4 != 0) printf "\n"; }' | less -pcuX goto loopX#---------------------------------------------------------------#X# print previous located collection of data #X#---------------------------------------------------------------#Xlibprint:X if ( -e ${tmpfile} && ! -z ${tmpfile} ) thenX print ${tmpfile}X elseX echo -n "Nothing to print"Xgetret:X echo -n ", press RETURN to continue: "X set yon = "$<"X endifX goto loopX#---------------------------------------------------------------#X# run vi on the library file (undocumented feature) #X#---------------------------------------------------------------#Xlibvi:X vi ${libfile}X goto loopX#---------------------------------------------------------------#X# display usage guide for inexperience users #X#---------------------------------------------------------------#Xlibhelp:X cat << cat_eofXadd add a new record into library database, privilege requiredXnew display what new books has arrived since last useXfind search for proper informationXhelp display this usage guideXkeyword show all current available keywordsXprint print the result from the last find commandXquit exitXXYou may enter search string in any of the fields (grep -i will be usedXin each occassion). If you specify book numbers, all the other fieldsXwill be ignored.XXThe one character fields at the beginning of each field is outputXselect, if it is 'y', it will be included in the output.XXcat_eofX echo -n "End of help info"X goto getretX#---------------------------------------------------------------#X# Clean up and exit here... #X#---------------------------------------------------------------#Xend:X /bin/rm -f ${tmpfile}X unset fnames fname srcfile tmpfileSHAR_EOFif test 8749 -ne "`wc -c < 'Lib'`"then echo shar: error transmitting "'Lib'" '(should have been 8749 characters)'fichmod +x 'Lib'fi # end of overwriting checkecho shar: extracting "'basic.h'" '(829 characters)'if test -f 'basic.h'then echo shar: will not over-write existing file "'basic.h'"elsesed 's/^X//' << \SHAR_EOF > 'basic.h'X#if !defined (YES)X#define YES 1X#endifXX#if !defined (NO)X#define NO 0X#endifXX#if !defined (EOS)X#define EOS '\0'X#endifXX#if !defined (TAB)X#define TAB '\t'X#endifXX#if !defined (NULL)X#define NULL 0X#endifXX#if defined (CTRL)X#undef CTRLX#endifX#define CTRL(x) ((x) & 0xbf)XX#define LOW_GCHAR ' 'X#define HIGH_GCHAR '~'XX#ifdef DEBUGX#define ENTER(name) static char *rname = "name"; \X { \X Level++; \X fprintf (stderr, "%*s%s\n", -(Level*4), "-", \X rname); \X fflush (stderr); \X }X#define RETURN(x) {Level--; return (x);}X#define EXIT {Level--; return; }X#elseX#define ENTER(name)X#define RETURN returnX#define EXIT returnX#endifXX#define when break;caseX#define otherwise break;defaultXX#ifndef EXTERNX#define EXTERN externX#endifXXEXTERN int Level; /* level of function call debug */SHAR_EOFif test 829 -ne "`wc -c < 'basic.h'`"then echo shar: error transmitting "'basic.h'" '(should have been 829 characters)'fifi # end of overwriting checkecho shar: extracting "'form.h'" '(1383 characters)'if test -f 'form.h'then echo shar: will not over-write existing file "'form.h'"elsesed 's/^X//' << \SHAR_EOF > 'form.h'X/* Screen controls */X X#define SCR_ERASE 0 /* clear screen */X#define SCR_HOME 1 /* home the cursor */X#define SCR_EEOL 2 /* erase to end of line */X#define SCR_DEL 3 /* BS SPACE BS */X#define SCR_SAVE 4 /* save cursor position */X#define SCR_RESTORE 5 /* restore cursor position */X#define SCR_REVERSE 6 /* reverse video mode */X#define SCR_NORMAL 7 /* normal video mode */X#define SCR_BACKSPACE 8 /* cursor left */X#define SCR_KEYXMIT 9 /* enter keypad xmit mode */X#define SCR_NOKEYXMIT 10 /* exit keypad xmit mode */X X#define EF_OK 1 /* field is ok */X#define EF_ERR 2 /* error on field */X#define EF_BOF 3 /* start by placing cursor at beg of field */X#define EF_EOF 4 /* start by placing cursor at end of field */X#define EF_FILL 5 /* fill rest of field */X X/* update field options */X X#define UF_MONEY 1 /* money format: dollar.cents */X#define UF_NUMBER 2 /* number */X#define UF_STRING 3 /* string to display */X#define UF_TIME 4 /* current time - HH:MM */X#define UF_DATE 5 /* today's date - MM/DD/YY */XX#define SCRLINE 24 /* number of lines on screen */X#define SCRCOL 80 /* number of columns on screen */X#define MAXVNAME 500 /* # of chars in variable name pool */X#define MAXFNAME 80 /* # of chars allowed in filename */X X#define BOURNE 1 /* bourne shell output */X#define CSH 2 /* C shell output */X#define PERL 3 /* perl script output */SHAR_EOFif test 1383 -ne "`wc -c < 'form.h'`"then echo shar: error transmitting "'form.h'" '(should have been 1383 characters)'fifi # end of overwriting checkecho shar: extracting "'field.h'" '(665 characters)'if test -f 'field.h'then echo shar: will not over-write existing file "'field.h'"elsesed 's/^X//' << \SHAR_EOF > 'field.h'X#define MAXFIELD 200XXstruct field {X unsigned char f_line; /* line number (1-24) */X unsigned char f_col; /* column number (1-80) */X unsigned char f_off; /* offset from beg of line */X unsigned char f_len; /* field size (bytes) */X unsigned f_attr; /* attributes */X#define FA_AUTOTAB 0x01 /* move to next field at eof */X#define FA_SELECTION 0x02 /* selection field */X#define FA_BLOCK 0x04 /* block type */X#define FA_NUMERIC 0x08 /* nuermic only field */X char **f_sel; /* ptr to selection array */X char **f_help; /* ptr to help message array */X unsigned char f_sno; /* current selection index */X char *f_var; /* variable to set at end */X };SHAR_EOFif test 665 -ne "`wc -c < 'field.h'`"then echo shar: error transmitting "'field.h'" '(should have been 665 characters)'fifi # end of overwriting checkecho shar: extracting "'term.h'" '(285 characters)'if test -f 'term.h'then echo shar: will not over-write existing file "'term.h'"elsesed 's/^X//' << \SHAR_EOF > 'term.h'X#define BC 0X#define CM 1X#define CL 2X#define CD 3X#define CE 4X#define HO 5X#define KS 6X#define KE 7X#define KU 8X#define KD 9X#define KL 10X#define KR 11X#define MD 12X#define ME 13X#define RC 14X#define SC 15X#define SO 16X#define SE 17X#define US 18X#define UE 19X#define BAD 20SHAR_EOFif test 285 -ne "`wc -c < 'term.h'`"then echo shar: error transmitting "'term.h'" '(should have been 285 characters)'fifi # end of overwriting checkecho shar: extracting "'Makefile'" '(3543 characters)'if test -f 'Makefile'then echo shar: will not over-write existing file "'Makefile'"elsesed 's/^X//' << \SHAR_EOF > 'Makefile'X###############################################################################X#X# Copyright (C) Paul Lew, 1988, All rights reservedX#X# sccsid = "%W% %G%"X#X# File Name: MakefileX#X# Author: Paul LewX# Creation Date: 05/07/86 05:06 PMX# Last update: 02/07/88 10:29 PM (Edition: 25)X#X# Function: Makefile for shell form editorX#X# Update History:X# Date Modification Description ByX# -------- ----------------------------------------------- ---X# 05/07/86 Initial version LewX# 08/01/87 Added field.h, split shform.c into load.c, LewX# option.c, field.c, and form.c LewX# 01/11/88 Added field.h (was missing) LewX# 01/13/88 Added summary.c LewX# 01/14/88 Added make zoo LewX# 01/28/88 Added make shar LewX# 02/07/88 Added Makefile to shar list (was missing) LewX# 02/07/88 Added COPYRIGHT LewX#X###############################################################################XTITLE = sfXXMODULE = sfXOBJECTS = sf.o form.o load.o field.o selection.o keyword.o \X option.o msg.o term.o io.o summary.oXFILES = sf.c form.c load.c field.c selection.c keyword.c \X option.c msg.c term.c io.c summary.cXEXAMPLES= Print Stty LibXINFO = sf.1 README MANIFEST COPYRIGHT TODOXLIBS = /gsg/lew/c/getopt.oXLIBSRC =XCFLAGS = -n -gxXLIBRARY = -ltermcapXINCLUDES= basic.h form.h field.h term.hXEDITION = 1X#------------ The remainder of this makefile is module independent -------#XX.SUFFIXES: .rel .obj .r .o .cXXCFLAG2 =XCREF = /gsg/lew/bin/crefXDEPEND = /gsg/lew/sh/dependXX#------------- Make executable -------------------------------------------#XX$(MODULE): $(OBJECTS) $(LIBS)X $(CC) $(CFLAGS) -o $(MODULE) $(OBJECTS) $(LIBS) $(LIBRARY)XX.c.o:X $(CC) $(CFLAGS) $(CFLAG2) -c $*.cXX#------------- Utilities -------------------------------------------------#XXutil: lint TAGS listing dependXXlint: $(FILES)X lint $(FILES) > lintXXTAGS: $(INCLUDES) $(FILES)X etags $(INCLUDES) $(FILES)XXlisting: $(INCLUDES) $(FILES)X -$(CREF) $(INCLUDES) $(FILES) > listingXXprint: listing xxxXxxx:X lpr -J '$(TITLE)' listingXXdepend: $(FILES)X @ touch dependX @ $(DEPEND) $(FILES)XXname:X @ echo $(INCLUDES) $(FILES)XXzoo:X @ /bin/rm -f sf.zooX zoo a sf RCS/* TAGS IDX @ chmod a-w sf.zoo; ls -l sf.zooXXshar:X echo '----shar.01-----' > MANIFESTX vitals $(INFO) $(EXAMPLES) $(INCLUDES) Makefile >> MANIFESTX echo '----shar.02-----' >> MANIFESTX vitals $(FILES) >> MANIFESTX shar -a $(INFO) $(EXAMPLES) $(INCLUDES) Makefile > shar.01X shar -a $(FILES) > shar.02XXhelp:X @ echo "make lint -- generate lint file: lint"X @ echo "make TAGS -- generate tag file: TAGS"X @ echo "make listing -- generate cross ref listing: listing"X @ echo "make print -- print out listing: listing"X @ echo "make depend -- update makefile dependency rule"X @ echo "make util -- do all above"X @ echo "make name -- output source name list"X @ echo "make zoo -- recreate sf.zoo archive"X @ echo "make shar -- create shell archive files"X#-------------------------------------------------------------------------#X# DO NOT DELETE THIS LINE, auto-generated dependency rules follow:Xfield.o: basic.h field.h form.h term.hXform.o: basic.h field.h form.h term.hXkeyword.o: basic.hXload.o: basic.h field.h form.hXmsg.o: basic.h form.hXoption.o: basic.h form.hXselection.o: basic.h field.h form.h term.hXsf.o: basic.h form.hXsummary.o: basic.h form.hXterm.o: form.h term.hX#X# Rules made at: Thu Jan 28 20:55:24 EST 1988 by lewX# DEPENDENCIES END HERE.SHAR_EOFif test 3543 -ne "`wc -c < 'Makefile'`"then echo shar: error transmitting "'Makefile'" '(should have been 3543 characters)'fifi # end of overwriting check# End of shell archiveexit 0-- Please send comp.sources.unix-related mail to rsalz@uunet.uu.net.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -