#include "ruby/ruby.h"#include <errno.h>#include <iconv.h>#include <assert.h>#include "ruby/st.h"#include "ruby/encoding.h"
Go to the source code of this file.
Data Structures | |
| struct | iconv_env_t |
| struct | rb_iconv_opt_t |
Defines | |
| #define | VALUE2ICONV(v) ((iconv_t)((VALUE)(v) ^ -1)) |
| #define | ICONV2VALUE(c) ((VALUE)(c) ^ -1) |
| #define | rb_sys_fail(s) rb_iconv_sys_fail(s) |
| #define | ICONV_FREE iconv_dfree |
| #define | ICONV_INPTR_CAST (char **) |
| #define | FAILED_MAXLEN 16 |
| #define | iconv_ctl(self, func, val) |
| #define | iconv_s_list rb_f_notimplement |
| #define | iconv_trivialp rb_f_notimplement |
| #define | iconv_get_transliterate rb_f_notimplement |
| #define | iconv_set_transliterate rb_f_notimplement |
| #define | iconv_get_discard_ilseq rb_f_notimplement |
| #define | iconv_set_discard_ilseq rb_f_notimplement |
Functions | |
| static VALUE iconv_fail | _ ((VALUE error, VALUE success, VALUE failed, struct iconv_env_t *env, const char *mesg)) |
| static VALUE iconv_failure_initialize | _ ((VALUE error, VALUE mesg, VALUE success, VALUE failed)) |
| static VALUE iconv_failure_success | _ ((VALUE self)) |
| static iconv_t iconv_create | _ ((VALUE to, VALUE from, struct rb_iconv_opt_t *opt, int *idx)) |
| static void iconv_dfree | _ ((void *cd)) |
| static VALUE iconv_free | _ ((VALUE cd)) |
| static VALUE iconv_try | _ ((iconv_t cd, const char **inptr, size_t *inlen, char **outptr, size_t *outlen)) |
| static VALUE rb_str_derive | _ ((VALUE str, const char *ptr, long len)) |
| static VALUE iconv_convert | _ ((iconv_t cd, VALUE str, long start, long length, int toidx, struct iconv_env_t *env)) |
| static VALUE iconv_s_allocate | _ ((VALUE klass)) |
| static VALUE iconv_initialize | _ ((int argc, VALUE *argv, VALUE self)) |
| static VALUE iconv_s_convert | _ ((struct iconv_env_t *env)) |
| static VALUE | charset_map_get (void) |
| static VALUE | strip_glibc_option (VALUE *code) |
| static char * | map_charset (VALUE *code) |
| NORETURN (static void rb_iconv_sys_fail(const char *s)) | |
| static void | rb_iconv_sys_fail (const char *s) |
| static iconv_t | iconv_create (VALUE to, VALUE from, struct rb_iconv_opt_t *opt, int *idx) |
| static void | iconv_dfree (void *cd) |
| static VALUE | iconv_free (VALUE cd) |
| static VALUE | check_iconv (VALUE obj) |
| static VALUE | iconv_try (iconv_t cd, const char **inptr, size_t *inlen, char **outptr, size_t *outlen) |
| static VALUE | iconv_failure_initialize (VALUE error, VALUE mesg, VALUE success, VALUE failed) |
| static VALUE | iconv_fail (VALUE error, VALUE success, VALUE failed, struct iconv_env_t *env, const char *mesg) |
| static VALUE | iconv_fail_retry (VALUE error, VALUE success, VALUE failed, struct iconv_env_t *env, const char *mesg) |
| static VALUE | rb_str_derive (VALUE str, const char *ptr, long len) |
| static VALUE | iconv_convert (iconv_t cd, VALUE str, long start, long length, int toidx, struct iconv_env_t *env) |
| static VALUE | iconv_s_allocate (VALUE klass) |
| static VALUE | get_iconv_opt_i (VALUE i, VALUE arg) |
| static void | get_iconv_opt (struct rb_iconv_opt_t *opt, VALUE options) |
| static VALUE | iconv_initialize (int argc, VALUE *argv, VALUE self) |
| static VALUE | iconv_s_open (int argc, VALUE *argv, VALUE self) |
| static VALUE | iconv_s_convert (struct iconv_env_t *env) |
| static VALUE | iconv_s_iconv (int argc, VALUE *argv, VALUE self) |
| static VALUE | iconv_s_conv (VALUE self, VALUE to, VALUE from, VALUE str) |
| static VALUE | iconv_init_state (VALUE self) |
| static VALUE | iconv_finish (VALUE self) |
| static VALUE | iconv_iconv (int argc, VALUE *argv, VALUE self) |
| static VALUE | iconv_conv (int argc, VALUE *argv, VALUE self) |
| static VALUE | iconv_s_ctlmethods (VALUE klass) |
| static VALUE | iconv_failure_success (VALUE self) |
| static VALUE | iconv_failure_failed (VALUE self) |
| static VALUE | iconv_failure_inspect (VALUE self) |
| void | Init_iconv (void) |
Variables | |
| static ID | id_transliterate |
| static ID | id_discard_ilseq |
| static VALUE | rb_eIconvInvalidEncoding |
| static VALUE | rb_eIconvFailure |
| static VALUE | rb_eIconvIllegalSeq |
| static VALUE | rb_eIconvInvalidChar |
| static VALUE | rb_eIconvOutOfRange |
| static VALUE | rb_eIconvBrokenLibrary |
| static ID | rb_success |
| static ID | rb_failed |
| static VALUE | charset_map |
| #define FAILED_MAXLEN 16 |
| #define ICONV2VALUE | ( | c | ) | ((VALUE)(c) ^ -1) |
Definition at line 80 of file iconv.c.
Referenced by iconv_initialize(), iconv_s_conv(), iconv_s_iconv(), and iconv_s_open().
| #define iconv_ctl | ( | self, | |||
| func, | |||||
| val | ) |
Value:
(\
iconvctl(VALUE2ICONV(check_iconv(self)), func, (void *)&(val)) ? \
rb_sys_fail(#func) : (void)0)
| #define ICONV_FREE iconv_dfree |
Definition at line 294 of file iconv.c.
Referenced by check_iconv(), iconv_s_allocate(), and iconv_s_open().
| #define iconv_get_discard_ilseq rb_f_notimplement |
| #define iconv_get_transliterate rb_f_notimplement |
| #define ICONV_INPTR_CAST (char **) |
Referenced by iconv_try().
| #define iconv_s_list rb_f_notimplement |
| #define iconv_set_discard_ilseq rb_f_notimplement |
| #define iconv_set_transliterate rb_f_notimplement |
| #define iconv_trivialp rb_f_notimplement |
| #define rb_sys_fail | ( | s | ) | rb_iconv_sys_fail(s) |
Definition at line 186 of file iconv.c.
Referenced by bsock_getpeername(), bsock_getsockname(), bsock_local_address(), bsock_remote_address(), bsock_shutdown(), chfunc(), chmod_internal(), chown_internal(), copy_stream_body(), copy_stream_finalize(), dir_chdir(), dir_initialize(), dir_read(), dir_s_mkdir(), dir_s_rmdir(), establishShell(), fdbm_initialize(), fdbm_store(), fgdbm_initialize(), fgdbm_store(), flush_before_seek(), fsdbm_initialize(), fsdbm_store(), iconv_create(), iconv_free(), iconv_try(), init_inetsock_internal(), io_reopen(), io_wait(), ip_addr(), ip_peeraddr(), make_fd_nonblock(), ossl_obj2bio(), ossl_ssl_read_internal(), ossl_ssl_write_internal(), ossl_start_ssl(), p_gid_change_privilege(), p_gid_exchange(), p_gid_switch(), p_uid_change_privilege(), p_uid_exchange(), p_uid_switch(), pipe_open(), proc_wait(), proc_waitall(), pty_getpty(), raise_zlib_error(), rb_f_exec(), rb_f_kill(), rb_f_spawn(), rb_f_test(), rb_fdopen(), rb_file_s_atime(), rb_file_s_ctime(), rb_file_s_ftype(), rb_file_s_lstat(), rb_file_s_mtime(), rb_file_s_size(), rb_file_s_stat(), rb_iconv_sys_fail(), rb_io_check_char_readable(), rb_io_flush(), rb_io_initialize(), rb_io_reopen(), rb_io_s_pipe(), rb_io_write_nonblock(), rb_setegid_core(), rb_seteuid_core(), rb_stat_init(), rb_sysopen(), rb_thread_wait_fd_rw(), realpath_rec(), remain_size(), rsock_bsock_send(), rsock_fd_socket_addrinfo(), rsock_init_sock(), rsock_raise_socket_error(), rsock_s_accept(), rsock_s_accept_nonblock(), rsock_s_recvfrom(), rsock_s_recvfrom_nonblock(), rsock_sock_listen(), ruby_dup(), ruby_getcwd(), ruby_setenv(), select_internal(), sock_bind(), sock_connect(), sock_connect_nonblock(), sock_initialize(), strio_init(), sys_fail2(), time_init_0(), udp_bind(), udp_connect(), udp_init(), udp_send(), and unlink_internal().
| #define VALUE2ICONV | ( | v | ) | ((iconv_t)((VALUE)(v) ^ -1)) |
Definition at line 79 of file iconv.c.
Referenced by iconv_conv(), iconv_dfree(), iconv_free(), iconv_iconv(), and iconv_init_state().
| static VALUE iconv_s_convert _ | ( | (struct iconv_env_t *env) | ) | [static] |
| static VALUE iconv_convert _ | ( | (iconv_t cd, VALUE str, long start, long length, int toidx, struct iconv_env_t *env) | ) | [static] |
| static VALUE iconv_try _ | ( | (iconv_t cd, const char **inptr, size_t *inlen, char **outptr, size_t *outlen) | ) | [static] |
| static void iconv_dfree _ | ( | (void *cd) | ) | [static] |
| static iconv_t iconv_create _ | ( | (VALUE to, VALUE from, struct rb_iconv_opt_t *opt, int *idx) | ) | [static] |
| static VALUE iconv_failure_initialize _ | ( | (VALUE error, VALUE mesg, VALUE success, VALUE failed) | ) | [static] |
| static VALUE iconv_fail_retry _ | ( | (VALUE error, VALUE success, VALUE failed, struct iconv_env_t *env, const char *mesg) | ) | [static] |
| static VALUE charset_map_get | ( | void | ) | [static] |
Definition at line 305 of file iconv.c.
References Check_Type, CLASS_OF, DATA_PTR, ICONV_FREE, rb_class2name(), rb_eArgError, rb_raise(), RDATA, and T_DATA.
Referenced by iconv_conv(), iconv_finish(), iconv_iconv(), and iconv_initialize().
| static void get_iconv_opt | ( | struct rb_iconv_opt_t * | opt, | |
| VALUE | options | |||
| ) | [static] |
Definition at line 618 of file iconv.c.
References rb_iconv_opt_t::discard_ilseq, get_iconv_opt_i(), NIL_P, Qundef, rb_block_call, rb_intern, and rb_iconv_opt_t::transliterate.
Referenced by iconv_initialize(), and iconv_s_open().
Definition at line 563 of file iconv.c.
References rb_iconv_opt_t::discard_ilseq, id_discard_ilseq, id_transliterate, name, Qnil, rb_Array(), rb_ary_entry(), rb_eArgError, rb_inspect(), rb_notimplement(), rb_raise(), StringValueCStr, SYM2ID, SYMBOL_P, and rb_iconv_opt_t::transliterate.
Referenced by get_iconv_opt().
Definition at line 951 of file iconv.c.
References iconv_env_t::cd, check_iconv(), ENCODING_GET, iconv_convert(), NULL, Qnil, rb_str_buf_append(), RSTRING_LEN, iconv_env_t::toidx, and VALUE2ICONV.
Referenced by Init_iconv().
| static VALUE iconv_convert | ( | iconv_t | cd, | |
| VALUE | str, | |||
| long | start, | |||
| long | length, | |||
| int | toidx, | |||
| struct iconv_env_t * | env | |||
| ) | [static] |
Definition at line 416 of file iconv.c.
References FIX2INT, FIXNUM_P, iconv_fail_retry(), iconv_try(), len, memcmp(), NIL_P, NULL, OBJ_INFECT, Qfalse, Qnil, RARRAY_LEN, RARRAY_PTR, rb_eArgError, rb_eIconvOutOfRange, rb_enc_associate_index(), rb_raise(), rb_str_buf_cat(), rb_str_cat(), rb_str_concat(), rb_str_derive(), rb_str_new(), iconv_env_t::ret, RSTRING_LEN, RSTRING_PTR, RTEST, SIGNEDNESS_OF_SIZE_T, StringValue, T_ARRAY, and TYPE.
Referenced by iconv_conv(), iconv_iconv(), iconv_init_state(), and iconv_s_convert().
| static iconv_t iconv_create | ( | VALUE | to, | |
| VALUE | from, | |||
| struct rb_iconv_opt_t * | opt, | |||
| int * | idx | |||
| ) | [static] |
Definition at line 189 of file iconv.c.
References iconv_env_t::cd, rb_iconv_opt_t::discard_ilseq, errno, iconv_fail(), map_charset(), msg, NULL, Qnil, Qundef, rb_ary_new3(), rb_eIconvInvalidEncoding, rb_enc_find_index(), rb_exc_raise(), rb_gc(), rb_str_equal(), rb_str_new(), rb_str_plus(), rb_str_resize(), rb_str_set_len, rb_sys_fail, rb_warning(), RSTRING_LEN, RSTRING_PTR, RTEST, strip_glibc_option(), and rb_iconv_opt_t::transliterate.
Referenced by iconv_initialize(), iconv_s_conv(), iconv_s_iconv(), and iconv_s_open().
| static void iconv_dfree | ( | void * | cd | ) | [static] |
| static VALUE iconv_fail | ( | VALUE | error, | |
| VALUE | success, | |||
| VALUE | failed, | |||
| struct iconv_env_t * | env, | |||
| const char * | mesg | |||
| ) | [static] |
Definition at line 365 of file iconv.c.
References iconv_env_t::argc, iconv_env_t::argv, FAILED_MAXLEN, rb_ary_new4(), rb_class_new_instance(), rb_inspect(), rb_obj_dup(), rb_str_cat2(), rb_str_new2, rb_str_substr(), iconv_env_t::ret, RSTRING_LEN, T_STRING, and TYPE.
Referenced by iconv_create(), iconv_fail_retry(), and rb_iconv_sys_fail().
| static VALUE iconv_fail_retry | ( | VALUE | error, | |
| VALUE | success, | |||
| VALUE | failed, | |||
| struct iconv_env_t * | env, | |||
| const char * | mesg | |||
| ) | [static] |
Definition at line 392 of file iconv.c.
References iconv_fail(), rb_block_given_p(), rb_exc_raise(), rb_set_errinfo(), and rb_yield().
Referenced by iconv_convert().
Definition at line 1122 of file iconv.c.
References rb_attr_get(), and rb_failed.
Referenced by Init_iconv().
| static VALUE iconv_failure_initialize | ( | VALUE | error, | |
| VALUE | mesg, | |||
| VALUE | success, | |||
| VALUE | failed | |||
| ) | [static] |
Definition at line 356 of file iconv.c.
References rb_call_super(), rb_failed, rb_ivar_set(), and rb_success.
Referenced by Init_iconv().
Definition at line 1134 of file iconv.c.
References CLASS_OF, rb_attr_get(), rb_class2name(), rb_failed, rb_inspect(), rb_str_buf_append(), rb_str_buf_cat(), rb_str_buf_cat2(), rb_str_new2, and rb_success.
Referenced by Init_iconv().
Definition at line 1109 of file iconv.c.
References rb_attr_get(), and rb_success.
Referenced by Init_iconv().
Definition at line 875 of file iconv.c.
References iconv_env_t::cd, check_iconv(), iconv_free(), iconv_init_state(), Qnil, and rb_ensure().
Referenced by iconv_s_open(), and Init_iconv().
Definition at line 297 of file iconv.c.
References Qnil, rb_sys_fail, and VALUE2ICONV.
Referenced by iconv_finish(), iconv_initialize(), iconv_s_conv(), and iconv_s_iconv().
Definition at line 911 of file iconv.c.
References iconv_env_t::cd, check_iconv(), ENCODING_GET, iconv_convert(), NIL_P, NULL, NUM2LONG(), rb_enc_get(), rb_enc_nth(), rb_range_beg_len(), rb_scan_args(), rb_str_length(), RSTRING_LEN, RSTRING_PTR, RTEST, StringValue, and VALUE2ICONV.
Referenced by Init_iconv().
Definition at line 867 of file iconv.c.
References iconv_env_t::cd, DATA_PTR, ENCODING_GET, iconv_convert(), NULL, Qnil, and VALUE2ICONV.
Referenced by iconv_finish().
Definition at line 651 of file iconv.c.
References check_iconv(), DATA_PTR, ENCODING_SET, get_iconv_opt(), ICONV2VALUE, iconv_create(), iconv_free(), NULL, options(), and rb_scan_args().
Referenced by Init_iconv().
Definition at line 557 of file iconv.c.
References Data_Wrap_Struct, and ICONV_FREE.
Referenced by Init_iconv().
Definition at line 759 of file iconv.c.
References iconv_env_t::argc, iconv_env_t::argv, iconv_env_t::cd, ICONV2VALUE, iconv_create(), iconv_free(), iconv_s_convert(), NULL, rb_ensure(), rb_str_append(), rb_str_new(), iconv_env_t::ret, and iconv_env_t::toidx.
Referenced by Init_iconv().
| static VALUE iconv_s_convert | ( | struct iconv_env_t * | env | ) | [static] |
Definition at line 697 of file iconv.c.
References iconv_env_t::argc, iconv_env_t::argv, iconv_env_t::cd, iconv_convert(), last, NIL_P, Qnil, iconv_env_t::ret, RSTRING_LEN, and iconv_env_t::toidx.
Referenced by iconv_s_conv(), and iconv_s_iconv().
Definition at line 1072 of file iconv.c.
References ID2SYM, rb_ary_new(), rb_ary_push(), and rb_intern.
Referenced by Init_iconv().
Definition at line 735 of file iconv.c.
References iconv_env_t::argc, iconv_env_t::argv, iconv_env_t::cd, ICONV2VALUE, iconv_create(), iconv_free(), iconv_s_convert(), NULL, rb_ary_new2(), rb_ary_push(), rb_eArgError, rb_ensure(), rb_raise(), iconv_env_t::ret, and iconv_env_t::toidx.
Referenced by Init_iconv().
Definition at line 675 of file iconv.c.
References iconv_env_t::cd, Data_Wrap_Struct, ENCODING_SET, get_iconv_opt(), ICONV2VALUE, iconv_create(), iconv_finish(), ICONV_FREE, NULL, options(), rb_block_given_p(), rb_ensure(), rb_scan_args(), and rb_yield().
Referenced by Init_iconv().
| static VALUE iconv_try | ( | iconv_t | cd, | |
| const char ** | inptr, | |||
| size_t * | inlen, | |||
| char ** | outptr, | |||
| size_t * | outlen | |||
| ) | [static] |
Definition at line 315 of file iconv.c.
References errno, iconv, ICONV_INPTR_CAST, Qfalse, Qnil, rb_eIconvBrokenLibrary, rb_eIconvIllegalSeq, rb_eIconvInvalidChar, rb_sys_fail, and iconv_env_t::ret.
Referenced by iconv_convert().
| void Init_iconv | ( | void | ) |
Definition at line 1182 of file iconv.c.
References charset_map, charset_map_get(), iconv_conv(), iconv_failure_failed(), iconv_failure_initialize(), iconv_failure_inspect(), iconv_failure_success(), iconv_finish(), iconv_get_discard_ilseq, iconv_get_transliterate, iconv_iconv(), iconv_initialize(), iconv_s_allocate(), iconv_s_conv(), iconv_s_ctlmethods(), iconv_s_iconv(), iconv_s_list, iconv_s_open(), iconv_set_discard_ilseq, iconv_set_transliterate, iconv_trivialp, id_discard_ilseq, id_transliterate, rb_cData, rb_define_alloc_func(), rb_define_class(), rb_define_class_under(), rb_define_method(), rb_define_module_under(), rb_define_singleton_method(), rb_eArgError, rb_eIconvBrokenLibrary, rb_eIconvFailure, rb_eIconvIllegalSeq, rb_eIconvInvalidChar, rb_eIconvInvalidEncoding, rb_eIconvOutOfRange, rb_eRuntimeError, rb_failed, rb_gc_register_address(), rb_hash_new(), rb_include_module(), rb_intern, and rb_success.
| static char* map_charset | ( | VALUE * | code | ) | [static] |
Definition at line 162 of file iconv.c.
References charset_map, rb_funcall2(), rb_intern, RHASH_SIZE, RHASH_TBL, st_lookup, StringValue, and StringValuePtr.
Referenced by iconv_create().
| NORETURN | ( | static void | rb_iconv_sys_failconst char *s | ) |
| static void rb_iconv_sys_fail | ( | const char * | s | ) | [static] |
Definition at line 178 of file iconv.c.
References errno, iconv_fail(), NULL, Qnil, rb_eIconvBrokenLibrary, rb_exc_raise(), and rb_sys_fail.
Definition at line 401 of file iconv.c.
References NIL_P, OBJ_INFECT, rb_str_new(), rb_str_subseq(), iconv_env_t::ret, RSTRING_LEN, and RSTRING_PTR.
Referenced by iconv_convert().
Definition at line 146 of file iconv.c.
References rb_str_subseq(), RSTRING_END, RSTRING_PTR, and StringValue.
Referenced by iconv_create().
VALUE charset_map [static] |
Definition at line 131 of file iconv.c.
Referenced by charset_map_get(), Init_iconv(), and map_charset().
ID id_discard_ilseq [static] |
ID id_transliterate [static] |
VALUE rb_eIconvBrokenLibrary [static] |
Definition at line 105 of file iconv.c.
Referenced by iconv_try(), Init_iconv(), and rb_iconv_sys_fail().
VALUE rb_eIconvFailure [static] |
VALUE rb_eIconvIllegalSeq [static] |
VALUE rb_eIconvInvalidChar [static] |
VALUE rb_eIconvInvalidEncoding [static] |
VALUE rb_eIconvOutOfRange [static] |
Definition at line 107 of file iconv.c.
Referenced by iconv_failure_failed(), iconv_failure_initialize(), iconv_failure_inspect(), and Init_iconv().
ID rb_success [static] |
Definition at line 107 of file iconv.c.
Referenced by iconv_failure_initialize(), iconv_failure_inspect(), iconv_failure_success(), and Init_iconv().