コード例 #1
0
ファイル: ChrootHelper.c プロジェクト: ColumPaget/Alaya
HTTPSession *ParseSessionInfo(char *Data)
{
HTTPSession *Response=NULL;
char *Name=NULL, *Value=NULL, *Tempstr=NULL, *ptr;

	Response=HTTPSessionCreate();
	Response->ContentType=CopyStr(Response->ContentType,"");
	Response->ContentSize=0;
	Response->LastModified=0;
	Response->CacheTime=Settings.DocumentCacheTime;
	Response->RealUser=CopyStr(Response->RealUser, Settings.DefaultUser);
	Response->Group=CopyStr(Response->Group, Settings.DefaultGroup);
	//if we got as far as calling this function, then the original session must be
	//authenticated.
	Response->Flags |= SESSION_AUTHENTICATED;
	Response->Flags &= ~SESSION_UPLOAD;

	ptr=GetNameValuePair(Data," ","=",&Name,&Tempstr);
	while (ptr)
	{
		Value=DeQuoteStr(Value,Tempstr);


		if (strcmp(Name,"User")==0) Response->UserName=CopyStr(Response->UserName,Value);
		else if (strcmp(Name,"RealUser")==0) Response->RealUser=CopyStr(Response->RealUser,Value);
		else if (strcmp(Name,"Group")==0) Response->Group=CopyStr(Response->Group,Value);
		else if (strcmp(Name,"Host")==0) Response->Host=CopyStr(Response->Host,Value);
		else if (strcmp(Name,"UserAgent")==0) Response->UserAgent=CopyStr(Response->UserAgent,Value);
		else if (strcmp(Name,"Method")==0) Response->Method=CopyStr(Response->Method,Value);
		else if (strcmp(Name,"ContentType")==0) HTTPServerParsePostContentType(Response, Value);
		else if (strcmp(Name,"SearchPath")==0) Response->SearchPath=DeQuoteStr(Response->SearchPath,Value);
		else if (strcmp(Name,"Path")==0) Response->Path=DeQuoteStr(Response->Path,Value);
		else if (strcmp(Name,"URL")==0) Response->URL=DeQuoteStr(Response->URL,Value);
		else if (strcmp(Name,"Arguments")==0) Response->Arguments=SanitizeQueryString(Response->Arguments,Value);
		else if (strcmp(Name,"ServerName")==0) Response->ServerName=CopyStr(Response->ServerName,Value);
		else if (strcmp(Name,"ServerPort")==0) Response->ServerPort=atoi(Value);
		else if (strcmp(Name,"ClientIP")==0) Response->ClientIP=CopyStr(Response->ClientIP,Value);
		else if (strcmp(Name,"ClientMAC")==0) Response->ClientMAC=CopyStr(Response->ClientMAC,Value);
		else if (strcmp(Name,"ContentLength")==0) Response->ContentSize=atoi(Value);
		else if (strcmp(Name,"StartDir")==0) Response->StartDir=DeQuoteStr(Response->StartDir,Value);
		else if (strcmp(Name,"ClientReferrer")==0) Response->ClientReferrer=DeQuoteStr(Response->ClientReferrer,Value);
		else if (strcmp(Name,"RemoteAuthenticate")==0) Response->RemoteAuthenticate=CopyStr(Response->RemoteAuthenticate,Value);
		else if (strcmp(Name,"Cipher")==0) Response->Cipher=CopyStr(Response->Cipher,Value);
		else if (strcmp(Name,"Cookies")==0) Response->Cookies=CopyStr(Response->Cookies,Value);
		else if (strcmp(Name,"KeepAlive")==0) Response->Flags |= SESSION_KEEPALIVE;
		else if (strcmp(Name,"Upload")==0) Response->Flags |= SESSION_UPLOAD;
		else if (strcmp(Name,"AuthCookie")==0) Response->AuthFlags |= FLAG_AUTH_HASCOOKIE;
		else if (strcmp(Name,"Cache")==0) Response->CacheTime=atoi(Value);

		ptr=GetNameValuePair(ptr," ","=",&Name,&Tempstr);
	}



DestroyString(Name);
DestroyString(Value);
DestroyString(Tempstr);

return(Response);
}
コード例 #2
0
ファイル: idrive.c プロジェクト: ColumPaget/FileFerry
TFileInfo *IDriveReadFileEntry(char *Data)
{
char *Name=NULL, *Value=NULL, *ptr;
TFileInfo *FI=NULL;

FI=(TFileInfo *) calloc(1,sizeof(TFileInfo));
ptr=GetNameValuePair(Data," ","=",&Name,&Value);
while (ptr)
{
	if (strcmp(Name,"restype")==0) 
	{
		if (atoi(Value)==0) FI->Type=FTYPE_DIR;
	}
	if (strcmp(Name,"resname")==0) 
	{
		FI->Name=CopyStr(FI->Name,Value);
		FI->Path=CopyStr(FI->Path,Value);
	}

	if (strcmp(Name,"size")==0) FI->Size=atoi(Value);
	if (strcmp(Name,"ver")==0) FI->Version=atoi(Value);
	if (strcmp(Name,"lmd")==0) FI->Mtime=DateStrToSecs("%Y/%m/%d %H:%M:%S",Value,NULL);

ptr=GetNameValuePair(ptr," ","=",&Name,&Value);
}

DestroyString(Value);
DestroyString(Name);

return(FI);
}
コード例 #3
0
void M3UStreamVarName(const char *Config, char **VarName)
{
char *Name=NULL, *Value=NULL;
char *Resolution=NULL, *Codec=NULL, *Bandwidth=NULL;
const char *ptr;

ptr=GetNameValuePair(Config, ",", "=", &Name, &Value);
while (ptr)
{
	StripTrailingWhitespace(Name);
	StripTrailingWhitespace(Value);
	if (strcasecmp(Name,"resolution")==0) Resolution=CopyStr(Resolution, Value);
	if (strcasecmp(Name,"codec")==0) Codec=CopyStr(Codec, Value);
	if (strcasecmp(Name,"bandwidth")==0) Bandwidth=CopyStr(Bandwidth, Value);
	while (isspace(*ptr)) ptr++;
	ptr=GetNameValuePair(ptr, ",", "=", &Name, &Value);
}

if (StrValid(Resolution)) *VarName=MCopyStr(*VarName, "item:m3u8-stream:", Resolution, NULL);
else *VarName=MCopyStr(*VarName, "item:m3u8-stream:", Bandwidth, NULL);

DestroyString(Name);
DestroyString(Value);
DestroyString(Codec);
DestroyString(Resolution);
DestroyString(Bandwidth);
}
コード例 #4
0
ファイル: directory_listing.c プロジェクト: ColumPaget/Alaya
int RequestedListingType(HTTPSession *Session, int *Flags)
{
char *Name=NULL, *Value=NULL, *ptr;
int Action=ACTION_HTML;

if (! (Settings.DirListFlags & DIR_SHOWFILES)) return(DIR_REJECT);

	ptr=GetNameValuePair(Session->Arguments,"&","=",&Name,&Value);
	while (ptr)
	{
		if ( StrLen(Name) && StrLen(Value))
		{
			if (strcmp(Name,"format")==0) Action=MatchTokenFromList(Value,DirActionTypes,0);
			else if (strcmp(Name,"sort")==0)
			{
				if (strcmp(Value,"size")==0) *Flags=SORT_SIZE;
				else if (strcmp(Value,"rsize")==0) *Flags=SORT_RSIZE;
				else if (strcmp(Value,"time")==0) *Flags=SORT_TIME;
				else if (strcmp(Value,"rtime")==0) *Flags=SORT_RTIME;
				else if (strcmp(Value,"name")==0) *Flags=SORT_NAME;
				else if (strcmp(Value,"rname")==0) *Flags=SORT_RNAME;
				//if (strcmp(Value,"rss")==0) *SortFlags=DIR_RSS;
			}
			else if (strcmp(Name,"all-selected")==0) *Flags|=SELECT_ALL;
		}
	ptr=GetNameValuePair(ptr,"&","=",&Name,&Value);
	}

DestroyString(Name);
DestroyString(Value);

return(Action);
}
コード例 #5
0
ファイル: ChrootHelper.c プロジェクト: ColumPaget/Alaya
char *SanitizeQueryString(char *Buffer, char *Data)
{
char *Name=NULL, *Value=NULL, *Token=NULL, *ptr;
char *RetStr=NULL;

RetStr=CopyStr(Buffer,"");
ptr=GetNameValuePair(Data,"&","=",&Name,&Value);
while (ptr)
{
	Token=HTTPUnQuote(Token, Value);
	StripTrailingWhitespace(Token);
	Value=SanitizeStr(Value,Token);

	if (RetStr && (*RetStr != '\0')) RetStr=MCatStr(RetStr,"&",Name,"=",Value,NULL);
	else RetStr=MCatStr(RetStr,Name,"=",Value,NULL);
	ptr=GetNameValuePair(ptr,"&","=",&Name,&Value);
}



DestroyString(Name);
DestroyString(Value);
DestroyString(Token);

return(RetStr);
}
コード例 #6
0
ファイル: oauth.c プロジェクト: ColumPaget/Movgrab
char *OAuthGetAccessToken(char *RetStr, const char *URL, const char *Key, const char *RequestToken)
{
STREAM *S;
char *Tempstr=NULL, *Name=NULL, *Value=NULL, *ptr;
int len;

Tempstr=MCopyStr(Tempstr,"consumer_key=",Key,"&code=",RequestToken,NULL);
S=HTTPMethod("POST",URL,"","","application/x-www-form-urlencoded; charset=UTF-8",Tempstr,StrLen(Tempstr));
if (S)
{
STREAMReadToString(S, &Tempstr, &len, NULL);
ptr=GetNameValuePair(Tempstr,"&","=",&Name,&Value);
while (ptr)
{
if (strcmp(Name,"access_token")==0) RetStr=CopyStr(RetStr,Value);
ptr=GetNameValuePair(ptr,"&","=",&Name,&Value);
}
STREAMClose(S);
}

DestroyString(Name);
DestroyString(Value);
DestroyString(Tempstr);
return(RetStr);
}
コード例 #7
0
ファイル: server.c プロジェクト: ColumPaget/Alaya
void HTTPServerHandleAuthHeader(HTTPSession *Heads,int HeaderType, char *Type, char *Data)
{
char *Tempstr=NULL, *Name=NULL, *Value=NULL, *ptr;
char *nonce=NULL, *cnonce=NULL, *request_count=NULL, *qop=NULL, *algo=NULL, *uri=NULL;
int len;

if (strcmp(Type,"Basic")==0)
{
	Tempstr=DecodeBase64(Tempstr, &len, Data);
	ptr=GetToken(Tempstr,":",&Heads->UserName,0);
	Heads->Password=CopyStr(Heads->Password,ptr);
}
else if (strcmp(Type,"Digest")==0)
{
	uri=CopyStr(uri,"");
	algo=CopyStr(algo,"");
	ptr=GetNameValuePair(Data,",","=",&Name,&Value);
	while (ptr)
	{
		if (StrLen(Name) && StrLen(Value))
		{
		StripLeadingWhitespace(Name);
		StripLeadingWhitespace(Value);
		if (strcmp(Name,"username")==0) Heads->UserName=CopyStr(Heads->UserName,Value);
		if (strcmp(Name,"response")==0) Heads->Password=CopyStr(Heads->Password,Value);
		if (strcmp(Name,"nonce")==0) nonce=CopyStr(nonce,Value);
		if (strcmp(Name,"cnonce")==0) cnonce=CopyStr(cnonce,Value);
		if (strcmp(Name,"nc")==0) request_count=CopyStr(request_count,Value);
		if (strcmp(Name,"qop")==0) qop=CopyStr(qop,Value);
		if (strcmp(Name,"uri")==0) uri=CopyStr(uri,Value);
		if (strcmp(Name,"algorithm")==0) algo=CopyStr(algo,Value);
		}
		
	ptr=GetNameValuePair(ptr,",","=",&Name,&Value);
	}

// server nonce (nonce), request counter (nc), client nonce (cnonce), quality of protection code (qop) and HA2 result is calculated. The result is the "response" value provided by the client.

if (StrLen(qop)) Heads->AuthDetails=MCopyStr(Heads->AuthDetails,uri,":",algo,":",nonce,":",request_count,":",cnonce,":",qop, NULL);
else Heads->AuthDetails=CopyStr(Heads->AuthDetails,nonce);

}

DestroyString(qop);
DestroyString(uri);
DestroyString(algo);
DestroyString(Name);
DestroyString(Value);
DestroyString(nonce);
DestroyString(cnonce);
DestroyString(Tempstr);
DestroyString(request_count);
}
コード例 #8
0
/**
	Checks that a path is in a valid form
	
	@return	ETrue if the path is valid otherwise EFalse
 */
