Freeciv-3.3
|
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include "astring.h"
#include "fcintl.h"
#include "ioz.h"
#include "log.h"
#include "mem.h"
#include "shared.h"
#include "support.h"
#include "inputfile.h"
Go to the source code of this file.
Data Structures | |
struct | inputfile |
Macros | |
#define | INF_DEBUG_FOUND FALSE |
#define | INF_DEBUG_NOT_FOUND FALSE |
#define | INF_MAGIC (0xabdc0132) /* Arbitrary */ |
#define | inf_log(inf, level, message, ...) |
#define | inf_warn(inf, message) inf_log(inf, LOG_NORMAL, "%s", message); |
Typedefs | |
typedef const char *(* | get_token_fn_t) (struct inputfile *inf) |
Variables | ||
struct { | ||
const char * name | ||
get_token_fn_t func | ||
} | tok_tab [INF_TOK_LAST] | |
Definition at line 85 of file inputfile.c.
Definition at line 86 of file inputfile.c.
Definition at line 143 of file inputfile.c.
Definition at line 88 of file inputfile.c.
Definition at line 148 of file inputfile.c.
Definition at line 116 of file inputfile.c.
Return TRUE if current pos is at end of current line.
Definition at line 335 of file inputfile.c.
Referenced by get_token_eol().
Check for an include command, which is an isolated line with: include "filename" If a file is included via this mechanism, returns 1, and sets up data appropriately: (*inf) will now correspond to the new file, which is opened but no data read, and inf->included_from is set to newly malloced memory which corresponds to the old file.
Definition at line 366 of file inputfile.c.
Referenced by read_a_line().
Get flag token comma, or nullptr if that is not next token.
Definition at line 804 of file inputfile.c.
Returns next entry name from inputfile. Skips white spaces and comments. Sets inputfile position after entry name.
Definition at line 695 of file inputfile.c.
If inputfile is at end-of-line, frees current line, and returns " ". If there is still something on that line, returns nullptr.
Definition at line 736 of file inputfile.c.
Returns section name in current position of inputfile. Returns nullptr if there is no section name on that position. Sets inputfile position after section name.
Definition at line 666 of file inputfile.c.
Get flag token for table end, or nullptr if that is not next token.
Definition at line 796 of file inputfile.c.
Get flag token for table start, or nullptr if that is not next token.
Definition at line 788 of file inputfile.c.
This one is more complicated; note that it may read in multiple lines.
Definition at line 812 of file inputfile.c.
Get a flag token of a single character, with optional preceding whitespace.
Definition at line 765 of file inputfile.c.
Referenced by get_token_comma(), get_token_table_end(), and get_token_table_start().
Return TRUE if have data for current line.
Definition at line 323 of file inputfile.c.
Referenced by get_token_entry_name(), get_token_eol(), get_token_section_name(), get_token_value(), get_token_white_char(), and inf_token().
Return TRUE if current pos is at end of file.
Definition at line 349 of file inputfile.c.
Referenced by secfile_from_input_file().
Close the file and free associated memory, included any partially recursed included files, and the memory allocated for 'inf' itself. Should only be used on an actually open inputfile. After this, the pointer should not be used.
Definition at line 303 of file inputfile.c.
Referenced by inf_close(), and secfile_from_input_file().
Close the file and free associated memory, but don't recurse included_from files, and don't free the actual memory where the inf record is stored (ie, the memory where the users pointer points to). This is used when closing an included file.
Definition at line 268 of file inputfile.c.
Referenced by inf_close(), and read_a_line().
int inf_discard_tokens | ( | struct inputfile * | inf, |
enum inf_token_type | type | ||
) |
Read as many tokens of specified type as possible, discarding the results; returns number of such tokens read and discarded.
Definition at line 650 of file inputfile.c.
Referenced by secfile_from_input_file().
Return the filename the inputfile was loaded as, or "(anonymous)" if this inputfile was loaded from a stream rather than from a file.
Definition at line 207 of file inputfile.c.
Referenced by inf_close(), inf_close_partial(), inf_from_stream(), and inf_log_str().
struct inputfile * inf_from_file | ( | const char * | filename, |
datafilename_fn_t | datafn | ||
) |
Open the file, and return an allocated, initialized structure. Returns nullptr if the file could not be opened.
Definition at line 220 of file inputfile.c.
Referenced by check_include(), and secfile_load_section().
struct inputfile * inf_from_stream | ( | fz_FILE * | stream, |
datafilename_fn_t | datafn | ||
) |
Open the stream, and return an allocated, initialized structure. Returns nullptr if the file could not be opened.
Definition at line 244 of file inputfile.c.
Referenced by inf_from_file(), and secfile_from_stream().
Return a detailed log message, including information on current line number etc. Message can be nullptr: then just logs information on where we are in the file.
Definition at line 571 of file inputfile.c.
Referenced by entry_from_inf_token(), and secfile_from_input_file().
Check sensible values for an opened inputfile.
Definition at line 183 of file inputfile.c.
Referenced by at_eol(), check_include(), have_line(), inf_at_eof(), inf_close(), inf_close_partial(), inf_log_str(), inf_sanity_check(), inf_token(), and read_a_line().
Returns token of given type from given inputfile.
Definition at line 611 of file inputfile.c.
Referenced by inf_discard_tokens(), and secfile_from_input_file().
Set values to zeros; should have free'd/closed everything before this if appropriate.
Definition at line 163 of file inputfile.c.
Referenced by inf_close_partial(), and inf_from_stream().
Return true if c is a 'comment' character: '#' or ';'
Definition at line 154 of file inputfile.c.
Referenced by check_include(), get_token_entry_name(), get_token_eol(), and get_token_value().
Read a new line into cur_line. Increments line_num and cur_line_pos. Returns FALSE if didn't read or other problem: treat as EOF. Strips newline from input.
Definition at line 475 of file inputfile.c.
Referenced by get_token_value(), inf_token(), and read_a_line().
get_token_fn_t func |
Definition at line 128 of file inputfile.c.
Referenced by choice_dialog::add_item(), connections_set_close_callback(), choice_dialog::execute_action(), fc_at_quick_exit(), fc_sidewidget::fc_sidewidget(), inf_token(), popup_action_selection(), popup_pillage_dialog(), popup_sabotage_dialog(), real_players_dialog_update(), fc_sidewidget::set_left_click(), fc_sidewidget::set_right_click(), fc_sidewidget::set_wheel_down(), fc_sidewidget::set_wheel_up(), spy_steal_shared(), try_default_city_action(), and try_default_unit_action().
Definition at line 127 of file inputfile.c.
Referenced by _by_name(), achievement_by_rule_name(), action_by_rule_name(), add_column(), advance_by_rule_name(), advance_by_translated_name(), ai_skill_callback(), pregame_options::ailevel_change(), ailevel_name(), api_edit_create_base(), api_edit_create_city(), api_edit_create_extra(), api_edit_create_owned_extra(), api_edit_create_road(), api_edit_remove_extra(), api_find_action_type_by_name(), api_find_counter_by_name(), api_find_player_by_name(), api_methods_tile_has_base(), api_methods_tile_has_extra(), api_methods_tile_has_road(), api_specenum_create_table(), audio_get_all_plugin_names(), audio_select_plugin(), boot_help_texts(), city_dialog::buy(), buy_callback(), change_build_target(), chatline_autocomplete(), check_leader_names(), check_player_or_user_name(), choice_dialog_add(), choice_dialog_start(), city_build(), city_dialog_update_building(), city_list_find_name(), city_name_compare(), city_name_suggestion(), city_rename(), city_style_name_translation(), city_style_rule_name(), client_handle_packet(), client_ss_by_name(), cmd_reply_no_such_conn(), cmd_reply_no_such_player(), comment_write(), compat_load_020400(), compat_load_020500(), compat_load_020600(), compat_load_030100(), compat_load_030200(), complain_ambiguous(), counter_by_rule_name(), counter_by_translated_name(), create_city(), create_city_for_player(), create_city_virtual(), create_command_newcomer(), create_command_pregame(), cut_client_connection(), delegate_command(), disaster_by_rule_name(), dlsend_packet_city_name_suggestion_info(), dsend_packet_city_name_suggestion_info(), dsend_packet_city_rename(), dsend_packet_nation_select_req(), dsend_packet_save_scenario(), dsend_packet_unit_do_action(), edit_buffer_copy(), entry_from_inf_token(), entry_from_token(), entry_new(), entry_set_name(), execute_orders(), extra_type_by_rule_name(), extra_type_by_translated_name(), extract_sequence_text(), extviewer_refresh_widgets(), finish_city(), game_city_by_name(), get_city_dialog_output_text(), fc_font::get_font(), get_help_item_spec(), get_output_name(), get_soundplugin_list(), get_ui_filename(), get_unique_guest_name(), global_worklist_load(), global_worklist_new(), global_worklist_set_name(), goods_by_rule_name(), goods_by_translated_name(), government_by_rule_name(), government_by_translated_name(), handle_chat_msg_req(), handle_city_name_suggestion_info(), handle_city_rename(), handle_nation_select_req(), handle_ruleset_select(), handle_save_scenario(), handle_unit_do_action(), improvement_by_rule_name(), improvement_by_translated_name(), inf_token(), insert_generated_text(), insert_veteran_help(), is_ascii_name(), is_default_city_name(), is_guest_name(), is_on_allowed_list(), is_reg_file_for_access(), is_safe_filename(), is_secfile_entry_name_valid(), is_valid_username(), kick_command(), load_nation_names(), load_ruleset_game(), load_ruleset_nations(), load_style_names(), lookup_option(), lookup_option_level(), lookup_req_list(), lookup_resource(), lookup_terrain(), luascript_do_string(), luascript_push_args(), makeup_connection_name(), mapimg_help(), match_prefix_full(), modpack_file_from_ruleset_cache(), modpack_file_from_tileset_cache(), modpack_tileset_target(), mpdb_installed_version(), mpdb_update_modpack(), multiplier_by_rule_name(), multipliers_init(), name_and_sort_items(), nation_by_rule_name(), nation_by_translated_plural(), nation_city_new(), nation_group_by_rule_name(), nation_group_new(), nation_leader_by_name(), nation_leader_new(), nation_set_by_rule_name(), net_lookup_service(), netfile_add_form_int(), netfile_add_form_str(), objprop_new(), objprop_refresh_widget(), observe_command(), option_dialog::option_dialog(), option_dialog_new(), option_dialog_popup(), option_dialog_popup(), optset_option_by_name(), city_production_delegate::paint(), pick_random_player_name(), player_by_name(), player_by_name_prefix(), player_by_user(), player_by_user_delegated(), player_name_check(), plocation_field_new(), popup_choice_dialog(), popup_hurry_production_dialog(), popup_pillage_dialog(), popup_worklist_editor(), property_editor_add_page(), property_filter_match(), property_page_new(), qtg_get_usable_themes_in_directory(), qtg_gui_load_theme(), races_leader_callback(), real_city_report_dialog_update_city(), real_conn_list_dialog_update(), real_info_city_report_dialog_update(), real_menus_update(), receive_packet_city_info_100(), receive_packet_city_name_suggestion_info_100(), receive_packet_city_rename_100(), receive_packet_city_short_info_100(), receive_packet_edit_city_100(), receive_packet_edit_player_100(), receive_packet_nation_select_req_100(), receive_packet_player_info_100(), receive_packet_ruleset_achievement_100(), receive_packet_ruleset_building_100(), receive_packet_ruleset_city_100(), receive_packet_ruleset_control_100(), receive_packet_ruleset_counter_100(), receive_packet_ruleset_disaster_100(), receive_packet_ruleset_extra_100(), receive_packet_ruleset_extra_flag_100(), receive_packet_ruleset_goods_100(), receive_packet_ruleset_government_100(), receive_packet_ruleset_impr_flag_100(), receive_packet_ruleset_multiplier_100(), receive_packet_ruleset_style_100(), receive_packet_ruleset_tech_100(), receive_packet_ruleset_tech_class_100(), receive_packet_ruleset_tech_flag_100(), receive_packet_ruleset_terrain_100(), receive_packet_ruleset_terrain_flag_100(), receive_packet_ruleset_unit_100(), receive_packet_ruleset_unit_class_100(), receive_packet_ruleset_unit_class_flag_100(), receive_packet_ruleset_unit_flag_100(), receive_packet_save_scenario_100(), receive_packet_scenario_info_100(), receive_packet_server_setting_const_100(), receive_packet_unit_do_action_100(), redraw_unit_info_label(), refresh_city_names(), refresh_production_label(), remove_player_command(), request_do_action(), research_advance_name_translation(), research_advance_rule_name(), resend_desired_settable_options(), rscompat_names(), ruleset_cache_listcmd_cb(), ruleset_entry_changed(), ruleset_load_names(), ruleset_selected(), save_actions_ruleset(), save_buildings_ruleset(), save_cities_ruleset(), save_effects_ruleset(), save_game_ruleset(), save_governments_ruleset(), save_name_translation(), save_nations_ruleset(), save_ruleset(), save_styles_ruleset(), save_techs_ruleset(), save_terrain_ruleset(), save_units_ruleset(), science_report_combo_get_active(), search_for_city_name(), secfile_lookup_enum_data(), secfile_lookup_enum_default_data(), secfile_section_by_name(), secfile_section_new(), section_entry_bool_new(), section_entry_by_name(), section_entry_filereference_new(), section_entry_float_new(), section_entry_int_new(), section_entry_str_new(), section_set_name(), send_ruleset_cities(), send_ruleset_team_names(), server_handle_packet(), server_option_bitwise_set(), server_option_enum_set(), server_player_name_is_allowed(), server_player_set_name(), server_player_set_name_full(), server_setting_by_name(), server_ss_by_name(), set_ai_level(), set_ai_level_named(), set_default_ai_type_name(), fc_font::set_font(), set_user_extra_flag_name(), set_user_impr_flag_name(), set_user_tech_flag_name(), set_user_terrain_flag_name(), set_user_unit_class_flag_name(), set_user_unit_type_flag_name(), settable_option_upgrade_value(), setting_bitwise_bit(), setting_bitwise_secfile_str(), setting_bitwise_to_str(), setting_bool_secfile_str(), setting_bool_to_str(), setting_by_name(), setting_enum_secfile_str(), setting_enum_to_str(), setting_enum_val(), setting_match_prefix_base(), setting_ruleset_one(), settings_game_load(), settings_ruleset(), mpgui::setup_list(), setup_modpack_list(), setup_modpack_list(), setup_modpack_list(), setup_modpack_list(), setup_modpack_list(), sex_by_name(), sg_load_player_city(), sg_load_player_city(), sg_load_player_main(), sg_load_player_main(), sg_load_player_units(), sg_load_player_units(), sg_load_ruledata(), sg_load_ruledata(), show_full_citybar(), show_small_citybar(), signal_callback_new(), sn_free(), special_by_rule_name(), specialist_by_rule_name(), specialist_by_translated_name(), srv_ready(), ssetv_by_rule_name(), style_by_rule_name(), take_command(), tech_class_by_rule_name(), technology_load(), technology_load(), technology_save(), terrain_by_rule_name(), terrain_by_translated_name(), text_tag_init_from_sequence(), theme_lookup_sprite_tag_alt(), themespec_reread(), tiles_lookup_sprite_tag_alt(), tileset_setup_citizen_types(), tilespec_reread(), timer_new(), timer_renew(), tolua_fcdb_fcdb_option00(), tolua_game_find_action02(), tolua_game_find_counter00(), tolua_game_find_player00(), tolua_game_Tile_has_base00(), tolua_game_Tile_has_extra00(), tolua_game_Tile_has_road00(), tolua_server_edit_city_create00(), tolua_server_edit_create_base00(), tolua_server_edit_create_extra00(), tolua_server_edit_create_owned_extra00(), tolua_server_edit_create_road00(), tolua_server_edit_remove_extra00(), tool_init(), trade_route_cancelling_type_by_name(), trade_route_type_by_name(), transfer_city_units(), unit_do_action(), unit_perform_action(), unit_type_by_rule_name(), unit_type_by_translated_name(), city_dialog::update_counters_table(), map_view::update_font(), info_tile::update_font(), update_info_label(), user_username(), valid_ruleset_filename(), worklist_load(), and worklist_load().
struct { ... } tok_tab[INF_TOK_LAST] |
Referenced by inf_token().