url.c
/**
 * Given a string, returns a copy up to and excluding the first '?', or the end.
 */
Given a string, returns a copy up to and excluding the first '?', or the end.
Given a string returns a copy up to and excluding the first ' ? ' or the end .
char* url_get_path(char* url)
{
	if (url == NULL) {
		return NULL;
	}
	char* end = strchr(url, '?');
	if (end == NULL) {
		end = url + strlen(url);
	}
	unsigned int length = end - url;
	char* ret = calloc(length+1, 1);
	strncpy(ret, url, length);
	return ret;
}
char * url_get_path ( char * url ) { if ( url == NULL ) { return NULL ; } char * end = strchr ( url , ' ' ) ; if ( end == NULL ) { end = url + strlen ( url ) ; } unsigned int length = end - url ; char * ret = calloc ( length + 1 , 1 ) ; strncpy ( ret , url , length ) ; return ret ; }
Given a string, returns a copy up to and excluding the first '?
Given a string returns a copy up to and excluding the first ' ?