/*----------------------------------------------------------------------------*/
/* prototype declare */
/*----------------------------------------------------------------------------*/
-extern char* qs_get_value_attr(
- Doc* doc,
- Node* tag,
- request_rec* r);
-
-extern char* qs_get_checked_attr(
- Doc* doc,
- Node* tag,
- request_rec* r);
+extern char *qs_get_value_attr(
+ Doc *doc,
+ Node *tag,
+ apr_pool_t *pool);
+
+extern char *qs_get_checked_attr(
+ Doc *doc,
+ Node *tag,
+ request_rec *r);
extern char* qs_get_type_attr(
Doc* doc,
type = qs_get_type_attr(doc, node, r);
name = qs_get_name_attr(doc, node, r);
- value = qs_get_value_attr(doc,node,r);
+ value = qs_get_value_attr(doc,node,doc->buf.pool);
istyle = qs_get_istyle_attr(doc,node,r);
max_length = qs_get_maxlength_attr(doc,node,r);
checked = qs_get_checked_attr(doc,node,r);
/*--------------------------------------------------------------------------*/
type = qs_get_type_attr(doc, node, r);
name = qs_get_name_attr(doc, node, r);
- value = qs_get_value_attr(doc,node,r);
+ value = qs_get_value_attr(doc,node,doc->buf.pool);
istyle = qs_get_istyle_attr(doc,node,r);
max_length = qs_get_maxlength_attr(doc,node,r);
checked = qs_get_checked_attr(doc,node,r);
/*--------------------------------------------------------------------------*/
type = qs_get_type_attr(doc, node, r);
name = qs_get_name_attr(doc, node, r);
- value = qs_get_value_attr(doc,node,r);
+ value = qs_get_value_attr(doc,node,doc->buf.pool);
istyle = qs_get_istyle_attr(doc,node,r);
max_length = qs_get_maxlength_attr(doc,node,r);
checked = qs_get_checked_attr(doc,node,r);
/*--------------------------------------------------------------------------*/
type = qs_get_type_attr(doc, node, r);
name = qs_get_name_attr(doc, node, r);
- value = qs_get_value_attr(doc,node,r);
+ value = qs_get_value_attr(doc,node,doc->buf.pool);
istyle = qs_get_istyle_attr(doc,node,r);
max_length = qs_get_maxlength_attr(doc,node,r);
checked = qs_get_checked_attr(doc,node,r);
/*--------------------------------------------------------------------------*/
type = qs_get_type_attr(doc, node, r);
name = qs_get_name_attr(doc, node, r);
- value = qs_get_value_attr(doc,node,r);
+ value = qs_get_value_attr(doc,node,doc->buf.pool);
istyle = qs_get_istyle_attr(doc,node,r);
max_length = qs_get_maxlength_attr(doc,node,r);
checked = qs_get_checked_attr(doc,node,r);
mlen = qs_get_maxlength_attr (doc, tag, r);
is = qs_get_istyle_attr (doc, tag, r);
- val = qs_get_value_attr (doc, tag, r);
+ val = qs_get_value_attr (doc, tag, doc->buf.pool);
fmt = qs_conv_istyle_to_format(r, is);
DBG(r,"qs_conv_istyle_to_format end");
hdml->var_cnt[hdml->pure_form_cnt]));
mlen = qs_get_maxlength_attr (doc, tag, r);
- val = qs_get_value_attr (doc, tag, r);
+ val = qs_get_value_attr (doc, tag, doc->buf.pool);
/*--------------------------------------------------------------------------*/
/* Default is a figure input. */
/*--------------------------------------------------------------------------*/
/* get name and value attribute */
/*--------------------------------------------------------------------------*/
nm = qs_get_name_attr (doc, tag, r);
- val = qs_get_value_attr (doc, tag, r);
+ val = qs_get_value_attr (doc, tag, doc->buf.pool);
if (nm && val) {
s_output_to_hdml_out(hdml,
/* get name and value attribute */
/*--------------------------------------------------------------------------*/
nm = qs_get_name_attr (doc, tag, r);
- val = qs_get_value_attr (doc, tag, r);
+ val = qs_get_value_attr (doc, tag, doc->buf.pool);
if (val) {
s_output_to_hdml_out(hdml, val);
}
/* get name and value attribute */
/*--------------------------------------------------------------------------*/
nm = qs_get_name_attr (doc, tag, r);
- val = qs_get_value_attr (doc, tag, r);
+ val = qs_get_value_attr (doc, tag, doc->buf.pool);
if (nm && val) {
s_output_to_postdata(hdml,
apr_psprintf(r->pool,
/* get name and value attribute */
/*--------------------------------------------------------------------------*/
nm = qs_get_name_attr (doc, tag, r);
- val = qs_get_value_attr (doc, tag, r);
+ val = qs_get_value_attr (doc, tag, doc->buf.pool);
/*--------------------------------------------------------------------------*/
/* The same name is searched out from the list made beforehand. */
/*--------------------------------------------------------------------------*/
/* The value of the name attribute and the value attribute is acquired */
/* respectively. */
/*--------------------------------------------------------------------------*/
- val = qs_get_value_attr(doc, tag, r);
+ val = qs_get_value_attr(doc, tag, doc->buf.pool);
nm = qs_get_name_attr(doc, tag, r);
if (! val) {
hdml->card_cnt++;
hdml->option_flag = 1;
- val = qs_get_value_attr(doc, node, r);
+ val = qs_get_value_attr(doc, node, doc->buf.pool);
/*--------------------------------------------------------------------------*/
/* The child node of the object tag node acquires the value in assumption */
DBG(r, "found type=radio");
rname = qs_get_name_attr (doc, child, r);
- rvalue = qs_get_value_attr(doc, child, r);
+ rvalue = qs_get_value_attr(doc, child, doc->buf.pool);
if (!rname) {
/*----------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/
type = qs_get_type_attr(doc, node, r);
name = qs_get_name_attr(doc, node, r);
- value = qs_get_value_attr(doc,node,r);
+ value = qs_get_value_attr(doc,node,doc->buf.pool);
istyle = qs_get_istyle_attr(doc,node,r);
max_length = qs_get_maxlength_attr(doc,node,r);
checked = qs_get_checked_attr(doc,node,r);
/*--------------------------------------------------------------------------*/
type = qs_get_type_attr(doc, node, r);
name = qs_get_name_attr(doc, node, r);
- value = qs_get_value_attr(doc,node,r);
+ value = qs_get_value_attr(doc,node, doc->buf.pool);
istyle = qs_get_istyle_attr(doc,node,r);
max_length = qs_get_maxlength_attr(doc,node,r);
checked = qs_get_checked_attr(doc,node,r);
* is returned. NULL is returned when not found.
*/
char *
-qs_get_value_attr(Doc *doc, Node *node, request_rec *r)
+qs_get_value_attr(Doc *doc, Node *node, apr_pool_t *pool)
{
Attr *attr;
/*----------------------------------------------------------------------*/
/* The VALUE attribute was found. */
/*----------------------------------------------------------------------*/
- return apr_pstrdup(r->pool, value);
+ return apr_pstrdup(pool, value);
}
}
/*--------------------------------------------------------------------------*/
/*------------------------------------------------------------------*/
/* SELECTED Value Found */
/*------------------------------------------------------------------*/
- return qs_get_value_attr(doc, child, r);
+ return qs_get_value_attr(doc, child, doc->buf.pool);
}
}
}
/*--------------------------------------------------------------------------*/
type = qs_get_type_attr(doc, node, r);
name = qs_get_name_attr(doc, node, r);
- value = qs_get_value_attr(doc,node,r);
+ value = qs_get_value_attr(doc,node,doc->buf.pool);
istyle = qs_get_istyle_attr(doc,node,r);
max_length = qs_get_maxlength_attr(doc,node,r);
checked = qs_get_checked_attr(doc,node,r);
--- /dev/null
+.SUFFIXES:
+.SUFFIXES: .c.o
+
+TARGET= test_chxj_tag_util
+
+TOP_DIR=../..
+
+INC_DIR=-I$(TOP_DIR)/include \
+ -I/usr/include/apache2 \
+ -I/usr/include/apr-1.0 \
+ -I$(TOP_DIR)/src
+
+all:test
+
+
+
+test: $(TARGET)
+ ./$(TARGET)
+
+$(TARGET): $(TARGET).c
+ gcc -g -o $@ -Wall -lcunit $< $(INC_DIR) -DLINUX=2 -D_REENTRANT -D_GNU_SOURCE -D_LARGEFILE64_SOURCE -lapr-1 -laprutil-1
+
+
+clean:
+ rm -f ./$(TARGET)
--- /dev/null
+#include <CUnit/CUnit.h>
+#include <CUnit/Console.h>
+#include <CUnit/Basic.h>
+#include <stdio.h>
+#define CHXJ_TEST
+#define IMG_NOT_CONVERT_FILENAME
+
+#include "apr.h"
+#include "apr_strings.h"
+#include "chxj_apache.h"
+#include "chxj_str_util.h"
+#include "chxj_str_util.c"
+#include "qs_ignore_sp.c"
+#include "qs_log.c"
+#include "qs_malloc.c"
+#include "qs_parse_string.c"
+#include "qs_parse_attr.c"
+#include "qs_parse_tag.c"
+#include "chxj_tag_util.c"
+#include <iconv.h>
+
+
+/*===========================================================================*/
+/* qs_new_tag(); */
+/*===========================================================================*/
+void test_qs_get_value_attr_001();
+void test_qs_get_value_attr_002();
+void test_qs_get_value_attr_003();
+/* pend */
+
+void test_log_rerror(const char *file, int line, int level, apr_status_t status, const request_rec *r, const char *fmt, ...)
+{
+ va_list ap;
+ fprintf(stderr, "ERROR LOG %s:%d ", file,line);
+ va_start(ap, fmt);
+ vfprintf(stderr, fmt,ap);
+ va_end(ap);
+ fprintf(stderr, "\n");
+}
+void test_log_error(const char *file, int line, int level, apr_status_t status, const request_rec *r, const char *fmt, ...)
+{
+ va_list ap;
+ fprintf(stderr, "ERROR LOG %s:%d ", file,line);
+ va_start(ap, fmt);
+ vfprintf(stderr, fmt,ap);
+ va_end(ap);
+ fprintf(stderr, "\n");
+}
+
+int
+main()
+{
+ CU_pSuite str_util_suite;
+ CU_initialize_registry();
+ str_util_suite = CU_add_suite("test chxj_tag_util.c", NULL, NULL);
+ /*=========================================================================*/
+ /* qs_new_tag() */
+ /*=========================================================================*/
+ CU_add_test(str_util_suite, "qs_get_value_attr() 001", test_qs_get_value_attr_001);
+ CU_add_test(str_util_suite, "qs_get_value_attr() 002", test_qs_get_value_attr_002);
+ CU_add_test(str_util_suite, "qs_get_value_attr() 003", test_qs_get_value_attr_003);
+ /* aend */
+
+ CU_basic_run_tests();
+ CU_cleanup_registry();
+
+ return(0);
+}
+
+
+
+#define APR_INIT \
+ apr_pool_t *p; \
+ Doc doc; \
+ do { \
+ apr_initialize(); \
+ apr_pool_create(&p, NULL); \
+ memset(&doc, 0, sizeof(Doc)); \
+ doc.pool = p; \
+ } \
+ while (0)
+
+#define APR_TERM \
+ do { \
+ apr_terminate(); \
+ } while (0)
+
+#define COOKIE_INIT(X) \
+ do { \
+ X.cookie_id = "test_cookie_id"; \
+ } while (0) \
+
+#define SPEC_INIT(X) \
+ do { \
+ X.html_spec_type = CHXJ_SPEC_Chtml_1_0; \
+ } while (0)
+
+
+
+
+/*===========================================================================*/
+/* qs_get_value_attr() */
+/*===========================================================================*/
+#if 0
+char *
+qs_get_value_attr(Doc *doc, Node *node, request_rec *r)
+#endif
+void test_qs_get_value_attr_001()
+{
+ Node *node;
+ char *ret;
+ APR_INIT;
+
+ node = qs_new_tag(&doc);
+ ret = qs_get_value_attr(&doc,node,p);
+ CU_ASSERT(ret == NULL);
+
+ APR_TERM;
+#undef TEST_STRING
+}
+void test_qs_get_value_attr_002()
+{
+ Node *node;
+ Attr *attr;
+ char *ret;
+ APR_INIT;
+
+ node = qs_new_tag(&doc);
+ attr = qs_new_attr(&doc);
+ attr->name = apr_pstrdup(p, "value");
+ attr->value = apr_pstrdup(p, "atai");
+ qs_add_attr(&doc,node,attr);
+ ret = qs_get_value_attr(&doc,node,p);
+ CU_ASSERT(ret != NULL);
+ CU_ASSERT(strcmp(ret, "atai") == 0);
+
+ APR_TERM;
+#undef TEST_STRING
+}
+void test_qs_get_value_attr_003()
+{
+ Node *node;
+ Attr *attr;
+ char *ret;
+ APR_INIT;
+
+ node = qs_new_tag(&doc);
+ attr = qs_new_attr(&doc);
+ attr->name = apr_pstrdup(p, "value1");
+ attr->value = apr_pstrdup(p, "atai");
+ qs_add_attr(&doc,node,attr);
+ ret = qs_get_value_attr(&doc,node,p);
+ CU_ASSERT(ret == NULL);
+
+ APR_TERM;
+#undef TEST_STRING
+}
+/*
+ * vim:ts=2 et
+ */