Beispiel #1
0
		virtual void set_bool(std::string path, std::string key, bool value) {
			get_impl()->set_bool(path, key, value);
		}
Beispiel #2
0
std::vector <task> task_container::list_tasks(void) const
{
    return get_impl()->list_tasks();
}
Beispiel #3
0
void task_container::cancel(void)
{
    get_impl()->cancel();
}
Beispiel #4
0
constexpr int get_impl (float, Tag, ic<N>, int C = get_impl (0, Tag {}, ic<N-1> {})) { // try next if (B) failed!
  return C; 
}
Beispiel #5
0
void task_container::add_task (task t)
{
    get_impl()->add_task(t);
}
/* returns true if size of the chunk file is off the limit. */
bool textual_dict_gen_t::is_chunk_file_full(void) const
{
	return static_cast<size_t>(ftell(get_impl(xmlfilechunk))) >= chunk_size;
}
Beispiel #7
0
int GeneratorBase::run(int argc, char *argv[])
{
#ifdef HAVE_LOCALE_H
	setlocale(LC_ALL, "");
#endif
	gint verbose = 2;
	gboolean show_version = FALSE, show_fmt = FALSE;
	glib::CharStr work_dir, basename;
	glib::CharStrArr generator_opts;

	static GOptionEntry entries[] = {
		{ "version", 'v', 0, G_OPTION_ARG_NONE, &show_version,
		  _("print version information and exit"), NULL },		
		{ "output-format", 'o', 0, G_OPTION_ARG_NONE, &show_fmt,
		  _("display supported output format and exit"), NULL },
		{ "work-dir", 'd', 0, G_OPTION_ARG_STRING, get_addr(work_dir),
		  _("use parameter as current directory"), NULL },
		{ "verbose", 0, 0, G_OPTION_ARG_INT, &verbose,
		  _("set level of verbosity"), NULL },
		{ "basename", 0, 0, G_OPTION_ARG_STRING, get_addr(basename),
		  _("base for name of newly create dictionary"), NULL },
		{ "generator-option", 0, 0, G_OPTION_ARG_STRING_ARRAY,
			get_addr(generator_opts), _("\"option_name=option_value\""),
			NULL },
		{ NULL },
	};

	logger_.reset(new Logger);
	glib::OptionContext opt_cnt(g_option_context_new(_("file1 file2...")));
	g_option_context_add_main_entries(get_impl(opt_cnt), entries, NULL);
	g_option_context_set_help_enabled(get_impl(opt_cnt), TRUE);
	glib::Error err;
	if (!g_option_context_parse(get_impl(opt_cnt), &argc, &argv, get_addr(err))) {
		g_warning(_("Options parsing failed: %s\n"), err->message);
		return EXIT_FAILURE;
	}
	logger_->set_verbosity(verbose);

	if (show_version) {
		g_message(version_.c_str());
		g_message("\n");
		return EXIT_SUCCESS;
	}
	if (show_fmt) {
		g_message(format_.c_str());
		g_message("\n");
		return EXIT_SUCCESS;
	}

	if (basename)
		dict_ops_->set_basename(get_impl(basename));
	std::string str_workdir;
	if (work_dir)
		str_workdir = get_impl(work_dir);

	if (generator_opts) {
		gchar **popts = get_impl(generator_opts);
		while (*popts) {
			if (!parse_option(*popts))
				return EXIT_FAILURE;
			++popts;
		}
	}

	return run(argv[0], str_workdir);
}
std::vector<std::string>
   entity_data_set::list_related_entity_names() const
{
   return get_impl()->list_related_entity_names();
}
std::string entity_data_set::get_information_system_url() const
{
   return get_impl()->get_information_system_url();
}
Beispiel #10
0
int main(int argc, char *argv[]) try {
    setlocale(LC_ALL, "");
#if ENABLE_NLS
    bindtextdomain("sdcv",
                   //"./locale"//< for testing
                   GETTEXT_TRANSLATIONS_PATH //< should be
                   );
    textdomain("sdcv");
#endif

    gboolean show_version = FALSE;
    gboolean show_list_dicts = FALSE;
    glib::StrArr use_dict_list;
    gboolean non_interactive = FALSE;
    gboolean json_output = FALSE;
    gboolean no_fuzzy = FALSE;
    gboolean utf8_output = FALSE;
    gboolean utf8_input = FALSE;
    glib::CharStr opt_data_dir;
    gboolean only_data_dir = FALSE;
    gboolean colorize = FALSE;

    const GOptionEntry entries[] = {
        { "version", 'v', 0, G_OPTION_ARG_NONE, &show_version,
          _("display version information and exit"), nullptr },
        { "list-dicts", 'l', 0, G_OPTION_ARG_NONE, &show_list_dicts,
          _("display list of available dictionaries and exit"), nullptr },
        { "use-dict", 'u', 0, G_OPTION_ARG_STRING_ARRAY, get_addr(use_dict_list),
          _("for search use only dictionary with this bookname"),
          _("bookname") },
        { "non-interactive", 'n', 0, G_OPTION_ARG_NONE, &non_interactive,
          _("for use in scripts"), nullptr },
        { "json-output", 'j', 0, G_OPTION_ARG_NONE, &json_output,
          _("print the result formatted as JSON"), nullptr },
        { "exact-search", 'e', 0, G_OPTION_ARG_NONE, &no_fuzzy,
          _("do not fuzzy-search for similar words, only return exact matches"), nullptr },
        { "utf8-output", '0', 0, G_OPTION_ARG_NONE, &utf8_output,
          _("output must be in utf8"), nullptr },
        { "utf8-input", '1', 0, G_OPTION_ARG_NONE, &utf8_input,
          _("input of sdcv in utf8"), nullptr },
        { "data-dir", '2', 0, G_OPTION_ARG_STRING, get_addr(opt_data_dir),
          _("use this directory as path to stardict data directory"),
          _("path/to/dir") },
        { "only-data-dir", 'x', 0, G_OPTION_ARG_NONE, &only_data_dir,
          _("only use the dictionaries in data-dir, do not search in user and system directories"), nullptr },
        { "color", 'c', 0, G_OPTION_ARG_NONE, &colorize,
          _("colorize the output"), nullptr },
        {},
    };

    glib::Error error;
    GOptionContext *context = g_option_context_new(_(" words"));
    g_option_context_set_help_enabled(context, TRUE);
    g_option_context_add_main_entries(context, entries, nullptr);
    const gboolean parse_res = g_option_context_parse(context, &argc, &argv, get_addr(error));
    g_option_context_free(context);
    if (!parse_res) {
        fprintf(stderr, _("Invalid command line arguments: %s\n"),
                error->message);
        return EXIT_FAILURE;
    }

    if (show_version) {
        printf(_("Console version of Stardict, version %s\n"), gVersion);
        return EXIT_SUCCESS;
    }

    const gchar *stardict_data_dir = g_getenv("STARDICT_DATA_DIR");
    std::string data_dir;
    if (!opt_data_dir) {
        if (!only_data_dir) {
            if (stardict_data_dir)
                data_dir = stardict_data_dir;
            else
                data_dir = "/usr/share/stardict/dic";
        }
    } else {
        data_dir = get_impl(opt_data_dir);
    }

    const char *homedir = g_getenv("HOME");
    if (!homedir)
        homedir = g_get_home_dir();

    std::list<std::string> dicts_dir_list;
    if (!only_data_dir)
        dicts_dir_list.push_back(std::string(homedir) + G_DIR_SEPARATOR + ".stardict" + G_DIR_SEPARATOR + "dic");
    dicts_dir_list.push_back(data_dir);
    if (show_list_dicts) {
        list_dicts(dicts_dir_list, json_output);
        return EXIT_SUCCESS;
    }

    std::list<std::string> disable_list;

    std::map<std::string, std::string> bookname_to_ifo;
    for_each_file(dicts_dir_list, ".ifo", std::list<std::string>(), std::list<std::string>(),
                  [&bookname_to_ifo](const std::string &fname, bool) {
                      DictInfo dict_info;
                      const bool load_ok = dict_info.load_from_ifo_file(fname, false);
                      if (!load_ok)
                          return;
                      bookname_to_ifo[dict_info.bookname] = dict_info.ifo_file_name;
                  });

    std::list<std::string> order_list;
    if (use_dict_list != nullptr) {
        for (auto &&x : bookname_to_ifo) {
            gchar **p = get_impl(use_dict_list);
            for (; *p != nullptr; ++p)
                if (x.first.compare(*p) == 0) {
                    break;
                }
            if (*p == nullptr) {
                disable_list.push_back(x.second);
            }
        }

        // add bookname to list
        gchar **p = get_impl(use_dict_list);
        while (*p) {
            order_list.push_back(bookname_to_ifo.at(*p));
            ++p;
        }
    } else {
        const std::string odering_cfg_file = std::string(homedir) + G_DIR_SEPARATOR_S ".sdcv_ordering";
        FILE *ordering_file = fopen(odering_cfg_file.c_str(), "r");
        if (ordering_file != nullptr) {
            std::string line;
            while (stdio_getline(ordering_file, line)) {
                order_list.push_back(bookname_to_ifo.at(line));
            }
            fclose(ordering_file);
        }
    }

    const std::string conf_dir = std::string(g_get_home_dir()) + G_DIR_SEPARATOR + ".stardict";
    if (g_mkdir(conf_dir.c_str(), S_IRWXU) == -1 && errno != EEXIST) {
        fprintf(stderr, _("g_mkdir failed: %s\n"), strerror(errno));
    }

    Library lib(utf8_input, utf8_output, colorize, json_output, no_fuzzy);
    lib.load(dicts_dir_list, order_list, disable_list);

    std::unique_ptr<IReadLine> io(create_readline_object());
    if (optind < argc) {
        for (int i = optind; i < argc; ++i)
            if (!lib.process_phrase(argv[i], *io, non_interactive)) {
                return EXIT_FAILURE;
            }
    } else if (!non_interactive) {

        std::string phrase;
        while (io->read(_("Enter word or phrase: "), phrase)) {
            if (!lib.process_phrase(phrase.c_str(), *io))
                return EXIT_FAILURE;
            phrase.clear();
        }

        putchar('\n');
    } else {
        fprintf(stderr, _("There are no words/phrases to translate.\n"));
    }
    return EXIT_SUCCESS;
} catch (const std::exception &ex) {
    fprintf(stderr, "Internal error: %s\n", ex.what());
    exit(EXIT_FAILURE);
}
//Return a copy of the entities in this entity_data_set
std::vector<saga::isn::entity_data> entity_data_set::get_data() const
{
   return get_impl()->get_data();
}
Beispiel #12
0
string method_properties::get_property( int num_opt, const string& name ) const
{
  // MSVC 6.0 has issues with the get_impl<impl>() syntax  
  return get_impl( (impl2*)NULL )->get_property( num_opt, name );
}
Beispiel #13
0
		virtual string_list get_keys(std::string path) {
			return get_impl()->get_keys(path);
		}
