1 /*****************************************************************************\
5 **---------------------------------------------------------------------------**
6 ** Copyright: Andreas Eversberg **
8 ** generate extension **
10 \*****************************************************************************/
18 #include <sys/types.h>
30 struct isdn_cause isdn_cause[128];
31 struct isdn_location isdn_location[16];
33 void _printdebug(const char *function, int line, unsigned long mask, const char *fmt, ...)
37 void _printerror(const char *function, int line, const char *fmt, ...)
43 VUNPRINT(buffer,sizeof(buffer)-1,fmt,args);
44 buffer[sizeof(buffer)-1]=0;
47 fprintf(stderr, "%s", buffer);
50 int main(int argc, char *argv[])
58 PERROR("Failed to read options.conf\n");
64 printf("Usage: %s <extension> <interfaces> <callerid>\n\n", argv[0]);
65 printf("extension: any number for the extension (e.g 200)\n");
66 printf("interfaces: internal interface(es) to reach extension (seperated by commas. e.g Int1,Int2)\n");
67 printf("callerid: normal undefined called is (use what your telco assigned you)\n");
71 SPRINT(pathname, "%s/%s/%s", INSTALL_DATA, options.extensions_dir, argv[1]);
72 if (mkdir(pathname, 0755) < 0)
75 PERROR("Extension's directory already exists. Nothing done!\n");
76 else PERROR("Cannot open extension's directory '%s'.\n", pathname);
80 memset(&ext, 0, sizeof(ext));
83 ext.tout_dialing = 120;
84 ext.tout_proceeding = 120;
85 ext.tout_alerting = 120;
86 ext.tout_disconnect = 120;
87 // ext.tout_hold = 900;
88 // ext.tout_park = 900;
90 ext.vbox_codec = CODEC_MONO;
91 UCPY(ext.interfaces, argv[2]);
92 UCPY(ext.callerid, argv[3]);
93 ext.callerid_present = INFO_PRESENT_ALLOWED;
94 ext.callerid_type = INFO_NTYPE_UNKNOWN;
95 ext.change_forward = 1;
97 write_extension(&ext, argv[1]);
99 SPRINT(pathname, "%s/%s/%s/phonebook", INSTALL_DATA, options.extensions_dir, argv[1]);
100 if (!(fp = fopen(pathname, "w")))
102 PERROR("Failed to write phonebook example '%s'.\n", pathname);
106 fprintf(fp, "# fromat: <shortcut> <phone number> [<Name>]\n");
107 fprintf(fp, "# The shotcut may have any number of digits. \n");
108 fprintf(fp, "# The phone number must include the dialing code for external, internal or\n");
109 fprintf(fp, "# other type of dialing. \n");
110 fprintf(fp, "# The name must not be in quotes. All 2 or 3 attributes must be seperated by\n");
111 fprintf(fp, "# white space(s) and/or tab(s)\n");
112 fprintf(fp, "# Empty lines and lines starting with '#' will be ignored.\n");
114 fprintf(fp, "0 008003301000 German Telekom Service\n");
115 fprintf(fp, "10 011880 Directory Service Telegate\n");
116 fprintf(fp, "11 011833 Directory Service DTAG\n");
117 fprintf(fp, "12 011811 Directory Service Fred\n");
121 SPRINT(pathname, "%s/%s/%s/secrets", INSTALL_DATA, options.extensions_dir, argv[1]);
122 if (!(fp = fopen(pathname, "w")))
124 PERROR("Failed to write secrets example '%s'.\n", pathname);
128 fprintf(fp, "# Format: <remote number> <key exchange> <cypher> [<key>]\n");
129 fprintf(fp, "# The remote number must match the dialed number for outgoing calls.\n");
130 fprintf(fp, "# The remote number must match the caller id for incoming calls.\n");
131 fprintf(fp, "# The caller id must include the prefix digits as received.\n");
132 fprintf(fp, "# The key exchange method must be given: e.g 'manual'\n");
133 fprintf(fp, "# The cypher method must be given: e.g 'blowfish'\n");
134 fprintf(fp, "# The key must be a string of characters (ASCII) or 0xXXXXXX...\n");
135 fprintf(fp, "# All 2 or 3 attributes must be seperated by white space(s) and/or tab(s)\n");
136 fprintf(fp, "# Empty lines and lines starting with '#' will be ignored.\n\n");
137 fprintf(fp, "###############################################################################\n");
138 fprintf(fp, "## REFER TO THE DOCUMENTATION FOR DETAILS ON ENCRYPTION AND KEYS! ##\n");
139 fprintf(fp, "###############################################################################\n");
141 fprintf(fp, "# This examples explains the format, NEVER USE IT, it would be dumb!\n");
142 fprintf(fp, "021250993 manual blowfish 0x012345678\n");
145 printf("Extension %s created at %s/%s/%s/.\n", argv[1], INSTALL_DATA, options.extensions_dir, argv[1]);