TBool TValidatorTel::IsValidPath() const
	{
	const TDesC8& path = iUri.Extract(EUriPath);
	//empty path is invalid
	if(!path.Length())
		{
		return EFalse;	
		}
	
	//Implementation of all the steps specified in section 2.5.2.2 
	//Validation of the path components of tel uri
	
	TDelimitedPathSegmentParser8 parser;
	parser.Parse(path);
	
	// tel parameters should start with a '+' or 'digit'
	TChar ch( path[0] );
	if(! (ch == '+' || ch.IsDigit()) )
		{
		return EFalse;	
		}
			
	TPtrC8 name;
	TPtrC8 value;
	TPtrC8 segment;
	//First segemnt must be telephone number
	if (parser.GetNext(segment) == KErrNone)
		{
		GetNameValuePair(segment, name, value);	
		//contains only digits
		if(!IsValidCharacters(name.Mid(1), KCharSetNumber))
			{
			return EFalse;	
			}
		}
	//Remainig all the segments
	while( parser.GetNext(segment) == KErrNone )
		{
		GetNameValuePair(segment, name, value);
		if(IsEmpty(segment))
			{
			return ETrue;	
			}
		if ( IsEmpty(value) || IsDuplicated(name, parser) || !IsValidParamSegment(name, value) )
			{
			return EFalse;	
			}
		}
	return ETrue;
	}
