| 463 | } |
| 464 | |
| 465 | int form_result(var_str buff, db_res_t** r) |
| 466 | { |
| 467 | db_res_t * res; |
| 468 | char * cur, * dest, * start, * end; |
| 469 | int col_count, cur_col, line_count, cur_line, delim_count, len; |
| 470 | int state, next, consume; |
| 471 | |
| 472 | |
| 473 | LM_DBG("Called with : %.*s\n",buff.len,buff.s); |
| 474 | |
| 475 | |
| 476 | |
| 477 | |
| 478 | end = buff.s + buff.len; |
| 479 | res = NULL; |
| 480 | |
| 481 | if( buff.len == 0 ) |
| 482 | { |
| 483 | *r = new_full_db_res(0,0); |
| 484 | return 0; |
| 485 | } |
| 486 | |
| 487 | |
| 488 | state = OUT; |
| 489 | cur = buff.s; |
| 490 | |
| 491 | col_count = 0; |
| 492 | cur_col = 0; |
| 493 | cur_line = -1; |
| 494 | delim_count = 0; |
| 495 | |
| 496 | |
| 497 | while( cur < end ) |
| 498 | { |
| 499 | |
| 500 | next = next_state[ state ][ (int)((unsigned char)*cur) ]; |
| 501 | consume = 1; |
| 502 | |
| 503 | if( state == OUT ) |
| 504 | { |
| 505 | if( *cur == col_delim ) |
| 506 | { |
| 507 | cur_col++; |
| 508 | delim_count++; |
| 509 | } |
| 510 | |
| 511 | if( *cur == line_delim ) |
| 512 | { |
| 513 | cur_col++; |
| 514 | if( cur_line == -1 ) |
| 515 | col_count = cur_col; |
| 516 | else |
| 517 | if(cur_col != col_count) { |
| 518 | LM_ERR("cur_col=[%d] != col_count=[%d]\n", cur_col, col_count); |
| 519 | goto error_before; |
| 520 | } |
| 521 | |
| 522 | delim_count++; |
no test coverage detected