本文整理汇总了C++中MCopyStr函数的典型用法代码示例。如果您正苦于以下问题:C++ MCopyStr函数的具体用法?C++ MCopyStr怎么用?C++ MCopyStr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了MCopyStr函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: IDriveRenameFile
int IDriveRenameFile(TFileStore *FS, char *FromArg, char *ToArg)
{
char *Tempstr=NULL, *Error=NULL, *FromPath=NULL, *ToPath=NULL;
HTTPInfoStruct *Info;
ListNode *Headers;
int result, val;
STREAM *S;
FromPath=MakeFullPath(FromPath,FS, FromArg);
ToPath=MakeFullPath(ToPath,FS, ToArg);
Tempstr=MCopyStr(Tempstr,"https://",FS->Host,"/evs/renameFileFolder?uid=",FS->Logon,"&pwd=",FS->Passwd,"&oldpath=",FromPath,"&newpath=",ToPath,NULL);
S=HTTPMethod("POST",Tempstr,"","","","",0);
val=HTTPReadDocument(S, &Tempstr);
if (Settings.Flags & FLAG_VERBOSE) printf("\n%s\n",Tempstr);
Error=CopyStr(Error,"");
result=IDriveParseStatusResponse(Tempstr, &Error);
DestroyString(Tempstr);
DestroyString(Error);
DestroyString(FromPath);
DestroyString(ToPath);
return(result);
}
开发者ID:ColumPaget,项目名称:FileFerry,代码行数:29,代码来源:idrive.c
示例2: CheckNativeFileChallengePassword
int CheckNativeFileChallengePassword(char *Challenge, char *Password, char *ProvidedPass)
{
char *Token=NULL, *Digest=NULL, *Tempstr=NULL, *ptr;
int RetVal=FALSE;
if (strcmp(Password,ProvidedPass)==0) return(TRUE);
if (! StrLen(Challenge)) return(FALSE);
ptr=GetToken(Settings.AuthMethods,",",&Token,0);
while (ptr)
{
if (strncmp(Token,"hp-",3)==0)
{
Tempstr=MCopyStr(Tempstr,Challenge,Password,NULL);
HashBytes(&Digest,Token+3,Tempstr,StrLen(Tempstr),ENCODE_HEX);
if (StrLen(Digest) && (strcasecmp(ProvidedPass, Digest)==0)) RetVal=TRUE;
}
ptr=GetToken(ptr,",",&Token,0);
}
DestroyString(Tempstr);
DestroyString(Digest);
DestroyString(Token);
return(RetVal);
}
开发者ID:ColumPaget,项目名称:MetaFTPD,代码行数:26,代码来源:Authenticate.c
示例3: ListNativeFile
void ListNativeFile(STREAM *Out, char *Path)
{
STREAM *S;
char *Tempstr=NULL, *Token=NULL, *SendStr=NULL, *ptr;
S=STREAMOpenFile(Settings.AuthFile,O_RDONLY);
if (S)
{
Tempstr=STREAMReadLine(Tempstr,S);
while (Tempstr)
{
StripTrailingWhitespace(Tempstr);
ptr=GetToken(Tempstr,":",&Token,0);
SendStr=MCopyStr(SendStr,Token," ",NULL);
ptr=GetToken(ptr,":",&Token,0); //passtype
ptr=GetToken(ptr,":",&Token,0); //password
ptr=GetToken(ptr,":",&Token,0); //realuser
SendStr=MCatStr(SendStr,"realuser=",Token," ",NULL);
ptr=GetToken(ptr,":",&Token,0); //homedir
SendStr=MCatStr(SendStr,"homedir=",Token," ",NULL);
SendStr=MCatStr(SendStr,ptr,"\n",NULL);
STREAMWriteLine(SendStr,Out);
Tempstr=STREAMReadLine(Tempstr,S);
}
STREAMClose(S);
}
STREAMFlush(Out);
DestroyString(Tempstr);
DestroyString(SendStr);
DestroyString(Token);
}
开发者ID:ColumPaget,项目名称:MetaFTPD,代码行数:35,代码来源:Authenticate.c
示例4: while
char *FindFileInPath(char *InBuff, const char *File, const char *Path)
{
char *Tempstr=NULL, *CurrPath=NULL, *RetStr=NULL, *ptr;
RetStr=CopyStr(InBuff,"");
if (*File=='/')
{
CurrPath=CopyStr(CurrPath,"");
ptr=""; //so we execute once below
}
else ptr=GetToken(Path,":",&CurrPath,0);
while (ptr)
{
CurrPath=SlashTerminateDirectoryPath(CurrPath);
Tempstr=MCopyStr(Tempstr,CurrPath,File,NULL);
if (access(Tempstr,F_OK)==0)
{
RetStr=CopyStr(RetStr,Tempstr);
break;
}
ptr=GetToken(ptr,":",&CurrPath,0);
}
DestroyString(Tempstr);
DestroyString(CurrPath);
return(RetStr);
}
开发者ID:ColumPaget,项目名称:Movgrab,代码行数:31,代码来源:FileSystem.c
示例5: FindFilesInPath
int FindFilesInPath(const char *File, const char *Path, ListNode *Files)
{
char *Tempstr=NULL, *CurrPath=NULL, *ptr;
int i;
glob_t Glob;
if (*File=='/')
{
CurrPath=CopyStr(CurrPath,"");
ptr=""; //so we execute once below
}
else ptr=GetToken(Path,":",&CurrPath,0);
while (ptr)
{
CurrPath=SlashTerminateDirectoryPath(CurrPath);
Tempstr=MCopyStr(Tempstr,CurrPath,File,NULL);
glob(Tempstr,0,0,&Glob);
for (i=0; i < Glob.gl_pathc; i++) ListAddItem(Files,CopyStr(NULL,Glob.gl_pathv[i]));
globfree(&Glob);
ptr=GetToken(ptr,":",&CurrPath,0);
}
DestroyString(Tempstr);
DestroyString(CurrPath);
return(ListSize(Files));
}
开发者ID:ColumPaget,项目名称:Movgrab,代码行数:29,代码来源:FileSystem.c
示例6: calloc
OAUTH *OAuthCreate(const char *Type, const char *Name, const char *ClientID, const char *ClientSecret, const char *Scopes, const char *RefreshURL)
{
OAUTH *Ctx;
char *Tempstr=NULL, *Token=NULL;
const char *ptr;
if (OAuthTypes==NULL) SetupOAuthTypes();
ptr=GetVar(OAuthTypes, Type);
if (! StrValid(ptr)) return(NULL);
Ctx=(OAUTH *) calloc(1,sizeof(OAUTH));
ptr=GetToken(ptr,",",&(Ctx->Stage1), 0);
ptr=GetToken(ptr,",",&(Ctx->Stage2), 0);
ptr=GetToken(ptr,",",&(Ctx->VerifyTemplate), 0);
Ctx->Name=CopyStr(Ctx->Name, Name);
Ctx->Vars=ListCreate();
SetVar(Ctx->Vars,"client_name",ClientID);
SetVar(Ctx->Vars,"client_id",ClientID);
SetVar(Ctx->Vars,"client_secret",ClientSecret);
Tempstr=HTTPQuote(Tempstr, Scopes);
SetVar(Ctx->Vars,"scope",Tempstr);
SetVar(Ctx->Vars,"redirect_uri","urn:ietf:wg:oauth:2.0:oob");
SetVar(Ctx->Vars,"connect_back_page","<html><body><h1>Code Accepted By Application</h1><body></html>");
Ctx->AccessToken=CopyStr(Ctx->AccessToken, "");
Ctx->RefreshToken=CopyStr(Ctx->RefreshToken, "");
Ctx->RefreshURL=CopyStr(Ctx->RefreshURL, RefreshURL);
Ctx->SavePath=MCopyStr(Ctx->SavePath, GetCurrUserHomeDir(), "/.oauth.creds",NULL);
if (strcasecmp(Type, "getpocket.com")==0)
{
ptr=GetToken(ClientID,"-",&Token,0);
Tempstr=MCopyStr(Tempstr, "pocketapp",Token,":authorizationFinished",NULL);
SetVar(Ctx->Vars, "redirect_uri",Tempstr);
//Ctx->VerifyURL=MCopyStr(Ctx->VerifyURL,"https://getpocket.com/auth/authorize?request_token=",Ctx->AccessToken,"&redirect_uri=",Args,NULL);
}
else if (strcasecmp(Type, "implicit")==0) Ctx->Flags |= OAUTH_IMPLICIT;
if (! OAuthKeyChain) OAuthKeyChain=ListCreate();
ListAddNamedItem(OAuthKeyChain, Name, Ctx);
DestroyString(Tempstr);
DestroyString(Token);
return(Ctx);
}
开发者ID:ColumPaget,项目名称:Crayonizer,代码行数:46,代码来源:OAuth.c
示例7: LaunchPlayer
//this shouldn't really be in here, but the decision to launch an player happens in the 'DisplayProgress' function
void LaunchPlayer()
{
char *Tempstr=NULL;
Tempstr=MCopyStr(Tempstr,Player," ",OutputFilesGetFilePath(),NULL);
PlayerPid=Spawn(Tempstr);
DestroyString(Tempstr);
}
开发者ID:JackieXie168,项目名称:movgrab,代码行数:10,代码来源:display.c
示例8: HTTPServerSendHeader
void HTTPServerSendHeader(STREAM *S, char *Header, char *Value)
{
char *Tempstr=NULL;
Tempstr=MCopyStr(Tempstr,Header,": ",Value,"\r\n",NULL);
STREAMWriteLine(Tempstr,S);
if (Settings.Flags & FLAG_LOG_VERBOSE) LogToFile(Settings.LogPath,">> %s",Tempstr);
DestroyString(Tempstr);
}
开发者ID:ColumPaget,项目名称:Alaya,代码行数:9,代码来源:server.c
示例9:
char *ItemCodeFromFileExtension(char *RetBuf, char *Default, char *Path)
{
char *Tempstr=NULL, *RetStr=NULL, *ptr;
Tempstr=CopyStr(Tempstr,Path);
ptr=strrchr(Tempstr,'?');
if (ptr) *ptr='\0';
ptr=strrchr(Tempstr,'.');
if (ptr)
{
ptr++;
RetStr=MCopyStr(RetBuf,"item:",ptr,NULL);
}
else RetStr=MCopyStr(RetBuf,Default);
DestroyString(Tempstr);
return(RetStr);
}
开发者ID:tcbabu,项目名称:kgmplayer,代码行数:18,代码来源:extract_text.c
示例10: SMTPHelo
int SMTPHelo(STREAM *S)
{
int RetVal=0;
char *Tempstr=NULL, *Token=NULL;
const char *ptr;
ptr=LibUsefulGetValue("SMTP:HELO");
if (! StrValid(ptr)) ptr=STREAMGetValue(S,"SMTP:HELO");
if (! StrValid(ptr))
{
Token=GetExternalIP(Token);
ptr=Token;
}
Tempstr=MCopyStr(Tempstr, "EHLO ", ptr, "\r\n", NULL);
STREAMWriteLine(Tempstr,S);
Tempstr=SMTPRead(Tempstr, S);
if (*Tempstr == '2')
{
RetVal |= CAP_EHLO;
ptr=GetToken(Tempstr,"\n",&Token,0);
while (ptr)
{
StripTrailingWhitespace(Token);
RetVal |= SMTPParseCapabilities(Token);
ptr=GetToken(ptr,"\n",&Token,0);
}
}
//Some old server that doesn't support EHLO, switch to HELO
else
{
Tempstr=MCopyStr(Tempstr, "HELO ", ptr, "\r\n", NULL);
STREAMWriteLine(Tempstr,S);
if (SMTPInteract(Tempstr, S)) RetVal |= CAP_HELO;
}
DestroyString(Tempstr);
DestroyString(Token);
return(RetVal);
}
开发者ID:ColumPaget,项目名称:ParanoidTelnetD,代码行数:44,代码来源:Smtp.c
示例11: HTTPServerSendM3U
void HTTPServerSendM3U(STREAM *S, HTTPSession *Session, char *Path, int NoOfFiles, TPathItem **Files)
{
char *Tempstr=NULL, *M3U=NULL, *URL=NULL, *Salt=NULL, *AccessToken=NULL, *ptr;
ListNode *Vars;
STREAM *F;
int i;
M3U=CopyStr(M3U,"#EXTM3U\n");
for (i=0; i < NoOfFiles; i++)
{
if (InFileTypeList(Files[i]->Path,Settings.M3UFileTypes))
{
//Examine file for Artist/title information
Vars=ListCreate();
F=STREAMOpenFile(Files[i]->Path, SF_RDONLY);
if (F)
{
MediaReadDetails(F, Vars);
STREAMClose(F);
}
ptr=GetVar(Vars, "Media-title");
if (StrLen(ptr))
{
//#EXTINF - extra info - length (seconds), title
Tempstr=CopyStr(Tempstr, GetVar(Vars, "Media-artist"));
if (! StrLen(Tempstr)) Tempstr=CopyStr(Tempstr,"unknown-artist");
M3U=MCatStr(M3U,"#EXTINF: -1, ", Tempstr, "-", GetVar(Vars,"Media-title"),"\n",NULL);
}
//Actually supply the URL
M3U=CatStr(M3U,Files[i]->URL);
//if we are supporting access token authentication, supply that
if (AuthenticateExamineMethods(Settings.AuthMethods, FALSE) & AUTH_ACCESSTOKEN)
{
GenerateRandomBytes(&Salt,24,ENCODE_HEX);
AccessToken=MakeAccessToken(AccessToken, Session->UserName, Salt, Session->ClientIP, Files[i]->URL);
M3U=MCatStr(M3U,"?AccessToken=",AccessToken,NULL);
}
ListDestroy(Vars,DestroyString);
M3U=CatStr(M3U,"\n");
}
}
Tempstr=MCopyStr(Tempstr,Path,".m3u",NULL);
SetVar(Session->Headers,"Content-disposition",Tempstr);
HTTPServerSendResponse(S, Session, "200 OK","audio/x-mpegurl",M3U);
DestroyString(AccessToken);
DestroyString(Tempstr);
DestroyString(Salt);
DestroyString(URL);
DestroyString(M3U);
}
开发者ID:ColumPaget,项目名称:Alaya,代码行数:56,代码来源:directory_listing.c
示例12: LibUsefulInitSettings
void LibUsefulInitSettings()
{
char *Tempstr=NULL;
LibUsefulSettings=ListCreate();
SetVar(LibUsefulSettings,"LibUsefulVersion",__LIBUSEFUL_VERSION__);
Tempstr=MCopyStr(Tempstr,__LIBUSEFUL_BUILD_DATE__," ",__LIBUSEFUL_BUILD_TIME__,NULL);
SetVar(LibUsefulSettings,"LibUsefulBuildTime",Tempstr);
DestroyString(Tempstr);
}
开发者ID:ColumPaget,项目名称:Alaya,代码行数:10,代码来源:libsettings.c
示例13: ProxyHandleFileTransfer
int ProxyHandleFileTransfer(TSession *Session, char *Command, char *Path, int Direction)
{
STREAM *InFile;
int fd, KeepReading;
char *Tempstr=NULL;
Tempstr=MCopyStr(Tempstr,Command," ",Path,"\r\n",NULL);
STREAMWriteLine(Tempstr,Session->ProxySock);
STREAMFlush(Session->ProxySock);
LogToFile(Settings.LogPath,"PROXY SEND: %s ",Tempstr);
if (! CopyToSock(Session->ProxySock, Session->ClientSock)) return(FALSE);
if (ProxyOpenDataConnection(Session,0))
{
if (OpenDataConnection(Session,0))
{
if (Direction==FILE_SEND) SendFileData(Session->Flags & SESSION_ASCII_TRANSFERS,Session->DataConnection->Sock, Session->ProxyDataConnection->Sock,0);
else
{
SendFileData(Session->Flags & SESSION_ASCII_TRANSFERS,Session->ProxyDataConnection->Sock, Session->DataConnection->Sock,0);
}
CloseDataConnection(Session, Session->DataConnection);
}
CloseDataConnection(Session, Session->ProxyDataConnection);
Tempstr=STREAMReadLine(Tempstr,Session->ProxySock);
STREAMWriteLine(Tempstr,Session->ClientSock);
STREAMFlush(Session->ClientSock);
Session->DataConnection=NULL;
Session->ProxyDataConnection=NULL;
}
/*
//One day will use this instead
LogToFile(Settings.LogPath, "MADE DATA CON");
DataCon->Input=DataCon->Sock;
LogToFile(Settings.LogPath, "ADD LOCAL CON");
DataCon->Output=Session->DataConnection->Sock;
LogToFile(Settings.LogPath, "SET FNAME");
DataCon->FileName=CopyStr(DataCon->FileName,"Proxy");
DataCon->Flags |= DC_RETR;
Session->DataConnection=NULL;
Session->ProxyDataConnection=NULL;
ListAddItem(Session->FileTransfers,DataCon);
*/
DestroyString(Tempstr);
return(TRUE);
}
开发者ID:ColumPaget,项目名称:MetaFTPD,代码行数:55,代码来源:proxy.c
示例14: CopyLocalItem
int CopyLocalItem(char *From, char *To)
{
glob_t Glob;
struct stat FStat;
char *Tempstr=NULL, *ptr;
int i, RetVal=EFAULT;
STREAM *In=NULL, *Out=NULL;
stat(From,&FStat);
if (S_ISDIR(FStat.st_mode))
{
mkdir(To,FStat.st_mode);
Tempstr=MCopyStr(Tempstr, From, "/*", NULL);
glob(Tempstr, 0, 0, &Glob);
for (i=0; i < Glob.gl_pathc; i++)
{
ptr=strrchr(Glob.gl_pathv[i],'/');
if (! ptr) ptr=Glob.gl_pathv[i];
Tempstr=MCopyStr(Tempstr, To, ptr, NULL);
CopyLocalItem(Glob.gl_pathv[i],Tempstr);
}
RetVal=0;
globfree(&Glob);
}
else
{
In=STREAMOpenFile(From,SF_RDONLY);
if (In)
{
Out=STREAMOpenFile(To, SF_CREAT| SF_WRONLY | SF_TRUNC);
if (Out) RetVal=STREAMSendFile(In, Out, 0, SENDFILE_KERNEL | SENDFILE_LOOP);
}
}
//as In and Out are NULL if not opened, it's safe to close them
//here as STREAMClose will ignore a NULL argument
STREAMClose(In);
STREAMClose(Out);
DestroyString(Tempstr);
return(RetVal);
}
开发者ID:ColumPaget,项目名称:Alaya,代码行数:42,代码来源:common.c
示例15: FileSystemUnMount
int FileSystemUnMount(const char *MountPoint, const char *Args)
{
int Flags=UMOUNT_NOFOLLOW;
int ExtraFlags=0;
char *Token=NULL;
const char *ptr;
struct stat FStat;
int i, result;
glob_t Glob;
ptr=GetToken(Args, " |,", &Token, GETTOKEN_MULTI_SEP);
while (ptr)
{
if (strcmp(Token,"follow")==0) Flags &= ~UMOUNT_NOFOLLOW;
if (strcmp(Token,"lazy")==0) Flags |= MNT_DETACH;
if (strcmp(Token,"detach")==0) Flags |= MNT_DETACH;
if (strcmp(Token,"recurse")==0) ExtraFlags |= UMOUNT_RECURSE;
if (strcmp(Token,"rmdir")==0) ExtraFlags |= UMOUNT_RMDIR;
ptr=GetToken(ptr, " |,", &Token, GETTOKEN_MULTI_SEP);
}
if (ExtraFlags & UMOUNT_RECURSE)
{
Token=MCopyStr(Token,MountPoint,"/*",NULL);
glob(Token, 0, 0, &Glob);
for (i=0; i < Glob.gl_pathc; i++)
{
stat(Glob.gl_pathv[i],&FStat);
if (S_ISDIR(FStat.st_mode))
{
FileSystemUnMount(Glob.gl_pathv[i], Args);
}
}
globfree(&Glob);
}
#ifdef HAVE_UMOUNT2
result=umount2(MountPoint, Flags);
#elif HAVE_UMOUNT
result=umount(MountPoint);
#elif HAVE_UNMOUNT
result=unmount(MountPoint,0);
#else
result=-1
#endif
if (ExtraFlags & UMOUNT_RMDIR) rmdir(MountPoint);
DestroyString(Token);
return(result);
}
开发者ID:ColumPaget,项目名称:Movgrab,代码行数:54,代码来源:FileSystem.c
示例16: DisplayAvailableFormats
int DisplayAvailableFormats(ListNode *Vars, char *Formats, int ShowSize)
{
char *URL=NULL, *Token=NULL, *TokenID=NULL, *Tempstr=NULL, *ptr;
STREAM *S;
int result=TRUE;
fprintf(stderr, "\nFormats available for this Movie: ");
ptr=GetToken(Formats," ",&Token,0);
while (ptr)
{
if (StrLen(Token)) TokenID=MCopyStr(TokenID,"item:",Token,NULL);
URL=CopyStr(URL,GetVar(Vars,TokenID));
if (strcmp(Token,"reference") !=0)
{
fprintf(stderr,"%s",Token);
if (ShowSize)
{
S=HTTPMethod("HEAD",URL,NULL,NULL);
if (S)
{
Tempstr=CopyStr(Tempstr,STREAMGetValue(S,"HTTP:ResponseCode"));
if (strcmp(Tempstr,"403") ==0)
{
printf("\nERROR: %s response for %s\n",Tempstr,URL);
result=FALSE;
break;
}
else if (strcmp(Tempstr,"200")==0)
{
Tempstr=CopyStr(Tempstr,STREAMGetValue(S,"HTTP:Content-length"));
fprintf(stderr, " (%s)",GetHumanReadableDataQty(strtod(Tempstr,NULL),FALSE));
STREAMClose(S);
}
}
}
}
fprintf(stderr,", ");
ptr=GetToken(ptr," ",&Token,0);
}
fprintf(stderr,"\n\n",Tempstr);
DestroyString(Token);
DestroyString(TokenID);
DestroyString(Tempstr);
DestroyString(URL);
return(result);
}
开发者ID:JackieXie168,项目名称:movgrab,代码行数:54,代码来源:display.c
示例17: if
char *FormatFileType(char *RetStr, TPathItem *File, ListNode *Vars, const char *MimeIconsURL)
{
char *Tempstr=NULL, *URL=NULL, *ptr;
TFileMagic *FM;
ListNode *Curr;
TPathItem *PathItem;
RetStr=CopyStr(RetStr, "???");
//Book a content type against file so that things outside this function can use it
if (File->Type==PATHTYPE_DIR) File->ContentType=CopyStr(File->ContentType, "DIR");
else
{
FM=GetFileTypeInfo(File->Name);
if (! FM) File->ContentType=CopyStr(File->ContentType, "FILE");
else File->ContentType=CopyStr(File->ContentType, FM->ContentType);
}
RetStr=CopyStr(RetStr,File->ContentType);
ptr=GetVar(Vars,"Thumbnail");
if (StrLen(ptr))
{
RetStr=CopyStr(RetStr, ptr);
}
else if ((Settings.DirListFlags & DIR_MIMEICONS) && MimeIconsURL)
{
ptr=strrchr(File->Name,'.');
if (ptr) ptr++;
if (File->Type==PATHTYPE_DIR) URL=MCopyStr(URL,MimeIconsURL,"?Type=folder&MimeType=inode/directory&FileExtn=",NULL);
else URL=MCopyStr(URL,MimeIconsURL,"?MimeType=",RetStr,"&FileExtn=",ptr,NULL);
Tempstr=MCopyStr(Tempstr,"<img src=\"",URL,"\" alt=\"",RetStr,"\">",NULL);
RetStr=CopyStr(RetStr, Tempstr);
}
DestroyString(Tempstr);
DestroyString(URL);
return(RetStr);
}
开发者ID:ColumPaget,项目名称:Alaya,代码行数:41,代码来源:directory_listing.c
示例18: OAuthInstalledAppURL
void OAuthInstalledAppURL(char *LoginURL, char *ClientID, char *Scope, char *RedirectURL, char **NextURL)
{
char *Encode=NULL;
Encode=HTTPQuote(Encode,ClientID);
*NextURL=MCopyStr(*NextURL,LoginURL,"?response_type=code&redirect_uri=",RedirectURL,"&client_id=",Encode,NULL);
Encode=HTTPQuote(Encode,Scope);
*NextURL=MCatStr(*NextURL,"&scope=",Encode,NULL);
DestroyString(Encode);
}
开发者ID:ColumPaget,项目名称:daytime,代码行数:12,代码来源:oauth.c
示例19: HTTPServerHandleAuthHeader
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);
}
开发者ID:ColumPaget,项目名称:Alaya,代码行数:53,代码来源:server.c
示例20: ParseURL
char *ResolveURL(char *RetStr, const char *Parent, const char *SubItem)
{
char *Proto=NULL, *Host=NULL, *Port=NULL, *Path=NULL;
char *BasePath=NULL;
ParseURL(Parent,&Proto,&Host,&Port,NULL,NULL,&Path,NULL);
if (StrValid(Port)) BasePath=FormatStr(BasePath, "%s://%s:%s/", Proto,Host,Port);
else BasePath=FormatStr(BasePath, "%s://%s/", Proto,Host);
//if it starts with '/' then we don't append to existing path
if (*SubItem=='/') RetStr=MCopyStr(RetStr, BasePath, SubItem, NULL);
else RetStr=MCopyStr(RetStr, BasePath, Path, "/", SubItem, NULL);
DestroyString(Proto);
DestroyString(Host);
DestroyString(Port);
DestroyString(Path);
DestroyString(BasePath);
return(RetStr);
}
开发者ID:ColumPaget,项目名称:Crayonizer,代码行数:21,代码来源:URL.c
注:本文中的MCopyStr函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论