Move kfile interface to the io/ directory.
[bertos.git] / bertos / mware / parser.c
index cc20b4e6a79e97a8fefef5e9323fb3e5ef141390..b6b408816c1f7732d0404f5a015f7f238c1b3e31 100644 (file)
  * All Rights Reserved.
  * -->
  *
- * \version $Id$
+ * \brief Channel protocol parser and commands.
  *
- * \author Bernardo Innocenti <bernie@develer.com>
- * \author Stefano Fedrigo <aleph@develer.com>
- * \author Giovanni Bajo <rasky@develer.com>
- *
- * \brief Serial protocol parser and commands.
- *
- * This file contains the serial protocol parser and
+ * This file contains the channel protocol parser and
  * the definition of the protocol commands. Commands are defined
  * in a "CmdTemplate" type array, containing:
  * - the name of the command,
  * using an union: the element of the union to use for each
  * argument is determined by format strings present in the
  * CmdTemplate table.
+ *
+ * \author Bernie Innocenti <bernie@codewiz.org>
+ * \author Stefano Fedrigo <aleph@develer.com>
+ * \author Giovanni Bajo <rasky@develer.com>
+ *
+ *
  */
 
 
 #include "parser.h"
-#include <drv/ser.h>
+
+#include "cfg/cfg_parser.h"
+
+#include <io/kfile.h>
+#include <struct/hashtable.h>
 
 #include <stdlib.h> // atol(), NULL
 #include <string.h> // strchr(), strcmp()
 
-#include <mware/hashtable.h>
-
-#include "appconfig.h"
+//TODO:
+#define CONFIG_INTERNAL_COMMANDS  0
 
 #define ARG_SEP_S " "
 #define ARG_SEP_C ' '
@@ -169,13 +172,13 @@ static bool parseArgs(const char *fmt, const char *input, parms argv[])
  * in the array result, using the format specified
  * in fmt.
  *
- * \param ser     Serial handle.
+ * \param ch     Channel handle.
  * \param fmt     Values format string.
  * \param result  Array containing result to be printed.
  *
  * \return -1 in case of errors, otherwise 0.
  */
-static int printResult(struct Serial *ser, const char *fmt, parms result[])
+static int printResult(KFile *ch, const char *fmt, parms result[])
 {
        long n;
        char repeat_cnt = 0;
@@ -199,23 +202,23 @@ static int printResult(struct Serial *ser, const char *fmt, parms result[])
                                switch (*fmt)
                                {
                                        case 'd':
-                                               ser_printf(ser, ARG_SEP_S "%ld", (*result).l);
+                                               kfile_printf(ch, ARG_SEP_S "%ld", (*result).l);
                                                result++;
                                                break;
                                        case 'c':
-                                               ser_print(ser, ARG_SEP_S);
-                                               ser_print(ser, (*result).s);
+                                               kfile_print(ch, ARG_SEP_S);
+                                               kfile_print(ch, (*result).s);
                                                result++;
                                                break;
                                        case 's':
-                                               ser_printf(ser, ARG_SEP_S "%s", (*result).s);
+                                               kfile_printf(ch, ARG_SEP_S "%s", (*result).s);
                                                result++;
                                                break;
                                        case 'n':
                                                n = (*result++).l;
-                                               ser_printf(ser, ARG_SEP_S "%ld", n);
+                                               kfile_printf(ch, ARG_SEP_S "%ld", n);
                                                while (n--) {
-                                                       ser_printf(ser, ARG_SEP_S "%ld", (*result).l);
+                                                       kfile_printf(ch, ARG_SEP_S "%ld", (*result).l);
                                                        result++;
                                                }
                                                break;
@@ -232,7 +235,7 @@ static int printResult(struct Serial *ser, const char *fmt, parms result[])
        } /* while (*fmt) */
 
 
-       ser_print(ser, "\r\n");
+       kfile_print(ch, "\r\n");
        return 0;
 }
 #endif /* UNUSED_CODE */
@@ -354,6 +357,7 @@ void parser_register_cmd(const struct CmdTemplate* cmd)
 }
 
 #if CONFIG_INTERNAL_COMMANDS
+#warning FIXME:This code use boost lib, if you compile with internal command you must fix it.
 static ResultCode cmd_help(void)
 {
 #ifdef _DEBUG