Explorar o código

sercmd: updated to the new mi_rpc format

- updated to the new mi output format
- support for tab completion for mi_dg, mi_fifo and mi_xmlrpc
Andrei Pelinescu-Onciul %!s(int64=16) %!d(string=hai) anos
pai
achega
ad12d90508
Modificáronse 1 ficheiros con 12 adicións e 12 borrados
  1. 12 12
      utils/sercmd/sercmd.c

+ 12 - 12
utils/sercmd/sercmd.c

@@ -314,6 +314,9 @@ char* complete_params_cfg_var[]={
 /* commands for which we complete the first param with an mi command*/
 /* commands for which we complete the first param with an mi command*/
 char* complete_params_mi[]={
 char* complete_params_mi[]={
 	"mi",
 	"mi",
+	"mi_fifo",
+	"mi_dg",
+	"mi_xmlrpc",
 	0
 	0
 };
 };
 #endif /* USE_MI */
 #endif /* USE_MI */
@@ -1423,10 +1426,10 @@ static int get_mi_list(int s)
 	for (r=0; r<mi_which_no; r++){
 	for (r=0; r<mi_which_no; r++){
 		if (mi_which_array[r].type!=BINRPC_T_STR)
 		if (mi_which_array[r].type!=BINRPC_T_STR)
 			continue;
 			continue;
-		/* we are interestend only in lines starting with '+', e.g.:
-		   + :: version */
+		/* we are interestend only in lines starting with ':', e.g.:
+		   :: version */
 		if ((mi_which_array[r].u.strval.len) &&
 		if ((mi_which_array[r].u.strval.len) &&
-			(mi_which_array[r].u.strval.s[0]=='+'))
+			(mi_which_array[r].u.strval.s[0]==':'))
 			mi_which_results++;
 			mi_which_results++;
 	}
 	}
 	/* no mi commands */
 	/* no mi commands */
@@ -1442,29 +1445,26 @@ static int get_mi_list(int s)
 			continue;
 			continue;
 		p=mi_which_array[r].u.strval.s;
 		p=mi_which_array[r].u.strval.s;
 		end=p+mi_which_array[r].u.strval.len;
 		end=p+mi_which_array[r].u.strval.len;
-		/* we are interestend only in lines starting with '+', e.g.:
-		   + :: version */
-		if ((p>=end) || (*p!='+'))
+		/* we are interestend only in lines starting with ':', e.g.:
+			:: version */
+		if ((p>=end) || (*p!=':'))
 			continue;
 			continue;
 		p++;
 		p++;
-		/* skip over to the first ':' */
-		for(;p<end && *p!=':'; p++);
-		if (p>=end) continue;
-		p++;
 		/* skip over to the next ':' */
 		/* skip over to the next ':' */
 		for(;p<end && *p!=':'; p++);
 		for(;p<end && *p!=':'; p++);
 		if (p>=end) continue;
 		if (p>=end) continue;
 		p++;
 		p++;
 		/* skip over spaces */
 		/* skip over spaces */
 		for(;p<end && (*p==' ' || *p=='\t'); p++);
 		for(;p<end && (*p==' ' || *p=='\t'); p++);
-		if (p>=end) continue;
+		if (p>=end || *p=='\n') continue;
 		if (mi_cmds_no >= mi_which_results){
 		if (mi_cmds_no >= mi_which_results){
 			fprintf(stderr, "BUG: wrong mi cmds no (%d >= %d)\n",
 			fprintf(stderr, "BUG: wrong mi cmds no (%d >= %d)\n",
 							mi_cmds_no, mi_which_results);
 							mi_cmds_no, mi_which_results);
 			goto error;
 			goto error;
 		}
 		}
 		mi_name.s=p;
 		mi_name.s=p;
-		mi_name.len=(int)(long)(end-p);
+		for(; p<end && *p!=' ' && *p!='\t' && *p!='\n'; p++);
+		mi_name.len=(int)(long)(p-mi_name.s);
 		mi_cmds[mi_cmds_no]=mi_name;
 		mi_cmds[mi_cmds_no]=mi_name;
 		mi_cmds_no++;
 		mi_cmds_no++;
 	}
 	}