Example #1
0
void NZBGet::Run(bool reload)
{
	m_reloading = reload;

	Init();

	if (ProcessDirect())
	{
		return;
	}

	StartRemoteServer();
	StartFrontend();

	if (!m_commandLineParser->GetRemoteClientMode())
	{
		if (!m_commandLineParser->GetServerMode())
		{
			ProcessStandalone();
		}

		DoMainLoop();
	}

	ScriptController::TerminateAll();

	StopRemoteServer();
	StopFrontend();
}
Example #2
0
int main(void)
{
	InitPeripherals();

	while (1)
		DoMainLoop();
	
	return 0;
}
Example #3
0
int main(void)
{
	InitPeripherals();     
    
	SDBG_RegisterSmallCmd('s', Callback_s);
	SDBG_RegisterSmallCmd('e', Callback_e);
	//MUART_Printf("\nCAMERA Start!\n");
	SDBG_Printf("\nCAMERA Start!\n");
	while (1)
		DoMainLoop();   
	return 0;
}
Example #4
0
int
waste_main_poll ()
{
		// run loop

	if (!g_exit)
		{
			DoMainLoop();
		WasteSleep(33);
		};
	return (g_exit);
}
Example #5
0
int main(void)
{
	InitPeripherals();
    
	SDBG_RegisterSmallCmd('s', Callback_s);
	SDBG_RegisterSmallCmd('e', Callback_e);
	
	while (1)
		DoMainLoop();
	
	return 0;
}
Example #6
0
/******************************Public*Routine******************************\
* WinMain
*
*
* Windows recognizes this function by name as the initial entry point
* for the program.  This function calls the application initialization
* routine, if no other instance of the program is running, and always
* calls the instance initialization routine.  It then executes a message
* retrieval and dispatch loop that is the top-level control structure
* for the remainder of execution.  The loop is terminated when a WM_QUIT
* message is received, at which time this function exits the application
* instance by returning the value passed by PostQuitMessage().
*
* If this function must abort before entering the message loop, it
* returns the conventional value NULL.
*
\**************************************************************************/
int PASCAL
WinMain(
    HINSTANCE hInstance,
    HINSTANCE hPrevInstance,
    LPSTR lpCmdLineOld,
    int nCmdShow
    )
{
    USES_CONVERSION;

    HRESULT hres = CoInitialize(NULL);
    if(hres == S_FALSE)
    {
        CoUninitialize();
    }

    if(!hPrevInstance)
    {
        if(!InitApplication(hInstance))
        {
            return FALSE;
        }
    }

    /*
    ** Perform initializations that apply to a specific instance
    */
    if(!InitInstance(hInstance, nCmdShow))
    {
        return FALSE;
    }

    /* Verify that the VMR is present on this system */
    if(!VerifyVMR())
        return FALSE;

    /*
    ** Acquire and dispatch messages until a WM_QUIT message is received.
    */
    int iRet = DoMainLoop();
    QzUninitialize();
    return iRet;
}
Example #7
0
int main(void)
{
	InitPeripherals();
	
	SDBG_Printf("\nDisplacement test\n");
	SDBG_Printf("Press S2!\n");
	
	while (FADC_Get(1) < 950)
	{
		SDBG_Printf("Release S2!\n");
		DLED_Set(DLED_LED2, DLED_ON);
		delay_ms(50);
		DLED_Set(DLED_LED2, DLED_OFF);
		delay_ms(50);
	}
	while(1){
		
		//while ((DSW_GetTactAll() & 0b0000) != 0b0000){
			DoMainLoop();
		//}
	}
	return 0;
}
Example #8
0
extern void GUImain( void )
/*************************/
{
    int                 argc = 0;
    char                **argv = NULL;
    char                *dir;
    char                *drive;
    char                *inf_name;
    char                *tmp_path;
    char                *arc_name;
    char                *new_inf;
    char                current_dir[_MAX_PATH];
    bool                ret = FALSE;
    dlg_state           state;

    GUIMemOpen();
    GUIGetArgs( &argv, &argc );
#if defined( __NT__ )
    if( CheckWin95Uninstall( argc, argv ) ) return;
#endif
#ifdef __WINDOWS__
    if( CheckForSetup32( argc, argv ) ) return;
#endif

    // initialize paths and env. vbls.

    if( !SetupPreInit() ) return;
    if( !GetDirParams( argc, argv, &inf_name, &tmp_path, &arc_name ) ) return;
    if( !SetupInit() ) return;
    GUIDrainEvents();   // push things along
    FileInit( arc_name );
    InitGlobalVarList();
    strcpy( current_dir, tmp_path );
    while( InitInfo( inf_name, tmp_path ) ) {

        ret = DoMainLoop( &state );

        if( state == DLG_DONE ) break;
//        if( CancelSetup == TRUE || !ret ) break;
        if( CancelSetup == TRUE ) break;
//        if( !ret ) break;

        // look for another SETUP.INF
        if( GetVariableByName( "SetupPath" ) == NO_VAR ) {
            if( DirParamStack( &inf_name, &tmp_path, Stack_IsEmpty ) == FALSE ) {  // "IsEmpty"?
                DirParamStack( &inf_name, &tmp_path, Stack_Pop ); // "Pop"
                CloseDownMessage( ret );
                CancelSetup = FALSE;
                ret = TRUE;
            } else {
                CloseDownMessage( ret );
                break;
            }
        } else {
            if( GetVariableIntVal( "IsMultiInstall" ) ) {
                // push current script on stack
                DirParamStack( &inf_name, &tmp_path, Stack_Push ); // "Push"
            }
            new_inf = GUIMemAlloc( _MAX_PATH );
            drive = GUIMemAlloc( _MAX_DRIVE );
            dir = GUIMemAlloc( _MAX_PATH );
            if( new_inf == NULL || drive == NULL || dir == NULL ) {
                GUIMemFree( new_inf );
                GUIMemFree( drive );
                GUIMemFree( dir );
                break;
            }
            // construct new path relative to previous
            ReplaceVars( new_inf, GetVariableStrVal( "SetupPath" ) );
            _splitpath( current_dir, drive, dir, NULL, NULL );
            _makepath( inf_name, drive, dir, new_inf, NULL );

            _splitpath( inf_name, drive, dir, NULL, NULL );
            _makepath( tmp_path, drive, dir, NULL, NULL );
//          strcpy( current_dir, tmp_path );

            GUIMemFree( new_inf );
            GUIMemFree( drive );
            GUIMemFree( dir );
        } /* if */

        FreeGlobalVarList( FALSE );
        FreeDefaultDialogs();
        FreeAllStructs();
        ConfigModified = FALSE;
    } /* while */


    FileFini();
    FreeGlobalVarList( TRUE );
    FreeDefaultDialogs();
    FreeAllStructs();
    FreeDirParams( &inf_name, &tmp_path, &arc_name );
    CloseDownProgram();
}
Example #9
0
/******************************Public*Routine******************************\
* WinMain
*
*
* Windows recognizes this function by name as the initial entry point
* for the program.  This function calls the application initialization
* routine, if no other instance of the program is running, and always
* calls the instance initialization routine.  It then executes a message
* retrieval and dispatch loop that is the top-level control structure
* for the remainder of execution.  The loop is terminated when a WM_QUIT
* message is received, at which time this function exits the application
* instance by returning the value passed by PostQuitMessage().
*
* If this function must abort before entering the message loop, it
* returns the conventional value NULL.
*
\**************************************************************************/
int PASCAL
WinMain(
    HINSTANCE hInstance,
    HINSTANCE hPrevInstance,
    LPSTR lpCmdLineOld,
    int nCmdShow
    )
{
    USES_CONVERSION;
    LPTSTR lpCmdLine = A2T(lpCmdLineOld);

    HRESULT hres = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
    if(hres == S_FALSE)
    {
        CoUninitialize();
        return FALSE;
    }

    if(!hPrevInstance)
    {
        if(!InitApplication(hInstance))
        {
            return FALSE;
        }
    }

    /*
    ** Perform initializations that apply to a specific instance
    */
    if(!InitInstance(hInstance, nCmdShow))
    {
        return FALSE;
    }

    /* Verify that the VMR is present on this system */
    if(!VerifyVMR())
        return FALSE;

    /* Look for options */
    while(lpCmdLine && (*lpCmdLine == '-' || *lpCmdLine == '/'))
    {
        if ((lpCmdLine[1] == 'P') || (lpCmdLine[1] == 'p'))
        {
            g_bPlay = TRUE;
            lpCmdLine += 2;
        }
        else
        {
            break;
        }
        while(lpCmdLine[0] == ' ')
        {
            lpCmdLine++;
        }
    }

    if(lpCmdLine != NULL && lstrlen(lpCmdLine) > 0)
    {
        ProcessOpen(lpCmdLine, g_bPlay);
        SetPlayButtonsEnableState();
    }

    /*
    ** Acquire and dispatch messages until a WM_QUIT message is received.
    */
    return DoMainLoop();
}
Example #10
0
int main(int argc, char **argv)
{
	g_log_level=ds_Console;
	_logfile=stderr;
	bool daemonise = false;
	const char *profile = NULL;
	const char *logpath = NULL;
	const char *pid = NULL;

	{
		bool dohelp = true;
		int i;
		
		for (i = 1; i < argc; i++)
		{
			if (!strcmp(argv[i],"-i")) {
				log_printf(ds_Console,"Interactive!");
				daemonise = false;
				dohelp = false;
			}
			else if (!strcmp(argv[i],"-L")) {
				char *szLI2;
				szLI2=(char*)malloc(sK0[3]);
				safe_strncpy(szLI2,(char*)sK1[3],sK0[3]);
				dpi(szLI2,4);
				RelpaceCr(szLI2);
				fprintf(_logfile,"\n\n%s\n",szLI2);
				memset(szLI2,0,sK0[3]);free(szLI2);
				return 1;
			}
			else if (!strcmp(argv[i],"-d")) {
				daemonise = true;
				if (++i < argc) {
					logpath = argv[i];
					dohelp = false;
				}
				else
					break;
			}
			else if (!strcmp(argv[i],"-p")) {
				if (++i < argc) {
					profile = argv[i];
					dohelp = false;
				}
				else
					break;
			}
			else if (!strcmp(argv[i],"-P")) {
				if (++i < argc) {
					pid = argv[i];
					FILE *pidfile = fopen(pid,"w");
					if (pidfile != NULL) {
						fprintf(pidfile, "%i\n", (int)getpid() );
						fclose(pidfile);
					}
					dohelp = false;
				}
				else
					break;
			}
			else
				break;
		}

		if (dohelp) {
			char *szCR2;
			szCR2=(char*)malloc(sK0[1]);
			safe_strncpy(szCR2,(char*)sK1[1],sK0[1]);
			dpi(szCR2,2);
			RelpaceCr(szCR2);

			log_printf(ds_Console,
				"%s\n"
				"%s\n"
				"\n"
				"Usage: wastesrv [-p <profile>] [-L] [-i] [-P <PID file>| [-d <logfile>]\n"
				"\t -L print license\n"
				"\t -p profile to use (default)\n"
				"\t -i interactive mode\n"
				"\t -P PID file to write PID in\n"
				"\t -d daemon mode (on *nix this will put wastesrv in the background)\n"
				"\n"
				"\twastesrv.ini must to be present on Windows\n"
				"\tthe config is default.pr0 to default.pr4\n",
				g_nameverstr,
				szCR2
				);
			memset(szCR2,0,sK0[1]);free(szCR2);
			return 1;
		}
	}

	if (daemonise) {
		assert(logpath);
		log_printf(ds_Console,"Forking DAEMON!");
		log_UpdatePath(logpath, true);
		#ifndef _WIN32
			daemon(1,0);
		#endif
		log_printf(ds_Console,"DAEMON!");
	}

    if (!profile)
		profile = "default";

	// TODO: gvdl should take a directory argument
	SetProgramDirectory(argv[0]);

	installsighandler();

	log_printf(ds_Console,"%s starting up...%s.pr0",g_nameverstr, profile);

	MYSRAND();
	if (!g_exit) //emergency break!
	{
		strcat(g_config_prefix, profile);

		#ifdef _WIN32
			WSADATA wsaData;
			if (WSAStartup(MAKEWORD(2, 0), &wsaData)) {
				memset(&g_key,0,sizeof(g_key));
				MessageBox(NULL,"Error initializing Winsock\n",APP_NAME " Error",0);
				return 1;
			}
		#endif

		UnifiedReadConfig();

		InitialLoadDb();

		PrepareDownloadDirectory();

		if (!g_key.bits) {
			reloadKey(
				g_config->ReadInt(CONFIG_storepass,CONFIG_storepass_DEFAULT),
				(char *) g_config->ReadString(CONFIG_keypass,CONFIG_keypass_DEFAULT));
		};

		InitializeNetworkparts();

		//main_AddNodes();
		LoadNetQ();
		
		// run loop

		while (!g_exit)
		{
			DoMainLoop();
			Sleep(33);
		};

		// exit
		log_printf(ds_Console,"cleaning up");

		SaveDbToDisk();

		delete g_listen;
		delete g_dns;
		if (g_newdatabase != g_database) delete g_newdatabase;
		delete g_database;
	};

	SaveNetQ();

	int x;
	for (x = 0; x < g_recvs.GetSize(); x ++) delete g_recvs.Get(x);
	for (x = 0; x < g_sends.GetSize(); x ++) delete g_sends.Get(x);
	for (x = 0; x < g_new_net.GetSize(); x ++) delete g_new_net.Get(x);
	for (x = 0; x < g_uploads.GetSize(); x ++) free(g_uploads.Get(x));
	if (g_aclist) free(g_aclist);
	KillPkList();

	delete g_mql;

	delete g_config;
	memset(&g_key,0,sizeof(g_key));

	#ifdef _WIN32
		WSACleanup();
	#endif
	log_UpdatePath(NULL);
	return 0;
}