コード例 #1
0
ファイル: console.c プロジェクト: ashmew2/kolibriosSVN
int main(int argc, char **argv) {

    struct import * hDll;
    int a,b,c,d;

    if((hDll = (struct import *)_ksys_cofflib_load(dllname)) == 0) {
        debug_out_str("can't load lib\n");
        return 1;
    }
    link(hDll, imports);
    debug_out_str("dll loaded\n");

    if(dll_start(1) == 0) {
        debug_out_str("dll_start failed\n");
        return 1;
    }

    con_init(-1, -1, -1, -1, caption);

    for(i = 0; i < 256; i++) {
        con_printf("Color 0x%02X: ", i);
        con_write_asciiz("Text sample.");

        con_printf("  printf %s test %d\n", "small", i);

    }

    con_exit(0);
    debug_out_str("all right's ;)\n");
}
コード例 #2
0
ファイル: console.c プロジェクト: Xeffyr/KolibriOS-Mod
void CONSOLE_INIT(char title[])
{
kol_struct_import *imp;

imp = kol_cofflib_load("/sys/lib/console.obj");
if (imp == NULL)
	kol_exit();

con_init = ( _stdcall  void (*)(unsigned, unsigned, unsigned, unsigned, const char*)) 
		kol_cofflib_procload (imp, "con_init");
if (con_init == NULL)
	kol_exit();

printf = ( _cdecl void (*)(const char*,...))
		kol_cofflib_procload (imp, "con_printf");
if (printf == NULL)
	kol_exit();

_exit = ( _stdcall void (*)(char))
		kol_cofflib_procload (imp, "con_exit");
if (_exit == NULL)
	kol_exit();

gets = ( _stdcall void (*)(char*, int))
		kol_cofflib_procload (imp, "con_gets");
if (gets == NULL)
	kol_exit();

getch = ( _stdcall int (*)(void))
		kol_cofflib_procload (imp, "con_getch2");
if (getch == NULL)
	kol_exit();

con_get_font_height = ( _stdcall int (*)(void))
		kol_cofflib_procload (imp, "con_get_font_height");
if (con_get_font_height == NULL)
	kol_exit();

con_set_cursor_height = ( _stdcall int (*)(int))
		kol_cofflib_procload (imp, "con_set_cursor_height");
if (con_set_cursor_height == NULL)
	kol_exit();

con_get_flags = ( _stdcall unsigned (*)(void))
		kol_cofflib_procload (imp, "con_get_flags");
if (con_get_flags == NULL)
	kol_exit();

con_set_flags = ( _stdcall unsigned (*)(unsigned))
		kol_cofflib_procload (imp, "con_set_flags");
if (con_set_flags == NULL)
	kol_exit();

con_cls = ( _stdcall void (*)(void))
		kol_cofflib_procload (imp, "con_cls");
if (con_cls == NULL)
	kol_exit();

con_init(-1, -1, -1, -1, title);
}
コード例 #3
0
ファイル: tty_io.c プロジェクト: escray/readlinuxkernel
// 初始化字符设备
void tty_init(void)
{
	// 设置串口
	rs_init();
	// 设置显示器
	con_init();
}
コード例 #4
0
ファイル: game.c プロジェクト: nosnickid/punani-strike
struct _game *game_new(const struct game_ops * const *modes,
		unsigned int num_modes, game_exit_fn_t efn, void *priv)
{
	struct _game *g;

	assert(num_modes);
	assert(modes[0] == NULL);

	g = calloc(1, sizeof(*g));
	if ( NULL == g )
		goto out;

	g->g_modes = modes;
	g->g_num_modes = num_modes;
	g->g_efn = efn;
	g->g_common = priv;

	g->g_render = renderer_new(g);
	if ( NULL == g->g_render )
		goto out_free;

	con_init();

	/* success */
	goto out;

out_free:
	free(g);
	g = NULL;
out:
	return g;
}
コード例 #5
0
ファイル: device.c プロジェクト: munshkr/spuriOS
inline void init_dev_modules() {
	proc_init();
	con_init("/disk/bin/screen_saver.pso");
	serial_init();
	hdd_init();
	fs_init();
	pipe_init();
}
コード例 #6
0
ファイル: keyval.c プロジェクト: doolse/wingsos
void main() {
  int i;

  con_init();

  while(1) {
    i = con_getkey();
    printf("%d\n",i);
    con_update();
  }

}
コード例 #7
0
int init_console(void)
{
  struct import * hDll;

        if((hDll = (struct import *)_ksys_cofflib_load(dllname)) == 0){
                debug_out_str("can't load lib\n");
                return 1;
        }
        printf_link(hDll, imports);
        debug_out_str("dll loaded\n");

        con_init(-1, -1, -1, -1, caption);
        return(0);
}
コード例 #8
0
ファイル: test.c プロジェクト: CurrentResident/gmqcc
int main(int argc, char **argv) {
    bool          succeed  = false;
    char         *redirout = (char*)stdout;
    char         *redirerr = (char*)stderr;
    char         *defs     = NULL;

    con_init();
    OPTS_OPTION_U16(OPTION_MEMDUMPCOLS) = 16;

    /*
     * Command line option parsing commences now We only need to support
     * a few things in the test suite.
     */
    while (argc > 1) {
        ++argv;
        --argc;

        if (argv[0][0] == '-') {
            if (parsecmd("redirout", &argc, &argv, &redirout, 1, false))
                continue;
            if (parsecmd("redirerr", &argc, &argv, &redirerr, 1, false))
                continue;
            if (parsecmd("defs",     &argc, &argv, &defs,     1, false))
                continue;

            con_change(redirout, redirerr);

            if (!strcmp(argv[0]+1, "debug")) {
                OPTS_OPTION_BOOL(OPTION_DEBUG) = true;
                continue;
            }
            if (!strcmp(argv[0]+1, "memchk")) {
                OPTS_OPTION_BOOL(OPTION_MEMCHK) = true;
                continue;
            }
            if (!strcmp(argv[0]+1, "nocolor")) {
                con_color(0);
                continue;
            }

            con_err("invalid argument %s\n", argv[0]+1);
            return -1;
        }
    }
    con_change(redirout, redirerr);
    succeed = test_perform("tests", defs);
    stat_info();

    return (succeed) ? EXIT_SUCCESS : EXIT_FAILURE;
}
コード例 #9
0
ファイル: useful.c プロジェクト: Zyrter/super-osd
/**
 * panic: fatal error routine. Panic displays the message
 * on the screen, then waits 2 seconds before restarting
 * the processor.
 *
 * @param	message to print
 */
void panic(char *msg)
{
	long int d = 5000000;
	// Initialize console, print message.
	con_init();
	con_puts("PANIC ON OSD DSP !!");
	con_puts("Super OSD's on screen display processor encountered a fatal error condition.");
	con_puts("");
	con_puts(msg);
	con_puts("");
	con_puts("Resetting soon.");
	// Reset after timer expires.
	while(d--);
	asm("reset");
}
コード例 #10
0
ファイル: MainWrapp.c プロジェクト: gsimi/rich-pd
int main(void)
{
	int   ret;
	char  esc = 0;

    loop = 0;

	for( ret = 0; ret < MAX_HVPS ; ret++ )
		System[ret].ID = -1;

	con_init();
	commandList();
	con_end();

	return 0;
}
コード例 #11
0
/**
 * @brief	Create a connection object for an accepted connection, and enqueue it to be handled.
 * @see		protocol_secure(), protocol_enqueue()
 * @note	Depending on whether the server specifies a secure transport layer, protocol_secure() or protocol_enqueue() will be dispatched.
 * @param	server	a pointer to the server object of the server handling the connection.
 * @param	sockd	the socket descriptor of the newly accepted connection.
 */
