本文整理汇总了C++中MCopyStr函数的典型用法代码示例。如果您正苦于以下问题:C++ MCopyStr函数的具体用法?C++ MCopyStr怎么用?C++ MCopyStr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了MCopyStr函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例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);
}
示例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);
}
示例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);
}
示例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));
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}