/[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.71 by xxhanwen, Sat Jul 20 14:08:33 2002 UTC revision 1.72 by xxhanwen, Sun Jul 21 17:46:23 2002 UTC
# Line 153  SCM_DEFINE (scm_gethost, "gethost", 0, 1 Line 153  SCM_DEFINE (scm_gethost, "gethost", 0, 1
153              "@code{system-error} or @code{misc_error} keys.")              "@code{system-error} or @code{misc_error} keys.")
154  #define FUNC_NAME s_scm_gethost  #define FUNC_NAME s_scm_gethost
155  {  {
156    SCM ans = scm_c_make_vector (5, SCM_UNSPECIFIED);    SCM result = scm_c_make_vector (5, SCM_UNSPECIFIED);
   SCM *ve = SCM_WRITABLE_VELTS (ans);  
157    SCM lst = SCM_EOL;    SCM lst = SCM_EOL;
158    struct hostent *entry;    struct hostent *entry;
159    struct in_addr inad;    struct in_addr inad;
# Line 190  SCM_DEFINE (scm_gethost, "gethost", 0, 1 Line 189  SCM_DEFINE (scm_gethost, "gethost", 0, 1
189    if (!entry)    if (!entry)
190      scm_resolv_error (FUNC_NAME, host);      scm_resolv_error (FUNC_NAME, host);
191        
192    SCM_VECTOR_SET(ans, 0, scm_mem2string (entry->h_name, strlen (entry->h_name)));    SCM_VECTOR_SET(result, 0, scm_mem2string (entry->h_name, strlen (entry->h_name)));
193    SCM_VECTOR_SET(ans, 1, scm_makfromstrs (-1, entry->h_aliases));    SCM_VECTOR_SET(result, 1, scm_makfromstrs (-1, entry->h_aliases));
194    SCM_VECTOR_SET(ans, 2, SCM_MAKINUM (entry->h_addrtype + 0L));    SCM_VECTOR_SET(result, 2, SCM_MAKINUM (entry->h_addrtype + 0L));
195    SCM_VECTOR_SET(ans, 3, SCM_MAKINUM (entry->h_length + 0L));    SCM_VECTOR_SET(result, 3, SCM_MAKINUM (entry->h_length + 0L));
196    if (sizeof (struct in_addr) != entry->h_length)    if (sizeof (struct in_addr) != entry->h_length)
197      {      {
198        SCM_VECTOR_SET(ans, 4, SCM_BOOL_F);        SCM_VECTOR_SET(result, 4, SCM_BOOL_F);
199        return ans;        return result;
200      }      }
201    for (argv = entry->h_addr_list; argv[i]; i++);    for (argv = entry->h_addr_list; argv[i]; i++);
202    while (i--)    while (i--)
# Line 205  SCM_DEFINE (scm_gethost, "gethost", 0, 1 Line 204  SCM_DEFINE (scm_gethost, "gethost", 0, 1
204        inad = *(struct in_addr *) argv[i];        inad = *(struct in_addr *) argv[i];
205        lst = scm_cons (scm_ulong2num (ntohl (inad.s_addr)), lst);        lst = scm_cons (scm_ulong2num (ntohl (inad.s_addr)), lst);
206      }      }
207    SCM_VECTOR_SET(ans, 4, lst);    SCM_VECTOR_SET(result, 4, lst);
208    return ans;    return result;
209  }  }
210  #undef FUNC_NAME  #undef FUNC_NAME
211    
# Line 232  SCM_DEFINE (scm_getnet, "getnet", 0, 1, Line 231  SCM_DEFINE (scm_getnet, "getnet", 0, 1,
231              "given.")              "given.")
232  #define FUNC_NAME s_scm_getnet  #define FUNC_NAME s_scm_getnet
233  {  {
234    SCM ans;    SCM   result = scm_c_make_vector (4, SCM_UNSPECIFIED);
   SCM *ve;  
235    struct netent *entry;    struct netent *entry;
236    
   ans = scm_c_make_vector (4, SCM_UNSPECIFIED);  
   ve = SCM_WRITABLE_VELTS (ans);  
     
237    if (SCM_UNBNDP (net))    if (SCM_UNBNDP (net))
238      {      {
239        entry = getnetent ();        entry = getnetent ();
# Line 262  SCM_DEFINE (scm_getnet, "getnet", 0, 1, Line 257  SCM_DEFINE (scm_getnet, "getnet", 0, 1,
257      }      }
258    if (!entry)    if (!entry)
259      SCM_SYSERROR_MSG ("no such network ~A", scm_list_1 (net), errno);      SCM_SYSERROR_MSG ("no such network ~A", scm_list_1 (net), errno);
260    SCM_VECTOR_SET(ans, 0, scm_mem2string (entry->n_name, strlen (entry->n_name)));    SCM_VECTOR_SET(result, 0, scm_mem2string (entry->n_name, strlen (entry->n_name)));
261    SCM_VECTOR_SET(ans, 1, scm_makfromstrs (-1, entry->n_aliases));    SCM_VECTOR_SET(result, 1, scm_makfromstrs (-1, entry->n_aliases));
262    SCM_VECTOR_SET(ans, 2, SCM_MAKINUM (entry->n_addrtype + 0L));    SCM_VECTOR_SET(result, 2, SCM_MAKINUM (entry->n_addrtype + 0L));
263    SCM_VECTOR_SET(ans, 3, scm_ulong2num (entry->n_net + 0L));    SCM_VECTOR_SET(result, 3, scm_ulong2num (entry->n_net + 0L));
264    return ans;    return result;
265  }  }
266  #undef FUNC_NAME  #undef FUNC_NAME
267  #endif  #endif
# Line 282  SCM_DEFINE (scm_getproto, "getproto", 0, Line 277  SCM_DEFINE (scm_getproto, "getproto", 0,
277              "@code{getprotoent} (see below) if no arguments are supplied.")              "@code{getprotoent} (see below) if no arguments are supplied.")
278  #define FUNC_NAME s_scm_getproto  #define FUNC_NAME s_scm_getproto
279  {  {
280    SCM ans;    SCM   result = scm_c_make_vector (3, SCM_UNSPECIFIED);
   SCM *ve;  
   struct protoent *entry;  
281    
282    ans = scm_c_make_vector (3, SCM_UNSPECIFIED);    struct protoent *entry;
   ve = SCM_WRITABLE_VELTS (ans);  
283    if (SCM_UNBNDP (protocol))    if (SCM_UNBNDP (protocol))
284      {      {
285        entry = getprotoent ();        entry = getprotoent ();
# Line 311  SCM_DEFINE (scm_getproto, "getproto", 0, Line 303  SCM_DEFINE (scm_getproto, "getproto", 0,
303      }      }
304    if (!entry)    if (!entry)
305      SCM_SYSERROR_MSG ("no such protocol ~A", scm_list_1 (protocol), errno);      SCM_SYSERROR_MSG ("no such protocol ~A", scm_list_1 (protocol), errno);
306    SCM_VECTOR_SET(ans, 0, scm_mem2string (entry->p_name, strlen (entry->p_name)));    SCM_VECTOR_SET(result, 0, scm_mem2string (entry->p_name, strlen (entry->p_name)));
307    SCM_VECTOR_SET(ans, 1, scm_makfromstrs (-1, entry->p_aliases));    SCM_VECTOR_SET(result, 1, scm_makfromstrs (-1, entry->p_aliases));
308    SCM_VECTOR_SET(ans, 2, SCM_MAKINUM (entry->p_proto + 0L));    SCM_VECTOR_SET(result, 2, SCM_MAKINUM (entry->p_proto + 0L));
309    return ans;    return result;
310  }  }
311  #undef FUNC_NAME  #undef FUNC_NAME
312  #endif  #endif
# Line 323  SCM_DEFINE (scm_getproto, "getproto", 0, Line 315  SCM_DEFINE (scm_getproto, "getproto", 0,
315  static SCM  static SCM
316  scm_return_entry (struct servent *entry)  scm_return_entry (struct servent *entry)
317  {  {
318    SCM ans;    SCM result = scm_c_make_vector (4, SCM_UNSPECIFIED);
   SCM *ve;  
319    
320    ans = scm_c_make_vector (4, SCM_UNSPECIFIED);    SCM_VECTOR_SET(result, 0, scm_mem2string (entry->s_name, strlen (entry->s_name)));
321    ve = SCM_WRITABLE_VELTS (ans);    SCM_VECTOR_SET(result, 1, scm_makfromstrs (-1, entry->s_aliases));
322    SCM_VECTOR_SET(ans, 0, scm_mem2string (entry->s_name, strlen (entry->s_name)));    SCM_VECTOR_SET(result, 2, SCM_MAKINUM (ntohs (entry->s_port) + 0L));
323    SCM_VECTOR_SET(ans, 1, scm_makfromstrs (-1, entry->s_aliases));    SCM_VECTOR_SET(result, 3, scm_mem2string (entry->s_proto, strlen (entry->s_proto)));
324    SCM_VECTOR_SET(ans, 2, SCM_MAKINUM (ntohs (entry->s_port) + 0L));    return result;
   SCM_VECTOR_SET(ans, 3, scm_mem2string (entry->s_proto, strlen (entry->s_proto)));  
   return ans;  
325  }  }
326    
327  SCM_DEFINE (scm_getserv, "getserv", 0, 2, 0,  SCM_DEFINE (scm_getserv, "getserv", 0, 2, 0,

Legend:
Removed from v.1.71  
changed lines
  Added in v.1.72

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