gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r13767 - in gnunet/src: include monkey


From: gnunet
Subject: [GNUnet-SVN] r13767 - in gnunet/src: include monkey
Date: Mon, 22 Nov 2010 21:48:49 +0100

Author: safey
Date: 2010-11-22 21:48:49 +0100 (Mon, 22 Nov 2010)
New Revision: 13767

Added:
   gnunet/src/include/gnunet_monkey_edb.h
   gnunet/src/monkey/edb_api.c
Modified:
   gnunet/src/include/Makefile.am
   gnunet/src/monkey/Makefile.am
Log:
Monkey Expression Database API

Modified: gnunet/src/include/Makefile.am
===================================================================
--- gnunet/src/include/Makefile.am      2010-11-22 20:37:55 UTC (rev 13766)
+++ gnunet/src/include/Makefile.am      2010-11-22 20:48:49 UTC (rev 13767)
@@ -62,4 +62,5 @@
   gnunet_transport_service.h \
   gnunet_transport_plugin.h \
   gnunet_upnp_service.h \
-  gnunet_util_lib.h
+  gnunet_util_lib.h \
+  gnunet_monkey_edb.h

Added: gnunet/src/include/gnunet_monkey_edb.h
===================================================================
--- gnunet/src/include/gnunet_monkey_edb.h                              (rev 0)
+++ gnunet/src/include/gnunet_monkey_edb.h      2010-11-22 20:48:49 UTC (rev 
13767)
@@ -0,0 +1,104 @@
+/*
+      This file is part of GNUnet
+      (C) 2009, 2010 Christian Grothoff (and other contributing authors)
+
+      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., 59 Temple Place - Suite 330,
+      Boston, MA 02111-1307, USA.
+ */
+
+/**
+ * @file include/gnunet_monkey_edb.h
+ * @brief Monkey API for accessing the Expression Database (edb)
+ */
+
+#ifndef GNUNET_MONKEY_EDB_H
+#define GNUNET_MONKEY_EDB_H
+
+#ifdef __cplusplus
+extern "C"
+{
+#if 0                           /* keep Emacsens' auto-indent happy */
+}
+#endif
+#endif
+
+
+struct GNUNET_MONKEY_EDB_Context;
+
+/**
+ * Establish a connection to the Expression Database
+ *
+ * @param db_file_name path the Expression Database file
+ * @return context to use for Accessing the Expression Database, NULL on error
+ */
+struct GNUNET_MONKEY_EDB_Context *GNUNET_MONKEY_EDB_connect (const char
+                                                            *db_file_name);
+
+
+/**
+ * Disconnect from Database, and cleanup resources
+ *
+ * @param cfg configuration to use (used to know the path of the .db file).
+ * @param service service that *this* process is implementing/providing, can 
be NULL
+ * @return GNUNET_OK on success, GNUNET_NO on failure
+ */
+int GNUNET_MONKEY_EDB_disconnect (struct GNUNET_MONKEY_EDB_Context *context);
+
+
+typedef int (*GNUNET_MONKEY_ExpressionIterator)(void *cls, const char 
*expression, int begin_line);
+
+
+/**
+ * Update the context with a list of expressions. 
+ * The list is the initializations of sub-expressions 
+ * of the expression pointed to by start_line_no and end_line_no
+ * For example, consider the following code snippet:
+ * {
+ *   struct Something whole; // line no.1 
+ *   struct SomethingElse part; // line no.2
+ *   whole.part = ∂ // line no.3
+ *   whole.part->member = 1; // line no.4
+ * }
+ * If the expression supplied to the function is that of line no.4 
"whole.part->member = 1;"
+ * The returned list of expressions will be: whole.part = part (line no.3), 
+ * struct SomethingElse part (line no.2), and struct Something whole (line 
no.1),
+ * which are the initialization expressions of the building components of the 
expression in question
+ * 
+ * @param context the returned expessions will be available in it. 
+ * expression_list_head, and expression_list_tail must be null, 
+ * otherwise GNUNET_NO will be returned 
+ * @param file_name path to the file in which the expression in question exists
+ * @param start_line_no expression beginning line
+ * @param end_line_no expression end line
+ * @param iter callback function, iterator for expressions returned from the 
Database
+ * @param iter_cls closure for the expression iterator
+ * @return GNUNET_OK success, GNUNET_NO failure
+ */
+int
+GNUNET_MONKEY_EDB_get_expressions (struct GNUNET_MONKEY_EDB_Context *context,
+                                  const char *file_name, int start_line_no,
+                                  int end_line_no,
+                                  GNUNET_MONKEY_ExpressionIterator iter, void 
*iter_cls);
+
+
+
+#if 0                           /* keep Emacsens' auto-indent happy */
+{
+#endif
+#ifdef __cplusplus
+}
+#endif
+
+#endif
\ No newline at end of file

