00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00033 #ifndef __GS_IMP_H__
00034 #define __GS_IMP_H__
00035
00036 #ifdef __cplusplus
00037 extern "C" {
00038 #endif
00039
00040 #include <pthread.h>
00041 #include <assert.h>
00042 #include <stdlib.h>
00043 #include <string.h>
00044 #include <unistd.h>
00045 #include <sys/types.h>
00046 #include <glib.h>
00047
00048 #include "hiker/global_settings.h"
00049
00050 #include "hiker/ipc.h"
00051 #include "proc_id.h"
00052
00053 #define ALP_STATUS_GLOBAL_SETTINGS_BUSY ((alp_status_t) ALP_CLASS_GLOBAL_SETTINGS | 0x40000000)
00054
00055 struct _AlpGlobalSettingsEntryIterator
00056 {
00057 GList *entries;
00058 GList *current;
00059 char *base_path;
00060 } ;
00061
00062 #if 0
00063 struct _Callback
00064 {
00065 AlpGlobalSettingsContext *context;
00066
00067 int exact_key;
00068 GString *key;
00069 int id;
00070 };
00071 #endif
00072
00073
00074
00075 #define CHECK_ARG(arg)\
00076 if ((arg) == NULL)\
00077 {\
00078 ALP_TM(T(ALP_CLASS_GLOBAL_SETTINGS, "zero " #arg " pointer supplied"));\
00079 return ALP_STATUS_GLOBAL_SETTINGS_ARGUMENT_INVALID ;\
00080 }
00081
00082
00083 #define CHECK_ARG_VOID_RETURN(arg)\
00084 if ((arg) == NULL)\
00085 {\
00086 ALP_TM(T(ALP_CLASS_GLOBAL_SETTINGS, "zero " #arg " pointer supplied"));\
00087 return ;\
00088 }
00089
00090 #define CHECK_CONTEXT\
00091 CHECK_ARG(context)
00092
00093 #define CHECK_ITERATOR\
00094 CHECK_ARG(iterator)
00095
00096 #define CHECK_TYPE(v, t)\
00097 if ((v)->type != (t))\
00098 {\
00099 ALP_TM(T(ALP_CLASS_GLOBAL_SETTINGS, "incorrect value type"));\
00100 return ALP_STATUS_GLOBAL_SETTINGS_INCORRECT_TYPE ;\
00101 }
00102
00103
00104
00105 void free_glist(GList *list);
00106 void free_gslist(GSList *list);
00107 void gstring_copy(GString **gs, const gchar *src);
00108 void global_settings_value_clean(AlpGlobalSettingsValue *value);
00109 void global_settings_entry_clean(AlpGlobalSettingsEntry *entry);
00110 void global_settings_value_copy(const AlpGlobalSettingsValue *src, AlpGlobalSettingsValue *des);
00111 void global_settings_value_list_to_GSList(const AlpGlobalSettingsValue *value, GSList **list);
00112 void global_settings_list_copy(const GList *src, GList **dst);
00113 AlpGlobalSettingsValue * global_settings_value_duplicate(const AlpGlobalSettingsValue *src);
00114 AlpGlobalSettingsEntry *alp_global_settings_entry_alloc(void);
00115 void alp_global_settings_entry_free(AlpGlobalSettingsEntry *e);
00116 AlpGlobalSettingsValue *alp_global_settings_value_alloc(void);
00117 void alp_global_settings_value_free(AlpGlobalSettingsValue *v);
00118 void alp_global_settings_entry_iterator_free(AlpGlobalSettingsEntryIterator *);
00119
00120 const char * gs_type_to_string(AlpGlobalSettingsValueType t);
00121 const char *gs_bool_to_string(gboolean b);
00122
00123 int gs_pack_value(AlpMessage* msg, const AlpGlobalSettingsValue *v);
00124 int gs_unpack_value(AlpMessage* msg, AlpGlobalSettingsValue *v);
00125 void gs_start_pack(AlpMessage** msg, ALP_GLOBAL_SETTINGS_RPC_PROCS);
00126 int gs_end_pack(AlpMessage* msg);
00127 int gs_svr_pack_entry_iterator(AlpMessage* msg, const AlpGlobalSettingsEntryIterator * iterator);
00128 int gs_svr_unpack_entry_iterator(AlpMessage* msg, AlpGlobalSettingsEntryIterator * iterator);
00129
00130 int is_dir(const char *path);
00131 void normalize_path(char *path);
00132 int form_absolute_path(const char *cwd, const char *key, char result[PATH_MAX]);
00133
00134 const char *status_to_string(int status);
00135
00136 #ifdef __cplusplus
00137 }
00138 #endif
00139
00140 #endif