void protocol_process(server_t *server, int sockd) {

	connection_t *con;

	if (!server || sockd == -1 || !net_set_timeout(sockd, server->network.timeout, server->network.timeout)) {
		log_pedantic("Invalid parameters were passed into the protocol processor.");
		if (sockd != -1)
			close(sockd);
		return;
	}

	if (!(con = con_init(sockd, server))) {
		close(sockd);
		return;
	}

	server->network.type == SSL_PORT && server->ssl.context ? enqueue(&protocol_secure, con) : enqueue(&protocol_enqueue, con);
	return;
}
コード例 #12
0
ファイル: main.c プロジェクト: pinkfluid/apme
/**
 * Initialize the application:
 *      - Initialize the debug console
 *      - Initialize the Aion subsystem
 *      - Initialize the chatlog engine
 *      - Register events
 *
 * @param[in]   argc        Argument number (passed from main) -- not used
 * @param[in]   argv        Argument array (passed from main) -- not used
 *
 * @retval      true        On success
 * @retval      false       If it fails to initialize the aion sub-system
 * @retval      false       If it fails to initialize the chatlog engine
 */
bool apme_init(int argc, char* argv[])
{
    (void)argc;
    (void)argv;

    /* First initialize the debug console */
    con_init();

    /* Initialize events early, elevation is requested with events! */
    event_register(apme_event_handler);

    /* Do the chatlog enable/disable stuff, warn user... */
    apme_chatlog_check();

    if (!aion_init())
    {
        con_printf("Unable to initialize the Aion subsystem.\n");
        return false; 
    }

    if (!chatlog_init())
    {
        con_printf("Error initializing the Chatlog parser.\n");
        return false;
    }

    /* Initialize the configuration file */
    if (!cfg_init())
    {
        con_printf("Error initializing the config subsystem.\n");
        /* Non-fatal for now -- we'll revert to defaults */
    }
    else
    {
        /* Apply the loaded configuration */
        apme_cfg_apply();
    }

    return true;
}
コード例 #13
0
ファイル: irc.c プロジェクト: doolse/wingsos
void main(int argc, char *argv[]) {
    FILE *stream;
    char *server = argv[1];
    int i;

    if (argc>1) {
        printf("Welcome to A-Jirc V1.0\n");
        if (!strchr(server, '/')) {
            char *newserve = malloc(strlen(server)+16);
            sprintf(newserve, "/dev/tcp/%s:6667", server);
            server = newserve;
        }
        stream = fopen(server, "r");
        if (!stream) {
            perror("AJirc");
            exit(1);
        }
        if (argc>2)
            nick = argv[2];
        con_init();
        printf("Connected to server\n");
        con_update();
        con_setscroll(0,con_ysize-2);
        con_gotoxy(0,con_ysize-2);
        printf("Ajirc V1.0 (c) J Maginnis & A Greenwood");
        for (i=39; i<con_xsize; i++) {
            putchar('-');
        }
        channel = makeChan();
        globsock = dup(fileno(stream));
        newThread(fromUser,STACK_DFL,NULL);
        newThread(outThread,256,&globsock);
        while (process(stream));
        printf("Connection closed by remote host!\n");
        con_end();
        printf("\x1b[0m\x1b[H\x1b[2J");
        exit(1);
    }
    printf("\x1b[0m\x1b[H\x1b[2J");
}
コード例 #14
0
ファイル: kmain.c プロジェクト: clandgraf/kdev
void kmain(uint32_t magic, multiboot_info_t * mbinfo)
{
    con_init();

    klog_info("Kernel Location:   0x%08x - 0x%08x\n", KERNEL_START, KERNEL_END);
    klog_info("Multiboot Version: %x\n", mbinfo->flags);
    klog_info("Memory (Low/High): 0x%08x/0x%08x\n", mbinfo->mem_lower, mbinfo->mem_upper);
    check_multiboot(magic, mbinfo);

    arch_init();
    mm_init(mbinfo);

    klog_info("Sepix %s-%s %s %s\n",
              BUILD_VERSION_BRANCH,
              BUILD_VERSION_REV,
              BUILD_VERSION_DATE,
              STRINGIFY(ARCH));

    task_init();
    arch_start();
    
    task_idle_fn();
}
コード例 #15
0
ファイル: tty_io.c プロジェクト: ChihMin/linux-0.11
// TTY终端初始化函数
// 初始化串口终端和控制台终端
void tty_init(void)
{
    // 初始化串行中断程序和串行接口1和2(serial.c)
	rs_init();
	con_init();     // 初始化控制台终端(console.c文件中)
}
コード例 #16
0
ファイル: conout.c プロジェクト: fmutant/scriptorium
void con_reset() {
    con_close();
    con_init ();
}
コード例 #17
0
ファイル: main.c プロジェクト: s1mme/OrbitOS
void start_kernel(struct multiboot *mbp, unsigned int magic,u32 esp)
 {
	 u32 initrd_location = *((u32*)mbp->mods_addr);
	 u32 initrd_end = *(u32*)(mbp->mods_addr+4);

	 __asm__ __volatile__("cli");
	 cpu_init();
	 placement_pointer = initrd_end;
	 vmmngr_initialize(mbp->mem_upper + mbp->mem_lower);	
	
	 kheap = _heapmngr_initialize(0x02000000, 0x20000000, 0x200000);

	 con_init();

	 init_IRQ();
	 time_init();
    
     _kbd_init_hook();
     /*setup_irq(2, &irq2); 
     setup_irq(3, &irq3 ); 
     setup_irq(4, &irq4 ); 
     setup_irq(5, &irq5 ); 

     setup_irq(8, &irq8 );
	*/
	 //auto_fpu();
	 task_initialize();
	 syscalls_install();
	 fs_root_initrd = install_initrd(initrd_location);
	
	 
	 //pci_inst_check();
	 //enable_pci_master(0,3,0);		//8139 need this
     struct request *info = 0;
	 probe_ide(info);
	 hd_init_hook_();
     putch('P');
     double test = 3.14444;
     printk("test ::: %d\n", test);
    //serial_install();

    //unsigned long cpu_khz = init_tsc();
   	//u32 *pf = (u32 *)0xffff0000;
	//*pf = 10;
	ext2_read_superblock();
	register_filesystem();

	__asm__ __volatile__("sti");
	//graphics_install_bochs(1024,768);
	//heaptest();
	//create_thread(test_task,1);
	while(1)
	{

	if(getch_polling() == 'i')
	{
	const char *filename = "test__2";
	
		//execve__((char*)filename,0,0);
		load_elf((char*)filename,0,0);
		//show_state();
		}
	}
}
コード例 #18
0
static int main(int argc, char *argv[])
{
	if (!PHYSFSX_init(argc, argv))
		return 1;
	con_init();  // Initialise the console

	setbuf(stdout, NULL); // unbuffered output via printf
#ifdef _WIN32
	freopen( "CON", "w", stdout );
	freopen( "CON", "w", stderr );
#endif

	if (CGameArg.SysShowCmdHelp) {
		print_commandline_help();

		return(0);
	}

	printf("\nType '%s -help' for a list of command-line options.\n\n", PROGNAME);

	PHYSFSX_listSearchPathContent();
	
	if (!PHYSFSX_checkSupportedArchiveTypes())
		return(0);

#if defined(DXX_BUILD_DESCENT_I)
	if (! PHYSFSX_contfile_init("descent.hog", 1))
#define DXX_NAME_NUMBER	"1"
#define DXX_HOGFILE_NAMES	"descent.hog"
#elif defined(DXX_BUILD_DESCENT_II)
	if (! PHYSFSX_contfile_init("descent2.hog", 1) && ! PHYSFSX_contfile_init("d2demo.hog", 1))
#define DXX_NAME_NUMBER	"2"
#define DXX_HOGFILE_NAMES	"descent2.hog or d2demo.hog"
#endif
	{
#if defined(__unix__) && !defined(__APPLE__)
#define DXX_HOGFILE_PROGRAM_DATA_DIRECTORY	\
			      "\t$HOME/.d" DXX_NAME_NUMBER "x-rebirth\n"	\
			      "\t" SHAREPATH "\n"
#else
#define DXX_HOGFILE_PROGRAM_DATA_DIRECTORY	\
				  "\tDirectory containing D" DXX_NAME_NUMBER "X\n"
#endif
#if (defined(__APPLE__) && defined(__MACH__)) || defined(macintosh)
#define DXX_HOGFILE_APPLICATION_BUNDLE	\
				  "\tIn 'Resources' inside the application bundle\n"
#else
#define DXX_HOGFILE_APPLICATION_BUNDLE	""
#endif
#define DXX_MISSING_HOGFILE_ERROR_TEXT	\
		"Could not find a valid hog file (" DXX_HOGFILE_NAMES ")\nPossible locations are:\n"	\
		DXX_HOGFILE_PROGRAM_DATA_DIRECTORY	\
		"\tIn a subdirectory called 'Data'\n"	\
		DXX_HOGFILE_APPLICATION_BUNDLE	\
		"Or use the -hogdir option to specify an alternate location."
		UserError(DXX_MISSING_HOGFILE_ERROR_TEXT);
	}

#if defined(DXX_BUILD_DESCENT_I)
	switch (PHYSFSX_fsize("descent.hog"))
	{
		case D1_MAC_SHARE_MISSION_HOGSIZE:
		case D1_MAC_MISSION_HOGSIZE:
			MacHog = 1;	// used for fonts and the Automap
			break;
	}
#endif

	load_text();

	//print out the banner title
#if defined(DXX_BUILD_DESCENT_I)
	con_printf(CON_NORMAL, "%s  %s", DESCENT_VERSION, g_descent_build_datetime); // D1X version
	con_printf(CON_NORMAL, "This is a MODIFIED version of Descent, based on %s.", BASED_VERSION);
	con_printf(CON_NORMAL, "%s\n%s",TXT_COPYRIGHT,TXT_TRADEMARK);
	con_printf(CON_NORMAL, "Copyright (C) 2005-2013 Christian Beckhaeuser");
#elif defined(DXX_BUILD_DESCENT_II)
	con_printf(CON_NORMAL, "%s%s  %s", DESCENT_VERSION, PHYSFSX_exists(MISSION_DIR "d2x.hog",1) ? "  Vertigo Enhanced" : "", g_descent_build_datetime); // D2X version
	con_printf(CON_NORMAL, "This is a MODIFIED version of Descent 2, based on %s.", BASED_VERSION);
	con_printf(CON_NORMAL, "%s\n%s",TXT_COPYRIGHT,TXT_TRADEMARK);
	con_printf(CON_NORMAL, "Copyright (C) 1999 Peter Hawkins, 2002 Bradley Bell, 2005-2013 Christian Beckhaeuser");
#endif

	if (CGameArg.DbgVerbose)
		con_puts(CON_VERBOSE, TXT_VERBOSE_1);
	
	ReadConfigFile();

	PHYSFSX_addArchiveContent();

	arch_init();

	select_tmap(CGameArg.DbgTexMap);

#if defined(DXX_BUILD_DESCENT_II)
	Lighting_on = 1;
#endif

	con_printf(CON_VERBOSE, "Going into graphics mode...");
	gr_set_mode(Game_screen_mode);

	// Load the palette stuff. Returns non-zero if error.
	con_printf(CON_DEBUG, "Initializing palette system..." );
#if defined(DXX_BUILD_DESCENT_I)
	gr_use_palette_table( "PALETTE.256" );
#elif defined(DXX_BUILD_DESCENT_II)
	gr_use_palette_table(D2_DEFAULT_PALETTE );
#endif

	con_printf(CON_DEBUG, "Initializing font system..." );
	gamefont_init();	// must load after palette data loaded.

#if defined(DXX_BUILD_DESCENT_II)
	con_printf( CON_DEBUG, "Initializing movie libraries..." );
	init_movies();		//init movie libraries
#endif

	show_titles();

	set_screen_mode(SCREEN_MENU);
#ifdef DEBUG_MEMORY_ALLOCATIONS
	/* Memdebug runs before global destructors, so it incorrectly
	 * reports as leaked any allocations that would be freed by a global
	 * destructor.  This local will force the newmenu globals to be
	 * reset before memdebug scans, which prevents memdebug falsely
	 * reporting them as leaked.
	 *
	 * External tools, such as Valgrind, know to run global destructors
	 * before checking for leaks, so this hack is only necessary when
	 * memdebug is used.
	 */
	struct hack_free_global_backgrounds
	{
		~hack_free_global_backgrounds()
		{
			newmenu_free_background();
		}
	};
	hack_free_global_backgrounds hack_free_global_background;
#endif

	con_printf( CON_DEBUG, "\nDoing gamedata_init..." );
	gamedata_init();

#if defined(DXX_BUILD_DESCENT_II)
#if DXX_USE_EDITOR
	if (GameArg.EdiSaveHoardData) {
		save_hoard_data();
		exit(1);
	}
	#endif
#endif

	if (CGameArg.DbgNoRun)
		return(0);

	con_printf( CON_DEBUG, "\nInitializing texture caching system..." );
	texmerge_init();		// 10 cache bitmaps

#if defined(DXX_BUILD_DESCENT_II)
	piggy_init_pigfile("groupa.pig");	//get correct pigfile
#endif

	con_printf( CON_DEBUG, "\nRunning game..." );
	init_game();

	get_local_player().callsign = {};

#if defined(DXX_BUILD_DESCENT_I)
	key_flush();
#elif defined(DXX_BUILD_DESCENT_II)
	//	If built with editor, option to auto-load a level and quit game
	//	to write certain data.
	#ifdef	EDITOR
	if (!GameArg.EdiAutoLoad.empty()) {
		Players[0].callsign = "dummy";
	} else
	#endif
#endif
	{
		if (!CGameArg.SysPilot.empty())
		{
			char filename[sizeof(PLAYER_DIRECTORY_TEXT) + CALLSIGN_LEN + 4];

			/* Step over the literal PLAYER_DIRECTORY_TEXT when it is
			 * present.  Point at &filename[0] when
			 * PLAYER_DIRECTORY_TEXT is absent.
			 */
			const auto b = &filename[-CGameArg.SysUsePlayersDir];
			snprintf(filename, sizeof(filename), PLAYER_DIRECTORY_STRING("%.12s"), CGameArg.SysPilot.c_str());
			/* The pilot name is never used after this.  Clear it to
			 * free the allocated memory, if any.
			 */
			CGameArg.SysPilot.clear();
			auto p = b;
			for (const auto &facet = std::use_facet<std::ctype<char>>(std::locale::classic()); char &c = *p; ++p)
			{
				c = facet.tolower(static_cast<uint8_t>(c));
			}
			auto j = p - filename;
			if (j < sizeof(filename) - 4 && (j <= 4 || strcmp(&filename[j - 4], ".plr"))) // if player hasn't specified .plr extension in argument, add it
			{
				strcpy(&filename[j], ".plr");
				j += 4;
			}
			if(PHYSFSX_exists(filename,0))
			{
				get_local_player().callsign.copy(b, std::distance(b, &filename[j - 4]));
				read_player_file();
				WriteConfigFile();
			}
		}
	}

#if defined(DXX_BUILD_DESCENT_II)
#if DXX_USE_EDITOR
	if (!GameArg.EdiAutoLoad.empty()) {
		/* Any number >= FILENAME_LEN works */
		Level_names[0].copy_if(GameArg.EdiAutoLoad.c_str(), GameArg.EdiAutoLoad.size());
		LoadLevel(1, 1);
	}
	else
#endif
#endif
	{
		Game_mode = GM_GAME_OVER;
		DoMenu();
	}

	while (window_get_front())
		// Send events to windows and the default handler
		event_process();
	
	// Tidy up - avoids a crash on exit
	{
		window *wind;

		show_menus();
		while ((wind = window_get_front()))
			window_close(wind);
	}

	WriteConfigFile();
	show_order_form();

	con_printf( CON_DEBUG, "\nCleanup..." );
	close_game();
	texmerge_close();
	gamedata_close();
	gamefont_close();
	Current_mission.reset();
	PHYSFSX_removeArchiveContent();

	return(0);		//presumably successful exit
}
コード例 #19
0
ファイル: CAENVMEDemoMain.c プロジェクト: abc6081/daq
int main(int argc, void *argv[]) 

