[sr-dev] git:master: sercmd: updated to the new mi_rpc format

Andrei Pelinescu-Onciul andrei at iptel.org
Mon Jul 13 22:41:27 CEST 2009


Module: sip-router
Branch: master
Commit: ad12d90508ef5f896ef0327362971cd9afba81f2
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=ad12d90508ef5f896ef0327362971cd9afba81f2

Author: Andrei Pelinescu-Onciul <andrei at iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei at iptel.org>
Date:   Mon Jul 13 22:40:33 2009 +0200

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

---

 utils/sercmd/sercmd.c |   24 ++++++++++++------------
 1 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/utils/sercmd/sercmd.c b/utils/sercmd/sercmd.c
index 0c26d9e..9c9edf0 100644
--- a/utils/sercmd/sercmd.c
+++ b/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*/
 char* complete_params_mi[]={
 	"mi",
+	"mi_fifo",
+	"mi_dg",
+	"mi_xmlrpc",
 	0
 };
 #endif /* USE_MI */
@@ -1423,10 +1426,10 @@ static int get_mi_list(int s)
 	for (r=0; r<mi_which_no; r++){
 		if (mi_which_array[r].type!=BINRPC_T_STR)
 			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) &&
-			(mi_which_array[r].u.strval.s[0]=='+'))
+			(mi_which_array[r].u.strval.s[0]==':'))
 			mi_which_results++;
 	}
 	/* no mi commands */
@@ -1442,29 +1445,26 @@ static int get_mi_list(int s)
 			continue;
 		p=mi_which_array[r].u.strval.s;
 		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;
 		p++;
-		/* skip over to the first ':' */
-		for(;p<end && *p!=':'; p++);
-		if (p>=end) continue;
-		p++;
 		/* skip over to the next ':' */
 		for(;p<end && *p!=':'; p++);
 		if (p>=end) continue;
 		p++;
 		/* skip over spaces */
 		for(;p<end && (*p==' ' || *p=='\t'); p++);
-		if (p>=end) continue;
+		if (p>=end || *p=='\n') continue;
 		if (mi_cmds_no >= mi_which_results){
 			fprintf(stderr, "BUG: wrong mi cmds no (%d >= %d)\n",
 							mi_cmds_no, mi_which_results);
 			goto error;
 		}
 		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_no++;
 	}




More information about the sr-dev mailing list