Reported by: tzafrir
Replace a bunch of if defined checks for Zaptel/DAHDI through several new defines in dahdi_compat.h. This removes a lot of code duplication. Example from bug:
#ifdef HAVE_ZAPTEL
fd = open("/dev/zap/pseudo", O_RDWR);
#else
fd = open("/dev/dahdi/pseudo", O_RDWR);
#endif
is replaced with:
fd = open(DAHDI_FILE_PSEUDO, O_RDRW);
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@165991 65c4cc65-6c06-0410-ace0-fbb531ad65f3
@ -3034,53 +3034,35 @@ int main(int argc, char *argv[])
dahdi_chan_name_len=&_dahdi_chan_name_len;
dahdi_chan_mode=&_dahdi_chan_mode;
#ifdef HAVE_ZAPTEL
{
intfd;
intx=160;
fd=open("/dev/zap/timer",O_RDWR);
if(fd>=0){
if(ioctl(fd,DAHDI_TIMERCONFIG,&x)){
ast_log(LOG_ERROR,"You have Zaptel built and drivers loaded, but the Zaptel timer test failed to set ZT_TIMERCONFIG to %d.\n",x);
exit(1);
}
if((x=ast_wait_for_input(fd,300))<0){
ast_log(LOG_ERROR,"You have Zaptel built and drivers loaded, but the Zaptel timer could not be polled during the Zaptel timer test.\n");
exit(1);
}
if(!x){
constcharzaptel_timer_error[]={
"Asterisk has detected a problem with your Zaptel configuration and will shutdown for your protection. You have options:"
"\n\t1. You only have to compile Zaptel support into Asterisk if you need it. One option is to recompile without Zaptel support."
"\n\t2. You only have to load Zaptel drivers if you want to take advantage of Zaptel services. One option is to unload zaptel modules if you don't need them."
"\n\t3. If you need Zaptel services, you must correctly configure Zaptel."
};
ast_log(LOG_ERROR,"%s\n",zaptel_timer_error);
exit(1);
}
close(fd);
}
}
#elif defined(HAVE_DAHDI)
{
intfd;
intx=160;
fd=open("/dev/dahdi/timer",O_RDWR);
fd=open(DAHDI_FILE_TIMER,O_RDWR);
if(fd>=0){
if(ioctl(fd,DAHDI_TIMERCONFIG,&x)){
ast_log(LOG_ERROR,"You have DAHDI built and drivers loaded, but the DAHDI timer test failed to set DAHDI_TIMERCONFIG to %d.\n",x);
ast_log(LOG_ERROR,"You have "DAHDI_NAME
" built and drivers loaded, but the "
DAHDI_NAME" timer test failed to set DAHDI_TIMERCONFIG to %d.\n",x);
exit(1);
}
if((x=ast_wait_for_input(fd,300))<0){
ast_log(LOG_ERROR,"You have DAHDI built and drivers loaded, but the DAHDI timer could not be polled during the DAHDI timer test.\n");
ast_log(LOG_ERROR,"You have "DAHDI_NAME
"built and drivers loaded, but the "
DAHDI_NAME" timer could not be polled during the "
DAHDI_NAME" timer test.\n");
exit(1);
}
if(!x){
constchardahdi_timer_error[]={
"Asterisk has detected a problem with your DAHDI configuration and will shutdown for your protection. You have options:"
"\n\t1. You only have to compile DAHDI support into Asterisk if you need it. One option is to recompile without DAHDI support."
"\n\t2. You only have to load DAHDI drivers if you want to take advantage of DAHDI services. One option is to unload DAHDI modules if you don't need them."
"\n\t3. If you need DAHDI services, you must correctly configure DAHDI."
"Asterisk has detected a problem with your "DAHDI_NAME
" configuration and will shutdown for your protection. You have options:"
"\n\t1. You only have to compile "DAHDI_NAME
" support into Asterisk if you need it. One option is to recompile without "
DAHDI_NAME" support."
"\n\t2. You only have to load "DAHDI_NAME" drivers if you want to take advantage of "
DAHDI_NAME" services. One option is to unload "
DAHDI_NAME" modules if you don't need them."
"\n\t3. If you need Zaptel services, you must correctly configure "DAHDI_NAME"."
};
ast_log(LOG_ERROR,"%s\n",dahdi_timer_error);
exit(1);
@ -3088,8 +3070,6 @@ int main(int argc, char *argv[])