本文整理汇总了C++中StrPtrLen::Equal方法的典型用法代码示例。如果您正苦于以下问题:C++ StrPtrLen::Equal方法的具体用法?C++ StrPtrLen::Equal怎么用?C++ StrPtrLen::Equal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StrPtrLen
的用法示例。
在下文中一共展示了StrPtrLen::Equal方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
inline Bool16 HasAuthentication(StringParser *theFullRequestPtr, StrPtrLen* namePtr, StrPtrLen* passwordPtr, StrPtrLen* outAuthTypePtr)
{
// Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
Bool16 hasAuthentication = false;
StrPtrLen strPtr;
StrPtrLen authType;
StrPtrLen authString;
while (theFullRequestPtr->GetDataRemaining() > 0)
{
theFullRequestPtr->ConsumeWhitespace();
theFullRequestPtr->ConsumeUntilWhitespace(&strPtr);
if ( strPtr.Len == 0 || !strPtr.Equal(StrPtrLen("Authorization:")) )
continue;
theFullRequestPtr->ConsumeWhitespace();
theFullRequestPtr->ConsumeUntilWhitespace(&authType);
if ( authType.Len == 0 )
continue;
theFullRequestPtr->ConsumeWhitespace();
theFullRequestPtr->ConsumeUntil(&authString, StringParser::sEOLMask);
if ( authString.Len == 0 )
continue;
if (outAuthTypePtr != NULL)
outAuthTypePtr->Set(authType.Ptr, authType.Len);
if (authType.Equal(StrPtrLen("Basic") ) )
{
(void) ParseAuthNameAndPassword(&authString,namePtr, passwordPtr);
if (namePtr->Len == 0)
continue;
hasAuthentication = true;
break;
}
else if (authType.Equal(sAuthRef) )
{
namePtr->Set(NULL,0);
passwordPtr->Set(authString.Ptr, authString.Len);
hasAuthentication = true;
break;
}
};
return hasAuthentication;
}
示例2: IsAuthentic
Bool16 IsAuthentic(QTSS_Filter_Params* inParams,StringParser *fullRequestPtr)
{
Bool16 isAuthentic = false;
if (!sAuthenticationEnabled) // no authentication
{
isAuthentic = true;
}
else // must authenticate
{
StrPtrLen theClientIPAddressStr;
(void) QTSS_GetValuePtr(inParams->inRTSPSession, qtssRTSPSesRemoteAddrStr, 0, (void**)&theClientIPAddressStr.Ptr, &theClientIPAddressStr.Len);
Bool16 isLocal = IPComponentStr(&theClientIPAddressStr).IsLocal();
StrPtrLen authenticateName;
StrPtrLen authenticatePassword;
StrPtrLen authType;
Bool16 hasAuthentication = HasAuthentication(fullRequestPtr,&authenticateName,&authenticatePassword, &authType);
if (hasAuthentication)
{
if (authType.Equal(sAuthRef))
{
if (isLocal)
isAuthentic = OSXAuthenticate(&authenticatePassword);
}
else
isAuthentic = Authenticate(inParams->inRTSPRequest, &authenticateName,&authenticatePassword);
}
}
// if (isAuthentic)
// isAuthentic = AuthorizeAdminRequest(inParams->inRTSPRequest);
(void) QTSS_SetValue(inParams->inRTSPRequest, sAuthenticatedID, 0, (void*)&isAuthentic, sizeof(isAuthentic));
return isAuthentic;
}
示例3: sNoAuthScheme
void QTSServerPrefs::UpdateAuthScheme()
{
static StrPtrLen sNoAuthScheme("none");
static StrPtrLen sBasicAuthScheme("basic");
static StrPtrLen sDigestAuthScheme("digest");
// Get the auth scheme attribute
StrPtrLen* theAuthScheme = this->GetValue(qtssPrefsAuthenticationScheme);
if (theAuthScheme->Equal(sNoAuthScheme))
fAuthScheme = qtssAuthNone;
else if (theAuthScheme->Equal(sBasicAuthScheme))
fAuthScheme = qtssAuthBasic;
else if (theAuthScheme->Equal(sDigestAuthScheme))
fAuthScheme = qtssAuthDigest;
}
示例4: ParseRequestLine
QTSS_Error HTTPRequest::ParseRequestLine(StringParser* parser)
{
// Get the method - If the method is not one of the defined methods
// then it doesn't return an error but sets fMethod to httpIllegalMethod
StrPtrLen theParsedData;
parser->ConsumeWord(&theParsedData);
fMethod = HTTPProtocol::GetMethod(&theParsedData);
//还有可能是HTTP Response类型
if((fMethod == httpIllegalMethod) && theParsedData.Equal("HTTP"))
{
parser->ConsumeUntilWhitespace();//过滤掉HTTP/1.1
parser->ConsumeUntilDigit(NULL);
UInt32 statusCode = parser->ConsumeInteger(NULL);
if( statusCode != 0 )
{
fHTTPType = httpResponseType;
parser->ConsumeWhitespace();
parser->ConsumeUntilWhitespace(NULL);
// Go past the end of line
if (!parser->ExpectEOL())
{
fStatusCode = httpBadRequest;
return QTSS_BadArgument; // Request line is not properly formatted!
}
return QTSS_NoErr;
}
}
// Consume whitespace
parser->ConsumeWhitespace();
// Parse the URI - If it fails returns an error after setting
// the fStatusCode to the appropriate error code
QTSS_Error err = ParseURI(parser);
if (err != QTSS_NoErr)
return err;
// Consume whitespace
parser->ConsumeWhitespace();
// If there is a version, consume the version string
StrPtrLen versionStr;
parser->ConsumeUntil(&versionStr, StringParser::sEOLMask);
// Check the version
if (versionStr.Len > 0)
fVersion = HTTPProtocol::GetVersion(&versionStr);
// Go past the end of line
if (!parser->ExpectEOL())
{
fStatusCode = httpBadRequest;
return QTSS_BadArgument; // Request line is not properly formatted!
}
return QTSS_NoErr;
}
示例5: IsAdminRequest
inline Bool16 IsAdminRequest(StringParser *theFullRequestPtr)
{
Bool16 handleRequest = false;
if (theFullRequestPtr != NULL) do
{
StrPtrLen strPtr;
theFullRequestPtr->ConsumeWord(&strPtr);
if ( !strPtr.Equal(StrPtrLen("GET")) ) break; //it's a "Get" request
theFullRequestPtr->ConsumeWhitespace();
if ( !theFullRequestPtr->Expect('/') ) break;
theFullRequestPtr->ConsumeWord(&strPtr);
if ( strPtr.Len == 0 || !strPtr.Equal(StrPtrLen("modules") ) ) break;
if (!theFullRequestPtr->Expect('/') ) break;
theFullRequestPtr->ConsumeWord(&strPtr);
if ( strPtr.Len == 0 || !strPtr.Equal(StrPtrLen("admin") ) ) break;
handleRequest = true;
} while (false);
return handleRequest;
}
示例6: ParseURL
// Parse out the URL from the HTTP GET line.
Bool16 ParseURL(StrPtrLen& theRequest, char* outURL, UInt16 maxlen)
{
StringParser reqParse(&theRequest);
StrPtrLen strPtr;
::memset(outURL, 0, maxlen);
reqParse.ConsumeWord(&strPtr);
if ( !strPtr.Equal(StrPtrLen("GET")) )
{
return false;
}
reqParse.ConsumeWhitespace();
reqParse.ConsumeUntilWhitespace(&strPtr);
if (strPtr.Len == 0)
return false;
else if ((UInt16)strPtr.Len > maxlen-1)
strPtr.Len = maxlen-1;
::memcpy(outURL, strPtr.Ptr, strPtr.Len);
return true;
}
示例7: GetModuleObjectByName
QTSS_ModulePrefsObject QTSSModuleUtils::GetModuleObjectByName(const StrPtrLen& inModuleName)
{
QTSS_ModuleObject theModule = NULL;
UInt32 theLen = sizeof(theModule);
for (int x = 0; QTSS_GetValue(sServer, qtssSvrModuleObjects, x, &theModule, &theLen) == QTSS_NoErr; x++)
{
Assert(theModule != NULL);
Assert(theLen == sizeof(theModule));
StrPtrLen theName;
QTSS_Error theErr = QTSS_GetValuePtr(theModule, qtssModName, 0, (void**)(void*)&theName.Ptr, &theName.Len);
Assert(theErr == QTSS_NoErr);
if (inModuleName.Equal(theName))
return theModule;
#if DEBUG
theModule = NULL;
theLen = sizeof(theModule);
#endif
}
return NULL;
}
示例8: Parse
void SDPSourceInfo::Parse(char* sdpData, UInt32 sdpLen)
{
//
// There are some situations in which Parse can be called twice.
// If that happens, just return and don't do anything the second time.
if (fSDPData.Ptr != NULL)
return;
Assert(fStreamArray == NULL);
char *sdpDataCopy = new char[sdpLen];
Assert(sdpDataCopy != NULL);
memcpy(sdpDataCopy,sdpData, sdpLen);
fSDPData.Set(sdpDataCopy, sdpLen);
// If there is no trackID information in this SDP, we make the track IDs start
// at 1 -> N
UInt32 currentTrack = 1;
bool hasGlobalStreamInfo = false;
StreamInfo theGlobalStreamInfo; //needed if there is one c= header independent of
//individual streams
StrPtrLen sdpLine;
StringParser trackCounter(&fSDPData);
StringParser sdpParser(&fSDPData);
UInt32 theStreamIndex = 0;
//walk through the SDP, counting up the number of tracks
// Repeat until there's no more data in the SDP
while (trackCounter.GetDataRemaining() > 0)
{
//each 'm' line in the SDP file corresponds to another track.
trackCounter.GetThruEOL(&sdpLine);
if ((sdpLine.Len > 0) && (sdpLine.Ptr[0] == 'm'))
fNumStreams++;
}
//We should scale the # of StreamInfos to the # of trax, but we can't because
//of an annoying compiler bug...
fStreamArray = new StreamInfo[fNumStreams];
::memset(fStreamArray, 0, sizeof(StreamInfo) * fNumStreams);
// set the default destination as our default IP address and set the default ttl
theGlobalStreamInfo.fDestIPAddr = INADDR_ANY;
theGlobalStreamInfo.fTimeToLive = kDefaultTTL;
//Set bufferdelay to default of 3
theGlobalStreamInfo.fBufferDelay = (Float32) eDefaultBufferDelay;
//Now actually get all the data on all the streams
while (sdpParser.GetDataRemaining() > 0)
{
sdpParser.GetThruEOL(&sdpLine);
if (sdpLine.Len == 0)
continue;//skip over any blank lines
switch (*sdpLine.Ptr)
{
case 't':
{
StringParser mParser(&sdpLine);
mParser.ConsumeUntil(NULL, StringParser::sDigitMask);
UInt32 ntpStart = mParser.ConsumeInteger(NULL);
mParser.ConsumeUntil(NULL, StringParser::sDigitMask);
UInt32 ntpEnd = mParser.ConsumeInteger(NULL);
SetActiveNTPTimes(ntpStart,ntpEnd);
}
break;
case 'm':
{
if (hasGlobalStreamInfo)
{
fStreamArray[theStreamIndex].fDestIPAddr = theGlobalStreamInfo.fDestIPAddr;
fStreamArray[theStreamIndex].fTimeToLive = theGlobalStreamInfo.fTimeToLive;
}
fStreamArray[theStreamIndex].fTrackID = currentTrack;
currentTrack++;
StringParser mParser(&sdpLine);
//find out what type of track this is
mParser.ConsumeLength(NULL, 2);//go past 'm='
StrPtrLen theStreamType;
mParser.ConsumeWord(&theStreamType);
if (theStreamType.Equal(sVideoStr))
fStreamArray[theStreamIndex].fPayloadType = qtssVideoPayloadType;
else if (theStreamType.Equal(sAudioStr))
fStreamArray[theStreamIndex].fPayloadType = qtssAudioPayloadType;
//find the port for this stream
mParser.ConsumeUntil(NULL, StringParser::sDigitMask);
SInt32 tempPort = mParser.ConsumeInteger(NULL);
if ((tempPort > 0) && (tempPort < 65536))
//.........这里部分代码省略.........
示例9: GetAccessFileInfo
void AccessChecker::GetAccessFileInfo(const char* inQTAccessDir)
{
Assert( fAccessFile != NULL);
const int kBufLen = 2048;
char buf[kBufLen];
StrPtrLen bufLine;
::qtss_printf("QTSSDemoODAuthModule: File Info\n");
while ( std::fgets(buf, kBufLen, fAccessFile) != NULL )
{
bufLine.Set(buf, strlen(buf));
StringParser bufParser(&bufLine);
//skip over leading whitespace
bufParser.ConsumeUntil(NULL, StringParser::sWhitespaceMask);
//skip over comments and blank lines...
if ( (bufParser.GetDataRemaining() == 0) || (bufParser[0] == '#') || (bufParser[0] == '\0') )
continue;
StrPtrLen word;
bufParser.ConsumeWord(&word);
bufParser.ConsumeWhitespace();
if ( word.Equal("AuthName") ) //realm name
{
bufParser.GetThruEOL(&word);
fRealmHeader = word.Ptr;
}
else if ( word.Equal("AuthUserFile" ) ) //users name
{
char filePath[kBufLen];
bufParser.GetThruEOL(&word);
if (word.Ptr[0] == '/') //absolute path
{
std::memcpy(filePath, word.Ptr, word.Len);
filePath[word.Len] = '\0';
}
else
{
std::snprintf(filePath, sizeof(filePath), "%s/%s", inQTAccessDir, word.Ptr);
}
fUsersFile = std::fopen(filePath, "r");
}
else if ( word.Equal("AuthGroupFile") ) //groups name
{
char filePath[kBufLen];
bufParser.GetThruEOL(&word);
if (word.Ptr[0] == '/') //absolute path
{
std::memcpy(filePath, word.Ptr, word.Len);
filePath[word.Len] = '\0';
}
else
{
std::snprintf(filePath, sizeof(filePath), "%s/%s", inQTAccessDir, word.Ptr);
}
fGroupsFile = std::fopen(filePath, "r");
}
}
if (fUsersFile == NULL)
{
fUsersFile = std::fopen(fUsersFilePath.c_str(), "r");
}
if (fGroupsFile == NULL)
{
fGroupsFile = std::fopen(fGroupsFilePath.c_str(), "r");
}
}
示例10: CheckUserAccess
bool AccessChecker::CheckUserAccess(const char* inUsername)
{
::qtss_printf("In QTSSDemoODAuthModule: Check User Access - start\n");
const int kBufLen = 2048;
char buf[kBufLen];
StrPtrLen bufLine;
if ( fAccessFile == NULL )
return false;
std::rewind(fAccessFile);
while ( std::fgets(buf, kBufLen, fAccessFile) != NULL )
{
bufLine.Set(buf, strlen(buf));
StringParser bufParser(&bufLine);
//skip over leading whitespace
bufParser.ConsumeUntil(NULL, StringParser::sWhitespaceMask);
//skip over comments and blank lines...
if ((bufParser.GetDataRemaining() == 0) || (bufParser[0] == '#') || (bufParser[0] == '\0') )
continue;
StrPtrLen word;
bufParser.ConsumeWord(&word);
if ( word.Equal("require") )
{
bufParser.ConsumeWhitespace();
bufParser.ConsumeWord(&word);
if ( word.Equal("user") )
{
while (word.Len != 0)
{
bufParser.ConsumeWhitespace();
bufParser.ConsumeWord(&word);
if (word.Equal(inUsername))
{
::qtss_printf("QTSSDemoODAuthModule in CheckUserAccess() : user %s found\n", inUsername);
return true;
}
}
}
else if (word.Equal("valid-user"))
{
::qtss_printf("QTSSDemoODAuthModule in CheckUserAccess(): valid-user\n");
return true;
}
else if ( word.Equal("group") )
{
while (word.Len != 0)
{
bufParser.ConsumeWhitespace();
bufParser.ConsumeWord(&word);
if ( this->CheckGroupMembership(inUsername, word.GetAsCString()) )
{
::qtss_printf("QTSSDemoODAuthModule in CheckUserAccess(): user is part of %s group\n", word.GetAsCString());
return true;
}
}
}
}
}
return false;
}
示例11: FindUsersAndGroupsFilesAndAuthScheme
// allocates memory for outUsersFilePath and outGroupsFilePath - remember to delete
// returns the auth scheme
QTSS_AuthScheme QTAccessFile::FindUsersAndGroupsFilesAndAuthScheme(char* inAccessFilePath, QTSS_ActionFlags inAction, char** outUsersFilePath, char** outGroupsFilePath)
{
QTSS_AuthScheme authScheme = qtssAuthNone;
QTSS_ActionFlags currentFlags = qtssActionFlagsRead;
if (inAccessFilePath == NULL)
return authScheme;
*outUsersFilePath = NULL;
*outGroupsFilePath = NULL;
//Assert(outUsersFilePath == NULL);
//Assert(outGroupsFilePath == NULL);
StrPtrLen accessFileBuf;
(void)QTSSModuleUtils::ReadEntireFile(inAccessFilePath, &accessFileBuf);
OSCharArrayDeleter accessFileBufDeleter(accessFileBuf.Ptr);
StringParser accessFileParser(&accessFileBuf);
StrPtrLen line;
StrPtrLen word;
while( accessFileParser.GetDataRemaining() != 0 )
{
accessFileParser.GetThruEOL(&line); // Read each line
StringParser lineParser(&line);
lineParser.ConsumeWhitespace(); //skip over leading whitespace
if (lineParser.GetDataRemaining() == 0) // must be an empty line
continue;
char firstChar = lineParser.PeekFast();
if ( (firstChar == '#') || (firstChar == '\0') )
continue; //skip over comments and blank lines...
lineParser.ConsumeUntilWhitespace(&word);
if ( word.Equal("<Limit") ) // a limit line
{
currentFlags = qtssActionFlagsNoFlags; // clear to no access
lineParser.ConsumeWhitespace();
lineParser.ConsumeUntil( &word, sWhitespaceAndGreaterThanMask); // the flag <limit Read> or <limit Read >
while (word.Len != 0) // compare each word in the line
{
if (word.Equal("WRITE") )
{
currentFlags |= inAction & qtssActionFlagsWrite; // accept following lines if inFlags has write
}
if (word.Equal("READ") )
{
currentFlags |= inAction & qtssActionFlagsRead; // accept following lines if inFlags has read
}
lineParser.ConsumeWhitespace();
lineParser.ConsumeUntil(&word, sWhitespaceAndGreaterThanMask);
}
continue; //done with limit line
}
if ( word.Equal("</Limit>") )
currentFlags = qtssActionFlagsRead; // set the current access state to the default of read access
if (0 == (currentFlags & inAction))
continue; // ignore lines because inFlags doesn't match the current access state
if (word.Equal("AuthUserFile") )
{
lineParser.ConsumeWhitespace();
lineParser.GetThruEOL(&word);
StringParser::UnQuote(&word);// if the parsed string is surrounded by quotes then remove them.
if(*outUsersFilePath != NULL) // we are encountering the AuthUserFile keyword twice!
delete[] *outUsersFilePath; // The last one found takes precedence...delete the previous path
*outUsersFilePath = word.GetAsCString();
continue;
}
if (word.Equal("AuthGroupFile") )
{
lineParser.ConsumeWhitespace();
lineParser.GetThruEOL(&word);
StringParser::UnQuote(&word);// if the parsed string is surrounded by quotes then remove them.
if(*outGroupsFilePath != NULL) // we are encountering the AuthGroupFile keyword twice!
delete[] *outGroupsFilePath; // The last one found takes precedence...delete the previous path
*outGroupsFilePath = word.GetAsCString();
continue;
}
if (word.Equal("AuthScheme") )
{
lineParser.ConsumeWhitespace();
lineParser.GetThruEOL(&word);
StringParser::UnQuote(&word);// if the parsed string is surrounded by quotes then remove them.
if (word.Equal("basic"))
//.........这里部分代码省略.........
示例12: AccessAllowed
Bool16 QTAccessFile::AccessAllowed ( char *userName, char**groupArray, UInt32 numGroups, StrPtrLen *accessFileBufPtr,
QTSS_ActionFlags inFlags,StrPtrLen* ioRealmNameStr, Bool16 *outAllowAnyUserPtr, void *extraDataPtr
)
{
if (NULL == accessFileBufPtr || NULL == accessFileBufPtr->Ptr || 0 == accessFileBufPtr->Len)
return true; // nothing to check
if (ioRealmNameStr != NULL && ioRealmNameStr->Ptr != NULL && ioRealmNameStr->Len > 0)
ioRealmNameStr->Ptr[0] = 0;
StringParser accessFileParser(accessFileBufPtr);
QTSS_ActionFlags currentFlags = qtssActionFlagsRead;
StrPtrLen line;
StrPtrLen word;
Bool16 haveUserName = false;
Bool16 haveRealmResultBuffer = false;
Bool16 haveGroups = false;
*outAllowAnyUserPtr = false;
haveUserName = HaveUser(userName, extraDataPtr);
haveGroups = HaveGroups(groupArray, numGroups, extraDataPtr);
haveRealmResultBuffer = HaveRealm(userName, ioRealmNameStr, extraDataPtr );
while( accessFileParser.GetDataRemaining() != 0 )
{
accessFileParser.GetThruEOL(&line); // Read each line
StringParser lineParser(&line);
lineParser.ConsumeWhitespace();//skip over leading whitespace
if (lineParser.GetDataRemaining() == 0) // must be an empty line
continue;
char firstChar = lineParser.PeekFast();
if ( (firstChar == '#') || (firstChar == '\0') )
continue; //skip over comments and blank lines...
lineParser.ConsumeUntilWhitespace(&word);
if ( word.Equal("<Limit") ) // a limit line
{
currentFlags = qtssActionFlagsNoFlags; // clear to no access
lineParser.ConsumeWhitespace();
lineParser.ConsumeUntil( &word, sWhitespaceAndGreaterThanMask); // the flag <limit Read> or <limit Read >
while (word.Len != 0) // compare each word in the line
{
if (word.Equal("WRITE") )
{ currentFlags |= inFlags & qtssActionFlagsWrite; // accept following lines if inFlags has write
}
if (word.Equal("READ") )
{ currentFlags |= inFlags & qtssActionFlagsRead; // accept following lines if inFlags has read
}
lineParser.ConsumeWhitespace();
lineParser.ConsumeUntil(&word, sWhitespaceAndGreaterThanMask);
}
continue; //done with limit line
}
if ( word.Equal("</Limit>") )
currentFlags = qtssActionFlagsRead; // set the current access state to the default of read access
if (0 == (currentFlags & inFlags))
continue; // ignore lines because inFlags doesn't match the current access state
if (haveRealmResultBuffer && word.Equal("AuthName") ) //realm name
{
lineParser.ConsumeWhitespace();
lineParser.GetThruEOL(&word);
StringParser::UnQuote(&word);// if the parsed string is surrounded by quotes then remove them.
GetRealm(&word, ioRealmNameStr, userName, extraDataPtr );
// we don't change the buffer len ioRealmNameStr->Len because we might have another AuthName tag to copy
continue; // done with AuthName (realm)
}
if (word.Equal("require") )
{
lineParser.ConsumeWhitespace();
lineParser.ConsumeUntilWhitespace(&word);
if (haveUserName && word.Equal("valid-user") )
{ return true;
}
if ( word.Equal("any-user") )
{
*outAllowAnyUserPtr = true;
return true;
}
if (!haveUserName)
continue;
if (word.Equal("user") )
{
lineParser.ConsumeWhitespace();
lineParser.ConsumeUntilWhitespace(&word);
//.........这里部分代码省略.........
示例13: FilterRequest
QTSS_Error FilterRequest(QTSS_Filter_Params* inParams)
{
#if HTTP_FILE_DEBUGGING
qtss_printf("FilterRequest\n");
#endif
static Bool16 sFalse = false;
QTSS_RTSPRequestObject theRequest = inParams->inRTSPRequest;
// Initial state.
StrPtrLen theFullRequest;
StrPtrLen reqMethod;
StrPtrLen reqStr;
StrPtrLen httpVersion;
(void)QTSS_GetValuePtr(theRequest, qtssRTSPReqFullRequest, 0, (void**)&theFullRequest.Ptr, &theFullRequest.Len);
StringParser fullRequest(&theFullRequest);
// Parsing the HTTP request
fullRequest.ConsumeWord(&reqMethod);
if ( !(reqMethod.Equal(StrPtrLen("GET")) || reqMethod.Equal(StrPtrLen("HEAD"))) )
// It's not a "Get" or a "Head" request
return QTSS_NoErr;
fullRequest.ConsumeWhitespace();
if ( !fullRequest.Expect('/') )
// Improperly formed request
return QTSS_NoErr;
fullRequest.ConsumeUntil(&reqStr, StringParser::sEOLWhitespaceMask);
if( reqStr.Len == 0 )
//if a file or directory name is not given, return
return QTSS_NoErr;
if ( !reqStr.Equal(StrPtrLen("Popular.smil")) )
return QTSS_NoErr;
// If it's a "Head" request send the Head response header back and just return
if ( reqMethod.Equal(StrPtrLen("HEAD")) )
{
QTSS_Write(theRequest, sResponseHeader, ::strlen(sResponseHeader), NULL, 0);
return QTSS_NoErr;
}
// Create a buffer to store data.
char theFileBuffer[8192];
char contentLength[256];
// Before sending any response, set keep alive to off for this connection
// Regardless of what the client sends, the server always closes the connection after sending the file
(void)QTSS_SetValue(theRequest, qtssRTSPReqRespKeepAlive, 0, &sFalse, sizeof(sFalse));
#if HTTP_FILE_DEBUGGING
qtss_printf("Creating a smil file\n");
#endif
// Create a ref movie buffer for the single file. It is of the form:
// rtsptext\r
// rtsp://servername/filepath
char smilFileBuf[8192] = {0};
GenerateHotHitSMIL(smilFileBuf);
qtss_sprintf(contentLength, "%lu", strlen(smilFileBuf));
// Allocate memory for theFileBuffer
// Write the HTTP header prefix into the buffer
::strcpy(theFileBuffer, sRespHeaderPrefix.Ptr);
::strcat(theFileBuffer, sContentLengthHeaderTag.Ptr);
// Write the remaining part of the HTTP header into the file buffer
::strcat(theFileBuffer, contentLength);
::strcat(theFileBuffer, sContentTypeHeaderTag.Ptr);
::strcat(theFileBuffer, sSmilMimeType.Ptr);
::strcat(theFileBuffer, "\r\n\r\n");
// Write the smil file created above to the file buffer
::strcat(theFileBuffer, smilFileBuf);
// Write the contents of the file buffer to the request stream and return
QTSS_Write(theRequest, theFileBuffer, strlen(theFileBuffer), NULL, 0);
#if HTTP_FILE_DEBUGGING
qtss_printf("Wrote the smil file to the request stream. Successful!\n");
#endif
return QTSS_NoErr;
}
示例14: FilterRequest
QTSS_Error FilterRequest(QTSS_Filter_Params* inParams)
{
UInt8 sParamStopMask[] =
{
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //0-9 //stop unless a '\t', ' ', or '&'
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //10-19
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //20-29
0, 0, 0, 0, 0, 0, 0, 0, 1, 0, //30-39
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //40-49
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //50-59
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //60-69
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //70-79
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //80-89
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //90-99
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //100-109
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //110-119
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //120-129
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //130-139
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //140-149
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //150-159
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //160-169
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //170-179
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //180-189
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //190-199
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //200-209
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //210-219
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //220-229
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //230-239
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //240-249
0, 0, 0, 0, 0, 1 //250-255
};
//check to see if we should handle this request. Invokation is triggered
//by a "GET /" request
QTSS_RTSPRequestObject theRequest = inParams->inRTSPRequest;
StrPtrLen theFullRequest;
(void)QTSS_GetValuePtr(theRequest, qtssRTSPReqFullRequest, 0, (void**)&theFullRequest.Ptr, &theFullRequest.Len);
StringParser fullRequest(&theFullRequest);
StrPtrLen strPtr;
StrPtrLen paramName;
StrPtrLen fieldsList;
fullRequest.ConsumeWord(&strPtr);
if ( strPtr.Equal(StrPtrLen("GET")) ) //it's a "Get" request
{
fullRequest.ConsumeWhitespace();
if ( fullRequest.Expect('/') )
{
UInt32 refreshInterval = 0;
Bool16 displayHelp = false;
OSCharArrayDeleter theWebStatsURL(GetPrefAsString(sPrefs, sDefaultURLPrefName));
StrPtrLen theWebStatsURLPtr(theWebStatsURL.GetObject());
// If there isn't any web stats URL, we can just return at this point
if (theWebStatsURLPtr.Len == 0)
return QTSS_NoErr;
fullRequest.ConsumeUntil(&strPtr, StringParser::sEOLWhitespaceQueryMask);
if ( strPtr.Len != 0 && strPtr.Equal(theWebStatsURLPtr) ) //it's a "stats" request
{
if ( fullRequest.Expect('?') )
{
do {
fullRequest.ConsumeWord(¶mName);
if( paramName.Len != 0)
{
if ( paramName.Equal(StrPtrLen("refresh",strlen("refresh"))) )
{
if (fullRequest.Expect('='))
refreshInterval = fullRequest.ConsumeInteger(NULL);
}
else if ( paramName.Equal(StrPtrLen("help",strlen("help"))) )
{
displayHelp = true;
}
else if ( paramName.Equal(StrPtrLen("fields",strlen("fields"))) )
{
if (fullRequest.Expect('='))
fullRequest.ConsumeUntil(&fieldsList, (UInt8*)sParamStopMask);
}
}
} while ( paramName.Len != 0 && fullRequest.Expect('&') );
}
// Before sending a response, set keep alive to off for this connection
(void)QTSS_SetValue(theRequest, qtssRTSPReqRespKeepAlive, 0, &sFalse, sizeof(sFalse));
SendStats(inParams->inRTSPRequest, refreshInterval, displayHelp, (fieldsList.Len != 0) ? &fieldsList : NULL);
}
}
}
//.........这里部分代码省略.........
示例15: GetLocalSDP
char* SDPSourceInfo::GetLocalSDP(UInt32* newSDPLen)
{
Assert(fSDPData.Ptr != NULL);
bool appendCLine = true;
UInt32 trackIndex = 0;
char *localSDP = new char[fSDPData.Len * 2];
OSCharArrayDeleter charArrayPathDeleter(localSDP);
StringFormatter localSDPFormatter(localSDP, fSDPData.Len * 2);
StrPtrLen sdpLine;
StringParser sdpParser(&fSDPData);
char trackIndexBuffer[50];
// Only generate our own trackIDs if this file doesn't have 'em.
// Our assumption here is that either the file has them, or it doesn't.
// A file with some trackIDs, and some not, won't work.
bool hasControlLine = false;
while (sdpParser.GetDataRemaining() > 0)
{
//stop when we reach an empty line.
sdpParser.GetThruEOL(&sdpLine);
if (sdpLine.Len == 0)
continue;
switch (*sdpLine.Ptr)
{
case 'c':
break;//ignore connection information
case 'm':
{
//append new connection information right before the first 'm'
if (appendCLine)
{
localSDPFormatter.Put(sCLine);
localSDPFormatter.PutEOL();
if (!hasControlLine)
{
localSDPFormatter.Put(sControlLine);
localSDPFormatter.PutEOL();
}
appendCLine = false;
}
//the last "a=" for each m should be the control a=
if ((trackIndex > 0) && (!hasControlLine))
{
qtss_sprintf(trackIndexBuffer, "a=control:trackID=%" _S32BITARG_ "\r\n",trackIndex);
localSDPFormatter.Put(trackIndexBuffer, ::strlen(trackIndexBuffer));
}
//now write the 'm' line, but strip off the port information
StringParser mParser(&sdpLine);
StrPtrLen mPrefix;
mParser.ConsumeUntil(&mPrefix, StringParser::sDigitMask);
localSDPFormatter.Put(mPrefix);
localSDPFormatter.Put("0", 1);
(void)mParser.ConsumeInteger(NULL);
localSDPFormatter.Put(mParser.GetCurrentPosition(), mParser.GetDataRemaining());
localSDPFormatter.PutEOL();
trackIndex++;
break;
}
case 'a':
{
StringParser aParser(&sdpLine);
aParser.ConsumeLength(NULL, 2);//go past 'a='
StrPtrLen aLineType;
aParser.ConsumeWord(&aLineType);
if (aLineType.Equal(sControlStr))
{
aParser.ConsumeUntil(NULL, '=');
aParser.ConsumeUntil(NULL, StringParser::sDigitMask);
StrPtrLen aDigitType;
(void)aParser.ConsumeInteger(&aDigitType);
if (aDigitType.Len > 0)
{
localSDPFormatter.Put("a=control:trackID=", 18);
localSDPFormatter.Put(aDigitType);
localSDPFormatter.PutEOL();
hasControlLine = true;
break;
}
}
localSDPFormatter.Put(sdpLine);
localSDPFormatter.PutEOL();
break;
}
default:
{
localSDPFormatter.Put(sdpLine);
localSDPFormatter.PutEOL();
}
}
}
//.........这里部分代码省略.........