+static char *hist_search_backward(char* buf, uint8_t num)
+{
+ hist_node *p = hist_cur;
+
+ if (p == NULL)
+ return NULL;
+
+ while (p->next && strncmp(p->line, buf, num))
+ p = p->next;
+
+ if(!strncmp(p->line, buf, num)) {
+ hist_cur = p->next;
+ return p->line;
+ }
+ return NULL;
+}
+
+static char *hist_search_forward (char* buf, uint8_t num)
+{
+ hist_node *p = NULL;
+ hist_node *match = NULL;
+ hist_node *q = hist_head;
+
+ if(q == hist_cur)
+ return NULL;
+
+ while(q->next != hist_cur) {
+ p = q;
+ q = q->next;
+ if (p && !strncmp(p->line, buf, num))
+ match = p;
+ }
+
+ if(match) {
+ hist_cur = match->next;
+ return match->line;
+ }
+ return NULL;
+}
+
+static void putnstr(char *str, int n)
+{
+ /* printf_P(PSTR("%.*s"), (int)n, str) */
+ while (n-- && *str)
+ putchar(*str++);
+}
+
+static void getcmd_putch(int ch) { putchar(ch);}
+static int getcmd_getch(void) { return vt_parse();}
+static void getcmd_cbeep(void) { getcmd_putch('\a');}