+tReadline *Readline_Init(int bUseHistory)
+{
+ tReadline *ret = calloc( 1, sizeof(tReadline) );
+ ret->UseHistory = bUseHistory;
+ ret->BufferSize = 0;
+
+ ret->History = malloc( 1 * sizeof(*ret->History) );
+ ret->History[0] = NULL;
+ ret->NumHistory = 1;
+
+ return ret;
+}
+
+/**
+ */
+char *Readline_NonBlock(tReadline *Info)
+{
+ int len, i;
+
+ // Read as much as possible (appending to remaining data)
+ len = read(STDIN_FD, Info->ReadBuffer, READ_BUFFER_SIZE - 1 - Info->ReadBufferLen);
+ if( len <= 0 ) return NULL;
+ Info->ReadBuffer[Info->ReadBufferLen + len] = '\0';
+
+ // Parse the data we have
+ for( i = 0; i < len; )
+ {
+ int size = Readline_int_ParseCharacter(Info, Info->ReadBuffer+i);
+ if( size <= 0 ) break; // Error, skip the rest?
+ i += size;
+ }
+
+ // Move the unused data to the start of the buffer
+ memcpy(Info->ReadBuffer, &Info->ReadBuffer[Info->ReadBufferLen + i], len - i);
+ Info->ReadBufferLen = len - i;
+
+ // Is the command finished?
+ if( Info->OutputValue ) {
+ char *ret = Info->OutputValue;
+ Info->OutputValue = NULL; // Mark as no command pending
+ return ret; // Return the string (now the caller's responsibility)
+ }
+
+ // Return NULL when command is still being edited
+ return NULL;
+}
+