[uClibc-cvs] svn commit: trunk/uClibc/libc/inet/rpc
vapier at uclibc.org
vapier at uclibc.org
Thu Aug 18 01:16:25 UTC 2005
Author: vapier
Date: 2005-08-17 19:16:25 -0600 (Wed, 17 Aug 2005)
New Revision: 11199
Log:
rework some of the code to shrink size
Modified:
trunk/uClibc/libc/inet/rpc/getrpcent.c
Changeset:
Modified: trunk/uClibc/libc/inet/rpc/getrpcent.c
===================================================================
--- trunk/uClibc/libc/inet/rpc/getrpcent.c 2005-08-18 01:11:50 UTC (rev 11198)
+++ trunk/uClibc/libc/inet/rpc/getrpcent.c 2005-08-18 01:16:25 UTC (rev 11199)
@@ -128,18 +128,27 @@
if (d == NULL)
return;
- if (d->current && !d->stayopen) {
+ if (d->stayopen)
+ return;
+ if (d->current) {
free(d->current);
d->current = NULL;
}
- if (d->rpcf && !d->stayopen) {
+ if (d->rpcf) {
fclose(d->rpcf);
d->rpcf = NULL;
}
}
-static struct rpcent *interpret(const char *val, int len);
+static struct rpcent *interpret(struct rpcdata *);
+static struct rpcent *__get_next_rpcent(struct rpcdata *d)
+{
+ if (fgets(d->line, BUFSIZ, d->rpcf) == NULL)
+ return NULL;
+ return interpret(d);
+}
+
struct rpcent *getrpcent()
{
register struct rpcdata *d = _rpcdata();
@@ -148,9 +157,7 @@
return NULL;
if (d->rpcf == NULL && (d->rpcf = fopen(RPCDB, "r")) == NULL)
return NULL;
- if (fgets(d->line, BUFSIZ, d->rpcf) == NULL)
- return NULL;
- return interpret(d->line, strlen(d->line));
+ return __get_next_rpcent(d);
}
#ifdef __linux__
@@ -170,37 +177,33 @@
}
#endif
-static struct rpcent *interpret(const char *val, int len)
+static struct rpcent *interpret(register struct rpcdata *d)
{
- register struct rpcdata *d = _rpcdata();
char *p;
register char *cp, **q;
- if (d == NULL)
- return NULL;
- strncpy(d->line, val, len);
p = d->line;
- d->line[len] = '\n';
+ d->line[strlen(p)-1] = '\n';
if (*p == '#')
- return (getrpcent());
+ return __get_next_rpcent(d);
cp = index(p, '#');
if (cp == NULL) {
cp = index(p, '\n');
if (cp == NULL)
- return (getrpcent());
+ return __get_next_rpcent(d);
}
*cp = '\0';
#ifdef __linux__
if ((cp = firstwhite(p)))
*cp++ = 0;
else
- return (getrpcent());
+ return __get_next_rpcent(d);
#else
cp = index(p, ' ');
if (cp == NULL) {
cp = index(p, '\t');
if (cp == NULL)
- return (getrpcent());
+ return __get_next_rpcent(d);
}
*cp++ = '\0';
#endif
More information about the uClibc-cvs
mailing list