For Terrance

Dependencies:   mbed

Committer:
emh203
Date:
Wed Jun 13 15:10:06 2012 +0000
Revision:
0:085749c8446f

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
emh203 0:085749c8446f 1 #include "System.h"
emh203 0:085749c8446f 2
emh203 0:085749c8446f 3
emh203 0:085749c8446f 4 CHAR Key[64];
emh203 0:085749c8446f 5 CHAR Value[64];
emh203 0:085749c8446f 6
emh203 0:085749c8446f 7 BOOL KeyValueSplit(CHAR *LineBuf,CHAR *Key,CHAR *Value)
emh203 0:085749c8446f 8 {
emh203 0:085749c8446f 9 BOOL FoundKey = FALSE;
emh203 0:085749c8446f 10
emh203 0:085749c8446f 11 DWORD StringLength;
emh203 0:085749c8446f 12
emh203 0:085749c8446f 13
emh203 0:085749c8446f 14 StringLength = strlen(LineBuf);
emh203 0:085749c8446f 15
emh203 0:085749c8446f 16
emh203 0:085749c8446f 17 if(LineBuf[StringLength-3] == '\r' || LineBuf[StringLength-3] == '\n')
emh203 0:085749c8446f 18 {
emh203 0:085749c8446f 19 LineBuf[StringLength-3] = NULL;
emh203 0:085749c8446f 20 }
emh203 0:085749c8446f 21
emh203 0:085749c8446f 22 if(LineBuf[StringLength-2] == '\r' || LineBuf[StringLength-2] == '\n')
emh203 0:085749c8446f 23 {
emh203 0:085749c8446f 24 LineBuf[StringLength-2] = NULL;
emh203 0:085749c8446f 25 }
emh203 0:085749c8446f 26
emh203 0:085749c8446f 27 if(LineBuf[StringLength-1] == '\r' || LineBuf[StringLength-1] == '\n')
emh203 0:085749c8446f 28 {
emh203 0:085749c8446f 29 LineBuf[StringLength-1] = NULL;
emh203 0:085749c8446f 30 }
emh203 0:085749c8446f 31
emh203 0:085749c8446f 32 while(*LineBuf!=NULL)
emh203 0:085749c8446f 33 {
emh203 0:085749c8446f 34 if(FoundKey == FALSE)
emh203 0:085749c8446f 35 {
emh203 0:085749c8446f 36 if(*LineBuf > 32)
emh203 0:085749c8446f 37 {
emh203 0:085749c8446f 38 if(*LineBuf == '=')
emh203 0:085749c8446f 39 {
emh203 0:085749c8446f 40 *Key = NULL;
emh203 0:085749c8446f 41 FoundKey = TRUE;
emh203 0:085749c8446f 42 }
emh203 0:085749c8446f 43 else
emh203 0:085749c8446f 44 {
emh203 0:085749c8446f 45 *Key = *LineBuf;
emh203 0:085749c8446f 46 Key++;
emh203 0:085749c8446f 47 }
emh203 0:085749c8446f 48 }
emh203 0:085749c8446f 49 }
emh203 0:085749c8446f 50 else
emh203 0:085749c8446f 51 {
emh203 0:085749c8446f 52 if(*LineBuf > 32)
emh203 0:085749c8446f 53 {
emh203 0:085749c8446f 54 *Value = *LineBuf;
emh203 0:085749c8446f 55 Value++;
emh203 0:085749c8446f 56 }
emh203 0:085749c8446f 57 }
emh203 0:085749c8446f 58
emh203 0:085749c8446f 59 LineBuf++;
emh203 0:085749c8446f 60 }
emh203 0:085749c8446f 61
emh203 0:085749c8446f 62
emh203 0:085749c8446f 63 //make sure the strings are terminated
emh203 0:085749c8446f 64 *Key = NULL;
emh203 0:085749c8446f 65 *Value = NULL;
emh203 0:085749c8446f 66
emh203 0:085749c8446f 67 return FoundKey;
emh203 0:085749c8446f 68 }
emh203 0:085749c8446f 69