mapistore: Move some function declarations from mapistore_common.h to mapistore_backend.h
authorBrad Hards <bradh@openchange.org>
Wed, 16 Feb 2011 05:14:13 +0000 (05:14 +0000)
committerBrad Hards <bradh@openchange.org>
Wed, 16 Feb 2011 05:14:13 +0000 (05:14 +0000)
Most of these require a backend context. mapistore_strip_ns_from_uri() doesn't
require one, but its currently only used from the backends, and that seems
the mostly use.

Also fix / move a bit of API documentation.

mapiproxy/libmapistore/mapistore_backend.c
mapiproxy/libmapistore/mapistore_backend.h
mapiproxy/libmapistore/mapistore_backend_defaults.c
mapiproxy/libmapistore/mapistore_backend_public.c
mapiproxy/libmapistore/mapistore_common.h

index 9e10142552c5c76827a6aab769efc3d2354df873..f4c0579954e3995bc87a51fd8f333d0d1dd428b1 100644 (file)
@@ -51,15 +51,45 @@ static struct mstore_backend {
 
 int                                    num_backends;
 
-
 /**
-   \details Register mapistore backends
-
-   \param backend pointer to the mapistore backend to register
-
-   \return MAPISTORE_SUCCESS on success
+  \brief Register a backend
+  This function registers a backend with mapistore.
+
+  The general approach is to create a mapistore_backend object within the 
+  mapistore_init_backend() entry point, fill in the various structure elements
+  and function pointers, and then call mapistore_backend_register().
+  \code
+  enum MAPISTORE_ERROR mapistore_init_backend(void)
+  {
+    enum MAPISTORE_ERROR       retval;
+    struct mapistore_backend   demo_backend;
+
+    retval = mapistore_backend_init_defaults(&demo_backend);
+    MAPISTORE_RETVAL_IF(retval, retval, NULL);
+
+    demo_backend.name = "demo";
+    demo_backend.description = "this is just a demostration of the mapistore backend API";
+    demo_backend.uri_namespace = "demo://";
+    demo.init = demo_init; // calls demo_init() on startup
+    ... // more function pointers here.
+    
+    mapistore_backend_register(&demo_backend);
+    if (retval != MAPISTORE_SUCCESS) {
+       MSTORE_DEBUG_ERROR(MSTORE_LEVEL_CRITICAL, "Failed to register the '%s' mapistore backend\n", demo_backend.name);
+        return retval;
+    }
+
+    return MAPISTORE_SUCCESS;
+  }
+  \endcode
+
+  \param backend pointer to the mapistore backend to register
+
+  \return MAPISTORE_SUCCESS on success
  */
-_PUBLIC_ extern enum MAPISTORE_ERROR mapistore_backend_register(const struct mapistore_backend *backend)
+_PUBLIC_ enum MAPISTORE_ERROR mapistore_backend_register(const struct mapistore_backend *backend)
 {
        int                             i;
 
index 4f30184e40cee832f7c6c647b69c85d1d4292801..6bf14a76588731c458c46c9fb0dc5b1ba2d37ed2 100644 (file)
@@ -76,42 +76,14 @@ struct mapistore_backend {
 
 __BEGIN_DECLS
 
-/*
-  \brief Register a backend
-  This function registers a backend with mapistore.
-
-  The general approach is to create a mapistore_backend object within the 
-  mapistore_init_backend() entry point, fill in the various structure elements
-  and function pointers, and then call mapistore_backend_register().
-  \code
-  enum MAPISTORE_ERROR mapistore_init_backend(void)
-  {
-    enum MAPISTORE_ERROR       retval;
-    struct mapistore_backend   demo_backend;
-
-    retval = mapistore_backend_init_defaults(&demo_backend);
-    MAPISTORE_RETVAL_IF(retval, retval, NULL);
 
-    demo_backend.name = "demo";
-    demo_backend.description = "this is just a demostration of the mapistore backend API";
-    demo_backend.uri_namespace = "demo://";
-    demo.init = demo_init; // calls demo_init() on startup
-    ... // more function pointers here.
-    
-    mapistore_backend_register(&demo_backend);
-    if (retval != MAPISTORE_SUCCESS) {
-       MSTORE_DEBUG_ERROR(MSTORE_LEVEL_CRITICAL, "Failed to register the '%s' mapistore backend\n", demo_backend.name);
-        return retval;
-    }
-
-    return MAPISTORE_SUCCESS;
-  }
-  \endcode
- */
-extern enum MAPISTORE_ERROR    mapistore_backend_register(const struct mapistore_backend *);
-extern enum MAPISTORE_ERROR    mapistore_backend_init_defaults(struct mapistore_backend *);
+enum MAPISTORE_ERROR   mapistore_backend_register(const struct mapistore_backend *);
+enum MAPISTORE_ERROR   mapistore_backend_init_defaults(struct mapistore_backend *);
+enum MAPISTORE_ERROR   mapistore_strip_ns_from_uri(const char *, char **);
+struct ldb_context     *mapistore_public_ldb_connect(struct mapistore_backend_context *, const char *);
+enum MAPISTORE_ERROR   mapistore_exist(struct mapistore_backend_context *, const char *, const char *);
+enum MAPISTORE_ERROR   mapistore_register_folder(struct mapistore_backend_context *, const char *, const char *, 
+                                                 const char *, uint64_t);
 
 __END_DECLS
 
index 0af564b62be3e5a244a599f2552a469289bff7d2..99c6cead71b8aefe102851b6c4d9c114af3386ea 100644 (file)
@@ -216,8 +216,19 @@ static enum MAPISTORE_ERROR mapistore_op_defaults_db_mkdir(void *private_data, e
        return MAPISTORE_ERR_NOT_IMPLEMENTED;
 }
 
-
-extern enum MAPISTORE_ERROR mapistore_backend_init_defaults(struct mapistore_backend *backend)
+/**
+ \brief Set default implementations for all the backend methods
+ The default implementations just fail (returning MAPISTORE_ERR_NOT_IMPLEMENTED), but
+ that is a lot better than forgetting to implement one and having the backend crash. You should
+ call this function before setting any of your own values.
+ \param backend the backend to set the defaults on
+ \return MAPISTORE_SUCCESS on success, otherwise a MAPISTORE_ERROR value
+*/
+
+enum MAPISTORE_ERROR mapistore_backend_init_defaults(struct mapistore_backend *backend)
 {
        /* Sanity checks */
        MAPISTORE_RETVAL_IF(!backend, MAPISTORE_ERR_INVALID_PARAMETER, NULL);
@@ -250,12 +261,10 @@ extern enum MAPISTORE_ERROR mapistore_backend_init_defaults(struct mapistore_bac
        backend->op_submitmessage = mapistore_op_defaults_submitmessage;
        backend->op_deletemessage = mapistore_op_defaults_deletemessage;
 
-       
        /* Common semantics */
        backend->op_getprops = mapistore_op_defaults_getprops;
        backend->op_setprops = mapistore_op_defaults_setprops;
 
-
        /* MAPIStoreDB/Store semantics */
        backend->op_db_create_uri = mapistore_op_defaults_db_create_uri;
        backend->op_db_provision_namedprops = mapistore_op_defaults_provision_namedprops;
index dc3457ae6e1416088d357e55c5e84eaef0d4756f..c3571e485356cddc956b61f5f075ef6be6f06c0d 100644 (file)
@@ -134,6 +134,7 @@ enum MAPISTORE_ERROR mapistore_strip_ns_from_uri(const char *uri, char **strippe
        return MAPISTORE_SUCCESS;
 }
 
+
 /**
    \details Let backends register a folder and index it within
    mapistore indexing database
index 32d6670ceb76e843bd22799a5f81d7ba9c539f71..fcd919d35506181d5d792d06d9054c3e014fbd4b 100644 (file)
@@ -71,13 +71,6 @@ const char           *mapistore_get_database_path(void);
 const char             *mapistore_get_named_properties_database_path(void);
 const char             *mapistore_get_named_properties_ldif_path(void);
 
-/* definition from mapistore_backend_public.c */
-struct ldb_context     *mapistore_public_ldb_connect(struct mapistore_backend_context *, const char *);
-enum MAPISTORE_ERROR   mapistore_exist(struct mapistore_backend_context *, const char *, const char *);
-enum MAPISTORE_ERROR   mapistore_register_folder(struct mapistore_backend_context *, const char *, const char *, 
-                                                 const char *, uint64_t);
-enum MAPISTORE_ERROR   mapistore_strip_ns_from_uri(const char *, char **);
-
 __END_DECLS
 
 #endif /* __MAPISTORE_COMMON_H */