-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpegboard
1772 lines (1768 loc) · 41.7 KB
/
pegboard
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
Subject: v20i076: An electronic office sign-in/signout pegboard
Newsgroups: comp.sources.unix
Sender: sources
Approved: [email protected]
Submitted-by: Richard O'Rourke <uunet!mplex!ror>
Posting-number: Volume 20, Issue 76
Archive-name: pegboard
[ I tweaked the Makefile and added the -DBSD stuff; looks like the
original was for Xenix (/etc/default?) /r$ ]
This program can be used to keep track of who is in or out of the
office, and when they are due back. To be useful, people have to
USE it, but this is true of traditional pegboards as well. People
here find it friendly enough and pretty much keep the pegboard updated.
#! /bin/sh
# This is a shell archive. Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file". To overwrite existing
# files, type "sh file -c". You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g.. If this archive is complete, you
# will see the following message at the end:
# "End of shell archive."
# Contents: Makefile README default.peg dot.pegrc peg.h peg.h.ansi
# peg.man peg.y pegboard.hdr pegio.c tfix.c
# Wrapped by [email protected] on Fri Oct 27 13:08:48 1989
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'Makefile' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'Makefile'\"
else
echo shar: Extracting \"'Makefile'\" \(477 characters\)
sed "s/^X//" >'Makefile' <<'END_OF_FILE'
XOBJS = peg.o tfix.o pegio.o
XSRCS = peg.c tfix.c pegio.c
XBINDIR = /usr/lbin
X
X#DEFS=-DBSD -DLPNMAX=128
XOPTS = -O $(DEFS)
X#
X# Name of executable
XBNAME = peg
X
X$(BNAME): $(OBJS) peg.h
X cc $(OPTS) -o $(BNAME) $(OBJS)
X
Xpeg.o: peg.c peg.h
X cc $(OPTS) -c peg.c
X
Xtfix.o: tfix.c peg.h
X cc $(OPTS) -c tfix.c
X
Xpegio.o: pegio.c peg.h
X cc $(OPTS) -c pegio.c
X
Xclean:
X rm $(OBJS)
Xinstall:
X mv peg $(BINDIR)/peg
X mv default.peg /etc/default/peg
Xlint:
X lint -pubx $(SRCS) >lint.out
X
Xpeg.c: peg.y
END_OF_FILE
if test 477 -ne `wc -c <'Makefile'`; then
echo shar: \"'Makefile'\" unpacked with wrong size!
fi
# end of 'Makefile'
fi
if test -f 'README' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'README'\"
else
echo shar: Extracting \"'README'\" \(1460 characters\)
sed "s/^X//" >'README' <<'END_OF_FILE'
XPeg is an online pegboard. It is used to see if someone is in or
Xout of the office and when they are expected back. Do "make install"
Xafter you get it to compile.
X
XThere is at least 1 incompatibilty problem you may encounter, fcntl
Xtype locking is used. The functions are "pblock()" and "pbunlock()"
Xin "pegio.c". "getopts()" is required, if you don't have it you can
Xget it from an archive site. You will want yacc if you are going to
Xdo any major additions to the source. There is nothing in the makefile
Xto install the man page, you will have to do that by hand.
X
XYou may find it useful for other things too, the verify "-v" option
Xhas possibilities, eg.:
X--------
X#
X# Mail list of meeting dates and times to users
X#
XSDATE="Monday 8" # The first meeting, next Monday at 8:00A
XUSERLIST=administrators
XSUBJECT=Meetings
XMESSAGE="Future meeting dates and times, please don't be late:\n"
X
X{
X echo $MESSAGE
X #
X # 6 monthly meetings, each on the day given in SDATE
X for OFFSET in 0 4 8 12 16 20
X do
X peg -v $SDATE + ${OFFSET}w
X done
X} | mail -s $SUBJECT $USERLIST
X--------
X
XPeg needs some way of recognizing dates that are holidays, so they can
Xbe skipped when the "-t" option is given. This is not covered in the
Xcurrent implementation. If someone cares to add this feature please
Xsend us the additions.
X
XThis was my first bout with yacc, and I'm sure there are better ways
Xto do what I did. Constructive criticism is welcome, send to:
X
Xuunet!mplex!ror
END_OF_FILE
if test 1460 -ne `wc -c <'README'`; then
echo shar: \"'README'\" unpacked with wrong size!
fi
# end of 'README'
fi
if test -f 'default.peg' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'default.peg'\"
else
echo shar: Extracting \"'default.peg'\" \(165 characters\)
sed "s/^X//" >'default.peg' <<'END_OF_FILE'
X#
X# NOUNPEG for a given tty will result in users NOT being unpegged
X# when they log on via that tty. Useful for modem lines.
X
X#NOUNPEG /dev/tty1A
XPEGDIR=/usr/spool
END_OF_FILE
if test 165 -ne `wc -c <'default.peg'`; then
echo shar: \"'default.peg'\" unpacked with wrong size!
fi
# end of 'default.peg'
fi
if test -f 'dot.pegrc' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'dot.pegrc'\"
else
echo shar: Extracting \"'dot.pegrc'\" \(57 characters\)
sed "s/^X//" >'dot.pegrc' <<'END_OF_FILE'
Xmon 8:30
Xtue 8:30
Xwed 8:30
Xthu 8:30
Xfri 8:30
Xsat -
Xsun -
END_OF_FILE
if test 57 -ne `wc -c <'dot.pegrc'`; then
echo shar: \"'dot.pegrc'\" unpacked with wrong size!
fi
# end of 'dot.pegrc'
fi
if test -f 'peg.h' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'peg.h'\"
else
echo shar: Extracting \"'peg.h'\" \(1322 characters\)
sed "s/^X//" >'peg.h' <<'END_OF_FILE'
X#include <stdio.h>
X#include <string.h>
X#include <pwd.h>
X#include <time.h>
X#include <signal.h>
X#include <fcntl.h>
X#include <ctype.h>
X#include <errno.h>
X
X#define HOMENV "HOME"
X#define PEGRCFN ".pegrc"
X#define PBFNM "pegboard"
X#define RCFNAM "/etc/default/peg"
X
X#define PBDIR "/usr/spool"
X#define TMPLATE "PEGCOPY.XXXXXX"
X#define PEGBOARD "/usr/spool/pegboard"
X#define PEGLOCK "/tmp/LCK.pegboard"
X#define OKCS \
X " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ +,~@0123456789"
X
Xtypedef void int;
X
Xvoid use ( );
Xvoid copytime( );
Xvoid dround ( );
Xvoid faterr ( );
Xvoid finit ( );
Xvoid specerr ( );
Xchar *igets ( );
Xchar *lows ( );
Xchar *getenv ( );
Xchar *ttyname( );
Xchar *fixargs( );
Xchar *malloc ( );
Xchar *mktemp ( );
Xint cleanup ( );
Xint chkpeg ( );
Xlong fixstrt ( );
Xlong fixday ( );
Xlong fixday ( );
Xlong fixhm ( );
Xlong fixymd ( );
Xlong time ( );
Xlong lseek ( );
Xstruct passwd *getpwuid( );
Xstruct passwd *getpwnam( );
Xstruct tm *localtime ( );
X
Xextern int opterr;
Xextern int optind;
Xextern int eod;
Xextern int admupd;
Xextern int quiet;
Xextern int vrbose;
Xextern int normpeg;
Xextern char lb[];
Xextern char *invkst;
Xextern char *pegfnm;
Xextern char *pegdir;
Xextern char *optarg;
Xextern char *sys_errlist[];
Xextern int sys_nerr;
Xextern int errno;
Xextern long duback;
Xextern long starts[];
Xextern struct tm today;
X
END_OF_FILE
if test 1322 -ne `wc -c <'peg.h'`; then
echo shar: \"'peg.h'\" unpacked with wrong size!
fi
# end of 'peg.h'
fi
if test -f 'peg.h.ansi' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'peg.h.ansi'\"
else
echo shar: Extracting \"'peg.h.ansi'\" \(1500 characters\)
sed "s/^X//" >'peg.h.ansi' <<'END_OF_FILE'
X#include <stdio.h>
X#include <string.h>
X#include <pwd.h>
X#include <time.h>
X#include <signal.h>
X#include <fcntl.h>
X#include <ctype.h>
X#include <errno.h>
X
X#define HOMENV "HOME"
X#define PEGRCFN ".pegrc"
X#define PBFNM "pegboard"
X#define RCFNAM "/etc/default/peg"
X
X#define PBDIR "/usr/spool"
X#define TMPLATE "PEGCOPY.XXXXXX"
X#define PEGBOARD "/usr/spool/pegboard"
X#define PEGLOCK "/tmp/LCK.pegboard"
X#define OKCS " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\
X+,~@0123456789"
X
Xvoid use ( );
Xvoid copytime( );
Xvoid dround ( long * );
Xvoid faterr ( char * );
Xvoid finit ( FILE *, char *[] );
Xvoid specerr ( char * );
Xchar *igets ( char [], int, int );
Xchar *lows ( char * );
Xchar *getenv ( char * );
Xchar *ttyname( int );
Xchar *fixargs( char *[] );
Xchar *malloc ( unsigned );
Xchar *mktemp ( char * );
Xint cleanup ( );
Xint chkpeg ( unsigned short );
Xlong fixstrt ( char * );
Xlong fixday ( long );
Xlong fixday ( long );
Xlong fixhm ( long, long );
Xlong fixymd ( long, long, long );
Xlong time ( long * );
Xlong lseek ( int, long, int );
Xstruct passwd *getpwuid( int );
Xstruct passwd *getpwnam( char * );
Xstruct tm *localtime ( long * );
X
Xextern int opterr;
Xextern int optind;
Xextern int eod;
Xextern int admupd;
Xextern int quiet;
Xextern int vrbose;
Xextern int normpeg;
Xextern char lb[];
Xextern char *invkst;
Xextern char *pegfnm;
Xextern char *pegdir;
Xextern char *optarg;
Xextern char *sys_errlist[];
Xextern int sys_nerr;
Xextern int errno;
Xextern long duback;
Xextern long starts[];
Xextern struct tm today;
X
END_OF_FILE
if test 1500 -ne `wc -c <'peg.h.ansi'`; then
echo shar: \"'peg.h.ansi'\" unpacked with wrong size!
fi
# end of 'peg.h.ansi'
fi
if test -f 'peg.man' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'peg.man'\"
else
echo shar: Extracting \"'peg.man'\" \(7450 characters\)
sed "s/^X//" >'peg.man' <<'END_OF_FILE'
X.tr _
X.TH PEG 1 "mplex"
X.SH NAME
X.I "peg"
X\- pegboard system
X.SH SYNTAX
X.RB peg
X[\-u|i
X.I user
X]
X[\-c
X.I text
X] [-lnqtvx] [+N[m|h|d|w] [H[:[M]][p]] [[[Y]/M]/D] [day] [month mday]
X.SH OPTIONS
X.TP 12
X.BR \-q
Xsuppress heading when reporting, suppress printing of date when updating
X.TP
X.BR \-u user
Xprint specific user's pegboard entry
X.TP
X.BR \-i user
X(interrogate) returns a value of 0 if the user is on the pegboard, 1 if not
X.TP
X.BR \-c text
Xmay be used to add a comment that is printed with the pegboard
X.TP
X.BR \-t
XLog off until tomorrow.
XThe file ".pegrc" in the invoking users home directory is consulted
Xto get the time of day the user starts work.
X.TP
X.BR \-v
XVerify only, with this option the time and date arguments are parsed and
Xthe target time is printed.
XThe pegboard is
X.B not
Xupdated nor is the invoker logged off.
X.TP
X.BR \-x
XRemove the invoking users peg.
XIt is not desirable for this option to work when
X.I peg
Xis invoked from
Xcertain ttys, specifically modems and some network ports.
XThis situation occurs when "peg -x" is put in the system
X.I .profile,
X(or equivalent) and a user dials in on a modem port.
XA facility is provided to avoid this in the file
X.I /etc/default/peg
X( see
X.BR FILES
Xheading below).
X.TP
X.BR \-n
Xdon't log off after updating pegboard
X.TP
X.BR \-l
XPrints long format
X.SH DESCRIPTION
X.I peg
Xmaintains a list of users who have logged off the system (a
X.I pegboard
X), and dates and times of when they intend return to the site.
XThe default action when no arguments are given is to print the
Xpegboard contents on standard output.
XThe -u option may be used to print the pegboard entry for a
Xspecific user.
X.P
XContext of arguments is dependent on their format.
XArguments that contain a "/" character are taken to be a date,
Xand one or two "/"'s may be present.
XIn the case of one, "MM/DD" is taken as a month and a day.
X"YY/MM/DD" is taken as year month and day.
X.P
XArguments that contain a ":" are taken as a time, and only one
X":" may be present.
X"HH:MM" is taken as hour and minute.
XA single argument is taken to be an hour in the current day.
XHours are in 24 hour format, unless the argument is suffixed with the
Xletter "p", in which case the time is assumed to be after 12 noon.
XFinally, a full date and time specification may be given by
Xproviding both arguments, in either order.
X.P
XNumeric arguments may be preceded by a "+", in this case
Xthe argument is taken as a "relative" quantity of time.
XThere may be an optional modifier after relative arguments,
Xlegal modifiers are "m", "h", "d" and "w".
X.TP
X.BR m
Xthe offset is taken as a number of minutes from the current time
X.TP
X.BR h
Xthe offset is taken as a number of hours from the current time (default)
X.TP
X.BR d
Xthe offset is taken as a number of days from the current date
X.TP
X.BR w
Xthe offset is taken as a number of weeks from the current date
X.P
XIf a modifier is not given and the argument is in "+n" format,
X"n" is assumed to be a number of hours from the current time
X(the h modifier is redundant).
X.P
XPeg recognizes names of days and months as well.
XMonth names must be followed by a day, ie. Sept 12.
XThe next occurrence of a day or month/day combination specified is assumed.
XSo specifying Tue on a Wednesday results in Tuesday of next week being
Xthe specified day.
XSimilarly, giving a month/day that has already gone by results in that day
Xin the next year being the specified date.
X.P
XAny (reasonable) number of arguments may be given.
XThe effect of multiple arguments is additive, so specifying more
Xthan one absolute date or time will not likely yield expected results.
XMixing one absolute date with some number of relative type arguments
Xhas the effect of adding the relative arguments to the absolute.
X.P
XAfter the pegboard is updated (and the -n, -x, -i or -v options
Xwere not given),
Xall processes in the process group are sent the signal SIGKILL.
X.P
X.I "peg"
Xshould be run with the "-x" option in the system
X.I .profile
Xso that each time the a user logs onto the system their pegboard entry
Xis expunged.
X.P
X.SH EXAMPLES
X.TP 20
X.BR "peg 99/1/12 14:00"
XLog off and peg invoking user to be back January 12, 1999, at 2:00 pm
X.TP 20
X.BR "peg 2:00p 99/1/12"
XSame as above
X.TP 20
X.BR "peg 3/10"
XLog off and peg invoking user to be back March 10 at the current time.
XIf March 10th has passed then March 10th next year is assumed.
X.TP 20
X.BR "peg +2"
XLog off and peg invoking user to be back 2 hours from current time
X.TP 20
X.BR "peg 2:00p"
XLog off and peg invoking user to be back at 2pm today
X.TP 20
X.BR "peg +45m"
XLog off and peg invoking user to be back 45 minutes from the current time
X.TP 20
X.BR "peg -t +3d"
XLog off and peg invoking user to be back 3 days from current date at the
Xtime found in the ".pegrc" file in their home directory
X.TP 20
X.BR "peg -t"
XLog off and and peg invoking user to be back on the next day and time that has
Xan entry in the ".pegrc" file.
XDays that have no entry will be skipped over.
X.TP 20
X.BR "peg -t 14"
XLog off and peg invoking user to be back 2:00 pm on the next day specified
Xin their
X.I .pegrc
Xfile.
X.TP 20
X.BR "peg -v +1 +1 +1"
Xprint what time it will be in three hours
X.P
X.SH FILES
X.TP
X.BR /etc/default/peg
X.TP
X.BR /$HOME/.pegrc
XThese files may have default start times for users in the format:
X.P
X.nf
X.sp
XMON 8:00
X.sp .5
XTUE 8:00
X.sp .5
X .
X.sp .5
X .
X.sp .5
X .
X.sp .5
XFRI 8:00
XSAT -
X.sp .5
XSUN -
X.fi
X.P
XIn addition,
X.I "/etc/default/peg"
Xshould contain entries of these formats:
X.P
X.nf
XPEGDIR /usr/spool
X.fi
X.P
XThis variable specifies the directory that peg uses for the pegboard.
XEach machine associated with a common pegboard should have
Xan "/etc/default/peg" file, specifying a common directory in
Xthe PEGDIR variable.
XThe pegbord file in the common directory must be readable and writable
Xby all users.
X.P
X.nf
X.sp .5
XNOUNPEG /dev/ttyxx
X.fi
X.P
X.P
XUsed to specify tty's that override the action of the
X.I "-x"
Xoption.
XIf peg is invoked from a tty that is listed thusly in
X.I "/etc/default/peg"
Xthen the program exits without updating the pegboard.
XPorts that are connected to modems should be listed in this manner.
X.TP 24
X.BR PEGDIR/pegboard.a*
Xholds a copy of the pegboard when update is in progress
X.TP 24
X.BR $HOME/.pegrc
Xdefault start time of day and days of week
X.TP 24
X.BR /etc/passwd
XUsernames etc. are extracted from this file.
XThe users name is assumed to be in the "gecos" field of the passwd entry
X.SH NOTES
XThe pegboard is maintained using
X.I "user id"
Xnumbers.
X.P
XOnly the first 3 letters of day and month names are significant.
X.P
XIf the real user id of the invoking user is 0 and the
X.I "-u"
Xcommand line option
Xis given then the specified users pegboard entry is updated to the date
Xgiven.
XIf the invoking user id is 0 and both the
X.I "-u"
Xand
X.I "-x"
Xoptions are given then the user name specified as the
X.I "-u"
Xargument is removed from the pegboard.
X.P
XWeek and month names etc. in the command line and tokens and variable names
Xin the
X.I ".pegrc"
Xand
X.I "/etc/default/peg"
Xfiles are
X.BR not
Xcase sensitive.
X.I Arguments
Xin the
X.I /etc/default/peg
Xand
X.I .pegrc
Xfiles
X.BR are
Xcase sensitive.
X.P
XComments are restricted to 64 characters, and must be whitespace or printable.
XThey are truncated to 32 characters in the short form to avoid
Xmessing up screens (assuming 80 column ttys).
XThe complete comment may be read by invoking with the "-l" option.
X.P
XIf no PEGDIR variable is found in the
X.I /etc/default/peg
Xfile then the default directory used is
X.I /usr/spool.
X
END_OF_FILE
if test 7450 -ne `wc -c <'peg.man'`; then
echo shar: \"'peg.man'\" unpacked with wrong size!
fi
# end of 'peg.man'
fi
if test -f 'peg.y' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'peg.y'\"
else
echo shar: Extracting \"'peg.y'\" \(7896 characters\)
sed "s/^X//" >'peg.y' <<'END_OF_FILE'
X%{
X/*
X peg.y
X
X Copyright 1989 RFM Microplex Systems Ltd.
X RFM Microplex Systems Ltd.
X 265 E. 1st Ave.
X Vancouver, B.C. CANADA
X V5T 1A7
X (604)875-1461
X Fax: (604)875-9029
X Email: uunet!mplex!ror
X
X These documents are copyrighted. However, they may be distributed freely
X as long as the following is understood and followed:
X
X A; They may not be distributed for financial or other gain under any
X circumstances.
X B; The author(s) and RFM Microplex Systems Ltd. will not be held liable
X for any damage or loss of data arising from their use
X C; Anyone who applies improvements or "bug fixes" shall make an attempt
X to return these changes to the author listed above
X D. This copyright applies to all of the documents listed below, and any
X other information created by compilers or other programs that are
X applied to them:
X peg.man peg.y tfix.c peg.h pegio.c
X*/
X#include "peg.h"
X
X#define YYSTYPE long
X
Xchar *invkst; /* Name of the executable */
Xchar *pegdir; /* Directory name for various files */
Xchar *pegfnm; /* File name where pegs go */
Xchar *comment; /* User's reason for leaving, if given */
Xchar lb[BUFSIZ]; /* Lines for yylex */
Xint chk; /* Check run only */
Xint eod; /* Log off till tomorrow */
Xint admupd; /* Administrator updating mortals peg */
Xint quiet; /* No header, don't print time when done */
Xint vrbse; /* Verbose output (this is not the opposite of quiet) */
Xint normpeg; /* Set if login tty is on no pegout list */
X/*
X Start times for invoking user stored here by rcinit
X*/
Xlong starts [] = { -1, -1, -1, -1, -1, -1, -1 };
Xlong int duback; /* Running count in seconds of the date determined */
Xstruct tm today; /* */
Xstruct tm *s;
X%}
X%token NUMBER
X%right ':'
X%left '+'
X%right '/'
X%right 'p'
X%%
Xnothing:
X | nothing expr
X ;
Xexpr: NUMBER {
X $$ = fixhm( $1, 0L );
X }
X | NUMBER ':' NUMBER {
X $$ = fixhm( $1, $3 );
X }
X | NUMBER ':' NUMBER 'p' {
X $$ = fixhm( $1 < 12 ? $1 + 12 : $1 , $3 );
X }
X | NUMBER '/' NUMBER {
X $$ = fixymd(
X (( $1 < today.tm_mon + 1 ||
X ( $1 == today.tm_mon + 1 && $3 < today.tm_mday ))
X ? (long)today.tm_year + 1 : (long)today.tm_year ), $1 , $3 );
X }
X | NUMBER '/' NUMBER '/' NUMBER {
X $$ = fixymd( $1, $3 , $5 );
X }
X | NUMBER 'p' {
X $$ = fixhm( $1 < 12 ? $1 + 12 : $1 , 0L );
X }
X
X | '+' NUMBER {
X s = localtime( &duback );
X $$ = fixhm( (long)s->tm_hour + $2, (long)s->tm_min );
X }
X | '+' NUMBER 'h' {
X s = localtime( &duback );
X $$ = fixhm( (long)s->tm_hour + $2, (long)s->tm_min );
X }
X | '+' NUMBER 'm' {
X s = localtime( &duback );
X $$ = fixhm( (long)s->tm_hour, (long)s->tm_min + $2 );
X }
X | '+' NUMBER 'd' {
X $$ = fixday( $2 );
X }
X | '+' NUMBER 'w' {
X $$ = fixday( $2 * 7L );
X }
X ;
X%%
X/*
X BUGS TO FIX:
X none (ha)
X*/
X
Xmain( argc, argv )
Xint argc;
Xchar *argv[];
X{
X extern struct tm today;
X extern long duback;
X extern char lb[];
X extern char *pegfnm;
X extern char *pegdir;
X extern char *invkst;
X extern char *optarg;
X extern char *sys_errlist[];
X extern int sys_nerr;
X extern int errno;
X extern int eod;
X extern int vrbse;
X extern int admupd;
X struct passwd *rpu = NULL;
X int i;
X int exp = 0;
X extern int chk;
X extern int normpeg;
X int logout = 1;
X
X invkst = (( strrchr( argv[0], '/' ) == NULL )
X ? argv[0] : strrchr( argv[0], '/' ) + 1 );
X /*
X Read "rc" files
X */
X pegfnm = NULL;
X comment = NULL;
X pegdir = NULL;
X rcinit( );
X
X# define LGLOPTS "c:i:u:lnqtvx"
X opterr=0;
X while(( i = getopt( argc, argv, LGLOPTS )) != EOF ) {
X switch( i ) {
X /*
X Suppress start time rounding
X */
X case 't':
X eod++;
X break;
X /*
X Peg invoking user as back at site (delete pegboard entry)
X */
X case 'x':
X exp++;
X break;
X /*
X Report due back date for specified userm unless invoker
X is root. If root then diddle other users peg
X */
X case 'u':
X if( ! getuid( )) {
X if( setuid( getpwnam( optarg )->pw_uid ))
X faterr( "setuid call failed" );
X admupd++;
X break;
X }
X if(( rpu = getpwnam( optarg )) == NULL )
X fprintf( stderr,
X "\n%s: user \"%.*s\" not found\n",
X invkst, strspn( optarg, OKCS ), optarg );
X break;
X /*
X Don't log the user off after updtaing pegboard
X */
X case 'n':
X logout = 0;
X break;
X /*
X Supress printing of header and time
X */
X case 'q':
X quiet = ( ! quiet );
X break;
X /*
X Check run only, no update, no logout
X */
X case 'v':
X chk++;
X break;
X /*
X Print long format
X */
X case 'l':
X vrbse++;
X break;
X /*
X Read comment
X */
X case 'c':
X comment = ( strlen( optarg ) > BUFSIZ ? "" : optarg );
X break;
X /*
X Interrogate pegboard. Return 0 if invoker pegged.
X */
X case 'i':
X if( ! *optarg )
X exit( 1 );
X exit( chkpeg( getpwnam( optarg )->pw_uid ));
X
X case '?':
X default:
X fprintf( stderr,
X "\n%s: Unrecognized option \"%c\"\n",
X invkst, i );
X use( ); /* Exits */
X } /* End of switch */
X } /* End of while */
X
X if( ! normpeg && exp ) {
X upddbdf( getuid( ), 1 );
X exit( 0 );
X }
X if ( exp )
X exit( 0 );
X
X /* Report for specific user */
X if( rpu != NULL) {
X report( rpu->pw_uid, quiet );
X exit( 0 );
X }
X
X if((( argc - optind ) < 1 ) && ( ! eod )) {
X /* No arguments, report all pegged users */
X report( 0, quiet );
X exit( 0 );
X }
X
X lb[0] = '\0';
X fixargs( &argv[optind] );
X if(( ! lb[0] ) && eod )
X sprintf( lb, "+1d" );
X time( &duback );
X copytime( localtime( &duback ), &today );
X
X yyparse( );
X
X if( chk ) {
X showtime( &duback );
X exit( 0 );
X }
X /*
X Update the pegboard. If it fails then don't die.
X */
X if( upddbdf( getuid( ), 0 ))
X logout = 0;
X /*
X Don't die if root
X */
X if( ! getuid( ) || admupd )
X exit( 0 );
X
X if( logout )
X kill( -1, SIGKILL );
X exit( 0 );
X}
X
Xyylex( )
X{
X static char *lp;
X static int init=1;
X char copy[ BUFSIZ ];
X int lah1;
X int lah2;
X extern char lb[];
X
X if( init ) {
X init=( ! init );
X lp = lb;
X }
X
X while( *lp == ' ' || *lp == '\t' )
X lp++;
X if( ! *lp || *lp == '\n' )
X return( 0 );
X if( isdigit( *lp )) {
X sscanf( lp, "%ld", &yylval );
X lp = ( lp + strspn( lp, "0123456789" ));
X return( NUMBER );
X }
X /*
X Look for a literal month name and day number
X */
X if(( lah1 = ismonth( lp ))) {
X do {
X if( ! *lp++ )
X specerr( "month name must be followed by day of month" );
X } while ( ! isdigit( *lp ));
X
X sscanf( lp, "%d", &lah2 );
X
X lp = strpbrk( lp, " \t\n" ); /* SP, TAB, NL */
X strcpy( copy, lp ); /* If this is NULL that's exactly what we want */
X if(( lah1 - 1 ) < today.tm_mon ||
X (( lah1 - 1 ) == today.tm_mon && lah2 < today.tm_mday ))
X sprintf( lp, "%d/%d/%d %s", today.tm_year + 1, lah1, lah2, copy );
X else
X sprintf( lp, "%d/%d/%d %s", today.tm_year, lah1, lah2, copy );
X sscanf( lp, "%ld", &yylval );
X lp = strchr( lp, '/' );
X return( NUMBER );
X }
X if(( lah1 = isday( lp )) != (-1)) {
X lp = strpbrk( lp, " \t\n" ); /* SP, TAB, NL */
X strcpy( copy, lp ); /* If this is NULL that's exactly what we want */
X if( lah1 < today.tm_wday )
X lah1 += 7;
X lah1 -= today.tm_wday;
X sprintf( lp, "+%dd %s", lah1, copy );
X }
X return( (int)*lp++ );
X}
X
X/*
X Consolidate string list
X*/
Xchar *fixargs( ss )
Xchar **ss;
X{
X extern char lb[];
X
X while( **ss ) {
X strcat( lb, *ss++ );
X if(( strlen( lb )) >= BUFSIZ )
X specerr( "argument string to long" );
X strcat( lb, " " );
X }
X return( lows( lb ));
X}
X
X/*
X Make s lowercase.
X*/
Xchar *lows( s )
Xchar *s;
X{
X int i;
X
X for( i = 0 ; s[i] ; i++ )
X s[i] = tolower( s[i] );
X return( s );
X}
X
Xyyerror( m )
Xchar *m;
X{
X specerr(m);
X}
X
Xvoid specerr( m )
Xchar *m;
X{
X extern char *invkst;
X
X fprintf( stderr,
X "\n%s: Bad specification (%.*s)\n",
X invkst, strspn( m, OKCS ), m );
X use( );
X}
X
Xvoid use( s )
Xchar *s;
X{
X extern char *invkst;
X
X /* LGLOPTS "tc:xu:vnqli:" */
X fprintf( stderr,
X "\n%s: maintains an \"on-line pegboard\"\n", invkst );
X fprintf( stderr,
X "use: %s [-u|i user -c \"comment\" [-qnxtvl] [date time]\n", invkst );
X
X exit( 1 );
X}
END_OF_FILE
if test 7896 -ne `wc -c <'peg.y'`; then
echo shar: \"'peg.y'\" unpacked with wrong size!
fi
# end of 'peg.y'
fi
if test -f 'pegboard.hdr' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'pegboard.hdr'\"
else