version 1.4, 1999/08/27 08:43:22 |
version 1.5, 1999/09/21 13:15:43 |
|
|
#include <stdlib.h> |
#include <stdlib.h> |
#include <string.h> |
#include <string.h> |
#include "pathnames.h" |
#include "pathnames.h" |
|
#include "extern.h" |
|
|
extern char *archive; /* archive name */ |
char *tname = "temporary file"; |
char *tname = "temporary file"; |
|
|
|
|
int |
tmp() |
tmp() |
{ |
{ |
static char *envtmp; |
static char *envtmp; |
|
|
(void)sigprocmask(SIG_BLOCK, &set, &oset); |
(void)sigprocmask(SIG_BLOCK, &set, &oset); |
if ((fd = mkstemp(path)) == -1) |
if ((fd = mkstemp(path)) == -1) |
error(tname); |
error(tname); |
(void)unlink(path); |
(void)unlink(path); |
(void)sigprocmask(SIG_SETMASK, &oset, (sigset_t *)NULL); |
(void)sigprocmask(SIG_SETMASK, &oset, (sigset_t *)NULL); |
return(fd); |
return(fd); |
} |
} |
|
|
void * |
void * |
emalloc(len) |
emalloc(len) |
int len; |
size_t len; |
{ |
{ |
char *p; |
void *p; |
|
|
if (!(p = malloc((u_int)len))) |
if (!(p = malloc(len))) |
error(archive); |
error(archive); |
return(p); |
return(p); |
} |
} |
|
|
char * |
const char * |
rname(path) |
rname(path) |
char *path; |
const char *path; |
{ |
{ |
register char *ind; |
register const char *ind; |
|
|
return((ind = strrchr(path, '/')) ? ind + 1 : path); |
return((ind = strrchr(path, '/')) ? ind + 1 : path); |
} |
} |
|
|
|
void |
badfmt() |
badfmt() |
{ |
{ |
errno = EFTYPE; |
errno = EFTYPE; |
error(archive); |
error(archive); |
} |
} |
|
|
|
void |
error(name) |
error(name) |
char *name; |
const char *name; |
{ |
{ |
(void)fprintf(stderr, "ranlib: %s: %s\n", name, strerror(errno)); |
|
exit(1); |
err(1, "%s", name); |
} |
} |