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