MiniGUI API Reference (MiniGUI-Processes)
v3.2.0
A mature and proven cross-platform GUI system for embedded and smart IoT devices
|
Data Structures | |
struct | _ETCSECTION |
struct | _ETC_S |
Macros | |
#define | ETC_MAXLINE 1024 |
The max line number of etc file. More... | |
#define | ETC_FILENOTFOUND -1 |
No found etc file. More... | |
#define | ETC_SECTIONNOTFOUND -2 |
No found section in etc file. More... | |
#define | ETC_KEYNOTFOUND -3 |
No found key in etc file. More... | |
#define | ETC_TMPFILEFAILED -4 |
Create tmpfile failed. More... | |
#define | ETC_FILEIOFAILED -5 |
IO operation failed to etc file. More... | |
#define | ETC_INTCONV -6 |
Convert the value string to an integer failed. More... | |
#define | ETC_INVALIDOBJ -7 |
Invalid object to etc file. More... | |
#define | ETC_READONLYOBJ -8 |
Read only to etc file. More... | |
#define | ETC_OK 0 |
Operate success to etc file. More... | |
#define | SetValueToEtc(hEtc, pSection, pKey, pValue) GetValueFromEtc(hEtc, pSection, pKey, pValue, -1) |
Sets the value in the etc object. More... | |
Typedefs | |
typedef struct _ETCSECTION | ETCSECTION |
typedef ETCSECTION * | PETCSECTION |
typedef struct _ETC_S | ETC_S |
Functions | |
MG_EXPORT int GUIAPI | GetValueFromEtcFile (const char *pEtcFile, const char *pSection, const char *pKey, char *pValue, int iLen) |
Gets value from a configuration file. More... | |
MG_EXPORT int GUIAPI | GetIntValueFromEtcFile (const char *pEtcFile, const char *pSection, const char *pKey, int *value) |
Gets integer value from a configuration file. More... | |
MG_EXPORT int GUIAPI | SetValueToEtcFile (const char *pEtcFile, const char *pSection, const char *pKey, char *pValue) |
Sets a value in a configuration file. More... | |
MG_EXPORT int GUIAPI | RemoveSectionInEtcFile (const char *pEtcFile, const char *pSection) |
Removes a section in an etc file. More... | |
MG_EXPORT int GUIAPI | SaveSectionToEtcFile (const char *pEtcFile, PETCSECTION psect) |
Saves a section to an etc file. More... | |
MG_EXPORT GHANDLE GUIAPI | LoadEtcFile (const char *pEtcFile) |
Loads an etc file into memory. More... | |
MG_EXPORT int GUIAPI | SaveEtcToFile (GHANDLE hEtc, const char *file_name) |
Saves an ETC object into a file. More... | |
MG_EXPORT int GUIAPI | UnloadEtcFile (GHANDLE hEtc) |
Unloads an etc file. More... | |
MG_EXPORT int GUIAPI | GetValueFromEtc (GHANDLE hEtc, const char *pSection, const char *pKey, char *pValue, int iLen) |
Gets value from a configuration etc object. More... | |
MG_EXPORT int GUIAPI | GetIntValueFromEtc (GHANDLE hEtc, const char *pSection, const char *pKey, int *pValue) |
Gets the integer value from a configuration etc object. More... | |
MG_EXPORT GHANDLE GUIAPI | FindSectionInEtc (GHANDLE hEtc, const char *pSection, BOOL bCreateNew) |
Finds/Creates a section from an etc object. More... | |
MG_EXPORT int GUIAPI | GetValueFromEtcSec (GHANDLE hSect, const char *pKey, char *pValue, int iLen) |
Gets value from an etc section object. More... | |
MG_EXPORT int GUIAPI | GetIntValueFromEtcSec (GHANDLE hSect, const char *pKey, int *pValue) |
Gets an integer value from an etc section object. More... | |
MG_EXPORT int GUIAPI | SetValueToEtcSec (GHANDLE hSect, const char *pKey, char *pValue) |
Sets the value in the etc section object. More... | |
MG_EXPORT int GUIAPI | RemoveSectionInEtc (GHANDLE hEtc, const char *pSection) |
Removes a section in etc object. More... | |
static int | GetMgEtcValue (const char *pSection, const char *pKey, char *pValue, int iLen) |
Gets value from MiniGUI configuration etc object. More... | |
static int | GetMgEtcIntValue (const char *pSection, const char *pKey, int *value) |
Gets integer value from MiniGUI configuration etc object. More... | |
Variables | |
MG_EXPORT char | ETCFILEPATH [] |
The path name of MiniGUI configuration file. More... | |
The configuration file used by MiniGUI have a similiar format as M$ Windows INI file, i.e. the file consists of sections, and the section consists of key-value pairs, like this:
Assume that the configuration file named my.cfg, if you want get the value of mdev in system section, you can call GetValueFromEtcFile in the following way:
Example:
#define ETC_FILEIOFAILED -5 |
#define ETC_INTCONV -6 |
#define ETC_MAXLINE 1024 |
#define ETC_SECTIONNOTFOUND -2 |
#define SetValueToEtc | ( | hEtc, | |
pSection, | |||
pKey, | |||
pValue | |||
) | GetValueFromEtc(hEtc, pSection, pKey, pValue, -1) |
Sets the value in the etc object.
This fuctions sets the value in the etc object, somewhat similiar to
typedef struct _ETCSECTION ETCSECTION |
Etc The current config section information
typedef ETCSECTION* PETCSECTION |
Finds/Creates a section from an etc object.
This function look for a section named pSection from the etc object hEtc. If there is no such section in the etc object and bCreateNew is TRUE, the function will create an empty section.
hEtc | Handle to the etc object. |
pSection | The name of the section. |
bCreateNew | Indicate whether to create a new section. |
int GUIAPI GetIntValueFromEtc | ( | GHANDLE | hEtc, |
const char * | pSection, | ||
const char * | pKey, | ||
int * | pValue | ||
) |
Gets the integer value from a configuration etc object.
Referenced by GetMgEtcIntValue().
int GUIAPI GetIntValueFromEtcFile | ( | const char * | pEtcFile, |
const char * | pSection, | ||
const char * | pKey, | ||
int * | value | ||
) |
Gets integer value from a configuration file.
This function gets the integer value of the key pKey in the section pSection of the configuration file pEtcFile, and returns the integer value through the buffer pointed to by value.
pEtcFile | The path name of the configuration file. |
pSection | The section name in which the value located. |
pKey | The key name of the value. |
value | The integer value will be saved in this buffer. |
ETC_OK | Gets value successfullly. |
ETC_FILENOTFOUND | Can not find the specified configuration file. |
ETC_SECTIONNOTFOUND | Can not find the specified section in the configuration file. |
ETC_KEYNOTFOUND | Can not find the specified key in the section. |
ETC_FILEIOFAILED | File I/O operation error occurred. |
ETC_INTCONV | Can not convert the value string to an integer. |
Referenced by GetMgEtcIntValue().
int GUIAPI GetIntValueFromEtcSec | ( | GHANDLE | hSect, |
const char * | pKey, | ||
int * | pValue | ||
) |
Gets an integer value from an etc section object.
This function gets an integer value from an etc section object, similar to GetIntValueFromEtc. It gets the value of the key pKey in the section hSect, and saves the value to the buffer pointed to by pValue.
hSect | The handle to the section. |
pKey | The key name of the value. |
pValue | The value will be saved in this buffer. |
ETC_OK | Gets value successfullly. |
ETC_INVALIDOBJ | Invalid etc object. |
ETC_KEYNOTFOUND | Can not find the specified key in the section. |
ETC_INTCONV | Can not convert the value string to an integer. |
|
inlinestatic |
Gets integer value from MiniGUI configuration etc object.
This fuctions get integer value from MiniGUI configuration etc object some what similiar to GetIntValueFromEtcFile and GetIntValueFromEtc
Definition at line 2265 of file minigui.h.
References GetIntValueFromEtc(), and GetIntValueFromEtcFile().
|
inlinestatic |
Gets value from MiniGUI configuration etc object.
This fuctions gets the value from MiniGUi configuration etc object, somewhat similiar to GetValueFromEtcFile and GetValueFromEtc
Definition at line 2245 of file minigui.h.
References GetValueFromEtc(), and GetValueFromEtcFile().
int GUIAPI GetValueFromEtc | ( | GHANDLE | hEtc, |
const char * | pSection, | ||
const char * | pKey, | ||
char * | pValue, | ||
int | iLen | ||
) |
Gets value from a configuration etc object.
This function gets value from an etc object, similar to GetValueFromEtcFile. This function gets the value of the key pKey in the section pSection of the etc object hEtc, and saves the value to the buffer pointed to by pValue.
hEtc | Handle to the etc object. |
pSection | The section name in which the value located. |
pKey | The key name of the value. |
pValue | The value will be saved in this buffer. |
iLen | The length in bytes of the buffer. This function will set value if the iLen is less than 1. |
ETC_OK | Gets value successfullly. |
ETC_INVALIDOBJ | Invalid etc object. |
ETC_SECTIONNOTFOUND | Can not find the specified section in the configuration file. |
ETC_KEYNOTFOUND | Can not find the specified key in the section. |
ETC_READONLYOBJ | The etc object is read-only. |
Referenced by GetMgEtcValue().
int GUIAPI GetValueFromEtcFile | ( | const char * | pEtcFile, |
const char * | pSection, | ||
const char * | pKey, | ||
char * | pValue, | ||
int | iLen | ||
) |
Gets value from a configuration file.
This function gets the value of the key pKey in the section pSection of the configuration file pEtcFile, and saves the value to the buffer pointed to by pValue.
pEtcFile | The path name of the configuration file. |
pSection | The section name in which the value located. |
pKey | The key name of the value. |
pValue | The value will be saved in this buffer. |
iLen | The length in bytes of the buffer. |
ETC_OK | Gets value successfullly. |
ETC_FILENOTFOUND | Can not find the specified configuration file. |
ETC_SECTIONNOTFOUND | Can not find the specified section in the configuration file. |
ETC_KEYNOTFOUND | Can not find the specified key in the section. |
ETC_FILEIOFAILED | File I/O operation error occurred. |
Referenced by GetMgEtcValue().
int GUIAPI GetValueFromEtcSec | ( | GHANDLE | hSect, |
const char * | pKey, | ||
char * | pValue, | ||
int | iLen | ||
) |
Gets value from an etc section object.
This function gets value from an etc section object, similar to GetValueFromEtc. It gets the value of the key pKey in the section hSect, and saves the value to the buffer pointed to by pValue.
hSect | The handle to the section. |
pKey | The key name of the value. |
pValue | The value will be saved in this buffer. |
iLen | The length in bytes of the buffer. This function will set value if the iLen is less than 1. |
ETC_OK | Gets value successfullly. |
ETC_INVALIDOBJ | Invalid etc object. |
ETC_KEYNOTFOUND | Can not find the specified key in the section. |
ETC_READONLYOBJ | The section object is read-only. |
GHANDLE GUIAPI LoadEtcFile | ( | const char * | pEtcFile | ) |
Loads an etc file into memory.
This function loads the content of an etc file into the memory, later, you can visit the content using GetValueFromEtc function.
pEtcFile | The path name of the configuration file. If pEtcFile is NULL, the function will create an empty ETC object. |
int GUIAPI RemoveSectionInEtc | ( | GHANDLE | hEtc, |
const char * | pSection | ||
) |
Removes a section in etc object.
This function removes a section named pSection from the etc object hEtc.
hEtc | The handle to the etc object. |
pSection | The name of the pSection; |
ETC_OK | Gets value successfullly. |
ETC_INVALIDOBJ | Invalid etc object. |
ETC_READONLYOBJ | The etc object is read-only. |
ETC_SECTIONNOTFOUND | Can not find the specified section in the etc object. |
int GUIAPI RemoveSectionInEtcFile | ( | const char * | pEtcFile, |
const char * | pSection | ||
) |
Removes a section in an etc file.
This function removes a section named pSection from the etc file named pEtcFile.
pEtcFile | The name of the etc file. |
pSection | The name of the pSection; |
ETC_OK | Gets value successfullly. |
ETC_FILEIOFAILED | File I/O operation error occurred. |
ETC_SECTIONNOTFOUND | Can not find the specified section in the etc object. |
int GUIAPI SaveEtcToFile | ( | GHANDLE | hEtc, |
const char * | file_name | ||
) |
Saves an ETC object into a file.
This function saves the etc object into the file named file_name;
hEtc | Handle to the etc object. |
file_name | The name of the target file. |
ETC_OK | Sets the etc object successfullly. |
ETC_INVALIDOBJ | Invalid etc object. |
ETC_FILEIOFAILED | File I/O operation error occurred. |
int GUIAPI SaveSectionToEtcFile | ( | const char * | pEtcFile, |
PETCSECTION | psect | ||
) |
Saves a section to an etc file.
This function saves a section named psect to the etc file named pEtcFile.
pEtcFile | The name of the etc file. |
psect | The name of the psect; |
ETC_OK | Gets value successfullly. |
ETC_FILEIOFAILED | File I/O operation error occurred. |
ETC_SECTIONNOTFOUND | Can not find the specified section in the etc object. |
int GUIAPI SetValueToEtcFile | ( | const char * | pEtcFile, |
const char * | pSection, | ||
const char * | pKey, | ||
char * | pValue | ||
) |
Sets a value in a configuration file.
This function sets the value of the key pKey in the section pSection of the configuration file pEtcFile to be the string pointed to by pValue.
pEtcFile | The path name of the configuration file. |
pSection | The section name in which the value located. |
pKey | The key name of the value. |
pValue | The null-terminated value string. |
ETC_OK | Sets value successfullly. |
ETC_FILEIOFAILED | File I/O operation error occurred. |
ETC_TMPFILEFAILED | Can not create temporary file. |
int GUIAPI SetValueToEtcSec | ( | GHANDLE | hSect, |
const char * | pKey, | ||
char * | pValue | ||
) |
Sets the value in the etc section object.
This fuctions sets the value in the etc section object hSect, somewhat similiar to SetValueToEtc
GUIAPI UnloadEtcFile | ( | GHANDLE | hEtc | ) |
Unloads an etc file.
This function unloads the etc object generated by using
hEtc | Handle of the etc object. |
char * ETCFILEPATH |
The path name of MiniGUI configuration file.
By default, the configuration file of MiniGUI must be installed in /etc, /usr/local/etc or your home directory. When you install it in your home directory, the name should be ".MiniGUI.cfg".
MiniGUI will try to use MiniGUI.cfg in the current directory, ~/.MiniGUI.cfg, then /usr/local/etc/MiniGUI.cfg, and /etc/MiniGUI.cfg last.
If MiniGUI can not find any MiniGUI.cfg file, or find a bad formated configure file, the initialzation of MiniGUI will be canceled.