Created
December 14, 2011 04:48
-
-
Save fknaopen/1475301 to your computer and use it in GitHub Desktop.
get cgi-name from URL
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
#include <stdio.h> | |
#include <string.h> | |
/*------------------------------------------------------------------------------*/ | |
/* | |
* @brief get cgi(included "/" ) from URL (URL文字列からcgi名('/'を含む)を取得) | |
* @param [in] in URL-strings | |
* @retval *p cgi-strings | |
* @retval *"\0" error | |
*/ | |
/*------------------------------------------------------------------------------*/ | |
char * func_cut_cgi( const char * in ) | |
{ | |
static char *blank = "\0"; | |
char *p; | |
// check argument | |
if ( in != NULL ){ | |
p = strrchr( in, '/' ); | |
if ( NULL == p ) { | |
p = blank; | |
} | |
}else { | |
// invalid argument | |
p = blank; | |
} | |
return p; | |
} | |
// test | |
main() { | |
char *url; | |
url = "http://www.a.b.c/cgi/jobs.cgi?h=99&z=3"; | |
printf( "URL[%s] -> cgi[%s]\n", url, func_cut_cgi( url )); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment