Lines Matching defs:mohandle
70 static int validate(void *, struct mohandle *);
371 validate(void *arg, struct mohandle *mohandle)
376 if (p < (char *)mohandle->addr ||
377 p > (char *)mohandle->addr + mohandle->len)
440 expand_sysdep(struct mohandle *mohandle, struct mosysdepstr_h *str)
457 mohandle->mo.mo_sysdep_segs[str->segs[i].ref].len;
471 memcpy(dst, mohandle->mo.mo_sysdep_segs[str->segs[i].ref].str,
472 mohandle->mo.mo_sysdep_segs[str->segs[i].ref].len);
473 dst += mohandle->mo.mo_sysdep_segs[str->segs[i].ref].len;
496 setup_sysdep_stuffs(struct mo *mo, struct mohandle *mohandle, char *base)
507 mohandle->mo.mo_sysdep_nsegs = flip(mo->mo_sysdep_nsegs, magic);
508 mohandle->mo.mo_sysdep_nstring = flip(mo->mo_sysdep_nstring, magic);
510 if (mohandle->mo.mo_sysdep_nstring == 0)
514 if (mohandle->mo.mo_hsize <= 2 ||
515 mohandle->mo.mo_hsize <
516 (mohandle->mo.mo_nstring + mohandle->mo.mo_sysdep_nstring))
520 l = sizeof(struct mosysdepsegs_h) * mohandle->mo.mo_sysdep_nsegs;
521 mohandle->mo.mo_sysdep_segs = (struct mosysdepsegs_h *)malloc(l);
522 if (!mohandle->mo.mo_sysdep_segs)
526 for (i=0; i<mohandle->mo.mo_sysdep_nsegs; i++) {
528 mohandle->mo.mo_sysdep_segs[i].str =
531 &mohandle->mo.mo_sysdep_segs[i].len);
535 mohandle->mo.mo_sysdep_otable =
536 (struct mosysdepstr_h **)calloc(mohandle->mo.mo_sysdep_nstring,
538 if (!mohandle->mo.mo_sysdep_otable)
542 if (get_sysdep_string_table(mohandle->mo.mo_sysdep_otable, ofstable,
543 mohandle->mo.mo_sysdep_nstring, magic,
546 mohandle->mo.mo_sysdep_ttable =
547 (struct mosysdepstr_h **)calloc(mohandle->mo.mo_sysdep_nstring,
549 if (!mohandle->mo.mo_sysdep_ttable)
553 if (get_sysdep_string_table(mohandle->mo.mo_sysdep_ttable, ofstable,
554 mohandle->mo.mo_sysdep_nstring, magic,
559 for (i=0; i<mohandle->mo.mo_sysdep_nstring; i++) {
560 if (expand_sysdep(mohandle, mohandle->mo.mo_sysdep_otable[i]))
562 insert_to_hash(mohandle->mo.mo_htable,
563 mohandle->mo.mo_hsize,
564 mohandle->mo.mo_sysdep_otable[i]->expanded,
585 struct mohandle *mohandle = &db->mohandle;
587 if (mohandle->addr && mohandle->addr != MAP_FAILED &&
588 mohandle->mo.mo_magic)
624 mohandle->addr = mmap(NULL, (size_t)st.st_size, PROT_READ,
626 if (!mohandle->addr || mohandle->addr == MAP_FAILED) {
631 mohandle->len = (size_t)st.st_size;
633 base = mohandle->addr;
634 mo = (struct mo *)mohandle->addr;
637 mohandle->mo.mo_magic = mo->mo_magic;
638 mohandle->mo.mo_revision = flip(mo->mo_revision, magic);
639 mohandle->mo.mo_nstring = flip(mo->mo_nstring, magic);
640 mohandle->mo.mo_hsize = flip(mo->mo_hsize, magic);
641 mohandle->mo.mo_flags = flags;
648 if (!validate(otable, mohandle) ||
649 !validate(&otable[mohandle->mo.mo_nstring], mohandle)) {
653 if (!validate(ttable, mohandle) ||
654 !validate(&ttable[mohandle->mo.mo_nstring], mohandle)) {
660 l = sizeof(struct moentry_h) * mohandle->mo.mo_nstring;
661 mohandle->mo.mo_otable = (struct moentry_h *)malloc(l);
662 if (!mohandle->mo.mo_otable) {
666 mohandle->mo.mo_ttable = (struct moentry_h *)malloc(l);
667 if (!mohandle->mo.mo_ttable) {
671 p = mohandle->mo.mo_otable;
672 for (i = 0; i < mohandle->mo.mo_nstring; i++) {
676 if (!validate(p[i].off, mohandle) ||
677 !validate(p[i].off + p[i].len + 1, mohandle)) {
682 p = mohandle->mo.mo_ttable;
683 for (i = 0; i < mohandle->mo.mo_nstring; i++) {
687 if (!validate(p[i].off, mohandle) ||
688 !validate(p[i].off + p[i].len + 1, mohandle)) {
694 if (mohandle->mo.mo_hsize > 2) {
695 l = sizeof(uint32_t) * mohandle->mo.mo_hsize;
696 mohandle->mo.mo_htable = (uint32_t *)malloc(l);
697 if (!mohandle->mo.mo_htable) {
703 for (i=0; i < mohandle->mo.mo_hsize; i++) {
704 mohandle->mo.mo_htable[i] = flip(htable[i], magic);
705 if (mohandle->mo.mo_htable[i] >=
706 mohandle->mo.mo_nstring+1) {
714 mohandle->mo.mo_header = lookup("", db, &headerlen);
715 if (mohandle->mo.mo_header)
716 v = strstr(mohandle->mo.mo_header, "charset=");
720 mohandle->mo.mo_charset = strdup(v + 8);
721 if (!mohandle->mo.mo_charset)
723 v = strchr(mohandle->mo.mo_charset, '\n');
727 if (!mohandle->mo.mo_header ||
728 _gettext_parse_plural(&mohandle->mo.mo_plural,
729 &mohandle->mo.mo_nplurals,
730 mohandle->mo.mo_header, headerlen))
731 mohandle->mo.mo_plural = NULL;
742 if ((mohandle->mo.mo_flags & MO_F_SYSDEP) != 0) {
743 if (setup_sysdep_stuffs(mo, mohandle, base)) {
774 struct mohandle *mohandle = &db->mohandle;
777 if (mohandle->addr && mohandle->addr != MAP_FAILED)
778 munmap(mohandle->addr, mohandle->len);
779 mohandle->addr = NULL;
780 free(mohandle->mo.mo_otable);
781 free(mohandle->mo.mo_ttable);
782 free(mohandle->mo.mo_charset);
783 free(mohandle->mo.mo_htable);
784 free(mohandle->mo.mo_sysdep_segs);
785 free_sysdep_table(mohandle->mo.mo_sysdep_otable,
786 mohandle->mo.mo_sysdep_nstring);
787 free_sysdep_table(mohandle->mo.mo_sysdep_ttable,
788 mohandle->mo.mo_sysdep_nstring);
789 _gettext_free_plural(mohandle->mo.mo_plural);
790 memset(&mohandle->mo, 0, sizeof(mohandle->mo));
798 struct mohandle *mohandle = &db->mohandle;
803 if (mohandle->mo.mo_hsize <= 2 || mohandle->mo.mo_htable == NULL)
807 step = calc_collision_step(hashval, mohandle->mo.mo_hsize);
808 idx = hashval % mohandle->mo.mo_hsize;
811 strno = mohandle->mo.mo_htable[idx];
819 if (len <= mohandle->mo.mo_otable[strno].len &&
820 !strcmp(msgid, mohandle->mo.mo_otable[strno].off)) {
824 mohandle->mo.mo_ttable[strno].len;
825 return mohandle->mo.mo_ttable[strno].off;
830 sysdep_otable = mohandle->mo.mo_sysdep_otable[strno];
831 sysdep_ttable = mohandle->mo.mo_sysdep_ttable[strno];
835 if (expand_sysdep(mohandle, sysdep_ttable))
843 idx = calc_next_index(idx, mohandle->mo.mo_hsize, step);
853 struct mohandle *mohandle = &db->mohandle;
856 bottom = mohandle->mo.mo_nstring;
866 if ((size_t)middle >= mohandle->mo.mo_nstring)
869 n = strcmp(msgid, mohandle->mo.mo_otable[middle].off);
872 *rlen = mohandle->mo.mo_ttable[middle].len;
873 return (const char *)mohandle->mo.mo_ttable[middle].off;
1000 db->mohandle.mo.mo_magic)
1023 if (db->mohandle.mo.mo_plural) {
1025 _gettext_calculate_plural(db->mohandle.mo.mo_plural, n);
1026 if (plural_index >= db->mohandle.mo.mo_nplurals)
1037 if (db->mohandle.mo.mo_plural)