00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include <config.h>
00025 #include "dbus-misc.h"
00026 #include "dbus-internals.h"
00027 #include "dbus-string.h"
00028
00072 char*
00073 dbus_get_local_machine_id (void)
00074 {
00075 DBusString uuid;
00076 char *s;
00077
00078 s = NULL;
00079
00080 if (!_dbus_string_init (&uuid))
00081 return NULL;
00082
00083 if (!_dbus_get_local_machine_uuid_encoded (&uuid) ||
00084 !_dbus_string_steal_data (&uuid, &s))
00085 {
00086 _dbus_string_free (&uuid);
00087 return NULL;
00088 }
00089 else
00090 {
00091 _dbus_string_free (&uuid);
00092 return s;
00093 }
00094
00095 }
00096
00160 void
00161 dbus_get_version (int *major_version_p,
00162 int *minor_version_p,
00163 int *micro_version_p)
00164 {
00165 if (major_version_p)
00166 *major_version_p = DBUS_MAJOR_VERSION;
00167 if (minor_version_p)
00168 *minor_version_p = DBUS_MINOR_VERSION;
00169 if (micro_version_p)
00170 *micro_version_p = DBUS_MICRO_VERSION;
00171 }
00172
00173
00175
00176 #ifdef DBUS_BUILD_TESTS
00177
00178 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00179
00180 #include "dbus-test.h"
00181 #include <stdlib.h>
00182
00183
00184 dbus_bool_t
00185 _dbus_misc_test (void)
00186 {
00187 int major, minor, micro;
00188 DBusString str;
00189
00190
00191 dbus_get_version (NULL, NULL, NULL);
00192
00193
00194
00195
00196
00197
00198 dbus_get_version (&major, &minor, µ);
00199
00200 _dbus_assert (major == DBUS_MAJOR_VERSION);
00201 _dbus_assert (minor == DBUS_MINOR_VERSION);
00202 _dbus_assert (micro == DBUS_MICRO_VERSION);
00203
00204 #define MAKE_VERSION(x, y, z) (((x) << 16) | ((y) << 8) | (z))
00205
00206
00207 _dbus_assert (MAKE_VERSION (1, 0, 0) > MAKE_VERSION (0, 0, 0));
00208 _dbus_assert (MAKE_VERSION (1, 1, 0) > MAKE_VERSION (1, 0, 0));
00209 _dbus_assert (MAKE_VERSION (1, 1, 1) > MAKE_VERSION (1, 1, 0));
00210
00211 _dbus_assert (MAKE_VERSION (2, 0, 0) > MAKE_VERSION (1, 1, 1));
00212 _dbus_assert (MAKE_VERSION (2, 1, 0) > MAKE_VERSION (1, 1, 1));
00213 _dbus_assert (MAKE_VERSION (2, 1, 1) > MAKE_VERSION (1, 1, 1));
00214
00215
00216 _dbus_assert (MAKE_VERSION (major, minor, micro) == DBUS_VERSION);
00217
00218
00219 _dbus_assert (MAKE_VERSION (major - 1, minor, micro) < DBUS_VERSION);
00220 _dbus_assert (MAKE_VERSION (major, minor - 1, micro) < DBUS_VERSION);
00221 _dbus_assert (MAKE_VERSION (major, minor, micro - 1) < DBUS_VERSION);
00222
00223 _dbus_assert (MAKE_VERSION (major + 1, minor, micro) > DBUS_VERSION);
00224 _dbus_assert (MAKE_VERSION (major, minor + 1, micro) > DBUS_VERSION);
00225 _dbus_assert (MAKE_VERSION (major, minor, micro + 1) > DBUS_VERSION);
00226
00227
00228
00229 if (!_dbus_string_init (&str))
00230 _dbus_assert_not_reached ("no memory");
00231
00232 if (!(_dbus_string_append_int (&str, major) &&
00233 _dbus_string_append_byte (&str, '.') &&
00234 _dbus_string_append_int (&str, minor) &&
00235 _dbus_string_append_byte (&str, '.') &&
00236 _dbus_string_append_int (&str, micro)))
00237 _dbus_assert_not_reached ("no memory");
00238
00239 _dbus_assert (_dbus_string_equal_c_str (&str, DBUS_VERSION_STRING));
00240
00241 _dbus_string_free (&str);
00242
00243 return TRUE;
00244 }
00245
00246 #endif
00247
00248 #endif