Exemple #1
0
/*=========================================================================
   WriteString : Writes a string to the ini file
*========================================================================*/
void WriteString (cchr * Section, cchr * pKey, cchr * Value)
{
    EFIND List;
    char Str[255];

    if (ArePtrValid (Section, pKey, Value) == FALSE)
    {
        return;
    }
    if (FindpKey (Section, pKey, &List) == TRUE)
    {
        sprintf (Str, "%s=%s%s", List.KeyText, Value, List.Comment);
        FreeMem (List.pKey->Text);
        List.pKey->Text = (char *) malloc (strlen (Str) + 1);
        strcpy (List.pKey->Text, Str);
    }
    else
    {
        if ((List.pSec != NULL) && (List.pKey == NULL)) /* section exist, pKey not */
        {
            AddpKey (List.pSec, pKey, Value);
        }
        else
        {
            AddSectionAndpKey (Section, pKey, Value);
        }
    }
}
Exemple #2
0
/*=========================================================================
   ReadString : Reads a string from the ini file
*========================================================================*/
const char *ReadString(cchr * Section, cchr * pKey, cchr * Default)
{
    EFIND List;
    if (ArePtrValid(Section, pKey, Default) == FALSE) {
        return Default;
    }
    if (FindpKey(Section, pKey, &List) == TRUE) {
        strcpy(Result, List.ValText);
        return Result;
    }
    return Default;
}
Exemple #3
0
/*=========================================================================
   read_string : Reads a string from the ini file
*========================================================================*/
const char *
read_string (INIFILE* thiz, cchr * Section, cchr * pKey, cchr * Default)
{
	EFIND List;
	if (ArePtrValid (Section, pKey, Default) == FALSE)
	{
		printf("ArePtrValid Fail!\n");
		return Default;
	}
	if (FindpKey (thiz, Section, pKey, &List) == TRUE)
	{
		strcpy (thiz->result, List.ValText);
		return thiz->result;
    }
	return Default;
}
Exemple #4
0
bool DeleteKey(cchr * Section, cchr * pKey)
{
    EFIND List;
    struct ENTRY *pPrev;
    struct ENTRY *pNext;

    if (FindpKey(Section, pKey, &List) == TRUE) {
        pPrev = List.pKey->pPrev;
        pNext = List.pKey->pNext;
        if (pPrev) {
            pPrev->pNext = pNext;
        }
        if (pNext) {
            pNext->pPrev = pPrev;
        }
        FreeMem(List.pKey->Text);
        FreeMem(List.pKey);
        return TRUE;
    }
    return FALSE;
}