1: #ifndef lint
   2: static char sccsid[] = "@(#)systat.c	5.1 (Berkeley) 7/2/83";
   3: #endif
   4: 
   5: #include "uucp.h"
   6: #include <sys/types.h>
   7: 
   8: extern  time_t  time();
   9: 
  10: #define STATNAME(f, n) sprintf(f, "%s/%s.%.7s", Spool, "STST", n)
  11: #define S_SIZE 100
  12: 
  13: /*******
  14:  *	systat(name, type, text)	make system status entry
  15:  *	char *name, *text;
  16:  *	int type.
  17:  *
  18:  *	return codes:  none
  19:  */
  20: 
  21: systat(name, type, text)
  22: char *name, *text;
  23: int type;
  24: {
  25:     char filename[MAXFULLNAME], line[S_SIZE];
  26:     int count;
  27:     register FILE *fp;
  28:     time_t prestime;
  29: 
  30:     if (type == 0)
  31:         return;
  32:     line[0] = '\0';
  33:     time(&prestime);
  34:     count = 0;
  35:     STATNAME(filename, name);
  36: 
  37:     fp = fopen(filename, "r");
  38:     if (fp != NULL) {
  39:         fgets(line, S_SIZE, fp);
  40:         sscanf(&line[2], "%d", &count);
  41:         if (count <= 0)
  42:             count = 0;
  43:         fclose(fp);
  44:     }
  45: 
  46:     if (type == SS_FAIL)
  47:         count++;
  48: 
  49:     fp = fopen(filename, "w");
  50:     ASSERT(fp != NULL, "SYSTAT OPEN FAIL", "", 0);
  51: /*	chmod(filename, 0666); rm-ed by rti!trt */
  52:     fprintf(fp, "%d %d %ld %ld %s %s\n", type, count, prestime, Retrytime, text, name);
  53:     fclose(fp);
  54:     return;
  55: }
  56: 
  57: /***
  58:  *	rmstat(name)	remove system status entry
  59:  *	char *name;
  60:  *
  61:  *	return codes:  none
  62:  */
  63: 
  64: rmstat(name)
  65: char *name;
  66: {
  67:     char filename[MAXFULLNAME];
  68: 
  69:     STATNAME(filename, name);
  70:     unlink(filename);
  71: }
  72: 
  73: /***
  74:  *	callok(name)	check system status for call
  75:  *	char *name;
  76:  *
  77:  *	return codes  0 - ok | >0 system status
  78:  */
  79: 
  80: callok(name)
  81: char *name;
  82: {
  83:     char filename[MAXFULLNAME], line[S_SIZE];
  84:     register FILE *fp;
  85:     time_t lasttime, prestime;
  86:     long retrytime;
  87:     int count, type;
  88: 
  89:     STATNAME(filename, name);
  90:     fp = fopen(filename, "r");
  91:     if (fp == NULL)
  92:         return(SS_OK);
  93: 
  94:     if (fgets(line, S_SIZE, fp) == NULL) {
  95:         /*  no data  */
  96:         fclose(fp);
  97:         unlink(filename);
  98:         return(SS_OK);
  99:     }
 100: 
 101:     fclose(fp);
 102:     time(&prestime);
 103:     sscanf(line, "%d%d%ld%ld", &type, &count, &lasttime, &retrytime);
 104: 
 105:     switch(type) {
 106:     case SS_BADSEQ:
 107:     case SS_CALLBACK:
 108:     case SS_NODEVICE:
 109:     case SS_INPROGRESS: /*let LCK take care of it */
 110:         return(SS_OK);
 111: 
 112:     case SS_FAIL:
 113:         if (count > MAXRECALLS) {
 114:             logent("MAX RECALLS", "NO CALL");
 115:             DEBUG(4, "MAX RECALL COUNT %d\n", count);
 116:             return(type);
 117:         }
 118: 
 119:         if (prestime - lasttime < retrytime) {
 120:             logent("RETRY TIME NOT REACHED", "NO CALL");
 121:             DEBUG(4, "RETRY TIME (%d) NOT REACHED\n", (long)  RETRYTIME);
 122:             return(type);
 123:         }
 124: 
 125:         return(SS_OK);
 126:     default:
 127:         return(SS_OK);
 128:     }
 129: }

Defined functions

callok defined in line 80; used 3 times
rmstat defined in line 64; used 2 times
systat defined in line 21; used 9 times

Defined variables

sccsid defined in line 2; never used

Defined macros

STATNAME defined in line 10; used 3 times
S_SIZE defined in line 11; used 4 times
Last modified: 1983-07-03
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 804
Valid CSS Valid XHTML 1.0 Strict