示例#1
0
static u_char *ast_var_indications(struct variable *vp, oid *name, size_t *length,
                                   int exact, size_t *var_len, WriteMethod **write_method)
{
    static unsigned long long_ret;
    struct tone_zone *tz = NULL;

    if (header_generic(vp, name, length, exact, var_len, write_method))
        return NULL;

    switch (vp->magic) {
    case ASTINDCOUNT:
        long_ret = 0;
        while ( (tz = ast_walk_indications(tz)) )
            long_ret++;

        return (u_char *)&long_ret;
    case ASTINDCURRENT:
        tz = ast_get_indication_zone(NULL);
        if (tz) {
            *var_len = strlen(tz->country);
            return (u_char *)tz->country;
        }
        *var_len = 0;
        return NULL;
    default:
        break;
    }
    return NULL;
}
示例#2
0
/*
 * SHOW INDICATIONS command stuff
 */
static int handle_show_indications(int fd, int argc, char *argv[])
{
	struct ind_tone_zone *tz = NULL;
	char buf[256];
	int found_country = 0;

	if (argc == 2) {
		/* no arguments, show a list of countries */
		ast_cli(fd,"Country Alias   Description\n"
			   "===========================\n");
		while ( (tz = ast_walk_indications(tz) ) )
			ast_cli(fd,"%-7.7s %-7.7s %s\n", tz->country, tz->alias, tz->description);
		return 0;
	}
	/* there was a request for specific country(ies), lets humor them */
	while ( (tz = ast_walk_indications(tz) ) ) {
		int i,j;
		for (i=2; i<argc; i++) {
			if (strcasecmp(tz->country,argv[i])==0 &&
			    !tz->alias[0]) {
				struct ind_tone_zone_sound* ts;
				if (!found_country) {
					found_country = 1;
					ast_cli(fd,"Country Indication      PlayList\n"
						   "=====================================\n");
				}
				j = snprintf(buf,sizeof(buf),"%-7.7s %-15.15s ",tz->country,"<ringcadence>");
				for (i=0; i<tz->nrringcadence; i++) {
					j += snprintf(buf+j,sizeof(buf)-j,"%d,",tz->ringcadence[i]);
				}
				if (tz->nrringcadence)
					j--;
				ast_copy_string(buf+j,"\n",sizeof(buf)-j);
				ast_cli(fd,buf);
				for (ts=tz->tones; ts; ts=ts->next)
					ast_cli(fd,"%-7.7s %-15.15s %s\n",tz->country,ts->name,ts->data);
				break;
			}
		}
	}
	if (!found_country)
		ast_cli(fd,"No countries matched your criteria.\n");
	return -1;
}
示例#3
0
static u_char *ast_var_indications_table(struct variable *vp, oid *name, size_t *length,
        int exact, size_t *var_len, WriteMethod **write_method)
{
    static unsigned long long_ret;
    struct tone_zone *tz = NULL;
    int i;

    if (header_simple_table(vp, name, length, exact, var_len, write_method, -1))
        return NULL;

    i = name[*length - 1] - 1;
    while ( (tz = ast_walk_indications(tz)) && i )
        i--;
    if (tz == NULL)
        return NULL;

    switch (vp->magic) {
    case ASTINDINDEX:
        long_ret = name[*length - 1];
        return (u_char *)&long_ret;
    case ASTINDCOUNTRY:
        *var_len = strlen(tz->country);
        return (u_char *)tz->country;
    case ASTINDALIAS:
        if (tz->alias) {
            *var_len = strlen(tz->alias);
            return (u_char *)tz->alias;
        }
        return NULL;
    case ASTINDDESCRIPTION:
        *var_len = strlen(tz->description);
        return (u_char *)tz->description;
    default:
        break;
    }
    return NULL;
}