Modified: gnunet/src/monkey/Makefile.am
===================================================================
--- gnunet/src/monkey/Makefile.am       2010-11-22 20:37:55 UTC (rev 13766)
+++ gnunet/src/monkey/Makefile.am       2010-11-22 20:48:49 UTC (rev 13767)
@@ -39,7 +39,8 @@
  gdbmi_thread.c \
  gdbmi_var_obj.c \
  gnunet-monkey.c \
- mail_sender.c
+ mail_sender.c \
+ edb_api.c
 
 gnunet_monkey_LDADD = \
   $(top_builddir)/src/util/libgnunetutil.la \

Added: gnunet/src/monkey/edb_api.c
===================================================================
--- gnunet/src/monkey/edb_api.c                         (rev 0)
+++ gnunet/src/monkey/edb_api.c 2010-11-22 20:48:49 UTC (rev 13767)
@@ -0,0 +1,96 @@
+/*
+     This file is part of GNUnet.
+     (C) 2009, 2010 Christian Grothoff (and other contributing authors)
+
+     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., 59 Temple Place - Suite 330,
+     Boston, MA 02111-1307, USA.
+*/
+
+/**
+ * @file monkey/edb_api.c
+ * @brief Monkey API for accessing the Expression Database (edb)
+ */
+
+#include "platform.h"
+#include "gnunet_common.h"
+#include "gnunet_monkey_edb.h"
+#include <sqlite3.h>
+
+
+/**
+ * Context for Database connection and Expressions
+ */
+struct GNUNET_MONKEY_EDB_Context
+{
+  /**
+   *  Database connection 
+   */
+  sqlite3 *db_handle;
+};
+
+
+/**
+ * Establish a connection to the Expression Database
+ *
+ * @param db_file_name path the Expression Database file
+ * @return context to use for Accessing the Expression Database, NULL on error
+ */
+struct GNUNET_MONKEY_EDB_Context *
+GNUNET_MONKEY_EDB_connect (const char *db_file_name)
+{
+       /* TODO: Implementation */
+       return NULL;
+}
+
+
+/**
+ * Disconnect from Database, and cleanup resources
+ *
+ * @param cfg configuration to use (used to know the path of the .db file).
+ * @param service service that *this* process is implementing/providing, can 
be NULL
+ * @return GNUNET_OK on success, GNUNET_NO on failure
+ */
+int
+GNUNET_MONKEY_EDB_disconnect (struct GNUNET_MONKEY_EDB_Context *context)
+{
+       /* TODO: Implementation */
+       return GNUNET_OK;
+}
+
+
+/**
+ * Update the context with a list of expressions. 
+ * The list is the initializations of sub-expressions 
+ * of the expression pointed to by start_line_no and end_line_no
+ * 
+ * @param context the returned expessions will be available in it. 
+ * expression_list_head, and expression_list_tail must be null, 
+ * otherwise GNUNET_NO will be returned 
+ * @param file_name path to the file in which the expression in question exists
+ * @param start_line_no expression beginning line
+ * @param end_line_no expression end line
+ * @param iter callback function, iterator for expressions returned from the 
Database
+ * @param iter_cls closure for the expression iterator
+ * @return GNUNET_OK success, GNUNET_NO failure
+ */
+int
+GNUNET_MONKEY_EDB_get_expressions (struct GNUNET_MONKEY_EDB_Context *context,
+                                  const char *file_name, int start_line_no,
+                                  int end_line_no,
+                                  GNUNET_MONKEY_ExpressionIterator iter, void 
*iter_cls)
+{
+       /* TODO: Implementation */
+       return GNUNET_OK;
+}




reply via email to

[Prev in Thread] Current Thread [Next in Thread]