{
CVBoardTypes  VMEBoard;
short         Link;
short         Device;
int32_t       BHandle;



if( (argc != 3) && (argc != 4) )
    {
    printf("Usage: CAENVMEDemo V1718 <VMEDevice>\n");
    printf("       CAENVMEDemo V2718 <VMEDevice> <VMELink>\n");
    exit(1);
    }
else 
    {
    if( strcmp((char*)argv[1], "V1718") == 0 )
        {
        if( argc == 3 )
            {
            VMEBoard = cvV1718;
            Device = atoi((const char*)argv[2]);
            Link = 0;
            }
        else
            {
            printf("       CAENVMEDemo V1718 <VMEDevice>\n");
            exit(1);
            }
        }
    else 
        {
        if( strcmp((char*)argv[1], "V2718") == 0 )
            {
            if( argc == 4 )
                {
                Device = atoi((const char*) argv[2]);
                Link = atoi((const char*) argv[3]);
                VMEBoard = cvV2718;	
                }
            else
                {
                printf("       CAENVMEDemo V2718 <VMEDevice> <VMELink>\n");
                exit(1);
                }
            }
        else
            {
            printf("Usage: CAENVMEDemo V1718 <VMEDevice>\n");
            printf("       CAENVMEDemo V2718 <VMEDevice> <VMELink>\n");
            exit(1);
            }
        }

    }

// Initialize the Board

if( CAENVME_Init(VMEBoard, Device, Link, &BHandle) != cvSuccess ) 
    {
    printf("\n\n Error opening the device\n");
    exit(1);
    }


con_init() ;

// CAENVME_SetFIFOMode(BHandle,1) ;
	
CaenVmeManual(BHandle,1) ;

con_end() ;

CAENVME_End(BHandle);
}
コード例 #20
0
ファイル: vnlsvc.c プロジェクト: yoursunny/VNL
int main(int argc, char* argv[]) {
  int opt;
  bool vns_console = false;
  char* command_file = NULL; char* pid_file = NULL;
  int i, ifcount = 0; struct vnlif iflist[vnlif_maxcount];

  int command_fd, command_eth = -1; FILE* pid_fd;
  struct pollfd pollfds[2+2*vnlif_maxcount]; int pollres;
  char buffer[MSGSIZE]; int len;
  char* pktbuffer = buffer + MSGHDRSIZE;
  c_base* vnsbasehdr = (c_base*)buffer;
  c_hwinfo* vnshwinfo = (c_hwinfo*)buffer;
  c_packet_header* vnspkthdr = (c_packet_header*)buffer;

// ---------------- parse command options ----------------
  while ((opt = getopt(argc, argv, "si:c:p:")) != -1) {
    switch (opt) {
    case 's': vns_console = true; break;
    case 'i':
      if (ifcount < vnlif_maxcount) {
        if (!vnlif_parse(iflist + ifcount, optarg)) die("vnlif_parse");
      } else {
        die("cmdline vnlif_maxcount");
      }
      ++ifcount;
      break;
    case 'c': command_file = optarg; break;
    case 'p': pid_file = optarg; break;
    }
  }

  if (ifcount == 0 || command_file == NULL || pid_file == NULL) {
    printf("vnlsvc: Virtual Network Lab Service\nTAP-UDP: vnlsvc -i eth0/tap0/1a:8e:22:b1:da:f1/198.51.100.1#255.255.255.0/192.0.2.1:2001/192.0.2.2:2001/ -c /tmp/command.pipe -p /tmp/vnltun.pid\nVNSconsole-UDP: vnlsvc -s -i eth0//1a:8e:22:b1:da:f1/198.51.100.1#255.255.255.0/192.0.2.1:2001/192.0.2.2:2001/ -c /tmp/command.pipe -p /tmp/vnltun.pid\n");
    exit(1);
  }

// ---------------- open files and sockets ----------------
  command_fd = open(command_file, O_RDONLY | O_NONBLOCK);
  if (command_fd < 0) die("command open");

  pollfds[0].fd = 0; pollfds[0].events = vns_console ? POLLIN : 0;
  pollfds[1].fd = command_fd; pollfds[1].events = POLLIN;
  for (i = 0; i < ifcount; ++i) {
    pollfds[2+i].fd = iflist[i].udp_fd
      = udp_open(&(iflist[i].tip), &(iflist[i].rtip));
    pollfds[2+i].events = POLLIN;
    if (!vns_console) {
      pollfds[2+ifcount+i].fd = iflist[i].tap_fd = tap_open(iflist[i].tapname);
      pollfds[2+ifcount+i].events = POLLIN;
    }
  }
  //pollfds: 0=stdin, 1=command pipe, 2..2+ifcount-1=UDP, 2+ifcount..2+2*ifcount-1=TAP

// ---------------- initialize ----------------
  pid_fd = fopen(pid_file, "w");
  if (pid_fd == NULL) die("pid output");
  fprintf(pid_fd, "%d", getpid());
  fclose(pid_fd);

  srand(time(NULL));

  if (vns_console) {
    con_init();
    vns_wAuthReq(buffer); con_write(buffer);
  }

// ---------------- main poll loop ----------------
  while (1) {
    pollres = poll(pollfds, 2+(vns_console?1:2)*ifcount, -1);
    if (pollres == -1) die("poll");
    else if (pollres == 0) { perror("poll timeout"); continue; }

/*
    for (i = 0; i < 2+(vns_console?1:2)*ifcount; ++i) {
      if (pollfds[i].revents & (POLLERR | POLLHUP | POLLNVAL)) {
        FILE* dbglog = fopen("/tmp/vnlsvc.debug.log","a");
        fprintf(dbglog,"%d %d %d %x\n",time(NULL),getpid(),i,pollfds[i].revents);
        fclose(dbglog);
      }
    }
*/

// ---------------- VNS protocol, console to UDP ----------------
    if (vns_console && (pollfds[0].revents & POLLIN)) {
      if (con_read(buffer)) {
        switch (vns_getType(buffer)) {
        case VNS_AUTH_REPLY:
          vns_wAuthStatus(buffer); con_write(buffer);
          break;
        case VNSOPEN:
          iflist_hwinfo(vnshwinfo, iflist, ifcount);
          con_write(buffer);
          break;
        case VNSPACKET:
          i = iflist_find(iflist, ifcount, vnspkthdr->mInterfaceName);
          if (i < 0) break;
          len = ntohl(vnspkthdr->mLen) - sizeof(c_packet_header);
          if (lossy_filter(iflist[i].lossy)) {
            udp_write(iflist[i].udp_fd, pktbuffer, len, &(iflist[i].rtip));
          }
          break;
        }
      }
    }
// ---------------- console error ----------------
    if (vns_console && (pollfds[0].revents & (POLLERR | POLLHUP))) {
      die("console error");
    }

// ---------------- setlossy command ----------------
    if (pollfds[1].revents & POLLIN) {
      if (command_eth < 0 && 1 == read(command_fd, buffer, 1)) {
        command_eth = buffer[0];
      }
      if (1 == read(command_fd, buffer, 1) && command_eth < ifcount) {
        iflist[command_eth].lossy = buffer[0];
      }
    }
    if (pollfds[1].revents & POLLHUP) {
      command_eth = -1;
      close(command_fd);
      pollfds[1].fd = command_fd = open(command_file, O_RDONLY | O_NONBLOCK);
      if (command_fd < 0) die("command reopen");
    }

    for (i = 0; i < ifcount; ++i) {
// ---------------- UDP to console/TAP ----------------
      if (pollfds[2+i].revents & POLLIN) {
        len = udp_read(iflist[i].udp_fd, pktbuffer, &(iflist[i].rtip));
        if (len > 0) {
          if (vns_console) {
            vns_wPacketHdr(buffer, len, iflist[i].ifname);
            con_write(buffer);
          } else {
            tap_write(iflist[i].tap_fd, pktbuffer, len);
          }
        }
      }
// ---------------- UDP error ----------------
      if (pollfds[2+i].revents & POLLERR) {
        int sockerror; socklen_t socklen = sizeof(int);
        getsockopt(iflist[i].udp_fd, SOL_SOCKET, SO_ERROR, &sockerror, &socklen);
      }
// ---------------- TAP to UDP ----------------
      if (!vns_console && (pollfds[2+ifcount+i].revents & POLLIN)) {
        len = tap_read(iflist[i].tap_fd, pktbuffer);
        if (len > 0 && lossy_filter(iflist[i].lossy)) {
          udp_write(iflist[i].udp_fd, pktbuffer, len, &(iflist[i].rtip));
        }
      }
    }
  }
}
コード例 #21
0
ファイル: console.c プロジェクト: ashmew2/kolibriosSVN
static inline void CONSOLE_INIT(char title[])
{

if(console_init_command)return;

struct_import *imp;

imp = cofflib_load("/sys/lib/console.obj");
if (imp == NULL)
	exit();

con_init = ( _stdcall  void (*)(unsigned, unsigned, unsigned, unsigned, const char*)) 
		cofflib_procload (imp, "con_init");
if (con_init == NULL)
	exit();

_printf = ( _cdecl void (*)(const char*,...))
		cofflib_procload (imp, "con_printf");
if (_printf == NULL)
	exit();
	
_print = ( _cdecl void (*)(const char*))
		cofflib_procload (imp, "con_write_asciiz");
if (_printf == NULL)
	exit();

_exit = ( _stdcall void (*)(char))
		cofflib_procload (imp, "con_exit");
if (_exit == NULL)
	exit();

_gets = ( _stdcall void (*)(char*, int))
		cofflib_procload (imp, "con_gets");
if (_gets == NULL)
	exit();

_getch = ( _stdcall int (*)(void))
		cofflib_procload (imp, "con_getch2");
if (_getch == NULL)
	exit();

con_get_font_height = ( _stdcall int (*)(void))
		cofflib_procload (imp, "con_get_font_height");
if (con_get_font_height == NULL)
	exit();

con_set_cursor_height = ( _stdcall int (*)(int))
		cofflib_procload (imp, "con_set_cursor_height");
if (con_set_cursor_height == NULL)
	exit();

con_get_flags = ( _stdcall unsigned (*)(void))
		cofflib_procload (imp, "con_get_flags");
if (con_get_flags == NULL)
	exit();

con_set_flags = ( _stdcall unsigned (*)(unsigned))
		cofflib_procload (imp, "con_set_flags");
if (con_set_flags == NULL)
	exit();

con_cls = ( _stdcall void (*)(void))
		cofflib_procload (imp, "con_cls");
if (con_cls == NULL)
	exit();

con_init(-1, -1, -1, -1, title);

console_init_command = TRUE;
}
コード例 #22
0
ファイル: engine.c プロジェクト: septag/darkhammer
result_t eng_init(const struct init_params* params)
{
    result_t r = RET_OK;

    ASSERT(g_eng == NULL);
    g_eng = (struct engine*)ALLOC(sizeof(struct engine), 0);
    if (g_eng == 0)
        return err_printn(__FILE__, __LINE__, RET_OUTOFMEMORY);
    memset(g_eng, 0x00, sizeof(struct engine));

    eng_zero();

    memcpy(&g_eng->params, params, sizeof(struct init_params));

    hw_getinfo(&g_eng->hwinfo, HWINFO_ALL);

    /* console (before anything else) */
    if (BIT_CHECK(params->flags, ENG_FLAG_CONSOLE))	{
		r |= con_init(params->console_lines_max);
		if (IS_FAIL(r))
			return RET_FAIL;
		log_outputfunc(TRUE, con_log, NULL);
    }

    /* show build options */
#if !defined(FULL_VERSION)
#error "must define FULL_VERSION macro"
#endif

    time_t raw_tm;
    time(&raw_tm);

    log_printf(LOG_TEXT, "init darkhammer engine v%s build[%s, %s, %s, %s], time: %s", 
        FULL_VERSION,
#if defined(_DEBUG_)
    		"debug"
#else
    		"release"
#endif
    		,
#if defined(_PROFILE_)
    		"profile"
#else
    		"no-profile"
#endif
    		,
#if defined(_X86_)
    		"x86"
#elif defined(_X64_)
    		"x64"
#endif
    		,
#if defined(_ENABLEASSERT_)
    		"assert"
#else
    		"no-assert"
#endif
            , asctime(localtime(&raw_tm)));

    /* hardware info */
    hw_printinfo(&g_eng->hwinfo, HWINFO_ALL);

    size_t tmp_sz = params->dev.buffsize_tmp;
    size_t data_sz = data_sz = params->dev.buffsize_data;
    tmp_sz = tmp_sz != 0 ? ((size_t)tmp_sz*1024) : FRAME_STACK_SIZE;
    data_sz = data_sz != 0 ? ((size_t)data_sz*1024) : DATA_SIZE;

    /* allocators */
    /* dynamic allocator for data in dev (editor) mode, stack allocator in game (normal) mode */
    if (BIT_CHECK(params->flags, ENG_FLAG_OPTIMIZEMEMORY))   {
        /* lsr (load-stay-resident) allocator for essential engine data */
        r |= mem_stack_create(mem_heap(), &g_eng->lsr_stack, LSR_SIZE, MID_DATA);
        mem_stack_bindalloc(&g_eng->lsr_stack, &g_eng->lsr_alloc);

        r |= mem_freelist_create(mem_heap(), &g_eng->data_freelist, data_sz, MID_DATA);
        mem_freelist_bindalloc(&g_eng->data_freelist, &g_eng->data_alloc);
    }   else    {
        mem_heap_bindalloc(&g_eng->data_alloc);
        mem_heap_bindalloc(&g_eng->lsr_alloc);

        g_eng->data_alloc.alloc_fn = eng_allocfn_data;
        g_eng->data_alloc.alignedalloc_fn = eng_alignedallocfn_data;
        g_eng->lsr_alloc.alloc_fn = eng_allocfn_lsr;
        g_eng->lsr_alloc.alignedalloc_fn = eng_alignedallocfn_lsr;

        r = RET_OK;
    }

    if (IS_FAIL(r)) {
        err_print(__FILE__, __LINE__, "engine init failed: out of memory for allocators");
        return RET_FAIL;
    }

    /* timer manager and frame timer */
    g_eng->timer = timer_createinstance(TRUE);

    /* add engine's own data path to file-mgr */
    if (params->data_path != NULL)   {
        char data_path_ext[DH_PATH_MAX];
        path_getfileext(data_path_ext, params->data_path);
        if (str_isequal_nocase(data_path_ext, "pak"))    {
            if (IS_FAIL(pak_open(&g_eng->data_pak, mem_heap(), params->data_path, 0)))    {
                err_print(__FILE__, __LINE__, "engine init: could not open data pak");
                return RET_FAIL;
            }
        }   else   {
            if (!util_pathisdir(params->data_path)) {
                err_print(__FILE__, __LINE__, "engine init: data path is not valid");
                return RET_FAIL;
            }
            fio_addvdir(params->data_path, FALSE);
        }
        /* assume that share directory is same as data dir */
        path_getdir(g_eng->share_dir, params->data_path);
    }   else    {
        char data_path[DH_PATH_MAX];
        char share_dir[DH_PATH_MAX];
#ifndef SHARE_DIR
        char exe_dir[DH_PATH_MAX];
        path_join(share_dir, util_getexedir(exe_dir), "..", NULL);
        path_norm(share_dir, share_dir);
#else
        path_norm(share_dir, SHARE_DIR);
#endif
        path_join(data_path, share_dir, "data", NULL);
        if (!util_pathisdir(data_path)) {
            err_print(__FILE__, __LINE__, "engine init: data path is not valid");
            return RET_FAIL;
        }

        fio_addvdir(data_path, FALSE);  /* set default (config.h configured on build) data dir */
        strcpy(g_eng->share_dir, share_dir);
    }

    uint rs_flags = 0;
    /* activate hot loading in DEV mode */
    rs_flags |= BIT_CHECK(params->flags, ENG_FLAG_DEV) ? RS_FLAG_HOTLOADING : 0;
    if (!BIT_CHECK(params->flags, ENG_FLAG_DISABLEBGLOAD))  {
        rs_flags |= RS_FLAG_PREPARE_BGLOAD;
    }

    /* task manager */
    uint thread_cnt = maxui(g_eng->hwinfo.cpu_core_cnt - 1, 1);
    r = tsk_initmgr(thread_cnt, 0, tmp_sz, 0);
    if (IS_FAIL(r)) {
        err_print(__FILE__, __LINE__, "engine init failed: could not init task-mgr");
        return RET_FAIL;
    }
    struct allocator* tmp_alloc = tsk_get_tmpalloc(0);
    A_SAVE(tmp_alloc);

    /* resource manager (with only 1 thread for multi-thread loading) */
    r = rs_initmgr(rs_flags, 1);
    if (IS_FAIL(r)) {
        err_print(__FILE__, __LINE__, "engine init failed: could not init res-mgr");
        return RET_FAIL;
    }
    rs_set_dataalloc(&g_eng->lsr_alloc);

    /* graphics renderer */
    r = gfx_init(&params->gfx);
    if (IS_FAIL(r)) {
        err_print(__FILE__, __LINE__, "engine init failed: could not init gfx");
        return RET_FAIL;
    }

    /* debug HUD */
    r = hud_init(BIT_CHECK(params->flags, ENG_FLAG_CONSOLE));
    if (IS_FAIL(r))	{
        err_print(__FILE__, __LINE__, "engine init failed: could not init debug-hud");
        return RET_FAIL;
    }

    /* Physics */
    if (!BIT_CHECK(params->flags, ENG_FLAG_DISABLEPHX)) {
        r = phx_init(params);
        if (IS_FAIL(r)) {
            err_print(__FILE__, __LINE__, "engine init failed: could not init physics");
            return RET_FAIL;
        }
    }

    /* component manager */
    r = cmp_initmgr();
    if (IS_FAIL(r)) {
        err_print(__FILE__, __LINE__, "engine init failed: could not init cmp-mgr");
        return RET_FAIL;
    }
    cmp_set_globalalloc(&g_eng->data_alloc, tsk_get_tmpalloc(0));

    /* world manager */
    r = wld_initmgr();
    if (IS_FAIL(r)) {
        err_print(__FILE__, __LINE__, "engine init failed: could not init world-mgr");
        return RET_FAIL;
    }

    /* scene manager */
    r = scn_initmgr();
    if (IS_FAIL(r)) {
        err_print(__FILE__, __LINE__, "engine init failed: could not init scene-mgr");
        return RET_FAIL;
    }

    /* init lua */
    r = sct_init(&params->sct, BIT_CHECK(params->flags, ENG_FLAG_DEV) ? TRUE : FALSE);
    if (IS_FAIL(r)) {
        err_print(__FILE__, __LINE__, "engine init failed: could not init script engine");
        return RET_FAIL;
    }

    /* web-server */
#if defined(_PROFILE_)
    r = prf_initmgr();
    if (IS_FAIL(r))	{
    	log_print(LOG_WARNING, "profiler manager init failed: service will not be available");
    	prf_releasemgr();
    }
#endif

    /* lod-scheme */
    r = lod_initmgr();
    if (IS_FAIL(r)) {
        err_print(__FILE__, __LINE__, "engine init failed: could not init lod-scheme");
        return RET_FAIL;
    }

    /* init basic resources */
    r = rs_init_resources();
    if (IS_FAIL(r)) {
        err_print(__FILE__, __LINE__, "engine init failed: coult not init res-mgr resources");
        return RET_FAIL;
    }

    /* switch back to normal data allocator */
    rs_set_dataalloc(&g_eng->data_alloc);

    /* enable background-loading if res-mgr is prepared for (see above rs_initmgr) */
    if (gfx_check_feature(GFX_FEATURE_THREADED_CREATES))
        rs_add_flags(RS_FLAG_BGLOADING);
    log_print(LOG_TEXT, "init ok: ready.");

    /* init world vars */
    eng_world_regvars();

    /* engine specific console commnads */
    con_register_cmd("showfps", eng_console_showfps, NULL, "showfps [1*/0]");
    con_register_cmd("showft", eng_console_showft, NULL, "showft [1*/0]");
    con_register_cmd("showgraph", eng_console_showgraph, NULL, "showgraph [ft][fps][drawcalls]");
    con_register_cmd("lockfps", eng_console_lockfps, NULL, "lockfps [fps]");

    /* execute console commands - should be the final stage if initialization */
    if (BIT_CHECK(params->flags, ENG_FLAG_CONSOLE))	{
		for (uint i = 0; i < params->console_cmds_cnt; i++)	{
			con_exec(params->console_cmds + i*128);
		}
    }

    A_LOAD(tmp_alloc);
    return RET_OK;
}
コード例 #23
0
void tty_init(void)
{
	rs_init(); // initializes console interupts, see kernel/console.c
	con_init(); // kernel/serial.c
}
コード例 #24
0
ファイル: inferno.c プロジェクト: CDarrow/DXX-Retro
int main(int argc, char *argv[])
{
	mem_init();
#ifdef __LINUX__
	error_init(NULL);
#else
	error_init(msgbox_error);
	set_warn_func(msgbox_warning);
#endif
	PHYSFSX_init(argc, argv);
	con_init();  // Initialise the console

	setbuf(stdout, NULL); // unbuffered output via printf
#ifdef _WIN32
	freopen( "CON", "w", stdout );
	freopen( "CON", "w", stderr );
#endif

	if (GameArg.SysShowCmdHelp) {
		print_commandline_help();

		return(0);
	}

	printf("\nType %s -help' for a list of command-line options.\n\n", PROGNAME);

	PHYSFSX_listSearchPathContent();
	
	if (!PHYSFSX_checkSupportedArchiveTypes())
		return(0);

	if (! PHYSFSX_contfile_init("descent2.hog", 1)) {
		if (! PHYSFSX_contfile_init("d2demo.hog", 1))
#define DXX_NAME_NUMBER	"2"
#define DXX_HOGFILE_NAMES	"descent2.hog or d2demo.hog"
#if defined(__unix__) && !defined(__APPLE__)
#define DXX_HOGFILE_PROGRAM_DATA_DIRECTORY	\
			      "\t$HOME/.d" DXX_NAME_NUMBER "x-rebirth\n"	\
			      "\t" SHAREPATH "\n"
#else
#define DXX_HOGFILE_PROGRAM_DATA_DIRECTORY	\
				  "\tDirectory containing D" DXX_NAME_NUMBER "X\n"
#endif
#if (defined(__APPLE__) && defined(__MACH__)) || defined(macintosh)
#define DXX_HOGFILE_APPLICATION_BUNDLE	\
				  "\tIn 'Resources' inside the application bundle\n"
#else
#define DXX_HOGFILE_APPLICATION_BUNDLE	""
#endif
#define DXX_MISSING_HOGFILE_ERROR_TEXT	\
		"Could not find a valid hog file (" DXX_HOGFILE_NAMES ")\nPossible locations are:\n"	\
		DXX_HOGFILE_PROGRAM_DATA_DIRECTORY	\
		"\tIn a subdirectory called 'Data'\n"	\
		DXX_HOGFILE_APPLICATION_BUNDLE	\
		"Or use the -hogdir option to specify an alternate location."
		Error(DXX_MISSING_HOGFILE_ERROR_TEXT);
	}

	load_text();

	//print out the banner title
	con_printf(CON_NORMAL, "%s%s  %s\n", DESCENT_VERSION, PHYSFSX_exists(MISSION_DIR "d2x.hog",1) ? "  Vertigo Enhanced" : "", g_descent_build_datetime); // D2X version
	con_printf(CON_NORMAL, "This is a MODIFIED version of Descent 2, based on %s.\n", BASED_VERSION);
	con_printf(CON_NORMAL, "%s\n%s\n",TXT_COPYRIGHT,TXT_TRADEMARK);
	con_printf(CON_NORMAL, "Copyright (C) 1999 Peter Hawkins, 2002 Bradley Bell, 2005-2011 Christian Beckhaeuser\n\n");

	if (GameArg.DbgVerbose)
		con_printf(CON_VERBOSE,"%s%s", TXT_VERBOSE_1, "\n");
	
	ReadConfigFile();

	PHYSFSX_addArchiveContent();

	arch_init();

	select_tmap(GameArg.DbgTexMap);

	Lighting_on = 1;

	con_printf(CON_VERBOSE, "Going into graphics mode...\n");
	gr_set_mode(Game_screen_mode);

	// Load the palette stuff. Returns non-zero if error.
	con_printf(CON_DEBUG, "Initializing palette system...\n" );
	gr_use_palette_table(D2_DEFAULT_PALETTE );

	con_printf(CON_DEBUG, "Initializing font system...\n" );
	gamefont_init();	// must load after palette data loaded.

	set_default_handler(standard_handler);

	con_printf( CON_DEBUG, "Initializing movie libraries...\n" );
	init_movies();		//init movie libraries

	show_titles();

	set_screen_mode(SCREEN_MENU);

	con_printf( CON_DEBUG, "\nDoing gamedata_init..." );
	gamedata_init();

	#ifdef EDITOR
	if (GameArg.EdiSaveHoardData) {
		save_hoard_data();
		exit(1);
	}
	#endif

	if (GameArg.DbgNoRun)
		return(0);

	con_printf( CON_DEBUG, "\nInitializing texture caching system..." );
	texmerge_init( 10 );		// 10 cache bitmaps

	piggy_init_pigfile("groupa.pig");	//get correct pigfile

	con_printf( CON_DEBUG, "\nRunning game...\n" );
	init_game();

	Players[Player_num].callsign[0] = '\0';

	//	If built with editor, option to auto-load a level and quit game
	//	to write certain data.
	#ifdef	EDITOR
	if (GameArg.EdiAutoLoad) {
		strcpy(Auto_file, GameArg.EdiAutoLoad);
		strcpy(Players[0].callsign, "dummy");
	} else
	#endif
	{
		if(GameArg.SysPilot)
		{
			char filename[32] = "";
			int j;

			if (GameArg.SysUsePlayersDir)
				strcpy(filename, "Players/");
			strncat(filename, GameArg.SysPilot, 12);
			filename[8 + 12] = '\0';	// unfortunately strncat doesn't put the terminating 0 on the end if it reaches 'n'
			for (j = GameArg.SysUsePlayersDir? 8 : 0; filename[j] != '\0'; j++) {
				switch (filename[j]) {
					case ' ':
						filename[j] = '\0';
				}
			}
			if(!strstr(filename,".plr")) // if player hasn't specified .plr extension in argument, add it
				strcat(filename,".plr");
			if(PHYSFSX_exists(filename,0))
			{
				strcpy(strstr(filename,".plr"),"\0");
				strcpy(Players[Player_num].callsign, GameArg.SysUsePlayersDir? &filename[8] : filename);
				read_player_file();
				WriteConfigFile();
			}
		}
	}

#ifdef EDITOR
	if (GameArg.EdiAutoLoad) {
		strcpy((char *)&Level_names[0], Auto_file);
		LoadLevel(1, 1);
	}
	else
#endif
	{
		Game_mode = GM_GAME_OVER;
		DoMenu();
	}

	setjmp(LeaveEvents);
	while (window_get_front())
		// Send events to windows and the default handler
		event_process();
	
	// Tidy up - avoids a crash on exit
	{
		window *wind;

		show_menus();
		while ((wind = window_get_front()))
			window_close(wind);
	}

	WriteConfigFile();
	show_order_form();

	con_printf( CON_DEBUG, "\nCleanup...\n" );
	close_game();
	texmerge_close();
	gamedata_close();
	gamefont_close();
	free_text();
	args_exit();
	newmenu_free_background();
	free_mission();
	PHYSFSX_removeArchiveContent();

	return(0);		//presumably successful exit
}
コード例 #25
0
ファイル: main.c プロジェクト: Zyrter/super-osd
int main()
{
	long int delay;
	int brg;
	// Call the various initialization functions.
	init_osd();
	setup_pll();
 	setup_io();
 	setup_int();
	init_gfx(1);
	// Turn on doze, with a 1:1 ratio.
	CLKDIVbits.DOZEN = 0;
	CLKDIVbits.DOZE = 0b000;
	// Start in console mode. Print startup messages.
	con_init();
	con_rolling = 0;
	con_puts("Super OSD v3.2-lite", 0);
	con_puts("dsPIC33F side", 0);
	con_puts("Copr. 2010 Tom O.", 0); ;
	con_puts("COMPILED FOR: ENGLISH", 0);
	con_puts("", 0); 
	con_puts("Booting kernel    [ OK ]", 0);
	con_puts("Verify 24F        [ OK ]", 0);
	con_puts("Verify 33F        [ OK ]", 0);
	con_puts("Switch to hi res  [ OK ]", 0);
	init_gfx(0);
	if(mem_test_full())
	{
		con_puts("VRAM test         [ OK ]", 0);
	}
	else
	{
		con_puts("VRAM test         [FAIL]", 0);
		con_puts("Check memory soon!      ", 0);
		// Show warning for some time
		delay = 2000000;
		while(delay--); 
	}
	// Clear graphics buffers of any memory test data remaining.
	init_gfx(0);
	con_puts("Init UART         [ OK ]", 0);
	// BUG: occasionally resets processor on start up
	//interface_init_uart();
	//brg = interface_set_baudrate(1843200);
	//sprintf(temp, "BRG=%d", brg);
	//con_puts(temp, 0);
	/*
	con_puts("PC detect...      [FAIL]", 0);
	con_puts("GPS detect...     [ OK ]", 0);
	con_puts("SPI initialized   [ OK ]", 0);
	con_puts("Found flash mem   [ OK ]", 0);
	con_puts("  Size: 2048 KB   [ OK ]", 0);
	con_puts("USB not supported [SKIP]", 0);
	con_puts("Init GPS          [ OK ]", 0);
	con_puts("Test I2C          [ OK ]", 0);
	con_puts("  Xbee Adap. 2.0  [ OK ]", 0);
	con_puts("  LSM303 acc      [ OK ]", 0);
	con_puts("  LSM303 mag      [ OK ]", 0);
	con_puts("  ITG3200 gyro    [FAIL]", 0);
	con_puts("Loading settings  [ OK ]", 0);
	con_puts("Init splash       [ OK ]", 0);
	*/	
	// Demo HUD.
	//buffer_mode(0);
	con_puts("Launching hud_demo", 0);
	delayhowlong = 10000;
	hud_demo();
}
コード例 #26
0
ファイル: taskConsole.c プロジェクト: spel-uchile/SUCHAI
______________________________________________________________________________\n\n";


