Пример #1
0
static int Hsp3ExtAddPlugin( void )
{
	//		プラグインの登録
	//
	int i;
	HSPHED *hed;
	char *ptr;
	char *libname;
	char *funcname;
	HPIDAT *hpi;
	HSP3TYPEINFO *info;
	HINSTANCE hd;
	char tmp[512];

	hed = hspctx->hsphed; ptr = (char *)hed;
	hpi = hpidat = (HPIDAT *)( ptr + hed->pt_hpidat );
	hpimax = hed->max_hpi / sizeof( HPIDAT );
	for ( i=0;i<hpimax;i++ ) {
		libname = strp(hpi->libname);
		funcname = strp(hpi->funcname);
		info = code_gettypeinfo(-1);

		if ( hpi->flag == HPIDAT_FLAG_TYPEFUNC ) {
		 	hd = DllManager().load_library( libname );
			if ( hd == NULL ) {
				sprintf( tmp,"No DLL:%s",libname );
				Alert( tmp );
				return 1;
			}
			hpi->libptr = (void *)hd;
			func = (DLLFUNC)GetProcAddress( hd, funcname );
			if ( func == NULL ) {
				sprintf( tmp,"No DLL:%s:%s", libname, funcname );
				Alert( tmp );
				return 1;
			}
			func( info );
			code_enable_typeinfo( info );
			//Alertf( "%d_%d [%s][%s]", i, info->type, libname, funcname );
		}
		hpi++;
	}
	return 0;
}
Пример #2
0
static void BindLIB( LIBDAT *lib, char *name )
{
	//		ライブラリのバインドを行なう
	//		(name:後から与える時のライブラリ名)
	//
	int i;
	char *n;
	HINSTANCE hd;
	if ( lib->flag != LIBDAT_FLAG_DLL ) return;
	i = lib->nameidx;
	if ( i < 0 ) {
		if ( name == NULL ) return;
		n = name;
	} else {
		n = strp(i);
	}
 	hd = DllManager().load_library( n );
	if ( hd == NULL ) return;
	lib->hlib = (void *)hd;
	lib->flag = LIBDAT_FLAG_DLLINIT;
}
Пример #3
0
static int Hsp3ExtAddPlugin( void )
{
	//		プラグインの登録
	//
	int i;
	HSPHED *hed;
	char *ptr;
	char *libname;
	char *funcname;
	HPIDAT *org_hpi;
	MEM_HPIDAT *hpi;
	HSP3TYPEINFO *info;
	HINSTANCE hd;
	TCHAR tmp[512];

	hed = hspctx->hsphed; ptr = (char *)hed;
	org_hpi = (HPIDAT *)(ptr + hed->pt_hpidat);
	hpimax = hed->max_hpi / sizeof(HPIDAT);

	if ( hpimax == 0 ) return 0;
	hpidat = (MEM_HPIDAT *)malloc(hpimax * sizeof(MEM_HPIDAT));
	hpi = hpidat;

	for ( i=0;i<hpimax;i++ ) {

		hpi->flag = org_hpi->flag;
		hpi->option = org_hpi->option;
		hpi->libname = org_hpi->libname;
		hpi->funcname = org_hpi->funcname;
		hpi->libptr = NULL;

		libname = strp(hpi->libname);
		funcname = strp(hpi->funcname);
		info = code_gettypeinfo(-1);

		if ( hpi->flag == HPIDAT_FLAG_TYPEFUNC ) {
		 	hd = DllManager().load_library( libname );
			if ( hd == NULL ) {
#ifdef HSPUTF8
				TCHAR tmp[512];
				HSPAPICHAR *haclibname;
				chartoapichar(libname, &haclibname);
				_stprintf(tmp, TEXT("No DLL:%s"), haclibname);
				freehac(&haclibname);
				AlertW(tmp);
#else
				Alertf( "No DLL:%s", libname );
#endif
				return 1;
			}
			hpi->libptr = (void *)hd;
#ifdef HSPUTF8
			HSPAPICHAR *hacfuncname;
			char tmp2[512];
			chartoapichar(funcname,&hacfuncname);
			cnvsjis(tmp2,(char*)hacfuncname,512);
			func = (DLLFUNC)GetProcAddress( hd, tmp2 );
#else
			func = (DLLFUNC)GetProcAddress( hd, funcname );
#endif
			if ( func == NULL ) {
#ifdef HSPUTF8
				TCHAR tmp[512];
				HSPAPICHAR *haclibname;
				chartoapichar(libname, &haclibname);
				_stprintf(tmp, TEXT("No DLL:%s:%s"), haclibname, hacfuncname);
				freehac(&haclibname);
				AlertW(tmp);
				freehac(&hacfuncname);
#else
				Alertf("No DLL:%s:%s", libname, funcname);
#endif
				return 1;
			}
			func( info );
			code_enable_typeinfo( info );
			//Alertf( "%d_%d [%s][%s]", i, info->type, libname, funcname );
#ifdef HSPUTF8
			freehac(&hacfuncname);
#endif
		}
		hpi++;
		org_hpi++;
	}
	return 0;
}