示例#1
0
spif_bool_t
spif_eterm_action_del(spif_eterm_action_t self)
{
    spif_eterm_action_done(self);
    SPIF_DEALLOC(self);
    return TRUE;
}
示例#2
0
文件: socket.c 项目: mej/libast
spif_bool_t
spif_socket_done(spif_socket_t self)
{
    ASSERT_RVAL(!SPIF_SOCKET_ISNULL(self), FALSE);
    if (self->fd >= 0) {
        spif_socket_close(self);
    }
    self->fam = AF_INET;
    self->type = SOCK_STREAM;
    self->proto = 0;
    if (self->addr != (spif_sockaddr_t) NULL) {
        SPIF_DEALLOC(self->addr);
        self->addr = (spif_sockaddr_t) NULL;
    }
    self->len = 0;
    self->flags = 0;
    if (!SPIF_URL_ISNULL(self->local_url)) {
        spif_url_del(self->local_url);
        self->local_url = (spif_url_t) NULL;
    }
    if (!SPIF_URL_ISNULL(self->remote_url)) {
        spif_url_del(self->remote_url);
        self->remote_url = (spif_url_t) NULL;
    }
    return TRUE;
}
示例#3
0
文件: socket.c 项目: mej/libast
spif_bool_t
spif_socket_del(spif_socket_t self)
{
    ASSERT_RVAL(!SPIF_SOCKET_ISNULL(self), FALSE);
    spif_socket_done(self);
    SPIF_DEALLOC(self);
    return TRUE;
}
示例#4
0
文件: url.c 项目: Limsik/e17
spif_bool_t
spif_url_del(spif_url_t self)
{
    ASSERT_RVAL(!SPIF_URL_ISNULL(self), FALSE);
    spif_url_done(self);
    SPIF_DEALLOC(self);
    return TRUE;
}
示例#5
0
文件: tok.c 项目: Limsik/e17
spif_bool_t
spif_tok_del(spif_tok_t self)
{
    spif_bool_t t;

    ASSERT_RVAL(!SPIF_TOK_ISNULL(self), FALSE);
    t = spif_tok_done(self);
    SPIF_DEALLOC(self);
    return t;
}
示例#6
0
spif_eterm_action_t
spif_eterm_action_new(void)
{
    spif_eterm_action_t self;

    self = SPIF_ALLOC(eterm_action);
    if (!spif_eterm_action_init(self)) {
        SPIF_DEALLOC(self);
        self = (spif_eterm_action_t) NULL;
    }
    return self;
}
示例#7
0
文件: str.c 项目: mej/libast
spif_str_t
spif_str_new_from_num(long num)
{
    spif_str_t self;

    self = SPIF_ALLOC(str);
    if (!spif_str_init_from_num(self, num)) {
        SPIF_DEALLOC(self);
        self = (spif_str_t) NULL;
    }
    return self;
}
示例#8
0
文件: tok.c 项目: Limsik/e17
spif_tok_t
spif_tok_new_from_fd(int fd)
{
    spif_tok_t self;

    self = SPIF_ALLOC(tok);
    if (!spif_tok_init_from_fd(self, fd)) {
        SPIF_DEALLOC(self);
        self = (spif_tok_t) NULL;
    }
    return self;
}
示例#9
0
文件: tok.c 项目: Limsik/e17
spif_tok_t
spif_tok_new_from_fp(FILE * fp)
{
    spif_tok_t self;

    self = SPIF_ALLOC(tok);
    if (!spif_tok_init_from_fp(self, fp)) {
        SPIF_DEALLOC(self);
        self = (spif_tok_t) NULL;
    }
    return self;
}
示例#10
0
文件: tok.c 项目: Limsik/e17
spif_tok_t
spif_tok_new_from_ptr(spif_charptr_t old)
{
    spif_tok_t self;

    self = SPIF_ALLOC(tok);
    if (!spif_tok_init_from_ptr(self, old)) {
        SPIF_DEALLOC(self);
        self = (spif_tok_t) NULL;
    }
    return self;
}
示例#11
0
文件: tok.c 项目: Limsik/e17
spif_tok_t
spif_tok_new(void)
{
    spif_tok_t self;

    self = SPIF_ALLOC(tok);
    if (!spif_tok_init(self)) {
        SPIF_DEALLOC(self);
        self = (spif_tok_t) NULL;
    }
    return self;
}
示例#12
0
文件: url.c 项目: Limsik/e17
spif_url_t
spif_url_new_from_ptr(spif_charptr_t other)
{
    spif_url_t self;

    self = SPIF_ALLOC(url);
    if (!spif_url_init_from_ptr(self, other)) {
        SPIF_DEALLOC(self);
        self = (spif_url_t) NULL;
    }
    return self;
}
示例#13
0
文件: url.c 项目: Limsik/e17
spif_url_t
spif_url_new(void)
{
    spif_url_t self;

    self = SPIF_ALLOC(url);
    if (!spif_url_init(self)) {
        SPIF_DEALLOC(self);
        self = (spif_url_t) NULL;
    }
    return self;
}
示例#14
0
文件: str.c 项目: mej/libast
spif_str_t
spif_str_new(void)
{
    spif_str_t self;

    self = SPIF_ALLOC(str);
    if (!spif_str_init(self)) {
        SPIF_DEALLOC(self);
        self = (spif_str_t) NULL;
    }
    return self;
}
示例#15
0
文件: socket.c 项目: mej/libast
static spif_url_t
spif_url_new_from_unixaddr(spif_unixsockaddr_t unixaddr)
{
    spif_url_t self;

    self = SPIF_ALLOC(url);
    if (!spif_url_init_from_unixaddr(self, unixaddr)) {
        SPIF_DEALLOC(self);
        self = (spif_url_t) NULL;
    }
    return self;
}
示例#16
0
文件: str.c 项目: mej/libast
spif_str_t
spif_str_new_from_buff(spif_charptr_t buff, spif_stridx_t size)
{
    spif_str_t self;

    self = SPIF_ALLOC(str);
    if (!spif_str_init_from_buff(self, buff, size)) {
        SPIF_DEALLOC(self);
        self = (spif_str_t) NULL;
    }
    return self;
}
示例#17
0
文件: socket.c 项目: mej/libast
spif_socket_t
spif_socket_new_from_urls(spif_url_t surl, spif_url_t durl)
{
    spif_socket_t self;

    self = SPIF_ALLOC(socket);
    if (!spif_socket_init_from_urls(self, surl, durl)) {
        SPIF_DEALLOC(self);
        self = (spif_socket_t) NULL;
    }
    return self;
}
示例#18
0
文件: socket.c 项目: mej/libast
spif_socket_t
spif_socket_new(void)
{
    spif_socket_t self;

    self = SPIF_ALLOC(socket);
    if (!spif_socket_init(self)) {
        SPIF_DEALLOC(self);
        self = (spif_socket_t) NULL;
    }
    return self;
}
示例#19
0
spif_eterm_action_t
spif_eterm_action_new_from_data(spif_eterm_action_type_t type, spif_ushort_t modifiers,
                                spif_uchar_t button, KeySym keysym, spif_ptr_t param)
{
    spif_eterm_action_t self;

    self = SPIF_ALLOC(eterm_action);
    if (!spif_eterm_action_init_from_data(self, type, modifiers, button, keysym, param)) {
        SPIF_DEALLOC(self);
        self = (spif_eterm_action_t) NULL;
    }
    return self;
}
示例#20
0
文件: socket.c 项目: mej/libast
spif_socket_t
spif_socket_accept(spif_socket_t self)
{
    spif_sockaddr_t addr;
    spif_sockaddr_len_t len;
    int newfd;
    spif_socket_t tmp;

    ASSERT_RVAL(!SPIF_SOCKET_ISNULL(self), (spif_socket_t) NULL);

    addr = SPIF_ALLOC(sockaddr);
    len = SPIF_SIZEOF_TYPE(sockaddr);
    do {
        newfd = accept(self->fd, addr, &len);
    } while ((newfd < 0) && ((errno == EAGAIN) || (errno == EWOULDBLOCK)));

    if (newfd < 0) {
        libast_print_error("Unable to accept() connection on %d -- %s\n", self->fd, strerror(errno));
        return (spif_socket_t) NULL;
    }

    /* We got one.  Create and return a new socket object for the accepted connection. */
    tmp = spif_socket_dup(self);
    tmp->fd = newfd;
    SPIF_SOCKET_FLAGS_CLEAR(tmp, (SPIF_SOCKET_FLAGS_LISTEN | SPIF_SOCKET_FLAGS_HAVE_INPUT | SPIF_SOCKET_FLAGS_CAN_OUTPUT));
    if (SPIF_SOCKET_FLAGS_IS_SET(self, SPIF_SOCKET_FLAGS_FAMILY_INET)) {
        tmp->remote_url = spif_url_new_from_ipaddr((spif_ipsockaddr_t) addr);
    } else if (SPIF_SOCKET_FLAGS_IS_SET(self, SPIF_SOCKET_FLAGS_FAMILY_UNIX)) {
        tmp->remote_url = spif_url_new_from_unixaddr((spif_unixsockaddr_t) addr);
    }
    SPIF_DEALLOC(addr);
    if (SPIF_SOCKET_FLAGS_IS_SET(self, SPIF_SOCKET_FLAGS_NBIO)) {
        spif_socket_set_nbio(tmp);
    }
    return tmp;
}