diff --git a/ChangeLog b/ChangeLog index 833af1e0a..ecc5c9c92 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2001-07-21 Hans Breuer + + * glib/giowin32.c : intial implementation of new API functions. + Not sure if it behaves as intended ... + + * glib.def : removed, glib/glib.def is the file used since moved + * glib/glib.def : updated + + * tests/makefile.msc : added iochannel-test + Fri Jul 20 19:19:10 (UTC) 2001 Ron Steinke * glib/giochannel.c: API changes, fixes to diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index 833af1e0a..ecc5c9c92 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,13 @@ +2001-07-21 Hans Breuer + + * glib/giowin32.c : intial implementation of new API functions. + Not sure if it behaves as intended ... + + * glib.def : removed, glib/glib.def is the file used since moved + * glib/glib.def : updated + + * tests/makefile.msc : added iochannel-test + Fri Jul 20 19:19:10 (UTC) 2001 Ron Steinke * glib/giochannel.c: API changes, fixes to diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 833af1e0a..ecc5c9c92 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,13 @@ +2001-07-21 Hans Breuer + + * glib/giowin32.c : intial implementation of new API functions. + Not sure if it behaves as intended ... + + * glib.def : removed, glib/glib.def is the file used since moved + * glib/glib.def : updated + + * tests/makefile.msc : added iochannel-test + Fri Jul 20 19:19:10 (UTC) 2001 Ron Steinke * glib/giochannel.c: API changes, fixes to diff --git a/ChangeLog.pre-2-12 b/ChangeLog.pre-2-12 index 833af1e0a..ecc5c9c92 100644 --- a/ChangeLog.pre-2-12 +++ b/ChangeLog.pre-2-12 @@ -1,3 +1,13 @@ +2001-07-21 Hans Breuer + + * glib/giowin32.c : intial implementation of new API functions. + Not sure if it behaves as intended ... + + * glib.def : removed, glib/glib.def is the file used since moved + * glib/glib.def : updated + + * tests/makefile.msc : added iochannel-test + Fri Jul 20 19:19:10 (UTC) 2001 Ron Steinke * glib/giochannel.c: API changes, fixes to diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index 833af1e0a..ecc5c9c92 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,13 @@ +2001-07-21 Hans Breuer + + * glib/giowin32.c : intial implementation of new API functions. + Not sure if it behaves as intended ... + + * glib.def : removed, glib/glib.def is the file used since moved + * glib/glib.def : updated + + * tests/makefile.msc : added iochannel-test + Fri Jul 20 19:19:10 (UTC) 2001 Ron Steinke * glib/giochannel.c: API changes, fixes to diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 833af1e0a..ecc5c9c92 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,13 @@ +2001-07-21 Hans Breuer + + * glib/giowin32.c : intial implementation of new API functions. + Not sure if it behaves as intended ... + + * glib.def : removed, glib/glib.def is the file used since moved + * glib/glib.def : updated + + * tests/makefile.msc : added iochannel-test + Fri Jul 20 19:19:10 (UTC) 2001 Ron Steinke * glib/giochannel.c: API changes, fixes to diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 833af1e0a..ecc5c9c92 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,13 @@ +2001-07-21 Hans Breuer + + * glib/giowin32.c : intial implementation of new API functions. + Not sure if it behaves as intended ... + + * glib.def : removed, glib/glib.def is the file used since moved + * glib/glib.def : updated + + * tests/makefile.msc : added iochannel-test + Fri Jul 20 19:19:10 (UTC) 2001 Ron Steinke * glib/giochannel.c: API changes, fixes to diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 833af1e0a..ecc5c9c92 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,13 @@ +2001-07-21 Hans Breuer + + * glib/giowin32.c : intial implementation of new API functions. + Not sure if it behaves as intended ... + + * glib.def : removed, glib/glib.def is the file used since moved + * glib/glib.def : updated + + * tests/makefile.msc : added iochannel-test + Fri Jul 20 19:19:10 (UTC) 2001 Ron Steinke * glib/giochannel.c: API changes, fixes to diff --git a/glib.def b/glib.def deleted file mode 100644 index e297349ad..000000000 --- a/glib.def +++ /dev/null @@ -1,660 +0,0 @@ -EXPORTS - g_allocator_free - g_allocator_new - g_array_append_vals - g_array_free - g_array_insert_vals - g_array_new - g_array_prepend_vals - g_array_remove_index - g_array_remove_index_fast - g_array_set_size - g_array_sized_new - g_array_sort - g_array_sort_with_data - g_async_queue_length - g_async_queue_length_unlocked - g_async_queue_lock - g_async_queue_new - g_async_queue_pop - g_async_queue_pop_unlocked - g_async_queue_push - g_async_queue_push_unlocked - g_async_queue_ref - g_async_queue_ref_unlocked - g_async_queue_timed_pop - g_async_queue_timed_pop_unlocked - g_async_queue_try_pop - g_async_queue_try_pop_unlocked - g_async_queue_unlock - g_async_queue_unref - g_async_queue_unref_and_unlock - g_atexit - g_basename - g_bit_nth_lsf - g_bit_nth_msf - g_bit_storage - g_blow_chunks - g_byte_array_append - g_byte_array_free - g_byte_array_new - g_byte_array_prepend - g_byte_array_remove_index - g_byte_array_remove_index_fast - g_byte_array_set_size - g_byte_array_sized_new - g_byte_array_sort - g_byte_array_sort_with_data - g_cache_destroy - g_cache_insert - g_cache_key_foreach - g_cache_new - g_cache_remove - g_cache_value_foreach - g_clear_error - g_completion_add_items - g_completion_clear_items - g_completion_complete - g_completion_free - g_completion_new - g_completion_remove_items - g_convert - g_convert_error_quark - g_convert_with_fallback - g_datalist_clear - g_datalist_foreach - g_datalist_id_get_data - g_datalist_id_remove_no_notify - g_datalist_id_set_data_full - g_datalist_init - g_dataset_destroy - g_dataset_foreach - g_dataset_id_get_data - g_dataset_id_remove_no_notify - g_dataset_id_set_data_full - g_date_add_days - g_date_add_months - g_date_add_years - g_date_clear - g_date_compare - g_date_free - g_date_get_day - g_date_get_day_of_year - g_date_get_days_in_month - g_date_get_julian - g_date_get_monday_week_of_year - g_date_get_monday_weeks_in_year - g_date_get_month - g_date_get_sunday_week_of_year - g_date_get_sunday_weeks_in_year - g_date_get_weekday - g_date_get_year - g_date_is_first_of_month - g_date_is_last_of_month - g_date_is_leap_year - g_date_new - g_date_new_dmy - g_date_new_julian - g_date_set_day - g_date_set_dmy - g_date_set_julian - g_date_set_month - g_date_set_parse - g_date_set_time - g_date_set_year - g_date_strftime - g_date_subtract_days - g_date_subtract_months - g_date_subtract_years - g_date_to_struct_tm - g_date_valid - g_date_valid_day - g_date_valid_dmy - g_date_valid_julian - g_date_valid_month - g_date_valid_weekday - g_date_valid_year - g_direct_equal - g_direct_hash - g_error_copy - g_error_free - g_error_matches - g_error_new - g_error_new_literal - g_file_error_from_errno - g_file_error_quark - g_file_get_contents - g_file_open_tmp - g_file_test - g_filename_from_utf8 - g_filename_to_utf8 - g_find_program_in_path - g_free - g_get_charset - g_get_codeset - g_get_current_dir - g_get_current_time - g_get_home_dir - g_get_prgname - g_get_real_name - g_get_tmp_dir - g_get_user_name - g_getenv - g_hash_table_destroy - g_hash_table_foreach - g_hash_table_foreach_remove - g_hash_table_insert - g_hash_table_lookup - g_hash_table_lookup_extended - g_hash_table_new - g_hash_table_remove - g_hash_table_size - g_hook_alloc - g_hook_compare_ids - g_hook_destroy - g_hook_destroy_link - g_hook_find - g_hook_find_data - g_hook_find_func - g_hook_find_func_data - g_hook_first_valid - g_hook_free - g_hook_get - g_hook_insert_before - g_hook_insert_sorted - g_hook_list_clear - g_hook_list_init - g_hook_list_invoke - g_hook_list_invoke_check - g_hook_list_marshal - g_hook_list_marshal_check - g_hook_next_valid - g_hook_prepend - g_hook_ref - g_hook_unref - g_iconv - g_iconv_close - g_iconv_open - g_idle_add - g_idle_add_full - g_idle_remove_by_data - g_idle_source_new - g_int_equal - g_int_hash - g_io_add_watch - g_io_add_watch_full - g_io_channel_close - g_io_channel_error_from_errno - g_io_channel_error_quark - g_io_channel_flush - g_io_channel_get_buffer_condition - g_io_channel_get_buffer_size - g_io_channel_get_buffered - g_io_channel_get_encoding - g_io_channel_get_flags - g_io_channel_get_line_term - g_io_channel_init - g_io_channel_new_file - g_io_channel_read - g_io_channel_read_chars - g_io_channel_read_line - g_io_channel_read_line_string - g_io_channel_read_to_end - g_io_channel_ref - g_io_channel_seek - g_io_channel_seek_position - g_io_channel_set_buffer_size - g_io_channel_set_buffered - g_io_channel_set_encoding - g_io_channel_set_flags - g_io_channel_set_line_term - g_io_channel_unix_get_fd - g_io_channel_unix_new - g_io_channel_unref - g_io_channel_win32_get_fd - g_io_channel_win32_make_pollfd - g_io_channel_win32_new_fd - g_io_channel_win32_new_messages - g_io_channel_win32_new_socket - g_io_channel_win32_new_stream_socket - g_io_channel_win32_poll - g_io_channel_win32_set_debug - g_io_channel_write - g_io_channel_write_chars - g_io_create_watch - g_list_alloc - g_list_append - g_list_concat - g_list_copy - g_list_delete_link - g_list_find - g_list_find_custom - g_list_first - g_list_foreach - g_list_free - g_list_free_1 - g_list_index - g_list_insert - g_list_insert_sorted - g_list_last - g_list_length - g_list_nth - g_list_nth_data - g_list_position - g_list_prepend - g_list_remove - g_list_remove_all - g_list_remove_link - g_list_reverse - g_list_sort - g_list_sort_with_data - g_locale_from_utf8 - g_locale_to_utf8 - g_log - g_log_default_handler - g_log_domain_glib - g_log_remove_handler - g_log_set_always_fatal - g_log_set_fatal_mask - g_log_set_handler - g_logv - g_main_context_add_poll - g_main_context_check - g_main_context_default - g_main_context_dispatch - g_main_context_find_source_by_funcs_user_data - g_main_context_find_source_by_id - g_main_context_find_source_by_user_data - g_main_context_get - g_main_context_get_poll_func - g_main_context_iteration - g_main_context_pending - g_main_context_prepare - g_main_context_query - g_main_context_remove_poll - g_main_context_set_poll_func - g_main_loop_is_running - g_main_loop_new - g_main_loop_quit - g_main_loop_ref - g_main_loop_run - g_main_loop_unref - g_malloc - g_malloc0 - g_markup_error_quark - g_markup_escape_text - g_markup_parse_context_end_parse - g_markup_parse_context_free - g_markup_parse_context_get_position - g_markup_parse_context_new - g_markup_parse_context_parse - g_mem_chunk_alloc - g_mem_chunk_alloc0 - g_mem_chunk_clean - g_mem_chunk_destroy - g_mem_chunk_free - g_mem_chunk_info - g_mem_chunk_new - g_mem_chunk_print - g_mem_chunk_reset - g_mem_init - g_mem_profile - g_mem_set_vtable - g_memdup - g_messages_init - g_mkstemp - g_mutex_init - g_node_child_index - g_node_child_position - g_node_children_foreach - g_node_copy - g_node_depth - g_node_destroy - g_node_find - g_node_find_child - g_node_first_sibling - g_node_get_root - g_node_insert - g_node_insert_after - g_node_insert_before - g_node_is_ancestor - g_node_last_child - g_node_last_sibling - g_node_max_height - g_node_n_children - g_node_n_nodes - g_node_new - g_node_nth_child - g_node_prepend - g_node_reverse_children - g_node_traverse - g_node_unlink - g_on_error_query - g_on_error_stack_trace - g_parse_debug_string - g_path_get_basename - g_path_get_dirname - g_path_is_absolute - g_path_skip_root - g_pattern_match - g_pattern_match_string - g_pattern_spec_free - g_pattern_spec_new - g_print - g_printerr - g_printf_string_upper_bound - g_propagate_error - g_ptr_array_add - g_ptr_array_free - g_ptr_array_new - g_ptr_array_remove - g_ptr_array_remove_fast - g_ptr_array_remove_index - g_ptr_array_remove_index_fast - g_ptr_array_set_size - g_ptr_array_sized_new - g_ptr_array_sort - g_ptr_array_sort_with_data - g_qsort_with_data - g_quark_from_static_string - g_quark_from_string - g_quark_to_string - g_quark_try_string - g_queue_free - g_queue_is_empty - g_queue_new - g_queue_peek_head - g_queue_peek_tail - g_queue_pop_head - g_queue_pop_head_link - g_queue_pop_tail - g_queue_pop_tail_link - g_queue_push_head - g_queue_push_head_link - g_queue_push_tail - g_queue_push_tail_link - g_rand_double - g_rand_double_range - g_rand_free - g_rand_int - g_rand_int_range - g_rand_new - g_rand_new_with_seed - g_rand_set_seed - g_random_double - g_random_double_range - g_random_int - g_random_int_range - g_random_set_seed - g_realloc - g_relation_count - g_relation_delete - g_relation_destroy - g_relation_exists - g_relation_index - g_relation_insert - g_relation_new - g_relation_print - g_relation_select - g_scanner_cur_line - g_scanner_cur_position - g_scanner_cur_token - g_scanner_cur_value - g_scanner_destroy - g_scanner_eof - g_scanner_error - g_scanner_get_next_token - g_scanner_input_file - g_scanner_input_text - g_scanner_lookup_symbol - g_scanner_new - g_scanner_peek_next_token - g_scanner_scope_add_symbol - g_scanner_scope_foreach_symbol - g_scanner_scope_lookup_symbol - g_scanner_scope_remove_symbol - g_scanner_set_scope - g_scanner_stat_mode - g_scanner_sync_file_offset - g_scanner_unexp_token - g_scanner_warn - g_set_error - g_set_error_handler - g_set_message_handler - g_set_prgname - g_set_print_handler - g_set_printerr_handler - g_set_warning_handler - g_shell_parse_argv - g_shell_quote - g_shell_unquote - g_slist_alloc - g_slist_append - g_slist_concat - g_slist_copy - g_slist_delete_link - g_slist_find - g_slist_find_custom - g_slist_foreach - g_slist_free - g_slist_free_1 - g_slist_index - g_slist_insert - g_slist_insert_sorted - g_slist_last - g_slist_length - g_slist_nth - g_slist_nth_data - g_slist_position - g_slist_prepend - g_slist_remove - g_slist_remove_all - g_slist_remove_link - g_slist_reverse - g_slist_sort - g_slist_sort_with_data - g_snprintf - g_source_add_poll - g_source_attach - g_source_destroy - g_source_get_can_recurse - g_source_get_context - g_source_get_current_time - g_source_get_id - g_source_get_priority - g_source_new - g_source_ref - g_source_remove - g_source_remove_by_funcs_user_data - g_source_remove_by_user_data - g_source_set_callback - g_source_set_callback_indirect - g_source_set_can_recurse - g_source_set_priority - g_source_unref - g_spaced_primes_closest - g_spawn_async - g_spawn_async_with_pipes - g_spawn_command_line_async - g_spawn_command_line_sync - g_spawn_error_quark - g_spawn_sync - g_static_mutex_get_mutex_impl - g_static_private_free - g_static_private_get - g_static_private_init - g_static_private_set - g_static_rec_mutex_free - g_static_rec_mutex_init - g_static_rec_mutex_lock - g_static_rec_mutex_trylock - g_static_rec_mutex_unlock - g_static_rw_lock_free - g_static_rw_lock_init - g_static_rw_lock_reader_lock - g_static_rw_lock_reader_trylock - g_static_rw_lock_reader_unlock - g_static_rw_lock_writer_lock - g_static_rw_lock_writer_trylock - g_static_rw_lock_writer_unlock - g_stpcpy - g_str_equal - g_str_hash - g_strcanon - g_strcasecmp - g_strchomp - g_strchug - g_strcompress - g_strconcat - g_strdelimit - g_strdown - g_strdup - g_strdup_printf - g_strdup_vprintf - g_strdupv - g_strerror - g_strescape - g_strfreev - g_string_append - g_string_append_c - g_string_append_len - g_string_assign - g_string_chunk_free - g_string_chunk_insert - g_string_chunk_insert_const - g_string_chunk_new - g_string_down - g_string_equal - g_string_erase - g_string_free - g_string_insert - g_string_insert_c - g_string_insert_len - g_string_new - g_string_new_len - g_string_prepend - g_string_prepend_c - g_string_prepend_len - g_string_printf - g_string_printfa - g_string_sized_new - g_string_truncate - g_string_up - g_strjoin - g_strjoinv - g_strlcat - g_strlcpy - g_strncasecmp - g_strndup - g_strnfill - g_strreverse - g_strsignal - g_strsplit - g_strtod - g_strup - g_thread_create_full - g_thread_error_quark - g_thread_functions_for_glib_use - g_thread_join - g_thread_exit - g_thread_pool_free - g_thread_pool_new - g_thread_pool_push - g_thread_self - g_thread_set_priority - g_thread_use_default_impl - g_threads_got_initialized - g_timeout_add - g_timeout_add_full - g_timeout_source_new - g_timer_destroy - g_timer_elapsed - g_timer_new - g_timer_reset - g_timer_start - g_timer_stop - g_trash_stack_height - g_trash_stack_peek - g_trash_stack_pop - g_trash_stack_push - g_tree_destroy - g_tree_height - g_tree_insert - g_tree_lookup - g_tree_new - g_tree_nnodes - g_tree_remove - g_tree_search - g_tree_traverse - g_try_malloc - g_try_realloc - g_tuples_destroy - g_tuples_index - g_ucs4_to_utf16 - g_ucs4_to_utf8 - g_unichar_break_type - g_unichar_digit_value - g_unichar_isalnum - g_unichar_isalpha - g_unichar_iscntrl - g_unichar_isdefined - g_unichar_isdigit - g_unichar_isgraph - g_unichar_islower - g_unichar_isprint - g_unichar_ispunct - g_unichar_isspace - g_unichar_istitle - g_unichar_isupper - g_unichar_iswide - g_unichar_isxdigit - g_unichar_to_utf8 - g_unichar_tolower - g_unichar_totitle - g_unichar_toupper - g_unichar_type - g_unichar_validate - g_unichar_xdigit_value - g_unicode_canonical_decomposition - g_unicode_canonical_ordering - g_usleep - g_utf16_to_ucs4 - g_utf16_to_utf8 - g_utf8_find_next_char - g_utf8_find_prev_char - g_utf8_get_char - g_utf8_offset_to_pointer - g_utf8_pointer_to_offset - g_utf8_prev_char - g_utf8_skip - g_utf8_strchr - g_utf8_strlen - g_utf8_strncpy - g_utf8_to_ucs4 - g_utf8_to_ucs4_fast - g_utf8_to_utf16 - g_utf8_validate - g_vsnprintf - g_win32_closedir - g_win32_error_message - g_win32_ftruncate - g_win32_get_package_installation_directory - g_win32_get_package_installation_subdirectory - g_win32_getlocale - g_win32_opendir - g_win32_readdir - g_win32_rewinddir - glib_binary_age - glib_interface_age - glib_major_version - glib_mem_profiler_table - glib_micro_version - glib_minor_version - -; compatibility for older win32 apps, which should -; not need an update because of simple function renaming -; and vice versa, i.e.: -; compatibility of Dia 0.87 with tml's latest Gtk+ version (2000-12-26) - g_dirname=g_path_get_dirname - g_string_sprintfa=g_string_printfa - g_string_sprintf=g_string_printf diff --git a/glib/giowin32.c b/glib/giowin32.c index ca8c99710..3db8b7a1c 100644 --- a/glib/giowin32.c +++ b/glib/giowin32.c @@ -1070,16 +1070,123 @@ g_io_win32_sock_create_watch (GIOChannel *channel, return g_io_win32_create_watch (channel, condition, select_thread); } -/* Some functions prototypes so win32 will (hopefully) still compile FIXME */ - GIOChannel * g_io_channel_new_file (const gchar *filename, - GIOFileMode mode, + const gchar *mode, GError **error) { - g_warning("Function unimplemented: %s", G_GNUC_FUNCTION); + int fid, flags; + GIOChannel *channel; - return NULL; + enum { /* Cheesy hack */ + MODE_R = 1 << 0, + MODE_W = 1 << 1, + MODE_A = 1 << 2, + MODE_PLUS = 1 << 3, + } mode_num; + + g_return_val_if_fail (filename != NULL, NULL); + g_return_val_if_fail (mode != NULL, NULL); + g_return_val_if_fail ((error == NULL) || (*error == NULL), NULL); + + switch (mode[0]) + { + case 'r': + mode_num = MODE_R; + break; + case 'w': + mode_num = MODE_W; + break; + case 'a': + mode_num = MODE_A; + break; + default: + g_warning ("Invalid GIOFileMode %s.\n", mode); + return NULL; + } + + switch (mode[1]) + { + case '\0': + break; + case '+': + if (mode[2] == '\0') + { + mode_num |= MODE_PLUS; + break; + } + /* Fall through */ + default: + g_warning ("Invalid GIOFileMode %s.\n", mode); + return NULL; + } + + switch (mode_num) + { + case MODE_R: + flags = O_RDONLY; + break; + case MODE_W: + flags = O_WRONLY | O_TRUNC | O_CREAT; + break; + case MODE_A: + flags = O_WRONLY | O_APPEND | O_CREAT; + break; + case MODE_R | MODE_PLUS: + flags = O_RDWR; + break; + case MODE_W | MODE_PLUS: + flags = O_RDWR | O_TRUNC | O_CREAT; + break; + case MODE_A | MODE_PLUS: + flags = O_RDWR | O_APPEND | O_CREAT; + break; + default: + g_assert_not_reached (); + flags = 0; + } + + + fid = open (filename, flags); + if (fid < 0) + { + g_set_error (error, G_FILE_ERROR, + g_file_error_from_errno (errno), + strerror (errno)); + return (GIOChannel *)NULL; + } + + channel = g_io_channel_win32_new_fd (fid); + + /* XXX: move this to g_io_channel_win32_new_fd () */ + channel->close_on_unref = TRUE; + channel->is_seekable = TRUE; + + switch (mode_num) + { + case MODE_R: + channel->is_readable = TRUE; + channel->is_writeable = FALSE; + break; + case MODE_W: + case MODE_A: + channel->is_readable = FALSE; + channel->is_writeable = TRUE; + break; + case MODE_R | MODE_PLUS: + case MODE_W | MODE_PLUS: + case MODE_A | MODE_PLUS: + channel->is_readable = TRUE; + channel->is_writeable = TRUE; + break; + default: + g_assert_not_reached (); + } + + if (((GIOWin32Channel *)channel)->debug) + g_print ("g_io_channel_win32_new_file: fd = %ud\n", fid); + + return channel; } GIOStatus @@ -1087,17 +1194,51 @@ g_io_win32_set_flags (GIOChannel *channel, GIOFlags flags, GError **err) { - g_message("Function %s unimplemented.\n", G_GNUC_FUNCTION); + GIOWin32Channel *win32_channel = (GIOWin32Channel *)channel; - return G_IO_STATUS_NORMAL; /* Can't return error, haven't set err */ + g_set_error (err, + G_IO_CHANNEL_ERROR, + g_file_error_from_errno (EACCES), + _("Channel set flags unsupported")); + return G_IO_STATUS_ERROR; } +GIOFlags +g_io_win32_fd_get_flags (GIOChannel *channel) +{ + GIOFlags flags = 0; + struct _stat st; + GIOWin32Channel *win32_channel = (GIOWin32Channel *)channel; + + g_return_val_if_fail (win32_channel != NULL, 0); + g_return_val_if_fail (win32_channel->type == G_IO_WIN32_FILE_DESC, 0); + + if (0 == _fstat (win32_channel->fd, &st)) + { + /* XXX: G_IO_FLAG_APPEND */ + /* XXX: G_IO_FLAG_NONBLOCK */ + if (st.st_mode & _S_IREAD) flags |= G_IO_FLAG_IS_READABLE; + if (st.st_mode & _S_IWRITE) flags |= G_IO_FLAG_IS_WRITEABLE; + /* XXX: */ + if (!(st.st_mode & _S_IFIFO)) flags |= G_IO_FLAG_IS_SEEKABLE; + } + + return flags; +} + +/* + * Generic implementation, just translating createion flags + */ GIOFlags g_io_win32_get_flags (GIOChannel *channel) { - g_message("Function %s unimplemented.\n", G_GNUC_FUNCTION); + GIOFlags flags; - return 0; + flags = (channel->is_readable ? G_IO_FLAG_IS_READABLE : 0) + | (channel->is_writeable ? G_IO_FLAG_IS_READABLE : 0) + | (channel->is_seekable ? G_IO_FLAG_IS_SEEKABLE : 0); + + return flags; } static GIOFuncs win32_channel_msg_funcs = { @@ -1119,7 +1260,7 @@ static GIOFuncs win32_channel_fd_funcs = { g_io_win32_fd_create_watch, g_io_win32_free, g_io_win32_set_flags, - g_io_win32_get_flags, + g_io_win32_fd_get_flags, }; static GIOFuncs win32_channel_sock_funcs = { @@ -1147,7 +1288,9 @@ g_io_channel_win32_new_messages (guint hwnd) win32_channel->type = G_IO_WIN32_WINDOWS_MESSAGES; win32_channel->hwnd = (HWND) hwnd; - /* FIXME set is_readable, is_writeable */ + /* XXX: check this. */ + channel->is_readable = IsWindow (win32_channel->hwnd); + channel->is_writeable = IsWindow (win32_channel->hwnd); channel->is_seekable = FALSE; @@ -1178,9 +1321,11 @@ g_io_channel_win32_new_fd (gint fd) win32_channel->type = G_IO_WIN32_FILE_DESC; win32_channel->fd = fd; - /* FIXME set is_readable, is_writeable */ - channel->is_seekable = TRUE; + channel->is_readable = !!(st.st_mode & _S_IREAD); + channel->is_writeable = !!(st.st_mode & _S_IWRITE); + /* XXX: pipes aren't seeakable, are they ? */ + channel->is_seekable = !(st.st_mode & _S_IFIFO); return channel; } @@ -1207,8 +1352,9 @@ g_io_channel_win32_new_socket (int socket) win32_channel->type = G_IO_WIN32_SOCKET; win32_channel->fd = socket; - /* FIXME set is_readable, is_writeable */ - + /* XXX: check this */ + channel->is_readable = TRUE; + channel->is_writeable = TRUE; channel->is_seekable = FALSE; return channel; diff --git a/glib/glib.def b/glib/glib.def index dcb0adf81..bc5e42138 100644 --- a/glib/glib.def +++ b/glib/glib.def @@ -55,8 +55,6 @@ EXPORTS g_cache_new g_cache_remove g_cache_value_foreach - g_channel_error_quark - g_channel_error_from_errno g_clear_error g_completion_add_items g_completion_clear_items @@ -190,9 +188,12 @@ EXPORTS g_io_add_watch g_io_add_watch_full g_io_channel_close + g_io_channel_error_from_errno + g_io_channel_error_quark g_io_channel_flush g_io_channel_get_buffer_condition g_io_channel_get_buffer_size + g_io_channel_get_buffered g_io_channel_get_encoding g_io_channel_get_flags g_io_channel_get_line_term @@ -207,6 +208,7 @@ EXPORTS g_io_channel_seek g_io_channel_seek_position g_io_channel_set_buffer_size + g_io_channel_set_buffered g_io_channel_set_encoding g_io_channel_set_flags g_io_channel_set_line_term diff --git a/tests/makefile.msc.in b/tests/makefile.msc.in index 83a74a24b..ead522dc3 100644 --- a/tests/makefile.msc.in +++ b/tests/makefile.msc.in @@ -23,6 +23,7 @@ TESTS = \ date-test.exe \ dirname-test.exe\ gio-test.exe \ + iochannel-test.exe \ hash-test.exe \ list-test.exe \ mainloop-test.exe\