1 /*************************************************************************** 2 begin : Mon Aug 11 2008 3 copyright : (C) 2008 by Martin Preuss 4 email : martin@libchipcard.de 5 6 *************************************************************************** 7 * * 8 * This library is free software; you can redistribute it and/or * 9 * modify it under the terms of the GNU Lesser General Public * 10 * License as published by the Free Software Foundation; either * 11 * version 2.1 of the License, or (at your option) any later version. * 12 * * 13 * This library is distributed in the hope that it will be useful, * 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 16 * Lesser General Public License for more details. * 17 * * 18 * You should have received a copy of the GNU Lesser General Public * 19 * License along with this library; if not, write to the Free Software * 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * 21 * MA 02111-1307 USA * 22 * * 23 ***************************************************************************/ 24 25 26 #ifndef GWENHYWFAR_CONFIGMGR_H 27 #define GWENHYWFAR_CONFIGMGR_H 28 29 #include <gwenhywfar/inherit.h> 30 31 #ifdef __cplusplus 32 extern "C" { 33 #endif 34 35 36 typedef struct GWEN_CONFIGMGR GWEN_CONFIGMGR; 37 GWEN_INHERIT_FUNCTION_LIB_DEFS(GWEN_CONFIGMGR, GWENHYWFAR_API) 38 39 #define GWEN_CONFIGMGR_PLUGIN_NAME "configmgr" 40 #define GWEN_CONFIGMGR_FOLDER "configmgr" 41 42 43 #include <gwenhywfar/db.h> 44 #include <gwenhywfar/stringlist.h> 45 46 47 48 /** 49 * Creates a GWEN_CONFIGMGR object. The given URL is inspected for the protocol part 50 * which is used to lookup the plugin responsible. 51 * A generic file based configuration manager might have the URL 52 * "dir://home/martin/testconfig" which means that all files of the configuration 53 * manager reside below the folder "/home/martin/testconfig". 54 * Other plugins might have another URL scheme, however, the protocol part always 55 * specifies the plugin (in this case "dir"). 56 */ 57 GWENHYWFAR_API 58 GWEN_CONFIGMGR *GWEN_ConfigMgr_Factory(const char *url); 59 60 GWENHYWFAR_API 61 void GWEN_ConfigMgr_free(GWEN_CONFIGMGR *mgr); 62 63 GWENHYWFAR_API 64 int GWEN_ConfigMgr_GetGroup(GWEN_CONFIGMGR *mgr, 65 const char *groupName, 66 const char *subGroupName, 67 GWEN_DB_NODE **pDb); 68 69 GWENHYWFAR_API 70 int GWEN_ConfigMgr_SetGroup(GWEN_CONFIGMGR *mgr, 71 const char *groupName, 72 const char *subGroupName, 73 GWEN_DB_NODE *db); 74 75 GWENHYWFAR_API 76 int GWEN_ConfigMgr_HasGroup(GWEN_CONFIGMGR *mgr, 77 const char *groupName, 78 const char *subGroupName); 79 80 GWENHYWFAR_API 81 int GWEN_ConfigMgr_LockGroup(GWEN_CONFIGMGR *mgr, 82 const char *groupName, 83 const char *subGroupName); 84 85 GWENHYWFAR_API 86 int GWEN_ConfigMgr_UnlockGroup(GWEN_CONFIGMGR *mgr, 87 const char *groupName, 88 const char *subGroupName); 89 90 GWENHYWFAR_API 91 int GWEN_ConfigMgr_GetUniqueId(GWEN_CONFIGMGR *mgr, 92 const char *groupName, 93 char *buffer, 94 uint32_t bufferLen); 95 96 /** 97 * Create an id which is unique inside the given group derived from 98 * the given id. 99 * @return 0 if okay, error code otherwise 100 * @param mgr pointer to config mgr object 101 * @param groupName name of the group within the id is unique 102 * @param doCheck if !=0 the derived unique id MUST NOT exist 103 * @param buffer buffer to receive the generated unique id 104 * @param bufferLen size of the buffer pointed to by "buffer" above 105 */ 106 GWENHYWFAR_API 107 int GWEN_ConfigMgr_MkUniqueIdFromId(GWEN_CONFIGMGR *mgr, 108 const char *groupName, 109 uint32_t uid, 110 int doCheck, 111 char *buffer, 112 uint32_t bufferLen); 113 114 GWENHYWFAR_API 115 int GWEN_ConfigMgr_DeleteGroup(GWEN_CONFIGMGR *mgr, 116 const char *groupName, 117 const char *subGroupName); 118 119 120 GWENHYWFAR_API 121 int GWEN_ConfigMgr_ListGroups(GWEN_CONFIGMGR *mgr, 122 GWEN_STRINGLIST *sl); 123 124 GWENHYWFAR_API 125 int GWEN_ConfigMgr_ListSubGroups(GWEN_CONFIGMGR *mgr, 126 const char *groupName, 127 GWEN_STRINGLIST *sl); 128 129 130 #ifdef __cplusplus 131 } 132 #endif 133 134 135 #endif 136 137