You've already forked linux-packaging-mono
Imported Upstream version 5.8.0.22
Former-commit-id: df344e34b07851d296efb3e6604c8db42b6f7aa3
This commit is contained in:
parent
5f4a27cc8a
commit
7d05485754
65
mono/eglib/Makefile.am
Normal file
65
mono/eglib/Makefile.am
Normal file
@@ -0,0 +1,65 @@
|
||||
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 HOST_ANDROID
|
||||
libeglib_la_LIBADD = -llog
|
||||
endif
|
||||
endif
|
||||
|
||||
MAINTAINERCLEANFILES = Makefile.in
|
||||
|
||||
EXTRA_DIST = eglib-config.h.in $(win_files) $(unix_files)
|
||||
1068
mono/eglib/Makefile.in
Normal file
1068
mono/eglib/Makefile.in
Normal file
File diff suppressed because it is too large
Load Diff
47
mono/eglib/eglib-config.h.in
Normal file
47
mono/eglib/eglib-config.h.in
Normal file
@@ -0,0 +1,47 @@
|
||||
#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
|
||||
|
||||
#if defined (HOST_WASM)
|
||||
#undef G_BREAKPOINT
|
||||
#define G_BREAKPOINT() do { printf ("MONO: BREAKPOINT\n"); abort (); } while (0)
|
||||
#endif
|
||||
|
||||
typedef @PIDTYPE@ GPid;
|
||||
|
||||
#endif
|
||||
63
mono/eglib/eglib-config.hw
Normal file
63
mono/eglib/eglib-config.hw
Normal file
@@ -0,0 +1,63 @@
|
||||
#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
|
||||
288
mono/eglib/eglib-remap.h
Normal file
288
mono/eglib/eglib-remap.h
Normal file
@@ -0,0 +1,288 @@
|
||||
#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
|
||||
238
mono/eglib/garray.c
Normal file
238
mono/eglib/garray.c
Normal file
@@ -0,0 +1,238 @@
|
||||
/*
|
||||
* 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;
|
||||
}
|
||||
58
mono/eglib/gbytearray.c
Normal file
58
mono/eglib/gbytearray.c
Normal file
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* 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);
|
||||
}
|
||||
|
||||
55
mono/eglib/gdate-unix.c
Normal file
55
mono/eglib/gdate-unix.c
Normal file
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* 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;
|
||||
}
|
||||
49
mono/eglib/gdate-win32.c
Normal file
49
mono/eglib/gdate-win32.c
Normal file
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* 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);
|
||||
}
|
||||
146
mono/eglib/gdir-unix.c
Normal file
146
mono/eglib/gdir-unix.c
Normal file
@@ -0,0 +1,146 @@
|
||||
/*
|
||||
* 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;
|
||||
}
|
||||
141
mono/eglib/gdir-win32.c
Normal file
141
mono/eglib/gdir-win32.c
Normal file
@@ -0,0 +1,141 @@
|
||||
/*
|
||||
* 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);
|
||||
}
|
||||
|
||||
|
||||
103
mono/eglib/gerror.c
Normal file
103
mono/eglib/gerror.c
Normal file
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
* 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;
|
||||
}
|
||||
}
|
||||
175
mono/eglib/gfile-posix.c
Normal file
175
mono/eglib/gfile-posix.c
Normal file
@@ -0,0 +1,175 @@
|
||||
/*
|
||||
* 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;
|
||||
}
|
||||
92
mono/eglib/gfile-unix.c
Normal file
92
mono/eglib/gfile-unix.c
Normal file
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
* 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 mkdtemp not supported");
|
||||
#endif
|
||||
}
|
||||
141
mono/eglib/gfile-win32.c
Normal file
141
mono/eglib/gfile-win32.c
Normal file
@@ -0,0 +1,141 @@
|
||||
/*
|
||||
* 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;
|
||||
}
|
||||
157
mono/eglib/gfile.c
Normal file
157
mono/eglib/gfile.c
Normal file
@@ -0,0 +1,157 @@
|
||||
/*
|
||||
* 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;
|
||||
}
|
||||
671
mono/eglib/ghashtable.c
Normal file
671
mono/eglib/ghashtable.c
Normal file
File diff suppressed because it is too large
Load Diff
1340
mono/eglib/giconv.c
Normal file
1340
mono/eglib/giconv.c
Normal file
File diff suppressed because it is too large
Load Diff
1079
mono/eglib/glib.h
Normal file
1079
mono/eglib/glib.h
Normal file
File diff suppressed because it is too large
Load Diff
345
mono/eglib/glist.c
Normal file
345
mono/eglib/glist.c
Normal file
@@ -0,0 +1,345 @@
|
||||
/*
|
||||
* 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;
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user