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 *file, const char *function, int line, unsigned int mask, const char *fmt, ...)
37 void _printerror(const char *file, 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[])
55 char options_error[256];
57 if (!read_options(options_error)) {
58 PERROR("%s", options_error);
63 printf("Usage: %s <extension> <interfaces> <callerid>\n\n", argv[0]);
64 printf("extension: any number for the extension (e.g 200)\n");
65 printf("interfaces: internal interface(s) to reach extension, NOT port numbers\n");
66 printf(" -> seperate multiple interfaces with 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", EXTENSION_DATA, argv[1]);
72 if (mkdir(pathname, 0755) < 0) {
74 PERROR("Extension's directory already exists. Nothing done!\n");
75 else PERROR("Cannot open extension's directory '%s'.\n", pathname);
79 memset(&ext, 0, sizeof(ext));
82 ext.vbox_codec = CODEC_MONO;
83 UCPY(ext.interfaces, argv[2]);
84 UCPY(ext.callerid, argv[3]);
85 ext.callerid_present = INFO_PRESENT_ALLOWED;
86 ext.callerid_type = INFO_NTYPE_UNKNOWN;
87 ext.change_forward = 1;
89 write_extension(&ext, argv[1]);
91 SPRINT(pathname, "%s/%s/phonebook", EXTENSION_DATA, argv[1]);
92 if (!(fp = fopen(pathname, "w"))) {
93 PERROR("Failed to write phonebook example '%s'.\n", pathname);
96 fprintf(fp, "# fromat: <shortcut> <phone number> [<Name>]\n");
97 fprintf(fp, "# The shotcut may have any number of digits. \n");
98 fprintf(fp, "# The phone number must include the dialing code for external, internal or\n");
99 fprintf(fp, "# other type of dialing. \n");
100 fprintf(fp, "# The name must not be in quotes. All 2 or 3 attributes must be seperated by\n");
101 fprintf(fp, "# white space(s) and/or tab(s)\n");
102 fprintf(fp, "# Empty lines and lines starting with '#' will be ignored.\n");
104 fprintf(fp, "0 008003301000 German Telekom Service\n");
105 fprintf(fp, "10 011880 Directory Service Telegate\n");
106 fprintf(fp, "11 011833 Directory Service DTAG\n");
107 fprintf(fp, "12 011811 Directory Service Fred\n");
111 SPRINT(pathname, "%s/%s/secrets", EXTENSION_DATA, argv[1]);
112 if (!(fp = fopen(pathname, "w"))) {
113 PERROR("Failed to write secrets example '%s'.\n", pathname);
116 fprintf(fp, "# Format: <remote number> <key exchange> <cypher> [<key>]\n");
117 fprintf(fp, "# The remote number must match the dialed number for outgoing calls.\n");
118 fprintf(fp, "# The remote number must match the caller id for incoming calls.\n");
119 fprintf(fp, "# The caller id must include the prefix digits as received.\n");
120 fprintf(fp, "# The key exchange method must be given: e.g 'manual'\n");
121 fprintf(fp, "# The cypher method must be given: e.g 'blowfish'\n");
122 fprintf(fp, "# The key must be a string of characters (ASCII) or 0xXXXXXX...\n");
123 fprintf(fp, "# All 2 or 3 attributes must be seperated by white space(s) and/or tab(s)\n");
124 fprintf(fp, "# Empty lines and lines starting with '#' will be ignored.\n\n");
125 fprintf(fp, "###############################################################################\n");
126 fprintf(fp, "## REFER TO THE DOCUMENTATION FOR DETAILS ON ENCRYPTION AND KEYS! ##\n");
127 fprintf(fp, "###############################################################################\n");
129 fprintf(fp, "# This examples explains the format, NEVER USE IT, it would be dumb!\n");
130 fprintf(fp, "021250993 manual blowfish 0x012345678\n");
133 printf("Extension %s created at %s/%s/.\n", argv[1], EXTENSION_DATA, argv[1]);