Exemplo n.º 1
0
int console_open(char *name)
{
#if CFG_MINIMAL_SIZE
    if (console_handle != -1) {
	console_close();
	}

    console_handle = cfe_open(name);
    if (console_handle < 0) return CFE_ERR_DEVNOTFOUND;

#else

    int flushbuf;

    console_name = NULL;

    if (console_handle != -1) {
	console_close();
	}

    flushbuf = console_buffer_flg;
    console_buffer_flg = 0;

    console_handle = cfe_open(name);
    if (console_handle < 0) return CFE_ERR_DEVNOTFOUND;

    console_name = name;
    if (flushbuf) console_flushbuffer();
#endif

    return 0;
}
Exemplo n.º 2
0
/*
 * ScreenInit - get screen info
 */
void ScreenInit( void )
{
    struct _osinfo              info;
    int                         rows, cols;
    unsigned                    size;
    unsigned                    seg;
    vi_rc                       rc;


    QNXCon = console_open( QNXConHandle, O_WRONLY );
    if( QNXCon == NULL ) {
        // FatalError( ERR_WIND_NO_MORE_WINDOWS );
        ChangeDirectory( HomeDirectory );
        exit( 0 );
    }
    if( console_size( QNXCon, QNXConsole, 0, 0, &rows, &cols ) != 0 ) {
        console_close( QNXCon );
        FatalError( ERR_WIND_NO_MORE_WINDOWS );
    }
    rc = BIOSKeyboardInit();
    if( rc != ERR_NO_ERR ) {
        console_close( QNXCon );
        FatalError( rc );
    }
    EditVars.WindMaxWidth = cols;
    EditVars.WindMaxHeight = rows;

    qnx_osinfo( 0, &info );
    switch( info.primary_monitor ) {
    case _MONITOR_PGS:
    case _MONITOR_CGA:
    case _MONITOR_PS30_COLOR:
    case _MONITOR_EGA_COLOR:
    case _MONITOR_VGA_COLOR:
        EditFlags.Color = TRUE;
        break;
    case _MONITOR_EGA_MONO:
    case _MONITOR_VGA_MONO:
    case _MONITOR_PS30_MONO:
        EditFlags.BlackAndWhite = TRUE;
        break;
    default:
        EditFlags.Monocolor = TRUE;
        break;
    }
    size = cols * rows * sizeof( char_info );
    seg = qnx_segment_alloc( size );
    Scrn = MK_FP( seg, 0 );
    ScreenPage( 0 );

} /* ScreenInit */
Exemplo n.º 3
0
int main(int argc, char **argv, char **env)
{
	float speed;

#ifndef WITH_SERIAL_PTY
	set_conio_terminal_mode();
#endif

	Verilated::commandArgs(argc, argv);
	dut = new Vdut;

	Verilated::traceEverOn(true);
	tfp = new VerilatedVcdC;
	dut->trace(tfp, 99);
	tfp->open("dut.vcd");

	struct sim s;
	sim_init(&s);

#ifdef WITH_SERIAL_PTY
	console_init(&s);
	console_open(&s);
#endif

#ifdef WITH_ETH
	eth_init(&s, "/dev/net/tap0", "tap0"); // XXX get this from /tmp/simethernet
	eth_open(&s);
#endif

	s.run = true;
	while(s.run) {
		sim_tick(&s);
		if(SYS_CLK) {
#ifdef WITH_SERIAL
			if(console_service(&s) != 0)
				s.run = false;
#endif
#ifdef WITH_ETH
			ethernet_service(&s);
#endif
		}
	}
	s.end = clock();

	speed = (s.tick/2)/((s.end-s.start)/CLOCKS_PER_SEC);

	printf("average speed: %3.3f MHz\n\r", speed/1000000);

	tfp->close();


#ifdef WITH_SERIAL_PTY
	console_close(&s);
#endif
#ifdef WITH_ETH
	eth_close(&s);
#endif

	exit(0);
}
Exemplo n.º 4
0
int CloseDUT()
{
    ENTRY;
    console_close(connection);
    error_msg = no_error;
    RETURNI(SUCCESS);
}
Exemplo n.º 5
0
/* FUNCTION: console_init()
 *
 * Initialize the console module.
 * Create tk_console and tk_nettick tasks.
 *
 * PARAMS: none
 *
 * RETURNS: int               0 if OK, else error code
 */
