1 |
/* Copyright (C) 1996,1997,1998,2000,2001 Free Software Foundation, Inc. |
/* Copyright (C) 1996,1997,1998,2000,2001, 2002 Free Software Foundation, Inc. |
2 |
* |
* |
3 |
* This program is free software; you can redistribute it and/or modify |
* This program is free software; you can redistribute it and/or modify |
4 |
* 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 |
922 |
|
|
923 |
/* Put the components of a sockaddr into a new SCM vector. */ |
/* Put the components of a sockaddr into a new SCM vector. */ |
924 |
static SCM |
static SCM |
925 |
scm_addr_vector (const struct sockaddr *address, const char *proc) |
scm_addr_vector (const struct sockaddr *address, int addr_size, |
926 |
|
const char *proc) |
927 |
{ |
{ |
928 |
short int fam = address->sa_family; |
short int fam = address->sa_family; |
929 |
SCM result =SCM_EOL; |
SCM result =SCM_EOL; |
968 |
result = scm_c_make_vector (2, SCM_UNSPECIFIED); |
result = scm_c_make_vector (2, SCM_UNSPECIFIED); |
969 |
|
|
970 |
SCM_VECTOR_SET(result, 0, scm_ulong2num ((unsigned long) fam)); |
SCM_VECTOR_SET(result, 0, scm_ulong2num ((unsigned long) fam)); |
971 |
SCM_VECTOR_SET(result, 1, scm_mem2string (nad->sun_path, strlen (nad->sun_path))); |
/* When addr_size is not enough to cover sun_path, do not try |
972 |
|
to access it. */ |
973 |
|
if (addr_size <= offsetof (struct sockaddr_un, sun_path)) |
974 |
|
SCM_VECTOR_SET(result, 1, SCM_BOOL_F); |
975 |
|
else |
976 |
|
SCM_VECTOR_SET(result, 1, scm_mem2string (nad->sun_path, |
977 |
|
strlen (nad->sun_path))); |
978 |
} |
} |
979 |
break; |
break; |
980 |
#endif |
#endif |
1035 |
if (newfd == -1) |
if (newfd == -1) |
1036 |
SCM_SYSERROR; |
SCM_SYSERROR; |
1037 |
newsock = SCM_SOCK_FD_TO_PORT (newfd); |
newsock = SCM_SOCK_FD_TO_PORT (newfd); |
1038 |
address = scm_addr_vector (addr, FUNC_NAME); |
address = scm_addr_vector (addr, addr_size, FUNC_NAME); |
1039 |
return scm_cons (newsock, address); |
return scm_cons (newsock, address); |
1040 |
} |
} |
1041 |
#undef FUNC_NAME |
#undef FUNC_NAME |
1057 |
fd = SCM_FPORT_FDES (sock); |
fd = SCM_FPORT_FDES (sock); |
1058 |
if (getsockname (fd, addr, &addr_size) == -1) |
if (getsockname (fd, addr, &addr_size) == -1) |
1059 |
SCM_SYSERROR; |
SCM_SYSERROR; |
1060 |
return scm_addr_vector (addr, FUNC_NAME); |
return scm_addr_vector (addr, addr_size, FUNC_NAME); |
1061 |
} |
} |
1062 |
#undef FUNC_NAME |
#undef FUNC_NAME |
1063 |
|
|
1079 |
fd = SCM_FPORT_FDES (sock); |
fd = SCM_FPORT_FDES (sock); |
1080 |
if (getpeername (fd, addr, &addr_size) == -1) |
if (getpeername (fd, addr, &addr_size) == -1) |
1081 |
SCM_SYSERROR; |
SCM_SYSERROR; |
1082 |
return scm_addr_vector (addr, FUNC_NAME); |
return scm_addr_vector (addr, addr_size, FUNC_NAME); |
1083 |
} |
} |
1084 |
#undef FUNC_NAME |
#undef FUNC_NAME |
1085 |
|
|
1206 |
if (rv == -1) |
if (rv == -1) |
1207 |
SCM_SYSERROR; |
SCM_SYSERROR; |
1208 |
if (addr->sa_family != AF_UNSPEC) |
if (addr->sa_family != AF_UNSPEC) |
1209 |
address = scm_addr_vector (addr, FUNC_NAME); |
address = scm_addr_vector (addr, addr_size, FUNC_NAME); |
1210 |
else |
else |
1211 |
address = SCM_BOOL_F; |
address = SCM_BOOL_F; |
1212 |
|
|