Freeciv-3.3
|
#include <freeciv_config.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
Go to the source code of this file.
Macros | |
#define | TRUE true |
#define | FALSE false |
#define | nullptr NULL |
#define | bool unsigned int |
#define | true 1 |
#define | false 0 |
#define | __bool_true_false_are_defined 1 |
#define | fc__attribute(x) |
#define | fc__warn_unused_result |
#define | fc__fallthrough |
#define | fc__noreturn |
#define | fc__unreachable(_cond_) fc_assert(!(_cond_)) |
#define | RETURN_VALUE_AFTER_EXIT(_val_) |
#define | VAR_ARG_CONST const |
#define | fc_strncmp(_s1_, _s2_, _len_) strncmp(_s1_, _s2_, _len_) |
#define | sz_strlcpy(dest, src) ((void) fc_strlcpy((dest), (src), sizeof(dest))) |
#define | sz_strlcat(dest, src) ((void) fc_strlcat((dest), (src), sizeof(dest))) |
Typedefs | |
typedef int | fc_errno |
#define sz_strlcat | ( | dest, | |
src | |||
) | ((void) fc_strlcat((dest), (src), sizeof(dest))) |
#define sz_strlcpy | ( | dest, | |
src | |||
) | ((void) fc_strlcpy((dest), (src), sizeof(dest))) |
Is the support module currently in usable state?
Definition at line 1369 of file support.c.
Referenced by audio_shutdown_atexit().
Count length of string without possible surrounding quotes.
Definition at line 356 of file support.c.
Referenced by conn_by_user_prefix(), and player_by_name_prefix().
Set quick_exit() callback if possible.
Definition at line 1317 of file support.c.
Referenced by client_main().
basename() replacement that always takes const parameter. POSIX basename() modifies its parameter, GNU one does not. Ideally we would like to use GNU one, when available, directly without extra string copies.
Definition at line 1287 of file support.c.
Referenced by cmdhelp_new().
Replace the spaces by line breaks when the line length is over the desired one. 'str' is modified. Returns number of lines in modified s.
Definition at line 1135 of file support.c.
Referenced by astr_break_lines(), create_races_dialog(), manual_commands(), manual_settings(), option_widget_new(), show_help_command(), show_help_intro(), show_help_option(), show_nationsets(), show_ruleset_info(), and show_settings_one().
Wrapper function for fopen() with filename conversion to local encoding on Windows.
Definition at line 505 of file support.c.
Referenced by fc_querysocket(), fz_from_file(), img_save_ppm(), log_civ_score_now(), log_real(), manual_start(), netfile_download_file(), rank_users(), read_init_script_real(), save_script_lua(), script_server_load_file(), write_chatline_content(), and write_init_script().
Returns last error code.
Definition at line 592 of file support.c.
Referenced by begin_lanserver_scan(), fc_init_network(), fc_nonblock(), fileinfolist(), find_next_free_port(), fz_strerror(), get_lanserver_announcement(), make_dir(), read_from_connection(), send_lanserver_response(), server_accept_connection(), server_open_socket(), server_sniff_all_input(), setup_interrupt_handlers(), and try_to_connect().
Call gethostname() if supported, else just returns -1.
Definition at line 1007 of file support.c.
Referenced by establish_new_connection(), and send_lanserver_response().
Wrapper function to work around broken libc implementations. See above.
Definition at line 1196 of file support.c.
Referenced by find_option(), get_token_value(), handle_stdin_input_real(), is_legal_table_entry_name(), is_secfile_entry_name_valid(), and year_suffix().
Wrapper function to work around broken libc implementations. See above.
Definition at line 1207 of file support.c.
Referenced by extract_sequence_text(), fc_vsnprintcf(), and is_legal_table_entry_name().
Wrapper function to work around broken libc implementations. See above.
Definition at line 1218 of file support.c.
Referenced by entry_from_token(), extract_escapes(), get_token_value(), is_good_password(), is_valid_username(), str_to_float(), str_to_int(), and str_to_uint().
Wrapper function to work around broken libc implementations. See above.
Definition at line 1240 of file support.c.
Referenced by check_include(), conn_pattern_from_string(), extract_sequence_text(), fc_break_lines(), find_option(), get_token_entry_name(), get_token_eol(), get_token_value(), get_token_white_char(), is_plain_public_message(), load_city_name_list(), remove_trailing_spaces(), skip_leading_spaces(), str_to_float(), str_to_int(), and str_to_uint().
Wrapper function to work around broken libc implementations. See above.
Definition at line 1251 of file support.c.
Referenced by is_good_password().
Thread safe localtime() replacement
Definition at line 1301 of file support.c.
Referenced by real_luaconsole_append(), real_output_window_append(), and send_pending_events().
Wrapper function for gzopen() with filename conversion to local encoding on Windows. Wrapper function for remove() with filename conversion to local encoding on Windows.
Definition at line 555 of file support.c.
Referenced by handle_single_want_hack_reply(), and save_dialog_response_callback().
Wrapper function for stat() with filename conversion to local encoding on Windows.
Definition at line 574 of file support.c.
Referenced by fileinfolist_infix(), fileinfoname(), get_usable_themes_in_directory(), is_reg_file_for_access(), load_install_info_lists(), lua_command(), script_server_load_file(), and secfile_load().
Compare strings like strcmp(), but ignoring case. UTF8 aware.
Definition at line 186 of file support.c.
Referenced by achievement_by_rule_name(), action_by_rule_name(), advance_by_rule_name(), ai_level_help(), ai_level_name_update_cb(), ai_type_by_name(), api_edit_trait_mod_set(), api_edit_unit_hitpoints(), api_edit_unit_kill(), api_effects_city_bonus(), api_effects_player_bonus(), api_effects_tile_bonus(), api_effects_unit_bonus(), api_effects_unit_vs_tile_bonus(), api_effects_world_bonus(), api_find_role_unit_type(), api_methods_nation_trait_default(), api_methods_nation_trait_max(), api_methods_nation_trait_min(), api_methods_player_has_flag(), api_methods_player_trait(), api_methods_player_trait_base(), api_methods_player_trait_current_mod(), api_methods_unit_type_has_flag(), api_methods_unit_type_has_role(), api_utilities_str2dir(), blocked_by_old_name_3_3(), boot_help_texts(), cancelvote_command(), check_leader_names(), check_sprite_type(), city_list_find_name(), city_name_compare(), city_style_by_rule_name(), client_main(), cmdarg_compare(), cmdlevel_command(), compar_event_message_texts(), compat_load_020400(), compat_load_020500(), compat_load_020600(), compat_load_030000(), compat_load_030100(), compat_load_030200(), compat_load_030300(), conn_by_user(), conn_pattern_from_string(), counter_by_rule_name(), counter_by_translated_name(), create_diplomacy_dialog(), delegate_command(), diplrel_by_rule_name(), disaster_by_rule_name(), download_modpack_list(), download_modpack_recursive(), tab_achievement::edit_type(), effect_edit::effect_type_menu(), event_cache_load(), extra_type_by_rule_name(), fc_cmp(), fc_stricoll(), gen_action_name_update_cb(), edit_impr::genus_menu(), get_lan_server_list(), get_tag_score(), goods_by_rule_name(), government_by_rule_name(), handle_login_request(), improvement_by_rule_name(), init_character_encodings(), is_default_city_name(), is_on_allowed_list(), is_valid_username(), load_action_range_max(), load_building_names(), load_city_name_list(), load_install_info_list(), load_ruleset_buildings(), load_ruleset_effects(), load_ruleset_game(), load_ruleset_nations(), load_ruleset_techs(), load_ruleset_terrain(), load_ruleset_units(), load_tech_names(), load_terrain_names(), load_unit_names(), lookup_cbonus_list(), lookup_option_level(), main(), mapimg_define(), message_options_load(), metaconnection_command(), modpack_file_from_ruleset_cache(), modpack_file_from_tileset_cache(), modpack_tileset_target(), multiplier_by_rule_name(), effect_edit::multiplier_menu(), nation_by_rule_name(), nation_group_by_rule_name(), nation_leader_by_name(), nation_set_by_rule_name(), ordered_gfx_fextensions(), output_type_by_identifier(), player_by_name(), player_by_user(), player_by_user_delegated(), player_name_check(), playercolor_command(), req_from_str(), req_edit::req_range_menu(), req_edit::req_type_menu(), rscompat_effect_name_3_3(), rscompat_names(), rscompat_universal_name_3_3(), rscompat_utype_flag_name_3_3(), save_game_ruleset(), secfile_lookup_enum_data(), server_player_name_is_allowed(), set_ai_level_named(), setcompat_name_generic(), setcompat_S3_2_val_from_S3_1(), setting_bitwise_secfile_str(), setting_ruleset_one(), settings_game_load(), settings_list_cmp(), sex_by_name(), sg_load_game(), sg_load_player_cities(), sg_load_player_cities(), sg_load_player_city(), sg_load_player_main(), sg_load_player_main(), sg_load_player_unit(), sg_load_player_unit(), sg_load_player_vision_city(), sg_load_savefile(), sg_load_savefile(), sg_load_treaties(), sg_load_treaties(), specialist_by_rule_name(), style_by_rule_name(), team_slot_by_rule_name(), tech_class_by_rule_name(), technology_load(), technology_load(), terrain_by_rule_name(), tileset_read_toplevel(), tileset_setup_extra(), trade_route_cancelling_type_by_name(), trade_route_type_by_name(), ui_name_old_name_3_3(), unit_class_by_rule_name(), unit_type_by_rule_name(), universal_by_rule_name(), and universal_value_from_str().
Return the needle in the haystack (or nullptr). Naive implementation.
Definition at line 437 of file support.c.
Referenced by property_filter_match().
Wrapper function for strcoll().
Definition at line 471 of file support.c.
Referenced by cmp_func(), compare_file_name_ptrs(), compare_fileinfo_name(), compare_strings(), compare_strings_ptrs(), compare_strings_strvec(), and sort_advance_names().
Return a string which describes a given error (errno-style.) The string is converted as necessary from the local_encoding to internal_encoding, for inclusion in translations. May be subsequently converted back to local_encoding for display.
Note that this is not the reentrant form.
Definition at line 609 of file support.c.
Referenced by begin_lanserver_scan(), fc_init_network(), fc_nonblock(), fileinfolist(), find_next_free_port(), fz_strerror(), get_lanserver_announcement(), read_from_connection(), send_lanserver_response(), server_accept_connection(), server_open_socket(), server_sniff_all_input(), setup_interrupt_handlers(), and try_to_connect().
Wrapper function for stricoll().
Definition at line 485 of file support.c.
Referenced by cmp_name().
fc_strlcat() provides utf-8 version of (non-standard) function strlcat() It is intended as more user-friendly version of strncat(), in particular easier to use safely and correctly, and ensuring nul-terminated results while being able to detect truncation.
Definition at line 822 of file support.c.
Referenced by boot_help_texts(), client_start_server(), get_city_dialog_production_full(), get_effect_req_text(), handle_page_msg_part(), handle_ruleset_description_part(), helptext_building(), helptext_goods(), helptext_government(), helptext_specialist(), historian_generic(), load_ruleset_nations(), meswin_add(), rebuild_citydlg_title_str(), req_text_insert(), req_text_insert_nl(), setting_bitwise_to_str(), tile_info_pollution(), and universal_name_translation().
fc_strlcpy() provides utf-8 version of (non-standard) function strlcpy() It is intended as more user-friendly version of strncpy(), in particular easier to use safely and correctly, and ensuring nul-terminated results while being able to detect truncation.
n is the full size of the destination buffer, including space for trailing nul, and including the pre-existing string for fc_strlcat(). Thus can eg use sizeof(buffer), or exact size malloc-ed.
Result is always nul-terminated, whether or not truncation occurs, and the return value is the strlen the destination would have had without truncation. I.e., a return value >= input n indicates truncation occurred.
Not sure about the asserts below, but they are easier than trying to ensure correct behaviour on strange inputs. In particular note that n == 0 is prohibited (e.g., since there must at least be room for a nul); could consider other options.
Definition at line 777 of file support.c.
Referenced by astr_vadd_at(), capitalized_string(), client_conn_close_callback(), client_option_font_set(), client_option_str_set(), client_start_server(), cmafec_preset_add(), compat_load_030200(), configure_single(), conn_pattern_from_string(), create_clause_menu(), desired_settable_options_update(), edit_buffer_get_status_string(), extract_sequence_text(), fc_basename(), fc_strlcat(), fc_utf8_validate_rep_len(), find_option(), fit_nationset_to_players(), get_city_dialog_production(), get_city_dialog_production_full(), get_city_dialog_production_row(), get_city_mapview_name_and_growth(), get_common_prefix(), get_full_nation(), get_full_username(), get_prod_complete_string(), get_server_address(), get_tokens(), get_unique_guest_name(), handle_chat_msg_req(), handle_ruleset_nation(), handle_ruleset_summary(), helptext_advance(), helptext_unit(), is_allowed_to_take(), load_ruleset_game(), loud_strlcpy(), main(), mapimg_def2str(), mapimg_define(), musicspec_load(), name_and_sort_items(), plrdata_slot_replace(), popup_load_game_dialog(), popup_newcity_dialog(), popup_worklist_editor(), property_page_set_store_value(), req_vec_problem_new_transl(), research_pretty_name(), ruleset_cache_sendclient_cb(), scan_score_log(), secfile_lookup_bitwise_enum_default_full(), secfile_lookup_bitwise_enum_full(), secfile_lookup_enum_data(), secfile_lookup_enum_default_data(), server_player_name_is_allowed(), server_player_set_name_full(), settable_options_load(), setting_bitwise_to_str(), setting_bitwise_validate_base(), setting_bool_to_str(), setting_enum_to_str(), setting_game_set(), setting_set_to_default(), setting_str_set(), setting_str_to_str(), settings_game_load(), sg_save_map_startpos(), team_pretty_name(), tileset_lookup_sprite_tags(), tileset_read_toplevel(), tileset_use_preferred_theme(), try_to_connect(), update_cma_preset_list(), and user_username().
Compare strings like strncmp(), but ignoring case. i.e. only compares first n chars. UTF8 aware.
Definition at line 235 of file support.c.
Referenced by api_fcdb_option(), check_player_or_user_name(), command_named(), delegate_command(), entry_from_token(), extract_sequence_text(), fc_strcasestr(), fcdb_command(), handle_event(), is_guest_name(), log_parse_level_str(), lookup_option(), lua_command(), mapimg_command(), reset_command(), setting_match_prefix_base(), show_help(), show_list(), show_settings(), text_tag_init_from_sequence(), and vote_command().
Compare strings like strncasecmp() but ignoring surrounding quotes in either string.
Definition at line 377 of file support.c.
Referenced by conn_by_user_prefix(), and player_by_name_prefix().
Replace 'search' by 'replace' within 'str'. sizeof(str) should be large enough for the modified value of 'str'. Returns TRUE if the replacement was successful.
Definition at line 720 of file support.c.
Referenced by fc_strrep_resize().
Replace 'search' by 'replace' within 'str'. If needed 'str' is resized using realloc() to fit the modified string. The new pointer to the string is returned.
Definition at line 681 of file support.c.
Referenced by html_special_chars().
Free misc resources allocated by the support module.
Definition at line 1347 of file support.c.
Referenced by libfreeciv_free().
Initialize support module.
Definition at line 1329 of file support.c.
Referenced by libfreeciv_init().
Wrapper function to work around broken libc implementations. See above.
Definition at line 1273 of file support.c.
Referenced by cmdarg_compare(), events_init(), fc_strncasequotecmp(), and load_city_name_list().
Wrapper function to work around broken libc implementations. See above.
Definition at line 1262 of file support.c.
Referenced by capitalized_string(), and server_player_set_name_full().
Suspend execution for the specified number of microseconds.
Definition at line 639 of file support.c.
Referenced by client_start_server(), move_unit_map_canvas(), put_nuke_mushroom_pixmaps(), and timer_usleep_since_start().
Return whether the program is currently running on a bigendian system.
Definition at line 235 of file support.h.
Referenced by create_sprite(), create_surfaces(), get_first_pixel(), get_pixel(), get_smaller_surface_rect(), load_gfxfile(), pixmap_put_overlay_tile_draw(), sprite_get_bounding_box(), and surface_get_pixbuf().
Returns TRUE iff the file is a regular file or a link to a regular file or write_access is TRUE and the file doesn't exists yet.
Definition at line 1120 of file support.c.
Referenced by fz_from_file(), lua_command(), manual_start(), read_init_script_real(), and write_init_script().
Copies a string and convert the following characters:
Definition at line 294 of file support.c.
Referenced by entry_to_file().
Copies a string. Backslash followed by a genuine newline always removes the newline. If full_escapes is TRUE:
Definition at line 330 of file support.c.
Referenced by entry_from_token().