#include <cfg/debug.h>
#include <cfg/log.h>
+#include <drv/timer.h>
#include <mware/formatwr.h>
#include <string.h>
};
+/**
+ * Discard input to resynchronize with remote end.
+ *
+ * Discard incoming data until the kfile_getc stops receiving
+ * characters for at least \a delay milliseconds.
+ *
+ * \note If the timeout occur, we reset the error before to
+ * quit.
+ */
+void kfile_resync(KFile *fd, mtime_t delay)
+{
+ ticks_t start_time = timer_clock();
+ for(;;)
+ {
+ if(kfile_getc(fd) != EOF)
+ start_time = timer_clock();
+
+ if ((timer_clock() - start_time) > ms_to_ticks(delay))
+ {
+ kfile_clearerr(fd);
+ break;
+ }
+
+ }
+}
+
+
int kfile_print(struct KFile *fd, const char *s);
int kfile_gets(struct KFile *fd, char *buf, int size);
int kfile_gets_echo(struct KFile *fd, char *buf, int size, bool echo);
+void kfile_resync(KFile *fd, mtime_t delay);
/**
* Interface functions for KFile access.