Annotation of researchv10no/cmd/netnews/src/uname.c, revision 1.1

1.1     ! root        1: /*
        !             2:  * This routine is compatible with the Unix T/S system call uname,
        !             3:  * which figures out the name of the local system.
        !             4:  * However, we do it by reading the file /usr/include/whoami.h.
        !             5:  * This avoids having to recompile uucp for each site and hence
        !             6:  * avoids having to distribute the source to uucp to people who
        !             7:  * have only binary licenses.
        !             8:  */
        !             9: 
        !            10: static char *SccsId = "@(#)uname.c     2.4     5/3/83";
        !            11: 
        !            12: #include "params.h"
        !            13: 
        !            14: 
        !            15: #ifdef UNAME
        !            16: # define DONE
        !            17: #endif
        !            18: 
        !            19: #ifdef GHNAME
        !            20: uname(uptr)
        !            21: struct utsname *uptr;
        !            22: {
        !            23:        gethostname(uptr->nodename, sizeof (uptr->nodename));
        !            24: }
        !            25: # define DONE
        !            26: #endif
        !            27: 
        !            28: #ifndef DONE
        !            29: #define        HDRFILE "/etc/whoami.h"
        !            30: 
        !            31: uname(uptr)
        !            32: struct utsname *uptr;
        !            33: {
        !            34:        char buf[BUFSIZ];
        !            35:        FILE *fd;
        !            36:        
        !            37:        fd = fopen(HDRFILE, "r");
        !            38:        if (fd == NULL) {
        !            39:                fprintf(stderr, "Cannot open %s\n", HDRFILE);
        !            40:                exit(1);
        !            41:        }
        !            42:        
        !            43:        for (;;) {      /* each line in the file */
        !            44:                if (fgets(buf, sizeof buf, fd) == NULL) {
        !            45:                        fprintf(stderr, "no sysname in %s\n", HDRFILE);
        !            46:                        fclose(fd);
        !            47:                        exit(2);
        !            48:                }
        !            49:                if (sscanf(buf, "#define sysname \"%[^\"]\"", uptr->nodename) == 1) {
        !            50:                        fclose(fd);
        !            51:                        return;
        !            52:                }
        !            53:        }
        !            54: }
        !            55: #endif

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.