[profiler] Some profiler API improvements.
AM_CFLAGS = $(WERROR_CFLAGS)
-MONOTOUCH_SUBDIRS = $(libgc_dir) eglib/src mono
+MONOTOUCH_SUBDIRS = $(libgc_dir) mono
# Some tools might not build when cross-compiling
if CROSS_COMPILING
tools_dir = tools
endif
-SUBDIRS = po $(libgc_dir) eglib mono $(ikvm_native_dir) support data runtime scripts man samples $(tools_dir) msvc $(docs_dir) acceptance-tests llvm
+SUBDIRS = po $(libgc_dir) mono $(ikvm_native_dir) support data runtime scripts man samples $(tools_dir) msvc $(docs_dir) acceptance-tests llvm
# Keep in sync with SUBDIRS
-DIST_SUBDIRS = m4 po $(libgc_dir) eglib mono ikvm-native support data runtime scripts man samples tools msvc docs acceptance-tests llvm
+DIST_SUBDIRS = m4 po $(libgc_dir) mono ikvm-native support data runtime scripts man samples tools msvc docs acceptance-tests llvm
all: update_submodules
AC_SUBST([WERROR_CFLAGS])
AC_SUBST([SHARED_CFLAGS])
-GLIB_CFLAGS='-I$(top_srcdir)/eglib/src -I$(top_builddir)/eglib/src'
-GLIB_LIBS='-L$(top_builddir)/eglib/src -leglib -lm'
+GLIB_CFLAGS='-I$(top_srcdir)/mono/eglib -I$(top_builddir)/mono/eglib'
+GLIB_LIBS='$(top_builddir)/mono/eglib/libeglib.la -lm'
AC_SUBST(GLIB_CFLAGS)
AC_SUBST(GLIB_LIBS)
mono/benchmark/Makefile
mono/mini/Makefile
mono/profiler/Makefile
-eglib/Makefile
-eglib/src/Makefile
-eglib/src/eglib-config.h
+mono/eglib/Makefile
+mono/eglib/eglib-config.h
m4/Makefile
ikvm-native/Makefile
scripts/Makefile
+++ /dev/null
-/
-/depcomp
-/config.guess
-/config.sub
-/ltmain.sh
-/eglib-*.tar.gz
-/missing
-/install-sh
-/compile
-/Makefile
-/Makefile.in
-/stamp-h1
-/config.h.in
-/libtool
-/autom4te.cache
-/aclocal.m4
-/config.log
-/configure
-/config.h
-/config.status
-/INSTALL
-dolt*
+++ /dev/null
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to
-deal in the Software without restriction, including without limitation the
-rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-sell copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-IN THE SOFTWARE.
+++ /dev/null
-AM_CFLAGS = $(WERROR_CFLAGS)
-
-SUBDIRS = src
-
-EXTRA_DIST = README NEWS AUTHORS winconfig.h
+++ /dev/null
-Release notes for Mono are hosted on the web, please see:
-
- http://www.mono-project.com/docs/about-mono/releases/
+++ /dev/null
-
-The purpose of eglib is to be an X11-licensed subset of glib that can
-be used with Mono when the Mono runtime is explicitly relicensed under
-a different license by Novell.
-
-The implementation is done from the public documentation available here:
-
- http://developer.gnome.org/doc/API/2.0/glib/
-
-Currently this is only being built standalone, use:
-
- ./autogen.sh --prefix=/tmp/test
-
-Currently all the definitions go into a single file: glib.h, there are
-no separate files, please try to follow the convetions in the source code
-
-* Tests
-
- Please read the README in tests/
-
-* Features
-
- The source code is designed to allow for different operating
- system builds of the eglib code.
-
- Files in src that:
-
- * Have a plain name: are cross platform, and should work on
- every operating system.
-
- * That end in -unix.c: These files contain Unix specific code.
-
- * That end in -win32.c: These files contain Win32 specific code.
-
- * That end in -posix.c: Will work on both Windows and Unix,
- but should not be included for other operating systems.
-
-* Plans: short and long term.
-
- The short term plans for eglib is to allow Mono to optionally
- build with it instead of using glib, gmodule and gthread, but
- the default build will continue to be done against glib 2.0.
-
- In the long-term we are considering dropping glib as a
- dependency, considering that Mono requires a modern Unix
- system to run anyways (for its thread support) it would allow
- us to fix some of the glib API limitations we have to live
- with (explicit thread support for example), rework the API to
- use types from stdint.h and we would be able to drop three
- external shared libraries.
-
- This would reduce memory usage for the handful of routines
- that we use from glib, dynamic linker overhead for those and
- would allow us to tune the implementation to Mono's needs.
+++ /dev/null
-* Missing code
-
- * Process launching
- 3 g_shell_quote
- 1 g_shell_unquote
-
-----------------------------------------------------------------------
-
-* Should implement, for better performance:
-
-Macros:
- 6 G_UNLIKELY
- 4 G_LIKELY
-
-* Unimplemented, not supported currently:
-
- (none as yet.)
-
-* Dead Code
-
- The GMainLoop code was no longer in use in Mono.
-
-* Windows implementations needed
-
- Directory, File manipulation:
-
- g_dir_open, g_dir_close, g_dir_read_name
-
- We're missing a native windows implementation. The unix one is in place.
-
- * Information retrieval
- 1 g_win32_getlocale
-
+++ /dev/null
-/Makefile
-/Makefile.in
-/.libs
-/.deps
-/*.lo
-/*.la
-/*.o
-/semantic.cache
-/.project
-/.cproject
-/eglib-config.h
+++ /dev/null
-noinst_LTLIBRARIES = libeglib.la
-
-AM_CFLAGS = $(WERROR_CFLAGS)
-
-win_files = \
- eglib-config.hw \
- gdate-win32.c gdir-win32.c gfile-win32.c gmisc-win32.c \
- gmodule-win32.c gmodule-win32-internals.h gtimer-win32.c gunicode-win32.c
-
-unix_files = \
- gdate-unix.c gdir-unix.c gfile-unix.c gmisc-unix.c \
- gmodule-unix.c gtimer-unix.c
-
-if HOST_WIN32
-os_files = $(win_files)
-else
-os_files = $(unix_files)
-endif
-
-libeglib_la_SOURCES = \
- eglib-remap.h \
- sort.frag.h \
- glib.h \
- garray.c \
- gbytearray.c \
- gerror.c \
- ghashtable.c \
- giconv.c \
- gmem.c \
- gmodule.h \
- goutput.c \
- gqsort.c \
- gstr.c \
- gslist.c \
- gstring.c \
- gptrarray.c \
- glist.c \
- gqueue.c \
- gpath.c \
- gshell.c \
- gspawn.c \
- gfile.c \
- gfile-posix.c \
- gpattern.c \
- gmarkup.c \
- gutf8.c \
- gunicode.c \
- unicode-data.h \
- $(os_files)
-
-libeglib_la_CFLAGS = -g -Wall -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE
-
-AM_CPPFLAGS = -I$(srcdir)
-
-if HOST_WIN32
-libeglib_la_LIBADD = -lm $(LIBICONV) -lpsapi
-else
-if PLATFORM_ANDROID
-libeglib_la_LIBADD = -llog
-endif
-endif
-
-MAINTAINERCLEANFILES = Makefile.in
-
-EXTRA_DIST = eglib-config.h.in $(win_files) $(unix_files)
+++ /dev/null
-#ifndef __EGLIB_CONFIG_H
-#define __EGLIB_CONFIG_H
-
-/*
- * System-dependent settings
- */
-#define G_GNUC_PRETTY_FUNCTION @GNUC_PRETTY@
-#define G_GNUC_UNUSED @GNUC_UNUSED@
-#define G_BYTE_ORDER @ORDER@
-#define G_GNUC_NORETURN @GNUC_NORETURN@
-#define G_SEARCHPATH_SEPARATOR_S "@SEARCHSEP@"
-#define G_SEARCHPATH_SEPARATOR '@SEARCHSEP@'
-#define G_DIR_SEPARATOR '@PATHSEP@'
-#define G_DIR_SEPARATOR_S "@PATHSEP@"
-#define G_BREAKPOINT() @BREAKPOINT@
-#define G_OS_@OS@
-#define GPOINTER_TO_INT(ptr) @GPOINTER_TO_INT@
-#define GPOINTER_TO_UINT(ptr) @GPOINTER_TO_UINT@
-#define GINT_TO_POINTER(v) @GINT_TO_POINTER@
-#define GUINT_TO_POINTER(v) @GUINT_TO_POINTER@
-
-#if @HAVE_ALLOCA_H@ == 1
-#define G_HAVE_ALLOCA_H
-#endif
-
-typedef unsigned @GSIZE@ gsize;
-typedef signed @GSIZE@ gssize;
-
-#define G_GSIZE_FORMAT @GSIZE_FORMAT@
-
-#if @G_HAVE_ISO_VARARGS@ == 1
-#define G_HAVE_ISO_VARARGS
-#endif
-
-#if defined (HOST_WATCHOS)
-#undef G_BREAKPOINT
-#define G_BREAKPOINT()
-#endif
-
-typedef @PIDTYPE@ GPid;
-
-#endif
+++ /dev/null
-#ifndef __EGLIB_CONFIG_H
-#define __EGLIB_CONFIG_H
-
-/*
- * System-dependent settings
- */
-#define G_OS_WIN32 1
-
-#ifdef _MSC_VER
-
-#include <io.h>
-
-#define G_GNUC_PRETTY_FUNCTION __FUNCTION__
-#define G_GNUC_UNUSED
-#define G_BYTE_ORDER 1234
-#define G_GNUC_NORETURN
-#define G_BREAKPOINT() __debugbreak()
-#define MAXPATHLEN 242
-
-typedef uintptr_t gsize;
-typedef intptr_t gssize;
-typedef int pid_t;
-
-#define G_DIR_SEPARATOR '\\'
-#define G_DIR_SEPARATOR_S "\\"
-#define G_SEARCHPATH_SEPARATOR_S ";"
-#define G_SEARCHPATH_SEPARATOR ';'
-#define G_GSIZE_FORMAT "d"
-#define GPOINTER_TO_INT(ptr) ((gint)(intptr_t) (ptr))
-#define GPOINTER_TO_UINT(ptr) ((guint)(intptr_t) (ptr))
-#define GINT_TO_POINTER(v) ((gpointer)(intptr_t) (v))
-#define GUINT_TO_POINTER(v) ((gpointer)(intptr_t) (v))
-
-#define STDOUT_FILENO (int)(intptr_t)stdout
-#define STDERR_FILENO (int)(intptr_t)stderr
-
-/* FIXME: what should this be ?*/
-#define X_OK 4 /* This is really read */
-#define WNOHANG 1
-#define F_SETFD 1
-#define FD_CLOEXEC 1
-
-#undef inline
-#define inline __inline
-
-#define strtok_r strtok_s
-
-#undef G_HAVE_UNISTD_H
-#undef G_HAVE_SYS_TIME_H
-#undef G_HAVE_SYS_WAIT_H
-#undef G_HAVE_PWD_H
-#undef G_HAVE_STRNDUP
-#define G_HAVE_GETOPT_H 1
-
-/* disable the following warnings
- * C4100: The formal parameter is not referenced in the body of the function. The unreferenced parameter is ignored.
- * C4127: conditional expression is constant
-*/
-#pragma warning(disable:4100 4127)
-#endif
-
-typedef void * GPid;
-#endif
+++ /dev/null
-#define g_array_append monoeg_g_array_append
-#define g_array_append_vals monoeg_g_array_append_vals
-#define g_array_free monoeg_g_array_free
-#define g_array_insert_vals monoeg_g_array_insert_vals
-#define g_array_new monoeg_g_array_new
-#define g_array_remove_index monoeg_g_array_remove_index
-#define g_array_remove_index_fast monoeg_g_array_remove_index_fast
-#define g_array_set_size monoeg_g_array_set_size
-#define g_array_sized_new monoeg_g_array_sized_new
-#define g_ascii_strdown monoeg_g_ascii_strdown
-#define g_ascii_strncasecmp monoeg_g_ascii_strncasecmp
-#define g_ascii_tolower monoeg_g_ascii_tolower
-#define g_ascii_xdigit_value monoeg_g_ascii_xdigit_value
-#define g_build_path monoeg_g_build_path
-#define g_byte_array_append monoeg_g_byte_array_append
-#define g_byte_array_free monoeg_g_byte_array_free
-#define g_byte_array_new monoeg_g_byte_array_new
-#define g_byte_array_set_size monoeg_g_byte_array_set_size
-#define g_calloc monoeg_g_calloc
-#define g_clear_error monoeg_g_clear_error
-#define g_convert monoeg_g_convert
-#define g_convert_error_quark monoeg_g_convert_error_quark
-#define g_dir_close monoeg_g_dir_close
-#define g_dir_open monoeg_g_dir_open
-#define g_dir_read_name monoeg_g_dir_read_name
-#define g_dir_rewind monoeg_g_dir_rewind
-#define g_mkdir_with_parents monoeg_g_mkdir_with_parents
-#define g_direct_equal monoeg_g_direct_equal
-#define g_direct_hash monoeg_g_direct_hash
-#define g_ensure_directory_exists monoeg_g_ensure_directory_exists
-#define g_error_free monoeg_g_error_free
-#define g_error_new monoeg_g_error_new
-#define g_error_vnew monoeg_g_error_vnew
-#define g_file_error_quark monoeg_g_file_error_quark
-#define g_file_error_from_errno monoeg_g_file_error_from_errno
-#define g_file_get_contents monoeg_g_file_get_contents
-#define g_file_set_contents monoeg_g_file_set_contents
-#define g_file_open_tmp monoeg_g_file_open_tmp
-#define g_file_test monoeg_g_file_test
-#define g_filename_from_uri monoeg_g_filename_from_uri
-#define g_filename_from_utf8 monoeg_g_filename_from_utf8
-#define g_filename_to_uri monoeg_g_filename_to_uri
-#define g_find_program_in_path monoeg_g_find_program_in_path
-#define g_fprintf monoeg_g_fprintf
-#define g_free monoeg_g_free
-#define g_get_charset monoeg_g_get_charset
-#define g_get_current_dir monoeg_g_get_current_dir
-#define g_get_current_time monoeg_g_get_current_time
-#define g_get_home_dir monoeg_g_get_home_dir
-#define g_get_prgname monoeg_g_get_prgname
-#define g_get_tmp_dir monoeg_g_get_tmp_dir
-#define g_get_user_name monoeg_g_get_user_name
-#define g_getenv monoeg_g_getenv
-#define g_hasenv monoeg_g_hasenv
-#define g_hash_table_destroy monoeg_g_hash_table_destroy
-#define g_hash_table_find monoeg_g_hash_table_find
-#define g_hash_table_foreach monoeg_g_hash_table_foreach
-#define g_hash_table_foreach_remove monoeg_g_hash_table_foreach_remove
-#define g_hash_table_foreach_steal monoeg_g_hash_table_foreach_steal
-#define g_hash_table_get_keys monoeg_g_hash_table_get_keys
-#define g_hash_table_get_values monoeg_g_hash_table_get_values
-#define g_hash_table_insert_replace monoeg_g_hash_table_insert_replace
-#define g_hash_table_lookup monoeg_g_hash_table_lookup
-#define g_hash_table_lookup_extended monoeg_g_hash_table_lookup_extended
-#define g_hash_table_new monoeg_g_hash_table_new
-#define g_hash_table_new_full monoeg_g_hash_table_new_full
-#define g_hash_table_remove monoeg_g_hash_table_remove
-#define g_hash_table_steal monoeg_g_hash_table_steal
-#define g_hash_table_size monoeg_g_hash_table_size
-#define g_hash_table_print_stats monoeg_g_hash_table_print_stats
-#define g_hash_table_remove_all monoeg_g_hash_table_remove_all
-#define g_hash_table_iter_init monoeg_g_hash_table_iter_init
-#define g_hash_table_iter_next monoeg_g_hash_table_iter_next
-#define g_iconv monoeg_g_iconv
-#define g_iconv_close monoeg_g_iconv_close
-#define g_iconv_open monoeg_g_iconv_open
-#define g_int_equal monoeg_g_int_equal
-#define g_int_hash monoeg_g_int_hash
-#define g_list_alloc monoeg_g_list_alloc
-#define g_list_append monoeg_g_list_append
-#define g_list_concat monoeg_g_list_concat
-#define g_list_copy monoeg_g_list_copy
-#define g_list_delete_link monoeg_g_list_delete_link
-#define g_list_find monoeg_g_list_find
-#define g_list_find_custom monoeg_g_list_find_custom
-#define g_list_first monoeg_g_list_first
-#define g_list_foreach monoeg_g_list_foreach
-#define g_list_free monoeg_g_list_free
-#define g_list_free_1 monoeg_g_list_free_1
-#define g_list_index monoeg_g_list_index
-#define g_list_insert_before monoeg_g_list_insert_before
-#define g_list_insert_sorted monoeg_g_list_insert_sorted
-#define g_list_last monoeg_g_list_last
-#define g_list_length monoeg_g_list_length
-#define g_list_nth monoeg_g_list_nth
-#define g_list_nth_data monoeg_g_list_nth_data
-#define g_list_prepend monoeg_g_list_prepend
-#define g_list_remove monoeg_g_list_remove
-#define g_list_remove_all monoeg_g_list_remove_all
-#define g_list_remove_link monoeg_g_list_remove_link
-#define g_list_reverse monoeg_g_list_reverse
-#define g_list_sort monoeg_g_list_sort
-#define g_locale_from_utf8 monoeg_g_locale_from_utf8
-#define g_locale_to_utf8 monoeg_g_locale_to_utf8
-#define g_log monoeg_g_log
-#define g_log_set_always_fatal monoeg_g_log_set_always_fatal
-#define g_log_set_fatal_mask monoeg_g_log_set_fatal_mask
-#define g_logv monoeg_g_logv
-#define g_markup_parse_context_end_parse monoeg_g_markup_parse_context_end_parse
-#define g_markup_parse_context_free monoeg_g_markup_parse_context_free
-#define g_markup_parse_context_new monoeg_g_markup_parse_context_new
-#define g_markup_parse_context_parse monoeg_g_markup_parse_context_parse
-#define g_memdup monoeg_g_memdup
-#define g_mem_set_vtable monoeg_g_mem_set_vtable
-#define g_mkdtemp monoeg_g_mkdtemp
-#define g_module_build_path monoeg_g_module_build_path
-#define g_module_close monoeg_g_module_close
-#define g_module_error monoeg_g_module_error
-#define g_module_open monoeg_g_module_open
-#define g_module_symbol monoeg_g_module_symbol
-#define g_path_get_basename monoeg_g_path_get_basename
-#define g_path_get_dirname monoeg_g_path_get_dirname
-#define g_path_is_absolute monoeg_g_path_is_absolute
-#define g_pattern_match_string monoeg_g_pattern_match_string
-#define g_pattern_spec_free monoeg_g_pattern_spec_free
-#define g_pattern_spec_new monoeg_g_pattern_spec_new
-#define g_print monoeg_g_print
-#define g_printf monoeg_g_printf
-#define g_printerr monoeg_g_printerr
-#define g_propagate_error monoeg_g_propagate_error
-#define g_ptr_array_add monoeg_g_ptr_array_add
-#define g_ptr_array_foreach monoeg_g_ptr_array_foreach
-#define g_ptr_array_free monoeg_g_ptr_array_free
-#define g_ptr_array_new monoeg_g_ptr_array_new
-#define g_ptr_array_remove monoeg_g_ptr_array_remove
-#define g_ptr_array_remove_fast monoeg_g_ptr_array_remove_fast
-#define g_ptr_array_remove_index monoeg_g_ptr_array_remove_index
-#define g_ptr_array_remove_index_fast monoeg_g_ptr_array_remove_index_fast
-#define g_ptr_array_set_size monoeg_g_ptr_array_set_size
-#define g_ptr_array_sized_new monoeg_g_ptr_array_sized_new
-#define g_ptr_array_sort monoeg_g_ptr_array_sort
-#define g_ptr_array_sort_with_data monoeg_g_ptr_array_sort_with_data
-#define g_qsort_with_data monoeg_g_qsort_with_data
-#define g_queue_free monoeg_g_queue_free
-#define g_queue_is_empty monoeg_g_queue_is_empty
-#define g_queue_foreach monoeg_g_queue_foreach
-#define g_queue_new monoeg_g_queue_new
-#define g_queue_pop_head monoeg_g_queue_pop_head
-#define g_queue_push_head monoeg_g_queue_push_head
-#define g_queue_push_tail monoeg_g_queue_push_tail
-#define g_set_error monoeg_g_set_error
-#define g_set_prgname monoeg_g_set_prgname
-#define g_setenv monoeg_g_setenv
-#define g_shell_parse_argv monoeg_g_shell_parse_argv
-#define g_shell_quote monoeg_g_shell_quote
-#define g_shell_unquote monoeg_g_shell_unquote
-#define g_slist_alloc monoeg_g_slist_alloc
-#define g_slist_append monoeg_g_slist_append
-#define g_slist_concat monoeg_g_slist_concat
-#define g_slist_copy monoeg_g_slist_copy
-#define g_slist_delete_link monoeg_g_slist_delete_link
-#define g_slist_find monoeg_g_slist_find
-#define g_slist_find_custom monoeg_g_slist_find_custom
-#define g_slist_foreach monoeg_g_slist_foreach
-#define g_slist_free monoeg_g_slist_free
-#define g_slist_free_1 monoeg_g_slist_free_1
-#define g_slist_index monoeg_g_slist_index
-#define g_slist_insert_before monoeg_g_slist_insert_before
-#define g_slist_insert_sorted monoeg_g_slist_insert_sorted
-#define g_slist_last monoeg_g_slist_last
-#define g_slist_length monoeg_g_slist_length
-#define g_slist_nth monoeg_g_slist_nth
-#define g_slist_nth_data monoeg_g_slist_nth_data
-#define g_slist_prepend monoeg_g_slist_prepend
-#define g_slist_remove monoeg_g_slist_remove
-#define g_slist_remove_all monoeg_g_slist_remove_all
-#define g_slist_remove_link monoeg_g_slist_remove_link
-#define g_slist_reverse monoeg_g_slist_reverse
-#define g_slist_sort monoeg_g_slist_sort
-#define g_snprintf monoeg_g_snprintf
-#define g_spaced_primes_closest monoeg_g_spaced_primes_closest
-#define g_spawn_async_with_pipes monoeg_g_spawn_async_with_pipes
-#define g_spawn_command_line_sync monoeg_g_spawn_command_line_sync
-#define g_sprintf monoeg_g_sprintf
-#define g_stpcpy monoeg_g_stpcpy
-#define g_str_equal monoeg_g_str_equal
-#define g_str_has_prefix monoeg_g_str_has_prefix
-#define g_str_has_suffix monoeg_g_str_has_suffix
-#define g_str_hash monoeg_g_str_hash
-#define g_strchomp monoeg_g_strchomp
-#define g_strchug monoeg_g_strchug
-#define g_strconcat monoeg_g_strconcat
-#define g_strdelimit monoeg_g_strdelimit
-#define g_strdown monoeg_g_strdown
-#define g_strdup_printf monoeg_g_strdup_printf
-#define g_strdup_vprintf monoeg_g_strdup_vprintf
-#define g_strerror monoeg_g_strerror
-#define g_strescape monoeg_g_strescape
-#define g_strfreev monoeg_g_strfreev
-#define g_strdupv monoeg_g_strdupv
-#define g_string_append monoeg_g_string_append
-#define g_string_append_c monoeg_g_string_append_c
-#define g_string_append_len monoeg_g_string_append_len
-#define g_string_append_unichar monoeg_g_string_append_unichar
-#define g_string_append_printf monoeg_g_string_append_printf
-#define g_string_append_vprintf monoeg_g_string_append_vprintf
-#define g_string_erase monoeg_g_string_erase
-#define g_string_free monoeg_g_string_free
-#define g_string_insert monoeg_g_string_insert
-#define g_string_new monoeg_g_string_new
-#define g_string_new_len monoeg_g_string_new_len
-#define g_string_prepend monoeg_g_string_prepend
-#define g_string_printf monoeg_g_string_printf
-#define g_string_set_size monoeg_g_string_set_size
-#define g_string_sized_new monoeg_g_string_sized_new
-#define g_string_truncate monoeg_g_string_truncate
-#define g_strjoin monoeg_g_strjoin
-#define g_strjoinv monoeg_g_strjoinv
-#define g_strlcpy monoeg_g_strlcpy
-#define g_strndup monoeg_g_strndup
-#define g_strnfill monoeg_g_strnfill
-#define g_strreverse monoeg_g_strreverse
-#define g_strsplit monoeg_g_strsplit
-#define g_strsplit_set monoeg_g_strsplit_set
-#define g_strv_length monoeg_g_strv_length
-#define g_timer_destroy monoeg_g_timer_destroy
-#define g_timer_elapsed monoeg_g_timer_elapsed
-#define g_timer_new monoeg_g_timer_new
-#define g_timer_start monoeg_g_timer_start
-#define g_timer_stop monoeg_g_timer_stop
-#define g_trailingBytesForUTF8 monoeg_g_trailingBytesForUTF8
-#define g_ucs4_to_utf8 monoeg_g_ucs4_to_utf8
-#define g_ucs4_to_utf16 monoeg_g_ucs4_to_utf16
-#define g_unichar_case monoeg_g_unichar_case
-#define g_unichar_isxdigit monoeg_g_unichar_isxdigit
-#define g_unichar_tolower monoeg_g_unichar_tolower
-#define g_unichar_totitle monoeg_g_unichar_totitle
-#define g_unichar_toupper monoeg_g_unichar_toupper
-#define g_unichar_type monoeg_g_unichar_type
-#define g_unichar_xdigit_value monoeg_g_unichar_xdigit_value
-#define g_unsetenv monoeg_g_unsetenv
-#define g_usleep monoeg_g_usleep
-#define g_utf16_to_ucs4 monoeg_g_utf16_to_ucs4
-#define g_utf16_to_utf8 monoeg_g_utf16_to_utf8
-#define g_utf8_get_char monoeg_g_utf8_get_char
-#define g_utf8_offset_to_pointer monoeg_g_utf8_offset_to_pointer
-#define g_utf8_pointer_to_offset monoeg_g_utf8_pointer_to_offset
-#define g_utf8_strdown monoeg_g_utf8_strdown
-#define g_utf8_strlen monoeg_g_utf8_strlen
-#define g_utf8_strup monoeg_g_utf8_strup
-#define g_utf8_to_ucs4_fast monoeg_g_utf8_to_ucs4_fast
-#define g_utf8_to_utf16 monoeg_g_utf8_to_utf16
-#define g_utf8_validate monoeg_g_utf8_validate
-#define g_unichar_to_utf8 monoeg_g_unichar_to_utf8
-#define g_unichar_is_space monoeg_g_unichar_is_space
-#define g_unicode_break_type monoeg_g_unicode_break_type
-#define g_utf8_offset_to_pointer monoeg_g_utf8_offset_to_pointer
-#define g_utf8_pointer_to_offset monoeg_g_utf8_pointer_to_offset
-#define g_utf8_to_ucs4_fast monoeg_g_utf8_to_ucs4_fast
-#define g_vasprintf monoeg_g_vasprintf
-#define g_win32_getlocale monoeg_g_win32_getlocale
-#define g_assertion_message monoeg_assertion_message
-#define g_malloc monoeg_malloc
-#define g_malloc0 monoeg_malloc0
-#define g_ptr_array_grow monoeg_ptr_array_grow
-#define g_realloc monoeg_realloc
-#define g_try_malloc monoeg_try_malloc
-#define g_try_realloc monoeg_try_realloc
-#define g_strdup monoeg_strdup
-#define g_ucs4_to_utf16_len monoeg_ucs4_to_utf16_len
-#define g_utf16_to_ucs4_len monoeg_utf16_to_ucs4_len
-
-#define g_ascii_strcasecmp monoeg_ascii_strcasecmp
-#define g_ascii_strup monoeg_ascii_strup
-#define g_ascii_toupper monoeg_ascii_toupper
-#define g_unichar_break_type monoeg_unichar_break_type
-#define g_unichar_isspace monoeg_unichar_isspace
-#define g_unichar_to_utf16 monoeg_unichar_to_utf16
-#define g_utf8_find_prev_char monoeg_utf8_find_prev_char
-#define g_utf8_get_char_validated monoeg_utf8_get_char_validated
-#define g_utf8_prev_char monoeg_utf8_prev_char
-#define g_utf8_to_ucs4 monoeg_utf8_to_ucs4
-
-
-#define g_log_default_handler monoeg_log_default_handler
-#define g_log_set_default_handler monoeg_log_set_default_handler
-#define g_set_print_handler monoeg_set_print_handler
-#define g_set_printerr_handler monoeg_set_printerr_handler
+++ /dev/null
-/*
- * Arrays
- *
- * Author:
- * Chris Toshok (toshok@novell.com)
- *
- * (C) 2006 Novell, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-#include <stdlib.h>
-#include <glib.h>
-
-#define INITIAL_CAPACITY 16
-
-#define element_offset(p,i) ((p)->array.data + (i) * (p)->element_size)
-#define element_length(p,i) ((i) * (p)->element_size)
-
-typedef struct {
- GArray array;
- gboolean clear_;
- guint element_size;
- gboolean zero_terminated;
- guint capacity;
-} GArrayPriv;
-
-static void
-ensure_capacity (GArrayPriv *priv, guint capacity)
-{
- guint new_capacity;
-
- if (capacity <= priv->capacity)
- return;
-
- new_capacity = (capacity + 63) & ~63;
-
- priv->array.data = g_realloc (priv->array.data, element_length (priv, new_capacity));
-
- if (priv->clear_) {
- memset (element_offset (priv, priv->capacity),
- 0,
- element_length (priv, new_capacity - priv->capacity));
- }
-
- priv->capacity = new_capacity;
-}
-
-GArray *
-g_array_new (gboolean zero_terminated,
- gboolean clear_,
- guint element_size)
-{
- GArrayPriv *rv = g_new0 (GArrayPriv, 1);
- rv->zero_terminated = zero_terminated;
- rv->clear_ = clear_;
- rv->element_size = element_size;
-
- ensure_capacity (rv, INITIAL_CAPACITY);
-
- return (GArray*)rv;
-}
-
-GArray *
-g_array_sized_new (gboolean zero_terminated,
- gboolean clear_,
- guint element_size,
- guint reserved_size)
-{
- GArrayPriv *rv = g_new0 (GArrayPriv, 1);
- rv->zero_terminated = zero_terminated;
- rv->clear_ = clear_;
- rv->element_size = element_size;
-
- ensure_capacity (rv, reserved_size);
-
- return (GArray*)rv;
-}
-
-gchar*
-g_array_free (GArray *array,
- gboolean free_segment)
-{
- gchar* rv = NULL;
-
- g_return_val_if_fail (array != NULL, NULL);
-
- if (free_segment)
- g_free (array->data);
- else
- rv = array->data;
-
- g_free (array);
-
- return rv;
-}
-
-GArray *
-g_array_append_vals (GArray *array,
- gconstpointer data,
- guint len)
-{
- GArrayPriv *priv = (GArrayPriv*)array;
-
- g_return_val_if_fail (array != NULL, NULL);
-
- ensure_capacity (priv, priv->array.len + len + (priv->zero_terminated ? 1 : 0));
-
- memmove (element_offset (priv, priv->array.len),
- data,
- element_length (priv, len));
-
- priv->array.len += len;
-
- if (priv->zero_terminated) {
- memset (element_offset (priv, priv->array.len),
- 0,
- priv->element_size);
- }
-
- return array;
-}
-
-GArray*
-g_array_insert_vals (GArray *array,
- guint index_,
- gconstpointer data,
- guint len)
-{
- GArrayPriv *priv = (GArrayPriv*)array;
- guint extra = (priv->zero_terminated ? 1 : 0);
-
- g_return_val_if_fail (array != NULL, NULL);
-
- ensure_capacity (priv, array->len + len + extra);
-
- /* first move the existing elements out of the way */
- memmove (element_offset (priv, index_ + len),
- element_offset (priv, index_),
- element_length (priv, array->len - index_));
-
- /* then copy the new elements into the array */
- memmove (element_offset (priv, index_),
- data,
- element_length (priv, len));
-
- array->len += len;
-
- if (priv->zero_terminated) {
- memset (element_offset (priv, priv->array.len),
- 0,
- priv->element_size);
- }
-
- return array;
-}
-
-GArray*
-g_array_remove_index (GArray *array,
- guint index_)
-{
- GArrayPriv *priv = (GArrayPriv*)array;
-
- g_return_val_if_fail (array != NULL, NULL);
-
- memmove (element_offset (priv, index_),
- element_offset (priv, index_ + 1),
- element_length (priv, array->len - index_));
-
- array->len --;
-
- if (priv->zero_terminated) {
- memset (element_offset (priv, priv->array.len),
- 0,
- priv->element_size);
- }
-
- return array;
-}
-
-GArray*
-g_array_remove_index_fast (GArray *array,
- guint index_)
-{
- GArrayPriv *priv = (GArrayPriv*)array;
-
- g_return_val_if_fail (array != NULL, NULL);
-
- memmove (element_offset (priv, index_),
- element_offset (priv, array->len - 1),
- element_length (priv, 1));
-
- array->len --;
-
- if (priv->zero_terminated) {
- memset (element_offset (priv, priv->array.len),
- 0,
- priv->element_size);
- }
-
- return array;
-}
-
-void
-g_array_set_size (GArray *array, gint length)
-{
- GArrayPriv *priv = (GArrayPriv*)array;
-
- g_return_if_fail (array != NULL);
- g_return_if_fail (length >= 0);
-
- if (length == priv->capacity)
- return; // nothing to be done
-
- if (length > priv->capacity) {
- // grow the array
- ensure_capacity (priv, length);
- }
-
- array->len = length;
-}
+++ /dev/null
-/*
- * Arrays
- *
- * Author:
- * Geoff Norton (gnorton@novell.com)
- *
- * (C) 2010 Novell, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-#include <stdlib.h>
-#include <glib.h>
-
-GByteArray *
-g_byte_array_new ()
-{
- return (GByteArray *) g_array_new (FALSE, TRUE, 1);
-}
-
-guint8*
-g_byte_array_free (GByteArray *array,
- gboolean free_segment)
-{
- return (guint8*) g_array_free ((GArray *)array, free_segment);
-}
-
-GByteArray *
-g_byte_array_append (GByteArray *array,
- const guint8 *data,
- guint len)
-{
- return (GByteArray *)g_array_append_vals ((GArray *)array, data, len);
-}
-
-void
-g_byte_array_set_size (GByteArray *array, gint length)
-{
- g_array_set_size ((GArray *)array, length);
-}
-
+++ /dev/null
-/*
- * gdate-unix.c: Date and time utility functions.
- *
- * Author:
- * Gonzalo Paniagua Javier (gonzalo@novell.com
- *
- * (C) 2006 Novell, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-#include <stdio.h>
-#include <glib.h>
-#include <time.h>
-#include <errno.h>
-#include <sys/time.h>
-
-void
-g_get_current_time (GTimeVal *result)
-{
- struct timeval tv;
-
- g_return_if_fail (result != NULL);
- gettimeofday (&tv, NULL);
- result->tv_sec = tv.tv_sec;
- result->tv_usec = tv.tv_usec;
-}
-
-void
-g_usleep (gulong microseconds)
-{
- struct timespec req, rem;
-
- req.tv_sec = microseconds / 1000000;
- req.tv_nsec = (microseconds % 1000000) * 1000;
-
- while (nanosleep (&req, &rem) == -1 && errno == EINTR)
- req = rem;
-}
+++ /dev/null
-/*
- * gdate-win32.c: Date and time utility functions.
- *
- * Author:
- * Gonzalo Paniagua Javier (gonzalo@novell.com
- *
- * (C) 2006 Novell, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-#include <stdio.h>
-#include <glib.h>
-
-#include <winsock2.h>
-
-void
-g_get_current_time (GTimeVal *result)
-{
- long int l;
-
- g_return_if_fail (result != NULL);
- l = GetTickCount();
-
- result->tv_sec = l / 1000;
- result->tv_usec = (l % 1000) * 1000;
-}
-
-void
-g_usleep (gulong microseconds)
-{
- Sleep (microseconds/1000);
-}
+++ /dev/null
-/*
- * Directory utility functions.
- *
- * Author:
- * Gonzalo Paniagua Javier (gonzalo@novell.com)
- *
- * (C) 2006 Novell, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-#include <glib.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <dirent.h>
-
-struct _GDir {
- DIR *dir;
-#ifndef HAVE_REWINDDIR
- char *path;
-#endif
-};
-
-GDir *
-g_dir_open (const gchar *path, guint flags, GError **error)
-{
- GDir *dir;
-
- g_return_val_if_fail (path != NULL, NULL);
- g_return_val_if_fail (error == NULL || *error == NULL, NULL);
-
- (void) flags; /* this is not used */
- dir = g_new (GDir, 1);
- dir->dir = opendir (path);
- if (dir->dir == NULL) {
- if (error) {
- gint err = errno;
- *error = g_error_new (G_LOG_DOMAIN, g_file_error_from_errno (err), strerror (err));
- }
- g_free (dir);
- return NULL;
- }
-#ifndef HAVE_REWINDDIR
- dir->path = g_strdup (path);
-#endif
- return dir;
-}
-
-const gchar *
-g_dir_read_name (GDir *dir)
-{
- struct dirent *entry;
-
- g_return_val_if_fail (dir != NULL && dir->dir != NULL, NULL);
- do {
- entry = readdir (dir->dir);
- if (entry == NULL)
- return NULL;
- } while ((strcmp (entry->d_name, ".") == 0) || (strcmp (entry->d_name, "..") == 0));
-
- return entry->d_name;
-}
-
-void
-g_dir_rewind (GDir *dir)
-{
- g_return_if_fail (dir != NULL && dir->dir != NULL);
-#ifndef HAVE_REWINDDIR
- closedir (dir->dir);
- dir->dir = opendir (dir->path);
-#else
- rewinddir (dir->dir);
-#endif
-}
-
-void
-g_dir_close (GDir *dir)
-{
- g_return_if_fail (dir != NULL && dir->dir != 0);
- closedir (dir->dir);
-#ifndef HAVE_REWINDDIR
- g_free (dir->path);
-#endif
- dir->dir = NULL;
- g_free (dir);
-}
-
-int
-g_mkdir_with_parents (const gchar *pathname, int mode)
-{
- char *path, *d;
- int rv;
-
- if (!pathname || *pathname == '\0') {
- errno = EINVAL;
- return -1;
- }
-
- d = path = g_strdup (pathname);
- if (*d == '/')
- d++;
-
- while (TRUE) {
- if (*d == '/' || *d == '\0') {
- char orig = *d;
- *d = '\0';
- rv = mkdir (path, mode);
- if (rv == -1 && errno != EEXIST) {
- g_free (path);
- return -1;
- }
-
- *d++ = orig;
- while (orig == '/' && *d == '/')
- d++;
- if (orig == '\0')
- break;
- } else {
- d++;
- }
- }
-
- g_free (path);
-
- return 0;
-}
+++ /dev/null
-/*
- * Directory utility functions.
- *
- * Author:
- * Gonzalo Paniagua Javier (gonzalo@novell.com)
- *
- * (C) 2006 Novell, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-#include <glib.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <io.h>
-
-#include <winsock2.h>
-
-struct _GDir {
- HANDLE handle;
- gchar* current;
- gchar* next;
-};
-
-GDir *
-g_dir_open (const gchar *path, guint flags, GError **error)
-{
- GDir *dir;
- gunichar2* path_utf16;
- gunichar2* path_utf16_search;
- WIN32_FIND_DATAW find_data;
-
- g_return_val_if_fail (path != NULL, NULL);
- g_return_val_if_fail (error == NULL || *error == NULL, NULL);
-
- dir = g_new0 (GDir, 1);
- path_utf16 = u8to16 (path);
- path_utf16_search = g_malloc ((wcslen((wchar_t *) path_utf16) + 3)*sizeof(gunichar2));
- wcscpy (path_utf16_search, path_utf16);
- wcscat (path_utf16_search, L"\\*");
-
- dir->handle = FindFirstFileW (path_utf16_search, &find_data);
- if (dir->handle == INVALID_HANDLE_VALUE) {
- if (error) {
- gint err = errno;
- *error = g_error_new (G_LOG_DOMAIN, g_file_error_from_errno (err), strerror (err));
- }
- g_free (path_utf16_search);
- g_free (path_utf16);
- g_free (dir);
- return NULL;
- }
- g_free (path_utf16_search);
- g_free (path_utf16);
-
- while ((wcscmp ((wchar_t *) find_data.cFileName, L".") == 0) || (wcscmp ((wchar_t *) find_data.cFileName, L"..") == 0)) {
- if (!FindNextFileW (dir->handle, &find_data)) {
- if (error) {
- gint err = errno;
- *error = g_error_new (G_LOG_DOMAIN, g_file_error_from_errno (err), strerror (err));
- }
- g_free (dir);
- return NULL;
- }
- }
-
- dir->current = NULL;
- dir->next = u16to8 (find_data.cFileName);
- return dir;
-}
-
-const gchar *
-g_dir_read_name (GDir *dir)
-{
- WIN32_FIND_DATAW find_data;
-
- g_return_val_if_fail (dir != NULL && dir->handle != 0, NULL);
-
- if (dir->current)
- g_free (dir->current);
- dir->current = NULL;
-
- dir->current = dir->next;
-
- if (!dir->current)
- return NULL;
-
- dir->next = NULL;
-
- do {
- if (!FindNextFileW (dir->handle, &find_data)) {
- dir->next = NULL;
- return dir->current;
- }
- } while ((wcscmp ((wchar_t *) find_data.cFileName, L".") == 0) || (wcscmp ((wchar_t *) find_data.cFileName, L"..") == 0));
-
- dir->next = u16to8 (find_data.cFileName);
- return dir->current;
-}
-
-void
-g_dir_rewind (GDir *dir)
-{
-}
-
-void
-g_dir_close (GDir *dir)
-{
- g_return_if_fail (dir != NULL && dir->handle != 0);
-
- if (dir->current)
- g_free (dir->current);
- dir->current = NULL;
- if (dir->next)
- g_free (dir->next);
- dir->next = NULL;
- FindClose (dir->handle);
- dir->handle = 0;
- g_free (dir);
-}
-
-
+++ /dev/null
-/*
- * gerror.c: Error support.
- *
- * Author:
- * Miguel de Icaza (miguel@novell.com)
- *
- * (C) 2006 Novell, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-#include <stdio.h>
-#include <stdarg.h>
-#include <string.h>
-#include <config.h>
-#include <glib.h>
-GError *
-g_error_new (gpointer domain, gint code, const char *format, ...)
-{
- va_list args;
- GError *err = g_new (GError, 1);
-
- err->domain = domain;
- err->code = code;
-
- va_start (args, format);
- if (g_vasprintf (&err->message, format, args) == -1)
- err->message = g_strdup_printf ("internal: invalid format string %s", format);
- va_end (args);
-
- return err;
-}
-
-static GError *
-g_error_vnew (gpointer domain, gint code, const char *format, va_list ap)
-{
- GError *err = g_new (GError, 1);
-
- err->domain = domain;
- err->code = code;
-
- if (g_vasprintf (&err->message, format, ap) == -1)
- err->message = g_strdup_printf ("internal: invalid format string %s", format);
-
- return err;
-}
-
-void
-g_clear_error (GError **error)
-{
- if (error && *error) {
- g_error_free (*error);
- *error = NULL;
- }
-}
-
-void
-g_error_free (GError *error)
-{
- g_return_if_fail (error != NULL);
-
- g_free (error->message);
- g_free (error);
-}
-
-void
-g_set_error (GError **err, gpointer domain, gint code, const gchar *format, ...)
-{
- va_list args;
-
- if (err) {
- va_start (args, format);
- *err = g_error_vnew (domain, code, format, args);
- va_end (args);
- }
-}
-
-void
-g_propagate_error (GError **dest, GError *src)
-{
- if (dest == NULL){
- if (src)
- g_error_free (src);
- } else {
- *dest = src;
- }
-}
+++ /dev/null
-/*
- * File utility functions.
- *
- * Author:
- * Gonzalo Paniagua Javier (gonzalo@novell.com)
- *
- * (C) 2006 Novell, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-#include <config.h>
-#include <glib.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#include <fcntl.h>
-#include <errno.h>
-
-#ifdef _MSC_VER
-#include <direct.h>
-#endif
-#ifdef G_OS_WIN32
-int mkstemp (char *tmp_template);
-#endif
-
-#ifndef O_LARGEFILE
-#define OPEN_FLAGS (O_RDONLY)
-#else
-#define OPEN_FLAGS (O_RDONLY | O_LARGEFILE)
-#endif
-gboolean
-g_file_get_contents (const gchar *filename, gchar **contents, gsize *length, GError **error)
-{
- gchar *str;
- int fd;
- struct stat st;
- long offset;
- int nread;
-
- g_return_val_if_fail (filename != NULL, FALSE);
- g_return_val_if_fail (contents != NULL, FALSE);
- g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
-
- *contents = NULL;
- if (length)
- *length = 0;
-
- fd = open (filename, OPEN_FLAGS);
- if (fd == -1) {
- if (error != NULL) {
- int err = errno;
- *error = g_error_new (G_LOG_DOMAIN, g_file_error_from_errno (err), "Error opening file");
- }
- return FALSE;
- }
-
- if (fstat (fd, &st) != 0) {
- if (error != NULL) {
- int err = errno;
- *error = g_error_new (G_LOG_DOMAIN, g_file_error_from_errno (err), "Error in fstat()");
- }
- close (fd);
- return FALSE;
- }
-
- str = g_malloc (st.st_size + 1);
- offset = 0;
- do {
- nread = read (fd, str + offset, st.st_size - offset);
- if (nread > 0) {
- offset += nread;
- }
- } while ((nread > 0 && offset < st.st_size) || (nread == -1 && errno == EINTR));
-
- close (fd);
- str [st.st_size] = '\0';
- if (length) {
- *length = st.st_size;
- }
- *contents = str;
- return TRUE;
-}
-
-gint
-g_file_open_tmp (const gchar *tmpl, gchar **name_used, GError **error)
-{
- const static gchar *default_tmpl = ".XXXXXX";
- gchar *t;
- gint fd;
- size_t len;
-
- g_return_val_if_fail (error == NULL || *error == NULL, -1);
-
- if (tmpl == NULL)
- tmpl = default_tmpl;
-
- if (strchr (tmpl, G_DIR_SEPARATOR) != NULL) {
- if (error) {
- *error = g_error_new (G_LOG_DOMAIN, 24, "Template should not have any " G_DIR_SEPARATOR_S);
- }
- return -1;
- }
-
- len = strlen (tmpl);
- if (len < 6 || strcmp (tmpl + len - 6, "XXXXXX")) {
- if (error) {
- *error = g_error_new (G_LOG_DOMAIN, 24, "Template should end with XXXXXX");
- }
- return -1;
- }
-
- t = g_build_filename (g_get_tmp_dir (), tmpl, NULL);
-
- fd = mkstemp (t);
-
- if (fd == -1) {
- if (error) {
- int err = errno;
- *error = g_error_new (G_LOG_DOMAIN, g_file_error_from_errno (err), "Error in mkstemp()");
- }
- g_free (t);
- return -1;
- }
-
- if (name_used) {
- *name_used = t;
- } else {
- g_free (t);
- }
- return fd;
-}
-
-gchar *
-g_get_current_dir (void)
-{
- int s = 32;
- char *buffer = NULL, *r;
- gboolean fail;
-
- do {
- buffer = g_realloc (buffer, s);
- r = getcwd (buffer, s);
- fail = (r == NULL && errno == ERANGE);
- if (fail) {
- s <<= 1;
- }
- } while (fail);
-
- /* On amd64 sometimes the bottom 32-bits of r == the bottom 32-bits of buffer
- * but the top 32-bits of r have overflown to 0xffffffff (seriously wtf getcwd
- * so we return the buffer here since it has a pointer to the valid string
- */
- return buffer;
-}
+++ /dev/null
-/*
- * File utility functions.
- *
- * Author:
- * Gonzalo Paniagua Javier (gonzalo@novell.com)
- *
- * (C) 2006 Novell, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-#include <config.h>
-#include <glib.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <errno.h>
-#include <fcntl.h>
-
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
-gboolean
-g_file_test (const gchar *filename, GFileTest test)
-{
- struct stat st;
- gboolean have_stat;
-
- if (filename == NULL || test == 0)
- return FALSE;
-
- have_stat = FALSE;
-
- if ((test & G_FILE_TEST_EXISTS) != 0) {
- if (access (filename, F_OK) == 0)
- return TRUE;
- }
-
- if ((test & G_FILE_TEST_IS_EXECUTABLE) != 0) {
- if (access (filename, X_OK) == 0)
- return TRUE;
- }
- if ((test & G_FILE_TEST_IS_SYMLINK) != 0) {
- have_stat = (lstat (filename, &st) == 0);
- if (have_stat && S_ISLNK (st.st_mode))
- return TRUE;
- }
-
- if ((test & G_FILE_TEST_IS_REGULAR) != 0) {
- if (!have_stat)
- have_stat = (stat (filename, &st) == 0);
- if (have_stat && S_ISREG (st.st_mode))
- return TRUE;
- }
- if ((test & G_FILE_TEST_IS_DIR) != 0) {
- if (!have_stat)
- have_stat = (stat (filename, &st) == 0);
- if (have_stat && S_ISDIR (st.st_mode))
- return TRUE;
- }
- return FALSE;
-}
-
-gchar *
-g_mkdtemp (char *tmp_template)
-{
-#ifdef HAVE_MKDTEMP
- char *template_copy = g_strdup (tmp_template);
-
- return mkdtemp (template_copy);
-#else
- g_error("Function not supported");
-#endif
-}
+++ /dev/null
-/*
- * File utility functions.
- *
- * Author:
- * Gonzalo Paniagua Javier (gonzalo@novell.com)
- *
- * (C) 2006 Novell, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-#include <config.h>
-#include <windows.h>
-#include <glib.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <sys/types.h>
-#include <direct.h>
-
-#ifdef G_OS_WIN32
-#include <io.h>
-#define open _open
-#ifndef S_ISREG
-#define S_ISREG(x) ((x & _S_IFMT) == _S_IFREG)
-#endif
-#ifndef S_ISDIR
-#define S_ISDIR(x) ((x & _S_IFMT) == _S_IFDIR)
-#endif
-#endif
-
-int mkstemp (char *tmp_template)
-{
- int fd;
- gunichar2* utf16_template;
-
- utf16_template = u8to16 (tmp_template);
-
- fd = -1;
- utf16_template = _wmktemp( utf16_template);
- if (utf16_template && *utf16_template) {
- /* FIXME: _O_TEMPORARY causes file to disappear on close causing a test to fail */
- fd = _wopen( utf16_template, _O_BINARY | _O_CREAT /*| _O_TEMPORARY*/ | _O_RDWR | _O_EXCL, _S_IREAD | _S_IWRITE);
- }
-
- /* FIXME: this will crash if utf16_template == NULL */
- sprintf (tmp_template + strlen (tmp_template) - 6, "%S", utf16_template + wcslen (utf16_template) - 6);
-
- g_free (utf16_template);
- return fd;
-}
-
-gchar *
-g_mkdtemp (char *tmp_template)
-{
- gunichar2* utf16_template;
-
- utf16_template = u8to16 (tmp_template);
-
- utf16_template = _wmktemp(utf16_template);
- if (utf16_template && *utf16_template) {
- if (_wmkdir (utf16_template) == 0){
- char *ret = u16to8 (utf16_template);
- g_free (utf16_template);
- return ret;
- }
- }
-
- g_free (utf16_template);
- return NULL;
-}
-
-#ifdef _MSC_VER
-#pragma warning(disable:4701)
-#endif
-
-gboolean
-g_file_test (const gchar *filename, GFileTest test)
-{
- gunichar2* utf16_filename = NULL;
- DWORD attr;
-
- if (filename == NULL || test == 0)
- return FALSE;
-
- utf16_filename = u8to16 (filename);
- attr = GetFileAttributesW (utf16_filename);
- g_free (utf16_filename);
-
- if (attr == INVALID_FILE_ATTRIBUTES)
- return FALSE;
-
- if ((test & G_FILE_TEST_EXISTS) != 0) {
- return TRUE;
- }
-
- if ((test & G_FILE_TEST_IS_EXECUTABLE) != 0) {
- size_t len = strlen (filename);
- if (len > 4 && strcmp (filename + len-3, "exe"))
- return TRUE;
-
- return FALSE;
- }
-
- if ((test & G_FILE_TEST_IS_REGULAR) != 0) {
- if (attr & (FILE_ATTRIBUTE_DEVICE|FILE_ATTRIBUTE_DIRECTORY))
- return FALSE;
- return TRUE;
- }
-
- if ((test & G_FILE_TEST_IS_DIR) != 0) {
- if (attr & FILE_ATTRIBUTE_DIRECTORY)
- return TRUE;
- }
-
- /* make this last in case it is OR'd with something else */
- if ((test & G_FILE_TEST_IS_SYMLINK) != 0) {
- return FALSE;
- }
-
- return FALSE;
-}
+++ /dev/null
-/*
- * File utility functions.
- *
- * Author:
- * Gonzalo Paniagua Javier (gonzalo@novell.com)
- *
- * (C) 2006 Novell, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-#include <config.h>
-
-#include <glib.h>
-#include <stdio.h>
-#include <string.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#include <errno.h>
-
-static gpointer error_quark = "FileError";
-
-gpointer
-g_file_error_quark (void)
-{
- return error_quark;
-}
-
-GFileError
-g_file_error_from_errno (gint err_no)
-{
- switch (err_no) {
- case EEXIST:
- return G_FILE_ERROR_EXIST;
- case EISDIR:
- return G_FILE_ERROR_ISDIR;
- case EACCES:
- return G_FILE_ERROR_ACCES;
- case ENAMETOOLONG:
- return G_FILE_ERROR_NAMETOOLONG;
- case ENOENT:
- return G_FILE_ERROR_NOENT;
- case ENOTDIR:
- return G_FILE_ERROR_NOTDIR;
- case ENXIO:
- return G_FILE_ERROR_NXIO;
- case ENODEV:
- return G_FILE_ERROR_NODEV;
- case EROFS:
- return G_FILE_ERROR_ROFS;
-#ifdef ETXTBSY
- case ETXTBSY:
- return G_FILE_ERROR_TXTBSY;
-#endif
- case EFAULT:
- return G_FILE_ERROR_FAULT;
-#ifdef ELOOP
- case ELOOP:
- return G_FILE_ERROR_LOOP;
-#endif
- case ENOSPC:
- return G_FILE_ERROR_NOSPC;
- case ENOMEM:
- return G_FILE_ERROR_NOMEM;
- case EMFILE:
- return G_FILE_ERROR_MFILE;
- case ENFILE:
- return G_FILE_ERROR_NFILE;
- case EBADF:
- return G_FILE_ERROR_BADF;
- case EINVAL:
- return G_FILE_ERROR_INVAL;
- case EPIPE:
- return G_FILE_ERROR_PIPE;
- case EAGAIN:
- return G_FILE_ERROR_AGAIN;
- case EINTR:
- return G_FILE_ERROR_INTR;
- case EIO:
- return G_FILE_ERROR_IO;
- case EPERM:
- return G_FILE_ERROR_PERM;
- case ENOSYS:
- return G_FILE_ERROR_NOSYS;
- default:
- return G_FILE_ERROR_FAILED;
- }
-}
-
-#ifdef G_OS_WIN32
-#define TMP_FILE_FORMAT "%.*s%s.tmp"
-#else
-#define TMP_FILE_FORMAT "%.*s.%s~"
-#endif
-
-gboolean
-g_file_set_contents (const gchar *filename, const gchar *contents, gssize length, GError **err)
-{
- const char *name;
- char *path;
- FILE *fp;
-
- if (!(name = strrchr (filename, G_DIR_SEPARATOR)))
- name = filename;
- else
- name++;
-
- path = g_strdup_printf (TMP_FILE_FORMAT, name - filename, filename, name);
- if (!(fp = fopen (path, "wb"))) {
- g_set_error (err, G_FILE_ERROR, g_file_error_from_errno (errno), "%s", g_strerror (errno));
- g_free (path);
- return FALSE;
- }
-
- if (length < 0)
- length = strlen (contents);
-
- if (fwrite (contents, 1, length, fp) < length) {
- g_set_error (err, G_FILE_ERROR, g_file_error_from_errno (ferror (fp)), "%s", g_strerror (ferror (fp)));
- g_unlink (path);
- g_free (path);
- fclose (fp);
-
- return FALSE;
- }
-
- fclose (fp);
-
- if (g_rename (path, filename) != 0) {
- g_set_error (err, G_FILE_ERROR, g_file_error_from_errno (errno), "%s", g_strerror (errno));
- g_unlink (path);
- g_free (path);
- return FALSE;
- }
-
- g_free (path);
-
- return TRUE;
-}
+++ /dev/null
-/*
- * ghashtable.c: Hashtable implementation
- *
- * Author:
- * Miguel de Icaza (miguel@novell.com)
- *
- * (C) 2006 Novell, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-#include <stdio.h>
-#include <math.h>
-#include <glib.h>
-
-typedef struct _Slot Slot;
-
-struct _Slot {
- gpointer key;
- gpointer value;
- Slot *next;
-};
-
-static gpointer KEYMARKER_REMOVED = &KEYMARKER_REMOVED;
-
-struct _GHashTable {
- GHashFunc hash_func;
- GEqualFunc key_equal_func;
-
- Slot **table;
- int table_size;
- int in_use;
- int threshold;
- int last_rehash;
- GDestroyNotify value_destroy_func, key_destroy_func;
-};
-
-typedef struct {
- GHashTable *ht;
- int slot_index;
- Slot *slot;
-} Iter;
-
-static const guint prime_tbl[] = {
- 11, 19, 37, 73, 109, 163, 251, 367, 557, 823, 1237,
- 1861, 2777, 4177, 6247, 9371, 14057, 21089, 31627,
- 47431, 71143, 106721, 160073, 240101, 360163,
- 540217, 810343, 1215497, 1823231, 2734867, 4102283,
- 6153409, 9230113, 13845163
-};
-
-static gboolean
-test_prime (int x)
-{
- if ((x & 1) != 0) {
- int n;
- for (n = 3; n< (int)sqrt (x); n += 2) {
- if ((x % n) == 0)
- return FALSE;
- }
- return TRUE;
- }
- // There is only one even prime - 2.
- return (x == 2);
-}
-
-static int
-calc_prime (int x)
-{
- int i;
-
- for (i = (x & (~1))-1; i< G_MAXINT32; i += 2) {
- if (test_prime (i))
- return i;
- }
- return x;
-}
-
-guint
-g_spaced_primes_closest (guint x)
-{
- int i;
-
- for (i = 0; i < G_N_ELEMENTS (prime_tbl); i++) {
- if (x <= prime_tbl [i])
- return prime_tbl [i];
- }
- return calc_prime (x);
-}
-
-GHashTable *
-g_hash_table_new (GHashFunc hash_func, GEqualFunc key_equal_func)
-{
- GHashTable *hash;
-
- if (hash_func == NULL)
- hash_func = g_direct_hash;
- if (key_equal_func == NULL)
- key_equal_func = g_direct_equal;
- hash = g_new0 (GHashTable, 1);
-
- hash->hash_func = hash_func;
- hash->key_equal_func = key_equal_func;
-
- hash->table_size = g_spaced_primes_closest (1);
- hash->table = g_new0 (Slot *, hash->table_size);
- hash->last_rehash = hash->table_size;
-
- return hash;
-}
-
-GHashTable *
-g_hash_table_new_full (GHashFunc hash_func, GEqualFunc key_equal_func,
- GDestroyNotify key_destroy_func, GDestroyNotify value_destroy_func)
-{
- GHashTable *hash = g_hash_table_new (hash_func, key_equal_func);
- if (hash == NULL)
- return NULL;
-
- hash->key_destroy_func = key_destroy_func;
- hash->value_destroy_func = value_destroy_func;
-
- return hash;
-}
-
-#if 0
-static void
-dump_hash_table (GHashTable *hash)
-{
- int i;
-
- for (i = 0; i < hash->table_size; i++) {
- Slot *s;
-
- for (s = hash->table [i]; s != NULL; s = s->next){
- guint hashcode = (*hash->hash_func) (s->key);
- guint slot = (hashcode) % hash->table_size;
- printf ("key %p hash %x on slot %d correct slot %d tb size %d\n", s->key, hashcode, i, slot, hash->table_size);
- }
- }
-}
-#endif
-
-#ifdef SANITY_CHECK
-static void
-sanity_check (GHashTable *hash)
-{
- int i;
-
- for (i = 0; i < hash->table_size; i++) {
- Slot *s;
-
- for (s = hash->table [i]; s != NULL; s = s->next){
- guint hashcode = (*hash->hash_func) (s->key);
- guint slot = (hashcode) % hash->table_size;
- if (slot != i) {
- dump_hashcode_func = 1;
- hashcode = (*hash->hash_func) (s->key);
- dump_hashcode_func = 0;
- g_error ("Key %p (bucket %d) on invalid bucket %d (hashcode %x) (tb size %d)", s->key, slot, i, hashcode, hash->table_size);
- }
- }
- }
-}
-#else
-
-#define sanity_check(HASH) do {}while(0)
-
-#endif
-
-static void
-do_rehash (GHashTable *hash)
-{
- int current_size, i;
- Slot **table;
-
- /* printf ("Resizing diff=%d slots=%d\n", hash->in_use - hash->last_rehash, hash->table_size); */
- hash->last_rehash = hash->table_size;
- current_size = hash->table_size;
- hash->table_size = g_spaced_primes_closest (hash->in_use);
- /* printf ("New size: %d\n", hash->table_size); */
- table = hash->table;
- hash->table = g_new0 (Slot *, hash->table_size);
-
- for (i = 0; i < current_size; i++){
- Slot *s, *next;
-
- for (s = table [i]; s != NULL; s = next){
- guint hashcode = ((*hash->hash_func) (s->key)) % hash->table_size;
- next = s->next;
-
- s->next = hash->table [hashcode];
- hash->table [hashcode] = s;
- }
- }
- g_free (table);
-}
-
-static void
-rehash (GHashTable *hash)
-{
- int diff = ABS (hash->last_rehash - hash->in_use);
-
- /* These are the factors to play with to change the rehashing strategy */
- /* I played with them with a large range, and could not really get */
- /* something that was too good, maybe the tests are not that great */
- if (!(diff * 0.75 > hash->table_size * 2))
- return;
- do_rehash (hash);
- sanity_check (hash);
-}
-
-void
-g_hash_table_insert_replace (GHashTable *hash, gpointer key, gpointer value, gboolean replace)
-{
- guint hashcode;
- Slot *s;
- GEqualFunc equal;
-
- g_return_if_fail (hash != NULL);
- sanity_check (hash);
-
- equal = hash->key_equal_func;
- if (hash->in_use >= hash->threshold)
- rehash (hash);
-
- hashcode = ((*hash->hash_func) (key)) % hash->table_size;
- for (s = hash->table [hashcode]; s != NULL; s = s->next){
- if ((*equal) (s->key, key)){
- if (replace){
- if (hash->key_destroy_func != NULL)
- (*hash->key_destroy_func)(s->key);
- s->key = key;
- }
- if (hash->value_destroy_func != NULL)
- (*hash->value_destroy_func) (s->value);
- s->value = value;
- sanity_check (hash);
- return;
- }
- }
- s = g_new (Slot, 1);
- s->key = key;
- s->value = value;
- s->next = hash->table [hashcode];
- hash->table [hashcode] = s;
- hash->in_use++;
- sanity_check (hash);
-}
-
-GList*
-g_hash_table_get_keys (GHashTable *hash)
-{
- GHashTableIter iter;
- GList *rv = NULL;
- gpointer key;
-
- g_hash_table_iter_init (&iter, hash);
-
- while (g_hash_table_iter_next (&iter, &key, NULL))
- rv = g_list_prepend (rv, key);
-
- return g_list_reverse (rv);
-}
-
-GList*
-g_hash_table_get_values (GHashTable *hash)
-{
- GHashTableIter iter;
- GList *rv = NULL;
- gpointer value;
-
- g_hash_table_iter_init (&iter, hash);
-
- while (g_hash_table_iter_next (&iter, NULL, &value))
- rv = g_list_prepend (rv, value);
-
- return g_list_reverse (rv);
-}
-
-
-guint
-g_hash_table_size (GHashTable *hash)
-{
- g_return_val_if_fail (hash != NULL, 0);
-
- return hash->in_use;
-}
-
-gpointer
-g_hash_table_lookup (GHashTable *hash, gconstpointer key)
-{
- gpointer orig_key, value;
-
- if (g_hash_table_lookup_extended (hash, key, &orig_key, &value))
- return value;
- else
- return NULL;
-}
-
-gboolean
-g_hash_table_lookup_extended (GHashTable *hash, gconstpointer key, gpointer *orig_key, gpointer *value)
-{
- GEqualFunc equal;
- Slot *s;
- guint hashcode;
-
- g_return_val_if_fail (hash != NULL, FALSE);
- sanity_check (hash);
- equal = hash->key_equal_func;
-
- hashcode = ((*hash->hash_func) (key)) % hash->table_size;
-
- for (s = hash->table [hashcode]; s != NULL; s = s->next){
- if ((*equal)(s->key, key)){
- if (orig_key)
- *orig_key = s->key;
- if (value)
- *value = s->value;
- return TRUE;
- }
- }
- return FALSE;
-}
-
-void
-g_hash_table_foreach (GHashTable *hash, GHFunc func, gpointer user_data)
-{
- int i;
-
- g_return_if_fail (hash != NULL);
- g_return_if_fail (func != NULL);
-
- for (i = 0; i < hash->table_size; i++){
- Slot *s;
-
- for (s = hash->table [i]; s != NULL; s = s->next)
- (*func)(s->key, s->value, user_data);
- }
-}
-
-gpointer
-g_hash_table_find (GHashTable *hash, GHRFunc predicate, gpointer user_data)
-{
- int i;
-
- g_return_val_if_fail (hash != NULL, NULL);
- g_return_val_if_fail (predicate != NULL, NULL);
-
- for (i = 0; i < hash->table_size; i++){
- Slot *s;
-
- for (s = hash->table [i]; s != NULL; s = s->next)
- if ((*predicate)(s->key, s->value, user_data))
- return s->value;
- }
- return NULL;
-}
-
-void
-g_hash_table_remove_all (GHashTable *hash)
-{
- int i;
-
- g_return_if_fail (hash != NULL);
-
- for (i = 0; i < hash->table_size; i++){
- Slot *s;
-
- while (hash->table [i]) {
- s = hash->table [i];
- g_hash_table_remove (hash, s->key);
- }
- }
-}
-
-gboolean
-g_hash_table_remove (GHashTable *hash, gconstpointer key)
-{
- GEqualFunc equal;
- Slot *s, *last;
- guint hashcode;
-
- g_return_val_if_fail (hash != NULL, FALSE);
- sanity_check (hash);
- equal = hash->key_equal_func;
-
- hashcode = ((*hash->hash_func)(key)) % hash->table_size;
- last = NULL;
- for (s = hash->table [hashcode]; s != NULL; s = s->next){
- if ((*equal)(s->key, key)){
- if (hash->key_destroy_func != NULL)
- (*hash->key_destroy_func)(s->key);
- if (hash->value_destroy_func != NULL)
- (*hash->value_destroy_func)(s->value);
- if (last == NULL)
- hash->table [hashcode] = s->next;
- else
- last->next = s->next;
- g_free (s);
- hash->in_use--;
- sanity_check (hash);
- return TRUE;
- }
- last = s;
- }
- sanity_check (hash);
- return FALSE;
-}
-
-guint
-g_hash_table_foreach_remove (GHashTable *hash, GHRFunc func, gpointer user_data)
-{
- int i;
- int count = 0;
-
- g_return_val_if_fail (hash != NULL, 0);
- g_return_val_if_fail (func != NULL, 0);
-
- sanity_check (hash);
- for (i = 0; i < hash->table_size; i++){
- Slot *s, *last;
-
- last = NULL;
- for (s = hash->table [i]; s != NULL; ){
- if ((*func)(s->key, s->value, user_data)){
- Slot *n;
-
- if (hash->key_destroy_func != NULL)
- (*hash->key_destroy_func)(s->key);
- if (hash->value_destroy_func != NULL)
- (*hash->value_destroy_func)(s->value);
- if (last == NULL){
- hash->table [i] = s->next;
- n = s->next;
- } else {
- last->next = s->next;
- n = last->next;
- }
- g_free (s);
- hash->in_use--;
- count++;
- s = n;
- } else {
- last = s;
- s = s->next;
- }
- }
- }
- sanity_check (hash);
- if (count > 0)
- rehash (hash);
- return count;
-}
-
-gboolean
-g_hash_table_steal (GHashTable *hash, gconstpointer key)
-{
- GEqualFunc equal;
- Slot *s, *last;
- guint hashcode;
-
- g_return_val_if_fail (hash != NULL, FALSE);
- sanity_check (hash);
- equal = hash->key_equal_func;
-
- hashcode = ((*hash->hash_func)(key)) % hash->table_size;
- last = NULL;
- for (s = hash->table [hashcode]; s != NULL; s = s->next){
- if ((*equal)(s->key, key)) {
- if (last == NULL)
- hash->table [hashcode] = s->next;
- else
- last->next = s->next;
- g_free (s);
- hash->in_use--;
- sanity_check (hash);
- return TRUE;
- }
- last = s;
- }
- sanity_check (hash);
- return FALSE;
-
-}
-
-guint
-g_hash_table_foreach_steal (GHashTable *hash, GHRFunc func, gpointer user_data)
-{
- int i;
- int count = 0;
-
- g_return_val_if_fail (hash != NULL, 0);
- g_return_val_if_fail (func != NULL, 0);
-
- sanity_check (hash);
- for (i = 0; i < hash->table_size; i++){
- Slot *s, *last;
-
- last = NULL;
- for (s = hash->table [i]; s != NULL; ){
- if ((*func)(s->key, s->value, user_data)){
- Slot *n;
-
- if (last == NULL){
- hash->table [i] = s->next;
- n = s->next;
- } else {
- last->next = s->next;
- n = last->next;
- }
- g_free (s);
- hash->in_use--;
- count++;
- s = n;
- } else {
- last = s;
- s = s->next;
- }
- }
- }
- sanity_check (hash);
- if (count > 0)
- rehash (hash);
- return count;
-}
-
-void
-g_hash_table_destroy (GHashTable *hash)
-{
- int i;
-
- g_return_if_fail (hash != NULL);
-
- for (i = 0; i < hash->table_size; i++){
- Slot *s, *next;
-
- for (s = hash->table [i]; s != NULL; s = next){
- next = s->next;
-
- if (hash->key_destroy_func != NULL)
- (*hash->key_destroy_func)(s->key);
- if (hash->value_destroy_func != NULL)
- (*hash->value_destroy_func)(s->value);
- g_free (s);
- }
- }
- g_free (hash->table);
-
- g_free (hash);
-}
-
-void
-g_hash_table_print_stats (GHashTable *table)
-{
- int i, max_chain_index, chain_size, max_chain_size;
- Slot *node;
-
- max_chain_size = 0;
- max_chain_index = -1;
- for (i = 0; i < table->table_size; i++) {
- chain_size = 0;
- for (node = table->table [i]; node; node = node->next)
- chain_size ++;
- if (chain_size > max_chain_size) {
- max_chain_size = chain_size;
- max_chain_index = i;
- }
- }
-
- printf ("Size: %d Table Size: %d Max Chain Length: %d at %d\n", table->in_use, table->table_size, max_chain_size, max_chain_index);
-}
-
-void
-g_hash_table_iter_init (GHashTableIter *it, GHashTable *hash_table)
-{
- Iter *iter = (Iter*)it;
-
- memset (iter, 0, sizeof (Iter));
- iter->ht = hash_table;
- iter->slot_index = -1;
-}
-
-gboolean g_hash_table_iter_next (GHashTableIter *it, gpointer *key, gpointer *value)
-{
- Iter *iter = (Iter*)it;
-
- GHashTable *hash = iter->ht;
-
- g_assert (iter->slot_index != -2);
- g_assert (sizeof (Iter) <= sizeof (GHashTableIter));
-
- if (!iter->slot) {
- while (TRUE) {
- iter->slot_index ++;
- if (iter->slot_index >= hash->table_size) {
- iter->slot_index = -2;
- return FALSE;
- }
- if (hash->table [iter->slot_index])
- break;
- }
- iter->slot = hash->table [iter->slot_index];
- }
-
- if (key)
- *key = iter->slot->key;
- if (value)
- *value = iter->slot->value;
- iter->slot = iter->slot->next;
-
- return TRUE;
-}
-
-gboolean
-g_direct_equal (gconstpointer v1, gconstpointer v2)
-{
- return v1 == v2;
-}
-
-guint
-g_direct_hash (gconstpointer v1)
-{
- return GPOINTER_TO_UINT (v1);
-}
-
-gboolean
-g_int_equal (gconstpointer v1, gconstpointer v2)
-{
- return *(gint *)v1 == *(gint *)v2;
-}
-
-guint
-g_int_hash (gconstpointer v1)
-{
- return *(guint *)v1;
-}
-
-gboolean
-g_str_equal (gconstpointer v1, gconstpointer v2)
-{
- return strcmp (v1, v2) == 0;
-}
-
-guint
-g_str_hash (gconstpointer v1)
-{
- guint hash = 0;
- char *p = (char *) v1;
-
- while (*p++)
- hash = (hash << 5) - (hash + *p);
-
- return hash;
-}
+++ /dev/null
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Copyright (C) 2011 Jeffrey Stedfast
- *
- * Permission is hereby granted, free of charge, to any person
- * obtaining a copy of this software and associated documentation
- * files (the "Software"), to deal in the Software without
- * restriction, including without limitation the rights to use, copy,
- * modify, merge, publish, distribute, sublicense, and/or sell copies
- * of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
- * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <glib.h>
-#include <string.h>
-#ifdef HAVE_ICONV_H
-#include <iconv.h>
-#endif
-#include <errno.h>
-
-#ifdef _MSC_VER
-#define FORCE_INLINE(RET_TYPE) __forceinline RET_TYPE
-#else
-#define FORCE_INLINE(RET_TYPE) inline RET_TYPE __attribute__((always_inline))
-#endif
-
-
-#define UNROLL_DECODE_UTF8 0
-#define UNROLL_ENCODE_UTF8 0
-
-typedef int (* Decoder) (char *inbuf, size_t inleft, gunichar *outchar);
-typedef int (* Encoder) (gunichar c, char *outbuf, size_t outleft);
-
-struct _GIConv {
- Decoder decode;
- Encoder encode;
- gunichar c;
-#ifdef HAVE_ICONV
- iconv_t cd;
-#endif
-};
-
-static int decode_utf32be (char *inbuf, size_t inleft, gunichar *outchar);
-static int encode_utf32be (gunichar c, char *outbuf, size_t outleft);
-
-static int decode_utf32le (char *inbuf, size_t inleft, gunichar *outchar);
-static int encode_utf32le (gunichar c, char *outbuf, size_t outleft);
-
-static int decode_utf16be (char *inbuf, size_t inleft, gunichar *outchar);
-static int encode_utf16be (gunichar c, char *outbuf, size_t outleft);
-
-static int decode_utf16le (char *inbuf, size_t inleft, gunichar *outchar);
-static int encode_utf16le (gunichar c, char *outbuf, size_t outleft);
-
-static FORCE_INLINE (int) decode_utf8 (char *inbuf, size_t inleft, gunichar *outchar);
-static int encode_utf8 (gunichar c, char *outbuf, size_t outleft);
-
-static int decode_latin1 (char *inbuf, size_t inleft, gunichar *outchar);
-static int encode_latin1 (gunichar c, char *outbuf, size_t outleft);
-
-#if G_BYTE_ORDER == G_LITTLE_ENDIAN
-#define decode_utf32 decode_utf32le
-#define encode_utf32 encode_utf32le
-#define decode_utf16 decode_utf16le
-#define encode_utf16 encode_utf16le
-#else
-#define decode_utf32 decode_utf32be
-#define encode_utf32 encode_utf32be
-#define decode_utf16 decode_utf16be
-#define encode_utf16 encode_utf16be
-#endif
-
-static struct {
- const char *name;
- Decoder decoder;
- Encoder encoder;
-} charsets[] = {
- { "ISO-8859-1", decode_latin1, encode_latin1 },
- { "ISO8859-1", decode_latin1, encode_latin1 },
- { "UTF-32BE", decode_utf32be, encode_utf32be },
- { "UTF-32LE", decode_utf32le, encode_utf32le },
- { "UTF-16BE", decode_utf16be, encode_utf16be },
- { "UTF-16LE", decode_utf16le, encode_utf16le },
- { "UTF-32", decode_utf32, encode_utf32 },
- { "UTF-16", decode_utf16, encode_utf16 },
- { "UTF-8", decode_utf8, encode_utf8 },
- { "US-ASCII", decode_latin1, encode_latin1 },
- { "Latin1", decode_latin1, encode_latin1 },
- { "ASCII", decode_latin1, encode_latin1 },
- { "UTF32", decode_utf32, encode_utf32 },
- { "UTF16", decode_utf16, encode_utf16 },
- { "UTF8", decode_utf8, encode_utf8 },
-};
-
-
-GIConv
-g_iconv_open (const char *to_charset, const char *from_charset)
-{
-#ifdef HAVE_ICONV
- iconv_t icd = (iconv_t) -1;
-#endif
- Decoder decoder = NULL;
- Encoder encoder = NULL;
- GIConv cd;
- guint i;
-
- if (!to_charset || !from_charset || !to_charset[0] || !from_charset[0]) {
- errno = EINVAL;
-
- return (GIConv) -1;
- }
-
- for (i = 0; i < G_N_ELEMENTS (charsets); i++) {
- if (!g_ascii_strcasecmp (charsets[i].name, from_charset))
- decoder = charsets[i].decoder;
-
- if (!g_ascii_strcasecmp (charsets[i].name, to_charset))
- encoder = charsets[i].encoder;
- }
-
- if (!encoder || !decoder) {
-#ifdef HAVE_ICONV
- if ((icd = iconv_open (to_charset, from_charset)) == (iconv_t) -1)
- return (GIConv) -1;
-#else
- errno = EINVAL;
-
- return (GIConv) -1;
-#endif
- }
-
- cd = (GIConv) g_malloc (sizeof (struct _GIConv));
- cd->decode = decoder;
- cd->encode = encoder;
- cd->c = -1;
-
-#ifdef HAVE_ICONV
- cd->cd = icd;
-#endif
-
- return cd;
-}
-
-int
-g_iconv_close (GIConv cd)
-{
-#ifdef HAVE_ICONV
- if (cd->cd != (iconv_t) -1)
- iconv_close (cd->cd);
-#endif
-
- g_free (cd);
-
- return 0;
-}
-
-gsize
-g_iconv (GIConv cd, gchar **inbytes, gsize *inbytesleft,
- gchar **outbytes, gsize *outbytesleft)
-{
- gsize inleft, outleft;
- char *inptr, *outptr;
- gunichar c;
- int rc = 0;
-
-#ifdef HAVE_ICONV
- if (cd->cd != (iconv_t) -1) {
- /* Note: gsize may have a different size than size_t, so we need to
- remap inbytesleft and outbytesleft to size_t's. */
- size_t *outleftptr, *inleftptr;
- size_t n_outleft, n_inleft;
-
- if (inbytesleft) {
- n_inleft = *inbytesleft;
- inleftptr = &n_inleft;
- } else {
- inleftptr = NULL;
- }
-
- if (outbytesleft) {
- n_outleft = *outbytesleft;
- outleftptr = &n_outleft;
- } else {
- outleftptr = NULL;
- }
-#if defined(__NetBSD__)
- return iconv (cd->cd, (const gchar **)inbytes, inleftptr, outbytes, outleftptr);
-#else
- return iconv (cd->cd, inbytes, inleftptr, outbytes, outleftptr);
-#endif
- }
-#endif
-
- if (outbytes == NULL || outbytesleft == NULL) {
- /* reset converter */
- cd->c = -1;
- return 0;
- }
-
- inleft = inbytesleft ? *inbytesleft : 0;
- inptr = inbytes ? *inbytes : NULL;
- outleft = *outbytesleft;
- outptr = *outbytes;
-
- if ((c = cd->c) != (gunichar) -1)
- goto encode;
-
- while (inleft > 0) {
- if ((rc = cd->decode (inptr, inleft, &c)) < 0)
- break;
-
- inleft -= rc;
- inptr += rc;
-
- encode:
- if ((rc = cd->encode (c, outptr, outleft)) < 0)
- break;
-
- c = (gunichar) -1;
- outleft -= rc;
- outptr += rc;
- }
-
- if (inbytesleft)
- *inbytesleft = inleft;
-
- if (inbytes)
- *inbytes = inptr;
-
- *outbytesleft = outleft;
- *outbytes = outptr;
- cd->c = c;
-
- return rc < 0 ? -1 : 0;
-}
-
-/*
- * Unicode encoders and decoders
- */
-
-static int
-decode_utf32be (char *inbuf, size_t inleft, gunichar *outchar)
-{
- unsigned char *inptr = (unsigned char *) inbuf;
- gunichar c;
-
- if (inleft < 4) {
- errno = EINVAL;
- return -1;
- }
-
- c = (inptr[0] << 24) | (inptr[1] << 16) | (inptr[2] << 8) | inptr[3];
-
- if (c >= 0xd800 && c < 0xe000) {
- errno = EILSEQ;
- return -1;
- } else if (c >= 0x110000) {
- errno = EILSEQ;
- return -1;
- }
-
- *outchar = c;
-
- return 4;
-}
-
-static int
-decode_utf32le (char *inbuf, size_t inleft, gunichar *outchar)
-{
- unsigned char *inptr = (unsigned char *) inbuf;
- gunichar c;
-
- if (inleft < 4) {
- errno = EINVAL;
- return -1;
- }
-
- c = (inptr[3] << 24) | (inptr[2] << 16) | (inptr[1] << 8) | inptr[0];
-
- if (c >= 0xd800 && c < 0xe000) {
- errno = EILSEQ;
- return -1;
- } else if (c >= 0x110000) {
- errno = EILSEQ;
- return -1;
- }
-
- *outchar = c;
-
- return 4;
-}
-
-static int
-encode_utf32be (gunichar c, char *outbuf, size_t outleft)
-{
- unsigned char *outptr = (unsigned char *) outbuf;
-
- if (outleft < 4) {
- errno = E2BIG;
- return -1;
- }
-
- outptr[0] = (c >> 24) & 0xff;
- outptr[1] = (c >> 16) & 0xff;
- outptr[2] = (c >> 8) & 0xff;
- outptr[3] = c & 0xff;
-
- return 4;
-}
-
-static int
-encode_utf32le (gunichar c, char *outbuf, size_t outleft)
-{
- unsigned char *outptr = (unsigned char *) outbuf;
-
- if (outleft < 4) {
- errno = E2BIG;
- return -1;
- }
-
- outptr[0] = c & 0xff;
- outptr[1] = (c >> 8) & 0xff;
- outptr[2] = (c >> 16) & 0xff;
- outptr[3] = (c >> 24) & 0xff;
-
- return 4;
-}
-
-static int
-decode_utf16be (char *inbuf, size_t inleft, gunichar *outchar)
-{
- unsigned char *inptr = (unsigned char *) inbuf;
- gunichar2 c;
- gunichar u;
-
- if (inleft < 2) {
- errno = EINVAL;
- return -1;
- }
-
- u = (inptr[0] << 8) | inptr[1];
-
- if (u < 0xd800) {
- /* 0x0000 -> 0xd7ff */
- *outchar = u;
- return 2;
- } else if (u < 0xdc00) {
- /* 0xd800 -> 0xdbff */
- if (inleft < 4) {
- errno = EINVAL;
- return -2;
- }
-
- c = (inptr[2] << 8) | inptr[3];
-
- if (c < 0xdc00 || c > 0xdfff) {
- errno = EILSEQ;
- return -2;
- }
-
- u = ((u - 0xd800) << 10) + (c - 0xdc00) + 0x0010000UL;
- *outchar = u;
-
- return 4;
- } else if (u < 0xe000) {
- /* 0xdc00 -> 0xdfff */
- errno = EILSEQ;
- return -1;
- } else {
- /* 0xe000 -> 0xffff */
- *outchar = u;
- return 2;
- }
-}
-
-static int
-decode_utf16le (char *inbuf, size_t inleft, gunichar *outchar)
-{
- unsigned char *inptr = (unsigned char *) inbuf;
- gunichar2 c;
- gunichar u;
-
- if (inleft < 2) {
- errno = EINVAL;
- return -1;
- }
-
- u = (inptr[1] << 8) | inptr[0];
-
- if (u < 0xd800) {
- /* 0x0000 -> 0xd7ff */
- *outchar = u;
- return 2;
- } else if (u < 0xdc00) {
- /* 0xd800 -> 0xdbff */
- if (inleft < 4) {
- errno = EINVAL;
- return -2;
- }
-
- c = (inptr[3] << 8) | inptr[2];
-
- if (c < 0xdc00 || c > 0xdfff) {
- errno = EILSEQ;
- return -2;
- }
-
- u = ((u - 0xd800) << 10) + (c - 0xdc00) + 0x0010000UL;
- *outchar = u;
-
- return 4;
- } else if (u < 0xe000) {
- /* 0xdc00 -> 0xdfff */
- errno = EILSEQ;
- return -1;
- } else {
- /* 0xe000 -> 0xffff */
- *outchar = u;
- return 2;
- }
-}
-
-static int
-encode_utf16be (gunichar c, char *outbuf, size_t outleft)
-{
- unsigned char *outptr = (unsigned char *) outbuf;
- gunichar2 ch;
- gunichar c2;
-
- if (c < 0x10000) {
- if (outleft < 2) {
- errno = E2BIG;
- return -1;
- }
-
- outptr[0] = (c >> 8) & 0xff;
- outptr[1] = c & 0xff;
-
- return 2;
- } else {
- if (outleft < 4) {
- errno = E2BIG;
- return -1;
- }
-
- c2 = c - 0x10000;
-
- ch = (gunichar2) ((c2 >> 10) + 0xd800);
- outptr[0] = (ch >> 8) & 0xff;
- outptr[1] = ch & 0xff;
-
- ch = (gunichar2) ((c2 & 0x3ff) + 0xdc00);
- outptr[2] = (ch >> 8) & 0xff;
- outptr[3] = ch & 0xff;
-
- return 4;
- }
-}
-
-static int
-encode_utf16le (gunichar c, char *outbuf, size_t outleft)
-{
- unsigned char *outptr = (unsigned char *) outbuf;
- gunichar2 ch;
- gunichar c2;
-
- if (c < 0x10000) {
- if (outleft < 2) {
- errno = E2BIG;
- return -1;
- }
-
- outptr[0] = c & 0xff;
- outptr[1] = (c >> 8) & 0xff;
-
- return 2;
- } else {
- if (outleft < 4) {
- errno = E2BIG;
- return -1;
- }
-
- c2 = c - 0x10000;
-
- ch = (gunichar2) ((c2 >> 10) + 0xd800);
- outptr[0] = ch & 0xff;
- outptr[1] = (ch >> 8) & 0xff;
-
- ch = (gunichar2) ((c2 & 0x3ff) + 0xdc00);
- outptr[2] = ch & 0xff;
- outptr[3] = (ch >> 8) & 0xff;
-
- return 4;
- }
-}
-
-static FORCE_INLINE (int)
-decode_utf8 (char *inbuf, size_t inleft, gunichar *outchar)
-{
- unsigned char *inptr = (unsigned char *) inbuf;
- gunichar u;
- int n, i;
-
- u = *inptr;
-
- if (u < 0x80) {
- /* simple ascii case */
- *outchar = u;
- return 1;
- } else if (u < 0xc2) {
- errno = EILSEQ;
- return -1;
- } else if (u < 0xe0) {
- u &= 0x1f;
- n = 2;
- } else if (u < 0xf0) {
- u &= 0x0f;
- n = 3;
- } else if (u < 0xf8) {
- u &= 0x07;
- n = 4;
- } else if (u < 0xfc) {
- u &= 0x03;
- n = 5;
- } else if (u < 0xfe) {
- u &= 0x01;
- n = 6;
- } else {
- errno = EILSEQ;
- return -1;
- }
-
- if (n > inleft) {
- errno = EINVAL;
- return -1;
- }
-
-#if UNROLL_DECODE_UTF8
- switch (n) {
- case 6: u = (u << 6) | (*++inptr ^ 0x80);
- case 5: u = (u << 6) | (*++inptr ^ 0x80);
- case 4: u = (u << 6) | (*++inptr ^ 0x80);
- case 3: u = (u << 6) | (*++inptr ^ 0x80);
- case 2: u = (u << 6) | (*++inptr ^ 0x80);
- }
-#else
- for (i = 1; i < n; i++)
- u = (u << 6) | (*++inptr ^ 0x80);
-#endif
-
- *outchar = u;
-
- return n;
-}
-
-static int
-encode_utf8 (gunichar c, char *outbuf, size_t outleft)
-{
- unsigned char *outptr = (unsigned char *) outbuf;
- int base, n, i;
-
- if (c < 0x80) {
- outptr[0] = c;
- return 1;
- } else if (c < 0x800) {
- base = 192;
- n = 2;
- } else if (c < 0x10000) {
- base = 224;
- n = 3;
- } else if (c < 0x200000) {
- base = 240;
- n = 4;
- } else if (c < 0x4000000) {
- base = 248;
- n = 5;
- } else {
- base = 252;
- n = 6;
- }
-
- if (outleft < n) {
- errno = E2BIG;
- return -1;
- }
-
-#if UNROLL_ENCODE_UTF8
- switch (n) {
- case 6: outptr[5] = (c & 0x3f) | 0x80; c >>= 6;
- case 5: outptr[4] = (c & 0x3f) | 0x80; c >>= 6;
- case 4: outptr[3] = (c & 0x3f) | 0x80; c >>= 6;
- case 3: outptr[2] = (c & 0x3f) | 0x80; c >>= 6;
- case 2: outptr[1] = (c & 0x3f) | 0x80; c >>= 6;
- case 1: outptr[0] = c | base;
- }
-#else
- for (i = n - 1; i > 0; i--) {
- outptr[i] = (c & 0x3f) | 0x80;
- c >>= 6;
- }
-
- outptr[0] = c | base;
-#endif
-
- return n;
-}
-
-static int
-decode_latin1 (char *inbuf, size_t inleft, gunichar *outchar)
-{
- *outchar = (unsigned char) *inbuf;
- return 1;
-}
-
-static int
-encode_latin1 (gunichar c, char *outbuf, size_t outleft)
-{
- if (outleft < 1) {
- errno = E2BIG;
- return -1;
- }
-
- if (c > 0xff) {
- errno = EILSEQ;
- return -1;
- }
-
- *outbuf = (char) c;
-
- return 1;
-}
-
-
-/*
- * Simple conversion API
- */
-
-static gpointer error_quark = "ConvertError";
-
-gpointer
-g_convert_error_quark (void)
-{
- return error_quark;
-}
-
-gchar *
-g_convert (const gchar *str, gssize len, const gchar *to_charset, const gchar *from_charset,
- gsize *bytes_read, gsize *bytes_written, GError **err)
-{
- gsize outsize, outused, outleft, inleft, grow, rc;
- char *result, *outbuf, *inbuf;
- gboolean flush = FALSE;
- gboolean done = FALSE;
- GIConv cd;
-
- g_return_val_if_fail (str != NULL, NULL);
- g_return_val_if_fail (to_charset != NULL, NULL);
- g_return_val_if_fail (from_charset != NULL, NULL);
-
- if ((cd = g_iconv_open (to_charset, from_charset)) == (GIConv) -1) {
- g_set_error (err, G_CONVERT_ERROR, G_CONVERT_ERROR_NO_CONVERSION,
- "Conversion from %s to %s not supported.",
- from_charset, to_charset);
-
- if (bytes_written)
- *bytes_written = 0;
-
- if (bytes_read)
- *bytes_read = 0;
-
- return NULL;
- }
-
- inleft = len < 0 ? strlen (str) : len;
- inbuf = (char *) str;
-
- outleft = outsize = MAX (inleft, 8);
- outbuf = result = g_malloc (outsize + 4);
-
- do {
- if (!flush)
- rc = g_iconv (cd, &inbuf, &inleft, &outbuf, &outleft);
- else
- rc = g_iconv (cd, NULL, NULL, &outbuf, &outleft);
-
- if (rc == (gsize) -1) {
- switch (errno) {
- case E2BIG:
- /* grow our result buffer */
- grow = MAX (inleft, 8) << 1;
- outused = outbuf - result;
- outsize += grow;
- outleft += grow;
- result = g_realloc (result, outsize + 4);
- outbuf = result + outused;
- break;
- case EINVAL:
- /* incomplete input, stop converting and terminate here */
- if (flush)
- done = TRUE;
- else
- flush = TRUE;
- break;
- case EILSEQ:
- /* illegal sequence in the input */
- g_set_error (err, G_CONVERT_ERROR, G_CONVERT_ERROR_ILLEGAL_SEQUENCE, "%s", g_strerror (errno));
-
- if (bytes_read) {
- /* save offset of the illegal input sequence */
- *bytes_read = (inbuf - str);
- }
-
- if (bytes_written)
- *bytes_written = 0;
-
- g_iconv_close (cd);
- g_free (result);
- return NULL;
- default:
- /* unknown errno */
- g_set_error (err, G_CONVERT_ERROR, G_CONVERT_ERROR_FAILED, "%s", g_strerror (errno));
-
- if (bytes_written)
- *bytes_written = 0;
-
- if (bytes_read)
- *bytes_read = 0;
-
- g_iconv_close (cd);
- g_free (result);
- return NULL;
- }
- } else if (flush) {
- /* input has been converted and output has been flushed */
- break;
- } else {
- /* input has been converted, need to flush the output */
- flush = TRUE;
- }
- } while (!done);
-
- g_iconv_close (cd);
-
- /* Note: not all charsets can be null-terminated with a single
- null byte. UCS2, for example, needs 2 null bytes and UCS4
- needs 4. I hope that 4 null bytes is enough to terminate all
- multibyte charsets? */
-
- /* null-terminate the result */
- memset (outbuf, 0, 4);
-
- if (bytes_written)
- *bytes_written = outbuf - result;
-
- if (bytes_read)
- *bytes_read = inbuf - str;
-
- return result;
-}
-
-
-/*
- * Unicode conversion
- */
-
-/**
- * An explanation of the conversion can be found at:
- * http://home.tiscali.nl/t876506/utf8tbl.html
- *
- **/
-gint
-g_unichar_to_utf8 (gunichar c, gchar *outbuf)
-{
- int base, n, i;
-
- if (c < 0x80) {
- base = 0;
- n = 1;
- } else if (c < 0x800) {
- base = 192;
- n = 2;
- } else if (c < 0x10000) {
- base = 224;
- n = 3;
- } else if (c < 0x200000) {
- base = 240;
- n = 4;
- } else if (c < 0x4000000) {
- base = 248;
- n = 5;
- } else if (c < 0x80000000) {
- base = 252;
- n = 6;
- } else {
- return -1;
- }
-
- if (outbuf != NULL) {
- for (i = n - 1; i > 0; i--) {
- /* mask off 6 bits worth and add 128 */
- outbuf[i] = (c & 0x3f) | 0x80;
- c >>= 6;
- }
-
- /* first character has a different base */
- outbuf[0] = c | base;
- }
-
- return n;
-}
-
-static FORCE_INLINE (int)
-g_unichar_to_utf16 (gunichar c, gunichar2 *outbuf)
-{
- gunichar c2;
-
- if (c < 0xd800) {
- if (outbuf)
- *outbuf = (gunichar2) c;
-
- return 1;
- } else if (c < 0xe000) {
- return -1;
- } else if (c < 0x10000) {
- if (outbuf)
- *outbuf = (gunichar2) c;
-
- return 1;
- } else if (c < 0x110000) {
- if (outbuf) {
- c2 = c - 0x10000;
-
- outbuf[0] = (gunichar2) ((c2 >> 10) + 0xd800);
- outbuf[1] = (gunichar2) ((c2 & 0x3ff) + 0xdc00);
- }
-
- return 2;
- } else {
- return -1;
- }
-}
-
-gunichar *
-g_utf8_to_ucs4_fast (const gchar *str, glong len, glong *items_written)
-{
- gunichar *outbuf, *outptr;
- char *inptr;
- glong n, i;
-
- g_return_val_if_fail (str != NULL, NULL);
-
- n = g_utf8_strlen (str, len);
-
- if (items_written)
- *items_written = n;
-
- outptr = outbuf = g_malloc ((n + 1) * sizeof (gunichar));
- inptr = (char *) str;
-
- for (i = 0; i < n; i++) {
- *outptr++ = g_utf8_get_char (inptr);
- inptr = g_utf8_next_char (inptr);
- }
-
- *outptr = 0;
-
- return outbuf;
-}
-
-static gunichar2 *
-eg_utf8_to_utf16_general (const gchar *str, glong len, glong *items_read, glong *items_written, gboolean include_nuls, GError **err)
-{
- gunichar2 *outbuf, *outptr;
- size_t outlen = 0;
- size_t inleft;
- char *inptr;
- gunichar c;
- int u, n;
-
- g_return_val_if_fail (str != NULL, NULL);
-
- if (len < 0) {
- if (include_nuls) {
- g_set_error (err, G_CONVERT_ERROR, G_CONVERT_ERROR_FAILED, "Conversions with embedded nulls must pass the string length");
- return NULL;
- }
-
- len = strlen (str);
- }
-
- inptr = (char *) str;
- inleft = len;
-
- while (inleft > 0) {
- if ((n = decode_utf8 (inptr, inleft, &c)) < 0)
- goto error;
-
- if (c == 0 && !include_nuls)
- break;
-
- if ((u = g_unichar_to_utf16 (c, NULL)) < 0) {
- errno = EILSEQ;
- goto error;
- }
-
- outlen += u;
- inleft -= n;
- inptr += n;
- }
-
- if (items_read)
- *items_read = inptr - str;
-
- if (items_written)
- *items_written = outlen;
-
- outptr = outbuf = g_malloc ((outlen + 1) * sizeof (gunichar2));
- inptr = (char *) str;
- inleft = len;
-
- while (inleft > 0) {
- if ((n = decode_utf8 (inptr, inleft, &c)) < 0)
- break;
-
- if (c == 0 && !include_nuls)
- break;
-
- outptr += g_unichar_to_utf16 (c, outptr);
- inleft -= n;
- inptr += n;
- }
-
- *outptr = '\0';
-
- return outbuf;
-
- error:
- if (errno == EILSEQ) {
- g_set_error (err, G_CONVERT_ERROR, G_CONVERT_ERROR_ILLEGAL_SEQUENCE,
- "Illegal byte sequence encounted in the input.");
- } else if (items_read) {
- /* partial input is ok if we can let our caller know... */
- } else {
- g_set_error (err, G_CONVERT_ERROR, G_CONVERT_ERROR_PARTIAL_INPUT,
- "Partial byte sequence encountered in the input.");
- }
-
- if (items_read)
- *items_read = inptr - str;
-
- if (items_written)
- *items_written = 0;
-
- return NULL;
-}
-
-gunichar2 *
-g_utf8_to_utf16 (const gchar *str, glong len, glong *items_read, glong *items_written, GError **err)
-{
- return eg_utf8_to_utf16_general (str, len, items_read, items_written, FALSE, err);
-}
-
-gunichar2 *
-eg_utf8_to_utf16_with_nuls (const gchar *str, glong len, glong *items_read, glong *items_written, GError **err)
-{
- return eg_utf8_to_utf16_general (str, len, items_read, items_written, TRUE, err);
-}
-
-gunichar *
-g_utf8_to_ucs4 (const gchar *str, glong len, glong *items_read, glong *items_written, GError **err)
-{
- gunichar *outbuf, *outptr;
- size_t outlen = 0;
- size_t inleft;
- char *inptr;
- gunichar c;
- int n;
-
- g_return_val_if_fail (str != NULL, NULL);
-
- if (len < 0)
- len = strlen (str);
-
- inptr = (char *) str;
- inleft = len;
-
- while (inleft > 0) {
- if ((n = decode_utf8 (inptr, inleft, &c)) < 0) {
- if (errno == EILSEQ) {
- g_set_error (err, G_CONVERT_ERROR, G_CONVERT_ERROR_ILLEGAL_SEQUENCE,
- "Illegal byte sequence encounted in the input.");
- } else if (items_read) {
- /* partial input is ok if we can let our caller know... */
- break;
- } else {
- g_set_error (err, G_CONVERT_ERROR, G_CONVERT_ERROR_PARTIAL_INPUT,
- "Partial byte sequence encountered in the input.");
- }
-
- if (items_read)
- *items_read = inptr - str;
-
- if (items_written)
- *items_written = 0;
-
- return NULL;
- } else if (c == 0)
- break;
-
- outlen += 4;
- inleft -= n;
- inptr += n;
- }
-
- if (items_written)
- *items_written = outlen / 4;
-
- if (items_read)
- *items_read = inptr - str;
-
- outptr = outbuf = g_malloc (outlen + 4);
- inptr = (char *) str;
- inleft = len;
-
- while (inleft > 0) {
- if ((n = decode_utf8 (inptr, inleft, &c)) < 0)
- break;
- else if (c == 0)
- break;
-
- *outptr++ = c;
- inleft -= n;
- inptr += n;
- }
-
- *outptr = 0;
-
- return outbuf;
-}
-
-gchar *
-g_utf16_to_utf8 (const gunichar2 *str, glong len, glong *items_read, glong *items_written, GError **err)
-{
- char *inptr, *outbuf, *outptr;
- size_t outlen = 0;
- size_t inleft;
- gunichar c;
- int n;
-
- g_return_val_if_fail (str != NULL, NULL);
-
- if (len < 0) {
- len = 0;
- while (str[len])
- len++;
- }
-
- inptr = (char *) str;
- inleft = len * 2;
-
- while (inleft > 0) {
- if ((n = decode_utf16 (inptr, inleft, &c)) < 0) {
- if (n == -2 && inleft > 2) {
- /* This means that the first UTF-16 char was read, but second failed */
- inleft -= 2;
- inptr += 2;
- }
-
- if (errno == EILSEQ) {
- g_set_error (err, G_CONVERT_ERROR, G_CONVERT_ERROR_ILLEGAL_SEQUENCE,
- "Illegal byte sequence encounted in the input.");
- } else if (items_read) {
- /* partial input is ok if we can let our caller know... */
- break;
- } else {
- g_set_error (err, G_CONVERT_ERROR, G_CONVERT_ERROR_PARTIAL_INPUT,
- "Partial byte sequence encountered in the input.");
- }
-
- if (items_read)
- *items_read = (inptr - (char *) str) / 2;
-
- if (items_written)
- *items_written = 0;
-
- return NULL;
- } else if (c == 0)
- break;
-
- outlen += g_unichar_to_utf8 (c, NULL);
- inleft -= n;
- inptr += n;
- }
-
- if (items_read)
- *items_read = (inptr - (char *) str) / 2;
-
- if (items_written)
- *items_written = outlen;
-
- outptr = outbuf = g_malloc (outlen + 1);
- inptr = (char *) str;
- inleft = len * 2;
-
- while (inleft > 0) {
- if ((n = decode_utf16 (inptr, inleft, &c)) < 0)
- break;
- else if (c == 0)
- break;
-
- outptr += g_unichar_to_utf8 (c, outptr);
- inleft -= n;
- inptr += n;
- }
-
- *outptr = '\0';
-
- return outbuf;
-}
-
-gunichar *
-g_utf16_to_ucs4 (const gunichar2 *str, glong len, glong *items_read, glong *items_written, GError **err)
-{
- gunichar *outbuf, *outptr;
- size_t outlen = 0;
- size_t inleft;
- char *inptr;
- gunichar c;
- int n;
-
- g_return_val_if_fail (str != NULL, NULL);
-
- if (len < 0) {
- len = 0;
- while (str[len])
- len++;
- }
-
- inptr = (char *) str;
- inleft = len * 2;
-
- while (inleft > 0) {
- if ((n = decode_utf16 (inptr, inleft, &c)) < 0) {
- if (n == -2 && inleft > 2) {
- /* This means that the first UTF-16 char was read, but second failed */
- inleft -= 2;
- inptr += 2;
- }
-
- if (errno == EILSEQ) {
- g_set_error (err, G_CONVERT_ERROR, G_CONVERT_ERROR_ILLEGAL_SEQUENCE,
- "Illegal byte sequence encounted in the input.");
- } else if (items_read) {
- /* partial input is ok if we can let our caller know... */
- break;
- } else {
- g_set_error (err, G_CONVERT_ERROR, G_CONVERT_ERROR_PARTIAL_INPUT,
- "Partial byte sequence encountered in the input.");
- }
-
- if (items_read)
- *items_read = (inptr - (char *) str) / 2;
-
- if (items_written)
- *items_written = 0;
-
- return NULL;
- } else if (c == 0)
- break;
-
- outlen += 4;
- inleft -= n;
- inptr += n;
- }
-
- if (items_read)
- *items_read = (inptr - (char *) str) / 2;
-
- if (items_written)
- *items_written = outlen / 4;
-
- outptr = outbuf = g_malloc (outlen + 4);
- inptr = (char *) str;
- inleft = len * 2;
-
- while (inleft > 0) {
- if ((n = decode_utf16 (inptr, inleft, &c)) < 0)
- break;
- else if (c == 0)
- break;
-
- *outptr++ = c;
- inleft -= n;
- inptr += n;
- }
-
- *outptr = 0;
-
- return outbuf;
-}
-
-gchar *
-g_ucs4_to_utf8 (const gunichar *str, glong len, glong *items_read, glong *items_written, GError **err)
-{
- char *outbuf, *outptr;
- size_t outlen = 0;
- glong i;
- int n;
-
- g_return_val_if_fail (str != NULL, NULL);
-
- if (len < 0) {
- for (i = 0; str[i] != 0; i++) {
- if ((n = g_unichar_to_utf8 (str[i], NULL)) < 0) {
- g_set_error (err, G_CONVERT_ERROR, G_CONVERT_ERROR_ILLEGAL_SEQUENCE,
- "Illegal byte sequence encounted in the input.");
-
- if (items_written)
- *items_written = 0;
-
- if (items_read)
- *items_read = i;
-
- return NULL;
- }
-
- outlen += n;
- }
- } else {
- for (i = 0; i < len && str[i] != 0; i++) {
- if ((n = g_unichar_to_utf8 (str[i], NULL)) < 0) {
- g_set_error (err, G_CONVERT_ERROR, G_CONVERT_ERROR_ILLEGAL_SEQUENCE,
- "Illegal byte sequence encounted in the input.");
-
- if (items_written)
- *items_written = 0;
-
- if (items_read)
- *items_read = i;
-
- return NULL;
- }
-
- outlen += n;
- }
- }
-
- len = i;
-
- outptr = outbuf = g_malloc (outlen + 1);
- for (i = 0; i < len; i++)
- outptr += g_unichar_to_utf8 (str[i], outptr);
- *outptr = 0;
-
- if (items_written)
- *items_written = outlen;
-
- if (items_read)
- *items_read = i;
-
- return outbuf;
-}
-
-gunichar2 *
-g_ucs4_to_utf16 (const gunichar *str, glong len, glong *items_read, glong *items_written, GError **err)
-{
- gunichar2 *outbuf, *outptr;
- size_t outlen = 0;
- glong i;
- int n;
-
- g_return_val_if_fail (str != NULL, NULL);
-
- if (len < 0) {
- for (i = 0; str[i] != 0; i++) {
- if ((n = g_unichar_to_utf16 (str[i], NULL)) < 0) {
- g_set_error (err, G_CONVERT_ERROR, G_CONVERT_ERROR_ILLEGAL_SEQUENCE,
- "Illegal byte sequence encounted in the input.");
-
- if (items_written)
- *items_written = 0;
-
- if (items_read)
- *items_read = i;
-
- return NULL;
- }
-
- outlen += n;
- }
- } else {
- for (i = 0; i < len && str[i] != 0; i++) {
- if ((n = g_unichar_to_utf16 (str[i], NULL)) < 0) {
- g_set_error (err, G_CONVERT_ERROR, G_CONVERT_ERROR_ILLEGAL_SEQUENCE,
- "Illegal byte sequence encounted in the input.");
-
- if (items_written)
- *items_written = 0;
-
- if (items_read)
- *items_read = i;
-
- return NULL;
- }
-
- outlen += n;
- }
- }
-
- len = i;
-
- outptr = outbuf = g_malloc ((outlen + 1) * sizeof (gunichar2));
- for (i = 0; i < len; i++)
- outptr += g_unichar_to_utf16 (str[i], outptr);
- *outptr = 0;
-
- if (items_written)
- *items_written = outlen;
-
- if (items_read)
- *items_read = i;
-
- return outbuf;
-}
+++ /dev/null
-#ifndef __GLIB_H
-#define __GLIB_H
-#include <stdarg.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdio.h>
-#include <stddef.h>
-#include <ctype.h>
-#include <limits.h>
-
-
-#ifdef _MSC_VER
-#pragma include_alias(<eglib-config.h>, <eglib-config.hw>)
-#endif
-
-#include <stdint.h>
-#include <inttypes.h>
-
-#include <eglib-config.h>
-#ifndef EGLIB_NO_REMAP
-#include <eglib-remap.h>
-#endif
-
-#ifdef G_HAVE_ALLOCA_H
-#include <alloca.h>
-#endif
-
-#ifdef WIN32
-/* For alloca */
-#include <malloc.h>
-#endif
-
-#ifndef offsetof
-# define offsetof(s_name,n_name) (size_t)(char *)&(((s_name*)0)->m_name)
-#endif
-
-#define __EGLIB_X11 1
-
-#ifdef __cplusplus
-#define G_BEGIN_DECLS extern "C" {
-#define G_END_DECLS }
-#else
-#define G_BEGIN_DECLS
-#define G_END_DECLS
-#endif
-
-G_BEGIN_DECLS
-
-/*
- * Basic data types
- */
-typedef int gint;
-typedef unsigned int guint;
-typedef short gshort;
-typedef unsigned short gushort;
-typedef long glong;
-typedef unsigned long gulong;
-typedef void * gpointer;
-typedef const void * gconstpointer;
-typedef char gchar;
-typedef unsigned char guchar;
-
-/* Types defined in terms of the stdint.h */
-typedef int8_t gint8;
-typedef uint8_t guint8;
-typedef int16_t gint16;
-typedef uint16_t guint16;
-typedef int32_t gint32;
-typedef uint32_t guint32;
-typedef int64_t gint64;
-typedef uint64_t guint64;
-typedef float gfloat;
-typedef double gdouble;
-typedef int32_t gboolean;
-
-typedef guint16 gunichar2;
-typedef guint32 gunichar;
-
-/*
- * Macros
- */
-#define G_N_ELEMENTS(s) (sizeof(s) / sizeof ((s) [0]))
-
-#define FALSE 0
-#define TRUE 1
-
-#define G_MINSHORT SHRT_MIN
-#define G_MAXSHORT SHRT_MAX
-#define G_MAXUSHORT USHRT_MAX
-#define G_MAXINT INT_MAX
-#define G_MININT INT_MIN
-#define G_MAXINT32 INT32_MAX
-#define G_MAXUINT32 UINT32_MAX
-#define G_MININT32 INT32_MIN
-#define G_MININT64 INT64_MIN
-#define G_MAXINT64 INT64_MAX
-#define G_MAXUINT64 UINT64_MAX
-
-#define G_LITTLE_ENDIAN 1234
-#define G_BIG_ENDIAN 4321
-#define G_STMT_START do
-#define G_STMT_END while (0)
-
-#define G_USEC_PER_SEC 1000000
-
-#ifndef ABS
-#define ABS(a) ((a) > 0 ? (a) : -(a))
-#endif
-
-#define G_STRUCT_OFFSET(p_type,field) offsetof(p_type,field)
-
-#define EGLIB_STRINGIFY(x) #x
-#define EGLIB_TOSTRING(x) EGLIB_STRINGIFY(x)
-#define G_STRLOC __FILE__ ":" EGLIB_TOSTRING(__LINE__) ":"
-
-#define G_CONST_RETURN const
-
-#define G_GUINT64_FORMAT PRIu64
-#define G_GINT64_FORMAT PRIi64
-#define G_GUINT32_FORMAT PRIu32
-#define G_GINT32_FORMAT PRIi32
-
-/*
- * Allocation
- */
-void g_free (void *ptr);
-gpointer g_realloc (gpointer obj, gsize size);
-gpointer g_malloc (gsize x);
-gpointer g_malloc0 (gsize x);
-gpointer g_calloc (gsize n, gsize x);
-gpointer g_try_malloc (gsize x);
-gpointer g_try_realloc (gpointer obj, gsize size);
-
-#define g_new(type,size) ((type *) g_malloc (sizeof (type) * (size)))
-#define g_new0(type,size) ((type *) g_malloc0 (sizeof (type)* (size)))
-#define g_newa(type,size) ((type *) alloca (sizeof (type) * (size)))
-
-#define g_memmove(dest,src,len) memmove (dest, src, len)
-#define g_renew(struct_type, mem, n_structs) g_realloc (mem, sizeof (struct_type) * n_structs)
-#define g_alloca(size) alloca (size)
-
-gpointer g_memdup (gconstpointer mem, guint byte_size);
-static inline gchar *g_strdup (const gchar *str) { if (str) { return (gchar*) g_memdup (str, (guint)strlen (str) + 1); } return NULL; }
-gchar **g_strdupv (gchar **str_array);
-
-typedef struct {
- gpointer (*malloc) (gsize n_bytes);
- gpointer (*realloc) (gpointer mem, gsize n_bytes);
- void (*free) (gpointer mem);
- gpointer (*calloc) (gsize n_blocks, gsize n_block_bytes);
-} GMemVTable;
-
-void g_mem_set_vtable (GMemVTable* vtable);
-
-struct _GMemChunk {
- guint alloc_size;
-};
-
-typedef struct _GMemChunk GMemChunk;
-/*
- * Misc.
- */
-
-gboolean g_hasenv(const gchar *variable);
-gchar * g_getenv(const gchar *variable);
-gboolean g_setenv(const gchar *variable, const gchar *value, gboolean overwrite);
-void g_unsetenv(const gchar *variable);
-
-gchar* g_win32_getlocale(void);
-
-/*
- * Precondition macros
- */
-#define g_warn_if_fail(x) G_STMT_START { if (!(x)) { g_warning ("%s:%d: assertion '%s' failed", __FILE__, __LINE__, #x); } } G_STMT_END
-#define g_return_if_fail(x) G_STMT_START { if (!(x)) { g_critical ("%s:%d: assertion '%s' failed", __FILE__, __LINE__, #x); return; } } G_STMT_END
-#define g_return_val_if_fail(x,e) G_STMT_START { if (!(x)) { g_critical ("%s:%d: assertion '%s' failed", __FILE__, __LINE__, #x); return (e); } } G_STMT_END
-
-/*
- * Errors
- */
-typedef struct {
- /* In the real glib, this is a GQuark, but we dont use/need that */
- gpointer domain;
- gint code;
- gchar *message;
-} GError;
-
-void g_clear_error (GError **error);
-void g_error_free (GError *error);
-GError *g_error_new (gpointer domain, gint code, const char *format, ...);
-void g_set_error (GError **err, gpointer domain, gint code, const gchar *format, ...);
-void g_propagate_error (GError **dest, GError *src);
-
-/*
- * Strings utility
- */
-gchar *g_strdup_printf (const gchar *format, ...);
-gchar *g_strdup_vprintf (const gchar *format, va_list args);
-gchar *g_strndup (const gchar *str, gsize n);
-const gchar *g_strerror (gint errnum);
-gchar *g_strndup (const gchar *str, gsize n);
-void g_strfreev (gchar **str_array);
-gchar *g_strconcat (const gchar *first, ...);
-gchar **g_strsplit (const gchar *string, const gchar *delimiter, gint max_tokens);
-gchar **g_strsplit_set (const gchar *string, const gchar *delimiter, gint max_tokens);
-gchar *g_strreverse (gchar *str);
-gboolean g_str_has_prefix (const gchar *str, const gchar *prefix);
-gboolean g_str_has_suffix (const gchar *str, const gchar *suffix);
-guint g_strv_length (gchar **str_array);
-gchar *g_strjoin (const gchar *separator, ...);
-gchar *g_strjoinv (const gchar *separator, gchar **str_array);
-gchar *g_strchug (gchar *str);
-gchar *g_strchomp (gchar *str);
-void g_strdown (gchar *string);
-gchar *g_strnfill (gsize length, gchar fill_char);
-
-gchar *g_strdelimit (gchar *string, const gchar *delimiters, gchar new_delimiter);
-gchar *g_strescape (const gchar *source, const gchar *exceptions);
-
-gchar *g_filename_to_uri (const gchar *filename, const gchar *hostname, GError **error);
-gchar *g_filename_from_uri (const gchar *uri, gchar **hostname, GError **error);
-
-gint g_printf (gchar const *format, ...);
-gint g_fprintf (FILE *file, gchar const *format, ...);
-gint g_sprintf (gchar *string, gchar const *format, ...);
-gint g_snprintf (gchar *string, gulong n, gchar const *format, ...);
-gint g_vasprintf (gchar **ret, const gchar *fmt, va_list ap);
-#define g_vprintf vprintf
-#define g_vfprintf vfprintf
-#define g_vsprintf vsprintf
-#define g_vsnprintf vsnprintf
-
-gsize g_strlcpy (gchar *dest, const gchar *src, gsize dest_size);
-gchar *g_stpcpy (gchar *dest, const char *src);
-
-
-gchar g_ascii_tolower (gchar c);
-gchar g_ascii_toupper (gchar c);
-gchar *g_ascii_strdown (const gchar *str, gssize len);
-gchar *g_ascii_strup (const gchar *str, gssize len);
-gint g_ascii_strncasecmp (const gchar *s1, const gchar *s2, gsize n);
-gint g_ascii_strcasecmp (const gchar *s1, const gchar *s2);
-gint g_ascii_xdigit_value (gchar c);
-#define g_ascii_isspace(c) (isspace (c) != 0)
-#define g_ascii_isalpha(c) (isalpha (c) != 0)
-#define g_ascii_isprint(c) (isprint (c) != 0)
-#define g_ascii_isxdigit(c) (isxdigit (c) != 0)
-
-/* FIXME: g_strcasecmp supports utf8 unicode stuff */
-#ifdef _MSC_VER
-#define g_strcasecmp stricmp
-#define g_strncasecmp strnicmp
-#define g_strstrip(a) g_strchug (g_strchomp (a))
-#else
-#define g_strcasecmp strcasecmp
-#define g_ascii_strtoull strtoull
-#define g_strncasecmp strncasecmp
-#define g_strstrip(a) g_strchug (g_strchomp (a))
-#endif
-#define g_ascii_strdup strdup
-
-
-#define G_STR_DELIMITERS "_-|> <."
-
-/*
- * String type
- */
-typedef struct {
- char *str;
- gsize len;
- gsize allocated_len;
-} GString;
-
-GString *g_string_new (const gchar *init);
-GString *g_string_new_len (const gchar *init, gssize len);
-GString *g_string_sized_new (gsize default_size);
-gchar *g_string_free (GString *string, gboolean free_segment);
-GString *g_string_append (GString *string, const gchar *val);
-void g_string_printf (GString *string, const gchar *format, ...);
-void g_string_append_printf (GString *string, const gchar *format, ...);
-void g_string_append_vprintf (GString *string, const gchar *format, va_list args);
-GString *g_string_append_unichar (GString *string, gunichar c);
-GString *g_string_append_c (GString *string, gchar c);
-GString *g_string_append (GString *string, const gchar *val);
-GString *g_string_append_len (GString *string, const gchar *val, gssize len);
-GString *g_string_truncate (GString *string, gsize len);
-GString *g_string_prepend (GString *string, const gchar *val);
-GString *g_string_insert (GString *string, gssize pos, const gchar *val);
-GString *g_string_set_size (GString *string, gsize len);
-GString *g_string_erase (GString *string, gssize pos, gssize len);
-
-#define g_string_sprintfa g_string_append_printf
-
-typedef void (*GFunc) (gpointer data, gpointer user_data);
-typedef gint (*GCompareFunc) (gconstpointer a, gconstpointer b);
-typedef gint (*GCompareDataFunc) (gconstpointer a, gconstpointer b, gpointer user_data);
-typedef void (*GHFunc) (gpointer key, gpointer value, gpointer user_data);
-typedef gboolean (*GHRFunc) (gpointer key, gpointer value, gpointer user_data);
-typedef void (*GDestroyNotify) (gpointer data);
-typedef guint (*GHashFunc) (gconstpointer key);
-typedef gboolean (*GEqualFunc) (gconstpointer a, gconstpointer b);
-typedef void (*GFreeFunc) (gpointer data);
-
-/*
- * Lists
- */
-typedef struct _GSList GSList;
-struct _GSList {
- gpointer data;
- GSList *next;
-};
-
-GSList *g_slist_alloc (void);
-GSList *g_slist_append (GSList *list,
- gpointer data);
-GSList *g_slist_prepend (GSList *list,
- gpointer data);
-void g_slist_free (GSList *list);
-void g_slist_free_1 (GSList *list);
-GSList *g_slist_copy (GSList *list);
-GSList *g_slist_concat (GSList *list1,
- GSList *list2);
-void g_slist_foreach (GSList *list,
- GFunc func,
- gpointer user_data);
-GSList *g_slist_last (GSList *list);
-GSList *g_slist_find (GSList *list,
- gconstpointer data);
-GSList *g_slist_find_custom (GSList *list,
- gconstpointer data,
- GCompareFunc func);
-GSList *g_slist_remove (GSList *list,
- gconstpointer data);
-GSList *g_slist_remove_all (GSList *list,
- gconstpointer data);
-GSList *g_slist_reverse (GSList *list);
-guint g_slist_length (GSList *list);
-GSList *g_slist_remove_link (GSList *list,
- GSList *link);
-GSList *g_slist_delete_link (GSList *list,
- GSList *link);
-GSList *g_slist_insert_sorted (GSList *list,
- gpointer data,
- GCompareFunc func);
-GSList *g_slist_insert_before (GSList *list,
- GSList *sibling,
- gpointer data);
-GSList *g_slist_sort (GSList *list,
- GCompareFunc func);
-gint g_slist_index (GSList *list,
- gconstpointer data);
-GSList *g_slist_nth (GSList *list,
- guint n);
-gpointer g_slist_nth_data (GSList *list,
- guint n);
-
-#define g_slist_next(slist) ((slist) ? (((GSList *) (slist))->next) : NULL)
-
-
-typedef struct _GList GList;
-struct _GList {
- gpointer data;
- GList *next;
- GList *prev;
-};
-
-#define g_list_next(list) ((list) ? (((GList *) (list))->next) : NULL)
-#define g_list_previous(list) ((list) ? (((GList *) (list))->prev) : NULL)
-
-GList *g_list_alloc (void);
-GList *g_list_append (GList *list,
- gpointer data);
-GList *g_list_prepend (GList *list,
- gpointer data);
-void g_list_free (GList *list);
-void g_list_free_1 (GList *list);
-GList *g_list_copy (GList *list);
-guint g_list_length (GList *list);
-gint g_list_index (GList *list,
- gconstpointer data);
-GList *g_list_nth (GList *list,
- guint n);
-gpointer g_list_nth_data (GList *list,
- guint n);
-GList *g_list_last (GList *list);
-GList *g_list_concat (GList *list1,
- GList *list2);
-void g_list_foreach (GList *list,
- GFunc func,
- gpointer user_data);
-GList *g_list_first (GList *list);
-GList *g_list_find (GList *list,
- gconstpointer data);
-GList *g_list_find_custom (GList *list,
- gconstpointer data,
- GCompareFunc func);
-GList *g_list_remove (GList *list,
- gconstpointer data);
-GList *g_list_remove_all (GList *list,
- gconstpointer data);
-GList *g_list_reverse (GList *list);
-GList *g_list_remove_link (GList *list,
- GList *link);
-GList *g_list_delete_link (GList *list,
- GList *link);
-GList *g_list_insert_sorted (GList *list,
- gpointer data,
- GCompareFunc func);
-GList *g_list_insert_before (GList *list,
- GList *sibling,
- gpointer data);
-GList *g_list_sort (GList *sort,
- GCompareFunc func);
-
-/*
- * Hashtables
- */
-typedef struct _GHashTable GHashTable;
-typedef struct _GHashTableIter GHashTableIter;
-
-/* Private, but needed for stack allocation */
-struct _GHashTableIter
-{
- gpointer dummy [8];
-};
-
-GHashTable *g_hash_table_new (GHashFunc hash_func, GEqualFunc key_equal_func);
-GHashTable *g_hash_table_new_full (GHashFunc hash_func, GEqualFunc key_equal_func,
- GDestroyNotify key_destroy_func, GDestroyNotify value_destroy_func);
-void g_hash_table_insert_replace (GHashTable *hash, gpointer key, gpointer value, gboolean replace);
-guint g_hash_table_size (GHashTable *hash);
-GList *g_hash_table_get_keys (GHashTable *hash);
-GList *g_hash_table_get_values (GHashTable *hash);
-gpointer g_hash_table_lookup (GHashTable *hash, gconstpointer key);
-gboolean g_hash_table_lookup_extended (GHashTable *hash, gconstpointer key, gpointer *orig_key, gpointer *value);
-void g_hash_table_foreach (GHashTable *hash, GHFunc func, gpointer user_data);
-gpointer g_hash_table_find (GHashTable *hash, GHRFunc predicate, gpointer user_data);
-gboolean g_hash_table_remove (GHashTable *hash, gconstpointer key);
-gboolean g_hash_table_steal (GHashTable *hash, gconstpointer key);
-void g_hash_table_remove_all (GHashTable *hash);
-guint g_hash_table_foreach_remove (GHashTable *hash, GHRFunc func, gpointer user_data);
-guint g_hash_table_foreach_steal (GHashTable *hash, GHRFunc func, gpointer user_data);
-void g_hash_table_destroy (GHashTable *hash);
-void g_hash_table_print_stats (GHashTable *table);
-
-void g_hash_table_iter_init (GHashTableIter *iter, GHashTable *hash_table);
-gboolean g_hash_table_iter_next (GHashTableIter *iter, gpointer *key, gpointer *value);
-
-guint g_spaced_primes_closest (guint x);
-
-#define g_hash_table_insert(h,k,v) g_hash_table_insert_replace ((h),(k),(v),FALSE)
-#define g_hash_table_replace(h,k,v) g_hash_table_insert_replace ((h),(k),(v),TRUE)
-
-gboolean g_direct_equal (gconstpointer v1, gconstpointer v2);
-guint g_direct_hash (gconstpointer v1);
-gboolean g_int_equal (gconstpointer v1, gconstpointer v2);
-guint g_int_hash (gconstpointer v1);
-gboolean g_str_equal (gconstpointer v1, gconstpointer v2);
-guint g_str_hash (gconstpointer v1);
-
-/*
- * ByteArray
- */
-
-typedef struct _GByteArray GByteArray;
-struct _GByteArray {
- guint8 *data;
- gint len;
-};
-
-GByteArray *g_byte_array_new (void);
-GByteArray* g_byte_array_append (GByteArray *array, const guint8 *data, guint len);
-guint8* g_byte_array_free (GByteArray *array, gboolean free_segment);
-void g_byte_array_set_size (GByteArray *array, gint length);
-
-/*
- * Array
- */
-
-typedef struct _GArray GArray;
-struct _GArray {
- gchar *data;
- gint len;
-};
-
-GArray *g_array_new (gboolean zero_terminated, gboolean clear_, guint element_size);
-GArray *g_array_sized_new (gboolean zero_terminated, gboolean clear_, guint element_size, guint reserved_size);
-gchar* g_array_free (GArray *array, gboolean free_segment);
-GArray *g_array_append_vals (GArray *array, gconstpointer data, guint len);
-GArray* g_array_insert_vals (GArray *array, guint index_, gconstpointer data, guint len);
-GArray* g_array_remove_index (GArray *array, guint index_);
-GArray* g_array_remove_index_fast (GArray *array, guint index_);
-void g_array_set_size (GArray *array, gint length);
-
-#define g_array_append_val(a,v) (g_array_append_vals((a),&(v),1))
-#define g_array_insert_val(a,i,v) (g_array_insert_vals((a),(i),&(v),1))
-#define g_array_index(a,t,i) *(t*)(((a)->data) + sizeof(t) * (i))
-
-/*
- * QSort
-*/
-
-void g_qsort_with_data (gpointer base, size_t nmemb, size_t size, GCompareDataFunc compare, gpointer user_data);
-
-/*
- * Pointer Array
- */
-
-typedef struct _GPtrArray GPtrArray;
-struct _GPtrArray {
- gpointer *pdata;
- guint len;
-};
-
-GPtrArray *g_ptr_array_new (void);
-GPtrArray *g_ptr_array_sized_new (guint reserved_size);
-void g_ptr_array_add (GPtrArray *array, gpointer data);
-gboolean g_ptr_array_remove (GPtrArray *array, gpointer data);
-gpointer g_ptr_array_remove_index (GPtrArray *array, guint index);
-gboolean g_ptr_array_remove_fast (GPtrArray *array, gpointer data);
-gpointer g_ptr_array_remove_index_fast (GPtrArray *array, guint index);
-void g_ptr_array_sort (GPtrArray *array, GCompareFunc compare_func);
-void g_ptr_array_sort_with_data (GPtrArray *array, GCompareDataFunc compare_func, gpointer user_data);
-void g_ptr_array_set_size (GPtrArray *array, gint length);
-gpointer *g_ptr_array_free (GPtrArray *array, gboolean free_seg);
-void g_ptr_array_foreach (GPtrArray *array, GFunc func, gpointer user_data);
-#define g_ptr_array_index(array,index) (array)->pdata[(index)]
-
-/*
- * Queues
- */
-typedef struct {
- GList *head;
- GList *tail;
- guint length;
-} GQueue;
-
-gpointer g_queue_pop_head (GQueue *queue);
-void g_queue_push_head (GQueue *queue,
- gpointer data);
-void g_queue_push_tail (GQueue *queue,
- gpointer data);
-gboolean g_queue_is_empty (GQueue *queue);
-GQueue *g_queue_new (void);
-void g_queue_free (GQueue *queue);
-void g_queue_foreach (GQueue *queue, GFunc func, gpointer user_data);
-
-/*
- * Messages
- */
-#ifndef G_LOG_DOMAIN
-#define G_LOG_DOMAIN ((gchar*) 0)
-#endif
-
-typedef enum {
- G_LOG_FLAG_RECURSION = 1 << 0,
- G_LOG_FLAG_FATAL = 1 << 1,
-
- G_LOG_LEVEL_ERROR = 1 << 2,
- G_LOG_LEVEL_CRITICAL = 1 << 3,
- G_LOG_LEVEL_WARNING = 1 << 4,
- G_LOG_LEVEL_MESSAGE = 1 << 5,
- G_LOG_LEVEL_INFO = 1 << 6,
- G_LOG_LEVEL_DEBUG = 1 << 7,
-
- G_LOG_LEVEL_MASK = ~(G_LOG_FLAG_RECURSION | G_LOG_FLAG_FATAL)
-} GLogLevelFlags;
-
-void g_print (const gchar *format, ...);
-void g_printerr (const gchar *format, ...);
-GLogLevelFlags g_log_set_always_fatal (GLogLevelFlags fatal_mask);
-GLogLevelFlags g_log_set_fatal_mask (const gchar *log_domain, GLogLevelFlags fatal_mask);
-void g_logv (const gchar *log_domain, GLogLevelFlags log_level, const gchar *format, va_list args);
-void g_log (const gchar *log_domain, GLogLevelFlags log_level, const gchar *format, ...);
-void g_assertion_message (const gchar *format, ...) G_GNUC_NORETURN;
-
-#ifdef HAVE_C99_SUPPORT
-/* The for (;;) tells gc thats g_error () doesn't return, avoiding warnings */
-#define g_error(format, ...) do { g_log (G_LOG_DOMAIN, G_LOG_LEVEL_ERROR, format, __VA_ARGS__); for (;;); } while (0)
-#define g_critical(format, ...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, format, __VA_ARGS__)
-#define g_warning(format, ...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, format, __VA_ARGS__)
-#define g_message(format, ...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_MESSAGE, format, __VA_ARGS__)
-#define g_debug(format, ...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, format, __VA_ARGS__)
-#else /* HAVE_C99_SUPPORT */
-#define g_error(...) do { g_log (G_LOG_DOMAIN, G_LOG_LEVEL_ERROR, __VA_ARGS__); for (;;); } while (0)
-#define g_critical(...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, __VA_ARGS__)
-#define g_warning(...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, __VA_ARGS__)
-#define g_message(...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_MESSAGE, __VA_ARGS__)
-#define g_debug(...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, __VA_ARGS__)
-#endif /* ndef HAVE_C99_SUPPORT */
-
-typedef void (*GLogFunc) (const gchar *log_domain, GLogLevelFlags log_level, const gchar *message, gpointer user_data);
-typedef void (*GPrintFunc) (const gchar *string);
-
-void g_log_default_handler (const gchar *log_domain, GLogLevelFlags log_level, const gchar *message, gpointer unused_data);
-GLogFunc g_log_set_default_handler (GLogFunc log_func, gpointer user_data);
-GPrintFunc g_set_print_handler (GPrintFunc func);
-GPrintFunc g_set_printerr_handler (GPrintFunc func);
-/*
- * Conversions
- */
-
-gpointer g_convert_error_quark(void);
-
-
-/*
- * Unicode Manipulation: most of this is not used by Mono by default, it is
- * only used if the old collation code is activated, so this is only the
- * bare minimum to build.
- */
-
-typedef enum {
- G_UNICODE_CONTROL,
- G_UNICODE_FORMAT,
- G_UNICODE_UNASSIGNED,
- G_UNICODE_PRIVATE_USE,
- G_UNICODE_SURROGATE,
- G_UNICODE_LOWERCASE_LETTER,
- G_UNICODE_MODIFIER_LETTER,
- G_UNICODE_OTHER_LETTER,
- G_UNICODE_TITLECASE_LETTER,
- G_UNICODE_UPPERCASE_LETTER,
- G_UNICODE_COMBINING_MARK,
- G_UNICODE_ENCLOSING_MARK,
- G_UNICODE_NON_SPACING_MARK,
- G_UNICODE_DECIMAL_NUMBER,
- G_UNICODE_LETTER_NUMBER,
- G_UNICODE_OTHER_NUMBER,
- G_UNICODE_CONNECT_PUNCTUATION,
- G_UNICODE_DASH_PUNCTUATION,
- G_UNICODE_CLOSE_PUNCTUATION,
- G_UNICODE_FINAL_PUNCTUATION,
- G_UNICODE_INITIAL_PUNCTUATION,
- G_UNICODE_OTHER_PUNCTUATION,
- G_UNICODE_OPEN_PUNCTUATION,
- G_UNICODE_CURRENCY_SYMBOL,
- G_UNICODE_MODIFIER_SYMBOL,
- G_UNICODE_MATH_SYMBOL,
- G_UNICODE_OTHER_SYMBOL,
- G_UNICODE_LINE_SEPARATOR,
- G_UNICODE_PARAGRAPH_SEPARATOR,
- G_UNICODE_SPACE_SEPARATOR
-} GUnicodeType;
-
-typedef enum {
- G_UNICODE_BREAK_MANDATORY,
- G_UNICODE_BREAK_CARRIAGE_RETURN,
- G_UNICODE_BREAK_LINE_FEED,
- G_UNICODE_BREAK_COMBINING_MARK,
- G_UNICODE_BREAK_SURROGATE,
- G_UNICODE_BREAK_ZERO_WIDTH_SPACE,
- G_UNICODE_BREAK_INSEPARABLE,
- G_UNICODE_BREAK_NON_BREAKING_GLUE,
- G_UNICODE_BREAK_CONTINGENT,
- G_UNICODE_BREAK_SPACE,
- G_UNICODE_BREAK_AFTER,
- G_UNICODE_BREAK_BEFORE,
- G_UNICODE_BREAK_BEFORE_AND_AFTER,
- G_UNICODE_BREAK_HYPHEN,
- G_UNICODE_BREAK_NON_STARTER,
- G_UNICODE_BREAK_OPEN_PUNCTUATION,
- G_UNICODE_BREAK_CLOSE_PUNCTUATION,
- G_UNICODE_BREAK_QUOTATION,
- G_UNICODE_BREAK_EXCLAMATION,
- G_UNICODE_BREAK_IDEOGRAPHIC,
- G_UNICODE_BREAK_NUMERIC,
- G_UNICODE_BREAK_INFIX_SEPARATOR,
- G_UNICODE_BREAK_SYMBOL,
- G_UNICODE_BREAK_ALPHABETIC,
- G_UNICODE_BREAK_PREFIX,
- G_UNICODE_BREAK_POSTFIX,
- G_UNICODE_BREAK_COMPLEX_CONTEXT,
- G_UNICODE_BREAK_AMBIGUOUS,
- G_UNICODE_BREAK_UNKNOWN,
- G_UNICODE_BREAK_NEXT_LINE,
- G_UNICODE_BREAK_WORD_JOINER,
- G_UNICODE_BREAK_HANGUL_L_JAMO,
- G_UNICODE_BREAK_HANGUL_V_JAMO,
- G_UNICODE_BREAK_HANGUL_T_JAMO,
- G_UNICODE_BREAK_HANGUL_LV_SYLLABLE,
- G_UNICODE_BREAK_HANGUL_LVT_SYLLABLE
-} GUnicodeBreakType;
-
-gunichar g_unichar_toupper (gunichar c);
-gunichar g_unichar_tolower (gunichar c);
-gunichar g_unichar_totitle (gunichar c);
-GUnicodeType g_unichar_type (gunichar c);
-gboolean g_unichar_isspace (gunichar c);
-gboolean g_unichar_isxdigit (gunichar c);
-gint g_unichar_xdigit_value (gunichar c);
-GUnicodeBreakType g_unichar_break_type (gunichar c);
-
-#ifndef MAX
-#define MAX(a,b) (((a)>(b)) ? (a) : (b))
-#endif
-
-#ifndef MIN
-#define MIN(a,b) (((a)<(b)) ? (a) : (b))
-#endif
-
-#ifndef CLAMP
-#define CLAMP(a,low,high) (((a) < (low)) ? (low) : (((a) > (high)) ? (high) : (a)))
-#endif
-
-#if defined(__GNUC__) && (__GNUC__ > 2)
-#define G_LIKELY(expr) (__builtin_expect ((expr) != 0, 1))
-#define G_UNLIKELY(expr) (__builtin_expect ((expr) != 0, 0))
-#else
-#define G_LIKELY(x) (x)
-#define G_UNLIKELY(x) (x)
-#endif
-
-#if defined(_MSC_VER)
-#define eg_unreachable() __assume(0)
-#elif defined(__GNUC__) && ((__GNUC__ > 4) || (__GNUC__ == 4 && (__GNUC_MINOR__ >= 5)))
-#define eg_unreachable() __builtin_unreachable()
-#else
-#define eg_unreachable()
-#endif
-
-#define g_assert(x) G_STMT_START { if (G_UNLIKELY (!(x))) g_assertion_message ("* Assertion at %s:%d, condition `%s' not met\n", __FILE__, __LINE__, #x); } G_STMT_END
-#define g_assert_not_reached() G_STMT_START { g_assertion_message ("* Assertion: should not be reached at %s:%d\n", __FILE__, __LINE__); eg_unreachable(); } G_STMT_END
-
-/*
- * Unicode conversion
- */
-
-#define G_CONVERT_ERROR g_convert_error_quark()
-
-typedef enum {
- G_CONVERT_ERROR_NO_CONVERSION,
- G_CONVERT_ERROR_ILLEGAL_SEQUENCE,
- G_CONVERT_ERROR_FAILED,
- G_CONVERT_ERROR_PARTIAL_INPUT,
- G_CONVERT_ERROR_BAD_URI,
- G_CONVERT_ERROR_NOT_ABSOLUTE_PATH
-} GConvertError;
-
-gchar *g_utf8_strup (const gchar *str, gssize len);
-gchar *g_utf8_strdown (const gchar *str, gssize len);
-gint g_unichar_to_utf8 (gunichar c, gchar *outbuf);
-gunichar *g_utf8_to_ucs4_fast (const gchar *str, glong len, glong *items_written);
-gunichar *g_utf8_to_ucs4 (const gchar *str, glong len, glong *items_read, glong *items_written, GError **err);
-gunichar2 *g_utf8_to_utf16 (const gchar *str, glong len, glong *items_read, glong *items_written, GError **err);
-gunichar2 *eg_utf8_to_utf16_with_nuls (const gchar *str, glong len, glong *items_read, glong *items_written, GError **err);
-gchar *g_utf16_to_utf8 (const gunichar2 *str, glong len, glong *items_read, glong *items_written, GError **err);
-gunichar *g_utf16_to_ucs4 (const gunichar2 *str, glong len, glong *items_read, glong *items_written, GError **err);
-gchar *g_ucs4_to_utf8 (const gunichar *str, glong len, glong *items_read, glong *items_written, GError **err);
-gunichar2 *g_ucs4_to_utf16 (const gunichar *str, glong len, glong *items_read, glong *items_written, GError **err);
-
-#define u8to16(str) g_utf8_to_utf16(str, (glong)strlen(str), NULL, NULL, NULL)
-
-#ifdef G_OS_WIN32
-#define u16to8(str) g_utf16_to_utf8((gunichar2 *) (str), (glong)wcslen((wchar_t *) (str)), NULL, NULL, NULL)
-#else
-#define u16to8(str) g_utf16_to_utf8(str, (glong)strlen(str), NULL, NULL, NULL)
-#endif
-
-/*
- * Path
- */
-gchar *g_build_path (const gchar *separator, const gchar *first_element, ...);
-#define g_build_filename(x, ...) g_build_path(G_DIR_SEPARATOR_S, x, __VA_ARGS__)
-gchar *g_path_get_dirname (const gchar *filename);
-gchar *g_path_get_basename (const char *filename);
-gchar *g_find_program_in_path (const gchar *program);
-gchar *g_get_current_dir (void);
-gboolean g_path_is_absolute (const char *filename);
-
-const gchar *g_get_home_dir (void);
-const gchar *g_get_tmp_dir (void);
-const gchar *g_get_user_name (void);
-gchar *g_get_prgname (void);
-void g_set_prgname (const gchar *prgname);
-
-gboolean g_ensure_directory_exists (const gchar *filename);
-
-/*
- * Shell
- */
-
-gboolean g_shell_parse_argv (const gchar *command_line, gint *argcp, gchar ***argvp, GError **error);
-gchar *g_shell_unquote (const gchar *quoted_string, GError **error);
-gchar *g_shell_quote (const gchar *unquoted_string);
-
-/*
- * Spawn
- */
-typedef enum {
- G_SPAWN_LEAVE_DESCRIPTORS_OPEN = 1,
- G_SPAWN_DO_NOT_REAP_CHILD = 1 << 1,
- G_SPAWN_SEARCH_PATH = 1 << 2,
- G_SPAWN_STDOUT_TO_DEV_NULL = 1 << 3,
- G_SPAWN_STDERR_TO_DEV_NULL = 1 << 4,
- G_SPAWN_CHILD_INHERITS_STDIN = 1 << 5,
- G_SPAWN_FILE_AND_ARGV_ZERO = 1 << 6
-} GSpawnFlags;
-
-typedef void (*GSpawnChildSetupFunc) (gpointer user_data);
-
-gboolean g_spawn_command_line_sync (const gchar *command_line, gchar **standard_output, gchar **standard_error, gint *exit_status, GError **error);
-gboolean g_spawn_async_with_pipes (const gchar *working_directory, gchar **argv, gchar **envp, GSpawnFlags flags, GSpawnChildSetupFunc child_setup,
- gpointer user_data, GPid *child_pid, gint *standard_input, gint *standard_output, gint *standard_error, GError **error);
-
-int eg_getdtablesize (void);
-
-/*
- * Timer
- */
-typedef struct _GTimer GTimer;
-
-GTimer *g_timer_new (void);
-void g_timer_destroy (GTimer *timer);
-gdouble g_timer_elapsed (GTimer *timer, gulong *microseconds);
-void g_timer_stop (GTimer *timer);
-void g_timer_start (GTimer *timer);
-
-/*
- * Date and time
- */
-typedef struct {
- glong tv_sec;
- glong tv_usec;
-} GTimeVal;
-
-void g_get_current_time (GTimeVal *result);
-void g_usleep (gulong microseconds);
-
-/*
- * File
- */
-
-gpointer g_file_error_quark (void);
-
-#define G_FILE_ERROR g_file_error_quark ()
-
-typedef enum {
- G_FILE_ERROR_EXIST,
- G_FILE_ERROR_ISDIR,
- G_FILE_ERROR_ACCES,
- G_FILE_ERROR_NAMETOOLONG,
- G_FILE_ERROR_NOENT,
- G_FILE_ERROR_NOTDIR,
- G_FILE_ERROR_NXIO,
- G_FILE_ERROR_NODEV,
- G_FILE_ERROR_ROFS,
- G_FILE_ERROR_TXTBSY,
- G_FILE_ERROR_FAULT,
- G_FILE_ERROR_LOOP,
- G_FILE_ERROR_NOSPC,
- G_FILE_ERROR_NOMEM,
- G_FILE_ERROR_MFILE,
- G_FILE_ERROR_NFILE,
- G_FILE_ERROR_BADF,
- G_FILE_ERROR_INVAL,
- G_FILE_ERROR_PIPE,
- G_FILE_ERROR_AGAIN,
- G_FILE_ERROR_INTR,
- G_FILE_ERROR_IO,
- G_FILE_ERROR_PERM,
- G_FILE_ERROR_NOSYS,
- G_FILE_ERROR_FAILED
-} GFileError;
-
-typedef enum {
- G_FILE_TEST_IS_REGULAR = 1 << 0,
- G_FILE_TEST_IS_SYMLINK = 1 << 1,
- G_FILE_TEST_IS_DIR = 1 << 2,
- G_FILE_TEST_IS_EXECUTABLE = 1 << 3,
- G_FILE_TEST_EXISTS = 1 << 4
-} GFileTest;
-
-
-gboolean g_file_set_contents (const gchar *filename, const gchar *contents, gssize length, GError **error);
-gboolean g_file_get_contents (const gchar *filename, gchar **contents, gsize *length, GError **error);
-GFileError g_file_error_from_errno (gint err_no);
-gint g_file_open_tmp (const gchar *tmpl, gchar **name_used, GError **error);
-gboolean g_file_test (const gchar *filename, GFileTest test);
-
-#define g_open open
-#define g_rename rename
-#define g_stat stat
-#define g_unlink unlink
-#define g_fopen fopen
-#define g_lstat lstat
-#define g_rmdir rmdir
-#define g_mkstemp mkstemp
-#define g_ascii_isdigit isdigit
-#define g_ascii_strtod strtod
-#define g_ascii_isalnum isalnum
-
-gchar *g_mkdtemp (gchar *tmpl);
-
-/*
- * Pattern matching
- */
-typedef struct _GPatternSpec GPatternSpec;
-GPatternSpec * g_pattern_spec_new (const gchar *pattern);
-void g_pattern_spec_free (GPatternSpec *pspec);
-gboolean g_pattern_match_string (GPatternSpec *pspec, const gchar *string);
-
-/*
- * Directory
- */
-typedef struct _GDir GDir;
-GDir *g_dir_open (const gchar *path, guint flags, GError **error);
-const gchar *g_dir_read_name (GDir *dir);
-void g_dir_rewind (GDir *dir);
-void g_dir_close (GDir *dir);
-
-int g_mkdir_with_parents (const gchar *pathname, int mode);
-#define g_mkdir mkdir
-
-/*
- * GMarkup
- */
-typedef struct _GMarkupParseContext GMarkupParseContext;
-
-typedef enum
-{
- G_MARKUP_DO_NOT_USE_THIS_UNSUPPORTED_FLAG = 1 << 0,
- G_MARKUP_TREAT_CDATA_AS_TEXT = 1 << 1
-} GMarkupParseFlags;
-
-typedef struct {
- void (*start_element) (GMarkupParseContext *context,
- const gchar *element_name,
- const gchar **attribute_names,
- const gchar **attribute_values,
- gpointer user_data,
- GError **error);
-
- void (*end_element) (GMarkupParseContext *context,
- const gchar *element_name,
- gpointer user_data,
- GError **error);
-
- void (*text) (GMarkupParseContext *context,
- const gchar *text,
- gsize text_len,
- gpointer user_data,
- GError **error);
-
- void (*passthrough) (GMarkupParseContext *context,
- const gchar *passthrough_text,
- gsize text_len,
- gpointer user_data,
- GError **error);
- void (*error) (GMarkupParseContext *context,
- GError *error,
- gpointer user_data);
-} GMarkupParser;
-
-GMarkupParseContext *g_markup_parse_context_new (const GMarkupParser *parser,
- GMarkupParseFlags flags,
- gpointer user_data,
- GDestroyNotify user_data_dnotify);
-void g_markup_parse_context_free (GMarkupParseContext *context);
-gboolean g_markup_parse_context_parse (GMarkupParseContext *context,
- const gchar *text, gssize text_len,
- GError **error);
-gboolean g_markup_parse_context_end_parse (GMarkupParseContext *context,
- GError **error);
-
-/*
- * Character set conversion
- */
-typedef struct _GIConv *GIConv;
-
-gsize g_iconv (GIConv cd, gchar **inbytes, gsize *inbytesleft, gchar **outbytes, gsize *outbytesleft);
-GIConv g_iconv_open (const gchar *to_charset, const gchar *from_charset);
-int g_iconv_close (GIConv cd);
-
-gboolean g_get_charset (G_CONST_RETURN char **charset);
-gchar *g_locale_to_utf8 (const gchar *opsysstring, gssize len,
- gsize *bytes_read, gsize *bytes_written,
- GError **error);
-gchar *g_locale_from_utf8 (const gchar *utf8string, gssize len, gsize *bytes_read,
- gsize *bytes_written, GError **error);
-gchar *g_filename_from_utf8 (const gchar *utf8string, gssize len, gsize *bytes_read,
- gsize *bytes_written, GError **error);
-gchar *g_convert (const gchar *str, gssize len,
- const gchar *to_codeset, const gchar *from_codeset,
- gsize *bytes_read, gsize *bytes_written, GError **error);
-
-/*
- * Unicode manipulation
- */
-extern const guchar g_utf8_jump_table[256];
-
-gboolean g_utf8_validate (const gchar *str, gssize max_len, const gchar **end);
-gunichar g_utf8_get_char_validated (const gchar *str, gssize max_len);
-gchar *g_utf8_find_prev_char (const char *str, const char *p);
-gchar *g_utf8_prev_char (const char *str);
-#define g_utf8_next_char(p) ((p) + g_utf8_jump_table[(guchar)(*p)])
-gunichar g_utf8_get_char (const gchar *src);
-glong g_utf8_strlen (const gchar *str, gssize max);
-gchar *g_utf8_offset_to_pointer (const gchar *str, glong offset);
-glong g_utf8_pointer_to_offset (const gchar *str, const gchar *pos);
-
-/*
- * priorities
- */
-#define G_PRIORITY_DEFAULT 0
-#define G_PRIORITY_DEFAULT_IDLE 200
-
-#define GUINT16_SWAP_LE_BE_CONSTANT(x) ((((guint16) x) >> 8) | ((((guint16) x) << 8)))
-
-#define GUINT16_SWAP_LE_BE(x) ((guint16) (((guint16) x) >> 8) | ((((guint16)(x)) & 0xff) << 8))
-#define GUINT32_SWAP_LE_BE(x) ((guint32) \
- ( (((guint32) (x)) << 24)| \
- ((((guint32) (x)) & 0xff0000) >> 8) | \
- ((((guint32) (x)) & 0xff00) << 8) | \
- (((guint32) (x)) >> 24)) )
-
-#define GUINT64_SWAP_LE_BE(x) ((guint64) (((guint64)(GUINT32_SWAP_LE_BE(((guint64)x) & 0xffffffff))) << 32) | \
- GUINT32_SWAP_LE_BE(((guint64)x) >> 32))
-
-
-
-#if G_BYTE_ORDER == G_LITTLE_ENDIAN
-# define GUINT64_FROM_BE(x) GUINT64_SWAP_LE_BE(x)
-# define GUINT32_FROM_BE(x) GUINT32_SWAP_LE_BE(x)
-# define GUINT16_FROM_BE(x) GUINT16_SWAP_LE_BE(x)
-# define GUINT_FROM_BE(x) GUINT32_SWAP_LE_BE(x)
-# define GUINT64_FROM_LE(x) (x)
-# define GUINT32_FROM_LE(x) (x)
-# define GUINT16_FROM_LE(x) (x)
-# define GUINT_FROM_LE(x) (x)
-# define GUINT64_TO_BE(x) GUINT64_SWAP_LE_BE(x)
-# define GUINT32_TO_BE(x) GUINT32_SWAP_LE_BE(x)
-# define GUINT16_TO_BE(x) GUINT16_SWAP_LE_BE(x)
-# define GUINT_TO_BE(x) GUINT32_SWAP_LE_BE(x)
-# define GUINT64_TO_LE(x) (x)
-# define GUINT32_TO_LE(x) (x)
-# define GUINT16_TO_LE(x) (x)
-# define GUINT_TO_LE(x) (x)
-#else
-# define GUINT64_FROM_BE(x) (x)
-# define GUINT32_FROM_BE(x) (x)
-# define GUINT16_FROM_BE(x) (x)
-# define GUINT_FROM_BE(x) (x)
-# define GUINT64_FROM_LE(x) GUINT64_SWAP_LE_BE(x)
-# define GUINT32_FROM_LE(x) GUINT32_SWAP_LE_BE(x)
-# define GUINT16_FROM_LE(x) GUINT16_SWAP_LE_BE(x)
-# define GUINT_FROM_LE(x) GUINT32_SWAP_LE_BE(x)
-# define GUINT64_TO_BE(x) (x)
-# define GUINT32_TO_BE(x) (x)
-# define GUINT16_TO_BE(x) (x)
-# define GUINT_TO_BE(x) (x)
-# define GUINT64_TO_LE(x) GUINT64_SWAP_LE_BE(x)
-# define GUINT32_TO_LE(x) GUINT32_SWAP_LE_BE(x)
-# define GUINT16_TO_LE(x) GUINT16_SWAP_LE_BE(x)
-# define GUINT_TO_LE(x) GUINT32_SWAP_LE_BE(x)
-#endif
-
-#define GINT64_FROM_BE(x) (GUINT64_TO_BE (x))
-#define GINT32_FROM_BE(x) (GUINT32_TO_BE (x))
-#define GINT16_FROM_BE(x) (GUINT16_TO_BE (x))
-#define GINT64_FROM_LE(x) (GUINT64_TO_LE (x))
-#define GINT32_FROM_LE(x) (GUINT32_TO_LE (x))
-#define GINT16_FROM_LE(x) (GUINT16_TO_LE (x))
-
-#define _EGLIB_MAJOR 2
-#define _EGLIB_MIDDLE 4
-#define _EGLIB_MINOR 0
-
-#define GLIB_CHECK_VERSION(a,b,c) ((a < _EGLIB_MAJOR) || (a == _EGLIB_MAJOR && (b < _EGLIB_MIDDLE || (b == _EGLIB_MIDDLE && c <= _EGLIB_MINOR))))
-
-#define G_HAVE_API_SUPPORT(x) (x)
-#define G_UNSUPPORTED_API "%s:%d: '%s' not supported.", __FILE__, __LINE__
-#define g_unsupported_api(name) G_STMT_START { g_warning (G_UNSUPPORTED_API, name); } G_STMT_END
-
-G_END_DECLS
-
-#endif
-
-
-
+++ /dev/null
-/*
- * glist.c: Doubly-linked list implementation
- *
- * Authors:
- * Duncan Mak (duncan@novell.com)
- * Raja R Harinath (rharinath@novell.com)
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * (C) 2006 Novell, Inc.
- */
-#include <stdio.h>
-#include <glib.h>
-
-GList*
-g_list_alloc ()
-{
- return g_new0 (GList, 1);
-}
-
-static inline GList*
-new_node (GList *prev, gpointer data, GList *next)
-{
- GList *node = g_list_alloc ();
- node->data = data;
- node->prev = prev;
- node->next = next;
- if (prev)
- prev->next = node;
- if (next)
- next->prev = node;
- return node;
-}
-
-static inline GList*
-disconnect_node (GList *node)
-{
- if (node->next)
- node->next->prev = node->prev;
- if (node->prev)
- node->prev->next = node->next;
- return node;
-}
-
-GList *
-g_list_prepend (GList *list, gpointer data)
-{
- return new_node (list ? list->prev : NULL, data, list);
-}
-
-void
-g_list_free_1 (GList *list)
-{
- g_free (list);
-}
-
-void
-g_list_free (GList *list)
-{
- while (list){
- GList *next = list->next;
- g_list_free_1 (list);
- list = next;
- }
-}
-
-GList*
-g_list_append (GList *list, gpointer data)
-{
- GList *node = new_node (g_list_last (list), data, NULL);
- return list ? list : node;
-}
-
-GList *
-g_list_concat (GList *list1, GList *list2)
-{
- if (list1 && list2) {
- list2->prev = g_list_last (list1);
- list2->prev->next = list2;
- }
- return list1 ? list1 : list2;
-}
-
-guint
-g_list_length (GList *list)
-{
- guint length = 0;
-
- while (list) {
- length ++;
- list = list->next;
- }
-
- return length;
-}
-
-GList*
-g_list_remove (GList *list, gconstpointer data)
-{
- GList *current = g_list_find (list, data);
- if (!current)
- return list;
-
- if (current == list)
- list = list->next;
- g_list_free_1 (disconnect_node (current));
-
- return list;
-}
-
-GList*
-g_list_remove_all (GList *list, gconstpointer data)
-{
- GList *current = g_list_find (list, data);
-
- if (!current)
- return list;
-
- while (current) {
- if (current == list)
- list = list->next;
- g_list_free_1 (disconnect_node (current));
-
- current = g_list_find (list, data);
- }
-
- return list;
-}
-
-GList*
-g_list_remove_link (GList *list, GList *link)
-{
- if (list == link)
- list = list->next;
-
- disconnect_node (link);
- link->next = NULL;
- link->prev = NULL;
-
- return list;
-}
-
-GList*
-g_list_delete_link (GList *list, GList *link)
-{
- list = g_list_remove_link (list, link);
- g_list_free_1 (link);
-
- return list;
-}
-
-GList*
-g_list_find (GList *list, gconstpointer data)
-{
- while (list){
- if (list->data == data)
- return list;
-
- list = list->next;
- }
-
- return NULL;
-}
-
-GList*
-g_list_find_custom (GList *list, gconstpointer data, GCompareFunc func)
-{
- if (!func)
- return NULL;
-
- while (list) {
- if (func (list->data, data) == 0)
- return list;
-
- list = list->next;
- }
-
- return NULL;
-}
-
-GList*
-g_list_reverse (GList *list)
-{
- GList *reverse = NULL;
-
- while (list) {
- reverse = list;
- list = reverse->next;
-
- reverse->next = reverse->prev;
- reverse->prev = list;
- }
-
- return reverse;
-}
-
-GList*
-g_list_first (GList *list)
-{
- if (!list)
- return NULL;
-
- while (list->prev)
- list = list->prev;
-
- return list;
-}
-
-GList*
-g_list_last (GList *list)
-{
- if (!list)
- return NULL;
-
- while (list->next)
- list = list->next;
-
- return list;
-}
-
-GList*
-g_list_insert_sorted (GList *list, gpointer data, GCompareFunc func)
-{
- GList *prev = NULL;
- GList *current;
- GList *node;
-
- if (!func)
- return list;
-
- /* Invariant: !prev || func (prev->data, data) <= 0) */
- for (current = list; current; current = current->next) {
- if (func (current->data, data) > 0)
- break;
- prev = current;
- }
-
- node = new_node (prev, data, current);
- return list == current ? node : list;
-}
-
-GList*
-g_list_insert_before (GList *list, GList *sibling, gpointer data)
-{
- if (sibling) {
- GList *node = new_node (sibling->prev, data, sibling);
- return list == sibling ? node : list;
- }
- return g_list_append (list, data);
-}
-
-void
-g_list_foreach (GList *list, GFunc func, gpointer user_data)
-{
- while (list){
- (*func) (list->data, user_data);
- list = list->next;
- }
-}
-
-gint
-g_list_index (GList *list, gconstpointer data)
-{
- gint index = 0;
-
- while (list){
- if (list->data == data)
- return index;
-
- index ++;
- list = list->next;
- }
-
- return -1;
-}
-
-GList*
-g_list_nth (GList *list, guint n)
-{
- for (; list; list = list->next) {
- if (n == 0)
- break;
- n--;
- }
- return list;
-}
-
-gpointer
-g_list_nth_data (GList *list, guint n)
-{
- GList *node = g_list_nth (list, n);
- return node ? node->data : NULL;
-}
-
-GList*
-g_list_copy (GList *list)
-{
- GList *copy = NULL;
-
- if (list) {
- GList *tmp = new_node (NULL, list->data, NULL);
- copy = tmp;
-
- for (list = list->next; list; list = list->next)
- tmp = new_node (tmp, list->data, NULL);
- }
-
- return copy;
-}
-
-typedef GList list_node;
-#include "sort.frag.h"
-
-GList*
-g_list_sort (GList *list, GCompareFunc func)
-{
- GList *current;
- if (!list || !list->next)
- return list;
- list = do_sort (list, func);
-
- /* Fixup: do_sort doesn't update 'prev' pointers */
- list->prev = NULL;
- for (current = list; current->next; current = current->next)
- current->next->prev = current;
-
- return list;
-}
+++ /dev/null
-/*
- * gmakrup.c: Minimal XML markup reader.
- *
- * Unlike the GLib one, this can not be restarted with more text
- * as the Mono use does not require it.
- *
- * Actually, with further thought, I think that this could be made
- * to restart very easily. The pos == end condition would mean
- * "return to caller" and only at end parse this would be a fatal
- * error.
- *
- * Not that it matters to Mono, but it is very simple to change, there
- * is a tricky situation: there are a few places where we check p+n
- * in the source, and that would have to change to be progressive, instead
- * of depending on the string to be complete at that point, so we would
- * have to introduce extra states to cope with that.
- *
- * Author:
- * Miguel de Icaza (miguel@novell.com)
- *
- * (C) 2006 Novell, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-#include <stdio.h>
-#include <ctype.h>
-#include <glib.h>
-
-#define set_error(msg, ...) do { if (error != NULL) *error = g_error_new (GINT_TO_POINTER (1), 1, msg, __VA_ARGS__); } while (0);
-
-typedef enum {
- START,
- START_ELEMENT,
- TEXT,
- FLUSH_TEXT,
- CLOSING_ELEMENT,
- COMMENT,
- SKIP_XML_DECLARATION
-} ParseState;
-
-struct _GMarkupParseContext {
- GMarkupParser parser;
- gpointer user_data;
- GDestroyNotify user_data_dnotify;
- ParseState state;
-
- /* Stores the name of the current element, so we can issue the end_element */
- GSList *level;
-
- GString *text;
-};
-
-GMarkupParseContext *
-g_markup_parse_context_new (const GMarkupParser *parser,
- GMarkupParseFlags flags,
- gpointer user_data,
- GDestroyNotify user_data_dnotify)
-{
- GMarkupParseContext *context = g_new0 (GMarkupParseContext, 1);
-
- context->parser = *parser;
- context->user_data = user_data;
- context->user_data_dnotify = user_data_dnotify;
-
- return context;
-}
-
-void
-g_markup_parse_context_free (GMarkupParseContext *context)
-{
- GSList *l;
-
- g_return_if_fail (context != NULL);
-
- if (context->user_data_dnotify != NULL)
- (context->user_data_dnotify) (context->user_data);
-
- if (context->text != NULL)
- g_string_free (context->text, TRUE);
- for (l = context->level; l; l = l->next)
- g_free (l->data);
- g_slist_free (context->level);
- g_free (context);
-}
-
-static gboolean
-my_isspace (char c)
-{
- if (c == ' ' || c == '\t' || c == '\r' || c == '\n' || c == '\v')
- return TRUE;
- return FALSE;
-}
-
-static gboolean
-my_isalnum (char c)
-{
- if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))
- return TRUE;
- if (c >= '0' && c <= '9')
- return TRUE;
-
- return FALSE;
-}
-
-static gboolean
-my_isalpha (char c)
-{
- if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))
- return TRUE;
- return FALSE;
-}
-
-static const char *
-skip_space (const char *p, const char *end)
-{
- for (; p < end && my_isspace (*p); p++)
- ;
- return p;
-}
-
-static const char *
-parse_value (const char *p, const char *end, char **value, GError **error)
-{
- const char *start;
- int l;
-
- if (*p != '"'){
- set_error ("%s", "Expected the attribute value to start with a quote");
- return end;
- }
- start = ++p;
- for (; p < end && *p != '"'; p++)
- ;
- if (p == end)
- return end;
- l = (int)(p - start);
- p++;
- *value = g_malloc (l + 1);
- if (*value == NULL)
- return end;
- strncpy (*value, start, l);
- (*value) [l] = 0;
- return p;
-}
-
-static const char *
-parse_name (const char *p, const char *end, char **value)
-{
- const char *start = p;
- int l;
-
- for (; p < end && my_isalnum (*p); p++)
- ;
- if (p == end)
- return end;
-
- l = (int)(p - start);
- *value = g_malloc (l + 1);
- if (*value == NULL)
- return end;
- strncpy (*value, start, l);
- (*value) [l] = 0;
- return p;
-}
-
-static const char *
-parse_attributes (const char *p, const char *end, char ***names, char ***values, GError **error, int *full_stop, int state)
-{
- int nnames = 0;
-
- while (TRUE){
- p = skip_space (p, end);
- if (p == end)
- return end;
-
- if (*p == '>'){
- *full_stop = 0;
- return p;
- }
- if (state == SKIP_XML_DECLARATION && *p == '?' && ((p+1) < end) && *(p+1) == '>'){
- *full_stop = 0;
- return p+1;
- }
-
- if (*p == '/' && ((p+1) < end && *(p+1) == '>')){
- *full_stop = 1;
- return p+1;
- } else {
- char *name, *value;
-
- p = parse_name (p, end, &name);
- if (p == end)
- return p;
-
- p = skip_space (p, end);
- if (p == end){
- g_free (name);
- return p;
- }
- if (*p != '='){
- set_error ("Expected an = after the attribute name `%s'", name);
- g_free (name);
- return end;
- }
- p++;
- p = skip_space (p, end);
- if (p == end){
- g_free (name);
- return end;
- }
-
- p = parse_value (p, end, &value, error);
- if (p == end){
- g_free (name);
- return p;
- }
-
- ++nnames;
- *names = g_realloc (*names, sizeof (char **) * (nnames+1));
- *values = g_realloc (*values, sizeof (char **) * (nnames+1));
- (*names) [nnames-1] = name;
- (*values) [nnames-1] = value;
- (*names) [nnames] = NULL;
- (*values) [nnames] = NULL;
- }
- }
-}
-
-static void
-destroy_parse_state (GMarkupParseContext *context)
-{
- GSList *p;
-
- for (p = context->level; p != NULL; p = p->next)
- g_free (p->data);
-
- g_slist_free (context->level);
- if (context->text != NULL)
- g_string_free (context->text, TRUE);
- context->text = NULL;
- context->level = NULL;
-}
-
-gboolean
-g_markup_parse_context_parse (GMarkupParseContext *context,
- const gchar *text, gssize text_len,
- GError **error)
-{
- const char *p, *end;
-
- g_return_val_if_fail (context != NULL, FALSE);
- g_return_val_if_fail (text != NULL, FALSE);
- g_return_val_if_fail (text_len >= 0, FALSE);
-
- end = text + text_len;
-
- for (p = text; p < end; p++){
- char c = *p;
-
- switch (context->state){
- case START:
- if (c == ' ' || c == '\t' || c == '\f' || c == '\n' || (c & 0x80))
- continue;
- if (c == '<'){
- if (p+1 < end && p [1] == '?'){
- context->state = SKIP_XML_DECLARATION;
- p++;
- } else
- context->state = START_ELEMENT;
- continue;
- }
- set_error ("%s", "Expected < to start the document");
- goto fail;
-
- case SKIP_XML_DECLARATION:
- case START_ELEMENT: {
- const char *element_start = p, *element_end;
- char *ename = NULL;
- int full_stop = 0, l;
- gchar **names = NULL, **values = NULL;
-
- for (; p < end && my_isspace (*p); p++)
- ;
- if (p == end){
- set_error ("%s", "Unfinished element");
- goto fail;
- }
-
- if (*p == '!' && (p+2 < end) && (p [1] == '-') && (p [2] == '-')){
- context->state = COMMENT;
- p += 2;
- break;
- }
-
- if (!my_isalpha (*p)){
- set_error ("%s", "Expected an element name");
- goto fail;
- }
-
- for (++p; p < end && (my_isalnum (*p) || (*p == '.')); p++)
- ;
- if (p == end){
- set_error ("%s", "Expected an element");
- goto fail;
- }
- element_end = p;
-
- for (; p < end && my_isspace (*p); p++)
- ;
- if (p == end){
- set_error ("%s", "Unfinished element");
- goto fail;
- }
- p = parse_attributes (p, end, &names, &values, error, &full_stop, context->state);
- if (p == end){
- if (names != NULL) {
- g_strfreev (names);
- g_strfreev (values);
- }
- /* Only set the error if parse_attributes did not */
- if (error != NULL && *error == NULL)
- set_error ("%s", "Unfinished sequence");
- goto fail;
- }
- l = (int)(element_end - element_start);
- ename = g_malloc (l + 1);
- if (ename == NULL)
- goto fail;
- strncpy (ename, element_start, l);
- ename [l] = 0;
-
- if (context->state == START_ELEMENT)
- if (context->parser.start_element != NULL)
- context->parser.start_element (context, ename,
- (const gchar **) names,
- (const gchar **) values,
- context->user_data, error);
-
- if (names != NULL){
- g_strfreev (names);
- g_strfreev (values);
- }
-
- if (error != NULL && *error != NULL){
- g_free (ename);
- goto fail;
- }
-
- if (full_stop){
- if (context->parser.end_element != NULL && context->state == START_ELEMENT){
- context->parser.end_element (context, ename, context->user_data, error);
- if (error != NULL && *error != NULL){
- g_free (ename);
- goto fail;
- }
- }
- g_free (ename);
- } else {
- context->level = g_slist_prepend (context->level, ename);
- }
-
- context->state = TEXT;
- break;
- } /* case START_ELEMENT */
-
- case TEXT: {
- if (c == '<'){
- context->state = FLUSH_TEXT;
- break;
- }
- if (context->parser.text != NULL){
- if (context->text == NULL)
- context->text = g_string_new ("");
- g_string_append_c (context->text, c);
- }
- break;
- }
-
- case COMMENT:
- if (*p != '-')
- break;
- if (p+2 < end && (p [1] == '-') && (p [2] == '>')){
- context->state = TEXT;
- p += 2;
- break;
- }
- break;
-
- case FLUSH_TEXT:
- if (context->parser.text != NULL && context->text != NULL){
- context->parser.text (context, context->text->str, context->text->len,
- context->user_data, error);
- if (error != NULL && *error != NULL)
- goto fail;
- }
-
- if (c == '/')
- context->state = CLOSING_ELEMENT;
- else {
- p--;
- context->state = START_ELEMENT;
- }
- break;
-
- case CLOSING_ELEMENT: {
- GSList *current = context->level;
- char *text;
-
- if (context->level == NULL){
- set_error ("%s", "Too many closing tags, not enough open tags");
- goto fail;
- }
-
- text = current->data;
- if (context->parser.end_element != NULL){
- context->parser.end_element (context, text, context->user_data, error);
- if (error != NULL && *error != NULL){
- g_free (text);
- goto fail;
- }
- }
- g_free (text);
-
- while (p < end && *p != '>')
- p++;
-
- context->level = context->level->next;
- g_slist_free_1 (current);
- context->state = TEXT;
- break;
- } /* case CLOSING_ELEMENT */
-
- } /* switch */
- }
-
-
- return TRUE;
- fail:
- if (context->parser.error && error != NULL && *error)
- context->parser.error (context, *error, context->user_data);
-
- destroy_parse_state (context);
- return FALSE;
-}
-
-gboolean
-g_markup_parse_context_end_parse (GMarkupParseContext *context, GError **error)
-{
- g_return_val_if_fail (context != NULL, FALSE);
-
- /*
- * In our case, we always signal errors during parse, not at the end
- * see the notes at the top of this file for details on how this
- * could be moved here
- */
- return TRUE;
-}
+++ /dev/null
-/*
- * gmem.c: memory utility functions
- *
- * Author:
- * Gonzalo Paniagua Javier (gonzalo@novell.com)
- *
- * (C) 2006 Novell, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-#include <config.h>
-#include <stdio.h>
-#include <string.h>
-#include <glib.h>
-
-#if defined (ENABLE_OVERRIDABLE_ALLOCATORS)
-
-static GMemVTable sGMemVTable = { malloc, realloc, free, calloc };
-
-void
-g_mem_set_vtable (GMemVTable* vtable)
-{
- sGMemVTable.calloc = vtable->calloc ? vtable->calloc : calloc;
- sGMemVTable.realloc = vtable->realloc ? vtable->realloc : realloc;
- sGMemVTable.malloc = vtable->malloc ? vtable->malloc : malloc;
- sGMemVTable.free = vtable->free ? vtable->free : free;
-}
-
-#define G_FREE_INTERNAL sGMemVTable.free
-#define G_REALLOC_INTERNAL sGMemVTable.realloc
-#define G_CALLOC_INTERNAL sGMemVTable.calloc
-#define G_MALLOC_INTERNAL sGMemVTable.malloc
-#else
-
-void
-g_mem_set_vtable (GMemVTable* vtable)
-{
-}
-
-#define G_FREE_INTERNAL free
-#define G_REALLOC_INTERNAL realloc
-#define G_CALLOC_INTERNAL calloc
-#define G_MALLOC_INTERNAL malloc
-#endif
-void
-g_free (void *ptr)
-{
- if (ptr != NULL)
- G_FREE_INTERNAL (ptr);
-}
-
-gpointer
-g_memdup (gconstpointer mem, guint byte_size)
-{
- gpointer ptr;
-
- if (mem == NULL)
- return NULL;
-
- ptr = g_malloc (byte_size);
- if (ptr != NULL)
- memcpy (ptr, mem, byte_size);
-
- return ptr;
-}
-
-gpointer g_realloc (gpointer obj, gsize size)
-{
- gpointer ptr;
- if (!size) {
- g_free (obj);
- return 0;
- }
- ptr = G_REALLOC_INTERNAL (obj, size);
- if (ptr)
- return ptr;
- g_error ("Could not allocate %i bytes", size);
-}
-
-gpointer
-g_malloc (gsize x)
-{
- gpointer ptr;
- if (!x)
- return 0;
- ptr = G_MALLOC_INTERNAL (x);
- if (ptr)
- return ptr;
- g_error ("Could not allocate %i bytes", x);
-}
-
-gpointer g_calloc (gsize n, gsize x)
-{
- gpointer ptr;
- if (!x || !n)
- return 0;
- ptr = G_CALLOC_INTERNAL (n, x);
- if (ptr)
- return ptr;
- g_error ("Could not allocate %i (%i * %i) bytes", x*n, n, x);
-}
-gpointer g_malloc0 (gsize x)
-{
- return g_calloc (1,x);
-}
-
-gpointer g_try_malloc (gsize x)
-{
- if (x)
- return G_MALLOC_INTERNAL (x);
- return 0;
-}
-
-
-gpointer g_try_realloc (gpointer obj, gsize size)
-{
- if (!size) {
- G_FREE_INTERNAL (obj);
- return 0;
- }
- return G_REALLOC_INTERNAL (obj, size);
-}
+++ /dev/null
-/*
- * gmisc.c: Misc functions with no place to go (right now)
- *
- * Author:
- * Aaron Bockover (abockover@novell.com)
- *
- * (C) 2006 Novell, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-#include <config.h>
-#include <stdlib.h>
-#include <glib.h>
-#include <pthread.h>
-
-#ifdef HAVE_PWD_H
-#include <pwd.h>
-#endif
-
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
-static pthread_mutex_t env_lock = PTHREAD_MUTEX_INITIALIZER;
-
-/* MONO Comment
- *
- * As per the UNIX spec,
- * "The return value from getenv() may point to static data which may be overwritten by subsequent calls to getenv(), setenv(), or unsetenv()."
- * Source: Unix Manual Pages for getenv, IEEE Std 1003.1
- *
- * This means that using pointers returned from getenv may (and does) lead to many
- * pointers which refer to the same piece of memory. When one is freed, all will be freed.
- *
- * This is unsafe and an ergonomics risk to fix in the callers. While the caller could lock,
- * this introduces the risk for looping or exiting while inside of a lock. For this reason,
- * g_getenv does not mimic the behavior of POSIX getenv anymore.
- *
- * The memory address returned will be unique to the invocaton, and must be freed.
- * */
-gchar *
-g_getenv (const gchar *variable)
-{
- gchar *ret = NULL;
- pthread_mutex_lock (&env_lock);
- gchar *res = getenv(variable);
- if (res)
- ret = g_strdup(res);
- pthread_mutex_unlock (&env_lock);
-
- return ret;
-}
-
-/*
- * This function checks if the given variable is non-NULL
- * in the environment. It's useful because it removes memory
- * freeing requirements.
- *
- */
-gboolean
-g_hasenv (const gchar *variable)
-{
- pthread_mutex_lock (&env_lock);
- gchar *res = getenv(variable);
- gboolean not_null = (res != NULL);
- pthread_mutex_unlock (&env_lock);
-
- return not_null;
-}
-
-gboolean
-g_setenv(const gchar *variable, const gchar *value, gboolean overwrite)
-{
- gboolean res;
- pthread_mutex_lock (&env_lock);
- res = (setenv(variable, value, overwrite) == 0);
- pthread_mutex_unlock (&env_lock);
- return res;
-}
-
-void
-g_unsetenv(const gchar *variable)
-{
- pthread_mutex_lock (&env_lock);
- unsetenv(variable);
- pthread_mutex_unlock (&env_lock);
-}
-
-gchar*
-g_win32_getlocale(void)
-{
- return NULL;
-}
-
-gboolean
-g_path_is_absolute (const char *filename)
-{
- g_return_val_if_fail (filename != NULL, FALSE);
-
- return (*filename == '/');
-}
-
-static pthread_mutex_t pw_lock = PTHREAD_MUTEX_INITIALIZER;
-static const gchar *home_dir;
-static const gchar *user_name;
-
-static void
-get_pw_data (void)
-{
-#ifdef HAVE_GETPWUID_R
- struct passwd pw;
- struct passwd *result;
- char buf [4096];
-#endif
-
- if (user_name != NULL)
- return;
-
- pthread_mutex_lock (&pw_lock);
- if (user_name != NULL) {
- pthread_mutex_unlock (&pw_lock);
- return;
- }
-
- home_dir = g_getenv ("HOME");
- user_name = g_getenv ("USER");
-
-#ifdef HAVE_GETPWUID_R
- if (home_dir == NULL || user_name == NULL) {
- if (getpwuid_r (getuid (), &pw, buf, 4096, &result) == 0) {
- if (home_dir == NULL)
- home_dir = g_strdup (pw.pw_dir);
- if (user_name == NULL)
- user_name = g_strdup (pw.pw_name);
- }
- }
-#endif
-
- if (user_name == NULL)
- user_name = "somebody";
- if (home_dir == NULL)
- home_dir = "/";
-
- pthread_mutex_unlock (&pw_lock);
-}
-
-const gchar *
-g_get_home_dir (void)
-{
- get_pw_data ();
- return home_dir;
-}
-
-const char *
-g_get_user_name (void)
-{
- get_pw_data ();
- return user_name;
-}
-
-static const char *tmp_dir;
-
-static pthread_mutex_t tmp_lock = PTHREAD_MUTEX_INITIALIZER;
-
-const gchar *
-g_get_tmp_dir (void)
-{
- if (tmp_dir == NULL){
- pthread_mutex_lock (&tmp_lock);
- if (tmp_dir == NULL){
- tmp_dir = g_getenv ("TMPDIR");
- if (tmp_dir == NULL){
- tmp_dir = g_getenv ("TMP");
- if (tmp_dir == NULL){
- tmp_dir = g_getenv ("TEMP");
- if (tmp_dir == NULL)
- tmp_dir = "/tmp";
- }
- }
- }
- pthread_mutex_unlock (&tmp_lock);
- }
- return tmp_dir;
-}
-
+++ /dev/null
-/*
- * gmisc-win32-uwp.c: UWP misc support.
- *
- * Copyright 2016 Microsoft
- * Licensed under the MIT license. See LICENSE file in the project root for full license information.
-*/
-#include <config.h>
-#include <glib.h>
-
-#if G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT)
-#include <windows.h>
-#include <assert.h>
-
-gchar*
-g_win32_getlocale(void)
-{
- gunichar2 buf[19];
- gint ccBuf = GetLocaleInfoEx (LOCALE_NAME_USER_DEFAULT, LOCALE_SISO639LANGNAME, buf, 9);
- assert (ccBuf <= 9);
- if (ccBuf != 0) {
- buf[ccBuf - 1] = L'-';
- ccBuf = GetLocaleInfoEx (LOCALE_NAME_USER_DEFAULT, LOCALE_SISO3166CTRYNAME, buf + ccBuf, 9);
- assert (ccBuf <= 9);
- }
-
- // Check for GetLocaleInfoEx failure.
- if (ccBuf == 0)
- buf[0] = L'\0';
-
- return u16to8 (buf);
-}
-
-#else /* G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT) */
-
-#ifdef _MSC_VER
-// Quiet Visual Studio linker warning, LNK4221, in cases when this source file intentional ends up empty.
-void __mono_win32_gmisc_win32_uwp_quiet_lnk4221(void) {}
-#endif
-#endif /* G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT) */
+++ /dev/null
-/*
- * gmisc.c: Misc functions with no place to go (right now)
- *
- * Author:
- * Aaron Bockover (abockover@novell.com)
- *
- * (C) 2006 Novell, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-#include <config.h>
-
-#include <stdlib.h>
-#include <glib.h>
-
-#include <windows.h>
-#if _MSC_VER && G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
-#include <shlobj.h>
-#endif
-#include <direct.h>
-#include <io.h>
-#include <assert.h>
-
-gboolean
-g_hasenv (const gchar *variable)
-{
- return g_getenv (variable) != NULL;
-}
-
-gchar *
-g_getenv(const gchar *variable)
-{
- gunichar2 *var, *buffer;
- gchar* val = NULL;
- gint32 buffer_size = 1024;
- gint32 retval;
- var = u8to16(variable);
- buffer = g_malloc(buffer_size*sizeof(gunichar2));
- retval = GetEnvironmentVariableW (var, buffer, buffer_size);
- if (retval != 0) {
- if (retval > buffer_size) {
- g_free (buffer);
- buffer_size = retval;
- buffer = g_malloc(buffer_size*sizeof(gunichar2));
- retval = GetEnvironmentVariableW (var, buffer, buffer_size);
- }
- val = u16to8 (buffer);
- } else {
- if (GetLastError () != ERROR_ENVVAR_NOT_FOUND){
- val = g_malloc (1);
- *val = 0;
- }
- }
- g_free(var);
- g_free(buffer);
- return val;
-}
-
-gboolean
-g_setenv(const gchar *variable, const gchar *value, gboolean overwrite)
-{
- gunichar2 *var, *val;
- gboolean result;
- var = u8to16(variable);
- val = u8to16(value);
- result = (SetEnvironmentVariableW(var, val) != 0) ? TRUE : FALSE;
- g_free(var);
- g_free(val);
- return result;
-}
-
-void
-g_unsetenv(const gchar *variable)
-{
- gunichar2 *var;
- var = u8to16(variable);
- SetEnvironmentVariableW(var, L"");
- g_free(var);
-}
-
-#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
-gchar*
-g_win32_getlocale(void)
-{
- LCID lcid = GetThreadLocale();
- gchar buf[19];
- gint ccBuf = GetLocaleInfoA(lcid, LOCALE_SISO639LANGNAME, buf, 9);
- buf[ccBuf - 1] = '-';
- ccBuf += GetLocaleInfoA(lcid, LOCALE_SISO3166CTRYNAME, buf + ccBuf, 9);
- return g_strdup (buf);
-}
-#endif /* G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) */
-
-gboolean
-g_path_is_absolute (const char *filename)
-{
- g_return_val_if_fail (filename != NULL, FALSE);
-
- if (filename[0] != '\0' && filename[1] != '\0') {
- if (filename[1] == ':' && filename[2] != '\0' &&
- (filename[2] == '\\' || filename[2] == '/'))
- return TRUE;
- /* UNC paths */
- else if (filename[0] == '\\' && filename[1] == '\\' &&
- filename[2] != '\0')
- return TRUE;
- }
-
- return FALSE;
-}
-
-#if _MSC_VER && G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
-static gchar*
-g_get_known_folder_path (void)
-{
- gchar *folder_path = NULL;
- PWSTR profile_path = NULL;
- HRESULT hr = SHGetKnownFolderPath (&FOLDERID_Profile, KF_FLAG_DEFAULT, NULL, &profile_path);
- if (SUCCEEDED(hr)) {
- folder_path = u16to8 (profile_path);
- CoTaskMemFree (profile_path);
- }
-
- return folder_path;
-}
-
-#else
-
-static inline gchar *
-g_get_known_folder_path (void)
-{
- return NULL;
-}
-#endif
-
-const gchar *
-g_get_home_dir (void)
-{
- gchar *home_dir = g_get_known_folder_path ();
-
- if (!home_dir) {
- home_dir = (gchar *) g_getenv ("USERPROFILE");
- }
-
- if (!home_dir) {
- const gchar *drive = g_getenv ("HOMEDRIVE");
- const gchar *path = g_getenv ("HOMEPATH");
-
- if (drive && path) {
- home_dir = g_malloc (strlen (drive) + strlen (path) + 1);
- if (home_dir) {
- sprintf (home_dir, "%s%s", drive, path);
- }
- }
- g_free (drive);
- g_free (path);
- }
-
- return home_dir;
-}
-
-const char *
-g_get_user_name (void)
-{
- const char * retName = g_getenv ("USER");
- if (!retName)
- retName = g_getenv ("USERNAME");
- return retName;
-}
-
-static const char *tmp_dir;
-
-const gchar *
-g_get_tmp_dir (void)
-{
- if (tmp_dir == NULL){
- if (tmp_dir == NULL){
- tmp_dir = g_getenv ("TMPDIR");
- if (tmp_dir == NULL){
- tmp_dir = g_getenv ("TMP");
- if (tmp_dir == NULL){
- tmp_dir = g_getenv ("TEMP");
- if (tmp_dir == NULL)
- tmp_dir = "C:\\temp";
- }
- }
- }
- }
- return tmp_dir;
-}
+++ /dev/null
-/*
- * gmodule.c: dl* functions, glib style
- *
- * Author:
- * Gonzalo Paniagua Javier (gonzalo@novell.com)
- * Jonathan Chambers (joncham@gmail.com)
- * Robert Jordan (robertj@gmx.net)
- *
- * (C) 2006 Novell, Inc.
- * (C) 2006 Jonathan Chambers
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-#include <config.h>
-
-#include <glib.h>
-#include <gmodule.h>
-
-#if defined(G_OS_UNIX) && defined(HAVE_DLFCN_H)
-#include <dlfcn.h>
-
-/* For Linux and Solaris, need to add others as we port this */
-#define LIBPREFIX "lib"
-#define LIBSUFFIX ".so"
-
-struct _GModule {
- void *handle;
-};
-
-GModule *
-g_module_open (const gchar *file, GModuleFlags flags)
-{
- int f = 0;
- GModule *module;
- void *handle;
-
- flags &= G_MODULE_BIND_MASK;
- if ((flags & G_MODULE_BIND_LAZY) != 0)
- f |= RTLD_LAZY;
- if ((flags & G_MODULE_BIND_LOCAL) != 0)
- f |= RTLD_LOCAL;
-
- handle = dlopen (file, f);
- if (handle == NULL)
- return NULL;
-
- module = g_new (GModule,1);
- module->handle = handle;
-
- return module;
-}
-
-gboolean
-g_module_symbol (GModule *module, const gchar *symbol_name, gpointer *symbol)
-{
- if (symbol_name == NULL || symbol == NULL)
- return FALSE;
-
- if (module == NULL || module->handle == NULL)
- return FALSE;
-
- *symbol = dlsym (module->handle, symbol_name);
- return (*symbol != NULL);
-}
-
-const gchar *
-g_module_error (void)
-{
- return dlerror ();
-}
-
-gboolean
-g_module_close (GModule *module)
-{
- void *handle;
- if (module == NULL || module->handle == NULL)
- return FALSE;
-
- handle = module->handle;
- module->handle = NULL;
- g_free (module);
- return (0 == dlclose (handle));
-}
-
-#elif defined (G_OS_WIN32)
-#include <windows.h>
-#include <psapi.h>
-
-#define LIBSUFFIX ".dll"
-#define LIBPREFIX ""
-
-struct _GModule {
- HMODULE handle;
- int main_module;
-};
-
-GModule *
-g_module_open (const gchar *file, GModuleFlags flags)
-{
- GModule *module;
- module = g_malloc (sizeof (GModule));
- if (module == NULL)
- return NULL;
-
- if (file != NULL) {
- gunichar2 *file16;
- file16 = u8to16(file);
- module->main_module = FALSE;
- module->handle = LoadLibrary (file16);
- g_free(file16);
- if (!module->handle) {
- g_free (module);
- return NULL;
- }
-
- } else {
- module->main_module = TRUE;
- module->handle = GetModuleHandle (NULL);
- }
-
- return module;
-}
-
-static gpointer
-w32_find_symbol (const gchar *symbol_name)
-{
- HMODULE *modules;
- DWORD buffer_size = sizeof (HMODULE) * 1024;
- DWORD needed, i;
-
- modules = (HMODULE *) g_malloc (buffer_size);
-
- if (modules == NULL)
- return NULL;
-
- if (!EnumProcessModules (GetCurrentProcess (), modules,
- buffer_size, &needed)) {
- g_free (modules);
- return NULL;
- }
-
- /* check whether the supplied buffer was too small, realloc, retry */
- if (needed > buffer_size) {
- g_free (modules);
-
- buffer_size = needed;
- modules = (HMODULE *) g_malloc (buffer_size);
-
- if (modules == NULL)
- return NULL;
-
- if (!EnumProcessModules (GetCurrentProcess (), modules,
- buffer_size, &needed)) {
- g_free (modules);
- return NULL;
- }
- }
-
- for (i = 0; i < needed / sizeof (HANDLE); i++) {
- gpointer proc = (gpointer)(intptr_t)GetProcAddress (modules [i], symbol_name);
- if (proc != NULL) {
- g_free (modules);
- return proc;
- }
- }
-
- g_free (modules);
- return NULL;
-}
-
-gboolean
-g_module_symbol (GModule *module, const gchar *symbol_name, gpointer *symbol)
-{
- if (module == NULL || symbol_name == NULL || symbol == NULL)
- return FALSE;
-
- if (module->main_module) {
- *symbol = (gpointer)(intptr_t)GetProcAddress (module->handle, symbol_name);
- if (*symbol != NULL)
- return TRUE;
-
- *symbol = w32_find_symbol (symbol_name);
- return *symbol != NULL;
- } else {
- *symbol = (gpointer)(intptr_t)GetProcAddress (module->handle, symbol_name);
- return *symbol != NULL;
- }
-}
-
-const gchar *
-g_module_error (void)
-{
- gchar* ret = NULL;
- TCHAR* buf = NULL;
- DWORD code = GetLastError ();
-
- FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER, NULL,
- code, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), buf, 0, NULL);
-
- ret = u16to8 (buf);
- LocalFree(buf);
-
- return ret;
-}
-
-gboolean
-g_module_close (GModule *module)
-{
- HMODULE handle;
- int main_module;
-
- if (module == NULL || module->handle == NULL)
- return FALSE;
-
- handle = module->handle;
- main_module = module->main_module;
- module->handle = NULL;
- g_free (module);
- return (main_module ? 1 : (0 == FreeLibrary (handle)));
-}
-
-#else
-
-#define LIBSUFFIX ""
-#define LIBPREFIX ""
-
-GModule *
-g_module_open (const gchar *file, GModuleFlags flags)
-{
- g_error ("%s", "g_module_open not implemented on this platform");
- return NULL;
-}
-
-gboolean
-g_module_symbol (GModule *module, const gchar *symbol_name, gpointer *symbol)
-{
- g_error ("%s", "g_module_open not implemented on this platform");
- return FALSE;
-}
-
-const gchar *
-g_module_error (void)
-{
- g_error ("%s", "g_module_open not implemented on this platform");
- return NULL;
-}
-
-gboolean
-g_module_close (GModule *module)
-{
- g_error ("%s", "g_module_open not implemented on this platform");
- return FALSE;
-}
-#endif
-
-gchar *
-g_module_build_path (const gchar *directory, const gchar *module_name)
-{
- char *lib_prefix = "";
-
- if (module_name == NULL)
- return NULL;
-
- if (strncmp (module_name, "lib", 3) != 0)
- lib_prefix = LIBPREFIX;
-
- if (directory && *directory){
-
- return g_strdup_printf ("%s/%s%s" LIBSUFFIX, directory, lib_prefix, module_name);
- }
- return g_strdup_printf ("%s%s" LIBSUFFIX, lib_prefix, module_name);
-}
-
+++ /dev/null
-#ifndef __G_MODULE_WINDOWS_INTERNALS_H__
-#define __G_MODULE_WINDOWS_INTERNALS_H__
-
-#include <config.h>
-#include <glib.h>
-
-#ifdef G_OS_WIN32
-#include <gmodule.h>
-
-gpointer
-w32_find_symbol (const gchar *symbol_name);
-#endif /* G_OS_WIN32 */
-#endif /* __G_MODULE_WINDOWS_INTERNALS_H__ */
+++ /dev/null
-/*
- * gmodule-win32-uwp.c: UWP gmodule support.
- *
- * Copyright 2016 Microsoft
- * Licensed under the MIT license. See LICENSE file in the project root for full license information.
-*/
-#include <config.h>
-#include <glib.h>
-
-#if G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT)
-#include <windows.h>
-#include <gmodule-win32-internals.h>
-
-gpointer
-w32_find_symbol (const gchar *symbol_name)
-{
- g_unsupported_api ("EnumProcessModules");
- SetLastError (ERROR_NOT_SUPPORTED);
- return NULL;
-}
-
-const gchar *
-g_module_error (void)
-{
- gchar *ret = NULL;
- TCHAR buf [1024];
- DWORD code = GetLastError ();
-
- if (!FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL,
- code, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), buf, G_N_ELEMENTS (buf) - 1, NULL) )
- buf[0] = TEXT('\0');
-
- ret = u16to8 (buf);
- return ret;
-}
-
-#else /* G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT) */
-
-#ifdef _MSC_VER
-// Quiet Visual Studio linker warning, LNK4221, in cases when this source file intentional ends up empty.
-void __mono_win32_gmodule_win32_uwp_quiet_lnk4221(void) {}
-#endif
-#endif /* G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT) */
+++ /dev/null
-/*
- * gmodule.c: dl* functions, glib style
- *
- * Author:
- * Gonzalo Paniagua Javier (gonzalo@novell.com)
- * Jonathan Chambers (joncham@gmail.com)
- * Robert Jordan (robertj@gmx.net)
- *
- * (C) 2006 Novell, Inc.
- * (C) 2006 Jonathan Chambers
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-#include <config.h>
-#include <glib.h>
-#include <windows.h>
-#include <psapi.h>
-#include <gmodule-win32-internals.h>
-
-#define LIBSUFFIX ".dll"
-#define LIBPREFIX ""
-
-struct _GModule {
- HMODULE handle;
- int main_module;
-};
-
-GModule *
-g_module_open (const gchar *file, GModuleFlags flags)
-{
- GModule *module;
- module = g_malloc (sizeof (GModule));
- if (module == NULL)
- return NULL;
-
- if (file != NULL) {
- gunichar2 *file16;
- file16 = u8to16(file);
- module->main_module = FALSE;
- module->handle = LoadLibraryW (file16);
- g_free(file16);
- if (!module->handle) {
- g_free (module);
- return NULL;
- }
-
- } else {
- module->main_module = TRUE;
- module->handle = GetModuleHandle (NULL);
- }
-
- return module;
-}
-
-#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
-gpointer
-w32_find_symbol (const gchar *symbol_name)
-{
- HMODULE *modules;
- DWORD buffer_size = sizeof (HMODULE) * 1024;
- DWORD needed, i;
-
- modules = (HMODULE *) g_malloc (buffer_size);
-
- if (modules == NULL)
- return NULL;
-
- if (!EnumProcessModules (GetCurrentProcess (), modules,
- buffer_size, &needed)) {
- g_free (modules);
- return NULL;
- }
-
- /* check whether the supplied buffer was too small, realloc, retry */
- if (needed > buffer_size) {
- g_free (modules);
-
- buffer_size = needed;
- modules = (HMODULE *) g_malloc (buffer_size);
-
- if (modules == NULL)
- return NULL;
-
- if (!EnumProcessModules (GetCurrentProcess (), modules,
- buffer_size, &needed)) {
- g_free (modules);
- return NULL;
- }
- }
-
- for (i = 0; i < needed / sizeof (HANDLE); i++) {
- gpointer proc = (gpointer)(intptr_t)GetProcAddress (modules [i], symbol_name);
- if (proc != NULL) {
- g_free (modules);
- return proc;
- }
- }
-
- g_free (modules);
- return NULL;
-}
-#endif /* G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) */
-
-gboolean
-g_module_symbol (GModule *module, const gchar *symbol_name, gpointer *symbol)
-{
- if (module == NULL || symbol_name == NULL || symbol == NULL)
- return FALSE;
-
- if (module->main_module) {
- *symbol = (gpointer)(intptr_t)GetProcAddress (module->handle, symbol_name);
- if (*symbol != NULL)
- return TRUE;
-
- *symbol = w32_find_symbol (symbol_name);
- return *symbol != NULL;
- } else {
- *symbol = (gpointer)(intptr_t)GetProcAddress (module->handle, symbol_name);
- return *symbol != NULL;
- }
-}
-
-#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
-const gchar *
-g_module_error (void)
-{
- gchar* ret = NULL;
- TCHAR* buf = NULL;
- DWORD code = GetLastError ();
-
- /* FIXME: buf must not be NULL! */
- FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER, NULL,
- code, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), buf, 0, NULL);
-
- ret = u16to8 (buf);
- LocalFree(buf);
-
- return ret;
-}
-#endif /* G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) */
-
-gboolean
-g_module_close (GModule *module)
-{
- HMODULE handle;
- int main_module;
-
- if (module == NULL || module->handle == NULL)
- return FALSE;
-
- handle = module->handle;
- main_module = module->main_module;
- module->handle = NULL;
- g_free (module);
- return (main_module ? 1 : (0 == FreeLibrary (handle)));
-}
-
-gchar *
-g_module_build_path (const gchar *directory, const gchar *module_name)
-{
- char *lib_prefix = "";
-
- if (module_name == NULL)
- return NULL;
-
- if (strncmp (module_name, "lib", 3) != 0)
- lib_prefix = LIBPREFIX;
-
- if (directory && *directory){
-
- return g_strdup_printf ("%s/%s%s" LIBSUFFIX, directory, lib_prefix, module_name);
- }
- return g_strdup_printf ("%s%s" LIBSUFFIX, lib_prefix, module_name);
-}
+++ /dev/null
-#ifndef __GLIB_GMODULE_H
-#define __GLIB_GMODULE_H
-
-#include <glib.h>
-
-#define G_MODULE_IMPORT extern
-#ifdef G_OS_WIN32
-#define G_MODULE_EXPORT __declspec(dllexport)
-#else
-#define G_MODULE_EXPORT
-#endif
-
-G_BEGIN_DECLS
-
-/*
- * Modules
- */
-typedef enum {
- G_MODULE_BIND_LAZY = 0x01,
- G_MODULE_BIND_LOCAL = 0x02,
- G_MODULE_BIND_MASK = 0x03
-} GModuleFlags;
-typedef struct _GModule GModule;
-
-GModule *g_module_open (const gchar *file, GModuleFlags flags);
-gboolean g_module_symbol (GModule *module, const gchar *symbol_name,
- gpointer *symbol);
-const gchar *g_module_error (void);
-gboolean g_module_close (GModule *module);
-gchar * g_module_build_path (const gchar *directory, const gchar *module_name);
-
-extern char *gmodule_libprefix;
-extern char *gmodule_libsuffix;
-
-G_END_DECLS
-
-#endif
+++ /dev/null
-/*
- * Output and debugging functions
- *
- * Author:
- * Miguel de Icaza (miguel@novell.com)
- *
- * (C) 2006 Novell, Inc.
- * Copyright 2011 Xamarin Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-#include <config.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <glib.h>
-
-/* The current fatal levels, error is always fatal */
-static GLogLevelFlags fatal = G_LOG_LEVEL_ERROR;
-static GLogFunc default_log_func;
-static gpointer default_log_func_user_data;
-static GPrintFunc stdout_handler, stderr_handler;
-
-static void default_stdout_handler (const gchar *string);
-static void default_stderr_handler (const gchar *string);
-
-void
-g_print (const gchar *format, ...)
-{
- char *msg;
- va_list args;
-
- va_start (args, format);
- if (g_vasprintf (&msg, format, args) < 0) {
- va_end (args);
- return;
- }
- va_end (args);
-
- if (!stdout_handler)
- stdout_handler = default_stdout_handler;
-
- stdout_handler (msg);
- g_free (msg);
-}
-
-void
-g_printerr (const gchar *format, ...)
-{
- char *msg;
- va_list args;
-
- va_start (args, format);
- if (g_vasprintf (&msg, format, args) < 0) {
- va_end (args);
- return;
- }
- va_end (args);
-
- if (!stderr_handler)
- stderr_handler = default_stderr_handler;
-
- stderr_handler (msg);
- g_free (msg);
-}
-
-GLogLevelFlags
-g_log_set_always_fatal (GLogLevelFlags fatal_mask)
-{
- GLogLevelFlags old_fatal = fatal;
-
- fatal |= fatal_mask;
-
- return old_fatal;
-}
-
-GLogLevelFlags
-g_log_set_fatal_mask (const gchar *log_domain, GLogLevelFlags fatal_mask)
-{
- /*
- * Mono does not use a G_LOG_DOMAIN currently, so we just assume things are fatal
- * if we decide to set G_LOG_DOMAIN (we probably should) we should implement
- * this.
- */
- return fatal_mask;
-}
-
-void
-g_logv (const gchar *log_domain, GLogLevelFlags log_level, const gchar *format, va_list args)
-{
- char *msg;
-
- if (!default_log_func)
- default_log_func = g_log_default_handler;
-
- if (g_vasprintf (&msg, format, args) < 0)
- return;
-
- default_log_func (log_domain, log_level, msg, default_log_func_user_data);
- g_free (msg);
-}
-
-void
-g_log (const gchar *log_domain, GLogLevelFlags log_level, const gchar *format, ...)
-{
- va_list args;
-
- va_start (args, format);
- g_logv (log_domain, log_level, format, args);
- va_end (args);
-}
-
-void
-g_assertion_message (const gchar *format, ...)
-{
- va_list args;
-
- va_start (args, format);
- g_logv (G_LOG_DOMAIN, G_LOG_LEVEL_ERROR, format, args);
- va_end (args);
- exit (0);
-}
-
-#if TARGET_ANDROID
-#include <android/log.h>
-
-static android_LogPriority
-to_android_priority (GLogLevelFlags log_level)
-{
- switch (log_level & G_LOG_LEVEL_MASK)
- {
- case G_LOG_LEVEL_ERROR: return ANDROID_LOG_FATAL;
- case G_LOG_LEVEL_CRITICAL: return ANDROID_LOG_ERROR;
- case G_LOG_LEVEL_WARNING: return ANDROID_LOG_WARN;
- case G_LOG_LEVEL_MESSAGE: return ANDROID_LOG_INFO;
- case G_LOG_LEVEL_INFO: return ANDROID_LOG_DEBUG;
- case G_LOG_LEVEL_DEBUG: return ANDROID_LOG_VERBOSE;
- }
- return ANDROID_LOG_UNKNOWN;
-}
-
-void
-g_log_default_handler (const gchar *log_domain, GLogLevelFlags log_level, const gchar *message, gpointer unused_data)
-{
- __android_log_write (to_android_priority (log_level), log_domain, message);
- if (log_level & fatal)
- abort ();
-}
-
-static void
-default_stdout_handler (const gchar *message)
-{
- /* TODO: provide a proper app name */
- __android_log_write (ANDROID_LOG_ERROR, "mono", message);
-}
-
-static void
-default_stderr_handler (const gchar *message)
-{
- /* TODO: provide a proper app name */
- __android_log_write (ANDROID_LOG_ERROR, "mono", message);
-}
-
-
-#elif defined(HOST_IOS)
-#include <asl.h>
-
-static int
-to_asl_priority (GLogLevelFlags log_level)
-{
- switch (log_level & G_LOG_LEVEL_MASK)
- {
- case G_LOG_LEVEL_ERROR: return ASL_LEVEL_CRIT;
- case G_LOG_LEVEL_CRITICAL: return ASL_LEVEL_ERR;
- case G_LOG_LEVEL_WARNING: return ASL_LEVEL_WARNING;
- case G_LOG_LEVEL_MESSAGE: return ASL_LEVEL_NOTICE;
- case G_LOG_LEVEL_INFO: return ASL_LEVEL_INFO;
- case G_LOG_LEVEL_DEBUG: return ASL_LEVEL_DEBUG;
- }
- return ASL_LEVEL_ERR;
-}
-
-void
-g_log_default_handler (const gchar *log_domain, GLogLevelFlags log_level, const gchar *message, gpointer unused_data)
-{
- asl_log (NULL, NULL, to_asl_priority (log_level), "%s", message);
- if (log_level & fatal)
- abort ();
-}
-
-static void
-default_stdout_handler (const gchar *message)
-{
- asl_log (NULL, NULL, ASL_LEVEL_WARNING, "%s", message);
-}
-
-static void
-default_stderr_handler (const gchar *message)
-{
- asl_log (NULL, NULL, ASL_LEVEL_WARNING, "%s", message);
-}
-
-#else
-
-void
-g_log_default_handler (const gchar *log_domain, GLogLevelFlags log_level, const gchar *message, gpointer unused_data)
-{
- FILE *target = stdout;
-
- fprintf (target, "%s%s%s\n",
- log_domain != NULL ? log_domain : "",
- log_domain != NULL ? ": " : "",
- message);
-
- if (log_level & fatal) {
- fflush (stdout);
- fflush (stderr);
- abort ();
- }
-}
-
-static void
-default_stdout_handler (const gchar *string)
-{
- fprintf (stdout, "%s", string);
-}
-
-static void
-default_stderr_handler (const gchar *string)
-{
- fprintf (stderr, "%s", string);
-}
-
-#endif
-
-GLogFunc
-g_log_set_default_handler (GLogFunc log_func, gpointer user_data)
-{
- GLogFunc old = default_log_func;
- default_log_func = log_func;
- default_log_func_user_data = user_data;
- return old;
-}
-
-GPrintFunc
-g_set_print_handler (GPrintFunc func)
-{
- GPrintFunc old = stdout_handler;
- stdout_handler = func;
- return old;
-}
-
-GPrintFunc
-g_set_printerr_handler (GPrintFunc func)
-{
- GPrintFunc old = stderr_handler;
- stderr_handler = func;
- return old;
-}
-
+++ /dev/null
-/*
- * Portable Utility Functions
- *
- * Author:
- * Miguel de Icaza (miguel@novell.com)
- *
- * (C) 2006 Novell, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-#include <config.h>
-#include <stdio.h>
-#include <glib.h>
-#include <errno.h>
-#include <sys/stat.h>
-
-#ifdef G_OS_WIN32
-#include <direct.h>
-#endif
-
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
-gchar *
-g_build_path (const gchar *separator, const gchar *first_element, ...)
-{
- const char *elem, *next, *endptr;
- gboolean trimmed;
- GString *path;
- va_list args;
- size_t slen;
-
- g_return_val_if_fail (separator != NULL, NULL);
-
- path = g_string_sized_new (48);
- slen = strlen (separator);
-
- va_start (args, first_element);
- for (elem = first_element; elem != NULL; elem = next) {
- /* trim any trailing separators from @elem */
- endptr = elem + strlen (elem);
- trimmed = FALSE;
-
- while (endptr >= elem + slen) {
- if (strncmp (endptr - slen, separator, slen) != 0)
- break;
-
- endptr -= slen;
- trimmed = TRUE;
- }
-
- /* append elem, not including any trailing separators */
- if (endptr > elem)
- g_string_append_len (path, elem, endptr - elem);
-
- /* get the next element */
- do {
- if (!(next = va_arg (args, char *)))
- break;
-
- /* remove leading separators */
- while (!strncmp (next, separator, slen))
- next += slen;
- } while (*next == '\0');
-
- if (next || trimmed)
- g_string_append_len (path, separator, slen);
- }
- va_end (args);
-
- return g_string_free (path, FALSE);
-}
-
-static gchar*
-strrchr_seperator (const gchar* filename)
-{
-#ifdef G_OS_WIN32
- char *p2;
-#endif
- char *p;
-
- p = strrchr (filename, G_DIR_SEPARATOR);
-#ifdef G_OS_WIN32
- p2 = strrchr (filename, '/');
- if (p2 > p)
- p = p2;
-#endif
-
- return p;
-}
-
-gchar *
-g_path_get_dirname (const gchar *filename)
-{
- char *p, *r;
- size_t count;
- g_return_val_if_fail (filename != NULL, NULL);
-
- p = strrchr_seperator (filename);
- if (p == NULL)
- return g_strdup (".");
- if (p == filename)
- return g_strdup ("/");
- count = p - filename;
- r = g_malloc (count + 1);
- strncpy (r, filename, count);
- r [count] = 0;
-
- return r;
-}
-
-gchar *
-g_path_get_basename (const char *filename)
-{
- char *r;
- g_return_val_if_fail (filename != NULL, NULL);
-
- /* Empty filename -> . */
- if (!*filename)
- return g_strdup (".");
-
- /* No separator -> filename */
- r = strrchr_seperator (filename);
- if (r == NULL)
- return g_strdup (filename);
-
- /* Trailing slash, remove component */
- if (r [1] == 0){
- char *copy = g_strdup (filename);
- copy [r-filename] = 0;
- r = strrchr_seperator (copy);
-
- if (r == NULL){
- g_free (copy);
- return g_strdup ("/");
- }
- r = g_strdup (&r[1]);
- g_free (copy);
- return r;
- }
-
- return g_strdup (&r[1]);
-}
-
-#ifndef HAVE_STRTOK_R
-// This is from BSD's strtok_r
-
-char *
-strtok_r(char *s, const char *delim, char **last)
-{
- char *spanp;
- int c, sc;
- char *tok;
-
- if (s == NULL && (s = *last) == NULL)
- return NULL;
-
- /*
- * Skip (span) leading delimiters (s += strspn(s, delim), sort of).
- */
-cont:
- c = *s++;
- for (spanp = (char *)delim; (sc = *spanp++) != 0; ){
- if (c == sc)
- goto cont;
- }
-
- if (c == 0){ /* no non-delimiter characters */
- *last = NULL;
- return NULL;
- }
- tok = s - 1;
-
- /*
- * Scan token (scan for delimiters: s += strcspn(s, delim), sort of).
- * Note that delim must have one NUL; we stop if we see that, too.
- */
- for (;;){
- c = *s++;
- spanp = (char *)delim;
- do {
- if ((sc = *spanp++) == c) {
- if (c == 0)
- s = NULL;
- else {
- char *w = s - 1;
- *w = '\0';
- }
- *last = s;
- return tok;
- }
- }
- while (sc != 0);
- }
- /* NOTREACHED */
-}
-#endif
-
-gchar *
-g_find_program_in_path (const gchar *program)
-{
- char *p;
- char *x, *l;
- gchar *curdir = NULL;
- char *save = NULL;
-#ifdef G_OS_WIN32
- char *program_exe;
- char *suffix_list[5] = {".exe",".cmd",".bat",".com",NULL};
- int listx;
- gboolean hasSuffix;
-#endif
-
- g_return_val_if_fail (program != NULL, NULL);
- x = p = g_strdup (g_getenv ("PATH"));
-
- if (x == NULL || *x == '\0') {
- curdir = g_get_current_dir ();
- x = curdir;
- }
-
-#ifdef G_OS_WIN32
- /* see if program already has a suffix */
- listx = 0;
- hasSuffix = FALSE;
- while (!hasSuffix && suffix_list[listx]) {
- hasSuffix = g_str_has_suffix(program,suffix_list[listx++]);
- }
-#endif
-
- while ((l = strtok_r (x, G_SEARCHPATH_SEPARATOR_S, &save)) != NULL){
- char *probe_path;
-
- x = NULL;
- probe_path = g_build_path (G_DIR_SEPARATOR_S, l, program, NULL);
- if (access (probe_path, X_OK) == 0){ /* FIXME: on windows this is just a read permissions test */
- g_free (curdir);
- g_free (p);
- return probe_path;
- }
- g_free (probe_path);
-
-#ifdef G_OS_WIN32
- /* check for program with a suffix attached */
- if (!hasSuffix) {
- listx = 0;
- while (suffix_list[listx]) {
- program_exe = g_strjoin(NULL,program,suffix_list[listx],NULL);
- probe_path = g_build_path (G_DIR_SEPARATOR_S, l, program_exe, NULL);
- if (access (probe_path, X_OK) == 0){ /* FIXME: on windows this is just a read permissions test */
- g_free (curdir);
- g_free (p);
- g_free (program_exe);
- return probe_path;
- }
- listx++;
- g_free (probe_path);
- g_free (program_exe);
- }
- }
-#endif
- }
- g_free (curdir);
- g_free (p);
- return NULL;
-}
-
-static char *name;
-
-void
-g_set_prgname (const gchar *prgname)
-{
- name = g_strdup (prgname);
-}
-
-gchar *
-g_get_prgname (void)
-{
- return name;
-}
-
-gboolean
-g_ensure_directory_exists (const gchar *filename)
-{
-#ifdef G_OS_WIN32
- gchar *dir_utf8 = g_path_get_dirname (filename);
- gunichar2 *p;
- gunichar2 *dir_utf16 = NULL;
- int retval;
-
- if (!dir_utf8 || !dir_utf8 [0])
- return FALSE;
-
- dir_utf16 = g_utf8_to_utf16 (dir_utf8, strlen (dir_utf8), NULL, NULL, NULL);
- g_free (dir_utf8);
-
- if (!dir_utf16)
- return FALSE;
-
- p = dir_utf16;
-
- /* make life easy and only use one directory seperator */
- while (*p != '\0')
- {
- if (*p == '/')
- *p = '\\';
- p++;
- }
-
- p = dir_utf16;
-
- /* get past C:\ )*/
- while (*p++ != '\\')
- {
- }
-
- while (1) {
- gboolean bRet = FALSE;
- p = wcschr (p, '\\');
- if (p)
- *p = '\0';
- retval = _wmkdir (dir_utf16);
- if (retval != 0 && errno != EEXIST) {
- g_free (dir_utf16);
- return FALSE;
- }
- if (!p)
- break;
- *p++ = '\\';
- }
-
- g_free (dir_utf16);
- return TRUE;
-#else
- char *p;
- gchar *dir = g_path_get_dirname (filename);
- int retval;
- struct stat sbuf;
-
- if (!dir || !dir [0]) {
- g_free (dir);
- return FALSE;
- }
-
- if (stat (dir, &sbuf) == 0 && S_ISDIR (sbuf.st_mode)) {
- g_free (dir);
- return TRUE;
- }
-
- p = dir;
- while (*p == '/')
- p++;
-
- while (1) {
- p = strchr (p, '/');
- if (p)
- *p = '\0';
- retval = mkdir (dir, 0777);
- if (retval != 0 && errno != EEXIST) {
- g_free (dir);
- return FALSE;
- }
- if (!p)
- break;
- *p++ = '/';
- }
-
- g_free (dir);
- return TRUE;
-#endif
-}
-
+++ /dev/null
-/*
- * Simple pattern matching
- *
- * Author:
- * Gonzalo Paniagua Javier (gonzalo@novell.com
- *
- * (C) 2006 Novell, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-#include <glib.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <errno.h>
-#ifndef _MSC_VER
-#include <unistd.h>
-#endif
-
-typedef enum {
- MATCH_LITERAL,
- MATCH_ANYCHAR,
- MATCH_ANYTHING,
- MATCH_ANYTHING_END,
- MATCH_INVALID = -1
-} MatchType;
-
-typedef struct {
- MatchType type;
- gchar *str;
-} PData;
-
-struct _GPatternSpec {
- GSList *pattern;
-};
-
-static GSList *
-compile_pattern (const gchar *pattern)
-{
- GSList *list;
- size_t i, len;
- PData *data;
- gchar c;
- MatchType last = MATCH_INVALID;
- GString *str;
- gboolean free_str;
-
- if (pattern == NULL)
- return NULL;
-
- data = NULL;
- list = NULL;
- free_str = TRUE;
- str = g_string_new ("");
- for (i = 0, len = strlen (pattern); i < len; i++) {
- c = pattern [i];
- if (c == '*' || c == '?') {
- if (str->len > 0) {
- data = g_new0 (PData, 1);
- data->type = MATCH_LITERAL;
- data->str = g_string_free (str, FALSE);
- list = g_slist_append (list, data);
- str = g_string_new ("");
- }
-
- if (last == MATCH_ANYTHING && c == '*')
- continue;
-
- data = g_new0 (PData, 1);
- data->type = (c == '*') ? MATCH_ANYTHING : MATCH_ANYCHAR;
- list = g_slist_append (list, data);
- last = data->type;
- } else {
- g_string_append_c (str, c);
- last = MATCH_LITERAL;
- }
- }
-
- if (last == MATCH_ANYTHING && str->len == 0) {
- data->type = MATCH_ANYTHING_END;
- free_str = TRUE;
- } else if (str->len > 0) {
- data = g_new0 (PData, 1);
- data->type = MATCH_LITERAL;
- data->str = str->str;
- free_str = FALSE;
- list = g_slist_append (list, data);
- }
- g_string_free (str, free_str);
- return list;
-}
-
-#ifdef DEBUG_PATTERN
-static void
-print_pattern (gpointer data, gpointer user_data)
-{
- PData *d = (PData *) data;
-
- printf ("Type: %s", d->type == MATCH_LITERAL ? "literal" : d->type == MATCH_ANYCHAR ? "any char" : "anything");
- if (d->type == MATCH_LITERAL)
- printf (" String: %s", d->str);
- printf ("\n");
-}
-#endif
-
-GPatternSpec *
-g_pattern_spec_new (const gchar *pattern)
-{
- GPatternSpec *spec;
-
- g_return_val_if_fail (pattern != NULL, NULL);
- spec = g_new0 (GPatternSpec, 1);
- if (pattern) {
- spec->pattern = compile_pattern (pattern);
-#ifdef DEBUG_PATTERN
- g_slist_foreach (spec->pattern, print_pattern, NULL);
- printf ("\n");
-#endif
- }
- return spec;
-}
-
-static void
-free_pdata (gpointer data, gpointer user_data)
-{
- PData *d = (PData *) data;
-
- if (d->str)
- g_free (d->str);
- g_free (d);
-}
-
-void
-g_pattern_spec_free (GPatternSpec *pspec)
-{
- if (pspec) {
- g_slist_foreach (pspec->pattern, free_pdata, NULL);
- g_slist_free (pspec->pattern);
- pspec->pattern = NULL;
- }
- g_free (pspec);
-}
-
-static gboolean
-match_string (GSList *list, const gchar *str, size_t idx, size_t max)
-{
- size_t len;
-
- while (list && idx < max) {
- PData *data = (PData *) list->data;
-
- if (data->type == MATCH_ANYTHING_END)
- return TRUE;
-
- if (data->type == MATCH_LITERAL) {
- len = strlen (data->str);
- if (strncmp (&str [idx], data->str, len) != 0)
- return FALSE;
- idx += len;
- list = list->next;
- if (list) {
- /*
- * When recursing, we need this to avoid returning FALSE
- * because 'list' will not be NULL
- */
- data = (PData *) list->data;
- if (data->type == MATCH_ANYTHING_END)
- return TRUE;
- }
- } else if (data->type == MATCH_ANYCHAR) {
- idx++;
- list = list->next;
- } else if (data->type == MATCH_ANYTHING) {
- while (idx < max) {
- if (match_string (list->next, str, idx++, max))
- return TRUE;
- }
- return FALSE;
- } else {
- g_assert_not_reached ();
- }
- }
-
- return (list == NULL && idx >= max);
-}
-gboolean
-g_pattern_match_string (GPatternSpec *pspec, const gchar *string)
-{
- g_return_val_if_fail (pspec != NULL, FALSE);
- g_return_val_if_fail (string != NULL, FALSE);
-
- if (pspec->pattern == NULL)
- return FALSE;
- return match_string (pspec->pattern, string, 0, strlen (string));
-}
-
-
+++ /dev/null
-/*
- * Pointer Array
- *
- * Author:
- * Aaron Bockover (abockover@novell.com)
- * Gonzalo Paniagua Javier (gonzalo@novell.com)
- * Jeffrey Stedfast (fejj@novell.com)
- *
- * (C) 2006,2011 Novell, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-#include <stdlib.h>
-#include <glib.h>
-
-typedef struct _GPtrArrayPriv {
- gpointer *pdata;
- guint len;
- guint size;
-} GPtrArrayPriv;
-
-static void
-g_ptr_array_grow(GPtrArrayPriv *array, guint length)
-{
- guint new_length = array->len + length;
-
- g_return_if_fail(array != NULL);
-
- if(new_length <= array->size) {
- return;
- }
-
- array->size = 1;
-
- while(array->size < new_length) {
- array->size <<= 1;
- }
-
- array->size = MAX(array->size, 16);
- array->pdata = g_realloc(array->pdata, array->size * sizeof(gpointer));
-}
-
-GPtrArray *
-g_ptr_array_new(void)
-{
- return g_ptr_array_sized_new(0);
-}
-
-GPtrArray *
-g_ptr_array_sized_new(guint reserved_size)
-{
- GPtrArrayPriv *array = g_new0(GPtrArrayPriv, 1);
-
- array->pdata = NULL;
- array->len = 0;
- array->size = 0;
-
- if(reserved_size > 0) {
- g_ptr_array_grow(array, reserved_size);
- }
-
- return (GPtrArray *)array;
-}
-
-gpointer *
-g_ptr_array_free(GPtrArray *array, gboolean free_seg)
-{
- gpointer *data = NULL;
-
- g_return_val_if_fail(array != NULL, NULL);
-
- if(free_seg) {
- g_free(array->pdata);
- } else {
- data = array->pdata;
- }
-
- g_free(array);
-
- return data;
-}
-
-void
-g_ptr_array_set_size(GPtrArray *array, gint length)
-{
- g_return_if_fail(array != NULL);
-
- if((size_t)length > array->len) {
- g_ptr_array_grow((GPtrArrayPriv *)array, length);
- memset(array->pdata + array->len, 0, (length - array->len)
- * sizeof(gpointer));
- }
-
- array->len = length;
-}
-
-void
-g_ptr_array_add(GPtrArray *array, gpointer data)
-{
- g_return_if_fail(array != NULL);
- g_ptr_array_grow((GPtrArrayPriv *)array, 1);
- array->pdata[array->len++] = data;
-}
-
-gpointer
-g_ptr_array_remove_index(GPtrArray *array, guint index)
-{
- gpointer removed_node;
-
- g_return_val_if_fail(array != NULL, NULL);
- g_return_val_if_fail(index < array->len, NULL);
-
- removed_node = array->pdata[index];
-
- if(index != array->len - 1) {
- g_memmove(array->pdata + index, array->pdata + index + 1,
- (array->len - index - 1) * sizeof(gpointer));
- }
-
- array->len--;
- array->pdata[array->len] = NULL;
-
- return removed_node;
-}
-
-gpointer
-g_ptr_array_remove_index_fast(GPtrArray *array, guint index)
-{
- gpointer removed_node;
-
- g_return_val_if_fail(array != NULL, NULL);
- g_return_val_if_fail(index < array->len, NULL);
-
- removed_node = array->pdata[index];
-
- if(index != array->len - 1) {
- g_memmove(array->pdata + index, array->pdata + array->len - 1,
- sizeof(gpointer));
- }
-
- array->len--;
- array->pdata[array->len] = NULL;
-
- return removed_node;
-}
-
-gboolean
-g_ptr_array_remove(GPtrArray *array, gpointer data)
-{
- guint i;
-
- g_return_val_if_fail(array != NULL, FALSE);
-
- for(i = 0; i < array->len; i++) {
- if(array->pdata[i] == data) {
- g_ptr_array_remove_index(array, i);
- return TRUE;
- }
- }
-
- return FALSE;
-}
-
-gboolean
-g_ptr_array_remove_fast(GPtrArray *array, gpointer data)
-{
- guint i;
-
- g_return_val_if_fail(array != NULL, FALSE);
-
- for(i = 0; i < array->len; i++) {
- if(array->pdata[i] == data) {
- array->len--;
- if (array->len > 0)
- array->pdata [i] = array->pdata [array->len];
- else
- array->pdata [i] = NULL;
- return TRUE;
- }
- }
-
- return FALSE;
-}
-
-void
-g_ptr_array_foreach(GPtrArray *array, GFunc func, gpointer user_data)
-{
- guint i;
-
- for(i = 0; i < array->len; i++) {
- func(g_ptr_array_index(array, i), user_data);
- }
-}
-
-void
-g_ptr_array_sort(GPtrArray *array, GCompareFunc compare)
-{
- g_return_if_fail(array != NULL);
- qsort(array->pdata, array->len, sizeof(gpointer), compare);
-}
-
-void
-g_ptr_array_sort_with_data (GPtrArray *array, GCompareDataFunc compare, gpointer user_data)
-{
- g_return_if_fail (array != NULL);
-
- g_qsort_with_data (array->pdata, array->len, sizeof (gpointer), compare, user_data);
-}
-
+++ /dev/null
-/*
- * QuickSort
- *
- * Author: Jeffrey Stedfast <fejj@novell.com>
- *
- * (C) 2011 Novell, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-#include <stdlib.h>
-#include <glib.h>
-
-/* Any segment <= this threshold will be sorted using insertion
- * sort. OpenBSD seems to use a value of 7 so we'll go with that for
- * now... */
-#define MAX_THRESHOLD 7
-
-#define STACK_SIZE (8 * sizeof (size_t))
-
-typedef struct _QSortStack {
- char *array;
- size_t count;
-} QSortStack;
-
-#define QSORT_PUSH(sp, a, c) (sp->array = a, sp->count = c, sp++)
-#define QSORT_POP(sp, a, c) (sp--, a = sp->array, c = sp->count)
-
-#define SWAPTYPE(TYPE, a, b) { \
- long __n = size / sizeof (TYPE); \
- register TYPE *__a = (TYPE *) (a); \
- register TYPE *__b = (TYPE *) (b); \
- register TYPE t; \
- \
- do { \
- t = *__a; \
- *__a++ = *__b; \
- *__b++ = t; \
- } while (--__n > 0); \
-}
-
-#define SWAPBYTE(a, b) SWAPTYPE(char, (a), (b))
-#define SWAPLONG(a, b) SWAPTYPE(long, (a), (b))
-#define SWAP(a, b) if (swaplong) SWAPLONG((a), (b)) else SWAPBYTE((a), (b))
-
-/* check if we can swap by longs rather than bytes by making sure that
- * memory is properly aligned and that the element size is a multiple
- * of sizeof (long) */
-#define SWAP_INIT() swaplong = (((char *) base) - ((char *) 0)) % sizeof (long) == 0 && (size % sizeof (long)) == 0
-
-void
-g_qsort_with_data (gpointer base, size_t nmemb, size_t size, GCompareDataFunc compare, gpointer user_data)
-{
- QSortStack stack[STACK_SIZE], *sp;
- register char *i, *k, *mid;
- size_t n, n1, n2;
- char *lo, *hi;
- int swaplong;
-
- if (nmemb <= 1)
- return;
-
- SWAP_INIT ();
-
- /* initialize our stack */
- sp = stack;
- QSORT_PUSH (sp, base, nmemb);
-
- do {
- QSORT_POP (sp, lo, n);
-
- hi = lo + (n - 1) * size;
-
- if (n < MAX_THRESHOLD) {
- /* switch to insertion sort */
- for (i = lo + size; i <= hi; i += size)
- for (k = i; k > lo && compare (k - size, k, user_data) > 0; k -= size)
- SWAP (k - size, k);
-
- continue;
- }
-
- /* calculate the middle element */
- mid = lo + (n / 2) * size;
-
- /* once we re-order the lo, mid, and hi elements to be in
- * ascending order, we'll use mid as our pivot. */
- if (compare (mid, lo, user_data) < 0) {
- SWAP (mid, lo);
- }
-
- if (compare (hi, mid, user_data) < 0) {
- SWAP (mid, hi);
- if (compare (mid, lo, user_data) < 0) {
- SWAP (mid, lo);
- }
- }
-
- /* since we've already guaranteed that lo <= mid and mid <= hi,
- * we can skip comparing them again */
- i = lo + size;
- k = hi - size;
-
- do {
- /* find the first element with a value > pivot value */
- while (i < k && compare (i, mid, user_data) <= 0)
- i += size;
-
- /* find the last element with a value <= pivot value */
- while (k >= i && compare (mid, k, user_data) < 0)
- k -= size;
-
- if (k <= i)
- break;
-
- SWAP (i, k);
-
- /* make sure we keep track of our pivot element */
- if (mid == i) {
- mid = k;
- } else if (mid == k) {
- mid = i;
- }
-
- i += size;
- k -= size;
- } while (1);
-
- if (k != mid) {
- /* swap the pivot with the last element in the first partition */
- SWAP (mid, k);
- }
-
- /* calculate segment sizes */
- n2 = (hi - k) / size;
- n1 = (k - lo) / size;
-
- /* push our partitions onto the stack, largest first
- * (to make sure we don't run out of stack space) */
- if (n2 > n1) {
- if (n2 > 1) QSORT_PUSH (sp, k + size, n2);
- if (n1 > 1) QSORT_PUSH (sp, lo, n1);
- } else {
- if (n1 > 1) QSORT_PUSH (sp, lo, n1);
- if (n2 > 1) QSORT_PUSH (sp, k + size, n2);
- }
- } while (sp > stack);
-}
+++ /dev/null
-/*
- * gqueue.c: Queue
- *
- * Author:
- * Duncan Mak (duncan@novell.com)
- * Gonzalo Paniagua Javier (gonzalo@novell.com)
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * Copyright (c) 2006-2009 Novell, Inc.
- *
- */
-
-#include <stdio.h>
-#include <glib.h>
-
-gpointer
-g_queue_pop_head (GQueue *queue)
-{
- gpointer result;
- GList *old_head;
-
- if (!queue || queue->length == 0)
- return NULL;
-
- result = queue->head->data;
- old_head = queue->head;
- queue->head = old_head->next;
- g_list_free_1 (old_head);
-
- if (--queue->length)
- queue->head->prev = NULL;
- else
- queue->tail = NULL;
-
- return result;
-}
-
-gboolean
-g_queue_is_empty (GQueue *queue)
-{
- if (!queue)
- return TRUE;
-
- return queue->length == 0;
-}
-
-void
-g_queue_push_head (GQueue *queue, gpointer head)
-{
- if (!queue)
- return;
-
- queue->head = g_list_prepend (queue->head, head);
-
- if (!queue->tail)
- queue->tail = queue->head;
-
- queue->length ++;
-}
-
-void
-g_queue_push_tail (GQueue *queue, gpointer data)
-{
- if (!queue)
- return;
-
- queue->tail = g_list_append (queue->tail, data);
- if (queue->head == NULL)
- queue->head = queue->tail;
- else
- queue->tail = queue->tail->next;
- queue->length++;
-}
-
-GQueue *
-g_queue_new (void)
-{
- return g_new0 (GQueue, 1);
-}
-
-void
-g_queue_free (GQueue *queue)
-{
- if (!queue)
- return;
-
- g_list_free (queue->head);
- g_free (queue);
-}
-
-void
-g_queue_foreach (GQueue *queue, GFunc func, gpointer user_data)
-{
- g_list_foreach (queue->head, func, user_data);
-}
+++ /dev/null
-/*
- * Shell utility functions.
- *
- * Author:
- * Gonzalo Paniagua Javier (gonzalo@novell.com
- *
- * (C) 2006 Novell, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-#include <stdio.h>
-#include <glib.h>
-
-static int
-split_cmdline (const gchar *cmdline, GPtrArray *array, GError **error)
-{
- gchar *ptr;
- gchar c;
- gboolean escaped = FALSE, fresh = TRUE;
- gchar quote_char = '\0';
- GString *str;
-
- str = g_string_new ("");
- ptr = (gchar *) cmdline;
- while ((c = *ptr++) != '\0') {
- if (escaped) {
- /*
- * \CHAR is only special inside a double quote if CHAR is
- * one of: $`"\ and newline
- */
- if (quote_char == '\"'){
- if (!(c == '$' || c == '`' || c == '"' || c == '\\'))
- g_string_append_c (str, '\\');
- g_string_append_c (str, c);
- } else {
- if (!g_ascii_isspace (c))
- g_string_append_c (str, c);
- }
- escaped = FALSE;
- } else if (quote_char) {
- if (c == quote_char) {
- quote_char = '\0';
- if (fresh && (g_ascii_isspace (*ptr) || *ptr == '\0')){
- g_ptr_array_add (array, g_string_free (str, FALSE));
- str = g_string_new ("");
- }
- } else if (c == '\\'){
- escaped = TRUE;
- } else
- g_string_append_c (str, c);
- } else if (g_ascii_isspace (c)) {
- if (str->len > 0) {
- g_ptr_array_add (array, g_string_free (str, FALSE));
- str = g_string_new ("");
- }
- } else if (c == '\\') {
- escaped = TRUE;
- } else if (c == '\'' || c == '"') {
- fresh = str->len == 0;
- quote_char = c;
- } else {
- g_string_append_c (str, c);
- }
- }
-
- if (escaped) {
- if (error)
- *error = g_error_new (G_LOG_DOMAIN, 0, "Unfinished escape.");
- g_string_free (str, TRUE);
- return -1;
- }
-
- if (quote_char) {
- if (error)
- *error = g_error_new (G_LOG_DOMAIN, 0, "Unfinished quote.");
- g_string_free (str, TRUE);
- return -1;
- }
-
- if (str->len > 0) {
- g_ptr_array_add (array, g_string_free (str, FALSE));
- } else {
- g_string_free (str, TRUE);
- }
- g_ptr_array_add (array, NULL);
- return 0;
-}
-
-gboolean
-g_shell_parse_argv (const gchar *command_line, gint *argcp, gchar ***argvp, GError **error)
-{
- GPtrArray *array;
- gint argc;
- gchar **argv;
-
- g_return_val_if_fail (command_line, FALSE);
- g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
-
- array = g_ptr_array_new();
- if (split_cmdline (command_line, array, error)) {
- g_ptr_array_add (array, NULL);
- g_strfreev ((gchar **) array->pdata);
- g_ptr_array_free (array, FALSE);
- return FALSE;
- }
-
- argc = array->len;
- argv = (gchar **) array->pdata;
-
- if (argc == 1) {
- g_strfreev (argv);
- g_ptr_array_free (array, FALSE);
- return FALSE;
- }
-
- if (argcp) {
- *argcp = array->len - 1;
- }
-
- if (argvp) {
- *argvp = argv;
- } else {
- g_strfreev (argv);
- }
-
- g_ptr_array_free (array, FALSE);
- return TRUE;
-}
-
-gchar *
-g_shell_quote (const gchar *unquoted_string)
-{
- GString *result = g_string_new ("'");
- const gchar *p;
-
- for (p = unquoted_string; *p; p++){
- if (*p == '\'')
- g_string_append (result, "'\\'");
- g_string_append_c (result, *p);
- }
- g_string_append_c (result, '\'');
- return g_string_free (result, FALSE);
-}
-
-gchar *
-g_shell_unquote (const gchar *quoted_string, GError **error)
-{
- GString *result;
- const char *p;
- int do_unquote = 0;
-
- if (quoted_string == NULL)
- return NULL;
-
- /* Quickly try to determine if we need to unquote or not */
- for (p = quoted_string; *p; p++){
- if (*p == '\'' || *p == '"' || *p == '\\'){
- do_unquote = 1;
- break;
- }
- }
-
- if (!do_unquote)
- return g_strdup (quoted_string);
-
- /* We do need to unquote */
- result = g_string_new ("");
- for (p = quoted_string; *p; p++){
-
- if (*p == '\''){
- /* Process single quote, not even \ is processed by glib's version */
- for (p++; *p; p++){
- if (*p == '\'')
- break;
- g_string_append_c (result, *p);
- }
- if (!*p){
- g_set_error (error, 0, 0, "Open quote");
- return NULL;
- }
- } else if (*p == '"'){
- /* Process double quote, allows some escaping */
- for (p++; *p; p++){
- if (*p == '"')
- break;
- if (*p == '\\'){
- p++;
- if (*p == 0){
- g_set_error (error, 0, 0, "Open quote");
- return NULL;
- }
- switch (*p){
- case '$':
- case '"':
- case '\\':
- case '`':
- break;
- default:
- g_string_append_c (result, '\\');
- break;
- }
- }
- g_string_append_c (result, *p);
- }
- if (!*p){
- g_set_error (error, 0, 0, "Open quote");
- return NULL;
- }
- } else if (*p == '\\'){
- char c = *(++p);
- if (!(c == '$' || c == '"' || c == '\\' || c == '`' || c == '\'' || c == 0 ))
- g_string_append_c (result, '\\');
- if (c == 0)
- break;
- else
- g_string_append_c (result, c);
- } else
- g_string_append_c (result, *p);
- }
- return g_string_free (result, FALSE);
-}
-
-#if JOINT_TEST
-/*
- * This test is designed to be built with the 2 glib/eglib to compare
- */
-
-char *args [] = {
- "\\",
- "\"Foo'bar\"",
- "'foo'",
- "'fo\'b'",
- "'foo\"bar'",
- "'foo' dingus bar",
- "'foo' 'bar' 'baz'",
- "\"foo\" 'bar' \"baz\"",
- "\"f\\$\\\'",
- "\"\\",
- "\\\\",
- "'\\\\'",
- "\"f\\$\"\\\"\\\\", // /\\\"\\\\"
- "'f\\$'\\\"\\\\",
- "'f\\$\\\\'",
- NULL
-};
-
-
-int
-main ()
-{
- char **s = args;
- int i;
-
- while (*s){
- char *r1 = g_shell_unquote (*s, NULL);
- char *r2 = g2_shell_unquote (*s, NULL);
- char *ok = r1 == r2 ? "ok" : (r1 != NULL && r2 != NULL && strcmp (r1, r2) == 0) ? "ok" : "fail";
-
- printf ("%s [%s] -> [%s] - [%s]\n", ok, *s, r1, r2);
- s++;
- }
- return;
- char buffer [10];
- buffer [0] = '\"';
- buffer [1] = '\\';
- buffer [3] = '\"';
- buffer [4] = 0;
-
- for (i = 32; i < 255; i++){
- buffer [2] = i;
- printf ("%d [%s] -> [%s]\n", i, buffer, g_shell_unquote (buffer, NULL));
- }
-}
-#endif
+++ /dev/null
-/*
- * gslist.c: Singly-linked list implementation
- *
- * Authors:
- * Duncan Mak (duncan@novell.com)
- * Raja R Harinath (rharinath@novell.com)
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * (C) 2006 Novell, Inc.
- */
-
-#include <stdio.h>
-#include <glib.h>
-
-GSList*
-g_slist_alloc (void)
-{
- return g_new0 (GSList, 1);
-}
-
-void
-g_slist_free_1 (GSList *list)
-{
- g_free (list);
-}
-
-GSList*
-g_slist_append (GSList *list, gpointer data)
-{
- return g_slist_concat (list, g_slist_prepend (NULL, data));
-}
-
-/* This is also a list node constructor. */
-GSList*
-g_slist_prepend (GSList *list, gpointer data)
-{
- GSList *head = g_slist_alloc ();
- head->data = data;
- head->next = list;
-
- return head;
-}
-
-/*
- * Insert the given data in a new node after the current node.
- * Return new node.
- */
-static inline GSList *
-insert_after (GSList *list, gpointer data)
-{
- list->next = g_slist_prepend (list->next, data);
- return list->next;
-}
-
-/*
- * Return the node prior to the node containing 'data'.
- * If the list is empty, or the first node contains 'data', return NULL.
- * If no node contains 'data', return the last node.
- */
-static inline GSList*
-find_prev (GSList *list, gconstpointer data)
-{
- GSList *prev = NULL;
- while (list) {
- if (list->data == data)
- break;
- prev = list;
- list = list->next;
- }
- return prev;
-}
-
-/* like 'find_prev', but searches for node 'link' */
-static inline GSList*
-find_prev_link (GSList *list, GSList *link)
-{
- GSList *prev = NULL;
- while (list) {
- if (list == link)
- break;
- prev = list;
- list = list->next;
- }
- return prev;
-}
-
-GSList*
-g_slist_insert_before (GSList *list, GSList *sibling, gpointer data)
-{
- GSList *prev = find_prev_link (list, sibling);
-
- if (!prev)
- return g_slist_prepend (list, data);
-
- insert_after (prev, data);
- return list;
-}
-
-void
-g_slist_free (GSList *list)
-{
- while (list) {
- GSList *next = list->next;
- g_slist_free_1 (list);
- list = next;
- }
-}
-
-GSList*
-g_slist_copy (GSList *list)
-{
- GSList *copy, *tmp;
-
- if (!list)
- return NULL;
-
- copy = g_slist_prepend (NULL, list->data);
- tmp = copy;
-
- for (list = list->next; list; list = list->next)
- tmp = insert_after (tmp, list->data);
-
- return copy;
-}
-
-GSList*
-g_slist_concat (GSList *list1, GSList *list2)
-{
- if (!list1)
- return list2;
-
- g_slist_last (list1)->next = list2;
- return list1;
-}
-
-void
-g_slist_foreach (GSList *list, GFunc func, gpointer user_data)
-{
- while (list) {
- (*func) (list->data, user_data);
- list = list->next;
- }
-}
-
-GSList*
-g_slist_last (GSList *list)
-{
- if (!list)
- return NULL;
-
- while (list->next)
- list = list->next;
-
- return list;
-}
-
-GSList*
-g_slist_find (GSList *list, gconstpointer data)
-{
- for (; list; list = list->next)
- if (list->data == data)
- break;
- return list;
-}
-
-GSList *
-g_slist_find_custom (GSList *list, gconstpointer data, GCompareFunc func)
-{
- if (!func)
- return NULL;
-
- while (list) {
- if (func (list->data, data) == 0)
- return list;
-
- list = list->next;
- }
-
- return NULL;
-}
-
-guint
-g_slist_length (GSList *list)
-{
- guint length = 0;
-
- while (list) {
- length ++;
- list = list->next;
- }
-
- return length;
-}
-
-GSList*
-g_slist_remove (GSList *list, gconstpointer data)
-{
- GSList *prev = find_prev (list, data);
- GSList *current = prev ? prev->next : list;
-
- if (current) {
- if (prev)
- prev->next = current->next;
- else
- list = current->next;
- g_slist_free_1 (current);
- }
-
- return list;
-}
-
-GSList*
-g_slist_remove_all (GSList *list, gconstpointer data)
-{
- GSList *next = list;
- GSList *prev = NULL;
- GSList *current;
-
- while (next) {
- GSList *tmp_prev = find_prev (next, data);
- if (tmp_prev)
- prev = tmp_prev;
- current = prev ? prev->next : list;
-
- if (!current)
- break;
-
- next = current->next;
-
- if (prev)
- prev->next = next;
- else
- list = next;
- g_slist_free_1 (current);
- }
-
- return list;
-}
-
-GSList*
-g_slist_remove_link (GSList *list, GSList *link)
-{
- GSList *prev = find_prev_link (list, link);
- GSList *current = prev ? prev->next : list;
-
- if (current) {
- if (prev)
- prev->next = current->next;
- else
- list = current->next;
- current->next = NULL;
- }
-
- return list;
-}
-
-GSList*
-g_slist_delete_link (GSList *list, GSList *link)
-{
- list = g_slist_remove_link (list, link);
- g_slist_free_1 (link);
-
- return list;
-}
-
-GSList*
-g_slist_reverse (GSList *list)
-{
- GSList *prev = NULL;
- while (list){
- GSList *next = list->next;
- list->next = prev;
- prev = list;
- list = next;
- }
-
- return prev;
-}
-
-GSList*
-g_slist_insert_sorted (GSList *list, gpointer data, GCompareFunc func)
-{
- GSList *prev = NULL;
-
- if (!func)
- return list;
-
- if (!list || func (list->data, data) > 0)
- return g_slist_prepend (list, data);
-
- /* Invariant: func (prev->data, data) <= 0) */
- for (prev = list; prev->next; prev = prev->next)
- if (func (prev->next->data, data) > 0)
- break;
-
- /* ... && (prev->next == 0 || func (prev->next->data, data) > 0)) */
- insert_after (prev, data);
- return list;
-}
-
-gint
-g_slist_index (GSList *list, gconstpointer data)
-{
- gint index = 0;
-
- while (list) {
- if (list->data == data)
- return index;
-
- index++;
- list = list->next;
- }
-
- return -1;
-}
-
-GSList*
-g_slist_nth (GSList *list, guint n)
-{
- for (; list; list = list->next) {
- if (n == 0)
- break;
- n--;
- }
- return list;
-}
-
-gpointer
-g_slist_nth_data (GSList *list, guint n)
-{
- GSList *node = g_slist_nth (list, n);
- return node ? node->data : NULL;
-}
-
-typedef GSList list_node;
-#include "sort.frag.h"
-
-GSList*
-g_slist_sort (GSList *list, GCompareFunc func)
-{
- if (!list || !list->next)
- return list;
- return do_sort (list, func);
-}
+++ /dev/null
-/*
- * Spawning processes.
- *
- * Author:
- * Gonzalo Paniagua Javier (gonzalo@novell.com
- *
- * (C) 2006 Novell, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-#include <config.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <sys/types.h>
-
-#include <glib.h>
-
-#ifdef HAVE_UNISTD_H
-#ifndef __USE_GNU
-#define __USE_GNU
-#endif
-#include <unistd.h>
-#endif
-
-#ifdef HAVE_SYS_SELECT_H
-#include <sys/select.h>
-#endif
-
-#ifdef HAVE_SYS_TIME_H
-#include <sys/time.h>
-#endif
-
-#ifdef HAVE_SYS_WAIT_H
-#include <sys/wait.h>
-#endif
-
-#ifdef HAVE_SYS_RESOURCE_H
-# include <sys/resource.h>
-#endif
-
-#ifdef G_OS_WIN32
-#include <io.h>
-#include <winsock2.h>
-#define open _open
-#define close _close
-#define read _read
-#define write _write
-/* windows pipe api details: http://msdn2.microsoft.com/en-us/library/edze9h7e(VS.80).aspx */
-#define pipe(x) _pipe(x, 256, 0)
-#endif
-
-#define set_error(msg, ...) do { if (error != NULL) *error = g_error_new (G_LOG_DOMAIN, 1, msg, __VA_ARGS__); } while (0)
-#define set_error_cond(cond,msg, ...) do { if ((cond) && error != NULL) *error = g_error_new (G_LOG_DOMAIN, 1, msg, __VA_ARGS__); } while (0)
-#define set_error_status(status,msg, ...) do { if (error != NULL) *error = g_error_new (G_LOG_DOMAIN, status, msg, __VA_ARGS__); } while (0)
-#define NO_INTR(var,cmd) do { (var) = (cmd); } while ((var) == -1 && errno == EINTR)
-#define CLOSE_PIPE(p) do { close (p [0]); close (p [1]); } while (0)
-
-#if defined(__APPLE__)
-#if defined (TARGET_OSX)
-/* Apple defines this in crt_externs.h but doesn't provide that header for
- * arm-apple-darwin9. We'll manually define the symbol on Apple as it does
- * in fact exist on all implementations (so far)
- */
-gchar ***_NSGetEnviron(void);
-#define environ (*_NSGetEnviron())
-#else
-static char *mono_environ[1] = { NULL };
-#define environ mono_environ
-#endif /* defined (TARGET_OSX) */
-#elif defined(_MSC_VER)
-/* MS defines this in stdlib.h */
-#else
-extern char **environ;
-#endif
-
-#ifndef G_OS_WIN32
-static int
-safe_read (int fd, gchar *buffer, gint count, GError **error)
-{
- int res;
-
- NO_INTR (res, read (fd, buffer, count));
- set_error_cond (res == -1, "%s", "Error reading from pipe.");
- return res;
-}
-
-static int
-read_pipes (int outfd, gchar **out_str, int errfd, gchar **err_str, GError **error)
-{
- fd_set rfds;
- int res;
- gboolean out_closed;
- gboolean err_closed;
- GString *out = NULL;
- GString *err = NULL;
- gchar *buffer = NULL;
- gint nread;
-
- out_closed = (outfd < 0);
- err_closed = (errfd < 0);
- if (out_str) {
- *out_str = NULL;
- out = g_string_new ("");
- }
-
- if (err_str) {
- *err_str = NULL;
- err = g_string_new ("");
- }
-
- do {
- if (out_closed && err_closed)
- break;
-
-#ifdef _MSC_VER
-#pragma warning(push)
-#pragma warning(disable:4389)
-#endif
-
- FD_ZERO (&rfds);
- if (!out_closed && outfd >= 0)
- FD_SET (outfd, &rfds);
- if (!err_closed && errfd >= 0)
- FD_SET (errfd, &rfds);
-
-#ifdef _MSC_VER
-#pragma warning(pop)
-#endif
-
- res = select (MAX (outfd, errfd) + 1, &rfds, NULL, NULL, NULL);
- if (res > 0) {
- if (buffer == NULL)
- buffer = g_malloc (1024);
- if (!out_closed && FD_ISSET (outfd, &rfds)) {
- nread = safe_read (outfd, buffer, 1024, error);
- if (nread < 0) {
- close (errfd);
- close (outfd);
- return -1;
- }
- g_string_append_len (out, buffer, nread);
- if (nread <= 0) {
- out_closed = TRUE;
- close (outfd);
- }
- }
-
- if (!err_closed && FD_ISSET (errfd, &rfds)) {
- nread = safe_read (errfd, buffer, 1024, error);
- if (nread < 0) {
- close (errfd);
- close (outfd);
- return -1;
- }
- g_string_append_len (err, buffer, nread);
- if (nread <= 0) {
- err_closed = TRUE;
- close (errfd);
- }
- }
- }
- } while (res > 0 || (res == -1 && errno == EINTR));
-
- g_free (buffer);
- if (out_str)
- *out_str = g_string_free (out, FALSE);
-
- if (err_str)
- *err_str = g_string_free (err, FALSE);
-
- return 0;
-}
-
-static gboolean
-create_pipe (int *fds, GError **error)
-{
- if (pipe (fds) == -1) {
- set_error ("%s", "Error creating pipe.");
- return FALSE;
- }
- return TRUE;
-}
-#endif /* G_OS_WIN32 */
-
-static int
-write_all (int fd, const void *vbuf, size_t n)
-{
- const char *buf = (const char *) vbuf;
- size_t nwritten = 0;
- int w;
-
- do {
- do {
- w = write (fd, buf + nwritten, n - nwritten);
- } while (w == -1 && errno == EINTR);
-
- if (w == -1)
- return -1;
-
- nwritten += w;
- } while (nwritten < n);
-
- return nwritten;
-}
-
-#ifndef G_OS_WIN32
-int
-eg_getdtablesize (void)
-{
-#ifdef HAVE_GETRLIMIT
- struct rlimit limit;
- int res;
-
- res = getrlimit (RLIMIT_NOFILE, &limit);
- g_assert (res == 0);
- return limit.rlim_cur;
-#else
- return getdtablesize ();
-#endif
-}
-#else
-int
-eg_getdtablesize (void)
-{
- g_error ("Should not be called");
-}
-#endif
-
-gboolean
-g_spawn_command_line_sync (const gchar *command_line,
- gchar **standard_output,
- gchar **standard_error,
- gint *exit_status,
- GError **error)
-{
-#ifdef G_OS_WIN32
-#elif !defined (HAVE_FORK) || !defined (HAVE_EXECV)
- fprintf (stderr, "g_spawn_command_line_sync not supported on this platform\n");
- return FALSE;
-#else
- pid_t pid;
- gchar **argv;
- gint argc;
- int stdout_pipe [2] = { -1, -1 };
- int stderr_pipe [2] = { -1, -1 };
- int status;
- int res;
-
- if (!g_shell_parse_argv (command_line, &argc, &argv, error))
- return FALSE;
-
- if (standard_output && !create_pipe (stdout_pipe, error))
- return FALSE;
-
- if (standard_error && !create_pipe (stderr_pipe, error)) {
- if (standard_output) {
- CLOSE_PIPE (stdout_pipe);
- }
- return FALSE;
- }
-
- pid = fork ();
- if (pid == 0) {
- gint i;
-
- if (standard_output) {
- close (stdout_pipe [0]);
- dup2 (stdout_pipe [1], STDOUT_FILENO);
- }
-
- if (standard_error) {
- close (stderr_pipe [0]);
- dup2 (stderr_pipe [1], STDERR_FILENO);
- }
- for (i = eg_getdtablesize () - 1; i >= 3; i--)
- close (i);
-
- /* G_SPAWN_SEARCH_PATH is always enabled for g_spawn_command_line_sync */
- if (!g_path_is_absolute (argv [0])) {
- gchar *arg0;
-
- arg0 = g_find_program_in_path (argv [0]);
- if (arg0 == NULL) {
- exit (1);
- }
- //g_free (argv [0]);
- argv [0] = arg0;
- }
- execv (argv [0], argv);
- exit (1); /* TODO: What now? */
- }
-
- g_strfreev (argv);
- if (standard_output)
- close (stdout_pipe [1]);
-
- if (standard_error)
- close (stderr_pipe [1]);
-
- if (standard_output || standard_error) {
- res = read_pipes (stdout_pipe [0], standard_output, stderr_pipe [0], standard_error, error);
- if (res) {
- waitpid (pid, &status, WNOHANG); /* avoid zombie */
- return FALSE;
- }
- }
-
- NO_INTR (res, waitpid (pid, &status, 0));
-
- /* TODO: What if error? */
- if (WIFEXITED (status) && exit_status) {
- *exit_status = WEXITSTATUS (status);
- }
-#endif
- return TRUE;
-}
-
-/*
- * This is the only use we have in mono/metadata
-!g_spawn_async_with_pipes (NULL, (char**)addr_argv, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, &child_pid, &ch_in, &ch_out, NULL, NULL)
-*/
-gboolean
-g_spawn_async_with_pipes (const gchar *working_directory,
- gchar **argv,
- gchar **envp,
- GSpawnFlags flags,
- GSpawnChildSetupFunc child_setup,
- gpointer user_data,
- GPid *child_pid,
- gint *standard_input,
- gint *standard_output,
- gint *standard_error,
- GError **error)
-{
-#ifdef G_OS_WIN32
-#elif !defined (HAVE_FORK) || !defined (HAVE_EXECVE)
- fprintf (stderr, "g_spawn_async_with_pipes is not supported on this platform\n");
- return FALSE;
-#else
- pid_t pid;
- int info_pipe [2];
- int in_pipe [2] = { -1, -1 };
- int out_pipe [2] = { -1, -1 };
- int err_pipe [2] = { -1, -1 };
- int status;
-
- g_return_val_if_fail (argv != NULL, FALSE); /* Only mandatory arg */
-
- if (!create_pipe (info_pipe, error))
- return FALSE;
-
- if (standard_output && !create_pipe (out_pipe, error)) {
- CLOSE_PIPE (info_pipe);
- return FALSE;
- }
-
- if (standard_error && !create_pipe (err_pipe, error)) {
- CLOSE_PIPE (info_pipe);
- CLOSE_PIPE (out_pipe);
- return FALSE;
- }
-
- if (standard_input && !create_pipe (in_pipe, error)) {
- CLOSE_PIPE (info_pipe);
- CLOSE_PIPE (out_pipe);
- CLOSE_PIPE (err_pipe);
- return FALSE;
- }
-
- pid = fork ();
- if (pid == -1) {
- CLOSE_PIPE (info_pipe);
- CLOSE_PIPE (out_pipe);
- CLOSE_PIPE (err_pipe);
- CLOSE_PIPE (in_pipe);
- set_error ("%s", "Error in fork ()");
- return FALSE;
- }
-
- if (pid == 0) {
- /* No zombie left behind */
- if ((flags & G_SPAWN_DO_NOT_REAP_CHILD) == 0) {
- pid = fork ();
- }
-
- if (pid != 0) {
- exit (pid == -1 ? 1 : 0);
- } else {
- gint i;
- int fd;
- gchar *arg0;
- gchar **actual_args;
- gint unused;
-
- close (info_pipe [0]);
- close (in_pipe [1]);
- close (out_pipe [0]);
- close (err_pipe [0]);
-
- /* when exec* succeeds, we want to close this fd, which will return
- * a 0 read on the parent. We're not supposed to keep it open forever.
- * If exec fails, we still can write the error to it before closing.
- */
- fcntl (info_pipe [1], F_SETFD, FD_CLOEXEC);
-
- if ((flags & G_SPAWN_DO_NOT_REAP_CHILD) == 0) {
- pid = getpid ();
- NO_INTR (unused, write_all (info_pipe [1], &pid, sizeof (pid_t)));
- }
-
- if (working_directory && chdir (working_directory) == -1) {
- int err = errno;
- NO_INTR (unused, write_all (info_pipe [1], &err, sizeof (int)));
- exit (0);
- }
-
- if (standard_output) {
- dup2 (out_pipe [1], STDOUT_FILENO);
- } else if ((flags & G_SPAWN_STDOUT_TO_DEV_NULL) != 0) {
- fd = open ("/dev/null", O_WRONLY);
- dup2 (fd, STDOUT_FILENO);
- }
-
- if (standard_error) {
- dup2 (err_pipe [1], STDERR_FILENO);
- } else if ((flags & G_SPAWN_STDERR_TO_DEV_NULL) != 0) {
- fd = open ("/dev/null", O_WRONLY);
- dup2 (fd, STDERR_FILENO);
- }
-
- if (standard_input) {
- dup2 (in_pipe [0], STDIN_FILENO);
- } else if ((flags & G_SPAWN_CHILD_INHERITS_STDIN) == 0) {
- fd = open ("/dev/null", O_RDONLY);
- dup2 (fd, STDIN_FILENO);
- }
-
- if ((flags & G_SPAWN_LEAVE_DESCRIPTORS_OPEN) != 0) {
- for (i = eg_getdtablesize () - 1; i >= 3; i--)
- close (i);
- }
-
- actual_args = ((flags & G_SPAWN_FILE_AND_ARGV_ZERO) == 0) ? argv : argv + 1;
- if (envp == NULL)
- envp = environ;
-
- if (child_setup)
- child_setup (user_data);
-
- arg0 = argv [0];
- if (!g_path_is_absolute (arg0) || (flags & G_SPAWN_SEARCH_PATH) != 0) {
- arg0 = g_find_program_in_path (argv [0]);
- if (arg0 == NULL) {
- int err = ENOENT;
- write_all (info_pipe [1], &err, sizeof (int));
- exit (0);
- }
- }
-
- execve (arg0, actual_args, envp);
- write_all (info_pipe [1], &errno, sizeof (int));
- exit (0);
- }
- } else if ((flags & G_SPAWN_DO_NOT_REAP_CHILD) == 0) {
- int w;
- /* Wait for the first child if two are created */
- NO_INTR (w, waitpid (pid, &status, 0));
- if (status == 1 || w == -1) {
- CLOSE_PIPE (info_pipe);
- CLOSE_PIPE (out_pipe);
- CLOSE_PIPE (err_pipe);
- CLOSE_PIPE (in_pipe);
- set_error ("Error in fork (): %d", status);
- return FALSE;
- }
- }
- close (info_pipe [1]);
- close (in_pipe [0]);
- close (out_pipe [1]);
- close (err_pipe [1]);
-
- if ((flags & G_SPAWN_DO_NOT_REAP_CHILD) == 0) {
- int x;
- NO_INTR (x, read (info_pipe [0], &pid, sizeof (pid_t))); /* if we read < sizeof (pid_t)... */
- }
-
- if (child_pid) {
- *child_pid = pid;
- }
-
- if (read (info_pipe [0], &status, sizeof (int)) != 0) {
- close (info_pipe [0]);
- close (in_pipe [0]);
- close (out_pipe [1]);
- close (err_pipe [1]);
- set_error_status (status, "Error in exec (%d -> %s)", status, strerror (status));
- return FALSE;
- }
-
- close (info_pipe [0]);
- if (standard_input)
- *standard_input = in_pipe [1];
- if (standard_output)
- *standard_output = out_pipe [0];
- if (standard_error)
- *standard_error = err_pipe [0];
-#endif
- return TRUE;
-}
-
-
+++ /dev/null
-/*
- * gstr.c: String Utility Functions.
- *
- * Author:
- * Miguel de Icaza (miguel@novell.com)
- * Aaron Bockover (abockover@novell.com)
- *
- * (C) 2006 Novell, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-#include <config.h>
-#include <stdio.h>
-#include <string.h>
-#include <ctype.h>
-#include <glib.h>
-
-#ifndef G_OS_WIN32
-#include <pthread.h>
-#endif
-
-#include <errno.h>
-
-/*
- * g_strndup and g_vasprintf need to allocate memory with g_malloc if
- * ENABLE_OVERRIDABLE_ALLOCATORS is defined so that it can be safely freed with g_free
- * rather than free.
- */
-
-/* This is not a macro, because I dont want to put _GNU_SOURCE in the glib.h header */
-gchar *
-g_strndup (const gchar *str, gsize n)
-{
-#if defined (HAVE_STRNDUP) && !defined (ENABLE_OVERRIDABLE_ALLOCATORS)
- return strndup (str, n);
-#else
- if (str) {
- char *retval = g_malloc(n+1);
- if (retval) {
- strncpy(retval, str, n)[n] = 0;
- }
- return retval;
- }
- return NULL;
-#endif
-}
-
-gint g_vasprintf (gchar **ret, const gchar *fmt, va_list ap)
-{
-#if defined (HAVE_VASPRINTF) && !defined (ENABLE_OVERRIDABLE_ALLOCATORS)
- return vasprintf (ret, fmt, ap);
-#else
- char *buf;
- int len;
- size_t buflen;
- va_list ap2;
-
-#if defined(_MSC_VER) || defined(__MINGW64_VERSION_MAJOR)
- ap2 = ap;
- len = _vscprintf(fmt, ap2); // NOTE MS specific extension ( :-( )
-#else
- va_copy(ap2, ap);
- len = vsnprintf(NULL, 0, fmt, ap2);
-#endif
-
- if (len >= 0 && (buf = g_malloc ((buflen = (size_t) (len + 1)))) != NULL) {
- len = vsnprintf(buf, buflen, fmt, ap);
- *ret = buf;
- } else {
- *ret = NULL;
- len = -1;
- }
-
- va_end(ap2);
- return len;
-#endif
-}
-
-void
-g_strfreev (gchar **str_array)
-{
- gchar **orig = str_array;
- if (str_array == NULL)
- return;
- while (*str_array != NULL){
- g_free (*str_array);
- str_array++;
- }
- g_free (orig);
-}
-
-gchar **
-g_strdupv (gchar **str_array)
-{
- guint length;
- gchar **ret;
- guint i;
-
- if (!str_array)
- return NULL;
-
- length = g_strv_length(str_array);
- ret = g_new0(gchar *, length + 1);
- for (i = 0; str_array[i]; i++) {
- ret[i] = g_strdup(str_array[i]);
- }
- ret[length] = NULL;
- return ret;
-}
-
-guint
-g_strv_length(gchar **str_array)
-{
- gint length = 0;
- g_return_val_if_fail(str_array != NULL, 0);
- for(length = 0; str_array[length] != NULL; length++);
- return length;
-}
-
-gboolean
-g_str_has_suffix(const gchar *str, const gchar *suffix)
-{
- size_t str_length;
- size_t suffix_length;
-
- g_return_val_if_fail(str != NULL, FALSE);
- g_return_val_if_fail(suffix != NULL, FALSE);
-
- str_length = strlen(str);
- suffix_length = strlen(suffix);
-
- return suffix_length <= str_length ?
- strncmp(str + str_length - suffix_length, suffix, suffix_length) == 0 :
- FALSE;
-}
-
-gboolean
-g_str_has_prefix(const gchar *str, const gchar *prefix)
-{
- size_t str_length;
- size_t prefix_length;
-
- g_return_val_if_fail(str != NULL, FALSE);
- g_return_val_if_fail(prefix != NULL, FALSE);
-
- str_length = strlen(str);
- prefix_length = strlen(prefix);
-
- return prefix_length <= str_length ?
- strncmp(str, prefix, prefix_length) == 0 :
- FALSE;
-}
-
-gchar *
-g_strdup_vprintf (const gchar *format, va_list args)
-{
- int n;
- char *ret;
-
- n = g_vasprintf (&ret, format, args);
- if (n == -1)
- return NULL;
-
- return ret;
-}
-
-gchar *
-g_strdup_printf (const gchar *format, ...)
-{
- gchar *ret;
- va_list args;
- int n;
-
- va_start (args, format);
- n = g_vasprintf (&ret, format, args);
- va_end (args);
- if (n == -1)
- return NULL;
-
- return ret;
-}
-
-
-/*
-Max error number we support. It's empirically found by looking at our target OS.
-
-Last this was checked was June-2017.
-
-Apple is at 106.
-Android is at 133.
-*/
-#define MONO_ERRNO_MAX 200
-#define str(s) #s
-
-#ifndef G_OS_WIN32
-static pthread_mutex_t strerror_lock = PTHREAD_MUTEX_INITIALIZER;
-#endif
-
-static char *error_messages [MONO_ERRNO_MAX];
-
-const gchar *
-g_strerror (gint errnum)
-{
- if (errnum < 0)
- errnum = -errnum;
- if (errnum >= MONO_ERRNO_MAX)
- return ("Error number higher than " str (MONO_ERRNO_MAX));
-
- if (!error_messages [errnum]) {
-#ifndef G_OS_WIN32
- pthread_mutex_lock (&strerror_lock);
-#endif
-
-#ifdef HAVE_STRERROR_R
- char tmp_buff [128]; //Quite arbitrary, should be large enough
- char *buff = tmp_buff;
- int buff_len = sizeof (tmp_buff);
- int r;
- buff [0] = 0;
-
- while ((r = strerror_r (errnum, buff, buff_len - 1))) {
- if (r != ERANGE) {
- buff = g_strdup_printf ("Invalid Error code '%d'", errnum);
- break;
- }
- if (buff == tmp_buff)
- buff = g_malloc (buff_len * 2);
- else
- buff = g_realloc (buff, buff_len * 2);
- buff_len *= 2;
- //Spec is not clean on whether size argument includes space for null terminator or not
- }
- if (!error_messages [errnum])
- error_messages [errnum] = g_strdup (buff);
- if (buff != tmp_buff)
- g_free (buff);
-#else
- if (!error_messages [errnum])
- error_messages [errnum] = g_strdup_printf ("Error code '%d'", errnum);
-#endif
-
-
-#ifndef G_OS_WIN32
- pthread_mutex_unlock (&strerror_lock);
-#endif
-
- }
- return error_messages [errnum];
-}
-
-gchar *
-g_strconcat (const gchar *first, ...)
-{
- va_list args;
- size_t total = 0;
- char *s, *ret;
- g_return_val_if_fail (first != NULL, NULL);
-
- total += strlen (first);
- va_start (args, first);
- for (s = va_arg (args, char *); s != NULL; s = va_arg(args, char *)){
- total += strlen (s);
- }
- va_end (args);
-
- ret = g_malloc (total + 1);
- if (ret == NULL)
- return NULL;
-
- ret [total] = 0;
- strcpy (ret, first);
- va_start (args, first);
- for (s = va_arg (args, char *); s != NULL; s = va_arg(args, char *)){
- strcat (ret, s);
- }
- va_end (args);
-
- return ret;
-}
-
-static void
-add_to_vector (gchar ***vector, int size, gchar *token)
-{
- *vector = *vector == NULL ?
- (gchar **)g_malloc(2 * sizeof(*vector)) :
- (gchar **)g_realloc(*vector, (size + 1) * sizeof(*vector));
-
- (*vector)[size - 1] = token;
-}
-
-gchar **
-g_strsplit (const gchar *string, const gchar *delimiter, gint max_tokens)
-{
- const gchar *c;
- gchar *token, **vector;
- gint size = 1;
-
- g_return_val_if_fail (string != NULL, NULL);
- g_return_val_if_fail (delimiter != NULL, NULL);
- g_return_val_if_fail (delimiter[0] != 0, NULL);
-
- if (strncmp (string, delimiter, strlen (delimiter)) == 0) {
- vector = (gchar **)g_malloc (2 * sizeof(vector));
- vector[0] = g_strdup ("");
- size++;
- string += strlen (delimiter);
- } else {
- vector = NULL;
- }
-
- while (*string && !(max_tokens > 0 && size >= max_tokens)) {
- c = string;
- if (strncmp (string, delimiter, strlen (delimiter)) == 0) {
- token = g_strdup ("");
- string += strlen (delimiter);
- } else {
- while (*string && strncmp (string, delimiter, strlen (delimiter)) != 0) {
- string++;
- }
-
- if (*string) {
- gsize toklen = (string - c);
- token = g_strndup (c, toklen);
-
- /* Need to leave a trailing empty
- * token if the delimiter is the last
- * part of the string
- */
- if (strcmp (string, delimiter) != 0) {
- string += strlen (delimiter);
- }
- } else {
- token = g_strdup (c);
- }
- }
-
- add_to_vector (&vector, size, token);
- size++;
- }
-
- if (*string) {
- if (strcmp (string, delimiter) == 0)
- add_to_vector (&vector, size, g_strdup (""));
- else {
- /* Add the rest of the string as the last element */
- add_to_vector (&vector, size, g_strdup (string));
- }
- size++;
- }
-
- if (vector == NULL) {
- vector = (gchar **) g_malloc (2 * sizeof (vector));
- vector [0] = NULL;
- } else if (size > 0) {
- vector[size - 1] = NULL;
- }
-
- return vector;
-}
-
-static gboolean
-charcmp (gchar testchar, const gchar *compare)
-{
- while(*compare) {
- if (*compare == testchar) {
- return TRUE;
- }
- compare++;
- }
-
- return FALSE;
-}
-
-gchar **
-g_strsplit_set (const gchar *string, const gchar *delimiter, gint max_tokens)
-{
- const gchar *c;
- gchar *token, **vector;
- gint size = 1;
-
- g_return_val_if_fail (string != NULL, NULL);
- g_return_val_if_fail (delimiter != NULL, NULL);
- g_return_val_if_fail (delimiter[0] != 0, NULL);
-
- if (charcmp (*string, delimiter)) {
- vector = (gchar **)g_malloc (2 * sizeof(vector));
- vector[0] = g_strdup ("");
- size++;
- string++;
- } else {
- vector = NULL;
- }
-
- c = string;
- while (*string && !(max_tokens > 0 && size >= max_tokens)) {
- if (charcmp (*string, delimiter)) {
- gsize toklen = (string - c);
- if (toklen == 0) {
- token = g_strdup ("");
- } else {
- token = g_strndup (c, toklen);
- }
-
- c = string + 1;
-
- add_to_vector (&vector, size, token);
- size++;
- }
-
- string++;
- }
-
- if (max_tokens > 0 && size >= max_tokens) {
- if (*string) {
- /* Add the rest of the string as the last element */
- add_to_vector (&vector, size, g_strdup (string));
- size++;
- }
- } else {
- if (*c) {
- /* Fill in the trailing last token */
- add_to_vector (&vector, size, g_strdup (c));
- size++;
- } else {
- /* Need to leave a trailing empty token if the
- * delimiter is the last part of the string
- */
- add_to_vector (&vector, size, g_strdup (""));
- size++;
- }
- }
-
- if (vector == NULL) {
- vector = (gchar **) g_malloc (2 * sizeof (vector));
- vector [0] = NULL;
- } else if (size > 0) {
- vector[size - 1] = NULL;
- }
-
- return vector;
-}
-
-gchar *
-g_strreverse (gchar *str)
-{
- size_t i, j;
- gchar c;
-
- if (str == NULL)
- return NULL;
-
- if (*str == 0)
- return str;
-
- for (i = 0, j = strlen (str) - 1; i < j; i++, j--) {
- c = str [i];
- str [i] = str [j];
- str [j] = c;
- }
-
- return str;
-}
-
-gchar *
-g_strjoin (const gchar *separator, ...)
-{
- va_list args;
- char *res, *s, *r;
- size_t len, slen;
-
- if (separator != NULL)
- slen = strlen (separator);
- else
- slen = 0;
-
- len = 0;
- va_start (args, separator);
- for (s = va_arg (args, char *); s != NULL; s = va_arg (args, char *)){
- len += strlen (s);
- len += slen;
- }
- va_end (args);
-
- if (len == 0)
- return g_strdup ("");
-
- /* Remove the last separator */
- if (slen > 0 && len > 0)
- len -= slen;
-
- res = g_malloc (len + 1);
- va_start (args, separator);
- s = va_arg (args, char *);
- r = g_stpcpy (res, s);
- for (s = va_arg (args, char *); s != NULL; s = va_arg (args, char *)){
- if (separator != NULL)
- r = g_stpcpy (r, separator);
- r = g_stpcpy (r, s);
- }
- va_end (args);
-
- return res;
-}
-
-gchar *
-g_strjoinv (const gchar *separator, gchar **str_array)
-{
- char *res, *r;
- size_t slen, len, i;
-
- if (separator != NULL)
- slen = strlen (separator);
- else
- slen = 0;
-
- len = 0;
- for (i = 0; str_array [i] != NULL; i++){
- len += strlen (str_array [i]);
- len += slen;
- }
-
- if (len == 0)
- return g_strdup ("");
-
- if (slen > 0 && len > 0)
- len -= slen;
-
- res = g_malloc (len + 1);
- r = g_stpcpy (res, str_array [0]);
- for (i = 1; str_array [i] != NULL; i++){
- if (separator != NULL)
- r = g_stpcpy (r, separator);
- r = g_stpcpy (r, str_array [i]);
- }
-
- return res;
-}
-
-gchar *
-g_strchug (gchar *str)
-{
- size_t len;
- gchar *tmp;
-
- if (str == NULL)
- return NULL;
-
- tmp = str;
- while (*tmp && isspace (*tmp)) tmp++;
- if (str != tmp) {
- len = strlen (str) - (tmp - str - 1);
- memmove (str, tmp, len);
- }
- return str;
-}
-
-gchar *
-g_strchomp (gchar *str)
-{
- gchar *tmp;
-
- if (str == NULL)
- return NULL;
-
- tmp = str + strlen (str) - 1;
- while (*tmp && isspace (*tmp)) tmp--;
- *(tmp + 1) = '\0';
- return str;
-}
-
-gint
-g_printf(gchar const *format, ...)
-{
- va_list args;
- gint ret;
-
- va_start(args, format);
- ret = vprintf(format, args);
- va_end(args);
-
- return ret;
-}
-
-gint
-g_fprintf(FILE *file, gchar const *format, ...)
-{
- va_list args;
- gint ret;
-
- va_start(args, format);
- ret = vfprintf(file, format, args);
- va_end(args);
-
- return ret;
-}
-
-gint
-g_sprintf(gchar *string, gchar const *format, ...)
-{
- va_list args;
- gint ret;
-
- va_start(args, format);
- ret = vsprintf(string, format, args);
- va_end(args);
-
- return ret;
-}
-
-gint
-g_snprintf(gchar *string, gulong n, gchar const *format, ...)
-{
- va_list args;
- gint ret;
-
- va_start(args, format);
- ret = vsnprintf(string, n, format, args);
- va_end(args);
-
- return ret;
-}
-
-static const char hx [] = { '0', '1', '2', '3', '4', '5', '6', '7',
- '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
-
-static gboolean
-char_needs_encoding (char c)
-{
- if (((unsigned char)c) >= 0x80)
- return TRUE;
-
- if ((c >= '@' && c <= 'Z') ||
- (c >= 'a' && c <= 'z') ||
- (c >= '&' && c < 0x3b) ||
- (c == '!') || (c == '$') || (c == '_') || (c == '=') || (c == '~'))
- return FALSE;
- return TRUE;
-}
-
-gchar *
-g_filename_to_uri (const gchar *filename, const gchar *hostname, GError **error)
-{
- size_t n;
- char *ret, *rp;
- const char *p;
-#ifdef G_OS_WIN32
- const char *uriPrefix = "file:///";
-#else
- const char *uriPrefix = "file://";
-#endif
-
- g_return_val_if_fail (filename != NULL, NULL);
-
- if (hostname != NULL)
- g_warning ("%s", "eglib: g_filename_to_uri: hostname not handled");
-
- if (!g_path_is_absolute (filename)){
- if (error != NULL)
- *error = g_error_new (NULL, 2, "Not an absolute filename");
-
- return NULL;
- }
-
- n = strlen (uriPrefix) + 1;
- for (p = filename; *p; p++){
-#ifdef G_OS_WIN32
- if (*p == '\\') {
- n++;
- continue;
- }
-#endif
- if (char_needs_encoding (*p))
- n += 3;
- else
- n++;
- }
- ret = g_malloc (n);
- strcpy (ret, uriPrefix);
- for (p = filename, rp = ret + strlen (ret); *p; p++){
-#ifdef G_OS_WIN32
- if (*p == '\\') {
- *rp++ = '/';
- continue;
- }
-#endif
- if (char_needs_encoding (*p)){
- *rp++ = '%';
- *rp++ = hx [((unsigned char)(*p)) >> 4];
- *rp++ = hx [((unsigned char)(*p)) & 0xf];
- } else
- *rp++ = *p;
- }
- *rp = 0;
- return ret;
-}
-
-static int
-decode (char p)
-{
- if (p >= '0' && p <= '9')
- return p - '0';
- if (p >= 'A' && p <= 'F')
- return p - 'A';
- if (p >= 'a' && p <= 'f')
- return p - 'a';
- g_assert_not_reached ();
- return 0;
-}
-
-gchar *
-g_filename_from_uri (const gchar *uri, gchar **hostname, GError **error)
-{
- const char *p;
- char *r, *result;
- int flen = 0;
-
- g_return_val_if_fail (uri != NULL, NULL);
-
- if (hostname != NULL)
- g_warning ("%s", "eglib: g_filename_from_uri: hostname not handled");
-
- if (strncmp (uri, "file:///", 8) != 0){
- if (error != NULL)
- *error = g_error_new (NULL, 2, "URI does not start with the file: scheme");
- return NULL;
- }
-
- for (p = uri + 8; *p; p++){
- if (*p == '%'){
- if (p [1] && p [2] && isxdigit (p [1]) && isxdigit (p [2])){
- p += 2;
- } else {
- if (error != NULL)
- *error = g_error_new (NULL, 2, "URI contains an invalid escape sequence");
- return NULL;
- }
- }
- flen++;
- }
-#ifndef G_OS_WIN32
- flen++;
-#endif
-
- result = g_malloc (flen + 1);
- result [flen] = 0;
-
-#ifndef G_OS_WIN32
- *result = '/';
- r = result + 1;
-#else
- r = result;
-#endif
-
- for (p = uri + 8; *p; p++){
- if (*p == '%'){
- *r++ = (char)((decode (p [1]) << 4) | decode (p [2]));
- p += 2;
- } else
- *r++ = *p;
- flen++;
- }
- return result;
-}
-
-void
-g_strdown (gchar *string)
-{
- g_return_if_fail (string != NULL);
-
- while (*string){
- *string = (gchar)tolower (*string);
- string++;
- }
-}
-
-gchar
-g_ascii_tolower (gchar c)
-{
- return c >= 'A' && c <= 'Z' ? c + ('a' - 'A') : c;
-}
-
-gchar *
-g_ascii_strdown (const gchar *str, gssize len)
-{
- char *ret;
- int i;
-
- g_return_val_if_fail (str != NULL, NULL);
-
- if (len == -1)
- len = strlen (str);
-
- ret = g_malloc (len + 1);
- for (i = 0; i < len; i++)
- ret [i] = (guchar) g_ascii_tolower (str [i]);
- ret [i] = 0;
-
- return ret;
-}
-
-gchar
-g_ascii_toupper (gchar c)
-{
- return c >= 'a' && c <= 'z' ? c + ('A' - 'a') : c;
-}
-
-gchar *
-g_ascii_strup (const gchar *str, gssize len)
-{
- char *ret;
- int i;
-
- g_return_val_if_fail (str != NULL, NULL);
-
- if (len == -1)
- len = strlen (str);
-
- ret = g_malloc (len + 1);
- for (i = 0; i < len; i++)
- ret [i] = (guchar) g_ascii_toupper (str [i]);
- ret [i] = 0;
-
- return ret;
-}
-
-gint
-g_ascii_strncasecmp (const gchar *s1, const gchar *s2, gsize n)
-{
- gsize i;
-
- g_return_val_if_fail (s1 != NULL, 0);
- g_return_val_if_fail (s2 != NULL, 0);
-
- for (i = 0; i < n; i++) {
- gchar c1 = g_ascii_tolower (*s1++);
- gchar c2 = g_ascii_tolower (*s2++);
-
- if (c1 != c2)
- return c1 - c2;
- }
-
- return 0;
-}
-
-gint
-g_ascii_strcasecmp (const gchar *s1, const gchar *s2)
-{
- const char *sp1 = s1;
- const char *sp2 = s2;
-
- g_return_val_if_fail (s1 != NULL, 0);
- g_return_val_if_fail (s2 != NULL, 0);
-
- while (*sp1 != '\0') {
- char c1 = g_ascii_tolower (*sp1++);
- char c2 = g_ascii_tolower (*sp2++);
-
- if (c1 != c2)
- return c1 - c2;
- }
-
- return (*sp1) - (*sp2);
-}
-
-gchar *
-g_strdelimit (gchar *string, const gchar *delimiters, gchar new_delimiter)
-{
- gchar *ptr;
-
- g_return_val_if_fail (string != NULL, NULL);
-
- if (delimiters == NULL)
- delimiters = G_STR_DELIMITERS;
-
- for (ptr = string; *ptr; ptr++) {
- if (strchr (delimiters, *ptr))
- *ptr = new_delimiter;
- }
-
- return string;
-}
-
-gsize
-g_strlcpy (gchar *dest, const gchar *src, gsize dest_size)
-{
-#ifdef HAVE_STRLCPY
- return strlcpy (dest, src, dest_size);
-#else
- gchar *d;
- const gchar *s;
- gchar c;
- gsize len;
-
- g_return_val_if_fail (src != NULL, 0);
- g_return_val_if_fail (dest != NULL, 0);
-
- len = dest_size;
- if (len == 0)
- return 0;
-
- s = src;
- d = dest;
- while (--len) {
- c = *s++;
- *d++ = c;
- if (c == '\0')
- return (dest_size - len - 1);
- }
-
- /* len is 0 i we get here */
- *d = '\0';
- /* we need to return the length of src here */
- while (*s++) ; /* instead of a plain strlen, we use 's' */
- return s - src - 1;
-#endif
-}
-
-gchar *
-g_stpcpy (gchar *dest, const char *src)
-{
- g_return_val_if_fail (dest != NULL, dest);
- g_return_val_if_fail (src != NULL, dest);
-
-#if HAVE_STPCPY
- return stpcpy (dest, src);
-#else
- while (*src)
- *dest++ = *src++;
-
- *dest = '\0';
-
- return dest;
-#endif
-}
-
-static const gchar escaped_dflt [256] = {
- 1, 1, 1, 1, 1, 1, 1, 1, 'b', 't', 'n', 1, 'f', 'r', 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 0, 0, '"', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '\\', 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
-};
-
-gchar *
-g_strescape (const gchar *source, const gchar *exceptions)
-{
- gchar escaped [256];
- const gchar *ptr;
- gchar c;
- gchar op;
- gchar *result;
- gchar *res_ptr;
-
- g_return_val_if_fail (source != NULL, NULL);
-
- memcpy (escaped, escaped_dflt, 256);
- if (exceptions != NULL) {
- for (ptr = exceptions; *ptr; ptr++)
- escaped [(int) *ptr] = 0;
- }
- result = g_malloc (strlen (source) * 4 + 1); /* Worst case: everything octal. */
- res_ptr = result;
- for (ptr = source; *ptr; ptr++) {
- c = *ptr;
- op = escaped [(int) c];
- if (op == 0) {
- *res_ptr++ = c;
- } else {
- *res_ptr++ = '\\';
- if (op != 1) {
- *res_ptr++ = op;
- } else {
- *res_ptr++ = '0' + ((c >> 6) & 3);
- *res_ptr++ = '0' + ((c >> 3) & 7);
- *res_ptr++ = '0' + (c & 7);
- }
- }
- }
- *res_ptr = '\0';
- return result;
-}
-
-gint
-g_ascii_xdigit_value (gchar c)
-{
- return ((isxdigit (c) == 0) ? -1 :
- ((c >= '0' && c <= '9') ? (c - '0') :
- ((c >= 'a' && c <= 'f') ? (c - 'a' + 10) :
- (c - 'A' + 10))));
-}
-
-gchar *
-g_strnfill (gsize length, gchar fill_char)
-{
- gchar *ret = g_new (gchar, length + 1);
-
- memset (ret, fill_char, length);
- ret [length] = 0;
- return ret;
-}
+++ /dev/null
-/*
- * String functions
- *
- * Author:
- * Miguel de Icaza (miguel@novell.com)
- * Aaron Bockover (abockover@novell.com)
- *
- * (C) 2006 Novell, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-#include <stdio.h>
-#include <glib.h>
-
-#define GROW_IF_NECESSARY(s,l) { \
- if(s->len + l >= s->allocated_len) { \
- s->allocated_len = (s->allocated_len + l + 16) * 2; \
- s->str = g_realloc(s->str, s->allocated_len); \
- } \
-}
-
-GString *
-g_string_new_len (const gchar *init, gssize len)
-{
- GString *ret = g_new (GString, 1);
-
- if (init == NULL)
- ret->len = 0;
- else
- ret->len = len < 0 ? strlen(init) : len;
- ret->allocated_len = MAX(ret->len + 1, 16);
- ret->str = g_malloc(ret->allocated_len);
- if (init)
- memcpy(ret->str, init, ret->len);
- ret->str[ret->len] = 0;
-
- return ret;
-}
-
-GString *
-g_string_new (const gchar *init)
-{
- return g_string_new_len(init, -1);
-}
-
-GString *
-g_string_sized_new (gsize default_size)
-{
- GString *ret = g_new (GString, 1);
-
- ret->str = g_malloc (default_size);
- ret->str [0] = 0;
- ret->len = 0;
- ret->allocated_len = default_size;
-
- return ret;
-}
-
-gchar *
-g_string_free (GString *string, gboolean free_segment)
-{
- gchar *data;
-
- g_return_val_if_fail (string != NULL, NULL);
-
- data = string->str;
- g_free(string);
-
- if(!free_segment) {
- return data;
- }
-
- g_free(data);
- return NULL;
-}
-
-GString *
-g_string_append_len (GString *string, const gchar *val, gssize len)
-{
- g_return_val_if_fail(string != NULL, NULL);
- g_return_val_if_fail(val != NULL, string);
-
- if(len < 0) {
- len = strlen(val);
- }
-
- GROW_IF_NECESSARY(string, len);
- memcpy(string->str + string->len, val, len);
- string->len += len;
- string->str[string->len] = 0;
-
- return string;
-}
-
-GString *
-g_string_append (GString *string, const gchar *val)
-{
- g_return_val_if_fail(string != NULL, NULL);
- g_return_val_if_fail(val != NULL, string);
-
- return g_string_append_len(string, val, -1);
-}
-
-GString *
-g_string_append_c (GString *string, gchar c)
-{
- g_return_val_if_fail(string != NULL, NULL);
-
- GROW_IF_NECESSARY(string, 1);
-
- string->str[string->len] = c;
- string->str[string->len + 1] = 0;
- string->len++;
-
- return string;
-}
-
-GString *
-g_string_append_unichar (GString *string, gunichar c)
-{
- gchar utf8[6];
- gint len;
-
- g_return_val_if_fail (string != NULL, NULL);
-
- if ((len = g_unichar_to_utf8 (c, utf8)) <= 0)
- return string;
-
- return g_string_append_len (string, utf8, len);
-}
-
-GString *
-g_string_prepend (GString *string, const gchar *val)
-{
- gssize len;
-
- g_return_val_if_fail (string != NULL, string);
- g_return_val_if_fail (val != NULL, string);
-
- len = strlen (val);
-
- GROW_IF_NECESSARY(string, len);
- memmove(string->str + len, string->str, string->len + 1);
- memcpy(string->str, val, len);
-
- return string;
-}
-
-GString *
-g_string_insert (GString *string, gssize pos, const gchar *val)
-{
- gssize len;
-
- g_return_val_if_fail (string != NULL, string);
- g_return_val_if_fail (val != NULL, string);
- g_return_val_if_fail (pos <= string->len, string);
-
- len = strlen (val);
-
- GROW_IF_NECESSARY(string, len);
- memmove(string->str + pos + len, string->str + pos, string->len - pos - len + 1);
- memcpy(string->str + pos, val, len);
-
- return string;
-}
-
-void
-g_string_append_printf (GString *string, const gchar *format, ...)
-{
- char *ret;
- va_list args;
-
- g_return_if_fail (string != NULL);
- g_return_if_fail (format != NULL);
-
- va_start (args, format);
- ret = g_strdup_vprintf (format, args);
- va_end (args);
- g_string_append (string, ret);
-
- g_free (ret);
-}
-
-void
-g_string_append_vprintf (GString *string, const gchar *format, va_list args)
-{
- char *ret;
-
- g_return_if_fail (string != NULL);
- g_return_if_fail (format != NULL);
-
- ret = g_strdup_vprintf (format, args);
- g_string_append (string, ret);
- g_free (ret);
-}
-
-void
-g_string_printf (GString *string, const gchar *format, ...)
-{
- va_list args;
-
- g_return_if_fail (string != NULL);
- g_return_if_fail (format != NULL);
-
- g_free (string->str);
-
- va_start (args, format);
- string->str = g_strdup_vprintf (format, args);
- va_end (args);
-
- string->len = strlen (string->str);
- string->allocated_len = string->len+1;
-}
-
-GString *
-g_string_truncate (GString *string, gsize len)
-{
- g_return_val_if_fail (string != NULL, string);
-
- /* Silent return */
- if (len >= string->len)
- return string;
-
- string->len = len;
- string->str[len] = 0;
- return string;
-}
-
-GString *
-g_string_set_size (GString *string, gsize len)
-{
- g_return_val_if_fail (string != NULL, string);
-
- GROW_IF_NECESSARY(string, len);
-
- string->len = len;
- string->str[len] = 0;
- return string;
-}
-
-GString *
-g_string_erase (GString *string, gssize pos, gssize len)
-{
- g_return_val_if_fail (string != NULL, string);
-
- /* Silent return */
- if (pos >= string->len)
- return string;
-
- if (len == -1 || (pos + len) >= string->len) {
- string->str[pos] = 0;
- }
- else {
- memmove (string->str + pos, string->str + pos + len, string->len - (pos + len) + 1);
- string->len -= len;
- }
-
- return string;
-}
+++ /dev/null
-/*
- * Timer
- *
- * Author:
- * Gonzalo Paniagua Javier (gonzalo@novell.com
- *
- * (C) 2006 Novell, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-#include <glib.h>
-#include <sys/time.h>
-
-struct _GTimer {
- struct timeval start;
- struct timeval stop;
-};
-
-GTimer *g_timer_new (void)
-{
- GTimer *timer;
-
- timer = g_new0 (GTimer, 1);
- g_timer_start (timer);
- return timer;
-}
-
-void
-g_timer_destroy (GTimer *timer)
-{
- g_return_if_fail (timer != NULL);
- g_free (timer);
-}
-
-void
-g_timer_start (GTimer *timer)
-{
- g_return_if_fail (timer != NULL);
- gettimeofday (&timer->start, NULL);
- memset (&timer->stop, 0, sizeof (struct timeval));
-}
-
-void
-g_timer_stop (GTimer *timer)
-{
- g_return_if_fail (timer != NULL);
- gettimeofday (&timer->stop, NULL);
-}
-
-gdouble
-g_timer_elapsed (GTimer *timer, gulong *microseconds)
-{
- struct timeval tv;
- gulong seconds;
- long usec;
- gdouble result;
-
- g_return_val_if_fail (timer != NULL, 0.0);
-
- if (timer->stop.tv_sec == 0 && timer->stop.tv_usec == 0) {
- gettimeofday (&tv, NULL);
- } else {
- tv = timer->stop;
- }
-
- usec = (tv.tv_usec) - (timer->start.tv_usec);
- seconds = tv.tv_sec - timer->start.tv_sec;
- if (microseconds) {
- if (usec < 0) {
- usec += 1000000;
- seconds--;
- }
- *microseconds = usec;
- }
- result = seconds * 1000000 + usec;
- return (result / 1000000);
-}
-
-
+++ /dev/null
-/*
- * Timer
- *
- * Author:
- * Gonzalo Paniagua Javier (gonzalo@novell.com
- *
- * (C) 2006 Novell, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-#include <glib.h>
-#include <windows.h>
-
-struct _GTimer {
- guint64 start;
- guint64 stop;
-};
-
-GTimer *g_timer_new (void)
-{
- GTimer *timer;
-
- timer = g_new0 (GTimer, 1);
- g_timer_start (timer);
- return timer;
-}
-
-void
-g_timer_destroy (GTimer *timer)
-{
- g_return_if_fail (timer != NULL);
- g_free (timer);
-}
-
-void
-g_timer_start (GTimer *timer)
-{
- g_return_if_fail (timer != NULL);
-
- QueryPerformanceCounter ((LARGE_INTEGER*)&timer->start);
-}
-
-void
-g_timer_stop (GTimer *timer)
-{
- g_return_if_fail (timer != NULL);
-
- QueryPerformanceCounter ((LARGE_INTEGER*)&timer->stop);
-}
-
-gdouble
-g_timer_elapsed (GTimer *timer, gulong *microseconds)
-{
- static guint64 freq = 0;
- guint64 delta, stop;
-
- if (freq == 0) {
- if (!QueryPerformanceFrequency ((LARGE_INTEGER *)&freq))
- freq = 1;
- }
-
- if (timer->stop == 0) {
- QueryPerformanceCounter ((LARGE_INTEGER*)&stop);
- }
- else {
- stop = timer->stop;
- }
-
- delta = stop - timer->start;
-
- if (microseconds)
- *microseconds = (gulong) (delta * (1000000.0 / freq));
-
- return (gdouble) delta / (gdouble) freq;
-}
-
-
+++ /dev/null
-/*
- * gunicode-win32-uwp.c: UWP unicode support.
- *
- * Copyright 2016 Microsoft
- * Licensed under the MIT license. See LICENSE file in the project root for full license information.
-*/
-#include <config.h>
-#include <glib.h>
-
-#if G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT)
-#define CODESET 1
-#include <windows.h>
-
-extern const char *my_charset;
-static gboolean is_utf8;
-
-gboolean
-g_get_charset (G_CONST_RETURN char **charset)
-{
- if (my_charset == NULL) {
- static char buf [14];
- CPINFOEXA cp_info;
-
- GetCPInfoExA (CP_ACP, 0, &cp_info);
- sprintf (buf, "CP%u", cp_info.CodePage);
- my_charset = buf;
- is_utf8 = FALSE;
- }
-
- if (charset != NULL)
- *charset = my_charset;
-
- return is_utf8;
-}
-
-#else /* G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT) */
-
-#ifdef _MSC_VER
-// Quiet Visual Studio linker warning, LNK4221, in cases when this source file intentional ends up empty.
-void __mono_win32_gunicode_win32_uwp_quiet_lnk4221(void) {}
-#endif
-#endif /* G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT) */
+++ /dev/null
-/*
- * gunicode-win32.c: Windows unicode support.
- *
- * Copyright 2016 Microsoft
- * Licensed under the MIT license. See LICENSE file in the project root for full license information.
-*/
-#include <config.h>
-#include <glib.h>
-
-#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
-#define CODESET 1
-#include <windows.h>
-
-extern const char *my_charset;
-static gboolean is_utf8;
-
-gboolean
-g_get_charset (G_CONST_RETURN char **charset)
-{
- if (my_charset == NULL) {
- static char buf [14];
- sprintf (buf, "CP%u", GetACP ());
- my_charset = buf;
- is_utf8 = FALSE;
- }
-
- if (charset != NULL)
- *charset = my_charset;
-
- return is_utf8;
-}
-
-#else /* G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) */
-
-#ifdef _MSC_VER
-// Quiet Visual Studio linker warning, LNK4221, in cases when this source file intentional ends up empty.
-void __mono_win32_mono_gunicode_win32_quiet_lnk4221(void) {}
-#endif
-#endif /* G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) */
+++ /dev/null
-/*
- * gunicode.c: Some Unicode routines
- *
- * Author:
- * Miguel de Icaza (miguel@novell.com)
- *
- * (C) 2006 Novell, Inc.
- *
- * utf8 validation code came from:
- * libxml2-2.6.26 licensed under the MIT X11 license
- *
- * Authors credit in libxml's string.c:
- * William Brack <wbrack@mmm.com.hk>
- * daniel@veillard.com
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- */
-#include <config.h>
-#include <stdio.h>
-#include <glib.h>
-#include <unicode-data.h>
-#include <errno.h>
-
-#ifndef G_OS_WIN32
-# ifdef HAVE_LOCALCHARSET_H
-# include <localcharset.h>
-# endif
-#endif
-
-const char *my_charset;
-
-/*
- * Character set conversion
- */
-
-GUnicodeType
-g_unichar_type (gunichar c)
-{
- int i;
-
- guint16 cp = (guint16) c;
- for (i = 0; i < unicode_category_ranges_count; i++) {
- if (cp < unicode_category_ranges [i].start)
- continue;
- if (unicode_category_ranges [i].end <= cp)
- continue;
- return unicode_category [i] [cp - unicode_category_ranges [i].start];
- }
-
- /*
- // 3400-4DB5: OtherLetter
- // 4E00-9FC3: OtherLetter
- // AC00-D7A3: OtherLetter
- // D800-DFFF: OtherSurrogate
- // E000-F8FF: OtherPrivateUse
- // 20000-2A6D6 OtherLetter
- // F0000-FFFFD OtherPrivateUse
- // 100000-10FFFD OtherPrivateUse
- */
- if (0x3400 <= cp && cp < 0x4DB5)
- return G_UNICODE_OTHER_LETTER;
- if (0x4E00 <= cp && cp < 0x9FC3)
- return G_UNICODE_OTHER_LETTER;
- if (0xAC00<= cp && cp < 0xD7A3)
- return G_UNICODE_OTHER_LETTER;
- if (0xD800 <= cp && cp < 0xDFFF)
- return G_UNICODE_SURROGATE;
- if (0xE000 <= cp && cp < 0xF8FF)
- return G_UNICODE_PRIVATE_USE;
- /* since the argument is UTF-16, we cannot check beyond FFFF */
-
- /* It should match any of above */
- return 0;
-}
-
-GUnicodeBreakType
-g_unichar_break_type (gunichar c)
-{
- // MOONLIGHT_FIXME
- return G_UNICODE_BREAK_UNKNOWN;
-}
-
-gunichar
-g_unichar_case (gunichar c, gboolean upper)
-{
- gint8 i, i2;
- guint32 cp = (guint32) c, v;
-
- for (i = 0; i < simple_case_map_ranges_count; i++) {
- if (cp < simple_case_map_ranges [i].start)
- return c;
- if (simple_case_map_ranges [i].end <= cp)
- continue;
- if (c < 0x10000) {
- const guint16 *tab = upper ? simple_upper_case_mapping_lowarea [i] : simple_lower_case_mapping_lowarea [i];
- v = tab [cp - simple_case_map_ranges [i].start];
- } else {
- const guint32 *tab;
- i2 = (gint8)(i - (upper ? simple_upper_case_mapping_lowarea_table_count : simple_lower_case_mapping_lowarea_table_count));
- tab = upper ? simple_upper_case_mapping_higharea [i2] : simple_lower_case_mapping_higharea [i2];
- v = tab [cp - simple_case_map_ranges [i].start];
- }
- return v != 0 ? (gunichar) v : c;
- }
- return c;
-}
-
-gunichar
-g_unichar_toupper (gunichar c)
-{
- return g_unichar_case (c, TRUE);
-}
-
-gunichar
-g_unichar_tolower (gunichar c)
-{
- return g_unichar_case (c, FALSE);
-}
-
-gunichar
-g_unichar_totitle (gunichar c)
-{
- guint8 i;
- guint32 cp;
-
- cp = (guint32) c;
- for (i = 0; i < simple_titlecase_mapping_count; i++) {
- if (simple_titlecase_mapping [i].codepoint == cp)
- return simple_titlecase_mapping [i].title;
- if (simple_titlecase_mapping [i].codepoint > cp)
- /* it is ordered, hence no more match */
- break;
- }
- return g_unichar_toupper (c);
-}
-
-gboolean
-g_unichar_isxdigit (gunichar c)
-{
- return (g_unichar_xdigit_value (c) != -1);
-
-}
-
-gint
-g_unichar_xdigit_value (gunichar c)
-{
- if (c >= 0x30 && c <= 0x39) /*0-9*/
- return (c - 0x30);
- if (c >= 0x41 && c <= 0x46) /*A-F*/
- return (c - 0x37);
- if (c >= 0x61 && c <= 0x66) /*a-f*/
- return (c - 0x57);
- return -1;
-}
-
-gboolean
-g_unichar_isspace (gunichar c)
-{
- GUnicodeType type = g_unichar_type (c);
- if (type == G_UNICODE_LINE_SEPARATOR ||
- type == G_UNICODE_PARAGRAPH_SEPARATOR ||
- type == G_UNICODE_SPACE_SEPARATOR)
- return TRUE;
-
- return FALSE;
-}
-
-
-/*
- * This is broken, and assumes an UTF8 system, but will do for eglib's first user
- */
-gchar *
-g_filename_from_utf8 (const gchar *utf8string, gssize len, gsize *bytes_read, gsize *bytes_written, GError **error)
-{
- char *res;
-
- if (len == -1)
- len = strlen (utf8string);
-
- res = g_malloc (len + 1);
- g_strlcpy (res, utf8string, len + 1);
- return res;
-}
-
-#ifndef G_OS_WIN32
-static gboolean is_utf8;
-
-gboolean
-g_get_charset (G_CONST_RETURN char **charset)
-{
- if (my_charset == NULL) {
- /* These shouldn't be heap allocated */
-#if defined(HAVE_LOCALCHARSET_H)
- my_charset = locale_charset ();
-#else
- my_charset = "UTF-8";
-#endif
- is_utf8 = strcmp (my_charset, "UTF-8") == 0;
- }
-
- if (charset != NULL)
- *charset = my_charset;
-
- return is_utf8;
-}
-#endif /* G_OS_WIN32 */
-
-gchar *
-g_locale_to_utf8 (const gchar *opsysstring, gssize len, gsize *bytes_read, gsize *bytes_written, GError **error)
-{
- g_get_charset (NULL);
-
- return g_convert (opsysstring, len, "UTF-8", my_charset, bytes_read, bytes_written, error);
-}
-
-gchar *
-g_locale_from_utf8 (const gchar *utf8string, gssize len, gsize *bytes_read, gsize *bytes_written, GError **error)
-{
- g_get_charset (NULL);
-
- return g_convert (utf8string, len, my_charset, "UTF-8", bytes_read, bytes_written, error);
-}
+++ /dev/null
-/*
- * gutf8.c: UTF-8 conversion
- *
- * Author:
- * Atsushi Enomoto <atsushi@ximian.com>
- *
- * (C) 2006 Novell, Inc.
- * Copyright 2012 Xamarin Inc
- */
-
-#include <stdio.h>
-#include <glib.h>
-
-/*
- * Index into the table below with the first byte of a UTF-8 sequence to get
- * the number of bytes that are supposed to follow it to complete the sequence.
- *
- * Note that *legal* UTF-8 values can't have 4 or 5-bytes. The table is left
- * as-is for anyone who may want to do such conversion, which was allowed in
- * earlier algorithms.
-*/
-const guchar g_utf8_jump_table[256] = {
- 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
- 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
- 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
- 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
- 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
- 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
- 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
- 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, 4,4,4,4,4,4,4,4,5,5,5,5,6,6,1,1
-};
-
-static gchar *
-utf8_case_conv (const gchar *str, gssize len, gboolean upper)
-{
- gunichar *ustr;
- glong i, ulen;
- gchar *utf8;
-
- ustr = g_utf8_to_ucs4_fast (str, (glong) len, &ulen);
- for (i = 0; i < ulen; i++)
- ustr[i] = upper ? g_unichar_toupper (ustr[i]) : g_unichar_tolower (ustr[i]);
- utf8 = g_ucs4_to_utf8 (ustr, ulen, NULL, NULL, NULL);
- g_free (ustr);
-
- return utf8;
-}
-
-gchar *
-g_utf8_strup (const gchar *str, gssize len)
-{
- return utf8_case_conv (str, len, TRUE);
-}
-
-gchar *
-g_utf8_strdown (const gchar *str, gssize len)
-{
- return utf8_case_conv (str, len, FALSE);
-}
-
-static gboolean
-utf8_validate (const unsigned char *inptr, size_t len)
-{
- const unsigned char *ptr = inptr + len;
- unsigned char c;
-
- /* Everything falls through when TRUE... */
- switch (len) {
- default:
- return FALSE;
- case 4:
- if ((c = (*--ptr)) < 0x80 || c > 0xBF)
- return FALSE;
-
- if ((c == 0xBF || c == 0xBE) && ptr[-1] == 0xBF) {
- if (ptr[-2] == 0x8F || ptr[-2] == 0x9F ||
- ptr[-2] == 0xAF || ptr[-2] == 0xBF)
- return FALSE;
- }
- case 3:
- if ((c = (*--ptr)) < 0x80 || c > 0xBF)
- return FALSE;
- case 2:
- if ((c = (*--ptr)) < 0x80 || c > 0xBF)
- return FALSE;
-
- /* no fall-through in this inner switch */
- switch (*inptr) {
- case 0xE0: if (c < 0xA0) return FALSE; break;
- case 0xED: if (c > 0x9F) return FALSE; break;
- case 0xEF: if (c == 0xB7 && (ptr[1] > 0x8F && ptr[1] < 0xB0)) return FALSE;
- if (c == 0xBF && (ptr[1] == 0xBE || ptr[1] == 0xBF)) return FALSE;
- break;
- case 0xF0: if (c < 0x90) return FALSE; break;
- case 0xF4: if (c > 0x8F) return FALSE; break;
- default: if (c < 0x80) return FALSE; break;
- }
- case 1: if (*inptr >= 0x80 && *inptr < 0xC2) return FALSE;
- }
-
- if (*inptr > 0xF4)
- return FALSE;
-
- return TRUE;
-}
-
-/**
- * g_utf8_validate:
- * @str: a utf-8 encoded string
- * @max_len: max number of bytes to validate (or -1 to validate the entire null-terminated string)
- * @end: output parameter to mark the end of the valid input
- *
- * Checks @utf for being valid UTF-8. @str is assumed to be
- * null-terminated. This function is not super-strict, as it will
- * allow longer UTF-8 sequences than necessary. Note that Java is
- * capable of producing these sequences if provoked. Also note, this
- * routine checks for the 4-byte maximum size, but does not check for
- * 0x10ffff maximum value.
- *
- * Return value: %TRUE if @str is valid or %FALSE otherwise.
- **/
-gboolean
-g_utf8_validate (const gchar *str, gssize max_len, const gchar **end)
-{
- guchar *inptr = (guchar *) str;
- gboolean valid = TRUE;
- guint length, min;
- gssize n = 0;
-
- if (max_len == 0)
- return FALSE;
-
- if (max_len < 0) {
- while (*inptr != 0) {
- length = g_utf8_jump_table[*inptr];
- if (!utf8_validate (inptr, length)) {
- valid = FALSE;
- break;
- }
-
- inptr += length;
- }
- } else {
- while (n < max_len) {
- if (*inptr == 0) {
- /* Note: return FALSE if we encounter nul-byte
- * before max_len is reached. */
- valid = FALSE;
- break;
- }
-
- length = g_utf8_jump_table[*inptr];
- min = MIN (length, max_len - n);
-
- if (!utf8_validate (inptr, min)) {
- valid = FALSE;
- break;
- }
-
- if (min < length) {
- valid = FALSE;
- break;
- }
-
- inptr += length;
- n += length;
- }
- }
-
- if (end != NULL)
- *end = (gchar *) inptr;
-
- return valid;
-}
-
-gunichar
-g_utf8_get_char_validated (const gchar *str, gssize max_len)
-{
- unsigned char *inptr = (unsigned char *) str;
- gunichar u = *inptr;
- int n, i;
-
- if (max_len == 0)
- return -2;
-
- if (u < 0x80) {
- /* simple ascii case */
- return u;
- } else if (u < 0xc2) {
- return -1;
- } else if (u < 0xe0) {
- u &= 0x1f;
- n = 2;
- } else if (u < 0xf0) {
- u &= 0x0f;
- n = 3;
- } else if (u < 0xf8) {
- u &= 0x07;
- n = 4;
- } else if (u < 0xfc) {
- u &= 0x03;
- n = 5;
- } else if (u < 0xfe) {
- u &= 0x01;
- n = 6;
- } else {
- return -1;
- }
-
- if (max_len > 0) {
- if (!utf8_validate (inptr, MIN (max_len, n)))
- return -1;
-
- if (max_len < n)
- return -2;
- } else {
- if (!utf8_validate (inptr, n))
- return -1;
- }
-
- for (i = 1; i < n; i++)
- u = (u << 6) | (*++inptr ^ 0x80);
-
- return u;
-}
-
-glong
-g_utf8_strlen (const gchar *str, gssize max_len)
-{
- const guchar *inptr = (const guchar *) str;
- glong clen = 0, len = 0, n;
-
- if (max_len == 0)
- return 0;
-
- if (max_len < 0) {
- while (*inptr) {
- inptr += g_utf8_jump_table[*inptr];
- len++;
- }
- } else {
- while (len < max_len && *inptr) {
- n = g_utf8_jump_table[*inptr];
- if ((clen + n) > max_len)
- break;
-
- inptr += n;
- clen += n;
- len++;
- }
- }
-
- return len;
-}
-
-gunichar
-g_utf8_get_char (const gchar *src)
-{
- unsigned char *inptr = (unsigned char *) src;
- gunichar u = *inptr;
- int n, i;
-
- if (u < 0x80) {
- /* simple ascii case */
- return u;
- } else if (u < 0xe0) {
- u &= 0x1f;
- n = 2;
- } else if (u < 0xf0) {
- u &= 0x0f;
- n = 3;
- } else if (u < 0xf8) {
- u &= 0x07;
- n = 4;
- } else if (u < 0xfc) {
- u &= 0x03;
- n = 5;
- } else {
- u &= 0x01;
- n = 6;
- }
-
- for (i = 1; i < n; i++)
- u = (u << 6) | (*++inptr ^ 0x80);
-
- return u;
-}
-
-gchar *
-g_utf8_find_prev_char (const gchar *str, const gchar *p)
-{
- while (p > str) {
- p--;
- if ((*p & 0xc0) != 0xb0)
- return (gchar *)p;
- }
- return NULL;
-}
-
-gchar *
-g_utf8_prev_char (const gchar *str)
-{
- const gchar *p = str;
- do {
- p--;
- } while ((*p & 0xc0) == 0xb0);
-
- return (gchar *)p;
-}
-
-gchar *
-g_utf8_offset_to_pointer (const gchar *str, glong offset)
-{
- const gchar *p = str;
-
- if (offset > 0) {
- do {
- p = g_utf8_next_char (p);
- offset --;
- } while (offset > 0);
- }
- else if (offset < 0) {
- const gchar *jump = str;
- do {
- // since the minimum size of a character is 1
- // we know we can step back at least offset bytes
- jump = jump + offset;
-
- // if we land in the middle of a character
- // walk to the beginning
- while ((*jump & 0xc0) == 0xb0)
- jump --;
-
- // count how many characters we've actually walked
- // by going forward
- p = jump;
- do {
- p = g_utf8_next_char (p);
- offset ++;
- } while (p < jump);
-
- } while (offset < 0);
- }
-
- return (gchar *)p;
-}
-
-glong
-g_utf8_pointer_to_offset (const gchar *str, const gchar *pos)
-{
- const gchar *inptr, *inend;
- glong offset = 0;
- glong sign = 1;
-
- if (pos == str)
- return 0;
-
- if (str < pos) {
- inptr = str;
- inend = pos;
- } else {
- inptr = pos;
- inend = str;
- sign = -1;
- }
-
- do {
- inptr = g_utf8_next_char (inptr);
- offset++;
- } while (inptr < inend);
-
- return offset * sign;
-}
+++ /dev/null
-/*
- * sort.frag.h: Common implementation of linked-list sorting
- *
- * Author:
- * Raja R Harinath (rharinath@novell.com)
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * (C) 2006 Novell, Inc.
- */
-
-/*
- * This code requires a typedef named 'list_node' for the list node. It
- * is assumed that the list type is the type of a pointer to a list
- * node, and that the node has a field named 'next' that implements to
- * the linked list. No additional invariant is maintained (e.g. the
- * 'prev' pointer of a doubly-linked list node is _not_ updated). Any
- * invariant would require a post-processing pass to fix matters if
- * necessary.
- */
-typedef list_node *digit;
-
-/*
- * The maximum possible depth of the merge tree
- * = ceiling (log2 (maximum number of list nodes))
- * = ceiling (log2 (maximum possible memory size/size of each list node))
- * = number of bits in 'size_t' - floor (log2 (sizeof digit))
- * Also, each list in sort_info is at least 2 nodes long: we can reduce the depth by 1
- */
-#define FLOOR_LOG2(x) (((x)>=2) + ((x)>=4) + ((x)>=8) + ((x)>=16) + ((x)>=32) + ((x)>=64) + ((x)>=128))
-#define MAX_RANKS ((sizeof (size_t) * 8) - FLOOR_LOG2(sizeof (list_node)) - 1)
-
-struct sort_info
-{
- int min_rank, n_ranks;
- GCompareFunc func;
-
- /* Invariant: ranks[i] == NULL || length(ranks[i]) >= 2**(i+1) */
- list_node *ranks [MAX_RANKS]; /* ~ 128 bytes on 32bit, ~ 512 bytes on 64bit */
-};
-
-static inline void
-init_sort_info (struct sort_info *si, GCompareFunc func)
-{
- si->min_rank = si->n_ranks = 0;
- si->func = func;
- /* we don't need to initialize si->ranks, since we never lookup past si->n_ranks. */
-}
-
-static inline list_node *
-merge_lists (list_node *first, list_node *second, GCompareFunc func)
-{
- /* merge the two lists */
- list_node *list = NULL;
- list_node **pos = &list;
- while (first && second) {
- if (func (first->data, second->data) > 0) {
- *pos = second;
- second = second->next;
- } else {
- *pos = first;
- first = first->next;
- }
- pos = &((*pos)->next);
- }
- *pos = first ? first : second;
- return list;
-}
-
-/* Pre-condition: upto <= si->n_ranks, list == NULL || length(list) == 1 */
-static inline list_node *
-sweep_up (struct sort_info *si, list_node *list, int upto)
-{
-#if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 406)
- /*
- * GCC incorrectly thinks we're writing below si->ranks array bounds.
- */
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Warray-bounds"
-#endif
-
- int i;
- for (i = si->min_rank; i < upto; ++i) {
- list = merge_lists (si->ranks [i], list, si->func);
- si->ranks [i] = NULL;
- }
- return list;
-
-#if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 406)
-#pragma GCC diagnostic pop
-#endif
-}
-
-/*
- * The 'ranks' array essentially captures the recursion stack of a mergesort.
- * The merge tree is built in a bottom-up manner. The control loop for
- * updating the 'ranks' array is analogous to incrementing a binary integer,
- * and the O(n) time for counting upto n translates to O(n) merges when
- * inserting rank-0 lists. When we plug in the sizes of the lists involved in
- * those merges, we get the O(n log n) time for the sort.
- *
- * Inserting higher-ranked lists reduce the height of the merge tree, and also
- * eliminate a lot of redundant comparisons when merging two lists that would've
- * been part of the same run. Adding a rank-i list is analogous to incrementing
- * a binary integer by 2**i in one operation, thus sharing a similar speedup.
- *
- * When inserting higher-ranked lists, we choose to clear out the lower ranks
- * in the interests of keeping the sort stable, but this makes analysis harder.
- * Note that clearing the lower-ranked lists is O(length(list))-- thus it
- * shouldn't affect the O(n log n) behaviour. IOW, inserting one rank-i list
- * is equivalent to inserting 2**i rank-0 lists, thus even if we do i additional
- * merges in the clearing-out (taking at most 2**i time) we are still fine.
- */
-
-#define stringify2(x) #x
-#define stringify(x) stringify2(x)
-
-/* Pre-condition: 2**(rank+1) <= length(list) < 2**(rank+2) (therefore: length(list) >= 2) */
-static inline void
-insert_list (struct sort_info *si, list_node* list, int rank)
-{
-#if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 406)
- /*
- * GCC incorrectly thinks we're writing below si->ranks array bounds.
- */
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Warray-bounds"
-#endif
-
- int i;
-
- if (rank > si->n_ranks) {
- if (rank > MAX_RANKS) {
- g_warning ("Rank '%d' should not exceed " stringify (MAX_RANKS), rank);
- rank = MAX_RANKS;
- }
- list = merge_lists (sweep_up (si, NULL, si->n_ranks), list, si->func);
- for (i = si->n_ranks; i < rank; ++i)
- si->ranks [i] = NULL;
- } else {
- if (rank)
- list = merge_lists (sweep_up (si, NULL, rank), list, si->func);
- for (i = rank; i < si->n_ranks && si->ranks [i]; ++i) {
- list = merge_lists (si->ranks [i], list, si->func);
- si->ranks [i] = NULL;
- }
- }
-
- if (i == MAX_RANKS) /* Will _never_ happen: so we can just devolve into quadratic ;-) */
- --i;
- if (i >= si->n_ranks)
- si->n_ranks = i + 1;
- si->min_rank = i;
- si->ranks [i] = list;
-
-#if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 406)
-#pragma GCC diagnostic pop
-#endif
-}
-
-#undef stringify2
-#undef stringify
-#undef MAX_RANKS
-#undef FLOOR_LOG2
-
-/* A non-recursive mergesort */
-static inline digit
-do_sort (list_node* list, GCompareFunc func)
-{
- struct sort_info si;
-
- init_sort_info (&si, func);
-
- while (list && list->next) {
- list_node* next = list->next;
- list_node* tail = next->next;
-
- if (func (list->data, next->data) > 0) {
- next->next = list;
- next = list;
- list = list->next;
- }
- next->next = NULL;
-
- insert_list (&si, list, 0);
-
- list = tail;
- }
-
- return sweep_up (&si, list, si.n_ranks);
-}
+++ /dev/null
-/*
-This file is automatically generated by ucd.exe.
-The source for this generator should be in Mono repository
-(mcs/class/corlib/Mono.Globalization.Unicode directory).
-*/
-
-#ifndef __UNICODE_DATA_H
-#define __UNICODE_DATA_H
-
-#include <glib.h>
-
-
-/* ======== Structures ======== */
-typedef struct {
- guint32 codepoint;
- guint32 upper;
- guint32 title;
-} SimpleTitlecaseMapping;
-typedef struct {
- guint32 start;
- guint32 end;
-} CodePointRange;
-typedef struct {
- guint32 upper;
- guint32 lower;
-} SimpleCaseMapping;
-
-/* ======== Unicode Categories ======== */
-static const guint8 unicode_category_ranges_count = 11;
-static const CodePointRange unicode_category_ranges [] = {
-{0x000000, 0x003400},
-{0x004DC0, 0x004E00},
-{0x00A000, 0x00AA80},
-{0x00F900, 0x010000},
-{0x010000, 0x0104C0},
-{0x010800, 0x010A80},
-{0x012000, 0x012480},
-{0x01D000, 0x01D800},
-{0x01F000, 0x01F0C0},
-{0x02F800, 0x02FA40},
-{0x0E0000, 0x0E0200},
-{0, 0}};
-static const guint8 unicode_category_table0 [] = {
- /* ==== 0-3400 ==== */
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 29,21,21,21,23,21,21,21,22,18,21,25,21,17,21,21,
- 13,13,13,13,13,13,13,13,13,13,21,21,25,25,25,21,
- 21,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,
- 9,9,9,9,9,9,9,9,9,9,9,22,21,18,24,16,
- 24,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
- 5,5,5,5,5,5,5,5,5,5,5,22,25,18,25,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 29,21,23,23,23,23,26,26,24,26,5,20,25,1,26,24,
- 26,25,15,15,24,5,26,21,24,15,5,19,15,15,15,21,
- 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,
- 9,9,9,9,9,9,9,25,9,9,9,9,9,9,9,5,
- 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
- 5,5,5,5,5,5,5,25,5,5,5,5,5,5,5,5,
- 9,5,9,5,9,5,9,5,9,5,9,5,9,5,9,5,
- 9,5,9,5,9,5,9,5,9,5,9,5,9,5,9,5,
- 9,5,9,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,24,24,24,24,24,24,24,24,
- 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,
- 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,
- 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,
- 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,
- 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,
- 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,
- 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,
- 9,5,9,5,6,24,9,5,0,0,6,5,5,5,21,0,
- 0,0,0,0,24,24,9,21,9,9,9,0,9,0,9,9,
- 5,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,
- 9,9,0,9,9,9,9,9,9,9,9,9,5,5,5,5,
- 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
- 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,9,
- 5,5,9,9,9,5,5,5,9,5,9,5,9,5,9,5,
- 9,5,9,5,9,5,9,5,9,5,9,5,9,5,9,5,
- 5,5,5,5,9,5,25,9,5,9,9,5,5,9,9,9,
- 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,
- 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,
- 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,
- 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
- 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
- 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
- 9,5,9,5,9,5,9,5,9,5,9,5,9,5,9,5,
- 9,5,9,5,9,5,9,5,9,5,9,5,9,5,9,5,
- 9,5,26,12,12,12,12,12,11,11,9,5,9,5,9,5,
- 9,5,9,5,9,5,9,5,9,5,9,5,9,5,9,5,
- 9,5,9,5,9,5,9,5,9,5,9,5,9,5,9,5,
- 9,5,9,5,9,5,9,5,9,5,9,5,9,5,9,5,
- 9,9,5,9,5,9,5,9,5,9,5,9,5,9,5,5,
- 9,5,9,5,9,5,9,5,9,5,9,5,9,5,9,5,
- 9,5,9,5,9,5,9,5,9,5,9,5,9,5,9,5,
- 9,5,9,5,9,5,9,5,9,5,9,5,9,5,9,5,
- 9,5,9,5,9,5,9,5,9,5,9,5,9,5,9,5,
- 9,5,9,5,9,5,9,5,9,5,9,5,9,5,9,5,
- 9,5,9,5,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,
- 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,
- 9,9,9,9,9,9,9,0,0,6,21,21,21,21,21,21,
- 0,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
- 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
- 5,5,5,5,5,5,5,5,0,21,17,0,0,0,0,0,
- 0,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,
- 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,
- 12,12,12,12,12,12,12,12,12,12,12,12,12,12,17,12,
- 21,12,12,21,12,12,21,12,0,0,0,0,0,0,0,0,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,7,7,7,0,0,0,0,0,
- 7,7,7,21,21,0,0,0,0,0,0,0,0,0,0,0,
- 1,1,1,1,0,0,25,25,25,21,21,23,21,21,26,26,
- 12,12,12,12,12,12,12,12,12,12,12,21,0,0,21,21,
- 0,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 6,7,7,7,7,7,7,7,7,7,7,12,12,12,12,12,
- 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,0,
- 13,13,13,13,13,13,13,13,13,13,21,21,21,21,7,7,
- 12,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,21,7,12,12,12,12,12,12,12,1,11,12,
- 12,12,12,12,12,6,6,12,12,26,12,12,12,12,7,7,
- 13,13,13,13,13,13,13,13,13,13,7,7,7,26,26,7,
- 21,21,21,21,21,21,21,21,21,21,21,21,21,21,0,1,
- 7,12,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,
- 12,12,12,12,12,12,12,12,12,12,12,0,0,7,7,7,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,12,12,12,12,12,12,12,12,12,12,
- 12,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 13,13,13,13,13,13,13,13,13,13,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,7,7,7,12,12,12,12,12,
- 12,12,12,12,6,6,26,21,21,21,6,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0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12,0,0,12,12,12,0,0,
- 0,12,0,0,0,0,0,0,0,7,7,7,7,0,7,0,
- 0,0,0,0,0,0,13,13,13,13,13,13,13,13,13,13,
- 12,12,7,7,7,12,0,0,0,0,0,0,0,0,0,0,
- 0,12,12,10,0,7,7,7,7,7,7,7,7,7,0,7,
- 7,7,0,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,7,0,7,7,7,7,7,7,
- 7,0,7,7,0,7,7,7,7,7,0,0,12,7,10,10,
- 10,12,12,12,12,12,0,12,12,10,0,10,10,12,0,0,
- 7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 7,7,12,12,0,0,13,13,13,13,13,13,13,13,13,13,
- 0,23,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,12,10,10,0,7,7,7,7,7,7,7,7,0,0,7,
- 7,0,0,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,7,0,7,7,7,7,7,7,
- 7,0,7,7,0,7,7,7,7,7,0,0,12,7,10,12,
- 10,12,12,12,12,0,0,10,10,0,0,10,10,12,0,0,
- 0,0,0,0,0,0,12,10,0,0,0,0,7,7,0,7,
- 7,7,12,12,0,0,13,13,13,13,13,13,13,13,13,13,
- 26,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,12,7,0,7,7,7,7,7,7,0,0,0,7,7,
- 7,0,7,7,7,7,0,0,0,7,7,0,7,0,7,7,
- 0,0,0,7,7,0,0,0,7,7,7,0,0,0,7,7,
- 7,7,7,7,7,7,7,7,7,7,0,0,0,0,10,10,
- 12,10,10,0,0,0,10,10,10,0,10,10,10,12,0,0,
- 7,0,0,0,0,0,0,10,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,13,13,13,13,13,13,13,13,13,13,
- 15,15,15,26,26,26,26,26,26,23,26,0,0,0,0,0,
- 0,10,10,10,0,7,7,7,7,7,7,7,7,0,7,7,
- 7,0,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,7,0,7,7,7,7,7,7,
- 7,7,7,7,0,7,7,7,7,7,0,0,0,7,12,12,
- 12,10,10,10,10,0,12,12,12,0,12,12,12,12,0,0,
- 0,0,0,0,0,12,12,0,7,7,0,0,0,0,0,0,
- 7,7,12,12,0,0,13,13,13,13,13,13,13,13,13,13,
- 0,0,0,0,0,0,0,0,15,15,15,15,15,15,15,26,
- 0,0,10,10,0,7,7,7,7,7,7,7,7,0,7,7,
- 7,0,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,7,0,7,7,7,7,7,7,
- 7,7,7,7,0,7,7,7,7,7,0,0,12,7,10,12,
- 10,10,10,10,10,0,12,10,10,0,10,10,12,12,0,0,
- 0,0,0,0,0,10,10,0,0,0,0,0,0,0,7,0,
- 7,7,12,12,0,0,13,13,13,13,13,13,13,13,13,13,
- 0,26,26,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,10,10,0,7,7,7,7,7,7,7,7,0,7,7,
- 7,0,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,7,0,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,7,7,0,0,0,7,10,10,
- 10,12,12,12,12,0,10,10,10,0,10,10,10,12,0,0,
- 0,0,0,0,0,0,0,10,0,0,0,0,0,0,0,0,
- 7,7,12,12,0,0,13,13,13,13,13,13,13,13,13,13,
- 15,15,15,15,15,15,0,0,0,26,7,7,7,7,7,7,
- 0,0,10,10,0,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,0,0,0,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,0,7,7,7,7,7,7,7,7,7,0,7,0,0,
- 7,7,7,7,7,7,7,0,0,0,12,0,0,0,0,10,
- 10,10,12,12,12,0,12,0,10,10,10,10,10,10,10,10,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,10,10,21,0,0,0,0,0,0,0,0,0,0,0,
- 0,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,12,7,7,12,12,12,12,12,12,12,0,0,0,0,23,
- 7,7,7,7,7,7,6,12,12,12,12,12,12,12,12,21,
- 13,13,13,13,13,13,13,13,13,13,21,21,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,7,7,0,7,0,0,7,7,0,7,0,0,7,0,0,
- 0,0,0,0,7,7,7,7,0,7,7,7,7,7,7,7,
- 0,7,7,7,0,7,0,7,0,0,7,7,0,7,7,7,
- 7,12,7,7,12,12,12,12,12,12,0,12,12,7,0,0,
- 7,7,7,7,7,0,6,0,12,12,12,12,12,12,0,0,
- 13,13,13,13,13,13,13,13,13,13,0,0,7,7,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 7,26,26,26,21,21,21,21,21,21,21,21,21,21,21,21,
- 21,21,21,26,26,26,26,26,12,12,26,26,26,26,26,26,
- 13,13,13,13,13,13,13,13,13,13,15,15,15,15,15,15,
- 15,15,15,15,26,12,26,12,26,12,22,18,22,18,10,10,
- 7,7,7,7,7,7,7,7,0,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,0,0,0,
- 0,12,12,12,12,12,12,12,12,12,12,12,12,12,12,10,
- 12,12,12,12,12,21,12,12,7,7,7,7,0,0,0,0,
- 12,12,12,12,12,12,12,12,0,12,12,12,12,12,12,12,
- 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,
- 12,12,12,12,12,12,12,12,12,12,12,12,12,0,26,26,
- 26,26,26,26,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0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,0,0,0,
- 12,12,12,10,10,10,10,12,12,10,10,10,0,0,0,0,
- 10,10,12,10,10,10,10,10,10,12,12,12,0,0,0,0,
- 26,0,0,0,21,21,13,13,13,13,13,13,13,13,13,13,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,0,0,
- 7,7,7,7,7,0,0,0,0,0,0,0,0,0,0,0,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,7,7,0,0,0,0,0,0,
- 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,
- 10,7,7,7,7,7,7,7,10,10,0,0,0,0,0,0,
- 13,13,13,13,13,13,13,13,13,13,0,0,0,0,21,21,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,12,12,10,10,10,0,0,21,21,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 12,12,12,12,10,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,12,10,12,12,12,12,12,10,12,10,10,10,
- 10,10,12,10,10,7,7,7,7,7,7,7,0,0,0,0,
- 13,13,13,13,13,13,13,13,13,13,21,21,21,21,21,21,
- 21,26,26,26,26,26,26,26,26,26,26,12,12,12,12,12,
- 12,12,12,12,26,26,26,26,26,26,26,26,26,0,0,0,
- 12,12,10,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,10,12,12,12,12,10,10,12,12,10,0,0,0,7,7,
- 13,13,13,13,13,13,13,13,13,13,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,10,10,10,10,10,10,10,10,12,12,12,12,
- 12,12,12,12,10,10,12,12,0,0,0,21,21,21,21,21,
- 13,13,13,13,13,13,13,13,13,13,0,0,0,7,7,7,
- 13,13,13,13,13,13,13,13,13,13,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,6,6,6,6,6,6,21,21,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0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,19,21,21,21,21,16,
- 16,21,21,21,25,22,18,21,21,21,21,21,21,21,21,21,
- 21,21,25,21,16,21,21,21,21,21,21,21,21,21,21,29,
- 1,1,1,1,1,0,0,0,0,0,1,1,1,1,1,1,
- 15,5,0,0,15,15,15,15,15,15,25,25,25,22,18,5,
- 15,15,15,15,15,15,15,15,15,15,25,25,25,22,18,0,
- 6,6,6,6,6,0,0,0,0,0,0,0,0,0,0,0,
- 23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,
- 23,23,23,23,23,23,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 12,12,12,12,12,12,12,12,12,12,12,12,12,11,11,11,
- 11,12,11,11,11,12,12,12,12,12,12,12,12,12,12,12,
- 12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 26,26,9,26,26,26,26,9,26,26,5,9,9,9,5,5,
- 9,9,9,5,26,9,26,26,26,9,9,9,9,9,26,26,
- 26,26,26,26,9,26,9,26,9,26,9,9,9,9,26,5,
- 9,9,9,9,5,7,7,7,7,5,26,26,5,5,9,9,
- 25,25,25,25,25,9,5,5,5,5,26,25,26,26,5,26,
- 0,0,0,15,15,15,15,15,15,15,15,15,15,15,15,15,
- 14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,
- 14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,
- 14,14,14,9,5,14,14,14,14,0,0,0,0,0,0,0,
- 25,25,25,25,25,26,26,26,26,26,25,25,26,26,26,26,
- 25,26,26,25,26,26,25,26,26,26,26,26,26,26,25,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,25,25,
- 26,26,25,26,25,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,25,25,25,25,25,25,25,25,25,25,25,25,
- 25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
- 25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
- 25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
- 25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
- 25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
- 25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
- 25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
- 25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
- 25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
- 25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
- 25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
- 25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
- 25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
- 25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
- 25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
- 25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
- 26,26,26,26,26,26,26,26,25,25,25,25,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 25,25,26,26,26,26,26,26,26,22,18,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,25,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,25,25,25,25,25,
- 25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
- 25,25,25,25,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,25,25,25,25,
- 25,25,26,26,26,26,26,26,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 26,26,26,26,26,26,26,26,26,26,26,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,
- 15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,
- 15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,
- 15,15,15,15,15,15,15,15,15,15,15,15,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,15,15,15,15,15,15,
- 15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,25,26,26,26,26,26,26,26,26,
- 26,25,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,25,25,25,25,25,25,25,25,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,25,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,0,0,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,0,0,0,
- 26,26,26,26,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,26,26,26,26,0,26,26,26,26,0,0,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,0,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,0,26,0,26,
- 26,26,26,0,0,0,26,0,26,26,26,26,26,26,26,0,
- 0,26,26,26,26,26,26,26,22,18,22,18,22,18,22,18,
- 22,18,22,18,22,18,15,15,15,15,15,15,15,15,15,15,
- 15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,
- 15,15,15,15,26,0,0,0,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 0,26,26,26,26,26,26,26,26,26,26,26,26,26,26,0,
- 25,25,25,25,25,22,18,25,25,25,25,0,25,0,0,0,
- 25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
- 25,25,25,25,25,25,22,18,22,18,22,18,22,18,22,18,
- 25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
- 25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
- 25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
- 25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
- 25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
- 25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
- 25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
- 25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
- 25,25,25,22,18,22,18,22,18,22,18,22,18,22,18,22,
- 18,22,18,22,18,22,18,22,18,25,25,25,25,25,25,25,
- 25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
- 25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
- 25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
- 25,25,25,25,25,25,25,25,22,18,22,18,25,25,25,25,
- 25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
- 25,25,25,25,25,25,25,25,25,25,25,25,22,18,25,25,
- 25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
- 25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
- 25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
- 25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
- 25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
- 25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
- 25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
- 25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
- 25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
- 25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
- 25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
- 25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
- 25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
- 25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
- 25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
- 25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 25,25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5,5,5,5,5,5,5,5,5,5,
- 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
- 5,5,5,5,5,5,0,0,0,0,0,0,0,0,0,0,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,0,0,0,0,0,0,0,0,0,6,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,0,0,0,0,0,0,0,0,0,
- 7,7,7,7,7,7,7,0,7,7,7,7,7,7,7,0,
- 7,7,7,7,7,7,7,0,7,7,7,7,7,7,7,0,
- 7,7,7,7,7,7,7,0,7,7,7,7,7,7,7,0,
- 7,7,7,7,7,7,7,0,7,7,7,7,7,7,7,0,
- 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,
- 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,
- 21,21,20,19,20,19,21,21,21,20,19,21,20,19,21,21,
- 21,21,21,21,21,21,21,17,21,21,17,21,20,19,21,21,
- 20,19,22,18,22,18,22,18,22,18,21,21,21,21,21,6,
- 21,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,0,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,0,0,0,0,0,0,0,0,0,0,0,0,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 26,26,26,26,26,26,26,26,26,26,26,26,0,0,0,0,
- 29,21,21,21,26,6,7,14,22,18,22,18,22,18,22,18,
- 22,18,26,26,22,18,22,18,22,18,22,18,17,22,18,18,
- 26,14,14,14,14,14,14,14,14,14,12,12,12,12,12,12,
- 17,6,6,6,6,6,26,26,14,14,14,6,7,21,26,26,
- 0,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,0,0,12,12,24,24,6,6,7,
- 17,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,7,7,7,21,6,6,6,7,
- 0,0,0,0,0,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,0,0,
- 0,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,0,
- 26,26,15,15,15,15,26,26,26,26,26,26,26,26,26,26,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,0,0,0,0,0,0,0,0,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,0,0,0,0,0,0,0,0,0,0,0,0,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,0,
- 15,15,15,15,15,15,15,15,15,15,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,0,0,0,0,0,0,0,0,0,0,0,0,
- 26,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 15,15,15,15,15,15,15,15,15,15,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,0,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 0};
-static const guint8 unicode_category_table1 [] = {
- /* ==== 4DC0-4E00 ==== */
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 0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7,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,0,0,1,
- 0,21,21,21,23,21,21,21,22,18,21,25,21,17,21,21,
- 13,13,13,13,13,13,13,13,13,13,21,21,25,25,25,21,
- 21,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,
- 9,9,9,9,9,9,9,9,9,9,9,22,21,18,24,16,
- 24,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
- 5,5,5,5,5,5,5,5,5,5,5,22,25,18,25,22,
- 18,21,22,18,21,21,7,7,7,7,7,7,7,7,7,7,
- 6,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,6,6,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,0,
- 0,0,7,7,7,7,7,7,0,0,7,7,7,7,7,7,
- 0,0,7,7,7,7,7,7,0,0,7,7,7,0,0,0,
- 23,23,25,24,26,23,23,0,26,25,25,25,25,26,26,0,
- 0,0,0,0,0,0,0,0,0,1,1,1,26,26,0};
-static const guint8 unicode_category_table4 [] = {
- /* ==== 10000-104C0 ==== */
- 7,7,7,7,7,7,7,7,7,7,7,7,0,7,7,7,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,0,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,7,7,7,0,7,7,0,7,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,0,0,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,7,7,7,0,0,0,0,0,
- 21,21,26,0,0,0,0,15,15,15,15,15,15,15,15,15,
- 15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,
- 15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,
- 15,15,15,15,0,0,0,26,26,26,26,26,26,26,26,26,
- 14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,
- 14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,
- 14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,
- 14,14,14,14,14,15,15,15,15,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,15,0,0,0,0,0,
- 26,26,26,26,26,26,26,26,26,26,26,26,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,12,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 7,7,7,7,7,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7,7,7,7,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,
- 14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,
- 14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,
- 14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,
- 14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,
- 14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,
- 14,14,14,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 21,21,21,21,0};
-static const guint8 unicode_category_table7 [] = {
- /* ==== 1D000-1D800 ==== */
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,0,0,0,0,0,0,0,0,0,0,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,0,0,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,10,10,12,12,12,26,26,26,10,10,10,
- 10,10,10,1,1,1,1,1,1,1,1,12,12,12,12,12,
- 12,12,12,26,26,12,12,12,12,12,12,12,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,12,12,12,12,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,12,12,12,26,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,0,0,0,0,0,0,0,0,0,
- 15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,
- 15,15,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,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,5,5,5,5,5,5,5,25,
- 5,5,5,5,5,5,9,9,9,9,9,9,9,9,9,9,
- 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,25,
- 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
- 5,5,5,5,5,5,5,5,5,25,5,5,5,5,5,5,
- 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,
- 9,9,9,9,9,9,9,9,9,25,5,5,5,5,5,5,
- 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
- 5,5,5,25,5,5,5,5,5,5,9,5,0,0,13,13,
- 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,
- 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,
- 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,
- 0};
-static const guint8 unicode_category_table8 [] = {
- /* ==== 1F000-1F0C0 ==== */
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,0,0,0,0,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,0};
-static const guint8 unicode_category_table9 [] = {
- /* ==== 2F800-2FA40 ==== */
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,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
- 0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
- 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
- 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
- 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
- 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
- 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,
- 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,
- 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,
- 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,
- 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,
- 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,
- 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,
- 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,
- 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,
- 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,
- 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,
- 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,
- 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,
- 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,
- 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,
- 0};
-static const guint8 *unicode_category [11] = {
- unicode_category_table0,
- unicode_category_table1,
- unicode_category_table2,
- unicode_category_table3,
- unicode_category_table4,
- unicode_category_table5,
- unicode_category_table6,
- unicode_category_table7,
- unicode_category_table8,
- unicode_category_table9,
- unicode_category_table10
-};
-
-static const guint8 simple_case_map_ranges_count = 9;
-static const CodePointRange simple_case_map_ranges [] = {
-{0x000040, 0x000600},
-{0x001000, 0x0010D0},
-{0x001D00, 0x002000},
-{0x002100, 0x0021C0},
-{0x002480, 0x002500},
-{0x002C00, 0x002D80},
-{0x00A640, 0x00A7C0},
-{0x00FF20, 0x00FF80},
-{0x010400, 0x010480},
-{0, 0}};
-static const guint16 simple_upper_case_mapping_lowarea_table0 [] = {
- /* ==== 40-600 ==== */
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4A,0x4B,0x4C,0x4D,0x4E,0x4F,
- 0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5A,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0x39C,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,
- 0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0x178,
- 0,0x100,0,0x102,0,0x104,0,0x106,0,0x108,0,0x10A,0,0x10C,0,0x10E,
- 0,0x110,0,0x112,0,0x114,0,0x116,0,0x118,0,0x11A,0,0x11C,0,0x11E,
- 0,0x120,0,0x122,0,0x124,0,0x126,0,0x128,0,0x12A,0,0x12C,0,0x12E,
- 0,0x49,0,0x132,0,0x134,0,0x136,0,0,0x139,0,0x13B,0,0x13D,0,
- 0x13F,0,0x141,0,0x143,0,0x145,0,0x147,0,0,0x14A,0,0x14C,0,0x14E,
- 0,0x150,0,0x152,0,0x154,0,0x156,0,0x158,0,0x15A,0,0x15C,0,0x15E,
- 0,0x160,0,0x162,0,0x164,0,0x166,0,0x168,0,0x16A,0,0x16C,0,0x16E,
- 0,0x170,0,0x172,0,0x174,0,0x176,0,0,0x179,0,0x17B,0,0x17D,0x53,
- 0x243,0,0,0x182,0,0x184,0,0,0x187,0,0,0,0x18B,0,0,0,
- 0,0,0x191,0,0,0x1F6,0,0,0,0x198,0x23D,0,0,0,0x220,0,
- 0,0x1A0,0,0x1A2,0,0x1A4,0,0,0x1A7,0,0,0,0,0x1AC,0,0,
- 0x1AF,0,0,0,0x1B3,0,0x1B5,0,0,0x1B8,0,0,0,0x1BC,0,0x1F7,
- 0,0,0,0,0,0x1C4,0x1C4,0,0x1C7,0x1C7,0,0x1CA,0x1CA,0,0x1CD,0,
- 0x1CF,0,0x1D1,0,0x1D3,0,0x1D5,0,0x1D7,0,0x1D9,0,0x1DB,0x18E,0,0x1DE,
- 0,0x1E0,0,0x1E2,0,0x1E4,0,0x1E6,0,0x1E8,0,0x1EA,0,0x1EC,0,0x1EE,
- 0,0,0x1F1,0x1F1,0,0x1F4,0,0,0,0x1F8,0,0x1FA,0,0x1FC,0,0x1FE,
- 0,0x200,0,0x202,0,0x204,0,0x206,0,0x208,0,0x20A,0,0x20C,0,0x20E,
- 0,0x210,0,0x212,0,0x214,0,0x216,0,0x218,0,0x21A,0,0x21C,0,0x21E,
- 0,0,0,0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x392,0x393,0x394,0x395,0x396,0x397,0x398,0x399,0x39A,0x39B,0x39C,0x39D,0x39E,0x39F,
- 0x3A0,0x3A1,0x3A3,0x3A3,0x3A4,0x3A5,0x3A6,0x3A7,0x3A8,0x3A9,0x3AA,0x3AB,0x38C,0x38E,0x38F,0,
- 0x392,0x398,0,0,0,0x3A6,0x3A0,0x3CF,0,0x3D8,0,0x3DA,0,0x3DC,0,0x3DE,
- 0,0x3E0,0,0x3E2,0,0x3E4,0,0x3E6,0,0x3E8,0,0x3EA,0,0x3EC,0,0x3EE,
- 0x39A,0x3A1,0x3F9,0,0,0x395,0,0,0x3F7,0,0,0x3FA,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0x410,0x411,0x412,0x413,0x414,0x415,0x416,0x417,0x418,0x419,0x41A,0x41B,0x41C,0x41D,0x41E,0x41F,
- 0x420,0x421,0x422,0x423,0x424,0x425,0x426,0x427,0x428,0x429,0x42A,0x42B,0x42C,0x42D,0x42E,0x42F,
- 0x400,0x401,0x402,0x403,0x404,0x405,0x406,0x407,0x408,0x409,0x40A,0x40B,0x40C,0x40D,0x40E,0x40F,
- 0,0x460,0,0x462,0,0x464,0,0x466,0,0x468,0,0x46A,0,0x46C,0,0x46E,
- 0,0x470,0,0x472,0,0x474,0,0x476,0,0x478,0,0x47A,0,0x47C,0,0x47E,
- 0,0x480,0,0,0,0,0,0,0,0,0,0x48A,0,0x48C,0,0x48E,
- 0,0x490,0,0x492,0,0x494,0,0x496,0,0x498,0,0x49A,0,0x49C,0,0x49E,
- 0,0x4A0,0,0x4A2,0,0x4A4,0,0x4A6,0,0x4A8,0,0x4AA,0,0x4AC,0,0x4AE,
- 0,0x4B0,0,0x4B2,0,0x4B4,0,0x4B6,0,0x4B8,0,0x4BA,0,0x4BC,0,0x4BE,
- 0,0,0x4C1,0,0x4C3,0,0x4C5,0,0x4C7,0,0x4C9,0,0x4CB,0,0x4CD,0x4C0,
- 0,0x4D0,0,0x4D2,0,0x4D4,0,0x4D6,0,0x4D8,0,0x4DA,0,0x4DC,0,0x4DE,
- 0,0x4E0,0,0x4E2,0,0x4E4,0,0x4E6,0,0x4E8,0,0x4EA,0,0x4EC,0,0x4EE,
- 0,0x4F0,0,0x4F2,0,0x4F4,0,0x4F6,0,0x4F8,0,0x4FA,0,0x4FC,0,0x4FE,
- 0,0x500,0,0x502,0,0x504,0,0x506,0,0x508,0,0x50A,0,0x50C,0,0x50E,
- 0,0x510,0,0x512,0,0x514,0,0x516,0,0x518,0,0x51A,0,0x51C,0,0x51E,
- 0,0x520,0,0x522,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0x531,0x532,0x533,0x534,0x535,0x536,0x537,0x538,0x539,0x53A,0x53B,0x53C,0x53D,0x53E,0x53F,
- 0x540,0x541,0x542,0x543,0x544,0x545,0x546,0x547,0x548,0x549,0x54A,0x54B,0x54C,0x54D,0x54E,0x54F,
- 0x550,0x551,0x552,0x553,0x554,0x555,0x556,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0};
-static const guint16 simple_upper_case_mapping_lowarea_table1 [] = {
- /* ==== 1000-10D0 ==== */
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,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8,0x1FE9,0,0,0,0x1FEC,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0x1FFC,0,0,0,0,0,0,0,0,0,0,0,0};
-static const guint16 simple_upper_case_mapping_lowarea_table3 [] = {
- /* ==== 2100-21C0 ==== */
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0x2132,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0x2160,0x2161,0x2162,0x2163,0x2164,0x2165,0x2166,0x2167,0x2168,0x2169,0x216A,0x216B,0x216C,0x216D,0x216E,0x216F,
- 0,0,0,0,0x2183,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0};
-static const guint16 simple_upper_case_mapping_lowarea_table4 [] = {
- /* ==== 2480-2500 ==== */
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0x24B6,0x24B7,0x24B8,0x24B9,0x24BA,0x24BB,0x24BC,0x24BD,0x24BE,0x24BF,0x24C0,0x24C1,0x24C2,0x24C3,0x24C4,0x24C5,
- 0x24C6,0x24C7,0x24C8,0x24C9,0x24CA,0x24CB,0x24CC,0x24CD,0x24CE,0x24CF,0,0,0,0,0,0,
- 0,0,0,0,0,0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0x2CDE,
- 0,0x2CE0,0,0x2CE2,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0x10A0,0x10A1,0x10A2,0x10A3,0x10A4,0x10A5,0x10A6,0x10A7,0x10A8,0x10A9,0x10AA,0x10AB,0x10AC,0x10AD,0x10AE,0x10AF,
- 0x10B0,0x10B1,0x10B2,0x10B3,0x10B4,0x10B5,0x10B6,0x10B7,0x10B8,0x10B9,0x10BA,0x10BB,0x10BC,0x10BD,0x10BE,0x10BF,
- 0x10C0,0x10C1,0x10C2,0x10C3,0x10C4,0x10C5,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0};
-static const guint16 simple_upper_case_mapping_lowarea_table6 [] = {
- /* ==== A640-A7C0 ==== */
- 0,0xA640,0,0xA642,0,0xA644,0,0xA646,0,0xA648,0,0xA64A,0,0xA64C,0,0xA64E,
- 0,0xA650,0,0xA652,0,0xA654,0,0xA656,0,0xA658,0,0xA65A,0,0xA65C,0,0xA65E,
- 0,0,0,0xA662,0,0xA664,0,0xA666,0,0xA668,0,0xA66A,0,0xA66C,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0xA680,0,0xA682,0,0xA684,0,0xA686,0,0xA688,0,0xA68A,0,0xA68C,0,0xA68E,
- 0,0xA690,0,0xA692,0,0xA694,0,0xA696,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0xA722,0,0xA724,0,0xA726,0,0xA728,0,0xA72A,0,0xA72C,0,0xA72E,
- 0,0,0,0xA732,0,0xA734,0,0xA736,0,0xA738,0,0xA73A,0,0xA73C,0,0xA73E,
- 0,0xA740,0,0xA742,0,0xA744,0,0xA746,0,0xA748,0,0xA74A,0,0xA74C,0,0xA74E,
- 0,0xA750,0,0xA752,0,0xA754,0,0xA756,0,0xA758,0,0xA75A,0,0xA75C,0,0xA75E,
- 0,0xA760,0,0xA762,0,0xA764,0,0xA766,0,0xA768,0,0xA76A,0,0xA76C,0,0xA76E,
- 0,0,0,0,0,0,0,0,0,0,0xA779,0,0xA77B,0,0,0xA77E,
- 0,0xA780,0,0xA782,0,0xA784,0,0xA786,0,0,0,0,0xA78B,0};
-static const guint16 simple_upper_case_mapping_lowarea_table7 [] = {
- /* ==== FF20-FF80 ==== */
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0xFF21,0xFF22,0xFF23,0xFF24,0xFF25,0xFF26,0xFF27,0xFF28,0xFF29,0xFF2A,0xFF2B,0xFF2C,0xFF2D,0xFF2E,0xFF2F,
- 0xFF30,0xFF31,0xFF32,0xFF33,0xFF34,0xFF35,0xFF36,0xFF37,0xFF38,0xFF39,0xFF3A,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0};
-static const guint16 *simple_upper_case_mapping_lowarea [] = {
- simple_upper_case_mapping_lowarea_table0,
- simple_upper_case_mapping_lowarea_table1,
- simple_upper_case_mapping_lowarea_table2,
- simple_upper_case_mapping_lowarea_table3,
- simple_upper_case_mapping_lowarea_table4,
- simple_upper_case_mapping_lowarea_table5,
- simple_upper_case_mapping_lowarea_table6,
- simple_upper_case_mapping_lowarea_table7};
-static const int simple_upper_case_mapping_lowarea_table_count = 8;
-
-static const guint32 simple_upper_case_mapping_higharea_table0 [] = {
- /* ==== 10400-10480 ==== */
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0x10400,0x10401,0x10402,0x10403,0x10404,0x10405,0x10406,0x10407,
- 0x10408,0x10409,0x1040A,0x1040B,0x1040C,0x1040D,0x1040E,0x1040F,0x10410,0x10411,0x10412,0x10413,0x10414,0x10415,0x10416,0x10417,
- 0x10418,0x10419,0x1041A,0x1041B,0x1041C,0x1041D,0x1041E,0x1041F,0x10420,0x10421,0x10422,0x10423,0x10424,0x10425,0x10426,0x10427,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0};
-static const guint32 *simple_upper_case_mapping_higharea [] = {
- simple_upper_case_mapping_higharea_table0};
-
-static const guint16 simple_lower_case_mapping_lowarea_table0 [] = {
- /* ==== 40-600 ==== */
- 0,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6A,0x6B,0x6C,0x6D,0x6E,0x6F,
- 0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7A,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,
- 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0x101,0,0x103,0,0x105,0,0x107,0,0x109,0,0x10B,0,0x10D,0,0x10F,0,
- 0x111,0,0x113,0,0x115,0,0x117,0,0x119,0,0x11B,0,0x11D,0,0x11F,0,
- 0x121,0,0x123,0,0x125,0,0x127,0,0x129,0,0x12B,0,0x12D,0,0x12F,0,
- 0x69,0,0x133,0,0x135,0,0x137,0,0,0x13A,0,0x13C,0,0x13E,0,0x140,
- 0,0x142,0,0x144,0,0x146,0,0x148,0,0,0x14B,0,0x14D,0,0x14F,0,
- 0x151,0,0x153,0,0x155,0,0x157,0,0x159,0,0x15B,0,0x15D,0,0x15F,0,
- 0x161,0,0x163,0,0x165,0,0x167,0,0x169,0,0x16B,0,0x16D,0,0x16F,0,
- 0x171,0,0x173,0,0x175,0,0x177,0,0xFF,0x17A,0,0x17C,0,0x17E,0,0,
- 0,0x253,0x183,0,0x185,0,0x254,0x188,0,0x256,0x257,0x18C,0,0,0x1DD,0x259,
- 0x25B,0x192,0,0x260,0x263,0,0x269,0x268,0x199,0,0,0,0x26F,0x272,0,0x275,
- 0x1A1,0,0x1A3,0,0x1A5,0,0x280,0x1A8,0,0x283,0,0,0x1AD,0,0x288,0x1B0,
- 0,0x28A,0x28B,0x1B4,0,0x1B6,0,0x292,0x1B9,0,0,0,0x1BD,0,0,0,
- 0,0,0,0,0x1C6,0x1C6,0,0x1C9,0x1C9,0,0x1CC,0x1CC,0,0x1CE,0,0x1D0,
- 0,0x1D2,0,0x1D4,0,0x1D6,0,0x1D8,0,0x1DA,0,0x1DC,0,0,0x1DF,0,
- 0x1E1,0,0x1E3,0,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x371,0,0x373,0,0,0,0x377,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0x3AC,0,0x3AD,0x3AE,0x3AF,0,0x3CC,0,0x3CD,0x3CE,
- 0,0x3B1,0x3B2,0x3B3,0x3B4,0x3B5,0x3B6,0x3B7,0x3B8,0x3B9,0x3BA,0x3BB,0x3BC,0x3BD,0x3BE,0x3BF,
- 0x3C0,0x3C1,0,0x3C3,0x3C4,0x3C5,0x3C6,0x3C7,0x3C8,0x3C9,0x3CA,0x3CB,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0x3D7,
- 0,0,0,0,0,0,0,0,0x3D9,0,0x3DB,0,0x3DD,0,0x3DF,0,
- 0x3E1,0,0x3E3,0,0x3E5,0,0x3E7,0,0x3E9,0,0x3EB,0,0x3ED,0,0x3EF,0,
- 0,0,0,0,0x3B8,0,0,0x3F8,0,0x3F2,0x3FB,0,0,0x37B,0x37C,0x37D,
- 0x450,0x451,0x452,0x453,0x454,0x455,0x456,0x457,0x458,0x459,0x45A,0x45B,0x45C,0x45D,0x45E,0x45F,
- 0x430,0x431,0x432,0x433,0x434,0x435,0x436,0x437,0x438,0x439,0x43A,0x43B,0x43C,0x43D,0x43E,0x43F,
- 0x440,0x441,0x442,0x443,0x444,0x445,0x446,0x447,0x448,0x449,0x44A,0x44B,0x44C,0x44D,0x44E,0x44F,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0x461,0,0x463,0,0x465,0,0x467,0,0x469,0,0x46B,0,0x46D,0,0x46F,0,
- 0x471,0,0x473,0,0x475,0,0x477,0,0x479,0,0x47B,0,0x47D,0,0x47F,0,
- 0x481,0,0,0,0,0,0,0,0,0,0x48B,0,0x48D,0,0x48F,0,
- 0x491,0,0x493,0,0x495,0,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0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0};
-static const guint16 simple_lower_case_mapping_lowarea_table1 [] = {
- /* ==== 1000-10D0 ==== */
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0x2D00,0x2D01,0x2D02,0x2D03,0x2D04,0x2D05,0x2D06,0x2D07,0x2D08,0x2D09,0x2D0A,0x2D0B,0x2D0C,0x2D0D,0x2D0E,0x2D0F,
- 0x2D10,0x2D11,0x2D12,0x2D13,0x2D14,0x2D15,0x2D16,0x2D17,0x2D18,0x2D19,0x2D1A,0x2D1B,0x2D1C,0x2D1D,0x2D1E,0x2D1F,
- 0x2D20,0x2D21,0x2D22,0x2D23,0x2D24,0x2D25,0};
-static const guint16 simple_lower_case_mapping_lowarea_table2 [] = {
- /* ==== 1D00-2000 ==== */
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0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- 0,0,0,0,0,0,0,0,0x1FA0,0x1FA1,0x1FA2,0x1FA3,0x1FA4,0x1FA5,0x1FA6,0x1FA7,
- 0,0,0,0,0,0,0,0,0x1FB0,0x1FB1,0x1F70,0x1F71,0x1FB3,0,0,0,
- 0,0,0,0,0,0,0,0,0x1F72,0x1F73,0x1F74,0x1F75,0x1FC3,0,0,0,
- 0,0,0,0,0,0,0,0,0x1FD0,0x1FD1,0x1F76,0x1F77,0,0,0,0,
- 0,0,0,0,0,0,0,0,0x1FE0,0x1FE1,0x1F7A,0x1F7B,0x1FE5,0,0,0,
- 0,0,0,0,0,0,0,0,0x1F78,0x1F79,0x1F7C,0x1F7D,0x1FF3,0,0,0};
-static const guint16 simple_lower_case_mapping_lowarea_table3 [] = {
- /* ==== 2100-21C0 ==== */
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0x3C9,0,0,0,0x6B,0xE5,0,0,0,0,
- 0,0,0x214E,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0x2170,0x2171,0x2172,0x2173,0x2174,0x2175,0x2176,0x2177,0x2178,0x2179,0x217A,0x217B,0x217C,0x217D,0x217E,0x217F,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0x2184,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0};
-static const guint16 simple_lower_case_mapping_lowarea_table4 [] = {
- /* ==== 2480-2500 ==== */
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0x24D0,0x24D1,0x24D2,0x24D3,0x24D4,0x24D5,0x24D6,0x24D7,0x24D8,0x24D9,
- 0x24DA,0x24DB,0x24DC,0x24DD,0x24DE,0x24DF,0x24E0,0x24E1,0x24E2,0x24E3,0x24E4,0x24E5,0x24E6,0x24E7,0x24E8,0x24E9,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0};
-static const guint16 simple_lower_case_mapping_lowarea_table5 [] = {
- /* ==== 2C00-2D80 ==== */
- 0x2C30,0x2C31,0x2C32,0x2C33,0x2C34,0x2C35,0x2C36,0x2C37,0x2C38,0x2C39,0x2C3A,0x2C3B,0x2C3C,0x2C3D,0x2C3E,0x2C3F,
- 0x2C40,0x2C41,0x2C42,0x2C43,0x2C44,0x2C45,0x2C46,0x2C47,0x2C48,0x2C49,0x2C4A,0x2C4B,0x2C4C,0x2C4D,0x2C4E,0x2C4F,
- 0x2C50,0x2C51,0x2C52,0x2C53,0x2C54,0x2C55,0x2C56,0x2C57,0x2C58,0x2C59,0x2C5A,0x2C5B,0x2C5C,0x2C5D,0x2C5E,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0x2C61,0,0x26B,0x1D7D,0x27D,0,0,0x2C68,0,0x2C6A,0,0x2C6C,0,0x251,0x271,0x250,
- 0,0,0x2C73,0,0,0x2C76,0,0,0,0,0,0,0,0,0,0,
-0x2C81,0,0x2C83,0,0x2C85,0,0x2C87,0,0x2C89,0,0x2C8B,0,0x2C8D,0,0x2C8F,0,
- 0x2C91,0,0x2C93,0,0x2C95,0,0x2C97,0,0x2C99,0,0x2C9B,0,0x2C9D,0,0x2C9F,0,
- 0x2CA1,0,0x2CA3,0,0x2CA5,0,0x2CA7,0,0x2CA9,0,0x2CAB,0,0x2CAD,0,0x2CAF,0,
- 0x2CB1,0,0x2CB3,0,0x2CB5,0,0x2CB7,0,0x2CB9,0,0x2CBB,0,0x2CBD,0,0x2CBF,0,
- 0x2CC1,0,0x2CC3,0,0x2CC5,0,0x2CC7,0,0x2CC9,0,0x2CCB,0,0x2CCD,0,0x2CCF,0,
- 0x2CD1,0,0x2CD3,0,0x2CD5,0,0x2CD7,0,0x2CD9,0,0x2CDB,0,0x2CDD,0,0x2CDF,0,
- 0x2CE1,0,0x2CE3,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0};
-static const guint16 simple_lower_case_mapping_lowarea_table6 [] = {
- /* ==== A640-A7C0 ==== */
- 0xA641,0,0xA643,0,0xA645,0,0xA647,0,0xA649,0,0xA64B,0,0xA64D,0,0xA64F,0,
- 0xA651,0,0xA653,0,0xA655,0,0xA657,0,0xA659,0,0xA65B,0,0xA65D,0,0xA65F,0,
- 0,0,0xA663,0,0xA665,0,0xA667,0,0xA669,0,0xA66B,0,0xA66D,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0xA681,0,0xA683,0,0xA685,0,0xA687,0,0xA689,0,0xA68B,0,0xA68D,0,0xA68F,0,
- 0xA691,0,0xA693,0,0xA695,0,0xA697,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0xA723,0,0xA725,0,0xA727,0,0xA729,0,0xA72B,0,0xA72D,0,0xA72F,0,
- 0,0,0xA733,0,0xA735,0,0xA737,0,0xA739,0,0xA73B,0,0xA73D,0,0xA73F,0,
- 0xA741,0,0xA743,0,0xA745,0,0xA747,0,0xA749,0,0xA74B,0,0xA74D,0,0xA74F,0,
- 0xA751,0,0xA753,0,0xA755,0,0xA757,0,0xA759,0,0xA75B,0,0xA75D,0,0xA75F,0,
- 0xA761,0,0xA763,0,0xA765,0,0xA767,0,0xA769,0,0xA76B,0,0xA76D,0,0xA76F,0,
- 0,0,0,0,0,0,0,0,0,0xA77A,0,0xA77C,0,0x1D79,0xA77F,0,
- 0xA781,0,0xA783,0,0xA785,0,0xA787,0,0,0,0,0xA78C,0,0};
-static const guint16 simple_lower_case_mapping_lowarea_table7 [] = {
- /* ==== FF20-FF80 ==== */
- 0,0xFF41,0xFF42,0xFF43,0xFF44,0xFF45,0xFF46,0xFF47,0xFF48,0xFF49,0xFF4A,0xFF4B,0xFF4C,0xFF4D,0xFF4E,0xFF4F,
- 0xFF50,0xFF51,0xFF52,0xFF53,0xFF54,0xFF55,0xFF56,0xFF57,0xFF58,0xFF59,0xFF5A,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0};
-static const guint16 *simple_lower_case_mapping_lowarea [] = {
- simple_lower_case_mapping_lowarea_table0,
- simple_lower_case_mapping_lowarea_table1,
- simple_lower_case_mapping_lowarea_table2,
- simple_lower_case_mapping_lowarea_table3,
- simple_lower_case_mapping_lowarea_table4,
- simple_lower_case_mapping_lowarea_table5,
- simple_lower_case_mapping_lowarea_table6,
- simple_lower_case_mapping_lowarea_table7};
-static const int simple_lower_case_mapping_lowarea_table_count = 8;
-
-static const guint32 simple_lower_case_mapping_higharea_table0 [] = {
- /* ==== 10400-10480 ==== */
- 0x10428,0x10429,0x1042A,0x1042B,0x1042C,0x1042D,0x1042E,0x1042F,0x10430,0x10431,0x10432,0x10433,0x10434,0x10435,0x10436,0x10437,
- 0x10438,0x10439,0x1043A,0x1043B,0x1043C,0x1043D,0x1043E,0x1043F,0x10440,0x10441,0x10442,0x10443,0x10444,0x10445,0x10446,0x10447,
- 0x10448,0x10449,0x1044A,0x1044B,0x1044C,0x1044D,0x1044E,0x1044F,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0};
-static const guint32 *simple_lower_case_mapping_higharea [] = {
- simple_lower_case_mapping_higharea_table0};
-
-
-static const SimpleTitlecaseMapping simple_titlecase_mapping [] = {
- {0x0001C4, 0x000000, 0x0001C5},
- {0x0001C5, 0x0001C4, 0x0001C5},
- {0x0001C6, 0x0001C4, 0x0001C5},
- {0x0001C7, 0x000000, 0x0001C8},
- {0x0001C8, 0x0001C7, 0x0001C8},
- {0x0001C9, 0x0001C7, 0x0001C8},
- {0x0001CA, 0x000000, 0x0001CB},
- {0x0001CB, 0x0001CA, 0x0001CB},
- {0x0001CC, 0x0001CA, 0x0001CB},
- {0x0001F1, 0x000000, 0x0001F2},
- {0x0001F2, 0x0001F1, 0x0001F2},
- {0x0001F3, 0x0001F1, 0x0001F2}
-};
-static const guint8 simple_titlecase_mapping_count = 12;
-
-#endif
-
+++ /dev/null
-/Makefile
-/Makefile.in
-/.libs
-/.deps
-/*.lo
-/*.la
-/*.o
-/semantic.cache
-/.project
-/.cproject
-/test-eglib
-/test-glib
+++ /dev/null
-EXTRA_DIST = UTF-8.txt UTF-16BE.txt UTF-16LE.txt UTF-32BE.txt UTF-32LE.txt
-
-SOURCES = \
- test.c \
- test.h \
- tests.h \
- driver.c \
- hashtable.c \
- string-util.c \
- string.c \
- slist.c \
- sizes.c \
- ptrarray.c \
- list.c \
- array.c \
- fake.c \
- path.c \
- queue.c \
- shell.c \
- spawn.c \
- timer.c \
- file.c \
- pattern.c \
- dir.c \
- markup.c \
- unicode.c \
- utf8.c \
- endian.c \
- module.c \
- memory.c
-
-test_eglib_SOURCES = $(SOURCES)
-
-test_eglib_CFLAGS = -Wall -DEGLIB_TESTS=1 -D_FORTIFY_SOURCE=2 -I$(srcdir)/../src -I../src -DDRIVER_NAME=\"EGlib\"
-test_eglib_LDADD = ../src/libeglib.la $(LIBICONV)
-
-run-eglib: all
- srcdir=`readlink -f $(srcdir)` ./test-eglib
-
-noinst_PROGRAMS = test-eglib
-
-run-both: run-eglib
-
-MAINTAINERCLEANFILES = Makefile.in
+++ /dev/null
-EGlib Unit Testing
-===============================================================================
-
- 1. Writing new tests
- 2. Using the test driver
-
-===============================================================================
-1. Writing new tests
-===============================================================================
-
-Tests are easy to write, but must be grouped in to logical cases. For instance,
-the GPtrArray group has a number of tests that cover the entire GPtrArray
-implementation.
-
-These logical case groups should be in a single C file, and must have
-three elements:
-
- #include <glib.h>
- #include "test.h"
-
- ...
- <define test implementations>
- ...
-
- static Test groupname_tests [] = {
- {"groupname_test1", groupname_test1},
- {"groupname_test1", groupname_test2},
- {NULL, NULL}
- };
-
- DEFINE_TEST_GROUP_INIT(groupname_tests_init, groupname_tests)
-
-A test implementation should look like:
-
- RESULT groupname_test1()
- {
- <perform the test>
-
- if(test_failed) {
- return FAILED("reason: %s", "this works like printf");
- }
-
- return OK; /* just NULL, but OK is cute */
- }
-
-Once a test group is written, it needs to be added to the groups table
-in tests.h:
-
- DEFINE_TEST_GROUP_INIT_H(groupname_tests_init) // same as in impl
-
- static Group test_groups [] = {
- ...
- {"groupname", groupname_tests_init}
- ...
- };
-
-===============================================================================
-2. Using the test driver
-===============================================================================
-
-When tests are written, they are rebuilt with make. Two programs will be
-built:
-
- test-eglib: the test driver and tests linked against eglib
- test-glib: the test driver and tests linked against system glib-2.0
-
-Each driver program works exactly the same. Running test-eglib will run
-the tests against eglib, and test-glib against glib-2.0.
-
-The test driver supports a few options to allow for performance measuring:
-
- --help show all options and available test groups
- --time time the overall run and report it, even if --quiet is set
- --quiet do not print test results, useful for timing
- --iterations N run all or specified test groups N times
-
-Run "test-eglib --help" for more details.
-
-Example: run the ptrarray test group 100000 times and only print the time
- it took to perform all iterations
-
- ./test-eglib -tqi 100000 ptrarray
-
-Example: show single iteration of test output for two groups
-
- ./test-eglib ptrarray hashtable
-
-Example: show test output of all available groups
-
- ./test-eglib
-
-The 'test-both' script can be used to run both test-eglib and test-glib
-with the same options back to back:
-
- $ ./test-both -tqi 100000 ptrarray
- EGlib Total Time: 1.1961s
- GLib Total Time: 0.955957s
-
-test-both also has a nice --speed-compare mode that shows comparison
-information about EGlib vs GLib. It can run all tests or specific tests
-with a configurable number of iterations. --speed-compare mode always runs
-the drivers with -qtni
-
-The syntax for --speed-compare is:
-
- ./test-both --speed-compare [ITERATIONS] [GROUPS...]
-
- $ ./test-both --speed-compare Runs all tests with default iterations
- $ ./test-both --speed-compare 500 Runs all tests with 500 iterations
- $ ./test-both --speed-compare ptrarray Runs ptrarray test with default
- iterations
-
-
+++ /dev/null
-
-UTF-8 encoded sample plain-text file
-‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
-
-Markus Kuhn [ˈmaʳkʊs kuːn] <http://www.cl.cam.ac.uk/~mgk25/> — 2002-07-25
-
-
-The ASCII compatible UTF-8 encoding used in this plain-text file
-is defined in Unicode, ISO 10646-1, and RFC 2279.
-
-
-Using Unicode/UTF-8, you can write in emails and source code things such as
-
-Mathematics and sciences:
-
- ∮ E⋅da = Q, n → ∞, ∑ f(i) = ∏ g(i), ⎧⎡⎛┌─────┐⎞⎤⎫
- ⎪⎢⎜│a²+b³ ⎟⎥⎪
- ∀x∈ℝ: ⌈x⌉ = −⌊−x⌋, α ∧ ¬β = ¬(¬α ∨ β), ⎪⎢⎜│───── ⎟⎥⎪
- ⎪⎢⎜⎷ c₈ ⎟⎥⎪
- ℕ ⊆ ℕ₀ ⊂ ℤ ⊂ ℚ ⊂ ℝ ⊂ ℂ, ⎨⎢⎜ ⎟⎥⎬
- ⎪⎢⎜ ∞ ⎟⎥⎪
- ⊥ < a ≠ b ≡ c ≤ d ≪ ⊤ ⇒ (⟦A⟧ ⇔ ⟪B⟫), ⎪⎢⎜ ⎲ ⎟⎥⎪
- ⎪⎢⎜ ⎳aⁱ-bⁱ⎟⎥⎪
- 2H₂ + O₂ ⇌ 2H₂O, R = 4.7 kΩ, ⌀ 200 mm ⎩⎣⎝i=1 ⎠⎦⎭
-
-Linguistics and dictionaries:
-
- ði ıntəˈnæʃənəl fəˈnɛtık əsoʊsiˈeıʃn
- Y [ˈʏpsilɔn], Yen [jɛn], Yoga [ˈjoːgɑ]
-
-APL:
-
- ((V⍳V)=⍳⍴V)/V←,V ⌷←⍳→⍴∆∇⊃‾⍎⍕⌈
-
-Nicer typography in plain text files:
-
- ╔══════════════════════════════════════════╗
- ║ ║
- ║ • ‘single’ and “double” quotes ║
- ║ ║
- ║ • Curly apostrophes: “We’ve been here” ║
- ║ ║
- ║ • Latin-1 apostrophe and accents: '´` ║
- ║ ║
- ║ • ‚deutsche‘ „Anführungszeichen“ ║
- ║ ║
- ║ • †, ‡, ‰, •, 3–4, —, −5/+5, ™, … ║
- ║ ║
- ║ • ASCII safety test: 1lI|, 0OD, 8B ║
- ║ ╭─────────╮ ║
- ║ • the euro symbol: │ 14.95 € │ ║
- ║ ╰─────────╯ ║
- ╚══════════════════════════════════════════╝
-
-Combining characters:
-
- STARGΛ̊TE SG-1, a = v̇ = r̈, a⃑ ⊥ b⃑
-
-Greek (in Polytonic):
-
- The Greek anthem:
-
- Σὲ γνωρίζω ἀπὸ τὴν κόψη
- τοῦ σπαθιοῦ τὴν τρομερή,
- σὲ γνωρίζω ἀπὸ τὴν ὄψη
- ποὺ μὲ βία μετράει τὴ γῆ.
-
- ᾿Απ᾿ τὰ κόκκαλα βγαλμένη
- τῶν ῾Ελλήνων τὰ ἱερά
- καὶ σὰν πρῶτα ἀνδρειωμένη
- χαῖρε, ὦ χαῖρε, ᾿Ελευθεριά!
-
- From a speech of Demosthenes in the 4th century BC:
-
- Οὐχὶ ταὐτὰ παρίσταταί μοι γιγνώσκειν, ὦ ἄνδρες ᾿Αθηναῖοι,
- ὅταν τ᾿ εἰς τὰ πράγματα ἀποβλέψω καὶ ὅταν πρὸς τοὺς
- λόγους οὓς ἀκούω· τοὺς μὲν γὰρ λόγους περὶ τοῦ
- τιμωρήσασθαι Φίλιππον ὁρῶ γιγνομένους, τὰ δὲ πράγματ᾿
- εἰς τοῦτο προήκοντα, ὥσθ᾿ ὅπως μὴ πεισόμεθ᾿ αὐτοὶ
- πρότερον κακῶς σκέψασθαι δέον. οὐδέν οὖν ἄλλο μοι δοκοῦσιν
- οἱ τὰ τοιαῦτα λέγοντες ἢ τὴν ὑπόθεσιν, περὶ ἧς βουλεύεσθαι,
- οὐχὶ τὴν οὖσαν παριστάντες ὑμῖν ἁμαρτάνειν. ἐγὼ δέ, ὅτι μέν
- ποτ᾿ ἐξῆν τῇ πόλει καὶ τὰ αὑτῆς ἔχειν ἀσφαλῶς καὶ Φίλιππον
- τιμωρήσασθαι, καὶ μάλ᾿ ἀκριβῶς οἶδα· ἐπ᾿ ἐμοῦ γάρ, οὐ πάλαι
- γέγονεν ταῦτ᾿ ἀμφότερα· νῦν μέντοι πέπεισμαι τοῦθ᾿ ἱκανὸν
- προλαβεῖν ἡμῖν εἶναι τὴν πρώτην, ὅπως τοὺς συμμάχους
- σώσομεν. ἐὰν γὰρ τοῦτο βεβαίως ὑπάρξῃ, τότε καὶ περὶ τοῦ
- τίνα τιμωρήσεταί τις καὶ ὃν τρόπον ἐξέσται σκοπεῖν· πρὶν δὲ
- τὴν ἀρχὴν ὀρθῶς ὑποθέσθαι, μάταιον ἡγοῦμαι περὶ τῆς
- τελευτῆς ὁντινοῦν ποιεῖσθαι λόγον.
-
- Δημοσθένους, Γ´ ᾿Ολυνθιακὸς
-
-Georgian:
-
- From a Unicode conference invitation:
-
- გთხოვთ ახლავე გაიაროთ რეგისტრაცია Unicode-ის მეათე საერთაშორისო
- კონფერენციაზე დასასწრებად, რომელიც გაიმართება 10-12 მარტს,
- ქ. მაინცში, გერმანიაში. კონფერენცია შეჰკრებს ერთად მსოფლიოს
- ექსპერტებს ისეთ დარგებში როგორიცაა ინტერნეტი და Unicode-ი,
- ინტერნაციონალიზაცია და ლოკალიზაცია, Unicode-ის გამოყენება
- ოპერაციულ სისტემებსა, და გამოყენებით პროგრამებში, შრიფტებში,
- ტექსტების დამუშავებასა და მრავალენოვან კომპიუტერულ სისტემებში.
-
-Russian:
-
- From a Unicode conference invitation:
-
- Зарегистрируйтесь сейчас на Десятую Международную Конференцию по
- Unicode, которая состоится 10-12 марта 1997 года в Майнце в Германии.
- Конференция соберет широкий круг экспертов по вопросам глобального
- Интернета и Unicode, локализации и интернационализации, воплощению и
- применению Unicode в различных операционных системах и программных
- приложениях, шрифтах, верстке и многоязычных компьютерных системах.
-
-Thai (UCS Level 2):
-
- Excerpt from a poetry on The Romance of The Three Kingdoms (a Chinese
- classic 'San Gua'):
-
- [----------------------------|------------------------]
- ๏ แผ่นดินฮั่นเสื่อมโทรมแสนสังเวช พระปกเกศกองบู๊กู้ขึ้นใหม่
- สิบสองกษัตริย์ก่อนหน้าแลถัดไป สององค์ไซร้โง่เขลาเบาปัญญา
- ทรงนับถือขันทีเป็นที่พึ่ง บ้านเมืองจึงวิปริตเป็นนักหนา
- โฮจิ๋นเรียกทัพทั่วหัวเมืองมา หมายจะฆ่ามดชั่วตัวสำคัญ
- เหมือนขับไสไล่เสือจากเคหา รับหมาป่าเข้ามาเลยอาสัญ
- ฝ่ายอ้องอุ้นยุแยกให้แตกกัน ใช้สาวนั้นเป็นชนวนชื่นชวนใจ
- พลันลิฉุยกุยกีกลับก่อเหตุ ช่างอาเพศจริงหนาฟ้าร้องไห้
- ต้องรบราฆ่าฟันจนบรรลัย ฤๅหาใครค้ำชูกู้บรรลังก์ ฯ
-
- (The above is a two-column text. If combining characters are handled
- correctly, the lines of the second column should be aligned with the
- | character above.)
-
-Ethiopian:
-
- Proverbs in the Amharic language:
-
- ሰማይ አይታረስ ንጉሥ አይከሰስ።
- ብላ ካለኝ እንደአባቴ በቆመጠኝ።
- ጌጥ ያለቤቱ ቁምጥና ነው።
- ደሀ በሕልሙ ቅቤ ባይጠጣ ንጣት በገደለው።
- የአፍ ወለምታ በቅቤ አይታሽም።
- አይጥ በበላ ዳዋ ተመታ።
- ሲተረጉሙ ይደረግሙ።
- ቀስ በቀስ፥ ዕንቁላል በእግሩ ይሄዳል።
- ድር ቢያብር አንበሳ ያስር።
- ሰው እንደቤቱ እንጅ እንደ ጉረቤቱ አይተዳደርም።
- እግዜር የከፈተውን ጉሮሮ ሳይዘጋው አይድርም።
- የጎረቤት ሌባ፥ ቢያዩት ይስቅ ባያዩት ያጠልቅ።
- ሥራ ከመፍታት ልጄን ላፋታት።
- ዓባይ ማደሪያ የለው፥ ግንድ ይዞ ይዞራል።
- የእስላም አገሩ መካ የአሞራ አገሩ ዋርካ።
- ተንጋሎ ቢተፉ ተመልሶ ባፉ።
- ወዳጅህ ማር ቢሆን ጨርስህ አትላሰው።
- እግርህን በፍራሽህ ልክ ዘርጋ።
-
-Runes:
-
- ᚻᛖ ᚳᚹᚫᚦ ᚦᚫᛏ ᚻᛖ ᛒᚢᛞᛖ ᚩᚾ ᚦᚫᛗ ᛚᚪᚾᛞᛖ ᚾᚩᚱᚦᚹᛖᚪᚱᛞᚢᛗ ᚹᛁᚦ ᚦᚪ ᚹᛖᛥᚫ
-
- (Old English, which transcribed into Latin reads 'He cwaeth that he
- bude thaem lande northweardum with tha Westsae.' and means 'He said
- that he lived in the northern land near the Western Sea.')
-
-Braille:
-
- ⡌⠁⠧⠑ ⠼⠁⠒ ⡍⠜⠇⠑⠹⠰⠎ ⡣⠕⠌
-
- ⡍⠜⠇⠑⠹ ⠺⠁⠎ ⠙⠑⠁⠙⠒ ⠞⠕ ⠃⠑⠛⠔ ⠺⠊⠹⠲ ⡹⠻⠑ ⠊⠎ ⠝⠕ ⠙⠳⠃⠞
- ⠱⠁⠞⠑⠧⠻ ⠁⠃⠳⠞ ⠹⠁⠞⠲ ⡹⠑ ⠗⠑⠛⠊⠌⠻ ⠕⠋ ⠙⠊⠎ ⠃⠥⠗⠊⠁⠇ ⠺⠁⠎
- ⠎⠊⠛⠝⠫ ⠃⠹ ⠹⠑ ⠊⠇⠻⠛⠹⠍⠁⠝⠂ ⠹⠑ ⠊⠇⠻⠅⠂ ⠹⠑ ⠥⠝⠙⠻⠞⠁⠅⠻⠂
- ⠁⠝⠙ ⠹⠑ ⠡⠊⠑⠋ ⠍⠳⠗⠝⠻⠲ ⡎⠊⠗⠕⠕⠛⠑ ⠎⠊⠛⠝⠫ ⠊⠞⠲ ⡁⠝⠙
- ⡎⠊⠗⠕⠕⠛⠑⠰⠎ ⠝⠁⠍⠑ ⠺⠁⠎ ⠛⠕⠕⠙ ⠥⠏⠕⠝ ⠰⡡⠁⠝⠛⠑⠂ ⠋⠕⠗ ⠁⠝⠹⠹⠔⠛ ⠙⠑
- ⠡⠕⠎⠑ ⠞⠕ ⠏⠥⠞ ⠙⠊⠎ ⠙⠁⠝⠙ ⠞⠕⠲
-
- ⡕⠇⠙ ⡍⠜⠇⠑⠹ ⠺⠁⠎ ⠁⠎ ⠙⠑⠁⠙ ⠁⠎ ⠁ ⠙⠕⠕⠗⠤⠝⠁⠊⠇⠲
-
- ⡍⠔⠙⠖ ⡊ ⠙⠕⠝⠰⠞ ⠍⠑⠁⠝ ⠞⠕ ⠎⠁⠹ ⠹⠁⠞ ⡊ ⠅⠝⠪⠂ ⠕⠋ ⠍⠹
- ⠪⠝ ⠅⠝⠪⠇⠫⠛⠑⠂ ⠱⠁⠞ ⠹⠻⠑ ⠊⠎ ⠏⠜⠞⠊⠊⠥⠇⠜⠇⠹ ⠙⠑⠁⠙ ⠁⠃⠳⠞
- ⠁ ⠙⠕⠕⠗⠤⠝⠁⠊⠇⠲ ⡊ ⠍⠊⠣⠞ ⠙⠁⠧⠑ ⠃⠑⠲ ⠔⠊⠇⠔⠫⠂ ⠍⠹⠎⠑⠇⠋⠂ ⠞⠕
- ⠗⠑⠛⠜⠙ ⠁ ⠊⠕⠋⠋⠔⠤⠝⠁⠊⠇ ⠁⠎ ⠹⠑ ⠙⠑⠁⠙⠑⠌ ⠏⠊⠑⠊⠑ ⠕⠋ ⠊⠗⠕⠝⠍⠕⠝⠛⠻⠹
- ⠔ ⠹⠑ ⠞⠗⠁⠙⠑⠲ ⡃⠥⠞ ⠹⠑ ⠺⠊⠎⠙⠕⠍ ⠕⠋ ⠳⠗ ⠁⠝⠊⠑⠌⠕⠗⠎
- ⠊⠎ ⠔ ⠹⠑ ⠎⠊⠍⠊⠇⠑⠆ ⠁⠝⠙ ⠍⠹ ⠥⠝⠙⠁⠇⠇⠪⠫ ⠙⠁⠝⠙⠎
- ⠩⠁⠇⠇ ⠝⠕⠞ ⠙⠊⠌⠥⠗⠃ ⠊⠞⠂ ⠕⠗ ⠹⠑ ⡊⠳⠝⠞⠗⠹⠰⠎ ⠙⠕⠝⠑ ⠋⠕⠗⠲ ⡹⠳
- ⠺⠊⠇⠇ ⠹⠻⠑⠋⠕⠗⠑ ⠏⠻⠍⠊⠞ ⠍⠑ ⠞⠕ ⠗⠑⠏⠑⠁⠞⠂ ⠑⠍⠏⠙⠁⠞⠊⠊⠁⠇⠇⠹⠂ ⠹⠁⠞
- ⡍⠜⠇⠑⠹ ⠺⠁⠎ ⠁⠎ ⠙⠑⠁⠙ ⠁⠎ ⠁ ⠙⠕⠕⠗⠤⠝⠁⠊⠇⠲
-
- (The first couple of paragraphs of "A Christmas Carol" by Dickens)
-
-Compact font selection example text:
-
- ABCDEFGHIJKLMNOPQRSTUVWXYZ /0123456789
- abcdefghijklmnopqrstuvwxyz £©µÀÆÖÞßéöÿ
- –—‘“”„†•…‰™œŠŸž€ ΑΒΓΔΩαβγδω АБВГДабвгд
- ∀∂∈ℝ∧∪≡∞ ↑↗↨↻⇣ ┐┼╔╘░►☺♀ fi�⑀₂ἠḂӥẄɐː⍎אԱა
-
-Greetings in various languages:
-
- Hello world, Καλημέρα κόσμε, コンニチハ
-
-Box drawing alignment tests: █
- ▉
- ╔══╦══╗ ┌──┬──┐ ╭──┬──╮ ╭──┬──╮ ┏━━┳━━┓ ┎┒┏┑ ╷ ╻ ┏┯┓ ┌┰┐ ▊ ╱╲╱╲╳╳╳
- ║┌─╨─┐║ │╔═╧═╗│ │╒═╪═╕│ │╓─╁─╖│ ┃┌─╂─┐┃ ┗╃╄┙ ╶┼╴╺╋╸┠┼┨ ┝╋┥ ▋ ╲╱╲╱╳╳╳
- ║│╲ ╱│║ │║ ║│ ││ │ ││ │║ ┃ ║│ ┃│ ╿ │┃ ┍╅╆┓ ╵ ╹ ┗┷┛ └┸┘ ▌ ╱╲╱╲╳╳╳
- ╠╡ ╳ ╞╣ ├╢ ╟┤ ├┼─┼─┼┤ ├╫─╂─╫┤ ┣┿╾┼╼┿┫ ┕┛┖┚ ┌┄┄┐ ╎ ┏┅┅┓ ┋ ▍ ╲╱╲╱╳╳╳
- ║│╱ ╲│║ │║ ║│ ││ │ ││ │║ ┃ ║│ ┃│ ╽ │┃ ░░▒▒▓▓██ ┊ ┆ ╎ ╏ ┇ ┋ ▎
- ║└─╥─┘║ │╚═╤═╝│ │╘═╪═╛│ │╙─╀─╜│ ┃└─╂─┘┃ ░░▒▒▓▓██ ┊ ┆ ╎ ╏ ┇ ┋ ▏
- ╚══╩══╝ └──┴──┘ ╰──┴──╯ ╰──┴──╯ ┗━━┻━━┛ ▗▄▖▛▀▜ └╌╌┘ ╎ ┗╍╍┛ ┋ ▁▂▃▄▅▆▇█
- ▝▀▘▙▄▟
+++ /dev/null
-#include <stdio.h>
-#include <string.h>
-#include <glib.h>
-#include "test.h"
-
-/* example from glib documentation */
-RESULT
-test_array_big ()
-{
- GArray *garray;
- gint i;
-
- /* We create a new array to store gint values.
- We don't want it zero-terminated or cleared to 0's. */
- garray = g_array_new (FALSE, FALSE, sizeof (gint));
- for (i = 0; i < 10000; i++)
- g_array_append_val (garray, i);
-
- for (i = 0; i < 10000; i++)
- if (g_array_index (garray, gint, i) != i)
- return FAILED ("array value didn't match");
-
- g_array_free (garray, TRUE);
-
- return NULL;
-}
-
-RESULT
-test_array_index ()
-{
- GArray *array = g_array_new (FALSE, FALSE, sizeof (int));
- int v;
-
- v = 27;
- g_array_append_val (array, v);
-
- if (27 != g_array_index (array, int, 0))
- return FAILED ("");
-
- g_array_free (array, TRUE);
-
- return NULL;
-}
-
-RESULT
-test_array_append_zero_terminated ()
-{
- GArray *array = g_array_new (TRUE, FALSE, sizeof (int));
- int v;
-
- v = 27;
- g_array_append_val (array, v);
-
- if (27 != g_array_index (array, int, 0))
- return FAILED ("g_array_append_val failed");
-
- if (0 != g_array_index (array, int, 1))
- return FAILED ("zero_terminated didn't append a zero element");
-
- g_array_free (array, TRUE);
-
- return NULL;
-}
-
-RESULT
-test_array_append ()
-{
- GArray *array = g_array_new (FALSE, FALSE, sizeof (int));
- int v;
-
- if (0 != array->len)
- return FAILED ("initial array length not zero");
-
- v = 27;
-
- g_array_append_val (array, v);
-
- if (1 != array->len)
- return FAILED ("array append failed");
-
- g_array_free (array, TRUE);
-
- return NULL;
-}
-
-RESULT
-test_array_insert_val ()
-{
- GArray *array = g_array_new (FALSE, FALSE, sizeof (gpointer));
- gpointer ptr0, ptr1, ptr2, ptr3;
-
- g_array_insert_val (array, 0, array);
-
- if (array != g_array_index (array, gpointer, 0))
- return FAILED ("1 The value in the array is incorrect");
-
- g_array_insert_val (array, 1, array);
- if (array != g_array_index (array, gpointer, 1))
- return FAILED ("2 The value in the array is incorrect");
-
- g_array_insert_val (array, 2, array);
- if (array != g_array_index (array, gpointer, 2))
- return FAILED ("3 The value in the array is incorrect");
-
- g_array_free (array, TRUE);
- array = g_array_new (FALSE, FALSE, sizeof (gpointer));
- ptr0 = array;
- ptr1 = array + 1;
- ptr2 = array + 2;
- ptr3 = array + 3;
-
- g_array_insert_val (array, 0, ptr0);
- g_array_insert_val (array, 1, ptr1);
- g_array_insert_val (array, 2, ptr2);
- g_array_insert_val (array, 1, ptr3);
- if (ptr0 != g_array_index (array, gpointer, 0))
- return FAILED ("4 The value in the array is incorrect");
- if (ptr3 != g_array_index (array, gpointer, 1))
- return FAILED ("5 The value in the array is incorrect");
- if (ptr1 != g_array_index (array, gpointer, 2))
- return FAILED ("6 The value in the array is incorrect");
- if (ptr2 != g_array_index (array, gpointer, 3))
- return FAILED ("7 The value in the array is incorrect");
-
- g_array_free (array, TRUE);
- return NULL;
-}
-
-RESULT
-test_array_remove ()
-{
- GArray *array = g_array_new (FALSE, FALSE, sizeof (int));
- int v[] = {30, 29, 28, 27, 26, 25};
-
- g_array_append_vals (array, v, 6);
-
- if (6 != array->len)
- return FAILED ("append_vals fail");
-
- g_array_remove_index (array, 3);
-
- if (5 != array->len)
- return FAILED ("remove_index failed to update length");
-
- if (26 != g_array_index (array, int, 3))
- return FAILED ("remove_index failed to update the array");
-
- g_array_free (array, TRUE);
-
- return NULL;
-}
-
-static Test array_tests [] = {
- {"big", test_array_big},
- {"append", test_array_append},
- {"insert_val", test_array_insert_val},
- {"index", test_array_index},
- {"remove", test_array_remove},
- {"append_zero_term", test_array_append_zero_terminated},
- {NULL, NULL}
-};
-
-DEFINE_TEST_GROUP_INIT(array_tests_init, array_tests)
+++ /dev/null
-#include <config.h>
-#include <glib.h>
-#include <string.h>
-#include <stdio.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#ifdef G_OS_UNIX
-#include <pthread.h>
-#endif
-#include "test.h"
-
-/* This test is just to be used with valgrind */
-RESULT
-test_dir ()
-{
- GDir *dir;
- GError *error;
- const gchar *name;
-
- /*
- dir = g_dir_open (NULL, 0, NULL);
- */
- dir = g_dir_open ("", 0, NULL);
- if (dir != NULL)
- return FAILED ("1 Should be an error");
-
- dir = g_dir_open ("", 9, NULL);
- if (dir != NULL)
- return FAILED ("2 Should be an error");
-
- error = NULL;
- dir = g_dir_open (".ljasdslakjd", 9, &error);
- if (dir != NULL)
- return FAILED ("3 opendir should fail");
- if (error == NULL)
- return FAILED ("4 got no error");
- g_error_free (error);
- error = NULL;
- dir = g_dir_open (g_get_tmp_dir (), 9, &error);
- if (dir == NULL)
- return FAILED ("5 opendir should succeed");
- if (error != NULL)
- return FAILED ("6 got an error");
- name = NULL;
- name = g_dir_read_name (dir);
- if (name == NULL)
- return FAILED ("7 didn't read a file name");
- while ((name = g_dir_read_name (dir)) != NULL) {
- if (strcmp (name, ".") == 0)
- return FAILED (". directory found");
- if (strcmp (name, "..") == 0)
- return FAILED (".. directory found");
- }
- g_dir_close (dir);
- return OK;
-}
-
-static Test dir_tests [] = {
- {"g_dir_*", test_dir},
- {NULL, NULL}
-};
-
-DEFINE_TEST_GROUP_INIT(dir_tests_init, dir_tests)
-
-
+++ /dev/null
-/*
- * EGLib Unit Test Driver
- *
- * Author:
- * Aaron Bockover (abockover@novell.com)
- *
- * (C) 2006 Novell, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-#include <config.h>
-#include "test.h"
-
-#ifndef DRIVER_EXTERNAL_TESTS
-#include "tests.h"
-#endif
-
-#include <stdio.h>
-#ifdef HAVE_GETOPT_H
-#include <getopt.h>
-#endif
-
-#if defined(HAVE_UNISTD_H)
-#include <unistd.h>
-#endif
-
-#ifndef DRIVER_NAME
-#define DRIVER_NAME "EGlib"
-#endif
-
-typedef struct _StringArray {
- gchar **strings;
- gint length;
-} StringArray;
-
-static StringArray *
-string_array_append(StringArray *array, gchar *string)
-{
- if(array == NULL) {
- array = g_new0(StringArray, 1);
- array->length = 1;
- array->strings = g_malloc(sizeof(gchar *) * 2);
- } else {
- array->length++;
- array->strings = g_realloc(array->strings, sizeof(gchar *)
- * (array->length + 1));
- }
-
- array->strings[array->length - 1] = string;
- array->strings[array->length] = NULL;
-
- return array;
-}
-
-gint global_passed = 0, global_tests = 0;
-
-static void
-string_array_free(StringArray *array)
-{
- g_free(array->strings);
- g_free(array);
-}
-
-static void print_help(char *s)
-{
- gint i;
-
- printf("Usage: %s [OPTION]... [TESTGROUP]...\n\n", s);
- printf("OPTIONS are:\n");
- printf(" -h, --help show this help\n");
- printf(" -t, --time time the tests\n");
- printf(" -i, --iterations number of times to run tests\n");
- printf(" -q, --quiet do not print test results; "
- "final time always prints\n");
- printf(" -n, --no-labels print final time without labels, "
- "nice for scripts\n");
- printf(" -d, --debug do not run tests, "
- "debug the driver itself for valgrind\n\n");
- printf("TESTGROUPS available:\n");
-
- for(i = 0; test_groups[i].name != NULL; i++) {
- if(test_groups[i].handler != fake_tests_init) {
- printf(" %s\n", test_groups[i].name);
- }
- }
-
- printf("\n");
-}
-
-#ifdef DRIVER_EXTERNAL_MAIN
-gint run_tests_main(gint argc, gchar **argv)
-#else
-gint main(gint argc, gchar **argv)
-#endif
-{
- gint i, j, c, iterations = 1;
- StringArray *tests_to_run = NULL;
- gdouble time_start;
- gboolean report_time = FALSE;
- gboolean quiet = FALSE;
- gboolean global_failure = FALSE;
- gboolean no_final_time_labels = FALSE;
- gboolean debug = FALSE;
-
-#if HAVE_GETOPT_H
- static struct option long_options [] = {
- {"help", no_argument, 0, 'h'},
- {"time", no_argument, 0, 't'},
- {"quiet", no_argument, 0, 'q'},
- {"iterations", required_argument, 0, 'i'},
- {"debug", no_argument, 0, 'd'},
- {"no-labels", no_argument, 0, 'n'},
- {0, 0, 0, 0}
- };
-
- while((c = getopt_long(argc, argv, "dhtqni:", long_options, NULL)) != -1) { switch(c) {
- case 'h':
- print_help(argv[0]);
- return 1;
- case 't':
- report_time = TRUE;
- break;
- case 'i':
- iterations = atoi(optarg);
- break;
- case 'q':
- quiet = TRUE;
- break;
- case 'n':
- no_final_time_labels = TRUE;
- break;
- case 'd':
- debug = TRUE;
- break;
- }
- }
-
- for(i = optind; i < argc; i++) {
- if(argv[i][0] == '-') {
- continue;
- }
-
- tests_to_run = string_array_append(tests_to_run, argv[i]);
- }
-#endif
-
- time_start = get_timestamp();
-
- for(j = 0; test_groups[j].name != NULL; j++) {
- gboolean run = TRUE;
- gchar *tests = NULL;
- gchar *group = NULL;
-
- if(tests_to_run != NULL) {
- gint k;
- run = FALSE;
-
- for(k = 0; k < tests_to_run->length; k++) {
- gchar *user = tests_to_run->strings[k];
- const gchar *table = test_groups[j].name;
- size_t user_len = strlen(user);
- size_t table_len = strlen(table);
-
- if(strncmp(user, table, table_len) == 0) {
- if(user_len > table_len && user[table_len] != ':') {
- break;
- }
-
- run = TRUE;
- group = tests_to_run->strings[k];
- break;
- }
- }
- }
-
- if(run) {
- gboolean passed;
- gchar **split = NULL;
-
- if(debug && test_groups[j].handler != fake_tests_init) {
- printf("Skipping %s, in driver debug mode\n",
- test_groups[j].name);
- continue;
- } else if(!debug && test_groups[j].handler == fake_tests_init) {
- continue;
- }
-
- if(group != NULL) {
- split = eg_strsplit(group, ":", -1);
- if(split != NULL) {
- gint m;
- for(m = 0; split[m] != NULL; m++) {
- if(m == 1) {
- tests = strdup(split[m]);
- break;
- }
- }
- eg_strfreev(split);
- }
- }
-
- passed = run_group(&(test_groups[j]),
- iterations, quiet, report_time, tests);
-
- if(tests != NULL) {
- g_free(tests);
- }
-
- if(!passed && !global_failure) {
- global_failure = TRUE;
- }
- }
- }
-
- if(!quiet) {
- gdouble pass_percentage = ((gdouble)global_passed / (gdouble)global_tests) * 100.0;
- printf("=============================\n");
- printf("Overall result: %s : %d / %d (%g%%)\n", global_failure ? "FAILED" : "OK", global_passed, global_tests, pass_percentage);
- }
-
- if(report_time) {
- gdouble duration = get_timestamp() - time_start;
- if(no_final_time_labels) {
- printf("%g\n", duration);
- } else {
- printf("%s Total Time: %g\n", DRIVER_NAME, duration);
- }
- }
-
- if(tests_to_run != NULL) {
- string_array_free(tests_to_run);
- }
-
- return global_tests - global_passed;
-}
-
-
+++ /dev/null
-#include "test.h"
-
-RESULT
-test_swap ()
-{
- guint32 a = 0xabcdef01, res32;
- guint64 b = (((guint64)a) << 32) | a, res64;
- guint64 b_expect = (((guint64)0x1efcdab) << 32) | 0x01efcdab;
- guint16 c = 0xabcd, res16;
-
- res32 = GUINT32_SWAP_LE_BE (a);
- if (res32 != 0x01efcdab)
- return FAILED ("GUINT32_SWAP_LE_BE returned 0x%x", res32);
- res32 = GUINT32_SWAP_LE_BE (1);
- if (res32 != 0x1000000)
- return FAILED ("GUINT32_SWAP_LE_BE returned 0x%x", res32);
-
- res64 = GUINT64_SWAP_LE_BE(b);
- if (res64 != b_expect)
- return FAILED ("GUINT64_SWAP_LE_BE returned 0x%llx (had=0x%llx)", res64, b);
- res16 = GUINT16_SWAP_LE_BE(c);
- if (res16 != 0xcdab)
- return FAILED ("GUINT16_SWAP_LE_BE returned 0x%x", (guint32) res16);
-
- return OK;
-}
-
-/*
- * test initialization
- */
-
-static Test endian_tests [] = {
- {"swap", test_swap},
- {NULL, NULL}
-};
-
-DEFINE_TEST_GROUP_INIT(endian_tests_init, endian_tests)
-
+++ /dev/null
-/*
- * Fake test allows debugging of the driver itself
- */
-
-#include "test.h"
-
-RESULT
-test_fake()
-{
- return OK;
-}
-
-static Test fake_tests [] = {
- {"fake", test_fake},
- {NULL, NULL}
-};
-
-DEFINE_TEST_GROUP_INIT(fake_tests_init, fake_tests)
-
+++ /dev/null
-#include <config.h>
-#include <glib.h>
-#include <string.h>
-#include <stdlib.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#include <stdio.h>
-#include "test.h"
-
-#ifdef G_OS_WIN32
-#include <io.h>
-#define close _close
-#endif
-
-RESULT
-test_file_get_contents ()
-{
- GError *error;
- gchar *content;
- gboolean ret;
- gsize length;
-#ifdef G_OS_WIN32
- const gchar *filename = "c:\\Windows\\system.ini";
-#else
- const gchar *filename = "/etc/hosts";
-#endif
-
- /*
- filename != NULL
- ret = g_file_get_contents (NULL, NULL, NULL, NULL);
- contents != NULL
- ret = g_file_get_contents ("", NULL, NULL, NULL);
- error no such file and fails for 'error' not being null too
- ret = g_file_get_contents ("", &content, NULL, &error);
- */
-
- error = NULL;
- ret = g_file_get_contents ("", &content, NULL, &error);
- if (ret)
- return FAILED ("HAH!");
- if (error == NULL)
- return FAILED ("Got nothing as error.");
- if (content != NULL)
- return FAILED ("Content is uninitialized");
-
- g_error_free (error);
- error = NULL;
- ret = g_file_get_contents (filename, &content, &length, &error);
- if (!ret)
- return FAILED ("The error is %d %s\n", error->code, error->message);
- if (error != NULL)
- return FAILED ("Got an error returning TRUE");
- if (content == NULL)
- return FAILED ("Content is NULL");
- if (strlen (content) != length)
- return FAILED ("length is %d but the string is %d", length, strlen (content));
- g_free (content);
-
- return OK;
-}
-
-RESULT
-test_open_tmp ()
-{
- GError *error;
- gint fd;
- gchar *name = GINT_TO_POINTER (-1);
-
- /*
- * Okay, this works, but creates a .xxx file in /tmp on every run. Disabled.
- * fd = g_file_open_tmp (NULL, NULL, NULL);
- * if (fd < 0)
- * return FAILED ("Default failed.");
- * close (fd);
- */
- error = NULL;
- fd = g_file_open_tmp ("invalidtemplate", NULL, &error);
- if (fd != -1)
- return FAILED ("The template was invalid and accepted");
- if (error == NULL)
- return FAILED ("No error returned.");
- g_error_free (error);
-
- error = NULL;
- fd = g_file_open_tmp ("i/nvalidtemplate", &name, &error);
- if (fd != -1)
- return FAILED ("The template was invalid and accepted");
- if (error == NULL)
- return FAILED ("No error returned.");
- if (name == NULL)
- return FAILED ("'name' is not reset");
- g_error_free (error);
-
- error = NULL;
- fd = g_file_open_tmp ("valid-XXXXXX", &name, &error);
- if (fd == -1)
- return FAILED ("This should be valid");
- if (error != NULL)
- return FAILED ("No error returned.");
- if (name == NULL)
- return FAILED ("No name returned.");
- close (fd);
- unlink (name);
- g_free (name);
- return OK;
-}
-
-RESULT
-test_file ()
-{
- gboolean res;
- const gchar *tmp;
- gchar *path;
-
-#ifndef G_OS_WIN32 /* FIXME */
- gchar *sympath;
- gint ignored G_GNUC_UNUSED;
-#endif
-
- res = g_file_test (NULL, 0);
- if (res)
- return FAILED ("Should return FALSE HERE");
-
- res = g_file_test ("file.c", 0);
- if (res)
- return FAILED ("Should return FALSE HERE");
-
- tmp = g_get_tmp_dir ();
- res = g_file_test (tmp, G_FILE_TEST_EXISTS);
- if (!res)
- return FAILED ("tmp does not exist.");
- res = g_file_test (tmp, G_FILE_TEST_IS_REGULAR);
- if (res)
- return FAILED ("tmp is regular");
-
- res = g_file_test (tmp, G_FILE_TEST_IS_DIR);
- if (!res)
- return FAILED ("tmp is not a directory");
- res = g_file_test (tmp, G_FILE_TEST_IS_EXECUTABLE);
- if (!res)
- return FAILED ("tmp is not a executable");
-
- res = g_file_test (tmp, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_SYMLINK);
- if (!res)
- return FAILED ("2 tmp does not exist.");
- res = g_file_test (tmp, G_FILE_TEST_IS_REGULAR | G_FILE_TEST_IS_SYMLINK);
- if (res)
- return FAILED ("2 tmp is regular");
-
- res = g_file_test (tmp, G_FILE_TEST_IS_DIR | G_FILE_TEST_IS_SYMLINK);
- if (!res)
- return FAILED ("2 tmp is not a directory");
- res = g_file_test (tmp, G_FILE_TEST_IS_EXECUTABLE | G_FILE_TEST_IS_SYMLINK);
- if (!res)
- return FAILED ("2 tmp is not a executable");
-
- close (g_file_open_tmp (NULL, &path, NULL)); /* create an empty file */
- res = g_file_test (path, G_FILE_TEST_EXISTS);
- if (!res)
- return FAILED ("3 %s should exist", path);
- res = g_file_test (path, G_FILE_TEST_IS_REGULAR);
- /* This is strange. Empty file is reported as not existing! */
- if (!res)
- return FAILED ("3 %s IS_REGULAR", path);
- res = g_file_test (path, G_FILE_TEST_IS_DIR);
- if (res)
- return FAILED ("3 %s should not be a directory", path);
- res = g_file_test (path, G_FILE_TEST_IS_EXECUTABLE);
- if (res)
- return FAILED ("3 %s should not be executable", path);
- res = g_file_test (path, G_FILE_TEST_IS_SYMLINK);
- if (res)
- return FAILED ("3 %s should not be a symlink", path);
-
-#ifndef G_OS_WIN32 /* FIXME */
- sympath = g_strconcat (path, "-link", NULL);
- ignored = symlink (path, sympath);
- res = g_file_test (sympath, G_FILE_TEST_EXISTS);
- if (!res)
- return FAILED ("4 %s should not exist", sympath);
- res = g_file_test (sympath, G_FILE_TEST_IS_REGULAR);
- if (!res)
- return FAILED ("4 %s should not be a regular file", sympath);
- res = g_file_test (sympath, G_FILE_TEST_IS_DIR);
- if (res)
- return FAILED ("4 %s should not be a directory", sympath);
- res = g_file_test (sympath, G_FILE_TEST_IS_EXECUTABLE);
- if (res)
- return FAILED ("4 %s should not be executable", sympath);
- res = g_file_test (sympath, G_FILE_TEST_IS_SYMLINK);
- if (!res)
- return FAILED ("4 %s should be a symlink", sympath);
-
- unlink (path);
-
- res = g_file_test (sympath, G_FILE_TEST_EXISTS);
- if (res)
- return FAILED ("5 %s should exist", sympath);
- res = g_file_test (sympath, G_FILE_TEST_IS_REGULAR);
- if (res)
- return FAILED ("5 %s should be a regular file", sympath);
- res = g_file_test (sympath, G_FILE_TEST_IS_DIR);
- if (res)
- return FAILED ("5 %s should not be a directory", sympath);
- res = g_file_test (sympath, G_FILE_TEST_IS_EXECUTABLE);
- if (res)
- return FAILED ("5 %s should not be executable", sympath);
- res = g_file_test (sympath, G_FILE_TEST_IS_SYMLINK);
- if (!res)
- return FAILED ("5 %s should be a symlink", sympath);
- unlink (sympath);
- g_free (sympath);
-#endif
- g_free (path);
- return OK;
-}
-
-static Test file_tests [] = {
- {"g_file_get_contents", test_file_get_contents},
- {"g_file_open_tmp", test_open_tmp},
- {"g_file_test", test_file},
- {NULL, NULL}
-};
-
-DEFINE_TEST_GROUP_INIT(file_tests_init, file_tests)
-
-
+++ /dev/null
-#include <stdio.h>
-#include <string.h>
-#include <glib.h>
-#include "test.h"
-
-int foreach_count = 0;
-int foreach_fail = 0;
-
-void foreach (gpointer key, gpointer value, gpointer user_data)
-{
- foreach_count++;
- if (GPOINTER_TO_INT (user_data) != 'a')
- foreach_fail = 1;
-}
-
-RESULT hash_t1 (void)
-{
- GHashTable *t = g_hash_table_new (g_str_hash, g_str_equal);
-
- foreach_count = 0;
- foreach_fail = 0;
- g_hash_table_insert (t, "hello", "world");
- g_hash_table_insert (t, "my", "god");
-
- g_hash_table_foreach (t, foreach, GINT_TO_POINTER('a'));
- if (foreach_count != 2)
- return FAILED ("did not find all keys, got %d expected 2", foreach_count);
- if (foreach_fail)
- return FAILED("failed to pass the user-data to foreach");
-
- if (!g_hash_table_remove (t, "my"))
- return FAILED ("did not find known key");
- if (g_hash_table_size (t) != 1)
- return FAILED ("unexpected size");
- g_hash_table_insert(t, "hello", "moon");
- if (strcmp (g_hash_table_lookup (t, "hello"), "moon") != 0)
- return FAILED ("did not replace world with moon");
-
- if (!g_hash_table_remove (t, "hello"))
- return FAILED ("did not find known key");
- if (g_hash_table_size (t) != 0)
- return FAILED ("unexpected size");
- g_hash_table_destroy (t);
-
- return OK;
-}
-
-RESULT hash_t2 (void)
-{
- return OK;
-}
-
-RESULT hash_default (void)
-{
- GHashTable *hash = g_hash_table_new (NULL, NULL);
-
- if (hash == NULL)
- return FAILED ("g_hash_table_new should return a valid hash");
-
- g_hash_table_destroy (hash);
- return NULL;
-}
-
-RESULT
-hash_null_lookup (void)
-{
- GHashTable *hash = g_hash_table_new (NULL, NULL);
- gpointer ok, ov;
-
- g_hash_table_insert (hash, NULL, GINT_TO_POINTER (1));
- g_hash_table_insert (hash, GINT_TO_POINTER(1), GINT_TO_POINTER(2));
-
- if (!g_hash_table_lookup_extended (hash, NULL, &ok, &ov))
- return FAILED ("Did not find the NULL");
- if (ok != NULL)
- return FAILED ("Incorrect key found");
- if (ov != GINT_TO_POINTER (1))
- return FAILED ("Got wrong value %p\n", ov);
-
- if (!g_hash_table_lookup_extended (hash, GINT_TO_POINTER(1), &ok, &ov))
- return FAILED ("Did not find the 1");
- if (ok != GINT_TO_POINTER(1))
- return FAILED ("Incorrect key found");
- if (ov != GINT_TO_POINTER (2))
- return FAILED ("Got wrong value %p\n", ov);
-
- g_hash_table_destroy (hash);
-
- return NULL;
-}
-
-static void
-counter (gpointer key, gpointer value, gpointer user_data)
-{
- int *counter = (int *) user_data;
-
- (*counter)++;
-}
-
-RESULT hash_grow (void)
-{
- GHashTable *hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
- int i, count = 0;
-
- for (i = 0; i < 1000; i++)
- g_hash_table_insert (hash, g_strdup_printf ("%d", i), g_strdup_printf ("x-%d", i));
-
- for (i = 0; i < 1000; i++){
- char buffer [30];
- gpointer value;
-
- sprintf (buffer, "%d", i);
-
- value = g_hash_table_lookup (hash, buffer);
- sprintf (buffer, "x-%d", i);
- if (strcmp (value, buffer) != 0){
- return FAILED ("Failed to lookup the key %d, the value was %s\n", i, value);
- }
- }
-
- if (g_hash_table_size (hash) != 1000)
- return FAILED ("Did not find 1000 elements on the hash, found %d\n", g_hash_table_size (hash));
-
- /* Now do the manual count, lets not trust the internals */
- g_hash_table_foreach (hash, counter, &count);
- if (count != 1000){
- return FAILED ("Foreach count is not 1000");
- }
-
- g_hash_table_destroy (hash);
- return NULL;
-}
-
-RESULT hash_iter (void)
-{
-#if !defined(GLIB_MAJOR_VERSION) || GLIB_CHECK_VERSION(2, 16, 0)
- GHashTable *hash = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, NULL);
- GHashTableIter iter;
- int i, sum, keys_sum, values_sum;
- gpointer key, value;
-
- sum = 0;
- for (i = 0; i < 1000; i++) {
- sum += i;
- g_hash_table_insert (hash, GUINT_TO_POINTER (i), GUINT_TO_POINTER (i));
- }
-
- keys_sum = values_sum = 0;
- g_hash_table_iter_init (&iter, hash);
- while (g_hash_table_iter_next (&iter, &key, &value)) {
- if (key != value)
- return FAILED ("key != value");
- keys_sum += GPOINTER_TO_UINT (key);
- values_sum += GPOINTER_TO_UINT (value);
- }
- if (keys_sum != sum || values_sum != sum)
- return FAILED ("Did not find all key-value pairs");
- g_hash_table_destroy (hash);
- return NULL;
-#else
- /* GHashTableIter was added in glib 2.16 */
- return NULL;
-#endif
-}
-
-static Test hashtable_tests [] = {
- {"t1", hash_t1},
- {"t2", hash_t2},
- {"grow", hash_grow},
- {"default", hash_default},
- {"null_lookup", hash_null_lookup},
- {"iter", hash_iter},
- {NULL, NULL}
-};
-
-DEFINE_TEST_GROUP_INIT(hashtable_tests_init, hashtable_tests)
-
+++ /dev/null
-#include <stdio.h>
-#include <string.h>
-#include <glib.h>
-#include "test.h"
-
-RESULT
-test_list_length ()
-{
- GList *list = g_list_prepend (NULL, "foo");
-
- if (g_list_length (list) != 1)
- return FAILED ("length failed. #1");
-
- list = g_list_prepend (list, "bar");
- if (g_list_length (list) != 2)
- return FAILED ("length failed. #2");
-
- list = g_list_append (list, "bar");
- if (g_list_length (list) != 3)
- return FAILED ("length failed. #3");
-
- g_list_free (list);
- return NULL;
-}
-
-RESULT
-test_list_nth ()
-{
- char *foo = "foo";
- char *bar = "bar";
- char *baz = "baz";
- GList *nth, *list;
- list = g_list_prepend (NULL, baz);
- list = g_list_prepend (list, bar);
- list = g_list_prepend (list, foo);
-
- nth = g_list_nth (list, 0);
- if (nth->data != foo)
- return FAILED ("nth failed. #0");
-
- nth = g_list_nth (list, 1);
- if (nth->data != bar)
- return FAILED ("nth failed. #1");
-
- nth = g_list_nth (list, 2);
- if (nth->data != baz)
- return FAILED ("nth failed. #2");
-
- nth = g_list_nth (list, 3);
- if (nth)
- return FAILED ("nth failed. #3: %s", nth->data);
-
- g_list_free (list);
- return OK;
-}
-
-RESULT
-test_list_index ()
-{
- int i;
- char *foo = "foo";
- char *bar = "bar";
- char *baz = "baz";
- GList *list;
- list = g_list_prepend (NULL, baz);
- list = g_list_prepend (list, bar);
- list = g_list_prepend (list, foo);
-
- i = g_list_index (list, foo);
- if (i != 0)
- return FAILED ("index failed. #0: %d", i);
-
- i = g_list_index (list, bar);
- if (i != 1)
- return FAILED ("index failed. #1: %d", i);
-
- i = g_list_index (list, baz);
- if (i != 2)
- return FAILED ("index failed. #2: %d", i);
-
- g_list_free (list);
- return OK;
-}
-
-RESULT
-test_list_append ()
-{
- GList *list = g_list_prepend (NULL, "first");
- if (g_list_length (list) != 1)
- return FAILED ("Prepend failed");
-
- list = g_list_append (list, "second");
-
- if (g_list_length (list) != 2)
- return FAILED ("Append failed");
-
- g_list_free (list);
- return OK;
-}
-
-RESULT
-test_list_last ()
-{
- GList *foo = g_list_prepend (NULL, "foo");
- GList *bar = g_list_prepend (NULL, "bar");
- GList *last;
-
- foo = g_list_concat (foo, bar);
- last = g_list_last (foo);
-
- if (last != bar)
- return FAILED ("last failed. #1");
-
- foo = g_list_concat (foo, g_list_prepend (NULL, "baz"));
- foo = g_list_concat (foo, g_list_prepend (NULL, "quux"));
-
- last = g_list_last (foo);
- if (strcmp ("quux", last->data))
- return FAILED ("last failed. #2");
-
- g_list_free (foo);
-
- return OK;
-}
-
-RESULT
-test_list_concat ()
-{
- GList *foo = g_list_prepend (NULL, "foo");
- GList *bar = g_list_prepend (NULL, "bar");
- GList *list = g_list_concat (foo, bar);
-
- if (g_list_length (list) != 2)
- return FAILED ("Concat failed. #1");
-
- if (strcmp (list->data, "foo"))
- return FAILED ("Concat failed. #2");
-
- if (strcmp (list->next->data, "bar"))
- return FAILED ("Concat failed. #3");
-
- if (g_list_first (list) != foo)
- return FAILED ("Concat failed. #4");
-
- if (g_list_last (list) != bar)
- return FAILED ("Concat failed. #5");
-
- g_list_free (list);
-
- return OK;
-}
-
-
-static gint
-compare (gconstpointer a, gconstpointer b)
-{
- char *foo = (char *) a;
- char *bar = (char *) b;
-
- if (strlen (foo) < strlen (bar))
- return -1;
-
- return 1;
-}
-
-RESULT
-test_list_insert_sorted ()
-{
- GList *list = g_list_prepend (NULL, "a");
- list = g_list_append (list, "aaa");
-
- /* insert at the middle */
- list = g_list_insert_sorted (list, "aa", compare);
- if (strcmp ("aa", list->next->data))
- return FAILED ("insert_sorted failed. #1");
-
- /* insert at the beginning */
- list = g_list_insert_sorted (list, "", compare);
- if (strcmp ("", list->data))
- return FAILED ("insert_sorted failed. #2");
-
- /* insert at the end */
- list = g_list_insert_sorted (list, "aaaa", compare);
- if (strcmp ("aaaa", g_list_last (list)->data))
- return FAILED ("insert_sorted failed. #3");
-
- g_list_free (list);
- return OK;
-}
-
-RESULT
-test_list_copy ()
-{
- int i, length;
- GList *list, *copy;
- list = g_list_prepend (NULL, "a");
- list = g_list_append (list, "aa");
- list = g_list_append (list, "aaa");
- list = g_list_append (list, "aaaa");
-
- length = g_list_length (list);
- copy = g_list_copy (list);
-
- for (i = 0; i < length; i++)
- if (strcmp (g_list_nth (list, i)->data,
- g_list_nth (copy, i)->data))
- return FAILED ("copy failed.");
-
- g_list_free (list);
- g_list_free (copy);
- return OK;
-}
-
-RESULT
-test_list_reverse ()
-{
- guint i, length;
- GList *list, *reverse;
- list = g_list_prepend (NULL, "a");
- list = g_list_append (list, "aa");
- list = g_list_append (list, "aaa");
- list = g_list_append (list, "aaaa");
-
- length = g_list_length (list);
- reverse = g_list_reverse (g_list_copy (list));
-
- if (g_list_length (reverse) != length)
- return FAILED ("reverse failed #1");
-
- for (i = 0; i < length; i++){
- guint j = length - i - 1;
- if (strcmp (g_list_nth (list, i)->data,
- g_list_nth (reverse, j)->data))
- return FAILED ("reverse failed. #2");
- }
-
- g_list_free (list);
- g_list_free (reverse);
- return OK;
-}
-
-RESULT
-test_list_remove ()
-{
- GList *list = g_list_prepend (NULL, "three");
- char *one = "one";
- list = g_list_prepend (list, "two");
- list = g_list_prepend (list, one);
-
- list = g_list_remove (list, one);
-
- if (g_list_length (list) != 2)
- return FAILED ("Remove failed");
-
- if (strcmp ("two", list->data) != 0)
- return FAILED ("Remove failed");
-
- g_list_free (list);
- return OK;
-}
-
-RESULT
-test_list_remove_link ()
-{
- GList *foo = g_list_prepend (NULL, "a");
- GList *bar = g_list_prepend (NULL, "b");
- GList *baz = g_list_prepend (NULL, "c");
- GList *list = foo;
-
- foo = g_list_concat (foo, bar);
- foo = g_list_concat (foo, baz);
-
- list = g_list_remove_link (list, bar);
-
- if (g_list_length (list) != 2)
- return FAILED ("remove_link failed #1");
-
- if (bar->next != NULL)
- return FAILED ("remove_link failed #2");
-
- g_list_free (list);
- g_list_free (bar);
- return OK;
-}
-
-RESULT
-test_list_insert_before ()
-{
- GList *foo, *bar, *baz;
-
- foo = g_list_prepend (NULL, "foo");
- foo = g_list_insert_before (foo, NULL, "bar");
- bar = g_list_last (foo);
-
- if (strcmp (bar->data, "bar"))
- return FAILED ("1");
-
- baz = g_list_insert_before (foo, bar, "baz");
- if (foo != baz)
- return FAILED ("2");
-
- if (strcmp (g_list_nth_data (foo, 1), "baz"))
- return FAILED ("3: %s", g_list_nth_data (foo, 1));
-
- g_list_free (foo);
- return OK;
-}
-
-#define N_ELEMS 101
-
-static int intcompare (gconstpointer p1, gconstpointer p2)
-{
- return GPOINTER_TO_INT (p1) - GPOINTER_TO_INT (p2);
-}
-
-static gboolean verify_sort (GList *list, int len)
-{
- int prev;
-
- if (list->prev)
- return FALSE;
-
- prev = GPOINTER_TO_INT (list->data);
- len--;
- for (list = list->next; list; list = list->next) {
- int curr = GPOINTER_TO_INT (list->data);
- if (prev > curr)
- return FALSE;
- prev = curr;
-
- if (!list->prev || list->prev->next != list)
- return FALSE;
-
- if (len == 0)
- return FALSE;
- len--;
- }
- return len == 0;
-}
-
-RESULT
-test_list_sort ()
-{
- int i, j, mul;
- GList *list = NULL;
-
- for (i = 0; i < N_ELEMS; ++i)
- list = g_list_prepend (list, GINT_TO_POINTER (i));
- list = g_list_sort (list, intcompare);
- if (!verify_sort (list, N_ELEMS))
- return FAILED ("decreasing list");
-
- g_list_free (list);
-
- list = NULL;
- for (i = 0; i < N_ELEMS; ++i)
- list = g_list_prepend (list, GINT_TO_POINTER (-i));
- list = g_list_sort (list, intcompare);
- if (!verify_sort (list, N_ELEMS))
- return FAILED ("increasing list");
-
- g_list_free (list);
-
- list = g_list_prepend (NULL, GINT_TO_POINTER (0));
- for (i = 1; i < N_ELEMS; ++i) {
- list = g_list_prepend (list, GINT_TO_POINTER (i));
- list = g_list_prepend (list, GINT_TO_POINTER (-i));
- }
- list = g_list_sort (list, intcompare);
- if (!verify_sort (list, 2*N_ELEMS-1))
- return FAILED ("alternating list");
-
- g_list_free (list);
-
- list = NULL;
- mul = 1;
- for (i = 1; i < N_ELEMS; ++i) {
- mul = -mul;
- for (j = 0; j < i; ++j)
- list = g_list_prepend (list, GINT_TO_POINTER (mul * j));
- }
- list = g_list_sort (list, intcompare);
- if (!verify_sort (list, (N_ELEMS*N_ELEMS - N_ELEMS)/2))
- return FAILED ("wavering list");
-
- g_list_free (list);
-
- return OK;
-}
-
-static gint
-find_custom (gconstpointer a, gconstpointer b)
-{
- return(strcmp (a, b));
-}
-
-RESULT
-test_list_find_custom ()
-{
- GList *list = NULL, *found;
- char *foo = "foo";
- char *bar = "bar";
- char *baz = "baz";
-
- list = g_list_prepend (list, baz);
- list = g_list_prepend (list, bar);
- list = g_list_prepend (list, foo);
-
- found = g_list_find_custom (list, baz, find_custom);
-
- if (found == NULL)
- return FAILED ("Find failed");
-
- g_list_free (list);
-
- return OK;
-}
-
-static Test list_tests [] = {
- { "length", test_list_length},
- { "nth", test_list_nth},
- { "index", test_list_index},
- { "last", test_list_last},
- { "append", test_list_append},
- { "concat", test_list_concat},
- {"insert_sorted", test_list_insert_sorted},
- {"insert_before", test_list_insert_before},
- { "copy", test_list_copy},
- { "reverse", test_list_reverse},
- { "remove", test_list_remove},
- { "remove_link", test_list_remove_link},
- { "remove_link", test_list_remove_link},
- { "sort", test_list_sort},
- { "find_custom", test_list_find_custom},
- {NULL, NULL}
-};
-
-DEFINE_TEST_GROUP_INIT(list_tests_init, list_tests)
+++ /dev/null
-#include <stdio.h>
-#include <string.h>
-#include <glib.h>
-#include "test.h"
-
-#define do_bad_test(s) do { char *r = markup_test (s); if (r == NULL) return FAILED ("Failed on test " # s); else g_free (r); } while (0)
-#define do_ok_test(s) do { char *r = markup_test (s); if (r != NULL) return FAILED ("Could not parse valid " # s); } while (0)
-
-static char *
-markup_test (const char *s)
-{
- GMarkupParser *parser = g_new0 (GMarkupParser, 1);
- GMarkupParseContext *context;
- GError *error = NULL;
-
- context = g_markup_parse_context_new (parser, 0, 0, 0);
-
- g_markup_parse_context_parse (context, s, strlen (s), &error);
- g_markup_parse_context_free (context);
-
- if (error != NULL){
- char *msg = g_strdup (error->message);
- g_error_free (error);
-
- g_free (parser);
- return msg;
- }
- g_free (parser);
- return NULL;
-}
-
-RESULT
-invalid_documents (void)
-{
- /* These should fail */
- do_bad_test ("<1>");
- do_bad_test ("<a<");
- do_bad_test ("</a>");
- do_bad_test ("<a b>");
- do_bad_test ("<a b=>");
- do_bad_test ("<a b=c>");
-
- return OK;
-}
-
-RESULT
-valid_documents (void)
-{
- /* These should fail */
- do_ok_test ("<a>");
- do_ok_test ("<a a=\"b\">");
-
- return OK;
-}
-
-/*
- * This is a test for the kind of files that the code in mono/domain.c
- * parses; This code comes from Mono
- */
-typedef struct {
- GSList *supported_runtimes;
- char *required_runtime;
- int configuration_count;
- int startup_count;
-} AppConfigInfo;
-
-static char *
-get_attribute_value (const gchar **attribute_names,
- const gchar **attribute_values,
- const char *att_name)
-{
- int n;
- for (n=0; attribute_names[n] != NULL; n++) {
- if (strcmp (attribute_names[n], att_name) == 0)
- return g_strdup (attribute_values[n]);
- }
- return NULL;
-}
-
-static void
-start_element (GMarkupParseContext *context,
- const gchar *element_name,
- const gchar **attribute_names,
- const gchar **attribute_values,
- gpointer user_data,
- GError **error)
-{
- AppConfigInfo* app_config = (AppConfigInfo*) user_data;
-
- if (strcmp (element_name, "configuration") == 0) {
- app_config->configuration_count++;
- return;
- }
- if (strcmp (element_name, "startup") == 0) {
- app_config->startup_count++;
- return;
- }
-
- if (app_config->configuration_count != 1 || app_config->startup_count != 1)
- return;
-
- if (strcmp (element_name, "requiredRuntime") == 0) {
- app_config->required_runtime = get_attribute_value (attribute_names, attribute_values, "version");
- } else if (strcmp (element_name, "supportedRuntime") == 0) {
- char *version = get_attribute_value (attribute_names, attribute_values, "version");
- app_config->supported_runtimes = g_slist_append (app_config->supported_runtimes, version);
- }
-}
-
-static void
-end_element (GMarkupParseContext *context,
- const gchar *element_name,
- gpointer user_data,
- GError **error)
-{
- AppConfigInfo* app_config = (AppConfigInfo*) user_data;
-
- if (strcmp (element_name, "configuration") == 0) {
- app_config->configuration_count--;
- } else if (strcmp (element_name, "startup") == 0) {
- app_config->startup_count--;
- }
-}
-
-static const GMarkupParser
-mono_parser = {
- start_element,
- end_element,
- NULL,
- NULL,
- NULL
-};
-
-AppConfigInfo *
-domain_test (char *text)
-{
- AppConfigInfo *app_config = g_new0 (AppConfigInfo, 1);
- GMarkupParseContext *context;
-
- context = g_markup_parse_context_new (&mono_parser, 0, app_config, NULL);
- if (g_markup_parse_context_parse (context, text, strlen (text), NULL)) {
- g_markup_parse_context_end_parse (context, NULL);
- }
- g_markup_parse_context_free (context);
-
- return app_config;
-}
-
-void
-domain_free (AppConfigInfo *info)
-{
- GSList *l;
- if (info->required_runtime)
- g_free (info->required_runtime);
- for (l = info->supported_runtimes; l != NULL; l = l->next){
- g_free (l->data);
- }
- g_slist_free (info->supported_runtimes);
- g_free (info);
-}
-
-RESULT
-mono_domain (void)
-{
- AppConfigInfo *info;
-
- info = domain_test ("<configuration><!--hello--><startup><!--world--><requiredRuntime version=\"v1\"><!--r--></requiredRuntime></startup></configuration>");
- if (info->required_runtime == NULL)
- return FAILED ("No required runtime section");
- if (strcmp (info->required_runtime, "v1") != 0)
- return FAILED ("Got a runtime version %s, expected v1", info->required_runtime);
- domain_free (info);
-
- info = domain_test ("<configuration><startup><requiredRuntime version=\"v1\"/><!--comment--></configuration><!--end-->");
- if (info->required_runtime == NULL)
- return FAILED ("No required runtime section on auto-close section");
- if (strcmp (info->required_runtime, "v1") != 0)
- return FAILED ("Got a runtime version %s, expected v1", info->required_runtime);
- domain_free (info);
-
- info = domain_test ("<!--start--><configuration><startup><supportedRuntime version=\"v1\"/><!--middle--><supportedRuntime version=\"v2\"/></startup></configuration>");
- if ((strcmp ((char*)info->supported_runtimes->data, "v1") == 0)){
- if (info->supported_runtimes->next == NULL)
- return FAILED ("Expected 2 supported runtimes");
-
- if ((strcmp ((char*)info->supported_runtimes->next->data, "v2") != 0))
- return FAILED ("Expected v1, v2, got %s", info->supported_runtimes->next->data);
- if (info->supported_runtimes->next->next != NULL)
- return FAILED ("Expected v1, v2, got more");
- } else
- return FAILED ("Expected `v1', got %s", info->supported_runtimes->data);
- domain_free (info);
-
- return NULL;
-}
-
-RESULT
-mcs_config (void)
-{
- return markup_test ("<configuration>\r\n <system.diagnostics>\r\n <trace autoflush=\"true\" indentsize=\"4\">\r\n <listeners>\r\n <add name=\"compilerLogListener\" type=\"System.Diagnostics.TextWriterTraceListener,System\"/> </listeners> </trace> </system.diagnostics> </configuration>");
-
-}
-
-RESULT
-xml_parse (void)
-{
- return markup_test ("<?xml version=\"1.0\" encoding=\"utf-8\"?><a></a>");
-}
-
-RESULT
-machine_config (void)
-{
- char *data;
- gsize size;
-
- if (g_file_get_contents ("../../data/net_1_1/machine.config", &data, &size, NULL)){
- return markup_test (data);
- }
- printf ("Ignoring this test\n");
- return NULL;
-}
-
-static Test markup_tests [] = {
- {"invalid_documents", invalid_documents},
- {"good_documents", valid_documents},
- {"mono_domain", mono_domain},
- {"mcs_config", mcs_config},
- {"xml_parse", xml_parse},
- {"machine_config", machine_config},
- {NULL, NULL}
-};
-
-DEFINE_TEST_GROUP_INIT(markup_tests_init, markup_tests)
-
+++ /dev/null
-
-#include <glib.h>
-#include "test.h"
-
-RESULT
-test_memory_zero_size_allocations ()
-{
- gpointer p;
-
- p = g_malloc (0);
- if (p)
- return FAILED ("Calling g_malloc with size zero should return NULL.");
-
- p = g_malloc0 (0);
- if (p)
- return FAILED ("Calling g_malloc0 with size zero should return NULL.");
-
- p = g_realloc (NULL, 0);
- if (p)
- return FAILED ("Calling g_realloc with size zero should return NULL.");
-
- p = g_new (int, 0);
- if (p)
- return FAILED ("Calling g_new with size zero should return NULL.");
-
- p = g_new0 (int, 0);
- if (p)
- return FAILED ("Calling g_new0 with size zero should return NULL.");
-
- return OK;
-}
-
-
-static Test memory_tests [] = {
- { "zero_size_allocations", test_memory_zero_size_allocations},
- {NULL, NULL}
-};
-
-DEFINE_TEST_GROUP_INIT(memory_tests_init, memory_tests)
-
+++ /dev/null
-#include <config.h>
-#include <glib.h>
-#include <gmodule.h>
-#include <string.h>
-#include <stdio.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#include "test.h"
-
-#if defined (G_OS_WIN32)
-#define EXTERNAL_SYMBOL "GetProcAddress"
-#else
-#define EXTERNAL_SYMBOL "system"
-#endif
-
-void G_MODULE_EXPORT
-dummy_test_export ()
-{
-}
-
-/* test for g_module_open (NULL, ...) */
-RESULT
-test_module_symbol_null ()
-{
- gpointer proc = GINT_TO_POINTER (42);
-
- GModule *m = g_module_open (NULL, G_MODULE_BIND_LAZY);
-
- if (m == NULL)
- return FAILED ("bind to main module failed. #0");
-
- if (g_module_symbol (m, "__unlikely_\nexistent__", &proc))
- return FAILED ("non-existent symbol lookup failed. #1");
-
- if (proc)
- return FAILED ("non-existent symbol lookup failed. #2");
-
- if (!g_module_symbol (m, EXTERNAL_SYMBOL, &proc))
- return FAILED ("external lookup failed. #3");
-
- if (!proc)
- return FAILED ("external lookup failed. #4");
-
- if (!g_module_symbol (m, "dummy_test_export", &proc))
- return FAILED ("in-proc lookup failed. #5");
-
- if (!proc)
- return FAILED ("in-proc lookup failed. #6");
-
- if (!g_module_close (m))
- return FAILED ("close failed. #7");
-
- return OK;
-}
-
-static Test module_tests [] = {
- {"g_module_symbol_null", test_module_symbol_null},
- {NULL, NULL}
-};
-
-DEFINE_TEST_GROUP_INIT(module_tests_init, module_tests)
-
-
+++ /dev/null
-#include <config.h>
-#include <glib.h>
-#include <string.h>
-#include <stdio.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#ifdef G_OS_UNIX
-#include <pthread.h>
-#endif
-#include "test.h"
-
-#ifdef G_OS_WIN32
-#include <direct.h>
-#define chdir _chdir
-#endif
-
-/* This test is just to be used with valgrind */
-RESULT
-test_buildpath ()
-{
- char *s;
- char *buffer = "var/private";
- char *dir = "/";
-
- s = g_build_path ("/", "hola///", "//mundo", NULL);
- if (strcmp (s, "hola/mundo") != 0)
- return FAILED ("1 Got wrong result, got: %s", s);
- g_free (s);
-
- s = g_build_path ("/", "hola/", "/mundo", NULL);
- if (strcmp (s, "hola/mundo") != 0)
- return FAILED ("2 Got wrong result, got: %s", s);
- g_free (s);
-
- s = g_build_path ("/", "hola/", "mundo", NULL);
- if (strcmp (s, "hola/mundo") != 0)
- return FAILED ("3 Got wrong result, got: %s", s);
- g_free (s);
-
- s = g_build_path ("/", "hola", "/mundo", NULL);
- if (strcmp (s, "hola/mundo") != 0)
- return FAILED ("4 Got wrong result, got: %s", s);
- g_free (s);
-
- s = g_build_path ("/", "/hello", "world/", NULL);
- if (strcmp (s, "/hello/world/") != 0)
- return FAILED ("5 Got wrong result, got: %s", s);
- g_free (s);
-
- /* Now test multi-char-separators */
- s = g_build_path ("**", "hello", "world", NULL);
- if (strcmp (s, "hello**world") != 0)
- return FAILED ("6 Got wrong result, got: %s", s);
- g_free (s);
-
- s = g_build_path ("**", "hello**", "world", NULL);
- if (strcmp (s, "hello**world") != 0)
- return FAILED ("7 Got wrong result, got: %s", s);
- g_free (s);
-
- s = g_build_path ("**", "hello**", "**world", NULL);
- if (strcmp (s, "hello**world") != 0)
- return FAILED ("8 Got wrong result, got: %s", s);
- g_free (s);
-
- s = g_build_path ("**", "hello**", "**world", NULL);
- if (strcmp (s, "hello**world") != 0)
- return FAILED ("9 Got wrong result, got: %s", s);
- g_free (s);
-
- s = g_build_path ("1234567890", "hello", "world", NULL);
- if (strcmp (s, "hello1234567890world") != 0)
- return FAILED ("10 Got wrong result, got: %s", s);
- g_free (s);
-
- s = g_build_path ("1234567890", "hello1234567890", "1234567890world", NULL);
- if (strcmp (s, "hello1234567890world") != 0)
- return FAILED ("11 Got wrong result, got: %s", s);
- g_free (s);
-
- s = g_build_path ("1234567890", "hello12345678901234567890", "1234567890world", NULL);
- if (strcmp (s, "hello1234567890world") != 0)
- return FAILED ("12 Got wrong result, got: %s", s);
- g_free (s);
-
- /* Multiple */
- s = g_build_path ("/", "a", "b", "c", "d", NULL);
- if (strcmp (s, "a/b/c/d") != 0)
- return FAILED ("13 Got wrong result, got: %s", s);
- g_free (s);
-
- s = g_build_path ("/", "/a", "", "/c/", NULL);
- if (strcmp (s, "/a/c/") != 0)
- return FAILED ("14 Got wrong result, got: %s", s);
- g_free (s);
-
- /* Null */
- s = g_build_path ("/", NULL, NULL);
- if (s == NULL)
- return FAILED ("must get a non-NULL return");
- if (s [0] != 0)
- return FAILED ("must get an empty string");
-
- // This is to test the regression introduced by Levi for the Windows support
- // that code errouneously read below the allowed area (in this case dir [-1]).
- // and caused all kinds of random errors.
- dir = "//";
- dir++;
- s = g_build_filename (dir, buffer, NULL);
- if (s [0] != '/')
- return FAILED ("Must have a '/' at the start");
-
- g_free (s);
- return OK;
-}
-
-RESULT
-test_buildfname ()
-{
- char *s;
-
- s = g_build_filename ("a", "b", "c", "d", NULL);
-#ifdef G_OS_WIN32
- if (strcmp (s, "a\\b\\c\\d") != 0)
-#else
- if (strcmp (s, "a/b/c/d") != 0)
-#endif
- return FAILED ("1 Got wrong result, got: %s", s);
- g_free (s);
-
-#ifdef G_OS_WIN32
- s = g_build_filename ("C:\\", "a", NULL);
- if (strcmp (s, "C:\\a") != 0)
-#else
- s = g_build_filename ("/", "a", NULL);
- if (strcmp (s, "/a") != 0)
-#endif
- return FAILED ("1 Got wrong result, got: %s", s);
-
-#ifndef G_OS_WIN32
- s = g_build_filename ("/", "foo", "/bar", "tolo/", "/meo/", NULL);
- if (strcmp (s, "/foo/bar/tolo/meo/") != 0)
- return FAILED ("1 Got wrong result, got: %s", s);
-#endif
-
- return OK;
-}
-
-char *
-test_dirname ()
-{
- char *s;
-
-#ifdef G_OS_WIN32
- s = g_path_get_dirname ("c:\\home\\miguel");
- if (strcmp (s, "c:\\home") != 0)
- return FAILED ("Expected c:\\home, got %s", s);
- g_free (s);
-
- s = g_path_get_dirname ("c:/home/miguel");
- if (strcmp (s, "c:/home") != 0)
- return FAILED ("Expected c:/home, got %s", s);
- g_free (s);
-
- s = g_path_get_dirname ("c:\\home\\dingus\\");
- if (strcmp (s, "c:\\home\\dingus") != 0)
- return FAILED ("Expected c:\\home\\dingus, got %s", s);
- g_free (s);
-
- s = g_path_get_dirname ("dir.c");
- if (strcmp (s, ".") != 0)
- return FAILED ("Expected `.', got %s", s);
- g_free (s);
-
- s = g_path_get_dirname ("c:\\index.html");
- if (strcmp (s, "c:") != 0)
- return FAILED ("Expected [c:], got [%s]", s);
-#else
- s = g_path_get_dirname ("/home/miguel");
- if (strcmp (s, "/home") != 0)
- return FAILED ("Expected /home, got %s", s);
- g_free (s);
-
- s = g_path_get_dirname ("/home/dingus/");
- if (strcmp (s, "/home/dingus") != 0)
- return FAILED ("Expected /home/dingus, got %s", s);
- g_free (s);
-
- s = g_path_get_dirname ("dir.c");
- if (strcmp (s, ".") != 0)
- return FAILED ("Expected `.', got %s", s);
- g_free (s);
-
- s = g_path_get_dirname ("/index.html");
- if (strcmp (s, "/") != 0)
- return FAILED ("Expected [/], got [%s]", s);
-#endif
- return OK;
-}
-
-char *
-test_basename ()
-{
- char *s;
-
-#ifdef G_OS_WIN32
- s = g_path_get_basename ("");
- if (strcmp (s, ".") != 0)
- return FAILED ("Expected `.', got %s", s);
- g_free (s);
-
- s = g_path_get_basename ("c:\\home\\dingus\\");
- if (strcmp (s, "dingus") != 0)
- return FAILED ("1 Expected dingus, got %s", s);
- g_free (s);
-
- s = g_path_get_basename ("c:/home/dingus/");
- if (strcmp (s, "dingus") != 0)
- return FAILED ("1 Expected dingus, got %s", s);
- g_free (s);
-
- s = g_path_get_basename ("c:\\home\\dingus");
- if (strcmp (s, "dingus") != 0)
- return FAILED ("2 Expected dingus, got %s", s);
- g_free (s);
-
- s = g_path_get_basename ("c:/home/dingus");
- if (strcmp (s, "dingus") != 0)
- return FAILED ("2 Expected dingus, got %s", s);
- g_free (s);
-#else
- s = g_path_get_basename ("");
- if (strcmp (s, ".") != 0)
- return FAILED ("Expected `.', got %s", s);
- g_free (s);
-
- s = g_path_get_basename ("/home/dingus/");
- if (strcmp (s, "dingus") != 0)
- return FAILED ("1 Expected dingus, got %s", s);
- g_free (s);
-
- s = g_path_get_basename ("/home/dingus");
- if (strcmp (s, "dingus") != 0)
- return FAILED ("2 Expected dingus, got %s", s);
- g_free (s);
-#endif
- return OK;
-}
-
-gchar *
-test_ppath ()
-{
- char *s;
-#ifdef G_OS_WIN32
- const gchar *searchfor = "explorer.exe";
-#else
- const gchar *searchfor = "ls";
-#endif
- s = g_find_program_in_path (searchfor);
- if (s == NULL)
- return FAILED ("No %s on this system?", searchfor);
- g_free (s);
- return OK;
-}
-
-gchar *
-test_ppath2 ()
-{
- char *s;
- const char *path = g_getenv ("PATH");
-#ifdef G_OS_WIN32
- const gchar *searchfor = "test_eglib.exe";
-#else
- const gchar *searchfor = "test-glib";
-#endif
-
- g_setenv ("PATH", "", TRUE);
- s = g_find_program_in_path ("ls");
- if (s != NULL) {
- g_setenv ("PATH", path, TRUE);
- return FAILED ("Found something interesting here: %s", s);
- }
- g_free (s);
- s = g_find_program_in_path (searchfor);
- if (s == NULL) {
- g_setenv ("PATH", path, TRUE);
- return FAILED ("It should find '%s' in the current directory.", searchfor);
- }
- g_free (s);
- g_setenv ("PATH", path, TRUE);
- return OK;
-}
-
-#ifndef DISABLE_FILESYSTEM_TESTS
-gchar *
-test_cwd ()
-{
- char *dir = g_get_current_dir ();
-#ifdef G_OS_WIN32
- const gchar *newdir = "C:\\Windows";
-#else
- const gchar *newdir = "/bin";
-#endif
-
- if (dir == NULL)
- return FAILED ("No current directory?");
- g_free (dir);
-
- if (chdir (newdir) == -1)
- return FAILED ("No %s?", newdir);
-
- dir = g_get_current_dir ();
- if (strcmp (dir, newdir) != 0)
- return FAILED("Did not go to %s?", newdir);
- g_free (dir);
-
- return OK;
-}
-#else
-gchar *
-test_cwd ()
-{
- return OK;
-}
-#endif
-
-gchar *
-test_misc ()
-{
- const char *home = g_get_home_dir ();
- const char *tmp = g_get_tmp_dir ();
-
- if (home == NULL)
- return FAILED ("Where did my home go?");
-
- if (tmp == NULL)
- return FAILED ("Where did my /tmp go?");
-
- return OK;
-}
-
-static Test path_tests [] = {
- {"g_build_filename", test_buildfname},
- {"g_buildpath", test_buildpath},
- {"g_path_get_dirname", test_dirname},
- {"g_path_get_basename", test_basename},
- {"g_find_program_in_path", test_ppath},
- {"g_find_program_in_path2", test_ppath2},
- {"test_cwd", test_cwd },
- {"test_misc", test_misc },
- {NULL, NULL}
-};
-
-DEFINE_TEST_GROUP_INIT(path_tests_init, path_tests)
-
-
+++ /dev/null
-#include <config.h>
-#include <glib.h>
-#include <string.h>
-#include <stdlib.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#include <stdio.h>
-#include "test.h"
-
-#define MATCH(pat,string,error_if,msg) \
- spec = g_pattern_spec_new (pat); \
- res = g_pattern_match_string (spec, string); \
- if (res == error_if) \
- return FAILED (msg " returned %s", res ? "TRUE" : "FALSE"); \
- g_pattern_spec_free (spec);
-
-#define TEST_MATCH(pat,string,n) MATCH (pat, string, FALSE, "MATCH " #n)
-#define TEST_NO_MATCH(pat,string,n) MATCH (pat, string,TRUE, "NO_MATCH " #n)
-
-RESULT
-test_pattern_spec ()
-{
- GPatternSpec *spec;
- gboolean res;
-
- /* spec = g_pattern_spec_new (NULL); */
- TEST_MATCH ("*", "hola", 1);
- TEST_MATCH ("hola", "hola", 2);
- TEST_MATCH ("????", "hola", 3);
- TEST_MATCH ("???a", "hola", 4);
- TEST_MATCH ("h??a", "hola", 5);
- TEST_MATCH ("h??*", "hola", 6);
- TEST_MATCH ("h*", "hola", 7);
- TEST_MATCH ("*hola", "hola", 8);
- TEST_MATCH ("*l*", "hola", 9);
- TEST_MATCH ("h*??", "hola", 10);
- TEST_MATCH ("h*???", "hola", 11);
- TEST_MATCH ("?o??", "hola", 12);
- TEST_MATCH ("*h*o*l*a*", "hola", 13);
- TEST_MATCH ("h*o*l*a", "hola", 14);
- TEST_MATCH ("h?*?", "hola", 15);
-
- TEST_NO_MATCH ("", "hola", 1);
- TEST_NO_MATCH ("?????", "hola", 2);
- TEST_NO_MATCH ("???", "hola", 3);
- TEST_NO_MATCH ("*o", "hola", 4);
- TEST_NO_MATCH ("h", "hola", 5);
- TEST_NO_MATCH ("h*????", "hola", 6);
-
- return OK;
-}
-
-static Test pattern_tests [] = {
- {"g_pattern_spec*", test_pattern_spec},
- {NULL, NULL}
-};
-
-DEFINE_TEST_GROUP_INIT(pattern_tests_init, pattern_tests)
-
-
+++ /dev/null
-#include <stdio.h>
-#include <glib.h>
-#include "test.h"
-
-/* Redefine the private structure only to verify proper allocations */
-typedef struct _GPtrArrayPriv {
- gpointer *pdata;
- guint len;
- guint size;
-} GPtrArrayPriv;
-
-/* Don't add more than 32 items to this please */
-static const char *items [] = {
- "Apples", "Oranges", "Plumbs", "Goats", "Snorps", "Grapes",
- "Tickle", "Place", "Coffee", "Cookies", "Cake", "Cheese",
- "Tseng", "Holiday", "Avenue", "Smashing", "Water", "Toilet",
- NULL
-};
-
-static GPtrArray *ptrarray_alloc_and_fill(guint *item_count)
-{
- GPtrArray *array = g_ptr_array_new();
- gint i;
-
- for(i = 0; items[i] != NULL; i++) {
- g_ptr_array_add(array, (gpointer)items[i]);
- }
-
- if(item_count != NULL) {
- *item_count = i;
- }
-
- return array;
-}
-
-static guint guess_size(guint length)
-{
- guint size = 1;
-
- while(size < length) {
- size <<= 1;
- }
-
- return size;
-}
-
-RESULT ptrarray_alloc()
-{
- GPtrArrayPriv *array;
- guint i;
-
- array = (GPtrArrayPriv *)ptrarray_alloc_and_fill(&i);
-
- if(array->size != guess_size(array->len)) {
- return FAILED("Size should be %d, but it is %d",
- guess_size(array->len), array->size);
- }
-
- if(array->len != i) {
- return FAILED("Expected %d node(s) in the array", i);
- }
-
- g_ptr_array_free((GPtrArray *)array, TRUE);
-
- return OK;
-}
-
-RESULT ptrarray_for_iterate()
-{
- GPtrArray *array = ptrarray_alloc_and_fill(NULL);
- guint i;
-
- for(i = 0; i < array->len; i++) {
- char *item = (char *)g_ptr_array_index(array, i);
- if(item != items[i]) {
- return FAILED(
- "Expected item at %d to be %s, but it was %s",
- i, items[i], item);
- }
- }
-
- g_ptr_array_free(array, TRUE);
-
- return OK;
-}
-
-static gint foreach_iterate_index = 0;
-static char *foreach_iterate_error = NULL;
-
-void foreach_callback(gpointer data, gpointer user_data)
-{
- char *item = (char *)data;
- const char *item_cmp = items[foreach_iterate_index++];
-
- if(foreach_iterate_error != NULL) {
- return;
- }
-
- if(item != item_cmp) {
- foreach_iterate_error = FAILED(
- "Expected item at %d to be %s, but it was %s",
- foreach_iterate_index - 1, item_cmp, item);
- }
-}
-
-RESULT ptrarray_foreach_iterate()
-{
- GPtrArray *array = ptrarray_alloc_and_fill(NULL);
-
- foreach_iterate_index = 0;
- foreach_iterate_error = NULL;
-
- g_ptr_array_foreach(array, foreach_callback, array);
-
- g_ptr_array_free(array, TRUE);
-
- return foreach_iterate_error;
-}
-
-RESULT ptrarray_set_size()
-{
- GPtrArray *array = g_ptr_array_new();
- guint i, grow_length = 50;
-
- g_ptr_array_add(array, (gpointer)items[0]);
- g_ptr_array_add(array, (gpointer)items[1]);
- g_ptr_array_set_size(array, grow_length);
-
- if(array->len != grow_length) {
- return FAILED("Array length should be 50, it is %d", array->len);
- } else if(array->pdata[0] != items[0]) {
- return FAILED("Item 0 was overwritten, should be %s", items[0]);
- } else if(array->pdata[1] != items[1]) {
- return FAILED("Item 1 was overwritten, should be %s", items[1]);
- }
-
- for(i = 2; i < array->len; i++) {
- if(array->pdata[i] != NULL) {
- return FAILED("Item %d is not NULL, it is %p", i, array->pdata[i]);
- }
- }
-
- g_ptr_array_free(array, TRUE);
-
- return OK;
-}
-
-RESULT ptrarray_remove_index()
-{
- GPtrArray *array;
- guint i;
-
- array = ptrarray_alloc_and_fill(&i);
-
- g_ptr_array_remove_index(array, 0);
- if(array->pdata[0] != items[1]) {
- return FAILED("First item is not %s, it is %s", items[1],
- array->pdata[0]);
- }
-
- g_ptr_array_remove_index(array, array->len - 1);
-
- if(array->pdata[array->len - 1] != items[array->len]) {
- return FAILED("Last item is not %s, it is %s",
- items[array->len - 2], array->pdata[array->len - 1]);
- }
-
- g_ptr_array_free(array, TRUE);
-
- return OK;
-}
-
-RESULT ptrarray_remove_index_fast()
-{
- GPtrArray *array;
- guint i;
-
- array = ptrarray_alloc_and_fill(&i);
-
- g_ptr_array_remove_index_fast(array, 0);
- if(array->pdata[0] != items[array->len]) {
- return FAILED("First item is not %s, it is %s", items[array->len],
- array->pdata[0]);
- }
-
- g_ptr_array_remove_index_fast(array, array->len - 1);
- if(array->pdata[array->len - 1] != items[array->len - 1]) {
- return FAILED("Last item is not %s, it is %s",
- items[array->len - 1], array->pdata[array->len - 1]);
- }
-
- g_ptr_array_free(array, TRUE);
-
- return OK;
-}
-
-RESULT ptrarray_remove()
-{
- GPtrArray *array;
- guint i;
-
- array = ptrarray_alloc_and_fill(&i);
-
- g_ptr_array_remove(array, (gpointer)items[7]);
-
- if(!g_ptr_array_remove(array, (gpointer)items[4])) {
- return FAILED("Item %s not removed", items[4]);
- }
-
- if(g_ptr_array_remove(array, (gpointer)items[4])) {
- return FAILED("Item %s still in array after removal", items[4]);
- }
-
- if(array->pdata[array->len - 1] != items[array->len + 1]) {
- return FAILED("Last item in GPtrArray not correct");
- }
-
- g_ptr_array_free(array, TRUE);
-
- return OK;
-}
-
-static gint ptrarray_sort_compare(gconstpointer a, gconstpointer b)
-{
- gchar *stra = *(gchar **) a;
- gchar *strb = *(gchar **) b;
- return strcmp(stra, strb);
-}
-
-RESULT ptrarray_sort()
-{
- GPtrArray *array = g_ptr_array_new();
- guint i;
- gchar *letters [] = { "A", "B", "C", "D", "E" };
-
- g_ptr_array_add(array, letters[0]);
- g_ptr_array_add(array, letters[1]);
- g_ptr_array_add(array, letters[2]);
- g_ptr_array_add(array, letters[3]);
- g_ptr_array_add(array, letters[4]);
-
- g_ptr_array_sort(array, ptrarray_sort_compare);
-
- for(i = 0; i < array->len; i++) {
- if(array->pdata[i] != letters[i]) {
- return FAILED("Array out of order, expected %s got %s at position %d",
- letters [i], (gchar *) array->pdata [i], i);
- }
- }
-
- g_ptr_array_free(array, TRUE);
-
- return OK;
-}
-
-static gint ptrarray_sort_compare_with_data (gconstpointer a, gconstpointer b, gpointer user_data)
-{
- gchar *stra = *(gchar **) a;
- gchar *strb = *(gchar **) b;
-
- if (strcmp (user_data, "this is the data for qsort") != 0)
- fprintf (stderr, "oops at compare with_data\n");
-
- return strcmp(stra, strb);
-}
-
-RESULT ptrarray_sort_with_data ()
-{
- GPtrArray *array = g_ptr_array_new();
- guint i;
- gchar *letters [] = { "A", "B", "C", "D", "E" };
-
- g_ptr_array_add(array, letters[4]);
- g_ptr_array_add(array, letters[1]);
- g_ptr_array_add(array, letters[2]);
- g_ptr_array_add(array, letters[0]);
- g_ptr_array_add(array, letters[3]);
-
- g_ptr_array_sort_with_data(array, ptrarray_sort_compare_with_data, "this is the data for qsort");
-
- for(i = 0; i < array->len; i++) {
- if(array->pdata[i] != letters[i]) {
- return FAILED("Array out of order, expected %s got %s at position %d",
- letters [i], (gchar *) array->pdata [i], i);
- }
- }
-
- g_ptr_array_free(array, TRUE);
-
- return OK;
-}
-
-RESULT ptrarray_remove_fast()
-{
- GPtrArray *array = g_ptr_array_new();
- gchar *letters [] = { "A", "B", "C", "D", "E" };
-
- if (g_ptr_array_remove_fast (array, NULL))
- return FAILED ("Removing NULL succeeded");
-
- g_ptr_array_add(array, letters[0]);
- if (!g_ptr_array_remove_fast (array, letters[0]) || array->len != 0)
- return FAILED ("Removing last element failed");
-
- g_ptr_array_add(array, letters[0]);
- g_ptr_array_add(array, letters[1]);
- g_ptr_array_add(array, letters[2]);
- g_ptr_array_add(array, letters[3]);
- g_ptr_array_add(array, letters[4]);
-
- if (!g_ptr_array_remove_fast (array, letters[0]) || array->len != 4)
- return FAILED ("Removing first element failed");
-
- if (array->pdata [0] != letters [4])
- return FAILED ("First element wasn't replaced with last upon removal");
-
- if (g_ptr_array_remove_fast (array, letters[0]))
- return FAILED ("Succedeed removing a non-existing element");
-
- if (!g_ptr_array_remove_fast (array, letters[3]) || array->len != 3)
- return FAILED ("Failed removing \"D\"");
-
- if (!g_ptr_array_remove_fast (array, letters[1]) || array->len != 2)
- return FAILED ("Failed removing \"B\"");
-
- if (array->pdata [0] != letters [4] || array->pdata [1] != letters [2])
- return FAILED ("Last two elements are wrong");
- g_ptr_array_free(array, TRUE);
-
- return OK;
-}
-
-static Test ptrarray_tests [] = {
- {"alloc", ptrarray_alloc},
- {"for_iterate", ptrarray_for_iterate},
- {"foreach_iterate", ptrarray_foreach_iterate},
- {"set_size", ptrarray_set_size},
- {"remove_index", ptrarray_remove_index},
- {"remove_index_fast", ptrarray_remove_index_fast},
- {"remove", ptrarray_remove},
- {"sort", ptrarray_sort},
- {"remove_fast", ptrarray_remove_fast},
- {"sort_with_data", ptrarray_sort_with_data},
- {NULL, NULL}
-};
-
-DEFINE_TEST_GROUP_INIT(ptrarray_tests_init, ptrarray_tests)
-
-
+++ /dev/null
-#include <stdio.h>
-#include <string.h>
-#include <glib.h>
-#include "test.h"
-
-RESULT
-test_queue_push ()
-{
- GQueue *queue = g_queue_new ();
-
- g_queue_push_head (queue, "foo");
- g_queue_push_head (queue, "bar");
- g_queue_push_head (queue, "baz");
-
- if (queue->length != 3)
- return FAILED ("push failed");
-
- if (NULL != queue->head->prev)
- return FAILED ("HEAD: prev is wrong");
- if (strcmp ("baz", queue->head->data))
- return FAILED ("HEAD: First element is wrong");
- if (strcmp ("bar", queue->head->next->data))
- return FAILED ("HEAD: Second element is wrong");
- if (strcmp ("foo", queue->head->next->next->data))
- return FAILED ("HEAD: Third element is wrong");
- if (NULL != queue->head->next->next->next)
- return FAILED ("HEAD: End is wrong");
-
- if (NULL != queue->tail->next)
- return FAILED ("TAIL: next is wrong");
- if (strcmp ("foo", queue->tail->data))
- return FAILED ("TAIL: Third element is wrong");
- if (strcmp ("bar", queue->tail->prev->data))
- return FAILED ("TAIL: Second element is wrong");
- if (strcmp ("baz", queue->tail->prev->prev->data))
- return FAILED ("TAIL: First element is wrong");
- if (NULL != queue->tail->prev->prev->prev)
- return FAILED ("TAIL: End is wrong");
-
- g_queue_free (queue);
- return OK;
-}
-
-RESULT
-test_queue_push_tail ()
-{
- GQueue *queue = g_queue_new ();
-
- g_queue_push_tail (queue, "baz");
- g_queue_push_tail (queue, "bar");
- g_queue_push_tail (queue, "foo");
-
- if (queue->length != 3)
- return FAILED ("push failed");
-
- if (NULL != queue->head->prev)
- return FAILED ("HEAD: prev is wrong");
- if (strcmp ("baz", queue->head->data))
- return FAILED ("HEAD: First element is wrong");
- if (strcmp ("bar", queue->head->next->data))
- return FAILED ("HEAD: Second element is wrong");
- if (strcmp ("foo", queue->head->next->next->data))
- return FAILED ("HEAD: Third element is wrong");
- if (NULL != queue->head->next->next->next)
- return FAILED ("HEAD: End is wrong");
-
- if (NULL != queue->tail->next)
- return FAILED ("TAIL: next is wrong");
- if (strcmp ("foo", queue->tail->data))
- return FAILED ("TAIL: Third element is wrong");
- if (strcmp ("bar", queue->tail->prev->data))
- return FAILED ("TAIL: Second element is wrong");
- if (strcmp ("baz", queue->tail->prev->prev->data))
- return FAILED ("TAIL: First element is wrong");
- if (NULL != queue->tail->prev->prev->prev)
- return FAILED ("TAIL: End is wrong");
-
- g_queue_free (queue);
- return OK;
-}
-
-RESULT
-test_queue_pop ()
-{
- GQueue *queue = g_queue_new ();
- gpointer data;
-
- g_queue_push_head (queue, "foo");
- g_queue_push_head (queue, "bar");
- g_queue_push_head (queue, "baz");
-
- data = g_queue_pop_head (queue);
- if (strcmp ("baz", data))
- return FAILED ("expect baz.");
-
- data = g_queue_pop_head (queue);
- if (strcmp ("bar", data))
- return FAILED ("expect bar.");
-
- data = g_queue_pop_head (queue);
- if (strcmp ("foo", data))
- return FAILED ("expect foo.");
-
- if (g_queue_is_empty (queue) == FALSE)
- return FAILED ("expect is_empty.");
-
- if (queue->length != 0)
- return FAILED ("expect 0 length .");
-
- g_queue_push_head (queue, "foo");
- g_queue_push_head (queue, "bar");
- g_queue_push_head (queue, "baz");
-
- g_queue_pop_head (queue);
-
- if (NULL != queue->head->prev)
- return FAILED ("HEAD: prev is wrong");
- if (strcmp ("bar", queue->head->data))
- return FAILED ("HEAD: Second element is wrong");
- if (strcmp ("foo", queue->head->next->data))
- return FAILED ("HEAD: Third element is wrong");
- if (NULL != queue->head->next->next)
- return FAILED ("HEAD: End is wrong");
-
- if (NULL != queue->tail->next)
- return FAILED ("TAIL: next is wrong");
- if (strcmp ("foo", queue->tail->data))
- return FAILED ("TAIL: Second element is wrong");
- if (strcmp ("bar", queue->tail->prev->data))
- return FAILED ("TAIL: First element is wrong");
- if (NULL != queue->tail->prev->prev)
- return FAILED ("TAIL: End is wrong");
-
- g_queue_free (queue);
- return OK;
-}
-
-RESULT
-test_queue_new ()
-{
- GQueue *queue = g_queue_new ();
-
- if (queue->length != 0)
- return FAILED ("expect length == 0");
-
- if (queue->head != NULL)
- return FAILED ("expect head == NULL");
-
- if (queue->tail != NULL)
- return FAILED ("expect tail == NULL");
-
- g_queue_free (queue);
- return OK;
-}
-
-RESULT
-test_queue_is_empty ()
-{
- GQueue *queue = g_queue_new ();
-
- if (g_queue_is_empty (queue) == FALSE)
- return FAILED ("new queue should be empty");
-
- g_queue_push_head (queue, "foo");
-
- if (g_queue_is_empty (queue) == TRUE)
- return FAILED ("expected TRUE");
-
- g_queue_free (queue);
-
- return OK;
-}
-
-static Test queue_tests [] = {
- { "push", test_queue_push},
- {"push_tail", test_queue_push_tail},
- { "pop", test_queue_pop},
- { "new", test_queue_new},
- {"is_empty", test_queue_is_empty},
- {NULL, NULL}
-};
-
-DEFINE_TEST_GROUP_INIT(queue_tests_init, queue_tests)
-
+++ /dev/null
-#include <glib.h>
-#include <string.h>
-#include <stdio.h>
-#include "test.h"
-
-RESULT
-test_shell_argv1 ()
-{
- GError *error;
- gint argc;
- gchar **argv;
- gboolean ret;
-
- /* The next line prints a critical error and returns FALSE
- ret = g_shell_parse_argv (NULL, NULL, NULL, NULL);
- */
- ret = g_shell_parse_argv ("", NULL, NULL, NULL);
- if (ret)
- return FAILED ("1. It should return FALSE");
-
- ret = g_shell_parse_argv ("hola", NULL, NULL, NULL);
- if (!ret)
- return FAILED ("2. It should return TRUE");
-
- argc = 0;
- ret = g_shell_parse_argv ("hola", &argc, NULL, NULL);
- if (!ret)
- return FAILED ("3. It should return TRUE");
- if (argc != 1)
- return FAILED ("4. argc was %d", argc);
-
- argc = 0;
- ret = g_shell_parse_argv ("hola bola", &argc, NULL, NULL);
- if (!ret)
- return FAILED ("5. It should return TRUE");
- if (argc != 2)
- return FAILED ("6. argc was %d", argc);
-
- argc = 0;
- ret = g_shell_parse_argv ("hola bola", &argc, &argv, NULL);
- if (!ret)
- return FAILED ("7. It should return TRUE");
- if (argc != 2)
- return FAILED ("8. argc was %d", argc);
- if (strcmp (argv [0], "hola"))
- return FAILED ("9. argv[0] was %s", argv [0]);
- if (strcmp (argv [1], "bola"))
- return FAILED ("10. argv[1] was %s", argv [1]);
-
- g_strfreev (argv);
- argv = NULL;
- argc = 0;
- error = NULL;
- ret = g_shell_parse_argv ("hola 'bola'", &argc, &argv, &error);
- if (!ret)
- return FAILED ("11. It should return TRUE");
- if (argc != 2)
- return FAILED ("12. argc was %d expected 2", argc);
- if (strcmp (argv [0], "hola"))
- return FAILED ("13. argv[0] was %s", argv [0]);
- if (strcmp (argv [1], "bola"))
- return FAILED ("14. argv[1] was %s", argv [1]);
- if (error != NULL)
- return FAILED ("15. error is not null");
-
-
- g_strfreev (argv);
- argv = NULL;
- argc = 0;
- error = NULL;
- ret = g_shell_parse_argv ("hola '' 'bola'", &argc, &argv, &error);
- if (!ret)
- return FAILED ("16. It should return TRUE");
- if (argc != 3)
- return FAILED ("17. argc was %d expected 3", argc);
- if (strcmp (argv [0], "hola"))
- return FAILED ("18. argv[0] was %s", argv [0]);
- if (strcmp (argv [1], ""))
- return FAILED ("19. argv[2] was %s", argv [1]);
- if (strcmp (argv [2], "bola"))
- return FAILED ("19. argv[2] was %s", argv [2]);
- if (error != NULL)
- return FAILED ("20. error is not null");
-
- g_strfreev (argv);
- argv = NULL;
- argc = 0;
- error = NULL;
- ret = g_shell_parse_argv ("hola'' bola", &argc, &argv, &error);
- if (!ret)
- return FAILED ("21. It should return TRUE");
- if (argc != 2)
- return FAILED ("22. argc was %d expected 2", argc);
- if (strcmp (argv [0], "hola"))
- return FAILED ("23. argv[0] was %s", argv [0]);
- if (strcmp (argv [1], "bola"))
- return FAILED ("24. argv[2] was %s", argv [1]);
- if (error != NULL)
- return FAILED ("25. error is not null");
-
- return OK;
-}
-
-RESULT
-test_shell_argv2 ()
-{
- GError *error;
- gint argc;
- gchar **argv;
- gboolean ret;
-
- argv = NULL;
- argc = 0;
- error = NULL;
- ret = g_shell_parse_argv ("hola \"bola\"", &argc, &argv, &error);
- if (!ret)
- return FAILED ("1. It should return TRUE");
- if (argc != 2)
- return FAILED ("2. argc was %d expected 2", argc);
- if (strcmp (argv [0], "hola"))
- return FAILED ("3. argv[0] was %s", argv [0]);
- if (strcmp (argv [1], "bola"))
- return FAILED ("4. argv[1] was %s", argv [1]);
- if (error != NULL)
- return FAILED ("5. error is not null");
-
- g_strfreev (argv);
- argv = NULL;
- argc = 0;
- error = NULL;
- ret = g_shell_parse_argv ("hola \"\" \"bola \"", &argc, &argv, &error);
- if (!ret)
- return FAILED ("6. It should return TRUE");
- if (argc != 3)
- return FAILED ("7. argc was %d expected 3", argc);
- if (strcmp (argv [0], "hola"))
- return FAILED ("8. argv[0] was %s", argv [0]);
- if (strcmp (argv [1], ""))
- return FAILED ("9. argv[2] was %s", argv [1]);
- if (strcmp (argv [2], "bola "))
- return FAILED ("10. argv[2] was %s", argv [2]);
- if (error != NULL)
- return FAILED ("11. error is not null");
-
- g_strfreev (argv);
- argv = NULL;
- argc = 0;
- error = NULL;
- ret = g_shell_parse_argv ("hola\n\t \"\t\" \"bola \"", &argc, &argv, &error);
- if (!ret)
- return FAILED ("10. It should return TRUE");
- if (argc != 3)
- return FAILED ("11. argc was %d expected 3", argc);
- if (strcmp (argv [0], "hola"))
- return FAILED ("12. argv[0] was %s", argv [0]);
- if (strcmp (argv [1], "\t"))
- return FAILED ("13. argv[2] was %s", argv [1]);
- if (strcmp (argv [2], "bola "))
- return FAILED ("14. argv[2] was %s", argv [2]);
- if (error != NULL)
- return FAILED ("15. error is not null");
-
- g_strfreev (argv);
- argv = NULL;
- argc = 0;
- error = NULL;
- ret = g_shell_parse_argv ("hola\n\t \\\n \"\t\" \"bola \"", &argc, &argv, &error);
- if (!ret)
- return FAILED ("16. It should return TRUE");
- if (argc != 3)
- return FAILED ("17. argc was %d expected 3", argc);
- if (strcmp (argv [0], "hola"))
- return FAILED ("18. argv[0] was %s", argv [0]);
- if (strcmp (argv [1], "\t"))
- return FAILED ("19. argv[2] was %s", argv [1]);
- if (strcmp (argv [2], "bola "))
- return FAILED ("20. argv[2] was %s", argv [2]);
- if (error != NULL)
- return FAILED ("21. error is not null");
-
- g_strfreev (argv);
- return OK;
-}
-
-RESULT
-test_shell_argv3 ()
-{
- GError *error;
- gint argc;
- gchar **argv;
- gboolean ret;
-
- argv = NULL;
- argc = 0;
- error = NULL;
- ret = g_shell_parse_argv ("hola \"bola", &argc, &argv, &error);
- if (ret)
- return FAILED ("1. It should return FALSE");
- if (argc != 0)
- return FAILED ("2. argc was %d expected 0", argc);
- if (argv != NULL)
- return FAILED ("3. argv[0] was %s", argv [0]);
- if (error == NULL)
- return FAILED ("4. error is null");
-
- /* Text ended before matching quote was found for ". (The text was 'hola "bola') */
- g_error_free (error);
- error = NULL;
- ret = g_shell_parse_argv ("hola \\\"bola", &argc, &argv, &error);
- if (!ret)
- return FAILED ("5. It should return TRUE");
- if (argc != 2)
- return FAILED ("6. argc was %d expected 2", argc);
- if (strcmp (argv [0], "hola"))
- return FAILED ("18. argv[0] was %s", argv [0]);
- if (strcmp (argv [1], "\"bola"))
- return FAILED ("18. argv[1] was %s", argv [1]);
- if (error != NULL)
- return FAILED ("8. error is not null");
-
- g_strfreev (argv);
- argv = NULL;
- argc = 0;
- ret = g_shell_parse_argv ("hola \"\n\\'bola\"", &argc, &argv, &error);
- if (!ret)
- return FAILED ("9. It should return TRUE. %s", error->message);
- if (argc != 2)
- return FAILED ("10. argc was %d expected 2", argc);
- if (strcmp (argv [0], "hola"))
- return FAILED ("11. argv[0] was %s", argv [0]);
- if (strcmp (argv [1], "\n\\'bola"))
- return FAILED ("12. argv[1] was %s", argv [1]);
- if (error != NULL)
- return FAILED ("13. error is not null");
-
- g_strfreev (argv);
- argv = NULL;
- argc = 0;
- return OK;
-}
-
-// This was the 2.8 showstopper error
-RESULT
-test_shell_argv4 ()
-{
- GError *error;
- gint argc;
- gchar **argv;
- gboolean ret;
- char *str = "'/usr/bin/gnome-terminal' -e \"bash -c 'read -p \\\"Press any key to continue...\\\" -n1;'\"";
-
- argv = NULL;
- argc = 0;
- error = NULL;
- ret = g_shell_parse_argv (str, &argc, &argv, &error);
- if (!ret)
- return FAILED ("1. It should return TRUE");
- if (argc != 3)
- return FAILED ("2. argc was %d expected 3", argc);
- if (argv == NULL)
- return FAILED ("3. argv[0] was NULL");
- if (error != NULL)
- return FAILED ("4. error was set");
-
- if (strcmp (argv [0], "/usr/bin/gnome-terminal"))
- return FAILED ("5. Expected /usr/bin/gnome-terminal got %s", argv [0]);
- if (strcmp (argv [1], "-e"))
- return FAILED ("6. Expected -e, got: %s", argv [1]);
- if (strcmp (argv [2], "bash -c 'read -p \"Press any key to continue...\" -n1;'"))
- return FAILED ("7. Got unexpected result: %s\n", argv [2]);
-
- return OK;
-}
-
-// This is https://bugzilla.novell.com/show_bug.cgi?id=655896
-RESULT
-test_shell_argv5 ()
-{
- GError *error;
- gint argc;
- gchar **argv;
- gboolean ret;
- char *str = "echo \"foo\",\"bar\"";
-
- argv = NULL;
- argc = 0;
- error = NULL;
- ret = g_shell_parse_argv (str, &argc, &argv, &error);
- if (!ret)
- return FAILED ("1. It should return TRUE");
- if (argc != 2)
- return FAILED ("2. argc was %d expected 2", argc);
- if (argv == NULL)
- return FAILED ("3. argv[0] was NULL");
- if (error != NULL)
- return FAILED ("4. error was set");
-
- if (strcmp (argv [0], "echo"))
- return FAILED ("5. Expected echo got %s", argv [0]);
- if (strcmp (argv [1], "foo,bar"))
- return FAILED ("6. Expected foo,bar, got: %s", argv [1]);
-
- return OK;
-}
-
-RESULT
-test_quote ()
-{
- if (strcmp (g_shell_quote ("foo"), "'foo'"))
- return FAILED ("Should return 'foo'");
-
- if (strcmp (g_shell_quote ("foo'bar"), "'foo'\\''bar'"))
- return FAILED ("Should return 'foo'\\''bar'");
-
- if (strcmp (g_shell_quote ("foo bar"), "'foo bar'"))
- return FAILED ("Should return 'foo bar'");
- return OK;
-}
-
-static Test shell_tests [] = {
- {"test_shell_argv1", test_shell_argv1},
- {"test_shell_argv2", test_shell_argv2},
- {"test_shell_argv3", test_shell_argv3},
- {"test_shell_argv4", test_shell_argv4},
- {"test_shell_argv5", test_shell_argv5},
- {"g_shell_quote", test_quote},
- {NULL, NULL}
-};
-
-DEFINE_TEST_GROUP_INIT(shell_tests_init, shell_tests)
-
+++ /dev/null
-/*
- * Tests to ensure that our type definitions are correct
- *
- * These depend on -Werror, -Wall being set to catch the build error.
- */
-#include <stdio.h>
-#ifndef _MSC_VER
-#include <stdint.h>
-#endif
-#include <string.h>
-#include <glib.h>
-#include "test.h"
-
-RESULT
-test_formats ()
-{
- char buffer [1024];
- gsize a = 1;
-
- sprintf (buffer, "%" G_GSIZE_FORMAT, a);
-
- return NULL;
-}
-
-RESULT
-test_ptrconv ()
-{
- int iv, iv2;
- unsigned int uv, uv2;
- gpointer ptr;
-
- iv = G_MAXINT32;
- ptr = GINT_TO_POINTER (iv);
- iv2 = GPOINTER_TO_INT (ptr);
- if (iv != iv2)
- return FAILED ("int to pointer and back conversions fail %d != %d", iv, iv2);
-
- iv = G_MININT32;
- ptr = GINT_TO_POINTER (iv);
- iv2 = GPOINTER_TO_INT (ptr);
- if (iv != iv2)
- return FAILED ("int to pointer and back conversions fail %d != %d", iv, iv2);
-
- iv = 1;
- ptr = GINT_TO_POINTER (iv);
- iv2 = GPOINTER_TO_INT (ptr);
- if (iv != iv2)
- return FAILED ("int to pointer and back conversions fail %d != %d", iv, iv2);
-
- iv = -1;
- ptr = GINT_TO_POINTER (iv);
- iv2 = GPOINTER_TO_INT (ptr);
- if (iv != iv2)
- return FAILED ("int to pointer and back conversions fail %d != %d", iv, iv2);
-
- iv = 0;
- ptr = GINT_TO_POINTER (iv);
- iv2 = GPOINTER_TO_INT (ptr);
- if (iv != iv2)
- return FAILED ("int to pointer and back conversions fail %d != %d", iv, iv2);
-
- uv = 0;
- ptr = GUINT_TO_POINTER (uv);
- uv2 = GPOINTER_TO_UINT (ptr);
- if (uv != uv2)
- return FAILED ("uint to pointer and back conversions fail %u != %d", uv, uv2);
-
- uv = 1;
- ptr = GUINT_TO_POINTER (uv);
- uv2 = GPOINTER_TO_UINT (ptr);
- if (uv != uv2)
- return FAILED ("uint to pointer and back conversions fail %u != %d", uv, uv2);
-
- uv = UINT32_MAX;
- ptr = GUINT_TO_POINTER (uv);
- uv2 = GPOINTER_TO_UINT (ptr);
- if (uv != uv2)
- return FAILED ("uint to pointer and back conversions fail %u != %d", uv, uv2);
-
- return NULL;
-
-}
-
-typedef struct {
- int a;
- int b;
-} my_struct;
-
-RESULT
-test_offset ()
-{
- if (G_STRUCT_OFFSET (my_struct, a) != 0)
- return FAILED ("offset of a is not zero");
-
- if (G_STRUCT_OFFSET (my_struct, b) != 4 && G_STRUCT_OFFSET (my_struct, b) != 8)
- return FAILED ("offset of b is 4 or 8, macro might be busted");
-
- return OK;
-}
-
-static Test size_tests [] = {
- {"formats", test_formats},
- {"ptrconv", test_ptrconv},
- {"g_struct_offset", test_offset},
- {NULL, NULL}
-};
-
-DEFINE_TEST_GROUP_INIT(size_tests_init, size_tests)
+++ /dev/null
-#include <stdio.h>
-#include <string.h>
-#include <glib.h>
-#include "test.h"
-
-
-RESULT
-test_slist_nth ()
-{
- char *foo = "foo";
- char *bar = "bar";
- char *baz = "baz";
- GSList *nth, *list;
- list = g_slist_prepend (NULL, baz);
- list = g_slist_prepend (list, bar);
- list = g_slist_prepend (list, foo);
-
- nth = g_slist_nth (list, 0);
- if (nth->data != foo)
- return FAILED ("nth failed. #0");
-
- nth = g_slist_nth (list, 1);
- if (nth->data != bar)
- return FAILED ("nth failed. #1");
-
- nth = g_slist_nth (list, 2);
- if (nth->data != baz)
- return FAILED ("nth failed. #2");
-
- nth = g_slist_nth (list, 3);
- if (nth)
- return FAILED ("nth failed. #3: %s", nth->data);
-
- g_slist_free (list);
- return OK;
-}
-
-RESULT
-test_slist_index ()
-{
- int i;
- char *foo = "foo";
- char *bar = "bar";
- char *baz = "baz";
- GSList *list;
- list = g_slist_prepend (NULL, baz);
- list = g_slist_prepend (list, bar);
- list = g_slist_prepend (list, foo);
-
- i = g_slist_index (list, foo);
- if (i != 0)
- return FAILED ("index failed. #0: %d", i);
-
- i = g_slist_index (list, bar);
- if (i != 1)
- return FAILED ("index failed. #1: %d", i);
-
- i = g_slist_index (list, baz);
- if (i != 2)
- return FAILED ("index failed. #2: %d", i);
-
- g_slist_free (list);
- return OK;
-}
-
-RESULT
-test_slist_append ()
-{
- GSList *foo;
- GSList *list = g_slist_append (NULL, "first");
- if (g_slist_length (list) != 1)
- return FAILED ("append(null,...) failed");
-
- foo = g_slist_append (list, "second");
- if (foo != list)
- return FAILED ("changed list head on non-empty");
-
- if (g_slist_length (list) != 2)
- return FAILED ("Append failed");
-
- g_slist_free (list);
- return OK;
-}
-
-RESULT
-test_slist_concat ()
-{
- GSList *foo = g_slist_prepend (NULL, "foo");
- GSList *bar = g_slist_prepend (NULL, "bar");
-
- GSList *list = g_slist_concat (foo, bar);
-
- if (g_slist_length (list) != 2)
- return FAILED ("Concat failed.");
-
- g_slist_free (list);
- return OK;
-}
-
-RESULT
-test_slist_find ()
-{
- GSList *list = g_slist_prepend (NULL, "three");
- GSList *found;
- char *data;
-
- list = g_slist_prepend (list, "two");
- list = g_slist_prepend (list, "one");
-
- data = "four";
- list = g_slist_append (list, data);
-
- found = g_slist_find (list, data);
-
- if (found->data != data)
- return FAILED ("Find failed");
-
- g_slist_free (list);
- return OK;
-}
-
-static gint
-find_custom (gconstpointer a, gconstpointer b)
-{
- return(strcmp (a, b));
-}
-
-RESULT
-test_slist_find_custom ()
-{
- GSList *list = NULL, *found;
- char *foo = "foo";
- char *bar = "bar";
- char *baz = "baz";
-
- list = g_slist_prepend (list, baz);
- list = g_slist_prepend (list, bar);
- list = g_slist_prepend (list, foo);
-
- found = g_slist_find_custom (list, baz, find_custom);
-
- if (found == NULL)
- return FAILED ("Find failed");
-
- g_slist_free (list);
-
- return OK;
-}
-
-RESULT
-test_slist_remove ()
-{
- GSList *list = g_slist_prepend (NULL, "three");
- char *one = "one";
- list = g_slist_prepend (list, "two");
- list = g_slist_prepend (list, one);
-
- list = g_slist_remove (list, one);
-
- if (g_slist_length (list) != 2)
- return FAILED ("Remove failed");
-
- if (strcmp ("two", list->data) != 0)
- return FAILED ("Remove failed");
-
- g_slist_free (list);
- return OK;
-}
-
-RESULT
-test_slist_remove_link ()
-{
- GSList *foo = g_slist_prepend (NULL, "a");
- GSList *bar = g_slist_prepend (NULL, "b");
- GSList *baz = g_slist_prepend (NULL, "c");
- GSList *list = foo;
-
- foo = g_slist_concat (foo, bar);
- foo = g_slist_concat (foo, baz);
-
- list = g_slist_remove_link (list, bar);
-
- if (g_slist_length (list) != 2)
- return FAILED ("remove_link failed #1");
-
- if (bar->next != NULL)
- return FAILED ("remove_link failed #2");
-
- g_slist_free (list);
- g_slist_free (bar);
-
- return OK;
-}
-
-static gint
-compare (gconstpointer a, gconstpointer b)
-{
- char *foo = (char *) a;
- char *bar = (char *) b;
-
- if (strlen (foo) < strlen (bar))
- return -1;
-
- return 1;
-}
-
-RESULT
-test_slist_insert_sorted ()
-{
- GSList *list = g_slist_prepend (NULL, "a");
- list = g_slist_append (list, "aaa");
-
- /* insert at the middle */
- list = g_slist_insert_sorted (list, "aa", compare);
- if (strcmp ("aa", list->next->data))
- return FAILED("insert_sorted failed #1");
-
- /* insert at the beginning */
- list = g_slist_insert_sorted (list, "", compare);
- if (strcmp ("", list->data))
- return FAILED ("insert_sorted failed #2");
-
- /* insert at the end */
- list = g_slist_insert_sorted (list, "aaaa", compare);
- if (strcmp ("aaaa", g_slist_last (list)->data))
- return FAILED ("insert_sorted failed #3");
-
- g_slist_free (list);
- return OK;
-}
-
-RESULT
-test_slist_insert_before ()
-{
- GSList *foo, *bar, *baz;
-
- foo = g_slist_prepend (NULL, "foo");
- foo = g_slist_insert_before (foo, NULL, "bar");
- bar = g_slist_last (foo);
-
- if (strcmp (bar->data, "bar"))
- return FAILED ("1");
-
- baz = g_slist_insert_before (foo, bar, "baz");
- if (foo != baz)
- return FAILED ("2");
-
- if (strcmp (foo->next->data, "baz"))
- return FAILED ("3: %s", foo->next->data);
-
- g_slist_free (foo);
- return OK;
-}
-
-#define N_ELEMS 100
-
-static int intcompare (gconstpointer p1, gconstpointer p2)
-{
- return GPOINTER_TO_INT (p1) - GPOINTER_TO_INT (p2);
-}
-
-static gboolean verify_sort (GSList *list, int len)
-{
- int prev = GPOINTER_TO_INT (list->data);
- len--;
- for (list = list->next; list; list = list->next) {
- int curr = GPOINTER_TO_INT (list->data);
- if (prev > curr)
- return FALSE;
- prev = curr;
-
- if (len == 0)
- return FALSE;
- len--;
- }
- return len == 0;
-}
-
-RESULT
-test_slist_sort ()
-{
- int i, j, mul;
- GSList *list = NULL;
-
- for (i = 0; i < N_ELEMS; ++i)
- list = g_slist_prepend (list, GINT_TO_POINTER (i));
- list = g_slist_sort (list, intcompare);
- if (!verify_sort (list, N_ELEMS))
- return FAILED ("decreasing list");
-
- g_slist_free (list);
-
- list = NULL;
- for (i = 0; i < N_ELEMS; ++i)
- list = g_slist_prepend (list, GINT_TO_POINTER (-i));
- list = g_slist_sort (list, intcompare);
- if (!verify_sort (list, N_ELEMS))
- return FAILED ("increasing list");
-
- g_slist_free (list);
-
- list = g_slist_prepend (NULL, GINT_TO_POINTER (0));
- for (i = 1; i < N_ELEMS; ++i) {
- list = g_slist_prepend (list, GINT_TO_POINTER (-i));
- list = g_slist_prepend (list, GINT_TO_POINTER (i));
- }
- list = g_slist_sort (list, intcompare);
- if (!verify_sort (list, 2*N_ELEMS-1))
- return FAILED ("alternating list");
-
- g_slist_free (list);
-
- list = NULL;
- mul = 1;
- for (i = 1; i < N_ELEMS; ++i) {
- mul = -mul;
- for (j = 0; j < i; ++j)
- list = g_slist_prepend (list, GINT_TO_POINTER (mul * j));
- }
- list = g_slist_sort (list, intcompare);
- if (!verify_sort (list, (N_ELEMS*N_ELEMS - N_ELEMS)/2))
- return FAILED ("wavering list");
-
- g_slist_free (list);
-
- return OK;
-}
-
-static Test slist_tests [] = {
- {"nth", test_slist_nth},
- {"index", test_slist_index},
- {"append", test_slist_append},
- {"concat", test_slist_concat},
- {"find", test_slist_find},
- {"find_custom", test_slist_find_custom},
- {"remove", test_slist_remove},
- {"remove_link", test_slist_remove_link},
- {"insert_sorted", test_slist_insert_sorted},
- {"insert_before", test_slist_insert_before},
- {"sort", test_slist_sort},
- {NULL, NULL}
-};
-
-DEFINE_TEST_GROUP_INIT(slist_tests_init, slist_tests)
-
+++ /dev/null
-#include <config.h>
-#include <glib.h>
-#include <string.h>
-#include <stdio.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#include "test.h"
-
-#ifdef G_OS_WIN32
-#include <io.h>
-#define read _read
-#define close _close
-#endif
-
-RESULT
-test_spawn_sync ()
-{
- gchar *out;
- gchar *err;
- gint status = -1;
- GError *error = NULL;
-
- if (!g_spawn_command_line_sync ("ls", &out, &err, &status, &error))
- return FAILED ("Error executing 'ls'");
-
- if (status != 0)
- return FAILED ("Status is %d", status);
-
- if (out == NULL || strlen (out) == 0)
- return FAILED ("Didn't get any output from ls!?");
-
- g_free (out);
- g_free (err);
- return OK;
-}
-
-RESULT
-test_spawn_async ()
-{
- /*
-gboolean
-g_spawn_async_with_pipes (const gchar *working_directory,
- gchar **argv,
- gchar **envp,
- GSpawnFlags flags,
- GSpawnChildSetupFunc child_setup,
- gpointer user_data,
- GPid *child_pid,
- gint *standard_input,
- gint *standard_output,
- gint *standard_error,
- GError **error) */
- char *argv [15];
- int stdout_fd = -1;
- char buffer [512];
- pid_t child_pid = 0;
-
- memset (argv, 0, 15 * sizeof (char *));
- argv [0] = "ls";
- if (!g_spawn_async_with_pipes (NULL, argv, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, &child_pid, NULL, &stdout_fd, NULL, NULL))
- return FAILED ("1 Failed to run ls");
- if (child_pid == 0)
- return FAILED ("2 child pid not returned");
- if (stdout_fd == -1)
- return FAILED ("3 out fd is -1");
-
- while (read (stdout_fd, buffer, 512) > 0);
- close (stdout_fd);
-
- return OK;
-}
-
-static Test spawn_tests [] = {
- {"g_shell_spawn_sync", test_spawn_sync},
- {"g_shell_spawn_async_with_pipes", test_spawn_async},
- {NULL, NULL}
-};
-
-DEFINE_TEST_GROUP_INIT(spawn_tests_init, spawn_tests)
-
-
+++ /dev/null
-#include <glib.h>
-#include <string.h>
-#include <stdio.h>
-#include "test.h"
-
-/* This test is just to be used with valgrind */
-RESULT
-test_strfreev ()
-{
- gchar **array = g_new (gchar *, 4);
- array [0] = g_strdup ("one");
- array [1] = g_strdup ("two");
- array [2] = g_strdup ("three");
- array [3] = NULL;
-
- g_strfreev (array);
- g_strfreev (NULL);
-
- return OK;
-}
-
-RESULT
-test_concat ()
-{
- gchar *x = g_strconcat ("Hello", ", ", "world", NULL);
- if (strcmp (x, "Hello, world") != 0)
- return FAILED("concat failed, got: %s", x);
- g_free (x);
- return OK;
-}
-
-RESULT
-test_split ()
-{
- const gchar *to_split = "Hello world, how are we doing today?";
- gint i;
- gchar **v;
-
- v= g_strsplit(to_split, " ", 0);
-
- if(v == NULL) {
- return FAILED("split failed, got NULL vector (1)");
- }
-
- for(i = 0; v[i] != NULL; i++);
- if(i != 7) {
- return FAILED("split failed, expected 7 tokens, got %d", i);
- }
-
- g_strfreev(v);
-
- v = g_strsplit(to_split, ":", -1);
- if(v == NULL) {
- return FAILED("split failed, got NULL vector (2)");
- }
-
- for(i = 0; v[i] != NULL; i++);
- if(i != 1) {
- return FAILED("split failed, expected 1 token, got %d", i);
- }
-
- if(strcmp(v[0], to_split) != 0) {
- return FAILED("expected vector[0] to be '%s' but it was '%s'",
- to_split, v[0]);
- }
- g_strfreev(v);
-
- v = g_strsplit ("", ":", 0);
- if (v == NULL)
- return FAILED ("g_strsplit returned NULL");
- g_strfreev (v);
-
- v = g_strsplit ("/home/miguel/dingus", "/", 0);
- if (v [0][0] != 0)
- return FAILED ("Got a non-empty first element");
- g_strfreev (v);
-
- v = g_strsplit ("appdomain1, Version=0.0.0.0, Culture=neutral", ",", 4);
- if (strcmp (v [0], "appdomain1") != 0)
- return FAILED ("Invalid value");
-
- if (strcmp (v [1], " Version=0.0.0.0") != 0)
- return FAILED ("Invalid value");
-
- if (strcmp (v [2], " Culture=neutral") != 0)
- return FAILED ("Invalid value");
-
- if (v [3] != NULL)
- return FAILED ("Expected only 3 elements");
-
- g_strfreev (v);
-
- v = g_strsplit ("abcXYdefXghiXYjklYmno", "XY", 4);
- if (strcmp (v [0], "abc") != 0)
- return FAILED ("Invalid value 0");
-
- if (strcmp (v [1], "defXghi") != 0)
- return FAILED ("Invalid value 1");
-
- if (strcmp (v [2], "jklYmno") != 0)
- return FAILED ("Invalid value 2");
-
- if (v [3] != NULL)
- return FAILED ("Expected only 3 elements (1)");
-
- g_strfreev (v);
-
- v = g_strsplit ("abcXYdefXghiXYjklYmno", "XY", 2);
- if (strcmp (v [0], "abc") != 0)
- return FAILED ("Invalid value 3");
-
- if (strcmp (v [1], "defXghiXYjklYmno") != 0)
- return FAILED ("Invalid value 4");
-
- if (v [2] != NULL)
- return FAILED ("Expected only 2 elements (2)");
-
- g_strfreev (v);
-
- v = g_strsplit ("abcXYdefXghiXYjklYmnoXY", "XY", 3);
- if (strcmp (v [0], "abc") != 0)
- return FAILED ("Invalid value 5");
-
- if (strcmp (v [1], "defXghi") != 0)
- return FAILED ("Invalid value 6");
-
- if (strcmp (v [2], "jklYmnoXY") != 0)
- return FAILED ("Invalid value 7");
-
- if (v [3] != NULL)
- return FAILED ("Expected only 3 elements (3)");
-
- g_strfreev (v);
-
- v = g_strsplit ("abcXYXYXYdefXY", "XY", -1);
- if (strcmp (v [0], "abc") != 0)
- return FAILED ("Invalid value 8");
-
- if (strcmp (v [1], "") != 0)
- return FAILED ("Invalid value 9");
-
- if (strcmp (v [2], "") != 0)
- return FAILED ("Invalid value 10");
-
- if (strcmp (v [3], "def") != 0)
- return FAILED ("Invalid value 11");
-
- if (strcmp (v [4], "") != 0)
- return FAILED ("Invalid value 12");
-
- if (v [5] != NULL)
- return FAILED ("Expected only 5 elements (4)");
-
- g_strfreev (v);
-
- v = g_strsplit ("XYXYXYabcXYdef", "XY", -1);
- if (strcmp (v [0], "") != 0)
- return FAILED ("Invalid value 13");
-
- if (strcmp (v [1], "") != 0)
- return FAILED ("Invalid value 14");
-
- if (strcmp (v [2], "") != 0)
- return FAILED ("Invalid value 15");
-
- if (strcmp (v [3], "abc") != 0)
- return FAILED ("Invalid value 16");
-
- if (strcmp (v [4], "def") != 0)
- return FAILED ("Invalid value 17");
-
- if (v [5] != NULL)
- return FAILED ("Expected only 5 elements (5)");
-
- g_strfreev (v);
-
- v = g_strsplit ("value=", "=", 2);
- if (strcmp (v [0], "value") != 0)
- return FAILED ("Invalid value 18; expected 'value', got '%s'", v [0]);
- if (strcmp (v [1], "") != 0)
- return FAILED ("Invalid value 19; expected '', got '%s'", v [1]);
- if (v [2] != NULL)
- return FAILED ("Expected only 2 elements (6)");
-
- g_strfreev (v);
-
- return OK;
-}
-
-RESULT
-test_split_set ()
-{
- gchar **v;
-
- v = g_strsplit_set ("abcXYdefXghiXYjklYmno", "XY", 6);
- if (strcmp (v [0], "abc") != 0)
- return FAILED ("Invalid value 0");
-
- if (strcmp (v [1], "") != 0)
- return FAILED ("Invalid value 1");
-
- if (strcmp (v [2], "def") != 0)
- return FAILED ("Invalid value 2");
-
- if (strcmp (v [3], "ghi") != 0)
- return FAILED ("Invalid value 3");
-
- if (strcmp (v [4], "") != 0)
- return FAILED ("Invalid value 4");
-
- if (strcmp (v [5], "jklYmno") != 0)
- return FAILED ("Invalid value 5");
-
- if (v [6] != NULL)
- return FAILED ("Expected only 6 elements (1)");
-
- g_strfreev (v);
-
- v = g_strsplit_set ("abcXYdefXghiXYjklYmno", "XY", 3);
- if (strcmp (v [0], "abc") != 0)
- return FAILED ("Invalid value 6");
-
- if (strcmp (v [1], "") != 0)
- return FAILED ("Invalid value 7");
-
- if (strcmp (v [2], "defXghiXYjklYmno") != 0)
- return FAILED ("Invalid value 8");
-
- if (v [3] != NULL)
- return FAILED ("Expected only 3 elements (2)");
-
- g_strfreev (v);
-
- v = g_strsplit_set ("abcXdefYghiXjklYmnoX", "XY", 5);
- if (strcmp (v [0], "abc") != 0)
- return FAILED ("Invalid value 9");
-
- if (strcmp (v [1], "def") != 0)
- return FAILED ("Invalid value 10");
-
- if (strcmp (v [2], "ghi") != 0)
- return FAILED ("Invalid value 11");
-
- if (strcmp (v [3], "jkl") != 0)
- return FAILED ("Invalid value 12");
-
- if (strcmp (v [4], "mnoX") != 0)
- return FAILED ("Invalid value 13");
-
- if (v [5] != NULL)
- return FAILED ("Expected only 5 elements (5)");
-
- g_strfreev (v);
-
- v = g_strsplit_set ("abcXYXdefXY", "XY", -1);
- if (strcmp (v [0], "abc") != 0)
- return FAILED ("Invalid value 14");
-
- if (strcmp (v [1], "") != 0)
- return FAILED ("Invalid value 15");
-
- if (strcmp (v [2], "") != 0)
- return FAILED ("Invalid value 16");
-
- if (strcmp (v [3], "def") != 0)
- return FAILED ("Invalid value 17");
-
- if (strcmp (v [4], "") != 0)
- return FAILED ("Invalid value 18");
-
- if (strcmp (v [5], "") != 0)
- return FAILED ("Invalid value 19");
-
- if (v [6] != NULL)
- return FAILED ("Expected only 6 elements (4)");
-
- g_strfreev (v);
-
- v = g_strsplit_set ("XYXabcXYdef", "XY", -1);
- if (strcmp (v [0], "") != 0)
- return FAILED ("Invalid value 20");
-
- if (strcmp (v [1], "") != 0)
- return FAILED ("Invalid value 21");
-
- if (strcmp (v [2], "") != 0)
- return FAILED ("Invalid value 22");
-
- if (strcmp (v [3], "abc") != 0)
- return FAILED ("Invalid value 23");
-
- if (strcmp (v [4], "") != 0)
- return FAILED ("Invalid value 24");
-
- if (strcmp (v [5], "def") != 0)
- return FAILED ("Invalid value 25");
-
- if (v [6] != NULL)
- return FAILED ("Expected only 6 elements (5)");
-
- g_strfreev (v);
-
- return OK;
-}
-
-RESULT
-test_strreverse ()
-{
- RESULT res = OK;
- gchar *a = g_strdup ("onetwothree");
- gchar *a_target = "eerhtowteno";
- gchar *b = g_strdup ("onetwothre");
- gchar *b_target = "erhtowteno";
- gchar *c = g_strdup ("");
- gchar *c_target = "";
-
- g_strreverse (a);
- if (strcmp (a, a_target)) {
- res = FAILED("strreverse failed. Expecting: '%s' and got '%s'\n", a, a_target);
- goto cleanup;
- }
-
- g_strreverse (b);
- if (strcmp (b, b_target)) {
- res = FAILED("strreverse failed. Expecting: '%s' and got '%s'\n", b, b_target);
- goto cleanup;
- }
-
- g_strreverse (c);
- if (strcmp (c, c_target)) {
- res = FAILED("strreverse failed. Expecting: '%s' and got '%s'\n", b, b_target);
- goto cleanup;
- }
-
-cleanup:
- g_free (c);
- g_free (b);
- g_free (a);
- return res;
-}
-
-RESULT
-test_strjoin ()
-{
- char *s;
-
- s = g_strjoin (NULL, "a", "b", NULL);
- if (strcmp (s, "ab") != 0)
- return FAILED ("Join of two strings with no separator fails");
- g_free (s);
-
- s = g_strjoin ("", "a", "b", NULL);
- if (strcmp (s, "ab") != 0)
- return FAILED ("Join of two strings with empty separator fails");
- g_free (s);
-
- s = g_strjoin ("-", "a", "b", NULL);
- if (strcmp (s, "a-b") != 0)
- return FAILED ("Join of two strings with separator fails");
- g_free (s);
-
- s = g_strjoin ("-", "aaaa", "bbbb", "cccc", "dddd", NULL);
- if (strcmp (s, "aaaa-bbbb-cccc-dddd") != 0)
- return FAILED ("Join of multiple strings fails");
- g_free (s);
-
- s = g_strjoin ("-", NULL);
- if (s == NULL || (strcmp (s, "") != 0))
- return FAILED ("Failed to join empty arguments");
- g_free (s);
-
- return OK;
-}
-
-RESULT
-test_strchug ()
-{
- char *str = g_strdup (" \t\n hola");
-
- g_strchug (str);
- if (strcmp ("hola", str)) {
- fprintf (stderr, "%s\n", str);
- g_free (str);
- return FAILED ("Failed.");
- }
- g_free (str);
- return OK;
-}
-
-RESULT
-test_strchomp ()
-{
- char *str = g_strdup ("hola \t");
-
- g_strchomp (str);
- if (strcmp ("hola", str)) {
- fprintf (stderr, "%s\n", str);
- g_free (str);
- return FAILED ("Failed.");
- }
- g_free (str);
- return OK;
-}
-
-RESULT
-test_strstrip ()
-{
- char *str = g_strdup (" \t hola ");
-
- g_strstrip (str);
- if (strcmp ("hola", str)) {
- fprintf (stderr, "%s\n", str);
- g_free (str);
- return FAILED ("Failed.");
- }
- g_free (str);
- return OK;
-}
-
-#define urit(so,j) do { s = g_filename_to_uri (so, NULL, NULL); if (strcmp (s, j) != 0) return FAILED("Got %s expected %s", s, j); g_free (s); } while (0);
-
-#define errit(so) do { s = g_filename_to_uri (so, NULL, NULL); if (s != NULL) return FAILED ("got %s, expected NULL", s); } while (0);
-
-RESULT
-test_filename_to_uri ()
-{
-#ifdef G_OS_WIN32
-#else
- char *s;
-
- urit ("/a", "file:///a");
- urit ("/home/miguel", "file:///home/miguel");
- urit ("/home/mig uel", "file:///home/mig%20uel");
- urit ("/\303\241", "file:///%C3%A1");
- urit ("/\303\241/octal", "file:///%C3%A1/octal");
- urit ("/%", "file:///%25");
- urit ("/\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037\040", "file:///%01%02%03%04%05%06%07%08%09%0A%0B%0C%0D%0E%0F%10%11%12%13%14%15%16%17%18%19%1A%1B%1C%1D%1E%1F%20");
- urit ("/!$&'()*+,-./", "file:///!$&'()*+,-./");
- urit ("/\042\043\045", "file:///%22%23%25");
- urit ("/0123456789:=", "file:///0123456789:=");
- urit ("/\073\074\076\077", "file:///%3B%3C%3E%3F");
- urit ("/\133\134\135\136_\140\173\174\175", "file:///%5B%5C%5D%5E_%60%7B%7C%7D");
- urit ("/\173\174\175\176\177\200", "file:///%7B%7C%7D~%7F%80");
- urit ("/@ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", "file:///@ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz");
- errit ("a");
- errit ("./hola");
-#endif
-
- return OK;
-}
-
-#define fileit(so,j) do { s = g_filename_from_uri (so, NULL, NULL); if (strcmp (s, j) != 0) return FAILED("Got %s expected %s", s, j); g_free (s); } while (0);
-
-#define ferrit(so) do { s = g_filename_from_uri (so, NULL, NULL); if (s != NULL) return FAILED ("got %s, expected NULL", s); } while (0);
-
-RESULT
-test_filename_from_uri ()
-{
-#ifdef G_OS_WIN32
-#else
- char *s;
-
- fileit ("file:///a", "/a");
- fileit ("file:///%41", "/A");
- fileit ("file:///home/miguel", "/home/miguel");
- fileit ("file:///home/mig%20uel", "/home/mig uel");
- ferrit ("/a");
- ferrit ("a");
- ferrit ("file://a");
- ferrit ("file:a");
- ferrit ("file:///%");
- ferrit ("file:///%0");
- ferrit ("file:///%jj");
-#endif
-
- return OK;
-}
-
-RESULT
-test_ascii_xdigit_value ()
-{
- int i;
- gchar j;
-
- i = g_ascii_xdigit_value ('9' + 1);
- if (i != -1)
- return FAILED ("'9' + 1");
- i = g_ascii_xdigit_value ('0' - 1);
- if (i != -1)
- return FAILED ("'0' - 1");
- i = g_ascii_xdigit_value ('a' - 1);
- if (i != -1)
- return FAILED ("'a' - 1");
- i = g_ascii_xdigit_value ('f' + 1);
- if (i != -1)
- return FAILED ("'f' + 1");
- i = g_ascii_xdigit_value ('A' - 1);
- if (i != -1)
- return FAILED ("'A' - 1");
- i = g_ascii_xdigit_value ('F' + 1);
- if (i != -1)
- return FAILED ("'F' + 1");
-
- for (j = '0'; j < '9'; j++) {
- int c = g_ascii_xdigit_value (j);
- if (c != (j - '0'))
- return FAILED ("Digits %c -> %d", j, c);
- }
- for (j = 'a'; j < 'f'; j++) {
- int c = g_ascii_xdigit_value (j);
- if (c != (j - 'a' + 10))
- return FAILED ("Lower %c -> %d", j, c);
- }
- for (j = 'A'; j < 'F'; j++) {
- int c = g_ascii_xdigit_value (j);
- if (c != (j - 'A' + 10))
- return FAILED ("Upper %c -> %d", j, c);
- }
- return OK;
-}
-
-RESULT
-test_strdelimit ()
-{
- gchar *str;
-
- str = g_strdup (G_STR_DELIMITERS);
- str = g_strdelimit (str, NULL, 'a');
- if (0 != strcmp ("aaaaaaa", str))
- return FAILED ("All delimiters: '%s'", str);
- g_free (str);
- str = g_strdup ("hola");
- str = g_strdelimit (str, "ha", '+');
- if (0 != strcmp ("+ol+", str))
- return FAILED ("2 delimiters: '%s'", str);
- g_free (str);
- return OK;
-}
-
-#define NUMBERS "0123456789"
-
-RESULT
-test_strlcpy ()
-{
- const gchar *src = "onetwothree";
- gchar *dest;
- gsize i;
-
- dest = g_malloc (strlen (src) + 1);
- memset (dest, 0, strlen (src) + 1);
- i = g_strlcpy (dest, src, (gsize)-1);
- if (i != strlen (src))
- return FAILED ("Test1 got %d", i);
-
- if (0 != strcmp (dest, src))
- return FAILED ("Src and dest not equal");
-
- i = g_strlcpy (dest, src, 3);
- if (i != strlen (src))
- return FAILED ("Test1 got %d", i);
- if (0 != strcmp (dest, "on"))
- return FAILED ("Test2");
-
- i = g_strlcpy (dest, src, 1);
- if (i != strlen (src))
- return FAILED ("Test3 got %d", i);
- if (*dest != '\0')
- return FAILED ("Test4");
-
- i = g_strlcpy (dest, src, 12345);
- if (i != strlen (src))
- return FAILED ("Test4 got %d", i);
- if (0 != strcmp (dest, src))
- return FAILED ("Src and dest not equal 2");
- g_free (dest);
-
- /* This is a test for g_filename_from_utf8, even if it does not look like it */
- dest = g_filename_from_utf8 (NUMBERS, strlen (NUMBERS), NULL, NULL, NULL);
- if (0 != strcmp (dest, NUMBERS))
- return FAILED ("problem [%s] and [%s]", dest, NUMBERS);
- g_free (dest);
-
- return OK;
-}
-
-RESULT
-test_strescape ()
-{
- gchar *str;
-
- str = g_strescape ("abc", NULL);
- if (strcmp ("abc", str))
- return FAILED ("#1");
- str = g_strescape ("\t\b\f\n\r\\\"abc", NULL);
- if (strcmp ("\\t\\b\\f\\n\\r\\\\\\\"abc", str))
- return FAILED ("#2 %s", str);
- str = g_strescape ("\001abc", NULL);
- if (strcmp ("\\001abc", str))
- return FAILED ("#3 %s", str);
- str = g_strescape ("\001abc", "\001");
- if (strcmp ("\001abc", str))
- return FAILED ("#3 %s", str);
- return OK;
-}
-
-RESULT
-test_ascii_strncasecmp ()
-{
- int n;
-
- n = g_ascii_strncasecmp ("123", "123", 1);
- if (n != 0)
- return FAILED ("Should have been 0");
-
- n = g_ascii_strncasecmp ("423", "123", 1);
- if (n != 3)
- return FAILED ("Should have been 3, got %d", n);
-
- n = g_ascii_strncasecmp ("123", "423", 1);
- if (n != -3)
- return FAILED ("Should have been -3, got %d", n);
-
- n = g_ascii_strncasecmp ("1", "1", 10);
- if (n != 0)
- return FAILED ("Should have been 0, got %d", n);
- return OK;
-}
-
-RESULT
-test_ascii_strdown ()
-{
- const gchar *a = "~09+AaBcDeFzZ$0909EmPAbCdEEEEEZZZZAAA";
- const gchar *b = "~09+aabcdefzz$0909empabcdeeeeezzzzaaa";
- gchar *c;
- gint n, l;
-
- l = (gint)strlen (b);
- c = g_ascii_strdown (a, l);
- n = g_ascii_strncasecmp (b, c, l);
-
- if (n != 0) {
- g_free (c);
- return FAILED ("Should have been 0, got %d", n);
- }
-
- g_free (c);
- return OK;
-}
-
-RESULT
-test_strdupv ()
-{
- gchar **one;
- gchar **two;
- gint len;
-
- one = g_strdupv (NULL);
- if (one)
- return FAILED ("Should have been NULL");
-
- one = g_malloc (sizeof (gchar *));
- *one = NULL;
- two = g_strdupv (one);
- if (!two)
- FAILED ("Should have been not NULL");
- len = g_strv_length (two);
- if (len)
- FAILED ("Should have been 0");
- g_strfreev (two);
- g_strfreev (one);
- return NULL;
-}
-
-static Test strutil_tests [] = {
- {"g_strfreev", test_strfreev},
- {"g_strconcat", test_concat},
- {"g_strsplit", test_split},
- {"g_strsplit_set", test_split_set},
- {"g_strreverse", test_strreverse},
- {"g_strjoin", test_strjoin},
- {"g_strchug", test_strchug},
- {"g_strchomp", test_strchomp},
- {"g_strstrip", test_strstrip},
- {"g_filename_to_uri", test_filename_to_uri},
- {"g_filename_from_uri", test_filename_from_uri},
- {"g_ascii_xdigit_value", test_ascii_xdigit_value},
- {"g_strdelimit", test_strdelimit},
- {"g_strlcpy", test_strlcpy},
- {"g_strescape", test_strescape},
- {"g_ascii_strncasecmp", test_ascii_strncasecmp },
- {"g_ascii_strdown", test_ascii_strdown },
- {"g_strdupv", test_strdupv },
- {NULL, NULL}
-};
-
-DEFINE_TEST_GROUP_INIT(strutil_tests_init, strutil_tests)
-
-
+++ /dev/null
-#include <glib.h>
-#include <string.h>
-#include <stdio.h>
-#include "test.h"
-
-#define sfail(k,p) if (s->str [p] != k) { g_string_free (s,TRUE); return FAILED("Got %s, Failed at %d, expected '%c'", s->str, p, k);}
-
-RESULT
-test_append_speed()
-{
- GString *s = g_string_new("");
- gint i;
-
- for(i = 0; i < 1024; i++) {
- g_string_append(s, "x");
- }
-
- if(strlen (s->str) != 1024) {
- return FAILED("Incorrect string size, got: %s %d",
- s->str, strlen(s->str));
- }
-
- g_string_free (s, TRUE);
-
- return OK;
-}
-
-RESULT
-test_append_c_speed()
-{
- GString *s = g_string_new("");
- gint i;
-
- for(i = 0; i < 1024; i++) {
- g_string_append_c(s, 'x');
- }
-
- if(strlen(s->str) != 1024) {
- return FAILED("Incorrect string size, got: %s %d", s->str,
- strlen(s->str));
- }
-
- g_string_free(s, TRUE);
-
- return OK;
-}
-
-RESULT
-test_gstring ()
-{
- GString *s = g_string_new_len ("My stuff", 2);
- char *ret;
- int i;
-
- if (strcmp (s->str, "My") != 0)
- return "Expected only 'My' on the string";
- g_string_free (s, TRUE);
-
- s = g_string_new_len ("My\0\0Rest", 6);
- if (s->str [2] != 0)
- return "Null was not copied";
- if (strcmp (s->str+4, "Re") != 0){
- return "Did not find the 'Re' part";
- }
-
- g_string_append (s, "lalalalalalalalalalalalalalalalalalalalalalal");
- if (s->str [2] != 0)
- return "Null as not copied";
- if (strncmp (s->str+4, "Relala", 6) != 0){
- return FAILED("Did not copy correctly, got: %s", s->str+4);
- }
-
- g_string_free (s, TRUE);
-
- s = g_string_new ("");
- for (i = 0; i < 1024; i++){
- g_string_append_c (s, 'x');
- }
- if (strlen (s->str) != 1024){
- return FAILED("Incorrect string size, got: %s %d\n", s->str, strlen (s->str));
- }
- g_string_free (s, TRUE);
-
- s = g_string_new ("hola");
- g_string_sprintfa (s, "%s%d", ", bola", 5);
- if (strcmp (s->str, "hola, bola5") != 0){
- return FAILED("Incorrect data, got: %s\n", s->str);
- }
- g_string_free (s, TRUE);
-
- s = g_string_new ("Hola");
- g_string_printf (s, "Dingus");
-
- /* Test that it does not release it */
- ret = g_string_free (s, FALSE);
- g_free (ret);
-
- s = g_string_new_len ("H" "\000" "H", 3);
- g_string_append_len (s, "1" "\000" "2", 3);
- sfail ('H', 0);
- sfail ( 0, 1);
- sfail ('H', 2);
- sfail ('1', 3);
- sfail ( 0, 4);
- sfail ('2', 5);
- g_string_free (s, TRUE);
-
- return OK;
-}
-
-RESULT
-test_sized ()
-{
- GString *s = g_string_sized_new (20);
-
- if (s->str [0] != 0)
- return FAILED ("Expected an empty string");
- if (s->len != 0)
- return FAILED ("Expected an empty len");
-
- g_string_free (s, TRUE);
-
- return NULL;
-}
-
-RESULT
-test_truncate ()
-{
- GString *s = g_string_new ("0123456789");
- g_string_truncate (s, 3);
-
- if (strlen (s->str) != 3)
- return FAILED ("size of string should have been 3, instead it is [%s]\n", s->str);
- g_string_free (s, TRUE);
-
- s = g_string_new ("a");
- s = g_string_truncate (s, 10);
- if (strlen (s->str) != 1)
- return FAILED ("The size is not 1");
- g_string_truncate (s, (gsize)-1);
- if (strlen (s->str) != 1)
- return FAILED ("The size is not 1");
- g_string_truncate (s, 0);
- if (strlen (s->str) != 0)
- return FAILED ("The size is not 0");
-
- g_string_free (s, TRUE);
-
- return NULL;
-}
-
-RESULT
-test_prepend ()
-{
- GString *s = g_string_new ("dingus");
- g_string_prepend (s, "one");
-
- if (strcmp (s->str, "onedingus") != 0)
- return FAILED ("Failed, expected onedingus, got [%s]", s->str);
-
- g_string_free (s, TRUE);
-
- /* This is to force the code that where stuff does not fit in the allocated block */
- s = g_string_sized_new (1);
- g_string_prepend (s, "one");
- if (strcmp (s->str, "one") != 0)
- return FAILED ("Got erroneous result, expected [one] got [%s]", s->str);
- g_string_free (s, TRUE);
-
- /* This is to force the path where things fit */
- s = g_string_new ("123123123123123123123123");
- g_string_truncate (s, 1);
- if (strcmp (s->str, "1") != 0)
- return FAILED ("Expected [1] string, got [%s]", s->str);
-
- g_string_prepend (s, "pre");
- if (strcmp (s->str, "pre1") != 0)
- return FAILED ("Expected [pre1], got [%s]", s->str);
- g_string_free (s, TRUE);
-
- return NULL;
-}
-
-RESULT
-test_appendlen ()
-{
- GString *s = g_string_new ("");
-
- g_string_append_len (s, "boo\000x", 0);
- if (s->len != 0)
- return FAILED ("The length is not zero %d", s->len);
- g_string_append_len (s, "boo\000x", 5);
- if (s->len != 5)
- return FAILED ("The length is not five %d", s->len);
- g_string_append_len (s, "ha", -1);
- if (s->len != 7)
- return FAILED ("The length is not seven %d", s->len);
-
- g_string_free (s, TRUE);
-
- return NULL;
-}
-
-RESULT
-test_macros ()
-{
- char *s = g_strdup (G_STRLOC);
- char *p = strchr (s + 2, ':');
- int n;
-
- if (p == NULL)
- return FAILED ("Did not find a separator");
- n = atoi (p+1);
- if (n <= 0)
- return FAILED ("did not find a valid line number");
-
- *p = 0;
- if (strcmp (s + strlen(s) - 8 , "string.c") != 0)
- return FAILED ("This did not store the filename on G_STRLOC");
-
- g_free (s);
- return NULL;
-}
-
-static Test string_tests [] = {
- {"append-speed", test_append_speed},
- {"append_c-speed", test_append_c_speed},
- {"ctor+append", test_gstring },
- {"ctor+sized", test_sized },
- {"truncate", test_truncate },
- {"prepend", test_prepend },
- {"append_len", test_appendlen },
- {"macros", test_macros },
- {NULL, NULL}
-};
-
-DEFINE_TEST_GROUP_INIT(string_tests_init, string_tests)
+++ /dev/null
-#!/bin/sh
-
-for arg in $@; do
- if [ "x$arg" = "x--help" ]; then
- echo "Usage: $0 [OPTION]... [ITERATIONS] [TESTGROUP]..."
- echo ""
- echo "Works the same as test-eglib or test-glib with the following"
- echo "exception. Run test-eglib --help for details on normal testing"
- echo ""
- echo "If the first OPTION is --speed-compare, the following is"
- echo "applicable to this program:"
- echo ""
- echo " --speed-compare run drivers in -qtni mode and report"
- echo " speed comparison information"
- echo ""
- echo "After --speed-compare, the number of iterations "
- echo "(optional, default is 100000) can be specified, followed "
- echo "by specific tests to run (or none to run all)"
- echo ""
- echo "If --speed-compare is not the first argument, all arguments are"
- echo "passed on directly to each driver"
- echo ""
- exit 1
- fi
-done
-
-if [ ! -x "./test-glib" -o ! -x "./test-eglib" ]; then
- make
-fi
-
-if [ "x$1" = "x--speed-compare" ]; then
- ITERATIONS=100000
- if [ ! -z "$2" ]; then
- case $2 in
- *[0-9]*) ITERATIONS=$2; break;
- esac
- fi
-
- OPTIONS="-qnti $ITERATIONS"
-
- for arg in $@; do
- if [ "x$arg" = "x--speed-compare" ]; then
- continue;
- elif [ "$arg" = "$ITERATIONS" ]; then
- continue;
- fi
-
- OPTIONS="$OPTIONS $arg"
- done
-
- echo "Running tests with $OPTIONS..."
-
- GLIB=`./test-glib $OPTIONS`
- EGLIB=`./test-eglib $OPTIONS`
-
- # this blows
- FASTER_NAME=`echo "$GLIB GLib $EGLIB EGlib" | awk '{ if($1 < $3) print $2; else print $4 }'`
- FASTER_SPEED=`echo "$GLIB $EGLIB" | awk '{ if($1 < $2) print $1; else print $2 }'`
- SLOWER_NAME=`echo "$GLIB GLib $EGLIB EGlib" | awk '{ if($1 > $3) print $2; else print $4 }'`
- SLOWER_SPEED=`echo "$GLIB $EGLIB" | awk '{ if($1 > $2) print $1; else print $2 }'`
-
- FASTER_PERCENTAGE=`echo "$SLOWER_SPEED $FASTER_SPEED" | awk '{ print ($1 / $2) * 100 }'`
-
- echo "$FASTER_NAME $FASTER_SPEED"
- echo "$SLOWER_NAME $SLOWER_SPEED"
- echo "------------------------------------------------"
- echo "$FASTER_NAME is $FASTER_PERCENTAGE% faster than $SLOWER_NAME"
-
- exit 0;
-fi
-
-./test-eglib $@
-./test-glib $@
-
+++ /dev/null
-/*
- * EGLib Unit Group/Test Runners
- *
- * Author:
- * Aaron Bockover (abockover@novell.com)
- *
- * (C) 2006 Novell, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-#ifndef _GNU_SOURCE
-#define _GNU_SOURCE
-#endif
-
-#include <config.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdarg.h>
-#include <glib.h>
-#ifdef HAVE_SYS_TIME_H
-#include <sys/time.h>
-#endif
-#ifdef G_OS_WIN32
-#include <winsock2.h>
-#endif
-
-#include "test.h"
-
-extern gint global_passed, global_tests;
-static gchar *last_result = NULL;
-
-gboolean
-run_test(Test *test, gchar **result_out)
-{
- gchar *result;
-
- if((result = test->handler()) == NULL) {
- *result_out = NULL;
- return TRUE;
- } else {
- *result_out = result;
- return FALSE;
- }
-}
-
-gboolean
-run_group(Group *group, gint iterations, gboolean quiet,
- gboolean time, gchar *tests_to_run_s)
-{
- Test *tests = group->handler();
- gint i, j, passed = 0, total = 0;
- gdouble start_time_group, start_time_test;
- gchar **tests_to_run = NULL;
-
- if(!quiet) {
- if(iterations > 1) {
- printf("[%s] (%dx)\n", group->name, iterations);
- } else {
- printf("[%s]\n", group->name);
- }
- }
-
- if(tests_to_run_s != NULL) {
- tests_to_run = eg_strsplit(tests_to_run_s, ",", -1);
- }
-
- start_time_group = get_timestamp();
-
- for(i = 0; tests[i].name != NULL; i++) {
- gchar *result = "";
- gboolean iter_pass, run;
-
- iter_pass = FALSE;
- if(tests_to_run != NULL) {
- gint j;
- run = FALSE;
- for(j = 0; tests_to_run[j] != NULL; j++) {
- if(strcmp(tests_to_run[j], tests[i].name) == 0) {
- run = TRUE;
- break;
- }
- }
- } else {
- run = TRUE;
- }
-
- if(!run) {
- continue;
- }
-
- total++;
-
- if(!quiet) {
- printf(" %s: ", tests[i].name);
- }
-
- start_time_test = get_timestamp();
-
- for(j = 0; j < iterations; j++) {
- iter_pass = run_test(&(tests[i]), &result);
- if(!iter_pass) {
- break;
- }
- }
-
- if(iter_pass) {
- passed++;
- if(!quiet) {
- if(time) {
- printf("OK (%g)\n", get_timestamp() - start_time_test);
- } else {
- printf("OK\n");
- }
- }
- } else {
- if(!quiet) {
- printf("FAILED (%s)\n", result);
- }
-
- if(last_result == result) {
- last_result = NULL;
- g_free(result);
- }
- }
- }
-
- global_passed += passed;
- global_tests += total;
-
- if(!quiet) {
- gdouble pass_percentage = ((gdouble)passed / (gdouble)total) * 100.0;
- if(time) {
- printf(" %d / %d (%g%%, %g)\n", passed, total,
- pass_percentage, get_timestamp() - start_time_group);
- } else {
- printf(" %d / %d (%g%%)\n", passed, total, pass_percentage);
- }
- }
-
- if(tests_to_run != NULL) {
- eg_strfreev(tests_to_run);
- }
-
- return passed == total;
-}
-
-RESULT
-FAILED(const gchar *format, ...)
-{
- gchar *ret;
- va_list args;
- gint n;
-
-#if !defined(HAVE_VASPRINTF) && !defined(_EGLIB_MAJOR)
- /* We are linked against the real glib, no vasprintf */
- g_assert_not_reached ();
- return NULL;
-#else
- va_start(args, format);
- n = g_vasprintf(&ret, format, args);
- va_end(args);
-
- if(n == -1) {
- last_result = NULL;
- return NULL;
- }
-
- last_result = ret;
- return ret;
-#endif
-}
-
-gdouble
-get_timestamp()
-{
- /* FIXME: We should use g_get_current_time here */
- GTimeVal res;
- g_get_current_time (&res);
- return res.tv_sec + (1.e-6) * res.tv_usec;
-}
-
-/*
- * Duplicating code here from EGlib to avoid g_strsplit skew between
- * EGLib and GLib
- */
-
-gchar **
-eg_strsplit (const gchar *string, const gchar *delimiter, gint max_tokens)
-{
- gchar *string_c;
- gchar *strtok_save, **vector;
- gchar *token, *token_c;
- gint size = 1;
- size_t token_length;
-
- g_return_val_if_fail(string != NULL, NULL);
- g_return_val_if_fail(delimiter != NULL, NULL);
- g_return_val_if_fail(delimiter[0] != 0, NULL);
-
- token_length = strlen(string);
- string_c = (gchar *)g_malloc(token_length + 1);
- memcpy(string_c, string, token_length);
- string_c[token_length] = 0;
-
- vector = NULL;
- token = (gchar *)strtok_r(string_c, delimiter, &strtok_save);
-
- while(token != NULL) {
- token_length = strlen(token);
- token_c = (gchar *)g_malloc(token_length + 1);
- memcpy(token_c, token, token_length);
- token_c[token_length] = 0;
-
- vector = vector == NULL ?
- (gchar **)g_malloc(2 * sizeof(vector)) :
- (gchar **)g_realloc(vector, (size + 1) * sizeof(vector));
-
- vector[size - 1] = token_c;
- size++;
-
- if(max_tokens > 0 && size >= max_tokens) {
- if(size > max_tokens) {
- break;
- }
-
- token = strtok_save;
- } else {
- token = (gchar *)strtok_r(NULL, delimiter, &strtok_save);
- }
- }
-
- if(vector != NULL && size > 0) {
- vector[size - 1] = NULL;
- }
-
- g_free(string_c);
- string_c = NULL;
-
- return vector;
-}
-
-void
-eg_strfreev (gchar **str_array)
-{
- gchar **orig = str_array;
- if (str_array == NULL)
- return;
- while (*str_array != NULL){
- g_free (*str_array);
- str_array++;
- }
- g_free (orig);
-}
-
-
-
+++ /dev/null
-/*
- * EGLib Unit Group/Test Runners
- *
- * Author:
- * Aaron Bockover (abockover@novell.com)
- *
- * (C) 2006 Novell, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-#ifndef _TEST_H
-#define _TEST_H
-
-#include <config.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <string.h>
-#include <glib.h>
-
-#ifdef _MSC_VER
-/* disable the following warnings
- * C4100: The formal parameter is not referenced in the body of the function. The unreferenced parameter is ignored.
- * C4127: conditional expression is constant (test macros produce a lot of these)
-*/
-#pragma warning(disable:4100 4127)
-#endif
-
-typedef gchar * RESULT;
-
-typedef struct _Test Test;
-typedef struct _Group Group;
-
-typedef gchar * (* RunTestHandler)();
-typedef Test * (* LoadGroupHandler)();
-
-struct _Test {
- const gchar *name;
- RunTestHandler handler;
-};
-
-struct _Group {
- const gchar *name;
- LoadGroupHandler handler;
-};
-
-gboolean run_group(Group *group, gint iterations, gboolean quiet,
- gboolean time, gchar *tests);
-#undef FAILED
-RESULT FAILED(const gchar *format, ...);
-gdouble get_timestamp();
-gchar ** eg_strsplit (const gchar *string, const gchar *delimiter, gint max_tokens);
-void eg_strfreev (gchar **str_array);
-
-#define OK NULL
-
-#define DEFINE_TEST_GROUP_INIT(name, table) \
- Test * (name)() { return table; }
-
-#define DEFINE_TEST_GROUP_INIT_H(name) \
- Test * (name)();
-
-#endif /* _TEST_H */
-
-
+++ /dev/null
-#include "test.h"
-
-DEFINE_TEST_GROUP_INIT_H(string_tests_init);
-DEFINE_TEST_GROUP_INIT_H(strutil_tests_init);
-DEFINE_TEST_GROUP_INIT_H(slist_tests_init);
-DEFINE_TEST_GROUP_INIT_H(list_tests_init);
-DEFINE_TEST_GROUP_INIT_H(hashtable_tests_init);
-DEFINE_TEST_GROUP_INIT_H(ptrarray_tests_init);
-DEFINE_TEST_GROUP_INIT_H(size_tests_init);
-DEFINE_TEST_GROUP_INIT_H(fake_tests_init);
-DEFINE_TEST_GROUP_INIT_H(array_tests_init);
-DEFINE_TEST_GROUP_INIT_H(queue_tests_init);
-DEFINE_TEST_GROUP_INIT_H(path_tests_init);
-DEFINE_TEST_GROUP_INIT_H(shell_tests_init);
-DEFINE_TEST_GROUP_INIT_H(spawn_tests_init);
-DEFINE_TEST_GROUP_INIT_H(timer_tests_init);
-DEFINE_TEST_GROUP_INIT_H(file_tests_init);
-DEFINE_TEST_GROUP_INIT_H(pattern_tests_init);
-DEFINE_TEST_GROUP_INIT_H(dir_tests_init);
-DEFINE_TEST_GROUP_INIT_H(markup_tests_init);
-DEFINE_TEST_GROUP_INIT_H(unicode_tests_init);
-DEFINE_TEST_GROUP_INIT_H(utf8_tests_init);
-DEFINE_TEST_GROUP_INIT_H(endian_tests_init);
-DEFINE_TEST_GROUP_INIT_H(module_tests_init);
-DEFINE_TEST_GROUP_INIT_H(memory_tests_init);
-
-static Group test_groups [] = {
- {"string", string_tests_init},
- {"strutil", strutil_tests_init},
- {"ptrarray", ptrarray_tests_init},
- {"slist", slist_tests_init},
- {"list", list_tests_init},
- {"hashtable", hashtable_tests_init},
- {"sizes", size_tests_init},
- {"fake", fake_tests_init},
- {"array", array_tests_init},
- {"queue", queue_tests_init},
- {"path", path_tests_init},
- {"shell", shell_tests_init},
- {"markup", markup_tests_init},
-#if !DISABLE_PROCESS_TESTS
- {"spawn", spawn_tests_init},
- {"module", module_tests_init},
-#endif
-#if !DISABLE_FILESYSTEM_TESTS
- {"file", file_tests_init},
-#endif
- {"timer", timer_tests_init},
- {"pattern", pattern_tests_init},
- {"dir", dir_tests_init},
- {"unicode", unicode_tests_init},
- {"utf8", utf8_tests_init},
- {"endian", endian_tests_init},
- {"memory", memory_tests_init},
- {NULL, NULL}
-};
-
+++ /dev/null
-#include <config.h>
-#include <glib.h>
-#include <string.h>
-#include <math.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#include <stdlib.h>
-#include <stdio.h>
-
-#ifdef G_OS_WIN32
-#include <windows.h>
-#define sleep(t) Sleep((t) * 1000)
-#endif
-
-#include "test.h"
-
-RESULT
-test_timer ()
-{
- GTimer *timer;
- gdouble elapsed1, elapsed2;
- gulong usec = 0;
-
- timer = g_timer_new ();
- sleep (1);
- elapsed1 = g_timer_elapsed (timer, NULL);
- if ((elapsed1 + 0.1) < 1.0)
- return FAILED ("Elapsed time should be around 1s and was %f", elapsed1);
-
- g_timer_stop (timer);
- elapsed1 = g_timer_elapsed (timer, NULL);
- elapsed2 = g_timer_elapsed (timer, &usec);
- if (fabs (elapsed1 - elapsed2) > 0.000001)
- return FAILED ("The elapsed times are not equal %f - %f.", elapsed1, elapsed2);
-
- elapsed2 *= 1000000;
- while (elapsed2 > 1000000)
- elapsed2 -= 1000000;
-
- if (fabs (usec - elapsed2) > 100.0)
- return FAILED ("usecs are wrong.");
-
- g_timer_destroy (timer);
- return OK;
-}
-
-static Test timer_tests [] = {
- {"g_timer", test_timer},
- {NULL, NULL}
-};
-
-DEFINE_TEST_GROUP_INIT(timer_tests_init, timer_tests)
-
-
+++ /dev/null
-#include "test.h"
-
-/*
- * g_unichar_type
- */
-RESULT
-test_g_unichar_type ()
-{
- if (g_unichar_type ('A') != G_UNICODE_UPPERCASE_LETTER)
- return FAILED ("#1");
- if (g_unichar_type ('a') != G_UNICODE_LOWERCASE_LETTER)
- return FAILED ("#2");
- if (g_unichar_type ('1') != G_UNICODE_DECIMAL_NUMBER)
- return FAILED ("#3");
- if (g_unichar_type (0xA3) != G_UNICODE_CURRENCY_SYMBOL)
- return FAILED ("#4");
- return NULL;
-}
-
-/*
- * g_unichar_toupper
- */
-RESULT
-test_g_unichar_toupper ()
-{
- if (g_unichar_toupper (0) != 0)
- return FAILED ("#0");
- if (g_unichar_toupper ('a') != 'A')
- return FAILED ("#1");
- if (g_unichar_toupper ('1') != '1')
- return FAILED ("#2");
- if (g_unichar_toupper (0x1C4) != 0x1C4)
- return FAILED ("#3");
- if (g_unichar_toupper (0x1F2) != 0x1F1)
- return FAILED ("#4");
- if (g_unichar_toupper (0x1F3) != 0x1F1)
- return FAILED ("#5");
- if (g_unichar_toupper (0xFFFF) != 0xFFFF)
- return FAILED ("#6");
- if (g_unichar_toupper (0x10428) != 0x10400)
- return FAILED ("#7");
- return NULL;
-}
-
-/*
- * g_unichar_tolower
- */
-RESULT
-test_g_unichar_tolower ()
-{
- if (g_unichar_tolower (0) != 0)
- return FAILED ("#0");
- if (g_unichar_tolower ('A') != 'a')
- return FAILED ("#1");
- if (g_unichar_tolower ('1') != '1')
- return FAILED ("#2");
- if (g_unichar_tolower (0x1C5) != 0x1C6)
- return FAILED ("#3");
- if (g_unichar_tolower (0x1F1) != 0x1F3)
- return FAILED ("#4");
- if (g_unichar_tolower (0x1F2) != 0x1F3)
- return FAILED ("#5");
- if (g_unichar_tolower (0xFFFF) != 0xFFFF)
- return FAILED ("#6");
- return NULL;
-}
-
-/*
- * g_unichar_totitle
- */
-RESULT
-test_g_unichar_totitle ()
-{
- if (g_unichar_toupper (0) != 0)
- return FAILED ("#0");
- if (g_unichar_totitle ('a') != 'A')
- return FAILED ("#1");
- if (g_unichar_totitle ('1') != '1')
- return FAILED ("#2");
- if (g_unichar_totitle (0x1C4) != 0x1C5)
- return FAILED ("#3");
- if (g_unichar_totitle (0x1F2) != 0x1F2)
- return FAILED ("#4");
- if (g_unichar_totitle (0x1F3) != 0x1F2)
- return FAILED ("#5");
- if (g_unichar_toupper (0xFFFF) != 0xFFFF)
- return FAILED ("#6");
- return NULL;
-}
-
-static Test unicode_tests [] = {
- {"g_unichar_type", test_g_unichar_type},
- {"g_unichar_toupper", test_g_unichar_toupper},
- {"g_unichar_tolower", test_g_unichar_tolower},
- {"g_unichar_totitle", test_g_unichar_totitle},
- {NULL, NULL}
-};
-
-DEFINE_TEST_GROUP_INIT(unicode_tests_init, unicode_tests)
+++ /dev/null
-#include <stdlib.h>
-
-#include "test.h"
-
-/*
- * g_utf16_to_utf8
- */
-
-glong
-compare_strings_utf8_pos (const gchar *expected, const gchar *actual, glong size)
-{
- int i;
- for (i = 0; i < size; i++)
- if (expected [i] != actual [i])
- return i;
- return -1;
-}
-
-RESULT
-compare_strings_utf8_RESULT (const gchar *expected, const gchar *actual, glong size)
-{
- glong ret;
-
- ret = compare_strings_utf8_pos (expected, actual, size);
- if (ret < 0)
- return OK;
- return FAILED ("Incorrect output: expected '%s' but was '%s', differ at %d\n", expected, actual, ret);
-}
-
-void
-gchar_to_gunichar2 (gunichar2 ret[], const gchar *src)
-{
- int i;
-
- for (i = 0; src [i]; i++)
- ret [i] = src [i];
- ret [i] = 0;
-}
-
-RESULT
-compare_utf16_to_utf8_explicit (const gchar *expected, const gunichar2 *utf16, glong len_in, glong len_out, glong size_spec)
-{
- GError *error;
- gchar* ret;
- RESULT result;
- glong in_read, out_read;
-
- result = NULL;
-
- error = NULL;
- ret = g_utf16_to_utf8 (utf16, size_spec, &in_read, &out_read, &error);
- if (error) {
- result = FAILED ("The error is %d %s\n", (error)->code, (error)->message);
- g_error_free (error);
- if (ret)
- g_free (ret);
- return result;
- }
- if (in_read != len_in)
- result = FAILED ("Read size is incorrect: expected %d but was %d\n", len_in, in_read);
- else if (out_read != len_out)
- result = FAILED ("Converted size is incorrect: expected %d but was %d\n", len_out, out_read);
- else
- result = compare_strings_utf8_RESULT (expected, ret, len_out);
-
- g_free (ret);
- if (result)
- return result;
-
- return OK;
-}
-
-RESULT
-compare_utf16_to_utf8 (const gchar *expected, const gunichar2 *utf16, glong len_in, glong len_out)
-{
- RESULT result;
-
- result = compare_utf16_to_utf8_explicit (expected, utf16, len_in, len_out, -1);
- if (result != OK)
- return result;
- return compare_utf16_to_utf8_explicit (expected, utf16, len_in, len_out, len_in);
-}
-
-RESULT
-test_utf16_to_utf8 ()
-{
- const gchar *src0 = "", *src1 = "ABCDE", *src2 = "\xE5\xB9\xB4\x27", *src3 = "\xEF\xBC\xA1", *src4 = "\xEF\xBD\x81", *src5 = "\xF0\x90\x90\x80";
- gunichar2 str0 [] = {0}, str1 [6], str2 [] = {0x5E74, 39, 0}, str3 [] = {0xFF21, 0}, str4 [] = {0xFF41, 0}, str5 [] = {0xD801, 0xDC00, 0};
- RESULT result;
-
- gchar_to_gunichar2 (str1, src1);
-
- /* empty string */
- result = compare_utf16_to_utf8 (src0, str0, 0, 0);
- if (result != OK)
- return result;
-
- result = compare_utf16_to_utf8 (src1, str1, 5, 5);
- if (result != OK)
- return result;
- result = compare_utf16_to_utf8 (src2, str2, 2, 4);
- if (result != OK)
- return result;
- result = compare_utf16_to_utf8 (src3, str3, 1, 3);
- if (result != OK)
- return result;
- result = compare_utf16_to_utf8 (src4, str4, 1, 3);
- if (result != OK)
- return result;
- result = compare_utf16_to_utf8 (src5, str5, 2, 4);
- if (result != OK)
- return result;
-
- return OK;
-}
-
-/*
- * g_utf8_to_utf16
- */
-
-glong
-compare_strings_utf16_pos (const gunichar2 *expected, const gunichar2 *actual, glong size)
-{
- int i;
- for (i = 0; i < size; i++)
- if (expected [i] != actual [i])
- return i;
- return -1;
-}
-
-RESULT
-compare_strings_utf16_RESULT (const gunichar2 *expected, const gunichar2 *actual, glong size)
-{
- glong ret;
-
- ret = compare_strings_utf16_pos (expected, actual, size);
- if (ret < 0)
- return OK;
- return FAILED ("Incorrect output: expected '%s' but was '%s', differ at %d ('%c' x '%c')\n", expected, actual, ret, expected [ret], actual [ret]);
-}
-
-#if !defined(EGLIB_TESTS)
-#define eg_utf8_to_utf16_with_nuls g_utf8_to_utf16
-#endif
-
-RESULT
-compare_utf8_to_utf16_explicit (const gunichar2 *expected, const gchar *utf8, glong len_in, glong len_out, glong size_spec, gboolean include_nuls)
-{
- GError *error;
- gunichar2* ret;
- RESULT result;
- glong in_read, out_read;
-
- result = NULL;
-
- error = NULL;
- if (include_nuls)
- ret = eg_utf8_to_utf16_with_nuls (utf8, size_spec, &in_read, &out_read, &error);
- else
- ret = g_utf8_to_utf16 (utf8, size_spec, &in_read, &out_read, &error);
-
- if (error) {
- result = FAILED ("The error is %d %s\n", (error)->code, (error)->message);
- g_error_free (error);
- if (ret)
- g_free (ret);
- return result;
- }
- if (in_read != len_in)
- result = FAILED ("Read size is incorrect: expected %d but was %d\n", len_in, in_read);
- else if (out_read != len_out)
- result = FAILED ("Converted size is incorrect: expected %d but was %d\n", len_out, out_read);
- else
- result = compare_strings_utf16_RESULT (expected, ret, len_out);
-
- g_free (ret);
- if (result)
- return result;
-
- return OK;
-}
-
-RESULT
-compare_utf8_to_utf16_general (const gunichar2 *expected, const gchar *utf8, glong len_in, glong len_out, gboolean include_nuls)
-{
- RESULT result;
-
- result = compare_utf8_to_utf16_explicit (expected, utf8, len_in, len_out, -1, include_nuls);
- if (result != OK)
- return result;
- return compare_utf8_to_utf16_explicit (expected, utf8, len_in, len_out, len_in, include_nuls);
-}
-
-RESULT
-compare_utf8_to_utf16 (const gunichar2 *expected, const gchar *utf8, glong len_in, glong len_out)
-{
- return compare_utf8_to_utf16_general (expected, utf8, len_in, len_out, FALSE);
-}
-
-RESULT
-compare_utf8_to_utf16_with_nuls (const gunichar2 *expected, const gchar *utf8, glong len_in, glong len_out)
-{
- return compare_utf8_to_utf16_explicit (expected, utf8, len_in, len_out, len_in, TRUE);
-}
-
-
-RESULT
-test_utf8_seq ()
-{
- const gchar *src = "\xE5\xB9\xB4\x27";
- glong in_read, out_read;
- //gunichar2 expected [6];
- GError *error = NULL;
- gunichar2 *dst;
-
- //printf ("got: %s\n", src);
- dst = g_utf8_to_utf16 (src, (glong)strlen (src), &in_read, &out_read, &error);
- if (error != NULL){
- return error->message;
- }
-
- if (in_read != 4) {
- return FAILED ("in_read is expected to be 4 but was %d\n", in_read);
- }
- if (out_read != 2) {
- return FAILED ("out_read is expected to be 2 but was %d\n", out_read);
- }
- g_free (dst);
-
- return OK;
-}
-
-RESULT
-test_utf8_to_utf16 ()
-{
- const gchar *src0 = "", *src1 = "ABCDE", *src2 = "\xE5\xB9\xB4\x27", *src3 = "\xEF\xBC\xA1", *src4 = "\xEF\xBD\x81";
- gunichar2 str0 [] = {0}, str1 [6], str2 [] = {0x5E74, 39, 0}, str3 [] = {0xFF21, 0}, str4 [] = {0xFF41, 0};
- RESULT result;
-
- gchar_to_gunichar2 (str1, src1);
-
- /* empty string */
- result = compare_utf8_to_utf16 (str0, src0, 0, 0);
- if (result != OK)
- return result;
-
- result = compare_utf8_to_utf16 (str1, src1, 5, 5);
- if (result != OK)
- return result;
- result = compare_utf8_to_utf16 (str2, src2, 4, 2);
- if (result != OK)
- return result;
- result = compare_utf8_to_utf16 (str3, src3, 3, 1);
- if (result != OK)
- return result;
- result = compare_utf8_to_utf16 (str4, src4, 3, 1);
- if (result != OK)
- return result;
-
- return OK;
-}
-
-RESULT
-test_utf8_to_utf16_with_nuls ()
-{
- const gchar *src0 = "", *src1 = "AB\0DE", *src2 = "\xE5\xB9\xB4\x27", *src3 = "\xEF\xBC\xA1", *src4 = "\xEF\xBD\x81";
- gunichar2 str0 [] = {0}, str1 [] = {'A', 'B', 0, 'D', 'E', 0}, str2 [] = {0x5E74, 39, 0}, str3 [] = {0xFF21, 0}, str4 [] = {0xFF41, 0};
- RESULT result;
-
-#if !defined(EGLIB_TESTS)
- return OK;
-#endif
-
- /* implicit length is forbidden */
- if (eg_utf8_to_utf16_with_nuls (src1, -1, NULL, NULL, NULL) != NULL)
- return FAILED ("explicit nulls must fail with -1 length\n");
-
- /* empty string */
- result = compare_utf8_to_utf16_with_nuls (str0, src0, 0, 0);
- if (result != OK)
- return result;
-
- result = compare_utf8_to_utf16_with_nuls (str1, src1, 5, 5);
- if (result != OK)
- return result;
- result = compare_utf8_to_utf16_with_nuls (str2, src2, 4, 2);
- if (result != OK)
- return result;
- result = compare_utf8_to_utf16_with_nuls (str3, src3, 3, 1);
- if (result != OK)
- return result;
- result = compare_utf8_to_utf16_with_nuls (str4, src4, 3, 1);
- if (result != OK)
- return result;
-
- return OK;
-}
-
-typedef struct {
- char *content;
- size_t length;
-} convert_result_t;
-
-RESULT
-test_convert ()
-{
- static const char *charsets[] = { "UTF-8", "UTF-16LE", "UTF-16BE", "UTF-32LE", "UTF-32BE" };
- gsize length, converted_length, n;
- char *content, *converted, *path;
- convert_result_t **expected;
- GError *err = NULL;
- const char *srcdir;
- gboolean loaded;
- guint i, j, k;
- char c;
-
- if (!(srcdir = getenv ("srcdir")) && !(srcdir = getenv ("PWD")))
- return FAILED ("srcdir not defined!");
-
- expected = g_malloc (sizeof (convert_result_t *) * G_N_ELEMENTS (charsets));
-
- /* first load all our test samples... */
- for (i = 0; i < G_N_ELEMENTS (charsets); i++) {
- path = g_strdup_printf ("%s%c%s.txt", srcdir, G_DIR_SEPARATOR, charsets[i]);
- loaded = g_file_get_contents (path, &content, &length, &err);
- g_free (path);
-
- if (!loaded) {
- for (j = 0; j < i; j++) {
- g_free (expected[j]->content);
- g_free (expected[j]);
- }
-
- g_free (expected);
-
- return FAILED ("Failed to load content for %s: %s", charsets[i], err->message);
- }
-
- expected[i] = g_malloc (sizeof (convert_result_t));
- expected[i]->content = content;
- expected[i]->length = length;
- }
-
- /* test conversion from every charset to every other charset */
- for (i = 0; i < G_N_ELEMENTS (charsets); i++) {
- for (j = 0; j < G_N_ELEMENTS (charsets); j++) {
- converted = g_convert (expected[i]->content, expected[i]->length, charsets[j],
- charsets[i], NULL, &converted_length, NULL);
-
- if (converted == NULL) {
- for (k = 0; k < G_N_ELEMENTS (charsets); k++) {
- g_free (expected[k]->content);
- g_free (expected[k]);
- }
-
- g_free (expected);
-
- return FAILED ("Failed to convert from %s to %s: NULL", charsets[i], charsets[j]);
- }
-
- if (converted_length != expected[j]->length) {
- length = expected[j]->length;
-
- for (k = 0; k < G_N_ELEMENTS (charsets); k++) {
- g_free (expected[k]->content);
- g_free (expected[k]);
- }
-
- g_free (converted);
- g_free (expected);
-
- return FAILED ("Failed to convert from %s to %s: expected %u bytes, got %u",
- charsets[i], charsets[j], length, converted_length);
- }
-
- for (n = 0; n < converted_length; n++) {
- if (converted[n] != expected[j]->content[n]) {
- c = expected[j]->content[n];
-
- for (k = 0; k < G_N_ELEMENTS (charsets); k++) {
- g_free (expected[k]->content);
- g_free (expected[k]);
- }
-
- g_free (converted);
- g_free (expected);
-
- return FAILED ("Failed to convert from %s to %s: expected 0x%x at offset %u, got 0x%x",
- charsets[i], charsets[j], c, n, converted[n]);
- }
- }
-
- g_free (converted);
- }
- }
-
- for (k = 0; k < G_N_ELEMENTS (charsets); k++) {
- g_free (expected[k]->content);
- g_free (expected[k]);
- }
-
- g_free (expected);
-
- return OK;
-}
-
-
-RESULT
-test_xdigit ()
-{
- static char test_chars[] = {
- '0', '1', '2', '3', '4',
- '5', '6', '7', '8', '9',
- 'a', 'b', 'c', 'd', 'e', 'f', 'g',
- 'A', 'B', 'C', 'D', 'E', 'F', 'G'};
- static gint32 test_values[] = {
- 0, 1, 2, 3, 4,
- 5, 6, 7, 8, 9,
- 10, 11, 12, 13, 14, 15, -1,
- 10, 11, 12, 13, 14, 15, -1};
-
- int i =0;
-
- for (i = 0; i < sizeof(test_chars); i++)
- if (g_unichar_xdigit_value ((gunichar)test_chars[i]) != test_values[i])
- return FAILED("Incorrect value %d at index %d", test_values[i], i);
-
- return OK;
-}
-
-static RESULT
-ucs4_to_utf16_check_result (const gunichar2 *result_str, const gunichar2 *expected_str,
- glong result_items_read, glong expected_items_read,
- glong result_items_written, glong expected_items_written,
- GError* result_error, gboolean expect_error)
-{
- glong i;
- if (result_items_read != expected_items_read)
- return FAILED("Incorrect number of items read; expected %d, got %d", expected_items_read, result_items_read);
- if (result_items_written != expected_items_written)
- return FAILED("Incorrect number of items written; expected %d, got %d", expected_items_written, result_items_written);
- if (result_error && !expect_error)
- return FAILED("There should not be an error code.");
- if (!result_error && expect_error)
- return FAILED("Unexpected error object.");
- if (expect_error && result_str)
- return FAILED("NULL should be returned when an error occurs.");
- if (!expect_error && !result_str)
- return FAILED("When no error occurs NULL should not be returned.");
- for (i=0; i<expected_items_written;i++) {
- if (result_str [i] != expected_str [i])
- return FAILED("Incorrect value %d at index %d", result_str [i], i);
- }
- if (result_str && result_str[expected_items_written] != '\0')
- return FAILED("Null termination not found at the end of the string.");
-
- return OK;
-}
-
-RESULT
-test_ucs4_to_utf16 ()
-{
- static gunichar str1[12] = {'H','e','l','l','o',' ','W','o','r','l','d','\0'};
- static gunichar2 exp1[12] = {'H','e','l','l','o',' ','W','o','r','l','d','\0'};
- static gunichar str2[3] = {'h',0x80000000,'\0'};
- static gunichar2 exp2[2] = {'h','\0'};
- static gunichar str3[3] = {'h',0xDA00,'\0'};
- static gunichar str4[3] = {'h',0x10FFFF,'\0'};
- static gunichar2 exp4[4] = {'h',0xdbff,0xdfff,'\0'};
- static gunichar str5[7] = {0xD7FF,0xD800,0xDFFF,0xE000,0x110000,0x10FFFF,'\0'};
- static gunichar2 exp5[5] = {0xD7FF,0xE000,0xdbff,0xdfff,'\0'};
- static gunichar str6[2] = {0x10400, '\0'};
- static gunichar2 exp6[3] = {0xD801, 0xDC00, '\0'};
- static glong read_write[12] = {1,1,0,0,0,0,1,1,0,0,1,2};
- gunichar2* res;
- glong items_read, items_written, current_write_index;
- GError* err=0;
- RESULT check_result;
- glong i;
-
- res = g_ucs4_to_utf16 (str1, 12, &items_read, &items_written, &err);
- check_result = ucs4_to_utf16_check_result (res, exp1, items_read, 11, items_written, 11, err, FALSE);
- if (check_result) return check_result;
- g_free (res);
-
- items_read = items_written = 0;
- res = g_ucs4_to_utf16 (str2, 0, &items_read, &items_written, &err);
- check_result = ucs4_to_utf16_check_result (res, exp2, items_read, 0, items_written, 0, err, FALSE);
- if (check_result) return check_result;
- g_free (res);
-
- items_read = items_written = 0;
- res = g_ucs4_to_utf16 (str2, 1, &items_read, &items_written, &err);
- check_result = ucs4_to_utf16_check_result (res, exp2, items_read, 1, items_written, 1, err, FALSE);
- if (check_result) return check_result;
- g_free (res);
-
- items_read = items_written = 0;
- res = g_ucs4_to_utf16 (str2, 2, &items_read, &items_written, &err);
- check_result = ucs4_to_utf16_check_result (res, 0, items_read, 1, items_written, 0, err, TRUE);
- g_free (res);
- if (check_result) return check_result;
-
- items_read = items_written = 0;
- err = 0;
- res = g_ucs4_to_utf16 (str3, 2, &items_read, &items_written, &err);
- check_result = ucs4_to_utf16_check_result (res, 0, items_read, 1, items_written, 0, err, TRUE);
- if (check_result) return check_result;
- g_free (res);
-
- items_read = items_written = 0;
- err = 0;
- res = g_ucs4_to_utf16 (str4, 5, &items_read, &items_written, &err);
- check_result = ucs4_to_utf16_check_result (res, exp4, items_read, 2, items_written, 3, err, FALSE);
- if (check_result) return check_result;
- g_free (res);
-
- // This loop tests the bounds of the conversion algorithm
- current_write_index = 0;
- for (i=0;i<6;i++) {
- items_read = items_written = 0;
- err = 0;
- res = g_ucs4_to_utf16 (&str5[i], 1, &items_read, &items_written, &err);
- check_result = ucs4_to_utf16_check_result (res, &exp5[current_write_index],
- items_read, read_write[i*2], items_written, read_write[(i*2)+1], err, !read_write[(i*2)+1]);
- if (check_result) return check_result;
- g_free (res);
- current_write_index += items_written;
- }
-
- items_read = items_written = 0;
- err = 0;
- res = g_ucs4_to_utf16 (str6, 1, &items_read, &items_written, &err);
- check_result = ucs4_to_utf16_check_result (res, exp6, items_read, 1, items_written, 2, err, FALSE);
- if (check_result) return check_result;
- g_free (res);
-
- return OK;
-}
-
-static RESULT
-utf16_to_ucs4_check_result (const gunichar *result_str, const gunichar *expected_str,
- glong result_items_read, glong expected_items_read,
- glong result_items_written, glong expected_items_written,
- GError* result_error, gboolean expect_error)
-{
- glong i;
- if (result_items_read != expected_items_read)
- return FAILED("Incorrect number of items read; expected %d, got %d", expected_items_read, result_items_read);
- if (result_items_written != expected_items_written)
- return FAILED("Incorrect number of items written; expected %d, got %d", expected_items_written, result_items_written);
- if (result_error && !expect_error)
- return FAILED("There should not be an error code.");
- if (!result_error && expect_error)
- return FAILED("Unexpected error object.");
- if (expect_error && result_str)
- return FAILED("NULL should be returned when an error occurs.");
- if (!expect_error && !result_str)
- return FAILED("When no error occurs NULL should not be returned.");
- for (i=0; i<expected_items_written;i++) {
- if (result_str [i] != expected_str [i])
- return FAILED("Incorrect value %d at index %d", result_str [i], i);
- }
- if (result_str && result_str[expected_items_written] != '\0')
- return FAILED("Null termination not found at the end of the string.");
-
- return OK;
-}
-
-RESULT
-test_utf16_to_ucs4 ()
-{
- static gunichar2 str1[12] = {'H','e','l','l','o',' ','W','o','r','l','d','\0'};
- static gunichar exp1[12] = {'H','e','l','l','o',' ','W','o','r','l','d','\0'};
- static gunichar2 str2[7] = {'H', 0xD800, 0xDC01,0xD800,0xDBFF,'l','\0'};
- static gunichar exp2[3] = {'H',0x00010001,'\0'};
- static gunichar2 str3[4] = {'H', 0xDC00 ,'l','\0'};
- static gunichar exp3[2] = {'H','\0'};
- static gunichar2 str4[20] = {0xDC00,0xDFFF,0xDFF,0xD800,0xDBFF,0xD800,0xDC00,0xD800,0xDFFF,
- 0xD800,0xE000,0xDBFF,0xDBFF,0xDBFF,0xDC00,0xDBFF,0xDFFF,0xDBFF,0xE000,'\0'};
- static gunichar exp4[6] = {0xDFF,0x10000,0x103ff,0x10fc00,0x10FFFF,'\0'};
- static gunichar2 str5[3] = {0xD801, 0xDC00, 0};
- static gunichar exp5[2] = {0x10400, 0};
- static glong read_write[33] = {1,0,0,1,0,0,1,1,1,2,1,0,2,2,1,2,2,1,2,1,0,2,1,0,2,2,1,2,2,1,2,1,0};
- gunichar* res;
- glong items_read, items_written, current_read_index,current_write_index;
- GError* err=0;
- RESULT check_result;
- glong i;
-
- res = g_utf16_to_ucs4 (str1, 12, &items_read, &items_written, &err);
- check_result = utf16_to_ucs4_check_result (res, exp1, items_read, 11, items_written, 11, err, FALSE);
- if (check_result) return check_result;
- g_free (res);
-
- items_read = items_written = 0;
- res = g_utf16_to_ucs4 (str2, 0, &items_read, &items_written, &err);
- check_result = utf16_to_ucs4_check_result (res, exp2, items_read, 0, items_written, 0, err, FALSE);
- if (check_result) return check_result;
- g_free (res);
-
- items_read = items_written = 0;
- res = g_utf16_to_ucs4 (str2, 1, &items_read, &items_written, &err);
- check_result = utf16_to_ucs4_check_result (res, exp2, items_read, 1, items_written, 1, err, FALSE);
- if (check_result) return check_result;
- g_free (res);
-
- items_read = items_written = 0;
- res = g_utf16_to_ucs4 (str2, 2, &items_read, &items_written, &err);
- check_result = utf16_to_ucs4_check_result (res, exp2, items_read, 1, items_written, 1, err, FALSE);
- if (check_result) return check_result;
- g_free (res);
-
- items_read = items_written = 0;
- res = g_utf16_to_ucs4 (str2, 3, &items_read, &items_written, &err);
- check_result = utf16_to_ucs4_check_result (res, exp2, items_read, 3, items_written, 2, err, FALSE);
- if (check_result) return check_result;
- g_free (res);
-
- items_read = items_written = 0;
- res = g_utf16_to_ucs4 (str2, 4, &items_read, &items_written, &err);
- check_result = utf16_to_ucs4_check_result (res, exp2, items_read, 3, items_written, 2, err, FALSE);
- if (check_result) return check_result;
- g_free (res);
-
- items_read = items_written = 0;
- res = g_utf16_to_ucs4 (str2, 5, &items_read, &items_written, &err);
- check_result = utf16_to_ucs4_check_result (res, exp2, items_read, 4, items_written, 0, err, TRUE);
- if (check_result) return check_result;
- g_free (res);
-
- items_read = items_written = 0;
- err = 0;
- res = g_utf16_to_ucs4 (str3, 5, &items_read, &items_written, &err);
- check_result = utf16_to_ucs4_check_result (res, exp3, items_read, 1, items_written, 0, err, TRUE);
- if (check_result) return check_result;
- g_free (res);
-
- // This loop tests the bounds of the conversion algorithm
- current_read_index = current_write_index = 0;
- for (i=0;i<11;i++) {
- items_read = items_written = 0;
- err = 0;
- res = g_utf16_to_ucs4 (&str4[current_read_index], read_write[i*3], &items_read, &items_written, &err);
- check_result = utf16_to_ucs4_check_result (res, &exp4[current_write_index], items_read,
- read_write[(i*3)+1], items_written, read_write[(i*3)+2], err,
- !read_write[(i*3)+2]);
- if (check_result) return check_result;
- g_free (res);
- current_read_index += read_write[i*3];
- current_write_index += items_written;
- }
-
- items_read = items_written = 0;
- err = 0;
- res = g_utf16_to_ucs4 (str5, 2, &items_read, &items_written, &err);
- check_result = utf16_to_ucs4_check_result (res, exp5, items_read, 2, items_written, 1, err, FALSE);
- if (check_result) return check_result;
- g_free (res);
-
- return OK;
-}
-RESULT
-test_utf8_strlen ()
-{
- gchar word1 [] = {0xC2, 0x82,0x45,0xE1, 0x81, 0x83,0x58,0xF1, 0x82, 0x82, 0x82,'\0'};//Valid, len = 5
- gchar word2 [] = {0xF1, 0x82, 0x82, 0x82,0xC2, 0x82,0x45,0xE1, 0x81, 0x83,0x58,'\0'};//Valid, len = 5
- gchar word3 [] = {'h','e',0xC2, 0x82,0x45,'\0'}; //Valid, len = 4
- gchar word4 [] = {0x62,0xC2, 0x82,0x45,0xE1, 0x81, 0x83,0x58,'\0'}; //Valid, len = 5
-
- glong len = 0;
-
- //Test word1
- len = g_utf8_strlen (word1,-1);
- if (len != 5)
- return FAILED ("Word1 expected length of 5, but was %i", len);
- //Do tests with different values for max parameter.
- len = g_utf8_strlen (word1,1);
- if (len != 0)
- return FAILED ("Word1, max = 1, expected length of 0, but was %i", len);
- len = g_utf8_strlen (word1,2);
- if (len != 1)
- return FAILED ("Word1, max = 1, expected length of 1, but was %i", len);
- len = g_utf8_strlen (word1,3);
- if (len != 2)
- return FAILED ("Word1, max = 2, expected length of 2, but was %i", len);
-
- //Test word2
- len = g_utf8_strlen (word2,-1);
- if (len != 5)
- return FAILED ("Word2 expected length of 5, but was %i", len);
-
- //Test word3
- len = g_utf8_strlen (word3,-1);
- if (len != 4)
- return FAILED ("Word3 expected length of 4, but was %i", len);
-
- //Test word4
- len = g_utf8_strlen (word4,-1);
- if (len != 5)
- return FAILED ("Word4 expected length of 5, but was %i", len);
-
- //Test null case
- len = g_utf8_strlen(NULL,0);
- if (len != 0)
- return FAILED ("Expected passing null to result in a length of 0");
- return OK;
-}
-
-RESULT
-test_utf8_get_char()
-{
- gchar word1 [] = {0xC2, 0x82,0x45,0xE1, 0x81, 0x83,0x58,0xF1, 0x82, 0x82, 0x82,'\0'}; //Valid, len = 5
-
- gunichar value = g_utf8_get_char (&word1 [0]);
- if (value != 0x82UL)
- return FAILED ("Expected value of 0x82, but was %x", value);
- value = g_utf8_get_char (&word1 [2]);
- if (value != 0x45UL)
- return FAILED ("Expected value of 0x45, but was %x", value);
- value = g_utf8_get_char (&word1 [3]);
- if (value != 0x1043UL)
- return FAILED ("Expected value of 0x1043, but was %x", value);
- value = g_utf8_get_char (&word1 [6]);
- if (value != 0x58UL)
- return FAILED ("Expected value of 0x58, but was %x", value);
- value = g_utf8_get_char (&word1 [7]);
- if (value != 0x42082UL)
- return FAILED ("Expected value of 0x42082, but was %x", value);
-
- return OK;
-}
-
-RESULT
-test_utf8_next_char()
-{
- gchar word1 [] = {0xC2, 0x82,0x45,0xE1, 0x81, 0x83,0x58,0xF1, 0x82, 0x82, 0x82,'\0'}; //Valid, len = 5
- gchar word2 [] = {0xF1, 0x82, 0x82, 0x82,0xC2, 0x82,0x45,0xE1, 0x81, 0x83,0x58,'\0'}; //Valid, len = 5
- gchar word1ExpectedValues [] = {0xC2, 0x45,0xE1, 0x58, 0xF1};
- gchar word2ExpectedValues [] = {0xF1, 0xC2, 0x45, 0xE1, 0x58};
-
- gchar* ptr = word1;
- gint count = 0;
- //Test word1
- while (*ptr != 0) {
- if (count > 4)
- return FAILED ("Word1 has gone past its expected length");
- if (*ptr != word1ExpectedValues[count])
- return FAILED ("Word1 has an incorrect next_char at index %i", count);
- ptr = g_utf8_next_char (ptr);
- count++;
- }
-
- //Test word2
- count = 0;
- ptr = word2;
- while (*ptr != 0) {
- if (count > 4)
- return FAILED ("Word2 has gone past its expected length");
- if (*ptr != word2ExpectedValues[count])
- return FAILED ("Word2 has an incorrect next_char at index %i", count);
- ptr = g_utf8_next_char (ptr);
- count++;
- }
-
- return OK;
-}
-
-RESULT
-test_utf8_validate()
-{
- gchar invalidWord1 [] = {0xC3, 0x82, 0xC1,0x90,'\0'}; //Invalid, 1nd oct Can't be 0xC0 or 0xC1
- gchar invalidWord2 [] = {0xC1, 0x89, 0x60, '\0'}; //Invalid, 1st oct can not be 0xC1
- gchar invalidWord3 [] = {0xC2, 0x45,0xE1, 0x81, 0x83,0x58,'\0'}; //Invalid, oct after 0xC2 must be > 0x80
-
- gchar validWord1 [] = {0xC2, 0x82, 0xC3,0xA0,'\0'}; //Valid
- gchar validWord2 [] = {0xC2, 0x82,0x45,0xE1, 0x81, 0x83,0x58,0xF1, 0x82, 0x82, 0x82,'\0'}; //Valid
-
- const gchar* end;
- gboolean retVal = g_utf8_validate (invalidWord1, -1, &end);
- if (retVal != FALSE)
- return FAILED ("Expected invalidWord1 to be invalid");
- if (end != &invalidWord1 [2])
- return FAILED ("Expected end parameter to be pointing to invalidWord1[2]");
-
- end = NULL;
- retVal = g_utf8_validate (invalidWord2, -1, &end);
- if (retVal != FALSE)
- return FAILED ("Expected invalidWord2 to be invalid");
- if (end != &invalidWord2 [0])
- return FAILED ("Expected end parameter to be pointing to invalidWord2[0]");
-
- end = NULL;
- retVal = g_utf8_validate (invalidWord3, -1, &end);
- if (retVal != FALSE)
- return FAILED ("Expected invalidWord3 to be invalid");
- if (end != &invalidWord3 [0])
- return FAILED ("Expected end parameter to be pointing to invalidWord3[1]");
-
- end = NULL;
- retVal = g_utf8_validate (validWord1, -1, &end);
- if (retVal != TRUE)
- return FAILED ("Expected validWord1 to be valid");
- if (end != &validWord1 [4])
- return FAILED ("Expected end parameter to be pointing to validWord1[4]");
-
- end = NULL;
- retVal = g_utf8_validate (validWord2, -1, &end);
- if (retVal != TRUE)
- return FAILED ("Expected validWord2 to be valid");
- if (end != &validWord2 [11])
- return FAILED ("Expected end parameter to be pointing to validWord2[11]");
- return OK;
-}
-
-glong
-utf8_byteslen (const gchar *src)
-{
- int i = 0;
- do {
- if (src [i] == '\0')
- return i;
- i++;
- } while (TRUE);
-}
-
-RESULT
-test_utf8_strcase_each (const gchar *src, const gchar *expected, gboolean strup)
-{
- gchar *tmp;
- glong len, len2;
- RESULT r;
-
- len = utf8_byteslen (src);
- tmp = strup ? g_utf8_strup (src, len) : g_utf8_strdown (src, len);
- len2 = utf8_byteslen (tmp);
- r = compare_strings_utf8_RESULT (expected, tmp, len < len2 ? len2 : len);
- g_free (tmp);
- return r;
-}
-
-RESULT
-test_utf8_strup_each (const gchar *src, const gchar *expected)
-{
- return test_utf8_strcase_each (src, expected, TRUE);
-}
-
-RESULT
-test_utf8_strdown_each (const gchar *src, const gchar *expected)
-{
- return test_utf8_strcase_each (src, expected, FALSE);
-}
-
-/*
- * g_utf8_strup
- */
-RESULT
-test_utf8_strup ()
-{
- RESULT r;
-
- if ((r = test_utf8_strup_each ("aBc", "ABC")) != OK)
- return r;
- if ((r = test_utf8_strup_each ("x86-64", "X86-64")) != OK)
- return r;
- // U+3B1 U+392 -> U+391 U+392
- if ((r = test_utf8_strup_each ("\xCE\xB1\xCE\x92", "\xCE\x91\xCE\x92")) != OK)
- return r;
- // U+FF21 -> U+FF21
- if ((r = test_utf8_strup_each ("\xEF\xBC\xA1", "\xEF\xBC\xA1")) != OK)
- return r;
- // U+FF41 -> U+FF21
- if ((r = test_utf8_strup_each ("\xEF\xBD\x81", "\xEF\xBC\xA1")) != OK)
- return r;
- // U+10428 -> U+10400
- if ((r = test_utf8_strup_each ("\xF0\x90\x90\xA8", "\xF0\x90\x90\x80")) != OK)
- return r;
-
- return OK;
-}
-
-/*
- * g_utf8_strdown
- */
-RESULT
-test_utf8_strdown ()
-{
- RESULT r;
-
- if ((r = test_utf8_strdown_each ("aBc", "abc")) != OK)
- return r;
- if ((r = test_utf8_strdown_each ("X86-64", "x86-64")) != OK)
- return r;
- // U+391 U+3B2 -> U+3B1 U+3B2
- if ((r = test_utf8_strdown_each ("\xCE\x91\xCE\xB2", "\xCE\xB1\xCE\xB2")) != OK)
- return r;
-/*
- // U+FF41 -> U+FF41
- if ((r = test_utf8_strdown_each ("\xEF\xBC\x81", "\xEF\xBC\x81")) != OK)
- return r;
- // U+FF21 -> U+FF41
- if ((r = test_utf8_strdown_each ("\xEF\xBC\xA1", "\xEF\xBD\x81")) != OK)
- return r;
- // U+10400 -> U+10428
- if ((r = test_utf8_strdown_each ("\xF0\x90\x90\x80", "\xF0\x90\x90\xA8")) != OK)
- return r;
-*/
- return OK;
-}
-
-/*
- * test initialization
- */
-
-static Test utf8_tests [] = {
- {"g_utf16_to_utf8", test_utf16_to_utf8},
- {"g_utf8_to_utf16", test_utf8_to_utf16},
- {"g_utf8_to_utf16_with_nuls", test_utf8_to_utf16_with_nuls},
- {"g_utf8_seq", test_utf8_seq},
- {"g_convert", test_convert },
- {"g_unichar_xdigit_value", test_xdigit },
- {"g_ucs4_to_utf16", test_ucs4_to_utf16 },
- {"g_utf16_to_ucs4", test_utf16_to_ucs4 },
- {"g_utf8_strlen", test_utf8_strlen },
- {"g_utf8_get_char", test_utf8_get_char },
- {"g_utf8_next_char", test_utf8_next_char },
- {"g_utf8_validate", test_utf8_validate },
- {"g_utf8_strup", test_utf8_strup},
- {"g_utf8_strdown", test_utf8_strdown},
- {NULL, NULL}
-};
-
-DEFINE_TEST_GROUP_INIT(utf8_tests_init, utf8_tests)
-
-
+++ /dev/null
-#!/bin/bash
-
-# Author: Aaron Bockover
-# Licensed under MIT/X11
-# (C) 2006 Novell
-
-if [ "x$1" = "x--help" ]; then
- echo "Usage: $0 [--show-only-mono]"
- echo ""
- echo "This script prints a sorted list of GLib functions used in Mono"
- echo "that have not yet been implemented in EGlib."
- echo ""
- echo "If --show-only-mono is passed, then the script will print all"
- echo "GLib functions used in Mono, whether or not they have been"
- echo "implemented in EGlib yet."
- echo ""
- echo "This script relies on the MONO_CHECKOUT environment variable."
- echo "MONO_CHECKOUT should be set to the location of a mono checkout."
- echo ""
- exit 1
-fi
-
-IGNORE_FUNCTIONS="g_hash_table_lookup_node g_hash_table_foreach_remove_or_steal g_hash_table_resize"
-
-if [ -z $MONO_CHECKOUT ]; then
- if [ -e ../../mono.pc.in ]; then
- MONO_CHECKOUT=../..
- else
- MONO_CHECKOUT=~/cvs/mono/mono
- fi
-fi
-
-if [ ! -d $MONO_CHECKOUT ]; then
- echo "Cannot find mono checkout; set MONO_CHECKOUT"
- exit 1
-fi
-
-MONO_CHECKOUT="$MONO_CHECKOUT/mono"
-RESULTS_FILE=.results
-
-(for i in `find $MONO_CHECKOUT -iregex \.*.c$`; do
- grep -oP "[ \t\(\)]+g_[a-z_]+[ ]{0,1}\([A-Za-z_\&\*\,\(\) ]+\)" $i |
- awk 'BEGIN { FS="(" } { print $1 }' |
- sed -e 's/[^A-Za-z_]//g'
- done
-) > $RESULTS_FILE
-
-if [ ! "x$1" = "x--show-only-mono" ]; then
- IMPLEMENTED_FUNCTIONS=`grep -oP "g_[a-z_]+[ ]{0,1}" ../src/glib.h | awk 'BEGIN { FS="(" } { print $1 }'`
-
- rm -f $RESULTS_FILE.tmp
-
- for mono_function in `cat $RESULTS_FILE`; do
- matched="no"
- for implemented_function in $IMPLEMENTED_FUNCTIONS; do
- if [ "x$mono_function" = "x$implemented_function" ]; then
- matched="yes"
- break
- fi
- done
-
- for ignore_function in $IGNORE_FUNCTIONS; do
- if [ "x$ignore_function" = "x$mono_function" ]; then
- matched="yes"
- break
- fi
- done
-
- if [ "x$matched" = "xno" ]; then
- echo $mono_function >> $RESULTS_FILE.tmp
- fi
- done
-
- mv $RESULTS_FILE.tmp $RESULTS_FILE
-fi
-
-(for i in `cat $RESULTS_FILE | sort -u`; do
- echo "`grep -c $i $RESULTS_FILE` $i";
- done;
-) | sort -nr
-
-rm $RESULTS_FILE
-
+++ /dev/null
-/* config.h. Generated by configure. */
-/* config.h.in. Generated from configure.ac by autoheader. */
-
-#ifndef _MSC_VER
-#include "cygconfig.h"
-#else
-
-#ifndef HAVE_WINAPI_FAMILY_SUPPORT
-
-#define HAVE_WINAPI_FAMILY_SUPPORT
-
-/* WIN API Family support */
-#include <winapifamily.h>
-
-#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
- #define HAVE_CLASSIC_WINAPI_SUPPORT 1
- #define HAVE_UWP_WINAPI_SUPPORT 0
-#elif WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)
- #define HAVE_CLASSIC_WINAPI_SUPPORT 0
- #define HAVE_UWP_WINAPI_SUPPORT 1
-#ifndef HAVE_EXTERN_DEFINED_WINAPI_SUPPORT
- #error Unsupported WINAPI family
-#endif
-#else
- #define HAVE_CLASSIC_WINAPI_SUPPORT 0
- #define HAVE_UWP_WINAPI_SUPPORT 0
-#ifndef HAVE_EXTERN_DEFINED_WINAPI_SUPPORT
- #error Unsupported WINAPI family
-#endif
-#endif
-
-#endif
-
-/* Define to 1 if you have the <dlfcn.h> header file. */
-#define HAVE_DLFCN_H 1
-
-/* Define to 1 if you have the <inttypes.h> header file. */
-#define HAVE_INTTYPES_H 1
-
-/* Define to 1 if you have the <memory.h> header file. */
-#define HAVE_MEMORY_H 1
-
-/* Define to 1 if you have the <pwd.h> header file. */
-/* #undef HAVE_PWD_H 1 */
-
-/* Define to 1 if you have the <stdint.h> header file. */
-#define HAVE_STDINT_H 1
-
-/* Define to 1 if you have the <stdlib.h> header file. */
-#define HAVE_STDLIB_H 1
-
-/* Define to 1 if you have the <strings.h> header file. */
-#define HAVE_STRINGS_H 1
-
-/* Define to 1 if you have the <string.h> header file. */
-#define HAVE_STRING_H 1
-
-/* Define to 1 if you have the `strlcpy' function. */
-/* #undef HAVE_STRLCPY */
-
-/* Define to 1 if you have the <sys/stat.h> header file. */
-#define HAVE_SYS_STAT_H 1
-
-/* Define to 1 if you have the <sys/time.h> header file. */
-/* #undef HAVE_SYS_TIME_H */
-
-/* Define to 1 if you have the <sys/types.h> header file. */
-#define HAVE_SYS_TYPES_H 1
-
-/* Define to 1 if you have the <sys/wait.h> header file. */
-/* #undef HAVE_SYS_WAIT_H */
-
-/* Define to 1 if you have the <unistd.h> header file. */
-/* #undef HAVE_UNISTD_H */
-
-/* Name of package */
-#define PACKAGE "eglib"
-
-/* Define to the address where bug reports for this package should be sent. */
-#define PACKAGE_BUGREPORT ""
-
-/* Define to the full name of this package. */
-#define PACKAGE_NAME ""
-
-/* Define to the full name and version of this package. */
-#define PACKAGE_STRING ""
-
-/* Define to the one symbol short name of this package. */
-#define PACKAGE_TARNAME ""
-
-/* Define to the version of this package. */
-#define PACKAGE_VERSION ""
-
-/* The size of a `int', as computed by sizeof. */
-#define SIZEOF_INT 4
-
-/* The size of a `void *', as computed by sizeof. */
-#define SIZEOF_VOID_P 4
-
-/* Define to 1 if you have the ANSI C header files. */
-#define STDC_HEADERS 1
-
-/* Version number of package */
-#define VERSION "0.1"
-
-#define HAVE_STRTOK_R 1
-#endif
endif
if CROSS_COMPILING
-SUBDIRS = $(btls_dirs) arch utils cil metadata $(sgen_dirs) mini dis profiler
+SUBDIRS = $(btls_dirs) eglib arch utils cil metadata $(sgen_dirs) mini dis profiler
else
if INSTALL_MONOTOUCH
-SUBDIRS = $(btls_dirs) arch utils metadata $(sgen_dirs) mini profiler
+SUBDIRS = $(btls_dirs) eglib arch utils metadata $(sgen_dirs) mini profiler
monotouch-do-build:
@list='$(SUBDIRS)'; for subdir in $$list; do \
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$target); \
done;
else
-SUBDIRS = $(btls_dirs) arch utils cil metadata $(sgen_dirs) mini dis tests unit-tests benchmark profiler
+SUBDIRS = $(btls_dirs) eglib arch utils cil metadata $(sgen_dirs) mini dis tests unit-tests benchmark profiler
endif
endif
-DIST_SUBDIRS = btls arch utils cil metadata $(sgen_dirs) mini dis tests unit-tests benchmark profiler
+DIST_SUBDIRS = btls eglib arch utils cil metadata $(sgen_dirs) mini dis tests unit-tests benchmark profiler
endif
if SUPPORT_SGEN
-metadata_lib=$(top_builddir)/mono/metadata/libmonoruntimesgen-static.la
-gc_lib=$(top_builddir)/mono/sgen/libmonosgen-static.la
+metadata_lib=$(top_builddir)/mono/metadata/libmonoruntimesgen.la
+gc_lib=$(top_builddir)/mono/sgen/libmonosgen.la
else
-metadata_lib=$(top_builddir)/mono/metadata/libmonoruntime-static.la
+metadata_lib=$(top_builddir)/mono/metadata/libmonoruntime.la
gc_lib=$(LIBGC_STATIC_LIBS)
endif
--- /dev/null
+/Makefile
+/Makefile.in
+/.libs
+/.deps
+/*.lo
+/*.la
+/*.o
+/semantic.cache
+/.project
+/.cproject
+/eglib-config.h
--- /dev/null
+noinst_LTLIBRARIES = libeglib.la
+
+AM_CFLAGS = $(WERROR_CFLAGS)
+
+win_files = \
+ eglib-config.hw \
+ gdate-win32.c gdir-win32.c gfile-win32.c gmisc-win32.c \
+ gmodule-win32.c gmodule-win32-internals.h gtimer-win32.c gunicode-win32.c
+
+unix_files = \
+ gdate-unix.c gdir-unix.c gfile-unix.c gmisc-unix.c \
+ gmodule-unix.c gtimer-unix.c
+
+if HOST_WIN32
+os_files = $(win_files)
+else
+os_files = $(unix_files)
+endif
+
+libeglib_la_SOURCES = \
+ eglib-remap.h \
+ sort.frag.h \
+ glib.h \
+ garray.c \
+ gbytearray.c \
+ gerror.c \
+ ghashtable.c \
+ giconv.c \
+ gmem.c \
+ gmodule.h \
+ goutput.c \
+ gqsort.c \
+ gstr.c \
+ gslist.c \
+ gstring.c \
+ gptrarray.c \
+ glist.c \
+ gqueue.c \
+ gpath.c \
+ gshell.c \
+ gspawn.c \
+ gfile.c \
+ gfile-posix.c \
+ gpattern.c \
+ gmarkup.c \
+ gutf8.c \
+ gunicode.c \
+ unicode-data.h \
+ $(os_files)
+
+libeglib_la_CFLAGS = -g -Wall -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE
+
+AM_CPPFLAGS = -I$(srcdir)
+
+if HOST_WIN32
+libeglib_la_LIBADD = -lm $(LIBICONV) -lpsapi
+else
+if PLATFORM_ANDROID
+libeglib_la_LIBADD = -llog
+endif
+endif
+
+MAINTAINERCLEANFILES = Makefile.in
+
+EXTRA_DIST = eglib-config.h.in $(win_files) $(unix_files)
--- /dev/null
+#ifndef __EGLIB_CONFIG_H
+#define __EGLIB_CONFIG_H
+
+/*
+ * System-dependent settings
+ */
+#define G_GNUC_PRETTY_FUNCTION @GNUC_PRETTY@
+#define G_GNUC_UNUSED @GNUC_UNUSED@
+#define G_BYTE_ORDER @ORDER@
+#define G_GNUC_NORETURN @GNUC_NORETURN@
+#define G_SEARCHPATH_SEPARATOR_S "@SEARCHSEP@"
+#define G_SEARCHPATH_SEPARATOR '@SEARCHSEP@'
+#define G_DIR_SEPARATOR '@PATHSEP@'
+#define G_DIR_SEPARATOR_S "@PATHSEP@"
+#define G_BREAKPOINT() @BREAKPOINT@
+#define G_OS_@OS@
+#define GPOINTER_TO_INT(ptr) @GPOINTER_TO_INT@
+#define GPOINTER_TO_UINT(ptr) @GPOINTER_TO_UINT@
+#define GINT_TO_POINTER(v) @GINT_TO_POINTER@
+#define GUINT_TO_POINTER(v) @GUINT_TO_POINTER@
+
+#if @HAVE_ALLOCA_H@ == 1
+#define G_HAVE_ALLOCA_H
+#endif
+
+typedef unsigned @GSIZE@ gsize;
+typedef signed @GSIZE@ gssize;
+
+#define G_GSIZE_FORMAT @GSIZE_FORMAT@
+
+#if @G_HAVE_ISO_VARARGS@ == 1
+#define G_HAVE_ISO_VARARGS
+#endif
+
+#if defined (HOST_WATCHOS)
+#undef G_BREAKPOINT
+#define G_BREAKPOINT()
+#endif
+
+typedef @PIDTYPE@ GPid;
+
+#endif
--- /dev/null
+#ifndef __EGLIB_CONFIG_H
+#define __EGLIB_CONFIG_H
+
+/*
+ * System-dependent settings
+ */
+#define G_OS_WIN32 1
+
+#ifdef _MSC_VER
+
+#include <io.h>
+
+#define G_GNUC_PRETTY_FUNCTION __FUNCTION__
+#define G_GNUC_UNUSED
+#define G_BYTE_ORDER 1234
+#define G_GNUC_NORETURN
+#define G_BREAKPOINT() __debugbreak()
+#define MAXPATHLEN 242
+
+typedef uintptr_t gsize;
+typedef intptr_t gssize;
+typedef int pid_t;
+
+#define G_DIR_SEPARATOR '\\'
+#define G_DIR_SEPARATOR_S "\\"
+#define G_SEARCHPATH_SEPARATOR_S ";"
+#define G_SEARCHPATH_SEPARATOR ';'
+#define G_GSIZE_FORMAT "d"
+#define GPOINTER_TO_INT(ptr) ((gint)(intptr_t) (ptr))
+#define GPOINTER_TO_UINT(ptr) ((guint)(intptr_t) (ptr))
+#define GINT_TO_POINTER(v) ((gpointer)(intptr_t) (v))
+#define GUINT_TO_POINTER(v) ((gpointer)(intptr_t) (v))
+
+#define STDOUT_FILENO (int)(intptr_t)stdout
+#define STDERR_FILENO (int)(intptr_t)stderr
+
+/* FIXME: what should this be ?*/
+#define X_OK 4 /* This is really read */
+#define WNOHANG 1
+#define F_SETFD 1
+#define FD_CLOEXEC 1
+
+#undef inline
+#define inline __inline
+
+#define strtok_r strtok_s
+
+#undef G_HAVE_UNISTD_H
+#undef G_HAVE_SYS_TIME_H
+#undef G_HAVE_SYS_WAIT_H
+#undef G_HAVE_PWD_H
+#undef G_HAVE_STRNDUP
+#define G_HAVE_GETOPT_H 1
+
+/* disable the following warnings
+ * C4100: The formal parameter is not referenced in the body of the function. The unreferenced parameter is ignored.
+ * C4127: conditional expression is constant
+*/
+#pragma warning(disable:4100 4127)
+#endif
+
+typedef void * GPid;
+#endif
--- /dev/null
+#define g_array_append monoeg_g_array_append
+#define g_array_append_vals monoeg_g_array_append_vals
+#define g_array_free monoeg_g_array_free
+#define g_array_insert_vals monoeg_g_array_insert_vals
+#define g_array_new monoeg_g_array_new
+#define g_array_remove_index monoeg_g_array_remove_index
+#define g_array_remove_index_fast monoeg_g_array_remove_index_fast
+#define g_array_set_size monoeg_g_array_set_size
+#define g_array_sized_new monoeg_g_array_sized_new
+#define g_ascii_strdown monoeg_g_ascii_strdown
+#define g_ascii_strncasecmp monoeg_g_ascii_strncasecmp
+#define g_ascii_tolower monoeg_g_ascii_tolower
+#define g_ascii_xdigit_value monoeg_g_ascii_xdigit_value
+#define g_build_path monoeg_g_build_path
+#define g_byte_array_append monoeg_g_byte_array_append
+#define g_byte_array_free monoeg_g_byte_array_free
+#define g_byte_array_new monoeg_g_byte_array_new
+#define g_byte_array_set_size monoeg_g_byte_array_set_size
+#define g_calloc monoeg_g_calloc
+#define g_clear_error monoeg_g_clear_error
+#define g_convert monoeg_g_convert
+#define g_convert_error_quark monoeg_g_convert_error_quark
+#define g_dir_close monoeg_g_dir_close
+#define g_dir_open monoeg_g_dir_open
+#define g_dir_read_name monoeg_g_dir_read_name
+#define g_dir_rewind monoeg_g_dir_rewind
+#define g_mkdir_with_parents monoeg_g_mkdir_with_parents
+#define g_direct_equal monoeg_g_direct_equal
+#define g_direct_hash monoeg_g_direct_hash
+#define g_ensure_directory_exists monoeg_g_ensure_directory_exists
+#define g_error_free monoeg_g_error_free
+#define g_error_new monoeg_g_error_new
+#define g_error_vnew monoeg_g_error_vnew
+#define g_file_error_quark monoeg_g_file_error_quark
+#define g_file_error_from_errno monoeg_g_file_error_from_errno
+#define g_file_get_contents monoeg_g_file_get_contents
+#define g_file_set_contents monoeg_g_file_set_contents
+#define g_file_open_tmp monoeg_g_file_open_tmp
+#define g_file_test monoeg_g_file_test
+#define g_filename_from_uri monoeg_g_filename_from_uri
+#define g_filename_from_utf8 monoeg_g_filename_from_utf8
+#define g_filename_to_uri monoeg_g_filename_to_uri
+#define g_find_program_in_path monoeg_g_find_program_in_path
+#define g_fprintf monoeg_g_fprintf
+#define g_free monoeg_g_free
+#define g_get_charset monoeg_g_get_charset
+#define g_get_current_dir monoeg_g_get_current_dir
+#define g_get_current_time monoeg_g_get_current_time
+#define g_get_home_dir monoeg_g_get_home_dir
+#define g_get_prgname monoeg_g_get_prgname
+#define g_get_tmp_dir monoeg_g_get_tmp_dir
+#define g_get_user_name monoeg_g_get_user_name
+#define g_getenv monoeg_g_getenv
+#define g_hasenv monoeg_g_hasenv
+#define g_hash_table_destroy monoeg_g_hash_table_destroy
+#define g_hash_table_find monoeg_g_hash_table_find
+#define g_hash_table_foreach monoeg_g_hash_table_foreach
+#define g_hash_table_foreach_remove monoeg_g_hash_table_foreach_remove
+#define g_hash_table_foreach_steal monoeg_g_hash_table_foreach_steal
+#define g_hash_table_get_keys monoeg_g_hash_table_get_keys
+#define g_hash_table_get_values monoeg_g_hash_table_get_values
+#define g_hash_table_insert_replace monoeg_g_hash_table_insert_replace
+#define g_hash_table_lookup monoeg_g_hash_table_lookup
+#define g_hash_table_lookup_extended monoeg_g_hash_table_lookup_extended
+#define g_hash_table_new monoeg_g_hash_table_new
+#define g_hash_table_new_full monoeg_g_hash_table_new_full
+#define g_hash_table_remove monoeg_g_hash_table_remove
+#define g_hash_table_steal monoeg_g_hash_table_steal
+#define g_hash_table_size monoeg_g_hash_table_size
+#define g_hash_table_print_stats monoeg_g_hash_table_print_stats
+#define g_hash_table_remove_all monoeg_g_hash_table_remove_all
+#define g_hash_table_iter_init monoeg_g_hash_table_iter_init
+#define g_hash_table_iter_next monoeg_g_hash_table_iter_next
+#define g_iconv monoeg_g_iconv
+#define g_iconv_close monoeg_g_iconv_close
+#define g_iconv_open monoeg_g_iconv_open
+#define g_int_equal monoeg_g_int_equal
+#define g_int_hash monoeg_g_int_hash
+#define g_list_alloc monoeg_g_list_alloc
+#define g_list_append monoeg_g_list_append
+#define g_list_concat monoeg_g_list_concat
+#define g_list_copy monoeg_g_list_copy
+#define g_list_delete_link monoeg_g_list_delete_link
+#define g_list_find monoeg_g_list_find
+#define g_list_find_custom monoeg_g_list_find_custom
+#define g_list_first monoeg_g_list_first
+#define g_list_foreach monoeg_g_list_foreach
+#define g_list_free monoeg_g_list_free
+#define g_list_free_1 monoeg_g_list_free_1
+#define g_list_index monoeg_g_list_index
+#define g_list_insert_before monoeg_g_list_insert_before
+#define g_list_insert_sorted monoeg_g_list_insert_sorted
+#define g_list_last monoeg_g_list_last
+#define g_list_length monoeg_g_list_length
+#define g_list_nth monoeg_g_list_nth
+#define g_list_nth_data monoeg_g_list_nth_data
+#define g_list_prepend monoeg_g_list_prepend
+#define g_list_remove monoeg_g_list_remove
+#define g_list_remove_all monoeg_g_list_remove_all
+#define g_list_remove_link monoeg_g_list_remove_link
+#define g_list_reverse monoeg_g_list_reverse
+#define g_list_sort monoeg_g_list_sort
+#define g_locale_from_utf8 monoeg_g_locale_from_utf8
+#define g_locale_to_utf8 monoeg_g_locale_to_utf8
+#define g_log monoeg_g_log
+#define g_log_set_always_fatal monoeg_g_log_set_always_fatal
+#define g_log_set_fatal_mask monoeg_g_log_set_fatal_mask
+#define g_logv monoeg_g_logv
+#define g_markup_parse_context_end_parse monoeg_g_markup_parse_context_end_parse
+#define g_markup_parse_context_free monoeg_g_markup_parse_context_free
+#define g_markup_parse_context_new monoeg_g_markup_parse_context_new
+#define g_markup_parse_context_parse monoeg_g_markup_parse_context_parse
+#define g_memdup monoeg_g_memdup
+#define g_mem_set_vtable monoeg_g_mem_set_vtable
+#define g_mkdtemp monoeg_g_mkdtemp
+#define g_module_build_path monoeg_g_module_build_path
+#define g_module_close monoeg_g_module_close
+#define g_module_error monoeg_g_module_error
+#define g_module_open monoeg_g_module_open
+#define g_module_symbol monoeg_g_module_symbol
+#define g_path_get_basename monoeg_g_path_get_basename
+#define g_path_get_dirname monoeg_g_path_get_dirname
+#define g_path_is_absolute monoeg_g_path_is_absolute
+#define g_pattern_match_string monoeg_g_pattern_match_string
+#define g_pattern_spec_free monoeg_g_pattern_spec_free
+#define g_pattern_spec_new monoeg_g_pattern_spec_new
+#define g_print monoeg_g_print
+#define g_printf monoeg_g_printf
+#define g_printerr monoeg_g_printerr
+#define g_propagate_error monoeg_g_propagate_error
+#define g_ptr_array_add monoeg_g_ptr_array_add
+#define g_ptr_array_foreach monoeg_g_ptr_array_foreach
+#define g_ptr_array_free monoeg_g_ptr_array_free
+#define g_ptr_array_new monoeg_g_ptr_array_new
+#define g_ptr_array_remove monoeg_g_ptr_array_remove
+#define g_ptr_array_remove_fast monoeg_g_ptr_array_remove_fast
+#define g_ptr_array_remove_index monoeg_g_ptr_array_remove_index
+#define g_ptr_array_remove_index_fast monoeg_g_ptr_array_remove_index_fast
+#define g_ptr_array_set_size monoeg_g_ptr_array_set_size
+#define g_ptr_array_sized_new monoeg_g_ptr_array_sized_new
+#define g_ptr_array_sort monoeg_g_ptr_array_sort
+#define g_ptr_array_sort_with_data monoeg_g_ptr_array_sort_with_data
+#define g_qsort_with_data monoeg_g_qsort_with_data
+#define g_queue_free monoeg_g_queue_free
+#define g_queue_is_empty monoeg_g_queue_is_empty
+#define g_queue_foreach monoeg_g_queue_foreach
+#define g_queue_new monoeg_g_queue_new
+#define g_queue_pop_head monoeg_g_queue_pop_head
+#define g_queue_push_head monoeg_g_queue_push_head
+#define g_queue_push_tail monoeg_g_queue_push_tail
+#define g_set_error monoeg_g_set_error
+#define g_set_prgname monoeg_g_set_prgname
+#define g_setenv monoeg_g_setenv
+#define g_shell_parse_argv monoeg_g_shell_parse_argv
+#define g_shell_quote monoeg_g_shell_quote
+#define g_shell_unquote monoeg_g_shell_unquote
+#define g_slist_alloc monoeg_g_slist_alloc
+#define g_slist_append monoeg_g_slist_append
+#define g_slist_concat monoeg_g_slist_concat
+#define g_slist_copy monoeg_g_slist_copy
+#define g_slist_delete_link monoeg_g_slist_delete_link
+#define g_slist_find monoeg_g_slist_find
+#define g_slist_find_custom monoeg_g_slist_find_custom
+#define g_slist_foreach monoeg_g_slist_foreach
+#define g_slist_free monoeg_g_slist_free
+#define g_slist_free_1 monoeg_g_slist_free_1
+#define g_slist_index monoeg_g_slist_index
+#define g_slist_insert_before monoeg_g_slist_insert_before
+#define g_slist_insert_sorted monoeg_g_slist_insert_sorted
+#define g_slist_last monoeg_g_slist_last
+#define g_slist_length monoeg_g_slist_length
+#define g_slist_nth monoeg_g_slist_nth
+#define g_slist_nth_data monoeg_g_slist_nth_data
+#define g_slist_prepend monoeg_g_slist_prepend
+#define g_slist_remove monoeg_g_slist_remove
+#define g_slist_remove_all monoeg_g_slist_remove_all
+#define g_slist_remove_link monoeg_g_slist_remove_link
+#define g_slist_reverse monoeg_g_slist_reverse
+#define g_slist_sort monoeg_g_slist_sort
+#define g_snprintf monoeg_g_snprintf
+#define g_spaced_primes_closest monoeg_g_spaced_primes_closest
+#define g_spawn_async_with_pipes monoeg_g_spawn_async_with_pipes
+#define g_spawn_command_line_sync monoeg_g_spawn_command_line_sync
+#define g_sprintf monoeg_g_sprintf
+#define g_stpcpy monoeg_g_stpcpy
+#define g_str_equal monoeg_g_str_equal
+#define g_str_has_prefix monoeg_g_str_has_prefix
+#define g_str_has_suffix monoeg_g_str_has_suffix
+#define g_str_hash monoeg_g_str_hash
+#define g_strchomp monoeg_g_strchomp
+#define g_strchug monoeg_g_strchug
+#define g_strconcat monoeg_g_strconcat
+#define g_strdelimit monoeg_g_strdelimit
+#define g_strdown monoeg_g_strdown
+#define g_strdup_printf monoeg_g_strdup_printf
+#define g_strdup_vprintf monoeg_g_strdup_vprintf
+#define g_strerror monoeg_g_strerror
+#define g_strescape monoeg_g_strescape
+#define g_strfreev monoeg_g_strfreev
+#define g_strdupv monoeg_g_strdupv
+#define g_string_append monoeg_g_string_append
+#define g_string_append_c monoeg_g_string_append_c
+#define g_string_append_len monoeg_g_string_append_len
+#define g_string_append_unichar monoeg_g_string_append_unichar
+#define g_string_append_printf monoeg_g_string_append_printf
+#define g_string_append_vprintf monoeg_g_string_append_vprintf
+#define g_string_erase monoeg_g_string_erase
+#define g_string_free monoeg_g_string_free
+#define g_string_insert monoeg_g_string_insert
+#define g_string_new monoeg_g_string_new
+#define g_string_new_len monoeg_g_string_new_len
+#define g_string_prepend monoeg_g_string_prepend
+#define g_string_printf monoeg_g_string_printf
+#define g_string_set_size monoeg_g_string_set_size
+#define g_string_sized_new monoeg_g_string_sized_new
+#define g_string_truncate monoeg_g_string_truncate
+#define g_strjoin monoeg_g_strjoin
+#define g_strjoinv monoeg_g_strjoinv
+#define g_strlcpy monoeg_g_strlcpy
+#define g_strndup monoeg_g_strndup
+#define g_strnfill monoeg_g_strnfill
+#define g_strreverse monoeg_g_strreverse
+#define g_strsplit monoeg_g_strsplit
+#define g_strsplit_set monoeg_g_strsplit_set
+#define g_strv_length monoeg_g_strv_length
+#define g_timer_destroy monoeg_g_timer_destroy
+#define g_timer_elapsed monoeg_g_timer_elapsed
+#define g_timer_new monoeg_g_timer_new
+#define g_timer_start monoeg_g_timer_start
+#define g_timer_stop monoeg_g_timer_stop
+#define g_trailingBytesForUTF8 monoeg_g_trailingBytesForUTF8
+#define g_ucs4_to_utf8 monoeg_g_ucs4_to_utf8
+#define g_ucs4_to_utf16 monoeg_g_ucs4_to_utf16
+#define g_unichar_case monoeg_g_unichar_case
+#define g_unichar_isxdigit monoeg_g_unichar_isxdigit
+#define g_unichar_tolower monoeg_g_unichar_tolower
+#define g_unichar_totitle monoeg_g_unichar_totitle
+#define g_unichar_toupper monoeg_g_unichar_toupper
+#define g_unichar_type monoeg_g_unichar_type
+#define g_unichar_xdigit_value monoeg_g_unichar_xdigit_value
+#define g_unsetenv monoeg_g_unsetenv
+#define g_usleep monoeg_g_usleep
+#define g_utf16_to_ucs4 monoeg_g_utf16_to_ucs4
+#define g_utf16_to_utf8 monoeg_g_utf16_to_utf8
+#define g_utf8_get_char monoeg_g_utf8_get_char
+#define g_utf8_offset_to_pointer monoeg_g_utf8_offset_to_pointer
+#define g_utf8_pointer_to_offset monoeg_g_utf8_pointer_to_offset
+#define g_utf8_strdown monoeg_g_utf8_strdown
+#define g_utf8_strlen monoeg_g_utf8_strlen
+#define g_utf8_strup monoeg_g_utf8_strup
+#define g_utf8_to_ucs4_fast monoeg_g_utf8_to_ucs4_fast
+#define g_utf8_to_utf16 monoeg_g_utf8_to_utf16
+#define g_utf8_validate monoeg_g_utf8_validate
+#define g_unichar_to_utf8 monoeg_g_unichar_to_utf8
+#define g_unichar_is_space monoeg_g_unichar_is_space
+#define g_unicode_break_type monoeg_g_unicode_break_type
+#define g_utf8_offset_to_pointer monoeg_g_utf8_offset_to_pointer
+#define g_utf8_pointer_to_offset monoeg_g_utf8_pointer_to_offset
+#define g_utf8_to_ucs4_fast monoeg_g_utf8_to_ucs4_fast
+#define g_vasprintf monoeg_g_vasprintf
+#define g_win32_getlocale monoeg_g_win32_getlocale
+#define g_assertion_message monoeg_assertion_message
+#define g_malloc monoeg_malloc
+#define g_malloc0 monoeg_malloc0
+#define g_ptr_array_grow monoeg_ptr_array_grow
+#define g_realloc monoeg_realloc
+#define g_try_malloc monoeg_try_malloc
+#define g_try_realloc monoeg_try_realloc
+#define g_strdup monoeg_strdup
+#define g_ucs4_to_utf16_len monoeg_ucs4_to_utf16_len
+#define g_utf16_to_ucs4_len monoeg_utf16_to_ucs4_len
+
+#define g_ascii_strcasecmp monoeg_ascii_strcasecmp
+#define g_ascii_strup monoeg_ascii_strup
+#define g_ascii_toupper monoeg_ascii_toupper
+#define g_unichar_break_type monoeg_unichar_break_type
+#define g_unichar_isspace monoeg_unichar_isspace
+#define g_unichar_to_utf16 monoeg_unichar_to_utf16
+#define g_utf8_find_prev_char monoeg_utf8_find_prev_char
+#define g_utf8_get_char_validated monoeg_utf8_get_char_validated
+#define g_utf8_prev_char monoeg_utf8_prev_char
+#define g_utf8_to_ucs4 monoeg_utf8_to_ucs4
+
+
+#define g_log_default_handler monoeg_log_default_handler
+#define g_log_set_default_handler monoeg_log_set_default_handler
+#define g_set_print_handler monoeg_set_print_handler
+#define g_set_printerr_handler monoeg_set_printerr_handler
--- /dev/null
+/*
+ * Arrays
+ *
+ * Author:
+ * Chris Toshok (toshok@novell.com)
+ *
+ * (C) 2006 Novell, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#include <stdlib.h>
+#include <glib.h>
+
+#define INITIAL_CAPACITY 16
+
+#define element_offset(p,i) ((p)->array.data + (i) * (p)->element_size)
+#define element_length(p,i) ((i) * (p)->element_size)
+
+typedef struct {
+ GArray array;
+ gboolean clear_;
+ guint element_size;
+ gboolean zero_terminated;
+ guint capacity;
+} GArrayPriv;
+
+static void
+ensure_capacity (GArrayPriv *priv, guint capacity)
+{
+ guint new_capacity;
+
+ if (capacity <= priv->capacity)
+ return;
+
+ new_capacity = (capacity + 63) & ~63;
+
+ priv->array.data = g_realloc (priv->array.data, element_length (priv, new_capacity));
+
+ if (priv->clear_) {
+ memset (element_offset (priv, priv->capacity),
+ 0,
+ element_length (priv, new_capacity - priv->capacity));
+ }
+
+ priv->capacity = new_capacity;
+}
+
+GArray *
+g_array_new (gboolean zero_terminated,
+ gboolean clear_,
+ guint element_size)
+{
+ GArrayPriv *rv = g_new0 (GArrayPriv, 1);
+ rv->zero_terminated = zero_terminated;
+ rv->clear_ = clear_;
+ rv->element_size = element_size;
+
+ ensure_capacity (rv, INITIAL_CAPACITY);
+
+ return (GArray*)rv;
+}
+
+GArray *
+g_array_sized_new (gboolean zero_terminated,
+ gboolean clear_,
+ guint element_size,
+ guint reserved_size)
+{
+ GArrayPriv *rv = g_new0 (GArrayPriv, 1);
+ rv->zero_terminated = zero_terminated;
+ rv->clear_ = clear_;
+ rv->element_size = element_size;
+
+ ensure_capacity (rv, reserved_size);
+
+ return (GArray*)rv;
+}
+
+gchar*
+g_array_free (GArray *array,
+ gboolean free_segment)
+{
+ gchar* rv = NULL;
+
+ g_return_val_if_fail (array != NULL, NULL);
+
+ if (free_segment)
+ g_free (array->data);
+ else
+ rv = array->data;
+
+ g_free (array);
+
+ return rv;
+}
+
+GArray *
+g_array_append_vals (GArray *array,
+ gconstpointer data,
+ guint len)
+{
+ GArrayPriv *priv = (GArrayPriv*)array;
+
+ g_return_val_if_fail (array != NULL, NULL);
+
+ ensure_capacity (priv, priv->array.len + len + (priv->zero_terminated ? 1 : 0));
+
+ memmove (element_offset (priv, priv->array.len),
+ data,
+ element_length (priv, len));
+
+ priv->array.len += len;
+
+ if (priv->zero_terminated) {
+ memset (element_offset (priv, priv->array.len),
+ 0,
+ priv->element_size);
+ }
+
+ return array;
+}
+
+GArray*
+g_array_insert_vals (GArray *array,
+ guint index_,
+ gconstpointer data,
+ guint len)
+{
+ GArrayPriv *priv = (GArrayPriv*)array;
+ guint extra = (priv->zero_terminated ? 1 : 0);
+
+ g_return_val_if_fail (array != NULL, NULL);
+
+ ensure_capacity (priv, array->len + len + extra);
+
+ /* first move the existing elements out of the way */
+ memmove (element_offset (priv, index_ + len),
+ element_offset (priv, index_),
+ element_length (priv, array->len - index_));
+
+ /* then copy the new elements into the array */
+ memmove (element_offset (priv, index_),
+ data,
+ element_length (priv, len));
+
+ array->len += len;
+
+ if (priv->zero_terminated) {
+ memset (element_offset (priv, priv->array.len),
+ 0,
+ priv->element_size);
+ }
+
+ return array;
+}
+
+GArray*
+g_array_remove_index (GArray *array,
+ guint index_)
+{
+ GArrayPriv *priv = (GArrayPriv*)array;
+
+ g_return_val_if_fail (array != NULL, NULL);
+
+ memmove (element_offset (priv, index_),
+ element_offset (priv, index_ + 1),
+ element_length (priv, array->len - index_));
+
+ array->len --;
+
+ if (priv->zero_terminated) {
+ memset (element_offset (priv, priv->array.len),
+ 0,
+ priv->element_size);
+ }
+
+ return array;
+}
+
+GArray*
+g_array_remove_index_fast (GArray *array,
+ guint index_)
+{
+ GArrayPriv *priv = (GArrayPriv*)array;
+
+ g_return_val_if_fail (array != NULL, NULL);
+
+ memmove (element_offset (priv, index_),
+ element_offset (priv, array->len - 1),
+ element_length (priv, 1));
+
+ array->len --;
+
+ if (priv->zero_terminated) {
+ memset (element_offset (priv, priv->array.len),
+ 0,
+ priv->element_size);
+ }
+
+ return array;
+}
+
+void
+g_array_set_size (GArray *array, gint length)
+{
+ GArrayPriv *priv = (GArrayPriv*)array;
+
+ g_return_if_fail (array != NULL);
+ g_return_if_fail (length >= 0);
+
+ if (length == priv->capacity)
+ return; // nothing to be done
+
+ if (length > priv->capacity) {
+ // grow the array
+ ensure_capacity (priv, length);
+ }
+
+ array->len = length;
+}
--- /dev/null
+/*
+ * Arrays
+ *
+ * Author:
+ * Geoff Norton (gnorton@novell.com)
+ *
+ * (C) 2010 Novell, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#include <stdlib.h>
+#include <glib.h>
+
+GByteArray *
+g_byte_array_new ()
+{
+ return (GByteArray *) g_array_new (FALSE, TRUE, 1);
+}
+
+guint8*
+g_byte_array_free (GByteArray *array,
+ gboolean free_segment)
+{
+ return (guint8*) g_array_free ((GArray *)array, free_segment);
+}
+
+GByteArray *
+g_byte_array_append (GByteArray *array,
+ const guint8 *data,
+ guint len)
+{
+ return (GByteArray *)g_array_append_vals ((GArray *)array, data, len);
+}
+
+void
+g_byte_array_set_size (GByteArray *array, gint length)
+{
+ g_array_set_size ((GArray *)array, length);
+}
+
--- /dev/null
+/*
+ * gdate-unix.c: Date and time utility functions.
+ *
+ * Author:
+ * Gonzalo Paniagua Javier (gonzalo@novell.com
+ *
+ * (C) 2006 Novell, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#include <stdio.h>
+#include <glib.h>
+#include <time.h>
+#include <errno.h>
+#include <sys/time.h>
+
+void
+g_get_current_time (GTimeVal *result)
+{
+ struct timeval tv;
+
+ g_return_if_fail (result != NULL);
+ gettimeofday (&tv, NULL);
+ result->tv_sec = tv.tv_sec;
+ result->tv_usec = tv.tv_usec;
+}
+
+void
+g_usleep (gulong microseconds)
+{
+ struct timespec req, rem;
+
+ req.tv_sec = microseconds / 1000000;
+ req.tv_nsec = (microseconds % 1000000) * 1000;
+
+ while (nanosleep (&req, &rem) == -1 && errno == EINTR)
+ req = rem;
+}
--- /dev/null
+/*
+ * gdate-win32.c: Date and time utility functions.
+ *
+ * Author:
+ * Gonzalo Paniagua Javier (gonzalo@novell.com
+ *
+ * (C) 2006 Novell, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#include <stdio.h>
+#include <glib.h>
+
+#include <winsock2.h>
+
+void
+g_get_current_time (GTimeVal *result)
+{
+ long int l;
+
+ g_return_if_fail (result != NULL);
+ l = GetTickCount();
+
+ result->tv_sec = l / 1000;
+ result->tv_usec = (l % 1000) * 1000;
+}
+
+void
+g_usleep (gulong microseconds)
+{
+ Sleep (microseconds/1000);
+}
--- /dev/null
+/*
+ * Directory utility functions.
+ *
+ * Author:
+ * Gonzalo Paniagua Javier (gonzalo@novell.com)
+ *
+ * (C) 2006 Novell, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#include <glib.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <dirent.h>
+
+struct _GDir {
+ DIR *dir;
+#ifndef HAVE_REWINDDIR
+ char *path;
+#endif
+};
+
+GDir *
+g_dir_open (const gchar *path, guint flags, GError **error)
+{
+ GDir *dir;
+
+ g_return_val_if_fail (path != NULL, NULL);
+ g_return_val_if_fail (error == NULL || *error == NULL, NULL);
+
+ (void) flags; /* this is not used */
+ dir = g_new (GDir, 1);
+ dir->dir = opendir (path);
+ if (dir->dir == NULL) {
+ if (error) {
+ gint err = errno;
+ *error = g_error_new (G_LOG_DOMAIN, g_file_error_from_errno (err), strerror (err));
+ }
+ g_free (dir);
+ return NULL;
+ }
+#ifndef HAVE_REWINDDIR
+ dir->path = g_strdup (path);
+#endif
+ return dir;
+}
+
+const gchar *
+g_dir_read_name (GDir *dir)
+{
+ struct dirent *entry;
+
+ g_return_val_if_fail (dir != NULL && dir->dir != NULL, NULL);
+ do {
+ entry = readdir (dir->dir);
+ if (entry == NULL)
+ return NULL;
+ } while ((strcmp (entry->d_name, ".") == 0) || (strcmp (entry->d_name, "..") == 0));
+
+ return entry->d_name;
+}
+
+void
+g_dir_rewind (GDir *dir)
+{
+ g_return_if_fail (dir != NULL && dir->dir != NULL);
+#ifndef HAVE_REWINDDIR
+ closedir (dir->dir);
+ dir->dir = opendir (dir->path);
+#else
+ rewinddir (dir->dir);
+#endif
+}
+
+void
+g_dir_close (GDir *dir)
+{
+ g_return_if_fail (dir != NULL && dir->dir != 0);
+ closedir (dir->dir);
+#ifndef HAVE_REWINDDIR
+ g_free (dir->path);
+#endif
+ dir->dir = NULL;
+ g_free (dir);
+}
+
+int
+g_mkdir_with_parents (const gchar *pathname, int mode)
+{
+ char *path, *d;
+ int rv;
+
+ if (!pathname || *pathname == '\0') {
+ errno = EINVAL;
+ return -1;
+ }
+
+ d = path = g_strdup (pathname);
+ if (*d == '/')
+ d++;
+
+ while (TRUE) {
+ if (*d == '/' || *d == '\0') {
+ char orig = *d;
+ *d = '\0';
+ rv = mkdir (path, mode);
+ if (rv == -1 && errno != EEXIST) {
+ g_free (path);
+ return -1;
+ }
+
+ *d++ = orig;
+ while (orig == '/' && *d == '/')
+ d++;
+ if (orig == '\0')
+ break;
+ } else {
+ d++;
+ }
+ }
+
+ g_free (path);
+
+ return 0;
+}
--- /dev/null
+/*
+ * Directory utility functions.
+ *
+ * Author:
+ * Gonzalo Paniagua Javier (gonzalo@novell.com)
+ *
+ * (C) 2006 Novell, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#include <glib.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <io.h>
+
+#include <winsock2.h>
+
+struct _GDir {
+ HANDLE handle;
+ gchar* current;
+ gchar* next;
+};
+
+GDir *
+g_dir_open (const gchar *path, guint flags, GError **error)
+{
+ GDir *dir;
+ gunichar2* path_utf16;
+ gunichar2* path_utf16_search;
+ WIN32_FIND_DATAW find_data;
+
+ g_return_val_if_fail (path != NULL, NULL);
+ g_return_val_if_fail (error == NULL || *error == NULL, NULL);
+
+ dir = g_new0 (GDir, 1);
+ path_utf16 = u8to16 (path);
+ path_utf16_search = g_malloc ((wcslen((wchar_t *) path_utf16) + 3)*sizeof(gunichar2));
+ wcscpy (path_utf16_search, path_utf16);
+ wcscat (path_utf16_search, L"\\*");
+
+ dir->handle = FindFirstFileW (path_utf16_search, &find_data);
+ if (dir->handle == INVALID_HANDLE_VALUE) {
+ if (error) {
+ gint err = errno;
+ *error = g_error_new (G_LOG_DOMAIN, g_file_error_from_errno (err), strerror (err));
+ }
+ g_free (path_utf16_search);
+ g_free (path_utf16);
+ g_free (dir);
+ return NULL;
+ }
+ g_free (path_utf16_search);
+ g_free (path_utf16);
+
+ while ((wcscmp ((wchar_t *) find_data.cFileName, L".") == 0) || (wcscmp ((wchar_t *) find_data.cFileName, L"..") == 0)) {
+ if (!FindNextFileW (dir->handle, &find_data)) {
+ if (error) {
+ gint err = errno;
+ *error = g_error_new (G_LOG_DOMAIN, g_file_error_from_errno (err), strerror (err));
+ }
+ g_free (dir);
+ return NULL;
+ }
+ }
+
+ dir->current = NULL;
+ dir->next = u16to8 (find_data.cFileName);
+ return dir;
+}
+
+const gchar *
+g_dir_read_name (GDir *dir)
+{
+ WIN32_FIND_DATAW find_data;
+
+ g_return_val_if_fail (dir != NULL && dir->handle != 0, NULL);
+
+ if (dir->current)
+ g_free (dir->current);
+ dir->current = NULL;
+
+ dir->current = dir->next;
+
+ if (!dir->current)
+ return NULL;
+
+ dir->next = NULL;
+
+ do {
+ if (!FindNextFileW (dir->handle, &find_data)) {
+ dir->next = NULL;
+ return dir->current;
+ }
+ } while ((wcscmp ((wchar_t *) find_data.cFileName, L".") == 0) || (wcscmp ((wchar_t *) find_data.cFileName, L"..") == 0));
+
+ dir->next = u16to8 (find_data.cFileName);
+ return dir->current;
+}
+
+void
+g_dir_rewind (GDir *dir)
+{
+}
+
+void
+g_dir_close (GDir *dir)
+{
+ g_return_if_fail (dir != NULL && dir->handle != 0);
+
+ if (dir->current)
+ g_free (dir->current);
+ dir->current = NULL;
+ if (dir->next)
+ g_free (dir->next);
+ dir->next = NULL;
+ FindClose (dir->handle);
+ dir->handle = 0;
+ g_free (dir);
+}
+
+
--- /dev/null
+/*
+ * gerror.c: Error support.
+ *
+ * Author:
+ * Miguel de Icaza (miguel@novell.com)
+ *
+ * (C) 2006 Novell, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#include <stdio.h>
+#include <stdarg.h>
+#include <string.h>
+#include <config.h>
+#include <glib.h>
+GError *
+g_error_new (gpointer domain, gint code, const char *format, ...)
+{
+ va_list args;
+ GError *err = g_new (GError, 1);
+
+ err->domain = domain;
+ err->code = code;
+
+ va_start (args, format);
+ if (g_vasprintf (&err->message, format, args) == -1)
+ err->message = g_strdup_printf ("internal: invalid format string %s", format);
+ va_end (args);
+
+ return err;
+}
+
+static GError *
+g_error_vnew (gpointer domain, gint code, const char *format, va_list ap)
+{
+ GError *err = g_new (GError, 1);
+
+ err->domain = domain;
+ err->code = code;
+
+ if (g_vasprintf (&err->message, format, ap) == -1)
+ err->message = g_strdup_printf ("internal: invalid format string %s", format);
+
+ return err;
+}
+
+void
+g_clear_error (GError **error)
+{
+ if (error && *error) {
+ g_error_free (*error);
+ *error = NULL;
+ }
+}
+
+void
+g_error_free (GError *error)
+{
+ g_return_if_fail (error != NULL);
+
+ g_free (error->message);
+ g_free (error);
+}
+
+void
+g_set_error (GError **err, gpointer domain, gint code, const gchar *format, ...)
+{
+ va_list args;
+
+ if (err) {
+ va_start (args, format);
+ *err = g_error_vnew (domain, code, format, args);
+ va_end (args);
+ }
+}
+
+void
+g_propagate_error (GError **dest, GError *src)
+{
+ if (dest == NULL){
+ if (src)
+ g_error_free (src);
+ } else {
+ *dest = src;
+ }
+}
--- /dev/null
+/*
+ * File utility functions.
+ *
+ * Author:
+ * Gonzalo Paniagua Javier (gonzalo@novell.com)
+ *
+ * (C) 2006 Novell, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#include <config.h>
+#include <glib.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#include <fcntl.h>
+#include <errno.h>
+
+#ifdef _MSC_VER
+#include <direct.h>
+#endif
+#ifdef G_OS_WIN32
+int mkstemp (char *tmp_template);
+#endif
+
+#ifndef O_LARGEFILE
+#define OPEN_FLAGS (O_RDONLY)
+#else
+#define OPEN_FLAGS (O_RDONLY | O_LARGEFILE)
+#endif
+gboolean
+g_file_get_contents (const gchar *filename, gchar **contents, gsize *length, GError **error)
+{
+ gchar *str;
+ int fd;
+ struct stat st;
+ long offset;
+ int nread;
+
+ g_return_val_if_fail (filename != NULL, FALSE);
+ g_return_val_if_fail (contents != NULL, FALSE);
+ g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
+
+ *contents = NULL;
+ if (length)
+ *length = 0;
+
+ fd = open (filename, OPEN_FLAGS);
+ if (fd == -1) {
+ if (error != NULL) {
+ int err = errno;
+ *error = g_error_new (G_LOG_DOMAIN, g_file_error_from_errno (err), "Error opening file");
+ }
+ return FALSE;
+ }
+
+ if (fstat (fd, &st) != 0) {
+ if (error != NULL) {
+ int err = errno;
+ *error = g_error_new (G_LOG_DOMAIN, g_file_error_from_errno (err), "Error in fstat()");
+ }
+ close (fd);
+ return FALSE;
+ }
+
+ str = g_malloc (st.st_size + 1);
+ offset = 0;
+ do {
+ nread = read (fd, str + offset, st.st_size - offset);
+ if (nread > 0) {
+ offset += nread;
+ }
+ } while ((nread > 0 && offset < st.st_size) || (nread == -1 && errno == EINTR));
+
+ close (fd);
+ str [st.st_size] = '\0';
+ if (length) {
+ *length = st.st_size;
+ }
+ *contents = str;
+ return TRUE;
+}
+
+gint
+g_file_open_tmp (const gchar *tmpl, gchar **name_used, GError **error)
+{
+ const static gchar *default_tmpl = ".XXXXXX";
+ gchar *t;
+ gint fd;
+ size_t len;
+
+ g_return_val_if_fail (error == NULL || *error == NULL, -1);
+
+ if (tmpl == NULL)
+ tmpl = default_tmpl;
+
+ if (strchr (tmpl, G_DIR_SEPARATOR) != NULL) {
+ if (error) {
+ *error = g_error_new (G_LOG_DOMAIN, 24, "Template should not have any " G_DIR_SEPARATOR_S);
+ }
+ return -1;
+ }
+
+ len = strlen (tmpl);
+ if (len < 6 || strcmp (tmpl + len - 6, "XXXXXX")) {
+ if (error) {
+ *error = g_error_new (G_LOG_DOMAIN, 24, "Template should end with XXXXXX");
+ }
+ return -1;
+ }
+
+ t = g_build_filename (g_get_tmp_dir (), tmpl, NULL);
+
+ fd = mkstemp (t);
+
+ if (fd == -1) {
+ if (error) {
+ int err = errno;
+ *error = g_error_new (G_LOG_DOMAIN, g_file_error_from_errno (err), "Error in mkstemp()");
+ }
+ g_free (t);
+ return -1;
+ }
+
+ if (name_used) {
+ *name_used = t;
+ } else {
+ g_free (t);
+ }
+ return fd;
+}
+
+gchar *
+g_get_current_dir (void)
+{
+ int s = 32;
+ char *buffer = NULL, *r;
+ gboolean fail;
+
+ do {
+ buffer = g_realloc (buffer, s);
+ r = getcwd (buffer, s);
+ fail = (r == NULL && errno == ERANGE);
+ if (fail) {
+ s <<= 1;
+ }
+ } while (fail);
+
+ /* On amd64 sometimes the bottom 32-bits of r == the bottom 32-bits of buffer
+ * but the top 32-bits of r have overflown to 0xffffffff (seriously wtf getcwd
+ * so we return the buffer here since it has a pointer to the valid string
+ */
+ return buffer;
+}
--- /dev/null
+/*
+ * File utility functions.
+ *
+ * Author:
+ * Gonzalo Paniagua Javier (gonzalo@novell.com)
+ *
+ * (C) 2006 Novell, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#include <config.h>
+#include <glib.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <errno.h>
+#include <fcntl.h>
+
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+gboolean
+g_file_test (const gchar *filename, GFileTest test)
+{
+ struct stat st;
+ gboolean have_stat;
+
+ if (filename == NULL || test == 0)
+ return FALSE;
+
+ have_stat = FALSE;
+
+ if ((test & G_FILE_TEST_EXISTS) != 0) {
+ if (access (filename, F_OK) == 0)
+ return TRUE;
+ }
+
+ if ((test & G_FILE_TEST_IS_EXECUTABLE) != 0) {
+ if (access (filename, X_OK) == 0)
+ return TRUE;
+ }
+ if ((test & G_FILE_TEST_IS_SYMLINK) != 0) {
+ have_stat = (lstat (filename, &st) == 0);
+ if (have_stat && S_ISLNK (st.st_mode))
+ return TRUE;
+ }
+
+ if ((test & G_FILE_TEST_IS_REGULAR) != 0) {
+ if (!have_stat)
+ have_stat = (stat (filename, &st) == 0);
+ if (have_stat && S_ISREG (st.st_mode))
+ return TRUE;
+ }
+ if ((test & G_FILE_TEST_IS_DIR) != 0) {
+ if (!have_stat)
+ have_stat = (stat (filename, &st) == 0);
+ if (have_stat && S_ISDIR (st.st_mode))
+ return TRUE;
+ }
+ return FALSE;
+}
+
+gchar *
+g_mkdtemp (char *tmp_template)
+{
+#ifdef HAVE_MKDTEMP
+ char *template_copy = g_strdup (tmp_template);
+
+ return mkdtemp (template_copy);
+#else
+ g_error("Function not supported");
+#endif
+}
--- /dev/null
+/*
+ * File utility functions.
+ *
+ * Author:
+ * Gonzalo Paniagua Javier (gonzalo@novell.com)
+ *
+ * (C) 2006 Novell, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#include <config.h>
+#include <windows.h>
+#include <glib.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <sys/types.h>
+#include <direct.h>
+
+#ifdef G_OS_WIN32
+#include <io.h>
+#define open _open
+#ifndef S_ISREG
+#define S_ISREG(x) ((x & _S_IFMT) == _S_IFREG)
+#endif
+#ifndef S_ISDIR
+#define S_ISDIR(x) ((x & _S_IFMT) == _S_IFDIR)
+#endif
+#endif
+
+int mkstemp (char *tmp_template)
+{
+ int fd;
+ gunichar2* utf16_template;
+
+ utf16_template = u8to16 (tmp_template);
+
+ fd = -1;
+ utf16_template = _wmktemp( utf16_template);
+ if (utf16_template && *utf16_template) {
+ /* FIXME: _O_TEMPORARY causes file to disappear on close causing a test to fail */
+ fd = _wopen( utf16_template, _O_BINARY | _O_CREAT /*| _O_TEMPORARY*/ | _O_RDWR | _O_EXCL, _S_IREAD | _S_IWRITE);
+ }
+
+ /* FIXME: this will crash if utf16_template == NULL */
+ sprintf (tmp_template + strlen (tmp_template) - 6, "%S", utf16_template + wcslen (utf16_template) - 6);
+
+ g_free (utf16_template);
+ return fd;
+}
+
+gchar *
+g_mkdtemp (char *tmp_template)
+{
+ gunichar2* utf16_template;
+
+ utf16_template = u8to16 (tmp_template);
+
+ utf16_template = _wmktemp(utf16_template);
+ if (utf16_template && *utf16_template) {
+ if (_wmkdir (utf16_template) == 0){
+ char *ret = u16to8 (utf16_template);
+ g_free (utf16_template);
+ return ret;
+ }
+ }
+
+ g_free (utf16_template);
+ return NULL;
+}
+
+#ifdef _MSC_VER
+#pragma warning(disable:4701)
+#endif
+
+gboolean
+g_file_test (const gchar *filename, GFileTest test)
+{
+ gunichar2* utf16_filename = NULL;
+ DWORD attr;
+
+ if (filename == NULL || test == 0)
+ return FALSE;
+
+ utf16_filename = u8to16 (filename);
+ attr = GetFileAttributesW (utf16_filename);
+ g_free (utf16_filename);
+
+ if (attr == INVALID_FILE_ATTRIBUTES)
+ return FALSE;
+
+ if ((test & G_FILE_TEST_EXISTS) != 0) {
+ return TRUE;
+ }
+
+ if ((test & G_FILE_TEST_IS_EXECUTABLE) != 0) {
+ size_t len = strlen (filename);
+ if (len > 4 && strcmp (filename + len-3, "exe"))
+ return TRUE;
+
+ return FALSE;
+ }
+
+ if ((test & G_FILE_TEST_IS_REGULAR) != 0) {
+ if (attr & (FILE_ATTRIBUTE_DEVICE|FILE_ATTRIBUTE_DIRECTORY))
+ return FALSE;
+ return TRUE;
+ }
+
+ if ((test & G_FILE_TEST_IS_DIR) != 0) {
+ if (attr & FILE_ATTRIBUTE_DIRECTORY)
+ return TRUE;
+ }
+
+ /* make this last in case it is OR'd with something else */
+ if ((test & G_FILE_TEST_IS_SYMLINK) != 0) {
+ return FALSE;
+ }
+
+ return FALSE;
+}
--- /dev/null
+/*
+ * File utility functions.
+ *
+ * Author:
+ * Gonzalo Paniagua Javier (gonzalo@novell.com)
+ *
+ * (C) 2006 Novell, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#include <config.h>
+
+#include <glib.h>
+#include <stdio.h>
+#include <string.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#include <errno.h>
+
+static gpointer error_quark = "FileError";
+
+gpointer
+g_file_error_quark (void)
+{
+ return error_quark;
+}
+
+GFileError
+g_file_error_from_errno (gint err_no)
+{
+ switch (err_no) {
+ case EEXIST:
+ return G_FILE_ERROR_EXIST;
+ case EISDIR:
+ return G_FILE_ERROR_ISDIR;
+ case EACCES:
+ return G_FILE_ERROR_ACCES;
+ case ENAMETOOLONG:
+ return G_FILE_ERROR_NAMETOOLONG;
+ case ENOENT:
+ return G_FILE_ERROR_NOENT;
+ case ENOTDIR:
+ return G_FILE_ERROR_NOTDIR;
+ case ENXIO:
+ return G_FILE_ERROR_NXIO;
+ case ENODEV:
+ return G_FILE_ERROR_NODEV;
+ case EROFS:
+ return G_FILE_ERROR_ROFS;
+#ifdef ETXTBSY
+ case ETXTBSY:
+ return G_FILE_ERROR_TXTBSY;
+#endif
+ case EFAULT:
+ return G_FILE_ERROR_FAULT;
+#ifdef ELOOP
+ case ELOOP:
+ return G_FILE_ERROR_LOOP;
+#endif
+ case ENOSPC:
+ return G_FILE_ERROR_NOSPC;
+ case ENOMEM:
+ return G_FILE_ERROR_NOMEM;
+ case EMFILE:
+ return G_FILE_ERROR_MFILE;
+ case ENFILE:
+ return G_FILE_ERROR_NFILE;
+ case EBADF:
+ return G_FILE_ERROR_BADF;
+ case EINVAL:
+ return G_FILE_ERROR_INVAL;
+ case EPIPE:
+ return G_FILE_ERROR_PIPE;
+ case EAGAIN:
+ return G_FILE_ERROR_AGAIN;
+ case EINTR:
+ return G_FILE_ERROR_INTR;
+ case EIO:
+ return G_FILE_ERROR_IO;
+ case EPERM:
+ return G_FILE_ERROR_PERM;
+ case ENOSYS:
+ return G_FILE_ERROR_NOSYS;
+ default:
+ return G_FILE_ERROR_FAILED;
+ }
+}
+
+#ifdef G_OS_WIN32
+#define TMP_FILE_FORMAT "%.*s%s.tmp"
+#else
+#define TMP_FILE_FORMAT "%.*s.%s~"
+#endif
+
+gboolean
+g_file_set_contents (const gchar *filename, const gchar *contents, gssize length, GError **err)
+{
+ const char *name;
+ char *path;
+ FILE *fp;
+
+ if (!(name = strrchr (filename, G_DIR_SEPARATOR)))
+ name = filename;
+ else
+ name++;
+
+ path = g_strdup_printf (TMP_FILE_FORMAT, name - filename, filename, name);
+ if (!(fp = fopen (path, "wb"))) {
+ g_set_error (err, G_FILE_ERROR, g_file_error_from_errno (errno), "%s", g_strerror (errno));
+ g_free (path);
+ return FALSE;
+ }
+
+ if (length < 0)
+ length = strlen (contents);
+
+ if (fwrite (contents, 1, length, fp) < length) {
+ g_set_error (err, G_FILE_ERROR, g_file_error_from_errno (ferror (fp)), "%s", g_strerror (ferror (fp)));
+ g_unlink (path);
+ g_free (path);
+ fclose (fp);
+
+ return FALSE;
+ }
+
+ fclose (fp);
+
+ if (g_rename (path, filename) != 0) {
+ g_set_error (err, G_FILE_ERROR, g_file_error_from_errno (errno), "%s", g_strerror (errno));
+ g_unlink (path);
+ g_free (path);
+ return FALSE;
+ }
+
+ g_free (path);
+
+ return TRUE;
+}
--- /dev/null
+/*
+ * ghashtable.c: Hashtable implementation
+ *
+ * Author:
+ * Miguel de Icaza (miguel@novell.com)
+ *
+ * (C) 2006 Novell, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#include <stdio.h>
+#include <math.h>
+#include <glib.h>
+
+typedef struct _Slot Slot;
+
+struct _Slot {
+ gpointer key;
+ gpointer value;
+ Slot *next;
+};
+
+static gpointer KEYMARKER_REMOVED = &KEYMARKER_REMOVED;
+
+struct _GHashTable {
+ GHashFunc hash_func;
+ GEqualFunc key_equal_func;
+
+ Slot **table;
+ int table_size;
+ int in_use;
+ int threshold;
+ int last_rehash;
+ GDestroyNotify value_destroy_func, key_destroy_func;
+};
+
+typedef struct {
+ GHashTable *ht;
+ int slot_index;
+ Slot *slot;
+} Iter;
+
+static const guint prime_tbl[] = {
+ 11, 19, 37, 73, 109, 163, 251, 367, 557, 823, 1237,
+ 1861, 2777, 4177, 6247, 9371, 14057, 21089, 31627,
+ 47431, 71143, 106721, 160073, 240101, 360163,
+ 540217, 810343, 1215497, 1823231, 2734867, 4102283,
+ 6153409, 9230113, 13845163
+};
+
+static gboolean
+test_prime (int x)
+{
+ if ((x & 1) != 0) {
+ int n;
+ for (n = 3; n< (int)sqrt (x); n += 2) {
+ if ((x % n) == 0)
+ return FALSE;
+ }
+ return TRUE;
+ }
+ // There is only one even prime - 2.
+ return (x == 2);
+}
+
+static int
+calc_prime (int x)
+{
+ int i;
+
+ for (i = (x & (~1))-1; i< G_MAXINT32; i += 2) {
+ if (test_prime (i))
+ return i;
+ }
+ return x;
+}
+
+guint
+g_spaced_primes_closest (guint x)
+{
+ int i;
+
+ for (i = 0; i < G_N_ELEMENTS (prime_tbl); i++) {
+ if (x <= prime_tbl [i])
+ return prime_tbl [i];
+ }
+ return calc_prime (x);
+}
+
+GHashTable *
+g_hash_table_new (GHashFunc hash_func, GEqualFunc key_equal_func)
+{
+ GHashTable *hash;
+
+ if (hash_func == NULL)
+ hash_func = g_direct_hash;
+ if (key_equal_func == NULL)
+ key_equal_func = g_direct_equal;
+ hash = g_new0 (GHashTable, 1);
+
+ hash->hash_func = hash_func;
+ hash->key_equal_func = key_equal_func;
+
+ hash->table_size = g_spaced_primes_closest (1);
+ hash->table = g_new0 (Slot *, hash->table_size);
+ hash->last_rehash = hash->table_size;
+
+ return hash;
+}
+
+GHashTable *
+g_hash_table_new_full (GHashFunc hash_func, GEqualFunc key_equal_func,
+ GDestroyNotify key_destroy_func, GDestroyNotify value_destroy_func)
+{
+ GHashTable *hash = g_hash_table_new (hash_func, key_equal_func);
+ if (hash == NULL)
+ return NULL;
+
+ hash->key_destroy_func = key_destroy_func;
+ hash->value_destroy_func = value_destroy_func;
+
+ return hash;
+}
+
+#if 0
+static void
+dump_hash_table (GHashTable *hash)
+{
+ int i;
+
+ for (i = 0; i < hash->table_size; i++) {
+ Slot *s;
+
+ for (s = hash->table [i]; s != NULL; s = s->next){
+ guint hashcode = (*hash->hash_func) (s->key);
+ guint slot = (hashcode) % hash->table_size;
+ printf ("key %p hash %x on slot %d correct slot %d tb size %d\n", s->key, hashcode, i, slot, hash->table_size);
+ }
+ }
+}
+#endif
+
+#ifdef SANITY_CHECK
+static void
+sanity_check (GHashTable *hash)
+{
+ int i;
+
+ for (i = 0; i < hash->table_size; i++) {
+ Slot *s;
+
+ for (s = hash->table [i]; s != NULL; s = s->next){
+ guint hashcode = (*hash->hash_func) (s->key);
+ guint slot = (hashcode) % hash->table_size;
+ if (slot != i) {
+ dump_hashcode_func = 1;
+ hashcode = (*hash->hash_func) (s->key);
+ dump_hashcode_func = 0;
+ g_error ("Key %p (bucket %d) on invalid bucket %d (hashcode %x) (tb size %d)", s->key, slot, i, hashcode, hash->table_size);
+ }
+ }
+ }
+}
+#else
+
+#define sanity_check(HASH) do {}while(0)
+
+#endif
+
+static void
+do_rehash (GHashTable *hash)
+{
+ int current_size, i;
+ Slot **table;
+
+ /* printf ("Resizing diff=%d slots=%d\n", hash->in_use - hash->last_rehash, hash->table_size); */
+ hash->last_rehash = hash->table_size;
+ current_size = hash->table_size;
+ hash->table_size = g_spaced_primes_closest (hash->in_use);
+ /* printf ("New size: %d\n", hash->table_size); */
+ table = hash->table;
+ hash->table = g_new0 (Slot *, hash->table_size);
+
+ for (i = 0; i < current_size; i++){
+ Slot *s, *next;
+
+ for (s = table [i]; s != NULL; s = next){
+ guint hashcode = ((*hash->hash_func) (s->key)) % hash->table_size;
+ next = s->next;
+
+ s->next = hash->table [hashcode];
+ hash->table [hashcode] = s;
+ }
+ }
+ g_free (table);
+}
+
+static void
+rehash (GHashTable *hash)
+{
+ int diff = ABS (hash->last_rehash - hash->in_use);
+
+ /* These are the factors to play with to change the rehashing strategy */
+ /* I played with them with a large range, and could not really get */
+ /* something that was too good, maybe the tests are not that great */
+ if (!(diff * 0.75 > hash->table_size * 2))
+ return;
+ do_rehash (hash);
+ sanity_check (hash);
+}
+
+void
+g_hash_table_insert_replace (GHashTable *hash, gpointer key, gpointer value, gboolean replace)
+{
+ guint hashcode;
+ Slot *s;
+ GEqualFunc equal;
+
+ g_return_if_fail (hash != NULL);
+ sanity_check (hash);
+
+ equal = hash->key_equal_func;
+ if (hash->in_use >= hash->threshold)
+ rehash (hash);
+
+ hashcode = ((*hash->hash_func) (key)) % hash->table_size;
+ for (s = hash->table [hashcode]; s != NULL; s = s->next){
+ if ((*equal) (s->key, key)){
+ if (replace){
+ if (hash->key_destroy_func != NULL)
+ (*hash->key_destroy_func)(s->key);
+ s->key = key;
+ }
+ if (hash->value_destroy_func != NULL)
+ (*hash->value_destroy_func) (s->value);
+ s->value = value;
+ sanity_check (hash);
+ return;
+ }
+ }
+ s = g_new (Slot, 1);
+ s->key = key;
+ s->value = value;
+ s->next = hash->table [hashcode];
+ hash->table [hashcode] = s;
+ hash->in_use++;
+ sanity_check (hash);
+}
+
+GList*
+g_hash_table_get_keys (GHashTable *hash)
+{
+ GHashTableIter iter;
+ GList *rv = NULL;
+ gpointer key;
+
+ g_hash_table_iter_init (&iter, hash);
+
+ while (g_hash_table_iter_next (&iter, &key, NULL))
+ rv = g_list_prepend (rv, key);
+
+ return g_list_reverse (rv);
+}
+
+GList*
+g_hash_table_get_values (GHashTable *hash)
+{
+ GHashTableIter iter;
+ GList *rv = NULL;
+ gpointer value;
+
+ g_hash_table_iter_init (&iter, hash);
+
+ while (g_hash_table_iter_next (&iter, NULL, &value))
+ rv = g_list_prepend (rv, value);
+
+ return g_list_reverse (rv);
+}
+
+
+guint
+g_hash_table_size (GHashTable *hash)
+{
+ g_return_val_if_fail (hash != NULL, 0);
+
+ return hash->in_use;
+}
+
+gpointer
+g_hash_table_lookup (GHashTable *hash, gconstpointer key)
+{
+ gpointer orig_key, value;
+
+ if (g_hash_table_lookup_extended (hash, key, &orig_key, &value))
+ return value;
+ else
+ return NULL;
+}
+
+gboolean
+g_hash_table_lookup_extended (GHashTable *hash, gconstpointer key, gpointer *orig_key, gpointer *value)
+{
+ GEqualFunc equal;
+ Slot *s;
+ guint hashcode;
+
+ g_return_val_if_fail (hash != NULL, FALSE);
+ sanity_check (hash);
+ equal = hash->key_equal_func;
+
+ hashcode = ((*hash->hash_func) (key)) % hash->table_size;
+
+ for (s = hash->table [hashcode]; s != NULL; s = s->next){
+ if ((*equal)(s->key, key)){
+ if (orig_key)
+ *orig_key = s->key;
+ if (value)
+ *value = s->value;
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+void
+g_hash_table_foreach (GHashTable *hash, GHFunc func, gpointer user_data)
+{
+ int i;
+
+ g_return_if_fail (hash != NULL);
+ g_return_if_fail (func != NULL);
+
+ for (i = 0; i < hash->table_size; i++){
+ Slot *s;
+
+ for (s = hash->table [i]; s != NULL; s = s->next)
+ (*func)(s->key, s->value, user_data);
+ }
+}
+
+gpointer
+g_hash_table_find (GHashTable *hash, GHRFunc predicate, gpointer user_data)
+{
+ int i;
+
+ g_return_val_if_fail (hash != NULL, NULL);
+ g_return_val_if_fail (predicate != NULL, NULL);
+
+ for (i = 0; i < hash->table_size; i++){
+ Slot *s;
+
+ for (s = hash->table [i]; s != NULL; s = s->next)
+ if ((*predicate)(s->key, s->value, user_data))
+ return s->value;
+ }
+ return NULL;
+}
+
+void
+g_hash_table_remove_all (GHashTable *hash)
+{
+ int i;
+
+ g_return_if_fail (hash != NULL);
+
+ for (i = 0; i < hash->table_size; i++){
+ Slot *s;
+
+ while (hash->table [i]) {
+ s = hash->table [i];
+ g_hash_table_remove (hash, s->key);
+ }
+ }
+}
+
+gboolean
+g_hash_table_remove (GHashTable *hash, gconstpointer key)
+{
+ GEqualFunc equal;
+ Slot *s, *last;
+ guint hashcode;
+
+ g_return_val_if_fail (hash != NULL, FALSE);
+ sanity_check (hash);
+ equal = hash->key_equal_func;
+
+ hashcode = ((*hash->hash_func)(key)) % hash->table_size;
+ last = NULL;
+ for (s = hash->table [hashcode]; s != NULL; s = s->next){
+ if ((*equal)(s->key, key)){
+ if (hash->key_destroy_func != NULL)
+ (*hash->key_destroy_func)(s->key);
+ if (hash->value_destroy_func != NULL)
+ (*hash->value_destroy_func)(s->value);
+ if (last == NULL)
+ hash->table [hashcode] = s->next;
+ else
+ last->next = s->next;
+ g_free (s);
+ hash->in_use--;
+ sanity_check (hash);
+ return TRUE;
+ }
+ last = s;
+ }
+ sanity_check (hash);
+ return FALSE;
+}
+
+guint
+g_hash_table_foreach_remove (GHashTable *hash, GHRFunc func, gpointer user_data)
+{
+ int i;
+ int count = 0;
+
+ g_return_val_if_fail (hash != NULL, 0);
+ g_return_val_if_fail (func != NULL, 0);
+
+ sanity_check (hash);
+ for (i = 0; i < hash->table_size; i++){
+ Slot *s, *last;
+
+ last = NULL;
+ for (s = hash->table [i]; s != NULL; ){
+ if ((*func)(s->key, s->value, user_data)){
+ Slot *n;
+
+ if (hash->key_destroy_func != NULL)
+ (*hash->key_destroy_func)(s->key);
+ if (hash->value_destroy_func != NULL)
+ (*hash->value_destroy_func)(s->value);
+ if (last == NULL){
+ hash->table [i] = s->next;
+ n = s->next;
+ } else {
+ last->next = s->next;
+ n = last->next;
+ }
+ g_free (s);
+ hash->in_use--;
+ count++;
+ s = n;
+ } else {
+ last = s;
+ s = s->next;
+ }
+ }
+ }
+ sanity_check (hash);
+ if (count > 0)
+ rehash (hash);
+ return count;
+}
+
+gboolean
+g_hash_table_steal (GHashTable *hash, gconstpointer key)
+{
+ GEqualFunc equal;
+ Slot *s, *last;
+ guint hashcode;
+
+ g_return_val_if_fail (hash != NULL, FALSE);
+ sanity_check (hash);
+ equal = hash->key_equal_func;
+
+ hashcode = ((*hash->hash_func)(key)) % hash->table_size;
+ last = NULL;
+ for (s = hash->table [hashcode]; s != NULL; s = s->next){
+ if ((*equal)(s->key, key)) {
+ if (last == NULL)
+ hash->table [hashcode] = s->next;
+ else
+ last->next = s->next;
+ g_free (s);
+ hash->in_use--;
+ sanity_check (hash);
+ return TRUE;
+ }
+ last = s;
+ }
+ sanity_check (hash);
+ return FALSE;
+
+}
+
+guint
+g_hash_table_foreach_steal (GHashTable *hash, GHRFunc func, gpointer user_data)
+{
+ int i;
+ int count = 0;
+
+ g_return_val_if_fail (hash != NULL, 0);
+ g_return_val_if_fail (func != NULL, 0);
+
+ sanity_check (hash);
+ for (i = 0; i < hash->table_size; i++){
+ Slot *s, *last;
+
+ last = NULL;
+ for (s = hash->table [i]; s != NULL; ){
+ if ((*func)(s->key, s->value, user_data)){
+ Slot *n;
+
+ if (last == NULL){
+ hash->table [i] = s->next;
+ n = s->next;
+ } else {
+ last->next = s->next;
+ n = last->next;
+ }
+ g_free (s);
+ hash->in_use--;
+ count++;
+ s = n;
+ } else {
+ last = s;
+ s = s->next;
+ }
+ }
+ }
+ sanity_check (hash);
+ if (count > 0)
+ rehash (hash);
+ return count;
+}
+
+void
+g_hash_table_destroy (GHashTable *hash)
+{
+ int i;
+
+ g_return_if_fail (hash != NULL);
+
+ for (i = 0; i < hash->table_size; i++){
+ Slot *s, *next;
+
+ for (s = hash->table [i]; s != NULL; s = next){
+ next = s->next;
+
+ if (hash->key_destroy_func != NULL)
+ (*hash->key_destroy_func)(s->key);
+ if (hash->value_destroy_func != NULL)
+ (*hash->value_destroy_func)(s->value);
+ g_free (s);
+ }
+ }
+ g_free (hash->table);
+
+ g_free (hash);
+}
+
+void
+g_hash_table_print_stats (GHashTable *table)
+{
+ int i, max_chain_index, chain_size, max_chain_size;
+ Slot *node;
+
+ max_chain_size = 0;
+ max_chain_index = -1;
+ for (i = 0; i < table->table_size; i++) {
+ chain_size = 0;
+ for (node = table->table [i]; node; node = node->next)
+ chain_size ++;
+ if (chain_size > max_chain_size) {
+ max_chain_size = chain_size;
+ max_chain_index = i;
+ }
+ }
+
+ printf ("Size: %d Table Size: %d Max Chain Length: %d at %d\n", table->in_use, table->table_size, max_chain_size, max_chain_index);
+}
+
+void
+g_hash_table_iter_init (GHashTableIter *it, GHashTable *hash_table)
+{
+ Iter *iter = (Iter*)it;
+
+ memset (iter, 0, sizeof (Iter));
+ iter->ht = hash_table;
+ iter->slot_index = -1;
+}
+
+gboolean g_hash_table_iter_next (GHashTableIter *it, gpointer *key, gpointer *value)
+{
+ Iter *iter = (Iter*)it;
+
+ GHashTable *hash = iter->ht;
+
+ g_assert (iter->slot_index != -2);
+ g_assert (sizeof (Iter) <= sizeof (GHashTableIter));
+
+ if (!iter->slot) {
+ while (TRUE) {
+ iter->slot_index ++;
+ if (iter->slot_index >= hash->table_size) {
+ iter->slot_index = -2;
+ return FALSE;
+ }
+ if (hash->table [iter->slot_index])
+ break;
+ }
+ iter->slot = hash->table [iter->slot_index];
+ }
+
+ if (key)
+ *key = iter->slot->key;
+ if (value)
+ *value = iter->slot->value;
+ iter->slot = iter->slot->next;
+
+ return TRUE;
+}
+
+gboolean
+g_direct_equal (gconstpointer v1, gconstpointer v2)
+{
+ return v1 == v2;
+}
+
+guint
+g_direct_hash (gconstpointer v1)
+{
+ return GPOINTER_TO_UINT (v1);
+}
+
+gboolean
+g_int_equal (gconstpointer v1, gconstpointer v2)
+{
+ return *(gint *)v1 == *(gint *)v2;
+}
+
+guint
+g_int_hash (gconstpointer v1)
+{
+ return *(guint *)v1;
+}
+
+gboolean
+g_str_equal (gconstpointer v1, gconstpointer v2)
+{
+ return strcmp (v1, v2) == 0;
+}
+
+guint
+g_str_hash (gconstpointer v1)
+{
+ guint hash = 0;
+ char *p = (char *) v1;
+
+ while (*p++)
+ hash = (hash << 5) - (hash + *p);
+
+ return hash;
+}
--- /dev/null
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2011 Jeffrey Stedfast
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy,
+ * modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <glib.h>
+#include <string.h>
+#ifdef HAVE_ICONV_H
+#include <iconv.h>
+#endif
+#include <errno.h>
+
+#ifdef _MSC_VER
+#define FORCE_INLINE(RET_TYPE) __forceinline RET_TYPE
+#else
+#define FORCE_INLINE(RET_TYPE) inline RET_TYPE __attribute__((always_inline))
+#endif
+
+
+#define UNROLL_DECODE_UTF8 0
+#define UNROLL_ENCODE_UTF8 0
+
+typedef int (* Decoder) (char *inbuf, size_t inleft, gunichar *outchar);
+typedef int (* Encoder) (gunichar c, char *outbuf, size_t outleft);
+
+struct _GIConv {
+ Decoder decode;
+ Encoder encode;
+ gunichar c;
+#ifdef HAVE_ICONV
+ iconv_t cd;
+#endif
+};
+
+static int decode_utf32be (char *inbuf, size_t inleft, gunichar *outchar);
+static int encode_utf32be (gunichar c, char *outbuf, size_t outleft);
+
+static int decode_utf32le (char *inbuf, size_t inleft, gunichar *outchar);
+static int encode_utf32le (gunichar c, char *outbuf, size_t outleft);
+
+static int decode_utf16be (char *inbuf, size_t inleft, gunichar *outchar);
+static int encode_utf16be (gunichar c, char *outbuf, size_t outleft);
+
+static int decode_utf16le (char *inbuf, size_t inleft, gunichar *outchar);
+static int encode_utf16le (gunichar c, char *outbuf, size_t outleft);
+
+static FORCE_INLINE (int) decode_utf8 (char *inbuf, size_t inleft, gunichar *outchar);
+static int encode_utf8 (gunichar c, char *outbuf, size_t outleft);
+
+static int decode_latin1 (char *inbuf, size_t inleft, gunichar *outchar);
+static int encode_latin1 (gunichar c, char *outbuf, size_t outleft);
+
+#if G_BYTE_ORDER == G_LITTLE_ENDIAN
+#define decode_utf32 decode_utf32le
+#define encode_utf32 encode_utf32le
+#define decode_utf16 decode_utf16le
+#define encode_utf16 encode_utf16le
+#else
+#define decode_utf32 decode_utf32be
+#define encode_utf32 encode_utf32be
+#define decode_utf16 decode_utf16be
+#define encode_utf16 encode_utf16be
+#endif
+
+static struct {
+ const char *name;
+ Decoder decoder;
+ Encoder encoder;
+} charsets[] = {
+ { "ISO-8859-1", decode_latin1, encode_latin1 },
+ { "ISO8859-1", decode_latin1, encode_latin1 },
+ { "UTF-32BE", decode_utf32be, encode_utf32be },
+ { "UTF-32LE", decode_utf32le, encode_utf32le },
+ { "UTF-16BE", decode_utf16be, encode_utf16be },
+ { "UTF-16LE", decode_utf16le, encode_utf16le },
+ { "UTF-32", decode_utf32, encode_utf32 },
+ { "UTF-16", decode_utf16, encode_utf16 },
+ { "UTF-8", decode_utf8, encode_utf8 },
+ { "US-ASCII", decode_latin1, encode_latin1 },
+ { "Latin1", decode_latin1, encode_latin1 },
+ { "ASCII", decode_latin1, encode_latin1 },
+ { "UTF32", decode_utf32, encode_utf32 },
+ { "UTF16", decode_utf16, encode_utf16 },
+ { "UTF8", decode_utf8, encode_utf8 },
+};
+
+
+GIConv
+g_iconv_open (const char *to_charset, const char *from_charset)
+{
+#ifdef HAVE_ICONV
+ iconv_t icd = (iconv_t) -1;
+#endif
+ Decoder decoder = NULL;
+ Encoder encoder = NULL;
+ GIConv cd;
+ guint i;
+
+ if (!to_charset || !from_charset || !to_charset[0] || !from_charset[0]) {
+ errno = EINVAL;
+
+ return (GIConv) -1;
+ }
+
+ for (i = 0; i < G_N_ELEMENTS (charsets); i++) {
+ if (!g_ascii_strcasecmp (charsets[i].name, from_charset))
+ decoder = charsets[i].decoder;
+
+ if (!g_ascii_strcasecmp (charsets[i].name, to_charset))
+ encoder = charsets[i].encoder;
+ }
+
+ if (!encoder || !decoder) {
+#ifdef HAVE_ICONV
+ if ((icd = iconv_open (to_charset, from_charset)) == (iconv_t) -1)
+ return (GIConv) -1;
+#else
+ errno = EINVAL;
+
+ return (GIConv) -1;
+#endif
+ }
+
+ cd = (GIConv) g_malloc (sizeof (struct _GIConv));
+ cd->decode = decoder;
+ cd->encode = encoder;
+ cd->c = -1;
+
+#ifdef HAVE_ICONV
+ cd->cd = icd;
+#endif
+
+ return cd;
+}
+
+int
+g_iconv_close (GIConv cd)
+{
+#ifdef HAVE_ICONV
+ if (cd->cd != (iconv_t) -1)
+ iconv_close (cd->cd);
+#endif
+
+ g_free (cd);
+
+ return 0;
+}
+
+gsize
+g_iconv (GIConv cd, gchar **inbytes, gsize *inbytesleft,
+ gchar **outbytes, gsize *outbytesleft)
+{
+ gsize inleft, outleft;
+ char *inptr, *outptr;
+ gunichar c;
+ int rc = 0;
+
+#ifdef HAVE_ICONV
+ if (cd->cd != (iconv_t) -1) {
+ /* Note: gsize may have a different size than size_t, so we need to
+ remap inbytesleft and outbytesleft to size_t's. */
+ size_t *outleftptr, *inleftptr;
+ size_t n_outleft, n_inleft;
+
+ if (inbytesleft) {
+ n_inleft = *inbytesleft;
+ inleftptr = &n_inleft;
+ } else {
+ inleftptr = NULL;
+ }
+
+ if (outbytesleft) {
+ n_outleft = *outbytesleft;
+ outleftptr = &n_outleft;
+ } else {
+ outleftptr = NULL;
+ }
+#if defined(__NetBSD__)
+ return iconv (cd->cd, (const gchar **)inbytes, inleftptr, outbytes, outleftptr);
+#else
+ return iconv (cd->cd, inbytes, inleftptr, outbytes, outleftptr);
+#endif
+ }
+#endif
+
+ if (outbytes == NULL || outbytesleft == NULL) {
+ /* reset converter */
+ cd->c = -1;
+ return 0;
+ }
+
+ inleft = inbytesleft ? *inbytesleft : 0;
+ inptr = inbytes ? *inbytes : NULL;
+ outleft = *outbytesleft;
+ outptr = *outbytes;
+
+ if ((c = cd->c) != (gunichar) -1)
+ goto encode;
+
+ while (inleft > 0) {
+ if ((rc = cd->decode (inptr, inleft, &c)) < 0)
+ break;
+
+ inleft -= rc;
+ inptr += rc;
+
+ encode:
+ if ((rc = cd->encode (c, outptr, outleft)) < 0)
+ break;
+
+ c = (gunichar) -1;
+ outleft -= rc;
+ outptr += rc;
+ }
+
+ if (inbytesleft)
+ *inbytesleft = inleft;
+
+ if (inbytes)
+ *inbytes = inptr;
+
+ *outbytesleft = outleft;
+ *outbytes = outptr;
+ cd->c = c;
+
+ return rc < 0 ? -1 : 0;
+}
+
+/*
+ * Unicode encoders and decoders
+ */
+
+static int
+decode_utf32be (char *inbuf, size_t inleft, gunichar *outchar)
+{
+ unsigned char *inptr = (unsigned char *) inbuf;
+ gunichar c;
+
+ if (inleft < 4) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ c = (inptr[0] << 24) | (inptr[1] << 16) | (inptr[2] << 8) | inptr[3];
+
+ if (c >= 0xd800 && c < 0xe000) {
+ errno = EILSEQ;
+ return -1;
+ } else if (c >= 0x110000) {
+ errno = EILSEQ;
+ return -1;
+ }
+
+ *outchar = c;
+
+ return 4;
+}
+
+static int
+decode_utf32le (char *inbuf, size_t inleft, gunichar *outchar)
+{
+ unsigned char *inptr = (unsigned char *) inbuf;
+ gunichar c;
+
+ if (inleft < 4) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ c = (inptr[3] << 24) | (inptr[2] << 16) | (inptr[1] << 8) | inptr[0];
+
+ if (c >= 0xd800 && c < 0xe000) {
+ errno = EILSEQ;
+ return -1;
+ } else if (c >= 0x110000) {
+ errno = EILSEQ;
+ return -1;
+ }
+
+ *outchar = c;
+
+ return 4;
+}
+
+static int
+encode_utf32be (gunichar c, char *outbuf, size_t outleft)
+{
+ unsigned char *outptr = (unsigned char *) outbuf;
+
+ if (outleft < 4) {
+ errno = E2BIG;
+ return -1;
+ }
+
+ outptr[0] = (c >> 24) & 0xff;
+ outptr[1] = (c >> 16) & 0xff;
+ outptr[2] = (c >> 8) & 0xff;
+ outptr[3] = c & 0xff;
+
+ return 4;
+}
+
+static int
+encode_utf32le (gunichar c, char *outbuf, size_t outleft)
+{
+ unsigned char *outptr = (unsigned char *) outbuf;
+
+ if (outleft < 4) {
+ errno = E2BIG;
+ return -1;
+ }
+
+ outptr[0] = c & 0xff;
+ outptr[1] = (c >> 8) & 0xff;
+ outptr[2] = (c >> 16) & 0xff;
+ outptr[3] = (c >> 24) & 0xff;
+
+ return 4;
+}
+
+static int
+decode_utf16be (char *inbuf, size_t inleft, gunichar *outchar)
+{
+ unsigned char *inptr = (unsigned char *) inbuf;
+ gunichar2 c;
+ gunichar u;
+
+ if (inleft < 2) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ u = (inptr[0] << 8) | inptr[1];
+
+ if (u < 0xd800) {
+ /* 0x0000 -> 0xd7ff */
+ *outchar = u;
+ return 2;
+ } else if (u < 0xdc00) {
+ /* 0xd800 -> 0xdbff */
+ if (inleft < 4) {
+ errno = EINVAL;
+ return -2;
+ }
+
+ c = (inptr[2] << 8) | inptr[3];
+
+ if (c < 0xdc00 || c > 0xdfff) {
+ errno = EILSEQ;
+ return -2;
+ }
+
+ u = ((u - 0xd800) << 10) + (c - 0xdc00) + 0x0010000UL;
+ *outchar = u;
+
+ return 4;
+ } else if (u < 0xe000) {
+ /* 0xdc00 -> 0xdfff */
+ errno = EILSEQ;
+ return -1;
+ } else {
+ /* 0xe000 -> 0xffff */
+ *outchar = u;
+ return 2;
+ }
+}
+
+static int
+decode_utf16le (char *inbuf, size_t inleft, gunichar *outchar)
+{
+ unsigned char *inptr = (unsigned char *) inbuf;
+ gunichar2 c;
+ gunichar u;
+
+ if (inleft < 2) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ u = (inptr[1] << 8) | inptr[0];
+
+ if (u < 0xd800) {
+ /* 0x0000 -> 0xd7ff */
+ *outchar = u;
+ return 2;
+ } else if (u < 0xdc00) {
+ /* 0xd800 -> 0xdbff */
+ if (inleft < 4) {
+ errno = EINVAL;
+ return -2;
+ }
+
+ c = (inptr[3] << 8) | inptr[2];
+
+ if (c < 0xdc00 || c > 0xdfff) {
+ errno = EILSEQ;
+ return -2;
+ }
+
+ u = ((u - 0xd800) << 10) + (c - 0xdc00) + 0x0010000UL;
+ *outchar = u;
+
+ return 4;
+ } else if (u < 0xe000) {
+ /* 0xdc00 -> 0xdfff */
+ errno = EILSEQ;
+ return -1;
+ } else {
+ /* 0xe000 -> 0xffff */
+ *outchar = u;
+ return 2;
+ }
+}
+
+static int
+encode_utf16be (gunichar c, char *outbuf, size_t outleft)
+{
+ unsigned char *outptr = (unsigned char *) outbuf;
+ gunichar2 ch;
+ gunichar c2;
+
+ if (c < 0x10000) {
+ if (outleft < 2) {
+ errno = E2BIG;
+ return -1;
+ }
+
+ outptr[0] = (c >> 8) & 0xff;
+ outptr[1] = c & 0xff;
+
+ return 2;
+ } else {
+ if (outleft < 4) {
+ errno = E2BIG;
+ return -1;
+ }
+
+ c2 = c - 0x10000;
+
+ ch = (gunichar2) ((c2 >> 10) + 0xd800);
+ outptr[0] = (ch >> 8) & 0xff;
+ outptr[1] = ch & 0xff;
+
+ ch = (gunichar2) ((c2 & 0x3ff) + 0xdc00);
+ outptr[2] = (ch >> 8) & 0xff;
+ outptr[3] = ch & 0xff;
+
+ return 4;
+ }
+}
+
+static int
+encode_utf16le (gunichar c, char *outbuf, size_t outleft)
+{
+ unsigned char *outptr = (unsigned char *) outbuf;
+ gunichar2 ch;
+ gunichar c2;
+
+ if (c < 0x10000) {
+ if (outleft < 2) {
+ errno = E2BIG;
+ return -1;
+ }
+
+ outptr[0] = c & 0xff;
+ outptr[1] = (c >> 8) & 0xff;
+
+ return 2;
+ } else {
+ if (outleft < 4) {
+ errno = E2BIG;
+ return -1;
+ }
+
+ c2 = c - 0x10000;
+
+ ch = (gunichar2) ((c2 >> 10) + 0xd800);
+ outptr[0] = ch & 0xff;
+ outptr[1] = (ch >> 8) & 0xff;
+
+ ch = (gunichar2) ((c2 & 0x3ff) + 0xdc00);
+ outptr[2] = ch & 0xff;
+ outptr[3] = (ch >> 8) & 0xff;
+
+ return 4;
+ }
+}
+
+static FORCE_INLINE (int)
+decode_utf8 (char *inbuf, size_t inleft, gunichar *outchar)
+{
+ unsigned char *inptr = (unsigned char *) inbuf;
+ gunichar u;
+ int n, i;
+
+ u = *inptr;
+
+ if (u < 0x80) {
+ /* simple ascii case */
+ *outchar = u;
+ return 1;
+ } else if (u < 0xc2) {
+ errno = EILSEQ;
+ return -1;
+ } else if (u < 0xe0) {
+ u &= 0x1f;
+ n = 2;
+ } else if (u < 0xf0) {
+ u &= 0x0f;
+ n = 3;
+ } else if (u < 0xf8) {
+ u &= 0x07;
+ n = 4;
+ } else if (u < 0xfc) {
+ u &= 0x03;
+ n = 5;
+ } else if (u < 0xfe) {
+ u &= 0x01;
+ n = 6;
+ } else {
+ errno = EILSEQ;
+ return -1;
+ }
+
+ if (n > inleft) {
+ errno = EINVAL;
+ return -1;
+ }
+
+#if UNROLL_DECODE_UTF8
+ switch (n) {
+ case 6: u = (u << 6) | (*++inptr ^ 0x80);
+ case 5: u = (u << 6) | (*++inptr ^ 0x80);
+ case 4: u = (u << 6) | (*++inptr ^ 0x80);
+ case 3: u = (u << 6) | (*++inptr ^ 0x80);
+ case 2: u = (u << 6) | (*++inptr ^ 0x80);
+ }
+#else
+ for (i = 1; i < n; i++)
+ u = (u << 6) | (*++inptr ^ 0x80);
+#endif
+
+ *outchar = u;
+
+ return n;
+}
+
+static int
+encode_utf8 (gunichar c, char *outbuf, size_t outleft)
+{
+ unsigned char *outptr = (unsigned char *) outbuf;
+ int base, n, i;
+
+ if (c < 0x80) {
+ outptr[0] = c;
+ return 1;
+ } else if (c < 0x800) {
+ base = 192;
+ n = 2;
+ } else if (c < 0x10000) {
+ base = 224;
+ n = 3;
+ } else if (c < 0x200000) {
+ base = 240;
+ n = 4;
+ } else if (c < 0x4000000) {
+ base = 248;
+ n = 5;
+ } else {
+ base = 252;
+ n = 6;
+ }
+
+ if (outleft < n) {
+ errno = E2BIG;
+ return -1;
+ }
+
+#if UNROLL_ENCODE_UTF8
+ switch (n) {
+ case 6: outptr[5] = (c & 0x3f) | 0x80; c >>= 6;
+ case 5: outptr[4] = (c & 0x3f) | 0x80; c >>= 6;
+ case 4: outptr[3] = (c & 0x3f) | 0x80; c >>= 6;
+ case 3: outptr[2] = (c & 0x3f) | 0x80; c >>= 6;
+ case 2: outptr[1] = (c & 0x3f) | 0x80; c >>= 6;
+ case 1: outptr[0] = c | base;
+ }
+#else
+ for (i = n - 1; i > 0; i--) {
+ outptr[i] = (c & 0x3f) | 0x80;
+ c >>= 6;
+ }
+
+ outptr[0] = c | base;
+#endif
+
+ return n;
+}
+
+static int
+decode_latin1 (char *inbuf, size_t inleft, gunichar *outchar)
+{
+ *outchar = (unsigned char) *inbuf;
+ return 1;
+}
+
+static int
+encode_latin1 (gunichar c, char *outbuf, size_t outleft)
+{
+ if (outleft < 1) {
+ errno = E2BIG;
+ return -1;
+ }
+
+ if (c > 0xff) {
+ errno = EILSEQ;
+ return -1;
+ }
+
+ *outbuf = (char) c;
+
+ return 1;
+}
+
+
+/*
+ * Simple conversion API
+ */
+
+static gpointer error_quark = "ConvertError";
+
+gpointer
+g_convert_error_quark (void)
+{
+ return error_quark;
+}
+
+gchar *
+g_convert (const gchar *str, gssize len, const gchar *to_charset, const gchar *from_charset,
+ gsize *bytes_read, gsize *bytes_written, GError **err)
+{
+ gsize outsize, outused, outleft, inleft, grow, rc;
+ char *result, *outbuf, *inbuf;
+ gboolean flush = FALSE;
+ gboolean done = FALSE;
+ GIConv cd;
+
+ g_return_val_if_fail (str != NULL, NULL);
+ g_return_val_if_fail (to_charset != NULL, NULL);
+ g_return_val_if_fail (from_charset != NULL, NULL);
+
+ if ((cd = g_iconv_open (to_charset, from_charset)) == (GIConv) -1) {
+ g_set_error (err, G_CONVERT_ERROR, G_CONVERT_ERROR_NO_CONVERSION,
+ "Conversion from %s to %s not supported.",
+ from_charset, to_charset);
+
+ if (bytes_written)
+ *bytes_written = 0;
+
+ if (bytes_read)
+ *bytes_read = 0;
+
+ return NULL;
+ }
+
+ inleft = len < 0 ? strlen (str) : len;
+ inbuf = (char *) str;
+
+ outleft = outsize = MAX (inleft, 8);
+ outbuf = result = g_malloc (outsize + 4);
+
+ do {
+ if (!flush)
+ rc = g_iconv (cd, &inbuf, &inleft, &outbuf, &outleft);
+ else
+ rc = g_iconv (cd, NULL, NULL, &outbuf, &outleft);
+
+ if (rc == (gsize) -1) {
+ switch (errno) {
+ case E2BIG:
+ /* grow our result buffer */
+ grow = MAX (inleft, 8) << 1;
+ outused = outbuf - result;
+ outsize += grow;
+ outleft += grow;
+ result = g_realloc (result, outsize + 4);
+ outbuf = result + outused;
+ break;
+ case EINVAL:
+ /* incomplete input, stop converting and terminate here */
+ if (flush)
+ done = TRUE;
+ else
+ flush = TRUE;
+ break;
+ case EILSEQ:
+ /* illegal sequence in the input */
+ g_set_error (err, G_CONVERT_ERROR, G_CONVERT_ERROR_ILLEGAL_SEQUENCE, "%s", g_strerror (errno));
+
+ if (bytes_read) {
+ /* save offset of the illegal input sequence */
+ *bytes_read = (inbuf - str);
+ }
+
+ if (bytes_written)
+ *bytes_written = 0;
+
+ g_iconv_close (cd);
+ g_free (result);
+ return NULL;
+ default:
+ /* unknown errno */
+ g_set_error (err, G_CONVERT_ERROR, G_CONVERT_ERROR_FAILED, "%s", g_strerror (errno));
+
+ if (bytes_written)
+ *bytes_written = 0;
+
+ if (bytes_read)
+ *bytes_read = 0;
+
+ g_iconv_close (cd);
+ g_free (result);
+ return NULL;
+ }
+ } else if (flush) {
+ /* input has been converted and output has been flushed */
+ break;
+ } else {
+ /* input has been converted, need to flush the output */
+ flush = TRUE;
+ }
+ } while (!done);
+
+ g_iconv_close (cd);
+
+ /* Note: not all charsets can be null-terminated with a single
+ null byte. UCS2, for example, needs 2 null bytes and UCS4
+ needs 4. I hope that 4 null bytes is enough to terminate all
+ multibyte charsets? */
+
+ /* null-terminate the result */
+ memset (outbuf, 0, 4);
+
+ if (bytes_written)
+ *bytes_written = outbuf - result;
+
+ if (bytes_read)
+ *bytes_read = inbuf - str;
+
+ return result;
+}
+
+
+/*
+ * Unicode conversion
+ */
+
+/**
+ * An explanation of the conversion can be found at:
+ * http://home.tiscali.nl/t876506/utf8tbl.html
+ *
+ **/
+gint
+g_unichar_to_utf8 (gunichar c, gchar *outbuf)
+{
+ int base, n, i;
+
+ if (c < 0x80) {
+ base = 0;
+ n = 1;
+ } else if (c < 0x800) {
+ base = 192;
+ n = 2;
+ } else if (c < 0x10000) {
+ base = 224;
+ n = 3;
+ } else if (c < 0x200000) {
+ base = 240;
+ n = 4;
+ } else if (c < 0x4000000) {
+ base = 248;
+ n = 5;
+ } else if (c < 0x80000000) {
+ base = 252;
+ n = 6;
+ } else {
+ return -1;
+ }
+
+ if (outbuf != NULL) {
+ for (i = n - 1; i > 0; i--) {
+ /* mask off 6 bits worth and add 128 */
+ outbuf[i] = (c & 0x3f) | 0x80;
+ c >>= 6;
+ }
+
+ /* first character has a different base */
+ outbuf[0] = c | base;
+ }
+
+ return n;
+}
+
+static FORCE_INLINE (int)
+g_unichar_to_utf16 (gunichar c, gunichar2 *outbuf)
+{
+ gunichar c2;
+
+ if (c < 0xd800) {
+ if (outbuf)
+ *outbuf = (gunichar2) c;
+
+ return 1;
+ } else if (c < 0xe000) {
+ return -1;
+ } else if (c < 0x10000) {
+ if (outbuf)
+ *outbuf = (gunichar2) c;
+
+ return 1;
+ } else if (c < 0x110000) {
+ if (outbuf) {
+ c2 = c - 0x10000;
+
+ outbuf[0] = (gunichar2) ((c2 >> 10) + 0xd800);
+ outbuf[1] = (gunichar2) ((c2 & 0x3ff) + 0xdc00);
+ }
+
+ return 2;
+ } else {
+ return -1;
+ }
+}
+
+gunichar *
+g_utf8_to_ucs4_fast (const gchar *str, glong len, glong *items_written)
+{
+ gunichar *outbuf, *outptr;
+ char *inptr;
+ glong n, i;
+
+ g_return_val_if_fail (str != NULL, NULL);
+
+ n = g_utf8_strlen (str, len);
+
+ if (items_written)
+ *items_written = n;
+
+ outptr = outbuf = g_malloc ((n + 1) * sizeof (gunichar));
+ inptr = (char *) str;
+
+ for (i = 0; i < n; i++) {
+ *outptr++ = g_utf8_get_char (inptr);
+ inptr = g_utf8_next_char (inptr);
+ }
+
+ *outptr = 0;
+
+ return outbuf;
+}
+
+static gunichar2 *
+eg_utf8_to_utf16_general (const gchar *str, glong len, glong *items_read, glong *items_written, gboolean include_nuls, GError **err)
+{
+ gunichar2 *outbuf, *outptr;
+ size_t outlen = 0;
+ size_t inleft;
+ char *inptr;
+ gunichar c;
+ int u, n;
+
+ g_return_val_if_fail (str != NULL, NULL);
+
+ if (len < 0) {
+ if (include_nuls) {
+ g_set_error (err, G_CONVERT_ERROR, G_CONVERT_ERROR_FAILED, "Conversions with embedded nulls must pass the string length");
+ return NULL;
+ }
+
+ len = strlen (str);
+ }
+
+ inptr = (char *) str;
+ inleft = len;
+
+ while (inleft > 0) {
+ if ((n = decode_utf8 (inptr, inleft, &c)) < 0)
+ goto error;
+
+ if (c == 0 && !include_nuls)
+ break;
+
+ if ((u = g_unichar_to_utf16 (c, NULL)) < 0) {
+ errno = EILSEQ;
+ goto error;
+ }
+
+ outlen += u;
+ inleft -= n;
+ inptr += n;
+ }
+
+ if (items_read)
+ *items_read = inptr - str;
+
+ if (items_written)
+ *items_written = outlen;
+
+ outptr = outbuf = g_malloc ((outlen + 1) * sizeof (gunichar2));
+ inptr = (char *) str;
+ inleft = len;
+
+ while (inleft > 0) {
+ if ((n = decode_utf8 (inptr, inleft, &c)) < 0)
+ break;
+
+ if (c == 0 && !include_nuls)
+ break;
+
+ outptr += g_unichar_to_utf16 (c, outptr);
+ inleft -= n;
+ inptr += n;
+ }
+
+ *outptr = '\0';
+
+ return outbuf;
+
+ error:
+ if (errno == EILSEQ) {
+ g_set_error (err, G_CONVERT_ERROR, G_CONVERT_ERROR_ILLEGAL_SEQUENCE,
+ "Illegal byte sequence encounted in the input.");
+ } else if (items_read) {
+ /* partial input is ok if we can let our caller know... */
+ } else {
+ g_set_error (err, G_CONVERT_ERROR, G_CONVERT_ERROR_PARTIAL_INPUT,
+ "Partial byte sequence encountered in the input.");
+ }
+
+ if (items_read)
+ *items_read = inptr - str;
+
+ if (items_written)
+ *items_written = 0;
+
+ return NULL;
+}
+
+gunichar2 *
+g_utf8_to_utf16 (const gchar *str, glong len, glong *items_read, glong *items_written, GError **err)
+{
+ return eg_utf8_to_utf16_general (str, len, items_read, items_written, FALSE, err);
+}
+
+gunichar2 *
+eg_utf8_to_utf16_with_nuls (const gchar *str, glong len, glong *items_read, glong *items_written, GError **err)
+{
+ return eg_utf8_to_utf16_general (str, len, items_read, items_written, TRUE, err);
+}
+
+gunichar *
+g_utf8_to_ucs4 (const gchar *str, glong len, glong *items_read, glong *items_written, GError **err)
+{
+ gunichar *outbuf, *outptr;
+ size_t outlen = 0;
+ size_t inleft;
+ char *inptr;
+ gunichar c;
+ int n;
+
+ g_return_val_if_fail (str != NULL, NULL);
+
+ if (len < 0)
+ len = strlen (str);
+
+ inptr = (char *) str;
+ inleft = len;
+
+ while (inleft > 0) {
+ if ((n = decode_utf8 (inptr, inleft, &c)) < 0) {
+ if (errno == EILSEQ) {
+ g_set_error (err, G_CONVERT_ERROR, G_CONVERT_ERROR_ILLEGAL_SEQUENCE,
+ "Illegal byte sequence encounted in the input.");
+ } else if (items_read) {
+ /* partial input is ok if we can let our caller know... */
+ break;
+ } else {
+ g_set_error (err, G_CONVERT_ERROR, G_CONVERT_ERROR_PARTIAL_INPUT,
+ "Partial byte sequence encountered in the input.");
+ }
+
+ if (items_read)
+ *items_read = inptr - str;
+
+ if (items_written)
+ *items_written = 0;
+
+ return NULL;
+ } else if (c == 0)
+ break;
+
+ outlen += 4;
+ inleft -= n;
+ inptr += n;
+ }
+
+ if (items_written)
+ *items_written = outlen / 4;
+
+ if (items_read)
+ *items_read = inptr - str;
+
+ outptr = outbuf = g_malloc (outlen + 4);
+ inptr = (char *) str;
+ inleft = len;
+
+ while (inleft > 0) {
+ if ((n = decode_utf8 (inptr, inleft, &c)) < 0)
+ break;
+ else if (c == 0)
+ break;
+
+ *outptr++ = c;
+ inleft -= n;
+ inptr += n;
+ }
+
+ *outptr = 0;
+
+ return outbuf;
+}
+
+gchar *
+g_utf16_to_utf8 (const gunichar2 *str, glong len, glong *items_read, glong *items_written, GError **err)
+{
+ char *inptr, *outbuf, *outptr;
+ size_t outlen = 0;
+ size_t inleft;
+ gunichar c;
+ int n;
+
+ g_return_val_if_fail (str != NULL, NULL);
+
+ if (len < 0) {
+ len = 0;
+ while (str[len])
+ len++;
+ }
+
+ inptr = (char *) str;
+ inleft = len * 2;
+
+ while (inleft > 0) {
+ if ((n = decode_utf16 (inptr, inleft, &c)) < 0) {
+ if (n == -2 && inleft > 2) {
+ /* This means that the first UTF-16 char was read, but second failed */
+ inleft -= 2;
+ inptr += 2;
+ }
+
+ if (errno == EILSEQ) {
+ g_set_error (err, G_CONVERT_ERROR, G_CONVERT_ERROR_ILLEGAL_SEQUENCE,
+ "Illegal byte sequence encounted in the input.");
+ } else if (items_read) {
+ /* partial input is ok if we can let our caller know... */
+ break;
+ } else {
+ g_set_error (err, G_CONVERT_ERROR, G_CONVERT_ERROR_PARTIAL_INPUT,
+ "Partial byte sequence encountered in the input.");
+ }
+
+ if (items_read)
+ *items_read = (inptr - (char *) str) / 2;
+
+ if (items_written)
+ *items_written = 0;
+
+ return NULL;
+ } else if (c == 0)
+ break;
+
+ outlen += g_unichar_to_utf8 (c, NULL);
+ inleft -= n;
+ inptr += n;
+ }
+
+ if (items_read)
+ *items_read = (inptr - (char *) str) / 2;
+
+ if (items_written)
+ *items_written = outlen;
+
+ outptr = outbuf = g_malloc (outlen + 1);
+ inptr = (char *) str;
+ inleft = len * 2;
+
+ while (inleft > 0) {
+ if ((n = decode_utf16 (inptr, inleft, &c)) < 0)
+ break;
+ else if (c == 0)
+ break;
+
+ outptr += g_unichar_to_utf8 (c, outptr);
+ inleft -= n;
+ inptr += n;
+ }
+
+ *outptr = '\0';
+
+ return outbuf;
+}
+
+gunichar *
+g_utf16_to_ucs4 (const gunichar2 *str, glong len, glong *items_read, glong *items_written, GError **err)
+{
+ gunichar *outbuf, *outptr;
+ size_t outlen = 0;
+ size_t inleft;
+ char *inptr;
+ gunichar c;
+ int n;
+
+ g_return_val_if_fail (str != NULL, NULL);
+
+ if (len < 0) {
+ len = 0;
+ while (str[len])
+ len++;
+ }
+
+ inptr = (char *) str;
+ inleft = len * 2;
+
+ while (inleft > 0) {
+ if ((n = decode_utf16 (inptr, inleft, &c)) < 0) {
+ if (n == -2 && inleft > 2) {
+ /* This means that the first UTF-16 char was read, but second failed */
+ inleft -= 2;
+ inptr += 2;
+ }
+
+ if (errno == EILSEQ) {
+ g_set_error (err, G_CONVERT_ERROR, G_CONVERT_ERROR_ILLEGAL_SEQUENCE,
+ "Illegal byte sequence encounted in the input.");
+ } else if (items_read) {
+ /* partial input is ok if we can let our caller know... */
+ break;
+ } else {
+ g_set_error (err, G_CONVERT_ERROR, G_CONVERT_ERROR_PARTIAL_INPUT,
+ "Partial byte sequence encountered in the input.");
+ }
+
+ if (items_read)
+ *items_read = (inptr - (char *) str) / 2;
+
+ if (items_written)
+ *items_written = 0;
+
+ return NULL;
+ } else if (c == 0)
+ break;
+
+ outlen += 4;
+ inleft -= n;
+ inptr += n;
+ }
+
+ if (items_read)
+ *items_read = (inptr - (char *) str) / 2;
+
+ if (items_written)
+ *items_written = outlen / 4;
+
+ outptr = outbuf = g_malloc (outlen + 4);
+ inptr = (char *) str;
+ inleft = len * 2;
+
+ while (inleft > 0) {
+ if ((n = decode_utf16 (inptr, inleft, &c)) < 0)
+ break;
+ else if (c == 0)
+ break;
+
+ *outptr++ = c;
+ inleft -= n;
+ inptr += n;
+ }
+
+ *outptr = 0;
+
+ return outbuf;
+}
+
+gchar *
+g_ucs4_to_utf8 (const gunichar *str, glong len, glong *items_read, glong *items_written, GError **err)
+{
+ char *outbuf, *outptr;
+ size_t outlen = 0;
+ glong i;
+ int n;
+
+ g_return_val_if_fail (str != NULL, NULL);
+
+ if (len < 0) {
+ for (i = 0; str[i] != 0; i++) {
+ if ((n = g_unichar_to_utf8 (str[i], NULL)) < 0) {
+ g_set_error (err, G_CONVERT_ERROR, G_CONVERT_ERROR_ILLEGAL_SEQUENCE,
+ "Illegal byte sequence encounted in the input.");
+
+ if (items_written)
+ *items_written = 0;
+
+ if (items_read)
+ *items_read = i;
+
+ return NULL;
+ }
+
+ outlen += n;
+ }
+ } else {
+ for (i = 0; i < len && str[i] != 0; i++) {
+ if ((n = g_unichar_to_utf8 (str[i], NULL)) < 0) {
+ g_set_error (err, G_CONVERT_ERROR, G_CONVERT_ERROR_ILLEGAL_SEQUENCE,
+ "Illegal byte sequence encounted in the input.");
+
+ if (items_written)
+ *items_written = 0;
+
+ if (items_read)
+ *items_read = i;
+
+ return NULL;
+ }
+
+ outlen += n;
+ }
+ }
+
+ len = i;
+
+ outptr = outbuf = g_malloc (outlen + 1);
+ for (i = 0; i < len; i++)
+ outptr += g_unichar_to_utf8 (str[i], outptr);
+ *outptr = 0;
+
+ if (items_written)
+ *items_written = outlen;
+
+ if (items_read)
+ *items_read = i;
+
+ return outbuf;
+}
+
+gunichar2 *
+g_ucs4_to_utf16 (const gunichar *str, glong len, glong *items_read, glong *items_written, GError **err)
+{
+ gunichar2 *outbuf, *outptr;
+ size_t outlen = 0;
+ glong i;
+ int n;
+
+ g_return_val_if_fail (str != NULL, NULL);
+
+ if (len < 0) {
+ for (i = 0; str[i] != 0; i++) {
+ if ((n = g_unichar_to_utf16 (str[i], NULL)) < 0) {
+ g_set_error (err, G_CONVERT_ERROR, G_CONVERT_ERROR_ILLEGAL_SEQUENCE,
+ "Illegal byte sequence encounted in the input.");
+
+ if (items_written)
+ *items_written = 0;
+
+ if (items_read)
+ *items_read = i;
+
+ return NULL;
+ }
+
+ outlen += n;
+ }
+ } else {
+ for (i = 0; i < len && str[i] != 0; i++) {
+ if ((n = g_unichar_to_utf16 (str[i], NULL)) < 0) {
+ g_set_error (err, G_CONVERT_ERROR, G_CONVERT_ERROR_ILLEGAL_SEQUENCE,
+ "Illegal byte sequence encounted in the input.");
+
+ if (items_written)
+ *items_written = 0;
+
+ if (items_read)
+ *items_read = i;
+
+ return NULL;
+ }
+
+ outlen += n;
+ }
+ }
+
+ len = i;
+
+ outptr = outbuf = g_malloc ((outlen + 1) * sizeof (gunichar2));
+ for (i = 0; i < len; i++)
+ outptr += g_unichar_to_utf16 (str[i], outptr);
+ *outptr = 0;
+
+ if (items_written)
+ *items_written = outlen;
+
+ if (items_read)
+ *items_read = i;
+
+ return outbuf;
+}
--- /dev/null
+#ifndef __GLIB_H
+#define __GLIB_H
+#include <stdarg.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <stddef.h>
+#include <ctype.h>
+#include <limits.h>
+
+
+#ifdef _MSC_VER
+#pragma include_alias(<eglib-config.h>, <eglib-config.hw>)
+#endif
+
+#include <stdint.h>
+#include <inttypes.h>
+
+#include <eglib-config.h>
+#ifndef EGLIB_NO_REMAP
+#include <eglib-remap.h>
+#endif
+
+#ifdef G_HAVE_ALLOCA_H
+#include <alloca.h>
+#endif
+
+#ifdef WIN32
+/* For alloca */
+#include <malloc.h>
+#endif
+
+#ifndef offsetof
+# define offsetof(s_name,n_name) (size_t)(char *)&(((s_name*)0)->m_name)
+#endif
+
+#define __EGLIB_X11 1
+
+#ifdef __cplusplus
+#define G_BEGIN_DECLS extern "C" {
+#define G_END_DECLS }
+#else
+#define G_BEGIN_DECLS
+#define G_END_DECLS
+#endif
+
+G_BEGIN_DECLS
+
+/*
+ * Basic data types
+ */
+typedef int gint;
+typedef unsigned int guint;
+typedef short gshort;
+typedef unsigned short gushort;
+typedef long glong;
+typedef unsigned long gulong;
+typedef void * gpointer;
+typedef const void * gconstpointer;
+typedef char gchar;
+typedef unsigned char guchar;
+
+/* Types defined in terms of the stdint.h */
+typedef int8_t gint8;
+typedef uint8_t guint8;
+typedef int16_t gint16;
+typedef uint16_t guint16;
+typedef int32_t gint32;
+typedef uint32_t guint32;
+typedef int64_t gint64;
+typedef uint64_t guint64;
+typedef float gfloat;
+typedef double gdouble;
+typedef int32_t gboolean;
+
+typedef guint16 gunichar2;
+typedef guint32 gunichar;
+
+/*
+ * Macros
+ */
+#define G_N_ELEMENTS(s) (sizeof(s) / sizeof ((s) [0]))
+
+#define FALSE 0
+#define TRUE 1
+
+#define G_MINSHORT SHRT_MIN
+#define G_MAXSHORT SHRT_MAX
+#define G_MAXUSHORT USHRT_MAX
+#define G_MAXINT INT_MAX
+#define G_MININT INT_MIN
+#define G_MAXINT32 INT32_MAX
+#define G_MAXUINT32 UINT32_MAX
+#define G_MININT32 INT32_MIN
+#define G_MININT64 INT64_MIN
+#define G_MAXINT64 INT64_MAX
+#define G_MAXUINT64 UINT64_MAX
+
+#define G_LITTLE_ENDIAN 1234
+#define G_BIG_ENDIAN 4321
+#define G_STMT_START do
+#define G_STMT_END while (0)
+
+#define G_USEC_PER_SEC 1000000
+
+#ifndef ABS
+#define ABS(a) ((a) > 0 ? (a) : -(a))
+#endif
+
+#define G_STRUCT_OFFSET(p_type,field) offsetof(p_type,field)
+
+#define EGLIB_STRINGIFY(x) #x
+#define EGLIB_TOSTRING(x) EGLIB_STRINGIFY(x)
+#define G_STRLOC __FILE__ ":" EGLIB_TOSTRING(__LINE__) ":"
+
+#define G_CONST_RETURN const
+
+#define G_GUINT64_FORMAT PRIu64
+#define G_GINT64_FORMAT PRIi64
+#define G_GUINT32_FORMAT PRIu32
+#define G_GINT32_FORMAT PRIi32
+
+/*
+ * Allocation
+ */
+void g_free (void *ptr);
+gpointer g_realloc (gpointer obj, gsize size);
+gpointer g_malloc (gsize x);
+gpointer g_malloc0 (gsize x);
+gpointer g_calloc (gsize n, gsize x);
+gpointer g_try_malloc (gsize x);
+gpointer g_try_realloc (gpointer obj, gsize size);
+
+#define g_new(type,size) ((type *) g_malloc (sizeof (type) * (size)))
+#define g_new0(type,size) ((type *) g_malloc0 (sizeof (type)* (size)))
+#define g_newa(type,size) ((type *) alloca (sizeof (type) * (size)))
+
+#define g_memmove(dest,src,len) memmove (dest, src, len)
+#define g_renew(struct_type, mem, n_structs) g_realloc (mem, sizeof (struct_type) * n_structs)
+#define g_alloca(size) alloca (size)
+
+gpointer g_memdup (gconstpointer mem, guint byte_size);
+static inline gchar *g_strdup (const gchar *str) { if (str) { return (gchar*) g_memdup (str, (guint)strlen (str) + 1); } return NULL; }
+gchar **g_strdupv (gchar **str_array);
+
+typedef struct {
+ gpointer (*malloc) (gsize n_bytes);
+ gpointer (*realloc) (gpointer mem, gsize n_bytes);
+ void (*free) (gpointer mem);
+ gpointer (*calloc) (gsize n_blocks, gsize n_block_bytes);
+} GMemVTable;
+
+void g_mem_set_vtable (GMemVTable* vtable);
+
+struct _GMemChunk {
+ guint alloc_size;
+};
+
+typedef struct _GMemChunk GMemChunk;
+/*
+ * Misc.
+ */
+
+gboolean g_hasenv(const gchar *variable);
+gchar * g_getenv(const gchar *variable);
+gboolean g_setenv(const gchar *variable, const gchar *value, gboolean overwrite);
+void g_unsetenv(const gchar *variable);
+
+gchar* g_win32_getlocale(void);
+
+/*
+ * Precondition macros
+ */
+#define g_warn_if_fail(x) G_STMT_START { if (!(x)) { g_warning ("%s:%d: assertion '%s' failed", __FILE__, __LINE__, #x); } } G_STMT_END
+#define g_return_if_fail(x) G_STMT_START { if (!(x)) { g_critical ("%s:%d: assertion '%s' failed", __FILE__, __LINE__, #x); return; } } G_STMT_END
+#define g_return_val_if_fail(x,e) G_STMT_START { if (!(x)) { g_critical ("%s:%d: assertion '%s' failed", __FILE__, __LINE__, #x); return (e); } } G_STMT_END
+
+/*
+ * Errors
+ */
+typedef struct {
+ /* In the real glib, this is a GQuark, but we dont use/need that */
+ gpointer domain;
+ gint code;
+ gchar *message;
+} GError;
+
+void g_clear_error (GError **error);
+void g_error_free (GError *error);
+GError *g_error_new (gpointer domain, gint code, const char *format, ...);
+void g_set_error (GError **err, gpointer domain, gint code, const gchar *format, ...);
+void g_propagate_error (GError **dest, GError *src);
+
+/*
+ * Strings utility
+ */
+gchar *g_strdup_printf (const gchar *format, ...);
+gchar *g_strdup_vprintf (const gchar *format, va_list args);
+gchar *g_strndup (const gchar *str, gsize n);
+const gchar *g_strerror (gint errnum);
+gchar *g_strndup (const gchar *str, gsize n);
+void g_strfreev (gchar **str_array);
+gchar *g_strconcat (const gchar *first, ...);
+gchar **g_strsplit (const gchar *string, const gchar *delimiter, gint max_tokens);
+gchar **g_strsplit_set (const gchar *string, const gchar *delimiter, gint max_tokens);
+gchar *g_strreverse (gchar *str);
+gboolean g_str_has_prefix (const gchar *str, const gchar *prefix);
+gboolean g_str_has_suffix (const gchar *str, const gchar *suffix);
+guint g_strv_length (gchar **str_array);
+gchar *g_strjoin (const gchar *separator, ...);
+gchar *g_strjoinv (const gchar *separator, gchar **str_array);
+gchar *g_strchug (gchar *str);
+gchar *g_strchomp (gchar *str);
+void g_strdown (gchar *string);
+gchar *g_strnfill (gsize length, gchar fill_char);
+
+gchar *g_strdelimit (gchar *string, const gchar *delimiters, gchar new_delimiter);
+gchar *g_strescape (const gchar *source, const gchar *exceptions);
+
+gchar *g_filename_to_uri (const gchar *filename, const gchar *hostname, GError **error);
+gchar *g_filename_from_uri (const gchar *uri, gchar **hostname, GError **error);
+
+gint g_printf (gchar const *format, ...);
+gint g_fprintf (FILE *file, gchar const *format, ...);
+gint g_sprintf (gchar *string, gchar const *format, ...);
+gint g_snprintf (gchar *string, gulong n, gchar const *format, ...);
+gint g_vasprintf (gchar **ret, const gchar *fmt, va_list ap);
+#define g_vprintf vprintf
+#define g_vfprintf vfprintf
+#define g_vsprintf vsprintf
+#define g_vsnprintf vsnprintf
+
+gsize g_strlcpy (gchar *dest, const gchar *src, gsize dest_size);
+gchar *g_stpcpy (gchar *dest, const char *src);
+
+
+gchar g_ascii_tolower (gchar c);
+gchar g_ascii_toupper (gchar c);
+gchar *g_ascii_strdown (const gchar *str, gssize len);
+gchar *g_ascii_strup (const gchar *str, gssize len);
+gint g_ascii_strncasecmp (const gchar *s1, const gchar *s2, gsize n);
+gint g_ascii_strcasecmp (const gchar *s1, const gchar *s2);
+gint g_ascii_xdigit_value (gchar c);
+#define g_ascii_isspace(c) (isspace (c) != 0)
+#define g_ascii_isalpha(c) (isalpha (c) != 0)
+#define g_ascii_isprint(c) (isprint (c) != 0)
+#define g_ascii_isxdigit(c) (isxdigit (c) != 0)
+
+/* FIXME: g_strcasecmp supports utf8 unicode stuff */
+#ifdef _MSC_VER
+#define g_strcasecmp stricmp
+#define g_strncasecmp strnicmp
+#define g_strstrip(a) g_strchug (g_strchomp (a))
+#else
+#define g_strcasecmp strcasecmp
+#define g_ascii_strtoull strtoull
+#define g_strncasecmp strncasecmp
+#define g_strstrip(a) g_strchug (g_strchomp (a))
+#endif
+#define g_ascii_strdup strdup
+
+
+#define G_STR_DELIMITERS "_-|> <."
+
+/*
+ * String type
+ */
+typedef struct {
+ char *str;
+ gsize len;
+ gsize allocated_len;
+} GString;
+
+GString *g_string_new (const gchar *init);
+GString *g_string_new_len (const gchar *init, gssize len);
+GString *g_string_sized_new (gsize default_size);
+gchar *g_string_free (GString *string, gboolean free_segment);
+GString *g_string_append (GString *string, const gchar *val);
+void g_string_printf (GString *string, const gchar *format, ...);
+void g_string_append_printf (GString *string, const gchar *format, ...);
+void g_string_append_vprintf (GString *string, const gchar *format, va_list args);
+GString *g_string_append_unichar (GString *string, gunichar c);
+GString *g_string_append_c (GString *string, gchar c);
+GString *g_string_append (GString *string, const gchar *val);
+GString *g_string_append_len (GString *string, const gchar *val, gssize len);
+GString *g_string_truncate (GString *string, gsize len);
+GString *g_string_prepend (GString *string, const gchar *val);
+GString *g_string_insert (GString *string, gssize pos, const gchar *val);
+GString *g_string_set_size (GString *string, gsize len);
+GString *g_string_erase (GString *string, gssize pos, gssize len);
+
+#define g_string_sprintfa g_string_append_printf
+
+typedef void (*GFunc) (gpointer data, gpointer user_data);
+typedef gint (*GCompareFunc) (gconstpointer a, gconstpointer b);
+typedef gint (*GCompareDataFunc) (gconstpointer a, gconstpointer b, gpointer user_data);
+typedef void (*GHFunc) (gpointer key, gpointer value, gpointer user_data);
+typedef gboolean (*GHRFunc) (gpointer key, gpointer value, gpointer user_data);
+typedef void (*GDestroyNotify) (gpointer data);
+typedef guint (*GHashFunc) (gconstpointer key);
+typedef gboolean (*GEqualFunc) (gconstpointer a, gconstpointer b);
+typedef void (*GFreeFunc) (gpointer data);
+
+/*
+ * Lists
+ */
+typedef struct _GSList GSList;
+struct _GSList {
+ gpointer data;
+ GSList *next;
+};
+
+GSList *g_slist_alloc (void);
+GSList *g_slist_append (GSList *list,
+ gpointer data);
+GSList *g_slist_prepend (GSList *list,
+ gpointer data);
+void g_slist_free (GSList *list);
+void g_slist_free_1 (GSList *list);
+GSList *g_slist_copy (GSList *list);
+GSList *g_slist_concat (GSList *list1,
+ GSList *list2);
+void g_slist_foreach (GSList *list,
+ GFunc func,
+ gpointer user_data);
+GSList *g_slist_last (GSList *list);
+GSList *g_slist_find (GSList *list,
+ gconstpointer data);
+GSList *g_slist_find_custom (GSList *list,
+ gconstpointer data,
+ GCompareFunc func);
+GSList *g_slist_remove (GSList *list,
+ gconstpointer data);
+GSList *g_slist_remove_all (GSList *list,
+ gconstpointer data);
+GSList *g_slist_reverse (GSList *list);
+guint g_slist_length (GSList *list);
+GSList *g_slist_remove_link (GSList *list,
+ GSList *link);
+GSList *g_slist_delete_link (GSList *list,
+ GSList *link);
+GSList *g_slist_insert_sorted (GSList *list,
+ gpointer data,
+ GCompareFunc func);
+GSList *g_slist_insert_before (GSList *list,
+ GSList *sibling,
+ gpointer data);
+GSList *g_slist_sort (GSList *list,
+ GCompareFunc func);
+gint g_slist_index (GSList *list,
+ gconstpointer data);
+GSList *g_slist_nth (GSList *list,
+ guint n);
+gpointer g_slist_nth_data (GSList *list,
+ guint n);
+
+#define g_slist_next(slist) ((slist) ? (((GSList *) (slist))->next) : NULL)
+
+
+typedef struct _GList GList;
+struct _GList {
+ gpointer data;
+ GList *next;
+ GList *prev;
+};
+
+#define g_list_next(list) ((list) ? (((GList *) (list))->next) : NULL)
+#define g_list_previous(list) ((list) ? (((GList *) (list))->prev) : NULL)
+
+GList *g_list_alloc (void);
+GList *g_list_append (GList *list,
+ gpointer data);
+GList *g_list_prepend (GList *list,
+ gpointer data);
+void g_list_free (GList *list);
+void g_list_free_1 (GList *list);
+GList *g_list_copy (GList *list);
+guint g_list_length (GList *list);
+gint g_list_index (GList *list,
+ gconstpointer data);
+GList *g_list_nth (GList *list,
+ guint n);
+gpointer g_list_nth_data (GList *list,
+ guint n);
+GList *g_list_last (GList *list);
+GList *g_list_concat (GList *list1,
+ GList *list2);
+void g_list_foreach (GList *list,
+ GFunc func,
+ gpointer user_data);
+GList *g_list_first (GList *list);
+GList *g_list_find (GList *list,
+ gconstpointer data);
+GList *g_list_find_custom (GList *list,
+ gconstpointer data,
+ GCompareFunc func);
+GList *g_list_remove (GList *list,
+ gconstpointer data);
+GList *g_list_remove_all (GList *list,
+ gconstpointer data);
+GList *g_list_reverse (GList *list);
+GList *g_list_remove_link (GList *list,
+ GList *link);
+GList *g_list_delete_link (GList *list,
+ GList *link);
+GList *g_list_insert_sorted (GList *list,
+ gpointer data,
+ GCompareFunc func);
+GList *g_list_insert_before (GList *list,
+ GList *sibling,
+ gpointer data);
+GList *g_list_sort (GList *sort,
+ GCompareFunc func);
+
+/*
+ * Hashtables
+ */
+typedef struct _GHashTable GHashTable;
+typedef struct _GHashTableIter GHashTableIter;
+
+/* Private, but needed for stack allocation */
+struct _GHashTableIter
+{
+ gpointer dummy [8];
+};
+
+GHashTable *g_hash_table_new (GHashFunc hash_func, GEqualFunc key_equal_func);
+GHashTable *g_hash_table_new_full (GHashFunc hash_func, GEqualFunc key_equal_func,
+ GDestroyNotify key_destroy_func, GDestroyNotify value_destroy_func);
+void g_hash_table_insert_replace (GHashTable *hash, gpointer key, gpointer value, gboolean replace);
+guint g_hash_table_size (GHashTable *hash);
+GList *g_hash_table_get_keys (GHashTable *hash);
+GList *g_hash_table_get_values (GHashTable *hash);
+gpointer g_hash_table_lookup (GHashTable *hash, gconstpointer key);
+gboolean g_hash_table_lookup_extended (GHashTable *hash, gconstpointer key, gpointer *orig_key, gpointer *value);
+void g_hash_table_foreach (GHashTable *hash, GHFunc func, gpointer user_data);
+gpointer g_hash_table_find (GHashTable *hash, GHRFunc predicate, gpointer user_data);
+gboolean g_hash_table_remove (GHashTable *hash, gconstpointer key);
+gboolean g_hash_table_steal (GHashTable *hash, gconstpointer key);
+void g_hash_table_remove_all (GHashTable *hash);
+guint g_hash_table_foreach_remove (GHashTable *hash, GHRFunc func, gpointer user_data);
+guint g_hash_table_foreach_steal (GHashTable *hash, GHRFunc func, gpointer user_data);
+void g_hash_table_destroy (GHashTable *hash);
+void g_hash_table_print_stats (GHashTable *table);
+
+void g_hash_table_iter_init (GHashTableIter *iter, GHashTable *hash_table);
+gboolean g_hash_table_iter_next (GHashTableIter *iter, gpointer *key, gpointer *value);
+
+guint g_spaced_primes_closest (guint x);
+
+#define g_hash_table_insert(h,k,v) g_hash_table_insert_replace ((h),(k),(v),FALSE)
+#define g_hash_table_replace(h,k,v) g_hash_table_insert_replace ((h),(k),(v),TRUE)
+
+gboolean g_direct_equal (gconstpointer v1, gconstpointer v2);
+guint g_direct_hash (gconstpointer v1);
+gboolean g_int_equal (gconstpointer v1, gconstpointer v2);
+guint g_int_hash (gconstpointer v1);
+gboolean g_str_equal (gconstpointer v1, gconstpointer v2);
+guint g_str_hash (gconstpointer v1);
+
+/*
+ * ByteArray
+ */
+
+typedef struct _GByteArray GByteArray;
+struct _GByteArray {
+ guint8 *data;
+ gint len;
+};
+
+GByteArray *g_byte_array_new (void);
+GByteArray* g_byte_array_append (GByteArray *array, const guint8 *data, guint len);
+guint8* g_byte_array_free (GByteArray *array, gboolean free_segment);
+void g_byte_array_set_size (GByteArray *array, gint length);
+
+/*
+ * Array
+ */
+
+typedef struct _GArray GArray;
+struct _GArray {
+ gchar *data;
+ gint len;
+};
+
+GArray *g_array_new (gboolean zero_terminated, gboolean clear_, guint element_size);
+GArray *g_array_sized_new (gboolean zero_terminated, gboolean clear_, guint element_size, guint reserved_size);
+gchar* g_array_free (GArray *array, gboolean free_segment);
+GArray *g_array_append_vals (GArray *array, gconstpointer data, guint len);
+GArray* g_array_insert_vals (GArray *array, guint index_, gconstpointer data, guint len);
+GArray* g_array_remove_index (GArray *array, guint index_);
+GArray* g_array_remove_index_fast (GArray *array, guint index_);
+void g_array_set_size (GArray *array, gint length);
+
+#define g_array_append_val(a,v) (g_array_append_vals((a),&(v),1))
+#define g_array_insert_val(a,i,v) (g_array_insert_vals((a),(i),&(v),1))
+#define g_array_index(a,t,i) *(t*)(((a)->data) + sizeof(t) * (i))
+
+/*
+ * QSort
+*/
+
+void g_qsort_with_data (gpointer base, size_t nmemb, size_t size, GCompareDataFunc compare, gpointer user_data);
+
+/*
+ * Pointer Array
+ */
+
+typedef struct _GPtrArray GPtrArray;
+struct _GPtrArray {
+ gpointer *pdata;
+ guint len;
+};
+
+GPtrArray *g_ptr_array_new (void);
+GPtrArray *g_ptr_array_sized_new (guint reserved_size);
+void g_ptr_array_add (GPtrArray *array, gpointer data);
+gboolean g_ptr_array_remove (GPtrArray *array, gpointer data);
+gpointer g_ptr_array_remove_index (GPtrArray *array, guint index);
+gboolean g_ptr_array_remove_fast (GPtrArray *array, gpointer data);
+gpointer g_ptr_array_remove_index_fast (GPtrArray *array, guint index);
+void g_ptr_array_sort (GPtrArray *array, GCompareFunc compare_func);
+void g_ptr_array_sort_with_data (GPtrArray *array, GCompareDataFunc compare_func, gpointer user_data);
+void g_ptr_array_set_size (GPtrArray *array, gint length);
+gpointer *g_ptr_array_free (GPtrArray *array, gboolean free_seg);
+void g_ptr_array_foreach (GPtrArray *array, GFunc func, gpointer user_data);
+#define g_ptr_array_index(array,index) (array)->pdata[(index)]
+
+/*
+ * Queues
+ */
+typedef struct {
+ GList *head;
+ GList *tail;
+ guint length;
+} GQueue;
+
+gpointer g_queue_pop_head (GQueue *queue);
+void g_queue_push_head (GQueue *queue,
+ gpointer data);
+void g_queue_push_tail (GQueue *queue,
+ gpointer data);
+gboolean g_queue_is_empty (GQueue *queue);
+GQueue *g_queue_new (void);
+void g_queue_free (GQueue *queue);
+void g_queue_foreach (GQueue *queue, GFunc func, gpointer user_data);
+
+/*
+ * Messages
+ */
+#ifndef G_LOG_DOMAIN
+#define G_LOG_DOMAIN ((gchar*) 0)
+#endif
+
+typedef enum {
+ G_LOG_FLAG_RECURSION = 1 << 0,
+ G_LOG_FLAG_FATAL = 1 << 1,
+
+ G_LOG_LEVEL_ERROR = 1 << 2,
+ G_LOG_LEVEL_CRITICAL = 1 << 3,
+ G_LOG_LEVEL_WARNING = 1 << 4,
+ G_LOG_LEVEL_MESSAGE = 1 << 5,
+ G_LOG_LEVEL_INFO = 1 << 6,
+ G_LOG_LEVEL_DEBUG = 1 << 7,
+
+ G_LOG_LEVEL_MASK = ~(G_LOG_FLAG_RECURSION | G_LOG_FLAG_FATAL)
+} GLogLevelFlags;
+
+void g_print (const gchar *format, ...);
+void g_printerr (const gchar *format, ...);
+GLogLevelFlags g_log_set_always_fatal (GLogLevelFlags fatal_mask);
+GLogLevelFlags g_log_set_fatal_mask (const gchar *log_domain, GLogLevelFlags fatal_mask);
+void g_logv (const gchar *log_domain, GLogLevelFlags log_level, const gchar *format, va_list args);
+void g_log (const gchar *log_domain, GLogLevelFlags log_level, const gchar *format, ...);
+void g_assertion_message (const gchar *format, ...) G_GNUC_NORETURN;
+
+#ifdef HAVE_C99_SUPPORT
+/* The for (;;) tells gc thats g_error () doesn't return, avoiding warnings */
+#define g_error(format, ...) do { g_log (G_LOG_DOMAIN, G_LOG_LEVEL_ERROR, format, __VA_ARGS__); for (;;); } while (0)
+#define g_critical(format, ...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, format, __VA_ARGS__)
+#define g_warning(format, ...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, format, __VA_ARGS__)
+#define g_message(format, ...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_MESSAGE, format, __VA_ARGS__)
+#define g_debug(format, ...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, format, __VA_ARGS__)
+#else /* HAVE_C99_SUPPORT */
+#define g_error(...) do { g_log (G_LOG_DOMAIN, G_LOG_LEVEL_ERROR, __VA_ARGS__); for (;;); } while (0)
+#define g_critical(...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, __VA_ARGS__)
+#define g_warning(...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, __VA_ARGS__)
+#define g_message(...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_MESSAGE, __VA_ARGS__)
+#define g_debug(...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, __VA_ARGS__)
+#endif /* ndef HAVE_C99_SUPPORT */
+
+typedef void (*GLogFunc) (const gchar *log_domain, GLogLevelFlags log_level, const gchar *message, gpointer user_data);
+typedef void (*GPrintFunc) (const gchar *string);
+
+void g_log_default_handler (const gchar *log_domain, GLogLevelFlags log_level, const gchar *message, gpointer unused_data);
+GLogFunc g_log_set_default_handler (GLogFunc log_func, gpointer user_data);
+GPrintFunc g_set_print_handler (GPrintFunc func);
+GPrintFunc g_set_printerr_handler (GPrintFunc func);
+/*
+ * Conversions
+ */
+
+gpointer g_convert_error_quark(void);
+
+
+/*
+ * Unicode Manipulation: most of this is not used by Mono by default, it is
+ * only used if the old collation code is activated, so this is only the
+ * bare minimum to build.
+ */
+
+typedef enum {
+ G_UNICODE_CONTROL,
+ G_UNICODE_FORMAT,
+ G_UNICODE_UNASSIGNED,
+ G_UNICODE_PRIVATE_USE,
+ G_UNICODE_SURROGATE,
+ G_UNICODE_LOWERCASE_LETTER,
+ G_UNICODE_MODIFIER_LETTER,
+ G_UNICODE_OTHER_LETTER,
+ G_UNICODE_TITLECASE_LETTER,
+ G_UNICODE_UPPERCASE_LETTER,
+ G_UNICODE_COMBINING_MARK,
+ G_UNICODE_ENCLOSING_MARK,
+ G_UNICODE_NON_SPACING_MARK,
+ G_UNICODE_DECIMAL_NUMBER,
+ G_UNICODE_LETTER_NUMBER,
+ G_UNICODE_OTHER_NUMBER,
+ G_UNICODE_CONNECT_PUNCTUATION,
+ G_UNICODE_DASH_PUNCTUATION,
+ G_UNICODE_CLOSE_PUNCTUATION,
+ G_UNICODE_FINAL_PUNCTUATION,
+ G_UNICODE_INITIAL_PUNCTUATION,
+ G_UNICODE_OTHER_PUNCTUATION,
+ G_UNICODE_OPEN_PUNCTUATION,
+ G_UNICODE_CURRENCY_SYMBOL,
+ G_UNICODE_MODIFIER_SYMBOL,
+ G_UNICODE_MATH_SYMBOL,
+ G_UNICODE_OTHER_SYMBOL,
+ G_UNICODE_LINE_SEPARATOR,
+ G_UNICODE_PARAGRAPH_SEPARATOR,
+ G_UNICODE_SPACE_SEPARATOR
+} GUnicodeType;
+
+typedef enum {
+ G_UNICODE_BREAK_MANDATORY,
+ G_UNICODE_BREAK_CARRIAGE_RETURN,
+ G_UNICODE_BREAK_LINE_FEED,
+ G_UNICODE_BREAK_COMBINING_MARK,
+ G_UNICODE_BREAK_SURROGATE,
+ G_UNICODE_BREAK_ZERO_WIDTH_SPACE,
+ G_UNICODE_BREAK_INSEPARABLE,
+ G_UNICODE_BREAK_NON_BREAKING_GLUE,
+ G_UNICODE_BREAK_CONTINGENT,
+ G_UNICODE_BREAK_SPACE,
+ G_UNICODE_BREAK_AFTER,
+ G_UNICODE_BREAK_BEFORE,
+ G_UNICODE_BREAK_BEFORE_AND_AFTER,
+ G_UNICODE_BREAK_HYPHEN,
+ G_UNICODE_BREAK_NON_STARTER,
+ G_UNICODE_BREAK_OPEN_PUNCTUATION,
+ G_UNICODE_BREAK_CLOSE_PUNCTUATION,
+ G_UNICODE_BREAK_QUOTATION,
+ G_UNICODE_BREAK_EXCLAMATION,
+ G_UNICODE_BREAK_IDEOGRAPHIC,
+ G_UNICODE_BREAK_NUMERIC,
+ G_UNICODE_BREAK_INFIX_SEPARATOR,
+ G_UNICODE_BREAK_SYMBOL,
+ G_UNICODE_BREAK_ALPHABETIC,
+ G_UNICODE_BREAK_PREFIX,
+ G_UNICODE_BREAK_POSTFIX,
+ G_UNICODE_BREAK_COMPLEX_CONTEXT,
+ G_UNICODE_BREAK_AMBIGUOUS,
+ G_UNICODE_BREAK_UNKNOWN,
+ G_UNICODE_BREAK_NEXT_LINE,
+ G_UNICODE_BREAK_WORD_JOINER,
+ G_UNICODE_BREAK_HANGUL_L_JAMO,
+ G_UNICODE_BREAK_HANGUL_V_JAMO,
+ G_UNICODE_BREAK_HANGUL_T_JAMO,
+ G_UNICODE_BREAK_HANGUL_LV_SYLLABLE,
+ G_UNICODE_BREAK_HANGUL_LVT_SYLLABLE
+} GUnicodeBreakType;
+
+gunichar g_unichar_toupper (gunichar c);
+gunichar g_unichar_tolower (gunichar c);
+gunichar g_unichar_totitle (gunichar c);
+GUnicodeType g_unichar_type (gunichar c);
+gboolean g_unichar_isspace (gunichar c);
+gboolean g_unichar_isxdigit (gunichar c);
+gint g_unichar_xdigit_value (gunichar c);
+GUnicodeBreakType g_unichar_break_type (gunichar c);
+
+#ifndef MAX
+#define MAX(a,b) (((a)>(b)) ? (a) : (b))
+#endif
+
+#ifndef MIN
+#define MIN(a,b) (((a)<(b)) ? (a) : (b))
+#endif
+
+#ifndef CLAMP
+#define CLAMP(a,low,high) (((a) < (low)) ? (low) : (((a) > (high)) ? (high) : (a)))
+#endif
+
+#if defined(__GNUC__) && (__GNUC__ > 2)
+#define G_LIKELY(expr) (__builtin_expect ((expr) != 0, 1))
+#define G_UNLIKELY(expr) (__builtin_expect ((expr) != 0, 0))
+#else
+#define G_LIKELY(x) (x)
+#define G_UNLIKELY(x) (x)
+#endif
+
+#if defined(_MSC_VER)
+#define eg_unreachable() __assume(0)
+#elif defined(__GNUC__) && ((__GNUC__ > 4) || (__GNUC__ == 4 && (__GNUC_MINOR__ >= 5)))
+#define eg_unreachable() __builtin_unreachable()
+#else
+#define eg_unreachable()
+#endif
+
+#define g_assert(x) G_STMT_START { if (G_UNLIKELY (!(x))) g_assertion_message ("* Assertion at %s:%d, condition `%s' not met\n", __FILE__, __LINE__, #x); } G_STMT_END
+#define g_assert_not_reached() G_STMT_START { g_assertion_message ("* Assertion: should not be reached at %s:%d\n", __FILE__, __LINE__); eg_unreachable(); } G_STMT_END
+
+/*
+ * Unicode conversion
+ */
+
+#define G_CONVERT_ERROR g_convert_error_quark()
+
+typedef enum {
+ G_CONVERT_ERROR_NO_CONVERSION,
+ G_CONVERT_ERROR_ILLEGAL_SEQUENCE,
+ G_CONVERT_ERROR_FAILED,
+ G_CONVERT_ERROR_PARTIAL_INPUT,
+ G_CONVERT_ERROR_BAD_URI,
+ G_CONVERT_ERROR_NOT_ABSOLUTE_PATH
+} GConvertError;
+
+gchar *g_utf8_strup (const gchar *str, gssize len);
+gchar *g_utf8_strdown (const gchar *str, gssize len);
+gint g_unichar_to_utf8 (gunichar c, gchar *outbuf);
+gunichar *g_utf8_to_ucs4_fast (const gchar *str, glong len, glong *items_written);
+gunichar *g_utf8_to_ucs4 (const gchar *str, glong len, glong *items_read, glong *items_written, GError **err);
+gunichar2 *g_utf8_to_utf16 (const gchar *str, glong len, glong *items_read, glong *items_written, GError **err);
+gunichar2 *eg_utf8_to_utf16_with_nuls (const gchar *str, glong len, glong *items_read, glong *items_written, GError **err);
+gchar *g_utf16_to_utf8 (const gunichar2 *str, glong len, glong *items_read, glong *items_written, GError **err);
+gunichar *g_utf16_to_ucs4 (const gunichar2 *str, glong len, glong *items_read, glong *items_written, GError **err);
+gchar *g_ucs4_to_utf8 (const gunichar *str, glong len, glong *items_read, glong *items_written, GError **err);
+gunichar2 *g_ucs4_to_utf16 (const gunichar *str, glong len, glong *items_read, glong *items_written, GError **err);
+
+#define u8to16(str) g_utf8_to_utf16(str, (glong)strlen(str), NULL, NULL, NULL)
+
+#ifdef G_OS_WIN32
+#define u16to8(str) g_utf16_to_utf8((gunichar2 *) (str), (glong)wcslen((wchar_t *) (str)), NULL, NULL, NULL)
+#else
+#define u16to8(str) g_utf16_to_utf8(str, (glong)strlen(str), NULL, NULL, NULL)
+#endif
+
+/*
+ * Path
+ */
+gchar *g_build_path (const gchar *separator, const gchar *first_element, ...);
+#define g_build_filename(x, ...) g_build_path(G_DIR_SEPARATOR_S, x, __VA_ARGS__)
+gchar *g_path_get_dirname (const gchar *filename);
+gchar *g_path_get_basename (const char *filename);
+gchar *g_find_program_in_path (const gchar *program);
+gchar *g_get_current_dir (void);
+gboolean g_path_is_absolute (const char *filename);
+
+const gchar *g_get_home_dir (void);
+const gchar *g_get_tmp_dir (void);
+const gchar *g_get_user_name (void);
+gchar *g_get_prgname (void);
+void g_set_prgname (const gchar *prgname);
+
+gboolean g_ensure_directory_exists (const gchar *filename);
+
+/*
+ * Shell
+ */
+
+gboolean g_shell_parse_argv (const gchar *command_line, gint *argcp, gchar ***argvp, GError **error);
+gchar *g_shell_unquote (const gchar *quoted_string, GError **error);
+gchar *g_shell_quote (const gchar *unquoted_string);
+
+/*
+ * Spawn
+ */
+typedef enum {
+ G_SPAWN_LEAVE_DESCRIPTORS_OPEN = 1,
+ G_SPAWN_DO_NOT_REAP_CHILD = 1 << 1,
+ G_SPAWN_SEARCH_PATH = 1 << 2,
+ G_SPAWN_STDOUT_TO_DEV_NULL = 1 << 3,
+ G_SPAWN_STDERR_TO_DEV_NULL = 1 << 4,
+ G_SPAWN_CHILD_INHERITS_STDIN = 1 << 5,
+ G_SPAWN_FILE_AND_ARGV_ZERO = 1 << 6
+} GSpawnFlags;
+
+typedef void (*GSpawnChildSetupFunc) (gpointer user_data);
+
+gboolean g_spawn_command_line_sync (const gchar *command_line, gchar **standard_output, gchar **standard_error, gint *exit_status, GError **error);
+gboolean g_spawn_async_with_pipes (const gchar *working_directory, gchar **argv, gchar **envp, GSpawnFlags flags, GSpawnChildSetupFunc child_setup,
+ gpointer user_data, GPid *child_pid, gint *standard_input, gint *standard_output, gint *standard_error, GError **error);
+
+int eg_getdtablesize (void);
+
+/*
+ * Timer
+ */
+typedef struct _GTimer GTimer;
+
+GTimer *g_timer_new (void);
+void g_timer_destroy (GTimer *timer);
+gdouble g_timer_elapsed (GTimer *timer, gulong *microseconds);
+void g_timer_stop (GTimer *timer);
+void g_timer_start (GTimer *timer);
+
+/*
+ * Date and time
+ */
+typedef struct {
+ glong tv_sec;
+ glong tv_usec;
+} GTimeVal;
+
+void g_get_current_time (GTimeVal *result);
+void g_usleep (gulong microseconds);
+
+/*
+ * File
+ */
+
+gpointer g_file_error_quark (void);
+
+#define G_FILE_ERROR g_file_error_quark ()
+
+typedef enum {
+ G_FILE_ERROR_EXIST,
+ G_FILE_ERROR_ISDIR,
+ G_FILE_ERROR_ACCES,
+ G_FILE_ERROR_NAMETOOLONG,
+ G_FILE_ERROR_NOENT,
+ G_FILE_ERROR_NOTDIR,
+ G_FILE_ERROR_NXIO,
+ G_FILE_ERROR_NODEV,
+ G_FILE_ERROR_ROFS,
+ G_FILE_ERROR_TXTBSY,
+ G_FILE_ERROR_FAULT,
+ G_FILE_ERROR_LOOP,
+ G_FILE_ERROR_NOSPC,
+ G_FILE_ERROR_NOMEM,
+ G_FILE_ERROR_MFILE,
+ G_FILE_ERROR_NFILE,
+ G_FILE_ERROR_BADF,
+ G_FILE_ERROR_INVAL,
+ G_FILE_ERROR_PIPE,
+ G_FILE_ERROR_AGAIN,
+ G_FILE_ERROR_INTR,
+ G_FILE_ERROR_IO,
+ G_FILE_ERROR_PERM,
+ G_FILE_ERROR_NOSYS,
+ G_FILE_ERROR_FAILED
+} GFileError;
+
+typedef enum {
+ G_FILE_TEST_IS_REGULAR = 1 << 0,
+ G_FILE_TEST_IS_SYMLINK = 1 << 1,
+ G_FILE_TEST_IS_DIR = 1 << 2,
+ G_FILE_TEST_IS_EXECUTABLE = 1 << 3,
+ G_FILE_TEST_EXISTS = 1 << 4
+} GFileTest;
+
+
+gboolean g_file_set_contents (const gchar *filename, const gchar *contents, gssize length, GError **error);
+gboolean g_file_get_contents (const gchar *filename, gchar **contents, gsize *length, GError **error);
+GFileError g_file_error_from_errno (gint err_no);
+gint g_file_open_tmp (const gchar *tmpl, gchar **name_used, GError **error);
+gboolean g_file_test (const gchar *filename, GFileTest test);
+
+#define g_open open
+#define g_rename rename
+#define g_stat stat
+#define g_unlink unlink
+#define g_fopen fopen
+#define g_lstat lstat
+#define g_rmdir rmdir
+#define g_mkstemp mkstemp
+#define g_ascii_isdigit isdigit
+#define g_ascii_strtod strtod
+#define g_ascii_isalnum isalnum
+
+gchar *g_mkdtemp (gchar *tmpl);
+
+/*
+ * Pattern matching
+ */
+typedef struct _GPatternSpec GPatternSpec;
+GPatternSpec * g_pattern_spec_new (const gchar *pattern);
+void g_pattern_spec_free (GPatternSpec *pspec);
+gboolean g_pattern_match_string (GPatternSpec *pspec, const gchar *string);
+
+/*
+ * Directory
+ */
+typedef struct _GDir GDir;
+GDir *g_dir_open (const gchar *path, guint flags, GError **error);
+const gchar *g_dir_read_name (GDir *dir);
+void g_dir_rewind (GDir *dir);
+void g_dir_close (GDir *dir);
+
+int g_mkdir_with_parents (const gchar *pathname, int mode);
+#define g_mkdir mkdir
+
+/*
+ * GMarkup
+ */
+typedef struct _GMarkupParseContext GMarkupParseContext;
+
+typedef enum
+{
+ G_MARKUP_DO_NOT_USE_THIS_UNSUPPORTED_FLAG = 1 << 0,
+ G_MARKUP_TREAT_CDATA_AS_TEXT = 1 << 1
+} GMarkupParseFlags;
+
+typedef struct {
+ void (*start_element) (GMarkupParseContext *context,
+ const gchar *element_name,
+ const gchar **attribute_names,
+ const gchar **attribute_values,
+ gpointer user_data,
+ GError **error);
+
+ void (*end_element) (GMarkupParseContext *context,
+ const gchar *element_name,
+ gpointer user_data,
+ GError **error);
+
+ void (*text) (GMarkupParseContext *context,
+ const gchar *text,
+ gsize text_len,
+ gpointer user_data,
+ GError **error);
+
+ void (*passthrough) (GMarkupParseContext *context,
+ const gchar *passthrough_text,
+ gsize text_len,
+ gpointer user_data,
+ GError **error);
+ void (*error) (GMarkupParseContext *context,
+ GError *error,
+ gpointer user_data);
+} GMarkupParser;
+
+GMarkupParseContext *g_markup_parse_context_new (const GMarkupParser *parser,
+ GMarkupParseFlags flags,
+ gpointer user_data,
+ GDestroyNotify user_data_dnotify);
+void g_markup_parse_context_free (GMarkupParseContext *context);
+gboolean g_markup_parse_context_parse (GMarkupParseContext *context,
+ const gchar *text, gssize text_len,
+ GError **error);
+gboolean g_markup_parse_context_end_parse (GMarkupParseContext *context,
+ GError **error);
+
+/*
+ * Character set conversion
+ */
+typedef struct _GIConv *GIConv;
+
+gsize g_iconv (GIConv cd, gchar **inbytes, gsize *inbytesleft, gchar **outbytes, gsize *outbytesleft);
+GIConv g_iconv_open (const gchar *to_charset, const gchar *from_charset);
+int g_iconv_close (GIConv cd);
+
+gboolean g_get_charset (G_CONST_RETURN char **charset);
+gchar *g_locale_to_utf8 (const gchar *opsysstring, gssize len,
+ gsize *bytes_read, gsize *bytes_written,
+ GError **error);
+gchar *g_locale_from_utf8 (const gchar *utf8string, gssize len, gsize *bytes_read,
+ gsize *bytes_written, GError **error);
+gchar *g_filename_from_utf8 (const gchar *utf8string, gssize len, gsize *bytes_read,
+ gsize *bytes_written, GError **error);
+gchar *g_convert (const gchar *str, gssize len,
+ const gchar *to_codeset, const gchar *from_codeset,
+ gsize *bytes_read, gsize *bytes_written, GError **error);
+
+/*
+ * Unicode manipulation
+ */
+extern const guchar g_utf8_jump_table[256];
+
+gboolean g_utf8_validate (const gchar *str, gssize max_len, const gchar **end);
+gunichar g_utf8_get_char_validated (const gchar *str, gssize max_len);
+gchar *g_utf8_find_prev_char (const char *str, const char *p);
+gchar *g_utf8_prev_char (const char *str);
+#define g_utf8_next_char(p) ((p) + g_utf8_jump_table[(guchar)(*p)])
+gunichar g_utf8_get_char (const gchar *src);
+glong g_utf8_strlen (const gchar *str, gssize max);
+gchar *g_utf8_offset_to_pointer (const gchar *str, glong offset);
+glong g_utf8_pointer_to_offset (const gchar *str, const gchar *pos);
+
+/*
+ * priorities
+ */
+#define G_PRIORITY_DEFAULT 0
+#define G_PRIORITY_DEFAULT_IDLE 200
+
+#define GUINT16_SWAP_LE_BE_CONSTANT(x) ((((guint16) x) >> 8) | ((((guint16) x) << 8)))
+
+#define GUINT16_SWAP_LE_BE(x) ((guint16) (((guint16) x) >> 8) | ((((guint16)(x)) & 0xff) << 8))
+#define GUINT32_SWAP_LE_BE(x) ((guint32) \
+ ( (((guint32) (x)) << 24)| \
+ ((((guint32) (x)) & 0xff0000) >> 8) | \
+ ((((guint32) (x)) & 0xff00) << 8) | \
+ (((guint32) (x)) >> 24)) )
+
+#define GUINT64_SWAP_LE_BE(x) ((guint64) (((guint64)(GUINT32_SWAP_LE_BE(((guint64)x) & 0xffffffff))) << 32) | \
+ GUINT32_SWAP_LE_BE(((guint64)x) >> 32))
+
+
+
+#if G_BYTE_ORDER == G_LITTLE_ENDIAN
+# define GUINT64_FROM_BE(x) GUINT64_SWAP_LE_BE(x)
+# define GUINT32_FROM_BE(x) GUINT32_SWAP_LE_BE(x)
+# define GUINT16_FROM_BE(x) GUINT16_SWAP_LE_BE(x)
+# define GUINT_FROM_BE(x) GUINT32_SWAP_LE_BE(x)
+# define GUINT64_FROM_LE(x) (x)
+# define GUINT32_FROM_LE(x) (x)
+# define GUINT16_FROM_LE(x) (x)
+# define GUINT_FROM_LE(x) (x)
+# define GUINT64_TO_BE(x) GUINT64_SWAP_LE_BE(x)
+# define GUINT32_TO_BE(x) GUINT32_SWAP_LE_BE(x)
+# define GUINT16_TO_BE(x) GUINT16_SWAP_LE_BE(x)
+# define GUINT_TO_BE(x) GUINT32_SWAP_LE_BE(x)
+# define GUINT64_TO_LE(x) (x)
+# define GUINT32_TO_LE(x) (x)
+# define GUINT16_TO_LE(x) (x)
+# define GUINT_TO_LE(x) (x)
+#else
+# define GUINT64_FROM_BE(x) (x)
+# define GUINT32_FROM_BE(x) (x)
+# define GUINT16_FROM_BE(x) (x)
+# define GUINT_FROM_BE(x) (x)
+# define GUINT64_FROM_LE(x) GUINT64_SWAP_LE_BE(x)
+# define GUINT32_FROM_LE(x) GUINT32_SWAP_LE_BE(x)
+# define GUINT16_FROM_LE(x) GUINT16_SWAP_LE_BE(x)
+# define GUINT_FROM_LE(x) GUINT32_SWAP_LE_BE(x)
+# define GUINT64_TO_BE(x) (x)
+# define GUINT32_TO_BE(x) (x)
+# define GUINT16_TO_BE(x) (x)
+# define GUINT_TO_BE(x) (x)
+# define GUINT64_TO_LE(x) GUINT64_SWAP_LE_BE(x)
+# define GUINT32_TO_LE(x) GUINT32_SWAP_LE_BE(x)
+# define GUINT16_TO_LE(x) GUINT16_SWAP_LE_BE(x)
+# define GUINT_TO_LE(x) GUINT32_SWAP_LE_BE(x)
+#endif
+
+#define GINT64_FROM_BE(x) (GUINT64_TO_BE (x))
+#define GINT32_FROM_BE(x) (GUINT32_TO_BE (x))
+#define GINT16_FROM_BE(x) (GUINT16_TO_BE (x))
+#define GINT64_FROM_LE(x) (GUINT64_TO_LE (x))
+#define GINT32_FROM_LE(x) (GUINT32_TO_LE (x))
+#define GINT16_FROM_LE(x) (GUINT16_TO_LE (x))
+
+#define _EGLIB_MAJOR 2
+#define _EGLIB_MIDDLE 4
+#define _EGLIB_MINOR 0
+
+#define GLIB_CHECK_VERSION(a,b,c) ((a < _EGLIB_MAJOR) || (a == _EGLIB_MAJOR && (b < _EGLIB_MIDDLE || (b == _EGLIB_MIDDLE && c <= _EGLIB_MINOR))))
+
+#define G_HAVE_API_SUPPORT(x) (x)
+#define G_UNSUPPORTED_API "%s:%d: '%s' not supported.", __FILE__, __LINE__
+#define g_unsupported_api(name) G_STMT_START { g_warning (G_UNSUPPORTED_API, name); } G_STMT_END
+
+G_END_DECLS
+
+#endif
+
+
+
--- /dev/null
+/*
+ * glist.c: Doubly-linked list implementation
+ *
+ * Authors:
+ * Duncan Mak (duncan@novell.com)
+ * Raja R Harinath (rharinath@novell.com)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * (C) 2006 Novell, Inc.
+ */
+#include <stdio.h>
+#include <glib.h>
+
+GList*
+g_list_alloc ()
+{
+ return g_new0 (GList, 1);
+}
+
+static inline GList*
+new_node (GList *prev, gpointer data, GList *next)
+{
+ GList *node = g_list_alloc ();
+ node->data = data;
+ node->prev = prev;
+ node->next = next;
+ if (prev)
+ prev->next = node;
+ if (next)
+ next->prev = node;
+ return node;
+}
+
+static inline GList*
+disconnect_node (GList *node)
+{
+ if (node->next)
+ node->next->prev = node->prev;
+ if (node->prev)
+ node->prev->next = node->next;
+ return node;
+}
+
+GList *
+g_list_prepend (GList *list, gpointer data)
+{
+ return new_node (list ? list->prev : NULL, data, list);
+}
+
+void
+g_list_free_1 (GList *list)
+{
+ g_free (list);
+}
+
+void
+g_list_free (GList *list)
+{
+ while (list){
+ GList *next = list->next;
+ g_list_free_1 (list);
+ list = next;
+ }
+}
+
+GList*
+g_list_append (GList *list, gpointer data)
+{
+ GList *node = new_node (g_list_last (list), data, NULL);
+ return list ? list : node;
+}
+
+GList *
+g_list_concat (GList *list1, GList *list2)
+{
+ if (list1 && list2) {
+ list2->prev = g_list_last (list1);
+ list2->prev->next = list2;
+ }
+ return list1 ? list1 : list2;
+}
+
+guint
+g_list_length (GList *list)
+{
+ guint length = 0;
+
+ while (list) {
+ length ++;
+ list = list->next;
+ }
+
+ return length;
+}
+
+GList*
+g_list_remove (GList *list, gconstpointer data)
+{
+ GList *current = g_list_find (list, data);
+ if (!current)
+ return list;
+
+ if (current == list)
+ list = list->next;
+ g_list_free_1 (disconnect_node (current));
+
+ return list;
+}
+
+GList*
+g_list_remove_all (GList *list, gconstpointer data)
+{
+ GList *current = g_list_find (list, data);
+
+ if (!current)
+ return list;
+
+ while (current) {
+ if (current == list)
+ list = list->next;
+ g_list_free_1 (disconnect_node (current));
+
+ current = g_list_find (list, data);
+ }
+
+ return list;
+}
+
+GList*
+g_list_remove_link (GList *list, GList *link)
+{
+ if (list == link)
+ list = list->next;
+
+ disconnect_node (link);
+ link->next = NULL;
+ link->prev = NULL;
+
+ return list;
+}
+
+GList*
+g_list_delete_link (GList *list, GList *link)
+{
+ list = g_list_remove_link (list, link);
+ g_list_free_1 (link);
+
+ return list;
+}
+
+GList*
+g_list_find (GList *list, gconstpointer data)
+{
+ while (list){
+ if (list->data == data)
+ return list;
+
+ list = list->next;
+ }
+
+ return NULL;
+}
+
+GList*
+g_list_find_custom (GList *list, gconstpointer data, GCompareFunc func)
+{
+ if (!func)
+ return NULL;
+
+ while (list) {
+ if (func (list->data, data) == 0)
+ return list;
+
+ list = list->next;
+ }
+
+ return NULL;
+}
+
+GList*
+g_list_reverse (GList *list)
+{
+ GList *reverse = NULL;
+
+ while (list) {
+ reverse = list;
+ list = reverse->next;
+
+ reverse->next = reverse->prev;
+ reverse->prev = list;
+ }
+
+ return reverse;
+}
+
+GList*
+g_list_first (GList *list)
+{
+ if (!list)
+ return NULL;
+
+ while (list->prev)
+ list = list->prev;
+
+ return list;
+}
+
+GList*
+g_list_last (GList *list)
+{
+ if (!list)
+ return NULL;
+
+ while (list->next)
+ list = list->next;
+
+ return list;
+}
+
+GList*
+g_list_insert_sorted (GList *list, gpointer data, GCompareFunc func)
+{
+ GList *prev = NULL;
+ GList *current;
+ GList *node;
+
+ if (!func)
+ return list;
+
+ /* Invariant: !prev || func (prev->data, data) <= 0) */
+ for (current = list; current; current = current->next) {
+ if (func (current->data, data) > 0)
+ break;
+ prev = current;
+ }
+
+ node = new_node (prev, data, current);
+ return list == current ? node : list;
+}
+
+GList*
+g_list_insert_before (GList *list, GList *sibling, gpointer data)
+{
+ if (sibling) {
+ GList *node = new_node (sibling->prev, data, sibling);
+ return list == sibling ? node : list;
+ }
+ return g_list_append (list, data);
+}
+
+void
+g_list_foreach (GList *list, GFunc func, gpointer user_data)
+{
+ while (list){
+ (*func) (list->data, user_data);
+ list = list->next;
+ }
+}
+
+gint
+g_list_index (GList *list, gconstpointer data)
+{
+ gint index = 0;
+
+ while (list){
+ if (list->data == data)
+ return index;
+
+ index ++;
+ list = list->next;
+ }
+
+ return -1;
+}
+
+GList*
+g_list_nth (GList *list, guint n)
+{
+ for (; list; list = list->next) {
+ if (n == 0)
+ break;
+ n--;
+ }
+ return list;
+}
+
+gpointer
+g_list_nth_data (GList *list, guint n)
+{
+ GList *node = g_list_nth (list, n);
+ return node ? node->data : NULL;
+}
+
+GList*
+g_list_copy (GList *list)
+{
+ GList *copy = NULL;
+
+ if (list) {
+ GList *tmp = new_node (NULL, list->data, NULL);
+ copy = tmp;
+
+ for (list = list->next; list; list = list->next)
+ tmp = new_node (tmp, list->data, NULL);
+ }
+
+ return copy;
+}
+
+typedef GList list_node;
+#include "sort.frag.h"
+
+GList*
+g_list_sort (GList *list, GCompareFunc func)
+{
+ GList *current;
+ if (!list || !list->next)
+ return list;
+ list = do_sort (list, func);
+
+ /* Fixup: do_sort doesn't update 'prev' pointers */
+ list->prev = NULL;
+ for (current = list; current->next; current = current->next)
+ current->next->prev = current;
+
+ return list;
+}
--- /dev/null
+/*
+ * gmakrup.c: Minimal XML markup reader.
+ *
+ * Unlike the GLib one, this can not be restarted with more text
+ * as the Mono use does not require it.
+ *
+ * Actually, with further thought, I think that this could be made
+ * to restart very easily. The pos == end condition would mean
+ * "return to caller" and only at end parse this would be a fatal
+ * error.
+ *
+ * Not that it matters to Mono, but it is very simple to change, there
+ * is a tricky situation: there are a few places where we check p+n
+ * in the source, and that would have to change to be progressive, instead
+ * of depending on the string to be complete at that point, so we would
+ * have to introduce extra states to cope with that.
+ *
+ * Author:
+ * Miguel de Icaza (miguel@novell.com)
+ *
+ * (C) 2006 Novell, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#include <stdio.h>
+#include <ctype.h>
+#include <glib.h>
+
+#define set_error(msg, ...) do { if (error != NULL) *error = g_error_new (GINT_TO_POINTER (1), 1, msg, __VA_ARGS__); } while (0);
+
+typedef enum {
+ START,
+ START_ELEMENT,
+ TEXT,
+ FLUSH_TEXT,
+ CLOSING_ELEMENT,
+ COMMENT,
+ SKIP_XML_DECLARATION
+} ParseState;
+
+struct _GMarkupParseContext {
+ GMarkupParser parser;
+ gpointer user_data;
+ GDestroyNotify user_data_dnotify;
+ ParseState state;
+
+ /* Stores the name of the current element, so we can issue the end_element */
+ GSList *level;
+
+ GString *text;
+};
+
+GMarkupParseContext *
+g_markup_parse_context_new (const GMarkupParser *parser,
+ GMarkupParseFlags flags,
+ gpointer user_data,
+ GDestroyNotify user_data_dnotify)
+{
+ GMarkupParseContext *context = g_new0 (GMarkupParseContext, 1);
+
+ context->parser = *parser;
+ context->user_data = user_data;
+ context->user_data_dnotify = user_data_dnotify;
+
+ return context;
+}
+
+void
+g_markup_parse_context_free (GMarkupParseContext *context)
+{
+ GSList *l;
+
+ g_return_if_fail (context != NULL);
+
+ if (context->user_data_dnotify != NULL)
+ (context->user_data_dnotify) (context->user_data);
+
+ if (context->text != NULL)
+ g_string_free (context->text, TRUE);
+ for (l = context->level; l; l = l->next)
+ g_free (l->data);
+ g_slist_free (context->level);
+ g_free (context);
+}
+
+static gboolean
+my_isspace (char c)
+{
+ if (c == ' ' || c == '\t' || c == '\r' || c == '\n' || c == '\v')
+ return TRUE;
+ return FALSE;
+}
+
+static gboolean
+my_isalnum (char c)
+{
+ if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))
+ return TRUE;
+ if (c >= '0' && c <= '9')
+ return TRUE;
+
+ return FALSE;
+}
+
+static gboolean
+my_isalpha (char c)
+{
+ if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))
+ return TRUE;
+ return FALSE;
+}
+
+static const char *
+skip_space (const char *p, const char *end)
+{
+ for (; p < end && my_isspace (*p); p++)
+ ;
+ return p;
+}
+
+static const char *
+parse_value (const char *p, const char *end, char **value, GError **error)
+{
+ const char *start;
+ int l;
+
+ if (*p != '"'){
+ set_error ("%s", "Expected the attribute value to start with a quote");
+ return end;
+ }
+ start = ++p;
+ for (; p < end && *p != '"'; p++)
+ ;
+ if (p == end)
+ return end;
+ l = (int)(p - start);
+ p++;
+ *value = g_malloc (l + 1);
+ if (*value == NULL)
+ return end;
+ strncpy (*value, start, l);
+ (*value) [l] = 0;
+ return p;
+}
+
+static const char *
+parse_name (const char *p, const char *end, char **value)
+{
+ const char *start = p;
+ int l;
+
+ for (; p < end && my_isalnum (*p); p++)
+ ;
+ if (p == end)
+ return end;
+
+ l = (int)(p - start);
+ *value = g_malloc (l + 1);
+ if (*value == NULL)
+ return end;
+ strncpy (*value, start, l);
+ (*value) [l] = 0;
+ return p;
+}
+
+static const char *
+parse_attributes (const char *p, const char *end, char ***names, char ***values, GError **error, int *full_stop, int state)
+{
+ int nnames = 0;
+
+ while (TRUE){
+ p = skip_space (p, end);
+ if (p == end)
+ return end;
+
+ if (*p == '>'){
+ *full_stop = 0;
+ return p;
+ }
+ if (state == SKIP_XML_DECLARATION && *p == '?' && ((p+1) < end) && *(p+1) == '>'){
+ *full_stop = 0;
+ return p+1;
+ }
+
+ if (*p == '/' && ((p+1) < end && *(p+1) == '>')){
+ *full_stop = 1;
+ return p+1;
+ } else {
+ char *name, *value;
+
+ p = parse_name (p, end, &name);
+ if (p == end)
+ return p;
+
+ p = skip_space (p, end);
+ if (p == end){
+ g_free (name);
+ return p;
+ }
+ if (*p != '='){
+ set_error ("Expected an = after the attribute name `%s'", name);
+ g_free (name);
+ return end;
+ }
+ p++;
+ p = skip_space (p, end);
+ if (p == end){
+ g_free (name);
+ return end;
+ }
+
+ p = parse_value (p, end, &value, error);
+ if (p == end){
+ g_free (name);
+ return p;
+ }
+
+ ++nnames;
+ *names = g_realloc (*names, sizeof (char **) * (nnames+1));
+ *values = g_realloc (*values, sizeof (char **) * (nnames+1));
+ (*names) [nnames-1] = name;
+ (*values) [nnames-1] = value;
+ (*names) [nnames] = NULL;
+ (*values) [nnames] = NULL;
+ }
+ }
+}
+
+static void
+destroy_parse_state (GMarkupParseContext *context)
+{
+ GSList *p;
+
+ for (p = context->level; p != NULL; p = p->next)
+ g_free (p->data);
+
+ g_slist_free (context->level);
+ if (context->text != NULL)
+ g_string_free (context->text, TRUE);
+ context->text = NULL;
+ context->level = NULL;
+}
+
+gboolean
+g_markup_parse_context_parse (GMarkupParseContext *context,
+ const gchar *text, gssize text_len,
+ GError **error)
+{
+ const char *p, *end;
+
+ g_return_val_if_fail (context != NULL, FALSE);
+ g_return_val_if_fail (text != NULL, FALSE);
+ g_return_val_if_fail (text_len >= 0, FALSE);
+
+ end = text + text_len;
+
+ for (p = text; p < end; p++){
+ char c = *p;
+
+ switch (context->state){
+ case START:
+ if (c == ' ' || c == '\t' || c == '\f' || c == '\n' || (c & 0x80))
+ continue;
+ if (c == '<'){
+ if (p+1 < end && p [1] == '?'){
+ context->state = SKIP_XML_DECLARATION;
+ p++;
+ } else
+ context->state = START_ELEMENT;
+ continue;
+ }
+ set_error ("%s", "Expected < to start the document");
+ goto fail;
+
+ case SKIP_XML_DECLARATION:
+ case START_ELEMENT: {
+ const char *element_start = p, *element_end;
+ char *ename = NULL;
+ int full_stop = 0, l;
+ gchar **names = NULL, **values = NULL;
+
+ for (; p < end && my_isspace (*p); p++)
+ ;
+ if (p == end){
+ set_error ("%s", "Unfinished element");
+ goto fail;
+ }
+
+ if (*p == '!' && (p+2 < end) && (p [1] == '-') && (p [2] == '-')){
+ context->state = COMMENT;
+ p += 2;
+ break;
+ }
+
+ if (!my_isalpha (*p)){
+ set_error ("%s", "Expected an element name");
+ goto fail;
+ }
+
+ for (++p; p < end && (my_isalnum (*p) || (*p == '.')); p++)
+ ;
+ if (p == end){
+ set_error ("%s", "Expected an element");
+ goto fail;
+ }
+ element_end = p;
+
+ for (; p < end && my_isspace (*p); p++)
+ ;
+ if (p == end){
+ set_error ("%s", "Unfinished element");
+ goto fail;
+ }
+ p = parse_attributes (p, end, &names, &values, error, &full_stop, context->state);
+ if (p == end){
+ if (names != NULL) {
+ g_strfreev (names);
+ g_strfreev (values);
+ }
+ /* Only set the error if parse_attributes did not */
+ if (error != NULL && *error == NULL)
+ set_error ("%s", "Unfinished sequence");
+ goto fail;
+ }
+ l = (int)(element_end - element_start);
+ ename = g_malloc (l + 1);
+ if (ename == NULL)
+ goto fail;
+ strncpy (ename, element_start, l);
+ ename [l] = 0;
+
+ if (context->state == START_ELEMENT)
+ if (context->parser.start_element != NULL)
+ context->parser.start_element (context, ename,
+ (const gchar **) names,
+ (const gchar **) values,
+ context->user_data, error);
+
+ if (names != NULL){
+ g_strfreev (names);
+ g_strfreev (values);
+ }
+
+ if (error != NULL && *error != NULL){
+ g_free (ename);
+ goto fail;
+ }
+
+ if (full_stop){
+ if (context->parser.end_element != NULL && context->state == START_ELEMENT){
+ context->parser.end_element (context, ename, context->user_data, error);
+ if (error != NULL && *error != NULL){
+ g_free (ename);
+ goto fail;
+ }
+ }
+ g_free (ename);
+ } else {
+ context->level = g_slist_prepend (context->level, ename);
+ }
+
+ context->state = TEXT;
+ break;
+ } /* case START_ELEMENT */
+
+ case TEXT: {
+ if (c == '<'){
+ context->state = FLUSH_TEXT;
+ break;
+ }
+ if (context->parser.text != NULL){
+ if (context->text == NULL)
+ context->text = g_string_new ("");
+ g_string_append_c (context->text, c);
+ }
+ break;
+ }
+
+ case COMMENT:
+ if (*p != '-')
+ break;
+ if (p+2 < end && (p [1] == '-') && (p [2] == '>')){
+ context->state = TEXT;
+ p += 2;
+ break;
+ }
+ break;
+
+ case FLUSH_TEXT:
+ if (context->parser.text != NULL && context->text != NULL){
+ context->parser.text (context, context->text->str, context->text->len,
+ context->user_data, error);
+ if (error != NULL && *error != NULL)
+ goto fail;
+ }
+
+ if (c == '/')
+ context->state = CLOSING_ELEMENT;
+ else {
+ p--;
+ context->state = START_ELEMENT;
+ }
+ break;
+
+ case CLOSING_ELEMENT: {
+ GSList *current = context->level;
+ char *text;
+
+ if (context->level == NULL){
+ set_error ("%s", "Too many closing tags, not enough open tags");
+ goto fail;
+ }
+
+ text = current->data;
+ if (context->parser.end_element != NULL){
+ context->parser.end_element (context, text, context->user_data, error);
+ if (error != NULL && *error != NULL){
+ g_free (text);
+ goto fail;
+ }
+ }
+ g_free (text);
+
+ while (p < end && *p != '>')
+ p++;
+
+ context->level = context->level->next;
+ g_slist_free_1 (current);
+ context->state = TEXT;
+ break;
+ } /* case CLOSING_ELEMENT */
+
+ } /* switch */
+ }
+
+
+ return TRUE;
+ fail:
+ if (context->parser.error && error != NULL && *error)
+ context->parser.error (context, *error, context->user_data);
+
+ destroy_parse_state (context);
+ return FALSE;
+}
+
+gboolean
+g_markup_parse_context_end_parse (GMarkupParseContext *context, GError **error)
+{
+ g_return_val_if_fail (context != NULL, FALSE);
+
+ /*
+ * In our case, we always signal errors during parse, not at the end
+ * see the notes at the top of this file for details on how this
+ * could be moved here
+ */
+ return TRUE;
+}
--- /dev/null
+/*
+ * gmem.c: memory utility functions
+ *
+ * Author:
+ * Gonzalo Paniagua Javier (gonzalo@novell.com)
+ *
+ * (C) 2006 Novell, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#include <config.h>
+#include <stdio.h>
+#include <string.h>
+#include <glib.h>
+
+#if defined (ENABLE_OVERRIDABLE_ALLOCATORS)
+
+static GMemVTable sGMemVTable = { malloc, realloc, free, calloc };
+
+void
+g_mem_set_vtable (GMemVTable* vtable)
+{
+ sGMemVTable.calloc = vtable->calloc ? vtable->calloc : calloc;
+ sGMemVTable.realloc = vtable->realloc ? vtable->realloc : realloc;
+ sGMemVTable.malloc = vtable->malloc ? vtable->malloc : malloc;
+ sGMemVTable.free = vtable->free ? vtable->free : free;
+}
+
+#define G_FREE_INTERNAL sGMemVTable.free
+#define G_REALLOC_INTERNAL sGMemVTable.realloc
+#define G_CALLOC_INTERNAL sGMemVTable.calloc
+#define G_MALLOC_INTERNAL sGMemVTable.malloc
+#else
+
+void
+g_mem_set_vtable (GMemVTable* vtable)
+{
+}
+
+#define G_FREE_INTERNAL free
+#define G_REALLOC_INTERNAL realloc
+#define G_CALLOC_INTERNAL calloc
+#define G_MALLOC_INTERNAL malloc
+#endif
+void
+g_free (void *ptr)
+{
+ if (ptr != NULL)
+ G_FREE_INTERNAL (ptr);
+}
+
+gpointer
+g_memdup (gconstpointer mem, guint byte_size)
+{
+ gpointer ptr;
+
+ if (mem == NULL)
+ return NULL;
+
+ ptr = g_malloc (byte_size);
+ if (ptr != NULL)
+ memcpy (ptr, mem, byte_size);
+
+ return ptr;
+}
+
+gpointer g_realloc (gpointer obj, gsize size)
+{
+ gpointer ptr;
+ if (!size) {
+ g_free (obj);
+ return 0;
+ }
+ ptr = G_REALLOC_INTERNAL (obj, size);
+ if (ptr)
+ return ptr;
+ g_error ("Could not allocate %i bytes", size);
+}
+
+gpointer
+g_malloc (gsize x)
+{
+ gpointer ptr;
+ if (!x)
+ return 0;
+ ptr = G_MALLOC_INTERNAL (x);
+ if (ptr)
+ return ptr;
+ g_error ("Could not allocate %i bytes", x);
+}
+
+gpointer g_calloc (gsize n, gsize x)
+{
+ gpointer ptr;
+ if (!x || !n)
+ return 0;
+ ptr = G_CALLOC_INTERNAL (n, x);
+ if (ptr)
+ return ptr;
+ g_error ("Could not allocate %i (%i * %i) bytes", x*n, n, x);
+}
+gpointer g_malloc0 (gsize x)
+{
+ return g_calloc (1,x);
+}
+
+gpointer g_try_malloc (gsize x)
+{
+ if (x)
+ return G_MALLOC_INTERNAL (x);
+ return 0;
+}
+
+
+gpointer g_try_realloc (gpointer obj, gsize size)
+{
+ if (!size) {
+ G_FREE_INTERNAL (obj);
+ return 0;
+ }
+ return G_REALLOC_INTERNAL (obj, size);
+}
--- /dev/null
+/*
+ * gmisc.c: Misc functions with no place to go (right now)
+ *
+ * Author:
+ * Aaron Bockover (abockover@novell.com)
+ *
+ * (C) 2006 Novell, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#include <config.h>
+#include <stdlib.h>
+#include <glib.h>
+#include <pthread.h>
+
+#ifdef HAVE_PWD_H
+#include <pwd.h>
+#endif
+
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+static pthread_mutex_t env_lock = PTHREAD_MUTEX_INITIALIZER;
+
+/* MONO Comment
+ *
+ * As per the UNIX spec,
+ * "The return value from getenv() may point to static data which may be overwritten by subsequent calls to getenv(), setenv(), or unsetenv()."
+ * Source: Unix Manual Pages for getenv, IEEE Std 1003.1
+ *
+ * This means that using pointers returned from getenv may (and does) lead to many
+ * pointers which refer to the same piece of memory. When one is freed, all will be freed.
+ *
+ * This is unsafe and an ergonomics risk to fix in the callers. While the caller could lock,
+ * this introduces the risk for looping or exiting while inside of a lock. For this reason,
+ * g_getenv does not mimic the behavior of POSIX getenv anymore.
+ *
+ * The memory address returned will be unique to the invocaton, and must be freed.
+ * */
+gchar *
+g_getenv (const gchar *variable)
+{
+ gchar *ret = NULL;
+ pthread_mutex_lock (&env_lock);
+ gchar *res = getenv(variable);
+ if (res)
+ ret = g_strdup(res);
+ pthread_mutex_unlock (&env_lock);
+
+ return ret;
+}
+
+/*
+ * This function checks if the given variable is non-NULL
+ * in the environment. It's useful because it removes memory
+ * freeing requirements.
+ *
+ */
+gboolean
+g_hasenv (const gchar *variable)
+{
+ pthread_mutex_lock (&env_lock);
+ gchar *res = getenv(variable);
+ gboolean not_null = (res != NULL);
+ pthread_mutex_unlock (&env_lock);
+
+ return not_null;
+}
+
+gboolean
+g_setenv(const gchar *variable, const gchar *value, gboolean overwrite)
+{
+ gboolean res;
+ pthread_mutex_lock (&env_lock);
+ res = (setenv(variable, value, overwrite) == 0);
+ pthread_mutex_unlock (&env_lock);
+ return res;
+}
+
+void
+g_unsetenv(const gchar *variable)
+{
+ pthread_mutex_lock (&env_lock);
+ unsetenv(variable);
+ pthread_mutex_unlock (&env_lock);
+}
+
+gchar*
+g_win32_getlocale(void)
+{
+ return NULL;
+}
+
+gboolean
+g_path_is_absolute (const char *filename)
+{
+ g_return_val_if_fail (filename != NULL, FALSE);
+
+ return (*filename == '/');
+}
+
+static pthread_mutex_t pw_lock = PTHREAD_MUTEX_INITIALIZER;
+static const gchar *home_dir;
+static const gchar *user_name;
+
+static void
+get_pw_data (void)
+{
+#ifdef HAVE_GETPWUID_R
+ struct passwd pw;
+ struct passwd *result;
+ char buf [4096];
+#endif
+
+ if (user_name != NULL)
+ return;
+
+ pthread_mutex_lock (&pw_lock);
+ if (user_name != NULL) {
+ pthread_mutex_unlock (&pw_lock);
+ return;
+ }
+
+ home_dir = g_getenv ("HOME");
+ user_name = g_getenv ("USER");
+
+#ifdef HAVE_GETPWUID_R
+ if (home_dir == NULL || user_name == NULL) {
+ if (getpwuid_r (getuid (), &pw, buf, 4096, &result) == 0) {
+ if (home_dir == NULL)
+ home_dir = g_strdup (pw.pw_dir);
+ if (user_name == NULL)
+ user_name = g_strdup (pw.pw_name);
+ }
+ }
+#endif
+
+ if (user_name == NULL)
+ user_name = "somebody";
+ if (home_dir == NULL)
+ home_dir = "/";
+
+ pthread_mutex_unlock (&pw_lock);
+}
+
+const gchar *
+g_get_home_dir (void)
+{
+ get_pw_data ();
+ return home_dir;
+}
+
+const char *
+g_get_user_name (void)
+{
+ get_pw_data ();
+ return user_name;
+}
+
+static const char *tmp_dir;
+
+static pthread_mutex_t tmp_lock = PTHREAD_MUTEX_INITIALIZER;
+
+const gchar *
+g_get_tmp_dir (void)
+{
+ if (tmp_dir == NULL){
+ pthread_mutex_lock (&tmp_lock);
+ if (tmp_dir == NULL){
+ tmp_dir = g_getenv ("TMPDIR");
+ if (tmp_dir == NULL){
+ tmp_dir = g_getenv ("TMP");
+ if (tmp_dir == NULL){
+ tmp_dir = g_getenv ("TEMP");
+ if (tmp_dir == NULL)
+ tmp_dir = "/tmp";
+ }
+ }
+ }
+ pthread_mutex_unlock (&tmp_lock);
+ }
+ return tmp_dir;
+}
+
--- /dev/null
+/*
+ * gmisc-win32-uwp.c: UWP misc support.
+ *
+ * Copyright 2016 Microsoft
+ * Licensed under the MIT license. See LICENSE file in the project root for full license information.
+*/
+#include <config.h>
+#include <glib.h>
+
+#if G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT)
+#include <windows.h>
+#include <assert.h>
+
+gchar*
+g_win32_getlocale(void)
+{
+ gunichar2 buf[19];
+ gint ccBuf = GetLocaleInfoEx (LOCALE_NAME_USER_DEFAULT, LOCALE_SISO639LANGNAME, buf, 9);
+ assert (ccBuf <= 9);
+ if (ccBuf != 0) {
+ buf[ccBuf - 1] = L'-';
+ ccBuf = GetLocaleInfoEx (LOCALE_NAME_USER_DEFAULT, LOCALE_SISO3166CTRYNAME, buf + ccBuf, 9);
+ assert (ccBuf <= 9);
+ }
+
+ // Check for GetLocaleInfoEx failure.
+ if (ccBuf == 0)
+ buf[0] = L'\0';
+
+ return u16to8 (buf);
+}
+
+#else /* G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT) */
+
+#ifdef _MSC_VER
+// Quiet Visual Studio linker warning, LNK4221, in cases when this source file intentional ends up empty.
+void __mono_win32_gmisc_win32_uwp_quiet_lnk4221(void) {}
+#endif
+#endif /* G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT) */
--- /dev/null
+/*
+ * gmisc.c: Misc functions with no place to go (right now)
+ *
+ * Author:
+ * Aaron Bockover (abockover@novell.com)
+ *
+ * (C) 2006 Novell, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#include <config.h>
+
+#include <stdlib.h>
+#include <glib.h>
+
+#include <windows.h>
+#if _MSC_VER && G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
+#include <shlobj.h>
+#endif
+#include <direct.h>
+#include <io.h>
+#include <assert.h>
+
+gboolean
+g_hasenv (const gchar *variable)
+{
+ return g_getenv (variable) != NULL;
+}
+
+gchar *
+g_getenv(const gchar *variable)
+{
+ gunichar2 *var, *buffer;
+ gchar* val = NULL;
+ gint32 buffer_size = 1024;
+ gint32 retval;
+ var = u8to16(variable);
+ buffer = g_malloc(buffer_size*sizeof(gunichar2));
+ retval = GetEnvironmentVariableW (var, buffer, buffer_size);
+ if (retval != 0) {
+ if (retval > buffer_size) {
+ g_free (buffer);
+ buffer_size = retval;
+ buffer = g_malloc(buffer_size*sizeof(gunichar2));
+ retval = GetEnvironmentVariableW (var, buffer, buffer_size);
+ }
+ val = u16to8 (buffer);
+ } else {
+ if (GetLastError () != ERROR_ENVVAR_NOT_FOUND){
+ val = g_malloc (1);
+ *val = 0;
+ }
+ }
+ g_free(var);
+ g_free(buffer);
+ return val;
+}
+
+gboolean
+g_setenv(const gchar *variable, const gchar *value, gboolean overwrite)
+{
+ gunichar2 *var, *val;
+ gboolean result;
+ var = u8to16(variable);
+ val = u8to16(value);
+ result = (SetEnvironmentVariableW(var, val) != 0) ? TRUE : FALSE;
+ g_free(var);
+ g_free(val);
+ return result;
+}
+
+void
+g_unsetenv(const gchar *variable)
+{
+ gunichar2 *var;
+ var = u8to16(variable);
+ SetEnvironmentVariableW(var, L"");
+ g_free(var);
+}
+
+#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
+gchar*
+g_win32_getlocale(void)
+{
+ LCID lcid = GetThreadLocale();
+ gchar buf[19];
+ gint ccBuf = GetLocaleInfoA(lcid, LOCALE_SISO639LANGNAME, buf, 9);
+ buf[ccBuf - 1] = '-';
+ ccBuf += GetLocaleInfoA(lcid, LOCALE_SISO3166CTRYNAME, buf + ccBuf, 9);
+ return g_strdup (buf);
+}
+#endif /* G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) */
+
+gboolean
+g_path_is_absolute (const char *filename)
+{
+ g_return_val_if_fail (filename != NULL, FALSE);
+
+ if (filename[0] != '\0' && filename[1] != '\0') {
+ if (filename[1] == ':' && filename[2] != '\0' &&
+ (filename[2] == '\\' || filename[2] == '/'))
+ return TRUE;
+ /* UNC paths */
+ else if (filename[0] == '\\' && filename[1] == '\\' &&
+ filename[2] != '\0')
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+#if _MSC_VER && G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
+static gchar*
+g_get_known_folder_path (void)
+{
+ gchar *folder_path = NULL;
+ PWSTR profile_path = NULL;
+ HRESULT hr = SHGetKnownFolderPath (&FOLDERID_Profile, KF_FLAG_DEFAULT, NULL, &profile_path);
+ if (SUCCEEDED(hr)) {
+ folder_path = u16to8 (profile_path);
+ CoTaskMemFree (profile_path);
+ }
+
+ return folder_path;
+}
+
+#else
+
+static inline gchar *
+g_get_known_folder_path (void)
+{
+ return NULL;
+}
+#endif
+
+const gchar *
+g_get_home_dir (void)
+{
+ gchar *home_dir = g_get_known_folder_path ();
+
+ if (!home_dir) {
+ home_dir = (gchar *) g_getenv ("USERPROFILE");
+ }
+
+ if (!home_dir) {
+ const gchar *drive = g_getenv ("HOMEDRIVE");
+ const gchar *path = g_getenv ("HOMEPATH");
+
+ if (drive && path) {
+ home_dir = g_malloc (strlen (drive) + strlen (path) + 1);
+ if (home_dir) {
+ sprintf (home_dir, "%s%s", drive, path);
+ }
+ }
+ g_free (drive);
+ g_free (path);
+ }
+
+ return home_dir;
+}
+
+const char *
+g_get_user_name (void)
+{
+ const char * retName = g_getenv ("USER");
+ if (!retName)
+ retName = g_getenv ("USERNAME");
+ return retName;
+}
+
+static const char *tmp_dir;
+
+const gchar *
+g_get_tmp_dir (void)
+{
+ if (tmp_dir == NULL){
+ if (tmp_dir == NULL){
+ tmp_dir = g_getenv ("TMPDIR");
+ if (tmp_dir == NULL){
+ tmp_dir = g_getenv ("TMP");
+ if (tmp_dir == NULL){
+ tmp_dir = g_getenv ("TEMP");
+ if (tmp_dir == NULL)
+ tmp_dir = "C:\\temp";
+ }
+ }
+ }
+ }
+ return tmp_dir;
+}
--- /dev/null
+/*
+ * gmodule.c: dl* functions, glib style
+ *
+ * Author:
+ * Gonzalo Paniagua Javier (gonzalo@novell.com)
+ * Jonathan Chambers (joncham@gmail.com)
+ * Robert Jordan (robertj@gmx.net)
+ *
+ * (C) 2006 Novell, Inc.
+ * (C) 2006 Jonathan Chambers
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#include <config.h>
+
+#include <glib.h>
+#include <gmodule.h>
+
+#if defined(G_OS_UNIX) && defined(HAVE_DLFCN_H)
+#include <dlfcn.h>
+
+/* For Linux and Solaris, need to add others as we port this */
+#define LIBPREFIX "lib"
+#define LIBSUFFIX ".so"
+
+struct _GModule {
+ void *handle;
+};
+
+GModule *
+g_module_open (const gchar *file, GModuleFlags flags)
+{
+ int f = 0;
+ GModule *module;
+ void *handle;
+
+ flags &= G_MODULE_BIND_MASK;
+ if ((flags & G_MODULE_BIND_LAZY) != 0)
+ f |= RTLD_LAZY;
+ if ((flags & G_MODULE_BIND_LOCAL) != 0)
+ f |= RTLD_LOCAL;
+
+ handle = dlopen (file, f);
+ if (handle == NULL)
+ return NULL;
+
+ module = g_new (GModule,1);
+ module->handle = handle;
+
+ return module;
+}
+
+gboolean
+g_module_symbol (GModule *module, const gchar *symbol_name, gpointer *symbol)
+{
+ if (symbol_name == NULL || symbol == NULL)
+ return FALSE;
+
+ if (module == NULL || module->handle == NULL)
+ return FALSE;
+
+ *symbol = dlsym (module->handle, symbol_name);
+ return (*symbol != NULL);
+}
+
+const gchar *
+g_module_error (void)
+{
+ return dlerror ();
+}
+
+gboolean
+g_module_close (GModule *module)
+{
+ void *handle;
+ if (module == NULL || module->handle == NULL)
+ return FALSE;
+
+ handle = module->handle;
+ module->handle = NULL;
+ g_free (module);
+ return (0 == dlclose (handle));
+}
+
+#elif defined (G_OS_WIN32)
+#include <windows.h>
+#include <psapi.h>
+
+#define LIBSUFFIX ".dll"
+#define LIBPREFIX ""
+
+struct _GModule {
+ HMODULE handle;
+ int main_module;
+};
+
+GModule *
+g_module_open (const gchar *file, GModuleFlags flags)
+{
+ GModule *module;
+ module = g_malloc (sizeof (GModule));
+ if (module == NULL)
+ return NULL;
+
+ if (file != NULL) {
+ gunichar2 *file16;
+ file16 = u8to16(file);
+ module->main_module = FALSE;
+ module->handle = LoadLibrary (file16);
+ g_free(file16);
+ if (!module->handle) {
+ g_free (module);
+ return NULL;
+ }
+
+ } else {
+ module->main_module = TRUE;
+ module->handle = GetModuleHandle (NULL);
+ }
+
+ return module;
+}
+
+static gpointer
+w32_find_symbol (const gchar *symbol_name)
+{
+ HMODULE *modules;
+ DWORD buffer_size = sizeof (HMODULE) * 1024;
+ DWORD needed, i;
+
+ modules = (HMODULE *) g_malloc (buffer_size);
+
+ if (modules == NULL)
+ return NULL;
+
+ if (!EnumProcessModules (GetCurrentProcess (), modules,
+ buffer_size, &needed)) {
+ g_free (modules);
+ return NULL;
+ }
+
+ /* check whether the supplied buffer was too small, realloc, retry */
+ if (needed > buffer_size) {
+ g_free (modules);
+
+ buffer_size = needed;
+ modules = (HMODULE *) g_malloc (buffer_size);
+
+ if (modules == NULL)
+ return NULL;
+
+ if (!EnumProcessModules (GetCurrentProcess (), modules,
+ buffer_size, &needed)) {
+ g_free (modules);
+ return NULL;
+ }
+ }
+
+ for (i = 0; i < needed / sizeof (HANDLE); i++) {
+ gpointer proc = (gpointer)(intptr_t)GetProcAddress (modules [i], symbol_name);
+ if (proc != NULL) {
+ g_free (modules);
+ return proc;
+ }
+ }
+
+ g_free (modules);
+ return NULL;
+}
+
+gboolean
+g_module_symbol (GModule *module, const gchar *symbol_name, gpointer *symbol)
+{
+ if (module == NULL || symbol_name == NULL || symbol == NULL)
+ return FALSE;
+
+ if (module->main_module) {
+ *symbol = (gpointer)(intptr_t)GetProcAddress (module->handle, symbol_name);
+ if (*symbol != NULL)
+ return TRUE;
+
+ *symbol = w32_find_symbol (symbol_name);
+ return *symbol != NULL;
+ } else {
+ *symbol = (gpointer)(intptr_t)GetProcAddress (module->handle, symbol_name);
+ return *symbol != NULL;
+ }
+}
+
+const gchar *
+g_module_error (void)
+{
+ gchar* ret = NULL;
+ TCHAR* buf = NULL;
+ DWORD code = GetLastError ();
+
+ FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER, NULL,
+ code, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), buf, 0, NULL);
+
+ ret = u16to8 (buf);
+ LocalFree(buf);
+
+ return ret;
+}
+
+gboolean
+g_module_close (GModule *module)
+{
+ HMODULE handle;
+ int main_module;
+
+ if (module == NULL || module->handle == NULL)
+ return FALSE;
+
+ handle = module->handle;
+ main_module = module->main_module;
+ module->handle = NULL;
+ g_free (module);
+ return (main_module ? 1 : (0 == FreeLibrary (handle)));
+}
+
+#else
+
+#define LIBSUFFIX ""
+#define LIBPREFIX ""
+
+GModule *
+g_module_open (const gchar *file, GModuleFlags flags)
+{
+ g_error ("%s", "g_module_open not implemented on this platform");
+ return NULL;
+}
+
+gboolean
+g_module_symbol (GModule *module, const gchar *symbol_name, gpointer *symbol)
+{
+ g_error ("%s", "g_module_open not implemented on this platform");
+ return FALSE;
+}
+
+const gchar *
+g_module_error (void)
+{
+ g_error ("%s", "g_module_open not implemented on this platform");
+ return NULL;
+}
+
+gboolean
+g_module_close (GModule *module)
+{
+ g_error ("%s", "g_module_open not implemented on this platform");
+ return FALSE;
+}
+#endif
+
+gchar *
+g_module_build_path (const gchar *directory, const gchar *module_name)
+{
+ char *lib_prefix = "";
+
+ if (module_name == NULL)
+ return NULL;
+
+ if (strncmp (module_name, "lib", 3) != 0)
+ lib_prefix = LIBPREFIX;
+
+ if (directory && *directory){
+
+ return g_strdup_printf ("%s/%s%s" LIBSUFFIX, directory, lib_prefix, module_name);
+ }
+ return g_strdup_printf ("%s%s" LIBSUFFIX, lib_prefix, module_name);
+}
+
--- /dev/null
+#ifndef __G_MODULE_WINDOWS_INTERNALS_H__
+#define __G_MODULE_WINDOWS_INTERNALS_H__
+
+#include <config.h>
+#include <glib.h>
+
+#ifdef G_OS_WIN32
+#include <gmodule.h>
+
+gpointer
+w32_find_symbol (const gchar *symbol_name);
+#endif /* G_OS_WIN32 */
+#endif /* __G_MODULE_WINDOWS_INTERNALS_H__ */
--- /dev/null
+/*
+ * gmodule-win32-uwp.c: UWP gmodule support.
+ *
+ * Copyright 2016 Microsoft
+ * Licensed under the MIT license. See LICENSE file in the project root for full license information.
+*/
+#include <config.h>
+#include <glib.h>
+
+#if G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT)
+#include <windows.h>
+#include <gmodule-win32-internals.h>
+
+gpointer
+w32_find_symbol (const gchar *symbol_name)
+{
+ g_unsupported_api ("EnumProcessModules");
+ SetLastError (ERROR_NOT_SUPPORTED);
+ return NULL;
+}
+
+const gchar *
+g_module_error (void)
+{
+ gchar *ret = NULL;
+ TCHAR buf [1024];
+ DWORD code = GetLastError ();
+
+ if (!FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL,
+ code, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), buf, G_N_ELEMENTS (buf) - 1, NULL) )
+ buf[0] = TEXT('\0');
+
+ ret = u16to8 (buf);
+ return ret;
+}
+
+#else /* G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT) */
+
+#ifdef _MSC_VER
+// Quiet Visual Studio linker warning, LNK4221, in cases when this source file intentional ends up empty.
+void __mono_win32_gmodule_win32_uwp_quiet_lnk4221(void) {}
+#endif
+#endif /* G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT) */
--- /dev/null
+/*
+ * gmodule.c: dl* functions, glib style
+ *
+ * Author:
+ * Gonzalo Paniagua Javier (gonzalo@novell.com)
+ * Jonathan Chambers (joncham@gmail.com)
+ * Robert Jordan (robertj@gmx.net)
+ *
+ * (C) 2006 Novell, Inc.
+ * (C) 2006 Jonathan Chambers
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#include <config.h>
+#include <glib.h>
+#include <windows.h>
+#include <psapi.h>
+#include <gmodule-win32-internals.h>
+
+#define LIBSUFFIX ".dll"
+#define LIBPREFIX ""
+
+struct _GModule {
+ HMODULE handle;
+ int main_module;
+};
+
+GModule *
+g_module_open (const gchar *file, GModuleFlags flags)
+{
+ GModule *module;
+ module = g_malloc (sizeof (GModule));
+ if (module == NULL)
+ return NULL;
+
+ if (file != NULL) {
+ gunichar2 *file16;
+ file16 = u8to16(file);
+ module->main_module = FALSE;
+ module->handle = LoadLibraryW (file16);
+ g_free(file16);
+ if (!module->handle) {
+ g_free (module);
+ return NULL;
+ }
+
+ } else {
+ module->main_module = TRUE;
+ module->handle = GetModuleHandle (NULL);
+ }
+
+ return module;
+}
+
+#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
+gpointer
+w32_find_symbol (const gchar *symbol_name)
+{
+ HMODULE *modules;
+ DWORD buffer_size = sizeof (HMODULE) * 1024;
+ DWORD needed, i;
+
+ modules = (HMODULE *) g_malloc (buffer_size);
+
+ if (modules == NULL)
+ return NULL;
+
+ if (!EnumProcessModules (GetCurrentProcess (), modules,
+ buffer_size, &needed)) {
+ g_free (modules);
+ return NULL;
+ }
+
+ /* check whether the supplied buffer was too small, realloc, retry */
+ if (needed > buffer_size) {
+ g_free (modules);
+
+ buffer_size = needed;
+ modules = (HMODULE *) g_malloc (buffer_size);
+
+ if (modules == NULL)
+ return NULL;
+
+ if (!EnumProcessModules (GetCurrentProcess (), modules,
+ buffer_size, &needed)) {
+ g_free (modules);
+ return NULL;
+ }
+ }
+
+ for (i = 0; i < needed / sizeof (HANDLE); i++) {
+ gpointer proc = (gpointer)(intptr_t)GetProcAddress (modules [i], symbol_name);
+ if (proc != NULL) {
+ g_free (modules);
+ return proc;
+ }
+ }
+
+ g_free (modules);
+ return NULL;
+}
+#endif /* G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) */
+
+gboolean
+g_module_symbol (GModule *module, const gchar *symbol_name, gpointer *symbol)
+{
+ if (module == NULL || symbol_name == NULL || symbol == NULL)
+ return FALSE;
+
+ if (module->main_module) {
+ *symbol = (gpointer)(intptr_t)GetProcAddress (module->handle, symbol_name);
+ if (*symbol != NULL)
+ return TRUE;
+
+ *symbol = w32_find_symbol (symbol_name);
+ return *symbol != NULL;
+ } else {
+ *symbol = (gpointer)(intptr_t)GetProcAddress (module->handle, symbol_name);
+ return *symbol != NULL;
+ }
+}
+
+#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
+const gchar *
+g_module_error (void)
+{
+ gchar* ret = NULL;
+ TCHAR* buf = NULL;
+ DWORD code = GetLastError ();
+
+ /* FIXME: buf must not be NULL! */
+ FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER, NULL,
+ code, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), buf, 0, NULL);
+
+ ret = u16to8 (buf);
+ LocalFree(buf);
+
+ return ret;
+}
+#endif /* G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) */
+
+gboolean
+g_module_close (GModule *module)
+{
+ HMODULE handle;
+ int main_module;
+
+ if (module == NULL || module->handle == NULL)
+ return FALSE;
+
+ handle = module->handle;
+ main_module = module->main_module;
+ module->handle = NULL;
+ g_free (module);
+ return (main_module ? 1 : (0 == FreeLibrary (handle)));
+}
+
+gchar *
+g_module_build_path (const gchar *directory, const gchar *module_name)
+{
+ char *lib_prefix = "";
+
+ if (module_name == NULL)
+ return NULL;
+
+ if (strncmp (module_name, "lib", 3) != 0)
+ lib_prefix = LIBPREFIX;
+
+ if (directory && *directory){
+
+ return g_strdup_printf ("%s/%s%s" LIBSUFFIX, directory, lib_prefix, module_name);
+ }
+ return g_strdup_printf ("%s%s" LIBSUFFIX, lib_prefix, module_name);
+}
--- /dev/null
+#ifndef __GLIB_GMODULE_H
+#define __GLIB_GMODULE_H
+
+#include <glib.h>
+
+#define G_MODULE_IMPORT extern
+#ifdef G_OS_WIN32
+#define G_MODULE_EXPORT __declspec(dllexport)
+#else
+#define G_MODULE_EXPORT
+#endif
+
+G_BEGIN_DECLS
+
+/*
+ * Modules
+ */
+typedef enum {
+ G_MODULE_BIND_LAZY = 0x01,
+ G_MODULE_BIND_LOCAL = 0x02,
+ G_MODULE_BIND_MASK = 0x03
+} GModuleFlags;
+typedef struct _GModule GModule;
+
+GModule *g_module_open (const gchar *file, GModuleFlags flags);
+gboolean g_module_symbol (GModule *module, const gchar *symbol_name,
+ gpointer *symbol);
+const gchar *g_module_error (void);
+gboolean g_module_close (GModule *module);
+gchar * g_module_build_path (const gchar *directory, const gchar *module_name);
+
+extern char *gmodule_libprefix;
+extern char *gmodule_libsuffix;
+
+G_END_DECLS
+
+#endif
--- /dev/null
+/*
+ * Output and debugging functions
+ *
+ * Author:
+ * Miguel de Icaza (miguel@novell.com)
+ *
+ * (C) 2006 Novell, Inc.
+ * Copyright 2011 Xamarin Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <glib.h>
+
+/* The current fatal levels, error is always fatal */
+static GLogLevelFlags fatal = G_LOG_LEVEL_ERROR;
+static GLogFunc default_log_func;
+static gpointer default_log_func_user_data;
+static GPrintFunc stdout_handler, stderr_handler;
+
+static void default_stdout_handler (const gchar *string);
+static void default_stderr_handler (const gchar *string);
+
+void
+g_print (const gchar *format, ...)
+{
+ char *msg;
+ va_list args;
+
+ va_start (args, format);
+ if (g_vasprintf (&msg, format, args) < 0) {
+ va_end (args);
+ return;
+ }
+ va_end (args);
+
+ if (!stdout_handler)
+ stdout_handler = default_stdout_handler;
+
+ stdout_handler (msg);
+ g_free (msg);
+}
+
+void
+g_printerr (const gchar *format, ...)
+{
+ char *msg;
+ va_list args;
+
+ va_start (args, format);
+ if (g_vasprintf (&msg, format, args) < 0) {
+ va_end (args);
+ return;
+ }
+ va_end (args);
+
+ if (!stderr_handler)
+ stderr_handler = default_stderr_handler;
+
+ stderr_handler (msg);
+ g_free (msg);
+}
+
+GLogLevelFlags
+g_log_set_always_fatal (GLogLevelFlags fatal_mask)
+{
+ GLogLevelFlags old_fatal = fatal;
+
+ fatal |= fatal_mask;
+
+ return old_fatal;
+}
+
+GLogLevelFlags
+g_log_set_fatal_mask (const gchar *log_domain, GLogLevelFlags fatal_mask)
+{
+ /*
+ * Mono does not use a G_LOG_DOMAIN currently, so we just assume things are fatal
+ * if we decide to set G_LOG_DOMAIN (we probably should) we should implement
+ * this.
+ */
+ return fatal_mask;
+}
+
+void
+g_logv (const gchar *log_domain, GLogLevelFlags log_level, const gchar *format, va_list args)
+{
+ char *msg;
+
+ if (!default_log_func)
+ default_log_func = g_log_default_handler;
+
+ if (g_vasprintf (&msg, format, args) < 0)
+ return;
+
+ default_log_func (log_domain, log_level, msg, default_log_func_user_data);
+ g_free (msg);
+}
+
+void
+g_log (const gchar *log_domain, GLogLevelFlags log_level, const gchar *format, ...)
+{
+ va_list args;
+
+ va_start (args, format);
+ g_logv (log_domain, log_level, format, args);
+ va_end (args);
+}
+
+void
+g_assertion_message (const gchar *format, ...)
+{
+ va_list args;
+
+ va_start (args, format);
+ g_logv (G_LOG_DOMAIN, G_LOG_LEVEL_ERROR, format, args);
+ va_end (args);
+ exit (0);
+}
+
+#if TARGET_ANDROID
+#include <android/log.h>
+
+static android_LogPriority
+to_android_priority (GLogLevelFlags log_level)
+{
+ switch (log_level & G_LOG_LEVEL_MASK)
+ {
+ case G_LOG_LEVEL_ERROR: return ANDROID_LOG_FATAL;
+ case G_LOG_LEVEL_CRITICAL: return ANDROID_LOG_ERROR;
+ case G_LOG_LEVEL_WARNING: return ANDROID_LOG_WARN;
+ case G_LOG_LEVEL_MESSAGE: return ANDROID_LOG_INFO;
+ case G_LOG_LEVEL_INFO: return ANDROID_LOG_DEBUG;
+ case G_LOG_LEVEL_DEBUG: return ANDROID_LOG_VERBOSE;
+ }
+ return ANDROID_LOG_UNKNOWN;
+}
+
+void
+g_log_default_handler (const gchar *log_domain, GLogLevelFlags log_level, const gchar *message, gpointer unused_data)
+{
+ __android_log_write (to_android_priority (log_level), log_domain, message);
+ if (log_level & fatal)
+ abort ();
+}
+
+static void
+default_stdout_handler (const gchar *message)
+{
+ /* TODO: provide a proper app name */
+ __android_log_write (ANDROID_LOG_ERROR, "mono", message);
+}
+
+static void
+default_stderr_handler (const gchar *message)
+{
+ /* TODO: provide a proper app name */
+ __android_log_write (ANDROID_LOG_ERROR, "mono", message);
+}
+
+
+#elif defined(HOST_IOS)
+#include <asl.h>
+
+static int
+to_asl_priority (GLogLevelFlags log_level)
+{
+ switch (log_level & G_LOG_LEVEL_MASK)
+ {
+ case G_LOG_LEVEL_ERROR: return ASL_LEVEL_CRIT;
+ case G_LOG_LEVEL_CRITICAL: return ASL_LEVEL_ERR;
+ case G_LOG_LEVEL_WARNING: return ASL_LEVEL_WARNING;
+ case G_LOG_LEVEL_MESSAGE: return ASL_LEVEL_NOTICE;
+ case G_LOG_LEVEL_INFO: return ASL_LEVEL_INFO;
+ case G_LOG_LEVEL_DEBUG: return ASL_LEVEL_DEBUG;
+ }
+ return ASL_LEVEL_ERR;
+}
+
+void
+g_log_default_handler (const gchar *log_domain, GLogLevelFlags log_level, const gchar *message, gpointer unused_data)
+{
+ asl_log (NULL, NULL, to_asl_priority (log_level), "%s", message);
+ if (log_level & fatal)
+ abort ();
+}
+
+static void
+default_stdout_handler (const gchar *message)
+{
+ asl_log (NULL, NULL, ASL_LEVEL_WARNING, "%s", message);
+}
+
+static void
+default_stderr_handler (const gchar *message)
+{
+ asl_log (NULL, NULL, ASL_LEVEL_WARNING, "%s", message);
+}
+
+#else
+
+void
+g_log_default_handler (const gchar *log_domain, GLogLevelFlags log_level, const gchar *message, gpointer unused_data)
+{
+ FILE *target = stdout;
+
+ fprintf (target, "%s%s%s\n",
+ log_domain != NULL ? log_domain : "",
+ log_domain != NULL ? ": " : "",
+ message);
+
+ if (log_level & fatal) {
+ fflush (stdout);
+ fflush (stderr);
+ abort ();
+ }
+}
+
+static void
+default_stdout_handler (const gchar *string)
+{
+ fprintf (stdout, "%s", string);
+}
+
+static void
+default_stderr_handler (const gchar *string)
+{
+ fprintf (stderr, "%s", string);
+}
+
+#endif
+
+GLogFunc
+g_log_set_default_handler (GLogFunc log_func, gpointer user_data)
+{
+ GLogFunc old = default_log_func;
+ default_log_func = log_func;
+ default_log_func_user_data = user_data;
+ return old;
+}
+
+GPrintFunc
+g_set_print_handler (GPrintFunc func)
+{
+ GPrintFunc old = stdout_handler;
+ stdout_handler = func;
+ return old;
+}
+
+GPrintFunc
+g_set_printerr_handler (GPrintFunc func)
+{
+ GPrintFunc old = stderr_handler;
+ stderr_handler = func;
+ return old;
+}
+
--- /dev/null
+/*
+ * Portable Utility Functions
+ *
+ * Author:
+ * Miguel de Icaza (miguel@novell.com)
+ *
+ * (C) 2006 Novell, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#include <config.h>
+#include <stdio.h>
+#include <glib.h>
+#include <errno.h>
+#include <sys/stat.h>
+
+#ifdef G_OS_WIN32
+#include <direct.h>
+#endif
+
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+gchar *
+g_build_path (const gchar *separator, const gchar *first_element, ...)
+{
+ const char *elem, *next, *endptr;
+ gboolean trimmed;
+ GString *path;
+ va_list args;
+ size_t slen;
+
+ g_return_val_if_fail (separator != NULL, NULL);
+
+ path = g_string_sized_new (48);
+ slen = strlen (separator);
+
+ va_start (args, first_element);
+ for (elem = first_element; elem != NULL; elem = next) {
+ /* trim any trailing separators from @elem */
+ endptr = elem + strlen (elem);
+ trimmed = FALSE;
+
+ while (endptr >= elem + slen) {
+ if (strncmp (endptr - slen, separator, slen) != 0)
+ break;
+
+ endptr -= slen;
+ trimmed = TRUE;
+ }
+
+ /* append elem, not including any trailing separators */
+ if (endptr > elem)
+ g_string_append_len (path, elem, endptr - elem);
+
+ /* get the next element */
+ do {
+ if (!(next = va_arg (args, char *)))
+ break;
+
+ /* remove leading separators */
+ while (!strncmp (next, separator, slen))
+ next += slen;
+ } while (*next == '\0');
+
+ if (next || trimmed)
+ g_string_append_len (path, separator, slen);
+ }
+ va_end (args);
+
+ return g_string_free (path, FALSE);
+}
+
+static gchar*
+strrchr_seperator (const gchar* filename)
+{
+#ifdef G_OS_WIN32
+ char *p2;
+#endif
+ char *p;
+
+ p = strrchr (filename, G_DIR_SEPARATOR);
+#ifdef G_OS_WIN32
+ p2 = strrchr (filename, '/');
+ if (p2 > p)
+ p = p2;
+#endif
+
+ return p;
+}
+
+gchar *
+g_path_get_dirname (const gchar *filename)
+{
+ char *p, *r;
+ size_t count;
+ g_return_val_if_fail (filename != NULL, NULL);
+
+ p = strrchr_seperator (filename);
+ if (p == NULL)
+ return g_strdup (".");
+ if (p == filename)
+ return g_strdup ("/");
+ count = p - filename;
+ r = g_malloc (count + 1);
+ strncpy (r, filename, count);
+ r [count] = 0;
+
+ return r;
+}
+
+gchar *
+g_path_get_basename (const char *filename)
+{
+ char *r;
+ g_return_val_if_fail (filename != NULL, NULL);
+
+ /* Empty filename -> . */
+ if (!*filename)
+ return g_strdup (".");
+
+ /* No separator -> filename */
+ r = strrchr_seperator (filename);
+ if (r == NULL)
+ return g_strdup (filename);
+
+ /* Trailing slash, remove component */
+ if (r [1] == 0){
+ char *copy = g_strdup (filename);
+ copy [r-filename] = 0;
+ r = strrchr_seperator (copy);
+
+ if (r == NULL){
+ g_free (copy);
+ return g_strdup ("/");
+ }
+ r = g_strdup (&r[1]);
+ g_free (copy);
+ return r;
+ }
+
+ return g_strdup (&r[1]);
+}
+
+#ifndef HAVE_STRTOK_R
+// This is from BSD's strtok_r
+
+char *
+strtok_r(char *s, const char *delim, char **last)
+{
+ char *spanp;
+ int c, sc;
+ char *tok;
+
+ if (s == NULL && (s = *last) == NULL)
+ return NULL;
+
+ /*
+ * Skip (span) leading delimiters (s += strspn(s, delim), sort of).
+ */
+cont:
+ c = *s++;
+ for (spanp = (char *)delim; (sc = *spanp++) != 0; ){
+ if (c == sc)
+ goto cont;
+ }
+
+ if (c == 0){ /* no non-delimiter characters */
+ *last = NULL;
+ return NULL;
+ }
+ tok = s - 1;
+
+ /*
+ * Scan token (scan for delimiters: s += strcspn(s, delim), sort of).
+ * Note that delim must have one NUL; we stop if we see that, too.
+ */
+ for (;;){
+ c = *s++;
+ spanp = (char *)delim;
+ do {
+ if ((sc = *spanp++) == c) {
+ if (c == 0)
+ s = NULL;
+ else {
+ char *w = s - 1;
+ *w = '\0';
+ }
+ *last = s;
+ return tok;
+ }
+ }
+ while (sc != 0);
+ }
+ /* NOTREACHED */
+}
+#endif
+
+gchar *
+g_find_program_in_path (const gchar *program)
+{
+ char *p;
+ char *x, *l;
+ gchar *curdir = NULL;
+ char *save = NULL;
+#ifdef G_OS_WIN32
+ char *program_exe;
+ char *suffix_list[5] = {".exe",".cmd",".bat",".com",NULL};
+ int listx;
+ gboolean hasSuffix;
+#endif
+
+ g_return_val_if_fail (program != NULL, NULL);
+ x = p = g_strdup (g_getenv ("PATH"));
+
+ if (x == NULL || *x == '\0') {
+ curdir = g_get_current_dir ();
+ x = curdir;
+ }
+
+#ifdef G_OS_WIN32
+ /* see if program already has a suffix */
+ listx = 0;
+ hasSuffix = FALSE;
+ while (!hasSuffix && suffix_list[listx]) {
+ hasSuffix = g_str_has_suffix(program,suffix_list[listx++]);
+ }
+#endif
+
+ while ((l = strtok_r (x, G_SEARCHPATH_SEPARATOR_S, &save)) != NULL){
+ char *probe_path;
+
+ x = NULL;
+ probe_path = g_build_path (G_DIR_SEPARATOR_S, l, program, NULL);
+ if (access (probe_path, X_OK) == 0){ /* FIXME: on windows this is just a read permissions test */
+ g_free (curdir);
+ g_free (p);
+ return probe_path;
+ }
+ g_free (probe_path);
+
+#ifdef G_OS_WIN32
+ /* check for program with a suffix attached */
+ if (!hasSuffix) {
+ listx = 0;
+ while (suffix_list[listx]) {
+ program_exe = g_strjoin(NULL,program,suffix_list[listx],NULL);
+ probe_path = g_build_path (G_DIR_SEPARATOR_S, l, program_exe, NULL);
+ if (access (probe_path, X_OK) == 0){ /* FIXME: on windows this is just a read permissions test */
+ g_free (curdir);
+ g_free (p);
+ g_free (program_exe);
+ return probe_path;
+ }
+ listx++;
+ g_free (probe_path);
+ g_free (program_exe);
+ }
+ }
+#endif
+ }
+ g_free (curdir);
+ g_free (p);
+ return NULL;
+}
+
+static char *name;
+
+void
+g_set_prgname (const gchar *prgname)
+{
+ name = g_strdup (prgname);
+}
+
+gchar *
+g_get_prgname (void)
+{
+ return name;
+}
+
+gboolean
+g_ensure_directory_exists (const gchar *filename)
+{
+#ifdef G_OS_WIN32
+ gchar *dir_utf8 = g_path_get_dirname (filename);
+ gunichar2 *p;
+ gunichar2 *dir_utf16 = NULL;
+ int retval;
+
+ if (!dir_utf8 || !dir_utf8 [0])
+ return FALSE;
+
+ dir_utf16 = g_utf8_to_utf16 (dir_utf8, strlen (dir_utf8), NULL, NULL, NULL);
+ g_free (dir_utf8);
+
+ if (!dir_utf16)
+ return FALSE;
+
+ p = dir_utf16;
+
+ /* make life easy and only use one directory seperator */
+ while (*p != '\0')
+ {
+ if (*p == '/')
+ *p = '\\';
+ p++;
+ }
+
+ p = dir_utf16;
+
+ /* get past C:\ )*/
+ while (*p++ != '\\')
+ {
+ }
+
+ while (1) {
+ gboolean bRet = FALSE;
+ p = wcschr (p, '\\');
+ if (p)
+ *p = '\0';
+ retval = _wmkdir (dir_utf16);
+ if (retval != 0 && errno != EEXIST) {
+ g_free (dir_utf16);
+ return FALSE;
+ }
+ if (!p)
+ break;
+ *p++ = '\\';
+ }
+
+ g_free (dir_utf16);
+ return TRUE;
+#else
+ char *p;
+ gchar *dir = g_path_get_dirname (filename);
+ int retval;
+ struct stat sbuf;
+
+ if (!dir || !dir [0]) {
+ g_free (dir);
+ return FALSE;
+ }
+
+ if (stat (dir, &sbuf) == 0 && S_ISDIR (sbuf.st_mode)) {
+ g_free (dir);
+ return TRUE;
+ }
+
+ p = dir;
+ while (*p == '/')
+ p++;
+
+ while (1) {
+ p = strchr (p, '/');
+ if (p)
+ *p = '\0';
+ retval = mkdir (dir, 0777);
+ if (retval != 0 && errno != EEXIST) {
+ g_free (dir);
+ return FALSE;
+ }
+ if (!p)
+ break;
+ *p++ = '/';
+ }
+
+ g_free (dir);
+ return TRUE;
+#endif
+}
+
--- /dev/null
+/*
+ * Simple pattern matching
+ *
+ * Author:
+ * Gonzalo Paniagua Javier (gonzalo@novell.com
+ *
+ * (C) 2006 Novell, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#include <glib.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#ifndef _MSC_VER
+#include <unistd.h>
+#endif
+
+typedef enum {
+ MATCH_LITERAL,
+ MATCH_ANYCHAR,
+ MATCH_ANYTHING,
+ MATCH_ANYTHING_END,
+ MATCH_INVALID = -1
+} MatchType;
+
+typedef struct {
+ MatchType type;
+ gchar *str;
+} PData;
+
+struct _GPatternSpec {
+ GSList *pattern;
+};
+
+static GSList *
+compile_pattern (const gchar *pattern)
+{
+ GSList *list;
+ size_t i, len;
+ PData *data;
+ gchar c;
+ MatchType last = MATCH_INVALID;
+ GString *str;
+ gboolean free_str;
+
+ if (pattern == NULL)
+ return NULL;
+
+ data = NULL;
+ list = NULL;
+ free_str = TRUE;
+ str = g_string_new ("");
+ for (i = 0, len = strlen (pattern); i < len; i++) {
+ c = pattern [i];
+ if (c == '*' || c == '?') {
+ if (str->len > 0) {
+ data = g_new0 (PData, 1);
+ data->type = MATCH_LITERAL;
+ data->str = g_string_free (str, FALSE);
+ list = g_slist_append (list, data);
+ str = g_string_new ("");
+ }
+
+ if (last == MATCH_ANYTHING && c == '*')
+ continue;
+
+ data = g_new0 (PData, 1);
+ data->type = (c == '*') ? MATCH_ANYTHING : MATCH_ANYCHAR;
+ list = g_slist_append (list, data);
+ last = data->type;
+ } else {
+ g_string_append_c (str, c);
+ last = MATCH_LITERAL;
+ }
+ }
+
+ if (last == MATCH_ANYTHING && str->len == 0) {
+ data->type = MATCH_ANYTHING_END;
+ free_str = TRUE;
+ } else if (str->len > 0) {
+ data = g_new0 (PData, 1);
+ data->type = MATCH_LITERAL;
+ data->str = str->str;
+ free_str = FALSE;
+ list = g_slist_append (list, data);
+ }
+ g_string_free (str, free_str);
+ return list;
+}
+
+#ifdef DEBUG_PATTERN
+static void
+print_pattern (gpointer data, gpointer user_data)
+{
+ PData *d = (PData *) data;
+
+ printf ("Type: %s", d->type == MATCH_LITERAL ? "literal" : d->type == MATCH_ANYCHAR ? "any char" : "anything");
+ if (d->type == MATCH_LITERAL)
+ printf (" String: %s", d->str);
+ printf ("\n");
+}
+#endif
+
+GPatternSpec *
+g_pattern_spec_new (const gchar *pattern)
+{
+ GPatternSpec *spec;
+
+ g_return_val_if_fail (pattern != NULL, NULL);
+ spec = g_new0 (GPatternSpec, 1);
+ if (pattern) {
+ spec->pattern = compile_pattern (pattern);
+#ifdef DEBUG_PATTERN
+ g_slist_foreach (spec->pattern, print_pattern, NULL);
+ printf ("\n");
+#endif
+ }
+ return spec;
+}
+
+static void
+free_pdata (gpointer data, gpointer user_data)
+{
+ PData *d = (PData *) data;
+
+ if (d->str)
+ g_free (d->str);
+ g_free (d);
+}
+
+void
+g_pattern_spec_free (GPatternSpec *pspec)
+{
+ if (pspec) {
+ g_slist_foreach (pspec->pattern, free_pdata, NULL);
+ g_slist_free (pspec->pattern);
+ pspec->pattern = NULL;
+ }
+ g_free (pspec);
+}
+
+static gboolean
+match_string (GSList *list, const gchar *str, size_t idx, size_t max)
+{
+ size_t len;
+
+ while (list && idx < max) {
+ PData *data = (PData *) list->data;
+
+ if (data->type == MATCH_ANYTHING_END)
+ return TRUE;
+
+ if (data->type == MATCH_LITERAL) {
+ len = strlen (data->str);
+ if (strncmp (&str [idx], data->str, len) != 0)
+ return FALSE;
+ idx += len;
+ list = list->next;
+ if (list) {
+ /*
+ * When recursing, we need this to avoid returning FALSE
+ * because 'list' will not be NULL
+ */
+ data = (PData *) list->data;
+ if (data->type == MATCH_ANYTHING_END)
+ return TRUE;
+ }
+ } else if (data->type == MATCH_ANYCHAR) {
+ idx++;
+ list = list->next;
+ } else if (data->type == MATCH_ANYTHING) {
+ while (idx < max) {
+ if (match_string (list->next, str, idx++, max))
+ return TRUE;
+ }
+ return FALSE;
+ } else {
+ g_assert_not_reached ();
+ }
+ }
+
+ return (list == NULL && idx >= max);
+}
+gboolean
+g_pattern_match_string (GPatternSpec *pspec, const gchar *string)
+{
+ g_return_val_if_fail (pspec != NULL, FALSE);
+ g_return_val_if_fail (string != NULL, FALSE);
+
+ if (pspec->pattern == NULL)
+ return FALSE;
+ return match_string (pspec->pattern, string, 0, strlen (string));
+}
+
+
--- /dev/null
+/*
+ * Pointer Array
+ *
+ * Author:
+ * Aaron Bockover (abockover@novell.com)
+ * Gonzalo Paniagua Javier (gonzalo@novell.com)
+ * Jeffrey Stedfast (fejj@novell.com)
+ *
+ * (C) 2006,2011 Novell, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#include <stdlib.h>
+#include <glib.h>
+
+typedef struct _GPtrArrayPriv {
+ gpointer *pdata;
+ guint len;
+ guint size;
+} GPtrArrayPriv;
+
+static void
+g_ptr_array_grow(GPtrArrayPriv *array, guint length)
+{
+ guint new_length = array->len + length;
+
+ g_return_if_fail(array != NULL);
+
+ if(new_length <= array->size) {
+ return;
+ }
+
+ array->size = 1;
+
+ while(array->size < new_length) {
+ array->size <<= 1;
+ }
+
+ array->size = MAX(array->size, 16);
+ array->pdata = g_realloc(array->pdata, array->size * sizeof(gpointer));
+}
+
+GPtrArray *
+g_ptr_array_new(void)
+{
+ return g_ptr_array_sized_new(0);
+}
+
+GPtrArray *
+g_ptr_array_sized_new(guint reserved_size)
+{
+ GPtrArrayPriv *array = g_new0(GPtrArrayPriv, 1);
+
+ array->pdata = NULL;
+ array->len = 0;
+ array->size = 0;
+
+ if(reserved_size > 0) {
+ g_ptr_array_grow(array, reserved_size);
+ }
+
+ return (GPtrArray *)array;
+}
+
+gpointer *
+g_ptr_array_free(GPtrArray *array, gboolean free_seg)
+{
+ gpointer *data = NULL;
+
+ g_return_val_if_fail(array != NULL, NULL);
+
+ if(free_seg) {
+ g_free(array->pdata);
+ } else {
+ data = array->pdata;
+ }
+
+ g_free(array);
+
+ return data;
+}
+
+void
+g_ptr_array_set_size(GPtrArray *array, gint length)
+{
+ g_return_if_fail(array != NULL);
+
+ if((size_t)length > array->len) {
+ g_ptr_array_grow((GPtrArrayPriv *)array, length);
+ memset(array->pdata + array->len, 0, (length - array->len)
+ * sizeof(gpointer));
+ }
+
+ array->len = length;
+}
+
+void
+g_ptr_array_add(GPtrArray *array, gpointer data)
+{
+ g_return_if_fail(array != NULL);
+ g_ptr_array_grow((GPtrArrayPriv *)array, 1);
+ array->pdata[array->len++] = data;
+}
+
+gpointer
+g_ptr_array_remove_index(GPtrArray *array, guint index)
+{
+ gpointer removed_node;
+
+ g_return_val_if_fail(array != NULL, NULL);
+ g_return_val_if_fail(index < array->len, NULL);
+
+ removed_node = array->pdata[index];
+
+ if(index != array->len - 1) {
+ g_memmove(array->pdata + index, array->pdata + index + 1,
+ (array->len - index - 1) * sizeof(gpointer));
+ }
+
+ array->len--;
+ array->pdata[array->len] = NULL;
+
+ return removed_node;
+}
+
+gpointer
+g_ptr_array_remove_index_fast(GPtrArray *array, guint index)
+{
+ gpointer removed_node;
+
+ g_return_val_if_fail(array != NULL, NULL);
+ g_return_val_if_fail(index < array->len, NULL);
+
+ removed_node = array->pdata[index];
+
+ if(index != array->len - 1) {
+ g_memmove(array->pdata + index, array->pdata + array->len - 1,
+ sizeof(gpointer));
+ }
+
+ array->len--;
+ array->pdata[array->len] = NULL;
+
+ return removed_node;
+}
+
+gboolean
+g_ptr_array_remove(GPtrArray *array, gpointer data)
+{
+ guint i;
+
+ g_return_val_if_fail(array != NULL, FALSE);
+
+ for(i = 0; i < array->len; i++) {
+ if(array->pdata[i] == data) {
+ g_ptr_array_remove_index(array, i);
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
+gboolean
+g_ptr_array_remove_fast(GPtrArray *array, gpointer data)
+{
+ guint i;
+
+ g_return_val_if_fail(array != NULL, FALSE);
+
+ for(i = 0; i < array->len; i++) {
+ if(array->pdata[i] == data) {
+ array->len--;
+ if (array->len > 0)
+ array->pdata [i] = array->pdata [array->len];
+ else
+ array->pdata [i] = NULL;
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
+void
+g_ptr_array_foreach(GPtrArray *array, GFunc func, gpointer user_data)
+{
+ guint i;
+
+ for(i = 0; i < array->len; i++) {
+ func(g_ptr_array_index(array, i), user_data);
+ }
+}
+
+void
+g_ptr_array_sort(GPtrArray *array, GCompareFunc compare)
+{
+ g_return_if_fail(array != NULL);
+ qsort(array->pdata, array->len, sizeof(gpointer), compare);
+}
+
+void
+g_ptr_array_sort_with_data (GPtrArray *array, GCompareDataFunc compare, gpointer user_data)
+{
+ g_return_if_fail (array != NULL);
+
+ g_qsort_with_data (array->pdata, array->len, sizeof (gpointer), compare, user_data);
+}
+
--- /dev/null
+/*
+ * QuickSort
+ *
+ * Author: Jeffrey Stedfast <fejj@novell.com>
+ *
+ * (C) 2011 Novell, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#include <stdlib.h>
+#include <glib.h>
+
+/* Any segment <= this threshold will be sorted using insertion
+ * sort. OpenBSD seems to use a value of 7 so we'll go with that for
+ * now... */
+#define MAX_THRESHOLD 7
+
+#define STACK_SIZE (8 * sizeof (size_t))
+
+typedef struct _QSortStack {
+ char *array;
+ size_t count;
+} QSortStack;
+
+#define QSORT_PUSH(sp, a, c) (sp->array = a, sp->count = c, sp++)
+#define QSORT_POP(sp, a, c) (sp--, a = sp->array, c = sp->count)
+
+#define SWAPTYPE(TYPE, a, b) { \
+ long __n = size / sizeof (TYPE); \
+ register TYPE *__a = (TYPE *) (a); \
+ register TYPE *__b = (TYPE *) (b); \
+ register TYPE t; \
+ \
+ do { \
+ t = *__a; \
+ *__a++ = *__b; \
+ *__b++ = t; \
+ } while (--__n > 0); \
+}
+
+#define SWAPBYTE(a, b) SWAPTYPE(char, (a), (b))
+#define SWAPLONG(a, b) SWAPTYPE(long, (a), (b))
+#define SWAP(a, b) if (swaplong) SWAPLONG((a), (b)) else SWAPBYTE((a), (b))
+
+/* check if we can swap by longs rather than bytes by making sure that
+ * memory is properly aligned and that the element size is a multiple
+ * of sizeof (long) */
+#define SWAP_INIT() swaplong = (((char *) base) - ((char *) 0)) % sizeof (long) == 0 && (size % sizeof (long)) == 0
+
+void
+g_qsort_with_data (gpointer base, size_t nmemb, size_t size, GCompareDataFunc compare, gpointer user_data)
+{
+ QSortStack stack[STACK_SIZE], *sp;
+ register char *i, *k, *mid;
+ size_t n, n1, n2;
+ char *lo, *hi;
+ int swaplong;
+
+ if (nmemb <= 1)
+ return;
+
+ SWAP_INIT ();
+
+ /* initialize our stack */
+ sp = stack;
+ QSORT_PUSH (sp, base, nmemb);
+
+ do {
+ QSORT_POP (sp, lo, n);
+
+ hi = lo + (n - 1) * size;
+
+ if (n < MAX_THRESHOLD) {
+ /* switch to insertion sort */
+ for (i = lo + size; i <= hi; i += size)
+ for (k = i; k > lo && compare (k - size, k, user_data) > 0; k -= size)
+ SWAP (k - size, k);
+
+ continue;
+ }
+
+ /* calculate the middle element */
+ mid = lo + (n / 2) * size;
+
+ /* once we re-order the lo, mid, and hi elements to be in
+ * ascending order, we'll use mid as our pivot. */
+ if (compare (mid, lo, user_data) < 0) {
+ SWAP (mid, lo);
+ }
+
+ if (compare (hi, mid, user_data) < 0) {
+ SWAP (mid, hi);
+ if (compare (mid, lo, user_data) < 0) {
+ SWAP (mid, lo);
+ }
+ }
+
+ /* since we've already guaranteed that lo <= mid and mid <= hi,
+ * we can skip comparing them again */
+ i = lo + size;
+ k = hi - size;
+
+ do {
+ /* find the first element with a value > pivot value */
+ while (i < k && compare (i, mid, user_data) <= 0)
+ i += size;
+
+ /* find the last element with a value <= pivot value */
+ while (k >= i && compare (mid, k, user_data) < 0)
+ k -= size;
+
+ if (k <= i)
+ break;
+
+ SWAP (i, k);
+
+ /* make sure we keep track of our pivot element */
+ if (mid == i) {
+ mid = k;
+ } else if (mid == k) {
+ mid = i;
+ }
+
+ i += size;
+ k -= size;
+ } while (1);
+
+ if (k != mid) {
+ /* swap the pivot with the last element in the first partition */
+ SWAP (mid, k);
+ }
+
+ /* calculate segment sizes */
+ n2 = (hi - k) / size;
+ n1 = (k - lo) / size;
+
+ /* push our partitions onto the stack, largest first
+ * (to make sure we don't run out of stack space) */
+ if (n2 > n1) {
+ if (n2 > 1) QSORT_PUSH (sp, k + size, n2);
+ if (n1 > 1) QSORT_PUSH (sp, lo, n1);
+ } else {
+ if (n1 > 1) QSORT_PUSH (sp, lo, n1);
+ if (n2 > 1) QSORT_PUSH (sp, k + size, n2);
+ }
+ } while (sp > stack);
+}
--- /dev/null
+/*
+ * gqueue.c: Queue
+ *
+ * Author:
+ * Duncan Mak (duncan@novell.com)
+ * Gonzalo Paniagua Javier (gonzalo@novell.com)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Copyright (c) 2006-2009 Novell, Inc.
+ *
+ */
+
+#include <stdio.h>
+#include <glib.h>
+
+gpointer
+g_queue_pop_head (GQueue *queue)
+{
+ gpointer result;
+ GList *old_head;
+
+ if (!queue || queue->length == 0)
+ return NULL;
+
+ result = queue->head->data;
+ old_head = queue->head;
+ queue->head = old_head->next;
+ g_list_free_1 (old_head);
+
+ if (--queue->length)
+ queue->head->prev = NULL;
+ else
+ queue->tail = NULL;
+
+ return result;
+}
+
+gboolean
+g_queue_is_empty (GQueue *queue)
+{
+ if (!queue)
+ return TRUE;
+
+ return queue->length == 0;
+}
+
+void
+g_queue_push_head (GQueue *queue, gpointer head)
+{
+ if (!queue)
+ return;
+
+ queue->head = g_list_prepend (queue->head, head);
+
+ if (!queue->tail)
+ queue->tail = queue->head;
+
+ queue->length ++;
+}
+
+void
+g_queue_push_tail (GQueue *queue, gpointer data)
+{
+ if (!queue)
+ return;
+
+ queue->tail = g_list_append (queue->tail, data);
+ if (queue->head == NULL)
+ queue->head = queue->tail;
+ else
+ queue->tail = queue->tail->next;
+ queue->length++;
+}
+
+GQueue *
+g_queue_new (void)
+{
+ return g_new0 (GQueue, 1);
+}
+
+void
+g_queue_free (GQueue *queue)
+{
+ if (!queue)
+ return;
+
+ g_list_free (queue->head);
+ g_free (queue);
+}
+
+void
+g_queue_foreach (GQueue *queue, GFunc func, gpointer user_data)
+{
+ g_list_foreach (queue->head, func, user_data);
+}
--- /dev/null
+/*
+ * Shell utility functions.
+ *
+ * Author:
+ * Gonzalo Paniagua Javier (gonzalo@novell.com
+ *
+ * (C) 2006 Novell, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#include <stdio.h>
+#include <glib.h>
+
+static int
+split_cmdline (const gchar *cmdline, GPtrArray *array, GError **error)
+{
+ gchar *ptr;
+ gchar c;
+ gboolean escaped = FALSE, fresh = TRUE;
+ gchar quote_char = '\0';
+ GString *str;
+
+ str = g_string_new ("");
+ ptr = (gchar *) cmdline;
+ while ((c = *ptr++) != '\0') {
+ if (escaped) {
+ /*
+ * \CHAR is only special inside a double quote if CHAR is
+ * one of: $`"\ and newline
+ */
+ if (quote_char == '\"'){
+ if (!(c == '$' || c == '`' || c == '"' || c == '\\'))
+ g_string_append_c (str, '\\');
+ g_string_append_c (str, c);
+ } else {
+ if (!g_ascii_isspace (c))
+ g_string_append_c (str, c);
+ }
+ escaped = FALSE;
+ } else if (quote_char) {
+ if (c == quote_char) {
+ quote_char = '\0';
+ if (fresh && (g_ascii_isspace (*ptr) || *ptr == '\0')){
+ g_ptr_array_add (array, g_string_free (str, FALSE));
+ str = g_string_new ("");
+ }
+ } else if (c == '\\'){
+ escaped = TRUE;
+ } else
+ g_string_append_c (str, c);
+ } else if (g_ascii_isspace (c)) {
+ if (str->len > 0) {
+ g_ptr_array_add (array, g_string_free (str, FALSE));
+ str = g_string_new ("");
+ }
+ } else if (c == '\\') {
+ escaped = TRUE;
+ } else if (c == '\'' || c == '"') {
+ fresh = str->len == 0;
+ quote_char = c;
+ } else {
+ g_string_append_c (str, c);
+ }
+ }
+
+ if (escaped) {
+ if (error)
+ *error = g_error_new (G_LOG_DOMAIN, 0, "Unfinished escape.");
+ g_string_free (str, TRUE);
+ return -1;
+ }
+
+ if (quote_char) {
+ if (error)
+ *error = g_error_new (G_LOG_DOMAIN, 0, "Unfinished quote.");
+ g_string_free (str, TRUE);
+ return -1;
+ }
+
+ if (str->len > 0) {
+ g_ptr_array_add (array, g_string_free (str, FALSE));
+ } else {
+ g_string_free (str, TRUE);
+ }
+ g_ptr_array_add (array, NULL);
+ return 0;
+}
+
+gboolean
+g_shell_parse_argv (const gchar *command_line, gint *argcp, gchar ***argvp, GError **error)
+{
+ GPtrArray *array;
+ gint argc;
+ gchar **argv;
+
+ g_return_val_if_fail (command_line, FALSE);
+ g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
+
+ array = g_ptr_array_new();
+ if (split_cmdline (command_line, array, error)) {
+ g_ptr_array_add (array, NULL);
+ g_strfreev ((gchar **) array->pdata);
+ g_ptr_array_free (array, FALSE);
+ return FALSE;
+ }
+
+ argc = array->len;
+ argv = (gchar **) array->pdata;
+
+ if (argc == 1) {
+ g_strfreev (argv);
+ g_ptr_array_free (array, FALSE);
+ return FALSE;
+ }
+
+ if (argcp) {
+ *argcp = array->len - 1;
+ }
+
+ if (argvp) {
+ *argvp = argv;
+ } else {
+ g_strfreev (argv);
+ }
+
+ g_ptr_array_free (array, FALSE);
+ return TRUE;
+}
+
+gchar *
+g_shell_quote (const gchar *unquoted_string)
+{
+ GString *result = g_string_new ("'");
+ const gchar *p;
+
+ for (p = unquoted_string; *p; p++){
+ if (*p == '\'')
+ g_string_append (result, "'\\'");
+ g_string_append_c (result, *p);
+ }
+ g_string_append_c (result, '\'');
+ return g_string_free (result, FALSE);
+}
+
+gchar *
+g_shell_unquote (const gchar *quoted_string, GError **error)
+{
+ GString *result;
+ const char *p;
+ int do_unquote = 0;
+
+ if (quoted_string == NULL)
+ return NULL;
+
+ /* Quickly try to determine if we need to unquote or not */
+ for (p = quoted_string; *p; p++){
+ if (*p == '\'' || *p == '"' || *p == '\\'){
+ do_unquote = 1;
+ break;
+ }
+ }
+
+ if (!do_unquote)
+ return g_strdup (quoted_string);
+
+ /* We do need to unquote */
+ result = g_string_new ("");
+ for (p = quoted_string; *p; p++){
+
+ if (*p == '\''){
+ /* Process single quote, not even \ is processed by glib's version */
+ for (p++; *p; p++){
+ if (*p == '\'')
+ break;
+ g_string_append_c (result, *p);
+ }
+ if (!*p){
+ g_set_error (error, 0, 0, "Open quote");
+ return NULL;
+ }
+ } else if (*p == '"'){
+ /* Process double quote, allows some escaping */
+ for (p++; *p; p++){
+ if (*p == '"')
+ break;
+ if (*p == '\\'){
+ p++;
+ if (*p == 0){
+ g_set_error (error, 0, 0, "Open quote");
+ return NULL;
+ }
+ switch (*p){
+ case '$':
+ case '"':
+ case '\\':
+ case '`':
+ break;
+ default:
+ g_string_append_c (result, '\\');
+ break;
+ }
+ }
+ g_string_append_c (result, *p);
+ }
+ if (!*p){
+ g_set_error (error, 0, 0, "Open quote");
+ return NULL;
+ }
+ } else if (*p == '\\'){
+ char c = *(++p);
+ if (!(c == '$' || c == '"' || c == '\\' || c == '`' || c == '\'' || c == 0 ))
+ g_string_append_c (result, '\\');
+ if (c == 0)
+ break;
+ else
+ g_string_append_c (result, c);
+ } else
+ g_string_append_c (result, *p);
+ }
+ return g_string_free (result, FALSE);
+}
+
+#if JOINT_TEST
+/*
+ * This test is designed to be built with the 2 glib/eglib to compare
+ */
+
+char *args [] = {
+ "\\",
+ "\"Foo'bar\"",
+ "'foo'",
+ "'fo\'b'",
+ "'foo\"bar'",
+ "'foo' dingus bar",
+ "'foo' 'bar' 'baz'",
+ "\"foo\" 'bar' \"baz\"",
+ "\"f\\$\\\'",
+ "\"\\",
+ "\\\\",
+ "'\\\\'",
+ "\"f\\$\"\\\"\\\\", // /\\\"\\\\"
+ "'f\\$'\\\"\\\\",
+ "'f\\$\\\\'",
+ NULL
+};
+
+
+int
+main ()
+{
+ char **s = args;
+ int i;
+
+ while (*s){
+ char *r1 = g_shell_unquote (*s, NULL);
+ char *r2 = g2_shell_unquote (*s, NULL);
+ char *ok = r1 == r2 ? "ok" : (r1 != NULL && r2 != NULL && strcmp (r1, r2) == 0) ? "ok" : "fail";
+
+ printf ("%s [%s] -> [%s] - [%s]\n", ok, *s, r1, r2);
+ s++;
+ }
+ return;
+ char buffer [10];
+ buffer [0] = '\"';
+ buffer [1] = '\\';
+ buffer [3] = '\"';
+ buffer [4] = 0;
+
+ for (i = 32; i < 255; i++){
+ buffer [2] = i;
+ printf ("%d [%s] -> [%s]\n", i, buffer, g_shell_unquote (buffer, NULL));
+ }
+}
+#endif
--- /dev/null
+/*
+ * gslist.c: Singly-linked list implementation
+ *
+ * Authors:
+ * Duncan Mak (duncan@novell.com)
+ * Raja R Harinath (rharinath@novell.com)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * (C) 2006 Novell, Inc.
+ */
+
+#include <stdio.h>
+#include <glib.h>
+
+GSList*
+g_slist_alloc (void)
+{
+ return g_new0 (GSList, 1);
+}
+
+void
+g_slist_free_1 (GSList *list)
+{
+ g_free (list);
+}
+
+GSList*
+g_slist_append (GSList *list, gpointer data)
+{
+ return g_slist_concat (list, g_slist_prepend (NULL, data));
+}
+
+/* This is also a list node constructor. */
+GSList*
+g_slist_prepend (GSList *list, gpointer data)
+{
+ GSList *head = g_slist_alloc ();
+ head->data = data;
+ head->next = list;
+
+ return head;
+}
+
+/*
+ * Insert the given data in a new node after the current node.
+ * Return new node.
+ */
+static inline GSList *
+insert_after (GSList *list, gpointer data)
+{
+ list->next = g_slist_prepend (list->next, data);
+ return list->next;
+}
+
+/*
+ * Return the node prior to the node containing 'data'.
+ * If the list is empty, or the first node contains 'data', return NULL.
+ * If no node contains 'data', return the last node.
+ */
+static inline GSList*
+find_prev (GSList *list, gconstpointer data)
+{
+ GSList *prev = NULL;
+ while (list) {
+ if (list->data == data)
+ break;
+ prev = list;
+ list = list->next;
+ }
+ return prev;
+}
+
+/* like 'find_prev', but searches for node 'link' */
+static inline GSList*
+find_prev_link (GSList *list, GSList *link)
+{
+ GSList *prev = NULL;
+ while (list) {
+ if (list == link)
+ break;
+ prev = list;
+ list = list->next;
+ }
+ return prev;
+}
+
+GSList*
+g_slist_insert_before (GSList *list, GSList *sibling, gpointer data)
+{
+ GSList *prev = find_prev_link (list, sibling);
+
+ if (!prev)
+ return g_slist_prepend (list, data);
+
+ insert_after (prev, data);
+ return list;
+}
+
+void
+g_slist_free (GSList *list)
+{
+ while (list) {
+ GSList *next = list->next;
+ g_slist_free_1 (list);
+ list = next;
+ }
+}
+
+GSList*
+g_slist_copy (GSList *list)
+{
+ GSList *copy, *tmp;
+
+ if (!list)
+ return NULL;
+
+ copy = g_slist_prepend (NULL, list->data);
+ tmp = copy;
+
+ for (list = list->next; list; list = list->next)
+ tmp = insert_after (tmp, list->data);
+
+ return copy;
+}
+
+GSList*
+g_slist_concat (GSList *list1, GSList *list2)
+{
+ if (!list1)
+ return list2;
+
+ g_slist_last (list1)->next = list2;
+ return list1;
+}
+
+void
+g_slist_foreach (GSList *list, GFunc func, gpointer user_data)
+{
+ while (list) {
+ (*func) (list->data, user_data);
+ list = list->next;
+ }
+}
+
+GSList*
+g_slist_last (GSList *list)
+{
+ if (!list)
+ return NULL;
+
+ while (list->next)
+ list = list->next;
+
+ return list;
+}
+
+GSList*
+g_slist_find (GSList *list, gconstpointer data)
+{
+ for (; list; list = list->next)
+ if (list->data == data)
+ break;
+ return list;
+}
+
+GSList *
+g_slist_find_custom (GSList *list, gconstpointer data, GCompareFunc func)
+{
+ if (!func)
+ return NULL;
+
+ while (list) {
+ if (func (list->data, data) == 0)
+ return list;
+
+ list = list->next;
+ }
+
+ return NULL;
+}
+
+guint
+g_slist_length (GSList *list)
+{
+ guint length = 0;
+
+ while (list) {
+ length ++;
+ list = list->next;
+ }
+
+ return length;
+}
+
+GSList*
+g_slist_remove (GSList *list, gconstpointer data)
+{
+ GSList *prev = find_prev (list, data);
+ GSList *current = prev ? prev->next : list;
+
+ if (current) {
+ if (prev)
+ prev->next = current->next;
+ else
+ list = current->next;
+ g_slist_free_1 (current);
+ }
+
+ return list;
+}
+
+GSList*
+g_slist_remove_all (GSList *list, gconstpointer data)
+{
+ GSList *next = list;
+ GSList *prev = NULL;
+ GSList *current;
+
+ while (next) {
+ GSList *tmp_prev = find_prev (next, data);
+ if (tmp_prev)
+ prev = tmp_prev;
+ current = prev ? prev->next : list;
+
+ if (!current)
+ break;
+
+ next = current->next;
+
+ if (prev)
+ prev->next = next;
+ else
+ list = next;
+ g_slist_free_1 (current);
+ }
+
+ return list;
+}
+
+GSList*
+g_slist_remove_link (GSList *list, GSList *link)
+{
+ GSList *prev = find_prev_link (list, link);
+ GSList *current = prev ? prev->next : list;
+
+ if (current) {
+ if (prev)
+ prev->next = current->next;
+ else
+ list = current->next;
+ current->next = NULL;
+ }
+
+ return list;
+}
+
+GSList*
+g_slist_delete_link (GSList *list, GSList *link)
+{
+ list = g_slist_remove_link (list, link);
+ g_slist_free_1 (link);
+
+ return list;
+}
+
+GSList*
+g_slist_reverse (GSList *list)
+{
+ GSList *prev = NULL;
+ while (list){
+ GSList *next = list->next;
+ list->next = prev;
+ prev = list;
+ list = next;
+ }
+
+ return prev;
+}
+
+GSList*
+g_slist_insert_sorted (GSList *list, gpointer data, GCompareFunc func)
+{
+ GSList *prev = NULL;
+
+ if (!func)
+ return list;
+
+ if (!list || func (list->data, data) > 0)
+ return g_slist_prepend (list, data);
+
+ /* Invariant: func (prev->data, data) <= 0) */
+ for (prev = list; prev->next; prev = prev->next)
+ if (func (prev->next->data, data) > 0)
+ break;
+
+ /* ... && (prev->next == 0 || func (prev->next->data, data) > 0)) */
+ insert_after (prev, data);
+ return list;
+}
+
+gint
+g_slist_index (GSList *list, gconstpointer data)
+{
+ gint index = 0;
+
+ while (list) {
+ if (list->data == data)
+ return index;
+
+ index++;
+ list = list->next;
+ }
+
+ return -1;
+}
+
+GSList*
+g_slist_nth (GSList *list, guint n)
+{
+ for (; list; list = list->next) {
+ if (n == 0)
+ break;
+ n--;
+ }
+ return list;
+}
+
+gpointer
+g_slist_nth_data (GSList *list, guint n)
+{
+ GSList *node = g_slist_nth (list, n);
+ return node ? node->data : NULL;
+}
+
+typedef GSList list_node;
+#include "sort.frag.h"
+
+GSList*
+g_slist_sort (GSList *list, GCompareFunc func)
+{
+ if (!list || !list->next)
+ return list;
+ return do_sort (list, func);
+}
--- /dev/null
+/*
+ * Spawning processes.
+ *
+ * Author:
+ * Gonzalo Paniagua Javier (gonzalo@novell.com
+ *
+ * (C) 2006 Novell, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <sys/types.h>
+
+#include <glib.h>
+
+#ifdef HAVE_UNISTD_H
+#ifndef __USE_GNU
+#define __USE_GNU
+#endif
+#include <unistd.h>
+#endif
+
+#ifdef HAVE_SYS_SELECT_H
+#include <sys/select.h>
+#endif
+
+#ifdef HAVE_SYS_TIME_H
+#include <sys/time.h>
+#endif
+
+#ifdef HAVE_SYS_WAIT_H
+#include <sys/wait.h>
+#endif
+
+#ifdef HAVE_SYS_RESOURCE_H
+# include <sys/resource.h>
+#endif
+
+#ifdef G_OS_WIN32
+#include <io.h>
+#include <winsock2.h>
+#define open _open
+#define close _close
+#define read _read
+#define write _write
+/* windows pipe api details: http://msdn2.microsoft.com/en-us/library/edze9h7e(VS.80).aspx */
+#define pipe(x) _pipe(x, 256, 0)
+#endif
+
+#define set_error(msg, ...) do { if (error != NULL) *error = g_error_new (G_LOG_DOMAIN, 1, msg, __VA_ARGS__); } while (0)
+#define set_error_cond(cond,msg, ...) do { if ((cond) && error != NULL) *error = g_error_new (G_LOG_DOMAIN, 1, msg, __VA_ARGS__); } while (0)
+#define set_error_status(status,msg, ...) do { if (error != NULL) *error = g_error_new (G_LOG_DOMAIN, status, msg, __VA_ARGS__); } while (0)
+#define NO_INTR(var,cmd) do { (var) = (cmd); } while ((var) == -1 && errno == EINTR)
+#define CLOSE_PIPE(p) do { close (p [0]); close (p [1]); } while (0)
+
+#if defined(__APPLE__)
+#if defined (TARGET_OSX)
+/* Apple defines this in crt_externs.h but doesn't provide that header for
+ * arm-apple-darwin9. We'll manually define the symbol on Apple as it does
+ * in fact exist on all implementations (so far)
+ */
+gchar ***_NSGetEnviron(void);
+#define environ (*_NSGetEnviron())
+#else
+static char *mono_environ[1] = { NULL };
+#define environ mono_environ
+#endif /* defined (TARGET_OSX) */
+#elif defined(_MSC_VER)
+/* MS defines this in stdlib.h */
+#else
+extern char **environ;
+#endif
+
+#ifndef G_OS_WIN32
+static int
+safe_read (int fd, gchar *buffer, gint count, GError **error)
+{
+ int res;
+
+ NO_INTR (res, read (fd, buffer, count));
+ set_error_cond (res == -1, "%s", "Error reading from pipe.");
+ return res;
+}
+
+static int
+read_pipes (int outfd, gchar **out_str, int errfd, gchar **err_str, GError **error)
+{
+ fd_set rfds;
+ int res;
+ gboolean out_closed;
+ gboolean err_closed;
+ GString *out = NULL;
+ GString *err = NULL;
+ gchar *buffer = NULL;
+ gint nread;
+
+ out_closed = (outfd < 0);
+ err_closed = (errfd < 0);
+ if (out_str) {
+ *out_str = NULL;
+ out = g_string_new ("");
+ }
+
+ if (err_str) {
+ *err_str = NULL;
+ err = g_string_new ("");
+ }
+
+ do {
+ if (out_closed && err_closed)
+ break;
+
+#ifdef _MSC_VER
+#pragma warning(push)
+#pragma warning(disable:4389)
+#endif
+
+ FD_ZERO (&rfds);
+ if (!out_closed && outfd >= 0)
+ FD_SET (outfd, &rfds);
+ if (!err_closed && errfd >= 0)
+ FD_SET (errfd, &rfds);
+
+#ifdef _MSC_VER
+#pragma warning(pop)
+#endif
+
+ res = select (MAX (outfd, errfd) + 1, &rfds, NULL, NULL, NULL);
+ if (res > 0) {
+ if (buffer == NULL)
+ buffer = g_malloc (1024);
+ if (!out_closed && FD_ISSET (outfd, &rfds)) {
+ nread = safe_read (outfd, buffer, 1024, error);
+ if (nread < 0) {
+ close (errfd);
+ close (outfd);
+ return -1;
+ }
+ g_string_append_len (out, buffer, nread);
+ if (nread <= 0) {
+ out_closed = TRUE;
+ close (outfd);
+ }
+ }
+
+ if (!err_closed && FD_ISSET (errfd, &rfds)) {
+ nread = safe_read (errfd, buffer, 1024, error);
+ if (nread < 0) {
+ close (errfd);
+ close (outfd);
+ return -1;
+ }
+ g_string_append_len (err, buffer, nread);
+ if (nread <= 0) {
+ err_closed = TRUE;
+ close (errfd);
+ }
+ }
+ }
+ } while (res > 0 || (res == -1 && errno == EINTR));
+
+ g_free (buffer);
+ if (out_str)
+ *out_str = g_string_free (out, FALSE);
+
+ if (err_str)
+ *err_str = g_string_free (err, FALSE);
+
+ return 0;
+}
+
+static gboolean
+create_pipe (int *fds, GError **error)
+{
+ if (pipe (fds) == -1) {
+ set_error ("%s", "Error creating pipe.");
+ return FALSE;
+ }
+ return TRUE;
+}
+#endif /* G_OS_WIN32 */
+
+static int
+write_all (int fd, const void *vbuf, size_t n)
+{
+ const char *buf = (const char *) vbuf;
+ size_t nwritten = 0;
+ int w;
+
+ do {
+ do {
+ w = write (fd, buf + nwritten, n - nwritten);
+ } while (w == -1 && errno == EINTR);
+
+ if (w == -1)
+ return -1;
+
+ nwritten += w;
+ } while (nwritten < n);
+
+ return nwritten;
+}
+
+#ifndef G_OS_WIN32
+int
+eg_getdtablesize (void)
+{
+#ifdef HAVE_GETRLIMIT
+ struct rlimit limit;
+ int res;
+
+ res = getrlimit (RLIMIT_NOFILE, &limit);
+ g_assert (res == 0);
+ return limit.rlim_cur;
+#else
+ return getdtablesize ();
+#endif
+}
+#else
+int
+eg_getdtablesize (void)
+{
+ g_error ("Should not be called");
+}
+#endif
+
+gboolean
+g_spawn_command_line_sync (const gchar *command_line,
+ gchar **standard_output,
+ gchar **standard_error,
+ gint *exit_status,
+ GError **error)
+{
+#ifdef G_OS_WIN32
+#elif !defined (HAVE_FORK) || !defined (HAVE_EXECV)
+ fprintf (stderr, "g_spawn_command_line_sync not supported on this platform\n");
+ return FALSE;
+#else
+ pid_t pid;
+ gchar **argv;
+ gint argc;
+ int stdout_pipe [2] = { -1, -1 };
+ int stderr_pipe [2] = { -1, -1 };
+ int status;
+ int res;
+
+ if (!g_shell_parse_argv (command_line, &argc, &argv, error))
+ return FALSE;
+
+ if (standard_output && !create_pipe (stdout_pipe, error))
+ return FALSE;
+
+ if (standard_error && !create_pipe (stderr_pipe, error)) {
+ if (standard_output) {
+ CLOSE_PIPE (stdout_pipe);
+ }
+ return FALSE;
+ }
+
+ pid = fork ();
+ if (pid == 0) {
+ gint i;
+
+ if (standard_output) {
+ close (stdout_pipe [0]);
+ dup2 (stdout_pipe [1], STDOUT_FILENO);
+ }
+
+ if (standard_error) {
+ close (stderr_pipe [0]);
+ dup2 (stderr_pipe [1], STDERR_FILENO);
+ }
+ for (i = eg_getdtablesize () - 1; i >= 3; i--)
+ close (i);
+
+ /* G_SPAWN_SEARCH_PATH is always enabled for g_spawn_command_line_sync */
+ if (!g_path_is_absolute (argv [0])) {
+ gchar *arg0;
+
+ arg0 = g_find_program_in_path (argv [0]);
+ if (arg0 == NULL) {
+ exit (1);
+ }
+ //g_free (argv [0]);
+ argv [0] = arg0;
+ }
+ execv (argv [0], argv);
+ exit (1); /* TODO: What now? */
+ }
+
+ g_strfreev (argv);
+ if (standard_output)
+ close (stdout_pipe [1]);
+
+ if (standard_error)
+ close (stderr_pipe [1]);
+
+ if (standard_output || standard_error) {
+ res = read_pipes (stdout_pipe [0], standard_output, stderr_pipe [0], standard_error, error);
+ if (res) {
+ waitpid (pid, &status, WNOHANG); /* avoid zombie */
+ return FALSE;
+ }
+ }
+
+ NO_INTR (res, waitpid (pid, &status, 0));
+
+ /* TODO: What if error? */
+ if (WIFEXITED (status) && exit_status) {
+ *exit_status = WEXITSTATUS (status);
+ }
+#endif
+ return TRUE;
+}
+
+/*
+ * This is the only use we have in mono/metadata
+!g_spawn_async_with_pipes (NULL, (char**)addr_argv, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, &child_pid, &ch_in, &ch_out, NULL, NULL)
+*/
+gboolean
+g_spawn_async_with_pipes (const gchar *working_directory,
+ gchar **argv,
+ gchar **envp,
+ GSpawnFlags flags,
+ GSpawnChildSetupFunc child_setup,
+ gpointer user_data,
+ GPid *child_pid,
+ gint *standard_input,
+ gint *standard_output,
+ gint *standard_error,
+ GError **error)
+{
+#ifdef G_OS_WIN32
+#elif !defined (HAVE_FORK) || !defined (HAVE_EXECVE)
+ fprintf (stderr, "g_spawn_async_with_pipes is not supported on this platform\n");
+ return FALSE;
+#else
+ pid_t pid;
+ int info_pipe [2];
+ int in_pipe [2] = { -1, -1 };
+ int out_pipe [2] = { -1, -1 };
+ int err_pipe [2] = { -1, -1 };
+ int status;
+
+ g_return_val_if_fail (argv != NULL, FALSE); /* Only mandatory arg */
+
+ if (!create_pipe (info_pipe, error))
+ return FALSE;
+
+ if (standard_output && !create_pipe (out_pipe, error)) {
+ CLOSE_PIPE (info_pipe);
+ return FALSE;
+ }
+
+ if (standard_error && !create_pipe (err_pipe, error)) {
+ CLOSE_PIPE (info_pipe);
+ CLOSE_PIPE (out_pipe);
+ return FALSE;
+ }
+
+ if (standard_input && !create_pipe (in_pipe, error)) {
+ CLOSE_PIPE (info_pipe);
+ CLOSE_PIPE (out_pipe);
+ CLOSE_PIPE (err_pipe);
+ return FALSE;
+ }
+
+ pid = fork ();
+ if (pid == -1) {
+ CLOSE_PIPE (info_pipe);
+ CLOSE_PIPE (out_pipe);
+ CLOSE_PIPE (err_pipe);
+ CLOSE_PIPE (in_pipe);
+ set_error ("%s", "Error in fork ()");
+ return FALSE;
+ }
+
+ if (pid == 0) {
+ /* No zombie left behind */
+ if ((flags & G_SPAWN_DO_NOT_REAP_CHILD) == 0) {
+ pid = fork ();
+ }
+
+ if (pid != 0) {
+ exit (pid == -1 ? 1 : 0);
+ } else {
+ gint i;
+ int fd;
+ gchar *arg0;
+ gchar **actual_args;
+ gint unused;
+
+ close (info_pipe [0]);
+ close (in_pipe [1]);
+ close (out_pipe [0]);
+ close (err_pipe [0]);
+
+ /* when exec* succeeds, we want to close this fd, which will return
+ * a 0 read on the parent. We're not supposed to keep it open forever.
+ * If exec fails, we still can write the error to it before closing.
+ */
+ fcntl (info_pipe [1], F_SETFD, FD_CLOEXEC);
+
+ if ((flags & G_SPAWN_DO_NOT_REAP_CHILD) == 0) {
+ pid = getpid ();
+ NO_INTR (unused, write_all (info_pipe [1], &pid, sizeof (pid_t)));
+ }
+
+ if (working_directory && chdir (working_directory) == -1) {
+ int err = errno;
+ NO_INTR (unused, write_all (info_pipe [1], &err, sizeof (int)));
+ exit (0);
+ }
+
+ if (standard_output) {
+ dup2 (out_pipe [1], STDOUT_FILENO);
+ } else if ((flags & G_SPAWN_STDOUT_TO_DEV_NULL) != 0) {
+ fd = open ("/dev/null", O_WRONLY);
+ dup2 (fd, STDOUT_FILENO);
+ }
+
+ if (standard_error) {
+ dup2 (err_pipe [1], STDERR_FILENO);
+ } else if ((flags & G_SPAWN_STDERR_TO_DEV_NULL) != 0) {
+ fd = open ("/dev/null", O_WRONLY);
+ dup2 (fd, STDERR_FILENO);
+ }
+
+ if (standard_input) {
+ dup2 (in_pipe [0], STDIN_FILENO);
+ } else if ((flags & G_SPAWN_CHILD_INHERITS_STDIN) == 0) {
+ fd = open ("/dev/null", O_RDONLY);
+ dup2 (fd, STDIN_FILENO);
+ }
+
+ if ((flags & G_SPAWN_LEAVE_DESCRIPTORS_OPEN) != 0) {
+ for (i = eg_getdtablesize () - 1; i >= 3; i--)
+ close (i);
+ }
+
+ actual_args = ((flags & G_SPAWN_FILE_AND_ARGV_ZERO) == 0) ? argv : argv + 1;
+ if (envp == NULL)
+ envp = environ;
+
+ if (child_setup)
+ child_setup (user_data);
+
+ arg0 = argv [0];
+ if (!g_path_is_absolute (arg0) || (flags & G_SPAWN_SEARCH_PATH) != 0) {
+ arg0 = g_find_program_in_path (argv [0]);
+ if (arg0 == NULL) {
+ int err = ENOENT;
+ write_all (info_pipe [1], &err, sizeof (int));
+ exit (0);
+ }
+ }
+
+ execve (arg0, actual_args, envp);
+ write_all (info_pipe [1], &errno, sizeof (int));
+ exit (0);
+ }
+ } else if ((flags & G_SPAWN_DO_NOT_REAP_CHILD) == 0) {
+ int w;
+ /* Wait for the first child if two are created */
+ NO_INTR (w, waitpid (pid, &status, 0));
+ if (status == 1 || w == -1) {
+ CLOSE_PIPE (info_pipe);
+ CLOSE_PIPE (out_pipe);
+ CLOSE_PIPE (err_pipe);
+ CLOSE_PIPE (in_pipe);
+ set_error ("Error in fork (): %d", status);
+ return FALSE;
+ }
+ }
+ close (info_pipe [1]);
+ close (in_pipe [0]);
+ close (out_pipe [1]);
+ close (err_pipe [1]);
+
+ if ((flags & G_SPAWN_DO_NOT_REAP_CHILD) == 0) {
+ int x;
+ NO_INTR (x, read (info_pipe [0], &pid, sizeof (pid_t))); /* if we read < sizeof (pid_t)... */
+ }
+
+ if (child_pid) {
+ *child_pid = pid;
+ }
+
+ if (read (info_pipe [0], &status, sizeof (int)) != 0) {
+ close (info_pipe [0]);
+ close (in_pipe [0]);
+ close (out_pipe [1]);
+ close (err_pipe [1]);
+ set_error_status (status, "Error in exec (%d -> %s)", status, strerror (status));
+ return FALSE;
+ }
+
+ close (info_pipe [0]);
+ if (standard_input)
+ *standard_input = in_pipe [1];
+ if (standard_output)
+ *standard_output = out_pipe [0];
+ if (standard_error)
+ *standard_error = err_pipe [0];
+#endif
+ return TRUE;
+}
+
+
--- /dev/null
+/*
+ * gstr.c: String Utility Functions.
+ *
+ * Author:
+ * Miguel de Icaza (miguel@novell.com)
+ * Aaron Bockover (abockover@novell.com)
+ *
+ * (C) 2006 Novell, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#include <config.h>
+#include <stdio.h>
+#include <string.h>
+#include <ctype.h>
+#include <glib.h>
+
+#ifndef G_OS_WIN32
+#include <pthread.h>
+#endif
+
+#include <errno.h>
+
+/*
+ * g_strndup and g_vasprintf need to allocate memory with g_malloc if
+ * ENABLE_OVERRIDABLE_ALLOCATORS is defined so that it can be safely freed with g_free
+ * rather than free.
+ */
+
+/* This is not a macro, because I dont want to put _GNU_SOURCE in the glib.h header */
+gchar *
+g_strndup (const gchar *str, gsize n)
+{
+#if defined (HAVE_STRNDUP) && !defined (ENABLE_OVERRIDABLE_ALLOCATORS)
+ return strndup (str, n);
+#else
+ if (str) {
+ char *retval = g_malloc(n+1);
+ if (retval) {
+ strncpy(retval, str, n)[n] = 0;
+ }
+ return retval;
+ }
+ return NULL;
+#endif
+}
+
+gint g_vasprintf (gchar **ret, const gchar *fmt, va_list ap)
+{
+#if defined (HAVE_VASPRINTF) && !defined (ENABLE_OVERRIDABLE_ALLOCATORS)
+ return vasprintf (ret, fmt, ap);
+#else
+ char *buf;
+ int len;
+ size_t buflen;
+ va_list ap2;
+
+#if defined(_MSC_VER) || defined(__MINGW64_VERSION_MAJOR)
+ ap2 = ap;
+ len = _vscprintf(fmt, ap2); // NOTE MS specific extension ( :-( )
+#else
+ va_copy(ap2, ap);
+ len = vsnprintf(NULL, 0, fmt, ap2);
+#endif
+
+ if (len >= 0 && (buf = g_malloc ((buflen = (size_t) (len + 1)))) != NULL) {
+ len = vsnprintf(buf, buflen, fmt, ap);
+ *ret = buf;
+ } else {
+ *ret = NULL;
+ len = -1;
+ }
+
+ va_end(ap2);
+ return len;
+#endif
+}
+
+void
+g_strfreev (gchar **str_array)
+{
+ gchar **orig = str_array;
+ if (str_array == NULL)
+ return;
+ while (*str_array != NULL){
+ g_free (*str_array);
+ str_array++;
+ }
+ g_free (orig);
+}
+
+gchar **
+g_strdupv (gchar **str_array)
+{
+ guint length;
+ gchar **ret;
+ guint i;
+
+ if (!str_array)
+ return NULL;
+
+ length = g_strv_length(str_array);
+ ret = g_new0(gchar *, length + 1);
+ for (i = 0; str_array[i]; i++) {
+ ret[i] = g_strdup(str_array[i]);
+ }
+ ret[length] = NULL;
+ return ret;
+}
+
+guint
+g_strv_length(gchar **str_array)
+{
+ gint length = 0;
+ g_return_val_if_fail(str_array != NULL, 0);
+ for(length = 0; str_array[length] != NULL; length++);
+ return length;
+}
+
+gboolean
+g_str_has_suffix(const gchar *str, const gchar *suffix)
+{
+ size_t str_length;
+ size_t suffix_length;
+
+ g_return_val_if_fail(str != NULL, FALSE);
+ g_return_val_if_fail(suffix != NULL, FALSE);
+
+ str_length = strlen(str);
+ suffix_length = strlen(suffix);
+
+ return suffix_length <= str_length ?
+ strncmp(str + str_length - suffix_length, suffix, suffix_length) == 0 :
+ FALSE;
+}
+
+gboolean
+g_str_has_prefix(const gchar *str, const gchar *prefix)
+{
+ size_t str_length;
+ size_t prefix_length;
+
+ g_return_val_if_fail(str != NULL, FALSE);
+ g_return_val_if_fail(prefix != NULL, FALSE);
+
+ str_length = strlen(str);
+ prefix_length = strlen(prefix);
+
+ return prefix_length <= str_length ?
+ strncmp(str, prefix, prefix_length) == 0 :
+ FALSE;
+}
+
+gchar *
+g_strdup_vprintf (const gchar *format, va_list args)
+{
+ int n;
+ char *ret;
+
+ n = g_vasprintf (&ret, format, args);
+ if (n == -1)
+ return NULL;
+
+ return ret;
+}
+
+gchar *
+g_strdup_printf (const gchar *format, ...)
+{
+ gchar *ret;
+ va_list args;
+ int n;
+
+ va_start (args, format);
+ n = g_vasprintf (&ret, format, args);
+ va_end (args);
+ if (n == -1)
+ return NULL;
+
+ return ret;
+}
+
+
+/*
+Max error number we support. It's empirically found by looking at our target OS.
+
+Last this was checked was June-2017.
+
+Apple is at 106.
+Android is at 133.
+*/
+#define MONO_ERRNO_MAX 200
+#define str(s) #s
+
+#ifndef G_OS_WIN32
+static pthread_mutex_t strerror_lock = PTHREAD_MUTEX_INITIALIZER;
+#endif
+
+static char *error_messages [MONO_ERRNO_MAX];
+
+const gchar *
+g_strerror (gint errnum)
+{
+ if (errnum < 0)
+ errnum = -errnum;
+ if (errnum >= MONO_ERRNO_MAX)
+ return ("Error number higher than " str (MONO_ERRNO_MAX));
+
+ if (!error_messages [errnum]) {
+#ifndef G_OS_WIN32
+ pthread_mutex_lock (&strerror_lock);
+#endif
+
+#ifdef HAVE_STRERROR_R
+ char tmp_buff [128]; //Quite arbitrary, should be large enough
+ char *buff = tmp_buff;
+ int buff_len = sizeof (tmp_buff);
+ int r;
+ buff [0] = 0;
+
+ while ((r = strerror_r (errnum, buff, buff_len - 1))) {
+ if (r != ERANGE) {
+ buff = g_strdup_printf ("Invalid Error code '%d'", errnum);
+ break;
+ }
+ if (buff == tmp_buff)
+ buff = g_malloc (buff_len * 2);
+ else
+ buff = g_realloc (buff, buff_len * 2);
+ buff_len *= 2;
+ //Spec is not clean on whether size argument includes space for null terminator or not
+ }
+ if (!error_messages [errnum])
+ error_messages [errnum] = g_strdup (buff);
+ if (buff != tmp_buff)
+ g_free (buff);
+#else
+ if (!error_messages [errnum])
+ error_messages [errnum] = g_strdup_printf ("Error code '%d'", errnum);
+#endif
+
+
+#ifndef G_OS_WIN32
+ pthread_mutex_unlock (&strerror_lock);
+#endif
+
+ }
+ return error_messages [errnum];
+}
+
+gchar *
+g_strconcat (const gchar *first, ...)
+{
+ va_list args;
+ size_t total = 0;
+ char *s, *ret;
+ g_return_val_if_fail (first != NULL, NULL);
+
+ total += strlen (first);
+ va_start (args, first);
+ for (s = va_arg (args, char *); s != NULL; s = va_arg(args, char *)){
+ total += strlen (s);
+ }
+ va_end (args);
+
+ ret = g_malloc (total + 1);
+ if (ret == NULL)
+ return NULL;
+
+ ret [total] = 0;
+ strcpy (ret, first);
+ va_start (args, first);
+ for (s = va_arg (args, char *); s != NULL; s = va_arg(args, char *)){
+ strcat (ret, s);
+ }
+ va_end (args);
+
+ return ret;
+}
+
+static void
+add_to_vector (gchar ***vector, int size, gchar *token)
+{
+ *vector = *vector == NULL ?
+ (gchar **)g_malloc(2 * sizeof(*vector)) :
+ (gchar **)g_realloc(*vector, (size + 1) * sizeof(*vector));
+
+ (*vector)[size - 1] = token;
+}
+
+gchar **
+g_strsplit (const gchar *string, const gchar *delimiter, gint max_tokens)
+{
+ const gchar *c;
+ gchar *token, **vector;
+ gint size = 1;
+
+ g_return_val_if_fail (string != NULL, NULL);
+ g_return_val_if_fail (delimiter != NULL, NULL);
+ g_return_val_if_fail (delimiter[0] != 0, NULL);
+
+ if (strncmp (string, delimiter, strlen (delimiter)) == 0) {
+ vector = (gchar **)g_malloc (2 * sizeof(vector));
+ vector[0] = g_strdup ("");
+ size++;
+ string += strlen (delimiter);
+ } else {
+ vector = NULL;
+ }
+
+ while (*string && !(max_tokens > 0 && size >= max_tokens)) {
+ c = string;
+ if (strncmp (string, delimiter, strlen (delimiter)) == 0) {
+ token = g_strdup ("");
+ string += strlen (delimiter);
+ } else {
+ while (*string && strncmp (string, delimiter, strlen (delimiter)) != 0) {
+ string++;
+ }
+
+ if (*string) {
+ gsize toklen = (string - c);
+ token = g_strndup (c, toklen);
+
+ /* Need to leave a trailing empty
+ * token if the delimiter is the last
+ * part of the string
+ */
+ if (strcmp (string, delimiter) != 0) {
+ string += strlen (delimiter);
+ }
+ } else {
+ token = g_strdup (c);
+ }
+ }
+
+ add_to_vector (&vector, size, token);
+ size++;
+ }
+
+ if (*string) {
+ if (strcmp (string, delimiter) == 0)
+ add_to_vector (&vector, size, g_strdup (""));
+ else {
+ /* Add the rest of the string as the last element */
+ add_to_vector (&vector, size, g_strdup (string));
+ }
+ size++;
+ }
+
+ if (vector == NULL) {
+ vector = (gchar **) g_malloc (2 * sizeof (vector));
+ vector [0] = NULL;
+ } else if (size > 0) {
+ vector[size - 1] = NULL;
+ }
+
+ return vector;
+}
+
+static gboolean
+charcmp (gchar testchar, const gchar *compare)
+{
+ while(*compare) {
+ if (*compare == testchar) {
+ return TRUE;
+ }
+ compare++;
+ }
+
+ return FALSE;
+}
+
+gchar **
+g_strsplit_set (const gchar *string, const gchar *delimiter, gint max_tokens)
+{
+ const gchar *c;
+ gchar *token, **vector;
+ gint size = 1;
+
+ g_return_val_if_fail (string != NULL, NULL);
+ g_return_val_if_fail (delimiter != NULL, NULL);
+ g_return_val_if_fail (delimiter[0] != 0, NULL);
+
+ if (charcmp (*string, delimiter)) {
+ vector = (gchar **)g_malloc (2 * sizeof(vector));
+ vector[0] = g_strdup ("");
+ size++;
+ string++;
+ } else {
+ vector = NULL;
+ }
+
+ c = string;
+ while (*string && !(max_tokens > 0 && size >= max_tokens)) {
+ if (charcmp (*string, delimiter)) {
+ gsize toklen = (string - c);
+ if (toklen == 0) {
+ token = g_strdup ("");
+ } else {
+ token = g_strndup (c, toklen);
+ }
+
+ c = string + 1;
+
+ add_to_vector (&vector, size, token);
+ size++;
+ }
+
+ string++;
+ }
+
+ if (max_tokens > 0 && size >= max_tokens) {
+ if (*string) {
+ /* Add the rest of the string as the last element */
+ add_to_vector (&vector, size, g_strdup (string));
+ size++;
+ }
+ } else {
+ if (*c) {
+ /* Fill in the trailing last token */
+ add_to_vector (&vector, size, g_strdup (c));
+ size++;
+ } else {
+ /* Need to leave a trailing empty token if the
+ * delimiter is the last part of the string
+ */
+ add_to_vector (&vector, size, g_strdup (""));
+ size++;
+ }
+ }
+
+ if (vector == NULL) {
+ vector = (gchar **) g_malloc (2 * sizeof (vector));
+ vector [0] = NULL;
+ } else if (size > 0) {
+ vector[size - 1] = NULL;
+ }
+
+ return vector;
+}
+
+gchar *
+g_strreverse (gchar *str)
+{
+ size_t i, j;
+ gchar c;
+
+ if (str == NULL)
+ return NULL;
+
+ if (*str == 0)
+ return str;
+
+ for (i = 0, j = strlen (str) - 1; i < j; i++, j--) {
+ c = str [i];
+ str [i] = str [j];
+ str [j] = c;
+ }
+
+ return str;
+}
+
+gchar *
+g_strjoin (const gchar *separator, ...)
+{
+ va_list args;
+ char *res, *s, *r;
+ size_t len, slen;
+
+ if (separator != NULL)
+ slen = strlen (separator);
+ else
+ slen = 0;
+
+ len = 0;
+ va_start (args, separator);
+ for (s = va_arg (args, char *); s != NULL; s = va_arg (args, char *)){
+ len += strlen (s);
+ len += slen;
+ }
+ va_end (args);
+
+ if (len == 0)
+ return g_strdup ("");
+
+ /* Remove the last separator */
+ if (slen > 0 && len > 0)
+ len -= slen;
+
+ res = g_malloc (len + 1);
+ va_start (args, separator);
+ s = va_arg (args, char *);
+ r = g_stpcpy (res, s);
+ for (s = va_arg (args, char *); s != NULL; s = va_arg (args, char *)){
+ if (separator != NULL)
+ r = g_stpcpy (r, separator);
+ r = g_stpcpy (r, s);
+ }
+ va_end (args);
+
+ return res;
+}
+
+gchar *
+g_strjoinv (const gchar *separator, gchar **str_array)
+{
+ char *res, *r;
+ size_t slen, len, i;
+
+ if (separator != NULL)
+ slen = strlen (separator);
+ else
+ slen = 0;
+
+ len = 0;
+ for (i = 0; str_array [i] != NULL; i++){
+ len += strlen (str_array [i]);
+ len += slen;
+ }
+
+ if (len == 0)
+ return g_strdup ("");
+
+ if (slen > 0 && len > 0)
+ len -= slen;
+
+ res = g_malloc (len + 1);
+ r = g_stpcpy (res, str_array [0]);
+ for (i = 1; str_array [i] != NULL; i++){
+ if (separator != NULL)
+ r = g_stpcpy (r, separator);
+ r = g_stpcpy (r, str_array [i]);
+ }
+
+ return res;
+}
+
+gchar *
+g_strchug (gchar *str)
+{
+ size_t len;
+ gchar *tmp;
+
+ if (str == NULL)
+ return NULL;
+
+ tmp = str;
+ while (*tmp && isspace (*tmp)) tmp++;
+ if (str != tmp) {
+ len = strlen (str) - (tmp - str - 1);
+ memmove (str, tmp, len);
+ }
+ return str;
+}
+
+gchar *
+g_strchomp (gchar *str)
+{
+ gchar *tmp;
+
+ if (str == NULL)
+ return NULL;
+
+ tmp = str + strlen (str) - 1;
+ while (*tmp && isspace (*tmp)) tmp--;
+ *(tmp + 1) = '\0';
+ return str;
+}
+
+gint
+g_printf(gchar const *format, ...)
+{
+ va_list args;
+ gint ret;
+
+ va_start(args, format);
+ ret = vprintf(format, args);
+ va_end(args);
+
+ return ret;
+}
+
+gint
+g_fprintf(FILE *file, gchar const *format, ...)
+{
+ va_list args;
+ gint ret;
+
+ va_start(args, format);
+ ret = vfprintf(file, format, args);
+ va_end(args);
+
+ return ret;
+}
+
+gint
+g_sprintf(gchar *string, gchar const *format, ...)
+{
+ va_list args;
+ gint ret;
+
+ va_start(args, format);
+ ret = vsprintf(string, format, args);
+ va_end(args);
+
+ return ret;
+}
+
+gint
+g_snprintf(gchar *string, gulong n, gchar const *format, ...)
+{
+ va_list args;
+ gint ret;
+
+ va_start(args, format);
+ ret = vsnprintf(string, n, format, args);
+ va_end(args);
+
+ return ret;
+}
+
+static const char hx [] = { '0', '1', '2', '3', '4', '5', '6', '7',
+ '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
+
+static gboolean
+char_needs_encoding (char c)
+{
+ if (((unsigned char)c) >= 0x80)
+ return TRUE;
+
+ if ((c >= '@' && c <= 'Z') ||
+ (c >= 'a' && c <= 'z') ||
+ (c >= '&' && c < 0x3b) ||
+ (c == '!') || (c == '$') || (c == '_') || (c == '=') || (c == '~'))
+ return FALSE;
+ return TRUE;
+}
+
+gchar *
+g_filename_to_uri (const gchar *filename, const gchar *hostname, GError **error)
+{
+ size_t n;
+ char *ret, *rp;
+ const char *p;
+#ifdef G_OS_WIN32
+ const char *uriPrefix = "file:///";
+#else
+ const char *uriPrefix = "file://";
+#endif
+
+ g_return_val_if_fail (filename != NULL, NULL);
+
+ if (hostname != NULL)
+ g_warning ("%s", "eglib: g_filename_to_uri: hostname not handled");
+
+ if (!g_path_is_absolute (filename)){
+ if (error != NULL)
+ *error = g_error_new (NULL, 2, "Not an absolute filename");
+
+ return NULL;
+ }
+
+ n = strlen (uriPrefix) + 1;
+ for (p = filename; *p; p++){
+#ifdef G_OS_WIN32
+ if (*p == '\\') {
+ n++;
+ continue;
+ }
+#endif
+ if (char_needs_encoding (*p))
+ n += 3;
+ else
+ n++;
+ }
+ ret = g_malloc (n);
+ strcpy (ret, uriPrefix);
+ for (p = filename, rp = ret + strlen (ret); *p; p++){
+#ifdef G_OS_WIN32
+ if (*p == '\\') {
+ *rp++ = '/';
+ continue;
+ }
+#endif
+ if (char_needs_encoding (*p)){
+ *rp++ = '%';
+ *rp++ = hx [((unsigned char)(*p)) >> 4];
+ *rp++ = hx [((unsigned char)(*p)) & 0xf];
+ } else
+ *rp++ = *p;
+ }
+ *rp = 0;
+ return ret;
+}
+
+static int
+decode (char p)
+{
+ if (p >= '0' && p <= '9')
+ return p - '0';
+ if (p >= 'A' && p <= 'F')
+ return p - 'A';
+ if (p >= 'a' && p <= 'f')
+ return p - 'a';
+ g_assert_not_reached ();
+ return 0;
+}
+
+gchar *
+g_filename_from_uri (const gchar *uri, gchar **hostname, GError **error)
+{
+ const char *p;
+ char *r, *result;
+ int flen = 0;
+
+ g_return_val_if_fail (uri != NULL, NULL);
+
+ if (hostname != NULL)
+ g_warning ("%s", "eglib: g_filename_from_uri: hostname not handled");
+
+ if (strncmp (uri, "file:///", 8) != 0){
+ if (error != NULL)
+ *error = g_error_new (NULL, 2, "URI does not start with the file: scheme");
+ return NULL;
+ }
+
+ for (p = uri + 8; *p; p++){
+ if (*p == '%'){
+ if (p [1] && p [2] && isxdigit (p [1]) && isxdigit (p [2])){
+ p += 2;
+ } else {
+ if (error != NULL)
+ *error = g_error_new (NULL, 2, "URI contains an invalid escape sequence");
+ return NULL;
+ }
+ }
+ flen++;
+ }
+#ifndef G_OS_WIN32
+ flen++;
+#endif
+
+ result = g_malloc (flen + 1);
+ result [flen] = 0;
+
+#ifndef G_OS_WIN32
+ *result = '/';
+ r = result + 1;
+#else
+ r = result;
+#endif
+
+ for (p = uri + 8; *p; p++){
+ if (*p == '%'){
+ *r++ = (char)((decode (p [1]) << 4) | decode (p [2]));
+ p += 2;
+ } else
+ *r++ = *p;
+ flen++;
+ }
+ return result;
+}
+
+void
+g_strdown (gchar *string)
+{
+ g_return_if_fail (string != NULL);
+
+ while (*string){
+ *string = (gchar)tolower (*string);
+ string++;
+ }
+}
+
+gchar
+g_ascii_tolower (gchar c)
+{
+ return c >= 'A' && c <= 'Z' ? c + ('a' - 'A') : c;
+}
+
+gchar *
+g_ascii_strdown (const gchar *str, gssize len)
+{
+ char *ret;
+ int i;
+
+ g_return_val_if_fail (str != NULL, NULL);
+
+ if (len == -1)
+ len = strlen (str);
+
+ ret = g_malloc (len + 1);
+ for (i = 0; i < len; i++)
+ ret [i] = (guchar) g_ascii_tolower (str [i]);
+ ret [i] = 0;
+
+ return ret;
+}
+
+gchar
+g_ascii_toupper (gchar c)
+{
+ return c >= 'a' && c <= 'z' ? c + ('A' - 'a') : c;
+}
+
+gchar *
+g_ascii_strup (const gchar *str, gssize len)
+{
+ char *ret;
+ int i;
+
+ g_return_val_if_fail (str != NULL, NULL);
+
+ if (len == -1)
+ len = strlen (str);
+
+ ret = g_malloc (len + 1);
+ for (i = 0; i < len; i++)
+ ret [i] = (guchar) g_ascii_toupper (str [i]);
+ ret [i] = 0;
+
+ return ret;
+}
+
+gint
+g_ascii_strncasecmp (const gchar *s1, const gchar *s2, gsize n)
+{
+ gsize i;
+
+ g_return_val_if_fail (s1 != NULL, 0);
+ g_return_val_if_fail (s2 != NULL, 0);
+
+ for (i = 0; i < n; i++) {
+ gchar c1 = g_ascii_tolower (*s1++);
+ gchar c2 = g_ascii_tolower (*s2++);
+
+ if (c1 != c2)
+ return c1 - c2;
+ }
+
+ return 0;
+}
+
+gint
+g_ascii_strcasecmp (const gchar *s1, const gchar *s2)
+{
+ const char *sp1 = s1;
+ const char *sp2 = s2;
+
+ g_return_val_if_fail (s1 != NULL, 0);
+ g_return_val_if_fail (s2 != NULL, 0);
+
+ while (*sp1 != '\0') {
+ char c1 = g_ascii_tolower (*sp1++);
+ char c2 = g_ascii_tolower (*sp2++);
+
+ if (c1 != c2)
+ return c1 - c2;
+ }
+
+ return (*sp1) - (*sp2);
+}
+
+gchar *
+g_strdelimit (gchar *string, const gchar *delimiters, gchar new_delimiter)
+{
+ gchar *ptr;
+
+ g_return_val_if_fail (string != NULL, NULL);
+
+ if (delimiters == NULL)
+ delimiters = G_STR_DELIMITERS;
+
+ for (ptr = string; *ptr; ptr++) {
+ if (strchr (delimiters, *ptr))
+ *ptr = new_delimiter;
+ }
+
+ return string;
+}
+
+gsize
+g_strlcpy (gchar *dest, const gchar *src, gsize dest_size)
+{
+#ifdef HAVE_STRLCPY
+ return strlcpy (dest, src, dest_size);
+#else
+ gchar *d;
+ const gchar *s;
+ gchar c;
+ gsize len;
+
+ g_return_val_if_fail (src != NULL, 0);
+ g_return_val_if_fail (dest != NULL, 0);
+
+ len = dest_size;
+ if (len == 0)
+ return 0;
+
+ s = src;
+ d = dest;
+ while (--len) {
+ c = *s++;
+ *d++ = c;
+ if (c == '\0')
+ return (dest_size - len - 1);
+ }
+
+ /* len is 0 i we get here */
+ *d = '\0';
+ /* we need to return the length of src here */
+ while (*s++) ; /* instead of a plain strlen, we use 's' */
+ return s - src - 1;
+#endif
+}
+
+gchar *
+g_stpcpy (gchar *dest, const char *src)
+{
+ g_return_val_if_fail (dest != NULL, dest);
+ g_return_val_if_fail (src != NULL, dest);
+
+#if HAVE_STPCPY
+ return stpcpy (dest, src);
+#else
+ while (*src)
+ *dest++ = *src++;
+
+ *dest = '\0';
+
+ return dest;
+#endif
+}
+
+static const gchar escaped_dflt [256] = {
+ 1, 1, 1, 1, 1, 1, 1, 1, 'b', 't', 'n', 1, 'f', 'r', 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 0, 0, '"', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '\\', 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
+};
+
+gchar *
+g_strescape (const gchar *source, const gchar *exceptions)
+{
+ gchar escaped [256];
+ const gchar *ptr;
+ gchar c;
+ gchar op;
+ gchar *result;
+ gchar *res_ptr;
+
+ g_return_val_if_fail (source != NULL, NULL);
+
+ memcpy (escaped, escaped_dflt, 256);
+ if (exceptions != NULL) {
+ for (ptr = exceptions; *ptr; ptr++)
+ escaped [(int) *ptr] = 0;
+ }
+ result = g_malloc (strlen (source) * 4 + 1); /* Worst case: everything octal. */
+ res_ptr = result;
+ for (ptr = source; *ptr; ptr++) {
+ c = *ptr;
+ op = escaped [(int) c];
+ if (op == 0) {
+ *res_ptr++ = c;
+ } else {
+ *res_ptr++ = '\\';
+ if (op != 1) {
+ *res_ptr++ = op;
+ } else {
+ *res_ptr++ = '0' + ((c >> 6) & 3);
+ *res_ptr++ = '0' + ((c >> 3) & 7);
+ *res_ptr++ = '0' + (c & 7);
+ }
+ }
+ }
+ *res_ptr = '\0';
+ return result;
+}
+
+gint
+g_ascii_xdigit_value (gchar c)
+{
+ return ((isxdigit (c) == 0) ? -1 :
+ ((c >= '0' && c <= '9') ? (c - '0') :
+ ((c >= 'a' && c <= 'f') ? (c - 'a' + 10) :
+ (c - 'A' + 10))));
+}
+
+gchar *
+g_strnfill (gsize length, gchar fill_char)
+{
+ gchar *ret = g_new (gchar, length + 1);
+
+ memset (ret, fill_char, length);
+ ret [length] = 0;
+ return ret;
+}
--- /dev/null
+/*
+ * String functions
+ *
+ * Author:
+ * Miguel de Icaza (miguel@novell.com)
+ * Aaron Bockover (abockover@novell.com)
+ *
+ * (C) 2006 Novell, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#include <stdio.h>
+#include <glib.h>
+
+#define GROW_IF_NECESSARY(s,l) { \
+ if(s->len + l >= s->allocated_len) { \
+ s->allocated_len = (s->allocated_len + l + 16) * 2; \
+ s->str = g_realloc(s->str, s->allocated_len); \
+ } \
+}
+
+GString *
+g_string_new_len (const gchar *init, gssize len)
+{
+ GString *ret = g_new (GString, 1);
+
+ if (init == NULL)
+ ret->len = 0;
+ else
+ ret->len = len < 0 ? strlen(init) : len;
+ ret->allocated_len = MAX(ret->len + 1, 16);
+ ret->str = g_malloc(ret->allocated_len);
+ if (init)
+ memcpy(ret->str, init, ret->len);
+ ret->str[ret->len] = 0;
+
+ return ret;
+}
+
+GString *
+g_string_new (const gchar *init)
+{
+ return g_string_new_len(init, -1);
+}
+
+GString *
+g_string_sized_new (gsize default_size)
+{
+ GString *ret = g_new (GString, 1);
+
+ ret->str = g_malloc (default_size);
+ ret->str [0] = 0;
+ ret->len = 0;
+ ret->allocated_len = default_size;
+
+ return ret;
+}
+
+gchar *
+g_string_free (GString *string, gboolean free_segment)
+{
+ gchar *data;
+
+ g_return_val_if_fail (string != NULL, NULL);
+
+ data = string->str;
+ g_free(string);
+
+ if(!free_segment) {
+ return data;
+ }
+
+ g_free(data);
+ return NULL;
+}
+
+GString *
+g_string_append_len (GString *string, const gchar *val, gssize len)
+{
+ g_return_val_if_fail(string != NULL, NULL);
+ g_return_val_if_fail(val != NULL, string);
+
+ if(len < 0) {
+ len = strlen(val);
+ }
+
+ GROW_IF_NECESSARY(string, len);
+ memcpy(string->str + string->len, val, len);
+ string->len += len;
+ string->str[string->len] = 0;
+
+ return string;
+}
+
+GString *
+g_string_append (GString *string, const gchar *val)
+{
+ g_return_val_if_fail(string != NULL, NULL);
+ g_return_val_if_fail(val != NULL, string);
+
+ return g_string_append_len(string, val, -1);
+}
+
+GString *
+g_string_append_c (GString *string, gchar c)
+{
+ g_return_val_if_fail(string != NULL, NULL);
+
+ GROW_IF_NECESSARY(string, 1);
+
+ string->str[string->len] = c;
+ string->str[string->len + 1] = 0;
+ string->len++;
+
+ return string;
+}
+
+GString *
+g_string_append_unichar (GString *string, gunichar c)
+{
+ gchar utf8[6];
+ gint len;
+
+ g_return_val_if_fail (string != NULL, NULL);
+
+ if ((len = g_unichar_to_utf8 (c, utf8)) <= 0)
+ return string;
+
+ return g_string_append_len (string, utf8, len);
+}
+
+GString *
+g_string_prepend (GString *string, const gchar *val)
+{
+ gssize len;
+
+ g_return_val_if_fail (string != NULL, string);
+ g_return_val_if_fail (val != NULL, string);
+
+ len = strlen (val);
+
+ GROW_IF_NECESSARY(string, len);
+ memmove(string->str + len, string->str, string->len + 1);
+ memcpy(string->str, val, len);
+
+ return string;
+}
+
+GString *
+g_string_insert (GString *string, gssize pos, const gchar *val)
+{
+ gssize len;
+
+ g_return_val_if_fail (string != NULL, string);
+ g_return_val_if_fail (val != NULL, string);
+ g_return_val_if_fail (pos <= string->len, string);
+
+ len = strlen (val);
+
+ GROW_IF_NECESSARY(string, len);
+ memmove(string->str + pos + len, string->str + pos, string->len - pos - len + 1);
+ memcpy(string->str + pos, val, len);
+
+ return string;
+}
+
+void
+g_string_append_printf (GString *string, const gchar *format, ...)
+{
+ char *ret;
+ va_list args;
+
+ g_return_if_fail (string != NULL);
+ g_return_if_fail (format != NULL);
+
+ va_start (args, format);
+ ret = g_strdup_vprintf (format, args);
+ va_end (args);
+ g_string_append (string, ret);
+
+ g_free (ret);
+}
+
+void
+g_string_append_vprintf (GString *string, const gchar *format, va_list args)
+{
+ char *ret;
+
+ g_return_if_fail (string != NULL);
+ g_return_if_fail (format != NULL);
+
+ ret = g_strdup_vprintf (format, args);
+ g_string_append (string, ret);
+ g_free (ret);
+}
+
+void
+g_string_printf (GString *string, const gchar *format, ...)
+{
+ va_list args;
+
+ g_return_if_fail (string != NULL);
+ g_return_if_fail (format != NULL);
+
+ g_free (string->str);
+
+ va_start (args, format);
+ string->str = g_strdup_vprintf (format, args);
+ va_end (args);
+
+ string->len = strlen (string->str);
+ string->allocated_len = string->len+1;
+}
+
+GString *
+g_string_truncate (GString *string, gsize len)
+{
+ g_return_val_if_fail (string != NULL, string);
+
+ /* Silent return */
+ if (len >= string->len)
+ return string;
+
+ string->len = len;
+ string->str[len] = 0;
+ return string;
+}
+
+GString *
+g_string_set_size (GString *string, gsize len)
+{
+ g_return_val_if_fail (string != NULL, string);
+
+ GROW_IF_NECESSARY(string, len);
+
+ string->len = len;
+ string->str[len] = 0;
+ return string;
+}
+
+GString *
+g_string_erase (GString *string, gssize pos, gssize len)
+{
+ g_return_val_if_fail (string != NULL, string);
+
+ /* Silent return */
+ if (pos >= string->len)
+ return string;
+
+ if (len == -1 || (pos + len) >= string->len) {
+ string->str[pos] = 0;
+ }
+ else {
+ memmove (string->str + pos, string->str + pos + len, string->len - (pos + len) + 1);
+ string->len -= len;
+ }
+
+ return string;
+}
--- /dev/null
+/*
+ * Timer
+ *
+ * Author:
+ * Gonzalo Paniagua Javier (gonzalo@novell.com
+ *
+ * (C) 2006 Novell, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#include <glib.h>
+#include <sys/time.h>
+
+struct _GTimer {
+ struct timeval start;
+ struct timeval stop;
+};
+
+GTimer *g_timer_new (void)
+{
+ GTimer *timer;
+
+ timer = g_new0 (GTimer, 1);
+ g_timer_start (timer);
+ return timer;
+}
+
+void
+g_timer_destroy (GTimer *timer)
+{
+ g_return_if_fail (timer != NULL);
+ g_free (timer);
+}
+
+void
+g_timer_start (GTimer *timer)
+{
+ g_return_if_fail (timer != NULL);
+ gettimeofday (&timer->start, NULL);
+ memset (&timer->stop, 0, sizeof (struct timeval));
+}
+
+void
+g_timer_stop (GTimer *timer)
+{
+ g_return_if_fail (timer != NULL);
+ gettimeofday (&timer->stop, NULL);
+}
+
+gdouble
+g_timer_elapsed (GTimer *timer, gulong *microseconds)
+{
+ struct timeval tv;
+ gulong seconds;
+ long usec;
+ gdouble result;
+
+ g_return_val_if_fail (timer != NULL, 0.0);
+
+ if (timer->stop.tv_sec == 0 && timer->stop.tv_usec == 0) {
+ gettimeofday (&tv, NULL);
+ } else {
+ tv = timer->stop;
+ }
+
+ usec = (tv.tv_usec) - (timer->start.tv_usec);
+ seconds = tv.tv_sec - timer->start.tv_sec;
+ if (microseconds) {
+ if (usec < 0) {
+ usec += 1000000;
+ seconds--;
+ }
+ *microseconds = usec;
+ }
+ result = seconds * 1000000 + usec;
+ return (result / 1000000);
+}
+
+
--- /dev/null
+/*
+ * Timer
+ *
+ * Author:
+ * Gonzalo Paniagua Javier (gonzalo@novell.com
+ *
+ * (C) 2006 Novell, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#include <glib.h>
+#include <windows.h>
+
+struct _GTimer {
+ guint64 start;
+ guint64 stop;
+};
+
+GTimer *g_timer_new (void)
+{
+ GTimer *timer;
+
+ timer = g_new0 (GTimer, 1);
+ g_timer_start (timer);
+ return timer;
+}
+
+void
+g_timer_destroy (GTimer *timer)
+{
+ g_return_if_fail (timer != NULL);
+ g_free (timer);
+}
+
+void
+g_timer_start (GTimer *timer)
+{
+ g_return_if_fail (timer != NULL);
+
+ QueryPerformanceCounter ((LARGE_INTEGER*)&timer->start);
+}
+
+void
+g_timer_stop (GTimer *timer)
+{
+ g_return_if_fail (timer != NULL);
+
+ QueryPerformanceCounter ((LARGE_INTEGER*)&timer->stop);
+}
+
+gdouble
+g_timer_elapsed (GTimer *timer, gulong *microseconds)
+{
+ static guint64 freq = 0;
+ guint64 delta, stop;
+
+ if (freq == 0) {
+ if (!QueryPerformanceFrequency ((LARGE_INTEGER *)&freq))
+ freq = 1;
+ }
+
+ if (timer->stop == 0) {
+ QueryPerformanceCounter ((LARGE_INTEGER*)&stop);
+ }
+ else {
+ stop = timer->stop;
+ }
+
+ delta = stop - timer->start;
+
+ if (microseconds)
+ *microseconds = (gulong) (delta * (1000000.0 / freq));
+
+ return (gdouble) delta / (gdouble) freq;
+}
+
+
--- /dev/null
+/*
+ * gunicode-win32-uwp.c: UWP unicode support.
+ *
+ * Copyright 2016 Microsoft
+ * Licensed under the MIT license. See LICENSE file in the project root for full license information.
+*/
+#include <config.h>
+#include <glib.h>
+
+#if G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT)
+#define CODESET 1
+#include <windows.h>
+
+extern const char *my_charset;
+static gboolean is_utf8;
+
+gboolean
+g_get_charset (G_CONST_RETURN char **charset)
+{
+ if (my_charset == NULL) {
+ static char buf [14];
+ CPINFOEXA cp_info;
+
+ GetCPInfoExA (CP_ACP, 0, &cp_info);
+ sprintf (buf, "CP%u", cp_info.CodePage);
+ my_charset = buf;
+ is_utf8 = FALSE;
+ }
+
+ if (charset != NULL)
+ *charset = my_charset;
+
+ return is_utf8;
+}
+
+#else /* G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT) */
+
+#ifdef _MSC_VER
+// Quiet Visual Studio linker warning, LNK4221, in cases when this source file intentional ends up empty.
+void __mono_win32_gunicode_win32_uwp_quiet_lnk4221(void) {}
+#endif
+#endif /* G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT) */
--- /dev/null
+/*
+ * gunicode-win32.c: Windows unicode support.
+ *
+ * Copyright 2016 Microsoft
+ * Licensed under the MIT license. See LICENSE file in the project root for full license information.
+*/
+#include <config.h>
+#include <glib.h>
+
+#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
+#define CODESET 1
+#include <windows.h>
+
+extern const char *my_charset;
+static gboolean is_utf8;
+
+gboolean
+g_get_charset (G_CONST_RETURN char **charset)
+{
+ if (my_charset == NULL) {
+ static char buf [14];
+ sprintf (buf, "CP%u", GetACP ());
+ my_charset = buf;
+ is_utf8 = FALSE;
+ }
+
+ if (charset != NULL)
+ *charset = my_charset;
+
+ return is_utf8;
+}
+
+#else /* G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) */
+
+#ifdef _MSC_VER
+// Quiet Visual Studio linker warning, LNK4221, in cases when this source file intentional ends up empty.
+void __mono_win32_mono_gunicode_win32_quiet_lnk4221(void) {}
+#endif
+#endif /* G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) */
--- /dev/null
+/*
+ * gunicode.c: Some Unicode routines
+ *
+ * Author:
+ * Miguel de Icaza (miguel@novell.com)
+ *
+ * (C) 2006 Novell, Inc.
+ *
+ * utf8 validation code came from:
+ * libxml2-2.6.26 licensed under the MIT X11 license
+ *
+ * Authors credit in libxml's string.c:
+ * William Brack <wbrack@mmm.com.hk>
+ * daniel@veillard.com
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+#include <config.h>
+#include <stdio.h>
+#include <glib.h>
+#include <unicode-data.h>
+#include <errno.h>
+
+#ifndef G_OS_WIN32
+# ifdef HAVE_LOCALCHARSET_H
+# include <localcharset.h>
+# endif
+#endif
+
+const char *my_charset;
+
+/*
+ * Character set conversion
+ */
+
+GUnicodeType
+g_unichar_type (gunichar c)
+{
+ int i;
+
+ guint16 cp = (guint16) c;
+ for (i = 0; i < unicode_category_ranges_count; i++) {
+ if (cp < unicode_category_ranges [i].start)
+ continue;
+ if (unicode_category_ranges [i].end <= cp)
+ continue;
+ return unicode_category [i] [cp - unicode_category_ranges [i].start];
+ }
+
+ /*
+ // 3400-4DB5: OtherLetter
+ // 4E00-9FC3: OtherLetter
+ // AC00-D7A3: OtherLetter
+ // D800-DFFF: OtherSurrogate
+ // E000-F8FF: OtherPrivateUse
+ // 20000-2A6D6 OtherLetter
+ // F0000-FFFFD OtherPrivateUse
+ // 100000-10FFFD OtherPrivateUse
+ */
+ if (0x3400 <= cp && cp < 0x4DB5)
+ return G_UNICODE_OTHER_LETTER;
+ if (0x4E00 <= cp && cp < 0x9FC3)
+ return G_UNICODE_OTHER_LETTER;
+ if (0xAC00<= cp && cp < 0xD7A3)
+ return G_UNICODE_OTHER_LETTER;
+ if (0xD800 <= cp && cp < 0xDFFF)
+ return G_UNICODE_SURROGATE;
+ if (0xE000 <= cp && cp < 0xF8FF)
+ return G_UNICODE_PRIVATE_USE;
+ /* since the argument is UTF-16, we cannot check beyond FFFF */
+
+ /* It should match any of above */
+ return 0;
+}
+
+GUnicodeBreakType
+g_unichar_break_type (gunichar c)
+{
+ // MOONLIGHT_FIXME
+ return G_UNICODE_BREAK_UNKNOWN;
+}
+
+gunichar
+g_unichar_case (gunichar c, gboolean upper)
+{
+ gint8 i, i2;
+ guint32 cp = (guint32) c, v;
+
+ for (i = 0; i < simple_case_map_ranges_count; i++) {
+ if (cp < simple_case_map_ranges [i].start)
+ return c;
+ if (simple_case_map_ranges [i].end <= cp)
+ continue;
+ if (c < 0x10000) {
+ const guint16 *tab = upper ? simple_upper_case_mapping_lowarea [i] : simple_lower_case_mapping_lowarea [i];
+ v = tab [cp - simple_case_map_ranges [i].start];
+ } else {
+ const guint32 *tab;
+ i2 = (gint8)(i - (upper ? simple_upper_case_mapping_lowarea_table_count : simple_lower_case_mapping_lowarea_table_count));
+ tab = upper ? simple_upper_case_mapping_higharea [i2] : simple_lower_case_mapping_higharea [i2];
+ v = tab [cp - simple_case_map_ranges [i].start];
+ }
+ return v != 0 ? (gunichar) v : c;
+ }
+ return c;
+}
+
+gunichar
+g_unichar_toupper (gunichar c)
+{
+ return g_unichar_case (c, TRUE);
+}
+
+gunichar
+g_unichar_tolower (gunichar c)
+{
+ return g_unichar_case (c, FALSE);
+}
+
+gunichar
+g_unichar_totitle (gunichar c)
+{
+ guint8 i;
+ guint32 cp;
+
+ cp = (guint32) c;
+ for (i = 0; i < simple_titlecase_mapping_count; i++) {
+ if (simple_titlecase_mapping [i].codepoint == cp)
+ return simple_titlecase_mapping [i].title;
+ if (simple_titlecase_mapping [i].codepoint > cp)
+ /* it is ordered, hence no more match */
+ break;
+ }
+ return g_unichar_toupper (c);
+}
+
+gboolean
+g_unichar_isxdigit (gunichar c)
+{
+ return (g_unichar_xdigit_value (c) != -1);
+
+}
+
+gint
+g_unichar_xdigit_value (gunichar c)
+{
+ if (c >= 0x30 && c <= 0x39) /*0-9*/
+ return (c - 0x30);
+ if (c >= 0x41 && c <= 0x46) /*A-F*/
+ return (c - 0x37);
+ if (c >= 0x61 && c <= 0x66) /*a-f*/
+ return (c - 0x57);
+ return -1;
+}
+
+gboolean
+g_unichar_isspace (gunichar c)
+{
+ GUnicodeType type = g_unichar_type (c);
+ if (type == G_UNICODE_LINE_SEPARATOR ||
+ type == G_UNICODE_PARAGRAPH_SEPARATOR ||
+ type == G_UNICODE_SPACE_SEPARATOR)
+ return TRUE;
+
+ return FALSE;
+}
+
+
+/*
+ * This is broken, and assumes an UTF8 system, but will do for eglib's first user
+ */
+gchar *
+g_filename_from_utf8 (const gchar *utf8string, gssize len, gsize *bytes_read, gsize *bytes_written, GError **error)
+{
+ char *res;
+
+ if (len == -1)
+ len = strlen (utf8string);
+
+ res = g_malloc (len + 1);
+ g_strlcpy (res, utf8string, len + 1);
+ return res;
+}
+
+#ifndef G_OS_WIN32
+static gboolean is_utf8;
+
+gboolean
+g_get_charset (G_CONST_RETURN char **charset)
+{
+ if (my_charset == NULL) {
+ /* These shouldn't be heap allocated */
+#if defined(HAVE_LOCALCHARSET_H)
+ my_charset = locale_charset ();
+#else
+ my_charset = "UTF-8";
+#endif
+ is_utf8 = strcmp (my_charset, "UTF-8") == 0;
+ }
+
+ if (charset != NULL)
+ *charset = my_charset;
+
+ return is_utf8;
+}
+#endif /* G_OS_WIN32 */
+
+gchar *
+g_locale_to_utf8 (const gchar *opsysstring, gssize len, gsize *bytes_read, gsize *bytes_written, GError **error)
+{
+ g_get_charset (NULL);
+
+ return g_convert (opsysstring, len, "UTF-8", my_charset, bytes_read, bytes_written, error);
+}
+
+gchar *
+g_locale_from_utf8 (const gchar *utf8string, gssize len, gsize *bytes_read, gsize *bytes_written, GError **error)
+{
+ g_get_charset (NULL);
+
+ return g_convert (utf8string, len, my_charset, "UTF-8", bytes_read, bytes_written, error);
+}
--- /dev/null
+/*
+ * gutf8.c: UTF-8 conversion
+ *
+ * Author:
+ * Atsushi Enomoto <atsushi@ximian.com>
+ *
+ * (C) 2006 Novell, Inc.
+ * Copyright 2012 Xamarin Inc
+ */
+
+#include <stdio.h>
+#include <glib.h>
+
+/*
+ * Index into the table below with the first byte of a UTF-8 sequence to get
+ * the number of bytes that are supposed to follow it to complete the sequence.
+ *
+ * Note that *legal* UTF-8 values can't have 4 or 5-bytes. The table is left
+ * as-is for anyone who may want to do such conversion, which was allowed in
+ * earlier algorithms.
+*/
+const guchar g_utf8_jump_table[256] = {
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
+ 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
+ 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, 4,4,4,4,4,4,4,4,5,5,5,5,6,6,1,1
+};
+
+static gchar *
+utf8_case_conv (const gchar *str, gssize len, gboolean upper)
+{
+ gunichar *ustr;
+ glong i, ulen;
+ gchar *utf8;
+
+ ustr = g_utf8_to_ucs4_fast (str, (glong) len, &ulen);
+ for (i = 0; i < ulen; i++)
+ ustr[i] = upper ? g_unichar_toupper (ustr[i]) : g_unichar_tolower (ustr[i]);
+ utf8 = g_ucs4_to_utf8 (ustr, ulen, NULL, NULL, NULL);
+ g_free (ustr);
+
+ return utf8;
+}
+
+gchar *
+g_utf8_strup (const gchar *str, gssize len)
+{
+ return utf8_case_conv (str, len, TRUE);
+}
+
+gchar *
+g_utf8_strdown (const gchar *str, gssize len)
+{
+ return utf8_case_conv (str, len, FALSE);
+}
+
+static gboolean
+utf8_validate (const unsigned char *inptr, size_t len)
+{
+ const unsigned char *ptr = inptr + len;
+ unsigned char c;
+
+ /* Everything falls through when TRUE... */
+ switch (len) {
+ default:
+ return FALSE;
+ case 4:
+ if ((c = (*--ptr)) < 0x80 || c > 0xBF)
+ return FALSE;
+
+ if ((c == 0xBF || c == 0xBE) && ptr[-1] == 0xBF) {
+ if (ptr[-2] == 0x8F || ptr[-2] == 0x9F ||
+ ptr[-2] == 0xAF || ptr[-2] == 0xBF)
+ return FALSE;
+ }
+ case 3:
+ if ((c = (*--ptr)) < 0x80 || c > 0xBF)
+ return FALSE;
+ case 2:
+ if ((c = (*--ptr)) < 0x80 || c > 0xBF)
+ return FALSE;
+
+ /* no fall-through in this inner switch */
+ switch (*inptr) {
+ case 0xE0: if (c < 0xA0) return FALSE; break;
+ case 0xED: if (c > 0x9F) return FALSE; break;
+ case 0xEF: if (c == 0xB7 && (ptr[1] > 0x8F && ptr[1] < 0xB0)) return FALSE;
+ if (c == 0xBF && (ptr[1] == 0xBE || ptr[1] == 0xBF)) return FALSE;
+ break;
+ case 0xF0: if (c < 0x90) return FALSE; break;
+ case 0xF4: if (c > 0x8F) return FALSE; break;
+ default: if (c < 0x80) return FALSE; break;
+ }
+ case 1: if (*inptr >= 0x80 && *inptr < 0xC2) return FALSE;
+ }
+
+ if (*inptr > 0xF4)
+ return FALSE;
+
+ return TRUE;
+}
+
+/**
+ * g_utf8_validate:
+ * @str: a utf-8 encoded string
+ * @max_len: max number of bytes to validate (or -1 to validate the entire null-terminated string)
+ * @end: output parameter to mark the end of the valid input
+ *
+ * Checks @utf for being valid UTF-8. @str is assumed to be
+ * null-terminated. This function is not super-strict, as it will
+ * allow longer UTF-8 sequences than necessary. Note that Java is
+ * capable of producing these sequences if provoked. Also note, this
+ * routine checks for the 4-byte maximum size, but does not check for
+ * 0x10ffff maximum value.
+ *
+ * Return value: %TRUE if @str is valid or %FALSE otherwise.
+ **/
+gboolean
+g_utf8_validate (const gchar *str, gssize max_len, const gchar **end)
+{
+ guchar *inptr = (guchar *) str;
+ gboolean valid = TRUE;
+ guint length, min;
+ gssize n = 0;
+
+ if (max_len == 0)
+ return FALSE;
+
+ if (max_len < 0) {
+ while (*inptr != 0) {
+ length = g_utf8_jump_table[*inptr];
+ if (!utf8_validate (inptr, length)) {
+ valid = FALSE;
+ break;
+ }
+
+ inptr += length;
+ }
+ } else {
+ while (n < max_len) {
+ if (*inptr == 0) {
+ /* Note: return FALSE if we encounter nul-byte
+ * before max_len is reached. */
+ valid = FALSE;
+ break;
+ }
+
+ length = g_utf8_jump_table[*inptr];
+ min = MIN (length, max_len - n);
+
+ if (!utf8_validate (inptr, min)) {
+ valid = FALSE;
+ break;
+ }
+
+ if (min < length) {
+ valid = FALSE;
+ break;
+ }
+
+ inptr += length;
+ n += length;
+ }
+ }
+
+ if (end != NULL)
+ *end = (gchar *) inptr;
+
+ return valid;
+}
+
+gunichar
+g_utf8_get_char_validated (const gchar *str, gssize max_len)
+{
+ unsigned char *inptr = (unsigned char *) str;
+ gunichar u = *inptr;
+ int n, i;
+
+ if (max_len == 0)
+ return -2;
+
+ if (u < 0x80) {
+ /* simple ascii case */
+ return u;
+ } else if (u < 0xc2) {
+ return -1;
+ } else if (u < 0xe0) {
+ u &= 0x1f;
+ n = 2;
+ } else if (u < 0xf0) {
+ u &= 0x0f;
+ n = 3;
+ } else if (u < 0xf8) {
+ u &= 0x07;
+ n = 4;
+ } else if (u < 0xfc) {
+ u &= 0x03;
+ n = 5;
+ } else if (u < 0xfe) {
+ u &= 0x01;
+ n = 6;
+ } else {
+ return -1;
+ }
+
+ if (max_len > 0) {
+ if (!utf8_validate (inptr, MIN (max_len, n)))
+ return -1;
+
+ if (max_len < n)
+ return -2;
+ } else {
+ if (!utf8_validate (inptr, n))
+ return -1;
+ }
+
+ for (i = 1; i < n; i++)
+ u = (u << 6) | (*++inptr ^ 0x80);
+
+ return u;
+}
+
+glong
+g_utf8_strlen (const gchar *str, gssize max_len)
+{
+ const guchar *inptr = (const guchar *) str;
+ glong clen = 0, len = 0, n;
+
+ if (max_len == 0)
+ return 0;
+
+ if (max_len < 0) {
+ while (*inptr) {
+ inptr += g_utf8_jump_table[*inptr];
+ len++;
+ }
+ } else {
+ while (len < max_len && *inptr) {
+ n = g_utf8_jump_table[*inptr];
+ if ((clen + n) > max_len)
+ break;
+
+ inptr += n;
+ clen += n;
+ len++;
+ }
+ }
+
+ return len;
+}
+
+gunichar
+g_utf8_get_char (const gchar *src)
+{
+ unsigned char *inptr = (unsigned char *) src;
+ gunichar u = *inptr;
+ int n, i;
+
+ if (u < 0x80) {
+ /* simple ascii case */
+ return u;
+ } else if (u < 0xe0) {
+ u &= 0x1f;
+ n = 2;
+ } else if (u < 0xf0) {
+ u &= 0x0f;
+ n = 3;
+ } else if (u < 0xf8) {
+ u &= 0x07;
+ n = 4;
+ } else if (u < 0xfc) {
+ u &= 0x03;
+ n = 5;
+ } else {
+ u &= 0x01;
+ n = 6;
+ }
+
+ for (i = 1; i < n; i++)
+ u = (u << 6) | (*++inptr ^ 0x80);
+
+ return u;
+}
+
+gchar *
+g_utf8_find_prev_char (const gchar *str, const gchar *p)
+{
+ while (p > str) {
+ p--;
+ if ((*p & 0xc0) != 0xb0)
+ return (gchar *)p;
+ }
+ return NULL;
+}
+
+gchar *
+g_utf8_prev_char (const gchar *str)
+{
+ const gchar *p = str;
+ do {
+ p--;
+ } while ((*p & 0xc0) == 0xb0);
+
+ return (gchar *)p;
+}
+
+gchar *
+g_utf8_offset_to_pointer (const gchar *str, glong offset)
+{
+ const gchar *p = str;
+
+ if (offset > 0) {
+ do {
+ p = g_utf8_next_char (p);
+ offset --;
+ } while (offset > 0);
+ }
+ else if (offset < 0) {
+ const gchar *jump = str;
+ do {
+ // since the minimum size of a character is 1
+ // we know we can step back at least offset bytes
+ jump = jump + offset;
+
+ // if we land in the middle of a character
+ // walk to the beginning
+ while ((*jump & 0xc0) == 0xb0)
+ jump --;
+
+ // count how many characters we've actually walked
+ // by going forward
+ p = jump;
+ do {
+ p = g_utf8_next_char (p);
+ offset ++;
+ } while (p < jump);
+
+ } while (offset < 0);
+ }
+
+ return (gchar *)p;
+}
+
+glong
+g_utf8_pointer_to_offset (const gchar *str, const gchar *pos)
+{
+ const gchar *inptr, *inend;
+ glong offset = 0;
+ glong sign = 1;
+
+ if (pos == str)
+ return 0;
+
+ if (str < pos) {
+ inptr = str;
+ inend = pos;
+ } else {
+ inptr = pos;
+ inend = str;
+ sign = -1;
+ }
+
+ do {
+ inptr = g_utf8_next_char (inptr);
+ offset++;
+ } while (inptr < inend);
+
+ return offset * sign;
+}
--- /dev/null
+/*
+ * sort.frag.h: Common implementation of linked-list sorting
+ *
+ * Author:
+ * Raja R Harinath (rharinath@novell.com)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * (C) 2006 Novell, Inc.
+ */
+
+/*
+ * This code requires a typedef named 'list_node' for the list node. It
+ * is assumed that the list type is the type of a pointer to a list
+ * node, and that the node has a field named 'next' that implements to
+ * the linked list. No additional invariant is maintained (e.g. the
+ * 'prev' pointer of a doubly-linked list node is _not_ updated). Any
+ * invariant would require a post-processing pass to fix matters if
+ * necessary.
+ */
+typedef list_node *digit;
+
+/*
+ * The maximum possible depth of the merge tree
+ * = ceiling (log2 (maximum number of list nodes))
+ * = ceiling (log2 (maximum possible memory size/size of each list node))
+ * = number of bits in 'size_t' - floor (log2 (sizeof digit))
+ * Also, each list in sort_info is at least 2 nodes long: we can reduce the depth by 1
+ */
+#define FLOOR_LOG2(x) (((x)>=2) + ((x)>=4) + ((x)>=8) + ((x)>=16) + ((x)>=32) + ((x)>=64) + ((x)>=128))
+#define MAX_RANKS ((sizeof (size_t) * 8) - FLOOR_LOG2(sizeof (list_node)) - 1)
+
+struct sort_info
+{
+ int min_rank, n_ranks;
+ GCompareFunc func;
+
+ /* Invariant: ranks[i] == NULL || length(ranks[i]) >= 2**(i+1) */
+ list_node *ranks [MAX_RANKS]; /* ~ 128 bytes on 32bit, ~ 512 bytes on 64bit */
+};
+
+static inline void
+init_sort_info (struct sort_info *si, GCompareFunc func)
+{
+ si->min_rank = si->n_ranks = 0;
+ si->func = func;
+ /* we don't need to initialize si->ranks, since we never lookup past si->n_ranks. */
+}
+
+static inline list_node *
+merge_lists (list_node *first, list_node *second, GCompareFunc func)
+{
+ /* merge the two lists */
+ list_node *list = NULL;
+ list_node **pos = &list;
+ while (first && second) {
+ if (func (first->data, second->data) > 0) {
+ *pos = second;
+ second = second->next;
+ } else {
+ *pos = first;
+ first = first->next;
+ }
+ pos = &((*pos)->next);
+ }
+ *pos = first ? first : second;
+ return list;
+}
+
+/* Pre-condition: upto <= si->n_ranks, list == NULL || length(list) == 1 */
+static inline list_node *
+sweep_up (struct sort_info *si, list_node *list, int upto)
+{
+#if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 406)
+ /*
+ * GCC incorrectly thinks we're writing below si->ranks array bounds.
+ */
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Warray-bounds"
+#endif
+
+ int i;
+ for (i = si->min_rank; i < upto; ++i) {
+ list = merge_lists (si->ranks [i], list, si->func);
+ si->ranks [i] = NULL;
+ }
+ return list;
+
+#if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 406)
+#pragma GCC diagnostic pop
+#endif
+}
+
+/*
+ * The 'ranks' array essentially captures the recursion stack of a mergesort.
+ * The merge tree is built in a bottom-up manner. The control loop for
+ * updating the 'ranks' array is analogous to incrementing a binary integer,
+ * and the O(n) time for counting upto n translates to O(n) merges when
+ * inserting rank-0 lists. When we plug in the sizes of the lists involved in
+ * those merges, we get the O(n log n) time for the sort.
+ *
+ * Inserting higher-ranked lists reduce the height of the merge tree, and also
+ * eliminate a lot of redundant comparisons when merging two lists that would've
+ * been part of the same run. Adding a rank-i list is analogous to incrementing
+ * a binary integer by 2**i in one operation, thus sharing a similar speedup.
+ *
+ * When inserting higher-ranked lists, we choose to clear out the lower ranks
+ * in the interests of keeping the sort stable, but this makes analysis harder.
+ * Note that clearing the lower-ranked lists is O(length(list))-- thus it
+ * shouldn't affect the O(n log n) behaviour. IOW, inserting one rank-i list
+ * is equivalent to inserting 2**i rank-0 lists, thus even if we do i additional
+ * merges in the clearing-out (taking at most 2**i time) we are still fine.
+ */
+
+#define stringify2(x) #x
+#define stringify(x) stringify2(x)
+
+/* Pre-condition: 2**(rank+1) <= length(list) < 2**(rank+2) (therefore: length(list) >= 2) */
+static inline void
+insert_list (struct sort_info *si, list_node* list, int rank)
+{
+#if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 406)
+ /*
+ * GCC incorrectly thinks we're writing below si->ranks array bounds.
+ */
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Warray-bounds"
+#endif
+
+ int i;
+
+ if (rank > si->n_ranks) {
+ if (rank > MAX_RANKS) {
+ g_warning ("Rank '%d' should not exceed " stringify (MAX_RANKS), rank);
+ rank = MAX_RANKS;
+ }
+ list = merge_lists (sweep_up (si, NULL, si->n_ranks), list, si->func);
+ for (i = si->n_ranks; i < rank; ++i)
+ si->ranks [i] = NULL;
+ } else {
+ if (rank)
+ list = merge_lists (sweep_up (si, NULL, rank), list, si->func);
+ for (i = rank; i < si->n_ranks && si->ranks [i]; ++i) {
+ list = merge_lists (si->ranks [i], list, si->func);
+ si->ranks [i] = NULL;
+ }
+ }
+
+ if (i == MAX_RANKS) /* Will _never_ happen: so we can just devolve into quadratic ;-) */
+ --i;
+ if (i >= si->n_ranks)
+ si->n_ranks = i + 1;
+ si->min_rank = i;
+ si->ranks [i] = list;
+
+#if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 406)
+#pragma GCC diagnostic pop
+#endif
+}
+
+#undef stringify2
+#undef stringify
+#undef MAX_RANKS
+#undef FLOOR_LOG2
+
+/* A non-recursive mergesort */
+static inline digit
+do_sort (list_node* list, GCompareFunc func)
+{
+ struct sort_info si;
+
+ init_sort_info (&si, func);
+
+ while (list && list->next) {
+ list_node* next = list->next;
+ list_node* tail = next->next;
+
+ if (func (list->data, next->data) > 0) {
+ next->next = list;
+ next = list;
+ list = list->next;
+ }
+ next->next = NULL;
+
+ insert_list (&si, list, 0);
+
+ list = tail;
+ }
+
+ return sweep_up (&si, list, si.n_ranks);
+}
--- /dev/null
+/Makefile
+/Makefile.in
+/.libs
+/.deps
+/*.lo
+/*.la
+/*.o
+/semantic.cache
+/.project
+/.cproject
+/test-eglib
+/test-glib
--- /dev/null
+EXTRA_DIST = UTF-8.txt UTF-16BE.txt UTF-16LE.txt UTF-32BE.txt UTF-32LE.txt
+
+SOURCES = \
+ test.c \
+ test.h \
+ tests.h \
+ driver.c \
+ hashtable.c \
+ string-util.c \
+ string.c \
+ slist.c \
+ sizes.c \
+ ptrarray.c \
+ list.c \
+ array.c \
+ fake.c \
+ path.c \
+ queue.c \
+ shell.c \
+ spawn.c \
+ timer.c \
+ file.c \
+ pattern.c \
+ dir.c \
+ markup.c \
+ unicode.c \
+ utf8.c \
+ endian.c \
+ module.c \
+ memory.c
+
+test_eglib_SOURCES = $(SOURCES)
+
+test_eglib_CFLAGS = -Wall -DEGLIB_TESTS=1 -D_FORTIFY_SOURCE=2 -I$(srcdir)/../src -I../src -DDRIVER_NAME=\"EGlib\"
+test_eglib_LDADD = ../src/libeglib.la $(LIBICONV)
+
+run-eglib: all
+ srcdir=`readlink -f $(srcdir)` ./test-eglib
+
+noinst_PROGRAMS = test-eglib
+
+run-both: run-eglib
+
+MAINTAINERCLEANFILES = Makefile.in
--- /dev/null
+EGlib Unit Testing
+===============================================================================
+
+ 1. Writing new tests
+ 2. Using the test driver
+
+===============================================================================
+1. Writing new tests
+===============================================================================
+
+Tests are easy to write, but must be grouped in to logical cases. For instance,
+the GPtrArray group has a number of tests that cover the entire GPtrArray
+implementation.
+
+These logical case groups should be in a single C file, and must have
+three elements:
+
+ #include <glib.h>
+ #include "test.h"
+
+ ...
+ <define test implementations>
+ ...
+
+ static Test groupname_tests [] = {
+ {"groupname_test1", groupname_test1},
+ {"groupname_test1", groupname_test2},
+ {NULL, NULL}
+ };
+
+ DEFINE_TEST_GROUP_INIT(groupname_tests_init, groupname_tests)
+
+A test implementation should look like:
+
+ RESULT groupname_test1()
+ {
+ <perform the test>
+
+ if(test_failed) {
+ return FAILED("reason: %s", "this works like printf");
+ }
+
+ return OK; /* just NULL, but OK is cute */
+ }
+
+Once a test group is written, it needs to be added to the groups table
+in tests.h:
+
+ DEFINE_TEST_GROUP_INIT_H(groupname_tests_init) // same as in impl
+
+ static Group test_groups [] = {
+ ...
+ {"groupname", groupname_tests_init}
+ ...
+ };
+
+===============================================================================
+2. Using the test driver
+===============================================================================
+
+When tests are written, they are rebuilt with make. Two programs will be
+built:
+
+ test-eglib: the test driver and tests linked against eglib
+ test-glib: the test driver and tests linked against system glib-2.0
+
+Each driver program works exactly the same. Running test-eglib will run
+the tests against eglib, and test-glib against glib-2.0.
+
+The test driver supports a few options to allow for performance measuring:
+
+ --help show all options and available test groups
+ --time time the overall run and report it, even if --quiet is set
+ --quiet do not print test results, useful for timing
+ --iterations N run all or specified test groups N times
+
+Run "test-eglib --help" for more details.
+
+Example: run the ptrarray test group 100000 times and only print the time
+ it took to perform all iterations
+
+ ./test-eglib -tqi 100000 ptrarray
+
+Example: show single iteration of test output for two groups
+
+ ./test-eglib ptrarray hashtable
+
+Example: show test output of all available groups
+
+ ./test-eglib
+
+The 'test-both' script can be used to run both test-eglib and test-glib
+with the same options back to back:
+
+ $ ./test-both -tqi 100000 ptrarray
+ EGlib Total Time: 1.1961s
+ GLib Total Time: 0.955957s
+
+test-both also has a nice --speed-compare mode that shows comparison
+information about EGlib vs GLib. It can run all tests or specific tests
+with a configurable number of iterations. --speed-compare mode always runs
+the drivers with -qtni
+
+The syntax for --speed-compare is:
+
+ ./test-both --speed-compare [ITERATIONS] [GROUPS...]
+
+ $ ./test-both --speed-compare Runs all tests with default iterations
+ $ ./test-both --speed-compare 500 Runs all tests with 500 iterations
+ $ ./test-both --speed-compare ptrarray Runs ptrarray test with default
+ iterations
+
+
--- /dev/null
+
+UTF-8 encoded sample plain-text file
+‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
+
+Markus Kuhn [ˈmaʳkʊs kuːn] <http://www.cl.cam.ac.uk/~mgk25/> — 2002-07-25
+
+
+The ASCII compatible UTF-8 encoding used in this plain-text file
+is defined in Unicode, ISO 10646-1, and RFC 2279.
+
+
+Using Unicode/UTF-8, you can write in emails and source code things such as
+
+Mathematics and sciences:
+
+ ∮ E⋅da = Q, n → ∞, ∑ f(i) = ∏ g(i), ⎧⎡⎛┌─────┐⎞⎤⎫
+ ⎪⎢⎜│a²+b³ ⎟⎥⎪
+ ∀x∈ℝ: ⌈x⌉ = −⌊−x⌋, α ∧ ¬β = ¬(¬α ∨ β), ⎪⎢⎜│───── ⎟⎥⎪
+ ⎪⎢⎜⎷ c₈ ⎟⎥⎪
+ ℕ ⊆ ℕ₀ ⊂ ℤ ⊂ ℚ ⊂ ℝ ⊂ ℂ, ⎨⎢⎜ ⎟⎥⎬
+ ⎪⎢⎜ ∞ ⎟⎥⎪
+ ⊥ < a ≠ b ≡ c ≤ d ≪ ⊤ ⇒ (⟦A⟧ ⇔ ⟪B⟫), ⎪⎢⎜ ⎲ ⎟⎥⎪
+ ⎪⎢⎜ ⎳aⁱ-bⁱ⎟⎥⎪
+ 2H₂ + O₂ ⇌ 2H₂O, R = 4.7 kΩ, ⌀ 200 mm ⎩⎣⎝i=1 ⎠⎦⎭
+
+Linguistics and dictionaries:
+
+ ði ıntəˈnæʃənəl fəˈnɛtık əsoʊsiˈeıʃn
+ Y [ˈʏpsilɔn], Yen [jɛn], Yoga [ˈjoːgɑ]
+
+APL:
+
+ ((V⍳V)=⍳⍴V)/V←,V ⌷←⍳→⍴∆∇⊃‾⍎⍕⌈
+
+Nicer typography in plain text files:
+
+ ╔══════════════════════════════════════════╗
+ ║ ║
+ ║ • ‘single’ and “double” quotes ║
+ ║ ║
+ ║ • Curly apostrophes: “We’ve been here” ║
+ ║ ║
+ ║ • Latin-1 apostrophe and accents: '´` ║
+ ║ ║
+ ║ • ‚deutsche‘ „Anführungszeichen“ ║
+ ║ ║
+ ║ • †, ‡, ‰, •, 3–4, —, −5/+5, ™, … ║
+ ║ ║
+ ║ • ASCII safety test: 1lI|, 0OD, 8B ║
+ ║ ╭─────────╮ ║
+ ║ • the euro symbol: │ 14.95 € │ ║
+ ║ ╰─────────╯ ║
+ ╚══════════════════════════════════════════╝
+
+Combining characters:
+
+ STARGΛ̊TE SG-1, a = v̇ = r̈, a⃑ ⊥ b⃑
+
+Greek (in Polytonic):
+
+ The Greek anthem:
+
+ Σὲ γνωρίζω ἀπὸ τὴν κόψη
+ τοῦ σπαθιοῦ τὴν τρομερή,
+ σὲ γνωρίζω ἀπὸ τὴν ὄψη
+ ποὺ μὲ βία μετράει τὴ γῆ.
+
+ ᾿Απ᾿ τὰ κόκκαλα βγαλμένη
+ τῶν ῾Ελλήνων τὰ ἱερά
+ καὶ σὰν πρῶτα ἀνδρειωμένη
+ χαῖρε, ὦ χαῖρε, ᾿Ελευθεριά!
+
+ From a speech of Demosthenes in the 4th century BC:
+
+ Οὐχὶ ταὐτὰ παρίσταταί μοι γιγνώσκειν, ὦ ἄνδρες ᾿Αθηναῖοι,
+ ὅταν τ᾿ εἰς τὰ πράγματα ἀποβλέψω καὶ ὅταν πρὸς τοὺς
+ λόγους οὓς ἀκούω· τοὺς μὲν γὰρ λόγους περὶ τοῦ
+ τιμωρήσασθαι Φίλιππον ὁρῶ γιγνομένους, τὰ δὲ πράγματ᾿
+ εἰς τοῦτο προήκοντα, ὥσθ᾿ ὅπως μὴ πεισόμεθ᾿ αὐτοὶ
+ πρότερον κακῶς σκέψασθαι δέον. οὐδέν οὖν ἄλλο μοι δοκοῦσιν
+ οἱ τὰ τοιαῦτα λέγοντες ἢ τὴν ὑπόθεσιν, περὶ ἧς βουλεύεσθαι,
+ οὐχὶ τὴν οὖσαν παριστάντες ὑμῖν ἁμαρτάνειν. ἐγὼ δέ, ὅτι μέν
+ ποτ᾿ ἐξῆν τῇ πόλει καὶ τὰ αὑτῆς ἔχειν ἀσφαλῶς καὶ Φίλιππον
+ τιμωρήσασθαι, καὶ μάλ᾿ ἀκριβῶς οἶδα· ἐπ᾿ ἐμοῦ γάρ, οὐ πάλαι
+ γέγονεν ταῦτ᾿ ἀμφότερα· νῦν μέντοι πέπεισμαι τοῦθ᾿ ἱκανὸν
+ προλαβεῖν ἡμῖν εἶναι τὴν πρώτην, ὅπως τοὺς συμμάχους
+ σώσομεν. ἐὰν γὰρ τοῦτο βεβαίως ὑπάρξῃ, τότε καὶ περὶ τοῦ
+ τίνα τιμωρήσεταί τις καὶ ὃν τρόπον ἐξέσται σκοπεῖν· πρὶν δὲ
+ τὴν ἀρχὴν ὀρθῶς ὑποθέσθαι, μάταιον ἡγοῦμαι περὶ τῆς
+ τελευτῆς ὁντινοῦν ποιεῖσθαι λόγον.
+
+ Δημοσθένους, Γ´ ᾿Ολυνθιακὸς
+
+Georgian:
+
+ From a Unicode conference invitation:
+
+ გთხოვთ ახლავე გაიაროთ რეგისტრაცია Unicode-ის მეათე საერთაშორისო
+ კონფერენციაზე დასასწრებად, რომელიც გაიმართება 10-12 მარტს,
+ ქ. მაინცში, გერმანიაში. კონფერენცია შეჰკრებს ერთად მსოფლიოს
+ ექსპერტებს ისეთ დარგებში როგორიცაა ინტერნეტი და Unicode-ი,
+ ინტერნაციონალიზაცია და ლოკალიზაცია, Unicode-ის გამოყენება
+ ოპერაციულ სისტემებსა, და გამოყენებით პროგრამებში, შრიფტებში,
+ ტექსტების დამუშავებასა და მრავალენოვან კომპიუტერულ სისტემებში.
+
+Russian:
+
+ From a Unicode conference invitation:
+
+ Зарегистрируйтесь сейчас на Десятую Международную Конференцию по
+ Unicode, которая состоится 10-12 марта 1997 года в Майнце в Германии.
+ Конференция соберет широкий круг экспертов по вопросам глобального
+ Интернета и Unicode, локализации и интернационализации, воплощению и
+ применению Unicode в различных операционных системах и программных
+ приложениях, шрифтах, верстке и многоязычных компьютерных системах.
+
+Thai (UCS Level 2):
+
+ Excerpt from a poetry on The Romance of The Three Kingdoms (a Chinese
+ classic 'San Gua'):
+
+ [----------------------------|------------------------]
+ ๏ แผ่นดินฮั่นเสื่อมโทรมแสนสังเวช พระปกเกศกองบู๊กู้ขึ้นใหม่
+ สิบสองกษัตริย์ก่อนหน้าแลถัดไป สององค์ไซร้โง่เขลาเบาปัญญา
+ ทรงนับถือขันทีเป็นที่พึ่ง บ้านเมืองจึงวิปริตเป็นนักหนา
+ โฮจิ๋นเรียกทัพทั่วหัวเมืองมา หมายจะฆ่ามดชั่วตัวสำคัญ
+ เหมือนขับไสไล่เสือจากเคหา รับหมาป่าเข้ามาเลยอาสัญ
+ ฝ่ายอ้องอุ้นยุแยกให้แตกกัน ใช้สาวนั้นเป็นชนวนชื่นชวนใจ
+ พลันลิฉุยกุยกีกลับก่อเหตุ ช่างอาเพศจริงหนาฟ้าร้องไห้
+ ต้องรบราฆ่าฟันจนบรรลัย ฤๅหาใครค้ำชูกู้บรรลังก์ ฯ
+
+ (The above is a two-column text. If combining characters are handled
+ correctly, the lines of the second column should be aligned with the
+ | character above.)
+
+Ethiopian:
+
+ Proverbs in the Amharic language:
+
+ ሰማይ አይታረስ ንጉሥ አይከሰስ።
+ ብላ ካለኝ እንደአባቴ በቆመጠኝ።
+ ጌጥ ያለቤቱ ቁምጥና ነው።
+ ደሀ በሕልሙ ቅቤ ባይጠጣ ንጣት በገደለው።
+ የአፍ ወለምታ በቅቤ አይታሽም።
+ አይጥ በበላ ዳዋ ተመታ።
+ ሲተረጉሙ ይደረግሙ።
+ ቀስ በቀስ፥ ዕንቁላል በእግሩ ይሄዳል።
+ ድር ቢያብር አንበሳ ያስር።
+ ሰው እንደቤቱ እንጅ እንደ ጉረቤቱ አይተዳደርም።
+ እግዜር የከፈተውን ጉሮሮ ሳይዘጋው አይድርም።
+ የጎረቤት ሌባ፥ ቢያዩት ይስቅ ባያዩት ያጠልቅ።
+ ሥራ ከመፍታት ልጄን ላፋታት።
+ ዓባይ ማደሪያ የለው፥ ግንድ ይዞ ይዞራል።
+ የእስላም አገሩ መካ የአሞራ አገሩ ዋርካ።
+ ተንጋሎ ቢተፉ ተመልሶ ባፉ።
+ ወዳጅህ ማር ቢሆን ጨርስህ አትላሰው።
+ እግርህን በፍራሽህ ልክ ዘርጋ።
+
+Runes:
+
+ ᚻᛖ ᚳᚹᚫᚦ ᚦᚫᛏ ᚻᛖ ᛒᚢᛞᛖ ᚩᚾ ᚦᚫᛗ ᛚᚪᚾᛞᛖ ᚾᚩᚱᚦᚹᛖᚪᚱᛞᚢᛗ ᚹᛁᚦ ᚦᚪ ᚹᛖᛥᚫ
+
+ (Old English, which transcribed into Latin reads 'He cwaeth that he
+ bude thaem lande northweardum with tha Westsae.' and means 'He said
+ that he lived in the northern land near the Western Sea.')
+
+Braille:
+
+ ⡌⠁⠧⠑ ⠼⠁⠒ ⡍⠜⠇⠑⠹⠰⠎ ⡣⠕⠌
+
+ ⡍⠜⠇⠑⠹ ⠺⠁⠎ ⠙⠑⠁⠙⠒ ⠞⠕ ⠃⠑⠛⠔ ⠺⠊⠹⠲ ⡹⠻⠑ ⠊⠎ ⠝⠕ ⠙⠳⠃⠞
+ ⠱⠁⠞⠑⠧⠻ ⠁⠃⠳⠞ ⠹⠁⠞⠲ ⡹⠑ ⠗⠑⠛⠊⠌⠻ ⠕⠋ ⠙⠊⠎ ⠃⠥⠗⠊⠁⠇ ⠺⠁⠎
+ ⠎⠊⠛⠝⠫ ⠃⠹ ⠹⠑ ⠊⠇⠻⠛⠹⠍⠁⠝⠂ ⠹⠑ ⠊⠇⠻⠅⠂ ⠹⠑ ⠥⠝⠙⠻⠞⠁⠅⠻⠂
+ ⠁⠝⠙ ⠹⠑ ⠡⠊⠑⠋ ⠍⠳⠗⠝⠻⠲ ⡎⠊⠗⠕⠕⠛⠑ ⠎⠊⠛⠝⠫ ⠊⠞⠲ ⡁⠝⠙
+ ⡎⠊⠗⠕⠕⠛⠑⠰⠎ ⠝⠁⠍⠑ ⠺⠁⠎ ⠛⠕⠕⠙ ⠥⠏⠕⠝ ⠰⡡⠁⠝⠛⠑⠂ ⠋⠕⠗ ⠁⠝⠹⠹⠔⠛ ⠙⠑
+ ⠡⠕⠎⠑ ⠞⠕ ⠏⠥⠞ ⠙⠊⠎ ⠙⠁⠝⠙ ⠞⠕⠲
+
+ ⡕⠇⠙ ⡍⠜⠇⠑⠹ ⠺⠁⠎ ⠁⠎ ⠙⠑⠁⠙ ⠁⠎ ⠁ ⠙⠕⠕⠗⠤⠝⠁⠊⠇⠲
+
+ ⡍⠔⠙⠖ ⡊ ⠙⠕⠝⠰⠞ ⠍⠑⠁⠝ ⠞⠕ ⠎⠁⠹ ⠹⠁⠞ ⡊ ⠅⠝⠪⠂ ⠕⠋ ⠍⠹
+ ⠪⠝ ⠅⠝⠪⠇⠫⠛⠑⠂ ⠱⠁⠞ ⠹⠻⠑ ⠊⠎ ⠏⠜⠞⠊⠊⠥⠇⠜⠇⠹ ⠙⠑⠁⠙ ⠁⠃⠳⠞
+ ⠁ ⠙⠕⠕⠗⠤⠝⠁⠊⠇⠲ ⡊ ⠍⠊⠣⠞ ⠙⠁⠧⠑ ⠃⠑⠲ ⠔⠊⠇⠔⠫⠂ ⠍⠹⠎⠑⠇⠋⠂ ⠞⠕
+ ⠗⠑⠛⠜⠙ ⠁ ⠊⠕⠋⠋⠔⠤⠝⠁⠊⠇ ⠁⠎ ⠹⠑ ⠙⠑⠁⠙⠑⠌ ⠏⠊⠑⠊⠑ ⠕⠋ ⠊⠗⠕⠝⠍⠕⠝⠛⠻⠹
+ ⠔ ⠹⠑ ⠞⠗⠁⠙⠑⠲ ⡃⠥⠞ ⠹⠑ ⠺⠊⠎⠙⠕⠍ ⠕⠋ ⠳⠗ ⠁⠝⠊⠑⠌⠕⠗⠎
+ ⠊⠎ ⠔ ⠹⠑ ⠎⠊⠍⠊⠇⠑⠆ ⠁⠝⠙ ⠍⠹ ⠥⠝⠙⠁⠇⠇⠪⠫ ⠙⠁⠝⠙⠎
+ ⠩⠁⠇⠇ ⠝⠕⠞ ⠙⠊⠌⠥⠗⠃ ⠊⠞⠂ ⠕⠗ ⠹⠑ ⡊⠳⠝⠞⠗⠹⠰⠎ ⠙⠕⠝⠑ ⠋⠕⠗⠲ ⡹⠳
+ ⠺⠊⠇⠇ ⠹⠻⠑⠋⠕⠗⠑ ⠏⠻⠍⠊⠞ ⠍⠑ ⠞⠕ ⠗⠑⠏⠑⠁⠞⠂ ⠑⠍⠏⠙⠁⠞⠊⠊⠁⠇⠇⠹⠂ ⠹⠁⠞
+ ⡍⠜⠇⠑⠹ ⠺⠁⠎ ⠁⠎ ⠙⠑⠁⠙ ⠁⠎ ⠁ ⠙⠕⠕⠗⠤⠝⠁⠊⠇⠲
+
+ (The first couple of paragraphs of "A Christmas Carol" by Dickens)
+
+Compact font selection example text:
+
+ ABCDEFGHIJKLMNOPQRSTUVWXYZ /0123456789
+ abcdefghijklmnopqrstuvwxyz £©µÀÆÖÞßéöÿ
+ –—‘“”„†•…‰™œŠŸž€ ΑΒΓΔΩαβγδω АБВГДабвгд
+ ∀∂∈ℝ∧∪≡∞ ↑↗↨↻⇣ ┐┼╔╘░►☺♀ fi�⑀₂ἠḂӥẄɐː⍎אԱა
+
+Greetings in various languages:
+
+ Hello world, Καλημέρα κόσμε, コンニチハ
+
+Box drawing alignment tests: █
+ ▉
+ ╔══╦══╗ ┌──┬──┐ ╭──┬──╮ ╭──┬──╮ ┏━━┳━━┓ ┎┒┏┑ ╷ ╻ ┏┯┓ ┌┰┐ ▊ ╱╲╱╲╳╳╳
+ ║┌─╨─┐║ │╔═╧═╗│ │╒═╪═╕│ │╓─╁─╖│ ┃┌─╂─┐┃ ┗╃╄┙ ╶┼╴╺╋╸┠┼┨ ┝╋┥ ▋ ╲╱╲╱╳╳╳
+ ║│╲ ╱│║ │║ ║│ ││ │ ││ │║ ┃ ║│ ┃│ ╿ │┃ ┍╅╆┓ ╵ ╹ ┗┷┛ └┸┘ ▌ ╱╲╱╲╳╳╳
+ ╠╡ ╳ ╞╣ ├╢ ╟┤ ├┼─┼─┼┤ ├╫─╂─╫┤ ┣┿╾┼╼┿┫ ┕┛┖┚ ┌┄┄┐ ╎ ┏┅┅┓ ┋ ▍ ╲╱╲╱╳╳╳
+ ║│╱ ╲│║ │║ ║│ ││ │ ││ │║ ┃ ║│ ┃│ ╽ │┃ ░░▒▒▓▓██ ┊ ┆ ╎ ╏ ┇ ┋ ▎
+ ║└─╥─┘║ │╚═╤═╝│ │╘═╪═╛│ │╙─╀─╜│ ┃└─╂─┘┃ ░░▒▒▓▓██ ┊ ┆ ╎ ╏ ┇ ┋ ▏
+ ╚══╩══╝ └──┴──┘ ╰──┴──╯ ╰──┴──╯ ┗━━┻━━┛ ▗▄▖▛▀▜ └╌╌┘ ╎ ┗╍╍┛ ┋ ▁▂▃▄▅▆▇█
+ ▝▀▘▙▄▟
--- /dev/null
+#include <stdio.h>
+#include <string.h>
+#include <glib.h>
+#include "test.h"
+
+/* example from glib documentation */
+RESULT
+test_array_big ()
+{
+ GArray *garray;
+ gint i;
+
+ /* We create a new array to store gint values.
+ We don't want it zero-terminated or cleared to 0's. */
+ garray = g_array_new (FALSE, FALSE, sizeof (gint));
+ for (i = 0; i < 10000; i++)
+ g_array_append_val (garray, i);
+
+ for (i = 0; i < 10000; i++)
+ if (g_array_index (garray, gint, i) != i)
+ return FAILED ("array value didn't match");
+
+ g_array_free (garray, TRUE);
+
+ return NULL;
+}
+
+RESULT
+test_array_index ()
+{
+ GArray *array = g_array_new (FALSE, FALSE, sizeof (int));
+ int v;
+
+ v = 27;
+ g_array_append_val (array, v);
+
+ if (27 != g_array_index (array, int, 0))
+ return FAILED ("");
+
+ g_array_free (array, TRUE);
+
+ return NULL;
+}
+
+RESULT
+test_array_append_zero_terminated ()
+{
+ GArray *array = g_array_new (TRUE, FALSE, sizeof (int));
+ int v;
+
+ v = 27;
+ g_array_append_val (array, v);
+
+ if (27 != g_array_index (array, int, 0))
+ return FAILED ("g_array_append_val failed");
+
+ if (0 != g_array_index (array, int, 1))
+ return FAILED ("zero_terminated didn't append a zero element");
+
+ g_array_free (array, TRUE);
+
+ return NULL;
+}
+
+RESULT
+test_array_append ()
+{
+ GArray *array = g_array_new (FALSE, FALSE, sizeof (int));
+ int v;
+
+ if (0 != array->len)
+ return FAILED ("initial array length not zero");
+
+ v = 27;
+
+ g_array_append_val (array, v);
+
+ if (1 != array->len)
+ return FAILED ("array append failed");
+
+ g_array_free (array, TRUE);
+
+ return NULL;
+}
+
+RESULT
+test_array_insert_val ()
+{
+ GArray *array = g_array_new (FALSE, FALSE, sizeof (gpointer));
+ gpointer ptr0, ptr1, ptr2, ptr3;
+
+ g_array_insert_val (array, 0, array);
+
+ if (array != g_array_index (array, gpointer, 0))
+ return FAILED ("1 The value in the array is incorrect");
+
+ g_array_insert_val (array, 1, array);
+ if (array != g_array_index (array, gpointer, 1))
+ return FAILED ("2 The value in the array is incorrect");
+
+ g_array_insert_val (array, 2, array);
+ if (array != g_array_index (array, gpointer, 2))
+ return FAILED ("3 The value in the array is incorrect");
+
+ g_array_free (array, TRUE);
+ array = g_array_new (FALSE, FALSE, sizeof (gpointer));
+ ptr0 = array;
+ ptr1 = array + 1;
+ ptr2 = array + 2;
+ ptr3 = array + 3;
+
+ g_array_insert_val (array, 0, ptr0);
+ g_array_insert_val (array, 1, ptr1);
+ g_array_insert_val (array, 2, ptr2);
+ g_array_insert_val (array, 1, ptr3);
+ if (ptr0 != g_array_index (array, gpointer, 0))
+ return FAILED ("4 The value in the array is incorrect");
+ if (ptr3 != g_array_index (array, gpointer, 1))
+ return FAILED ("5 The value in the array is incorrect");
+ if (ptr1 != g_array_index (array, gpointer, 2))
+ return FAILED ("6 The value in the array is incorrect");
+ if (ptr2 != g_array_index (array, gpointer, 3))
+ return FAILED ("7 The value in the array is incorrect");
+
+ g_array_free (array, TRUE);
+ return NULL;
+}
+
+RESULT
+test_array_remove ()
+{
+ GArray *array = g_array_new (FALSE, FALSE, sizeof (int));
+ int v[] = {30, 29, 28, 27, 26, 25};
+
+ g_array_append_vals (array, v, 6);
+
+ if (6 != array->len)
+ return FAILED ("append_vals fail");
+
+ g_array_remove_index (array, 3);
+
+ if (5 != array->len)
+ return FAILED ("remove_index failed to update length");
+
+ if (26 != g_array_index (array, int, 3))
+ return FAILED ("remove_index failed to update the array");
+
+ g_array_free (array, TRUE);
+
+ return NULL;
+}
+
+static Test array_tests [] = {
+ {"big", test_array_big},
+ {"append", test_array_append},
+ {"insert_val", test_array_insert_val},
+ {"index", test_array_index},
+ {"remove", test_array_remove},
+ {"append_zero_term", test_array_append_zero_terminated},
+ {NULL, NULL}
+};
+
+DEFINE_TEST_GROUP_INIT(array_tests_init, array_tests)
--- /dev/null
+#include <config.h>
+#include <glib.h>
+#include <string.h>
+#include <stdio.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#ifdef G_OS_UNIX
+#include <pthread.h>
+#endif
+#include "test.h"
+
+/* This test is just to be used with valgrind */
+RESULT
+test_dir ()
+{
+ GDir *dir;
+ GError *error;
+ const gchar *name;
+
+ /*
+ dir = g_dir_open (NULL, 0, NULL);
+ */
+ dir = g_dir_open ("", 0, NULL);
+ if (dir != NULL)
+ return FAILED ("1 Should be an error");
+
+ dir = g_dir_open ("", 9, NULL);
+ if (dir != NULL)
+ return FAILED ("2 Should be an error");
+
+ error = NULL;
+ dir = g_dir_open (".ljasdslakjd", 9, &error);
+ if (dir != NULL)
+ return FAILED ("3 opendir should fail");
+ if (error == NULL)
+ return FAILED ("4 got no error");
+ g_error_free (error);
+ error = NULL;
+ dir = g_dir_open (g_get_tmp_dir (), 9, &error);
+ if (dir == NULL)
+ return FAILED ("5 opendir should succeed");
+ if (error != NULL)
+ return FAILED ("6 got an error");
+ name = NULL;
+ name = g_dir_read_name (dir);
+ if (name == NULL)
+ return FAILED ("7 didn't read a file name");
+ while ((name = g_dir_read_name (dir)) != NULL) {
+ if (strcmp (name, ".") == 0)
+ return FAILED (". directory found");
+ if (strcmp (name, "..") == 0)
+ return FAILED (".. directory found");
+ }
+ g_dir_close (dir);
+ return OK;
+}
+
+static Test dir_tests [] = {
+ {"g_dir_*", test_dir},
+ {NULL, NULL}
+};
+
+DEFINE_TEST_GROUP_INIT(dir_tests_init, dir_tests)
+
+
--- /dev/null
+/*
+ * EGLib Unit Test Driver
+ *
+ * Author:
+ * Aaron Bockover (abockover@novell.com)
+ *
+ * (C) 2006 Novell, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#include <config.h>
+#include "test.h"
+
+#ifndef DRIVER_EXTERNAL_TESTS
+#include "tests.h"
+#endif
+
+#include <stdio.h>
+#ifdef HAVE_GETOPT_H
+#include <getopt.h>
+#endif
+
+#if defined(HAVE_UNISTD_H)
+#include <unistd.h>
+#endif
+
+#ifndef DRIVER_NAME
+#define DRIVER_NAME "EGlib"
+#endif
+
+typedef struct _StringArray {
+ gchar **strings;
+ gint length;
+} StringArray;
+
+static StringArray *
+string_array_append(StringArray *array, gchar *string)
+{
+ if(array == NULL) {
+ array = g_new0(StringArray, 1);
+ array->length = 1;
+ array->strings = g_malloc(sizeof(gchar *) * 2);
+ } else {
+ array->length++;
+ array->strings = g_realloc(array->strings, sizeof(gchar *)
+ * (array->length + 1));
+ }
+
+ array->strings[array->length - 1] = string;
+ array->strings[array->length] = NULL;
+
+ return array;
+}
+
+gint global_passed = 0, global_tests = 0;
+
+static void
+string_array_free(StringArray *array)
+{
+ g_free(array->strings);
+ g_free(array);
+}
+
+static void print_help(char *s)
+{
+ gint i;
+
+ printf("Usage: %s [OPTION]... [TESTGROUP]...\n\n", s);
+ printf("OPTIONS are:\n");
+ printf(" -h, --help show this help\n");
+ printf(" -t, --time time the tests\n");
+ printf(" -i, --iterations number of times to run tests\n");
+ printf(" -q, --quiet do not print test results; "
+ "final time always prints\n");
+ printf(" -n, --no-labels print final time without labels, "
+ "nice for scripts\n");
+ printf(" -d, --debug do not run tests, "
+ "debug the driver itself for valgrind\n\n");
+ printf("TESTGROUPS available:\n");
+
+ for(i = 0; test_groups[i].name != NULL; i++) {
+ if(test_groups[i].handler != fake_tests_init) {
+ printf(" %s\n", test_groups[i].name);
+ }
+ }
+
+ printf("\n");
+}
+
+#ifdef DRIVER_EXTERNAL_MAIN
+gint run_tests_main(gint argc, gchar **argv)
+#else
+gint main(gint argc, gchar **argv)
+#endif
+{
+ gint i, j, c, iterations = 1;
+ StringArray *tests_to_run = NULL;
+ gdouble time_start;
+ gboolean report_time = FALSE;
+ gboolean quiet = FALSE;
+ gboolean global_failure = FALSE;
+ gboolean no_final_time_labels = FALSE;
+ gboolean debug = FALSE;
+
+#if HAVE_GETOPT_H
+ static struct option long_options [] = {
+ {"help", no_argument, 0, 'h'},
+ {"time", no_argument, 0, 't'},
+ {"quiet", no_argument, 0, 'q'},
+ {"iterations", required_argument, 0, 'i'},
+ {"debug", no_argument, 0, 'd'},
+ {"no-labels", no_argument, 0, 'n'},
+ {0, 0, 0, 0}
+ };
+
+ while((c = getopt_long(argc, argv, "dhtqni:", long_options, NULL)) != -1) { switch(c) {
+ case 'h':
+ print_help(argv[0]);
+ return 1;
+ case 't':
+ report_time = TRUE;
+ break;
+ case 'i':
+ iterations = atoi(optarg);
+ break;
+ case 'q':
+ quiet = TRUE;
+ break;
+ case 'n':
+ no_final_time_labels = TRUE;
+ break;
+ case 'd':
+ debug = TRUE;
+ break;
+ }
+ }
+
+ for(i = optind; i < argc; i++) {
+ if(argv[i][0] == '-') {
+ continue;
+ }
+
+ tests_to_run = string_array_append(tests_to_run, argv[i]);
+ }
+#endif
+
+ time_start = get_timestamp();
+
+ for(j = 0; test_groups[j].name != NULL; j++) {
+ gboolean run = TRUE;
+ gchar *tests = NULL;
+ gchar *group = NULL;
+
+ if(tests_to_run != NULL) {
+ gint k;
+ run = FALSE;
+
+ for(k = 0; k < tests_to_run->length; k++) {
+ gchar *user = tests_to_run->strings[k];
+ const gchar *table = test_groups[j].name;
+ size_t user_len = strlen(user);
+ size_t table_len = strlen(table);
+
+ if(strncmp(user, table, table_len) == 0) {
+ if(user_len > table_len && user[table_len] != ':') {
+ break;
+ }
+
+ run = TRUE;
+ group = tests_to_run->strings[k];
+ break;
+ }
+ }
+ }
+
+ if(run) {
+ gboolean passed;
+ gchar **split = NULL;
+
+ if(debug && test_groups[j].handler != fake_tests_init) {
+ printf("Skipping %s, in driver debug mode\n",
+ test_groups[j].name);
+ continue;
+ } else if(!debug && test_groups[j].handler == fake_tests_init) {
+ continue;
+ }
+
+ if(group != NULL) {
+ split = eg_strsplit(group, ":", -1);
+ if(split != NULL) {
+ gint m;
+ for(m = 0; split[m] != NULL; m++) {
+ if(m == 1) {
+ tests = strdup(split[m]);
+ break;
+ }
+ }
+ eg_strfreev(split);
+ }
+ }
+
+ passed = run_group(&(test_groups[j]),
+ iterations, quiet, report_time, tests);
+
+ if(tests != NULL) {
+ g_free(tests);
+ }
+
+ if(!passed && !global_failure) {
+ global_failure = TRUE;
+ }
+ }
+ }
+
+ if(!quiet) {
+ gdouble pass_percentage = ((gdouble)global_passed / (gdouble)global_tests) * 100.0;
+ printf("=============================\n");
+ printf("Overall result: %s : %d / %d (%g%%)\n", global_failure ? "FAILED" : "OK", global_passed, global_tests, pass_percentage);
+ }
+
+ if(report_time) {
+ gdouble duration = get_timestamp() - time_start;
+ if(no_final_time_labels) {
+ printf("%g\n", duration);
+ } else {
+ printf("%s Total Time: %g\n", DRIVER_NAME, duration);
+ }
+ }
+
+ if(tests_to_run != NULL) {
+ string_array_free(tests_to_run);
+ }
+
+ return global_tests - global_passed;
+}
+
+
--- /dev/null
+#include "test.h"
+
+RESULT
+test_swap ()
+{
+ guint32 a = 0xabcdef01, res32;
+ guint64 b = (((guint64)a) << 32) | a, res64;
+ guint64 b_expect = (((guint64)0x1efcdab) << 32) | 0x01efcdab;
+ guint16 c = 0xabcd, res16;
+
+ res32 = GUINT32_SWAP_LE_BE (a);
+ if (res32 != 0x01efcdab)
+ return FAILED ("GUINT32_SWAP_LE_BE returned 0x%x", res32);
+ res32 = GUINT32_SWAP_LE_BE (1);
+ if (res32 != 0x1000000)
+ return FAILED ("GUINT32_SWAP_LE_BE returned 0x%x", res32);
+
+ res64 = GUINT64_SWAP_LE_BE(b);
+ if (res64 != b_expect)
+ return FAILED ("GUINT64_SWAP_LE_BE returned 0x%llx (had=0x%llx)", res64, b);
+ res16 = GUINT16_SWAP_LE_BE(c);
+ if (res16 != 0xcdab)
+ return FAILED ("GUINT16_SWAP_LE_BE returned 0x%x", (guint32) res16);
+
+ return OK;
+}
+
+/*
+ * test initialization
+ */
+
+static Test endian_tests [] = {
+ {"swap", test_swap},
+ {NULL, NULL}
+};
+
+DEFINE_TEST_GROUP_INIT(endian_tests_init, endian_tests)
+
--- /dev/null
+/*
+ * Fake test allows debugging of the driver itself
+ */
+
+#include "test.h"
+
+RESULT
+test_fake()
+{
+ return OK;
+}
+
+static Test fake_tests [] = {
+ {"fake", test_fake},
+ {NULL, NULL}
+};
+
+DEFINE_TEST_GROUP_INIT(fake_tests_init, fake_tests)
+
--- /dev/null
+#include <config.h>
+#include <glib.h>
+#include <string.h>
+#include <stdlib.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#include <stdio.h>
+#include "test.h"
+
+#ifdef G_OS_WIN32
+#include <io.h>
+#define close _close
+#endif
+
+RESULT
+test_file_get_contents ()
+{
+ GError *error;
+ gchar *content;
+ gboolean ret;
+ gsize length;
+#ifdef G_OS_WIN32
+ const gchar *filename = "c:\\Windows\\system.ini";
+#else
+ const gchar *filename = "/etc/hosts";
+#endif
+
+ /*
+ filename != NULL
+ ret = g_file_get_contents (NULL, NULL, NULL, NULL);
+ contents != NULL
+ ret = g_file_get_contents ("", NULL, NULL, NULL);
+ error no such file and fails for 'error' not being null too
+ ret = g_file_get_contents ("", &content, NULL, &error);
+ */
+
+ error = NULL;
+ ret = g_file_get_contents ("", &content, NULL, &error);
+ if (ret)
+ return FAILED ("HAH!");
+ if (error == NULL)
+ return FAILED ("Got nothing as error.");
+ if (content != NULL)
+ return FAILED ("Content is uninitialized");
+
+ g_error_free (error);
+ error = NULL;
+ ret = g_file_get_contents (filename, &content, &length, &error);
+ if (!ret)
+ return FAILED ("The error is %d %s\n", error->code, error->message);
+ if (error != NULL)
+ return FAILED ("Got an error returning TRUE");
+ if (content == NULL)
+ return FAILED ("Content is NULL");
+ if (strlen (content) != length)
+ return FAILED ("length is %d but the string is %d", length, strlen (content));
+ g_free (content);
+
+ return OK;
+}
+
+RESULT
+test_open_tmp ()
+{
+ GError *error;
+ gint fd;
+ gchar *name = GINT_TO_POINTER (-1);
+
+ /*
+ * Okay, this works, but creates a .xxx file in /tmp on every run. Disabled.
+ * fd = g_file_open_tmp (NULL, NULL, NULL);
+ * if (fd < 0)
+ * return FAILED ("Default failed.");
+ * close (fd);
+ */
+ error = NULL;
+ fd = g_file_open_tmp ("invalidtemplate", NULL, &error);
+ if (fd != -1)
+ return FAILED ("The template was invalid and accepted");
+ if (error == NULL)
+ return FAILED ("No error returned.");
+ g_error_free (error);
+
+ error = NULL;
+ fd = g_file_open_tmp ("i/nvalidtemplate", &name, &error);
+ if (fd != -1)
+ return FAILED ("The template was invalid and accepted");
+ if (error == NULL)
+ return FAILED ("No error returned.");
+ if (name == NULL)
+ return FAILED ("'name' is not reset");
+ g_error_free (error);
+
+ error = NULL;
+ fd = g_file_open_tmp ("valid-XXXXXX", &name, &error);
+ if (fd == -1)
+ return FAILED ("This should be valid");
+ if (error != NULL)
+ return FAILED ("No error returned.");
+ if (name == NULL)
+ return FAILED ("No name returned.");
+ close (fd);
+ unlink (name);
+ g_free (name);
+ return OK;
+}
+
+RESULT
+test_file ()
+{
+ gboolean res;
+ const gchar *tmp;
+ gchar *path;
+
+#ifndef G_OS_WIN32 /* FIXME */
+ gchar *sympath;
+ gint ignored G_GNUC_UNUSED;
+#endif
+
+ res = g_file_test (NULL, 0);
+ if (res)
+ return FAILED ("Should return FALSE HERE");
+
+ res = g_file_test ("file.c", 0);
+ if (res)
+ return FAILED ("Should return FALSE HERE");
+
+ tmp = g_get_tmp_dir ();
+ res = g_file_test (tmp, G_FILE_TEST_EXISTS);
+ if (!res)
+ return FAILED ("tmp does not exist.");
+ res = g_file_test (tmp, G_FILE_TEST_IS_REGULAR);
+ if (res)
+ return FAILED ("tmp is regular");
+
+ res = g_file_test (tmp, G_FILE_TEST_IS_DIR);
+ if (!res)
+ return FAILED ("tmp is not a directory");
+ res = g_file_test (tmp, G_FILE_TEST_IS_EXECUTABLE);
+ if (!res)
+ return FAILED ("tmp is not a executable");
+
+ res = g_file_test (tmp, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_SYMLINK);
+ if (!res)
+ return FAILED ("2 tmp does not exist.");
+ res = g_file_test (tmp, G_FILE_TEST_IS_REGULAR | G_FILE_TEST_IS_SYMLINK);
+ if (res)
+ return FAILED ("2 tmp is regular");
+
+ res = g_file_test (tmp, G_FILE_TEST_IS_DIR | G_FILE_TEST_IS_SYMLINK);
+ if (!res)
+ return FAILED ("2 tmp is not a directory");
+ res = g_file_test (tmp, G_FILE_TEST_IS_EXECUTABLE | G_FILE_TEST_IS_SYMLINK);
+ if (!res)
+ return FAILED ("2 tmp is not a executable");
+
+ close (g_file_open_tmp (NULL, &path, NULL)); /* create an empty file */
+ res = g_file_test (path, G_FILE_TEST_EXISTS);
+ if (!res)
+ return FAILED ("3 %s should exist", path);
+ res = g_file_test (path, G_FILE_TEST_IS_REGULAR);
+ /* This is strange. Empty file is reported as not existing! */
+ if (!res)
+ return FAILED ("3 %s IS_REGULAR", path);
+ res = g_file_test (path, G_FILE_TEST_IS_DIR);
+ if (res)
+ return FAILED ("3 %s should not be a directory", path);
+ res = g_file_test (path, G_FILE_TEST_IS_EXECUTABLE);
+ if (res)
+ return FAILED ("3 %s should not be executable", path);
+ res = g_file_test (path, G_FILE_TEST_IS_SYMLINK);
+ if (res)
+ return FAILED ("3 %s should not be a symlink", path);
+
+#ifndef G_OS_WIN32 /* FIXME */
+ sympath = g_strconcat (path, "-link", NULL);
+ ignored = symlink (path, sympath);
+ res = g_file_test (sympath, G_FILE_TEST_EXISTS);
+ if (!res)
+ return FAILED ("4 %s should not exist", sympath);
+ res = g_file_test (sympath, G_FILE_TEST_IS_REGULAR);
+ if (!res)
+ return FAILED ("4 %s should not be a regular file", sympath);
+ res = g_file_test (sympath, G_FILE_TEST_IS_DIR);
+ if (res)
+ return FAILED ("4 %s should not be a directory", sympath);
+ res = g_file_test (sympath, G_FILE_TEST_IS_EXECUTABLE);
+ if (res)
+ return FAILED ("4 %s should not be executable", sympath);
+ res = g_file_test (sympath, G_FILE_TEST_IS_SYMLINK);
+ if (!res)
+ return FAILED ("4 %s should be a symlink", sympath);
+
+ unlink (path);
+
+ res = g_file_test (sympath, G_FILE_TEST_EXISTS);
+ if (res)
+ return FAILED ("5 %s should exist", sympath);
+ res = g_file_test (sympath, G_FILE_TEST_IS_REGULAR);
+ if (res)
+ return FAILED ("5 %s should be a regular file", sympath);
+ res = g_file_test (sympath, G_FILE_TEST_IS_DIR);
+ if (res)
+ return FAILED ("5 %s should not be a directory", sympath);
+ res = g_file_test (sympath, G_FILE_TEST_IS_EXECUTABLE);
+ if (res)
+ return FAILED ("5 %s should not be executable", sympath);
+ res = g_file_test (sympath, G_FILE_TEST_IS_SYMLINK);
+ if (!res)
+ return FAILED ("5 %s should be a symlink", sympath);
+ unlink (sympath);
+ g_free (sympath);
+#endif
+ g_free (path);
+ return OK;
+}
+
+static Test file_tests [] = {
+ {"g_file_get_contents", test_file_get_contents},
+ {"g_file_open_tmp", test_open_tmp},
+ {"g_file_test", test_file},
+ {NULL, NULL}
+};
+
+DEFINE_TEST_GROUP_INIT(file_tests_init, file_tests)
+
+
--- /dev/null
+#include <stdio.h>
+#include <string.h>
+#include <glib.h>
+#include "test.h"
+
+int foreach_count = 0;
+int foreach_fail = 0;
+
+void foreach (gpointer key, gpointer value, gpointer user_data)
+{
+ foreach_count++;
+ if (GPOINTER_TO_INT (user_data) != 'a')
+ foreach_fail = 1;
+}
+
+RESULT hash_t1 (void)
+{
+ GHashTable *t = g_hash_table_new (g_str_hash, g_str_equal);
+
+ foreach_count = 0;
+ foreach_fail = 0;
+ g_hash_table_insert (t, "hello", "world");
+ g_hash_table_insert (t, "my", "god");
+
+ g_hash_table_foreach (t, foreach, GINT_TO_POINTER('a'));
+ if (foreach_count != 2)
+ return FAILED ("did not find all keys, got %d expected 2", foreach_count);
+ if (foreach_fail)
+ return FAILED("failed to pass the user-data to foreach");
+
+ if (!g_hash_table_remove (t, "my"))
+ return FAILED ("did not find known key");
+ if (g_hash_table_size (t) != 1)
+ return FAILED ("unexpected size");
+ g_hash_table_insert(t, "hello", "moon");
+ if (strcmp (g_hash_table_lookup (t, "hello"), "moon") != 0)
+ return FAILED ("did not replace world with moon");
+
+ if (!g_hash_table_remove (t, "hello"))
+ return FAILED ("did not find known key");
+ if (g_hash_table_size (t) != 0)
+ return FAILED ("unexpected size");
+ g_hash_table_destroy (t);
+
+ return OK;
+}
+
+RESULT hash_t2 (void)
+{
+ return OK;
+}
+
+RESULT hash_default (void)
+{
+ GHashTable *hash = g_hash_table_new (NULL, NULL);
+
+ if (hash == NULL)
+ return FAILED ("g_hash_table_new should return a valid hash");
+
+ g_hash_table_destroy (hash);
+ return NULL;
+}
+
+RESULT
+hash_null_lookup (void)
+{
+ GHashTable *hash = g_hash_table_new (NULL, NULL);
+ gpointer ok, ov;
+
+ g_hash_table_insert (hash, NULL, GINT_TO_POINTER (1));
+ g_hash_table_insert (hash, GINT_TO_POINTER(1), GINT_TO_POINTER(2));
+
+ if (!g_hash_table_lookup_extended (hash, NULL, &ok, &ov))
+ return FAILED ("Did not find the NULL");
+ if (ok != NULL)
+ return FAILED ("Incorrect key found");
+ if (ov != GINT_TO_POINTER (1))
+ return FAILED ("Got wrong value %p\n", ov);
+
+ if (!g_hash_table_lookup_extended (hash, GINT_TO_POINTER(1), &ok, &ov))
+ return FAILED ("Did not find the 1");
+ if (ok != GINT_TO_POINTER(1))
+ return FAILED ("Incorrect key found");
+ if (ov != GINT_TO_POINTER (2))
+ return FAILED ("Got wrong value %p\n", ov);
+
+ g_hash_table_destroy (hash);
+
+ return NULL;
+}
+
+static void
+counter (gpointer key, gpointer value, gpointer user_data)
+{
+ int *counter = (int *) user_data;
+
+ (*counter)++;
+}
+
+RESULT hash_grow (void)
+{
+ GHashTable *hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
+ int i, count = 0;
+
+ for (i = 0; i < 1000; i++)
+ g_hash_table_insert (hash, g_strdup_printf ("%d", i), g_strdup_printf ("x-%d", i));
+
+ for (i = 0; i < 1000; i++){
+ char buffer [30];
+ gpointer value;
+
+ sprintf (buffer, "%d", i);
+
+ value = g_hash_table_lookup (hash, buffer);
+ sprintf (buffer, "x-%d", i);
+ if (strcmp (value, buffer) != 0){
+ return FAILED ("Failed to lookup the key %d, the value was %s\n", i, value);
+ }
+ }
+
+ if (g_hash_table_size (hash) != 1000)
+ return FAILED ("Did not find 1000 elements on the hash, found %d\n", g_hash_table_size (hash));
+
+ /* Now do the manual count, lets not trust the internals */
+ g_hash_table_foreach (hash, counter, &count);
+ if (count != 1000){
+ return FAILED ("Foreach count is not 1000");
+ }
+
+ g_hash_table_destroy (hash);
+ return NULL;
+}
+
+RESULT hash_iter (void)
+{
+#if !defined(GLIB_MAJOR_VERSION) || GLIB_CHECK_VERSION(2, 16, 0)
+ GHashTable *hash = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, NULL);
+ GHashTableIter iter;
+ int i, sum, keys_sum, values_sum;
+ gpointer key, value;
+
+ sum = 0;
+ for (i = 0; i < 1000; i++) {
+ sum += i;
+ g_hash_table_insert (hash, GUINT_TO_POINTER (i), GUINT_TO_POINTER (i));
+ }
+
+ keys_sum = values_sum = 0;
+ g_hash_table_iter_init (&iter, hash);
+ while (g_hash_table_iter_next (&iter, &key, &value)) {
+ if (key != value)
+ return FAILED ("key != value");
+ keys_sum += GPOINTER_TO_UINT (key);
+ values_sum += GPOINTER_TO_UINT (value);
+ }
+ if (keys_sum != sum || values_sum != sum)
+ return FAILED ("Did not find all key-value pairs");
+ g_hash_table_destroy (hash);
+ return NULL;
+#else
+ /* GHashTableIter was added in glib 2.16 */
+ return NULL;
+#endif
+}
+
+static Test hashtable_tests [] = {
+ {"t1", hash_t1},
+ {"t2", hash_t2},
+ {"grow", hash_grow},
+ {"default", hash_default},
+ {"null_lookup", hash_null_lookup},
+ {"iter", hash_iter},
+ {NULL, NULL}
+};
+
+DEFINE_TEST_GROUP_INIT(hashtable_tests_init, hashtable_tests)
+
--- /dev/null
+#include <stdio.h>
+#include <string.h>
+#include <glib.h>
+#include "test.h"
+
+RESULT
+test_list_length ()
+{
+ GList *list = g_list_prepend (NULL, "foo");
+
+ if (g_list_length (list) != 1)
+ return FAILED ("length failed. #1");
+
+ list = g_list_prepend (list, "bar");
+ if (g_list_length (list) != 2)
+ return FAILED ("length failed. #2");
+
+ list = g_list_append (list, "bar");
+ if (g_list_length (list) != 3)
+ return FAILED ("length failed. #3");
+
+ g_list_free (list);
+ return NULL;
+}
+
+RESULT
+test_list_nth ()
+{
+ char *foo = "foo";
+ char *bar = "bar";
+ char *baz = "baz";
+ GList *nth, *list;
+ list = g_list_prepend (NULL, baz);
+ list = g_list_prepend (list, bar);
+ list = g_list_prepend (list, foo);
+
+ nth = g_list_nth (list, 0);
+ if (nth->data != foo)
+ return FAILED ("nth failed. #0");
+
+ nth = g_list_nth (list, 1);
+ if (nth->data != bar)
+ return FAILED ("nth failed. #1");
+
+ nth = g_list_nth (list, 2);
+ if (nth->data != baz)
+ return FAILED ("nth failed. #2");
+
+ nth = g_list_nth (list, 3);
+ if (nth)
+ return FAILED ("nth failed. #3: %s", nth->data);
+
+ g_list_free (list);
+ return OK;
+}
+
+RESULT
+test_list_index ()
+{
+ int i;
+ char *foo = "foo";
+ char *bar = "bar";
+ char *baz = "baz";
+ GList *list;
+ list = g_list_prepend (NULL, baz);
+ list = g_list_prepend (list, bar);
+ list = g_list_prepend (list, foo);
+
+ i = g_list_index (list, foo);
+ if (i != 0)
+ return FAILED ("index failed. #0: %d", i);
+
+ i = g_list_index (list, bar);
+ if (i != 1)
+ return FAILED ("index failed. #1: %d", i);
+
+ i = g_list_index (list, baz);
+ if (i != 2)
+ return FAILED ("index failed. #2: %d", i);
+
+ g_list_free (list);
+ return OK;
+}
+
+RESULT
+test_list_append ()
+{
+ GList *list = g_list_prepend (NULL, "first");
+ if (g_list_length (list) != 1)
+ return FAILED ("Prepend failed");
+
+ list = g_list_append (list, "second");
+
+ if (g_list_length (list) != 2)
+ return FAILED ("Append failed");
+
+ g_list_free (list);
+ return OK;
+}
+
+RESULT
+test_list_last ()
+{
+ GList *foo = g_list_prepend (NULL, "foo");
+ GList *bar = g_list_prepend (NULL, "bar");
+ GList *last;
+
+ foo = g_list_concat (foo, bar);
+ last = g_list_last (foo);
+
+ if (last != bar)
+ return FAILED ("last failed. #1");
+
+ foo = g_list_concat (foo, g_list_prepend (NULL, "baz"));
+ foo = g_list_concat (foo, g_list_prepend (NULL, "quux"));
+
+ last = g_list_last (foo);
+ if (strcmp ("quux", last->data))
+ return FAILED ("last failed. #2");
+
+ g_list_free (foo);
+
+ return OK;
+}
+
+RESULT
+test_list_concat ()
+{
+ GList *foo = g_list_prepend (NULL, "foo");
+ GList *bar = g_list_prepend (NULL, "bar");
+ GList *list = g_list_concat (foo, bar);
+
+ if (g_list_length (list) != 2)
+ return FAILED ("Concat failed. #1");
+
+ if (strcmp (list->data, "foo"))
+ return FAILED ("Concat failed. #2");
+
+ if (strcmp (list->next->data, "bar"))
+ return FAILED ("Concat failed. #3");
+
+ if (g_list_first (list) != foo)
+ return FAILED ("Concat failed. #4");
+
+ if (g_list_last (list) != bar)
+ return FAILED ("Concat failed. #5");
+
+ g_list_free (list);
+
+ return OK;
+}
+
+
+static gint
+compare (gconstpointer a, gconstpointer b)
+{
+ char *foo = (char *) a;
+ char *bar = (char *) b;
+
+ if (strlen (foo) < strlen (bar))
+ return -1;
+
+ return 1;
+}
+
+RESULT
+test_list_insert_sorted ()
+{
+ GList *list = g_list_prepend (NULL, "a");
+ list = g_list_append (list, "aaa");
+
+ /* insert at the middle */
+ list = g_list_insert_sorted (list, "aa", compare);
+ if (strcmp ("aa", list->next->data))
+ return FAILED ("insert_sorted failed. #1");
+
+ /* insert at the beginning */
+ list = g_list_insert_sorted (list, "", compare);
+ if (strcmp ("", list->data))
+ return FAILED ("insert_sorted failed. #2");
+
+ /* insert at the end */
+ list = g_list_insert_sorted (list, "aaaa", compare);
+ if (strcmp ("aaaa", g_list_last (list)->data))
+ return FAILED ("insert_sorted failed. #3");
+
+ g_list_free (list);
+ return OK;
+}
+
+RESULT
+test_list_copy ()
+{
+ int i, length;
+ GList *list, *copy;
+ list = g_list_prepend (NULL, "a");
+ list = g_list_append (list, "aa");
+ list = g_list_append (list, "aaa");
+ list = g_list_append (list, "aaaa");
+
+ length = g_list_length (list);
+ copy = g_list_copy (list);
+
+ for (i = 0; i < length; i++)
+ if (strcmp (g_list_nth (list, i)->data,
+ g_list_nth (copy, i)->data))
+ return FAILED ("copy failed.");
+
+ g_list_free (list);
+ g_list_free (copy);
+ return OK;
+}
+
+RESULT
+test_list_reverse ()
+{
+ guint i, length;
+ GList *list, *reverse;
+ list = g_list_prepend (NULL, "a");
+ list = g_list_append (list, "aa");
+ list = g_list_append (list, "aaa");
+ list = g_list_append (list, "aaaa");
+
+ length = g_list_length (list);
+ reverse = g_list_reverse (g_list_copy (list));
+
+ if (g_list_length (reverse) != length)
+ return FAILED ("reverse failed #1");
+
+ for (i = 0; i < length; i++){
+ guint j = length - i - 1;
+ if (strcmp (g_list_nth (list, i)->data,
+ g_list_nth (reverse, j)->data))
+ return FAILED ("reverse failed. #2");
+ }
+
+ g_list_free (list);
+ g_list_free (reverse);
+ return OK;
+}
+
+RESULT
+test_list_remove ()
+{
+ GList *list = g_list_prepend (NULL, "three");
+ char *one = "one";
+ list = g_list_prepend (list, "two");
+ list = g_list_prepend (list, one);
+
+ list = g_list_remove (list, one);
+
+ if (g_list_length (list) != 2)
+ return FAILED ("Remove failed");
+
+ if (strcmp ("two", list->data) != 0)
+ return FAILED ("Remove failed");
+
+ g_list_free (list);
+ return OK;
+}
+
+RESULT
+test_list_remove_link ()
+{
+ GList *foo = g_list_prepend (NULL, "a");
+ GList *bar = g_list_prepend (NULL, "b");
+ GList *baz = g_list_prepend (NULL, "c");
+ GList *list = foo;
+
+ foo = g_list_concat (foo, bar);
+ foo = g_list_concat (foo, baz);
+
+ list = g_list_remove_link (list, bar);
+
+ if (g_list_length (list) != 2)
+ return FAILED ("remove_link failed #1");
+
+ if (bar->next != NULL)
+ return FAILED ("remove_link failed #2");
+
+ g_list_free (list);
+ g_list_free (bar);
+ return OK;
+}
+
+RESULT
+test_list_insert_before ()
+{
+ GList *foo, *bar, *baz;
+
+ foo = g_list_prepend (NULL, "foo");
+ foo = g_list_insert_before (foo, NULL, "bar");
+ bar = g_list_last (foo);
+
+ if (strcmp (bar->data, "bar"))
+ return FAILED ("1");
+
+ baz = g_list_insert_before (foo, bar, "baz");
+ if (foo != baz)
+ return FAILED ("2");
+
+ if (strcmp (g_list_nth_data (foo, 1), "baz"))
+ return FAILED ("3: %s", g_list_nth_data (foo, 1));
+
+ g_list_free (foo);
+ return OK;
+}
+
+#define N_ELEMS 101
+
+static int intcompare (gconstpointer p1, gconstpointer p2)
+{
+ return GPOINTER_TO_INT (p1) - GPOINTER_TO_INT (p2);
+}
+
+static gboolean verify_sort (GList *list, int len)
+{
+ int prev;
+
+ if (list->prev)
+ return FALSE;
+
+ prev = GPOINTER_TO_INT (list->data);
+ len--;
+ for (list = list->next; list; list = list->next) {
+ int curr = GPOINTER_TO_INT (list->data);
+ if (prev > curr)
+ return FALSE;
+ prev = curr;
+
+ if (!list->prev || list->prev->next != list)
+ return FALSE;
+
+ if (len == 0)
+ return FALSE;
+ len--;
+ }
+ return len == 0;
+}
+
+RESULT
+test_list_sort ()
+{
+ int i, j, mul;
+ GList *list = NULL;
+
+ for (i = 0; i < N_ELEMS; ++i)
+ list = g_list_prepend (list, GINT_TO_POINTER (i));
+ list = g_list_sort (list, intcompare);
+ if (!verify_sort (list, N_ELEMS))
+ return FAILED ("decreasing list");
+
+ g_list_free (list);
+
+ list = NULL;
+ for (i = 0; i < N_ELEMS; ++i)
+ list = g_list_prepend (list, GINT_TO_POINTER (-i));
+ list = g_list_sort (list, intcompare);
+ if (!verify_sort (list, N_ELEMS))
+ return FAILED ("increasing list");
+
+ g_list_free (list);
+
+ list = g_list_prepend (NULL, GINT_TO_POINTER (0));
+ for (i = 1; i < N_ELEMS; ++i) {
+ list = g_list_prepend (list, GINT_TO_POINTER (i));
+ list = g_list_prepend (list, GINT_TO_POINTER (-i));
+ }
+ list = g_list_sort (list, intcompare);
+ if (!verify_sort (list, 2*N_ELEMS-1))
+ return FAILED ("alternating list");
+
+ g_list_free (list);
+
+ list = NULL;
+ mul = 1;
+ for (i = 1; i < N_ELEMS; ++i) {
+ mul = -mul;
+ for (j = 0; j < i; ++j)
+ list = g_list_prepend (list, GINT_TO_POINTER (mul * j));
+ }
+ list = g_list_sort (list, intcompare);
+ if (!verify_sort (list, (N_ELEMS*N_ELEMS - N_ELEMS)/2))
+ return FAILED ("wavering list");
+
+ g_list_free (list);
+
+ return OK;
+}
+
+static gint
+find_custom (gconstpointer a, gconstpointer b)
+{
+ return(strcmp (a, b));
+}
+
+RESULT
+test_list_find_custom ()
+{
+ GList *list = NULL, *found;
+ char *foo = "foo";
+ char *bar = "bar";
+ char *baz = "baz";
+
+ list = g_list_prepend (list, baz);
+ list = g_list_prepend (list, bar);
+ list = g_list_prepend (list, foo);
+
+ found = g_list_find_custom (list, baz, find_custom);
+
+ if (found == NULL)
+ return FAILED ("Find failed");
+
+ g_list_free (list);
+
+ return OK;
+}
+
+static Test list_tests [] = {
+ { "length", test_list_length},
+ { "nth", test_list_nth},
+ { "index", test_list_index},
+ { "last", test_list_last},
+ { "append", test_list_append},
+ { "concat", test_list_concat},
+ {"insert_sorted", test_list_insert_sorted},
+ {"insert_before", test_list_insert_before},
+ { "copy", test_list_copy},
+ { "reverse", test_list_reverse},
+ { "remove", test_list_remove},
+ { "remove_link", test_list_remove_link},
+ { "remove_link", test_list_remove_link},
+ { "sort", test_list_sort},
+ { "find_custom", test_list_find_custom},
+ {NULL, NULL}
+};
+
+DEFINE_TEST_GROUP_INIT(list_tests_init, list_tests)
--- /dev/null
+#include <stdio.h>
+#include <string.h>
+#include <glib.h>
+#include "test.h"
+
+#define do_bad_test(s) do { char *r = markup_test (s); if (r == NULL) return FAILED ("Failed on test " # s); else g_free (r); } while (0)
+#define do_ok_test(s) do { char *r = markup_test (s); if (r != NULL) return FAILED ("Could not parse valid " # s); } while (0)
+
+static char *
+markup_test (const char *s)
+{
+ GMarkupParser *parser = g_new0 (GMarkupParser, 1);
+ GMarkupParseContext *context;
+ GError *error = NULL;
+
+ context = g_markup_parse_context_new (parser, 0, 0, 0);
+
+ g_markup_parse_context_parse (context, s, strlen (s), &error);
+ g_markup_parse_context_free (context);
+
+ if (error != NULL){
+ char *msg = g_strdup (error->message);
+ g_error_free (error);
+
+ g_free (parser);
+ return msg;
+ }
+ g_free (parser);
+ return NULL;
+}
+
+RESULT
+invalid_documents (void)
+{
+ /* These should fail */
+ do_bad_test ("<1>");
+ do_bad_test ("<a<");
+ do_bad_test ("</a>");
+ do_bad_test ("<a b>");
+ do_bad_test ("<a b=>");
+ do_bad_test ("<a b=c>");
+
+ return OK;
+}
+
+RESULT
+valid_documents (void)
+{
+ /* These should fail */
+ do_ok_test ("<a>");
+ do_ok_test ("<a a=\"b\">");
+
+ return OK;
+}
+
+/*
+ * This is a test for the kind of files that the code in mono/domain.c
+ * parses; This code comes from Mono
+ */
+typedef struct {
+ GSList *supported_runtimes;
+ char *required_runtime;
+ int configuration_count;
+ int startup_count;
+} AppConfigInfo;
+
+static char *
+get_attribute_value (const gchar **attribute_names,
+ const gchar **attribute_values,
+ const char *att_name)
+{
+ int n;
+ for (n=0; attribute_names[n] != NULL; n++) {
+ if (strcmp (attribute_names[n], att_name) == 0)
+ return g_strdup (attribute_values[n]);
+ }
+ return NULL;
+}
+
+static void
+start_element (GMarkupParseContext *context,
+ const gchar *element_name,
+ const gchar **attribute_names,
+ const gchar **attribute_values,
+ gpointer user_data,
+ GError **error)
+{
+ AppConfigInfo* app_config = (AppConfigInfo*) user_data;
+
+ if (strcmp (element_name, "configuration") == 0) {
+ app_config->configuration_count++;
+ return;
+ }
+ if (strcmp (element_name, "startup") == 0) {
+ app_config->startup_count++;
+ return;
+ }
+
+ if (app_config->configuration_count != 1 || app_config->startup_count != 1)
+ return;
+
+ if (strcmp (element_name, "requiredRuntime") == 0) {
+ app_config->required_runtime = get_attribute_value (attribute_names, attribute_values, "version");
+ } else if (strcmp (element_name, "supportedRuntime") == 0) {
+ char *version = get_attribute_value (attribute_names, attribute_values, "version");
+ app_config->supported_runtimes = g_slist_append (app_config->supported_runtimes, version);
+ }
+}
+
+static void
+end_element (GMarkupParseContext *context,
+ const gchar *element_name,
+ gpointer user_data,
+ GError **error)
+{
+ AppConfigInfo* app_config = (AppConfigInfo*) user_data;
+
+ if (strcmp (element_name, "configuration") == 0) {
+ app_config->configuration_count--;
+ } else if (strcmp (element_name, "startup") == 0) {
+ app_config->startup_count--;
+ }
+}
+
+static const GMarkupParser
+mono_parser = {
+ start_element,
+ end_element,
+ NULL,
+ NULL,
+ NULL
+};
+
+AppConfigInfo *
+domain_test (char *text)
+{
+ AppConfigInfo *app_config = g_new0 (AppConfigInfo, 1);
+ GMarkupParseContext *context;
+
+ context = g_markup_parse_context_new (&mono_parser, 0, app_config, NULL);
+ if (g_markup_parse_context_parse (context, text, strlen (text), NULL)) {
+ g_markup_parse_context_end_parse (context, NULL);
+ }
+ g_markup_parse_context_free (context);
+
+ return app_config;
+}
+
+void
+domain_free (AppConfigInfo *info)
+{
+ GSList *l;
+ if (info->required_runtime)
+ g_free (info->required_runtime);
+ for (l = info->supported_runtimes; l != NULL; l = l->next){
+ g_free (l->data);
+ }
+ g_slist_free (info->supported_runtimes);
+ g_free (info);
+}
+
+RESULT
+mono_domain (void)
+{
+ AppConfigInfo *info;
+
+ info = domain_test ("<configuration><!--hello--><startup><!--world--><requiredRuntime version=\"v1\"><!--r--></requiredRuntime></startup></configuration>");
+ if (info->required_runtime == NULL)
+ return FAILED ("No required runtime section");
+ if (strcmp (info->required_runtime, "v1") != 0)
+ return FAILED ("Got a runtime version %s, expected v1", info->required_runtime);
+ domain_free (info);
+
+ info = domain_test ("<configuration><startup><requiredRuntime version=\"v1\"/><!--comment--></configuration><!--end-->");
+ if (info->required_runtime == NULL)
+ return FAILED ("No required runtime section on auto-close section");
+ if (strcmp (info->required_runtime, "v1") != 0)
+ return FAILED ("Got a runtime version %s, expected v1", info->required_runtime);
+ domain_free (info);
+
+ info = domain_test ("<!--start--><configuration><startup><supportedRuntime version=\"v1\"/><!--middle--><supportedRuntime version=\"v2\"/></startup></configuration>");
+ if ((strcmp ((char*)info->supported_runtimes->data, "v1") == 0)){
+ if (info->supported_runtimes->next == NULL)
+ return FAILED ("Expected 2 supported runtimes");
+
+ if ((strcmp ((char*)info->supported_runtimes->next->data, "v2") != 0))
+ return FAILED ("Expected v1, v2, got %s", info->supported_runtimes->next->data);
+ if (info->supported_runtimes->next->next != NULL)
+ return FAILED ("Expected v1, v2, got more");
+ } else
+ return FAILED ("Expected `v1', got %s", info->supported_runtimes->data);
+ domain_free (info);
+
+ return NULL;
+}
+
+RESULT
+mcs_config (void)
+{
+ return markup_test ("<configuration>\r\n <system.diagnostics>\r\n <trace autoflush=\"true\" indentsize=\"4\">\r\n <listeners>\r\n <add name=\"compilerLogListener\" type=\"System.Diagnostics.TextWriterTraceListener,System\"/> </listeners> </trace> </system.diagnostics> </configuration>");
+
+}
+
+RESULT
+xml_parse (void)
+{
+ return markup_test ("<?xml version=\"1.0\" encoding=\"utf-8\"?><a></a>");
+}
+
+RESULT
+machine_config (void)
+{
+ char *data;
+ gsize size;
+
+ if (g_file_get_contents ("../../data/net_1_1/machine.config", &data, &size, NULL)){
+ return markup_test (data);
+ }
+ printf ("Ignoring this test\n");
+ return NULL;
+}
+
+static Test markup_tests [] = {
+ {"invalid_documents", invalid_documents},
+ {"good_documents", valid_documents},
+ {"mono_domain", mono_domain},
+ {"mcs_config", mcs_config},
+ {"xml_parse", xml_parse},
+ {"machine_config", machine_config},
+ {NULL, NULL}
+};
+
+DEFINE_TEST_GROUP_INIT(markup_tests_init, markup_tests)
+
--- /dev/null
+
+#include <glib.h>
+#include "test.h"
+
+RESULT
+test_memory_zero_size_allocations ()
+{
+ gpointer p;
+
+ p = g_malloc (0);
+ if (p)
+ return FAILED ("Calling g_malloc with size zero should return NULL.");
+
+ p = g_malloc0 (0);
+ if (p)
+ return FAILED ("Calling g_malloc0 with size zero should return NULL.");
+
+ p = g_realloc (NULL, 0);
+ if (p)
+ return FAILED ("Calling g_realloc with size zero should return NULL.");
+
+ p = g_new (int, 0);
+ if (p)
+ return FAILED ("Calling g_new with size zero should return NULL.");
+
+ p = g_new0 (int, 0);
+ if (p)
+ return FAILED ("Calling g_new0 with size zero should return NULL.");
+
+ return OK;
+}
+
+
+static Test memory_tests [] = {
+ { "zero_size_allocations", test_memory_zero_size_allocations},
+ {NULL, NULL}
+};
+
+DEFINE_TEST_GROUP_INIT(memory_tests_init, memory_tests)
+
--- /dev/null
+#include <config.h>
+#include <glib.h>
+#include <gmodule.h>
+#include <string.h>
+#include <stdio.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#include "test.h"
+
+#if defined (G_OS_WIN32)
+#define EXTERNAL_SYMBOL "GetProcAddress"
+#else
+#define EXTERNAL_SYMBOL "system"
+#endif
+
+void G_MODULE_EXPORT
+dummy_test_export ()
+{
+}
+
+/* test for g_module_open (NULL, ...) */
+RESULT
+test_module_symbol_null ()
+{
+ gpointer proc = GINT_TO_POINTER (42);
+
+ GModule *m = g_module_open (NULL, G_MODULE_BIND_LAZY);
+
+ if (m == NULL)
+ return FAILED ("bind to main module failed. #0");
+
+ if (g_module_symbol (m, "__unlikely_\nexistent__", &proc))
+ return FAILED ("non-existent symbol lookup failed. #1");
+
+ if (proc)
+ return FAILED ("non-existent symbol lookup failed. #2");
+
+ if (!g_module_symbol (m, EXTERNAL_SYMBOL, &proc))
+ return FAILED ("external lookup failed. #3");
+
+ if (!proc)
+ return FAILED ("external lookup failed. #4");
+
+ if (!g_module_symbol (m, "dummy_test_export", &proc))
+ return FAILED ("in-proc lookup failed. #5");
+
+ if (!proc)
+ return FAILED ("in-proc lookup failed. #6");
+
+ if (!g_module_close (m))
+ return FAILED ("close failed. #7");
+
+ return OK;
+}
+
+static Test module_tests [] = {
+ {"g_module_symbol_null", test_module_symbol_null},
+ {NULL, NULL}
+};
+
+DEFINE_TEST_GROUP_INIT(module_tests_init, module_tests)
+
+
--- /dev/null
+#include <config.h>
+#include <glib.h>
+#include <string.h>
+#include <stdio.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#ifdef G_OS_UNIX
+#include <pthread.h>
+#endif
+#include "test.h"
+
+#ifdef G_OS_WIN32
+#include <direct.h>
+#define chdir _chdir
+#endif
+
+/* This test is just to be used with valgrind */
+RESULT
+test_buildpath ()
+{
+ char *s;
+ char *buffer = "var/private";
+ char *dir = "/";
+
+ s = g_build_path ("/", "hola///", "//mundo", NULL);
+ if (strcmp (s, "hola/mundo") != 0)
+ return FAILED ("1 Got wrong result, got: %s", s);
+ g_free (s);
+
+ s = g_build_path ("/", "hola/", "/mundo", NULL);
+ if (strcmp (s, "hola/mundo") != 0)
+ return FAILED ("2 Got wrong result, got: %s", s);
+ g_free (s);
+
+ s = g_build_path ("/", "hola/", "mundo", NULL);
+ if (strcmp (s, "hola/mundo") != 0)
+ return FAILED ("3 Got wrong result, got: %s", s);
+ g_free (s);
+
+ s = g_build_path ("/", "hola", "/mundo", NULL);
+ if (strcmp (s, "hola/mundo") != 0)
+ return FAILED ("4 Got wrong result, got: %s", s);
+ g_free (s);
+
+ s = g_build_path ("/", "/hello", "world/", NULL);
+ if (strcmp (s, "/hello/world/") != 0)
+ return FAILED ("5 Got wrong result, got: %s", s);
+ g_free (s);
+
+ /* Now test multi-char-separators */
+ s = g_build_path ("**", "hello", "world", NULL);
+ if (strcmp (s, "hello**world") != 0)
+ return FAILED ("6 Got wrong result, got: %s", s);
+ g_free (s);
+
+ s = g_build_path ("**", "hello**", "world", NULL);
+ if (strcmp (s, "hello**world") != 0)
+ return FAILED ("7 Got wrong result, got: %s", s);
+ g_free (s);
+
+ s = g_build_path ("**", "hello**", "**world", NULL);
+ if (strcmp (s, "hello**world") != 0)
+ return FAILED ("8 Got wrong result, got: %s", s);
+ g_free (s);
+
+ s = g_build_path ("**", "hello**", "**world", NULL);
+ if (strcmp (s, "hello**world") != 0)
+ return FAILED ("9 Got wrong result, got: %s", s);
+ g_free (s);
+
+ s = g_build_path ("1234567890", "hello", "world", NULL);
+ if (strcmp (s, "hello1234567890world") != 0)
+ return FAILED ("10 Got wrong result, got: %s", s);
+ g_free (s);
+
+ s = g_build_path ("1234567890", "hello1234567890", "1234567890world", NULL);
+ if (strcmp (s, "hello1234567890world") != 0)
+ return FAILED ("11 Got wrong result, got: %s", s);
+ g_free (s);
+
+ s = g_build_path ("1234567890", "hello12345678901234567890", "1234567890world", NULL);
+ if (strcmp (s, "hello1234567890world") != 0)
+ return FAILED ("12 Got wrong result, got: %s", s);
+ g_free (s);
+
+ /* Multiple */
+ s = g_build_path ("/", "a", "b", "c", "d", NULL);
+ if (strcmp (s, "a/b/c/d") != 0)
+ return FAILED ("13 Got wrong result, got: %s", s);
+ g_free (s);
+
+ s = g_build_path ("/", "/a", "", "/c/", NULL);
+ if (strcmp (s, "/a/c/") != 0)
+ return FAILED ("14 Got wrong result, got: %s", s);
+ g_free (s);
+
+ /* Null */
+ s = g_build_path ("/", NULL, NULL);
+ if (s == NULL)
+ return FAILED ("must get a non-NULL return");
+ if (s [0] != 0)
+ return FAILED ("must get an empty string");
+
+ // This is to test the regression introduced by Levi for the Windows support
+ // that code errouneously read below the allowed area (in this case dir [-1]).
+ // and caused all kinds of random errors.
+ dir = "//";
+ dir++;
+ s = g_build_filename (dir, buffer, NULL);
+ if (s [0] != '/')
+ return FAILED ("Must have a '/' at the start");
+
+ g_free (s);
+ return OK;
+}
+
+RESULT
+test_buildfname ()
+{
+ char *s;
+
+ s = g_build_filename ("a", "b", "c", "d", NULL);
+#ifdef G_OS_WIN32
+ if (strcmp (s, "a\\b\\c\\d") != 0)
+#else
+ if (strcmp (s, "a/b/c/d") != 0)
+#endif
+ return FAILED ("1 Got wrong result, got: %s", s);
+ g_free (s);
+
+#ifdef G_OS_WIN32
+ s = g_build_filename ("C:\\", "a", NULL);
+ if (strcmp (s, "C:\\a") != 0)
+#else
+ s = g_build_filename ("/", "a", NULL);
+ if (strcmp (s, "/a") != 0)
+#endif
+ return FAILED ("1 Got wrong result, got: %s", s);
+
+#ifndef G_OS_WIN32
+ s = g_build_filename ("/", "foo", "/bar", "tolo/", "/meo/", NULL);
+ if (strcmp (s, "/foo/bar/tolo/meo/") != 0)
+ return FAILED ("1 Got wrong result, got: %s", s);
+#endif
+
+ return OK;
+}
+
+char *
+test_dirname ()
+{
+ char *s;
+
+#ifdef G_OS_WIN32
+ s = g_path_get_dirname ("c:\\home\\miguel");
+ if (strcmp (s, "c:\\home") != 0)
+ return FAILED ("Expected c:\\home, got %s", s);
+ g_free (s);
+
+ s = g_path_get_dirname ("c:/home/miguel");
+ if (strcmp (s, "c:/home") != 0)
+ return FAILED ("Expected c:/home, got %s", s);
+ g_free (s);
+
+ s = g_path_get_dirname ("c:\\home\\dingus\\");
+ if (strcmp (s, "c:\\home\\dingus") != 0)
+ return FAILED ("Expected c:\\home\\dingus, got %s", s);
+ g_free (s);
+
+ s = g_path_get_dirname ("dir.c");
+ if (strcmp (s, ".") != 0)
+ return FAILED ("Expected `.', got %s", s);
+ g_free (s);
+
+ s = g_path_get_dirname ("c:\\index.html");
+ if (strcmp (s, "c:") != 0)
+ return FAILED ("Expected [c:], got [%s]", s);
+#else
+ s = g_path_get_dirname ("/home/miguel");
+ if (strcmp (s, "/home") != 0)
+ return FAILED ("Expected /home, got %s", s);
+ g_free (s);
+
+ s = g_path_get_dirname ("/home/dingus/");
+ if (strcmp (s, "/home/dingus") != 0)
+ return FAILED ("Expected /home/dingus, got %s", s);
+ g_free (s);
+
+ s = g_path_get_dirname ("dir.c");
+ if (strcmp (s, ".") != 0)
+ return FAILED ("Expected `.', got %s", s);
+ g_free (s);
+
+ s = g_path_get_dirname ("/index.html");
+ if (strcmp (s, "/") != 0)
+ return FAILED ("Expected [/], got [%s]", s);
+#endif
+ return OK;
+}
+
+char *
+test_basename ()
+{
+ char *s;
+
+#ifdef G_OS_WIN32
+ s = g_path_get_basename ("");
+ if (strcmp (s, ".") != 0)
+ return FAILED ("Expected `.', got %s", s);
+ g_free (s);
+
+ s = g_path_get_basename ("c:\\home\\dingus\\");
+ if (strcmp (s, "dingus") != 0)
+ return FAILED ("1 Expected dingus, got %s", s);
+ g_free (s);
+
+ s = g_path_get_basename ("c:/home/dingus/");
+ if (strcmp (s, "dingus") != 0)
+ return FAILED ("1 Expected dingus, got %s", s);
+ g_free (s);
+
+ s = g_path_get_basename ("c:\\home\\dingus");
+ if (strcmp (s, "dingus") != 0)
+ return FAILED ("2 Expected dingus, got %s", s);
+ g_free (s);
+
+ s = g_path_get_basename ("c:/home/dingus");
+ if (strcmp (s, "dingus") != 0)
+ return FAILED ("2 Expected dingus, got %s", s);
+ g_free (s);
+#else
+ s = g_path_get_basename ("");
+ if (strcmp (s, ".") != 0)
+ return FAILED ("Expected `.', got %s", s);
+ g_free (s);
+
+ s = g_path_get_basename ("/home/dingus/");
+ if (strcmp (s, "dingus") != 0)
+ return FAILED ("1 Expected dingus, got %s", s);
+ g_free (s);
+
+ s = g_path_get_basename ("/home/dingus");
+ if (strcmp (s, "dingus") != 0)
+ return FAILED ("2 Expected dingus, got %s", s);
+ g_free (s);
+#endif
+ return OK;
+}
+
+gchar *
+test_ppath ()
+{
+ char *s;
+#ifdef G_OS_WIN32
+ const gchar *searchfor = "explorer.exe";
+#else
+ const gchar *searchfor = "ls";
+#endif
+ s = g_find_program_in_path (searchfor);
+ if (s == NULL)
+ return FAILED ("No %s on this system?", searchfor);
+ g_free (s);
+ return OK;
+}
+
+gchar *
+test_ppath2 ()
+{
+ char *s;
+ const char *path = g_getenv ("PATH");
+#ifdef G_OS_WIN32
+ const gchar *searchfor = "test_eglib.exe";
+#else
+ const gchar *searchfor = "test-glib";
+#endif
+
+ g_setenv ("PATH", "", TRUE);
+ s = g_find_program_in_path ("ls");
+ if (s != NULL) {
+ g_setenv ("PATH", path, TRUE);
+ return FAILED ("Found something interesting here: %s", s);
+ }
+ g_free (s);
+ s = g_find_program_in_path (searchfor);
+ if (s == NULL) {
+ g_setenv ("PATH", path, TRUE);
+ return FAILED ("It should find '%s' in the current directory.", searchfor);
+ }
+ g_free (s);
+ g_setenv ("PATH", path, TRUE);
+ return OK;
+}
+
+#ifndef DISABLE_FILESYSTEM_TESTS
+gchar *
+test_cwd ()
+{
+ char *dir = g_get_current_dir ();
+#ifdef G_OS_WIN32
+ const gchar *newdir = "C:\\Windows";
+#else
+ const gchar *newdir = "/bin";
+#endif
+
+ if (dir == NULL)
+ return FAILED ("No current directory?");
+ g_free (dir);
+
+ if (chdir (newdir) == -1)
+ return FAILED ("No %s?", newdir);
+
+ dir = g_get_current_dir ();
+ if (strcmp (dir, newdir) != 0)
+ return FAILED("Did not go to %s?", newdir);
+ g_free (dir);
+
+ return OK;
+}
+#else
+gchar *
+test_cwd ()
+{
+ return OK;
+}
+#endif
+
+gchar *
+test_misc ()
+{
+ const char *home = g_get_home_dir ();
+ const char *tmp = g_get_tmp_dir ();
+
+ if (home == NULL)
+ return FAILED ("Where did my home go?");
+
+ if (tmp == NULL)
+ return FAILED ("Where did my /tmp go?");
+
+ return OK;
+}
+
+static Test path_tests [] = {
+ {"g_build_filename", test_buildfname},
+ {"g_buildpath", test_buildpath},
+ {"g_path_get_dirname", test_dirname},
+ {"g_path_get_basename", test_basename},
+ {"g_find_program_in_path", test_ppath},
+ {"g_find_program_in_path2", test_ppath2},
+ {"test_cwd", test_cwd },
+ {"test_misc", test_misc },
+ {NULL, NULL}
+};
+
+DEFINE_TEST_GROUP_INIT(path_tests_init, path_tests)
+
+
--- /dev/null
+#include <config.h>
+#include <glib.h>
+#include <string.h>
+#include <stdlib.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#include <stdio.h>
+#include "test.h"
+
+#define MATCH(pat,string,error_if,msg) \
+ spec = g_pattern_spec_new (pat); \
+ res = g_pattern_match_string (spec, string); \
+ if (res == error_if) \
+ return FAILED (msg " returned %s", res ? "TRUE" : "FALSE"); \
+ g_pattern_spec_free (spec);
+
+#define TEST_MATCH(pat,string,n) MATCH (pat, string, FALSE, "MATCH " #n)
+#define TEST_NO_MATCH(pat,string,n) MATCH (pat, string,TRUE, "NO_MATCH " #n)
+
+RESULT
+test_pattern_spec ()
+{
+ GPatternSpec *spec;
+ gboolean res;
+
+ /* spec = g_pattern_spec_new (NULL); */
+ TEST_MATCH ("*", "hola", 1);
+ TEST_MATCH ("hola", "hola", 2);
+ TEST_MATCH ("????", "hola", 3);
+ TEST_MATCH ("???a", "hola", 4);
+ TEST_MATCH ("h??a", "hola", 5);
+ TEST_MATCH ("h??*", "hola", 6);
+ TEST_MATCH ("h*", "hola", 7);
+ TEST_MATCH ("*hola", "hola", 8);
+ TEST_MATCH ("*l*", "hola", 9);
+ TEST_MATCH ("h*??", "hola", 10);
+ TEST_MATCH ("h*???", "hola", 11);
+ TEST_MATCH ("?o??", "hola", 12);
+ TEST_MATCH ("*h*o*l*a*", "hola", 13);
+ TEST_MATCH ("h*o*l*a", "hola", 14);
+ TEST_MATCH ("h?*?", "hola", 15);
+
+ TEST_NO_MATCH ("", "hola", 1);
+ TEST_NO_MATCH ("?????", "hola", 2);
+ TEST_NO_MATCH ("???", "hola", 3);
+ TEST_NO_MATCH ("*o", "hola", 4);
+ TEST_NO_MATCH ("h", "hola", 5);
+ TEST_NO_MATCH ("h*????", "hola", 6);
+
+ return OK;
+}
+
+static Test pattern_tests [] = {
+ {"g_pattern_spec*", test_pattern_spec},
+ {NULL, NULL}
+};
+
+DEFINE_TEST_GROUP_INIT(pattern_tests_init, pattern_tests)
+
+
--- /dev/null
+#include <stdio.h>
+#include <glib.h>
+#include "test.h"
+
+/* Redefine the private structure only to verify proper allocations */
+typedef struct _GPtrArrayPriv {
+ gpointer *pdata;
+ guint len;
+ guint size;
+} GPtrArrayPriv;
+
+/* Don't add more than 32 items to this please */
+static const char *items [] = {
+ "Apples", "Oranges", "Plumbs", "Goats", "Snorps", "Grapes",
+ "Tickle", "Place", "Coffee", "Cookies", "Cake", "Cheese",
+ "Tseng", "Holiday", "Avenue", "Smashing", "Water", "Toilet",
+ NULL
+};
+
+static GPtrArray *ptrarray_alloc_and_fill(guint *item_count)
+{
+ GPtrArray *array = g_ptr_array_new();
+ gint i;
+
+ for(i = 0; items[i] != NULL; i++) {
+ g_ptr_array_add(array, (gpointer)items[i]);
+ }
+
+ if(item_count != NULL) {
+ *item_count = i;
+ }
+
+ return array;
+}
+
+static guint guess_size(guint length)
+{
+ guint size = 1;
+
+ while(size < length) {
+ size <<= 1;
+ }
+
+ return size;
+}
+
+RESULT ptrarray_alloc()
+{
+ GPtrArrayPriv *array;
+ guint i;
+
+ array = (GPtrArrayPriv *)ptrarray_alloc_and_fill(&i);
+
+ if(array->size != guess_size(array->len)) {
+ return FAILED("Size should be %d, but it is %d",
+ guess_size(array->len), array->size);
+ }
+
+ if(array->len != i) {
+ return FAILED("Expected %d node(s) in the array", i);
+ }
+
+ g_ptr_array_free((GPtrArray *)array, TRUE);
+
+ return OK;
+}
+
+RESULT ptrarray_for_iterate()
+{
+ GPtrArray *array = ptrarray_alloc_and_fill(NULL);
+ guint i;
+
+ for(i = 0; i < array->len; i++) {
+ char *item = (char *)g_ptr_array_index(array, i);
+ if(item != items[i]) {
+ return FAILED(
+ "Expected item at %d to be %s, but it was %s",
+ i, items[i], item);
+ }
+ }
+
+ g_ptr_array_free(array, TRUE);
+
+ return OK;
+}
+
+static gint foreach_iterate_index = 0;
+static char *foreach_iterate_error = NULL;
+
+void foreach_callback(gpointer data, gpointer user_data)
+{
+ char *item = (char *)data;
+ const char *item_cmp = items[foreach_iterate_index++];
+
+ if(foreach_iterate_error != NULL) {
+ return;
+ }
+
+ if(item != item_cmp) {
+ foreach_iterate_error = FAILED(
+ "Expected item at %d to be %s, but it was %s",
+ foreach_iterate_index - 1, item_cmp, item);
+ }
+}
+
+RESULT ptrarray_foreach_iterate()
+{
+ GPtrArray *array = ptrarray_alloc_and_fill(NULL);
+
+ foreach_iterate_index = 0;
+ foreach_iterate_error = NULL;
+
+ g_ptr_array_foreach(array, foreach_callback, array);
+
+ g_ptr_array_free(array, TRUE);
+
+ return foreach_iterate_error;
+}
+
+RESULT ptrarray_set_size()
+{
+ GPtrArray *array = g_ptr_array_new();
+ guint i, grow_length = 50;
+
+ g_ptr_array_add(array, (gpointer)items[0]);
+ g_ptr_array_add(array, (gpointer)items[1]);
+ g_ptr_array_set_size(array, grow_length);
+
+ if(array->len != grow_length) {
+ return FAILED("Array length should be 50, it is %d", array->len);
+ } else if(array->pdata[0] != items[0]) {
+ return FAILED("Item 0 was overwritten, should be %s", items[0]);
+ } else if(array->pdata[1] != items[1]) {
+ return FAILED("Item 1 was overwritten, should be %s", items[1]);
+ }
+
+ for(i = 2; i < array->len; i++) {
+ if(array->pdata[i] != NULL) {
+ return FAILED("Item %d is not NULL, it is %p", i, array->pdata[i]);
+ }
+ }
+
+ g_ptr_array_free(array, TRUE);
+
+ return OK;
+}
+
+RESULT ptrarray_remove_index()
+{
+ GPtrArray *array;
+ guint i;
+
+ array = ptrarray_alloc_and_fill(&i);
+
+ g_ptr_array_remove_index(array, 0);
+ if(array->pdata[0] != items[1]) {
+ return FAILED("First item is not %s, it is %s", items[1],
+ array->pdata[0]);
+ }
+
+ g_ptr_array_remove_index(array, array->len - 1);
+
+ if(array->pdata[array->len - 1] != items[array->len]) {
+ return FAILED("Last item is not %s, it is %s",
+ items[array->len - 2], array->pdata[array->len - 1]);
+ }
+
+ g_ptr_array_free(array, TRUE);
+
+ return OK;
+}
+
+RESULT ptrarray_remove_index_fast()
+{
+ GPtrArray *array;
+ guint i;
+
+ array = ptrarray_alloc_and_fill(&i);
+
+ g_ptr_array_remove_index_fast(array, 0);
+ if(array->pdata[0] != items[array->len]) {
+ return FAILED("First item is not %s, it is %s", items[array->len],
+ array->pdata[0]);
+ }
+
+ g_ptr_array_remove_index_fast(array, array->len - 1);
+ if(array->pdata[array->len - 1] != items[array->len - 1]) {
+ return FAILED("Last item is not %s, it is %s",
+ items[array->len - 1], array->pdata[array->len - 1]);
+ }
+
+ g_ptr_array_free(array, TRUE);
+
+ return OK;
+}
+
+RESULT ptrarray_remove()
+{
+ GPtrArray *array;
+ guint i;
+
+ array = ptrarray_alloc_and_fill(&i);
+
+ g_ptr_array_remove(array, (gpointer)items[7]);
+
+ if(!g_ptr_array_remove(array, (gpointer)items[4])) {
+ return FAILED("Item %s not removed", items[4]);
+ }
+
+ if(g_ptr_array_remove(array, (gpointer)items[4])) {
+ return FAILED("Item %s still in array after removal", items[4]);
+ }
+
+ if(array->pdata[array->len - 1] != items[array->len + 1]) {
+ return FAILED("Last item in GPtrArray not correct");
+ }
+
+ g_ptr_array_free(array, TRUE);
+
+ return OK;
+}
+
+static gint ptrarray_sort_compare(gconstpointer a, gconstpointer b)
+{
+ gchar *stra = *(gchar **) a;
+ gchar *strb = *(gchar **) b;
+ return strcmp(stra, strb);
+}
+
+RESULT ptrarray_sort()
+{
+ GPtrArray *array = g_ptr_array_new();
+ guint i;
+ gchar *letters [] = { "A", "B", "C", "D", "E" };
+
+ g_ptr_array_add(array, letters[0]);
+ g_ptr_array_add(array, letters[1]);
+ g_ptr_array_add(array, letters[2]);
+ g_ptr_array_add(array, letters[3]);
+ g_ptr_array_add(array, letters[4]);
+
+ g_ptr_array_sort(array, ptrarray_sort_compare);
+
+ for(i = 0; i < array->len; i++) {
+ if(array->pdata[i] != letters[i]) {
+ return FAILED("Array out of order, expected %s got %s at position %d",
+ letters [i], (gchar *) array->pdata [i], i);
+ }
+ }
+
+ g_ptr_array_free(array, TRUE);
+
+ return OK;
+}
+
+static gint ptrarray_sort_compare_with_data (gconstpointer a, gconstpointer b, gpointer user_data)
+{
+ gchar *stra = *(gchar **) a;
+ gchar *strb = *(gchar **) b;
+
+ if (strcmp (user_data, "this is the data for qsort") != 0)
+ fprintf (stderr, "oops at compare with_data\n");
+
+ return strcmp(stra, strb);
+}
+
+RESULT ptrarray_sort_with_data ()
+{
+ GPtrArray *array = g_ptr_array_new();
+ guint i;
+ gchar *letters [] = { "A", "B", "C", "D", "E" };
+
+ g_ptr_array_add(array, letters[4]);
+ g_ptr_array_add(array, letters[1]);
+ g_ptr_array_add(array, letters[2]);
+ g_ptr_array_add(array, letters[0]);
+ g_ptr_array_add(array, letters[3]);
+
+ g_ptr_array_sort_with_data(array, ptrarray_sort_compare_with_data, "this is the data for qsort");
+
+ for(i = 0; i < array->len; i++) {
+ if(array->pdata[i] != letters[i]) {
+ return FAILED("Array out of order, expected %s got %s at position %d",
+ letters [i], (gchar *) array->pdata [i], i);
+ }
+ }
+
+ g_ptr_array_free(array, TRUE);
+
+ return OK;
+}
+
+RESULT ptrarray_remove_fast()
+{
+ GPtrArray *array = g_ptr_array_new();
+ gchar *letters [] = { "A", "B", "C", "D", "E" };
+
+ if (g_ptr_array_remove_fast (array, NULL))
+ return FAILED ("Removing NULL succeeded");
+
+ g_ptr_array_add(array, letters[0]);
+ if (!g_ptr_array_remove_fast (array, letters[0]) || array->len != 0)
+ return FAILED ("Removing last element failed");
+
+ g_ptr_array_add(array, letters[0]);
+ g_ptr_array_add(array, letters[1]);
+ g_ptr_array_add(array, letters[2]);
+ g_ptr_array_add(array, letters[3]);
+ g_ptr_array_add(array, letters[4]);
+
+ if (!g_ptr_array_remove_fast (array, letters[0]) || array->len != 4)
+ return FAILED ("Removing first element failed");
+
+ if (array->pdata [0] != letters [4])
+ return FAILED ("First element wasn't replaced with last upon removal");
+
+ if (g_ptr_array_remove_fast (array, letters[0]))
+ return FAILED ("Succedeed removing a non-existing element");
+
+ if (!g_ptr_array_remove_fast (array, letters[3]) || array->len != 3)
+ return FAILED ("Failed removing \"D\"");
+
+ if (!g_ptr_array_remove_fast (array, letters[1]) || array->len != 2)
+ return FAILED ("Failed removing \"B\"");
+
+ if (array->pdata [0] != letters [4] || array->pdata [1] != letters [2])
+ return FAILED ("Last two elements are wrong");
+ g_ptr_array_free(array, TRUE);
+
+ return OK;
+}
+
+static Test ptrarray_tests [] = {
+ {"alloc", ptrarray_alloc},
+ {"for_iterate", ptrarray_for_iterate},
+ {"foreach_iterate", ptrarray_foreach_iterate},
+ {"set_size", ptrarray_set_size},
+ {"remove_index", ptrarray_remove_index},
+ {"remove_index_fast", ptrarray_remove_index_fast},
+ {"remove", ptrarray_remove},
+ {"sort", ptrarray_sort},
+ {"remove_fast", ptrarray_remove_fast},
+ {"sort_with_data", ptrarray_sort_with_data},
+ {NULL, NULL}
+};
+
+DEFINE_TEST_GROUP_INIT(ptrarray_tests_init, ptrarray_tests)
+
+
--- /dev/null
+#include <stdio.h>
+#include <string.h>
+#include <glib.h>
+#include "test.h"
+
+RESULT
+test_queue_push ()
+{
+ GQueue *queue = g_queue_new ();
+
+ g_queue_push_head (queue, "foo");
+ g_queue_push_head (queue, "bar");
+ g_queue_push_head (queue, "baz");
+
+ if (queue->length != 3)
+ return FAILED ("push failed");
+
+ if (NULL != queue->head->prev)
+ return FAILED ("HEAD: prev is wrong");
+ if (strcmp ("baz", queue->head->data))
+ return FAILED ("HEAD: First element is wrong");
+ if (strcmp ("bar", queue->head->next->data))
+ return FAILED ("HEAD: Second element is wrong");
+ if (strcmp ("foo", queue->head->next->next->data))
+ return FAILED ("HEAD: Third element is wrong");
+ if (NULL != queue->head->next->next->next)
+ return FAILED ("HEAD: End is wrong");
+
+ if (NULL != queue->tail->next)
+ return FAILED ("TAIL: next is wrong");
+ if (strcmp ("foo", queue->tail->data))
+ return FAILED ("TAIL: Third element is wrong");
+ if (strcmp ("bar", queue->tail->prev->data))
+ return FAILED ("TAIL: Second element is wrong");
+ if (strcmp ("baz", queue->tail->prev->prev->data))
+ return FAILED ("TAIL: First element is wrong");
+ if (NULL != queue->tail->prev->prev->prev)
+ return FAILED ("TAIL: End is wrong");
+
+ g_queue_free (queue);
+ return OK;
+}
+
+RESULT
+test_queue_push_tail ()
+{
+ GQueue *queue = g_queue_new ();
+
+ g_queue_push_tail (queue, "baz");
+ g_queue_push_tail (queue, "bar");
+ g_queue_push_tail (queue, "foo");
+
+ if (queue->length != 3)
+ return FAILED ("push failed");
+
+ if (NULL != queue->head->prev)
+ return FAILED ("HEAD: prev is wrong");
+ if (strcmp ("baz", queue->head->data))
+ return FAILED ("HEAD: First element is wrong");
+ if (strcmp ("bar", queue->head->next->data))
+ return FAILED ("HEAD: Second element is wrong");
+ if (strcmp ("foo", queue->head->next->next->data))
+ return FAILED ("HEAD: Third element is wrong");
+ if (NULL != queue->head->next->next->next)
+ return FAILED ("HEAD: End is wrong");
+
+ if (NULL != queue->tail->next)
+ return FAILED ("TAIL: next is wrong");
+ if (strcmp ("foo", queue->tail->data))
+ return FAILED ("TAIL: Third element is wrong");
+ if (strcmp ("bar", queue->tail->prev->data))
+ return FAILED ("TAIL: Second element is wrong");
+ if (strcmp ("baz", queue->tail->prev->prev->data))
+ return FAILED ("TAIL: First element is wrong");
+ if (NULL != queue->tail->prev->prev->prev)
+ return FAILED ("TAIL: End is wrong");
+
+ g_queue_free (queue);
+ return OK;
+}
+
+RESULT
+test_queue_pop ()
+{
+ GQueue *queue = g_queue_new ();
+ gpointer data;
+
+ g_queue_push_head (queue, "foo");
+ g_queue_push_head (queue, "bar");
+ g_queue_push_head (queue, "baz");
+
+ data = g_queue_pop_head (queue);
+ if (strcmp ("baz", data))
+ return FAILED ("expect baz.");
+
+ data = g_queue_pop_head (queue);
+ if (strcmp ("bar", data))
+ return FAILED ("expect bar.");
+
+ data = g_queue_pop_head (queue);
+ if (strcmp ("foo", data))
+ return FAILED ("expect foo.");
+
+ if (g_queue_is_empty (queue) == FALSE)
+ return FAILED ("expect is_empty.");
+
+ if (queue->length != 0)
+ return FAILED ("expect 0 length .");
+
+ g_queue_push_head (queue, "foo");
+ g_queue_push_head (queue, "bar");
+ g_queue_push_head (queue, "baz");
+
+ g_queue_pop_head (queue);
+
+ if (NULL != queue->head->prev)
+ return FAILED ("HEAD: prev is wrong");
+ if (strcmp ("bar", queue->head->data))
+ return FAILED ("HEAD: Second element is wrong");
+ if (strcmp ("foo", queue->head->next->data))
+ return FAILED ("HEAD: Third element is wrong");
+ if (NULL != queue->head->next->next)
+ return FAILED ("HEAD: End is wrong");
+
+ if (NULL != queue->tail->next)
+ return FAILED ("TAIL: next is wrong");
+ if (strcmp ("foo", queue->tail->data))
+ return FAILED ("TAIL: Second element is wrong");
+ if (strcmp ("bar", queue->tail->prev->data))
+ return FAILED ("TAIL: First element is wrong");
+ if (NULL != queue->tail->prev->prev)
+ return FAILED ("TAIL: End is wrong");
+
+ g_queue_free (queue);
+ return OK;
+}
+
+RESULT
+test_queue_new ()
+{
+ GQueue *queue = g_queue_new ();
+
+ if (queue->length != 0)
+ return FAILED ("expect length == 0");
+
+ if (queue->head != NULL)
+ return FAILED ("expect head == NULL");
+
+ if (queue->tail != NULL)
+ return FAILED ("expect tail == NULL");
+
+ g_queue_free (queue);
+ return OK;
+}
+
+RESULT
+test_queue_is_empty ()
+{
+ GQueue *queue = g_queue_new ();
+
+ if (g_queue_is_empty (queue) == FALSE)
+ return FAILED ("new queue should be empty");
+
+ g_queue_push_head (queue, "foo");
+
+ if (g_queue_is_empty (queue) == TRUE)
+ return FAILED ("expected TRUE");
+
+ g_queue_free (queue);
+
+ return OK;
+}
+
+static Test queue_tests [] = {
+ { "push", test_queue_push},
+ {"push_tail", test_queue_push_tail},
+ { "pop", test_queue_pop},
+ { "new", test_queue_new},
+ {"is_empty", test_queue_is_empty},
+ {NULL, NULL}
+};
+
+DEFINE_TEST_GROUP_INIT(queue_tests_init, queue_tests)
+
--- /dev/null
+#include <glib.h>
+#include <string.h>
+#include <stdio.h>
+#include "test.h"
+
+RESULT
+test_shell_argv1 ()
+{
+ GError *error;
+ gint argc;
+ gchar **argv;
+ gboolean ret;
+
+ /* The next line prints a critical error and returns FALSE
+ ret = g_shell_parse_argv (NULL, NULL, NULL, NULL);
+ */
+ ret = g_shell_parse_argv ("", NULL, NULL, NULL);
+ if (ret)
+ return FAILED ("1. It should return FALSE");
+
+ ret = g_shell_parse_argv ("hola", NULL, NULL, NULL);
+ if (!ret)
+ return FAILED ("2. It should return TRUE");
+
+ argc = 0;
+ ret = g_shell_parse_argv ("hola", &argc, NULL, NULL);
+ if (!ret)
+ return FAILED ("3. It should return TRUE");
+ if (argc != 1)
+ return FAILED ("4. argc was %d", argc);
+
+ argc = 0;
+ ret = g_shell_parse_argv ("hola bola", &argc, NULL, NULL);
+ if (!ret)
+ return FAILED ("5. It should return TRUE");
+ if (argc != 2)
+ return FAILED ("6. argc was %d", argc);
+
+ argc = 0;
+ ret = g_shell_parse_argv ("hola bola", &argc, &argv, NULL);
+ if (!ret)
+ return FAILED ("7. It should return TRUE");
+ if (argc != 2)
+ return FAILED ("8. argc was %d", argc);
+ if (strcmp (argv [0], "hola"))
+ return FAILED ("9. argv[0] was %s", argv [0]);
+ if (strcmp (argv [1], "bola"))
+ return FAILED ("10. argv[1] was %s", argv [1]);
+
+ g_strfreev (argv);
+ argv = NULL;
+ argc = 0;
+ error = NULL;
+ ret = g_shell_parse_argv ("hola 'bola'", &argc, &argv, &error);
+ if (!ret)
+ return FAILED ("11. It should return TRUE");
+ if (argc != 2)
+ return FAILED ("12. argc was %d expected 2", argc);
+ if (strcmp (argv [0], "hola"))
+ return FAILED ("13. argv[0] was %s", argv [0]);
+ if (strcmp (argv [1], "bola"))
+ return FAILED ("14. argv[1] was %s", argv [1]);
+ if (error != NULL)
+ return FAILED ("15. error is not null");
+
+
+ g_strfreev (argv);
+ argv = NULL;
+ argc = 0;
+ error = NULL;
+ ret = g_shell_parse_argv ("hola '' 'bola'", &argc, &argv, &error);
+ if (!ret)
+ return FAILED ("16. It should return TRUE");
+ if (argc != 3)
+ return FAILED ("17. argc was %d expected 3", argc);
+ if (strcmp (argv [0], "hola"))
+ return FAILED ("18. argv[0] was %s", argv [0]);
+ if (strcmp (argv [1], ""))
+ return FAILED ("19. argv[2] was %s", argv [1]);
+ if (strcmp (argv [2], "bola"))
+ return FAILED ("19. argv[2] was %s", argv [2]);
+ if (error != NULL)
+ return FAILED ("20. error is not null");
+
+ g_strfreev (argv);
+ argv = NULL;
+ argc = 0;
+ error = NULL;
+ ret = g_shell_parse_argv ("hola'' bola", &argc, &argv, &error);
+ if (!ret)
+ return FAILED ("21. It should return TRUE");
+ if (argc != 2)
+ return FAILED ("22. argc was %d expected 2", argc);
+ if (strcmp (argv [0], "hola"))
+ return FAILED ("23. argv[0] was %s", argv [0]);
+ if (strcmp (argv [1], "bola"))
+ return FAILED ("24. argv[2] was %s", argv [1]);
+ if (error != NULL)
+ return FAILED ("25. error is not null");
+
+ return OK;
+}
+
+RESULT
+test_shell_argv2 ()
+{
+ GError *error;
+ gint argc;
+ gchar **argv;
+ gboolean ret;
+
+ argv = NULL;
+ argc = 0;
+ error = NULL;
+ ret = g_shell_parse_argv ("hola \"bola\"", &argc, &argv, &error);
+ if (!ret)
+ return FAILED ("1. It should return TRUE");
+ if (argc != 2)
+ return FAILED ("2. argc was %d expected 2", argc);
+ if (strcmp (argv [0], "hola"))
+ return FAILED ("3. argv[0] was %s", argv [0]);
+ if (strcmp (argv [1], "bola"))
+ return FAILED ("4. argv[1] was %s", argv [1]);
+ if (error != NULL)
+ return FAILED ("5. error is not null");
+
+ g_strfreev (argv);
+ argv = NULL;
+ argc = 0;
+ error = NULL;
+ ret = g_shell_parse_argv ("hola \"\" \"bola \"", &argc, &argv, &error);
+ if (!ret)
+ return FAILED ("6. It should return TRUE");
+ if (argc != 3)
+ return FAILED ("7. argc was %d expected 3", argc);
+ if (strcmp (argv [0], "hola"))
+ return FAILED ("8. argv[0] was %s", argv [0]);
+ if (strcmp (argv [1], ""))
+ return FAILED ("9. argv[2] was %s", argv [1]);
+ if (strcmp (argv [2], "bola "))
+ return FAILED ("10. argv[2] was %s", argv [2]);
+ if (error != NULL)
+ return FAILED ("11. error is not null");
+
+ g_strfreev (argv);
+ argv = NULL;
+ argc = 0;
+ error = NULL;
+ ret = g_shell_parse_argv ("hola\n\t \"\t\" \"bola \"", &argc, &argv, &error);
+ if (!ret)
+ return FAILED ("10. It should return TRUE");
+ if (argc != 3)
+ return FAILED ("11. argc was %d expected 3", argc);
+ if (strcmp (argv [0], "hola"))
+ return FAILED ("12. argv[0] was %s", argv [0]);
+ if (strcmp (argv [1], "\t"))
+ return FAILED ("13. argv[2] was %s", argv [1]);
+ if (strcmp (argv [2], "bola "))
+ return FAILED ("14. argv[2] was %s", argv [2]);
+ if (error != NULL)
+ return FAILED ("15. error is not null");
+
+ g_strfreev (argv);
+ argv = NULL;
+ argc = 0;
+ error = NULL;
+ ret = g_shell_parse_argv ("hola\n\t \\\n \"\t\" \"bola \"", &argc, &argv, &error);
+ if (!ret)
+ return FAILED ("16. It should return TRUE");
+ if (argc != 3)
+ return FAILED ("17. argc was %d expected 3", argc);
+ if (strcmp (argv [0], "hola"))
+ return FAILED ("18. argv[0] was %s", argv [0]);
+ if (strcmp (argv [1], "\t"))
+ return FAILED ("19. argv[2] was %s", argv [1]);
+ if (strcmp (argv [2], "bola "))
+ return FAILED ("20. argv[2] was %s", argv [2]);
+ if (error != NULL)
+ return FAILED ("21. error is not null");
+
+ g_strfreev (argv);
+ return OK;
+}
+
+RESULT
+test_shell_argv3 ()
+{
+ GError *error;
+ gint argc;
+ gchar **argv;
+ gboolean ret;
+
+ argv = NULL;
+ argc = 0;
+ error = NULL;
+ ret = g_shell_parse_argv ("hola \"bola", &argc, &argv, &error);
+ if (ret)
+ return FAILED ("1. It should return FALSE");
+ if (argc != 0)
+ return FAILED ("2. argc was %d expected 0", argc);
+ if (argv != NULL)
+ return FAILED ("3. argv[0] was %s", argv [0]);
+ if (error == NULL)
+ return FAILED ("4. error is null");
+
+ /* Text ended before matching quote was found for ". (The text was 'hola "bola') */
+ g_error_free (error);
+ error = NULL;
+ ret = g_shell_parse_argv ("hola \\\"bola", &argc, &argv, &error);
+ if (!ret)
+ return FAILED ("5. It should return TRUE");
+ if (argc != 2)
+ return FAILED ("6. argc was %d expected 2", argc);
+ if (strcmp (argv [0], "hola"))
+ return FAILED ("18. argv[0] was %s", argv [0]);
+ if (strcmp (argv [1], "\"bola"))
+ return FAILED ("18. argv[1] was %s", argv [1]);
+ if (error != NULL)
+ return FAILED ("8. error is not null");
+
+ g_strfreev (argv);
+ argv = NULL;
+ argc = 0;
+ ret = g_shell_parse_argv ("hola \"\n\\'bola\"", &argc, &argv, &error);
+ if (!ret)
+ return FAILED ("9. It should return TRUE. %s", error->message);
+ if (argc != 2)
+ return FAILED ("10. argc was %d expected 2", argc);
+ if (strcmp (argv [0], "hola"))
+ return FAILED ("11. argv[0] was %s", argv [0]);
+ if (strcmp (argv [1], "\n\\'bola"))
+ return FAILED ("12. argv[1] was %s", argv [1]);
+ if (error != NULL)
+ return FAILED ("13. error is not null");
+
+ g_strfreev (argv);
+ argv = NULL;
+ argc = 0;
+ return OK;
+}
+
+// This was the 2.8 showstopper error
+RESULT
+test_shell_argv4 ()
+{
+ GError *error;
+ gint argc;
+ gchar **argv;
+ gboolean ret;
+ char *str = "'/usr/bin/gnome-terminal' -e \"bash -c 'read -p \\\"Press any key to continue...\\\" -n1;'\"";
+
+ argv = NULL;
+ argc = 0;
+ error = NULL;
+ ret = g_shell_parse_argv (str, &argc, &argv, &error);
+ if (!ret)
+ return FAILED ("1. It should return TRUE");
+ if (argc != 3)
+ return FAILED ("2. argc was %d expected 3", argc);
+ if (argv == NULL)
+ return FAILED ("3. argv[0] was NULL");
+ if (error != NULL)
+ return FAILED ("4. error was set");
+
+ if (strcmp (argv [0], "/usr/bin/gnome-terminal"))
+ return FAILED ("5. Expected /usr/bin/gnome-terminal got %s", argv [0]);
+ if (strcmp (argv [1], "-e"))
+ return FAILED ("6. Expected -e, got: %s", argv [1]);
+ if (strcmp (argv [2], "bash -c 'read -p \"Press any key to continue...\" -n1;'"))
+ return FAILED ("7. Got unexpected result: %s\n", argv [2]);
+
+ return OK;
+}
+
+// This is https://bugzilla.novell.com/show_bug.cgi?id=655896
+RESULT
+test_shell_argv5 ()
+{
+ GError *error;
+ gint argc;
+ gchar **argv;
+ gboolean ret;
+ char *str = "echo \"foo\",\"bar\"";
+
+ argv = NULL;
+ argc = 0;
+ error = NULL;
+ ret = g_shell_parse_argv (str, &argc, &argv, &error);
+ if (!ret)
+ return FAILED ("1. It should return TRUE");
+ if (argc != 2)
+ return FAILED ("2. argc was %d expected 2", argc);
+ if (argv == NULL)
+ return FAILED ("3. argv[0] was NULL");
+ if (error != NULL)
+ return FAILED ("4. error was set");
+
+ if (strcmp (argv [0], "echo"))
+ return FAILED ("5. Expected echo got %s", argv [0]);
+ if (strcmp (argv [1], "foo,bar"))
+ return FAILED ("6. Expected foo,bar, got: %s", argv [1]);
+
+ return OK;
+}
+
+RESULT
+test_quote ()
+{
+ if (strcmp (g_shell_quote ("foo"), "'foo'"))
+ return FAILED ("Should return 'foo'");
+
+ if (strcmp (g_shell_quote ("foo'bar"), "'foo'\\''bar'"))
+ return FAILED ("Should return 'foo'\\''bar'");
+
+ if (strcmp (g_shell_quote ("foo bar"), "'foo bar'"))
+ return FAILED ("Should return 'foo bar'");
+ return OK;
+}
+
+static Test shell_tests [] = {
+ {"test_shell_argv1", test_shell_argv1},
+ {"test_shell_argv2", test_shell_argv2},
+ {"test_shell_argv3", test_shell_argv3},
+ {"test_shell_argv4", test_shell_argv4},
+ {"test_shell_argv5", test_shell_argv5},
+ {"g_shell_quote", test_quote},
+ {NULL, NULL}
+};
+
+DEFINE_TEST_GROUP_INIT(shell_tests_init, shell_tests)
+
--- /dev/null
+/*
+ * Tests to ensure that our type definitions are correct
+ *
+ * These depend on -Werror, -Wall being set to catch the build error.
+ */
+#include <stdio.h>
+#ifndef _MSC_VER
+#include <stdint.h>
+#endif
+#include <string.h>
+#include <glib.h>
+#include "test.h"
+
+RESULT
+test_formats ()
+{
+ char buffer [1024];
+ gsize a = 1;
+
+ sprintf (buffer, "%" G_GSIZE_FORMAT, a);
+
+ return NULL;
+}
+
+RESULT
+test_ptrconv ()
+{
+ int iv, iv2;
+ unsigned int uv, uv2;
+ gpointer ptr;
+
+ iv = G_MAXINT32;
+ ptr = GINT_TO_POINTER (iv);
+ iv2 = GPOINTER_TO_INT (ptr);
+ if (iv != iv2)
+ return FAILED ("int to pointer and back conversions fail %d != %d", iv, iv2);
+
+ iv = G_MININT32;
+ ptr = GINT_TO_POINTER (iv);
+ iv2 = GPOINTER_TO_INT (ptr);
+ if (iv != iv2)
+ return FAILED ("int to pointer and back conversions fail %d != %d", iv, iv2);
+
+ iv = 1;
+ ptr = GINT_TO_POINTER (iv);
+ iv2 = GPOINTER_TO_INT (ptr);
+ if (iv != iv2)
+ return FAILED ("int to pointer and back conversions fail %d != %d", iv, iv2);
+
+ iv = -1;
+ ptr = GINT_TO_POINTER (iv);
+ iv2 = GPOINTER_TO_INT (ptr);
+ if (iv != iv2)
+ return FAILED ("int to pointer and back conversions fail %d != %d", iv, iv2);
+
+ iv = 0;
+ ptr = GINT_TO_POINTER (iv);
+ iv2 = GPOINTER_TO_INT (ptr);
+ if (iv != iv2)
+ return FAILED ("int to pointer and back conversions fail %d != %d", iv, iv2);
+
+ uv = 0;
+ ptr = GUINT_TO_POINTER (uv);
+ uv2 = GPOINTER_TO_UINT (ptr);
+ if (uv != uv2)
+ return FAILED ("uint to pointer and back conversions fail %u != %d", uv, uv2);
+
+ uv = 1;
+ ptr = GUINT_TO_POINTER (uv);
+ uv2 = GPOINTER_TO_UINT (ptr);
+ if (uv != uv2)
+ return FAILED ("uint to pointer and back conversions fail %u != %d", uv, uv2);
+
+ uv = UINT32_MAX;
+ ptr = GUINT_TO_POINTER (uv);
+ uv2 = GPOINTER_TO_UINT (ptr);
+ if (uv != uv2)
+ return FAILED ("uint to pointer and back conversions fail %u != %d", uv, uv2);
+
+ return NULL;
+
+}
+
+typedef struct {
+ int a;
+ int b;
+} my_struct;
+
+RESULT
+test_offset ()
+{
+ if (G_STRUCT_OFFSET (my_struct, a) != 0)
+ return FAILED ("offset of a is not zero");
+
+ if (G_STRUCT_OFFSET (my_struct, b) != 4 && G_STRUCT_OFFSET (my_struct, b) != 8)
+ return FAILED ("offset of b is 4 or 8, macro might be busted");
+
+ return OK;
+}
+
+static Test size_tests [] = {
+ {"formats", test_formats},
+ {"ptrconv", test_ptrconv},
+ {"g_struct_offset", test_offset},
+ {NULL, NULL}
+};
+
+DEFINE_TEST_GROUP_INIT(size_tests_init, size_tests)
--- /dev/null
+#include <stdio.h>
+#include <string.h>
+#include <glib.h>
+#include "test.h"
+
+
+RESULT
+test_slist_nth ()
+{
+ char *foo = "foo";
+ char *bar = "bar";
+ char *baz = "baz";
+ GSList *nth, *list;
+ list = g_slist_prepend (NULL, baz);
+ list = g_slist_prepend (list, bar);
+ list = g_slist_prepend (list, foo);
+
+ nth = g_slist_nth (list, 0);
+ if (nth->data != foo)
+ return FAILED ("nth failed. #0");
+
+ nth = g_slist_nth (list, 1);
+ if (nth->data != bar)
+ return FAILED ("nth failed. #1");
+
+ nth = g_slist_nth (list, 2);
+ if (nth->data != baz)
+ return FAILED ("nth failed. #2");
+
+ nth = g_slist_nth (list, 3);
+ if (nth)
+ return FAILED ("nth failed. #3: %s", nth->data);
+
+ g_slist_free (list);
+ return OK;
+}
+
+RESULT
+test_slist_index ()
+{
+ int i;
+ char *foo = "foo";
+ char *bar = "bar";
+ char *baz = "baz";
+ GSList *list;
+ list = g_slist_prepend (NULL, baz);
+ list = g_slist_prepend (list, bar);
+ list = g_slist_prepend (list, foo);
+
+ i = g_slist_index (list, foo);
+ if (i != 0)
+ return FAILED ("index failed. #0: %d", i);
+
+ i = g_slist_index (list, bar);
+ if (i != 1)
+ return FAILED ("index failed. #1: %d", i);
+
+ i = g_slist_index (list, baz);
+ if (i != 2)
+ return FAILED ("index failed. #2: %d", i);
+
+ g_slist_free (list);
+ return OK;
+}
+
+RESULT
+test_slist_append ()
+{
+ GSList *foo;
+ GSList *list = g_slist_append (NULL, "first");
+ if (g_slist_length (list) != 1)
+ return FAILED ("append(null,...) failed");
+
+ foo = g_slist_append (list, "second");
+ if (foo != list)
+ return FAILED ("changed list head on non-empty");
+
+ if (g_slist_length (list) != 2)
+ return FAILED ("Append failed");
+
+ g_slist_free (list);
+ return OK;
+}
+
+RESULT
+test_slist_concat ()
+{
+ GSList *foo = g_slist_prepend (NULL, "foo");
+ GSList *bar = g_slist_prepend (NULL, "bar");
+
+ GSList *list = g_slist_concat (foo, bar);
+
+ if (g_slist_length (list) != 2)
+ return FAILED ("Concat failed.");
+
+ g_slist_free (list);
+ return OK;
+}
+
+RESULT
+test_slist_find ()
+{
+ GSList *list = g_slist_prepend (NULL, "three");
+ GSList *found;
+ char *data;
+
+ list = g_slist_prepend (list, "two");
+ list = g_slist_prepend (list, "one");
+
+ data = "four";
+ list = g_slist_append (list, data);
+
+ found = g_slist_find (list, data);
+
+ if (found->data != data)
+ return FAILED ("Find failed");
+
+ g_slist_free (list);
+ return OK;
+}
+
+static gint
+find_custom (gconstpointer a, gconstpointer b)
+{
+ return(strcmp (a, b));
+}
+
+RESULT
+test_slist_find_custom ()
+{
+ GSList *list = NULL, *found;
+ char *foo = "foo";
+ char *bar = "bar";
+ char *baz = "baz";
+
+ list = g_slist_prepend (list, baz);
+ list = g_slist_prepend (list, bar);
+ list = g_slist_prepend (list, foo);
+
+ found = g_slist_find_custom (list, baz, find_custom);
+
+ if (found == NULL)
+ return FAILED ("Find failed");
+
+ g_slist_free (list);
+
+ return OK;
+}
+
+RESULT
+test_slist_remove ()
+{
+ GSList *list = g_slist_prepend (NULL, "three");
+ char *one = "one";
+ list = g_slist_prepend (list, "two");
+ list = g_slist_prepend (list, one);
+
+ list = g_slist_remove (list, one);
+
+ if (g_slist_length (list) != 2)
+ return FAILED ("Remove failed");
+
+ if (strcmp ("two", list->data) != 0)
+ return FAILED ("Remove failed");
+
+ g_slist_free (list);
+ return OK;
+}
+
+RESULT
+test_slist_remove_link ()
+{
+ GSList *foo = g_slist_prepend (NULL, "a");
+ GSList *bar = g_slist_prepend (NULL, "b");
+ GSList *baz = g_slist_prepend (NULL, "c");
+ GSList *list = foo;
+
+ foo = g_slist_concat (foo, bar);
+ foo = g_slist_concat (foo, baz);
+
+ list = g_slist_remove_link (list, bar);
+
+ if (g_slist_length (list) != 2)
+ return FAILED ("remove_link failed #1");
+
+ if (bar->next != NULL)
+ return FAILED ("remove_link failed #2");
+
+ g_slist_free (list);
+ g_slist_free (bar);
+
+ return OK;
+}
+
+static gint
+compare (gconstpointer a, gconstpointer b)
+{
+ char *foo = (char *) a;
+ char *bar = (char *) b;
+
+ if (strlen (foo) < strlen (bar))
+ return -1;
+
+ return 1;
+}
+
+RESULT
+test_slist_insert_sorted ()
+{
+ GSList *list = g_slist_prepend (NULL, "a");
+ list = g_slist_append (list, "aaa");
+
+ /* insert at the middle */
+ list = g_slist_insert_sorted (list, "aa", compare);
+ if (strcmp ("aa", list->next->data))
+ return FAILED("insert_sorted failed #1");
+
+ /* insert at the beginning */
+ list = g_slist_insert_sorted (list, "", compare);
+ if (strcmp ("", list->data))
+ return FAILED ("insert_sorted failed #2");
+
+ /* insert at the end */
+ list = g_slist_insert_sorted (list, "aaaa", compare);
+ if (strcmp ("aaaa", g_slist_last (list)->data))
+ return FAILED ("insert_sorted failed #3");
+
+ g_slist_free (list);
+ return OK;
+}
+
+RESULT
+test_slist_insert_before ()
+{
+ GSList *foo, *bar, *baz;
+
+ foo = g_slist_prepend (NULL, "foo");
+ foo = g_slist_insert_before (foo, NULL, "bar");
+ bar = g_slist_last (foo);
+
+ if (strcmp (bar->data, "bar"))
+ return FAILED ("1");
+
+ baz = g_slist_insert_before (foo, bar, "baz");
+ if (foo != baz)
+ return FAILED ("2");
+
+ if (strcmp (foo->next->data, "baz"))
+ return FAILED ("3: %s", foo->next->data);
+
+ g_slist_free (foo);
+ return OK;
+}
+
+#define N_ELEMS 100
+
+static int intcompare (gconstpointer p1, gconstpointer p2)
+{
+ return GPOINTER_TO_INT (p1) - GPOINTER_TO_INT (p2);
+}
+
+static gboolean verify_sort (GSList *list, int len)
+{
+ int prev = GPOINTER_TO_INT (list->data);
+ len--;
+ for (list = list->next; list; list = list->next) {
+ int curr = GPOINTER_TO_INT (list->data);
+ if (prev > curr)
+ return FALSE;
+ prev = curr;
+
+ if (len == 0)
+ return FALSE;
+ len--;
+ }
+ return len == 0;
+}
+
+RESULT
+test_slist_sort ()
+{
+ int i, j, mul;
+ GSList *list = NULL;
+
+ for (i = 0; i < N_ELEMS; ++i)
+ list = g_slist_prepend (list, GINT_TO_POINTER (i));
+ list = g_slist_sort (list, intcompare);
+ if (!verify_sort (list, N_ELEMS))
+ return FAILED ("decreasing list");
+
+ g_slist_free (list);
+
+ list = NULL;
+ for (i = 0; i < N_ELEMS; ++i)
+ list = g_slist_prepend (list, GINT_TO_POINTER (-i));
+ list = g_slist_sort (list, intcompare);
+ if (!verify_sort (list, N_ELEMS))
+ return FAILED ("increasing list");
+
+ g_slist_free (list);
+
+ list = g_slist_prepend (NULL, GINT_TO_POINTER (0));
+ for (i = 1; i < N_ELEMS; ++i) {
+ list = g_slist_prepend (list, GINT_TO_POINTER (-i));
+ list = g_slist_prepend (list, GINT_TO_POINTER (i));
+ }
+ list = g_slist_sort (list, intcompare);
+ if (!verify_sort (list, 2*N_ELEMS-1))
+ return FAILED ("alternating list");
+
+ g_slist_free (list);
+
+ list = NULL;
+ mul = 1;
+ for (i = 1; i < N_ELEMS; ++i) {
+ mul = -mul;
+ for (j = 0; j < i; ++j)
+ list = g_slist_prepend (list, GINT_TO_POINTER (mul * j));
+ }
+ list = g_slist_sort (list, intcompare);
+ if (!verify_sort (list, (N_ELEMS*N_ELEMS - N_ELEMS)/2))
+ return FAILED ("wavering list");
+
+ g_slist_free (list);
+
+ return OK;
+}
+
+static Test slist_tests [] = {
+ {"nth", test_slist_nth},
+ {"index", test_slist_index},
+ {"append", test_slist_append},
+ {"concat", test_slist_concat},
+ {"find", test_slist_find},
+ {"find_custom", test_slist_find_custom},
+ {"remove", test_slist_remove},
+ {"remove_link", test_slist_remove_link},
+ {"insert_sorted", test_slist_insert_sorted},
+ {"insert_before", test_slist_insert_before},
+ {"sort", test_slist_sort},
+ {NULL, NULL}
+};
+
+DEFINE_TEST_GROUP_INIT(slist_tests_init, slist_tests)
+
--- /dev/null
+#include <config.h>
+#include <glib.h>
+#include <string.h>
+#include <stdio.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#include "test.h"
+
+#ifdef G_OS_WIN32
+#include <io.h>
+#define read _read
+#define close _close
+#endif
+
+RESULT
+test_spawn_sync ()
+{
+ gchar *out;
+ gchar *err;
+ gint status = -1;
+ GError *error = NULL;
+
+ if (!g_spawn_command_line_sync ("ls", &out, &err, &status, &error))
+ return FAILED ("Error executing 'ls'");
+
+ if (status != 0)
+ return FAILED ("Status is %d", status);
+
+ if (out == NULL || strlen (out) == 0)
+ return FAILED ("Didn't get any output from ls!?");
+
+ g_free (out);
+ g_free (err);
+ return OK;
+}
+
+RESULT
+test_spawn_async ()
+{
+ /*
+gboolean
+g_spawn_async_with_pipes (const gchar *working_directory,
+ gchar **argv,
+ gchar **envp,
+ GSpawnFlags flags,
+ GSpawnChildSetupFunc child_setup,
+ gpointer user_data,
+ GPid *child_pid,
+ gint *standard_input,
+ gint *standard_output,
+ gint *standard_error,
+ GError **error) */
+ char *argv [15];
+ int stdout_fd = -1;
+ char buffer [512];
+ pid_t child_pid = 0;
+
+ memset (argv, 0, 15 * sizeof (char *));
+ argv [0] = "ls";
+ if (!g_spawn_async_with_pipes (NULL, argv, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, &child_pid, NULL, &stdout_fd, NULL, NULL))
+ return FAILED ("1 Failed to run ls");
+ if (child_pid == 0)
+ return FAILED ("2 child pid not returned");
+ if (stdout_fd == -1)
+ return FAILED ("3 out fd is -1");
+
+ while (read (stdout_fd, buffer, 512) > 0);
+ close (stdout_fd);
+
+ return OK;
+}
+
+static Test spawn_tests [] = {
+ {"g_shell_spawn_sync", test_spawn_sync},
+ {"g_shell_spawn_async_with_pipes", test_spawn_async},
+ {NULL, NULL}
+};
+
+DEFINE_TEST_GROUP_INIT(spawn_tests_init, spawn_tests)
+
+
--- /dev/null
+#include <glib.h>
+#include <string.h>
+#include <stdio.h>
+#include "test.h"
+
+/* This test is just to be used with valgrind */
+RESULT
+test_strfreev ()
+{
+ gchar **array = g_new (gchar *, 4);
+ array [0] = g_strdup ("one");
+ array [1] = g_strdup ("two");
+ array [2] = g_strdup ("three");
+ array [3] = NULL;
+
+ g_strfreev (array);
+ g_strfreev (NULL);
+
+ return OK;
+}
+
+RESULT
+test_concat ()
+{
+ gchar *x = g_strconcat ("Hello", ", ", "world", NULL);
+ if (strcmp (x, "Hello, world") != 0)
+ return FAILED("concat failed, got: %s", x);
+ g_free (x);
+ return OK;
+}
+
+RESULT
+test_split ()
+{
+ const gchar *to_split = "Hello world, how are we doing today?";
+ gint i;
+ gchar **v;
+
+ v= g_strsplit(to_split, " ", 0);
+
+ if(v == NULL) {
+ return FAILED("split failed, got NULL vector (1)");
+ }
+
+ for(i = 0; v[i] != NULL; i++);
+ if(i != 7) {
+ return FAILED("split failed, expected 7 tokens, got %d", i);
+ }
+
+ g_strfreev(v);
+
+ v = g_strsplit(to_split, ":", -1);
+ if(v == NULL) {
+ return FAILED("split failed, got NULL vector (2)");
+ }
+
+ for(i = 0; v[i] != NULL; i++);
+ if(i != 1) {
+ return FAILED("split failed, expected 1 token, got %d", i);
+ }
+
+ if(strcmp(v[0], to_split) != 0) {
+ return FAILED("expected vector[0] to be '%s' but it was '%s'",
+ to_split, v[0]);
+ }
+ g_strfreev(v);
+
+ v = g_strsplit ("", ":", 0);
+ if (v == NULL)
+ return FAILED ("g_strsplit returned NULL");
+ g_strfreev (v);
+
+ v = g_strsplit ("/home/miguel/dingus", "/", 0);
+ if (v [0][0] != 0)
+ return FAILED ("Got a non-empty first element");
+ g_strfreev (v);
+
+ v = g_strsplit ("appdomain1, Version=0.0.0.0, Culture=neutral", ",", 4);
+ if (strcmp (v [0], "appdomain1") != 0)
+ return FAILED ("Invalid value");
+
+ if (strcmp (v [1], " Version=0.0.0.0") != 0)
+ return FAILED ("Invalid value");
+
+ if (strcmp (v [2], " Culture=neutral") != 0)
+ return FAILED ("Invalid value");
+
+ if (v [3] != NULL)
+ return FAILED ("Expected only 3 elements");
+
+ g_strfreev (v);
+
+ v = g_strsplit ("abcXYdefXghiXYjklYmno", "XY", 4);
+ if (strcmp (v [0], "abc") != 0)
+ return FAILED ("Invalid value 0");
+
+ if (strcmp (v [1], "defXghi") != 0)
+ return FAILED ("Invalid value 1");
+
+ if (strcmp (v [2], "jklYmno") != 0)
+ return FAILED ("Invalid value 2");
+
+ if (v [3] != NULL)
+ return FAILED ("Expected only 3 elements (1)");
+
+ g_strfreev (v);
+
+ v = g_strsplit ("abcXYdefXghiXYjklYmno", "XY", 2);
+ if (strcmp (v [0], "abc") != 0)
+ return FAILED ("Invalid value 3");
+
+ if (strcmp (v [1], "defXghiXYjklYmno") != 0)
+ return FAILED ("Invalid value 4");
+
+ if (v [2] != NULL)
+ return FAILED ("Expected only 2 elements (2)");
+
+ g_strfreev (v);
+
+ v = g_strsplit ("abcXYdefXghiXYjklYmnoXY", "XY", 3);
+ if (strcmp (v [0], "abc") != 0)
+ return FAILED ("Invalid value 5");
+
+ if (strcmp (v [1], "defXghi") != 0)
+ return FAILED ("Invalid value 6");
+
+ if (strcmp (v [2], "jklYmnoXY") != 0)
+ return FAILED ("Invalid value 7");
+
+ if (v [3] != NULL)
+ return FAILED ("Expected only 3 elements (3)");
+
+ g_strfreev (v);
+
+ v = g_strsplit ("abcXYXYXYdefXY", "XY", -1);
+ if (strcmp (v [0], "abc") != 0)
+ return FAILED ("Invalid value 8");
+
+ if (strcmp (v [1], "") != 0)
+ return FAILED ("Invalid value 9");
+
+ if (strcmp (v [2], "") != 0)
+ return FAILED ("Invalid value 10");
+
+ if (strcmp (v [3], "def") != 0)
+ return FAILED ("Invalid value 11");
+
+ if (strcmp (v [4], "") != 0)
+ return FAILED ("Invalid value 12");
+
+ if (v [5] != NULL)
+ return FAILED ("Expected only 5 elements (4)");
+
+ g_strfreev (v);
+
+ v = g_strsplit ("XYXYXYabcXYdef", "XY", -1);
+ if (strcmp (v [0], "") != 0)
+ return FAILED ("Invalid value 13");
+
+ if (strcmp (v [1], "") != 0)
+ return FAILED ("Invalid value 14");
+
+ if (strcmp (v [2], "") != 0)
+ return FAILED ("Invalid value 15");
+
+ if (strcmp (v [3], "abc") != 0)
+ return FAILED ("Invalid value 16");
+
+ if (strcmp (v [4], "def") != 0)
+ return FAILED ("Invalid value 17");
+
+ if (v [5] != NULL)
+ return FAILED ("Expected only 5 elements (5)");
+
+ g_strfreev (v);
+
+ v = g_strsplit ("value=", "=", 2);
+ if (strcmp (v [0], "value") != 0)
+ return FAILED ("Invalid value 18; expected 'value', got '%s'", v [0]);
+ if (strcmp (v [1], "") != 0)
+ return FAILED ("Invalid value 19; expected '', got '%s'", v [1]);
+ if (v [2] != NULL)
+ return FAILED ("Expected only 2 elements (6)");
+
+ g_strfreev (v);
+
+ return OK;
+}
+
+RESULT
+test_split_set ()
+{
+ gchar **v;
+
+ v = g_strsplit_set ("abcXYdefXghiXYjklYmno", "XY", 6);
+ if (strcmp (v [0], "abc") != 0)
+ return FAILED ("Invalid value 0");
+
+ if (strcmp (v [1], "") != 0)
+ return FAILED ("Invalid value 1");
+
+ if (strcmp (v [2], "def") != 0)
+ return FAILED ("Invalid value 2");
+
+ if (strcmp (v [3], "ghi") != 0)
+ return FAILED ("Invalid value 3");
+
+ if (strcmp (v [4], "") != 0)
+ return FAILED ("Invalid value 4");
+
+ if (strcmp (v [5], "jklYmno") != 0)
+ return FAILED ("Invalid value 5");
+
+ if (v [6] != NULL)
+ return FAILED ("Expected only 6 elements (1)");
+
+ g_strfreev (v);
+
+ v = g_strsplit_set ("abcXYdefXghiXYjklYmno", "XY", 3);
+ if (strcmp (v [0], "abc") != 0)
+ return FAILED ("Invalid value 6");
+
+ if (strcmp (v [1], "") != 0)
+ return FAILED ("Invalid value 7");
+
+ if (strcmp (v [2], "defXghiXYjklYmno") != 0)
+ return FAILED ("Invalid value 8");
+
+ if (v [3] != NULL)
+ return FAILED ("Expected only 3 elements (2)");
+
+ g_strfreev (v);
+
+ v = g_strsplit_set ("abcXdefYghiXjklYmnoX", "XY", 5);
+ if (strcmp (v [0], "abc") != 0)
+ return FAILED ("Invalid value 9");
+
+ if (strcmp (v [1], "def") != 0)
+ return FAILED ("Invalid value 10");
+
+ if (strcmp (v [2], "ghi") != 0)
+ return FAILED ("Invalid value 11");
+
+ if (strcmp (v [3], "jkl") != 0)
+ return FAILED ("Invalid value 12");
+
+ if (strcmp (v [4], "mnoX") != 0)
+ return FAILED ("Invalid value 13");
+
+ if (v [5] != NULL)
+ return FAILED ("Expected only 5 elements (5)");
+
+ g_strfreev (v);
+
+ v = g_strsplit_set ("abcXYXdefXY", "XY", -1);
+ if (strcmp (v [0], "abc") != 0)
+ return FAILED ("Invalid value 14");
+
+ if (strcmp (v [1], "") != 0)
+ return FAILED ("Invalid value 15");
+
+ if (strcmp (v [2], "") != 0)
+ return FAILED ("Invalid value 16");
+
+ if (strcmp (v [3], "def") != 0)
+ return FAILED ("Invalid value 17");
+
+ if (strcmp (v [4], "") != 0)
+ return FAILED ("Invalid value 18");
+
+ if (strcmp (v [5], "") != 0)
+ return FAILED ("Invalid value 19");
+
+ if (v [6] != NULL)
+ return FAILED ("Expected only 6 elements (4)");
+
+ g_strfreev (v);
+
+ v = g_strsplit_set ("XYXabcXYdef", "XY", -1);
+ if (strcmp (v [0], "") != 0)
+ return FAILED ("Invalid value 20");
+
+ if (strcmp (v [1], "") != 0)
+ return FAILED ("Invalid value 21");
+
+ if (strcmp (v [2], "") != 0)
+ return FAILED ("Invalid value 22");
+
+ if (strcmp (v [3], "abc") != 0)
+ return FAILED ("Invalid value 23");
+
+ if (strcmp (v [4], "") != 0)
+ return FAILED ("Invalid value 24");
+
+ if (strcmp (v [5], "def") != 0)
+ return FAILED ("Invalid value 25");
+
+ if (v [6] != NULL)
+ return FAILED ("Expected only 6 elements (5)");
+
+ g_strfreev (v);
+
+ return OK;
+}
+
+RESULT
+test_strreverse ()
+{
+ RESULT res = OK;
+ gchar *a = g_strdup ("onetwothree");
+ gchar *a_target = "eerhtowteno";
+ gchar *b = g_strdup ("onetwothre");
+ gchar *b_target = "erhtowteno";
+ gchar *c = g_strdup ("");
+ gchar *c_target = "";
+
+ g_strreverse (a);
+ if (strcmp (a, a_target)) {
+ res = FAILED("strreverse failed. Expecting: '%s' and got '%s'\n", a, a_target);
+ goto cleanup;
+ }
+
+ g_strreverse (b);
+ if (strcmp (b, b_target)) {
+ res = FAILED("strreverse failed. Expecting: '%s' and got '%s'\n", b, b_target);
+ goto cleanup;
+ }
+
+ g_strreverse (c);
+ if (strcmp (c, c_target)) {
+ res = FAILED("strreverse failed. Expecting: '%s' and got '%s'\n", b, b_target);
+ goto cleanup;
+ }
+
+cleanup:
+ g_free (c);
+ g_free (b);
+ g_free (a);
+ return res;
+}
+
+RESULT
+test_strjoin ()
+{
+ char *s;
+
+ s = g_strjoin (NULL, "a", "b", NULL);
+ if (strcmp (s, "ab") != 0)
+ return FAILED ("Join of two strings with no separator fails");
+ g_free (s);
+
+ s = g_strjoin ("", "a", "b", NULL);
+ if (strcmp (s, "ab") != 0)
+ return FAILED ("Join of two strings with empty separator fails");
+ g_free (s);
+
+ s = g_strjoin ("-", "a", "b", NULL);
+ if (strcmp (s, "a-b") != 0)
+ return FAILED ("Join of two strings with separator fails");
+ g_free (s);
+
+ s = g_strjoin ("-", "aaaa", "bbbb", "cccc", "dddd", NULL);
+ if (strcmp (s, "aaaa-bbbb-cccc-dddd") != 0)
+ return FAILED ("Join of multiple strings fails");
+ g_free (s);
+
+ s = g_strjoin ("-", NULL);
+ if (s == NULL || (strcmp (s, "") != 0))
+ return FAILED ("Failed to join empty arguments");
+ g_free (s);
+
+ return OK;
+}
+
+RESULT
+test_strchug ()
+{
+ char *str = g_strdup (" \t\n hola");
+
+ g_strchug (str);
+ if (strcmp ("hola", str)) {
+ fprintf (stderr, "%s\n", str);
+ g_free (str);
+ return FAILED ("Failed.");
+ }
+ g_free (str);
+ return OK;
+}
+
+RESULT
+test_strchomp ()
+{
+ char *str = g_strdup ("hola \t");
+
+ g_strchomp (str);
+ if (strcmp ("hola", str)) {
+ fprintf (stderr, "%s\n", str);
+ g_free (str);
+ return FAILED ("Failed.");
+ }
+ g_free (str);
+ return OK;
+}
+
+RESULT
+test_strstrip ()
+{
+ char *str = g_strdup (" \t hola ");
+
+ g_strstrip (str);
+ if (strcmp ("hola", str)) {
+ fprintf (stderr, "%s\n", str);
+ g_free (str);
+ return FAILED ("Failed.");
+ }
+ g_free (str);
+ return OK;
+}
+
+#define urit(so,j) do { s = g_filename_to_uri (so, NULL, NULL); if (strcmp (s, j) != 0) return FAILED("Got %s expected %s", s, j); g_free (s); } while (0);
+
+#define errit(so) do { s = g_filename_to_uri (so, NULL, NULL); if (s != NULL) return FAILED ("got %s, expected NULL", s); } while (0);
+
+RESULT
+test_filename_to_uri ()
+{
+#ifdef G_OS_WIN32
+#else
+ char *s;
+
+ urit ("/a", "file:///a");
+ urit ("/home/miguel", "file:///home/miguel");
+ urit ("/home/mig uel", "file:///home/mig%20uel");
+ urit ("/\303\241", "file:///%C3%A1");
+ urit ("/\303\241/octal", "file:///%C3%A1/octal");
+ urit ("/%", "file:///%25");
+ urit ("/\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037\040", "file:///%01%02%03%04%05%06%07%08%09%0A%0B%0C%0D%0E%0F%10%11%12%13%14%15%16%17%18%19%1A%1B%1C%1D%1E%1F%20");
+ urit ("/!$&'()*+,-./", "file:///!$&'()*+,-./");
+ urit ("/\042\043\045", "file:///%22%23%25");
+ urit ("/0123456789:=", "file:///0123456789:=");
+ urit ("/\073\074\076\077", "file:///%3B%3C%3E%3F");
+ urit ("/\133\134\135\136_\140\173\174\175", "file:///%5B%5C%5D%5E_%60%7B%7C%7D");
+ urit ("/\173\174\175\176\177\200", "file:///%7B%7C%7D~%7F%80");
+ urit ("/@ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", "file:///@ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz");
+ errit ("a");
+ errit ("./hola");
+#endif
+
+ return OK;
+}
+
+#define fileit(so,j) do { s = g_filename_from_uri (so, NULL, NULL); if (strcmp (s, j) != 0) return FAILED("Got %s expected %s", s, j); g_free (s); } while (0);
+
+#define ferrit(so) do { s = g_filename_from_uri (so, NULL, NULL); if (s != NULL) return FAILED ("got %s, expected NULL", s); } while (0);
+
+RESULT
+test_filename_from_uri ()
+{
+#ifdef G_OS_WIN32
+#else
+ char *s;
+
+ fileit ("file:///a", "/a");
+ fileit ("file:///%41", "/A");
+ fileit ("file:///home/miguel", "/home/miguel");
+ fileit ("file:///home/mig%20uel", "/home/mig uel");
+ ferrit ("/a");
+ ferrit ("a");
+ ferrit ("file://a");
+ ferrit ("file:a");
+ ferrit ("file:///%");
+ ferrit ("file:///%0");
+ ferrit ("file:///%jj");
+#endif
+
+ return OK;
+}
+
+RESULT
+test_ascii_xdigit_value ()
+{
+ int i;
+ gchar j;
+
+ i = g_ascii_xdigit_value ('9' + 1);
+ if (i != -1)
+ return FAILED ("'9' + 1");
+ i = g_ascii_xdigit_value ('0' - 1);
+ if (i != -1)
+ return FAILED ("'0' - 1");
+ i = g_ascii_xdigit_value ('a' - 1);
+ if (i != -1)
+ return FAILED ("'a' - 1");
+ i = g_ascii_xdigit_value ('f' + 1);
+ if (i != -1)
+ return FAILED ("'f' + 1");
+ i = g_ascii_xdigit_value ('A' - 1);
+ if (i != -1)
+ return FAILED ("'A' - 1");
+ i = g_ascii_xdigit_value ('F' + 1);
+ if (i != -1)
+ return FAILED ("'F' + 1");
+
+ for (j = '0'; j < '9'; j++) {
+ int c = g_ascii_xdigit_value (j);
+ if (c != (j - '0'))
+ return FAILED ("Digits %c -> %d", j, c);
+ }
+ for (j = 'a'; j < 'f'; j++) {
+ int c = g_ascii_xdigit_value (j);
+ if (c != (j - 'a' + 10))
+ return FAILED ("Lower %c -> %d", j, c);
+ }
+ for (j = 'A'; j < 'F'; j++) {
+ int c = g_ascii_xdigit_value (j);
+ if (c != (j - 'A' + 10))
+ return FAILED ("Upper %c -> %d", j, c);
+ }
+ return OK;
+}
+
+RESULT
+test_strdelimit ()
+{
+ gchar *str;
+
+ str = g_strdup (G_STR_DELIMITERS);
+ str = g_strdelimit (str, NULL, 'a');
+ if (0 != strcmp ("aaaaaaa", str))
+ return FAILED ("All delimiters: '%s'", str);
+ g_free (str);
+ str = g_strdup ("hola");
+ str = g_strdelimit (str, "ha", '+');
+ if (0 != strcmp ("+ol+", str))
+ return FAILED ("2 delimiters: '%s'", str);
+ g_free (str);
+ return OK;
+}
+
+#define NUMBERS "0123456789"
+
+RESULT
+test_strlcpy ()
+{
+ const gchar *src = "onetwothree";
+ gchar *dest;
+ gsize i;
+
+ dest = g_malloc (strlen (src) + 1);
+ memset (dest, 0, strlen (src) + 1);
+ i = g_strlcpy (dest, src, (gsize)-1);
+ if (i != strlen (src))
+ return FAILED ("Test1 got %d", i);
+
+ if (0 != strcmp (dest, src))
+ return FAILED ("Src and dest not equal");
+
+ i = g_strlcpy (dest, src, 3);
+ if (i != strlen (src))
+ return FAILED ("Test1 got %d", i);
+ if (0 != strcmp (dest, "on"))
+ return FAILED ("Test2");
+
+ i = g_strlcpy (dest, src, 1);
+ if (i != strlen (src))
+ return FAILED ("Test3 got %d", i);
+ if (*dest != '\0')
+ return FAILED ("Test4");
+
+ i = g_strlcpy (dest, src, 12345);
+ if (i != strlen (src))
+ return FAILED ("Test4 got %d", i);
+ if (0 != strcmp (dest, src))
+ return FAILED ("Src and dest not equal 2");
+ g_free (dest);
+
+ /* This is a test for g_filename_from_utf8, even if it does not look like it */
+ dest = g_filename_from_utf8 (NUMBERS, strlen (NUMBERS), NULL, NULL, NULL);
+ if (0 != strcmp (dest, NUMBERS))
+ return FAILED ("problem [%s] and [%s]", dest, NUMBERS);
+ g_free (dest);
+
+ return OK;
+}
+
+RESULT
+test_strescape ()
+{
+ gchar *str;
+
+ str = g_strescape ("abc", NULL);
+ if (strcmp ("abc", str))
+ return FAILED ("#1");
+ str = g_strescape ("\t\b\f\n\r\\\"abc", NULL);
+ if (strcmp ("\\t\\b\\f\\n\\r\\\\\\\"abc", str))
+ return FAILED ("#2 %s", str);
+ str = g_strescape ("\001abc", NULL);
+ if (strcmp ("\\001abc", str))
+ return FAILED ("#3 %s", str);
+ str = g_strescape ("\001abc", "\001");
+ if (strcmp ("\001abc", str))
+ return FAILED ("#3 %s", str);
+ return OK;
+}
+
+RESULT
+test_ascii_strncasecmp ()
+{
+ int n;
+
+ n = g_ascii_strncasecmp ("123", "123", 1);
+ if (n != 0)
+ return FAILED ("Should have been 0");
+
+ n = g_ascii_strncasecmp ("423", "123", 1);
+ if (n != 3)
+ return FAILED ("Should have been 3, got %d", n);
+
+ n = g_ascii_strncasecmp ("123", "423", 1);
+ if (n != -3)
+ return FAILED ("Should have been -3, got %d", n);
+
+ n = g_ascii_strncasecmp ("1", "1", 10);
+ if (n != 0)
+ return FAILED ("Should have been 0, got %d", n);
+ return OK;
+}
+
+RESULT
+test_ascii_strdown ()
+{
+ const gchar *a = "~09+AaBcDeFzZ$0909EmPAbCdEEEEEZZZZAAA";
+ const gchar *b = "~09+aabcdefzz$0909empabcdeeeeezzzzaaa";
+ gchar *c;
+ gint n, l;
+
+ l = (gint)strlen (b);
+ c = g_ascii_strdown (a, l);
+ n = g_ascii_strncasecmp (b, c, l);
+
+ if (n != 0) {
+ g_free (c);
+ return FAILED ("Should have been 0, got %d", n);
+ }
+
+ g_free (c);
+ return OK;
+}
+
+RESULT
+test_strdupv ()
+{
+ gchar **one;
+ gchar **two;
+ gint len;
+
+ one = g_strdupv (NULL);
+ if (one)
+ return FAILED ("Should have been NULL");
+
+ one = g_malloc (sizeof (gchar *));
+ *one = NULL;
+ two = g_strdupv (one);
+ if (!two)
+ FAILED ("Should have been not NULL");
+ len = g_strv_length (two);
+ if (len)
+ FAILED ("Should have been 0");
+ g_strfreev (two);
+ g_strfreev (one);
+ return NULL;
+}
+
+static Test strutil_tests [] = {
+ {"g_strfreev", test_strfreev},
+ {"g_strconcat", test_concat},
+ {"g_strsplit", test_split},
+ {"g_strsplit_set", test_split_set},
+ {"g_strreverse", test_strreverse},
+ {"g_strjoin", test_strjoin},
+ {"g_strchug", test_strchug},
+ {"g_strchomp", test_strchomp},
+ {"g_strstrip", test_strstrip},
+ {"g_filename_to_uri", test_filename_to_uri},
+ {"g_filename_from_uri", test_filename_from_uri},
+ {"g_ascii_xdigit_value", test_ascii_xdigit_value},
+ {"g_strdelimit", test_strdelimit},
+ {"g_strlcpy", test_strlcpy},
+ {"g_strescape", test_strescape},
+ {"g_ascii_strncasecmp", test_ascii_strncasecmp },
+ {"g_ascii_strdown", test_ascii_strdown },
+ {"g_strdupv", test_strdupv },
+ {NULL, NULL}
+};
+
+DEFINE_TEST_GROUP_INIT(strutil_tests_init, strutil_tests)
+
+
--- /dev/null
+#include <glib.h>
+#include <string.h>
+#include <stdio.h>
+#include "test.h"
+
+#define sfail(k,p) if (s->str [p] != k) { g_string_free (s,TRUE); return FAILED("Got %s, Failed at %d, expected '%c'", s->str, p, k);}
+
+RESULT
+test_append_speed()
+{
+ GString *s = g_string_new("");
+ gint i;
+
+ for(i = 0; i < 1024; i++) {
+ g_string_append(s, "x");
+ }
+
+ if(strlen (s->str) != 1024) {
+ return FAILED("Incorrect string size, got: %s %d",
+ s->str, strlen(s->str));
+ }
+
+ g_string_free (s, TRUE);
+
+ return OK;
+}
+
+RESULT
+test_append_c_speed()
+{
+ GString *s = g_string_new("");
+ gint i;
+
+ for(i = 0; i < 1024; i++) {
+ g_string_append_c(s, 'x');
+ }
+
+ if(strlen(s->str) != 1024) {
+ return FAILED("Incorrect string size, got: %s %d", s->str,
+ strlen(s->str));
+ }
+
+ g_string_free(s, TRUE);
+
+ return OK;
+}
+
+RESULT
+test_gstring ()
+{
+ GString *s = g_string_new_len ("My stuff", 2);
+ char *ret;
+ int i;
+
+ if (strcmp (s->str, "My") != 0)
+ return "Expected only 'My' on the string";
+ g_string_free (s, TRUE);
+
+ s = g_string_new_len ("My\0\0Rest", 6);
+ if (s->str [2] != 0)
+ return "Null was not copied";
+ if (strcmp (s->str+4, "Re") != 0){
+ return "Did not find the 'Re' part";
+ }
+
+ g_string_append (s, "lalalalalalalalalalalalalalalalalalalalalalal");
+ if (s->str [2] != 0)
+ return "Null as not copied";
+ if (strncmp (s->str+4, "Relala", 6) != 0){
+ return FAILED("Did not copy correctly, got: %s", s->str+4);
+ }
+
+ g_string_free (s, TRUE);
+
+ s = g_string_new ("");
+ for (i = 0; i < 1024; i++){
+ g_string_append_c (s, 'x');
+ }
+ if (strlen (s->str) != 1024){
+ return FAILED("Incorrect string size, got: %s %d\n", s->str, strlen (s->str));
+ }
+ g_string_free (s, TRUE);
+
+ s = g_string_new ("hola");
+ g_string_sprintfa (s, "%s%d", ", bola", 5);
+ if (strcmp (s->str, "hola, bola5") != 0){
+ return FAILED("Incorrect data, got: %s\n", s->str);
+ }
+ g_string_free (s, TRUE);
+
+ s = g_string_new ("Hola");
+ g_string_printf (s, "Dingus");
+
+ /* Test that it does not release it */
+ ret = g_string_free (s, FALSE);
+ g_free (ret);
+
+ s = g_string_new_len ("H" "\000" "H", 3);
+ g_string_append_len (s, "1" "\000" "2", 3);
+ sfail ('H', 0);
+ sfail ( 0, 1);
+ sfail ('H', 2);
+ sfail ('1', 3);
+ sfail ( 0, 4);
+ sfail ('2', 5);
+ g_string_free (s, TRUE);
+
+ return OK;
+}
+
+RESULT
+test_sized ()
+{
+ GString *s = g_string_sized_new (20);
+
+ if (s->str [0] != 0)
+ return FAILED ("Expected an empty string");
+ if (s->len != 0)
+ return FAILED ("Expected an empty len");
+
+ g_string_free (s, TRUE);
+
+ return NULL;
+}
+
+RESULT
+test_truncate ()
+{
+ GString *s = g_string_new ("0123456789");
+ g_string_truncate (s, 3);
+
+ if (strlen (s->str) != 3)
+ return FAILED ("size of string should have been 3, instead it is [%s]\n", s->str);
+ g_string_free (s, TRUE);
+
+ s = g_string_new ("a");
+ s = g_string_truncate (s, 10);
+ if (strlen (s->str) != 1)
+ return FAILED ("The size is not 1");
+ g_string_truncate (s, (gsize)-1);
+ if (strlen (s->str) != 1)
+ return FAILED ("The size is not 1");
+ g_string_truncate (s, 0);
+ if (strlen (s->str) != 0)
+ return FAILED ("The size is not 0");
+
+ g_string_free (s, TRUE);
+
+ return NULL;
+}
+
+RESULT
+test_prepend ()
+{
+ GString *s = g_string_new ("dingus");
+ g_string_prepend (s, "one");
+
+ if (strcmp (s->str, "onedingus") != 0)
+ return FAILED ("Failed, expected onedingus, got [%s]", s->str);
+
+ g_string_free (s, TRUE);
+
+ /* This is to force the code that where stuff does not fit in the allocated block */
+ s = g_string_sized_new (1);
+ g_string_prepend (s, "one");
+ if (strcmp (s->str, "one") != 0)
+ return FAILED ("Got erroneous result, expected [one] got [%s]", s->str);
+ g_string_free (s, TRUE);
+
+ /* This is to force the path where things fit */
+ s = g_string_new ("123123123123123123123123");
+ g_string_truncate (s, 1);
+ if (strcmp (s->str, "1") != 0)
+ return FAILED ("Expected [1] string, got [%s]", s->str);
+
+ g_string_prepend (s, "pre");
+ if (strcmp (s->str, "pre1") != 0)
+ return FAILED ("Expected [pre1], got [%s]", s->str);
+ g_string_free (s, TRUE);
+
+ return NULL;
+}
+
+RESULT
+test_appendlen ()
+{
+ GString *s = g_string_new ("");
+
+ g_string_append_len (s, "boo\000x", 0);
+ if (s->len != 0)
+ return FAILED ("The length is not zero %d", s->len);
+ g_string_append_len (s, "boo\000x", 5);
+ if (s->len != 5)
+ return FAILED ("The length is not five %d", s->len);
+ g_string_append_len (s, "ha", -1);
+ if (s->len != 7)
+ return FAILED ("The length is not seven %d", s->len);
+
+ g_string_free (s, TRUE);
+
+ return NULL;
+}
+
+RESULT
+test_macros ()
+{
+ char *s = g_strdup (G_STRLOC);
+ char *p = strchr (s + 2, ':');
+ int n;
+
+ if (p == NULL)
+ return FAILED ("Did not find a separator");
+ n = atoi (p+1);
+ if (n <= 0)
+ return FAILED ("did not find a valid line number");
+
+ *p = 0;
+ if (strcmp (s + strlen(s) - 8 , "string.c") != 0)
+ return FAILED ("This did not store the filename on G_STRLOC");
+
+ g_free (s);
+ return NULL;
+}
+
+static Test string_tests [] = {
+ {"append-speed", test_append_speed},
+ {"append_c-speed", test_append_c_speed},
+ {"ctor+append", test_gstring },
+ {"ctor+sized", test_sized },
+ {"truncate", test_truncate },
+ {"prepend", test_prepend },
+ {"append_len", test_appendlen },
+ {"macros", test_macros },
+ {NULL, NULL}
+};
+
+DEFINE_TEST_GROUP_INIT(string_tests_init, string_tests)
--- /dev/null
+#!/bin/sh
+
+for arg in $@; do
+ if [ "x$arg" = "x--help" ]; then
+ echo "Usage: $0 [OPTION]... [ITERATIONS] [TESTGROUP]..."
+ echo ""
+ echo "Works the same as test-eglib or test-glib with the following"
+ echo "exception. Run test-eglib --help for details on normal testing"
+ echo ""
+ echo "If the first OPTION is --speed-compare, the following is"
+ echo "applicable to this program:"
+ echo ""
+ echo " --speed-compare run drivers in -qtni mode and report"
+ echo " speed comparison information"
+ echo ""
+ echo "After --speed-compare, the number of iterations "
+ echo "(optional, default is 100000) can be specified, followed "
+ echo "by specific tests to run (or none to run all)"
+ echo ""
+ echo "If --speed-compare is not the first argument, all arguments are"
+ echo "passed on directly to each driver"
+ echo ""
+ exit 1
+ fi
+done
+
+if [ ! -x "./test-glib" -o ! -x "./test-eglib" ]; then
+ make
+fi
+
+if [ "x$1" = "x--speed-compare" ]; then
+ ITERATIONS=100000
+ if [ ! -z "$2" ]; then
+ case $2 in
+ *[0-9]*) ITERATIONS=$2; break;
+ esac
+ fi
+
+ OPTIONS="-qnti $ITERATIONS"
+
+ for arg in $@; do
+ if [ "x$arg" = "x--speed-compare" ]; then
+ continue;
+ elif [ "$arg" = "$ITERATIONS" ]; then
+ continue;
+ fi
+
+ OPTIONS="$OPTIONS $arg"
+ done
+
+ echo "Running tests with $OPTIONS..."
+
+ GLIB=`./test-glib $OPTIONS`
+ EGLIB=`./test-eglib $OPTIONS`
+
+ # this blows
+ FASTER_NAME=`echo "$GLIB GLib $EGLIB EGlib" | awk '{ if($1 < $3) print $2; else print $4 }'`
+ FASTER_SPEED=`echo "$GLIB $EGLIB" | awk '{ if($1 < $2) print $1; else print $2 }'`
+ SLOWER_NAME=`echo "$GLIB GLib $EGLIB EGlib" | awk '{ if($1 > $3) print $2; else print $4 }'`
+ SLOWER_SPEED=`echo "$GLIB $EGLIB" | awk '{ if($1 > $2) print $1; else print $2 }'`
+
+ FASTER_PERCENTAGE=`echo "$SLOWER_SPEED $FASTER_SPEED" | awk '{ print ($1 / $2) * 100 }'`
+
+ echo "$FASTER_NAME $FASTER_SPEED"
+ echo "$SLOWER_NAME $SLOWER_SPEED"
+ echo "------------------------------------------------"
+ echo "$FASTER_NAME is $FASTER_PERCENTAGE% faster than $SLOWER_NAME"
+
+ exit 0;
+fi
+
+./test-eglib $@
+./test-glib $@
+
--- /dev/null
+/*
+ * EGLib Unit Group/Test Runners
+ *
+ * Author:
+ * Aaron Bockover (abockover@novell.com)
+ *
+ * (C) 2006 Novell, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
+
+#include <config.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdarg.h>
+#include <glib.h>
+#ifdef HAVE_SYS_TIME_H
+#include <sys/time.h>
+#endif
+#ifdef G_OS_WIN32
+#include <winsock2.h>
+#endif
+
+#include "test.h"
+
+extern gint global_passed, global_tests;
+static gchar *last_result = NULL;
+
+gboolean
+run_test(Test *test, gchar **result_out)
+{
+ gchar *result;
+
+ if((result = test->handler()) == NULL) {
+ *result_out = NULL;
+ return TRUE;
+ } else {
+ *result_out = result;
+ return FALSE;
+ }
+}
+
+gboolean
+run_group(Group *group, gint iterations, gboolean quiet,
+ gboolean time, gchar *tests_to_run_s)
+{
+ Test *tests = group->handler();
+ gint i, j, passed = 0, total = 0;
+ gdouble start_time_group, start_time_test;
+ gchar **tests_to_run = NULL;
+
+ if(!quiet) {
+ if(iterations > 1) {
+ printf("[%s] (%dx)\n", group->name, iterations);
+ } else {
+ printf("[%s]\n", group->name);
+ }
+ }
+
+ if(tests_to_run_s != NULL) {
+ tests_to_run = eg_strsplit(tests_to_run_s, ",", -1);
+ }
+
+ start_time_group = get_timestamp();
+
+ for(i = 0; tests[i].name != NULL; i++) {
+ gchar *result = "";
+ gboolean iter_pass, run;
+
+ iter_pass = FALSE;
+ if(tests_to_run != NULL) {
+ gint j;
+ run = FALSE;
+ for(j = 0; tests_to_run[j] != NULL; j++) {
+ if(strcmp(tests_to_run[j], tests[i].name) == 0) {
+ run = TRUE;
+ break;
+ }
+ }
+ } else {
+ run = TRUE;
+ }
+
+ if(!run) {
+ continue;
+ }
+
+ total++;
+
+ if(!quiet) {
+ printf(" %s: ", tests[i].name);
+ }
+
+ start_time_test = get_timestamp();
+
+ for(j = 0; j < iterations; j++) {
+ iter_pass = run_test(&(tests[i]), &result);
+ if(!iter_pass) {
+ break;
+ }
+ }
+
+ if(iter_pass) {
+ passed++;
+ if(!quiet) {
+ if(time) {
+ printf("OK (%g)\n", get_timestamp() - start_time_test);
+ } else {
+ printf("OK\n");
+ }
+ }
+ } else {
+ if(!quiet) {
+ printf("FAILED (%s)\n", result);
+ }
+
+ if(last_result == result) {
+ last_result = NULL;
+ g_free(result);
+ }
+ }
+ }
+
+ global_passed += passed;
+ global_tests += total;
+
+ if(!quiet) {
+ gdouble pass_percentage = ((gdouble)passed / (gdouble)total) * 100.0;
+ if(time) {
+ printf(" %d / %d (%g%%, %g)\n", passed, total,
+ pass_percentage, get_timestamp() - start_time_group);
+ } else {
+ printf(" %d / %d (%g%%)\n", passed, total, pass_percentage);
+ }
+ }
+
+ if(tests_to_run != NULL) {
+ eg_strfreev(tests_to_run);
+ }
+
+ return passed == total;
+}
+
+RESULT
+FAILED(const gchar *format, ...)
+{
+ gchar *ret;
+ va_list args;
+ gint n;
+
+#if !defined(HAVE_VASPRINTF) && !defined(_EGLIB_MAJOR)
+ /* We are linked against the real glib, no vasprintf */
+ g_assert_not_reached ();
+ return NULL;
+#else
+ va_start(args, format);
+ n = g_vasprintf(&ret, format, args);
+ va_end(args);
+
+ if(n == -1) {
+ last_result = NULL;
+ return NULL;
+ }
+
+ last_result = ret;
+ return ret;
+#endif
+}
+
+gdouble
+get_timestamp()
+{
+ /* FIXME: We should use g_get_current_time here */
+ GTimeVal res;
+ g_get_current_time (&res);
+ return res.tv_sec + (1.e-6) * res.tv_usec;
+}
+
+/*
+ * Duplicating code here from EGlib to avoid g_strsplit skew between
+ * EGLib and GLib
+ */
+
+gchar **
+eg_strsplit (const gchar *string, const gchar *delimiter, gint max_tokens)
+{
+ gchar *string_c;
+ gchar *strtok_save, **vector;
+ gchar *token, *token_c;
+ gint size = 1;
+ size_t token_length;
+
+ g_return_val_if_fail(string != NULL, NULL);
+ g_return_val_if_fail(delimiter != NULL, NULL);
+ g_return_val_if_fail(delimiter[0] != 0, NULL);
+
+ token_length = strlen(string);
+ string_c = (gchar *)g_malloc(token_length + 1);
+ memcpy(string_c, string, token_length);
+ string_c[token_length] = 0;
+
+ vector = NULL;
+ token = (gchar *)strtok_r(string_c, delimiter, &strtok_save);
+
+ while(token != NULL) {
+ token_length = strlen(token);
+ token_c = (gchar *)g_malloc(token_length + 1);
+ memcpy(token_c, token, token_length);
+ token_c[token_length] = 0;
+
+ vector = vector == NULL ?
+ (gchar **)g_malloc(2 * sizeof(vector)) :
+ (gchar **)g_realloc(vector, (size + 1) * sizeof(vector));
+
+ vector[size - 1] = token_c;
+ size++;
+
+ if(max_tokens > 0 && size >= max_tokens) {
+ if(size > max_tokens) {
+ break;
+ }
+
+ token = strtok_save;
+ } else {
+ token = (gchar *)strtok_r(NULL, delimiter, &strtok_save);
+ }
+ }
+
+ if(vector != NULL && size > 0) {
+ vector[size - 1] = NULL;
+ }
+
+ g_free(string_c);
+ string_c = NULL;
+
+ return vector;
+}
+
+void
+eg_strfreev (gchar **str_array)
+{
+ gchar **orig = str_array;
+ if (str_array == NULL)
+ return;
+ while (*str_array != NULL){
+ g_free (*str_array);
+ str_array++;
+ }
+ g_free (orig);
+}
+
+
+
--- /dev/null
+/*
+ * EGLib Unit Group/Test Runners
+ *
+ * Author:
+ * Aaron Bockover (abockover@novell.com)
+ *
+ * (C) 2006 Novell, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef _TEST_H
+#define _TEST_H
+
+#include <config.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <string.h>
+#include <glib.h>
+
+#ifdef _MSC_VER
+/* disable the following warnings
+ * C4100: The formal parameter is not referenced in the body of the function. The unreferenced parameter is ignored.
+ * C4127: conditional expression is constant (test macros produce a lot of these)
+*/
+#pragma warning(disable:4100 4127)
+#endif
+
+typedef gchar * RESULT;
+
+typedef struct _Test Test;
+typedef struct _Group Group;
+
+typedef gchar * (* RunTestHandler)();
+typedef Test * (* LoadGroupHandler)();
+
+struct _Test {
+ const gchar *name;
+ RunTestHandler handler;
+};
+
+struct _Group {
+ const gchar *name;
+ LoadGroupHandler handler;
+};
+
+gboolean run_group(Group *group, gint iterations, gboolean quiet,
+ gboolean time, gchar *tests);
+#undef FAILED
+RESULT FAILED(const gchar *format, ...);
+gdouble get_timestamp();
+gchar ** eg_strsplit (const gchar *string, const gchar *delimiter, gint max_tokens);
+void eg_strfreev (gchar **str_array);
+
+#define OK NULL
+
+#define DEFINE_TEST_GROUP_INIT(name, table) \
+ Test * (name)() { return table; }
+
+#define DEFINE_TEST_GROUP_INIT_H(name) \
+ Test * (name)();
+
+#endif /* _TEST_H */
+
+
--- /dev/null
+#include "test.h"
+
+DEFINE_TEST_GROUP_INIT_H(string_tests_init);
+DEFINE_TEST_GROUP_INIT_H(strutil_tests_init);
+DEFINE_TEST_GROUP_INIT_H(slist_tests_init);
+DEFINE_TEST_GROUP_INIT_H(list_tests_init);
+DEFINE_TEST_GROUP_INIT_H(hashtable_tests_init);
+DEFINE_TEST_GROUP_INIT_H(ptrarray_tests_init);
+DEFINE_TEST_GROUP_INIT_H(size_tests_init);
+DEFINE_TEST_GROUP_INIT_H(fake_tests_init);
+DEFINE_TEST_GROUP_INIT_H(array_tests_init);
+DEFINE_TEST_GROUP_INIT_H(queue_tests_init);
+DEFINE_TEST_GROUP_INIT_H(path_tests_init);
+DEFINE_TEST_GROUP_INIT_H(shell_tests_init);
+DEFINE_TEST_GROUP_INIT_H(spawn_tests_init);
+DEFINE_TEST_GROUP_INIT_H(timer_tests_init);
+DEFINE_TEST_GROUP_INIT_H(file_tests_init);
+DEFINE_TEST_GROUP_INIT_H(pattern_tests_init);
+DEFINE_TEST_GROUP_INIT_H(dir_tests_init);
+DEFINE_TEST_GROUP_INIT_H(markup_tests_init);
+DEFINE_TEST_GROUP_INIT_H(unicode_tests_init);
+DEFINE_TEST_GROUP_INIT_H(utf8_tests_init);
+DEFINE_TEST_GROUP_INIT_H(endian_tests_init);
+DEFINE_TEST_GROUP_INIT_H(module_tests_init);
+DEFINE_TEST_GROUP_INIT_H(memory_tests_init);
+
+static Group test_groups [] = {
+ {"string", string_tests_init},
+ {"strutil", strutil_tests_init},
+ {"ptrarray", ptrarray_tests_init},
+ {"slist", slist_tests_init},
+ {"list", list_tests_init},
+ {"hashtable", hashtable_tests_init},
+ {"sizes", size_tests_init},
+ {"fake", fake_tests_init},
+ {"array", array_tests_init},
+ {"queue", queue_tests_init},
+ {"path", path_tests_init},
+ {"shell", shell_tests_init},
+ {"markup", markup_tests_init},
+#if !DISABLE_PROCESS_TESTS
+ {"spawn", spawn_tests_init},
+ {"module", module_tests_init},
+#endif
+#if !DISABLE_FILESYSTEM_TESTS
+ {"file", file_tests_init},
+#endif
+ {"timer", timer_tests_init},
+ {"pattern", pattern_tests_init},
+ {"dir", dir_tests_init},
+ {"unicode", unicode_tests_init},
+ {"utf8", utf8_tests_init},
+ {"endian", endian_tests_init},
+ {"memory", memory_tests_init},
+ {NULL, NULL}
+};
+
--- /dev/null
+#include <config.h>
+#include <glib.h>
+#include <string.h>
+#include <math.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#include <stdlib.h>
+#include <stdio.h>
+
+#ifdef G_OS_WIN32
+#include <windows.h>
+#define sleep(t) Sleep((t) * 1000)
+#endif
+
+#include "test.h"
+
+RESULT
+test_timer ()
+{
+ GTimer *timer;
+ gdouble elapsed1, elapsed2;
+ gulong usec = 0;
+
+ timer = g_timer_new ();
+ sleep (1);
+ elapsed1 = g_timer_elapsed (timer, NULL);
+ if ((elapsed1 + 0.1) < 1.0)
+ return FAILED ("Elapsed time should be around 1s and was %f", elapsed1);
+
+ g_timer_stop (timer);
+ elapsed1 = g_timer_elapsed (timer, NULL);
+ elapsed2 = g_timer_elapsed (timer, &usec);
+ if (fabs (elapsed1 - elapsed2) > 0.000001)
+ return FAILED ("The elapsed times are not equal %f - %f.", elapsed1, elapsed2);
+
+ elapsed2 *= 1000000;
+ while (elapsed2 > 1000000)
+ elapsed2 -= 1000000;
+
+ if (fabs (usec - elapsed2) > 100.0)
+ return FAILED ("usecs are wrong.");
+
+ g_timer_destroy (timer);
+ return OK;
+}
+
+static Test timer_tests [] = {
+ {"g_timer", test_timer},
+ {NULL, NULL}
+};
+
+DEFINE_TEST_GROUP_INIT(timer_tests_init, timer_tests)
+
+
--- /dev/null
+#include "test.h"
+
+/*
+ * g_unichar_type
+ */
+RESULT
+test_g_unichar_type ()
+{
+ if (g_unichar_type ('A') != G_UNICODE_UPPERCASE_LETTER)
+ return FAILED ("#1");
+ if (g_unichar_type ('a') != G_UNICODE_LOWERCASE_LETTER)
+ return FAILED ("#2");
+ if (g_unichar_type ('1') != G_UNICODE_DECIMAL_NUMBER)
+ return FAILED ("#3");
+ if (g_unichar_type (0xA3) != G_UNICODE_CURRENCY_SYMBOL)
+ return FAILED ("#4");
+ return NULL;
+}
+
+/*
+ * g_unichar_toupper
+ */
+RESULT
+test_g_unichar_toupper ()
+{
+ if (g_unichar_toupper (0) != 0)
+ return FAILED ("#0");
+ if (g_unichar_toupper ('a') != 'A')
+ return FAILED ("#1");
+ if (g_unichar_toupper ('1') != '1')
+ return FAILED ("#2");
+ if (g_unichar_toupper (0x1C4) != 0x1C4)
+ return FAILED ("#3");
+ if (g_unichar_toupper (0x1F2) != 0x1F1)
+ return FAILED ("#4");
+ if (g_unichar_toupper (0x1F3) != 0x1F1)
+ return FAILED ("#5");
+ if (g_unichar_toupper (0xFFFF) != 0xFFFF)
+ return FAILED ("#6");
+ if (g_unichar_toupper (0x10428) != 0x10400)
+ return FAILED ("#7");
+ return NULL;
+}
+
+/*
+ * g_unichar_tolower
+ */
+RESULT
+test_g_unichar_tolower ()
+{
+ if (g_unichar_tolower (0) != 0)
+ return FAILED ("#0");
+ if (g_unichar_tolower ('A') != 'a')
+ return FAILED ("#1");
+ if (g_unichar_tolower ('1') != '1')
+ return FAILED ("#2");
+ if (g_unichar_tolower (0x1C5) != 0x1C6)
+ return FAILED ("#3");
+ if (g_unichar_tolower (0x1F1) != 0x1F3)
+ return FAILED ("#4");
+ if (g_unichar_tolower (0x1F2) != 0x1F3)
+ return FAILED ("#5");
+ if (g_unichar_tolower (0xFFFF) != 0xFFFF)
+ return FAILED ("#6");
+ return NULL;
+}
+
+/*
+ * g_unichar_totitle
+ */
+RESULT
+test_g_unichar_totitle ()
+{
+ if (g_unichar_toupper (0) != 0)
+ return FAILED ("#0");
+ if (g_unichar_totitle ('a') != 'A')
+ return FAILED ("#1");
+ if (g_unichar_totitle ('1') != '1')
+ return FAILED ("#2");
+ if (g_unichar_totitle (0x1C4) != 0x1C5)
+ return FAILED ("#3");
+ if (g_unichar_totitle (0x1F2) != 0x1F2)
+ return FAILED ("#4");
+ if (g_unichar_totitle (0x1F3) != 0x1F2)
+ return FAILED ("#5");
+ if (g_unichar_toupper (0xFFFF) != 0xFFFF)
+ return FAILED ("#6");
+ return NULL;
+}
+
+static Test unicode_tests [] = {
+ {"g_unichar_type", test_g_unichar_type},
+ {"g_unichar_toupper", test_g_unichar_toupper},
+ {"g_unichar_tolower", test_g_unichar_tolower},
+ {"g_unichar_totitle", test_g_unichar_totitle},
+ {NULL, NULL}
+};
+
+DEFINE_TEST_GROUP_INIT(unicode_tests_init, unicode_tests)
--- /dev/null
+#include <stdlib.h>
+
+#include "test.h"
+
+/*
+ * g_utf16_to_utf8
+ */
+
+glong
+compare_strings_utf8_pos (const gchar *expected, const gchar *actual, glong size)
+{
+ int i;
+ for (i = 0; i < size; i++)
+ if (expected [i] != actual [i])
+ return i;
+ return -1;
+}
+
+RESULT
+compare_strings_utf8_RESULT (const gchar *expected, const gchar *actual, glong size)
+{
+ glong ret;
+
+ ret = compare_strings_utf8_pos (expected, actual, size);
+ if (ret < 0)
+ return OK;
+ return FAILED ("Incorrect output: expected '%s' but was '%s', differ at %d\n", expected, actual, ret);
+}
+
+void
+gchar_to_gunichar2 (gunichar2 ret[], const gchar *src)
+{
+ int i;
+
+ for (i = 0; src [i]; i++)
+ ret [i] = src [i];
+ ret [i] = 0;
+}
+
+RESULT
+compare_utf16_to_utf8_explicit (const gchar *expected, const gunichar2 *utf16, glong len_in, glong len_out, glong size_spec)
+{
+ GError *error;
+ gchar* ret;
+ RESULT result;
+ glong in_read, out_read;
+
+ result = NULL;
+
+ error = NULL;
+ ret = g_utf16_to_utf8 (utf16, size_spec, &in_read, &out_read, &error);
+ if (error) {
+ result = FAILED ("The error is %d %s\n", (error)->code, (error)->message);
+ g_error_free (error);
+ if (ret)
+ g_free (ret);
+ return result;
+ }
+ if (in_read != len_in)
+ result = FAILED ("Read size is incorrect: expected %d but was %d\n", len_in, in_read);
+ else if (out_read != len_out)
+ result = FAILED ("Converted size is incorrect: expected %d but was %d\n", len_out, out_read);
+ else
+ result = compare_strings_utf8_RESULT (expected, ret, len_out);
+
+ g_free (ret);
+ if (result)
+ return result;
+
+ return OK;
+}
+
+RESULT
+compare_utf16_to_utf8 (const gchar *expected, const gunichar2 *utf16, glong len_in, glong len_out)
+{
+ RESULT result;
+
+ result = compare_utf16_to_utf8_explicit (expected, utf16, len_in, len_out, -1);
+ if (result != OK)
+ return result;
+ return compare_utf16_to_utf8_explicit (expected, utf16, len_in, len_out, len_in);
+}
+
+RESULT
+test_utf16_to_utf8 ()
+{
+ const gchar *src0 = "", *src1 = "ABCDE", *src2 = "\xE5\xB9\xB4\x27", *src3 = "\xEF\xBC\xA1", *src4 = "\xEF\xBD\x81", *src5 = "\xF0\x90\x90\x80";
+ gunichar2 str0 [] = {0}, str1 [6], str2 [] = {0x5E74, 39, 0}, str3 [] = {0xFF21, 0}, str4 [] = {0xFF41, 0}, str5 [] = {0xD801, 0xDC00, 0};
+ RESULT result;
+
+ gchar_to_gunichar2 (str1, src1);
+
+ /* empty string */
+ result = compare_utf16_to_utf8 (src0, str0, 0, 0);
+ if (result != OK)
+ return result;
+
+ result = compare_utf16_to_utf8 (src1, str1, 5, 5);
+ if (result != OK)
+ return result;
+ result = compare_utf16_to_utf8 (src2, str2, 2, 4);
+ if (result != OK)
+ return result;
+ result = compare_utf16_to_utf8 (src3, str3, 1, 3);
+ if (result != OK)
+ return result;
+ result = compare_utf16_to_utf8 (src4, str4, 1, 3);
+ if (result != OK)
+ return result;
+ result = compare_utf16_to_utf8 (src5, str5, 2, 4);
+ if (result != OK)
+ return result;
+
+ return OK;
+}
+
+/*
+ * g_utf8_to_utf16
+ */
+
+glong
+compare_strings_utf16_pos (const gunichar2 *expected, const gunichar2 *actual, glong size)
+{
+ int i;
+ for (i = 0; i < size; i++)
+ if (expected [i] != actual [i])
+ return i;
+ return -1;
+}
+
+RESULT
+compare_strings_utf16_RESULT (const gunichar2 *expected, const gunichar2 *actual, glong size)
+{
+ glong ret;
+
+ ret = compare_strings_utf16_pos (expected, actual, size);
+ if (ret < 0)
+ return OK;
+ return FAILED ("Incorrect output: expected '%s' but was '%s', differ at %d ('%c' x '%c')\n", expected, actual, ret, expected [ret], actual [ret]);
+}
+
+#if !defined(EGLIB_TESTS)
+#define eg_utf8_to_utf16_with_nuls g_utf8_to_utf16
+#endif
+
+RESULT
+compare_utf8_to_utf16_explicit (const gunichar2 *expected, const gchar *utf8, glong len_in, glong len_out, glong size_spec, gboolean include_nuls)
+{
+ GError *error;
+ gunichar2* ret;
+ RESULT result;
+ glong in_read, out_read;
+
+ result = NULL;
+
+ error = NULL;
+ if (include_nuls)
+ ret = eg_utf8_to_utf16_with_nuls (utf8, size_spec, &in_read, &out_read, &error);
+ else
+ ret = g_utf8_to_utf16 (utf8, size_spec, &in_read, &out_read, &error);
+
+ if (error) {
+ result = FAILED ("The error is %d %s\n", (error)->code, (error)->message);
+ g_error_free (error);
+ if (ret)
+ g_free (ret);
+ return result;
+ }
+ if (in_read != len_in)
+ result = FAILED ("Read size is incorrect: expected %d but was %d\n", len_in, in_read);
+ else if (out_read != len_out)
+ result = FAILED ("Converted size is incorrect: expected %d but was %d\n", len_out, out_read);
+ else
+ result = compare_strings_utf16_RESULT (expected, ret, len_out);
+
+ g_free (ret);
+ if (result)
+ return result;
+
+ return OK;
+}
+
+RESULT
+compare_utf8_to_utf16_general (const gunichar2 *expected, const gchar *utf8, glong len_in, glong len_out, gboolean include_nuls)
+{
+ RESULT result;
+
+ result = compare_utf8_to_utf16_explicit (expected, utf8, len_in, len_out, -1, include_nuls);
+ if (result != OK)
+ return result;
+ return compare_utf8_to_utf16_explicit (expected, utf8, len_in, len_out, len_in, include_nuls);
+}
+
+RESULT
+compare_utf8_to_utf16 (const gunichar2 *expected, const gchar *utf8, glong len_in, glong len_out)
+{
+ return compare_utf8_to_utf16_general (expected, utf8, len_in, len_out, FALSE);
+}
+
+RESULT
+compare_utf8_to_utf16_with_nuls (const gunichar2 *expected, const gchar *utf8, glong len_in, glong len_out)
+{
+ return compare_utf8_to_utf16_explicit (expected, utf8, len_in, len_out, len_in, TRUE);
+}
+
+
+RESULT
+test_utf8_seq ()
+{
+ const gchar *src = "\xE5\xB9\xB4\x27";
+ glong in_read, out_read;
+ //gunichar2 expected [6];
+ GError *error = NULL;
+ gunichar2 *dst;
+
+ //printf ("got: %s\n", src);
+ dst = g_utf8_to_utf16 (src, (glong)strlen (src), &in_read, &out_read, &error);
+ if (error != NULL){
+ return error->message;
+ }
+
+ if (in_read != 4) {
+ return FAILED ("in_read is expected to be 4 but was %d\n", in_read);
+ }
+ if (out_read != 2) {
+ return FAILED ("out_read is expected to be 2 but was %d\n", out_read);
+ }
+ g_free (dst);
+
+ return OK;
+}
+
+RESULT
+test_utf8_to_utf16 ()
+{
+ const gchar *src0 = "", *src1 = "ABCDE", *src2 = "\xE5\xB9\xB4\x27", *src3 = "\xEF\xBC\xA1", *src4 = "\xEF\xBD\x81";
+ gunichar2 str0 [] = {0}, str1 [6], str2 [] = {0x5E74, 39, 0}, str3 [] = {0xFF21, 0}, str4 [] = {0xFF41, 0};
+ RESULT result;
+
+ gchar_to_gunichar2 (str1, src1);
+
+ /* empty string */
+ result = compare_utf8_to_utf16 (str0, src0, 0, 0);
+ if (result != OK)
+ return result;
+
+ result = compare_utf8_to_utf16 (str1, src1, 5, 5);
+ if (result != OK)
+ return result;
+ result = compare_utf8_to_utf16 (str2, src2, 4, 2);
+ if (result != OK)
+ return result;
+ result = compare_utf8_to_utf16 (str3, src3, 3, 1);
+ if (result != OK)
+ return result;
+ result = compare_utf8_to_utf16 (str4, src4, 3, 1);
+ if (result != OK)
+ return result;
+
+ return OK;
+}
+
+RESULT
+test_utf8_to_utf16_with_nuls ()
+{
+ const gchar *src0 = "", *src1 = "AB\0DE", *src2 = "\xE5\xB9\xB4\x27", *src3 = "\xEF\xBC\xA1", *src4 = "\xEF\xBD\x81";
+ gunichar2 str0 [] = {0}, str1 [] = {'A', 'B', 0, 'D', 'E', 0}, str2 [] = {0x5E74, 39, 0}, str3 [] = {0xFF21, 0}, str4 [] = {0xFF41, 0};
+ RESULT result;
+
+#if !defined(EGLIB_TESTS)
+ return OK;
+#endif
+
+ /* implicit length is forbidden */
+ if (eg_utf8_to_utf16_with_nuls (src1, -1, NULL, NULL, NULL) != NULL)
+ return FAILED ("explicit nulls must fail with -1 length\n");
+
+ /* empty string */
+ result = compare_utf8_to_utf16_with_nuls (str0, src0, 0, 0);
+ if (result != OK)
+ return result;
+
+ result = compare_utf8_to_utf16_with_nuls (str1, src1, 5, 5);
+ if (result != OK)
+ return result;
+ result = compare_utf8_to_utf16_with_nuls (str2, src2, 4, 2);
+ if (result != OK)
+ return result;
+ result = compare_utf8_to_utf16_with_nuls (str3, src3, 3, 1);
+ if (result != OK)
+ return result;
+ result = compare_utf8_to_utf16_with_nuls (str4, src4, 3, 1);
+ if (result != OK)
+ return result;
+
+ return OK;
+}
+
+typedef struct {
+ char *content;
+ size_t length;
+} convert_result_t;
+
+RESULT
+test_convert ()
+{
+ static const char *charsets[] = { "UTF-8", "UTF-16LE", "UTF-16BE", "UTF-32LE", "UTF-32BE" };
+ gsize length, converted_length, n;
+ char *content, *converted, *path;
+ convert_result_t **expected;
+ GError *err = NULL;
+ const char *srcdir;
+ gboolean loaded;
+ guint i, j, k;
+ char c;
+
+ if (!(srcdir = getenv ("srcdir")) && !(srcdir = getenv ("PWD")))
+ return FAILED ("srcdir not defined!");
+
+ expected = g_malloc (sizeof (convert_result_t *) * G_N_ELEMENTS (charsets));
+
+ /* first load all our test samples... */
+ for (i = 0; i < G_N_ELEMENTS (charsets); i++) {
+ path = g_strdup_printf ("%s%c%s.txt", srcdir, G_DIR_SEPARATOR, charsets[i]);
+ loaded = g_file_get_contents (path, &content, &length, &err);
+ g_free (path);
+
+ if (!loaded) {
+ for (j = 0; j < i; j++) {
+ g_free (expected[j]->content);
+ g_free (expected[j]);
+ }
+
+ g_free (expected);
+
+ return FAILED ("Failed to load content for %s: %s", charsets[i], err->message);
+ }
+
+ expected[i] = g_malloc (sizeof (convert_result_t));
+ expected[i]->content = content;
+ expected[i]->length = length;
+ }
+
+ /* test conversion from every charset to every other charset */
+ for (i = 0; i < G_N_ELEMENTS (charsets); i++) {
+ for (j = 0; j < G_N_ELEMENTS (charsets); j++) {
+ converted = g_convert (expected[i]->content, expected[i]->length, charsets[j],
+ charsets[i], NULL, &converted_length, NULL);
+
+ if (converted == NULL) {
+ for (k = 0; k < G_N_ELEMENTS (charsets); k++) {
+ g_free (expected[k]->content);
+ g_free (expected[k]);
+ }
+
+ g_free (expected);
+
+ return FAILED ("Failed to convert from %s to %s: NULL", charsets[i], charsets[j]);
+ }
+
+ if (converted_length != expected[j]->length) {
+ length = expected[j]->length;
+
+ for (k = 0; k < G_N_ELEMENTS (charsets); k++) {
+ g_free (expected[k]->content);
+ g_free (expected[k]);
+ }
+
+ g_free (converted);
+ g_free (expected);
+
+ return FAILED ("Failed to convert from %s to %s: expected %u bytes, got %u",
+ charsets[i], charsets[j], length, converted_length);
+ }
+
+ for (n = 0; n < converted_length; n++) {
+ if (converted[n] != expected[j]->content[n]) {
+ c = expected[j]->content[n];
+
+ for (k = 0; k < G_N_ELEMENTS (charsets); k++) {
+ g_free (expected[k]->content);
+ g_free (expected[k]);
+ }
+
+ g_free (converted);
+ g_free (expected);
+
+ return FAILED ("Failed to convert from %s to %s: expected 0x%x at offset %u, got 0x%x",
+ charsets[i], charsets[j], c, n, converted[n]);
+ }
+ }
+
+ g_free (converted);
+ }
+ }
+
+ for (k = 0; k < G_N_ELEMENTS (charsets); k++) {
+ g_free (expected[k]->content);
+ g_free (expected[k]);
+ }
+
+ g_free (expected);
+
+ return OK;
+}
+
+
+RESULT
+test_xdigit ()
+{
+ static char test_chars[] = {
+ '0', '1', '2', '3', '4',
+ '5', '6', '7', '8', '9',
+ 'a', 'b', 'c', 'd', 'e', 'f', 'g',
+ 'A', 'B', 'C', 'D', 'E', 'F', 'G'};
+ static gint32 test_values[] = {
+ 0, 1, 2, 3, 4,
+ 5, 6, 7, 8, 9,
+ 10, 11, 12, 13, 14, 15, -1,
+ 10, 11, 12, 13, 14, 15, -1};
+
+ int i =0;
+
+ for (i = 0; i < sizeof(test_chars); i++)
+ if (g_unichar_xdigit_value ((gunichar)test_chars[i]) != test_values[i])
+ return FAILED("Incorrect value %d at index %d", test_values[i], i);
+
+ return OK;
+}
+
+static RESULT
+ucs4_to_utf16_check_result (const gunichar2 *result_str, const gunichar2 *expected_str,
+ glong result_items_read, glong expected_items_read,
+ glong result_items_written, glong expected_items_written,
+ GError* result_error, gboolean expect_error)
+{
+ glong i;
+ if (result_items_read != expected_items_read)
+ return FAILED("Incorrect number of items read; expected %d, got %d", expected_items_read, result_items_read);
+ if (result_items_written != expected_items_written)
+ return FAILED("Incorrect number of items written; expected %d, got %d", expected_items_written, result_items_written);
+ if (result_error && !expect_error)
+ return FAILED("There should not be an error code.");
+ if (!result_error && expect_error)
+ return FAILED("Unexpected error object.");
+ if (expect_error && result_str)
+ return FAILED("NULL should be returned when an error occurs.");
+ if (!expect_error && !result_str)
+ return FAILED("When no error occurs NULL should not be returned.");
+ for (i=0; i<expected_items_written;i++) {
+ if (result_str [i] != expected_str [i])
+ return FAILED("Incorrect value %d at index %d", result_str [i], i);
+ }
+ if (result_str && result_str[expected_items_written] != '\0')
+ return FAILED("Null termination not found at the end of the string.");
+
+ return OK;
+}
+
+RESULT
+test_ucs4_to_utf16 ()
+{
+ static gunichar str1[12] = {'H','e','l','l','o',' ','W','o','r','l','d','\0'};
+ static gunichar2 exp1[12] = {'H','e','l','l','o',' ','W','o','r','l','d','\0'};
+ static gunichar str2[3] = {'h',0x80000000,'\0'};
+ static gunichar2 exp2[2] = {'h','\0'};
+ static gunichar str3[3] = {'h',0xDA00,'\0'};
+ static gunichar str4[3] = {'h',0x10FFFF,'\0'};
+ static gunichar2 exp4[4] = {'h',0xdbff,0xdfff,'\0'};
+ static gunichar str5[7] = {0xD7FF,0xD800,0xDFFF,0xE000,0x110000,0x10FFFF,'\0'};
+ static gunichar2 exp5[5] = {0xD7FF,0xE000,0xdbff,0xdfff,'\0'};
+ static gunichar str6[2] = {0x10400, '\0'};
+ static gunichar2 exp6[3] = {0xD801, 0xDC00, '\0'};
+ static glong read_write[12] = {1,1,0,0,0,0,1,1,0,0,1,2};
+ gunichar2* res;
+ glong items_read, items_written, current_write_index;
+ GError* err=0;
+ RESULT check_result;
+ glong i;
+
+ res = g_ucs4_to_utf16 (str1, 12, &items_read, &items_written, &err);
+ check_result = ucs4_to_utf16_check_result (res, exp1, items_read, 11, items_written, 11, err, FALSE);
+ if (check_result) return check_result;
+ g_free (res);
+
+ items_read = items_written = 0;
+ res = g_ucs4_to_utf16 (str2, 0, &items_read, &items_written, &err);
+ check_result = ucs4_to_utf16_check_result (res, exp2, items_read, 0, items_written, 0, err, FALSE);
+ if (check_result) return check_result;
+ g_free (res);
+
+ items_read = items_written = 0;
+ res = g_ucs4_to_utf16 (str2, 1, &items_read, &items_written, &err);
+ check_result = ucs4_to_utf16_check_result (res, exp2, items_read, 1, items_written, 1, err, FALSE);
+ if (check_result) return check_result;
+ g_free (res);
+
+ items_read = items_written = 0;
+ res = g_ucs4_to_utf16 (str2, 2, &items_read, &items_written, &err);
+ check_result = ucs4_to_utf16_check_result (res, 0, items_read, 1, items_written, 0, err, TRUE);
+ g_free (res);
+ if (check_result) return check_result;
+
+ items_read = items_written = 0;
+ err = 0;
+ res = g_ucs4_to_utf16 (str3, 2, &items_read, &items_written, &err);
+ check_result = ucs4_to_utf16_check_result (res, 0, items_read, 1, items_written, 0, err, TRUE);
+ if (check_result) return check_result;
+ g_free (res);
+
+ items_read = items_written = 0;
+ err = 0;
+ res = g_ucs4_to_utf16 (str4, 5, &items_read, &items_written, &err);
+ check_result = ucs4_to_utf16_check_result (res, exp4, items_read, 2, items_written, 3, err, FALSE);
+ if (check_result) return check_result;
+ g_free (res);
+
+ // This loop tests the bounds of the conversion algorithm
+ current_write_index = 0;
+ for (i=0;i<6;i++) {
+ items_read = items_written = 0;
+ err = 0;
+ res = g_ucs4_to_utf16 (&str5[i], 1, &items_read, &items_written, &err);
+ check_result = ucs4_to_utf16_check_result (res, &exp5[current_write_index],
+ items_read, read_write[i*2], items_written, read_write[(i*2)+1], err, !read_write[(i*2)+1]);
+ if (check_result) return check_result;
+ g_free (res);
+ current_write_index += items_written;
+ }
+
+ items_read = items_written = 0;
+ err = 0;
+ res = g_ucs4_to_utf16 (str6, 1, &items_read, &items_written, &err);
+ check_result = ucs4_to_utf16_check_result (res, exp6, items_read, 1, items_written, 2, err, FALSE);
+ if (check_result) return check_result;
+ g_free (res);
+
+ return OK;
+}
+
+static RESULT
+utf16_to_ucs4_check_result (const gunichar *result_str, const gunichar *expected_str,
+ glong result_items_read, glong expected_items_read,
+ glong result_items_written, glong expected_items_written,
+ GError* result_error, gboolean expect_error)
+{
+ glong i;
+ if (result_items_read != expected_items_read)
+ return FAILED("Incorrect number of items read; expected %d, got %d", expected_items_read, result_items_read);
+ if (result_items_written != expected_items_written)
+ return FAILED("Incorrect number of items written; expected %d, got %d", expected_items_written, result_items_written);
+ if (result_error && !expect_error)
+ return FAILED("There should not be an error code.");
+ if (!result_error && expect_error)
+ return FAILED("Unexpected error object.");
+ if (expect_error && result_str)
+ return FAILED("NULL should be returned when an error occurs.");
+ if (!expect_error && !result_str)
+ return FAILED("When no error occurs NULL should not be returned.");
+ for (i=0; i<expected_items_written;i++) {
+ if (result_str [i] != expected_str [i])
+ return FAILED("Incorrect value %d at index %d", result_str [i], i);
+ }
+ if (result_str && result_str[expected_items_written] != '\0')
+ return FAILED("Null termination not found at the end of the string.");
+
+ return OK;
+}
+
+RESULT
+test_utf16_to_ucs4 ()
+{
+ static gunichar2 str1[12] = {'H','e','l','l','o',' ','W','o','r','l','d','\0'};
+ static gunichar exp1[12] = {'H','e','l','l','o',' ','W','o','r','l','d','\0'};
+ static gunichar2 str2[7] = {'H', 0xD800, 0xDC01,0xD800,0xDBFF,'l','\0'};
+ static gunichar exp2[3] = {'H',0x00010001,'\0'};
+ static gunichar2 str3[4] = {'H', 0xDC00 ,'l','\0'};
+ static gunichar exp3[2] = {'H','\0'};
+ static gunichar2 str4[20] = {0xDC00,0xDFFF,0xDFF,0xD800,0xDBFF,0xD800,0xDC00,0xD800,0xDFFF,
+ 0xD800,0xE000,0xDBFF,0xDBFF,0xDBFF,0xDC00,0xDBFF,0xDFFF,0xDBFF,0xE000,'\0'};
+ static gunichar exp4[6] = {0xDFF,0x10000,0x103ff,0x10fc00,0x10FFFF,'\0'};
+ static gunichar2 str5[3] = {0xD801, 0xDC00, 0};
+ static gunichar exp5[2] = {0x10400, 0};
+ static glong read_write[33] = {1,0,0,1,0,0,1,1,1,2,1,0,2,2,1,2,2,1,2,1,0,2,1,0,2,2,1,2,2,1,2,1,0};
+ gunichar* res;
+ glong items_read, items_written, current_read_index,current_write_index;
+ GError* err=0;
+ RESULT check_result;
+ glong i;
+
+ res = g_utf16_to_ucs4 (str1, 12, &items_read, &items_written, &err);
+ check_result = utf16_to_ucs4_check_result (res, exp1, items_read, 11, items_written, 11, err, FALSE);
+ if (check_result) return check_result;
+ g_free (res);
+
+ items_read = items_written = 0;
+ res = g_utf16_to_ucs4 (str2, 0, &items_read, &items_written, &err);
+ check_result = utf16_to_ucs4_check_result (res, exp2, items_read, 0, items_written, 0, err, FALSE);
+ if (check_result) return check_result;
+ g_free (res);
+
+ items_read = items_written = 0;
+ res = g_utf16_to_ucs4 (str2, 1, &items_read, &items_written, &err);
+ check_result = utf16_to_ucs4_check_result (res, exp2, items_read, 1, items_written, 1, err, FALSE);
+ if (check_result) return check_result;
+ g_free (res);
+
+ items_read = items_written = 0;
+ res = g_utf16_to_ucs4 (str2, 2, &items_read, &items_written, &err);
+ check_result = utf16_to_ucs4_check_result (res, exp2, items_read, 1, items_written, 1, err, FALSE);
+ if (check_result) return check_result;
+ g_free (res);
+
+ items_read = items_written = 0;
+ res = g_utf16_to_ucs4 (str2, 3, &items_read, &items_written, &err);
+ check_result = utf16_to_ucs4_check_result (res, exp2, items_read, 3, items_written, 2, err, FALSE);
+ if (check_result) return check_result;
+ g_free (res);
+
+ items_read = items_written = 0;
+ res = g_utf16_to_ucs4 (str2, 4, &items_read, &items_written, &err);
+ check_result = utf16_to_ucs4_check_result (res, exp2, items_read, 3, items_written, 2, err, FALSE);
+ if (check_result) return check_result;
+ g_free (res);
+
+ items_read = items_written = 0;
+ res = g_utf16_to_ucs4 (str2, 5, &items_read, &items_written, &err);
+ check_result = utf16_to_ucs4_check_result (res, exp2, items_read, 4, items_written, 0, err, TRUE);
+ if (check_result) return check_result;
+ g_free (res);
+
+ items_read = items_written = 0;
+ err = 0;
+ res = g_utf16_to_ucs4 (str3, 5, &items_read, &items_written, &err);
+ check_result = utf16_to_ucs4_check_result (res, exp3, items_read, 1, items_written, 0, err, TRUE);
+ if (check_result) return check_result;
+ g_free (res);
+
+ // This loop tests the bounds of the conversion algorithm
+ current_read_index = current_write_index = 0;
+ for (i=0;i<11;i++) {
+ items_read = items_written = 0;
+ err = 0;
+ res = g_utf16_to_ucs4 (&str4[current_read_index], read_write[i*3], &items_read, &items_written, &err);
+ check_result = utf16_to_ucs4_check_result (res, &exp4[current_write_index], items_read,
+ read_write[(i*3)+1], items_written, read_write[(i*3)+2], err,
+ !read_write[(i*3)+2]);
+ if (check_result) return check_result;
+ g_free (res);
+ current_read_index += read_write[i*3];
+ current_write_index += items_written;
+ }
+
+ items_read = items_written = 0;
+ err = 0;
+ res = g_utf16_to_ucs4 (str5, 2, &items_read, &items_written, &err);
+ check_result = utf16_to_ucs4_check_result (res, exp5, items_read, 2, items_written, 1, err, FALSE);
+ if (check_result) return check_result;
+ g_free (res);
+
+ return OK;
+}
+RESULT
+test_utf8_strlen ()
+{
+ gchar word1 [] = {0xC2, 0x82,0x45,0xE1, 0x81, 0x83,0x58,0xF1, 0x82, 0x82, 0x82,'\0'};//Valid, len = 5
+ gchar word2 [] = {0xF1, 0x82, 0x82, 0x82,0xC2, 0x82,0x45,0xE1, 0x81, 0x83,0x58,'\0'};//Valid, len = 5
+ gchar word3 [] = {'h','e',0xC2, 0x82,0x45,'\0'}; //Valid, len = 4
+ gchar word4 [] = {0x62,0xC2, 0x82,0x45,0xE1, 0x81, 0x83,0x58,'\0'}; //Valid, len = 5
+
+ glong len = 0;
+
+ //Test word1
+ len = g_utf8_strlen (word1,-1);
+ if (len != 5)
+ return FAILED ("Word1 expected length of 5, but was %i", len);
+ //Do tests with different values for max parameter.
+ len = g_utf8_strlen (word1,1);
+ if (len != 0)
+ return FAILED ("Word1, max = 1, expected length of 0, but was %i", len);
+ len = g_utf8_strlen (word1,2);
+ if (len != 1)
+ return FAILED ("Word1, max = 1, expected length of 1, but was %i", len);
+ len = g_utf8_strlen (word1,3);
+ if (len != 2)
+ return FAILED ("Word1, max = 2, expected length of 2, but was %i", len);
+
+ //Test word2
+ len = g_utf8_strlen (word2,-1);
+ if (len != 5)
+ return FAILED ("Word2 expected length of 5, but was %i", len);
+
+ //Test word3
+ len = g_utf8_strlen (word3,-1);
+ if (len != 4)
+ return FAILED ("Word3 expected length of 4, but was %i", len);
+
+ //Test word4
+ len = g_utf8_strlen (word4,-1);
+ if (len != 5)
+ return FAILED ("Word4 expected length of 5, but was %i", len);
+
+ //Test null case
+ len = g_utf8_strlen(NULL,0);
+ if (len != 0)
+ return FAILED ("Expected passing null to result in a length of 0");
+ return OK;
+}
+
+RESULT
+test_utf8_get_char()
+{
+ gchar word1 [] = {0xC2, 0x82,0x45,0xE1, 0x81, 0x83,0x58,0xF1, 0x82, 0x82, 0x82,'\0'}; //Valid, len = 5
+
+ gunichar value = g_utf8_get_char (&word1 [0]);
+ if (value != 0x82UL)
+ return FAILED ("Expected value of 0x82, but was %x", value);
+ value = g_utf8_get_char (&word1 [2]);
+ if (value != 0x45UL)
+ return FAILED ("Expected value of 0x45, but was %x", value);
+ value = g_utf8_get_char (&word1 [3]);
+ if (value != 0x1043UL)
+ return FAILED ("Expected value of 0x1043, but was %x", value);
+ value = g_utf8_get_char (&word1 [6]);
+ if (value != 0x58UL)
+ return FAILED ("Expected value of 0x58, but was %x", value);
+ value = g_utf8_get_char (&word1 [7]);
+ if (value != 0x42082UL)
+ return FAILED ("Expected value of 0x42082, but was %x", value);
+
+ return OK;
+}
+
+RESULT
+test_utf8_next_char()
+{
+ gchar word1 [] = {0xC2, 0x82,0x45,0xE1, 0x81, 0x83,0x58,0xF1, 0x82, 0x82, 0x82,'\0'}; //Valid, len = 5
+ gchar word2 [] = {0xF1, 0x82, 0x82, 0x82,0xC2, 0x82,0x45,0xE1, 0x81, 0x83,0x58,'\0'}; //Valid, len = 5
+ gchar word1ExpectedValues [] = {0xC2, 0x45,0xE1, 0x58, 0xF1};
+ gchar word2ExpectedValues [] = {0xF1, 0xC2, 0x45, 0xE1, 0x58};
+
+ gchar* ptr = word1;
+ gint count = 0;
+ //Test word1
+ while (*ptr != 0) {
+ if (count > 4)
+ return FAILED ("Word1 has gone past its expected length");
+ if (*ptr != word1ExpectedValues[count])
+ return FAILED ("Word1 has an incorrect next_char at index %i", count);
+ ptr = g_utf8_next_char (ptr);
+ count++;
+ }
+
+ //Test word2
+ count = 0;
+ ptr = word2;
+ while (*ptr != 0) {
+ if (count > 4)
+ return FAILED ("Word2 has gone past its expected length");
+ if (*ptr != word2ExpectedValues[count])
+ return FAILED ("Word2 has an incorrect next_char at index %i", count);
+ ptr = g_utf8_next_char (ptr);
+ count++;
+ }
+
+ return OK;
+}
+
+RESULT
+test_utf8_validate()
+{
+ gchar invalidWord1 [] = {0xC3, 0x82, 0xC1,0x90,'\0'}; //Invalid, 1nd oct Can't be 0xC0 or 0xC1
+ gchar invalidWord2 [] = {0xC1, 0x89, 0x60, '\0'}; //Invalid, 1st oct can not be 0xC1
+ gchar invalidWord3 [] = {0xC2, 0x45,0xE1, 0x81, 0x83,0x58,'\0'}; //Invalid, oct after 0xC2 must be > 0x80
+
+ gchar validWord1 [] = {0xC2, 0x82, 0xC3,0xA0,'\0'}; //Valid
+ gchar validWord2 [] = {0xC2, 0x82,0x45,0xE1, 0x81, 0x83,0x58,0xF1, 0x82, 0x82, 0x82,'\0'}; //Valid
+
+ const gchar* end;
+ gboolean retVal = g_utf8_validate (invalidWord1, -1, &end);
+ if (retVal != FALSE)
+ return FAILED ("Expected invalidWord1 to be invalid");
+ if (end != &invalidWord1 [2])
+ return FAILED ("Expected end parameter to be pointing to invalidWord1[2]");
+
+ end = NULL;
+ retVal = g_utf8_validate (invalidWord2, -1, &end);
+ if (retVal != FALSE)
+ return FAILED ("Expected invalidWord2 to be invalid");
+ if (end != &invalidWord2 [0])
+ return FAILED ("Expected end parameter to be pointing to invalidWord2[0]");
+
+ end = NULL;
+ retVal = g_utf8_validate (invalidWord3, -1, &end);
+ if (retVal != FALSE)
+ return FAILED ("Expected invalidWord3 to be invalid");
+ if (end != &invalidWord3 [0])
+ return FAILED ("Expected end parameter to be pointing to invalidWord3[1]");
+
+ end = NULL;
+ retVal = g_utf8_validate (validWord1, -1, &end);
+ if (retVal != TRUE)
+ return FAILED ("Expected validWord1 to be valid");
+ if (end != &validWord1 [4])
+ return FAILED ("Expected end parameter to be pointing to validWord1[4]");
+
+ end = NULL;
+ retVal = g_utf8_validate (validWord2, -1, &end);
+ if (retVal != TRUE)
+ return FAILED ("Expected validWord2 to be valid");
+ if (end != &validWord2 [11])
+ return FAILED ("Expected end parameter to be pointing to validWord2[11]");
+ return OK;
+}
+
+glong
+utf8_byteslen (const gchar *src)
+{
+ int i = 0;
+ do {
+ if (src [i] == '\0')
+ return i;
+ i++;
+ } while (TRUE);
+}
+
+RESULT
+test_utf8_strcase_each (const gchar *src, const gchar *expected, gboolean strup)
+{
+ gchar *tmp;
+ glong len, len2;
+ RESULT r;
+
+ len = utf8_byteslen (src);
+ tmp = strup ? g_utf8_strup (src, len) : g_utf8_strdown (src, len);
+ len2 = utf8_byteslen (tmp);
+ r = compare_strings_utf8_RESULT (expected, tmp, len < len2 ? len2 : len);
+ g_free (tmp);
+ return r;
+}
+
+RESULT
+test_utf8_strup_each (const gchar *src, const gchar *expected)
+{
+ return test_utf8_strcase_each (src, expected, TRUE);
+}
+
+RESULT
+test_utf8_strdown_each (const gchar *src, const gchar *expected)
+{
+ return test_utf8_strcase_each (src, expected, FALSE);
+}
+
+/*
+ * g_utf8_strup
+ */
+RESULT
+test_utf8_strup ()
+{
+ RESULT r;
+
+ if ((r = test_utf8_strup_each ("aBc", "ABC")) != OK)
+ return r;
+ if ((r = test_utf8_strup_each ("x86-64", "X86-64")) != OK)
+ return r;
+ // U+3B1 U+392 -> U+391 U+392
+ if ((r = test_utf8_strup_each ("\xCE\xB1\xCE\x92", "\xCE\x91\xCE\x92")) != OK)
+ return r;
+ // U+FF21 -> U+FF21
+ if ((r = test_utf8_strup_each ("\xEF\xBC\xA1", "\xEF\xBC\xA1")) != OK)
+ return r;
+ // U+FF41 -> U+FF21
+ if ((r = test_utf8_strup_each ("\xEF\xBD\x81", "\xEF\xBC\xA1")) != OK)
+ return r;
+ // U+10428 -> U+10400
+ if ((r = test_utf8_strup_each ("\xF0\x90\x90\xA8", "\xF0\x90\x90\x80")) != OK)
+ return r;
+
+ return OK;
+}
+
+/*
+ * g_utf8_strdown
+ */
+RESULT
+test_utf8_strdown ()
+{
+ RESULT r;
+
+ if ((r = test_utf8_strdown_each ("aBc", "abc")) != OK)
+ return r;
+ if ((r = test_utf8_strdown_each ("X86-64", "x86-64")) != OK)
+ return r;
+ // U+391 U+3B2 -> U+3B1 U+3B2
+ if ((r = test_utf8_strdown_each ("\xCE\x91\xCE\xB2", "\xCE\xB1\xCE\xB2")) != OK)
+ return r;
+/*
+ // U+FF41 -> U+FF41
+ if ((r = test_utf8_strdown_each ("\xEF\xBC\x81", "\xEF\xBC\x81")) != OK)
+ return r;
+ // U+FF21 -> U+FF41
+ if ((r = test_utf8_strdown_each ("\xEF\xBC\xA1", "\xEF\xBD\x81")) != OK)
+ return r;
+ // U+10400 -> U+10428
+ if ((r = test_utf8_strdown_each ("\xF0\x90\x90\x80", "\xF0\x90\x90\xA8")) != OK)
+ return r;
+*/
+ return OK;
+}
+
+/*
+ * test initialization
+ */
+
+static Test utf8_tests [] = {
+ {"g_utf16_to_utf8", test_utf16_to_utf8},
+ {"g_utf8_to_utf16", test_utf8_to_utf16},
+ {"g_utf8_to_utf16_with_nuls", test_utf8_to_utf16_with_nuls},
+ {"g_utf8_seq", test_utf8_seq},
+ {"g_convert", test_convert },
+ {"g_unichar_xdigit_value", test_xdigit },
+ {"g_ucs4_to_utf16", test_ucs4_to_utf16 },
+ {"g_utf16_to_ucs4", test_utf16_to_ucs4 },
+ {"g_utf8_strlen", test_utf8_strlen },
+ {"g_utf8_get_char", test_utf8_get_char },
+ {"g_utf8_next_char", test_utf8_next_char },
+ {"g_utf8_validate", test_utf8_validate },
+ {"g_utf8_strup", test_utf8_strup},
+ {"g_utf8_strdown", test_utf8_strdown},
+ {NULL, NULL}
+};
+
+DEFINE_TEST_GROUP_INIT(utf8_tests_init, utf8_tests)
+
+
--- /dev/null
+#!/bin/bash
+
+# Author: Aaron Bockover
+# Licensed under MIT/X11
+# (C) 2006 Novell
+
+if [ "x$1" = "x--help" ]; then
+ echo "Usage: $0 [--show-only-mono]"
+ echo ""
+ echo "This script prints a sorted list of GLib functions used in Mono"
+ echo "that have not yet been implemented in EGlib."
+ echo ""
+ echo "If --show-only-mono is passed, then the script will print all"
+ echo "GLib functions used in Mono, whether or not they have been"
+ echo "implemented in EGlib yet."
+ echo ""
+ echo "This script relies on the MONO_CHECKOUT environment variable."
+ echo "MONO_CHECKOUT should be set to the location of a mono checkout."
+ echo ""
+ exit 1
+fi
+
+IGNORE_FUNCTIONS="g_hash_table_lookup_node g_hash_table_foreach_remove_or_steal g_hash_table_resize"
+
+if [ -z $MONO_CHECKOUT ]; then
+ if [ -e ../../mono.pc.in ]; then
+ MONO_CHECKOUT=../..
+ else
+ MONO_CHECKOUT=~/cvs/mono/mono
+ fi
+fi
+
+if [ ! -d $MONO_CHECKOUT ]; then
+ echo "Cannot find mono checkout; set MONO_CHECKOUT"
+ exit 1
+fi
+
+MONO_CHECKOUT="$MONO_CHECKOUT/mono"
+RESULTS_FILE=.results
+
+(for i in `find $MONO_CHECKOUT -iregex \.*.c$`; do
+ grep -oP "[ \t\(\)]+g_[a-z_]+[ ]{0,1}\([A-Za-z_\&\*\,\(\) ]+\)" $i |
+ awk 'BEGIN { FS="(" } { print $1 }' |
+ sed -e 's/[^A-Za-z_]//g'
+ done
+) > $RESULTS_FILE
+
+if [ ! "x$1" = "x--show-only-mono" ]; then
+ IMPLEMENTED_FUNCTIONS=`grep -oP "g_[a-z_]+[ ]{0,1}" ../src/glib.h | awk 'BEGIN { FS="(" } { print $1 }'`
+
+ rm -f $RESULTS_FILE.tmp
+
+ for mono_function in `cat $RESULTS_FILE`; do
+ matched="no"
+ for implemented_function in $IMPLEMENTED_FUNCTIONS; do
+ if [ "x$mono_function" = "x$implemented_function" ]; then
+ matched="yes"
+ break
+ fi
+ done
+
+ for ignore_function in $IGNORE_FUNCTIONS; do
+ if [ "x$ignore_function" = "x$mono_function" ]; then
+ matched="yes"
+ break
+ fi
+ done
+
+ if [ "x$matched" = "xno" ]; then
+ echo $mono_function >> $RESULTS_FILE.tmp
+ fi
+ done
+
+ mv $RESULTS_FILE.tmp $RESULTS_FILE
+fi
+
+(for i in `cat $RESULTS_FILE | sort -u`; do
+ echo "`grep -c $i $RESULTS_FILE` $i";
+ done;
+) | sort -nr
+
+rm $RESULTS_FILE
+
--- /dev/null
+/*
+This file is automatically generated by ucd.exe.
+The source for this generator should be in Mono repository
+(mcs/class/corlib/Mono.Globalization.Unicode directory).
+*/
+
+#ifndef __UNICODE_DATA_H
+#define __UNICODE_DATA_H
+
+#include <glib.h>
+
+
+/* ======== Structures ======== */
+typedef struct {
+ guint32 codepoint;
+ guint32 upper;
+ guint32 title;
+} SimpleTitlecaseMapping;
+typedef struct {
+ guint32 start;
+ guint32 end;
+} CodePointRange;
+typedef struct {
+ guint32 upper;
+ guint32 lower;
+} SimpleCaseMapping;
+
+/* ======== Unicode Categories ======== */
+static const guint8 unicode_category_ranges_count = 11;
+static const CodePointRange unicode_category_ranges [] = {
+{0x000000, 0x003400},
+{0x004DC0, 0x004E00},
+{0x00A000, 0x00AA80},
+{0x00F900, 0x010000},
+{0x010000, 0x0104C0},
+{0x010800, 0x010A80},
+{0x012000, 0x012480},
+{0x01D000, 0x01D800},
+{0x01F000, 0x01F0C0},
+{0x02F800, 0x02FA40},
+{0x0E0000, 0x0E0200},
+{0, 0}};
+static const guint8 unicode_category_table0 [] = {
+ /* ==== 0-3400 ==== */
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 29,21,21,21,23,21,21,21,22,18,21,25,21,17,21,21,
+ 13,13,13,13,13,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5,9,5,
+ 9,5,9,5,9,5,9,5,9,5,9,5,9,5,9,5,
+ 9,5,9,5,9,5,9,5,9,5,9,5,9,5,9,5,
+ 9,5,9,5,9,5,9,5,9,5,9,5,9,5,9,5,
+ 9,5,9,5,5,5,5,5,5,5,9,9,5,9,9,5,
+ 5,9,5,9,9,9,9,5,9,5,9,5,9,5,9,5,
+ 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
+ 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
+ 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
+ 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
+ 5,5,5,5,7,5,5,5,5,5,5,5,5,5,5,5,
+ 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
+ 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
+ 6,6,24,24,24,24,6,6,6,6,6,6,6,6,6,6,
+ 6,6,24,24,24,24,24,24,24,24,24,24,24,24,24,24,
+ 6,6,6,6,6,24,24,24,24,24,24,24,6,24,6,24,
+ 24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,
+ 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,
+ 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,
+ 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,
+ 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,
+ 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,
+ 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,
+ 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,
+ 9,5,9,5,6,24,9,5,0,0,6,5,5,5,21,0,
+ 0,0,0,0,24,24,9,21,9,9,9,0,9,0,9,9,
+ 5,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,
+ 9,9,0,9,9,9,9,9,9,9,9,9,5,5,5,5,
+ 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
+ 5,5,5,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0,0,0,0,0,
+ 0,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,
+ 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,
+ 12,12,12,12,12,12,12,12,12,12,12,12,12,12,17,12,
+ 21,12,12,21,12,12,21,12,0,0,0,0,0,0,0,0,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 7,7,7,7,7,7,7,7,7,7,7,0,0,0,0,0,
+ 7,7,7,21,21,0,0,0,0,0,0,0,0,0,0,0,
+ 1,1,1,1,0,0,25,25,25,21,21,23,21,21,26,26,
+ 12,12,12,12,12,12,12,12,12,12,12,21,0,0,21,21,
+ 0,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 6,7,7,7,7,7,7,7,7,7,7,12,12,12,12,12,
+ 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,0,
+ 13,13,13,13,13,13,13,13,13,13,21,21,21,21,7,7,
+ 12,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 7,7,7,7,21,7,12,12,12,12,12,12,12,1,11,12,
+ 12,12,12,12,12,6,6,12,12,26,12,12,12,12,7,7,
+ 13,13,13,13,13,13,13,13,13,13,7,7,7,26,26,7,
+ 21,21,21,21,21,21,21,21,21,21,21,21,21,21,0,1,
+ 7,12,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,
+ 12,12,12,12,12,12,12,12,12,12,12,0,0,7,7,7,
+ 7,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0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,7,7,0,7,0,0,7,7,0,7,0,0,7,0,0,
+ 0,0,0,0,7,7,7,7,0,7,7,7,7,7,7,7,
+ 0,7,7,7,0,7,0,7,0,0,7,7,0,7,7,7,
+ 7,12,7,7,12,12,12,12,12,12,0,12,12,7,0,0,
+ 7,7,7,7,7,0,6,0,12,12,12,12,12,12,0,0,
+ 13,13,13,13,13,13,13,13,13,13,0,0,7,7,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 7,26,26,26,21,21,21,21,21,21,21,21,21,21,21,21,
+ 21,21,21,26,26,26,26,26,12,12,26,26,26,26,26,26,
+ 13,13,13,13,13,13,13,13,13,13,15,15,15,15,15,15,
+ 15,15,15,15,26,12,26,12,26,12,22,18,22,18,10,10,
+ 7,7,7,7,7,7,7,7,0,7,7,7,7,7,7,7,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,0,0,0,
+ 0,12,12,12,12,12,12,12,12,12,12,12,12,12,12,10,
+ 12,12,12,12,12,21,12,12,7,7,7,7,0,0,0,0,
+ 12,12,12,12,12,12,12,12,0,12,12,12,12,12,12,12,
+ 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,
+ 12,12,12,12,12,12,12,12,12,12,12,12,12,0,26,26,
+ 26,26,26,26,26,26,12,26,26,26,26,26,26,0,26,26,
+ 21,21,21,21,21,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 7,7,7,7,7,7,7,7,7,7,7,10,10,12,12,12,
+ 12,10,12,12,12,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 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 12,12,12,12,10,7,7,7,7,7,7,7,7,7,7,7,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 7,7,7,7,12,10,12,12,12,12,12,10,12,10,10,10,
+ 10,10,12,10,10,7,7,7,7,7,7,7,0,0,0,0,
+ 13,13,13,13,13,13,13,13,13,13,21,21,21,21,21,21,
+ 21,26,26,26,26,26,26,26,26,26,26,12,12,12,12,12,
+ 12,12,12,12,26,26,26,26,26,26,26,26,26,0,0,0,
+ 12,12,10,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 7,10,12,12,12,12,10,10,12,12,10,0,0,0,7,7,
+ 13,13,13,13,13,13,13,13,13,13,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 7,7,7,7,10,10,10,10,10,10,10,10,12,12,12,12,
+ 12,12,12,12,10,10,12,12,0,0,0,21,21,21,21,21,
+ 13,13,13,13,13,13,13,13,13,13,0,0,0,7,7,7,
+ 13,13,13,13,13,13,13,13,13,13,7,7,7,7,7,7,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 7,7,7,7,7,7,7,7,6,6,6,6,6,6,21,21,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,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21,21,21,21,20,19,21,21,21,21,16,
+ 16,21,21,21,25,22,18,21,21,21,21,21,21,21,21,21,
+ 21,21,25,21,16,21,21,21,21,21,21,21,21,21,21,29,
+ 1,1,1,1,1,0,0,0,0,0,1,1,1,1,1,1,
+ 15,5,0,0,15,15,15,15,15,15,25,25,25,22,18,5,
+ 15,15,15,15,15,15,15,15,15,15,25,25,25,22,18,0,
+ 6,6,6,6,6,0,0,0,0,0,0,0,0,0,0,0,
+ 23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,
+ 23,23,23,23,23,23,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 12,12,12,12,12,12,12,12,12,12,12,12,12,11,11,11,
+ 11,12,11,11,11,12,12,12,12,12,12,12,12,12,12,12,
+ 12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 26,26,9,26,26,26,26,9,26,26,5,9,9,9,5,5,
+ 9,9,9,5,26,9,26,26,26,9,9,9,9,9,26,26,
+ 26,26,26,26,9,26,9,26,9,26,9,9,9,9,26,5,
+ 9,9,9,9,5,7,7,7,7,5,26,26,5,5,9,9,
+ 25,25,25,25,25,9,5,5,5,5,26,25,26,26,5,26,
+ 0,0,0,15,15,15,15,15,15,15,15,15,15,15,15,15,
+ 14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,
+ 14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,
+ 14,14,14,9,5,14,14,14,14,0,0,0,0,0,0,0,
+ 25,25,25,25,25,26,26,26,26,26,25,25,26,26,26,26,
+ 25,26,26,25,26,26,25,26,26,26,26,26,26,26,25,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,25,25,
+ 26,26,25,26,25,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,25,25,25,25,25,25,25,25,25,25,25,25,
+ 25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
+ 25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
+ 25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
+ 25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
+ 25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
+ 25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
+ 25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
+ 25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
+ 25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
+ 25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
+ 25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
+ 25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
+ 25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
+ 25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
+ 25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
+ 25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
+ 26,26,26,26,26,26,26,26,25,25,25,25,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 25,25,26,26,26,26,26,26,26,22,18,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,25,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,25,25,25,25,25,
+ 25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
+ 25,25,25,25,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,25,25,25,25,
+ 25,25,26,26,26,26,26,26,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 26,26,26,26,26,26,26,26,26,26,26,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,
+ 15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,
+ 15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,
+ 15,15,15,15,15,15,15,15,15,15,15,15,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,15,15,15,15,15,15,
+ 15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,25,26,26,26,26,26,26,26,26,
+ 26,25,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,25,25,25,25,25,25,25,25,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,25,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,0,0,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,0,0,0,
+ 26,26,26,26,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,26,26,26,26,0,26,26,26,26,0,0,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,0,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,0,26,0,26,
+ 26,26,26,0,0,0,26,0,26,26,26,26,26,26,26,0,
+ 0,26,26,26,26,26,26,26,22,18,22,18,22,18,22,18,
+ 22,18,22,18,22,18,15,15,15,15,15,15,15,15,15,15,
+ 15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,
+ 15,15,15,15,26,0,0,0,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 0,26,26,26,26,26,26,26,26,26,26,26,26,26,26,0,
+ 25,25,25,25,25,22,18,25,25,25,25,0,25,0,0,0,
+ 25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
+ 25,25,25,25,25,25,22,18,22,18,22,18,22,18,22,18,
+ 25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
+ 25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
+ 25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
+ 25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
+ 25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
+ 25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
+ 25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
+ 25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
+ 25,25,25,22,18,22,18,22,18,22,18,22,18,22,18,22,
+ 18,22,18,22,18,22,18,22,18,25,25,25,25,25,25,25,
+ 25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
+ 25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
+ 25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
+ 25,25,25,25,25,25,25,25,22,18,22,18,25,25,25,25,
+ 25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
+ 25,25,25,25,25,25,25,25,25,25,25,25,22,18,25,25,
+ 25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
+ 25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
+ 25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
+ 25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
+ 25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
+ 25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
+ 25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
+ 25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
+ 25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
+ 25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
+ 25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
+ 25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
+ 25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
+ 25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
+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0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,0,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,0,0,0,0,0,0,0,0,0,0,0,0,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 26,26,26,26,26,26,26,26,26,26,26,26,0,0,0,0,
+ 29,21,21,21,26,6,7,14,22,18,22,18,22,18,22,18,
+ 22,18,26,26,22,18,22,18,22,18,22,18,17,22,18,18,
+ 26,14,14,14,14,14,14,14,14,14,12,12,12,12,12,12,
+ 17,6,6,6,6,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7,7,7,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,0,
+ 15,15,15,15,15,15,15,15,15,15,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,0,0,0,0,0,0,0,0,0,0,0,0,
+ 26,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 15,15,15,15,15,15,15,15,15,15,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,0,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 0};
+static const guint8 unicode_category_table1 [] = {
+ /* ==== 4DC0-4E00 ==== */
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 0};
+static const guint8 unicode_category_table2 [] = {
+ /* ==== A000-AA80 ==== */
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 7,7,7,7,7,6,7,7,7,7,7,7,7,7,7,7,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+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0,0,0,0,0,0,0,0,0,0,0,
+ 7,7,7,7,7,7,7,7,7,7,7,7,23,26,0,0,
+ 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,
+ 21,21,21,21,21,21,21,22,18,21,0,0,0,0,0,0,
+ 12,12,12,12,12,12,12,0,0,0,0,0,0,0,0,0,
+ 21,17,17,16,16,22,18,22,18,22,18,22,18,22,18,22,
+ 18,22,18,22,18,21,21,22,18,21,21,21,21,16,16,16,
+ 21,21,21,0,21,21,21,21,17,22,18,22,18,22,18,21,
+ 21,21,25,17,25,25,25,0,21,23,21,21,0,0,0,0,
+ 7,7,7,7,7,0,7,7,7,7,7,7,7,7,7,7,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,0,0,1,
+ 0,21,21,21,23,21,21,21,22,18,21,25,21,17,21,21,
+ 13,13,13,13,13,13,13,13,13,13,21,21,25,25,25,21,
+ 21,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,
+ 9,9,9,9,9,9,9,9,9,9,9,22,21,18,24,16,
+ 24,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
+ 5,5,5,5,5,5,5,5,5,5,5,22,25,18,25,22,
+ 18,21,22,18,21,21,7,7,7,7,7,7,7,7,7,7,
+ 6,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,6,6,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,0,
+ 0,0,7,7,7,7,7,7,0,0,7,7,7,7,7,7,
+ 0,0,7,7,7,7,7,7,0,0,7,7,7,0,0,0,
+ 23,23,25,24,26,23,23,0,26,25,25,25,25,26,26,0,
+ 0,0,0,0,0,0,0,0,0,1,1,1,26,26,0};
+static const guint8 unicode_category_table4 [] = {
+ /* ==== 10000-104C0 ==== */
+ 7,7,7,7,7,7,7,7,7,7,7,7,0,7,7,7,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 7,7,7,7,7,7,7,0,7,7,7,7,7,7,7,7,
+ 7,7,7,7,7,7,7,7,7,7,7,0,7,7,0,7,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,0,0,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 7,7,7,7,7,7,7,7,7,7,7,0,0,0,0,0,
+ 21,21,26,0,0,0,0,15,15,15,15,15,15,15,15,15,
+ 15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,
+ 15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,
+ 15,15,15,15,0,0,0,26,26,26,26,26,26,26,26,26,
+ 14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,
+ 14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,
+ 14,14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7,7,7,7,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,
+ 14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,
+ 14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,
+ 14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,
+ 14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,
+ 14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,
+ 14,14,14,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 21,21,21,21,0};
+static const guint8 unicode_category_table7 [] = {
+ /* ==== 1D000-1D800 ==== */
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,0,0,0,0,0,0,0,0,0,0,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,0,0,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,10,10,12,12,12,26,26,26,10,10,10,
+ 10,10,10,1,1,1,1,1,1,1,1,12,12,12,12,12,
+ 12,12,12,26,26,12,12,12,12,12,12,12,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,12,12,12,12,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,12,12,12,26,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,0,0,0,0,0,0,0,0,0,
+ 15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,
+ 15,15,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,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5,5,5,5,5,5,5,5,5,5,
+ 5,5,5,5,5,5,5,5,5,25,5,5,5,5,5,5,
+ 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,
+ 9,9,9,9,9,9,9,9,9,25,5,5,5,5,5,5,
+ 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
+ 5,5,5,25,5,5,5,5,5,5,9,5,0,0,13,13,
+ 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,
+ 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,
+ 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,
+ 0};
+static const guint8 unicode_category_table8 [] = {
+ /* ==== 1F000-1F0C0 ==== */
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,0,0,0,0,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
+ 26,26,26,26,0};
+static const guint8 unicode_category_table9 [] = {
+ /* ==== 2F800-2FA40 ==== */
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7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0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,
+ 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,
+ 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,
+ 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,
+ 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,
+ 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,
+ 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,
+ 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,
+ 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,
+ 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,
+ 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,
+ 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,
+ 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,
+ 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,
+ 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,
+ 0};
+static const guint8 *unicode_category [11] = {
+ unicode_category_table0,
+ unicode_category_table1,
+ unicode_category_table2,
+ unicode_category_table3,
+ unicode_category_table4,
+ unicode_category_table5,
+ unicode_category_table6,
+ unicode_category_table7,
+ unicode_category_table8,
+ unicode_category_table9,
+ unicode_category_table10
+};
+
+static const guint8 simple_case_map_ranges_count = 9;
+static const CodePointRange simple_case_map_ranges [] = {
+{0x000040, 0x000600},
+{0x001000, 0x0010D0},
+{0x001D00, 0x002000},
+{0x002100, 0x0021C0},
+{0x002480, 0x002500},
+{0x002C00, 0x002D80},
+{0x00A640, 0x00A7C0},
+{0x00FF20, 0x00FF80},
+{0x010400, 0x010480},
+{0, 0}};
+static const guint16 simple_upper_case_mapping_lowarea_table0 [] = {
+ /* ==== 40-600 ==== */
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4A,0x4B,0x4C,0x4D,0x4E,0x4F,
+ 0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5A,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0x39C,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,
+ 0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0x178,
+ 0,0x100,0,0x102,0,0x104,0,0x106,0,0x108,0,0x10A,0,0x10C,0,0x10E,
+ 0,0x110,0,0x112,0,0x114,0,0x116,0,0x118,0,0x11A,0,0x11C,0,0x11E,
+ 0,0x120,0,0x122,0,0x124,0,0x126,0,0x128,0,0x12A,0,0x12C,0,0x12E,
+ 0,0x49,0,0x132,0,0x134,0,0x136,0,0,0x139,0,0x13B,0,0x13D,0,
+ 0x13F,0,0x141,0,0x143,0,0x145,0,0x147,0,0,0x14A,0,0x14C,0,0x14E,
+ 0,0x150,0,0x152,0,0x154,0,0x156,0,0x158,0,0x15A,0,0x15C,0,0x15E,
+ 0,0x160,0,0x162,0,0x164,0,0x166,0,0x168,0,0x16A,0,0x16C,0,0x16E,
+ 0,0x170,0,0x172,0,0x174,0,0x176,0,0,0x179,0,0x17B,0,0x17D,0x53,
+ 0x243,0,0,0x182,0,0x184,0,0,0x187,0,0,0,0x18B,0,0,0,
+ 0,0,0x191,0,0,0x1F6,0,0,0,0x198,0x23D,0,0,0,0x220,0,
+ 0,0x1A0,0,0x1A2,0,0x1A4,0,0,0x1A7,0,0,0,0,0x1AC,0,0,
+ 0x1AF,0,0,0,0x1B3,0,0x1B5,0,0,0x1B8,0,0,0,0x1BC,0,0x1F7,
+ 0,0,0,0,0,0x1C4,0x1C4,0,0x1C7,0x1C7,0,0x1CA,0x1CA,0,0x1CD,0,
+ 0x1CF,0,0x1D1,0,0x1D3,0,0x1D5,0,0x1D7,0,0x1D9,0,0x1DB,0x18E,0,0x1DE,
+ 0,0x1E0,0,0x1E2,0,0x1E4,0,0x1E6,0,0x1E8,0,0x1EA,0,0x1EC,0,0x1EE,
+ 0,0,0x1F1,0x1F1,0,0x1F4,0,0,0,0x1F8,0,0x1FA,0,0x1FC,0,0x1FE,
+ 0,0x200,0,0x202,0,0x204,0,0x206,0,0x208,0,0x20A,0,0x20C,0,0x20E,
+ 0,0x210,0,0x212,0,0x214,0,0x216,0,0x218,0,0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 0,0,0,0,0,0,0,0,0,0,0,0,0x386,0x388,0x389,0x38A,
+ 0,0x391,0x392,0x393,0x394,0x395,0x396,0x397,0x398,0x399,0x39A,0x39B,0x39C,0x39D,0x39E,0x39F,
+ 0x3A0,0x3A1,0x3A3,0x3A3,0x3A4,0x3A5,0x3A6,0x3A7,0x3A8,0x3A9,0x3AA,0x3AB,0x38C,0x38E,0x38F,0,
+ 0x392,0x398,0,0,0,0x3A6,0x3A0,0x3CF,0,0x3D8,0,0x3DA,0,0x3DC,0,0x3DE,
+ 0,0x3E0,0,0x3E2,0,0x3E4,0,0x3E6,0,0x3E8,0,0x3EA,0,0x3EC,0,0x3EE,
+ 0x39A,0x3A1,0x3F9,0,0,0x395,0,0,0x3F7,0,0,0x3FA,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0x410,0x411,0x412,0x413,0x414,0x415,0x416,0x417,0x418,0x419,0x41A,0x41B,0x41C,0x41D,0x41E,0x41F,
+ 0x420,0x421,0x422,0x423,0x424,0x425,0x426,0x427,0x428,0x429,0x42A,0x42B,0x42C,0x42D,0x42E,0x42F,
+ 0x400,0x401,0x402,0x403,0x404,0x405,0x406,0x407,0x408,0x409,0x40A,0x40B,0x40C,0x40D,0x40E,0x40F,
+ 0,0x460,0,0x462,0,0x464,0,0x466,0,0x468,0,0x46A,0,0x46C,0,0x46E,
+ 0,0x470,0,0x472,0,0x474,0,0x476,0,0x478,0,0x47A,0,0x47C,0,0x47E,
+ 0,0x480,0,0,0,0,0,0,0,0,0,0x48A,0,0x48C,0,0x48E,
+ 0,0x490,0,0x492,0,0x494,0,0x496,0,0x498,0,0x49A,0,0x49C,0,0x49E,
+ 0,0x4A0,0,0x4A2,0,0x4A4,0,0x4A6,0,0x4A8,0,0x4AA,0,0x4AC,0,0x4AE,
+ 0,0x4B0,0,0x4B2,0,0x4B4,0,0x4B6,0,0x4B8,0,0x4BA,0,0x4BC,0,0x4BE,
+ 0,0,0x4C1,0,0x4C3,0,0x4C5,0,0x4C7,0,0x4C9,0,0x4CB,0,0x4CD,0x4C0,
+ 0,0x4D0,0,0x4D2,0,0x4D4,0,0x4D6,0,0x4D8,0,0x4DA,0,0x4DC,0,0x4DE,
+ 0,0x4E0,0,0x4E2,0,0x4E4,0,0x4E6,0,0x4E8,0,0x4EA,0,0x4EC,0,0x4EE,
+ 0,0x4F0,0,0x4F2,0,0x4F4,0,0x4F6,0,0x4F8,0,0x4FA,0,0x4FC,0,0x4FE,
+ 0,0x500,0,0x502,0,0x504,0,0x506,0,0x508,0,0x50A,0,0x50C,0,0x50E,
+ 0,0x510,0,0x512,0,0x514,0,0x516,0,0x518,0,0x51A,0,0x51C,0,0x51E,
+ 0,0x520,0,0x522,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0x531,0x532,0x533,0x534,0x535,0x536,0x537,0x538,0x539,0x53A,0x53B,0x53C,0x53D,0x53E,0x53F,
+ 0x540,0x541,0x542,0x543,0x544,0x545,0x546,0x547,0x548,0x549,0x54A,0x54B,0x54C,0x54D,0x54E,0x54F,
+ 0x550,0x551,0x552,0x553,0x554,0x555,0x556,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0};
+static const guint16 simple_upper_case_mapping_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1FB8,0x1FB9,0,0x1FBC,0,0,0,0,0,0,0,0,0,0,0x399,0,
+ 0,0,0,0x1FCC,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0x1FD8,0x1FD9,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0x1FE8,0x1FE9,0,0,0,0x1FEC,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0x1FFC,0,0,0,0,0,0,0,0,0,0,0,0};
+static const guint16 simple_upper_case_mapping_lowarea_table3 [] = {
+ /* ==== 2100-21C0 ==== */
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0x2132,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0x2160,0x2161,0x2162,0x2163,0x2164,0x2165,0x2166,0x2167,0x2168,0x2169,0x216A,0x216B,0x216C,0x216D,0x216E,0x216F,
+ 0,0,0,0,0x2183,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0};
+static const guint16 simple_upper_case_mapping_lowarea_table4 [] = {
+ /* ==== 2480-2500 ==== */
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0x24B6,0x24B7,0x24B8,0x24B9,0x24BA,0x24BB,0x24BC,0x24BD,0x24BE,0x24BF,0x24C0,0x24C1,0x24C2,0x24C3,0x24C4,0x24C5,
+ 0x24C6,0x24C7,0x24C8,0x24C9,0x24CA,0x24CB,0x24CC,0x24CD,0x24CE,0x24CF,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0};
+static const guint16 simple_upper_case_mapping_lowarea_table5 [] = {
+ /* ==== 2C00-2D80 ==== */
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0x2C00,0x2C01,0x2C02,0x2C03,0x2C04,0x2C05,0x2C06,0x2C07,0x2C08,0x2C09,0x2C0A,0x2C0B,0x2C0C,0x2C0D,0x2C0E,0x2C0F,
+ 0x2C10,0x2C11,0x2C12,0x2C13,0x2C14,0x2C15,0x2C16,0x2C17,0x2C18,0x2C19,0x2C1A,0x2C1B,0x2C1C,0x2C1D,0x2C1E,0x2C1F,
+ 0x2C20,0x2C21,0x2C22,0x2C23,0x2C24,0x2C25,0x2C26,0x2C27,0x2C28,0x2C29,0x2C2A,0x2C2B,0x2C2C,0x2C2D,0x2C2E,0,
+0,0x2C60,0,0,0,0x23A,0x23E,0,0x2C67,0,0x2C69,0,0x2C6B,0,0,0,
+ 0,0,0,0x2C72,0,0,0x2C75,0,0,0,0,0,0,0,0,0,
+0,0x2C80,0,0x2C82,0,0x2C84,0,0x2C86,0,0x2C88,0,0x2C8A,0,0x2C8C,0,0x2C8E,
+ 0,0x2C90,0,0x2C92,0,0x2C94,0,0x2C96,0,0x2C98,0,0x2C9A,0,0x2C9C,0,0x2C9E,
+ 0,0x2CA0,0,0x2CA2,0,0x2CA4,0,0x2CA6,0,0x2CA8,0,0x2CAA,0,0x2CAC,0,0x2CAE,
+ 0,0x2CB0,0,0x2CB2,0,0x2CB4,0,0x2CB6,0,0x2CB8,0,0x2CBA,0,0x2CBC,0,0x2CBE,
+ 0,0x2CC0,0,0x2CC2,0,0x2CC4,0,0x2CC6,0,0x2CC8,0,0x2CCA,0,0x2CCC,0,0x2CCE,
+ 0,0x2CD0,0,0x2CD2,0,0x2CD4,0,0x2CD6,0,0x2CD8,0,0x2CDA,0,0x2CDC,0,0x2CDE,
+ 0,0x2CE0,0,0x2CE2,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0x10A0,0x10A1,0x10A2,0x10A3,0x10A4,0x10A5,0x10A6,0x10A7,0x10A8,0x10A9,0x10AA,0x10AB,0x10AC,0x10AD,0x10AE,0x10AF,
+ 0x10B0,0x10B1,0x10B2,0x10B3,0x10B4,0x10B5,0x10B6,0x10B7,0x10B8,0x10B9,0x10BA,0x10BB,0x10BC,0x10BD,0x10BE,0x10BF,
+ 0x10C0,0x10C1,0x10C2,0x10C3,0x10C4,0x10C5,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0};
+static const guint16 simple_upper_case_mapping_lowarea_table6 [] = {
+ /* ==== A640-A7C0 ==== */
+ 0,0xA640,0,0xA642,0,0xA644,0,0xA646,0,0xA648,0,0xA64A,0,0xA64C,0,0xA64E,
+ 0,0xA650,0,0xA652,0,0xA654,0,0xA656,0,0xA658,0,0xA65A,0,0xA65C,0,0xA65E,
+ 0,0,0,0xA662,0,0xA664,0,0xA666,0,0xA668,0,0xA66A,0,0xA66C,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0xA680,0,0xA682,0,0xA684,0,0xA686,0,0xA688,0,0xA68A,0,0xA68C,0,0xA68E,
+ 0,0xA690,0,0xA692,0,0xA694,0,0xA696,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0xA722,0,0xA724,0,0xA726,0,0xA728,0,0xA72A,0,0xA72C,0,0xA72E,
+ 0,0,0,0xA732,0,0xA734,0,0xA736,0,0xA738,0,0xA73A,0,0xA73C,0,0xA73E,
+ 0,0xA740,0,0xA742,0,0xA744,0,0xA746,0,0xA748,0,0xA74A,0,0xA74C,0,0xA74E,
+ 0,0xA750,0,0xA752,0,0xA754,0,0xA756,0,0xA758,0,0xA75A,0,0xA75C,0,0xA75E,
+ 0,0xA760,0,0xA762,0,0xA764,0,0xA766,0,0xA768,0,0xA76A,0,0xA76C,0,0xA76E,
+ 0,0,0,0,0,0,0,0,0,0,0xA779,0,0xA77B,0,0,0xA77E,
+ 0,0xA780,0,0xA782,0,0xA784,0,0xA786,0,0,0,0,0xA78B,0};
+static const guint16 simple_upper_case_mapping_lowarea_table7 [] = {
+ /* ==== FF20-FF80 ==== */
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0xFF21,0xFF22,0xFF23,0xFF24,0xFF25,0xFF26,0xFF27,0xFF28,0xFF29,0xFF2A,0xFF2B,0xFF2C,0xFF2D,0xFF2E,0xFF2F,
+ 0xFF30,0xFF31,0xFF32,0xFF33,0xFF34,0xFF35,0xFF36,0xFF37,0xFF38,0xFF39,0xFF3A,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0};
+static const guint16 *simple_upper_case_mapping_lowarea [] = {
+ simple_upper_case_mapping_lowarea_table0,
+ simple_upper_case_mapping_lowarea_table1,
+ simple_upper_case_mapping_lowarea_table2,
+ simple_upper_case_mapping_lowarea_table3,
+ simple_upper_case_mapping_lowarea_table4,
+ simple_upper_case_mapping_lowarea_table5,
+ simple_upper_case_mapping_lowarea_table6,
+ simple_upper_case_mapping_lowarea_table7};
+static const int simple_upper_case_mapping_lowarea_table_count = 8;
+
+static const guint32 simple_upper_case_mapping_higharea_table0 [] = {
+ /* ==== 10400-10480 ==== */
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0x10400,0x10401,0x10402,0x10403,0x10404,0x10405,0x10406,0x10407,
+ 0x10408,0x10409,0x1040A,0x1040B,0x1040C,0x1040D,0x1040E,0x1040F,0x10410,0x10411,0x10412,0x10413,0x10414,0x10415,0x10416,0x10417,
+ 0x10418,0x10419,0x1041A,0x1041B,0x1041C,0x1041D,0x1041E,0x1041F,0x10420,0x10421,0x10422,0x10423,0x10424,0x10425,0x10426,0x10427,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0};
+static const guint32 *simple_upper_case_mapping_higharea [] = {
+ simple_upper_case_mapping_higharea_table0};
+
+static const guint16 simple_lower_case_mapping_lowarea_table0 [] = {
+ /* ==== 40-600 ==== */
+ 0,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6A,0x6B,0x6C,0x6D,0x6E,0x6F,
+ 0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7A,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,
+ 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0x101,0,0x103,0,0x105,0,0x107,0,0x109,0,0x10B,0,0x10D,0,0x10F,0,
+ 0x111,0,0x113,0,0x115,0,0x117,0,0x119,0,0x11B,0,0x11D,0,0x11F,0,
+ 0x121,0,0x123,0,0x125,0,0x127,0,0x129,0,0x12B,0,0x12D,0,0x12F,0,
+ 0x69,0,0x133,0,0x135,0,0x137,0,0,0x13A,0,0x13C,0,0x13E,0,0x140,
+ 0,0x142,0,0x144,0,0x146,0,0x148,0,0,0x14B,0,0x14D,0,0x14F,0,
+ 0x151,0,0x153,0,0x155,0,0x157,0,0x159,0,0x15B,0,0x15D,0,0x15F,0,
+ 0x161,0,0x163,0,0x165,0,0x167,0,0x169,0,0x16B,0,0x16D,0,0x16F,0,
+ 0x171,0,0x173,0,0x175,0,0x177,0,0xFF,0x17A,0,0x17C,0,0x17E,0,0,
+ 0,0x253,0x183,0,0x185,0,0x254,0x188,0,0x256,0x257,0x18C,0,0,0x1DD,0x259,
+ 0x25B,0x192,0,0x260,0x263,0,0x269,0x268,0x199,0,0,0,0x26F,0x272,0,0x275,
+ 0x1A1,0,0x1A3,0,0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D,0x44E,0x44F,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0x461,0,0x463,0,0x465,0,0x467,0,0x469,0,0x46B,0,0x46D,0,0x46F,0,
+ 0x471,0,0x473,0,0x475,0,0x477,0,0x479,0,0x47B,0,0x47D,0,0x47F,0,
+ 0x481,0,0,0,0,0,0,0,0,0,0x48B,0,0x48D,0,0x48F,0,
+ 0x491,0,0x493,0,0x495,0,0x497,0,0x499,0,0x49B,0,0x49D,0,0x49F,0,
+ 0x4A1,0,0x4A3,0,0x4A5,0,0x4A7,0,0x4A9,0,0x4AB,0,0x4AD,0,0x4AF,0,
+ 0x4B1,0,0x4B3,0,0x4B5,0,0x4B7,0,0x4B9,0,0x4BB,0,0x4BD,0,0x4BF,0,
+ 0x4CF,0x4C2,0,0x4C4,0,0x4C6,0,0x4C8,0,0x4CA,0,0x4CC,0,0x4CE,0,0,
+ 0x4D1,0,0x4D3,0,0x4D5,0,0x4D7,0,0x4D9,0,0x4DB,0,0x4DD,0,0x4DF,0,
+ 0x4E1,0,0x4E3,0,0x4E5,0,0x4E7,0,0x4E9,0,0x4EB,0,0x4ED,0,0x4EF,0,
+ 0x4F1,0,0x4F3,0,0x4F5,0,0x4F7,0,0x4F9,0,0x4FB,0,0x4FD,0,0x4FF,0,
+ 0x501,0,0x503,0,0x505,0,0x507,0,0x509,0,0x50B,0,0x50D,0,0x50F,0,
+ 0x511,0,0x513,0,0x515,0,0x517,0,0x519,0,0x51B,0,0x51D,0,0x51F,0,
+ 0x521,0,0x523,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0x561,0x562,0x563,0x564,0x565,0x566,0x567,0x568,0x569,0x56A,0x56B,0x56C,0x56D,0x56E,0x56F,
+ 0x570,0x571,0x572,0x573,0x574,0x575,0x576,0x577,0x578,0x579,0x57A,0x57B,0x57C,0x57D,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,0x2171,0x2172,0x2173,0x2174,0x2175,0x2176,0x2177,0x2178,0x2179,0x217A,0x217B,0x217C,0x217D,0x217E,0x217F,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0x2184,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0};
+static const guint16 simple_lower_case_mapping_lowarea_table4 [] = {
+ /* ==== 2480-2500 ==== */
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0x24D0,0x24D1,0x24D2,0x24D3,0x24D4,0x24D5,0x24D6,0x24D7,0x24D8,0x24D9,
+ 0x24DA,0x24DB,0x24DC,0x24DD,0x24DE,0x24DF,0x24E0,0x24E1,0x24E2,0x24E3,0x24E4,0x24E5,0x24E6,0x24E7,0x24E8,0x24E9,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0};
+static const guint16 simple_lower_case_mapping_lowarea_table5 [] = {
+ /* ==== 2C00-2D80 ==== */
+ 0x2C30,0x2C31,0x2C32,0x2C33,0x2C34,0x2C35,0x2C36,0x2C37,0x2C38,0x2C39,0x2C3A,0x2C3B,0x2C3C,0x2C3D,0x2C3E,0x2C3F,
+ 0x2C40,0x2C41,0x2C42,0x2C43,0x2C44,0x2C45,0x2C46,0x2C47,0x2C48,0x2C49,0x2C4A,0x2C4B,0x2C4C,0x2C4D,0x2C4E,0x2C4F,
+ 0x2C50,0x2C51,0x2C52,0x2C53,0x2C54,0x2C55,0x2C56,0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,0,0,0,0,0,0,0,0,0,0,0,
+ 0};
+static const guint16 simple_lower_case_mapping_lowarea_table6 [] = {
+ /* ==== A640-A7C0 ==== */
+ 0xA641,0,0xA643,0,0xA645,0,0xA647,0,0xA649,0,0xA64B,0,0xA64D,0,0xA64F,0,
+ 0xA651,0,0xA653,0,0xA655,0,0xA657,0,0xA659,0,0xA65B,0,0xA65D,0,0xA65F,0,
+ 0,0,0xA663,0,0xA665,0,0xA667,0,0xA669,0,0xA66B,0,0xA66D,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0xA681,0,0xA683,0,0xA685,0,0xA687,0,0xA689,0,0xA68B,0,0xA68D,0,0xA68F,0,
+ 0xA691,0,0xA693,0,0xA695,0,0xA697,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0xA723,0,0xA725,0,0xA727,0,0xA729,0,0xA72B,0,0xA72D,0,0xA72F,0,
+ 0,0,0xA733,0,0xA735,0,0xA737,0,0xA739,0,0xA73B,0,0xA73D,0,0xA73F,0,
+ 0xA741,0,0xA743,0,0xA745,0,0xA747,0,0xA749,0,0xA74B,0,0xA74D,0,0xA74F,0,
+ 0xA751,0,0xA753,0,0xA755,0,0xA757,0,0xA759,0,0xA75B,0,0xA75D,0,0xA75F,0,
+ 0xA761,0,0xA763,0,0xA765,0,0xA767,0,0xA769,0,0xA76B,0,0xA76D,0,0xA76F,0,
+ 0,0,0,0,0,0,0,0,0,0xA77A,0,0xA77C,0,0x1D79,0xA77F,0,
+ 0xA781,0,0xA783,0,0xA785,0,0xA787,0,0,0,0,0xA78C,0,0};
+static const guint16 simple_lower_case_mapping_lowarea_table7 [] = {
+ /* ==== FF20-FF80 ==== */
+ 0,0xFF41,0xFF42,0xFF43,0xFF44,0xFF45,0xFF46,0xFF47,0xFF48,0xFF49,0xFF4A,0xFF4B,0xFF4C,0xFF4D,0xFF4E,0xFF4F,
+ 0xFF50,0xFF51,0xFF52,0xFF53,0xFF54,0xFF55,0xFF56,0xFF57,0xFF58,0xFF59,0xFF5A,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0};
+static const guint16 *simple_lower_case_mapping_lowarea [] = {
+ simple_lower_case_mapping_lowarea_table0,
+ simple_lower_case_mapping_lowarea_table1,
+ simple_lower_case_mapping_lowarea_table2,
+ simple_lower_case_mapping_lowarea_table3,
+ simple_lower_case_mapping_lowarea_table4,
+ simple_lower_case_mapping_lowarea_table5,
+ simple_lower_case_mapping_lowarea_table6,
+ simple_lower_case_mapping_lowarea_table7};
+static const int simple_lower_case_mapping_lowarea_table_count = 8;
+
+static const guint32 simple_lower_case_mapping_higharea_table0 [] = {
+ /* ==== 10400-10480 ==== */
+ 0x10428,0x10429,0x1042A,0x1042B,0x1042C,0x1042D,0x1042E,0x1042F,0x10430,0x10431,0x10432,0x10433,0x10434,0x10435,0x10436,0x10437,
+ 0x10438,0x10439,0x1043A,0x1043B,0x1043C,0x1043D,0x1043E,0x1043F,0x10440,0x10441,0x10442,0x10443,0x10444,0x10445,0x10446,0x10447,
+ 0x10448,0x10449,0x1044A,0x1044B,0x1044C,0x1044D,0x1044E,0x1044F,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0};
+static const guint32 *simple_lower_case_mapping_higharea [] = {
+ simple_lower_case_mapping_higharea_table0};
+
+
+static const SimpleTitlecaseMapping simple_titlecase_mapping [] = {
+ {0x0001C4, 0x000000, 0x0001C5},
+ {0x0001C5, 0x0001C4, 0x0001C5},
+ {0x0001C6, 0x0001C4, 0x0001C5},
+ {0x0001C7, 0x000000, 0x0001C8},
+ {0x0001C8, 0x0001C7, 0x0001C8},
+ {0x0001C9, 0x0001C7, 0x0001C8},
+ {0x0001CA, 0x000000, 0x0001CB},
+ {0x0001CB, 0x0001CA, 0x0001CB},
+ {0x0001CC, 0x0001CA, 0x0001CB},
+ {0x0001F1, 0x000000, 0x0001F2},
+ {0x0001F2, 0x0001F1, 0x0001F2},
+ {0x0001F3, 0x0001F1, 0x0001F2}
+};
+static const guint8 simple_titlecase_mapping_count = 12;
+
+#endif
+
platform_sources += ../../support/libm/complex.c
endif
-#
-# libtool is not capable of creating static/shared versions of the same
-# convenience lib, so we have to do it ourselves
-#
if SUPPORT_SGEN
if DISABLE_EXECUTABLES
shared_sgen_libraries = libmonoruntimesgen.la
shared_sgen_libraries = libmonoruntimesgen.la
endif
endif
-sgen_libraries = $(shared_sgen_libraries) libmonoruntimesgen-static.la
+sgen_libraries = $(shared_sgen_libraries)
endif
if SUPPORT_BOEHM
shared_boehm_libraries = libmonoruntime.la
endif
endif
-boehm_libraries = $(shared_boehm_libraries) libmonoruntime-static.la
+boehm_libraries = $(shared_boehm_libraries)
endif
if DISABLE_EXECUTABLES
libmonoruntimesgen_la_CFLAGS = $(SGEN_DEFINES)
libmonoruntimesgen_la_LIBADD = libmonoruntime-config.la
-libmonoruntime_static_la_SOURCES = $(libmonoruntime_la_SOURCES)
-libmonoruntime_static_la_LDFLAGS = -static
-libmonoruntime_static_la_CFLAGS = $(BOEHM_DEFINES)
-libmonoruntime_static_la_LIBADD = $(bundle_obj) libmonoruntime-config.la
-
-libmonoruntimesgen_static_la_SOURCES = $(libmonoruntimesgen_la_SOURCES)
-libmonoruntimesgen_static_la_LDFLAGS = -static
-libmonoruntimesgen_static_la_CFLAGS = $(SGEN_DEFINES)
-libmonoruntimesgen_static_la_LIBADD = libmonoruntime-config.la
-
libmonoruntimeincludedir = $(includedir)/mono-$(API_VER)/mono/metadata
libmonoruntimeinclude_HEADERS = \
$(monodir)/mono/utils/libmonoutils.la \
$(GLIB_LIBS) $(LIBICONV)
-boehm_static_libs= \
- $(monodir)/mono/metadata/libmonoruntime-static.la \
- $(monodir)/mono/utils/libmonoutils.la \
- $(GLIB_LIBS) $(LIBICONV) \
- $(libgc_static_libs)
-
-sgen_static_libs = \
- $(monodir)/mono/metadata/libmonoruntimesgen-static.la \
- $(monodir)/mono/sgen/libmonosgen-static.la \
- $(monodir)/mono/utils/libmonoutils.la \
- $(GLIB_LIBS) $(LIBICONV)
-
if FULL_AOT_TESTS
# if the tests are going to run with framework assemblies compiled with
# -d:MOBILE, tell the runtime to remap framework assemblies using the mobile
if SUPPORT_SGEN
sgen_binaries = mono-sgen
sgen_libraries = libmonosgen-2.0.la
-sgen_static_libraries = libmini-static.la $(sgen_static_libs)
+sgen_static_libraries = libmini.la $(sgen_libs)
endif
if SUPPORT_BOEHM
boehm_libraries = libmonoboehm-2.0.la
-boehm_static_libraries = libmini-static.la $(boehm_static_libs)
+boehm_static_libraries = libmini.la $(boehm_libs)
boehm_binaries = mono-boehm
endif
if DISABLE_EXECUTABLES
noinst_LTLIBRARIES = $(mini_common_lib)
else
-noinst_LTLIBRARIES = $(mini_common_lib) libmini-static.la
+noinst_LTLIBRARIES = $(mini_common_lib)
endif
if LOADED_LLVM
# We build this after libmono was built so it contains the date when the final
# link was done
if SUPPORT_BOEHM
-if DISABLE_EXECUTABLES
-buildver-boehm.h: libmini-static.la $(monodir)/mono/metadata/libmonoruntime.la
-else
-buildver-boehm.h: libmini-static.la $(monodir)/mono/metadata/libmonoruntime-static.la
-endif
+buildver-boehm.h: libmini.la $(monodir)/mono/metadata/libmonoruntime.la
@echo "const char *build_date = \"`date`\";" > buildver-boehm.h
mono_boehm-main.$(OBJEXT): buildver-boehm.h
endif
-if DISABLE_EXECUTABLES
-buildver-sgen.h: libmini-static.la $(monodir)/mono/metadata/libmonoruntimesgen.la $(monodir)/mono/sgen/libmonosgen.la
-else
-buildver-sgen.h: libmini-static.la $(monodir)/mono/metadata/libmonoruntimesgen-static.la $(monodir)/mono/sgen/libmonosgen-static.la
-endif
+buildver-sgen.h: libmini.la $(monodir)/mono/metadata/libmonoruntimesgen.la $(monodir)/mono/sgen/libmonosgen.la
@echo "const char *build_date = \"`date`\";" > buildver-sgen.h
mono_sgen-main-sgen.$(OBJEXT): buildver-sgen.h
main-sgen.$(OBJEXT): buildver-sgen.h
monobin_platform_ldflags=-framework CoreFoundation -framework Foundation
endif
+#
+# This library is shared between mono and mono-sgen, since the code in mini/ doesn't contain
+# compile time dependencies on boehm/sgen.
+#
libmini_la_SOURCES = $(common_sources) $(llvm_sources) $(llvm_runtime_sources) $(interp_sources) $(arch_sources) $(os_sources)
libmini_la_CFLAGS = $(mono_CFLAGS)
libmonosgen_2_0_la_LIBADD = libmini.la $(sgen_libs) $(LIBMONO_DTRACE_OBJECT) $(LLVMMONOF)
libmonosgen_2_0_la_LDFLAGS = $(libmonoldflags) $(monobin_platform_ldflags)
-#
-# This library is shared between mono and mono-sgen, since the code in mini/ doesn't contain
-# compile time dependencies on boehm/sgen.
-#
-libmini_static_la_SOURCES = $(libmini_la_SOURCES)
-libmini_static_la_CFLAGS = $(AM_CFLAGS)
-libmini_static_la_LDFLAGS = -static
-libmini_static_la_LIBADD = $(MONO_DTRACE_OBJECT)
-
libmonoincludedir = $(includedir)/mono-$(API_VER)/mono/jit
libmonoinclude_HEADERS = jit.h
}
#endif
-gboolean
-mono_arch_print_tree (MonoInst *tree, int arity)
-{
- return 0;
-}
-
mgreg_t
mono_arch_context_get_int_reg (MonoContext *ctx, int reg)
{
return NULL;
}
-gboolean
-mono_arch_print_tree (MonoInst *tree, int arity)
-{
- return 0;
-}
-
#ifndef DISABLE_JIT
#endif
return NULL;
}
-gboolean
-mono_arch_print_tree (MonoInst *tree, int arity)
-{
- return FALSE;
-}
-
guint32
mono_arch_get_patch_offset (guint8 *code)
{
return NULL;
}
-gboolean
-mono_arch_print_tree (MonoInst *tree, int arity)
-{
- return 0;
-}
-
mgreg_t
mono_arch_context_get_int_reg (MonoContext *ctx, int reg)
{
return NULL;
}
-gboolean
-mono_arch_print_tree (MonoInst *tree, int arity)
-{
- return 0;
-}
-
mgreg_t
mono_arch_context_get_int_reg (MonoContext *ctx, int reg)
{
/*========================= End of Function ========================*/
-/*------------------------------------------------------------------*/
-/* */
-/* Name - mono_arch_print_tree */
-/* */
-/* Function - Print platform-specific opcode details. */
-/* */
-/* Returns - 1 - opcode details have been printed */
-/* 0 - opcode details have not been printed */
-/* */
-/*------------------------------------------------------------------*/
-
-gboolean
-mono_arch_print_tree (MonoInst *tree, int arity)
-{
- gboolean done;
-
- switch (tree->opcode) {
- case OP_S390_LOADARG:
- case OP_S390_ARGREG:
- case OP_S390_ARGPTR:
- printf ("[0x%lx(%s)]", tree->inst_offset,
- mono_arch_regname (tree->inst_basereg));
- done = 1;
- break;
- case OP_S390_STKARG:
- printf ("[0x%lx(previous_frame)]",
- tree->inst_offset);
- done = 1;
- break;
- case OP_S390_MOVE:
- printf ("[0x%lx(%d,%s),0x%lx(%s)]",
- tree->inst_offset, tree->backend.size,
- mono_arch_regname(tree->dreg),
- tree->inst_imm,
- mono_arch_regname(tree->sreg1));
- done = 1;
- break;
- case OP_S390_SETF4RET:
- printf ("[f%s,f%s]",
- mono_arch_regname (tree->dreg),
- mono_arch_regname (tree->sreg1));
- done = 1;
- break;
- case OP_TLS_GET:
- printf ("[0x%lx(0x%lx,%s)]", tree->inst_offset,
- tree->inst_imm,
- mono_arch_regname (tree->sreg1));
- done = 1;
- break;
- case OP_TLS_SET:
- printf ("[0x%lx(0x%lx,%s)]", tree->inst_offset,
- tree->inst_imm,
- mono_arch_regname (tree->sreg1));
- done = 1;
- break;
- case OP_S390_BKCHAIN:
- printf ("[previous_frame(%s)]",
- mono_arch_regname (tree->sreg1));
- done = 1;
- default:
- done = 0;
- }
- return (done);
-}
-
-/*========================= End of Function ========================*/
-
/*------------------------------------------------------------------*/
/* */
/* Name - mono_arch_regalloc_cost */
return 0;
}
-gboolean
-mono_arch_print_tree (MonoInst *tree, int arity)
-{
- return 0;
-}
-
mgreg_t
mono_arch_context_get_int_reg (MonoContext *ctx, int reg)
{
return ins;
}
-gboolean
-mono_arch_print_tree (MonoInst *tree, int arity)
-{
- return 0;
-}
-
guint32
mono_arch_get_patch_offset (guint8 *code)
{
extern int mono_break_at_bb_bb_num;
extern gboolean mono_verify_all;
extern gboolean mono_do_x86_stack_align;
-extern const char *mono_build_date;
+extern MONO_API const char *mono_build_date;
extern gboolean mono_do_signal_chaining;
extern gboolean mono_do_crash_chaining;
extern MONO_API gboolean mono_use_llvm;
void mono_arch_fill_argument_info (MonoCompile *cfg);
void mono_arch_allocate_vars (MonoCompile *m);
int mono_arch_get_argument_info (MonoMethodSignature *csig, int param_count, MonoJitArgumentInfo *arg_info);
-gboolean mono_arch_print_tree (MonoInst *tree, int arity);
void mono_arch_emit_call (MonoCompile *cfg, MonoCallInst *call);
void mono_arch_emit_outarg_vt (MonoCompile *cfg, MonoInst *ins, MonoInst *src);
void mono_arch_emit_setret (MonoCompile *cfg, MonoMethod *method, MonoInst *val);
shared_libraries = libmonosgen.la
endif
endif
-libraries = $(shared_libraries) libmonosgen-static.la
+libraries = $(shared_libraries)
endif
if DISABLE_EXECUTABLES
libmonosgen_la_SOURCES = $(monosgen_sources)
libmonosgen_la_CFLAGS = $(SGEN_DEFINES)
-
-libmonosgen_static_la_SOURCES = $(libmonosgen_la_SOURCES)
-libmonosgen_static_la_CFLAGS = $(SGEN_DEFINES)
-libmonosgen_static_la_LDFLAGS = -static
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
- <ClCompile Include="$(MonoSourceLocation)\eglib\src\garray.c" />
- <ClCompile Include="$(MonoSourceLocation)\eglib\src\gbytearray.c" />
- <ClCompile Include="$(MonoSourceLocation)\eglib\src\gerror.c" />
- <ClCompile Include="$(MonoSourceLocation)\eglib\src\gfile.c" />
- <ClCompile Include="$(MonoSourceLocation)\eglib\src\ghashtable.c" />
- <ClCompile Include="$(MonoSourceLocation)\eglib\src\giconv.c" />
- <ClCompile Include="$(MonoSourceLocation)\eglib\src\glist.c" />
- <ClCompile Include="$(MonoSourceLocation)\eglib\src\gmarkup.c" />
- <ClCompile Include="$(MonoSourceLocation)\eglib\src\gmem.c" />
- <ClCompile Include="$(MonoSourceLocation)\eglib\src\goutput.c" />
- <ClCompile Include="$(MonoSourceLocation)\eglib\src\gpattern.c" />
- <ClCompile Include="$(MonoSourceLocation)\eglib\src\gptrarray.c" />
- <ClCompile Include="$(MonoSourceLocation)\eglib\src\gqsort.c" />
- <ClCompile Include="$(MonoSourceLocation)\eglib\src\gqueue.c" />
- <ClCompile Include="$(MonoSourceLocation)\eglib\src\gshell.c" />
- <ClCompile Include="$(MonoSourceLocation)\eglib\src\gslist.c" />
- <ClCompile Include="$(MonoSourceLocation)\eglib\src\gspawn.c" />
- <ClCompile Include="$(MonoSourceLocation)\eglib\src\gstr.c" />
- <ClCompile Include="$(MonoSourceLocation)\eglib\src\gstring.c" />
- <ClCompile Include="$(MonoSourceLocation)\eglib\src\gunicode.c" />
- <ClCompile Include="$(MonoSourceLocation)\eglib\src\gutf8.c" />
+ <ClCompile Include="$(MonoSourceLocation)\mono\eglib\garray.c" />
+ <ClCompile Include="$(MonoSourceLocation)\mono\eglib\gbytearray.c" />
+ <ClCompile Include="$(MonoSourceLocation)\mono\eglib\gerror.c" />
+ <ClCompile Include="$(MonoSourceLocation)\mono\eglib\gfile.c" />
+ <ClCompile Include="$(MonoSourceLocation)\mono\eglib\ghashtable.c" />
+ <ClCompile Include="$(MonoSourceLocation)\mono\eglib\giconv.c" />
+ <ClCompile Include="$(MonoSourceLocation)\mono\eglib\glist.c" />
+ <ClCompile Include="$(MonoSourceLocation)\mono\eglib\gmarkup.c" />
+ <ClCompile Include="$(MonoSourceLocation)\mono\eglib\gmem.c" />
+ <ClCompile Include="$(MonoSourceLocation)\mono\eglib\goutput.c" />
+ <ClCompile Include="$(MonoSourceLocation)\mono\eglib\gpattern.c" />
+ <ClCompile Include="$(MonoSourceLocation)\mono\eglib\gptrarray.c" />
+ <ClCompile Include="$(MonoSourceLocation)\mono\eglib\gqsort.c" />
+ <ClCompile Include="$(MonoSourceLocation)\mono\eglib\gqueue.c" />
+ <ClCompile Include="$(MonoSourceLocation)\mono\eglib\gshell.c" />
+ <ClCompile Include="$(MonoSourceLocation)\mono\eglib\gslist.c" />
+ <ClCompile Include="$(MonoSourceLocation)\mono\eglib\gspawn.c" />
+ <ClCompile Include="$(MonoSourceLocation)\mono\eglib\gstr.c" />
+ <ClCompile Include="$(MonoSourceLocation)\mono\eglib\gstring.c" />
+ <ClCompile Include="$(MonoSourceLocation)\mono\eglib\gunicode.c" />
+ <ClCompile Include="$(MonoSourceLocation)\mono\eglib\gutf8.c" />
</ItemGroup>
<ItemGroup>
- <ClInclude Include="$(MonoSourceLocation)\eglib\src\glib.h" />
- <ClInclude Include="$(MonoSourceLocation)\eglib\src\gmodule.h" />
- <ClInclude Include="$(MonoSourceLocation)\eglib\src\sort.frag.h" />
+ <ClInclude Include="$(MonoSourceLocation)\mono\eglib\glib.h" />
+ <ClInclude Include="$(MonoSourceLocation)\mono\eglib\gmodule.h" />
+ <ClInclude Include="$(MonoSourceLocation)\mono\eglib\sort.frag.h" />
</ItemGroup>
</Project>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
- <ClCompile Include="$(MonoSourceLocation)\eglib\src\garray.c">
+ <ClCompile Include="$(MonoSourceLocation)\mono\eglib\garray.c">
<Filter>Source Files\Common</Filter>
</ClCompile>
- <ClCompile Include="$(MonoSourceLocation)\eglib\src\gbytearray.c">
+ <ClCompile Include="$(MonoSourceLocation)\mono\eglib\gbytearray.c">
<Filter>Source Files\Common</Filter>
</ClCompile>
- <ClCompile Include="$(MonoSourceLocation)\eglib\src\gfile.c">
+ <ClCompile Include="$(MonoSourceLocation)\mono\eglib\gfile.c">
<Filter>Source Files\Common</Filter>
</ClCompile>
- <ClCompile Include="$(MonoSourceLocation)\eglib\src\gerror.c">
+ <ClCompile Include="$(MonoSourceLocation)\mono\eglib\gerror.c">
<Filter>Source Files\Common</Filter>
</ClCompile>
- <ClCompile Include="$(MonoSourceLocation)\eglib\src\ghashtable.c">
+ <ClCompile Include="$(MonoSourceLocation)\mono\eglib\ghashtable.c">
<Filter>Source Files\Common</Filter>
</ClCompile>
- <ClCompile Include="$(MonoSourceLocation)\eglib\src\giconv.c">
+ <ClCompile Include="$(MonoSourceLocation)\mono\eglib\giconv.c">
<Filter>Source Files\Common</Filter>
</ClCompile>
- <ClCompile Include="$(MonoSourceLocation)\eglib\src\glist.c">
+ <ClCompile Include="$(MonoSourceLocation)\mono\eglib\glist.c">
<Filter>Source Files\Common</Filter>
</ClCompile>
- <ClCompile Include="$(MonoSourceLocation)\eglib\src\gmarkup.c">
+ <ClCompile Include="$(MonoSourceLocation)\mono\eglib\gmarkup.c">
<Filter>Source Files\Common</Filter>
</ClCompile>
- <ClCompile Include="$(MonoSourceLocation)\eglib\src\gmem.c">
+ <ClCompile Include="$(MonoSourceLocation)\mono\eglib\gmem.c">
<Filter>Source Files\Common</Filter>
</ClCompile>
- <ClCompile Include="$(MonoSourceLocation)\eglib\src\goutput.c">
+ <ClCompile Include="$(MonoSourceLocation)\mono\eglib\goutput.c">
<Filter>Source Files\Common</Filter>
</ClCompile>
- <ClCompile Include="$(MonoSourceLocation)\eglib\src\gpattern.c">
+ <ClCompile Include="$(MonoSourceLocation)\mono\eglib\gpattern.c">
<Filter>Source Files\Common</Filter>
</ClCompile>
- <ClCompile Include="$(MonoSourceLocation)\eglib\src\gptrarray.c">
+ <ClCompile Include="$(MonoSourceLocation)\mono\eglib\gptrarray.c">
<Filter>Source Files\Common</Filter>
</ClCompile>
- <ClCompile Include="$(MonoSourceLocation)\eglib\src\gqsort.c">
+ <ClCompile Include="$(MonoSourceLocation)\mono\eglib\gqsort.c">
<Filter>Source Files\Common</Filter>
</ClCompile>
- <ClCompile Include="$(MonoSourceLocation)\eglib\src\gqueue.c">
+ <ClCompile Include="$(MonoSourceLocation)\mono\eglib\gqueue.c">
<Filter>Source Files\Common</Filter>
</ClCompile>
- <ClCompile Include="$(MonoSourceLocation)\eglib\src\gshell.c">
+ <ClCompile Include="$(MonoSourceLocation)\mono\eglib\gshell.c">
<Filter>Source Files\Common</Filter>
</ClCompile>
- <ClCompile Include="$(MonoSourceLocation)\eglib\src\gslist.c">
+ <ClCompile Include="$(MonoSourceLocation)\mono\eglib\gslist.c">
<Filter>Source Files\Common</Filter>
</ClCompile>
- <ClCompile Include="$(MonoSourceLocation)\eglib\src\gspawn.c">
+ <ClCompile Include="$(MonoSourceLocation)\mono\eglib\gspawn.c">
<Filter>Source Files\Common</Filter>
</ClCompile>
- <ClCompile Include="$(MonoSourceLocation)\eglib\src\gstr.c">
+ <ClCompile Include="$(MonoSourceLocation)\mono\eglib\gstr.c">
<Filter>Source Files\Common</Filter>
</ClCompile>
- <ClCompile Include="$(MonoSourceLocation)\eglib\src\gstring.c">
+ <ClCompile Include="$(MonoSourceLocation)\mono\eglib\gstring.c">
<Filter>Source Files\Common</Filter>
</ClCompile>
- <ClCompile Include="$(MonoSourceLocation)\eglib\src\gunicode.c">
+ <ClCompile Include="$(MonoSourceLocation)\mono\eglib\gunicode.c">
<Filter>Source Files\Common</Filter>
</ClCompile>
- <ClCompile Include="$(MonoSourceLocation)\eglib\src\gutf8.c">
+ <ClCompile Include="$(MonoSourceLocation)\mono\eglib\gutf8.c">
<Filter>Source Files\Common</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
- <ClInclude Include="$(MonoSourceLocation)\eglib\src\glib.h">
+ <ClInclude Include="$(MonoSourceLocation)\mono\eglib\glib.h">
<Filter>Header Files\Common</Filter>
</ClInclude>
- <ClInclude Include="$(MonoSourceLocation)\eglib\src\gmodule.h">
+ <ClInclude Include="$(MonoSourceLocation)\mono\eglib\gmodule.h">
<Filter>Header Files\Common</Filter>
</ClInclude>
- <ClInclude Include="$(MonoSourceLocation)\eglib\src\sort.frag.h">
+ <ClInclude Include="$(MonoSourceLocation)\mono\eglib\sort.frag.h">
<Filter>Header Files\Common</Filter>
</ClInclude>
</ItemGroup>
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
- <ClCompile Include="$(MonoSourceLocation)\eglib\src\gfile-posix.c" />
+ <ClCompile Include="$(MonoSourceLocation)\mono\eglib\gfile-posix.c" />
</ItemGroup>
</Project>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
- <ClCompile Include="$(MonoSourceLocation)\eglib\src\gfile-posix.c">
+ <ClCompile Include="$(MonoSourceLocation)\mono\eglib\gfile-posix.c">
<Filter>Source Files\Posix</Filter>
</ClCompile>
</ItemGroup>
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
- <ClCompile Include="$(MonoSourceLocation)\eglib\src\gdate-win32.c" />
- <ClCompile Include="$(MonoSourceLocation)\eglib\src\gdir-win32.c" />
- <ClCompile Include="$(MonoSourceLocation)\eglib\src\gfile-win32.c" />
- <ClCompile Include="$(MonoSourceLocation)\eglib\src\gmisc-win32.c" />
- <ClCompile Include="$(MonoSourceLocation)\eglib\src\gmodule-win32.c" />
- <ClCompile Include="$(MonoSourceLocation)\eglib\src\gpath.c" />
- <ClCompile Include="$(MonoSourceLocation)\eglib\src\gtimer-win32.c" />
- <ClCompile Include="$(MonoSourceLocation)\eglib\src\gunicode-win32.c" />
+ <ClCompile Include="$(MonoSourceLocation)\mono\eglib\gdate-win32.c" />
+ <ClCompile Include="$(MonoSourceLocation)\mono\eglib\gdir-win32.c" />
+ <ClCompile Include="$(MonoSourceLocation)\mono\eglib\gfile-win32.c" />
+ <ClCompile Include="$(MonoSourceLocation)\mono\eglib\gmisc-win32.c" />
+ <ClCompile Include="$(MonoSourceLocation)\mono\eglib\gmodule-win32.c" />
+ <ClCompile Include="$(MonoSourceLocation)\mono\eglib\gpath.c" />
+ <ClCompile Include="$(MonoSourceLocation)\mono\eglib\gtimer-win32.c" />
+ <ClCompile Include="$(MonoSourceLocation)\mono\eglib\gunicode-win32.c" />
</ItemGroup>
<ItemGroup>
- <ClInclude Include="$(MonoSourceLocation)\eglib\src\gmodule-win32-internals.h" />
+ <ClInclude Include="$(MonoSourceLocation)\mono\eglib\gmodule-win32-internals.h" />
</ItemGroup>
</Project>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
- <ClCompile Include="$(MonoSourceLocation)\eglib\src\gdate-win32.c">
+ <ClCompile Include="$(MonoSourceLocation)\mono\eglib\gdate-win32.c">
<Filter>Source Files\Win32</Filter>
</ClCompile>
- <ClCompile Include="$(MonoSourceLocation)\eglib\src\gdir-win32.c">
+ <ClCompile Include="$(MonoSourceLocation)\mono\eglib\gdir-win32.c">
<Filter>Source Files\Win32</Filter>
</ClCompile>
- <ClCompile Include="$(MonoSourceLocation)\eglib\src\gfile-win32.c">
+ <ClCompile Include="$(MonoSourceLocation)\mono\eglib\gfile-win32.c">
<Filter>Source Files\Win32</Filter>
</ClCompile>
- <ClCompile Include="$(MonoSourceLocation)\eglib\src\gmisc-win32.c">
+ <ClCompile Include="$(MonoSourceLocation)\mono\eglib\gmisc-win32.c">
<Filter>Source Files\Win32</Filter>
</ClCompile>
- <ClCompile Include="$(MonoSourceLocation)\eglib\src\gmodule-win32.c">
+ <ClCompile Include="$(MonoSourceLocation)\mono\eglib\gmodule-win32.c">
<Filter>Source Files\Win32</Filter>
</ClCompile>
- <ClCompile Include="$(MonoSourceLocation)\eglib\src\gpath.c">
+ <ClCompile Include="$(MonoSourceLocation)\mono\eglib\gpath.c">
<Filter>Source Files\Win32</Filter>
</ClCompile>
- <ClCompile Include="$(MonoSourceLocation)\eglib\src\gtimer-win32.c">
+ <ClCompile Include="$(MonoSourceLocation)\mono\eglib\gtimer-win32.c">
<Filter>Source Files\Win32</Filter>
</ClCompile>
- <ClCompile Include="$(MonoSourceLocation)\eglib\src\gunicode-win32.c">
+ <ClCompile Include="$(MonoSourceLocation)\mono\eglib\gunicode-win32.c">
<Filter>Source Files\Win32</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
- <ClInclude Include="$(MonoSourceLocation)\eglib\src\gmodule-win32-internals.h">
+ <ClInclude Include="$(MonoSourceLocation)\mono\eglib\gmodule-win32-internals.h">
<Filter>Header Files\Win32</Filter>
</ClInclude>
</ItemGroup>
-<?xml version="1.0" encoding="utf-8"?>\r
+<?xml version="1.0" encoding="utf-8"?>\r
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\r
<ItemGroup Label="ProjectConfigurations">\r
<ProjectConfiguration Include="Debug|Win32">\r
</PreBuildEvent>\r
<ClCompile>\r
<Optimization>Disabled</Optimization>\r
- <AdditionalIncludeDirectories>$(MONO_EGLIB_SOURCE_DIR);$(MONO_EGLIB_INCLUDE_DIR);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r
+ <AdditionalIncludeDirectories>$(MONO_DIR);$(MONO_EGLIB_SOURCE_DIR);$(MONO_EGLIB_INCLUDE_DIR);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r
<MinimalRebuild>true</MinimalRebuild>\r
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>\r
<PrecompiledHeader>\r
</PreBuildEvent>\r
<ClCompile>\r
<Optimization>MinSpace</Optimization>\r
- <AdditionalIncludeDirectories>$(MONO_EGLIB_SOURCE_DIR);$(MONO_EGLIB_INCLUDE_DIR);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r
+ <AdditionalIncludeDirectories>$(MONO_DIR);$(MONO_EGLIB_SOURCE_DIR);$(MONO_EGLIB_INCLUDE_DIR);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r
<PrecompiledHeader>\r
</PrecompiledHeader>\r
<WarningLevel>Level4</WarningLevel>\r
</Midl>\r
<ClCompile>\r
<Optimization>Disabled</Optimization>\r
- <AdditionalIncludeDirectories>$(MONO_EGLIB_SOURCE_DIR);$(MONO_EGLIB_INCLUDE_DIR);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r
+ <AdditionalIncludeDirectories>$(MONO_DIR);$(MONO_EGLIB_SOURCE_DIR);$(MONO_EGLIB_INCLUDE_DIR);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r
<MinimalRebuild>true</MinimalRebuild>\r
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>\r
<PrecompiledHeader>\r
</Midl>\r
<ClCompile>\r
<Optimization>MinSpace</Optimization>\r
- <AdditionalIncludeDirectories>$(MONO_EGLIB_SOURCE_DIR);$(MONO_EGLIB_INCLUDE_DIR);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r
+ <AdditionalIncludeDirectories>$(MONO_DIR);$(MONO_EGLIB_SOURCE_DIR);$(MONO_EGLIB_INCLUDE_DIR);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r
<PrecompiledHeader>\r
</PrecompiledHeader>\r
<WarningLevel>Level4</WarningLevel>\r
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Label="UserMacros">
<!-- Change this to custom build tree location to enable out of source tree builds, example c:/mono-build/ -->
<top_srcdir>$(MSBuildProjectDirectory)/$(MonoSourceLocation)</top_srcdir>
<MONO_DIR>$(top_srcdir)</MONO_DIR>
<MONO_INCLUDE_DIR>$(MONO_DIR)/mono</MONO_INCLUDE_DIR>
- <MONO_EGLIB_INCLUDE_DIR>$(MONO_DIR)/eglib;$(MONO_DIR)/eglib/include;$(MONO_DIR)/eglib/test</MONO_EGLIB_INCLUDE_DIR>
- <MONO_EGLIB_SOURCE_DIR>$(MONO_DIR)/eglib/src</MONO_EGLIB_SOURCE_DIR>
+ <MONO_EGLIB_INCLUDE_DIR>$(MONO_DIR)/mono/eglib</MONO_EGLIB_INCLUDE_DIR>
+ <MONO_EGLIB_SOURCE_DIR>$(MONO_DIR)/mono/eglib</MONO_EGLIB_SOURCE_DIR>
<MONO_LIBGC_INCLUDE_DIR>$(MONO_DIR)/libgc/include</MONO_LIBGC_INCLUDE_DIR>
<MONO_LIBGC_SOURCE_DIR>$(MONO_DIR)/libgc/src</MONO_LIBGC_SOURCE_DIR>
<MONO_JIT_INCLUDE_DIR>$(MONO_INCLUDE_DIR)/jit</MONO_JIT_INCLUDE_DIR>
-<?xml version="1.0" encoding="utf-8"?>\r
+<?xml version="1.0" encoding="utf-8"?>\r
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\r
<ItemGroup Label="ProjectConfigurations">\r
<ProjectConfiguration Include="Debug|Win32">\r
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
<ClCompile>\r
<Optimization>Disabled</Optimization>\r
- <AdditionalIncludeDirectories>$(MONO_EGLIB_INCLUDE_DIR);$(MONO_EGLIB_SOURCE_DIR)%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r
+ <AdditionalIncludeDirectories>$(MONO_DIR);$(MONO_EGLIB_INCLUDE_DIR);$(MONO_EGLIB_SOURCE_DIR)%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBTEST_EGLIB_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
<MinimalRebuild>true</MinimalRebuild>\r
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>\r
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
<ClCompile>\r
<Optimization>MinSpace</Optimization>\r
- <AdditionalIncludeDirectories>$(MONO_EGLIB_INCLUDE_DIR);$(MONO_EGLIB_SOURCE_DIR)%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r
+ <AdditionalIncludeDirectories>$(MONO_DIR);$(MONO_EGLIB_INCLUDE_DIR);$(MONO_EGLIB_SOURCE_DIR)%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBTEST_EGLIB_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
<PrecompiledHeader>\r
</PrecompiledHeader>\r
</Midl>\r
<ClCompile>\r
<Optimization>Disabled</Optimization>\r
- <AdditionalIncludeDirectories>$(MONO_EGLIB_INCLUDE_DIR);$(MONO_EGLIB_SOURCE_DIR)%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r
+ <AdditionalIncludeDirectories>$(MONO_DIR);$(MONO_EGLIB_INCLUDE_DIR);$(MONO_EGLIB_SOURCE_DIR)%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBTEST_EGLIB_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
<MinimalRebuild>true</MinimalRebuild>\r
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>\r
</Midl>\r
<ClCompile>\r
<Optimization>MinSpace</Optimization>\r
- <AdditionalIncludeDirectories>$(MONO_EGLIB_INCLUDE_DIR);$(MONO_EGLIB_SOURCE_DIR)%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r
+ <AdditionalIncludeDirectories>$(MONO_DIR);$(MONO_EGLIB_INCLUDE_DIR);$(MONO_EGLIB_SOURCE_DIR)%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBTEST_EGLIB_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
<PrecompiledHeader>\r
</PrecompiledHeader>\r
</Link>\r
</ItemDefinitionGroup>\r
<ItemGroup>\r
- <ClCompile Include="..\eglib\test\array.c" />\r
- <ClCompile Include="..\eglib\test\dir.c" />\r
- <ClCompile Include="..\eglib\test\driver.c" />\r
- <ClCompile Include="..\eglib\test\endian.c" />\r
- <ClCompile Include="..\eglib\test\fake.c" />\r
- <ClCompile Include="..\eglib\test\file.c" />\r
+ <ClCompile Include="..\mono\eglib\test\array.c" />\r
+ <ClCompile Include="..\mono\eglib\test\dir.c" />\r
+ <ClCompile Include="..\mono\eglib\test\driver.c" />\r
+ <ClCompile Include="..\mono\eglib\test\endian.c" />\r
+ <ClCompile Include="..\mono\eglib\test\fake.c" />\r
+ <ClCompile Include="..\mono\eglib\test\file.c" />\r
<ClCompile Include="getopt.c" />\r
<ClCompile Include="getopt_long.c" />\r
- <ClCompile Include="..\eglib\test\hashtable.c" />\r
- <ClCompile Include="..\eglib\test\list.c" />\r
- <ClCompile Include="..\eglib\test\markup.c" />\r
- <ClCompile Include="..\eglib\test\memory.c" />\r
- <ClCompile Include="..\eglib\test\module.c" />\r
- <ClCompile Include="..\eglib\test\path.c" />\r
- <ClCompile Include="..\eglib\test\pattern.c" />\r
- <ClCompile Include="..\eglib\test\ptrarray.c" />\r
- <ClCompile Include="..\eglib\test\queue.c" />\r
- <ClCompile Include="..\eglib\test\shell.c" />\r
- <ClCompile Include="..\eglib\test\sizes.c" />\r
- <ClCompile Include="..\eglib\test\slist.c" />\r
- <ClCompile Include="..\eglib\test\spawn.c" />\r
- <ClCompile Include="..\eglib\test\string-util.c" />\r
- <ClCompile Include="..\eglib\test\string.c" />\r
- <ClCompile Include="..\eglib\test\test.c" />\r
- <ClCompile Include="..\eglib\test\timer.c" />\r
- <ClCompile Include="..\eglib\test\unicode.c" />\r
- <ClCompile Include="..\eglib\test\utf8.c" />\r
+ <ClCompile Include="..\mono\eglib\test\hashtable.c" />\r
+ <ClCompile Include="..\mono\eglib\test\list.c" />\r
+ <ClCompile Include="..\mono\eglib\test\markup.c" />\r
+ <ClCompile Include="..\mono\eglib\test\memory.c" />\r
+ <ClCompile Include="..\mono\eglib\test\module.c" />\r
+ <ClCompile Include="..\mono\eglib\test\path.c" />\r
+ <ClCompile Include="..\mono\eglib\test\pattern.c" />\r
+ <ClCompile Include="..\mono\eglib\test\ptrarray.c" />\r
+ <ClCompile Include="..\mono\eglib\test\queue.c" />\r
+ <ClCompile Include="..\mono\eglib\test\shell.c" />\r
+ <ClCompile Include="..\mono\eglib\test\sizes.c" />\r
+ <ClCompile Include="..\mono\eglib\test\slist.c" />\r
+ <ClCompile Include="..\mono\eglib\test\spawn.c" />\r
+ <ClCompile Include="..\mono\eglib\test\string-util.c" />\r
+ <ClCompile Include="..\mono\eglib\test\string.c" />\r
+ <ClCompile Include="..\mono\eglib\test\test.c" />\r
+ <ClCompile Include="..\mono\eglib\test\timer.c" />\r
+ <ClCompile Include="..\mono\eglib\test\unicode.c" />\r
+ <ClCompile Include="..\mono\eglib\test\utf8.c" />\r
</ItemGroup>\r
<ItemGroup>\r
<ClInclude Include="getopt.h" />\r
<ClInclude Include="getopt_long.h" />\r
- <ClInclude Include="..\eglib\src\glib.h" />\r
- <ClInclude Include="..\eglib\test\test.h" />\r
- <ClInclude Include="..\eglib\test\tests.h" />\r
+ <ClInclude Include="..\mono\eglib\src\glib.h" />\r
+ <ClInclude Include="..\mono\eglib\test\test.h" />\r
+ <ClInclude Include="..\mono\eglib\test\tests.h" />\r
</ItemGroup>\r
<ItemGroup>\r
<ProjectReference Include="eglib.vcxproj">\r
-<?xml version="1.0" encoding="utf-8"?>\r
+<?xml version="1.0" encoding="utf-8"?>\r
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\r
<ItemGroup>\r
- <ClCompile Include="..\eglib\test\array.c">\r
+ <ClCompile Include="..\mono\eglib\test\array.c">\r
<Filter>Source Files</Filter>\r
</ClCompile>\r
- <ClCompile Include="..\eglib\test\dir.c">\r
+ <ClCompile Include="..\mono\eglib\test\dir.c">\r
<Filter>Source Files</Filter>\r
</ClCompile>\r
- <ClCompile Include="..\eglib\test\driver.c">\r
+ <ClCompile Include="..\mono\eglib\test\driver.c">\r
<Filter>Source Files</Filter>\r
</ClCompile>\r
- <ClCompile Include="..\eglib\test\endian.c">\r
+ <ClCompile Include="..\mono\eglib\test\endian.c">\r
<Filter>Source Files</Filter>\r
</ClCompile>\r
- <ClCompile Include="..\eglib\test\fake.c">\r
+ <ClCompile Include="..\mono\eglib\test\fake.c">\r
<Filter>Source Files</Filter>\r
</ClCompile>\r
- <ClCompile Include="..\eglib\test\file.c">\r
+ <ClCompile Include="..\mono\eglib\test\file.c">\r
<Filter>Source Files</Filter>\r
</ClCompile>\r
<ClCompile Include="getopt.c">\r
<ClCompile Include="getopt_long.c">\r
<Filter>Source Files</Filter>\r
</ClCompile>\r
- <ClCompile Include="..\eglib\test\hashtable.c">\r
+ <ClCompile Include="..\mono\eglib\test\hashtable.c">\r
<Filter>Source Files</Filter>\r
</ClCompile>\r
- <ClCompile Include="..\eglib\test\list.c">\r
+ <ClCompile Include="..\mono\eglib\test\list.c">\r
<Filter>Source Files</Filter>\r
</ClCompile>\r
- <ClCompile Include="..\eglib\test\markup.c">\r
+ <ClCompile Include="..\mono\eglib\test\markup.c">\r
<Filter>Source Files</Filter>\r
</ClCompile>\r
- <ClCompile Include="..\eglib\test\memory.c">\r
+ <ClCompile Include="..\mono\eglib\test\memory.c">\r
<Filter>Source Files</Filter>\r
</ClCompile>\r
- <ClCompile Include="..\eglib\test\module.c">\r
+ <ClCompile Include="..\mono\eglib\test\module.c">\r
<Filter>Source Files</Filter>\r
</ClCompile>\r
- <ClCompile Include="..\eglib\test\path.c">\r
+ <ClCompile Include="..\mono\eglib\test\path.c">\r
<Filter>Source Files</Filter>\r
</ClCompile>\r
- <ClCompile Include="..\eglib\test\pattern.c">\r
+ <ClCompile Include="..\mono\eglib\test\pattern.c">\r
<Filter>Source Files</Filter>\r
</ClCompile>\r
- <ClCompile Include="..\eglib\test\ptrarray.c">\r
+ <ClCompile Include="..\mono\eglib\test\ptrarray.c">\r
<Filter>Source Files</Filter>\r
</ClCompile>\r
- <ClCompile Include="..\eglib\test\queue.c">\r
+ <ClCompile Include="..\mono\eglib\test\queue.c">\r
<Filter>Source Files</Filter>\r
</ClCompile>\r
- <ClCompile Include="..\eglib\test\shell.c">\r
+ <ClCompile Include="..\mono\eglib\test\shell.c">\r
<Filter>Source Files</Filter>\r
</ClCompile>\r
- <ClCompile Include="..\eglib\test\sizes.c">\r
+ <ClCompile Include="..\mono\eglib\test\sizes.c">\r
<Filter>Source Files</Filter>\r
</ClCompile>\r
- <ClCompile Include="..\eglib\test\slist.c">\r
+ <ClCompile Include="..\mono\eglib\test\slist.c">\r
<Filter>Source Files</Filter>\r
</ClCompile>\r
- <ClCompile Include="..\eglib\test\spawn.c">\r
+ <ClCompile Include="..\mono\eglib\test\spawn.c">\r
<Filter>Source Files</Filter>\r
</ClCompile>\r
- <ClCompile Include="..\eglib\test\string.c">\r
+ <ClCompile Include="..\mono\eglib\test\string.c">\r
<Filter>Source Files</Filter>\r
</ClCompile>\r
- <ClCompile Include="..\eglib\test\string-util.c">\r
+ <ClCompile Include="..\mono\eglib\test\string-util.c">\r
<Filter>Source Files</Filter>\r
</ClCompile>\r
- <ClCompile Include="..\eglib\test\test.c">\r
+ <ClCompile Include="..\mono\eglib\test\test.c">\r
<Filter>Source Files</Filter>\r
</ClCompile>\r
- <ClCompile Include="..\eglib\test\utf8.c">\r
+ <ClCompile Include="..\mono\eglib\test\utf8.c">\r
<Filter>Source Files</Filter>\r
</ClCompile>\r
- <ClCompile Include="..\eglib\test\timer.c">\r
+ <ClCompile Include="..\mono\eglib\test\timer.c">\r
<Filter>Source Files</Filter>\r
</ClCompile>\r
- <ClCompile Include="..\eglib\test\unicode.c">\r
+ <ClCompile Include="..\mono\eglib\test\unicode.c">\r
<Filter>Source Files</Filter>\r
</ClCompile>\r
</ItemGroup>\r
<ClInclude Include="getopt_long.h">\r
<Filter>Header Files</Filter>\r
</ClInclude>\r
- <ClInclude Include="..\eglib\src\glib.h">\r
+ <ClInclude Include="..\mono\eglib\src\glib.h">\r
<Filter>Header Files</Filter>\r
</ClInclude>\r
- <ClInclude Include="..\eglib\test\test.h">\r
+ <ClInclude Include="..\mono\eglib\test\test.h">\r
<Filter>Header Files</Filter>\r
</ClInclude>\r
- <ClInclude Include="..\eglib\test\tests.h">\r
+ <ClInclude Include="..\mono\eglib\test\tests.h">\r
<Filter>Header Files</Filter>\r
</ClInclude>\r
</ItemGroup>\r
@ECHO off
SET CONFIG_H=..\config.h
-SET EGLIB_CONFIG_H=..\eglib\config.h
SET CYG_CONFIG_H=..\cygconfig.h
-SET EGLIB_CYG_CONFIG_H=..\eglib\cygconfig.h
SET WIN_CONFIG_H=..\winconfig.h
-SET EGLIB_WIN_CONFIG_H=..\eglib\winconfig.h
SET CONFIGURE_AC=..\configure.ac
SET VERSION_H=..\mono\mini\version.h
REM Backup existing config.h into cygconfig.h if its not already replaced.
%windir%\system32\WindowsPowerShell\v1.0\powershell.exe -executionpolicy bypass -NonInteractive -File backup-config-files.ps1 %CONFIG_H% %CYG_CONFIG_H% 2>&1
-%windir%\system32\WindowsPowerShell\v1.0\powershell.exe -executionpolicy bypass -NonInteractive -File backup-config-files.ps1 %EGLIB_CONFIG_H% %EGLIB_CYG_CONFIG_H% 2>&1
%windir%\system32\WindowsPowerShell\v1.0\powershell.exe -executionpolicy bypass -NonInteractive -File compare-config-files.ps1 %WIN_CONFIG_H% %CONFIG_H% %CONFIGURE_AC% 2>&1
%windir%\system32\WindowsPowerShell\v1.0\powershell.exe -NonInteractive -Command "$mono_version=[int[]](Select-String -path %CONFIGURE_AC% -pattern 'AC_INIT\(mono, \[(.*)\]').Matches[0].Groups[1].Value.Split('.'); $corlib_counter=[int](Select-String -path %CONFIGURE_AC% -pattern 'MONO_CORLIB_COUNTER=(.*)').Matches[0].Groups[1].Value; (Get-Content %CONFIG_H%) -replace '#MONO_CORLIB_VERSION#',('1{0:00}{1:00}{2:00}{3:000}' -f $mono_version[0],$mono_version[1],$mono_version[2],$corlib_counter) | Set-Content %CONFIG_H%" 2>&1
)
-%windir%\system32\WindowsPowerShell\v1.0\powershell.exe -executionpolicy bypass -NonInteractive -File compare-config-files.ps1 %EGLIB_WIN_CONFIG_H% %EGLIB_CONFIG_H% 2>&1
-
-IF NOT %ERRORLEVEL% == 0 (
- ECHO copy %EGLIB_WIN_CONFIG_H% %EGLIB_CONFIG_H%
- copy %EGLIB_WIN_CONFIG_H% %EGLIB_CONFIG_H%
-)
-
SET VERSION_CONTENT="#define FULL_VERSION \"Visual Studio built mono\""
%windir%\system32\WindowsPowerShell\v1.0\powershell.exe -executionpolicy bypass -NonInteractive -File compare-config-content.ps1 %VERSION_CONTENT% %VERSION_H% 2>&1
runtime_lib=$(top_builddir)/mono/mini/$(LIBMONO_LA) $(static_libs)
else
static_libs= \
- $(top_builddir)/mono/metadata/libmonoruntimesgen-static.la \
+ $(top_builddir)/mono/metadata/libmonoruntimesgen.la \
$(top_builddir)/mono/utils/libmonoutils.la \
$(GLIB_LIBS) $(LIBICONV) \
$(LIBGC_STATIC_LIBS)
var includeDirs = new[]
{
targetBuild,
- Path.Combine(targetBuild, "eglib", "src"),
+ Path.Combine(targetBuild, "mono", "eglib"),
MonoDir,
Path.Combine(MonoDir, "mono"),
Path.Combine(MonoDir, "mono", "mini"),
- Path.Combine(MonoDir, "eglib", "src")
+ Path.Combine(MonoDir, "mono", "eglib")
};
foreach (var inc in includeDirs)
pedump.c
pedump_LDADD = \
- $(top_builddir)/mono/metadata/libmonoruntimesgen-static.la \
- $(top_builddir)/mono/sgen/libmonosgen-static.la \
+ $(top_builddir)/mono/metadata/libmonoruntimesgen.la \
+ $(top_builddir)/mono/sgen/libmonosgen.la \
$(top_builddir)/mono/utils/libmonoutils.la \
$(LLVM_LIBS) \
$(LLVM_LDFLAGS) \
-/* config.h. Generated from config.h.in by configure. */
-/* config.h.in. Generated from configure.ac by autoheader. */
-
#ifndef _MSC_VER
#include "cygconfig.h"
#else
/* Define to 1 if you have IPv6 support. */
#define HAVE_STRUCT_SOCKADDR_IN6 1
+/* Defined as strtok_s in eglib-config.hw */
+#define HAVE_STRTOK_R 1
+
/* Have a working sigaltstack */
/* #undef HAVE_WORKING_SIGALTSTACK */