예제 #1
0
파일: testSymbols.cpp 프로젝트: JT-a/USD
int main()
{
    std::string path;

    // Invalid pointer.
    ARCH_AXIOM(!_GetLibraryPath(0, &path));

    // Pointer to a local non-function.
    ARCH_AXIOM(!_GetLibraryPath(&path, &path));

    // Pointer into the DATA section.
    ARCH_AXIOM(_GetLibraryPath(&data, &path));
    ARCH_AXIOM(GetBasename(path) == "testArchSymbols");

    // Pointer into the BSS section.
    ARCH_AXIOM(_GetLibraryPath(&bss, &path));
    ARCH_AXIOM(GetBasename(path) == "testArchSymbols");

    // Find this library.
    ARCH_AXIOM(_GetLibraryPath((void*)&Code, &path));
    ARCH_AXIOM(GetBasename(path) == "testArchSymbols");

    // Find another library.
    ARCH_AXIOM(_GetLibraryPath((void*)&exit, &path));
    ARCH_AXIOM(GetBasename(path) != "testArchSymbols");

    return 0;
}
예제 #2
0
void SigUIFrame::m_local_addOnButtonClick( wxCommandEvent& WXUNUSED(event) )
{
    //TODO: keep in sync with DBEXT
    wxString wildcard = wxString(_("ClamAV database files")) + " (*.cbc, *.cdb, *.cfg, *.cld, *.cvd, *.db, *.fp, *.ftm, *.gdb, *.hdb, *.hdu, *.idb, *.ldb, *.ldu, *.mdb, *.mdu, *.ndb, *.ndu, *.pdb, *.rmd, *.sdb, *.wdb, *.zmd)|*.cbc;*.cdb;*.cfg;*.cld;*.cvd;*.db;*.fp;*.ftm;*.gdb;*.hdb;*.hdu;*.idb;*.ldb;*.ldu;*.mdb;*.mdu;*.ndb;*.ndu;*.pdb;*.rmd;*.sdb;*.wdb;*.zmd";
    wxFileDialog dlg(this, _("Choose a virus signature file"),
		     wxEmptyString, wxEmptyString,
		     wildcard,
		     wxFD_OPEN | wxFD_FILE_MUST_EXIST | wxFD_MULTIPLE | wxFD_CHANGE_DIR);
    dlg.CentreOnParent();
    if (dlg.ShowModal() == wxID_OK) {
	wxArrayString paths;
	dlg.GetPaths(paths);
	StringSet db_set;
	GetFreshclamDBnames(&db_set);

	for (unsigned i=0;i<paths.GetCount();i++) {
	    wxString path = paths[i];
	    if (m_sig_candidates->FindString(path, false) != wxNOT_FOUND) {
		wxLogWarning(_("File already added: %s"), path);
		continue;
	    }
	    if (db_set.count(GetBasename(path))) {
		wxLogWarning(_("File is managed by freshclam. On next update it will be overwritten: %s"), path);
	    }

	    m_sig_candidates->Append(path);
	}
	m_local_remove->Enable(!m_sig_candidates->IsEmpty());
	m_install->Enable(!m_sig_candidates->IsEmpty());
    }
}
예제 #3
0
void SigUIFrame::m_custom_addOnButtonClick( wxCommandEvent& WXUNUSED(event) )
{
    URLEntryDialog dlg(this, _("Custom virus signatures source HTTP or file URL:"), _("Input http:// file:// URL or UNC path:"));
    if (dlg.ShowModal() == wxID_OK) {
	wxString str = dlg.GetValue();
	if (str.StartsWith("\\\\")) {
	    wxLogWarning(_("You specified an UNC path, make sure the SYSTEM account can access it!\n"
			   "(SYSTEM account usually can't access network shares)"));
	    str = "file://" + str;//freshclam remove file:// so it should be fine
	}

	// look for duplicate basename (since it will they will just overwrite
	// eachother in the DBdir)
	StringSet db_set;
	GetFreshclamDBnames(&db_set);
	wxString basename = GetBasename(str);

	if (db_set.count(basename)) {
	    wxLogWarning(_("Adding this database (%s) will overwrite existing database (%s)!\n"
			   "You should remove one of them from the custom signatures list"),
			 str, basename);
	}

	m_urls->Append(str);
	m_custom_remove->Enable();
    }
}
예제 #4
0
void FilePath::ReplaceExtension(const String &extension)
{
    if(!IsEmpty())
    {
        const String basename = GetBasename();
        absolutePathname = NormalizePathname((GetDirectory() + (basename + extension)).absolutePathname);
    }
}
예제 #5
0
void SigUIFrame::GetFreshclamDBnames(StringSet *set)
{
    set->insert("main.cvd");
    set->insert("daily.cvd");
    set->insert("bytecode.cvd");
    for (unsigned i=0;i<m_urls->GetCount();i++) {
	set->insert( GetBasename(m_urls->GetString(i)) );
    }
}
예제 #6
0
파일: common.c 프로젝트: ColumPaget/Alaya
TPathItem *PathItemCreate(int Type, const char *URL, const char *Path)
{
TPathItem *PI=NULL;

PI=(TPathItem *) calloc(1,sizeof(TPathItem));
PI->Type=Type;
PI->Path=CopyStr(PI->Path,Path);
PI->Name=CopyStr(PI->Name,GetBasename((char *) Path));
PI->URL=CopyStr(PI->URL,URL);
PI->ContentType=CopyStr(PI->ContentType, "");
return(PI);
}
예제 #7
0
StreamBase & Maps::operator<< (StreamBase & msg, const FileInfo & fi)
{
    msg << GetBasename(fi.file) << fi.name << fi.description <<
	fi.size_w << fi.size_h << fi.difficulty << static_cast<u8>(KINGDOMMAX);

    for(u8 ii = 0; ii < KINGDOMMAX; ++ii)
	msg << fi.races[ii] << fi.unions[ii];

    msg << fi.kingdom_colors << fi.allow_human_colors << fi.allow_comp_colors <<
	fi.rnd_races << fi.conditions_wins << fi.wins1 << fi.wins2 << fi.wins3 << fi.wins4 <<
	fi.conditions_loss << fi.loss1 << fi.loss2 << fi.localtime << fi.with_heroes;

    return msg;
}
예제 #8
0
void HTTPServerSendCSV(STREAM *S, HTTPSession *Session, char *Path, int NoOfFiles, TPathItem **Files)
{
char *Tempstr=NULL, *SizeStr=NULL, *CSV=NULL;
struct stat Stat;
int i;

CSV=CopyStr(CSV,"File Name,URL,Last Modified,Size\r\n");

for (i=0; i < NoOfFiles; i++)
{
		stat(Files[i]->Path,&Stat);
		SizeStr=FormatStr(SizeStr,"%d",Stat.st_size);
		CSV=MCatStr(CSV,"\"",GetBasename(Files[i]->Path),"\", \"",Files[i]->URL,"\", \"",GetDateStrFromSecs("%Y/%m/%d %H:%M:%S",Stat.st_mtime,NULL),"\", \"",SizeStr,"\"\r\n",NULL);
}

Tempstr=MCopyStr(Tempstr,Path,".csv",NULL);
SetVar(Session->Headers,"Content-disposition",Tempstr);
HTTPServerSendResponse(S, Session, "200 OK","text/csv",CSV);

DestroyString(Tempstr);
DestroyString(SizeStr);
DestroyString(CSV);
}
예제 #9
0
파일: server.c 프로젝트: ColumPaget/Alaya
void IcecastSendData(STREAM *Input, STREAM *Output, int ICYInterval)
{
char *ICYMessage=NULL, *Tempstr=NULL;
int BuffSize=4096, BytesRead=0, len, result;
ListNode *Vars;

	Vars=ListCreate();
	SetVar(Vars, "Title",GetBasename(Input->Path));
	MediaReadDetails(Input,Vars);

	ICYMessage=SubstituteVarsInString(ICYMessage,"StreamTitle='$(Title)'; StreamArtist='$(Artist)';",Vars,0);
	LogToFile(Settings.LogPath,"Open: %s, message: %s",Input->Path,ICYMessage);
	Tempstr=SetStrLen(Tempstr,BuffSize);
	while (TRUE) 
	{
		len=ICYInterval-BytesRead;
		if (len > BuffSize) len=BuffSize;
		result=STREAMReadBytes(Input,Tempstr,len);
		if (result==EOF) break;

		BytesRead+=result;
		STREAMWriteBytes(Output,Tempstr,result);

		if (BytesRead==ICYInterval)
		{
			LogToFile(Settings.LogPath,"SEND ICY: %s",ICYMessage);
			BytesRead=0;
			SendICYMessage(Output, ICYMessage);
			//Don't send it again.
			ICYMessage=CopyStr(ICYMessage,"");
		}	
	}

ListDestroy(Vars,DestroyString);
DestroyString(ICYMessage);
DestroyString(Tempstr);
}
예제 #10
0
int HTTPServerSendPackedDir(STREAM *S, HTTPSession *Session, const char *Dir)
{
char *Tempstr=NULL, *DirName=NULL, *FileName=NULL, *ptr;
char *Extn=NULL, *PackType=NULL, *Name=NULL, *Value=NULL;
char *PackList=NULL;
TFileMagic *FM;
HTTPSession *Response;
STREAM *Pipe;

	chdir(Dir);
	//unset session reuse, because we will close session to indicate end of package
	Session->Flags &= ~SESSION_REUSE;

	//do this so we can strcmp it
	PackList=CopyStr(PackList,"");

	Response=HTTPSessionResponse(Session);
	Response->ResponseCode=CopyStr(Response->ResponseCode,"200 OK");

	ptr=GetNameValuePair(Session->Arguments, "&","=",&Name,&Value);
	while (ptr)
	{
		if ( StrLen(Name) )
		{
		if	(strcasecmp(Name,"packtype")==0)
		{
			PackType=CopyStr(PackType,Value);
			Extn=MCopyStr(Extn, ".", Value, NULL);
			FM=GetFileMagicForFile(Extn, NULL);
			Response->ContentType=CopyStr(Response->ContentType, FM->ContentType);
		}
		else if (strcasecmp(Name,"selected")==0) 
		{
			if (strcmp(PackList," *") !=0) PackList=MCatStr(PackList, " ", Value, NULL);
		}
		}
		
	ptr=GetNameValuePair(ptr, "&","=",&Name,&Value);
	}

	if (StrLen(PackList)==0) PackList=CopyStr(PackList, " *");
	DirName=CopyStr(DirName,Dir);
	StripDirectorySlash(DirName);
	ptr=GetBasename(DirName);

	if (! StrLen(ptr)) ptr="rootdir";

	FileName=MCopyStr(FileName,Session->Host,"-",Session->UserName,"-",ptr,Extn,NULL);
	strrep(FileName,' ','_');

	Tempstr=MCopyStr(Tempstr,"attachment; filename=",FileName,NULL);
	SetVar(Response->Headers,"Content-disposition",Tempstr);

	ptr=GetNameValuePair(Settings.PackFormats, ",",":", &Name, &Value);
	while (ptr)
	{
	if (strcasecmp(Name, PackType)==0)
	{
		if (strcasecmp(Value,"internal")==0)
		{
			if (strcasecmp(Name,"tar")==0) 
			{
				HTTPServerSendHeaders(S, Response, 0); 
				TarFiles(S, PackList);
			}
		}
		else
		{
		HTTPServerSendHeaders(S, Response, 0); 
		Tempstr=MCopyStr(Tempstr,Value,PackList,NULL);
		Pipe=STREAMSpawnCommand(Tempstr, COMMS_BY_PIPE);
		STREAMSendFile(Pipe, S, 0, SENDFILE_KERNEL| SENDFILE_LOOP);
		STREAMClose(Pipe);
		}
	}
	ptr=GetNameValuePair(ptr, ",",":", &Name, &Value);
	}

	STREAMFlush(S);

DestroyString(FileName);
DestroyString(Tempstr);
DestroyString(DirName);
DestroyString(PackList);
DestroyString(PackType);
DestroyString(Name);
DestroyString(Value);
DestroyString(Extn);


//This true means 'please close the connection' as our tarballs/zips are transferred using
//connection: close to indicate end of transfer
return(STREAM_CLOSED);
}
예제 #11
0
//yes, '***', three levels of pointer! It's an array of pointers that
//has to be passed into the function as a pointer
int LoadDir(char *Path, HTTPSession *Session, int Flags, TPathItem ***fl_ptr)
{
char *Tempstr=NULL, *URL=NULL, *Dir=NULL;
glob_t Glob;
struct stat Stat;
TPathItem *File, **Files;
ListNode *Curr;
int i, val, fcount=0;

Tempstr=MCopyStr(Tempstr,Path,"/*",NULL);
glob(Tempstr,0,0,&Glob);


Dir=CopyStr(Dir,Session->URL);
Dir=SlashTerminateDirectoryPath(Dir);
//Allocate As Many Items As glob found, plus VPaths, plus one for '..'

val=Glob.gl_pathc+1;
if (Settings.DirListFlags & DIR_SHOW_VPATHS) val+=ListSize(Settings.VPaths);

*fl_ptr=(TPathItem **) calloc(val , sizeof(TPathItem *));
Files=*fl_ptr;

//if we are at '/' then don't offer a parent directory
if (StrLen(Path) > 1)
{
Tempstr=ParentDirectory(Tempstr, Session->URL);
URL=FormatURL(URL,Session,Tempstr);
Files[0]=PathItemCreate(PATHTYPE_DIR,Tempstr,"..");
fcount++;
}


//LoadVPaths if in top-level dir
if (Settings.DirListFlags & DIR_SHOW_VPATHS) 
{
	if (strcmp(Path,Session->StartDir)==0)
	{
		Curr=ListGetNext(Settings.VPaths);
		while (Curr)
		{	
			File=(TPathItem *) Curr->Item;
			if ((File->Type==PATHTYPE_EXTFILE) && (strcmp(File->URL,"/") !=0)) 
			{
				Files[fcount]=PathItemCreate(PATHTYPE_DIR,File->URL,File->URL);
				fcount++;
			}
		Curr=ListGetNext(Curr);
		}
	}
}

for (i=0; i < Glob.gl_pathc; i++)
{
  Tempstr=MCopyStr(Tempstr,Dir,GetBasename(Glob.gl_pathv[i]),NULL);
	URL=FormatURL(URL,Session,Tempstr);

  if (stat(Glob.gl_pathv[i],&Stat) > -1)
	{
  if (S_ISDIR(Stat.st_mode)) File=PathItemCreate(PATHTYPE_DIR,URL,Glob.gl_pathv[i]);
  else File=PathItemCreate(PATHTYPE_FILE,URL,Glob.gl_pathv[i]);
  File->Mtime=Stat.st_mtime;
  File->Size=Stat.st_size;
	}
  Files[fcount]=File;
	fcount++;
}


switch (Flags & SORT_TYPE_MASK)
{
case SORT_SIZE: qsort(Files,fcount,sizeof(TPathItem *),FilesSortSizeCmp); break;
case SORT_RSIZE: qsort(Files,fcount,sizeof(TPathItem *),FilesRSortSizeCmp); break;
case SORT_TIME: qsort(Files,fcount,sizeof(TPathItem *),FilesSortTimeCmp); break;
case SORT_RTIME: qsort(Files,fcount,sizeof(TPathItem *),FilesRSortTimeCmp); break;
case SORT_NAME: qsort(Files,fcount,sizeof(TPathItem *),FilesSortNameCmp); break;
case SORT_RNAME: qsort(Files,fcount,sizeof(TPathItem *),FilesRSortNameCmp); break;
}


globfree(&Glob);
DestroyString(Dir);
DestroyString(URL);
DestroyString(Tempstr);

//i will equal 'Glob.pathc' at end of loop, we also added '..' so return i+1 
return(fcount);
}
예제 #12
0
bool RunEditor(const char* name)
{
    const char* feditor2 = "feditor2";
    return 0 == String::Lower(GetBasename(name)).compare(0, strlen(feditor2), feditor2);
}
예제 #13
0
파일: VPath.c 프로젝트: ColumPaget/Alaya
//This function checks the Paths configured in the server for virtual 
//documents like cgi scripts or streams, or for directories to which we
//are allowed access from outside chroot
int VPathProcess(STREAM *S, HTTPSession *Session, int Flags)
{
ListNode *Curr=NULL, *Default=NULL;
TPathItem *PI=NULL;
char *Path=NULL, *Tempstr=NULL, *ptr;
HTTPSession *VPathSession=NULL;
int result=FALSE;

	
	Curr=ListGetNext(Settings.VPaths);
	while (Curr)
	{
		if (StrLen(Curr->Tag) < 2) Default=Curr;
		else if (strncmp(Session->Path,Curr->Tag,StrLen(Curr->Tag))==0) break;
		Curr=ListGetNext(Curr);
	}

	//If Curr is set then we found a VPath
	if (! Curr) Curr=Default;

	if (! Curr) return(FALSE);

	if (Curr)
	{
		VPathSession=HTTPSessionClone(Session);
		PI=(TPathItem *) Curr->Item;
		result=TRUE;

		//Some things are configureable on a VPath basis. Set those up.
		if (PI->CacheTime) VPathSession->CacheTime=PI->CacheTime;
		if (StrLen(PI->User)) VPathSession->RealUser=CopyStr(VPathSession->RealUser, PI->User);
		if (StrLen(PI->Group)) VPathSession->Group=CopyStr(VPathSession->Group, PI->Group);
		VPathSession->Flags &= ~SESSION_UPLOAD;
		if (PI->Flags & PATHITEM_UPLOAD) VPathSession->Flags |= SESSION_UPLOAD;
	

//		if (Flags & HEADERS_POST) HTTPServerHandlePost(S,Session,PI->Type);
		LogToFile(Settings.LogPath,"APPLYING VPATH: %d [%s] -> [%s] %d",PI->Type,Curr->Tag,PI->Path,VPathSession->Flags & SESSION_UPLOAD);
		switch (PI->Type)
		{
			case PATHTYPE_CGI:
			LogToFile(Settings.LogPath,"CGI EXEC REQUEST: Script='%s' Path='%s'",GetBasename(Session->Path), PI->Path);
			ChrootProcessRequest(S, VPathSession, "EXEC", GetBasename(VPathSession->Path), PI->Path);
			//Don't reuse this session after CGI. CGI program will not send a 'Content-Length'
	    Session->Flags &= ~SESSION_REUSE;
			break;

			case PATHTYPE_EXTFILE:
			VPathHandleFilePath(S,VPathSession,PI,Flags);
			break;

			case PATHTYPE_STREAM:
			HTTPServerHandleStream(S,VPathSession,PI->Path,Flags);
			break;

			case PATHTYPE_LOGOUT:
			VPathSession->Path=FormatStr(VPathSession->Path,"%d-%d-%d",getpid(),time(NULL),rand());
			HTTPServerHandleRegister(VPathSession, LOGIN_CHANGE);
			Path=FormatURL(Path, VPathSession, "/");
			Path=MCatStr(Path,"?Logout=",VPathSession->Path,NULL);
			VPathSession->Flags &= ~SESSION_KEEPALIVE; 
			HTTPServerSendResponse(S, VPathSession, "302", "", Path);
			break;

			case PATHTYPE_URL:
			ChrootProcessRequest(S, VPathSession, "PROXY", PI->Path, "");
			break;

			case PATHTYPE_PROXY:
			if (StrLen(VPathSession->UserName)) 
			{
				//We don't normally copy Password into VPATH, so we need to get it from 'Session'
				if (StrLen(PI->Password)) VPathSession->Password=CopyStr(VPathSession->Password, Session->Password);
				else VPathSession->Password=CopyStr(VPathSession->Password, Session->Password);
				Path=MCopyStr(Path,VPathSession->UserName,":",VPathSession->Password,NULL);
				Tempstr=EncodeBytes(Tempstr, Path, StrLen(Path), ENCODE_BASE64);
				VPathSession->RemoteAuthenticate=MCopyStr(VPathSession->RemoteAuthenticate,"Basic ",Tempstr,NULL);	
			}
			Path=MCopyStr(Path,PI->Path,VPathSession->Path+StrLen(PI->URL),NULL);
			ChrootProcessRequest(S, VPathSession, "PROXY", Path, "");
			break;

			case PATHTYPE_MIMEICONS:
			VPathMimeIcons(S,VPathSession, PI, Flags);
			break;

			default:
				//We didn't find a VPATH to handle this, so return false
			 result=FALSE;
			break;
		}

//		HTTPSessionDestroy(VPathSession);
	}


DestroyString(Tempstr);
DestroyString(Path);

return(result);
}