//
// LibraryMain.cpp for VectorWorks Externals SDK 9.0
//
// Copyright © Diehl Graphsoft, Inc. 2000.
// All Rights Reserved.
//
// This file serves as the main entry point for SDK Plug-in Library Routines. This should be included
// into Mac and Windows project files as the supported main entry point for the Plug-in.
// The user should then implement the entry point documented in MiniCadHookIntf.h
//
//
//
// Started 6/6/00 by Jeff Koppi
// Jeff Koppi
//

//
// Please note that the Dev configuration for this project does not currently build with the 10.4 SDK.
//
//
// The reason why has to do with the information found on the following page:
// 
// http://developer.apple.com/releasenotes/Darwin/SymbolVariantsRelNotes/index.html
// 
// So, basically, what is going on is that the GSESDK is built
// with the 10.5 SDK which is using the new Unix conforming
// functions in the standard libraries. PIS(NET) is being built
// with the 10.4 SDK which, while it has some of the new unix
// conforming functions (which is what we want), does not
// have all of them - like fputs.
// 
// If GSESDK is built with the 10.4 sdk, the original functions
// (i.e. the non-unix conforming functions) will be used and we
// can build PIS(NET).
// 
// When building GSESDK, the actual implementation for fputs is
// not apart of the library. The implementation is only
// provided when PIS(NET) is built.
// 
// Again, since PIS(NET) is built with the 10.4 sdk, it does
// not have the new unix conforming function for fputs and
// therefore cannot supply the implementation for the unix
// conforming fputs function to the GSESDK. Hence, we get a
// link error.
// 
// There is only one line in the GSESDK which is causing the
// problem - in OutputMessage::SendString:
// 
// fprintf(theFile, "%s", s)


#if _WINDOWS && !ALTURA

	#if _AFXDLL
		#include "StdAfx.h"
		#error "Plug-ins should not be linked against DLL based MFC. See comment in GSESetup.h."
	#else
		#include <Windows.h>
	#endif

	#include "GSWinSDK.h"	// Graphsoft Required.
#else
	#include "StdHeaders.h"
#endif

#include <GSESetup.h>
#include <MiniCadHookIntf.h>
#include <MiniCadCallBacks.h>
#include <GSString.X.h>
#include <ExtendedProperties.h>
#include <VWInterfaces.h>

#if GS_WIN || GS_MAC_MACHO
extern "C" long GS_EXTERNAL_ENTRY plugin_main(long routineSelector, void* argTable, long &userData, CallBackPtr cbpParam)
#elif GS_MAC_CFM
extern "C" long GS_EXTERNAL_ENTRY main(long routineSelector, void* argTable, long &userData, CallBackPtr cbpParam)
#endif
{
	GSExternalSetup(cbpParam);
	long reply	= 0;
	
	{ // SCOPE
		// initialize VCOM mechanizm
		::GS_InitializeVCOM( gCBP );

		// Init gSDK
		VCOMPtr<VectorWorks::ISDK> localSDKPtr(VectorWorks::IID_SDK);
		gSDK = localSDKPtr;

		reply = PluginLibraryMain(routineSelector, argTable, userData);
	}
	
	//if (routineSelector != kMenuCheckHilite && action != kMenuNotify)
	GSExternalSetdown(0L);

	return reply;
	return 0;
}




