IO_API PDRIVER_INFO PMC_API io_load_driver(PCVENDOR_KEY v, PCDEVTYPE_KEY t)
{		
	DRIVER_LIST::iterator it;
	DRIVER_INFO driver;
	string		infofile;

	ZeroMemory(&driver, sizeof(DRIVER_INFO));

	infofile = get_exe_dir();
	infofile += "infs/";
	infofile += (char*)CVendorName(*v);
	infofile += ".inf";
	GetPrivateProfileString(
		(char*)CDevTypeName(*t),
		"module",
		"",
		driver.dllname,
		sizeof(driver.dllname),
		infofile.data()
		 );	
	for(it = g_Drivers.begin(); it != g_Drivers.end(); it++){
		if( !strnicmp(it->dllname, driver.dllname, sizeof(it->dllname)) ){
			return &(*it);  
		}
	}	

	driver.vendor.key = *v;
	driver.type.key = *t;

	GetPrivateProfileString(
		"oem",
		"vendor",
		"",
		driver.vendor.description,
		sizeof(driver.vendor.description),
		infofile.data()
		);
	GetPrivateProfileString(
		(char*)CDevTypeName(*t),
		"description",
		"",
		driver.type.description,
		sizeof(driver.type.description),
		infofile.data()
		);
	
	if(_load_module(driver)){
		if(driver.load){
			driver.load(&driver);
		}
	}
	
	it = g_Drivers.insert(g_Drivers.end(), driver);
	if(it == g_Drivers.end()){
		io_unload_driver(&driver);
		return 0;
	}
	
	return &(*it);
}
Beispiel #2
0
char *mp_get_win_config_path(const char *filename)
{
    wchar_t w_appdir[MAX_PATH + 1] = {0};
    wchar_t w_exedir[MAX_PATH + 1] = {0};
    char *res = NULL;
    void *tmp = talloc_new(NULL);

#ifndef __CYGWIN__
    if (SHGetFolderPathW(NULL, CSIDL_LOCAL_APPDATA|CSIDL_FLAG_CREATE, NULL,
        SHGFP_TYPE_CURRENT, w_appdir) != S_OK)
        w_appdir[0] = '\0';
#endif

    get_exe_dir(w_exedir);

    if (filename && filename[0] && w_exedir[0]) {
        char *dir = mp_to_utf8(tmp, w_exedir);
        char *temp = mp_path_join(tmp, bstr0(dir), bstr0("mpv"));
        res = mp_path_join(NULL, bstr0(temp), bstr0(filename));
        if (!mp_path_exists(res) || mp_path_isdir(res)) {
            talloc_free(res);
            res = NULL;
        }
    }

    if (!res && w_appdir[0]) {
        char *dir = mp_to_utf8(tmp, w_appdir);
        char *temp = mp_path_join(tmp, bstr0(dir), bstr0("mpv"));
        res = mp_path_join(NULL, bstr0(temp), bstr0(filename));
    }

    talloc_free(tmp);
    return res;
}
Beispiel #3
0
ngspice::ngspice()
	:m_sendDataDebug(0)
	,m_flagPrompt(false)
	,m_running(false)
	,m_flagCheckLoadCircuit(false)
	//,m_breakTest(false)
{
	string path = get_exe_dir();
	SetCurrentDirectoryA(path.c_str());

	static int copy = 1;
	string dll = FormatString(100, "ngspice%d.dll", copy++);
	BOOL success = CopyFileA("ngspice.dll", dll.c_str(), FALSE);
	m_mod = LoadLibrary(dll.c_str());
	ngSpice_Init		= (Func_ngSpice_Init)GetProcAddress(m_mod, "ngSpice_Init");
	ngSpice_Init_Sync	= (Func_ngSpice_Init_Sync)GetProcAddress(m_mod, "ngSpice_Init_Sync");
	ngSpice_Command		= (Func_ngSpice_Command)GetProcAddress(m_mod, "ngSpice_Command");
	ngGet_Vec_Info		= (Func_ngGet_Vec_Info)GetProcAddress(m_mod, "ngGet_Vec_Info");
	ngSpice_Circ		= (Func_ngSpice_Circ)GetProcAddress(m_mod, "ngSpice_Circ");
	ngSpice_CurPlot		= (Func_ngSpice_CurPlot)GetProcAddress(m_mod, "ngSpice_CurPlot");
	ngSpice_AllPlots	= (Func_ngSpice_AllPlots)GetProcAddress(m_mod, "ngSpice_AllPlots");
	ngSpice_AllVecs		= (Func_ngSpice_AllVecs)GetProcAddress(m_mod, "ngSpice_AllVecs");
	ngSpice_running		= (Func_ngSpice_running)GetProcAddress(m_mod, "ngSpice_running");
	ngSpice_SetBkpt		= (Func_ngSpice_SetBkpt)GetProcAddress(m_mod, "ngSpice_SetBkpt");

	int ret = ngSpice_Init(procSendChar, procSendStat, procControlledExit, procSendData, procSendInitData, procBGThreadRunning, this);
}
Beispiel #4
0
int
vim_format_help_cmd(const char topic[], char cmd[], size_t cmd_size)
{
	int bg;

#ifndef _WIN32
	char *const escaped_rtp = shell_like_escape(PACKAGE_DATA_DIR, 0);
	char *const escaped_args = shell_like_escape(topic, 0);

	snprintf(cmd, cmd_size,
			"%s -c 'set runtimepath+=%s/vim-doc' -c help\\ %s -c only",
			cfg_get_vicmd(&bg), escaped_rtp, escaped_args);

	free(escaped_args);
	free(escaped_rtp);
#else
	char exe_dir[PATH_MAX];
	char *escaped_rtp;

	(void)get_exe_dir(exe_dir, sizeof(exe_dir));
	escaped_rtp = shell_like_escape(exe_dir, 0);

	snprintf(cmd, cmd_size,
			"%s -c \"set runtimepath+=%s/data/vim-doc\" -c \"help %s\" -c only",
			cfg_get_vicmd(&bg), escaped_rtp, topic);

	free(escaped_rtp);
#endif

	return bg;
}
// Get path for default database file
const char * get_drivedb_path_default()
{
#ifndef _WIN32
  return SMARTMONTOOLS_DRIVEDBDIR"/drivedb.h";
#else
  static std::string path = get_exe_dir() + "/drivedb.h";
  return path.c_str();
#endif
}
// Get path for additional database file
const char * get_drivedb_path_add()
{
#ifndef _WIN32
  return SMARTMONTOOLS_SYSCONFDIR"/smart_drivedb.h";
#else
  static std::string path = get_exe_dir() + "/drivedb-add.h";
  return path.c_str();
#endif
}
Beispiel #7
0
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
    : TForm(Owner)
{
    if(localFile==""){
        AnsiString s;
        s=get_exe_dir();
        s=s+"license.dat";
        localFile=s;
    }
}
Beispiel #8
0
int main(int argc,char * argv[])
{
#ifdef _WIN32
	CoInitialize(NULL);
#endif

	std::string ipfile = search_qqwrydat(get_exe_dir(argv[0]));

	QQWry::ipdb iplook(ipfile.c_str());

	//使用 CIPLocation::GetIPLocation 获得对应 ip 地址的地区表示.
	in_addr ip;

	if (argc <= 2)
	{

		ip.s_addr = inet_addr(argc == 2 ? argv[1] : "8.8.8.8");
		if (ip.s_addr && ip.s_addr != (-1)) // 如果命令行没有键入合法的ip地址,就进行地址-》ip的操作
		{
			QQWry::IPLocation iplocation = iplook.GetIPLocation(ip);
			puts(iplocation.country);
			puts(iplocation.area);
		}

		return 0;
	}
	//使用 CIPLocation::GetIPs 获得匹配地址的所有 ip 区间
	std::list<QQWry::IP_regon> ipregon;

	char country[80],area[80];

	if(argc!=3)
		ipregon = iplook.GetIPs("浙江省温州市","*网吧*");
	else
		ipregon = iplook.GetIPs(argv[1],argv[2]);

	std::list<QQWry::IP_regon>::iterator it;

	//在一个循环中打印出来
	for(it=ipregon.begin(); it != ipregon.end() ; it ++)
	{
		char	ipstr[30];
		strcpy(ipstr,inet_ntoa(it->start));

		printf(  "%s to %s :%s %s\n",ipstr, inet_ntoa(it->end), it->location.country,it->location.area);
	}
#ifdef _WIN32
	CoUninitialize();
#endif
	return 0;
}
Beispiel #9
0
/* Tries to use directory of executable file as configuration directory.
 * Returns non-zero on success, otherwise zero is returned. */
