コード例 #1
0
ファイル: CONFIG.C プロジェクト: TMSWhite/CognitiveBiasTask
int	CONFIGparse_lines(int num_entries, char **conf_menu)
{
	char  *token="";
	int	which_tag;
	char	*argv_list[CONFIG_MAX_ARGS+1];
	char	**argv = &argv_list[1];	// so that argv[-1] = command tag
	int	argc;


	for (token=CONFIGget_arg();token!=(char *) 0;token=CONFIGget_arg()) {
		if (*token == '\n') {	// blank line
			continue;
		}

		/* Is first arg on the line a valid tag? */
		if (!CONFIGistag(token,num_entries,conf_menu,&which_tag)){
			printf("WARN(L%i): Invalid tag \"%s\"\n",CONFIGline, token);
			++CONFIGerrs;
			continue;
		}

		/** Make array of grabbed tokens and pass them to parser.  Note that
			token replaces occurances of tokensep with '\0', so buf becomes
			a discrete set of strings whose pointers can be stored in argv **/

		argv[-1] = token;
		argc = 0;
		while ((token = CONFIGget_arg()) != (char *) 0) {
			if (argc >= CONFIG_MAX_ARGS) {
				(void) printf("ERR(L%i):  Too many args (max %i)\n",
					CONFIGline, CONFIG_MAX_ARGS);
				++CONFIGerrs;
				goto next_line;
			}
			if (*token == '\n')
				break;
			argv[argc++] = token;
		}
		if (!CBTparse(which_tag, argc, argv)) {
			++CONFIGerrs;
			continue;
		}
		continue;

next_line:
		while ((token=CONFIGget_arg()) != (char *) 0)
			if (*token == '\n')
				break;
	}
	if (CONFIGerrs > 0) {
		printf("<press a key to continue>");
		GetAKey();
	}
	return (!CONFIGerrs);
}
コード例 #2
0
ファイル: hostc.c プロジェクト: jamjr/Helios-NG
PUBLIC VOID SpGetkey()
{
#if (BOARD_ID == UDP)
/* the udp version of iserver requires that the link is kept active,
   if it is inactive for X seconds the transputer will reset itself.
   Therefore this function polls the keyboard & sends an ACTIVE frame
   every X seconds to keep the transputer alive. */
   BUFFER_DECLARATIONS;
   BYTE c;
   int timeval1,timeval2,finished;

#ifdef VMS
   struct CHARACTERISTICS {
			     short  Count;
			     char   ch;
			     char   res1;
			     long   res2;
			   } Chars;
#endif

   DEBUG(( "SP.GETKEY {udp}" ));
   INIT_BUFFERS;           
   finished = FALSE;  
   time (&timeval1);

   while (!finished) {
     time (&timeval2);
     /* if 10 seconds elapsed, check link still active */
     if ((timeval2-timeval1) >= QUIETTIMEOUT) {
       if (TestLink(TheLink) != SUCCEEDED) {
	 finished = TRUE;
	 PUT_BYTE( SP_ERROR );
	 break;
       } else {
	 time (&timeval1);
       };
     };

#ifdef MSC
     if (kbhit()) {
       c = getch();
       PUT_BYTE( SP_SUCCESS );
       PUT_BYTE( c );    
       finished = TRUE;
     };
#endif

#ifdef SUN          
     if ( TermMode == ORG_MODE ) {
       CurMode.c_iflag &= ~ICRNL;
       CurMode.c_lflag &= ~(ICANON | ECHO);
       CurMode.c_cc[VTIME] = 1;
       CurMode.c_cc[VMIN] = 0;
       ioctl( 0, TCSETS, &CurMode );
       TermMode = POLL_MODE;
      } else {
	if ( TermMode == GET_MODE ) {
	  CurMode.c_cc[VTIME] = 1;
	  CurMode.c_cc[VMIN] = 0;
	  ioctl( 0, TCSETS, &CurMode );
	  TermMode = POLL_MODE;
	};
      };
      if (read(0, &c, 1) != 0) {
	PUT_BYTE( SP_SUCCESS );
	PUT_BYTE( c );   
	finished = TRUE;
      };
#endif

#ifdef VMS
     (void)SYS$QIOW( 0, InputChan, (IO$_SENSEMODE | IO$M_TYPEAHDCNT ), &iosb_desc, 0, 0, &Chars, sizeof(struct CHARACTERISTICS), 0, 0, 0, 0 ) ;
     if (Chars.Count > 0) {
       (void)SYS$QIOW( 0, InputChan, (IO$_READVBLK | IO$M_NOECHO | IO$M_NOFILTR ), &iosb_desc, 0, 0, &c, 1, 0, 0L, 0, 0 );
       PUT_BYTE( SP_SUCCESS );
       PUT_BYTE( c );   
       finished = TRUE;
     };
#endif

#ifdef HELIOS
    if ( TermMode == ORG_MODE ) {
      RemoveAttribute(&CurAttributes,ConsoleEcho);
      AddAttribute(&CurAttributes,ConsoleRawInput);
      AddAttribute(&CurAttributes,ConsoleBreakInterrupt);
      SetAttributes(InputStream,&CurAttributes);
      TermMode = POLL_MODE;
     }
     if ( Read( InputStream, &c, 1, OneSec/10 ) == 1 ) {
       PUT_BYTE( SP_SUCCESS );
       PUT_BYTE( c );  
       finished = TRUE;
     };
#endif 
   };   /* end of while */
 
   DEBUG(("key was %c",c));
   REPLY;
#else
   BUFFER_DECLARATIONS;
   BYTE c;

   DEBUG(( "SP.GETKEY {non-udp}" ));
   INIT_BUFFERS;

   c = GetAKey();

   DEBUG(("key was %c",c));
   PUT_BYTE( SP_SUCCESS );
   PUT_BYTE( c );  
   REPLY;
#endif
}