[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r37182 - in gnunet: . po src src/my
From: |
gnunet |
Subject: |
[GNUnet-SVN] r37182 - in gnunet: . po src src/my |
Date: |
Thu, 19 May 2016 12:05:51 +0200 |
Author: grothoff
Date: 2016-05-19 12:05:51 +0200 (Thu, 19 May 2016)
New Revision: 37182
Added:
gnunet/src/my/
gnunet/src/my/Makefile.am
gnunet/src/my/my.c
gnunet/src/my/my_query_helper.c
Modified:
gnunet/configure.ac
gnunet/po/POTFILES.in
gnunet/src/Makefile.am
Log:
starting libgnunetmy
Modified: gnunet/configure.ac
===================================================================
--- gnunet/configure.ac 2016-05-17 11:38:09 UTC (rev 37181)
+++ gnunet/configure.ac 2016-05-19 10:05:51 UTC (rev 37182)
@@ -1560,6 +1560,7 @@
src/hostlist/Makefile
src/multicast/Makefile
src/multicast/multicast.conf
+src/my/Makefile
src/mysql/Makefile
src/namecache/Makefile
src/namecache/namecache.conf
Modified: gnunet/po/POTFILES.in
===================================================================
--- gnunet/po/POTFILES.in 2016-05-17 11:38:09 UTC (rev 37181)
+++ gnunet/po/POTFILES.in 2016-05-19 10:05:51 UTC (rev 37182)
@@ -225,6 +225,7 @@
src/multicast/gnunet-multicast.c
src/multicast/gnunet-service-multicast.c
src/multicast/multicast_api.c
+src/my/my.c
src/mysql/mysql.c
src/namecache/gnunet-namecache.c
src/namecache/gnunet-service-namecache.c
Modified: gnunet/src/Makefile.am
===================================================================
--- gnunet/src/Makefile.am 2016-05-17 11:38:09 UTC (rev 37181)
+++ gnunet/src/Makefile.am 2016-05-19 10:05:51 UTC (rev 37182)
@@ -45,7 +45,7 @@
endif
if HAVE_MYSQL
- MYSQL_DIR = mysql
+ MYSQL_DIR = mysql my
endif
if HAVE_POSTGRESQL
Added: gnunet/src/my/Makefile.am
===================================================================
--- gnunet/src/my/Makefile.am (rev 0)
+++ gnunet/src/my/Makefile.am 2016-05-19 10:05:51 UTC (rev 37182)
@@ -0,0 +1,24 @@
+# This Makefile.am is in the public domain
+AM_CPPFLAGS = -I$(top_srcdir)/src/include
+
+if MINGW
+ WINFLAGS = -Wl,--no-undefined -Wl,--export-all-symbols
+endif
+
+if USE_COVERAGE
+ AM_CFLAGS = --coverage
+endif
+
+if HAVE_MYSQL
+lib_LTLIBRARIES = libgnunetmy.la
+endif
+
+libgnunetmy_la_SOURCES = \
+ my.c \
+ my_query_helper.c
+libgnunetmy_la_LIBADD = $(MYSQL_LDFLAGS) -lmysqlclient \
+ $(top_builddir)/src/mysql/libgnunetmysql.la \
+ $(top_builddir)/src/util/libgnunetutil.la
+libgnunetmy_la_LDFLAGS = \
+ $(GN_LIB_LDFLAGS) \
+ -version-info 0:0:0
Added: gnunet/src/my/my.c
===================================================================
--- gnunet/src/my/my.c (rev 0)
+++ gnunet/src/my/my.c 2016-05-19 10:05:51 UTC (rev 37182)
@@ -0,0 +1,94 @@
+/*
+ This file is part of GNUnet
+ Copyright (C) 2016 GNUnet e.V.
+
+ GNUnet is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 3, or (at your
+ option) any later version.
+
+ GNUnet 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
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNUnet; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+/**
+ * @file my/my.c
+ * @brief library to help with access to a MySQL database
+ * @author Christian Grothoff
+ */
+#include "platform.h"
+#include <mysql/mysql.h>
+#include "gnunet_my_lib.h"
+
+
+
+/**
+ * Run a prepared SELECT statement.
+ *
+ * @param mc mysql context
+ * @param sh handle to SELECT statment
+ * @param params parameters to the statement
+ * @return
+ */
+int
+GNUNET_MY_exec_prepared (struct GNUNET_MYSQL_Context *mc,
+ struct GNUNET_MYSQL_StatementHandle *sh,
+ const struct GNUNET_MY_QueryParam *params)
+{
+ const struct GNUNET_MY_QueryParam *p;
+ unsigned int num;
+ unsigned int i;
+ MYSQL_STMT *stmt;
+
+ num = 0;
+ for (i=0;NULL != params[i].conv;i++)
+ num += params[i].num_params;
+ {
+ MYSQL_BIND qbind[num];
+ unsigned int off;
+
+ memset(qbind, 0, sizeof(qbind));
+ off = 0;
+ for (i=0;NULL != (p = ¶ms[i])->conv;i++)
+ {
+ if (GNUNET_OK !=
+ p->conv (p->conv_cls,
+ p,
+ &qbind[off]))
+ {
+ return GNUNET_SYSERR;
+ }
+ off += p->num_params;
+ }
+ stmt = GNUNET_MYSQL_statement_get_stmt (mc, sh);
+ if (mysql_stmt_bind_param (stmt,
+ qbind))
+ {
+ GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "mysql",
+ _("`%s' failed at %s:%d with error: %s\n"),
+ "mysql_stmt_bind_param", __FILE__, __LINE__,
+ mysql_stmt_error (stmt));
+ GNUNET_MYSQL_statements_invalidate (mc);
+ return GNUNET_SYSERR;
+ }
+ }
+ if (mysql_stmt_execute (stmt))
+ {
+ GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "mysql",
+ _("`%s' failed at %s:%d with error: %s\n"),
+ "mysql_stmt_execute", __FILE__, __LINE__,
+ mysql_stmt_error (stmt));
+ GNUNET_MYSQL_statements_invalidate (mc);
+ return GNUNET_SYSERR;
+ }
+ return GNUNET_OK;
+}
+
+
+/* end of my.c */
Added: gnunet/src/my/my_query_helper.c
===================================================================
--- gnunet/src/my/my_query_helper.c (rev 0)
+++ gnunet/src/my/my_query_helper.c 2016-05-19 10:05:51 UTC (rev 37182)
@@ -0,0 +1,73 @@
+/*
+ This file is part of GNUnet
+ Copyright (C) 2016 GNUnet e.V.
+
+ GNUnet is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 3, or (at your
+ option) any later version.
+
+ GNUnet 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
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNUnet; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+/**
+ * @file my/my_query_helper.c
+ * @brief library to help with access to a MySQL database
+ * @author Christian Grothoff
+ */
+#include "platform.h"
+#include <mysql/mysql.h>
+#include "gnunet_my_lib.h"
+
+
+/**
+ * Function called to convert input argument into SQL parameters.
+ *
+ * @param cls closure
+ * @param pq data about the query
+ * @param qbind array of parameters to initialize
+ * @return -1 on error
+ */
+static int
+pq_conv_fixed_size (void *cls,
+ const struct GNUNET_MY_QueryParam *qp,
+ MYSQL_BIND *qbind)
+{
+ GNUNET_assert (1 == qp->num_params);
+ qbind->buffer = (void *) qp->data;
+ qbind->buffer_length = qp->data_len;
+ qbind->length = (unsigned long *) &qp->data_len;
+ return 0;
+}
+
+
+/**
+ * Generate query parameter for a buffer @a ptr of
+ * @a ptr_size bytes.
+ *
+ * @param ptr pointer to the query parameter to pass
+ * @oaran ptr_size number of bytes in @a ptr
+ */
+struct GNUNET_MY_QueryParam
+GNUNET_MY_query_param_fixed_size (const void *ptr,
+ size_t ptr_size)
+{
+ struct GNUNET_MY_QueryParam qp = {
+ &pq_conv_fixed_size,
+ NULL,
+ 1,
+ ptr,
+ (unsigned long) ptr_size
+ };
+ return qp;
+}
+
+
+/* end of my_query_helper.c */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r37182 - in gnunet: . po src src/my,
gnunet <=