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"
21 * The value of the VALUE attribute that the object tag node maintains is
24 * @param doc [i] The pointer to the Doc structure to be scanned is
26 * @param node [i] The tag node to be scanned is specified.
27 * @param pool [i] To use POOL.
28 * @return The value of the VALUE attribute that the object tag node maintains
29 * is returned. NULL is returned when not found.
32 qs_get_value_attr(Doc *doc, Node *node, apr_pool_t *pool)
36 /*--------------------------------------------------------------------------*/
37 /* The object tag node is scanned. */
38 /*--------------------------------------------------------------------------*/
39 for (attr = qs_get_attr(doc,node);
41 attr = qs_get_next_attr(doc,attr)) {
42 char *name = qs_get_attr_name(doc,attr);
43 char *value = qs_get_attr_value(doc,attr);
44 if (STRCASEEQ('v','V',"value",name)) {
45 /*----------------------------------------------------------------------*/
46 /* The VALUE attribute was found. */
47 /*----------------------------------------------------------------------*/
48 return apr_pstrdup(pool, value);
51 /*--------------------------------------------------------------------------*/
53 /*--------------------------------------------------------------------------*/
59 * The value of the checked tag is acquired.
61 * @param doc [i] The pointer to the Doc structure to be scanned is
63 * @param tag [i] The tag node to be scanned is specified.
64 * @param pool [i] To use POOL(unused).
65 * @return The value of the checked tag is returned. NULL is returned when
69 qs_get_checked_attr(Doc *doc, Node *tag, apr_pool_t *UNUSED(pool))
72 /*--------------------------------------------------------------------------*/
73 /* The object tag node is scanned. */
74 /*--------------------------------------------------------------------------*/
75 for (attr = qs_get_attr(doc,tag);
77 attr = qs_get_next_attr(doc,attr)) {
78 char *name = qs_get_attr_name(doc,attr);
79 if (STRCASEEQ('c','C',"checked",name)) {
80 /*----------------------------------------------------------------------*/
81 /* The VALUE attribute was found. */
82 /*----------------------------------------------------------------------*/
86 /*------------------------------------------------------------------------*/
88 /*------------------------------------------------------------------------*/
94 * The value of the type attribute is acquired.
96 * @param doc [i] The pointer to the Doc structure to be scanned is
98 * @param tag [i] The tag node to be scanned is specified.
99 * @param r [i] To use POOL, the pointer to request_rec is specified.
100 * @return The value of the type attribute is returned. NULL is returned when
104 qs_get_type_attr(Doc *doc, Node *tag, apr_pool_t *pool)
107 /*--------------------------------------------------------------------------*/
108 /* The object tag node is scanned. */
109 /*--------------------------------------------------------------------------*/
110 for (attr = qs_get_attr(doc,tag);
112 attr = qs_get_next_attr(doc,attr)) {
113 char *name = qs_get_attr_name(doc,attr);
114 char *value = qs_get_attr_value(doc,attr);
115 if (STRCASEEQ('t','T',"type",name)) {
116 /*----------------------------------------------------------------------*/
117 /* The VALUE attribute was found. */
118 /*----------------------------------------------------------------------*/
119 return apr_pstrdup(pool, value);
122 /*--------------------------------------------------------------------------*/
124 /*--------------------------------------------------------------------------*/
130 * The character string area in 0 bytes is allocated.
132 * @param pool [i] To use POOL.
133 * @return The allocated 0 byte character string is returned.
136 qs_alloc_zero_byte_string(apr_pool_t *pool)
143 tgt = apr_palloc(pool, 1);
151 * A consecutive head and the last WHITESPACE are removed.
153 * @param p [i] To use POOL
154 * @param s [i] The character string that should be removed is specified.
155 * @return The character string that has been removed is returned.
158 qs_trim_string(apr_pool_t *p, char* s)
160 char *ss = apr_pstrdup(p, s);
165 for (ii = 0;is_white_space(*ss) && ii < len; ss++, ii++);
168 for(;is_white_space(ss[ii-1]) && ii > 0; ii--);
177 * The value of child TEXT of tag that maintains the SELECTED attribute is
180 * @param Doc [i] The pointer to the Doc structure to be scanned is
182 * @param node [i] The tag node to be scanned is specified.
183 * @param pool [i] To use POOL.
184 * @reutrn The value of child TEXT of tag that maintains the SELECTED
185 * attribute is returned. NULL is returned when not found.
188 qs_get_selected_value_text(Doc *doc, Node *node, apr_pool_t *pool)
194 for (child = qs_get_child_node(doc,node);
196 child = qs_get_next_node(doc,child)) {
197 char *name = qs_get_node_name(doc,child);
198 /*------------------------------------------------------------------------*/
200 /*------------------------------------------------------------------------*/
201 if (STRCASEEQ('o','O',"option",name)) {
203 for (attr = qs_get_attr(doc,child);
205 attr = qs_get_next_attr(doc,attr)) {
206 <<<<<<< HEAD:src/chxj_tag_util.c
207 char *name = qs_get_attr_name(doc,attr);
208 DBG(r, "qs_get_selected_value name::[%s]" , name);
210 if ((*name == 's'|| *name == 'S') && strcasecmp(name, "selected") == 0) {
212 char *name2 = qs_get_attr_name(doc,attr);
213 if (STRCASEEQ('s','S',"selected",name2)) {
214 >>>>>>> * updated new trunk.:src/chxj_tag_util.c
215 /*------------------------------------------------------------------*/
216 /* SELECTED Value Found */
217 /*------------------------------------------------------------------*/
218 selchild = qs_get_child_node(doc, child);
221 return apr_pstrdup(pool, "");
223 return qs_get_node_value(doc, selchild);
228 if ((result = qs_get_selected_value_text(doc, child, pool)) != NULL) {
233 /*--------------------------------------------------------------------------*/
235 /*--------------------------------------------------------------------------*/
241 * The value of tag that maintains the SELECTED attribute is acquired.
243 * @param doc [i] The pointer to the Doc structure to be scanned is
245 * @param node [i] The SELECT tag node is specified.
246 * @param pool [i] To use POOL.
247 * @return The value of tag that maintains the SELECTED attribute is
248 * returned. NULL is returned when not found.
251 qs_get_selected_value(Doc *doc, Node *node, apr_pool_t *pool)
256 for (child = qs_get_child_node(doc,node);
258 child = qs_get_next_node(doc,child)) {
259 char *name = qs_get_node_name(doc,child);
260 /*------------------------------------------------------------------------*/
262 /*------------------------------------------------------------------------*/
263 if (STRCASEEQ('o','O',"option",name)) {
265 for (attr = qs_get_attr(doc,child);
267 attr = qs_get_next_attr(doc,attr)) {
268 char *name2 = qs_get_attr_name(doc,attr);
269 if (STRCASEEQ('s','S',"selected",name2)) {
270 /*------------------------------------------------------------------*/
271 /* SELECTED Value Found */
272 /*------------------------------------------------------------------*/
273 return qs_get_value_attr(doc, child, doc->buf.pool);
278 if ((result = qs_get_selected_value(doc, child, pool)) != NULL) {
283 /*--------------------------------------------------------------------------*/
285 /*--------------------------------------------------------------------------*/
291 * The value of the NAME 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 pool [i] To use POOL.
298 * @return The value of the NAME attribute is returned. NULL is
299 * returned when not is.
302 qs_get_name_attr(Doc *doc, Node *tag, apr_pool_t *pool)
305 for (attr = qs_get_attr(doc,tag);
307 attr = qs_get_next_attr(doc,attr)) {
308 char *name = qs_get_attr_name(doc,attr);
309 char *value = qs_get_attr_value(doc,attr);
310 if (STRCASEEQ('n','N',"name",name)) {
311 return apr_pstrdup(pool, (value ? value : ""));
319 * The value of the SIZE attribute is acquired.
321 * @param doc [i] The pointer to the Doc structure at the output
322 * destination is specified.
323 * @param tag [i] The tag node to want to acquire the SIZE attribute
325 * @param pool [i] To use POOL.
326 * @return The value of the SIZE attribute is returned. NULL is
327 * returned when not is.
330 qs_get_size_attr(Doc *doc, Node *tag, apr_pool_t *pool)
333 for (attr = qs_get_attr(doc,tag);
335 attr = qs_get_next_attr(doc,attr)) {
336 char *name = qs_get_attr_name(doc,attr);
337 char *value = qs_get_attr_value(doc,attr);
338 if (STRCASEEQ('s','S',"size",name)) {
339 return apr_pstrdup(pool, (value ? value : ""));
347 * The value of the ACCESSKEY attribute is acquired.
349 * @param doc [i] The pointer to the Doc structure at the output
350 * destination is specified.
351 * @param tag [i] The tag node to want to acquire the ACCESSKEY attribute
353 * @param pool [i] To use POOL.
354 * @return The value of the ACCESSKEY attribute is returned. NULL is
355 * returned when not is.
358 qs_get_accesskey_attr(Doc *doc, Node *tag, apr_pool_t *pool)
361 for (attr = qs_get_attr(doc,tag);
363 attr = qs_get_next_attr(doc,attr)) {
364 char *name = qs_get_attr_name(doc,attr);
365 char *value = qs_get_attr_value(doc,attr);
366 if (STRCASEEQ('a','A',"accesskey",name)) {
367 return apr_pstrdup(pool, value);
375 * The value of the ISTYLE attribute is acquired.
377 * @param doc [i] The pointer to the Doc structure at the output
378 * destination is specified.
379 * @param tag [i] The tag node to want to acquire the ISTYLE attribute
381 * @param pool [i] To use POOL.
382 * @return The value of the ISTYLE attribute is returned. NULL is
383 * returned when not is.
386 qs_get_istyle_attr(Doc *doc, Node *tag, apr_pool_t *pool)
389 for (attr = qs_get_attr(doc,tag);
391 attr = qs_get_next_attr(doc,attr)) {
392 char *name = qs_get_attr_name(doc,attr);
393 char *value = qs_get_attr_value(doc,attr);
394 if (STRCASEEQ('i','I',"istyle",name)) {
395 return apr_pstrdup(pool, value);
403 * The value of the MAXLENGTH attribute is acquired from the tag node of the
406 * @param doc [i] The pointer to the Doc structure at the output
407 * destination is specified.
408 * @param tag [i] The tag node to want to acquire the MAXLENGTH attribute
410 * @param pool [i] To use POOL.
411 * @return The value of the MAXLENGTH attribute is returned. NULL is
412 * returned when not is.
415 qs_get_maxlength_attr(Doc *doc, Node *tag, apr_pool_t *pool)
418 for (attr = qs_get_attr(doc,tag);
420 attr = qs_get_next_attr(doc,attr)) {
421 char *name = qs_get_attr_name(doc,attr);
422 char *value = qs_get_attr_value(doc,attr);
423 if (STRCASEEQ('m','M',"maxlength",name)) {
424 return apr_pstrdup(pool, value);
432 * It is scanned whether the CHECKBOX tag of the object is CHECKED.
434 * @param doc [i] The pointer to the Doc structure at the output
435 * destination is specified.
436 * @param tag [i] The tag node to want to acquire the CHECKBOX attribute
438 * @param pool [i] To use POOL.
439 * @return 1 is returned when it is CHECKED and, additionally, 0 is returned.
442 <<<<<<< HEAD:src/chxj_tag_util.c
443 qs_is_checked_checkbox_attr(Doc* doc, Node* tag, request_rec* UNUSED(r))
445 qs_is_checked_checkbox_attr(Doc *doc, Node *tag, apr_pool_t *UNUSED(pool))
446 >>>>>>> * updated new trunk.:src/chxj_tag_util.c
449 for (attr = qs_get_attr(doc,tag);
451 attr = qs_get_next_attr(doc,attr)) {
452 char *name = qs_get_attr_name(doc,attr);
453 if (STRCASEEQ('c','C',"checked",name)) {
462 chxj_chxjif_is_mine(device_table *spec, Doc *doc, Node *tag)
464 request_rec *r = doc->r;
467 for (attr = qs_get_attr(doc,tag);
469 attr = qs_get_next_attr(doc,attr)) {
470 char *name = qs_get_attr_name(doc,attr);
471 char *value = qs_get_attr_value(doc,attr);
472 if ((*name == 'l' || *name == 'L') && strcasecmp(name, "lang") == 0) {
474 DBG(r, "lang found [%s] spec [%d]", value, spec->html_spec_type);
476 if (STRCASEEQ('x','X',"xhtml",value)) {
477 if (spec->html_spec_type == CHXJ_SPEC_XHtml_Mobile_1_0) {
478 /* Yes , it is mine */
482 else if (STRCASEEQ('h','H',"hdml",value)) {
483 if (spec->html_spec_type == CHXJ_SPEC_Hdml) {
484 /* Yes , it is mine */
488 else if (STRCASEEQ('j','J',"jhtml",value)) {
489 if (spec->html_spec_type == CHXJ_SPEC_Jhtml) {
490 /* Yes , it is mine */
494 else if (STRCASEEQ('j','J',"jxhtml",value)) {
495 if (spec->html_spec_type == CHXJ_SPEC_Jxhtml) {
496 /* Yes , it is mine */
500 else if (STRCASEEQ('c','C',"chtml",value)) {
501 switch (spec->html_spec_type) {
502 case CHXJ_SPEC_Chtml_1_0:
503 case CHXJ_SPEC_Chtml_2_0:
504 case CHXJ_SPEC_Chtml_3_0:
505 case CHXJ_SPEC_Chtml_4_0:
506 case CHXJ_SPEC_Chtml_5_0:
512 else if (STRCASEEQ('c','C',"cxhtml",value)) {
513 switch (spec->html_spec_type) {
514 case CHXJ_SPEC_Chtml_6_0:
515 case CHXJ_SPEC_Chtml_7_0:
524 /* No, it is not mine. */
530 * The value of the DESTLANG attribute is acquired from the tag node of the
533 * @param doc [i] The pointer to the Doc structure at the output
534 * destination is specified.
535 * @param tag [i] The tag node to want to acquire the DESTLANG attribute
537 * @param pool [i] To use POOL.
538 * @return The value of the DESTLANG attribute is returned. NULL is
539 * returned when not is.
542 qs_get_destlang_attr(Doc *doc, Node *tag, apr_pool_t *pool)
545 for (attr = qs_get_attr(doc,tag);
547 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);
550 if (STRCASEEQ('d','D',"destlang",name)) {
551 return apr_pstrdup(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 pool [i] To use POOL.
566 * @return The value of the PARSE attribute is returned. NULL is returned when
570 qs_get_parse_attr(Doc *doc, Node *tag, apr_pool_t *pool)
573 /*--------------------------------------------------------------------------*/
574 /* The object tag node is scanned. */
575 /*--------------------------------------------------------------------------*/
576 for (attr = qs_get_attr(doc,tag);
578 attr = qs_get_next_attr(doc,attr)) {
579 char *name = qs_get_attr_name(doc,attr);
580 char *value = qs_get_attr_value(doc,attr);
581 if (STRCASEEQ('p','P',"parse",name)) {
582 /*----------------------------------------------------------------------*/
583 /* The VALUE attribute was found. */
584 /*----------------------------------------------------------------------*/
585 return apr_pstrdup(pool, value);
589 /*--------------------------------------------------------------------------*/
591 /*--------------------------------------------------------------------------*/