Example #1
0
int main(int argc, char *argv[]) {
    static struct WSAData wsa_state;
    TCHAR *c, stunnel_exe_path[MAX_PATH];

    /* set current working directory and engine path */
    GetModuleFileName(0, stunnel_exe_path, MAX_PATH);
    c=_tcsrchr(stunnel_exe_path, TEXT('\\')); /* last backslash */
    if(c) /* found */
        c[1]=TEXT('\0'); /* truncate program name */
#ifndef _WIN32_WCE
    if(!SetCurrentDirectory(stunnel_exe_path)) {
        /* log to stderr, as s_log() is not initialized */
        _ftprintf(stderr, TEXT("Cannot set directory to %s"),
            stunnel_exe_path);
        return 1;
    }
#endif
    _tputenv_s(TEXT("OPENSSL_ENGINES"), stunnel_exe_path);

    str_init(); /* initialize per-thread string management */
    if(WSAStartup(MAKEWORD(1, 1), &wsa_state))
        return 1;
    resolver_init();
    main_init();
    if(!main_configure(argc>1 ? argv[1] : NULL, argc>2 ? argv[2] : NULL))
        daemon_loop();
    main_cleanup();
    return 0;
}
Example #2
0
int main(void)
{
    main_init();
    while(1) {
        main_step();
    }
}
Example #3
0
void main() {
  main_init();

  // set up interrupts.
  USE_USB_INTS();

  ENABLE_SUDAV();
  ENABLE_USBRESET();
  ENABLE_HISPEED(); 
  ENABLE_SUSPEND();
  ENABLE_RESUME();

  EA = 1;

  // iic files (c2 load) don't need to renumerate/delay
  // trm 3.6
  #ifndef NORENUM
  RENUMERATE();
  #else
  USBCS &= ~bmDISCON;
  #endif
 
 while ( TRUE ) {
  main_loop();

  if (dosud) {
    dosud = FALSE;
    handle_setupdata();
  }

  if (dosuspend) {
    dosuspend = FALSE;
    do {
      WAKEUPCS |= bmWU | bmWU2; // make sure ext wakeups are cleared
      SUSPEND=1;
      PCON |= 1;
      __asm
        nop
        nop
        nop
        nop
        nop
        nop
        nop
      __endasm;
    } while ( !remote_wakeup_allowed && REMOTE_WAKEUP()); 

    // resume
    // trm 6.4
    if ( REMOTE_WAKEUP() ) {
      delay ( 5 );
      USBCS |= bmSIGRESUME;
      delay ( 15 );
      USBCS &= ~bmSIGRESUME;
    }
  }

 } // end while

} // end main
Example #4
0
int main(int argc, char* argv[]) {

    printf("INIT\n");

    main_init();


    fp_log = fopen(file_log, "w");
    setup_termination();

	pthread_mutex_init(&mutex, NULL);


    pthread_attr_t attr_main;
    pthread_attr_init(&attr_main);
	// Main thread
	pthread_create(&thread_main, &attr_main, &tf_main, NULL);
	pthread_create(&thread_pic, &attr_main, &tf_pic2netus, NULL);	

#ifdef JOYSTICK
    pthread_create(&thread_joy, &attr_main, &tf_joy_read, NULL);	
#endif

#ifdef HOKUYO
    pthread_create(&thread_laser, &attr_main, &tf_laser_read, NULL);	
#endif
	
    printf("FD Pic: %d\n", pic_fd);
    printf("FD Xbee Write: %d\n ", xbee_fd_w);
    printf("FD Xbee Read: %d\n ", xbee_fd_r);
    pthread_join(thread_main, NULL);
    return 0;
}
Example #5
0
//------------------------------------------------------------------------------
//     					===== main =====
//------------------------------------------------------------------------------
int main(void)
{
//	unsigned int Dis=0 ;

	main_init();
	
	unsigned char y;

	while(1)
	{   
	/*
	//	Uart_Putch(1,10);
		
		Read_ADC(0);
	//	Uart_U16Bit_PutNum(ADC);
		
		Dis = (( (11.65/((ADC/204.8) - 0.147) ) - 0.42 ) * 10)-4;
		Uart_U16Bit_PutNum(Dis);
		_delay_ms(1000);

		*/
		Read_ADC(2);
		_delay_ms(10);
		
		y = (706.6*pow(ADC, -0.1541))-146;
//	Uart_Putch(0,1);
		Uart_Putch(0,y);
	}



	return 0;
}
Example #6
0
int main(void)
{
  main_init();

#if LIMIT_EVENT_POLLING
  /* Limit main loop frequency to 1kHz.
   * This is a kludge until we can better leverage threads and have real events.
   * Without this limit the event flags will constantly polled as fast as possible,
   * resulting on 100% cpu load on boards with an (RT)OS.
   * On bare metal boards this is not an issue, as you have nothing else running anyway.
   */
  uint32_t t_begin = 0;
  uint32_t t_diff = 0;
  while (1) {
    t_begin = get_sys_time_usec();

    handle_periodic_tasks();
    main_event();

    /* sleep remaining time to limit to 1kHz */
    t_diff = get_sys_time_usec() - t_begin;
    if (t_diff < 1000) {
      sys_time_usleep(1000 - t_diff);
    }
  }
#else
  while (1) {
    handle_periodic_tasks();
    main_event();
  }
#endif

  return 0;
}
Example #7
0
// The main goroutine.
void
runtime_main(void)
{
	// Lock the main goroutine onto this, the main OS thread,
	// during initialization.  Most programs won't care, but a few
	// do require certain calls to be made by the main thread.
	// Those can arrange for main.main to run in the main thread
	// by calling runtime.LockOSThread during initialization
	// to preserve the lock.
	runtime_LockOSThread();
	// From now on, newgoroutines may use non-main threads.
	setmcpumax(runtime_gomaxprocs);
	runtime_sched.init = true;
	scvg = __go_go(runtime_MHeap_Scavenger, nil);
	main_init();
	runtime_sched.init = false;
	if(!runtime_sched.lockmain)
		runtime_UnlockOSThread();

	// For gccgo we have to wait until after main is initialized
	// to enable GC, because initializing main registers the GC
	// roots.
	mstats.enablegc = 1;

	// The deadlock detection has false negatives.
	// Let scvg start up, to eliminate the false negative
	// for the trivial program func main() { select{} }.
	runtime_gosched();

	main_main();
	runtime_exit(0);
	for(;;)
		*(int32*)0 = 0;
}
Example #8
0
int main(int argc, char *argv[])
{
	const struct setting_parser_info *set_roots[] = {
		&doveadm_setting_parser_info,
		NULL
	};
	enum master_service_flags service_flags =
		MASTER_SERVICE_FLAG_KEEP_CONFIG_OPEN;
	const char *error;

	master_service = master_service_init("doveadm", service_flags,
					     &argc, &argv, "");
	if (master_getopt(master_service) > 0)
		return FATAL_DEFAULT;

	if (master_service_settings_read_simple(master_service, set_roots,
						&error) < 0)
		i_fatal("Error reading configuration: %s", error);

	master_service_init_log(master_service, "doveadm: ");
	main_preinit();
	master_service_set_die_callback(master_service, doveadm_die);

	main_init();
	master_service_init_finish(master_service);
	master_service_run(master_service, client_connected);

	main_deinit();
	master_service_deinit(&master_service);
        return 0;
}
Example #9
0
File: win.c Project: hoglet67/b-em
void _mainthread(PVOID pvoid)
{
        HMENU hmenu;
        main_init(argc, argv);

//Carlo Concari: show correct disc protected status at startup
       	hmenu=GetMenu(ghwnd);
        CheckMenuItem(hmenu, IDM_DISC_WPROT_0, (writeprot[0]) ? MF_CHECKED : MF_UNCHECKED);
        CheckMenuItem(hmenu, IDM_DISC_WPROT_1, (writeprot[1]) ? MF_CHECKED : MF_UNCHECKED);

        while (1)
        {
                main_run();
                if (doautoboot)
                {
                        main_reset();
                        disc_close(0);
                        disc_load(0, discfns[0]);
                        if (defaultwriteprot) writeprot[0] = 1;
                        hmenu = GetMenu(ghwnd);
                        CheckMenuItem(hmenu, IDM_DISC_WPROT_0, (writeprot[0]) ? MF_CHECKED : MF_UNCHECKED);
                        autoboot = 150;
                        doautoboot = 0;
                }
        }
}
Example #10
0
int main( int argc, char **argv )
{
    char               *cfg_file;
    char               *module_name;
    module_t           *module;

    __get_args( &cfg_file, &module_name, argc, argv );

    main_init();

    module = module_get( module_name );

    config_init( cfg_file, module->cfg_init_cb );

    logger_init();

    net_init();

    http_init();

    module->init_cb();

    net_main_loop();

    return 0;
}
Example #11
0
int main(void)
{
  uint32_t tTime;


  main_init();

  tTime = millis();
  while(1)
  {
    if( millis()-tTime > 100 )
    {
      tTime = millis();
      led_toggle(0);
    }


#if 0
    uint8_t ch;
    static uint32_t cnt = 0;

    vcp_printf("cnd : %d \r\n", cnt++);


    if( vcp_is_available() )
    {
      ch = vcp_getch();
      vcp_printf("pressed : 0x%02X \r\n", ch);
      //vcp_printf("float test %f\r\n",fvalue);
    }
#else
    msg_process_vcp();
#endif
  }
}
int
main(int argc, char *argv[])
{
    /* Initialize board-specific hardware */
    BSP_Init();
    led1_off();
    led2_off();

#if 1
    /* Initialize TimerA and oscillator */
    BCSCTL3 |= LFXT1S_2;                      // LFXT1 = VLO
    TACCTL0 = CCIE;                           // TACCR0 interrupt enabled
    TACCR0 = 12000;                           // ~1 second
    TACTL = TASSEL_1 + MC_1;                  // ACLK, upmode
#endif

    while (1)
    {
        main_init();

        while (1)
        {
            main_task();
        }
    }

    return 0;
}
int main(int argc, char *argv[]) {

    main_init();

    return 0;

}
Example #14
0
void init(int argc, char* argv[]) {
    {extern void input_init(int, char *[]); input_init(argc, argv);}
    {extern void main_init(int, char *[]); main_init(argc, argv);}
    {extern void prof_init(int, char *[]); prof_init(argc, argv);}
    {extern void trace_init(int, char *[]); trace_init(argc, argv);}
    {extern void type_init(int, char *[]); type_init(argc, argv);}
}
// import most common Eigen types 
USING_PART_OF_NAMESPACE_EIGEN

