本文整理汇总了C++中HttpReq::getFileStat方法的典型用法代码示例。如果您正苦于以下问题:C++ HttpReq::getFileStat方法的具体用法?C++ HttpReq::getFileStat怎么用?C++ HttpReq::getFileStat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HttpReq
的用法示例。
在下文中一共展示了HttpReq::getFileStat方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getReqVar
int RequestVars::getReqVar( HttpSession *pSession, int type, char * &pValue, int bufLen)
{
HttpReq * pReq = pSession->getReq();
int i;
char *p;
if ( type < REF_STRING )
{
pValue = (char *)pReq->getHeader( type );
if ( *pValue )
return pReq->getHeaderLen( type );
else
return 0;
}
switch( type )
{
case REF_REMOTE_HOST:
//FIXME: use remote addr for now
case REF_REMOTE_ADDR:
pValue = (char *)pSession->getPeerAddrString();
return pSession->getPeerAddrStrLen();
case REF_REMOTE_PORT:
return snprintf( pValue, bufLen, "%hu", pSession->getRemotePort() );
case REF_REMOTE_USER:
pValue = (char *)pReq->getAuthUser();
return strlen( pValue );
case REF_REMOTE_IDENT:
//do not support;
return 0;
case REF_REQ_METHOD:
i = pReq->getMethod();
strcpy(pValue, HttpMethod::get( i ) );
return HttpMethod::getLen( i );
case REF_QUERY_STRING:
pValue = (char *)pReq->getQueryString();
return pReq->getQueryStringLen();
case REF_AUTH_TYPE:
//FIXME: hard code for now
strncpy( pValue, "Basic", 6 );
return 5;
case REF_REQUST_FN:
case REF_SCRIPTFILENAME:
case REF_SCRIPT_BASENAME:
case REF_REQ_BASENAME:
{
const AutoStr2 * psTemp = pReq->getRealPath();
if ( psTemp )
{
if (( type == REF_SCRIPT_BASENAME )||
( type == REF_REQ_BASENAME ))
{
const char * pEnd = psTemp->c_str() + psTemp->len();
pValue = (char *)pEnd;
while( pValue[-1] != '/' )
--pValue;
return pEnd - pValue;
}
pValue = (char *)psTemp->c_str();
return psTemp->len();
}
else
return 0;
}
case REF_SCRIPT_UID:
case REF_SCRIPT_GID:
case REF_SCRIPT_USERNAME:
case REF_SCRIPT_GRPNAME:
case REF_SCRIPT_MODE:
{
const AutoStr2 * psTemp = pReq->getRealPath();
if ( psTemp )
{
struct stat& st = pReq->getFileStat();
if ( type == REF_SCRIPT_UID )
{
return snprintf( pValue, bufLen, "%d", st.st_uid );
}
else if ( type == REF_SCRIPT_GID )
{
return snprintf( pValue, bufLen, "%d", st.st_gid );
}
else if ( type == REF_SCRIPT_MODE )
{
return snprintf( pValue, bufLen, "%o", st.st_mode );
}
else if ( type == REF_SCRIPT_USERNAME )
{
struct passwd * pw = getpwuid( st.st_uid );
if ( pw )
return snprintf( pValue, bufLen, "%s", pw->pw_name );
}
else
{
struct group * gr = getgrgid( st.st_gid );
if ( gr )
return snprintf( pValue, bufLen, "%s", gr->gr_name );
}
}
return 0;
}
case REF_PATH_INFO:
//.........这里部分代码省略.........