int
console_init(void)
{
   int err;

   console_wakes = 0;

   /* initialize net tasks */
   if (to_console == TK_NOTASK)
   {
      if ((err = TK_CREATE(&task_console)) != 0)
      {
         console_close(0);
         return (err);
      }
   }

   if (ctx == (CLI_CTX)NULL)
   {
      if (((ctx = cli_get_context()) == (CLI_CTX)NULL) ||
          (GIO_PUSH_CONSOLE(&ctx->gio, GIO_RW) != GIO_DONE))
      {
         cli_free_context(ctx);
         ctx = (CLI_CTX)NULL;
         return (-1);
      }
   }

   return (0);
}
Exemplo n.º 6
0
void console_toggle()
{
	if (gConsoleOpen)
		console_close();
	else
		console_open();
}
Exemplo n.º 7
0
void close(){
	net_close();
	input_close();
	physics_close();
	console_close();
	test_logic_close();
	// the functions are smart enough to not close if they never initialized
}
Exemplo n.º 8
0
/*
 * ScreenFini - done with the screen
 */
void ScreenFini( void )
{
    KeyboardFini();
    if( QNXCon != NULL ) {
        console_close( QNXCon );
    }

} /* ScreenFini */
Exemplo n.º 9
0
static int cd_fini( void )
/************************/
{
    finikeyboard();
    uifinicursor();
    console_close( UIConCtrl );
    return( false );
}
Exemplo n.º 10
0
void PMAPI PM_closeConsole(PM_HWND hwndConsole)
{
#ifndef __QNXNTO__
    if (--console_count == 0) {
        console_close(cc);
        cc = NULL;
        }
#endif
}
Exemplo n.º 11
0
void main (int argc, char **argv)
{
	// Init libxenon
	xenos_init(VIDEO_MODE_AUTO);
	console_init();

	xenon_make_it_faster(XENON_SPEED_FULL);

#if 0
	threading_init();
	network_init_sys();
#endif

	usb_init();
	usb_do_poll();

	xenon_ata_init();

	xenon_atapi_init();

	fatInitDefault();
#ifdef CAPS	
	fatMountSimple("udb", &usb2mass_ops_1);
	printf("CAPTURE BUILD !!!\n");
#endif	
	// Quake II
	
	char * newargv[] = {
		"uda:/q3.elf",
		//"+set", "game", "baseq2", "+set", "cddir", "uda:/baseq2/"
		"+set", "basedir" , "uda:/",
		"+set", "cddir", "uda:/baseq2/",
		"+set", "cl_maxfps", "400"
	};
	int newargc = sizeof (newargv) / sizeof (char *);
	
	Qcommon_Init (newargc, newargv);
	
	console_close();

	int	time, oldtime, newtime;
	oldtime = Sys_Milliseconds();
	while (1)
	{
		do {
			newtime = Sys_Milliseconds ();
			time = newtime - oldtime;
		} while (time < 1);
		Qcommon_Frame (time);
		oldtime = newtime;
	}
}
Exemplo n.º 12
0
console_t
console_open() {
    console_t console = 0;
    int err=-1;
    char buf[4096];
    int reboot=0;

    do {
	console = (console_t)malloc(sizeof(*console));
	assertb(console);
	memset(console, 0, sizeof(*console));
	
	if( 1 ) {
	    console->read_handle = GetStdHandle(STD_INPUT_HANDLE);
	}
	else {
	    snprintf(buf, sizeof(buf), "CONIN$");

	    debug(DEBUG_INFO,  
		  ("console_open: CreateFile(path=%s)\n", buf));
 
	    console->read_handle = 
		CreateFile(buf,
		   GENERIC_READ | GENERIC_WRITE,
		   0,
		   0,
		   OPEN_EXISTING,
		   FILE_FLAG_OVERLAPPED | FILE_ATTRIBUTE_SYSTEM,
		   0
		   );
	}
	assertb_syserr(console->read_handle != INVALID_HANDLE_VALUE);

	console->read_pending = 0;
	console->read_event = CreateEvent(0,0,0,0);
	assertb(console->read_event);

	err = 0;
	break;
	
    } while(0);

    if( err ) {
	console_close(console);
	console = 0;
    }

    return console;
}
Exemplo n.º 13
0
void FiniScreen( void )
{
    if( _IsOn( SW_USE_MOUSE ) ) GUIFiniMouse();
    uistop();
    switch( ConMode ) {
    case C_QCON:
        console_active( ConCtrl, InitConsole );
        console_size( ConCtrl, DbgConsole, PrevLines, PrevColumns, NULL, NULL );
        console_close( ConCtrl );
        break;
    case C_XWIN:
        signal( SIGHUP, SIG_IGN );
        kill( XQshPid, SIGTERM );
        break;
    }
}
Exemplo n.º 14
0
trap_retval ReqRead_user_keyboard( void )
{
    struct _console_ctrl    *con;
    unsigned                con_num;
    int                     con_hdl;
    int                     con_mode;
    char                    chr;
    //NYI: what about QNX windows?
    static char             con_name[] = "/dev/conXX";
    unsigned                timeout;
    read_user_keyboard_req      *acc;
    read_user_keyboard_ret      *ret;

#   define FIRST_DIGIT (sizeof( con_name ) - 3)

    acc = GetInPtr( 0 );
    ret = GetOutPtr( 0 );
    timeout = acc->wait * 10;
    if( timeout == 0 ) timeout = -1;
    ret->key = '\0';
    con = console_open( 2, O_WRONLY );
    if( con == NULL ) {
        return( sizeof( *ret ) );
    }
    con_num = console_active( con, -1 );
    console_close( con );
    con_name[ FIRST_DIGIT + 0 ] = (con_num / 10) + '0';
    con_name[ FIRST_DIGIT + 1 ] = (con_num % 10) + '0';

    con_hdl = open( con_name, O_RDONLY );
    if( con_hdl < 0 ) {
        if( timeout == -1 ) timeout = 50;
        sleep( timeout / 10 );
        return( sizeof( *ret ) );
    }
    con_mode = dev_mode( con_hdl, 0, _DEV_MODES );
    if( dev_read( con_hdl, &chr, 1, 1, 0, timeout, 0, 0 ) == 1 ) {
        if( chr == 0xff ) {
            read( con_hdl, &chr, 1 );
            chr = '\0';
        }
        ret->key = chr;
    }
    dev_mode( con_hdl, con_mode, _DEV_MODES );
    close( con_hdl );
    return( sizeof( *ret ) );
}
Exemplo n.º 15
0
long script_start_gui( int autostart )
{
    int i;

    if (conf.script_file[0] == 0) return 0;

    libshothisto->shot_histogram_set(0);
    camera_info.state.auto_started = autostart;

    // Kill high speed USB timer if running
    stop_usb_HPtimer();

    // Keyboard init
    camera_info.state.kbd_last_clicked = 0;
    camera_info.state.kbd_last_checked_time = get_tick_count();
    kbd_key_release_all();

    // Close old console, will be re-opened when first line added
    console_close();
    script_print_screen_init();

    save_params_values(0);

    script_console_add_line((autostart)?LANG_CONSOLE_TEXT_AUTOSTARTED:LANG_CONSOLE_TEXT_STARTED);

    module_set_script_lang(conf.script_file);
    if ( !libscriptapi->script_start_file(conf.script_file) )
    {
        return -1;
    }

    sc_param *p = script_params;
    while (p)
    {
        libscriptapi->set_variable(p->name, p->val, (p->range == 1), (p->data_type == DTYPE_TABLE), p->option_count, p->options);
        p = p->next;
    }

    conf_update_prevent_shutdown();

    old_gui_handler = gui_set_mode(&scriptGuiHandler);

    return script_stack_start();
}
Exemplo n.º 16
0
void Sys_PlatformInit( void )
{
	// Init libxenon
	xenos_init(VIDEO_MODE_AUTO);

	console_init();

	xenon_make_it_faster(XENON_SPEED_FULL);
	
	
	http_output_start();
		
#if 0
	threading_init();
	network_init_sys();
#endif	
	
	usb_init();
	usb_do_poll();

	xenon_ata_init();
	xenon_atapi_init();

	// fatInitDefault();
	// XTAFMount();	
	
	// fatInit(16, 1);
	
	fatMount ("uda", &usb2mass_ops_0, 0, 256, 64);
	
	ListDevices();
	
	Sys_SetEnv("HOME", "uda:/");
	
	console_close();
}
Exemplo n.º 17
0
//
// D_DoomMain
//
void D_DoomMain(void)
{
    int  p;
    char file[256];

    IdentifyVersion ();

    modifiedgame = false;

    nomonsters = M_CheckParm("-nomonsters");
    respawnparm = M_CheckParm("-respawn");
    fastparm = M_CheckParm("-fast");
    devparm = M_CheckParm("-devparm");
    if (M_CheckParm("-altdeath"))
    {
        deathmatch = 2;
    }
    else if (M_CheckParm ("-deathmatch"))
    {
        deathmatch = 1;
    }

    switch (gamemode)
    {
    case retail:
        sprintf (title,
//		 "                         "
                 "The Ultimate DOOM Startup v%i.%i",
//		 "                           ",
                 VERSION/100,VERSION%100);
        break;
    case shareware:
        sprintf (title,
//		 "                            "
                 "DOOM Shareware Startup v%i.%i",
//		 "                           ",
                 VERSION/100,VERSION%100);
        break;
    case registered:
        sprintf (title,
//		 "                            "
                 "DOOM Registered Startup v%i.%i",
//		 "                           ",
                 VERSION/100,VERSION%100);
        break;
    case commercial:
        sprintf (title,
//		 "                         "
                 "DOOM 2: Hell on Earth v%i.%i",
//		 "                           ",
                 VERSION/100,VERSION%100);
        break;
    /*FIXME
           case pack_plut:
    	sprintf (title,
    		 "                   "
    		 "DOOM 2: Plutonia Experiment v%i.%i"
    		 "                           ",
    		 VERSION/100,VERSION%100);
    	break;
          case pack_tnt:
    	sprintf (title,
    		 "                     "
    		 "DOOM 2: TNT - Evilution v%i.%i"
    		 "                           ",
    		 VERSION/100,VERSION%100);
    	break;
    */
    default:
        sprintf (title,
//		 "                     "
                 "Public DOOM - v%i.%i",
//		 "                           ",
                 VERSION/100,VERSION%100);
        break;
    }

    printf ("%s\n",title);

    // turbo option
    if ( (p=M_CheckParm ("-turbo")) )
    {
        int     scale = 200;
        extern int forwardmove[2];
        extern int sidemove[2];

        if (p<myargc-1)
            scale = atoi (myargv[p+1]);
        if (scale < 10)
            scale = 10;
        if (scale > 400)
            scale = 400;
//	printf ("turbo scale: %i%%\n",scale);
        forwardmove[0] = forwardmove[0]*scale/100;
        forwardmove[1] = forwardmove[1]*scale/100;
        sidemove[0] = sidemove[0]*scale/100;
        sidemove[1] = sidemove[1]*scale/100;
    }

    // add any files specified on the command line with -file wadfile
    // to the wad list
    //
    // convenience hack to allow -wart e m to add a wad file
    // prepend a tilde to the filename so wadfile will be reloadable
    p = M_CheckParm ("-wart");
    if (p)
    {
        myargv[p][4] = 'p';     // big hack, change to -warp

        // Map name handling.
        switch (gamemode )
        {
        case shareware:
        case retail:
        case registered:
            sprintf (file,"~"DEVMAPS"E%cM%c.wad",
                     myargv[p+1][0], myargv[p+2][0]);
            printf("Warping to Episode %s, Map %s.\n",
                   myargv[p+1],myargv[p+2]);
            break;

        case commercial:
        default:
            p = atoi (myargv[p+1]);
            if (p<10)
                sprintf (file,"~"DEVMAPS"cdata/map0%i.wad", p);
            else
                sprintf (file,"~"DEVMAPS"cdata/map%i.wad", p);
            break;
        }
        D_AddFile (file);
    }

    p = M_CheckParm ("-file");
    if (p)
    {
        // the parms after p are wadfile/lump names,
        // until end of parms or another - preceded parm
        modifiedgame = true;            // homebrew levels
        while (++p != myargc && myargv[p][0] != '-')
            D_AddFile (myargv[p]);
    }

    p = M_CheckParm ("-playdemo");

    if (!p)
        p = M_CheckParm ("-timedemo");

    if (p && p < myargc-1)
    {
        sprintf (file,"%s.lmp", myargv[p+1]);
        D_AddFile (file);
        printf("Playing demo %s.lmp.\n",myargv[p+1]);
    }

    // get skill / episode / map from parms
    startskill = sk_medium;
    startepisode = 1;
    startmap = 3;
    autostart = false;

    p = M_CheckParm ("-skill");
    if (p && p < myargc-1)
    {
        startskill = myargv[p+1][0]-'1';
        autostart = true;
    }

    p = M_CheckParm ("-episode");
    if (p && p < myargc-1)
    {
        startepisode = myargv[p+1][0]-'0';
        startmap = 1;
        autostart = true;
    }

    p = M_CheckParm ("-timer");
    if (p && p < myargc-1 && deathmatch)
    {
        int     time;
        time = atoi(myargv[p+1]);
        printf("Levels will end after %d minute",time);
        if (time>1)
            printf("s");
        printf(".\n");
    }

    p = M_CheckParm ("-avg");
    if (p && p < myargc-1 && deathmatch)
        printf("Austin Virtual Gaming: Levels will end after 20 minutes\n");

    p = M_CheckParm ("-warp");
    if (p && p < myargc-1)
    {
        if (gamemode == commercial)
            startmap = atoi (myargv[p+1]);
        else
        {
            startepisode = myargv[p+1][0]-'0';
            startmap = myargv[p+2][0]-'0';
        }
        autostart = true;
    }

    // init subsystems
    printf ("V_Init: allocate screens.\n");
    V_Init ();

    printf ("M_LoadDefaults: Load system defaults.\n");
    M_LoadDefaults ();              // load before initing other systems

    printf ("Z_Init: Init zone memory allocation daemon. \n");
    Z_Init ();

    printf ("W_Init: Init WADfiles.\n");
    W_InitMultipleFiles (wadfiles);

    // Check for -file in shareware
    /*    if (modifiedgame)
        {
    	// These are the lumps that will be checked in IWAD,
    	// if any one is not present, execution will be aborted.
    	char name[23][8]=
    	{
    	    "e2m1","e2m2","e2m3","e2m4","e2m5","e2m6","e2m7","e2m8","e2m9",
    	    "e3m1","e3m3","e3m3","e3m4","e3m5","e3m6","e3m7","e3m8","e3m9",
    	    "dphoof","bfgga0","heada1","cybra1","spida1d1"
    	};
    	int i;

    	if ( gamemode == shareware)
    	    I_Error("\nYou cannot -file with the shareware "
    		    "version. Register!");

    	// Check for fake IWAD with right name,
    	// but w/o all the lumps of the registered version.
    	if (gamemode == registered)
    	    for (i = 0;i < 23; i++)
    		if (W_CheckNumForName(name[i])<0)
    		    I_Error("\nThis is not the registered version.");
        }

        // Iff additonal PWAD files are used, print modified banner
        if (modifiedgame)
        {
    	printf (
    	    "===========================================================================\n"
    	    "ATTENTION:  This version of DOOM has been modified.  If you would like to\n"
    	    "get a copy of the original game, call 1-800-IDGAMES or see the readme file.\n"
    	    "        You will not receive technical support for modified games.\n"
    	    "                      press enter to continue\n"
    	    "===========================================================================\n"
    	    );
    	getchar ();
        }
    */

    // Check and print which version is executed.
    switch ( gamemode )
    {
    case shareware:
    case indetermined:
        printf ( "%s", shareware_banner
                 /*	    "===========================================================================\n"
                 	    "                                Shareware!\n",
                 	    "===========================================================================\n"*/
               );
        break;
    case registered:
    case retail:
    case commercial:
        printf ( "%s", commercial_banner
                 /*	    "===========================================================================\n"
                 	    "                 Commercial product - do not distribute!\n"
                 	    "         Please report software piracy to the SPA: 1-800-388-PIR8\n"
                 	    "===========================================================================\n"*/
               );
        break;

    default:
        // Ouch.
        break;
    }

    printf ("M_Init: Init miscellaneous info.\n");
    M_Init ();

    printf ("R_Init: Init DOOM refresh daemon - ");
    R_Init ();

    printf ("\nP_Init: Init Playloop state.\n");
    P_Init ();

    printf ("I_Init: Setting up machine state.\n");
    I_Init ();

    printf ("D_CheckNetGame: Checking network game status.\n");
    D_CheckNetGame ();

    printf ("S_Init: Setting up sound.\n");
    S_Init (snd_SfxVolume /* *8 */, snd_MusicVolume /* *8*/ );

    printf ("HU_Init: Setting up heads up display.\n");
    HU_Init ();

    printf ("ST_Init: Init status bar.\n");
    ST_Init ();

    /*    // check for a driver that wants intermission stats
        p = M_CheckParm ("-statcopy");
        if (p && p<myargc-1)
        {
    	// for statistics driver
    	extern  void*	statcopy;

    	statcopy = (void*)atoi(myargv[p+1]);
    	printf ("External statistics registered.\n");
        }*/

    /*    // start the apropriate game based on parms
        p = M_CheckParm ("-record");

        if (p && p < myargc-1)
        {
    	G_RecordDemo (myargv[p+1]);
    	autostart = true;
        }*/

    /*    p = M_CheckParm ("-playdemo");
        if (p && p < myargc-1)
        {
    	singledemo = true;              // quit after one demo
    	G_DeferedPlayDemo (myargv[p+1]);
    	D_DoomLoop ();  // never returns
        }*/

    /*    p = M_CheckParm ("-timedemo");
        if (p && p < myargc-1)
        {
    	G_TimeDemo (myargv[p+1]);
    	D_DoomLoop ();  // never returns
        }*/

    /*    p = M_CheckParm ("-loadgame");
        if (p && p < myargc-1)
        {
    	if (M_CheckParm("-cdrom"))
    	    sprintf(file, "c:\\doomdata\\"SAVEGAMENAME"%c.dsg",myargv[p+1][0]);
    	else
    	    sprintf(file, SAVEGAMENAME"%c.dsg",myargv[p+1][0]);
    	G_LoadGame (file);
        }*/

    if (!should_sound)
    {
        // install sound callback
        register_AI_handler(sound_callback);
        set_AI_interrupt(1);
        should_sound = 1;
        sound_callback();
        printf("D_DoomMain: AI interrupt handler installed.\n");
    }


    if (gameaction != ga_loadgame)
    {
        if (autostart || netgame)
        {
            G_InitNew(startskill, startepisode, startmap);
        }
        else
        {
            D_StartTitle(); // start up intro loop
        }
    }

    console_clear();
    console_close();

    D_DoomLoop();  // never returns
}
Exemplo n.º 18
0
void uimon_window_close(void)
{
  console_close(console_log);
  console_log = NULL;
}
Exemplo n.º 19
0
int console_get_userpass_input(prompts_t *p, unsigned char *in, int inlen)
{
    size_t curr_prompt;
    FILE *outfp = NULL;
    int infd;

    /*
     * Zero all the results, in case we abort half-way through.
     */
    {
	int i;
	for (i = 0; i < p->n_prompts; i++)
            prompt_set_result(p->prompts[i], "");
    }

    if (p->n_prompts && console_batch_mode)
	return 0;

    console_open(&outfp, &infd);

    /*
     * Preamble.
     */
    /* We only print the `name' caption if we have to... */
    if (p->name_reqd && p->name) {
	size_t l = strlen(p->name);
	console_prompt_text(outfp, p->name, l);
	if (p->name[l-1] != '\n')
	    console_prompt_text(outfp, "\n", 1);
    }
    /* ...but we always print any `instruction'. */
    if (p->instruction) {
	size_t l = strlen(p->instruction);
	console_prompt_text(outfp, p->instruction, l);
	if (p->instruction[l-1] != '\n')
	    console_prompt_text(outfp, "\n", 1);
    }

    for (curr_prompt = 0; curr_prompt < p->n_prompts; curr_prompt++) {

	struct termios oldmode, newmode;
	int len;
	prompt_t *pr = p->prompts[curr_prompt];

	tcgetattr(infd, &oldmode);
	newmode = oldmode;
	newmode.c_lflag |= ISIG | ICANON;
	if (!pr->echo)
	    newmode.c_lflag &= ~ECHO;
	else
	    newmode.c_lflag |= ECHO;
	tcsetattr(infd, TCSANOW, &newmode);

	console_prompt_text(outfp, pr->prompt, strlen(pr->prompt));

        len = 0;
        while (1) {
            int ret;

            prompt_ensure_result_size(pr, len * 5 / 4 + 512);
            ret = read(infd, pr->result + len, pr->resultsize - len - 1);
            if (ret <= 0) {
                len = -1;
                break;
            }
            len += ret;
            if (pr->result[len - 1] == '\n') {
                len--;
                break;
            }
        }

	tcsetattr(infd, TCSANOW, &oldmode);

	if (!pr->echo)
	    console_prompt_text(outfp, "\n", 1);

        if (len < 0) {
            console_close(outfp, infd);
            return 0;                  /* failure due to read error */
        }

	pr->result[len] = '\0';
    }

    console_close(outfp, infd);

    return 1; /* success */
}
Exemplo n.º 20
0
static int cc_hide(const char **argv, int argc)
{
	console_close();
	return 0;
}