int main(int, char *argv[]) {
  
  entry_counter = 0;
  printf("==============================\nRunning libeknav from File...\n==============================\n");
  
  int raw_log_fd = open(argv[1], O_RDONLY); 
  
  if (raw_log_fd == -1) {
    perror("opening log\n");
    return -1;
  }
  
  printf("Initialisation...\n");
  struct raw_log_entry e = first_entry_after_initialisation(raw_log_fd);
  printf("Starting at t = %5.2f s\n", e.time);
  printf("entry counter: %i\n", entry_counter);
  main_init();
  printf("Running filter from file...\n");
  main_run_from_file(raw_log_fd, e);
  
  printf("Finished\n");
  return 0;

}
Example #16
0
// The main goroutine.
void
runtime_main(void)
{
	// Lock the main goroutine onto this, the main OS thread,
	// during initialization.  Most programs won't care, but a few
	// do require certain calls to be made by the main thread.
	// Those can arrange for main.main to run in the main thread
	// by calling runtime.LockOSThread during initialization
	// to preserve the lock.
	runtime_LockOSThread();
	runtime_sched.init = true;
	main_init();
	runtime_sched.init = false;
	if(!runtime_sched.lockmain)
		runtime_UnlockOSThread();

	// For gccgo we have to wait until after main is initialized
	// to enable GC, because initializing main registers the GC
	// roots.
	mstats.enablegc = 1;

	main_main();
	runtime_exit(0);
	for(;;)
		*(int32*)0 = 0;
}
Example #17
0
int main(int argc, char *argv[])
{
	const struct setting_parser_info *set_roots[] = {
		&dict_setting_parser_info,
		NULL
	};
	const char *error;

	master_service = master_service_init("dict", 0, &argc, &argv, NULL);
	if (master_getopt(master_service) > 0)
		return FATAL_DEFAULT;

	if (master_service_settings_read_simple(master_service, set_roots,
						&error) < 0)
		i_fatal("Error reading configuration: %s", error);

	master_service_init_log(master_service, "dict: ");
	main_preinit();
	master_service_init_finish(master_service);
	master_service_set_die_callback(master_service, dict_die);

	main_init();
	master_service_run(master_service, client_connected);

	main_deinit();
	master_service_deinit(&master_service);
        return 0;
}
Example #18
0
int main( void ) {
  main_init();
  while(1) {
    if (sys_time_periodic())
      main_periodic_task();
  }
  return 0;
}
Example #19
0
int main( void ) {
  main_init();
  while(1) {
    if (sys_time_check_and_ack_timer(0))
      main_periodic_task();
  }
  return 0;
}
Example #20
0
int main(int argc, char ** argv)
{
	bool success_all = true;
	bool unbalance_check = true;
	struct busy_data busy;
	const char * exec_name = argv[0];

	os_init(OS_INIT_NOFREQUENCY);
	printf("# %s Created by Olivier Cozette <olivier.cozette@arm.com>\n# Copyright (C) 2013  ARM Limited\n", argv[0]);

	if ((argc > 1) && (strcmp(argv[1], "NO_BALANCE_CHECK") == 0))
	{
		argv++;
		argc--;
		unbalance_check = false;
	}

	if (argc < 5)
	{
		printf("#Usage %s [NO_BALANCE_CHECK] TOTAL_SEQUENTIAL_TIME RUNNING_TIME SLEEPING_TIME NICE_PID0 [NICE_PID1] ...\n", exec_name);
		printf("#\tif NO_BALANCED_CHECK is given, even unbalanced thread won't raise a FAILED\n");
		os_cleanup();
		exit(1);
	}

	if (!main_init(&busy, argc, argv))
	{
		printf("# error :%s\n", busy.error_str);
		main_cleanup(&busy);
		os_cleanup();
		exit(1);
	}

	if (!main_launch(&busy))
		success_all = false;
	if (!main_wait(&busy))
		success_all = false;
	if (success_all)
		printf("SUCCESS before checking if tasks were well balanced\n");
	if (!main_check(&busy))
	{
		if (unbalance_check)
			success_all = false;
		else
			printf("#Seen as unbalanced or not using all the cpu time, but this doesn't affect the result\n");
	}

	main_cleanup(&busy);
	os_cleanup();
	if (!success_all)
	{
		printf("FAILED\n");
		exit(1);
	}
	printf("SUCCESS\n");
	return 0;
}
Example #21
0
File: main.c Project: Raffprta/core
int main(int argc, char *argv[])
{
	const struct setting_parser_info *set_roots[] = {
		&lda_setting_parser_info,
		&lmtp_setting_parser_info,
		NULL
	};
	enum master_service_flags service_flags =
		MASTER_SERVICE_FLAG_USE_SSL_SETTINGS;
	enum mail_storage_service_flags storage_service_flags =
		MAIL_STORAGE_SERVICE_FLAG_DISALLOW_ROOT |
		MAIL_STORAGE_SERVICE_FLAG_USERDB_LOOKUP |
		MAIL_STORAGE_SERVICE_FLAG_TEMP_PRIV_DROP |
		MAIL_STORAGE_SERVICE_FLAG_NO_LOG_INIT |
		MAIL_STORAGE_SERVICE_FLAG_NO_IDLE_TIMEOUT |
		MAIL_STORAGE_SERVICE_FLAG_AUTOEXPUNGE;
	int c;

	if (IS_STANDALONE()) {
		service_flags |= MASTER_SERVICE_FLAG_STANDALONE |
			MASTER_SERVICE_FLAG_STD_CLIENT;
	} else {
		service_flags |= MASTER_SERVICE_FLAG_KEEP_CONFIG_OPEN  ;
	}

	master_service = master_service_init("lmtp", service_flags,
					     &argc, &argv, "D");
	while ((c = master_getopt(master_service)) > 0) {
		switch (c) {
		case 'D':
			storage_service_flags |=
				MAIL_STORAGE_SERVICE_FLAG_ENABLE_CORE_DUMPS;
			break;
		default:
			return FATAL_DEFAULT;
		}
	}

	if (t_get_current_dir(&base_dir) < 0)
		i_fatal("getcwd() failed: %m");
	drop_privileges();
	master_service_init_log(master_service,
				t_strdup_printf("lmtp(%s): ", my_pid));

	storage_service = mail_storage_service_init(master_service, set_roots,
						    storage_service_flags);
	restrict_access_allow_coredumps(TRUE);

	main_init();
	master_service_init_finish(master_service);
	master_service_run(master_service, client_connected);

	main_deinit();
	mail_storage_service_deinit(&storage_service);
	master_service_deinit(&master_service);
	return 0;
}
Example #22
0
int main( void ) {
  main_init();

  while(1) {
    handle_periodic_tasks();
    main_event();
  }
  return 0;
}
Example #23
0
int main(int argc, char **argv)
{
	struct sigaction sig_stop;
	struct sigaction sig_time;

	_main = main_init(argc, argv);
	_log = log_init();
	_main->conf = conf_init(argc, argv);
	_main->work = work_init();

	_main->tcp = tcp_init();
	_main->node = node_init();
	_main->mime = mime_init();

	/* Check configuration */
	conf_print();

	/* Catch SIG INT */
	unix_signal(&sig_stop, &sig_time);

	/* Fork daemon */
	unix_fork(log_console(_log));

	/* Increase limits */
	unix_limits(_main->conf->cores, CONF_EPOLL_MAX_EVENTS);

	/* Load mime types */
	mime_load();
	mime_hash();

	/* Prepare TCP daemon */
	tcp_start();

	/* Drop privileges */
	unix_dropuid0();

	/* Start worker threads */
	work_start();

	/* Stop worker threads */
	work_stop();

	/* Stop TCP daemon */
	tcp_stop();

	mime_free();
	node_free();
	tcp_free();

	work_free();
	conf_free();
	log_free(_log);
	main_free();

	return 0;
}
Example #24
0
/**
 * Call this method for program start. Allows restarting the program.
 * Reads configuration file to configure program.
 * Starts flight software threads based off of configs.
 * 
 * @return 
 */
