25 #include <dahdi/tonezone.h>
28 #define PROGRAM "zones2indication"
30 void print_tone_zone_sound(
struct ind_tone_zone *zone_data,
const char* name,
33 for (i=0; i<DAHDI_TONE_MAX; i++) {
34 if (zone_data->tones[i].toneid == toneid){
35 printf(
"%s = %s\n", name, zone_data->tones[i].data);
41 void print_indications(
struct ind_tone_zone *zone_data) {
46 "; Source: libtonezone.\n"
49 zone_data->country, zone_data->description
56 if (zone_data->ringcadence[i] == 0)
60 printf(
"%d",zone_data->ringcadence[i]);
64 print_tone_zone_sound(zone_data,
"dial", DAHDI_TONE_DIALTONE);
65 print_tone_zone_sound(zone_data,
"busy", DAHDI_TONE_BUSY);
66 print_tone_zone_sound(zone_data,
"ring", DAHDI_TONE_RINGTONE);
67 print_tone_zone_sound(zone_data,
"congestion", DAHDI_TONE_CONGESTION);
68 print_tone_zone_sound(zone_data,
"callwaiting", DAHDI_TONE_CALLWAIT);
69 print_tone_zone_sound(zone_data,
"dialrecall", DAHDI_TONE_DIALRECALL);
70 print_tone_zone_sound(zone_data,
"record", DAHDI_TONE_RECORDTONE);
71 print_tone_zone_sound(zone_data,
"info", DAHDI_TONE_INFO);
72 print_tone_zone_sound(zone_data,
"stutter", DAHDI_TONE_STUTTER);
76 int print_zone_by_id(
int zone_num) {
77 struct tone_zone *zone_data = tone_zone_find_by_num(zone_num);
79 if (zone_data == NULL)
82 print_indications(zone_data);
87 int print_zone_by_country(
char* country) {
88 struct tone_zone *zone_data = tone_zone_find(country);
90 if (zone_data == NULL)
93 print_indications(zone_data);
102 if (print_zone_by_id(i))
110 PROGRAM
": print libtonezone data as Asterisk indications.conf\n"
113 " " PROGRAM
" -a Print all countries\n"
114 " " PROGRAM
" -c <code> Select country by two-letter country code\n"
115 " " PROGRAM
" -n <num> Select country by its internal libtonezone number\n"
116 " " PROGRAM
" -h Print this text.\n"
120 int main(
int argc,
char* argv[]){
121 int country_code = -1;
122 int opt_print_all = 0;
126 while((opt = getopt(argc, argv,
"ac:hn:")) != -1) {
131 return print_zone_by_country(optarg);
136 printf(
"number is %s.\n", optarg);
137 country_code = strtol(optarg, &endptr, 10);
138 return print_zone_by_id(country_code);
int main(int argc, char *argv[])