/[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.70 by mvo, Wed Jul 10 19:40:43 2002 UTC revision 1.71 by xxhanwen, Sat Jul 20 14:08:33 2002 UTC
# Line 154  SCM_DEFINE (scm_gethost, "gethost", 0, 1 Line 154  SCM_DEFINE (scm_gethost, "gethost", 0, 1
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 ans = scm_c_make_vector (5, SCM_UNSPECIFIED);
157    SCM *ve = SCM_VELTS (ans);    SCM *ve = SCM_WRITABLE_VELTS (ans);
158    SCM lst = SCM_EOL;    SCM lst = SCM_EOL;
159    struct hostent *entry;    struct hostent *entry;
160    struct in_addr inad;    struct in_addr inad;
# Line 190  SCM_DEFINE (scm_gethost, "gethost", 0, 1 Line 190  SCM_DEFINE (scm_gethost, "gethost", 0, 1
190    if (!entry)    if (!entry)
191      scm_resolv_error (FUNC_NAME, host);      scm_resolv_error (FUNC_NAME, host);
192        
193    ve[0] = scm_mem2string (entry->h_name, strlen (entry->h_name));    SCM_VECTOR_SET(ans, 0, scm_mem2string (entry->h_name, strlen (entry->h_name)));
194    ve[1] = scm_makfromstrs (-1, entry->h_aliases);    SCM_VECTOR_SET(ans, 1, scm_makfromstrs (-1, entry->h_aliases));
195    ve[2] = SCM_MAKINUM (entry->h_addrtype + 0L);    SCM_VECTOR_SET(ans, 2, SCM_MAKINUM (entry->h_addrtype + 0L));
196    ve[3] = SCM_MAKINUM (entry->h_length + 0L);    SCM_VECTOR_SET(ans, 3, SCM_MAKINUM (entry->h_length + 0L));
197    if (sizeof (struct in_addr) != entry->h_length)    if (sizeof (struct in_addr) != entry->h_length)
198      {      {
199        ve[4] = SCM_BOOL_F;        SCM_VECTOR_SET(ans, 4, SCM_BOOL_F);
200        return ans;        return ans;
201      }      }
202    for (argv = entry->h_addr_list; argv[i]; i++);    for (argv = entry->h_addr_list; argv[i]; i++);
# Line 205  SCM_DEFINE (scm_gethost, "gethost", 0, 1 Line 205  SCM_DEFINE (scm_gethost, "gethost", 0, 1
205        inad = *(struct in_addr *) argv[i];        inad = *(struct in_addr *) argv[i];
206        lst = scm_cons (scm_ulong2num (ntohl (inad.s_addr)), lst);        lst = scm_cons (scm_ulong2num (ntohl (inad.s_addr)), lst);
207      }      }
208    ve[4] = lst;    SCM_VECTOR_SET(ans, 4, lst);
209    return ans;    return ans;
210  }  }
211  #undef FUNC_NAME  #undef FUNC_NAME
# Line 237  SCM_DEFINE (scm_getnet, "getnet", 0, 1, Line 237  SCM_DEFINE (scm_getnet, "getnet", 0, 1,
237    struct netent *entry;    struct netent *entry;
238    
239    ans = scm_c_make_vector (4, SCM_UNSPECIFIED);    ans = scm_c_make_vector (4, SCM_UNSPECIFIED);
240    ve = SCM_VELTS (ans);    ve = SCM_WRITABLE_VELTS (ans);
241      
242    if (SCM_UNBNDP (net))    if (SCM_UNBNDP (net))
243      {      {
244        entry = getnetent ();        entry = getnetent ();
# Line 261  SCM_DEFINE (scm_getnet, "getnet", 0, 1, Line 262  SCM_DEFINE (scm_getnet, "getnet", 0, 1,
262      }      }
263    if (!entry)    if (!entry)
264      SCM_SYSERROR_MSG ("no such network ~A", scm_list_1 (net), errno);      SCM_SYSERROR_MSG ("no such network ~A", scm_list_1 (net), errno);
265    ve[0] = scm_mem2string (entry->n_name, strlen (entry->n_name));    SCM_VECTOR_SET(ans, 0, scm_mem2string (entry->n_name, strlen (entry->n_name)));
266    ve[1] = scm_makfromstrs (-1, entry->n_aliases);    SCM_VECTOR_SET(ans, 1, scm_makfromstrs (-1, entry->n_aliases));
267    ve[2] = SCM_MAKINUM (entry->n_addrtype + 0L);    SCM_VECTOR_SET(ans, 2, SCM_MAKINUM (entry->n_addrtype + 0L));
268    ve[3] = scm_ulong2num (entry->n_net + 0L);    SCM_VECTOR_SET(ans, 3, scm_ulong2num (entry->n_net + 0L));
269    return ans;    return ans;
270  }  }
271  #undef FUNC_NAME  #undef FUNC_NAME
# Line 286  SCM_DEFINE (scm_getproto, "getproto", 0, Line 287  SCM_DEFINE (scm_getproto, "getproto", 0,
287    struct protoent *entry;    struct protoent *entry;
288    
289    ans = scm_c_make_vector (3, SCM_UNSPECIFIED);    ans = scm_c_make_vector (3, SCM_UNSPECIFIED);
290    ve = SCM_VELTS (ans);    ve = SCM_WRITABLE_VELTS (ans);
291    if (SCM_UNBNDP (protocol))    if (SCM_UNBNDP (protocol))
292      {      {
293        entry = getprotoent ();        entry = getprotoent ();
# Line 310  SCM_DEFINE (scm_getproto, "getproto", 0, Line 311  SCM_DEFINE (scm_getproto, "getproto", 0,
311      }      }
312    if (!entry)    if (!entry)
313      SCM_SYSERROR_MSG ("no such protocol ~A", scm_list_1 (protocol), errno);      SCM_SYSERROR_MSG ("no such protocol ~A", scm_list_1 (protocol), errno);
314    ve[0] = scm_mem2string (entry->p_name, strlen (entry->p_name));    SCM_VECTOR_SET(ans, 0, scm_mem2string (entry->p_name, strlen (entry->p_name)));
315    ve[1] = scm_makfromstrs (-1, entry->p_aliases);    SCM_VECTOR_SET(ans, 1, scm_makfromstrs (-1, entry->p_aliases));
316    ve[2] = SCM_MAKINUM (entry->p_proto + 0L);    SCM_VECTOR_SET(ans, 2, SCM_MAKINUM (entry->p_proto + 0L));
317    return ans;    return ans;
318  }  }
319  #undef FUNC_NAME  #undef FUNC_NAME
# Line 326  scm_return_entry (struct servent *entry) Line 327  scm_return_entry (struct servent *entry)
327    SCM *ve;    SCM *ve;
328    
329    ans = scm_c_make_vector (4, SCM_UNSPECIFIED);    ans = scm_c_make_vector (4, SCM_UNSPECIFIED);
330    ve = SCM_VELTS (ans);    ve = SCM_WRITABLE_VELTS (ans);
331    ve[0] = scm_mem2string (entry->s_name, strlen (entry->s_name));    SCM_VECTOR_SET(ans, 0, scm_mem2string (entry->s_name, strlen (entry->s_name)));
332    ve[1] = scm_makfromstrs (-1, entry->s_aliases);    SCM_VECTOR_SET(ans, 1, scm_makfromstrs (-1, entry->s_aliases));
333    ve[2] = SCM_MAKINUM (ntohs (entry->s_port) + 0L);    SCM_VECTOR_SET(ans, 2, SCM_MAKINUM (ntohs (entry->s_port) + 0L));
334    ve[3] = scm_mem2string (entry->s_proto, strlen (entry->s_proto));    SCM_VECTOR_SET(ans, 3, scm_mem2string (entry->s_proto, strlen (entry->s_proto)));
335    return ans;    return ans;
336  }  }
337    
# Line 367  SCM_DEFINE (scm_getserv, "getserv", 0, 2 Line 368  SCM_DEFINE (scm_getserv, "getserv", 0, 2
368      }      }
369    else    else
370      {      {
371        SCM_VALIDATE_INUM (1,name);        SCM_VALIDATE_INUM (1, name);
372        entry = getservbyport (htons (SCM_INUM (name)), SCM_STRING_CHARS (protocol));        entry = getservbyport (htons (SCM_INUM (name)), SCM_STRING_CHARS (protocol));
373      }      }
374    if (!entry)    if (!entry)

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

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