コード例 #9
0
ファイル: cgi.c プロジェクト: ColumPaget/Hashrat
static int CGIParseArgs(const char *Str, const char *Sep1, const char *Sep2, char **HashType, char **Encoding, char **LineEnding, char **Text, int *OutputLength, int *SegmentLength, char **SegmentChar, char **OptionsFile)
{
char *QName=NULL, *QValue=NULL, *Name=NULL, *Value=NULL;
const char *ptr;
int Flags=0;

ptr=GetNameValuePair(Str, Sep1, Sep2, &QName, &QValue);
while (ptr)
{
	Name=HTTPUnQuote(Name,QName);
	Value=HTTPUnQuote(Value,QValue);

	if (strcasecmp(Name,"OptionsFile")==0) 
	{
		Flags |= CGILoadOptionsFile(Value, HashType, Encoding, LineEnding, Text, OutputLength, SegmentLength, SegmentChar);
		*OptionsFile=CopyStr(*OptionsFile, Value);
	}

	if (strcasecmp(Name,"HashType")==0) *HashType=CopyStr(*HashType, Value);
	if (strcasecmp(Name,"PlainText")==0) 
	{
		*Text=CopyStr(*Text, Value);
		Flags |= CGI_DOHASH;
	}
	if (strcasecmp(Name,"Encoding")==0) *Encoding=CopyStr(*Encoding, Value);
	if (strcasecmp(Name,"LineEnding")==0) *LineEnding=CopyStr(*LineEnding, Value);
	if (strcasecmp(Name,"SegmentChar")==0) *SegmentChar=CopyStr(*SegmentChar, Value);

	if (strcasecmp(Name,"HideText")==0) Flags |= CGI_HIDETEXT;
	if (strcasecmp(Name,"ShowText")==0) Flags |= CGI_SHOWTEXT;

	if (strcasecmp(Name,"OutputLength")==0) *OutputLength=atoi(Value);
	if (strcasecmp(Name,"SegmentLength")==0) *SegmentLength=atoi(Value);

	if (strcasecmp(Name,"NoOptions")==0) Flags |= CGI_NOOPTIONS;

ptr=GetNameValuePair(ptr, Sep1, Sep2, &QName, &QValue);
}

if (Flags & CGI_SHOWTEXT) Flags &= ~CGI_HIDETEXT;

Destroy(QName);
Destroy(QValue);
Destroy(Name);
Destroy(Value);

return(Flags);
}
コード例 #10
0
/**
	Checks whether any duplicate parameter names exist in the 
	whole path of the sip-uri.
							
	@param		aParamName	The descriptor to be checked.
	@param		aParamList	the path/parameter part of uri, which conatians all parameters and values.
	@return		A boolean value of ETrue if uri contains duplicate parameters,
				EFalse if it does not.
*/
TBool TValidatorSip::IsDuplicated(const TDesC8& aParamName, const TDelimitedParserBase8 aParamList) const
	{
	// roll back to the start of the lhs segment parser
	while(aParamList.Dec() != KErrNotFound) 
	{
	//Nothing to do
	}
	
	TPtrC8 name;
	TPtrC8 value;
	TPtrC8 segment;
	TInt count = 0;
	while( aParamList.GetNext(segment) == KErrNone )
		{
		GetNameValuePair(segment, name, value);
		if (aParamName.CompareF(name) == 0)
			{
			count++;
			}
		if (count > 1)
			{
			// The parameter name appears more than once in the paramter list
			return ETrue;
			}
		}
	return EFalse;	
	}
