Esempio n. 1
0
LOCAL BOOL CheckPCDSave(LPTSTR lpFileName)
/***********************************************************************/
{
	FNAME		   	szPP5FileName;
	STRING			szExt;

	if (GetPPFileType(lpFileName) == IDN_PHOTOCD)
	{
		lstrcpy(szPP5FileName, lpFileName);
		stripext(szPP5FileName);
		AstralStrEx(IDN_PP, szExt, sizeof(szExt));
		//lstrcat(szPP5FileName, szExt+1);
		lstrcat(szPP5FileName, MyCharNext( szExt ));

		if (!fPCDNotice)
		{
			int retc = AstralOKCancel(IDS_SAVEPCDASPP5);
			fPCDNotice = TRUE;
			if (retc == IDCANCEL)
				return(FALSE);
		}
		lstrcpy(lpFileName, szPP5FileName);
	}
	return(TRUE);
}
Esempio n. 2
0
bool CompileMaps(const char *ext, MapScriptCompiler *compiler, char *directory = NULL)
{
	if (!directory)
		directory = ".";

	std::string pattern = std::string(directory);
	pattern.append("/*");

	std::vector<std::string> filenames;
	listFilePattern(filenames, pattern.c_str());
	for(std::vector<std::string>::iterator i = filenames.begin();
		i != filenames.end();
		i++)
	{
		if (ExtensionIs(i->c_str(),"map"))
		{
			std::string fullpath(directory);
			fullpath.append("/");
			fullpath.append(*i);

			char *s = stripext(fullpath.c_str());
			if (Exist(va("%s.%s", s,ext))) 
				if(!compiler->CompileMap(s))
					return false;
		}
		else if (i->at(0) != '.')
		{
			// for now, if it's not a .map then try to use it as a directory
			std::string newpath(directory);
			newpath.append("/");
			newpath.append(*i);
			CompileMaps(ext,compiler,(char *)newpath.c_str());
		}
	}


	//log ("");
	return true;
}
Esempio n. 3
0
void SetFileName(
/***********************************************************************/
HWND	hDlg,
int		idCtl,
LPSTR	lpFileSpec,
LPSTR	lpSaveName,
BOOL	bSaving)
{
FNAME szName, szSpec, szExt;

if (bSaving && !fUntitled)
	{
	lstrcpy( szName, stripdir(lpSaveName) );
	stripext( szName );
	lstrcpy( szExt, extension(lpFileSpec) );
	lstrcpy( szSpec, lpFileSpec );
	stripfile( szSpec );
	FixPath( szSpec );
	lstrcat( szSpec, szName );
	lstrcat( szSpec, szExt );
	SetDlgItemText( hDlg, idCtl, Lowercase(szSpec) );
	}
else	SetDlgItemText( hDlg, idCtl, Lowercase(lpFileSpec) );
}
Esempio n. 4
0
    void test_stripext()
    {
        std::string sex("...");
        bool b = stripext(sex);
        assert_true(b);
        assert_equal(sex, "..");
        b = stripext(sex);
        assert_true(b);
        assert_equal(sex, ".");
        b = stripext(sex);
        assert_true(b);
        assert_equal(sex, "");
        b = stripext(sex);
        assert_equal(sex, "");
        assert_false(b);

        sex = "foo.bar.baz";
        stripext(sex);
        assert_equal(sex, "foo.bar");
        stripext(sex);
        assert_equal(sex, "foo");
        stripext(sex);
        assert_equal(sex, "foo");
    }
