void CmdLineParserTest() {
    WStrVec args;

    ParseCmdLine(L"test.exe -arg foo.pdf", args);
    utassert(3 == args.size());
    utassert(str::Eq(args.at(0), L"test.exe"));
    utassert(str::Eq(args.at(1), L"-arg"));
    utassert(str::Eq(args.at(2), L"foo.pdf"));
    args.Reset();

    ParseCmdLine(L"test.exe \"foo \\\" bar \\\\.pdf\" un\\\"quoted.pdf", args);
    utassert(3 == args.size());
    utassert(str::Eq(args.at(0), L"test.exe"));
    utassert(str::Eq(args.at(1), L"foo \" bar \\\\.pdf"));
    utassert(str::Eq(args.at(2), L"un\"quoted.pdf"));
    args.Reset();

    ParseCmdLine(L"test.exe \"foo\".pdf foo\" bar.pdf ", args);
    utassert(3 == args.size());
    utassert(str::Eq(args.at(0), L"test.exe"));
    utassert(str::Eq(args.at(1), L"foo.pdf"));
    utassert(str::Eq(args.at(2), L"foo bar.pdf "));
    args.Reset();

    ParseCmdLine(L"test.exe -arg \"%1\" -more", args, 2);
    utassert(2 == args.size());
    utassert(str::Eq(args.at(0), L"test.exe"));
    utassert(str::Eq(args.at(1), L"-arg \"%1\" -more"));
    args.Reset();
}
Example #2
0
bool ViewWithExternalViewer(size_t idx, const WCHAR *filePath, int pageNo)
{
    if (!HasPermission(Perm_DiskAccess) || !file::Exists(filePath))
        return false;
    for (size_t i = 0; i < gGlobalPrefs->externalViewers->Count() && i <= idx; i++) {
        ExternalViewer *ev = gGlobalPrefs->externalViewers->At(i);
        // cf. AppendExternalViewersToMenu in Menu.cpp
        if (!ev->commandLine || ev->filter && !str::Eq(ev->filter, L"*") && !(filePath && path::Match(filePath, ev->filter)))
            idx++;
    }
    if (idx >= gGlobalPrefs->externalViewers->Count() || !gGlobalPrefs->externalViewers->At(idx)->commandLine)
        return false;

    ExternalViewer *ev = gGlobalPrefs->externalViewers->At(idx);
    WStrVec args;
    ParseCmdLine(ev->commandLine, args, 2);
    if (args.Count() == 0 || !file::Exists(args.At(0)))
        return false;

    // if the command line contains %p, it's replaced with the current page number
    // if it contains %1, it's replaced with the file path (else the file path is appended)
    const WCHAR *cmdLine = args.Count() > 1 ? args.At(1) : L"\"%1\"";
    ScopedMem<WCHAR> pageNoStr(str::Format(L"%d", pageNo));
    ScopedMem<WCHAR> params(str::Replace(cmdLine, L"%p", pageNoStr));
    if (str::Find(params, L"%1"))
        params.Set(str::Replace(params, L"%1", filePath));
    else
        params.Set(str::Format(L"%s \"%s\"", params.Get(), filePath));
    return LaunchFile(args.At(0), params);
}
Example #3
0
int main (int argc, char *argv[])
{
#ifdef WIN32
    if (__argv[0]) {
        applicationPath = __argv[0];
        applicationPath.erase (applicationPath.find_last_of ('\\')+1, applicationPath.size());
    }
#else
    if (argv[0]) {
        applicationPath = argv[0];
        applicationPath.erase (applicationPath.find_last_of ('/')+1, applicationPath.size());
    }
#endif

    // Setup logger callback, so error messages are reported with fltk::message
    logger.AddCallback (LogCallbackProc, 0);
#ifdef _DEBUG
    logger.SetDebugMode (true);
#endif

//	math_test();

    // Initialize the class system
    creg::ClassBinder::InitializeClasses ();

    int r = 0;
    if (ParseCmdLine(argc, argv, r))
    {
        // Bring up the main editor dialog
        EditorUI editor;
        editorUI = &editor;
        editor.Show(true);
        editor.LoadToolWindowSettings();

//		luaBinder.Init();
        lua_State *L = lua_open();
        luaL_openlibs(L);
        luaopen_upspring(L);

        editor.luaState = L;

        if (luaL_dostring(L, "require(\"jit.opt\").start()") != 0)
        {
            const char *err = lua_tostring(L, -1);
            fltk::message("Unable to start Lua JIT: %s", err);
        }

        if (luaL_dofile(L, "scripts/init.lua") != 0)
        {
            const char *err = lua_tostring(L, -1);
            fltk::message("Error while executing init.lua: %s", err);
        }
        fltk::run();
    }

    // Shutdown scripting system and class system
    creg::ClassBinder::FreeClasses ();

    return r;
}
Example #4
0
/*>int main(int argc, char **argv)
   -------------------------------
*//**

   Main program for converting PDB format to MS 

-  24.01.96 Original   By: ACRM
-  29.01.96 Added -a and -q handling
-  01.02.95 Added -t and -r handling
-  22.07.14 Renamed deprecated functions with bl prefix. By: CTP
*/
int main(int argc, char **argv)
{
   char InFile[MAXBUFF],
        OutFile[MAXBUFF];
   FILE *in  = stdin,
        *out = stdout;
   PDB  *pdb;
   int  natoms;
   BOOL DoStd, Quiet, Alt, GotRad, GotType;

   if(ParseCmdLine(argc, argv, InFile, OutFile, &DoStd, &Quiet, &Alt,
                   &GotRad, &GotType))
   {
      if(blOpenStdFiles(InFile, OutFile, &in, &out))
      {
         if((pdb = blReadPDB(in, &natoms))==NULL)
         {
            fprintf(stderr,"No atoms read from PDB file\n");
            return(1);
         }

         if(!ConvertPDB2MS(out, pdb, Alt, GotRad, GotType))
            return(1);

         if(DoStd)
            WriteStdDataFiles(Quiet, GotRad);
      }
   }
   else
   {
      Usage();
   }

   return(0);
}
Example #5
0
int main(int argc, char *argv[]) {
#ifdef RUN_UNIT_TESTS
    TestGenerateData();
    TestBPTree();
    return 0;
#endif

    ParseCmdLine(argc, argv);

    if (workdir[0]) {
        if (chdir(workdir) == -1) {
            perror("chdir");
            return 0;
        }
        if (verbose)
            printf(" >> Set CWD to %s\n", workdir);
    }

    if (cache_flush) {
        ThumbCacheFlush();
        return 0;
    }

    if (!cache_no_update && !cache_dont_use)
        ThumbCacheUpdate();

    if (comparison)
        ImageComparisonPerform(comparison, imgpath1, imgpath2);
    if (cache_dump)
        ThumbCacheEnumerate(cache_dump);
    if (deduplicate_dir)
        DedupPerform(workdir);

    return 0;
}
Example #6
0
/*>int main(int argc, char **argv)
   -------------------------------
*//**

   Main program for format conversion

-  23.08.94 Original    By: ACRM
-  24.08.94 Changed to call OpenStdFiles()
-  22.07.14 Renamed deprecated functions with bl prefix. By: CTP
*/
int main(int argc, char **argv)
{
   FILE *in  = stdin,
        *out = stdout;
   char infile[MAXBUFF],
        outfile[MAXBUFF],
        title[MAXBUFF];
   PDB  *pdb;
   int  natoms;
   
   if(ParseCmdLine(argc, argv, infile, outfile, title))
   {
      if(blOpenStdFiles(infile, outfile, &in, &out))
      {
         if((pdb = blReadPDB(in,&natoms)) != NULL)
         {
            WriteXYZ(out, pdb, natoms, title);
         }
         else
         {
            fprintf(stderr,"No atoms read from PDB file\n");
         }
      }
   }
   else
   {
      Usage();
   }
   
   return(0);
}
Example #7
0
int _CRTAPI1 main(
    int argc,
    char *argv[])
{
    //
    //  Parse the command line.
    //  Open input file.
    //
    if (ParseCmdLine(argc, argv))
    {
        return (1);
    }

    //
    //  Parse the input file.
    //  Close the input file.
    //
    if (ParseInputFile())
    {
        fclose(pInputFile);
        return (1);
    }
    fclose(pInputFile);

    //
    //  Return success.
    //
    return (0);
}
Example #8
0
//////////////////////////////////////////////////////////////////////
//  Parse command line, print settings, and execute one of two modes.
//////////////////////////////////////////////////////////////////////
void main( int argc, char** argv )
{
    ParseCmdLine (argc,argv);
    PrintSettings(cout);

    if (MODE=='e') Evolution();
    else           Match();
}
Example #9
0
// Main function
void MainFunction(char *cmd)
{
	char tmp[MAX_SIZE];
	bool first = true;
	bool exit_now = false;

	while (true)
	{
		if (first && StrLen(cmd) != 0 && g_memcheck == false)
		{
			first = false;
			StrCpy(tmp, sizeof(tmp), cmd);
			exit_now = true;
			Print("%s\n", cmd);
		}
		else
		{
			_exit(0);
		}
		Trim(tmp);
		if (StrLen(tmp) != 0)
		{
			UINT i, num;
			bool b = false;
			TOKEN_LIST *token = ParseCmdLine(tmp);
			char *cmd = token->Token[0];

			num = sizeof(test_list) / sizeof(TEST_LIST);
			for (i = 0;i < num;i++)
			{
				if (!StrCmpi(test_list[i].command_str, cmd))
				{
					char **arg = Malloc(sizeof(char *) * (token->NumTokens - 1));
					UINT j;
					for (j = 0;j < token->NumTokens - 1;j++)
					{
						arg[j] = CopyStr(token->Token[j + 1]);
					}
					test_list[i].proc(token->NumTokens - 1, arg);
					for (j = 0;j < token->NumTokens - 1;j++)
					{
						Free(arg[j]);
					}
					Free(arg);
					b = true;
					_exit(1);
					break;
				}
			}
			FreeToken(token);

			if (exit_now)
			{
				break;
			}
		}
	}
}
Example #10
0
/*>int main(int argc, char **argv)
   -------------------------------
   Main program for submitting jobs to a farm

   14.09.00 Original   By: ACRM
*/
int main(int argc, char **argv)
{
   uid_t uid;
   gid_t gid;
   char  jobfile[PATH_MAX],
         *env;
   BOOL  doDelete = FALSE,
         quiet = FALSE;
   int   status,
         cluster = 0,
         nice    = 10,
         port    = 0;
   ULONG jobnum;
   char  spoolDir[PATH_MAX],
         lockhost[MAXBUFF];
   
   /* Get the default spool directory from the environment variable if
      this has been set
   */
   if((env=getenv("QLSPOOLDIR"))!=NULL)
      strcpy(spoolDir, env);
   else
      strcpy(spoolDir, DEF_SPOOLDIR);

   /* Get the default cluster from the environment variable if this has 
      been set
   */
   if((env=getenv("QLCLUSTER"))!=NULL)
      sscanf(env,"%d", &cluster);

   if(ParseCmdLine(argc, argv, jobfile, &doDelete, spoolDir, &quiet,
                   &cluster, &nice, lockhost, &port))
   {
      CreateFullPath(jobfile);
      if(cluster!=0)
         UpdateSpoolDir(spoolDir, cluster);
      
      if(!CheckForSpoolDir(spoolDir))
      {
         fprintf(stderr,"Spool directory, %s, does not exist!\n",
                 spoolDir);
         return(1);
      }

      /* If either the port of host has not been specified get the values
         from a file
      */
      if((port==0) || (!lockhost[0]))
      {
         GetPortAndLockHost(spoolDir, &port, lockhost);
         if(!lockhost[0])
         {
            fprintf(stderr,"You must specify a host running the \
qllockd locking daemon\n");
            fprintf(stderr,"   Either use the .qllockdaemon file in \
the spool directory or the -l flag\n");
            return(1);
         }
Example #11
0
int TesterMain()
{
    RedirectIOToConsole();

    WCHAR *cmdLine = GetCommandLine();

    WStrVec argv;
    ParseCmdLine(cmdLine, argv);

    InitAllCommonControls();
    ScopedGdiPlus gdi;
    mui::Initialize();

    WCHAR *dirOrFile = NULL;

    bool mobiTest = false;
    size_t i = 2; // skip program name and "/tester"
    while (i < argv.Count()) {
        if (str::Eq(argv[i], L"-mobi")) {
            ++i;
            if (i == argv.Count())
                return Usage();
            mobiTest = true;
            dirOrFile = argv[i];
            ++i;
        } else if (str::Eq(argv[i], L"-layout")) {
            gLayout = true;
            ++i;
        } else if (str::Eq(argv[i], L"-save-html")) {
            gSaveHtml = true;
            ++i;
        } else if (str::Eq(argv[i], L"-save-images")) {
            gSaveImages = true;
            ++i;
        } else if (str::Eq(argv[i], L"-zip-create")) {
            ZipCreateTest();
            ++i;
        } else if (str::Eq(argv[i], L"-bench-md5")) {
            BenchMD5();
            ++i;
        } else {
            // unknown argument
            return Usage();
        }
    }
    if (2 == i) {
        // no arguments
        return Usage();
    }

    if (mobiTest) {
        MobiTest(dirOrFile);
    }

    mui::Destroy();
    system("pause");
    return 0;
}
Example #12
0
int Chkdraft::Run(LPSTR lpCmdLine, int nCmdShow)
{
    if ( !CreateThis() )
        return 1;

    scData.Load();
    InitCommonControls();
    ShowWindow(getHandle(), nCmdShow);
    UpdateWindow();
    ParseCmdLine(lpCmdLine);
    GuiMap::SetAutoBackup(true);
    this->OnLoadTest();

    MSG msg = {};
    bool keepRunning = true;
    do
    {
        while ( ::PeekMessage(&msg, NULL, 0, 0, PM_REMOVE) != 0 )
        {
            if ( msg.message == WM_QUIT )
                keepRunning = false;
            else
            {
                bool isDlgKey = DlgKeyListener(msg.hwnd, msg.message, msg.wParam, msg.lParam);
                if ( ::IsDialogMessage(currDialog, &msg) == FALSE )
                {
                    ::TranslateMessage(&msg);
                    if ( !isDlgKey )
                        KeyListener(msg.hwnd, msg.message, msg.wParam, msg.lParam);
                    ::DispatchMessage(&msg);
                }
            }
        }

        if ( CM != nullptr && ColorCycler::CycleColors(CM->getTileset()) )
            CM->Redraw(false);

        std::this_thread::sleep_for(std::chrono::milliseconds(1)); // Avoid consuming a core

    } while ( keepRunning );

    /*MSG msg;
    while ( GetMessage(&msg, NULL, 0, 0) > 0 )
    {
        bool isDlgKey = DlgKeyListener(msg.hwnd, msg.message, msg.wParam, msg.lParam);
        if ( IsDialogMessage(currDialog, &msg) == FALSE &&
             TranslateMDISysAccel(maps.getHandle(), &msg) == FALSE )
        {
            TranslateMessage(&msg);
            if ( !isDlgKey )
                KeyListener(msg.hwnd, msg.message, msg.wParam, msg.lParam);
            DispatchMessage(&msg);
        }
    }*/
    return msg.wParam;
}
Example #13
0
/*>int main(int argc, char **argv)
   -------------------------------
   Input:     
   Output:    
   Returns:   

   Main program for the qlrun daemon

   15.09.00 Original  By: ACRM
*/
int main(int argc, char **argv)
{
   char spoolDir[PATH_MAX],
        *env;
   BOOL resume = FALSE;
   

   /* Get the default spool directory from the environment variable if
      this has been set
   */
   if((env=getenv("QLSPOOLDIR"))!=NULL)
      strcpy(spoolDir, env);
   else
      strcpy(spoolDir, DEF_SPOOLDIR);

   if(ParseCmdLine(argc, argv, spoolDir, &resume))
   {
#ifdef ROOT_ONLY
      if(!RootUser())
      {
         fprintf(stderr,"qlsuspend must be run as root\n");
         return(1);
      }
#endif

      if(!CheckForSpoolDir(spoolDir))
      {
         fprintf(stderr,"Spool directory, %s, does not exist!\n",
                 spoolDir);
         return(1);
      }
         
      if(resume)
      {
         if(!DeleteSuspendFile(spoolDir))
         {
            fprintf(stderr,"Unable to delete suspend file.\n");
            return(1);
         }
      }
      else
      {
         if(!CreateSuspendFile(spoolDir))
         {
            fprintf(stderr,"Unable to create suspend file.\n");
            return(1);
         }
      }
   }
   else
   {
      Usage();
   }
   return(0);
}
Example #14
0
/**
 * @brief Initializes the SpringApp instance
 * @return whether initialization was successful
 */
bool SpringApp::Initialize ()
{
    if (!ParseCmdLine ())
        return false;

#ifdef WIN32
    // Initialize crash reporting
    Install( (LPGETLOGFILE) crashCallback, "*****@*****.**", "TA Spring Crashreport");
#endif

    // Initialize class system
    creg::ClassBinder::InitializeClasses ();

#ifndef NO_LUA
    // Initialize lua bindings
    CLuaBinder lua;
    if (!lua.LoadScript("testscript.lua"))
        handleerror(NULL, lua.lastError.c_str(), "lua",MBF_OK|MBF_EXCL);
#endif

    InitVFS ();

    if (!InitWindow ("RtsSpring"))
    {
        SDL_Quit ();
        return false;
    }
    // Global structures
    ENTER_SYNCED;
    gs=new CGlobalSyncedStuff();
    ENTER_UNSYNCED;
    gu=new CGlobalUnsyncedStuff();

    InitOpenGL();

    palette.Init();

    // Initialize keyboard
    SDL_EnableUNICODE(1);
    SDL_EnableKeyRepeat (SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
    SDL_SetModState (KMOD_NONE);

    keys = new Uint8[SDLK_LAST];
    memset (keys,0,sizeof(Uint8)*SDLK_LAST);

    // Initialize font
    font = new CglFont(32,223);
    LoadExtensions();
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    SDL_GL_SwapBuffers();

    CreateGameSetup ();

    return true;
}
Example #15
0
int main(int argc, char **argv)
{
    PIN_Init(argc, argv);
    if (!ParseCmdLine(argc, argv))
        return 1;

    PIN_AddSignalInterceptFunction(Signal, HandleSig, 0);

    PIN_StartProgram();
    return 0;
}
Example #16
0
File: main.cpp Project: dquam/Bak3d
 CmdLineArgs ()
 {
   // Save local copy of the command line string, because
   // ParseCmdLine() modifies this string while parsing it.
   PSZ cmdline = GetCommandLineA();
   m_cmdline = new char [strlen (cmdline) + 1];
   if (m_cmdline)
   {
     strcpy (m_cmdline, cmdline);
     ParseCmdLine();
   }
 }
Example #17
0
int main(int argc, char **argv)
{
    PIN_Init(argc, argv);
    if (!ParseCmdLine(argc, argv))
        return 1;

    PIN_InterceptSignal(Signal, HandleSig, 0);
    PIN_UnblockSignal(Signal, TRUE);

    PIN_StartProgram();
    return 0;
}
Example #18
0
/**
 * Initializes SpringApp variables
 *
 * @param argc argument count
 * @param argv array of argument strings
 */
SpringApp::SpringApp(int argc, char** argv): cmdline(new CmdLineParams(argc, argv))
{
	// initializes configHandler which we need
	ParseCmdLine(argv[0]);

	spring_clock::PushTickRate(configHandler->GetBool("UseHighResTimer") || cmdline->IsSet("useHighResTimer"));
	// set the Spring "epoch" to be whatever value the first
	// call to gettime() returns, should not be 0 (can safely
	// be done before SDL_Init, we are not using SDL_GetTicks
	// as our clock anymore)
	spring_time::setstarttime(spring_time::gettime(true));
}
Example #19
0
static  bool    ProcCmd( char *buffer ) {
//=======================================

    char        *opt_array[MAX_OPTIONS+1];

    RetCode = _BADCMDLINE;
    if( ParseCmdLine( &SrcName, &CmdPtr, opt_array, buffer ) != FALSE ) {
        RetCode = ProcName();
        if( RetCode == _SUCCESSFUL ) {
            ProcOpts( opt_array );
        }
    }
    return( RetCode == _SUCCESSFUL );
}
Example #20
0
/*>int main(int argc, char **argv)
   -------------------------------
*//**


-  27.07.12 Original   By: ACRM
-  22.07.14 Renamed deprecated functions with bl prefix. By: CTP
-  07.11.14 Initialized closest
-  12.03.15 Changed to allow multi-character chain names
*/
int main(int argc, char **argv)
{
   FILE *in  = stdin,
        *out = stdout;
   char infile[MAXBUFF],
        outfile[MAXBUFF];
   PDB  *pdb;
   int  natoms;
   
   if(ParseCmdLine(argc, argv, infile, outfile))
   {
      if(blOpenStdFiles(infile, outfile, &in, &out))
      {
         if((pdb = blReadPDB(in,&natoms)) != NULL)
         {
            VEC3F cg;
            PDB   *p, *closest = NULL;
            REAL  bestDistSq = 99999.0,
                  dist;
            
            blGetCofGPDB(pdb, &cg);
            for(p=pdb; p!=NULL; NEXT(p))
            {
               if(!strncmp(p->atnam, "CA  ",4))
               {
                  dist = DISTSQ(p, (&cg));
                  if(dist < bestDistSq)
                  {
                     bestDistSq = dist;
                     closest = p;
                  }
               }
            }
            fprintf(out, "%s%d%c\n", 
                    closest->chain, closest->resnum, closest->insert[0]);
         }
         else
         {
            fprintf(stderr,"No atoms read from PDB file\n");
         }
      }
   }
   else
   {
      Usage();
   }

   return(0);
}
Example #21
0
int wmain(int _Argc, wchar_t ** _Argv)
{
	setlocale(LC_ALL, "chs");

	if (_Argc < 2)
		PringUsage();
	
	UPDATE_INFO UpdateInfo = {};
	if (!ParseCmdLine(_Argc, _Argv, UpdateInfo))
	{
		printf("Parse CmdLine failure\n");
		exit(-1);
	}
	
	bool bChangeFileVer = lstrlen(UpdateInfo.szFileVersion) > 0, 
		bChangeProductionVer = lstrlen(UpdateInfo.szProduction) > 0;
	
	CPEResInfo PEInfo;
	PEInfo.Open(UpdateInfo.szPath);
	

	DWORD FileVerNums[4] = {}, ProVerNums[4] = {};
	if (bChangeFileVer)
	{
		VerStringToInt(UpdateInfo.szFileVersion, FileVerNums);
	}
	else
	{
		CPEResInfo::GetFileVersion(UpdateInfo.szPath, &FileVerNums[0], &FileVerNums[1], &FileVerNums[2], &FileVerNums[3]);
		FileVerNums[3] += 1;
	}
	
	if (bChangeProductionVer)
	{
		VerStringToInt(UpdateInfo.szProduction, ProVerNums);
	}
	else
	{
		CPEResInfo::GetFileVersion(UpdateInfo.szPath, &ProVerNums[0], &ProVerNums[1], &ProVerNums[2], &ProVerNums[3]);
		ProVerNums[3] += 1;
	}

	bool bret = PEInfo.UpdateResVersion(FileVerNums, ProVerNums);
	PEInfo.Close(TRUE);
	printf("update version %s\n", bret ? "succ" : "failure");

	return bret ? 0 : -1;
}
Example #22
0
void main(int argc, char * argv[])
{

   puts("TLog;  Creates log file from ToneLoc Data file      V1.0");
   puts("       by Minor Threat and Mucho Maas\n");

   if (strchr(argv[1],'?')) helpscreen();
   if (argc < 4) badparms();

   printf("\nPrefix (NXX) : ");
   gets(nxx);

   ParseCmdLine(argc, argv);
   mainloop();

}
Example #23
0
void CTelnetServerSession::OnReceive(int nErrorCode)
{
   ASSERT_VALID(this);
   CSocket::OnReceive(nErrorCode);

   TRY
   {
      char sz[100];
      while (m_bContinue)
      {
         const int dwRead = m_pFile->Read(sz, _countof(sz));
         for (int i = 0; i < dwRead; i++)
         {
            switch (sz[i])
            {
               case '\x8':
                  if (!m_cmdline.IsEmpty())
                  {
                     if (m_bEcho) Send("\x8 \x8");
                     m_cmdline = m_cmdline.Left(m_cmdline.GetLength() - 1);
                  }
                  break;
               case '\n':
                  break;
               case '\r':
                  if (m_bEcho) Send("\r\n");
                  ParseCmdLine();
                  if (m_bContinue) Send(GetPromptString());
                  m_cmdline.Empty();
                  break;
               default:
                  if (m_bEcho) Send(sz[i]);
                  m_cmdline+=sz[i];
                  break;
            }
         }
         if (_countof(sz) != dwRead)
         {
            break;
         }
      }
   }
	CATCH(CFileException, e)
	{
      ASSERT(FALSE); 
	}
Example #24
0
int main(int argc, char ** argv) {
    pridil::WorldInfo wInfo;
    DisplayOptions dOptions;

    //  Get command line and config file options

    try {
        if ( !ParseCmdLine(argc, argv, wInfo, dOptions) ) {
            return 0;
        }
    } catch(...) {
        return 1;
    }

    try {

        //  Initialize and run world.

        pridil::World world(wInfo);
        for ( int i = 0; i < wInfo.m_days_to_run; ++i ) {
            world.advance_day();
        }


        //  Output statistics

        world.output_world_stats(std::cout);
        if ( dOptions.m_detailed_memories ) {
            world.output_full_creature_stats(std::cout);
        }
        if ( dOptions.m_summary_creatures ) {
            world.output_summary_creature_stats(std::cout);
        }
        if ( dOptions.m_summary_resources ) {
            world.output_summary_resources_by_strategy(std::cout);
            world.output_summary_dead_by_strategy(std::cout);
        }
    } catch(pridil::PridilException& e) {
        std::cerr << e.what() << std::endl;
        return 1;
    } catch(...) {
        return 1;
    }
    return 0;
}
Example #25
0
int PASCAL WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
            LPSTR lpszCmdLine, int nCmdShow)
//----------------------------------------------------------------
{
 
 #ifdef COMMCTRL
 InitCommonControls();
 #endif

 hInst = hInstance;
 CmdShow = nCmdShow;

 n_args = ParseCmdLine(lpszCmdLine, args);

 if (! hPrevInstance) RegisterEventWindow();

 return SMain(n_args,args);
}
Example #26
0
//------------------------------------------------------------  ExperimentSetup()
//
void ExperimentSetup(int argc, char **argv){
	Uint8 i=0,j=0;

	// Parsea la linea de comandos y el archivo de configuracion: 	auxfuncs.c
	ParseCmdLine(argc, argv);

	//Inicializamos la tableta con la función handler				libwacom.a
	WacomInit(WACOM_SCANMODE_NOCALLBACK, NULL);

	//Crea la mascara de eventos y escondemos cursor
	ExperimentEventMask();
	SDL_ShowCursor(FALSE);

	//Inicializamos la semilla del generador de numeros aleatorios
	srand(time(0));

	//Initialize Configurations array
	for(i=ID_MIN;i<ID_MAX;i+=ID_STEP){
		g_TrialConfig[j].ID0 = i;
		g_TrialConfig[j].IDf = i+ID_STEP;
		//g_TrialConfig[j].initSide = (rand()/((double)RAND_MAX + 1) > 0.5) ? 'L' : 'R';
		g_TrialConfig[j].replications = TRIAL_REPLICATIONS;
		j++;
	}
	for(i=ID_MAX;i>ID_MIN;i-=ID_STEP){
		g_TrialConfig[j].ID0 = i;
		g_TrialConfig[j].IDf = i-ID_STEP;
		//g_TrialConfig[j].initSide = (rand()/((double)RAND_MAX + 1) > 0.5) ? 'L' : 'R';
		g_TrialConfig[j].replications = TRIAL_REPLICATIONS;
		j++;
	}

	//Initialize speed and position buffers to zero
	for (i=0;i<SPEED_BUFFER_SIZE;i++) {
		g_SpeedBuffer[i].vx=0;
		g_SpeedBuffer[i].vy=0;
		g_SpeedBuffer[i].t=0;
	}
	for (i=0;i<POSITION_BUFFER_SIZE;i++){
		g_PositionBuffer[i].x=0;
		g_PositionBuffer[i].y=0;
		g_PositionBuffer[i].t=0;
	}
}
Example #27
0
int __cdecl main(int argc, const char *argv[])
{
	if ( ParseCmdLine (argc, argv) == false )
	{
		usage();
		return 0;
	}

	if ( CheckParameters () == false ) {
		return 0;
	}

	// init DebugPlot library
	DebugPlotInit();

	InitializeTimestampInfo ( &tsinfo, true );
	
	// begin receive or transmit packets
	if (!SoraUInitUserExtension("\\\\.\\HWTest")) {
		printf ( "Error: fail to find the hwtest driver!\n" );
		getchar();
		return -1;
	}

	if ( bWarning ) {
		printf ( "Warnings - press enter to continue...\n" );
		getchar();
	}	
	
	// clear screen	
	system( "cls" );	
	
	// Start the main procedure
	Dot11_main ();

	// clear screen
	// system( "cls" );	
	
	SoraUCleanUserExtension();
	DebugPlotDeinit();

    return 0;
}
Example #28
0
/*>int main(int argc, char **argv)
   -------------------------------
   Main program for scoring variability on the basis of a mutation matrix
   across a sequence alignment stored in a PDB file.

   11.09.96 Original   By: ACRM
   17.09.96 Rewritten. Zeros the MDM
   18.09.96 Added check on environment variable if ReadMDM() failed.
   15.07.08 Added -x/Extended handling
*/
int main(int argc, char **argv)
{
   FILE *in  = stdin,
        *out = stdout;
   char InFile[MAXBUFF],
        OutFile[MAXBUFF],
        matrix[MAXBUFF];
   int  MaxInMatrix,
        Method = METH_MDM;
   BOOL Extended = FALSE;
   
   if(ParseCmdLine(argc, argv, InFile, OutFile, matrix, &Method,
                   &Extended))
   {
      if(blOpenStdFiles(InFile, OutFile, &in, &out))
      {
         if(!blReadMDM(MUTMAT))
         {
            fprintf(stderr,"Unable to read mutation matrix: %s\n",MUTMAT);
            if(getenv(DATADIR) == NULL)
            {
               fprintf(stderr,"Environment variable (%s) not set.\n",
                       DATADIR);
            }
            return(1);
         }
         MaxInMatrix = blZeroMDM();
         return(ReadAndScoreSeqs(in, out, MaxInMatrix, Method,
                                 Extended)?0:1);
      }
      else
      {
         return(1);
      }
   }
   else
   {
      Usage();
   }
   return(0);
}
Example #29
0
/*>int main(int argc, char **argv)
   -------------------------------
*//** 
   Main program for finding disulphides

-  20.07.15 Original   By: ACRM
*/
int main(int argc, char **argv)
{
   FILE     *in     = stdin,
            *out    = stdout;
   int      natoms;
   PDB      *pdb;
   char     infile[MAXBUFF],
            outfile[MAXBUFF];
   
   if(!ParseCmdLine(argc, argv, infile, outfile))
   {
      Usage();
      return(0);
   }

   if(!blOpenStdFiles(infile, outfile, &in, &out))
   {
      fprintf(stderr, "Error (pdblistss): Unable to open input or output \
file\n");
      return(1);
   }
Example #30
0
// verify that all registry entries that need to be set in order to associate
// Sumatra with .pdf files exist and have the right values
bool IsExeAssociatedWithPdfExtension()
{
    // this one doesn't have to exist but if it does, it must be APP_NAME_STR
    ScopedMem<WCHAR> tmp(ReadRegStr(HKEY_CURRENT_USER, REG_EXPLORER_PDF_EXT, L"Progid"));
    if (tmp && !str::Eq(tmp, APP_NAME_STR))
        return false;

    // this one doesn't have to exist but if it does, it must be APP_NAME_STR.exe
    tmp.Set(ReadRegStr(HKEY_CURRENT_USER, REG_EXPLORER_PDF_EXT, L"Application"));
    if (tmp && !str::EqI(tmp, APP_NAME_STR L".exe"))
        return false;

    // this one doesn't have to exist but if it does, it must be APP_NAME_STR
    tmp.Set(ReadRegStr(HKEY_CURRENT_USER, REG_EXPLORER_PDF_EXT L"\\UserChoice", L"Progid"));
    if (tmp && !str::Eq(tmp, APP_NAME_STR))
        return false;

    // HKEY_CLASSES_ROOT\.pdf default key must exist and be equal to APP_NAME_STR
    tmp.Set(ReadRegStr(HKEY_CLASSES_ROOT, L".pdf", NULL));
    if (!str::Eq(tmp, APP_NAME_STR))
        return false;

    // HKEY_CLASSES_ROOT\SumatraPDF\shell\open default key must be: open
    tmp.Set(ReadRegStr(HKEY_CLASSES_ROOT, APP_NAME_STR L"\\shell", NULL));
    if (!str::EqI(tmp, L"open"))
        return false;

    // HKEY_CLASSES_ROOT\SumatraPDF\shell\open\command default key must be: "${exe_path}" "%1"
    tmp.Set(ReadRegStr(HKEY_CLASSES_ROOT, APP_NAME_STR L"\\shell\\open\\command", NULL));
    if (!tmp)
        return false;

    WStrVec argList;
    ParseCmdLine(tmp, argList);
    ScopedMem<WCHAR> exePath(GetExePath());
    if (!exePath || !argList.Contains(L"%1") || !str::Find(tmp, L"\"%1\""))
        return false;

    return path::IsSame(exePath, argList.At(0));
}