3
3
* value to the calling entity.
4
4
*/
5
5
6
- static const char * extract_remote_host (request_rec * r , char * a )
6
+ json_object * extract_remote_host (request_rec * r , char * a )
7
7
{
8
- return ( char * ) ap_get_remote_host (r -> connection , r -> per_dir_config , REMOTE_NAME , NULL );
8
+ return json_object_new_string ( ap_get_remote_host (r -> connection , r -> per_dir_config , REMOTE_NAME , NULL ) );
9
9
}
10
10
11
- static const char * extract_remote_address (request_rec * r , char * a ) __attribute__((unused ));
11
+ json_object * extract_remote_address (request_rec * r , char * a ) __attribute__((unused ));
12
12
13
- static const char * extract_remote_address (request_rec * r , char * a )
13
+ json_object * extract_remote_address (request_rec * r , char * a )
14
14
{
15
15
#ifdef WITH_APACHE22
16
- return r -> connection -> remote_ip ;
16
+ return json_object_new_string ( r -> connection -> remote_ip ) ;
17
17
#else
18
- return r -> connection -> client_ip ;
18
+ return json_object_new_string ( r -> connection -> client_ip ) ;
19
19
#endif
20
20
}
21
21
22
- static const char * extract_local_address (request_rec * r , char * a ) __attribute__((unused ));
22
+ json_object * extract_local_address (request_rec * r , char * a ) __attribute__((unused ));
23
23
24
- static const char * extract_local_address (request_rec * r , char * a )
24
+ json_object * extract_local_address (request_rec * r , char * a )
25
25
{
26
- return r -> connection -> local_ip ;
26
+ return json_object_new_string ( r -> connection -> local_ip ) ;
27
27
}
28
28
29
- static const char * extract_remote_logname (request_rec * r , char * a )
29
+ json_object * extract_remote_logname (request_rec * r , char * a )
30
30
{
31
31
const char * rlogin = ap_get_remote_logname (r );
32
32
if (rlogin == NULL ) {
33
- rlogin = "-" ;
33
+ return NULL ;
34
34
} else if (strlen (rlogin ) == 0 ) {
35
35
rlogin = "\"\"" ;
36
36
}
37
37
38
- return rlogin ;
38
+ return json_object_new_string ( rlogin ) ;
39
39
}
40
40
41
- static const char * extract_remote_user (request_rec * r , char * a )
41
+ json_object * extract_remote_user (request_rec * r , char * a )
42
42
{
43
43
#ifdef WITH_APACHE13
44
44
char * rvalue = r -> connection -> user ;
@@ -50,76 +50,77 @@ static const char *extract_remote_user(request_rec *r, char *a)
50
50
} else if (strlen (rvalue ) == 0 ) {
51
51
rvalue = "\"\"" ;
52
52
}
53
- return rvalue ;
53
+ return json_object_new_string ( rvalue ) ;
54
54
}
55
55
56
- static const char * extract_request_line (request_rec * r , char * a )
56
+ json_object * extract_request_line (request_rec * r , char * a )
57
57
{
58
58
/* Upddated to mod_log_config logic */
59
59
/* NOTE: If the original request contained a password, we
60
60
* re-write the request line here to contain XXXXXX instead:
61
61
* (note the truncation before the protocol string for HTTP/0.9 requests)
62
62
* (note also that r->the_request contains the unmodified request)
63
63
*/
64
- return (r -> parsed_uri .password )
64
+ return json_object_new_string (
65
+ (r -> parsed_uri .password )
65
66
? apr_pstrcat (r -> pool , r -> method , " " ,
66
67
apr_uri_unparse (r -> pool ,
67
68
& r -> parsed_uri , 0 ),
68
69
r -> assbackwards ? NULL : " " ,
69
70
r -> protocol , NULL )
70
- : r -> the_request ;
71
+ : r -> the_request ) ;
71
72
}
72
73
73
- static const char * extract_request_file (request_rec * r , char * a )
74
+ json_object * extract_request_file (request_rec * r , char * a )
74
75
{
75
- return r -> filename ;
76
+ return json_object_new_string ( r -> filename ) ;
76
77
}
77
78
78
- static const char * extract_request_uri (request_rec * r , char * a )
79
+ json_object * extract_request_uri (request_rec * r , char * a )
79
80
{
80
- return r -> uri ;
81
+ return json_object_new_string ( r -> uri ) ;
81
82
}
82
83
83
- static const char * extract_request_method (request_rec * r , char * a )
84
+ json_object * extract_request_method (request_rec * r , char * a )
84
85
{
85
- return r -> method ;
86
+ return json_object_new_string ( r -> method ) ;
86
87
}
87
88
88
- static const char * extract_request_protocol (request_rec * r , char * a )
89
+ json_object * extract_request_protocol (request_rec * r , char * a )
89
90
{
90
- return r -> protocol ;
91
+ return json_object_new_string ( r -> protocol ) ;
91
92
}
92
93
93
- static const char * extract_request_query (request_rec * r , char * a )
94
+ json_object * extract_request_query (request_rec * r , char * a )
94
95
{
95
- return (r -> args ) ? apr_pstrcat (r -> pool , "?" ,
96
+ return json_object_new_string ( (r -> args ) ? apr_pstrcat (r -> pool , "?" ,
96
97
r -> args , NULL )
97
- : "" ;
98
+ : "" ) ;
98
99
}
99
100
100
- static const char * extract_status (request_rec * r , char * a )
101
+ json_object * extract_status (request_rec * r , char * a )
101
102
{
102
103
if (r -> status <= 0 ) {
103
- return "-" ;
104
+ return NULL ;
104
105
} else {
105
- return apr_psprintf ( r -> pool , "%d" , r -> status );
106
+ return json_object_new_int ( r -> status );
106
107
}
107
108
}
108
109
109
- static const char * extract_virtual_host (request_rec * r , char * a )
110
+ json_object * extract_virtual_host (request_rec * r , char * a )
110
111
{
111
- return r -> server -> server_hostname ;
112
+ return json_object_new_string ( r -> server -> server_hostname ) ;
112
113
}
113
114
114
- static const char * extract_server_name (request_rec * r , char * a )
115
+ json_object * extract_server_name (request_rec * r , char * a )
115
116
{
116
- return ap_get_server_name (r );
117
+ return json_object_new_string ( ap_get_server_name (r ) );
117
118
}
118
119
119
- static const char * extract_server_port (request_rec * r , char * a )
120
+ json_object * extract_server_port (request_rec * r , char * a )
120
121
{
121
- return apr_psprintf (r -> pool , "%u" ,
122
- r -> server -> port ? r -> server -> port : ap_default_port (r ));
122
+ return json_object_new_string ( apr_psprintf (r -> pool , "%u" ,
123
+ r -> server -> port ? r -> server -> port : ap_default_port (r ))) ;
123
124
}
124
125
125
126
/* This respects the setting of UseCanonicalName so that
@@ -131,63 +132,63 @@ static const char *log_server_name(request_rec *r, char *a)
131
132
return ap_get_server_name (r );
132
133
}
133
134
134
- static const char * extract_child_pid (request_rec * r , char * a )
135
+ json_object * extract_child_pid (request_rec * r , char * a )
135
136
{
136
137
if (* a == '\0' || !strcmp (a , "pid" )) {
137
- return apr_psprintf (r -> pool , "%" APR_PID_T_FMT , getpid ());
138
+ return json_object_new_string ( apr_psprintf (r -> pool , "%" APR_PID_T_FMT , getpid () ));
138
139
}
139
140
else if (!strcmp (a , "tid" )) {
140
141
#if APR_HAS_THREADS
141
142
apr_os_thread_t tid = apr_os_thread_current ();
142
143
#else
143
144
int tid = 0 ; /* APR will format "0" anyway but an arg is needed */
144
145
#endif
145
- return apr_psprintf (r -> pool , "%pT" , & tid );
146
+ return json_object_new_string ( apr_psprintf (r -> pool , "%pT" , & tid ) );
146
147
}
147
148
/* bogus format */
148
- return a ;
149
+ return json_object_new_string ( a ) ;
149
150
}
150
151
151
- static const char * extract_header (request_rec * r , char * a )
152
+ json_object * extract_header (request_rec * r , char * a )
152
153
{
153
154
const char * tempref ;
154
155
155
156
tempref = apr_table_get (r -> headers_in , a );
156
157
if (!tempref )
157
158
{
158
- return "-" ;
159
+ return NULL ;
159
160
} else {
160
- return tempref ;
161
+ return json_object_new_string ( tempref ) ;
161
162
}
162
163
}
163
164
164
- static const char * extract_referer (request_rec * r , char * a )
165
+ json_object * extract_referer (request_rec * r , char * a )
165
166
{
166
167
const char * tempref ;
167
168
168
169
tempref = apr_table_get (r -> headers_in , "Referer" );
169
170
if (!tempref )
170
171
{
171
- return "-" ;
172
+ return NULL ;
172
173
} else {
173
- return tempref ;
174
+ return json_object_new_string ( tempref ) ;
174
175
}
175
176
}
176
177
177
- static const char * extract_agent (request_rec * r , char * a )
178
+ json_object * extract_agent (request_rec * r , char * a )
178
179
{
179
180
const char * tempag ;
180
181
181
182
tempag = apr_table_get (r -> headers_in , "User-Agent" );
182
183
if (!tempag )
183
184
{
184
- return "-" ;
185
+ return NULL ;
185
186
} else {
186
- return tempag ;
187
+ return json_object_new_string ( tempag ) ;
187
188
}
188
189
}
189
190
190
- static const char * extract_specific_cookie (request_rec * r , char * a )
191
+ json_object * extract_specific_cookie (request_rec * r , char * a )
191
192
{
192
193
const char * cookiestr ;
193
194
char * cookieend ;
@@ -215,7 +216,7 @@ static const char *extract_specific_cookie(request_rec *r, char *a)
215
216
cookieend = ap_strchr (cookiebuf , ';' );
216
217
if (cookieend != NULL )
217
218
* cookieend = '\0' ;
218
- return cookiebuf ;
219
+ return json_object_new_string ( cookiebuf ) ;
219
220
}
220
221
}
221
222
@@ -230,7 +231,7 @@ static const char *extract_specific_cookie(request_rec *r, char *a)
230
231
cookieend = ap_strchr (cookiebuf , ';' );
231
232
if (cookieend != NULL )
232
233
* cookieend = '\0' ;
233
- return cookiebuf ;
234
+ return json_object_new_string ( cookiebuf ) ;
234
235
}
235
236
}
236
237
@@ -245,10 +246,10 @@ static const char *extract_specific_cookie(request_rec *r, char *a)
245
246
cookieend = ap_strchr (cookiebuf , ';' );
246
247
if (cookieend != NULL )
247
248
* cookieend = '\0' ;
248
- return cookiebuf ;
249
+ return json_object_new_string ( cookiebuf ) ;
249
250
}
250
251
}
251
252
}
252
253
253
- return "-" ;
254
+ return NULL ;
254
255
}
0 commit comments