Beispiel #14
0
		virtual string_list get_sections(std::string path) {
			return get_impl()->get_sections(path);
		}
int textual_dict_gen_t::contents_puts(const char* str)
{
	int res = fputs(str, get_impl(use_chunk_file() ? xmlfilechunk : xmlfilemain));
	return (res < 0) ? EXIT_FAILURE : EXIT_SUCCESS;
}
std::size_t entity_data_set::get_entity_count() const
{
   return get_impl()->get_entity_count();
}
int textual_dict_gen_t::generate_chunk_file_footer(void)
{
	const char * str = "</contents>\n";
	int res = fputs(str, get_impl(xmlfilechunk));
	return (res < 0) ? EXIT_FAILURE : EXIT_SUCCESS;
}
Beispiel #18
0
 XBT_ATTRIB_DEPRECATED_v323("Please use Actor::get_impl()") kernel::actor::ActorImpl* getImpl() { return get_impl(); }
Beispiel #19
0
bool DictInfo::load_from_ifo_file(const std::string& ifofilename,
	DictInfoType infotype)
{
	clear();
	ifo_file_name=ifofilename;
	set_infotype(infotype);
	glib::CharStr buffer;
	glib::Error error;
	if (!g_file_get_contents(ifo_file_name.c_str(), get_addr(buffer), NULL, get_addr(error))) {
		g_critical("Load %s failed. Error: %s.", ifo_file_name.c_str(), error->message);
		return false;
	}
	const gchar *p1 = get_impl(buffer);
	
	if(g_str_has_prefix(p1, UTF8_BOM))
		p1 += 3;
	if(!g_utf8_validate(p1, -1, NULL)) {
		g_critical("Load %s failed: Invalid UTF-8 encoded text.", ifo_file_name.c_str());
		return false;
	}
	lineno = 1;

	const gchar *magic_data = NULL;
	if(infotype == DictInfoType_NormDict)
		magic_data = NORM_DICT_MAGIC_DATA;
	else if(infotype == DictInfoType_TreeDict)
		magic_data = TREE_DICT_MAGIC_DATA;
	else if(infotype == DictInfoType_ResDb)
		magic_data = RES_DB_MAGIC_DATA;
	else
		return false;
	if (!g_str_has_prefix(p1, magic_data)) {
		g_critical("Load %s failed: Incorrect magic data.", ifo_file_name.c_str());
		if(g_str_has_prefix(p1, NORM_DICT_MAGIC_DATA))
			g_message("File '%s' is an index-based dictionary.", ifo_file_name.c_str());
		else if(g_str_has_prefix(p1, TREE_DICT_MAGIC_DATA))
			g_message("File '%s' is a tree dictionary.", ifo_file_name.c_str());
		else if(g_str_has_prefix(p1, RES_DB_MAGIC_DATA))
			g_message("File '%s' is a resource database.", ifo_file_name.c_str());
		else
			g_message("File '%s' is not a StarDict dictionary or it's broken.", ifo_file_name.c_str());
		return false;
	}
	p1 += strlen(magic_data);
	p1 = skip_new_line(p1);
	if(!p1) {
		g_critical("Load %s failed: Incorrect magic data.", ifo_file_name.c_str());
		return false;
	}

	std::string key, value;
	while(true) {
		++lineno;
		p1 = get_key_value(p1, key, value);
		if(!p1)
			break;

		// version must the first option
		if(!is_version()) {
			if(key != "version") {
				g_critical("Load %s failed: \"version\" must be the first option.", ifo_file_name.c_str());
				return false;
			}
		}
		if(key == "version") {
			if(!check_option_duplicate(f_version, "version"))
				continue;
			set_version(value);
			if(infotype == DictInfoType_NormDict) {
				if(version != "2.4.2" && version != "3.0.0") {
					g_critical("Load %s failed: Unknown version.", ifo_file_name.c_str());
					return false;
				}
			} else if(infotype == DictInfoType_TreeDict) {
				if(version != "2.4.2") {
					g_critical("Load %s failed: Unknown version.", ifo_file_name.c_str());
					return false;
				}
			} else if(infotype == DictInfoType_ResDb) {
				if(version != "3.0.0") {
					g_critical("Load %s failed: Unknown version.", ifo_file_name.c_str());
					return false;
				}
			}
		} else if(key == "idxoffsetbits") {
			if(!check_option_duplicate(f_idxoffsetbits, "idxoffsetbits"))
				continue;
			if(value != "32") {
				// TODO
				g_critical("Load %s failed: idxoffsetbits != 32 not supported presently.",
					ifo_file_name.c_str());
				return false;
			}
		} else if(key == "wordcount" && (infotype == DictInfoType_NormDict
			|| infotype == DictInfoType_TreeDict)) {
			if(!check_option_duplicate(f_wordcount, "wordcount"))
				continue;
			set_wordcount(atol(value.c_str()));
		} else if(key == "filecount" && infotype == DictInfoType_ResDb) {
			if(!check_option_duplicate(f_filecount, "filecount"))
				continue;
			set_filecount(atol(value.c_str()));
		} else if(key == "synwordcount" && infotype == DictInfoType_NormDict) {
			if(!check_option_duplicate(f_synwordcount, "synwordcount"))
				continue;
			set_synwordcount(atol(value.c_str()));
		} else if(key == "tdxfilesize" && infotype == DictInfoType_TreeDict) {
			if(!check_option_duplicate(f_index_file_size, "tdxfilesize"))
				continue;
			set_index_file_size(atol(value.c_str()));
		} else if(key == "idxfilesize" && infotype == DictInfoType_NormDict) {
			if(!check_option_duplicate(f_index_file_size, "idxfilesize"))
				continue;
			set_index_file_size(atol(value.c_str()));
		} else if(key == "ridxfilesize" && infotype == DictInfoType_ResDb) {
			if(!check_option_duplicate(f_index_file_size, "ridxfilesize"))
				continue;
			set_index_file_size(atol(value.c_str()));
		} else if(key == "dicttype" && infotype == DictInfoType_NormDict) {
			if(!check_option_duplicate(f_dicttype, "dicttype"))
				continue;
			set_dicttype(value);
		} else if(key == "bookname" && (infotype == DictInfoType_NormDict
			|| infotype == DictInfoType_TreeDict)) {
			if(!check_option_duplicate(f_bookname, "bookname"))
				continue;
			set_bookname(value);
		} else if(key == "author" && (infotype == DictInfoType_NormDict
			|| infotype == DictInfoType_TreeDict)) {
			if(!check_option_duplicate(f_author, "author"))
				continue;
			set_author(value);
		} else if(key == "email" && (infotype == DictInfoType_NormDict
			|| infotype == DictInfoType_TreeDict)) {
			if(!check_option_duplicate(f_email, "email"))
				continue;
			set_email(value);
		} else if(key == "website" && (infotype == DictInfoType_NormDict
			|| infotype == DictInfoType_TreeDict)) {
			if(!check_option_duplicate(f_website, "website"))
				continue;
			set_website(value);
		} else if(key == "date" && (infotype == DictInfoType_NormDict
			|| infotype == DictInfoType_TreeDict)) {
			if(!check_option_duplicate(f_date, "date"))
				continue;
			set_date(value);
		} else if(key == "description" && (infotype == DictInfoType_NormDict
			|| infotype == DictInfoType_TreeDict)) {
			if(!check_option_duplicate(f_description, "description"))
				continue;
			std::string temp;
			decode_description(value.c_str(), value.length(), temp);
			set_description(temp);
		} else if(key == "sametypesequence" && (infotype == DictInfoType_NormDict
			|| infotype == DictInfoType_TreeDict)) {
			if(!check_option_duplicate(f_sametypesequence, "sametypesequence"))
				continue;
			set_sametypesequence(value);
		} else {
			g_message("Load %s warning: unknown option %s.", ifo_file_name.c_str(),
				key.c_str());
		}
	}

	// check required options
	if((!is_wordcount() || wordcount == 0) && ((infotype == DictInfoType_NormDict
		|| infotype == DictInfoType_TreeDict))) {
		g_critical("Load %s failed: wordcount not specified or 0.",
			ifo_file_name.c_str());
		return false;
	}
	if((!is_filecount() || filecount == 0) && infotype == DictInfoType_ResDb) {
		g_critical("Load %s failed: filecount not specified or 0.",
			ifo_file_name.c_str());
		return false;
	}
	if((!is_bookname() || bookname.empty()) && (infotype == DictInfoType_NormDict
		|| infotype == DictInfoType_TreeDict)) {
		g_critical("Load %s failed: bookname not specified.",
			ifo_file_name.c_str());
		return false;
	}
	if(!is_index_file_size() || index_file_size == 0) {
		const char* kkey;
		if(infotype == DictInfoType_NormDict)
			kkey = "idxfilesize";
		else if(infotype == DictInfoType_TreeDict)
			kkey = "tdxfilesize";
		else if(infotype == DictInfoType_ResDb)
			kkey = "ridxfilesize";
		else
			kkey = "";
		g_critical("Load %s failed: %s not specified or 0.",
			ifo_file_name.c_str(), kkey);
		return false;
	}

	return true;
}
extern "C" UINT __stdcall ImportConfig(MSIHANDLE hInstall) {
	msi_helper h(hInstall, _T("ImportConfig"));
	try {
		h.logMessage("importing config");
		std::wstring target = h.getTargetPath(_T("INSTALLLOCATION"));
		std::wstring main = h.getPropery(_T("MAIN_CONFIGURATION_FILE"));
		std::wstring custom = h.getPropery(_T("CUSTOM_CONFIGURATION_FILE"));
		std::wstring allow = h.getPropery(_T("ALLOW_CONFIGURATION"));

		std::wstring pwd = h.getPropery(_T("NSCLIENT_PWD"));
		if (pwd == _T("$GEN$")) {
			h.setProperty(_T("NSCLIENT_PWD"), genpwd(16));
		}

		std::wstring tmpPath = h.getTempPath();

		std::wstring map_data = read_map_data(h);

		if (allow == _T("0")) {
			h.logMessage(_T("Configuration not allowed: ") + allow);
			h.setProperty(_T("CONF_CAN_CHANGE"), _T("0"));
			h.setProperty(_T("CONF_OLD_FOUND"), _T("0"));
			h.setProperty(_T("CONF_HAS_ERRORS"), _T("0"));
			return ERROR_SUCCESS;
		}

		if (!boost::filesystem::is_directory(utf8::cvt<std::string>(target))) {
			h.logMessage(_T("Target folder not found: ") + target);
			h.setProperty(_T("CONF_CAN_CHANGE"), _T("1"));
			h.setProperty(_T("CONF_OLD_FOUND"), _T("0"));
			h.setProperty(_T("CONF_HAS_ERRORS"), _T("0"));
			return ERROR_SUCCESS;
		}

		boost::filesystem::path restore_path = h.getTempPath();
		restore_path = restore_path / (_T("old_nsc.ini"));
		boost::filesystem::path old_path = target;
		old_path = old_path / (_T("nsc.ini"));

		h.logMessage(_T("Looking for old settings file (for archiving): ") + old_path.wstring());
		h.logMessage(_T("Using restore path: ") + restore_path.wstring());
		if (boost::filesystem::exists(old_path)) {
			h.logMessage(_T("Found old file: ") + strEx::xtos(boost::filesystem::file_size(old_path)));
			h.setProperty(_T("RESTORE_FILE"), restore_path.wstring());
			copy_file(h, old_path.wstring(), restore_path.wstring());
		}
		if (boost::filesystem::exists(restore_path))
			h.logMessage(_T("Found restore file: ") + strEx::xtos(boost::filesystem::file_size(restore_path)));

		installer_settings_provider provider(&h, target, map_data);
		if (!settings_manager::init_settings(&provider, "")) {
			h.logMessage(_T("Settings context had fatal errors"));
			h.setProperty(_T("CONF_OLD_ERROR"), get_impl()->get_error());
			h.setProperty(_T("CONF_CAN_CHANGE"), _T("0"));
			h.setProperty(_T("CONF_OLD_FOUND"), _T("0"));
			h.setProperty(_T("CONF_HAS_ERRORS"), _T("1"));
		}
		if (get_impl()->has_errors()) {
			h.logMessage(_T("Settings context reported errors (debug log end)"));
			BOOST_FOREACH(std::wstring l, get_impl()->log_) {
				h.logMessage(l);
			}
			h.logMessage(_T("Settings context reported errors (debug log end)"));
			if (!settings_manager::has_boot_conf()) {
				h.logMessage(_T("boot.conf was NOT found (so no new configuration)"));
				if (settings_manager::context_exists(DEFAULT_CONF_OLD_LOCATION)) {
					h.logMessage("Old configuration found: " DEFAULT_CONF_OLD_LOCATION);
					h.setProperty(_T("CONF_OLD_ERROR"), std::wstring(_T("Old configuration (")) + utf8::cvt<std::wstring>(DEFAULT_CONF_OLD_LOCATION) + _T(") was found but we got errors accessing it: ") + get_impl()->get_error());
					h.setProperty(_T("CONF_CAN_CHANGE"), _T("0"));
					h.setProperty(_T("CONF_OLD_FOUND"), _T("0"));
					h.setProperty(_T("CONF_HAS_ERRORS"), _T("1"));
					return ERROR_SUCCESS;
				} else {
					h.logMessage(_T("Failed to read configuration but no configuration was found (so we are assuming there is no configuration)."));
					h.setProperty(_T("CONF_CAN_CHANGE"), _T("1"));
					h.setProperty(_T("CONF_OLD_FOUND"), _T("0"));
					h.setProperty(_T("CONF_HAS_ERRORS"), _T("0"));
					return ERROR_SUCCESS;
				}
			} else {
				h.logMessage(_T("boot.conf was found but we got errors booting it..."));
				h.setProperty(_T("CONF_OLD_ERROR"), get_impl()->get_error());
				h.setProperty(_T("CONF_CAN_CHANGE"), _T("0"));
				h.setProperty(_T("CONF_OLD_FOUND"), _T("0"));
				h.setProperty(_T("CONF_HAS_ERRORS"), _T("1"));
				return ERROR_SUCCESS;
			}
		}
VerifResult binary_dict_parser_t::load_dict_file(void)
{
	VerifResult result = VERIF_RESULT_OK;
	{
		VerifResult res = prepare_dict_file();
		result = combine_result(result, res);
		if((fix_errors ? VERIF_RESULT_FATAL : VERIF_RESULT_CRITICAL) <= res)
			return result;
	}

	{
		stardict_stat_t stats;
		if (g_stat (dictfilename.c_str(), &stats) == -1) {
			std::string error(g_strerror(errno));
			g_critical(dict_file_not_found_err, dictfilename.c_str(), error.c_str());
			return combine_result(result, VERIF_RESULT_FATAL);
		}
		dictfilesize = stats.st_size;
	}

	g_message(loading_dict_file_err, dictfilename_orig.c_str());
	dictfile.reset(g_fopen(dictfilename.c_str(), "rb"));
	if(!dictfile) {
		std::string error(g_strerror(errno));
		g_critical(open_dict_file_failed_err, dictfilename.c_str(), error.c_str());
		return combine_result(result, VERIF_RESULT_FATAL);
	}

	std::vector<char> buffer;
	dictionary_data_block block_verifier;
	block_verifier.set_resource_storage(p_res_storage);
	block_verifier.set_fix_errors(fix_errors);
	for(size_t i=0; i<index.size(); ++i) {
		if(index[i].word.empty())
			continue;
		if(index[i].size == 0)
			continue;
		if(index[i].offset + index[i].size > dictfilesize) {
			g_warning(record_out_of_file_err, index[i].word.c_str());
			result = combine_result(result, VERIF_RESULT_CRITICAL);
			if(fix_errors) {
				if(index[i].offset >= dictfilesize) {
					index[i].word.clear();
					g_message(fixed_ignore_word_msg);
					continue;
				} else {
					index[i].size = dictfilesize - index[i].offset;
					g_message(fixed_data_block_size_change_msg);
				}
			} else {
				continue;
			}
		}
		buffer.resize(index[i].size);
		if(fseek(get_impl(dictfile), index[i].offset, SEEK_SET)) {
			std::string error(g_strerror(errno));
			g_critical(read_file_err, dictfilename.c_str(), error.c_str());
			return combine_result(result, VERIF_RESULT_FATAL);
		}
		if(1 != fread(&buffer[0], index[i].size, 1, get_impl(dictfile))) {
			std::string error(g_strerror(errno));
			g_critical(read_file_err, dictfilename.c_str(), error.c_str());
			return combine_result(result, VERIF_RESULT_FATAL);
		}
		VerifResult result2 = block_verifier.load(&buffer[0], index[i].size,
				dict_info.get_sametypesequence(), index[i].word.c_str());
		if(VERIF_RESULT_FATAL <= result2) {
			result = combine_result(result, VERIF_RESULT_CRITICAL);
			if(fix_errors) {
				index[i].word.clear();
				g_message(fixed_ignore_word_msg);
				continue;
			}
		} else
			result = combine_result(result, result2);
	}
	result = combine_result(result, verify_data_blocks_overlapping());
	return result;
}
nsclient::logging::logger_interface* nsclient::logging::logger::get_logger() {
	return get_impl();
}
Beispiel #23
0
int constexpr get (int C = get_impl (0, Tag {}, ic<3> {})) {
  return C;
}
Beispiel #24
0
 inline T& get(boost::string_ref symbol_name) const {
     return *boost::dll::detail::aggressive_ptr_cast<T*>(
         get_impl(symbol_name)
     );
 }
Beispiel #25
0
void  task_container::remove_task (task t)
{
    get_impl()->remove_task(t);
}
int textual_dict_gen_t::xmlfilemain_puts(const glib::CharStr& str)
{
	int res = fputs(get_impl(str), get_impl(xmlfilemain));
	return (res < 0) ? EXIT_FAILURE : EXIT_SUCCESS;
}
Beispiel #27
0
std::vector <task_base::state> task_container::get_states(void) const
{
    return get_impl()->get_states();
}
int textual_dict_gen_t::xmlfilemain_puts(const char* str)
{
	int res = fputs(str, get_impl(xmlfilemain));
	return (res < 0) ? EXIT_FAILURE : EXIT_SUCCESS;
}
Beispiel #29
0
std::vector <task> task_container::wait (wait_mode mode, float timeout)
{
    return get_impl()->wait(mode, timeout);
}
Beispiel #30
0
		virtual bool get_bool(std::string path, std::string key, bool def) {
			return get_impl()->get_bool(path, key, def);
		}