示例#1
0
文件: autocal.c 项目: uluckas/em8300
int main( int   argc,
          char *argv[] )
{
    FILE *dev	;
    overlay_t *ov;
    Screen *xscrn;
    
    dpy = XOpenDisplay (NULL);
    if (!dpy) _exit(1);

    xscrn=ScreenOfDisplay(dpy, 0);
    xsize=WidthOfScreen(xscrn)/NUM_MONITORS;
    ysize=HeightOfScreen(xscrn);
    depth=PlanesOfScreen(xscrn);
    fprintf(stderr, "Width: %d, Height: %d, Depth: "
	    "%d\n", xsize, ysize, depth);

    AllBlackButInit();

    if(!(dev=fopen("/dev/em8300-0", "r")))
        {
	    const gchar *errstr = g_strerror(errno);
	    perror("Could not open /dev/em8300-0 for reading");
	    AllBlackButClose();
	    gtk_init(&argc, &argv);
	    GtkWidget *dialog = gtk_message_dialog_new(
		NULL, 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE,
		"Could not open EM8300 device for reading.\n\n"
		"Make sure the hardware is present, modules are "
		"loaded, and you have read permissions to the "
		"device.\n\nThe error was: /dev/em8300-0: %s", errstr);
	    gtk_window_set_title(GTK_WINDOW(dialog),
		"Autocal: Exiting with error");
	    gtk_dialog_run(GTK_DIALOG(dialog));
	    gtk_widget_destroy(dialog);
	    _exit(-1);
        }

    ov = overlay_init(dev);

    overlay_set_screen(ov,xsize,ysize,depth);

    overlay_read_state(ov,NULL);

    overlay_autocalibrate(ov, pattern_draw, NULL);

    overlay_write_state(ov,NULL);
    
    overlay_release(ov);

    fclose(dev);    

    AllBlackButClose();
    return 0;
}
示例#2
0
void vid_init()
{
	int flags;

	if (!vmode[0] || !vmode[1])
	{
		int scale = rc_getint("scale");
		if (scale < 1) scale = 1;
		vmode[0] = 160 * scale;
		vmode[1] = 144 * scale;
	}
	
	flags = SDL_ANYFORMAT | SDL_HWPALETTE | SDL_HWSURFACE;

	if (fullscreen)
		flags |= SDL_FULLSCREEN;

	if (SDL_Init(SDL_INIT_VIDEO))
		die("SDL: Couldn't initialize SDL: %s\n", SDL_GetError());

	if (!(screen = SDL_SetVideoMode(vmode[0], vmode[1], vmode[2], flags)))
		die("SDL: can't set video mode: %s\n", SDL_GetError());

	SDL_ShowCursor(0);

	joy_init();

	overlay_init();
	
	if (fb.yuv) return;
	
	SDL_LockSurface(screen);
	
	fb.w = screen->w;
	fb.h = screen->h;
	fb.pelsize = screen->format->BytesPerPixel;
	fb.pitch = screen->pitch;
	fb.indexed = fb.pelsize == 1;
	fb.ptr = screen->pixels;
	fb.cc[0].r = screen->format->Rloss;
	fb.cc[0].l = screen->format->Rshift;
	fb.cc[1].r = screen->format->Gloss;
	fb.cc[1].l = screen->format->Gshift;
	fb.cc[2].r = screen->format->Bloss;
	fb.cc[2].l = screen->format->Bshift;

	SDL_UnlockSurface(screen);

	fb.enabled = 1;
	fb.dirty = 0;
	
}
示例#3
0
int
slap_init( int mode, const char *name )
{
	int rc;

	assert( mode );

	if ( slapMode != SLAP_UNDEFINED_MODE ) {
		/* Make sure we write something to stderr */
		slap_debug |= LDAP_DEBUG_NONE;
		Debug( LDAP_DEBUG_ANY,
		 "%s init: init called twice (old=%d, new=%d)\n",
		 name, slapMode, mode );

		return 1;
	}

	slapMode = mode;

	slap_op_init();

#ifdef SLAPD_MODULES
	if ( module_init() != 0 ) {
		slap_debug |= LDAP_DEBUG_NONE;
		Debug( LDAP_DEBUG_ANY,
		    "%s: module_init failed\n",
			name, 0, 0 );
		return 1;
	}
#endif

	if ( slap_schema_init( ) != 0 ) {
		slap_debug |= LDAP_DEBUG_NONE;
		Debug( LDAP_DEBUG_ANY,
		    "%s: slap_schema_init failed\n",
		    name, 0, 0 );
		return 1;
	}

	if ( filter_init() != 0 ) {
		slap_debug |= LDAP_DEBUG_NONE;
		Debug( LDAP_DEBUG_ANY,
		    "%s: filter_init failed\n",
		    name, 0, 0 );
		return 1;
	}

	if ( entry_init() != 0 ) {
		slap_debug |= LDAP_DEBUG_NONE;
		Debug( LDAP_DEBUG_ANY,
		    "%s: entry_init failed\n",
		    name, 0, 0 );
		return 1;
	}

	switch ( slapMode & SLAP_MODE ) {
	case SLAP_SERVER_MODE:
		root_dse_init();

		/* FALLTHRU */
	case SLAP_TOOL_MODE:
		Debug( LDAP_DEBUG_TRACE,
			"%s init: initiated %s.\n",	name,
			(mode & SLAP_MODE) == SLAP_TOOL_MODE ? "tool" : "server",
			0 );

		slap_name = name;

		ldap_pvt_thread_pool_init( &connection_pool,
				connection_pool_max, 0);

		slap_counters_init( &slap_counters );

		ldap_pvt_thread_mutex_init( &slapd_rq.rq_mutex );
		LDAP_STAILQ_INIT( &slapd_rq.task_list );
		LDAP_STAILQ_INIT( &slapd_rq.run_list );

		slap_passwd_init();

		rc = slap_sasl_init();

		if( rc == 0 ) {
			rc = backend_init( );
		}
		if ( rc )
			return rc;

		break;

	default:
		slap_debug |= LDAP_DEBUG_NONE;
		Debug( LDAP_DEBUG_ANY,
			"%s init: undefined mode (%d).\n", name, mode, 0 );

		rc = 1;
		break;
	}

	if ( slap_controls_init( ) != 0 ) {
		slap_debug |= LDAP_DEBUG_NONE;
		Debug( LDAP_DEBUG_ANY,
		    "%s: slap_controls_init failed\n",
		    name, 0, 0 );
		return 1;
	}

	if ( frontend_init() ) {
		slap_debug |= LDAP_DEBUG_NONE;
		Debug( LDAP_DEBUG_ANY,
		    "%s: frontend_init failed\n",
		    name, 0, 0 );
		return 1;
	}

	if ( overlay_init() ) {
		slap_debug |= LDAP_DEBUG_NONE;
		Debug( LDAP_DEBUG_ANY,
		    "%s: overlay_init failed\n",
		    name, 0, 0 );
		return 1;
	}

	if ( glue_sub_init() ) {
		slap_debug |= LDAP_DEBUG_NONE;
		Debug( LDAP_DEBUG_ANY,
		    "%s: glue/subordinate init failed\n",
		    name, 0, 0 );

		return 1;
	}

	if ( acl_init() ) {
		slap_debug |= LDAP_DEBUG_NONE;
		Debug( LDAP_DEBUG_ANY,
		    "%s: acl_init failed\n",
		    name, 0, 0 );
		return 1;
	}

	return rc;
}
示例#4
0
int overlay_tx_messages()
{
  if (overlay_socket==-1) overlay_init();

  return 0;
}
示例#5
0
文件: main.c 项目: eried/QuadPawn
int loadprogram(const char *filename, char *error, size_t error_size)
{
    FIL *file = &amx_file;
    FRESULT status = f_open(file, filename, FA_READ);
    if (status != FR_OK)
    {
        snprintf(error, error_size, "Could not open file %s: %d", filename, status);
        return AMX_ERR_NOTFOUND;
    }
    
    /* Read file header */
    memset(&amx, 0, sizeof(amx));
    AMX_HEADER hdr;
    UINT read_count;
    f_read(file, &hdr, sizeof hdr, &read_count);
    if (read_count != sizeof hdr || hdr.magic != AMX_MAGIC)
        return AMX_ERR_FORMAT;
    
    if (hdr.flags & AMX_FLAG_OVERLAY)
    {
        // Read the header
        f_lseek(file, 0);
        f_read(file, vm_data, hdr.cod, &read_count);
        
        // Read the data block
        f_lseek(file, hdr.dat);
        unsigned dat_size = hdr.hea - hdr.dat;
        f_read(file, vm_data + hdr.cod, dat_size, &read_count);
        if (read_count != dat_size)
            return AMX_ERR_FORMAT;
        
        unsigned static_size = (hdr.stp - hdr.dat) + hdr.cod;
        amx_poolinit(vm_data + static_size, sizeof(vm_data) - static_size);
        
        amx.base = vm_data;
        amx.data = vm_data + hdr.cod;
        overlay_init(&amx, amx_filename, &amx_file);
    }
    else
    {
        if (hdr.stp > sizeof(vm_data))
            return AMX_ERR_MEMORY;
        
        /* Read the actual file, including the header (again) */
        f_lseek(file, 0);
        f_read(file, vm_data, hdr.size, &read_count);
        if (read_count != hdr.size)
            return AMX_ERR_FORMAT;
    }
    
    AMXERRORS(amx_Init(&amx, vm_data));
    
    amxinit_display(&amx);
    amx_CoreInit(&amx);
    amxinit_string(&amx);
    amxinit_fixed(&amx);
    amxinit_wavein(&amx);
    amxinit_waveout(&amx);
    amxinit_menu(&amx);
    amxinit_file(&amx);
    amxinit_buttons(&amx);
    amxinit_fourier(&amx);
    amxinit_time(&amx);
    amxinit_device(&amx);
    amxinit_fpga(&amx);
    
    // Check that everything has been registered
    int regstat = amx_Register(&amx, NULL, -1);
    if (regstat != 0)
    {
        // Find out what is missing
        for (int i = 0; i < NUMENTRIES((AMX_HEADER*)amx.base,natives,libraries); i++)
        {
            AMX_FUNCSTUB *func = GETENTRY((AMX_HEADER*)amx.base,natives,i);
            if (func->address == 0)
            {
                snprintf(error, error_size, "Native function not found: %s",
                         GETENTRYNAME((AMX_HEADER*)amx.base,func));
                return AMX_ERR_NOTFOUND;
            }
        }
        
        snprintf(error, error_size, "Error registering native functions");
        return regstat;
    }
    
    return 0;
}