Esempio n. 5
0
/************************************************************

 	SaveWallpaper

	  	Saves the current picture into the specified file.
		Installs it as the system wallpaper (uses name given).
		Sets the INI tiled flag to the passed value

		returns FALSE if it could not save wallpaper.
************************************************************/
BOOL SaveWallpaper( LPSTR lpName, BOOL fTiled )
{
WORD idDataType;
STRING szSaveAs;
LPFRAME lpFrame;
int nBits, nPlanes, nDepth, nOutWidth, nOutHeight;

if ( !lpImage )
	return(FALSE);
if ( !(lpFrame = ImgGetBaseEditFrame(lpImage)) )
	return(FALSE);

AstralCursor( IDC_WAIT );	/* Put up the wait cursor */

nBits = GetDeviceCaps( Window.hDC, BITSPIXEL );
nPlanes = GetDeviceCaps( Window.hDC, PLANES );
nDepth = nBits * nPlanes;
nOutWidth = GetDeviceCaps( Window.hDC,HORZRES);
nOutHeight = GetDeviceCaps( Window.hDC,VERTRES);

// decide on proper depth
if ( FrameType(lpFrame) == FDT_LINEART )
	idDataType = IDC_SAVELA;
else
if (nDepth <= 4)
	{
  	if( FrameType(lpFrame) == FDT_GRAYSCALE )
		idDataType = IDC_SAVESP;
	else
		idDataType = IDC_SAVE4BITCOLOR;
	}
else
if( nDepth <= 8 || !Control.Save24BitWallpaper)
	{
	if ( FrameType(lpFrame) == FDT_GRAYSCALE )
		idDataType = IDC_SAVECT;
	else
		idDataType = IDC_SAVE8BITCOLOR;
	}
else
	{
	if ( FrameType(lpFrame) == FDT_GRAYSCALE )
		idDataType = IDC_SAVECT;
	else
		idDataType = IDC_SAVE24BITCOLOR;
	}

// Save file into the Windows directory
GetWindowsDirectory(szSaveAs, sizeof(FNAME));
FixPath( szSaveAs );
lstrcat( szSaveAs, filename(lpName) );
stripext( szSaveAs );
lstrcat( szSaveAs, ".BMP" );

if ( !AstralImageSave( IDN_BMP, idDataType, szSaveAs ) )
	goto ErrorExit;

// Make szSaveAs the current wallpaper and apply
WriteProfileString( "Desktop", "TileWallPaper", (fTiled?"1":"0") );
SystemParametersInfo( SPI_SETDESKWALLPAPER, 0, filename(szSaveAs),
	SPIF_UPDATEINIFILE );
AstralCursor( NULL ); /* Revert back to the old cursor */
return (TRUE);

ErrorExit:

AstralCursor( NULL ); /* Revert back to the old cursor */
return(FALSE);
}
Esempio n. 6
0
void runTest(const char* path)
{
	/*
	std::string line;
	g_shell->out() << "echo Hello world\n" << std::flush;
	std::getline(g_shell->in(), line);

	termcolor::set(termcolor::RED);
	std::cout << line << std::endl;
	termcolor::reset();
	*/
	
	std::stringstream cmd;
	std::string binary;
	std::string out, err;
	std::string filename = "/tmp/";
	int rv;

	filename += uniqueName(path);

	binary = stripext(filename);
	
	termcolor::set(termcolor::WHITE, termcolor::BLACK, termcolor::DIM);

	std::cout << "Uploading " << path << "...\n";
	// upload the source code
	g_sftp->upload(path, filename);

	try
	{
		std::cout << "Compiling...\n";
		// compile the code remotely
		cmd << compiler(path) << ' ' << cflags(path) << filename << " -o " << binary;
		rv = g_ssh->runCommand(cmd.str(), out, err);

		if (rv)
			throw compile_error(err);

		std::cout << "Running remotely...\n";
		// run the program remotely
		rv = g_ssh->runCommand(binary, out, err);
		
		if (rv)
			throw nonzero_exit_error(true, out);

		std::cout << "Downloading...\n";
		// download the Mach-O executable
		g_sftp->download(binary, binary);

		std::cout << "Running locally...\n";
		// run the executable via dyld
		std::stringstream locOut;
		pstream* loc = pstream::popen(std::string(DYLD_COMMAND) + " " + binary);

		locOut << loc;
		
		rv = loc->wait();
		
		if (rv)
			throw nonzero_exit_error(false, locOut.str());

		if (locOut.str() != out)
			throw different_output_error(out, locOut.str());
	}
	catch (...)
	{
		// clean up locally
		unlink(binary.c_str());

		try
		{
			// clean up remotely
			g_sftp->unlink(binary);
			g_sftp->unlink(filename);
		}
		catch (...) {}

		throw;
	}
}
Esempio n. 7
0
LOCAL BOOL SetupMacro(LPQUEUEITEM lpQueueItem)
/***********************************************************************/
{
	LPCMDPKT		lpCmdPkt;
	FNAME		   	szFileName;

	lpCmdPkt = CreatePacket(IDS_CMD_LOADFILE, &lpQueueItem->parms, TRUE);
	if (!lpCmdPkt)
		goto MemError;
	ListAddHead(&lpQueueItem->PacketList, lpCmdPkt);

	// create the new filename
	// add a save command to the end if necessary
	if (Macro.BatchSave == IDC_SAVETOORIGINAL)
		lstrcpy(szFileName, lpQueueItem->szFileName);
	else
	if (Macro.BatchSave == IDC_SAVETODIR)
	{
		lstrcpy(szFileName, Macro.BatchDir);
		lstrcat(szFileName, filename(lpQueueItem->szFileName));
	}
	else
	if (Macro.BatchSave == IDC_SAVETOALBUM)
	{
		lstrcpy(szFileName, Browser.AlbumFileDir);
		lstrcat(szFileName, filename(lpQueueItem->szFileName));
	}

	// if we are changing the file type, then change the extension
	if (Macro.fBatchChangeType &&
		(Macro.BatchSave == IDC_SAVETODIR || Macro.BatchSave == IDC_SAVETOALBUM))
	{
		STRING szExt;

		LookupExtension(LocalFileType(Macro.BatchFileType), szExt);
		stripext(szFileName);
		lstrcat(szFileName, szExt);
	}

	// check to make sure we are not saving to PCD and overwrite warning
	if (Macro.BatchSave != IDC_NOSAVE)
	{
		if (!CheckPCDSave(szFileName))
			return(FALSE);
		if (Macro.BatchSave != IDC_SAVETOORIGINAL)
		{
			if (FileExists(szFileName))
			{
				if (AstralOKCancel (IDS_OVERWRITEIMAGE, (LPTSTR)szFileName) != IDOK)
					return(FALSE);
			}
		}

	}

	if (Macro.BatchSave == IDC_SAVETOALBUM)
	{
		// get a path name from the browser
		SAVETOALBUM_PARMS parms;

		lstrcpy(parms.szAlbum, Macro.BatchAlbum);
		lstrcpy(parms.szFileName, szFileName);
	  	parms.idFileType = 	GetPPFileType(parms.szFileName);
		parms.idDataType = 0;
		parms.EPSOptions = EPSOptions;
		parms.TIFFOptions = TIFFOptions;
		parms.TGAOptions = TGAOptions;
		parms.JPEGOptions = JPEGOptions;
		parms.PPFFOptions = PPFFOptions;
		parms.AVIOptions = AVIOptions;

		// create a command list for the load command
		lpCmdPkt = CreatePacket(IDS_CMD_SAVETOALBUM, &parms, TRUE);
		if (!lpCmdPkt)
			goto MemError;
		ListAddTail(&lpQueueItem->PacketList, lpCmdPkt);
	}
	else
	if (Macro.BatchSave != IDC_NOSAVE)
	{
		SAVEFILE_PARMS parms;

		lstrcpy(parms.szFileName, szFileName);
		parms.idFileType = 	GetPPFileType(parms.szFileName);
		parms.idDataType = 0;
		parms.EPSOptions = EPSOptions;
		parms.TIFFOptions = TIFFOptions;
		parms.TGAOptions = TGAOptions;
		parms.JPEGOptions = JPEGOptions;
		parms.PPFFOptions = PPFFOptions;
		parms.AVIOptions = AVIOptions;

		// create a command list for the load command
		lpCmdPkt = CreatePacket(IDS_CMD_SAVEFILE, &parms, TRUE);
		if (!lpCmdPkt)
			goto MemError;
		ListAddTail(&lpQueueItem->PacketList, lpCmdPkt);
	}
	if (Macro.fBatchClose)
	{
		CMD_PARMS parms;

		// create a command list for the load command
		lpCmdPkt = CreatePacket(IDS_CMD_CLOSE, &parms, TRUE);
		if (!lpCmdPkt)
			goto MemError;
		ListAddTail(&lpQueueItem->PacketList, lpCmdPkt);
	}
	return(TRUE);

MemError:
	Message(IDS_EMEMALLOC);
	return(FALSE);
}
Esempio n. 8
0
int main(int eargc, char **eargv) {
	char fname[255];
	char *test;
	char tdfname[255];
	
	char *tok;
	char hopt[255];
	char hargs[255];	


// stupid default values
	longbase=100.0;
	latbase=10.0;
	range=20;

// Lets do ARGS

	argc=eargc;
	argv=eargv;

	totalitems=0;
	totalcoords=0;
	skippeditems=0;

	if (argc<2 || Check_Param("-h") || Check_Param("-?")) {
		showhelp();
		exit(0);	
	}

	if (Check_Param("-f")) fileoutput=1;
	
	if (fileoutput) {
		printf("Polygon E00 to Falcon4 features converter v0.1\n");
		printf("(C)opyright 2000 PMC TFW <*****@*****.**>\n");
		printf("http://tactical.nekromantix.com\n");
		printf("--------------------------------------------------\n");
	}	
	test=Get_Next_Option();
	while (test) {
		if (strchr(test,'=')) {
		// fixme: "Do not never ever use strtok" :-)
			rmallws(test);
			tok=strtok(test,"=");
			if(!tok) continue;
			strncpy(hopt,tok,254);
			tok=strtok(NULL,"=");
			if (!tok) continue;
			strncpy(hargs,tok,254);
			if (strncmp(hopt,"-range",6)==0) range=atoi(hargs);
			else if (strncmp(test,"-long",5)==0) longbase=atol(hargs);
			else if (strncmp(test,"-lat",4)==0) latbase=atol(hargs);
		}
		test=Get_Next_Option();
	}	

	test=NULL;
// first we try to get TYPE	
	test=Get_Next_Name();
	if(!test) exit(1); // erm, not found
	strncpy(type,test,254);

// then we hope for source filename
	test=Get_Next_Name();	
	if(!test) exit(1); // not found..
	strncpy(fname,test,254);

// and from the remaing crap, if there is any, we create output filename
// (to be used, when fileoutput=1)
	test=Get_Next_Name();			
	while(test) {
		strncpy(tdfname,test,254);
		test=Get_Next_Name();		
	}

	if (!tdfname) {
		stripext(fname,test);
		sprintf(tdfname,"%s.tdf",test);
	}

	if (fileoutput) printf("Reading E00 data from: %s\n",fname);
	if(fileoutput) {	
		tdffile=fopen(tdfname,"wt");
		if(!tdffile) fileerror("Error creating tdf...");
		printf("Writing TDF data to: %s\n",tdfname);
		
	}
	
	readstuffs(fname);

	if (tdffile) fclose(tdffile);
	if (fileoutput) {
		printf("\nTotal %ld items %ld coordinates\n",totalitems,totalcoords);
		printf("Processing completed\n\n");
	}
	return 0;
}