<HTML>
<HEAD>
<!-- Changed by: Henrik Frystyk Nielsen, 23-Mar-1996 -->
<TITLE>W3C Sample Code Library libwww Atom Class</TITLE>
</HEAD>
<BODY>
<H1>
The Atom Class
</H1>
<PRE>
/*
** (c) COPYRIGHT MIT 1995.
** Please first read the full copyright statement in the file COPYRIGH.
*/
</PRE>
<P>
The <CODE>Atom Class defines s</CODE>trings which are given representative
pointer values so that they can be stored more efficiently, and comparisons
for equality done more efficiently. The list of <CODE>atoms</CODE> is stored
in a hash table, so when asking for a new atom you might in fact get back an
existing one.
<P>
<B>Note</B>: There are a whole bunch of
<A HREF="HTFormat.html#FormatTypes">MIME-types</A> defined as
<CODE>atoms</CODE>, so please use them!
<P>
This module is implemented by <A HREF="HTAtom.c">HTAtom.c</A>, and it is
a part of the <A HREF="http://www.w3.org/Library/"> W3C Sample Code
Library</A>.
<PRE>
#ifndef HTATOM_H
#define HTATOM_H
#include "HTList.h"
typedef struct _HTAtom HTAtom;
struct _HTAtom {
HTAtom * next;
char * name;
}; /* struct _HTAtom */
</PRE>
<H3>
Get an Atom
</H3>
<P>
This function returns a representative value (an <CODE>atom</CODE>) such
that it will always (within one run of the program) return the same value
for the same given string. The former is case sensitive, the latter is case
insensitive.
<PRE>
extern HTAtom * HTAtom_for (const char * string);
extern HTAtom * HTAtom_caseFor (const char * string);
</PRE>
<H3>
Get Content of an Atom
</H3>
<PRE>
#define HTAtom_name(a) ((a) ? (a)->name : NULL)
</PRE>
<P>
This macro returns the string pointed to by the <CODE>atom</CODE>.
<H3>
Search For Atoms
</H3>
<P>
Returns a list of <CODE>atoms</CODE> which matches the template given. It
is especially made for MIME-types so that for example a template like
<CODE>text<slash><star></CODE> returns a list of all MIME-types
of type <CODE>text</CODE>.
<PRE>
extern HTList * HTAtom_templateMatches (const char * templ);
</PRE>
<H3>
Cleanup Memory
</H3>
<P>
In order to cleanup memory, call this function. This is done automaticly
from the <A HREF="HTReq.html#Library">HTLibTerminate</A> function.
<PRE>
extern void HTAtom_deleteAll (void);
#endif
</PRE>
<P>
<HR>
<ADDRESS>
@(#) $Id: HTAtom.html,v 2.27 2000/07/04 15:23:24 kahan Exp $
</ADDRESS>
</BODY></HTML>
Webmaster