diff options
author | Andy Wingo <wingo@pobox.com> | 2013-03-09 15:56:30 +0100 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2013-03-09 15:56:30 +0100 |
commit | 7e369c38993cc7cf4063a6cadc8496552abf323d (patch) | |
tree | 46e0be00b6a6a5f2254c2d7b086f05d93da85330 /libguile/win32-socket.c | |
parent | 4c187d46d40aff1601f38675c11f92a73a13a7c9 (diff) | |
download | guile-7e369c38993cc7cf4063a6cadc8496552abf323d.tar.gz |
remove mingw32 implementations of {get,end,set}{serv,proto}ent
* libguile/win32-socket.h:
* libguile/win32-socket.c (getservent, endservent, setservent)
(getprotoent, endprotoent, setprotoent): Remove mingw32 wrappers.
Their place is in gnulib, if anywhere.
Diffstat (limited to 'libguile/win32-socket.c')
-rw-r--r-- | libguile/win32-socket.c | 165 |
1 files changed, 1 insertions, 164 deletions
diff --git a/libguile/win32-socket.c b/libguile/win32-socket.c index 825b4c499..7ffb9611f 100644 --- a/libguile/win32-socket.c +++ b/libguile/win32-socket.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2001, 2006 Free Software Foundation, Inc. +/* Copyright (C) 2001, 2006, 2013 Free Software Foundation, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License @@ -441,169 +441,6 @@ scm_i_socket_uncomment (char *line) return end; } -/* The getservent() function reads the next line from the file `/etc/services' - and returns a structure servent containing the broken out fields from the - line. The `/etc/services' file is opened if necessary. */ -struct servent * -getservent (void) -{ - char line[MAX_NAMLEN], *end, *p; - int done = 0, i, n, a; - struct servent *e = NULL; - - /* Ensure a open file. */ - if (scm_i_servent.fd == NULL || feof (scm_i_servent.fd)) - { - setservent (1); - if (scm_i_servent.fd == NULL) - return NULL; - } - - while (!done) - { - /* Get new line. */ - if (fgets (line, MAX_NAMLEN, scm_i_servent.fd) != NULL) - { - end = scm_i_socket_uncomment (line); - - /* Scan the line. */ - if ((i = sscanf (line, "%s %d/%s%n", - scm_i_servent.name, - &scm_i_servent.port, - scm_i_servent.proto, &n)) != 3) - continue; - - /* Scan the remaining aliases. */ - p = line + n; - for (a = 0; a < MAX_ALIASES && p < end && i != -1 && n > 1; - a++, p += n) - i = sscanf (p, "%s%n", scm_i_servent.alias[a], &n); - - /* Prepare the return value. */ - e = &scm_i_servent.ent; - e->s_name = scm_i_servent.name; - e->s_port = htons (scm_i_servent.port); - e->s_proto = scm_i_servent.proto; - e->s_aliases = scm_i_servent.aliases; - scm_i_servent.aliases[a] = NULL; - while (a--) - scm_i_servent.aliases[a] = scm_i_servent.alias[a]; - done = 1; - } - else - break; - } - return done ? e : NULL; -} - -/* The setservent() function opens and rewinds the `/etc/services' file. - This file can be set from outside with an environment variable specifying - the file name. */ -void -setservent (int stayopen) -{ - char *file = NULL; - - endservent (); - if ((file = getenv (ENVIRON_ETC_SERVICES)) != NULL) - strcpy (scm_i_servent.file, file); - else if ((file = scm_i_socket_filename (FILE_ETC_SERVICES)) != NULL) - strcpy (scm_i_servent.file, file); - scm_i_servent.fd = fopen (scm_i_servent.file, "rt"); -} - -/* The endservent() function closes the `/etc/services' file. */ -void -endservent (void) -{ - if (scm_i_servent.fd != NULL) - { - fclose (scm_i_servent.fd); - scm_i_servent.fd = NULL; - } -} - -/* The getprotoent() function reads the next line from the file - `/etc/protocols' and returns a structure protoent containing the broken - out fields from the line. The `/etc/protocols' file is opened if - necessary. */ -struct protoent * -getprotoent (void) -{ - char line[MAX_NAMLEN], *end, *p; - int done = 0, i, n, a; - struct protoent *e = NULL; - - /* Ensure a open file. */ - if (scm_i_protoent.fd == NULL || feof (scm_i_protoent.fd)) - { - setprotoent (1); - if (scm_i_protoent.fd == NULL) - return NULL; - } - - while (!done) - { - /* Get new line. */ - if (fgets (line, MAX_NAMLEN, scm_i_protoent.fd) != NULL) - { - end = scm_i_socket_uncomment (line); - - /* Scan the line. */ - if ((i = sscanf (line, "%s %d%n", - scm_i_protoent.name, - &scm_i_protoent.proto, &n)) != 2) - continue; - - /* Scan the remaining aliases. */ - p = line + n; - for (a = 0; a < MAX_ALIASES && p < end && i != -1 && n > 1; - a++, p += n) - i = sscanf (p, "%s%n", scm_i_protoent.alias[a], &n); - - /* Prepare the return value. */ - e = &scm_i_protoent.ent; - e->p_name = scm_i_protoent.name; - e->p_proto = scm_i_protoent.proto; - e->p_aliases = scm_i_protoent.aliases; - scm_i_protoent.aliases[a] = NULL; - while (a--) - scm_i_protoent.aliases[a] = scm_i_protoent.alias[a]; - done = 1; - } - else - break; - } - return done ? e : NULL; -} - -/* The setprotoent() function opens and rewinds the `/etc/protocols' file. - As in setservent() the user can modify the location of the file using - an environment variable. */ -void -setprotoent (int stayopen) -{ - char *file = NULL; - - endprotoent (); - if ((file = getenv (ENVIRON_ETC_PROTOCOLS)) != NULL) - strcpy (scm_i_protoent.file, file); - else if ((file = scm_i_socket_filename (FILE_ETC_PROTOCOLS)) != NULL) - strcpy (scm_i_protoent.file, file); - scm_i_protoent.fd = fopen (scm_i_protoent.file, "rt"); -} - -/* The endprotoent() function closes `/etc/protocols'. */ -void -endprotoent (void) -{ - if (scm_i_protoent.fd != NULL) - { - fclose (scm_i_protoent.fd); - scm_i_protoent.fd = NULL; - } -} - /* Define both the original and replacement error symbol is possible. Thus the user is able to check symbolic errors after unsuccessful networking function calls. */ |