|
|
1.1 root 1: #include "defs.h"
2: #include <stdio.h>
3:
4: /* imported */
5: char *malloc();
6: char *strcpy();
7: char *strcat();
8:
9: /* get the system name */
10: char *
11: getsysname()
12: {
13: int i, fd;
14: char *cp;
15: static char name[DKNAMELEN+1];
16:
17: /* read the system name */
18: fd = open("/etc/whoami", 0);
19: if (fd < 0)
20: return (NULL);
21: i = read(fd, name, DKNAMELEN);
22: if (i <= 0) {
23: return (NULL);
24: }
25: (void)close (fd);
26: name[i] = NULL;
27: for (cp = name; *cp != 0 && *cp != '\n'; cp++);
28: *cp = NULL;
29: return (name);
30: }
31:
32:
33: /* make a name from the given system name and suffix */
34: char *
35: sname(sysname, generic)
36: char *sysname;
37: char *generic;
38: {
39: static char name[DKNAMELEN+1];
40: int i,j;
41:
42: i = strlen(sysname);
43: j = strlen (generic);
44: if (i+j > DKNAMELEN) {
45: if (j >= DKNAMELEN)
46: return (NULL);
47: for (i = 0, j = DKNAMELEN - j; i <= j; i++) {
48: name[i] = sysname[i];
49: }
50: name[i] = 0;
51: } else {
52: (void)strcpy (name, sysname);
53: }
54: (void)strcat (name, generic);
55: return (name);
56: }
57:
58: /* ealloc with error reporting */
59: char *
60: ealloc(size)
61: int size;
62: {
63: char *ptr;
64:
65: ptr = malloc ((unsigned)size);
66: if (ptr == NULL) {
67: perror ("ealloc");
68: exit(-1);
69: }
70: return (ptr);
71: }
72:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.