2 * Copyright (C) 2005 QSDN,Inc. All rights reserved.
3 * Copyright (C) 2005 Atsushi Konno All rights reserved.
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
19 static device_table_t UNKNOWN_DEVICE = {
20 NULL, "","UNKNOWN", CHXJ_SPEC_UNKNOWN, 0, 0,0,0,0,0,0,0,0,0,0,0,0, ""};
23 * The device is specified from UserAgent.
24 * @param r Request_rec is appointed.
25 * @param userAgent UserAgent is appointed here,
26 * @return The style which corresponds is returned.
29 chxj_specified_device(request_rec* r, const char* user_agent)
32 ap_regmatch_t match[10];
33 device_table_t* returnType = &UNKNOWN_DEVICE;
34 device_table_list_t* dtl;
36 mod_chxj_config* conf;
44 DBG(r, "start chxj_specified_device()");
45 conf = ap_get_module_config(r->per_dir_config, &chxj_module);
46 for (dtl = conf->devices; dtl; dtl = dtl->next) {
48 DBG(r, "pattern is null");
52 DBG1(r, "pattern is [%s]", dtl->pattern);
54 DBG(r,"compile failed.");
58 rtn = ap_regexec(regexp, user_agent, regexp->re_nsub + 1, match, 0);
59 ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, "pattern is [%s]", dtl->pattern);
61 device_id = ap_pregsub(r->pool, "$1", user_agent, regexp->re_nsub + 1, match);
62 ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, "device_id:[%s]", device_id);
63 for (dt = dtl->table; dt; dt = dt->next) {
64 if (strcasecmp(device_id, dt->device_id) == 0) {
65 ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, "device_name:[%s]", dt->device_name);
71 for (dt = dtl->table; dt; dt = dt->next) {
72 if (dt->next == NULL) {
81 ap_pregfree(r->pool, regexp);
82 if (returnType != &UNKNOWN_DEVICE) {
83 ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, "end chxj_specified_device()");
87 ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, "end chxj_specified_device()");