Skip to content

Commit

Permalink
Merge pull request #1843 from rrthomas/master
Browse files Browse the repository at this point in the history
Switch to libossp-uuid, to get UUIDs on Windows
  • Loading branch information
rrthomas committed Oct 24, 2014
2 parents 6df34b6 + 06234fb commit df64614
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 67 deletions.
18 changes: 7 additions & 11 deletions collab/zmq_kvmsg.c
Expand Up @@ -51,10 +51,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// kvmsg class - key-value message class for example applications

#include "zmq_kvmsg.h"
#if !defined(__MINGW32__)
#include <uuid/uuid.h>
#endif
#include "zlist.h"

#include <glib.h>
#include <inttypes.h>
Expand Down Expand Up @@ -456,7 +452,7 @@ kvmsg_uuid (kvmsg_t *self)
{
assert (self);
if (self->present [FRAME_UUID]
&& zmq_msg_size (&self->frame [FRAME_UUID]) == sizeof (uuid_t))
&& zmq_msg_size (&self->frame [FRAME_UUID]) == 16)
return (byte *) zmq_msg_data (&self->frame [FRAME_UUID]);
else
return NULL;
Expand All @@ -470,15 +466,15 @@ kvmsg_set_uuid (kvmsg_t *self)
{
assert (self);
zmq_msg_t *msg = &self->frame [FRAME_UUID];
#if !defined(__MINGW32__)
uuid_t uuid;
uuid_generate (uuid);
zuuid_t *uuid = zuuid_new ();
size_t sz = zuuid_size (uuid);
unsigned char *uuid_buf = NULL;
if (self->present [FRAME_UUID])
zmq_msg_close (msg);
zmq_msg_init_size (msg, sizeof (uuid));
memcpy (zmq_msg_data (msg), uuid, sizeof (uuid));
zmq_msg_init_size (msg, sz);
memcpy (zmq_msg_data (msg), zuuid_data (uuid), sz);
zuuid_destroy (&uuid);
self->present [FRAME_UUID] = 1;
#endif
}


Expand Down
5 changes: 0 additions & 5 deletions configure.ac
Expand Up @@ -283,11 +283,6 @@ FONTFORGE_ARG_ENABLE([tile-path],
[enable a 'tile path' command (a variant of 'expand stroke')])],
[FONTFORGE_CONFIG_TILEPATH])

AC_ARG_ENABLE([windows-cross-compile],
[AS_HELP_STRING([--enable-windows-cross-compile],
[enable cross compile for windows extra support])],
[WINDOWS_CROSS_COMPILE=yes])

#--------------------------------------------------------------------------
# Theme pixmap ICON selection.
# Go with tango by default. Retain older 2012 theme for those who like it.
Expand Down
3 changes: 2 additions & 1 deletion fontforge/collabclientpriv.h
Expand Up @@ -57,7 +57,7 @@ extern int DEBUG_SHOW_SFD_CHUNKS; // defined in collabclient.c


#define beacon_announce_protocol_sz 20
#define beacon_announce_uuid_sz 40
#define beacon_announce_uuid_sz 33
#define beacon_announce_username_sz 50
#define beacon_announce_machinename_sz 50
#define beacon_announce_ip_sz 20
Expand All @@ -74,6 +74,7 @@ extern int DEBUG_SHOW_SFD_CHUNKS; // defined in collabclient.c
#include "inc/gnetwork.h"
#include "splinefont.h"

#include "czmq.h"


