diff -Naur asterisk.old/cdr/cdr_odbc.c asterisk.new/cdr/cdr_odbc.c --- asterisk.old/cdr/cdr_odbc.c 2004-06-08 18:45:07.000000000 -0700 +++ asterisk.new/cdr/cdr_odbc.c 2004-06-17 00:48:40.000000000 -0700 @@ -33,6 +33,7 @@ #include #define DATE_FORMAT "%Y-%m-%d %T" +#define BINDCSTR(idx,fld,csz) { SQLLEN l=(SQLLEN)strlen(fld); SQLBindParameter(ODBC_stmt,idx,SQL_PARAM_INPUT,SQL_C_CHAR,SQL_VARCHAR,csz,0,fld,sizeof(fld),&l); } static char *desc = "ODBC CDR Backend"; static char *name = "ODBC"; @@ -61,6 +62,7 @@ struct tm tm; struct timeval tv; time_t t; + char *disp; gettimeofday(&tv,NULL); t = tv.tv_sec; @@ -126,25 +128,26 @@ return 0; } - SQLBindParameter(ODBC_stmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(timestr), 0, ×tr, 0, NULL); - SQLBindParameter(ODBC_stmt, 2, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(cdr->clid), 0, cdr->clid, 0, NULL); - SQLBindParameter(ODBC_stmt, 3, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(cdr->src), 0, cdr->src, 0, NULL); - SQLBindParameter(ODBC_stmt, 4, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(cdr->dst), 0, cdr->dst, 0, NULL); - SQLBindParameter(ODBC_stmt, 5, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(cdr->dcontext), 0, cdr->dcontext, 0, NULL); - SQLBindParameter(ODBC_stmt, 6, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(cdr->channel), 0, cdr->channel, 0, NULL); - SQLBindParameter(ODBC_stmt, 7, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(cdr->dstchannel), 0, cdr->dstchannel, 0, NULL); - SQLBindParameter(ODBC_stmt, 8, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(cdr->lastapp), 0, cdr->lastapp, 0, NULL); - SQLBindParameter(ODBC_stmt, 9, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(cdr->lastdata), 0, cdr->lastdata, 0, NULL); + BINDCSTR( 1, timestr, 25 ); + BINDCSTR( 2, cdr->clid, 80 ); + BINDCSTR( 3, cdr->src, 80 ); + BINDCSTR( 4, cdr->dst, 80 ); + BINDCSTR( 5, cdr->dcontext, 80 ); + BINDCSTR( 6, cdr->channel, 80 ); + BINDCSTR( 7, cdr->dstchannel, 80 ); + BINDCSTR( 8, cdr->lastapp, 80 ); + BINDCSTR( 9, cdr->lastdata, 80 ); SQLBindParameter(ODBC_stmt, 10, SQL_PARAM_INPUT, SQL_C_SLONG, SQL_INTEGER, 0, 0, &cdr->duration, 0, NULL); SQLBindParameter(ODBC_stmt, 11, SQL_PARAM_INPUT, SQL_C_SLONG, SQL_INTEGER, 0, 0, &cdr->billsec, 0, NULL); - SQLBindParameter(ODBC_stmt, 12, SQL_PARAM_INPUT, SQL_C_SLONG, SQL_INTEGER, 0, 0, &cdr->disposition, 0, NULL); + disp = ast_cdr_disp2str(cdr->disposition); + BINDCSTR( 12, disp, 45 ); SQLBindParameter(ODBC_stmt, 13, SQL_PARAM_INPUT, SQL_C_SLONG, SQL_INTEGER, 0, 0, &cdr->amaflags, 0, NULL); - SQLBindParameter(ODBC_stmt, 14, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(cdr->accountcode), 0, cdr->accountcode, 0, NULL); + BINDCSTR( 14, cdr->accountcode, 20 ); if((loguniqueid != NULL) && ((strcmp(loguniqueid, "1") == 0) || (strcmp(loguniqueid, "yes") == 0))) { - SQLBindParameter(ODBC_stmt, 15, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(cdr->uniqueid), 0, cdr->uniqueid, 0, NULL); - SQLBindParameter(ODBC_stmt, 16, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, sizeof(cdr->userfield), 0, cdr->userfield, 0, NULL); + BINDCSTR( 15, cdr->uniqueid, 32 ); + BINDCSTR( 16, cdr->userfield, 255 ); } if(connected)