#define MAXALIASES 35
static const char NETDB[] = _PATH_NETWORKS;
static FILE *netf = NULL;
-static char line[BUFSIZ+1];
+static char *line = NULL;
static struct netent net;
static char *net_aliases[MAXALIASES];
return (NULL);
}
again:
+
+ if (!line) {
+ line = malloc(BUFSIZ + 1);
+ if (!line)
+ abort();
+ }
+
p = fgets(line, BUFSIZ, netf);
if (p == NULL) {
UNLOCK;
net.n_net = inet_network(cp);
net.n_addrtype = AF_INET;
q = net.n_aliases = net_aliases;
- if (p != NULL)
+ if (p != NULL)
cp = p;
while (cp && *cp) {
if (*cp == ' ' || *cp == '\t') {
#define MAXALIASES 35
+#define SBUFSIZE (BUFSIZ + 1 + (sizeof(char *) * MAXALIASES))
static FILE *protof = NULL;
static struct protoent proto;
-static char static_aliases[BUFSIZ+1 + sizeof(char *)*MAXALIASES];
+static char *static_aliases = NULL;
static int proto_stayopen;
+static void __initbuf(void)
+{
+ if (!static_aliases) {
+ static_aliases = malloc(SBUFSIZE);
+ if (!static_aliases)
+ abort();
+ }
+}
+
void setprotoent(int f)
{
LOCK;
struct protoent * getprotoent(void)
{
struct protoent *result;
- getprotoent_r(&proto, static_aliases, sizeof(static_aliases), &result);
+
+ __initbuf();
+ getprotoent_r(&proto, static_aliases, SBUFSIZE, &result);
return result;
}
struct protoent * getprotobyname(const char *name)
{
struct protoent *result;
- getprotobyname_r(name, &proto, static_aliases, sizeof(static_aliases), &result);
+
+ __initbuf();
+ getprotobyname_r(name, &proto, static_aliases, SBUFSIZE, &result);
return result;
}
struct protoent * getprotobynumber(int proto_num)
{
struct protoent *result;
- getprotobynumber_r(proto_num, &proto, static_aliases, sizeof(static_aliases), &result);
+
+ __initbuf();
+ getprotobynumber_r(proto_num, &proto, static_aliases,
+ SBUFSIZE, &result);
return result;
}
#define MAXALIASES 35
+#define SBUFSIZE (BUFSIZ + 1 + (sizeof(char *) * MAXALIASES))
static FILE *servf = NULL;
static struct servent serv;
-static char buf[BUFSIZ+1 + sizeof(char *)*MAXALIASES];
+static char *buf = NULL;
static int serv_stayopen;
+static void __initbuf(void)
+{
+ if (!buf) {
+ buf = malloc(SBUFSIZE);
+ if (!buf)
+ abort();
+ }
+}
+
void setservent(int f)
{
LOCK;
struct servent * getservent(void)
{
struct servent *result;
- getservent_r(&serv, buf, sizeof(buf), &result);
+
+ __initbuf();
+ getservent_r(&serv, buf, SBUFSIZE, &result);
return result;
}
struct servent *getservbyname(const char *name, const char *proto)
{
struct servent *result;
- getservbyname_r(name, proto, &serv, buf, sizeof(buf), &result);
+
+ __initbuf();
+ getservbyname_r(name, proto, &serv, buf, SBUFSIZE, &result);
return result;
}
struct servent * getservbyport(int port, const char *proto)
{
struct servent *result;
- getservbyport_r(port, proto, &serv, buf, sizeof(buf), &result);
+
+ __initbuf();
+ getservbyport_r(port, proto, &serv, buf, SBUFSIZE, &result);
return result;
}
struct mntent *getmntent(FILE * filep)
{
struct mntent *tmp;
- static char buff[BUFSIZ];
+ static char *buff = NULL;
static struct mntent mnt;
LOCK;
- tmp = getmntent_r(filep, &mnt, buff, sizeof buff);
+
+ if (!buff) {
+ buff = malloc(BUFSIZ);
+ if (!buff)
+ abort();
+ }
+
+ tmp = getmntent_r(filep, &mnt, buff, BUFSIZ);
UNLOCK;
return(tmp);
}
{
register int c;
register char *p;
- static char line[BUFSIZ];
+ static char *line = NULL;
if (!tf && !setttyent())
return (NULL);
+
+ if (!line) {
+ line = malloc(BUFSIZ);
+ if (!line)
+ abort();
+ }
+
flockfile (tf);
+
for (;;) {
if (!fgets_unlocked(p = line, sizeof(line), tf)) {
funlockfile (tf);