Eli Hughes
/
RobotPowerLogger-V2
For Terrance
Diff: Code/KeyValue.c
- Revision:
- 0:085749c8446f
diff -r 000000000000 -r 085749c8446f Code/KeyValue.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Code/KeyValue.c Wed Jun 13 15:10:06 2012 +0000 @@ -0,0 +1,69 @@ +#include "System.h" + + +CHAR Key[64]; +CHAR Value[64]; + +BOOL KeyValueSplit(CHAR *LineBuf,CHAR *Key,CHAR *Value) +{ + BOOL FoundKey = FALSE; + + DWORD StringLength; + + + StringLength = strlen(LineBuf); + + + if(LineBuf[StringLength-3] == '\r' || LineBuf[StringLength-3] == '\n') + { + LineBuf[StringLength-3] = NULL; + } + + if(LineBuf[StringLength-2] == '\r' || LineBuf[StringLength-2] == '\n') + { + LineBuf[StringLength-2] = NULL; + } + + if(LineBuf[StringLength-1] == '\r' || LineBuf[StringLength-1] == '\n') + { + LineBuf[StringLength-1] = NULL; + } + + while(*LineBuf!=NULL) + { + if(FoundKey == FALSE) + { + if(*LineBuf > 32) + { + if(*LineBuf == '=') + { + *Key = NULL; + FoundKey = TRUE; + } + else + { + *Key = *LineBuf; + Key++; + } + } + } + else + { + if(*LineBuf > 32) + { + *Value = *LineBuf; + Value++; + } + } + + LineBuf++; + } + + + //make sure the strings are terminated + *Key = NULL; + *Value = NULL; + + return FoundKey; +} +