typedef struct {
Expand Down
8 changes: 4 additions & 4 deletions fontforgeexe/fontview.c
Expand Up @@ -26,6 +26,10 @@
*/
#include <fontforge-config.h>

#include "inc/gnetwork.h"
#include "collabclientui.h"
#include "collabclientpriv.h"

#include "fontforgeui.h"
#include "groups.h"
#include "psfont.h"
Expand All @@ -41,10 +45,6 @@
#include <math.h>
#include <unistd.h>

#include "inc/gnetwork.h"
#include "collabclientui.h"
#include "collabclientpriv.h"

#include "gutils/unicodelibinfo.h"
#include "sfundo.h"

Expand Down
1 change: 1 addition & 0 deletions gutils/Makefile.am
Expand Up @@ -48,6 +48,7 @@ libgutils_la_CPPFLAGS = "-I$(top_builddir)/inc" "-I$(top_srcdir)/inc" \
libgutils_la_LIBADD = $(MY_LIBS) $(top_builddir)/Unicode/libgunicode.la $(top_builddir)/lib/libgnu.la
if LIBZMQ
libgutils_la_LIBADD += $(LIBZMQ_LIBS)
libgutils_la_CFLAGS += $(LIBZMQ_CFLAGS)
endif

libgutils_la_LDFLAGS = $(MY_CFLAGS) -version-info $(LIBGUTILS_VERSION) \
Expand Down
25 changes: 10 additions & 15 deletions gutils/gnetwork.c
Expand Up @@ -29,6 +29,10 @@
#include "inc/gnetwork.h"
#include "inc/ustring.h"

#ifdef BUILD_COLLAB
#include "czmq.h"
#endif

#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
Expand All @@ -45,13 +49,6 @@ extern int h_errno;

#include <arpa/inet.h>

#ifdef BUILD_COLLAB
#if !defined(__MINGW32__)
#include <uuid/uuid.h>
#endif
#endif


char* ff_gethostname( char* outstring, int outstring_sz )
{
char hostname[PATH_MAX+1];
Expand Down Expand Up @@ -119,18 +116,16 @@ char* HostPortUnpack( char* packed, int* port, int port_default )


//
// target must be at least 1b4e28ba-2fa1-11d2-883f-0016d3cca427 + null in length.
// target must be at least 32 bytes + NUL in length.
//
char* ff_uuid_generate( char* target )
{
strcpy( target, "" );

#ifdef BUILD_COLLAB
#if !defined(__MINGW32__)
uuid_t uuid;
uuid_generate (uuid);
uuid_unparse_lower( uuid, target );
#endif
zuuid_t *uuid = zuuid_new ();
strcpy (target, zuuid_str (uuid));
zuuid_destroy (&uuid);
#else
strcpy( target, "" );
#endif // collab guard.

return target;
Expand Down
7 changes: 3 additions & 4 deletions inc/gnetwork.h
Expand Up @@ -60,17 +60,16 @@ extern char* HostPortUnpack( char* packed, int* port, int port_default );
* generate a new uuid and stringify it into the target area provided
* after the call target should contain something like
* 1b4e28ba-2fa1-11d2-883f-0016d3cca427
* with the trailing null. Before the call target needs to be at least
* strlen(1b4e28ba-2fa1-11d2-883f-0016d3cca427) + 1 bytes long.
* 40 bytes is a good length for target.
* with the trailing NUL. Before the call target needs to be at least
* UUID_LEN_STR + 1 bytes long.
* the 'target' is also the return value.
*/
char* ff_uuid_generate( char* target );

/**
* This test might be improved in the future.
* You pass a string which might have the form of a UUID (or be "\0 whatever") or
* just be a null pointer, and the function returns true of the uuid string
* just be a null pointer, and the function returns true if the uuid string
* you passed in conforms to being a uuid.
*/
extern int ff_uuid_isValid( char* uuid );
Expand Down
25 changes: 0 additions & 25 deletions m4/fontforge_arg_with.m4
Expand Up @@ -392,21 +392,6 @@ dnl ---------------------------
AC_DEFUN([FONTFORGE_WARN_PKG_FALLBACK],
[AC_MSG_WARN([No pkg-config file was found for $1, but the library is present and we will try to use it.])])

AC_DEFUN([CHECK_LIBUUID],
[
PKG_CHECK_MODULES([LIBUUID], [uuid >= 1.41.2], [LIBUUID_FOUND=yes], [LIBUUID_FOUND=no])
if test "$LIBUUID_FOUND" = "no" ; then
PKG_CHECK_MODULES([LIBUUID], [uuid], [LIBUUID_FOUND=yes], [LIBUUID_FOUND=no])
if test "$LIBUUID_FOUND" = "no" ; then
AC_MSG_ERROR([libuuid development files required])
else
LIBUUID_CFLAGS+=" -I$(pkg-config --variable=includedir uuid)/uuid "
fi
fi
AC_SUBST([LIBUUID_CFLAGS])
AC_SUBST([LIBUUID_LIBS])
])

dnl FONTFORGE_ARG_WITH_ZEROMQ
dnl -------------------------
AC_DEFUN([FONTFORGE_ARG_WITH_ZEROMQ],
Expand All @@ -416,14 +401,4 @@ FONTFORGE_ARG_WITH([libzmq],
[ libczmq >= 2.2.0 libzmq >= 4.0.4 ],
[FONTFORGE_WARN_PKG_NOT_FOUND([LIBZMQ])],
[_NO_LIBZMQ], [NO_LIBZMQ=1])
if test "x$i_do_have_libzmq" = xyes; then
if test "x${WINDOWS_CROSS_COMPILE}" = x; then
AC_MSG_WARN([Using zeromq enables collab, which needs libuuid, so I'm checking for that now...])
CHECK_LIBUUID
fi
fi
LIBZMQ_CFLAGS+=" $LIBUUID_CFLAGS"
LIBZMQ_LIBS+=" $LIBUUID_LIBS"
])
2 changes: 1 addition & 1 deletion travis-scripts/before_install_osx.sh
@@ -1,6 +1,6 @@
#!/bin/bash

type -all brew
type -a brew

. ./travis-scripts/common.sh
set -ev
Expand Down
1 change: 0 additions & 1 deletion travis-scripts/fontforge.rb
Expand Up @@ -55,7 +55,6 @@ class Fontforge < Formula
depends_on 'glib'
depends_on 'pango'
depends_on 'cairo'
depends_on 'ossp-uuid'
depends_on 'zeromq'
depends_on 'czmq'
depends_on 'dylibbundler'
Expand Down

0 comments on commit df64614

Please sign in to comment.