コード例 #11
0
/**
	Checks that a Path/uri-parameter is in a valid form as specified in RFC 3261.
	
	@return		A boolean value of ETrue if uri contains valid Path/uri-parameter,
				EFalse if it does not.
*/
TBool TValidatorSip::IsValidPath() const
	{
	const TDesC8& parameters = iUri.Extract(EUriPath);
	TDelimitedPathSegmentParser8 parser;
	parser.Parse(parameters);
	
	// sip parameters should start with a ';'
	if (parameters.Length() && parameters[0] != ';')
		{
		return EFalse;
		}
		
	TPtrC8 name;
	TPtrC8 value;
	TPtrC8 segment;
	while( parser.GetNext(segment) == KErrNone )
		{
		GetNameValuePair(segment, name, value);
		if (IsEmpty(value) || IsDuplicated(name, parser) || !IsValidParamSegment(name, value))
			{
			return EFalse;
		}
		}

	return ETrue;
	}
コード例 #12
0
/**
	Checks that a Query/Header is in a valid form as specified in RFC 3261.

	@return		A boolean value of ETrue if uri contains valid Query/Header,
				EFalse if it does not.
*/
TBool TValidatorSip::IsValidQuery() const
	{
	const TDesC8& headers = iUri.Extract(EUriQuery);
	if (IsEmpty(headers))
		{
		return EFalse;
		}

	TDelimitedQueryParser8 parser;
	parser.Parse(headers);

	TPtrC8 name;
	TPtrC8 value;
	TPtrC8 segment;
	while( parser.GetNext(segment) == KErrNone )
		{
		// must be in the form name=value even if the value part is empty
		if (segment.Locate(KEqualsSeparator) == KErrNotFound)
			{
			return EFalse;
			}
		
		GetNameValuePair(segment, name, value);
		if (IsDuplicated(name, parser) || !IsValidHeaderSegment(name, value))
			{
			return EFalse;
		}
		}
	return ETrue;
	}
