Eli Hughes
/
RobotPowerLogger-V2
For Terrance
Code/KeyValue.c
- Committer:
- emh203
- Date:
- 2012-06-13
- Revision:
- 0:085749c8446f
File content as of revision 0:085749c8446f:
#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; }