int a_remove(attrib ** pa, attrib * a) { attrib *head = *pa; int ok; assert(a != NULL); ok = a_unlink(pa, a); if (ok) { if (head == a) { *pa = a->next; } a_free(a); } return ok; }
enum io_result a_open_listen_socket(int *result, const char *path) { int fd, i; struct sockaddr_un addr_un; char *tc = (char *)&(addr_un); a_unlink(path); if ((fd = sys_socket(AF_UNIX, SOCK_STREAM, 0)) < 0) { return io_unrecoverable_error; } for (i = 0; i < sizeof(struct sockaddr_un); i++) { tc[i] = (char)0; } addr_un.sun_family = AF_UNIX; for (i = 0; (i < (sizeof(addr_un.sun_path)-1)) && (path[i] != (char)0); i++) { addr_un.sun_path[i] = path[i]; } if (sys_bind(fd, (struct sockaddr *) &addr_un, sizeof(struct sockaddr_un)) < 0) { a_close (fd); return io_unrecoverable_error; } if (sys_listen(fd, 32) == -1) { a_close (fd); return io_unrecoverable_error; } *result = fd; return io_complete; }