1: /* string extraction/restoration routines */
   2: 
   3: #define BUFLEN 256
   4: #include "sendmail.h"
   5: #include <varargs.h>
   6: 
   7: char    *StringFile =   "/usr/share/misc/sendmail.sr";  /* extracted string storage */
   8: static int strfile = -1, ourpid = 0;
   9: 
  10: errprep(offset, buf)
  11: unsigned short offset;
  12: char *buf;
  13: {
  14: register int pid = getpid();
  15: 
  16:     if (pid != ourpid) {
  17:         ourpid = pid;
  18:         if (strfile >= 0) {
  19:             close(strfile);
  20:             strfile = -1;
  21:         }
  22:     }
  23:     if (strfile < 0) {
  24:         strfile = open(StringFile, 0);
  25:         if (strfile < 0) {
  26: oops:
  27:             QuickAbort++;
  28:             syserr("Cannot find strings");
  29:         }
  30:     }
  31:     if (lseek(strfile, (long) offset, 0) < 0
  32:             || read(strfile, buf, BUFLEN) <= 0)
  33:         goto oops;
  34: }
  35: 
  36: /* extracted string front end for printf() */
  37: /*VARARGS1*/
  38: strprerror(fmt, va_alist)
  39:     int fmt;
  40:     va_dcl
  41: {
  42:     va_list ap;
  43:     char buf[BUFLEN];
  44: 
  45:     errprep(fmt, buf);
  46:     va_start(ap);
  47:     vprintf(buf, ap);
  48:     va_end(ap);
  49: }
  50: 
  51: /* extracted string front end for sprintf() */
  52: /*VARARGS1*/
  53: strsrerror(fmt, obuf, va_alist)
  54:     int fmt;
  55:     char *obuf;
  56:     va_dcl
  57: {
  58:     char buf[BUFLEN];
  59:     va_list ap;
  60: 
  61:     errprep(fmt, buf);
  62:     va_start(ap);
  63:     vsprintf(obuf, buf, ap);
  64:     va_end(ap);
  65: }
  66: 
  67: /* extracted string front end for fprintf() */
  68: /*VARARGS1*/
  69: strfrerror(fmt, fd, va_alist)
  70:     int fmt, fd;
  71:     va_dcl
  72: {
  73:     va_list ap;
  74:     char buf[BUFLEN];
  75: 
  76:     errprep(fmt, buf);
  77:     va_start(ap);
  78:     vfprintf(fd, buf, ap);
  79:     va_end(ap);
  80: }
  81: 
  82: /* extracted string front end for syslog() */
  83: /*VARARGS1*/
  84: slogerror(fmt, pri, a, b, c, d, e)
  85:     int fmt, pri;
  86: {
  87:     char buf[BUFLEN];
  88: 
  89:     errprep(fmt, buf);
  90:     syslog(pri, buf, a, b, c, d, e);
  91: }
  92: 
  93: /* extracted string front end for syserr() */
  94: /*VARARGS1*/
  95: syserror(fmt, a, b, c, d, e)
  96:     int fmt;
  97: {
  98:     char buf[BUFLEN];
  99:     extern int errno;
 100:     register int olderrno = errno;
 101: 
 102:     errprep(fmt, buf);
 103:     errno = olderrno;
 104:     syserr(buf, a, b, c, d, e);
 105: }
 106: 
 107: /* extracted string front end for usrerr() */
 108: /*VARARGS1*/
 109: usrerror(fmt, a, b, c, d, e)
 110:     int fmt;
 111: {
 112:     char buf[BUFLEN];
 113:     extern int errno;
 114:     register int olderrno = errno;
 115: 
 116:     errprep(fmt, buf);
 117:     errno = olderrno;
 118:     usrerr(buf, a, b, c, d, e);
 119: }
 120: 
 121: /* extracted string front end for nmessage() */
 122: /*VARARGS2*/
 123: nmesserror(fmt, num, a, b, c, d, e)
 124:     int fmt;
 125:     char *num;
 126: {
 127:     char buf[BUFLEN];
 128: 
 129:     errprep(fmt, buf);
 130:     nmessage(num, buf, a, b, c, d, e);
 131: }
 132: /* extracted string front end for message() */
 133: /*VARARGS2*/
 134: messerror(fmt, num, a, b, c, d, e)
 135:     int fmt;
 136:     char *num;
 137: {
 138:     char buf[BUFLEN];
 139: 
 140:     errprep(fmt, buf);
 141:     message(num, buf, a, b, c, d, e);
 142: }

Defined functions

errprep defined in line 10; used 8 times
messerror defined in line 134; never used
nmesserror defined in line 123; never used
slogerror defined in line 84; never used
strfrerror defined in line 69; never used
strprerror defined in line 38; never used
strsrerror defined in line 53; never used
syserror defined in line 95; never used
usrerror defined in line 109; never used

Defined variables

StringFile defined in line 7; used 1 times
  • in line 24
strfile defined in line 8; used 8 times

Defined macros

BUFLEN defined in line 3; used 9 times
Last modified: 1996-10-25
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 3193
Valid CSS Valid XHTML 1.0 Strict