goat3d

diff exporters/maxgoat_stub/src/stub.cc @ 73:9862541fdcf5

- build qt goatview on linux - fixed line endings in a bunch of files
author John Tsiombikas <nuclear@member.fsf.org>
date Tue, 06 May 2014 03:57:11 +0300
parents 3751aabbc5b3
children
line diff
     1.1 --- a/exporters/maxgoat_stub/src/stub.cc	Tue May 06 03:31:35 2014 +0300
     1.2 +++ b/exporters/maxgoat_stub/src/stub.cc	Tue May 06 03:57:11 2014 +0300
     1.3 @@ -1,274 +1,274 @@
     1.4 -#include <stdio.h>
     1.5 -#include <string.h>
     1.6 -#include <stdlib.h>
     1.7 -#include <errno.h>
     1.8 -#include <map>
     1.9 -#include <windows.h>
    1.10 -#include <shlobj.h>
    1.11 -#include "max.h"
    1.12 -#include "impexp.h"		// SceneExport
    1.13 -#include "iparamb2.h"	// ClassDesc2
    1.14 -#include "plugapi.h"
    1.15 -#include "IGame.h"
    1.16 -#include "IGameExport.h"
    1.17 -#include "IConversionmanager.h"
    1.18 -
    1.19 -
    1.20 -#pragma comment (lib, "core.lib")
    1.21 -#pragma comment (lib, "geom.lib")
    1.22 -#pragma comment (lib, "gfx.lib")
    1.23 -#pragma comment (lib, "mesh.lib")
    1.24 -#pragma comment (lib, "maxutil.lib")
    1.25 -#pragma comment (lib, "maxscrpt.lib")
    1.26 -#pragma comment (lib, "paramblk2.lib")
    1.27 -#pragma comment (lib, "msxml2.lib")
    1.28 -#pragma comment (lib, "igame.lib")
    1.29 -#pragma comment (lib, "comctl32.lib")
    1.30 -
    1.31 -
    1.32 -#define VER_MAJOR	1
    1.33 -#define VER_MINOR	0
    1.34 -#define VERSION(major, minor) \
    1.35 -	((major) * 100 + ((minor) < 10 ? (minor) * 10 : (minor)))
    1.36 -
    1.37 -typedef int (*PluginInitFunc)();
    1.38 -typedef int (*PluginShutdownFunc)();
    1.39 -typedef ClassDesc *(*PluginClassDescFunc)(int);
    1.40 -
    1.41 -static FILE *logfile;
    1.42 -static HINSTANCE hinst;
    1.43 -static const wchar_t *copyright_str = L"Copyright 2013 (C) John Tsiombikas - GNU General Public License v3, see COPYING for details.";
    1.44 -
    1.45 -class GoatExporterStub : public SceneExport {
    1.46 -public:
    1.47 -	IGameScene *igame;
    1.48 -
    1.49 -	int ExtCount() { return 1; }
    1.50 -	const TCHAR *Ext(int n) { return L"goatsce"; }
    1.51 -	const TCHAR *LongDesc() { return L"Goat3D Scene file"; }
    1.52 -	const TCHAR *ShortDesc() { return L"Goat3D Scene"; }
    1.53 -	const TCHAR *AuthorName() { return L"John Tsiombikas"; }
    1.54 -	const TCHAR *CopyrightMessage() { return copyright_str; }
    1.55 -	const TCHAR *OtherMessage1() { return L"foo1"; }
    1.56 -	const TCHAR *OtherMessage2() { return L"foo2"; }
    1.57 -	unsigned int Version() { return VERSION(VER_MAJOR, VER_MINOR); }
    1.58 -	void ShowAbout(HWND win) { MessageBoxA(win, "Goat3D exporter", "About this plugin", 0); }
    1.59 -
    1.60 -	int DoExport(const MCHAR *name, ExpInterface *eiface, Interface *iface, BOOL silent = FALSE, DWORD opt = 0);
    1.61 -};
    1.62 -
    1.63 -class GoatAnimExporterStub : public SceneExport {
    1.64 -public:
    1.65 -	IGameScene *igame;
    1.66 -
    1.67 -	int ExtCount() { return 1; }
    1.68 -	const TCHAR *Ext(int n) { return L"goatanm"; }
    1.69 -	const TCHAR *LongDesc() { return L"Goat3D Animation file"; }
    1.70 -	const TCHAR *ShortDesc() { return L"Goat3D Animation"; }
    1.71 -	const TCHAR *AuthorName() { return L"John Tsiombikas"; }
    1.72 -	const TCHAR *CopyrightMessage() { return copyright_str; }
    1.73 -	const TCHAR *OtherMessage1() { return L"bar1"; }
    1.74 -	const TCHAR *OtherMessage2() { return L"bar2"; }
    1.75 -	unsigned int Version() { return VERSION(VER_MAJOR, VER_MINOR); }
    1.76 -	void ShowAbout(HWND win) { MessageBoxA(win, "Goat3D anim exporter", "About this plugin", 0); }
    1.77 -
    1.78 -	int DoExport(const MCHAR *name, ExpInterface *eiface, Interface *iface, BOOL silent = FALSE, DWORD opt = 0);
    1.79 -};
    1.80 -
    1.81 -static const char *find_dll_dir()
    1.82 -{
    1.83 -	static char path[MAX_PATH];
    1.84 -
    1.85 -	HMODULE dll;
    1.86 -	if(!GetModuleHandleExA(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
    1.87 -			(LPCSTR)find_dll_dir, &dll)) {
    1.88 -		return 0;
    1.89 -	}
    1.90 -	GetModuleFileNameA(dll, path, sizeof path);
    1.91 -
    1.92 -	char *last_slash = strrchr(path, '\\');
    1.93 -	if(last_slash && last_slash[1]) {
    1.94 -		*last_slash = 0;
    1.95 -	}
    1.96 -
    1.97 -	return path;
    1.98 -}
    1.99 -
   1.100 -static int do_export(int which, const MCHAR *name, ExpInterface *eiface, Interface *iface, BOOL non_int, DWORD opt)
   1.101 -{
   1.102 -	const char *dll_fname = "maxgoat.dll";
   1.103 -	char *dll_path;
   1.104 -	HMODULE dll = 0;
   1.105 -	PluginInitFunc init;
   1.106 -	PluginShutdownFunc shutdown;
   1.107 -	PluginClassDescFunc get_class_desc;
   1.108 -	ClassDesc *desc;
   1.109 -	SceneExport *ex;
   1.110 -	int result = IMPEXP_FAIL;
   1.111 -
   1.112 -	const char *plugdir = find_dll_dir();
   1.113 -	if(plugdir) {
   1.114 -		dll_path = new char[strlen(dll_fname) + strlen(plugdir) + 2];
   1.115 -		sprintf(dll_path, "%s\\%s", plugdir, dll_fname);
   1.116 -	} else {
   1.117 -		dll_path = new char[strlen(dll_fname) + 1];
   1.118 -		strcpy(dll_path, dll_fname);
   1.119 -	}
   1.120 -
   1.121 -	if(!(dll = LoadLibraryA(dll_path))) {
   1.122 -		fprintf(logfile, "failed to load exporter: %s\n", dll_path);
   1.123 -		goto done;
   1.124 -	}
   1.125 -
   1.126 -	if(!(get_class_desc = (PluginClassDescFunc)GetProcAddress(dll, "LibClassDesc"))) {
   1.127 -		fprintf(logfile, "maxgoat.dll is invalid (no LibClassDesc function)\n");
   1.128 -		goto done;
   1.129 -	}
   1.130 -
   1.131 -	// first initialize the library
   1.132 -	if((init = (PluginInitFunc)GetProcAddress(dll, "LibInitialize"))) {
   1.133 -		if(!init()) {
   1.134 -			fprintf(logfile, "exporter initialization failed!\n");
   1.135 -			goto done;
   1.136 -		}
   1.137 -	}
   1.138 -
   1.139 -	if(!(desc = get_class_desc(which))) {
   1.140 -		fprintf(logfile, "failed to get the class descriptor\n");
   1.141 -		goto done;
   1.142 -	}
   1.143 -
   1.144 -	if(!(ex = (SceneExport*)desc->Create())) {
   1.145 -		fprintf(logfile, "failed to create exporter class instance\n");
   1.146 -		goto done;
   1.147 -	}
   1.148 -
   1.149 -	__try {
   1.150 -		result = ex->DoExport(name, eiface, iface);
   1.151 -	}
   1.152 -	__except(EXCEPTION_EXECUTE_HANDLER) {
   1.153 -		fprintf(logfile, "Exception caught!\n");
   1.154 -		delete ex;
   1.155 -		goto done;
   1.156 -	}
   1.157 -	delete ex;
   1.158 -
   1.159 -	if((shutdown = (PluginShutdownFunc)GetProcAddress(dll, "LibShutdown"))) {
   1.160 -		shutdown();
   1.161 -	}
   1.162 -
   1.163 -done:
   1.164 -	delete [] dll_path;
   1.165 -	if(dll) {
   1.166 -		FreeLibrary(dll);
   1.167 -	}
   1.168 -	return result;
   1.169 -}
   1.170 -
   1.171 -int GoatExporterStub::DoExport(const MCHAR *name, ExpInterface *eiface, Interface *iface,
   1.172 -		BOOL non_interactive, DWORD opt)
   1.173 -{
   1.174 -	return do_export(0, name, eiface, iface, non_interactive, opt);
   1.175 -}
   1.176 -
   1.177 -
   1.178 -int GoatAnimExporterStub::DoExport(const MCHAR *name, ExpInterface *eiface, Interface *iface,
   1.179 -		BOOL non_interactive, DWORD opt)
   1.180 -{
   1.181 -	return do_export(1, name, eiface, iface, non_interactive, opt);
   1.182 -}
   1.183 -
   1.184 -// ------------------------------------------
   1.185 -
   1.186 -class GoatClassDesc : public ClassDesc2 {
   1.187 -public:
   1.188 -	int IsPublic() { return TRUE; }
   1.189 -	void *Create(BOOL loading = FALSE) { return new GoatExporterStub; }
   1.190 -	const TCHAR *ClassName() { return L"GoatExporterStub"; }
   1.191 -	SClass_ID SuperClassID() { return SCENE_EXPORT_CLASS_ID; }
   1.192 -	Class_ID ClassID() { return Class_ID(0x2e4e6311, 0x2b154d91); }
   1.193 -	const TCHAR *Category() { return L"Mutant Stargoat"; }
   1.194 -
   1.195 -	const TCHAR *InternalName() { return L"GoatExporterStub"; }
   1.196 -	HINSTANCE HInstance() { return hinst; }
   1.197 -};
   1.198 -
   1.199 -class GoatAnimClassDesc : public ClassDesc2 {
   1.200 -public:
   1.201 -	int IsPublic() { return TRUE; }
   1.202 -	void *Create(BOOL loading = FALSE) { return new GoatAnimExporterStub; }
   1.203 -	const TCHAR *ClassName() { return L"GoatAnimExporterStub"; }
   1.204 -	SClass_ID SuperClassID() { return SCENE_EXPORT_CLASS_ID; }
   1.205 -	Class_ID ClassID() { return Class_ID(0x75054666, 0x45487285); }
   1.206 -	const TCHAR *Category() { return L"Mutant Stargoat"; }
   1.207 -
   1.208 -	const TCHAR *InternalName() { return L"GoatAnimExporterStub"; }
   1.209 -	HINSTANCE HInstance() { return hinst; }
   1.210 -};
   1.211 -
   1.212 -
   1.213 -static GoatClassDesc class_desc;
   1.214 -static GoatAnimClassDesc anim_class_desc;
   1.215 -
   1.216 -BOOL WINAPI DllMain(HINSTANCE inst_handle, ULONG reason, void *reserved)
   1.217 -{
   1.218 -	if(reason == DLL_PROCESS_ATTACH) {
   1.219 -		hinst = inst_handle;
   1.220 -		DisableThreadLibraryCalls(hinst);
   1.221 -	}
   1.222 -	return TRUE;
   1.223 -}
   1.224 -
   1.225 -extern "C" {
   1.226 -
   1.227 -__declspec(dllexport) const TCHAR *LibDescription()
   1.228 -{
   1.229 -	return L"Goat3D exporter stub";
   1.230 -}
   1.231 -
   1.232 -__declspec(dllexport) int LibNumberClasses()
   1.233 -{
   1.234 -	return 2;
   1.235 -}
   1.236 -
   1.237 -__declspec(dllexport) ClassDesc *LibClassDesc(int i)
   1.238 -{
   1.239 -	switch(i) {
   1.240 -	case 0:
   1.241 -		return &class_desc;
   1.242 -	case 1:
   1.243 -		return &anim_class_desc;
   1.244 -	default:
   1.245 -		break;
   1.246 -	}
   1.247 -	return 0;
   1.248 -}
   1.249 -
   1.250 -__declspec(dllexport) ULONG LibVersion()
   1.251 -{
   1.252 -	return Get3DSMAXVersion();
   1.253 -}
   1.254 -
   1.255 -__declspec(dllexport) int LibInitialize()
   1.256 -{
   1.257 -	static char path[1024];
   1.258 -
   1.259 -	SHGetFolderPathA(0, CSIDL_PERSONAL, 0, 0, path);
   1.260 -	strcat(path, "/testexpstub.log");
   1.261 -
   1.262 -	if((logfile = fopen(path, "w"))) {
   1.263 -		setvbuf(logfile, 0, _IONBF, 0);
   1.264 -	}
   1.265 -	return TRUE;
   1.266 -}
   1.267 -
   1.268 -__declspec(dllexport) int LibShutdown()
   1.269 -{
   1.270 -	if(logfile) {
   1.271 -		fclose(logfile);
   1.272 -		logfile = 0;
   1.273 -	}
   1.274 -	return TRUE;
   1.275 -}
   1.276 -
   1.277 -}	// extern "C"
   1.278 \ No newline at end of file
   1.279 +#include <stdio.h>
   1.280 +#include <string.h>
   1.281 +#include <stdlib.h>
   1.282 +#include <errno.h>
   1.283 +#include <map>
   1.284 +#include <windows.h>
   1.285 +#include <shlobj.h>
   1.286 +#include "max.h"
   1.287 +#include "impexp.h"		// SceneExport
   1.288 +#include "iparamb2.h"	// ClassDesc2
   1.289 +#include "plugapi.h"
   1.290 +#include "IGame.h"
   1.291 +#include "IGameExport.h"
   1.292 +#include "IConversionmanager.h"
   1.293 +
   1.294 +
   1.295 +#pragma comment (lib, "core.lib")
   1.296 +#pragma comment (lib, "geom.lib")
   1.297 +#pragma comment (lib, "gfx.lib")
   1.298 +#pragma comment (lib, "mesh.lib")
   1.299 +#pragma comment (lib, "maxutil.lib")
   1.300 +#pragma comment (lib, "maxscrpt.lib")
   1.301 +#pragma comment (lib, "paramblk2.lib")
   1.302 +#pragma comment (lib, "msxml2.lib")
   1.303 +#pragma comment (lib, "igame.lib")
   1.304 +#pragma comment (lib, "comctl32.lib")
   1.305 +
   1.306 +
   1.307 +#define VER_MAJOR	1
   1.308 +#define VER_MINOR	0
   1.309 +#define VERSION(major, minor) \
   1.310 +	((major) * 100 + ((minor) < 10 ? (minor) * 10 : (minor)))
   1.311 +
   1.312 +typedef int (*PluginInitFunc)();
   1.313 +typedef int (*PluginShutdownFunc)();
   1.314 +typedef ClassDesc *(*PluginClassDescFunc)(int);
   1.315 +
   1.316 +static FILE *logfile;
   1.317 +static HINSTANCE hinst;
   1.318 +static const wchar_t *copyright_str = L"Copyright 2013 (C) John Tsiombikas - GNU General Public License v3, see COPYING for details.";
   1.319 +
   1.320 +class GoatExporterStub : public SceneExport {
   1.321 +public:
   1.322 +	IGameScene *igame;
   1.323 +
   1.324 +	int ExtCount() { return 1; }
   1.325 +	const TCHAR *Ext(int n) { return L"goatsce"; }
   1.326 +	const TCHAR *LongDesc() { return L"Goat3D Scene file"; }
   1.327 +	const TCHAR *ShortDesc() { return L"Goat3D Scene"; }
   1.328 +	const TCHAR *AuthorName() { return L"John Tsiombikas"; }
   1.329 +	const TCHAR *CopyrightMessage() { return copyright_str; }
   1.330 +	const TCHAR *OtherMessage1() { return L"foo1"; }
   1.331 +	const TCHAR *OtherMessage2() { return L"foo2"; }
   1.332 +	unsigned int Version() { return VERSION(VER_MAJOR, VER_MINOR); }
   1.333 +	void ShowAbout(HWND win) { MessageBoxA(win, "Goat3D exporter", "About this plugin", 0); }
   1.334 +
   1.335 +	int DoExport(const MCHAR *name, ExpInterface *eiface, Interface *iface, BOOL silent = FALSE, DWORD opt = 0);
   1.336 +};
   1.337 +
   1.338 +class GoatAnimExporterStub : public SceneExport {
   1.339 +public:
   1.340 +	IGameScene *igame;
   1.341 +
   1.342 +	int ExtCount() { return 1; }
   1.343 +	const TCHAR *Ext(int n) { return L"goatanm"; }
   1.344 +	const TCHAR *LongDesc() { return L"Goat3D Animation file"; }
   1.345 +	const TCHAR *ShortDesc() { return L"Goat3D Animation"; }
   1.346 +	const TCHAR *AuthorName() { return L"John Tsiombikas"; }
   1.347 +	const TCHAR *CopyrightMessage() { return copyright_str; }
   1.348 +	const TCHAR *OtherMessage1() { return L"bar1"; }
   1.349 +	const TCHAR *OtherMessage2() { return L"bar2"; }
   1.350 +	unsigned int Version() { return VERSION(VER_MAJOR, VER_MINOR); }
   1.351 +	void ShowAbout(HWND win) { MessageBoxA(win, "Goat3D anim exporter", "About this plugin", 0); }
   1.352 +
   1.353 +	int DoExport(const MCHAR *name, ExpInterface *eiface, Interface *iface, BOOL silent = FALSE, DWORD opt = 0);
   1.354 +};
   1.355 +
   1.356 +static const char *find_dll_dir()
   1.357 +{
   1.358 +	static char path[MAX_PATH];
   1.359 +
   1.360 +	HMODULE dll;
   1.361 +	if(!GetModuleHandleExA(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
   1.362 +			(LPCSTR)find_dll_dir, &dll)) {
   1.363 +		return 0;
   1.364 +	}
   1.365 +	GetModuleFileNameA(dll, path, sizeof path);
   1.366 +
   1.367 +	char *last_slash = strrchr(path, '\\');
   1.368 +	if(last_slash && last_slash[1]) {
   1.369 +		*last_slash = 0;
   1.370 +	}
   1.371 +
   1.372 +	return path;
   1.373 +}
   1.374 +
   1.375 +static int do_export(int which, const MCHAR *name, ExpInterface *eiface, Interface *iface, BOOL non_int, DWORD opt)
   1.376 +{
   1.377 +	const char *dll_fname = "maxgoat.dll";
   1.378 +	char *dll_path;
   1.379 +	HMODULE dll = 0;
   1.380 +	PluginInitFunc init;
   1.381 +	PluginShutdownFunc shutdown;
   1.382 +	PluginClassDescFunc get_class_desc;
   1.383 +	ClassDesc *desc;
   1.384 +	SceneExport *ex;
   1.385 +	int result = IMPEXP_FAIL;
   1.386 +
   1.387 +	const char *plugdir = find_dll_dir();
   1.388 +	if(plugdir) {
   1.389 +		dll_path = new char[strlen(dll_fname) + strlen(plugdir) + 2];
   1.390 +		sprintf(dll_path, "%s\\%s", plugdir, dll_fname);
   1.391 +	} else {
   1.392 +		dll_path = new char[strlen(dll_fname) + 1];
   1.393 +		strcpy(dll_path, dll_fname);
   1.394 +	}
   1.395 +
   1.396 +	if(!(dll = LoadLibraryA(dll_path))) {
   1.397 +		fprintf(logfile, "failed to load exporter: %s\n", dll_path);
   1.398 +		goto done;
   1.399 +	}
   1.400 +
   1.401 +	if(!(get_class_desc = (PluginClassDescFunc)GetProcAddress(dll, "LibClassDesc"))) {
   1.402 +		fprintf(logfile, "maxgoat.dll is invalid (no LibClassDesc function)\n");
   1.403 +		goto done;
   1.404 +	}
   1.405 +
   1.406 +	// first initialize the library
   1.407 +	if((init = (PluginInitFunc)GetProcAddress(dll, "LibInitialize"))) {
   1.408 +		if(!init()) {
   1.409 +			fprintf(logfile, "exporter initialization failed!\n");
   1.410 +			goto done;
   1.411 +		}
   1.412 +	}
   1.413 +
   1.414 +	if(!(desc = get_class_desc(which))) {
   1.415 +		fprintf(logfile, "failed to get the class descriptor\n");
   1.416 +		goto done;
   1.417 +	}
   1.418 +
   1.419 +	if(!(ex = (SceneExport*)desc->Create())) {
   1.420 +		fprintf(logfile, "failed to create exporter class instance\n");
   1.421 +		goto done;
   1.422 +	}
   1.423 +
   1.424 +	__try {
   1.425 +		result = ex->DoExport(name, eiface, iface);
   1.426 +	}
   1.427 +	__except(EXCEPTION_EXECUTE_HANDLER) {
   1.428 +		fprintf(logfile, "Exception caught!\n");
   1.429 +		delete ex;
   1.430 +		goto done;
   1.431 +	}
   1.432 +	delete ex;
   1.433 +
   1.434 +	if((shutdown = (PluginShutdownFunc)GetProcAddress(dll, "LibShutdown"))) {
   1.435 +		shutdown();
   1.436 +	}
   1.437 +
   1.438 +done:
   1.439 +	delete [] dll_path;
   1.440 +	if(dll) {
   1.441 +		FreeLibrary(dll);
   1.442 +	}
   1.443 +	return result;
   1.444 +}
   1.445 +
   1.446 +int GoatExporterStub::DoExport(const MCHAR *name, ExpInterface *eiface, Interface *iface,
   1.447 +		BOOL non_interactive, DWORD opt)
   1.448 +{
   1.449 +	return do_export(0, name, eiface, iface, non_interactive, opt);
   1.450 +}
   1.451 +
   1.452 +
   1.453 +int GoatAnimExporterStub::DoExport(const MCHAR *name, ExpInterface *eiface, Interface *iface,
   1.454 +		BOOL non_interactive, DWORD opt)
   1.455 +{
   1.456 +	return do_export(1, name, eiface, iface, non_interactive, opt);
   1.457 +}
   1.458 +
   1.459 +// ------------------------------------------
   1.460 +
   1.461 +class GoatClassDesc : public ClassDesc2 {
   1.462 +public:
   1.463 +	int IsPublic() { return TRUE; }
   1.464 +	void *Create(BOOL loading = FALSE) { return new GoatExporterStub; }
   1.465 +	const TCHAR *ClassName() { return L"GoatExporterStub"; }
   1.466 +	SClass_ID SuperClassID() { return SCENE_EXPORT_CLASS_ID; }
   1.467 +	Class_ID ClassID() { return Class_ID(0x2e4e6311, 0x2b154d91); }
   1.468 +	const TCHAR *Category() { return L"Mutant Stargoat"; }
   1.469 +
   1.470 +	const TCHAR *InternalName() { return L"GoatExporterStub"; }
   1.471 +	HINSTANCE HInstance() { return hinst; }
   1.472 +};
   1.473 +
   1.474 +class GoatAnimClassDesc : public ClassDesc2 {
   1.475 +public:
   1.476 +	int IsPublic() { return TRUE; }
   1.477 +	void *Create(BOOL loading = FALSE) { return new GoatAnimExporterStub; }
   1.478 +	const TCHAR *ClassName() { return L"GoatAnimExporterStub"; }
   1.479 +	SClass_ID SuperClassID() { return SCENE_EXPORT_CLASS_ID; }
   1.480 +	Class_ID ClassID() { return Class_ID(0x75054666, 0x45487285); }
   1.481 +	const TCHAR *Category() { return L"Mutant Stargoat"; }
   1.482 +
   1.483 +	const TCHAR *InternalName() { return L"GoatAnimExporterStub"; }
   1.484 +	HINSTANCE HInstance() { return hinst; }
   1.485 +};
   1.486 +
   1.487 +
   1.488 +static GoatClassDesc class_desc;
   1.489 +static GoatAnimClassDesc anim_class_desc;
   1.490 +
   1.491 +BOOL WINAPI DllMain(HINSTANCE inst_handle, ULONG reason, void *reserved)
   1.492 +{
   1.493 +	if(reason == DLL_PROCESS_ATTACH) {
   1.494 +		hinst = inst_handle;
   1.495 +		DisableThreadLibraryCalls(hinst);
   1.496 +	}
   1.497 +	return TRUE;
   1.498 +}
   1.499 +
   1.500 +extern "C" {
   1.501 +
   1.502 +__declspec(dllexport) const TCHAR *LibDescription()
   1.503 +{
   1.504 +	return L"Goat3D exporter stub";
   1.505 +}
   1.506 +
   1.507 +__declspec(dllexport) int LibNumberClasses()
   1.508 +{
   1.509 +	return 2;
   1.510 +}
   1.511 +
   1.512 +__declspec(dllexport) ClassDesc *LibClassDesc(int i)
   1.513 +{
   1.514 +	switch(i) {
   1.515 +	case 0:
   1.516 +		return &class_desc;
   1.517 +	case 1:
   1.518 +		return &anim_class_desc;
   1.519 +	default:
   1.520 +		break;
   1.521 +	}
   1.522 +	return 0;
   1.523 +}
   1.524 +
   1.525 +__declspec(dllexport) ULONG LibVersion()
   1.526 +{
   1.527 +	return Get3DSMAXVersion();
   1.528 +}
   1.529 +
   1.530 +__declspec(dllexport) int LibInitialize()
   1.531 +{
   1.532 +	static char path[1024];
   1.533 +
   1.534 +	SHGetFolderPathA(0, CSIDL_PERSONAL, 0, 0, path);
   1.535 +	strcat(path, "/testexpstub.log");
   1.536 +
   1.537 +	if((logfile = fopen(path, "w"))) {
   1.538 +		setvbuf(logfile, 0, _IONBF, 0);
   1.539 +	}
   1.540 +	return TRUE;
   1.541 +}
   1.542 +
   1.543 +__declspec(dllexport) int LibShutdown()
   1.544 +{
   1.545 +	if(logfile) {
   1.546 +		fclose(logfile);
   1.547 +		logfile = 0;
   1.548 +	}
   1.549 +	return TRUE;
   1.550 +}
   1.551 +
   1.552 +}	// extern "C"