gethostname.c (1574) | gethostname.c (20160) |
---|---|
1/* 2 * Copyright (c) 1989, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 24 unchanged lines hidden (view full) --- 33 34#if defined(LIBC_SCCS) && !defined(lint) 35static char sccsid[] = "@(#)gethostname.c 8.1 (Berkeley) 6/4/93"; 36#endif /* LIBC_SCCS and not lint */ 37 38#include <sys/param.h> 39#include <sys/sysctl.h> 40 | 1/* 2 * Copyright (c) 1989, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 24 unchanged lines hidden (view full) --- 33 34#if defined(LIBC_SCCS) && !defined(lint) 35static char sccsid[] = "@(#)gethostname.c 8.1 (Berkeley) 6/4/93"; 36#endif /* LIBC_SCCS and not lint */ 37 38#include <sys/param.h> 39#include <sys/sysctl.h> 40 |
41long | 41int |
42gethostname(name, namelen) 43 char *name; 44 int namelen; 45{ 46 int mib[2]; 47 size_t size; 48 49 mib[0] = CTL_KERN; 50 mib[1] = KERN_HOSTNAME; 51 size = namelen; 52 if (sysctl(mib, 2, name, &size, NULL, 0) == -1) 53 return (-1); 54 return (0); 55} | 42gethostname(name, namelen) 43 char *name; 44 int namelen; 45{ 46 int mib[2]; 47 size_t size; 48 49 mib[0] = CTL_KERN; 50 mib[1] = KERN_HOSTNAME; 51 size = namelen; 52 if (sysctl(mib, 2, name, &size, NULL, 0) == -1) 53 return (-1); 54 return (0); 55} |