예제 #1
0
EXPORT void *CreateInterface(const char *pName, int *pReturnCode)
{
	if (strcmp(pName, METAMOD_PLAPI_NAME) == 0)
	{
		char our_file[256];
		if (!GetFileOfAddress((void *)CreateInterface_MMS, our_file, sizeof(our_file)))
		{
			return NULL;
		}

		/* Go backwards and get the first token */
		size_t len = strlen(our_file);
		for (size_t i = len; i-- > 0;)
		{
			if (IsPathSepChar(our_file[i]))
			{
				our_file[i] = '\0';
				break;
			}
		}

		char new_file[256];
		UTIL_Format(new_file, sizeof(new_file), "%s" PATH_SEP_CHAR MMS_1_4_EP1_FILE, our_file);

		return TryAndLoadLibrary(new_file);
	}

	return NULL;
}
예제 #2
0
DLL_EXPORT void *CreateInterface(const char *iface, int *ret)
{
	/**
	 * If a load has already been attempted, bail out immediately.
	 */
	if (load_attempted)
	{
		return NULL;
	}

	if (strcmp(iface, METAMOD_PLAPI_NAME) == 0)
	{
		char thisfile[256];
		char targetfile[256];

		if (!GetFileOfAddress((void *)CreateInterface_MMS, thisfile, sizeof(thisfile)))
		{
			return NULL;
		}

		size_t len = strlen(thisfile);
		for (size_t iter=len-1; iter<len; iter--)
		{
			if (IsPathSepChar(thisfile[iter]))
			{
				thisfile[iter] = '\0';
				break;
			}
		}

		UTIL_Format(targetfile, sizeof(targetfile), "%s" PATH_SEP_CHAR FILENAME_1_4_EP1, thisfile);

		return _GetPluginPtr(targetfile, METAMOD_FAIL_API_V1);
	}

	return NULL;
}