Mercurial > hg > octave-kai > gnulib-hg
annotate lib/gethostname.c @ 10690:01f3623813da
Split winsock.c into many smaller files.
* lib/close.c: Add _gl_close_fd_maybe_socket from winsock.c.
* lib/accept.c: New file, based on winsock.c.
* lib/bind.c: New file, based on winsock.c.
* lib/connect.c: New file, based on winsock.c.
* lib/getpeername.c: New file, based on winsock.c.
* lib/getsockname.c: New file, based on winsock.c.
* lib/getsockopt.c: New file, based on winsock.c.
* lib/ioctl.c: New file, based on winsock.c.
* lib/listen.c: New file, based on winsock.c.
* lib/recv.c: New file, based on winsock.c.
* lib/recvfrom.c: New file, based on winsock.c.
* lib/send.c: New file, based on winsock.c.
* lib/sendto.c: New file, based on winsock.c.
* lib/setsockopt.c: New file, based on winsock.c.
* lib/shutdown.c: New file, based on winsock.c.
* lib/socket.c: New file, based on winsock.c.
* lib/w32sock.h: New file, based on winsock.c.
* lib/winsock.c: Remove file.
* modules/accept: Likewise.
* modules/bind: Likewise.
* modules/connect: Likewise.
* modules/getpeername: Likewise.
* modules/getsockname: Likewise.
* modules/getsockopt: Likewise.
* modules/ioctl: Likewise.
* modules/listen: Likewise.
* modules/recv: Likewise.
* modules/recvfrom: Likewise.
* modules/send: Likewise.
* modules/sendto: Likewise.
* modules/setsockopt: Likewise.
* modules/shutdown: Likewise.
* modules/socket: Use socket.c instead of winsock.c.
* modules/sys_socket: Remove (unneeded?) dependency on winsock.c.
* doc/posix-functions/accept.texi: Doc fix.
* doc/posix-functions/bind.texi: Doc fix.
* doc/posix-functions/close.texi: Doc fix.
* doc/posix-functions/connect.texi: Doc fix.
* doc/posix-functions/getpeername.texi: Doc fix.
* doc/posix-functions/getsockname.texi: Doc fix.
* doc/posix-functions/getsockopt.texi: Doc fix.
* doc/posix-functions/ioctl.texi: Doc fix.
* doc/posix-functions/listen.texi: Doc fix.
* doc/posix-functions/recv.texi: Doc fix.
* doc/posix-functions/recvfrom.texi: Doc fix.
* doc/posix-functions/send.texi: Doc fix.
* doc/posix-functions/sendto.texi: Doc fix.
* doc/posix-functions/setsockopt.texi: Doc fix.
* doc/posix-functions/shutdown.texi: Doc fix.
* doc/posix-functions/socket.texi: Doc fix.
author | Simon Josefsson <simon@josefsson.org> |
---|---|
date | Tue, 21 Oct 2008 12:17:19 +0200 |
parents | e225fe0e35c0 |
children | b867b19bccb3 |
rev | line source |
---|---|
9 | 1 /* gethostname emulation for SysV and POSIX.1. |
7302
8a1a9361108c
* _fpending.c: Include <config.h> unconditionally, since we no
Paul Eggert <eggert@cs.ucla.edu>
parents:
5848
diff
changeset
|
2 |
9627
5d966818e300
Need string.h for strcpy in gethostname module.
Simon Josefsson <simon@josefsson.org>
parents:
9309
diff
changeset
|
3 Copyright (C) 1992, 2003, 2006, 2008 Free Software Foundation, Inc. |
9 | 4 |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
7302
diff
changeset
|
5 This program is free software: you can redistribute it and/or modify |
9 | 6 it under the terms of the GNU General Public License as published by |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
7302
diff
changeset
|
7 the Free Software Foundation; either version 3 of the License, or |
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
7302
diff
changeset
|
8 (at your option) any later version. |
9 | 9 |
10 This program is distributed in the hope that it will be useful, | |
11 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 GNU General Public License for more details. | |
14 | |
15 You should have received a copy of the GNU General Public License | |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
7302
diff
changeset
|
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
9 | 17 |
18 /* David MacKenzie <djm@gnu.ai.mit.edu> */ | |
19 | |
7302
8a1a9361108c
* _fpending.c: Include <config.h> unconditionally, since we no
Paul Eggert <eggert@cs.ucla.edu>
parents:
5848
diff
changeset
|
20 #include <config.h> |
651
242f0fe39aa7
update FSF address in copyright
Jim Meyering <jim@meyering.net>
parents:
9
diff
changeset
|
21 |
9 | 22 #ifdef HAVE_UNAME |
653 | 23 # include <sys/utsname.h> |
9 | 24 #endif |
25 | |
9631
e225fe0e35c0
Need string.h unconditionally, for strncpy or strcpy.
Simon Josefsson <simon@josefsson.org>
parents:
9627
diff
changeset
|
26 #include <string.h> |
e225fe0e35c0
Need string.h unconditionally, for strncpy or strcpy.
Simon Josefsson <simon@josefsson.org>
parents:
9627
diff
changeset
|
27 |
9 | 28 /* Put up to LEN chars of the host name into NAME. |
29 Null terminate it if the name is shorter than LEN. | |
30 Return 0 if ok, -1 if error. */ | |
31 | |
4645 | 32 #include <stddef.h> |
33 | |
9 | 34 int |
4645 | 35 gethostname (char *name, size_t len) |
9 | 36 { |
37 #ifdef HAVE_UNAME | |
38 struct utsname uts; | |
39 | |
40 if (uname (&uts) == -1) | |
41 return -1; | |
42 if (len > sizeof (uts.nodename)) | |
43 { | |
44 /* More space than we need is available. */ | |
45 name[sizeof (uts.nodename)] = '\0'; | |
46 len = sizeof (uts.nodename); | |
47 } | |
48 strncpy (name, uts.nodename, len); | |
49 #else | |
50 strcpy (name, ""); /* Hardcode your system name if you want. */ | |
51 #endif | |
52 return 0; | |
53 } |