void trace_eval(u16 result, u8 *log_data) { u16 temp2; temp2 = *(log_data++); if (temp2 == 0xE) said_state = 1; else said_state = 0; trace_add(temp2, eval_table, log_data, 0xDC, result); }
/* * Command handler for the NO_ARGS "Example" directive. All we do is mark the * call in the trace log, and flag the applicability of the directive to the * current location in that location's configuration record. */ static const char *cmd_example(cmd_parms *cmd, void *mconfig) { excfg *cfg = (excfg *) mconfig; /* * "Example Wuz Here" */ cfg->local = 1; trace_add(cmd->server, NULL, cfg, "cmd_example()"); return NULL; }
/* * This routine is called to check the authentication information sent with * the request (such as looking up the user in a database and verifying that * the [encrypted] password sent matches the one in the database). * * The return value is OK, DECLINED, or some HTTP_mumble error (typically * HTTP_UNAUTHORIZED). If we return OK, no other modules are given a chance * at the request during this phase. */ static int example_check_user_id(request_rec *r) { excfg *cfg; cfg = our_dconfig(r); /* * Don't do anything except log the call. */ trace_add(r->server, r, cfg, "example_check_user_id()"); return DECLINED; }
/* * This routine is called to perform any module-specific fixing of header * fields, et cetera. It is invoked just before any content-handler. * * The return value is OK, DECLINED, or HTTP_mumble. If we return OK, the * server will still call any remaining modules with an handler for this * phase. */ static int example_fixer_upper(request_rec *r) { excfg *cfg; cfg = our_dconfig(r); /* * Log the call and exit. */ trace_add(r->server, r, cfg, "example_fixer_upper()"); return OK; }
/* * This routine is called to determine and/or set the various document type * information bits, like Content-type (via r->content_type), language, et * cetera. * * The return value is OK, DECLINED, or HTTP_mumble. If we return OK, no * further modules are given a chance at the request for this phase. */ static int example_type_checker(request_rec *r) { excfg *cfg; cfg = our_dconfig(r); /* * Log the call, but don't do anything else - and report truthfully that * we didn't do anything. */ trace_add(r->server, r, cfg, "example_type_checker()"); return DECLINED; }
/* * This routine is called to check to see if the resource being requested * requires authorisation. * * The return value is OK, DECLINED, or HTTP_mumble. If we return OK, no * other modules are called during this phase. * * If *all* modules return DECLINED, the request is aborted with a server * error. */ static int example_auth_checker(request_rec *r) { excfg *cfg; cfg = our_dconfig(r); /* * Log the call and return OK, or access will be denied (even though we * didn't actually do anything). */ trace_add(r->server, r, cfg, "example_auth_checker()"); return DECLINED; }
/* * This routine gives our module an opportunity to translate the URI into an * actual filename. If we don't do anything special, the server's default * rules (Alias directives and the like) will continue to be followed. * * The return value is OK, DECLINED, or HTTP_mumble. If we return OK, no * further modules are called for this phase. */ static int example_translate_handler(request_rec *r) { excfg *cfg; cfg = our_dconfig(r); /* * We don't actually *do* anything here, except note the fact that we were * called. */ trace_add(r->server, r, cfg, "example_translate_handler()"); return DECLINED; }
/* * All our process-death routine does is add its trace to the log. */ static void example_child_exit(server_rec *s, pool *p) { char *note; char *sname = s->server_hostname; /* * The arbitrary text we add to our trace entry indicates for which server * we're being called. */ sname = (sname != NULL) ? sname : ""; note = ap_pstrcat(p, "example_child_exit(", sname, ")", NULL); trace_add(s, NULL, NULL, note); }
/* * All our process-initialiser does is add its trace to the log. */ static void example_child_init(server_rec *s, pool *p) { char *note; char *sname = s->server_hostname; /* * Set up any module cells that ought to be initialised. */ setup_module_cells(); /* * The arbitrary text we add to our trace entry indicates for which server * we're being called. */ sname = (sname != NULL) ? sname : ""; note = ap_pstrcat(p, "example_child_init(", sname, ")", NULL); trace_add(s, NULL, NULL, note); }
/* * This function gets called to create a per-server configuration * record. It will always be called for the "default" server. * * The return value is a pointer to the created module-specific * structure. */ static void *example_create_server_config(pool *p, server_rec *s) { excfg *cfg; char *sname = s->server_hostname; /* * As with the example_create_dir_config() reoutine, we allocate and fill * in an empty record. */ cfg = (excfg *) ap_pcalloc(p, sizeof(excfg)); cfg->local = 0; cfg->congenital = 0; cfg->cmode = CONFIG_MODE_SERVER; /* * Note that we were called in the trace list. */ sname = (sname != NULL) ? sname : ""; cfg->loc = ap_pstrcat(p, "SVR(", sname, ")", NULL); trace_add(s, NULL, cfg, "example_create_server_config()"); return (void *) cfg; }
/* * This function gets called to merge two per-directory configuration * records. This is typically done to cope with things like .htaccess files * or <Location> directives for directories that are beneath one for which a * configuration record was already created. The routine has the * responsibility of creating a new record and merging the contents of the * other two into it appropriately. If the module doesn't declare a merge * routine, the record for the closest ancestor location (that has one) is * used exclusively. * * The routine MUST NOT modify any of its arguments! * * The return value is a pointer to the created module-specific structure * containing the merged values. */ static void *example_merge_dir_config(pool *p, void *parent_conf, void *newloc_conf) { excfg *merged_config = (excfg *) ap_pcalloc(p, sizeof(excfg)); excfg *pconf = (excfg *) parent_conf; excfg *nconf = (excfg *) newloc_conf; char *note; /* * Some things get copied directly from the more-specific record, rather * than getting merged. */ merged_config->local = nconf->local; merged_config->loc = ap_pstrdup(p, nconf->loc); /* * Others, like the setting of the `congenital' flag, get ORed in. The * setting of that particular flag, for instance, is TRUE if it was ever * true anywhere in the upstream configuration. */ merged_config->congenital = (pconf->congenital | pconf->local); /* * If we're merging records for two different types of environment (server * and directory), mark the new record appropriately. Otherwise, inherit * the current value. */ merged_config->cmode = (pconf->cmode == nconf->cmode) ? pconf->cmode : CONFIG_MODE_COMBO; /* * Now just record our being called in the trace list. Include the * locations we were asked to merge. */ note = ap_pstrcat(p, "example_merge_dir_config(\"", pconf->loc, "\",\"", nconf->loc, "\")", NULL); trace_add(NULL, NULL, merged_config, note); return (void *) merged_config; }
void trace_cmd(u16 op, u8 *log_data) { said_state = 0; trace_add(op, cmd_table, log_data, 0, 0xFFFF); }
/* * Sample content handler. All this does is display the call list that has * been built up so far. * * The return value instructs the caller concerning what happened and what to * do next: * OK ("we did our thing") * DECLINED ("this isn't something with which we want to get involved") * HTTP_mumble ("an error status should be reported") */ static int example_handler(request_rec *r) { excfg *dcfg; dcfg = our_dconfig(r); trace_add(r->server, r, dcfg, "example_handler()"); /* * We're about to start sending content, so we need to force the HTTP * headers to be sent at this point. Otherwise, no headers will be sent * at all. We can set any we like first, of course. **NOTE** Here's * where you set the "Content-type" header, and you do so by putting it in * r->content_type, *not* r->headers_out("Content-type"). If you don't * set it, it will be filled in with the server's default type (typically * "text/plain"). You *must* also ensure that r->content_type is lower * case. * * We also need to start a timer so the server can know if the connexion * is broken. */ r->content_type = "text/html"; ap_soft_timeout("send example call trace", r); ap_send_http_header(r); #ifdef CHARSET_EBCDIC /* Server-generated response, converted */ ap_bsetflag(r->connection->client, B_EBCDIC2ASCII, r->ebcdic.conv_out = 1); #endif /* * If we're only supposed to send header information (HEAD request), we're * already there. */ if (r->header_only) { ap_kill_timeout(r); return OK; } /* * Now send our actual output. Since we tagged this as being * "text/html", we need to embed any HTML. */ ap_rputs(DOCTYPE_HTML_3_2, r); ap_rputs("<HTML>\n", r); ap_rputs(" <HEAD>\n", r); ap_rputs(" <TITLE>mod_example Module Content-Handler Output\n", r); ap_rputs(" </TITLE>\n", r); ap_rputs(" </HEAD>\n", r); ap_rputs(" <BODY>\n", r); ap_rputs(" <H1><SAMP>mod_example</SAMP> Module Content-Handler Output\n", r); ap_rputs(" </H1>\n", r); ap_rputs(" <P>\n", r); ap_rprintf(r, " Apache HTTP Server version: \"%s\"\n", ap_get_server_version()); ap_rputs(" <BR>\n", r); ap_rprintf(r, " Server built: \"%s\"\n", ap_get_server_built()); ap_rputs(" </P>\n", r);; ap_rputs(" <P>\n", r); ap_rputs(" The format for the callback trace is:\n", r); ap_rputs(" </P>\n", r); ap_rputs(" <DL>\n", r); ap_rputs(" <DT><EM>n</EM>.<SAMP><routine-name>", r); ap_rputs("(<routine-data>)</SAMP>\n", r); ap_rputs(" </DT>\n", r); ap_rputs(" <DD><SAMP>[<applies-to>]</SAMP>\n", r); ap_rputs(" </DD>\n", r); ap_rputs(" </DL>\n", r); ap_rputs(" <P>\n", r); ap_rputs(" The <SAMP><routine-data></SAMP> is supplied by\n", r); ap_rputs(" the routine when it requests the trace,\n", r); ap_rputs(" and the <SAMP><applies-to></SAMP> is extracted\n", r); ap_rputs(" from the configuration record at the time of the trace.\n", r); ap_rputs(" <STRONG>SVR()</STRONG> indicates a server environment\n", r); ap_rputs(" (blank means the main or default server, otherwise it's\n", r); ap_rputs(" the name of the VirtualHost); <STRONG>DIR()</STRONG>\n", r); ap_rputs(" indicates a location in the URL or filesystem\n", r); ap_rputs(" namespace.\n", r); ap_rputs(" </P>\n", r); ap_rprintf(r, " <H2>Static callbacks so far:</H2>\n <OL>\n%s </OL>\n", trace); ap_rputs(" <H2>Request-specific callbacks so far:</H2>\n", r); ap_rprintf(r, " <OL>\n%s </OL>\n", ap_table_get(r->notes, TRACE_NOTE)); ap_rputs(" <H2>Environment for <EM>this</EM> call:</H2>\n", r); ap_rputs(" <UL>\n", r); ap_rprintf(r, " <LI>Applies-to: <SAMP>%s</SAMP>\n </LI>\n", dcfg->loc); ap_rprintf(r, " <LI>\"Example\" directive declared here: %s\n </LI>\n", (dcfg->local ? "YES" : "NO")); ap_rprintf(r, " <LI>\"Example\" inherited: %s\n </LI>\n", (dcfg->congenital ? "YES" : "NO")); ap_rputs(" </UL>\n", r); ap_rputs(" </BODY>\n", r); ap_rputs("</HTML>\n", r); /* * We're all done, so cancel the timeout we set. Since this is probably * the end of the request we *could* assume this would be done during * post-processing - but it's possible that another handler might be * called and inherit our outstanding timer. Not good; to each its own. */ ap_kill_timeout(r); /* * We did what we wanted to do, so tell the rest of the server we * succeeded. */ return OK; }