muteki
Loading...
Searching...
No Matches
ini.h File Reference

INI file operation API. More...

#include <muteki/common.h>

Go to the source code of this file.

Functions

unsigned int _GetPrivateProfileInt (const char *section, const char *key, int default_value, const char *path)
 Read a value from an INI file and parse it as an integer.
 
unsigned int _GetPrivateProfileString (const char *section, const char *key, const char *default_value, char *out, size_t outsize, const char *path)
 Read a value from an INI file.
 
bool _WritePrivateProfileString (const char *section, const char *key, const char *value, const char *path)
 Write a value to an INI file.
 

Detailed Description

INI file operation API.

The functions in this API have the same names (other than the prefixed underscore) and function signatures as their Win32 API counterpart. However some behaviors seen in the original Win32 API were missing or altered, particularly on how these functions handle NULLs. Therefore one should not treat them the same way as treating their Win32 API counterpart.

Function Documentation

◆ _GetPrivateProfileInt()

unsigned int _GetPrivateProfileInt ( const char *  section,
const char *  key,
int  default_value,
const char *  path 
)
extern

Read a value from an INI file and parse it as an integer.

Syscall Number
0x10110
Parameters
sectionThe section where the key is located.
keyThe key.
default_valueThe default value to be returned when the key does not exist in the INI file.
pathDOS 8.3 path to INI file.
Returns
The value that is associated with section.key, or default if the key does not exist.

◆ _GetPrivateProfileString()

unsigned int _GetPrivateProfileString ( const char *  section,
const char *  key,
const char *  default_value,
char *  out,
size_t  outsize,
const char *  path 
)
extern

Read a value from an INI file.

For values, the function will copy at most outsize - 1 bytes and the last byte in the out buffer will always be set to '\0'.

Warning
It is unsafe to use this function as not all systems check outsize and buffer overrun is not preventable on such systems.
Note
The section/key listing behavior as seen in the corresponding Win32 API call is unimplemented and setting section or key to NULL seems to only let the call fail unconditionally.
Syscall Number
0x10111
Parameters
sectionThe section where the key is located.
keyThe key.
default_valueThe default value to be copied to out when the key does not exist in the INI file, or "" when set to NULL.
[out]outPointer to the output buffer.
outsizeMaximum size of the output buffer.
pathDOS 8.3 path to INI file.
Returns
The length of the string copied to the out buffer.

◆ _WritePrivateProfileString()

bool _WritePrivateProfileString ( const char *  section,
const char *  key,
const char *  value,
const char *  path 
)
extern

Write a value to an INI file.

NULL in section, key or value will be interpreted as the string "<NULL>". A NULL key but not a NULL section seems to also cause the function to stop using the specified section.

Syscall Number
0x10112
Parameters
sectionThe section where the key is located.
keyThe key.
valueThe value.
pathDOS 8.3 path to INI file.
Return values
trueThe operation was completed successfully.
falseThe operation failed with error.