MF_API const char* MFFile_HomePath(const char *pFilename) { MFCALLSTACK; pFilename = pFilename ? pFilename : ""; #if defined(MF_XBOX) return MFStr("E:\\Home\\%s", pFilename); #elif defined(_LINUX) return MFStr("~/%s", pFilename); #elif defined(MF_IPHONE) const char *GetUserHome(); return MFStr("%s/%s", GetUserHome(), pFilename); #else return MFStr("Home/%s", pFilename); #endif }
Url WindowsEnvFun::GetUserData(cstring org, cstring app) { if(!org && !app) { org = ApplicationData().organization_name.c_str(); app = ApplicationData().application_name.c_str(); } CString out; out = GetUserHome().internUrl; out = ConcatPath(out.c_str(), "AppData"); out = ConcatPath(out.c_str(), "Local"); out = ConcatPath(out.c_str(), org); out = ConcatPath(out.c_str(), app); out = str::replace::str(out, "\\", "/"); return MkUrl(out, RSCA::SystemFile); }
bool GetTempDir( std::string& tempdir ) { std::string homedir; if ( GetUserHome( homedir ) ) { #ifdef WIN32 tempdir = homedir + "\\MultiGetTemp"; #else tempdir = homedir + "/.MultiGet"; #endif return true; } else { return false; } }
void ReadUsersInfo(LINACONFIG *lc) { USERINFO *Usr; char *Shell=NULL; FILE *pf=NULL,*sf=NULL; char buff[500],*pt,*Pw,sbuff[500],*tmp,*tmp1; int UserNo; system("cat /etc/passwd 2>/tmp/.Junk1 >/tmp/.Junk"); system("ypcat passwd 2>/tmp/.Junk1 >>/tmp/.Junk"); pf = fopen("/tmp/.Junk","r"); if(pf==NULL) return; lc->Ulist=Dopen(); while (fgets(buff,499,pf) != NULL) { if( (pt=GetLoginId(buff))==NULL) continue; Shell=GetUserShell(buff); if(SearchString(Shell,"sh") < 0) { free(Shell);continue;} free(Shell); Shell = NULL; #if 1 Pw = GetUserPasswd(buff); if(Pw==NULL) continue; if(Pw[0]=='\0') { free(Pw);continue;} if((strlen(Pw)==1)&&(strcmp(Pw,"x")!=0)) {free(Pw);continue;} if((strlen(Pw)==1)&&(strcmp(Pw,"x")==0)) { free(Pw); // sf = fopen("/etc/shadow","r"); system("cat /etc/shadow 2>/tmp/.Junk1 >/tmp/.Sjunk"); system("ypcat shadow 2>/tmp/.Junk1 >>/tmp/.Sjunk"); sf = fopen("/tmp/.Sjunk","r"); if(sf==NULL) { fprintf(stderr,"Failed to open /etc/shadow\n"); continue; } while (fgets(sbuff,499,sf) != NULL) { tmp=strchr(sbuff,':'); tmp[0]='\0';tmp++; if(strcmp(sbuff,pt)!=0) continue; tmp1=strchr(tmp,':'); tmp1[0]='\0'; Pw=(char *)malloc(strlen(tmp)+1); strcpy(Pw,tmp); break; } fclose(sf); if((strlen(Pw)==1)&&(strcmp(Pw,"x")!=0)) {free(Pw);continue;} if((strlen(Pw)==1)&&(strcmp(Pw,"*")!=0)) {free(Pw);continue;} if((strlen(Pw)<=1)) {free(Pw);continue;} } #endif UserNo=GetUserNo(buff); if(((lc->NoRootLogin!=1) &&(UserNo==0))||(UserNo>=100)){ // if( (UserNo==0) || (UserNo>=100) ) { Usr= InitUserInfo(); Usr->LoginId=pt; Usr->UserNo=UserNo; Usr->gid=GetGrpId(buff); Usr->Passwd=Pw; Usr->Name = GetUserName(buff); Usr->Home = GetUserHome(buff); Shell=GetUserShell(buff); Usr->Shell= Shell; MakeUserImages(lc,Usr); Dadd(lc->Ulist,Usr); } else {free(pt);free(Pw);} } Dsort(lc->Ulist,CompId); fclose(pf); }
CNewTaskDlg::CNewTaskDlg( MainFrame* parent, wxString defUrl, wxString refer, wxString defSavePath ) : wxDialog( parent, -1, _MGSTR( _S_NEW_TASK ), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER ) { m_pParent = parent; m_sUrl = defUrl; m_sRefer = refer; //对这个url分离用户名和密码 if ( !m_sUrl.IsEmpty() ) { CUrlParser par; std::string m_swap; #ifndef _UNICODE if ( par.SetUrl( m_sUrl.mb_str( wxConvLocal ) ) ) #else if ( par.SetUrl( m_sUrl.mb_str( wxConvLocal ).data() ) ) #endif { if ( par.GetUrlType() == FTP_PROTOCOL ) { m_sUser = wxString( par.GetUser().c_str(), wxConvLocal ); m_sPass = wxString( par.GetPass().c_str(), wxConvLocal ); m_sUrl = wxString( par.GetRawUrl().c_str(), wxConvLocal ); } else { m_sUrl = wxString( par.GetRawUrl().c_str(), wxConvLocal ); } if ( par.GetFileName().empty() ) { m_sRename = wxT( "index.html" ); } else { //m_sRename = par.GetFileName(); m_sRename=wxString(par.GetFileName().c_str(),wxConvLocal); } } } m_sSavePath = defSavePath; if ( m_sSavePath.IsEmpty() ) { m_sSavePath = wxString( gDefSavePath.c_str(), wxConvLocal ); if ( m_sSavePath.IsEmpty() ) { std::string home; GetUserHome( home ); m_sSavePath = wxString( home.c_str(), wxConvLocal ); } } m_nThreadNum = gTaskDefThread; m_nSocksProxy = 0; m_nFtpProxy = 0; m_nHttpProxy = 0; m_nRunNow = 0; //run m_nFileSpin = 1; m_nRetry = gRetryTime; m_nRetryWait = gRetryWait; m_sSavePath = wxString( gDefSavePath.c_str(), wxConvLocal ); m_pMirrorBox = NULL; m_ThSpin = NULL; m_ThRetry = NULL; m_ThRetryWait = NULL; m_FileSpin = NULL; m_pTextCtrl = NULL; m_RenameCtrl=NULL; m_bOpenUrlKeyEvent = false; //这里准备一下代理列表 InitProxyList(); Init(); }