• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ raw函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中raw函数的典型用法代码示例。如果您正苦于以下问题:C++ raw函数的具体用法?C++ raw怎么用?C++ raw使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了raw函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: xyzsh_readline_interface_on_curses

void xyzsh_readline_interface_on_curses(char* cmdline, int cursor_point, char** argv, int argc, BOOL exit_in_spite_ofjob_exist, BOOL welcome_msg)
{
    gSigChld = FALSE;
    gSigWinch = FALSE;

    signal(SIGCHLD, handler);
    signal(SIGWINCH, handler);

    const int maxx = mgetmaxx();
    const int maxy = mgetmaxy();

    int temulator_y = 0;
    int temulator_x = 0;
    int temulator_height = maxy;
    int temulator_width = maxx;

    sTEmulator* temulator = temulator_init(temulator_height, temulator_width);

    struct sTEmulatorFunArg arg;

    arg.cmdline = cmdline;
    arg.cursor_point = cursor_point;
    arg.argv = argv;
    arg.argc = argc;
    arg.exit_in_spite_ofjob_exist = exit_in_spite_ofjob_exist;
    arg.welcome_msg = welcome_msg;

    temulator_open(temulator, temulator_fun, &arg);

    initscr();
    start_color();
    noecho();
    raw();
    nodelay(stdscr, TRUE);
    keypad(stdscr, TRUE);
    curs_set(0);
    ESCDELAY=50;

    temulator_init_colors();

    WINDOW* term_win = newwin(temulator_height, temulator_width, temulator_y, temulator_x);

    int pty = temulator->mFD;

    fd_set mask, read_ok;
    FD_ZERO(&mask);
    FD_SET(0, &mask);
    FD_SET(pty, &mask);

    int dirty = 0;
    struct timeval next;

    gettimeofday(&next, NULL);
    while(1) {
        struct timeval tv = { 0, 1000 * 1000 / 100 };
        read_ok = mask;

        if(select(pty+1, &read_ok, NULL, NULL, &tv) > 0) {
            if(FD_ISSET(pty, &read_ok)) {
                temulator_read(temulator);
                dirty = 1;
            }
        }

        int key;
        while((key = getch()) != ERR) {
            temulator_write(temulator, key);
            dirty = 1;
        }

        gettimeofday(&tv, NULL);
        if(dirty && is_expired(tv, next)) {
            temulator_draw_on_curses(temulator, term_win, temulator_y, temulator_x);
            wrefresh(term_win);
            dirty = 0;
            next = timeval_add(tv, slice);
        }

        if(gSigChld) {
            gSigChld = FALSE;
            break;
        }

        if(gSigWinch) {
            gSigWinch = 0;

            temulator_height = mgetmaxy();
            temulator_width = mgetmaxx();

            if(temulator_width >= 10 && temulator_height >= 10) {
                resizeterm(temulator_height, temulator_width);

                wresize(term_win, temulator_height, temulator_width);
                temulator_resize(temulator, temulator_height, temulator_width);

                dirty = 1;
            }
        }
    }

//.........这里部分代码省略.........
开发者ID:kenhys,项目名称:xyzsh,代码行数:101,代码来源:interface.c


示例2: init_curses

void init_curses() {
	initscr();
	raw();
	keypad(stdscr, TRUE);
	noecho();
}
开发者ID:bio4554,项目名称:dev,代码行数:6,代码来源:graphics.c


示例3: modify_display

void modify_display ( void )
{
	int i;
	int focus = 0;
	int c;
	int x,y;
	int maxx;
	int maxy __attribute((unused));
	int ll_focus_y = 0;
	int ll_focus_x = 0;
	WINDOW *mod_win;

	getmaxyx ( win, maxy, maxx );
	mod_win = newwin ( 8, maxx, 0, 0 );
	cbreak();
	raw();
	nonl();
	keypad ( mod_win, TRUE );
	while ( 1 )
	{
		werase( mod_win );
		wrefresh( mod_win );
		mvwprintw ( mod_win,  0, 0, "Use arrow keys (or vim cursor keys) to navigate;" );
		mvwprintw ( mod_win,  1, 0, "Set sort field (highlighted) with 's', order %s (change with 'r')", parametres.reversesort ? "ascending" : "descending" );
		mvwprintw ( mod_win,  2, 0, "go down or press enter to change a field, select with space key");
		mvwprintw ( mod_win,  3, 0, "'i' to insert a field, 'a' to append it, 'd' to delete");
		wmove ( mod_win, 6, 0 );
		for ( i = 0; i < MAX_DISPLAY_FIELDS; i++ )
		{
			wattron ( mod_win, A_REVERSE );
			if ( display_fields[i] == NULL )
			{
				break;
			}
			if ( display_fields[i]->identifier == parametres.sortby )
			{
				wattroff ( mod_win, A_REVERSE );
			}
			wprintw ( mod_win, display_fields[i]->header_format, display_fields[i]->fieldname );
			if ( i == focus )
			{
				wattroff ( mod_win, A_REVERSE );
				/* find out where to print the menu in case we need one */
				getyx ( mod_win, y, x );
				ll_focus_y = y + 1;
				ll_focus_x = x - display_fields[i]->field_length;
				/*
				  keep menu inside the current window - in case it would "fall
				  off" off the edge, move it inwards by the width of the menu
				*/
				if ( maxx < ( x + MENU_WIDTH ) )
				{
					ll_focus_x = maxx - MENU_WIDTH;
				}

				mvwaddch( mod_win, y - 1, x - display_fields[i]->field_length - 1 , ACS_ULCORNER);
				mvwaddch( mod_win, y + 1, x - display_fields[i]->field_length - 1 , ACS_LLCORNER);
				mvwaddch( mod_win, y + 1, x -1, ACS_LRCORNER);
				mvwaddch( mod_win, y - 1, x - 1 , ACS_URCORNER);
				mvwvline( mod_win, y , x - display_fields[i]->field_length - 1 , ACS_VLINE, 1 );
				mvwvline( mod_win, y , x - 1 , ACS_VLINE, 1 );
				mvwhline( mod_win, y - 1, x - display_fields[i]->field_length, ACS_HLINE, display_fields[i]->field_length - 1 );
				mvwhline( mod_win, y + 1, x - display_fields[i]->field_length, ACS_HLINE, display_fields[i]->field_length - 1 );
				wmove ( mod_win, y, x );
			}
		}
		wrefresh( mod_win );
		c = getch();
		switch ( c )
		{
			case 'h':
			case KEY_LEFT:
				if ( focus > 0 )
				{
					focus--;
				}
				break;
			case 'l':		
			case KEY_RIGHT:
				if ( display_fields[focus + 1] != NULL )
				{
					focus++;
				}
				break;
			case 's':
			case 'S':
				if (  display_fields[focus]->sortable == 1 )
				{
				 	parametres.sortby = display_fields[focus]->identifier;
					goto end;
				}
				else
				{
					printf ( "\a" );
					mvwprintw ( mod_win,  5, 0, "%-79s", "Sorry, can't sort by this field");
					wrefresh ( mod_win );
					sleep ( 1 );
				}
				break;
			case 'r':
//.........这里部分代码省略.........
开发者ID:horrovac,项目名称:jkutop,代码行数:101,代码来源:printing.c


示例4: main

int main()
{
    // Allocate a BCH codec Galois order 8 (w/ 2^8-1 == 255 bit codeword size), and 2 bits of
    // correction capacity.  This results in a BCH( 255, 239, 2) codec: 255-bit codeword, 239-bit
    // data payload capacity, hence 255-239 == 16 bits of parity.  Define EZPWD_BCH_CLASSIC to use
    // classic Djelic Linux Kernel API.  Otherwise, uses <ezpwd/bch> 'bch<..>' or 'BCH<...>' classes.
    ezpwd::asserter		assert;
    try {
#if defined( EZPWD_BCH_CLASSIC )
        ezpwd::bch_control                 *bch     = ezpwd::init_bch( 8, 2, 0 );
        if ( ! bch )
    	throw std::logic_error( "Failed to allocate valid BCH codec" );
        ezpwd::bch_control                 &bch_codec( *bch );	// By Galois order, Correction capacity
#else
        //ezpwd::bch_base		bch_codec( 8, 2 );	// By Galois order, Correction capacity, flexibly
        ezpwd::BCH<255,239,2>		bch_codec;	// By Codeword, Payload and Correction capacities, exactly
#endif

#if defined( EZPWD_BCH_FIXED )
        typedef std::array<uint8_t,10>	codeword_t;		// Fixed (parity initialized to 0)
#else
        typedef std::vector<uint8_t>	codeword_t;		// Variable (parity added by encode)
#endif

	codeword_t				codeword= {
	    0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF	// 8 data
	};							// 2 ECC parity

#if defined( EZPWD_BCH_CLASSIC )
	// A BCH codeword's ECC must be zero-initialized for classic Djelic API, and
	// must be added to variable containers
#  if ! defined( EZPWD_BCH_FIXED )
	codeword.resize( 10 );
#  endif
	codeword[8] 				= 0;
	codeword[9] 				= 0;
	ezpwd::encode_bch( &bch_codec, &codeword[0], 8, &codeword[8] );
#else
	// A codeword in a fixed container will not be resized by API; assumes ECC on end. Will
	// initialize to 0.  A variable container will have parity appended by the API.
	bch_codec.encode( codeword );
#endif

	// Place random errors in the codeword and correct, up to the capacity of the BCH codec.
	for ( size_t t = 0; t < 5; ++t ) {
	    for ( size_t e = 0
#if defined( EZPWD_BCH_CLASSIC )
		      ; e < bch_codec.t
#else
		      ; e < bch_codec.t()
#endif
		      ; ++e ) {
		codeword_t		corrupted( codeword );
		// Randomly corrupt from 0 to bch->t bits
		for ( size_t be = 0; be < e; ++be ) {
		    unsigned int	bl	= random_80( randomizer );
		    corrupted[bl/8]	       ^= uint8_t( 1 ) << ( bl % 8 );
		}
		codeword_t		corrected( corrupted );
#if defined( EZPWD_BCH_CLASSIC )
		int corrections			= correct_bch( &bch_codec, &corrected[0], 8, &corrected[8] );
#else
		int corrections			= bch_codec.decode( corrected );
#endif

		if ( assert.ISEQUAL( corrections, int( e ),
				     std::string( "Failed decode of " ) << bch_codec
				     << " codeword w/ " << e << " bit errrors"
				     )) {
		    std::cout << assert << std::endl;
		    continue;
		}

		// Success; If differences were found, they better be in the parity data!
		for ( size_t i = 0; i < 8; ++i )
		    if ( assert.ISEQUAL( corrected[i], codeword[i], 
					 std::string( "Failed recovery of " ) << bch_codec
					 << " codeword w/ " << e << " bit errors" ))
			std::cout << assert << std::endl;
	    }
#if ! defined( EZPWD_BCH_CLASSIC )
	    // Try the inline versions (only available in C++ API)
	    std::string			raw( "abc" );
	    std::string			enc	= bch_codec.encoded( raw );
	    std::string			err	= enc;
	    err[0]			       ^= 0x40;
	    err[2]			       ^= 0x08;
	    std::string			dec	= bch_codec.decoded( err );
	    if ( assert.ISEQUAL( dec.substr( 0, 3 ), raw,
				 std::string( "decoded/encoded of " )	<< bch_codec
				 << " codeword failed, encoded '0x"	<< ezpwd::hexstr( raw )
				 << "' to '0x"				<< ezpwd::hexstr( enc )
				 << "', decoded '0x"			<< ezpwd::hexstr( err )
				 << "' to '0x"				<< ezpwd::hexstr( dec )
				 << "'" ))
		std::cout << assert << std::endl;
#endif
	}
	std::cout
	    << bch_codec << ": ";
//.........这里部分代码省略.........
开发者ID:FreeApophis,项目名称:ezpwd-reed-solomon,代码行数:101,代码来源:bchsimple.C


示例5: mousemask

      bool Display::Open()
      {
        // Open curses
        screen=initscr();

        if (screen==NULL) {
          std::cerr << "Cannot initialize curses" << std::endl;
          return false;
        }


#ifdef NCURSES_MOUSE_VERSION
        mousemask(BUTTON1_PRESSED|
                  BUTTON1_RELEASED/*|
                  BUTTON1_CLICKED|
                  BUTTON1_DOUBLE_CLICKED|
                  BUTTON1_TRIPLE_CLICKED*/,NULL);
#endif

        // Check availibility of colors
        colorDepth=1;
        colorMode=colorModeMonochrome;

        if (has_colors() && start_color()!=ERR && COLORS>=8) {
          colorMode=colorModeColor;
          colorDepth=4;
        }

        // Basic curses initialisation
        curs_set(0);
        noecho();
        cbreak();
        nonl();
        raw();
        //Images::Factory::Set(OS::Factory::factory->CreateImageFactory(this));

        screenWidth=COLS;
        screenHeight=LINES;

        workAreaWidth=screenWidth;
        workAreaHeight=screenHeight;

        type=typeTextual;

        EvaluateDisplaySize();

        for (int c=1; c<COLOR_PAIRS; c++) {
          if (init_pair(c,c%COLORS,c/COLORS)==ERR) {
            std::cerr << c << " " << c%COLORS << " " << c/COLORS << std::endl;
            std::cerr << "Cannot initialize terminal color pairs" << std::endl;
            colorDepth=1;
            colorMode=colorModeMonochrome;
            break;
          }
        }

        propFont=driver->CreateFont();
        propFont=propFont->Load();
        propFontSize=1;

        fixedFont=driver->CreateFont();
        fixedFont=fixedFont->Load();
        fixedFontSize=1;

        theme=new Theme(this);

        for (size_t i=0; i<colorCount; i++) {
          color[i]=theme->GetColor((ColorIndex)i);
        }

        multiClickTime=200;

        eventLoop=new UnixEventLoop();
        eventLoop->AddSource(new CursesEventSource(this));

        return true;
      }
开发者ID:kolosov,项目名称:libosmscout,代码行数:77,代码来源:Display.cpp


示例6: raw64

 inline /*-*/ uint64_t* raw64(word_t a) /*-*/ { assert(a==last_addr); return (uint64_t*) raw(a); }
开发者ID:kinhoa122345,项目名称:virtualsoc-wcdma,代码行数:1,代码来源:host_memory.hpp


示例7: main

int main(int argc, char* argv[]) {
    char * enclave_path = argv[1];
    int vm_id = atoi(argv[2]);
    int ctrl_fd;
    int cons_fd;

    use_curses = 1;

    if (argc < 3) {
	printf("usage: v3_cons_sc <enclave_device> <vm_id>\n");
	return -1;
    }

    /* Check for minimum Terminal size at start */
    if (check_terminal_size() != 0) {
        printf ("Error: terminal too small!\n");
        return -1;
    }



    ctrl_fd = pet_ioctl_path(enclave_path, PISCES_ENCLAVE_CTRL_CONNECT, NULL);



    if (ctrl_fd < 0) {
	printf("Error opening enclave control channel\n");
	return -1;
    }

    cons_fd = pet_ioctl_fd(ctrl_fd, PISCES_CMD_VM_CONS_CONNECT, (void *)(uint64_t)vm_id); 

    close(ctrl_fd);

    if (cons_fd < 0) {
	printf("Error opening VM console\n");
	close(cons_fd);
	return -1;
    }

    tcgetattr(STDIN_FILENO, &console.termios_old);
    atexit(handle_exit);

    console.x = 0;
    console.y = 0;


    if (use_curses) {
	gettmode();
	console.win = initscr();
	
	if (console.win == NULL) {
	    fprintf(stderr, "Error initialization curses screen\n");
	    exit(-1);
	}

	scrollok(console.win, 1);

	erase();
    }

    /*
    termios = console.termios_old;
    termios.c_iflag &= ~(BRKINT | ICRNL | IGNBRK | IGNCR | IGNPAR);
    termios.c_iflag &= ~(INLCR | INPCK | ISTRIP | IXOFF | IXON | PARMRK); 
    //termios.c_iflag &= ~(ICRNL | INLCR );    

    //  termios.c_iflag |= SCANCODES; 
    //    termios.c_lflag &= ~(ECHO | ECHOE | ECHOK | ECHONL); 
    //termios.c_lflag &= ~(ICANON | IEXTEN | ISIG | NOFLSH);
    termios.c_lflag &= ~(ICANON | ECHO);

    termios.c_cc[VMIN] = 1;
    termios.c_cc[VTIME] = 0;

    tcflush(STDIN_FILENO, TCIFLUSH);
    tcsetattr(STDIN_FILENO, TCSANOW, &termios);
    */    

    raw();
    cbreak();
    noecho();
    keypad(console.win, TRUE);

    //ioctl(STDIN_FILENO, KDSKBMODE, K_RAW);

    while (1) {
	int ret; 
	fd_set rset;

	FD_ZERO(&rset);
	FD_SET(cons_fd, &rset);
	FD_SET(STDIN_FILENO, &rset);

	ret = select(cons_fd + 1, &rset, NULL, NULL, NULL);
	
	//	printf("Returned from select...\n");

	if (ret == 0) {
	    continue;
//.........这里部分代码省略.........
开发者ID:ouyangjn,项目名称:pisces,代码行数:101,代码来源:v3_cons_sc.c


示例8: main

int main(int argc, char *argv[])
{

    if (argc != 10 || !strncmp(argv[1],"-h",2))
    {
        puts("DrawLineSegment: Prints a line through two given points");
        puts("USAGE: ./DrawLineSegment x");
        return 0;
    }

    initscr();			/* Start curses mode 		*/
    raw();				/* Line buffering disabled	*/
    noecho();			/* Don't echo() while we do getch */

    start_color();			/* Start color 			*/
    init_pair(1, COLOR_RED, COLOR_RED);
    init_pair(2, COLOR_BLUE, COLOR_BLUE);
    attron(COLOR_PAIR(1));
    curs_set(0);

    double x1 = atof(argv[1]);
    double y1 = atof(argv[2]);

    double x2 = atof(argv[3]);
    double y2 = atof(argv[4]);

    double x3 = atof(argv[5]);
    double y3 = atof(argv[6]);

    double x4 = atof(argv[7]);
    double y4 = atof(argv[8]);

    Pair mid1 = midPoint(x1,y1,x2,y2);
    Pair mid2 = midPoint(x3,y3,x4,y4);
    Pair mid = midPoint(mid1.x,mid1.y,mid2.x,mid2.y);

    Pair rpoint1;
    Pair rpoint2;
    Pair rpoint3;
    Pair rpoint4;

    for (int i = 0; i < 1080; i++)
    {
        rpoint1 = rotateDPoint(mid.x,mid.y,x1,y1,i);
        rpoint2 = rotateDPoint(mid.x,mid.y,x2,y2,i);
        rpoint3 = rotateDPoint(mid.x,mid.y,x3,y3,i);
        rpoint4 = rotateDPoint(mid.x,mid.y,x4,y4,i);

        //draw the starting line

        //draw the midpoint
        attron(COLOR_PAIR(2));
        drawPair(mid);

        //draw rotated about the middle point
        attron(COLOR_PAIR(1));
        drawQuadrilateral(rpoint1.x,rpoint1.y,
                          rpoint2.x,rpoint2.y,
                          rpoint3.x,rpoint3.y,
                          rpoint4.x,rpoint4.y); //draw the shape

        refresh(); /* Print it on to the real screen */
        //sleep() wasn't working too well for me
        for (int j = 0; j <= atol(argv[5])*10000; j++);
        clear();
    }
    getch();			/* Wait for user input */
    endwin();			/* End curses mode		  */

    return 0;
}
开发者ID:mehstruslehpy,项目名称:Documents,代码行数:71,代码来源:4ShapeRotate.c


示例9: main

int main(int argc, char *argv[])
{
  void (*old_hook)(const char *, long, const char *, va_list);
  int use_menu = 1, k_errno;
  char buf[BUFSIZ];

  if ((whoami = strrchr(argv[0], '/')) == NULL)
    whoami = argv[0];
  else
    whoami++;
  if (!(current_li = malloc(sizeof(List_info))))
    {
      sprintf(buf, ": allocating list info");
      goto punt;
    }
  else
    {
      current_li->acl_type = NULL;
      current_li->acl_name = NULL;
      current_li->desc = NULL;
      current_li->modtime = NULL;
      current_li->modby = NULL;
      current_li->modwith = NULL;
    }

  username = mrcl_krb_user();
  if (!username)
    exit(1);
  
  if (mrcl_connect(NULL, "mailmaint", 2, 1))
    exit(2);

  initscr();
  if ((LINES < 24) || (COLS < 60))
    {
      display_buff("Display window too small.\n\n");
      sprintf(buf, "Current window parameters are (%d lines, %d columns)\n",
	      LINES, COLS);
      display_buff(buf);
      display_buff("Please resize your window\n");
      display_buff("to at least 24 lines and 60 columns.\n");
      exit(0);
    }

  raw();
  noecho();
  old_hook = set_com_err_hook(menu_err_hook);
  position[0] = oldpos[0] = 1;
  level = 0;

  pack_main_menu();
  pack_help_menu();
  display_menu(main_menu);
  get_main_input();
  cls();
  endwin();
  set_com_err_hook(old_hook);

  free_menu(main_menu);
  free_menu(help_menu);

  if (current_li->acl_type)
    free(current_li->acl_type);
  if (current_li->acl_name)
    free(current_li->acl_name);
  if (current_li->desc)
    free(current_li->desc);
  if (current_li->modtime)
    free(current_li->modtime);
  if (current_li->modby)
    free(current_li->modby);
  if (current_li->modwith)
    free(current_li->modwith);
  free(current_li);

  mr_disconnect();

  exit(0);

punt:
  com_err(whoami, status, "%s", buf);
  exit(1);
}
开发者ID:sipb,项目名称:athena-svn-mirror,代码行数:83,代码来源:mailmaint.c


示例10: main


//.........这里部分代码省略.........
	/*
	 * Now that we have the logfile and the ACU open
	 *  return to the real uid and gid.  These things will
	 *  be closed on exit.  The saved-setuid uid and gid
	 *  allows us to get the original setuid permissions back
	 *  for removing the uucp lock.
	 */
	userperm();

	/*
	 * Kludge, there's no easy way to get the initialization
	 *   in the right order, so force it here.
	 * Do the open here, before we change back to real uid.
	 * We will check whether the open succeeded later, when
	 * (and if) we actually go to use the file.
	 */
	if ((PH = getenv("PHONES")) == NOSTR) {
		myperm();
		PH = "/etc/phones";
	}
	phfd = fopen(PH, "r");

	userperm();

	vinit();				/* init variables */
	setparity("none");			/* set the parity table */
	if ((i = speed(number(value(BAUDRATE)))) == NULL) {
		(void) printf("tip: bad baud rate %d\n",
		    number(value(BAUDRATE)));
		myperm();
		delock(uucplock);
		return (3);
	}


	/*
	 * Hardwired connections require the
	 *  line speed set before they make any transmissions
	 *  (this is particularly true of things like a DF03-AC)
	 */
	if (HW)
		ttysetup(i);
	if (p = connect()) {
		(void) printf("\07%s\n[EOT]\n", p);
		myperm();
		delock(uucplock);
		return (1);
	}

	/*
	 * Always setup the tty again here in case hardware flow
	 *  control was selected, which can only be set after the
	 *  connection is made, or in case this is not a hardwired
	 *  modem (rare these days) that likewise can only be setup
	 *  after the connection is made.
	 */
	ttysetup(i);
cucommon:
	/*
	 * From here down the code is shared with
	 * the "cu" version of tip.
	 */

	(void) ioctl(0, TCGETS, (char *)&defarg);
	arg = defarg;
	/* turn off input processing */
	arg.c_lflag &= ~(ICANON|ISIG|ECHO|IEXTEN);
	arg.c_cc[VMIN] = 1;
	arg.c_cc[VTIME] = 0;
	arg.c_iflag &= ~(INPCK|IXON|IXOFF|ICRNL);
	arg.c_oflag = 0;		/* turn off all output processing */
	/* handle tandem mode in case was set in remote file */
	if (boolean(value(TAND)))
		tandem("on");
	else
		tandem("off");
	raw();

	(void) pipe(fildes); (void) pipe(repdes);
	(void) signal(SIGALRM, (sig_handler_t)timeout);

	/*
	 * Everything's set up now:
	 *	connection established (hardwired or dialup)
	 *	line conditioned (baud rate, mode, etc.)
	 *	internal data structures (variables)
	 * so, fork one process for local side and one for remote.
	 */
	if (CM != NOSTR) {
		(void) sleep(2);	/* let line settle */
		parwrite(FD, (unsigned char *)CM, strlen(CM));
	}
	(void) printf(cumode ? "Connected\r\n" : "\07connected\r\n");
	(void) signal(SIGCHLD, (sig_handler_t)deadkid);
	if (pid = fork())
		tipin();
	else
		tipout();
	/*NOTREACHED*/
}
开发者ID:AlfredArouna,项目名称:illumos-gate,代码行数:101,代码来源:tip.c


示例11: main

int main(int argc, char *argv[])
{
    RedditUserLogged *user = NULL;
    char *subreddit = NULL;
    char *password = NULL, *username = NULL;
    optParser parser;

    DEBUG_START(DEBUG_FILE, DEBUG_FILENAME);

    memset(&parser, 0, sizeof(optParser));

    parser.argc = argc;
    parser.argv = argv;

    optAddOptions (&parser, mainOptions, MOPT_ARG_COUNT);

    handleArguments(&parser);

    if (mainOptions[MOPT_HELP].isSet) {
        displayHelp(&parser);
        return 0;
    }

    optClearParser(&parser);

    setlocale(LC_CTYPE, "");


    initscr();
    raw();//We want character for character input
    keypad(stdscr,1);//Enable extra keys like arrowkeys
    noecho();
    start_color();
    use_default_colors();
    init_pair(1, -1, -1);
    init_pair(2, COLOR_BLACK, COLOR_WHITE);

    DEBUG_PRINT(L"Starting...\n");

    /* Start libreddit */
    redditGlobalInit();

    globalState = redditStateNew();

    globalState->userAgent = redditCopyString("cReddit/0.0.1");

    redditStateSet(globalState);

    if (mainOptions[MOPT_USERNAME].isSet) {
        username = mainOptions[MOPT_USERNAME].svalue;
        if (!mainOptions[MOPT_PASSWORD].isSet)
            password = getPassword();
        else
            password = mainOptions[MOPT_PASSWORD].svalue;

        user = redditUserLoggedNew();
        redditUserLoggedLogin(user, username, password);

        /* Don't want to leave that important Reddit password in memory */
        memset(password, 0, strlen(password));
        if (!mainOptions[MOPT_PASSWORD].isSet)
            free(password);
    }
    if (mainOptions[MOPT_SUBREDDIT].isSet) {
        subreddit = mainOptions[MOPT_SUBREDDIT].svalue;
        if (!startsWith("/r/", subreddit) && strcmp("/", subreddit) != 0)
            prepend("/r/", subreddit);

    } else {
        subreddit = "/";
    }
    showSubreddit(subreddit);

    redditUserLoggedFree(user);
    redditStateFree(globalState);
    redditGlobalCleanup();
    endwin();

    DEBUG_END(DEBUG_FILE);
    return 0;
}
开发者ID:stoicism2323,项目名称:cReddit,代码行数:81,代码来源:main.c


示例12: ncurses_init_graphics

static int ncurses_init_graphics(caca_display_t *dp)
{
    static int curses_colors[] =
    {
        /* Standard curses colours */
        COLOR_BLACK,
        COLOR_BLUE,
        COLOR_GREEN,
        COLOR_CYAN,
        COLOR_RED,
        COLOR_MAGENTA,
        COLOR_YELLOW,
        COLOR_WHITE,
        /* Extra values for xterm-16color */
        COLOR_BLACK + 8,
        COLOR_BLUE + 8,
        COLOR_GREEN + 8,
        COLOR_CYAN + 8,
        COLOR_RED + 8,
        COLOR_MAGENTA + 8,
        COLOR_YELLOW + 8,
        COLOR_WHITE + 8
    };

    mmask_t newmask;
    int fg, bg, max;

    dp->drv.p = malloc(sizeof(struct driver_private));

#if defined HAVE_GETENV && defined HAVE_PUTENV
    ncurses_install_terminal(dp);
#endif

#if defined HAVE_SIGNAL
    sigwinch_d = dp;
    signal(SIGWINCH, sigwinch_handler);
#endif

#if defined HAVE_LOCALE_H
    setlocale(LC_ALL, "");
#endif

    _caca_set_term_title("caca for ncurses");

    initscr();
    keypad(stdscr, TRUE);
    nonl();
    raw();
    noecho();
    nodelay(stdscr, TRUE);
    curs_set(0);

    /* Activate mouse */
    newmask = REPORT_MOUSE_POSITION | ALL_MOUSE_EVENTS;
    mousemask(newmask, &dp->drv.p->oldmask);
    mouseinterval(-1); /* No click emulation */

    /* Set the escape delay to a ridiculously low value */
    ESCDELAY = 10;

    /* Activate colour */
    start_color();

    /* If COLORS == 16, it means the terminal supports full bright colours
     * using setab and setaf (will use \e[90m \e[91m etc. for colours >= 8),
     * we can build 16*16 colour pairs.
     * If COLORS == 8, it means the terminal does not know about bright
     * colours and we need to get them through A_BOLD and A_BLINK (\e[1m
     * and \e[5m). We can only build 8*8 colour pairs. */
    max = COLORS >= 16 ? 16 : 8;

    for(bg = 0; bg < max; bg++)
        for(fg = 0; fg < max; fg++)
        {
            /* Use ((max + 7 - fg) % max) instead of fg so that colour 0
             * is light gray on black. Some terminals don't like this
             * colour pair to be redefined. */
            int col = ((max + 7 - fg) % max) + max * bg;
            init_pair(col, curses_colors[fg], curses_colors[bg]);
            dp->drv.p->attr[fg + 16 * bg] = COLOR_PAIR(col);

            if(max == 8)
            {
                /* Bright fg on simple bg */
                dp->drv.p->attr[fg + 8 + 16 * bg] = A_BOLD | COLOR_PAIR(col);
                /* Simple fg on bright bg */
                dp->drv.p->attr[fg + 16 * (bg + 8)] = A_BLINK
                                                    | COLOR_PAIR(col);
                /* Bright fg on bright bg */
                dp->drv.p->attr[fg + 8 + 16 * (bg + 8)] = A_BLINK | A_BOLD
                                                        | COLOR_PAIR(col);
            }
        }

    caca_add_dirty_rect(dp->cv, 0, 0, dp->cv->width, dp->cv->height);
    dp->resize.allow = 1;
    caca_set_canvas_size(dp->cv, COLS, LINES);
    dp->resize.allow = 0;

    return 0;
//.........这里部分代码省略.........
开发者ID:mwgoldsmith,项目名称:caca,代码行数:101,代码来源:ncurses.c


示例13: raw

char *Buffer::current() const {
    return raw(_cur);
}
开发者ID:laurynas-biveinis,项目名称:ft-index,代码行数:3,代码来源:buffer.cpp


示例14: grow

char *Buffer::alloc(size_t sz) {
    grow(sz);
    char *p = raw(_end);
    _end += sz;
    return p;
}
开发者ID:laurynas-biveinis,项目名称:ft-index,代码行数:6,代码来源:buffer.cpp


示例15: avatar


//.........这里部分代码省略.........
                                    AddWall(Avatars[b].pos.y, Avatars[b].pos.x, Avatars[b].last_move, 0);
                                }
                                break;
                            case M_SOUTH:
                                if (maze->maze[Avatars[b].pos.y][Avatars[b].pos.x].south_wall != 2) {
                                    AddWall(Avatars[b].pos.y, Avatars[b].pos.x, Avatars[b].last_move, 0);
                                }
                                break;
                            case M_EAST:
                                if (maze->maze[Avatars[b].pos.y][Avatars[b].pos.x].east_wall != 2) {
                                    AddWall(Avatars[b].pos.y, Avatars[b].pos.x, Avatars[b].last_move, 0);
                                }
                                break;
                            case M_WEST:
                                if (maze->maze[Avatars[b].pos.y][Avatars[b].pos.x].west_wall != 2) {
                                    AddWall(Avatars[b].pos.y, Avatars[b].pos.x, Avatars[b].last_move, 0);
                                }
                                break;
                            default:
                                AddWall(Avatars[b].pos.y, Avatars[b].pos.x, Avatars[b].last_move, 0);
                                break;
                            }
                            Avatars[b].pos = pos;
                            Avatars[b].direction = Avatars[b].last_move;
                            Avatars[b].last_move = M_NULL_MOVE;
                        }
                    }

                }

                ////////////////graphics////////////////
                //initscr();
                clear();
                raw();
                //start_color();
                create_border(maze->num_col, maze->num_row);
                draw_inside(maze);
                //draw_fakes(maze);
                int f;
                for (f = 0; f<a.nAvatars; f++) {
                    draw_avatar(2*Avatars[f].pos.y+1, 2*Avatars[f].pos.x+1);
                }
                //unsigned int microseconds;
                //microseconds = 200;
                //usleep(microseconds);
                refresh();

                /* Determine the direction of the move for the current Avatar */

                /* Avatar 0 has a fixed location - it never moves */
                if (a.avID == 0) {
                    if(!final_destination) {
                        final_destination = (XYPos *) calloc(1, sizeof(XYPos));
                        final_destination->x = Avatars[a.avID].pos.x;
                        final_destination->y = Avatars[a.avID].pos.y;
                    }
                    move = M_NULL_MOVE;
                }
                // if(!final_destination){
                //   for(int i = 0; i < a.nAvatars; i++){
                //     if (i == a.avID) continue;
                //     //if the Avatar is in the same place as another Avatar, save position as final_destination
                //     if((Avatars[i].pos.x == Avatars[a.avID].pos.x) && (Avatars[i].pos.y == Avatars[a.avID].pos.y)){
                //       final_destination = (XYPos *) calloc(1, sizeof(XYPos));
                //       final_destination->x = Avatars[a.avID].pos.x;
                //       final_destination->y = Avatars[a.avID].pos.y;
开发者ID:daniellemidulla,项目名称:a-maze-ing-client,代码行数:67,代码来源:avatar.c


示例16: initTypeMap

/*! Tries to write the image object to the given fileName.
    Returns true on success.
*/
bool DATImageFileType::write(const Image *image,
                             const Char8 *fileName)
{
    initTypeMap();

    // ok we write always in big endian.
#if BYTE_ORDER == LITTLE_ENDIAN
    Image *pSwapImage = const_cast<Image *>(&(*image));

    pSwapImage->swapDataEndian();
#endif

    std::ofstream dat(fileName, std::ios::binary);

    if(!dat)
    {
        SWARNING << "DATImageFileType::write : Can not open output stream "
                 << "for file '"
                 << fileName
                 << "'!"
                 << std::endl;

        return false;
    }

    Real64 sT[3];
    sT[0] = sT[1] = sT[2] = 1.0;

    const std::string *attr = image->findAttachmentField("SliceThickness");

    if(attr != NULL)
        sscanf(attr->c_str(), "%lf %lf %lf", &sT[0], &sT[1], &sT[2]);

    std::string format = "UCHAR";

    for(std::map<std::string, FormatDesc>::iterator it = _formatStrMap.begin();
        it != _formatStrMap.end();
        ++it)
    {
        if((*it).second.type == image->getDataType())
        {
            format = (*it).first;
            break;
        }
    }

    std::string basename = fileName;
    std::string::size_type i = basename.rfind(".");

    if(i != std::string::npos)
        basename = basename.substr(0, i);

    basename += ".raw";

    std::string name = basename;

    i = name.rfind("/");

    // on windows also a / is possible!
#if defined(WIN32)
    if(i == std::string::npos)
        i = name.rfind("\\");
#endif

    if(i != std::string::npos)
        name = name.substr(i+1);

    dat << "ObjectFileName: " << name << "\n";
    dat << "TaggedFileName: ---\n";
    dat << "Resolution:     " << image->getWidth() << " " << image->getHeight()
        << " "                << image->getDepth() << "\n";
    dat << "SliceThickness: " << sT[0] << " " << sT[1] << " " << sT[2] << "\n";
    dat << "Format:         " << format << "\n";
    dat << "NbrTags:        0\n";
    dat << "ObjectType:     TEXTURE_VOLUME_OBJECT\n";
    dat << "ObjectModel:    DENSITY\n";
    dat << "GridType:       EQUIDISTANT\n";

    if(image->getBpp() > 1)
      dat << "Channel: " << image->getBpp() << "\n";

    dat.close();

    std::ofstream raw(basename.c_str(), std::ios::binary);

    if(!raw)
    {
        SWARNING << "DATImageFileType::write : Can not open output stream "
                 << "for file '"
                 << basename
                 << "'!"
                 << std::endl;

        return false;
    }

    raw.write (reinterpret_cast<const char *>(image->getData()), 
//.........这里部分代码省略.........
开发者ID:jondo2010,项目名称:OpenSG,代码行数:101,代码来源:OSGDATImageFileType.cpp


示例17: raw

	pointer_wrapper<T>::operator typename pointer_wrapper<T>::pointer()
	{
		return raw();
	}
开发者ID:RushOnline,项目名称:libcryptoplus,代码行数:4,代码来源:pointer_wrapper.hpp


示例18: main_menu

void main_menu(const char *curr_path) {
  const char *menu_title = "Main Menu";
  int choice;
  char curr_menu_path[BUFSIZ];
  sprintf(curr_menu_path, "%s > %s", curr_path, menu_title );

  void (*farray[])(const char*) = { cases_menu,
                                    summons_menu,
                                    actions_menu,
                                    reports_menu,
                                    setup_menu,
                                    dbutils_menu
                                  }; 
  initscr();
  raw();
  while(choice != 7) {
    choice = 0;
    noecho();
    curs_set(0);
    clear();
    mvprintw(0, 0, curr_menu_path);
    mvprintw(4, 10, "1. Cases");
    mvprintw(6, 10, "2. Summons");
    mvprintw(8, 10, "3. Actions");
    mvprintw(10, 10, "4. Reports");
    mvprintw(12, 10, "5. Setup");
    mvprintw(14, 10, "6. DB Utils");
    mvprintw(16, 10, "7. Exit");
    mvprintw(18, 10, "Select an option from the above menu, use only the numbers for selection.");
    refresh();
    choice = getch();
    switch(choice) {
      case '1':
        choice = 0;
        break;  
      case '2':
        choice = 1;
        break;
      case '3':
        choice = 2;
        break;
      case '4':
        choice = 3;
        break;
      case '5':
        choice = 4;
        break;
      case '6':
        choice = 5;
        break;
      case '7':
        choice = 7;
        break;
      default:
        beep();
        break;
    }
    if (choice < 7)
      farray[choice](curr_menu_path);
  }
  endwin();
  return;
}
开发者ID:aspacsa,项目名称:vlp,代码行数:63,代码来源:menus.c


示例19: do_curses

static void
do_curses(struct VSM_data *vd)
{
	pthread_t thr;
	int ch;

	if (pthread_create(&thr, NULL, accumulate_thread, vd) != 0) {
		fprintf(stderr, "pthread_create(): %s\n", strerror(errno));
		exit(1);
	}

	initscr();
	raw();
	noecho();
	nonl();
	intrflush(stdscr, FALSE);
	curs_set(0);
	erase();
	for (;;) {
		pthread_mutex_lock(&mtx);
		update(vd);
		pthread_mutex_unlock(&mtx);

		timeout(delay * 1000);
		switch ((ch = getch())) {
		case ERR:
			break;
#ifdef KEY_RESIZE
		case KEY_RESIZE:
			erase();
			break;
#endif
		case '\014': /* Ctrl-L */
		case '\024': /* Ctrl-T */
			redrawwin(stdscr);
			refresh();
			break;
		case '\003': /* Ctrl-C */
			raise(SIGINT);
			break;
		case '\032': /* Ctrl-Z */
			endwin();
			raise(SIGTSTP);
			break;
		case '\021': /* Ctrl-Q */
		case 'Q':
		case 'q':
			endwin();
			return;
		case '0':
		case '1':
		case '2':
		case '3':
		case '4':
		case '5':
		case '6':
		case '7':
		case '8':
		case '9':
			delay = 1 << (ch - '0');
			break;
		default:
			beep();
			break;
		}
	}
}
开发者ID:BabyOnlineSG,项目名称:pkg-varnish,代码行数:67,代码来源:varnishhist.c


示例20: print_flags

 std::string MoveSplineFlag::ToString() const
 {
     std::string str;
     print_flags(raw(),g_SplineFlag_names,str);
     return str;
 }
开发者ID:Alorain,项目名称:server,代码行数:6,代码来源:util.cpp



注:本文中的raw函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ raw_notifier_chain_register函数代码示例发布时间:2022-05-30
下一篇:
C++ rational函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap