Exemplo n.º 1
0
void Authorization::check()
{
    if (file.open(QIODevice::ReadOnly | QIODevice::Text)) {
        while (!file.atEnd())
            digest = QString(file.readLine()).toUtf8().simplified();
        file.close();
        isSet = true;
        init_ui();
    } else if (_set) {
        init_ui();
    } else {
        delete this;
    }
}
Exemplo n.º 2
0
int main(int argc, char **argv)
{
	int i;

	output_units = SI_units;
	parse_xml_init();

	init_ui(argc, argv);
	
	for (i = 1; i < argc; i++) {
		const char *a = argv[i];

		if (a[0] == '-') {
			parse_argument(a);
			continue;
		}
		GError *error = NULL;
		parse_xml_file(a, &error);
		
		if (error != NULL)
		{
			report_error(error);
			g_error_free(error);
			error = NULL;
		}
	}

	report_dives();
	dive_list_update_dives();

	run_ui();
	return 0;
}
Exemplo n.º 3
0
int16_t main(void) {
    init_clock();
    init_ui();
    init_pin();
    init_timer();
    init_i2c();
    InitUSB();
    init_oc();

    init_display(&i2c3, 0x70, 0x71);
    init_game(&timer1, &timer2, &A[0], &disp1, &disp2);
    init_gun(&D[13], &A[1], &A[2], &timer3);
    init_launcher(&D[5], &D[8], &D[3], &D[4]);
    init_shooter(&D[6], &D[9], &D[1], &D[2], &D[7], &D[0], &oc3, &oc4);
    init_baller(&D[10], &oc2, &timer4, &shooter, &launcher);
    init_pix(&D[11], &timer5, 30, 0.05);
    init_audio(&D[12]);

    uint8_t level = 0;
    uint8_t hit_flag = 0;
    while (1) {
        ServiceUSB(); // usb times out if not checked fast enough :/
        level = run_game(hit_flag);
        ServiceUSB();
        hit_flag = run_gun(level);
        ServiceUSB();
        run_baller(level);
    }
}
Exemplo n.º 4
0
int16_t main(void) {
    init_clock();
    init_ui();
    init_pin();
    init_spi();

    ENC_MISO = &D[1];
    ENC_MOSI = &D[0];
    ENC_SCK = &D[2];
    ENC_NCS = &D[3];

    pin_digitalOut(ENC_NCS);
    pin_set(ENC_NCS);

    spi_open(&spi1, ENC_MISO, ENC_MOSI, ENC_SCK, 2e8);


    InitUSB();                              // initialize the USB registers and serial interface engine
    while (USB_USWSTAT!=CONFIG_STATE) {     // while the peripheral is not configured...
        ServiceUSB();                       // ...service USB requests
    }
    while (1) {
        ServiceUSB();                       // service any pending USB requests
    }
}
Exemplo n.º 5
0
int16_t main(void) {
	//initialize all system clocks
    init_clock();
	//initialize serial communications
    init_uart();
	//initialize pin driving library (to be able to use the &D[x] defs)
	init_pin();
	//initialize the UI library
    init_ui();
	//initialize the timer module
    init_timer();
	//initialize the OC module (used by the servo driving code)
	init_oc();
	
    imu_init()
	//Set servo control pins as output
	pin_digitalOut(PAN_PIN);
	pin_digitalOut(TILT_PIN);
	pin_digitalOut(SONIC_OUT_PIN);
	pin_digitalIn(SONIC_IN_PIN);
	
	//Set LED off
	led_off(LED);
	//Configure blinking rate for LED when connected
    timer_setPeriod(LED_TIM, 0.2);
    timer_start(LED_TIM);
	

    //Configure timer for reciever timeout
    timer_setPeriod(DIST_TIM, 0.05);


	//configure PWM on sonic output pin
	oc_pwm(PWM_OC, SONIC_OUT_PIN, NULL, SONIC_FREQ, 0x0000);
	
	//According to HobbyKing documentation: range .8 through 2.2 msec
	//Set servo control pins as OC outputs on their respective timers
	oc_servo(SERVO1_OC, PAN_PIN, 	SERVO1_TIM, SERVO_PERIOD, SERVO_MIN, SERVO_MAX, pan_set_val);
	oc_servo(SERVO2_OC, TILT_PIN, 	SERVO2_TIM, SERVO_PERIOD, SERVO_MIN, SERVO_MAX, tilt_set_val);

    InitUSB();                              // initialize the USB registers and serial interface engine
    while (USB_USWSTAT!=CONFIG_STATE) {     // while the peripheral is not configured...
        ServiceUSB();                       // ...service USB requests
		led_on(LED);
		//There's no point in driving the servos when there's no one connected yet.
    }
	
    while (1) {
        ServiceUSB();                       // service any pending USB requests
		
		//blink the LED
		if (timer_flag(LED_TIM)) {
            timer_lower(LED_TIM);
            led_toggle(LED);
        }
		
		//Update the servo control values.
        x_gout = gyro_read(OUT_X_L);
    }
}
Exemplo n.º 6
0
int16_t main(void) {
    // printf("Starting Rocket Controller...\r\n");
    init_clock();
    init_ui();
    init_pin();
    init_timer();
    init_i2c();
    setup();
    init_servo_driver(&sd1, &i2c3, 16000., 0x0);
    init_servo(&servo4, &sd1, 0);
    InitUSB();
    U1IE = 0xFF; //setting up ISR for USB requests
    U1EIE = 0xFF;
    IFS5bits.USB1IF = 0; //flag
    IEC5bits.USB1IE = 1; //enable
    // uint32_t pid_command;
    servo_set(&servo4, 1500, 0);
    while (1) {
        if (timer_flag(&timer1)) {
            // Blink green light to show normal operation.
            timer_lower(&timer1);
            led_toggle(&led2);
            // servo_set(&servo4, 1500, 0);
        }
    }
}
Exemplo n.º 7
0
int16_t main(void) {
    int led2_on;
    int led3_on;

    led2_on = 0;
    led3_on = 1;
    init_clock();
    init_ui();
    init_timer();

    led_on(&led1);
    timer_setPeriod(&timer2, 0.1);
    timer_start(&timer2);

    while (1) {
        if (timer_flag(&timer2)) {
            timer_lower(&timer2);
            led_toggle(&led1);
        }

        if(!sw_read(&sw2)){
            timer_setPeriod(&timer2, 0.5);
            timer_start(&timer2);
            led2_on = 1;
            led3_on = 0;
        } else if(!sw_read(&sw3)){
            timer_setPeriod(&timer2, 0.1);
            timer_start(&timer2);
            led2_on = 0;
            led3_on = 1;
        }
        led_write(&led2, led2_on);
        led_write(&led3, led3_on);
    }
}
Exemplo n.º 8
0
//OTHER INITIAL CONDITIONS
void initChip(){
    init_clock();
    init_uart();
    init_timer();
    init_ui();
    init_pin();
    init_oc();

    pin_analogIn(CUR);
    pin_analogIn(EMF);
    pin_analogIn(FB);

    pin_digitalIn(SF);
    pin_digitalIn(ENC);

    pin_digitalOut(D1);
    pin_digitalOut(D2);
    pin_digitalOut(IN1);
    pin_digitalOut(IN2);
    pin_digitalOut(ENA);
    pin_digitalOut(SLEW);
    pin_digitalOut(INV);

    oc_pwm(&oc1, D2, PWM_TIMER, 250, 0); 
}
Exemplo n.º 9
0
int main(int argc, char *argv[])
{
  getcwd(cwd, 999);
  arg0 = argv[0];
  arg1 = argc ? argv[1] : NULL;

  /* LOAD FILES AND STUFF HERE */
  init_work(argc ? argv[1] : NULL);
  init_ui();

#ifdef USE_JOYSTICK
  printf("Initializing joystick...\n");
  signal(SIGVTALRM,joy_alarm);
  joy_fd = open ("/dev/input/js0", O_RDONLY | O_NONBLOCK);
#endif

  idle_id = gtk_idle_add (iterate, NULL);

  system("xset s noblank");
  system("xset s off");
  system("xset -dpms");
  
  /* -------------------------------------- */
  gtk_main();
  gdk_flush ();
  /* -------------------------------------- */

  system("xset +dpms");
  system("xset s on");
  system("xset s blank");
  
  flynn_exit(0);
}
Exemplo n.º 10
0
int main(int argc, char* argv[]){
  parse_args(argc, argv);
  
  init_ui();
  init_structs();
  init_plotter();

  start_debug();
  
  int x;
  while (!options.quit) {
    clear();
    set_terminal_size();    
    draw_axis();
    replot_functions();

    x = input();
    if(x == -1) break;

    refresh(); 
  } 

  clean_plotter();
  clean_ui();
  return 0;
}
Exemplo n.º 11
0
void setup(void) {
    // Initialize PIC24 modules.
    init_clock();
    init_ui();
    init_timer();
    init_pin();
    init_oc();
    init_spi();
    init_uart();

    // Configure single SPI comms. system
    pin_digitalOut(SPI_CS);
    pin_set(SPI_CS);
    spi_open(spi_inst, SPI_MISO, SPI_MOSI, SPI_SCK, spi_freq, spi_mode);

    // Configure & start timers used.
    timer_setPeriod(&timer1, 1);
    timer_setPeriod(&timer2, 1);  // Timer for LED operation/status blink
    timer_setPeriod(&timer3, LOOP_TIME); // Timer for main control loop
    timer_start(&timer1);
    timer_start(&timer2);
    timer_start(&timer3);

    // Configure dual PWM signals for bidirectional motor control
    oc_pwm(&oc1, PWM_I1, NULL, pwm_freq, pwm_duty);
    oc_pwm(&oc2, PWM_I2, NULL, pwm_freq, pwm_duty);

    InitUSB();                              // initialize the USB registers and
                                            // serial interface engine
    while (USB_USWSTAT != CONFIG_STATE) {   // while periph. is not configured,
        ServiceUSB();                       // service USB requests
    }
}
Exemplo n.º 12
0
void
init_game(Memory *memory, GameState *game_state, Keys *keys, u64 time_us, u32 argc, char *argv[])
{
    game_state->init = true;

    game_state->single_step = false;
    game_state->sim_ticks_per_s = 5;

    game_state->finish_sim_step_move = false;

    if (argc > 1)
    {
        game_state->filename = argv[1];
    }
    else
    {
        printf("Error: No Maze filename supplied.\n");
        exit(1);
    }

    setup_inputs(keys, &game_state->inputs);

    load_bitmap(&game_state->particles.spark_bitmap, "particles/spark.bmp");
    load_bitmap(&game_state->particles.cross_bitmap, "particles/cross.bmp");
    load_bitmap(&game_state->particles.blob_bitmap,  "particles/blob.bmp");
    load_bitmap(&game_state->particles.smoke_bitmap, "particles/smoke.bmp");
    load_bitmap(&game_state->bitmaps.tile, "tile.bmp");
    load_bitmap(&game_state->bitmaps.font, "font.bmp");

    load_cell_bitmaps(&game_state->cell_bitmaps);

    strcpy(game_state->persistent_str, "Init!");

    init_ui(&game_state->ui);
}
Exemplo n.º 13
0
int16_t main(void) {
    init_clock();
    init_timer();
    init_ui();
    init_pin();
    init_spi();
    init_oc();
    init_md();

    // Current measurement pin
    pin_analogIn(&A[0]);

    // SPI pin setup
    ENC_MISO = &D[1];
    ENC_MOSI = &D[0];
    ENC_SCK = &D[2];
    ENC_NCS = &D[3];
    pin_digitalOut(ENC_NCS);
    pin_set(ENC_NCS);

    // Open SPI in mode 1
    spi_open(&spi1, ENC_MISO, ENC_MOSI, ENC_SCK, 2e6, 1);

    // Motor setup
    md_velocity(&md1, 0, 0);

    // Get initial angle offset
    uint8_t unset = 1;
    while (unset) {
        ANG_OFFSET = enc_readReg((WORD) REG_ANG_ADDR);
        unset = parity(ANG_OFFSET.w);
    }
    ANG_OFFSET.w &= ENC_MASK;

    // USB setup
    InitUSB();
    while (USB_USWSTAT!=CONFIG_STATE) {
        ServiceUSB();
    }

    // Timers
    timer_setFreq(&timer2, READ_FREQ);
    timer_setFreq(&timer3, CTRL_FREQ);
    timer_start(&timer2);
    timer_start(&timer3);

    // Main loop
    while (1) {
        ServiceUSB();
        if (timer_flag(&timer2)) {
            timer_lower(&timer2);
            get_readings();
        }
        if (timer_flag(&timer3)) {
            timer_lower(&timer3);
            set_velocity();
        }
    }
}
Exemplo n.º 14
0
DashcoinWallet::DashcoinWallet(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::DashcoinWallet)
{
    ui->setupUi(this);
    init_ui();
    init_wallet();
}
Exemplo n.º 15
0
Arquivo: rirc.c Projeto: jdan/rirc
int
main(int argc, char **argv)
{
	init_ui();
	main_loop();
	cleanup(1);
	return 0;
}
Exemplo n.º 16
0
int main(int argc, char **argv)
{
	int i;
	bool no_filenames = true;

	init_qt(&argc, &argv);
	QStringList files;
	QStringList importedFiles;
	QStringList arguments = QCoreApplication::arguments();

	bool dedicated_console = arguments.length() > 1 &&
				 (arguments.at(1) == QString("--win32console"));
	subsurface_console_init(dedicated_console);

	for (i = 1; i < arguments.length(); i++) {
		QString a = arguments.at(i);
		if (a.at(0) == '-') {
			parse_argument(a.toLocal8Bit().data());
			continue;
		}
		if (imported) {
			importedFiles.push_back(a);
		} else {
			no_filenames = false;
			files.push_back(a);
		}
	}
#if !LIBGIT2_VER_MAJOR && LIBGIT2_VER_MINOR < 22
	git_threads_init();
#else
	git_libgit2_init();
#endif
	setup_system_prefs();
	prefs = default_prefs;
	fill_profile_color();
	parse_xml_init();
	taglist_init_global();
	init_ui();
	if (no_filenames) {
		QString defaultFile(prefs.default_filename);
		if (!defaultFile.isEmpty())
			files.push_back(QString(prefs.default_filename));
	}

	MainWindow *m = MainWindow::instance();
	m->setLoadedWithFiles(!files.isEmpty() || !importedFiles.isEmpty());
	m->loadFiles(files);
	m->importFiles(importedFiles);
	if (!quit)
		run_ui();
	exit_ui();
	taglist_free(g_tag_list);
	parse_xml_exit();
	subsurface_console_exit();
	free_prefs();
	return 0;
}
Exemplo n.º 17
0
int16_t main(void) {
    init_clock();
    init_ui();
    init_pin();
    init_spi();

    init_timer();
    init_oc();
    init_md();

    led_off(&led2);
    led_off(&led3);

    ENC_MISO = &D[1];
    ENC_MOSI = &D[0];
    ENC_SCK = &D[2];
    ENC_NCS = &D[3];


    read_angle.w=0x3FFF;
    Pscale.w=1;
    Iscale.w=0;
    direction.w=1;
    speed.w=0;
    angle_now.i=180;
    angle_prev.i=180;
    angle.w=10;
    uint8_t loop = 0;

    pin_digitalOut(ENC_NCS);
    pin_set(ENC_NCS);

    spi_open(&spi1, ENC_MISO, ENC_MOSI, ENC_SCK, 2e8,1);

    timer_setPeriod(&timer1, 0.05);
    timer_start(&timer1);

    InitUSB();  
                              // initialize the USB registers and serial interface engine
    while (USB_USWSTAT!=CONFIG_STATE) {     // while the peripheral is not configured...
        ServiceUSB();                       // ...service USB requests
    }  

   while(1){
    ServiceUSB();
        if (timer_flag(&timer1)) {
            timer_lower(&timer1);
            angle_prev=angle_now; 
            angle_prev_con=angle;                // service any pending USB requests
            angle_now = enc_readReg(read_angle);
            angle_now = mask_angle(angle_now);
            angle=convert_Angle(angle_prev,angle_now,&loop);

            spring_simple(angle);
        }
    }    
}
Exemplo n.º 18
0
bool
zathura_init(zathura_t* zathura)
{
  if (zathura == NULL) {
    return false;
  }

  /* create zathura (config/data) directory */
  create_directories(zathura);

  /* load plugins */
  zathura_plugin_manager_load(zathura->plugins.manager);

  /* configuration */
  config_load_default(zathura);
  config_load_files(zathura);

  /* UI */
  if (!init_ui(zathura)) {
    goto error_free;
  }

  /* database */
  init_database(zathura);

  /* bookmarks */
  zathura->bookmarks.bookmarks = girara_sorted_list_new2(
    (girara_compare_function_t)zathura_bookmarks_compare,
    (girara_free_function_t)zathura_bookmark_free);

  /* jumplist */
  init_jumplist(zathura);

  /* CSS for index mode */
  init_css(zathura);

  /* Shortcut helpers */
  init_shortcut_helpers(zathura);

  /* Start D-Bus service */
  bool dbus = true;
  girara_setting_get(zathura->ui.session, "dbus-service", &dbus);
  if (dbus == true) {
    zathura->dbus = zathura_dbus_new(zathura);
  }

  return true;

error_free:

  if (zathura->ui.page_widget != NULL) {
    g_object_unref(zathura->ui.page_widget);
  }

  return false;
}
Exemplo n.º 19
0
void init(void){
    init_pin();
    init_clock();
    init_uart();
    init_ui();
    init_timer();
    init_oc();
    init_motor();
    InitUSB(); // initialize the USB registers and serial interface engine    
    init_interrupts();
}
Exemplo n.º 20
0
int main(void) {
    srand(time(NULL));

    init_ui();

    while(1) {
        main_menu();
        run_game();
    }

    return 0;
}
Exemplo n.º 21
0
NetAndUart::NetAndUart(QWidget *parent) :
    QWidget(parent)
{
    //ui->setupUi(this);
    serial = NULL;
    readAll = true;
    timerData = new QTimer();

    init_ui();
    init_connect();

}
ChipCapacitiesDialog::ChipCapacitiesDialog( BaseObjectType* cobject,
	const Glib::RefPtr<Gtk::Builder>& builder)
	:
	ScannerTemplateDialog( cobject, builder, "chip-capacities"),
	button_change_capacity_(0),
	capacity_(SCANNER_DEFAULT_CHIP_CAPACITY)
{
	init_ui();

	connect_signals();

	show_all_children();
}
Exemplo n.º 23
0
int
main(int argc, char **argv)
{
	squidge_t squidge;

	if (argc != 2) {
		fprintf(stderr, "Usage: squidge logfile\n");
		return 1;
	}

	file_fd = open(argv[1], O_RDONLY, 0);
	if (file_fd < 0) {
		perror("Couldn't open log file");
		return 1;
	}

	gtk_init(&argc, &argv);
	init_ui( &squidge );
	squidge.follow_bottom = true;

	inotify_fd = inotify_init();
	inotify_add_watch(inotify_fd, argv[1], IN_MODIFY);

	inotify_io = g_io_channel_unix_new(inotify_fd);
	g_io_add_watch(inotify_io, G_IO_IN, read_inotify_fd, &squidge);

	log_io = g_io_channel_unix_new(file_fd);
	g_io_add_watch(log_io, G_IO_IN, read_log_file, &squidge);
	log_io_active = true;

	stdin_io = g_io_channel_unix_new(0);
	g_io_add_watch(stdin_io, G_IO_IN, read_stdin, &squidge);

	/* Hide the cursor by making it transparent */
	GdkWindow* gdk_window = gtk_widget_get_window(GTK_WIDGET(squidge.ui.win));
	GdkCursor *cursor;
	cursor = gdk_cursor_new(GDK_BLANK_CURSOR);
	gdk_window_set_cursor(gdk_window, cursor);

	GdkDisplay *display = gdk_display_get_default();
	GdkScreen *scr = gdk_screen_get_default();
	gdk_display_warp_pointer(display, scr, 1000, 1000);

	gtk_main();

	return 0;
}
Exemplo n.º 24
0
void setup(void) {
    // Initialize PIC24 modules.
    init_clock();
    init_ui();
    init_timer();
    init_pin();
    init_oc();
    init_spi();
    init_uart();

    // Configure single SPI comms. system
    pin_digitalOut(SPI_CS);
    pin_set(SPI_CS);
    spi_open(spi_inst, SPI_MISO, SPI_MOSI, SPI_SCK, spi_freq, spi_mode);

    // Configure & start timers used.
    timer_setPeriod(&timer1, 1);
    timer_setPeriod(&timer2, 1);  // Timer for LED operation/status blink
    timer_setPeriod(&timer3, LOOP_TIME); // Timer for main control loop
    timer_start(&timer1);
    timer_start(&timer2);
    timer_start(&timer3);

    // Configure motor current conversion coefficient
    CURRENT_CONV_COEF = MAX_ADC_OUTPUT * MOTOR_VOLTAGE_RESISTOR;
    cur_control.Kp = KP;
    cur_control.Kd = KD;
    cur_control.Ki = KI;
    cur_control.dt = LOOP_TIME;
    cur_control.integ_min = -100;
    cur_control.integ_max = 100;
    cur_control.integ_state = 0;
    read_motor_current(&motor);
    cur_control.prev_position = convert_motor_torque(motor.current);
    // Configure dual PWM signals for bidirectional motor control
    oc_pwm(&oc1, PWM_I1, NULL, pwm_freq, pwm_duty);
    oc_pwm(&oc2, PWM_I2, NULL, pwm_freq, pwm_duty);
    pin_analogIn(MOTOR_VOLTAGE);
    pin_digitalOut(DEBUGD0);
    pin_digitalOut(DEBUGD1);

    InitUSB();                              // initialize the USB registers and
                                            // serial interface engine
    while (USB_USWSTAT != CONFIG_STATE) {   // while periph. is not configured,
        ServiceUSB();                       // service USB requests
    }
}
Exemplo n.º 25
0
int16_t main(void) {
    init_clock();
    init_ui();
    init_timer();

    led_on(&led1);
    led_on(&led3);
    timer_setPeriod(&timer2, 0.5);
    timer_start(&timer2);

    while (1) {
        if (timer_flag(&timer2)) {
            timer_lower(&timer2);
            led_toggle(&led1);
            led_toggle(&led2);
<<<<<<< HEAD
        }
Exemplo n.º 26
0
int16_t main(void) {
    init_clock();
    init_ui();
    init_timer();

    led_on(&led1);
    timer_setPeriod(&timer2, 1.0);
    timer_start(&timer2);

    while (1) {
        if (timer_flag(&timer2)) {
            timer_lower(&timer2);
            led_toggle(&led1);
            led_toggle(&led2);
        }
        led_write(&led3, !sw_read(&sw3));
    }
}
Exemplo n.º 27
0
gint
main (gint argc, gchar *argv[])
{
        if (!init_ui (&argc, &argv)) {
           return -2;
        }

        if (!init_upnp ()) {
           return -3;
        }
        
        gtk_main ();
       
        deinit_upnp ();
        deinit_ui ();
        
        return 0;
}
Exemplo n.º 28
0
gint
main (gint   argc,
      gchar *argv[])
{
	setpriority (PRIO_PROCESS, 0, 10);
	mafw_log_init(NULL);
        if (!init_ui (&argc, &argv)) {
           return -2;
        }

        if (!init_app ()) {
           return -3;
        }

        gtk_main ();

        return 0;
}
Exemplo n.º 29
0
int
do_ui(void)
{
  char key = '\0';
  int ret = DOUI_ERR;

  /* init TUI and UI Elements (input field, status bar, etc) */
  if (init_ui(on_update_cb, on_postupdate_cb))
    init_ui_elements(ui_get_maxx(), ui_get_maxy());
  else
    return DOUI_ERR;

  /* some color definitions */
  init_pair(1, COLOR_RED, COLOR_WHITE);
  init_pair(2, COLOR_WHITE, COLOR_BLACK);
  init_pair(3, COLOR_BLACK, COLOR_WHITE);
  /* TXTwindow */
  init_pair(4, COLOR_YELLOW, COLOR_RED);
  init_pair(5, COLOR_WHITE, COLOR_CYAN);

  ui_thrd_suspend();
  if (run_ui_thrd() != 0) {
    ui_thrd_resume();
    return ret;
  }
  timeout(0);
  ui_thrd_resume();

  while ( ui_ipc_getvalue(SEM_UI) > 0 ) {
    if ( (key = ui_wgetch(10000)) == ERR )
      continue;

    if ( process_key(key) != true ) {
      ui_ipc_semtrywait(SEM_UI);
    }

    ui_thrd_force_update(true,false);
  }
  stop_ui_thrd();
  free_ui_elements();

  return DOUI_OK;
}
Exemplo n.º 30
0
int main (int argc, char** argv)
{
	if (argc < 2)
	{
		std::cout << "Please, enter a filename" << std::endl;
		exit(-1);
	}

	local_addrs = new local_addr (/*TODO*/1, NULL);
	needrefresh = false;

	process_init();

	tracemode = 1;
	if ((!tracemode) && (!DEBUG)){
		init_ui();
	}

	char errbuf[DP_ERRBUF_SIZE];

	//dp_handle * newhandle = dp_open_live(current_dev->name, BUFSIZ, promisc, 100, errbuf); 
	dp_handle * newhandle = dp_open_offline(argv[1], errbuf); 
	dp_addcb (newhandle, dp_packet_ip, process_ip);
	dp_addcb (newhandle, dp_packet_ip6, process_ip6);
	dp_addcb (newhandle, dp_packet_tcp, process_tcp);
	dp_addcb (newhandle, dp_packet_udp, process_udp);

	signal (SIGALRM, &alarm_cb);
	signal (SIGINT, &quit_cb);
	//alarm (refreshdelay);
	//fprintf(stderr, "Waiting for first packet to arrive (see sourceforge.net bug 1019381)\n");
	struct dpargs * userdata = (dpargs *) malloc (sizeof (struct dpargs));
	userdata->sa_family = AF_UNSPEC;
	int ret = dp_dispatch (newhandle, -1, (u_char *)userdata, sizeof (struct dpargs));
	free (userdata);
	if (ret == -1)
	{
		std::cout << "Error dispatching: " << dp_geterr(newhandle);
	}
	std::cout << "Done dispatching. " << dp_geterr(newhandle);
	do_refresh();
}