[RFC] gsmd multi-line response support, 2nd try

pHilipp Zabel philipp.zabel at gmail.com
Tue Jul 31 11:11:58 CEST 2007


On 7/31/07, Harald Welte <laforge at openmoko.org> wrote:
> On Mon, Jun 18, 2007 at 04:16:41PM +0200, Philipp Zabel wrote:
> > Hi!
> >
> > This second try works much better in that every extended response causes
> > a flush of the previous mlbuf and starts collecting new response lines.
> > Also, final_cb is now really only reached for final responses and the
> > code for case 'A' won't overwrite the command buffer with the response
> > anymore. I throw in '\n' as a separator for multi-line responses, and
> > the callback is called for each response this way.
>
> I've now committed this patch, just changing one minor detail: the
> static size of 1024 for mlbuf has been replaced with a constat that's
> defined in the header file to 65535.
>
> I'd actually prefer to have that buffer static in bss, rather than
> putting it on the stack every time we enter the parser.

Like this?

Index: src/gsmd/atcmd.c
===================================================================
--- src/gsmd/atcmd.c	(revision 2581)
+++ src/gsmd/atcmd.c	(working copy)
@@ -171,13 +171,14 @@
 	return -1;
 }

+static char mlbuf[MLPARSE_BUF_SIZE];
+static int mlbuf_len;
+
 static int ml_parse(const char *buf, int len, void *ctx)
 {
 	struct gsmd *g = ctx;
 	struct gsmd_atcmd *cmd = NULL;
-	static char mlbuf[MLPARSE_BUF_SIZE];
 	int rc = 0, final = 0;
-	int mlbuf_len;

 	DEBUGP("buf=`%s'(%d)\n", buf, len);



More information about the gsmd-devel mailing list