From null+ranguba at clear-code.com Wed Sep 1 00:09:50 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Wed, 01 Sep 2010 04:09:50 +0000 Subject: [groonga-commit:1197] ranguba/chupatext [master] * test/test_text.c: removed garbage. Message-ID: <20100901092909.D81FE170521@taiyaki.ru> Nobuyoshi Nakada 2010-09-01 04:09:50 +0000 (Wed, 01 Sep 2010) New Revision: c02c05172c2b93cc1b2ff13dd7f19d3d8a0a26d4 Log: * test/test_text.c: removed garbage. Modified files: test/test_text.c Modified: test/test_text.c (+0 -3) =================================================================== --- test/test_text.c 2010-09-01 01:29:28 +0000 (d42fa1f) +++ test/test_text.c 2010-09-01 04:09:50 +0000 (fbd4c9e) @@ -39,9 +39,6 @@ text_decomposed(gpointer obj, gpointer arg, gpointer udata) gsize length; read_data = g_data_input_stream_read_until(data, "", &length, NULL, NULL); -#if 0 - g_main_loop_quit(main_loop); -#endif } void From null+ranguba at clear-code.com Wed Sep 1 05:15:42 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Wed, 01 Sep 2010 09:15:42 +0000 Subject: [groonga-commit:1198] ranguba/chupatext [master] * module/chupa_pdf.c, module/chupa_tar.c: register dynamically. Message-ID: <20100901092910.00FDB170F43@taiyaki.ru> Nobuyoshi Nakada 2010-09-01 09:15:42 +0000 (Wed, 01 Sep 2010) New Revision: d982571ba7b3a9c3b703773f729a640cdc68bb9b Log: * module/chupa_pdf.c, module/chupa_tar.c: register dynamically. Modified files: module/chupa_pdf.c module/chupa_tar.c Modified: module/chupa_pdf.c (+53 -7) =================================================================== --- module/chupa_pdf.c 2010-09-01 04:11:07 +0000 (35f04a6) +++ module/chupa_pdf.c 2010-09-01 09:15:42 +0000 (fc8bd13) @@ -4,10 +4,11 @@ */ #include +#include #include #include -#define CHUPA_TYPE_PDF_DECOMPOSER chupa_pdf_decomposer_get_type() +#define CHUPA_TYPE_PDF_DECOMPOSER chupa_type_pdf_decomposer #define CHUPA_PDF_DECOMPOSER(obj) \ G_TYPE_CHECK_INSTANCE_CAST(obj, CHUPA_TYPE_PDF_DECOMPOSER, ChupaPDFDecomposer) #define CHUPA_PDF_DECOMPOSER_CLASS(klass) \ @@ -32,12 +33,7 @@ struct _ChupaPDFDecomposerClass ChupaDecomposerClass parent_class; }; -G_DEFINE_TYPE(ChupaPDFDecomposer, chupa_pdf_decomposer, CHUPA_TYPE_DECOMPOSER) - -static void -chupa_pdf_decomposer_init(ChupaPDFDecomposer *pdf_decomposer) -{ -} +static GType chupa_type_pdf_decomposer = 0; static void chupa_pdf_decomposer_feed(ChupaDecomposer *dec, ChupaText *chupar, ChupaTextInputStream *stream) @@ -98,3 +94,53 @@ chupa_pdf_decomposer_class_init(ChupaPDFDecomposerClass *klass) ChupaDecomposerClass *super = CHUPA_DECOMPOSER_CLASS(klass); super->feed = chupa_pdf_decomposer_feed; } + + +static GType +register_type(GTypeModule *type_module) +{ + static const GTypeInfo info = { + sizeof(ChupaPDFDecomposerClass), + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) chupa_pdf_decomposer_class_init, + NULL, /* class_finalize */ + NULL, /* class_data */ + sizeof(ChupaPDFDecomposer), + 0, + (GInstanceInitFunc) NULL, + }; + + return chupa_type_pdf_decomposer = + g_type_module_register_type(type_module, + G_TYPE_OBJECT, + "ChupaPDFDecomposer", + &info, 0); +} + +G_MODULE_EXPORT GList * +CHUPA_MODULE_IMPL_INIT(GTypeModule *type_module) +{ + GType type = register_type(type_module); + GList *registered_types = NULL; + + if (type) { + chupa_decomposer_register("application/pdf", type); + registered_types = + g_list_prepend(registered_types, + (gchar *)g_type_name(type)); + } + + return registered_types; +} + +G_MODULE_EXPORT void +CHUPA_MODULE_IMPL_EXIT(void) +{ +} + +G_MODULE_EXPORT GObject * +CHUPA_MODULE_IMPL_INSTANTIATE(const gchar *first_property, va_list var_args) +{ + return NULL; +} Modified: module/chupa_tar.c (+51 -7) =================================================================== --- module/chupa_tar.c 2010-09-01 04:11:07 +0000 (c3cb699) +++ module/chupa_tar.c 2010-09-01 09:15:42 +0000 (3c1d5fb) @@ -40,7 +40,7 @@ G_STATIC_ASSERT(sizeof(union tar_buffer) == TAR_PAGE_SIZE); #define roomof(count, unit) (((count) + (unit) - 1) / (unit)) #define roundup(count, unit) (roomof(count, unit) * (unit)) -#define CHUPA_TYPE_TAR_DECOMPOSER chupa_tar_decomposer_get_type() +#define CHUPA_TYPE_TAR_DECOMPOSER chupa_type_tar_decomposer #define CHUPA_TAR_DECOMPOSER(obj) \ G_TYPE_CHECK_INSTANCE_CAST(obj, CHUPA_TYPE_TAR_DECOMPOSER, ChupaTARDecomposer) #define CHUPA_TAR_DECOMPOSER_CLASS(klass) \ @@ -65,12 +65,7 @@ struct _ChupaTARDecomposerClass ChupaDecomposerClass parent_class; }; -G_DEFINE_TYPE(ChupaTARDecomposer, chupa_tar_decomposer, CHUPA_TYPE_DECOMPOSER) - -static void -chupa_tar_decomposer_init(ChupaTARDecomposer *dec) -{ -} +static GType chupa_type_tar_decomposer = 0; static gboolean is_null_page(const unsigned int *up, gsize size) @@ -140,3 +135,52 @@ chupa_tar_decomposer_class_init(ChupaTARDecomposerClass *klass) ChupaDecomposerClass *super = CHUPA_DECOMPOSER_CLASS(klass); super->feed = chupa_tar_decomposer_feed; } + +static GType +register_type(GTypeModule *type_module) +{ + static const GTypeInfo info = { + sizeof(ChupaTARDecomposerClass), + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) chupa_tar_decomposer_class_init, + NULL, /* class_finalize */ + NULL, /* class_data */ + sizeof(ChupaTARDecomposer), + 0, + (GInstanceInitFunc) NULL, + }; + + return chupa_type_tar_decomposer = + g_type_module_register_type(type_module, + G_TYPE_OBJECT, + "ChupaTARDecomposer", + &info, 0); +} + +G_MODULE_EXPORT GList * +CHUPA_MODULE_IMPL_INIT(GTypeModule *type_module) +{ + GType type = register_type(type_module); + GList *registered_types = NULL; + + if (type) { + chupa_decomposer_register("application/x-tar", type); + registered_types = + g_list_prepend(registered_types, + (gchar *)g_type_name(type)); + } + + return registered_types; +} + +G_MODULE_EXPORT void +CHUPA_MODULE_IMPL_EXIT(void) +{ +} + +G_MODULE_EXPORT GObject * +CHUPA_MODULE_IMPL_INSTANTIATE(const gchar *first_property, va_list var_args) +{ + return NULL; +} From null+ranguba at clear-code.com Wed Sep 1 00:11:07 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Wed, 01 Sep 2010 04:11:07 +0000 Subject: [groonga-commit:1199] ranguba/chupatext [master] * module/chupa_tar.c: refactored. Message-ID: <20100901092909.E4D66170EE4@taiyaki.ru> Nobuyoshi Nakada 2010-09-01 04:11:07 +0000 (Wed, 01 Sep 2010) New Revision: 01f160ba6ab5fae8efd587287cc2d236d95b4188 Log: * module/chupa_tar.c: refactored. Modified files: module/chupa_tar.c Modified: module/chupa_tar.c (+91 -34) =================================================================== --- module/chupa_tar.c 2010-09-01 04:09:50 +0000 (06d9549) +++ module/chupa_tar.c 2010-09-01 04:11:07 +0000 (c3cb699) @@ -3,10 +3,14 @@ * Copyright (C) 2010 Nobuyoshi Nakada */ -#include "chupatext.h" +#include +#include +#include #include #include +#define TAR_PAGE_SIZE 512 + struct tar_header { guchar name[100]; /* NUL-terminated if NUL fits */ guchar mode[8]; @@ -26,60 +30,113 @@ struct tar_header { guchar prefix[155]; /* NUL-terminated if NUL fits */ }; +union tar_buffer { + struct tar_header bytes; + unsigned int uints[TAR_PAGE_SIZE / sizeof(unsigned int)]; +}; + +G_STATIC_ASSERT(sizeof(union tar_buffer) == TAR_PAGE_SIZE); + #define roomof(count, unit) (((count) + (unit) - 1) / (unit)) #define roundup(count, unit) (roomof(count, unit) * (unit)) -static int -chupa_tar_foreach(ChupaSwitcher *chupar, GInputStream *input, ChupaCallbackFunc *func, void *arg) +#define CHUPA_TYPE_TAR_DECOMPOSER chupa_tar_decomposer_get_type() +#define CHUPA_TAR_DECOMPOSER(obj) \ + G_TYPE_CHECK_INSTANCE_CAST(obj, CHUPA_TYPE_TAR_DECOMPOSER, ChupaTARDecomposer) +#define CHUPA_TAR_DECOMPOSER_CLASS(klass) \ + G_TYPE_CHECK_CLASS_CAST(klass, CHUPA_TYPE_TAR_DECOMPOSER, ChupaTARDecomposerClass) +#define CHUPA_IS_TAR_DECOMPOSER(obj) \ + G_TYPE_CHECK_INSTANCE_TYPE(obj, CHUPA_TYPE_TAR_DECOMPOSER) +#define CHUPA_IS_TAR_DECOMPOSER_CLASS(klass) \ + G_TYPE_CHECK_CLASS_TYPE(klass, CHUPA_TYPE_TAR_DECOMPOSER) +#define CHUPA_TAR_DECOMPOSER_GET_CLASS(obj) \ + G_TYPE_INSTANCE_GET_CLASS(obj, CHUPA_TYPE_TAR_DECOMPOSER, ChupaTARDecomposerClass) + +typedef struct _ChupaTARDecomposer ChupaTARDecomposer; +typedef struct _ChupaTARDecomposerClass ChupaTARDecomposerClass; + +struct _ChupaTARDecomposer +{ + ChupaDecomposer object; +}; + +struct _ChupaTARDecomposerClass +{ + ChupaDecomposerClass parent_class; +}; + +G_DEFINE_TYPE(ChupaTARDecomposer, chupa_tar_decomposer, CHUPA_TYPE_DECOMPOSER) + +static void +chupa_tar_decomposer_init(ChupaTARDecomposer *dec) +{ +} + +static gboolean +is_null_page(const unsigned int *up, gsize size) +{ + gsize i = size / sizeof(*up); + + while (--i > 0) { + if (*up++) { + return FALSE; + } + } + i = size % sizeof(*up); + if (i > 0) { + const unsigned char *cp = (const unsigned char *)up; + while (--i > 0) { + if (*cp++) { + return FALSE; + } + } + } + return TRUE; +} + +static void +chupa_tar_decomposer_feed(ChupaDecomposer *dec, ChupaText *chupar, ChupaTextInputStream *stream) { - struct tar_header header; + union tar_buffer header; gssize size; - guchar name[sizeof(header.name) + sizeof(header.prefix) + 2]; + guchar name[sizeof(header.bytes.name) + sizeof(header.bytes.prefix) + 2]; + GInputStream *input = G_INPUT_STREAM(stream); - while ((size = g_input_stream_read(input, &header, sizeof(header), 0, 0)) > 0) { - guchar *p; + while ((size = g_input_stream_read(input, &header, sizeof(header), 0, 0)) > 0 && + !is_null_page(header.uints, size)) { if (size < sizeof(header)) { g_warning("garbage in tar file\n"); break; } - if (memcmp(header.magic, TMAGIC, TMAGLEN) != 0) { + if (memcmp(header.bytes.magic, TMAGIC, TMAGLEN) != 0) { g_warning("bad magic\n"); break; } - size = strtoul(header.size); - if (header.typeflag[0] == REGTYPE || header.typeflag[0] == AREGTYPE) { + size = strtoul(header.bytes.size); + if (header.bytes.typeflag[0] == REGTYPE || header.bytes.typeflag[0] == AREGTYPE) { /* regular file only */ GInputStream *part; - ChupaSwitcher *subchupar; - int ret; - p = name; - if (header.prefix[0]) { - p += strlcpy(p, header.prefix, sizeof(header.prefix)); + guchar *p = name; + if (header.bytes.prefix[0]) { + p += strlcpy(p, header.bytes.prefix, sizeof(header.bytes.prefix)); *p++ = '/'; } - p += g_strlcpy(p, header.name, sizeof(header.name)); - /* TODO: make delimited stream */ - part = g_memory_input_stream_new(); - subchupar = chupa_switcher_new(part); - ret = chupa_foreach(subchupar, func, arg); + p += g_strlcpy(p, header.bytes.name, sizeof(header.bytes.name)); + part = chupa_restrict_input_stream_new(input, size); + chupa_text_feed(chupar, part); + chupa_restrict_input_stream_skip_to_end(part); g_object_unref(part); - g_free(subchupar); - if (ret) break; + g_input_stream_skip(input, (gsize)size % TAR_PAGE_SIZE, NULL, NULL); + } + else { + g_input_stream_skip(input, roundup((gsize)size, TAR_PAGE_SIZE), NULL, NULL); } - g_input_stream_skip(input, roundup((gsize)size, 512), NULL, NULL); } - return 0; } -static const ChupaExtractor -chupa_tar_extactor = { - {"application", "x-tar"}, - NULL, - chupa_tar_foreach, -}; - -void -chupa_module_tar_init(void) +static void +chupa_tar_decomposer_class_init(ChupaTARDecomposerClass *klass) { - chupa_regsiter_extactor(&chupa_tar_extactor); + ChupaDecomposerClass *super = CHUPA_DECOMPOSER_CLASS(klass); + super->feed = chupa_tar_decomposer_feed; } From null+ranguba at clear-code.com Wed Sep 1 05:18:59 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Wed, 01 Sep 2010 09:18:59 +0000 Subject: [groonga-commit:1200] ranguba/chupatext [master] * chupatext/chupa_module.c: add chupa_module_path(). Message-ID: <20100901092910.16C41170F45@taiyaki.ru> Nobuyoshi Nakada 2010-09-01 09:18:59 +0000 (Wed, 01 Sep 2010) New Revision: 1f9c492adb070997742745a50b270e904c8cfe92 Log: * chupatext/chupa_module.c: add chupa_module_path(). Modified files: chupatext/Makefile.am chupatext/chupa_decomposer.c chupatext/chupa_module.c chupatext/chupa_module.h Modified: chupatext/Makefile.am (+1 -1) =================================================================== --- chupatext/Makefile.am 2010-09-01 09:17:41 +0000 (eadb1c6) +++ chupatext/Makefile.am 2010-09-01 09:18:59 +0000 (240b283) @@ -9,7 +9,7 @@ libchupatext_la_SOURCES = chupa_init.c chupa_metadata.c \ version.c \ $(EMPTY) -AM_CPPFLAGS = -DCHUPA_MODULE_PATH=\"$(moduledir)\" +AM_CPPFLAGS = -DCHUPA_MODULE_PATH=\"$(moduledir)\" -D_GNU_SOURCE AM_CFLAGS = $(GLIB_CFLAGS) DEFAULT_INCLUDES = -I$(top_includedir) -I$(build_includedir) Modified: chupatext/chupa_decomposer.c (+1 -0) =================================================================== --- chupatext/chupa_decomposer.c 2010-09-01 09:17:41 +0000 (fd9304f) +++ chupatext/chupa_decomposer.c 2010-09-01 09:18:59 +0000 (08e34a0) @@ -69,6 +69,7 @@ void chupa_decomposer_load_modules(void) { chupa_decomposer_register(text_plain, CHUPA_TYPE_TEXT_DECOMPOSER); + chupa_module_load_modules(chupa_module_path()); } void Modified: chupatext/chupa_module.c (+55 -1) =================================================================== --- chupatext/chupa_module.c 2010-09-01 09:17:41 +0000 (0722b1e) +++ chupatext/chupa_module.c 2010-09-01 09:18:59 +0000 (5424d27) @@ -28,6 +28,9 @@ #include "chupatext/chupa_module.h" #include "chupatext/chupa_module_impl.h" +#if !defined G_PLATFORM_WIN32 && defined HAVE_DLFCN_H +#include +#endif #define CHUPA_MODULE_GET_PRIVATE(obj) \ (G_TYPE_INSTANCE_GET_PRIVATE(obj, \ @@ -239,7 +242,7 @@ chupa_module_find(GList *modules, const gchar *name) GObject * chupa_module_instantiate(ChupaModule *module, - const gchar *first_property, va_list var_args) + const gchar *first_property, va_list var_args) { GObject *object = NULL; ChupaModulePrivate *priv; @@ -410,6 +413,57 @@ chupa_module_unload(ChupaModule *module) } } +#ifdef G_PLATFORM_WIN32 + +#ifdef DLL_EXPORT +static HMODULE chupa_dll = NULL; + +BOOL WINAPI +DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) +{ + if (fdwReason == DLL_PROCESS_ATTACH) + chupa_dll = hinstDLL; + + return TRUE; +} +#else +#define chupa_dll NULL +#endif + +#define get_package_dir() g_win32_get_package_installation_directory_of_module(chupa_dll) + +#else +static gchar * +get_package_dir(void) +{ +#if defined HAVE_DLFCN_H + Dl_info dli; + if (dladdr((gpointer)get_package_dir, &dli)) { + return g_strdup(dli.dli_fname); + } +#endif + return NULL; +} +#endif + +gchar * +chupa_module_path(void) +{ + const gchar *path = g_getenv("CHUPA_MODULE_PATH"); + if (!path && !g_path_is_absolute(path = CHUPA_MODULE_PATH)) { + gchar *base_dir; +#if defined G_OS_WIN32 + base_dir = g_win32_get_package_installation_directory_of_module(chupa_dll); +#elif defined HAVE_DLFCN_H + base_dir = get_package_dir(); +#endif + if (base_dir) { + return g_build_filename(base_dir, path, NULL); + } + } + return g_strdup(path); +} + /* vi:ts=4:nowrap:ai:expandtab:sw=4 */ Modified: chupatext/chupa_module.h (+1 -0) =================================================================== --- chupatext/chupa_module.h 2010-09-01 09:17:41 +0000 (7b2b666) +++ chupatext/chupa_module.h 2010-09-01 09:18:59 +0000 (c559179) @@ -46,6 +46,7 @@ GObject *chupa_module_instantiate(ChupaModule *module, GList *chupa_module_collect_registered_types(GList *modules); GList *chupa_module_collect_names(GList *modules); void chupa_module_unload(ChupaModule *module); +gchar *chupa_module_path(void); #define CHUPA_MODULE_IMPL_INIT chupa_module_impl_init #define CHUPA_MODULE_IMPL_EXIT chupa_module_impl_exit From null+ranguba at clear-code.com Wed Sep 1 05:20:20 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Wed, 01 Sep 2010 09:20:20 +0000 Subject: [groonga-commit:1201] ranguba/chupatext [master] * Makefile.am: build modules. Message-ID: <20100901092910.258E4170F46@taiyaki.ru> Nobuyoshi Nakada 2010-09-01 09:20:20 +0000 (Wed, 01 Sep 2010) New Revision: 54c247786396e1c3e2fa77ca4a1240faf3cc790a Log: * Makefile.am: build modules. Modified files: Makefile.am Modified: Makefile.am (+1 -1) =================================================================== --- Makefile.am 2010-09-01 09:18:59 +0000 (e7d25cd) +++ Makefile.am 2010-09-01 09:20:20 +0000 (b243ee8) @@ -1,6 +1,6 @@ ACLOCAL_AMFLAGS = -I m4 -SUBDIRS = chupatext test +SUBDIRS = chupatext test module all-recursive: update-version.h From null+ranguba at clear-code.com Wed Sep 1 05:17:41 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Wed, 01 Sep 2010 09:17:41 +0000 Subject: [groonga-commit:1200] ranguba/chupatext [master] * chupatext/Makefile.am, configure.ac: set module path. Message-ID: <20100901092910.0B67B170F44@taiyaki.ru> Nobuyoshi Nakada 2010-09-01 09:17:41 +0000 (Wed, 01 Sep 2010) New Revision: 8bd90998930efedf5c91afd7c6db135dc41a3205 Log: * chupatext/Makefile.am, configure.ac: set module path. Modified files: chupatext/Makefile.am configure.ac Modified: chupatext/Makefile.am (+2 -0) =================================================================== --- chupatext/Makefile.am 2010-09-01 09:15:42 +0000 (0c13a55) +++ chupatext/Makefile.am 2010-09-01 09:17:41 +0000 (eadb1c6) @@ -9,6 +9,8 @@ libchupatext_la_SOURCES = chupa_init.c chupa_metadata.c \ version.c \ $(EMPTY) +AM_CPPFLAGS = -DCHUPA_MODULE_PATH=\"$(moduledir)\" + AM_CFLAGS = $(GLIB_CFLAGS) DEFAULT_INCLUDES = -I$(top_includedir) -I$(build_includedir) Modified: configure.ac (+1 -1) =================================================================== --- configure.ac 2010-09-01 09:15:42 +0000 (e2f4384) +++ configure.ac 2010-09-01 09:17:41 +0000 (db4f686) @@ -1,6 +1,6 @@ AC_PREREQ(2.59) -AC_INIT() +AC_INIT(chupatext, 0) AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_AUX_DIR([config]) From null+ranguba at clear-code.com Wed Sep 1 05:51:07 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Wed, 01 Sep 2010 09:51:07 +0000 Subject: [groonga-commit:1201] ranguba/chupatext [master] * chupatext/version.c: changed somehow. Message-ID: <20100901095120.831BF170521@taiyaki.ru> Nobuyoshi Nakada 2010-09-01 09:51:07 +0000 (Wed, 01 Sep 2010) New Revision: 6adeade3672e7ac38648248fe720363e025ea9f6 Log: * chupatext/version.c: changed somehow. Modified files: chupatext/version.c Modified: chupatext/version.c (+5 -3) =================================================================== --- chupatext/version.c 2010-09-01 09:20:20 +0000 (d6d4307) +++ chupatext/version.c 2010-09-01 09:51:07 +0000 (42bcf0d) @@ -23,6 +23,8 @@ chupa_release_date(void) return CHUPA_RELEASE_DATE; } -#define STRINGIZE(x) #x -#define STRINGIZE2(x) STRINGIZE(x) -const char chupa_ident[] = "$Ident: ChupaText " CHUPA_VERSION_STRING "-" STRINGIZE2(CHUPA_COMMITS) " $"; +#define STRINGIFY_ARG(x) #x +#define STRINGIFY(x) STRINGIFY_ARG(x) +const char chupa_ident[] = "$Ident: ChupaText " + CHUPA_VERSION_STRING "-" STRINGIFY(CHUPA_COMMITS) + " $"; From null+ranguba at clear-code.com Thu Sep 2 00:02:41 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Thu, 02 Sep 2010 04:02:41 +0000 Subject: [groonga-commit:1202] ranguba/chupatext [master] * chupatext/chupa_module.c (chupa_module_load_module), (chupa_module_load_modules): force prefix and suffix. Message-ID: <20100902094319.2A596170ED0@taiyaki.ru> Nobuyoshi Nakada 2010-09-02 04:02:41 +0000 (Thu, 02 Sep 2010) New Revision: 21c7ff8e3857d566ff642e57fc97483570ad769f Log: * chupatext/chupa_module.c (chupa_module_load_module), (chupa_module_load_modules): force prefix and suffix. Modified files: chupatext/chupa_module.c Modified: chupatext/chupa_module.c (+13 -17) =================================================================== --- chupatext/chupa_module.c 2010-09-02 00:58:43 +0000 (5424d27) +++ chupatext/chupa_module.c 2010-09-02 04:02:41 +0000 (9c0ea36) @@ -51,6 +51,8 @@ struct _ChupaModulePrivate G_DEFINE_TYPE(ChupaModule, chupa_module, G_TYPE_TYPE_MODULE) +static const char chupa_module_prefix[] = "chupa_"; + static void finalize(GObject *object); static gboolean load(GTypeModule *module); static void unload(GTypeModule *module); @@ -314,22 +316,13 @@ chupa_module_load_module(const gchar *base_dir, const gchar *name) if (g_file_test(mod_path, G_FILE_TEST_EXISTS)) { ChupaModulePrivate *priv; - gchar *mod_name; - module = g_object_new(CHUPA_TYPE_MODULE, NULL); + module = chupa_module_new(name, NULL, NULL, NULL); priv = CHUPA_MODULE_GET_PRIVATE(module); - priv->mod_path = g_strdup(mod_path); - - mod_name = g_strdup(name); - if (g_str_has_suffix(mod_name, "."G_MODULE_SUFFIX)) { - guint last_index; - last_index = strlen(mod_name) - strlen("."G_MODULE_SUFFIX); - mod_name[last_index] = '\0'; - } - g_type_module_set_name(G_TYPE_MODULE(module), mod_name); - g_free(mod_name); + priv->mod_path = mod_path; + } else { + g_free(mod_path); } - g_free(mod_path); return module; } @@ -355,6 +348,12 @@ chupa_module_load_modules_unique(const gchar *base_dir, return exist_modules; while ((entry = g_dir_read_name(dir))) { + if (!g_str_has_prefix(entry, chupa_module_prefix)) + continue; + if (!g_str_has_suffix(entry, "."G_MODULE_SUFFIX)) + continue; + if (chupa_module_find(exist_modules, entry)) + continue; sorted_entries = g_slist_prepend(sorted_entries, g_strdup(entry)); } sorted_entries = g_slist_sort(sorted_entries, (GCompareFunc)strcmp); @@ -368,10 +367,7 @@ chupa_module_load_modules_unique(const gchar *base_dir, continue; g_module = G_TYPE_MODULE(module); - if (chupa_module_find(exist_modules, g_module->name)) - chupa_module_unload(module); - else - modules = g_list_prepend(modules, module); + modules = g_list_prepend(modules, module); } g_slist_foreach(sorted_entries, (GFunc)g_free, NULL); g_slist_free(sorted_entries); From null+ranguba at clear-code.com Wed Sep 1 20:58:43 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Thu, 02 Sep 2010 00:58:43 +0000 Subject: [groonga-commit:1203] ranguba/chupatext [master] * test/test_text.c: use user_data. Message-ID: <20100902094319.20D50170E84@taiyaki.ru> Nobuyoshi Nakada 2010-09-02 00:58:43 +0000 (Thu, 02 Sep 2010) New Revision: f7b4201fdf158019d9c257907efdbfcc2d72aec1 Log: * test/test_text.c: use user_data. Modified files: test/test_text.c Modified: test/test_text.c (+2 -2) =================================================================== --- test/test_text.c 2010-09-01 09:51:07 +0000 (fbd4c9e) +++ test/test_text.c 2010-09-02 00:58:43 +0000 (5667133) @@ -38,7 +38,7 @@ text_decomposed(gpointer obj, gpointer arg, gpointer udata) GDataInputStream *data = G_DATA_INPUT_STREAM(arg); gsize length; - read_data = g_data_input_stream_read_until(data, "", &length, NULL, NULL); + *(gpointer *)udata = g_data_input_stream_read_until(data, "", &length, NULL, NULL); } void @@ -49,7 +49,7 @@ test_decompose_text_plain (void) source = mem; chupar = chupa_text_new(); - g_signal_connect(chupar, chupa_text_signal_decomposed, (GCallback)text_decomposed, NULL); + g_signal_connect(chupar, chupa_text_signal_decomposed, (GCallback)text_decomposed, &read_data); chupa_text_feed(chupar, source); cut_assert_equal_string(plain_text, read_data); } From null+ranguba at clear-code.com Thu Sep 2 05:37:03 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Thu, 02 Sep 2010 09:37:03 +0000 Subject: [groonga-commit:1204] ranguba/chupatext [master] * module/chupa_pdf.c, module/chupa_tar.c: initialize once. Message-ID: <20100902094319.A7C00170F46@taiyaki.ru> Nobuyoshi Nakada 2010-09-02 09:37:03 +0000 (Thu, 02 Sep 2010) New Revision: 959de4ade36435df4d2d127d4bedc77b598d96b5 Log: * module/chupa_pdf.c, module/chupa_tar.c: initialize once. Modified files: module/chupa_pdf.c module/chupa_tar.c Modified: module/chupa_pdf.c (+15 -8) =================================================================== --- module/chupa_pdf.c 2010-09-02 09:35:42 +0000 (fc8bd13) +++ module/chupa_pdf.c 2010-09-02 09:37:03 +0000 (3e5be87) @@ -110,12 +110,17 @@ register_type(GTypeModule *type_module) 0, (GInstanceInitFunc) NULL, }; - - return chupa_type_pdf_decomposer = - g_type_module_register_type(type_module, - G_TYPE_OBJECT, - "ChupaPDFDecomposer", - &info, 0); + GType type = chupa_type_pdf_decomposer; + + if (!type) { + type = g_type_module_register_type(type_module, + CHUPA_TYPE_DECOMPOSER, + "ChupaPDFDecomposer", + &info, 0); + chupa_type_pdf_decomposer = type; + chupa_decomposer_register("application/pdf", type); + } + return type; } G_MODULE_EXPORT GList * @@ -124,12 +129,13 @@ CHUPA_MODULE_IMPL_INIT(GTypeModule *type_module) GType type = register_type(type_module); GList *registered_types = NULL; +#if 0 if (type) { - chupa_decomposer_register("application/pdf", type); registered_types = g_list_prepend(registered_types, (gchar *)g_type_name(type)); } +#endif return registered_types; } @@ -142,5 +148,6 @@ CHUPA_MODULE_IMPL_EXIT(void) G_MODULE_EXPORT GObject * CHUPA_MODULE_IMPL_INSTANTIATE(const gchar *first_property, va_list var_args) { - return NULL; + return g_object_new_valist(CHUPA_TYPE_PDF_DECOMPOSER, + first_property, var_args); } Modified: module/chupa_tar.c (+15 -8) =================================================================== --- module/chupa_tar.c 2010-09-02 09:35:42 +0000 (3c1d5fb) +++ module/chupa_tar.c 2010-09-02 09:37:03 +0000 (dbdb48f) @@ -150,12 +150,17 @@ register_type(GTypeModule *type_module) 0, (GInstanceInitFunc) NULL, }; - - return chupa_type_tar_decomposer = - g_type_module_register_type(type_module, - G_TYPE_OBJECT, - "ChupaTARDecomposer", - &info, 0); + GType type = chupa_type_tar_decomposer; + + if (!type) { + type = g_type_module_register_type(type_module, + CHUPA_TYPE_DECOMPOSER, + "ChupaTARDecomposer", + &info, 0); + chupa_type_tar_decomposer = type; + chupa_decomposer_register("application/x-tar", type); + } + return type; } G_MODULE_EXPORT GList * @@ -164,12 +169,13 @@ CHUPA_MODULE_IMPL_INIT(GTypeModule *type_module) GType type = register_type(type_module); GList *registered_types = NULL; +#if 0 if (type) { - chupa_decomposer_register("application/x-tar", type); registered_types = g_list_prepend(registered_types, (gchar *)g_type_name(type)); } +#endif return registered_types; } @@ -182,5 +188,6 @@ CHUPA_MODULE_IMPL_EXIT(void) G_MODULE_EXPORT GObject * CHUPA_MODULE_IMPL_INSTANTIATE(const gchar *first_property, va_list var_args) { - return NULL; + return g_object_new_valist(CHUPA_TYPE_TAR_DECOMPOSER, + first_property, var_args); } From null+ranguba at clear-code.com Thu Sep 2 05:35:42 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Thu, 02 Sep 2010 09:35:42 +0000 Subject: [groonga-commit:1205] ranguba/chupatext [master] * chupatext/chupa_decomposer.c (chupa_decomposer_load_modules): fix memory leak. Message-ID: <20100902094319.7C683170F45@taiyaki.ru> Nobuyoshi Nakada 2010-09-02 09:35:42 +0000 (Thu, 02 Sep 2010) New Revision: ade4bd3f0513b760314c95133153e855f1d67b56 Log: * chupatext/chupa_decomposer.c (chupa_decomposer_load_modules): fix memory leak. Modified files: chupatext/chupa_decomposer.c Modified: chupatext/chupa_decomposer.c (+6 -1) =================================================================== --- chupatext/chupa_decomposer.c 2010-09-02 09:34:52 +0000 (08e34a0) +++ chupatext/chupa_decomposer.c 2010-09-02 09:35:42 +0000 (4fe82d6) @@ -4,6 +4,7 @@ */ #include "chupatext/chupa_decomposer.h" +#include "chupatext/chupa_module.h" #include "chupatext/text_decomposer.h" #include #include @@ -68,8 +69,12 @@ static const char text_plain[] = "text/plain"; void chupa_decomposer_load_modules(void) { + gchar *base_dir; + chupa_decomposer_register(text_plain, CHUPA_TYPE_TEXT_DECOMPOSER); - chupa_module_load_modules(chupa_module_path()); + base_dir = chupa_module_path(); + chupa_module_load_modules(base_dir); + g_free(base_dir); } void From null+ranguba at clear-code.com Thu Sep 2 05:37:35 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Thu, 02 Sep 2010 09:37:35 +0000 Subject: [groonga-commit:1206] ranguba/chupatext [master] * module/Makefile.am: link against chupatext. Message-ID: <20100902094319.B2AA8170F48@taiyaki.ru> Nobuyoshi Nakada 2010-09-02 09:37:35 +0000 (Thu, 02 Sep 2010) New Revision: 18007ad7be0ccb2bb1bdc943500d57b9836fc53f Log: * module/Makefile.am: link against chupatext. Modified files: module/Makefile.am Modified: module/Makefile.am (+2 -0) =================================================================== --- module/Makefile.am 2010-09-02 09:37:03 +0000 (3d47861) +++ module/Makefile.am 2010-09-02 09:37:35 +0000 (a74133c) @@ -1,5 +1,7 @@ EMPTY = +LDFLAGS = -L$(top_builddir)/chupatext -lchupatext + module_LTLIBRARIES = \ chupa_tar.la \ chupa_pdf.la \ From null+ranguba at clear-code.com Thu Sep 2 05:57:49 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Thu, 02 Sep 2010 09:57:49 +0000 Subject: [groonga-commit:1207] ranguba/chupatext [master] * chupatext/chupa_module.c (chupa_module_new): add. Message-ID: <20100902095810.05D8D170E84@taiyaki.ru> Nobuyoshi Nakada 2010-09-02 09:57:49 +0000 (Thu, 02 Sep 2010) New Revision: 8ef2dc232ca133597e342c55d739353346a21113 Log: * chupatext/chupa_module.c (chupa_module_new): add. Modified files: chupatext/chupa_module.c chupatext/chupa_module_impl.h Modified: chupatext/chupa_module.c (+33 -0) =================================================================== --- chupatext/chupa_module.c 2010-09-02 09:38:47 +0000 (8607fba) +++ chupatext/chupa_module.c 2010-09-02 09:57:49 +0000 (39ffc29) @@ -300,6 +300,39 @@ _chupa_module_load_func(GModule *module, const gchar *func_name, } } +static gchar * +chupa_module_stem_name(const gchar *name) +{ + gchar *mod_name; + + if (g_str_has_prefix(name, chupa_module_prefix)) + name += strlen(chupa_module_prefix); + mod_name = g_strdup(name); + if (g_str_has_suffix(mod_name, "."G_MODULE_SUFFIX)) { + guint last_index; + last_index = strlen(mod_name) - strlen("."G_MODULE_SUFFIX); + mod_name[last_index] = '\0'; + } + return mod_name; +} + +ChupaModule * +chupa_module_new(const gchar *name, + ChupaModuleInitFunc init, + ChupaModuleExitFunc exit, + ChupaModuleInstantiateFunc instantiate) +{ + ChupaModule *module = g_object_new(CHUPA_TYPE_MODULE, NULL); + ChupaModulePrivate *priv = CHUPA_MODULE_GET_PRIVATE(module); + gchar *mod_name = chupa_module_stem_name(name); + g_type_module_set_name(G_TYPE_MODULE(module), mod_name); + g_free(mod_name); + priv->init = init; + priv->exit = exit; + priv->instantiate = instantiate; + return module; +} + ChupaModule * chupa_module_load_module(const gchar *base_dir, const gchar *name) { Modified: chupatext/chupa_module_impl.h (+6 -0) =================================================================== --- chupatext/chupa_module_impl.h 2010-09-02 09:38:47 +0000 (efe63df) +++ chupatext/chupa_module_impl.h 2010-09-02 09:57:49 +0000 (f29bb41) @@ -31,6 +31,12 @@ typedef void (*ChupaModuleExitFunc)(void); typedef GObject *(*ChupaModuleInstantiateFunc)(const gchar *first_property, va_list var_args); +ChupaModule * +chupa_module_new(const gchar *name, + ChupaModuleInitFunc init, + ChupaModuleExitFunc exit, + ChupaModuleInstantiateFunc instantiate); + G_END_DECLS #endif /* CHUPA_MODULE_IMPL_H */ From null+ranguba at clear-code.com Thu Sep 2 05:34:52 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Thu, 02 Sep 2010 09:34:52 +0000 Subject: [groonga-commit:1208] ranguba/chupatext [master] * chupatext/chupa_module.c (chupa_module_new): load found modules all. Message-ID: <20100902094319.33D8B170F44@taiyaki.ru> Nobuyoshi Nakada 2010-09-02 09:34:52 +0000 (Thu, 02 Sep 2010) New Revision: ce4436e097130e82a6c9e4824f27b4cf0fa1afa3 Log: * chupatext/chupa_module.c (chupa_module_new): load found modules all. Modified files: chupatext/chupa_module.c Modified: chupatext/chupa_module.c (+3 -1) =================================================================== --- chupatext/chupa_module.c 2010-09-02 04:02:41 +0000 (9c0ea36) +++ chupatext/chupa_module.c 2010-09-02 09:34:52 +0000 (8607fba) @@ -330,7 +330,9 @@ chupa_module_load_module(const gchar *base_dir, const gchar *name) GList * chupa_module_load_modules(const gchar *base_dir) { - return chupa_module_load_modules_unique(base_dir, NULL); + GList *modules = chupa_module_load_modules_unique(base_dir, NULL); + g_list_foreach(modules, (GFunc)g_type_module_use, NULL); + return modules; } GList * From null+ranguba at clear-code.com Thu Sep 2 05:38:08 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Thu, 02 Sep 2010 09:38:08 +0000 Subject: [groonga-commit:1209] ranguba/chupatext [master] * test/test_pdf.c: test for PDF decomposer. Message-ID: <20100902094319.BE9CF170F49@taiyaki.ru> Nobuyoshi Nakada 2010-09-02 09:38:08 +0000 (Thu, 02 Sep 2010) New Revision: 5627a62835a9cd9779668c95e631add57ba0177a Log: * test/test_pdf.c: test for PDF decomposer. Added files: test/fixtures/sample.pdf test/test_pdf.c Modified files: test/Makefile.am Modified: test/Makefile.am (+2 -0) =================================================================== --- test/Makefile.am 2010-09-02 09:37:35 +0000 (5803387) +++ test/Makefile.am 2010-09-02 09:38:08 +0000 (239eb4d) @@ -11,6 +11,7 @@ noinst_LTLIBRARIES = \ test_text_input_stream.la \ test_decomposer.la \ test_restrict_input_stream.la \ + test_pdf.la \ $(EMPTY) endif @@ -46,6 +47,7 @@ test_text_la_SOURCES = test_text.c test_text_input_stream_la_SOURCES = test_text_input_stream.c test_decomposer_la_SOURCES = test_decomposer.c test_restrict_input_stream_la_SOURCES = test_restrict_input_stream.c +test_pdf_la_SOURCES = test_pdf.c echo-cutter: @echo $(CUTTER) Added: test/fixtures/sample.pdf (+0 -0) 100644 =================================================================== (Binary files differ) Added: test/test_pdf.c (+73 -0) 100644 =================================================================== --- /dev/null +++ test/test_pdf.c 2010-09-02 09:38:08 +0000 (8c579ad) @@ -0,0 +1,73 @@ +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Copyright (C) 2010 Nobuyoshi Nakada + */ + +#include +#include + +#include +#include + +static ChupaText *chupar; +static GInputStream *source; +static gchar *sample_path; +static GFile *sample_file; +static gchar *read_data; + +#if !CUTTER_CHECK_VERSION(1, 1, 5) +#define cut_get_source_directory() \ + cut_run_context_get_source_directory( \ + cut_test_context_get_run_context( \ + cut_get_current_test_context())) +#endif + +void +setup(void) +{ + chupa_decomposer_load_modules(); + + chupar = NULL; + source = NULL; + sample_path = NULL; + sample_file = NULL; + read_data = NULL; + + cut_set_fixture_data_dir(cut_get_source_directory(), "fixtures", NULL); +} + +void +teardown(void) +{ + if (chupar) + g_object_unref(chupar); + if (source) + g_object_unref(source); + if (sample_path) + g_free(sample_path); + if (sample_file) + g_object_unref(sample_file); + if (read_data) + g_free(read_data); +} + +static void +text_decomposed(gpointer obj, gpointer arg, gpointer udata) +{ + GDataInputStream *data = G_DATA_INPUT_STREAM(arg); + gsize length; + + *(gpointer *)udata = g_data_input_stream_read_until(data, "", &length, NULL, NULL); +} + +void +test_decompose_pdf(void) +{ + chupar = chupa_text_new(); + g_signal_connect(chupar, chupa_text_signal_decomposed, (GCallback)text_decomposed, &read_data); + sample_path = cut_build_fixture_data_path("sample.pdf", NULL); + sample_file = g_file_new_for_path(sample_path); + source = G_INPUT_STREAM(g_file_read(sample_file, NULL, NULL)); + chupa_text_feed(chupar, source); + cut_assert_equal_string("sample\n", read_data); +} From null+ranguba at clear-code.com Thu Sep 2 05:38:47 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Thu, 02 Sep 2010 09:38:47 +0000 Subject: [groonga-commit:1210] ranguba/chupatext [master] * prereq.mk: split source updating stuff. Message-ID: <20100902094319.C8A16170F4A@taiyaki.ru> Nobuyoshi Nakada 2010-09-02 09:38:47 +0000 (Thu, 02 Sep 2010) New Revision: 3144f284f83003b6d5b8ce27bbc1f00f6cf15b24 Log: * prereq.mk: split source updating stuff. Added files: prereq.mk Modified files: Makefile.am Modified: Makefile.am (+1 -4) =================================================================== --- Makefile.am 2010-09-02 09:38:08 +0000 (b243ee8) +++ Makefile.am 2010-09-02 09:38:47 +0000 (074cf76) @@ -4,7 +4,4 @@ SUBDIRS = chupatext test module all-recursive: update-version.h -update-version.h: - $(SHELL) $(top_srcdir)/tool/version-update.sh chupatext/version.h $(top_srcdir) - -.PHONY: update-version.h +include prereq.mk Added: prereq.mk (+12 -0) 100644 =================================================================== --- /dev/null +++ prereq.mk 2010-09-02 09:38:47 +0000 (86894cd) @@ -0,0 +1,12 @@ +GIT = git + +up: pull update-version.h + +pull: + @cd "$(srcdir)" && $(GIT) pull + +update-version.h: + @cd "$(top_srcdir)" && \ + $(SHELL) ./tool/version-update.sh chupatext/version.h + +.PHONY: update-version.h From null+ranguba at clear-code.com Thu Sep 2 16:51:09 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Thu, 02 Sep 2010 20:51:09 +0000 Subject: [groonga-commit:1211] ranguba/chupatext [master] * test/run-test.sh: set up CHUPA_MODULE_PATH. Message-ID: <20100902205139.346AA170ED0@taiyaki.ru> Nobuyoshi Nakada 2010-09-02 20:51:09 +0000 (Thu, 02 Sep 2010) New Revision: 8d3e8a1a23afd451e2f72929b61641174b3cc880 Log: * test/run-test.sh: set up CHUPA_MODULE_PATH. Modified files: test/run-test.sh Modified: test/run-test.sh (+1 -0) =================================================================== --- test/run-test.sh 2010-09-02 20:43:56 +0000 (2632c6e) +++ test/run-test.sh 2010-09-02 20:51:09 +0000 (ff6f40f) @@ -81,5 +81,6 @@ export CHUPATEXT_RUBYLIB export RUBYLIB export CHUPATEXT_CONFIGURATION_MODULE_DIR=$builddir/module/configuration/ruby/.libs export CHUPATEXT_CONFIG_DIR=$top_srcdir/test/fixtures/configuration +export CHUPA_MODULE_PATH=$builddir/module/.libs $CUTTER_WRAPPER $CUTTER $CUTTER_ARGS "$@" "$testdir" From null+ranguba at clear-code.com Thu Sep 2 16:43:56 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Thu, 02 Sep 2010 20:43:56 +0000 Subject: [groonga-commit:1212] ranguba/chupatext [master] * prereq.mk: assume make under /usr/bin. Message-ID: <20100902205139.258D6170E84@taiyaki.ru> Nobuyoshi Nakada 2010-09-02 20:43:56 +0000 (Thu, 02 Sep 2010) New Revision: fa8dd2faa27f55158ec43f30113952a46e1e278b Log: * prereq.mk: assume make under /usr/bin. Modified files: prereq.mk Modified: prereq.mk (+2 -0) Mode: 100644 -> 100755 =================================================================== --- prereq.mk 2010-09-02 09:57:49 +0000 (86894cd) +++ prereq.mk 2010-09-02 20:43:56 +0000 (87f5970) @@ -1,3 +1,5 @@ +#!/usr/bin/make -f + GIT = git up: pull update-version.h From null+ranguba at clear-code.com Fri Sep 3 01:08:26 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Fri, 03 Sep 2010 05:08:26 +0000 Subject: [groonga-commit:1213] ranguba/chupatext [master] * configure.ac, module/Makefile.am, test/Makefile.am: skip PDF module if popper-glib is not available. Message-ID: <20100903052225.AFCDF170536@taiyaki.ru> Nobuyoshi Nakada 2010-09-03 05:08:26 +0000 (Fri, 03 Sep 2010) New Revision: c50a39844cffbfee71983b91fa6a682a8fcfa76f Log: * configure.ac, module/Makefile.am, test/Makefile.am: skip PDF module if popper-glib is not available. Modified files: configure.ac module/Makefile.am test/Makefile.am Modified: configure.ac (+2 -1) =================================================================== --- configure.ac 2010-09-02 20:51:09 +0000 (db4f686) +++ configure.ac 2010-09-03 05:08:26 +0000 (81eb85a) @@ -62,7 +62,8 @@ AC_CHECK_GCUTTER(>= 1.1.4) ], [ac_cv_use_cutter="no"]) -PKG_CHECK_MODULES(POPPLER_GLIB, poppler-glib) +PKG_CHECK_MODULES(POPPLER_GLIB, poppler-glib, [have_poppler=yes], [:]) +AM_CONDITIONAL([HAVE_POPPLER_GLIB], [test "$have_poppler" = "yes"]) AM_CONDITIONAL([WITH_CUTTER], [test "$ac_cv_use_cutter" != "no"]) if test "$ac_cv_use_cutter" != "no"; then Modified: module/Makefile.am (+5 -4) =================================================================== --- module/Makefile.am 2010-09-02 20:51:09 +0000 (a74133c) +++ module/Makefile.am 2010-09-03 05:08:26 +0000 (1b15597) @@ -2,10 +2,11 @@ EMPTY = LDFLAGS = -L$(top_builddir)/chupatext -lchupatext -module_LTLIBRARIES = \ - chupa_tar.la \ - chupa_pdf.la \ - $(EMPTY) +module_LTLIBRARIES = +module_LTLIBRARIES += chupa_tar.la +if HAVE_POPPLER_GLIB +module_LTLIBRARIES += chupa_pdf.la +endif chupa_tar_la_SOURCES = chupa_tar.c chupa_tar_la_LDFLAGS = -module Modified: test/Makefile.am (+5 -1) =================================================================== --- test/Makefile.am 2010-09-02 20:51:09 +0000 (239eb4d) +++ test/Makefile.am 2010-09-03 05:08:26 +0000 (0c5cf9b) @@ -11,8 +11,12 @@ noinst_LTLIBRARIES = \ test_text_input_stream.la \ test_decomposer.la \ test_restrict_input_stream.la \ - test_pdf.la \ $(EMPTY) + +if HAVE_POPPLER_GLIB +noinst_LTLIBRARIES += test_pdf.la +endif + endif EXTRA_DIST = \ From null+ranguba at clear-code.com Fri Sep 3 01:22:09 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Fri, 03 Sep 2010 05:22:09 +0000 Subject: [groonga-commit:1214] ranguba/chupatext [master] * module/chupa_msword.c: support MS-Word. Message-ID: <20100903052225.B92C6170EC3@taiyaki.ru> Nobuyoshi Nakada 2010-09-03 05:22:09 +0000 (Fri, 03 Sep 2010) New Revision: 015c04e460b5c680af8d16e2cbd8147869445890 Log: * module/chupa_msword.c: support MS-Word. Added files: module/chupa_msword.c test/test_msword.c Modified files: configure.ac module/Makefile.am test/Makefile.am Modified: configure.ac (+2 -0) =================================================================== --- configure.ac 2010-09-03 05:08:26 +0000 (81eb85a) +++ configure.ac 2010-09-03 05:22:09 +0000 (5a77fcb) @@ -64,6 +64,8 @@ AC_CHECK_GCUTTER(>= 1.1.4) PKG_CHECK_MODULES(POPPLER_GLIB, poppler-glib, [have_poppler=yes], [:]) AM_CONDITIONAL([HAVE_POPPLER_GLIB], [test "$have_poppler" = "yes"]) +PKG_CHECK_MODULES(WV2, wv2, [have_wv2=yes], [:]) +AM_CONDITIONAL([HAVE_WV2], [test "$have_wv2" = "yes"]) AM_CONDITIONAL([WITH_CUTTER], [test "$ac_cv_use_cutter" != "no"]) if test "$ac_cv_use_cutter" != "no"; then Modified: module/Makefile.am (+8 -0) =================================================================== --- module/Makefile.am 2010-09-03 05:08:26 +0000 (1b15597) +++ module/Makefile.am 2010-09-03 05:22:09 +0000 (18c02c2) @@ -7,6 +7,9 @@ module_LTLIBRARIES += chupa_tar.la if HAVE_POPPLER_GLIB module_LTLIBRARIES += chupa_pdf.la endif +if HAVE_WV2 +module_LTLIBRARIES += chupa_msword.la +endif chupa_tar_la_SOURCES = chupa_tar.c chupa_tar_la_LDFLAGS = -module @@ -18,4 +21,9 @@ chupa_pdf_la_LDFLAGS = -module chupa_pdf_la_CPPFLAGS = $(POPPLER_GLIB_CFLAGS) chupa_pdf_la_LIBADD = $(POPPLER_GLIB_LIBS) +chupa_msword_la_SOURCES = chupa_msword.c +chupa_msword_la_LDFLAGS = -module +chupa_msword_la_CPPFLAGS = $(WV_GLIB_CFLAGS) +chupa_msword_la_LIBADD = $(WV_GLIB_LIBS) + DEFAULT_INCLUDES = -I$(top_includedir) -I$(build_includedir) Added: module/chupa_msword.c (+128 -0) 100644 =================================================================== --- /dev/null +++ module/chupa_msword.c 2010-09-03 05:22:09 +0000 (363adea) @@ -0,0 +1,128 @@ +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Copyright (C) 2010 Nobuyoshi Nakada + */ + +#include +#include +#include +#include +#include + +#define CHUPA_TYPE_MSWORD_DECOMPOSER chupa_type_msword_decomposer +#define CHUPA_MSWORD_DECOMPOSER(obj) \ + G_TYPE_CHECK_INSTANCE_CAST(obj, CHUPA_TYPE_MSWORD_DECOMPOSER, ChupaMSWORDDecomposer) +#define CHUPA_MSWORD_DECOMPOSER_CLASS(klass) \ + G_TYPE_CHECK_CLASS_CAST(klass, CHUPA_TYPE_MSWORD_DECOMPOSER, ChupaMSWORDDecomposerClass) +#define CHUPA_IS_MSWORD_DECOMPOSER(obj) \ + G_TYPE_CHECK_INSTANCE_TYPE(obj, CHUPA_TYPE_MSWORD_DECOMPOSER) +#define CHUPA_IS_MSWORD_DECOMPOSER_CLASS(klass) \ + G_TYPE_CHECK_CLASS_TYPE(klass, CHUPA_TYPE_MSWORD_DECOMPOSER) +#define CHUPA_MSWORD_DECOMPOSER_GET_CLASS(obj) \ + G_TYPE_INSTANCE_GET_CLASS(obj, CHUPA_TYPE_MSWORD_DECOMPOSER, ChupaMSWORDDecomposerClass) + +typedef struct _ChupaMSWORDDecomposer ChupaMSWORDDecomposer; +typedef struct _ChupaMSWORDDecomposerClass ChupaMSWORDDecomposerClass; + +struct _ChupaMSWORDDecomposer +{ + ChupaDecomposer object; +}; + +struct _ChupaMSWORDDecomposerClass +{ + ChupaDecomposerClass parent_class; +}; + +static GType chupa_type_msword_decomposer = 0; + +static gboolean +is_null_page(const unsigned int *up, gsize size) +{ + gsize i = size / sizeof(*up); + + while (--i > 0) { + if (*up++) { + return FALSE; + } + } + i = size % sizeof(*up); + if (i > 0) { + const unsigned char *cp = (const unsigned char *)up; + while (--i > 0) { + if (*cp++) { + return FALSE; + } + } + } + return TRUE; +} + +static void +chupa_msword_decomposer_feed(ChupaDecomposer *dec, ChupaText *chupar, ChupaTextInputStream *stream) +{ + GInputStream *input = G_INPUT_STREAM(stream); +} + +static void +chupa_msword_decomposer_class_init(ChupaMSWORDDecomposerClass *klass) +{ + ChupaDecomposerClass *super = CHUPA_DECOMPOSER_CLASS(klass); + super->feed = chupa_msword_decomposer_feed; +} + +static GType +register_type(GTypeModule *type_module) +{ + static const GTypeInfo info = { + sizeof(ChupaMSWORDDecomposerClass), + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) chupa_msword_decomposer_class_init, + NULL, /* class_finalize */ + NULL, /* class_data */ + sizeof(ChupaMSWORDDecomposer), + 0, + (GInstanceInitFunc) NULL, + }; + GType type = chupa_type_msword_decomposer; + + if (!type) { + type = g_type_module_register_type(type_module, + CHUPA_TYPE_DECOMPOSER, + "ChupaMSWORDDecomposer", + &info, 0); + chupa_type_msword_decomposer = type; + chupa_decomposer_register("application/x-msword", type); + } + return type; +} + +G_MODULE_EXPORT GList * +CHUPA_MODULE_IMPL_INIT(GTypeModule *type_module) +{ + GType type = register_type(type_module); + GList *registered_types = NULL; + +#if 0 + if (type) { + registered_types = + g_list_prepend(registered_types, + (gchar *)g_type_name(type)); + } +#endif + + return registered_types; +} + +G_MODULE_EXPORT void +CHUPA_MODULE_IMPL_EXIT(void) +{ +} + +G_MODULE_EXPORT GObject * +CHUPA_MODULE_IMPL_INSTANTIATE(const gchar *first_property, va_list var_args) +{ + return g_object_new_valist(CHUPA_TYPE_MSWORD_DECOMPOSER, + first_property, var_args); +} Modified: test/Makefile.am (+5 -0) =================================================================== --- test/Makefile.am 2010-09-03 05:08:26 +0000 (0c5cf9b) +++ test/Makefile.am 2010-09-03 05:22:09 +0000 (4e68b3c) @@ -17,6 +17,10 @@ if HAVE_POPPLER_GLIB noinst_LTLIBRARIES += test_pdf.la endif +if HAVE_WV2 +noinst_LTLIBRARIES += test_msword.la +endif + endif EXTRA_DIST = \ @@ -52,6 +56,7 @@ test_text_input_stream_la_SOURCES = test_text_input_stream.c test_decomposer_la_SOURCES = test_decomposer.c test_restrict_input_stream_la_SOURCES = test_restrict_input_stream.c test_pdf_la_SOURCES = test_pdf.c +test_msword_la_SOURCES = test_msword.c echo-cutter: @echo $(CUTTER) Added: test/test_msword.c (+73 -0) 100644 =================================================================== --- /dev/null +++ test/test_msword.c 2010-09-03 05:22:09 +0000 (a6abc18) @@ -0,0 +1,73 @@ +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Copyright (C) 2010 Nobuyoshi Nakada + */ + +#include +#include + +#include +#include + +static ChupaText *chupar; +static GInputStream *source; +static gchar *sample_path; +static GFile *sample_file; +static gchar *read_data; + +#if !CUTTER_CHECK_VERSION(1, 1, 5) +#define cut_get_source_directory() \ + cut_run_context_get_source_directory( \ + cut_test_context_get_run_context( \ + cut_get_current_test_context())) +#endif + +void +setup(void) +{ + chupa_decomposer_load_modules(); + + chupar = NULL; + source = NULL; + sample_path = NULL; + sample_file = NULL; + read_data = NULL; + + cut_set_fixture_data_dir(cut_get_source_directory(), "fixtures", NULL); +} + +void +teardown(void) +{ + if (chupar) + g_object_unref(chupar); + if (source) + g_object_unref(source); + if (sample_path) + g_free(sample_path); + if (sample_file) + g_object_unref(sample_file); + if (read_data) + g_free(read_data); +} + +static void +text_decomposed(gpointer obj, gpointer arg, gpointer udata) +{ + GDataInputStream *data = G_DATA_INPUT_STREAM(arg); + gsize length; + + *(gpointer *)udata = g_data_input_stream_read_until(data, "", &length, NULL, NULL); +} + +void +test_decompose_msword(void) +{ + chupar = chupa_text_new(); + g_signal_connect(chupar, chupa_text_signal_decomposed, (GCallback)text_decomposed, &read_data); + sample_path = cut_build_fixture_data_path("sample.doc", NULL); + sample_file = g_file_new_for_path(sample_path); + source = G_INPUT_STREAM(g_file_read(sample_file, NULL, NULL)); + chupa_text_feed(chupar, source); + cut_assert_equal_string("sample\n", read_data); +} From null+ranguba at clear-code.com Fri Sep 3 01:34:23 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Fri, 03 Sep 2010 05:34:23 +0000 Subject: [groonga-commit:1215] ranguba/chupatext [master] * configure.ac: use wv2-config. Message-ID: <20100903053434.B595F170536@taiyaki.ru> Nobuyoshi Nakada 2010-09-03 05:34:23 +0000 (Fri, 03 Sep 2010) New Revision: 874f26f9334115a224323a75550ff8aa4d4cf390 Log: * configure.ac: use wv2-config. Modified files: configure.ac module/Makefile.am Modified: configure.ac (+6 -1) =================================================================== --- configure.ac 2010-09-03 05:22:09 +0000 (5a77fcb) +++ configure.ac 2010-09-03 05:34:23 +0000 (ed31b39) @@ -64,7 +64,12 @@ AC_CHECK_GCUTTER(>= 1.1.4) PKG_CHECK_MODULES(POPPLER_GLIB, poppler-glib, [have_poppler=yes], [:]) AM_CONDITIONAL([HAVE_POPPLER_GLIB], [test "$have_poppler" = "yes"]) -PKG_CHECK_MODULES(WV2, wv2, [have_wv2=yes], [:]) +AC_PATH_TOOL([WV2_CONFIG], [wv2-config]) +if test -n "$WV2_CONFIG"; then + WV2_CFLAGS=`$WV2_CONFIG --cflags wv2` + WV2_LIBS=`$WV2_CONFIG --libs wv2` + have_wv2=yes +fi AM_CONDITIONAL([HAVE_WV2], [test "$have_wv2" = "yes"]) AM_CONDITIONAL([WITH_CUTTER], [test "$ac_cv_use_cutter" != "no"]) Modified: module/Makefile.am (+2 -2) =================================================================== --- module/Makefile.am 2010-09-03 05:22:09 +0000 (18c02c2) +++ module/Makefile.am 2010-09-03 05:34:23 +0000 (463521e) @@ -23,7 +23,7 @@ chupa_pdf_la_LIBADD = $(POPPLER_GLIB_LIBS) chupa_msword_la_SOURCES = chupa_msword.c chupa_msword_la_LDFLAGS = -module -chupa_msword_la_CPPFLAGS = $(WV_GLIB_CFLAGS) -chupa_msword_la_LIBADD = $(WV_GLIB_LIBS) +chupa_msword_la_CPPFLAGS = $(WV_CFLAGS) $(GLIB_CFLAGS) +chupa_msword_la_LIBADD = $(WV_LIBS) $(GLIB_LIBS) DEFAULT_INCLUDES = -I$(top_includedir) -I$(build_includedir) From null+ranguba at clear-code.com Fri Sep 3 01:40:19 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Fri, 03 Sep 2010 05:40:19 +0000 Subject: [groonga-commit:1216] ranguba/chupatext [master] * module/chupa_msword.c (is_null_page): removed garbage. Message-ID: <20100903054030.581E7170536@taiyaki.ru> Nobuyoshi Nakada 2010-09-03 05:40:19 +0000 (Fri, 03 Sep 2010) New Revision: 1f5ce3297158a35b40510ce13734ef54a5aff0ee Log: * module/chupa_msword.c (is_null_page): removed garbage. Modified files: module/chupa_msword.c Modified: module/chupa_msword.c (+0 -22) =================================================================== --- module/chupa_msword.c 2010-09-03 05:34:23 +0000 (363adea) +++ module/chupa_msword.c 2010-09-03 05:40:19 +0000 (556dca8) @@ -36,28 +36,6 @@ struct _ChupaMSWORDDecomposerClass static GType chupa_type_msword_decomposer = 0; -static gboolean -is_null_page(const unsigned int *up, gsize size) -{ - gsize i = size / sizeof(*up); - - while (--i > 0) { - if (*up++) { - return FALSE; - } - } - i = size % sizeof(*up); - if (i > 0) { - const unsigned char *cp = (const unsigned char *)up; - while (--i > 0) { - if (*cp++) { - return FALSE; - } - } - } - return TRUE; -} - static void chupa_msword_decomposer_feed(ChupaDecomposer *dec, ChupaText *chupar, ChupaTextInputStream *stream) { From null+ranguba at clear-code.com Fri Sep 3 01:57:54 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Fri, 03 Sep 2010 05:57:54 +0000 Subject: [groonga-commit:1217] ranguba/chupatext [master] * configure.ac: use wv-1.0. Message-ID: <20100903055805.DB8C8170536@taiyaki.ru> Nobuyoshi Nakada 2010-09-03 05:57:54 +0000 (Fri, 03 Sep 2010) New Revision: 96bc0aca230d1fef7f0c8d2c1b2e33803d564dc8 Log: * configure.ac: use wv-1.0. Modified files: configure.ac module/Makefile.am module/chupa_msword.c test/Makefile.am Modified: configure.ac (+2 -7) =================================================================== --- configure.ac 2010-09-03 05:40:19 +0000 (ed31b39) +++ configure.ac 2010-09-03 05:57:54 +0000 (80e3b61) @@ -64,13 +64,8 @@ AC_CHECK_GCUTTER(>= 1.1.4) PKG_CHECK_MODULES(POPPLER_GLIB, poppler-glib, [have_poppler=yes], [:]) AM_CONDITIONAL([HAVE_POPPLER_GLIB], [test "$have_poppler" = "yes"]) -AC_PATH_TOOL([WV2_CONFIG], [wv2-config]) -if test -n "$WV2_CONFIG"; then - WV2_CFLAGS=`$WV2_CONFIG --cflags wv2` - WV2_LIBS=`$WV2_CONFIG --libs wv2` - have_wv2=yes -fi -AM_CONDITIONAL([HAVE_WV2], [test "$have_wv2" = "yes"]) +PKG_CHECK_MODULES(WV, wv-1.0, [have_wv=yes], [:]) +AM_CONDITIONAL([HAVE_WV], [test "$have_wv" = "yes"]) AM_CONDITIONAL([WITH_CUTTER], [test "$ac_cv_use_cutter" != "no"]) if test "$ac_cv_use_cutter" != "no"; then Modified: module/Makefile.am (+3 -3) =================================================================== --- module/Makefile.am 2010-09-03 05:40:19 +0000 (463521e) +++ module/Makefile.am 2010-09-03 05:57:54 +0000 (3aaabdc) @@ -7,7 +7,7 @@ module_LTLIBRARIES += chupa_tar.la if HAVE_POPPLER_GLIB module_LTLIBRARIES += chupa_pdf.la endif -if HAVE_WV2 +if HAVE_WV module_LTLIBRARIES += chupa_msword.la endif @@ -23,7 +23,7 @@ chupa_pdf_la_LIBADD = $(POPPLER_GLIB_LIBS) chupa_msword_la_SOURCES = chupa_msword.c chupa_msword_la_LDFLAGS = -module -chupa_msword_la_CPPFLAGS = $(WV_CFLAGS) $(GLIB_CFLAGS) -chupa_msword_la_LIBADD = $(WV_LIBS) $(GLIB_LIBS) +chupa_msword_la_CPPFLAGS = $(WV_CFLAGS) +chupa_msword_la_LIBADD = $(WV_LIBS) DEFAULT_INCLUDES = -I$(top_includedir) -I$(build_includedir) Modified: module/chupa_msword.c (+1 -1) =================================================================== --- module/chupa_msword.c 2010-09-03 05:40:19 +0000 (556dca8) +++ module/chupa_msword.c 2010-09-03 05:57:54 +0000 (cc0b080) @@ -7,7 +7,7 @@ #include #include #include -#include +#include #define CHUPA_TYPE_MSWORD_DECOMPOSER chupa_type_msword_decomposer #define CHUPA_MSWORD_DECOMPOSER(obj) \ Modified: test/Makefile.am (+1 -1) =================================================================== --- test/Makefile.am 2010-09-03 05:40:19 +0000 (4e68b3c) +++ test/Makefile.am 2010-09-03 05:57:54 +0000 (262fc06) @@ -17,7 +17,7 @@ if HAVE_POPPLER_GLIB noinst_LTLIBRARIES += test_pdf.la endif -if HAVE_WV2 +if HAVE_WV noinst_LTLIBRARIES += test_msword.la endif From null+ranguba at clear-code.com Mon Sep 6 03:06:56 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Mon, 06 Sep 2010 07:06:56 +0000 Subject: [groonga-commit:1218] ranguba/chupatext [master] * chupatext/chupa_text_input_stream.c (guess_mime_type): use ChupaTextInputStream. Message-ID: <20100907071307.5ABEF170E7F@taiyaki.ru> Nobuyoshi Nakada 2010-09-06 07:06:56 +0000 (Mon, 06 Sep 2010) New Revision: 51c6c064ed8e5cd97f25a7dfe48cb5c2dac4f31b Log: * chupatext/chupa_text_input_stream.c (guess_mime_type): use ChupaTextInputStream. Modified files: chupatext/chupa_text_input_stream.c Modified: chupatext/chupa_text_input_stream.c (+13 -7) =================================================================== --- chupatext/chupa_text_input_stream.c 2010-09-06 04:09:51 +0000 (616449c) +++ chupatext/chupa_text_input_stream.c 2010-09-06 07:06:56 +0000 (0883ae4) @@ -30,18 +30,24 @@ enum { }; static const char * -guess_mime_type(GInputStream *stream, gboolean *uncertain) +guess_mime_type(ChupaTextInputStream *stream, gboolean *uncertain) { - const char *mime_type; + const char *mime_type = NULL; + GInputStream *base; - if (G_IS_FILE_INPUT_STREAM(stream)) { - GFileInfo *info = g_file_input_stream_query_info(G_FILE_INPUT_STREAM(stream), + base = g_filter_input_stream_get_base_stream(G_FILTER_INPUT_STREAM(stream)); + + if (G_IS_FILE_INPUT_STREAM(base)) { + GFileInfo *info = g_file_input_stream_query_info(G_FILE_INPUT_STREAM(base), G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE, NULL, NULL); - mime_type = g_content_type_get_mime_type(g_file_info_get_content_type(info)); + const char *content_type = g_file_info_get_content_type(info); + if (content_type) { + mime_type = g_content_type_get_mime_type(content_type); + } g_object_unref(info); } - else { + if (!mime_type) { gsize len; const char *buf; GBufferedInputStream *buffered = G_BUFFERED_INPUT_STREAM(stream); @@ -73,7 +79,7 @@ constructed(GObject *object) priv->metadata = chupa_metadata_new(); } - mime_type = guess_mime_type(G_INPUT_STREAM(stream), NULL); + mime_type = guess_mime_type(stream, NULL); chupa_metadata_replace_value(priv->metadata, "mime-type", mime_type); } From null+ranguba at clear-code.com Mon Sep 6 00:09:51 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Mon, 06 Sep 2010 04:09:51 +0000 Subject: [groonga-commit:1219] ranguba/chupatext [master] * configure.ac: moved PKG_CHECK_MODULES. Message-ID: <20100907071307.500A0170E0C@taiyaki.ru> Nobuyoshi Nakada 2010-09-06 04:09:51 +0000 (Mon, 06 Sep 2010) New Revision: 67ab30c9f12ca296cdc7ef449968acf90a001c71 Log: * configure.ac: moved PKG_CHECK_MODULES. Modified files: configure.ac Modified: configure.ac (+5 -5) =================================================================== --- configure.ac 2010-09-03 05:57:54 +0000 (80e3b61) +++ configure.ac 2010-09-06 04:09:51 +0000 (5458a96) @@ -54,6 +54,11 @@ if test "$ac_glib_available" != "yes"; then AC_MSG_ERROR([no glib available]) fi +PKG_CHECK_MODULES(POPPLER_GLIB, poppler-glib, [have_poppler=yes], [:]) +AM_CONDITIONAL([HAVE_POPPLER_GLIB], [test "$have_poppler" = "yes"]) +PKG_CHECK_MODULES(WV, wv-1.0, [have_wv=yes], [:]) +AM_CONDITIONAL([HAVE_WV], [test "$have_wv" = "yes"]) + dnl ************************************************************** dnl Check for Cutter dnl ************************************************************** @@ -62,11 +67,6 @@ AC_CHECK_GCUTTER(>= 1.1.4) ], [ac_cv_use_cutter="no"]) -PKG_CHECK_MODULES(POPPLER_GLIB, poppler-glib, [have_poppler=yes], [:]) -AM_CONDITIONAL([HAVE_POPPLER_GLIB], [test "$have_poppler" = "yes"]) -PKG_CHECK_MODULES(WV, wv-1.0, [have_wv=yes], [:]) -AM_CONDITIONAL([HAVE_WV], [test "$have_wv" = "yes"]) - AM_CONDITIONAL([WITH_CUTTER], [test "$ac_cv_use_cutter" != "no"]) if test "$ac_cv_use_cutter" != "no"; then AC_DEFINE(WITH_CUTTER, 1, [Define to 1 if you use Cutter]) From null+ranguba at clear-code.com Mon Sep 6 03:08:25 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Mon, 06 Sep 2010 07:08:25 +0000 Subject: [groonga-commit:1220] ranguba/chupatext [master] * module/chupa_msword.c (register_type): MS-Word document cannot be distinguished from OLE storage without filename. Message-ID: <20100907071307.642D8170F52@taiyaki.ru> Nobuyoshi Nakada 2010-09-06 07:08:25 +0000 (Mon, 06 Sep 2010) New Revision: 129e10d540445d33880705fa4d181913d04370e2 Log: * module/chupa_msword.c (register_type): MS-Word document cannot be distinguished from OLE storage without filename. Modified files: module/chupa_msword.c Modified: module/chupa_msword.c (+1 -0) =================================================================== --- module/chupa_msword.c 2010-09-06 07:06:56 +0000 (cc0b080) +++ module/chupa_msword.c 2010-09-06 07:08:25 +0000 (5242251) @@ -72,6 +72,7 @@ register_type(GTypeModule *type_module) &info, 0); chupa_type_msword_decomposer = type; chupa_decomposer_register("application/x-msword", type); + chupa_decomposer_register("application/x-ole-storage", type); } return type; } From null+ranguba at clear-code.com Tue Sep 7 03:12:38 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Tue, 07 Sep 2010 07:12:38 +0000 Subject: [groonga-commit:1221] ranguba/chupatext [master] * chupatext/chupa_text.h: use GsfInput as base instead of GInputStream. Message-ID: <20100907071307.7056A170F54@taiyaki.ru> Nobuyoshi Nakada 2010-09-07 07:12:38 +0000 (Tue, 07 Sep 2010) New Revision: e2d373d4931ce4669523588713225aa94a45813a Log: * chupatext/chupa_text.h: use GsfInput as base instead of GInputStream. Added files: chupatext/chupa_text_input.c chupatext/chupa_text_input.h Modified files: chupatext/Makefile.am chupatext/chupa_decomposer.c chupatext/chupa_decomposer.h chupatext/chupa_text.c chupatext/chupa_text.h chupatext/chupa_text_input_stream.c chupatext/chupa_text_input_stream.h chupatext/text_decomposer.c configure.ac Modified: chupatext/Makefile.am (+3 -2) =================================================================== --- chupatext/Makefile.am 2010-09-06 07:08:25 +0000 (240b283) +++ chupatext/Makefile.am 2010-09-07 07:12:38 +0000 (f4b3cb6) @@ -3,7 +3,8 @@ lib_LTLIBRARIES = libchupatext.la EMPTY = libchupatext_la_SOURCES = chupa_init.c chupa_metadata.c \ - chupa_text.c chupa_text_input_stream.c chupa_module.c \ + chupa_text.c chupa_text_input.c chupa_module.c \ + chupa_text_input_stream.c \ chupa_decomposer.c text_decomposer.c \ chupa_restrict_input_stream.c \ version.c \ @@ -11,7 +12,7 @@ libchupatext_la_SOURCES = chupa_init.c chupa_metadata.c \ AM_CPPFLAGS = -DCHUPA_MODULE_PATH=\"$(moduledir)\" -D_GNU_SOURCE -AM_CFLAGS = $(GLIB_CFLAGS) +AM_CFLAGS = $(GSF_CFLAGS) DEFAULT_INCLUDES = -I$(top_includedir) -I$(build_includedir) version.lo: version.h Modified: chupatext/chupa_decomposer.c (+2 -2) =================================================================== --- chupatext/chupa_decomposer.c 2010-09-06 07:08:25 +0000 (4fe82d6) +++ chupatext/chupa_decomposer.c 2010-09-07 07:12:38 +0000 (2b39adb) @@ -58,10 +58,10 @@ chupa_decomposer_class_init(ChupaDecomposerClass *klass) } void -chupa_decomposer_feed(ChupaDecomposer *dec, ChupaText *text, ChupaTextInputStream *stream) +chupa_decomposer_feed(ChupaDecomposer *dec, ChupaText *text, ChupaTextInput *input) { g_return_if_fail(CHUPA_IS_DECOMPOSER(dec)); - (*CHUPA_DECOMPOSER_GET_CLASS(dec)->feed)(dec, text, stream); + (*CHUPA_DECOMPOSER_GET_CLASS(dec)->feed)(dec, text, input); } static const char text_plain[] = "text/plain"; Modified: chupatext/chupa_decomposer.h (+3 -3) =================================================================== --- chupatext/chupa_decomposer.h 2010-09-06 07:08:25 +0000 (143eaa3) +++ chupatext/chupa_decomposer.h 2010-09-07 07:12:38 +0000 (2c6da39) @@ -36,14 +36,14 @@ struct _ChupaDecomposerClass { GObjectClass parent_class; - gboolean (*can_handle)(ChupaDecomposerClass *dec, ChupaTextInputStream *stream, const char *mime_type); - void (*feed)(ChupaDecomposer *dec, ChupaText *text, ChupaTextInputStream *stream); + gboolean (*can_handle)(ChupaDecomposerClass *dec, ChupaTextInput *input, const char *mime_type); + void (*feed)(ChupaDecomposer *dec, ChupaText *text, ChupaTextInput *input); }; GType chupa_decomposer_get_type(void) G_GNUC_CONST; ChupaDecomposer *chupa_decomposer_search(const gchar *mime_type); -void chupa_decomposer_feed(ChupaDecomposer *dec, ChupaText *text, ChupaTextInputStream *stream); +void chupa_decomposer_feed(ChupaDecomposer *dec, ChupaText *text, ChupaTextInput *input); void chupa_decomposer_load_modules(void); void chupa_decomposer_register(const gchar *mime_type, GType type); Modified: chupatext/chupa_text.c (+5 -7) =================================================================== --- chupatext/chupa_text.c 2010-09-06 07:08:25 +0000 (1516faf) +++ chupatext/chupa_text.c 2010-09-07 07:12:38 +0000 (7faaaaf) @@ -63,30 +63,28 @@ chupa_text_new(void) } void -chupa_text_decomposed(ChupaText *chupar, ChupaTextInputStream *stream) +chupa_text_decomposed(ChupaText *chupar, ChupaTextInput *input) { + GInputStream *stream = chupa_text_input_get_stream(input); g_signal_emit_by_name(chupar, chupa_text_signal_decomposed, stream); } void -chupa_text_feed(ChupaText *chupar, GInputStream *stream) +chupa_text_feed(ChupaText *chupar, ChupaTextInput *input) { const char *mime_type = NULL; - ChupaTextInputStream *ti; ChupaDecomposer *dec; - ti = chupa_text_input_stream_new(NULL, stream); - mime_type = chupa_text_input_stream_get_mime_type(ti); + mime_type = chupa_text_input_get_mime_type(input); if (!mime_type) { g_error("can't determin mime-type\n"); } else if (dec = chupa_decomposer_search(mime_type)) { - chupa_decomposer_feed(dec, chupar, ti); + chupa_decomposer_feed(dec, chupar, input); g_object_unref(dec); } else { g_warning("unknown mime-type %s\n", mime_type); } - g_object_unref(G_OBJECT(ti)); } Modified: chupatext/chupa_text.h (+3 -3) =================================================================== --- chupatext/chupa_text.h 2010-09-06 07:08:25 +0000 (365937c) +++ chupatext/chupa_text.h 2010-09-07 07:12:38 +0000 (5930bdf) @@ -8,7 +8,7 @@ #include #include -#include "chupatext/chupa_text_input_stream.h" +#include "chupatext/chupa_text_input.h" G_BEGIN_DECLS @@ -40,8 +40,8 @@ struct ChupaTextClass GType chupa_text_get_type(void) G_GNUC_CONST; ChupaText *chupa_text_new(void); -void chupa_text_feed(ChupaText *chupar, GInputStream *stream); -void chupa_text_decomposed(ChupaText *chupar, ChupaTextInputStream *stream); +void chupa_text_feed(ChupaText *chupar, ChupaTextInput *input); +void chupa_text_decomposed(ChupaText *chupar, ChupaTextInput *input); guint chupa_text_connect_decomposed(ChupaText *chupar, GCallback *func, gpointer arg); #endif Added: chupatext/chupa_text_input.c (+339 -0) 100644 =================================================================== --- /dev/null +++ chupatext/chupa_text_input.c 2010-09-07 07:12:38 +0000 (2617a36) @@ -0,0 +1,339 @@ +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Copyright (C) 2010 Nobuyoshi Nakada + */ + +#include "chupatext/chupa_text_input.h" +#include "chupatext/chupa_text_input_stream.h" +#include +#include + +#define INPUT_STREAM_FILE_TYPE input_stream_file_get_type() +#define INPUT_STREAM_FILE(obj) \ + G_TYPE_CHECK_INSTANCE_CAST(obj, INPUT_STREAM_FILE_TYPE, InputStreamFile) +#define INPUT_STREAM_FILE_CLASS(klass) \ + G_TYPE_CHECK_CLASS_CAST(klass, INPUT_STREAM_FILE_TYPE, InputStreamFileClass) +#define IS_INPUT_STREAM_FILE(obj) \ + G_TYPE_CHECK_INSTANCE_TYPE(obj, INPUT_STREAM_FILE_TYPE) +#define IS_INPUT_STREAM_FILE_CLASS(klass) \ + G_TYPE_CHECK_CLASS_TYPE(klass, INPUT_STREAM_FILE_TYPE) +#define INPUT_STREAM_FILE_GET_CLASS(obj) \ + G_TYPE_INSTANCE_GET_CLASS(obj, INPUT_STREAM_FILE_TYPE, InputStreamFileClass) + +typedef struct { + GObject parent_instance; + + char *path; + GInputStream *stream; +} InputStreamFile; + +typedef struct { + GObjectClass parent_class; +} InputStreamFileClass; + +static void input_stream_file_file_iface_init(GFileIface *iface); + +G_DEFINE_TYPE_WITH_CODE(InputStreamFile, input_stream_file, G_TYPE_OBJECT, + G_IMPLEMENT_INTERFACE(G_TYPE_FILE, + input_stream_file_file_iface_init)) + +static void +input_stream_file_finalize(GObject *object) +{ + InputStreamFile *isfile = (InputStreamFile *)object; + g_object_unref(isfile->stream); +} + +static GFileInputStream * +input_stream_file_read(GFile *file, GCancellable *cancellable, GError **error) +{ + InputStreamFile *isfile = (InputStreamFile *)file; + return g_object_ref(isfile->stream); +} + +static GFileInfo * +input_stream_file_query_info(GFile *file, const char *attributes, + GFileQueryInfoFlags flags, + GCancellable *cancellable, GError **error) +{ + InputStreamFile *isfile = (InputStreamFile *)file; + GFileInfo *info = NULL; + GSeekable *sk; + goffset size, curpos; + if (strcmp(attributes, G_FILE_ATTRIBUTE_STANDARD_NAME) == 0) { + info = g_file_info_new(); + g_file_info_set_attribute_string(info, attributes, isfile->path); + } + else if (strcmp(attributes, G_FILE_ATTRIBUTE_STANDARD_SIZE) == 0 && + G_IS_SEEKABLE(isfile->stream) && + g_seekable_can_seek(sk = G_SEEKABLE(isfile->stream)) && + (curpos = g_seekable_tell(sk), + g_seekable_seek(sk, (goffset)0, G_SEEK_END, NULL, NULL))) { + size = g_seekable_tell(sk); + g_seekable_seek(sk, curpos, G_SEEK_SET, NULL, NULL); + info = g_file_info_new(); + g_file_info_set_attribute_uint64(info, attributes, size); + } + return info; +} + +static GFile * +input_stream_file_dup(GFile *file) +{ + return g_object_ref(file); +} + +static void +input_stream_file_init(InputStreamFile *isfile) +{ + isfile->path = NULL; + isfile->stream = NULL; +} + +static void +input_stream_file_class_init(InputStreamFileClass *klass) +{ + GObjectClass *gobject_class = G_OBJECT_CLASS(klass); + + gobject_class->finalize = input_stream_file_finalize; +} + +static void +input_stream_file_file_iface_init(GFileIface *iface) +{ + iface->dup = input_stream_file_dup; + iface->query_info = input_stream_file_query_info; + iface->read_fn = input_stream_file_read; +} + +GFile * +input_stream_file_new(const char *path, GInputStream *stream) +{ + InputStreamFile *isfile = g_object_new(INPUT_STREAM_FILE_TYPE, NULL); + isfile->path = g_strdup(path); + rb_object_ref(isfile->stream = stream); + return G_FILE(isfile); +} + + +/* ChupaTextInput */ +G_DEFINE_TYPE(ChupaTextInput, chupa_text_input, GSF_INPUT_TYPE) + +#define CHUPA_TEXT_INPUT_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE((obj), \ + CHUPA_TYPE_TEXT_INPUT, \ + ChupaTextInputPrivate)) + +typedef struct _ChupaTextInputPrivate ChupaTextInputPrivate; + +struct _ChupaTextInputPrivate +{ + GsfInput *input; + ChupaMetadata *metadata; + GDataInputStream *stream; +}; + +enum { + PROP_0, + PROP_INPUT, + PROP_METADATA, + PROP_DUMMY +}; + +enum { + peek_buffer_size = 1024 +}; + +static const char * +guess_mime_type(const char *name, GBufferedInputStream *buffered, gboolean *uncertain) +{ + const char *content_type; + gsize len; + const char *buf; + + g_buffered_input_stream_fill(buffered, peek_buffer_size, NULL, NULL); + buf = g_buffered_input_stream_peek_buffer(buffered, &len); + content_type = g_content_type_guess(name, buf, len, uncertain); + return g_content_type_get_mime_type(content_type); +} + +static void +chupa_text_input_init(ChupaTextInput *input) +{ + ChupaTextInputPrivate *priv; + + priv = CHUPA_TEXT_INPUT_GET_PRIVATE(input); + priv->stream = NULL; + priv->metadata = NULL; +} + +static void +constructed(GObject *object) +{ + ChupaTextInput *input = CHUPA_TEXT_INPUT(object); + ChupaTextInputPrivate *priv = CHUPA_TEXT_INPUT_GET_PRIVATE(input); + const gchar *mime_type; + GInputStream *stream; + + if (!priv->metadata) { + priv->metadata = chupa_metadata_new(); + } + stream = G_INPUT_STREAM(chupa_text_input_stream_new(input)); + if (G_IS_DATA_INPUT_STREAM(stream)) { + priv->stream = G_DATA_INPUT_STREAM(stream); + } + else { + priv->stream = g_data_input_stream_new(stream); + } + + mime_type = guess_mime_type(gsf_input_name(GSF_INPUT(input)), + G_BUFFERED_INPUT_STREAM(priv->stream), + NULL); + chupa_metadata_replace_value(priv->metadata, "mime-type", mime_type); +} + +static void +dispose(GObject *object) +{ + ChupaTextInputPrivate *priv; + + priv = CHUPA_TEXT_INPUT_GET_PRIVATE(object); + if (priv->metadata) { + g_object_unref(priv->metadata); + priv->metadata = NULL; + } + + G_OBJECT_CLASS(chupa_text_input_parent_class)->dispose(object); +} + +static void +set_property(GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) +{ + ChupaTextInputPrivate *priv; + GObject *obj; + + priv = CHUPA_TEXT_INPUT_GET_PRIVATE(object); + switch (prop_id) { + case PROP_INPUT: + obj = g_value_dup_object(value); + priv->input = GSF_INPUT(obj); + break; + case PROP_METADATA: + obj = g_value_dup_object(value); + priv->metadata = CHUPA_METADATA(obj); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + break; + } +} + +static void +get_property(GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ + ChupaTextInputPrivate *priv; + + priv = CHUPA_TEXT_INPUT_GET_PRIVATE(object); + switch (prop_id) { + case PROP_INPUT: + g_value_set_object(value, priv->stream); + break; + case PROP_METADATA: + g_value_set_object(value, priv->metadata); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + break; + } +} + +static void +chupa_text_input_class_init(ChupaTextInputClass *klass) +{ + GObjectClass *gobject_class = G_OBJECT_CLASS(klass); + GParamSpec *spec; + + gobject_class->constructed = constructed; + gobject_class->dispose = dispose; + gobject_class->set_property = set_property; + gobject_class->get_property = get_property; + + spec = g_param_spec_object("input", + "Input", + "Input", + GSF_INPUT_TYPE, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS); + g_object_class_install_property(gobject_class, PROP_INPUT, spec); + + spec = g_param_spec_object("metadata", + "Metadata", + "Metadata of the input", + CHUPA_TYPE_METADATA, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS); + g_object_class_install_property(gobject_class, PROP_METADATA, spec); + + g_type_class_add_private(gobject_class, sizeof(ChupaTextInputPrivate)); +} + +ChupaTextInput * +chupa_text_input_new(ChupaMetadata *metadata, GsfInput *input) +{ + return g_object_new(CHUPA_TYPE_TEXT_INPUT, + "input", input, + "metadata", metadata, + NULL); +} + +ChupaTextInput * +chupa_text_input_new_from_stream(ChupaMetadata *metadata, GInputStream *stream, const char *path) +{ + ChupaTextInput *text; + GFile *file = input_stream_file_new(path, stream); + GsfInput *input = gsf_input_gio_new(file, NULL); + g_object_unref(file); + text = chupa_text_input_new(metadata, input); + g_object_unref(input); + return text; +} + +GsfInput * +chupa_text_input_get_base_input(ChupaTextInput *input) +{ + ChupaTextInputPrivate *priv; + + priv = CHUPA_TEXT_INPUT_GET_PRIVATE(input); + return priv->input; +} + +GInputStream * +chupa_text_input_get_stream(ChupaTextInput *input) +{ + ChupaTextInputPrivate *priv; + + priv = CHUPA_TEXT_INPUT_GET_PRIVATE(input); + return G_INPUT_STREAM(priv->stream); +} + +ChupaMetadata * +chupa_text_input_get_metadata(ChupaTextInput *input) +{ + ChupaTextInputPrivate *priv; + + priv = CHUPA_TEXT_INPUT_GET_PRIVATE(input); + return priv->metadata; +} + +const gchar * +chupa_text_input_get_mime_type(ChupaTextInput *input) +{ + ChupaMetadata *meta = chupa_text_input_get_metadata(input); + return chupa_metadata_get_first_value(meta, "mime-type"); +} Added: chupatext/chupa_text_input.h (+61 -0) 100644 =================================================================== --- /dev/null +++ chupatext/chupa_text_input.h 2010-09-07 07:12:38 +0000 (a7e78cb) @@ -0,0 +1,61 @@ +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Copyright (C) 2010 Nobuyoshi Nakada + */ + +#ifndef CHUPA_TEXT_INPUT_H +#define CHUPA_TEXT_INPUT_H + +#include +#include +#include +#include +#include +#include "chupatext/chupa_metadata.h" + +G_BEGIN_DECLS + +#define CHUPA_TYPE_TEXT_INPUT chupa_text_input_get_type() +#define CHUPA_TEXT_INPUT(obj) \ + G_TYPE_CHECK_INSTANCE_CAST(obj, CHUPA_TYPE_TEXT_INPUT, ChupaTextInput) +#define CHUPA_TEXT_INPUT_CLASS(klass) \ + G_TYPE_CHECK_CLASS_CAST(klass, CHUPA_TYPE_TEXT_INPUT, ChupaTextInputClass) +#define CHUPA_IS_TEXT_INPUT(obj) \ + G_TYPE_CHECK_INSTANCE_TYPE(obj, CHUPA_TYPE_TEXT_INPUT) +#define CHUPA_IS_TEXT_INPUT_CLASS(klass) \ + G_TYPE_CHECK_CLASS_TYPE(klass, CHUPA_TYPE_TEXT_INPUT) +#define CHUPA_TEXT_INPUT_GET_CLASS(obj) \ + G_TYPE_INSTANCE_GET_CLASS(obj, CHUPA_TYPE_TEXT_INPUT, ChupaTextInputClass) + +typedef struct _ChupaTextInput ChupaTextInput; +typedef struct _ChupaTextInputClass ChupaTextInputClass; + +struct _ChupaTextInput +{ + struct { + GsfInput input; + GFile *file; + GInputStream *stream; + guint8 *buf; + size_t buf_size; + } object; +}; + +struct _ChupaTextInputClass +{ + struct { + GsfInputClass input_class; + } parent_class; +}; + +GType chupa_text_input_get_type(void) G_GNUC_CONST; +ChupaTextInput *chupa_text_input_new(ChupaMetadata *metadata, GsfInput *inpt); +ChupaTextInput *chupa_text_input_new_from_stream(ChupaMetadata *metadata, GInputStream *stream, const char *path); +ChupaMetadata *chupa_text_input_get_metadata(ChupaTextInput *input); +const gchar *chupa_text_input_get_mime_type(ChupaTextInput *input); +GsfInput *chupa_text_input_get_base_input(ChupaTextInput *input); +GInputStream *chupa_text_input_get_stream(ChupaTextInput *input); + +G_END_DECLS + +#endif /* CHUPA_TEXT_INPUT_H */ Modified: chupatext/chupa_text_input_stream.c (+67 -88) =================================================================== --- chupatext/chupa_text_input_stream.c 2010-09-06 07:08:25 +0000 (0883ae4) +++ chupatext/chupa_text_input_stream.c 2010-09-07 07:12:38 +0000 (b6ddbc6) @@ -16,12 +16,12 @@ typedef struct _ChupaTextInputStreamPrivate ChupaTextInputStreamPrivate; struct _ChupaTextInputStreamPrivate { - ChupaMetadata *metadata; + ChupaTextInput *input; }; enum { PROP_0, - PROP_METADATA, + PROP_INPUT, PROP_DUMMY }; @@ -29,58 +29,13 @@ enum { peek_buffer_size = 1024 }; -static const char * -guess_mime_type(ChupaTextInputStream *stream, gboolean *uncertain) -{ - const char *mime_type = NULL; - GInputStream *base; - - base = g_filter_input_stream_get_base_stream(G_FILTER_INPUT_STREAM(stream)); - - if (G_IS_FILE_INPUT_STREAM(base)) { - GFileInfo *info = g_file_input_stream_query_info(G_FILE_INPUT_STREAM(base), - G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE, - NULL, NULL); - const char *content_type = g_file_info_get_content_type(info); - if (content_type) { - mime_type = g_content_type_get_mime_type(content_type); - } - g_object_unref(info); - } - if (!mime_type) { - gsize len; - const char *buf; - GBufferedInputStream *buffered = G_BUFFERED_INPUT_STREAM(stream); - - g_buffered_input_stream_fill(buffered, peek_buffer_size, NULL, NULL); - buf = g_buffered_input_stream_peek_buffer(buffered, &len); - mime_type = g_content_type_get_mime_type(g_content_type_guess(NULL, buf, len, uncertain)); - } - return mime_type; -} - static void chupa_text_input_stream_init(ChupaTextInputStream *stream) { ChupaTextInputStreamPrivate *priv; priv = CHUPA_TEXT_INPUT_STREAM_GET_PRIVATE(stream); - priv->metadata = NULL; -} - -static void -constructed(GObject *object) -{ - ChupaTextInputStream *stream = CHUPA_TEXT_INPUT_STREAM(object); - ChupaTextInputStreamPrivate *priv = CHUPA_TEXT_INPUT_STREAM_GET_PRIVATE(stream); - const gchar *mime_type; - - if (!priv->metadata) { - priv->metadata = chupa_metadata_new(); - } - - mime_type = guess_mime_type(stream, NULL); - chupa_metadata_replace_value(priv->metadata, "mime-type", mime_type); + priv->input = NULL; } static void @@ -89,11 +44,10 @@ dispose(GObject *object) ChupaTextInputStreamPrivate *priv; priv = CHUPA_TEXT_INPUT_STREAM_GET_PRIVATE(object); - if (priv->metadata) { - g_object_unref(priv->metadata); - priv->metadata = NULL; + if (priv->input) { + g_object_unref(priv->input); + priv->input = NULL; } - G_OBJECT_CLASS(chupa_text_input_stream_parent_class)->dispose(object); } @@ -108,9 +62,9 @@ set_property(GObject *object, priv = CHUPA_TEXT_INPUT_STREAM_GET_PRIVATE(object); switch (prop_id) { - case PROP_METADATA: + case PROP_INPUT: obj = g_value_dup_object(value); - priv->metadata = CHUPA_METADATA(obj); + priv->input = CHUPA_TEXT_INPUT(obj); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); @@ -128,8 +82,8 @@ get_property(GObject *object, priv = CHUPA_TEXT_INPUT_STREAM_GET_PRIVATE(object); switch (prop_id) { - case PROP_METADATA: - g_value_set_object(value, priv->metadata); + case PROP_INPUT: + g_value_set_object(value, priv->input); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); @@ -137,55 +91,80 @@ get_property(GObject *object, } } +static gssize +read_fn(GInputStream *stream, void *buffer, gsize count, + GCancellable *cancellable, GError **error) +{ + ChupaTextInputStreamPrivate *priv; + GsfInput *input; + gsf_off_t pos; + + priv = CHUPA_TEXT_INPUT_STREAM_GET_PRIVATE(stream); + input = GSF_INPUT(priv->input); + pos = gsf_input_tell(input); + if (!gsf_input_read(input, count, buffer)) { + return 0; + } + return gsf_input_tell(input) - pos; +} + +static gssize +skip_fn(GInputStream *stream, gsize count, + GCancellable *cancellable, GError **error) +{ + ChupaTextInputStreamPrivate *priv; + GsfInput *input; + + priv = CHUPA_TEXT_INPUT_STREAM_GET_PRIVATE(stream); + input = GSF_INPUT(priv->input); + if (gsf_input_seek(input, count, G_SEEK_CUR)) { + return (gssize)-1; + } + return gsf_input_tell(input); +} + +static gboolean +close_fn(GInputStream *stream, GCancellable *cancellable, GError **error) +{ + ChupaTextInputStreamPrivate *priv; + + priv = CHUPA_TEXT_INPUT_STREAM_GET_PRIVATE(stream); + if (priv->input) { + g_object_unref(priv->input); + priv->input = NULL; + } +} + static void chupa_text_input_stream_class_init(ChupaTextInputStreamClass *klass) { GObjectClass *gobject_class = G_OBJECT_CLASS(klass); + GInputStreamClass *input_stream_class = G_INPUT_STREAM_CLASS(klass); GParamSpec *spec; - gobject_class->constructed = constructed; gobject_class->dispose = dispose; gobject_class->set_property = set_property; gobject_class->get_property = get_property; - - spec = g_param_spec_object("metadata", - "Metadata", - "Metadata of the input stream", - CHUPA_TYPE_METADATA, + input_stream_class->read_fn = read_fn; + input_stream_class->skip = skip_fn; + input_stream_class->close_fn = close_fn; + + spec = g_param_spec_object("input", + "Input", + "Input", + CHUPA_TYPE_TEXT_INPUT, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS); - g_object_class_install_property(gobject_class, PROP_METADATA, spec); + g_object_class_install_property(gobject_class, PROP_INPUT, spec); + g_type_class_add_private(gobject_class, sizeof(ChupaTextInputStreamPrivate)); } ChupaTextInputStream * -chupa_text_input_stream_new(ChupaMetadata *metadata, GInputStream *input) +chupa_text_input_stream_new(ChupaTextInput *input) { - if (CHUPA_IS_TEXT_INPUT_STREAM(input)) { - ChupaTextInputStream *ti = (ChupaTextInputStream *)input; - if (metadata) { - chupa_metadata_merge(chupa_text_input_stream_get_metadata(ti), metadata); - } - return ti; - } return g_object_new(CHUPA_TYPE_TEXT_INPUT_STREAM, - "metadata", metadata, - "base-stream", input, + "input", input, NULL); } -ChupaMetadata * -chupa_text_input_stream_get_metadata(ChupaTextInputStream *stream) -{ - ChupaTextInputStreamPrivate *priv; - - priv = CHUPA_TEXT_INPUT_STREAM_GET_PRIVATE(stream); - return priv->metadata; -} - -const gchar * -chupa_text_input_stream_get_mime_type(ChupaTextInputStream *stream) -{ - ChupaMetadata *meta = chupa_text_input_stream_get_metadata(stream); - return chupa_metadata_get_first_value(meta, "mime-type"); -} Modified: chupatext/chupa_text_input_stream.h (+5 -5) =================================================================== --- chupatext/chupa_text_input_stream.h 2010-09-06 07:08:25 +0000 (d37028e) +++ chupatext/chupa_text_input_stream.h 2010-09-07 07:12:38 +0000 (47c3895) @@ -10,6 +10,7 @@ #include #include #include "chupatext/chupa_metadata.h" +#include "chupatext/chupa_text_input.h" G_BEGIN_DECLS @@ -30,18 +31,17 @@ typedef struct _ChupaTextInputStreamClass ChupaTextInputStreamClass; struct _ChupaTextInputStream { - GDataInputStream object; + GInputStream object; }; struct _ChupaTextInputStreamClass { - GDataInputStreamClass parent_class; + GInputStreamClass parent_class; }; GType chupa_text_input_stream_get_type(void) G_GNUC_CONST; -ChupaTextInputStream *chupa_text_input_stream_new(ChupaMetadata *metadata, GInputStream *input); -ChupaMetadata *chupa_text_input_stream_get_metadata(ChupaTextInputStream *stream); -const gchar *chupa_text_input_stream_get_mime_type(ChupaTextInputStream *stream); +ChupaTextInputStream *chupa_text_input_stream_new(ChupaTextInput *input); +ChupaTextInput *chupa_text_input_stream_get_input(ChupaTextInputStream *stream); G_END_DECLS Modified: chupatext/text_decomposer.c (+2 -2) =================================================================== --- chupatext/text_decomposer.c 2010-09-06 07:08:25 +0000 (1eb93fc) +++ chupatext/text_decomposer.c 2010-09-07 07:12:38 +0000 (b394341) @@ -13,9 +13,9 @@ chupa_text_decomposer_init(ChupaTextDecomposer *text_decomposer) } static void -chupa_text_decomposer_feed(ChupaDecomposer *dec, ChupaText *text, ChupaTextInputStream *stream) +chupa_text_decomposer_feed(ChupaDecomposer *dec, ChupaText *text, ChupaTextInput *input) { - chupa_text_decomposed(text, stream); + chupa_text_decomposed(text, input); } static void Modified: configure.ac (+2 -0) =================================================================== --- configure.ac 2010-09-06 07:08:25 +0000 (5458a96) +++ configure.ac 2010-09-07 07:12:38 +0000 (5529734) @@ -54,6 +54,8 @@ if test "$ac_glib_available" != "yes"; then AC_MSG_ERROR([no glib available]) fi +PKG_CHECK_MODULES(GSF, libgsf-1, [have_gsf=yes], [:]) +AM_CONDITIONAL([HAVE_GSF], [test "$have_gsf" = "yes"]) PKG_CHECK_MODULES(POPPLER_GLIB, poppler-glib, [have_poppler=yes], [:]) AM_CONDITIONAL([HAVE_POPPLER_GLIB], [test "$have_poppler" = "yes"]) PKG_CHECK_MODULES(WV, wv-1.0, [have_wv=yes], [:]) From null+ranguba at clear-code.com Tue Sep 7 03:30:10 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Tue, 07 Sep 2010 07:30:10 +0000 Subject: [groonga-commit:1222] ranguba/chupatext [master] * chupatext/chupa_text_input.c (input_stream_file_new): fix typo. Message-ID: <20100907073021.CC949170E0C@taiyaki.ru> Nobuyoshi Nakada 2010-09-07 07:30:10 +0000 (Tue, 07 Sep 2010) New Revision: fdd5f44f2adaff22e928a2d80fc63d24f41509e6 Log: * chupatext/chupa_text_input.c (input_stream_file_new): fix typo. Modified files: chupatext/chupa_text_input.c Modified: chupatext/chupa_text_input.c (+1 -1) =================================================================== --- chupatext/chupa_text_input.c 2010-09-07 07:12:38 +0000 (2617a36) +++ chupatext/chupa_text_input.c 2010-09-07 07:30:10 +0000 (d7e386d) @@ -111,7 +111,7 @@ input_stream_file_new(const char *path, GInputStream *stream) { InputStreamFile *isfile = g_object_new(INPUT_STREAM_FILE_TYPE, NULL); isfile->path = g_strdup(path); - rb_object_ref(isfile->stream = stream); + g_object_ref(isfile->stream = stream); return G_FILE(isfile); } From null+ranguba at clear-code.com Wed Sep 8 22:44:25 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Thu, 09 Sep 2010 02:44:25 +0000 Subject: [groonga-commit:1223] ranguba/chupatext [master] * Makefile.am (echo-cutter): moved from test/Makefile.am. Message-ID: <20100909080736.9F5AB1704C0@taiyaki.ru> Nobuyoshi Nakada 2010-09-09 02:44:25 +0000 (Thu, 09 Sep 2010) New Revision: a022d69e633c223d6b69b6beda3a6cb948481dc2 Log: * Makefile.am (echo-cutter): moved from test/Makefile.am. Modified files: Makefile.am test/Makefile.am Modified: Makefile.am (+3 -0) =================================================================== --- Makefile.am 2010-09-07 07:30:10 +0000 (074cf76) +++ Makefile.am 2010-09-09 02:44:25 +0000 (796de74) @@ -4,4 +4,7 @@ SUBDIRS = chupatext test module all-recursive: update-version.h +echo-cutter: + @echo $(CUTTER) + include prereq.mk Modified: test/Makefile.am (+0 -3) =================================================================== --- test/Makefile.am 2010-09-07 07:30:10 +0000 (262fc06) +++ test/Makefile.am 2010-09-09 02:44:25 +0000 (fa2f432) @@ -57,6 +57,3 @@ test_decomposer_la_SOURCES = test_decomposer.c test_restrict_input_stream_la_SOURCES = test_restrict_input_stream.c test_pdf_la_SOURCES = test_pdf.c test_msword_la_SOURCES = test_msword.c - -echo-cutter: - @echo $(CUTTER) From null+ranguba at clear-code.com Thu Sep 9 02:42:10 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Thu, 09 Sep 2010 06:42:10 +0000 Subject: [groonga-commit:1224] ranguba/chupatext [master] * chupatext/chupa_text_input.h (ChupaTextInput): no longer inherits GsfInput. Message-ID: <20100909080736.C8238278002@taiyaki.ru> Nobuyoshi Nakada 2010-09-09 06:42:10 +0000 (Thu, 09 Sep 2010) New Revision: 259b40c4b4e2fae2ace65cd39fb2ff920c69da7f Log: * chupatext/chupa_text_input.h (ChupaTextInput): no longer inherits GsfInput. Modified files: chupatext/chupa_text_input.c chupatext/chupa_text_input.h chupatext/chupa_text_input_stream.c Modified: chupatext/chupa_text_input.c (+2 -2) =================================================================== --- chupatext/chupa_text_input.c 2010-09-09 06:41:21 +0000 (d7e386d) +++ chupatext/chupa_text_input.c 2010-09-09 06:42:10 +0000 (118a791) @@ -117,7 +117,7 @@ input_stream_file_new(const char *path, GInputStream *stream) /* ChupaTextInput */ -G_DEFINE_TYPE(ChupaTextInput, chupa_text_input, GSF_INPUT_TYPE) +G_DEFINE_TYPE(ChupaTextInput, chupa_text_input, G_TYPE_OBJECT) #define CHUPA_TEXT_INPUT_GET_PRIVATE(obj) \ (G_TYPE_INSTANCE_GET_PRIVATE((obj), \ @@ -186,7 +186,7 @@ constructed(GObject *object) priv->stream = g_data_input_stream_new(stream); } - mime_type = guess_mime_type(gsf_input_name(GSF_INPUT(input)), + mime_type = guess_mime_type(gsf_input_name(priv->input), G_BUFFERED_INPUT_STREAM(priv->stream), NULL); chupa_metadata_replace_value(priv->metadata, "mime-type", mime_type); Modified: chupatext/chupa_text_input.h (+2 -10) =================================================================== --- chupatext/chupa_text_input.h 2010-09-09 06:41:21 +0000 (a7e78cb) +++ chupatext/chupa_text_input.h 2010-09-09 06:42:10 +0000 (fcf0f09) @@ -32,20 +32,12 @@ typedef struct _ChupaTextInputClass ChupaTextInputClass; struct _ChupaTextInput { - struct { - GsfInput input; - GFile *file; - GInputStream *stream; - guint8 *buf; - size_t buf_size; - } object; + GObject parent_instance; }; struct _ChupaTextInputClass { - struct { - GsfInputClass input_class; - } parent_class; + GObjectClass parent_class; }; GType chupa_text_input_get_type(void) G_GNUC_CONST; Modified: chupatext/chupa_text_input_stream.c (+2 -2) =================================================================== --- chupatext/chupa_text_input_stream.c 2010-09-09 06:41:21 +0000 (2b70cc0) +++ chupatext/chupa_text_input_stream.c 2010-09-09 06:42:10 +0000 (76aae6e) @@ -100,7 +100,7 @@ read_fn(GInputStream *stream, void *buffer, gsize count, gsf_off_t pos; priv = CHUPA_TEXT_INPUT_STREAM_GET_PRIVATE(stream); - input = GSF_INPUT(priv->input); + input = chupa_text_input_get_base_input(priv->input); pos = gsf_input_tell(input); if (!gsf_input_read(input, count, buffer)) { return 0; @@ -116,7 +116,7 @@ skip_fn(GInputStream *stream, gsize count, GsfInput *input; priv = CHUPA_TEXT_INPUT_STREAM_GET_PRIVATE(stream); - input = GSF_INPUT(priv->input); + input = chupa_text_input_get_base_input(priv->input); if (gsf_input_seek(input, count, G_SEEK_CUR)) { return (gssize)-1; } From null+ranguba at clear-code.com Thu Sep 9 03:58:03 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Thu, 09 Sep 2010 07:58:03 +0000 Subject: [groonga-commit:1225] ranguba/chupatext [master] * chupatext/chupa_text.c (chupa_text_connect_decomposed): helper function. Message-ID: <20100909080736.DEECC278004@taiyaki.ru> Nobuyoshi Nakada 2010-09-09 07:58:03 +0000 (Thu, 09 Sep 2010) New Revision: 7fa21fd7eaaa207a2c2757646c21f04412be0410 Log: * chupatext/chupa_text.c (chupa_text_connect_decomposed): helper function. Added files: test/test_text_input.c Modified files: chupatext/chupa_text.c chupatext/chupa_text.h test/test_msword.c test/test_pdf.c test/test_text.c Modified: chupatext/chupa_text.c (+6 -0) =================================================================== --- chupatext/chupa_text.c 2010-09-09 07:32:27 +0000 (dcbc659) +++ chupatext/chupa_text.c 2010-09-09 07:58:03 +0000 (3bd66a2) @@ -68,6 +68,12 @@ chupa_text_decomposed(ChupaText *chupar, ChupaTextInput *input) g_signal_emit_by_name(chupar, chupa_text_signal_decomposed, input); } +guint +chupa_text_connect_decomposed(ChupaText *chupar, ChupaTextCallback func, gpointer arg) +{ + return g_signal_connect(chupar, chupa_text_signal_decomposed, (GCallback)func, arg); +} + void chupa_text_feed(ChupaText *chupar, ChupaTextInput *input) { Modified: chupatext/chupa_text.h (+2 -1) =================================================================== --- chupatext/chupa_text.h 2010-09-09 07:32:27 +0000 (5930bdf) +++ chupatext/chupa_text.h 2010-09-09 07:58:03 +0000 (45b6358) @@ -38,10 +38,11 @@ struct ChupaTextClass void (*decomposed)(GObject *object, GInputStream *stream); }; +typedef void (*ChupaTextCallback)(ChupaText *, ChupaTextInput *, gpointer); GType chupa_text_get_type(void) G_GNUC_CONST; ChupaText *chupa_text_new(void); void chupa_text_feed(ChupaText *chupar, ChupaTextInput *input); void chupa_text_decomposed(ChupaText *chupar, ChupaTextInput *input); -guint chupa_text_connect_decomposed(ChupaText *chupar, GCallback *func, gpointer arg); +guint chupa_text_connect_decomposed(ChupaText *chupar, ChupaTextCallback func, gpointer arg); #endif Modified: test/test_msword.c (+1 -1) =================================================================== --- test/test_msword.c 2010-09-09 07:32:27 +0000 (5c4f5c9) +++ test/test_msword.c 2010-09-09 07:58:03 +0000 (5fc490d) @@ -68,7 +68,7 @@ void test_decompose_msword(void) { chupar = chupa_text_new(); - g_signal_connect(chupar, chupa_text_signal_decomposed, (GCallback)text_decomposed, &read_data); + chupa_text_connect_decomposed(chupar, text_decomposed, &read_data); sample_path = cut_build_fixture_data_path("sample.doc", NULL); sample_file = g_file_new_for_path(sample_path); text_input = chupa_text_input_new_from_file(NULL, sample_file); Modified: test/test_pdf.c (+1 -1) =================================================================== --- test/test_pdf.c 2010-09-09 07:32:27 +0000 (5262cf1) +++ test/test_pdf.c 2010-09-09 07:58:03 +0000 (790c88b) @@ -64,7 +64,7 @@ void test_decompose_pdf(void) { chupar = chupa_text_new(); - g_signal_connect(chupar, chupa_text_signal_decomposed, (GCallback)text_decomposed, &read_data); + chupa_text_connect_decomposed(chupar, text_decomposed, &read_data); sample_path = cut_build_fixture_data_path("sample.pdf", NULL); sample_file = g_file_new_for_path(sample_path); text_input = chupa_text_input_new_from_file(NULL, sample_file); Modified: test/test_text.c (+1 -1) =================================================================== --- test/test_text.c 2010-09-09 07:32:27 +0000 (9937bfb) +++ test/test_text.c 2010-09-09 07:58:03 +0000 (a30cda8) @@ -55,7 +55,7 @@ test_decompose_text_plain (void) source = mem; input = chupa_text_input_new_from_stream(NULL, source, NULL); chupar = chupa_text_new(); - g_signal_connect(chupar, chupa_text_signal_decomposed, (GCallback)text_decomposed, &read_data); + chupa_text_connect_decomposed(chupar, text_decomposed, &read_data); chupa_text_feed(chupar, input); cut_assert_equal_string(plain_text, read_data); } Added: test/test_text_input.c (+52 -0) 100644 =================================================================== --- /dev/null +++ test/test_text_input.c 2010-09-09 07:58:03 +0000 (a47eccb) @@ -0,0 +1,52 @@ +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Copyright (C) 2010 Nobuyoshi Nakada + */ + +#include + +#include + +void test_new (void); +void test_new_with_metadata (void); + +static ChupaTextInput *input; + +void +setup (void) +{ + input = NULL; +} + +void +teardown (void) +{ + if (input) + g_object_unref(input); +} + +void +test_new (void) +{ + ChupaMetadata *meta; + GInputStream *memstream = g_memory_input_stream_new(); + input = chupa_text_input_new_from_stream(NULL, memstream, NULL); + meta = chupa_text_input_get_metadata(input); + cut_assert_not_null(meta); + cut_assert_equal_int(1, chupa_metadata_size(meta)); + cut_assert_not_null(chupa_metadata_get_first_value(meta, "mime-type")); +} + +void +test_new_with_metadata (void) +{ + ChupaMetadata *meta = chupa_metadata_new(); + GInputStream *memstream = g_memory_input_stream_new(); + input = chupa_text_input_new_from_stream(meta, memstream, NULL); + gcut_assert_equal_object(meta, chupa_text_input_get_metadata(input)); + cut_assert_equal_uint(1, chupa_metadata_size(meta)); +} + +/* +vi:ts=4:nowrap:ai:expandtab:sw=4 +*/ From null+ranguba at clear-code.com Thu Sep 9 04:03:56 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Thu, 09 Sep 2010 08:03:56 +0000 Subject: [groonga-commit:1226] ranguba/chupatext [master] * chupatext/chupa_text_input_stream.c (read_fn): calculate readble length in advance, since gsf_input_read() fails when trying to read longer than remaining. Message-ID: <20100909080736.E95B6278005@taiyaki.ru> Nobuyoshi Nakada 2010-09-09 08:03:56 +0000 (Thu, 09 Sep 2010) New Revision: 21bd0ac966b6670561f2e51b7913fe6adbf14795 Log: * chupatext/chupa_text_input_stream.c (read_fn): calculate readble length in advance, since gsf_input_read() fails when trying to read longer than remaining. Modified files: chupatext/chupa_text_input.c chupatext/chupa_text_input_stream.c Modified: chupatext/chupa_text_input.c (+4 -2) =================================================================== --- chupatext/chupa_text_input.c 2010-09-09 07:58:03 +0000 (0eb0336) +++ chupatext/chupa_text_input.c 2010-09-09 08:03:56 +0000 (1cf1c4b) @@ -61,8 +61,10 @@ input_stream_file_query_info(GFile *file, const char *attributes, GSeekable *sk; goffset size, curpos; if (strcmp(attributes, G_FILE_ATTRIBUTE_STANDARD_NAME) == 0) { - info = g_file_info_new(); - g_file_info_set_attribute_string(info, attributes, isfile->path); + if (isfile->path) { + info = g_file_info_new(); + g_file_info_set_attribute_byte_string(info, attributes, isfile->path); + } } else if (strcmp(attributes, G_FILE_ATTRIBUTE_STANDARD_SIZE) == 0 && G_IS_SEEKABLE(isfile->stream) && Modified: chupatext/chupa_text_input_stream.c (+6 -3) =================================================================== --- chupatext/chupa_text_input_stream.c 2010-09-09 07:58:03 +0000 (76aae6e) +++ chupatext/chupa_text_input_stream.c 2010-09-09 08:03:56 +0000 (e417ac4) @@ -97,15 +97,18 @@ read_fn(GInputStream *stream, void *buffer, gsize count, { ChupaTextInputStreamPrivate *priv; GsfInput *input; - gsf_off_t pos; + gsf_off_t remaining; priv = CHUPA_TEXT_INPUT_STREAM_GET_PRIVATE(stream); input = chupa_text_input_get_base_input(priv->input); - pos = gsf_input_tell(input); + remaining = gsf_input_remaining(input); + if (count > remaining) { + count = remaining; + } if (!gsf_input_read(input, count, buffer)) { return 0; } - return gsf_input_tell(input) - pos; + return remaining; } static gssize From null+ranguba at clear-code.com Thu Sep 9 04:17:08 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Thu, 09 Sep 2010 08:17:08 +0000 Subject: [groonga-commit:1227] ranguba/chupatext [master] * configure.ac: requires cutter 1.1.5 or later. Message-ID: <20100909081720.EC592278004@taiyaki.ru> Nobuyoshi Nakada 2010-09-09 08:17:08 +0000 (Thu, 09 Sep 2010) New Revision: 12f9702c30af8f14e3b57e855ae6602e53dff001 Log: * configure.ac: requires cutter 1.1.5 or later. Modified files: configure.ac test/test_msword.c test/test_pdf.c Modified: configure.ac (+1 -1) =================================================================== --- configure.ac 2010-09-09 08:07:48 +0000 (5529734) +++ configure.ac 2010-09-09 08:17:08 +0000 (adf5b5d) @@ -65,7 +65,7 @@ dnl ************************************************************** dnl Check for Cutter dnl ************************************************************** m4_ifdef([AC_CHECK_GCUTTER], [ -AC_CHECK_GCUTTER(>= 1.1.4) +AC_CHECK_GCUTTER(>= 1.1.5) ], [ac_cv_use_cutter="no"]) Modified: test/test_msword.c (+0 -7) =================================================================== --- test/test_msword.c 2010-09-09 08:07:48 +0000 (5fc490d) +++ test/test_msword.c 2010-09-09 08:17:08 +0000 (0804317) @@ -16,13 +16,6 @@ static gchar *sample_path; static GFile *sample_file; static gchar *read_data; -#if !CUTTER_CHECK_VERSION(1, 1, 5) -#define cut_get_source_directory() \ - cut_run_context_get_source_directory( \ - cut_test_context_get_run_context( \ - cut_get_current_test_context())) -#endif - void setup(void) { Modified: test/test_pdf.c (+0 -7) =================================================================== --- test/test_pdf.c 2010-09-09 08:07:48 +0000 (790c88b) +++ test/test_pdf.c 2010-09-09 08:17:08 +0000 (84bf9da) @@ -15,13 +15,6 @@ static gchar *sample_path; static GFile *sample_file; static gchar *read_data; -#if !CUTTER_CHECK_VERSION(1, 1, 5) -#define cut_get_source_directory() \ - cut_run_context_get_source_directory( \ - cut_test_context_get_run_context( \ - cut_get_current_test_context())) -#endif - void setup(void) { From null+ranguba at clear-code.com Thu Sep 9 03:32:27 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Thu, 09 Sep 2010 07:32:27 +0000 Subject: [groonga-commit:1228] ranguba/chupatext [master] * chupatext/chupa_text.c (chupa_text_class_init), (chupa_text_decomposed): send ChupaTextInput instead of GInputStream. Message-ID: <20100909080736.D283A278003@taiyaki.ru> Nobuyoshi Nakada 2010-09-09 07:32:27 +0000 (Thu, 09 Sep 2010) New Revision: 43fbc62c21abfe56add40877d765f3e700781fc0 Log: * chupatext/chupa_text.c (chupa_text_class_init), (chupa_text_decomposed): send ChupaTextInput instead of GInputStream. * chupatext/chupa_text_input.c (chupa_text_input_new_from_file): new function. Modified files: chupatext/chupa_text.c chupatext/chupa_text_input.c chupatext/chupa_text_input.h module/chupa_msword.c module/chupa_pdf.c test/Makefile.am test/test_msword.c test/test_pdf.c test/test_text.c test/test_text_input_stream.c Modified: chupatext/chupa_text.c (+2 -3) =================================================================== --- chupatext/chupa_text.c 2010-09-09 06:42:10 +0000 (7faaaaf) +++ chupatext/chupa_text.c 2010-09-09 07:32:27 +0000 (dcbc659) @@ -40,7 +40,7 @@ chupa_text_class_init(ChupaTextClass *klass) G_STRUCT_OFFSET(ChupaTextClass, decomposed), NULL, NULL, g_cclosure_marshal_VOID__OBJECT, - G_TYPE_NONE, 1, G_TYPE_INPUT_STREAM); + G_TYPE_NONE, 1, CHUPA_TYPE_TEXT_INPUT); } static void @@ -65,8 +65,7 @@ chupa_text_new(void) void chupa_text_decomposed(ChupaText *chupar, ChupaTextInput *input) { - GInputStream *stream = chupa_text_input_get_stream(input); - g_signal_emit_by_name(chupar, chupa_text_signal_decomposed, stream); + g_signal_emit_by_name(chupar, chupa_text_signal_decomposed, input); } void Modified: chupatext/chupa_text_input.c (+10 -0) =================================================================== --- chupatext/chupa_text_input.c 2010-09-09 06:42:10 +0000 (118a791) +++ chupatext/chupa_text_input.c 2010-09-09 07:32:27 +0000 (0eb0336) @@ -304,6 +304,16 @@ chupa_text_input_new_from_stream(ChupaMetadata *metadata, GInputStream *stream, return text; } +ChupaTextInput * +chupa_text_input_new_from_file(ChupaMetadata *metadata, GFile *file) +{ + ChupaTextInput *text; + GsfInput *input = gsf_input_gio_new(file, NULL); + text = chupa_text_input_new(metadata, input); + g_object_unref(input); + return text; +} + GsfInput * chupa_text_input_get_base_input(ChupaTextInput *input) { Modified: chupatext/chupa_text_input.h (+1 -0) =================================================================== --- chupatext/chupa_text_input.h 2010-09-09 06:42:10 +0000 (fcf0f09) +++ chupatext/chupa_text_input.h 2010-09-09 07:32:27 +0000 (35a8a05) @@ -43,6 +43,7 @@ struct _ChupaTextInputClass GType chupa_text_input_get_type(void) G_GNUC_CONST; ChupaTextInput *chupa_text_input_new(ChupaMetadata *metadata, GsfInput *inpt); ChupaTextInput *chupa_text_input_new_from_stream(ChupaMetadata *metadata, GInputStream *stream, const char *path); +ChupaTextInput *chupa_text_input_new_from_file(ChupaMetadata *metadata, GFile *file); ChupaMetadata *chupa_text_input_get_metadata(ChupaTextInput *input); const gchar *chupa_text_input_get_mime_type(ChupaTextInput *input); GsfInput *chupa_text_input_get_base_input(ChupaTextInput *input); Modified: module/chupa_msword.c (+2 -2) =================================================================== --- module/chupa_msword.c 2010-09-09 06:42:10 +0000 (5242251) +++ module/chupa_msword.c 2010-09-09 07:32:27 +0000 (d03e48b) @@ -37,9 +37,9 @@ struct _ChupaMSWORDDecomposerClass static GType chupa_type_msword_decomposer = 0; static void -chupa_msword_decomposer_feed(ChupaDecomposer *dec, ChupaText *chupar, ChupaTextInputStream *stream) +chupa_msword_decomposer_feed(ChupaDecomposer *dec, ChupaText *chupar, ChupaTextInput *input) { - GInputStream *input = G_INPUT_STREAM(stream); + GsfInput *gi = chupa_text_input_get_base_input(input); } static void Modified: module/chupa_pdf.c (+8 -4) =================================================================== --- module/chupa_pdf.c 2010-09-09 06:42:10 +0000 (3e5be87) +++ module/chupa_pdf.c 2010-09-09 07:32:27 +0000 (1c0eaa3) @@ -36,7 +36,7 @@ struct _ChupaPDFDecomposerClass static GType chupa_type_pdf_decomposer = 0; static void -chupa_pdf_decomposer_feed(ChupaDecomposer *dec, ChupaText *chupar, ChupaTextInputStream *stream) +chupa_pdf_decomposer_feed(ChupaDecomposer *dec, ChupaText *chupar, ChupaTextInput *input) { PopplerDocument *doc; GError **error = NULL; @@ -45,8 +45,10 @@ chupa_pdf_decomposer_feed(ChupaDecomposer *dec, ChupaText *chupar, ChupaTextInpu gchar buffer[16*1024]; const gsize bufsize = sizeof(buffer); GString *str = g_string_sized_new(sizeof(buffer)); - GInputStream *inp = G_INPUT_STREAM(stream); - ChupaMetadata *meta = chupa_text_input_stream_get_metadata(stream); + GInputStream *inp = chupa_text_input_get_stream(input); + ChupaMetadata *meta = chupa_text_input_get_metadata(input); + ChupaTextInput *pdf_text = NULL; + const char *name = gsf_input_name(chupa_text_input_get_base_input(input)); int n, i; while ((count = g_input_stream_read(inp, buffer, bufsize, NULL, NULL)) > 0) { @@ -78,7 +80,8 @@ chupa_pdf_decomposer_feed(ChupaDecomposer *dec, ChupaText *chupar, ChupaTextInpu } else { inp = g_memory_input_stream_new_from_data(text, -1, g_free); - chupa_text_decomposed(chupar, chupa_text_input_stream_new(meta, inp)); + pdf_text = chupa_text_input_new_from_stream(meta, inp, name); + chupa_text_decomposed(chupar, pdf_text); mem = (GMemoryInputStream *)inp; } g_object_unref(page); @@ -86,6 +89,7 @@ chupa_pdf_decomposer_feed(ChupaDecomposer *dec, ChupaText *chupar, ChupaTextInpu g_object_unref(doc); g_string_free(str, TRUE); g_object_unref(mem); + g_object_unref(pdf_text); } static void Modified: test/Makefile.am (+2 -0) =================================================================== --- test/Makefile.am 2010-09-09 06:42:10 +0000 (15dadf5) +++ test/Makefile.am 2010-09-09 07:32:27 +0000 (50a7d36) @@ -8,6 +8,7 @@ TESTS_ENVIRONMENT = NO_MAKE=yes CUTTER="$(CUTTER)" noinst_LTLIBRARIES = \ test_metadata.la \ test_text.la \ + test_text_input.la \ test_text_input_stream.la \ test_decomposer.la \ test_restrict_input_stream.la \ @@ -52,6 +53,7 @@ LIBS = \ test_metadata_la_SOURCES = test_metadata.c test_text_la_SOURCES = test_text.c +test_text_input_la_SOURCES = test_text_input.c test_text_input_stream_la_SOURCES = test_text_input_stream.c test_decomposer_la_SOURCES = test_decomposer.c test_restrict_input_stream_la_SOURCES = test_restrict_input_stream.c Modified: test/test_msword.c (+12 -8) =================================================================== --- test/test_msword.c 2010-09-09 06:42:10 +0000 (a6abc18) +++ test/test_msword.c 2010-09-09 07:32:27 +0000 (5c4f5c9) @@ -10,7 +10,8 @@ #include static ChupaText *chupar; -static GInputStream *source; +static ChupaTextInput *text_input; +static GsfInput *sample_input; static gchar *sample_path; static GFile *sample_file; static gchar *read_data; @@ -28,7 +29,8 @@ setup(void) chupa_decomposer_load_modules(); chupar = NULL; - source = NULL; + text_input = NULL; + sample_input = NULL; sample_path = NULL; sample_file = NULL; read_data = NULL; @@ -41,8 +43,10 @@ teardown(void) { if (chupar) g_object_unref(chupar); - if (source) - g_object_unref(source); + if (text_input) + g_object_unref(text_input); + if (sample_input) + g_object_unref(sample_input); if (sample_path) g_free(sample_path); if (sample_file) @@ -52,9 +56,9 @@ teardown(void) } static void -text_decomposed(gpointer obj, gpointer arg, gpointer udata) +text_decomposed(ChupaText *chupar, ChupaTextInput *input, gpointer udata) { - GDataInputStream *data = G_DATA_INPUT_STREAM(arg); + GDataInputStream *data = G_DATA_INPUT_STREAM(chupa_text_input_get_stream(input)); gsize length; *(gpointer *)udata = g_data_input_stream_read_until(data, "", &length, NULL, NULL); @@ -67,7 +71,7 @@ test_decompose_msword(void) g_signal_connect(chupar, chupa_text_signal_decomposed, (GCallback)text_decomposed, &read_data); sample_path = cut_build_fixture_data_path("sample.doc", NULL); sample_file = g_file_new_for_path(sample_path); - source = G_INPUT_STREAM(g_file_read(sample_file, NULL, NULL)); - chupa_text_feed(chupar, source); + text_input = chupa_text_input_new_from_file(NULL, sample_file); + chupa_text_feed(chupar, text_input); cut_assert_equal_string("sample\n", read_data); } Modified: test/test_pdf.c (+8 -8) =================================================================== --- test/test_pdf.c 2010-09-09 06:42:10 +0000 (8c579ad) +++ test/test_pdf.c 2010-09-09 07:32:27 +0000 (5262cf1) @@ -10,7 +10,7 @@ #include static ChupaText *chupar; -static GInputStream *source; +static ChupaTextInput *text_input; static gchar *sample_path; static GFile *sample_file; static gchar *read_data; @@ -28,7 +28,7 @@ setup(void) chupa_decomposer_load_modules(); chupar = NULL; - source = NULL; + text_input = NULL; sample_path = NULL; sample_file = NULL; read_data = NULL; @@ -41,8 +41,8 @@ teardown(void) { if (chupar) g_object_unref(chupar); - if (source) - g_object_unref(source); + if (text_input) + g_object_unref(text_input); if (sample_path) g_free(sample_path); if (sample_file) @@ -52,9 +52,9 @@ teardown(void) } static void -text_decomposed(gpointer obj, gpointer arg, gpointer udata) +text_decomposed(ChupaText *chupar, ChupaTextInput *input, gpointer udata) { - GDataInputStream *data = G_DATA_INPUT_STREAM(arg); + GDataInputStream *data = G_DATA_INPUT_STREAM(chupa_text_input_get_stream(input)); gsize length; *(gpointer *)udata = g_data_input_stream_read_until(data, "", &length, NULL, NULL); @@ -67,7 +67,7 @@ test_decompose_pdf(void) g_signal_connect(chupar, chupa_text_signal_decomposed, (GCallback)text_decomposed, &read_data); sample_path = cut_build_fixture_data_path("sample.pdf", NULL); sample_file = g_file_new_for_path(sample_path); - source = G_INPUT_STREAM(g_file_read(sample_file, NULL, NULL)); - chupa_text_feed(chupar, source); + text_input = chupa_text_input_new_from_file(NULL, sample_file); + chupa_text_feed(chupar, text_input); cut_assert_equal_string("sample\n", read_data); } Modified: test/test_text.c (+9 -3) =================================================================== --- test/test_text.c 2010-09-09 06:42:10 +0000 (5667133) +++ test/test_text.c 2010-09-09 07:32:27 +0000 (9937bfb) @@ -4,12 +4,14 @@ */ #include +#include #include #include static ChupaText *chupar; static GInputStream *source; +static ChupaTextInput *input; static gchar *read_data; void @@ -18,6 +20,7 @@ setup(void) chupa_decomposer_load_modules(); chupar = NULL; source = NULL; + input = NULL; read_data = NULL; } @@ -28,14 +31,16 @@ teardown(void) g_object_unref(chupar); if (source) g_object_unref(source); + if (input) + g_object_unref(input); if (read_data) g_free(read_data); } static void -text_decomposed(gpointer obj, gpointer arg, gpointer udata) +text_decomposed(ChupaText *chupar, ChupaTextInput *input, gpointer udata) { - GDataInputStream *data = G_DATA_INPUT_STREAM(arg); + GDataInputStream *data = G_DATA_INPUT_STREAM(chupa_text_input_get_stream(input)); gsize length; *(gpointer *)udata = g_data_input_stream_read_until(data, "", &length, NULL, NULL); @@ -48,8 +53,9 @@ test_decompose_text_plain (void) GInputStream *mem = g_memory_input_stream_new_from_data(plain_text, strlen(plain_text), NULL); source = mem; + input = chupa_text_input_new_from_stream(NULL, source, NULL); chupar = chupa_text_new(); g_signal_connect(chupar, chupa_text_signal_decomposed, (GCallback)text_decomposed, &read_data); - chupa_text_feed(chupar, source); + chupa_text_feed(chupar, input); cut_assert_equal_string(plain_text, read_data); } Modified: test/test_text_input_stream.c (+27 -22) =================================================================== --- test/test_text_input_stream.c 2010-09-09 06:42:10 +0000 (d049027) +++ test/test_text_input_stream.c 2010-09-09 07:32:27 +0000 (7c95927) @@ -10,41 +10,46 @@ void test_new (void); void test_new_with_metadata (void); -static ChupaTextInputStream *stream; +static GInputStream *memstream; +static ChupaTextInput *input; void setup (void) { - stream = NULL; + memstream = NULL; + input = NULL; } void teardown (void) { - if (stream) - g_object_unref(stream); + if (memstream) + g_object_unref(memstream); + if (input) + g_object_unref(input); } void -test_new (void) +test_read(void) { - ChupaMetadata *meta; - GInputStream *memstream = g_memory_input_stream_new(); - stream = chupa_text_input_stream_new(NULL, memstream); - meta = chupa_text_input_stream_get_metadata(stream); - cut_assert_not_null(meta); - cut_assert_equal_int(1, chupa_metadata_size(meta)); - cut_assert_not_null(chupa_metadata_get_first_value(meta, "mime-type")); -} - -void -test_new_with_metadata (void) -{ - ChupaMetadata *meta = chupa_metadata_new(); - GInputStream *memstream = g_memory_input_stream_new(); - stream = chupa_text_input_stream_new(meta, memstream); - gcut_assert_equal_object(meta, chupa_text_input_stream_get_metadata(stream)); - cut_assert_equal_uint(1, chupa_metadata_size(meta)); + static const char data[] = "plain\n\0text\nfoo\0bar"; + GDataInputStream *dis; + gsize length; + const char *str; + + memstream = g_memory_input_stream_new_from_data(data, sizeof(data) - 1, NULL); + input = chupa_text_input_new_from_stream(NULL, memstream, NULL); + dis = G_DATA_INPUT_STREAM(chupa_text_input_get_stream(input)); + cut_assert_not_null(dis); + str = cut_take_string(g_data_input_stream_read_line(dis, &length, NULL, NULL)); + cut_assert_equal_string("plain", str); + cut_assert_equal_uint(5, length); + cut_assert_equal_uint(0, g_data_input_stream_read_byte(dis, NULL, NULL)); + str = cut_take_string(g_data_input_stream_read_line(dis, &length, NULL, NULL)); + cut_assert_equal_string("text", str); + cut_assert_equal_uint(4, length); + str = cut_take_memory(g_data_input_stream_read_line(dis, &length, NULL, NULL)); + cut_assert_equal_memory("foo\0bar", 7, str, length); } /* From null+ranguba at clear-code.com Thu Sep 9 04:07:48 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Thu, 09 Sep 2010 08:07:48 +0000 Subject: [groonga-commit:1229] ranguba/chupatext [master] * test/fixtures/sample.doc: test data. Message-ID: <20100909080757.EA16F278002@taiyaki.ru> Nobuyoshi Nakada 2010-09-09 08:07:48 +0000 (Thu, 09 Sep 2010) New Revision: d6373f4b8c0437a6a94d149840c92f8fec9588ec Log: * test/fixtures/sample.doc: test data. Added files: test/fixtures/sample.doc Added: test/fixtures/sample.doc (+0 -0) 100644 =================================================================== (Binary files differ) From null+ranguba at clear-code.com Thu Sep 9 04:07:15 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Thu, 09 Sep 2010 08:07:15 +0000 Subject: [groonga-commit:1230] ranguba/chupatext [master] * test/run-test.sh: option string is not a directory name. Message-ID: <20100909080737.D926D1704C0@taiyaki.ru> Nobuyoshi Nakada 2010-09-09 08:07:15 +0000 (Thu, 09 Sep 2010) New Revision: 845a5e10718f6ac5b53bd7a299b536f542df8dda Log: * test/run-test.sh: option string is not a directory name. Modified files: test/run-test.sh Modified: test/run-test.sh (+1 -0) =================================================================== --- test/run-test.sh 2010-09-09 08:06:34 +0000 (ff6f40f) +++ test/run-test.sh 2010-09-09 08:07:15 +0000 (5fb8c56) @@ -20,6 +20,7 @@ top_srcdir="$BASE_DIR/.." testdir=. test $# = 0 || eval testdir='"${'$#'-.}"' case "$testdir" in + -* ) testdir=.; builddir="`pwd`";; */. | */.. ) builddir="$testdir/..";; */* ) builddir=`expr "$testdir" : '\(.*\)/.*'`;; *) builddir="`cd $testdir && cd .. && pwd`";; From null+ranguba at clear-code.com Thu Sep 9 04:06:34 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Thu, 09 Sep 2010 08:06:34 +0000 Subject: [groonga-commit:1231] ranguba/chupatext [master] * module/chupa_msword.c (chupa_msword_decomposer_feed): implemented. Message-ID: <20100909080737.0448D278006@taiyaki.ru> Nobuyoshi Nakada 2010-09-09 08:06:34 +0000 (Thu, 09 Sep 2010) New Revision: df975273292752c5dc885093d4160c823cc8fa1d Log: * module/chupa_msword.c (chupa_msword_decomposer_feed): implemented. Modified files: module/chupa_msword.c Modified: module/chupa_msword.c (+122 -1) =================================================================== --- module/chupa_msword.c 2010-09-09 08:03:56 +0000 (d03e48b) +++ module/chupa_msword.c 2010-09-09 08:06:34 +0000 (8e43a81) @@ -36,10 +36,131 @@ struct _ChupaMSWORDDecomposerClass static GType chupa_type_msword_decomposer = 0; +struct char_proc_arg { + GString *buffer; + GMemoryInputStream *dest; + ChupaText *chupar; + ChupaTextInput *input; + const char *encoding; + wvParseStruct ps; +}; + +static int +char_proc(wvParseStruct *ps, U16 eachchar, U8 chartype, U16 lid) +{ + struct char_proc_arg *arg = ps->userData; + GString *s = arg->buffer; + gboolean first = FALSE; + + if (!arg->encoding) { + ChupaMetadata *meta = chupa_text_input_get_metadata(arg->input); + if (chartype) { + arg->encoding = wvLIDToCodePageConverter(lid); + } + else { + arg->encoding = "UTF-8"; + } + chupa_metadata_add_value(meta, "charset", arg->encoding); + first = TRUE; + } + + /* take care of any oddities in Microsoft's character "encoding" */ + /* TODO: does the above code page handler take care of these? */ + if (chartype == 1 && eachchar == 146) + eachchar = 39; /* apostrophe */ + + switch (eachchar) { + case 13: /* paragraph end */ + case 11: /* hard line break */ + eachchar = '\n'; + break; + + case 12: /* page breaks, section marks */ + eachchar = '\f'; + break; + + case 14: /* column break */ + eachchar = '\t'; + break; + + case 19: /* field begin */ + /* flush current text buffer */ + ps->fieldstate++; + ps->fieldmiddle = 0; + return 0; + case 20: /* field separator */ + ps->fieldmiddle = 1; + return 0; + case 21: /* field end */ + ps->fieldstate--; + ps->fieldmiddle = 0; + return 0; + + default: + break; + } + + /* todo: properly handle fields */ + if (eachchar == 0x13 || eachchar == 0x14) + return 0; + + if (!s) { + s = g_string_new(0); + arg->buffer = s; + } + + /* convert incoming character to unicode */ + if (chartype) { + g_string_append_c(s, eachchar); + } + else { + g_string_append_unichar(s, eachchar); + } + + if (eachchar == '\f') { + GMemoryInputStream *stream; + stream = G_MEMORY_INPUT_STREAM(arg->dest); + g_memory_input_stream_add_data(stream, s->str, s->len, g_free); + g_string_free(s, FALSE); + arg->buffer = NULL; + if (first) { + chupa_text_decomposed(arg->chupar, arg->input); + } + } + return 0; +} + static void chupa_msword_decomposer_feed(ChupaDecomposer *dec, ChupaText *chupar, ChupaTextInput *input) { + struct char_proc_arg arg; GsfInput *gi = chupa_text_input_get_base_input(input); + + arg.buffer = NULL; + arg.dest = G_MEMORY_INPUT_STREAM(g_memory_input_stream_new()); + arg.chupar = chupar; + arg.input = chupa_text_input_new_from_stream(NULL, G_INPUT_STREAM(arg.dest), + gsf_input_name(gi)); + arg.encoding = NULL; + + wvInitParser_gsf(&arg.ps, gi); + arg.ps.userData = &arg; + wvSetCharHandler(&arg.ps, char_proc); + wvText(&arg.ps); + wvOLEFree(&arg.ps); + if (arg.buffer) { + GString *s = arg.buffer; + g_memory_input_stream_add_data(arg.dest, s->str, s->len, g_free); + g_string_free(s, FALSE); + arg.buffer = NULL; + if (!arg.encoding) { + ChupaMetadata *meta = chupa_text_input_get_metadata(arg.input); + chupa_metadata_add_value(meta, "charset", "US-ASCII"); + chupa_text_decomposed(chupar, arg.input); + } + } + g_object_unref(arg.dest); + g_object_unref(arg.input); } static void @@ -71,8 +192,8 @@ register_type(GTypeModule *type_module) "ChupaMSWORDDecomposer", &info, 0); chupa_type_msword_decomposer = type; + chupa_decomposer_register("application/msword", type); chupa_decomposer_register("application/x-msword", type); - chupa_decomposer_register("application/x-ole-storage", type); } return type; } From null+ranguba at clear-code.com Wed Sep 8 22:48:20 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Thu, 09 Sep 2010 02:48:20 +0000 Subject: [groonga-commit:1232] ranguba/chupatext [master] * chupatext/Makefile.am: use GSF instead of direct GLIB. * module/Makefile.am: ditto. * test/Makefile.am: ditto. Message-ID: <20100909080736.AB53A170ED3@taiyaki.ru> Nobuyoshi Nakada 2010-09-09 02:48:20 +0000 (Thu, 09 Sep 2010) New Revision: 6090b083502ced0972b40afe5f76a31dbed66796 Log: * chupatext/Makefile.am: use GSF instead of direct GLIB. * module/Makefile.am: ditto. * test/Makefile.am: ditto. Modified files: chupatext/Makefile.am module/Makefile.am test/Makefile.am Modified: chupatext/Makefile.am (+2 -1) =================================================================== --- chupatext/Makefile.am 2010-09-09 02:44:25 +0000 (f4b3cb6) +++ chupatext/Makefile.am 2010-09-09 02:48:20 +0000 (cebea1b) @@ -11,8 +11,9 @@ libchupatext_la_SOURCES = chupa_init.c chupa_metadata.c \ $(EMPTY) AM_CPPFLAGS = -DCHUPA_MODULE_PATH=\"$(moduledir)\" -D_GNU_SOURCE - AM_CFLAGS = $(GSF_CFLAGS) +AM_LDFLAGS = $(GSF_LIBS) + DEFAULT_INCLUDES = -I$(top_includedir) -I$(build_includedir) version.lo: version.h Modified: module/Makefile.am (+9 -2) =================================================================== --- module/Makefile.am 2010-09-09 02:44:25 +0000 (3aaabdc) +++ module/Makefile.am 2010-09-09 02:48:20 +0000 (c55c7a4) @@ -1,9 +1,14 @@ EMPTY = +AM_CFLAGS = $(GSF_CFLAGS) +AM_LDFLAGS = $(GSF_LIBS) + LDFLAGS = -L$(top_builddir)/chupatext -lchupatext module_LTLIBRARIES = +if FALSE module_LTLIBRARIES += chupa_tar.la +endif if HAVE_POPPLER_GLIB module_LTLIBRARIES += chupa_pdf.la endif @@ -11,19 +16,21 @@ if HAVE_WV module_LTLIBRARIES += chupa_msword.la endif +if FALSE chupa_tar_la_SOURCES = chupa_tar.c chupa_tar_la_LDFLAGS = -module chupa_tar_la_CPPFLAGS = $(GLIB_CFLAGS) chupa_tar_la_LIBADD = $(GLIB_LIBS) +endif chupa_pdf_la_SOURCES = chupa_pdf.c chupa_pdf_la_LDFLAGS = -module chupa_pdf_la_CPPFLAGS = $(POPPLER_GLIB_CFLAGS) -chupa_pdf_la_LIBADD = $(POPPLER_GLIB_LIBS) +chupa_pdf_la_LIBADD = $(POPPLER_GLIB_LIBS) $(GSF_LIBS) chupa_msword_la_SOURCES = chupa_msword.c chupa_msword_la_LDFLAGS = -module chupa_msword_la_CPPFLAGS = $(WV_CFLAGS) -chupa_msword_la_LIBADD = $(WV_LIBS) +chupa_msword_la_LIBADD = $(WV_LIBS) $(GSF_LIBS) DEFAULT_INCLUDES = -I$(top_includedir) -I$(build_includedir) Modified: test/Makefile.am (+2 -2) =================================================================== --- test/Makefile.am 2010-09-09 02:44:25 +0000 (fa2f432) +++ test/Makefile.am 2010-09-09 02:48:20 +0000 (15dadf5) @@ -35,7 +35,7 @@ INCLUDES = \ AM_CFLAGS = \ $(CHUPATEXT_CFLAGS) \ $(GCUTTER_CFLAGS) \ - $(GLIB_CFLAGS) \ + $(GSF_CFLAGS) \ $(EMPTY) AM_LDFLAGS = \ @@ -47,7 +47,7 @@ AM_LDFLAGS = \ LIBS = \ $(top_builddir)/chupatext/libchupatext.la \ $(GCUTTER_LIBS) \ - $(GLIB_LIBS) \ + $(GSF_LIBS) \ $(EMPTY) test_metadata_la_SOURCES = test_metadata.c From null+ranguba at clear-code.com Thu Sep 9 02:41:21 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Thu, 09 Sep 2010 06:41:21 +0000 Subject: [groonga-commit:1233] ranguba/chupatext [master] * chupatext/chupa_text_input_stream.c (CHUPA_TEXT_INPUT_STREAM): fix super class. Message-ID: <20100909080736.BB7DB278001@taiyaki.ru> Nobuyoshi Nakada 2010-09-09 06:41:21 +0000 (Thu, 09 Sep 2010) New Revision: 4bc69cb3cad047d90d70bbc2e129bea0bb172d9e Log: * chupatext/chupa_text_input_stream.c (CHUPA_TEXT_INPUT_STREAM): fix super class. Modified files: chupatext/chupa_text_input_stream.c Modified: chupatext/chupa_text_input_stream.c (+1 -1) =================================================================== --- chupatext/chupa_text_input_stream.c 2010-09-09 02:48:20 +0000 (b6ddbc6) +++ chupatext/chupa_text_input_stream.c 2010-09-09 06:41:21 +0000 (2b70cc0) @@ -5,7 +5,7 @@ #include "chupatext/chupa_text_input_stream.h" -G_DEFINE_TYPE(ChupaTextInputStream, chupa_text_input_stream, G_TYPE_DATA_INPUT_STREAM) +G_DEFINE_TYPE(ChupaTextInputStream, chupa_text_input_stream, G_TYPE_INPUT_STREAM) #define CHUPA_TEXT_INPUT_STREAM_GET_PRIVATE(obj) \ (G_TYPE_INSTANCE_GET_PRIVATE((obj), \ From null+ranguba at clear-code.com Thu Sep 9 06:08:24 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Thu, 09 Sep 2010 10:08:24 +0000 Subject: [groonga-commit:1234] ranguba/chupatext [master] * test/Makefile.am (echo-cutter): moved back. Message-ID: <20100909100839.49AB21704C0@taiyaki.ru> Nobuyoshi Nakada 2010-09-09 10:08:24 +0000 (Thu, 09 Sep 2010) New Revision: c403ccf048889b6b2dbf2ad63079d6a26ae19cc2 Log: * test/Makefile.am (echo-cutter): moved back. * test/run-test.sh: fix for BASE_DIR. Modified files: Makefile.am test/Makefile.am test/run-test.sh Modified: Makefile.am (+0 -3) =================================================================== --- Makefile.am 2010-09-09 08:17:08 +0000 (796de74) +++ Makefile.am 2010-09-09 10:08:24 +0000 (074cf76) @@ -4,7 +4,4 @@ SUBDIRS = chupatext test module all-recursive: update-version.h -echo-cutter: - @echo $(CUTTER) - include prereq.mk Modified: test/Makefile.am (+3 -0) =================================================================== --- test/Makefile.am 2010-09-09 08:17:08 +0000 (50a7d36) +++ test/Makefile.am 2010-09-09 10:08:24 +0000 (099ff9c) @@ -59,3 +59,6 @@ test_decomposer_la_SOURCES = test_decomposer.c test_restrict_input_stream_la_SOURCES = test_restrict_input_stream.c test_pdf_la_SOURCES = test_pdf.c test_msword_la_SOURCES = test_msword.c + +echo-cutter: + @echo $(CUTTER) Modified: test/run-test.sh (+6 -3) =================================================================== --- test/run-test.sh 2010-09-09 08:17:08 +0000 (5fb8c56) +++ test/run-test.sh 2010-09-09 10:08:24 +0000 (6af1e79) @@ -15,13 +15,16 @@ # You should have received a copy of the GNU Lesser General Public License # along with this library. If not, see . -export BASE_DIR="`dirname $0`" -top_srcdir="$BASE_DIR/.." +export BASE_DIR="`dirname $0 | sed 's|\/.$||'`" +case "$BASE_DIR" in + */..) top_srcdir="$BASE_DIR/..";; + */test) top_srcdir="`dirname "$BASE_DIR"`";; +esac testdir=. test $# = 0 || eval testdir='"${'$#'-.}"' case "$testdir" in -* ) testdir=.; builddir="`pwd`";; - */. | */.. ) builddir="$testdir/..";; + . | .. | */. | */.. ) builddir="$testdir/..";; */* ) builddir=`expr "$testdir" : '\(.*\)/.*'`;; *) builddir="`cd $testdir && cd .. && pwd`";; esac From null+ranguba at clear-code.com Thu Sep 9 06:09:05 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Thu, 09 Sep 2010 10:09:05 +0000 Subject: [groonga-commit:1235] ranguba/chupatext [master] * chupatext/chupa_text_input_stream.c (read_fn): return read size. Message-ID: <20100909100915.E62231704C0@taiyaki.ru> Nobuyoshi Nakada 2010-09-09 10:09:05 +0000 (Thu, 09 Sep 2010) New Revision: 2cfbe5ccb233e3cfae411dc43ae60678265ffc6f Log: * chupatext/chupa_text_input_stream.c (read_fn): return read size. Modified files: chupatext/chupa_text_input_stream.c Modified: chupatext/chupa_text_input_stream.c (+1 -1) =================================================================== --- chupatext/chupa_text_input_stream.c 2010-09-09 10:08:24 +0000 (e417ac4) +++ chupatext/chupa_text_input_stream.c 2010-09-09 10:09:05 +0000 (50829a2) @@ -108,7 +108,7 @@ read_fn(GInputStream *stream, void *buffer, gsize count, if (!gsf_input_read(input, count, buffer)) { return 0; } - return remaining; + return count; } static gssize From null+ranguba at clear-code.com Thu Sep 9 09:22:01 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Thu, 09 Sep 2010 13:22:01 +0000 Subject: [groonga-commit:1236] ranguba/chupatext [master] * test/test_msword.c (test_decompose_msword): fix expected result. Message-ID: <20100909132214.766EF170F54@taiyaki.ru> Nobuyoshi Nakada 2010-09-09 13:22:01 +0000 (Thu, 09 Sep 2010) New Revision: 11a3d2a996b5d914a4715106e1118334254bd8ba Log: * test/test_msword.c (test_decompose_msword): fix expected result. Modified files: test/test_msword.c Modified: test/test_msword.c (+1 -1) =================================================================== --- test/test_msword.c 2010-09-09 13:21:18 +0000 (0804317) +++ test/test_msword.c 2010-09-09 13:22:01 +0000 (02c7000) @@ -66,5 +66,5 @@ test_decompose_msword(void) sample_file = g_file_new_for_path(sample_path); text_input = chupa_text_input_new_from_file(NULL, sample_file); chupa_text_feed(chupar, text_input); - cut_assert_equal_string("sample\n", read_data); + cut_assert_equal_string("Sample\n\n", read_data); } From null+ranguba at clear-code.com Thu Sep 9 09:17:16 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Thu, 09 Sep 2010 13:17:16 +0000 Subject: [groonga-commit:1237] ranguba/chupatext [master] * chupatext/chupa_text_input.c (chupa_text_input_new_from_stream): initialize by stream directly. Message-ID: <20100909132214.60D73170ED3@taiyaki.ru> Nobuyoshi Nakada 2010-09-09 13:17:16 +0000 (Thu, 09 Sep 2010) New Revision: 8d7d76f380b9ce8049418326f9908b9d793fff33 Log: * chupatext/chupa_text_input.c (chupa_text_input_new_from_stream): initialize by stream directly. Modified files: chupatext/chupa_text_input.c Modified: chupatext/chupa_text_input.c (+33 -9) =================================================================== --- chupatext/chupa_text_input.c 2010-09-09 13:00:29 +0000 (1cf1c4b) +++ chupatext/chupa_text_input.c 2010-09-09 13:17:16 +0000 (5b006f3) @@ -138,6 +138,7 @@ struct _ChupaTextInputPrivate enum { PROP_0, PROP_INPUT, + PROP_STREAM, PROP_METADATA, PROP_DUMMY }; @@ -175,12 +176,16 @@ constructed(GObject *object) ChupaTextInput *input = CHUPA_TEXT_INPUT(object); ChupaTextInputPrivate *priv = CHUPA_TEXT_INPUT_GET_PRIVATE(input); const gchar *mime_type; - GInputStream *stream; + GInputStream *stream = (GInputStream *)priv->stream; + + g_return_if_fail(stream || priv->input); if (!priv->metadata) { priv->metadata = chupa_metadata_new(); } - stream = G_INPUT_STREAM(chupa_text_input_stream_new(input)); + if (!stream) { + stream = G_INPUT_STREAM(chupa_text_input_stream_new(input)); + } if (G_IS_DATA_INPUT_STREAM(stream)) { priv->stream = G_DATA_INPUT_STREAM(stream); } @@ -223,6 +228,17 @@ set_property(GObject *object, obj = g_value_dup_object(value); priv->input = GSF_INPUT(obj); break; + case PROP_STREAM: + obj = g_value_dup_object(value); + if (obj) { + if (G_IS_DATA_INPUT_STREAM(obj)) { + priv->stream = G_DATA_INPUT_STREAM(obj); + } + else { + priv->stream = g_data_input_stream_new(G_INPUT_STREAM(obj)); + } + } + break; case PROP_METADATA: obj = g_value_dup_object(value); priv->metadata = CHUPA_METADATA(obj); @@ -244,6 +260,9 @@ get_property(GObject *object, priv = CHUPA_TEXT_INPUT_GET_PRIVATE(object); switch (prop_id) { case PROP_INPUT: + g_value_set_object(value, priv->input); + break; + case PROP_STREAM: g_value_set_object(value, priv->stream); break; case PROP_METADATA: @@ -274,6 +293,14 @@ chupa_text_input_class_init(ChupaTextInputClass *klass) G_PARAM_STATIC_STRINGS); g_object_class_install_property(gobject_class, PROP_INPUT, spec); + spec = g_param_spec_object("stream", + "Stream", + "Stream", + G_TYPE_INPUT_STREAM, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS); + g_object_class_install_property(gobject_class, PROP_STREAM, spec); + spec = g_param_spec_object("metadata", "Metadata", "Metadata of the input", @@ -297,13 +324,10 @@ chupa_text_input_new(ChupaMetadata *metadata, GsfInput *input) ChupaTextInput * chupa_text_input_new_from_stream(ChupaMetadata *metadata, GInputStream *stream, const char *path) { - ChupaTextInput *text; - GFile *file = input_stream_file_new(path, stream); - GsfInput *input = gsf_input_gio_new(file, NULL); - g_object_unref(file); - text = chupa_text_input_new(metadata, input); - g_object_unref(input); - return text; + return g_object_new(CHUPA_TYPE_TEXT_INPUT, + "stream", stream, + "metadata", metadata, + NULL); } ChupaTextInput * From null+ranguba at clear-code.com Thu Sep 9 09:21:18 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Thu, 09 Sep 2010 13:21:18 +0000 Subject: [groonga-commit:1238] ranguba/chupatext [master] * chupatext/chupa_text_input.c (constructed, chupa_text_input_new) (chupa_text_input_new_from_stream): initialize filename metadata. Message-ID: <20100909132214.6CD30170F52@taiyaki.ru> Nobuyoshi Nakada 2010-09-09 13:21:18 +0000 (Thu, 09 Sep 2010) New Revision: 127612129b2c95008cdf18dc4f03b884e59b03db Log: * chupatext/chupa_text_input.c (constructed, chupa_text_input_new) (chupa_text_input_new_from_stream): initialize filename metadata. Modified files: chupatext/chupa_text_input.c Modified: chupatext/chupa_text_input.c (+21 -1) =================================================================== --- chupatext/chupa_text_input.c 2010-09-09 13:17:16 +0000 (5b006f3) +++ chupatext/chupa_text_input.c 2010-09-09 13:21:18 +0000 (8c46536) @@ -177,11 +177,18 @@ constructed(GObject *object) ChupaTextInputPrivate *priv = CHUPA_TEXT_INPUT_GET_PRIVATE(input); const gchar *mime_type; GInputStream *stream = (GInputStream *)priv->stream; + const char *path = NULL; g_return_if_fail(stream || priv->input); if (!priv->metadata) { priv->metadata = chupa_metadata_new(); + if (priv->input) { + path = gsf_input_name(priv->input); + } + } + else { + path = chupa_metadata_get_first_value(priv->metadata, "filename"); } if (!stream) { stream = G_INPUT_STREAM(chupa_text_input_stream_new(input)); @@ -193,7 +200,7 @@ constructed(GObject *object) priv->stream = g_data_input_stream_new(stream); } - mime_type = guess_mime_type(gsf_input_name(priv->input), + mime_type = guess_mime_type(path, G_BUFFERED_INPUT_STREAM(priv->stream), NULL); chupa_metadata_replace_value(priv->metadata, "mime-type", mime_type); @@ -315,6 +322,13 @@ chupa_text_input_class_init(ChupaTextInputClass *klass) ChupaTextInput * chupa_text_input_new(ChupaMetadata *metadata, GsfInput *input) { + const char *path; + if (input && (path = gsf_input_name(input))) { + if (!metadata) { + metadata = chupa_metadata_new(); + } + chupa_metadata_add_value(metadata, "filename", path); + } return g_object_new(CHUPA_TYPE_TEXT_INPUT, "input", input, "metadata", metadata, @@ -324,6 +338,12 @@ chupa_text_input_new(ChupaMetadata *metadata, GsfInput *input) ChupaTextInput * chupa_text_input_new_from_stream(ChupaMetadata *metadata, GInputStream *stream, const char *path) { + if (path) { + if (!metadata) { + metadata = chupa_metadata_new(); + } + chupa_metadata_add_value(metadata, "filename", path); + } return g_object_new(CHUPA_TYPE_TEXT_INPUT, "stream", stream, "metadata", metadata, From null+ranguba at clear-code.com Thu Sep 9 09:00:29 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Thu, 09 Sep 2010 13:00:29 +0000 Subject: [groonga-commit:1239] ranguba/chupatext [master] * module/chupa_msword.c (chupa_msword_decomposer_feed): check if successfully initialized. Message-ID: <20100909132214.547C61704C0@taiyaki.ru> Nobuyoshi Nakada 2010-09-09 13:00:29 +0000 (Thu, 09 Sep 2010) New Revision: e13e57d4b7aece99876c589a4b1001f84011da61 Log: * module/chupa_msword.c (chupa_msword_decomposer_feed): check if successfully initialized. Modified files: module/chupa_msword.c Modified: module/chupa_msword.c (+14 -9) =================================================================== --- module/chupa_msword.c 2010-09-09 10:09:05 +0000 (8e43a81) +++ module/chupa_msword.c 2010-09-09 13:00:29 +0000 (ea0a254) @@ -42,7 +42,6 @@ struct char_proc_arg { ChupaText *chupar; ChupaTextInput *input; const char *encoding; - wvParseStruct ps; }; static int @@ -50,7 +49,6 @@ char_proc(wvParseStruct *ps, U16 eachchar, U8 chartype, U16 lid) { struct char_proc_arg *arg = ps->userData; GString *s = arg->buffer; - gboolean first = FALSE; if (!arg->encoding) { ChupaMetadata *meta = chupa_text_input_get_metadata(arg->input); @@ -61,7 +59,6 @@ char_proc(wvParseStruct *ps, U16 eachchar, U8 chartype, U16 lid) arg->encoding = "UTF-8"; } chupa_metadata_add_value(meta, "charset", arg->encoding); - first = TRUE; } /* take care of any oddities in Microsoft's character "encoding" */ @@ -123,7 +120,7 @@ char_proc(wvParseStruct *ps, U16 eachchar, U8 chartype, U16 lid) g_memory_input_stream_add_data(stream, s->str, s->len, g_free); g_string_free(s, FALSE); arg->buffer = NULL; - if (first) { + if (arg->chupar) { chupa_text_decomposed(arg->chupar, arg->input); } } @@ -134,7 +131,9 @@ static void chupa_msword_decomposer_feed(ChupaDecomposer *dec, ChupaText *chupar, ChupaTextInput *input) { struct char_proc_arg arg; + wvParseStruct ps; GsfInput *gi = chupa_text_input_get_base_input(input); + int ret; arg.buffer = NULL; arg.dest = G_MEMORY_INPUT_STREAM(g_memory_input_stream_new()); @@ -143,11 +142,15 @@ chupa_msword_decomposer_feed(ChupaDecomposer *dec, ChupaText *chupar, ChupaTextI gsf_input_name(gi)); arg.encoding = NULL; - wvInitParser_gsf(&arg.ps, gi); - arg.ps.userData = &arg; - wvSetCharHandler(&arg.ps, char_proc); - wvText(&arg.ps); - wvOLEFree(&arg.ps); + gsf_input_seek(gi, 0, G_SEEK_SET); + if ((ret = wvInitParser_gsf(&ps, gi)) != 0) { + g_warning("wvInitParser_gsf failed: %d", ret); + return; + } + ps.userData = &arg; + wvSetCharHandler(&ps, char_proc); + wvText(&ps); + wvOLEFree(&ps); if (arg.buffer) { GString *s = arg.buffer; g_memory_input_stream_add_data(arg.dest, s->str, s->len, g_free); @@ -156,6 +159,8 @@ chupa_msword_decomposer_feed(ChupaDecomposer *dec, ChupaText *chupar, ChupaTextI if (!arg.encoding) { ChupaMetadata *meta = chupa_text_input_get_metadata(arg.input); chupa_metadata_add_value(meta, "charset", "US-ASCII"); + } + if (arg.chupar) { chupa_text_decomposed(chupar, arg.input); } } From null+ranguba at clear-code.com Thu Sep 9 20:01:21 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Fri, 10 Sep 2010 00:01:21 +0000 Subject: [groonga-commit:1240] ranguba/chupatext [master] * test/test_msword.c (test_decompose_msword_ja): test for japanese. Message-ID: <20100910000138.00BB6170ED3@taiyaki.ru> Nobuyoshi Nakada 2010-09-10 00:01:21 +0000 (Fri, 10 Sep 2010) New Revision: b8a9301a2a00b6252d4f210b3d06c67eb3e678ae Log: * test/test_msword.c (test_decompose_msword_ja): test for japanese. Added files: test/fixtures/sample_ja.doc Modified files: test/test_msword.c Added: test/fixtures/sample_ja.doc (+0 -0) 100644 =================================================================== (Binary files differ) Modified: test/test_msword.c (+6 -0) =================================================================== --- test/test_msword.c 2010-09-10 00:00:06 +0000 (128e844) +++ test/test_msword.c 2010-09-10 00:01:21 +0000 (5806c21) @@ -74,3 +74,9 @@ test_decompose_msword(void) { cut_assert_equal_string("Sample\n\n", decompose_msword("sample.doc")); } + +void +test_decompose_msword_ja(void) +{ + cut_assert_equal_string("Sample\n?????\n", decompose_msword("sample_ja.doc")); +} From null+ranguba at clear-code.com Thu Sep 9 20:00:06 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Fri, 10 Sep 2010 00:00:06 +0000 Subject: [groonga-commit:1241] ranguba/chupatext [master] * test/test_msword.c (decompose_msword): extract decompose function. Message-ID: <20100910000137.E0F731704C0@taiyaki.ru> Nobuyoshi Nakada 2010-09-10 00:00:06 +0000 (Fri, 10 Sep 2010) New Revision: 693d36f3e51e674ac2ec888f501d3a0adaba4811 Log: * test/test_msword.c (decompose_msword): extract decompose function. Modified files: test/test_msword.c Modified: test/test_msword.c (+10 -4) =================================================================== --- test/test_msword.c 2010-09-09 13:22:01 +0000 (02c7000) +++ test/test_msword.c 2010-09-10 00:00:06 +0000 (128e844) @@ -57,14 +57,20 @@ text_decomposed(ChupaText *chupar, ChupaTextInput *input, gpointer udata) *(gpointer *)udata = g_data_input_stream_read_until(data, "", &length, NULL, NULL); } -void -test_decompose_msword(void) +static const char * +decompose_msword(const char *fixture) { chupar = chupa_text_new(); chupa_text_connect_decomposed(chupar, text_decomposed, &read_data); - sample_path = cut_build_fixture_data_path("sample.doc", NULL); + sample_path = cut_build_fixture_data_path(fixture, NULL); sample_file = g_file_new_for_path(sample_path); text_input = chupa_text_input_new_from_file(NULL, sample_file); chupa_text_feed(chupar, text_input); - cut_assert_equal_string("Sample\n\n", read_data); + return read_data; +} + +void +test_decompose_msword(void) +{ + cut_assert_equal_string("Sample\n\n", decompose_msword("sample.doc")); } From null+ranguba at clear-code.com Thu Sep 9 21:55:15 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Fri, 10 Sep 2010 01:55:15 +0000 Subject: [groonga-commit:1242] ranguba/chupatext [master] * chupatext/chupa_text.c (chupa_text_decompose), (chupa_text_decompose_all): helper functions. Message-ID: <20100910015536.99F9217063F@taiyaki.ru> Nobuyoshi Nakada 2010-09-10 01:55:15 +0000 (Fri, 10 Sep 2010) New Revision: 85af96f8fdb404a5615974aaa8a5ad88ff50325a Log: * chupatext/chupa_text.c (chupa_text_decompose), (chupa_text_decompose_all): helper functions. Modified files: chupatext/chupa_text.c chupatext/chupa_text.h test/test_msword.c test/test_pdf.c test/test_text.c Modified: chupatext/chupa_text.c (+24 -0) =================================================================== --- chupatext/chupa_text.c 2010-09-10 00:01:21 +0000 (3bd66a2) +++ chupatext/chupa_text.c 2010-09-10 01:55:15 +0000 (78a791d) @@ -93,3 +93,27 @@ chupa_text_feed(ChupaText *chupar, ChupaTextInput *input) g_warning("unknown mime-type %s\n", mime_type); } } + +void +chupa_text_decompose(ChupaText *chupar, ChupaTextInput *text_input, ChupaTextCallback func, gpointer arg) +{ + chupa_text_connect_decomposed(chupar, func, arg); + chupa_text_feed(chupar, text_input); +} + +static void +text_decomposed(ChupaText *chupar, ChupaTextInput *input, gpointer udata) +{ + GDataInputStream *data = G_DATA_INPUT_STREAM(chupa_text_input_get_stream(input)); + gsize length; + + *(gpointer *)udata = g_data_input_stream_read_until(data, "", &length, NULL, NULL); +} + +char * +chupa_text_decompose_all(ChupaText *chupar, ChupaTextInput *text_input) +{ + char *read_data = NULL; + chupa_text_decompose(chupar, text_input, text_decomposed, &read_data); + return read_data; +} Modified: chupatext/chupa_text.h (+2 -0) =================================================================== --- chupatext/chupa_text.h 2010-09-10 00:01:21 +0000 (45b6358) +++ chupatext/chupa_text.h 2010-09-10 01:55:15 +0000 (5ab678c) @@ -44,5 +44,7 @@ ChupaText *chupa_text_new(void); void chupa_text_feed(ChupaText *chupar, ChupaTextInput *input); void chupa_text_decomposed(ChupaText *chupar, ChupaTextInput *input); guint chupa_text_connect_decomposed(ChupaText *chupar, ChupaTextCallback func, gpointer arg); +void chupa_text_decompose(ChupaText *chupar, ChupaTextInput *text_input, ChupaTextCallback func, gpointer arg); +char *chupa_text_decompose_all(ChupaText *chupar, ChupaTextInput *text_input); #endif Modified: test/test_msword.c (+13 -41) =================================================================== --- test/test_msword.c 2010-09-10 00:01:21 +0000 (5806c21) +++ test/test_msword.c 2010-09-10 01:55:15 +0000 (67d7e66) @@ -9,64 +9,36 @@ #include #include -static ChupaText *chupar; -static ChupaTextInput *text_input; -static GsfInput *sample_input; -static gchar *sample_path; -static GFile *sample_file; -static gchar *read_data; - void setup(void) { chupa_decomposer_load_modules(); - chupar = NULL; - text_input = NULL; - sample_input = NULL; - sample_path = NULL; - sample_file = NULL; - read_data = NULL; - cut_set_fixture_data_dir(cut_get_source_directory(), "fixtures", NULL); } void teardown(void) { - if (chupar) - g_object_unref(chupar); - if (text_input) - g_object_unref(text_input); - if (sample_input) - g_object_unref(sample_input); - if (sample_path) - g_free(sample_path); - if (sample_file) - g_object_unref(sample_file); - if (read_data) - g_free(read_data); } -static void -text_decomposed(ChupaText *chupar, ChupaTextInput *input, gpointer udata) -{ - GDataInputStream *data = G_DATA_INPUT_STREAM(chupa_text_input_get_stream(input)); - gsize length; - - *(gpointer *)udata = g_data_input_stream_read_until(data, "", &length, NULL, NULL); -} +#define TAKE_OBJECT(obj) gcut_take_object(G_OBJECT(obj)) +#define TAKE_STRING(str) cut_take_string(str) static const char * decompose_msword(const char *fixture) { - chupar = chupa_text_new(); - chupa_text_connect_decomposed(chupar, text_decomposed, &read_data); - sample_path = cut_build_fixture_data_path(fixture, NULL); - sample_file = g_file_new_for_path(sample_path); - text_input = chupa_text_input_new_from_file(NULL, sample_file); - chupa_text_feed(chupar, text_input); - return read_data; + ChupaText *chupar; + ChupaTextInput *text_input; + GsfInput *sample_input; + gchar *sample_path; + GFile *sample_file; + + TAKE_OBJECT(chupar = chupa_text_new()); + TAKE_STRING(sample_path = cut_build_fixture_data_path(fixture, NULL)); + TAKE_OBJECT(sample_file = g_file_new_for_path(sample_path)); + TAKE_OBJECT(text_input = chupa_text_input_new_from_file(NULL, sample_file)); + return TAKE_STRING(chupa_text_decompose_all(chupar, text_input)); } void Modified: test/test_pdf.c (+17 -35) =================================================================== --- test/test_pdf.c 2010-09-10 00:01:21 +0000 (84bf9da) +++ test/test_pdf.c 2010-09-10 01:55:15 +0000 (25ca5d3) @@ -9,58 +9,40 @@ #include #include -static ChupaText *chupar; -static ChupaTextInput *text_input; -static gchar *sample_path; -static GFile *sample_file; -static gchar *read_data; - void setup(void) { chupa_decomposer_load_modules(); - chupar = NULL; - text_input = NULL; - sample_path = NULL; - sample_file = NULL; - read_data = NULL; - cut_set_fixture_data_dir(cut_get_source_directory(), "fixtures", NULL); } void teardown(void) { - if (chupar) - g_object_unref(chupar); - if (text_input) - g_object_unref(text_input); - if (sample_path) - g_free(sample_path); - if (sample_file) - g_object_unref(sample_file); - if (read_data) - g_free(read_data); } -static void -text_decomposed(ChupaText *chupar, ChupaTextInput *input, gpointer udata) -{ - GDataInputStream *data = G_DATA_INPUT_STREAM(chupa_text_input_get_stream(input)); - gsize length; +#define TAKE_OBJECT(obj) gcut_take_object(G_OBJECT(obj)) +#define TAKE_STRING(str) cut_take_string(str) - *(gpointer *)udata = g_data_input_stream_read_until(data, "", &length, NULL, NULL); +static const char * +decompose_pdf(const char *fixture) +{ + ChupaText *chupar; + ChupaTextInput *text_input; + GsfInput *sample_input; + gchar *sample_path; + GFile *sample_file; + + TAKE_OBJECT(chupar = chupa_text_new()); + TAKE_STRING(sample_path = cut_build_fixture_data_path(fixture, NULL)); + TAKE_OBJECT(sample_file = g_file_new_for_path(sample_path)); + TAKE_OBJECT(text_input = chupa_text_input_new_from_file(NULL, sample_file)); + return TAKE_STRING(chupa_text_decompose_all(chupar, text_input)); } void test_decompose_pdf(void) { - chupar = chupa_text_new(); - chupa_text_connect_decomposed(chupar, text_decomposed, &read_data); - sample_path = cut_build_fixture_data_path("sample.pdf", NULL); - sample_file = g_file_new_for_path(sample_path); - text_input = chupa_text_input_new_from_file(NULL, sample_file); - chupa_text_feed(chupar, text_input); - cut_assert_equal_string("sample\n", read_data); + cut_assert_equal_string("sample\n", decompose_pdf("sample.pdf")); } Modified: test/test_text.c (+15 -31) =================================================================== --- test/test_text.c 2010-09-10 00:01:21 +0000 (a30cda8) +++ test/test_text.c 2010-09-10 01:55:15 +0000 (14199ae) @@ -9,53 +9,37 @@ #include -static ChupaText *chupar; -static GInputStream *source; -static ChupaTextInput *input; -static gchar *read_data; - void setup(void) { chupa_decomposer_load_modules(); - chupar = NULL; - source = NULL; - input = NULL; - read_data = NULL; } void teardown(void) { - if (chupar) - g_object_unref(chupar); - if (source) - g_object_unref(source); - if (input) - g_object_unref(input); - if (read_data) - g_free(read_data); } -static void -text_decomposed(ChupaText *chupar, ChupaTextInput *input, gpointer udata) -{ - GDataInputStream *data = G_DATA_INPUT_STREAM(chupa_text_input_get_stream(input)); - gsize length; +#define TAKE_OBJECT(obj) gcut_take_object(G_OBJECT(obj)) +#define TAKE_STRING(str) cut_take_string(str) - *(gpointer *)udata = g_data_input_stream_read_until(data, "", &length, NULL, NULL); +static const char * +decompose_text(const char *text, gsize size) +{ + ChupaText *chupar; + ChupaTextInput *text_input; + GInputStream *mem; + + TAKE_OBJECT(chupar = chupa_text_new()); + TAKE_OBJECT(mem = g_memory_input_stream_new_from_data(text, size, NULL)); + TAKE_OBJECT(text_input = chupa_text_input_new_from_stream(NULL, mem, NULL)); + return TAKE_STRING(chupa_text_decompose_all(chupar, text_input)); } void test_decompose_text_plain (void) { static const char plain_text[] = "plain text\n"; - GInputStream *mem = g_memory_input_stream_new_from_data(plain_text, strlen(plain_text), NULL); - - source = mem; - input = chupa_text_input_new_from_stream(NULL, source, NULL); - chupar = chupa_text_new(); - chupa_text_connect_decomposed(chupar, text_decomposed, &read_data); - chupa_text_feed(chupar, input); - cut_assert_equal_string(plain_text, read_data); + + cut_assert_equal_string(plain_text, decompose_text(plain_text, sizeof(plain_text) - 1)); } From null+ranguba at clear-code.com Fri Sep 10 01:22:47 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Fri, 10 Sep 2010 05:22:47 +0000 Subject: [groonga-commit:1243] ranguba/chupatext [master] * test/chupa_test_util.c (chupa_test_decompose_data), (chupa_test_decompose_fixture): helper functions for test. Message-ID: <20100910054409.9A6B3170DF3@taiyaki.ru> Nobuyoshi Nakada 2010-09-10 05:22:47 +0000 (Fri, 10 Sep 2010) New Revision: f7a56b7889eb22e2222ae42f975c8f05b404395c Log: * test/chupa_test_util.c (chupa_test_decompose_data), (chupa_test_decompose_fixture): helper functions for test. Added files: test/chupa_test_util.h Copied files: test/chupa_test_util.c (from test/test_msword.c) Modified files: test/Makefile.am test/test_msword.c test/test_pdf.c test/test_text.c Modified: test/Makefile.am (+3 -3) =================================================================== --- test/Makefile.am 2010-09-10 05:21:39 +0000 (099ff9c) +++ test/Makefile.am 2010-09-10 05:22:47 +0000 (25fba15) @@ -52,13 +52,13 @@ LIBS = \ $(EMPTY) test_metadata_la_SOURCES = test_metadata.c -test_text_la_SOURCES = test_text.c +test_text_la_SOURCES = test_text.c chupa_test_util.c test_text_input_la_SOURCES = test_text_input.c test_text_input_stream_la_SOURCES = test_text_input_stream.c test_decomposer_la_SOURCES = test_decomposer.c test_restrict_input_stream_la_SOURCES = test_restrict_input_stream.c -test_pdf_la_SOURCES = test_pdf.c -test_msword_la_SOURCES = test_msword.c +test_pdf_la_SOURCES = test_pdf.c chupa_test_util.c +test_msword_la_SOURCES = test_msword.c chupa_test_util.c echo-cutter: @echo $(CUTTER) Copied: test/chupa_test_util.c (+23 -22) 53% =================================================================== --- test/test_msword.c 2010-09-10 05:21:39 +0000 (67d7e66) +++ test/chupa_test_util.c 2010-09-10 05:22:47 +0000 (56baef9) @@ -3,14 +3,10 @@ * Copyright (C) 2010 Nobuyoshi Nakada */ -#include -#include - -#include -#include +#include "chupa_test_util.h" void -setup(void) +chupa_test_setup(void) { chupa_decomposer_load_modules(); @@ -18,37 +14,42 @@ setup(void) } void -teardown(void) +chupa_test_teardown(void) { } #define TAKE_OBJECT(obj) gcut_take_object(G_OBJECT(obj)) #define TAKE_STRING(str) cut_take_string(str) -static const char * -decompose_msword(const char *fixture) +char * +chupa_test_decompose_data(const char *text, gsize size) +{ + ChupaText *chupar; + ChupaTextInput *text_input; + GInputStream *mem; + char *str; + + TAKE_OBJECT(chupar = chupa_text_new()); + TAKE_OBJECT(mem = g_memory_input_stream_new_from_data(text, size, NULL)); + TAKE_OBJECT(text_input = chupa_text_input_new_from_stream(NULL, mem, NULL)); + TAKE_STRING(str = chupa_text_decompose_all(chupar, text_input)); + return str; +} + +char * +chupa_test_decompose_fixture(const char *fixture) { ChupaText *chupar; ChupaTextInput *text_input; GsfInput *sample_input; gchar *sample_path; GFile *sample_file; + char *str; TAKE_OBJECT(chupar = chupa_text_new()); TAKE_STRING(sample_path = cut_build_fixture_data_path(fixture, NULL)); TAKE_OBJECT(sample_file = g_file_new_for_path(sample_path)); TAKE_OBJECT(text_input = chupa_text_input_new_from_file(NULL, sample_file)); - return TAKE_STRING(chupa_text_decompose_all(chupar, text_input)); -} - -void -test_decompose_msword(void) -{ - cut_assert_equal_string("Sample\n\n", decompose_msword("sample.doc")); -} - -void -test_decompose_msword_ja(void) -{ - cut_assert_equal_string("Sample\n?????\n", decompose_msword("sample_ja.doc")); + TAKE_STRING(str = chupa_text_decompose_all(chupar, text_input)); + return str; } Added: test/chupa_test_util.h (+20 -0) 100644 =================================================================== --- /dev/null +++ test/chupa_test_util.h 2010-09-10 05:22:47 +0000 (10d994e) @@ -0,0 +1,20 @@ +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Copyright (C) 2010 Nobuyoshi Nakada + */ + +#ifndef CHUPA_TEST_UTIL_H +#define CHUPA_TEST_UTIL_H + +#include +#include + +#include +#include + +void chupa_test_setup(void); +void chupa_test_teardown(void); +char *chupa_test_decompose_fixture(const char *fixture); +char *chupa_test_decompose_data(const char *text, gsize size); + +#endif Modified: test/test_msword.c (+4 -26) =================================================================== --- test/test_msword.c 2010-09-10 05:21:39 +0000 (67d7e66) +++ test/test_msword.c 2010-09-10 05:22:47 +0000 (3207a6d) @@ -3,43 +3,21 @@ * Copyright (C) 2010 Nobuyoshi Nakada */ -#include -#include - -#include -#include +#include "chupa_test_util.h" void setup(void) { - chupa_decomposer_load_modules(); - - cut_set_fixture_data_dir(cut_get_source_directory(), "fixtures", NULL); + chupa_test_setup(); } void teardown(void) { + chupa_test_teardown(); } -#define TAKE_OBJECT(obj) gcut_take_object(G_OBJECT(obj)) -#define TAKE_STRING(str) cut_take_string(str) - -static const char * -decompose_msword(const char *fixture) -{ - ChupaText *chupar; - ChupaTextInput *text_input; - GsfInput *sample_input; - gchar *sample_path; - GFile *sample_file; - - TAKE_OBJECT(chupar = chupa_text_new()); - TAKE_STRING(sample_path = cut_build_fixture_data_path(fixture, NULL)); - TAKE_OBJECT(sample_file = g_file_new_for_path(sample_path)); - TAKE_OBJECT(text_input = chupa_text_input_new_from_file(NULL, sample_file)); - return TAKE_STRING(chupa_text_decompose_all(chupar, text_input)); -} +#define decompose_msword chupa_test_decompose_fixture void test_decompose_msword(void) Modified: test/test_pdf.c (+4 -26) =================================================================== --- test/test_pdf.c 2010-09-10 05:21:39 +0000 (25ca5d3) +++ test/test_pdf.c 2010-09-10 05:22:47 +0000 (d442ccb) @@ -3,43 +3,21 @@ * Copyright (C) 2010 Nobuyoshi Nakada */ -#include -#include - -#include -#include +#include "chupa_test_util.h" void setup(void) { - chupa_decomposer_load_modules(); - - cut_set_fixture_data_dir(cut_get_source_directory(), "fixtures", NULL); + chupa_test_setup(); } void teardown(void) { + chupa_test_teardown(); } -#define TAKE_OBJECT(obj) gcut_take_object(G_OBJECT(obj)) -#define TAKE_STRING(str) cut_take_string(str) - -static const char * -decompose_pdf(const char *fixture) -{ - ChupaText *chupar; - ChupaTextInput *text_input; - GsfInput *sample_input; - gchar *sample_path; - GFile *sample_file; - - TAKE_OBJECT(chupar = chupa_text_new()); - TAKE_STRING(sample_path = cut_build_fixture_data_path(fixture, NULL)); - TAKE_OBJECT(sample_file = g_file_new_for_path(sample_path)); - TAKE_OBJECT(text_input = chupa_text_input_new_from_file(NULL, sample_file)); - return TAKE_STRING(chupa_text_decompose_all(chupar, text_input)); -} +#define decompose_pdf chupa_test_decompose_fixture void test_decompose_pdf(void) Modified: test/test_text.c (+3 -16) =================================================================== --- test/test_text.c 2010-09-10 05:21:39 +0000 (14199ae) +++ test/test_text.c 2010-09-10 05:22:47 +0000 (68f58ec) @@ -12,29 +12,16 @@ void setup(void) { - chupa_decomposer_load_modules(); + chupa_test_setup(); } void teardown(void) { + chupa_test_teardown(); } -#define TAKE_OBJECT(obj) gcut_take_object(G_OBJECT(obj)) -#define TAKE_STRING(str) cut_take_string(str) - -static const char * -decompose_text(const char *text, gsize size) -{ - ChupaText *chupar; - ChupaTextInput *text_input; - GInputStream *mem; - - TAKE_OBJECT(chupar = chupa_text_new()); - TAKE_OBJECT(mem = g_memory_input_stream_new_from_data(text, size, NULL)); - TAKE_OBJECT(text_input = chupa_text_input_new_from_stream(NULL, mem, NULL)); - return TAKE_STRING(chupa_text_decompose_all(chupar, text_input)); -} +#define decompose_text chupa_test_decompose_data void test_decompose_text_plain (void) From null+ranguba at clear-code.com Fri Sep 10 01:21:39 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Fri, 10 Sep 2010 05:21:39 +0000 Subject: [groonga-commit:1244] ranguba/chupatext [master] * chupatext/chupa_decomposer.c: removed unused enum. Message-ID: <20100910054409.8BB0517063F@taiyaki.ru> Nobuyoshi Nakada 2010-09-10 05:21:39 +0000 (Fri, 10 Sep 2010) New Revision: 7ff9f9952d2c44def34697dd18ac02e174a1cddd Log: * chupatext/chupa_decomposer.c: removed unused enum. Modified files: chupatext/chupa_decomposer.c Modified: chupatext/chupa_decomposer.c (+0 -6) =================================================================== --- chupatext/chupa_decomposer.c 2010-09-10 01:55:15 +0000 (2b39adb) +++ chupatext/chupa_decomposer.c 2010-09-10 05:21:39 +0000 (1a2dd93) @@ -35,12 +35,6 @@ struct _ChupaDecomposerPrivate G_DEFINE_ABSTRACT_TYPE_WITH_CODE(ChupaDecomposer, chupa_decomposer, G_TYPE_OBJECT, decomp_modules_init()) -enum { - PROP_0, - PROP_SOURCE, - PROP_DUMMY -}; - static void chupa_decomposer_init(ChupaDecomposer *decomposer) { From null+ranguba at clear-code.com Fri Sep 10 01:24:49 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Fri, 10 Sep 2010 05:24:49 +0000 Subject: [groonga-commit:1245] ranguba/chupatext [master] * chupatext/archive_decomposer.c: abstruct class for archive files. Message-ID: <20100910054409.A2FDF170F52@taiyaki.ru> Nobuyoshi Nakada 2010-09-10 05:24:49 +0000 (Fri, 10 Sep 2010) New Revision: cb16df9502dcc466ee04f68d02a002a263beaca9 Log: * chupatext/archive_decomposer.c: abstruct class for archive files. Added files: chupatext/archive_decomposer.c chupatext/archive_decomposer.h Modified files: chupatext/Makefile.am Modified: chupatext/Makefile.am (+1 -1) =================================================================== --- chupatext/Makefile.am 2010-09-10 05:22:47 +0000 (cebea1b) +++ chupatext/Makefile.am 2010-09-10 05:24:49 +0000 (5baca14) @@ -5,7 +5,7 @@ EMPTY = libchupatext_la_SOURCES = chupa_init.c chupa_metadata.c \ chupa_text.c chupa_text_input.c chupa_module.c \ chupa_text_input_stream.c \ - chupa_decomposer.c text_decomposer.c \ + chupa_decomposer.c archive_decomposer.c text_decomposer.c \ chupa_restrict_input_stream.c \ version.c \ $(EMPTY) Added: chupatext/archive_decomposer.c (+112 -0) 100644 =================================================================== --- /dev/null +++ chupatext/archive_decomposer.c 2010-09-10 05:24:49 +0000 (c1c6ba2) @@ -0,0 +1,112 @@ +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Copyright (C) 2010 Nobuyoshi Nakada + */ + +#include "archive_decomposer.h" + +#define CHUPA_ARCHIVE_DECOMPOSER_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE(obj, \ + CHUPA_TYPE_ARCHIVE_DECOMPOSER_OBJECT, \ + ChupaArchiveDecomposerPrivate)) + +typedef struct _ChupaArchiveDecomposerPrivate ChupaArchiveDecomposerPrivate; +struct _ChupaArchiveDecomposerPrivate +{ +}; + +G_DEFINE_ABSTRACT_TYPE(ChupaArchiveDecomposer, chupa_archive_decomposer, CHUPA_TYPE_DECOMPOSER) + +enum { + PROP_0, + PROP_INFILE, + PROP_DUMMY +}; + +static void +dispose(GObject *object) +{ + ChupaArchiveDecomposer *dec = CHUPA_ARCHIVE_DECOMPOSER(object); + if (dec->infile) { + g_object_unref(dec->infile); + dec->infile = NULL; + } + G_OBJECT_CLASS(chupa_archive_decomposer_parent_class)->dispose(object); +} + +static void +set_property(GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) +{ + ChupaArchiveDecomposer *dec = CHUPA_ARCHIVE_DECOMPOSER(object); + GObject *obj; + + switch (prop_id) { + case PROP_INFILE: + obj = g_value_dup_object(value); + dec->infile = GSF_INFILE(obj); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + break; + } +} + +static void +get_property(GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ + ChupaArchiveDecomposer *dec = CHUPA_ARCHIVE_DECOMPOSER(object); + switch (prop_id) { + case PROP_INFILE: + g_value_set_object(value, dec->infile); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + break; + } +} + +static void +feed(ChupaDecomposer *dec, ChupaText *chupar, ChupaTextInput *input) +{ + GsfInfile *infile; + int i, num; + + g_return_if_fail(CHUPA_IS_ARCHIVE_DECOMPOSER(dec)); + infile = chupa_archive_decomoser_get_infile(CHUPA_ARCHIVE_DECOMPOSER(dec)); + if (!infile) { + return; + } + num = gsf_infile_num_children(infile); + for (i = 0; i < num; ++i) { + const char *name = gsf_infile_name_by_index(infile, i); + GsfInput *inp = gsf_infile_child_by_index(infile, i); + ChupaTextInput *t = chupa_text_input_new(NULL, inp); + g_object_unref(inp); + chupa_text_feed(chupar, t); + g_object_unref(t); + } +} + +static void +chupa_archive_decomposer_init(ChupaArchiveDecomposer *dec) +{ + dec->infile = NULL; +} + +static void +chupa_archive_decomposer_class_init(ChupaArchiveDecomposerClass *klass) +{ + GObjectClass *gobject_class = G_OBJECT_CLASS(klass); + ChupaDecomposerClass *decomposer_class = CHUPA_DECOMPOSER_CLASS(klass); + + gobject_class->dispose = dispose; + gobject_class->set_property = set_property; + gobject_class->get_property = get_property; + decomposer_class->feed = feed; +} Added: chupatext/archive_decomposer.h (+48 -0) 100644 =================================================================== --- /dev/null +++ chupatext/archive_decomposer.h 2010-09-10 05:24:49 +0000 (07add4e) @@ -0,0 +1,48 @@ +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Copyright (C) 2010 Nobuyoshi Nakada + */ + +#ifndef CHUPATEXT_ARCHIVE_DECOMPOSER_H +#define CHUPATEXT_ARCHIVE_DECOMPOSER_H + +#include "chupatext/chupa_decomposer.h" +#include +#include + +G_BEGIN_DECLS + +#define CHUPA_TYPE_ARCHIVE_DECOMPOSER chupa_archive_decomposer_get_type() +#define CHUPA_ARCHIVE_DECOMPOSER(obj) \ + G_TYPE_CHECK_INSTANCE_CAST(obj, CHUPA_TYPE_ARCHIVE_DECOMPOSER, ChupaArchiveDecomposer) +#define CHUPA_ARCHIVE_DECOMPOSER_CLASS(klass) \ + G_TYPE_CHECK_CLASS_CAST(klass, CHUPA_TYPE_ARCHIVE_DECOMPOSER, ChupaArchiveDecomposerClass) +#define CHUPA_IS_ARCHIVE_DECOMPOSER(obj) \ + G_TYPE_CHECK_INSTANCE_TYPE(obj, CHUPA_TYPE_ARCHIVE_DECOMPOSER) +#define CHUPA_IS_ARCHIVE_DECOMPOSER_CLASS(klass) \ + G_TYPE_CHECK_CLASS_TYPE(klass, CHUPA_TYPE_ARCHIVE_DECOMPOSER) +#define CHUPA_ARCHIVE_DECOMPOSER_GET_CLASS(obj) \ + G_TYPE_INSTANCE_GET_CLASS(obj, CHUPA_TYPE_ARCHIVE_DECOMPOSER, ChupaArchiveDecomposerClass) + +typedef struct _ChupaArchiveDecomposer ChupaArchiveDecomposer; +typedef struct _ChupaArchiveDecomposerClass ChupaArchiveDecomposerClass; + +struct _ChupaArchiveDecomposer +{ + ChupaDecomposer object; + GsfInfile *infile; +}; + +struct _ChupaArchiveDecomposerClass +{ + ChupaDecomposerClass parent_class; +}; + +GType chupa_archive_decomposer_get_type(void) G_GNUC_CONST; +GsfInfile *chupa_archive_decomoser_get_infile(ChupaArchiveDecomposer *); +void chupa_archive_decomposer_feed(ChupaArchiveDecomposer *, ChupaText *, ChupaTextInput *); + + +G_END_DECLS + +#endif /* CHUPATEXT_ARCHIVE_DECOMPOSER_H */ From null+ranguba at clear-code.com Fri Sep 10 01:52:32 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Fri, 10 Sep 2010 05:52:32 +0000 Subject: [groonga-commit:1246] ranguba/chupatext [master] * chupatext/archive_decomposer.c (chupa_archive_decomoser_get_infile): implemented. Message-ID: <20100910055920.3975017063F@taiyaki.ru> Nobuyoshi Nakada 2010-09-10 05:52:32 +0000 (Fri, 10 Sep 2010) New Revision: 621ad106467c8afad0a948b810f8fefc233fcb34 Log: * chupatext/archive_decomposer.c (chupa_archive_decomoser_get_infile): implemented. Modified files: chupatext/archive_decomposer.c Modified: chupatext/archive_decomposer.c (+8 -0) =================================================================== --- chupatext/archive_decomposer.c 2010-09-10 05:24:49 +0000 (c1c6ba2) +++ chupatext/archive_decomposer.c 2010-09-10 05:52:32 +0000 (2d02379) @@ -110,3 +110,11 @@ chupa_archive_decomposer_class_init(ChupaArchiveDecomposerClass *klass) gobject_class->get_property = get_property; decomposer_class->feed = feed; } + +GsfInfile * +chupa_archive_decomoser_get_infile(ChupaArchiveDecomposer *dec) +{ + g_return_val_if_fail(CHUPA_IS_ARCHIVE_DECOMPOSER(dec), NULL); + + return dec->infile; +} From null+ranguba at clear-code.com Fri Sep 10 01:58:56 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Fri, 10 Sep 2010 05:58:56 +0000 Subject: [groonga-commit:1247] ranguba/chupatext [master] * module/chupa_tar.c: rewrote using ChupaArchiveDecomposer. * module/chupa_zip.c: new. Message-ID: <20100910055920.46756170DF3@taiyaki.ru> Nobuyoshi Nakada 2010-09-10 05:58:56 +0000 (Fri, 10 Sep 2010) New Revision: 4b0e05c6a41cc3df1c663c5c946f60cae29fe40d Log: * module/chupa_tar.c: rewrote using ChupaArchiveDecomposer. * module/chupa_zip.c: new. Added files: module/chupa_zip.c test/fixtures/sample.tar.gz test/fixtures/sample.zip test/test_tar.c test/test_zip.c Modified files: module/Makefile.am module/chupa_tar.c test/Makefile.am Modified: module/Makefile.am (+8 -6) =================================================================== --- module/Makefile.am 2010-09-10 05:52:32 +0000 (c55c7a4) +++ module/Makefile.am 2010-09-10 05:58:56 +0000 (1003e90) @@ -6,9 +6,8 @@ AM_LDFLAGS = $(GSF_LIBS) LDFLAGS = -L$(top_builddir)/chupatext -lchupatext module_LTLIBRARIES = -if FALSE module_LTLIBRARIES += chupa_tar.la -endif +module_LTLIBRARIES += chupa_zip.la if HAVE_POPPLER_GLIB module_LTLIBRARIES += chupa_pdf.la endif @@ -16,12 +15,15 @@ if HAVE_WV module_LTLIBRARIES += chupa_msword.la endif -if FALSE chupa_tar_la_SOURCES = chupa_tar.c chupa_tar_la_LDFLAGS = -module -chupa_tar_la_CPPFLAGS = $(GLIB_CFLAGS) -chupa_tar_la_LIBADD = $(GLIB_LIBS) -endif +chupa_tar_la_CPPFLAGS = $(GSF_CFLAGS) +chupa_tar_la_LIBADD = $(GSF_LIBS) + +chupa_zip_la_SOURCES = chupa_zip.c +chupa_zip_la_LDFLAGS = -module +chupa_zip_la_CPPFLAGS = $(GSF_CFLAGS) +chupa_zip_la_LIBADD = $(GSF_LIBS) chupa_pdf_la_SOURCES = chupa_pdf.c chupa_pdf_la_LDFLAGS = -module Modified: module/chupa_tar.c (+7 -97) =================================================================== --- module/chupa_tar.c 2010-09-10 05:52:32 +0000 (dbdb48f) +++ module/chupa_tar.c 2010-09-10 05:58:56 +0000 (1b1795d) @@ -3,42 +3,10 @@ * Copyright (C) 2010 Nobuyoshi Nakada */ -#include +#include #include -#include #include -#include - -#define TAR_PAGE_SIZE 512 - -struct tar_header { - guchar name[100]; /* NUL-terminated if NUL fits */ - guchar mode[8]; - guchar uid[8]; - guchar gid[8]; - guchar size[12]; - guchar mtime[12]; - guchar chksum[8]; - guchar typeflag[1]; - guchar linkname[100]; /* NUL-terminated if NUL fits */ - guchar magic[6]; /* must be TMAGIC (NUL term.) */ - guchar version[2]; /* must be TVERSION */ - guchar uname[32]; /* NUL-terminated */ - guchar gname[32]; /* NUL-terminated */ - guchar devmajor[8]; - guchar devminor[8]; - guchar prefix[155]; /* NUL-terminated if NUL fits */ -}; - -union tar_buffer { - struct tar_header bytes; - unsigned int uints[TAR_PAGE_SIZE / sizeof(unsigned int)]; -}; - -G_STATIC_ASSERT(sizeof(union tar_buffer) == TAR_PAGE_SIZE); - -#define roomof(count, unit) (((count) + (unit) - 1) / (unit)) -#define roundup(count, unit) (roomof(count, unit) * (unit)) +#include #define CHUPA_TYPE_TAR_DECOMPOSER chupa_type_tar_decomposer #define CHUPA_TAR_DECOMPOSER(obj) \ @@ -57,83 +25,24 @@ typedef struct _ChupaTARDecomposerClass ChupaTARDecomposerClass; struct _ChupaTARDecomposer { - ChupaDecomposer object; + ChupaArchiveDecomposer parent_object; }; struct _ChupaTARDecomposerClass { - ChupaDecomposerClass parent_class; + ChupaArchiveDecomposerClass parent_class; }; static GType chupa_type_tar_decomposer = 0; -static gboolean -is_null_page(const unsigned int *up, gsize size) -{ - gsize i = size / sizeof(*up); - - while (--i > 0) { - if (*up++) { - return FALSE; - } - } - i = size % sizeof(*up); - if (i > 0) { - const unsigned char *cp = (const unsigned char *)up; - while (--i > 0) { - if (*cp++) { - return FALSE; - } - } - } - return TRUE; -} - static void -chupa_tar_decomposer_feed(ChupaDecomposer *dec, ChupaText *chupar, ChupaTextInputStream *stream) +chupa_tar_decomposer_init(ChupaTARDecomposer *dec) { - union tar_buffer header; - gssize size; - guchar name[sizeof(header.bytes.name) + sizeof(header.bytes.prefix) + 2]; - GInputStream *input = G_INPUT_STREAM(stream); - - while ((size = g_input_stream_read(input, &header, sizeof(header), 0, 0)) > 0 && - !is_null_page(header.uints, size)) { - if (size < sizeof(header)) { - g_warning("garbage in tar file\n"); - break; - } - if (memcmp(header.bytes.magic, TMAGIC, TMAGLEN) != 0) { - g_warning("bad magic\n"); - break; - } - size = strtoul(header.bytes.size); - if (header.bytes.typeflag[0] == REGTYPE || header.bytes.typeflag[0] == AREGTYPE) { - /* regular file only */ - GInputStream *part; - guchar *p = name; - if (header.bytes.prefix[0]) { - p += strlcpy(p, header.bytes.prefix, sizeof(header.bytes.prefix)); - *p++ = '/'; - } - p += g_strlcpy(p, header.bytes.name, sizeof(header.bytes.name)); - part = chupa_restrict_input_stream_new(input, size); - chupa_text_feed(chupar, part); - chupa_restrict_input_stream_skip_to_end(part); - g_object_unref(part); - g_input_stream_skip(input, (gsize)size % TAR_PAGE_SIZE, NULL, NULL); - } - else { - g_input_stream_skip(input, roundup((gsize)size, TAR_PAGE_SIZE), NULL, NULL); - } - } } static void chupa_tar_decomposer_class_init(ChupaTARDecomposerClass *klass) { - ChupaDecomposerClass *super = CHUPA_DECOMPOSER_CLASS(klass); - super->feed = chupa_tar_decomposer_feed; } static GType @@ -154,11 +63,12 @@ register_type(GTypeModule *type_module) if (!type) { type = g_type_module_register_type(type_module, - CHUPA_TYPE_DECOMPOSER, + CHUPA_TYPE_ARCHIVE_DECOMPOSER, "ChupaTARDecomposer", &info, 0); chupa_type_tar_decomposer = type; chupa_decomposer_register("application/x-tar", type); + chupa_decomposer_register("application/x-compressed-tar", type); } return type; } Added: module/chupa_zip.c (+102 -0) 100644 =================================================================== --- /dev/null +++ module/chupa_zip.c 2010-09-10 05:58:56 +0000 (05e54a3) @@ -0,0 +1,102 @@ +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Copyright (C) 2010 Nobuyoshi Nakada + */ + +#include +#include +#include +#include + +#define CHUPA_TYPE_ZIP_DECOMPOSER chupa_type_zip_decomposer +#define CHUPA_ZIP_DECOMPOSER(obj) \ + G_TYPE_CHECK_INSTANCE_CAST(obj, CHUPA_TYPE_ZIP_DECOMPOSER, ChupaZIPDecomposer) +#define CHUPA_ZIP_DECOMPOSER_CLASS(klass) \ + G_TYPE_CHECK_CLASS_CAST(klass, CHUPA_TYPE_ZIP_DECOMPOSER, ChupaZIPDecomposerClass) +#define CHUPA_IS_ZIP_DECOMPOSER(obj) \ + G_TYPE_CHECK_INSTANCE_TYPE(obj, CHUPA_TYPE_ZIP_DECOMPOSER) +#define CHUPA_IS_ZIP_DECOMPOSER_CLASS(klass) \ + G_TYPE_CHECK_CLASS_TYPE(klass, CHUPA_TYPE_ZIP_DECOMPOSER) +#define CHUPA_ZIP_DECOMPOSER_GET_CLASS(obj) \ + G_TYPE_INSTANCE_GET_CLASS(obj, CHUPA_TYPE_ZIP_DECOMPOSER, ChupaZIPDecomposerClass) + +typedef struct _ChupaZIPDecomposer ChupaZIPDecomposer; +typedef struct _ChupaZIPDecomposerClass ChupaZIPDecomposerClass; + +struct _ChupaZIPDecomposer +{ + ChupaArchiveDecomposer parent_object; +}; + +struct _ChupaZIPDecomposerClass +{ + ChupaArchiveDecomposerClass parent_class; +}; + +static GType chupa_type_zip_decomposer = 0; + +static void +chupa_zip_decomposer_init(ChupaZIPDecomposer *dec) +{ +} + +static void +chupa_zip_decomposer_class_init(ChupaZIPDecomposerClass *klass) +{ +} + +static GType +register_type(GTypeModule *type_module) +{ + static const GTypeInfo info = { + sizeof(ChupaZIPDecomposerClass), + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) chupa_zip_decomposer_class_init, + NULL, /* class_finalize */ + NULL, /* class_data */ + sizeof(ChupaZIPDecomposer), + 0, + (GInstanceInitFunc) NULL, + }; + GType type = chupa_type_zip_decomposer; + + if (!type) { + type = g_type_module_register_type(type_module, + CHUPA_TYPE_ARCHIVE_DECOMPOSER, + "ChupaZIPDecomposer", + &info, 0); + chupa_type_zip_decomposer = type; + chupa_decomposer_register("application/zip", type); + } + return type; +} + +G_MODULE_EXPORT GList * +CHUPA_MODULE_IMPL_INIT(GTypeModule *type_module) +{ + GType type = register_type(type_module); + GList *registered_types = NULL; + +#if 0 + if (type) { + registered_types = + g_list_prepend(registered_types, + (gchar *)g_type_name(type)); + } +#endif + + return registered_types; +} + +G_MODULE_EXPORT void +CHUPA_MODULE_IMPL_EXIT(void) +{ +} + +G_MODULE_EXPORT GObject * +CHUPA_MODULE_IMPL_INSTANTIATE(const gchar *first_property, va_list var_args) +{ + return g_object_new_valist(CHUPA_TYPE_ZIP_DECOMPOSER, + first_property, var_args); +} Modified: test/Makefile.am (+4 -0) =================================================================== --- test/Makefile.am 2010-09-10 05:52:32 +0000 (25fba15) +++ test/Makefile.am 2010-09-10 05:58:56 +0000 (b38afbf) @@ -12,6 +12,8 @@ noinst_LTLIBRARIES = \ test_text_input_stream.la \ test_decomposer.la \ test_restrict_input_stream.la \ + test_tar.la \ + test_zip.la \ $(EMPTY) if HAVE_POPPLER_GLIB @@ -59,6 +61,8 @@ test_decomposer_la_SOURCES = test_decomposer.c test_restrict_input_stream_la_SOURCES = test_restrict_input_stream.c test_pdf_la_SOURCES = test_pdf.c chupa_test_util.c test_msword_la_SOURCES = test_msword.c chupa_test_util.c +test_tar_la_SOURCES = test_tar.c chupa_test_util.c +test_zip_la_SOURCES = test_zip.c chupa_test_util.c echo-cutter: @echo $(CUTTER) Added: test/fixtures/sample.tar.gz (+0 -0) 100644 =================================================================== (Binary files differ) Added: test/fixtures/sample.zip (+0 -0) 100644 =================================================================== (Binary files differ) Added: test/test_tar.c (+26 -0) 100644 =================================================================== --- /dev/null +++ test/test_tar.c 2010-09-10 05:58:56 +0000 (1f4ba75) @@ -0,0 +1,26 @@ +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Copyright (C) 2010 Nobuyoshi Nakada + */ + +#include "chupa_test_util.h" + +void +setup(void) +{ + chupa_test_setup(); +} + +void +teardown(void) +{ + chupa_test_teardown(); +} + +#define decompose_tar chupa_test_decompose_fixture + +void +test_decompose_tar(void) +{ + cut_assert_equal_string("sample\n", decompose_tar("sample.tar.gz")); +} Added: test/test_zip.c (+26 -0) 100644 =================================================================== --- /dev/null +++ test/test_zip.c 2010-09-10 05:58:56 +0000 (f9ce23b) @@ -0,0 +1,26 @@ +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Copyright (C) 2010 Nobuyoshi Nakada + */ + +#include "chupa_test_util.h" + +void +setup(void) +{ + chupa_test_setup(); +} + +void +teardown(void) +{ + chupa_test_teardown(); +} + +#define decompose_zip chupa_test_decompose_fixture + +void +test_decompose_zip(void) +{ + cut_assert_equal_string("sample\n", decompose_zip("sample.zip")); +} From null+ranguba at clear-code.com Fri Sep 10 02:07:12 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Fri, 10 Sep 2010 06:07:12 +0000 Subject: [groonga-commit:1248] ranguba/chupatext [master] * chupatext/archive_decomposer.c (constructed): check if set properly. Message-ID: <20100910060719.73B6017063F@taiyaki.ru> Nobuyoshi Nakada 2010-09-10 06:07:12 +0000 (Fri, 10 Sep 2010) New Revision: 2aa04f365911ca9d23a5f73b1f356be0bb2b2fff Log: * chupatext/archive_decomposer.c (constructed): check if set properly. Modified files: chupatext/archive_decomposer.c Modified: chupatext/archive_decomposer.c (+9 -0) =================================================================== --- chupatext/archive_decomposer.c 2010-09-10 05:58:56 +0000 (2d02379) +++ chupatext/archive_decomposer.c 2010-09-10 06:07:12 +0000 (767be36) @@ -72,6 +72,14 @@ get_property(GObject *object, } static void +constructed(GObject *object) +{ + ChupaArchiveDecomposer *dec = CHUPA_ARCHIVE_DECOMPOSER(object); + g_return_if_fail(dec); + g_return_if_fail(dec->infile); +} + +static void feed(ChupaDecomposer *dec, ChupaText *chupar, ChupaTextInput *input) { GsfInfile *infile; @@ -105,6 +113,7 @@ chupa_archive_decomposer_class_init(ChupaArchiveDecomposerClass *klass) GObjectClass *gobject_class = G_OBJECT_CLASS(klass); ChupaDecomposerClass *decomposer_class = CHUPA_DECOMPOSER_CLASS(klass); + gobject_class->constructed = constructed; gobject_class->dispose = dispose; gobject_class->set_property = set_property; gobject_class->get_property = get_property; From null+ranguba at clear-code.com Sat Sep 11 20:12:38 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Sun, 12 Sep 2010 00:12:38 +0000 Subject: [groonga-commit:1249] ranguba/rroonga [master] fix object type flag on creating a table. Message-ID: <20100912001256.1F076170521@taiyaki.ru> Kouhei Sutou 2010-09-12 00:12:38 +0000 (Sun, 12 Sep 2010) New Revision: 4e3b74fd904776e88e0cff1a24244cd240db899d Log: fix object type flag on creating a table. Reported by ono matope. Thanks!!! Modified files: README.ja.rdoc README.rdoc ext/groonga/rb-grn-array.c ext/groonga/rb-grn-hash.c ext/groonga/rb-grn-patricia-trie.c test/test-patricia-trie.rb Modified: README.ja.rdoc (+1 -0) =================================================================== --- README.ja.rdoc 2010-08-28 16:59:32 +0000 (38218de) +++ README.ja.rdoc 2010-09-12 00:12:38 +0000 (0e6a900) @@ -63,3 +63,4 @@ http://lists.sourceforge.jp/mailman/listinfo/groonga-dev * id:mat_aki??: ???????????????????? * @yune_kotomi: ?????????????? * ???: ?????????????? +* ???????: ?????????????? Modified: README.rdoc (+1 -0) =================================================================== --- README.rdoc 2010-08-28 16:59:32 +0000 (6137b94) +++ README.rdoc 2010-09-12 00:12:38 +0000 (16179cf) @@ -64,3 +64,4 @@ http://rubyforge.org/mailman/listinfo/groonga-users-en * id:mat_aki: sent bug reports. * @yune_kotomi: sent a bug report. * m_seki: sent bug reports. +* ono matope: sent bug reports. Modified: ext/groonga/rb-grn-array.c (+1 -1) =================================================================== --- ext/groonga/rb-grn-array.c 2010-08-28 16:59:32 +0000 (6cd8aea) +++ ext/groonga/rb-grn-array.c 2010-09-12 00:12:38 +0000 (d8bae76) @@ -97,7 +97,7 @@ rb_grn_array_s_create (int argc, VALUE *argv, VALUE klass) grn_obj *value_type = NULL, *table; const char *name = NULL, *path = NULL; unsigned name_size = 0; - grn_obj_flags flags = GRN_TABLE_NO_KEY; + grn_obj_flags flags = GRN_OBJ_TABLE_NO_KEY; VALUE rb_table; VALUE options, rb_context, rb_name, rb_path, rb_persistent; VALUE rb_value_type, rb_sub_records; Modified: ext/groonga/rb-grn-hash.c (+1 -1) =================================================================== --- ext/groonga/rb-grn-hash.c 2010-08-28 16:59:32 +0000 (014cc83) +++ ext/groonga/rb-grn-hash.c 2010-09-12 00:12:38 +0000 (f8fe4e1) @@ -152,7 +152,7 @@ rb_grn_hash_s_create (int argc, VALUE *argv, VALUE klass) grn_obj *key_type = NULL, *value_type = NULL, *table; const char *name = NULL, *path = NULL; unsigned name_size = 0; - grn_obj_flags flags = GRN_TABLE_HASH_KEY; + grn_obj_flags flags = GRN_OBJ_TABLE_HASH_KEY; VALUE rb_table; VALUE options, rb_context, rb_name, rb_path, rb_persistent; VALUE rb_key_normalize, rb_key_type, rb_value_type, rb_default_tokenizer; Modified: ext/groonga/rb-grn-patricia-trie.c (+1 -1) =================================================================== --- ext/groonga/rb-grn-patricia-trie.c 2010-08-28 16:59:32 +0000 (c3cf013) +++ ext/groonga/rb-grn-patricia-trie.c 2010-09-12 00:12:38 +0000 (8e84211) @@ -161,7 +161,7 @@ rb_grn_patricia_trie_s_create (int argc, VALUE *argv, VALUE klass) grn_obj *key_type = NULL, *value_type = NULL, *table; const char *name = NULL, *path = NULL; unsigned name_size = 0; - grn_obj_flags flags = GRN_TABLE_PAT_KEY; + grn_obj_flags flags = GRN_OBJ_TABLE_PAT_KEY; VALUE rb_table; VALUE options, rb_context, rb_name, rb_path, rb_persistent; VALUE rb_key_normalize, rb_key_with_sis, rb_key_type; Modified: test/test-patricia-trie.rb (+10 -0) =================================================================== --- test/test-patricia-trie.rb 2010-08-28 16:59:32 +0000 (0f38a7e) +++ test/test-patricia-trie.rb 2010-09-12 00:12:38 +0000 (d787084) @@ -363,4 +363,14 @@ class PatriciaTrieTest < Test::Unit::TestCase end assert_equal(expected, actual) end + + def test_add_uint_key + numbers = Groonga::PatriciaTrie.create(:name => "Numbers", + :key_type => "UInt32") + numbers.add(1) + numbers.add(2) + numbers.add(5) + numbers.add(7) + assert_equal([1, 2, 5, 7], numbers.collect {|number| number.key}) + end end From null+ranguba at clear-code.com Sat Sep 11 20:15:35 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Sun, 12 Sep 2010 00:15:35 +0000 Subject: [groonga-commit:1250] ranguba/rroonga [master] add 1.0.1 entry. Message-ID: <20100912001549.094DA278001@taiyaki.ru> Kouhei Sutou 2010-09-12 00:15:35 +0000 (Sun, 12 Sep 2010) New Revision: 51141ddafd8e0130a8ebe92c6b69fadcf29d730b Log: add 1.0.1 entry. Modified files: NEWS.ja.rdoc NEWS.rdoc Modified: NEWS.ja.rdoc (+11 -0) =================================================================== --- NEWS.ja.rdoc 2010-09-12 00:12:38 +0000 (f50ff0a) +++ NEWS.ja.rdoc 2010-09-12 00:15:35 +0000 (9c57fd5) @@ -1,5 +1,16 @@ = ???? +== 1.0.1: 2010-09-12 + +=== ?? + +* ??????????????????????????? + [??????????] + +=== ?? + +* ??????? + == 1.0.0: 2010-08-29 * groonga 1.0.0??? Modified: NEWS.rdoc (+11 -0) =================================================================== --- NEWS.rdoc 2010-09-12 00:12:38 +0000 (ea3ac1b) +++ NEWS.rdoc 2010-09-12 00:15:35 +0000 (7db8da9) @@ -1,5 +1,16 @@ = NEWS +== 1.0.1: 2010-09-12 + +=== Fixes + +* Fixed wrong flag used on creating a table. + [Reported by ono matope] + +=== Thanks + +* ono matope + == 1.0.0: 2010-08-29 * Supported groonga 1.0.0. From null+ranguba at clear-code.com Sat Sep 11 20:18:10 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Sun, 12 Sep 2010 00:18:10 +0000 Subject: [groonga-commit:1251] ranguba/rroonga [master] 1.0.1 -> 1.0.2. Message-ID: <20100912001947.84278278001@taiyaki.ru> Kouhei Sutou 2010-09-12 00:18:10 +0000 (Sun, 12 Sep 2010) New Revision: 4aba21faeb3ce41491b162e80edb7a25023b74c3 Log: 1.0.1 -> 1.0.2. Modified files: ext/groonga/rb-grn.h Modified: ext/groonga/rb-grn.h (+1 -1) =================================================================== --- ext/groonga/rb-grn.h 2010-09-12 00:15:35 +0000 (c8f8acf) +++ ext/groonga/rb-grn.h 2010-09-12 00:18:10 +0000 (2926d7e) @@ -69,7 +69,7 @@ RB_GRN_BEGIN_DECLS #define RB_GRN_MAJOR_VERSION 1 #define RB_GRN_MINOR_VERSION 0 -#define RB_GRN_MICRO_VERSION 1 +#define RB_GRN_MICRO_VERSION 2 typedef int rb_grn_boolean; #define RB_GRN_FALSE (0) From null+ranguba at clear-code.com Sat Sep 11 20:18:36 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Sun, 12 Sep 2010 00:18:36 +0000 Subject: [groonga-commit:1252] ranguba/rroonga [master] update release date on HTML: 1.0.0 -> 1.0.1. Message-ID: <20100912001947.A3A1D278002@taiyaki.ru> Kouhei Sutou 2010-09-12 00:18:36 +0000 (Sun, 12 Sep 2010) New Revision: a90d2c4e029b50fc03e72c2d1a51a3c462903761 Log: update release date on HTML: 1.0.0 -> 1.0.1. Modified files: html/index.html Modified: html/index.html (+1 -1) =================================================================== --- html/index.html 2010-09-12 00:18:10 +0000 (c6ef5f5) +++ html/index.html 2010-09-12 00:18:36 +0000 (f5db15a) @@ -42,7 +42,7 @@

rroonga???????

- 2010-08-29????????1.0.0?????? + 2010-09-12????????1.0.1??????

rroonga???????

From null+ranguba at clear-code.com Sun Sep 12 21:05:13 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Mon, 13 Sep 2010 01:05:13 +0000 Subject: [groonga-commit:1253] ranguba/chupatext [master] * chupatext/archive_decomposer.h (ChupaArchiveDecomposerClass): add get_infile method, instead of infile instance variable. Message-ID: <20100913010541.D09BE278001@taiyaki.ru> Nobuyoshi Nakada 2010-09-13 01:05:13 +0000 (Mon, 13 Sep 2010) New Revision: 68008f5d8750e966f5eb085461432bd8e7fe00c7 Log: * chupatext/archive_decomposer.h (ChupaArchiveDecomposerClass): add get_infile method, instead of infile instance variable. * chupatext/archive_decomposer.c (feed): use get_infile method. Modified files: chupatext/archive_decomposer.c chupatext/archive_decomposer.h module/chupa_tar.c module/chupa_zip.c Modified: chupatext/archive_decomposer.c (+4 -28) =================================================================== --- chupatext/archive_decomposer.c 2010-09-10 06:07:12 +0000 (767be36) +++ chupatext/archive_decomposer.c 2010-09-13 01:05:13 +0000 (c36b0ed) @@ -17,20 +17,10 @@ struct _ChupaArchiveDecomposerPrivate G_DEFINE_ABSTRACT_TYPE(ChupaArchiveDecomposer, chupa_archive_decomposer, CHUPA_TYPE_DECOMPOSER) -enum { - PROP_0, - PROP_INFILE, - PROP_DUMMY -}; - static void dispose(GObject *object) { ChupaArchiveDecomposer *dec = CHUPA_ARCHIVE_DECOMPOSER(object); - if (dec->infile) { - g_object_unref(dec->infile); - dec->infile = NULL; - } G_OBJECT_CLASS(chupa_archive_decomposer_parent_class)->dispose(object); } @@ -44,10 +34,6 @@ set_property(GObject *object, GObject *obj; switch (prop_id) { - case PROP_INFILE: - obj = g_value_dup_object(value); - dec->infile = GSF_INFILE(obj); - break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); break; @@ -62,9 +48,6 @@ get_property(GObject *object, { ChupaArchiveDecomposer *dec = CHUPA_ARCHIVE_DECOMPOSER(object); switch (prop_id) { - case PROP_INFILE: - g_value_set_object(value, dec->infile); - break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); break; @@ -76,17 +59,19 @@ constructed(GObject *object) { ChupaArchiveDecomposer *dec = CHUPA_ARCHIVE_DECOMPOSER(object); g_return_if_fail(dec); - g_return_if_fail(dec->infile); } static void feed(ChupaDecomposer *dec, ChupaText *chupar, ChupaTextInput *input) { GsfInfile *infile; + GsfInput *inp; int i, num; g_return_if_fail(CHUPA_IS_ARCHIVE_DECOMPOSER(dec)); - infile = chupa_archive_decomoser_get_infile(CHUPA_ARCHIVE_DECOMPOSER(dec)); + g_return_if_fail(CHUPA_IS_TEXT_INPUT(input)); + inp = chupa_text_input_get_base_input(input); + infile = CHUPA_ARCHIVE_DECOMPOSER_GET_CLASS(dec)->get_infile(inp, NULL); if (!infile) { return; } @@ -104,7 +89,6 @@ feed(ChupaDecomposer *dec, ChupaText *chupar, ChupaTextInput *input) static void chupa_archive_decomposer_init(ChupaArchiveDecomposer *dec) { - dec->infile = NULL; } static void @@ -119,11 +103,3 @@ chupa_archive_decomposer_class_init(ChupaArchiveDecomposerClass *klass) gobject_class->get_property = get_property; decomposer_class->feed = feed; } - -GsfInfile * -chupa_archive_decomoser_get_infile(ChupaArchiveDecomposer *dec) -{ - g_return_val_if_fail(CHUPA_IS_ARCHIVE_DECOMPOSER(dec), NULL); - - return dec->infile; -} Modified: chupatext/archive_decomposer.h (+2 -3) =================================================================== --- chupatext/archive_decomposer.h 2010-09-10 06:07:12 +0000 (07add4e) +++ chupatext/archive_decomposer.h 2010-09-13 01:05:13 +0000 (c7bcbab) @@ -30,18 +30,17 @@ typedef struct _ChupaArchiveDecomposerClass ChupaArchiveDecomposerClass; struct _ChupaArchiveDecomposer { ChupaDecomposer object; - GsfInfile *infile; }; struct _ChupaArchiveDecomposerClass { ChupaDecomposerClass parent_class; + + GsfInfile *(*get_infile)(GsfInput *input, GError **error); }; GType chupa_archive_decomposer_get_type(void) G_GNUC_CONST; GsfInfile *chupa_archive_decomoser_get_infile(ChupaArchiveDecomposer *); -void chupa_archive_decomposer_feed(ChupaArchiveDecomposer *, ChupaText *, ChupaTextInput *); - G_END_DECLS Modified: module/chupa_tar.c (+2 -0) =================================================================== --- module/chupa_tar.c 2010-09-10 06:07:12 +0000 (1b1795d) +++ module/chupa_tar.c 2010-09-13 01:05:13 +0000 (101cfda) @@ -43,6 +43,8 @@ chupa_tar_decomposer_init(ChupaTARDecomposer *dec) static void chupa_tar_decomposer_class_init(ChupaTARDecomposerClass *klass) { + ChupaArchiveDecomposerClass *dec_class = CHUPA_ARCHIVE_DECOMPOSER_CLASS(klass); + dec_class->get_infile = gsf_infile_tar_new; } static GType Modified: module/chupa_zip.c (+2 -0) =================================================================== --- module/chupa_zip.c 2010-09-10 06:07:12 +0000 (05e54a3) +++ module/chupa_zip.c 2010-09-13 01:05:13 +0000 (6bdf793) @@ -43,6 +43,8 @@ chupa_zip_decomposer_init(ChupaZIPDecomposer *dec) static void chupa_zip_decomposer_class_init(ChupaZIPDecomposerClass *klass) { + ChupaArchiveDecomposerClass *dec_class = CHUPA_ARCHIVE_DECOMPOSER_CLASS(klass); + dec_class->get_infile = gsf_infile_zip_new; } static GType From null+ranguba at clear-code.com Sun Sep 12 21:43:03 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Mon, 13 Sep 2010 01:43:03 +0000 Subject: [groonga-commit:1254] ranguba/chupatext [master] * chupatext/chupa_text.c, chupatext/chupa_text.h: add documents. Message-ID: <20100913014313.7799C170536@taiyaki.ru> Nobuyoshi Nakada 2010-09-13 01:43:03 +0000 (Mon, 13 Sep 2010) New Revision: 12d7d2c570849a8c5ae215b25446b6443feec84c Log: * chupatext/chupa_text.c, chupatext/chupa_text.h: add documents. Modified files: chupatext/chupa_text.c chupatext/chupa_text.h Modified: chupatext/chupa_text.c (+60 -4) =================================================================== --- chupatext/chupa_text.c 2010-09-13 01:05:13 +0000 (78a791d) +++ chupatext/chupa_text.c 2010-09-13 01:43:03 +0000 (c6ddfba) @@ -53,6 +53,13 @@ chupa_text_init(ChupaText *chupar) #endif } +/** + * chupa_text_new: + * + * Creates a new instance of a #ChupaText type. + * + * Returns: a new instance of #ChupaText + */ ChupaText * chupa_text_new(void) { @@ -62,18 +69,45 @@ chupa_text_new(void) return chupar; } +/** + * chupa_text_decomposed: + * @chupar: the #ChupaText instance to be signaled. + * @input: the input to extract from. + * + * This function is protected, and should be called from subclass of + * #ChupaTextDecomposer only. + */ void chupa_text_decomposed(ChupaText *chupar, ChupaTextInput *input) { g_signal_emit_by_name(chupar, chupa_text_signal_decomposed, input); } +/** + * chupa_text_connect_decomposed: + * + * @chupar: the #ChupaText instance to be connected. + * @func: the callback function to be called with extracted text + * input. + * @arg: arbitrary user data. + * + * Connect @func to @chupar, so that @func will be called when any + * text portion is found. + */ guint chupa_text_connect_decomposed(ChupaText *chupar, ChupaTextCallback func, gpointer arg) { return g_signal_connect(chupar, chupa_text_signal_decomposed, (GCallback)func, arg); } +/** + * chupa_text_feed: + * + * @chupar: the #ChupaText instance. + * @input: the input to extract from. + * + * Feeds @input to @chpuar, to extract text portions. + */ void chupa_text_feed(ChupaText *chupar, ChupaTextInput *input) { @@ -94,11 +128,22 @@ chupa_text_feed(ChupaText *chupar, ChupaTextInput *input) } } +/** + * chupa_text_decompose: + * + * @chupar: the #ChupaText instance. + * @input: the input to extract from. + * @func: the callback function to be called with extracted text + * input. + * @arg: arbitrary user data. + * + * Feeds @input to @chupar, with @func + */ void -chupa_text_decompose(ChupaText *chupar, ChupaTextInput *text_input, ChupaTextCallback func, gpointer arg) +chupa_text_decompose(ChupaText *chupar, ChupaTextInput *input, ChupaTextCallback func, gpointer arg) { chupa_text_connect_decomposed(chupar, func, arg); - chupa_text_feed(chupar, text_input); + chupa_text_feed(chupar, input); } static void @@ -110,10 +155,21 @@ text_decomposed(ChupaText *chupar, ChupaTextInput *input, gpointer udata) *(gpointer *)udata = g_data_input_stream_read_until(data, "", &length, NULL, NULL); } +/** + * chupa_text_decompose: + * + * @chupar: the #ChupaText instance. + * @input: the input to extract from. + * + * Extracts all text portions from @input. + * + * Returns: pointer to the text data that all text portion in @input + * are combined. + */ char * -chupa_text_decompose_all(ChupaText *chupar, ChupaTextInput *text_input) +chupa_text_decompose_all(ChupaText *chupar, ChupaTextInput *input) { char *read_data = NULL; - chupa_text_decompose(chupar, text_input, text_decomposed, &read_data); + chupa_text_decompose(chupar, input, text_decomposed, &read_data); return read_data; } Modified: chupatext/chupa_text.h (+17 -0) =================================================================== --- chupatext/chupa_text.h 2010-09-13 01:05:13 +0000 (5ab678c) +++ chupatext/chupa_text.h 2010-09-13 01:43:03 +0000 (1c4ec7d) @@ -25,11 +25,22 @@ extern const char chupa_text_signal_decomposed[]; typedef struct ChupaText ChupaText; typedef struct ChupaTextClass ChupaTextClass; +/** + * ChupaText: + * + * The class to decompose an input and extract text portions. + */ struct ChupaText { GObject parent_instance; }; +/** + * ChupaTextClass: + * + * @decomposed: the callback function called when each text portion is + * found. + */ struct ChupaTextClass { GObjectClass parent_class; @@ -38,7 +49,13 @@ struct ChupaTextClass void (*decomposed)(GObject *object, GInputStream *stream); }; +/** + * ChupaTextCallback: + * + * The type used for callback functions when extracting the text portion. + */ typedef void (*ChupaTextCallback)(ChupaText *, ChupaTextInput *, gpointer); + GType chupa_text_get_type(void) G_GNUC_CONST; ChupaText *chupa_text_new(void); void chupa_text_feed(ChupaText *chupar, ChupaTextInput *input); From null+ranguba at clear-code.com Sun Sep 12 21:58:07 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Mon, 13 Sep 2010 01:58:07 +0000 Subject: [groonga-commit:1255] ranguba/chupatext [master] * test/test_text.c: using chupa_test_util.h. Message-ID: <20100913015821.D37ED170536@taiyaki.ru> Nobuyoshi Nakada 2010-09-13 01:58:07 +0000 (Mon, 13 Sep 2010) New Revision: 1fa58412fa72f62b874bbe764f95b1390b8fc5ef Log: * test/test_text.c: using chupa_test_util.h. Modified files: test/test_text.c Modified: test/test_text.c (+1 -0) =================================================================== --- test/test_text.c 2010-09-13 01:43:03 +0000 (68f58ec) +++ test/test_text.c 2010-09-13 01:58:07 +0000 (c22cdd2) @@ -5,6 +5,7 @@ #include #include +#include "chupa_test_util.h" #include #include From null+ranguba at clear-code.com Sun Sep 12 21:59:41 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Mon, 13 Sep 2010 01:59:41 +0000 Subject: [groonga-commit:1256] ranguba/chupatext [master] * module/Makefile.am: chupa_tar module is postponed until the next. Message-ID: <20100913015953.4B20C170536@taiyaki.ru> Nobuyoshi Nakada 2010-09-13 01:59:41 +0000 (Mon, 13 Sep 2010) New Revision: c0734cb1b60c04886d7ac26fe57e4ae720fd722d Log: * module/Makefile.am: chupa_tar module is postponed until the next. Modified files: module/Makefile.am test/Makefile.am Modified: module/Makefile.am (+1 -1) =================================================================== --- module/Makefile.am 2010-09-13 01:58:07 +0000 (1003e90) +++ module/Makefile.am 2010-09-13 01:59:41 +0000 (44bf7e8) @@ -15,7 +15,7 @@ if HAVE_WV module_LTLIBRARIES += chupa_msword.la endif -chupa_tar_la_SOURCES = chupa_tar.c +nodist_chupa_tar_la_SOURCES = chupa_tar.c chupa_tar_la_LDFLAGS = -module chupa_tar_la_CPPFLAGS = $(GSF_CFLAGS) chupa_tar_la_LIBADD = $(GSF_LIBS) Modified: test/Makefile.am (+1 -1) =================================================================== --- test/Makefile.am 2010-09-13 01:58:07 +0000 (b38afbf) +++ test/Makefile.am 2010-09-13 01:59:41 +0000 (43019bd) @@ -61,7 +61,7 @@ test_decomposer_la_SOURCES = test_decomposer.c test_restrict_input_stream_la_SOURCES = test_restrict_input_stream.c test_pdf_la_SOURCES = test_pdf.c chupa_test_util.c test_msword_la_SOURCES = test_msword.c chupa_test_util.c -test_tar_la_SOURCES = test_tar.c chupa_test_util.c +nodist_test_tar_la_SOURCES = test_tar.c chupa_test_util.c test_zip_la_SOURCES = test_zip.c chupa_test_util.c echo-cutter: From null+ranguba at clear-code.com Mon Sep 13 01:27:24 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Mon, 13 Sep 2010 05:27:24 +0000 Subject: [groonga-commit:1257] ranguba/chupatext [master] * chupatext/chupa_init.c (chupa_init): fix typo. * chupatext/chupa_text.c (chupa_text_feed): ditto. Message-ID: <20100913052741.5AC16170536@taiyaki.ru> Nobuyoshi Nakada 2010-09-13 05:27:24 +0000 (Mon, 13 Sep 2010) New Revision: 781fe64acd7b43b78cf9d3860fcd0916ceb1bbfe Log: * chupatext/chupa_init.c (chupa_init): fix typo. * chupatext/chupa_text.c (chupa_text_feed): ditto. Modified files: chupatext/chupa_init.c chupatext/chupa_text.c Modified: chupatext/chupa_init.c (+1 -1) =================================================================== --- chupatext/chupa_init.c 2010-09-13 01:59:41 +0000 (74a01f5) +++ chupatext/chupa_init.c 2010-09-13 05:27:24 +0000 (101eea2) @@ -9,7 +9,7 @@ int chupa_init(void *var) { - chpua_module_load_module(); + chupa_module_load_module(); return 0; } Modified: chupatext/chupa_text.c (+1 -1) =================================================================== --- chupatext/chupa_text.c 2010-09-13 01:59:41 +0000 (c6ddfba) +++ chupatext/chupa_text.c 2010-09-13 05:27:24 +0000 (058bfd7) @@ -106,7 +106,7 @@ chupa_text_connect_decomposed(ChupaText *chupar, ChupaTextCallback func, gpointe * @chupar: the #ChupaText instance. * @input: the input to extract from. * - * Feeds @input to @chpuar, to extract text portions. + * Feeds @input to @chupar, to extract text portions. */ void chupa_text_feed(ChupaText *chupar, ChupaTextInput *input) From null+ranguba at clear-code.com Mon Sep 13 01:29:30 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Mon, 13 Sep 2010 05:29:30 +0000 Subject: [groonga-commit:1258] ranguba/chupatext [master] * chupatext/chupa_init.c (chupa_init): fix initialization function. Message-ID: <20100913052954.40071170536@taiyaki.ru> Nobuyoshi Nakada 2010-09-13 05:29:30 +0000 (Mon, 13 Sep 2010) New Revision: a88c31eb38f65db3fe656a6ffedea3c4d86cba0c Log: * chupatext/chupa_init.c (chupa_init): fix initialization function. Modified files: chupatext/chupa_init.c Modified: chupatext/chupa_init.c (+1 -1) =================================================================== --- chupatext/chupa_init.c 2010-09-13 05:27:24 +0000 (101eea2) +++ chupatext/chupa_init.c 2010-09-13 05:29:30 +0000 (be0fc81) @@ -9,7 +9,7 @@ int chupa_init(void *var) { - chupa_module_load_module(); + chupa_decomposer_load_modules(); return 0; } From null+ranguba at clear-code.com Mon Sep 13 03:02:22 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Mon, 13 Sep 2010 07:02:22 +0000 Subject: [groonga-commit:1259] ranguba/chupatext [master] * chupatext.h: include chupa_text.h. Message-ID: <20100913074546.28DD9278003@taiyaki.ru> Nobuyoshi Nakada 2010-09-13 07:02:22 +0000 (Mon, 13 Sep 2010) New Revision: 82d29d918ea9d398cf759b8557d47379616e81f8 Log: * chupatext.h: include chupa_text.h. Modified files: chupatext.h Modified: chupatext.h (+6 -0) =================================================================== --- chupatext.h 2010-09-13 06:57:08 +0000 (5ed91c8) +++ chupatext.h 2010-09-13 07:02:22 +0000 (9505067) @@ -6,6 +6,10 @@ #ifndef CHUPATEXT_H #define CHUPATEXT_H +#include + +G_BEGIN_DECLS + int chupa_init(void *); int chupa_cleanup(void); @@ -13,4 +17,6 @@ const int chupa_version(void); const int chupa_commits(void); const int chupa_release_date(void); +G_END_DECLS + #endif /* CHUPATEXT_H */ From null+ranguba at clear-code.com Mon Sep 13 01:53:43 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Mon, 13 Sep 2010 05:53:43 +0000 Subject: [groonga-commit:1260] ranguba/chupatext [master] * chupatext/chupa_init.c (chupa_init): initliaze glib type system. Message-ID: <20100913074546.15D2F278001@taiyaki.ru> Nobuyoshi Nakada 2010-09-13 05:53:43 +0000 (Mon, 13 Sep 2010) New Revision: 02574f06af144c340d8167c029e210fd681d3918 Log: * chupatext/chupa_init.c (chupa_init): initliaze glib type system. Modified files: chupatext/chupa_init.c Modified: chupatext/chupa_init.c (+2 -0) =================================================================== --- chupatext/chupa_init.c 2010-09-13 05:52:39 +0000 (be0fc81) +++ chupatext/chupa_init.c 2010-09-13 05:53:43 +0000 (b30bacd) @@ -9,6 +9,7 @@ int chupa_init(void *var) { + g_type_init(); chupa_decomposer_load_modules(); return 0; } @@ -16,4 +17,5 @@ chupa_init(void *var) int chupa_cleanup(void) { + return 0; } From null+ranguba at clear-code.com Mon Sep 13 03:45:30 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Mon, 13 Sep 2010 07:45:30 +0000 Subject: [groonga-commit:1261] ranguba/chupatext [master] * chupatext/chupa.c: sample wrapper. Message-ID: <20100913074546.48ACC278006@taiyaki.ru> Nobuyoshi Nakada 2010-09-13 07:45:30 +0000 (Mon, 13 Sep 2010) New Revision: 99147ad65ba4262442c7ac517278559219a6aab2 Log: * chupatext/chupa.c: sample wrapper. Added files: chupatext/chupa.c Modified files: chupatext/Makefile.am Modified: chupatext/Makefile.am (+5 -0) =================================================================== --- chupatext/Makefile.am 2010-09-13 07:03:49 +0000 (ffaff52) +++ chupatext/Makefile.am 2010-09-13 07:45:30 +0000 (eb6df42) @@ -2,6 +2,11 @@ lib_LTLIBRARIES = libchupatext.la EMPTY = +bin_PROGRAMS = chupa + +chupa_SOURCES = chupa.c +chupa_LDADD = libchupatext.la + libchupatext_la_SOURCES = chupa_init.c chupa_metadata.c \ chupa_text.c chupa_text_input.c chupa_module.c \ chupa_text_input_stream.c error.c \ Added: chupatext/chupa.c (+84 -0) 100644 =================================================================== --- /dev/null +++ chupatext/chupa.c 2010-09-13 07:45:30 +0000 (c9a4a54) @@ -0,0 +1,84 @@ +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Copyright (C) 2010 Nobuyoshi Nakada + */ + +#include +#include +#include + +static void +output_to_FILE(ChupaText *chupar, ChupaTextInput *input, gpointer udata) +{ + GInputStream *inst = G_INPUT_STREAM(chupa_text_input_get_stream(input)); + ChupaMetadata *meta = chupa_text_input_get_metadata(input); + FILE *out = udata; + const char *name = chupa_metadata_get_first_value(meta, "filename"); + const char *charset = chupa_metadata_get_first_value(meta, "charset"); + char buf[4096]; + gssize size; + + fprintf(out, "File: %s\n", name ? name : "(noname)"); + if (charset) { + fprintf(out, "Charset: %s\n", charset); + } + putc('\n', out); + while ((size = g_input_stream_read(inst, buf, sizeof(buf), NULL, NULL)) > 0) { + fwrite(buf, 1, size, out); + } + putc('\n', out); +} + +int +main(int argc, char **argv) +{ + int i; + int rc = EXIT_SUCCESS; + ChupaText *chupar; + GError *err = NULL; + gboolean version = FALSE; + GOptionContext *ctx; + GOptionEntry opts[] = { + { + "version", 'v', 0, G_OPTION_ARG_NONE, NULL, + "show version", NULL + }, + { NULL } + }; + opts[0].arg_data = &version; + + g_type_init(); + ctx = g_option_context_new(" input files..."); + g_option_context_set_description(ctx, "sample wraper of libchupatext."); + g_option_context_set_help_enabled(ctx, TRUE); + g_option_context_add_main_entries(ctx, opts, NULL); + if (!g_option_context_parse(ctx, &argc, &argv, &err)) { + g_print("Failed to initialize: %s\n", err->message); + g_error_free(err); + return EXIT_FAILURE; + } + if (version) { + puts(chupa_version_description()); + return EXIT_SUCCESS; + } + + chupa_init(&chupar); + chupar = chupa_text_new(); + chupa_text_connect_decomposed(chupar, output_to_FILE, stdout); + for (i = 1; i < argc; ++i) { + GFile *file = g_file_new_for_commandline_arg(argv[i]); + ChupaTextInput *input = chupa_text_input_new_from_file(NULL, file, &err); + g_object_unref(file); + if (!input || !chupa_text_feed(chupar, input, &err)) { + fprintf(stderr, "%s: %s\n", argv[0], err->message); + g_error_free(err); + err = NULL; + rc = EXIT_FAILURE; + break; + } + g_object_unref(input); + } + g_object_unref(chupar); + chupa_cleanup(); + return rc; +} From null+ranguba at clear-code.com Mon Sep 13 03:03:17 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Mon, 13 Sep 2010 07:03:17 +0000 Subject: [groonga-commit:1262] ranguba/chupatext [master] * chupatext.h: constified. Message-ID: <20100913074546.32A44278004@taiyaki.ru> Nobuyoshi Nakada 2010-09-13 07:03:17 +0000 (Mon, 13 Sep 2010) New Revision: 9d245b82bde5f8d8f902e20e6d7752fd9f3a4ada Log: * chupatext.h: constified. Modified files: chupatext.h Modified: chupatext.h (+3 -3) =================================================================== --- chupatext.h 2010-09-13 07:02:22 +0000 (9505067) +++ chupatext.h 2010-09-13 07:03:17 +0000 (8ec217f) @@ -13,9 +13,9 @@ G_BEGIN_DECLS int chupa_init(void *); int chupa_cleanup(void); -const int chupa_version(void); -const int chupa_commits(void); -const int chupa_release_date(void); +const int chupa_version(void) G_GNUC_CONST; +const int chupa_commits(void) G_GNUC_CONST; +const int chupa_release_date(void) G_GNUC_CONST; G_END_DECLS From null+ranguba at clear-code.com Mon Sep 13 03:55:20 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Mon, 13 Sep 2010 07:55:20 +0000 Subject: [groonga-commit:1263] ranguba/chupatext [master] * chupatext/chupa_metadata.c: no needs for config.h. Message-ID: <20100913075532.5F46B278001@taiyaki.ru> Nobuyoshi Nakada 2010-09-13 07:55:20 +0000 (Mon, 13 Sep 2010) New Revision: fc3e4242cf5fb00aec27127d8446fca36371e554 Log: * chupatext/chupa_metadata.c: no needs for config.h. Modified files: chupatext/chupa_metadata.c Modified: chupatext/chupa_metadata.c (+0 -4) =================================================================== --- chupatext/chupa_metadata.c 2010-09-13 07:45:30 +0000 (6424126) +++ chupatext/chupa_metadata.c 2010-09-13 07:55:20 +0000 (b3a3c6c) @@ -17,10 +17,6 @@ * */ -#ifdef HAVE_CONFIG_H -# include "chupatext/config.h" -#endif /* HAVE_CONFIG_H */ - #include "chupatext/chupa_metadata.h" #define CHUPA_METADATA_GET_PRIVATE(obj) \ From null+ranguba at clear-code.com Mon Sep 13 02:57:08 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Mon, 13 Sep 2010 06:57:08 +0000 Subject: [groonga-commit:1264] ranguba/chupatext [master] * chupatext/chupa_text.c (chupa_text_feed): check errors. Message-ID: <20100913074546.1F255278002@taiyaki.ru> Nobuyoshi Nakada 2010-09-13 06:57:08 +0000 (Mon, 13 Sep 2010) New Revision: b4316c7e4b390293a3c6e19a041b0a2b12475375 Log: * chupatext/chupa_text.c (chupa_text_feed): check errors. Added files: chupatext/error.c Modified files: chupatext/Makefile.am chupatext/archive_decomposer.c chupatext/chupa_decomposer.c chupatext/chupa_decomposer.h chupatext/chupa_text.c chupatext/chupa_text.h chupatext/chupa_text_input.c chupatext/chupa_text_input.h chupatext/text_decomposer.c module/chupa_msword.c module/chupa_pdf.c test/chupa_test_util.c test/chupa_test_util.h test/test_msword.c test/test_pdf.c test/test_tar.c test/test_text.c test/test_zip.c Modified: chupatext/Makefile.am (+1 -1) =================================================================== --- chupatext/Makefile.am 2010-09-13 05:53:43 +0000 (5baca14) +++ chupatext/Makefile.am 2010-09-13 06:57:08 +0000 (ffaff52) @@ -4,7 +4,7 @@ EMPTY = libchupatext_la_SOURCES = chupa_init.c chupa_metadata.c \ chupa_text.c chupa_text_input.c chupa_module.c \ - chupa_text_input_stream.c \ + chupa_text_input_stream.c error.c \ chupa_decomposer.c archive_decomposer.c text_decomposer.c \ chupa_restrict_input_stream.c \ version.c \ Modified: chupatext/archive_decomposer.c (+8 -3) =================================================================== --- chupatext/archive_decomposer.c 2010-09-13 05:53:43 +0000 (c36b0ed) +++ chupatext/archive_decomposer.c 2010-09-13 06:57:08 +0000 (18a79db) @@ -61,11 +61,12 @@ constructed(GObject *object) g_return_if_fail(dec); } -static void -feed(ChupaDecomposer *dec, ChupaText *chupar, ChupaTextInput *input) +static gboolean +feed(ChupaDecomposer *dec, ChupaText *chupar, ChupaTextInput *input, GError **err) { GsfInfile *infile; GsfInput *inp; + gboolean result = TRUE; int i, num; g_return_if_fail(CHUPA_IS_ARCHIVE_DECOMPOSER(dec)); @@ -81,9 +82,13 @@ feed(ChupaDecomposer *dec, ChupaText *chupar, ChupaTextInput *input) GsfInput *inp = gsf_infile_child_by_index(infile, i); ChupaTextInput *t = chupa_text_input_new(NULL, inp); g_object_unref(inp); - chupa_text_feed(chupar, t); + result = chupa_text_feed(chupar, t, err); g_object_unref(t); + if (!result) { + break; + } } + return result; } static void Modified: chupatext/chupa_decomposer.c (+4 -4) =================================================================== --- chupatext/chupa_decomposer.c 2010-09-13 05:53:43 +0000 (1a2dd93) +++ chupatext/chupa_decomposer.c 2010-09-13 06:57:08 +0000 (bfd12c4) @@ -51,11 +51,11 @@ chupa_decomposer_class_init(ChupaDecomposerClass *klass) #endif } -void -chupa_decomposer_feed(ChupaDecomposer *dec, ChupaText *text, ChupaTextInput *input) +gboolean +chupa_decomposer_feed(ChupaDecomposer *dec, ChupaText *text, ChupaTextInput *input, GError **err) { - g_return_if_fail(CHUPA_IS_DECOMPOSER(dec)); - (*CHUPA_DECOMPOSER_GET_CLASS(dec)->feed)(dec, text, input); + g_return_val_if_fail(CHUPA_IS_DECOMPOSER(dec), FALSE); + return (*CHUPA_DECOMPOSER_GET_CLASS(dec)->feed)(dec, text, input, err); } static const char text_plain[] = "text/plain"; Modified: chupatext/chupa_decomposer.h (+2 -2) =================================================================== --- chupatext/chupa_decomposer.h 2010-09-13 05:53:43 +0000 (2c6da39) +++ chupatext/chupa_decomposer.h 2010-09-13 06:57:08 +0000 (9681033) @@ -37,13 +37,13 @@ struct _ChupaDecomposerClass GObjectClass parent_class; gboolean (*can_handle)(ChupaDecomposerClass *dec, ChupaTextInput *input, const char *mime_type); - void (*feed)(ChupaDecomposer *dec, ChupaText *text, ChupaTextInput *input); + gboolean (*feed)(ChupaDecomposer *dec, ChupaText *text, ChupaTextInput *input, GError **err); }; GType chupa_decomposer_get_type(void) G_GNUC_CONST; ChupaDecomposer *chupa_decomposer_search(const gchar *mime_type); -void chupa_decomposer_feed(ChupaDecomposer *dec, ChupaText *text, ChupaTextInput *input); +gboolean chupa_decomposer_feed(ChupaDecomposer *dec, ChupaText *text, ChupaTextInput *input, GError **err); void chupa_decomposer_load_modules(void); void chupa_decomposer_register(const gchar *mime_type, GType type); Modified: chupatext/chupa_text.c (+37 -13) =================================================================== --- chupatext/chupa_text.c 2010-09-13 05:53:43 +0000 (058bfd7) +++ chupatext/chupa_text.c 2010-09-13 06:57:08 +0000 (0743ae4) @@ -108,24 +108,38 @@ chupa_text_connect_decomposed(ChupaText *chupar, ChupaTextCallback func, gpointe * * Feeds @input to @chupar, to extract text portions. */ -void -chupa_text_feed(ChupaText *chupar, ChupaTextInput *input) +gboolean +chupa_text_feed(ChupaText *chupar, ChupaTextInput *input, GError **error) { const char *mime_type = NULL; ChupaDecomposer *dec; + GError *e; + gboolean result; + + g_return_val_if_fail(chupar != NULL, FALSE); + g_return_val_if_fail(input != NULL, FALSE); + g_return_val_if_fail(error == NULL || *error == NULL, FALSE); mime_type = chupa_text_input_get_mime_type(input); if (!mime_type) { - g_error("can't determin mime-type\n"); + e = chupa_text_error_new_literal(CHUPA_TEXT_ERROR_UNKNOWN_CONTENT, + "can't determin mime-type"); + g_propagate_error(error, e); + result = FALSE; } else if (dec = chupa_decomposer_search(mime_type)) { - chupa_decomposer_feed(dec, chupar, input); + result = chupa_decomposer_feed(dec, chupar, input, error); g_object_unref(dec); + result = TRUE; } else { - g_warning("unknown mime-type %s\n", mime_type); + e = chupa_text_error_new(CHUPA_TEXT_ERROR_UNKNOWN_MIMETYPE, + "unknown mime-type %s", mime_type); + g_propagate_error(error, e); + result = FALSE; } + return result; } /** @@ -140,19 +154,26 @@ chupa_text_feed(ChupaText *chupar, ChupaTextInput *input) * Feeds @input to @chupar, with @func */ void -chupa_text_decompose(ChupaText *chupar, ChupaTextInput *input, ChupaTextCallback func, gpointer arg) +chupa_text_decompose(ChupaText *chupar, ChupaTextInput *input, + ChupaTextCallback func, gpointer arg, GError **error) { chupa_text_connect_decomposed(chupar, func, arg); - chupa_text_feed(chupar, input); + chupa_text_feed(chupar, input, error); } +struct decompose_arg { + char *read_data; + gsize length; + GError **error; +}; + static void text_decomposed(ChupaText *chupar, ChupaTextInput *input, gpointer udata) { GDataInputStream *data = G_DATA_INPUT_STREAM(chupa_text_input_get_stream(input)); - gsize length; + struct decompose_arg *arg = udata; - *(gpointer *)udata = g_data_input_stream_read_until(data, "", &length, NULL, NULL); + arg->read_data = g_data_input_stream_read_until(data, "", &arg->length, NULL, arg->error); } /** @@ -167,9 +188,12 @@ text_decomposed(ChupaText *chupar, ChupaTextInput *input, gpointer udata) * are combined. */ char * -chupa_text_decompose_all(ChupaText *chupar, ChupaTextInput *input) +chupa_text_decompose_all(ChupaText *chupar, ChupaTextInput *input, GError **error) { - char *read_data = NULL; - chupa_text_decompose(chupar, input, text_decomposed, &read_data); - return read_data; + struct decompose_arg arg; + arg.read_data = NULL; + arg.length = 0; + arg.error = error; + chupa_text_decompose(chupar, input, text_decomposed, &arg, error); + return arg.read_data; } Modified: chupatext/chupa_text.h (+19 -3) =================================================================== --- chupatext/chupa_text.h 2010-09-13 05:53:43 +0000 (1c4ec7d) +++ chupatext/chupa_text.h 2010-09-13 06:57:08 +0000 (534c8a8) @@ -58,10 +58,26 @@ typedef void (*ChupaTextCallback)(ChupaText *, ChupaTextInput *, gpointer); GType chupa_text_get_type(void) G_GNUC_CONST; ChupaText *chupa_text_new(void); -void chupa_text_feed(ChupaText *chupar, ChupaTextInput *input); +gboolean chupa_text_feed(ChupaText *chupar, ChupaTextInput *input, GError **err); void chupa_text_decomposed(ChupaText *chupar, ChupaTextInput *input); guint chupa_text_connect_decomposed(ChupaText *chupar, ChupaTextCallback func, gpointer arg); -void chupa_text_decompose(ChupaText *chupar, ChupaTextInput *text_input, ChupaTextCallback func, gpointer arg); -char *chupa_text_decompose_all(ChupaText *chupar, ChupaTextInput *text_input); +void chupa_text_decompose(ChupaText *chupar, ChupaTextInput *text_input, + ChupaTextCallback func, gpointer arg, GError **error); +char *chupa_text_decompose_all(ChupaText *chupar, ChupaTextInput *text_input, GError **error); + +typedef enum { + CHUPA_TEXT_ERROR_NONE, + CHUPA_TEXT_ERROR_UNKNOWN_CONTENT, + CHUPA_TEXT_ERROR_UNKNOWN_MIMETYPE, + CHUPA_TEXT_ERROR_INVALID_INPUT, + CHUPA_TEXT_ERROR_MAX_ +} ChupaTextError; + +#define CHUPA_TEXT_ERROR chupa_text_error_quark() + +GQuark chupa_text_error_quark(void) G_GNUC_CONST; +GError *chupa_text_error_new_valist(ChupaTextError code, const char *format, va_list args); +GError *chupa_text_error_new(ChupaTextError code, const char *format, ...); +GError *chupa_text_error_new_literal(ChupaTextError code, const char *message); #endif Modified: chupatext/chupa_text_input.c (+2 -2) =================================================================== --- chupatext/chupa_text_input.c 2010-09-13 05:53:43 +0000 (65cdf62) +++ chupatext/chupa_text_input.c 2010-09-13 06:57:08 +0000 (4ab580b) @@ -354,10 +354,10 @@ chupa_text_input_new_from_stream(ChupaMetadata *metadata, GInputStream *stream, } ChupaTextInput * -chupa_text_input_new_from_file(ChupaMetadata *metadata, GFile *file) +chupa_text_input_new_from_file(ChupaMetadata *metadata, GFile *file, GError **err) { ChupaTextInput *text; - GsfInput *input = gsf_input_gio_new(file, NULL); + GsfInput *input = gsf_input_gio_new(file, err); if (!input) { return NULL; } Modified: chupatext/chupa_text_input.h (+1 -1) =================================================================== --- chupatext/chupa_text_input.h 2010-09-13 05:53:43 +0000 (35a8a05) +++ chupatext/chupa_text_input.h 2010-09-13 06:57:08 +0000 (086182b) @@ -43,7 +43,7 @@ struct _ChupaTextInputClass GType chupa_text_input_get_type(void) G_GNUC_CONST; ChupaTextInput *chupa_text_input_new(ChupaMetadata *metadata, GsfInput *inpt); ChupaTextInput *chupa_text_input_new_from_stream(ChupaMetadata *metadata, GInputStream *stream, const char *path); -ChupaTextInput *chupa_text_input_new_from_file(ChupaMetadata *metadata, GFile *file); +ChupaTextInput *chupa_text_input_new_from_file(ChupaMetadata *metadata, GFile *file, GError **err); ChupaMetadata *chupa_text_input_get_metadata(ChupaTextInput *input); const gchar *chupa_text_input_get_mime_type(ChupaTextInput *input); GsfInput *chupa_text_input_get_base_input(ChupaTextInput *input); Added: chupatext/error.c (+43 -0) 100644 =================================================================== --- /dev/null +++ chupatext/error.c 2010-09-13 06:57:08 +0000 (cb90e13) @@ -0,0 +1,43 @@ +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Copyright (C) 2010 Nobuyoshi Nakada + */ + +#include "chupatext/chupa_text.h" + + +GQuark +chupa_text_error_quark(void) +{ + static GQuark error_quark = 0; + + if (G_UNLIKELY(error_quark == 0)) { + error_quark = g_quark_from_static_string("chupa-text-error-quark"); + } + + return error_quark; +} + +GError * +chupa_text_error_new_valist(ChupaTextError code, const char *format, va_list args) +{ + return g_error_new_valist(CHUPA_TEXT_ERROR, code, format, args); +} + +GError * +chupa_text_error_new(ChupaTextError code, const char *format, ...) +{ + va_list args; + GError *error; + + va_start(args, format); + error = chupa_text_error_new_valist(code, format, args); + va_end(args); + return error; +} + +GError * +chupa_text_error_new_literal(ChupaTextError code, const char *message) +{ + return g_error_new_literal(CHUPA_TEXT_ERROR, code, message); +} Modified: chupatext/text_decomposer.c (+3 -2) =================================================================== --- chupatext/text_decomposer.c 2010-09-13 05:53:43 +0000 (b394341) +++ chupatext/text_decomposer.c 2010-09-13 06:57:08 +0000 (631bd69) @@ -12,10 +12,11 @@ chupa_text_decomposer_init(ChupaTextDecomposer *text_decomposer) { } -static void -chupa_text_decomposer_feed(ChupaDecomposer *dec, ChupaText *text, ChupaTextInput *input) +static gboolean +chupa_text_decomposer_feed(ChupaDecomposer *dec, ChupaText *text, ChupaTextInput *input, GError **err) { chupa_text_decomposed(text, input); + return TRUE; } static void Modified: module/chupa_msword.c (+6 -3) =================================================================== --- module/chupa_msword.c 2010-09-13 05:53:43 +0000 (ea0a254) +++ module/chupa_msword.c 2010-09-13 06:57:08 +0000 (e0c054a) @@ -127,8 +127,9 @@ char_proc(wvParseStruct *ps, U16 eachchar, U8 chartype, U16 lid) return 0; } -static void -chupa_msword_decomposer_feed(ChupaDecomposer *dec, ChupaText *chupar, ChupaTextInput *input) +static gboolean +chupa_msword_decomposer_feed(ChupaDecomposer *dec, ChupaText *chupar, + ChupaTextInput *input, GError **err) { struct char_proc_arg arg; wvParseStruct ps; @@ -144,7 +145,9 @@ chupa_msword_decomposer_feed(ChupaDecomposer *dec, ChupaText *chupar, ChupaTextI gsf_input_seek(gi, 0, G_SEEK_SET); if ((ret = wvInitParser_gsf(&ps, gi)) != 0) { - g_warning("wvInitParser_gsf failed: %d", ret); + g_propagate_error(err, chupa_text_error_new(CHUPA_TEXT_ERROR_INVALID_INPUT, + "wvInitParser_gsf failed: %d", + ret)); return; } ps.userData = &arg; Modified: module/chupa_pdf.c (+8 -6) =================================================================== --- module/chupa_pdf.c 2010-09-13 05:53:43 +0000 (1c0eaa3) +++ module/chupa_pdf.c 2010-09-13 06:57:08 +0000 (232af80) @@ -35,8 +35,9 @@ struct _ChupaPDFDecomposerClass static GType chupa_type_pdf_decomposer = 0; -static void -chupa_pdf_decomposer_feed(ChupaDecomposer *dec, ChupaText *chupar, ChupaTextInput *input) +static gboolean +chupa_pdf_decomposer_feed(ChupaDecomposer *dec, ChupaText *chupar, + ChupaTextInput *input, GError **err) { PopplerDocument *doc; GError **error = NULL; @@ -51,18 +52,18 @@ chupa_pdf_decomposer_feed(ChupaDecomposer *dec, ChupaText *chupar, ChupaTextInpu const char *name = gsf_input_name(chupa_text_input_get_base_input(input)); int n, i; - while ((count = g_input_stream_read(inp, buffer, bufsize, NULL, NULL)) > 0) { + while ((count = g_input_stream_read(inp, buffer, bufsize, NULL, err)) > 0) { g_string_append_len(str, buffer, count); if (count < bufsize) break; } if (count < 0) { g_string_free(str, TRUE); - return; + return FALSE; } - doc = poppler_document_new_from_data(str->str, str->len, NULL, NULL); + doc = poppler_document_new_from_data(str->str, str->len, NULL, err); if (!doc) { g_string_free(str, TRUE); - return; + return FALSE; } n = poppler_document_get_n_pages(doc); for (i = 0; i < n; ++i) { @@ -90,6 +91,7 @@ chupa_pdf_decomposer_feed(ChupaDecomposer *dec, ChupaText *chupar, ChupaTextInpu g_string_free(str, TRUE); g_object_unref(mem); g_object_unref(pdf_text); + return TRUE; } static void Modified: test/chupa_test_util.c (+11 -5) =================================================================== --- test/chupa_test_util.c 2010-09-13 05:53:43 +0000 (56baef9) +++ test/chupa_test_util.c 2010-09-13 06:57:08 +0000 (dc8b294) @@ -22,7 +22,7 @@ chupa_test_teardown(void) #define TAKE_STRING(str) cut_take_string(str) char * -chupa_test_decompose_data(const char *text, gsize size) +chupa_test_decompose_data(const char *text, gsize size, GError **err) { ChupaText *chupar; ChupaTextInput *text_input; @@ -32,12 +32,15 @@ chupa_test_decompose_data(const char *text, gsize size) TAKE_OBJECT(chupar = chupa_text_new()); TAKE_OBJECT(mem = g_memory_input_stream_new_from_data(text, size, NULL)); TAKE_OBJECT(text_input = chupa_text_input_new_from_stream(NULL, mem, NULL)); - TAKE_STRING(str = chupa_text_decompose_all(chupar, text_input)); + if (!text_input) { + return NULL; + } + TAKE_STRING(str = chupa_text_decompose_all(chupar, text_input, err)); return str; } char * -chupa_test_decompose_fixture(const char *fixture) +chupa_test_decompose_fixture(const char *fixture, GError **err) { ChupaText *chupar; ChupaTextInput *text_input; @@ -49,7 +52,10 @@ chupa_test_decompose_fixture(const char *fixture) TAKE_OBJECT(chupar = chupa_text_new()); TAKE_STRING(sample_path = cut_build_fixture_data_path(fixture, NULL)); TAKE_OBJECT(sample_file = g_file_new_for_path(sample_path)); - TAKE_OBJECT(text_input = chupa_text_input_new_from_file(NULL, sample_file)); - TAKE_STRING(str = chupa_text_decompose_all(chupar, text_input)); + TAKE_OBJECT(text_input = chupa_text_input_new_from_file(NULL, sample_file, err)); + if (!text_input) { + return NULL; + } + TAKE_STRING(str = chupa_text_decompose_all(chupar, text_input, err)); return str; } Modified: test/chupa_test_util.h (+2 -2) =================================================================== --- test/chupa_test_util.h 2010-09-13 05:53:43 +0000 (10d994e) +++ test/chupa_test_util.h 2010-09-13 06:57:08 +0000 (4eab9ff) @@ -14,7 +14,7 @@ void chupa_test_setup(void); void chupa_test_teardown(void); -char *chupa_test_decompose_fixture(const char *fixture); -char *chupa_test_decompose_data(const char *text, gsize size); +char *chupa_test_decompose_fixture(const char *fixture, GError **err); +char *chupa_test_decompose_data(const char *text, gsize size, GError **err); #endif Modified: test/test_msword.c (+2 -2) =================================================================== --- test/test_msword.c 2010-09-13 05:53:43 +0000 (3207a6d) +++ test/test_msword.c 2010-09-13 06:57:08 +0000 (a5f861f) @@ -22,11 +22,11 @@ teardown(void) void test_decompose_msword(void) { - cut_assert_equal_string("Sample\n\n", decompose_msword("sample.doc")); + cut_assert_equal_string("Sample\n\n", decompose_msword("sample.doc", NULL)); } void test_decompose_msword_ja(void) { - cut_assert_equal_string("Sample\n?????\n", decompose_msword("sample_ja.doc")); + cut_assert_equal_string("Sample\n?????\n", decompose_msword("sample_ja.doc", NULL)); } Modified: test/test_pdf.c (+1 -1) =================================================================== --- test/test_pdf.c 2010-09-13 05:53:43 +0000 (d442ccb) +++ test/test_pdf.c 2010-09-13 06:57:08 +0000 (85a661f) @@ -22,5 +22,5 @@ teardown(void) void test_decompose_pdf(void) { - cut_assert_equal_string("sample\n", decompose_pdf("sample.pdf")); + cut_assert_equal_string("sample\n", decompose_pdf("sample.pdf", NULL)); } Modified: test/test_tar.c (+1 -1) =================================================================== --- test/test_tar.c 2010-09-13 05:53:43 +0000 (1f4ba75) +++ test/test_tar.c 2010-09-13 06:57:08 +0000 (33062e9) @@ -22,5 +22,5 @@ teardown(void) void test_decompose_tar(void) { - cut_assert_equal_string("sample\n", decompose_tar("sample.tar.gz")); + cut_assert_equal_string("sample\n", decompose_tar("sample.tar.gz", NULL)); } Modified: test/test_text.c (+1 -1) =================================================================== --- test/test_text.c 2010-09-13 05:53:43 +0000 (c22cdd2) +++ test/test_text.c 2010-09-13 06:57:08 +0000 (551155e) @@ -29,5 +29,5 @@ test_decompose_text_plain (void) { static const char plain_text[] = "plain text\n"; - cut_assert_equal_string(plain_text, decompose_text(plain_text, sizeof(plain_text) - 1)); + cut_assert_equal_string(plain_text, decompose_text(plain_text, sizeof(plain_text) - 1, NULL)); } Modified: test/test_zip.c (+1 -1) =================================================================== --- test/test_zip.c 2010-09-13 05:53:43 +0000 (f9ce23b) +++ test/test_zip.c 2010-09-13 06:57:08 +0000 (13bee36) @@ -22,5 +22,5 @@ teardown(void) void test_decompose_zip(void) { - cut_assert_equal_string("sample\n", decompose_zip("sample.zip")); + cut_assert_equal_string("sample\n", decompose_zip("sample.zip", NULL)); } From null+ranguba at clear-code.com Mon Sep 13 03:03:49 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Mon, 13 Sep 2010 07:03:49 +0000 Subject: [groonga-commit:1265] ranguba/chupatext [master] * chupatext/version.c (chupa_version_string): added. * chupatext/version.c (chupa_version_description): added. Message-ID: <20100913074546.3E224278005@taiyaki.ru> Nobuyoshi Nakada 2010-09-13 07:03:49 +0000 (Mon, 13 Sep 2010) New Revision: 43ff4f8b5f923f97cfbb2814f28f98c50079616a Log: * chupatext/version.c (chupa_version_string): added. * chupatext/version.c (chupa_version_description): added. Modified files: chupatext.h chupatext/version.c Modified: chupatext.h (+2 -0) =================================================================== --- chupatext.h 2010-09-13 07:03:17 +0000 (8ec217f) +++ chupatext.h 2010-09-13 07:03:49 +0000 (8e2f964) @@ -16,6 +16,8 @@ int chupa_cleanup(void); const int chupa_version(void) G_GNUC_CONST; const int chupa_commits(void) G_GNUC_CONST; const int chupa_release_date(void) G_GNUC_CONST; +const char *chupa_version_string(void) G_GNUC_CONST; +const char *chupa_version_description(void) G_GNUC_CONST; G_END_DECLS Modified: chupatext/version.c (+15 -1) =================================================================== --- chupatext/version.c 2010-09-13 07:03:17 +0000 (42bcf0d) +++ chupatext/version.c 2010-09-13 07:03:49 +0000 (302740e) @@ -11,6 +11,12 @@ chupa_version(void) return CHUPA_VERSION_CODE; } +const char * +chupa_version_string(void) +{ + return CHUPA_VERSION_STRING; +} + const int chupa_commits(void) { @@ -25,6 +31,14 @@ chupa_release_date(void) #define STRINGIFY_ARG(x) #x #define STRINGIFY(x) STRINGIFY_ARG(x) -const char chupa_ident[] = "$Ident: ChupaText " +#define CHUPA_DESCRIPTION "ChupaText " \ CHUPA_VERSION_STRING "-" STRINGIFY(CHUPA_COMMITS) + +const char * +chupa_version_description(void) +{ + return CHUPA_DESCRIPTION; +} + +const char chupa_ident[] = "$Ident: " CHUPA_DESCRIPTION " $"; From null+ranguba at clear-code.com Mon Sep 13 01:52:39 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Mon, 13 Sep 2010 05:52:39 +0000 Subject: [groonga-commit:1266] ranguba/chupatext [master] * chupatext/chupa_text_input.c (chupa_text_input_new): check argument. (chupa_text_input_new_from_stream): ditto. (chupa_text_input_new_from_file): ditto. Message-ID: <20100913074546.0BEE1170536@taiyaki.ru> Nobuyoshi Nakada 2010-09-13 05:52:39 +0000 (Mon, 13 Sep 2010) New Revision: ac146210ef3e6b60f43c3b43df45957ff9518021 Log: * chupatext/chupa_text_input.c (chupa_text_input_new): check argument. (chupa_text_input_new_from_stream): ditto. (chupa_text_input_new_from_file): ditto. Modified files: chupatext/chupa_text_input.c Modified: chupatext/chupa_text_input.c (+7 -1) =================================================================== --- chupatext/chupa_text_input.c 2010-09-13 05:29:30 +0000 (8c46536) +++ chupatext/chupa_text_input.c 2010-09-13 05:52:39 +0000 (65cdf62) @@ -323,7 +323,9 @@ ChupaTextInput * chupa_text_input_new(ChupaMetadata *metadata, GsfInput *input) { const char *path; - if (input && (path = gsf_input_name(input))) { + + g_return_val_if_fail(input, NULL); + if ((path = gsf_input_name(input)) != NULL) { if (!metadata) { metadata = chupa_metadata_new(); } @@ -338,6 +340,7 @@ chupa_text_input_new(ChupaMetadata *metadata, GsfInput *input) ChupaTextInput * chupa_text_input_new_from_stream(ChupaMetadata *metadata, GInputStream *stream, const char *path) { + g_return_val_if_fail(stream, NULL); if (path) { if (!metadata) { metadata = chupa_metadata_new(); @@ -355,6 +358,9 @@ chupa_text_input_new_from_file(ChupaMetadata *metadata, GFile *file) { ChupaTextInput *text; GsfInput *input = gsf_input_gio_new(file, NULL); + if (!input) { + return NULL; + } text = chupa_text_input_new(metadata, input); g_object_unref(input); return text; From null+ranguba at clear-code.com Mon Sep 13 04:47:17 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Mon, 13 Sep 2010 08:47:17 +0000 Subject: [groonga-commit:1267] ranguba/rroonga [master] use TokenBigramSplitSymbol. Message-ID: <20100913084729.C6674170536@taiyaki.ru> Kouhei Sutou 2010-09-13 08:47:17 +0000 (Mon, 13 Sep 2010) New Revision: 9928cfb697c5a89d7a2e50debdb349f721a34eae Log: use TokenBigramSplitSymbol. Modified files: test/test-table-select-normalize.rb Modified: test/test-table-select-normalize.rb (+7 -3) =================================================================== --- test/test-table-select-normalize.rb 2010-09-12 00:18:36 +0000 (4e01470) +++ test/test-table-select-normalize.rb 2010-09-13 08:47:17 +0000 (48c20e9) @@ -25,11 +25,15 @@ class TableSelectNormalizeTest < Test::Unit::TestCase @comments = Groonga::Array.create(:name => "Comments") @comments.define_column("content", "Text") @comments.define_column("created_at", "Time") - terms = Groonga::PatriciaTrie.create(:name => "Terms", - :default_tokenizer => "TokenBigram", - :key_normalize => true) + options = { + :name => "Terms", + :default_tokenizer => "TokenBigramSplitSymbol", + :key_normalize => true, + } + terms = Groonga::PatriciaTrie.create(options) terms.define_index_column("comment_content", @comments, :with_section => true, + :with_position => true, :source => "Comments.content") @japanese_comment = @comments.add(:content => "?????TV?????...????????", From null+ranguba at clear-code.com Mon Sep 13 05:14:47 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Mon, 13 Sep 2010 09:14:47 +0000 Subject: [groonga-commit:1268] ranguba/rroonga [master] -> Text. Message-ID: <20100913091500.72902278001@taiyaki.ru> Kouhei Sutou 2010-09-13 09:14:47 +0000 (Mon, 13 Sep 2010) New Revision: 7daf17a59da1d64e277b16bdfa6013a7cd52e2cb Log: -> Text. Modified files: test/test-patricia-trie.rb Modified: test/test-patricia-trie.rb (+1 -1) =================================================================== --- test/test-patricia-trie.rb 2010-09-13 08:47:17 +0000 (d787084) +++ test/test-patricia-trie.rb 2010-09-13 09:14:47 +0000 (f774873) @@ -57,7 +57,7 @@ class PatriciaTrieTest < Test::Unit::TestCase def test_add users = Groonga::PatriciaTrie.create(:name => "Users") - users.define_column("address", "") + users.define_column("address", "Text") me = users.add("me", :address => "me at example.com") assert_equal("me at example.com", me[:address]) end From null+ranguba at clear-code.com Mon Sep 13 05:33:18 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Mon, 13 Sep 2010 09:33:18 +0000 Subject: [groonga-commit:1269] ranguba/rroonga [master] add Record#support_sub_records?. Message-ID: <20100913093330.CDBCD170536@taiyaki.ru> Kouhei Sutou 2010-09-13 09:33:18 +0000 (Mon, 13 Sep 2010) New Revision: e763b53639fba9365b5c4eeba65e3372fdcd3343 Log: add Record#support_sub_records?. Modified files: lib/groonga/record.rb test/test-record.rb Modified: lib/groonga/record.rb (+12 -0) =================================================================== --- lib/groonga/record.rb 2010-09-13 09:14:47 +0000 (37987a0) +++ lib/groonga/record.rb 2010-09-13 09:33:18 +0000 (d11770f) @@ -144,11 +144,23 @@ module Groonga # # ????????????????????????????? # ??????????????????? + # + # Groonga::Record#support_sub_records????????? + # ??????? def n_sub_records self["._nsubrecs"] end # call-seq: + # record.support_sub_records -> true/false + # + # Groonga::Record#n_sub_records?????????true? + # ??? + def support_sub_records? + @table.support_sub_records? + end + + # call-seq: # record.value -> ? # # ?????????? Modified: test/test-record.rb (+7 -0) =================================================================== --- test/test-record.rb 2010-09-13 09:14:47 +0000 (71b8a87) +++ test/test-record.rb 2010-09-13 09:33:18 +0000 (e2628f3) @@ -268,4 +268,11 @@ class RecordTest < Test::Unit::TestCase groonga = @bookmarks.add(:user => morita, :uri => "http://groonga.org") assert_equal("morita", groonga.user.key) end + + def test_support_sub_records + morita = @users.add("morita") + assert_not_predicate(morita, :support_sub_records?) + users = @users.select {|record| record.key == "morita"} + assert_predicate(users.to_a[0], :support_sub_records?) + end end From null+ranguba at clear-code.com Mon Sep 13 05:41:23 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Mon, 13 Sep 2010 09:41:23 +0000 Subject: [groonga-commit:1270] ranguba/rroonga [master] fix a typo. Message-ID: <20100913094133.A8822170536@taiyaki.ru> Kouhei Sutou 2010-09-13 09:41:23 +0000 (Mon, 13 Sep 2010) New Revision: a230be49e563787ab651251f4c3f262095e04a9c Log: fix a typo. Modified files: lib/groonga/record.rb Modified: lib/groonga/record.rb (+1 -1) =================================================================== --- lib/groonga/record.rb 2010-09-13 09:33:18 +0000 (d11770f) +++ lib/groonga/record.rb 2010-09-13 09:41:23 +0000 (82d4031) @@ -152,7 +152,7 @@ module Groonga end # call-seq: - # record.support_sub_records -> true/false + # record.support_sub_records? -> true/false # # Groonga::Record#n_sub_records?????????true? # ??? From null+ranguba at clear-code.com Mon Sep 13 20:48:32 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Tue, 14 Sep 2010 00:48:32 +0000 Subject: [groonga-commit:1271] ranguba/chupatext [master] * chupatext/archive_decomposer.c (feed): set filename. Message-ID: <20100914004918.0DAEC278001@taiyaki.ru> Nobuyoshi Nakada 2010-09-14 00:48:32 +0000 (Tue, 14 Sep 2010) New Revision: f0f56d3cef4223c6279967921550f588af174ad7 Log: * chupatext/archive_decomposer.c (feed): set filename. Modified files: chupatext/archive_decomposer.c Modified: chupatext/archive_decomposer.c (+3 -0) =================================================================== --- chupatext/archive_decomposer.c 2010-09-13 07:55:20 +0000 (18a79db) +++ chupatext/archive_decomposer.c 2010-09-14 00:48:32 +0000 (bb32991) @@ -82,6 +82,9 @@ feed(ChupaDecomposer *dec, ChupaText *chupar, ChupaTextInput *input, GError **er GsfInput *inp = gsf_infile_child_by_index(infile, i); ChupaTextInput *t = chupa_text_input_new(NULL, inp); g_object_unref(inp); + if (name) { + chupa_metadata_add_value(chupa_text_input_get_metadata(t), "filename", name); + } result = chupa_text_feed(chupar, t, err); g_object_unref(t); if (!result) { From null+ranguba at clear-code.com Mon Sep 13 21:09:38 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Tue, 14 Sep 2010 01:09:38 +0000 Subject: [groonga-commit:1272] ranguba/rroonga [master] add Groonga::Record#eql? and #hash for uniq. Message-ID: <20100914010957.A1D18170536@taiyaki.ru> Kouhei Sutou 2010-09-14 01:09:38 +0000 (Tue, 14 Sep 2010) New Revision: 9175130266469fbaf8d6f56d17bc821834e2e2c6 Log: add Groonga::Record#eql? and #hash for uniq. Modified files: lib/groonga/record.rb Modified: lib/groonga/record.rb (+20 -2) =================================================================== --- lib/groonga/record.rb 2010-09-13 09:41:23 +0000 (82d4031) +++ lib/groonga/record.rb 2010-09-14 01:09:38 +0000 (86b5452) @@ -44,14 +44,32 @@ module Groonga # call-seq: # record == other -> true/false # - # _record_?_other_???groonga???????+true+???? - # ???????+false+???? + # _record_?_other_?????????????????? + # ??????ID?????+true+??????????? + # +false+???? def ==(other) self.class == other.class and [table, id] == [other.table, other.id] end # call-seq: + # record.eql?(other) -> true/false + # + # Groonga::Record#==???? + def eql?(other) + self == other + end + + # call-seq: + # record.hash -> ????? + # + # ?????????ID?????????????????? + # ????? + def hash + @table.hash ^ @id.hash + end + + # call-seq: # record[column_name] -> ? # # ???????_column_name_??????????????? From null+ranguba at clear-code.com Mon Sep 13 20:50:06 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Tue, 14 Sep 2010 00:50:06 +0000 Subject: [groonga-commit:1273] ranguba/chupatext [master] * chupatext/archive_decomposer.h (ChupaArchiveDecomposerClass): add private method feed_component(). Message-ID: <20100914072927.D3F6F1704C0@taiyaki.ru> Nobuyoshi Nakada 2010-09-14 00:50:06 +0000 (Tue, 14 Sep 2010) New Revision: d54bab049af46c52268da9198bd1451a383e66da Log: * chupatext/archive_decomposer.h (ChupaArchiveDecomposerClass): add private method feed_component(). Modified files: chupatext/archive_decomposer.c chupatext/archive_decomposer.h Modified: chupatext/archive_decomposer.c (+5 -2) =================================================================== --- chupatext/archive_decomposer.c 2010-09-14 00:48:32 +0000 (bb32991) +++ chupatext/archive_decomposer.c 2010-09-14 00:50:06 +0000 (66e4028) @@ -67,12 +67,14 @@ feed(ChupaDecomposer *dec, ChupaText *chupar, ChupaTextInput *input, GError **er GsfInfile *infile; GsfInput *inp; gboolean result = TRUE; + ChupaArchiveDecomposerClass *arch_class; int i, num; g_return_if_fail(CHUPA_IS_ARCHIVE_DECOMPOSER(dec)); g_return_if_fail(CHUPA_IS_TEXT_INPUT(input)); + arch_class = CHUPA_ARCHIVE_DECOMPOSER_GET_CLASS(dec); inp = chupa_text_input_get_base_input(input); - infile = CHUPA_ARCHIVE_DECOMPOSER_GET_CLASS(dec)->get_infile(inp, NULL); + infile = arch_class->get_infile(inp, err); if (!infile) { return; } @@ -85,7 +87,7 @@ feed(ChupaDecomposer *dec, ChupaText *chupar, ChupaTextInput *input, GError **er if (name) { chupa_metadata_add_value(chupa_text_input_get_metadata(t), "filename", name); } - result = chupa_text_feed(chupar, t, err); + result = arch_class->feed_component(chupar, t, err); g_object_unref(t); if (!result) { break; @@ -110,4 +112,5 @@ chupa_archive_decomposer_class_init(ChupaArchiveDecomposerClass *klass) gobject_class->set_property = set_property; gobject_class->get_property = get_property; decomposer_class->feed = feed; + CHUPA_ARCHIVE_DECOMPOSER_CLASS(klass)->feed_component = chupa_text_feed; } Modified: chupatext/archive_decomposer.h (+1 -0) =================================================================== --- chupatext/archive_decomposer.h 2010-09-14 00:48:32 +0000 (c7bcbab) +++ chupatext/archive_decomposer.h 2010-09-14 00:50:06 +0000 (9c5ed1f) @@ -37,6 +37,7 @@ struct _ChupaArchiveDecomposerClass ChupaDecomposerClass parent_class; GsfInfile *(*get_infile)(GsfInput *input, GError **error); + gboolean (*feed_component)(ChupaText *chupar, ChupaTextInput *input, GError **error); }; GType chupa_archive_decomposer_get_type(void) G_GNUC_CONST; From null+ranguba at clear-code.com Tue Sep 14 03:27:07 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Tue, 14 Sep 2010 07:27:07 +0000 Subject: [groonga-commit:1274] ranguba/chupatext [master] * chupatext/chupa_decomposer.c (chupa_decomposer_search): autoload modules by name from mime-type. Message-ID: <20100914072928.083D5278002@taiyaki.ru> Nobuyoshi Nakada 2010-09-14 07:27:07 +0000 (Tue, 14 Sep 2010) New Revision: 0478edc1235b1c49965259a7b90cd956990faee1 Log: * chupatext/chupa_decomposer.c (chupa_decomposer_search): autoload modules by name from mime-type. Modified files: chupatext/chupa_decomposer.c chupatext/chupa_module.c module/chupa_msword.c module/chupa_tar.c Modified: chupatext/chupa_decomposer.c (+32 -9) =================================================================== --- chupatext/chupa_decomposer.c 2010-09-14 07:25:19 +0000 (bfd12c4) +++ chupatext/chupa_decomposer.c 2010-09-14 07:27:07 +0000 (a046097) @@ -59,6 +59,7 @@ chupa_decomposer_feed(ChupaDecomposer *dec, ChupaText *text, ChupaTextInput *inp } static const char text_plain[] = "text/plain"; +static GList *load_modules = NULL; void chupa_decomposer_load_modules(void) @@ -67,7 +68,7 @@ chupa_decomposer_load_modules(void) chupa_decomposer_register(text_plain, CHUPA_TYPE_TEXT_DECOMPOSER); base_dir = chupa_module_path(); - chupa_module_load_modules(base_dir); + load_modules = chupa_module_load_modules(base_dir); g_free(base_dir); } @@ -101,22 +102,44 @@ chupa_decomposer_unregister(const gchar *mime_type, GType type) } ChupaDecomposer * -chupa_decomposer_search(const gchar *mime_type) +chupa_decomposer_search(const gchar *const mime_type) { GList *type_list = NULL; - const gchar *slash; + const char *sub_type; gpointer key, value; + again: if (g_hash_table_lookup_extended(decomp_modules, mime_type, &key, &value)) { type_list = (GList *)value; } - else if ((slash = strchr((const char *)mime_type, '/')) != NULL) { - GString *tmp_type = g_string_new_len(mime_type, slash + 1 - mime_type); - g_string_append_c(tmp_type, '*'); - if (g_hash_table_lookup_extended(decomp_modules, tmp_type->str, &key, &value)) { - type_list = (GList *)value; + else if ((sub_type = strchr((const char *)mime_type, '/')) != NULL) { + ++sub_type; + if (sub_type[0] == 'x' && sub_type[1] == '-') { + GString *tmp_type = g_string_new_len(mime_type, sub_type - mime_type); + g_string_append(tmp_type, sub_type += 2); + if (g_hash_table_lookup_extended(decomp_modules, tmp_type->str, &key, &value)) { + type_list = (GList *)value; + } + g_string_free(tmp_type, TRUE); + } + if (!type_list) { + const char *dot = strchr(sub_type, '.'); + gsize i; + char *p; + ChupaModule *mod; + GString *mod_name = g_string_new(dot ? dot + 1 : sub_type); + for (i = 0; (p = strchr(mod_name->str + i, '-')) != NULL; ) { + g_string_erase(mod_name, i = p - mod_name->str, 1); + } + mod = chupa_module_find(load_modules, mod_name->str); + g_string_free(mod_name, TRUE); + if (mod) { + load_modules = g_list_remove(load_modules, mod); + if (g_type_module_use(G_TYPE_MODULE(mod))) { + goto again; + } + } } - g_string_free(tmp_type, TRUE); } if (!type_list) { Modified: chupatext/chupa_module.c (+0 -1) =================================================================== --- chupatext/chupa_module.c 2010-09-14 07:25:19 +0000 (f906e05) +++ chupatext/chupa_module.c 2010-09-14 07:27:07 +0000 (4f4fa89) @@ -360,7 +360,6 @@ GList * chupa_module_load_modules(const gchar *base_dir) { GList *modules = chupa_module_load_modules_unique(base_dir, NULL); - g_list_foreach(modules, (GFunc)g_type_module_use, NULL); return modules; } Modified: module/chupa_msword.c (+0 -1) =================================================================== --- module/chupa_msword.c 2010-09-14 07:25:19 +0000 (e0c054a) +++ module/chupa_msword.c 2010-09-14 07:27:07 +0000 (5a4ec80) @@ -201,7 +201,6 @@ register_type(GTypeModule *type_module) &info, 0); chupa_type_msword_decomposer = type; chupa_decomposer_register("application/msword", type); - chupa_decomposer_register("application/x-msword", type); } return type; } Modified: module/chupa_tar.c (+2 -2) =================================================================== --- module/chupa_tar.c 2010-09-14 07:25:19 +0000 (101cfda) +++ module/chupa_tar.c 2010-09-14 07:27:07 +0000 (9c01793) @@ -69,8 +69,8 @@ register_type(GTypeModule *type_module) "ChupaTARDecomposer", &info, 0); chupa_type_tar_decomposer = type; - chupa_decomposer_register("application/x-tar", type); - chupa_decomposer_register("application/x-compressed-tar", type); + chupa_decomposer_register("application/tar", type); + chupa_decomposer_register("application/compressed-tar", type); } return type; } From null+ranguba at clear-code.com Mon Sep 13 21:25:59 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Tue, 14 Sep 2010 01:25:59 +0000 Subject: [groonga-commit:1275] ranguba/chupatext [master] * chupatext/chupa_text_input.c (chupa_text_input_get_filename), (chupa_text_input_set_filename, chupa_text_input_get_charset), (chupa_text_input_set_charset): new accessors. Message-ID: <20100914072927.E351F170E0E@taiyaki.ru> Nobuyoshi Nakada 2010-09-14 01:25:59 +0000 (Tue, 14 Sep 2010) New Revision: c7d7893a7bac552a1f85f3d9bc034a17b33ac91b Log: * chupatext/chupa_text_input.c (chupa_text_input_get_filename), (chupa_text_input_set_filename, chupa_text_input_get_charset), (chupa_text_input_set_charset): new accessors. Modified files: chupatext/archive_decomposer.c chupatext/chupa.c chupatext/chupa_text_input.c chupatext/chupa_text_input.h Modified: chupatext/archive_decomposer.c (+1 -1) =================================================================== --- chupatext/archive_decomposer.c 2010-09-14 00:50:06 +0000 (66e4028) +++ chupatext/archive_decomposer.c 2010-09-14 01:25:59 +0000 (35f3eb3) @@ -85,7 +85,7 @@ feed(ChupaDecomposer *dec, ChupaText *chupar, ChupaTextInput *input, GError **er ChupaTextInput *t = chupa_text_input_new(NULL, inp); g_object_unref(inp); if (name) { - chupa_metadata_add_value(chupa_text_input_get_metadata(t), "filename", name); + chupa_text_input_set_filename(t, name); } result = arch_class->feed_component(chupar, t, err); g_object_unref(t); Modified: chupatext/chupa.c (+2 -3) =================================================================== --- chupatext/chupa.c 2010-09-14 00:50:06 +0000 (c9a4a54) +++ chupatext/chupa.c 2010-09-14 01:25:59 +0000 (49445a9) @@ -11,10 +11,9 @@ static void output_to_FILE(ChupaText *chupar, ChupaTextInput *input, gpointer udata) { GInputStream *inst = G_INPUT_STREAM(chupa_text_input_get_stream(input)); - ChupaMetadata *meta = chupa_text_input_get_metadata(input); FILE *out = udata; - const char *name = chupa_metadata_get_first_value(meta, "filename"); - const char *charset = chupa_metadata_get_first_value(meta, "charset"); + const char *name = chupa_text_input_get_filename(input); + const char *charset = chupa_text_input_get_charset(input); char buf[4096]; gssize size; Modified: chupatext/chupa_text_input.c (+34 -3) =================================================================== --- chupatext/chupa_text_input.c 2010-09-14 00:50:06 +0000 (4ab580b) +++ chupatext/chupa_text_input.c 2010-09-14 01:25:59 +0000 (91d9027) @@ -33,6 +33,9 @@ typedef struct { static void input_stream_file_file_iface_init(GFileIface *iface); +static const char meta_filename[] = "filename"; +static const char meta_charset[] = "charset"; + G_DEFINE_TYPE_WITH_CODE(InputStreamFile, input_stream_file, G_TYPE_OBJECT, G_IMPLEMENT_INTERFACE(G_TYPE_FILE, input_stream_file_file_iface_init)) @@ -188,7 +191,7 @@ constructed(GObject *object) } } else { - path = chupa_metadata_get_first_value(priv->metadata, "filename"); + path = chupa_metadata_get_first_value(priv->metadata, meta_filename); } if (!stream) { stream = G_INPUT_STREAM(chupa_text_input_stream_new(input)); @@ -329,7 +332,7 @@ chupa_text_input_new(ChupaMetadata *metadata, GsfInput *input) if (!metadata) { metadata = chupa_metadata_new(); } - chupa_metadata_add_value(metadata, "filename", path); + chupa_metadata_add_value(metadata, meta_filename, path); } return g_object_new(CHUPA_TYPE_TEXT_INPUT, "input", input, @@ -345,7 +348,7 @@ chupa_text_input_new_from_stream(ChupaMetadata *metadata, GInputStream *stream, if (!metadata) { metadata = chupa_metadata_new(); } - chupa_metadata_add_value(metadata, "filename", path); + chupa_metadata_add_value(metadata, meta_filename, path); } return g_object_new(CHUPA_TYPE_TEXT_INPUT, "stream", stream, @@ -399,3 +402,31 @@ chupa_text_input_get_mime_type(ChupaTextInput *input) ChupaMetadata *meta = chupa_text_input_get_metadata(input); return chupa_metadata_get_first_value(meta, "mime-type"); } + +const gchar * +chupa_text_input_get_filename(ChupaTextInput *input) +{ + ChupaMetadata *meta = chupa_text_input_get_metadata(input); + return chupa_metadata_get_first_value(meta, meta_filename); +} + +void +chupa_text_input_set_filename(ChupaTextInput *input, const char *filename) +{ + ChupaMetadata *meta = chupa_text_input_get_metadata(input); + chupa_metadata_add_value(meta, meta_filename, filename); +} + +const gchar * +chupa_text_input_get_charset(ChupaTextInput *input) +{ + ChupaMetadata *meta = chupa_text_input_get_metadata(input); + return chupa_metadata_get_first_value(meta, meta_charset); +} + +void +chupa_text_input_set_charset(ChupaTextInput *input, const char *charset) +{ + ChupaMetadata *meta = chupa_text_input_get_metadata(input); + chupa_metadata_add_value(meta, meta_charset, charset); +} Modified: chupatext/chupa_text_input.h (+4 -0) =================================================================== --- chupatext/chupa_text_input.h 2010-09-14 00:50:06 +0000 (086182b) +++ chupatext/chupa_text_input.h 2010-09-14 01:25:59 +0000 (a021fec) @@ -46,6 +46,10 @@ ChupaTextInput *chupa_text_input_new_from_stream(ChupaMetadata *metadata, GInput ChupaTextInput *chupa_text_input_new_from_file(ChupaMetadata *metadata, GFile *file, GError **err); ChupaMetadata *chupa_text_input_get_metadata(ChupaTextInput *input); const gchar *chupa_text_input_get_mime_type(ChupaTextInput *input); +const gchar *chupa_text_input_get_filename(ChupaTextInput *input); +void chupa_text_input_set_filename(ChupaTextInput *input, const char *filename); +const gchar *chupa_text_input_get_charset(ChupaTextInput *input); +void chupa_text_input_set_charset(ChupaTextInput *input, const char *charset); GsfInput *chupa_text_input_get_base_input(ChupaTextInput *input); GInputStream *chupa_text_input_get_stream(ChupaTextInput *input); From null+ranguba at clear-code.com Tue Sep 14 03:25:19 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Tue, 14 Sep 2010 07:25:19 +0000 Subject: [groonga-commit:1276] ranguba/chupatext [master] * chupatext/chupa_module.c (chupa_module_find): match by stem name of modules. Message-ID: <20100914072927.F1C52278001@taiyaki.ru> Nobuyoshi Nakada 2010-09-14 07:25:19 +0000 (Tue, 14 Sep 2010) New Revision: e7145c440e00c24c22146e7fb897226fdcf77b10 Log: * chupatext/chupa_module.c (chupa_module_find): match by stem name of modules. Modified files: chupatext/chupa_module.c Modified: chupatext/chupa_module.c (+2 -23) =================================================================== --- chupatext/chupa_module.c 2010-09-14 01:25:59 +0000 (39ffc29) +++ chupatext/chupa_module.c 2010-09-14 07:25:19 +0000 (f906e05) @@ -231,12 +231,8 @@ chupa_module_find(GList *modules, const gchar *name) GList *node; for (node = modules; node; node = g_list_next(node)) { - ChupaModule *module = node->data; - ChupaModulePrivate *priv; - - priv = CHUPA_MODULE_GET_PRIVATE(module); - if (_chupa_module_match_name(priv->mod_path, name)) - return module; + if (strcmp(G_TYPE_MODULE(node->data)->name, name) == 0) + return node->data; } return NULL; @@ -411,23 +407,6 @@ chupa_module_load_modules_unique(const gchar *base_dir, return g_list_concat(modules, exist_modules); } -static gboolean -_chupa_module_match_name(const gchar *mod_path, const gchar *name) -{ - gboolean matched; - gchar *module_base_name, *normalized_matched_name; - - module_base_name = g_path_get_basename(mod_path); - normalized_matched_name = g_strconcat(name, "." G_MODULE_SUFFIX, NULL); - - matched = (0 == strcmp(module_base_name, normalized_matched_name)); - - g_free(module_base_name); - g_free(normalized_matched_name); - - return matched; -} - void chupa_module_unload(ChupaModule *module) { From null+ranguba at clear-code.com Tue Sep 14 03:44:45 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Tue, 14 Sep 2010 07:44:45 +0000 Subject: [groonga-commit:1277] ranguba/chupatext [master] * test/test_msword.c (test_decompose_msword_ja): test for old formats. Message-ID: <20100914074507.83B8F1704C0@taiyaki.ru> Nobuyoshi Nakada 2010-09-14 07:44:45 +0000 (Tue, 14 Sep 2010) New Revision: 4d86a0e5ee6852a7dae17fc59c09373b3a564195 Log: * test/test_msword.c (test_decompose_msword_ja): test for old formats. Added files: test/fixtures/ja95.doc test/fixtures/ja97.doc Modified files: test/test_msword.c Added: test/fixtures/ja95.doc (+0 -0) 100644 =================================================================== (Binary files differ) Added: test/fixtures/ja97.doc (+0 -0) 100644 =================================================================== (Binary files differ) Modified: test/test_msword.c (+12 -0) =================================================================== --- test/test_msword.c 2010-09-14 07:27:07 +0000 (a5f861f) +++ test/test_msword.c 2010-09-14 07:44:45 +0000 (46b46f3) @@ -30,3 +30,15 @@ test_decompose_msword_ja(void) { cut_assert_equal_string("Sample\n?????\n", decompose_msword("sample_ja.doc", NULL)); } + +void +test_decompose_msword_ja97(void) +{ + cut_assert_equal_string("Sample of Word97\n???????Word97\n", decompose_msword("ja97.doc", NULL)); +} + +void +test_decompose_msword_ja95(void) +{ + cut_assert_equal_string("Sample of Word95\n???????Word95\n", decompose_msword("ja95.doc", NULL)); +} From null+ranguba at clear-code.com Tue Sep 14 03:47:22 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Tue, 14 Sep 2010 07:47:22 +0000 Subject: [groonga-commit:1278] ranguba/chupatext [master] * module/chupa_mspowerpoint.c: implementing vnd.ms-powerpoint. Message-ID: <20100914074817.57D0C1704C0@taiyaki.ru> Nobuyoshi Nakada 2010-09-14 07:47:22 +0000 (Tue, 14 Sep 2010) New Revision: 48aa3e2aaeaf26f57ada066d77a504c780d1136e Log: * module/chupa_mspowerpoint.c: implementing vnd.ms-powerpoint. Added files: module/chupa_mspowerpoint.c test/fixtures/sample.ppt test/test_mspowerpoint.c Modified files: module/Makefile.am test/Makefile.am Modified: module/Makefile.am (+6 -0) =================================================================== --- module/Makefile.am 2010-09-14 07:44:45 +0000 (44bf7e8) +++ module/Makefile.am 2010-09-14 07:47:22 +0000 (dbbaba3) @@ -14,6 +14,7 @@ endif if HAVE_WV module_LTLIBRARIES += chupa_msword.la endif +module_LTLIBRARIES += chupa_mspowerpoint.la nodist_chupa_tar_la_SOURCES = chupa_tar.c chupa_tar_la_LDFLAGS = -module @@ -35,4 +36,9 @@ chupa_msword_la_LDFLAGS = -module chupa_msword_la_CPPFLAGS = $(WV_CFLAGS) chupa_msword_la_LIBADD = $(WV_LIBS) $(GSF_LIBS) +chupa_mspowerpoint_la_SOURCES = chupa_mspowerpoint.c +chupa_mspowerpoint_la_LDFLAGS = -module +chupa_mspowerpoint_la_CPPFLAGS = $(GSF_CFLAGS) +chupa_mspowerpoint_la_LIBADD = $(GSF_LIBS) + DEFAULT_INCLUDES = -I$(top_includedir) -I$(build_includedir) Added: module/chupa_mspowerpoint.c (+419 -0) 100644 =================================================================== --- /dev/null +++ module/chupa_mspowerpoint.c 2010-09-14 07:47:22 +0000 (62a852a) @@ -0,0 +1,419 @@ +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Copyright (C) 2010 Nobuyoshi Nakada + */ + +#include +#include +#include +#include + +#define CHUPA_TYPE_PPT_DECOMPOSER chupa_type_ppt_decomposer +#define CHUPA_PPT_DECOMPOSER(obj) \ + G_TYPE_CHECK_INSTANCE_CAST(obj, CHUPA_TYPE_PPT_DECOMPOSER, ChupaPPTDecomposer) +#define CHUPA_PPT_DECOMPOSER_CLASS(klass) \ + G_TYPE_CHECK_CLASS_CAST(klass, CHUPA_TYPE_PPT_DECOMPOSER, ChupaPPTDecomposerClass) +#define CHUPA_IS_PPT_DECOMPOSER(obj) \ + G_TYPE_CHECK_INSTANCE_TYPE(obj, CHUPA_TYPE_PPT_DECOMPOSER) +#define CHUPA_IS_PPT_DECOMPOSER_CLASS(klass) \ + G_TYPE_CHECK_CLASS_TYPE(klass, CHUPA_TYPE_PPT_DECOMPOSER) +#define CHUPA_PPT_DECOMPOSER_GET_CLASS(obj) \ + G_TYPE_INSTANCE_GET_CLASS(obj, CHUPA_TYPE_PPT_DECOMPOSER, ChupaPPTDecomposerClass) + +typedef struct _ChupaPPTDecomposer ChupaPPTDecomposer; +typedef struct _ChupaPPTDecomposerClass ChupaPPTDecomposerClass; + +struct _ChupaPPTDecomposer +{ + ChupaArchiveDecomposer parent_object; +}; + +struct _ChupaPPTDecomposerClass +{ + ChupaArchiveDecomposerClass parent_class; +}; + +static GType chupa_type_ppt_decomposer = 0; + +/* borrowed from catdoc-0.94.2 */ +typedef enum { + PPT_ITEM_DOCUMENT = 1000, + PPT_ITEM_DOCUMENT_ATOM = 1001, + PPT_ITEM_DOCUMENT_END = 1002, + PPT_ITEM_SLIDE_PERSIST = 1003, + PPT_ITEM_SLIDE_BASE = 1004, + PPT_ITEM_SLIDE_BASE_ATOM = 1005, + PPT_ITEM_SLIDE = 1006, + PPT_ITEM_SLIDE_ATOM = 1007, + PPT_ITEM_NOTES = 1008 , + PPT_ITEM_NOTES_ATOM = 1009, + PPT_ITEM_ENVIRONMENT = 1010, + PPT_ITEM_SLIDE_PERSIST_ATOM = 1011, + PPT_ITEM_MAIN_MASTER = 1016, + PPT_ITEM_SSSLIDE_INFO_ATOM = 1017, + PPT_ITEM_SSDOC_INFO_ATOM = 1025, + PPT_ITEM_EX_OBJ_LIST = 1033, + PPT_ITEM_PPDRAWING_GROUP = 1035, + PPT_ITEM_PPDRAWING = 1036, + PPT_ITEM_LIST = 2000, + PPT_ITEM_COLOR_SCHEME_ATOM = 2032, + PPT_ITEM_TEXT_HEADER_ATOM = 3999, + PPT_ITEM_TEXT_CHARS_ATOM = 4000, + PPT_ITEM_STYLE_TEXT_PROP_ATOM = 4001, + PPT_ITEM_TX_MASTER_STYLE_ATOM = 4003, + PPT_ITEM_TEXT_BYTES_ATOM = 4008, + PPT_ITEM_TEXT_CISTYLE_ATOM = 4008, + PPT_ITEM_TEXT_SPEC_INFO = 4010, + PPT_ITEM_EX_OLE_OBJ_STG = 4113, + PPT_ITEM_CSTRING = 4026, + PPT_ITEM_HANDOUT = 4041, + PPT_ITEM_HEADERS_FOOTERS = 4057, + PPT_ITEM_HEADERS_FOOTERS_ATOM = 4058, + PPT_ITEM_SLIDE_LIST_WITH_TEXT = 4080, + PPT_ITEM_SLIDE_LIST = 4084, + PPT_ITEM_USER_EDIT_ATOM = 4085, + PPT_ITEM_PROG_TAGS = 5000, + PPT_ITEM_PROG_STRING_TAG = 5001, + PPT_ITEM_PROG_BINARY_TAG = 5002, + PPT_ITEM_PERSIST_PTR_INCREMENTAL_BLOCK = 6002, + PPT_ITEM_UNKNOWN = 0 +} ppt_item_type_t; + +static unsigned int +getushort(unsigned char *buffer, int offset) +{ + return (unsigned short int)buffer[offset] | ((unsigned short int)buffer[offset+1]<<8); +} + +static unsigned long int +getulong(unsigned char *buffer, int offset) +{ + return (unsigned long)buffer[offset] | ((unsigned long)buffer[offset+1]<<8) | + ((unsigned long)buffer[offset+2]<<16) | ((unsigned long)buffer[offset+3]<<24); +} + +/** + * process_item: + * + * @param rectype + * @param reclen + * @param input + */ +static void +process_item(ppt_item_type_t rectype, long reclen, + GDataInputStream* input, GMemoryInputStream *mem, + GError **err) +{ + switch (rectype) { + case PPT_ITEM_DOCUMENT_END: + g_debug("End of document"); + g_input_stream_skip((GInputStream *)input, reclen, NULL, err); + break; + + case PPT_ITEM_DOCUMENT: + g_debug("Start of document, reclen=%ld", reclen); + break; + + case PPT_ITEM_DOCUMENT_ATOM: + g_debug("DocumentAtom, reclen=%ld", reclen); + g_input_stream_skip((GInputStream *)input, reclen, NULL, err); + break; + + case PPT_ITEM_SLIDE: + g_debug("Slide, reclen=%ld" + "---------------------------------------", reclen); + break; + + case PPT_ITEM_SLIDE_ATOM: + g_debug("SlideAtom, reclen=%ld", reclen); + g_input_stream_skip((GInputStream *)input, reclen, NULL, err); + break; + + case PPT_ITEM_SLIDE_BASE: + g_debug("SlideBase, reclen=%ld", reclen); + break; + + case PPT_ITEM_SLIDE_BASE_ATOM: + g_debug("SlideBaseAtom, reclen=%ld", reclen); + g_input_stream_skip((GInputStream *)input, reclen, NULL, err); + break; + + case PPT_ITEM_NOTES: + g_debug("Notes, reclen=%ld", reclen); + break; + + case PPT_ITEM_NOTES_ATOM: + g_debug("NotesAtom, reclen=%ld", reclen); + g_input_stream_skip((GInputStream *)input, reclen, NULL, err); + break; + + case PPT_ITEM_HEADERS_FOOTERS: + g_debug("HeadersFooters, reclen=%ld", reclen); + break; + + case PPT_ITEM_HEADERS_FOOTERS_ATOM: + g_debug("HeadersFootersAtom, reclen=%ld", reclen); + g_input_stream_skip((GInputStream *)input, reclen, NULL, err); + break; + + case PPT_ITEM_MAIN_MASTER: + g_debug("MainMaster, reclen=%ld", reclen); + break; + + case PPT_ITEM_TEXT_BYTES_ATOM: { + gchar *buf; + gssize i, size; + + g_debug("TextBytes, reclen=%ld", reclen); + buf = g_malloc(reclen); + if (!g_input_stream_read_all((GInputStream *)input, buf, reclen, &size, NULL, err)) { + break; + } + for (i = 0; i < size; i++) { + if ((unsigned char)buf[i] == '\r') { + buf[i] = '\n'; + } + } + g_memory_input_stream_add_data(mem, buf, size, g_free); + break; + } + + case PPT_ITEM_TEXT_CHARS_ATOM: + case PPT_ITEM_CSTRING: { + int u; + gsize size; + GString *str; + + g_debug("CString, reclen=%ld", reclen); + size = reclen / 2; + str = g_string_sized_new(size); + while (size > 0) { + u = g_data_input_stream_read_uint16(input, NULL, err); + if (u == '\r') { + u = '\n'; + } + g_string_append_unichar(str, (gunichar)u); + } + size = str->len; + g_memory_input_stream_add_data(mem, g_string_free(str, FALSE), size, g_free); + break; + } + + case PPT_ITEM_USER_EDIT_ATOM: + g_debug("UserEditAtom, reclen=%ld", reclen); + g_input_stream_skip((GInputStream *)input, reclen, NULL, err); + break; + + case PPT_ITEM_COLOR_SCHEME_ATOM: + g_debug("ColorSchemeAtom, reclen=%ld", reclen); + g_input_stream_skip((GInputStream *)input, reclen, NULL, err); + break; + + case PPT_ITEM_PPDRAWING: + g_debug("PPDrawing, reclen=%ld", reclen); + g_input_stream_skip((GInputStream *)input, reclen, NULL, err); + break; + + case PPT_ITEM_ENVIRONMENT: + g_debug("Environment, reclen=%ld", reclen); + g_input_stream_skip((GInputStream *)input, reclen, NULL, err); + break; + + case PPT_ITEM_SSDOC_INFO_ATOM: + g_debug("SSDocInfoAtom, reclen=%ld", reclen); + g_input_stream_skip((GInputStream *)input, reclen, NULL, err); + break; + + case PPT_ITEM_SSSLIDE_INFO_ATOM: + g_debug("SSSlideInfoAtom, reclen=%ld", reclen); + g_input_stream_skip((GInputStream *)input, reclen, NULL, err); + break; + + case PPT_ITEM_PROG_TAGS: + g_debug("ProgTags, reclen=%ld", reclen); + g_input_stream_skip((GInputStream *)input, reclen, NULL, err); + break; + + case PPT_ITEM_PROG_STRING_TAG: + g_debug("ProgStringTag, reclen=%ld", reclen); + g_input_stream_skip((GInputStream *)input, reclen, NULL, err); + break; + + case PPT_ITEM_PROG_BINARY_TAG: + g_debug("ProgBinaryTag, reclen=%ld", reclen); + g_input_stream_skip((GInputStream *)input, reclen, NULL, err); + break; + + case PPT_ITEM_LIST: + g_debug("List, reclen=%ld", reclen); + break; + + case PPT_ITEM_SLIDE_LIST_WITH_TEXT: + g_debug("SlideListWithText, reclen=%ld" + "---------------------------------------", reclen); + break; + + case PPT_ITEM_PERSIST_PTR_INCREMENTAL_BLOCK: + g_debug("PersistPtrIncrementalBlock, reclen=%ld", reclen); + g_input_stream_skip((GInputStream *)input, reclen, NULL, err); + break; + + case PPT_ITEM_EX_OLE_OBJ_STG: + g_debug("ExOleObjStg, reclen=%ld", reclen); + g_input_stream_skip((GInputStream *)input, reclen, NULL, err); + break; + + case PPT_ITEM_PPDRAWING_GROUP: + g_debug("PpdrawingGroup, reclen=%ld", reclen); + g_input_stream_skip((GInputStream *)input, reclen, NULL, err); + break; + + case PPT_ITEM_EX_OBJ_LIST: + g_debug("ExObjList, reclen=%ld", reclen); + g_input_stream_skip((GInputStream *)input, reclen, NULL, err); + break; + + case PPT_ITEM_TX_MASTER_STYLE_ATOM: + g_debug("TxMasterStyleAtom, reclen=%ld", reclen); + g_input_stream_skip((GInputStream *)input, reclen, NULL, err); + break; + + case PPT_ITEM_HANDOUT: + g_debug("Handout, reclen=%ld", reclen); + g_input_stream_skip((GInputStream *)input, reclen, NULL, err); + break; + + case PPT_ITEM_SLIDE_PERSIST_ATOM: + g_debug("SlidePersistAtom, reclen=%ld", reclen); + g_input_stream_skip((GInputStream *)input, reclen, NULL, err); + break; + + case PPT_ITEM_TEXT_HEADER_ATOM: + g_debug("TextHeaderAtom, reclen=%ld", reclen); + g_input_stream_skip((GInputStream *)input, reclen, NULL, err); + break; + + case PPT_ITEM_TEXT_SPEC_INFO: + g_debug("TextSpecInfo, reclen=%ld", reclen); + g_input_stream_skip((GInputStream *)input, reclen, NULL, err); + break; + + case PPT_ITEM_STYLE_TEXT_PROP_ATOM: + g_debug("StyleTextPropAtom, reclen=%ld", reclen); + g_input_stream_skip((GInputStream *)input, reclen, NULL, err); + break; + + default: + g_debug("Default action for rectype=%d reclen=%ld", + rectype, reclen); + g_input_stream_skip((GInputStream *)input, reclen, NULL, err); + + } +} + +static gboolean +chupa_feed_ppt(ChupaText *chupar, ChupaTextInput *input, GError **error) +{ + const char *filename = chupa_text_input_get_filename(input); + GInputStream *mem; + GDataInputStream *inp; + + if (strcmp(filename, "PowerPoint Document")) { + return TRUE; + } + inp = G_DATA_INPUT_STREAM(chupa_text_input_get_stream(input)); + g_data_input_stream_set_byte_order(inp, G_DATA_STREAM_BYTE_ORDER_LITTLE_ENDIAN); + mem = g_memory_input_stream_new(); + input = chupa_text_input_new_from_stream(NULL, mem, filename); + chupa_text_feed(chupar, input, error); + do { + unsigned short rectype; + unsigned long reclen; + unsigned char recbuf[8]; + gssize size = g_input_stream_read((GInputStream *)inp, recbuf, sizeof(recbuf), NULL, error); + if (size == 0) { + process_item(PPT_ITEM_DOCUMENT_END, 0, + inp, (GMemoryInputStream *)mem, error); + break; + } + if (size < sizeof(recbuf)) { + break; + } + rectype = getushort(recbuf, 2); + reclen = getulong(recbuf, 4); + if (reclen < 0) { + break; + } + process_item((ppt_item_type_t)rectype, reclen, + inp, (GMemoryInputStream *)mem, error); + } while (1); + return TRUE; +} + +static void +chupa_ppt_decomposer_init(ChupaPPTDecomposer *dec) +{ +} +static void +chupa_ppt_decomposer_class_init(ChupaPPTDecomposerClass *klass) +{ + ChupaArchiveDecomposerClass *dec_class = CHUPA_ARCHIVE_DECOMPOSER_CLASS(klass); + dec_class->get_infile = gsf_infile_msole_new; + dec_class->feed_component = chupa_feed_ppt; +} + +static GType +register_type(GTypeModule *type_module) +{ + static const GTypeInfo info = { + sizeof(ChupaPPTDecomposerClass), + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) chupa_ppt_decomposer_class_init, + NULL, /* class_finalize */ + NULL, /* class_data */ + sizeof(ChupaPPTDecomposer), + 0, + (GInstanceInitFunc) NULL, + }; + GType type = chupa_type_ppt_decomposer; + + if (!type) { + type = g_type_module_register_type(type_module, + CHUPA_TYPE_ARCHIVE_DECOMPOSER, + "ChupaPPTDecomposer", + &info, 0); + chupa_type_ppt_decomposer = type; + chupa_decomposer_register("application/vnd.ms-powerpoint", type); + } + return type; +} + +G_MODULE_EXPORT GList * +CHUPA_MODULE_IMPL_INIT(GTypeModule *type_module) +{ + GType type = register_type(type_module); + GList *registered_types = NULL; + +#if 0 + if (type) { + registered_types = + g_list_prepend(registered_types, + (gchar *)g_type_name(type)); + } +#endif + + return registered_types; +} + +G_MODULE_EXPORT void +CHUPA_MODULE_IMPL_EXIT(void) +{ +} + +G_MODULE_EXPORT GObject * +CHUPA_MODULE_IMPL_INSTANTIATE(const gchar *first_property, va_list var_args) +{ + return g_object_new_valist(CHUPA_TYPE_PPT_DECOMPOSER, + first_property, var_args); +} Modified: test/Makefile.am (+2 -0) =================================================================== --- test/Makefile.am 2010-09-14 07:44:45 +0000 (43019bd) +++ test/Makefile.am 2010-09-14 07:47:22 +0000 (5e4424a) @@ -24,6 +24,7 @@ if HAVE_WV noinst_LTLIBRARIES += test_msword.la endif +noinst_LTLIBRARIES += test_mspowerpoint.la endif EXTRA_DIST = \ @@ -61,6 +62,7 @@ test_decomposer_la_SOURCES = test_decomposer.c test_restrict_input_stream_la_SOURCES = test_restrict_input_stream.c test_pdf_la_SOURCES = test_pdf.c chupa_test_util.c test_msword_la_SOURCES = test_msword.c chupa_test_util.c +test_mspowerpoint_la_SOURCES = test_mspowerpoint.c chupa_test_util.c nodist_test_tar_la_SOURCES = test_tar.c chupa_test_util.c test_zip_la_SOURCES = test_zip.c chupa_test_util.c Added: test/fixtures/sample.ppt (+0 -0) 100644 =================================================================== (Binary files differ) Added: test/test_mspowerpoint.c (+31 -0) 100644 =================================================================== --- /dev/null +++ test/test_mspowerpoint.c 2010-09-14 07:47:22 +0000 (f4de132) @@ -0,0 +1,31 @@ +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Copyright (C) 2010 Nobuyoshi Nakada + */ + +#include "chupa_test_util.h" + +void +setup(void) +{ + chupa_test_setup(); +} + +void +teardown(void) +{ + chupa_test_teardown(); +} + +#define decompose_msppt chupa_test_decompose_fixture + +void +test_decompose_msppt(void) +{ + cut_assert_equal_string("Sample Title\n\n", decompose_msppt("sample.ppt", NULL)); +} + +void +test_decompose_msppt_ja(void) +{ +} From null+ranguba at clear-code.com Tue Sep 14 10:35:05 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Tue, 14 Sep 2010 14:35:05 +0000 Subject: [groonga-commit:1279] ranguba/rroonga [master] document: PatriciaTrie#oepn_cursor's :order_by uses :key by default. Message-ID: <20100914143517.C88931704C0@taiyaki.ru> Kouhei Sutou 2010-09-14 14:35:05 +0000 (Tue, 14 Sep 2010) New Revision: ff10694742983591c031913f5855587cec687cc3 Log: document: PatriciaTrie#oepn_cursor's :order_by uses :key by default. Modified files: ext/groonga/rb-grn-table.c Modified: ext/groonga/rb-grn-table.c (+9 -2) =================================================================== --- ext/groonga/rb-grn-table.c 2010-09-14 01:09:38 +0000 (3cb3ae7) +++ ext/groonga/rb-grn-table.c 2010-09-14 14:35:05 +0000 (c49c854) @@ -734,6 +734,11 @@ rb_grn_table_open_grn_cursor (int argc, VALUE *argv, VALUE self, rb_grn_inspect(rb_order)); } if (NIL_P(rb_order_by)) { + if (table->header.type == GRN_TABLE_PAT_KEY) { + flags |= GRN_CURSOR_BY_KEY; + } else { + flags |= GRN_CURSOR_BY_ID; + } } else if (rb_grn_equal_option(rb_order_by, "id")) { flags |= GRN_CURSOR_BY_ID; } else if (rb_grn_equal_option(rb_order_by, "key")) { @@ -798,10 +803,12 @@ rb_grn_table_open_grn_cursor (int argc, VALUE *argv, VALUE self, * ????? * * [+:order_by+] - * +:id+??????ID??????????????????? + * +:id+??????ID?????????????Array? + * Hash??????? * * +:key+??????????????????????? - * Groonga::PatriciaTrie???????? + * Groonga::PatriciaTrie?????????PatriciaTrie?? + * ????? * * [+:greater_than+] * +true+??????+:min+???????????[+key+]? From null+ranguba at clear-code.com Wed Sep 15 02:52:31 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Wed, 15 Sep 2010 06:52:31 +0000 Subject: [groonga-commit:1280] ranguba/chupatext [master] update ignore files. Message-ID: <20100915065250.3FCC8278001@taiyaki.ru> Kouhei Sutou 2010-09-15 06:52:31 +0000 (Wed, 15 Sep 2010) New Revision: 37ef16803d251cc9ccc4d63e9f3db1f8232ddd30 Log: update ignore files. Modified files: .gitignore Modified: .gitignore (+11 -3) =================================================================== --- .gitignore 2010-09-14 07:47:22 +0000 (9bffd6c) +++ .gitignore 2010-09-15 06:52:31 +0000 (3b526af) @@ -1,8 +1,16 @@ +Makefile Makefile.in -aclocal.m4 -autom4te.cache +/aclocal.m4 +/autom4te.cache config.h.in +/config.log +/config.status +/libtool /tmp /config /m4 -chupatext/version.h +/chupatext/version.h +/chupatext/config.h +/chupatext/stamp-h1 +/configure +.deps/ From null+ranguba at clear-code.com Wed Sep 15 02:57:18 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Wed, 15 Sep 2010 06:57:18 +0000 Subject: [groonga-commit:1281] ranguba/chupatext [master] update ignore files. Message-ID: <20100915065735.27DA1278001@taiyaki.ru> Kouhei Sutou 2010-09-15 06:57:18 +0000 (Wed, 15 Sep 2010) New Revision: 543a0194ffd6bb419d5c4e02ef86340c7588d705 Log: update ignore files. Modified files: .gitignore Modified: .gitignore (+7 -1) =================================================================== --- .gitignore 2010-09-15 06:52:31 +0000 (3b526af) +++ .gitignore 2010-09-15 06:57:18 +0000 (a65a95b) @@ -1,5 +1,8 @@ Makefile Makefile.in +*.lo +*.la +*.o /aclocal.m4 /autom4te.cache config.h.in @@ -8,9 +11,12 @@ config.h.in /libtool /tmp /config -/m4 +/m4/ +/test/log/ /chupatext/version.h /chupatext/config.h /chupatext/stamp-h1 +/chupatext/chupa /configure .deps/ +.libs/ From null+ranguba at clear-code.com Wed Sep 15 03:06:20 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Wed, 15 Sep 2010 07:06:20 +0000 Subject: [groonga-commit:1282] ranguba/chupatext [master] include header files. Message-ID: <20100915070639.ED701278001@taiyaki.ru> Kouhei Sutou 2010-09-15 07:06:20 +0000 (Wed, 15 Sep 2010) New Revision: 691f012f8ccd407b73919e49a63cd512fa770468 Log: include header files. Modified files: Makefile.am chupatext/Makefile.am Modified: Makefile.am (+2 -0) =================================================================== --- Makefile.am 2010-09-15 06:57:18 +0000 (074cf76) +++ Makefile.am 2010-09-15 07:06:20 +0000 (6a4a08b) @@ -2,6 +2,8 @@ ACLOCAL_AMFLAGS = -I m4 SUBDIRS = chupatext test module +pkginclude_HEADERS = chupatext.h + all-recursive: update-version.h include prereq.mk Modified: chupatext/Makefile.am (+15 -0) =================================================================== --- chupatext/Makefile.am 2010-09-15 06:57:18 +0000 (eb6df42) +++ chupatext/Makefile.am 2010-09-15 07:06:20 +0000 (84b6754) @@ -21,4 +21,19 @@ AM_LDFLAGS = $(GSF_LIBS) DEFAULT_INCLUDES = -I$(top_includedir) -I$(build_includedir) +chupatext_includedir = $(pkgincludedir)/chupatext +chupatext_include_HEADERS = \ + archive_decomposer.h \ + chupa_decomposer.h \ + chupa_metadata.h \ + chupa_module.h \ + chupa_module_impl.h \ + chupa_private.h \ + chupa_restrict_input_stream.h \ + chupa_text.h \ + chupa_text_input.h \ + chupa_text_input_stream.h \ + text_decomposer.h \ + version.h + version.lo: version.h From null+ranguba at clear-code.com Wed Sep 15 03:09:28 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Wed, 15 Sep 2010 07:09:28 +0000 Subject: [groonga-commit:1283] ranguba/chupatext [master] include update-version.sh. Message-ID: <20100915070943.36918278001@taiyaki.ru> Kouhei Sutou 2010-09-15 07:09:28 +0000 (Wed, 15 Sep 2010) New Revision: 95c3b61c4171b7185b24286e9f120567a20e7169 Log: include update-version.sh. Added files: tool/Makefile.am Modified files: Makefile.am configure.ac Modified: Makefile.am (+1 -1) =================================================================== --- Makefile.am 2010-09-15 07:06:20 +0000 (6a4a08b) +++ Makefile.am 2010-09-15 07:09:28 +0000 (acea81e) @@ -1,6 +1,6 @@ ACLOCAL_AMFLAGS = -I m4 -SUBDIRS = chupatext test module +SUBDIRS = tool chupatext test module pkginclude_HEADERS = chupatext.h Modified: configure.ac (+1 -0) =================================================================== --- configure.ac 2010-09-15 07:06:20 +0000 (adf5b5d) +++ configure.ac 2010-09-15 07:09:28 +0000 (8599757) @@ -84,6 +84,7 @@ AC_SUBST(build_includedir, '$(top_build_prefix)') AC_SUBST(top_includedir, '$(top_srcdir)') AC_CONFIG_FILES([Makefile + tool/Makefile chupatext/Makefile test/Makefile module/Makefile]) Added: tool/Makefile.am (+2 -0) 100644 =================================================================== --- /dev/null +++ tool/Makefile.am 2010-09-15 07:09:28 +0000 (066c2c2) @@ -0,0 +1,2 @@ +EXTRA_DIST = \ + version-update.sh From null+ranguba at clear-code.com Wed Sep 15 03:12:46 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Wed, 15 Sep 2010 07:12:46 +0000 Subject: [groonga-commit:1284] ranguba/chupatext [master] include chupa_test_util.h. Message-ID: <20100915071303.06DE3278001@taiyaki.ru> Kouhei Sutou 2010-09-15 07:12:46 +0000 (Wed, 15 Sep 2010) New Revision: 76515603a7236f97ab99ffca06321708ed082a30 Log: include chupa_test_util.h. Modified files: test/Makefile.am Modified: test/Makefile.am (+3 -2) =================================================================== --- test/Makefile.am 2010-09-15 07:09:28 +0000 (5e4424a) +++ test/Makefile.am 2010-09-15 07:12:46 +0000 (088b6ed) @@ -27,8 +27,9 @@ endif noinst_LTLIBRARIES += test_mspowerpoint.la endif -EXTRA_DIST = \ - run-test.sh +EXTRA_DIST = \ + run-test.sh \ + chupa_test_util.h INCLUDES = \ -I$(srcdir) \ From null+ranguba at clear-code.com Wed Sep 15 03:14:17 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Wed, 15 Sep 2010 07:14:17 +0000 Subject: [groonga-commit:1285] ranguba/chupatext [master] include test_tar.c. Message-ID: <20100915071434.BB834278001@taiyaki.ru> Kouhei Sutou 2010-09-15 07:14:17 +0000 (Wed, 15 Sep 2010) New Revision: fe0a7cdfc967f2b5644e6a5babdff4c7e4a6247f Log: include test_tar.c. Modified files: test/Makefile.am Modified: test/Makefile.am (+1 -1) =================================================================== --- test/Makefile.am 2010-09-15 07:12:46 +0000 (088b6ed) +++ test/Makefile.am 2010-09-15 07:14:17 +0000 (9ac03ae) @@ -64,7 +64,7 @@ test_restrict_input_stream_la_SOURCES = test_restrict_input_stream.c test_pdf_la_SOURCES = test_pdf.c chupa_test_util.c test_msword_la_SOURCES = test_msword.c chupa_test_util.c test_mspowerpoint_la_SOURCES = test_mspowerpoint.c chupa_test_util.c -nodist_test_tar_la_SOURCES = test_tar.c chupa_test_util.c +test_tar_la_SOURCES = test_tar.c chupa_test_util.c test_zip_la_SOURCES = test_zip.c chupa_test_util.c echo-cutter: From null+ranguba at clear-code.com Wed Sep 15 03:22:53 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Wed, 15 Sep 2010 07:22:53 +0000 Subject: [groonga-commit:1286] ranguba/chupatext [master] include fixture files. Message-ID: <20100915072306.2CF05278001@taiyaki.ru> Kouhei Sutou 2010-09-15 07:22:53 +0000 (Wed, 15 Sep 2010) New Revision: 311700301f595aad1a4ea477b58e32c7086ae4cc Log: include fixture files. Added files: test/fixtures/Makefile.am Modified files: configure.ac test/Makefile.am Modified: configure.ac (+1 -0) =================================================================== --- configure.ac 2010-09-15 07:14:17 +0000 (8599757) +++ configure.ac 2010-09-15 07:22:53 +0000 (773591c) @@ -87,6 +87,7 @@ AC_CONFIG_FILES([Makefile tool/Makefile chupatext/Makefile test/Makefile + test/fixtures/Makefile module/Makefile]) AC_OUTPUT Modified: test/Makefile.am (+1 -1) =================================================================== --- test/Makefile.am 2010-09-15 07:14:17 +0000 (9ac03ae) +++ test/Makefile.am 2010-09-15 07:22:53 +0000 (5af2b21) @@ -1,4 +1,4 @@ -SUBDIRS = +SUBDIRS = fixtures EMPTY = if WITH_CUTTER Added: test/fixtures/Makefile.am (+9 -0) 100644 =================================================================== --- /dev/null +++ test/fixtures/Makefile.am 2010-09-15 07:22:53 +0000 (a53d519) @@ -0,0 +1,9 @@ +EXTRA_DIST = \ + ja95.doc \ + ja97.doc \ + sample.doc \ + sample.pdf \ + sample.ppt \ + sample.tar.gz \ + sample.zip \ + sample_ja.doc From null+ranguba at clear-code.com Wed Sep 15 03:25:11 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Wed, 15 Sep 2010 07:25:11 +0000 Subject: [groonga-commit:1287] ranguba/chupatext [master] format. Message-ID: <20100915072611.7888D278001@taiyaki.ru> Kouhei Sutou 2010-09-15 07:25:11 +0000 (Wed, 15 Sep 2010) New Revision: 8c53fab2d8052c72c215f29e0be13a54a9b53c6a Log: format. Modified files: chupatext/Makefile.am Modified: chupatext/Makefile.am (+13 -6) =================================================================== --- chupatext/Makefile.am 2010-09-15 07:22:53 +0000 (84b6754) +++ chupatext/Makefile.am 2010-09-15 07:25:11 +0000 (2dfade7) @@ -7,12 +7,19 @@ bin_PROGRAMS = chupa chupa_SOURCES = chupa.c chupa_LDADD = libchupatext.la -libchupatext_la_SOURCES = chupa_init.c chupa_metadata.c \ - chupa_text.c chupa_text_input.c chupa_module.c \ - chupa_text_input_stream.c error.c \ - chupa_decomposer.c archive_decomposer.c text_decomposer.c \ - chupa_restrict_input_stream.c \ - version.c \ +libchupatext_la_SOURCES = \ + chupa_init.c \ + chupa_metadata.c \ + chupa_text.c \ + chupa_text_input.c \ + chupa_module.c \ + chupa_text_input_stream.c \ + error.c \ + chupa_decomposer.c \ + archive_decomposer.c \ + text_decomposer.c \ + chupa_restrict_input_stream.c \ + version.c \ $(EMPTY) AM_CPPFLAGS = -DCHUPA_MODULE_PATH=\"$(moduledir)\" -D_GNU_SOURCE From null+ranguba at clear-code.com Wed Sep 15 03:26:00 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Wed, 15 Sep 2010 07:26:00 +0000 Subject: [groonga-commit:1288] ranguba/chupatext [master] include tar module. Message-ID: <20100915072611.87CDC278002@taiyaki.ru> Kouhei Sutou 2010-09-15 07:26:00 +0000 (Wed, 15 Sep 2010) New Revision: 6da14678078ea3d7a3766483f25a99a704d52c9c Log: include tar module. Modified files: module/Makefile.am Modified: module/Makefile.am (+1 -1) =================================================================== --- module/Makefile.am 2010-09-15 07:25:11 +0000 (dbbaba3) +++ module/Makefile.am 2010-09-15 07:26:00 +0000 (7dfaf24) @@ -16,7 +16,7 @@ module_LTLIBRARIES += chupa_msword.la endif module_LTLIBRARIES += chupa_mspowerpoint.la -nodist_chupa_tar_la_SOURCES = chupa_tar.c +chupa_tar_la_SOURCES = chupa_tar.c chupa_tar_la_LDFLAGS = -module chupa_tar_la_CPPFLAGS = $(GSF_CFLAGS) chupa_tar_la_LIBADD = $(GSF_LIBS) From null+ranguba at clear-code.com Wed Sep 15 03:53:26 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Wed, 15 Sep 2010 07:53:26 +0000 Subject: [groonga-commit:1289] ranguba/chupatext [master] add README in Japanese. Message-ID: <20100915075340.91ACA278002@taiyaki.ru> Kouhei Sutou 2010-09-15 07:53:26 +0000 (Wed, 15 Sep 2010) New Revision: 64bc66ec5ef9a5d691949dea219e3232a9af42c3 Log: add README in Japanese. Added files: README.ja Modified files: Makefile.am configure.ac Modified: Makefile.am (+3 -2) =================================================================== --- Makefile.am 2010-09-15 07:53:08 +0000 (9657fb1) +++ Makefile.am 2010-09-15 07:53:26 +0000 (0324bbe) @@ -1,11 +1,12 @@ ACLOCAL_AMFLAGS = -I m4 -SUBDIRS = tool chupatext test module +SUBDIRS = tool chupatext test module license pkginclude_HEADERS = chupatext.h EXTRA_DIST = \ - COPYING + COPYING \ + README.ja all-recursive: update-version.h Added: README.ja (+78 -0) 100644 =================================================================== --- /dev/null +++ README.ja 2010-09-15 07:53:26 +0000 (a662553) @@ -0,0 +1,78 @@ +# -*- rd -*- + += ???? --- ?????????????ChupaText??? + +== ?? + +ChupaText + +== ?? + + * Nobuyoshi Nakada + * Kouhei Sutou + +== ????? + + * ??????: LGPL?????2.1????????????? + ???: + ((<"license/lgpl-2.1.txt"|URL:http://www.gnu.org/licenses/lgpl-2.1.html>))? + ??? + * ??????: LGPL?GFDL??????????????????? + ??????????? + * LGPL?????2.1????????????? + ???: + ((<"license/lgpl-2.1.txt"|URL:http://www.gnu.org/licenses/lgpl-2.1.html>))? + ??? + * GFDL??????1.3??????? + ?????????: + ((<"license/gfdl-1.3.txt"|URL:http://www.gnu.org/licenses/fdl.html>))? + ??? + * ???????????????????(()) + ??? + * ??: + * ... + +== ChupaText? + +ChupaText?PDF??????????????????????? +?????????????????????????Web???? +?????????? + +== ??????? + +??: + * GLib >= 2.24 + +??: + * libgsf + * Poppler + * wv + * OpenOffice.org + +== ???? + +tar.gz: (()) + +== ????? + +(()) + + % git clone git://github.com/ranguba/chupatext.git + +== ?????? + +(())???????? + +== ??? + + % chupa [????? ...] ???? + +?????????????????????????? + +???(())???????? + +== ?? + + * ... Modified: configure.ac (+2 -1) =================================================================== --- configure.ac 2010-09-15 07:53:08 +0000 (773591c) +++ configure.ac 2010-09-15 07:53:26 +0000 (6d76a2a) @@ -88,6 +88,7 @@ AC_CONFIG_FILES([Makefile chupatext/Makefile test/Makefile test/fixtures/Makefile - module/Makefile]) + module/Makefile + license/Makefile]) AC_OUTPUT From null+ranguba at clear-code.com Wed Sep 15 03:53:08 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Wed, 15 Sep 2010 07:53:08 +0000 Subject: [groonga-commit:1290] ranguba/chupatext [master] describe license. Message-ID: <20100915075340.8D412278001@taiyaki.ru> Kouhei Sutou 2010-09-15 07:53:08 +0000 (Wed, 15 Sep 2010) New Revision: 7b31274c621337ca68abd2d3b0f6c60f9a1546de Log: describe license. Added files: COPYING license/Makefile.am license/fdl-1.3.txt license/lgpl-2.1.txt Modified files: Makefile.am Added: COPYING (+1 -0) 100644 =================================================================== --- /dev/null +++ COPYING 2010-09-15 07:53:08 +0000 (77492c1) @@ -0,0 +1 @@ +LGPL 2.1 or later. See license/lgpl-2.1.txt for detail. Modified: Makefile.am (+3 -0) =================================================================== --- Makefile.am 2010-09-15 07:26:00 +0000 (acea81e) +++ Makefile.am 2010-09-15 07:53:08 +0000 (9657fb1) @@ -4,6 +4,9 @@ SUBDIRS = tool chupatext test module pkginclude_HEADERS = chupatext.h +EXTRA_DIST = \ + COPYING + all-recursive: update-version.h include prereq.mk Added: license/Makefile.am (+1 -0) 100644 =================================================================== --- /dev/null +++ license/Makefile.am 2010-09-15 07:53:08 +0000 (aba09c8) @@ -0,0 +1 @@ +EXTRA_DIST = lgpl-2.1.txt Added: license/fdl-1.3.txt (+451 -0) 100644 =================================================================== --- /dev/null +++ license/fdl-1.3.txt 2010-09-15 07:53:08 +0000 (2f7e03c) @@ -0,0 +1,451 @@ + + GNU Free Documentation License + Version 1.3, 3 November 2008 + + + Copyright (C) 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc. + + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +0. PREAMBLE + +The purpose of this License is to make a manual, textbook, or other +functional and useful document "free" in the sense of freedom: to +assure everyone the effective freedom to copy and redistribute it, +with or without modifying it, either commercially or noncommercially. +Secondarily, this License preserves for the author and publisher a way +to get credit for their work, while not being considered responsible +for modifications made by others. + +This License is a kind of "copyleft", which means that derivative +works of the document must themselves be free in the same sense. It +complements the GNU General Public License, which is a copyleft +license designed for free software. + +We have designed this License in order to use it for manuals for free +software, because free software needs free documentation: a free +program should come with manuals providing the same freedoms that the +software does. But this License is not limited to software manuals; +it can be used for any textual work, regardless of subject matter or +whether it is published as a printed book. We recommend this License +principally for works whose purpose is instruction or reference. + + +1. APPLICABILITY AND DEFINITIONS + +This License applies to any manual or other work, in any medium, that +contains a notice placed by the copyright holder saying it can be +distributed under the terms of this License. Such a notice grants a +world-wide, royalty-free license, unlimited in duration, to use that +work under the conditions stated herein. The "Document", below, +refers to any such manual or work. Any member of the public is a +licensee, and is addressed as "you". You accept the license if you +copy, modify or distribute the work in a way requiring permission +under copyright law. + +A "Modified Version" of the Document means any work containing the +Document or a portion of it, either copied verbatim, or with +modifications and/or translated into another language. + +A "Secondary Section" is a named appendix or a front-matter section of +the Document that deals exclusively with the relationship of the +publishers or authors of the Document to the Document's overall +subject (or to related matters) and contains nothing that could fall +directly within that overall subject. (Thus, if the Document is in +part a textbook of mathematics, a Secondary Section may not explain +any mathematics.) The relationship could be a matter of historical +connection with the subject or with related matters, or of legal, +commercial, philosophical, ethical or political position regarding +them. + +The "Invariant Sections" are certain Secondary Sections whose titles +are designated, as being those of Invariant Sections, in the notice +that says that the Document is released under this License. If a +section does not fit the above definition of Secondary then it is not +allowed to be designated as Invariant. The Document may contain zero +Invariant Sections. If the Document does not identify any Invariant +Sections then there are none. + +The "Cover Texts" are certain short passages of text that are listed, +as Front-Cover Texts or Back-Cover Texts, in the notice that says that +the Document is released under this License. A Front-Cover Text may +be at most 5 words, and a Back-Cover Text may be at most 25 words. + +A "Transparent" copy of the Document means a machine-readable copy, +represented in a format whose specification is available to the +general public, that is suitable for revising the document +straightforwardly with generic text editors or (for images composed of +pixels) generic paint programs or (for drawings) some widely available +drawing editor, and that is suitable for input to text formatters or +for automatic translation to a variety of formats suitable for input +to text formatters. A copy made in an otherwise Transparent file +format whose markup, or absence of markup, has been arranged to thwart +or discourage subsequent modification by readers is not Transparent. +An image format is not Transparent if used for any substantial amount +of text. A copy that is not "Transparent" is called "Opaque". + +Examples of suitable formats for Transparent copies include plain +ASCII without markup, Texinfo input format, LaTeX input format, SGML +or XML using a publicly available DTD, and standard-conforming simple +HTML, PostScript or PDF designed for human modification. Examples of +transparent image formats include PNG, XCF and JPG. Opaque formats +include proprietary formats that can be read and edited only by +proprietary word processors, SGML or XML for which the DTD and/or +processing tools are not generally available, and the +machine-generated HTML, PostScript or PDF produced by some word +processors for output purposes only. + +The "Title Page" means, for a printed book, the title page itself, +plus such following pages as are needed to hold, legibly, the material +this License requires to appear in the title page. For works in +formats which do not have any title page as such, "Title Page" means +the text near the most prominent appearance of the work's title, +preceding the beginning of the body of the text. + +The "publisher" means any person or entity that distributes copies of +the Document to the public. + +A section "Entitled XYZ" means a named subunit of the Document whose +title either is precisely XYZ or contains XYZ in parentheses following +text that translates XYZ in another language. (Here XYZ stands for a +specific section name mentioned below, such as "Acknowledgements", +"Dedications", "Endorsements", or "History".) To "Preserve the Title" +of such a section when you modify the Document means that it remains a +section "Entitled XYZ" according to this definition. + +The Document may include Warranty Disclaimers next to the notice which +states that this License applies to the Document. These Warranty +Disclaimers are considered to be included by reference in this +License, but only as regards disclaiming warranties: any other +implication that these Warranty Disclaimers may have is void and has +no effect on the meaning of this License. + +2. VERBATIM COPYING + +You may copy and distribute the Document in any medium, either +commercially or noncommercially, provided that this License, the +copyright notices, and the license notice saying this License applies +to the Document are reproduced in all copies, and that you add no +other conditions whatsoever to those of this License. You may not use +technical measures to obstruct or control the reading or further +copying of the copies you make or distribute. However, you may accept +compensation in exchange for copies. If you distribute a large enough +number of copies you must also follow the conditions in section 3. + +You may also lend copies, under the same conditions stated above, and +you may publicly display copies. + + +3. COPYING IN QUANTITY + +If you publish printed copies (or copies in media that commonly have +printed covers) of the Document, numbering more than 100, and the +Document's license notice requires Cover Texts, you must enclose the +copies in covers that carry, clearly and legibly, all these Cover +Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on +the back cover. Both covers must also clearly and legibly identify +you as the publisher of these copies. The front cover must present +the full title with all words of the title equally prominent and +visible. You may add other material on the covers in addition. +Copying with changes limited to the covers, as long as they preserve +the title of the Document and satisfy these conditions, can be treated +as verbatim copying in other respects. + +If the required texts for either cover are too voluminous to fit +legibly, you should put the first ones listed (as many as fit +reasonably) on the actual cover, and continue the rest onto adjacent +pages. + +If you publish or distribute Opaque copies of the Document numbering +more than 100, you must either include a machine-readable Transparent +copy along with each Opaque copy, or state in or with each Opaque copy +a computer-network location from which the general network-using +public has access to download using public-standard network protocols +a complete Transparent copy of the Document, free of added material. +If you use the latter option, you must take reasonably prudent steps, +when you begin distribution of Opaque copies in quantity, to ensure +that this Transparent copy will remain thus accessible at the stated +location until at least one year after the last time you distribute an +Opaque copy (directly or through your agents or retailers) of that +edition to the public. + +It is requested, but not required, that you contact the authors of the +Document well before redistributing any large number of copies, to +give them a chance to provide you with an updated version of the +Document. + + +4. MODIFICATIONS + +You may copy and distribute a Modified Version of the Document under +the conditions of sections 2 and 3 above, provided that you release +the Modified Version under precisely this License, with the Modified +Version filling the role of the Document, thus licensing distribution +and modification of the Modified Version to whoever possesses a copy +of it. In addition, you must do these things in the Modified Version: + +A. Use in the Title Page (and on the covers, if any) a title distinct + from that of the Document, and from those of previous versions + (which should, if there were any, be listed in the History section + of the Document). You may use the same title as a previous version + if the original publisher of that version gives permission. +B. List on the Title Page, as authors, one or more persons or entities + responsible for authorship of the modifications in the Modified + Version, together with at least five of the principal authors of the + Document (all of its principal authors, if it has fewer than five), + unless they release you from this requirement. +C. State on the Title page the name of the publisher of the + Modified Version, as the publisher. +D. Preserve all the copyright notices of the Document. +E. Add an appropriate copyright notice for your modifications + adjacent to the other copyright notices. +F. Include, immediately after the copyright notices, a license notice + giving the public permission to use the Modified Version under the + terms of this License, in the form shown in the Addendum below. +G. Preserve in that license notice the full lists of Invariant Sections + and required Cover Texts given in the Document's license notice. +H. Include an unaltered copy of this License. +I. Preserve the section Entitled "History", Preserve its Title, and add + to it an item stating at least the title, year, new authors, and + publisher of the Modified Version as given on the Title Page. If + there is no section Entitled "History" in the Document, create one + stating the title, year, authors, and publisher of the Document as + given on its Title Page, then add an item describing the Modified + Version as stated in the previous sentence. +J. Preserve the network location, if any, given in the Document for + public access to a Transparent copy of the Document, and likewise + the network locations given in the Document for previous versions + it was based on. These may be placed in the "History" section. + You may omit a network location for a work that was published at + least four years before the Document itself, or if the original + publisher of the version it refers to gives permission. +K. For any section Entitled "Acknowledgements" or "Dedications", + Preserve the Title of the section, and preserve in the section all + the substance and tone of each of the contributor acknowledgements + and/or dedications given therein. +L. Preserve all the Invariant Sections of the Document, + unaltered in their text and in their titles. Section numbers + or the equivalent are not considered part of the section titles. +M. Delete any section Entitled "Endorsements". Such a section + may not be included in the Modified Version. +N. Do not retitle any existing section to be Entitled "Endorsements" + or to conflict in title with any Invariant Section. +O. Preserve any Warranty Disclaimers. + +If the Modified Version includes new front-matter sections or +appendices that qualify as Secondary Sections and contain no material +copied from the Document, you may at your option designate some or all +of these sections as invariant. To do this, add their titles to the +list of Invariant Sections in the Modified Version's license notice. +These titles must be distinct from any other section titles. + +You may add a section Entitled "Endorsements", provided it contains +nothing but endorsements of your Modified Version by various +parties--for example, statements of peer review or that the text has +been approved by an organization as the authoritative definition of a +standard. + +You may add a passage of up to five words as a Front-Cover Text, and a +passage of up to 25 words as a Back-Cover Text, to the end of the list +of Cover Texts in the Modified Version. Only one passage of +Front-Cover Text and one of Back-Cover Text may be added by (or +through arrangements made by) any one entity. If the Document already +includes a cover text for the same cover, previously added by you or +by arrangement made by the same entity you are acting on behalf of, +you may not add another; but you may replace the old one, on explicit +permission from the previous publisher that added the old one. + +The author(s) and publisher(s) of the Document do not by this License +give permission to use their names for publicity for or to assert or +imply endorsement of any Modified Version. + + +5. COMBINING DOCUMENTS + +You may combine the Document with other documents released under this +License, under the terms defined in section 4 above for modified +versions, provided that you include in the combination all of the +Invariant Sections of all of the original documents, unmodified, and +list them all as Invariant Sections of your combined work in its +license notice, and that you preserve all their Warranty Disclaimers. + +The combined work need only contain one copy of this License, and +multiple identical Invariant Sections may be replaced with a single +copy. If there are multiple Invariant Sections with the same name but +different contents, make the title of each such section unique by +adding at the end of it, in parentheses, the name of the original +author or publisher of that section if known, or else a unique number. +Make the same adjustment to the section titles in the list of +Invariant Sections in the license notice of the combined work. + +In the combination, you must combine any sections Entitled "History" +in the various original documents, forming one section Entitled +"History"; likewise combine any sections Entitled "Acknowledgements", +and any sections Entitled "Dedications". You must delete all sections +Entitled "Endorsements". + + +6. COLLECTIONS OF DOCUMENTS + +You may make a collection consisting of the Document and other +documents released under this License, and replace the individual +copies of this License in the various documents with a single copy +that is included in the collection, provided that you follow the rules +of this License for verbatim copying of each of the documents in all +other respects. + +You may extract a single document from such a collection, and +distribute it individually under this License, provided you insert a +copy of this License into the extracted document, and follow this +License in all other respects regarding verbatim copying of that +document. + + +7. AGGREGATION WITH INDEPENDENT WORKS + +A compilation of the Document or its derivatives with other separate +and independent documents or works, in or on a volume of a storage or +distribution medium, is called an "aggregate" if the copyright +resulting from the compilation is not used to limit the legal rights +of the compilation's users beyond what the individual works permit. +When the Document is included in an aggregate, this License does not +apply to the other works in the aggregate which are not themselves +derivative works of the Document. + +If the Cover Text requirement of section 3 is applicable to these +copies of the Document, then if the Document is less than one half of +the entire aggregate, the Document's Cover Texts may be placed on +covers that bracket the Document within the aggregate, or the +electronic equivalent of covers if the Document is in electronic form. +Otherwise they must appear on printed covers that bracket the whole +aggregate. + + +8. TRANSLATION + +Translation is considered a kind of modification, so you may +distribute translations of the Document under the terms of section 4. +Replacing Invariant Sections with translations requires special +permission from their copyright holders, but you may include +translations of some or all Invariant Sections in addition to the +original versions of these Invariant Sections. You may include a +translation of this License, and all the license notices in the +Document, and any Warranty Disclaimers, provided that you also include +the original English version of this License and the original versions +of those notices and disclaimers. In case of a disagreement between +the translation and the original version of this License or a notice +or disclaimer, the original version will prevail. + +If a section in the Document is Entitled "Acknowledgements", +"Dedications", or "History", the requirement (section 4) to Preserve +its Title (section 1) will typically require changing the actual +title. + + +9. TERMINATION + +You may not copy, modify, sublicense, or distribute the Document +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense, or distribute it is void, and +will automatically terminate your rights under this License. + +However, if you cease all violation of this License, then your license +from a particular copyright holder is reinstated (a) provisionally, +unless and until the copyright holder explicitly and finally +terminates your license, and (b) permanently, if the copyright holder +fails to notify you of the violation by some reasonable means prior to +60 days after the cessation. + +Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + +Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, receipt of a copy of some or all of the same material does +not give you any rights to use it. + + +10. FUTURE REVISIONS OF THIS LICENSE + +The Free Software Foundation may publish new, revised versions of the +GNU Free Documentation License from time to time. Such new versions +will be similar in spirit to the present version, but may differ in +detail to address new problems or concerns. See +http://www.gnu.org/copyleft/. + +Each version of the License is given a distinguishing version number. +If the Document specifies that a particular numbered version of this +License "or any later version" applies to it, you have the option of +following the terms and conditions either of that specified version or +of any later version that has been published (not as a draft) by the +Free Software Foundation. If the Document does not specify a version +number of this License, you may choose any version ever published (not +as a draft) by the Free Software Foundation. If the Document +specifies that a proxy can decide which future versions of this +License can be used, that proxy's public statement of acceptance of a +version permanently authorizes you to choose that version for the +Document. + +11. RELICENSING + +"Massive Multiauthor Collaboration Site" (or "MMC Site") means any +World Wide Web server that publishes copyrightable works and also +provides prominent facilities for anybody to edit those works. A +public wiki that anybody can edit is an example of such a server. A +"Massive Multiauthor Collaboration" (or "MMC") contained in the site +means any set of copyrightable works thus published on the MMC site. + +"CC-BY-SA" means the Creative Commons Attribution-Share Alike 3.0 +license published by Creative Commons Corporation, a not-for-profit +corporation with a principal place of business in San Francisco, +California, as well as future copyleft versions of that license +published by that same organization. + +"Incorporate" means to publish or republish a Document, in whole or in +part, as part of another Document. + +An MMC is "eligible for relicensing" if it is licensed under this +License, and if all works that were first published under this License +somewhere other than this MMC, and subsequently incorporated in whole or +in part into the MMC, (1) had no cover texts or invariant sections, and +(2) were thus incorporated prior to November 1, 2008. + +The operator of an MMC Site may republish an MMC contained in the site +under CC-BY-SA on the same site at any time before August 1, 2009, +provided the MMC is eligible for relicensing. + + +ADDENDUM: How to use this License for your documents + +To use this License in a document you have written, include a copy of +the License in the document and put the following copyright and +license notices just after the title page: + + Copyright (c) YEAR YOUR NAME. + Permission is granted to copy, distribute and/or modify this document + under the terms of the GNU Free Documentation License, Version 1.3 + or any later version published by the Free Software Foundation; + with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. + A copy of the license is included in the section entitled "GNU + Free Documentation License". + +If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts, +replace the "with...Texts." line with this: + + with the Invariant Sections being LIST THEIR TITLES, with the + Front-Cover Texts being LIST, and with the Back-Cover Texts being LIST. + +If you have Invariant Sections without Cover Texts, or some other +combination of the three, merge those two alternatives to suit the +situation. + +If your document contains nontrivial examples of program code, we +recommend releasing these examples in parallel under your choice of +free software license, such as the GNU General Public License, +to permit their use in free software. Added: license/lgpl-2.1.txt (+502 -0) 100644 =================================================================== --- /dev/null +++ license/lgpl-2.1.txt 2010-09-15 07:53:08 +0000 (4362b49) @@ -0,0 +1,502 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + 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.1 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! From null+ranguba at clear-code.com Wed Sep 15 05:08:48 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Wed, 15 Sep 2010 09:08:48 +0000 Subject: [groonga-commit:1291] ranguba/chupatext [master] use @am__include@ for portability. Message-ID: <20100915090902.6772C278001@taiyaki.ru> Kouhei Sutou 2010-09-15 09:08:48 +0000 (Wed, 15 Sep 2010) New Revision: 647c61851d3c571d7df0542751dddfe48e6fe5c9 Log: use @am__include@ for portability. Modified files: Makefile.am Modified: Makefile.am (+1 -1) =================================================================== --- Makefile.am 2010-09-15 07:53:26 +0000 (0324bbe) +++ Makefile.am 2010-09-15 09:08:48 +0000 (fd50390) @@ -10,4 +10,4 @@ EXTRA_DIST = \ all-recursive: update-version.h -include prereq.mk + at am__include@ prereq.mk From null+ranguba at clear-code.com Wed Sep 15 21:59:17 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Thu, 16 Sep 2010 01:59:17 +0000 Subject: [groonga-commit:1292] ranguba/chupatext [master] * license/Makefile.am: add FDL. Message-ID: <20100916015931.9BF43170640@taiyaki.ru> Nobuyoshi Nakada 2010-09-16 01:59:17 +0000 (Thu, 16 Sep 2010) New Revision: c15112e40f658d556550de2186f67356992a4ff2 Log: * license/Makefile.am: add FDL. Modified files: license/Makefile.am Modified: license/Makefile.am (+1 -1) =================================================================== --- license/Makefile.am 2010-09-15 09:08:48 +0000 (aba09c8) +++ license/Makefile.am 2010-09-16 01:59:17 +0000 (3c50d2b) @@ -1 +1 @@ -EXTRA_DIST = lgpl-2.1.txt +EXTRA_DIST = fdl-1.3.txt lgpl-2.1.txt From null+ranguba at clear-code.com Wed Sep 15 22:35:05 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Thu, 16 Sep 2010 02:35:05 +0000 Subject: [groonga-commit:1293] ranguba/chupatext [master] * Makefile.am: prereq.mk is in srcdir. Message-ID: <20100916023518.AB5F6170E2C@taiyaki.ru> Nobuyoshi Nakada 2010-09-16 02:35:05 +0000 (Thu, 16 Sep 2010) New Revision: d9fd29e24dd7c9e739b12d32dad611325e3f5af0 Log: * Makefile.am: prereq.mk is in srcdir. Modified files: Makefile.am Modified: Makefile.am (+1 -1) =================================================================== --- Makefile.am 2010-09-16 01:59:17 +0000 (fd50390) +++ Makefile.am 2010-09-16 02:35:05 +0000 (b39338a) @@ -10,4 +10,4 @@ EXTRA_DIST = \ all-recursive: update-version.h - at am__include@ prereq.mk + at am__include@ $(srcdir)/prereq.mk From null+ranguba at clear-code.com Thu Sep 16 01:09:52 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Thu, 16 Sep 2010 05:09:52 +0000 Subject: [groonga-commit:1294] ranguba/rroonga [master] use pkg-config library. Message-ID: <20100916051011.BC889170640@taiyaki.ru> Kouhei Sutou 2010-09-16 05:09:52 +0000 (Thu, 16 Sep 2010) New Revision: 1808c931e6d9c52fef9de5b6819f953941a4fcbb Log: use pkg-config library. Removed files: pkg-config.rb Modified files: Rakefile ext/groonga/extconf.rb Modified: Rakefile (+15 -6) =================================================================== --- Rakefile 2010-09-14 14:35:05 +0000 (9f27d87) +++ Rakefile 2010-09-16 05:09:52 +0000 (6cc4356) @@ -49,13 +49,10 @@ manifest_contents = [] base_dir_included_components = %w(AUTHORS Rakefile README.rdoc README.ja.rdoc NEWS.rdoc NEWS.ja.rdoc - rroonga-build.rb extconf.rb pkg-config.rb) + rroonga-build.rb extconf.rb) excluded_components = %w(.cvsignore .gdb_history CVS depend Makefile doc pkg - .svn .git doc data .test-result tmp) + .svn .git doc data .test-result tmp vendor) excluded_suffixes = %w(.png .ps .pdf .o .so .a .txt .~) -unless ENV["RUBY_CC_VERSION"] - excluded_components << "vendor" -end Find.find(base_dir) do |target| target = truncate_base_dir[target] components = target.split(File::SEPARATOR) @@ -110,6 +107,7 @@ Hoe.spec('rroonga') do :require_paths => ["lib", "ext/groonga"], :extra_rdoc_files => Dir.glob("**/*.rdoc"), } + project.extra_dev_deps << ['pkg-config', '>= 0'] project.readme_file = "README.ja.rdoc" news_of_current_release = File.read("NEWS.rdoc").split(/^==\s.*$/)[1] @@ -135,9 +133,20 @@ ObjectSpace.each_object(Rake::RDocTask) do |rdoc_task| rdoc_task.rdoc_files += Dir.glob("**/*.rdoc") end +binary_dir = File.join("vendor", "local") Rake::ExtensionTask.new("groonga", project.spec) do |ext| ext.cross_compile = true - ext.cross_platform = 'x86-mingw32' + ext.cross_compiling do |spec| + if /mingw|mswin/ =~ spec.platform.to_s + binary_files = [] + Find.find(binary_dir) do |name| + next unless File.file?(name) + next if /\.zip\z/i =~ name + binary_files << name + end + spec.files += binary_files + end + end end task :publish_docs => [:prepare_docs_for_publishing] Modified: ext/groonga/extconf.rb (+12 -11) =================================================================== --- ext/groonga/extconf.rb 2010-09-14 14:35:05 +0000 (0e803d5) +++ ext/groonga/extconf.rb 2010-09-16 05:09:52 +0000 (5ef6b0e) @@ -22,9 +22,15 @@ $LOAD_PATH.unshift(base_dir.to_s) require 'English' require 'mkmf' -require 'pkg-config' require 'rroonga-build' +begin + require 'pkg-config' +rescue LoadError + require 'rubygems' + require 'pkg-config' +end + include RroongaBuild package_name = "groonga" @@ -61,16 +67,11 @@ checking_for(checking_message("Win32 OS")) do import_library_name = "libruby-#{module_name}.a" $DLDFLAGS << " -Wl,--out-implib=#{import_library_name}" $cleanfiles << import_library_name - local_groonga_install_dir = base_dir + "vendor" + "local" - $CFLAGS += " -I#{local_groonga_install_dir}/include" - local_groonga_lib_dir = local_groonga_install_dir + "lib" - ["libgroonga.lib", "libgroonga.dll.a"].each do |libgroonga_base| - libgroonga = local_groonga_lib_dir + libgroonga_base - if libgroonga.exist? - $DLDFLAGS += " -L#{local_groonga_lib_dir}" - break - end - end + binary_base_dir = base_dir + "vendor" + "local" + $CFLAGS += " -I#{binary_base_dir}/include" + pkg_config_dir = binary_base_dir + "lib" + "pkgconfig" + PKGConfig.add_path(pkg_config_dir.to_s) + PKGConfig.set_override_variable("prefix", binary_base_dir.to_s) end win32 end Deleted: pkg-config.rb (+0 -333) 100644 =================================================================== --- pkg-config.rb 2010-09-14 14:35:05 +0000 (becab73) +++ /dev/null @@ -1,333 +0,0 @@ -# Copyright 2008-2009 Kouhei Sutou -# This file is made available under the same terms as Ruby. - -require "rbconfig" - -require 'mkmf' -require 'shellwords' -require 'English' -require 'pathname' - -class PackageConfig - @@default_prepend_paths = [] - @@default_append_paths = [] - - class << self - def prepend_default_path(path) - @@default_prepend_paths.unshift(path) - end - - def append_default_path(path) - @@default_append_paths << path - end - end - - attr_accessor :msvc_syntax - def initialize(name, path=nil, msvc_syntax=false) - @name = name - @path = path || ENV["PKG_CONFIG_PATH"] - @path = [@path, guess_default_path].compact.join(separator) - @msvc_syntax = msvc_syntax - @variables = @declarations = nil - override_variables = with_config("override-variables", "") - @override_variables = parse_override_variables(override_variables) - end - - def exist? - not pc.nil? - end - - def requires - parse_requires(declaration("Requires")) - end - - def requires_private - parse_requires(declaration("Requires.private")) - end - - def cflags - path_flags, other_flags = collect_cflags - (other_flags + path_flags).join(" ") - end - - def cflags_only_I - collect_cflags[0].join(" ") - end - - def libs - path_flags, other_flags = collect_libs - (other_flags + path_flags).join(" ") - end - - def libs_only_l - collect_libs[1].find_all do |arg| - if @msvc_syntax - /\.lib\z/ =~ arg - else - /\A-l/ =~ arg - end - end.join(" ") - end - - def version - declaration("Version") - end - - def variable(name) - parse_pc if @variables.nil? - expand_value(@override_variables[name] || @variables[name]) - end - - def declaration(name) - parse_pc if @declarations.nil? - expand_value(@declarations[name]) - end - - private - def paths - paths = @@default_prepend_paths - paths += @path.split(separator) - paths += @@default_append_paths - paths - end - - def pc - paths.each do |path| - pc_name = File.join(path, "#{@name}.pc") - return pc_name if File.exist?(pc_name) - end - return nil - end - - def separator - File.expand_path(".").index(":") ? ";" : ":" - end - - def collect_cflags - all_cflags = (requires_private + requires.reverse).collect do |package| - self.class.new(package, @path, @msvc_syntax).cflags - end - all_cflags = [declaration("Cflags")] + all_cflags - all_cflags = all_cflags.join(" ").gsub(/-I /, '-I').split.uniq - path_flags, other_flags = all_cflags.partition {|flag| /\A-I/ =~ flag} - path_flags = path_flags.reject do |flag| - flag == "-I/usr/include" - end - if @msvc_syntax - path_flags = path_flags.collect do |flag| - flag.gsub(/\A-I/, "/I") - end - end - [path_flags, other_flags] - end - - def collect_libs - all_libs = requires.collect do |package| - self.class.new(package, @path, @msvc_syntax).libs - end - all_libs = [declaration("Libs")] + all_libs - all_libs = all_libs.join(" ").gsub(/-([Ll]) /, '\1').split.uniq - path_flags, other_flags = all_libs.partition {|flag| /\A-L/ =~ flag} - path_flags = path_flags.reject do |flag| - /\A-L\/usr\/lib(?:64)?\z/ =~ flag - end - if @msvc_syntax - path_flags = path_flags.collect do |flag| - flag.gsub(/\A-L/, "/libpath:") - end - other_flags = other_flags.collect do |flag| - if /\A-l/ =~ flag - "#{$POSTMATCH}.lib" - else - flag - end - end - end - [path_flags, other_flags] - end - - IDENTIFIER_RE = /[\w.]+/ - def parse_pc - raise ".pc for #{@name} doesn't exist." unless exist? - @variables = {} - @declarations = {} - File.open(pc) do |input| - input.each_line do |line| - line = line.gsub(/#.*/, '').strip - next if line.empty? - case line - when /^(#{IDENTIFIER_RE})=/ - @variables[$1] = $POSTMATCH.strip - when /^(#{IDENTIFIER_RE}):/ - @declarations[$1] = $POSTMATCH.strip - end - end - end - end - - def parse_requires(requires) - return [] if requires.nil? - requires_without_version = requires.gsub(/[<>]?=\s*[\d.]+\s*/, '') - requires_without_version.split(/[,\s]+/) - end - - def parse_override_variables(override_variables) - variables = {} - override_variables.split(",").each do |variable| - name, value = variable.split("=", 2) - variables[name] = value - end - variables - end - - def expand_value(value) - return nil if value.nil? - value.gsub(/\$\{(#{IDENTIFIER_RE})\}/) do - variable($1) - end - end - - def search_pkg_config_from_path(pkg_config) - (ENV["PATH"] || "").split(separator).each do |path| - try_pkg_config = Pathname(path) + pkg_config - return try_pkg_config if try_pkg_config.exist? - end - nil - end - - def search_pkg_config_by_dln_find_exe(pkg_config) - begin - require "dl/import" - rescue LoadError - return nil - end - dln = Module.new - dln.module_eval do - if DL.const_defined?(:Importer) - extend DL::Importer - else - extend DL::Importable - end - begin - dlload RbConfig::CONFIG["LIBRUBY"] - rescue RuntimeError - return nil if $!.message == "unknown error" - return nil if /: image not found\z/ =~ $!.message - raise - rescue DL::DLError - return nil - end - extern "const char *dln_find_exe(const char *, const char *)" - end - path = dln.dln_find_exe(pkg_config.to_s, nil) - if path and path.size.zero? - nil - else - Pathname(path.to_s) - end - end - - def guess_default_path - default_path = ["/usr/local/lib64/pkgconfig", - "/usr/local/lib/pkgconfig", - "/usr/local/libdata/pkgconfig", - "/opt/local/lib/pkgconfig", - "/usr/lib64/pkgconfig", - "/usr/lib/pkgconfig", - "/usr/X11/lib/pkgconfig/", - "/usr/share/pkgconfig"].join(separator) - libdir = ENV["PKG_CONFIG_LIBDIR"] - default_path = [libdir, default_path].join(separator) if libdir - - pkg_config = with_config("pkg-config", ENV["PKG_CONFIG"] || "pkg-config") - pkg_config = Pathname.new(pkg_config) - unless pkg_config.absolute? - found_pkg_config = search_pkg_config_from_path(pkg_config) - pkg_config = found_pkg_config if found_pkg_config - end - unless pkg_config.absolute? - found_pkg_config = search_pkg_config_by_dln_find_exe(pkg_config) - pkg_config = found_pkg_config if found_pkg_config - end - - return default_path unless pkg_config.absolute? - [(pkg_config.parent.parent + "lib" + "pkgconfig").to_s, - (pkg_config.parent.parent + "libdata" + "pkgconfig").to_s, - default_path].join(separator) - end -end - -module PKGConfig - module_function - def msvc? - /mswin32/.match(RUBY_PLATFORM) and /^cl\b/.match(Config::CONFIG['CC']) - end - - def package_config(package) - PackageConfig.new(package, nil, msvc?) - end - - def exist?(pkg) - package_config(pkg).exist? - end - - def libs(pkg) - package_config(pkg).libs - end - - def libs_only_l(pkg) - package_config(pkg).libs_only_l - end - - def cflags(pkg) - package_config(pkg).cflags - end - - def cflags_only_I(pkg) - package_config(pkg).cflags_only_I - end - - def modversion(pkg) - package_config(pkg).version - end - - def check_version?(pkg, major = 0, minor = 0, micro = 0) - return false unless exist?(pkg) - ver = modversion(pkg).split(".").collect{|item| item.to_i} - (0..2).each {|i| ver[i] = 0 unless ver[i]} - - (ver[0] > major || - (ver[0] == major && ver[1] > minor) || - (ver[0] == major && ver[1] == minor && - ver[2] >= micro)) - end - - def have_package(pkg, major = nil, minor = 0, micro = 0) - if major.nil? - STDOUT.print("checking for #{pkg}... ") - else - STDOUT.print("checking for #{pkg} version (>= #{major}.#{minor}.#{micro})... ") - end - major ||= 0 - STDOUT.flush - if check_version?(pkg, major, minor, micro) - STDOUT.print "yes\n" - libraries = libs_only_l(pkg) - dldflags = libs(pkg) - dldflags = (Shellwords.shellwords(dldflags) - - Shellwords.shellwords(libraries)) - dldflags = dldflags.map {|s| /\s/ =~ s ? "\"#{s}\"" : s }.join(' ') - $libs += ' ' + libraries - if /mswin32/ =~ RUBY_PLATFORM - $DLDFLAGS += ' ' + dldflags - else - $LDFLAGS += ' ' + dldflags - end - $CFLAGS += ' ' + cflags(pkg) - true - else - STDOUT.print "no\n" - false - end - end -end From null+ranguba at clear-code.com Thu Sep 16 10:45:30 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Thu, 16 Sep 2010 14:45:30 +0000 Subject: [groonga-commit:1295] ranguba/rroonga [master] support cross compile for Windows. Message-ID: <20100916144542.45F8D170640@taiyaki.ru> Kouhei Sutou 2010-09-16 14:45:30 +0000 (Thu, 16 Sep 2010) New Revision: 22d40d5c8280236b681dcf868fc67de8e89f627d Log: support cross compile for Windows. Added files: ext/groonga/groonga.def Modified files: ext/groonga/extconf.rb Modified: ext/groonga/extconf.rb (+14 -15) =================================================================== --- ext/groonga/extconf.rb 2010-09-16 05:09:52 +0000 (5ef6b0e) +++ ext/groonga/extconf.rb 2010-09-16 14:45:30 +0000 (6e3d18a) @@ -37,20 +37,6 @@ package_name = "groonga" module_name = "groonga" major, minor, micro = RequiredGroongaVersion::VERSION -unless PKGConfig.have_package(package_name, major, minor, micro) - have_local_groonga?(package_name, major, minor, micro) or exit 1 - add_rpath_for_local_groonga -end - -real_version = PKGConfig.modversion(package_name) -real_major, real_minor, real_micro = real_version.split(/\./) - -$defs << "-DRB_GRN_COMPILATION" - -$defs << "-DGRN_MAJOR_VERSION=#{real_major}" -$defs << "-DGRN_MINOR_VERSION=#{real_minor}" -$defs << "-DGRN_MICRO_VERSION=#{real_micro}" - checking_for(checking_message("GCC")) do if macro_defined?("__GNUC__", "") $CFLAGS += ' -Wall' @@ -68,7 +54,6 @@ checking_for(checking_message("Win32 OS")) do $DLDFLAGS << " -Wl,--out-implib=#{import_library_name}" $cleanfiles << import_library_name binary_base_dir = base_dir + "vendor" + "local" - $CFLAGS += " -I#{binary_base_dir}/include" pkg_config_dir = binary_base_dir + "lib" + "pkgconfig" PKGConfig.add_path(pkg_config_dir.to_s) PKGConfig.set_override_variable("prefix", binary_base_dir.to_s) @@ -76,6 +61,20 @@ checking_for(checking_message("Win32 OS")) do win32 end +unless PKGConfig.have_package(package_name, major, minor, micro) + have_local_groonga?(package_name, major, minor, micro) or exit 1 + add_rpath_for_local_groonga +end + +real_version = PKGConfig.modversion(package_name) +real_major, real_minor, real_micro = real_version.split(/\./) + +$defs << "-DRB_GRN_COMPILATION" + +$defs << "-DGRN_MAJOR_VERSION=#{real_major}" +$defs << "-DGRN_MINOR_VERSION=#{real_minor}" +$defs << "-DGRN_MICRO_VERSION=#{real_micro}" + have_header("ruby/st.h") unless have_macro("HAVE_RUBY_ST_H", "ruby.h") have_func("rb_errinfo", "ruby.h") have_type("enum ruby_value_type", "ruby.h") Added: ext/groonga/groonga.def (+2 -0) 100644 =================================================================== --- /dev/null +++ ext/groonga/groonga.def 2010-09-16 14:45:30 +0000 (7fd07eb) @@ -0,0 +1,2 @@ +EXPORTS + Init_groonga From null+ranguba at clear-code.com Fri Sep 17 01:28:27 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Fri, 17 Sep 2010 05:28:27 +0000 Subject: [groonga-commit:1296] ranguba/chupatext [master] * test/chupa_test_util.c: split helper functions. Message-ID: <20100917052847.799BC170EE4@taiyaki.ru> Nobuyoshi Nakada 2010-09-17 05:28:27 +0000 (Fri, 17 Sep 2010) New Revision: ad63bded01b6209cad0eb1ec3001fc70dacb8e8a Log: * test/chupa_test_util.c: split helper functions. Modified files: test/chupa_test_util.c test/chupa_test_util.h Modified: test/chupa_test_util.c (+25 -12) =================================================================== --- test/chupa_test_util.c 2010-09-16 02:35:05 +0000 (dc8b294) +++ test/chupa_test_util.c 2010-09-17 05:28:27 +0000 (1f930df) @@ -24,38 +24,51 @@ chupa_test_teardown(void) char * chupa_test_decompose_data(const char *text, gsize size, GError **err) { - ChupaText *chupar; + ChupaTextInput *input = chupa_test_decomposer_from_data(text, size, err); + return chupa_test_decompose_all(input, err); +} + +ChupaTextInput * +chupa_test_decomposer_from_data(const char *text, gsize size, GError **err) +{ ChupaTextInput *text_input; GInputStream *mem; - char *str; - TAKE_OBJECT(chupar = chupa_text_new()); TAKE_OBJECT(mem = g_memory_input_stream_new_from_data(text, size, NULL)); TAKE_OBJECT(text_input = chupa_text_input_new_from_stream(NULL, mem, NULL)); - if (!text_input) { - return NULL; - } - TAKE_STRING(str = chupa_text_decompose_all(chupar, text_input, err)); - return str; + return text_input; } char * chupa_test_decompose_fixture(const char *fixture, GError **err) { - ChupaText *chupar; + ChupaTextInput *input = chupa_test_decomposer_from_fixture(fixture, err); + return chupa_test_decompose_all(input, err); +} + +ChupaTextInput * +chupa_test_decomposer_from_fixture(const char *fixture, GError **err) +{ ChupaTextInput *text_input; - GsfInput *sample_input; gchar *sample_path; GFile *sample_file; - char *str; - TAKE_OBJECT(chupar = chupa_text_new()); TAKE_STRING(sample_path = cut_build_fixture_data_path(fixture, NULL)); TAKE_OBJECT(sample_file = g_file_new_for_path(sample_path)); TAKE_OBJECT(text_input = chupa_text_input_new_from_file(NULL, sample_file, err)); + return text_input; +} + +char * +chupa_test_decompose_all(ChupaTextInput *text_input, GError **err) +{ + ChupaText *chupar; + char *str; + if (!text_input) { return NULL; } + TAKE_OBJECT(chupar = chupa_text_new()); TAKE_STRING(str = chupa_text_decompose_all(chupar, text_input, err)); return str; } Modified: test/chupa_test_util.h (+3 -0) =================================================================== --- test/chupa_test_util.h 2010-09-16 02:35:05 +0000 (4eab9ff) +++ test/chupa_test_util.h 2010-09-17 05:28:27 +0000 (31bd74c) @@ -16,5 +16,8 @@ void chupa_test_setup(void); void chupa_test_teardown(void); char *chupa_test_decompose_fixture(const char *fixture, GError **err); char *chupa_test_decompose_data(const char *text, gsize size, GError **err); +ChupaTextInput *chupa_test_decomposer_from_data(const char *text, gsize size, GError **err); +ChupaTextInput *chupa_test_decomposer_from_fixture(const char *fixture, GError **err); +char *chupa_test_decompose_all(ChupaTextInput *text_input, GError **err); #endif From null+ranguba at clear-code.com Fri Sep 17 11:38:46 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Fri, 17 Sep 2010 15:38:46 +0000 Subject: [groonga-commit:1297] ranguba/rroonga [master] fix a typo. Message-ID: <20100917153904.CFE2A170EE4@taiyaki.ru> Kouhei Sutou 2010-09-17 15:38:46 +0000 (Fri, 17 Sep 2010) New Revision: 2b53902b31ad59bf26b072941d308cbabae87078 Log: fix a typo. Modified files: lib/groonga/schema.rb Modified: lib/groonga/schema.rb (+1 -1) =================================================================== --- lib/groonga/schema.rb 2010-09-16 14:45:30 +0000 (b97eae9) +++ lib/groonga/schema.rb 2010-09-17 15:38:46 +0000 (4d21a6f) @@ -96,7 +96,7 @@ module Groonga @options = options @unknown_keys = unknown_keys @available_keys = available_keys - message = "unknown keys are specified: #{u at nknown_keys.inspect}" + message = "unknown keys are specified: #{@unknown_keys.inspect}" message << ": available keys: #{@available_keys.inspect}" message << ": options: #{@options.inspect}" super(message) From null+ranguba at clear-code.com Tue Sep 21 00:22:12 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Tue, 21 Sep 2010 04:22:12 +0000 Subject: [groonga-commit:1298] ranguba/chupatext [master] * chupatext/chupa_decomposer.c (chupa_decomposer_unregister): steal before modification. Message-ID: <20100921042229.11BB7170640@taiyaki.ru> Nobuyoshi Nakada 2010-09-21 04:22:12 +0000 (Tue, 21 Sep 2010) New Revision: b6b700f814cdf8161a09e4a7731eedf09dfc8579 Log: * chupatext/chupa_decomposer.c (chupa_decomposer_unregister): steal before modification. Modified files: chupatext/chupa_decomposer.c test/test_decomposer.c Modified: chupatext/chupa_decomposer.c (+1 -4) =================================================================== --- chupatext/chupa_decomposer.c 2010-09-17 05:28:27 +0000 (a046097) +++ chupatext/chupa_decomposer.c 2010-09-21 04:22:12 +0000 (5152ccb) @@ -90,14 +90,11 @@ chupa_decomposer_unregister(const gchar *mime_type, GType type) gpointer key = (gpointer)mime_type, val = NULL; if (g_hash_table_lookup_extended(decomp_modules, key, &key, &val)) { + g_hash_table_steal(decomp_modules, key); val = g_list_remove((GList *)val, (gpointer)type); if (val) { - g_hash_table_steal(decomp_modules, key); g_hash_table_insert(decomp_modules, key, val); } - else { - g_hash_table_remove(decomp_modules, key); - } } } Modified: test/test_decomposer.c (+46 -0) =================================================================== --- test/test_decomposer.c 2010-09-17 05:28:27 +0000 (b57c95e) +++ test/test_decomposer.c 2010-09-21 04:22:12 +0000 (4a4e820) @@ -34,3 +34,49 @@ test_search(void) cut_assert_not_null(decomp); cut_assert_not_null(CHUPA_TEXT_DECOMPOSER(decomp)); } + +#define CHUPA_TEST_TYPE_DUMMY_DECOMPOSER chupa_test_dummy_decomposer_get_type() +#define CHUPA_TEST_DUMMY_DECOMPOSER(obj) \ + G_TYPE_CHECK_INSTANCE_CAST(obj, CHUPA_TEST_TYPE_DUMMY_DECOMPOSER, ChupaTestDummyDecomposer) +#define CHUPA_TEST_DUMMY_DECOMPOSER_CLASS(klass) \ + G_TYPE_CHECK_CLASS_CAST(klass, CHUPA_TEST_TYPE_DUMMY_DECOMPOSER, ChupaTestDummyDecomposerClass) +#define CHUPA_TEST_IS_DUMMY_DECOMPOSER(obj) \ + G_TYPE_CHECK_INSTANCE_TYPE(obj, CHUPA_TEST_TYPE_DUMMY_DECOMPOSER) +#define CHUPA_TEST_IS_DUMMY_DECOMPOSER_CLASS(klass) \ + G_TYPE_CHECK_CLASS_TYPE(klass, CHUPA_TEST_TYPE_DUMMY_DECOMPOSER) +#define CHUPA_TEST_DUMMY_DECOMPOSER_GET_CLASS(obj) \ + G_TYPE_INSTANCE_GET_CLASS(obj, CHUPA_TEST_TYPE_DUMMY_DECOMPOSER, ChupaTestDummyDecomposerClass) + +typedef struct _ChupaTestDummyDecomposer ChupaTestDummyDecomposer; +typedef struct _ChupaTestDummyDecomposerClass ChupaTestDummyDecomposerClass; +typedef struct _ChupaTestDummyDecomposerPrivate ChupaTestDummyDecomposerPrivate; + +struct _ChupaTestDummyDecomposer +{ + ChupaDecomposer object; +}; + +struct _ChupaTestDummyDecomposerClass +{ + ChupaDecomposerClass parent_class; +}; + +G_DEFINE_TYPE(ChupaTestDummyDecomposer, chupa_test_dummy_decomposer, CHUPA_TYPE_DECOMPOSER) + +static void +chupa_test_dummy_decomposer_init(ChupaTestDummyDecomposer *dec) +{ +} + +static void +chupa_test_dummy_decomposer_class_init(ChupaTestDummyDecomposerClass *klass) +{ +} + +void +test_register(void) +{ + static const char test_dummy_type[] = "application/x-chupa-test"; + chupa_decomposer_register(test_dummy_type, CHUPA_TEST_TYPE_DUMMY_DECOMPOSER); + chupa_decomposer_unregister(test_dummy_type, CHUPA_TEST_TYPE_DUMMY_DECOMPOSER); +} From null+ranguba at clear-code.com Tue Sep 21 00:25:06 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Tue, 21 Sep 2010 04:25:06 +0000 Subject: [groonga-commit:1299] ranguba/chupatext [master] * chupatext/external_decomposer.c: decomposer using external process. Message-ID: <20100921042533.21C27170640@taiyaki.ru> Nobuyoshi Nakada 2010-09-21 04:25:06 +0000 (Tue, 21 Sep 2010) New Revision: 2082101943c8ab05544a0ae0f6f1d320db3d7cba Log: * chupatext/external_decomposer.c: decomposer using external process. Added files: chupatext/external_decomposer.c chupatext/external_decomposer.h test/test_external_decomposer.c Modified files: chupatext/Makefile.am configure.ac test/Makefile.am Modified: chupatext/Makefile.am (+4 -2) =================================================================== --- chupatext/Makefile.am 2010-09-21 04:22:12 +0000 (2dfade7) +++ chupatext/Makefile.am 2010-09-21 04:25:06 +0000 (4e73185) @@ -17,14 +17,15 @@ libchupatext_la_SOURCES = \ error.c \ chupa_decomposer.c \ archive_decomposer.c \ + external_decomposer.c \ text_decomposer.c \ chupa_restrict_input_stream.c \ version.c \ $(EMPTY) AM_CPPFLAGS = -DCHUPA_MODULE_PATH=\"$(moduledir)\" -D_GNU_SOURCE -AM_CFLAGS = $(GSF_CFLAGS) -AM_LDFLAGS = $(GSF_LIBS) +AM_CFLAGS = $(GSF_CFLAGS) $(GIO_UNIX_CFLAGS) +AM_LDFLAGS = $(GSF_LIBS) $(GIO_UNIX_LIBS) DEFAULT_INCLUDES = -I$(top_includedir) -I$(build_includedir) @@ -41,6 +42,7 @@ chupatext_include_HEADERS = \ chupa_text_input.h \ chupa_text_input_stream.h \ text_decomposer.h \ + external_decomposer.h \ version.h version.lo: version.h Added: chupatext/external_decomposer.c (+170 -0) 100644 =================================================================== --- /dev/null +++ chupatext/external_decomposer.c 2010-09-21 04:25:06 +0000 (cd30778) @@ -0,0 +1,170 @@ +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Copyright (C) 2010 Nobuyoshi Nakada + */ + +#include "external_decomposer.h" +#include +#include + +#define CHUPA_EXTERNAL_DECOMPOSER_GET_PRIVATE(obj) NULL + +#if 0 + (G_TYPE_INSTANCE_GET_PRIVATE(obj, \ + CHUPA_TYPE_EXTERNAL_DECOMPOSER, \ + ChupaExternalDecomposerPrivate)) + +struct _ChupaExternalDecomposerPrivate +{ +}; +#endif + +G_DEFINE_ABSTRACT_TYPE(ChupaExternalDecomposer, chupa_external_decomposer, CHUPA_TYPE_DECOMPOSER) + +gboolean +chupa_external_decomposer_spawn(ChupaExternalDecomposer *dec, gchar **argv, GOutputStream **stdinput, + GInputStream **stdoutput, GError **error) +{ + ChupaExternalDecomposerPrivate *priv; + gint input, output; + + priv = CHUPA_EXTERNAL_DECOMPOSER_GET_PRIVATE(dec); + if (!g_spawn_async_with_pipes(NULL, argv, NULL, G_SPAWN_SEARCH_PATH, + NULL, NULL, NULL, + stdinput ? &input : NULL, + stdoutput ? &output : NULL, + NULL, error)) { + return FALSE; + } + if (stdinput) { + *stdinput = g_unix_output_stream_new(input, TRUE); + } + if (stdoutput) { + *stdoutput = g_unix_input_stream_new(output, TRUE); + } + return TRUE; +} + +void +chupa_external_decomposer_set_metadata(ChupaExternalDecomposer *dec, ChupaTextInput *input) +{ +} + +#if 0 +#define close_invalidate(stream) (void)(stream ? (g_object_unref(stream), stream = NULL) : NULL) + +static void +dispose(GObject *object) +{ + ChupaExternalDecomposerPrivate *priv; + + priv = CHUPA_EXTERNAL_DECOMPOSER(object)->priv; + + G_OBJECT_CLASS(chupa_external_decomposer_parent_class)->dispose(object); +} + +static void +set_property(GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) +{ + ChupaExternalDecomposer *dec = CHUPA_EXTERNAL_DECOMPOSER(object); + GObject *obj; + + switch (prop_id) { + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + break; + } +} + +static void +get_property(GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ + ChupaExternalDecomposer *dec = CHUPA_EXTERNAL_DECOMPOSER(object); + switch (prop_id) { + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + break; + } +} + +static void +constructed(GObject *object) +{ + ChupaExternalDecomposer *dec; + g_return_if_fail(CHUPA_IS_EXTERNAL_DECOMPOSER(object)); + dec = CHUPA_EXTERNAL_DECOMPOSER(object); +} +#endif + +static gboolean +feed(ChupaDecomposer *dec, ChupaText *chupar, ChupaTextInput *input, GError **err) +{ + GInputStream *inp, *sout = NULL; + GOutputStream *sin = NULL; + ChupaExternalDecomposerClass *self_class; + ChupaExternalDecomposer *extdec; + ChupaExternalDecomposerPrivate *priv; + ChupaMetadata *meta; + gboolean result; + + g_return_val_if_fail(CHUPA_IS_EXTERNAL_DECOMPOSER(dec), FALSE); + g_return_val_if_fail(CHUPA_IS_TEXT_INPUT(input), FALSE); + extdec = CHUPA_EXTERNAL_DECOMPOSER(dec); + self_class = CHUPA_EXTERNAL_DECOMPOSER_GET_CLASS(extdec); + priv = extdec->priv; + inp = G_INPUT_STREAM(chupa_text_input_get_stream(input)); + g_return_val_if_fail(self_class->spawn(extdec, chupar, &sin, &sout, err), FALSE); + if (sin) { + g_output_stream_splice_async(sin, inp, + G_OUTPUT_STREAM_SPLICE_CLOSE_SOURCE| + G_OUTPUT_STREAM_SPLICE_CLOSE_TARGET, + 0, NULL, + NULL, NULL); + g_object_unref(sin); + } + g_return_val_if_fail(sout, FALSE); + input = chupa_text_input_new_from_stream(NULL, sout, + chupa_text_input_get_filename(input)); + g_object_unref(sout); + self_class->set_metadata(extdec, input); + result = chupa_text_feed(chupar, input, err); + g_object_unref(input); + return result; +} + +static void +chupa_external_decomposer_init(ChupaExternalDecomposer *dec) +{ + ChupaExternalDecomposerClass *self_class; + self_class = CHUPA_EXTERNAL_DECOMPOSER_GET_CLASS(dec); + g_return_if_fail(self_class); + dec->priv = CHUPA_EXTERNAL_DECOMPOSER_GET_PRIVATE(dec); +} + +static void +chupa_external_decomposer_class_init(ChupaExternalDecomposerClass *klass) +{ +#if 0 + { + GObjectClass *gobject_class = G_OBJECT_CLASS(klass); + gobject_class->constructed = constructed; + gobject_class->dispose = dispose; + gobject_class->set_property = set_property; + gobject_class->get_property = get_property; + } +#endif + { + ChupaDecomposerClass *decomposer_class = CHUPA_DECOMPOSER_CLASS(klass); + decomposer_class->feed = feed; + } + { + ChupaExternalDecomposerClass *extdec_class = CHUPA_EXTERNAL_DECOMPOSER_CLASS(klass); + extdec_class->set_metadata = chupa_external_decomposer_set_metadata; + } +} Added: chupatext/external_decomposer.h (+54 -0) 100644 =================================================================== --- /dev/null +++ chupatext/external_decomposer.h 2010-09-21 04:25:06 +0000 (60af19f) @@ -0,0 +1,54 @@ +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Copyright (C) 2010 Nobuyoshi Nakada + */ + +#ifndef CHUPATEXT_EXTERNAL_DECOMPOSER_H +#define CHUPATEXT_EXTERNAL_DECOMPOSER_H + +#include "chupatext/chupa_decomposer.h" +#include +#include +#include + +G_BEGIN_DECLS + +#define CHUPA_TYPE_EXTERNAL_DECOMPOSER chupa_external_decomposer_get_type() +#define CHUPA_EXTERNAL_DECOMPOSER(obj) \ + G_TYPE_CHECK_INSTANCE_CAST(obj, CHUPA_TYPE_EXTERNAL_DECOMPOSER, ChupaExternalDecomposer) +#define CHUPA_EXTERNAL_DECOMPOSER_CLASS(klass) \ + G_TYPE_CHECK_CLASS_CAST(klass, CHUPA_TYPE_EXTERNAL_DECOMPOSER, ChupaExternalDecomposerClass) +#define CHUPA_IS_EXTERNAL_DECOMPOSER(obj) \ + G_TYPE_CHECK_INSTANCE_TYPE(obj, CHUPA_TYPE_EXTERNAL_DECOMPOSER) +#define CHUPA_IS_EXTERNAL_DECOMPOSER_CLASS(klass) \ + G_TYPE_CHECK_CLASS_TYPE(klass, CHUPA_TYPE_EXTERNAL_DECOMPOSER) +#define CHUPA_EXTERNAL_DECOMPOSER_GET_CLASS(obj) \ + G_TYPE_INSTANCE_GET_CLASS(obj, CHUPA_TYPE_EXTERNAL_DECOMPOSER, ChupaExternalDecomposerClass) + +typedef struct _ChupaExternalDecomposer ChupaExternalDecomposer; +typedef struct _ChupaExternalDecomposerClass ChupaExternalDecomposerClass; +typedef struct _ChupaExternalDecomposerPrivate ChupaExternalDecomposerPrivate; + +struct _ChupaExternalDecomposer +{ + ChupaDecomposer object; + + ChupaExternalDecomposerPrivate *priv; +}; + +struct _ChupaExternalDecomposerClass +{ + ChupaDecomposerClass parent_class; + + gboolean (*spawn)(ChupaExternalDecomposer *dec, ChupaText *chupar, + GOutputStream **stdinput, GInputStream **stdoutput, + GError **error); + void (*set_metadata)(ChupaExternalDecomposer *dec, ChupaTextInput *input); +}; + +GType chupa_external_decomposer_get_type(void) G_GNUC_CONST; +GsfInfile *chupa_external_decomoser_get_infile(ChupaExternalDecomposer *); + +G_END_DECLS + +#endif /* CHUPATEXT_EXTERNAL_DECOMPOSER_H */ Modified: configure.ac (+2 -0) =================================================================== --- configure.ac 2010-09-21 04:22:12 +0000 (6d76a2a) +++ configure.ac 2010-09-21 04:25:06 +0000 (e5b6e70) @@ -56,6 +56,8 @@ fi PKG_CHECK_MODULES(GSF, libgsf-1, [have_gsf=yes], [:]) AM_CONDITIONAL([HAVE_GSF], [test "$have_gsf" = "yes"]) +PKG_CHECK_MODULES(GIO_UNIX, gio-unix-2.0, [have_gio_unix=yes], [:]) +AM_CONDITIONAL([HAVE_GIO_UNIX], [test "$have_gio_unix" = "yes"]) PKG_CHECK_MODULES(POPPLER_GLIB, poppler-glib, [have_poppler=yes], [:]) AM_CONDITIONAL([HAVE_POPPLER_GLIB], [test "$have_poppler" = "yes"]) PKG_CHECK_MODULES(WV, wv-1.0, [have_wv=yes], [:]) Modified: test/Makefile.am (+2 -0) =================================================================== --- test/Makefile.am 2010-09-21 04:22:12 +0000 (5af2b21) +++ test/Makefile.am 2010-09-21 04:25:06 +0000 (6e55535) @@ -11,6 +11,7 @@ noinst_LTLIBRARIES = \ test_text_input.la \ test_text_input_stream.la \ test_decomposer.la \ + test_external_decomposer.la \ test_restrict_input_stream.la \ test_tar.la \ test_zip.la \ @@ -60,6 +61,7 @@ test_text_la_SOURCES = test_text.c chupa_test_util.c test_text_input_la_SOURCES = test_text_input.c test_text_input_stream_la_SOURCES = test_text_input_stream.c test_decomposer_la_SOURCES = test_decomposer.c +test_external_decomposer_la_SOURCES = test_external_decomposer.c chupa_test_util.c test_restrict_input_stream_la_SOURCES = test_restrict_input_stream.c test_pdf_la_SOURCES = test_pdf.c chupa_test_util.c test_msword_la_SOURCES = test_msword.c chupa_test_util.c Added: test/test_external_decomposer.c (+87 -0) 100644 =================================================================== --- /dev/null +++ test/test_external_decomposer.c 2010-09-21 04:25:06 +0000 (ad93247) @@ -0,0 +1,87 @@ +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Copyright (C) 2010 Nobuyoshi Nakada + */ + +#include "chupatext/external_decomposer.h" +#include "chupa_test_util.h" +#include + +#define CHUPA_TEST_TYPE_EXTERNAL_DECOMPOSER chupa_test_external_decomposer_get_type() +#define CHUPA_TEST_EXTERNAL_DECOMPOSER(obj) \ + G_TYPE_CHECK_INSTANCE_CAST(obj, CHUPA_TEST_TYPE_EXTERNAL_DECOMPOSER, ChupaTestExternalDecomposer) +#define CHUPA_TEST_EXTERNAL_DECOMPOSER_CLASS(klass) \ + G_TYPE_CHECK_CLASS_CAST(klass, CHUPA_TEST_TYPE_EXTERNAL_DECOMPOSER, ChupaTestExternalDecomposerClass) +#define CHUPA_TEST_IS_EXTERNAL_DECOMPOSER(obj) \ + G_TYPE_CHECK_INSTANCE_TYPE(obj, CHUPA_TEST_TYPE_EXTERNAL_DECOMPOSER) +#define CHUPA_TEST_IS_EXTERNAL_DECOMPOSER_CLASS(klass) \ + G_TYPE_CHECK_CLASS_TYPE(klass, CHUPA_TEST_TYPE_EXTERNAL_DECOMPOSER) +#define CHUPA_TEST_EXTERNAL_DECOMPOSER_GET_CLASS(obj) \ + G_TYPE_INSTANCE_GET_CLASS(obj, CHUPA_TEST_TYPE_EXTERNAL_DECOMPOSER, ChupaTestExternalDecomposerClass) + +typedef struct _ChupaTestExternalDecomposer ChupaTestExternalDecomposer; +typedef struct _ChupaTestExternalDecomposerClass ChupaTestExternalDecomposerClass; +typedef struct _ChupaTestExternalDecomposerPrivate ChupaTestExternalDecomposerPrivate; + +struct _ChupaTestExternalDecomposer +{ + ChupaExternalDecomposer object; +}; + +struct _ChupaTestExternalDecomposerClass +{ + ChupaExternalDecomposerClass parent_class; +}; + +G_DEFINE_TYPE(ChupaTestExternalDecomposer, chupa_test_external_decomposer, CHUPA_TYPE_EXTERNAL_DECOMPOSER) + +static const char plain_text[] = "plain text\n"; + +static gboolean +testdec_spawn(ChupaExternalDecomposer *dec, ChupaText *chupar, + GOutputStream **stdinput, GInputStream **stdoutput, + GError **error) +{ + *stdoutput = g_memory_input_stream_new_from_data(plain_text, sizeof(plain_text) - 1, NULL); + return TRUE; +} + +static void +chupa_test_external_decomposer_init(ChupaTestExternalDecomposer *dec) +{ +} + +static void +chupa_test_external_decomposer_class_init(ChupaTestExternalDecomposerClass *klass) +{ + ChupaExternalDecomposerClass *extdec_class = CHUPA_EXTERNAL_DECOMPOSER_CLASS(klass); + extdec_class->spawn = testdec_spawn; +} + +static const char test_external_type[] = "application/x-chupa-test-external"; + +void +setup(void) +{ + chupa_test_setup(); + chupa_decomposer_register(test_external_type, CHUPA_TEST_TYPE_EXTERNAL_DECOMPOSER); +} + +void +teardown(void) +{ + chupa_decomposer_unregister(test_external_type, CHUPA_TEST_TYPE_EXTERNAL_DECOMPOSER); + chupa_test_teardown(); +} + +void +test_decompose_external(void) +{ + ChupaTextInput *input = chupa_test_decomposer_from_data(plain_text, sizeof(plain_text) - 1, NULL); + + cut_assert_not_null(input); + chupa_metadata_replace_value(chupa_text_input_get_metadata(input), + "mime-type", test_external_type); + cut_assert(CHUPA_TEST_IS_EXTERNAL_DECOMPOSER(gcut_take_object(G_OBJECT(chupa_decomposer_search(test_external_type))))); + cut_assert_equal_string(plain_text, chupa_test_decompose_all(input, NULL)); +} From null+ranguba at clear-code.com Tue Sep 21 17:22:28 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Tue, 21 Sep 2010 21:22:28 +0000 Subject: [groonga-commit:1300] ranguba/chupatext [master] * chupatext/chupa_decomposer.c (chupa_decomposer_search): load modules on demand. Message-ID: <20100921213713.DE376170640@taiyaki.ru> Nobuyoshi Nakada 2010-09-21 21:22:28 +0000 (Tue, 21 Sep 2010) New Revision: 37b63d5163fcedb2dffdca691143a5b0f11ae30f Log: * chupatext/chupa_decomposer.c (chupa_decomposer_search): load modules on demand. Added files: module/.gitignore module/prereq.mk Modified files: Makefile.am chupatext/chupa_decomposer.c module/Makefile.am prereq.mk Modified: Makefile.am (+1 -1) =================================================================== --- Makefile.am 2010-09-21 04:25:06 +0000 (b39338a) +++ Makefile.am 2010-09-21 21:22:28 +0000 (5d9423f) @@ -8,6 +8,6 @@ EXTRA_DIST = \ COPYING \ README.ja -all-recursive: update-version.h +all-recursive: prereq @am__include@ $(srcdir)/prereq.mk Modified: chupatext/chupa_decomposer.c (+36 -34) =================================================================== --- chupatext/chupa_decomposer.c 2010-09-21 04:25:06 +0000 (5152ccb) +++ chupatext/chupa_decomposer.c 2010-09-21 21:22:28 +0000 (22757a9) @@ -15,6 +15,8 @@ ChupaDecomposerPrivate)) static GHashTable *decomp_modules = NULL; +static GHashTable *decomp_load_table = NULL; +static gchar *module_base_dir; #define module_list_free (GDestroyNotify)g_list_free @@ -23,6 +25,13 @@ decomp_modules_init(void) { decomp_modules = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, module_list_free); + decomp_load_table = g_hash_table_new(g_str_hash, g_str_equal); + module_base_dir = chupa_module_path(); + +#define REGISTER(mime_type, module) \ + g_hash_table_insert(decomp_load_table, mime_type, module) +#include "module/init_chupa.h" +#undef REGISTER } #ifdef USE_CHUPA_DECOMPOSER_PRIVATE @@ -59,17 +68,11 @@ chupa_decomposer_feed(ChupaDecomposer *dec, ChupaText *text, ChupaTextInput *inp } static const char text_plain[] = "text/plain"; -static GList *load_modules = NULL; void chupa_decomposer_load_modules(void) { - gchar *base_dir; - chupa_decomposer_register(text_plain, CHUPA_TYPE_TEXT_DECOMPOSER); - base_dir = chupa_module_path(); - load_modules = chupa_module_load_modules(base_dir); - g_free(base_dir); } void @@ -104,40 +107,39 @@ chupa_decomposer_search(const gchar *const mime_type) GList *type_list = NULL; const char *sub_type; gpointer key, value; + ChupaModule *mod; + int retry = 0; - again: - if (g_hash_table_lookup_extended(decomp_modules, mime_type, &key, &value)) { - type_list = (GList *)value; - } - else if ((sub_type = strchr((const char *)mime_type, '/')) != NULL) { - ++sub_type; - if (sub_type[0] == 'x' && sub_type[1] == '-') { - GString *tmp_type = g_string_new_len(mime_type, sub_type - mime_type); - g_string_append(tmp_type, sub_type += 2); - if (g_hash_table_lookup_extended(decomp_modules, tmp_type->str, &key, &value)) { - type_list = (GList *)value; - } - g_string_free(tmp_type, TRUE); + do { + if (g_hash_table_lookup_extended(decomp_modules, mime_type, &key, &value)) { + type_list = (GList *)value; } - if (!type_list) { - const char *dot = strchr(sub_type, '.'); - gsize i; - char *p; - ChupaModule *mod; - GString *mod_name = g_string_new(dot ? dot + 1 : sub_type); - for (i = 0; (p = strchr(mod_name->str + i, '-')) != NULL; ) { - g_string_erase(mod_name, i = p - mod_name->str, 1); + else if (g_hash_table_lookup_extended(decomp_load_table, mime_type, &key, &value) && + (mod = chupa_module_load_module(module_base_dir, (const gchar *)value)) != NULL) { + if (!g_type_module_use(G_TYPE_MODULE(mod))) { + break; } - mod = chupa_module_find(load_modules, mod_name->str); - g_string_free(mod_name, TRUE); - if (mod) { - load_modules = g_list_remove(load_modules, mod); - if (g_type_module_use(G_TYPE_MODULE(mod))) { - goto again; + } + else if ((sub_type = strchr((const char *)mime_type, '/')) != NULL) { + GString *tmp_type = NULL; + ++sub_type; + if (sub_type[0] == 'x' && sub_type[1] == '-') { + tmp_type = g_string_new_len(mime_type, sub_type - mime_type); + g_string_append(tmp_type, sub_type += 2); + if (g_hash_table_lookup_extended(decomp_modules, tmp_type->str, &key, &value)) { + type_list = (GList *)value; } } + if (!type_list && + g_hash_table_lookup_extended(decomp_load_table, tmp_type->str, &key, &value)) { + mod = chupa_module_load_module(module_base_dir, (const gchar *)value); + } + g_string_free(tmp_type, TRUE); + if (!mod || !g_type_module_use(G_TYPE_MODULE(mod))) { + break; + } } - } + } while (!type_list && !retry++); if (!type_list) { return NULL; Added: module/.gitignore (+1 -0) 100644 =================================================================== --- /dev/null +++ module/.gitignore 2010-09-21 21:22:28 +0000 (3bb1af5) @@ -0,0 +1 @@ +init_chupa.h Modified: module/Makefile.am (+4 -0) =================================================================== --- module/Makefile.am 2010-09-21 04:25:06 +0000 (7dfaf24) +++ module/Makefile.am 2010-09-21 21:22:28 +0000 (b08ea9b) @@ -42,3 +42,7 @@ chupa_mspowerpoint_la_CPPFLAGS = $(GSF_CFLAGS) chupa_mspowerpoint_la_LIBADD = $(GSF_LIBS) DEFAULT_INCLUDES = -I$(top_includedir) -I$(build_includedir) + +all: prereq + + at am__include@ $(srcdir)/prereq.mk Added: module/prereq.mk (+18 -0) 100644 =================================================================== --- /dev/null +++ module/prereq.mk 2010-09-21 21:22:28 +0000 (eda5c18) @@ -0,0 +1,18 @@ +prereq: init_chupa.h + +init_chupa.h: $(SOURCES) + @set dummy $(SOURCES); shift; \ + test $$# -gt 0 || set chupa_*.c; \ + srcdir="$(srcdir)"; : $${srcdir:=.}; \ + for f do \ + b=`basename $$f .c`; \ + sed -n '/chupa_decomposer_register/s/.*\(".*"\).*/REGISTER(\1,"'$$b'");/p' \ + "$$srcdir/$$f"; \ + done > $@.new && \ + if test -f $@ && cmp $@ $@.new; then \ + echo $@ is up-to-date; \ + rm $@.new; \ + else \ + echo updating $@; \ + mv $@.new $@; \ + fi Modified: prereq.mk (+24 -1) =================================================================== --- prereq.mk 2010-09-21 04:25:06 +0000 (87f5970) +++ prereq.mk 2010-09-21 21:22:28 +0000 (56f9b2e) @@ -2,11 +2,34 @@ GIT = git -up: pull update-version.h +up: pull update-version.h chupatext/module_list.h pull: @cd "$(srcdir)" && $(GIT) pull +prereq: prereq-local prereq-recursive + +prereq-local: update-version.h + +prereq-recursive: + @local_target=`echo $@ | sed s/-recursive//`; \ + top=$(top_srcdir) cd=$(am__cd); \ + : "$${top:=.}" "$${cd:=cd}"; \ + set dummy $(SUBDIRS); shift; \ + if test $$# = 0; then \ + set dummy `ls */prereq.mk 2> /dev/null | sed 's/\/prereq\.mk$$//'`; \ + shift; \ + fi; \ + for subdir do \ + test -f "$$top/$$subdir/prereq.mk" || continue; \ + ($$cd $$subdir && \ + if test -f Makefile; then \ + exec $(MAKE) $(AM_MAKEFLAGS) $$local_target; \ + else \ + exec $(MAKE) -f prereq.mk $(AM_MAKEFLAGS) $$local_target; \ + fi) || exit 1; \ + done + update-version.h: @cd "$(top_srcdir)" && \ $(SHELL) ./tool/version-update.sh chupatext/version.h From null+ranguba at clear-code.com Thu Sep 23 06:25:19 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Thu, 23 Sep 2010 10:25:19 +0000 Subject: [groonga-commit:1301] ranguba/chupatext [master] fix default testdir for test/run-test.sh case. Message-ID: <20100923102531.6E74F170EB4@taiyaki.ru> Kouhei Sutou 2010-09-23 10:25:19 +0000 (Thu, 23 Sep 2010) New Revision: 7989f1bd9b121e69a423dbe7a969461af661d365 Log: fix default testdir for test/run-test.sh case. Modified files: test/run-test.sh Modified: test/run-test.sh (+1 -1) =================================================================== --- test/run-test.sh 2010-09-21 21:22:28 +0000 (6af1e79) +++ test/run-test.sh 2010-09-23 10:25:19 +0000 (9760533) @@ -20,7 +20,7 @@ case "$BASE_DIR" in */..) top_srcdir="$BASE_DIR/..";; */test) top_srcdir="`dirname "$BASE_DIR"`";; esac -testdir=. +testdir=${BASE_DIR} test $# = 0 || eval testdir='"${'$#'-.}"' case "$testdir" in -* ) testdir=.; builddir="`pwd`";; From null+ranguba at clear-code.com Thu Sep 23 06:29:11 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Thu, 23 Sep 2010 10:29:11 +0000 Subject: [groonga-commit:1302] ranguba/chupatext [master] add valid value checks. Message-ID: <20100923102921.923F9170EB4@taiyaki.ru> Kouhei Sutou 2010-09-23 10:29:11 +0000 (Thu, 23 Sep 2010) New Revision: 458545757d3b69267c73bd5c5cafa5570227608b Log: add valid value checks. Modified files: chupatext/chupa_decomposer.c Modified: chupatext/chupa_decomposer.c (+2 -2) =================================================================== --- chupatext/chupa_decomposer.c 2010-09-23 10:25:19 +0000 (22757a9) +++ chupatext/chupa_decomposer.c 2010-09-23 10:29:11 +0000 (9f9ed48) @@ -107,7 +107,7 @@ chupa_decomposer_search(const gchar *const mime_type) GList *type_list = NULL; const char *sub_type; gpointer key, value; - ChupaModule *mod; + ChupaModule *mod = NULL; int retry = 0; do { @@ -130,7 +130,7 @@ chupa_decomposer_search(const gchar *const mime_type) type_list = (GList *)value; } } - if (!type_list && + if (!type_list && tmp_type && g_hash_table_lookup_extended(decomp_load_table, tmp_type->str, &key, &value)) { mod = chupa_module_load_module(module_base_dir, (const gchar *)value); } From null+ranguba at clear-code.com Thu Sep 23 06:33:31 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Thu, 23 Sep 2010 10:33:31 +0000 Subject: [groonga-commit:1303] ranguba/chupatext [master] add NULL check. Message-ID: <20100923103340.21293170EB4@taiyaki.ru> Kouhei Sutou 2010-09-23 10:33:31 +0000 (Thu, 23 Sep 2010) New Revision: b845040e09e1acd946cba23cb82fe7536190e1e1 Log: add NULL check. Modified files: chupatext/chupa_decomposer.c Modified: chupatext/chupa_decomposer.c (+3 -1) =================================================================== --- chupatext/chupa_decomposer.c 2010-09-23 10:29:11 +0000 (9f9ed48) +++ chupatext/chupa_decomposer.c 2010-09-23 10:33:31 +0000 (3c440cf) @@ -134,7 +134,9 @@ chupa_decomposer_search(const gchar *const mime_type) g_hash_table_lookup_extended(decomp_load_table, tmp_type->str, &key, &value)) { mod = chupa_module_load_module(module_base_dir, (const gchar *)value); } - g_string_free(tmp_type, TRUE); + if (tmp_type) { + g_string_free(tmp_type, TRUE); + } if (!mod || !g_type_module_use(G_TYPE_MODULE(mod))) { break; } From null+ranguba at clear-code.com Thu Sep 23 06:36:56 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Thu, 23 Sep 2010 10:36:56 +0000 Subject: [groonga-commit:1304] ranguba/chupatext [master] remove middle variable declaration. Message-ID: <20100923103705.BF042170EB4@taiyaki.ru> Kouhei Sutou 2010-09-23 10:36:56 +0000 (Thu, 23 Sep 2010) New Revision: e27c56d2bb27c7b502baf809c07594d846fd95a7 Log: remove middle variable declaration. Modified files: module/chupa_pdf.c Modified: module/chupa_pdf.c (+3 -2) =================================================================== --- module/chupa_pdf.c 2010-09-23 10:33:31 +0000 (232af80) +++ module/chupa_pdf.c 2010-09-23 10:36:56 +0000 (20819ac) @@ -68,12 +68,13 @@ chupa_pdf_decomposer_feed(ChupaDecomposer *dec, ChupaText *chupar, n = poppler_document_get_n_pages(doc); for (i = 0; i < n; ++i) { PopplerPage *page = poppler_document_get_page(doc, i); + gchar *text; #if POPPLER_CHECK_VERSION(0, 14, 0) - char *text = poppler_page_get_text(page); + text = poppler_page_get_text(page); #else PopplerRectangle rectangle = {0, 0, 0, 0}; poppler_page_get_size (page, &rectangle.x2, &rectangle.y2); - char *text = poppler_page_get_text(page, POPPLER_SELECTION_GLYPH, &rectangle); + text = poppler_page_get_text(page, POPPLER_SELECTION_GLYPH, &rectangle); #endif if (mem) { g_memory_input_stream_add_data(mem, "\f", 1, NULL); From null+ranguba at clear-code.com Thu Sep 23 20:59:06 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Fri, 24 Sep 2010 00:59:06 +0000 Subject: [groonga-commit:1305] ranguba/chupatext [master] * prereq.mk (prereq-recursive): am__cd may not be single command. Message-ID: <20100924010100.AF44E170EB4@taiyaki.ru> Nobuyoshi Nakada 2010-09-24 00:59:06 +0000 (Fri, 24 Sep 2010) New Revision: b64b68762829e48cab9dd570c560a0f7b6829374 Log: * prereq.mk (prereq-recursive): am__cd may not be single command. Modified files: prereq.mk Modified: prereq.mk (+7 -5) =================================================================== --- prereq.mk 2010-09-23 10:36:56 +0000 (56f9b2e) +++ prereq.mk 2010-09-24 00:59:06 +0000 (8ee9afa) @@ -1,8 +1,10 @@ #!/usr/bin/make -f +prereq: + GIT = git -up: pull update-version.h chupatext/module_list.h +up: pull prereq pull: @cd "$(srcdir)" && $(GIT) pull @@ -13,8 +15,8 @@ prereq-local: update-version.h prereq-recursive: @local_target=`echo $@ | sed s/-recursive//`; \ - top=$(top_srcdir) cd=$(am__cd); \ - : "$${top:=.}" "$${cd:=cd}"; \ + top="$(top_srcdir)"; \ + : "$${top:=.}"; \ set dummy $(SUBDIRS); shift; \ if test $$# = 0; then \ set dummy `ls */prereq.mk 2> /dev/null | sed 's/\/prereq\.mk$$//'`; \ @@ -22,7 +24,7 @@ prereq-recursive: fi; \ for subdir do \ test -f "$$top/$$subdir/prereq.mk" || continue; \ - ($$cd $$subdir && \ + (if test -z "$(am__cd)"; then cd $$subdir; else $(am__cd) $$subdir; fi && \ if test -f Makefile; then \ exec $(MAKE) $(AM_MAKEFLAGS) $$local_target; \ else \ @@ -34,4 +36,4 @@ update-version.h: @cd "$(top_srcdir)" && \ $(SHELL) ./tool/version-update.sh chupatext/version.h -.PHONY: update-version.h +.PHONY: update-version.h prereq-local prereq-recursive From null+ranguba at clear-code.com Thu Sep 23 21:48:55 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Fri, 24 Sep 2010 01:48:55 +0000 Subject: [groonga-commit:1306] ranguba/chupatext [master] * test/test_external_decomposer.c: test for long lines. Message-ID: <20100924015113.61B891704C0@taiyaki.ru> Nobuyoshi Nakada 2010-09-24 01:48:55 +0000 (Fri, 24 Sep 2010) New Revision: 826f6c018d55dca023bb0451ab25e3bedd46b949 Log: * test/test_external_decomposer.c: test for long lines. Modified files: test/test_external_decomposer.c Modified: test/test_external_decomposer.c (+12 -3) =================================================================== --- test/test_external_decomposer.c 2010-09-24 00:59:06 +0000 (ad93247) +++ test/test_external_decomposer.c 2010-09-24 01:48:55 +0000 (f4520d5) @@ -35,15 +35,24 @@ struct _ChupaTestExternalDecomposerClass G_DEFINE_TYPE(ChupaTestExternalDecomposer, chupa_test_external_decomposer, CHUPA_TYPE_EXTERNAL_DECOMPOSER) -static const char plain_text[] = "plain text\n"; +#define A_LINE "abcdefghijklmnopqrstuvwxyz-0123456789" +#define DOUBLE(x) x x +#define LONG_LINE DOUBLE(DOUBLE(DOUBLE(DOUBLE(A_LINE)))) +static const char plain_text[] = "plain text\n" + "foo bar\n" + "\fzot\n" + DOUBLE(DOUBLE(DOUBLE(LONG_LINE "\n"))) + ; static gboolean testdec_spawn(ChupaExternalDecomposer *dec, ChupaText *chupar, GOutputStream **stdinput, GInputStream **stdoutput, GError **error) { - *stdoutput = g_memory_input_stream_new_from_data(plain_text, sizeof(plain_text) - 1, NULL); - return TRUE; + gchar *argv[2]; + argv[0] = "cat"; + argv[1] = NULL; + return chupa_external_decomposer_spawn(dec, argv, stdinput, stdoutput, error); } static void From null+ranguba at clear-code.com Fri Sep 24 02:10:36 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Fri, 24 Sep 2010 06:10:36 +0000 Subject: [groonga-commit:1307] ranguba/chupatext [master] * module/chupa_msexcel.c: added. Message-ID: <20100924061122.E82041704C0@taiyaki.ru> Nobuyoshi Nakada 2010-09-24 06:10:36 +0000 (Fri, 24 Sep 2010) New Revision: cac97a3b88bea610bece4e4693e546bc95608b4a Log: * module/chupa_msexcel.c: added. Added files: module/chupa_msexcel.c module/msexcel/command-context-stderr.h module/msexcel/gnumeric.h module/msexcel/workbook-view.h test/test_msexcel.c Modified files: configure.ac module/Makefile.am test/Makefile.am Modified: configure.ac (+2 -0) =================================================================== --- configure.ac 2010-09-24 01:48:55 +0000 (e5b6e70) +++ configure.ac 2010-09-24 06:10:36 +0000 (f27775f) @@ -62,6 +62,8 @@ PKG_CHECK_MODULES(POPPLER_GLIB, poppler-glib, [have_poppler=yes], [:]) AM_CONDITIONAL([HAVE_POPPLER_GLIB], [test "$have_poppler" = "yes"]) PKG_CHECK_MODULES(WV, wv-1.0, [have_wv=yes], [:]) AM_CONDITIONAL([HAVE_WV], [test "$have_wv" = "yes"]) +PKG_CHECK_MODULES(GOFFICE, libgoffice-0.8, [have_goffice=yes], [:]) +AM_CONDITIONAL([HAVE_GOFFICE], [test "$have_goffice" = "yes"]) dnl ************************************************************** dnl Check for Cutter Modified: module/Makefile.am (+8 -0) =================================================================== --- module/Makefile.am 2010-09-24 01:48:55 +0000 (b08ea9b) +++ module/Makefile.am 2010-09-24 06:10:36 +0000 (58eb5ea) @@ -14,6 +14,9 @@ endif if HAVE_WV module_LTLIBRARIES += chupa_msword.la endif +if HAVE_GOFFICE +module_LTLIBRARIES += chupa_msexcel.la +endif module_LTLIBRARIES += chupa_mspowerpoint.la chupa_tar_la_SOURCES = chupa_tar.c @@ -36,6 +39,11 @@ chupa_msword_la_LDFLAGS = -module chupa_msword_la_CPPFLAGS = $(WV_CFLAGS) chupa_msword_la_LIBADD = $(WV_LIBS) $(GSF_LIBS) +chupa_msexcel_la_SOURCES = chupa_msexcel.c +chupa_msexcel_la_LDFLAGS = -module +chupa_msexcel_la_CPPFLAGS = -I$(srcdir)/msexcel $(GOFFICE_CFLAGS) +chupa_msexcel_la_LIBADD = $(GOFFICE_LIBS) -lspreadsheet + chupa_mspowerpoint_la_SOURCES = chupa_mspowerpoint.c chupa_mspowerpoint_la_LDFLAGS = -module chupa_mspowerpoint_la_CPPFLAGS = $(GSF_CFLAGS) Added: module/chupa_msexcel.c (+226 -0) 100644 =================================================================== --- /dev/null +++ module/chupa_msexcel.c 2010-09-24 06:10:36 +0000 (5a9ea8e) @@ -0,0 +1,226 @@ +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Copyright (C) 2010 Nobuyoshi Nakada + */ + +#include +#include +#include +#include +#include +#include "workbook-view.h" +#include "command-context-stderr.h" + +#define CHUPA_TYPE_EXCEL_DECOMPOSER chupa_type_excel_decomposer +#define CHUPA_EXCEL_DECOMPOSER(obj) \ + G_TYPE_CHECK_INSTANCE_CAST(obj, CHUPA_TYPE_EXCEL_DECOMPOSER, ChupaExcelDecomposer) +#define CHUPA_EXCEL_DECOMPOSER_CLASS(klass) \ + G_TYPE_CHECK_CLASS_CAST(klass, CHUPA_TYPE_EXCEL_DECOMPOSER, ChupaExcelDecomposerClass) +#define CHUPA_IS_EXCEL_DECOMPOSER(obj) \ + G_TYPE_CHECK_INSTANCE_TYPE(obj, CHUPA_TYPE_EXCEL_DECOMPOSER) +#define CHUPA_IS_EXCEL_DECOMPOSER_CLASS(klass) \ + G_TYPE_CHECK_CLASS_TYPE(klass, CHUPA_TYPE_EXCEL_DECOMPOSER) +#define CHUPA_EXCEL_DECOMPOSER_GET_CLASS(obj) \ + G_TYPE_INSTANCE_GET_CLASS(obj, CHUPA_TYPE_EXCEL_DECOMPOSER, ChupaExcelDecomposerClass) + +typedef struct _ChupaExcelDecomposer ChupaExcelDecomposer; +typedef struct _ChupaExcelDecomposerClass ChupaExcelDecomposerClass; + +struct _ChupaExcelDecomposer +{ + ChupaExternalDecomposer parent_object; + GOCmdContext *cc; +}; + +struct _ChupaExcelDecomposerClass +{ + ChupaExternalDecomposerClass parent_class; +}; + +static GType chupa_type_excel_decomposer = 0; + +#define CHUPA_TYPE_TUNNEL_STREAM chupa_tunnel_stream_get_type() +#define CHUPA_TUNNEL_STREAM(obj) \ + G_TYPE_CHECK_INSTANCE_CAST(obj, CHUPA_TYPE_TUNNEL_STREAM, ChupaTunnelStream) +#define CHUPA_TUNNEL_STREAM_CLASS(klass) \ + G_TYPE_CHECK_CLASS_CAST(klass, CHUPA_TYPE_TUNNEL_STREAM, ChupaTunnelStreamClass) +#define CHUPA_IS_TUNNEL_STREAM(obj) \ + G_TYPE_CHECK_INSTANCE_TYPE(obj, CHUPA_TYPE_TUNNEL_STREAM) +#define CHUPA_IS_TUNNEL_STREAM_CLASS(klass) \ + G_TYPE_CHECK_CLASS_TYPE(klass, CHUPA_TYPE_TUNNEL_STREAM) +#define CHUPA_TUNNEL_STREAM_GET_CLASS(obj) \ + G_TYPE_INSTANCE_GET_CLASS(obj, CHUPA_TYPE_TUNNEL_STREAM, ChupaTunnelStreamClass) + +typedef struct _ChupaTunnelStream ChupaTunnelStream; +typedef struct _ChupaTunnelStreamClass ChupaTunnelStreamClass; + +struct _ChupaTunnelStream +{ + GMemoryInputStream parent_object; + GsfOutputMemory *source; +}; + +struct _ChupaTunnelStreamClass +{ + GMemoryInputStreamClass parent_class; +}; + +G_DEFINE_TYPE(ChupaTunnelStream, chupa_tunnel_stream, G_TYPE_MEMORY_INPUT_STREAM) + +static void +tunnel_dispose(GObject *object) +{ + ChupaTunnelStream *stream = CHUPA_TUNNEL_STREAM(object); + + if (stream->source) { + g_object_unref(stream->source); + stream->source = NULL; + } + + G_OBJECT_CLASS(chupa_tunnel_stream_parent_class)->dispose(object); +} + +static void +chupa_tunnel_stream_init(ChupaTunnelStream *stream) +{ + stream->source = NULL; +} + +static void +chupa_tunnel_stream_class_init(ChupaTunnelStreamClass *klass) +{ + GObjectClass *gobject_class = G_OBJECT_CLASS(klass); + gobject_class->dispose = tunnel_dispose; +} + +static GInputStream * +chupa_tunnel_stream_new(GsfOutputMemory *mem) +{ + ChupaTunnelStream *stream = g_object_new(CHUPA_TYPE_TUNNEL_STREAM, NULL); + GsfOutput *out = GSF_OUTPUT(mem); + + g_object_ref(mem); + stream->source = mem; + g_memory_input_stream_add_data(G_MEMORY_INPUT_STREAM(stream), + gsf_output_memory_get_bytes(mem), + gsf_output_size(out), NULL); + return G_INPUT_STREAM(stream); +} + +static const char export_id[] = "Gnumeric_stf:stf_csv"; + +static gboolean +chupa_msword_decomposer_feed(ChupaDecomposer *dec, ChupaText *chupar, + ChupaTextInput *input, GError **err) +{ + ChupaExcelDecomposer *xlsdec = CHUPA_EXCEL_DECOMPOSER(dec); + GOFileSaver *fs = NULL; + GOIOContext *io_context = go_io_context_new(xlsdec->cc); + WorkbookView *wbv = NULL; + GsfOutput *tmpout; + GInputStream *tmpinp; + + fs = go_file_saver_for_id(export_id); + g_return_val_if_fail(fs, FALSE); + tmpout = gsf_output_memory_new(); + g_return_val_if_fail(tmpout, FALSE); + wbv = wb_view_new_from_input(chupa_text_input_get_base_input(input), + NULL, NULL, io_context, NULL); + g_return_val_if_fail(wbv, FALSE); + + wbv_save_to_output(wbv, fs, tmpout, io_context); + g_object_unref(wbv); + if (go_io_error_occurred(io_context)) { + g_object_unref(io_context); + g_object_unref(tmpout); + return FALSE; + } + + tmpinp = chupa_tunnel_stream_new(GSF_OUTPUT_MEMORY(tmpout)); + g_object_unref(io_context); + g_object_unref(tmpout); + input = chupa_text_input_new_from_stream(NULL, tmpinp, chupa_text_input_get_filename(input)); + g_object_unref(tmpinp); + chupa_text_decomposed(chupar, input); + return TRUE; +} + +static void +chupa_excel_decomposer_init(ChupaExcelDecomposer *dec) +{ + dec->cc = NULL; +} + +static void +chupa_excel_constructed(GObject *object) +{ + ChupaExcelDecomposer *dec = CHUPA_EXCEL_DECOMPOSER(object); + dec->cc = cmd_context_stderr_new(); + gnm_plugins_init(GO_CMD_CONTEXT(dec->cc)); +} + +static void +chupa_excel_decomposer_class_init(ChupaExcelDecomposerClass *klass) +{ + GObjectClass *gobject_class = G_OBJECT_CLASS(klass); + ChupaDecomposerClass *dec_class = CHUPA_DECOMPOSER_CLASS(klass); + gobject_class->constructed = chupa_excel_constructed; + dec_class->feed = chupa_msword_decomposer_feed; +} + +static GType +register_type(GTypeModule *type_module) +{ + static const GTypeInfo info = { + sizeof(ChupaExcelDecomposerClass), + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) chupa_excel_decomposer_class_init, + NULL, /* class_finalize */ + NULL, /* class_data */ + sizeof(ChupaExcelDecomposer), + 0, + (GInstanceInitFunc) NULL, + }; + GType type = chupa_type_excel_decomposer; + + if (!type) { + type = g_type_module_register_type(type_module, + CHUPA_TYPE_EXTERNAL_DECOMPOSER, + "ChupaExcelDecomposer", + &info, 0); + chupa_type_excel_decomposer = type; + chupa_decomposer_register("application/vnd.ms-excel", type); + } + return type; +} + +G_MODULE_EXPORT GList * +CHUPA_MODULE_IMPL_INIT(GTypeModule *type_module) +{ + GType type = register_type(type_module); + GList *registered_types = NULL; + + gnm_conf_init(); +#if 0 + if (type) { + registered_types = + g_list_prepend(registered_types, + (gchar *)g_type_name(type)); + } +#endif + + return registered_types; +} + +G_MODULE_EXPORT void +CHUPA_MODULE_IMPL_EXIT(void) +{ +} + +G_MODULE_EXPORT GObject * +CHUPA_MODULE_IMPL_INSTANTIATE(const gchar *first_property, va_list var_args) +{ + return g_object_new_valist(CHUPA_TYPE_EXCEL_DECOMPOSER, + first_property, var_args); +} Added: module/msexcel/command-context-stderr.h (+23 -0) 100644 =================================================================== --- /dev/null +++ module/msexcel/command-context-stderr.h 2010-09-24 06:10:36 +0000 (28ce4bd) @@ -0,0 +1,23 @@ +/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +#ifndef _GNM_COMMAND_CONTEXT_STDERR_H_ +# define _GNM_COMMAND_CONTEXT_STDERR_H_ + +#include "gnumeric.h" +#include + +G_BEGIN_DECLS + +#define CMD_CONTEXT_STDERR_TYPE (cmd_context_stderr_get_type ()) +#define COMMAND_CONTEXT_STDERR(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), CMD_CONTEXT_STDERR_TYPE, CmdContextStderr)) +#define IS_COMMAND_CONTEXT_STDERR(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), CMD_CONTEXT_STDERR_TYPE)) + +typedef struct _CmdContextStderr CmdContextStderr; + +GType cmd_context_stderr_get_type (void); +GOCmdContext *cmd_context_stderr_new (void); +void cmd_context_stderr_set_status (CmdContextStderr *ccs, int status); +int cmd_context_stderr_get_status (CmdContextStderr *ccs); + +G_END_DECLS + +#endif /* _GNM_COMMAND_CONTEXT_STDERR_H_ */ Added: module/msexcel/gnumeric.h (+200 -0) 100644 =================================================================== --- /dev/null +++ module/msexcel/gnumeric.h 2010-09-24 06:10:36 +0000 (9713e55) @@ -0,0 +1,200 @@ +/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +#ifndef _GNM_GNUMERIC_H_ +# define _GNM_GNUMERIC_H_ + +#include +#include + +G_BEGIN_DECLS + +/* Individual maxima for the dimensions. See also gnm_sheet_valid_size. */ +#define GNM_MAX_ROWS 0x1000000 +#define GNM_MAX_COLS 0x4000 + +/* Standard size */ +#define GNM_DEFAULT_COLS 0x100 +#define GNM_DEFAULT_ROWS 0x10000 + +/* Minimum size. dependent.c sets row constraint. */ +#define GNM_MIN_ROWS 0x80 +#define GNM_MIN_COLS 0x80 + +/* + * Note: more than 364238 columns will introduce a column named TRUE. + */ + +typedef struct _GnmApp GnmApp; +typedef struct _Workbook Workbook; +typedef struct _WorkbookView WorkbookView; +typedef struct _WorkbookControl WorkbookControl; +typedef struct _WorkbookSheetState WorkbookSheetState; + +typedef enum { + GNM_SHEET_VISIBILITY_VISIBLE, + GNM_SHEET_VISIBILITY_HIDDEN, + GNM_SHEET_VISIBILITY_VERY_HIDDEN +} GnmSheetVisibility; +typedef enum { + GNM_SHEET_DATA, + GNM_SHEET_OBJECT, + GNM_SHEET_XLM +} GnmSheetType; + +typedef struct _Sheet Sheet; +typedef struct _SheetView SheetView; +typedef struct _SheetControl SheetControl; + +typedef struct _SheetObject SheetObject; +typedef struct _SheetObjectAnchor SheetObjectAnchor; +typedef struct _SheetObjectView SheetObjectView; +typedef struct _SheetObjectViewContainer SheetObjectViewContainer; +typedef struct _SheetObjectImageableIface SheetObjectImageableIface; +typedef struct _SheetObjectExportableIface SheetObjectExportableIface; + +typedef struct _GnmDepContainer GnmDepContainer; +typedef struct _GnmDependent GnmDependent; +typedef struct _GnmCell GnmCell; +typedef struct _GnmComment GnmComment; + +typedef union _GnmValue GnmValue; +typedef struct _GnmValueBool GnmValueBool; +typedef struct _GnmValueFloat GnmValueFloat; +typedef struct _GnmValueErr GnmValueErr; +typedef struct _GnmValueStr GnmValueStr; +typedef struct _GnmValueRange GnmValueRange; +typedef struct _GnmValueArray GnmValueArray; + +typedef enum { + GNM_ERROR_NULL, + GNM_ERROR_DIV0, + GNM_ERROR_VALUE, + GNM_ERROR_REF, + GNM_ERROR_NAME, + GNM_ERROR_NUM, + GNM_ERROR_NA, + GNM_ERROR_UNKNOWN +} GnmStdError; + +typedef struct _GnmRenderedValue GnmRenderedValue; +typedef struct _GnmRenderedRotatedValue GnmRenderedRotatedValue; +typedef struct _GnmRenderedValueCollection GnmRenderedValueCollection; + +typedef GSList GnmExprList; +typedef union _GnmExpr GnmExpr; +typedef struct _GnmExprConstant GnmExprConstant; +typedef struct _GnmExprFunction GnmExprFunction; +typedef struct _GnmExprUnary GnmExprUnary; +typedef struct _GnmExprBinary GnmExprBinary; +typedef struct _GnmExprName GnmExprName; +typedef struct _GnmExprCellRef GnmExprCellRef; +typedef struct _GnmExprArrayCorner GnmExprArrayCorner; +typedef struct _GnmExprArrayElem GnmExprArrayElem; +typedef struct _GnmExprSet GnmExprSet; +typedef GnmExpr const * GnmExprConstPtr; + +typedef struct _GnmExprTop GnmExprTop; +typedef struct _GnmExprSharer GnmExprSharer; + +typedef struct _GnmExprRelocateInfo GnmExprRelocateInfo; + +typedef struct _GnmNamedExpr GnmNamedExpr; +typedef struct _GnmNamedExprCollection GnmNamedExprCollection; + +typedef struct _GnmPasteTarget GnmPasteTarget; +typedef struct _GnmCellRegion GnmCellRegion; + +typedef struct _ColRowInfo ColRowInfo; +typedef struct _ColRowCollection ColRowCollection; +typedef struct _ColRowSegment ColRowSegment; +typedef GSList ColRowVisList; +typedef GSList ColRowStateGroup; +typedef GSList ColRowStateList; +typedef GList ColRowIndexList; +typedef struct _ColRowIndexSet ColRowIndexSet; + +typedef struct _GnmFont GnmFont; +typedef struct _GnmFontMetrics GnmFontMetrics; +typedef struct _GnmColor GnmColor; +typedef struct _GnmBorder GnmBorder; +typedef struct _GnmStyle GnmStyle; +typedef struct _GnmStyleRow GnmStyleRow; +typedef GSList GnmStyleList; +typedef struct _GnmStyleRegion GnmStyleRegion; +typedef struct _GnmStyleConditions GnmStyleConditions; +typedef struct _GnmSheetStyleData GnmSheetStyleData; +typedef struct _GnmFormatTemplate GnmFormatTemplate; /* does not really belong here */ + +typedef struct { + int col, row; /* these must be int not unsigned in some places (eg SUMIF ) */ +} GnmCellPos; +typedef struct { + GnmCellPos start, end; +} GnmRange; +typedef struct { + Sheet *sheet; + GnmRange range; +} GnmSheetRange; +typedef struct _GnmCellRef GnmCellRef; /* abs/rel point with sheet */ +typedef struct _GnmRangeRef GnmRangeRef; /* abs/rel range with sheet */ +typedef struct _GnmEvalPos GnmEvalPos; +typedef struct _GnmParsePos GnmParsePos; +typedef struct _GnmSheetSize GnmSheetSize; +typedef struct _GnmParseError GnmParseError; +typedef struct _GnmConventions GnmConventions; +typedef struct _GnmConventionsOut GnmConventionsOut; +typedef struct _GnmFuncEvalInfo GnmFuncEvalInfo; +typedef struct _GnmFunc GnmFunc; +typedef struct _GnmFuncGroup GnmFuncGroup; +typedef struct _GnmFuncDescriptor GnmFuncDescriptor; +typedef struct _GnmAction GnmAction; + +typedef enum { + CELL_ITER_ALL = 0, + CELL_ITER_IGNORE_NONEXISTENT = 1 << 0, + CELL_ITER_IGNORE_EMPTY = 1 << 1, + CELL_ITER_IGNORE_BLANK = (CELL_ITER_IGNORE_NONEXISTENT | CELL_ITER_IGNORE_EMPTY), + CELL_ITER_IGNORE_HIDDEN = 1 << 2, /* hidden manually */ + + /* contains SUBTOTAL, or hidden row in a filter */ + CELL_ITER_IGNORE_SUBTOTAL = 1 << 3 +} CellIterFlags; +typedef struct _GnmCellIter GnmCellIter; +typedef GnmValue *(*CellIterFunc) (GnmCellIter const *iter, gpointer user); + +typedef enum { + GNM_SPANCALC_SIMPLE = 0x0, /* Just calc spans */ + GNM_SPANCALC_RESIZE = 0x1, /* Calculate sizes of all cells */ + GNM_SPANCALC_RE_RENDER = 0x2, /* Render and Size all cells */ + GNM_SPANCALC_RENDER = 0x4, /* Render and Size any unrendered cells */ + GNM_SPANCALC_ROW_HEIGHT = 0x8 /* Resize the row height */ +} GnmSpanCalcFlags; + +typedef enum { + GNM_EXPR_EVAL_SCALAR_NON_EMPTY = 0, + GNM_EXPR_EVAL_PERMIT_NON_SCALAR = 0x1, + GNM_EXPR_EVAL_PERMIT_EMPTY = 0x2 +} GnmExprEvalFlags; + +typedef struct _XmlParseContext XmlParseContext; + +typedef struct _GnmSortData GnmSortData; +typedef struct _GnmSearchReplace GnmSearchReplace; +typedef struct _GnmConsolidate GnmConsolidate; +typedef struct _GnmValidation GnmValidation; +typedef struct _GnmFilter GnmFilter; +typedef struct _GnmFilterCondition GnmFilterCondition; +typedef struct _GnmHLink GnmHLink; +typedef struct _GnmInputMsg GnmInputMsg; +typedef struct _GnmSheetSlicer GnmSheetSlicer; + +typedef struct _PrintInformation PrintInformation; + +typedef struct GnmSolverParameters_ GnmSolverParameters; +typedef struct GnmSolverConstraint_ GnmSolverConstraint; +typedef struct GnmSolverFactory_ GnmSolverFactory; + +typedef struct GnmScenario_ GnmScenario; + +G_END_DECLS + +#endif /* _GNM_GNUMERIC_H_ */ Added: module/msexcel/workbook-view.h (+120 -0) 100644 =================================================================== --- /dev/null +++ module/msexcel/workbook-view.h 2010-09-24 06:10:36 +0000 (0c3e786) @@ -0,0 +1,120 @@ +/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +#ifndef _GNM_WORKBOOK_VIEW_H_ +# define _GNM_WORKBOOK_VIEW_H_ + +#include "gnumeric.h" +#include +#include + +G_BEGIN_DECLS + +struct _WorkbookView { + GObject base; + + Workbook *wb; + GPtrArray *wb_controls; + + Sheet *current_sheet; /* convenience */ + SheetView *current_sheet_view; + + /* preferences */ + gboolean show_horizontal_scrollbar; + gboolean show_vertical_scrollbar; + gboolean show_notebook_tabs; + gboolean show_function_cell_markers; + gboolean do_auto_completion; + gboolean is_protected; + + /* Non-normative size information */ + int preferred_width, preferred_height; + + /* The auto-expression */ + GnmFunc *auto_expr_func; + char *auto_expr_descr; + char *auto_expr_text; + PangoAttrList *auto_expr_attrs; + gboolean auto_expr_use_max_precision; + + /* selection */ + char *selection_description; + + /* Style for feedback */ + GnmStyle const *current_style; + SheetObject *in_cell_combo; /* validation or data slicer */ +}; + +typedef struct { + GObjectClass gtk_object_class; + void (*sheet_entered) (Sheet *sheet); +} WorkbookViewClass; + +#define WORKBOOK_VIEW_TYPE (workbook_view_get_type ()) +#define WORKBOOK_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), WORKBOOK_VIEW_TYPE, WorkbookView)) +#define WORKBOOK_VIEW_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), WORKBOOK_VIEW_TYPE, WorkbookViewClass)) +#define IS_WORKBOOK_VIEW(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), WORKBOOK_VIEW_TYPE)) + +/* Lifecycle */ +GType workbook_view_get_type (void); +WorkbookView *workbook_view_new (Workbook *optional_workbook); +void wb_view_attach_control (WorkbookView *wbv, WorkbookControl *wbc); +void wb_view_detach_control (WorkbookControl *wbc); +void wb_view_detach_from_workbook (WorkbookView *wbv); + +/* Information */ +GODoc *wb_view_get_doc (WorkbookView const *wbv); +Workbook *wb_view_get_workbook (WorkbookView const *wbv); +int wb_view_get_index_in_wb (WorkbookView const *wbv); +Sheet *wb_view_cur_sheet (WorkbookView const *wbv); +SheetView *wb_view_cur_sheet_view (WorkbookView const *wbv); +void wb_view_sheet_focus (WorkbookView *wbv, Sheet *sheet); +void wb_view_sheet_add (WorkbookView *wbv, Sheet *new_sheet); +gboolean wb_view_is_protected (WorkbookView *wbv, gboolean check_sheet); + +/* Manipulation */ +void wb_view_set_attribute (WorkbookView *wbv, char const *name, + char const *value); +void wb_view_preferred_size (WorkbookView *wbv, + int w_pixels, int h_pixels); +void wb_view_style_feedback (WorkbookView *wbv); +void wb_view_menus_update (WorkbookView *wbv); +void wb_view_selection_desc (WorkbookView *wbv, gboolean use_pos, + WorkbookControl *optional_wbc); +void wb_view_edit_line_set (WorkbookView *wbv, + WorkbookControl *optional_wbc); +void wb_view_auto_expr_recalc (WorkbookView *wbv); + +/* I/O routines */ +gboolean wb_view_save_as (WorkbookView *wbv, GOFileSaver *fs, + char const *file_name, GOCmdContext *cc); +gboolean wb_view_save (WorkbookView *wbv, GOCmdContext *cc); +void wbv_save_to_output (WorkbookView *wbv, GOFileSaver const *fs, + GsfOutput *output, GOIOContext *io_context); +void wb_view_save_to_uri (WorkbookView *wbv, GOFileSaver const *fs, + char const *uri, GOIOContext *io_context); + +WorkbookView *wb_view_new_from_input (GsfInput *input, + const char *optional_uri, + GOFileOpener const *optional_format, + GOIOContext *io_context, + gchar const *optional_encoding); +WorkbookView *wb_view_new_from_uri (char const *uri, + GOFileOpener const *optional_format, + GOIOContext *io_context, + gchar const *optional_encoding); + +#define WORKBOOK_VIEW_FOREACH_CONTROL(wbv, control, code) \ +do { \ + int jNd; \ + GPtrArray *wb_controls = (wbv)->wb_controls; \ + if (wb_controls != NULL) /* Reverse is important during destruction */ \ + for (jNd = wb_controls->len; jNd-- > 0 ;) { \ + WorkbookControl *control = \ + g_ptr_array_index (wb_controls, jNd); \ + code \ + } \ +} while (0) + + +G_END_DECLS + +#endif /* _GNM_WORKBOOK_VIEW_H_ */ Modified: test/Makefile.am (+4 -0) =================================================================== --- test/Makefile.am 2010-09-24 01:48:55 +0000 (6e55535) +++ test/Makefile.am 2010-09-24 06:10:36 +0000 (903733f) @@ -24,6 +24,9 @@ endif if HAVE_WV noinst_LTLIBRARIES += test_msword.la endif +if HAVE_GOFFICE +noinst_LTLIBRARIES += test_msexcel.la +endif noinst_LTLIBRARIES += test_mspowerpoint.la endif @@ -65,6 +68,7 @@ test_external_decomposer_la_SOURCES = test_external_decomposer.c chupa_test_util test_restrict_input_stream_la_SOURCES = test_restrict_input_stream.c test_pdf_la_SOURCES = test_pdf.c chupa_test_util.c test_msword_la_SOURCES = test_msword.c chupa_test_util.c +test_msexcel_la_SOURCES = test_msexcel.c chupa_test_util.c test_mspowerpoint_la_SOURCES = test_mspowerpoint.c chupa_test_util.c test_tar_la_SOURCES = test_tar.c chupa_test_util.c test_zip_la_SOURCES = test_zip.c chupa_test_util.c Added: test/test_msexcel.c (+26 -0) 100644 =================================================================== --- /dev/null +++ test/test_msexcel.c 2010-09-24 06:10:36 +0000 (2237b04) @@ -0,0 +1,26 @@ +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Copyright (C) 2010 Nobuyoshi Nakada + */ + +#include "chupa_test_util.h" + +void +setup(void) +{ + chupa_test_setup(); +} + +void +teardown(void) +{ + chupa_test_teardown(); +} + +#define decompose_fixture chupa_test_decompose_fixture + +void +test_decompose_msexcel(void) +{ + cut_assert_equal_string("Sample\n\n", decompose_fixture("sample.xls", NULL)); +} From null+ranguba at clear-code.com Fri Sep 24 02:26:15 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Fri, 24 Sep 2010 06:26:15 +0000 Subject: [groonga-commit:1308] ranguba/chupatext [master] * module/chupa_msexcel.c (CHUPA_MODULE_IMPL_INIT): initialize gnumeric. Message-ID: <20100924062628.B0C691704C0@taiyaki.ru> Nobuyoshi Nakada 2010-09-24 06:26:15 +0000 (Fri, 24 Sep 2010) New Revision: 893103c784f87760e6d7725bca47bd900b7ddd8e Log: * module/chupa_msexcel.c (CHUPA_MODULE_IMPL_INIT): initialize gnumeric. Modified files: module/chupa_msexcel.c Modified: module/chupa_msexcel.c (+1 -0) =================================================================== --- module/chupa_msexcel.c 2010-09-24 06:10:36 +0000 (5a9ea8e) +++ module/chupa_msexcel.c 2010-09-24 06:26:15 +0000 (d7c84c8) @@ -201,6 +201,7 @@ CHUPA_MODULE_IMPL_INIT(GTypeModule *type_module) GType type = register_type(type_module); GList *registered_types = NULL; + gnm_init (); gnm_conf_init(); #if 0 if (type) { From null+ranguba at clear-code.com Fri Sep 24 03:04:14 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Fri, 24 Sep 2010 07:04:14 +0000 Subject: [groonga-commit:1309] ranguba/chupatext [master] * test/test_msexcel.c: add fixtures. Message-ID: <20100924070431.67A971704C0@taiyaki.ru> Nobuyoshi Nakada 2010-09-24 07:04:14 +0000 (Fri, 24 Sep 2010) New Revision: fd45e39123df03d0fa6504b8472e2310ce4a2ac4 Log: * test/test_msexcel.c: add fixtures. Added files: test/fixtures/sample.xls test/fixtures/sample_2007.xlsx Modified files: test/test_msexcel.c Added: test/fixtures/sample.xls (+0 -0) 100644 =================================================================== (Binary files differ) Added: test/fixtures/sample_2007.xlsx (+0 -0) 100644 =================================================================== (Binary files differ) Modified: test/test_msexcel.c (+6 -0) =================================================================== --- test/test_msexcel.c 2010-09-24 06:26:15 +0000 (2237b04) +++ test/test_msexcel.c 2010-09-24 07:04:14 +0000 (4cc823d) @@ -24,3 +24,9 @@ test_decompose_msexcel(void) { cut_assert_equal_string("Sample\n\n", decompose_fixture("sample.xls", NULL)); } + +void +test_decompose_msexcel_2007(void) +{ + cut_assert_equal_string("Sample\n\n", decompose_fixture("sample_2007.xlsx", NULL)); +} From null+ranguba at clear-code.com Fri Sep 24 03:05:09 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Fri, 24 Sep 2010 07:05:09 +0000 Subject: [groonga-commit:1310] ranguba/chupatext [master] * module/chupa_msexcel.c: fix initialization. Message-ID: <20100924070548.D3E5B1704C0@taiyaki.ru> Nobuyoshi Nakada 2010-09-24 07:05:09 +0000 (Fri, 24 Sep 2010) New Revision: 06bfbabb27bbcc9d484d484faa64ca9f1d19389f Log: * module/chupa_msexcel.c: fix initialization. Modified files: module/chupa_msexcel.c Modified: module/chupa_msexcel.c (+21 -7) =================================================================== --- module/chupa_msexcel.c 2010-09-24 07:04:14 +0000 (d7c84c8) +++ module/chupa_msexcel.c 2010-09-24 07:05:09 +0000 (cf31060) @@ -29,7 +29,6 @@ typedef struct _ChupaExcelDecomposerClass ChupaExcelDecomposerClass; struct _ChupaExcelDecomposer { ChupaExternalDecomposer parent_object; - GOCmdContext *cc; }; struct _ChupaExcelDecomposerClass @@ -37,6 +36,7 @@ struct _ChupaExcelDecomposerClass ChupaExternalDecomposerClass parent_class; }; +static GOCmdContext *cc; static GType chupa_type_excel_decomposer = 0; #define CHUPA_TYPE_TUNNEL_STREAM chupa_tunnel_stream_get_type() @@ -115,17 +115,24 @@ chupa_msword_decomposer_feed(ChupaDecomposer *dec, ChupaText *chupar, { ChupaExcelDecomposer *xlsdec = CHUPA_EXCEL_DECOMPOSER(dec); GOFileSaver *fs = NULL; - GOIOContext *io_context = go_io_context_new(xlsdec->cc); + GOFileOpener *fo = NULL; + GOIOContext *io_context = go_io_context_new(cc); WorkbookView *wbv = NULL; + GsfInput *source = chupa_text_input_get_base_input(input); GsfOutput *tmpout; GInputStream *tmpinp; + const char *filename = chupa_text_input_get_filename(input); fs = go_file_saver_for_id(export_id); g_return_val_if_fail(fs, FALSE); tmpout = gsf_output_memory_new(); g_return_val_if_fail(tmpout, FALSE); - wbv = wb_view_new_from_input(chupa_text_input_get_base_input(input), - NULL, NULL, io_context, NULL); + g_return_val_if_fail(!gsf_input_seek(source, 0, G_SEEK_SET), FALSE); + fo = go_file_opener_for_id("Gnumeric_Excel:excel"); + wbv = wb_view_new_from_input(source, filename, fo, io_context, NULL); + if (go_io_error_occurred(io_context)) { + go_io_error_display(io_context); + } g_return_val_if_fail(wbv, FALSE); wbv_save_to_output(wbv, fs, tmpout, io_context); @@ -148,15 +155,12 @@ chupa_msword_decomposer_feed(ChupaDecomposer *dec, ChupaText *chupar, static void chupa_excel_decomposer_init(ChupaExcelDecomposer *dec) { - dec->cc = NULL; } static void chupa_excel_constructed(GObject *object) { ChupaExcelDecomposer *dec = CHUPA_EXCEL_DECOMPOSER(object); - dec->cc = cmd_context_stderr_new(); - gnm_plugins_init(GO_CMD_CONTEXT(dec->cc)); } static void @@ -200,9 +204,19 @@ CHUPA_MODULE_IMPL_INIT(GTypeModule *type_module) { GType type = register_type(type_module); GList *registered_types = NULL; + GOErrorInfo *plugin_errs; gnm_init (); gnm_conf_init(); + cc = cmd_context_stderr_new(); + gnm_plugins_init(GO_CMD_CONTEXT(cc)); + go_plugin_db_activate_plugin_list(go_plugins_get_available_plugins(), &plugin_errs); + if (plugin_errs) { + fprintf(stderr, "go_plugin_db_activate_plugin_list failed\n"); + go_error_display(plugin_errs); + go_error_info_free(plugin_errs); + } + #if 0 if (type) { registered_types = From null+ranguba at clear-code.com Fri Sep 24 03:05:39 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Fri, 24 Sep 2010 07:05:39 +0000 Subject: [groonga-commit:1311] ranguba/chupatext [master] * test/run-test.sh (CUTTER_WRAPPER): run with strace if CUTTER_CHECK_STRACE is yes. Message-ID: <20100924070548.E3A97278001@taiyaki.ru> Nobuyoshi Nakada 2010-09-24 07:05:39 +0000 (Fri, 24 Sep 2010) New Revision: 808cc2fdf51e2150a4874a9cbef06f0097579831 Log: * test/run-test.sh (CUTTER_WRAPPER): run with strace if CUTTER_CHECK_STRACE is yes. Modified files: test/run-test.sh Modified: test/run-test.sh (+2 -0) =================================================================== --- test/run-test.sh 2010-09-24 07:05:09 +0000 (9760533) +++ test/run-test.sh 2010-09-24 07:05:39 +0000 (e26b977) @@ -51,6 +51,8 @@ elif test x"$CUTTER_CHECK_LEAK" = x"yes"; then CUTTER_WRAPPER="${LIBTOOL-$builddir/libtool} --mode=execute valgrind " CUTTER_WRAPPER="$CUTTER_WRAPPER --leak-check=full --show-reachable=yes -v" CUTTER_ARGS="--keep-opening-modules" +elif test x"$CUTTER_CHECK_STRACE" = x"yes"; then + CUTTER_WRAPPER="${LIBTOOL-$builddir/libtool} --mode=execute strace -o strace.out " fi export CUTTER From null+ranguba at clear-code.com Fri Sep 24 03:19:13 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Fri, 24 Sep 2010 07:19:13 +0000 Subject: [groonga-commit:1312] ranguba/chupatext [master] * module/chupa_msexcel.c (CHUPA_MODULE_IMPL_INIT): needs gnm_pre_parse_init. Message-ID: <20100924071923.19BE61704C0@taiyaki.ru> Nobuyoshi Nakada 2010-09-24 07:19:13 +0000 (Fri, 24 Sep 2010) New Revision: 70101eeb15ef700f2c8c59b207a5d4436b0bc32b Log: * module/chupa_msexcel.c (CHUPA_MODULE_IMPL_INIT): needs gnm_pre_parse_init. Modified files: module/chupa_msexcel.c Modified: module/chupa_msexcel.c (+4 -0) =================================================================== --- module/chupa_msexcel.c 2010-09-24 07:05:39 +0000 (cf31060) +++ module/chupa_msexcel.c 2010-09-24 07:19:13 +0000 (ebc374c) @@ -205,6 +205,10 @@ CHUPA_MODULE_IMPL_INIT(GTypeModule *type_module) GType type = register_type(type_module); GList *registered_types = NULL; GOErrorInfo *plugin_errs; + char *argv[2]; + + argv[0] = NULL; + gnm_pre_parse_init(0, argv); gnm_init (); gnm_conf_init(); From null+ranguba at clear-code.com Fri Sep 24 03:19:38 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Fri, 24 Sep 2010 07:19:38 +0000 Subject: [groonga-commit:1313] ranguba/chupatext [master] * test/test_msexcel.c (test_decompose_msexcel): fix expected string. Message-ID: <20100924071947.4DC0D1704C0@taiyaki.ru> Nobuyoshi Nakada 2010-09-24 07:19:38 +0000 (Fri, 24 Sep 2010) New Revision: adddcabfc15c642d40a51d54e079bf868097b83c Log: * test/test_msexcel.c (test_decompose_msexcel): fix expected string. Modified files: test/test_msexcel.c Modified: test/test_msexcel.c (+4 -2) =================================================================== --- test/test_msexcel.c 2010-09-24 07:19:13 +0000 (4cc823d) +++ test/test_msexcel.c 2010-09-24 07:19:38 +0000 (86867ea) @@ -22,11 +22,13 @@ teardown(void) void test_decompose_msexcel(void) { - cut_assert_equal_string("Sample\n\n", decompose_fixture("sample.xls", NULL)); + cut_assert_equal_string("sample\n", decompose_fixture("sample.xls", NULL)); } +#if 0 void test_decompose_msexcel_2007(void) { - cut_assert_equal_string("Sample\n\n", decompose_fixture("sample_2007.xlsx", NULL)); + cut_assert_equal_string("sample\n", decompose_fixture("sample_2007.xlsx", NULL)); } +#endif From null+ranguba at clear-code.com Fri Sep 24 04:04:24 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Fri, 24 Sep 2010 08:04:24 +0000 Subject: [groonga-commit:1314] ranguba/chupatext [master] * module/chupa_msexcel.c (register_type): add Excel 2007. Message-ID: <20100924080436.ECD581704C0@taiyaki.ru> Nobuyoshi Nakada 2010-09-24 08:04:24 +0000 (Fri, 24 Sep 2010) New Revision: baec659e3d1b94341c10e449910597aecc5c6435 Log: * module/chupa_msexcel.c (register_type): add Excel 2007. Modified files: module/chupa_msexcel.c test/test_msexcel.c Modified: module/chupa_msexcel.c (+1 -0) =================================================================== --- module/chupa_msexcel.c 2010-09-24 07:19:38 +0000 (ebc374c) +++ module/chupa_msexcel.c 2010-09-24 08:04:24 +0000 (85b6eb7) @@ -195,6 +195,7 @@ register_type(GTypeModule *type_module) &info, 0); chupa_type_excel_decomposer = type; chupa_decomposer_register("application/vnd.ms-excel", type); + chupa_decomposer_register("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", type); } return type; } Modified: test/test_msexcel.c (+0 -2) =================================================================== --- test/test_msexcel.c 2010-09-24 07:19:38 +0000 (86867ea) +++ test/test_msexcel.c 2010-09-24 08:04:24 +0000 (37a5d9e) @@ -25,10 +25,8 @@ test_decompose_msexcel(void) cut_assert_equal_string("sample\n", decompose_fixture("sample.xls", NULL)); } -#if 0 void test_decompose_msexcel_2007(void) { cut_assert_equal_string("sample\n", decompose_fixture("sample_2007.xlsx", NULL)); } -#endif From null+ranguba at clear-code.com Fri Sep 24 04:35:31 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Fri, 24 Sep 2010 08:35:31 +0000 Subject: [groonga-commit:1315] ranguba/chupatext [master] * module/chupa_msexcel.c (chupa_msword_decomposer_feed): suppress useless warnings. Message-ID: <20100924083542.714BA1704C0@taiyaki.ru> Nobuyoshi Nakada 2010-09-24 08:35:31 +0000 (Fri, 24 Sep 2010) New Revision: c718d197446fbb6d1e6839985f71ec9cf85f8ebf Log: * module/chupa_msexcel.c (chupa_msword_decomposer_feed): suppress useless warnings. Modified files: module/chupa_msexcel.c Modified: module/chupa_msexcel.c (+17 -1) =================================================================== --- module/chupa_msexcel.c 2010-09-24 08:04:24 +0000 (85b6eb7) +++ module/chupa_msexcel.c 2010-09-24 08:35:31 +0000 (1452d71) @@ -109,6 +109,17 @@ chupa_tunnel_stream_new(GsfOutputMemory *mem) static const char export_id[] = "Gnumeric_stf:stf_csv"; +static void +silent_printerr(const gchar *string) +{ +} + +static void +silent_log(const gchar *log_domain, GLogLevelFlags log_level, + const gchar *message, gpointer user_data) +{ +} + static gboolean chupa_msword_decomposer_feed(ChupaDecomposer *dec, ChupaText *chupar, ChupaTextInput *input, GError **err) @@ -122,14 +133,19 @@ chupa_msword_decomposer_feed(ChupaDecomposer *dec, ChupaText *chupar, GsfOutput *tmpout; GInputStream *tmpinp; const char *filename = chupa_text_input_get_filename(input); + GPrintFunc print_func; + guint loghandler; fs = go_file_saver_for_id(export_id); g_return_val_if_fail(fs, FALSE); tmpout = gsf_output_memory_new(); g_return_val_if_fail(tmpout, FALSE); g_return_val_if_fail(!gsf_input_seek(source, 0, G_SEEK_SET), FALSE); - fo = go_file_opener_for_id("Gnumeric_Excel:excel"); + print_func = g_set_printerr_handler(silent_printerr); + loghandler = g_log_set_handler(G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, silent_log, NULL); wbv = wb_view_new_from_input(source, filename, fo, io_context, NULL); + g_log_remove_handler(G_LOG_DOMAIN, loghandler); + g_set_printerr_handler(print_func); if (go_io_error_occurred(io_context)) { go_io_error_display(io_context); } From null+ranguba at clear-code.com Fri Sep 24 04:36:40 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Fri, 24 Sep 2010 08:36:40 +0000 Subject: [groonga-commit:1316] ranguba/chupatext [master] * test/test_msexcel.c (test_decompose_msexcel): include newlines. Message-ID: <20100924083649.0DF371704C0@taiyaki.ru> Nobuyoshi Nakada 2010-09-24 08:36:40 +0000 (Fri, 24 Sep 2010) New Revision: 5985309f25f9357175beb9c701f3515a67abe5c1 Log: * test/test_msexcel.c (test_decompose_msexcel): include newlines. Modified files: test/fixtures/sample.xls test/test_msexcel.c Modified: test/fixtures/sample.xls (+0 -0) =================================================================== (Binary files differ) Modified: test/test_msexcel.c (+1 -1) =================================================================== --- test/test_msexcel.c 2010-09-24 08:35:31 +0000 (37a5d9e) +++ test/test_msexcel.c 2010-09-24 08:36:40 +0000 (4a184c5) @@ -22,7 +22,7 @@ teardown(void) void test_decompose_msexcel(void) { - cut_assert_equal_string("sample\n", decompose_fixture("sample.xls", NULL)); + cut_assert_equal_string("sample\n1\n2\n3\n4\n5\n6\n7\n", decompose_fixture("sample.xls", NULL)); } void From null+ranguba at clear-code.com Fri Sep 24 05:51:08 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Fri, 24 Sep 2010 09:51:08 +0000 Subject: [groonga-commit:1317] ranguba/chupatext [master] * module/chupa_mspowerpoint.c: rewriting. Message-ID: <20100924095117.B7008278001@taiyaki.ru> Nobuyoshi Nakada 2010-09-24 09:51:08 +0000 (Fri, 24 Sep 2010) New Revision: 420a0e28b063afada33154b2ac3e7e6c8ab8ed5d Log: * module/chupa_mspowerpoint.c: rewriting. Modified files: module/chupa_mspowerpoint.c Modified: module/chupa_mspowerpoint.c (+186 -222) =================================================================== --- module/chupa_mspowerpoint.c 2010-09-24 09:50:49 +0000 (62a852a) +++ module/chupa_mspowerpoint.c 2010-09-24 09:51:08 +0000 (26fdda5) @@ -5,8 +5,11 @@ #include #include +#include #include +#include #include +#include #define CHUPA_TYPE_PPT_DECOMPOSER chupa_type_ppt_decomposer #define CHUPA_PPT_DECOMPOSER(obj) \ @@ -90,224 +93,200 @@ getulong(unsigned char *buffer, int offset) { return (unsigned long)buffer[offset] | ((unsigned long)buffer[offset+1]<<8) | ((unsigned long)buffer[offset+2]<<16) | ((unsigned long)buffer[offset+3]<<24); -} +} + +#define WORK_SIZE 128 + +struct PPT { + unsigned char working_buffer[WORK_SIZE]; + int buf_idx; + int output_this_container; + int past_first_slide; + int last_container; + GsfOutput *output; +}; -/** - * process_item: - * - * @param rectype - * @param reclen - * @param input - */ static void -process_item(ppt_item_type_t rectype, long reclen, - GDataInputStream* input, GMemoryInputStream *mem, - GError **err) +put_byte(struct PPT *ppt, unsigned char c) { - switch (rectype) { - case PPT_ITEM_DOCUMENT_END: - g_debug("End of document"); - g_input_stream_skip((GInputStream *)input, reclen, NULL, err); - break; + gsf_output_write(ppt->output, 1, &c); +} - case PPT_ITEM_DOCUMENT: - g_debug("Start of document, reclen=%ld", reclen); - break; +static void +put_utf8(struct PPT *ppt, unsigned short c) +{ + put_byte(ppt, 0x0080 | ((short)c & 0x003F)); +} - case PPT_ITEM_DOCUMENT_ATOM: - g_debug("DocumentAtom, reclen=%ld", reclen); - g_input_stream_skip((GInputStream *)input, reclen, NULL, err); - break; +static void +print_utf8(struct PPT *ppt, unsigned short c) +{ + if (c == 0) + return; + + if (c < 0x80) + put_byte(ppt, c); + else if (c < 0x800) { + put_byte(ppt, 0xC0 | (c >> 6)); + put_utf8(ppt, c); + } + else + { + put_byte(ppt, 0xE0 | (c >> 12)); + put_utf8(ppt, c >> 6); + put_utf8(ppt, c); + } +} - case PPT_ITEM_SLIDE: - g_debug("Slide, reclen=%ld" - "---------------------------------------", reclen); - break; +static void +print_unicode(struct PPT *ppt, unsigned char *ucs, int len) +{ + int i; + for (i = 0; i < len; i += 2) { + print_utf8(ppt, ucs[i] | (ucs[i+1] << 8)); + } +} - case PPT_ITEM_SLIDE_ATOM: - g_debug("SlideAtom, reclen=%ld", reclen); - g_input_stream_skip((GInputStream *)input, reclen, NULL, err); - break; - - case PPT_ITEM_SLIDE_BASE: - g_debug("SlideBase, reclen=%ld", reclen); +static void +container_processor(struct PPT *ppt, int type) +{ + if (type == 0x03EE) { + if (ppt->past_first_slide) { + put_byte(ppt, '\f'); + } + else { + ppt->past_first_slide = 1; + } + } + switch (type) { + case 0x000D: + if (ppt->last_container == 0x11) /* suppress notes info */ + ppt->output_this_container = 0; + else + ppt->output_this_container = 1; break; - - case PPT_ITEM_SLIDE_BASE_ATOM: - g_debug("SlideBaseAtom, reclen=%ld", reclen); - g_input_stream_skip((GInputStream *)input, reclen, NULL, err); + case 0x0FF0: + ppt->output_this_container = 1; break; - - case PPT_ITEM_NOTES: - g_debug("Notes, reclen=%ld", reclen); + default: + /* printf("Cont:%x|\n", type); */ + ppt->output_this_container = 0; break; + } + ppt->last_container = type; +} - case PPT_ITEM_NOTES_ATOM: - g_debug("NotesAtom, reclen=%ld", reclen); - g_input_stream_skip((GInputStream *)input, reclen, NULL, err); - break; - - case PPT_ITEM_HEADERS_FOOTERS: - g_debug("HeadersFooters, reclen=%ld", reclen); - break; +static void +atom_processor(struct PPT *ppt, int type, int count, int buf_last, unsigned char data) +{ + if ((ppt->buf_idx >= WORK_SIZE) || (ppt->output_this_container == 0)) + return; - case PPT_ITEM_HEADERS_FOOTERS_ATOM: - g_debug("HeadersFootersAtom, reclen=%ld", reclen); - g_input_stream_skip((GInputStream *)input, reclen, NULL, err); + if (count == 0) { + memset(ppt->working_buffer, 0, WORK_SIZE); + ppt->buf_idx = 0; + } + + switch (type) { + case 0x0FA0: /* Text String in unicode */ + ppt->working_buffer[ppt->buf_idx++] = data; + if (count == buf_last) { + /* printf("Atom:%x|\n", type); */ + /* working_buffer[buf_idx++] = 0; */ + /* printf("%s
\n", working_buffer); */ + print_unicode(ppt, ppt->working_buffer, ppt->buf_idx); + put_byte(ppt, '\n'); + } break; - - case PPT_ITEM_MAIN_MASTER: - g_debug("MainMaster, reclen=%ld", reclen); + case 0x0FA8: /* Text String in ASCII */ + if (data == '\r') { + data = '\n'; + } + ppt->working_buffer[ppt->buf_idx++] = data; + if (count == buf_last) { + int i; + /* ppt->working_buffer[ppt->buf_idx++] = 0; */ + /* printf("Atom:%x|\n", type); */ + gsf_output_write(ppt->output, ppt->buf_idx, ppt->working_buffer); + put_byte(ppt, '\n'); + } break; - - case PPT_ITEM_TEXT_BYTES_ATOM: { - gchar *buf; - gssize i, size; - - g_debug("TextBytes, reclen=%ld", reclen); - buf = g_malloc(reclen); - if (!g_input_stream_read_all((GInputStream *)input, buf, reclen, &size, NULL, err)) { - break; + case 0x0FBA: /* CString - unicode... */ + if (data == '\r') { + data = '\n'; } - for (i = 0; i < size; i++) { - if ((unsigned char)buf[i] == '\r') { - buf[i] = '\n'; - } + ppt->working_buffer[ppt->buf_idx++] = data; + if (count == buf_last) { + /* working_buffer[buf_idx++] = 0; */ + /* printf("%s
\n", working_buffer); */ + /* printf("Atom:%x|\n", type); */ + print_unicode(ppt, ppt->working_buffer, ppt->buf_idx); + put_byte(ppt, '\n'); } - g_memory_input_stream_add_data(mem, buf, size, g_free); + break; + default: break; } - - case PPT_ITEM_TEXT_CHARS_ATOM: - case PPT_ITEM_CSTRING: { - int u; - gsize size; - GString *str; +} - g_debug("CString, reclen=%ld", reclen); - size = reclen / 2; - str = g_string_sized_new(size); - while (size > 0) { - u = g_data_input_stream_read_uint16(input, NULL, err); - if (u == '\r') { - u = '\n'; +static gboolean +dump_file(struct PPT *ppt, GsfInput *inp) +{ + unsigned long version=0, instance=0, type=0, length=0, target=0, count=0; + unsigned char buf[16]; + + /* Output body */ + while (gsf_input_read(inp, 1, buf)) { + switch (count) { + case 0: + instance = buf[0]; + type = 0; + length = 0; + target = 80; /* ficticious number */ + break; + case 1: + instance |= (buf[0]<<8); + version = instance &0x000F; + instance = (instance>>4); + break; + case 2: + type = (unsigned)buf[0]; + break; + case 3: + type |= (buf[0]<<8)&0x00000FFFL; + break; + case 4: + length = (unsigned)buf[0]; + break; + case 5: + length |= (buf[0]<<8); + break; + case 6: + length |= (buf[0]<<16); + break; + case 7: + length |= (buf[0]<<24); + target = length; + if (version == 0x0F) { + /* Do container level Processing */ + container_processor(ppt, type); + count = -1; } - g_string_append_unichar(str, (gunichar)u); + break; } - size = str->len; - g_memory_input_stream_add_data(mem, g_string_free(str, FALSE), size, g_free); - break; + if (count > 7) { + /* Here is where we want to process the data + based on the Atom type... */ + atom_processor(ppt, type, count-8, target-1, buf[0]); + } + if (count == (target+7)) + count = 0; + else + count++; } - - case PPT_ITEM_USER_EDIT_ATOM: - g_debug("UserEditAtom, reclen=%ld", reclen); - g_input_stream_skip((GInputStream *)input, reclen, NULL, err); - break; - - case PPT_ITEM_COLOR_SCHEME_ATOM: - g_debug("ColorSchemeAtom, reclen=%ld", reclen); - g_input_stream_skip((GInputStream *)input, reclen, NULL, err); - break; - - case PPT_ITEM_PPDRAWING: - g_debug("PPDrawing, reclen=%ld", reclen); - g_input_stream_skip((GInputStream *)input, reclen, NULL, err); - break; - - case PPT_ITEM_ENVIRONMENT: - g_debug("Environment, reclen=%ld", reclen); - g_input_stream_skip((GInputStream *)input, reclen, NULL, err); - break; - - case PPT_ITEM_SSDOC_INFO_ATOM: - g_debug("SSDocInfoAtom, reclen=%ld", reclen); - g_input_stream_skip((GInputStream *)input, reclen, NULL, err); - break; - - case PPT_ITEM_SSSLIDE_INFO_ATOM: - g_debug("SSSlideInfoAtom, reclen=%ld", reclen); - g_input_stream_skip((GInputStream *)input, reclen, NULL, err); - break; - - case PPT_ITEM_PROG_TAGS: - g_debug("ProgTags, reclen=%ld", reclen); - g_input_stream_skip((GInputStream *)input, reclen, NULL, err); - break; - - case PPT_ITEM_PROG_STRING_TAG: - g_debug("ProgStringTag, reclen=%ld", reclen); - g_input_stream_skip((GInputStream *)input, reclen, NULL, err); - break; - - case PPT_ITEM_PROG_BINARY_TAG: - g_debug("ProgBinaryTag, reclen=%ld", reclen); - g_input_stream_skip((GInputStream *)input, reclen, NULL, err); - break; - - case PPT_ITEM_LIST: - g_debug("List, reclen=%ld", reclen); - break; - - case PPT_ITEM_SLIDE_LIST_WITH_TEXT: - g_debug("SlideListWithText, reclen=%ld" - "---------------------------------------", reclen); - break; - - case PPT_ITEM_PERSIST_PTR_INCREMENTAL_BLOCK: - g_debug("PersistPtrIncrementalBlock, reclen=%ld", reclen); - g_input_stream_skip((GInputStream *)input, reclen, NULL, err); - break; - - case PPT_ITEM_EX_OLE_OBJ_STG: - g_debug("ExOleObjStg, reclen=%ld", reclen); - g_input_stream_skip((GInputStream *)input, reclen, NULL, err); - break; - - case PPT_ITEM_PPDRAWING_GROUP: - g_debug("PpdrawingGroup, reclen=%ld", reclen); - g_input_stream_skip((GInputStream *)input, reclen, NULL, err); - break; - - case PPT_ITEM_EX_OBJ_LIST: - g_debug("ExObjList, reclen=%ld", reclen); - g_input_stream_skip((GInputStream *)input, reclen, NULL, err); - break; - - case PPT_ITEM_TX_MASTER_STYLE_ATOM: - g_debug("TxMasterStyleAtom, reclen=%ld", reclen); - g_input_stream_skip((GInputStream *)input, reclen, NULL, err); - break; - - case PPT_ITEM_HANDOUT: - g_debug("Handout, reclen=%ld", reclen); - g_input_stream_skip((GInputStream *)input, reclen, NULL, err); - break; - - case PPT_ITEM_SLIDE_PERSIST_ATOM: - g_debug("SlidePersistAtom, reclen=%ld", reclen); - g_input_stream_skip((GInputStream *)input, reclen, NULL, err); - break; - - case PPT_ITEM_TEXT_HEADER_ATOM: - g_debug("TextHeaderAtom, reclen=%ld", reclen); - g_input_stream_skip((GInputStream *)input, reclen, NULL, err); - break; - - case PPT_ITEM_TEXT_SPEC_INFO: - g_debug("TextSpecInfo, reclen=%ld", reclen); - g_input_stream_skip((GInputStream *)input, reclen, NULL, err); - break; - - case PPT_ITEM_STYLE_TEXT_PROP_ATOM: - g_debug("StyleTextPropAtom, reclen=%ld", reclen); - g_input_stream_skip((GInputStream *)input, reclen, NULL, err); - break; - - default: - g_debug("Default action for rectype=%d reclen=%ld", - rectype, reclen); - g_input_stream_skip((GInputStream *)input, reclen, NULL, err); + if (ppt->past_first_slide) { + put_byte(ppt, '\f'); } } @@ -315,38 +294,23 @@ static gboolean chupa_feed_ppt(ChupaText *chupar, ChupaTextInput *input, GError **error) { const char *filename = chupa_text_input_get_filename(input); - GInputStream *mem; - GDataInputStream *inp; + GsfOutput *mem; + GsfInput *gin = chupa_text_input_get_base_input(input); + GInputStream *inp; + struct PPT ppt; if (strcmp(filename, "PowerPoint Document")) { return TRUE; } - inp = G_DATA_INPUT_STREAM(chupa_text_input_get_stream(input)); - g_data_input_stream_set_byte_order(inp, G_DATA_STREAM_BYTE_ORDER_LITTLE_ENDIAN); - mem = g_memory_input_stream_new(); - input = chupa_text_input_new_from_stream(NULL, mem, filename); + mem = gsf_output_memory_new(); + inp = chupa_gsf_input_stream_new(GSF_OUTPUT_MEMORY(mem)); + input = chupa_text_input_new_from_stream(NULL, inp, filename); chupa_text_feed(chupar, input, error); - do { - unsigned short rectype; - unsigned long reclen; - unsigned char recbuf[8]; - gssize size = g_input_stream_read((GInputStream *)inp, recbuf, sizeof(recbuf), NULL, error); - if (size == 0) { - process_item(PPT_ITEM_DOCUMENT_END, 0, - inp, (GMemoryInputStream *)mem, error); - break; - } - if (size < sizeof(recbuf)) { - break; - } - rectype = getushort(recbuf, 2); - reclen = getulong(recbuf, 4); - if (reclen < 0) { - break; - } - process_item((ppt_item_type_t)rectype, reclen, - inp, (GMemoryInputStream *)mem, error); - } while (1); + memset(&ppt, 0, sizeof(ppt)); + gsf_input_seek(gin, 0, G_SEEK_SET); + ppt.output = mem; + while (dump_file(&ppt, gin)) { + } return TRUE; } From null+ranguba at clear-code.com Fri Sep 24 05:50:49 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Fri, 24 Sep 2010 09:50:49 +0000 Subject: [groonga-commit:1318] ranguba/chupatext [master] * chupatext/chupa_gsf_input_stream.c: split from chupa_msexcel.c with renaming. Message-ID: <20100924095117.ACC611704C0@taiyaki.ru> Nobuyoshi Nakada 2010-09-24 09:50:49 +0000 (Fri, 24 Sep 2010) New Revision: 0222d9dc2b902ee71316c6aadace78c912efaafd Log: * chupatext/chupa_gsf_input_stream.c: split from chupa_msexcel.c with renaming. Added files: chupatext/chupa_gsf_input_stream.c chupatext/chupa_gsf_input_stream.h Modified files: chupatext/Makefile.am module/chupa_msexcel.c Modified: chupatext/Makefile.am (+2 -0) =================================================================== --- chupatext/Makefile.am 2010-09-24 08:36:40 +0000 (4e73185) +++ chupatext/Makefile.am 2010-09-24 09:50:49 +0000 (f561947) @@ -14,6 +14,7 @@ libchupatext_la_SOURCES = \ chupa_text_input.c \ chupa_module.c \ chupa_text_input_stream.c \ + chupa_gsf_input_stream.c \ error.c \ chupa_decomposer.c \ archive_decomposer.c \ @@ -41,6 +42,7 @@ chupatext_include_HEADERS = \ chupa_text.h \ chupa_text_input.h \ chupa_text_input_stream.h \ + chupa_gsf_input_stream.h \ text_decomposer.h \ external_decomposer.h \ version.h Added: chupatext/chupa_gsf_input_stream.c (+59 -0) 100644 =================================================================== --- /dev/null +++ chupatext/chupa_gsf_input_stream.c 2010-09-24 09:50:49 +0000 (26e3872) @@ -0,0 +1,59 @@ +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Copyright (C) 2010 Nobuyoshi Nakada + */ + +#include "chupatext/chupa_gsf_input_stream.h" + +struct _ChupaGsfInputStream +{ + GMemoryInputStream parent_object; + GsfOutputMemory *source; +}; + +struct _ChupaGsfInputStreamClass +{ + GMemoryInputStreamClass parent_class; +}; + +G_DEFINE_TYPE(ChupaGsfInputStream, chupa_gsf_input_stream, G_TYPE_MEMORY_INPUT_STREAM) + +static void +gsf_input_dispose(GObject *object) +{ + ChupaGsfInputStream *stream = CHUPA_GSF_INPUT_STREAM(object); + + if (stream->source) { + g_object_unref(stream->source); + stream->source = NULL; + } + + G_OBJECT_CLASS(chupa_gsf_input_stream_parent_class)->dispose(object); +} + +static void +chupa_gsf_input_stream_init(ChupaGsfInputStream *stream) +{ + stream->source = NULL; +} + +static void +chupa_gsf_input_stream_class_init(ChupaGsfInputStreamClass *klass) +{ + GObjectClass *gobject_class = G_OBJECT_CLASS(klass); + gobject_class->dispose = gsf_input_dispose; +} + +GInputStream * +chupa_gsf_input_stream_new(GsfOutputMemory *mem) +{ + ChupaGsfInputStream *stream = g_object_new(CHUPA_TYPE_GSF_INPUT_STREAM, NULL); + GsfOutput *out = GSF_OUTPUT(mem); + + g_object_ref(mem); + stream->source = mem; + g_memory_input_stream_add_data(G_MEMORY_INPUT_STREAM(stream), + gsf_output_memory_get_bytes(mem), + gsf_output_size(out), NULL); + return G_INPUT_STREAM(stream); +} Added: chupatext/chupa_gsf_input_stream.h (+29 -0) 100644 =================================================================== --- /dev/null +++ chupatext/chupa_gsf_input_stream.h 2010-09-24 09:50:49 +0000 (2cb8c16) @@ -0,0 +1,29 @@ +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Copyright (C) 2010 Nobuyoshi Nakada + */ + +#include +#include +#include + +G_BEGIN_DECLS + +#define CHUPA_TYPE_GSF_INPUT_STREAM chupa_gsf_input_stream_get_type() +#define CHUPA_GSF_INPUT_STREAM(obj) \ + G_TYPE_CHECK_INSTANCE_CAST(obj, CHUPA_TYPE_GSF_INPUT_STREAM, ChupaGsfInputStream) +#define CHUPA_GSF_INPUT_STREAM_CLASS(klass) \ + G_TYPE_CHECK_CLASS_CAST(klass, CHUPA_TYPE_GSF_INPUT_STREAM, ChupaGsfInputStreamClass) +#define CHUPA_IS_GSF_INPUT_STREAM(obj) \ + G_TYPE_CHECK_INSTANCE_TYPE(obj, CHUPA_TYPE_GSF_INPUT_STREAM) +#define CHUPA_IS_GSF_INPUT_STREAM_CLASS(klass) \ + G_TYPE_CHECK_CLASS_TYPE(klass, CHUPA_TYPE_GSF_INPUT_STREAM) +#define CHUPA_GSF_INPUT_STREAM_GET_CLASS(obj) \ + G_TYPE_INSTANCE_GET_CLASS(obj, CHUPA_TYPE_GSF_INPUT_STREAM, ChupaGsfInputStreamClass) + +typedef struct _ChupaGsfInputStream ChupaGsfInputStream; +typedef struct _ChupaGsfInputStreamClass ChupaGsfInputStreamClass; + +GInputStream *chupa_gsf_input_stream_new(GsfOutputMemory *); + +G_END_DECLS Modified: module/chupa_msexcel.c (+2 -69) =================================================================== --- module/chupa_msexcel.c 2010-09-24 08:36:40 +0000 (1452d71) +++ module/chupa_msexcel.c 2010-09-24 09:50:49 +0000 (b76f401) @@ -10,6 +10,7 @@ #include #include "workbook-view.h" #include "command-context-stderr.h" +#include "chupatext/chupa_gsf_input_stream.h" #define CHUPA_TYPE_EXCEL_DECOMPOSER chupa_type_excel_decomposer #define CHUPA_EXCEL_DECOMPOSER(obj) \ @@ -39,74 +40,6 @@ struct _ChupaExcelDecomposerClass static GOCmdContext *cc; static GType chupa_type_excel_decomposer = 0; -#define CHUPA_TYPE_TUNNEL_STREAM chupa_tunnel_stream_get_type() -#define CHUPA_TUNNEL_STREAM(obj) \ - G_TYPE_CHECK_INSTANCE_CAST(obj, CHUPA_TYPE_TUNNEL_STREAM, ChupaTunnelStream) -#define CHUPA_TUNNEL_STREAM_CLASS(klass) \ - G_TYPE_CHECK_CLASS_CAST(klass, CHUPA_TYPE_TUNNEL_STREAM, ChupaTunnelStreamClass) -#define CHUPA_IS_TUNNEL_STREAM(obj) \ - G_TYPE_CHECK_INSTANCE_TYPE(obj, CHUPA_TYPE_TUNNEL_STREAM) -#define CHUPA_IS_TUNNEL_STREAM_CLASS(klass) \ - G_TYPE_CHECK_CLASS_TYPE(klass, CHUPA_TYPE_TUNNEL_STREAM) -#define CHUPA_TUNNEL_STREAM_GET_CLASS(obj) \ - G_TYPE_INSTANCE_GET_CLASS(obj, CHUPA_TYPE_TUNNEL_STREAM, ChupaTunnelStreamClass) - -typedef struct _ChupaTunnelStream ChupaTunnelStream; -typedef struct _ChupaTunnelStreamClass ChupaTunnelStreamClass; - -struct _ChupaTunnelStream -{ - GMemoryInputStream parent_object; - GsfOutputMemory *source; -}; - -struct _ChupaTunnelStreamClass -{ - GMemoryInputStreamClass parent_class; -}; - -G_DEFINE_TYPE(ChupaTunnelStream, chupa_tunnel_stream, G_TYPE_MEMORY_INPUT_STREAM) - -static void -tunnel_dispose(GObject *object) -{ - ChupaTunnelStream *stream = CHUPA_TUNNEL_STREAM(object); - - if (stream->source) { - g_object_unref(stream->source); - stream->source = NULL; - } - - G_OBJECT_CLASS(chupa_tunnel_stream_parent_class)->dispose(object); -} - -static void -chupa_tunnel_stream_init(ChupaTunnelStream *stream) -{ - stream->source = NULL; -} - -static void -chupa_tunnel_stream_class_init(ChupaTunnelStreamClass *klass) -{ - GObjectClass *gobject_class = G_OBJECT_CLASS(klass); - gobject_class->dispose = tunnel_dispose; -} - -static GInputStream * -chupa_tunnel_stream_new(GsfOutputMemory *mem) -{ - ChupaTunnelStream *stream = g_object_new(CHUPA_TYPE_TUNNEL_STREAM, NULL); - GsfOutput *out = GSF_OUTPUT(mem); - - g_object_ref(mem); - stream->source = mem; - g_memory_input_stream_add_data(G_MEMORY_INPUT_STREAM(stream), - gsf_output_memory_get_bytes(mem), - gsf_output_size(out), NULL); - return G_INPUT_STREAM(stream); -} - static const char export_id[] = "Gnumeric_stf:stf_csv"; static void @@ -159,7 +92,7 @@ chupa_msword_decomposer_feed(ChupaDecomposer *dec, ChupaText *chupar, return FALSE; } - tmpinp = chupa_tunnel_stream_new(GSF_OUTPUT_MEMORY(tmpout)); + tmpinp = chupa_gsf_input_stream_new(GSF_OUTPUT_MEMORY(tmpout)); g_object_unref(io_context); g_object_unref(tmpout); input = chupa_text_input_new_from_stream(NULL, tmpinp, chupa_text_input_get_filename(input)); From null+ranguba at clear-code.com Sun Sep 26 04:35:40 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Sun, 26 Sep 2010 08:35:40 +0000 Subject: [groonga-commit:1319] ranguba/chupatext [master] add a test for multi pages PDF. Message-ID: <20100926083600.B8DBB170640@taiyaki.ru> Kouhei Sutou 2010-09-26 08:35:40 +0000 (Sun, 26 Sep 2010) New Revision: c5ff3565c02c17aaf3a91df2e65a9f3e1fda9a34 Log: add a test for multi pages PDF. Added files: test/fixtures/sample_multi_pages.pdf test/fixtures/sample_multi_pages.svg Modified files: test/test_pdf.c Added: test/fixtures/sample_multi_pages.pdf (+0 -0) 100644 =================================================================== (Binary files differ) Added: test/fixtures/sample_multi_pages.svg (+104 -0) 100644 =================================================================== --- /dev/null +++ test/fixtures/sample_multi_pages.svg 2010-09-26 08:35:40 +0000 (1846a81) @@ -0,0 +1,104 @@ + + + + + + + + + + + + image/svg+xml + + + + + + + page1 + + + 2???? + + + page3 + + Modified: test/test_pdf.c (+13 -1) =================================================================== --- test/test_pdf.c 2010-09-24 09:51:08 +0000 (85a661f) +++ test/test_pdf.c 2010-09-26 08:35:40 +0000 (bd68e25) @@ -5,6 +5,9 @@ #include "chupa_test_util.h" +void test_decompose_pdf(void); +void test_decompose_pdf_multi_pages(void); + void setup(void) { @@ -22,5 +25,14 @@ teardown(void) void test_decompose_pdf(void) { - cut_assert_equal_string("sample\n", decompose_pdf("sample.pdf", NULL)); + cut_assert_equal_string("sample", decompose_pdf("sample.pdf", NULL)); +} + +void +test_decompose_pdf_multi_pages(void) +{ + cut_assert_equal_string("page1\n" + "2????\n" + "page3\n", + decompose_pdf("sample_multi_pages.pdf", NULL)); } From null+ranguba at clear-code.com Sun Sep 26 05:00:04 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Sun, 26 Sep 2010 09:00:04 +0000 Subject: [groonga-commit:1320] ranguba/chupatext [master] chupa_module_path -> chupa_module_dir. Message-ID: <20100926135243.76590278001@taiyaki.ru> Kouhei Sutou 2010-09-26 09:00:04 +0000 (Sun, 26 Sep 2010) New Revision: 820bdc9ea17a4d21c9778ed76034a10b220acbf8 Log: chupa_module_path -> chupa_module_dir. Modified files: chupatext/chupa_decomposer.c chupatext/chupa_module.c chupatext/chupa_module.h test/run-test.sh Modified: chupatext/chupa_decomposer.c (+1 -1) =================================================================== --- chupatext/chupa_decomposer.c 2010-09-26 08:35:40 +0000 (3c440cf) +++ chupatext/chupa_decomposer.c 2010-09-26 09:00:04 +0000 (27ea447) @@ -26,7 +26,7 @@ decomp_modules_init(void) decomp_modules = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, module_list_free); decomp_load_table = g_hash_table_new(g_str_hash, g_str_equal); - module_base_dir = chupa_module_path(); + module_base_dir = chupa_module_dir(); #define REGISTER(mime_type, module) \ g_hash_table_insert(decomp_load_table, mime_type, module) Modified: chupatext/chupa_module.c (+5 -5) =================================================================== --- chupatext/chupa_module.c 2010-09-26 08:35:40 +0000 (4f4fa89) +++ chupatext/chupa_module.c 2010-09-26 09:00:04 +0000 (76272a6) @@ -456,10 +456,10 @@ get_package_dir(void) #endif gchar * -chupa_module_path(void) +chupa_module_dir(void) { - const gchar *path = g_getenv("CHUPA_MODULE_PATH"); - if (!path && !g_path_is_absolute(path = CHUPA_MODULE_PATH)) { + const gchar *dir = g_getenv("CHUPA_MODULE_DIR"); + if (!dir && !g_dir_is_absolute(dir = CHUPA_MODULE_DIR)) { gchar *base_dir; #if defined G_OS_WIN32 base_dir = g_win32_get_package_installation_directory_of_module(chupa_dll); @@ -467,10 +467,10 @@ chupa_module_path(void) base_dir = get_package_dir(); #endif if (base_dir) { - return g_build_filename(base_dir, path, NULL); + return g_build_filename(base_dir, dir, NULL); } } - return g_strdup(path); + return g_strdup(dir); } /* Modified: chupatext/chupa_module.h (+1 -1) =================================================================== --- chupatext/chupa_module.h 2010-09-26 08:35:40 +0000 (c559179) +++ chupatext/chupa_module.h 2010-09-26 09:00:04 +0000 (3d16344) @@ -46,7 +46,7 @@ GObject *chupa_module_instantiate(ChupaModule *module, GList *chupa_module_collect_registered_types(GList *modules); GList *chupa_module_collect_names(GList *modules); void chupa_module_unload(ChupaModule *module); -gchar *chupa_module_path(void); +gchar *chupa_module_dir(void); #define CHUPA_MODULE_IMPL_INIT chupa_module_impl_init #define CHUPA_MODULE_IMPL_EXIT chupa_module_impl_exit Modified: test/run-test.sh (+1 -1) =================================================================== --- test/run-test.sh 2010-09-26 08:35:40 +0000 (e26b977) +++ test/run-test.sh 2010-09-26 09:00:04 +0000 (70cdc91) @@ -87,6 +87,6 @@ export CHUPATEXT_RUBYLIB export RUBYLIB export CHUPATEXT_CONFIGURATION_MODULE_DIR=$builddir/module/configuration/ruby/.libs export CHUPATEXT_CONFIG_DIR=$top_srcdir/test/fixtures/configuration -export CHUPA_MODULE_PATH=$builddir/module/.libs +export CHUPA_MODULE_DIR=$builddir/module/.libs $CUTTER_WRAPPER $CUTTER $CUTTER_ARGS "$@" "$testdir" From null+ranguba at clear-code.com Sun Sep 26 05:02:30 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Sun, 26 Sep 2010 09:02:30 +0000 Subject: [groonga-commit:1321] ranguba/chupatext [master] fix a memory leak. Message-ID: <20100926135243.88330278002@taiyaki.ru> Kouhei Sutou 2010-09-26 09:02:30 +0000 (Sun, 26 Sep 2010) New Revision: 376d4900ce0132b476b8ddd4fd926edbc9460275 Log: fix a memory leak. Modified files: chupatext/chupa_module.c Modified: chupatext/chupa_module.c (+4 -1) =================================================================== --- chupatext/chupa_module.c 2010-09-26 09:00:04 +0000 (76272a6) +++ chupatext/chupa_module.c 2010-09-26 09:02:30 +0000 (d817b50) @@ -467,7 +467,10 @@ chupa_module_dir(void) base_dir = get_package_dir(); #endif if (base_dir) { - return g_build_filename(base_dir, dir, NULL); + gchar *absolute_dir; + absolute_dir = g_build_filename(base_dir, dir, NULL); + g_free(base_dir); + return absolute_dir; } } return g_strdup(dir); From null+ranguba at clear-code.com Sun Sep 26 09:57:09 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Sun, 26 Sep 2010 13:57:09 +0000 Subject: [groonga-commit:1322] ranguba/chupatext [master] Word decomposer works as dynamic decomposer. Message-ID: <20100926135719.5D6E2170640@taiyaki.ru> Kouhei Sutou 2010-09-26 13:57:09 +0000 (Sun, 26 Sep 2010) New Revision: d4f9dbf7d8cb08f8f6f09eaf8e365ffdf624d5ce Log: Word decomposer works as dynamic decomposer. Added files: module/word_factory.c Modified files: module/Makefile.am test/Makefile.am Renamed files: module/word.c (from module/chupa_msword.c) test/test_word.c (from test/test_msword.c) Modified: module/Makefile.am (+11 -5) =================================================================== --- module/Makefile.am 2010-09-26 13:52:29 +0000 (3c8cb7f) +++ module/Makefile.am 2010-09-26 13:57:09 +0000 (aa3d0c0) @@ -11,7 +11,8 @@ decomposer_LTLIBRARIES += pdf.la factory_LTLIBRARIES += pdf_factory.la endif if HAVE_WV -decomposer_LTLIBRARIES += chupa_msword.la +decomposer_LTLIBRARIES += word.la +factory_LTLIBRARIES += word_factory.la endif if HAVE_GOFFICE decomposer_LTLIBRARIES += excel.la @@ -39,10 +40,15 @@ pdf_factory_la_LDFLAGS = -module pdf_factory_la_CPPFLAGS = $(GLIB_CFLAGS) $(GSF_CFLAGS) pdf_factory_la_LIBADD = $(GLIB_LIBS) -chupa_msword_la_SOURCES = chupa_msword.c -chupa_msword_la_LDFLAGS = -module -chupa_msword_la_CPPFLAGS = $(WV_CFLAGS) -chupa_msword_la_LIBADD = $(WV_LIBS) $(GSF_LIBS) +word_la_SOURCES = word.c +word_la_LDFLAGS = -module +word_la_CPPFLAGS = $(WV_CFLAGS) +word_la_LIBADD = $(WV_LIBS) $(GSF_LIBS) + +word_factory_la_SOURCES = word_factory.c +word_factory_la_LDFLAGS = -module +word_factory_la_CPPFLAGS = $(GLIB_CFLAGS) $(GSF_CFLAGS) +word_factory_la_LIBADD = $(GLIB_LIBS) excel_la_SOURCES = excel.c excel_la_LDFLAGS = -module Renamed: module/word.c (+0 -1) 99% =================================================================== --- module/chupa_msword.c 2010-09-26 13:52:29 +0000 (5a4ec80) +++ module/word.c 2010-09-26 13:57:09 +0000 (68a1f92) @@ -200,7 +200,6 @@ register_type(GTypeModule *type_module) "ChupaMSWORDDecomposer", &info, 0); chupa_type_msword_decomposer = type; - chupa_decomposer_register("application/msword", type); } return type; } Added: module/word_factory.c (+159 -0) 100644 =================================================================== --- /dev/null +++ module/word_factory.c 2010-09-26 13:57:09 +0000 (961ac62) @@ -0,0 +1,159 @@ +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Copyright (C) 2010 Kouhei Sutou + * + * 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 3 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 program. If not, see . + * + */ + +#ifdef HAVE_CONFIG_H +# include +#endif /* HAVE_CONFIG_H */ + +#include +#include +#include +/* #include */ +#include + +#include +#include +#include + +#define CHUPA_TYPE_WORD_FACTORY chupa_type_word_factory +#define CHUPA_WORD_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CHUPA_TYPE_WORD_FACTORY, ChupaWORDFactory)) +#define CHUPA_WORD_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CHUPA_TYPE_WORD_FACTORY, ChupaWORDFactoryClass)) +#define CHUPA_IS_WORD_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CHUPA_TYPE_WORD_FACTORY)) +#define CHUPA_IS_WORD_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CHUPA_TYPE_WORD_FACTORY)) +#define CHUPA_WORD_FACTORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), CHUPA_TYPE_WORD_FACTORY, ChupaWORDFactoryClass)) + +typedef struct _ChupaWORDFactory ChupaWORDFactory; +typedef struct _ChupaWORDFactoryClass ChupaWORDFactoryClass; + +struct _ChupaWORDFactory +{ + ChupaModuleFactory object; +}; + +struct _ChupaWORDFactoryClass +{ + ChupaModuleFactoryClass parent_class; +}; + +static GType chupa_type_word_factory = 0; +static ChupaModuleFactoryClass *parent_class; + +static GList *get_mime_types (ChupaModuleFactory *factory); +static GObject *create (ChupaModuleFactory *factory); + +static void +class_init (ChupaModuleFactoryClass *klass) +{ + GObjectClass *gobject_class; + ChupaModuleFactoryClass *factory_class; + + parent_class = g_type_class_peek_parent(klass); + + gobject_class = G_OBJECT_CLASS(klass); + factory_class = CHUPA_MODULE_FACTORY_CLASS(klass); + + factory_class->get_mime_types = get_mime_types; + factory_class->create = create; +} + +static void +init (ChupaWORDFactory *factory) +{ +} + +static void +register_type (GTypeModule *type_module) +{ + static const GTypeInfo info = + { + sizeof (ChupaWORDFactoryClass), + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) class_init, + NULL, /* class_finalize */ + NULL, /* class_data */ + sizeof(ChupaWORDFactory), + 0, + (GInstanceInitFunc) init, + }; + + chupa_type_word_factory = + g_type_module_register_type(type_module, + CHUPA_TYPE_MODULE_FACTORY, + "ChupaWORDFactory", + &info, 0); +} + +G_MODULE_EXPORT GList * +CHUPA_MODULE_IMPL_INIT (GTypeModule *type_module) +{ + GList *registered_types = NULL; + + register_type(type_module); + if (chupa_type_word_factory) { + registered_types = + g_list_prepend(registered_types, + (gchar *)g_type_name(chupa_type_word_factory)); + } + + return registered_types; +} + +G_MODULE_EXPORT void +CHUPA_MODULE_IMPL_EXIT (void) +{ +} + +G_MODULE_EXPORT GObject * +CHUPA_MODULE_IMPL_INSTANTIATE (const gchar *first_property, va_list var_args) +{ + return g_object_new_valist(CHUPA_TYPE_WORD_FACTORY, first_property, var_args); +} + +static GList * +get_mime_types (ChupaModuleFactory *factory) +{ + GList *mime_types = NULL; + + mime_types = g_list_prepend(mime_types, g_strdup("application/msword")); + + return mime_types; +} + +GObject * +create (ChupaModuleFactory *factory) +{ + static int n_instances = 0; + GObject *decomposer; + + decomposer = G_OBJECT(chupa_decomposer_new("word", NULL)); + n_instances++; + if (n_instances == 1) { + /* FIXME: This causes memory leak but we need to + * keep at least 1 decomposer instance to avoid + * duplicated non-module GType + * (e.g. PopplerDocument) registration. */ + g_object_ref(decomposer); + } + return decomposer; +} + +/* +vi:ts=4:nowrap:ai:expandtab:sw=4 +*/ Modified: test/Makefile.am (+2 -2) =================================================================== --- test/Makefile.am 2010-09-26 13:52:29 +0000 (434b9ff) +++ test/Makefile.am 2010-09-26 13:57:09 +0000 (c5f9ca2) @@ -23,7 +23,7 @@ noinst_LTLIBRARIES += test_pdf.la endif if HAVE_WV -noinst_LTLIBRARIES += test_msword.la +noinst_LTLIBRARIES += test_word.la endif if HAVE_GOFFICE noinst_LTLIBRARIES += test_excel.la @@ -70,7 +70,7 @@ test_decomposer_la_SOURCES = test_decomposer.c test_external_decomposer_la_SOURCES = test_external_decomposer.c chupa_test_util.c test_restrict_input_stream_la_SOURCES = test_restrict_input_stream.c test_pdf_la_SOURCES = test_pdf.c chupa_test_util.c -test_msword_la_SOURCES = test_msword.c chupa_test_util.c +test_word_la_SOURCES = test_word.c chupa_test_util.c test_excel_la_SOURCES = test_excel.c chupa_test_util.c test_mspowerpoint_la_SOURCES = test_mspowerpoint.c chupa_test_util.c test_tar_la_SOURCES = test_tar.c chupa_test_util.c Renamed: test/test_word.c (+0 -0) 100% =================================================================== From null+ranguba at clear-code.com Sun Sep 26 05:29:55 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Sun, 26 Sep 2010 09:29:55 +0000 Subject: [groonga-commit:1323] ranguba/chupatext [master] add chupa factory builder. Message-ID: <20100926135243.96F36278003@taiyaki.ru> Kouhei Sutou 2010-09-26 09:29:55 +0000 (Sun, 26 Sep 2010) New Revision: 03974980b3fe8fd795b574e6b32b9b56dbb252b7 Log: add chupa factory builder. Added files: chupatext/chupa_factory_builder.c chupatext/chupa_factory_builder.h Modified files: chupatext/Makefile.am Modified: chupatext/Makefile.am (+5 -1) =================================================================== --- chupatext/Makefile.am 2010-09-26 09:02:30 +0000 (f561947) +++ chupatext/Makefile.am 2010-09-26 09:29:55 +0000 (7e44951) @@ -13,6 +13,7 @@ libchupatext_la_SOURCES = \ chupa_text.c \ chupa_text_input.c \ chupa_module.c \ + chupa_module_factory.c \ chupa_text_input_stream.c \ chupa_gsf_input_stream.c \ error.c \ @@ -24,7 +25,9 @@ libchupatext_la_SOURCES = \ version.c \ $(EMPTY) -AM_CPPFLAGS = -DCHUPA_MODULE_PATH=\"$(moduledir)\" -D_GNU_SOURCE +AM_CPPFLAGS = \ + -DCHUPA_MODULE_DIR=\"$(moduledir)\" \ + -D_GNU_SOURCE AM_CFLAGS = $(GSF_CFLAGS) $(GIO_UNIX_CFLAGS) AM_LDFLAGS = $(GSF_LIBS) $(GIO_UNIX_LIBS) @@ -36,6 +39,7 @@ chupatext_include_HEADERS = \ chupa_decomposer.h \ chupa_metadata.h \ chupa_module.h \ + chupa_module_factory.h \ chupa_module_impl.h \ chupa_private.h \ chupa_restrict_input_stream.h \ Added: chupatext/chupa_factory_builder.c (+234 -0) 100644 =================================================================== --- /dev/null +++ chupatext/chupa_factory_builder.c 2010-09-26 09:29:55 +0000 (1558b53) @@ -0,0 +1,234 @@ +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Copyright (C) 2007-2010 Kouhei Sutou + * + * 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 3 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 program. If not, see . + * + */ + +#ifdef HAVE_CONFIG_H +# include +#endif /* HAVE_CONFIG_H */ + +#include +#include + +#include "chupa_factory_builder.h" + +#define CHUPA_FACTORY_BUILDER_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE((obj), \ + CHUPA_TYPE_FACTORY_BUILDER, \ + ChupaFactoryBuilderPrivate)) + +typedef struct _ChupaFactoryBuilderPrivate ChupaFactoryBuilderPrivate; +struct _ChupaFactoryBuilderPrivate +{ + gchar *module_dir; + GOptionContext *option_context; + GList *factories; +}; + +enum +{ + PROP_0, + PROP_MODULE_DIR, + PROP_OPTION_CONTEXT +}; + +G_DEFINE_ABSTRACT_TYPE(ChupaFactoryBuilder, chupa_factory_builder, G_TYPE_OBJECT) + +static void dispose (GObject *object); +static void set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec); +static void get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec); +static void +chupa_factory_builder_class_init (ChupaFactoryBuilderClass *klass) +{ + GObjectClass *gobject_class; + GParamSpec *spec; + + gobject_class = G_OBJECT_CLASS(klass); + + gobject_class->dispose = dispose; + gobject_class->set_property = set_property; + gobject_class->get_property = get_property; + + spec = g_param_spec_string("module-dir", + "The name of the directory", + "The name of the directory in which includes target factory", + NULL, + G_PARAM_READWRITE); + g_object_class_install_property(gobject_class, PROP_MODULE_DIR, spec); + + spec = g_param_spec_pointer("option-context", + "GOptionContext", + "GOptionContext", + G_PARAM_READWRITE); + g_object_class_install_property(gobject_class, PROP_OPTION_CONTEXT, spec); + + g_type_class_add_private(gobject_class, sizeof(ChupaFactoryBuilderPrivate)); +} + +static void +chupa_factory_builder_init (ChupaFactoryBuilder *builder) +{ + ChupaFactoryBuilderPrivate *priv = CHUPA_FACTORY_BUILDER_GET_PRIVATE(builder); + + priv->module_dir = NULL; + priv->option_context = NULL; + priv->factories = NULL; +} + +static void +dispose (GObject *object) +{ + ChupaFactoryBuilderPrivate *priv = CHUPA_FACTORY_BUILDER_GET_PRIVATE(object); + + if (priv->module_dir) { + g_free(priv->module_dir); + priv->module_dir = NULL; + } + + if (priv->factories) { + g_list_free(priv->factories); + priv->factories = NULL; + } + priv->option_context = NULL; + + G_OBJECT_CLASS(chupa_factory_builder_parent_class)->dispose(object); +} + +static void +set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) +{ + ChupaFactoryBuilderPrivate *priv = CHUPA_FACTORY_BUILDER_GET_PRIVATE(object); + + switch (prop_id) { + case PROP_MODULE_DIR: + if (priv->module_dir) + g_free(priv->module_dir); + priv->module_dir = g_value_dup_string(value); + break; + case PROP_OPTION_CONTEXT: + priv->option_context = g_value_get_pointer(value); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + break; + } +} + +static void +get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ + ChupaFactoryBuilderPrivate *priv = CHUPA_FACTORY_BUILDER_GET_PRIVATE(object); + + switch (prop_id) { + case PROP_MODULE_DIR: + g_value_set_string(value, priv->module_dir); + break; + case PROP_OPTION_CONTEXT: + g_value_set_pointer(value, priv->option_context); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + break; + } +} + +const gchar * +chupa_factory_builder_get_type_name (ChupaFactoryBuilder *builder) +{ + ChupaFactoryBuilderClass *klass; + + g_return_val_if_fail(CHUPA_IS_FACTORY_BUILDER(builder), NULL); + + klass = CHUPA_FACTORY_BUILDER_GET_CLASS(builder); + if (klass->get_type_name) + return klass->get_type_name(builder); + + return NULL; +} + +const gchar * +chupa_factory_builder_get_module_dir (ChupaFactoryBuilder *builder) +{ + return CHUPA_FACTORY_BUILDER_GET_PRIVATE(builder)->module_dir; +} + +void +chupa_factory_builder_set_option_context (ChupaFactoryBuilder *builder, + GOptionContext *context) +{ + ChupaFactoryBuilderClass *klass; + ChupaFactoryBuilderPrivate *priv; + + priv = CHUPA_FACTORY_BUILDER_GET_PRIVATE(builder); + g_return_if_fail(CHUPA_IS_FACTORY_BUILDER(builder)); + + klass = CHUPA_FACTORY_BUILDER_GET_CLASS(builder); + g_return_if_fail(klass->set_option_context); + + priv->option_context = context; + klass->set_option_context(builder, context); +} + +GList * +chupa_factory_builder_build (ChupaFactoryBuilder *builder) +{ + ChupaFactoryBuilderClass *klass; + ChupaFactoryBuilderPrivate *priv; + + priv = CHUPA_FACTORY_BUILDER_GET_PRIVATE(builder); + g_return_val_if_fail(CHUPA_IS_FACTORY_BUILDER(builder), NULL); + + klass = CHUPA_FACTORY_BUILDER_GET_CLASS(builder); + g_return_val_if_fail(klass->build, NULL); + + priv->factories = klass->build(builder); + + return priv->factories; +} + +GList * +chupa_factory_builder_build_all (ChupaFactoryBuilder *builder) +{ + ChupaFactoryBuilderClass *klass; + ChupaFactoryBuilderPrivate *priv; + + priv = CHUPA_FACTORY_BUILDER_GET_PRIVATE(builder); + g_return_val_if_fail(CHUPA_IS_FACTORY_BUILDER(builder), NULL); + + klass = CHUPA_FACTORY_BUILDER_GET_CLASS(builder); + g_return_val_if_fail(klass->build_all, NULL); + + priv->factories = klass->build_all(builder); + + return priv->factories; +} + +/* +vi:ts=4:nowrap:ai:expandtab:sw=4 +*/ Added: chupatext/chupa_factory_builder.h (+67 -0) 100644 =================================================================== --- /dev/null +++ chupatext/chupa_factory_builder.h 2010-09-26 09:29:55 +0000 (3237c13) @@ -0,0 +1,67 @@ +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Copyright (C) 2007-2010 Kouhei Sutou + * + * 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 3 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 program. If not, see . + * + */ + +#ifndef __CHUPA_FACTORY_BUILDER_H__ +#define __CHUPA_FACTORY_BUILDER_H__ + +#include + +G_BEGIN_DECLS + +#define CHUPA_TYPE_FACTORY_BUILDER (chupa_factory_builder_get_type ()) +#define CHUPA_FACTORY_BUILDER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CHUPA_TYPE_FACTORY_BUILDER, ChupaFactoryBuilder)) +#define CHUPA_FACTORY_BUILDER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CHUPA_TYPE_FACTORY_BUILDER, ChupaFactoryBuilderClass)) +#define CHUPA_IS_FACTORY_BUILDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CHUPA_TYPE_FACTORY_BUILDER)) +#define CHUPA_IS_FACTORY_BUILDER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CHUPA_TYPE_FACTORY_BUILDER)) +#define CHUPA_FACTORY_BUILDER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), CHUPA_TYPE_FACTORY_BUILDER, ChupaFactoryBuilderClass)) + +typedef struct _ChupaFactoryBuilder ChupaFactoryBuilder; +typedef struct _ChupaFactoryBuilderClass ChupaFactoryBuilderClass; + +struct _ChupaFactoryBuilder +{ + GObject object; +}; + +struct _ChupaFactoryBuilderClass +{ + GObjectClass parent_class; + void (*set_option_context) (ChupaFactoryBuilder *builder, + GOptionContext *context); + GList *(*build) (ChupaFactoryBuilder *builder); + GList *(*build_all) (ChupaFactoryBuilder *builder); + const gchar *(*get_type_name) (ChupaFactoryBuilder *builder); +}; + +GType chupa_factory_builder_get_type (void) G_GNUC_CONST; +const gchar *chupa_factory_builder_get_type_name (ChupaFactoryBuilder *builder); +const gchar *chupa_factory_builder_get_module_dir (ChupaFactoryBuilder *builder); +void chupa_factory_builder_set_option_context + (ChupaFactoryBuilder *builder, + GOptionContext *context); +GList *chupa_factory_builder_build (ChupaFactoryBuilder *builder); +GList *chupa_factory_builder_build_all (ChupaFactoryBuilder *builder); + +G_END_DECLS + +#endif /* __CHUPA_FACTORY_BUILDER_H__ */ + +/* +vi:ts=4:nowrap:ai:expandtab:sw=4 +*/ From null+ranguba at clear-code.com Sun Sep 26 09:45:18 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Sun, 26 Sep 2010 13:45:18 +0000 Subject: [groonga-commit:1324] ranguba/chupatext [master] support dynamic decompoer registration. Message-ID: <20100926135243.A5954278004@taiyaki.ru> Kouhei Sutou 2010-09-26 13:45:18 +0000 (Sun, 26 Sep 2010) New Revision: 65bd55fd0f089e1619174d5bf9a85182595adc57 Log: support dynamic decompoer registration. But only PDF is suppored for now. Added files: chupatext/chupa_dispatcher.c chupatext/chupa_dispatcher.h chupatext/chupa_module_factory.c chupatext/chupa_module_factory.h chupatext/chupa_module_factory_utils.c chupatext/chupa_module_factory_utils.h chupatext/chupa_utils.c chupatext/chupa_utils.h module/pdf_factory.c test/suite_chupatext_test.c Removed files: chupatext/chupa_factory_builder.c chupatext/chupa_factory_builder.h Modified files: chupatext/Makefile.am chupatext/chupa_decomposer.c chupatext/chupa_decomposer.h chupatext/chupa_init.c chupatext/chupa_module.c chupatext/chupa_text.c configure.ac module/Makefile.am test/Makefile.am test/run-test.sh Renamed files: module/pdf.c (from module/chupa_pdf.c) Modified: chupatext/Makefile.am (+10 -2) =================================================================== --- chupatext/Makefile.am 2010-09-26 09:29:55 +0000 (7e44951) +++ chupatext/Makefile.am 2010-09-26 13:45:18 +0000 (fd9058a) @@ -14,6 +14,8 @@ libchupatext_la_SOURCES = \ chupa_text_input.c \ chupa_module.c \ chupa_module_factory.c \ + chupa_module_factory_utils.c \ + chupa_dispatcher.c \ chupa_text_input_stream.c \ chupa_gsf_input_stream.c \ error.c \ @@ -22,11 +24,14 @@ libchupatext_la_SOURCES = \ external_decomposer.c \ text_decomposer.c \ chupa_restrict_input_stream.c \ + chupa_utils.c \ version.c \ $(EMPTY) -AM_CPPFLAGS = \ - -DCHUPA_MODULE_DIR=\"$(moduledir)\" \ +AM_CPPFLAGS = \ + -DCHUPA_MODULE_DIR=\"$(moduledir)\" \ + -DDECOMPOSER_MODULE_DIR=\"$(decomposerdir)\" \ + -DFACTORY_MODULE_DIR=\"$(factorydir)\" \ -D_GNU_SOURCE AM_CFLAGS = $(GSF_CFLAGS) $(GIO_UNIX_CFLAGS) AM_LDFLAGS = $(GSF_LIBS) $(GIO_UNIX_LIBS) @@ -40,7 +45,9 @@ chupatext_include_HEADERS = \ chupa_metadata.h \ chupa_module.h \ chupa_module_factory.h \ + chupa_module_factory_utils.h \ chupa_module_impl.h \ + chupa_dispatcher.h \ chupa_private.h \ chupa_restrict_input_stream.h \ chupa_text.h \ @@ -49,6 +56,7 @@ chupatext_include_HEADERS = \ chupa_gsf_input_stream.h \ text_decomposer.h \ external_decomposer.h \ + chupa_utils.h \ version.h version.lo: version.h Modified: chupatext/chupa_decomposer.c (+73 -101) =================================================================== --- chupatext/chupa_decomposer.c 2010-09-26 09:29:55 +0000 (27ea447) +++ chupatext/chupa_decomposer.c 2010-09-26 13:45:18 +0000 (42dd478) @@ -3,36 +3,17 @@ * Copyright (C) 2010 Nobuyoshi Nakada */ -#include "chupatext/chupa_decomposer.h" -#include "chupatext/chupa_module.h" -#include "chupatext/text_decomposer.h" #include #include -#define CHUPA_DECOMPOSER_GET_PRIVATE(obj) \ - (G_TYPE_INSTANCE_GET_PRIVATE(obj, \ - CHUPA_TYPE_DECOMPOSER_OBJECT, \ - ChupaDecomposerPrivate)) - -static GHashTable *decomp_modules = NULL; -static GHashTable *decomp_load_table = NULL; -static gchar *module_base_dir; - -#define module_list_free (GDestroyNotify)g_list_free +#include "chupa_decomposer.h" +#include "chupa_module.h" +#include "chupa_module_factory.h" -static void -decomp_modules_init(void) -{ - decomp_modules = g_hash_table_new_full(g_str_hash, g_str_equal, - NULL, module_list_free); - decomp_load_table = g_hash_table_new(g_str_hash, g_str_equal); - module_base_dir = chupa_module_dir(); - -#define REGISTER(mime_type, module) \ - g_hash_table_insert(decomp_load_table, mime_type, module) -#include "module/init_chupa.h" -#undef REGISTER -} +#define CHUPA_DECOMPOSER_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE(obj, \ + CHUPA_TYPE_DECOMPOSER_OBJECT, \ + ChupaDecomposerPrivate)) #ifdef USE_CHUPA_DECOMPOSER_PRIVATE typedef struct _ChupaDecomposerPrivate ChupaDecomposerPrivate; @@ -41,8 +22,7 @@ struct _ChupaDecomposerPrivate }; #endif -G_DEFINE_ABSTRACT_TYPE_WITH_CODE(ChupaDecomposer, chupa_decomposer, G_TYPE_OBJECT, - decomp_modules_init()) +G_DEFINE_ABSTRACT_TYPE(ChupaDecomposer, chupa_decomposer, G_TYPE_OBJECT) static void chupa_decomposer_init(ChupaDecomposer *decomposer) @@ -60,91 +40,83 @@ chupa_decomposer_class_init(ChupaDecomposerClass *klass) #endif } -gboolean -chupa_decomposer_feed(ChupaDecomposer *dec, ChupaText *text, ChupaTextInput *input, GError **err) -{ - g_return_val_if_fail(CHUPA_IS_DECOMPOSER(dec), FALSE); - return (*CHUPA_DECOMPOSER_GET_CLASS(dec)->feed)(dec, text, input, err); -} - -static const char text_plain[] = "text/plain"; +static GList *decomposers = NULL; +static gchar *decomposer_module_dir = NULL; +#ifdef G_OS_WIN32 +static gchar *win32_decomposer_module_dir = NULL; +#endif -void -chupa_decomposer_load_modules(void) +static const gchar * +_chupa_decomposer_module_dir (void) { - chupa_decomposer_register(text_plain, CHUPA_TYPE_TEXT_DECOMPOSER); + const gchar *dir; + + if (decomposer_module_dir) + return decomposer_module_dir; + + dir = g_getenv("CHUPA_DECOMPOSER_DIR"); + if (dir) + return dir; + +#ifdef G_OS_WIN32 + if (!win32_decomposer_module_dir) + win32_decomposer_module_dir = + chupa_win32_build_module_dir_name("decomposer"); + return win32_decomopser_module_dir; +#else + return DECOMPOSER_MODULE_DIR; +#endif } -void -chupa_decomposer_register(const gchar *mime_type, GType type) +static ChupaModule * +_chupa_decomposer_load_module (const gchar *decomposer) { - gpointer key = (gpointer)mime_type, val = NULL; - - if (g_hash_table_lookup_extended(decomp_modules, key, &key, &val)) { - g_hash_table_steal(decomp_modules, key); + ChupaModule *module; + + module = chupa_module_find(decomposers, decomposer); + if (module) + return module; + + module = chupa_module_load_module(_chupa_decomposer_module_dir(), + decomposer); + if (module) { + if (g_type_module_use(G_TYPE_MODULE(module))) { + decomposers = g_list_prepend(decomposers, module); + g_type_module_unuse(G_TYPE_MODULE(module)); + } } - val = g_list_prepend((GList *)val, (gpointer)type); - g_hash_table_insert(decomp_modules, key, val); + + return module; } -void -chupa_decomposer_unregister(const gchar *mime_type, GType type) +ChupaDecomposer * +chupa_decomposer_new (const gchar *name, const gchar *first_property, ...) { - gpointer key = (gpointer)mime_type, val = NULL; + ChupaModule *module; + ChupaDecomposer *decomposer; + va_list var_args; - if (g_hash_table_lookup_extended(decomp_modules, key, &key, &val)) { - g_hash_table_steal(decomp_modules, key); - val = g_list_remove((GList *)val, (gpointer)type); - if (val) { - g_hash_table_insert(decomp_modules, key, val); - } - } + module = _chupa_decomposer_load_module(name); + g_return_val_if_fail(module != NULL, NULL); + + va_start(var_args, first_property); + decomposer = chupa_module_instantiate(module, first_property, var_args); + va_end(var_args); + + return decomposer; } -ChupaDecomposer * -chupa_decomposer_search(const gchar *const mime_type) +gboolean +chupa_decomposer_feed(ChupaDecomposer *dec, ChupaText *text, ChupaTextInput *input, GError **err) { - GList *type_list = NULL; - const char *sub_type; - gpointer key, value; - ChupaModule *mod = NULL; - int retry = 0; - - do { - if (g_hash_table_lookup_extended(decomp_modules, mime_type, &key, &value)) { - type_list = (GList *)value; - } - else if (g_hash_table_lookup_extended(decomp_load_table, mime_type, &key, &value) && - (mod = chupa_module_load_module(module_base_dir, (const gchar *)value)) != NULL) { - if (!g_type_module_use(G_TYPE_MODULE(mod))) { - break; - } - } - else if ((sub_type = strchr((const char *)mime_type, '/')) != NULL) { - GString *tmp_type = NULL; - ++sub_type; - if (sub_type[0] == 'x' && sub_type[1] == '-') { - tmp_type = g_string_new_len(mime_type, sub_type - mime_type); - g_string_append(tmp_type, sub_type += 2); - if (g_hash_table_lookup_extended(decomp_modules, tmp_type->str, &key, &value)) { - type_list = (GList *)value; - } - } - if (!type_list && tmp_type && - g_hash_table_lookup_extended(decomp_load_table, tmp_type->str, &key, &value)) { - mod = chupa_module_load_module(module_base_dir, (const gchar *)value); - } - if (tmp_type) { - g_string_free(tmp_type, TRUE); - } - if (!mod || !g_type_module_use(G_TYPE_MODULE(mod))) { - break; - } - } - } while (!type_list && !retry++); + g_return_val_if_fail(CHUPA_IS_DECOMPOSER(dec), FALSE); + return (*CHUPA_DECOMPOSER_GET_CLASS(dec)->feed)(dec, text, input, err); +} - if (!type_list) { - return NULL; - } - return CHUPA_DECOMPOSER(g_object_new((GType)type_list->data, NULL)); +static const char text_plain[] = "text/plain"; + +void +chupa_decomposer_load_modules(void) +{ + /* chupa_decomposer_register(text_plain, CHUPA_TYPE_TEXT_DECOMPOSER); */ } Modified: chupatext/chupa_decomposer.h (+8 -3) =================================================================== --- chupatext/chupa_decomposer.h 2010-09-26 09:29:55 +0000 (9681033) +++ chupatext/chupa_decomposer.h 2010-09-26 13:45:18 +0000 (8ac8e22) @@ -8,7 +8,7 @@ #include #include -#include "chupatext/chupa_text.h" +#include G_BEGIN_DECLS @@ -42,8 +42,13 @@ struct _ChupaDecomposerClass GType chupa_decomposer_get_type(void) G_GNUC_CONST; -ChupaDecomposer *chupa_decomposer_search(const gchar *mime_type); -gboolean chupa_decomposer_feed(ChupaDecomposer *dec, ChupaText *text, ChupaTextInput *input, GError **err); +ChupaDecomposer *chupa_decomposer_new (const gchar *name, + const gchar *first_property, + ...); +gboolean chupa_decomposer_feed (ChupaDecomposer *dec, + ChupaText *text, + ChupaTextInput *input, + GError **error); void chupa_decomposer_load_modules(void); void chupa_decomposer_register(const gchar *mime_type, GType type); Added: chupatext/chupa_dispatcher.c (+283 -0) 100644 =================================================================== --- /dev/null +++ chupatext/chupa_dispatcher.c 2010-09-26 13:45:18 +0000 (ab535a9) @@ -0,0 +1,283 @@ +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Copyright (C) 2007-2010 Kouhei Sutou + * + * 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 3 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 program. If not, see . + * + */ + +#ifdef HAVE_CONFIG_H +# include +#endif /* HAVE_CONFIG_H */ + +#include +#include + +#include "chupa_dispatcher.h" +#include "chupa_module_factory.h" +#include "chupa_module_factory_utils.h" + +#define CHUPA_DISPATCHER_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE((obj), \ + CHUPA_TYPE_DISPATCHER, \ + ChupaDispatcherPrivate)) + +typedef struct _ChupaDispatcherPrivate ChupaDispatcherPrivate; +struct _ChupaDispatcherPrivate +{ + gchar *module_dir; + GList *factories; + GHashTable *mime_type_table; +}; + +enum +{ + PROP_0, + PROP_MODULE_DIR +}; + +G_DEFINE_TYPE(ChupaDispatcher, chupa_dispatcher, G_TYPE_OBJECT) + +static void dispose (GObject *object); +static void set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec); +static void get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec); +static void +chupa_dispatcher_class_init (ChupaDispatcherClass *klass) +{ + GObjectClass *gobject_class; + GParamSpec *spec; + + gobject_class = G_OBJECT_CLASS(klass); + + gobject_class->dispose = dispose; + gobject_class->set_property = set_property; + gobject_class->get_property = get_property; + + spec = g_param_spec_string("module-dir", + "The name of the directory", + "The name of the directory in which includes target factory", + NULL, + G_PARAM_READWRITE); + g_object_class_install_property(gobject_class, PROP_MODULE_DIR, spec); + + g_type_class_add_private(gobject_class, sizeof(ChupaDispatcherPrivate)); +} + +#define module_list_free (GDestroyNotify)g_list_free + +static gchar * +detect_module_dir(void) +{ + const gchar *dir; + + dir = g_getenv("CHUPA_FACTORY_DIR"); + if (!dir) { +#ifdef G_OS_WIN32 + if (!win32_decomposer_factory_module_dir) + win32_decomposer_factory_module_dir = + chupa_win32_build_factory_module_dir_name("decomposer"); + dir = win32_decomposer_factory_module_dir; +#else + dir = FACTORY_MODULE_DIR; +#endif + } + return g_strdup(dir); +} + +static void +register_factory(ChupaDispatcherPrivate *priv, + const gchar *mime_type, ChupaModuleFactory *factory) +{ + gpointer key = (gpointer)mime_type, value = NULL; + + if (g_hash_table_lookup_extended(priv->mime_type_table, key, &key, &value)) { + g_hash_table_steal(priv->mime_type_table, key); + } + value = g_list_prepend((GList *)value, factory); + g_hash_table_insert(priv->mime_type_table, key, value); +} + +static void +unregister_factory(ChupaDispatcherPrivate *priv, + const gchar *mime_type, ChupaModuleFactory *factory) +{ + gpointer key = (gpointer)mime_type, value = NULL; + + if (g_hash_table_lookup_extended(priv->mime_type_table, key, &key, &value)) { + g_hash_table_steal(priv->mime_type_table, key); + value = g_list_remove((GList *)value, factory); + if (value) { + g_hash_table_insert(priv->mime_type_table, key, value); + } + } +} + +static void +load_factories (ChupaDispatcherPrivate *priv) +{ + GList *factories = NULL, *node; + GList *factory_names; + + factory_names = chupa_module_factory_get_names("decomposer"); + + for (node = factory_names; node; node = g_list_next(node)) { + ChupaModuleFactory *module_factory; + GList *mime_types; + + module_factory = chupa_module_factory_new("decomposer", node->data, NULL); + factories = g_list_prepend(factories, module_factory); + mime_types = chupa_module_factory_get_mime_types(module_factory); + for (; mime_types; mime_types = g_list_next(mime_types)) { + const gchar *mime_type = mime_types->data; + register_factory(priv, mime_type, module_factory); + } + } + + priv->factories = g_list_reverse(factories); +} + +static void +chupa_dispatcher_init (ChupaDispatcher *dispatcher) +{ + ChupaDispatcherPrivate *priv; + + priv = CHUPA_DISPATCHER_GET_PRIVATE(dispatcher); + priv->module_dir = detect_module_dir(); + priv->mime_type_table = g_hash_table_new_full(g_str_hash, g_str_equal, + NULL, module_list_free); + load_factories(priv); +} + +static void +dispose(GObject *object) +{ + ChupaDispatcherPrivate *priv; + + priv = CHUPA_DISPATCHER_GET_PRIVATE(object); + if (priv->module_dir) { + g_free(priv->module_dir); + priv->module_dir = NULL; + } + + if (priv->factories) { + g_list_foreach(priv->factories, (GFunc)g_object_unref, NULL); + g_list_free(priv->factories); + priv->factories = NULL; + } + + if (priv->mime_type_table) { + g_hash_table_unref(priv->mime_type_table); + priv->mime_type_table = NULL; + } + + G_OBJECT_CLASS(chupa_dispatcher_parent_class)->dispose(object); +} + +static void +set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) +{ + ChupaDispatcherPrivate *priv = CHUPA_DISPATCHER_GET_PRIVATE(object); + + switch (prop_id) { + case PROP_MODULE_DIR: + if (priv->module_dir) + g_free(priv->module_dir); + priv->module_dir = g_value_dup_string(value); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + break; + } +} + +static void +get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ + ChupaDispatcherPrivate *priv = CHUPA_DISPATCHER_GET_PRIVATE(object); + + switch (prop_id) { + case PROP_MODULE_DIR: + g_value_set_string(value, priv->module_dir); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + break; + } +} + +const gchar * +chupa_dispatcher_get_module_dir (ChupaDispatcher *dispatcher) +{ + return CHUPA_DISPATCHER_GET_PRIVATE(dispatcher)->module_dir; +} + +ChupaDispatcher * +chupa_dispatcher_new(void) +{ + return g_object_new(CHUPA_TYPE_DISPATCHER, NULL); +} + +ChupaDecomposer * +chupa_dispatcher_dispatch(ChupaDispatcher *dispatcher, const gchar *mime_type) +{ + ChupaDispatcherPrivate *priv; + GList *factories = NULL; + const char *sub_type; + gpointer key, value; + int retry = 0; + + priv = CHUPA_DISPATCHER_GET_PRIVATE(dispatcher); + do { + if (g_hash_table_lookup_extended(priv->mime_type_table, mime_type, + &key, &value)) { + factories = (GList *)value; + } + else if ((sub_type = strchr((const char *)mime_type, '/')) != NULL) { + GString *tmp_type = NULL; + ++sub_type; + if (sub_type[0] == 'x' && sub_type[1] == '-') { + tmp_type = g_string_new_len(mime_type, sub_type - mime_type); + g_string_append(tmp_type, sub_type += 2); + if (g_hash_table_lookup_extended(priv->mime_type_table, + tmp_type->str, &key, &value)) { + factories = (GList *)value; + } + } + if (tmp_type) { + g_string_free(tmp_type, TRUE); + } + } + } while (!factories && !retry++); + + if (!factories) { + return NULL; + } + return CHUPA_DECOMPOSER(chupa_module_factory_create(factories->data)); +} + +/* +vi:ts=4:nowrap:ai:expandtab:sw=4 +*/ Added: chupatext/chupa_dispatcher.h (+62 -0) 100644 =================================================================== --- /dev/null +++ chupatext/chupa_dispatcher.h 2010-09-26 13:45:18 +0000 (b83ef65) @@ -0,0 +1,62 @@ +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Copyright (C) 2007-2010 Kouhei Sutou + * + * 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 3 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 program. If not, see . + * + */ + +#ifndef __CHUPA_DISPATCHER_H__ +#define __CHUPA_DISPATCHER_H__ + +#include + +#include "chupatext/chupa_decomposer.h" + +G_BEGIN_DECLS + +#define CHUPA_TYPE_DISPATCHER (chupa_dispatcher_get_type ()) +#define CHUPA_DISPATCHER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CHUPA_TYPE_DISPATCHER, ChupaDispatcher)) +#define CHUPA_DISPATCHER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CHUPA_TYPE_DISPATCHER, ChupaDispatcherClass)) +#define CHUPA_IS_DISPATCHER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CHUPA_TYPE_DISPATCHER)) +#define CHUPA_IS_DISPATCHER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CHUPA_TYPE_DISPATCHER)) +#define CHUPA_DISPATCHER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), CHUPA_TYPE_DISPATCHER, ChupaDispatcherClass)) + +typedef struct _ChupaDispatcher ChupaDispatcher; +typedef struct _ChupaDispatcherClass ChupaDispatcherClass; + +struct _ChupaDispatcher +{ + GObject object; +}; + +struct _ChupaDispatcherClass +{ + GObjectClass parent_class; +}; + +GType chupa_dispatcher_get_type (void) G_GNUC_CONST; + +ChupaDispatcher *chupa_dispatcher_new (void); +const gchar *chupa_dispatcher_get_module_dir (ChupaDispatcher *builder); +ChupaDecomposer *chupa_dispatcher_dispatch (ChupaDispatcher *builder, + const gchar *mime_type); + +G_END_DECLS + +#endif /* __CHUPA_DISPATCHER_H__ */ + +/* +vi:ts=4:nowrap:ai:expandtab:sw=4 +*/ Deleted: chupatext/chupa_factory_builder.c (+0 -234) 100644 =================================================================== --- chupatext/chupa_factory_builder.c 2010-09-26 09:29:55 +0000 (1558b53) +++ /dev/null @@ -1,234 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * Copyright (C) 2007-2010 Kouhei Sutou - * - * 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 3 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 program. If not, see . - * - */ - -#ifdef HAVE_CONFIG_H -# include -#endif /* HAVE_CONFIG_H */ - -#include -#include - -#include "chupa_factory_builder.h" - -#define CHUPA_FACTORY_BUILDER_GET_PRIVATE(obj) \ - (G_TYPE_INSTANCE_GET_PRIVATE((obj), \ - CHUPA_TYPE_FACTORY_BUILDER, \ - ChupaFactoryBuilderPrivate)) - -typedef struct _ChupaFactoryBuilderPrivate ChupaFactoryBuilderPrivate; -struct _ChupaFactoryBuilderPrivate -{ - gchar *module_dir; - GOptionContext *option_context; - GList *factories; -}; - -enum -{ - PROP_0, - PROP_MODULE_DIR, - PROP_OPTION_CONTEXT -}; - -G_DEFINE_ABSTRACT_TYPE(ChupaFactoryBuilder, chupa_factory_builder, G_TYPE_OBJECT) - -static void dispose (GObject *object); -static void set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec); -static void get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec); -static void -chupa_factory_builder_class_init (ChupaFactoryBuilderClass *klass) -{ - GObjectClass *gobject_class; - GParamSpec *spec; - - gobject_class = G_OBJECT_CLASS(klass); - - gobject_class->dispose = dispose; - gobject_class->set_property = set_property; - gobject_class->get_property = get_property; - - spec = g_param_spec_string("module-dir", - "The name of the directory", - "The name of the directory in which includes target factory", - NULL, - G_PARAM_READWRITE); - g_object_class_install_property(gobject_class, PROP_MODULE_DIR, spec); - - spec = g_param_spec_pointer("option-context", - "GOptionContext", - "GOptionContext", - G_PARAM_READWRITE); - g_object_class_install_property(gobject_class, PROP_OPTION_CONTEXT, spec); - - g_type_class_add_private(gobject_class, sizeof(ChupaFactoryBuilderPrivate)); -} - -static void -chupa_factory_builder_init (ChupaFactoryBuilder *builder) -{ - ChupaFactoryBuilderPrivate *priv = CHUPA_FACTORY_BUILDER_GET_PRIVATE(builder); - - priv->module_dir = NULL; - priv->option_context = NULL; - priv->factories = NULL; -} - -static void -dispose (GObject *object) -{ - ChupaFactoryBuilderPrivate *priv = CHUPA_FACTORY_BUILDER_GET_PRIVATE(object); - - if (priv->module_dir) { - g_free(priv->module_dir); - priv->module_dir = NULL; - } - - if (priv->factories) { - g_list_free(priv->factories); - priv->factories = NULL; - } - priv->option_context = NULL; - - G_OBJECT_CLASS(chupa_factory_builder_parent_class)->dispose(object); -} - -static void -set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) -{ - ChupaFactoryBuilderPrivate *priv = CHUPA_FACTORY_BUILDER_GET_PRIVATE(object); - - switch (prop_id) { - case PROP_MODULE_DIR: - if (priv->module_dir) - g_free(priv->module_dir); - priv->module_dir = g_value_dup_string(value); - break; - case PROP_OPTION_CONTEXT: - priv->option_context = g_value_get_pointer(value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); - break; - } -} - -static void -get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - ChupaFactoryBuilderPrivate *priv = CHUPA_FACTORY_BUILDER_GET_PRIVATE(object); - - switch (prop_id) { - case PROP_MODULE_DIR: - g_value_set_string(value, priv->module_dir); - break; - case PROP_OPTION_CONTEXT: - g_value_set_pointer(value, priv->option_context); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); - break; - } -} - -const gchar * -chupa_factory_builder_get_type_name (ChupaFactoryBuilder *builder) -{ - ChupaFactoryBuilderClass *klass; - - g_return_val_if_fail(CHUPA_IS_FACTORY_BUILDER(builder), NULL); - - klass = CHUPA_FACTORY_BUILDER_GET_CLASS(builder); - if (klass->get_type_name) - return klass->get_type_name(builder); - - return NULL; -} - -const gchar * -chupa_factory_builder_get_module_dir (ChupaFactoryBuilder *builder) -{ - return CHUPA_FACTORY_BUILDER_GET_PRIVATE(builder)->module_dir; -} - -void -chupa_factory_builder_set_option_context (ChupaFactoryBuilder *builder, - GOptionContext *context) -{ - ChupaFactoryBuilderClass *klass; - ChupaFactoryBuilderPrivate *priv; - - priv = CHUPA_FACTORY_BUILDER_GET_PRIVATE(builder); - g_return_if_fail(CHUPA_IS_FACTORY_BUILDER(builder)); - - klass = CHUPA_FACTORY_BUILDER_GET_CLASS(builder); - g_return_if_fail(klass->set_option_context); - - priv->option_context = context; - klass->set_option_context(builder, context); -} - -GList * -chupa_factory_builder_build (ChupaFactoryBuilder *builder) -{ - ChupaFactoryBuilderClass *klass; - ChupaFactoryBuilderPrivate *priv; - - priv = CHUPA_FACTORY_BUILDER_GET_PRIVATE(builder); - g_return_val_if_fail(CHUPA_IS_FACTORY_BUILDER(builder), NULL); - - klass = CHUPA_FACTORY_BUILDER_GET_CLASS(builder); - g_return_val_if_fail(klass->build, NULL); - - priv->factories = klass->build(builder); - - return priv->factories; -} - -GList * -chupa_factory_builder_build_all (ChupaFactoryBuilder *builder) -{ - ChupaFactoryBuilderClass *klass; - ChupaFactoryBuilderPrivate *priv; - - priv = CHUPA_FACTORY_BUILDER_GET_PRIVATE(builder); - g_return_val_if_fail(CHUPA_IS_FACTORY_BUILDER(builder), NULL); - - klass = CHUPA_FACTORY_BUILDER_GET_CLASS(builder); - g_return_val_if_fail(klass->build_all, NULL); - - priv->factories = klass->build_all(builder); - - return priv->factories; -} - -/* -vi:ts=4:nowrap:ai:expandtab:sw=4 -*/ Deleted: chupatext/chupa_factory_builder.h (+0 -67) 100644 =================================================================== --- chupatext/chupa_factory_builder.h 2010-09-26 09:29:55 +0000 (3237c13) +++ /dev/null @@ -1,67 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * Copyright (C) 2007-2010 Kouhei Sutou - * - * 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 3 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 program. If not, see . - * - */ - -#ifndef __CHUPA_FACTORY_BUILDER_H__ -#define __CHUPA_FACTORY_BUILDER_H__ - -#include - -G_BEGIN_DECLS - -#define CHUPA_TYPE_FACTORY_BUILDER (chupa_factory_builder_get_type ()) -#define CHUPA_FACTORY_BUILDER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CHUPA_TYPE_FACTORY_BUILDER, ChupaFactoryBuilder)) -#define CHUPA_FACTORY_BUILDER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CHUPA_TYPE_FACTORY_BUILDER, ChupaFactoryBuilderClass)) -#define CHUPA_IS_FACTORY_BUILDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CHUPA_TYPE_FACTORY_BUILDER)) -#define CHUPA_IS_FACTORY_BUILDER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CHUPA_TYPE_FACTORY_BUILDER)) -#define CHUPA_FACTORY_BUILDER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), CHUPA_TYPE_FACTORY_BUILDER, ChupaFactoryBuilderClass)) - -typedef struct _ChupaFactoryBuilder ChupaFactoryBuilder; -typedef struct _ChupaFactoryBuilderClass ChupaFactoryBuilderClass; - -struct _ChupaFactoryBuilder -{ - GObject object; -}; - -struct _ChupaFactoryBuilderClass -{ - GObjectClass parent_class; - void (*set_option_context) (ChupaFactoryBuilder *builder, - GOptionContext *context); - GList *(*build) (ChupaFactoryBuilder *builder); - GList *(*build_all) (ChupaFactoryBuilder *builder); - const gchar *(*get_type_name) (ChupaFactoryBuilder *builder); -}; - -GType chupa_factory_builder_get_type (void) G_GNUC_CONST; -const gchar *chupa_factory_builder_get_type_name (ChupaFactoryBuilder *builder); -const gchar *chupa_factory_builder_get_module_dir (ChupaFactoryBuilder *builder); -void chupa_factory_builder_set_option_context - (ChupaFactoryBuilder *builder, - GOptionContext *context); -GList *chupa_factory_builder_build (ChupaFactoryBuilder *builder); -GList *chupa_factory_builder_build_all (ChupaFactoryBuilder *builder); - -G_END_DECLS - -#endif /* __CHUPA_FACTORY_BUILDER_H__ */ - -/* -vi:ts=4:nowrap:ai:expandtab:sw=4 -*/ Modified: chupatext/chupa_init.c (+7 -2) =================================================================== --- chupatext/chupa_init.c 2010-09-26 09:29:55 +0000 (b30bacd) +++ chupatext/chupa_init.c 2010-09-26 13:45:18 +0000 (9ac04de) @@ -3,19 +3,24 @@ * Copyright (C) 2010 Nobuyoshi Nakada */ -#include "chupa_private.h" #include +#include "chupa_private.h" +#include "chupa_module_factory_utils.h" + int chupa_init(void *var) { g_type_init(); - chupa_decomposer_load_modules(); + chupa_module_factory_init(); + chupa_module_factory_load(chupa_module_factory_get_module_dir(), + "decomposer"); return 0; } int chupa_cleanup(void) { + chupa_module_factory_quit(); return 0; } Modified: chupatext/chupa_module.c (+5 -9) =================================================================== --- chupatext/chupa_module.c 2010-09-26 09:29:55 +0000 (d817b50) +++ chupatext/chupa_module.c 2010-09-26 13:45:18 +0000 (ab7fc18) @@ -51,8 +51,6 @@ struct _ChupaModulePrivate G_DEFINE_TYPE(ChupaModule, chupa_module, G_TYPE_TYPE_MODULE) -static const char chupa_module_prefix[] = "chupa_"; - static void finalize(GObject *object); static gboolean load(GTypeModule *module); static void unload(GTypeModule *module); @@ -63,8 +61,6 @@ static void _chupa_module_close(GModule *module); static gboolean _chupa_module_load_func(GModule *module, const gchar *func_name, gpointer *symbol); -static gboolean _chupa_module_match_name(const gchar *mod_path, - const gchar *name); static void chupa_module_class_init(ChupaModuleClass *klass) @@ -301,14 +297,13 @@ chupa_module_stem_name(const gchar *name) { gchar *mod_name; - if (g_str_has_prefix(name, chupa_module_prefix)) - name += strlen(chupa_module_prefix); mod_name = g_strdup(name); if (g_str_has_suffix(mod_name, "."G_MODULE_SUFFIX)) { guint last_index; last_index = strlen(mod_name) - strlen("."G_MODULE_SUFFIX); mod_name[last_index] = '\0'; } + return mod_name; } @@ -321,11 +316,14 @@ chupa_module_new(const gchar *name, ChupaModule *module = g_object_new(CHUPA_TYPE_MODULE, NULL); ChupaModulePrivate *priv = CHUPA_MODULE_GET_PRIVATE(module); gchar *mod_name = chupa_module_stem_name(name); + g_type_module_set_name(G_TYPE_MODULE(module), mod_name); g_free(mod_name); + priv->init = init; priv->exit = exit; priv->instantiate = instantiate; + return module; } @@ -378,8 +376,6 @@ chupa_module_load_modules_unique(const gchar *base_dir, return exist_modules; while ((entry = g_dir_read_name(dir))) { - if (!g_str_has_prefix(entry, chupa_module_prefix)) - continue; if (!g_str_has_suffix(entry, "."G_MODULE_SUFFIX)) continue; if (chupa_module_find(exist_modules, entry)) @@ -459,7 +455,7 @@ gchar * chupa_module_dir(void) { const gchar *dir = g_getenv("CHUPA_MODULE_DIR"); - if (!dir && !g_dir_is_absolute(dir = CHUPA_MODULE_DIR)) { + if (!dir && !g_path_is_absolute(dir = CHUPA_MODULE_DIR)) { gchar *base_dir; #if defined G_OS_WIN32 base_dir = g_win32_get_package_installation_directory_of_module(chupa_dll); Added: chupatext/chupa_module_factory.c (+153 -0) 100644 =================================================================== --- /dev/null +++ chupatext/chupa_module_factory.c 2010-09-26 13:45:18 +0000 (d978906) @@ -0,0 +1,153 @@ +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Copyright (C) 2007-2010 Kouhei Sutou + * + * 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 3 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 program. If not, see . + * + */ + +#ifdef HAVE_CONFIG_H +# include +#endif /* HAVE_CONFIG_H */ + +#include +#include +/* #include */ + +#include "chupa_module.h" +#include "chupa_module_factory.h" +#include "chupa_module_factory_utils.h" + +#define CHUPA_MODULE_FACTORY_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE((obj), \ + CHUPA_TYPE_MODULE_FACTORY, \ + ChupaModuleFactoryPrivate)) + +typedef struct _ChupaModuleFactoryPrivate ChupaModuleFactoryPrivate; +struct _ChupaModuleFactoryPrivate +{ + GList *mime_types; +}; + +#define chupa_module_factory_init init +G_DEFINE_ABSTRACT_TYPE(ChupaModuleFactory, chupa_module_factory, G_TYPE_OBJECT) +#undef chupa_module_factory_init + +static void dispose (GObject *object); + +static void +chupa_module_factory_class_init (ChupaModuleFactoryClass *klass) +{ + GObjectClass *gobject_class; + + gobject_class = G_OBJECT_CLASS(klass); + + gobject_class->dispose = dispose; + + g_type_class_add_private(gobject_class, sizeof(ChupaModuleFactoryPrivate)); +} + +static void +init (ChupaModuleFactory *factory) +{ + ChupaModuleFactoryPrivate *priv; + + priv = CHUPA_MODULE_FACTORY_GET_PRIVATE(factory); + priv->mime_types = NULL; +} + +static void +dispose(GObject *object) +{ + ChupaModuleFactoryPrivate *priv; + + priv = CHUPA_MODULE_FACTORY_GET_PRIVATE(object); + if (priv->mime_types) { + g_list_foreach(priv->mime_types, (GFunc)g_free, NULL); + g_list_free(priv->mime_types); + priv->mime_types = NULL; + } + + G_OBJECT_CLASS(chupa_module_factory_parent_class)->dispose(object); +} + +ChupaModuleFactory * +chupa_module_factory_new_valist (const gchar *type, const gchar *name, + const gchar *first_property, va_list var_args) +{ + ChupaModule *module; + GObject *factory; + + module = chupa_module_factory_load_module(type, name); + g_return_val_if_fail(module != NULL, NULL); + + factory = chupa_module_instantiate(module, first_property, var_args); + + return CHUPA_MODULE_FACTORY(factory); +} + +ChupaModuleFactory * +chupa_module_factory_new (const gchar *type, const gchar *name, + const gchar *first_property, ...) +{ + ChupaModule *module; + GObject *factory; + va_list var_args; + + module = chupa_module_factory_load_module(type, name); + if (!module) + return NULL; + + va_start(var_args, first_property); + factory = chupa_module_instantiate(module, first_property, var_args); + va_end(var_args); + + return CHUPA_MODULE_FACTORY(factory); +} + +GObject * +chupa_module_factory_create(ChupaModuleFactory *factory) +{ + ChupaModuleFactoryClass *klass; + + g_return_val_if_fail(CHUPA_IS_MODULE_FACTORY(factory), NULL); + + klass = CHUPA_MODULE_FACTORY_GET_CLASS(factory); + g_return_val_if_fail(klass->create, NULL); + + return klass->create(factory); +} + +GList * +chupa_module_factory_get_mime_types(ChupaModuleFactory *factory) +{ + ChupaModuleFactoryPrivate *priv; + + g_return_val_if_fail(CHUPA_IS_MODULE_FACTORY(factory), NULL); + + priv = CHUPA_MODULE_FACTORY_GET_PRIVATE(factory); + if (!priv->mime_types) { + ChupaModuleFactoryClass *klass; + klass = CHUPA_MODULE_FACTORY_GET_CLASS(factory); + g_return_val_if_fail(klass->get_mime_types, NULL); + priv->mime_types = klass->get_mime_types(factory); + } + + return priv->mime_types; +} + + +/* +vi:ts=4:nowrap:ai:expandtab:sw=4 +*/ Added: chupatext/chupa_module_factory.h (+74 -0) 100644 =================================================================== --- /dev/null +++ chupatext/chupa_module_factory.h 2010-09-26 13:45:18 +0000 (5ff2a6e) @@ -0,0 +1,74 @@ +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Copyright (C) 2007-2010 Kouhei Sutou + * + * 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 3 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 program. If not, see . + * + */ + +#ifndef __CHUPA_MODULE_FACTORY_H__ +#define __CHUPA_MODULE_FACTORY_H__ + +#include + +#include + +G_BEGIN_DECLS + +#define CHUPA_TYPE_MODULE_FACTORY (chupa_module_factory_get_type ()) +#define CHUPA_MODULE_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CHUPA_TYPE_MODULE_FACTORY, ChupaModuleFactory)) +#define CHUPA_MODULE_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CHUPA_TYPE_MODULE_FACTORY, ChupaModuleFactoryClass)) +#define CHUPA_IS_MODULE_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CHUPA_TYPE_MODULE_FACTORY)) +#define CHUPA_IS_MODULE_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CHUPA_TYPE_MODULE_FACTORY)) +#define CHUPA_MODULE_FACTORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), CHUPA_TYPE_MODULE_FACTORY, ChupaModuleFactoryClass)) + +typedef struct _ChupaModuleFactory ChupaModuleFactory; +typedef struct _ChupaModuleFactoryClass ChupaModuleFactoryClass; + +struct _ChupaModuleFactory +{ + GObject object; +}; + +struct _ChupaModuleFactoryClass +{ + GObjectClass parent_class; + + GObject *(*create) (ChupaModuleFactory *factory); + GList *(*get_mime_types) (ChupaModuleFactory *factory); +}; + +GType chupa_module_factory_get_type (void) G_GNUC_CONST; + +ChupaModuleFactory *chupa_module_factory_new (const gchar *type, + const gchar *name, + const gchar *first_property, + ...); +ChupaModuleFactory *chupa_module_factory_new_valist + (const gchar *type, + const gchar *name, + const gchar *first_property, + va_list var_args); + +GObject *chupa_module_factory_create (ChupaModuleFactory *factory); + +GList *chupa_module_factory_get_mime_types(ChupaModuleFactory *factory); + +G_END_DECLS + +#endif /* __CHUPA_MODULE_FACTORY_H__ */ + +/* +vi:ts=4:nowrap:ai:expandtab:sw=4 +*/ Added: chupatext/chupa_module_factory_utils.c (+241 -0) 100644 =================================================================== --- /dev/null +++ chupatext/chupa_module_factory_utils.c 2010-09-26 13:45:18 +0000 (d79b6a5) @@ -0,0 +1,241 @@ +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Copyright (C) 2007-2010 Kouhei Sutou + * + * 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 3 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 program. If not, see . + * + */ + +#ifdef HAVE_CONFIG_H +# include +#endif /* HAVE_CONFIG_H */ + +#include +#include +/* #include */ + +#include "chupa_utils.h" +#include "chupa_module.h" +#include "chupa_module_factory_utils.h" + +static gchar *module_dir = NULL; +static GHashTable *factories = NULL; +#ifdef G_OS_WIN32 +static gchar *win32_factory_module_dir = NULL; +#endif + + +static void +unload_modules (gpointer data) +{ + GList *modules = (GList *)data; + g_list_foreach(modules, (GFunc)chupa_module_unload, NULL); + g_list_free(modules); +} + +void +chupa_module_factory_init (void) +{ + factories = g_hash_table_new_full(g_str_hash, + g_str_equal, + g_free, + unload_modules); +} + +void +chupa_module_factory_quit (void) +{ + chupa_module_factory_unload(); + chupa_module_factory_set_default_module_dir(NULL); +} + +const gchar * +chupa_module_factory_get_default_module_dir (void) +{ + return module_dir; +} + +void +chupa_module_factory_set_default_module_dir (const gchar *dir) +{ + if (module_dir) + g_free(module_dir); + module_dir = NULL; + + if (dir) + module_dir = g_strdup(dir); +} + +const gchar * +chupa_module_factory_get_module_dir (void) +{ + const gchar *dir; + + if (module_dir) + return module_dir; + + dir = g_getenv("CHUPA_FACTORY_DIR"); + if (dir) + return dir; + +#ifdef G_OS_WIN32 + if (!win32_factory_module_dir) + win32_factory_module_dir = + chupa_win32_build_factory_module_dir_name(NULL); + return win32_factory_module_dir; +#else + return FACTORY_MODULE_DIR; +#endif +} + +void +chupa_module_factory_load (const gchar *dir, const gchar *type) +{ + if (g_file_test(dir, G_FILE_TEST_IS_DIR)) { + GList *modules; + + modules = chupa_module_load_modules(dir); + + if (modules) + g_hash_table_replace(factories, g_strdup(type), modules); + } +} + +void +chupa_module_factory_load_all (const gchar *base_dir) +{ + GDir *gdir; + const gchar *entry; + + if (!base_dir) + base_dir = chupa_module_factory_get_module_dir(); + + gdir = g_dir_open(base_dir, 0, NULL); + if (!gdir) + return; + + while ((entry = g_dir_read_name(gdir))) { + gchar *dir_name; + + dir_name = g_build_filename(base_dir, entry, NULL); + if (g_file_test(dir_name, G_FILE_TEST_IS_DIR)) { + GList *modules; + + modules = chupa_module_load_modules(dir_name); + if (!modules) { + gchar *libs_dir; + + libs_dir = g_build_filename(dir_name, ".libs", NULL); + if (g_file_test(libs_dir, G_FILE_TEST_IS_DIR)) + modules = chupa_module_load_modules(libs_dir); + g_free(libs_dir); + } + if (modules) + g_hash_table_replace(factories, g_strdup(entry), modules); + } + g_free(dir_name); + } + g_dir_close(gdir); +} + +ChupaModule * +chupa_module_factory_load_module (const gchar *type, const gchar *name) +{ + ChupaModule *module; + GList *modules = NULL; + gchar *real_name; + gchar *separators[] = {"_", "-", NULL}; + gchar **separators_p; + + modules = g_hash_table_lookup(factories, type); + if (!modules) + return NULL; + + for (separators_p = separators; *separators_p; separators_p++) { + real_name = g_strconcat(name, *separators_p, "factory", NULL); + module = chupa_module_find(modules, real_name); + if (module) { + g_free(real_name); + return module; + } + + module = chupa_module_load_module(chupa_module_factory_get_module_dir(), + real_name); + g_free(real_name); + if (module) { + if (g_type_module_use(G_TYPE_MODULE(module))) { + modules = g_list_prepend(modules, module); + g_type_module_unuse(G_TYPE_MODULE(module)); + g_hash_table_replace(factories, g_strdup(type), modules); + } + return module; + } + } + + return NULL; +} + +void +chupa_module_factory_unload (void) +{ + if (!factories) + return; + + g_hash_table_unref(factories); + factories = NULL; +} + +GList * +chupa_module_factory_get_names (const gchar *type) +{ + GList *modules, *orig_names, *node, *names = NULL; + + modules = g_hash_table_lookup(factories, type); + if (!modules) + return NULL; + + orig_names = chupa_module_collect_names(modules); + for (node = orig_names; node; node = g_list_next(node)) { + const gchar *name = node->data; + + if (g_str_has_suffix(name, "_factory") || + g_str_has_suffix(name, "-factory")) { + gchar *p; + p = g_strrstr(name, "factory") - 1; + names = g_list_prepend(names, g_strndup(name, p - name)); + } + } + g_list_free(orig_names); + return g_list_reverse(names); +} + +gboolean +chupa_module_factory_exist_module (const gchar *type, const gchar *name) +{ + GList *names, *list; + + names = chupa_module_factory_get_names(type); + if (!names) + return FALSE; + list= g_list_find_custom(names, name, (GCompareFunc)strcmp); + + g_list_foreach(names, (GFunc)g_free, NULL); + g_list_free(names); + + return (list != NULL); +} + +/* +vi:ts=4:nowrap:ai:expandtab:sw=4 +*/ Added: chupatext/chupa_module_factory_utils.h (+52 -0) 100644 =================================================================== --- /dev/null +++ chupatext/chupa_module_factory_utils.h 2010-09-26 13:45:18 +0000 (84a5fa4) @@ -0,0 +1,52 @@ +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Copyright (C) 2007-2010 Kouhei Sutou + * + * 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 3 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 program. If not, see . + * + */ + +#ifndef __CHUPA_MODULE_FACTORY_UTILS_H__ +#define __CHUPA_MODULE_FACTORY_UTILS_H__ + +#include + +#include + +G_BEGIN_DECLS + +void chupa_module_factory_init (void); +void chupa_module_factory_quit (void); + +const gchar *chupa_module_factory_get_default_module_dir (void); +void chupa_module_factory_set_default_module_dir (const gchar *dir); +const gchar *chupa_module_factory_get_module_dir (void); + +void chupa_module_factory_load (const gchar *dir, + const gchar *type); +void chupa_module_factory_load_all (const gchar *base_dir); +void chupa_module_factory_unload (void); +GList *chupa_module_factory_get_names (const gchar *type); +gboolean chupa_module_factory_exist_module(const gchar *type, + const gchar *name); +ChupaModule *chupa_module_factory_load_module (const gchar *type, + const gchar *name); + +G_END_DECLS + +#endif /* __CHUPA_MODULE_FACTORY_UTILS_H__ */ + +/* +vi:ts=4:nowrap:ai:expandtab:sw=4 +*/ Modified: chupatext/chupa_text.c (+30 -9) =================================================================== --- chupatext/chupa_text.c 2010-09-26 09:29:55 +0000 (0743ae4) +++ chupatext/chupa_text.c 2010-09-26 13:45:18 +0000 (0d68bc5) @@ -5,14 +5,19 @@ #include "chupatext/chupa_text.h" #include "chupatext/chupa_decomposer.h" +#include "chupatext/chupa_dispatcher.h" +#include "chupatext/chupa_module_factory_utils.h" + +#define CHUPA_TEXT_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE((obj), \ + CHUPA_TYPE_TEXT, \ + ChupaTextPrivate)) G_DEFINE_TYPE(ChupaText, chupa_text, G_TYPE_OBJECT) -#ifdef USE_CHUPA_TEXT_PRIVATE typedef struct ChupaTextPrivate { - + ChupaDispatcher *dispatcher; } ChupaTextPrivate; -#endif const char chupa_text_signal_decomposed[] = "decomposed"; @@ -23,15 +28,16 @@ enum { static gint gsignals[LAST_SIGNAL] = {0}; +static void dispose (GObject *object); + static void chupa_text_class_init(ChupaTextClass *klass) { GObjectClass *gobject_class = G_OBJECT_CLASS(klass); - /*GTypeModuleClass *type_module_class = G_TYPE_MODULE_CLASS(klass);*/ -#ifdef USE_CHUPA_TEXT_PRIVATE g_type_class_add_private(gobject_class, sizeof(ChupaTextPrivate)); -#endif + + gobject_class->dispose = dispose; gsignals[DECOMPOSED] = g_signal_new(chupa_text_signal_decomposed, @@ -46,11 +52,24 @@ chupa_text_class_init(ChupaTextClass *klass) static void chupa_text_init(ChupaText *chupar) { -#ifdef USE_CHUPA_TEXT_PRIVATE ChupaTextPrivate *priv; priv = CHUPA_TEXT_GET_PRIVATE(chupar); -#endif + + priv->dispatcher = chupa_dispatcher_new(); +} + +static void +dispose (GObject *object) +{ + ChupaTextPrivate *priv = CHUPA_TEXT_GET_PRIVATE(object); + + if (priv->dispatcher) { + g_object_unref(priv->dispatcher); + priv->dispatcher = NULL; + } + + G_OBJECT_CLASS(chupa_text_parent_class)->dispose(object); } /** @@ -111,6 +130,7 @@ chupa_text_connect_decomposed(ChupaText *chupar, ChupaTextCallback func, gpointe gboolean chupa_text_feed(ChupaText *chupar, ChupaTextInput *input, GError **error) { + ChupaTextPrivate *priv; const char *mime_type = NULL; ChupaDecomposer *dec; GError *e; @@ -120,6 +140,7 @@ chupa_text_feed(ChupaText *chupar, ChupaTextInput *input, GError **error) g_return_val_if_fail(input != NULL, FALSE); g_return_val_if_fail(error == NULL || *error == NULL, FALSE); + priv = CHUPA_TEXT_GET_PRIVATE(chupar); mime_type = chupa_text_input_get_mime_type(input); if (!mime_type) { @@ -128,7 +149,7 @@ chupa_text_feed(ChupaText *chupar, ChupaTextInput *input, GError **error) g_propagate_error(error, e); result = FALSE; } - else if (dec = chupa_decomposer_search(mime_type)) { + else if ((dec = chupa_dispatcher_dispatch(priv->dispatcher, mime_type))) { result = chupa_decomposer_feed(dec, chupar, input, error); g_object_unref(dec); result = TRUE; Added: chupatext/chupa_utils.c (+77 -0) 100644 =================================================================== --- /dev/null +++ chupatext/chupa_utils.c 2010-09-26 13:45:18 +0000 (639b58f) @@ -0,0 +1,77 @@ +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Copyright (C) 2007-2010 Kouhei Sutou + * + * 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 3 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 program. If not, see . + * + */ + +#ifdef HAVE_CONFIG_H +# include +#endif /* HAVE_CONFIG_H */ + +#include +#include +#ifdef HAVE_UNISTD_H +# include +#endif +#include +#include +#ifdef G_OS_WIN32 +# include +# include +# define close _close +#endif + +#include + +#include "chupa_utils.h" + +#ifdef G_OS_WIN32 +static gchar *win32_base_path = NULL; + +const gchar * +chupa_win32_base_path (void) +{ + if (win32_base_path) + return win32_base_path; + + win32_base_path = g_win32_get_package_installation_directory_of_module(NULL); + + return win32_base_path; +} + +gchar * +chupa_win32_build_module_dir_name (const gchar *type) +{ + return g_build_filename(chupa_win32_base_path(), "lib", PACKAGE, + "module", type, NULL); +} + +gchar * +chupa_win32_build_factory_module_dir_name (const gchar *type) +{ + gchar *module_dir, *factory_module_dir; + + module_dir = chupa_win32_build_module_dir_name("factory"); + factory_module_dir = g_build_filename(module_dir, type, NULL); + g_free(module_dir); + return factory_module_dir; +} +#endif + + +/* +vi:ts=4:nowrap:ai:expandtab:sw=4 +*/ Added: chupatext/chupa_utils.h (+39 -0) 100644 =================================================================== --- /dev/null +++ chupatext/chupa_utils.h 2010-09-26 13:45:18 +0000 (ab193fe) @@ -0,0 +1,39 @@ +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Copyright (C) 2007-2010 Kouhei Sutou + * + * 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 3 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 program. If not, see . + * + */ + +#ifndef __CHUPA_UTILS_H__ +#define __CHUPA_UTILS_H__ + +#include + +G_BEGIN_DECLS + +#ifdef G_OS_WIN32 +const gchar *chupa_win32_base_path (void); +gchar *chupa_win32_build_module_dir_name (const gchar *type); +gchar *chupa_win32_build_factory_module_dir_name (const gchar *type); +#endif + +G_END_DECLS + +#endif /* __CHUPA_UTILS_H__ */ + +/* +vi:ts=4:nowrap:ai:expandtab:sw=4 +*/ Modified: configure.ac (+33 -0) =================================================================== --- configure.ac 2010-09-26 09:29:55 +0000 (f27775f) +++ configure.ac 2010-09-26 13:45:18 +0000 (3eccba1) @@ -39,6 +39,33 @@ AC_PROG_INSTALL AC_PROG_LN_S AC_PROG_MAKE_SET +if test "x$GCC" = "xyes"; then + case " $CFLAGS " in + *[\ \ ]-Wall[\ \ ]*) ;; + *) CFLAGS="$CFLAGS -Wall" ;; + esac + + case " $CFLAGS " in + *[\ \ ]-Wmissing-declarations[\ \ ]*) ;; + *) CFLAGS="$CFLAGS -Wmissing-declarations" ;; + esac + + case " $CFLAGS " in + *[\ \ ]-Wmissing-prototypes[\ \ ]*) ;; + *) CFLAGS="$CFLAGS -Wmissing-prototypes" ;; + esac + + case " $CFLAGS " in + *[\ \ ]-Wpointer-arith[\ \ ]*) ;; + *) CFLAGS="$CFLAGS -Wpointer-arith" ;; + esac + + case " $CFLAGS " in + *[\ \ ]-Wcast-align[\ \ ]*) ;; + *) CFLAGS="$CFLAGS -Wcast-align" ;; + esac +fi + m4_ifdef([AM_PATH_GLIB_2_0], [ GLIB_REQUIRED=2.24.0 AC_SUBST(GLIB_REQUIRED) @@ -84,6 +111,12 @@ GENHTML_OPTIONS="--title 'chupatext Code Coverage'" moduledir='$(pkglibdir)/module' AC_SUBST(moduledir) +decomposerdir='$(moduledir)/decomposer' +AC_SUBST(decomposerdir) + +factorydir='$(moduledir)/factory' +AC_SUBST(factorydir) + AC_SUBST(build_includedir, '$(top_build_prefix)') AC_SUBST(top_includedir, '$(top_srcdir)') Modified: module/Makefile.am (+18 -14) =================================================================== --- module/Makefile.am 2010-09-26 09:29:55 +0000 (58eb5ea) +++ module/Makefile.am 2010-09-26 13:45:18 +0000 (7d1d43a) @@ -1,23 +1,22 @@ EMPTY = -AM_CFLAGS = $(GSF_CFLAGS) -AM_LDFLAGS = $(GSF_LIBS) - LDFLAGS = -L$(top_builddir)/chupatext -lchupatext -module_LTLIBRARIES = -module_LTLIBRARIES += chupa_tar.la -module_LTLIBRARIES += chupa_zip.la +decomposer_LTLIBRARIES = +factory_LTLIBRARIES = +decomposer_LTLIBRARIES += chupa_tar.la +decomposer_LTLIBRARIES += chupa_zip.la if HAVE_POPPLER_GLIB -module_LTLIBRARIES += chupa_pdf.la +decomposer_LTLIBRARIES += pdf.la +factory_LTLIBRARIES += pdf_factory.la endif if HAVE_WV -module_LTLIBRARIES += chupa_msword.la +decomposer_LTLIBRARIES += chupa_msword.la endif if HAVE_GOFFICE -module_LTLIBRARIES += chupa_msexcel.la +decomposer_LTLIBRARIES += chupa_msexcel.la endif -module_LTLIBRARIES += chupa_mspowerpoint.la +decomposer_LTLIBRARIES += chupa_mspowerpoint.la chupa_tar_la_SOURCES = chupa_tar.c chupa_tar_la_LDFLAGS = -module @@ -29,10 +28,15 @@ chupa_zip_la_LDFLAGS = -module chupa_zip_la_CPPFLAGS = $(GSF_CFLAGS) chupa_zip_la_LIBADD = $(GSF_LIBS) -chupa_pdf_la_SOURCES = chupa_pdf.c -chupa_pdf_la_LDFLAGS = -module -chupa_pdf_la_CPPFLAGS = $(POPPLER_GLIB_CFLAGS) -chupa_pdf_la_LIBADD = $(POPPLER_GLIB_LIBS) $(GSF_LIBS) +pdf_la_SOURCES = pdf.c +pdf_la_LDFLAGS = -module +pdf_la_CPPFLAGS = $(POPPLER_GLIB_CFLAGS) $(GSF_CFLAGS) +pdf_la_LIBADD = $(POPPLER_GLIB_LIBS) $(GSF_LIBS) + +pdf_factory_la_SOURCES = pdf_factory.c +pdf_factory_la_LDFLAGS = -module +pdf_factory_la_CPPFLAGS = $(GLIB_CFLAGS) $(GSF_CFLAGS) +pdf_factory_la_LIBADD = $(GLIB_LIBS) chupa_msword_la_SOURCES = chupa_msword.c chupa_msword_la_LDFLAGS = -module Renamed: module/pdf.c (+1 -1) 98% =================================================================== --- module/chupa_pdf.c 2010-09-26 09:29:55 +0000 (20819ac) +++ module/pdf.c 2010-09-26 13:45:18 +0000 (c4efabe) @@ -125,7 +125,7 @@ register_type(GTypeModule *type_module) "ChupaPDFDecomposer", &info, 0); chupa_type_pdf_decomposer = type; - chupa_decomposer_register("application/pdf", type); + POPPLER_TYPE_DOCUMENT; } return type; } Added: module/pdf_factory.c (+159 -0) 100644 =================================================================== --- /dev/null +++ module/pdf_factory.c 2010-09-26 13:45:18 +0000 (62c238f) @@ -0,0 +1,159 @@ +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Copyright (C) 2010 Kouhei Sutou + * + * 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 3 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 program. If not, see . + * + */ + +#ifdef HAVE_CONFIG_H +# include +#endif /* HAVE_CONFIG_H */ + +#include +#include +#include +/* #include */ +#include + +#include +#include +#include + +#define CHUPA_TYPE_PDF_FACTORY chupa_type_pdf_factory +#define CHUPA_PDF_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CHUPA_TYPE_PDF_FACTORY, ChupaPDFFactory)) +#define CHUPA_PDF_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CHUPA_TYPE_PDF_FACTORY, ChupaPDFFactoryClass)) +#define CHUPA_IS_PDF_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CHUPA_TYPE_PDF_FACTORY)) +#define CHUPA_IS_PDF_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CHUPA_TYPE_PDF_FACTORY)) +#define CHUPA_PDF_FACTORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), CHUPA_TYPE_PDF_FACTORY, ChupaPDFFactoryClass)) + +typedef struct _ChupaPDFFactory ChupaPDFFactory; +typedef struct _ChupaPDFFactoryClass ChupaPDFFactoryClass; + +struct _ChupaPDFFactory +{ + ChupaModuleFactory object; +}; + +struct _ChupaPDFFactoryClass +{ + ChupaModuleFactoryClass parent_class; +}; + +static GType chupa_type_pdf_factory = 0; +static ChupaModuleFactoryClass *parent_class; + +static GList *get_mime_types (ChupaModuleFactory *factory); +static GObject *create (ChupaModuleFactory *factory); + +static void +class_init (ChupaModuleFactoryClass *klass) +{ + GObjectClass *gobject_class; + ChupaModuleFactoryClass *factory_class; + + parent_class = g_type_class_peek_parent(klass); + + gobject_class = G_OBJECT_CLASS(klass); + factory_class = CHUPA_MODULE_FACTORY_CLASS(klass); + + factory_class->get_mime_types = get_mime_types; + factory_class->create = create; +} + +static void +init (ChupaPDFFactory *factory) +{ +} + +static void +register_type (GTypeModule *type_module) +{ + static const GTypeInfo info = + { + sizeof (ChupaPDFFactoryClass), + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) class_init, + NULL, /* class_finalize */ + NULL, /* class_data */ + sizeof(ChupaPDFFactory), + 0, + (GInstanceInitFunc) init, + }; + + chupa_type_pdf_factory = + g_type_module_register_type(type_module, + CHUPA_TYPE_MODULE_FACTORY, + "ChupaPDFFactory", + &info, 0); +} + +G_MODULE_EXPORT GList * +CHUPA_MODULE_IMPL_INIT (GTypeModule *type_module) +{ + GList *registered_types = NULL; + + register_type(type_module); + if (chupa_type_pdf_factory) { + registered_types = + g_list_prepend(registered_types, + (gchar *)g_type_name(chupa_type_pdf_factory)); + } + + return registered_types; +} + +G_MODULE_EXPORT void +CHUPA_MODULE_IMPL_EXIT (void) +{ +} + +G_MODULE_EXPORT GObject * +CHUPA_MODULE_IMPL_INSTANTIATE (const gchar *first_property, va_list var_args) +{ + return g_object_new_valist(CHUPA_TYPE_PDF_FACTORY, first_property, var_args); +} + +static GList * +get_mime_types (ChupaModuleFactory *factory) +{ + GList *mime_types = NULL; + + mime_types = g_list_prepend(mime_types, g_strdup("application/pdf")); + + return mime_types; +} + +GObject * +create (ChupaModuleFactory *factory) +{ + static int n_instances = 0; + GObject *decomposer; + + decomposer = G_OBJECT(chupa_decomposer_new("pdf", NULL)); + n_instances++; + if (n_instances == 1) { + /* FIXME: This causes memory leak but we need to + * keep at least 1 decomposer instance to avoid + * duplicated non-module GType + * (e.g. PopplerDocument) registration. */ + g_object_ref(decomposer); + } + return decomposer; +} + +/* +vi:ts=4:nowrap:ai:expandtab:sw=4 +*/ Modified: test/Makefile.am (+13 -10) =================================================================== --- test/Makefile.am 2010-09-26 09:29:55 +0000 (903733f) +++ test/Makefile.am 2010-09-26 13:45:18 +0000 (8e7f75d) @@ -5,16 +5,17 @@ if WITH_CUTTER TESTS = run-test.sh TESTS_ENVIRONMENT = NO_MAKE=yes CUTTER="$(CUTTER)" -noinst_LTLIBRARIES = \ - test_metadata.la \ - test_text.la \ - test_text_input.la \ - test_text_input_stream.la \ - test_decomposer.la \ - test_external_decomposer.la \ - test_restrict_input_stream.la \ - test_tar.la \ - test_zip.la \ +noinst_LTLIBRARIES = \ + suite_chupatext_test.la \ + test_metadata.la \ + test_text.la \ + test_text_input.la \ + test_text_input_stream.la \ + test_decomposer.la \ + test_external_decomposer.la \ + test_restrict_input_stream.la \ + test_tar.la \ + test_zip.la \ $(EMPTY) if HAVE_POPPLER_GLIB @@ -59,6 +60,8 @@ LIBS = \ $(GSF_LIBS) \ $(EMPTY) +suite_chupatext_test_la_SOURCES = suite_chupatext_test.c + test_metadata_la_SOURCES = test_metadata.c test_text_la_SOURCES = test_text.c chupa_test_util.c test_text_input_la_SOURCES = test_text_input.c Modified: test/run-test.sh (+2 -1) =================================================================== --- test/run-test.sh 2010-09-26 09:29:55 +0000 (70cdc91) +++ test/run-test.sh 2010-09-26 13:45:18 +0000 (ab1506d) @@ -87,6 +87,7 @@ export CHUPATEXT_RUBYLIB export RUBYLIB export CHUPATEXT_CONFIGURATION_MODULE_DIR=$builddir/module/configuration/ruby/.libs export CHUPATEXT_CONFIG_DIR=$top_srcdir/test/fixtures/configuration -export CHUPA_MODULE_DIR=$builddir/module/.libs +export CHUPA_DECOMPOSER_DIR=$builddir/module/.libs +export CHUPA_FACTORY_DIR=$builddir/module/.libs $CUTTER_WRAPPER $CUTTER $CUTTER_ARGS "$@" "$testdir" Added: test/suite_chupatext_test.c (+35 -0) 100644 =================================================================== --- /dev/null +++ test/suite_chupatext_test.c 2010-09-26 13:45:18 +0000 (77779b2) @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2010 Kouhei Sutou + * + * 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 3 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 program. If not, see . + * + */ + +#include + +void chupatext_test_warmup(void); +void chupatext_test_cooldown(void); + +void +chupatext_test_warmup(void) +{ + int variable; + chupa_init(&variable); +} + +void +chupatext_test_cooldown(void) +{ + chupa_cleanup(); +} From null+ranguba at clear-code.com Sun Sep 26 10:00:02 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Sun, 26 Sep 2010 14:00:02 +0000 Subject: [groonga-commit:1325] ranguba/chupatext [master] fix type name. Message-ID: <20100926140015.8C4F5170640@taiyaki.ru> Kouhei Sutou 2010-09-26 14:00:02 +0000 (Sun, 26 Sep 2010) New Revision: 13c6904a3ef86f43ea03ad3790080adc31d0a471 Log: fix type name. Modified files: module/word.c Modified: module/word.c (+22 -22) =================================================================== --- module/word.c 2010-09-26 13:57:09 +0000 (68a1f92) +++ module/word.c 2010-09-26 14:00:02 +0000 (6003090) @@ -9,27 +9,27 @@ #include #include -#define CHUPA_TYPE_MSWORD_DECOMPOSER chupa_type_msword_decomposer -#define CHUPA_MSWORD_DECOMPOSER(obj) \ - G_TYPE_CHECK_INSTANCE_CAST(obj, CHUPA_TYPE_MSWORD_DECOMPOSER, ChupaMSWORDDecomposer) -#define CHUPA_MSWORD_DECOMPOSER_CLASS(klass) \ - G_TYPE_CHECK_CLASS_CAST(klass, CHUPA_TYPE_MSWORD_DECOMPOSER, ChupaMSWORDDecomposerClass) -#define CHUPA_IS_MSWORD_DECOMPOSER(obj) \ - G_TYPE_CHECK_INSTANCE_TYPE(obj, CHUPA_TYPE_MSWORD_DECOMPOSER) -#define CHUPA_IS_MSWORD_DECOMPOSER_CLASS(klass) \ - G_TYPE_CHECK_CLASS_TYPE(klass, CHUPA_TYPE_MSWORD_DECOMPOSER) -#define CHUPA_MSWORD_DECOMPOSER_GET_CLASS(obj) \ - G_TYPE_INSTANCE_GET_CLASS(obj, CHUPA_TYPE_MSWORD_DECOMPOSER, ChupaMSWORDDecomposerClass) - -typedef struct _ChupaMSWORDDecomposer ChupaMSWORDDecomposer; -typedef struct _ChupaMSWORDDecomposerClass ChupaMSWORDDecomposerClass; - -struct _ChupaMSWORDDecomposer +#define CHUPA_TYPE_WORD_DECOMPOSER chupa_type_msword_decomposer +#define CHUPA_WORD_DECOMPOSER(obj) \ + G_TYPE_CHECK_INSTANCE_CAST(obj, CHUPA_TYPE_WORD_DECOMPOSER, ChupaWordDecomposer) +#define CHUPA_WORD_DECOMPOSER_CLASS(klass) \ + G_TYPE_CHECK_CLASS_CAST(klass, CHUPA_TYPE_WORD_DECOMPOSER, ChupaWordDecomposerClass) +#define CHUPA_IS_WORD_DECOMPOSER(obj) \ + G_TYPE_CHECK_INSTANCE_TYPE(obj, CHUPA_TYPE_WORD_DECOMPOSER) +#define CHUPA_IS_WORD_DECOMPOSER_CLASS(klass) \ + G_TYPE_CHECK_CLASS_TYPE(klass, CHUPA_TYPE_WORD_DECOMPOSER) +#define CHUPA_WORD_DECOMPOSER_GET_CLASS(obj) \ + G_TYPE_INSTANCE_GET_CLASS(obj, CHUPA_TYPE_WORD_DECOMPOSER, ChupaWordDecomposerClass) + +typedef struct _ChupaWordDecomposer ChupaWordDecomposer; +typedef struct _ChupaWordDecomposerClass ChupaWordDecomposerClass; + +struct _ChupaWordDecomposer { ChupaDecomposer object; }; -struct _ChupaMSWORDDecomposerClass +struct _ChupaWordDecomposerClass { ChupaDecomposerClass parent_class; }; @@ -172,7 +172,7 @@ chupa_msword_decomposer_feed(ChupaDecomposer *dec, ChupaText *chupar, } static void -chupa_msword_decomposer_class_init(ChupaMSWORDDecomposerClass *klass) +chupa_msword_decomposer_class_init(ChupaWordDecomposerClass *klass) { ChupaDecomposerClass *super = CHUPA_DECOMPOSER_CLASS(klass); super->feed = chupa_msword_decomposer_feed; @@ -182,13 +182,13 @@ static GType register_type(GTypeModule *type_module) { static const GTypeInfo info = { - sizeof(ChupaMSWORDDecomposerClass), + sizeof(ChupaWordDecomposerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) chupa_msword_decomposer_class_init, NULL, /* class_finalize */ NULL, /* class_data */ - sizeof(ChupaMSWORDDecomposer), + sizeof(ChupaWordDecomposer), 0, (GInstanceInitFunc) NULL, }; @@ -197,7 +197,7 @@ register_type(GTypeModule *type_module) if (!type) { type = g_type_module_register_type(type_module, CHUPA_TYPE_DECOMPOSER, - "ChupaMSWORDDecomposer", + "ChupaWordDecomposer", &info, 0); chupa_type_msword_decomposer = type; } @@ -229,6 +229,6 @@ CHUPA_MODULE_IMPL_EXIT(void) G_MODULE_EXPORT GObject * CHUPA_MODULE_IMPL_INSTANTIATE(const gchar *first_property, va_list var_args) { - return g_object_new_valist(CHUPA_TYPE_MSWORD_DECOMPOSER, + return g_object_new_valist(CHUPA_TYPE_WORD_DECOMPOSER, first_property, var_args); } From null+ranguba at clear-code.com Sun Sep 26 10:00:30 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Sun, 26 Sep 2010 14:00:30 +0000 Subject: [groonga-commit:1326] ranguba/chupatext [master] fix typos. Message-ID: <20100926140039.5D92B170640@taiyaki.ru> Kouhei Sutou 2010-09-26 14:00:30 +0000 (Sun, 26 Sep 2010) New Revision: c3fede0ae4616f7e6de7a23a1f907e087c65e9fc Log: fix typos. Modified files: module/excel.c Modified: module/excel.c (+3 -3) =================================================================== --- module/excel.c 2010-09-26 14:00:02 +0000 (1f6c8fd) +++ module/excel.c 2010-09-26 14:00:30 +0000 (76414fe) @@ -54,8 +54,8 @@ silent_log(const gchar *log_domain, GLogLevelFlags log_level, } static gboolean -chupa_msword_decomposer_feed(ChupaDecomposer *dec, ChupaText *chupar, - ChupaTextInput *input, GError **err) +chupa_excel_decomposer_feed(ChupaDecomposer *dec, ChupaText *chupar, + ChupaTextInput *input, GError **err) { ChupaExcelDecomposer *xlsdec = CHUPA_EXCEL_DECOMPOSER(dec); GOFileSaver *fs = NULL; @@ -118,7 +118,7 @@ chupa_excel_decomposer_class_init(ChupaExcelDecomposerClass *klass) GObjectClass *gobject_class = G_OBJECT_CLASS(klass); ChupaDecomposerClass *dec_class = CHUPA_DECOMPOSER_CLASS(klass); gobject_class->constructed = chupa_excel_constructed; - dec_class->feed = chupa_msword_decomposer_feed; + dec_class->feed = chupa_excel_decomposer_feed; } static GType From null+ranguba at clear-code.com Sun Sep 26 10:03:41 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Sun, 26 Sep 2010 14:03:41 +0000 Subject: [groonga-commit:1327] ranguba/chupatext [master] remove ms. Message-ID: <20100926140348.B98FF170640@taiyaki.ru> Kouhei Sutou 2010-09-26 14:03:41 +0000 (Sun, 26 Sep 2010) New Revision: 6cbf21ab8a0dc1ad8926eee3ed9ce4bec64278c7 Log: remove ms. Modified files: module/word.c Modified: module/word.c (+8 -8) =================================================================== --- module/word.c 2010-09-26 14:00:30 +0000 (6003090) +++ module/word.c 2010-09-26 14:03:41 +0000 (8b2417c) @@ -9,7 +9,7 @@ #include #include -#define CHUPA_TYPE_WORD_DECOMPOSER chupa_type_msword_decomposer +#define CHUPA_TYPE_WORD_DECOMPOSER chupa_type_word_decomposer #define CHUPA_WORD_DECOMPOSER(obj) \ G_TYPE_CHECK_INSTANCE_CAST(obj, CHUPA_TYPE_WORD_DECOMPOSER, ChupaWordDecomposer) #define CHUPA_WORD_DECOMPOSER_CLASS(klass) \ @@ -34,7 +34,7 @@ struct _ChupaWordDecomposerClass ChupaDecomposerClass parent_class; }; -static GType chupa_type_msword_decomposer = 0; +static GType chupa_type_word_decomposer = 0; struct char_proc_arg { GString *buffer; @@ -128,7 +128,7 @@ char_proc(wvParseStruct *ps, U16 eachchar, U8 chartype, U16 lid) } static gboolean -chupa_msword_decomposer_feed(ChupaDecomposer *dec, ChupaText *chupar, +chupa_word_decomposer_feed(ChupaDecomposer *dec, ChupaText *chupar, ChupaTextInput *input, GError **err) { struct char_proc_arg arg; @@ -172,10 +172,10 @@ chupa_msword_decomposer_feed(ChupaDecomposer *dec, ChupaText *chupar, } static void -chupa_msword_decomposer_class_init(ChupaWordDecomposerClass *klass) +chupa_word_decomposer_class_init(ChupaWordDecomposerClass *klass) { ChupaDecomposerClass *super = CHUPA_DECOMPOSER_CLASS(klass); - super->feed = chupa_msword_decomposer_feed; + super->feed = chupa_word_decomposer_feed; } static GType @@ -185,21 +185,21 @@ register_type(GTypeModule *type_module) sizeof(ChupaWordDecomposerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, - (GClassInitFunc) chupa_msword_decomposer_class_init, + (GClassInitFunc) chupa_word_decomposer_class_init, NULL, /* class_finalize */ NULL, /* class_data */ sizeof(ChupaWordDecomposer), 0, (GInstanceInitFunc) NULL, }; - GType type = chupa_type_msword_decomposer; + GType type = chupa_type_word_decomposer; if (!type) { type = g_type_module_register_type(type_module, CHUPA_TYPE_DECOMPOSER, "ChupaWordDecomposer", &info, 0); - chupa_type_msword_decomposer = type; + chupa_type_word_decomposer = type; } return type; } From null+ranguba at clear-code.com Sun Sep 26 09:52:29 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Sun, 26 Sep 2010 13:52:29 +0000 Subject: [groonga-commit:1328] ranguba/chupatext [master] Excel decomposer works as dynamic decomposer. Message-ID: <20100926135243.C07E6278005@taiyaki.ru> Kouhei Sutou 2010-09-26 13:52:29 +0000 (Sun, 26 Sep 2010) New Revision: 18fbfa2e3d9e529db36aff976969dcac3984c822 Log: Excel decomposer works as dynamic decomposer. Added files: module/excel_factory.c Modified files: module/Makefile.am test/Makefile.am Renamed files: module/excel.c (from module/chupa_msexcel.c) module/excel/command-context-stderr.h (from module/msexcel/command-context-stderr.h) module/excel/gnumeric.h (from module/msexcel/gnumeric.h) module/excel/workbook-view.h (from module/msexcel/workbook-view.h) test/test_excel.c (from test/test_msexcel.c) Modified: module/Makefile.am (+11 -5) =================================================================== --- module/Makefile.am 2010-09-26 13:45:18 +0000 (7d1d43a) +++ module/Makefile.am 2010-09-26 13:52:29 +0000 (3c8cb7f) @@ -14,7 +14,8 @@ if HAVE_WV decomposer_LTLIBRARIES += chupa_msword.la endif if HAVE_GOFFICE -decomposer_LTLIBRARIES += chupa_msexcel.la +decomposer_LTLIBRARIES += excel.la +factory_LTLIBRARIES += excel_factory.la endif decomposer_LTLIBRARIES += chupa_mspowerpoint.la @@ -43,10 +44,15 @@ chupa_msword_la_LDFLAGS = -module chupa_msword_la_CPPFLAGS = $(WV_CFLAGS) chupa_msword_la_LIBADD = $(WV_LIBS) $(GSF_LIBS) -chupa_msexcel_la_SOURCES = chupa_msexcel.c -chupa_msexcel_la_LDFLAGS = -module -chupa_msexcel_la_CPPFLAGS = -I$(srcdir)/msexcel $(GOFFICE_CFLAGS) -chupa_msexcel_la_LIBADD = $(GOFFICE_LIBS) -lspreadsheet +excel_la_SOURCES = excel.c +excel_la_LDFLAGS = -module +excel_la_CPPFLAGS = -I$(srcdir)/excel $(GOFFICE_CFLAGS) +excel_la_LIBADD = $(GOFFICE_LIBS) -lspreadsheet + +excel_factory_la_SOURCES = excel_factory.c +excel_factory_la_LDFLAGS = -module +excel_factory_la_CPPFLAGS = $(GLIB_CFLAGS) $(GSF_CFLAGS) +excel_factory_la_LIBADD = $(GLIB_LIBS) chupa_mspowerpoint_la_SOURCES = chupa_mspowerpoint.c chupa_mspowerpoint_la_LDFLAGS = -module Renamed: module/excel.c (+0 -2) 97% =================================================================== --- module/chupa_msexcel.c 2010-09-26 13:45:18 +0000 (b76f401) +++ module/excel.c 2010-09-26 13:52:29 +0000 (1f6c8fd) @@ -143,8 +143,6 @@ register_type(GTypeModule *type_module) "ChupaExcelDecomposer", &info, 0); chupa_type_excel_decomposer = type; - chupa_decomposer_register("application/vnd.ms-excel", type); - chupa_decomposer_register("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", type); } return type; } Renamed: module/excel/command-context-stderr.h (+0 -0) 100% =================================================================== Renamed: module/excel/gnumeric.h (+0 -0) 100% =================================================================== Renamed: module/excel/workbook-view.h (+0 -0) 100% =================================================================== Added: module/excel_factory.c (+160 -0) 100644 =================================================================== --- /dev/null +++ module/excel_factory.c 2010-09-26 13:52:29 +0000 (63881e0) @@ -0,0 +1,160 @@ +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Copyright (C) 2010 Kouhei Sutou + * + * 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 3 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 program. If not, see . + * + */ + +#ifdef HAVE_CONFIG_H +# include +#endif /* HAVE_CONFIG_H */ + +#include +#include +#include +/* #include */ +#include + +#include +#include +#include + +#define CHUPA_TYPE_EXCEL_FACTORY chupa_type_excel_factory +#define CHUPA_EXCEL_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CHUPA_TYPE_EXCEL_FACTORY, ChupaEXCELFactory)) +#define CHUPA_EXCEL_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CHUPA_TYPE_EXCEL_FACTORY, ChupaEXCELFactoryClass)) +#define CHUPA_IS_EXCEL_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CHUPA_TYPE_EXCEL_FACTORY)) +#define CHUPA_IS_EXCEL_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CHUPA_TYPE_EXCEL_FACTORY)) +#define CHUPA_EXCEL_FACTORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), CHUPA_TYPE_EXCEL_FACTORY, ChupaEXCELFactoryClass)) + +typedef struct _ChupaEXCELFactory ChupaEXCELFactory; +typedef struct _ChupaEXCELFactoryClass ChupaEXCELFactoryClass; + +struct _ChupaEXCELFactory +{ + ChupaModuleFactory object; +}; + +struct _ChupaEXCELFactoryClass +{ + ChupaModuleFactoryClass parent_class; +}; + +static GType chupa_type_excel_factory = 0; +static ChupaModuleFactoryClass *parent_class; + +static GList *get_mime_types (ChupaModuleFactory *factory); +static GObject *create (ChupaModuleFactory *factory); + +static void +class_init (ChupaModuleFactoryClass *klass) +{ + GObjectClass *gobject_class; + ChupaModuleFactoryClass *factory_class; + + parent_class = g_type_class_peek_parent(klass); + + gobject_class = G_OBJECT_CLASS(klass); + factory_class = CHUPA_MODULE_FACTORY_CLASS(klass); + + factory_class->get_mime_types = get_mime_types; + factory_class->create = create; +} + +static void +init (ChupaEXCELFactory *factory) +{ +} + +static void +register_type (GTypeModule *type_module) +{ + static const GTypeInfo info = + { + sizeof (ChupaEXCELFactoryClass), + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) class_init, + NULL, /* class_finalize */ + NULL, /* class_data */ + sizeof(ChupaEXCELFactory), + 0, + (GInstanceInitFunc) init, + }; + + chupa_type_excel_factory = + g_type_module_register_type(type_module, + CHUPA_TYPE_MODULE_FACTORY, + "ChupaEXCELFactory", + &info, 0); +} + +G_MODULE_EXPORT GList * +CHUPA_MODULE_IMPL_INIT (GTypeModule *type_module) +{ + GList *registered_types = NULL; + + register_type(type_module); + if (chupa_type_excel_factory) { + registered_types = + g_list_prepend(registered_types, + (gchar *)g_type_name(chupa_type_excel_factory)); + } + + return registered_types; +} + +G_MODULE_EXPORT void +CHUPA_MODULE_IMPL_EXIT (void) +{ +} + +G_MODULE_EXPORT GObject * +CHUPA_MODULE_IMPL_INSTANTIATE (const gchar *first_property, va_list var_args) +{ + return g_object_new_valist(CHUPA_TYPE_EXCEL_FACTORY, first_property, var_args); +} + +static GList * +get_mime_types (ChupaModuleFactory *factory) +{ + GList *mime_types = NULL; + + mime_types = g_list_prepend(mime_types, g_strdup("application/vnd.ms-excel")); + mime_types = g_list_prepend(mime_types, g_strdup("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")); + + return mime_types; +} + +GObject * +create (ChupaModuleFactory *factory) +{ + static int n_instances = 0; + GObject *decomposer; + + decomposer = G_OBJECT(chupa_decomposer_new("excel", NULL)); + n_instances++; + if (n_instances == 1) { + /* FIXME: This causes memory leak but we need to + * keep at least 1 decomposer instance to avoid + * duplicated non-module GType + * (e.g. PopplerDocument) registration. */ + g_object_ref(decomposer); + } + return decomposer; +} + +/* +vi:ts=4:nowrap:ai:expandtab:sw=4 +*/ Modified: test/Makefile.am (+2 -2) =================================================================== --- test/Makefile.am 2010-09-26 13:45:18 +0000 (8e7f75d) +++ test/Makefile.am 2010-09-26 13:52:29 +0000 (434b9ff) @@ -26,7 +26,7 @@ if HAVE_WV noinst_LTLIBRARIES += test_msword.la endif if HAVE_GOFFICE -noinst_LTLIBRARIES += test_msexcel.la +noinst_LTLIBRARIES += test_excel.la endif noinst_LTLIBRARIES += test_mspowerpoint.la @@ -71,7 +71,7 @@ test_external_decomposer_la_SOURCES = test_external_decomposer.c chupa_test_util test_restrict_input_stream_la_SOURCES = test_restrict_input_stream.c test_pdf_la_SOURCES = test_pdf.c chupa_test_util.c test_msword_la_SOURCES = test_msword.c chupa_test_util.c -test_msexcel_la_SOURCES = test_msexcel.c chupa_test_util.c +test_excel_la_SOURCES = test_excel.c chupa_test_util.c test_mspowerpoint_la_SOURCES = test_mspowerpoint.c chupa_test_util.c test_tar_la_SOURCES = test_tar.c chupa_test_util.c test_zip_la_SOURCES = test_zip.c chupa_test_util.c Renamed: test/test_excel.c (+2 -2) 89% =================================================================== --- test/test_msexcel.c 2010-09-26 13:45:18 +0000 (4a184c5) +++ test/test_excel.c 2010-09-26 13:52:29 +0000 (33c4c9c) @@ -20,13 +20,13 @@ teardown(void) #define decompose_fixture chupa_test_decompose_fixture void -test_decompose_msexcel(void) +test_decompose_excel(void) { cut_assert_equal_string("sample\n1\n2\n3\n4\n5\n6\n7\n", decompose_fixture("sample.xls", NULL)); } void -test_decompose_msexcel_2007(void) +test_decompose_excel_2007(void) { cut_assert_equal_string("sample\n", decompose_fixture("sample_2007.xlsx", NULL)); } From null+ranguba at clear-code.com Sun Sep 26 10:18:31 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Sun, 26 Sep 2010 14:18:31 +0000 Subject: [groonga-commit:1329] ranguba/chupatext [master] make text/plain decorator module. Message-ID: <20100926141841.EE0A5170640@taiyaki.ru> Kouhei Sutou 2010-09-26 14:18:31 +0000 (Sun, 26 Sep 2010) New Revision: e9ce128bb6492da585d96853d9b7b606a6c3ef54 Log: make text/plain decorator module. Added files: module/text.c module/text_factory.c Removed files: chupatext/text_decomposer.c chupatext/text_decomposer.h Modified files: chupatext/Makefile.am chupatext/chupa_decomposer.c chupatext/chupa_decomposer.h module/Makefile.am test/chupa_test_util.c test/chupa_test_util.h test/test_decomposer.c test/test_text.c Modified: chupatext/Makefile.am (+0 -2) =================================================================== --- chupatext/Makefile.am 2010-09-26 14:03:41 +0000 (fd9058a) +++ chupatext/Makefile.am 2010-09-26 14:18:31 +0000 (29af428) @@ -22,7 +22,6 @@ libchupatext_la_SOURCES = \ chupa_decomposer.c \ archive_decomposer.c \ external_decomposer.c \ - text_decomposer.c \ chupa_restrict_input_stream.c \ chupa_utils.c \ version.c \ @@ -54,7 +53,6 @@ chupatext_include_HEADERS = \ chupa_text_input.h \ chupa_text_input_stream.h \ chupa_gsf_input_stream.h \ - text_decomposer.h \ external_decomposer.h \ chupa_utils.h \ version.h Modified: chupatext/chupa_decomposer.c (+2 -10) =================================================================== --- chupatext/chupa_decomposer.c 2010-09-26 14:03:41 +0000 (42dd478) +++ chupatext/chupa_decomposer.c 2010-09-26 14:18:31 +0000 (a5e9e97) @@ -93,7 +93,7 @@ ChupaDecomposer * chupa_decomposer_new (const gchar *name, const gchar *first_property, ...) { ChupaModule *module; - ChupaDecomposer *decomposer; + GObject *decomposer; va_list var_args; module = _chupa_decomposer_load_module(name); @@ -103,7 +103,7 @@ chupa_decomposer_new (const gchar *name, const gchar *first_property, ...) decomposer = chupa_module_instantiate(module, first_property, var_args); va_end(var_args); - return decomposer; + return CHUPA_DECOMPOSER(decomposer); } gboolean @@ -112,11 +112,3 @@ chupa_decomposer_feed(ChupaDecomposer *dec, ChupaText *text, ChupaTextInput *inp g_return_val_if_fail(CHUPA_IS_DECOMPOSER(dec), FALSE); return (*CHUPA_DECOMPOSER_GET_CLASS(dec)->feed)(dec, text, input, err); } - -static const char text_plain[] = "text/plain"; - -void -chupa_decomposer_load_modules(void) -{ - /* chupa_decomposer_register(text_plain, CHUPA_TYPE_TEXT_DECOMPOSER); */ -} Modified: chupatext/chupa_decomposer.h (+0 -1) =================================================================== --- chupatext/chupa_decomposer.h 2010-09-26 14:03:41 +0000 (8ac8e22) +++ chupatext/chupa_decomposer.h 2010-09-26 14:18:31 +0000 (d00b94a) @@ -50,7 +50,6 @@ gboolean chupa_decomposer_feed (ChupaDecomposer *dec, ChupaTextInput *input, GError **error); -void chupa_decomposer_load_modules(void); void chupa_decomposer_register(const gchar *mime_type, GType type); void chupa_decomposer_unregister(const gchar *mime_type, GType type); Deleted: chupatext/text_decomposer.c (+0 -27) 100644 =================================================================== --- chupatext/text_decomposer.c 2010-09-26 14:03:41 +0000 (631bd69) +++ /dev/null @@ -1,27 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * Copyright (C) 2010 Nobuyoshi Nakada - */ - -#include "chupatext/text_decomposer.h" - -G_DEFINE_TYPE(ChupaTextDecomposer, chupa_text_decomposer, CHUPA_TYPE_DECOMPOSER) - -static void -chupa_text_decomposer_init(ChupaTextDecomposer *text_decomposer) -{ -} - -static gboolean -chupa_text_decomposer_feed(ChupaDecomposer *dec, ChupaText *text, ChupaTextInput *input, GError **err) -{ - chupa_text_decomposed(text, input); - return TRUE; -} - -static void -chupa_text_decomposer_class_init(ChupaTextDecomposerClass *klass) -{ - ChupaDecomposerClass *super = CHUPA_DECOMPOSER_CLASS(klass); - super->feed = chupa_text_decomposer_feed; -} Deleted: chupatext/text_decomposer.h (+0 -39) 100644 =================================================================== --- chupatext/text_decomposer.h 2010-09-26 14:03:41 +0000 (ae593a6) +++ /dev/null @@ -1,39 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * Copyright (C) 2010 Nobuyoshi Nakada - */ - -#ifndef TEXT_DECOMPOSER_H -#define TEXT_DECOMPOSER_H - -#include "chupatext/chupa_decomposer.h" -#include - -G_BEGIN_DECLS - -#define CHUPA_TYPE_TEXT_DECOMPOSER chupa_text_decomposer_get_type() -#define CHUPA_TEXT_DECOMPOSER(obj) \ - G_TYPE_CHECK_INSTANCE_CAST(obj, CHUPA_TYPE_TEXT_DECOMPOSER, ChupaTextDecomposer) -#define CHUPA_TEXT_DECOMPOSER_CLASS(klass) \ - G_TYPE_CHECK_CLASS_CAST(klass, CHUPA_TYPE_TEXT_DECOMPOSER, ChupaTextDecomposerClass) -#define CHUPA_IS_TEXT_DECOMPOSER(obj) \ - G_TYPE_CHECK_INSTANCE_TYPE(obj, CHUPA_TYPE_TEXT_DECOMPOSER) -#define CHUPA_IS_TEXT_DECOMPOSER_CLASS(klass) \ - G_TYPE_CHECK_CLASS_TYPE(klass, CHUPA_TYPE_TEXT_DECOMPOSER) -#define CHUPA_TEXT_DECOMPOSER_GET_CLASS(obj) \ - G_TYPE_INSTANCE_GET_CLASS(obj, CHUPA_TYPE_TEXT_DECOMPOSER, ChupaTextDecomposerClass) - -typedef struct _ChupaTextDecomposer ChupaTextDecomposer; -typedef struct _ChupaTextDecomposerClass ChupaTextDecomposerClass; - -struct _ChupaTextDecomposer -{ - ChupaDecomposer object; -}; - -struct _ChupaTextDecomposerClass -{ - ChupaDecomposerClass parent_class; -}; - -#endif Modified: module/Makefile.am (+13 -0) =================================================================== --- module/Makefile.am 2010-09-26 14:03:41 +0000 (aa3d0c0) +++ module/Makefile.am 2010-09-26 14:18:31 +0000 (b52ef99) @@ -4,6 +4,9 @@ LDFLAGS = -L$(top_builddir)/chupatext -lchupatext decomposer_LTLIBRARIES = factory_LTLIBRARIES = + +decomposer_LTLIBRARIES += text.la +factory_LTLIBRARIES += text_factory.la decomposer_LTLIBRARIES += chupa_tar.la decomposer_LTLIBRARIES += chupa_zip.la if HAVE_POPPLER_GLIB @@ -20,6 +23,16 @@ factory_LTLIBRARIES += excel_factory.la endif decomposer_LTLIBRARIES += chupa_mspowerpoint.la +text_la_SOURCES = text.c +text_la_LDFLAGS = -module +text_la_CPPFLAGS = $(GLIB_CFLAGS) $(GSF_CFLAGS) +text_la_LIBADD = $(GLIB_LIBS) + +text_factory_la_SOURCES = text_factory.c +text_factory_la_LDFLAGS = -module +text_factory_la_CPPFLAGS = $(GLIB_CFLAGS) $(GSF_CFLAGS) +text_factory_la_LIBADD = $(GLIB_LIBS) + chupa_tar_la_SOURCES = chupa_tar.c chupa_tar_la_LDFLAGS = -module chupa_tar_la_CPPFLAGS = $(GSF_CFLAGS) Added: module/text.c (+99 -0) 100644 =================================================================== --- /dev/null +++ module/text.c 2010-09-26 14:18:31 +0000 (be6c9ea) @@ -0,0 +1,99 @@ +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Copyright (C) 2010 Nobuyoshi Nakada + */ + +#include +#include +#include + +#define CHUPA_TYPE_TEXT_DECOMPOSER chupa_type_text_decomposer +#define CHUPA_TEXT_DECOMPOSER(obj) \ + G_TYPE_CHECK_INSTANCE_CAST(obj, CHUPA_TYPE_TEXT_DECOMPOSER, ChupaTextDecomposer) +#define CHUPA_TEXT_DECOMPOSER_CLASS(klass) \ + G_TYPE_CHECK_CLASS_CAST(klass, CHUPA_TYPE_TEXT_DECOMPOSER, ChupaTextDecomposerClass) +#define CHUPA_IS_TEXT_DECOMPOSER(obj) \ + G_TYPE_CHECK_INSTANCE_TYPE(obj, CHUPA_TYPE_TEXT_DECOMPOSER) +#define CHUPA_IS_TEXT_DECOMPOSER_CLASS(klass) \ + G_TYPE_CHECK_CLASS_TYPE(klass, CHUPA_TYPE_TEXT_DECOMPOSER) +#define CHUPA_TEXT_DECOMPOSER_GET_CLASS(obj) \ + G_TYPE_INSTANCE_GET_CLASS(obj, CHUPA_TYPE_TEXT_DECOMPOSER, ChupaTextDecomposerClass) + +typedef struct _ChupaTextDecomposer ChupaTextDecomposer; +typedef struct _ChupaTextDecomposerClass ChupaTextDecomposerClass; + +struct _ChupaTextDecomposer +{ + ChupaDecomposer object; +}; + +struct _ChupaTextDecomposerClass +{ + ChupaDecomposerClass parent_class; +}; + +static GType chupa_type_text_decomposer = 0; + +static gboolean +chupa_text_decomposer_feed(ChupaDecomposer *decomposer, ChupaText *chupar, + ChupaTextInput *input, GError **err) +{ + chupa_text_decomposed(chupar, input); + return TRUE; +} + +static void +chupa_text_decomposer_class_init(ChupaTextDecomposerClass *klass) +{ + ChupaDecomposerClass *super = CHUPA_DECOMPOSER_CLASS(klass); + super->feed = chupa_text_decomposer_feed; +} + +static void +register_type(GTypeModule *type_module) +{ + static const GTypeInfo info = { + sizeof(ChupaTextDecomposerClass), + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) chupa_text_decomposer_class_init, + NULL, /* class_finalize */ + NULL, /* class_data */ + sizeof(ChupaTextDecomposer), + 0, + (GInstanceInitFunc) NULL, + }; + + chupa_type_text_decomposer = + g_type_module_register_type(type_module, + CHUPA_TYPE_DECOMPOSER, + "ChupaTextDecomposer", + &info, 0); +} + +G_MODULE_EXPORT GList * +CHUPA_MODULE_IMPL_INIT(GTypeModule *type_module) +{ + GList *registered_types = NULL; + + register_type(type_module); + if (chupa_type_text_decomposer) { + registered_types = + g_list_prepend(registered_types, + (gchar *)g_type_name(chupa_type_text_decomposer)); + } + + return registered_types; +} + +G_MODULE_EXPORT void +CHUPA_MODULE_IMPL_EXIT(void) +{ +} + +G_MODULE_EXPORT GObject * +CHUPA_MODULE_IMPL_INSTANTIATE(const gchar *first_property, va_list var_args) +{ + return g_object_new_valist(CHUPA_TYPE_TEXT_DECOMPOSER, + first_property, var_args); +} Added: module/text_factory.c (+147 -0) 100644 =================================================================== --- /dev/null +++ module/text_factory.c 2010-09-26 14:18:31 +0000 (9fb8ea9) @@ -0,0 +1,147 @@ +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Copyright (C) 2010 Kouhei Sutou + * + * 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 3 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 program. If not, see . + * + */ + +#ifdef HAVE_CONFIG_H +# include +#endif /* HAVE_CONFIG_H */ + +#include +#include +#include +/* #include */ +#include + +#include +#include +#include + +#define CHUPA_TYPE_TEXT_FACTORY chupa_type_text_factory +#define CHUPA_TEXT_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CHUPA_TYPE_TEXT_FACTORY, ChupaTextFactory)) +#define CHUPA_TEXT_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CHUPA_TYPE_TEXT_FACTORY, ChupaTextFactoryClass)) +#define CHUPA_IS_TEXT_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CHUPA_TYPE_TEXT_FACTORY)) +#define CHUPA_IS_TEXT_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CHUPA_TYPE_TEXT_FACTORY)) +#define CHUPA_TEXT_FACTORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), CHUPA_TYPE_TEXT_FACTORY, ChupaTextFactoryClass)) + +typedef struct _ChupaTextFactory ChupaTextFactory; +typedef struct _ChupaTextFactoryClass ChupaTextFactoryClass; + +struct _ChupaTextFactory +{ + ChupaModuleFactory object; +}; + +struct _ChupaTextFactoryClass +{ + ChupaModuleFactoryClass parent_class; +}; + +static GType chupa_type_text_factory = 0; +static ChupaModuleFactoryClass *parent_class; + +static GList *get_mime_types (ChupaModuleFactory *factory); +static GObject *create (ChupaModuleFactory *factory); + +static void +class_init (ChupaModuleFactoryClass *klass) +{ + GObjectClass *gobject_class; + ChupaModuleFactoryClass *factory_class; + + parent_class = g_type_class_peek_parent(klass); + + gobject_class = G_OBJECT_CLASS(klass); + factory_class = CHUPA_MODULE_FACTORY_CLASS(klass); + + factory_class->get_mime_types = get_mime_types; + factory_class->create = create; +} + +static void +init (ChupaTextFactory *factory) +{ +} + +static void +register_type (GTypeModule *type_module) +{ + static const GTypeInfo info = + { + sizeof (ChupaTextFactoryClass), + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) class_init, + NULL, /* class_finalize */ + NULL, /* class_data */ + sizeof(ChupaTextFactory), + 0, + (GInstanceInitFunc) init, + }; + + chupa_type_text_factory = + g_type_module_register_type(type_module, + CHUPA_TYPE_MODULE_FACTORY, + "ChupaTextFactory", + &info, 0); +} + +G_MODULE_EXPORT GList * +CHUPA_MODULE_IMPL_INIT (GTypeModule *type_module) +{ + GList *registered_types = NULL; + + register_type(type_module); + if (chupa_type_text_factory) { + registered_types = + g_list_prepend(registered_types, + (gchar *)g_type_name(chupa_type_text_factory)); + } + + return registered_types; +} + +G_MODULE_EXPORT void +CHUPA_MODULE_IMPL_EXIT (void) +{ +} + +G_MODULE_EXPORT GObject * +CHUPA_MODULE_IMPL_INSTANTIATE (const gchar *first_property, va_list var_args) +{ + return g_object_new_valist(CHUPA_TYPE_TEXT_FACTORY, first_property, var_args); +} + +static GList * +get_mime_types (ChupaModuleFactory *factory) +{ + GList *mime_types = NULL; + + mime_types = g_list_prepend(mime_types, g_strdup("text/plain")); + + return mime_types; +} + +GObject * +create (ChupaModuleFactory *factory) +{ + return G_OBJECT(chupa_decomposer_new("text", NULL)); +} + +/* +vi:ts=4:nowrap:ai:expandtab:sw=4 +*/ Modified: test/chupa_test_util.c (+0 -2) =================================================================== --- test/chupa_test_util.c 2010-09-26 14:03:41 +0000 (1f930df) +++ test/chupa_test_util.c 2010-09-26 14:18:31 +0000 (3729ce9) @@ -8,8 +8,6 @@ void chupa_test_setup(void) { - chupa_decomposer_load_modules(); - cut_set_fixture_data_dir(cut_get_source_directory(), "fixtures", NULL); } Modified: test/chupa_test_util.h (+1 -1) =================================================================== --- test/chupa_test_util.h 2010-09-26 14:03:41 +0000 (31bd74c) +++ test/chupa_test_util.h 2010-09-26 14:18:31 +0000 (a753aec) @@ -6,7 +6,7 @@ #ifndef CHUPA_TEST_UTIL_H #define CHUPA_TEST_UTIL_H -#include +#include #include #include Modified: test/test_decomposer.c (+6 -3) =================================================================== --- test/test_decomposer.c 2010-09-26 14:03:41 +0000 (4a4e820) +++ test/test_decomposer.c 2010-09-26 14:18:31 +0000 (3d2dba8) @@ -3,24 +3,27 @@ * Copyright (C) 2010 Nobuyoshi Nakada */ -#include +#include #include #include static ChupaDecomposer *decomp; +static ChupaDispatcher *dispatcher; static GInputStream *source; void setup(void) { - chupa_decomposer_load_modules(); decomp = NULL; + dispatcher = chupa_dispatcher_new(); } void teardown(void) { + if (dispatcher) + g_object_unref(dispatcher); if (decomp) g_object_unref(decomp); if (source) @@ -30,7 +33,7 @@ teardown(void) void test_search(void) { - decomp = chupa_decomposer_search("text/plain"); + decomp = chupa_dispatcher_dispatch(dispatcher, "text/plain"); cut_assert_not_null(decomp); cut_assert_not_null(CHUPA_TEXT_DECOMPOSER(decomp)); } Modified: test/test_text.c (+0 -1) =================================================================== --- test/test_text.c 2010-09-26 14:03:41 +0000 (551155e) +++ test/test_text.c 2010-09-26 14:18:31 +0000 (f56d571) @@ -3,7 +3,6 @@ * Copyright (C) 2010 Nobuyoshi Nakada */ -#include #include #include "chupa_test_util.h" #include From null+ranguba at clear-code.com Sun Sep 26 10:25:34 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Sun, 26 Sep 2010 14:25:34 +0000 Subject: [groonga-commit:1330] ranguba/chupatext [master] Tar decomposer works as dynamic decomposer. Message-ID: <20100926142545.56B1F170640@taiyaki.ru> Kouhei Sutou 2010-09-26 14:25:34 +0000 (Sun, 26 Sep 2010) New Revision: b2423e3c11e3ef14161c3c995373dfd793f3c3dc Log: Tar decomposer works as dynamic decomposer. Added files: module/tar_factory.c Modified files: module/Makefile.am Renamed files: module/tar.c (from module/chupa_tar.c) Modified: module/Makefile.am (+11 -5) =================================================================== --- module/Makefile.am 2010-09-26 14:18:31 +0000 (b52ef99) +++ module/Makefile.am 2010-09-26 14:25:34 +0000 (ff6f3b3) @@ -7,7 +7,8 @@ factory_LTLIBRARIES = decomposer_LTLIBRARIES += text.la factory_LTLIBRARIES += text_factory.la -decomposer_LTLIBRARIES += chupa_tar.la +decomposer_LTLIBRARIES += tar.la +factory_LTLIBRARIES += tar_factory.la decomposer_LTLIBRARIES += chupa_zip.la if HAVE_POPPLER_GLIB decomposer_LTLIBRARIES += pdf.la @@ -33,10 +34,15 @@ text_factory_la_LDFLAGS = -module text_factory_la_CPPFLAGS = $(GLIB_CFLAGS) $(GSF_CFLAGS) text_factory_la_LIBADD = $(GLIB_LIBS) -chupa_tar_la_SOURCES = chupa_tar.c -chupa_tar_la_LDFLAGS = -module -chupa_tar_la_CPPFLAGS = $(GSF_CFLAGS) -chupa_tar_la_LIBADD = $(GSF_LIBS) +tar_la_SOURCES = tar.c +tar_la_LDFLAGS = -module +tar_la_CPPFLAGS = $(GSF_CFLAGS) +tar_la_LIBADD = $(GSF_LIBS) + +tar_factory_la_SOURCES = tar_factory.c +tar_factory_la_LDFLAGS = -module +tar_factory_la_CPPFLAGS = $(GLIB_CFLAGS) $(GSF_CFLAGS) +tar_factory_la_LIBADD = $(GLIB_LIBS) chupa_zip_la_SOURCES = chupa_zip.c chupa_zip_la_LDFLAGS = -module Renamed: module/tar.c (+21 -31) 62% =================================================================== --- module/chupa_tar.c 2010-09-26 14:18:31 +0000 (9c01793) +++ module/tar.c 2010-09-26 14:25:34 +0000 (592fedf) @@ -10,25 +10,25 @@ #define CHUPA_TYPE_TAR_DECOMPOSER chupa_type_tar_decomposer #define CHUPA_TAR_DECOMPOSER(obj) \ - G_TYPE_CHECK_INSTANCE_CAST(obj, CHUPA_TYPE_TAR_DECOMPOSER, ChupaTARDecomposer) + G_TYPE_CHECK_INSTANCE_CAST(obj, CHUPA_TYPE_TAR_DECOMPOSER, ChupaTarDecomposer) #define CHUPA_TAR_DECOMPOSER_CLASS(klass) \ - G_TYPE_CHECK_CLASS_CAST(klass, CHUPA_TYPE_TAR_DECOMPOSER, ChupaTARDecomposerClass) + G_TYPE_CHECK_CLASS_CAST(klass, CHUPA_TYPE_TAR_DECOMPOSER, ChupaTarDecomposerClass) #define CHUPA_IS_TAR_DECOMPOSER(obj) \ G_TYPE_CHECK_INSTANCE_TYPE(obj, CHUPA_TYPE_TAR_DECOMPOSER) #define CHUPA_IS_TAR_DECOMPOSER_CLASS(klass) \ G_TYPE_CHECK_CLASS_TYPE(klass, CHUPA_TYPE_TAR_DECOMPOSER) #define CHUPA_TAR_DECOMPOSER_GET_CLASS(obj) \ - G_TYPE_INSTANCE_GET_CLASS(obj, CHUPA_TYPE_TAR_DECOMPOSER, ChupaTARDecomposerClass) + G_TYPE_INSTANCE_GET_CLASS(obj, CHUPA_TYPE_TAR_DECOMPOSER, ChupaTarDecomposerClass) -typedef struct _ChupaTARDecomposer ChupaTARDecomposer; -typedef struct _ChupaTARDecomposerClass ChupaTARDecomposerClass; +typedef struct _ChupaTarDecomposer ChupaTarDecomposer; +typedef struct _ChupaTarDecomposerClass ChupaTarDecomposerClass; -struct _ChupaTARDecomposer +struct _ChupaTarDecomposer { ChupaArchiveDecomposer parent_object; }; -struct _ChupaTARDecomposerClass +struct _ChupaTarDecomposerClass { ChupaArchiveDecomposerClass parent_class; }; @@ -36,58 +36,48 @@ struct _ChupaTARDecomposerClass static GType chupa_type_tar_decomposer = 0; static void -chupa_tar_decomposer_init(ChupaTARDecomposer *dec) +chupa_tar_decomposer_init(ChupaTarDecomposer *dec) { } static void -chupa_tar_decomposer_class_init(ChupaTARDecomposerClass *klass) +chupa_tar_decomposer_class_init(ChupaTarDecomposerClass *klass) { ChupaArchiveDecomposerClass *dec_class = CHUPA_ARCHIVE_DECOMPOSER_CLASS(klass); dec_class->get_infile = gsf_infile_tar_new; } -static GType +static void register_type(GTypeModule *type_module) { static const GTypeInfo info = { - sizeof(ChupaTARDecomposerClass), + sizeof(ChupaTarDecomposerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) chupa_tar_decomposer_class_init, NULL, /* class_finalize */ NULL, /* class_data */ - sizeof(ChupaTARDecomposer), + sizeof(ChupaTarDecomposer), 0, (GInstanceInitFunc) NULL, }; - GType type = chupa_type_tar_decomposer; - if (!type) { - type = g_type_module_register_type(type_module, - CHUPA_TYPE_ARCHIVE_DECOMPOSER, - "ChupaTARDecomposer", - &info, 0); - chupa_type_tar_decomposer = type; - chupa_decomposer_register("application/tar", type); - chupa_decomposer_register("application/compressed-tar", type); - } - return type; + chupa_type_tar_decomposer = + g_type_module_register_type(type_module, + CHUPA_TYPE_ARCHIVE_DECOMPOSER, + "ChupaTarDecomposer", + &info, 0); } G_MODULE_EXPORT GList * CHUPA_MODULE_IMPL_INIT(GTypeModule *type_module) { - GType type = register_type(type_module); GList *registered_types = NULL; -#if 0 - if (type) { - registered_types = - g_list_prepend(registered_types, - (gchar *)g_type_name(type)); - } -#endif + register_type(type_module); + registered_types = + g_list_prepend(registered_types, + (gchar *)g_type_name(chupa_type_tar_decomposer)); return registered_types; } Added: module/tar_factory.c (+148 -0) 100644 =================================================================== --- /dev/null +++ module/tar_factory.c 2010-09-26 14:25:34 +0000 (828dd3a) @@ -0,0 +1,148 @@ +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Copyright (C) 2010 Kouhei Sutou + * + * 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 3 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 program. If not, see . + * + */ + +#ifdef HAVE_CONFIG_H +# include +#endif /* HAVE_CONFIG_H */ + +#include +#include +#include +/* #include */ +#include + +#include +#include +#include + +#define CHUPA_TYPE_TAR_FACTORY chupa_type_tar_factory +#define CHUPA_TAR_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CHUPA_TYPE_TAR_FACTORY, ChupaTarFactory)) +#define CHUPA_TAR_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CHUPA_TYPE_TAR_FACTORY, ChupaTarFactoryClass)) +#define CHUPA_IS_TAR_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CHUPA_TYPE_TAR_FACTORY)) +#define CHUPA_IS_TAR_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CHUPA_TYPE_TAR_FACTORY)) +#define CHUPA_TAR_FACTORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), CHUPA_TYPE_TAR_FACTORY, ChupaTarFactoryClass)) + +typedef struct _ChupaTarFactory ChupaTarFactory; +typedef struct _ChupaTarFactoryClass ChupaTarFactoryClass; + +struct _ChupaTarFactory +{ + ChupaModuleFactory object; +}; + +struct _ChupaTarFactoryClass +{ + ChupaModuleFactoryClass parent_class; +}; + +static GType chupa_type_tar_factory = 0; +static ChupaModuleFactoryClass *parent_class; + +static GList *get_mime_types (ChupaModuleFactory *factory); +static GObject *create (ChupaModuleFactory *factory); + +static void +class_init (ChupaModuleFactoryClass *klass) +{ + GObjectClass *gobject_class; + ChupaModuleFactoryClass *factory_class; + + parent_class = g_type_class_peek_parent(klass); + + gobject_class = G_OBJECT_CLASS(klass); + factory_class = CHUPA_MODULE_FACTORY_CLASS(klass); + + factory_class->get_mime_types = get_mime_types; + factory_class->create = create; +} + +static void +init (ChupaTarFactory *factory) +{ +} + +static void +register_type (GTypeModule *type_module) +{ + static const GTypeInfo info = + { + sizeof (ChupaTarFactoryClass), + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) class_init, + NULL, /* class_finalize */ + NULL, /* class_data */ + sizeof(ChupaTarFactory), + 0, + (GInstanceInitFunc) init, + }; + + chupa_type_tar_factory = + g_type_module_register_type(type_module, + CHUPA_TYPE_MODULE_FACTORY, + "ChupaTarFactory", + &info, 0); +} + +G_MODULE_EXPORT GList * +CHUPA_MODULE_IMPL_INIT (GTypeModule *type_module) +{ + GList *registered_types = NULL; + + register_type(type_module); + if (chupa_type_tar_factory) { + registered_types = + g_list_prepend(registered_types, + (gchar *)g_type_name(chupa_type_tar_factory)); + } + + return registered_types; +} + +G_MODULE_EXPORT void +CHUPA_MODULE_IMPL_EXIT (void) +{ +} + +G_MODULE_EXPORT GObject * +CHUPA_MODULE_IMPL_INSTANTIATE (const gchar *first_property, va_list var_args) +{ + return g_object_new_valist(CHUPA_TYPE_TAR_FACTORY, first_property, var_args); +} + +static GList * +get_mime_types (ChupaModuleFactory *factory) +{ + GList *mime_types = NULL; + + mime_types = g_list_prepend(mime_types, g_strdup("application/tar")); + mime_types = g_list_prepend(mime_types, g_strdup("application/compressed-tar")); + + return mime_types; +} + +GObject * +create (ChupaModuleFactory *factory) +{ + return G_OBJECT(chupa_decomposer_new("tar", NULL)); +} + +/* +vi:ts=4:nowrap:ai:expandtab:sw=4 +*/ From null+ranguba at clear-code.com Sun Sep 26 10:28:43 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Sun, 26 Sep 2010 14:28:43 +0000 Subject: [groonga-commit:1331] ranguba/chupatext [master] Zip decomposer works as dynamic decomposer. Message-ID: <20100926142852.234AD170640@taiyaki.ru> Kouhei Sutou 2010-09-26 14:28:43 +0000 (Sun, 26 Sep 2010) New Revision: c96ee243bf085f75a5cc1f5b95f7670e7046cd53 Log: Zip decomposer works as dynamic decomposer. Added files: module/zip_factory.c Modified files: module/Makefile.am Renamed files: module/zip.c (from module/chupa_zip.c) Modified: module/Makefile.am (+12 -19) =================================================================== --- module/Makefile.am 2010-09-26 14:25:34 +0000 (ff6f3b3) +++ module/Makefile.am 2010-09-26 14:28:43 +0000 (0b03a66) @@ -1,6 +1,8 @@ EMPTY = -LDFLAGS = -L$(top_builddir)/chupatext -lchupatext +DEFAULT_INCLUDES = -I$(top_includedir) -I$(build_includedir) + +LDFLAGS = -module -L$(top_builddir)/chupatext -lchupatext decomposer_LTLIBRARIES = factory_LTLIBRARIES = @@ -9,7 +11,8 @@ decomposer_LTLIBRARIES += text.la factory_LTLIBRARIES += text_factory.la decomposer_LTLIBRARIES += tar.la factory_LTLIBRARIES += tar_factory.la -decomposer_LTLIBRARIES += chupa_zip.la +decomposer_LTLIBRARIES += zip.la +factory_LTLIBRARIES += zip_factory.la if HAVE_POPPLER_GLIB decomposer_LTLIBRARIES += pdf.la factory_LTLIBRARIES += pdf_factory.la @@ -25,67 +28,57 @@ endif decomposer_LTLIBRARIES += chupa_mspowerpoint.la text_la_SOURCES = text.c -text_la_LDFLAGS = -module text_la_CPPFLAGS = $(GLIB_CFLAGS) $(GSF_CFLAGS) text_la_LIBADD = $(GLIB_LIBS) text_factory_la_SOURCES = text_factory.c -text_factory_la_LDFLAGS = -module text_factory_la_CPPFLAGS = $(GLIB_CFLAGS) $(GSF_CFLAGS) text_factory_la_LIBADD = $(GLIB_LIBS) tar_la_SOURCES = tar.c -tar_la_LDFLAGS = -module tar_la_CPPFLAGS = $(GSF_CFLAGS) tar_la_LIBADD = $(GSF_LIBS) tar_factory_la_SOURCES = tar_factory.c -tar_factory_la_LDFLAGS = -module tar_factory_la_CPPFLAGS = $(GLIB_CFLAGS) $(GSF_CFLAGS) tar_factory_la_LIBADD = $(GLIB_LIBS) -chupa_zip_la_SOURCES = chupa_zip.c -chupa_zip_la_LDFLAGS = -module -chupa_zip_la_CPPFLAGS = $(GSF_CFLAGS) -chupa_zip_la_LIBADD = $(GSF_LIBS) +zip_la_SOURCES = zip.c +zip_la_CPPFLAGS = $(GSF_CFLAGS) +zip_la_LIBADD = $(GSF_LIBS) + +zip_factory_la_SOURCES = zip_factory.c +zip_factory_la_CPPFLAGS = $(GLIB_CFLAGS) $(GSF_CFLAGS) +zip_factory_la_LIBADD = $(GLIB_LIBS) pdf_la_SOURCES = pdf.c -pdf_la_LDFLAGS = -module pdf_la_CPPFLAGS = $(POPPLER_GLIB_CFLAGS) $(GSF_CFLAGS) pdf_la_LIBADD = $(POPPLER_GLIB_LIBS) $(GSF_LIBS) pdf_factory_la_SOURCES = pdf_factory.c -pdf_factory_la_LDFLAGS = -module pdf_factory_la_CPPFLAGS = $(GLIB_CFLAGS) $(GSF_CFLAGS) pdf_factory_la_LIBADD = $(GLIB_LIBS) word_la_SOURCES = word.c -word_la_LDFLAGS = -module word_la_CPPFLAGS = $(WV_CFLAGS) word_la_LIBADD = $(WV_LIBS) $(GSF_LIBS) word_factory_la_SOURCES = word_factory.c -word_factory_la_LDFLAGS = -module word_factory_la_CPPFLAGS = $(GLIB_CFLAGS) $(GSF_CFLAGS) word_factory_la_LIBADD = $(GLIB_LIBS) excel_la_SOURCES = excel.c -excel_la_LDFLAGS = -module excel_la_CPPFLAGS = -I$(srcdir)/excel $(GOFFICE_CFLAGS) excel_la_LIBADD = $(GOFFICE_LIBS) -lspreadsheet excel_factory_la_SOURCES = excel_factory.c -excel_factory_la_LDFLAGS = -module excel_factory_la_CPPFLAGS = $(GLIB_CFLAGS) $(GSF_CFLAGS) excel_factory_la_LIBADD = $(GLIB_LIBS) chupa_mspowerpoint_la_SOURCES = chupa_mspowerpoint.c -chupa_mspowerpoint_la_LDFLAGS = -module chupa_mspowerpoint_la_CPPFLAGS = $(GSF_CFLAGS) chupa_mspowerpoint_la_LIBADD = $(GSF_LIBS) -DEFAULT_INCLUDES = -I$(top_includedir) -I$(build_includedir) - all: prereq @am__include@ $(srcdir)/prereq.mk Renamed: module/zip.c (+21 -30) 64% =================================================================== --- module/chupa_zip.c 2010-09-26 14:25:34 +0000 (6bdf793) +++ module/zip.c 2010-09-26 14:28:43 +0000 (fc68248) @@ -10,25 +10,25 @@ #define CHUPA_TYPE_ZIP_DECOMPOSER chupa_type_zip_decomposer #define CHUPA_ZIP_DECOMPOSER(obj) \ - G_TYPE_CHECK_INSTANCE_CAST(obj, CHUPA_TYPE_ZIP_DECOMPOSER, ChupaZIPDecomposer) + G_TYPE_CHECK_INSTANCE_CAST(obj, CHUPA_TYPE_ZIP_DECOMPOSER, ChupaZipDecomposer) #define CHUPA_ZIP_DECOMPOSER_CLASS(klass) \ - G_TYPE_CHECK_CLASS_CAST(klass, CHUPA_TYPE_ZIP_DECOMPOSER, ChupaZIPDecomposerClass) + G_TYPE_CHECK_CLASS_CAST(klass, CHUPA_TYPE_ZIP_DECOMPOSER, ChupaZipDecomposerClass) #define CHUPA_IS_ZIP_DECOMPOSER(obj) \ G_TYPE_CHECK_INSTANCE_TYPE(obj, CHUPA_TYPE_ZIP_DECOMPOSER) #define CHUPA_IS_ZIP_DECOMPOSER_CLASS(klass) \ G_TYPE_CHECK_CLASS_TYPE(klass, CHUPA_TYPE_ZIP_DECOMPOSER) #define CHUPA_ZIP_DECOMPOSER_GET_CLASS(obj) \ - G_TYPE_INSTANCE_GET_CLASS(obj, CHUPA_TYPE_ZIP_DECOMPOSER, ChupaZIPDecomposerClass) + G_TYPE_INSTANCE_GET_CLASS(obj, CHUPA_TYPE_ZIP_DECOMPOSER, ChupaZipDecomposerClass) -typedef struct _ChupaZIPDecomposer ChupaZIPDecomposer; -typedef struct _ChupaZIPDecomposerClass ChupaZIPDecomposerClass; +typedef struct _ChupaZipDecomposer ChupaZipDecomposer; +typedef struct _ChupaZipDecomposerClass ChupaZipDecomposerClass; -struct _ChupaZIPDecomposer +struct _ChupaZipDecomposer { ChupaArchiveDecomposer parent_object; }; -struct _ChupaZIPDecomposerClass +struct _ChupaZipDecomposerClass { ChupaArchiveDecomposerClass parent_class; }; @@ -36,57 +36,48 @@ struct _ChupaZIPDecomposerClass static GType chupa_type_zip_decomposer = 0; static void -chupa_zip_decomposer_init(ChupaZIPDecomposer *dec) +chupa_zip_decomposer_init(ChupaZipDecomposer *dec) { } static void -chupa_zip_decomposer_class_init(ChupaZIPDecomposerClass *klass) +chupa_zip_decomposer_class_init(ChupaZipDecomposerClass *klass) { ChupaArchiveDecomposerClass *dec_class = CHUPA_ARCHIVE_DECOMPOSER_CLASS(klass); dec_class->get_infile = gsf_infile_zip_new; } -static GType +static void register_type(GTypeModule *type_module) { static const GTypeInfo info = { - sizeof(ChupaZIPDecomposerClass), + sizeof(ChupaZipDecomposerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) chupa_zip_decomposer_class_init, NULL, /* class_finalize */ NULL, /* class_data */ - sizeof(ChupaZIPDecomposer), + sizeof(ChupaZipDecomposer), 0, (GInstanceInitFunc) NULL, }; - GType type = chupa_type_zip_decomposer; - if (!type) { - type = g_type_module_register_type(type_module, - CHUPA_TYPE_ARCHIVE_DECOMPOSER, - "ChupaZIPDecomposer", - &info, 0); - chupa_type_zip_decomposer = type; - chupa_decomposer_register("application/zip", type); - } - return type; + chupa_type_zip_decomposer = + g_type_module_register_type(type_module, + CHUPA_TYPE_ARCHIVE_DECOMPOSER, + "ChupaZipDecomposer", + &info, 0); } G_MODULE_EXPORT GList * CHUPA_MODULE_IMPL_INIT(GTypeModule *type_module) { - GType type = register_type(type_module); GList *registered_types = NULL; -#if 0 - if (type) { - registered_types = - g_list_prepend(registered_types, - (gchar *)g_type_name(type)); - } -#endif + register_type(type_module); + registered_types = + g_list_prepend(registered_types, + (gchar *)g_type_name(chupa_type_zip_decomposer)); return registered_types; } Added: module/zip_factory.c (+147 -0) 100644 =================================================================== --- /dev/null +++ module/zip_factory.c 2010-09-26 14:28:43 +0000 (f347d23) @@ -0,0 +1,147 @@ +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Copyright (C) 2010 Kouhei Sutou + * + * 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 3 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 program. If not, see . + * + */ + +#ifdef HAVE_CONFIG_H +# include +#endif /* HAVE_CONFIG_H */ + +#include +#include +#include +/* #include */ +#include + +#include +#include +#include + +#define CHUPA_TYPE_ZIP_FACTORY chupa_type_zip_factory +#define CHUPA_ZIP_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CHUPA_TYPE_ZIP_FACTORY, ChupaZipFactory)) +#define CHUPA_ZIP_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CHUPA_TYPE_ZIP_FACTORY, ChupaZipFactoryClass)) +#define CHUPA_IS_ZIP_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CHUPA_TYPE_ZIP_FACTORY)) +#define CHUPA_IS_ZIP_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CHUPA_TYPE_ZIP_FACTORY)) +#define CHUPA_ZIP_FACTORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), CHUPA_TYPE_ZIP_FACTORY, ChupaZipFactoryClass)) + +typedef struct _ChupaZipFactory ChupaZipFactory; +typedef struct _ChupaZipFactoryClass ChupaZipFactoryClass; + +struct _ChupaZipFactory +{ + ChupaModuleFactory object; +}; + +struct _ChupaZipFactoryClass +{ + ChupaModuleFactoryClass parent_class; +}; + +static GType chupa_type_zip_factory = 0; +static ChupaModuleFactoryClass *parent_class; + +static GList *get_mime_types (ChupaModuleFactory *factory); +static GObject *create (ChupaModuleFactory *factory); + +static void +class_init (ChupaModuleFactoryClass *klass) +{ + GObjectClass *gobject_class; + ChupaModuleFactoryClass *factory_class; + + parent_class = g_type_class_peek_parent(klass); + + gobject_class = G_OBJECT_CLASS(klass); + factory_class = CHUPA_MODULE_FACTORY_CLASS(klass); + + factory_class->get_mime_types = get_mime_types; + factory_class->create = create; +} + +static void +init (ChupaZipFactory *factory) +{ +} + +static void +register_type (GTypeModule *type_module) +{ + static const GTypeInfo info = + { + sizeof (ChupaZipFactoryClass), + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) class_init, + NULL, /* class_finalize */ + NULL, /* class_data */ + sizeof(ChupaZipFactory), + 0, + (GInstanceInitFunc) init, + }; + + chupa_type_zip_factory = + g_type_module_register_type(type_module, + CHUPA_TYPE_MODULE_FACTORY, + "ChupaZipFactory", + &info, 0); +} + +G_MODULE_EXPORT GList * +CHUPA_MODULE_IMPL_INIT (GTypeModule *type_module) +{ + GList *registered_types = NULL; + + register_type(type_module); + if (chupa_type_zip_factory) { + registered_types = + g_list_prepend(registered_types, + (gchar *)g_type_name(chupa_type_zip_factory)); + } + + return registered_types; +} + +G_MODULE_EXPORT void +CHUPA_MODULE_IMPL_EXIT (void) +{ +} + +G_MODULE_EXPORT GObject * +CHUPA_MODULE_IMPL_INSTANTIATE (const gchar *first_property, va_list var_args) +{ + return g_object_new_valist(CHUPA_TYPE_ZIP_FACTORY, first_property, var_args); +} + +static GList * +get_mime_types (ChupaModuleFactory *factory) +{ + GList *mime_types = NULL; + + mime_types = g_list_prepend(mime_types, g_strdup("application/zip")); + + return mime_types; +} + +GObject * +create (ChupaModuleFactory *factory) +{ + return G_OBJECT(chupa_decomposer_new("zip", NULL)); +} + +/* +vi:ts=4:nowrap:ai:expandtab:sw=4 +*/ From null+ranguba at clear-code.com Sun Sep 26 10:30:54 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Sun, 26 Sep 2010 14:30:54 +0000 Subject: [groonga-commit:1332] ranguba/chupatext [master] always register type. Message-ID: <20100926143104.B9C81170640@taiyaki.ru> Kouhei Sutou 2010-09-26 14:30:54 +0000 (Sun, 26 Sep 2010) New Revision: 4ea1c88fa6a35ac7637f9b3884b2b2db329ce94b Log: always register type. Modified files: module/excel.c module/word.c Modified: module/excel.c (+11 -19) =================================================================== --- module/excel.c 2010-09-26 14:28:43 +0000 (76414fe) +++ module/excel.c 2010-09-26 14:30:54 +0000 (f0d4b1b) @@ -121,7 +121,7 @@ chupa_excel_decomposer_class_init(ChupaExcelDecomposerClass *klass) dec_class->feed = chupa_excel_decomposer_feed; } -static GType +static void register_type(GTypeModule *type_module) { static const GTypeInfo info = { @@ -135,22 +135,17 @@ register_type(GTypeModule *type_module) 0, (GInstanceInitFunc) NULL, }; - GType type = chupa_type_excel_decomposer; - - if (!type) { - type = g_type_module_register_type(type_module, - CHUPA_TYPE_EXTERNAL_DECOMPOSER, - "ChupaExcelDecomposer", - &info, 0); - chupa_type_excel_decomposer = type; - } - return type; + + chupa_type_excel_decomposer = + g_type_module_register_type(type_module, + CHUPA_TYPE_EXTERNAL_DECOMPOSER, + "ChupaExcelDecomposer", + &info, 0); } G_MODULE_EXPORT GList * CHUPA_MODULE_IMPL_INIT(GTypeModule *type_module) { - GType type = register_type(type_module); GList *registered_types = NULL; GOErrorInfo *plugin_errs; char *argv[2]; @@ -169,13 +164,10 @@ CHUPA_MODULE_IMPL_INIT(GTypeModule *type_module) go_error_info_free(plugin_errs); } -#if 0 - if (type) { - registered_types = - g_list_prepend(registered_types, - (gchar *)g_type_name(type)); - } -#endif + register_type(type_module); + registered_types = + g_list_prepend(registered_types, + (gchar *)g_type_name(chupa_type_excel_decomposer)); return registered_types; } Modified: module/word.c (+11 -19) =================================================================== --- module/word.c 2010-09-26 14:28:43 +0000 (8b2417c) +++ module/word.c 2010-09-26 14:30:54 +0000 (e98114a) @@ -178,7 +178,7 @@ chupa_word_decomposer_class_init(ChupaWordDecomposerClass *klass) super->feed = chupa_word_decomposer_feed; } -static GType +static void register_type(GTypeModule *type_module) { static const GTypeInfo info = { @@ -192,31 +192,23 @@ register_type(GTypeModule *type_module) 0, (GInstanceInitFunc) NULL, }; - GType type = chupa_type_word_decomposer; - - if (!type) { - type = g_type_module_register_type(type_module, - CHUPA_TYPE_DECOMPOSER, - "ChupaWordDecomposer", - &info, 0); - chupa_type_word_decomposer = type; - } - return type; + + chupa_type_word_decomposer = + g_type_module_register_type(type_module, + CHUPA_TYPE_DECOMPOSER, + "ChupaWordDecomposer", + &info, 0); } G_MODULE_EXPORT GList * CHUPA_MODULE_IMPL_INIT(GTypeModule *type_module) { - GType type = register_type(type_module); GList *registered_types = NULL; + register_type(type_module); -#if 0 - if (type) { - registered_types = - g_list_prepend(registered_types, - (gchar *)g_type_name(type)); - } -#endif + registered_types = + g_list_prepend(registered_types, + (gchar *)g_type_name(chupa_type_word_decomposer)); return registered_types; } From null+ranguba at clear-code.com Sun Sep 26 10:31:52 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Sun, 26 Sep 2010 14:31:52 +0000 Subject: [groonga-commit:1333] ranguba/chupatext [master] always register type. Message-ID: <20100926143201.D95CB170640@taiyaki.ru> Kouhei Sutou 2010-09-26 14:31:52 +0000 (Sun, 26 Sep 2010) New Revision: d92f1fa0f84ae132b63cc4164205ad61a72e83c9 Log: always register type. Modified files: module/pdf.c Modified: module/pdf.c (+11 -20) =================================================================== --- module/pdf.c 2010-09-26 14:30:54 +0000 (c4efabe) +++ module/pdf.c 2010-09-26 14:31:52 +0000 (321716f) @@ -103,7 +103,7 @@ chupa_pdf_decomposer_class_init(ChupaPDFDecomposerClass *klass) } -static GType +static void register_type(GTypeModule *type_module) { static const GTypeInfo info = { @@ -117,32 +117,23 @@ register_type(GTypeModule *type_module) 0, (GInstanceInitFunc) NULL, }; - GType type = chupa_type_pdf_decomposer; - - if (!type) { - type = g_type_module_register_type(type_module, - CHUPA_TYPE_DECOMPOSER, - "ChupaPDFDecomposer", - &info, 0); - chupa_type_pdf_decomposer = type; - POPPLER_TYPE_DOCUMENT; - } - return type; + + chupa_type_pdf_decomposer = + g_type_module_register_type(type_module, + CHUPA_TYPE_DECOMPOSER, + "ChupaPDFDecomposer", + &info, 0); } G_MODULE_EXPORT GList * CHUPA_MODULE_IMPL_INIT(GTypeModule *type_module) { - GType type = register_type(type_module); GList *registered_types = NULL; -#if 0 - if (type) { - registered_types = - g_list_prepend(registered_types, - (gchar *)g_type_name(type)); - } -#endif + register_type(type_module); + registered_types = + g_list_prepend(registered_types, + (gchar *)g_type_name(chupa_type_pdf_decomposer)); return registered_types; } From null+ranguba at clear-code.com Sun Sep 26 10:39:42 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Sun, 26 Sep 2010 14:39:42 +0000 Subject: [groonga-commit:1334] ranguba/chupatext [master] PowerPoint decomposer works as dynamic decomposer. Message-ID: <20100926143956.E265A170640@taiyaki.ru> Kouhei Sutou 2010-09-26 14:39:42 +0000 (Sun, 26 Sep 2010) New Revision: 8346d06ed9fc98ceebd9abf6300a67adc7c8f323 Log: PowerPoint decomposer works as dynamic decomposer. Added files: module/powerpoint_factory.c Modified files: module/Makefile.am test/Makefile.am Renamed files: module/powerpoint.c (from module/chupa_mspowerpoint.c) test/test_powerpoint.c (from test/test_mspowerpoint.c) Modified: module/Makefile.am (+9 -4) =================================================================== --- module/Makefile.am 2010-09-26 14:31:52 +0000 (0b03a66) +++ module/Makefile.am 2010-09-26 14:39:42 +0000 (1452de9) @@ -25,7 +25,8 @@ if HAVE_GOFFICE decomposer_LTLIBRARIES += excel.la factory_LTLIBRARIES += excel_factory.la endif -decomposer_LTLIBRARIES += chupa_mspowerpoint.la +decomposer_LTLIBRARIES += powerpoint.la +factory_LTLIBRARIES += powerpoint_factory.la text_la_SOURCES = text.c text_la_CPPFLAGS = $(GLIB_CFLAGS) $(GSF_CFLAGS) @@ -75,9 +76,13 @@ excel_factory_la_SOURCES = excel_factory.c excel_factory_la_CPPFLAGS = $(GLIB_CFLAGS) $(GSF_CFLAGS) excel_factory_la_LIBADD = $(GLIB_LIBS) -chupa_mspowerpoint_la_SOURCES = chupa_mspowerpoint.c -chupa_mspowerpoint_la_CPPFLAGS = $(GSF_CFLAGS) -chupa_mspowerpoint_la_LIBADD = $(GSF_LIBS) +powerpoint_la_SOURCES = powerpoint.c +powerpoint_la_CPPFLAGS = $(GSF_CFLAGS) +powerpoint_la_LIBADD = $(GSF_LIBS) + +powerpoint_factory_la_SOURCES = powerpoint_factory.c +powerpoint_factory_la_CPPFLAGS = $(GLIB_CFLAGS) $(GSF_CFLAGS) +powerpoint_factory_la_LIBADD = $(GLIB_LIBS) all: prereq Renamed: module/powerpoint.c (+10 -19) 94% =================================================================== --- module/chupa_mspowerpoint.c 2010-09-26 14:31:52 +0000 (26fdda5) +++ module/powerpoint.c 2010-09-26 14:39:42 +0000 (07fb3d3) @@ -326,7 +326,7 @@ chupa_ppt_decomposer_class_init(ChupaPPTDecomposerClass *klass) dec_class->feed_component = chupa_feed_ppt; } -static GType +static void register_type(GTypeModule *type_module) { static const GTypeInfo info = { @@ -340,32 +340,23 @@ register_type(GTypeModule *type_module) 0, (GInstanceInitFunc) NULL, }; - GType type = chupa_type_ppt_decomposer; - if (!type) { - type = g_type_module_register_type(type_module, - CHUPA_TYPE_ARCHIVE_DECOMPOSER, - "ChupaPPTDecomposer", - &info, 0); - chupa_type_ppt_decomposer = type; - chupa_decomposer_register("application/vnd.ms-powerpoint", type); - } - return type; + chupa_type_ppt_decomposer = + g_type_module_register_type(type_module, + CHUPA_TYPE_ARCHIVE_DECOMPOSER, + "ChupaPPTDecomposer", + &info, 0); } G_MODULE_EXPORT GList * CHUPA_MODULE_IMPL_INIT(GTypeModule *type_module) { - GType type = register_type(type_module); GList *registered_types = NULL; -#if 0 - if (type) { - registered_types = - g_list_prepend(registered_types, - (gchar *)g_type_name(type)); - } -#endif + register_type(type_module); + registered_types = + g_list_prepend(registered_types, + (gchar *)g_type_name(chupa_type_ppt_decomposer)); return registered_types; } Added: module/powerpoint_factory.c (+159 -0) 100644 =================================================================== --- /dev/null +++ module/powerpoint_factory.c 2010-09-26 14:39:42 +0000 (d0e785b) @@ -0,0 +1,159 @@ +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Copyright (C) 2010 Kouhei Sutou + * + * 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 3 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 program. If not, see . + * + */ + +#ifdef HAVE_CONFIG_H +# include +#endif /* HAVE_CONFIG_H */ + +#include +#include +#include +/* #include */ +#include + +#include +#include +#include + +#define CHUPA_TYPE_PPT_FACTORY chupa_type_ppt_factory +#define CHUPA_PPT_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CHUPA_TYPE_PPT_FACTORY, ChupaPPTFactory)) +#define CHUPA_PPT_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CHUPA_TYPE_PPT_FACTORY, ChupaPPTFactoryClass)) +#define CHUPA_IS_PPT_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CHUPA_TYPE_PPT_FACTORY)) +#define CHUPA_IS_PPT_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CHUPA_TYPE_PPT_FACTORY)) +#define CHUPA_PPT_FACTORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), CHUPA_TYPE_PPT_FACTORY, ChupaPPTFactoryClass)) + +typedef struct _ChupaPPTFactory ChupaPPTFactory; +typedef struct _ChupaPPTFactoryClass ChupaPPTFactoryClass; + +struct _ChupaPPTFactory +{ + ChupaModuleFactory object; +}; + +struct _ChupaPPTFactoryClass +{ + ChupaModuleFactoryClass parent_class; +}; + +static GType chupa_type_ppt_factory = 0; +static ChupaModuleFactoryClass *parent_class; + +static GList *get_mime_types (ChupaModuleFactory *factory); +static GObject *create (ChupaModuleFactory *factory); + +static void +class_init (ChupaModuleFactoryClass *klass) +{ + GObjectClass *gobject_class; + ChupaModuleFactoryClass *factory_class; + + parent_class = g_type_class_peek_parent(klass); + + gobject_class = G_OBJECT_CLASS(klass); + factory_class = CHUPA_MODULE_FACTORY_CLASS(klass); + + factory_class->get_mime_types = get_mime_types; + factory_class->create = create; +} + +static void +init (ChupaPPTFactory *factory) +{ +} + +static void +register_type (GTypeModule *type_module) +{ + static const GTypeInfo info = + { + sizeof (ChupaPPTFactoryClass), + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) class_init, + NULL, /* class_finalize */ + NULL, /* class_data */ + sizeof(ChupaPPTFactory), + 0, + (GInstanceInitFunc) init, + }; + + chupa_type_ppt_factory = + g_type_module_register_type(type_module, + CHUPA_TYPE_MODULE_FACTORY, + "ChupaPPTFactory", + &info, 0); +} + +G_MODULE_EXPORT GList * +CHUPA_MODULE_IMPL_INIT (GTypeModule *type_module) +{ + GList *registered_types = NULL; + + register_type(type_module); + if (chupa_type_ppt_factory) { + registered_types = + g_list_prepend(registered_types, + (gchar *)g_type_name(chupa_type_ppt_factory)); + } + + return registered_types; +} + +G_MODULE_EXPORT void +CHUPA_MODULE_IMPL_EXIT (void) +{ +} + +G_MODULE_EXPORT GObject * +CHUPA_MODULE_IMPL_INSTANTIATE (const gchar *first_property, va_list var_args) +{ + return g_object_new_valist(CHUPA_TYPE_PPT_FACTORY, first_property, var_args); +} + +static GList * +get_mime_types (ChupaModuleFactory *factory) +{ + GList *mime_types = NULL; + + mime_types = g_list_prepend(mime_types, g_strdup("application/vnd.ms-powerpoint")); + + return mime_types; +} + +GObject * +create (ChupaModuleFactory *factory) +{ + static int n_instances = 0; + GObject *decomposer; + + decomposer = G_OBJECT(chupa_decomposer_new("ppt", NULL)); + n_instances++; + if (n_instances == 1) { + /* FIXME: This causes memory leak but we need to + * keep at least 1 decomposer instance to avoid + * duplicated non-module GType + * (e.g. PopplerDocument) registration. */ + g_object_ref(decomposer); + } + return decomposer; +} + +/* +vi:ts=4:nowrap:ai:expandtab:sw=4 +*/ Modified: test/Makefile.am (+2 -2) =================================================================== --- test/Makefile.am 2010-09-26 14:31:52 +0000 (c5f9ca2) +++ test/Makefile.am 2010-09-26 14:39:42 +0000 (3a9003c) @@ -29,7 +29,7 @@ if HAVE_GOFFICE noinst_LTLIBRARIES += test_excel.la endif -noinst_LTLIBRARIES += test_mspowerpoint.la +noinst_LTLIBRARIES += test_powerpoint.la endif EXTRA_DIST = \ @@ -72,7 +72,7 @@ test_restrict_input_stream_la_SOURCES = test_restrict_input_stream.c test_pdf_la_SOURCES = test_pdf.c chupa_test_util.c test_word_la_SOURCES = test_word.c chupa_test_util.c test_excel_la_SOURCES = test_excel.c chupa_test_util.c -test_mspowerpoint_la_SOURCES = test_mspowerpoint.c chupa_test_util.c +test_powerpoint_la_SOURCES = test_powerpoint.c chupa_test_util.c test_tar_la_SOURCES = test_tar.c chupa_test_util.c test_zip_la_SOURCES = test_zip.c chupa_test_util.c Renamed: test/test_powerpoint.c (+2 -2) 88% =================================================================== --- test/test_mspowerpoint.c 2010-09-26 14:31:52 +0000 (f4de132) +++ test/test_powerpoint.c 2010-09-26 14:39:42 +0000 (bc3b69b) @@ -20,12 +20,12 @@ teardown(void) #define decompose_msppt chupa_test_decompose_fixture void -test_decompose_msppt(void) +test_decompose_ppt(void) { cut_assert_equal_string("Sample Title\n\n", decompose_msppt("sample.ppt", NULL)); } void -test_decompose_msppt_ja(void) +test_decompose_ppt_ja(void) { } From null+ranguba at clear-code.com Sun Sep 26 10:45:09 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Sun, 26 Sep 2010 14:45:09 +0000 Subject: [groonga-commit:1335] ranguba/chupatext [master] remove deprecated decomposer functions. Message-ID: <20100926144519.283D9170F30@taiyaki.ru> Kouhei Sutou 2010-09-26 14:45:09 +0000 (Sun, 26 Sep 2010) New Revision: 1fa2c2124c3a011feecf634a9960a1b0e024f613 Log: remove deprecated decomposer functions. Modified files: chupatext/chupa_decomposer.h test/test_decomposer.c test/test_external_decomposer.c Modified: chupatext/chupa_decomposer.h (+0 -3) =================================================================== --- chupatext/chupa_decomposer.h 2010-09-26 14:39:42 +0000 (d00b94a) +++ chupatext/chupa_decomposer.h 2010-09-26 14:45:09 +0000 (885635c) @@ -50,9 +50,6 @@ gboolean chupa_decomposer_feed (ChupaDecomposer *dec, ChupaTextInput *input, GError **error); -void chupa_decomposer_register(const gchar *mime_type, GType type); -void chupa_decomposer_unregister(const gchar *mime_type, GType type); - G_END_DECLS #endif /* CHUPATEXT_DECOMPOSER_H */ Modified: test/test_decomposer.c (+1 -1) =================================================================== --- test/test_decomposer.c 2010-09-26 14:39:42 +0000 (3d2dba8) +++ test/test_decomposer.c 2010-09-26 14:45:09 +0000 (2753f75) @@ -35,7 +35,6 @@ test_search(void) { decomp = chupa_dispatcher_dispatch(dispatcher, "text/plain"); cut_assert_not_null(decomp); - cut_assert_not_null(CHUPA_TEXT_DECOMPOSER(decomp)); } #define CHUPA_TEST_TYPE_DUMMY_DECOMPOSER chupa_test_dummy_decomposer_get_type() @@ -80,6 +79,7 @@ void test_register(void) { static const char test_dummy_type[] = "application/x-chupa-test"; + return; chupa_decomposer_register(test_dummy_type, CHUPA_TEST_TYPE_DUMMY_DECOMPOSER); chupa_decomposer_unregister(test_dummy_type, CHUPA_TEST_TYPE_DUMMY_DECOMPOSER); } Modified: test/test_external_decomposer.c (+3 -2) =================================================================== --- test/test_external_decomposer.c 2010-09-26 14:39:42 +0000 (f4520d5) +++ test/test_external_decomposer.c 2010-09-26 14:45:09 +0000 (ffa795c) @@ -73,13 +73,14 @@ void setup(void) { chupa_test_setup(); - chupa_decomposer_register(test_external_type, CHUPA_TEST_TYPE_EXTERNAL_DECOMPOSER); + cut_omit("chupa_decomposer_register() was deleted"); + /* chupa_decomposer_register(test_external_type, CHUPA_TEST_TYPE_EXTERNAL_DECOMPOSER); */ } void teardown(void) { - chupa_decomposer_unregister(test_external_type, CHUPA_TEST_TYPE_EXTERNAL_DECOMPOSER); + /* chupa_decomposer_unregister(test_external_type, CHUPA_TEST_TYPE_EXTERNAL_DECOMPOSER); */ chupa_test_teardown(); } From null+ranguba at clear-code.com Sun Sep 26 10:48:25 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Sun, 26 Sep 2010 14:48:25 +0000 Subject: [groonga-commit:1336] ranguba/chupatext [master] remove needless module/prereq.mk. Message-ID: <20100926144835.B17E3170640@taiyaki.ru> Kouhei Sutou 2010-09-26 14:48:25 +0000 (Sun, 26 Sep 2010) New Revision: ecd7bc5f47c98b7a72603dbc88100e750e4580da Log: remove needless module/prereq.mk. Removed files: module/prereq.mk Modified files: module/Makefile.am Modified: module/Makefile.am (+0 -4) =================================================================== --- module/Makefile.am 2010-09-26 14:45:09 +0000 (1452de9) +++ module/Makefile.am 2010-09-26 14:48:25 +0000 (e4c9efc) @@ -83,7 +83,3 @@ powerpoint_la_LIBADD = $(GSF_LIBS) powerpoint_factory_la_SOURCES = powerpoint_factory.c powerpoint_factory_la_CPPFLAGS = $(GLIB_CFLAGS) $(GSF_CFLAGS) powerpoint_factory_la_LIBADD = $(GLIB_LIBS) - -all: prereq - - at am__include@ $(srcdir)/prereq.mk Deleted: module/prereq.mk (+0 -18) 100644 =================================================================== --- module/prereq.mk 2010-09-26 14:45:09 +0000 (eda5c18) +++ /dev/null @@ -1,18 +0,0 @@ -prereq: init_chupa.h - -init_chupa.h: $(SOURCES) - @set dummy $(SOURCES); shift; \ - test $$# -gt 0 || set chupa_*.c; \ - srcdir="$(srcdir)"; : $${srcdir:=.}; \ - for f do \ - b=`basename $$f .c`; \ - sed -n '/chupa_decomposer_register/s/.*\(".*"\).*/REGISTER(\1,"'$$b'");/p' \ - "$$srcdir/$$f"; \ - done > $@.new && \ - if test -f $@ && cmp $@ $@.new; then \ - echo $@ is up-to-date; \ - rm $@.new; \ - else \ - echo updating $@; \ - mv $@.new $@; \ - fi From null+ranguba at clear-code.com Sun Sep 26 20:48:11 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Mon, 27 Sep 2010 00:48:11 +0000 Subject: [groonga-commit:1337] ranguba/chupatext [master] * Makefile.am (prereq): merged from prereq.mk. Message-ID: <20100927004841.4EDA8170640@taiyaki.ru> Nobuyoshi Nakada 2010-09-27 00:48:11 +0000 (Mon, 27 Sep 2010) New Revision: 12e17e67736a4621af91c2184fe16d45c59cd102 Log: * Makefile.am (prereq): merged from prereq.mk. Removed files: prereq.mk Modified files: Makefile.am Modified: Makefile.am (+20 -1) =================================================================== --- Makefile.am 2010-09-26 14:48:25 +0000 (5d9423f) +++ Makefile.am 2010-09-27 00:48:11 +0000 (a0cc318) @@ -10,4 +10,23 @@ EXTRA_DIST = \ all-recursive: prereq - at am__include@ $(srcdir)/prereq.mk +prereq: + +GIT = git + +up: pull prereq + +pull: + @cd "$(srcdir)" && $(GIT) pull + +prereq: prereq-local prereq-recursive + +prereq-local: update-version.h + +prereq-recursive: + +update-version.h: + @cd "$(top_srcdir)" && \ + $(SHELL) ./tool/version-update.sh chupatext/version.h + +.PHONY: update-version.h prereq-local prereq-recursive Deleted: prereq.mk (+0 -39) 100755 =================================================================== --- prereq.mk 2010-09-26 14:48:25 +0000 (8ee9afa) +++ /dev/null @@ -1,39 +0,0 @@ -#!/usr/bin/make -f - -prereq: - -GIT = git - -up: pull prereq - -pull: - @cd "$(srcdir)" && $(GIT) pull - -prereq: prereq-local prereq-recursive - -prereq-local: update-version.h - -prereq-recursive: - @local_target=`echo $@ | sed s/-recursive//`; \ - top="$(top_srcdir)"; \ - : "$${top:=.}"; \ - set dummy $(SUBDIRS); shift; \ - if test $$# = 0; then \ - set dummy `ls */prereq.mk 2> /dev/null | sed 's/\/prereq\.mk$$//'`; \ - shift; \ - fi; \ - for subdir do \ - test -f "$$top/$$subdir/prereq.mk" || continue; \ - (if test -z "$(am__cd)"; then cd $$subdir; else $(am__cd) $$subdir; fi && \ - if test -f Makefile; then \ - exec $(MAKE) $(AM_MAKEFLAGS) $$local_target; \ - else \ - exec $(MAKE) -f prereq.mk $(AM_MAKEFLAGS) $$local_target; \ - fi) || exit 1; \ - done - -update-version.h: - @cd "$(top_srcdir)" && \ - $(SHELL) ./tool/version-update.sh chupatext/version.h - -.PHONY: update-version.h prereq-local prereq-recursive From null+ranguba at clear-code.com Sun Sep 26 20:51:25 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Mon, 27 Sep 2010 00:51:25 +0000 Subject: [groonga-commit:1338] ranguba/chupatext [master] * .gitignore (strace.out): made by test/run-test.sh with CUTTER_CHECK_STRACE. Message-ID: <20100927005140.AD4F2170640@taiyaki.ru> Nobuyoshi Nakada 2010-09-27 00:51:25 +0000 (Mon, 27 Sep 2010) New Revision: 04cda28dc0e31846de527f3f94cc96c7abc8c8d3 Log: * .gitignore (strace.out): made by test/run-test.sh with CUTTER_CHECK_STRACE. Modified files: .gitignore Modified: .gitignore (+1 -0) =================================================================== --- .gitignore 2010-09-27 00:48:11 +0000 (a65a95b) +++ .gitignore 2010-09-27 00:51:25 +0000 (a89a8a4) @@ -20,3 +20,4 @@ config.h.in /configure .deps/ .libs/ +strace.out From null+ranguba at clear-code.com Sun Sep 26 21:00:59 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Mon, 27 Sep 2010 01:00:59 +0000 Subject: [groonga-commit:1339] ranguba/chupatext [master] * chupatext/chupa_text_input.c (InputStreamFile): removed intermediate class. Message-ID: <20100927010118.E9AB8170640@taiyaki.ru> Nobuyoshi Nakada 2010-09-27 01:00:59 +0000 (Mon, 27 Sep 2010) New Revision: 98cdf83d9e836868ceaaf262da11f37dfc28dc27 Log: * chupatext/chupa_text_input.c (InputStreamFile): removed intermediate class. Modified files: chupatext/chupa_text_input.c Modified: chupatext/chupa_text_input.c (+0 -110) =================================================================== --- chupatext/chupa_text_input.c 2010-09-27 00:51:25 +0000 (91d9027) +++ chupatext/chupa_text_input.c 2010-09-27 01:00:59 +0000 (dae88ae) @@ -8,119 +8,9 @@ #include #include -#define INPUT_STREAM_FILE_TYPE input_stream_file_get_type() -#define INPUT_STREAM_FILE(obj) \ - G_TYPE_CHECK_INSTANCE_CAST(obj, INPUT_STREAM_FILE_TYPE, InputStreamFile) -#define INPUT_STREAM_FILE_CLASS(klass) \ - G_TYPE_CHECK_CLASS_CAST(klass, INPUT_STREAM_FILE_TYPE, InputStreamFileClass) -#define IS_INPUT_STREAM_FILE(obj) \ - G_TYPE_CHECK_INSTANCE_TYPE(obj, INPUT_STREAM_FILE_TYPE) -#define IS_INPUT_STREAM_FILE_CLASS(klass) \ - G_TYPE_CHECK_CLASS_TYPE(klass, INPUT_STREAM_FILE_TYPE) -#define INPUT_STREAM_FILE_GET_CLASS(obj) \ - G_TYPE_INSTANCE_GET_CLASS(obj, INPUT_STREAM_FILE_TYPE, InputStreamFileClass) - -typedef struct { - GObject parent_instance; - - char *path; - GInputStream *stream; -} InputStreamFile; - -typedef struct { - GObjectClass parent_class; -} InputStreamFileClass; - -static void input_stream_file_file_iface_init(GFileIface *iface); - static const char meta_filename[] = "filename"; static const char meta_charset[] = "charset"; -G_DEFINE_TYPE_WITH_CODE(InputStreamFile, input_stream_file, G_TYPE_OBJECT, - G_IMPLEMENT_INTERFACE(G_TYPE_FILE, - input_stream_file_file_iface_init)) - -static void -input_stream_file_finalize(GObject *object) -{ - InputStreamFile *isfile = (InputStreamFile *)object; - g_object_unref(isfile->stream); -} - -static GFileInputStream * -input_stream_file_read(GFile *file, GCancellable *cancellable, GError **error) -{ - InputStreamFile *isfile = (InputStreamFile *)file; - return g_object_ref(isfile->stream); -} - -static GFileInfo * -input_stream_file_query_info(GFile *file, const char *attributes, - GFileQueryInfoFlags flags, - GCancellable *cancellable, GError **error) -{ - InputStreamFile *isfile = (InputStreamFile *)file; - GFileInfo *info = NULL; - GSeekable *sk; - goffset size, curpos; - if (strcmp(attributes, G_FILE_ATTRIBUTE_STANDARD_NAME) == 0) { - if (isfile->path) { - info = g_file_info_new(); - g_file_info_set_attribute_byte_string(info, attributes, isfile->path); - } - } - else if (strcmp(attributes, G_FILE_ATTRIBUTE_STANDARD_SIZE) == 0 && - G_IS_SEEKABLE(isfile->stream) && - g_seekable_can_seek(sk = G_SEEKABLE(isfile->stream)) && - (curpos = g_seekable_tell(sk), - g_seekable_seek(sk, (goffset)0, G_SEEK_END, NULL, NULL))) { - size = g_seekable_tell(sk); - g_seekable_seek(sk, curpos, G_SEEK_SET, NULL, NULL); - info = g_file_info_new(); - g_file_info_set_attribute_uint64(info, attributes, size); - } - return info; -} - -static GFile * -input_stream_file_dup(GFile *file) -{ - return g_object_ref(file); -} - -static void -input_stream_file_init(InputStreamFile *isfile) -{ - isfile->path = NULL; - isfile->stream = NULL; -} - -static void -input_stream_file_class_init(InputStreamFileClass *klass) -{ - GObjectClass *gobject_class = G_OBJECT_CLASS(klass); - - gobject_class->finalize = input_stream_file_finalize; -} - -static void -input_stream_file_file_iface_init(GFileIface *iface) -{ - iface->dup = input_stream_file_dup; - iface->query_info = input_stream_file_query_info; - iface->read_fn = input_stream_file_read; -} - -GFile * -input_stream_file_new(const char *path, GInputStream *stream) -{ - InputStreamFile *isfile = g_object_new(INPUT_STREAM_FILE_TYPE, NULL); - isfile->path = g_strdup(path); - g_object_ref(isfile->stream = stream); - return G_FILE(isfile); -} - - /* ChupaTextInput */ G_DEFINE_TYPE(ChupaTextInput, chupa_text_input, G_TYPE_OBJECT) From null+ranguba at clear-code.com Sun Sep 26 22:34:29 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Mon, 27 Sep 2010 02:34:29 +0000 Subject: [groonga-commit:1340] ranguba/chupatext [master] * chupatext/chupa_text_input.c (guess_mime_type): fix type. Message-ID: <20100927024517.43AE9170EE5@taiyaki.ru> Nobuyoshi Nakada 2010-09-27 02:34:29 +0000 (Mon, 27 Sep 2010) New Revision: 1f710abc4becc7f9a846bff86fb879c32ba3f473 Log: * chupatext/chupa_text_input.c (guess_mime_type): fix type. Modified files: chupatext/chupa_text_input.c Modified: chupatext/chupa_text_input.c (+1 -1) =================================================================== --- chupatext/chupa_text_input.c 2010-09-27 01:00:59 +0000 (dae88ae) +++ chupatext/chupa_text_input.c 2010-09-27 02:34:29 +0000 (60ce0af) @@ -45,7 +45,7 @@ guess_mime_type(const char *name, GBufferedInputStream *buffered, gboolean *unce { const char *content_type; gsize len; - const char *buf; + const guchar *buf; g_buffered_input_stream_fill(buffered, peek_buffer_size, NULL, NULL); buf = g_buffered_input_stream_peek_buffer(buffered, &len); From null+ranguba at clear-code.com Sun Sep 26 22:43:08 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Mon, 27 Sep 2010 02:43:08 +0000 Subject: [groonga-commit:1341] ranguba/chupatext [master] * chupatext/archive_decomposer.c: removed unused functions and variables. chupatext/chupa_decomposer.c: ditto. chupatext/chupa_dispatcher.c: ditto. chupatext/chupa_metadata.c: ditto. chupatext/chupa_restrict_input_stream.c: ditto. chupatext/external_decomposer.c: ditto. module/excel.c: ditto. module/pdf.c: ditto. module/powerpoint.c: ditto. module/tar.c: ditto. module/zip.c: ditto. Message-ID: <20100927024517.89623170F80@taiyaki.ru> Nobuyoshi Nakada 2010-09-27 02:43:08 +0000 (Mon, 27 Sep 2010) New Revision: d4d68898f31f3ad2dec9d7079b5536c7eb4b5f10 Log: * chupatext/archive_decomposer.c: removed unused functions and variables. chupatext/chupa_decomposer.c: ditto. chupatext/chupa_dispatcher.c: ditto. chupatext/chupa_metadata.c: ditto. chupatext/chupa_restrict_input_stream.c: ditto. chupatext/external_decomposer.c: ditto. module/excel.c: ditto. module/pdf.c: ditto. module/powerpoint.c: ditto. module/tar.c: ditto. module/zip.c: ditto. Modified files: chupatext/archive_decomposer.c chupatext/chupa_decomposer.c chupatext/chupa_dispatcher.c chupatext/chupa_metadata.c chupatext/chupa_restrict_input_stream.c chupatext/external_decomposer.c module/excel.c module/pdf.c module/powerpoint.c module/tar.c module/zip.c Modified: chupatext/archive_decomposer.c (+17 -9) =================================================================== --- chupatext/archive_decomposer.c 2010-09-27 02:40:47 +0000 (6524882) +++ chupatext/archive_decomposer.c 2010-09-27 02:43:08 +0000 (0368aa4) @@ -5,6 +5,7 @@ #include "archive_decomposer.h" +#ifdef USE_CHUPA_ARCHIVE_DECOMPOSER_PRIVATE #define CHUPA_ARCHIVE_DECOMPOSER_GET_PRIVATE(obj) \ (G_TYPE_INSTANCE_GET_PRIVATE(obj, \ CHUPA_TYPE_ARCHIVE_DECOMPOSER_OBJECT, \ @@ -14,9 +15,11 @@ typedef struct _ChupaArchiveDecomposerPrivate ChupaArchiveDecomposerPrivate; struct _ChupaArchiveDecomposerPrivate { }; +#endif G_DEFINE_ABSTRACT_TYPE(ChupaArchiveDecomposer, chupa_archive_decomposer, CHUPA_TYPE_DECOMPOSER) +#ifdef USE_CHUPA_ARCHIVE_DECOMPOSER_PRIVATE static void dispose(GObject *object) { @@ -31,7 +34,6 @@ set_property(GObject *object, GParamSpec *pspec) { ChupaArchiveDecomposer *dec = CHUPA_ARCHIVE_DECOMPOSER(object); - GObject *obj; switch (prop_id) { default: @@ -60,6 +62,7 @@ constructed(GObject *object) ChupaArchiveDecomposer *dec = CHUPA_ARCHIVE_DECOMPOSER(object); g_return_if_fail(dec); } +#endif static gboolean feed(ChupaDecomposer *dec, ChupaText *chupar, ChupaTextInput *input, GError **err) @@ -104,13 +107,18 @@ chupa_archive_decomposer_init(ChupaArchiveDecomposer *dec) static void chupa_archive_decomposer_class_init(ChupaArchiveDecomposerClass *klass) { - GObjectClass *gobject_class = G_OBJECT_CLASS(klass); - ChupaDecomposerClass *decomposer_class = CHUPA_DECOMPOSER_CLASS(klass); - - gobject_class->constructed = constructed; - gobject_class->dispose = dispose; - gobject_class->set_property = set_property; - gobject_class->get_property = get_property; - decomposer_class->feed = feed; +#ifdef USE_CHUPA_ARCHIVE_DECOMPOSER_PRIVATE + { + GObjectClass *gobject_class = G_OBJECT_CLASS(klass); + gobject_class->constructed = constructed; + gobject_class->dispose = dispose; + gobject_class->set_property = set_property; + gobject_class->get_property = get_property; + } +#endif + { + ChupaDecomposerClass *decomposer_class = CHUPA_DECOMPOSER_CLASS(klass); + decomposer_class->feed = feed; + } CHUPA_ARCHIVE_DECOMPOSER_CLASS(klass)->feed_component = chupa_text_feed; } Modified: chupatext/chupa_decomposer.c (+1 -3) =================================================================== --- chupatext/chupa_decomposer.c 2010-09-27 02:40:47 +0000 (a5e9e97) +++ chupatext/chupa_decomposer.c 2010-09-27 02:43:08 +0000 (372a255) @@ -32,10 +32,8 @@ chupa_decomposer_init(ChupaDecomposer *decomposer) static void chupa_decomposer_class_init(ChupaDecomposerClass *klass) { - GObjectClass *gobject_class = G_OBJECT_CLASS(klass); - /*GTypeModuleClass *type_module_class = G_TYPE_MODULE_CLASS(klass);*/ - #ifdef USE_CHUPA_DECOMPOSER_PRIVATE + GObjectClass *gobject_class = G_OBJECT_CLASS(klass); g_type_class_add_private(gobject_class, sizeof(ChupaDecomposerPrivate)); #endif } Modified: chupatext/chupa_dispatcher.c (+2 -0) =================================================================== --- chupatext/chupa_dispatcher.c 2010-09-27 02:40:47 +0000 (ab535a9) +++ chupatext/chupa_dispatcher.c 2010-09-27 02:43:08 +0000 (6db6a32) @@ -114,6 +114,7 @@ register_factory(ChupaDispatcherPrivate *priv, g_hash_table_insert(priv->mime_type_table, key, value); } +#if 0 static void unregister_factory(ChupaDispatcherPrivate *priv, const gchar *mime_type, ChupaModuleFactory *factory) @@ -128,6 +129,7 @@ unregister_factory(ChupaDispatcherPrivate *priv, } } } +#endif static void load_factories (ChupaDispatcherPrivate *priv) Modified: chupatext/chupa_metadata.c (+0 -4) =================================================================== --- chupatext/chupa_metadata.c 2010-09-27 02:40:47 +0000 (b3a3c6c) +++ chupatext/chupa_metadata.c 2010-09-27 02:43:08 +0000 (4f83593) @@ -38,7 +38,6 @@ static void chupa_metadata_class_init (ChupaMetadataClass *klass) { GObjectClass *gobject_class; - GParamSpec *spec; gobject_class = G_OBJECT_CLASS(klass); @@ -92,7 +91,6 @@ chupa_metadata_add_value(ChupaMetadata *metadata, const gchar *key, const gchar { ChupaMetadataPrivate *priv; GList *values = NULL; - gboolean existing; gpointer keyptr = (gpointer)key, valptr; priv = CHUPA_METADATA_GET_PRIVATE(metadata); @@ -112,7 +110,6 @@ void chupa_metadata_replace_value(ChupaMetadata *metadata, const gchar *key, const gchar *value) { ChupaMetadataPrivate *priv; - GList *values, *new_values; priv = CHUPA_METADATA_GET_PRIVATE(metadata); g_hash_table_replace(priv->data, g_strdup(key), g_list_append(NULL, g_strdup(value))); @@ -136,7 +133,6 @@ GList * chupa_metadata_get_values(ChupaMetadata *metadata, const gchar *key) { ChupaMetadataPrivate *priv; - GList *values; priv = CHUPA_METADATA_GET_PRIVATE(metadata); return g_hash_table_lookup(priv->data, key); Modified: chupatext/chupa_restrict_input_stream.c (+0 -1) =================================================================== --- chupatext/chupa_restrict_input_stream.c 2010-09-27 02:40:47 +0000 (9554c7c) +++ chupatext/chupa_restrict_input_stream.c 2010-09-27 02:43:08 +0000 (5818a8c) @@ -46,7 +46,6 @@ set_property(GObject *object, GParamSpec *pspec) { ChupaRestrictInputStreamPrivate *priv; - GObject *obj; goffset ofs; priv = CHUPA_RESTRICT_INPUT_STREAM_GET_PRIVATE(object); Modified: chupatext/external_decomposer.c (+0 -1) =================================================================== --- chupatext/external_decomposer.c 2010-09-27 02:40:47 +0000 (cd30778) +++ chupatext/external_decomposer.c 2010-09-27 02:43:08 +0000 (336d1d1) @@ -110,7 +110,6 @@ feed(ChupaDecomposer *dec, ChupaText *chupar, ChupaTextInput *input, GError **er ChupaExternalDecomposerClass *self_class; ChupaExternalDecomposer *extdec; ChupaExternalDecomposerPrivate *priv; - ChupaMetadata *meta; gboolean result; g_return_val_if_fail(CHUPA_IS_EXTERNAL_DECOMPOSER(dec), FALSE); Modified: module/excel.c (+0 -14) =================================================================== --- module/excel.c 2010-09-27 02:40:47 +0000 (8378d67) +++ module/excel.c 2010-09-27 02:43:08 +0000 (1d9ea20) @@ -57,7 +57,6 @@ static gboolean chupa_excel_decomposer_feed(ChupaDecomposer *dec, ChupaText *chupar, ChupaTextInput *input, GError **err) { - ChupaExcelDecomposer *xlsdec = CHUPA_EXCEL_DECOMPOSER(dec); GOFileSaver *fs = NULL; GOFileOpener *fo = NULL; GOIOContext *io_context = go_io_context_new(cc); @@ -102,22 +101,9 @@ chupa_excel_decomposer_feed(ChupaDecomposer *dec, ChupaText *chupar, } static void -chupa_excel_decomposer_init(ChupaExcelDecomposer *dec) -{ -} - -static void -chupa_excel_constructed(GObject *object) -{ - ChupaExcelDecomposer *dec = CHUPA_EXCEL_DECOMPOSER(object); -} - -static void chupa_excel_decomposer_class_init(ChupaExcelDecomposerClass *klass) { - GObjectClass *gobject_class = G_OBJECT_CLASS(klass); ChupaDecomposerClass *dec_class = CHUPA_DECOMPOSER_CLASS(klass); - gobject_class->constructed = chupa_excel_constructed; dec_class->feed = chupa_excel_decomposer_feed; } Modified: module/pdf.c (+0 -1) =================================================================== --- module/pdf.c 2010-09-27 02:40:47 +0000 (321716f) +++ module/pdf.c 2010-09-27 02:43:08 +0000 (7838d65) @@ -40,7 +40,6 @@ chupa_pdf_decomposer_feed(ChupaDecomposer *dec, ChupaText *chupar, ChupaTextInput *input, GError **err) { PopplerDocument *doc; - GError **error = NULL; GMemoryInputStream *mem = NULL; gssize count; gchar buffer[16*1024]; Modified: module/powerpoint.c (+2 -5) =================================================================== --- module/powerpoint.c 2010-09-27 02:40:47 +0000 (6f10dd0) +++ module/powerpoint.c 2010-09-27 02:43:08 +0000 (9917adb) @@ -82,6 +82,7 @@ typedef enum { PPT_ITEM_UNKNOWN = 0 } ppt_item_type_t; +#if 0 static unsigned int getushort(unsigned char *buffer, int offset) { @@ -94,6 +95,7 @@ getulong(unsigned char *buffer, int offset) return (unsigned long)buffer[offset] | ((unsigned long)buffer[offset+1]<<8) | ((unsigned long)buffer[offset+2]<<16) | ((unsigned long)buffer[offset+3]<<24); } +#endif #define WORK_SIZE 128 @@ -204,7 +206,6 @@ atom_processor(struct PPT *ppt, int type, int count, int buf_last, unsigned char } ppt->working_buffer[ppt->buf_idx++] = data; if (count == buf_last) { - int i; /* ppt->working_buffer[ppt->buf_idx++] = 0; */ /* printf("Atom:%x|\n", type); */ gsf_output_write(ppt->output, ppt->buf_idx, ppt->working_buffer); @@ -316,10 +317,6 @@ chupa_feed_ppt(ChupaText *chupar, ChupaTextInput *input, GError **error) } static void -chupa_ppt_decomposer_init(ChupaPPTDecomposer *dec) -{ -} -static void chupa_ppt_decomposer_class_init(ChupaPPTDecomposerClass *klass) { ChupaArchiveDecomposerClass *dec_class = CHUPA_ARCHIVE_DECOMPOSER_CLASS(klass); Modified: module/tar.c (+0 -5) =================================================================== --- module/tar.c 2010-09-27 02:40:47 +0000 (592fedf) +++ module/tar.c 2010-09-27 02:43:08 +0000 (50a2699) @@ -36,11 +36,6 @@ struct _ChupaTarDecomposerClass static GType chupa_type_tar_decomposer = 0; static void -chupa_tar_decomposer_init(ChupaTarDecomposer *dec) -{ -} - -static void chupa_tar_decomposer_class_init(ChupaTarDecomposerClass *klass) { ChupaArchiveDecomposerClass *dec_class = CHUPA_ARCHIVE_DECOMPOSER_CLASS(klass); Modified: module/zip.c (+0 -5) =================================================================== --- module/zip.c 2010-09-27 02:40:47 +0000 (fc68248) +++ module/zip.c 2010-09-27 02:43:08 +0000 (8492a33) @@ -36,11 +36,6 @@ struct _ChupaZipDecomposerClass static GType chupa_type_zip_decomposer = 0; static void -chupa_zip_decomposer_init(ChupaZipDecomposer *dec) -{ -} - -static void chupa_zip_decomposer_class_init(ChupaZipDecomposerClass *klass) { ChupaArchiveDecomposerClass *dec_class = CHUPA_ARCHIVE_DECOMPOSER_CLASS(klass); From null+ranguba at clear-code.com Sun Sep 26 22:37:43 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Mon, 27 Sep 2010 02:37:43 +0000 Subject: [groonga-commit:1342] ranguba/chupatext [master] * chupatext/archive_decomposer.c (feed): missing return values. chupatext/chupa_text_input_stream.c (close_fn): ditto. module/powerpoint.c (dump_file): ditto. module/word.c (chupa_word_decomposer_feed): ditto. Message-ID: <20100927024517.674EB170F7E@taiyaki.ru> Nobuyoshi Nakada 2010-09-27 02:37:43 +0000 (Mon, 27 Sep 2010) New Revision: 971f7c405c21cf044383262c3a0a6530f701093a Log: * chupatext/archive_decomposer.c (feed): missing return values. chupatext/chupa_text_input_stream.c (close_fn): ditto. module/powerpoint.c (dump_file): ditto. module/word.c (chupa_word_decomposer_feed): ditto. Modified files: chupatext/archive_decomposer.c chupatext/chupa_text_input_stream.c module/powerpoint.c module/word.c Modified: chupatext/archive_decomposer.c (+3 -3) =================================================================== --- chupatext/archive_decomposer.c 2010-09-27 02:34:29 +0000 (35f3eb3) +++ chupatext/archive_decomposer.c 2010-09-27 02:37:43 +0000 (6524882) @@ -70,13 +70,13 @@ feed(ChupaDecomposer *dec, ChupaText *chupar, ChupaTextInput *input, GError **er ChupaArchiveDecomposerClass *arch_class; int i, num; - g_return_if_fail(CHUPA_IS_ARCHIVE_DECOMPOSER(dec)); - g_return_if_fail(CHUPA_IS_TEXT_INPUT(input)); + g_return_val_if_fail(CHUPA_IS_ARCHIVE_DECOMPOSER(dec), FALSE); + g_return_val_if_fail(CHUPA_IS_TEXT_INPUT(input), FALSE); arch_class = CHUPA_ARCHIVE_DECOMPOSER_GET_CLASS(dec); inp = chupa_text_input_get_base_input(input); infile = arch_class->get_infile(inp, err); if (!infile) { - return; + return FALSE; } num = gsf_infile_num_children(infile); for (i = 0; i < num; ++i) { Modified: chupatext/chupa_text_input_stream.c (+1 -0) =================================================================== --- chupatext/chupa_text_input_stream.c 2010-09-27 02:34:29 +0000 (50829a2) +++ chupatext/chupa_text_input_stream.c 2010-09-27 02:37:43 +0000 (742b029) @@ -136,6 +136,7 @@ close_fn(GInputStream *stream, GCancellable *cancellable, GError **error) g_object_unref(priv->input); priv->input = NULL; } + return TRUE; } static void Modified: module/powerpoint.c (+1 -0) =================================================================== --- module/powerpoint.c 2010-09-27 02:34:29 +0000 (07fb3d3) +++ module/powerpoint.c 2010-09-27 02:37:43 +0000 (6f10dd0) @@ -288,6 +288,7 @@ dump_file(struct PPT *ppt, GsfInput *inp) if (ppt->past_first_slide) { put_byte(ppt, '\f'); } + return TRUE; } static gboolean Modified: module/word.c (+3 -1) =================================================================== --- module/word.c 2010-09-27 02:34:29 +0000 (e98114a) +++ module/word.c 2010-09-27 02:37:43 +0000 (e567cb2) @@ -148,7 +148,7 @@ chupa_word_decomposer_feed(ChupaDecomposer *dec, ChupaText *chupar, g_propagate_error(err, chupa_text_error_new(CHUPA_TEXT_ERROR_INVALID_INPUT, "wvInitParser_gsf failed: %d", ret)); - return; + return FALSE; } ps.userData = &arg; wvSetCharHandler(&ps, char_proc); @@ -169,6 +169,8 @@ chupa_word_decomposer_feed(ChupaDecomposer *dec, ChupaText *chupar, } g_object_unref(arg.dest); g_object_unref(arg.input); + + return TRUE; } static void From null+ranguba at clear-code.com Sun Sep 26 22:44:45 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Mon, 27 Sep 2010 02:44:45 +0000 Subject: [groonga-commit:1343] ranguba/chupatext [master] * module/excel.c (CHUPA_MODULE_IMPL_INIT): warn if plugin activation failed. Message-ID: <20100927024517.A3E0A170F81@taiyaki.ru> Nobuyoshi Nakada 2010-09-27 02:44:45 +0000 (Mon, 27 Sep 2010) New Revision: f46314b4d0e828c40064ab38289d1416cec3d2ef Log: * module/excel.c (CHUPA_MODULE_IMPL_INIT): warn if plugin activation failed. Modified files: module/excel.c Modified: module/excel.c (+4 -2) =================================================================== --- module/excel.c 2010-09-27 02:43:08 +0000 (1d9ea20) +++ module/excel.c 2010-09-27 02:44:45 +0000 (f462dc6) @@ -157,8 +157,10 @@ CHUPA_MODULE_IMPL_INIT(GTypeModule *type_module) gnm_plugins_init(GO_CMD_CONTEXT(cc)); go_plugin_db_activate_plugin_list(go_plugins_get_available_plugins(), &plugin_errs); if (plugin_errs) { - fprintf(stderr, "go_plugin_db_activate_plugin_list failed\n"); - go_error_display(plugin_errs); + if (go_error_info_peek_severity(plugin_errs) >= GO_ERROR) { + g_warning("go_plugin_db_activate_plugin_list failed: %s", + go_error_info_peek_message(plugin_errs)); + } go_error_info_free(plugin_errs); } From null+ranguba at clear-code.com Sun Sep 26 22:40:47 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Mon, 27 Sep 2010 02:40:47 +0000 Subject: [groonga-commit:1344] ranguba/chupatext [master] * chupatext/chupa_gsf_input_stream.h: add prototypes. * chupatext/external_decomposer.h: ditto. Message-ID: <20100927024517.76505170F7F@taiyaki.ru> Nobuyoshi Nakada 2010-09-27 02:40:47 +0000 (Mon, 27 Sep 2010) New Revision: 3931ec88dc57561838d0c6bf7d2ea83454587e2f Log: * chupatext/chupa_gsf_input_stream.h: add prototypes. * chupatext/external_decomposer.h: ditto. Modified files: chupatext/chupa_gsf_input_stream.h chupatext/external_decomposer.h module/excel.c test/test_decomposer.c test/test_excel.c test/test_external_decomposer.c test/test_metadata.c test/test_powerpoint.c test/test_restrict_input_stream.c test/test_tar.c test/test_text.c test/test_text_input_stream.c test/test_word.c test/test_zip.c tool/version-update.sh Modified: chupatext/chupa_gsf_input_stream.h (+1 -0) =================================================================== --- chupatext/chupa_gsf_input_stream.h 2010-09-27 02:37:43 +0000 (2cb8c16) +++ chupatext/chupa_gsf_input_stream.h 2010-09-27 02:40:47 +0000 (6b9d69e) @@ -24,6 +24,7 @@ G_BEGIN_DECLS typedef struct _ChupaGsfInputStream ChupaGsfInputStream; typedef struct _ChupaGsfInputStreamClass ChupaGsfInputStreamClass; +GType chupa_gsf_input_stream_get_type(void); GInputStream *chupa_gsf_input_stream_new(GsfOutputMemory *); G_END_DECLS Modified: chupatext/external_decomposer.h (+3 -0) =================================================================== --- chupatext/external_decomposer.h 2010-09-27 02:37:43 +0000 (60af19f) +++ chupatext/external_decomposer.h 2010-09-27 02:40:47 +0000 (8e4289d) @@ -48,6 +48,9 @@ struct _ChupaExternalDecomposerClass GType chupa_external_decomposer_get_type(void) G_GNUC_CONST; GsfInfile *chupa_external_decomoser_get_infile(ChupaExternalDecomposer *); +gboolean chupa_external_decomposer_spawn(ChupaExternalDecomposer *, gchar **, GOutputStream **, + GInputStream **, GError **); +void chupa_external_decomposer_set_metadata(ChupaExternalDecomposer *, ChupaTextInput *); G_END_DECLS Modified: module/excel.c (+13 -1) =================================================================== --- module/excel.c 2010-09-27 02:37:43 +0000 (f0d4b1b) +++ module/excel.c 2010-09-27 02:40:47 +0000 (8378d67) @@ -143,12 +143,24 @@ register_type(GTypeModule *type_module) &info, 0); } +/* copied from libgnumeric.h */ +char const **gnm_pre_parse_init (int argc, gchar const **argv); +void gnm_pre_parse_shutdown (void); +void gnm_init (void); +void gnm_shutdown (void); +/* copied from gnumeric-gconf.h */ +void gnm_conf_init (void); +void gnm_conf_shutdown (void); +GOConfNode *gnm_conf_get_root (void); +/* copied from gnm-plugin.h */ +void gnm_plugins_init (GOCmdContext *c); + G_MODULE_EXPORT GList * CHUPA_MODULE_IMPL_INIT(GTypeModule *type_module) { GList *registered_types = NULL; GOErrorInfo *plugin_errs; - char *argv[2]; + const gchar *argv[2]; argv[0] = NULL; gnm_pre_parse_init(0, argv); Modified: test/test_decomposer.c (+5 -0) =================================================================== --- test/test_decomposer.c 2010-09-27 02:37:43 +0000 (2753f75) +++ test/test_decomposer.c 2010-09-27 02:40:47 +0000 (ed8a26b) @@ -8,6 +8,9 @@ #include +void test_search(void); +void test_register(void); + static ChupaDecomposer *decomp; static ChupaDispatcher *dispatcher; static GInputStream *source; @@ -63,6 +66,8 @@ struct _ChupaTestDummyDecomposerClass ChupaDecomposerClass parent_class; }; +static GType chupa_test_dummy_decomposer_get_type(void); + G_DEFINE_TYPE(ChupaTestDummyDecomposer, chupa_test_dummy_decomposer, CHUPA_TYPE_DECOMPOSER) static void Modified: test/test_excel.c (+3 -0) =================================================================== --- test/test_excel.c 2010-09-27 02:37:43 +0000 (33c4c9c) +++ test/test_excel.c 2010-09-27 02:40:47 +0000 (7967382) @@ -5,6 +5,9 @@ #include "chupa_test_util.h" +void test_decompose_excel(void); +void test_decompose_excel_2007(void); + void setup(void) { Modified: test/test_external_decomposer.c (+3 -0) =================================================================== --- test/test_external_decomposer.c 2010-09-27 02:37:43 +0000 (ffa795c) +++ test/test_external_decomposer.c 2010-09-27 02:40:47 +0000 (f1d3c52) @@ -7,6 +7,8 @@ #include "chupa_test_util.h" #include +void test_decompose_external(void); + #define CHUPA_TEST_TYPE_EXTERNAL_DECOMPOSER chupa_test_external_decomposer_get_type() #define CHUPA_TEST_EXTERNAL_DECOMPOSER(obj) \ G_TYPE_CHECK_INSTANCE_CAST(obj, CHUPA_TEST_TYPE_EXTERNAL_DECOMPOSER, ChupaTestExternalDecomposer) @@ -33,6 +35,7 @@ struct _ChupaTestExternalDecomposerClass ChupaExternalDecomposerClass parent_class; }; +static GType chupa_test_external_decomposer_get_type(void); G_DEFINE_TYPE(ChupaTestExternalDecomposer, chupa_test_external_decomposer, CHUPA_TYPE_EXTERNAL_DECOMPOSER) #define A_LINE "abcdefghijklmnopqrstuvwxyz-0123456789" Modified: test/test_metadata.c (+2 -0) =================================================================== --- test/test_metadata.c 2010-09-27 02:37:43 +0000 (d5d1e30) +++ test/test_metadata.c 2010-09-27 02:40:47 +0000 (638ec2b) @@ -24,6 +24,8 @@ void test_new (void); void test_get_first_value (void); void test_get_values (void); +void test_replace_value (void); +void test_update_value (void); static ChupaMetadata *metadata, *metadata2; Modified: test/test_powerpoint.c (+3 -0) =================================================================== --- test/test_powerpoint.c 2010-09-27 02:37:43 +0000 (bc3b69b) +++ test/test_powerpoint.c 2010-09-27 02:40:47 +0000 (7672acc) @@ -5,6 +5,9 @@ #include "chupa_test_util.h" +void test_decompose_ppt(void); +void test_decompose_ppt_ja(void); + void setup(void) { Modified: test/test_restrict_input_stream.c (+1 -0) =================================================================== --- test/test_restrict_input_stream.c 2010-09-27 02:37:43 +0000 (5b4e231) +++ test/test_restrict_input_stream.c 2010-09-27 02:40:47 +0000 (c4be64d) @@ -9,6 +9,7 @@ void test_read (void); void test_skip_to_end (void); +void test_read_line (void); static GInputStream *stream; Modified: test/test_tar.c (+2 -0) =================================================================== --- test/test_tar.c 2010-09-27 02:37:43 +0000 (33062e9) +++ test/test_tar.c 2010-09-27 02:40:47 +0000 (be1b65e) @@ -5,6 +5,8 @@ #include "chupa_test_util.h" +void test_decompose_tar(void); + void setup(void) { Modified: test/test_text.c (+2 -0) =================================================================== --- test/test_text.c 2010-09-27 02:37:43 +0000 (f56d571) +++ test/test_text.c 2010-09-27 02:40:47 +0000 (b3874e7) @@ -9,6 +9,8 @@ #include +void test_decompose_text_plain (void); + void setup(void) { Modified: test/test_text_input_stream.c (+1 -0) =================================================================== --- test/test_text_input_stream.c 2010-09-27 02:37:43 +0000 (7c95927) +++ test/test_text_input_stream.c 2010-09-27 02:40:47 +0000 (4caa451) @@ -9,6 +9,7 @@ void test_new (void); void test_new_with_metadata (void); +void test_read(void); static GInputStream *memstream; static ChupaTextInput *input; Modified: test/test_word.c (+5 -0) =================================================================== --- test/test_word.c 2010-09-27 02:37:43 +0000 (46b46f3) +++ test/test_word.c 2010-09-27 02:40:47 +0000 (d3911d0) @@ -5,6 +5,11 @@ #include "chupa_test_util.h" +void test_decompose_msword(void); +void test_decompose_msword_ja(void); +void test_decompose_msword_ja97(void); +void test_decompose_msword_ja95(void); + void setup(void) { Modified: test/test_zip.c (+2 -0) =================================================================== --- test/test_zip.c 2010-09-27 02:37:43 +0000 (13bee36) +++ test/test_zip.c 2010-09-27 02:40:47 +0000 (741a6de) @@ -5,6 +5,8 @@ #include "chupa_test_util.h" +void test_decompose_zip(void); + void setup(void) { Modified: tool/version-update.sh (+15 -2) =================================================================== --- tool/version-update.sh 2010-09-27 02:37:43 +0000 (e6d98fa) +++ tool/version-update.sh 2010-09-27 02:40:47 +0000 (f79e4e8) @@ -15,14 +15,27 @@ if test -d .git; then IFS="$save_IFS" version=`expr $major \* 1000000 + $minor \* 1000 + $micro` date=`git log --max-count=1 --format=%cd --date=short | tr -d -` - new="\ + new="#ifndef CHUPATEXT_VERSION_H #define CHUPA_VERSION_STRING \"$versionstr\" #define CHUPA_VERSION_CODE $version #define CHUPA_VERSION_MAJOR $major #define CHUPA_VERSION_MINOR $minor #define CHUPA_VERSION_MICRO $micro #define CHUPA_COMMITS ${commits:-0} -#define CHUPA_RELEASE_DATE $date" +#define CHUPA_RELEASE_DATE $date + +#ifdef __cplusplus +extern \"C\" { +#endif +const int chupa_version(void); +const char *chupa_version_string(void); +const int chupa_commits(void); +const int chupa_release_date(void); +const char *chupa_version_description(void); +#ifdef __cplusplus +} +#endif +#endif" fi fi unset old From null+ranguba at clear-code.com Mon Sep 27 00:08:38 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Mon, 27 Sep 2010 04:08:38 +0000 Subject: [groonga-commit:1345] ranguba/chupatext [master] * test/test_pdf.c, test/test_word.c: encoded in UTF-8. Message-ID: <20100927041017.3FB79170DBE@taiyaki.ru> Nobuyoshi Nakada 2010-09-27 04:08:38 +0000 (Mon, 27 Sep 2010) New Revision: e7064547f829ab46dde723a55e1989f4ae5d4313 Log: * test/test_pdf.c, test/test_word.c: encoded in UTF-8. Modified files: test/test_pdf.c test/test_word.c Modified: test/test_pdf.c (+2 -2) =================================================================== --- test/test_pdf.c 2010-09-27 02:44:45 +0000 (bd68e25) +++ test/test_pdf.c 2010-09-27 04:08:38 +0000 (52be284) @@ -1,4 +1,4 @@ -/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4; encoding: utf-8 -*- */ /* * Copyright (C) 2010 Nobuyoshi Nakada */ @@ -25,7 +25,7 @@ teardown(void) void test_decompose_pdf(void) { - cut_assert_equal_string("sample", decompose_pdf("sample.pdf", NULL)); + cut_assert_equal_string("sample\n", decompose_pdf("sample.pdf", NULL)); } void Modified: test/test_word.c (+1 -1) =================================================================== --- test/test_word.c 2010-09-27 02:44:45 +0000 (d3911d0) +++ test/test_word.c 2010-09-27 04:08:38 +0000 (4794944) @@ -1,4 +1,4 @@ -/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4; encoding: utf-8 -*- */ /* * Copyright (C) 2010 Nobuyoshi Nakada */ From null+ranguba at clear-code.com Mon Sep 27 00:09:55 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Mon, 27 Sep 2010 04:09:55 +0000 Subject: [groonga-commit:1346] ranguba/chupatext [master] * test/fixtures/sample_multi_pages.pdf: multi pages. Message-ID: <20100927041017.53F8E170EE5@taiyaki.ru> Nobuyoshi Nakada 2010-09-27 04:09:55 +0000 (Mon, 27 Sep 2010) New Revision: 67384297461f0dda5cb2a31884e0e5666a23d4f1 Log: * test/fixtures/sample_multi_pages.pdf: multi pages. Modified files: test/fixtures/sample_multi_pages.pdf Modified: test/fixtures/sample_multi_pages.pdf (+0 -0) =================================================================== (Binary files differ) From null+ranguba at clear-code.com Mon Sep 27 02:43:00 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Mon, 27 Sep 2010 06:43:00 +0000 Subject: [groonga-commit:1347] ranguba/chupatext [master] * module/powerpoint_factory.c (create): fix module name. Message-ID: <20100927064318.26AAC170EE5@taiyaki.ru> Nobuyoshi Nakada 2010-09-27 06:43:00 +0000 (Mon, 27 Sep 2010) New Revision: 7d26edebc766ccb99ce6c06193b574356b9cf8b3 Log: * module/powerpoint_factory.c (create): fix module name. Modified files: module/powerpoint_factory.c Modified: module/powerpoint_factory.c (+1 -1) =================================================================== --- module/powerpoint_factory.c 2010-09-27 06:42:30 +0000 (d0e785b) +++ module/powerpoint_factory.c 2010-09-27 06:43:00 +0000 (a300e3b) @@ -142,7 +142,7 @@ create (ChupaModuleFactory *factory) static int n_instances = 0; GObject *decomposer; - decomposer = G_OBJECT(chupa_decomposer_new("ppt", NULL)); + decomposer = G_OBJECT(chupa_decomposer_new("powerpoint", NULL)); n_instances++; if (n_instances == 1) { /* FIXME: This causes memory leak but we need to From null+ranguba at clear-code.com Mon Sep 27 02:42:30 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Mon, 27 Sep 2010 06:42:30 +0000 Subject: [groonga-commit:1348] ranguba/chupatext [master] * chupatext/chupa_gsf_input_stream.c (chupa_gsf_input_stream_new): add data only if data is not empty. Message-ID: <20100927064318.1C0AC170DBE@taiyaki.ru> Nobuyoshi Nakada 2010-09-27 06:42:30 +0000 (Mon, 27 Sep 2010) New Revision: c2eaeec9348ab29aea9f40d7d5b8fcb4a6ab2b7b Log: * chupatext/chupa_gsf_input_stream.c (chupa_gsf_input_stream_new): add data only if data is not empty. Modified files: chupatext/chupa_gsf_input_stream.c Modified: chupatext/chupa_gsf_input_stream.c (+7 -3) =================================================================== --- chupatext/chupa_gsf_input_stream.c 2010-09-27 04:09:55 +0000 (26e3872) +++ chupatext/chupa_gsf_input_stream.c 2010-09-27 06:42:30 +0000 (650b9f3) @@ -49,11 +49,15 @@ chupa_gsf_input_stream_new(GsfOutputMemory *mem) { ChupaGsfInputStream *stream = g_object_new(CHUPA_TYPE_GSF_INPUT_STREAM, NULL); GsfOutput *out = GSF_OUTPUT(mem); + gsize size; g_object_ref(mem); stream->source = mem; - g_memory_input_stream_add_data(G_MEMORY_INPUT_STREAM(stream), - gsf_output_memory_get_bytes(mem), - gsf_output_size(out), NULL); + size = gsf_output_size(out); + if (size > 0) { + g_memory_input_stream_add_data(G_MEMORY_INPUT_STREAM(stream), + gsf_output_memory_get_bytes(mem), + size, NULL); + } return G_INPUT_STREAM(stream); } From null+ranguba at clear-code.com Mon Sep 27 03:04:15 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Mon, 27 Sep 2010 07:04:15 +0000 Subject: [groonga-commit:1349] ranguba/chupatext [master] * module/powerpoint.c (register_type): dump once and check the result. Message-ID: <20100927071204.D3D16170F7E@taiyaki.ru> Nobuyoshi Nakada 2010-09-27 07:04:15 +0000 (Mon, 27 Sep 2010) New Revision: f5d0e2d743126891163bda21dd9b20a87f0d9b37 Log: * module/powerpoint.c (register_type): dump once and check the result. Modified files: module/powerpoint.c Modified: module/powerpoint.c (+2 -1) =================================================================== --- module/powerpoint.c 2010-09-27 07:02:20 +0000 (eb4ac37) +++ module/powerpoint.c 2010-09-27 07:04:15 +0000 (5f0c901) @@ -308,7 +308,8 @@ chupa_feed_ppt(ChupaText *chupar, ChupaTextInput *input, GError **error) memset(&ppt, 0, sizeof(ppt)); gsf_input_seek(gin, 0, G_SEEK_SET); ppt.output = mem; - while (dump_file(&ppt, gin)) { + if (!dump_file(&ppt, gin)) { + return FALSE; } return TRUE; } From null+ranguba at clear-code.com Mon Sep 27 02:46:53 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Mon, 27 Sep 2010 06:46:53 +0000 Subject: [groonga-commit:1350] ranguba/chupatext [master] * module/powerpoint.c (print_utf8, atom_processor): convert Unicode char CR to LF. Message-ID: <20100927071204.BBC7A170DBE@taiyaki.ru> Nobuyoshi Nakada 2010-09-27 06:46:53 +0000 (Mon, 27 Sep 2010) New Revision: 267eacb479ffac48593300e7260afe24a3e39aa4 Log: * module/powerpoint.c (print_utf8, atom_processor): convert Unicode char CR to LF. Modified files: module/powerpoint.c Modified: module/powerpoint.c (+4 -4) =================================================================== --- module/powerpoint.c 2010-09-27 06:43:00 +0000 (9917adb) +++ module/powerpoint.c 2010-09-27 06:46:53 +0000 (fedc342) @@ -125,7 +125,10 @@ print_utf8(struct PPT *ppt, unsigned short c) { if (c == 0) return; - + + if (c == '\r') { + c = '\n'; + } if (c < 0x80) put_byte(ppt, c); else if (c < 0x800) { @@ -213,9 +216,6 @@ atom_processor(struct PPT *ppt, int type, int count, int buf_last, unsigned char } break; case 0x0FBA: /* CString - unicode... */ - if (data == '\r') { - data = '\n'; - } ppt->working_buffer[ppt->buf_idx++] = data; if (count == buf_last) { /* working_buffer[buf_idx++] = 0; */ From null+ranguba at clear-code.com Mon Sep 27 03:06:06 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Mon, 27 Sep 2010 07:06:06 +0000 Subject: [groonga-commit:1351] ranguba/chupatext [master] * module/powerpoint.c (dump_file): no formfeed at the end. Message-ID: <20100927071204.DFD67170F7F@taiyaki.ru> Nobuyoshi Nakada 2010-09-27 07:06:06 +0000 (Mon, 27 Sep 2010) New Revision: 6c7f2c6de1ef56d67618a62c3d11851b087de89e Log: * module/powerpoint.c (dump_file): no formfeed at the end. Modified files: module/powerpoint.c Modified: module/powerpoint.c (+0 -3) =================================================================== --- module/powerpoint.c 2010-09-27 07:04:15 +0000 (5f0c901) +++ module/powerpoint.c 2010-09-27 07:06:06 +0000 (6b63289) @@ -283,9 +283,6 @@ dump_file(struct PPT *ppt, GsfInput *inp) count++; } - if (ppt->past_first_slide) { - put_byte(ppt, '\f'); - } return TRUE; } From null+ranguba at clear-code.com Mon Sep 27 03:02:20 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Mon, 27 Sep 2010 07:02:20 +0000 Subject: [groonga-commit:1352] ranguba/chupatext [master] * module/powerpoint.c (atom_processor): flush buffer if full. Message-ID: <20100927071204.C7F53170EE5@taiyaki.ru> Nobuyoshi Nakada 2010-09-27 07:02:20 +0000 (Mon, 27 Sep 2010) New Revision: abb3b294040eeec6fd6dd8003524d96a2bd65eb7 Log: * module/powerpoint.c (atom_processor): flush buffer if full. Modified files: module/powerpoint.c Modified: module/powerpoint.c (+18 -21) =================================================================== --- module/powerpoint.c 2010-09-27 06:46:53 +0000 (fedc342) +++ module/powerpoint.c 2010-09-27 07:02:20 +0000 (eb4ac37) @@ -184,43 +184,40 @@ container_processor(struct PPT *ppt, int type) static void atom_processor(struct PPT *ppt, int type, int count, int buf_last, unsigned char data) { - if ((ppt->buf_idx >= WORK_SIZE) || (ppt->output_this_container == 0)) + if (ppt->output_this_container == 0) return; - if (count == 0) { - memset(ppt->working_buffer, 0, WORK_SIZE); - ppt->buf_idx = 0; - } - switch (type) { - case 0x0FA0: /* Text String in unicode */ - ppt->working_buffer[ppt->buf_idx++] = data; - if (count == buf_last) { - /* printf("Atom:%x|\n", type); */ - /* working_buffer[buf_idx++] = 0; */ - /* printf("%s
\n", working_buffer); */ - print_unicode(ppt, ppt->working_buffer, ppt->buf_idx); - put_byte(ppt, '\n'); - } - break; case 0x0FA8: /* Text String in ASCII */ + if (count == 0) { + ppt->buf_idx = 0; + } + else if (ppt->buf_idx >= WORK_SIZE) { + gsf_output_write(ppt->output, ppt->buf_idx, ppt->working_buffer); + ppt->buf_idx = 0; + } if (data == '\r') { data = '\n'; } ppt->working_buffer[ppt->buf_idx++] = data; if (count == buf_last) { - /* ppt->working_buffer[ppt->buf_idx++] = 0; */ - /* printf("Atom:%x|\n", type); */ + /* printf("Atom:%x|%.*s\n", type, ppt->buf_idx, ppt->working_buffer); */ gsf_output_write(ppt->output, ppt->buf_idx, ppt->working_buffer); put_byte(ppt, '\n'); } break; + case 0x0FA0: /* Text String in unicode */ case 0x0FBA: /* CString - unicode... */ + if (count == 0) { + ppt->buf_idx = 0; + } + else if (ppt->buf_idx >= WORK_SIZE) { + print_unicode(ppt, ppt->working_buffer, ppt->buf_idx); + ppt->buf_idx = 0; + } ppt->working_buffer[ppt->buf_idx++] = data; if (count == buf_last) { - /* working_buffer[buf_idx++] = 0; */ - /* printf("%s
\n", working_buffer); */ - /* printf("Atom:%x|\n", type); */ + /* printf("Atom:%x|%.*s\n", type, ppt->buf_idx, ppt->working_buffer); */ print_unicode(ppt, ppt->working_buffer, ppt->buf_idx); put_byte(ppt, '\n'); } From null+ranguba at clear-code.com Mon Sep 27 04:36:14 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Mon, 27 Sep 2010 08:36:14 +0000 Subject: [groonga-commit:1353] ranguba/chupatext [master] * module/powerpoint.c: removed code borrowed from catdoc. Message-ID: <20100927105125.7D48F170DBE@taiyaki.ru> Nobuyoshi Nakada 2010-09-27 08:36:14 +0000 (Mon, 27 Sep 2010) New Revision: 83c4785fe286d5885e0476fa6206e68cfc0df997 Log: * module/powerpoint.c: removed code borrowed from catdoc. Modified files: module/powerpoint.c Modified: module/powerpoint.c (+0 -44) =================================================================== --- module/powerpoint.c 2010-09-27 07:06:06 +0000 (6b63289) +++ module/powerpoint.c 2010-09-27 08:36:14 +0000 (121153b) @@ -38,50 +38,6 @@ struct _ChupaPPTDecomposerClass static GType chupa_type_ppt_decomposer = 0; -/* borrowed from catdoc-0.94.2 */ -typedef enum { - PPT_ITEM_DOCUMENT = 1000, - PPT_ITEM_DOCUMENT_ATOM = 1001, - PPT_ITEM_DOCUMENT_END = 1002, - PPT_ITEM_SLIDE_PERSIST = 1003, - PPT_ITEM_SLIDE_BASE = 1004, - PPT_ITEM_SLIDE_BASE_ATOM = 1005, - PPT_ITEM_SLIDE = 1006, - PPT_ITEM_SLIDE_ATOM = 1007, - PPT_ITEM_NOTES = 1008 , - PPT_ITEM_NOTES_ATOM = 1009, - PPT_ITEM_ENVIRONMENT = 1010, - PPT_ITEM_SLIDE_PERSIST_ATOM = 1011, - PPT_ITEM_MAIN_MASTER = 1016, - PPT_ITEM_SSSLIDE_INFO_ATOM = 1017, - PPT_ITEM_SSDOC_INFO_ATOM = 1025, - PPT_ITEM_EX_OBJ_LIST = 1033, - PPT_ITEM_PPDRAWING_GROUP = 1035, - PPT_ITEM_PPDRAWING = 1036, - PPT_ITEM_LIST = 2000, - PPT_ITEM_COLOR_SCHEME_ATOM = 2032, - PPT_ITEM_TEXT_HEADER_ATOM = 3999, - PPT_ITEM_TEXT_CHARS_ATOM = 4000, - PPT_ITEM_STYLE_TEXT_PROP_ATOM = 4001, - PPT_ITEM_TX_MASTER_STYLE_ATOM = 4003, - PPT_ITEM_TEXT_BYTES_ATOM = 4008, - PPT_ITEM_TEXT_CISTYLE_ATOM = 4008, - PPT_ITEM_TEXT_SPEC_INFO = 4010, - PPT_ITEM_EX_OLE_OBJ_STG = 4113, - PPT_ITEM_CSTRING = 4026, - PPT_ITEM_HANDOUT = 4041, - PPT_ITEM_HEADERS_FOOTERS = 4057, - PPT_ITEM_HEADERS_FOOTERS_ATOM = 4058, - PPT_ITEM_SLIDE_LIST_WITH_TEXT = 4080, - PPT_ITEM_SLIDE_LIST = 4084, - PPT_ITEM_USER_EDIT_ATOM = 4085, - PPT_ITEM_PROG_TAGS = 5000, - PPT_ITEM_PROG_STRING_TAG = 5001, - PPT_ITEM_PROG_BINARY_TAG = 5002, - PPT_ITEM_PERSIST_PTR_INCREMENTAL_BLOCK = 6002, - PPT_ITEM_UNKNOWN = 0 -} ppt_item_type_t; - #if 0 static unsigned int getushort(unsigned char *buffer, int offset) From null+ranguba at clear-code.com Mon Sep 27 06:53:23 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Mon, 27 Sep 2010 10:53:23 +0000 Subject: [groonga-commit:1354] ranguba/chupatext [master] * module/powerpoint.c (chupa_feed_ppt): use external converter. Message-ID: <20100927105406.E0E81170EE5@taiyaki.ru> Nobuyoshi Nakada 2010-09-27 10:53:23 +0000 (Mon, 27 Sep 2010) New Revision: e0aeb183f57b51e8820fc6393f7642568fa6a387 Log: * module/powerpoint.c (chupa_feed_ppt): use external converter. Modified files: module/Makefile.am module/powerpoint.c Modified: module/Makefile.am (+2 -2) =================================================================== --- module/Makefile.am 2010-09-27 10:52:35 +0000 (e4c9efc) +++ module/Makefile.am 2010-09-27 10:53:23 +0000 (81e2dbe) @@ -77,8 +77,8 @@ excel_factory_la_CPPFLAGS = $(GLIB_CFLAGS) $(GSF_CFLAGS) excel_factory_la_LIBADD = $(GLIB_LIBS) powerpoint_la_SOURCES = powerpoint.c -powerpoint_la_CPPFLAGS = $(GSF_CFLAGS) -powerpoint_la_LIBADD = $(GSF_LIBS) +powerpoint_la_CPPFLAGS = $(GIO_UNIX_CFLAGS) $(GSF_CFLAGS) +powerpoint_la_LIBADD = $(GIO_UNIX_LIBS) $(GSF_LIBS) powerpoint_factory_la_SOURCES = powerpoint_factory.c powerpoint_factory_la_CPPFLAGS = $(GLIB_CFLAGS) $(GSF_CFLAGS) Modified: module/powerpoint.c (+56 -232) =================================================================== --- module/powerpoint.c 2010-09-27 10:52:35 +0000 (121153b) +++ module/powerpoint.c 2010-09-27 10:53:23 +0000 (2cc0415) @@ -3,12 +3,16 @@ * Copyright (C) 2010 Nobuyoshi Nakada */ -#include +#include #include -#include +#include #include +#include +#include +#include #include #include +#include #include #define CHUPA_TYPE_PPT_DECOMPOSER chupa_type_ppt_decomposer @@ -28,251 +32,71 @@ typedef struct _ChupaPPTDecomposerClass ChupaPPTDecomposerClass; struct _ChupaPPTDecomposer { - ChupaArchiveDecomposer parent_object; + ChupaExternalDecomposer parent_object; }; struct _ChupaPPTDecomposerClass { - ChupaArchiveDecomposerClass parent_class; + ChupaExternalDecomposerClass parent_class; }; static GType chupa_type_ppt_decomposer = 0; -#if 0 -static unsigned int -getushort(unsigned char *buffer, int offset) -{ - return (unsigned short int)buffer[offset] | ((unsigned short int)buffer[offset+1]<<8); -} - -static unsigned long int -getulong(unsigned char *buffer, int offset) -{ - return (unsigned long)buffer[offset] | ((unsigned long)buffer[offset+1]<<8) | - ((unsigned long)buffer[offset+2]<<16) | ((unsigned long)buffer[offset+3]<<24); -} -#endif - -#define WORK_SIZE 128 - -struct PPT { - unsigned char working_buffer[WORK_SIZE]; - int buf_idx; - int output_this_container; - int past_first_slide; - int last_container; - GsfOutput *output; -}; - -static void -put_byte(struct PPT *ppt, unsigned char c) -{ - gsf_output_write(ppt->output, 1, &c); -} - -static void -put_utf8(struct PPT *ppt, unsigned short c) -{ - put_byte(ppt, 0x0080 | ((short)c & 0x003F)); -} - -static void -print_utf8(struct PPT *ppt, unsigned short c) -{ - if (c == 0) - return; - - if (c == '\r') { - c = '\n'; - } - if (c < 0x80) - put_byte(ppt, c); - else if (c < 0x800) { - put_byte(ppt, 0xC0 | (c >> 6)); - put_utf8(ppt, c); - } - else - { - put_byte(ppt, 0xE0 | (c >> 12)); - put_utf8(ppt, c >> 6); - put_utf8(ppt, c); - } -} - -static void -print_unicode(struct PPT *ppt, unsigned char *ucs, int len) -{ - int i; - for (i = 0; i < len; i += 2) { - print_utf8(ppt, ucs[i] | (ucs[i+1] << 8)); - } -} - -static void -container_processor(struct PPT *ppt, int type) -{ - if (type == 0x03EE) { - if (ppt->past_first_slide) { - put_byte(ppt, '\f'); - } - else { - ppt->past_first_slide = 1; - } - } - switch (type) { - case 0x000D: - if (ppt->last_container == 0x11) /* suppress notes info */ - ppt->output_this_container = 0; - else - ppt->output_this_container = 1; - break; - case 0x0FF0: - ppt->output_this_container = 1; - break; - default: - /* printf("Cont:%x|\n", type); */ - ppt->output_this_container = 0; - break; - } - ppt->last_container = type; -} - -static void -atom_processor(struct PPT *ppt, int type, int count, int buf_last, unsigned char data) -{ - if (ppt->output_this_container == 0) - return; - - switch (type) { - case 0x0FA8: /* Text String in ASCII */ - if (count == 0) { - ppt->buf_idx = 0; - } - else if (ppt->buf_idx >= WORK_SIZE) { - gsf_output_write(ppt->output, ppt->buf_idx, ppt->working_buffer); - ppt->buf_idx = 0; - } - if (data == '\r') { - data = '\n'; - } - ppt->working_buffer[ppt->buf_idx++] = data; - if (count == buf_last) { - /* printf("Atom:%x|%.*s\n", type, ppt->buf_idx, ppt->working_buffer); */ - gsf_output_write(ppt->output, ppt->buf_idx, ppt->working_buffer); - put_byte(ppt, '\n'); - } - break; - case 0x0FA0: /* Text String in unicode */ - case 0x0FBA: /* CString - unicode... */ - if (count == 0) { - ppt->buf_idx = 0; - } - else if (ppt->buf_idx >= WORK_SIZE) { - print_unicode(ppt, ppt->working_buffer, ppt->buf_idx); - ppt->buf_idx = 0; - } - ppt->working_buffer[ppt->buf_idx++] = data; - if (count == buf_last) { - /* printf("Atom:%x|%.*s\n", type, ppt->buf_idx, ppt->working_buffer); */ - print_unicode(ppt, ppt->working_buffer, ppt->buf_idx); - put_byte(ppt, '\n'); - } - break; - default: - break; - } -} - -static gboolean -dump_file(struct PPT *ppt, GsfInput *inp) -{ - unsigned long version=0, instance=0, type=0, length=0, target=0, count=0; - unsigned char buf[16]; - - /* Output body */ - while (gsf_input_read(inp, 1, buf)) { - switch (count) { - case 0: - instance = buf[0]; - type = 0; - length = 0; - target = 80; /* ficticious number */ - break; - case 1: - instance |= (buf[0]<<8); - version = instance &0x000F; - instance = (instance>>4); - break; - case 2: - type = (unsigned)buf[0]; - break; - case 3: - type |= (buf[0]<<8)&0x00000FFFL; - break; - case 4: - length = (unsigned)buf[0]; - break; - case 5: - length |= (buf[0]<<8); - break; - case 6: - length |= (buf[0]<<16); - break; - case 7: - length |= (buf[0]<<24); - target = length; - if (version == 0x0F) { - /* Do container level Processing */ - container_processor(ppt, type); - count = -1; - } - break; - } - if (count > 7) { - /* Here is where we want to process the data - based on the Atom type... */ - atom_processor(ppt, type, count-8, target-1, buf[0]); - } - if (count == (target+7)) - count = 0; - else - count++; - } - - return TRUE; -} - +#define TMPFILE_BASE "chupa-XXXXXX" static gboolean -chupa_feed_ppt(ChupaText *chupar, ChupaTextInput *input, GError **error) +chupa_feed_ppt(ChupaDecomposer *dec, ChupaText *chupar, ChupaTextInput *input, GError **error) { const char *filename = chupa_text_input_get_filename(input); - GsfOutput *mem; - GsfInput *gin = chupa_text_input_get_base_input(input); - GInputStream *inp; - struct PPT ppt; - - if (strcmp(filename, "PowerPoint Document")) { - return TRUE; - } - mem = gsf_output_memory_new(); - inp = chupa_gsf_input_stream_new(GSF_OUTPUT_MEMORY(mem)); - input = chupa_text_input_new_from_stream(NULL, inp, filename); - chupa_text_feed(chupar, input, error); - memset(&ppt, 0, sizeof(ppt)); - gsf_input_seek(gin, 0, G_SEEK_SET); - ppt.output = mem; - if (!dump_file(&ppt, gin)) { - return FALSE; - } - return TRUE; + gchar *tmp_ppt_name, *tmp_pdf_name; + gint fd_ppt, fd_pdf; + GOutputStream *out_tmpfile; + GInputStream *in_tmpfile; + char *argv[5]; + gsize size; + gboolean result; + GsfInput *base_input; + + fd_ppt = g_file_open_tmp(TMPFILE_BASE".ppt", &tmp_ppt_name, error); + out_tmpfile = g_unix_output_stream_new(fd_ppt, TRUE); + base_input = chupa_text_input_get_base_input(input); + gsf_input_seek(base_input, 0, G_SEEK_SET); + in_tmpfile = chupa_text_input_get_stream(input); + in_tmpfile = g_filter_input_stream_get_base_stream(G_FILTER_INPUT_STREAM(in_tmpfile)); + size = g_output_stream_splice(out_tmpfile, in_tmpfile, + G_OUTPUT_STREAM_SPLICE_CLOSE_SOURCE| + G_OUTPUT_STREAM_SPLICE_CLOSE_TARGET, + NULL, error); + g_object_unref(out_tmpfile); + g_return_val_if_fail(size != -1, (g_unlink(tmp_ppt_name), g_free(tmp_ppt_name), FALSE)); + fd_pdf = g_file_open_tmp(TMPFILE_BASE".pdf", &tmp_pdf_name, error); + argv[0] = "ooffice"; + argv[1] = "-headless"; + argv[2] = tmp_ppt_name; + argv[3] = g_strdup_printf("macro:///Standard.Export.WritePDF(\"file://%s\")", tmp_pdf_name); + argv[4] = NULL; + g_return_val_if_fail(chupa_external_decomposer_spawn(CHUPA_EXTERNAL_DECOMPOSER(dec), + argv, NULL, NULL, error), + FALSE); + g_unlink(tmp_ppt_name); + g_free(tmp_ppt_name); + g_free(argv[3]); + g_unlink(tmp_pdf_name); + g_free(tmp_pdf_name); + in_tmpfile = g_unix_input_stream_new(fd_pdf, TRUE); + input = chupa_text_input_new_from_stream(NULL, in_tmpfile, filename); + g_object_unref(in_tmpfile); + chupa_metadata_replace_value(chupa_text_input_get_metadata(input), + "mime-type", "application/pdf"); + result = chupa_text_feed(chupar, input, error); + g_object_unref(input); + return result; } static void chupa_ppt_decomposer_class_init(ChupaPPTDecomposerClass *klass) { - ChupaArchiveDecomposerClass *dec_class = CHUPA_ARCHIVE_DECOMPOSER_CLASS(klass); - dec_class->get_infile = gsf_infile_msole_new; - dec_class->feed_component = chupa_feed_ppt; + ChupaDecomposerClass *dec_class = CHUPA_DECOMPOSER_CLASS(klass); + dec_class->feed = chupa_feed_ppt; } static void @@ -292,7 +116,7 @@ register_type(GTypeModule *type_module) chupa_type_ppt_decomposer = g_type_module_register_type(type_module, - CHUPA_TYPE_ARCHIVE_DECOMPOSER, + CHUPA_TYPE_EXTERNAL_DECOMPOSER, "ChupaPPTDecomposer", &info, 0); } From null+ranguba at clear-code.com Mon Sep 27 06:52:35 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Mon, 27 Sep 2010 10:52:35 +0000 Subject: [groonga-commit:1355] ranguba/chupatext [master] * module/pdf.c (chupa_pdf_decomposer_feed): ChupaTextInput may not be based on GsfInput. Message-ID: <20100927105406.D4C82170DBE@taiyaki.ru> Nobuyoshi Nakada 2010-09-27 10:52:35 +0000 (Mon, 27 Sep 2010) New Revision: 4622bd458b9d1f638c64465245463ea7b738d3e5 Log: * module/pdf.c (chupa_pdf_decomposer_feed): ChupaTextInput may not be based on GsfInput. Modified files: module/pdf.c Modified: module/pdf.c (+2 -1) =================================================================== --- module/pdf.c 2010-09-27 08:36:14 +0000 (7838d65) +++ module/pdf.c 2010-09-27 10:52:35 +0000 (be035be) @@ -48,7 +48,6 @@ chupa_pdf_decomposer_feed(ChupaDecomposer *dec, ChupaText *chupar, GInputStream *inp = chupa_text_input_get_stream(input); ChupaMetadata *meta = chupa_text_input_get_metadata(input); ChupaTextInput *pdf_text = NULL; - const char *name = gsf_input_name(chupa_text_input_get_base_input(input)); int n, i; while ((count = g_input_stream_read(inp, buffer, bufsize, NULL, err)) > 0) { @@ -80,6 +79,8 @@ chupa_pdf_decomposer_feed(ChupaDecomposer *dec, ChupaText *chupar, g_memory_input_stream_add_data(mem, text, -1, g_free); } else { + GsfInput *base_input = chupa_text_input_get_base_input(input); + const char *name = base_input ? gsf_input_name(base_input) : NULL; inp = g_memory_input_stream_new_from_data(text, -1, g_free); pdf_text = chupa_text_input_new_from_stream(meta, inp, name); chupa_text_decomposed(chupar, pdf_text); From null+ranguba at clear-code.com Mon Sep 27 06:54:00 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Mon, 27 Sep 2010 10:54:00 +0000 Subject: [groonga-commit:1356] ranguba/chupatext [master] * chupatext/chupa_gsf_input_stream.c (gsf_input_stream_read): implemented. Message-ID: <20100927105406.EA819170F7E@taiyaki.ru> Nobuyoshi Nakada 2010-09-27 10:54:00 +0000 (Mon, 27 Sep 2010) New Revision: bf4aea06211e32c05284cc0252e51e30f4b64b00 Log: * chupatext/chupa_gsf_input_stream.c (gsf_input_stream_read): implemented. Modified files: chupatext/chupa_gsf_input_stream.c Modified: chupatext/chupa_gsf_input_stream.c (+36 -2) =================================================================== --- chupatext/chupa_gsf_input_stream.c 2010-09-27 10:53:23 +0000 (650b9f3) +++ chupatext/chupa_gsf_input_stream.c 2010-09-27 10:54:00 +0000 (9757c84) @@ -4,16 +4,20 @@ */ #include "chupatext/chupa_gsf_input_stream.h" +#include + +typedef struct _ChupaGsfInputStreamPrivate ChupaGsfInputStreamPrivate; struct _ChupaGsfInputStream { - GMemoryInputStream parent_object; + GInputStream parent_object; GsfOutputMemory *source; + gsize cur_offset; }; struct _ChupaGsfInputStreamClass { - GMemoryInputStreamClass parent_class; + GInputStreamClass parent_class; }; G_DEFINE_TYPE(ChupaGsfInputStream, chupa_gsf_input_stream, G_TYPE_MEMORY_INPUT_STREAM) @@ -31,6 +35,32 @@ gsf_input_dispose(GObject *object) G_OBJECT_CLASS(chupa_gsf_input_stream_parent_class)->dispose(object); } +static gssize +gsf_input_stream_read(GInputStream *input_stream, + void *buffer, + gsize count, + GCancellable *cancellable, + GError **error) +{ + ChupaGsfInputStream *stream = CHUPA_GSF_INPUT_STREAM(input_stream); + gsize cur_size; + + g_return_val_if_fail(stream->source, -1); + g_return_val_if_fail(count >= 0, -1); + cur_size = gsf_output_size(GSF_OUTPUT(stream->source)); + if (count > cur_size) { + return -1; + } + if (count + stream->cur_offset > cur_size) { + count = cur_size - stream->cur_offset; + } + if (count > 0) { + const guint8 *mem_buffer = gsf_output_memory_get_bytes(stream->source); + memcpy(buffer, mem_buffer + stream->cur_offset, count); + } + return count; +} + static void chupa_gsf_input_stream_init(ChupaGsfInputStream *stream) { @@ -42,6 +72,10 @@ chupa_gsf_input_stream_class_init(ChupaGsfInputStreamClass *klass) { GObjectClass *gobject_class = G_OBJECT_CLASS(klass); gobject_class->dispose = gsf_input_dispose; + { + GInputStreamClass *input_stream_class = G_INPUT_STREAM_CLASS(klass); + input_stream_class->read_fn = gsf_input_stream_read; + } } GInputStream * From null+ranguba at clear-code.com Mon Sep 27 07:24:23 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Mon, 27 Sep 2010 11:24:23 +0000 Subject: [groonga-commit:1357] ranguba/chupatext [master] * module/powerpoint.c (chupa_feed_ppt): wait for OpenOffice to exit. Message-ID: <20100927112431.642D9170EE5@taiyaki.ru> Nobuyoshi Nakada 2010-09-27 11:24:23 +0000 (Mon, 27 Sep 2010) New Revision: 9386cd8146c943f9e88afaa02d87e8263adab864 Log: * module/powerpoint.c (chupa_feed_ppt): wait for OpenOffice to exit. Modified files: module/powerpoint.c Modified: module/powerpoint.c (+2 -0) =================================================================== --- module/powerpoint.c 2010-09-27 11:15:45 +0000 (2938e8a) +++ module/powerpoint.c 2010-09-27 11:24:23 +0000 (3da4197) @@ -14,6 +14,7 @@ #include #include #include +#include #define CHUPA_TYPE_PPT_DECOMPOSER chupa_type_ppt_decomposer #define CHUPA_PPT_DECOMPOSER(obj) \ @@ -83,6 +84,7 @@ chupa_feed_ppt(ChupaDecomposer *dec, ChupaText *chupar, ChupaTextInput *input, G g_return_val_if_fail(chupa_external_decomposer_spawn(CHUPA_EXTERNAL_DECOMPOSER(dec), argv, NULL, NULL, error), FALSE); + sleep(2); /* Suck! */ g_unlink(tmp_ppt_name); g_free(tmp_ppt_name); g_free(argv[3]); From null+ranguba at clear-code.com Mon Sep 27 07:15:45 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Mon, 27 Sep 2010 11:15:45 +0000 Subject: [groonga-commit:1358] ranguba/chupatext [master] * module/powerpoint.c (chupa_feed_ppt): prevent from overflow. Message-ID: <20100927112431.5B44D170DBE@taiyaki.ru> Nobuyoshi Nakada 2010-09-27 11:15:45 +0000 (Mon, 27 Sep 2010) New Revision: d08c869f7acd54605d0d2a02910475e8ea635b1d Log: * module/powerpoint.c (chupa_feed_ppt): prevent from overflow. Modified files: module/powerpoint.c Modified: module/powerpoint.c (+11 -5) =================================================================== --- module/powerpoint.c 2010-09-27 10:54:00 +0000 (2cc0415) +++ module/powerpoint.c 2010-09-27 11:15:45 +0000 (2938e8a) @@ -51,6 +51,7 @@ chupa_feed_ppt(ChupaDecomposer *dec, ChupaText *chupar, ChupaTextInput *input, G gint fd_ppt, fd_pdf; GOutputStream *out_tmpfile; GInputStream *in_tmpfile; + int argc; char *argv[5]; gsize size; gboolean result; @@ -69,11 +70,16 @@ chupa_feed_ppt(ChupaDecomposer *dec, ChupaText *chupar, ChupaTextInput *input, G g_object_unref(out_tmpfile); g_return_val_if_fail(size != -1, (g_unlink(tmp_ppt_name), g_free(tmp_ppt_name), FALSE)); fd_pdf = g_file_open_tmp(TMPFILE_BASE".pdf", &tmp_pdf_name, error); - argv[0] = "ooffice"; - argv[1] = "-headless"; - argv[2] = tmp_ppt_name; - argv[3] = g_strdup_printf("macro:///Standard.Export.WritePDF(\"file://%s\")", tmp_pdf_name); - argv[4] = NULL; + argc = 0; + argv[argc++] = "ooffice"; + argv[argc++] = "-headless"; + argv[argc++] = tmp_ppt_name; + argv[argc++] = g_strdup_printf("macro:///Standard.Export.WritePDF(\"file://%s\")", tmp_pdf_name); + argv[argc++] = NULL; + if (argc > (int)(sizeof(argv)/sizeof(argv[0]))) { + g_error("argv overflow"); + return FALSE; + } g_return_val_if_fail(chupa_external_decomposer_spawn(CHUPA_EXTERNAL_DECOMPOSER(dec), argv, NULL, NULL, error), FALSE); From null+ranguba at clear-code.com Mon Sep 27 07:34:54 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Mon, 27 Sep 2010 11:34:54 +0000 Subject: [groonga-commit:1359] ranguba/chupatext [master] * module/powerpoint.c (chupa_feed_ppt): run synchronously. Message-ID: <20100927113508.38EA5170DBE@taiyaki.ru> Nobuyoshi Nakada 2010-09-27 11:34:54 +0000 (Mon, 27 Sep 2010) New Revision: c9f2c6c00eee5930305171483aa6d5f8a3125bca Log: * module/powerpoint.c (chupa_feed_ppt): run synchronously. Modified files: module/powerpoint.c Modified: module/powerpoint.c (+7 -3) =================================================================== --- module/powerpoint.c 2010-09-27 11:24:23 +0000 (3da4197) +++ module/powerpoint.c 2010-09-27 11:34:54 +0000 (7c8141c) @@ -57,6 +57,7 @@ chupa_feed_ppt(ChupaDecomposer *dec, ChupaText *chupar, ChupaTextInput *input, G gsize size; gboolean result; GsfInput *base_input; + gint ooo_status; fd_ppt = g_file_open_tmp(TMPFILE_BASE".ppt", &tmp_ppt_name, error); out_tmpfile = g_unix_output_stream_new(fd_ppt, TRUE); @@ -81,9 +82,12 @@ chupa_feed_ppt(ChupaDecomposer *dec, ChupaText *chupar, ChupaTextInput *input, G g_error("argv overflow"); return FALSE; } - g_return_val_if_fail(chupa_external_decomposer_spawn(CHUPA_EXTERNAL_DECOMPOSER(dec), - argv, NULL, NULL, error), - FALSE); + + result = g_spawn_sync(NULL, argv, NULL, G_SPAWN_SEARCH_PATH, + NULL, NULL, NULL, NULL, &ooo_status, error); + g_return_val_if_fail(result, FALSE); + g_return_val_if_fail(ooo_status == 0, FALSE); + sleep(2); /* Suck! */ g_unlink(tmp_ppt_name); g_free(tmp_ppt_name); From null+ranguba at clear-code.com Mon Sep 27 07:37:07 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Mon, 27 Sep 2010 11:37:07 +0000 Subject: [groonga-commit:1360] ranguba/chupatext [master] * data/powerpoint/basic/Standard/Export.xba: WritePDF procedure. Message-ID: <20100927113718.5B41F170DBE@taiyaki.ru> Nobuyoshi Nakada 2010-09-27 11:37:07 +0000 (Mon, 27 Sep 2010) New Revision: 13d6663dff743358bbe68336b056fa6cfea7c1a7 Log: * data/powerpoint/basic/Standard/Export.xba: WritePDF procedure. Added files: data/powerpoint/basic/Standard/Export.xba data/powerpoint/basic/Standard/script.xlb Added: data/powerpoint/basic/Standard/Export.xba (+21 -0) 100644 =================================================================== --- /dev/null +++ data/powerpoint/basic/Standard/Export.xba 2010-09-27 11:37:07 +0000 (0c36b0c) @@ -0,0 +1,21 @@ + + + +sub WritePDF(url as string) +dim document as object +dim dispatcher as object +document = ThisComponent.CurrentController.Frame +dispatcher = createUnoService("com.sun.star.frame.DispatchHelper") + +dim args1(1) as new com.sun.star.beans.PropertyValue +args1(0).Name = "URL" +args1(0).Value = url +args1(1).Name = "FilterName" +args1(1).Value = "writer_pdf_Export" + +dispatcher.executeDispatch(document, ".uno:ExportDirectToPDF", "", 0, args1()) + +document.close(true) + +end sub + Added: data/powerpoint/basic/Standard/script.xlb (+6 -0) 100644 =================================================================== --- /dev/null +++ data/powerpoint/basic/Standard/script.xlb 2010-09-27 11:37:07 +0000 (98ba590) @@ -0,0 +1,6 @@ + + + + + + From null+ranguba at clear-code.com Mon Sep 27 07:52:38 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Mon, 27 Sep 2010 11:52:38 +0000 Subject: [groonga-commit:1361] ranguba/chupatext [master] use BUILT_SOURCES for generating version.h. Message-ID: <20100927115338.926DF170DBE@taiyaki.ru> Kouhei Sutou 2010-09-27 11:52:38 +0000 (Mon, 27 Sep 2010) New Revision: 709b539650a16e16d5c968e4fefcb2c97205846d Log: use BUILT_SOURCES for generating version.h. Modified files: Makefile.am chupatext/Makefile.am tool/version-update.sh Modified: Makefile.am (+1 -17) =================================================================== --- Makefile.am 2010-09-27 11:37:07 +0000 (a0cc318) +++ Makefile.am 2010-09-27 11:52:38 +0000 (3141368) @@ -8,25 +8,9 @@ EXTRA_DIST = \ COPYING \ README.ja -all-recursive: prereq - -prereq: - GIT = git -up: pull prereq +up: pull pull: @cd "$(srcdir)" && $(GIT) pull - -prereq: prereq-local prereq-recursive - -prereq-local: update-version.h - -prereq-recursive: - -update-version.h: - @cd "$(top_srcdir)" && \ - $(SHELL) ./tool/version-update.sh chupatext/version.h - -.PHONY: update-version.h prereq-local prereq-recursive Modified: chupatext/Makefile.am (+4 -1) =================================================================== --- chupatext/Makefile.am 2010-09-27 11:37:07 +0000 (29af428) +++ chupatext/Makefile.am 2010-09-27 11:52:38 +0000 (ef60341) @@ -7,6 +7,8 @@ bin_PROGRAMS = chupa chupa_SOURCES = chupa.c chupa_LDADD = libchupatext.la +BUILT_SOURCES = version.h + libchupatext_la_SOURCES = \ chupa_init.c \ chupa_metadata.c \ @@ -57,4 +59,5 @@ chupatext_include_HEADERS = \ chupa_utils.h \ version.h -version.lo: version.h +version.h: $(top_srcdir)/tool/version-update.sh + $(SHELL) $(top_srcdir)/tool/version-update.sh version.h Modified: tool/version-update.sh (+5 -2) =================================================================== --- tool/version-update.sh 2010-09-27 11:37:07 +0000 (f79e4e8) +++ tool/version-update.sh 2010-09-27 11:52:38 +0000 (35cd3dc) @@ -3,9 +3,12 @@ header="$1" test -z "$2" || cd "$2" +base_dir="$(dirname $0)" +top_dir="${base_dir}/.." + new= -if test -d .git; then - versionstr=`git describe --tags --match='[0-9][.0-9]*' 2>/dev/null` +if test -d "${top_dir}/.git"; then + versionstr=`git --git-dir "${top_dir}" describe --tags --match='[0-9][.0-9]*' 2>/dev/null` if test -n "$versionstr"; then save_IFS="$IFS" IFS=-; set $versionstr versionstr=$1 From null+ranguba at clear-code.com Mon Sep 27 08:18:27 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Mon, 27 Sep 2010 12:18:27 +0000 Subject: [groonga-commit:1362] ranguba/chupatext [master] add license header. Message-ID: <20100927121845.86CF7170DBE@taiyaki.ru> Kouhei Sutou 2010-09-27 12:18:27 +0000 (Mon, 27 Sep 2010) New Revision: bf1347572e76d549b29f17998f88dc99772c7694 Log: add license header. Modified files: chupatext/archive_decomposer.c chupatext/archive_decomposer.h chupatext/chupa.c chupatext/chupa_decomposer.c chupatext/chupa_decomposer.h chupatext/chupa_dispatcher.c chupatext/chupa_dispatcher.h chupatext/chupa_gsf_input_stream.c chupatext/chupa_gsf_input_stream.h chupatext/chupa_init.c chupatext/chupa_metadata.c chupatext/chupa_metadata.h chupatext/chupa_module.c chupatext/chupa_module.h chupatext/chupa_module_factory.c chupatext/chupa_module_factory.h chupatext/chupa_module_factory_utils.c chupatext/chupa_module_factory_utils.h chupatext/chupa_module_impl.h chupatext/chupa_private.h chupatext/chupa_restrict_input_stream.c chupatext/chupa_restrict_input_stream.h chupatext/chupa_text.c chupatext/chupa_text.h chupatext/chupa_text_input.c chupatext/chupa_text_input.h chupatext/chupa_text_input_stream.c chupatext/chupa_text_input_stream.h chupatext/chupa_utils.c chupatext/chupa_utils.h chupatext/error.c chupatext/external_decomposer.c chupatext/external_decomposer.h chupatext/version.c module/excel.c module/excel_factory.c module/pdf.c module/pdf_factory.c module/powerpoint.c module/powerpoint_factory.c module/tar.c module/tar_factory.c module/text.c module/text_factory.c module/word.c module/word_factory.c module/zip.c module/zip_factory.c test/chupa_test_util.c test/chupa_test_util.h test/suite_chupatext_test.c test/test_decomposer.c test/test_excel.c test/test_external_decomposer.c test/test_metadata.c test/test_pdf.c test/test_powerpoint.c test/test_restrict_input_stream.c test/test_tar.c test/test_text.c test/test_text_input.c test/test_text_input_stream.c test/test_word.c test/test_zip.c Modified: chupatext/archive_decomposer.c (+15 -0) =================================================================== --- chupatext/archive_decomposer.c 2010-09-27 11:52:38 +0000 (0368aa4) +++ chupatext/archive_decomposer.c 2010-09-27 12:18:27 +0000 (bf27e94) @@ -1,6 +1,21 @@ /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * Copyright (C) 2010 Nobuyoshi Nakada + * + * 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.1 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., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA */ #include "archive_decomposer.h" Modified: chupatext/archive_decomposer.h (+15 -0) =================================================================== --- chupatext/archive_decomposer.h 2010-09-27 11:52:38 +0000 (9c5ed1f) +++ chupatext/archive_decomposer.h 2010-09-27 12:18:27 +0000 (0f138b0) @@ -1,6 +1,21 @@ /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * Copyright (C) 2010 Nobuyoshi Nakada + * + * 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.1 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., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA */ #ifndef CHUPATEXT_ARCHIVE_DECOMPOSER_H Modified: chupatext/chupa.c (+15 -0) =================================================================== --- chupatext/chupa.c 2010-09-27 11:52:38 +0000 (49445a9) +++ chupatext/chupa.c 2010-09-27 12:18:27 +0000 (7ea229a) @@ -1,6 +1,21 @@ /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * Copyright (C) 2010 Nobuyoshi Nakada + * + * 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.1 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., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA */ #include Modified: chupatext/chupa_decomposer.c (+15 -0) =================================================================== --- chupatext/chupa_decomposer.c 2010-09-27 11:52:38 +0000 (372a255) +++ chupatext/chupa_decomposer.c 2010-09-27 12:18:27 +0000 (0311f61) @@ -1,6 +1,21 @@ /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * Copyright (C) 2010 Nobuyoshi Nakada + * + * 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.1 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., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA */ #include Modified: chupatext/chupa_decomposer.h (+15 -0) =================================================================== --- chupatext/chupa_decomposer.h 2010-09-27 11:52:38 +0000 (885635c) +++ chupatext/chupa_decomposer.h 2010-09-27 12:18:27 +0000 (2d7f6c2) @@ -1,6 +1,21 @@ /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * Copyright (C) 2010 Nobuyoshi Nakada + * + * 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.1 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., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA */ #ifndef CHUPATEXT_DECOMPOSER_H Modified: chupatext/chupa_dispatcher.c (+10 -9) =================================================================== --- chupatext/chupa_dispatcher.c 2010-09-27 11:52:38 +0000 (6db6a32) +++ chupatext/chupa_dispatcher.c 2010-09-27 12:18:27 +0000 (d4bd404) @@ -2,19 +2,20 @@ /* * Copyright (C) 2007-2010 Kouhei Sutou * - * 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 3 of the License, or - * (at your option) any later version. + * 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.1 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 program. If not, see . + * 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., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA */ #ifdef HAVE_CONFIG_H Modified: chupatext/chupa_dispatcher.h (+10 -9) =================================================================== --- chupatext/chupa_dispatcher.h 2010-09-27 11:52:38 +0000 (b83ef65) +++ chupatext/chupa_dispatcher.h 2010-09-27 12:18:27 +0000 (bea3712) @@ -2,19 +2,20 @@ /* * Copyright (C) 2007-2010 Kouhei Sutou * - * 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 3 of the License, or - * (at your option) any later version. + * 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.1 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 program. If not, see . + * 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., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA */ #ifndef __CHUPA_DISPATCHER_H__ Modified: chupatext/chupa_gsf_input_stream.c (+15 -0) =================================================================== --- chupatext/chupa_gsf_input_stream.c 2010-09-27 11:52:38 +0000 (9757c84) +++ chupatext/chupa_gsf_input_stream.c 2010-09-27 12:18:27 +0000 (aee21b9) @@ -1,6 +1,21 @@ /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * Copyright (C) 2010 Nobuyoshi Nakada + * + * 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.1 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., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA */ #include "chupatext/chupa_gsf_input_stream.h" Modified: chupatext/chupa_gsf_input_stream.h (+15 -0) =================================================================== --- chupatext/chupa_gsf_input_stream.h 2010-09-27 11:52:38 +0000 (6b9d69e) +++ chupatext/chupa_gsf_input_stream.h 2010-09-27 12:18:27 +0000 (789ff88) @@ -1,6 +1,21 @@ /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * Copyright (C) 2010 Nobuyoshi Nakada + * + * 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.1 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., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA */ #include Modified: chupatext/chupa_init.c (+15 -0) =================================================================== --- chupatext/chupa_init.c 2010-09-27 11:52:38 +0000 (9ac04de) +++ chupatext/chupa_init.c 2010-09-27 12:18:27 +0000 (b33a56e) @@ -1,6 +1,21 @@ /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * Copyright (C) 2010 Nobuyoshi Nakada + * + * 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.1 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., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA */ #include Modified: chupatext/chupa_metadata.c (+11 -10) =================================================================== --- chupatext/chupa_metadata.c 2010-09-27 11:52:38 +0000 (4f83593) +++ chupatext/chupa_metadata.c 2010-09-27 12:18:27 +0000 (b4f55af) @@ -1,20 +1,21 @@ /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* - * Copyright (C) 2008-2009 Kouhei Sutou + * Copyright (C) 2008-2010 Kouhei Sutou * - * 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 3 of the License, or - * (at your option) any later version. + * 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.1 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, see . + * 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., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA */ #include "chupatext/chupa_metadata.h" Modified: chupatext/chupa_metadata.h (+20 -0) =================================================================== --- chupatext/chupa_metadata.h 2010-09-27 11:52:38 +0000 (1499b08) +++ chupatext/chupa_metadata.h 2010-09-27 12:18:27 +0000 (c7a9df1) @@ -1,3 +1,23 @@ +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Copyright (C) 2010 Nobuyoshi Nakada + * + * 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.1 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., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + #ifndef CHUPA_METADATA_H #define CHUPA_METADATA_H Modified: chupatext/chupa_module.c (+11 -10) =================================================================== --- chupatext/chupa_module.c 2010-09-27 11:52:38 +0000 (ab7fc18) +++ chupatext/chupa_module.c 2010-09-27 12:18:27 +0000 (f8d96dc) @@ -1,20 +1,21 @@ /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* - * Copyright (C) 2008 Kouhei Sutou + * Copyright (C) 2008-2010 Kouhei Sutou * - * 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 3 of the License, or - * (at your option) any later version. + * 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.1 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, see . + * 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., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA */ #ifdef HAVE_CONFIG_H Modified: chupatext/chupa_module.h (+15 -0) =================================================================== --- chupatext/chupa_module.h 2010-09-27 11:52:38 +0000 (3d16344) +++ chupatext/chupa_module.h 2010-09-27 12:18:27 +0000 (48a5c96) @@ -1,6 +1,21 @@ /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * Copyright (C) 2010 Nobuyoshi Nakada + * + * 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.1 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., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA */ #ifndef CHUPA_MODULE_H Modified: chupatext/chupa_module_factory.c (+10 -9) =================================================================== --- chupatext/chupa_module_factory.c 2010-09-27 11:52:38 +0000 (d978906) +++ chupatext/chupa_module_factory.c 2010-09-27 12:18:27 +0000 (5da0def) @@ -2,19 +2,20 @@ /* * Copyright (C) 2007-2010 Kouhei Sutou * - * 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 3 of the License, or - * (at your option) any later version. + * 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.1 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 program. If not, see . + * 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., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA */ #ifdef HAVE_CONFIG_H Modified: chupatext/chupa_module_factory.h (+10 -9) =================================================================== --- chupatext/chupa_module_factory.h 2010-09-27 11:52:38 +0000 (5ff2a6e) +++ chupatext/chupa_module_factory.h 2010-09-27 12:18:27 +0000 (c18af4a) @@ -2,19 +2,20 @@ /* * Copyright (C) 2007-2010 Kouhei Sutou * - * 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 3 of the License, or - * (at your option) any later version. + * 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.1 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 program. If not, see . + * 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., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA */ #ifndef __CHUPA_MODULE_FACTORY_H__ Modified: chupatext/chupa_module_factory_utils.c (+10 -9) =================================================================== --- chupatext/chupa_module_factory_utils.c 2010-09-27 11:52:38 +0000 (d79b6a5) +++ chupatext/chupa_module_factory_utils.c 2010-09-27 12:18:27 +0000 (e88e6d6) @@ -2,19 +2,20 @@ /* * Copyright (C) 2007-2010 Kouhei Sutou * - * 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 3 of the License, or - * (at your option) any later version. + * 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.1 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 program. If not, see . + * 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., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA */ #ifdef HAVE_CONFIG_H Modified: chupatext/chupa_module_factory_utils.h (+11 -10) =================================================================== --- chupatext/chupa_module_factory_utils.h 2010-09-27 11:52:38 +0000 (84a5fa4) +++ chupatext/chupa_module_factory_utils.h 2010-09-27 12:18:27 +0000 (e48f5da) @@ -1,20 +1,21 @@ /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* - * Copyright (C) 2007-2010 Kouhei Sutou + * Copyright (C) 2007-2010 Kouhei Sutou * - * 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 3 of the License, or - * (at your option) any later version. + * 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.1 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 program. If not, see . + * 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., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA */ #ifndef __CHUPA_MODULE_FACTORY_UTILS_H__ Modified: chupatext/chupa_module_impl.h (+11 -10) =================================================================== --- chupatext/chupa_module_impl.h 2010-09-27 11:52:38 +0000 (f29bb41) +++ chupatext/chupa_module_impl.h 2010-09-27 12:18:27 +0000 (f8d5b8c) @@ -1,20 +1,21 @@ /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* - * Copyright (C) 2008 Kouhei Sutou + * Copyright (C) 2008-2010 Kouhei Sutou * - * 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 3 of the License, or - * (at your option) any later version. + * 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.1 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, see . + * 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., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA */ #ifndef CHUPA_MODULE_IMPL_H Modified: chupatext/chupa_private.h (+15 -0) =================================================================== --- chupatext/chupa_private.h 2010-09-27 11:52:38 +0000 (917f22d) +++ chupatext/chupa_private.h 2010-09-27 12:18:27 +0000 (aa72dd2) @@ -1,6 +1,21 @@ /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * Copyright (C) 2010 Nobuyoshi Nakada + * + * 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.1 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., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA */ #ifndef CHUPA_PRIVATE_H Modified: chupatext/chupa_restrict_input_stream.c (+15 -0) =================================================================== --- chupatext/chupa_restrict_input_stream.c 2010-09-27 11:52:38 +0000 (5818a8c) +++ chupatext/chupa_restrict_input_stream.c 2010-09-27 12:18:27 +0000 (4ff358b) @@ -1,6 +1,21 @@ /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * Copyright (C) 2010 Nobuyoshi Nakada + * + * 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.1 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., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA */ #include "chupatext/chupa_restrict_input_stream.h" Modified: chupatext/chupa_restrict_input_stream.h (+15 -0) =================================================================== --- chupatext/chupa_restrict_input_stream.h 2010-09-27 11:52:38 +0000 (5aef4dd) +++ chupatext/chupa_restrict_input_stream.h 2010-09-27 12:18:27 +0000 (bc591ef) @@ -1,6 +1,21 @@ /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * Copyright (C) 2010 Nobuyoshi Nakada + * + * 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.1 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., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA */ #ifndef CHUPA_RESTRICT_INPUT_STREAM_H Modified: chupatext/chupa_text.c (+15 -0) =================================================================== --- chupatext/chupa_text.c 2010-09-27 11:52:38 +0000 (0d68bc5) +++ chupatext/chupa_text.c 2010-09-27 12:18:27 +0000 (395d259) @@ -1,6 +1,21 @@ /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * Copyright (C) 2010 Nobuyoshi Nakada + * + * 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.1 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., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA */ #include "chupatext/chupa_text.h" Modified: chupatext/chupa_text.h (+15 -0) =================================================================== --- chupatext/chupa_text.h 2010-09-27 11:52:38 +0000 (534c8a8) +++ chupatext/chupa_text.h 2010-09-27 12:18:27 +0000 (4a75362) @@ -1,6 +1,21 @@ /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * Copyright (C) 2010 Nobuyoshi Nakada + * + * 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.1 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., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA */ #ifndef CHUPA_TEXT_H Modified: chupatext/chupa_text_input.c (+15 -0) =================================================================== --- chupatext/chupa_text_input.c 2010-09-27 11:52:38 +0000 (60ce0af) +++ chupatext/chupa_text_input.c 2010-09-27 12:18:27 +0000 (f7f5d35) @@ -1,6 +1,21 @@ /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * Copyright (C) 2010 Nobuyoshi Nakada + * + * 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.1 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., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA */ #include "chupatext/chupa_text_input.h" Modified: chupatext/chupa_text_input.h (+15 -0) =================================================================== --- chupatext/chupa_text_input.h 2010-09-27 11:52:38 +0000 (a021fec) +++ chupatext/chupa_text_input.h 2010-09-27 12:18:27 +0000 (1b5b41f) @@ -1,6 +1,21 @@ /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * Copyright (C) 2010 Nobuyoshi Nakada + * + * 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.1 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., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA */ #ifndef CHUPA_TEXT_INPUT_H Modified: chupatext/chupa_text_input_stream.c (+15 -0) =================================================================== --- chupatext/chupa_text_input_stream.c 2010-09-27 11:52:38 +0000 (742b029) +++ chupatext/chupa_text_input_stream.c 2010-09-27 12:18:27 +0000 (59e25c0) @@ -1,6 +1,21 @@ /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * Copyright (C) 2010 Nobuyoshi Nakada + * + * 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.1 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., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA */ #include "chupatext/chupa_text_input_stream.h" Modified: chupatext/chupa_text_input_stream.h (+15 -0) =================================================================== --- chupatext/chupa_text_input_stream.h 2010-09-27 11:52:38 +0000 (47c3895) +++ chupatext/chupa_text_input_stream.h 2010-09-27 12:18:27 +0000 (2fbd264) @@ -1,6 +1,21 @@ /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * Copyright (C) 2010 Nobuyoshi Nakada + * + * 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.1 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., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA */ #ifndef CHUPA_TEXT_INPUT_STREAM_H Modified: chupatext/chupa_utils.c (+10 -9) =================================================================== --- chupatext/chupa_utils.c 2010-09-27 11:52:38 +0000 (639b58f) +++ chupatext/chupa_utils.c 2010-09-27 12:18:27 +0000 (6ea8dd9) @@ -2,19 +2,20 @@ /* * Copyright (C) 2007-2010 Kouhei Sutou * - * 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 3 of the License, or - * (at your option) any later version. + * 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.1 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 program. If not, see . + * 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., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA */ #ifdef HAVE_CONFIG_H Modified: chupatext/chupa_utils.h (+10 -9) =================================================================== --- chupatext/chupa_utils.h 2010-09-27 11:52:38 +0000 (ab193fe) +++ chupatext/chupa_utils.h 2010-09-27 12:18:27 +0000 (e7c733a) @@ -2,19 +2,20 @@ /* * Copyright (C) 2007-2010 Kouhei Sutou * - * 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 3 of the License, or - * (at your option) any later version. + * 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.1 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 program. If not, see . + * 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., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA */ #ifndef __CHUPA_UTILS_H__ Modified: chupatext/error.c (+15 -0) =================================================================== --- chupatext/error.c 2010-09-27 11:52:38 +0000 (cb90e13) +++ chupatext/error.c 2010-09-27 12:18:27 +0000 (fc8dd48) @@ -1,6 +1,21 @@ /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * Copyright (C) 2010 Nobuyoshi Nakada + * + * 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.1 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., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA */ #include "chupatext/chupa_text.h" Modified: chupatext/external_decomposer.c (+15 -0) =================================================================== --- chupatext/external_decomposer.c 2010-09-27 11:52:38 +0000 (336d1d1) +++ chupatext/external_decomposer.c 2010-09-27 12:18:27 +0000 (b7a217a) @@ -1,6 +1,21 @@ /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * Copyright (C) 2010 Nobuyoshi Nakada + * + * 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.1 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., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA */ #include "external_decomposer.h" Modified: chupatext/external_decomposer.h (+15 -0) =================================================================== --- chupatext/external_decomposer.h 2010-09-27 11:52:38 +0000 (8e4289d) +++ chupatext/external_decomposer.h 2010-09-27 12:18:27 +0000 (b6f5302) @@ -1,6 +1,21 @@ /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * Copyright (C) 2010 Nobuyoshi Nakada + * + * 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.1 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., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA */ #ifndef CHUPATEXT_EXTERNAL_DECOMPOSER_H Modified: chupatext/version.c (+15 -0) =================================================================== --- chupatext/version.c 2010-09-27 11:52:38 +0000 (302740e) +++ chupatext/version.c 2010-09-27 12:18:27 +0000 (0c6b7dc) @@ -1,6 +1,21 @@ /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * Copyright (C) 2010 Nobuyoshi Nakada + * + * 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.1 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., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA */ #include "version.h" Modified: module/excel.c (+15 -0) =================================================================== --- module/excel.c 2010-09-27 11:52:38 +0000 (f462dc6) +++ module/excel.c 2010-09-27 12:18:27 +0000 (fc3bfd9) @@ -1,6 +1,21 @@ /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * Copyright (C) 2010 Nobuyoshi Nakada + * + * 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.1 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., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA */ #include Modified: module/excel_factory.c (+10 -9) =================================================================== --- module/excel_factory.c 2010-09-27 11:52:38 +0000 (63881e0) +++ module/excel_factory.c 2010-09-27 12:18:27 +0000 (79433d8) @@ -2,19 +2,20 @@ /* * Copyright (C) 2010 Kouhei Sutou * - * 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 3 of the License, or - * (at your option) any later version. + * 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.1 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 program. If not, see . + * 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., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA */ #ifdef HAVE_CONFIG_H Modified: module/pdf.c (+15 -0) =================================================================== --- module/pdf.c 2010-09-27 11:52:38 +0000 (be035be) +++ module/pdf.c 2010-09-27 12:18:27 +0000 (0084daf) @@ -1,6 +1,21 @@ /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * Copyright (C) 2010 Nobuyoshi Nakada + * + * 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.1 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., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA */ #include Modified: module/pdf_factory.c (+10 -9) =================================================================== --- module/pdf_factory.c 2010-09-27 11:52:38 +0000 (62c238f) +++ module/pdf_factory.c 2010-09-27 12:18:27 +0000 (632de42) @@ -2,19 +2,20 @@ /* * Copyright (C) 2010 Kouhei Sutou * - * 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 3 of the License, or - * (at your option) any later version. + * 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.1 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 program. If not, see . + * 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., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA */ #ifdef HAVE_CONFIG_H Modified: module/powerpoint.c (+15 -0) =================================================================== --- module/powerpoint.c 2010-09-27 11:52:38 +0000 (7c8141c) +++ module/powerpoint.c 2010-09-27 12:18:27 +0000 (aabbc95) @@ -1,6 +1,21 @@ /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * Copyright (C) 2010 Nobuyoshi Nakada + * + * 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.1 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., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA */ #include Modified: module/powerpoint_factory.c (+10 -9) =================================================================== --- module/powerpoint_factory.c 2010-09-27 11:52:38 +0000 (a300e3b) +++ module/powerpoint_factory.c 2010-09-27 12:18:27 +0000 (3abf6ef) @@ -2,19 +2,20 @@ /* * Copyright (C) 2010 Kouhei Sutou * - * 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 3 of the License, or - * (at your option) any later version. + * 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.1 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 program. If not, see . + * 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., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA */ #ifdef HAVE_CONFIG_H Modified: module/tar.c (+15 -0) =================================================================== --- module/tar.c 2010-09-27 11:52:38 +0000 (50a2699) +++ module/tar.c 2010-09-27 12:18:27 +0000 (f3dee70) @@ -1,6 +1,21 @@ /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * Copyright (C) 2010 Nobuyoshi Nakada + * + * 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.1 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., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA */ #include Modified: module/tar_factory.c (+10 -9) =================================================================== --- module/tar_factory.c 2010-09-27 11:52:38 +0000 (828dd3a) +++ module/tar_factory.c 2010-09-27 12:18:27 +0000 (27dc0f7) @@ -2,19 +2,20 @@ /* * Copyright (C) 2010 Kouhei Sutou * - * 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 3 of the License, or - * (at your option) any later version. + * 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.1 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 program. If not, see . + * 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., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA */ #ifdef HAVE_CONFIG_H Modified: module/text.c (+15 -0) =================================================================== --- module/text.c 2010-09-27 11:52:38 +0000 (be6c9ea) +++ module/text.c 2010-09-27 12:18:27 +0000 (6e569d6) @@ -1,6 +1,21 @@ /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * Copyright (C) 2010 Nobuyoshi Nakada + * + * 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.1 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., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA */ #include Modified: module/text_factory.c (+10 -9) =================================================================== --- module/text_factory.c 2010-09-27 11:52:38 +0000 (9fb8ea9) +++ module/text_factory.c 2010-09-27 12:18:27 +0000 (e9de9d8) @@ -2,19 +2,20 @@ /* * Copyright (C) 2010 Kouhei Sutou * - * 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 3 of the License, or - * (at your option) any later version. + * 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.1 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 program. If not, see . + * 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., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA */ #ifdef HAVE_CONFIG_H Modified: module/word.c (+15 -0) =================================================================== --- module/word.c 2010-09-27 11:52:38 +0000 (e567cb2) +++ module/word.c 2010-09-27 12:18:27 +0000 (d3d185e) @@ -1,6 +1,21 @@ /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * Copyright (C) 2010 Nobuyoshi Nakada + * + * 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.1 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., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA */ #include Modified: module/word_factory.c (+10 -9) =================================================================== --- module/word_factory.c 2010-09-27 11:52:38 +0000 (961ac62) +++ module/word_factory.c 2010-09-27 12:18:27 +0000 (2c5ae1b) @@ -2,19 +2,20 @@ /* * Copyright (C) 2010 Kouhei Sutou * - * 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 3 of the License, or - * (at your option) any later version. + * 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.1 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 program. If not, see . + * 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., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA */ #ifdef HAVE_CONFIG_H Modified: module/zip.c (+15 -0) =================================================================== --- module/zip.c 2010-09-27 11:52:38 +0000 (8492a33) +++ module/zip.c 2010-09-27 12:18:27 +0000 (98784fc) @@ -1,6 +1,21 @@ /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * Copyright (C) 2010 Nobuyoshi Nakada + * + * 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.1 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., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA */ #include Modified: module/zip_factory.c (+10 -9) =================================================================== --- module/zip_factory.c 2010-09-27 11:52:38 +0000 (f347d23) +++ module/zip_factory.c 2010-09-27 12:18:27 +0000 (50cbaff) @@ -2,19 +2,20 @@ /* * Copyright (C) 2010 Kouhei Sutou * - * 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 3 of the License, or - * (at your option) any later version. + * 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.1 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 program. If not, see . + * 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., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA */ #ifdef HAVE_CONFIG_H Modified: test/chupa_test_util.c (+15 -0) =================================================================== --- test/chupa_test_util.c 2010-09-27 11:52:38 +0000 (3729ce9) +++ test/chupa_test_util.c 2010-09-27 12:18:27 +0000 (8500fa4) @@ -1,6 +1,21 @@ /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * Copyright (C) 2010 Nobuyoshi Nakada + * + * 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.1 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., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA */ #include "chupa_test_util.h" Modified: test/chupa_test_util.h (+15 -0) =================================================================== --- test/chupa_test_util.h 2010-09-27 11:52:38 +0000 (a753aec) +++ test/chupa_test_util.h 2010-09-27 12:18:27 +0000 (8c43201) @@ -1,6 +1,21 @@ /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * Copyright (C) 2010 Nobuyoshi Nakada + * + * 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.1 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., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA */ #ifndef CHUPA_TEST_UTIL_H Modified: test/suite_chupatext_test.c (+11 -9) =================================================================== --- test/suite_chupatext_test.c 2010-09-27 11:52:38 +0000 (77779b2) +++ test/suite_chupatext_test.c 2010-09-27 12:18:27 +0000 (fdcd5f4) @@ -1,19 +1,21 @@ +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * Copyright (C) 2010 Kouhei Sutou * - * 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 3 of the License, or - * (at your option) any later version. + * 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.1 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 program. If not, see . + * 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., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA */ #include Modified: test/test_decomposer.c (+15 -0) =================================================================== --- test/test_decomposer.c 2010-09-27 11:52:38 +0000 (ed8a26b) +++ test/test_decomposer.c 2010-09-27 12:18:27 +0000 (8f13adf) @@ -1,6 +1,21 @@ /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * Copyright (C) 2010 Nobuyoshi Nakada + * + * 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.1 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., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA */ #include Modified: test/test_excel.c (+15 -0) =================================================================== --- test/test_excel.c 2010-09-27 11:52:38 +0000 (7967382) +++ test/test_excel.c 2010-09-27 12:18:27 +0000 (cec4aaa) @@ -1,6 +1,21 @@ /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * Copyright (C) 2010 Nobuyoshi Nakada + * + * 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.1 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., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA */ #include "chupa_test_util.h" Modified: test/test_external_decomposer.c (+15 -0) =================================================================== --- test/test_external_decomposer.c 2010-09-27 11:52:38 +0000 (f1d3c52) +++ test/test_external_decomposer.c 2010-09-27 12:18:27 +0000 (4891b2b) @@ -1,6 +1,21 @@ /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * Copyright (C) 2010 Nobuyoshi Nakada + * + * 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.1 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., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA */ #include "chupatext/external_decomposer.h" Modified: test/test_metadata.c (+11 -10) =================================================================== --- test/test_metadata.c 2010-09-27 11:52:38 +0000 (638ec2b) +++ test/test_metadata.c 2010-09-27 12:18:27 +0000 (7429829) @@ -1,20 +1,21 @@ /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* - * Copyright (C) 2008-2009 Kouhei Sutou + * Copyright (C) 2008-2010 Kouhei Sutou * - * 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 3 of the License, or - * (at your option) any later version. + * 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.1 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, see . + * 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., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA */ #include Modified: test/test_pdf.c (+15 -0) =================================================================== --- test/test_pdf.c 2010-09-27 11:52:38 +0000 (52be284) +++ test/test_pdf.c 2010-09-27 12:18:27 +0000 (a38f67f) @@ -1,6 +1,21 @@ /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4; encoding: utf-8 -*- */ /* * Copyright (C) 2010 Nobuyoshi Nakada + * + * 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.1 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., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA */ #include "chupa_test_util.h" Modified: test/test_powerpoint.c (+15 -0) =================================================================== --- test/test_powerpoint.c 2010-09-27 11:52:38 +0000 (7672acc) +++ test/test_powerpoint.c 2010-09-27 12:18:27 +0000 (af8f7ff) @@ -1,6 +1,21 @@ /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * Copyright (C) 2010 Nobuyoshi Nakada + * + * 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.1 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., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA */ #include "chupa_test_util.h" Modified: test/test_restrict_input_stream.c (+15 -0) =================================================================== --- test/test_restrict_input_stream.c 2010-09-27 11:52:38 +0000 (c4be64d) +++ test/test_restrict_input_stream.c 2010-09-27 12:18:27 +0000 (8eac062) @@ -1,6 +1,21 @@ /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * Copyright (C) 2010 Nobuyoshi Nakada + * + * 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.1 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., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA */ #include Modified: test/test_tar.c (+15 -0) =================================================================== --- test/test_tar.c 2010-09-27 11:52:38 +0000 (be1b65e) +++ test/test_tar.c 2010-09-27 12:18:27 +0000 (2a1c291) @@ -1,6 +1,21 @@ /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * Copyright (C) 2010 Nobuyoshi Nakada + * + * 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.1 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., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA */ #include "chupa_test_util.h" Modified: test/test_text.c (+15 -0) =================================================================== --- test/test_text.c 2010-09-27 11:52:38 +0000 (b3874e7) +++ test/test_text.c 2010-09-27 12:18:27 +0000 (81a9acf) @@ -1,6 +1,21 @@ /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * Copyright (C) 2010 Nobuyoshi Nakada + * + * 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.1 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., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA */ #include Modified: test/test_text_input.c (+15 -0) =================================================================== --- test/test_text_input.c 2010-09-27 11:52:38 +0000 (a47eccb) +++ test/test_text_input.c 2010-09-27 12:18:27 +0000 (7c558dc) @@ -1,6 +1,21 @@ /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * Copyright (C) 2010 Nobuyoshi Nakada + * + * 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.1 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., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA */ #include Modified: test/test_text_input_stream.c (+15 -0) =================================================================== --- test/test_text_input_stream.c 2010-09-27 11:52:38 +0000 (4caa451) +++ test/test_text_input_stream.c 2010-09-27 12:18:27 +0000 (66cae3d) @@ -1,6 +1,21 @@ /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * Copyright (C) 2010 Nobuyoshi Nakada + * + * 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.1 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., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA */ #include Modified: test/test_word.c (+15 -0) =================================================================== --- test/test_word.c 2010-09-27 11:52:38 +0000 (4794944) +++ test/test_word.c 2010-09-27 12:18:27 +0000 (663696d) @@ -1,6 +1,21 @@ /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4; encoding: utf-8 -*- */ /* * Copyright (C) 2010 Nobuyoshi Nakada + * + * 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.1 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., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA */ #include "chupa_test_util.h" Modified: test/test_zip.c (+15 -0) =================================================================== --- test/test_zip.c 2010-09-27 11:52:38 +0000 (741a6de) +++ test/test_zip.c 2010-09-27 12:18:27 +0000 (23e6c45) @@ -1,6 +1,21 @@ /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * Copyright (C) 2010 Nobuyoshi Nakada + * + * 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.1 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., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA */ #include "chupa_test_util.h" From null+ranguba at clear-code.com Mon Sep 27 10:15:35 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Mon, 27 Sep 2010 14:15:35 +0000 Subject: [groonga-commit:1363] ranguba/chupatext [master] mention about module/excel/ license. Message-ID: <20100927141549.161FC170DBE@taiyaki.ru> Kouhei Sutou 2010-09-27 14:15:35 +0000 (Mon, 27 Sep 2010) New Revision: 3820969b98012bfa09a794d2ad4e0343a604fd20 Log: mention about module/excel/ license. Added files: license/gpl-2.txt Modified files: README.ja Modified: README.ja (+5 -0) =================================================================== --- README.ja 2010-09-27 12:18:27 +0000 (a662553) +++ README.ja 2010-09-27 14:15:35 +0000 (eb5205b) @@ -32,6 +32,11 @@ ChupaText BY-SA?|URL:http://creativecommons.org/licenses/by-sa/3.0/>)) ??? * ??: + * module/excel/: GPL?????2???: + ((<"license/gpl-2.txt"|URL:http://www.gnu.org/licenses/gpl-2.html>))? + ??? + (()) + ?????????????? * ... == ChupaText? Added: license/gpl-2.txt (+339 -0) 100644 =================================================================== --- /dev/null +++ license/gpl-2.txt 2010-09-27 14:15:35 +0000 (d159169) @@ -0,0 +1,339 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. From null+ranguba at clear-code.com Mon Sep 27 10:18:52 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Mon, 27 Sep 2010 14:18:52 +0000 Subject: [groonga-commit:1364] ranguba/chupatext [master] decomp -> decomposer. Message-ID: <20100927141902.E9F86170EE5@taiyaki.ru> Kouhei Sutou 2010-09-27 14:18:52 +0000 (Mon, 27 Sep 2010) New Revision: b220de3316c2a0ac5a7400636bd744466f61e216 Log: decomp -> decomposer. Modified files: test/test_decomposer.c Modified: test/test_decomposer.c (+6 -6) =================================================================== --- test/test_decomposer.c 2010-09-27 14:18:17 +0000 (d6212fc) +++ test/test_decomposer.c 2010-09-27 14:18:52 +0000 (9bbc63b) @@ -26,14 +26,14 @@ void test_search(void); void test_register(void); -static ChupaDecomposer *decomp; +static ChupaDecomposer *decomposer; static ChupaDispatcher *dispatcher; static GInputStream *source; void setup(void) { - decomp = NULL; + decomposer = NULL; dispatcher = chupa_dispatcher_new(); } @@ -42,8 +42,8 @@ teardown(void) { if (dispatcher) g_object_unref(dispatcher); - if (decomp) - g_object_unref(decomp); + if (decomposer) + g_object_unref(decomposer); if (source) g_object_unref(source); } @@ -51,6 +51,6 @@ teardown(void) void test_search(void) { - decomp = chupa_dispatcher_dispatch(dispatcher, "text/plain"); - cut_assert_not_null(decomp); + decomposer = chupa_dispatcher_dispatch(dispatcher, "text/plain"); + cut_assert_not_null(decomposer); } From null+ranguba at clear-code.com Mon Sep 27 10:18:17 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Mon, 27 Sep 2010 14:18:17 +0000 Subject: [groonga-commit:1365] ranguba/chupatext [master] remove a needless test. Message-ID: <20100927141902.DEB8B170DBE@taiyaki.ru> Kouhei Sutou 2010-09-27 14:18:17 +0000 (Mon, 27 Sep 2010) New Revision: c1b79ecd144ef6c758bebf8a06c55a4a23c8f301 Log: remove a needless test. Modified files: test/test_decomposer.c Modified: test/test_decomposer.c (+0 -49) =================================================================== --- test/test_decomposer.c 2010-09-27 14:15:35 +0000 (8f13adf) +++ test/test_decomposer.c 2010-09-27 14:18:17 +0000 (d6212fc) @@ -54,52 +54,3 @@ test_search(void) decomp = chupa_dispatcher_dispatch(dispatcher, "text/plain"); cut_assert_not_null(decomp); } - -#define CHUPA_TEST_TYPE_DUMMY_DECOMPOSER chupa_test_dummy_decomposer_get_type() -#define CHUPA_TEST_DUMMY_DECOMPOSER(obj) \ - G_TYPE_CHECK_INSTANCE_CAST(obj, CHUPA_TEST_TYPE_DUMMY_DECOMPOSER, ChupaTestDummyDecomposer) -#define CHUPA_TEST_DUMMY_DECOMPOSER_CLASS(klass) \ - G_TYPE_CHECK_CLASS_CAST(klass, CHUPA_TEST_TYPE_DUMMY_DECOMPOSER, ChupaTestDummyDecomposerClass) -#define CHUPA_TEST_IS_DUMMY_DECOMPOSER(obj) \ - G_TYPE_CHECK_INSTANCE_TYPE(obj, CHUPA_TEST_TYPE_DUMMY_DECOMPOSER) -#define CHUPA_TEST_IS_DUMMY_DECOMPOSER_CLASS(klass) \ - G_TYPE_CHECK_CLASS_TYPE(klass, CHUPA_TEST_TYPE_DUMMY_DECOMPOSER) -#define CHUPA_TEST_DUMMY_DECOMPOSER_GET_CLASS(obj) \ - G_TYPE_INSTANCE_GET_CLASS(obj, CHUPA_TEST_TYPE_DUMMY_DECOMPOSER, ChupaTestDummyDecomposerClass) - -typedef struct _ChupaTestDummyDecomposer ChupaTestDummyDecomposer; -typedef struct _ChupaTestDummyDecomposerClass ChupaTestDummyDecomposerClass; -typedef struct _ChupaTestDummyDecomposerPrivate ChupaTestDummyDecomposerPrivate; - -struct _ChupaTestDummyDecomposer -{ - ChupaDecomposer object; -}; - -struct _ChupaTestDummyDecomposerClass -{ - ChupaDecomposerClass parent_class; -}; - -static GType chupa_test_dummy_decomposer_get_type(void); - -G_DEFINE_TYPE(ChupaTestDummyDecomposer, chupa_test_dummy_decomposer, CHUPA_TYPE_DECOMPOSER) - -static void -chupa_test_dummy_decomposer_init(ChupaTestDummyDecomposer *dec) -{ -} - -static void -chupa_test_dummy_decomposer_class_init(ChupaTestDummyDecomposerClass *klass) -{ -} - -void -test_register(void) -{ - static const char test_dummy_type[] = "application/x-chupa-test"; - return; - chupa_decomposer_register(test_dummy_type, CHUPA_TEST_TYPE_DUMMY_DECOMPOSER); - chupa_decomposer_unregister(test_dummy_type, CHUPA_TEST_TYPE_DUMMY_DECOMPOSER); -} From null+ranguba at clear-code.com Mon Sep 27 10:20:22 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Mon, 27 Sep 2010 14:20:22 +0000 Subject: [groonga-commit:1366] ranguba/chupatext [master] encoding -> coding. Message-ID: <20100927142032.72786170DBE@taiyaki.ru> Kouhei Sutou 2010-09-27 14:20:22 +0000 (Mon, 27 Sep 2010) New Revision: d17455dcc852b2e4365aceb1f283642604b802a3 Log: encoding -> coding. Modified files: test/test_pdf.c test/test_word.c Modified: test/test_pdf.c (+1 -1) =================================================================== --- test/test_pdf.c 2010-09-27 14:18:52 +0000 (a38f67f) +++ test/test_pdf.c 2010-09-27 14:20:22 +0000 (07a8ec7) @@ -1,4 +1,4 @@ -/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4; encoding: utf-8 -*- */ +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4; coding: utf-8 -*- */ /* * Copyright (C) 2010 Nobuyoshi Nakada * Modified: test/test_word.c (+1 -1) =================================================================== --- test/test_word.c 2010-09-27 14:18:52 +0000 (663696d) +++ test/test_word.c 2010-09-27 14:20:22 +0000 (9824adc) @@ -1,4 +1,4 @@ -/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4; encoding: utf-8 -*- */ +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4; coding: utf-8 -*- */ /* * Copyright (C) 2010 Nobuyoshi Nakada * From null+ranguba at clear-code.com Mon Sep 27 19:38:40 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Mon, 27 Sep 2010 23:38:40 +0000 Subject: [groonga-commit:1367] ranguba/chupatext [master] * chupatext/chupa_gsf_input_stream.c (ChupaGsfInputStream): fix parent class object. Message-ID: <20100927233840.F0334170DBE@taiyaki.ru> Nobuyoshi Nakada 2010-09-27 23:38:40 +0000 (Mon, 27 Sep 2010) New Revision: 4e0777d9de340711a41a24855b49349354f364ba Log: * chupatext/chupa_gsf_input_stream.c (ChupaGsfInputStream): fix parent class object. Modified files: chupatext/chupa_gsf_input_stream.c Modified: chupatext/chupa_gsf_input_stream.c (+2 -2) =================================================================== --- chupatext/chupa_gsf_input_stream.c 2010-09-27 14:20:22 +0000 (aee21b9) +++ chupatext/chupa_gsf_input_stream.c 2010-09-27 23:38:40 +0000 (52fb345) @@ -25,14 +25,14 @@ typedef struct _ChupaGsfInputStreamPrivate ChupaGsfInputStreamPrivate; struct _ChupaGsfInputStream { - GInputStream parent_object; + GMemoryInputStream parent_object; GsfOutputMemory *source; gsize cur_offset; }; struct _ChupaGsfInputStreamClass { - GInputStreamClass parent_class; + GMemoryInputStreamClass parent_class; }; G_DEFINE_TYPE(ChupaGsfInputStream, chupa_gsf_input_stream, G_TYPE_MEMORY_INPUT_STREAM) From null+ranguba at clear-code.com Mon Sep 27 19:57:19 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Mon, 27 Sep 2010 23:57:19 +0000 Subject: [groonga-commit:1368] ranguba/chupatext [master] * module/excel.c (CHUPA_MODULE_IMPL_INIT): call gutils_init. Message-ID: <20100928062906.DA1F9170EB4@taiyaki.ru> Nobuyoshi Nakada 2010-09-27 23:57:19 +0000 (Mon, 27 Sep 2010) New Revision: 52593e5d4c6e0a41155d28e101a11b3091d4ab42 Log: * module/excel.c (CHUPA_MODULE_IMPL_INIT): call gutils_init. Modified files: module/excel.c Modified: module/excel.c (+2 -3) =================================================================== --- module/excel.c 2010-09-27 23:38:40 +0000 (fc3bfd9) +++ module/excel.c 2010-09-27 23:57:19 +0000 (d1aa4db) @@ -159,12 +159,11 @@ void gnm_plugins_init (GOCmdContext *c); G_MODULE_EXPORT GList * CHUPA_MODULE_IMPL_INIT(GTypeModule *type_module) { + extern void gutils_init(void); GList *registered_types = NULL; GOErrorInfo *plugin_errs; - const gchar *argv[2]; - argv[0] = NULL; - gnm_pre_parse_init(0, argv); + gutils_init(); gnm_init (); gnm_conf_init(); From null+ranguba at clear-code.com Tue Sep 28 02:26:08 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Tue, 28 Sep 2010 06:26:08 +0000 Subject: [groonga-commit:1369] ranguba/chupatext [master] * chupatext/chupa_memory_input_stream.c: renamed from chupa_gsf_input_stream. Message-ID: <20100928062907.129CD170EC2@taiyaki.ru> Nobuyoshi Nakada 2010-09-28 06:26:08 +0000 (Tue, 28 Sep 2010) New Revision: 6bc2ce28392eb1bc4ec519d8103a8393900b4206 Log: * chupatext/chupa_memory_input_stream.c: renamed from chupa_gsf_input_stream. Modified files: chupatext/Makefile.am module/excel.c Renamed files: chupatext/chupa_memory_input_stream.c (from chupatext/chupa_gsf_input_stream.c) chupatext/chupa_memory_input_stream.h (from chupatext/chupa_gsf_input_stream.h) Modified: chupatext/Makefile.am (+2 -2) =================================================================== --- chupatext/Makefile.am 2010-09-27 23:57:19 +0000 (ef60341) +++ chupatext/Makefile.am 2010-09-28 06:26:08 +0000 (665a94d) @@ -19,7 +19,7 @@ libchupatext_la_SOURCES = \ chupa_module_factory_utils.c \ chupa_dispatcher.c \ chupa_text_input_stream.c \ - chupa_gsf_input_stream.c \ + chupa_memory_input_stream.c \ error.c \ chupa_decomposer.c \ archive_decomposer.c \ @@ -54,7 +54,7 @@ chupatext_include_HEADERS = \ chupa_text.h \ chupa_text_input.h \ chupa_text_input_stream.h \ - chupa_gsf_input_stream.h \ + chupa_memory_input_stream.h \ external_decomposer.h \ chupa_utils.h \ version.h Renamed: chupatext/chupa_memory_input_stream.c (+17 -20) 67% =================================================================== --- chupatext/chupa_gsf_input_stream.c 2010-09-27 23:57:19 +0000 (52fb345) +++ chupatext/chupa_memory_input_stream.c 2010-09-28 06:26:08 +0000 (7fd9abf) @@ -18,46 +18,43 @@ * MA 02110-1301 USA */ -#include "chupatext/chupa_gsf_input_stream.h" +#include "chupatext/chupa_memory_input_stream.h" #include -typedef struct _ChupaGsfInputStreamPrivate ChupaGsfInputStreamPrivate; +typedef struct _ChupaMemoryInputStreamPrivate ChupaMemoryInputStreamPrivate; -struct _ChupaGsfInputStream +struct _ChupaMemoryInputStream { GMemoryInputStream parent_object; GsfOutputMemory *source; gsize cur_offset; }; -struct _ChupaGsfInputStreamClass +struct _ChupaMemoryInputStreamClass { GMemoryInputStreamClass parent_class; }; -G_DEFINE_TYPE(ChupaGsfInputStream, chupa_gsf_input_stream, G_TYPE_MEMORY_INPUT_STREAM) +G_DEFINE_TYPE(ChupaMemoryInputStream, chupa_memory_input_stream, G_TYPE_MEMORY_INPUT_STREAM) static void -gsf_input_dispose(GObject *object) +chupa_memory_input_stream_dispose(GObject *object) { - ChupaGsfInputStream *stream = CHUPA_GSF_INPUT_STREAM(object); + ChupaMemoryInputStream *stream = CHUPA_MEMORY_INPUT_STREAM(object); if (stream->source) { g_object_unref(stream->source); stream->source = NULL; } - G_OBJECT_CLASS(chupa_gsf_input_stream_parent_class)->dispose(object); + G_OBJECT_CLASS(chupa_memory_input_stream_parent_class)->dispose(object); } static gssize -gsf_input_stream_read(GInputStream *input_stream, - void *buffer, - gsize count, - GCancellable *cancellable, - GError **error) +chupa_memory_input_stream_read(GInputStream *input_stream, void *buffer, gsize count, + GCancellable *cancellable, GError **error) { - ChupaGsfInputStream *stream = CHUPA_GSF_INPUT_STREAM(input_stream); + ChupaMemoryInputStream *stream = CHUPA_MEMORY_INPUT_STREAM(input_stream); gsize cur_size; g_return_val_if_fail(stream->source, -1); @@ -77,26 +74,26 @@ gsf_input_stream_read(GInputStream *input_stream, } static void -chupa_gsf_input_stream_init(ChupaGsfInputStream *stream) +chupa_memory_input_stream_init(ChupaMemoryInputStream *stream) { stream->source = NULL; } static void -chupa_gsf_input_stream_class_init(ChupaGsfInputStreamClass *klass) +chupa_memory_input_stream_class_init(ChupaMemoryInputStreamClass *klass) { GObjectClass *gobject_class = G_OBJECT_CLASS(klass); - gobject_class->dispose = gsf_input_dispose; + gobject_class->dispose = chupa_memory_input_stream_dispose; { GInputStreamClass *input_stream_class = G_INPUT_STREAM_CLASS(klass); - input_stream_class->read_fn = gsf_input_stream_read; + input_stream_class->read_fn = chupa_memory_input_stream_read; } } GInputStream * -chupa_gsf_input_stream_new(GsfOutputMemory *mem) +chupa_memory_input_stream_new(GsfOutputMemory *mem) { - ChupaGsfInputStream *stream = g_object_new(CHUPA_TYPE_GSF_INPUT_STREAM, NULL); + ChupaMemoryInputStream *stream = g_object_new(CHUPA_TYPE_MEMORY_INPUT_STREAM, NULL); GsfOutput *out = GSF_OUTPUT(mem); gsize size; Renamed: chupatext/chupa_memory_input_stream.h (+15 -15) 50% =================================================================== --- chupatext/chupa_gsf_input_stream.h 2010-09-27 23:57:19 +0000 (789ff88) +++ chupatext/chupa_memory_input_stream.h 2010-09-28 06:26:08 +0000 (4588d8e) @@ -24,22 +24,22 @@ G_BEGIN_DECLS -#define CHUPA_TYPE_GSF_INPUT_STREAM chupa_gsf_input_stream_get_type() -#define CHUPA_GSF_INPUT_STREAM(obj) \ - G_TYPE_CHECK_INSTANCE_CAST(obj, CHUPA_TYPE_GSF_INPUT_STREAM, ChupaGsfInputStream) -#define CHUPA_GSF_INPUT_STREAM_CLASS(klass) \ - G_TYPE_CHECK_CLASS_CAST(klass, CHUPA_TYPE_GSF_INPUT_STREAM, ChupaGsfInputStreamClass) -#define CHUPA_IS_GSF_INPUT_STREAM(obj) \ - G_TYPE_CHECK_INSTANCE_TYPE(obj, CHUPA_TYPE_GSF_INPUT_STREAM) -#define CHUPA_IS_GSF_INPUT_STREAM_CLASS(klass) \ - G_TYPE_CHECK_CLASS_TYPE(klass, CHUPA_TYPE_GSF_INPUT_STREAM) -#define CHUPA_GSF_INPUT_STREAM_GET_CLASS(obj) \ - G_TYPE_INSTANCE_GET_CLASS(obj, CHUPA_TYPE_GSF_INPUT_STREAM, ChupaGsfInputStreamClass) +#define CHUPA_TYPE_MEMORY_INPUT_STREAM chupa_memory_input_stream_get_type() +#define CHUPA_MEMORY_INPUT_STREAM(obj) \ + G_TYPE_CHECK_INSTANCE_CAST(obj, CHUPA_TYPE_MEMORY_INPUT_STREAM, ChupaMemoryInputStream) +#define CHUPA_MEMORY_INPUT_STREAM_CLASS(klass) \ + G_TYPE_CHECK_CLASS_CAST(klass, CHUPA_TYPE_MEMORY_INPUT_STREAM, ChupaMemoryInputStreamClass) +#define CHUPA_IS_MEMORY_INPUT_STREAM(obj) \ + G_TYPE_CHECK_INSTANCE_TYPE(obj, CHUPA_TYPE_MEMORY_INPUT_STREAM) +#define CHUPA_IS_MEMORY_INPUT_STREAM_CLASS(klass) \ + G_TYPE_CHECK_CLASS_TYPE(klass, CHUPA_TYPE_MEMORY_INPUT_STREAM) +#define CHUPA_MEMORY_INPUT_STREAM_GET_CLASS(obj) \ + G_TYPE_INSTANCE_GET_CLASS(obj, CHUPA_TYPE_MEMORY_INPUT_STREAM, ChupaMemoryInputStreamClass) -typedef struct _ChupaGsfInputStream ChupaGsfInputStream; -typedef struct _ChupaGsfInputStreamClass ChupaGsfInputStreamClass; +typedef struct _ChupaMemoryInputStream ChupaMemoryInputStream; +typedef struct _ChupaMemoryInputStreamClass ChupaMemoryInputStreamClass; -GType chupa_gsf_input_stream_get_type(void); -GInputStream *chupa_gsf_input_stream_new(GsfOutputMemory *); +GType chupa_memory_input_stream_get_type(void); +GInputStream *chupa_memory_input_stream_new(GsfOutputMemory *); G_END_DECLS Modified: module/excel.c (+2 -2) =================================================================== --- module/excel.c 2010-09-27 23:57:19 +0000 (d1aa4db) +++ module/excel.c 2010-09-28 06:26:08 +0000 (d08fdc3) @@ -25,7 +25,7 @@ #include #include "workbook-view.h" #include "command-context-stderr.h" -#include "chupatext/chupa_gsf_input_stream.h" +#include "chupatext/chupa_memory_input_stream.h" #define CHUPA_TYPE_EXCEL_DECOMPOSER chupa_type_excel_decomposer #define CHUPA_EXCEL_DECOMPOSER(obj) \ @@ -106,7 +106,7 @@ chupa_excel_decomposer_feed(ChupaDecomposer *dec, ChupaText *chupar, return FALSE; } - tmpinp = chupa_gsf_input_stream_new(GSF_OUTPUT_MEMORY(tmpout)); + tmpinp = chupa_memory_input_stream_new(GSF_OUTPUT_MEMORY(tmpout)); g_object_unref(io_context); g_object_unref(tmpout); input = chupa_text_input_new_from_stream(NULL, tmpinp, chupa_text_input_get_filename(input)); From null+ranguba at clear-code.com Tue Sep 28 02:29:03 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Tue, 28 Sep 2010 06:29:03 +0000 Subject: [groonga-commit:1370] ranguba/chupatext [master] * test/test_external_decomposer.c: removed. Message-ID: <20100928062907.2ECFD170F7E@taiyaki.ru> Nobuyoshi Nakada 2010-09-28 06:29:03 +0000 (Tue, 28 Sep 2010) New Revision: 39f494eedfd0db4b01f11eb311efed601715af0b Log: * test/test_external_decomposer.c: removed. Removed files: test/test_external_decomposer.c Modified files: test/Makefile.am Modified: test/Makefile.am (+0 -2) =================================================================== --- test/Makefile.am 2010-09-28 06:26:08 +0000 (3a9003c) +++ test/Makefile.am 2010-09-28 06:29:03 +0000 (0a0c25e) @@ -12,7 +12,6 @@ noinst_LTLIBRARIES = \ test_text_input.la \ test_text_input_stream.la \ test_decomposer.la \ - test_external_decomposer.la \ test_restrict_input_stream.la \ test_tar.la \ test_zip.la \ @@ -67,7 +66,6 @@ test_text_la_SOURCES = test_text.c chupa_test_util.c test_text_input_la_SOURCES = test_text_input.c test_text_input_stream_la_SOURCES = test_text_input_stream.c test_decomposer_la_SOURCES = test_decomposer.c -test_external_decomposer_la_SOURCES = test_external_decomposer.c chupa_test_util.c test_restrict_input_stream_la_SOURCES = test_restrict_input_stream.c test_pdf_la_SOURCES = test_pdf.c chupa_test_util.c test_word_la_SOURCES = test_word.c chupa_test_util.c Deleted: test/test_external_decomposer.c (+0 -115) 100644 =================================================================== --- test/test_external_decomposer.c 2010-09-28 06:26:08 +0000 (4891b2b) +++ /dev/null @@ -1,115 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * Copyright (C) 2010 Nobuyoshi Nakada - * - * 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.1 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., 51 Franklin Street, Fifth Floor, Boston, - * MA 02110-1301 USA - */ - -#include "chupatext/external_decomposer.h" -#include "chupa_test_util.h" -#include - -void test_decompose_external(void); - -#define CHUPA_TEST_TYPE_EXTERNAL_DECOMPOSER chupa_test_external_decomposer_get_type() -#define CHUPA_TEST_EXTERNAL_DECOMPOSER(obj) \ - G_TYPE_CHECK_INSTANCE_CAST(obj, CHUPA_TEST_TYPE_EXTERNAL_DECOMPOSER, ChupaTestExternalDecomposer) -#define CHUPA_TEST_EXTERNAL_DECOMPOSER_CLASS(klass) \ - G_TYPE_CHECK_CLASS_CAST(klass, CHUPA_TEST_TYPE_EXTERNAL_DECOMPOSER, ChupaTestExternalDecomposerClass) -#define CHUPA_TEST_IS_EXTERNAL_DECOMPOSER(obj) \ - G_TYPE_CHECK_INSTANCE_TYPE(obj, CHUPA_TEST_TYPE_EXTERNAL_DECOMPOSER) -#define CHUPA_TEST_IS_EXTERNAL_DECOMPOSER_CLASS(klass) \ - G_TYPE_CHECK_CLASS_TYPE(klass, CHUPA_TEST_TYPE_EXTERNAL_DECOMPOSER) -#define CHUPA_TEST_EXTERNAL_DECOMPOSER_GET_CLASS(obj) \ - G_TYPE_INSTANCE_GET_CLASS(obj, CHUPA_TEST_TYPE_EXTERNAL_DECOMPOSER, ChupaTestExternalDecomposerClass) - -typedef struct _ChupaTestExternalDecomposer ChupaTestExternalDecomposer; -typedef struct _ChupaTestExternalDecomposerClass ChupaTestExternalDecomposerClass; -typedef struct _ChupaTestExternalDecomposerPrivate ChupaTestExternalDecomposerPrivate; - -struct _ChupaTestExternalDecomposer -{ - ChupaExternalDecomposer object; -}; - -struct _ChupaTestExternalDecomposerClass -{ - ChupaExternalDecomposerClass parent_class; -}; - -static GType chupa_test_external_decomposer_get_type(void); -G_DEFINE_TYPE(ChupaTestExternalDecomposer, chupa_test_external_decomposer, CHUPA_TYPE_EXTERNAL_DECOMPOSER) - -#define A_LINE "abcdefghijklmnopqrstuvwxyz-0123456789" -#define DOUBLE(x) x x -#define LONG_LINE DOUBLE(DOUBLE(DOUBLE(DOUBLE(A_LINE)))) -static const char plain_text[] = "plain text\n" - "foo bar\n" - "\fzot\n" - DOUBLE(DOUBLE(DOUBLE(LONG_LINE "\n"))) - ; - -static gboolean -testdec_spawn(ChupaExternalDecomposer *dec, ChupaText *chupar, - GOutputStream **stdinput, GInputStream **stdoutput, - GError **error) -{ - gchar *argv[2]; - argv[0] = "cat"; - argv[1] = NULL; - return chupa_external_decomposer_spawn(dec, argv, stdinput, stdoutput, error); -} - -static void -chupa_test_external_decomposer_init(ChupaTestExternalDecomposer *dec) -{ -} - -static void -chupa_test_external_decomposer_class_init(ChupaTestExternalDecomposerClass *klass) -{ - ChupaExternalDecomposerClass *extdec_class = CHUPA_EXTERNAL_DECOMPOSER_CLASS(klass); - extdec_class->spawn = testdec_spawn; -} - -static const char test_external_type[] = "application/x-chupa-test-external"; - -void -setup(void) -{ - chupa_test_setup(); - cut_omit("chupa_decomposer_register() was deleted"); - /* chupa_decomposer_register(test_external_type, CHUPA_TEST_TYPE_EXTERNAL_DECOMPOSER); */ -} - -void -teardown(void) -{ - /* chupa_decomposer_unregister(test_external_type, CHUPA_TEST_TYPE_EXTERNAL_DECOMPOSER); */ - chupa_test_teardown(); -} - -void -test_decompose_external(void) -{ - ChupaTextInput *input = chupa_test_decomposer_from_data(plain_text, sizeof(plain_text) - 1, NULL); - - cut_assert_not_null(input); - chupa_metadata_replace_value(chupa_text_input_get_metadata(input), - "mime-type", test_external_type); - cut_assert(CHUPA_TEST_IS_EXTERNAL_DECOMPOSER(gcut_take_object(G_OBJECT(chupa_decomposer_search(test_external_type))))); - cut_assert_equal_string(plain_text, chupa_test_decompose_all(input, NULL)); -} From null+ranguba at clear-code.com Tue Sep 28 02:52:27 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Tue, 28 Sep 2010 06:52:27 +0000 Subject: [groonga-commit:1371] ranguba/chupatext [master] * chupatext/chupa_text.h (ChupaTextClass): fixed argument type of decomposed. Message-ID: <20100928065225.A1A59170EB4@taiyaki.ru> Nobuyoshi Nakada 2010-09-28 06:52:27 +0000 (Tue, 28 Sep 2010) New Revision: 7ee021b0a2925c32d12d61346d6f79d1787944bd Log: * chupatext/chupa_text.h (ChupaTextClass): fixed argument type of decomposed. Modified files: chupatext/chupa_text.h Modified: chupatext/chupa_text.h (+1 -1) =================================================================== --- chupatext/chupa_text.h 2010-09-28 06:29:03 +0000 (4a75362) +++ chupatext/chupa_text.h 2010-09-28 06:52:27 +0000 (8f0df36) @@ -61,7 +61,7 @@ struct ChupaTextClass GObjectClass parent_class; /* signals */ - void (*decomposed)(GObject *object, GInputStream *stream); + void (*decomposed)(GObject *object, ChupaTextInput *input); }; /** From null+ranguba at clear-code.com Tue Sep 28 03:02:42 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Tue, 28 Sep 2010 07:02:42 +0000 Subject: [groonga-commit:1372] ranguba/chupatext [master] * chupatext/chupa_text.h (ChupaTextClass::decomposed): add userdata. Message-ID: <20100928070323.EDC91170EB4@taiyaki.ru> Nobuyoshi Nakada 2010-09-28 07:02:42 +0000 (Tue, 28 Sep 2010) New Revision: 883b71981597b5d158722d86194476cd6c84997d Log: * chupatext/chupa_text.h (ChupaTextClass::decomposed): add userdata. Modified files: chupatext/chupa_text.h Modified: chupatext/chupa_text.h (+1 -1) =================================================================== --- chupatext/chupa_text.h 2010-09-28 06:52:27 +0000 (8f0df36) +++ chupatext/chupa_text.h 2010-09-28 07:02:42 +0000 (0e8645d) @@ -61,7 +61,7 @@ struct ChupaTextClass GObjectClass parent_class; /* signals */ - void (*decomposed)(GObject *object, ChupaTextInput *input); + void (*decomposed)(GObject *object, ChupaTextInput *input, gpointer userdata); }; /** From null+ranguba at clear-code.com Tue Sep 28 03:03:24 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Tue, 28 Sep 2010 07:03:24 +0000 Subject: [groonga-commit:1373] ranguba/chupatext [master] * chupatext/chupa_text_input.c: add new signal, "finished". Message-ID: <20100928070324.05B96170EC2@taiyaki.ru> Nobuyoshi Nakada 2010-09-28 07:03:24 +0000 (Tue, 28 Sep 2010) New Revision: 71e1a2464c64d59ee9b7f26209fbdcdfc5123221 Log: * chupatext/chupa_text_input.c: add new signal, "finished". Modified files: chupatext/chupa_text_input.c chupatext/chupa_text_input.h Modified: chupatext/chupa_text_input.c (+30 -0) =================================================================== --- chupatext/chupa_text_input.c 2010-09-28 07:02:42 +0000 (f7f5d35) +++ chupatext/chupa_text_input.c 2010-09-28 07:03:24 +0000 (5f9c8cb) @@ -51,6 +51,15 @@ enum { PROP_DUMMY }; +const char chupa_text_signal_finished[] = "finished"; + +enum { + FINISHED, + LAST_SIGNAL +}; + +static gint gsignals[LAST_SIGNAL] = {0}; + enum { peek_buffer_size = 1024 }; @@ -225,6 +234,15 @@ chupa_text_input_class_init(ChupaTextInputClass *klass) g_object_class_install_property(gobject_class, PROP_METADATA, spec); g_type_class_add_private(gobject_class, sizeof(ChupaTextInputPrivate)); + + gsignals[FINISHED] = + g_signal_new(chupa_text_signal_finished, + G_TYPE_FROM_CLASS(klass), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET(ChupaTextInputClass, finished), + NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); } ChupaTextInput * @@ -335,3 +353,15 @@ chupa_text_input_set_charset(ChupaTextInput *input, const char *charset) ChupaMetadata *meta = chupa_text_input_get_metadata(input); chupa_metadata_add_value(meta, meta_charset, charset); } + +void +chupa_text_input_finished(ChupaTextInput *input) +{ + g_signal_emit_by_name(input, chupa_text_signal_finished); +} + +guint +chupa_text_input_connect_finished(ChupaTextInput *input, ChupaTextInputCallback func, gpointer arg) +{ + return g_signal_connect(input, chupa_text_signal_finished, (GCallback)func, arg); +} Modified: chupatext/chupa_text_input.h (+10 -0) =================================================================== --- chupatext/chupa_text_input.h 2010-09-28 07:02:42 +0000 (1b5b41f) +++ chupatext/chupa_text_input.h 2010-09-28 07:03:24 +0000 (75e5316) @@ -42,6 +42,9 @@ G_BEGIN_DECLS #define CHUPA_TEXT_INPUT_GET_CLASS(obj) \ G_TYPE_INSTANCE_GET_CLASS(obj, CHUPA_TYPE_TEXT_INPUT, ChupaTextInputClass) +#define CHUPA_TEXT_SIGNAL_FINISHED chupa_text_signal_finished +extern const char chupa_text_signal_finished[]; + typedef struct _ChupaTextInput ChupaTextInput; typedef struct _ChupaTextInputClass ChupaTextInputClass; @@ -53,8 +56,13 @@ struct _ChupaTextInput struct _ChupaTextInputClass { GObjectClass parent_class; + + /* signals */ + void (*finished)(GObject *object, gpointer userdata); }; +typedef void (*ChupaTextInputCallback)(ChupaTextInput *, gpointer); + GType chupa_text_input_get_type(void) G_GNUC_CONST; ChupaTextInput *chupa_text_input_new(ChupaMetadata *metadata, GsfInput *inpt); ChupaTextInput *chupa_text_input_new_from_stream(ChupaMetadata *metadata, GInputStream *stream, const char *path); @@ -67,6 +75,8 @@ const gchar *chupa_text_input_get_charset(ChupaTextInput *input); void chupa_text_input_set_charset(ChupaTextInput *input, const char *charset); GsfInput *chupa_text_input_get_base_input(ChupaTextInput *input); GInputStream *chupa_text_input_get_stream(ChupaTextInput *input); +void chupa_text_input_finished(ChupaTextInput *input); +guint chupa_text_input_connect_finished(ChupaTextInput *input, ChupaTextInputCallback func, gpointer arg); G_END_DECLS From null+ranguba at clear-code.com Tue Sep 28 03:56:09 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Tue, 28 Sep 2010 07:56:09 +0000 Subject: [groonga-commit:1374] ranguba/chupatext [master] * chupatext/chupa_text.h: no userdata argument. * chupatext/chupa_text_input.h: ditto. Message-ID: <20100928075603.C9C61170EB4@taiyaki.ru> Nobuyoshi Nakada 2010-09-28 07:56:09 +0000 (Tue, 28 Sep 2010) New Revision: d40d27c84103928ab01b71117ec7bb12d750e69a Log: * chupatext/chupa_text.h: no userdata argument. * chupatext/chupa_text_input.h: ditto. Modified files: chupatext/chupa_text.h chupatext/chupa_text_input.h Modified: chupatext/chupa_text.h (+1 -1) =================================================================== --- chupatext/chupa_text.h 2010-09-28 07:03:24 +0000 (0e8645d) +++ chupatext/chupa_text.h 2010-09-28 07:56:09 +0000 (8f0df36) @@ -61,7 +61,7 @@ struct ChupaTextClass GObjectClass parent_class; /* signals */ - void (*decomposed)(GObject *object, ChupaTextInput *input, gpointer userdata); + void (*decomposed)(GObject *object, ChupaTextInput *input); }; /** Modified: chupatext/chupa_text_input.h (+1 -1) =================================================================== --- chupatext/chupa_text_input.h 2010-09-28 07:03:24 +0000 (75e5316) +++ chupatext/chupa_text_input.h 2010-09-28 07:56:09 +0000 (06f77d2) @@ -58,7 +58,7 @@ struct _ChupaTextInputClass GObjectClass parent_class; /* signals */ - void (*finished)(GObject *object, gpointer userdata); + void (*finished)(GObject *object); }; typedef void (*ChupaTextInputCallback)(ChupaTextInput *, gpointer); From null+ranguba at clear-code.com Tue Sep 28 03:59:22 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Tue, 28 Sep 2010 07:59:22 +0000 Subject: [groonga-commit:1375] ranguba/chupatext [master] * chupatext/chupa_text.c (chupa_text_connect_decomposed): removed. * chupatext/chupa_text_input.c (chupa_text_input_connect_finished): ditto. Message-ID: <20100928080130.6D6C0170EB4@taiyaki.ru> Nobuyoshi Nakada 2010-09-28 07:59:22 +0000 (Tue, 28 Sep 2010) New Revision: 2057af587fe3d4fb1ced113e109a1a36175689fe Log: * chupatext/chupa_text.c (chupa_text_connect_decomposed): removed. * chupatext/chupa_text_input.c (chupa_text_input_connect_finished): ditto. Modified files: chupatext/chupa.c chupatext/chupa_text.c chupatext/chupa_text.h chupatext/chupa_text_input.c chupatext/chupa_text_input.h Modified: chupatext/chupa.c (+2 -1) =================================================================== --- chupatext/chupa.c 2010-09-28 07:56:09 +0000 (7ea229a) +++ chupatext/chupa.c 2010-09-28 07:59:22 +0000 (92e88f6) @@ -78,7 +78,8 @@ main(int argc, char **argv) chupa_init(&chupar); chupar = chupa_text_new(); - chupa_text_connect_decomposed(chupar, output_to_FILE, stdout); + g_signal_connect(chupar, chupa_text_signal_decomposed, + (GCallback)output_to_FILE, stdout); for (i = 1; i < argc; ++i) { GFile *file = g_file_new_for_commandline_arg(argv[i]); ChupaTextInput *input = chupa_text_input_new_from_file(NULL, file, &err); Modified: chupatext/chupa_text.c (+1 -18) =================================================================== --- chupatext/chupa_text.c 2010-09-28 07:56:09 +0000 (395d259) +++ chupatext/chupa_text.c 2010-09-28 07:59:22 +0000 (108a6d7) @@ -118,23 +118,6 @@ chupa_text_decomposed(ChupaText *chupar, ChupaTextInput *input) } /** - * chupa_text_connect_decomposed: - * - * @chupar: the #ChupaText instance to be connected. - * @func: the callback function to be called with extracted text - * input. - * @arg: arbitrary user data. - * - * Connect @func to @chupar, so that @func will be called when any - * text portion is found. - */ -guint -chupa_text_connect_decomposed(ChupaText *chupar, ChupaTextCallback func, gpointer arg) -{ - return g_signal_connect(chupar, chupa_text_signal_decomposed, (GCallback)func, arg); -} - -/** * chupa_text_feed: * * @chupar: the #ChupaText instance. @@ -193,7 +176,7 @@ void chupa_text_decompose(ChupaText *chupar, ChupaTextInput *input, ChupaTextCallback func, gpointer arg, GError **error) { - chupa_text_connect_decomposed(chupar, func, arg); + g_signal_connect(chupar, chupa_text_signal_decomposed, (GCallback)func, arg); chupa_text_feed(chupar, input, error); } Modified: chupatext/chupa_text.h (+0 -1) =================================================================== --- chupatext/chupa_text.h 2010-09-28 07:56:09 +0000 (8f0df36) +++ chupatext/chupa_text.h 2010-09-28 07:59:22 +0000 (d050448) @@ -75,7 +75,6 @@ GType chupa_text_get_type(void) G_GNUC_CONST; ChupaText *chupa_text_new(void); gboolean chupa_text_feed(ChupaText *chupar, ChupaTextInput *input, GError **err); void chupa_text_decomposed(ChupaText *chupar, ChupaTextInput *input); -guint chupa_text_connect_decomposed(ChupaText *chupar, ChupaTextCallback func, gpointer arg); void chupa_text_decompose(ChupaText *chupar, ChupaTextInput *text_input, ChupaTextCallback func, gpointer arg, GError **error); char *chupa_text_decompose_all(ChupaText *chupar, ChupaTextInput *text_input, GError **error); Modified: chupatext/chupa_text_input.c (+0 -6) =================================================================== --- chupatext/chupa_text_input.c 2010-09-28 07:56:09 +0000 (5f9c8cb) +++ chupatext/chupa_text_input.c 2010-09-28 07:59:22 +0000 (f338f62) @@ -359,9 +359,3 @@ chupa_text_input_finished(ChupaTextInput *input) { g_signal_emit_by_name(input, chupa_text_signal_finished); } - -guint -chupa_text_input_connect_finished(ChupaTextInput *input, ChupaTextInputCallback func, gpointer arg) -{ - return g_signal_connect(input, chupa_text_signal_finished, (GCallback)func, arg); -} Modified: chupatext/chupa_text_input.h (+0 -1) =================================================================== --- chupatext/chupa_text_input.h 2010-09-28 07:56:09 +0000 (06f77d2) +++ chupatext/chupa_text_input.h 2010-09-28 07:59:22 +0000 (198f00e) @@ -76,7 +76,6 @@ void chupa_text_input_set_charset(ChupaTextInput *input, const char *charset); GsfInput *chupa_text_input_get_base_input(ChupaTextInput *input); GInputStream *chupa_text_input_get_stream(ChupaTextInput *input); void chupa_text_input_finished(ChupaTextInput *input); -guint chupa_text_input_connect_finished(ChupaTextInput *input, ChupaTextInputCallback func, gpointer arg); G_END_DECLS From null+ranguba at clear-code.com Tue Sep 28 04:45:04 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Tue, 28 Sep 2010 08:45:04 +0000 Subject: [groonga-commit:1376] ranguba/chupatext [master] * module/ruby.c: added. Message-ID: <20100928084512.952CF170EB4@taiyaki.ru> Nobuyoshi Nakada 2010-09-28 08:45:04 +0000 (Tue, 28 Sep 2010) New Revision: 4b971b66f3137f761a201a711f296be85bd115e5 Log: * module/ruby.c: added. Added files: module/ruby.c module/ruby_factory.c Modified files: chupatext/chupa_text.h configure.ac module/Makefile.am Modified: chupatext/chupa_text.h (+1 -0) =================================================================== --- chupatext/chupa_text.h 2010-09-28 07:59:22 +0000 (d050448) +++ chupatext/chupa_text.h 2010-09-28 08:45:04 +0000 (5fe59b4) @@ -84,6 +84,7 @@ typedef enum { CHUPA_TEXT_ERROR_UNKNOWN_CONTENT, CHUPA_TEXT_ERROR_UNKNOWN_MIMETYPE, CHUPA_TEXT_ERROR_INVALID_INPUT, + CHUPA_TEXT_ERROR_UNKNOWN, CHUPA_TEXT_ERROR_MAX_ } ChupaTextError; Modified: configure.ac (+42 -0) =================================================================== --- configure.ac 2010-09-28 07:59:22 +0000 (3eccba1) +++ configure.ac 2010-09-28 08:45:04 +0000 (db89623) @@ -92,6 +92,48 @@ AM_CONDITIONAL([HAVE_WV], [test "$have_wv" = "yes"]) PKG_CHECK_MODULES(GOFFICE, libgoffice-0.8, [have_goffice=yes], [:]) AM_CONDITIONAL([HAVE_GOFFICE], [test "$have_goffice" = "yes"]) +ruby_available="no" +AC_ARG_WITH([ruby], + AS_HELP_STRING([--with-ruby=PATH], + [Ruby interpreter path (default: auto-detect)]), + [RUBY="$withval"]) + +AS_CASE("$RUBY", + [no], [:], + [""], + [AC_PATH_PROG(RUBY, ruby, none) + test "$RUBY" = "none" || ruby_available="yes" + ]) + +RBCONFIG="$RUBY -rrbconfig"dnl +AC_DEFUN([RUBY_CONFIG],dnl +[dnl +AS_VAR_PUSHDEF([rbcv],[rb_]$1)dnl +if test $ruby_available = yes; then + AC_MSG_CHECKING([for RbConfig[[$1]]]) + rbcv=`[$RBCONFIG -e 'puts RbConfig::CONFIG["$1"]||abort']` || ruby_available=no + AC_MSG_RESULT($rbcv) +fi dnl +AS_VAR_POPDEF([rbcv])dnl +]) + +RUBY_CONFIG(rubyhdrdir) +RUBY_CONFIG(arch) +RUBY_CONFIG(CFLAGS) +RUBY_CONFIG(CPPFLAGS) +RUBY_CONFIG(LDFLAGS) +RUBY_CONFIG(DLDFLAGS) +RUBY_CONFIG(LIBS) +AC_SUBST(RUBY_CFLAGS, "$rb_CFLAGS") +AC_SUBST(RUBY_CPPFLAGS, "$rb_CPPFLAGS -I$rb_rubyhdrdir/$rb_arch -I$rb_rubyhdrdir") +AC_SUBST(RUBY_LDFLAGS, "$rb_LDFLAGS $rb_DLDFLAGS") +AC_SUBST(RUBY_LIBS, "$rb_LIBS") +if test "$ruby_available" = "yes"; then + AC_SUBST(rubyarch, $rb_arch) +fi + +AM_CONDITIONAL([HAVE_RUBY], [test "$ruby_available" = "yes"]) + dnl ************************************************************** dnl Check for Cutter dnl ************************************************************** Modified: module/Makefile.am (+14 -0) =================================================================== --- module/Makefile.am 2010-09-28 07:59:22 +0000 (81e2dbe) +++ module/Makefile.am 2010-09-28 08:45:04 +0000 (783ae38) @@ -27,6 +27,10 @@ factory_LTLIBRARIES += excel_factory.la endif decomposer_LTLIBRARIES += powerpoint.la factory_LTLIBRARIES += powerpoint_factory.la +if HAVE_RUBY +decomposer_LTLIBRARIES += ruby.la +factory_LTLIBRARIES += ruby_factory.la +endif text_la_SOURCES = text.c text_la_CPPFLAGS = $(GLIB_CFLAGS) $(GSF_CFLAGS) @@ -83,3 +87,13 @@ powerpoint_la_LIBADD = $(GIO_UNIX_LIBS) $(GSF_LIBS) powerpoint_factory_la_SOURCES = powerpoint_factory.c powerpoint_factory_la_CPPFLAGS = $(GLIB_CFLAGS) $(GSF_CFLAGS) powerpoint_factory_la_LIBADD = $(GLIB_LIBS) + +ruby_la_SOURCES = ruby.c +ruby_la_CFLAGS = $(RUBY_CFLAGS) +ruby_la_CPPFLAGS = -DCHUPA_RUBY_DIR=\"$(rubydir)\" -DRUBY_ARCH=\"$(rubyarch)\" \ + $(RUBY_CPPFLAGS) $(GSF_CFLAGS) +ruby_la_LIBADD = $(RUBY_LDFLAGS) $(RUBY_LIBS) $(GSF_LIBS) + +ruby_factory_la_SOURCES = ruby_factory.c +ruby_factory_la_CPPFLAGS = $(GLIB_CFLAGS) $(GSF_CFLAGS) +ruby_factory_la_LIBADD = $(GLIB_LIBS) Added: module/ruby.c (+298 -0) 100644 =================================================================== --- /dev/null +++ module/ruby.c 2010-09-28 08:45:04 +0000 (5ba0f20) @@ -0,0 +1,298 @@ +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Copyright (C) 2010 Nobuyoshi Nakada + */ + +#include +#include +#include +#include +#include + +#define CHUPA_TYPE_RUBY_DECOMPOSER chupa_type_ruby_decomposer +#define CHUPA_RUBY_DECOMPOSER(obj) \ + G_TYPE_CHECK_INSTANCE_CAST(obj, CHUPA_TYPE_RUBY_DECOMPOSER, ChupaRubyDecomposer) +#define CHUPA_RUBY_DECOMPOSER_CLASS(klass) \ + G_TYPE_CHECK_CLASS_CAST(klass, CHUPA_TYPE_RUBY_DECOMPOSER, ChupaRubyDecomposerClass) +#define CHUPA_IS_RUBY_DECOMPOSER(obj) \ + G_TYPE_CHECK_INSTANCE_TYPE(obj, CHUPA_TYPE_RUBY_DECOMPOSER) +#define CHUPA_IS_RUBY_DECOMPOSER_CLASS(klass) \ + G_TYPE_CHECK_CLASS_TYPE(klass, CHUPA_TYPE_RUBY_DECOMPOSER) +#define CHUPA_RUBY_DECOMPOSER_GET_CLASS(obj) \ + G_TYPE_INSTANCE_GET_CLASS(obj, CHUPA_TYPE_RUBY_DECOMPOSER, ChupaRubyDecomposerClass) + +typedef struct _ChupaRubyDecomposer ChupaRubyDecomposer; +typedef struct _ChupaRubyDecomposerClass ChupaRubyDecomposerClass; + +struct _ChupaRubyDecomposer +{ + ChupaDecomposer object; +}; + +struct _ChupaRubyDecomposerClass +{ + ChupaDecomposerClass parent_class; +}; + +static GType chupa_type_ruby_decomposer = 0; + +/* ruby class */ +typedef struct { + ChupaText *chupar; + ChupaTextInput *input; + ChupaMemoryInputStream *stream; + GsfOutputMemory *sink; +} chupa_ruby_t; + +static void +chupa_ruby_dispose(void *ptr) +{ + if (ptr) { + chupa_ruby_t *ch = ptr; + gpointer *obj; +#define DISPOSE(member) \ + (!(obj = (gpointer)ch->member) ? (void)0 : \ + (void)(ch->member = 0, g_object_unref(obj))) + DISPOSE(chupar); + DISPOSE(input); + DISPOSE(stream); + DISPOSE(sink); +#undef DISPOSE + } +} + +static size_t +chupa_ruby_memsize(const void *ptr) +{ + return ptr ? sizeof(chupa_ruby_t) : 0; +} + +static const rb_data_type_t chupa_ruby_type = { + "chupa", +#ifdef HAVE_RB_DATA_TYPE_T_FUNCTION + { +#endif + 0, chupa_ruby_dispose, chupa_ruby_memsize, +#ifdef HAVE_RB_DATA_TYPE_T_FUNCTION + }, +#endif +}; + +static VALUE cChupa; +static void init_chupa_ruby(void); + +static VALUE +chupa_ruby_decomposed(VALUE self, VALUE data) +{ + chupa_ruby_t *ptr = rb_check_typeddata(self, &chupa_ruby_type); + + StringValue(data); + gsf_output_write(GSF_OUTPUT(ptr->sink), RSTRING_LEN(data), (const guchar *)RSTRING_PTR(data)); + return data; +} + +typedef struct { + ChupaText *chupar; + ChupaTextInput *text_input; +} create_arguments; + +static VALUE +chupa_ruby_s_create(VALUE arg) +{ + create_arguments *argp = (create_arguments *)arg; + VALUE klass = cChupa; + ChupaText *chupar = argp->chupar; + ChupaTextInput *text_input = argp->text_input; + chupa_ruby_t *ptr; + const char *filename = chupa_text_input_get_filename(text_input); + VALUE obj; + + init_chupa_ruby(); + obj = TypedData_Make_Struct(klass, chupa_ruby_t, &chupa_ruby_type, ptr); + ptr->chupar = chupar; + ptr->sink = GSF_OUTPUT_MEMORY(gsf_output_memory_new()); + ptr->stream = CHUPA_MEMORY_INPUT_STREAM(chupa_memory_input_stream_new(ptr->sink)); + ptr->input = chupa_text_input_new_from_stream(NULL, G_INPUT_STREAM(ptr->stream), filename); + return obj; +} + +typedef struct { + VALUE receiver; + ID name; + int argc; + VALUE *argv; +} funcall_arguments; + +static VALUE +invoke_rb_funcall2(VALUE data) +{ + funcall_arguments *arguments = (funcall_arguments *)data; + + return rb_funcall2(arguments->receiver, arguments->name, + arguments->argc, arguments->argv); +} + +typedef struct { + GError **g_error; + VALUE error; +} make_error_arguments; + +static VALUE +make_error_message(VALUE arg) +{ + make_error_arguments *ptr = (make_error_arguments *)arg; + GError **g_error = ptr->g_error; + VALUE error = ptr->error; + GString *error_message; + VALUE message, class_name, backtrace; + long i; + + error_message = g_string_new(NULL); + message = rb_funcall(error, rb_intern("message"), 0); + class_name = rb_funcall(CLASS_OF(error), rb_intern("to_s"), 0); + g_string_append_printf(error_message, "%s (%s)\n", + StringValueCStr(message), + StringValueCStr(class_name)); + backtrace = rb_funcall(error, rb_intern("backtrace"), 0); + for (i = 0; i < RARRAY_LEN(backtrace); i++) { + VALUE line = RARRAY_PTR(backtrace)[i]; + g_string_append_printf(error_message, "%s\n", StringValueCStr(line)); + } + g_set_error(g_error, + CHUPA_TEXT_ERROR, CHUPA_TEXT_ERROR_UNKNOWN, + "unknown error is occurred: <%s>", error_message->str); + g_string_free(error_message, TRUE); + + return Qnil; +} + +static gboolean +chupa_ruby_feed(chupa_ruby_t *self, GError **g_error) +{ + return chupa_text_feed(self->chupar, self->input, g_error); +} + +static void +init_chupa_ruby(void) +{ + extern void *chupa_stack_base; + const VALUE *outer_klass = &rb_cObject; + + if (!outer_klass || !*outer_klass) { + int argc; + const char *args[6]; + char **argv; + gchar *rubydir, *rubyarchdir; + + argv = (char **)args; + argc = 0; + args[argc++] = "chupa"; + args[argc] = NULL; + ruby_sysinit(&argc, &argv); + ruby_init_stack(chupa_stack_base); + ruby_init(); + rubydir = g_build_path(chupa_module_dir(), "ruby", NULL); + rubyarchdir = g_build_path(rubydir, RUBY_ARCH, NULL); + ruby_incpush(rubyarchdir); + ruby_incpush(rubydir); + g_free(rubyarchdir); + g_free(rubydir); + argc = 1; + args[argc++] = "-e;"; + args[argc] = NULL; + (void)ruby_process_options(argc, argv); /* ignore the insns which does nothing */ + } + if (!rb_const_defined(*outer_klass, rb_intern("Chupa"))) { + cChupa = rb_define_class_under(*outer_klass, "Chupa", rb_cObject); + rb_define_method(cChupa, "decomposed", chupa_ruby_decomposed, 1); + } +} + +static gboolean +chupa_ruby_decomposer_feed(ChupaDecomposer *dec, ChupaText *chupar, + ChupaTextInput *input, GError **g_error) +{ + VALUE receiver; + create_arguments create_args; + funcall_arguments call_args; + VALUE result, error; + int state = 0; + ID id_decomposed; + CONST_ID(id_decomposed, "decomposed"); + + gsf_input_seek(chupa_text_input_get_base_input(input), 0, G_SEEK_SET); + + create_args.chupar = chupar; + create_args.text_input = input; + receiver = rb_protect(chupa_ruby_s_create, (VALUE)&create_args, &state); + if (!NIL_P(receiver) && chupa_ruby_feed(DATA_PTR(receiver), g_error)) { + call_args.receiver = receiver; + call_args.name = id_decomposed; + call_args.argc = 0; + call_args.argv = 0; + result = rb_protect(invoke_rb_funcall2, (VALUE)&call_args, &state); + } + + if (state && !NIL_P(error = rb_errinfo())) { + make_error_arguments error_args; + error_args.g_error = g_error; + error_args.error = error; + rb_protect(make_error_message, (VALUE)&error_args, &state); + } + + return RTEST(result); +} + +static void +chupa_ruby_decomposer_class_init(ChupaRubyDecomposerClass *klass) +{ + ChupaDecomposerClass *super = CHUPA_DECOMPOSER_CLASS(klass); + super->feed = chupa_ruby_decomposer_feed; +} + +static void +register_type(GTypeModule *type_module) +{ + static const GTypeInfo info = { + sizeof(ChupaRubyDecomposerClass), + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) chupa_ruby_decomposer_class_init, + NULL, /* class_finalize */ + NULL, /* class_data */ + sizeof(ChupaRubyDecomposer), + 0, + (GInstanceInitFunc) NULL, + }; + + chupa_type_ruby_decomposer = + g_type_module_register_type(type_module, + CHUPA_TYPE_DECOMPOSER, + "ChupaRubyDecomposer", + &info, 0); +} + +G_MODULE_EXPORT GList * +CHUPA_MODULE_IMPL_INIT(GTypeModule *type_module) +{ + GList *registered_types = NULL; + register_type(type_module); + + registered_types = + g_list_prepend(registered_types, + (gchar *)g_type_name(chupa_type_ruby_decomposer)); + + return registered_types; +} + +G_MODULE_EXPORT void +CHUPA_MODULE_IMPL_EXIT(void) +{ +} + +G_MODULE_EXPORT GObject * +CHUPA_MODULE_IMPL_INSTANTIATE(const gchar *first_property, va_list var_args) +{ + return g_object_new_valist(CHUPA_TYPE_RUBY_DECOMPOSER, + first_property, var_args); +} Added: module/ruby_factory.c (+159 -0) 100644 =================================================================== --- /dev/null +++ module/ruby_factory.c 2010-09-28 08:45:04 +0000 (7f81747) @@ -0,0 +1,159 @@ +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Copyright (C) 2010 Nobuyoshi Nakada + * + * 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 3 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 program. If not, see . + * + */ + +#ifdef HAVE_CONFIG_H +# include +#endif /* HAVE_CONFIG_H */ + +#include +#include +#include +/* #include */ +#include + +#include +#include +#include + +#define CHUPA_TYPE_RUBY_FACTORY chupa_type_ruby_factory +#define CHUPA_RUBY_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CHUPA_TYPE_RUBY_FACTORY, ChupaRUBYFactory)) +#define CHUPA_RUBY_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CHUPA_TYPE_RUBY_FACTORY, ChupaRUBYFactoryClass)) +#define CHUPA_IS_RUBY_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CHUPA_TYPE_RUBY_FACTORY)) +#define CHUPA_IS_RUBY_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CHUPA_TYPE_RUBY_FACTORY)) +#define CHUPA_RUBY_FACTORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), CHUPA_TYPE_RUBY_FACTORY, ChupaRUBYFactoryClass)) + +typedef struct _ChupaRUBYFactory ChupaRUBYFactory; +typedef struct _ChupaRUBYFactoryClass ChupaRUBYFactoryClass; + +struct _ChupaRUBYFactory +{ + ChupaModuleFactory object; +}; + +struct _ChupaRUBYFactoryClass +{ + ChupaModuleFactoryClass parent_class; +}; + +static GType chupa_type_ruby_factory = 0; +static ChupaModuleFactoryClass *parent_class; + +static GList *get_mime_types (ChupaModuleFactory *factory); +static GObject *create (ChupaModuleFactory *factory); + +static void +class_init (ChupaModuleFactoryClass *klass) +{ + GObjectClass *gobject_class; + ChupaModuleFactoryClass *factory_class; + + parent_class = g_type_class_peek_parent(klass); + + gobject_class = G_OBJECT_CLASS(klass); + factory_class = CHUPA_MODULE_FACTORY_CLASS(klass); + + factory_class->get_mime_types = get_mime_types; + factory_class->create = create; +} + +static void +init (ChupaRUBYFactory *factory) +{ +} + +static void +register_type (GTypeModule *type_module) +{ + static const GTypeInfo info = + { + sizeof (ChupaRUBYFactoryClass), + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) class_init, + NULL, /* class_finalize */ + NULL, /* class_data */ + sizeof(ChupaRUBYFactory), + 0, + (GInstanceInitFunc) init, + }; + + chupa_type_ruby_factory = + g_type_module_register_type(type_module, + CHUPA_TYPE_MODULE_FACTORY, + "ChupaRUBYFactory", + &info, 0); +} + +G_MODULE_EXPORT GList * +CHUPA_MODULE_IMPL_INIT (GTypeModule *type_module) +{ + GList *registered_types = NULL; + + register_type(type_module); + if (chupa_type_ruby_factory) { + registered_types = + g_list_prepend(registered_types, + (gchar *)g_type_name(chupa_type_ruby_factory)); + } + + return registered_types; +} + +G_MODULE_EXPORT void +CHUPA_MODULE_IMPL_EXIT (void) +{ +} + +G_MODULE_EXPORT GObject * +CHUPA_MODULE_IMPL_INSTANTIATE (const gchar *first_property, va_list var_args) +{ + return g_object_new_valist(CHUPA_TYPE_RUBY_FACTORY, first_property, var_args); +} + +static GList * +get_mime_types (ChupaModuleFactory *factory) +{ + GList *mime_types = NULL; + + mime_types = g_list_prepend(mime_types, g_strdup("text/ruby")); + + return mime_types; +} + +GObject * +create (ChupaModuleFactory *factory) +{ + static int n_instances = 0; + GObject *decomposer; + + decomposer = G_OBJECT(chupa_decomposer_new("ruby", NULL)); + n_instances++; + if (n_instances == 1) { + /* FIXME: This causes memory leak but we need to + * keep at least 1 decomposer instance to avoid + * duplicated non-module GType + * (e.g. PopplerDocument) registration. */ + g_object_ref(decomposer); + } + return decomposer; +} + +/* +vi:ts=4:nowrap:ai:expandtab:sw=4 +*/ From null+ranguba at clear-code.com Tue Sep 28 05:02:29 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Tue, 28 Sep 2010 09:02:29 +0000 Subject: [groonga-commit:1377] ranguba/chupatext [master] * chupatext/chupa_restrict_input_stream.c: removed. Message-ID: <20100928090225.2C0E0170EB4@taiyaki.ru> Nobuyoshi Nakada 2010-09-28 09:02:29 +0000 (Tue, 28 Sep 2010) New Revision: 225ad6f503d34d2e2142f0bf405ca49d78ac8549 Log: * chupatext/chupa_restrict_input_stream.c: removed. Removed files: chupatext/chupa_restrict_input_stream.c chupatext/chupa_restrict_input_stream.h Modified files: chupatext/Makefile.am Modified: chupatext/Makefile.am (+0 -2) =================================================================== --- chupatext/Makefile.am 2010-09-28 08:45:04 +0000 (665a94d) +++ chupatext/Makefile.am 2010-09-28 09:02:29 +0000 (88a419a) @@ -24,7 +24,6 @@ libchupatext_la_SOURCES = \ chupa_decomposer.c \ archive_decomposer.c \ external_decomposer.c \ - chupa_restrict_input_stream.c \ chupa_utils.c \ version.c \ $(EMPTY) @@ -50,7 +49,6 @@ chupatext_include_HEADERS = \ chupa_module_impl.h \ chupa_dispatcher.h \ chupa_private.h \ - chupa_restrict_input_stream.h \ chupa_text.h \ chupa_text_input.h \ chupa_text_input_stream.h \ Deleted: chupatext/chupa_restrict_input_stream.c (+0 -181) 100644 =================================================================== --- chupatext/chupa_restrict_input_stream.c 2010-09-28 08:45:04 +0000 (4ff358b) +++ /dev/null @@ -1,181 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * Copyright (C) 2010 Nobuyoshi Nakada - * - * 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.1 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., 51 Franklin Street, Fifth Floor, Boston, - * MA 02110-1301 USA - */ - -#include "chupatext/chupa_restrict_input_stream.h" - -G_DEFINE_TYPE(ChupaRestrictInputStream, chupa_restrict_input_stream, G_TYPE_FILTER_INPUT_STREAM) - -#define CHUPA_RESTRICT_INPUT_STREAM_GET_PRIVATE(obj) \ - (G_TYPE_INSTANCE_GET_PRIVATE((obj), \ - CHUPA_TYPE_RESTRICT_INPUT_STREAM, \ - ChupaRestrictInputStreamPrivate)) - -#define PARENT_CLASS chupa_restrict_input_stream_parent_class - -typedef struct _ChupaRestrictInputStreamPrivate ChupaRestrictInputStreamPrivate; - -struct _ChupaRestrictInputStreamPrivate -{ - goffset current, start, length; -}; - -enum { - PROP_0, - PROP_START, - PROP_LENGTH, - PROP_DUMMY -}; - -static void -chupa_restrict_input_stream_init(ChupaRestrictInputStream *stream) -{ - ChupaRestrictInputStreamPrivate *priv; - - priv = CHUPA_RESTRICT_INPUT_STREAM_GET_PRIVATE(stream); - priv->current = 0; - priv->start = 0; - priv->length = 0; -} - -static void -set_property(GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) -{ - ChupaRestrictInputStreamPrivate *priv; - goffset ofs; - - priv = CHUPA_RESTRICT_INPUT_STREAM_GET_PRIVATE(object); - switch (prop_id) { - case PROP_LENGTH: - ofs = g_value_get_int64(value); - if (ofs < 0) { - g_error("%s: negative length %"G_GOFFSET_FORMAT, G_STRLOC, ofs); - } - else { - priv->length = ofs; - } - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); - break; - } -} - -static void -get_property(GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - ChupaRestrictInputStreamPrivate *priv; - - priv = CHUPA_RESTRICT_INPUT_STREAM_GET_PRIVATE(object); - switch (prop_id) { - case PROP_LENGTH: - g_value_set_int64(value, priv->length); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); - break; - } -} - -static gssize -restrict_read(GInputStream *stream, void *buffer, gsize count, - GCancellable *cancellable, GError **error) -{ - ChupaRestrictInputStreamPrivate *priv = CHUPA_RESTRICT_INPUT_STREAM_GET_PRIVATE(stream); - gssize limit = priv->length - priv->current, result; - - if (count > limit) { - count = limit; - } - result = G_INPUT_STREAM_CLASS(PARENT_CLASS)->read_fn(stream, buffer, count, cancellable, error); - if (result > 0) { - priv->current += result; - } - - return result; -} - -static gssize -restrict_skip(GInputStream *stream, gsize count, - GCancellable *cancellable, GError **error) -{ - ChupaRestrictInputStreamPrivate *priv = CHUPA_RESTRICT_INPUT_STREAM_GET_PRIVATE(stream); - gssize limit = priv->length - priv->current, result; - - if (count > limit) { - count = limit; - } - result = G_INPUT_STREAM_CLASS(PARENT_CLASS)->skip(stream, count, cancellable, error); - if (result > 0) { - priv->current += result; - } - return result; -} - -static void -chupa_restrict_input_stream_class_init(ChupaRestrictInputStreamClass *klass) -{ - GObjectClass *gobject_class = G_OBJECT_CLASS(klass); - GInputStreamClass *input_class = G_INPUT_STREAM_CLASS(klass); - GParamSpec *spec; - - gobject_class->set_property = set_property; - gobject_class->get_property = get_property; - - input_class->read_fn = restrict_read; - input_class->skip = restrict_skip; - - spec = g_param_spec_int64("length", - "Length", - "Length of the input stream", - 0, G_MAXINT64, 0, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_STRINGS); - g_object_class_install_property(gobject_class, PROP_LENGTH, spec); - - g_type_class_add_private(gobject_class, sizeof(ChupaRestrictInputStreamPrivate)); -} - -GInputStream * -chupa_restrict_input_stream_new(GInputStream *input, goffset length) -{ - return g_object_new(CHUPA_TYPE_RESTRICT_INPUT_STREAM, - "base-stream", input, - "length", length, - NULL); -} - -gsize -chupa_restrict_input_stream_skip_to_end(GInputStream *stream) -{ - ChupaRestrictInputStreamPrivate *priv = CHUPA_RESTRICT_INPUT_STREAM_GET_PRIVATE(stream); - gssize rest = priv->length - priv->current, result; - - result = G_INPUT_STREAM_CLASS(PARENT_CLASS)->skip(stream, rest, NULL, NULL); - if (result > 0) { - priv->current += result; - } - return result; -} Deleted: chupatext/chupa_restrict_input_stream.h (+0 -62) 100644 =================================================================== --- chupatext/chupa_restrict_input_stream.h 2010-09-28 08:45:04 +0000 (bc591ef) +++ /dev/null @@ -1,62 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * Copyright (C) 2010 Nobuyoshi Nakada - * - * 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.1 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., 51 Franklin Street, Fifth Floor, Boston, - * MA 02110-1301 USA - */ - -#ifndef CHUPA_RESTRICT_INPUT_STREAM_H -#define CHUPA_RESTRICT_INPUT_STREAM_H - -#include -#include -#include - -G_BEGIN_DECLS - -#define CHUPA_TYPE_RESTRICT_INPUT_STREAM \ - chupa_restrict_input_stream_get_type() -#define CHUPA_RESTRICT_INPUT_STREAM(obj) \ - G_TYPE_CHECK_INSTANCE_CAST(obj, CHUPA_TYPE_RESTRICT_INPUT_STREAM, ChupaRestrictInputStream) -#define CHUPA_RESTRICT_INPUT_STREAM_CLASS(klass) \ - G_TYPE_CHECK_CLASS_CAST(klass, CHUPA_TYPE_RESTRICT_INPUT_STREAM, ChupaRestrictInputStreamClass) -#define CHUPA_IS_RESTRICT_INPUT_STREAM(obj) \ - G_TYPE_CHECK_INSTANCE_TYPE(obj, CHUPA_TYPE_RESTRICT_INPUT_STREAM) -#define CHUPA_IS_RESTRICT_INPUT_STREAM_CLASS(klass) \ - G_TYPE_CHECK_CLASS_TYPE(klass, CHUPA_TYPE_RESTRICT_INPUT_STREAM) -#define CHUPA_RESTRICT_INPUT_STREAM_GET_CLASS(obj) \ - G_TYPE_INSTANCE_GET_CLASS(obj, CHUPA_TYPE_RESTRICT_INPUT_STREAM, ChupaRestrictInputStreamClass) - -typedef struct _ChupaRestrictInputStream ChupaRestrictInputStream; -typedef struct _ChupaRestrictInputStreamClass ChupaRestrictInputStreamClass; - -struct _ChupaRestrictInputStream -{ - GFilterInputStream object; -}; - -struct _ChupaRestrictInputStreamClass -{ - GFilterInputStreamClass parent_class; -}; - -GType chupa_restrict_input_stream_get_type(void) G_GNUC_CONST; -GInputStream *chupa_restrict_input_stream_new(GInputStream *input, goffset length); -gsize chupa_restrict_input_stream_skip_to_end(GInputStream *input); - -G_END_DECLS - -#endif /* CHUPA_RESTRICT_INPUT_STREAM_H */ From null+ranguba at clear-code.com Wed Sep 15 04:08:40 2010 From: null+ranguba at clear-code.com (null+ranguba at clear-code.com) Date: Wed, 15 Sep 2010 08:08:40 +0000 Subject: [groonga-commit:1378] ranguba/rroonga [master] add ChupaText description. Message-ID: <20100928093630.069F6170EB4@taiyaki.ru> Kouhei Sutou 2010-09-15 08:08:40 +0000 (Wed, 15 Sep 2010) New Revision: 55457d0ef3e7a51d243818ee9da7cd072be0aad4 Log: add ChupaText description. Modified files: html/developer.html html/index.html Modified: html/developer.html (+4 -2) =================================================================== --- html/developer.html 2010-09-17 15:38:46 +0000 (b613872) +++ html/developer.html 2010-09-15 08:08:40 +0000 (dda8256) @@ -37,7 +37,7 @@

?????

- rroonga?ActiveGroonga?racknga???????GitHub??????? + rroonga?ActiveGroonga?racknga?ChupaText???????GitHub??????? git??????????????????????????????

@@ -47,10 +47,12 @@
% git clone git://github.com/ranguba/activegroonga.git
racknga
% git clone git://github.com/ranguba/racknga.git
+
chupatext
+
% git clone git://github.com/ranguba/chupatext.git

- rroonga?ActiveGroonga?racknga?????????????????????????? + rroonga?ActiveGroonga?racknga?ChupaText?????????????????????????? ????????????????????????????

Modified: html/index.html (+45 -5) =================================================================== --- html/index.html 2010-09-17 15:38:46 +0000 (f5db15a) +++ html/index.html 2010-09-15 08:08:40 +0000 (10719c2) @@ -31,13 +31,19 @@

??????????

- ??????????????????????????????????????groonga????Ruby???????????????????????????? - groonga????Ruby??????????????????????????? + ??????????????????????????????????????groonga??????????????????????????groonga????Ruby???????????????????????????????????????????????Web???????????????????????????????????

+

rroonga

- rroonga???????groonga???????????DB-API??????Ruby??????????DB-API????????QL-API??????????ActiveGroonga??????? + rroonga???????groonga???????????DB-API??????Ruby??????????rroonga??????Web???????????????????????ActiveGroonga??????????Web?????????????????????????racknga???????????????groonga????Ruby???????????????????????????

rroonga???????

@@ -122,13 +128,47 @@
  • racknga????????????
  • +

    ChupaText

    +

    + ChupaText??????????PDF?????????????????????????????????????????????????Web?????????????? +

    + +

    ChupaText???????

    +

    + ?????? +

    + +

    ChupaText???????

    +

    + TODO +

    +
    % sudo TODO
    + +

    ChupaText???????

    +

    + TODO +

    + + +

    ????????

    +

    + ?????????groonga??????????????????????????????????????????????????????????? +

    + +

    ????????

    +

    + ?????? +

    +

    ?????

    - rroonga?ActiveGroonga?racknga?????????????????? Free Software Foundation?????GNU Lesser General Public License 2.1??????????????????????????????????? + rroonga?ActiveGroonga?racknga?ChupaText?????????????????? Free Software Foundation?????GNU Lesser General Public License 2.1???????????????????????????????????

    - rroonga?ActiveGroonga?racknga????????????????????????????????????????????????????????????????????GNU Lesser General Public License 2.1????????? + rroonga?ActiveGroonga?racknga?ChupaText????????????????????????????????????????????????????????????????????GNU Lesser General Public License 2.1?????????