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

Function lookup_map_program

modules/mappers/mod_rewrite.c:1577–1739  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1575}
1576
1577static char *lookup_map_program(request_rec *r, apr_file_t *fpin,
1578 apr_file_t *fpout, char *key)
1579{
1580 char *buf;
1581 char c;
1582 apr_size_t i, nbytes, combined_len = 0;
1583 apr_status_t rv;
1584 const char *eol = APR_EOL_STR;
1585 apr_size_t eolc = 0;
1586 int found_nl = 0;
1587 result_list *buflist = NULL, *curbuf = NULL;
1588
1589#ifndef NO_WRITEV
1590 struct iovec iova[2];
1591 apr_size_t niov;
1592#endif
1593
1594 /* when `RewriteEngine off' was used in the per-server
1595 * context then the rewritemap-programs were not spawned.
1596 * In this case using such a map (usually in per-dir context)
1597 * is useless because it is not available.
1598 *
1599 * newlines in the key leave bytes in the pipe and cause
1600 * bad things to happen (next map lookup will use the chars
1601 * after the \n instead of the new key etc etc - in other words,
1602 * the Rewritemap falls out of sync with the requests).
1603 */
1604 if (fpin == NULL || fpout == NULL || ap_strchr(key, '\n')) {
1605 return NULL;
1606 }
1607
1608 /* take the lock */
1609 if (rewrite_mapr_lock_acquire) {
1610 rv = apr_global_mutex_lock(rewrite_mapr_lock_acquire);
1611 if (rv != APR_SUCCESS) {
1612 ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, APLOGNO(00659)
1613 "apr_global_mutex_lock(rewrite_mapr_lock_acquire) "
1614 "failed");
1615 return NULL; /* Maybe this should be fatal? */
1616 }
1617 }
1618
1619 /* write out the request key */
1620#ifdef NO_WRITEV
1621 nbytes = strlen(key);
1622 /* XXX: error handling */
1623 apr_file_write_full(fpin, key, nbytes, NULL);
1624 nbytes = 1;
1625 apr_file_write_full(fpin, "\n", nbytes, NULL);
1626#else
1627 iova[0].iov_base = key;
1628 iova[0].iov_len = strlen(key);
1629 iova[1].iov_base = "\n";
1630 iova[1].iov_len = 1;
1631
1632 niov = 2;
1633 /* XXX: error handling */
1634 apr_file_writev_full(fpin, iova, niov, &nbytes);

Callers 1

lookup_mapFunction · 0.85

Calls 1

ap_strchrFunction · 0.85

Tested by

no test coverage detected