/* * Returns an array of rk_member structs. */ struct rk_member * rk_get_membership(u_int32_t conf) { struct get_conf_stat_store *walker; struct rk_member *rm; int i, nmembers; walker = findconf(conf); if ((walker = findconf(conf)) == NULL) { if (rk_confinfo(conf) == NULL) return NULL; /* Komerr will be set already */ walker = findconf(conf); /* Cannot fail */ } if (walker->rkm != NULL) return walker->rkm; if (send_reply("101 %d 0 65535\n", conf)) { komerr = get_int(); get_eat('\n'); return NULL; } nmembers = get_int(); rm = calloc(sizeof(struct rk_member), nmembers+1); get_accept('{'); for (i = 0; i < nmembers; i++) { rm[i].rm_member = get_int(); rm[i].rm_added_by = get_int(); read_in_time(&rm[i].rm_added_at); rm[i].rm_type = get_int(); } get_accept('}'); get_accept('\n'); walker->rkm = rm; return rm; }
/* * Returns the conference struct for a given conference. * If it's not in the cache; ask the server for it. */ struct rk_conference * rk_confinfo(u_int32_t conf) { struct get_conf_stat_store *walker; struct rk_conference *c; /* First, see if we have this conference in the cache */ if ((walker = findconf(conf))) return &walker->confer; /* Nope, alloc a new struct and put it into the cache */ if (send_reply("91 %d\n", conf)) { komerr = get_int(); get_eat('\n'); return NULL; } walker = calloc(sizeof(struct get_conf_stat_store), 1); walker->number = conf; c = &walker->confer; readin_conf_stat(c); walker->next = gcs; gcs = walker; return c; }
u_int32_t rk_local_to_global(u_int32_t conf, u_int32_t local) { struct get_conf_stat_store *g; if ((g = findconf(conf)) == NULL) { rk_confinfo(conf); if ((g = findconf(conf)) == NULL) return 0; } if (g->map == NULL) read_lgtable(g); if (local >= g->mapsz) return 0; return g->map[local]; }
char* getconf(char *name) { int i; i = findconf(name); if(i >= 0) return confval[i]; return nil; }
static int next_local(int conf, int local) { struct get_conf_stat_store *g; int i; if ((g = findconf(conf)) == NULL) { rk_confinfo(conf); if ((g = findconf(conf)) == NULL) return 0; } if (g->map == NULL) read_lgtable(g); if (local >= g->mapsz) return 0; for (i = local; i < g->mapsz; i++) if (g->map[i]) return i; return 0; }
void addconf(char *name, char *val) { int i; i = findconf(name); if(i < 0){ if(val == nil || nconf >= MAXCONF) return; i = nconf++; strecpy(confname[i], confname[i]+sizeof(confname[i]), name); } strecpy(confval[i], confval[i]+sizeof(confval[i]), val); }
void newname(int uid) { struct person_store *pp; struct get_conf_stat_store *walker; pp = findperson(uid); if (pp == 0) return; walker = findconf(uid); if (walker == 0) return; free(pp->person.rp_username); pp->person.rp_username = strdup(walker->confer.rc_name); }
static void reread_conf_stat_bg_callback(int err, int arg) { struct get_conf_stat_store *walker; if (err) { printf("reread_conf_stat_bg_callback: error %d\n", err); get_eat('\n'); return; } walker = findconf(arg); if (walker) { free(walker->confer.rc_name); } else { walker = calloc(sizeof(struct get_conf_stat_store), 1); walker->number = arg; walker->next = gcs; gcs = walker; } readin_conf_stat(&walker->confer); }
void invalidate_local(struct rk_text_stat *ts) { struct get_conf_stat_store *g; struct rk_misc_info *mi = ts->rt_misc_info.rt_misc_info_val; int nmi = ts->rt_misc_info.rt_misc_info_len; int i, conf, local; for (i = 0; i < nmi; i++) { if (mi[i].rmi_type != recpt && mi[i].rmi_type != cc_recpt) continue; conf = mi[i].rmi_numeric; if (mi[i+1].rmi_type != loc_no) continue; i++; local = mi[i].rmi_numeric; if ((g = findconf(conf)) == NULL) continue; if (local >= g->mapsz) continue; g->map[local] = 0; } }