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 UNKNOWN_DEVICE = {
22 .device_name = "UNKNOWN",
23 .html_spec_type = CHXJ_SPEC_UNKNOWN,
26 /*--------------------------------------------------------------------------*/
27 /* Walll Paper Size */
28 /*--------------------------------------------------------------------------*/
31 /*--------------------------------------------------------------------------*/
33 /*--------------------------------------------------------------------------*/
35 /*--------------------------------------------------------------------------*/
36 /* Correspondence image format */
37 /* 1: It is possible to display it. */
38 /* 0: It is not possible to display it. */
39 /*--------------------------------------------------------------------------*/
47 /*--------------------------------------------------------------------------*/
48 /* Color number type */
51 /* 256 : 256 Colors */
52 /* 4096 : 4096 Colors */
53 /* 65536 : 65536 Colors */
54 /* 262144 : 262144 Colors */
55 /* 15680000: 15680000 over colors */
56 /*--------------------------------------------------------------------------*/
62 * The device is specified from UserAgent.
63 * @param r Request_rec is appointed.
64 * @param userAgent UserAgent is appointed here,
65 * @return The style which corresponds is returned.
68 chxj_specified_device(request_rec* r, const char* user_agent)
70 ap_regmatch_t match[10];
71 device_table* returnType = &UNKNOWN_DEVICE;
72 device_table_list* dtl;
74 mod_chxj_config* conf;
81 DBG(r, "start chxj_specified_device()");
83 conf = ap_get_module_config(r->per_dir_config, &chxj_module);
84 if (! conf->devices) {
85 DBG(r, "device_data.xml load failure");
89 for (dtl = conf->devices; dtl; dtl = dtl->next) {
91 DBG(r, "pattern is null");
95 DBG1(r, "pattern is [%s]", dtl->pattern);
97 DBG(r,"compile failed.");
101 if (ap_regexec(dtl->regexp, user_agent, dtl->regexp->re_nsub + 1, match, 0) == 0) {
102 device_id = ap_pregsub(r->pool, "$1", user_agent, dtl->regexp->re_nsub + 1, match);
103 DBG1(r, "device_id:[%s]", device_id);
104 for (dt = dtl->table; dt; dt = dt->next) {
105 if (strcasecmp(device_id, dt->device_id) == 0) {
106 DBG1(r, "device_name:[%s]", dt->device_name);
113 for (dt = dtl->table; dt; dt = dt->next) {
114 if (dt->next == NULL)
123 if (returnType != &UNKNOWN_DEVICE) {
124 DBG(r,"end chxj_specified_device()");
129 DBG(r,"end chxj_specified_device()");