]> git.saurik.com Git - apple/libc.git/blob - nls/FreeBSD/msgcat.h
Libc-763.12.tar.gz
[apple/libc.git] / nls / FreeBSD / msgcat.h
1 /* $FreeBSD: src/lib/libc/nls/msgcat.h,v 1.9 2005/02/01 16:04:55 phantom Exp $ */
2
3 #ifndef _MSGCAT_H_
4 #define _MSGCAT_H_
5
6
7 /***********************************************************
8 Copyright 1990, by Alfalfa Software Incorporated, Cambridge, Massachusetts.
9
10 All Rights Reserved
11
12 Permission to use, copy, modify, and distribute this software and its
13 documentation for any purpose and without fee is hereby granted,
14 provided that the above copyright notice appear in all copies and that
15 both that copyright notice and this permission notice appear in
16 supporting documentation, and that Alfalfa's name not be used in
17 advertising or publicity pertaining to distribution of the software
18 without specific, written prior permission.
19
20 ALPHALPHA DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
21 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
22 ALPHALPHA BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
23 ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
24 WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
25 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
26 SOFTWARE.
27
28 If you make any modifications, bugfixes or other changes to this software
29 we'd appreciate it if you could send a copy to us so we can keep things
30 up-to-date. Many thanks.
31 Kee Hinckley
32 Alfalfa Software, Inc.
33 267 Allston St., #3
34 Cambridge, MA 02139 USA
35 nazgul@alfalfa.com
36
37 ******************************************************************/
38
39 /*
40 * Magic definitions
41 */
42
43 #define MCMagicLen 8
44 #define MCMagic "*nazgul*"
45
46 #define MCMajorVer 1L
47 #define MCMinorVer 0
48
49 /* For or'd constants */
50 #define MCMakeId(s,m) (unsigned long) ( ((unsigned short)s << (sizeof(short)*8)) \
51 | (unsigned short)m )
52
53 /*
54 * Critical note here. Sets and Messages *MUST* be stored in ascending
55 * order. There are stored that way (by specification) in the original
56 * data file, however in the process of merging in new stuff you might
57 * mix that up. Don't! The catget stuff does a binary search and will
58 * totally lose it if these aren't in order (not contiguous mind you, just
59 * in order. If this turns out to be a major problem this could be enhanced
60 * by adding a 'sorted' flag to the db, and sorting msgs and sets at load
61 * time if things aren't sorted, but I'd like not to have to do that.
62 */
63
64 /*
65 * I have tried here to define data structures which can be used
66 * while the catalog is on disk, and at runtime.
67 * This is rather dangerous of course, but I think it can be done without
68 * overly increasing the memory usage, and it makes loading and storing
69 * somewhat simpler and less prone to accidents. I have also tried to
70 * define on disk data structures which can be updated in place, so that
71 * with a very large catalog (e.g. all system errors) you don't have to
72 * load everything in memory in order to add or update one set. With
73 * this in mind there are "invalid" flags which allow items to be
74 * invalidated and thus not loaded at runtime. Note however that although
75 * I pay attention to these when I load the DB, I do not currently use
76 * them in gencat (it just reads everything into memory), so there is
77 * no guarantee that this will all work.
78 */
79
80 /*
81 * MCOffsetT - Union to handle both disk and runtime pointers
82 */
83 typedef union {
84 off_t off;
85 char *str;
86 void *ptr;
87 struct _MCMsgT *msg;
88 struct _MCSetT *set;
89 } MCOffsetT;
90
91 /*
92 * MCMsgT - Message structure (disk and runtime)
93 */
94 typedef struct _MCMsgT {
95 long msgId; /* Id of this message */
96 MCOffsetT msg; /* Relative offset on disk or pointer in memory */
97 long invalid; /* Valid on disk, loaded in memory */
98 } MCMsgT;
99
100 /*
101 * MCSetT - Set structure (disk and runtime)
102 */
103 typedef struct _MCSetT {
104 long setId; /* Id of this set */
105 off_t nextSet; /* Offset of next set on disk */
106 union {
107 off_t firstMsg; /* Offset to first Msg (while on disk) */
108 MCMsgT *msgs; /* Pointer to array of msgs (in mem, loaded) */
109 } u;
110 MCOffsetT data; /* Offset to data, or pointer to data */
111 long dataLen; /* Length of data area on disk */
112 long numMsgs; /* Number of messages */
113 long invalid; /* Valid on disk, loaded in memory */
114 } MCSetT;
115
116 /*
117 * MCCatT - Runtime catalog pointer
118 */
119 typedef struct {
120 FILE *fp; /* File descriptor of catalog (if load-on-demand) */
121 long numSets; /* Number of sets */
122 MCSetT *sets; /* Pointer to the sets */
123 off_t firstSet; /* Offset of first set on disk */
124 } MCCatT;
125
126 /*
127 * MCHeaderT - Disk file header
128 */
129 typedef struct {
130 char magic[MCMagicLen]; /* Magic cookie "*nazgul*" */
131 long majorVer; /* ++ on incompatible changes */
132 long minorVer; /* ++ on compatible changes */
133 long flags; /* Informational flags */
134 long numSets; /* Number of valid Sets */
135 off_t firstSet; /* Offset of first set on disk */
136 } MCHeaderT;
137
138 /* Some flags */
139 #define MC68KByteOrder 0x01
140 #define MCn86ByteOrder 0x02
141
142 #endif /* !_MSGCAT_H_ */