/* msplugin.cpp - Identify a MilkShape 3D plugin. Jason Hood, 3 June, 2010. Build (VC6): cl /nologo /W3 /GfX /MD /Ox msplugin.cpp setargv.obj */ #define PVERS "1.00" #define PDATE "3 June, 2010" #define WIN32_LEAN_AND_MEAN #include #include "msLib/msPlugIn.h" #include #define STREQ( s1, s2 ) (strcmp( s1, s2 ) == 0) static const char* const Type[] = { NULL, "Import ", "Export ", "Tools ", "Edit ", "Vertex ", "Face ", "Animate" }; int main( int argc, char* argv[] ) { HMODULE dll; FN_CREATE_PLUGIN func; cMsPlugIn* plugin; int type; const char* title; int len; int i; if (argc == 1 || STREQ( argv[1], "/?" ) || STREQ( argv[1], "-?" ) || STREQ( argv[1], "--help" )) { puts( "msPlugIn by Jason Hood .\n" "Version " PVERS " (" PDATE "). Freeware.\n" "http://misc.adoxa.cjb.net/\n" "\n" "Identify a MilkShape 3D plugin.\n" "\n" "msplugin file...\n" "\n" "file\tthe file(s) to identify\n" "\n" "Files that aren't plugins are ignored." ); return 0; } // Identify the longest file name, to provide alignment. len = 0; for (i = 1; i < argc; ++i) { int l = strlen( argv[i] ); if (l > len) len = l; } ++len; // Prevent message box on bad files. SetErrorMode( SEM_FAILCRITICALERRORS ); while (*++argv) { dll = LoadLibrary( *argv ); if (dll == NULL) continue; func = (FN_CREATE_PLUGIN)GetProcAddress( dll, "CreatePlugIn" ); if (func == NULL) { FreeLibrary( dll ); continue; } plugin = func(); if (plugin == NULL) { FreeLibrary( dll ); continue; } if (argc != 2) printf( "%s:%*c", *argv, len - strlen( *argv ), ' ' ); type = plugin->GetType() & cMsPlugIn::eTypeMask; title = plugin->GetTitle(); if (type <= 0 || type >= sizeof(Type)/sizeof(*Type)) printf( "(%d)", type ); else fputs( Type[type], stdout ); printf( " -> %s\n", title ); FreeLibrary( dll ); } return 0; }