00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include <config.h>
00024 #include "dbus-uuidgen.h"
00025 #include "dbus-internals.h"
00026 #include "dbus-string.h"
00027 #include "dbus-protocol.h"
00028
00029 #ifdef DBUS_WIN
00030 #error "dbus-uuidgen should not be needed on Windows"
00031 #endif
00032
00044 static dbus_bool_t
00045 return_uuid (DBusGUID *uuid,
00046 char **uuid_p,
00047 DBusError *error)
00048 {
00049 if (uuid_p)
00050 {
00051 DBusString encoded;
00052
00053 if (!_dbus_string_init (&encoded))
00054 {
00055 _DBUS_SET_OOM (error);
00056 return FALSE;
00057 }
00058
00059 if (!_dbus_uuid_encode (uuid, &encoded) ||
00060 !_dbus_string_steal_data (&encoded, uuid_p))
00061 {
00062 _DBUS_SET_OOM (error);
00063 _dbus_string_free (&encoded);
00064 return FALSE;
00065 }
00066 _dbus_string_free (&encoded);
00067 }
00068 return TRUE;
00069 }
00070
00082 dbus_bool_t
00083 dbus_internal_do_not_use_get_uuid (const char *filename,
00084 char **uuid_p,
00085 dbus_bool_t create_if_not_found,
00086 DBusError *error)
00087 {
00088 DBusGUID uuid;
00089
00090 if (filename)
00091 {
00092 DBusString filename_str;
00093 _dbus_string_init_const (&filename_str, filename);
00094 if (!_dbus_read_uuid_file (&filename_str, &uuid, create_if_not_found, error))
00095 goto error;
00096 }
00097 else
00098 {
00099 if (!_dbus_read_local_machine_uuid (&uuid, create_if_not_found, error))
00100 goto error;
00101 }
00102
00103 if (!return_uuid(&uuid, uuid_p, error))
00104 goto error;
00105
00106 return TRUE;
00107
00108 error:
00109 _DBUS_ASSERT_ERROR_IS_SET (error);
00110 return FALSE;
00111 }
00112
00121 dbus_bool_t
00122 dbus_internal_do_not_use_create_uuid (char **uuid_p)
00123 {
00124 DBusGUID uuid;
00125
00126 _dbus_generate_uuid (&uuid);
00127 return return_uuid (&uuid, uuid_p, NULL);
00128 }
00129