/[guile]/guile/guile-core/libguile/net_db.c
ViewVC logotype

Diff of /guile/guile-core/libguile/net_db.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.42 by mdj, Tue Jun 13 19:08:14 2000 UTC revision 1.42.2.1 by ttn, Thu Jan 24 16:40:51 2002 UTC
# Line 1  Line 1 
1  /* "net_db.c" network database support  /* "net_db.c" network database support
2   * Copyright (C) 1995, 96, 97, 98, 99, 2000 Free Software Foundation, Inc.   * Copyright (C) 1995, 96, 97, 98, 99, 2000 Free Software Foundation, Inc.
3   *   *
4   * This program is free software; you can redistribute it and/or modify   * This program is free software; you can redistribute it and/or modify
5   * it under the terms of the GNU General Public License as published by   * it under the terms of the GNU General Public License as published by
6   * the Free Software Foundation; either version 2, or (at your option)   * the Free Software Foundation; either version 2, or (at your option)
7   * any later version.   * any later version.
8   *   *
9   * This program is distributed in the hope that it will be useful,   * This program is distributed in the hope that it will be useful,
10   * but WITHOUT ANY WARRANTY; without even the implied warranty of   * but WITHOUT ANY WARRANTY; without even the implied warranty of
11   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12   * GNU General Public License for more details.   * GNU General Public License for more details.
13   *   *
14   * You should have received a copy of the GNU General Public License   * You should have received a copy of the GNU General Public License
15   * along with this software; see the file COPYING.  If not, write to   * along with this software; see the file COPYING.  If not, write to
16   * the Free Software Foundation, Inc., 59 Temple Place, Suite 330,   * the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
# Line 82  extern int h_errno; Line 82  extern int h_errno;
82  int close ();  int close ();
83  #endif /* STDC_HEADERS */  #endif /* STDC_HEADERS */
84    
85    #ifndef HAVE_INET_ATON
86    /* for our definition in inet_aton.c, not usually needed.  */
87  extern int inet_aton ();  extern int inet_aton ();
88    #endif
89    
90  SCM_DEFINE (scm_inet_aton, "inet-aton", 1, 0, 0,  SCM_DEFINE (scm_inet_aton, "inet-aton", 1, 0, 0,
91              (SCM address),              (SCM address),
92              "Converts a string containing an Internet host address in the traditional\n"              "Converts a string containing an Internet host address in the traditional\n"
93              "dotted decimal notation into an integer.\n\n"              "dotted decimal notation into an integer.\n\n"
# Line 105  SCM_DEFINE (scm_inet_aton, "inet-aton", Line 108  SCM_DEFINE (scm_inet_aton, "inet-aton",
108  #undef FUNC_NAME  #undef FUNC_NAME
109    
110    
111  SCM_DEFINE (scm_inet_ntoa, "inet-ntoa", 1, 0, 0,  SCM_DEFINE (scm_inet_ntoa, "inet-ntoa", 1, 0, 0,
112              (SCM inetid),              (SCM inetid),
113              "Converts an integer Internet host address into a string with the\n"              "Converts an integer Internet host address into a string with the\n"
114              "traditional dotted decimal representation.\n\n"              "traditional dotted decimal representation.\n\n"
# Line 125  SCM_DEFINE (scm_inet_ntoa, "inet-ntoa", Line 128  SCM_DEFINE (scm_inet_ntoa, "inet-ntoa",
128  #undef FUNC_NAME  #undef FUNC_NAME
129    
130  #ifdef HAVE_INET_NETOF  #ifdef HAVE_INET_NETOF
131  SCM_DEFINE (scm_inet_netof, "inet-netof", 1, 0, 0,  SCM_DEFINE (scm_inet_netof, "inet-netof", 1, 0, 0,
132              (SCM address),              (SCM address),
133              "Returns the network number part of the given integer Internet address.\n\n"              "Returns the network number part of the given integer Internet address.\n\n"
134              "@smalllisp\n"              "@smalllisp\n"
# Line 141  SCM_DEFINE (scm_inet_netof, "inet-netof" Line 144  SCM_DEFINE (scm_inet_netof, "inet-netof"
144  #endif  #endif
145    
146  #ifdef HAVE_INET_LNAOF  #ifdef HAVE_INET_LNAOF
147  SCM_DEFINE (scm_lnaof, "inet-lnaof", 1, 0, 0,  SCM_DEFINE (scm_lnaof, "inet-lnaof", 1, 0, 0,
148              (SCM address),              (SCM address),
149              "Returns the local-address-with-network part of the given Internet\n"              "Returns the local-address-with-network part of the given Internet\n"
150              "address.\n\n"              "address.\n\n"
# Line 207  static void scm_resolv_error (const char Line 210  static void scm_resolv_error (const char
210          {          {
211          case HOST_NOT_FOUND:          case HOST_NOT_FOUND:
212            key = scm_host_not_found_key;            key = scm_host_not_found_key;
213            errmsg = "Unknown host";            errmsg = "Unknown host";
214            break;            break;
215          case TRY_AGAIN:          case TRY_AGAIN:
216            key = scm_try_again_key;            key = scm_try_again_key;
217            errmsg = "Host name lookup failure";            errmsg = "Host name lookup failure";
218            break;            break;
219          case NO_RECOVERY:          case NO_RECOVERY:
220            key = scm_no_recovery_key;            key = scm_no_recovery_key;
221            errmsg = "Unknown server error";            errmsg = "Unknown server error";
222            break;            break;
223          case NO_DATA:          case NO_DATA:
224            key = scm_no_data_key;            key = scm_no_data_key;
# Line 237  static void scm_resolv_error (const char Line 240  static void scm_resolv_error (const char
240     Should use reentrant facilities if available.     Should use reentrant facilities if available.
241   */   */
242    
243  SCM_DEFINE (scm_gethost, "gethost", 0, 1, 0,  SCM_DEFINE (scm_gethost, "gethost", 0, 1, 0,
244              (SCM name),              (SCM name),
245              "@deffnx procedure gethostbyname hostname\n"              "@deffnx procedure gethostbyname hostname\n"
246              "@deffnx procedure gethostbyaddr address\n"              "@deffnx procedure gethostbyaddr address\n"
# Line 289  SCM_DEFINE (scm_gethost, "gethost", 0, 1 Line 292  SCM_DEFINE (scm_gethost, "gethost", 0, 1
292      }      }
293    if (!entry)    if (!entry)
294      scm_resolv_error (FUNC_NAME, name);      scm_resolv_error (FUNC_NAME, name);
295      
296    ve[0] = scm_makfromstr (entry->h_name,    ve[0] = scm_makfromstr (entry->h_name,
297                            (scm_sizet) strlen (entry->h_name), 0);                            (scm_sizet) strlen (entry->h_name), 0);
298    ve[1] = scm_makfromstrs (-1, entry->h_aliases);    ve[1] = scm_makfromstrs (-1, entry->h_aliases);
299    ve[2] = SCM_MAKINUM (entry->h_addrtype + 0L);    ve[2] = SCM_MAKINUM (entry->h_addrtype + 0L);
# Line 322  SCM_DEFINE (scm_gethost, "gethost", 0, 1 Line 325  SCM_DEFINE (scm_gethost, "gethost", 0, 1
325     operation?), but it seems to work okay.  We'll see.  */     operation?), but it seems to work okay.  We'll see.  */
326    
327  #if defined(HAVE_GETNETENT) && defined(HAVE_GETNETBYNAME) && defined(HAVE_GETNETBYADDR)  #if defined(HAVE_GETNETENT) && defined(HAVE_GETNETBYNAME) && defined(HAVE_GETNETBYADDR)
328  SCM_DEFINE (scm_getnet, "getnet", 0, 1, 0,  SCM_DEFINE (scm_getnet, "getnet", 0, 1, 0,
329              (SCM name),              (SCM name),
330              "@deffnx procedure getnetbyname net-name\n"              "@deffnx procedure getnetbyname net-name\n"
331              "@deffnx procedure getnetbyaddr net-number\n"              "@deffnx procedure getnetbyaddr net-number\n"
# Line 347  SCM_DEFINE (scm_getnet, "getnet", 0, 1, Line 350  SCM_DEFINE (scm_getnet, "getnet", 0, 1,
350          {          {
351            if (errno)            if (errno)
352              SCM_SYSERROR;              SCM_SYSERROR;
353            else            else
354              return SCM_BOOL_F;              return SCM_BOOL_F;
355          }          }
356      }      }
# Line 375  SCM_DEFINE (scm_getnet, "getnet", 0, 1, Line 378  SCM_DEFINE (scm_getnet, "getnet", 0, 1,
378  #endif  #endif
379    
380  #ifdef HAVE_GETPROTOENT  #ifdef HAVE_GETPROTOENT
381  SCM_DEFINE (scm_getproto, "getproto", 0, 1, 0,  SCM_DEFINE (scm_getproto, "getproto", 0, 1, 0,
382              (SCM name),              (SCM name),
383              "@deffnx procedure getprotobyname name\n"              "@deffnx procedure getprotobyname name\n"
384              "@deffnx procedure getprotobynumber number\n"              "@deffnx procedure getprotobynumber number\n"
# Line 481  SCM_DEFINE (scm_getserv, "getserv", 0, 2 Line 484  SCM_DEFINE (scm_getserv, "getserv", 0, 2
484        entry = getservbyport (htons (SCM_INUM (name)), SCM_ROCHARS (proto));        entry = getservbyport (htons (SCM_INUM (name)), SCM_ROCHARS (proto));
485      }      }
486    if (!entry)    if (!entry)
487      SCM_SYSERROR_MSG("no such service ~A",      SCM_SYSERROR_MSG("no such service ~A",
488                       scm_listify (name, SCM_UNDEFINED), errno);                       scm_listify (name, SCM_UNDEFINED), errno);
489    return scm_return_entry (entry);    return scm_return_entry (entry);
490  }  }
# Line 489  SCM_DEFINE (scm_getserv, "getserv", 0, 2 Line 492  SCM_DEFINE (scm_getserv, "getserv", 0, 2
492  #endif  #endif
493    
494  #if defined(HAVE_SETHOSTENT) && defined(HAVE_ENDHOSTENT)  #if defined(HAVE_SETHOSTENT) && defined(HAVE_ENDHOSTENT)
495  SCM_DEFINE (scm_sethost, "sethost", 0, 1, 0,  SCM_DEFINE (scm_sethost, "sethost", 0, 1, 0,
496              (SCM arg),              (SCM arg),
497              "If @var{stayopen} is omitted, this is equivalent to @code{endhostent}.\n"              "If @var{stayopen} is omitted, this is equivalent to @code{endhostent}.\n"
498              "Otherwise it is equivalent to @code{sethostent stayopen}.")              "Otherwise it is equivalent to @code{sethostent stayopen}.")
# Line 504  SCM_DEFINE (scm_sethost, "sethost", 0, 1 Line 507  SCM_DEFINE (scm_sethost, "sethost", 0, 1
507  #undef FUNC_NAME  #undef FUNC_NAME
508  #endif  #endif
509    
510  #if defined(HAVE_SETNETENT) && defined(HAVE_ENDNETENT)  #if defined(HAVE_SETNETENT) && defined(HAVE_ENDNETENT)
511  SCM_DEFINE (scm_setnet, "setnet", 0, 1, 0,  SCM_DEFINE (scm_setnet, "setnet", 0, 1, 0,
512              (SCM arg),              (SCM arg),
513              "If @var{stayopen} is omitted, this is equivalent to @code{endnetent}.\n"              "If @var{stayopen} is omitted, this is equivalent to @code{endnetent}.\n"
514              "Otherwise it is equivalent to @code{setnetent stayopen}.")              "Otherwise it is equivalent to @code{setnetent stayopen}.")
# Line 521  SCM_DEFINE (scm_setnet, "setnet", 0, 1, Line 524  SCM_DEFINE (scm_setnet, "setnet", 0, 1,
524  #endif  #endif
525    
526  #if defined(HAVE_SETPROTOENT) && defined(HAVE_ENDPROTOENT)  #if defined(HAVE_SETPROTOENT) && defined(HAVE_ENDPROTOENT)
527  SCM_DEFINE (scm_setproto, "setproto", 0, 1, 0,  SCM_DEFINE (scm_setproto, "setproto", 0, 1, 0,
528              (SCM arg),              (SCM arg),
529              "If @var{stayopen} is omitted, this is equivalent to @code{endprotoent}.\n"              "If @var{stayopen} is omitted, this is equivalent to @code{endprotoent}.\n"
530              "Otherwise it is equivalent to @code{setprotoent stayopen}.")              "Otherwise it is equivalent to @code{setprotoent stayopen}.")
# Line 537  SCM_DEFINE (scm_setproto, "setproto", 0, Line 540  SCM_DEFINE (scm_setproto, "setproto", 0,
540  #endif  #endif
541    
542  #if defined(HAVE_SETSERVENT) && defined(HAVE_ENDSERVENT)  #if defined(HAVE_SETSERVENT) && defined(HAVE_ENDSERVENT)
543  SCM_DEFINE (scm_setserv, "setserv", 0, 1, 0,  SCM_DEFINE (scm_setserv, "setserv", 0, 1, 0,
544              (SCM arg),              (SCM arg),
545              "If @var{stayopen} is omitted, this is equivalent to @code{endservent}.\n"              "If @var{stayopen} is omitted, this is equivalent to @code{endservent}.\n"
546              "Otherwise it is equivalent to @code{setservent stayopen}.")              "Otherwise it is equivalent to @code{setservent stayopen}.")
# Line 553  SCM_DEFINE (scm_setserv, "setserv", 0, 1 Line 556  SCM_DEFINE (scm_setserv, "setserv", 0, 1
556  #endif  #endif
557    
558    
559  void  void
560  scm_init_net_db ()  scm_init_net_db ()
561  {  {
562  #ifdef INADDR_ANY  #ifdef INADDR_ANY

Legend:
Removed from v.1.42  
changed lines
  Added in v.1.42.2.1

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26