/
| 96 | |
| 97 | /**************************************************************************************/ |
| 98 | paralist *pj_param_exists (paralist *list, const char *parameter) { |
| 99 | /*************************************************************************************** |
| 100 | Determine whether a given parameter exists in a paralist. If it does, return |
| 101 | a pointer to the corresponding list element - otherwise return 0. |
| 102 | |
| 103 | In support of the pipeline syntax, the search is terminated once a "+step" list |
| 104 | element is reached, in which case a 0 is returned, unless the parameter |
| 105 | searched for is actually "step", in which case a pointer to the "step" list |
| 106 | element is returned. |
| 107 | |
| 108 | This function is equivalent to the pj_param (...) call with the "opt" argument |
| 109 | set to the parameter name preceeeded by a 't'. But by using this one, one avoids |
| 110 | writing the code allocating memory for a new copy of parameter name, and prepending |
| 111 | the t (for compile time known names, this is obviously not an issue). |
| 112 | ***************************************************************************************/ |
| 113 | paralist *next = list; |
| 114 | const char *c = strchr (parameter, '='); |
| 115 | size_t len = strlen (parameter); |
| 116 | if (c) |
| 117 | len = c - parameter; |
| 118 | if (list==nullptr) |
| 119 | return nullptr; |
| 120 | |
| 121 | for (next = list; next; next = next->next) { |
| 122 | if (0==strncmp (parameter, next->param, len) && (next->param[len]=='=' || next->param[len]==0)) { |
| 123 | next->used = 1; |
| 124 | return next; |
| 125 | } |
| 126 | if (0==strcmp (parameter, "step")) |
| 127 | return nullptr; |
| 128 | } |
| 129 | |
| 130 | return nullptr; |
| 131 | } |
| 132 | |
| 133 | |
| 134 | /************************************************************************/ |
no outgoing calls
no test coverage detected