Ticket #26122: patch-optout-uuid.diff

File patch-optout-uuid.diff, 1.6 KB (added by louis-francis.ratte-boulianne@…, 14 years ago)

Patch to opt out libuuid

  • configure.ac

    diff --git configure.ac.orig configure.ac
    index e1b213f..9ceed92 100644
    old new PKG_CHECK_MODULES(NICE, nice >= 0.0.11) 
    273273AC_SUBST(NICE_CFLAGS)
    274274AC_SUBST(NICE_LIBS)
    275275
    276 PKG_CHECK_MODULES([UUID], [uuid])
    277 AC_SUBST([UUID_CFLAGS])
    278 AC_SUBST([UUID_LIBS])
     276dnl Check for libuuid
     277PKG_CHECK_MODULES([UUID], [uuid], [HAVE_UUID=yes], [HAVE_UUID=no])
     278if test x"$HAVE_UUID" = xyes; then
     279  AC_SUBST([UUID_CFLAGS])
     280  AC_SUBST([UUID_LIBS])
     281  AC_DEFINE([HAVE_UUID], [1], [Define if libuuid is available])
     282else
     283  AC_MSG_WARN([libuuid not found, falling back to generating random IDs])
     284fi
    279285
    280286dnl Check for MCE, a Maemo service used by Gabble to determine when the device
    281287dnl is idle.
  • src/util.c

    diff --git src/util.c.orig src/util.c
    index 15dc1ae..4ca3743 100644
    old new  
    3636
    3737#include <extensions/extensions.h>
    3838
    39 #include <uuid.h>
     39#ifdef HAVE_UUID
     40# include <uuid.h>
     41#endif
    4042
    4143#define DEBUG_FLAG GABBLE_DEBUG_JID
    4244
    gchar * 
    8486gabble_generate_id (void)
    8587{
    8688  /* generate random UUIDs */
    87   uuid_t uu;
    8889  gchar *str;
    8990
    9091  str = g_new0 (gchar, 37);
    91   uuid_generate_random (uu);
    92   uuid_unparse_lower (uu, str);
    93   return str;
     92
     93#ifdef HAVE_UUID
     94    {
     95      uuid_t uu;
     96
     97      uuid_generate_random (uu);
     98      uuid_unparse_lower (uu, str);
     99    }
     100#else
     101    {
     102      const char *hex = "0123456789abcdef";
     103      int i;
     104
     105      for (i = 0; i < 36; i++)
     106        str[i] =  hex[g_random_int_range (0, 16)];
     107
     108      str[8] = str[13] = str[18] = str[23] = '-';
     109    }
     110#endif
     111
     112   return str;
    94113}
    95114
    96115static void