(closes issue #13480)

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
This commit is contained in:
Jeff Peeler
2008-12-19 19:48:00 +00:00
parent 5de6848d0c
commit e0bec5d67d
10 changed files with 51 additions and 135 deletions

View File

@@ -230,17 +230,10 @@ static int zap_translate(struct ast_trans_pvt *pvt, int dest, int source)
struct pvt *ztp = pvt->pvt;
int flags;
#ifdef HAVE_ZAPTEL
if ((fd = open("/dev/zap/transcode", O_RDWR)) < 0) {
ast_log(LOG_ERROR, "Failed to open /dev/zap/transcode: %s\n", strerror(errno));
if ((fd = open(DAHDI_FILE_TRANSCODE, O_RDWR)) < 0) {
ast_log(LOG_ERROR, "Failed to open " DAHDI_FILE_TRANSCODE ": %s\n", strerror(errno));
return -1;
}
#else
if ((fd = open("/dev/dahdi/transcode", O_RDWR)) < 0) {
ast_log(LOG_ERROR, "Failed to open /dev/dahdi/transcode: %s\n", strerror(errno));
return -1;
}
#endif
ztp->fmts.srcfmt = (1 << source);
ztp->fmts.dstfmt = (1 << dest);
@@ -422,17 +415,10 @@ static int find_transcoders(void)
int fd, res;
unsigned int x, y;
#ifdef HAVE_ZAPTEL
if ((fd = open("/dev/zap/transcode", O_RDWR)) < 0) {
ast_log(LOG_ERROR, "Failed to open /dev/zap/transcode: %s\n", strerror(errno));
if ((fd = open(DAHDI_FILE_TRANSCODE, O_RDWR)) < 0) {
ast_log(LOG_ERROR, "Failed to open " DAHDI_FILE_TRANSCODE ": %s\n", strerror(errno));
return 0;
}
#else
if ((fd = open("/dev/dahdi/transcode", O_RDWR)) < 0) {
ast_log(LOG_ERROR, "Failed to open /dev/dahdi/transcode: %s\n", strerror(errno));
return 0;
}
#endif
for (info.tcnum = 0; !(res = ioctl(fd, DAHDI_TC_GETINFO, &info)); info.tcnum++) {
if (option_verbose > 1)