Simple library of INI file parser.

Dependents:   TrainInfoSample WatchSensorMail

Files at this revision

API Documentation at this revision

Comitter:
rinosh2
Date:
Thu Nov 18 17:39:02 2010 +0000
Parent:
1:3601c7feb547
Commit message:
Add debug messages

Changed in this revision

IniFile.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 3601c7feb547 -r 4ae80a05f6ea IniFile.cpp
--- a/IniFile.cpp	Wed Nov 17 16:24:11 2010 +0000
+++ b/IniFile.cpp	Thu Nov 18 17:39:02 2010 +0000
@@ -74,7 +74,10 @@
 }
 
 IniFile::Status IniFile::get(const char* key, char* ret, int ret_size){
-	if(!m_fp) return S_OPEN_ERROR;
+	if(!m_fp){
+		printf("IniFile::get %s S_OPEN_ERROR\n", key);
+		return S_OPEN_ERROR;
+	}
 
 	rewind(m_fp);
 	char line[INI_LINE_BUF];
@@ -86,7 +89,7 @@
 
 		*p++ = 0;
 		strtrim(line, line, p - line);
-		if(strcmp(line, key)) continue; // different key
+		if(strcmp(line, key)) continue; // different key // stricmp?
 
 		// check data type
 		switch(ret_size){
@@ -94,6 +97,7 @@
 			strtrim(line, p, INI_LINE_BUF);
 			*(int*)ret = strtoul(line, &p, 0);
 			//return p[0]? S_FORMAT_ERROR : S_SUCCESS; // check end
+			printf("IniFile::get %s INT %d\n", key, *(int*)ret);
 			return S_SUCCESS; // always success
 
 		case DTYPE_BOOL:
@@ -105,12 +109,18 @@
 			case 'f':	*(bool*)ret = false;	break;
 			default:	*(bool*)ret = strtoul(line, &p, 0)? true : false;
 			}
+			printf("IniFile::get %s BOOL %d\n", key, *(bool*)ret);
 			return S_SUCCESS;
 
 		default: // string
-			return strtrim(ret, p, ret_size);
+			{
+				Status sts = strtrim(ret, p, ret_size);
+				printf("IniFile::get %s = '%s'\n", key, ret_size? ret : "E");
+				return sts;
+			}
 		}
 	}
+	printf("IniFile::get S_NO_KEY'%s'\n", key);
 	return S_NO_KEY; // No key
 }
 IniFile::Status IniFile::get(const char* key, int& ret){