@kermitaner : As you were posting your code, I was looking at strtok. Although I got it working, I will certainly try your code as well (for learning reasons).
Here is the working code I've come up with. It may be a bit 'heavier' than I would like, but it works beautifully. A huge thanks to "Elysia" and "jeffcobb" for consistently mentioning the strtok function, but I suppose it was fear of my unknowing about the function that kept me from trying it.
Anyway, here's what I have come up with:
Code:
void parseRoomPuzzleKeywords(int room, char *orig)
{
while (*orig && *orig != '*')
{
char delims1[] = "=";
char delims2[] = ",";
char *result = NULL;
switch (*orig)
{
case '0':
orig++;
while (*orig && *orig == ',')
orig++;
char buf0[500];
snprintf(buf0, sizeof(buf0), "%s", orig);
result = strtok( orig, delims1 );
result = strtok( result, delims2 );
orig = buf0;
world[room].puzzle.actionKeyword[0] = _strdup(result);
break;
case '1':
orig++;
while (*orig && *orig == ',')
orig++;
char buf1[500];
snprintf(buf1, sizeof(buf1), "%s", orig);
result = strtok( orig, delims1 );
result = strtok( result, delims2 );
orig = buf1;
world[room].puzzle.actionKeyword[1] = _strdup(result);
break;
case '2':
orig++;
while (*orig && *orig == ',')
orig++;
char buf2[500];
snprintf(buf2, sizeof(buf2), "%s", orig);
result = strtok( orig, delims1 );
result = strtok( result, delims2 );
orig = buf2;
world[room].puzzle.actionKeyword[2] = _strdup(result);
break;
}
orig++;
}
}