OSDN Git Service

* version up
[modchxj/mod_chxj.git] / include / chxj_specified_device.h
1 /*
2  * Copyright (C) 2005-2011 Atsushi Konno All rights reserved.
3  * Copyright (C) 2005 QSDN,Inc. All rights reserved.
4  *
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
8  *
9  *     http://www.apache.org/licenses/LICENSE-2.0
10  *
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.
16  */
17 #ifndef __CHXJ_SPECIFIED_DEVICE_H__
18 #define __CHXJ_SPECIFIED_DEVICE_H__
19
20 typedef enum {
21   CHXJ_SPEC_UNKNOWN=0,
22   CHXJ_SPEC_Chtml_1_0,
23   CHXJ_SPEC_Chtml_2_0,
24   CHXJ_SPEC_Chtml_3_0,
25   CHXJ_SPEC_Chtml_4_0,
26   CHXJ_SPEC_Chtml_5_0,
27   CHXJ_SPEC_Chtml_6_0, /* use XHTML */
28   CHXJ_SPEC_Chtml_7_0, /* use XHTML */
29   CHXJ_SPEC_XHtml_Mobile_1_0,
30   CHXJ_SPEC_Hdml,
31   CHXJ_SPEC_Jhtml,
32   CHXJ_SPEC_Jxhtml,    /* use XHTML */
33   CHXJ_SPEC_iPhone2,   /* use XHTML */
34   CHXJ_SPEC_iPhone3,   /* use XHTML */
35   CHXJ_SPEC_iPhone4,   /* use XHTML */
36   CHXJ_SPEC_softbank_android, /* use XHTML (SoftBank) */
37   CHXJ_SPEC_au_android, /* use XHTML (au KDDI)  */
38   CHXJ_SPEC_docomo_android, /* use XHTML (docomo)   */
39   CHXJ_SPEC_android,        /* use XHTML */
40   CHXJ_SPEC_HTML,
41 } spec_type;
42
43 #define CHXJ_PIC_OK                (0x01)
44 #define CHXJ_PIC_NG                (0x00)
45
46 #define IS_IPHONE(X) (((X)->html_spec_type == CHXJ_SPEC_iPhone2) \
47                      || ((X)->html_spec_type == CHXJ_SPEC_iPhone3) \
48                      || ((X)->html_spec_type == CHXJ_SPEC_iPhone4))
49 #define IS_ANDROID(X) (  ((X)->html_spec_type == CHXJ_SPEC_softbank_android) \
50                       || ((X)->html_spec_type == CHXJ_SPEC_au_android)  \
51                       || ((X)->html_spec_type == CHXJ_SPEC_docomo_android) \
52                       || ((X)->html_spec_type == CHXJ_SPEC_android))
53
54 #include "mod_chxj.h"
55 #include "chxj_cookie.h"
56
57
58 typedef struct device_table_t device_table;
59
60 struct device_table_t {
61   struct device_table_t* next;
62   int                    provider;              /* DOCOMO|AU|SOFTBANK|UNKNOWN */
63   const char*            device_id;
64   const char*            device_name;
65   spec_type              html_spec_type;
66   int                    width;
67   int                    heigh;
68   /*--------------------------------------------------------------------------*/
69   /* Walll Paper Size                                                         */
70   /*--------------------------------------------------------------------------*/
71   int                    wp_width;
72   int                    wp_heigh;
73   /*--------------------------------------------------------------------------*/
74   /* Cache Size                                                               */
75   /*--------------------------------------------------------------------------*/
76   int                    cache;
77   /*--------------------------------------------------------------------------*/
78   /* Correspondence image format                                              */
79   /* 1: It is possible to display it.                                         */
80   /* 0: It is not possible to display it.                                     */
81   /*--------------------------------------------------------------------------*/
82   int                    available_gif;
83   int                    available_jpeg;
84   int                    available_png;
85   int                    available_bmp2;
86   int                    available_bmp4;
87   /*--------------------------------------------------------------------------*/
88   /* Resolution                                                               */
89   /*--------------------------------------------------------------------------*/
90   int                    dpi_width;
91   int                    dpi_heigh;
92   /*--------------------------------------------------------------------------*/
93   /* Color number type                                                        */
94   /* 2       : 2        Colors                                                */
95   /* 4       : 4        Colors                                                */
96   /* 256     : 256      Colors                                                */
97   /* 4096    : 4096     Colors                                                */
98   /* 65536   : 65536    Colors                                                */
99   /* 262144  : 262144   Colors                                                */
100   /* 15680000: 15680000 over colors                                           */
101   /*--------------------------------------------------------------------------*/
102   int                    color;
103   char*                  emoji_type;
104   char*                  output_encoding;  /* Output encoding */
105 };
106
107 typedef struct device_table_list_t  device_table_list;
108
109 struct device_table_list_t {
110   struct device_table_list_t  *next;
111
112   char                        *pattern;
113   ap_regex_t                  *regexp;
114   device_table                *table;
115   device_table                *tail;
116
117   device_table                **sort_table;
118   size_t                      table_count;
119 };
120
121 typedef struct converter_t converter_t;
122
123 struct converter_t {
124   /* convert routine */
125   char *(*converter)(request_rec                 *r,
126                      struct device_table_t       *spec,
127                      const char                  *src, 
128                      apr_size_t                  srclen, 
129                      apr_size_t                  *dstlen,
130                      struct chxjconvrule_entry   *entryp,
131                      cookie_t                    *cookie);
132
133   char *(*encoder)(request_rec  *r,
134                    const char   *src,
135                    apr_size_t   *len);
136
137
138   char *(*emoji_only_converter)(
139                    request_rec           *r,
140                    struct device_table_t *spec,
141                    const char            *src,
142                    apr_size_t            len);
143 };
144
145 extern converter_t convert_routine[];
146
147 extern device_table* chxj_specified_device(
148   request_rec             *r, 
149   const char              *user_agent);
150
151 #endif