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

Function macro_section

modules/core/mod_macro.c:685–797  ·  view source on GitHub ↗

handles: any trash there is ignored... */

Source from the content-addressed store, hash-verified

683 handles: <Macro macroname arg1 arg2 ...> any trash there is ignored...
684*/
685static const char *macro_section(cmd_parms * cmd,
686 void *dummy, const char *arg)
687{
688 apr_pool_t *pool;
689 char *endp, *name, *where;
690 const char *errmsg;
691 ap_macro_t *macro;
692
693 debug(fprintf(stderr, "macro_section: arg='%s'\n", arg));
694
695 /* lazy initialization */
696 if (ap_macros == NULL) {
697 pool = cmd->pool;
698 ap_macros = apr_hash_make(pool);
699 ap_assert(ap_macros != NULL);
700 apr_pool_cleanup_register(pool, &ap_macros,
701 ap_pool_cleanup_set_null,
702 apr_pool_cleanup_null);
703 }
704 else {
705 pool = apr_hash_pool_get(ap_macros);
706 }
707
708 endp = (char *) ap_strrchr_c(arg, '>');
709
710 if (endp == NULL) {
711 return BEGIN_MACRO "> directive missing closing '>'";
712 }
713
714 if (endp == arg) {
715 return BEGIN_MACRO " macro definition: empty name";
716 }
717
718 warn_if_non_blank(APLOGNO(02801) "non blank chars found after "
719 BEGIN_MACRO " closing '>'",
720 endp+1, cmd->config_file);
721
722 /* coldly drop '>[^>]*$' out */
723 *endp = '\0';
724
725 /* get lowercase macro name */
726 name = ap_getword_conf(pool, &arg);
727 if (empty_string_p(name)) {
728 return BEGIN_MACRO " macro definition: name not found";
729 }
730
731 ap_str_tolower(name);
732 macro = apr_hash_get(ap_macros, name, APR_HASH_KEY_STRING);
733
734 if (macro != NULL) {
735 /* already defined: warn about the redefinition */
736 ap_log_error(APLOG_MARK, APLOG_WARNING, 0, NULL, APLOGNO(02802)
737 "macro '%s' multiply defined: "
738 "%s, redefined on line %d of \"%s\"",
739 macro->name, macro->location,
740 cmd->config_file->line_number, cmd->config_file->name);
741 }
742 else {

Callers

nothing calls this directly

Calls 10

ap_strrchr_cFunction · 0.85
warn_if_non_blankFunction · 0.85
ap_getword_confFunction · 0.85
ap_str_tolowerFunction · 0.85
looks_like_an_argumentFunction · 0.85
get_argumentsFunction · 0.85
check_macro_argumentsFunction · 0.85
get_lines_till_end_tokenFunction · 0.85
check_macro_contentsFunction · 0.85
ap_log_errorFunction · 0.50

Tested by

no test coverage detected