MCPcopy Create free account
hub / github.com/apache/httpd / select_random_value_part

Function select_random_value_part

modules/mappers/mod_rewrite.c:1272–1300  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1270}
1271
1272static char *select_random_value_part(request_rec *r, char *value)
1273{
1274 char *p = value;
1275 unsigned n = 1;
1276
1277 /* count number of distinct values */
1278 while ((p = ap_strchr(p, '|')) != NULL) {
1279 ++n;
1280 ++p;
1281 }
1282
1283 if (n > 1) {
1284 n = ap_random_pick(1, n);
1285
1286 /* extract it from the whole string */
1287 while (--n && (value = ap_strchr(value, '|')) != NULL) {
1288 ++value;
1289 }
1290
1291 if (value) { /* should not be NULL, but ... */
1292 p = ap_strchr(value, '|');
1293 if (p) {
1294 *p = '\0';
1295 }
1296 }
1297 }
1298
1299 return value;
1300}
1301
1302/* child process code */
1303static void rewrite_child_errfn(apr_pool_t *p, apr_status_t err,

Callers 1

lookup_mapFunction · 0.85

Calls 2

ap_strchrFunction · 0.85
ap_random_pickFunction · 0.85

Tested by

no test coverage detected