W3C home > Mailing lists > Public > www-lib@w3.org > July to September 1999

Redirect in meta tag (was: How to get a binary e.g. from an URL if another request-object exists ?)

From: Vaclav Barta <vbar@comp.cz>
Date: Mon, 23 Aug 1999 18:20:07 +0000
Message-ID: <37C190D7.43FF66A9@comp.cz>
To: wwwlib <www-lib@w3.org>
CC: tobi@ibs.debis.de
> From: "Tobias Fischer" <tobi@ibs.debis.de>
> To: "'Vaclav Barta'" <vbar@comp.cz>
> Subject: AW: How to get a binary e.g. from an URL if another request-object > exists ? 
> Date: Mon, 23 Aug 1999 14:11:14 +0200 
[snip my badly thought-out suggestion]
> I'am sitting in front of Michael and tried these lines bevor your message
> out... It seams that the libwww does not handle the META EQUIV-Tag in the
> same manner. But thank you for your mail.
> After tesing theses lines again, I looked to amaya and found out that amaya
> can't handle this Tag too.
> Is there anyone other with the same Problem ( or a solution :) )
Actually, it's not that complicated to just parse the tag in the
element callback:

/* if you already have element callbacks, don't use these, just
   add to yours */
void HandleStartTag(HText *text,
    int	element_number,
    const BOOL *present,
    const char **value);
void HandleEndTag(HText *text,
    int element_number);

/* somewhere at the beginning */
    HText_registerElementCallback(HandleStartTag, HandleEndTag);

void HandleStartTag(HText *text,
    int	element_number,
    const BOOL *present,
    const char **value)
{
    if (element_number == HTML_META &&
        present[HTML_META_HTTP_EQUIV] &&
	value[HTML_META_HTTP_EQUIV] &&
	    /* not sure this test is needed, but it doesn't hurt */
	!strcasecmp(value[HTML_META_HTTP_EQUIV], "refresh") &&
	    /* if you don't have strcasecmp, use stricmp or
	       something */
	present[HTML_META_CONTENT] &&
	value[HTML_META_CONTENT])
	    /* not sure this test is needed, but it doesn't hurt */
    {   /* AFAIK this is as far as we get with support from
	   libwww. We must continue on our own, but we're
	   almost there... */
	const char *p = FindNoCase(value[HTML_META_CONTENT],
	    "URL=");
	    /* FindNoCase is a function I'm embarrassed to post; it
	       works like case-ignoring strstr */
        if (p)
	{   p += 4;
	    printf("%s\n", p);
	    /* I didn't actually try to load the URL here,
	       but I hope it would... :-) */
	}
    }
}


/* it's a pity HText_registerElementCallback requires end tag
   callback even when we really don't need it */
void HandleEndTag(HText *text,
    int element_number)
{
}


This does parse meta tags like
<META HTTP-EQUIV=REFRESH CONTENT="5; URL=http://localhost/goal.html">
but I confess I've never seen a formal definition of their syntax,
so your mileage may vary. If somebody knows the definition, please
let me know.

	Bye
		Vasek
--
I have a search engine, too!
http://www.locus.cz/locus/
Received on Tuesday, 24 August 1999 00:34:29 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 5 February 2014 07:15:17 UTC