1 /* plist.h -- header file for the plist module.
2 Copyright (C) 2003, 2004
3 National Institute of Advanced Industrial Science and Technology (AIST)
4 Registration Number H15PRO112
6 This file is part of the m17n library.
8 The m17n library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Lesser General Public License
10 as published by the Free Software Foundation; either version 2.1 of
11 the License, or (at your option) any later version.
13 The m17n library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
18 You should have received a copy of the GNU Lesser General Public
19 License along with the m17n library; if not, write to the Free
20 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
23 #ifndef _M17N_PLIST_H_
24 #define _M17N_PLIST_H_
28 /** Header for a managed object. */
31 /**en Key of the first element of the plist. If the value is Mnil,
32 this is the tail of the plist. In that case, <val> and <next> is
33 NULL. If the value is a managing key, <val> is a managed
37 /**en Value of the first element of the plist. */
40 /**en Plist for the next element. */
44 /** Macros to access each member of PLIST. */
46 #define MPLIST_KEY(plist) ((plist)->key)
47 #define MPLIST_VAL(plist) ((plist)->val)
48 #define MPLIST_VAL_MANAGED_P(plist) ((plist)->control.flag)
49 #define MPLIST_NEXT(plist) ((plist)->next)
50 #define MPLIST_TAIL_P(plist) ((plist)->key == Mnil)
52 #define MPLIST_SYMBOL_P(plist) (MPLIST_KEY (plist) == Msymbol)
53 #define MPLIST_STRING_P(plist) (MPLIST_KEY (plist) == Mstring)
54 #define MPLIST_MTEXT_P(plist) (MPLIST_KEY (plist) == Mtext)
55 #define MPLIST_INTEGER_P(plist) (MPLIST_KEY (plist) == Minteger)
56 #define MPLIST_PLIST_P(plist) (MPLIST_KEY (plist) == Mplist)
58 #define MPLIST_SYMBOL(plist) ((MSymbol) MPLIST_VAL (plist))
59 #define MPLIST_STRING(plist) ((char *) MPLIST_VAL (plist))
60 #define MPLIST_MTEXT(plist) ((MText *) MPLIST_VAL (plist))
61 #define MPLIST_INTEGER(plist) ((int) MPLIST_VAL (plist))
62 #define MPLIST_PLIST(plist) ((MPlist *) MPLIST_VAL (plist))
64 #define MPLIST_FIND(plist, key) \
66 while (! MPLIST_TAIL_P (plist) && MPLIST_KEY (plist) != (key)) \
67 (plist) = (plist)->next; \
71 #define MPLIST_DO(elt, plist) \
72 for ((elt) = (plist); ! MPLIST_TAIL_P (elt); (elt) = MPLIST_NEXT (elt))
74 #define MPLIST_LENGTH(plist) \
75 (MPLIST_TAIL_P (plist) ? 0 \
76 : MPLIST_TAIL_P ((plist)->next) ? 1 \
77 : MPLIST_TAIL_P ((plist)->next->next) ? 2 \
78 : mplist_length (plist))
81 extern unsigned char hex_mnemonic[256];
82 extern unsigned char escape_mnemonic[256];
84 extern MPlist *mplist__from_file (FILE *fp);
86 extern MPlist *mplist__from_plist (MPlist *plist);
88 extern MPlist *mplist__from_alist (MPlist *plist);
90 extern MPlist *mplist__from_string (unsigned char *str, int n);
92 extern int mplist__serialize (MText *mt, MPlist *plist);
94 #endif /* _M17N_PLIST_H_ */