#include "console.h" #include Console::Console(QObject *parent) : QSocketNotifier(STDIN_FILENO, QSocketNotifier::Read, parent) { connect(this, SIGNAL(activated(int)), this, SLOT(process())); printf("Waiting for Console Input\n"); } void Console::process(){ char buffer[1024]; QString com, temp; QStringList arguments; int len = fread(buffer, 1024, 1, stdin); char inquote = '\0'; for(int i=0; i 0) { arguments << temp; temp.clear(); } inquote = '\0'; } else if(buffer[i] == '"' || buffer[i] == '\''){ temp = temp.trimmed(); if(temp.length() > 0) { arguments << temp; temp.clear(); } inquote = buffer[i]; } else { temp.append(buffer[i]); } } temp = temp.trimmed(); if(temp.length() > 0) { arguments << temp; } if(arguments.size() > 0){ com = arguments.value(0); arguments.removeFirst(); emit command(com, arguments); // this is an emitor! } }