8 #define V(p) be32toh(*(uint32_t *)(p))
10 static int cmp(const void *a
, const void *b
)
12 uint32_t x
= V(a
), y
= V(b
);
13 return x
<y
? -1 : x
>y
? 1 : 0;
16 char *catgets (nl_catd catd
, int set_id
, int msg_id
, const char *s
)
18 const char *map
= (const char *)catd
;
19 uint32_t nsets
= V(map
+4);
20 const char *sets
= map
+20;
21 const char *msgs
= map
+20+V(map
+12);
22 const char *strings
= map
+20+V(map
+16);
23 uint32_t set_id_be
= htobe32(set_id
);
24 uint32_t msg_id_be
= htobe32(msg_id
);
25 const char *set
= bsearch(&set_id_be
, sets
, nsets
, 12, cmp
);
30 uint32_t nmsgs
= V(set
+4);
32 const char *msg
= bsearch(&msg_id_be
, msgs
, nmsgs
, 12, cmp
);
37 return (char *)(strings
+ V(msg
+8));