r3938 - trunk/sfi



Author: timj
Date: 2006-10-06 17:18:47 -0400 (Fri, 06 Oct 2006)
New Revision: 3938

Added:
   trunk/sfi/sfiwrapper.cc
   trunk/sfi/sfiwrapper.h
Modified:
   trunk/sfi/ChangeLog
   trunk/sfi/sfitypes.h
Log:
Fri Oct  6 23:13:05 2006  Tim Janik  <timj gtk org>

        * sfiwrapper.h, sfiwrapper.cc: C API wrapper around useful
        Birnet utilities.




Modified: trunk/sfi/ChangeLog
===================================================================
--- trunk/sfi/ChangeLog	2006-10-06 16:55:46 UTC (rev 3937)
+++ trunk/sfi/ChangeLog	2006-10-06 21:18:47 UTC (rev 3938)
@@ -1,3 +1,8 @@
+Fri Oct  6 23:13:05 2006  Tim Janik  <timj gtk org>
+
+	* sfiwrapper.h, sfiwrapper.cc: C API wrapper around useful
+	Birnet utilities.
+
 Fri Oct  6 18:53:35 2006  Tim Janik  <timj gtk org>
 
 	* sfimsg.h, sfimsg.c: renamed and moved here from birnet/. 

Modified: trunk/sfi/sfitypes.h
===================================================================
--- trunk/sfi/sfitypes.h	2006-10-06 16:55:46 UTC (rev 3937)
+++ trunk/sfi/sfitypes.h	2006-10-06 21:18:47 UTC (rev 3938)
@@ -19,12 +19,35 @@
 #ifndef __SFI_TYPES_H__
 #define __SFI_TYPES_H__
 
-#include <birnet/birnetthread.h>
 #include <sfi/glib-extra.h>
+#include <birnet/birnetthread.h> /* include glib before birnet for G_LOG_DOMAIN */
 
 G_BEGIN_DECLS
 
+/* --- common type definitions --- */
+typedef unsigned int          uint8       __attribute__ ((__mode__ (__QI__)));
+typedef unsigned int          uint16      __attribute__ ((__mode__ (__HI__)));
+typedef unsigned int          uint32      __attribute__ ((__mode__ (__SI__)));
+typedef unsigned int          uint64      __attribute__ ((__mode__ (__DI__)));
+// provided by Birnet:        uint;
+BIRNET_STATIC_ASSERT (sizeof (uint8)  == 1);
+BIRNET_STATIC_ASSERT (sizeof (uint16) == 2);
+BIRNET_STATIC_ASSERT (sizeof (uint32) == 4);
+BIRNET_STATIC_ASSERT (sizeof (uint64) == 8);
+typedef signed int            int8        __attribute__ ((__mode__ (__QI__)));
+typedef signed int            int16       __attribute__ ((__mode__ (__HI__)));
+typedef signed int            int32       __attribute__ ((__mode__ (__SI__)));
+typedef signed int            int64       __attribute__ ((__mode__ (__DI__)));
+// provided by compiler	      int;
+BIRNET_STATIC_ASSERT (sizeof (int8)  == 1);
+BIRNET_STATIC_ASSERT (sizeof (int16) == 2);
+BIRNET_STATIC_ASSERT (sizeof (int32) == 4);
+BIRNET_STATIC_ASSERT (sizeof (int64) == 8);
+typedef uint32                unichar;
+BIRNET_STATIC_ASSERT (sizeof (unichar) == 4);
 
+
+
 /* --- Sfi typedefs --- */
 
 /* 64 bit types - FIXME: assert in configure script that sizeof (long long) == 8 */

