add a string to the result string list for this request */ it is the responsibility of the caller to allocate "str" */
| 540 | /* add a string to the result string list for this request */ |
| 541 | /* it is the responsibility of the caller to allocate "str" */ |
| 542 | static int magic_rsl_add(request_rec *r, const char *str) |
| 543 | { |
| 544 | magic_req_rec *req_dat = (magic_req_rec *) |
| 545 | ap_get_module_config(r->request_config, &mime_magic_module); |
| 546 | magic_rsl *rsl; |
| 547 | |
| 548 | /* make sure we have a list to put it in */ |
| 549 | if (!req_dat) { |
| 550 | ap_log_rerror(APLOG_MARK, APLOG_ERR, APR_EINVAL, r, APLOGNO(01507) |
| 551 | MODNAME ": request config should not be NULL"); |
| 552 | if (!(req_dat = magic_set_config(r))) { |
| 553 | /* failure */ |
| 554 | return -1; |
| 555 | } |
| 556 | } |
| 557 | |
| 558 | /* allocate the list entry */ |
| 559 | rsl = (magic_rsl *) apr_palloc(r->pool, sizeof(magic_rsl)); |
| 560 | |
| 561 | /* fill it */ |
| 562 | rsl->str = str; |
| 563 | rsl->next = (magic_rsl *) NULL; |
| 564 | |
| 565 | /* append to the list */ |
| 566 | if (req_dat->head && req_dat->tail) { |
| 567 | req_dat->tail->next = rsl; |
| 568 | req_dat->tail = rsl; |
| 569 | } |
| 570 | else { |
| 571 | req_dat->head = req_dat->tail = rsl; |
| 572 | } |
| 573 | |
| 574 | /* success */ |
| 575 | return 0; |
| 576 | } |
| 577 | |
| 578 | /* RSL hook for puts-type functions */ |
| 579 | static int magic_rsl_puts(request_rec *r, const char *str) |
no test coverage detected