[摘要]hex(*from++);break;case '+' :ch = ' '; break;}*to++ = ch;}*to = '\0';}int P...
hex(*from++);
break;
case '+' :
ch = ' '; break;
}
*to++ = ch;
}
*to = '\0';
}
int Parse::hex( char c )
{
if ( isdigit( c ) )
return c-'0';
if ( isalpha( c ) )
return tolower(c)-'a'+10;
return 0;
}
char* Parse::map_uname( char *path )
{
#ifndef NO_MAP
if ( path[0] == '~' )
{
char uname[255]; // 容纳用户名字的变量
char *rest = &path[1];
char *p = &uname[0];
while ( *rest != '/' && *rest != '\0' )
{
*p++ = *rest++;
}
*p = '\0'; // 结束标识
char *root = uname;
passwd *pw = getpwnam( uname );
if ( pw != NULL )
{
root = pw->pw_dir; // 用户的主目录
}
int len_root = strlen(root);
int len_path = len_root + strlen(rest);
char *new_path = new char[len_path+1]; // 动态字符
strcpy( &new_path[0], root ); // 复制用户路径
strcpy( &new_path[len_root], rest ); // 其余部分
return new_path;
} else {
return path;
}
#endif
return path;
}
#endif
关键词:CGI图文详细教程(7)解码数据发送给CGI脚本之一