Instead of using a string, you better use an enumeration with all possible cases.
typedef enum { FIELD_SSID, FIELD_RATE, } field_t field_t string;
and then use the switch
switch (string) { case FIELD_SSID: //use ssid break; case FIELD_RATE: //use rate break; }
This method is faster than string comparison.
If you use only one field OR another, you can use a union instead of a structure.
source share