Example #1
1
void main( int argc, char *argv[] )
{
    int         fp;
    HelpHeader  header;
    unsigned    i;

    if( argc != 2 ) {
        printf( "Usage: helpdump <help file name>\n" );
        return;
    }
    fp = open( argv[1], O_RDONLY | O_BINARY );
    if( fp == -1 ) {
        printf( "Unable to open %s\n", argv[1] );
        return;
    }
    read( fp, &header, sizeof( HelpHeader ) );
    PrintHeader( &header );
    read( fp, Buffer, header.str_size );
    PrintStrings( Buffer );
    read( fp, Buffer, header.datapagecnt * sizeof( uint_16 ) );
    PrintItemIndex( &header );
    for( i = 0; i < header.indexpagecnt + header.datapagecnt; i++ ) {
        read( fp, Buffer, HLP_PAGE_SIZE );
        PrintPage();
    }
}
Example #2
0
int main(int argc, char **argv) {
        logxx::GlobalLogLevel(logxx::warning);
        bool res(true);
        
        AddTest<TestServer>(true);
        AddTest<TestTask>(true);
        AddTest<TestPool>(true);
        AddTest<TestExecutor>(true);
        AddTest<TestExecutorsPool>(true);
        
        if (argc < 2)
                SetAll(true);
        else {
                for (int i = 1; i < argc; ++i){
                        std::string arg(argv[i]);
                        if (arg == "all")
                                SetAll(true);
                        else if (arg == "none")
                                SetAll(false);
                        else
                                Set(arg);
                }
        }
        
        log(logxx::info) << "Starting tests" << logxx::endl;
        
        std::vector<std::string> passed, failed;
        
        for (auto &pair : tests){
                if (pair.second){
                        std::string label = pair.first->GetLabel();
                        bool testRes = pair.first->RunTests();
                        if (testRes)
                                passed.push_back(label);
                        else
                                failed.push_back(label);
                        res &= testRes;
                }
        }
        
        if (!passed.empty()){
                auto &s = log(logxx::info) << "PASSED tests: ";
                PrintStrings(s, passed);
                s << logxx::endl;
        } else
                log(logxx::info) << "No tests passed" << logxx::endl;
        
        if (!failed.empty()){
                auto &s = log(logxx::info) << "FAILED tests: ";
                PrintStrings(s, passed);
                s << logxx::endl;
        } else
                log(logxx::info) << "No tests failed" << logxx::endl;
        
        return res ? 0 : 1;
}
Example #3
0
/*
============
main
============
*/
int main (int argc, char **argv)
{
	const char	*psrc;
	void		*src, *src2;
	char	filename[1024];
	int		p, c;
	unsigned short		crc;
	double	start, stop;
	FILE	*f;

	myargc = argc;
	myargv = argv;

	if (CheckParm("-?") || CheckParm("-h") || CheckParm("-help") || CheckParm("--help"))
	{
		printf(" Compiles progs.dat using progs.src in the current directory\n");
		printf(" -src <directory> : Specify source directory\n");
		printf(" -dcc : decompile the progs.dat in the current directory\n");
		printf(" -dcc -fix : fixes mangled names during decompilation\n");
		printf(" -dcc -asm <functionname> : decompile filename to the console\n");
		printf(" -dcc -dump -asm <functionname> : same as above but will show\n\t\tinstructions (opcodes and parms) as well\n");
		exit(0);
	}

	ValidateByteorder ();

	start = GetTime ();

	p = CheckParm("-src");
	if (p && p < argc-1)
	{
		strcpy(sourcedir, argv[p+1]);
		strcat(sourcedir, "/");
		printf("Source directory: %s\n", sourcedir);
	}
	else
	{
		sourcedir[0] = '\0';
	}

	InitData ();

	PR_FILE = stdout;

	p = CheckParm("-dump");
	if (p)
		pr_dumpasm = true;

	// do a crc of the file
	p = CheckParm("-crc");
	if (p)
	{
		CRC_Init (&crc);
		f = fopen ("progdefs.h", "r");
		while ((c = fgetc(f)) != EOF)
			CRC_ProcessByte (&crc, (byte)c);

		printf ("#define PROGHEADER_CRC %i %d\n", crc, (int)crc);
		fclose (f);
		exit (0);
	}

	p = CheckParm("-dcc");
	if (p)
	{
		DEC_ReadData ("progs.dat");
		//fix mangled names if asked
		p = CheckParm ("-fix");
		if (p)
			FILE_NUM_FOR_NAME = 1;

		memset(func_headers, 0, MAX_FUNCTIONS * sizeof(char *));
		memset(temp_val, 0, MAX_REGS * sizeof(char *));

		p = CheckParm("-bbb");
		if (p)
		{
		/*	i= -999;
			for (p = 0; p < numstatements; p++)
				if ((statements+p)->op > i)
					i = (statements+p)->op;
			printf("largest op %d\n", i); */
			FindBuiltinParameters(1);

			exit (0);
		}

		p = CheckParm("-ddd");
		if (p)
		{
			for (p++ ; p < argc ; p++)
			{
				if (argv[p][0] == '-')
					break;
				DccFunctionOP (atoi(argv[p]));
			}
			exit (0);
		}

		p = CheckParm("-info2");
		if (p)
		{
			printf("\n=======================\n");
			printf("fields\n");
			printf("=======================\n");
			PrintFields ();
			printf("\n=======================\n");
			printf("globals\n");
			printf("=======================\n");
			PrintGlobals ();
			exit (0);
		}

		p = CheckParm("-info");
		if (p)
		{
			printf("\n=======================\n");
			printf("strings\n");
			printf("=======================\n");
			PrintStrings ();
			printf("\n=======================\n");
			printf("functions");
			printf("\n=======================\n");
			PrintFunctions ();
			printf("\n=======================\n");
			printf("fields\n");
			printf("=======================\n");
			PrintFields ();
			printf("\n=======================\n");
			printf("globals\n");
			printf("=======================\n");
			PrintGlobals ();
			printf("\n=======================\n");
			printf("pr_globals\n");
			printf("=======================\n");
			PrintPRGlobals ();
			printf("\n=======================\n");
			printf("statements\n");
			printf("=======================\n");
			Printstatements();
			exit (0);
		}

		p = CheckParm("-asm");
		if (p)
		{
			for (p++; p < argc; p++)
			{
				if (argv[p][0] == '-')
					break;
				PR_PrintFunction(argv[p]);
			}
		}
		else
		{
			Dcc_Functions ();
			stop = GetTime ();
			printf("\n%d seconds elapsed.\n", (int)(stop-start));
		}

		exit (0);
	}

	sprintf(filename, "%sprogs.src", sourcedir);
	LoadFile(filename, &src);
	psrc = (char *) src;

	psrc = COM_Parse(psrc);
	if (!psrc)
	{
		Error("No destination filename.  HCC -help for info.\n");
	}

	strcpy(destfile, com_token);
	printf("outputfile: %s\n", destfile);

	pr_dumpasm = false;

	PR_BeginCompilation();

	// compile all the files
	do
	{
		psrc = COM_Parse(psrc);
		if (!psrc)
			break;

		sprintf (filename, "%s%s", sourcedir, com_token);
		printf ("compiling %s\n", filename);
		LoadFile (filename, &src2);

		if (!PR_CompileFile((char *)src2, filename))
			exit (1);

	} while (1);

	if (!PR_FinishCompilation())
	{
		Error ("compilation errors");
	}

	p = CheckParm("-asm");
	if (p)
	{
		for (p++; p < argc; p++)
		{
			if (argv[p][0] == '-')
			{
				break;
			}
			PrintFunction(argv[p]);
		}
	}

	// write progdefs.h
	crc = PR_WriteProgdefs("progdefs.h");
//	crc = 14046;	// FIXME: cheap hack for now!!!!!!!!!!!!!

	// write data file
	WriteData(crc);

	// write files.dat
	WriteFiles();

	stop = GetTime ();
	printf("\n%d seconds elapsed.\n", (int)(stop-start));

	exit (0);
}