Jump to content
Sign in to follow this  
Qzen

iniDB extended functionality problems

Recommended Posts

I am working on adding a function to iniDB that returns all the variable names in a specific section in the ini-file.

In the VC++ Project I have added this code:

ini.cpp

bool Ini::ReadAll(char* file, char* section, char* output, size_t outputSize)
{
if(GetPrivateProfileSectionA(section, output, outputSize, file) == NULL)
{
	return false;
}

if(GetLastError() == 2)
{
	return false;
}

return true;
}

dllmain.cpp

if(_stricmp(func, "readall") == 0)
{
char* file = strtok(NULL, ";");
char* sec = strtok(NULL, ";");

if(file != NULL && sec != NULL)
{
	char realFile[MAX_PATH] = {0};

	sprintf_s(realFile, MAX_PATH, "db\\%s.ini", file);

	//logger.write("inidb.log", "read[%s, %s, %s, %s]", logger.dirFile(realFile), sec, key);

	char trueValue[512] = {0};

	if(Ini::ReadAll(logger.dirFile(realFile), sec, trueValue, 512))
	{
		if(_stricmp(trueValue, "c0f916b469c17e0f967c6774e0d837fac0f916b469c17e0f967c6774e0d837fa") == 0)
		{
			strncpy(output, "[false];", outputSize);
		}
		else
		{
			sprintf_s(output, outputSize, "[true, '%s'];", trueValue);
		}
	}
}
else
{
	strncpy(output, "[false];", outputSize);
}

//logger.write("inidb.log", "result: %s", output);
}

There is a problem with this code and that is that it only returns the first variable in the section.

And it returns it this way:

variable="value"

I need it to only return the variable name.

So I am wondering if anyone knows how to make it return all the variable names in a array so I can later parse it in my SQF scripting.

Edited by Qzen

Share this post


Link to post
Share on other sites

Yeah, sure. I will release it in source code for you.

Share this post


Link to post
Share on other sites

I figured out how to achieve what I was trying to do. Now I have some other problems that I need to fix. So I will post the source code here when I have fixed those issues.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×