2 * lmo - Lua Machine Objects - General header
4 * Copyright (C) 2009-2012 Jo-Philipp Wich <xm@subsignal.org>
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
19 #ifndef _TEMPLATE_LMO_H_
20 #define _TEMPLATE_LMO_H_
29 #include <arpa/inet.h>
36 #if (defined(__GNUC__) && defined(__i386__))
37 #define sfh_get16(d) (*((const uint16_t *) (d)))
39 #define sfh_get16(d) ((((uint32_t)(((const uint8_t *)(d))[1])) << 8)\
40 +(uint32_t)(((const uint8_t *)(d))[0]) )
49 } __attribute__((packed
));
51 typedef struct lmo_entry lmo_entry_t
;
61 struct lmo_archive
*next
;
64 typedef struct lmo_archive lmo_archive_t
;
69 struct lmo_archive
*archives
;
70 struct lmo_catalog
*next
;
73 typedef struct lmo_catalog lmo_catalog_t
;
76 uint32_t sfh_hash(const char *data
, int len
);
77 uint32_t lmo_canon_hash(const char *data
, int len
);
79 lmo_archive_t
* lmo_open(const char *file
);
80 void lmo_close(lmo_archive_t
*ar
);
83 extern lmo_catalog_t
*_lmo_catalogs
;
84 extern lmo_catalog_t
*_lmo_active_catalog
;
86 int lmo_load_catalog(const char *lang
, const char *dir
);
87 int lmo_change_catalog(const char *lang
);
88 int lmo_translate(const char *key
, int keylen
, char **out
, int *outlen
);
89 void lmo_close_catalog(const char *lang
);