Esempio n. 1
0
/**************************************************************************//**
 * @brief Get a command from the terminal on the serialport.
 *****************************************************************************/
static void getCommand( void )
{
  int c;
  int index = 0;

  printf( "\n>" );
  while (1)
  {
    c = getchar();
    if (c > 0)
    {
      /* Output character - most terminals use CRLF */
      if (c == '\r')
      {
        cmdBuffer[index] = '\0';
        splitCommandLine();
        putchar( '\n' );
        return;
      }
      else if (c == '\b')
      {
        printf( "\b \b" );
        if ( index )
          index--;
      }
      else
      {
        /* Filter non-printable characters */
        if ((c < ' ') || (c > '~'))
          continue;

        /* Enter into buffer */
        cmdBuffer[index] = c;
        index++;
        if (index == CMDBUFSIZE)
        {
          cmdBuffer[index] = '\0';
          splitCommandLine();
          return;
        }
        /* Echo char */
        putchar(c);
      }
    }
  }
}
Esempio n. 2
0
static
list *first_pass(FILE *asmfile, dictionary *D)
{

	char commandLine[COMMAND_LINE_BUFFER];
	int c;
	int charsRead;
	int currentLine = 0;

	do
	{
		charsRead = 0;
		currentLine++;
		c = fgetc(asmfile);
		commandLine[0] = '\0';
		while(c != '\n' && c != '#' && c != EOF)
		{
			if (charsRead++ > COMMAND_LINE_BUFFER)
			{
			    fprintf(stderr, "%s : ", commandLine);
				error(E_CMDLINE_BUF, ACTION_PRINTMSG);
				break;
			}
			commandLine[charsRead-1] = c;
			commandLine[charsRead] = '\0';
			c = fgetc(asmfile);
		}
		if (commandLine[0] != '\0')
		{
			splitCommandLine(commandLine, currentLine, D);
		}
		if (c == '#')
			while ((c = fgetc(asmfile))!= '\n' && c != EOF);
	}while(c != EOF);

    return L1;
}