home *** CD-ROM | disk | FTP | other *** search
/ Serving the Web / ServingTheWeb1995.disc1of1.iso / linux / slacksrce / d / libc / libc-4.6 / libc-4 / libc-linux / nls / msgcat.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-11-16  |  5.7 KB  |  179 lines

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