X-Git-Url: http://git.eversberg.eu/gitweb.cgi?p=lcr.git;a=blobdiff_plain;f=genext.c;h=4d34bbe51e0b8d8f6d513e89a0691252ad14d13e;hp=bd4226bfb7af35310456d5f18c25ea73c927af1f;hb=5a7b2b52008bbd8d64c6b1fe6a1f7398312afb5d;hpb=d2b113f2c4f11acfaee1b2e0fd2f03744a89f6d4 diff --git a/genext.c b/genext.c index bd4226b..4d34bbe 100644 --- a/genext.c +++ b/genext.c @@ -52,15 +52,14 @@ int main(int argc, char *argv[]) struct extension ext; char pathname[256]; FILE *fp; + char options_error[256]; - if (!read_options()) - { + if (!read_options(options_error)) { PERROR("%s", options_error); return(-1); } - if (argc != 4) - { + if (argc != 4) { printf("Usage: %s \n\n", argv[0]); printf("extension: any number for the extension (e.g 200)\n"); printf("interfaces: internal interface(s) to reach extension, NOT port numbers\n"); @@ -69,9 +68,8 @@ int main(int argc, char *argv[]) return(0); } - SPRINT(pathname, "%s/%s/%s", INSTALL_DATA, options.extensions_dir, argv[1]); - if (mkdir(pathname, 0755) < 0) - { + SPRINT(pathname, "%s/%s", EXTENSION_DATA, argv[1]); + if (mkdir(pathname, 0755) < 0) { if (errno == EEXIST) PERROR("Extension's directory already exists. Nothing done!\n"); else PERROR("Cannot open extension's directory '%s'.\n", pathname); @@ -90,13 +88,11 @@ int main(int argc, char *argv[]) ext.facility = 1; write_extension(&ext, argv[1]); - SPRINT(pathname, "%s/%s/%s/phonebook", INSTALL_DATA, options.extensions_dir, argv[1]); - if (!(fp = fopen(pathname, "w"))) - { + SPRINT(pathname, "%s/%s/phonebook", EXTENSION_DATA, argv[1]); + if (!(fp = fopen(pathname, "w"))) { PERROR("Failed to write phonebook example '%s'.\n", pathname); return(-1); - } else - { + } else { fprintf(fp, "# fromat: []\n"); fprintf(fp, "# The shotcut may have any number of digits. \n"); fprintf(fp, "# The phone number must include the dialing code for external, internal or\n"); @@ -112,13 +108,11 @@ int main(int argc, char *argv[]) fclose(fp); } - SPRINT(pathname, "%s/%s/%s/secrets", INSTALL_DATA, options.extensions_dir, argv[1]); - if (!(fp = fopen(pathname, "w"))) - { + SPRINT(pathname, "%s/%s/secrets", EXTENSION_DATA, argv[1]); + if (!(fp = fopen(pathname, "w"))) { PERROR("Failed to write secrets example '%s'.\n", pathname); return(-1); - } else - { + } else { fprintf(fp, "# Format: []\n"); fprintf(fp, "# The remote number must match the dialed number for outgoing calls.\n"); fprintf(fp, "# The remote number must match the caller id for incoming calls.\n"); @@ -136,7 +130,7 @@ int main(int argc, char *argv[]) fprintf(fp, "021250993 manual blowfish 0x012345678\n"); fclose(fp); } - printf("Extension %s created at %s/%s/%s/.\n", argv[1], INSTALL_DATA, options.extensions_dir, argv[1]); + printf("Extension %s created at %s/%s/.\n", argv[1], EXTENSION_DATA, argv[1]); return(0); }