method
unpack_sockaddr_un
v1_9_1_378 -
Show latest stable
-
0 notes -
Class: Socket
- 1_8_6_287
- 1_8_7_72
- 1_8_7_330
- 1_9_1_378 (0)
- 1_9_2_180 (38)
- 1_9_3_125 (0)
- 1_9_3_392 (0)
- 2_1_10 (0)
- 2_2_9 (0)
- 2_4_6 (0)
- 2_5_5 (0)
- 2_6_3 (0)
- What's this?
unpack_sockaddr_un(p1)
public
Hide source
static VALUE sock_s_unpack_sockaddr_un(VALUE self, VALUE addr) { struct sockaddr_un * sockaddr; const char *sun_path; VALUE path; sockaddr = (struct sockaddr_un*)StringValuePtr(addr); if (RSTRING_LEN(addr) < (char*)&((struct sockaddr *)sockaddr)->sa_family + sizeof(((struct sockaddr *)sockaddr)->sa_family) - (char*)sockaddr) rb_raise(rb_eArgError, "too short sockaddr"); if (((struct sockaddr *)sockaddr)->sa_family != AF_UNIX) { rb_raise(rb_eArgError, "not an AF_UNIX sockaddr"); } if (sizeof(struct sockaddr_un) < RSTRING_LEN(addr)) { rb_raise(rb_eTypeError, "too long sockaddr_un - %ld longer than %d", RSTRING_LEN(addr), (int)sizeof(struct sockaddr_un)); } sun_path = unixpath(sockaddr, RSTRING_LEN(addr)); if (sizeof(struct sockaddr_un) == RSTRING_LEN(addr) && sun_path == sockaddr->sun_path && sun_path + strlen(sun_path) == RSTRING_PTR(addr) + RSTRING_LEN(addr)) { rb_raise(rb_eArgError, "sockaddr_un.sun_path not NUL terminated"); } path = rb_str_new2(sun_path); OBJ_INFECT(path, addr); return path; }