Beispiel #1
0
static cell AMX_NATIVE_CALL amx_trim(AMX *amx, cell *params)
{
	int len, newlen;
	char *str = get_amxstring(amx, params[1], 0, len);

	UTIL_TrimLeft(str);
	UTIL_TrimRight(str);

	newlen = strlen(str);
	len -= newlen;

	set_amxstring(amx, params[1], str, newlen);

	return len;
}
Beispiel #2
0
void CPluginMngr::CALMFromFile(const char *file)
{
	char filename[PLATFORM_MAX_PATH];
	FILE *fp = fopen(build_pathname_r(filename, sizeof(filename), "%s", file), "rt");

	if (!fp)
	{
		return;
	}

	// Find now folder
	char pluginName[256];
	char line[256];
	char rline[256];

	while (!feof(fp))
	{
		fgets(line, sizeof(line)-1, fp);
		if (line[0] == ';' || line[0] == '\n' || line[0] == '\0')
		{
			continue;
		}

		/** quick hack */
		char *ptr = line;
		while (*ptr)
		{
			if (*ptr == ';')
			{
				*ptr = '\0';
			} else {
				ptr++;
			}
		}

		strncopy(rline, line, sizeof(rline));
		UTIL_TrimLeft(rline);
		UTIL_TrimRight(rline);

		pluginName[0] = '\0';
		sscanf(rline, "%s", pluginName);

		/* HACK: see if there's a 'disabled' coming up
		 * new block for scopying flexibility
		 */
		if (1)
		{
			const char *_ptr = rline + strlen(pluginName);
			while (*_ptr != '\0'  && isspace(*_ptr))
			{
				_ptr++;
			}
			if ((*_ptr != '\0') && !strcmp(_ptr, "disabled"))
			{
				ke::AString *pString = new ke::AString(pluginName);
				m_BlockList.push_back(pString);
				continue;
			}
		}

		if (!isalnum(*pluginName))
		{
			continue;
		}

		build_pathname_r(filename, sizeof(filename), "%s/%s", get_localinfo("amxx_pluginsdir", "addons/amxmodx/plugins"), pluginName);

		CacheAndLoadModules(filename);
	}

	fclose(fp);
}