static int load_locale_sub(int category, const char *locname, int isspecial) { char name[PATH_MAX]; /* check for the default locales */ if (!strcmp(new_categories[category], "C") || !strcmp(new_categories[category], "POSIX")) { revert_to_default(category); return(0); } /* check whether special symbol */ if (isspecial && _bcs_strcasecmp(locname, _LOCALE_SYM_FORCE) == 0) return(force_locale_enable(category)); /* sanity check */ if (strchr(locname, '/') != NULL) return(-1); snprintf(name, sizeof(name), "%s/%s/%s", _PathLocale, locname, categories[category].name); if (category > 0 && category < (int)__arysize(categories) && categories[category].load_function != NULL) return(categories[category].load_function(locname)); return(0); }
static int find_src(struct src_head *sh, struct src_entry **rse, const char *name) { int ret; struct src_entry *se; STAILQ_FOREACH(se, sh, se_entry) { if (_bcs_strcasecmp(se->se_name, name) == 0) { *rse = se; return (0); } } se = malloc(sizeof(*se)); if (se == NULL) return (errno); se->se_name = strdup(name); if (se->se_name == NULL) { ret = errno; free(se); return (ret); } ret = _db_factory_create(&se->se_df, &_db_hash_std, NULL); if (ret) { free(se->se_name); free(se); return (ret); } STAILQ_INSERT_TAIL(sh, se, se_entry); *rse = se; return (0); }
static int load_locale_sub( int category, const char *locname, int isspecial ) { char name[PATH_MAX]; /* check for the default locales */ if (!strcmp(new_categories[category], "C") || !strcmp(new_categories[category], "POSIX")) { revert_to_default(category); return 0; } /* check whether special symbol */ if (isspecial && _bcs_strcasecmp(locname, _LOCALE_SYM_FORCE) == 0) return force_locale_enable(category); /* sanity check */ if (strchr(locname, '/') != NULL) return -1; (void)snprintf(name, sizeof(name), "%s/%s/%s", _PathLocale, locname, categories[category]); switch (category) { case LC_CTYPE: #ifdef WITH_RUNE if (_xpg4_setrunelocale(__UNCONST(locname))) return -1; if (__runetable_to_netbsd_ctype(locname)) { /* very unfortunate, but need to go to "C" locale */ revert_to_default(category); return -1; } #else if (!__loadctype(name)) return -1; #endif break; case LC_MESSAGES: /* * XXX we don't have LC_MESSAGES support yet, * but catopen may use the value of LC_MESSAGES category. * so return successfully if locale directory is present. */ (void)snprintf(name, sizeof(name), "%s/%s", _PathLocale, locname); /* local */ { struct stat st; if (stat(name, &st) < 0) return -1; if (!S_ISDIR(st.st_mode)) return -1; } break; case LC_COLLATE: case LC_MONETARY: case LC_NUMERIC: case LC_TIME: return -1; } return 0; }