void ElementVisitor::Visit_CCode( const ESMoL::CCode & ccode ) {
	// Get the code info block
	std::string codeinfo = ccode.CodeInfo();
	// See if code block is code or name of .c file
	if ( codeinfo.find( ".c" ) != std::string::npos ) {
		// Add to list of c files
		std::string cfiles = _curSComp.cfiles();
		// It's a filename
		AddToFileList( cfiles, codeinfo);
		// Set the new list of c files
		_curSComp.cfiles() = cfiles;
	}
	// Otherwise, we will be generating the code as a component using C_CodeGen
	else {
		// Get the name of the component
		std::string compName = ccode.name();
		// Set the block of code
		_curSComp.ccode() = codeinfo; // it's a code block
		// Set the hfiles name
		std::string hfiles = _curSComp.hfiles();
		AddToFileList( hfiles, compName + ".h" );
		_curSComp.hfiles() = hfiles;
		// Set the cfiles name
		std::string cfiles = _curSComp.cfiles();
		AddToFileList( cfiles, compName + ".c" );
		_curSComp.cfiles() = cfiles;
		// Since we actually call things using msubsystem, we need to fill it in
		_curSComp.msubsystem() = compName;
	}
}
void ElementVisitor::Visit_Subsystem( const ESMoL::Subsystem & subSys )
{
	_curSComp.msubsystem() = subSys.name();
	ostringstream cbasename;
	cbasename << subSys.name() << "_sl.";
	std::string cfiles = _curSComp.cfiles();
	std::string hfiles = _curSComp.hfiles();
	AddToFileList( cfiles, cbasename.str() + string("c"));
	AddToFileList( hfiles, cbasename.str() + string("h"));
	_curSComp.cfiles() = cfiles;
	_curSComp.hfiles() = hfiles;
}
Beispiel #3
0
void wipe_file (struct trap_record * tr_ptr)
{
    FILELIST *fl;
    char *name;
    BOOL bSuccess;

    name=strrchr(tr_ptr->tr_file1,'\\');

    if(name==NULL)
        name=tr_ptr->tr_file1;
    else
        name++;

    // This must be one of our wiping temp files... skip.
    if(strnicmp(name,"aaaaaaaa",8)!=0)
    {
        fl=NULL;
        AddToFileList(&fl,tr_ptr->tr_file1,NULL);

        if(fl!=NULL)
        {
            bSuccess=WipeFileList(g_hwnd,PGPsc,fl,FALSE);
        }
    }
}
Beispiel #4
0
VOID
FltQueueFile( WCHAR* File )
{
    FLT_FILE_LIST_ENTRY fileEntry;

    fileEntry.Name = File;

    AddToFileList(&fileEntry);
}
Beispiel #5
0
FILELIST *HDropToFileList(HDROP hDrop)
{
	char szFile[5000+1];
	int NumFiles,i,ReturnCode;
	FILELIST *ListHead;

	NumFiles=DragQueryFile(hDrop,0xFFFFFFFF,NULL,0);
	ListHead=0;
	ReturnCode=TRUE;

	if(NumFiles==0)
		return 0;

	for(i=0;i<NumFiles && ReturnCode == TRUE;i++)
	{
		DragQueryFile(hDrop,i,szFile,5000);
		AddToFileList(&ListHead,szFile,NULL);
	}

	return ListHead;
}
//函数:开始接收文件列表
//功能:
//
//输出: 0 成功, <0 失败
short CPRJ3_0613Dlg::StartRecvFileList(SOCKET s, FilePDU *file_pdu)
{
	int buf_len;
	long retval;
	char *recv_buf;
	//FilePDU *file_pdu;
	CString filename;

	//打印到屏幕
	filename = file_pdu->buf;
	AddToFileList(filename);

	//回复文件列表首帧
	file_pdu = (FilePDU *)malloc(sizeof(FilePDU));
	file_pdu->type = FILE_PDU_TYPE;
	file_pdu->No = 0;
	file_pdu->len = 3;
	strcpy(file_pdu->buf, "ACK");

	buf_len = 1 + 1 + 1 + file_pdu->len;

	retval = send(s, (char*)file_pdu, buf_len, 0);
	if (retval <= 0){
		//返回值判定
		MessageBox(TEXT("回复文件列表首帧失败!"), TEXT("回复错误"), MB_OK);
		return retval;
	}

	filelist_sock = s;
	fl_sock_status = S_RECVFL_0;

	WSAAsyncSelect(s, m_hWnd, WM_FL_SOCK, FD_READ | FD_CLOSE);

	free(file_pdu);

	return 0;
}
Beispiel #7
0
FILELIST *CmdLineToFileList(char *szCmdLine)
{
	char *szNext,*szNow;
	FILELIST *ListHead;
	HANDLE hFindFile;
	WIN32_FIND_DATAA FindFileDataA;
	char szLongName[MAX_PATH+1];
	char *name;
	char *path;

	szNext=szCmdLine;
	ListHead=0;

	while(szNext!=NULL)
	{
		szNow=szNext;
			
		szNext=strstr(szNext," ");
		
		if(szNext!=NULL)
		{
			szNext=strstr(szNext,":\\");

			if(szNext!=NULL)
			{
				szNext=szNext-2;
				if(szNext>szCmdLine)
				{
					*szNext=0;
					szNext++;
				}
				else
				{
					szNext=NULL;
				}
			}
		}
		
		strcpy(szLongName,szNow);

		hFindFile=FindFirstFileA(szNow,&FindFileDataA);

		if(hFindFile!=NULL)
		{
			name=strrchr(szNow,'\\');

			if(name!=NULL)
			{
				path=szNow;
				*name=0;
				name++;

				strcpy(szLongName,path);
				strcat(szLongName,"\\");
				strcat(szLongName,FindFileDataA.cFileName);
			}
			else
			{	
				strcpy(szLongName,FindFileDataA.cFileName);
			}

			CloseHandle(hFindFile);
		}

		AddToFileList(&ListHead,szLongName,NULL);
	}

	return ListHead;
}
//函数:接收文件列表
//
//
//输出: 0 成功, -1 失败
short CPRJ3_0613Dlg::RecvFileList(SOCKET s)
{
	int buf_len;
	long retval;
	char *recv_buf;
	char tmp_No;
	FilePDU *file_pdu;
	CString filename;

	recv_buf = (char*)malloc(BUF_SIZE);		//1 + 1 + 1 + FILE_BUF_SIZE
	buf_len = recv(s, recv_buf, BUF_SIZE, 0);
	if (buf_len <= 0){
		retval = WSAGetLastError();
		if (retval != WSAEWOULDBLOCK){
			closesocket(s);
			MessageBox(TEXT("接收信息错误,连接关闭!"), TEXT("接收失败"), MB_OK);
			//m_InfoList.AddString(TEXT("套接字错误:接收信息错误,连接关闭!"));
			//ShowInfo(TEXT("套接字错误:接收信息错误,连接关闭!"));
			return -1;
		}
		else{
			//非阻塞导致的错误,继续运行即可
			return -1;
		}
	}
	recv_buf[buf_len] = 0;

	file_pdu = (FilePDU*)recv_buf;
	if (file_pdu->type != FILE_PDU_TYPE){
		////////////////////////////////////////////////////////////////
		return -1;
	}
	if (file_pdu->len == 0){
		closesocket(s);
		filelist_sock = 0;
		fl_sock_status = S_CLOSE;
		return 0;
	}
	switch (fl_sock_status){
	case S_RECVFL_0:
		if (file_pdu->No == 0){
			//////////////////////////////////////////
			tmp_No = 0;
			break;
		}
		tmp_No = 1;
		fl_sock_status = S_RECVFL_1;
		break;
	case S_RECVFL_1:
		if (file_pdu->No == 1){
			/////////////////////////////////////////
			tmp_No = 1;
			break;
		}
		tmp_No = 0;
		fl_sock_status = S_RECVFL_0;
		break;
	default:
		free(recv_buf);
		return -1;
	}

	//打印到屏幕
	filename = file_pdu->buf;
	AddToFileList(filename);

	free(recv_buf);

	//回复文件列表首帧
	file_pdu = (FilePDU *)malloc(sizeof(FilePDU));
	file_pdu->type = FILE_PDU_TYPE;
	file_pdu->No = tmp_No;
	file_pdu->len = 3;
	strcpy(file_pdu->buf, "ACK");

	buf_len = 1 + 1 + 1 + file_pdu->len;

	retval = send(s, (char*)file_pdu, buf_len, 0);
	if (retval <= 0){
		//返回值判定
		MessageBox(TEXT("回复文件列表首帧失败!"), TEXT("回复错误"), MB_OK);
		return retval;
	}

	free(file_pdu);

	return 0;
}
Beispiel #9
0
int main(int argc, char* argv[])
{
	SDAHEADER SDAHeader;
	FILE *fout;
	char szOutput[MAX_PATH+1];
	char szDirectory[MAX_PATH+1];
	FILELIST *flindex,*fl,*flnext;
	GETPUTINFO gpi;
	DWORD dwStubSize;
	HRSRC hRCStub;
	HGLOBAL hGBStub;
	char *pStubData;
	HMODULE hModule;

	if(argc!=3)
	{
		printf("MakeSEA <output filename> <input directory>\n");
		return 0;
	}

	strcpy(szOutput,argv[1]);
	strcpy(szDirectory,argv[2]);

	fout=fopen(szOutput,"wb");

	if(fout==0)
	{
		printf("Could not open output file for writing\n");
		return 0;
	}

	memset(&SDAHeader,0x00,sizeof(SDAHEADER));
	memcpy(&(SDAHeader.szPGPSDA),"PGPSEA",6);

	// Write out stub to disk from resources
	hModule=GetModuleHandle(NULL);

	hRCStub=FindResource(hModule,
		MAKEINTRESOURCE(IDR_SEASTUB),
		RT_RCDATA);

	dwStubSize=SizeofResource(hModule,hRCStub);

	hGBStub=LoadResource(hModule,hRCStub);
	pStubData=(char *)LockResource(hGBStub);

	fwrite(pStubData,1,dwStubSize,fout);
	SDAHeader.offset=dwStubSize;

	// Get files from directory parameter
	fl=flindex=NULL;

	AddToFileList(&flindex,szDirectory,NULL);

	// Reverse list since we need directories first
	while(flindex!=NULL)
	{
		flnext=flindex->next;
		
		flindex->next=fl;
		fl=flindex;

		flindex=flnext;
	}

	memset(&gpi,0x00,sizeof(GETPUTINFO));

	gpi.fout=fout;
	gpi.SDAHeader=&SDAHeader;
	gpi.fl=fl;
	gpi.bFeedFilename=TRUE;

	// Find beginning of SEA directory tree
	gpi.PathHead=strlen(gpi.fl->name);
	if(gpi.fl->name[gpi.PathHead]!='\\')
		gpi.PathHead++;
	gpi.fl=gpi.fl->next;

	Deflate_Compress(&gpi);

	FreeFileList(fl);

	fwrite(&SDAHeader,1,sizeof(SDAHEADER),fout);

	fclose(fout);

	if(gpi.CancelOperation)
	{
		remove(szOutput);
	}

	return 0;
}