const char *json_object_iter_key(void *iter) { if(!iter) return NULL; return (const char *)hashtable_iter_key(iter); }
const object_key_t *jsonp_object_iter_fullkey(void *iter) { if(!iter) return NULL; return (object_key_t *) hashtable_iter_key(iter); }
ta_list_t * bitu_plugin_ctx_get_list (bitu_plugin_ctx_t *plugin_ctx) { void *iter; ta_list_t *ret = NULL; iter = hashtable_iter (plugin_ctx->plugins); if (iter == NULL) return NULL; do ret = ta_list_append (ret, hashtable_iter_key (iter)); while ((iter = hashtable_iter_next (plugin_ctx->plugins, iter))); return ret; }
static char * cmd_env (bitu_app_t *app, char **TA_UNUSED(params), int num_params) { void *iter; char *error, *val, *tmp, *pos, *list = NULL; size_t val_size, current_size = 0, full_size = 0, step = 256, lastp = 0; if ((error = _validate_num_params ("env", 0, num_params)) != NULL) return error; iter = hashtable_iter (app->environment); if (iter == NULL) return NULL; do { val = hashtable_iter_key (iter); val_size = strlen (val); current_size += val_size + 1; if (full_size < current_size) { full_size += step; if ((tmp = realloc (list, full_size)) == NULL) { free (list); return NULL; } else list = tmp; } pos = list + lastp; memcpy (pos, val, val_size); memcpy (pos+val_size, "\n", 1); lastp += val_size + 1; } while ((iter = hashtable_iter_next (app->environment, iter))); list[current_size-1] = '\0'; return list; }
void *pc_map_iter_key(void *iter) { return hashtable_iter_key(iter); }
static char * cmd_list (bitu_app_t *app, char **params, int num_params) { char *action, *ret; char *error; if ((error = _validate_num_params ("list", 1, num_params)) != NULL) return error; ret = NULL; action = params[0]; if (strcmp (action, "plugins") == 0) { ta_list_t *plugins, *tmp; char *val, *tmp_val, *current_pos_str; size_t val_size, current_pos, full_size = 0; plugins = bitu_plugin_ctx_get_list (app->plugin_ctx); for (tmp = plugins; tmp; tmp = tmp->next) { val = tmp->data; /* This +1 means the \n at the end of each line. */ val_size = strlen (val) + 1; /* Remembering current end of the full string. */ current_pos = full_size; full_size += val_size; if ((tmp_val = realloc (ret, full_size)) == NULL) { free (ret); return NULL; } else ret = tmp_val; current_pos_str = ret + current_pos; memcpy (current_pos_str, val, val_size); memcpy (current_pos_str + val_size - 1, "\n", 1); } /* Removing the last \n. It is not needed in the end of the * string */ if (ret != NULL) { memcpy (ret + full_size - 1, "\0", 1); ta_list_free (plugins); } } else if (strcmp (action, "commands") == 0) { void *iter; char *val, *tmp, *current_pos_str; size_t val_size, current_pos, full_size = 0; iter = hashtable_iter (app->commands); if (iter == NULL) return NULL; do { val = hashtable_iter_key (iter); /* This +1 means the \n at the end of each line. */ val_size = strlen (val) + 1; /* Remembering current end of the full string. */ current_pos = full_size; full_size += val_size; if ((tmp = realloc (ret, full_size)) == NULL) { free (ret); return NULL; } else ret = tmp; current_pos_str = ret + current_pos; memcpy (current_pos_str, val, val_size); memcpy (current_pos_str + val_size - 1, "\n", 1); } while ((iter = hashtable_iter_next (app->commands, iter))); /* Removing the last \n. It is not needed in the end of the string */ ret[full_size-1] = '\0'; } else ret = strdup ("Possible values are `commands' or `plugins'"); return ret; }