Nicer solution for 64bit support.

This commit is contained in:
MelwareDE 2007-08-23 13:30:05 +00:00
parent 620550e1e8
commit 411ad13361
2 changed files with 20 additions and 29 deletions

View File

@ -3048,14 +3048,8 @@ static void capidev_send_faxdata(struct capi_pvt *i)
len = fread(faxdata, 1, CAPI_MAX_B3_BLOCK_SIZE, i->fFax); len = fread(faxdata, 1, CAPI_MAX_B3_BLOCK_SIZE, i->fFax);
if (len > 0) { if (len > 0) {
i->send_buffer_handle++; i->send_buffer_handle++;
if (sizeof(void *) == 4) { capi_sendf(NULL, 0, CAPI_DATA_B3_REQ, i->NCCI, get_capi_MessageNumber(),
capi_sendf(NULL, 0, CAPI_DATA_B3_REQ, i->NCCI, get_capi_MessageNumber(), "dwww", faxdata, len, i->send_buffer_handle, 0);
"dwww", faxdata, len, i->send_buffer_handle, 0);
} else {
/* 64bit */
capi_sendf(NULL, 0, CAPI_DATA_B3_REQ, i->NCCI, get_capi_MessageNumber(),
"dwwwq", 0, len, i->send_buffer_handle, 0, faxdata);
}
cc_verbose(5, 1, VERBOSE_PREFIX_3 "%s: send %d fax bytes.\n", cc_verbose(5, 1, VERBOSE_PREFIX_3 "%s: send %d fax bytes.\n",
i->vname, len); i->vname, len);
#ifndef CC_AST_HAS_VERSION_1_4 #ifndef CC_AST_HAS_VERSION_1_4

View File

@ -416,9 +416,9 @@ MESSAGE_EXCHANGE_ERROR capi_sendf(
MESSAGE_EXCHANGE_ERROR ret; MESSAGE_EXCHANGE_ERROR ret;
int i, j; int i, j;
unsigned int d; unsigned int d;
uint64_t ll;
unsigned char *p, *p_length; unsigned char *p, *p_length;
unsigned char *string; unsigned char *string;
unsigned short header_length;
va_list ap; va_list ap;
capi_prestruct_t *s; capi_prestruct_t *s;
unsigned char msg[2048]; unsigned char msg[2048];
@ -456,17 +456,6 @@ MESSAGE_EXCHANGE_ERROR capi_sendf(
*(p++) = (unsigned char)(d >> 16); *(p++) = (unsigned char)(d >> 16);
*(p++) = (unsigned char)(d >> 24); *(p++) = (unsigned char)(d >> 24);
break; break;
case 'q': /* quad word (8 bytes) */
ll = va_arg(ap, uint64_t);
*(p++) = (unsigned char) ll;
*(p++) = (unsigned char)(ll >> 8);
*(p++) = (unsigned char)(ll >> 16);
*(p++) = (unsigned char)(ll >> 24);
*(p++) = (unsigned char)(ll >> 32);
*(p++) = (unsigned char)(ll >> 40);
*(p++) = (unsigned char)(ll >> 48);
*(p++) = (unsigned char)(ll >> 56);
break;
case 's': /* struct, length is the first byte */ case 's': /* struct, length is the first byte */
string = va_arg(ap, unsigned char *); string = va_arg(ap, unsigned char *);
if (string == NULL) { if (string == NULL) {
@ -518,7 +507,21 @@ MESSAGE_EXCHANGE_ERROR capi_sendf(
if (p_length) { if (p_length) {
cc_log(LOG_ERROR, "capi_sendf: inconsistent format \"%s\"\n", format); cc_log(LOG_ERROR, "capi_sendf: inconsistent format \"%s\"\n", format);
} }
write_capi_word(&msg[0], (unsigned short)(p - (&msg[0])));
header_length = (unsigned short)(p - (&msg[0]));
if ((sizeof(void *) > 4) && (command == CAPI_DATA_B3_REQ)) {
void* req_data;
va_start(ap, format);
req_data = va_arg(ap, void *);
va_end(ap);
header_length += 8;
write_capi_dword(&msg[12], 0);
memcpy(&msg[22], &req_data, sizeof(void *));
}
write_capi_word(&msg[0], header_length);
ret = _capi_put_msg(&msg[0]); ret = _capi_put_msg(&msg[0]);
if ((!(ret)) && (waitconf)) { if ((!(ret)) && (waitconf)) {
@ -1223,14 +1226,8 @@ int capi_write_frame(struct capi_pvt *i, struct ast_frame *f)
error = 1; error = 1;
if (i->B3q > 0) { if (i->B3q > 0) {
if (sizeof(void *) == 4) { error = capi_sendf(NULL, 0, CAPI_DATA_B3_REQ, i->NCCI, get_capi_MessageNumber(),
error = capi_sendf(NULL, 0, CAPI_DATA_B3_REQ, i->NCCI, get_capi_MessageNumber(), "dwww", buf, fsmooth->datalen, i->send_buffer_handle, 0);
"dwww", buf, fsmooth->datalen, i->send_buffer_handle, 0);
} else {
/* for 64bit */
error = capi_sendf(NULL, 0, CAPI_DATA_B3_REQ, i->NCCI, get_capi_MessageNumber(),
"dwwwq", 0, fsmooth->datalen, i->send_buffer_handle, 0, buf);
}
} else { } else {
cc_verbose(3, 1, VERBOSE_PREFIX_4 "%s: too much voice to send for NCCI=%#x\n", cc_verbose(3, 1, VERBOSE_PREFIX_4 "%s: too much voice to send for NCCI=%#x\n",
i->vname, i->NCCI); i->vname, i->NCCI);