dtprintinfo: Coverity 89561
[oweals/cde.git] / cde / programs / dtdocbook / instant / hyper.c
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
6  * These libraries and programs are free software; you can
7  * redistribute them and/or modify them under the terms of the GNU
8  * Lesser General Public License as published by the Free Software
9  * Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * These libraries and programs are distributed in the hope that
13  * they will be useful, but WITHOUT ANY WARRANTY; without even the
14  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  * PURPOSE. See the GNU Lesser General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with these libraries and programs; if not, write
20  * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21  * Floor, Boston, MA 02110-1301 USA
22  */
23 /*
24  *  Copyright 1993 Open Software Foundation, Inc., Cambridge, Massachusetts.
25  *  All rights reserved.
26  */
27 /*
28  * Copyright (c) 1994  
29  * Open Software Foundation, Inc. 
30  *  
31  * Permission is hereby granted to use, copy, modify and freely distribute 
32  * the software in this file and its documentation for any purpose without 
33  * fee, provided that the above copyright notice appears in all copies and 
34  * that both the copyright notice and this permission notice appear in 
35  * supporting documentation.  Further, provided that the name of Open 
36  * Software Foundation, Inc. ("OSF") not be used in advertising or 
37  * publicity pertaining to distribution of the software without prior 
38  * written permission from OSF.  OSF makes no representations about the 
39  * suitability of this software for any purpose.  It is provided "as is" 
40  * without express or implied warranty. 
41  */
42 /* ________________________________________________________________________
43  *
44  *  Hypermedia-related facilities.
45  *
46  *  Entry points for this module:
47  *      AddID(elem, idval)              add elem-id pair to list of known ids
48  *      FindElemByID(idval)             find elem by id
49  * ________________________________________________________________________
50  */
51
52 #ifndef lint
53 static char *RCSid =
54   "$XConsortium: hyper.c /main/3 1996/06/19 17:13:07 drk $";
55 #endif
56
57 #include <stdio.h>
58 #include <stdlib.h>
59 #include <ctype.h>
60 #include <string.h>
61 #include <memory.h>
62 #include <sys/types.h>
63
64 #include "general.h"
65
66
67 /* ______________________________________________________________________ */
68
69 void
70 AddID(Element *e, char *idval)
71 {
72     static ID *id_last;
73     if (!IDList) {
74         Calloc(1, id_last, ID);
75         IDList = id_last;
76     }
77     else {
78         Calloc(1, id_last->next, ID);
79         id_last = id_last->next;
80     }
81     id_last->elem = e;
82     id_last->id   = idval;
83 }
84
85 Element *
86 FindElemByID(char *idval)
87 {
88     ID *id;
89     for (id=IDList; id; id=id->next)
90         if (!strcmp(id->id, idval)) return id->elem;
91     return 0;
92 }
93
94 /* ______________________________________________________________________ */
95