source: trunk/third/GConf/gconf/gconf-internals.h @ 18003

Revision 18003, 8.8 KB checked in by rbasch, 22 years ago (diff)
Hacks to support logins to multiple machines by the same user, plus other integration with our environment, and bug fixes: * Move the daemon lock directory to local disk, in /tmp/gconfd-$USER, so a per-machine instance of gconfd can run. * Don't hold a lock on the XML backend; instead, lock the backend only around a sync. * Add gconf_mkdir_private(), a wrapper for creating a private directory (mode 0700), which also sets the ACL in case the directory is in AFS. * Run gconfd under dustbuster; call setsid() in the daemon process, to disassociate it from the calling client. * Try to ping the server after we start it, in case it exited due to a failure to acquire the lock, to avoid greater lossage later. * Add an fsync() after the daemon writes its IOR to the lock file (otherwise, the file appears empty from other machines when it lives in AFS). * Handle a failure to read the IOR from the lock file. * Plug a descriptor leak in fork_exec_with_pipes(). * Fix a buffer overrun in subst_variables() (from the GConf mainline).
Line 
1/* GConf
2 * Copyright (C) 1999, 2000 Red Hat Inc.
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 * Library General Public License for more details.
13 *
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
18 */
19
20#ifndef GCONF_GCONF_INTERNALS_H
21#define GCONF_GCONF_INTERNALS_H
22
23#ifndef GCONF_ENABLE_INTERNALS
24#warning "you are trying to use GConf internal functions outside of GConf. This is a Bad Idea"
25#endif
26
27#ifdef GCONF_ENABLE_INTERNALS
28
29#include <glib.h>
30#include "gconf-error.h"
31#include "gconf-value.h"
32#include "GConf.h"
33
34gchar*       gconf_key_directory  (const gchar* key);
35const gchar* gconf_key_key        (const gchar* key);
36
37/* These file tests are in libgnome, I cut-and-pasted them */
38enum {
39  GCONF_FILE_EXISTS=(1<<0)|(1<<1)|(1<<2), /*any type of file*/
40  GCONF_FILE_ISFILE=1<<0,
41  GCONF_FILE_ISLINK=1<<1,
42  GCONF_FILE_ISDIR=1<<2
43};
44
45gboolean gconf_file_test   (const gchar* filename, int test);
46gboolean gconf_file_exists (const gchar* filename);
47
48GConfValue*  gconf_value_from_corba_value      (const ConfigValue *value);
49ConfigValue* corba_value_from_gconf_value      (GConfValue        *value);
50void         fill_corba_value_from_gconf_value (GConfValue        *value,
51                                                ConfigValue       *dest);
52ConfigValue* invalid_corba_value               (void);
53
54
55gchar* gconf_object_to_string (CORBA_Object obj,
56                               GError **err);
57
58void          fill_corba_schema_from_gconf_schema (GConfSchema        *sc,
59                                                   ConfigSchema       *dest);
60ConfigSchema* corba_schema_from_gconf_schema      (GConfSchema        *sc);
61GConfSchema*  gconf_schema_from_corba_schema      (const ConfigSchema *cs);
62
63const gchar*   gconf_value_type_to_string   (GConfValueType  type);
64GConfValueType gconf_value_type_from_string (const gchar    *str);
65
66
67gchar**       gconf_load_source_path (const gchar* filename, GError** err);
68
69/* shouldn't be used in applications (although implemented in gconf.c) */
70
71void     gconf_shutdown_daemon (GError **err);
72gboolean gconf_ping_daemon     (void);
73gboolean gconf_spawn_daemon    (GError **err);
74
75
76/* Returns 0 on failure (or if the string is "0" of course) */
77gulong       gconf_string_to_gulong (const gchar *str);
78gboolean     gconf_string_to_double (const gchar *str,
79                                     gdouble     *val);
80gchar*       gconf_double_to_string (gdouble      val);
81const gchar* gconf_current_locale   (void);
82
83
84/* Log wrapper; we might want to not use syslog someday */
85typedef enum {
86  GCL_EMERG,
87  GCL_ALERT,
88  GCL_CRIT,
89  GCL_ERR,
90  GCL_WARNING,
91  GCL_NOTICE,
92  GCL_INFO,
93  GCL_DEBUG
94} GConfLogPriority;
95
96void          gconf_log      (GConfLogPriority pri, const gchar* format, ...) G_GNUC_PRINTF (2, 3);
97
98extern gboolean gconf_log_debug_messages;
99
100/* return FALSE and set error if the key is bad */
101gboolean      gconf_key_check(const gchar* key, GError** err);
102
103/*
104 * If these were public they'd be in gconf-value.h
105 */
106
107/* doesn't work on complicated types (only string, int, bool, float) */
108GConfValue* gconf_value_new_from_string      (GConfValueType type,
109                                              const gchar* str,
110                                              GError** err);
111/* for the complicated types */
112GConfValue* gconf_value_new_list_from_string (GConfValueType list_type,
113                                              const gchar* str,
114                                              GError** err);
115GConfValue* gconf_value_new_pair_from_string (GConfValueType car_type,
116                                              GConfValueType cdr_type,
117                                              const gchar* str,
118                                              GError** err);
119
120/* These are a hack to encode values into strings and ship them over CORBA,
121 * necessary for obscure reasons (ORBit doesn't like recursive datatypes yet)
122 */
123
124/* string quoting is only public for the benefit of the test suite */
125
126gchar* gconf_quote_string           (const gchar  *str);
127gchar* gconf_unquote_string         (const gchar  *str,
128                                     const gchar **end,
129                                     GError      **err);
130void   gconf_unquote_string_inplace (gchar        *str,
131                                     gchar       **end,
132                                     GError      **err);
133
134GConfValue* gconf_value_decode (const gchar *encoded);
135gchar*      gconf_value_encode (GConfValue  *val);
136
137/* FIXME is this used? */
138gchar* gconf_quote_percents (const gchar* src);
139
140/*
141 * List/pair conversion stuff
142 */
143
144GConfValue* gconf_value_list_from_primitive_list (GConfValueType  list_type,
145                                                  GSList         *list,
146                                                  GError        **err);
147GConfValue* gconf_value_pair_from_primitive_pair (GConfValueType  car_type,
148                                                  GConfValueType  cdr_type,
149                                                  gconstpointer   address_of_car,
150                                                  gconstpointer   address_of_cdr,
151                                                  GError        **err);
152
153GSList*  gconf_value_list_to_primitive_list_destructive (GConfValue      *val,
154                                                         GConfValueType   list_type,
155                                                         GError         **err);
156gboolean gconf_value_pair_to_primitive_pair_destructive (GConfValue      *val,
157                                                         GConfValueType   car_type,
158                                                         GConfValueType   cdr_type,
159                                                         gpointer         car_retloc,
160                                                         gpointer         cdr_retloc,
161                                                         GError         **err);
162
163
164void         gconf_set_daemon_mode (gboolean     setting);
165gboolean     gconf_in_daemon_mode  (void);
166void         gconf_set_daemon_ior  (const gchar *ior);
167const gchar* gconf_get_daemon_ior  (void);
168
169/* Returns TRUE if there was an error, frees exception, sets err */
170gboolean gconf_handle_oaf_exception (CORBA_Environment* ev, GError** err);
171
172void gconf_nanosleep (gulong useconds);
173
174typedef struct _GConfLock GConfLock;
175
176GConfLock* gconf_get_lock     (const gchar  *lock_directory,
177                               GError      **err);
178gboolean   gconf_release_lock (GConfLock    *lock,
179                               GError      **err);
180GConfLock* gconf_get_lock_or_current_holder (const gchar  *lock_directory,
181                                             ConfigServer *current_server,
182                                             GError      **err);
183ConfigServer gconf_get_current_lock_holder  (const gchar *lock_directory);
184
185GError*  gconf_error_new  (GConfError en,
186                           const gchar* format, ...) G_GNUC_PRINTF (2, 3);
187
188void     gconf_set_error  (GError** err,
189                           GConfError en,
190                           const gchar* format, ...) G_GNUC_PRINTF (3, 4);
191
192/* merge two errors into a single message */
193GError*  gconf_compose_errors (GError* err1, GError* err2);
194
195CORBA_ORB gconf_orb_get (void);
196
197ConfigServer gconf_activate_server (gboolean  start_if_not_found,
198                                    GError  **error);
199
200char*     gconf_get_lock_dir (void);
201char*     gconf_get_daemon_dir (void);
202
203gboolean gconf_schema_validate (GConfSchema *sc,
204                                GError     **err);
205gboolean gconf_value_validate  (GConfValue *value,
206                                GError    **err);
207
208#define g_utf8_validate gconf_g_utf8_validate
209
210gboolean gconf_g_utf8_validate (const gchar  *str,
211                                gssize        max_len,   
212                                const gchar **end);
213
214int gconf_mkdir_private (const char *path);
215
216#ifdef ENABLE_NLS
217#    include <libintl.h>
218#    include <config.h>
219#    undef _
220#    define _(String) dgettext (GETTEXT_PACKAGE, String)
221#    ifdef gettext_noop
222#        define N_(String) gettext_noop (String)
223#    else
224#        define N_(String) (String)
225#    endif
226#else
227/* Stubs that do something close enough.  */
228#    define textdomain(String) (String)
229#    define bindtextdomain(Domain,Directory) (Domain)
230#    define _(String) (String)
231#    define N_(String) (String)
232#endif
233
234#endif /* GCONF_ENABLE_INTERNALS */
235
236#endif /* GCONF_GCONF_INTERNALS_H */
237
238
Note: See TracBrowser for help on using the repository browser.