static int get_rlist_result (zhash_t *mods, flux_mrpc_t *mrpc, uint32_t nodeid, int *ep) { JSON o = NULL; int rc = -1; const char *name, *digest; int i, len, errnum, size, idle; module_t *m; if (flux_mrpc_get_outarg_obj (mrpc, nodeid, &o) < 0) goto done; if (modctl_rlist_dec (o, &errnum, &len) < 0) goto done; for (i = 0; i < len; i++) { if (modctl_rlist_dec_nth (o, i, &name, &size, &digest, &idle) < 0) goto done; if (!(m = zhash_lookup (mods, digest))) { if (!(m = module_create (name, size, digest, idle, nodeid))) goto done; zhash_update (mods, digest, m); zhash_freefn (mods, digest, (zhash_free_fn *)module_destroy); } else if (module_update (m, idle, nodeid) < 0) goto done; } *ep = errnum; rc = 0; done: Jput (o); return rc; }
char *quiz_change_string(bot_t * bot, char *string, int opt) { unique_t *bu = NULL; quiz_active_t **qa = NULL; dlist_t *dl = NULL; char **arg_array = NULL; char *str = NULL; char buf[MAX_BUF_SZ]; char *sep_ptr; debug(bot, "quiz_change_string: Entered\n"); if (!bot || !string) return NULL; sep_ptr = str_find_sep(string); if (sep_ptr) string = sep_ptr; bu = unique_create(bot, &dl_quiz_active_unique, UNIQUE_ID_TAG | UNIQUE_ID_CHAN); if (!bu) return NULL; qa = (quiz_active_t **) & bu->data; if (!qa) { } _memset(buf, 0, sizeof(buf)); if (strlen(string)) { dl = tokenize(bot, string, TOKENIZE_NORMAL | TOKENIZE_EATWHITESPACE, " "); if (!dl) return NULL; arg_array = (char **)dlist_convert_dlist_to_array(dl); if (!arg_array) goto cleanup; capsup(arg_array[0]); } switch (opt) { case QUIZ_OPT_LIST: { str = quiz_op_list(bot); break; } case QUIZ_OPT_INFO: { str = quiz_op_info(bot, *qa); break; } case QUIZ_OPT_CLEAR: { str = quiz_op_clear(bot, *qa); break; } case QUIZ_OPT_CLEAR_WINNERS: { str = quiz_op_clear_winners(bot, *qa); break; } case QUIZ_OPT_WINNERS: { str = quiz_op_winners(bot, *qa); break; } case QUIZ_OPT_SETUP: { str = quiz_op_setup(bot, qa, string); if (str) { module_t *m_ptr = NULL; mod_quiz_info.timer = quiz_timer; m_ptr = module_find_by_name("mod_quiz"); if (m_ptr) { m_ptr->timer = quiz_timer; module_update(m_ptr, "mod_quiz"); } } if (*qa) bu->data = *qa; break; } case QUIZ_OPT_ANSWER: { str = quiz_op_answer(bot, *qa, string); break; } case QUIZ_OPT_GET: { if (!arg_array[1]) return NULL; str = quiz_op_get(bot, arg_array[0], atoi(arg_array[1])); break; } case QUIZ_OPT_DEL: { break; } case QUIZ_OPT_TIMEOUT: { str = quiz_op_timeout(bot, *qa, atoi(arg_array[0])); break; } case QUIZ_OPT_SIZE: { str = quiz_op_size(bot, arg_array[0]); break; } case QUIZ_OPT_MULTI: { str = quiz_op_multi(bot, *qa, arg_array[0]); break; } case QUIZ_OPT_NEWLINES: { str = quiz_op_newlines(bot, *qa, arg_array[0]); break; } case QUIZ_OPT_HIDEKEY: { str = quiz_op_hidekey(bot, *qa, arg_array[1]); break; } default: break; } cleanup: if (dl) tokenize_destroy(bot, &dl); if (arg_array) free(arg_array); if (str) bot->shouldsend = 1; return str; }