/*========================================================================= 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); } } }
/*========================================================================= WriteString : Writes a string to the ini file *========================================================================*/ void CIniFile::WriteString (CCHR *pSection, CCHR *pKey, CCHR *pValue) { EFIND List; char Str [255]; if (ArePtrValid (pSection, pKey, pValue) == FALSE) { return; } if (FindKey (pSection, pKey, &List) == TRUE) { sprintf (Str, "%s=%s%s", List.KeyText, pValue, List.Comment); FreeMem (List.pKey->pText); List.pKey->pText = (char *)malloc (strlen (Str)+1); strcpy (List.pKey->pText, Str); } else { if ((List.pSec != NULL) && (List.pKey == NULL)) // section exist, Key not { AddKey (List.pSec, pKey, pValue); } else { AddSectionAndKey (pSection, pKey, pValue); } } }
/*========================================================================= ReadString : Reads a string from the ini file *========================================================================*/ CCHR *CIniFile::ReadString (CCHR *pSection, CCHR *pKey, CCHR *pDefault) { EFIND List; if (ArePtrValid (pSection, pKey, pDefault) == FALSE) { return pDefault; } if (FindKey (pSection, pKey, &List) == TRUE) { strcpy (m_result, List.ValText); return m_result; } return pDefault; }
/*========================================================================= 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; }
/*========================================================================= 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; }