int ftrigr_check (ftrigr_ref a, uint16 id, char *c) { ftrigr1_t *p ; if (!id--) return (errno = EINVAL, -1) ; p = GENSETDYN_P(ftrigr1_t, &a->data, id) ; if (!p) return (errno = EINVAL, -1) ; switch (p->state) { case FR1STATE_WAITACKDATA : { *c = p->what ; *p = ftrigr1_zero ; gensetdyn_delete(&a->data, id) ; return 1 ; } case FR1STATE_LISTENING : { register unsigned int r = p->count ; if (r) *c = p->what ; p->count = 0 ; return (int)r ; } case FR1STATE_WAITACK : { errno = p->what ; *p = ftrigr1_zero ; gensetdyn_delete(&a->data, id) ; return -1 ; } default: return (errno = EINVAL, -1) ; } return 0 ; }
int ftrigr_unsubscribe (ftrigr_ref a, uint16 i, tain_t const *deadline, tain_t *stamp) { ftrigr1_t *p ; if (!i--) return (errno = EINVAL, 0) ; p = GENSETDYN_P(ftrigr1_t, &a->data, i) ; if (!p) return (errno = EINVAL, 0) ; switch (p->state) { case FR1STATE_WAITACK : case FR1STATE_WAITACKDATA : { char dummy ; ftrigr_check(a, i+1, &dummy) ; return 1 ; } default : break ; } { char err ; char pack[3] = "--U" ; uint16_pack_big(pack, i) ; if (!skaclient_send(&a->connection, pack, 3, &skaclient_default_cb, &err, deadline, stamp)) return 0 ; if (err) return (errno = err, 0) ; } *p = ftrigr1_zero ; return gensetdyn_delete(&a->data, i) ; }
int boz_connect_release(const boz_connect_t id) { boz_connect_internal_t *p=NULL; BOZ_CONNECT_EMPIRIC_BAD_ID_TEST p = GENSETDYN_P(boz_connect_internal_t, &boz_connect_g.storage, id); if(p->id != id) return (errno=ENOMSG,-1); bufalloc_free(&p->d_out); free(p->b_in); if(fcntl(p->params.fd, F_GETFD)>0) close(p->params.fd); p->b_in=0; (*p) = boz_connect_internal_zero; { iter_max_stuff_t stuff = { 0 }; gensetdyn_iter(&boz_connect_g.storage, iter_max, &stuff); boz_connect_g.max=stuff.max; } gensetdyn_delete(&boz_connect_g.storage, id); return (errno=0,0); }
int boz_discovery_term(boz_disc_t *mgr) { int ret=-1; if(!mgr || !(*mgr)) return (errno=EINVAL,-1); if((*mgr)->magic!=g_disco_main.magic) return (errno=EINVAL,-1); BOZDISCO_LOCK_MUTEX(g_disco_main.mutex); ret=gensetdyn_delete (&g_disco_main.mgr, (*mgr)->idx); if(!ret) { BOZDISCO_UNLOCK_MUTEX(g_disco_main.mutex); return (errno=EIO,-1); } gensetdyn_free (&(*mgr)->reg); (*mgr)->reg = gensetdyn_zero; (*mgr)->idx = -1; (*mgr)->magic = 0; pthread_mutex_destroy(&(*mgr)->mutex); BOZDISCO_UNLOCK_MUTEX(g_disco_main.mutex); (*mgr)=BOZ_DISC_ZERO; return (errno=0,0); }
int s6lock_release (s6lock_t *a, uint16 i, tain_t const *deadline, tain_t *stamp) { char *p = GENSETDYN_P(char, &a->data, i) ; if ((*p != EBUSY) && !error_isagain(*p)) { s6lock_check(a, i) ; return 1 ; } { char err ; char pack[3] = "-->" ; uint16_pack_big(pack, i) ; if (!skaclient_send(&a->connection, pack, 3, &skaclient_default_cb, &err, deadline, stamp)) return 0 ; if (err) return (errno = err, 0) ; } *p = EINVAL ; return gensetdyn_delete(&a->data, i) ; }
void nx_json_ska_free(nx_json* p) { assert(p); gensetdyn_delete(&nx_json_nodes, p->alloc_idx); }