#include <stdio.h>
#include <string.h>
void parse_ftpurl(char * url,
char *user,char *passwd,
char *ipaddr, uint *port)
{
char * p, *host;
char *newURL;
if(!url) return;
if(strncmp(newURL, "ftp://", 6) != 0) {
printf("error ftp URL\n");
} else {
newURL = (char *) malloc(strlen(url)+1);
strcpy(newURL, url + 6);
}
/* username / password */
p = strchr(newURL, '@');
if(p)
*p++ = 0, host = p;
else
host = newURL;
if(p) {
p = strchr(newURL, ':');
if(p) {
*p++ = 0;
strcpy(passwd, p);
}
strcpy(user, newURL);
}
/* host / port */
p = strchr(host, ':');
if(!p) {
*port = 21;
} else {
*port = atoi(p + 1);
解析包含用户名密码的FTPURL
最新推荐文章于 2024-08-27 19:45:02 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)