Added: trunk/sfi/sfiwrapper.cc
===================================================================
--- trunk/sfi/sfiwrapper.cc	2006-10-06 16:55:46 UTC (rev 3937)
+++ trunk/sfi/sfiwrapper.cc	2006-10-06 21:18:47 UTC (rev 3938)
@@ -0,0 +1,105 @@
+/* SfiWrapper - Birnet C wrapper
+ * Copyright (C) 2006 Tim Janik
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+#include "sfiwrapper.h"
+#include <birnet/birnet.hh>
+
+/* --- initialization --- */
+void
+sfi_init (int            *argcp,
+          char         ***argvp,
+          const char     *app_name,
+          SfiInitValue    sivalues[])
+{
+  BIRNET_STATIC_ASSERT (sizeof (SfiInitValue) == sizeof (BirnetInitValue));
+  BIRNET_STATIC_ASSERT (offsetof (SfiInitValue, value_name) == offsetof (BirnetInitValue, value_name));
+  BIRNET_STATIC_ASSERT (offsetof (SfiInitValue, value_string) == offsetof (BirnetInitValue, value_string));
+  BIRNET_STATIC_ASSERT (offsetof (SfiInitValue, value_num) == offsetof (BirnetInitValue, value_num));
+  Birnet::birnet_init (argcp, argvp, app_name, (BirnetInitValue*) sivalues);
+}
+
+bool
+sfi_init_value_bool (SfiInitValue *value)
+{
+  return Birnet::init_value_bool ((BirnetInitValue*) value);
+}
+
+double
+sfi_init_value_double (SfiInitValue *value)
+{
+  return Birnet::init_value_double ((BirnetInitValue*) value);
+}
+
+gint64
+sfi_init_value_int (SfiInitValue *value)
+{
+  return Birnet::init_value_int ((BirnetInitValue*) value);
+}
+
+/* --- file testing --- */
+bool
+birnet_file_check (const char *file,
+                   const char *mode)
+{
+  return Birnet::Path::check (file, mode);
+}
+
+bool
+birnet_file_equals (const char *file1,
+                    const char *file2)
+{
+  return Birnet::Path::equals (file1, file2);
+}
+
+/* --- url handling --- */
+void
+sfi_url_show (const char *url)
+{
+  return Birnet::url_show (url);
+}
+
+void
+sfi_url_show_with_cookie (const char *url,
+                          const char *url_title,
+                          const char *cookie)
+{
+  return Birnet::url_show_with_cookie (url, url_title, cookie);
+}
+
+bool
+sfi_url_test_show (const char *url)
+{
+  return Birnet::url_test_show (url);
+}
+
+bool
+sfi_url_test_show_with_cookie (const char *url,
+                               const char *url_title,
+                               const char *cookie)
+{
+  return Birnet::url_test_show_with_cookie (url, url_title, cookie);
+}
+
+/* --- cleanup handlers --- */
+void
+birnet_cleanup_force_handlers (void)
+{
+  return Birnet::cleanup_force_handlers();
+}
+
+/* vim:set ts=8 sts=2 sw=2: */

Added: trunk/sfi/sfiwrapper.h
===================================================================
--- trunk/sfi/sfiwrapper.h	2006-10-06 16:55:46 UTC (rev 3937)
+++ trunk/sfi/sfiwrapper.h	2006-10-06 21:18:47 UTC (rev 3938)
@@ -0,0 +1,68 @@
+/* SfiWrapper - Birnet C wrapper
+ * Copyright (C) 2006 Tim Janik
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+#ifndef __SFI_WRAPPER_H__
+#define __SFI_WRAPPER_H__
+
+#include <sfi/sfitypes.h>
+
+/* sfiwrapper.h is a thin C language wrapper around C++ features
+ * provided by libbirnet.
+ */
+
+BIRNET_EXTERN_C_BEGIN();
+
+/* --- initialization --- */
+typedef struct
+{
+  const char *value_name;       /* value list ends with value_name == NULL */
+  const char *value_string;
+  long double value_num;        /* valid if value_string == NULL */
+} SfiInitValue;
+void    sfi_init        (int            *argcp,
+			 char         ***argvp,
+			 const char     *app_name,
+			 SfiInitValue    sivalues[]);
+bool    sfi_init_value_bool   (SfiInitValue *value);
+double  sfi_init_value_double (SfiInitValue *value);
+gint64  sfi_init_value_int    (SfiInitValue *value);
+
+/* --- file tests --- */
+bool	birnet_file_check (const char *file,
+			   const char *mode);
+bool	birnet_file_equals (const char *file1,
+			    const char *file2);
+
+/* --- url handling --- */
+void sfi_url_show                   	(const char           *url);
+void sfi_url_show_with_cookie       	(const char           *url,
+					 const char           *url_title,
+					 const char           *cookie);
+bool sfi_url_test_show              	(const char           *url);
+bool sfi_url_test_show_with_cookie	(const char           *url,
+					 const char           *url_title,
+					 const char           *cookie);
+
+/* --- cleanup handlers --- */
+void birnet_cleanup_force_handlers     (void); // FIXME: remove 
+
+BIRNET_EXTERN_C_END();
+
+#endif /* __SFI_WRAPPER_H__ */
+
+/* vim:set ts=8 sts=2 sw=2: */




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]