/
| 70 | |
| 71 | /**************************************************************************************/ |
| 72 | paralist *pj_param_exists(paralist *list, const char *parameter) { |
| 73 | /*************************************************************************************** |
| 74 | Determine whether a given parameter exists in a paralist. If it does, |
| 75 | return a pointer to the corresponding list element - otherwise return 0. |
| 76 | |
| 77 | In support of the pipeline syntax, the search is terminated once a |
| 78 | "+step" list element is reached, in which case a 0 is returned, unless the |
| 79 | parameter searched for is actually "step", in which case a pointer to the |
| 80 | "step" list element is returned. |
| 81 | |
| 82 | This function is equivalent to the pj_param (...) call with the "opt" |
| 83 | argument set to the parameter name preceeeded by a 't'. But by using this |
| 84 | one, one avoids writing the code allocating memory for a new copy of |
| 85 | parameter name, and prepending the t (for compile time known names, this is |
| 86 | obviously not an issue). |
| 87 | ***************************************************************************************/ |
| 88 | paralist *next = list; |
| 89 | const char *c = strchr(parameter, '='); |
| 90 | size_t len = strlen(parameter); |
| 91 | if (c) |
| 92 | len = c - parameter; |
| 93 | if (list == nullptr) |
| 94 | return nullptr; |
| 95 | |
| 96 | for (next = list; next; next = next->next) { |
| 97 | if (0 == strncmp(parameter, next->param, len) && |
| 98 | (next->param[len] == '=' || next->param[len] == 0)) { |
| 99 | next->used = 1; |
| 100 | return next; |
| 101 | } |
| 102 | if (0 == strcmp(parameter, "step")) |
| 103 | return nullptr; |
| 104 | } |
| 105 | |
| 106 | return nullptr; |
| 107 | } |
| 108 | |
| 109 | /************************************************************************/ |
| 110 | /* pj_param() */ |
no outgoing calls
no test coverage detected