1: /*
   2:  *                     Logging of RCS commands co and ci
   3:  */
   4: #ifndef lint
   5:  static char rcsid[]=
   6:  "$Header: /usr/src/local/bin/rcs/src/RCS/snoop.c,v 4.3 87/12/18 11:46:52 narten Exp $ Purdue CS";
   7: #endif
   8: /*******************************************************************
   9:  * This program appends argv[1] to the file SNOOPFILE.
  10:  * To avoid overlaps, it creates a lockfile with name lock in the same
  11:  * directory as SNOOPFILE. SNOOPFILE must be defined in the cc command.
  12:  * Prints an error message if lockfile doesn't get deleted after
  13:  * MAXTRIES tries.
  14:  *******************************************************************
  15:  *
  16:  * Copyright (C) 1982 by Walter F. Tichy
  17:  *                       Purdue University
  18:  *                       Computer Science Department
  19:  *                       West Lafayette, IN 47907
  20:  *
  21:  * All rights reserved. No part of this software may be sold or distributed
  22:  * in any form or by any means without the prior written permission of the
  23:  * author.
  24:  * Report problems and direct all inquiries to Tichy@purdue (ARPA net).
  25:  */
  26: 
  27: 
  28: /* $Log:	snoop.c,v $
  29:  * Revision 4.3  87/12/18  11:46:52  narten
  30:  * more lint cleanups (Guy Harris)
  31:  *
  32:  * Revision 4.2  87/10/18  10:41:47  narten
  33:  * Changing version numbers. Changes relative to 1.1 actually relative to
  34:  * 4.1
  35:  *
  36:  * Revision 1.2  87/09/24  14:01:41  narten
  37:  * Sources now pass through lint (if you ignore printf/sprintf/fprintf
  38:  * warnings)
  39:  *
  40:  * Revision 1.1  84/01/23  14:50:49  kcs
  41:  * Initial revision
  42:  *
  43:  * Revision 4.1  83/03/28  13:23:42  wft
  44:  * No change; just new revision number.
  45:  *
  46:  * Revision 3.2  82/12/04  17:14:31  wft
  47:  * Added rcsbase.h, changed SNOOPDIR to SNOOPFILE, reintroduced
  48:  * error message in case of permanent locking.
  49:  *
  50:  * Revision 3.1  82/10/18  21:22:03  wft
  51:  * Number of polls now 20, no error message if critical section can't
  52:  * be entered.
  53:  *
  54:  * Revision 2.3  82/07/01  23:49:28  wft
  55:  * changed copyright notice only.
  56:  *
  57:  * Revision 2.2  82/06/03  20:00:10  wft
  58:  * changed name from rcslog to snoop, replaced LOGDIR with SNOOPDIR.
  59:  *
  60:  * Revision 2.1  82/05/06  17:55:54  wft
  61:  * Initial revision
  62:  *
  63:  */
  64: 
  65: 
  66: #include "rcsbase.h"
  67: #define fflsbuf _flsbuf
  68: /* undo redefinition of putc in rcsbase.h */
  69: 
  70: char  lockfname[NCPPN];
  71: FILE * logfile;
  72: int lockfile;
  73: 
  74: #define MAXTRIES 20
  75: 
  76: main(argc,argv)
  77: int argc; char * argv[];
  78: /* writes argv[1] to SNOOPFILE and appends a newline. Invoked as follows:
  79:  * rcslog logmessage
  80:  */
  81: {       int tries;
  82:         register char * lastslash, *sp;
  83: 
  84:         VOID strcpy(lockfname,(char *) SNOOPFILE);
  85:         lastslash = sp = lockfname;
  86:         while (*sp) if (*sp++ =='/') lastslash=sp; /* points beyond / */
  87:         VOID strcpy(lastslash,",lockfile");
  88:         tries=0;
  89:         while (((lockfile=creat(lockfname, 000)) == -1) && (tries<=MAXTRIES)) {
  90:                 tries++;
  91:                 sleep(5);
  92:         }
  93:         if (tries<=MAXTRIES) {
  94:                 VOID close(lockfile);
  95:                 if ((logfile=fopen(SNOOPFILE,"a")) ==NULL) {
  96:                         VOID fprintf(stderr,"Can't open logfile %s\n",SNOOPFILE);
  97:                 } else {
  98:                         VOID fputs(argv[1],logfile);
  99:                         VOID putc('\n',logfile);
 100:                         VOID fclose(logfile);
 101:                 }
 102:                 VOID unlink(lockfname);
 103:         } else {
 104:                 VOID fprintf(stderr,"RCS logfile %s seems permanently locked.\n",SNOOPFILE);
 105:                 VOID fprintf(stderr,"Please alert system administrator\n");
 106:         }
 107: }

Defined functions

main defined in line 76; never used

Defined variables

lockfile defined in line 72; used 2 times
lockfname defined in line 70; used 4 times
rcsid defined in line 5; never used

Defined macros

MAXTRIES defined in line 74; used 2 times
fflsbuf defined in line 67; never used
Last modified: 1988-02-18
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 657
Valid CSS Valid XHTML 1.0 Strict