| 56 | #define SLEEP_INTERVAL 300 |
| 57 | |
| 58 | static int read_and_write2var(struct sip_msg* msg, FILE** strm, pv_spec_t *outvar) |
| 59 | { |
| 60 | #define MAX_LINE_SIZE 1024 |
| 61 | #define MAX_BUF_SIZE 32 * MAX_LINE_SIZE |
| 62 | |
| 63 | int buflen=0, tmplen; |
| 64 | pv_value_t outval; |
| 65 | char buf[MAX_BUF_SIZE], tmpbuf[MAX_LINE_SIZE]; |
| 66 | |
| 67 | |
| 68 | while((tmplen=fread(tmpbuf, 1, MAX_LINE_SIZE, *strm))) { |
| 69 | if ((buflen + tmplen) >= MAX_BUF_SIZE) { |
| 70 | LM_WARN("no more space in output buffer\n"); |
| 71 | break; |
| 72 | } |
| 73 | memcpy(buf+buflen, tmpbuf, tmplen); |
| 74 | buflen += tmplen; |
| 75 | } |
| 76 | |
| 77 | outval.flags = PV_VAL_STR; |
| 78 | outval.rs.s = buf; |
| 79 | outval.rs.len = buflen; |
| 80 | |
| 81 | if (buflen && |
| 82 | pv_set_value(msg, outvar, 0, &outval) < 0) { |
| 83 | LM_ERR("cannot set output pv value\n"); |
| 84 | return -1; |
| 85 | } |
| 86 | |
| 87 | return 0; |
| 88 | |
| 89 | #undef MAX_LINE_SIZE |
| 90 | #undef MAX_BUF_SIZE |
| 91 | } |
| 92 | |
| 93 | int exec_sync(struct sip_msg* msg, str* command, str* input, |
| 94 | pv_spec_t *outvar, pv_spec_t *errvar) |
no test coverage detected