int moses() {
    char msg[255];

    record("*****************************************************\n");
    record("*            MOSES FLIGHT SOFTWARE                  *\n");
    record("*****************************************************\n");

    printf("*****************************************************\n");
    printf("*            MOSES FLIGHT SOFTWARE                  *\n");
    printf("*****************************************************\n");

    /*init configuration stings*/
    main_init();

    /*read in configuration values*/
    read_moses_config();

    /*record this thread's PID*/
    main_pid = getpid();

    /*Use signals to inform the program to quit*/
    init_quit_signal_handler();

    /*start threads indicated by configuration file*/
    start_threads();

    /*Upon program termination (^c) attempt to join the threads*/
    pthread_sigmask(SIG_BLOCK, &mask, &oldmask);
    sigwait(&mask, &quit_sig);
    pthread_sigmask(SIG_UNBLOCK, &mask, &oldmask);

    record("exited wait\n");

    /*SIGINT or SIGHUP caught, ending program*/
    join_threads();

    /*clean up memory and open devices*/
    cleanup();

    sprintf(msg, "quit_sig: %d\n", quit_sig);
    record(msg);

    /* if SIGUSR2, a reset command was received. */
    if (quit_sig == SIGUSR2) {

        sleep(2);
        record("Flight software rebooting...\n");

        return TRUE;
    }

    record("FLIGHT SOFTWARE EXITED\n\n\n");

    return FALSE;
}
Example #25
0
int			main(int argc, char **argv)
{
    if (main_init(argc, argv) == -1)
        sig_handler(-1);
    while (42)
    {
        play_turn();
    }
    exit_shmem();
    return (EXIT_SUCCESS);
}
Example #26
0
int
main (int argc, char **argv)
{
    /* produce AVR's FSM headers. */
    if (ANGFSM_OPTIONS (argc, argv))
        return 0;
    avr_init (argc, argv);
    main_init ();
    main_loop ();
    return 0;
}
Example #27
0
int
main (int argc, char **argv)
{
    char **opts = main_init (argc, argv);

    fd_epoll = epoll_create (1024);
    ASSERT (fd_epoll >= 0);
    main_init_srv (opts);
    main_run (&main_loop);
    close (fd_epoll);
    return 0;
}
Example #28
0
int main(int argv, char* argc[]){
	main_init();
	OVERLAP = atoi(argc[1]);
	THREAD = atoi(argc[2]);
	ITERFLAG = atoi(argc[3]);
	ITER_ALGO = atoi(argc[4]);
	PICK_ALGO = atoi(argc[5]);
	printf("Iteration Algorithm Version: %d\n", ITER_ALGO);
	printf("Selection Algorithm Version: %d\n", PICK_ALGO);
	printf("Init done...\n");
	main_routine();
}
void nps_autopilot_init(enum NpsRadioControlType type_rc, int num_rc_script, char* rc_dev) {
  autopilot.launch = TRUE;

  nps_radio_control_init(type_rc, num_rc_script, rc_dev);
  nps_electrical_init();

  nps_bypass_ahrs = NPS_BYPASS_AHRS;
  nps_bypass_ins = NPS_BYPASS_INS;

  main_init();

}
Example #30
0
int main(void)
{

  main_init();
  while (1) {
    if (sys_time_check_and_ack_timer(0)) {
      main_periodic();
    }
    main_event();
  };
  return 0;
}