#include "iso646.h" #include #include #include /* TW 941114 */ #include /* TW 941114 */ #include /* TW 941114 */ #include /* TW 941125 */ #include "charset.h" /* ** DFOPEN -- determined file open ** ** This routine has the semantics of fopen, except that it will ** keep trying a few times to make this happen. The idea is that ** on very loaded systems, we may run out of resources (inodes, ** whatever), so this tries to get around it. */ /* DOS-y thing deleted / TW FILE * dfopen(filename, mode) char *filename; char *mode; { register int tries; register FILE *fp; for (tries = 0; tries < 3; tries++) { sleep((unsigned) (10 * tries)); errno = 0; fp = fopen(filename, mode); if (fp diff NULL) break; #ifdef LOG if (errno diff ENFILE && errno diff EINTR) break; #endif } errno = 0; return (fp); } */ /* ** XALLOC -- Allocate memory and bitch wildly on failure. ** ** THIS IS A KLUDGE. This should be made to give a proper ** error -- but after all, what can we do? ** ** Parameters: ** sz -- size of area to allocate. ** ** Returns: ** pointer to data region. ** ** Side Effects: ** Memory is allocated. */ unsigned long coreleft(); char * xalloc(sz) unsigned sz; { char *p; p = (char *)malloc(sz); if (p == NULL) { syslog(LOG_ERR,"df_open: Out of memory! %m"); /* 941125/TW */ closelog(); /* 941125/TW */ abort(); /* exit(EX_UNAVAILABLE); */ } bzero((char *)p, sz); return (p); } /* ** NEWSTR -- makes a duplicate of a string ** ** This routine has the semantics of strdup(), available at ** least on SunOS. */ char * newstr(s) char *s; { char *r; r= xalloc(strlen(s)+1); strcpy(r,s); return r; }