Reading from config file and attempting to use strtok() to end of line
Basically, here's the function in question:
Code:
static void ConfPassSwhois(aClient *aptr) {
char *myport = NULL, *mypass, *mywhois = NULL;
ConfigItem_except *e;
char line[512];
int len = 0;
for (e = portpass; e; e = (ConfigItem_except *) e->next) {
strcpy(line,e->mask);
myport = strtok(line, ":");
if (myport) {
mypass = strtok(NULL, ":");
mywhois = strtok(NULL, ":");
len = strlen(mywhois);
if ((atoi(myport) == aptr->listener->port)) {
if (mywhois && len < 35)
strcpy(swhois, mywhois);
else
strcpy(swhois, "SWHOIS info is too long!!");
}
}
}
}
The variable swhois has been previously defined in the program as 'static char *swhois[50]; '.
The line in question is "mywhois = strtok(NULL, ":");" as it's reading in 18 characters from the file properly but doesn't continue reading to the end of the line. It is intended to load something like this example '80:somepassword:some description with spaces' from the file and assign it to variables. Everything works (with numerous warnings) except that at the end of it all, 'myswhois' only contains 18 (of say 30) characters. Is there a way i can make strtok() read in more characters? If not, what should I use instead to read the line in?
Thanks for any [positive] feedback.