Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #76539

Re: Data IO for project

From "Morten W. Petersen" <morphex@gmail.com>
Newsgroups comp.lang.c
Subject Re: Data IO for project
Date 2015-11-19 18:42 +0100
Organization Aioe.org NNTP Server
Message-ID <n2l1mc$sud$1@speranza.aioe.org> (permalink)
References <n2kob0$68v$1@speranza.aioe.org> <0e4410a8-8ef1-4b0e-847c-b586828b8b04@googlegroups.com>

Show all headers | View raw


On 19.11.2015 17:12, Malcolm McLean wrote:
> On Thursday, November 19, 2015 at 3:03:17 PM UTC, Morten W. Petersen wrote:
[...]
>> Is there any kind of stream the project also should be able to handle?
>>
> You don't.

OK.

> You provide the functions along the lines of
>
> XMLParser *createparser(void);
> xml_feed(XMLParser *parser, const char *data);
>
> xml_query(XML_Parser *parser);
>
> Now the issue you face is whether xml_query() can be called whilst the parser
> is in a state of being fed, that is, between feed calls. But put that to one side
> for the time being.
>
> First thing is to get the feed() interface going. Now in reality the xml might be
> hosted on an external website under an unreliable connection. But you don't
> worry about that. Your test script is just open an xml file with open(),
> create the parser, feed it lines (or part lines, or chunks, whatever you support),
> and return to your feeding loop. In reality there could be delays of several seconds
> or even minutes between feed calls, but the socket code can worry about that.
>
> If you support query operations before the full data is fed to the parser, then of
> course you need to test that by artificially constructing feeds, and calling the
> query function in between calls.

OK.  But what's a good way to design this?  A while ago I was thinking
of creating a buffer that is a linked list, that could be "fed" or built
as data came in, and the parser loop could block and wait for the
necessary data.

But this means that the parser loop has to run in its own thread, and it
should be possible to use the library without threading.

> Whichever you decide, you'll need an abort of some sort on bad data feeds,
> probably just a sticky error flag - if the error flag is set, just return on any
> more data without attempting to process, then reject all queries.

Well I was thinking of using setjmp/longjmp, to avoid passing back
status codes and checking these.

The library shouldn't be verbose, just a yes/no on success.

-Morten

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Data IO for project "Morten W. Petersen" <morphex@gmail.com> - 2015-11-19 16:03 +0100
  Re: Data IO for project Malcolm McLean <malcolm.mclean5@btinternet.com> - 2015-11-19 08:12 -0800
    Re: Data IO for project "Morten W. Petersen" <morphex@gmail.com> - 2015-11-19 18:42 +0100
      Re: Data IO for project Malcolm McLean <malcolm.mclean5@btinternet.com> - 2015-11-19 12:15 -0800
      Re: Data IO for project Robert Wessel <robertwessel2@yahoo.com> - 2015-11-19 16:17 -0600
        Re: Data IO for project "Morten W. Petersen" <morphex@gmail.com> - 2015-11-20 01:16 +0100
          Re: Data IO for project Robert Wessel <robertwessel2@yahoo.com> - 2015-11-20 00:15 -0600
            Re: Data IO for project "Morten W. Petersen" <morphex@gmail.com> - 2015-11-21 00:37 +0100
  Re: Data IO for project Nobody <nobody@nowhere.invalid> - 2015-11-19 19:59 +0000
    Re: Data IO for project "Morten W. Petersen" <morphex@gmail.com> - 2015-11-20 01:26 +0100
      Re: Data IO for project Malcolm McLean <malcolm.mclean5@btinternet.com> - 2015-11-19 16:46 -0800
      Re: Data IO for project Nobody <nobody@nowhere.invalid> - 2015-11-20 05:08 +0000
        Re: Data IO for project Malcolm McLean <malcolm.mclean5@btinternet.com> - 2015-11-20 02:21 -0800
  Re: Data IO for project Ian Collins <ian-news@hotmail.com> - 2015-11-20 12:00 +1300
    Re: Data IO for project "Morten W. Petersen" <morphex@gmail.com> - 2015-11-20 01:19 +0100
    Re: Data IO for project asetofsymbols@gmail.com - 2015-11-21 12:29 -0800
      Re: Data IO for project Ian Collins <ian-news@hotmail.com> - 2015-11-22 12:13 +1300

csiph-web