Created
January 11, 2013 08:57
-
-
Save anonymous/4509088 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template <size_t N> | |
const char* find_param(request* r, const char (&psz)[N]) { | |
char name[N + 2] = "&"; | |
memcpy(name + 1, psz, N - 1); | |
name[N] = '='; | |
if (strncmp(r->query, name + 1, N)) { | |
return strstr(r->query, name); | |
} else { | |
return args; | |
} | |
} | |
// ... | |
const char* textStart = find_param(r, "text"); | |
// ... check for NULL, find first '&' after textStart and do something useful |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment