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

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

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

revision 1.91 by hanwen, Fri Aug 16 22:01:10 2002 UTC revision 1.92 by mvo, Fri Aug 30 21:57:10 2002 UTC
# Line 1  Line 1 
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
# Line 922  SCM_DEFINE (scm_listen, "listen", 2, 0, Line 922  SCM_DEFINE (scm_listen, "listen", 2, 0,
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;
# Line 967  scm_addr_vector (const struct sockaddr * Line 968  scm_addr_vector (const struct sockaddr *
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
# Line 1028  SCM_DEFINE (scm_accept, "accept", 1, 0, Line 1035  SCM_DEFINE (scm_accept, "accept", 1, 0,
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
# Line 1050  SCM_DEFINE (scm_getsockname, "getsocknam Line 1057  SCM_DEFINE (scm_getsockname, "getsocknam
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    
# Line 1072  SCM_DEFINE (scm_getpeername, "getpeernam Line 1079  SCM_DEFINE (scm_getpeername, "getpeernam
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    
# Line 1199  SCM_DEFINE (scm_recvfrom, "recvfrom!", 2 Line 1206  SCM_DEFINE (scm_recvfrom, "recvfrom!", 2
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    

Legend:
Removed from v.1.91  
changed lines
  Added in v.1.92

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