[Fwd: LDAP backend]



Sorry for repeat,
sent direct to Colm, not list ... netscape is a pain at times.
--- Begin Message ---
Colm Smyth wrote:

> >From: monkeyiq dingoblue net au
> > ...
> >
> >    I am having trouble using gconf_value_new_pair_from_string().
>
> This isn't a reliable function for constructing a pair; the
> functions in backends/val-encode.c are intended for just
> this purpose.

I now use these, in serialize.c,
/**
 * Takes a GConfValue and creates a single string representation of it
 *
 * See also ___external_serialize_value_from_string()
 *
 * Caller must free return value.
 *
 */
char *
___external_serialize_value_to_string (GConfValue * val) {
 gchar* ret  = NULL;
 gchar* tmp  = NULL;
 size_t zz  = 0;

 gconf_log( GCL_DEBUG, "___external_serialize_value_to_string. called ");

 tmp = bdb_serialize_value (val, &zz);
 gconf_log( GCL_DEBUG, "___external_serialize_value_to_string.");
 gconf_log( GCL_DEBUG, "___external_serialize_value_to_string. string:
%s",tmp);
 ret = g_strdup(tmp);
 return ret;
}

/**
 * Creates a GConfValue from a single string representation of it what
was
 * obtained using ___external_serialize_value_to_string()
 *
 * See also ___external_serialize_value_to_string()
 *
 * Caller must free return value.
 *
 */
GConfValue *
___external_serialize_value_from_string (const char *srz)
{
 return bdb_restore_value (srz);
}

Oddly, my LDAP code to IO a pair works fine, but if I use the bdb_* stuff

I get a segv in ___external_serialize_value_to_string() something about
malloc(). I can send a bt if you are interested, I can't see that
___external_serialize_value_to_string() is complex enough to be the
problem.

> They're currently without documentation and
> could have better names;

Thus my wrappers, and it makes it simple to change it when the marshaling
code
if moved.

> I plan to create and check-in
> some changes, which will include some improvements
> that should make the val-encode API's easier to use for
> serializing and de-serializing GConfValue's in other
> backends.

I have taken the liberty of doing something like that based on my
___external() functions. Basically I allow the user to decide if
they want to marshal each datatype. I have made yet another vtable
driven function to dispatch this
void
serialize_from_gconf_value(
 GError** err,
 const gchar* key,
 GConfValue* value,
 serialize_as_t sat,
 gpointer user_data,
 serialize_from_gconf_value_vtable* vtab)

and

GConfValue*
deserialize_to_gconf_value(
 GError** err,
 const gchar* key,
 serialize_as_t sat,
 gpointer user_data,
 deserialize_to_gconf_value_vtable* vtab
 )

these are in serialize.c, the code will be posted today.
Note that these two functions don't require each function in vtab,
the basically just demux based on "sat" if the user wants to save
each type as marshaled. The last case uses your bdb_*() to save
a marshaled version.

> If you look at bdb*.c, you can see where the
> current main API's are used (bdb_serialize_value,
> bdb_restore_value and _gconf_check_free); these will
> become _gconf_serialize_value, _gconf_restore_value and
> _gconf_free_serialized_value respectively.

I hope to maybe add my functions to this list,
gconf-backend-serialize.c maybe.



--- End Message ---


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