Cleanup prototypes and remove dead code

MFC After:      3 days
This commit is contained in:
Alexey Zelkin 2005-02-01 16:04:55 +00:00
parent 3559895440
commit f24d446afb
2 changed files with 23 additions and 74 deletions

View File

@ -64,14 +64,12 @@ __FBSDID("$FreeBSD$");
#define NLERR ((nl_catd) -1) #define NLERR ((nl_catd) -1)
#define NLRETERR(errc) { errno = errc; return (NLERR); } #define NLRETERR(errc) { errno = errc; return (NLERR); }
static nl_catd loadCat(); static nl_catd loadCat(__const char *);
static int loadSet(); static int loadSet(MCCatT *, MCSetT *);
static void __nls_free_resources(); static void __nls_free_resources(MCCatT *, int);
nl_catd nl_catd
catopen(name, type) catopen(__const char *name, int type)
__const char *name;
int type;
{ {
int spcleft, saverr; int spcleft, saverr;
char path[PATH_MAX]; char path[PATH_MAX];
@ -158,7 +156,7 @@ catopen(name, type)
(pathP - path) - 1; (pathP - path) - 1;
if (strlcpy(pathP, tmpptr, spcleft) >= if (strlcpy(pathP, tmpptr, spcleft) >=
spcleft) { spcleft) {
too_long: too_long:
free(plang); free(plang);
free(base); free(base);
NLRETERR(ENAMETOOLONG); NLRETERR(ENAMETOOLONG);
@ -240,9 +238,7 @@ catopen(name, type)
} }
static MCSetT * static MCSetT *
MCGetSet(cat, setId) MCGetSet(MCCatT *cat, int setId)
MCCatT *cat;
int setId;
{ {
MCSetT *set; MCSetT *set;
long lo, hi, cur, dir; long lo, hi, cur, dir;
@ -256,9 +252,7 @@ MCGetSet(cat, setId)
} }
static MCMsgT * static MCMsgT *
MCGetMsg(set, msgId) MCGetMsg(MCSetT *set, int msgId)
MCSetT *set;
int msgId;
{ {
MCMsgT *msg; MCMsgT *msg;
long lo, hi, cur, dir; long lo, hi, cur, dir;
@ -270,11 +264,7 @@ MCGetMsg(set, msgId)
} }
char * char *
catgets(catd, setId, msgId, dflt) catgets(nl_catd catd, int setId, int msgId, __const char *dflt)
nl_catd catd;
int setId;
int msgId;
__const char *dflt;
{ {
MCMsgT *msg; MCMsgT *msg;
MCCatT *cat = (MCCatT *)catd; MCCatT *cat = (MCCatT *)catd;
@ -291,8 +281,7 @@ catgets(catd, setId, msgId, dflt)
} }
int int
catclose(catd) catclose(nl_catd catd)
nl_catd catd;
{ {
MCCatT *cat = (MCCatT *)catd; MCCatT *cat = (MCCatT *)catd;
@ -300,10 +289,8 @@ catclose(catd)
errno = EBADF; errno = EBADF;
return (-1); return (-1);
} }
#if 0
if (cat->loadType != MCLoadAll) (void)fclose(cat->fp);
#endif
(void)fclose(cat->fp);
__nls_free_resources(cat, cat->numSets); __nls_free_resources(cat, cat->numSets);
free(cat); free(cat);
return (0); return (0);
@ -333,9 +320,7 @@ static char *_errowner = "Message Catalog System";
} }
static void static void
__nls_free_resources(cat, i) __nls_free_resources(MCCatT *cat, int i)
MCCatT *cat;
int i;
{ {
MCSetT *set; MCSetT *set;
int j; int j;
@ -351,8 +336,7 @@ __nls_free_resources(cat, i)
} }
static nl_catd static nl_catd
loadCat(catpath) loadCat(__const char *catpath)
__const char *catpath;
{ {
MCHeaderT header; MCHeaderT header;
MCCatT *cat; MCCatT *cat;
@ -363,7 +347,6 @@ loadCat(catpath)
if ((cat = (MCCatT *)malloc(sizeof(MCCatT))) == NULL) if ((cat = (MCCatT *)malloc(sizeof(MCCatT))) == NULL)
return (NLERR); return (NLERR);
cat->loadType = MCLoadBySet;
if ((cat->fp = fopen(catpath, "r")) == NULL) { if ((cat->fp = fopen(catpath, "r")) == NULL) {
saverr = errno; saverr = errno;
@ -417,36 +400,15 @@ loadCat(catpath)
nextSet = set->nextSet; nextSet = set->nextSet;
continue; continue;
} }
#if 0 set->invalid = TRUE;
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;
nextSet = set->nextSet; nextSet = set->nextSet;
} }
#if 0
if (cat->loadType == MCLoadAll) {
(void)fclose(cat->fp);
cat->fp = NULL;
}
#endif
return ((nl_catd) cat); return ((nl_catd) cat);
} }
static int static int
loadSet(cat, set) loadSet(MCCatT *cat, MCSetT *set)
MCCatT *cat;
MCSetT *set;
{ {
MCMsgT *msg; MCMsgT *msg;
int i; int i;

View File

@ -36,26 +36,19 @@ up-to-date. Many thanks.
******************************************************************/ ******************************************************************/
#include <sys/types.h>
/* /*
* On disk data structures * Magic definitions
*/ */
#define MCMagicLen 8
#define MCMagic "*nazgul*"
#define MCMajorVer 1L
#define MCMinorVer 0
/* For or'd constants */ /* For or'd constants */
#define MCMakeId(s,m) (unsigned long) ( ((unsigned short)s << (sizeof(short)*8)) \ #define MCMakeId(s,m) (unsigned long) ( ((unsigned short)s << (sizeof(short)*8)) \
| (unsigned short)m ) | (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 * 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. * 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 * MCOffsetT - Union to handle both disk and runtime pointers
*/ */
@ -129,7 +117,6 @@ typedef struct _MCSetT {
* MCCatT - Runtime catalog pointer * MCCatT - Runtime catalog pointer
*/ */
typedef struct { typedef struct {
long loadType; /* How to load the messages (see MSLoadType) */
FILE *fp; /* File descriptor of catalog (if load-on-demand) */ FILE *fp; /* File descriptor of catalog (if load-on-demand) */
long numSets; /* Number of sets */ long numSets; /* Number of sets */
MCSetT *sets; /* Pointer to the sets */ MCSetT *sets; /* Pointer to the sets */