// $FreeBSD: src/share/examples/isdn/contrib/answer.c,v 1.1.2.1 2001/08/10 14:59:47 obrien Exp $ // $DragonFly: src/share/examples/isdn/contrib/answer.c,v 1.2 2003/06/17 04:36:57 dillon Exp $ // changed ".g711a" to ".al" (-hm) // Tue Mar 3 02:42:14 MET 1998 dave@turbocat.de // started #define BLK_SIZE 2048 #define SOX "/usr/local/bin/sox" #define ALAWULAW "/usr/local/bin/alaw2ulaw" #include #include FILE *device; FILE *logfile; char srcNum[30]; char destNum[30]; char argbuf[255]; char tmpBuf[1024] = ""; void writeToPhone (char *path) { char buf[BLK_SIZE]; FILE *srcfile; int i = 0; int readcount = 0; srcfile = fopen(path,"r"); if (srcfile) { for (i=0;i 2) { argbuf[strlen(argbuf)-1] = '\0'; } device = fopen(argWithName("-D"),"r+"); strcpy(destNum, argWithName("-d")); strcpy(srcNum, argWithName("-s")); fprintf(logfile,"device '%s'\n", argWithName("-D")); fprintf(logfile,"srcNum '%s'\n", srcNum); fprintf(logfile,"destNum '%s'\n", destNum); if (device) { strftime(timeStr,40,I4B_TIME_FORMAT,localtime(&now)); sprintf(outfileName,"/var/isdn/%s_%s_%s", timeStr, srcNum, destNum); writeToPhone ("/usr/local/lib/isdn/msg.al"); readFromPhone (outfileName); sprintf(cmdStr,"/bin/cat %s | %s | %s -t raw -U -b -r 8000 - -t .au %s.snd", outfileName, ALAWULAW, SOX, outfileName); fprintf(logfile,"%s\n",cmdStr); system(cmdStr); unlink(outfileName); fclose(device); } else { fprintf(logfile,"Can't open file '%s'\n",argWithName("-D")); } now=time(NULL); strftime(timeStr,40,I4B_TIME_FORMAT,localtime(&now)); fprintf(logfile,"%s Done\n",timeStr); fclose(logfile); exit(0); // insure the process exit status is 0 return 0; // ...and make main fit the ANSI spec. }