コード例 #13
0
/**
	Checks whether any duplicate parameter names exist in the 
	whole path of the tel-uri, and also checks whether the both ISDN and EXTN 
	parameters exist in tel-uri.
							
	@param		aParamName	The descriptor to be checked.
	@param		aParamList	the path part of uri, which conatians all parameters and values.
	@return		A boolean value of ETrue if uri contains duplicate parameters or 
				both isdn and extn parameters exist, EFalse if it does not.
 */
TBool TValidatorTel::IsDuplicated(const TDesC8& aParamName, const TDelimitedParserBase8 aParamList) const
	{
	// roll back to the start of the lhs segment parser
	while(aParamList.Dec() != KErrNotFound) 
		{
		//do nothing
		}
	aParamList.Inc(); //To exclude phone number from the list.
	
	TPtrC8 name;
	TPtrC8 value;
	TPtrC8 segment;
	TInt count = 0;
	while( aParamList.GetNext(segment) == KErrNone )
		{
		GetNameValuePair(segment, name, value);
		if (aParamName.CompareF(name) == 0)
			{
			count++;	
			}
		if (count > 1)
			{
			// The parameter name appears more than once in the paramter list
			return ETrue;
			}
		if( ( KIsdnSubAddress().CompareF(aParamName) == 0 && KExtension().CompareF(name) == 0 ) || 
			( KExtension().CompareF(aParamName) == 0 && KIsdnSubAddress().CompareF(name) == 0 ) )
			{
			//Both ISDN and EXTN should not exist in Uri
			return ETrue;	
			}
		}

	return EFalse;	
	}
