From d57e9a8527d2aafb97e3f52fc9653e4be68fae5c Mon Sep 17 00:00:00 2001 From: Andrea Zagli Date: Sun, 2 Aug 2015 10:00:18 +0200 Subject: [PATCH] Started form implementation. --- src/Makefile.am | 10 +++- src/form.c | 148 ++++++++++++++++++++++++++++++++++++++++++++++ src/form.h | 60 +++++++++++++++++++ src/formelement.c | 146 +++++++++++++++++++++++++++++++++++++++++++++ src/formelement.h | 60 +++++++++++++++++++ src/libzakcgi.h | 1 + 6 files changed, 423 insertions(+), 2 deletions(-) create mode 100644 src/form.c create mode 100644 src/form.h create mode 100644 src/formelement.c create mode 100644 src/formelement.h diff --git a/src/Makefile.am b/src/Makefile.am index 8dcaea6..3f2c79a 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -5,14 +5,20 @@ AM_CPPFLAGS = $(ZAKCGI_CFLAGS) \ lib_LTLIBRARIES = libzakcgi.la -libzakcgi_la_SOURCES = main.c \ +libzakcgi_la_SOURCES = \ + form.c \ + formelement.c \ + main.c \ session.c \ tag.c \ url.c libzakcgi_la_LDFLAGS = -no-undefined -libzakcgi_include_HEADERS = libzakcgi.h \ +libzakcgi_include_HEADERS = \ + libzakcgi.h \ + form.h \ + formelement.h \ main.h \ session.h \ tag.h \ diff --git a/src/form.c b/src/form.c new file mode 100644 index 0000000..0efed69 --- /dev/null +++ b/src/form.c @@ -0,0 +1,148 @@ +/* + * Copyright (C) 2015 Andrea Zagli + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifdef HAVE_CONFIG_H + #include +#endif + +#include + +#include "form.h" + +static void zak_cgi_form_class_init (ZakCgiFormClass *class); +static void zak_cgi_form_init (ZakCgiForm *zak_cgi_form); + +static void zak_cgi_form_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec); +static void zak_cgi_form_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec); + +static void zak_cgi_form_dispose (GObject *gobject); +static void zak_cgi_form_finalize (GObject *gobject); + +#define ZAK_CGI_FORM_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), ZAK_CGI_TYPE_FORM, ZakCgiFormPrivate)) + +typedef struct _ZakCgiFormPrivate ZakCgiFormPrivate; +struct _ZakCgiFormPrivate + { + ZakCgiMain *zakcgimain; + }; + +G_DEFINE_TYPE (ZakCgiForm, zak_cgi_form, G_TYPE_OBJECT) + +static void +zak_cgi_form_class_init (ZakCgiFormClass *class) +{ + GObjectClass *object_class = G_OBJECT_CLASS (class); + + object_class->set_property = zak_cgi_form_set_property; + object_class->get_property = zak_cgi_form_get_property; + object_class->dispose = zak_cgi_form_dispose; + object_class->finalize = zak_cgi_form_finalize; + + g_type_class_add_private (object_class, sizeof (ZakCgiFormPrivate)); +} + +static void +zak_cgi_form_init (ZakCgiForm *zak_cgi_form) +{ + ZakCgiFormPrivate *priv = ZAK_CGI_FORM_GET_PRIVATE (zak_cgi_form); + + priv->zakcgimain = NULL; +} + +/** + * zak_cgi_form_new: + * @zakcgimain: + * + * Returns: the newly created #ZakCgiForm object. + */ +ZakCgiForm +*zak_cgi_form_new (ZakCgiMain *zakcgimain) +{ + ZakCgiForm *zak_cgi_form; + ZakCgiFormPrivate *priv; + + zak_cgi_form = ZAK_CGI_FORM (g_object_new (zak_cgi_form_get_type (), NULL)); + + priv = ZAK_CGI_FORM_GET_PRIVATE (zak_cgi_form); + priv->zakcgimain = zakcgimain; + + return zak_cgi_form; +} + +/* PRIVATE */ +static void +zak_cgi_form_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec) +{ + ZakCgiForm *zak_cgi_form = (ZakCgiForm *)object; + ZakCgiFormPrivate *priv = ZAK_CGI_FORM_GET_PRIVATE (zak_cgi_form); + + switch (property_id) + { + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; + } +} + +static void +zak_cgi_form_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) +{ + ZakCgiForm *zak_cgi_form = (ZakCgiForm *)object; + ZakCgiFormPrivate *priv = ZAK_CGI_FORM_GET_PRIVATE (zak_cgi_form); + + switch (property_id) + { + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; + } +} + +static void +zak_cgi_form_dispose (GObject *gobject) +{ + ZakCgiForm *zak_cgi_form = (ZakCgiForm *)gobject; + ZakCgiFormPrivate *priv = ZAK_CGI_FORM_GET_PRIVATE (zak_cgi_form); + + + GObjectClass *parent_class = g_type_class_peek_parent (G_OBJECT_GET_CLASS (gobject)); + parent_class->dispose (gobject); +} + +static void +zak_cgi_form_finalize (GObject *gobject) +{ + ZakCgiForm *zak_cgi_form = (ZakCgiForm *)gobject; + ZakCgiFormPrivate *priv = ZAK_CGI_FORM_GET_PRIVATE (zak_cgi_form); + + + GObjectClass *parent_class = g_type_class_peek_parent (G_OBJECT_GET_CLASS (gobject)); + parent_class->finalize (gobject); +} diff --git a/src/form.h b/src/form.h new file mode 100644 index 0000000..785ba72 --- /dev/null +++ b/src/form.h @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2015 Andrea Zagli + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef __ZAK_CGI_FORM_H__ +#define __ZAK_CGI_FORM_H__ + + +#include + +#include "main.h" + + +G_BEGIN_DECLS + + +#define ZAK_CGI_TYPE_FORM (zak_cgi_form_get_type ()) +#define ZAK_CGI_FORM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ZAK_CGI_TYPE_FORM, ZakCgiForm)) +#define ZAK_CGI_FORM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ZAK_CGI_TYPE_FORM, ZakCgiFormClass)) +#define ZAK_CGI_IS_FORM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ZAK_CGI_TYPE_FORM)) +#define ZAK_CGI_IS_FORM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ZAK_CGI_TYPE_FORM)) +#define ZAK_CGI_FORM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ZAK_CGI_TYPE_FORM, ZakCgiFormClass)) + +typedef struct _ZakCgiForm ZakCgiForm; +typedef struct _ZakCgiFormClass ZakCgiFormClass; + +struct _ZakCgiForm + { + GObject parent_instance; + }; + +struct _ZakCgiFormClass + { + GObjectClass parent_class; + }; + +GType zak_cgi_form_get_type (void); + + +ZakCgiForm *zak_cgi_form_new (ZakCgiMain *zakcgimain); + + +G_END_DECLS + + +#endif /* __ZAK_CGI_FORM_H__ */ diff --git a/src/formelement.c b/src/formelement.c new file mode 100644 index 0000000..ebbb431 --- /dev/null +++ b/src/formelement.c @@ -0,0 +1,146 @@ +/* + * Copyright (C) 2015 Andrea Zagli + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifdef HAVE_CONFIG_H + #include +#endif + +#include + +#include "formelement.h" + +static void zak_cgi_form_element_class_init (ZakCgiFormElementClass *class); +static void zak_cgi_form_element_init (ZakCgiFormElement *zak_cgi_form_element); + +static void zak_cgi_form_element_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec); +static void zak_cgi_form_element_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec); + +static void zak_cgi_form_element_dispose (GObject *gobject); +static void zak_cgi_form_element_finalize (GObject *gobject); + +#define ZAK_CGI_FORM_ELEMENT_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), ZAK_CGI_TYPE_FORM_ELEMENT, ZakCgiFormElementPrivate)) + +typedef struct _ZakCgiFormElementPrivate ZakCgiFormElementPrivate; +struct _ZakCgiFormElementPrivate + { + }; + +G_DEFINE_TYPE (ZakCgiFormElement, zak_cgi_form_element, G_TYPE_OBJECT) + +static void +zak_cgi_form_element_class_init (ZakCgiFormElementClass *class) +{ + GObjectClass *object_class = G_OBJECT_CLASS (class); + + object_class->set_property = zak_cgi_form_element_set_property; + object_class->get_property = zak_cgi_form_element_get_property; + object_class->dispose = zak_cgi_form_element_dispose; + object_class->finalize = zak_cgi_form_element_finalize; + + g_type_class_add_private (object_class, sizeof (ZakCgiFormElementPrivate)); +} + +static void +zak_cgi_form_element_init (ZakCgiFormElement *zak_cgi_form_element) +{ + ZakCgiFormElementPrivate *priv = ZAK_CGI_FORM_ELEMENT_GET_PRIVATE (zak_cgi_form_element); + + +} + +/** + * zak_cgi_form_element_new: + * + * Returns: the newly created #ZakCgiFormElement object. + */ +ZakCgiFormElement +*zak_cgi_form_element_new (void) +{ + ZakCgiFormElement *zak_cgi_form_element; + ZakCgiFormElementPrivate *priv; + + zak_cgi_form_element = ZAK_CGI_FORM_ELEMENT (g_object_new (zak_cgi_form_element_get_type (), NULL)); + + priv = ZAK_CGI_FORM_ELEMENT_GET_PRIVATE (zak_cgi_form_element); + + return zak_cgi_form_element; +} + +/* PRIVATE */ +static void +zak_cgi_form_element_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec) +{ + ZakCgiFormElement *zak_cgi_form_element = (ZakCgiFormElement *)object; + ZakCgiFormElementPrivate *priv = ZAK_CGI_FORM_ELEMENT_GET_PRIVATE (zak_cgi_form_element); + + switch (property_id) + { + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; + } +} + +static void +zak_cgi_form_element_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) +{ + ZakCgiFormElement *zak_cgi_form_element = (ZakCgiFormElement *)object; + ZakCgiFormElementPrivate *priv = ZAK_CGI_FORM_ELEMENT_GET_PRIVATE (zak_cgi_form_element); + + switch (property_id) + { + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; + } +} + +static void +zak_cgi_form_element_dispose (GObject *gobject) +{ + ZakCgiFormElement *zak_cgi_form_element = (ZakCgiFormElement *)gobject; + ZakCgiFormElementPrivate *priv = ZAK_CGI_FORM_ELEMENT_GET_PRIVATE (zak_cgi_form_element); + + + GObjectClass *parent_class = g_type_class_peek_parent (G_OBJECT_GET_CLASS (gobject)); + parent_class->dispose (gobject); +} + +static void +zak_cgi_form_element_finalize (GObject *gobject) +{ + ZakCgiFormElement *zak_cgi_form_element = (ZakCgiFormElement *)gobject; + ZakCgiFormElementPrivate *priv = ZAK_CGI_FORM_ELEMENT_GET_PRIVATE (zak_cgi_form_element); + + + + GObjectClass *parent_class = g_type_class_peek_parent (G_OBJECT_GET_CLASS (gobject)); + parent_class->finalize (gobject); +} diff --git a/src/formelement.h b/src/formelement.h new file mode 100644 index 0000000..561bec7 --- /dev/null +++ b/src/formelement.h @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2015 Andrea Zagli + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef __ZAK_CGI_FORM_ELEMENT_H__ +#define __ZAK_CGI_FORM_ELEMENT_H__ + + +#include + +#include "main.h" + + +G_BEGIN_DECLS + + +#define ZAK_CGI_TYPE_FORM_ELEMENT (zak_cgi_form_element_get_type ()) +#define ZAK_CGI_FORM_ELEMENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ZAK_CGI_TYPE_FORM_ELEMENT, ZakCgiFormElement)) +#define ZAK_CGI_FORM_ELEMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ZAK_CGI_TYPE_FORM_ELEMENT, ZakCgiFormElementClass)) +#define ZAK_CGI_IS_FORM_ELEMENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ZAK_CGI_TYPE_FORM_ELEMENT)) +#define ZAK_CGI_IS_FORM_ELEMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ZAK_CGI_TYPE_FORM_ELEMENT)) +#define ZAK_CGI_FORM_ELEMENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ZAK_CGI_TYPE_FORM_ELEMENT, ZakCgiFormElementClass)) + +typedef struct _ZakCgiFormElement ZakCgiFormElement; +typedef struct _ZakCgiFormElementClass ZakCgiFormElementClass; + +struct _ZakCgiFormElement + { + GObject parent_instance; + }; + +struct _ZakCgiFormElementClass + { + GObjectClass parent_class; + }; + + +GType zak_cgi_form_element_get_type (void); + +ZakCgiFormElement *zak_cgi_form_element_new (void); + + +G_END_DECLS + + +#endif /* __ZAK_CGI_FORM_ELEMENT_H__ */ diff --git a/src/libzakcgi.h b/src/libzakcgi.h index b33731e..d7d750c 100644 --- a/src/libzakcgi.h +++ b/src/libzakcgi.h @@ -20,6 +20,7 @@ #define __LIBZAKCGI_H__ #include +#include #include #include #include -- 2.49.0