diff --git a/lib/libc/nls/msgcat.c b/lib/libc/nls/msgcat.c index 86fba82692cf..767f56525edc 100644 --- a/lib/libc/nls/msgcat.c +++ b/lib/libc/nls/msgcat.c @@ -64,14 +64,12 @@ __FBSDID("$FreeBSD$"); #define NLERR ((nl_catd) -1) #define NLRETERR(errc) { errno = errc; return (NLERR); } -static nl_catd loadCat(); -static int loadSet(); -static void __nls_free_resources(); +static nl_catd loadCat(__const char *); +static int loadSet(MCCatT *, MCSetT *); +static void __nls_free_resources(MCCatT *, int); nl_catd -catopen(name, type) - __const char *name; - int type; +catopen(__const char *name, int type) { int spcleft, saverr; char path[PATH_MAX]; @@ -158,7 +156,7 @@ catopen(name, type) (pathP - path) - 1; if (strlcpy(pathP, tmpptr, spcleft) >= spcleft) { - too_long: + too_long: free(plang); free(base); NLRETERR(ENAMETOOLONG); @@ -240,9 +238,7 @@ catopen(name, type) } static MCSetT * -MCGetSet(cat, setId) - MCCatT *cat; - int setId; +MCGetSet(MCCatT *cat, int setId) { MCSetT *set; long lo, hi, cur, dir; @@ -256,9 +252,7 @@ MCGetSet(cat, setId) } static MCMsgT * -MCGetMsg(set, msgId) - MCSetT *set; - int msgId; +MCGetMsg(MCSetT *set, int msgId) { MCMsgT *msg; long lo, hi, cur, dir; @@ -270,11 +264,7 @@ MCGetMsg(set, msgId) } char * -catgets(catd, setId, msgId, dflt) - nl_catd catd; - int setId; - int msgId; - __const char *dflt; +catgets(nl_catd catd, int setId, int msgId, __const char *dflt) { MCMsgT *msg; MCCatT *cat = (MCCatT *)catd; @@ -291,8 +281,7 @@ catgets(catd, setId, msgId, dflt) } int -catclose(catd) - nl_catd catd; +catclose(nl_catd catd) { MCCatT *cat = (MCCatT *)catd; @@ -300,10 +289,8 @@ catclose(catd) errno = EBADF; return (-1); } -#if 0 - if (cat->loadType != MCLoadAll) -#endif - (void)fclose(cat->fp); + + (void)fclose(cat->fp); __nls_free_resources(cat, cat->numSets); free(cat); return (0); @@ -333,9 +320,7 @@ static char *_errowner = "Message Catalog System"; } static void -__nls_free_resources(cat, i) - MCCatT *cat; - int i; +__nls_free_resources(MCCatT *cat, int i) { MCSetT *set; int j; @@ -351,8 +336,7 @@ __nls_free_resources(cat, i) } static nl_catd -loadCat(catpath) - __const char *catpath; +loadCat(__const char *catpath) { MCHeaderT header; MCCatT *cat; @@ -363,7 +347,6 @@ loadCat(catpath) if ((cat = (MCCatT *)malloc(sizeof(MCCatT))) == NULL) return (NLERR); - cat->loadType = MCLoadBySet; if ((cat->fp = fopen(catpath, "r")) == NULL) { saverr = errno; @@ -417,36 +400,15 @@ loadCat(catpath) nextSet = set->nextSet; continue; } -#if 0 - if (cat->loadType == MCLoadAll) { - int res; - - if ((res = loadSet(cat, set)) <= 0) { - saverr = errno; - __nls_free_resources(cat, i); - errno = saverr; - if (res < 0) - NOSPACE(); - CORRUPT(); - } - } else -#endif - set->invalid = TRUE; + set->invalid = TRUE; nextSet = set->nextSet; } -#if 0 - if (cat->loadType == MCLoadAll) { - (void)fclose(cat->fp); - cat->fp = NULL; - } -#endif + return ((nl_catd) cat); } static int -loadSet(cat, set) - MCCatT *cat; - MCSetT *set; +loadSet(MCCatT *cat, MCSetT *set) { MCMsgT *msg; int i; diff --git a/lib/libc/nls/msgcat.h b/lib/libc/nls/msgcat.h index f13d88823110..403b33c83c9c 100644 --- a/lib/libc/nls/msgcat.h +++ b/lib/libc/nls/msgcat.h @@ -36,26 +36,19 @@ up-to-date. Many thanks. ******************************************************************/ - -#include - /* - * On disk data structures + * Magic definitions */ +#define MCMagicLen 8 +#define MCMagic "*nazgul*" + +#define MCMajorVer 1L +#define MCMinorVer 0 + /* For or'd constants */ #define MCMakeId(s,m) (unsigned long) ( ((unsigned short)s << (sizeof(short)*8)) \ | (unsigned short)m ) -#define MCSetId(id) (unsigned int) ( id >> (sizeof(short) * 8) ) -#define MCMsgId(id) (unsigned int) ( (id << (sizeof(short) * 8)) \ - >> (sizeof(short) * 8) ) -#define MCMagicLen 8 -#define MCMagic "*nazgul*" -#define MCLastMsg 0 -#define MCLastSet 0 - -#define MCMajorVer 1L -#define MCMinorVer 0 /* * Critical note here. Sets and Messages *MUST* be stored in ascending @@ -84,11 +77,6 @@ up-to-date. Many thanks. * no guarantee that this will all work. */ -/* These should be publicly available */ - -#define MCLoadBySet 0 /* Load entire sets as they are used */ -#define MCLoadAll 1 /* Load entire DB on catopen */ - /* * MCOffsetT - Union to handle both disk and runtime pointers */ @@ -129,7 +117,6 @@ typedef struct _MCSetT { * MCCatT - Runtime catalog pointer */ typedef struct { - long loadType; /* How to load the messages (see MSLoadType) */ FILE *fp; /* File descriptor of catalog (if load-on-demand) */ long numSets; /* Number of sets */ MCSetT *sets; /* Pointer to the sets */