Add GNU LGPL headers to all .c .C and .h files
[oweals/cde.git] / cde / programs / dthelp / parser / canon1 / parser / ifdata.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 librararies 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 /* $XConsortium: ifdata.c /main/3 1995/11/08 09:38:00 rswiston $ */
24 /* Copyright 1988, 1989 Hewlett-Packard Co. */
25
26 /* Ifdata.c contains functions used by the interface to access the
27    single item of interface-determined data stored on the parse stack. */
28
29 #include <stdio.h>
30 #include "basic.h"
31 #include "trie.h"
32 #include "dtdext.h"
33 #include "parser.h"
34
35 /* Retrieve the interface data stored with the current element's nth parent */
36 void *m_getdata(n, flag)
37   int n ;
38   LOGICAL *flag ;
39   {
40     M_PARSE *stackptr ;
41
42     for (stackptr = m_stacktop ;
43          stackptr->oldtop && n >= 0 ;
44          stackptr = stackptr->oldtop, n--) {
45       if (! n) {
46         *flag = TRUE ;
47         return(stackptr->ifdata) ;
48         }
49       }
50     *flag = FALSE ;
51     return(NULL) ;
52     }
53
54 /* Store interface data for the current element's nth parent */
55 LOGICAL m_putdata(data, n)
56   void *data ;
57   int n ;
58   {
59     M_PARSE *stackptr ;
60
61     for (stackptr = m_stacktop ;
62          stackptr->oldtop && n >= 0 ;
63          stackptr = stackptr->oldtop, n--) {
64       if (! n) {
65         stackptr->ifdata = data ;
66         return(TRUE) ;
67         }
68       }
69     return(FALSE) ;
70     }
71