/* char sccsID[] = "@(# hostname.c V1.2 Copyright Julian Stacey Jan 89"; */ /* Returns hostname string from /etc/hostname */ #include #define HOSTNAM 40 #define HOSTFILE "/etc/hostname" char hostfile[] = HOSTFILE ; vsl_gethostname(name, namelen) char *name; int namelen; { FILE *fp, *fopen(); char ctl[6] ; /* typically %.14s\0 */ *name = '\0' ; if ((fp = fopen(hostfile, "r")) == NULL) { fprintf(stderr, "Can't open %s\n", hostfile); return(-1); } (void) sprintf(ctl,"%%%ds",namelen); (void) fscanf(fp,ctl,name); (void) fclose(fp); return(0); } /* later vsl_sethostname(name, namelen) char *name ; int namelen; { } */