aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlfcorreia <>2006-07-29 21:12:31 +0000
committerlfcorreia <>2006-07-29 21:12:31 +0000
commitcc5243d78e4d294243d12c36b6770cecd317e5e5 (patch)
tree379933ef4e4d026832cc36d9f8bbb2805bbc9ba1
parent254258d4ec523377baf7b08344eb33ea6438b0ca (diff)
downloadlcd4linux-cc5243d78e4d294243d12c36b6770cecd317e5e5.tar.gz
[lcd4linux @ 2006-07-29 21:12:31 by lfcorreia]
Add UPPERCASE string plugin function
-rw-r--r--plugin.c8
-rw-r--r--plugin_string.c46
2 files changed, 52 insertions, 2 deletions
diff --git a/plugin.c b/plugin.c
index 72d2847..8070b0a 100644
--- a/plugin.c
+++ b/plugin.c
@@ -1,4 +1,4 @@
-/* $Id: plugin.c,v 1.41 2006/04/15 05:22:52 reinelt Exp $
+/* $Id: plugin.c,v 1.42 2006/07/29 21:12:31 lfcorreia Exp $
*
* plugin handler for the Evaluator
*
@@ -23,6 +23,9 @@
*
*
* $Log: plugin.c,v $
+ * Revision 1.42 2006/07/29 21:12:31 lfcorreia
+ * Add UPPERCASE string plugin function
+ *
* Revision 1.41 2006/04/15 05:22:52 reinelt
* mpd plugin from Stefan Kuhne
*
@@ -218,6 +221,8 @@ int plugin_init_math(void);
void plugin_exit_math(void);
int plugin_init_string(void);
void plugin_exit_string(void);
+int plugin_init_strupper(void);
+void plugin_exit_strupper(void);
int plugin_init_test(void);
void plugin_exit_test(void);
int plugin_init_time(void);
@@ -280,6 +285,7 @@ int plugin_init(void)
plugin_init_cfg();
plugin_init_math();
plugin_init_string();
+ plugin_init_strupper();
plugin_init_test();
plugin_init_time();
diff --git a/plugin_string.c b/plugin_string.c
index e1fd0a4..464d9e8 100644
--- a/plugin_string.c
+++ b/plugin_string.c
@@ -1,4 +1,4 @@
-/* $Id: plugin_string.c,v 1.8 2005/05/08 04:32:45 reinelt Exp $
+/* $Id: plugin_string.c,v 1.9 2006/07/29 21:12:31 lfcorreia Exp $
*
* string plugin
*
@@ -23,6 +23,9 @@
*
*
* $Log: plugin_string.c,v $
+ * Revision 1.9 2006/07/29 21:12:31 lfcorreia
+ * Add UPPERCASE string plugin function
+ *
* Revision 1.8 2005/05/08 04:32:45 reinelt
* CodingStyle added and applied
*
@@ -96,3 +99,44 @@ void plugin_exit_string(void)
{
/* empty */
}
+
+/* 'upcase' function (shamelessly stolen from plugin_sample.c)*/
+/* takes one argument, a string */
+/* returns the string in upper case letters */
+
+static void my_upcase(RESULT * result, RESULT * arg1)
+{
+ char *value, *p;
+
+ /* create a local copy of the argument */
+ /* Do *NOT* try to modify the original string! */
+ value = strdup(R2S(arg1));
+
+ /* process the string */
+ for (p = value; *p != '\0'; p++)
+ *p = toupper(*p);
+
+ /* store result */
+ /* when called with R_STRING, it assumes the */
+ /* next parameter to be a pointer to a string */
+ /* 'value' is already a char*, so use 'value', not '&value' */
+ SetResult(&result, R_STRING, value);
+
+ /* free local copy again */
+ /* Note that SetResult() makes its own string copy */
+ free(value);
+}
+
+int plugin_init_strupper(void)
+{
+
+ /* register my UPPERCASE transforming function */
+ AddFunction("strupper", 1, my_upcase);
+
+ return 0;
+}
+
+void plugin_exit_strupper(void)
+{
+ /* empty */
+}