libs/web: further endian fixes in lmo processing
This commit is contained in:
parent
5f76dada3c
commit
6bec9b6bcf
1 changed files with 8 additions and 5 deletions
|
@ -244,6 +244,7 @@ int lmo_change_catalog(const char *lang)
|
||||||
static lmo_entry_t * lmo_find_entry(lmo_archive_t *ar, uint32_t hash)
|
static lmo_entry_t * lmo_find_entry(lmo_archive_t *ar, uint32_t hash)
|
||||||
{
|
{
|
||||||
unsigned int m, l, r;
|
unsigned int m, l, r;
|
||||||
|
uint32_t k;
|
||||||
|
|
||||||
l = 0;
|
l = 0;
|
||||||
r = ar->length - 1;
|
r = ar->length - 1;
|
||||||
|
@ -255,10 +256,12 @@ static lmo_entry_t * lmo_find_entry(lmo_archive_t *ar, uint32_t hash)
|
||||||
if (r < l)
|
if (r < l)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (ar->index[m].key_id == hash)
|
k = ntohl(ar->index[m].key_id);
|
||||||
|
|
||||||
|
if (k == hash)
|
||||||
return &ar->index[m];
|
return &ar->index[m];
|
||||||
|
|
||||||
if (ar->index[m].key_id > hash)
|
if (k > hash)
|
||||||
{
|
{
|
||||||
if (!m)
|
if (!m)
|
||||||
break;
|
break;
|
||||||
|
@ -283,14 +286,14 @@ int lmo_translate(const char *key, int keylen, char **out, int *outlen)
|
||||||
if (!key || !_lmo_active_catalog)
|
if (!key || !_lmo_active_catalog)
|
||||||
return -2;
|
return -2;
|
||||||
|
|
||||||
hash = htonl(lmo_canon_hash(key, keylen));
|
hash = lmo_canon_hash(key, keylen);
|
||||||
|
|
||||||
for (ar = _lmo_active_catalog->archives; ar; ar = ar->next)
|
for (ar = _lmo_active_catalog->archives; ar; ar = ar->next)
|
||||||
{
|
{
|
||||||
if ((e = lmo_find_entry(ar, hash)) != NULL)
|
if ((e = lmo_find_entry(ar, hash)) != NULL)
|
||||||
{
|
{
|
||||||
*out = ar->mmap + e->offset;
|
*out = ar->mmap + ntohl(e->offset);
|
||||||
*outlen = e->length;
|
*outlen = ntohl(e->length);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue