#!/bin/bash
-PID=`ps ax | grep $1 | grep -v grep | awk ' { print $1 }'`
-gdb --pid $PID --symbols=$2
+PID=`ps ax | grep $1 | awk '{ print $1 }'`
+su -c "gdb --pid $PID --symbols=$2"
ret = TRUE;
- for (i == 0; i < priv->ar_elems->len; i++)
+ for (i = 0; i < priv->ar_elems->len; i++)
{
ZakCgiFormElement *element = (ZakCgiFormElement *)g_ptr_array_index (priv->ar_elems, i);
if (!ZAK_CGI_IS_FORM_ELEMENT_STRING (element))
if (!zak_cgi_form_element_is_valid (element))
{
ret = FALSE;
- break;
}
}
}
gchar *id;
gchar *validation_regex;
GHashTable *ht_attrs;
+ GPtrArray *pa_filters;
GValue *value;
GHashTable *ht_label_attrs;
};
priv->validation_regex = NULL;
priv->ht_attrs = NULL;
+ priv->pa_filters = NULL;
priv->value = NULL;
priv->ht_label_attrs = NULL;
}
return ret;
}
+/**
+ * zak_cgi_form_element_add_filter:
+ * @element:
+ * @filter:
+ *
+ */
+void
+zak_cgi_form_element_add_filter (ZakCgiFormElement *element, ZakCgiFormElementIFilter *filter)
+{
+ ZakCgiFormElementPrivate *priv;
+
+ priv = ZAK_CGI_FORM_ELEMENT_GET_PRIVATE (element);
+
+ if (priv->pa_filters == NULL)
+ {
+ priv->pa_filters = g_ptr_array_new ();
+ }
+
+ g_ptr_array_add (priv->pa_filters, filter);
+}
+
+/**
+ * zak_cgi_form_element_filter:
+ * @element:
+ *
+ */
+void
+zak_cgi_form_element_filter (ZakCgiFormElement *element)
+{
+ guint i;
+
+ ZakCgiFormElementPrivate *priv;
+
+ priv = ZAK_CGI_FORM_ELEMENT_GET_PRIVATE (element);
+
+ if (priv->pa_filters == NULL)
+ {
+ return;
+ }
+
+ for (i = 0; i < priv->pa_filters->len; i++)
+ {
+ GValue *val;
+
+ val = zak_cgi_form_element_ifilter_filter ((ZakCgiFormElementIFilter *)g_ptr_array_index (priv->pa_filters, i),
+ zak_cgi_form_element_get_value (element));
+ zak_cgi_form_element_set_value (element, val);
+ }
+}
+
/**
* zak_cgi_form_element_set_value:
* @element:
if (ZAK_CGI_IS_FORM_ELEMENT (element) && ZAK_CGI_FORM_ELEMENT_GET_CLASS (element)->is_valid != NULL)
{
+ zak_cgi_form_element_filter (element);
ret = ZAK_CGI_FORM_ELEMENT_GET_CLASS (element)->is_valid (element);
}
#include <glib-object.h>
#include "main.h"
+#include "formelementifilter.h"
G_BEGIN_DECLS
void zak_cgi_form_element_set_validation_regex (ZakCgiFormElement *element, const gchar *validation_regex);
gchar *zak_cgi_form_element_get_validation_regex (ZakCgiFormElement *element);
+void zak_cgi_form_element_add_filter (ZakCgiFormElement *element, ZakCgiFormElementIFilter *filter);
+void zak_cgi_form_element_filter (ZakCgiFormElement *element);
+
void zak_cgi_form_element_set_value (ZakCgiFormElement *element, GValue *value);
GValue *zak_cgi_form_element_get_value (ZakCgiFormElement *element);
static void zak_cgi_form_element_filter_trim_dispose (GObject *gobject);
static void zak_cgi_form_element_filter_trim_finalize (GObject *gobject);
-static gchar *zak_cgi_form_element_filter_trim_filter (ZakCgiFormElementFilterTrim *filter_trim, const gchar *value);
+static GValue *zak_cgi_form_element_filter_trim_filter (ZakCgiFormElementIFilter *filter_trim, GValue *value);
struct _ZakCgiFormElementFilterTrim
{
ZakCgiFormElementFilterTrimPrivate *priv = ZAK_CGI_FORM_ELEMENT_FILTER_TRIM_GET_PRIVATE (zak_cgi_form_element);
}
+/**
+ * zak_cgi_form_element_filter_trim_new:
+ *
+ * Returns: the newly created #ZakCgiFormElementFilterTrim object.
+ */
+ZakCgiFormElementFilterTrim
+*zak_cgi_form_element_filter_trim_new ()
+{
+ ZakCgiFormElementFilterTrim *zak_cgi_form_element_filter_trim;
+
+ zak_cgi_form_element_filter_trim = ZAK_CGI_FORM_ELEMENT_FILTER_TRIM (g_object_new (zak_cgi_form_element_filter_trim_get_type (), NULL));
+
+ return zak_cgi_form_element_filter_trim;
+}
+
/* PRIVATE */
static void
zak_cgi_form_element_filter_trim_set_property (GObject *object,
parent_class->finalize (gobject);
}
-static gchar
-*zak_cgi_form_element_filter_trim_filter (ZakCgiFormElementFilterTrim *filter_trim,
- const gchar *value)
+static GValue
+*zak_cgi_form_element_filter_trim_filter (ZakCgiFormElementIFilter *filter_trim,
+ GValue *value)
{
- gchar *ret;
+ GValue *ret;
+ gchar *_value;
g_return_val_if_fail (value != NULL, g_strdup (""));
- ret = g_strdup (value);
- g_strstrip (ret);
+ _value = g_strdup (g_value_get_string (value));
+
+ ret = g_new0 (GValue, 1);
+ g_value_init (ret, G_TYPE_STRING);
+ g_value_set_string (ret, g_strdup (g_strstrip (_value)));
- return ret;;
+ return ret;
}
G_BEGIN_DECLS
-/*
- * Type declaration.
- */
#define ZAK_CGI_TYPE_FORM_ELEMENT_FILTER_TRIM zak_cgi_form_element_filter_trim_get_type ()
G_DECLARE_FINAL_TYPE (ZakCgiFormElementFilterTrim, zak_cgi_form_element_filter_trim, ZAK_CGI, FORM_ELEMENT_FILTER_TRIM, GObject)
-/*
- * Method definitions.
- */
ZakCgiFormElementFilterTrim *zak_cgi_form_element_filter_trim_new (void);
/* add properties and signals to the interface here */
}
-gchar
-*zak_cgi_form_element_ifilter_filter (ZakCgiFormElementIFilter *self, const gchar *value)
+GValue
+*zak_cgi_form_element_ifilter_filter (ZakCgiFormElementIFilter *self, GValue *value)
{
g_return_if_fail (ZAK_CGI_IS_FORM_ELEMENT_IFILTER (self));
{
GTypeInterface parent_iface;
- gchar *(*filter) (ZakCgiFormElementIFilter *self, const gchar *value);
+ GValue *(*filter) (ZakCgiFormElementIFilter *self, GValue *value);
};
-gchar *zak_cgi_form_element_ifilter_filter (ZakCgiFormElementIFilter *self, const gchar *value);
+GValue *zak_cgi_form_element_ifilter_filter (ZakCgiFormElementIFilter *self, GValue *value);
G_END_DECLS
|| error != NULL)
{
syslog (LOG_MAKEPRI(LOG_SYSLOG, LOG_DEBUG), "Error on creating regex: %s.",
- error->message != NULL ? error->message : "no details");
+ error != NULL && error->message != NULL ? error->message : "no details");
return FALSE;
}
#include <libzakcgi/main.h>
#include <libzakcgi/form.h>
+#include <libzakcgi/formelement.h>
+#include <libzakcgi/formelementifilter.h>
+#include <libzakcgi/formelementfiltertrim.h>
#include <libzakcgi/session.h>
#include <libzakcgi/tag.h>
#include <libzakcgi/url.h>
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <unistd.h>
+
#include <form.h>
#include <formelement.h>
#include <formelementcheck.h>
#include <formelementtext.h>
#include <formelementtextarea.h>
#include <formelementsubmit.h>
+#include <formelementifilter.h>
+#include <formelementfiltertrim.h>
int
main (int argc, char *argv[])
element = zak_cgi_form_element_text_new ("first", "aaa", NULL);
zak_cgi_form_element_set_label (element, "The Label for first", NULL);
+ zak_cgi_form_element_add_filter (element,
+ ZAK_CGI_FORM_ELEMENT_IFILTER (zak_cgi_form_element_filter_trim_new ()));
zak_cgi_form_add_element (form, element);
element = zak_cgi_form_element_check_new ("chk", NULL, NULL);
if (zak_cgi_main_is_post (zakcgimain))
{
+ sleep(10);
/* validating the form */
zak_cgi_form_bind (form);
if (zak_cgi_form_is_valid (form))