[Cherokee-commits] [4151] cherokee/trunk/cherokee: Adds a new helper function: cherokee_dwriter_lang_to_type().
SVN at cherokee-project.com
SVN at cherokee-project.com
Fri Jan 22 12:28:24 CET 2010
Revision: 4151
http://svn.cherokee-project.com/changeset/4151
Author: alo
Date: 2010-01-22 12:28:24 +0100 (Fri, 22 Jan 2010)
Log Message:
-----------
Adds a new helper function: cherokee_dwriter_lang_to_type(). The lang
string to lang type should be perform by this class as well.
Modified Paths:
--------------
cherokee/trunk/cherokee/dwriter.c
cherokee/trunk/cherokee/dwriter.h
cherokee/trunk/cherokee/handler_dbslayer.c
Modified: cherokee/trunk/cherokee/dwriter.c
===================================================================
--- cherokee/trunk/cherokee/dwriter.c 2010-01-22 10:18:04 UTC (rev 4150)
+++ cherokee/trunk/cherokee/dwriter.c 2010-01-22 11:28:24 UTC (rev 4151)
@@ -423,3 +423,31 @@
ADD_NEW_LINE;
return ret_ok;
}
+
+
+ret_t
+cherokee_dwriter_lang_to_type (cherokee_buffer_t *buf,
+ cherokee_dwriter_lang_t *lang)
+{
+ if (equal_buf_str (buf, "json")) {
+ *lang = dwriter_json;
+ return ret_ok;
+ }
+
+ if (equal_buf_str (buf, "python")) {
+ *lang = dwriter_python;
+ return ret_ok;
+ }
+
+ if (equal_buf_str (buf, "php")) {
+ *lang = dwriter_php;
+ return ret_ok;
+ }
+
+ if (equal_buf_str (buf, "ruby")) {
+ props->lang = dwriter_ruby;
+ return ret_ok;
+ }
+
+ return ret_not_found;
+}
Modified: cherokee/trunk/cherokee/dwriter.h
===================================================================
--- cherokee/trunk/cherokee/dwriter.h 2010-01-22 10:18:04 UTC (rev 4150)
+++ cherokee/trunk/cherokee/dwriter.h 2010-01-22 11:28:24 UTC (rev 4151)
@@ -81,6 +81,9 @@
ret_t cherokee_dwriter_list_open (cherokee_dwriter_t *w);
ret_t cherokee_dwriter_list_close (cherokee_dwriter_t *w);
+/* Helpers */
+ret_t cherokee_dwriter_lang_to_type (cherokee_buffer_t *buf, cherokee_dwriter_lang_t *lang);
+
CHEROKEE_END_DECLS
#endif /* CHEROKEE_DATA_WRITER_H */
Modified: cherokee/trunk/cherokee/handler_dbslayer.c
===================================================================
--- cherokee/trunk/cherokee/handler_dbslayer.c 2010-01-22 10:18:04 UTC (rev 4150)
+++ cherokee/trunk/cherokee/handler_dbslayer.c 2010-01-22 11:28:24 UTC (rev 4151)
@@ -544,16 +544,8 @@
} else if (equal_buf_str (&subconf->key, "lang")) {
- if (equal_buf_str (&subconf->val, "json")) {
- props->lang = dwriter_json;
- } else if (equal_buf_str (&subconf->val, "python")) {
- props->lang = dwriter_python;
- } else if (equal_buf_str (&subconf->val, "php")) {
- props->lang = dwriter_php;
- } else if (equal_buf_str (&subconf->val, "ruby")) {
- props->lang = dwriter_ruby;
-
- } else {
+ ret = cherokee_dwriter_lang_to_type (&subconf->val, &props->lang);
+ if (ret != ret_ok) {
LOG_CRITICAL (CHEROKEE_ERROR_HANDLER_DBSLAYER_LANG, subconf->val.buf);
return ret_error;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.octality.com/pipermail/cherokee-commits/attachments/20100122/137c2744/attachment.htm
More information about the Cherokee-commits
mailing list