]> rtime.felk.cvut.cz Git - sysless.git/commitdiff
Attempt to make HELP command working even without use of stdio.h. Declaration of...
authorMichal Sojka <sojkam1@fel.cvut.cz>
Mon, 13 Nov 2006 09:02:00 +0000 (09:02 +0000)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Mon, 13 Nov 2006 09:02:00 +0000 (09:02 +0000)
darcs-hash:20061113090212-f2ef6-dc2a14a3ef24d8a5a24658d9493bad6273323217.gz

libs4c/misc/cmd_bth.h
libs4c/misc/cmd_proc.c
libs4c/misc/cmd_proc.h

index cdcf8b22bff1114f63ba1e7890b1cc237e341423..9df4d623ad0ef96c0e346876436489caa36a840c 100644 (file)
@@ -5,7 +5,7 @@
 
 cmd_des_t const **cmd_bth;
 
-cmd_io_t cmd_io_bth;
+extern cmd_io_t cmd_io_bth;
 
 int cmd_bth_line_out(cmd_io_t *cmd_io);
 
@@ -13,4 +13,6 @@ int cmd_bth_line_in(cmd_io_t *cmd_io);
 
 char *cmd_bth_rdline(cmd_io_t *cmd_io, int mode);
 
-#endif
\ No newline at end of file
+int cmd_bth_processor_run(void);
+
+#endif
index 9362fdefc487b5a013afc475fc0e52b4bd0a2b3f..6c2b09ff79e582836d187474872aa8ef230790a9 100644 (file)
@@ -49,13 +49,12 @@ inline int cmd_io_read(struct cmd_io *cmd_io,void *buf,int count)
 
 
 #endif /* declared inline */
-int cmd_send_string(cmd_io_t *cmd_io, char *q)
+
+int cmd_io_send_string(cmd_io_t *cmd_io, char *str)
 {
-/*  int i=0;
-  while((*(q+i)!=0) && (cmd_io_putc(cmd_io,*(q+i)))>=0)
-  {
-    i++;
-  };*/
+  for (; *str; str++) {
+    cmd_io_putc(cmd_io, *str);
+  }
   return 0;
 };
 
@@ -156,11 +155,11 @@ int proc_cmd_line(cmd_io_t *cmd_io, cmd_des_t const **des_arr, char *line)
       des_arr=arr_stack[--arr_stack_sp];
       continue;
     }
-    if(des==(cmd_des_t*)1){
+    if(des==CMD_DES_CONTINUE_AT){
       /* list continues at new address */
       des_arr=(const cmd_des_t **)*des_arr;continue;
     }
-    if(des==(cmd_des_t*)2){
+    if(des==CMD_DES_INCLUDE_SUBLIST){
       /* list includes commands from sublists */
       if(arr_stack_sp>=CMD_ARR_STACK_SIZE){
         des_arr++;
@@ -256,6 +255,8 @@ int cmd_do_help(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
   }
 #ifndef CONFIG_NO_STDIO
   printf("Help for commands\n");
+#else
+  cmd_io_send_string(cmd_io, "Help for commands\n");
 #endif
   while(1){
     des=*(des_arr++);
@@ -264,12 +265,12 @@ int cmd_do_help(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
       des_arr=arr_stack[--arr_stack_sp];
       continue;
     }
-    if(des==(cmd_des_t*)1){
+    if(des==CMD_DES_CONTINUE_AT){
       /* list continues at new address */
       des_arr=(const cmd_des_t **)*des_arr;
       continue;
     }
-    if(des==(cmd_des_t*)2){
+    if(des==CMD_DES_INCLUDE_SUBLIST){
       /* list includes commands from sublists */
       if(arr_stack_sp>=CMD_ARR_STACK_SIZE){
         des_arr++;
@@ -284,8 +285,10 @@ int cmd_do_help(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
         help=des->help;
         if(!help) help="?";
 #ifdef CONFIG_NO_STDIO
-//        cmd_send_string(cmd_io,(char*)(des->name));
-//        cmd_io_putc(cmd_io,*(char*)(des->name));
+        cmd_io_send_string(cmd_io,des->name);
+        cmd_io_send_string(cmd_io," - ");
+        cmd_io_send_string(cmd_io,help);
+        cmd_io_send_string(cmd_io, "\n");
 #else
        printf("  %s - %s\n",des->name,help);
 #endif
index ce2d174f0f6a35eceb5a2f276e001529e6af6fa6..1e5d744cc97064928ad80c5c6b9610432b04f11d 100644 (file)
@@ -18,6 +18,8 @@
 #define FL_ELB_INSEND 0x20      /* The line is currently being sent */
 #define FL_ELB_NOCRLF 0x40      /* CR and/or LF will not start the new line */
 
+#define CMD_DES_CONTINUE_AT     ((cmd_des_t*)1)
+#define CMD_DES_INCLUDE_SUBLIST ((cmd_des_t*)2)
 /* generic cmd_io tructure */
 
 /* buffer for in/out line collection */