Prototypes/typedefs cleanup

Fix error return codes
This commit is contained in:
Andrey A. Chernov 1998-04-30 10:14:55 +00:00
parent 3f5fb4817a
commit 1adba262d7
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=35546
2 changed files with 22 additions and 21 deletions

View File

@ -1,4 +1,4 @@
/* $Id$ */
/* $Id: catgets.c,v 1.3 1997/02/22 15:00:47 peter Exp $ */
/*
* Written by J.T. Conklin, 10/05/94
@ -13,14 +13,14 @@ __indr_reference(_catgets,catgets);
#include <nl_types.h>
extern char * _catgets __P((nl_catd, int, int, char *));
extern char * _catgets __P((nl_catd, int, int, __const char *));
char *
catgets(catd, set_id, msg_id, s)
nl_catd catd;
int set_id;
int msg_id;
char *s;
__const char *s;
{
return _catgets(catd, set_id, msg_id, s);
}

View File

@ -1,4 +1,4 @@
/* $Id: msgcat.c,v 1.11 1997/05/10 04:40:40 ache Exp $ */
/* $Id: msgcat.c,v 1.12 1998/01/15 09:58:08 jb Exp $ */
/***********************************************************
Copyright 1990, by Alfalfa Software Incorporated, Cambridge, Massachusetts.
@ -79,7 +79,7 @@ static char *rcsid = "$NetBSD: msgcat.c,v 1.11 1995/02/27 13:06:51 cgd Exp $";
#define NLERR ((nl_catd) -1)
static nl_catd loadCat();
static nl_catd loadSet();
static int loadSet();
nl_catd _catopen( name, type)
__const char *name;
@ -97,7 +97,7 @@ int type;
if (strchr(name, '/')) {
catpath = name;
if (stat(catpath, &sbuf)) return(0);
if (stat(catpath, &sbuf)) return(NLERR);
} else {
if ((lang = (char *) getenv("LANG")) == NULL)
lang = "C";
@ -109,7 +109,7 @@ int type;
nlspath = "/usr/share/nls/%L/%N.cat:/usr/share/nls/%N/%L:/usr/local/share/nls/%L/%N.cat:/usr/local/share/nls/%N/%L";
len = strlen(nlspath);
base = cptr = (char *) malloc(len + 2);
base = cptr = malloc(len + 2);
if (!base) return(NLERR);
strcpy(cptr, nlspath);
cptr[len] = ':';
@ -141,7 +141,7 @@ int type;
}
free(base);
if (!catpath) return(0);
if (!catpath) return(NLERR);
}
return(loadCat(catpath, type));
@ -200,7 +200,8 @@ int setId;
if (hi - lo == 1) cur += dir;
else cur += ((hi - lo) / 2) * dir;
}
if (set->invalid) loadSet(cat, set);
if (set->invalid)
(void) loadSet(cat, set);
return(set);
}
@ -241,20 +242,20 @@ int msgId;
return(msg);
}
char *_catgets( catd, setId, msgId, dflt)
char *_catgets( catd, setId, msgId, dflt)
nl_catd catd;
int setId;
int msgId;
char *dflt;
__const char *dflt;
{
MCMsgT *msg;
MCCatT *cat = (MCCatT *) catd;
char *cptr;
__const char *cptr;
msg = MCGetMsg(MCGetSet(cat, setId), msgId);
if (msg) cptr = msg->msg.str;
else cptr = dflt;
return(cptr);
return((char *)cptr);
}
@ -287,7 +288,7 @@ nl_catd catd;
/* Note that only malloc failures are allowed to return an error */
#define ERRNAME "Message Catalog System"
#define CORRUPT() {fprintf(stderr, "%s: corrupt file.\n", ERRNAME); free(cat); return(0);}
#define CORRUPT() {fprintf(stderr, "%s: corrupt file.\n", ERRNAME); free(cat); return(NLERR);}
#define NOSPACE() {fprintf(stderr, "%s: no more memory.\n", ERRNAME); free(cat); return(NLERR);}
static nl_catd loadCat( catpath, type)
@ -306,7 +307,7 @@ int type;
if ((cat->fd = open(catpath, O_RDONLY)) < 0) {
free(cat);
return(0);
return(NLERR);
}
(void)fcntl(cat->fd, F_SETFD, FD_CLOEXEC);
@ -319,14 +320,14 @@ int type;
free(cat);
fprintf(stderr, "%s: %s is version %ld, we need %ld.\n", ERRNAME,
catpath, header.majorVer, MCMajorVer);
return(0);
return(NLERR);
}
if (header.numSets <= 0) {
free(cat);
fprintf(stderr, "%s: %s has %ld sets!\n", ERRNAME, catpath,
header.numSets);
return(0);
return(NLERR);
}
cat->numSets = header.numSets;
@ -370,7 +371,7 @@ int type;
}
if (cat->loadType == MCLoadAll) {
nl_catd res;
int res;
if ((res = loadSet(cat, set)) <= 0) {
for (j = 0; j < i; j++) {
@ -381,7 +382,7 @@ int type;
}
}
free(cat->sets);
if (res == -1) NOSPACE();
if (res < 0) NOSPACE();
CORRUPT();
}
} else set->invalid = True;
@ -394,7 +395,7 @@ int type;
return((nl_catd) cat);
}
static nl_catd loadSet( cat, set)
static int loadSet(cat, set)
MCCatT *cat;
MCSetT *set;
{
@ -403,7 +404,7 @@ MCSetT *set;
/* Get the data */
if (lseek(cat->fd, set->data.off, 0) == -1) return(0);
if ((set->data.str = (char *) malloc(set->dataLen)) == NULL) return(-1);
if ((set->data.str = malloc(set->dataLen)) == NULL) return(-1);
if (read(cat->fd, set->data.str, set->dataLen) != set->dataLen) {
free(set->data.str); return(0);
}