On Tue, Sep 11, 2012 at 02:34:09PM +0200, Markus Armbruster wrote: > Bharata B Rao <bhar...@linux.vnet.ibm.com> writes: > > > From: Bharata B Rao <bhar...@linux.vnet.ibm.com> > > > > Make inet_parse() non static. > > > > - Make inet_parse() non-static so that other subsystems like gluster > > can use it to parse inet addresses. As a pre-requisite, define and > > globalize the qemu_inet_opts. > > Please repost this as part of a series that needs non-static > inet_parse().
Sure, will post it as part of next version of gluster patches. > I'm worried parameter "block" will cause trouble, but I > can't see that without the users. I don't see how that could affect the users. FYI I am not using "block" parameter, pls wait for my next post to check this. > > > - Extend inet_parse() to parse just 'address' also in addition to > > 'address:port'. > > Separate patch, please. Hmm ok. > > > Signed-off-by: Bharata B Rao <bhar...@linux.vnet.ibm.com> > > --- > > Ideally I needn't use sscanf twice once for parsing host:port (checking > > return value of 2) and if that fails for parsing host w/o port (checking > > return value of 1). I could just check if sscanf returned 2 or 1 and decide > > if addr:port or just addr was provided, but in the latter case the > > pointer to the bytes consumed (&pos) doesn't get updated. > > You can use two of them, like this: > > a_end = b_end = -1; > sscanf(str, "%d%n:%d%n", &a, &a_end, &b, &b_end); > if (b_end >= 0) ... Thanks. Bharata.