//"\n\n====== WELCOME TO THE SUCHAI CONSOLE - PRESS ANY KEY TO START ======\n\r"

void taskConsole(void *param)
{
#if (SCH_TCONSOLE_VERBOSE)
    printf(">>[Console] Started\r\n");
#endif

    //char ret[10];

    const unsigned int Delayms = 250 / portTICK_RATE_MS;
    DispCmd NewCmd;
    NewCmd.idOrig = SCH_TCONSOLE_IDORIG; /* Consola */
    NewCmd.cmdId = CMD_CMDNULL;  /* cmdNULL */
    NewCmd.param = 0;

    /*Avoid the acummulation of commands while the SUCHAI is still deploying.. */
//    #if (SCH_THOUSEKEEPING_USE == 1)
//        portTickType xLastWakeTime = xTaskGetTickCount();
//        portTickType check_deployment_time = (10000) / portTICK_RATE_MS;      /* check every 10sec  */
//        while( TRUE ){            
//            /* TODO: Infinite loop if EEPROM is not onboard */
//            if( sta_get_BusStateVar(sta_dep_ant_deployed)==1 ){
//                break;
//            }
//            vTaskDelayUntil(&xLastWakeTime, check_deployment_time);
//        }
//    #endif

    /* Initializing console */
    con_init();

#if (SCH_TCONSOLE_VERBOSE>=1)
    __delay_ms(500);    //helps printing a cleaner banner (avoid interruption)
    printf((char *)console_baner);
#endif

    while(1)
    {
        vTaskDelay(Delayms);     //just delay is enough
        //vTaskDelayUntil(&xLastWakeTime, Delayms);

        /* Parsing command - return CmdDisp structure*/
        NewCmd = con_cmd_handler();

        /* cmdId = 0xFFFF means no new command */
        if(NewCmd.cmdId != CMD_CMDNULL)
        {
            printf("\r\n");

            #if (SCH_TCONSOLE_VERBOSE >=1)
                /* Print the command code */
//                sprintf( ret, "0x%X", (unsigned int)NewCmd.cmdId );
//                con_printf("[Console] Se genera comando: ");
//                con_printf(ret); con_printf("\n\0");
                printf("[Console] Se genera comando: 0x%X \r\n", (unsigned int)NewCmd.cmdId);
            #endif

            /* Queue NewCmd - Blocking */
            xQueueSend(dispatcherQueue, &NewCmd, portMAX_DELAY);
        }        
    }
}
コード例 #27
0
ファイル: manager.c プロジェクト: gawallsibya/BIT_C-CPP
void ma_init()
{
	con_init(&g_arr);	//dlist_init(&g_list);
	init_queue(&g_queue);
}
コード例 #28
0
ファイル: inferno.c プロジェクト: CDarrow/Spectator-JinX
int main(int argc, char *argv[])
{
	mem_init();
#ifdef __LINUX__
	error_init(NULL, NULL);
#else
	error_init(msgbox_error, NULL);
	set_warn_func(msgbox_warning);
#endif
	PHYSFSX_init(argc, argv);
	con_init();  // Initialise the console

	setbuf(stdout, NULL); // unbuffered output via printf
#ifdef _WIN32
	freopen( "CON", "w", stdout );
	freopen( "CON", "w", stderr );
#endif

	if (GameArg.SysShowCmdHelp) {
		print_commandline_help();
		set_exit_message("");

		return(0);
	}

	printf("\nType %s -help' for a list of command-line options.\n\n", PROGNAME);

	PHYSFSX_listSearchPathContent();
	
	if (!PHYSFSX_checkSupportedArchiveTypes())
		return(0);

	if (! PHYSFSX_contfile_init("descent.hog", 1))
		Error("Could not find a valid hog file (descent.hog)\nPossible locations are:\n"
#if defined(__unix__) && !defined(__APPLE__)
			  "\t$HOME/.d1x-rebirth\n"
			  "\t" SHAREPATH "\n"
#else
			  "\tDirectory containing D1X\n"
#endif
			  "\tIn a subdirectory called 'Data'\n"
#if (defined(__APPLE__) && defined(__MACH__)) || defined(macintosh)
			  "\tIn 'Resources' inside the application bundle\n"
#endif
			  "Or use the -hogdir option to specify an alternate location.");
	
	switch (PHYSFSX_fsize("descent.hog"))
	{
		case D1_MAC_SHARE_MISSION_HOGSIZE:
		case D1_MAC_MISSION_HOGSIZE:
			MacHog = 1;	// used for fonts and the Automap
			break;
	}

	load_text();

	//print out the banner title
	con_printf(CON_NORMAL, "%s", DESCENT_VERSION); // D1X version
	con_printf(CON_NORMAL, "  %s %s\n", __DATE__,__TIME__);
	con_printf(CON_NORMAL, "This is a MODIFIED version of Descent, based on %s.\n", BASED_VERSION);
	con_printf(CON_NORMAL, "%s\n%s\n",TXT_COPYRIGHT,TXT_TRADEMARK);
	con_printf(CON_NORMAL, "Copyright (C) 2005-2011 Christian Beckhaeuser\n\n");

	if (GameArg.DbgVerbose)
		con_printf(CON_VERBOSE,"%s%s", TXT_VERBOSE_1, "\n");
	
	ReadConfigFile();

	PHYSFSX_addArchiveContent();

	arch_init();

	select_tmap(GameArg.DbgTexMap);

	con_printf(CON_VERBOSE, "Going into graphics mode...\n");
	gr_set_mode(Game_screen_mode);

	// Load the palette stuff. Returns non-zero if error.
	con_printf(CON_DEBUG, "Initializing palette system...\n" );
	gr_use_palette_table( "PALETTE.256" );

	con_printf(CON_DEBUG, "Initializing font system...\n" );
	gamefont_init();	// must load after palette data loaded.

	set_default_handler(standard_handler);

	show_titles();

	set_screen_mode(SCREEN_MENU);

	con_printf( CON_DEBUG, "\nDoing gamedata_init..." );
	gamedata_init();

	if (GameArg.DbgNoRun)
		return(0);

	con_printf( CON_DEBUG, "\nInitializing texture caching system..." );
	texmerge_init( 10 );		// 10 cache bitmaps

	con_printf( CON_DEBUG, "\nRunning game...\n" );
	init_game();

	Players[Player_num].callsign[0] = '\0';

	key_flush();

	if(GameArg.SysPilot)
	{
		char filename[32] = "";
		int j;

		if (GameArg.SysUsePlayersDir)
			strcpy(filename, "Players/");
		strncat(filename, GameArg.SysPilot, 12);
		filename[8 + 12] = '\0';	// unfortunately strncat doesn't put the terminating 0 on the end if it reaches 'n'
		for (j = GameArg.SysUsePlayersDir? 8 : 0; filename[j] != '\0'; j++) {
			switch (filename[j]) {
				case ' ':
					filename[j] = '\0';
			}
		}
		if(!strstr(filename,".plr")) // if player hasn't specified .plr extension in argument, add it
			strcat(filename,".plr");
		if(PHYSFSX_exists(filename,0))
		{
			strcpy(strstr(filename,".plr"),"\0");
			strcpy(Players[Player_num].callsign, GameArg.SysUsePlayersDir? &filename[8] : filename);
			read_player_file();
			WriteConfigFile();
		}
	}


	Game_mode = GM_GAME_OVER;
	DoMenu();

	setjmp(LeaveEvents);
	while (window_get_front())
		// Send events to windows and the default handler
		event_process();
	
	// Tidy up - avoids a crash on exit
	{
		window *wind;

		show_menus();
		while ((wind = window_get_front()))
			window_close(wind);
	}

	WriteConfigFile();
	show_order_form();

	con_printf( CON_DEBUG, "\nCleanup...\n" );
	close_game();
	texmerge_close();
	gamedata_close();
	gamefont_close();
	free_text();
	args_exit();
	newmenu_free_background();
	free_mission();
	PHYSFSX_removeArchiveContent();

	return(0);		//presumably successful exit
}
コード例 #29
0
ファイル: tty_io.c プロジェクト: jiajuwu/linux-0.11
void tty_init(void)
{
	rs_init();
	con_init();
}
コード例 #30
0
ファイル: pak.c プロジェクト: matthiaskrgr/gmqcc
int main(int argc, char **argv) {
    bool          extract   = true;
    char         *redirout  = (char*)stdout;
    char         *redirerr  = (char*)stderr;
    char         *file      = NULL;
    char        **files     = NULL;
    pak_file_t   *pak       = NULL;
    size_t        iter      = 0;

    con_init();

    /*
     * Command line option parsing commences now We only need to support
     * a few things in the test suite.
     */
    while (argc > 1) {
        ++argv;
        --argc;

        if (argv[0][0] == '-') {
            if (parsecmd("redirout",  &argc, &argv, &redirout,  1, false))
                continue;
            if (parsecmd("redirerr",  &argc, &argv, &redirerr,  1, false))
                continue;
            if (parsecmd("file",      &argc, &argv, &file,      1, false))
                continue;

            con_change(redirout, redirerr);

            switch (argv[0][1]) {
                case 'e': extract = true;  continue;
                case 'c': extract = false; continue;
            }

            if (!strcmp(argv[0]+1, "debug")) {
                OPTS_OPTION_BOOL(OPTION_DEBUG) = true;
                continue;
            }
            if (!strcmp(argv[0]+1, "memchk")) {
                OPTS_OPTION_BOOL(OPTION_MEMCHK) = true;
                continue;
            }
            if (!strcmp(argv[0]+1, "nocolor")) {
                con_color(0);
                continue;
            }
        }

        vec_push(files, argv[0]);
    }
    con_change(redirout, redirerr);


    if (!file) {
        con_err("-file must be specified for output/input PAK file\n");
        vec_free(files);
        return EXIT_FAILURE;
    }

    if (extract) {
        if (!(pak = pak_open(file, "r"))) {
            con_err("failed to open PAK file %s\n", file);
            vec_free(files);
            return EXIT_FAILURE;
        }

        if (!pak_extract_all(pak, "./")) {
            con_err("failed to extract PAK %s (files may be missing)\n", file);
            pak_close(pak);
            vec_free(files);
            return EXIT_FAILURE;
        }

        /* not possible */
        pak_close(pak);
        vec_free(files);
        stat_info();

        return EXIT_SUCCESS;
    }

    if (!(pak = pak_open(file, "w"))) {
        con_err("failed to open PAK %s for writing\n", file);
        vec_free(files);
        return EXIT_FAILURE;
    }

    for (iter = 0; iter < vec_size(files); iter++) {
        if (!(pak_insert_one(pak, files[iter]))) {
            con_err("failed inserting %s for PAK %s\n", files[iter], file);
            pak_close(pak);
            vec_free(files);
            return EXIT_FAILURE;
        }
    }

    /* not possible */
    pak_close(pak);
    vec_free(files);

    stat_info();
    return EXIT_SUCCESS;
}