/[Apache-SVN]/httpd/flood/trunk/flood_simple_reports.c
ViewVC logotype

Contents of /httpd/flood/trunk/flood_simple_reports.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 653656 - (show annotations) (download)
Tue May 6 00:42:11 2008 UTC (16 years, 3 months ago) by fielding
File MIME type: text/plain
File size: 2560 byte(s)
promote flood to released products
1 /* Licensed to the Apache Software Foundation (ASF) under one or more
2 * contributor license agreements. See the NOTICE file distributed with
3 * this work for additional information regarding copyright ownership.
4 * The ASF licenses this file to You under the Apache License, Version 2.0
5 * (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 * Originally developed by Aaron Bannert and Justin Erenkrantz, eBuilt.
17 */
18
19 #include "flood_simple_reports.h"
20
21 extern apr_file_t *local_stdout;
22 extern apr_file_t *local_stderr;
23
24 struct simple_report_t {
25 int hit_count;
26 int successes;
27 int failures;
28 };
29 typedef struct simple_report_t simple_report_t;
30
31 apr_status_t simple_report_init(report_t **report, config_t *config, const char *profile_name, apr_pool_t *pool)
32 {
33 simple_report_t *sr = apr_palloc(pool, sizeof(simple_report_t));
34
35 sr->hit_count = 0;
36 sr->successes = 0; sr->failures = 0;
37
38 *report = sr;
39
40 return APR_SUCCESS;
41 }
42
43 apr_status_t simple_process_stats(report_t *report, int verified, request_t *req, response_t *resp, flood_timer_t *timer)
44 {
45 simple_report_t *sr = (simple_report_t*)report;
46
47 sr->hit_count++;
48
49 if (verified == FLOOD_VALID) {
50 sr->successes++;
51 apr_file_printf(local_stdout, "OK %s\n", req->uri);
52 } else if (verified == FLOOD_INVALID) {
53 sr->failures++;
54 apr_file_printf(local_stdout, "FAIL %s\n", req->uri);
55 } else {
56 apr_file_printf(local_stderr, "simple_process_stats(): Internal Error: 'verified' has invalid value.\n");
57 }
58
59 return APR_SUCCESS;
60 }
61
62 apr_status_t simple_report_stats(report_t *report)
63 {
64 simple_report_t *sr = (simple_report_t*)report;
65
66 apr_file_printf(local_stdout, "Report Follows ------------\n");
67 apr_file_printf(local_stdout, " #OK - %d\n", sr->successes);
68 apr_file_printf(local_stdout, " #FAILED - %d\n", sr->failures);
69 apr_file_printf(local_stdout, " Total ---- %d\n", sr->hit_count);
70
71 return APR_SUCCESS;
72 }
73
74 apr_status_t simple_destroy_report(report_t *report)
75 {
76 /* FIXME: APR can't free memory, and is lame */
77 return APR_SUCCESS;
78 }

Properties

Name Value
svn:eol-style native

infrastructure at apache.org
ViewVC Help
Powered by ViewVC 1.1.26