[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [freehaven-dev] how to use tags.c ?
On Sun, Mar 26, 2000 at 11:16:54AM -0500, firstname.lastname@example.org wrote:
> <QUZ> want eat Moon </QUZ>
> So if the file above was named "parseme", I could say
> tag_t parsed;
> char* what_does_quz_want;
> parsed = build_tag_list_from_file("parseme");
> what_does_quz_want = get_tag(parsed, "QUZ");
> and then
> what_does_quz_want = "want eat Moon"
Note that you passed over a subtle but possibly tricky point here: the
build_tag functions eat whitespace on each side of tags and endtags. This
means that yes, your value will be "want eat Moon", not " want eat Moon "
as the markup in your example might suggest.
Also note that it's polite to free_tag_list() on whatever build_tag_list*()
returned, once you're done with it.
> In the comm module for sending, we get the message over a socket from
> haven. We process it and then place the message in a file somewhere. Then
Yep. You should be able to swipe the code for this wholesale, from towards
the end of haven.c. (The only really tricky part is making sure you don't
read half of the </message> on one read and the other half of the next, and
end up writing </message> into your file and never realizing it.)
> we call "build_tag_list_from_file" on the message, and get a tag_t
> pointing to the first tag in the message.
> Then the comm needs to know what kind of message it is sending (broadcast
> or directed), so it calls get_tag(message, "TYPE"). Then it may call
> something like get_tag(message, "DESTINATION") or otherwise switch off the
> message type.