1: /*
2: * This software is Copyright (c) 1986 by Rick Adams.
3: *
4: * Permission is hereby granted to copy, reproduce, redistribute or
5: * otherwise use this software as long as: there is no monetary
6: * profit gained specifically from the use or reproduction or this
7: * software, it is not sold, rented, traded or otherwise marketed, and
8: * this copyright notice is included prominently in any copy
9: * made.
10: *
11: * The author make no claims as to the fitness or correctness of
12: * this software for any use whatsoever, and it is provided as is.
13: * Any use of this software is at the user's own risk.
14: *
15: * This routine is compatible with the Unix T/S system call uname,
16: * which figures out the name of the local system.
17: * However, we do it by reading the file /usr/include/whoami.h.
18: * This avoids having to recompile uucp for each site and hence
19: * avoids having to distribute the source to uucp to people who
20: * have only binary licenses.
21: */
22:
23: #ifdef SCCSID
24: static char *SccsId = "@(#)uname.c 2.9.1 12/31/93";
25: #endif /* SCCSID */
26:
27: #include <stdio.h>
28: #include "../common/conf.h"
29:
30: #ifdef UNAME
31: # define DONE
32: #endif /* UNAME */
33:
34: #ifdef GHNAME
35: uname(uptr)
36: char *uptr;
37: {
38: gethostname(uptr, 256);
39: }
40: # define DONE
41: #endif
42:
43: #ifdef UUNAME
44: uname(uptr)
45: char *uptr;
46: {
47: FILE *uucpf;
48: register char *p;
49: /* uucp name is stored in /etc/uucpname or /local/uucpname */
50:
51: if (((uucpf = fopen("/etc/uucpname", "r")) == NULL &&
52: (uucpf = fopen("/local/uucpname", "r")) == NULL) ||
53: fgets(uptr, 256, uucpf) == NULL) {
54: fprintf(stderr, "no sysname in %s\n", "/etc/uucpname");
55: return;
56: }
57: p = index(uptr, '\n');
58: if (p)
59: *p = '\0';
60: if (uucpf != NULL)
61: fclose(uucpf);
62: }
63: #define DONE
64: #endif /* UUNAME */
65:
66: #ifndef DONE
67: #define HDRFILE "/usr/include/whoami.h"
68:
69: uname(uptr)
70: char *uptr;
71: {
72: char buf[BUFSIZ];
73: FILE *fd;
74:
75: fd = fopen(HDRFILE, "r");
76: if (fd == NULL) {
77: fprintf(stderr, "Cannot open %s\n", HDRFILE);
78: exit(1);
79: }
80:
81: for (;;) { /* each line in the file */
82: if (fgets(buf, sizeof buf, fd) == NULL) {
83: fprintf(stderr, "no sysname in %s\n", HDRFILE);
84: fclose(fd);
85: exit(2);
86: }
87: if (sscanf(buf, "#define sysname \"%[^\"]\"", uptr) == 1) {
88: fclose(fd);
89: return;
90: }
91: }
92: }
93: #endif
Defined functions
uname
defined in line
69; used 1 times
Defined variables
Defined macros
DONE
defined in line
63; used 1 times