コード例 #14
0
ファイル: DemoCGI.c プロジェクト: aranni/GWYNE64
/*********************************************************************
*
* FUNCTION:			BuildMenuIndexes
*
* ARGUMENTS:		fat_index   Index of the file system table entry
*                   wLen        Lenght of the request string from the web page
*                   bSession    Http session
*
* RETURNS:			None
*
* DESCRIPTION:		Decodes the CGI tag/value pairs and updates the variables
*              
* RESTRICTIONS:		
*
*********************************************************************/
void DemoCGI(BYTE fat_index, WORD wLen, BYTE bSession)
{
    USR_DYNAMIC_INITIALIZE* pDynamicTable;
    UINT16 ValuePairEnd;
    char szName[32];
    char szValue[32];

    fat_index++;		//not used - stops compiler warning
    do
    {
        ValuePairEnd = GetNameValuePair(wLen, szName, szValue);
        pDynamicTable = FindTableName(szName, (USR_DYNAMIC_INITIALIZE *)(StringFields));
        if(pDynamicTable != NULL)
        {
            SaveValue(szValue, pDynamicTable);
        }
    }while(ValuePairEnd);
    

	  https[bSession].fstart    = (UINT32)https_ack_page; //(unsigned char*)https_ack_page;
	  https[bSession].fstart   |= (UINT32)0xF0000000;
  	https[bSession].funacked  = 0;
	  https[bSession].flen      = strlen((char *)https_ack_page);
	  https[bSession].fpoint    = 0;

//    PutEventMsg (EVT_VAR_CMDSTART, PROC_DNP, OS_NOT_PROC, 0x00);
	
}
コード例 #15
0
ファイル: idrive.c プロジェクト: ColumPaget/FileFerry
void IDriveParseResponseItem(char *Data, ListNode *Vars)
{
char *Name=NULL, *Value=NULL, *ptr;

ptr=Data+StrLen(Data)-1;
if (*ptr=='/') *ptr='\0';

ptr=GetNameValuePair(Data," ","=",&Name,&Value);
while (ptr)
{
	SetVar(Vars,Name,Value);
	ptr=GetNameValuePair(ptr," ","=",&Name,&Value);
}

DestroyString(Name);
DestroyString(Value);
}
コード例 #16
0
int PipeCommandProcessorInit(TProcessingModule *ProcMod, const char *Args)
{
int result=FALSE;
char *Tempstr=NULL;
char *Name=NULL, *Value=NULL, *ptr;
STREAM *S;

ptr=GetNameValuePair(Args,"\\S","=",&Name,&Value);
while (ptr)
{
  if (strcasecmp(Name,"Command")==0) Tempstr=CopyStr(Tempstr,Value);

ptr=GetNameValuePair(ptr,"\\S","=",&Name,&Value);
}

if (! StrLen(Tempstr) )
{
	DestroyString(Name);
	DestroyString(Value);
	DestroyString(Tempstr);
	return(FALSE);
}

GetToken(Tempstr,"\\S",&Name,0);
Value=FindFileInPath(Value,Name,getenv("PATH"));

if (! StrLen(Value) )
{
	DestroyString(Name);
	DestroyString(Value);
	DestroyString(Tempstr);
	return(FALSE);
}


S=STREAMSpawnCommand(Value, COMMS_BY_PIPE);
ProcMod->Data=(void *) S;
result=TRUE;

DestroyString(Name);
DestroyString(Value);
DestroyString(Tempstr);

return(result);
}
コード例 #17
0
ファイル: upload.c プロジェクト: ColumPaget/Alaya
int UploadReadMultipartHeaders(STREAM *S, char **Field, char **FileName)
{
char *Tempstr=NULL, *Name=NULL, *Value=NULL, *ptr;
int result=FALSE;

Tempstr=STREAMReadLine(Tempstr,S);
while (StrLen(Tempstr))
{
StripTrailingWhitespace(Tempstr);
ptr=GetToken(Tempstr,":",&Name,0);

if (strcasecmp(Name,"Content-Disposition")==0)
{
	ptr=GetNameValuePair(ptr,";","=",&Name,&Value);
	while (ptr)
	{
		StripLeadingWhitespace(Name);
		StripTrailingWhitespace(Name);
		StripLeadingWhitespace(Value);
		StripTrailingWhitespace(Value);
	if (strcasecmp(Name,"name")==0) 
	{
		*Field=CopyStr(*Field,Value);
		result=TRUE;
	}

	if (strcasecmp(Name,"filename")==0) 
	{
		*FileName=CopyStr(*FileName,Value);
		result=TRUE;
	}
	ptr=GetNameValuePair(ptr,";","=",&Name,&Value);
	}
}
Tempstr=STREAMReadLine(Tempstr,S);
StripTrailingWhitespace(Tempstr);
}

DestroyString(Tempstr);
DestroyString(Name);
DestroyString(Value);

return(result);
}
コード例 #18
0
ファイル: OAuth.c プロジェクト: ColumPaget/Crayonizer
void OAuthParse(OAUTH *Ctx, const char *Line)
{
    char *Name=NULL, *Value=NULL;
    const char *ptr;

    ptr=GetToken(Line,"\\S",&Ctx->Name,GETTOKEN_QUOTES);
    ptr=GetNameValuePair(ptr," ", "=", &Name, &Value);
    while (ptr)
    {
        SetVar(Ctx->Vars, Name, Value);
        ptr=GetNameValuePair(ptr," ", "=", &Name, &Value);
    }

    Ctx->AccessToken=CopyStr(Ctx->AccessToken, GetVar(Ctx->Vars,"access_token"));
    Ctx->RefreshToken=CopyStr(Ctx->RefreshToken, GetVar(Ctx->Vars,"refresh_token"));

    DestroyString(Name);
    DestroyString(Value);
}
コード例 #19
0
ファイル: oauth.c プロジェクト: ColumPaget/daytime
void ParseTagData(char *TagName,char *TagData,char **RType,char **RName,char **RValue)
{
char *Name=NULL, *Value=NULL, *ptr;

ptr=GetNameValuePair(TagData," ","=",&Name,&Value);
while (ptr)
{
if (strcasecmp(Name,"type")==0) *RType=HtmlUnQuote(*RType,Value);
if (strcasecmp(Name,"name")==0) *RName=HtmlUnQuote(*RName,Value);
if (strcasecmp(Name,"value")==0) *RValue=HtmlUnQuote(*RValue,Value);
if (strcasecmp(Name,"method")==0) *RType=HtmlUnQuote(*RType,Value);
if (strcasecmp(Name,"action")==0) *RValue=HtmlUnQuote(*RValue,Value);

ptr=GetNameValuePair(ptr," ","=",&Name,&Value);
}

DestroyString(Name);
DestroyString(Value);
}
コード例 #20
0
ファイル: server.c プロジェクト: ColumPaget/Alaya
void HTTPServerParsePostContentType(HTTPSession *Session, char *Data)
{
char *ptr, *Name=NULL, *Value=NULL;

ptr=GetToken(Data,";",&Session->ContentType,0);
if (ptr)
{
while (isspace(*ptr)) ptr++;

ptr=GetNameValuePair(ptr,";","=",&Name,&Value);
while (ptr)
{
	if (strcmp(Name,"boundary")==0) Session->ContentBoundary=CopyStr(Session->ContentBoundary,Value);
	ptr=GetNameValuePair(ptr,";","=",&Name,&Value);
}
}

DestroyString(Name);
DestroyString(Value);
}
コード例 #21
0
ファイル: youtube.c プロジェクト: JackieXie168/movgrab
void YouTubeFormatGetData(char *Data, char **URL, char **Code)
{
char *Name=NULL, *Value=NULL, *ptr;

ptr=GetNameValuePair(Data,"&","=",&Name,&Value);
while (ptr)
{
 if (StrLen(Name))
 {
	if (strcmp(Name,"sig")==0) *URL=MCatStr(*URL,"&signature=", Value, NULL);
	if (strcmp(Name,"url")==0) *URL=HTTPUnQuote(*URL,Value);
	if (strcmp(Name,"itag")==0) *Code=CopyStr(*Code,Value);
 }

ptr=GetNameValuePair(ptr,"&","=",&Name,&Value);
}

DestroyString(Name);
DestroyString(Value);
}
コード例 #22
0
ファイル: common.c プロジェクト: ColumPaget/Alaya
char *SessionGetArgument(char *RetBuff, HTTPSession *Session, const char *ReqName)
{
char *Name=NULL, *Value=NULL, *RetStr=NULL, *ptr;

ptr=GetNameValuePair(Session->Arguments, "&", "=", &Name, &Value);
while (ptr)
{
	if (strcasecmp(ReqName,Name)==0) 
	{
		RetStr=HTTPUnQuote(RetBuff,Value);
		break;
	}
ptr=GetNameValuePair(ptr, "&", "=", &Name, &Value);
}

DestroyString(Name);
DestroyString(Value);

return(RetStr);
}
コード例 #23
0
ファイル: containerfiles.c プロジェクト: JackieXie168/movgrab
void M3UParseStreamInfo(char *Line, char **Resolution, char **Bandwidth)
{
char *Name=NULL, *Value=NULL, *ptr;

ptr=GetToken(Line,":",&Name,0);
ptr=GetNameValuePair(ptr,",","=",&Name,&Value);
while (ptr)
{
	StripLeadingWhitespace(Name);
	StripTrailingWhitespace(Name);
	StripLeadingWhitespace(Value);
	StripTrailingWhitespace(Value);
	if (strcasecmp(Name,"RESOLUTION")==0) *Resolution=CopyStr(*Resolution,Value);
	if (strcasecmp(Name,"BANDWIDTH")==0) *Bandwidth=CopyStr(*Bandwidth,Value);
ptr=GetNameValuePair(ptr,",","=",&Name,&Value);
}

DestroyString(Name);
DestroyString(Value);
}
コード例 #24
0
int zlibProcessorInit(TProcessingModule *ProcMod, const char *Args)
{
int result=FALSE;

#ifdef HAVE_LIBZ
zlibData *ZData;
int CompressionLevel=5;
char *ptr, *Name=NULL, *Value=NULL;

ptr=GetNameValuePair(Args,"\\S","=",&Name,&Value);
while (ptr)
{
  if (strcasecmp(Name,"CompressionLevel")==0) CompressionLevel=atoi(Value);
  if (strcasecmp(Name,"Level")==0) CompressionLevel=atoi(Value);
ptr=GetNameValuePair(ptr,"\\S","=",&Name,&Value);
}


ProcMod->ReadMax=4096;
ProcMod->WriteMax=4096;


ZData=(zlibData *) calloc(1,sizeof(zlibData));
ZData->z_in.avail_in=0;
ZData->z_in.avail_out=0;
result=inflateInit(&ZData->z_in);

ZData->z_out.avail_in=0;
ZData->z_out.avail_out=0;
deflateInit(&ZData->z_out,CompressionLevel);


ProcMod->Data=(void *) ZData;
result=TRUE;

DestroyString(Name);
DestroyString(Value);

#endif
return(result);
}
コード例 #25
0
ファイル: directory_listing.c プロジェクト: ColumPaget/Alaya
char *DisplayPackAction(char *HTML, HTTPSession *Session)
{
char *Name=NULL, *Value=NULL, *ptr;

//if (Flags & DIR_TARBALLS) 
if (StrLen(Settings.PackFormats))
{
ptr=GetNameValuePair(Settings.PackFormats,",",":",&Name,&Value);

HTML=CatStr(HTML,"<td align=center colspan='2' bgcolor='skyblue'>Download as <select name=\"PackType\">");
while (ptr)
{
	HTML=MCatStr(HTML,"<option value=\"",Name,"\">",Name,NULL);
	ptr=GetNameValuePair(ptr,",",":",&Name,&Value);
}

HTML=MCatStr(HTML,"</select><input type=submit name='pack:",Session->URL,"' value='Pack'></td>",NULL);
}

return(HTML);
}
コード例 #26
0
ファイル: DataParser.c プロジェクト: ColumPaget/Crayonizer
static const char *ParserURLItems(int ParserType, const char *Doc, ListNode *Parent, int IndentLevel)
{
    char *Name=NULL, *Value=NULL;
    const char *ptr;

    ptr=strchr(Doc, '?');
    if (! ptr) ptr=strchr(Doc, '#');
    if (! ptr) ptr=Doc;

    ptr=GetNameValuePair(ptr, "&", "=", &Name, &Value);
    while (ptr)
    {
        SetTypedVar(Parent, Name, Value, ITEM_VALUE);
        ptr=GetNameValuePair(ptr, "&", "=", &Name, &Value);
    }

    DestroyString(Name);
    DestroyString(Value);

    return(NULL);
}
コード例 #27
0
ファイル: wAjaxCommon.c プロジェクト: aranni/GWYNE64
/*********************************************************************
*
* FUNCTION:			WebApiWrite
*
* ARGUMENTS:		fat_index   Index of the file system table entry
*               wLen        Lenght of the request string from the web page
*               bSession    Http session
*
* RETURNS:			None
*
* DESCRIPTION:	
*
*********************************************************************/
void WebApiWrite (BYTE fat_index, UINT16 wLen, BYTE bSession)
{
  	USR_DYNAMIC_FIELDS* StringFieldPtr;
    UINT16 ValuePairEnd;
    char szName [32];
    char szValue[32];
  	
  	fat_index++;        // evitar warning  
  	
    TagFlags= 0x00;
    do
    {
        ValuePairEnd = GetNameValuePair(wLen, szName, szValue);
        StringFieldPtr = FindTableName(szName, (USR_DYNAMIC_FIELDS *)(StringFields));
        if(StringFieldPtr != NULL)
        {
            if ( StringFieldPtr->fieldType & WRITE_ACCESS_MASK) 
            {
                if ( StringFieldPtr->fieldDataSource != NULL )
                {
                    SaveValue(szValue, StringFieldPtr);
                } 
                else if ( StringFieldPtr->SetVarFunction != NULL ) 
                {
                    StringFieldPtr->SetVarFunction(StringFieldPtr->FunctionParam, StringFieldPtr->FunctionLen, (void*)szValue);
                }
            }
            else
            {
                WebPrepareMsgAnswer ("Error: No tiene permisos de escritura", 0x01, bSession);
                return;
            }
        }
        wLen -= ValuePairEnd;
        
    }while(ValuePairEnd);
  
	  https[bSession].fstart    = (UINT32)https_ack_page_Accepted;
	  https[bSession].flen      = strlen((char *)https_ack_page_Accepted);
  	https[bSession].fstart   |= (UINT32)0xF0000000;
  	https[bSession].fpoint   = 0;
  	https[bSession].funacked = 0;
  	
#ifdef MOD_MODBUSRTU_AUTOQUERY_ENABLED  	
  	if (TagFlags & 0x01)
  	  MOD_ModbusRtuAutoQuerySaveBanks();
#endif
  	
   	return;  

}
コード例 #28
0
ファイル: VPath.c プロジェクト: ColumPaget/Alaya
char *HTTPServerSubstituteArgs(char *RetStr, const char *Template, HTTPSession *Session)
{
ListNode *Vars;
char *Name=NULL, *Value=NULL, *ptr;


Vars=ListCreate();
ptr=GetNameValuePair(Session->Arguments,"&","=",&Name,&Value);
while (ptr)
{
SetVar(Vars,Name,Value);
ptr=GetNameValuePair(ptr,"&","=",&Name,&Value);
}

RetStr=SubstituteVarsInString(RetStr, Template, Vars, 0);

ListDestroy(Vars, DestroyString);
DestroyString(Name);
DestroyString(Value);


return(RetStr);
}
コード例 #29
0
ファイル: directory_listing.c プロジェクト: ColumPaget/Alaya
void DirectoryDeleteSelected(STREAM *S, HTTPSession *Session, const char *Dir)
{
char *Name=NULL, *Value=NULL, *Path=NULL, *ptr;

	LogToFile(Settings.LogPath,"DeleteSelected: [%s]\n",Session->Arguments);
	ptr=GetNameValuePair(Session->Arguments, "&","=",&Name,&Value);
	while (ptr)
	{
		if ( StrLen(Name) )
		{
		if (strcasecmp(Name,"selected")==0) 
		{
			Path=MCopyStr(Path,Dir,"/",Value,NULL);
			DirectoryDeleteItem(S, Session, Path);
		}
		}
	ptr=GetNameValuePair(ptr, "&","=",&Name,&Value);
	}

DestroyString(Value);
DestroyString(Name);
DestroyString(Path);
}
コード例 #30
0
ファイル: ChrootHelper.c プロジェクト: ColumPaget/Alaya
int HTTPServerHandleRegister(HTTPSession *Session, int Flags)
{
char *Tempstr=NULL, *Name=NULL, *Value=NULL, *ptr;
char *FlagChar="";
int result=FALSE;


	if (Flags & LOGGED_IN) FlagChar="I";
	if (Flags & LOGIN_FAIL) FlagChar="F";
	Tempstr=MCopyStr(Tempstr,"REG ",Session->ClientIP,":",FlagChar,"\n",NULL);

	//Override above tempstr if Logout value found
	if (Flags & LOGIN_CHANGE) Tempstr=MCopyStr(Tempstr,"REG ",Session->Path,":C\n",NULL);
	if (Flags & LOGIN_CHECK_ALLOWED) 
	{
		FlagChar="A";
		ptr=GetNameValuePair(Session->Arguments,"&","=",&Name,&Value);
		while (ptr)
		{
			if (Name && (strcmp(Name,"Logout")==0)) Tempstr=MCopyStr(Tempstr,"REG ",Value,":",FlagChar,"\n",NULL);
			ptr=GetNameValuePair(ptr,"&","=",&Name,&Value);
		}
	}

	
	STREAMWriteLine(Tempstr,ParentProcessPipe);
	STREAMFlush(ParentProcessPipe);

	Tempstr=STREAMReadLine(Tempstr,ParentProcessPipe);
	if (strcmp(Tempstr,"okay\n")==0) result=TRUE;

DestroyString(Tempstr);
DestroyString(Name);
DestroyString(Value);

return(result);
}