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