From de47eb59bb829423b1d0f47ba13099073999b3cb Mon Sep 17 00:00:00 2001 From: Nicolas Planel Date: Wed, 29 Oct 2003 16:07:11 +0000 Subject: Corporate Server 2.1.1 release --- mdk-stage1/dietlibc/libugly/getprotoent.c | 130 ++---------------------------- 1 file changed, 5 insertions(+), 125 deletions(-) (limited to 'mdk-stage1/dietlibc/libugly/getprotoent.c') diff --git a/mdk-stage1/dietlibc/libugly/getprotoent.c b/mdk-stage1/dietlibc/libugly/getprotoent.c index a648e2307..3f0fd4d41 100644 --- a/mdk-stage1/dietlibc/libugly/getprotoent.c +++ b/mdk-stage1/dietlibc/libugly/getprotoent.c @@ -1,130 +1,10 @@ -#include -#include #include -#include -#include -#include -#include -#include -static int protofd=-1; -static char* protomap; -static unsigned int protolen; +extern struct protoent __protoent_pw; +extern char __protoent_buf[1000]; -static char* aliases[10]; - -static char *cur; - -/* ip 0 IP # internet protocol, pseudo protocol number */ struct protoent *getprotoent(void) { - static struct protoent pe; - char *last; - int aliasidx; - if (protofd<0) { - protofd=open(_PATH_SERVICES,O_RDONLY); - if (protofd<0) return 0; - protolen=lseek(protofd,0,SEEK_END); - protomap=mmap(0,protolen,PROT_READ|PROT_WRITE,MAP_PRIVATE,protofd,0); - if ((long)protomap==(-1)) goto error; - cur=protomap; - } - last=protomap+protolen; -again: - pe.p_name=0; - pe.p_aliases=aliases; aliases[0]=0; - pe.p_proto=0; - if (cur>=last) return 0; - if (*cur=='#' || *cur=='\n') goto parseerror; - /* first, the primary name */ - if (!isalpha(*cur)) goto parseerror; - pe.p_name=cur; - pe.p_aliases=aliases; - while (cur=last) return 0; - if (*cur=='\n') goto parseerror; - *cur=0; cur++; - /* second, the protocol number */ - while (cur=last) return 0; - if (*cur=='\n') { *cur++=0; return &pe; } - *cur=0; cur++; - /* now the aliases */ - for (aliasidx=0;aliasidx<10;++aliasidx) { - while (cur=last || !isblank(*cur)) break; - *cur++=0; - } - aliases[aliasidx]=0; - return &pe; -parseerror: - while (curp_name,strlen(s->p_name)); - write(1,"/",1); - write(1,s->p_proto,strlen(s->p_proto)); - write(1,"\n",1); - if (!strcmp(name,"auth")) { - tmp=s->p_aliases; - write(1," aka ",5); - while (*tmp) { - write(1,*tmp,strlen(*tmp)); - write(1,", ",2); - ++tmp; - } - write(1,"\n",1); - } -#endif - if (!strcmp(name,s->p_name)) - return s; - tmp=s->p_aliases; - while (*tmp) - if (!strcmp(name,*tmp++)) return s; - } - return 0; + struct protoent* tmp; + getprotoent_r(&__protoent_pw,__protoent_buf,sizeof(__protoent_buf),&tmp); + return tmp; } - -struct protoent *getprotobynumber(int proto) { - struct protoent *s; - for (s=getprotoent(); s; s=getprotoent()) { - if (proto==s->p_proto) - return s; - } - return 0; -} - -void endprotoent(void) { - if (protomap!=(char*)-1) munmap(protomap,protolen); - if (protofd!=-1) close(protofd); - protomap=(char*)-1; - protofd=-1; -} - -- cgit v1.2.1