static u_char *ast_var_channel_types_table(struct variable *vp, oid *name, size_t *length, int exact, size_t *var_len, WriteMethod **write_method) { const struct ast_channel_tech *tech = NULL; struct ast_variable *channel_types, *next; static unsigned long long_ret; struct ast_channel *chan; u_long i; if (header_simple_table(vp, name, length, exact, var_len, write_method, -1)) return NULL; channel_types = ast_channeltype_list(); for (i = 1, next = channel_types; next && i != name[*length - 1]; next = next->next, i++) ; if (next != NULL) tech = ast_get_channel_tech(next->name); ast_variables_destroy(channel_types); if (next == NULL || tech == NULL) return NULL; switch (vp->magic) { case ASTCHANTYPEINDEX: long_ret = name[*length - 1]; return (u_char *)&long_ret; case ASTCHANTYPENAME: *var_len = strlen(tech->type); return (u_char *)tech->type; case ASTCHANTYPEDESC: *var_len = strlen(tech->description); return (u_char *)tech->description; case ASTCHANTYPEDEVSTATE: long_ret = tech->devicestate ? 1 : 2; return (u_char *)&long_ret; case ASTCHANTYPEINDICATIONS: long_ret = tech->indicate ? 1 : 2; return (u_char *)&long_ret; case ASTCHANTYPETRANSFER: long_ret = tech->transfer ? 1 : 2; return (u_char *)&long_ret; case ASTCHANTYPECHANNELS: long_ret = 0; for (chan = ast_channel_walk_locked(NULL); chan; chan = ast_channel_walk_locked(chan)) { if (chan->tech == tech) long_ret++; ast_channel_unlock(chan); } return (u_char *)&long_ret; default: break; } return NULL; }
static u_char *ast_var_channel_types(struct variable *vp, oid *name, size_t *length, int exact, size_t *var_len, WriteMethod **write_method) { static unsigned long long_ret; struct ast_variable *channel_types, *next; if (header_generic(vp, name, length, exact, var_len, write_method)) return NULL; if (vp->magic != ASTCHANTYPECOUNT) return NULL; for (long_ret = 0, channel_types = next = ast_channeltype_list(); next; next = next->next) long_ret++; ast_variables_destroy(channel_types); return (u_char *)&long_ret; }
static u_char *ast_var_channel_types(struct variable *vp, oid *name, size_t *length, int exact, size_t *var_len, WriteMethod **write_method) { static unsigned long long_ret; struct ast_variable *channel_types, *next; if (header_generic(vp, name, length, exact, var_len, write_method)) return NULL; switch (vp->magic) { case ASTCHANTYPECOUNT: long_ret = 0; for (channel_types = next = ast_channeltype_list(); next; next = next->next) { long_ret++; } ast_variables_destroy(channel_types); return (u_char *)&long_ret; default: break; } return NULL; }