* Implements the container */
| 170 | * Implements the <IfVersion> container |
| 171 | */ |
| 172 | static const char *start_ifversion(cmd_parms *cmd, void *mconfig, |
| 173 | const char *arg1, const char *arg2, |
| 174 | const char *arg3) |
| 175 | { |
| 176 | const char *endp; |
| 177 | int reverse = 0, done = 0, match = 0, compare; |
| 178 | const char *p, *error; |
| 179 | char c; |
| 180 | |
| 181 | /* supplying one argument is possible, we assume an equality check then */ |
| 182 | if (!arg2) { |
| 183 | arg2 = arg1; |
| 184 | arg1 = "="; |
| 185 | } |
| 186 | |
| 187 | /* surrounding quotes without operator */ |
| 188 | if (!arg3 && *arg2 == '>' && !arg2[1]) { |
| 189 | arg3 = ">"; |
| 190 | arg2 = arg1; |
| 191 | arg1 = "="; |
| 192 | } |
| 193 | |
| 194 | /* the third argument makes version surrounding quotes plus operator |
| 195 | * possible. |
| 196 | */ |
| 197 | endp = arg2 + strlen(arg2); |
| 198 | if ( endp == arg2 |
| 199 | || (!(arg3 && *arg3 == '>' && !arg3[1]) && *--endp != '>')) { |
| 200 | return apr_pstrcat(cmd->pool, cmd->cmd->name, |
| 201 | "> directive missing closing '>'", NULL); |
| 202 | } |
| 203 | |
| 204 | p = arg1; |
| 205 | if (*p == '!') { |
| 206 | reverse = 1; |
| 207 | if (p[1]) { |
| 208 | ++p; |
| 209 | } |
| 210 | } |
| 211 | |
| 212 | c = *p++; |
| 213 | if (!*p || (*p == '=' && !p[1] && c != '~')) { |
| 214 | if (!httpd_version.major) { |
| 215 | ap_get_server_revision(&httpd_version); |
| 216 | } |
| 217 | |
| 218 | done = 1; |
| 219 | switch (c) { |
| 220 | case '=': |
| 221 | /* normal comparison */ |
| 222 | if (*arg2 != '/') { |
| 223 | compare = compare_version(apr_pstrmemdup(cmd->temp_pool, arg2, |
| 224 | endp-arg2), |
| 225 | &error); |
| 226 | if (error) { |
| 227 | return error; |
| 228 | } |
| 229 |
nothing calls this directly
no test coverage detected