It has been a while since I did some parsing in C, so I am trying to get it all back
I have a specific string that I need to parse. Basically get the specific string of length M starting at position X.
Here is a sample of data format:
I have a structure to to store this data.Code:1 TestTeamCisco96279 68:7f:74:56:64:ec WPA2PSK/AES 68 11b/g/n NONE In
Right now I have parse until WPAPSK/AES and I wanted to separate the string before and after "/" .
So here is what I did.
The output is these:Code:int get_data(char *ssid, char *mac , char *auth, char * enc, const char *data) { char p[150]; char tmp[30]; memset(p, 0, strlen(data) ); memcpy(p, data, strlen(data)); // get data starting at pos =57 length = 23 memmove(tmp, p+57, 23); int pos = strcspn(tmp , "/"); memmove(enc, tmp+pos+1, strlen(tmp)-pos); memmove(auth, p+57, pos); printf("Auth :: %s \n", auth); printf("Encryption :: %s \n", enc); }
If I changed the lenght of Encryption to 10, then the data is corrrectly displayed.Code:Auth :: WPA2PSK Encryption :: AES WPA2PSK
This is something wrong with how I manipulated the pointers?
englighten me please![]()





Reply With Quote