2 * Copyright (C) 2005-2008 Atsushi Konno All rights reserved.
3 * Copyright (C) 2005 QSDN,Inc. 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.
17 #include "chxj_tag_util.h"
20 * The value of the VALUE attribute that the object tag node maintains is
23 * @param doc [i] The pointer to the Doc structure to be scanned is
25 * @param node [i] The tag node to be scanned is specified.
26 * @param r [i] To use POOL, the pointer to request_rec is specified.
27 * @return The value of the VALUE attribute that the object tag node maintains
28 * is returned. NULL is returned when not found.
31 qs_get_value_attr(Doc* doc, Node* node, request_rec* r)
35 /*--------------------------------------------------------------------------*/
36 /* The object tag node is scanned. */
37 /*--------------------------------------------------------------------------*/
38 for (attr = qs_get_attr(doc,node);
40 attr = qs_get_next_attr(doc,attr)) {
45 name = qs_get_attr_name(doc,attr);
46 value = qs_get_attr_value(doc,attr);
48 if ((*name == 'v' || *name == 'V') && strcasecmp(name, "value") == 0)
49 /*----------------------------------------------------------------------*/
50 /* The VALUE attribute was found. */
51 /*----------------------------------------------------------------------*/
52 return apr_pstrdup(r->pool, value);
55 /*--------------------------------------------------------------------------*/
57 /*--------------------------------------------------------------------------*/
62 * The value of the checked tag is acquired.
64 * @param doc [i] The pointer to the Doc structure to be scanned is
66 * @param tag [i] The tag node to be scanned is specified.
67 * @param r [i] To use POOL, the pointer to request_rec is specified.
68 * @return The value of the checked tag is returned. NULL is returned when
72 qs_get_checked_attr(Doc* doc, Node* tag, request_rec *UNUSED(r))
76 /*--------------------------------------------------------------------------*/
77 /* The object tag node is scanned. */
78 /*--------------------------------------------------------------------------*/
79 for (attr = qs_get_attr(doc,tag);
81 attr = qs_get_next_attr(doc,attr)) {
82 char* name = qs_get_attr_name(doc,attr);
83 if ((*name == 'c' || *name == 'C') && strcasecmp(name, "checked") == 0) {
84 /*----------------------------------------------------------------------*/
85 /* The VALUE attribute was found. */
86 /*----------------------------------------------------------------------*/
90 /*------------------------------------------------------------------------*/
92 /*------------------------------------------------------------------------*/
98 * The value of the type attribute is acquired.
100 * @param doc [i] The pointer to the Doc structure to be scanned is
102 * @param tag [i] The tag node to be scanned is specified.
103 * @param r [i] To use POOL, the pointer to request_rec is specified.
104 * @return The value of the type attribute is returned. NULL is returned when
108 qs_get_type_attr(Doc* doc, Node* tag, request_rec* r)
112 /*--------------------------------------------------------------------------*/
113 /* The object tag node is scanned. */
114 /*--------------------------------------------------------------------------*/
115 for (attr = qs_get_attr(doc,tag);
117 attr = qs_get_next_attr(doc,attr)) {
119 char* name = qs_get_attr_name(doc,attr);
120 char* value = qs_get_attr_value(doc,attr);
122 if ((*name == 't' || *name == 'T') && strcasecmp(name, "type") == 0)
123 /*----------------------------------------------------------------------*/
124 /* The VALUE attribute was found. */
125 /*----------------------------------------------------------------------*/
126 return apr_pstrdup(r->pool, value);
128 /*--------------------------------------------------------------------------*/
130 /*--------------------------------------------------------------------------*/
135 * The character string area in 0 bytes is allocated.
137 * @param r [i] To use POOL, the pointer to request_rec is specified.
138 * @return The allocated 0 byte character string is returned.
141 qs_alloc_zero_byte_string(request_rec* r)
143 char* tgt = apr_palloc(r->pool, 1);
150 * A consecutive head and the last WHITESPACE are removed.
152 * @param p [i] To use POOL
153 * @param s [i] The character string that should be removed is specified.
154 * @return The character string that has been removed is returned.
157 qs_trim_string(apr_pool_t *p, char* s)
159 char* ss = apr_pstrdup(p, s);
164 for (ii = 0;is_white_space(*ss) && ii < len; ss++, ii++);
167 for(;is_white_space(ss[ii-1]) && ii > 0; ii--);
175 * The value of child TEXT of tag that maintains the SELECTED attribute is
178 * @param Doc [i] The pointer to the Doc structure to be scanned is
180 * @param node [i] The tag node to be scanned is specified.
181 * @param r [i] To use POOL, the pointer to request_rec is specified.
182 * @reutrn The value of child TEXT of tag that maintains the SELECTED
183 * attribute is returned. NULL is returned when not found.
186 qs_get_selected_value_text(Doc *doc, Node* node, request_rec* r)
192 for (child = qs_get_child_node(doc,node);
194 child = qs_get_next_node(doc,child)) {
196 char* name = qs_get_node_name(doc,child);
198 /*------------------------------------------------------------------------*/
200 /*------------------------------------------------------------------------*/
201 if ((*name == 'o' || *name == 'O') && strcasecmp(name, "option") == 0) {
204 for (attr = qs_get_attr(doc,child);
206 attr = qs_get_next_attr(doc,attr)) {
208 char* name = qs_get_attr_name(doc,attr);
210 DBG(r, "qs_get_selected_value name::[%s]" , name);
212 if ((*name == 's'|| *name == 'S') && strcasecmp(name, "selected") == 0) {
213 /*------------------------------------------------------------------*/
214 /* SELECTED Value Found */
215 /*------------------------------------------------------------------*/
216 selchild = qs_get_child_node(doc, child);
218 DBG(r,"found selected tag but null node" );
221 return qs_get_node_value(doc, selchild);
226 if ((result = qs_get_selected_value_text(doc, child, r)) != NULL)
230 /*--------------------------------------------------------------------------*/
232 /*--------------------------------------------------------------------------*/
237 * The value of tag that maintains the SELECTED attribute is acquired.
239 * @param doc [i] The pointer to the Doc structure to be scanned is
241 * @param node [i] The SELECT tag node is specified.
242 * @param r [i] To use POOL, the pointer to request_rec is specified.
243 * @return The value of tag that maintains the SELECTED attribute is
244 * returned. NULL is returned when not found.
247 qs_get_selected_value(Doc* doc, Node* node, request_rec* r)
252 for (child = qs_get_child_node(doc,node);
254 child = qs_get_next_node(doc,child)) {
256 char* name = qs_get_node_name(doc,child);
258 /*------------------------------------------------------------------------*/
260 /*------------------------------------------------------------------------*/
261 if ((*name == 'o' || *name == 'O') && strcasecmp(name, "option") == 0) {
264 for (attr = qs_get_attr(doc,child);
266 attr = qs_get_next_attr(doc,attr)) {
268 char* name = qs_get_attr_name(doc,attr);
270 DBG(r, "qs_get_selected_value name::[%s]" , name);
272 if ((*name == 's' || *name == 'S') && strcasecmp(name, "selected") == 0)
273 /*------------------------------------------------------------------*/
274 /* SELECTED Value Found */
275 /*------------------------------------------------------------------*/
276 return qs_get_value_attr(doc, child, r);
280 if ((result = qs_get_selected_value(doc, child, r)) != NULL)
284 /*--------------------------------------------------------------------------*/
286 /*--------------------------------------------------------------------------*/
291 * The value of the SIZE attribute is acquired.
293 * @param doc [i] The pointer to the Doc structure at the output
294 * destination is specified.
295 * @param tag [i] The tag node to want to acquire the SIZE attribute
297 * @param r [i] To use POOL, the pointer to request_rec is specified.
298 * @return The value of the SIZE attribute is returned. NULL is
299 * returned when not is.
302 qs_get_name_attr(Doc* doc, Node* tag, request_rec* r)
306 for (attr = qs_get_attr(doc,tag);
308 attr = qs_get_next_attr(doc,attr)) {
310 char* name = qs_get_attr_name(doc,attr);
311 char* value = qs_get_attr_value(doc,attr);
313 if ((*name == 'n' || *name == 'N') && strcasecmp(name, "name") == 0)
314 return apr_pstrdup(r->pool, value);
321 * The value of the SIZE attribute is acquired.
323 * @param doc [i] The pointer to the Doc structure at the output
324 * destination is specified.
325 * @param tag [i] The tag node to want to acquire the SIZE attribute
327 * @param r [i] To use POOL, the pointer to request_rec is specified.
328 * @return The value of the SIZE attribute is returned. NULL is
329 * returned when not is.
332 qs_get_size_attr(Doc* doc, Node* tag, request_rec* r)
336 for (attr = qs_get_attr(doc,tag);
338 attr = qs_get_next_attr(doc,attr)) {
340 char* name = qs_get_attr_name(doc,attr);
341 char* value = qs_get_attr_value(doc,attr);
343 if ((*name == 's' || *name == 'S') && strcasecmp(name, "size") == 0)
344 return apr_pstrdup(r->pool, value);
351 * The value of the ACCESSKEY attribute is acquired.
353 * @param doc [i] The pointer to the Doc structure at the output
354 * destination is specified.
355 * @param tag [i] The tag node to want to acquire the ACCESSKEY attribute
357 * @param r [i] To use POOL, the pointer to request_rec is specified.
358 * @return The value of the ACCESSKEY attribute is returned. NULL is
359 * returned when not is.
362 qs_get_accesskey_attr(Doc* doc, Node* tag, request_rec* r)
366 for (attr = qs_get_attr(doc,tag);
368 attr = qs_get_next_attr(doc,attr)) {
370 char* name = qs_get_attr_name(doc,attr);
371 char* value = qs_get_attr_value(doc,attr);
373 if ((*name == 'a' || *name == 'A') && strcasecmp(name, "accesskey") == 0)
374 return apr_pstrdup(r->pool, value);
381 * The value of the ISTYLE attribute is acquired.
383 * @param doc [i] The pointer to the Doc structure at the output
384 * destination is specified.
385 * @param tag [i] The tag node to want to acquire the ISTYLE attribute
387 * @param r [i] To use POOL, the pointer to request_rec is specified.
388 * @return The value of the ISTYLE attribute is returned. NULL is
389 * returned when not is.
392 qs_get_istyle_attr(Doc* doc, Node* tag, request_rec* r)
396 for (attr = qs_get_attr(doc,tag);
398 attr = qs_get_next_attr(doc,attr)) {
400 char* name = qs_get_attr_name(doc,attr);
401 char* value = qs_get_attr_value(doc,attr);
403 if ((*name == 'i' || *name == 'I') && strcasecmp(name, "istyle") == 0)
404 return apr_pstrdup(r->pool, value);
411 * The value of the MAXLENGTH attribute is acquired from the tag node of the
414 * @param doc [i] The pointer to the Doc structure at the output
415 * destination is specified.
416 * @param tag [i] The tag node to want to acquire the MAXLENGTH attribute
418 * @param r [i] To use POOL, the pointer to request_rec is specified.
419 * @return The value of the MAXLENGTH attribute is returned. NULL is
420 * returned when not is.
423 qs_get_maxlength_attr(Doc* doc, Node* tag, request_rec* r)
427 for (attr = qs_get_attr(doc,tag);
429 attr = qs_get_next_attr(doc,attr)) {
431 char* name = qs_get_attr_name(doc,attr);
432 char* value = qs_get_attr_value(doc,attr);
434 if ((*name == 'm' || *name == 'M') && strcasecmp(name, "maxlength") == 0)
435 return apr_pstrdup(r->pool, value);
442 * It is scanned whether the CHECKBOX tag of the object is CHECKED.
444 * @param doc [i] The pointer to the Doc structure at the output
445 * destination is specified.
446 * @param tag [i] The tag node to want to acquire the CHECKBOX attribute
448 * @param r [i] To use POOL, the pointer to request_rec is specified.
449 * @return 1 is returned when it is CHECKED and, additionally, 0 is returned.
452 qs_is_checked_checkbox_attr(Doc* doc, Node* tag, request_rec* UNUSED(r))
456 for (attr = qs_get_attr(doc,tag);
458 attr = qs_get_next_attr(doc,attr)) {
460 char* name = qs_get_attr_name(doc,attr);
462 if ((*name == 'c' || *name == 'C') && strcasecmp(name, "checked") == 0)
471 chxj_chxjif_is_mine(device_table* spec, Doc* doc, Node* tag)
473 request_rec* r = doc->r;
476 for (attr = qs_get_attr(doc,tag);
478 attr = qs_get_next_attr(doc,attr)) {
480 char* name = qs_get_attr_name(doc,attr);
481 char* value = qs_get_attr_value(doc,attr);
483 if ((*name == 'l' || *name == 'L') && strcasecmp(name, "lang") == 0) {
485 DBG(r, "lang found [%s] spec [%d]", value, spec->html_spec_type);
487 if ((*value == 'x' || *value == 'X') && strcasecmp(value, "xhtml") == 0) {
488 if (spec->html_spec_type == CHXJ_SPEC_XHtml_Mobile_1_0) {
489 /* Yes , it is mine */
494 if ((*value == 'h' || *value == 'H') && strcasecmp(value, "hdml") == 0) {
495 if (spec->html_spec_type == CHXJ_SPEC_Hdml) {
496 /* Yes , it is mine */
501 if ((*value == 'j' || *value == 'J') && strcasecmp(value, "jhtml") == 0) {
502 if (spec->html_spec_type == CHXJ_SPEC_Jhtml) {
503 /* Yes , it is mine */
508 if ((*value == 'c' || *value == 'C') && strcasecmp(value, "chtml") == 0) {
509 switch (spec->html_spec_type) {
510 case CHXJ_SPEC_Chtml_1_0:
511 case CHXJ_SPEC_Chtml_2_0:
512 case CHXJ_SPEC_Chtml_3_0:
513 case CHXJ_SPEC_Chtml_4_0:
514 case CHXJ_SPEC_Chtml_5_0:
523 /* No, it is not mine. */
528 * The value of the DESTLANG attribute is acquired from the tag node of the
531 * @param doc [i] The pointer to the Doc structure at the output
532 * destination is specified.
533 * @param tag [i] The tag node to want to acquire the DESTLANG attribute
535 * @param r [i] To use POOL, the pointer to request_rec is specified.
536 * @return The value of the DESTLANG attribute is returned. NULL is
537 * returned when not is.
540 qs_get_destlang_attr(Doc* doc, Node* tag, request_rec* r)
544 for (attr = qs_get_attr(doc,tag);
546 attr = qs_get_next_attr(doc,attr)) {
548 char* name = qs_get_attr_name(doc,attr);
549 char* value = qs_get_attr_value(doc,attr);
551 if ((*name == 'd' || *name == 'D') && strcasecmp(name, "destlang") == 0)
552 return apr_pstrdup(r->pool, value);
560 * The value of the PARSE attribute is acquired.
562 * @param doc [i] The pointer to the Doc structure to be scanned is
564 * @param tag [i] The tag node to be scanned is specified.
565 * @param r [i] To use POOL, the pointer to request_rec is specified.
566 * @return The value of the PARSE attribute is returned. NULL is returned when
570 qs_get_parse_attr(Doc* doc, Node* tag, request_rec* r)
574 /*--------------------------------------------------------------------------*/
575 /* The object tag node is scanned. */
576 /*--------------------------------------------------------------------------*/
577 for (attr = qs_get_attr(doc,tag);
579 attr = qs_get_next_attr(doc,attr)) {
581 char* name = qs_get_attr_name(doc,attr);
582 char* value = qs_get_attr_value(doc,attr);
584 if ((*name == 'p' || *name == 'P') && strcasecmp(name, "parse") == 0) {
585 /*----------------------------------------------------------------------*/
586 /* The VALUE attribute was found. */
587 /*----------------------------------------------------------------------*/
588 return apr_pstrdup(r->pool, value);
592 /*--------------------------------------------------------------------------*/
594 /*--------------------------------------------------------------------------*/