static int
try_exe_directory_for_conf(void)
{
	LOG_FUNC_ENTER;

	char exe_dir[PATH_MAX + 1];

	if(get_exe_dir(exe_dir, sizeof(exe_dir)) != 0)
	{
		return 0;
	}

	if(!path_exists_at(exe_dir, VIFMRC, DEREF))
	{
		return 0;
	}

	env_set(VIFM_EV, exe_dir);
	return 1;
}
Beispiel #10
0
/* Tries to use vifmrc in directory of executable file as configuration file.
 * Returns non-zero on success, otherwise zero is returned. */
static int
try_exe_directory_for_vifmrc(void)
{
	LOG_FUNC_ENTER;

	char exe_dir[PATH_MAX + 1];
	char vifmrc[PATH_MAX + 1];

	if(get_exe_dir(exe_dir, sizeof(exe_dir)) != 0)
	{
		return 0;
	}

	snprintf(vifmrc, sizeof(vifmrc), "%s/" VIFMRC, exe_dir);
	if(!path_exists(vifmrc, DEREF))
	{
		return 0;
	}

	env_set(MYVIFMRC_EV, vifmrc);
	return 1;
}
Beispiel #11
0
void
init_config(void)
{
	cfg.show_one_window = 0;
	cfg.history_len = 15;

	(void)hist_init(&cfg.cmd_hist, cfg.history_len);
	(void)hist_init(&cfg.search_hist, cfg.history_len);
	(void)hist_init(&cfg.prompt_hist, cfg.history_len);
	(void)hist_init(&cfg.filter_hist, cfg.history_len);

	cfg.auto_execute = 0;
	cfg.time_format = strdup(" %m/%d %H:%M");
	cfg.wrap_quick_view = 1;
	cfg.use_iec_prefixes = 0;
	cfg.undo_levels = 100;
	cfg.sort_numbers = 0;
	cfg.follow_links = 1;
	cfg.fast_run = 0;
	cfg.confirm = 1;
	cfg.vi_command = strdup("vim");
	cfg.vi_cmd_bg = 0;
	cfg.vi_x_command = strdup("");
	cfg.vi_x_cmd_bg = 0;
	cfg.use_trash = 1;

	{
		char fuse_home[PATH_MAX];
		int update_stat;
		snprintf(fuse_home, sizeof(fuse_home), "%s/vifm_FUSE", get_tmpdir());
		update_stat = set_fuse_home(fuse_home);
		assert(update_stat == 0);
	}

	cfg.use_term_multiplexer = 0;
	cfg.use_vim_help = 0;
	cfg.wild_menu = 0;
	cfg.ignore_case = 0;
	cfg.smart_case = 0;
	cfg.hl_search = 1;
	cfg.vifm_info = VIFMINFO_BOOKMARKS;
	cfg.auto_ch_pos = 1;
	cfg.timeout_len = 1000;
	cfg.scroll_off = 0;
	cfg.gdefault = 0;
#ifndef _WIN32
	cfg.slow_fs_list = strdup("");
#endif
	cfg.scroll_bind = 0;
	cfg.wrap_scan = 1;
	cfg.inc_search = 0;
	cfg.selection_is_primary = 1;
	cfg.tab_switches_pane = 1;
	cfg.use_system_calls = 0;
	cfg.last_status = 1;
	cfg.tab_stop = 8;
	cfg.ruler_format = strdup("%=%l/%S ");
	cfg.status_line = strdup("");

	cfg.lines = INT_MIN;
	cfg.columns = INT_MIN;

	cfg.dot_dirs = DD_NONROOT_PARENT;

	cfg.trunc_normal_sb_msgs = 0;

	cfg.filter_inverted_by_default = 1;

	cfg.apropos_prg = strdup("apropos %a");
	cfg.find_prg = strdup("find %s %a -print , "
			"-type d \\( ! -readable -o ! -executable \\) -prune");
	cfg.grep_prg = strdup("grep -n -H -I -r %i %a %s");
	cfg.locate_prg = strdup("locate %a");

	cfg.cd_path = strdup(env_get_def("CDPATH", DEFAULT_CD_PATH));
	replace_char(cfg.cd_path, ':', ',');

	cfg.filelist_col_padding = 1;
	cfg.side_borders_visible = 1;

	cfg.border_filler = strdup(" ");

#ifndef _WIN32
	copy_str(cfg.log_file, sizeof(cfg.log_file), "/var/log/vifm-startup-log");
#else
	{
		char exe_dir[PATH_MAX];
		(void)get_exe_dir(exe_dir, sizeof(exe_dir));
		snprintf(cfg.log_file, sizeof(cfg.log_file), "%s/startup-log", exe_dir);
	}
#endif

	cfg_set_shell(env_get_def("SHELL", DEFAULT_SHELL_CMD));

	memset(&cfg.decorations, '\0', sizeof(cfg.decorations));
	cfg.decorations[DIRECTORY][DECORATION_SUFFIX] = '/';
}