1 /* $Id: recctrl.c,v 1.6 2002-08-02 19:26:56 adam Exp $
2 Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
5 This file is part of the Zebra server.
7 Zebra is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 2, or (at your option) any later
12 Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 You should have received a copy of the GNU General Public License
18 along with Zebra; see the file LICENSE.zebra. If not, write to the
19 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
34 struct recTypeEntry *next;
41 struct recTypeEntry *entries;
44 RecTypes recTypes_init (data1_handle dh)
46 RecTypes p = (RecTypes) nmem_malloc (data1_nmem_get (dh), sizeof(*p));
53 void recTypes_destroy (RecTypes rts)
55 struct recTypeEntry *rte;
57 for (rte = rts->entries; rte; rte = rte->next)
59 (*(rte->recType)->destroy)(rte->clientData);
62 void recTypes_add_handler (RecTypes rts, RecType rt)
64 struct recTypeEntry *rte;
66 rte = (struct recTypeEntry *)
67 nmem_malloc (data1_nmem_get (rts->dh), sizeof(*rte));
72 rte->next = rts->entries;
76 RecType recType_byName (RecTypes rts, const char *name, char *subType,
79 struct recTypeEntry *rte;
83 strcpy (tmpname, name);
84 if ((p = strchr (tmpname, '.')))
87 strcpy (subType, p+1);
91 for (rte = rts->entries; rte; rte = rte->next)
92 if (!strcmp (rte->recType->name, tmpname))
98 (*(rte->recType)->init)(rte->recType);
100 *clientDataP = rte->clientData;
106 void recTypes_default_handlers (RecTypes rts)
108 recTypes_add_handler (rts, recTypeGrs);
109 recTypes_add_handler (rts, recTypeText);