As pj_mkparam, but payload ends at first whitespace, rather than at end of * */
| 27 | /* As pj_mkparam, but payload ends at first whitespace, rather than at end of |
| 28 | * <str> */ |
| 29 | paralist *pj_mkparam_ws(const char *str, const char **next_str) { |
| 30 | paralist *newitem; |
| 31 | size_t len = 0; |
| 32 | |
| 33 | if (nullptr == str) |
| 34 | return nullptr; |
| 35 | |
| 36 | /* Find start and length of string */ |
| 37 | while (isspace(*str)) |
| 38 | str++; |
| 39 | if (*str == '+') |
| 40 | str++; |
| 41 | bool in_string = false; |
| 42 | for (; str[len] != '\0'; len++) { |
| 43 | if (in_string) { |
| 44 | if (str[len] == '"' && str[len + 1] == '"') { |
| 45 | len++; |
| 46 | } else if (str[len] == '"') { |
| 47 | in_string = false; |
| 48 | } |
| 49 | } else if (str[len] == '=' && str[len + 1] == '"') { |
| 50 | in_string = true; |
| 51 | } else if (isspace(str[len])) { |
| 52 | break; |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | if (next_str) |
| 57 | *next_str = str + len; |
| 58 | |
| 59 | /* Use calloc to automagically 0-terminate the copy */ |
| 60 | newitem = (paralist *)calloc(1, sizeof(paralist) + len + 1); |
| 61 | if (nullptr == newitem) |
| 62 | return nullptr; |
| 63 | memcpy(newitem->param, str, len); |
| 64 | |
| 65 | newitem->used = 0; |
| 66 | newitem->next = nullptr; |
| 67 | |
| 68 | return newitem; |
| 69 | } |
| 70 | |
| 71 | /**************************************************************************************/ |
| 72 | paralist *pj_param_exists(paralist *list, const char *parameter) { |
no outgoing calls
no test coverage detected