CUBRID Engine
latest
|
#include "config.h"
#include <stdio.h>
#include <assert.h>
#include <errno.h>
#include <signal.h>
#include <ctype.h>
#include <time.h>
#include <unistd.h>
#include <curses.h>
#include "porting.h"
#include <stdarg.h>
#include <sys/types.h>
#include <string.h>
Go to the source code of this file.
Functions | |
char * | strdup (const char *str) |
int | vasprintf (char **ptr, const char *format, va_list ap) |
int | asprintf (char **ptr, const char *format,...) |
int | cub_dirname_r (const char *path, char *pathbuf, size_t buflen) |
char * | dirname (const char *path) |
int | basename_r (const char *path, char *pathbuf, size_t buflen) |
char * | basename (const char *path) |
char * | stristr (const char *s, const char *find) |
char * | getuserid (char *string, int size) |
int | os_rename_file (const char *src_path, const char *dest_path) |
SIGNAL_HANDLER_FUNCTION | os_set_signal_handler (const int sig_no, SIGNAL_HANDLER_FUNCTION sig_handler) |
void | os_send_signal (const int sig_no) |
INT64 | timeval_diff_in_msec (const struct timeval *end_time, const struct timeval *start_time) |
int | timeval_add_msec (struct timeval *added_time, const struct timeval *start_time, int msec) |
int | timeval_to_timespec (struct timespec *to, const struct timeval *from) |
FILE * | port_open_memstream (char **ptr, size_t *sizeloc) |
void | port_close_memstream (FILE *fp, char **ptr, size_t *sizeloc) |
char * | trim (char *str) |
int | parse_int (int *ret_p, const char *str_p, int base) |
int | parse_bigint (INT64 *ret_p, const char *str_p, int base) |
int | str_to_int32 (int *ret_p, char **end_p, const char *str_p, int base) |
int | str_to_uint32 (unsigned int *ret_p, char **end_p, const char *str_p, int base) |
int | str_to_int64 (INT64 *ret_p, char **end_p, const char *str_p, int base) |
int | str_to_uint64 (UINT64 *ret_p, char **end_p, const char *str_p, int base) |
int | str_to_double (double *ret_p, char **end_p, const char *str_p) |
int | str_to_float (float *ret_p, char **end_p, const char *str_p) |
size_t | strlcpy (char *dst, const char *src, size_t siz) |
int | msleep (const long msec) |
int asprintf | ( | char ** | ptr, |
const char * | format, | ||
... | |||
) |
Definition at line 973 of file porting.c.
References NULL, and vasprintf().
Referenced by fileio_continue_restore(), fileio_find_restore_volume(), fileio_finish_backup(), fileio_get_next_backup_volume(), fileio_make_error_message(), and logpb_remote_ask_user_before_delete_volumes().
char* basename | ( | const char * | path | ) |
Definition at line 1132 of file porting.c.
References assert, basename_r(), CTIME_MAX, err, NULL, and p.
Referenced by acldb(), addvoldb(), alterdbhost(), applyinfo(), applylogdb(), backupdb(), changemode(), checkdb(), checksumdb(), compact_usage(), compactdb_usage(), copydb(), copylogdb(), createdb(), deletedb(), diagdb(), dump_tz(), dumplocale(), event_log_init(), gen_tz(), genlocale(), installdb(), killtran(), load_usage(), lockdb(), main(), optimizedb(), paramdump(), patchdb(), plandump(), renamedb(), restoredb(), restoreslave(), sl_init(), spacedb(), statdump(), synccolldb(), sysprm_load_and_init_internal(), sysprm_set_er_log_file(), tde(), tranlist(), unload_usage(), util_admin_usage(), util_admin_version(), util_service_usage(), util_service_version(), and vacuumdb().
int basename_r | ( | const char * | path, |
char * | pathbuf, | ||
size_t | buflen | ||
) |
Definition at line 1082 of file porting.c.
References PATH_CURRENT, PATH_SEPARATOR, and strlen.
Referenced by basename(), boot_get_host_name(), boot_set_server_session_key(), broker_config_read(), and clientids::set_program_name().
int cub_dirname_r | ( | const char * | path, |
char * | pathbuf, | ||
size_t | buflen | ||
) |
Definition at line 989 of file porting.c.
References PATH_CURRENT, PATH_SEPARATOR, and strlen.
Referenced by dirname(), er_file_backup(), er_file_open(), event_file_open(), fileio_lock_la_dbname(), ha_mkdir(), javasp_open_info_dir(), xboot_copy(), and xboot_initialize_server().
char* dirname | ( | const char * | path | ) |
Definition at line 1066 of file porting.c.
References cub_dirname_r(), and NULL.
Referenced by access_log_open(), backupdb(), cas_log_query_plan_file(), get_as_slow_log_filename(), get_as_sql_log_filename(), log_open(), make_error_log_filename(), make_proxy_log_filename(), make_sql_log_filename(), set_cubrid_home(), and sql_log2_init().
char* getuserid | ( | char * | string, |
int | size | ||
) |
Definition at line 1271 of file porting.c.
References NULL.
Referenced by boot_initialize_client(), boot_restart_client(), css_sprintf_conn_infoids(), fileio_check_lockby_file(), fileio_lock(), fileio_lock_la_log_path(), and tran_unilaterally_abort().
int msleep | ( | const long | msec | ) |
Definition at line 2657 of file porting.c.
References assert, and error().
Referenced by db_sleep().
Definition at line 1294 of file porting.c.
Referenced by es_posix_final(), fileio_rename(), fileio_unformat_and_rename(), logpb_archive_active_log(), and logpb_restore().
void os_send_signal | ( | const int | sig_no | ) |
Definition at line 1378 of file porting.c.
References assert, bool, COND_BROADCAST, cubregex::count(), FALSE, mutex, NULL, p, pthread_mutex_destroy, pthread_mutex_init, strlen, THREAD_CALLING_CONVENTION, THREAD_RET_T, and TRUE.
Referenced by signal_stop().
SIGNAL_HANDLER_FUNCTION os_set_signal_handler | ( | const int | sig_no, |
SIGNAL_HANDLER_FUNCTION | sig_handler | ||
) |
Definition at line 1333 of file porting.c.
Referenced by abort_handler(), applyinfo(), backupdb(), ci_conn_close_impl(), conn_restart_client(), crash_handler(), csql(), css_daemon_start(), css_master_init(), css_set_pipe_signal(), css_setup_server_loop(), css_terminate(), db_restart(), db_shutdown(), display_buffer(), dynload_install_handlers(), er_event(), er_event_final(), er_event_init(), extract_objects(), la_apply_log_file(), main(), process_class(), sigfpe_handler(), signal_stop(), statdump(), system_interrupt_handler(), system_quit_handler(), util_arm_signal_handlers(), util_disarm_signal_handlers(), write_results_to_stream(), and xboot_initialize_server().
int parse_bigint | ( | INT64 * | ret_p, |
const char * | str_p, | ||
int | base | ||
) |
Definition at line 2318 of file porting.c.
References assert, error(), and str_to_int64().
Referenced by ldr_int_db_bigint(), ldr_int_elem(), sp_make_int_sp_value_from_string(), cubload::to_db_bigint(), cubload::to_int_generic(), and util_put_option_value().
int parse_int | ( | int * | ret_p, |
const char * | str_p, | ||
int | base | ||
) |
Definition at line 2290 of file porting.c.
References assert, error(), and str_to_int32().
Referenced by access_control_read_ip_info(), admin_conf_change(), bin_string_to_int(), broker_init_shm(), cas_init_shm(), csql_do_session_cmd(), css_register_server_timeout_fn(), db_inet_aton(), fileio_request_user_response(), get_args(), hex_string_to_int(), ini_gethex(), ini_getint(), killtran(), ldr_compare_attribute_with_meta(), ldr_int_db_int(), ldr_int_db_short(), ldr_int_elem(), main(), proxy_shm_initialize(), sysprm_generate_new_value(), cubload::to_db_int(), cubload::to_db_short(), cubload::to_int_generic(), and util_put_option_value().
void port_close_memstream | ( | FILE * | fp, |
char ** | ptr, | ||
size_t * | sizeloc | ||
) |
Definition at line 2220 of file porting.c.
References NULL.
Referenced by do_send_plan_trace_to_session(), lock_detect_local_deadlock(), pt_plan_query(), qexec_clear_regu_variable_list(), qo_top_plan_print_text(), and session_get_trace_stats().
FILE* port_open_memstream | ( | char ** | ptr, |
size_t * | sizeloc | ||
) |
Definition at line 2198 of file porting.c.
Referenced by do_send_plan_trace_to_session(), lock_detect_local_deadlock(), pt_plan_query(), qexec_clear_regu_variable_list(), qo_top_plan_print_text(), and session_get_trace_stats().
int str_to_double | ( | double * | ret_p, |
char ** | end_p, | ||
const char * | str_p | ||
) |
int str_to_float | ( | float * | ret_p, |
char ** | end_p, | ||
const char * | str_p | ||
) |
int str_to_int32 | ( | int * | ret_p, |
char ** | end_p, | ||
const char * | str_p, | ||
int | base | ||
) |
Definition at line 2346 of file porting.c.
Referenced by classobj_decompose_property_oid(), co_find_conversion(), get_temp_file_line(), hb_check_ping(), ipstr2int(), load_ducet(), log_bind_value(), log_converter(), log_prepare(), make_sql_info(), net_client_request_with_callback(), oidstr2xoid(), parse_int(), read_cp_from_tag(), read_execute_end_msg(), rel_compare(), rel_get_compatible_internal(), str_to_log_date_format(), and string_to_coll_ce_list().
int str_to_int64 | ( | INT64 * | ret_p, |
char ** | end_p, | ||
const char * | str_p, | ||
int | base | ||
) |
Definition at line 2419 of file porting.c.
References assert, LLONG_MAX, LLONG_MIN, and NULL.
Referenced by ldr_elo_ext_elem(), parse_bigint(), and cubload::to_db_elo_ext().
int str_to_uint32 | ( | unsigned int * | ret_p, |
char ** | end_p, | ||
const char * | str_p, | ||
int | base | ||
) |
Definition at line 2382 of file porting.c.
Referenced by load_console_conv_data(), load_unicode_data(), and string_to_int_array().
int str_to_uint64 | ( | UINT64 * | ret_p, |
char ** | end_p, | ||
const char * | str_p, | ||
int | base | ||
) |
Definition at line 2449 of file porting.c.
References assert, NULL, and ULLONG_MAX.
Referenced by sysprm_generate_new_value().
char* strdup | ( | const char * | str | ) |
Definition at line 901 of file porting.c.
References assert, strlen, and vasprintf().
Referenced by access_log_open(), add_fk_info_result(), alloc_dynamic(), applylogdb(), area_create(), au_user_name_dup(), boot_restart_server(), build_attr_change_map(), build_query_graph_function_index(), cfg_new_db(), cfg_update_db(), chksum_get_prev_checksum_results(), classobj_btid_from_property_value(), classobj_check_index_exist(), classobj_make_foreign_key_ref(), conf_file_has_been_loaded(), create_child_process(), csql(), csql_help_info(), csql_set_column_width_info(), css_init(), cub_catopen(), db_query_plan_dump_file(), db_set_preferred_hosts(), disk_get_remarks(), dl_validate_file_entry(), do_alter_index_rebuild(), do_promote_partition_by_name(), do_reclaim_class_addresses(), do_remove_partition_pre(), dumplocale(), er_dump_call_stack_to_string(), er_file_open(), event_file_open(), fh_create(), fileio_get_volume_label(), genlocale(), get_args(), hb_resource_job_proc_start(), heap_cache_class_info(), heap_get_class_info_from_record(), heap_get_class_name_alloc_if_diff(), heap_get_indexinfo_of_btid(), if(), ini_table_set(), init_default_conn_info(), init_tester_info(), installdb(), JSON_VALIDATOR::JSON_VALIDATOR(), jsp_check_stored_procedure_name(), jsp_start_server(), la_add_repl_filter(), load_console_conv_data(), load_properties(), locale_check_and_set_shared_data(), locale_compile_locale(), locator_initialize(), log_open(), log_prepare(), log_recovery_resetlog(), log_top(), main(), make_node_info(), method_initialize_vacomm_buffer(), msgcat_open(), object_to_trigger(), or_get_constraint_comment(), or_get_current_representation(), or_install_btids_class(), or_install_btids_filter_pred(), or_install_btids_foreign_key(), or_install_btids_foreign_key_ref(), or_install_btids_function_info(), pp_add_whenever_to_scope(), pp_new_cursor(), pp_new_stmt(), pp_new_structdef(), pp_new_symbol(), prm_file_has_been_loaded(), prm_set_force(), process_bind(), pt_fillin_type_size(), pt_get_attr_name(), pt_get_node_title(), pt_node_to_function_index(), qexec_execute_build_indexes(), qmgr_set_query_error(), query_info_add(), query_info_add_ne(), read_conf(), save_constraint_info_from_pt_node(), session_add_variable(), sm_save_constraint_info(), sp_create_parser(), sql_info_add(), sql_info_write(), start_include_collation(), start_one_alphabet(), start_one_collation(), stmt_exec_batch_query_internal(), stmt_exec_prepared_batch_internal(), stmt_make_error_info(), stmt_reset_session_and_parse(), sysprm_generate_new_value(), sysprm_set_sysprm_value_from_parameter(), sysprm_set_value(), sysprm_unpack_sysprm_value(), tr_create_trigger(), tr_drop_trigger(), tr_process_name(), tr_rename_trigger(), tr_set_comment(), tzc_compile_data(), tzc_compile_ds_rules(), tzc_index_raw_subdata(), uc_change_config(), update_locksets_for_multiple_rename(), util_make_ha_conf(), util_put_option_value(), util_split_string(), util_str_to_time_since_epoch(), xlocator_reserve_class_name(), xlogtb_get_pack_tran_table(), and xstrdup().
Definition at line 1242 of file porting.c.
Referenced by pt_get_hint().
size_t strlcpy | ( | char * | dst, |
const char * | src, | ||
size_t | siz | ||
) |
Definition at line 2584 of file porting.c.
References assert.
Referenced by boot_restart_server(), cub_catopen(), envvar_expand(), es_posix_init(), xtx_add_lob_locator(), and xtx_change_state_of_locator().
int timeval_add_msec | ( | struct timeval * | added_time, |
const struct timeval * | start_time, | ||
int | msec | ||
) |
Definition at line 2152 of file porting.c.
Referenced by dwb_wait_for_block_completion(), dwb_wait_for_strucure_modification(), logpb_flush_pages(), and pgbuf_flush_chkpt_seq_list().
Definition at line 2133 of file porting.c.
Referenced by pgbuf_flush_seq_list().
int timeval_to_timespec | ( | struct timespec * | to, |
const struct timeval * | from | ||
) |
Definition at line 2173 of file porting.c.
References assert.
Referenced by dwb_wait_for_block_completion(), dwb_wait_for_strucure_modification(), and logpb_flush_pages().
char* trim | ( | char * | str | ) |
Definition at line 2260 of file porting.c.
Referenced by access_control_read_config_file(), access_control_read_ip_info(), access_control_repath_file(), broker_create_dir(), csql_do_session_cmd(), csql_get_column_width(), csql_set_trace(), dir_repath(), execute_test(), get_column_name_argument(), get_query_stmt_from_plan(), la_create_repl_filter(), logddl_create_dir(), make_node_info(), make_sql_stmt(), shard_metadata_read_conn(), shard_metadata_read_key(), showstmt_array_end_scan(), and uw_acl_make().
int vasprintf | ( | char ** | ptr, |
const char * | format, | ||
va_list | ap | ||
) |
Definition at line 936 of file porting.c.
References cubregex::count(), and NULL.
Referenced by asprintf(), pt_frob_error(), pt_frob_warning(), and strdup().