PebbleOS
Loading...
Searching...
No Matches
Data Structures | Macros

Layout of gettext MO files, used for language packs. More...

Data Structures

struct  MoHeader
 MO file header. More...
 
struct  MoEntry
 Entry of the original or translated strings table. More...
 
struct  Mo
 Loaded MO file. More...
 
struct  MoHandle
 Handle to a loaded MO file. More...
 

Macros

#define MO_MAGIC   0x950412de
 Magic number at the start of an MO file.
 
#define MO_GET_REV_MAJOR(r)   (((r) >> 16) & 0xFFFF)
 Get the major part of an MO file revision.
 
#define MO_GET_REV_MINOR(r)   ((r) & 0xFFFF)
 Get the minor part of an MO file revision.
 
#define MO_MAKE_REV(maj, min)   (((maj) << 16) | (min))
 Build an MO file revision.
 
#define LANG_PROP_NAME   "Language: "
 Header property holding the ISO locale of the language.
 

Detailed Description

Layout of gettext MO files, used for language packs.

Offsets are in bytes from the start of the file:

*           byte
*                +------------------------------------------+
*             0  | magic number = 0x950412de                |
*                |                                          |
*             4  | file format revision = 0                 |
*                |                                          |
*             8  | number of strings                        |  == N
*                |                                          |
*            12  | offset of table with original strings    |  == O
*                |                                          |
*            16  | offset of table with translation strings |  == T
*                |                                          |
*            20  | size of hashing table                    |  == S
*                |                                          |
*            24  | offset of hashing table                  |  == H
*                |                                          |
*                .                                          .
*                .    (possibly more entries later)         .
*                .                                          .
*                |                                          |
*             O  | length & offset 0th string  ----------------.
*         O + 8  | length & offset 1st string  ------------------.
*                 ...                                    ...   | |
*   O + ((N-1)*8)| length & offset (N-1)th string           |  | |
*                |                                          |  | |
*             T  | length & offset 0th translation  ---------------.
*         T + 8  | length & offset 1st translation  -----------------.
*                 ...                                    ...   | | | |
*   T + ((N-1)*8)| length & offset (N-1)th translation      |  | | | |
*                |                                          |  | | | |
*             H  | start hash table                         |  | | | |
*                 ...                                    ...   | | | |
*     H + S * 4  | end hash table                           |  | | | |
*                |                                          |  | | | |
*                | NUL terminated 0th string  <----------------' | | |
*                |                                          |    | | |
*                | NUL terminated 1st string  <------------------' | |
*                |                                          |      | |
*                 ...                                    ...       | |
*                |                                          |      | |
*                | NUL terminated 0th translation  <---------------' |
*                |                                          |        |
*                | NUL terminated 1st translation  <-----------------'
*                |                                          |
*                 ...                                    ...
*                |                                          |
*                +------------------------------------------+
* 

Data Structure Documentation

◆ MoHeader

struct MoHeader

MO file header.

Data Fields
uint32_t mo_hoffset Offset of the hash table (H).
uint32_t mo_hsize Number of entries in the hash table (S).
uint32_t mo_magic Magic number, MO_MAGIC; determines the endianness.
uint32_t mo_nstring Number of strings (N).
uint32_t mo_otable Offset of the original strings table (O).
uint32_t mo_revision File format revision, 0.
uint32_t mo_ttable Offset of the translated strings table (T).

◆ MoEntry

struct MoEntry

Entry of the original or translated strings table.

Data Fields
uint32_t len String length without terminator; the string occupies len + 1 bytes.
uint32_t off Offset of the NUL-terminated string.

◆ Mo

struct Mo

Loaded MO file.

Data Fields
MoHeader hdr File header.
uint32_t * mo_htable Hash table (H), loaded into RAM.
char * mo_lang Language of the file.

Currently unused.

◆ MoHandle

struct MoHandle

Handle to a loaded MO file.

Data Fields
size_t len Size of the file in bytes.
Mo mo Loaded file.

Macro Definition Documentation

◆ LANG_PROP_NAME

#define LANG_PROP_NAME   "Language: "

Header property holding the ISO locale of the language.

◆ MO_GET_REV_MAJOR

#define MO_GET_REV_MAJOR (   r)    (((r) >> 16) & 0xFFFF)

Get the major part of an MO file revision.

Parameters
rRevision.

◆ MO_GET_REV_MINOR

#define MO_GET_REV_MINOR (   r)    ((r) & 0xFFFF)

Get the minor part of an MO file revision.

Parameters
rRevision.

◆ MO_MAGIC

#define MO_MAGIC   0x950412de

Magic number at the start of an MO file.

◆ MO_MAKE_REV

#define MO_MAKE_REV (   maj,
  min 
)    (((maj) << 16) | (min))

Build an MO file revision.

Parameters
majMajor part.
minMinor part.