Index: configure.in =================================================================== RCS file: /cvs/gnome/beagle/configure.in,v retrieving revision 1.139 diff -u -B -p -r1.139 configure.in --- configure.in 8 Jun 2005 18:52:08 -0000 1.139 +++ configure.in 8 Jun 2005 21:29:45 -0000 @@ -46,6 +46,21 @@ for i in $needed_dlls; do fi done +# check for OS +case "$target" in + *-*-linux*) + os=linux + ;; + *-*-freebsd*) + os=freebsd + ;; + *) + AC_MSG_ERROR([Unrecognised target OS: $target]) + ;; +esac +AM_CONDITIONAL(OS_LINUX, test "x$os" == "xlinux") +AM_CONDITIONAL(OS_FREEBSD, test "x$os" == "xfreebsd") + # check for wsdl AC_PATH_PROG(WSDL, wsdl) @@ -491,6 +506,7 @@ po/Makefile.in ]) echo " + Target OS: ${os} Prefix: ${prefix} GNOME Prefix: ${GNOME_PREFIX} KDE Prefix: ${kde_prefix_print} Index: Util/ExtendedAttribute.cs =================================================================== RCS file: /cvs/gnome/beagle/Util/ExtendedAttribute.cs,v retrieving revision 1.14 diff -u -B -p -r1.14 ExtendedAttribute.cs --- Util/ExtendedAttribute.cs 20 Apr 2005 14:55:42 -0000 1.14 +++ Util/ExtendedAttribute.cs 8 Jun 2005 21:29:46 -0000 @@ -38,7 +38,10 @@ namespace Beagle.Util { // FIXME: Once Mono 1.1/1.2 is required, we should start using the // xattr bindings which are now present in the Mono.Unix.Syscall class. - + // The interface provided via Syscall in future Mono versions will support both + // Linux/FreeBSD attributes transparently. + + // Linux xattrs [DllImport ("libc", SetLastError=true)] static extern int lsetxattr (string path, string name, byte[] value, uint size, int flags); @@ -48,9 +51,25 @@ namespace Beagle.Util { [DllImport ("libc", SetLastError=true)] static extern int lremovexattr (string path, string name); + // FreeBSD extattrs + // Very similar to Linux xattrs, but the namespace is provided as a + // parameter as opposed to a string prefix to the name. + [DllImport ("libc", SetLastError=true)] + static extern int extattr_set_link (string path, int attrnamespace, string attrname, byte[] value, uint size); + + [DllImport ("libc", SetLastError=true)] + static extern int extattr_get_link (string path, int attrnamespace, string attrname, byte[] value, uint size); + + [DllImport ("libc", SetLastError=true)] + static extern int extattr_delete_link (string path, int attrnamespace, string attrname); + private static string AddPrefix (string name) { +#if OS_LINUX return "user.Beagle." + name; +#elif OS_FREEBSD + return "Beagle." + name; +#endif } static Encoding encoding = new UTF8Encoding (); @@ -63,8 +82,12 @@ namespace Beagle.Util { name = AddPrefix (name); byte[] buffer = encoding.GetBytes (value); +#if OS_LINUX int retval = lsetxattr (path, name, buffer, (uint) buffer.Length, 0); - if (retval != 0) +#elif OS_FREEBSD + int retval = extattr_set_link (path, 1, name, buffer, (uint) buffer.Length); +#endif + if (retval == -1) throw new IOException ("Could not set extended attribute on " + path + ": " + Syscall.strerror (Marshal.GetLastWin32Error ())); } @@ -76,11 +99,19 @@ namespace Beagle.Util { name = AddPrefix (name); byte[] buffer = null; +#if OS_LINUX int size = lgetxattr (path, name, buffer, 0); +#elif OS_FREEBSD + int size = extattr_get_link (path, 1, name, buffer, 0); +#endif if (size <= 0) return null; buffer = new byte [size]; +#if OS_LINUX int retval = lgetxattr (path, name, buffer, (uint) size); +#elif OS_FREEBSD + int retval = extattr_get_link (path, 1, name, buffer, (uint) size); +#endif if (retval < 0) throw new IOException ("Could not get extended attribute on " + path + ": " + Syscall.strerror (Marshal.GetLastWin32Error ())); @@ -94,7 +125,11 @@ namespace Beagle.Util { name = AddPrefix (name); +#if OS_LINUX int retval = lremovexattr (path, name); +#elif OS_FREEBSD + int retval = extattr_delete_link (path, 1, name); +#endif if (retval != 0) throw new IOException ("Could not remove extended attribute on " + path + ": " + Syscall.strerror (Marshal.GetLastWin32Error ())); } Index: Util/Makefile.am =================================================================== RCS file: /cvs/gnome/beagle/Util/Makefile.am,v retrieving revision 1.57 diff -u -B -p -r1.57 Makefile.am --- Util/Makefile.am 8 Jun 2005 18:52:09 -0000 1.57 +++ Util/Makefile.am 8 Jun 2005 21:29:46 -0000 @@ -10,6 +10,14 @@ TARGET_CONFIG = $(TARGET).config CSFLAGS = -target:library +if OS_LINUX +CSFLAGS += -define:OS_LINUX +endif + +if OS_FREEBSD +CSFLAGS += -define:OS_FREEBSD +endif + GOOGLE_WSDL = $(srcdir)/GoogleSearch.wsdl GOOGLE_CS = GoogleSearch.cs