#include #include #include #include #include #include int main(int argc, char *argv[]) { FILE *fp = NULL; char linebuff[256]; char *context = NULL; char *extension = NULL; int maxretries = 2; int retrytime = 60; int waittime = 30; int priority = 1; int numvoicemails = 0; char *channel = "Channel: Zap/g1"; int debug = 1; if(argc < 4) { perror("Insufficient arguements\n"); return; } numvoicemails = atoi(argv[3]); extension = argv[2]; if (numvoicemails > 0) { context = "havevoicemail"; } else context = "novoicemail"; /* open up the pipe to the asterisk spool */ if((fp = fopen("/var/spool/asterisk/outgoing/sp0132.call", "w+")) == NULL) { perror("Problem opening spool\n"); // return; } for (debug = 1; debug >= 0; debug--) { if (debug = 0) { fp = fopen("/tmp/o0utpe.i32", "w+"); if (!fp) { perror("Couldn't open debug test file\n"); } } /* Ok, now let's start writing the file to the spool */ fprintf(fp, "%s\n", channel); fprintf(fp, "MaxRetries: %d\n", maxretries); fprintf(fp, "RetryTime: %d\n", retrytime); fprintf(fp, "WaitTime: %d\n", waittime); fprintf(fp, "Context: %s\n", context); fprintf(fp, "Extension: %s\n", extension); fprintf(fp, "Priority: %d\n", priority); /* Clean it up... */ fclose(fp); } return; }