Commit d0793b22 authored by ROOL's avatar ROOL 🤖
Browse files

This commit was manufactured by cvs2git to create tag 'celkins_Internet_506'.

Sprout from master 1998-04-29 10:10:13 UTC Carl Elkins <celkins@gitlab.riscosopen.org> 'Added sysctl control interface to IGMPv2 (added in Internet 5.05)'
Delete:
    LibraryDoc
    inetlib/!Make,fd7
    inetlib/!MkClean,fd7
    inetlib/!MkExport,fd7
    inetlib/Makefile
    inetlib/c/gethent
    inetlib/c/gethnad
    inetlib/c/getnbyad
    inetlib/c/getnbyna
    inetlib/c/getnent
    inetlib/c/getprent
    inetlib/c/getprnam
    inetlib/c/getproto
    inetlib/c/getsbyna
    inetlib/c/getsbypo
    inetlib/c/getsent
    inetlib/c/htonl
    inetlib/c/inet_addr
    inetlib/c/inet_lnaof
    inetlib/c/inet_maddr
    inetlib/c/inet_nof
    inetlib/c/inet_ntoa
    inetlib/c/inet_nwork
    inetlib/c/iso_addr
    inetlib/c/linkaddr
    inetlib/c/ns_addr
    inetlib/c/ns_ntoa
    inetlib/c/rresvport
    inetlib/h/inetlib
    rpclib/DISCLAIMER
    rpclib/Log
    rpclib/README
    rpclib/demo/Makefile
    rpclib/demo/dir/Makefile
    rpclib/demo/dir/c/dir_proc
    rpclib/demo/dir/c/rls
    rpclib/demo/dir/x/dir
    rpclib/demo/msg/Makefile
    rpclib/demo/msg/c/msg_proc
    rpclib/demo/msg/c/printmsg
    rpclib/demo/msg/c/rprintmsg
    rpclib/demo/msg/x/msg
    rpclib/demo/sort/Makefile
    rpclib/demo/sort/c/rsort
    rpclib/demo/sort/c/sort_proc
    rpclib/demo/sort/x/sort
    rpclib/etc/Makefile
    rpclib/etc/c/getopt
    rpclib/etc/c/portmap
    rpclib/etc/c/rpcinfo
    rpclib/etc/rpc
    rpclib/rpc/!Make,fd7
    rpclib/rpc/!MkClean,fd7
    rpclib/rpc/!MkExport,fd7
    rpclib/rpc/Makefile
    rpclib/rpc/c/auth_none
    rpclib/rpc/c/auth_unix
    rpclib/rpc/c/authunix_p
    rpclib/rpc/c/bindresvpo
    rpclib/rpc/c/clnt_gener
    rpclib/rpc/c/clnt_perro
    rpclib/rpc/c/clnt_raw
    rpclib/rpc/c/clnt_simpl
    rpclib/rpc/c/clnt_udp
    rpclib/rpc/c/get_myaddr
    rpclib/rpc/c/getrpcent
    rpclib/rpc/c/getrpcport
    rpclib/rpc/c/pmap_clnt
    rpclib/rpc/c/pmap_getma
    rpclib/rpc/c/pmap_getpo
    rpclib/rpc/c/pmap_prot
    rpclib/rpc/c/pmap_prot2
    rpclib/rpc/c/pmap_rmt
    rpclib/rpc/c/rpc_callms
    rpclib/rpc/c/rpc_common
    rpclib/rpc/c/rpc_dtable
    rpclib/rpc/c/rpc_prot
    rpclib/rpc/c/xdr
    rpclib/rpc/c/xdr_array
    rpclib/rpc/c/xdr_float
    rpclib/rpc/c/xdr_mem
    rpclib/rpc/c/xdr_rec
    rpclib/rpc/c/xdr_refere
    rpclib/rpc/c/xdr_stdio
    rpclib/rpc/copyright
    rpclib/rpc/h/auth
    rpclib/rpc/h/auth_unix
    rpclib/rpc/h/clnt
    rpclib/rpc/h/netdb
    rpclib/rpc/h/pmap_clnt
    rpclib/rpc/h/pmap_prot
    rpclib/rpc/h/pmap_rmt
    rpclib/rpc/h/rpc
    rpclib/rpc/h/rpc_msg
    rpclib/rpc/h/svc
    rpclib/rpc/h/svc_auth
    rpclib/rpc/h/types
    rpclib/rpc/h/xdr
    rpclib/rpc/s/callback
    rpclib/rpcsvc/Makefile
    rpclib/rpcsvc/c/rstat_proc
    rpclib/rpcsvc/output/c/mount_clnt
    rpclib/rpcsvc/output/c/mount_svc
    rpclib/rpcsvc/output/c/mount_xdr
    rpclib/rpcsvc/output/c/nfs_prot_c
    rpclib/rpcsvc/output/c/nfs_prot_s
    rpclib/rpcsvc/output/c/nfs_prot_x
    rpclib/rpcsvc/output/h/mount
    rpclib/rpcsvc/output/h/nfs_prot
    rpclib/rpcsvc/x/bootparam_
    rpclib/rpcsvc/x/klm_prot
    rpclib/rpcsvc/x/mount
    rpclib/rpcsvc/x/nfs_prot
    rpclib/rpcsvc/x/nlm_prot
    rpclib/rpcsvc/x/rex
    rpclib/rpcsvc/x/rnusers
    rpclib/rpcsvc/x/rquota
    rpclib/rpcsvc/x/rstat
    rpclib/rpcsvc/x/sm_inter
    rpclib/rpcsvc/x/spray
    rpclib/rpcsvc/x/yp
    rpclib/rpcsvc/x/yppasswd
    socklib/!Make,fd7
    socklib/!MkClean,fd7
    socklib/!MkExport,fd7
    socklib/Makefile
    socklib/Prototypes
    socklib/c/_inet_err
    socklib/c/mkveneers
    socklib/c/recv5
    socklib/c/send5
    socklib/h/socklib
    socklib/hdr/InetSWIs
    socklib/s/copyerror
    socklib/s/makecall
    unixlib/!Make,fd7
    unixlib/!MkClean,fd7
    unixlib/!MkExport,fd7
    unixlib/Makefile
    unixlib/c/access
    unixlib/c/chdir
    unixlib/c/chmod
    unixlib/c/close
    unixlib/c/err
    unixlib/c/errlst
    unixlib/c/filestat
    unixlib/c/flushinput
    unixlib/c/fstat
    unixlib/c/getdtabsiz
    unixlib/c/getegid
    unixlib/c/geteuid
    unixlib/c/getgroups
    unixlib/c/gethostnam
    unixlib/c/getlogin
    unixlib/c/getopt
    unixlib/c/getpass
    unixlib/c/getpid
    unixlib/c/getpwent
    unixlib/c/getpwnam
    unixlib/c/getpwuid
    unixlib/c/getuid
    unixlib/c/getusernam
    unixlib/c/getwd
    unixlib/c/gtimeofday
    unixlib/c/herror
    unixlib/c/index
    unixlib/c/ioctl
    unixlib/c/killfile
    unixlib/c/kvm
    unixlib/c/lseek
    unixlib/c/memops
    unixlib/c/osreadc
    unixlib/c/read
    unixlib/c/readdir
    unixlib/c/readv
    unixlib/c/string
    unixlib/c/strsep
    unixlib/c/stubs
    unixlib/c/write
    unixlib/c/writev
    unixlib/c/xgets
    unixlib/c/xperror
    unixlib/c/xputchar
    unixlib/c/xstrerror
    unixlib/h/stubs
    unixlib/h/unixlib
parent b6785d91
**/hdr/** gitlab-language=armasm linguist-language=armasm linguist-detectable=true
**/s/** gitlab-language=armasm linguist-language=armasm linguist-detectable=true
**/c/** gitlab-language=c linguist-language=c linguist-detectable=true
**/h/** gitlab-language=c linguist-language=c linguist-detectable=true
**/x/** gitlab-language=c linguist-language=c linguist-detectable=true
This diff is collapsed.
| Copyright 1997 Acorn Computers Ltd
|
| Licensed under the Apache License, Version 2.0 (the "License");
| you may not use this file except in compliance with the License.
| You may obtain a copy of the License at
|
| http://www.apache.org/licenses/LICENSE-2.0
|
| Unless required by applicable law or agreed to in writing, software
| distributed under the License is distributed on an "AS IS" BASIS,
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
| See the License for the specific language governing permissions and
| limitations under the License.
|
Dir <Obey$Dir>
amu
| Copyright 1997 Acorn Computers Ltd
|
| Licensed under the Apache License, Version 2.0 (the "License");
| you may not use this file except in compliance with the License.
| You may obtain a copy of the License at
|
| http://www.apache.org/licenses/LICENSE-2.0
|
| Unless required by applicable law or agreed to in writing, software
| distributed under the License is distributed on an "AS IS" BASIS,
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
| See the License for the specific language governing permissions and
| limitations under the License.
|
Dir <Obey$Dir>
amu clean
| Copyright 1997 Acorn Computers Ltd
|
| Licensed under the Apache License, Version 2.0 (the "License");
| you may not use this file except in compliance with the License.
| You may obtain a copy of the License at
|
| http://www.apache.org/licenses/LICENSE-2.0
|
| Unless required by applicable law or agreed to in writing, software
| distributed under the License is distributed on an "AS IS" BASIS,
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
| See the License for the specific language governing permissions and
| limitations under the License.
|
Dir <Obey$Dir>
amu_machine export_hdrs
amu_machine export_libs
This diff is collapsed.
/* -*-C-*-
*
* $Header$
* $Source$
*
* Copyright (c) 1995 Acorn Computers Ltd., Cambridge, England
*
* :RCS Log discontinued:
* Revision 1.2 95/04/20 12:38:42 kwelton
* All library functions are now prototyped in inetlib.h.
*
* Revision 1.1 95/04/18 16:47:46 kwelton
* Initial revision
*
*/
/*
* Copyright (c) 1983 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)gethostent.c 5.3 (Berkeley) 3/9/86";
#endif /* LIBC_SCCS and not lint */
#include <stdio.h>
#include <ctype.h>
#include "netdb.h"
#include "sys/types.h"
#include "sys/socket.h"
#include "inetlib.h"
/*
* Internet version.
*/
#define MAXALIASES 35
#define MAXADDRSIZE 14
#define LBUFSIZ 255
static char HOSTDB[] = "InetDBase:Hosts";
static FILE *hostf = NULL;
static char hostaddr[MAXADDRSIZE];
static char line[LBUFSIZ+1];
static struct hostent host;
static char *host_aliases[MAXALIASES];
static char *host_addrs[2];
int _host_stayopen;
static char *any(char *, char *);
void sethostent(int f)
{
if (hostf != NULL)
rewind(hostf);
else hostf = fopen(HOSTDB, "r");
_host_stayopen |= f;
}
void endhostent(void)
{
if (hostf) {
fclose(hostf);
hostf = NULL;
}
_host_stayopen = 0;
}
struct hostent *namisipadr(const char *nam)
{
u_long val;
char **q;
val = inet_addr(nam);
if (val == -1)
return (NULL);
/*
* ksr 22.9.92
*/
host_addrs[0] = hostaddr;
host.h_addr_list = host_addrs;
*((u_long *)host.h_addr) = val;
host.h_length = sizeof (u_long);
host.h_addrtype = AF_INET;
host.h_name = (char *) nam;
q = host.h_aliases = host_aliases;
*q = NULL;
return (&host);
}
struct hostent *gethostent(void)
{
char *p;
register char *cp, **q;
if (hostf == NULL && (hostf = fopen(HOSTDB, "r" )) == NULL)
return (NULL);
again:
if ((p = fgets(line, LBUFSIZ, hostf)) == NULL)
return (NULL);
if (*p == '#')
goto again;
while (*p == ' ' || *p == '\t')
p++;
cp = any(p, "#\n");
if (cp == NULL)
goto again;
*cp = '\0';
cp = any(p, " \t");
if (cp == NULL)
goto again;
*cp++ = '\0';
/* THIS STUFF IS INTERNET SPECIFIC */
/*
* ksr 22.9.92
*/
host_addrs[0] = hostaddr;
host.h_addr_list = host_addrs;
*((u_long *)host.h_addr) = inet_addr(p);
host.h_length = sizeof (u_long);
host.h_addrtype = AF_INET;
while (*cp == ' ' || *cp == '\t')
cp++;
host.h_name = cp;
q = host.h_aliases = host_aliases;
cp = any(cp, " \t");
if (cp != NULL)
*cp++ = '\0';
while (cp && *cp) {
if (*cp == ' ' || *cp == '\t') {
cp++;
continue;
}
if (q < &host_aliases[MAXALIASES - 1])
*q++ = cp;
cp = any(cp, " \t");
if (cp != NULL)
*cp++ = '\0';
}
*q = NULL;
return (&host);
}
static char *any(char *cp, char *match)
{
register char *mp, c;
while (c = *cp) {
for (mp = match; *mp; mp++)
if (*mp == c)
return (cp);
cp++;
}
return ((char *)0);
}
/* EOF gethent.c */
/* -*-C-*-
*
* $Header$
* $Source$
*
* Copyright (c) 1995 Acorn Computers Ltd., Cambridge, England
*
* :RCS Log discontinued:
* Revision 1.3 95/05/24 13:06:04 kwelton
* Replaced a call to bcmp() with the more correct memcmp().
*
* Revision 1.2 95/04/20 12:39:31 kwelton
* All library functions are now prototyped in inetlib.h.
*
* Revision 1.1 95/04/18 16:47:47 kwelton
* Initial revision
*
*/
/*
* Copyright (c) 1983 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)gethostnamadr.c 5.5 (Berkeley) 3/9/86";
#endif /* LIBC_SCCS and not lint*/
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include "kernel.h"
#include "swis.h"
#include "netdb.h"
#include "inetlib.h"
/*
* DNS module SWIs
*/
#define DNS_GetHostByName 0x46000
#define DNS_GetHost 0x46001 /* According to a third party */
#define DNS_GetHostByAddr 0x46001 /* According to InetDB and ResolverZM */
#ifndef __riscos
#define MAXALIASES 35
static struct hostent host;
static char *host_aliases[MAXALIASES];
static char hostbuf[BUFSIZ+1];
static char *host_addrs[2];
static int _host_stayopen = 0;
#else
static int have_gethostbyaddr=-1;
#endif
struct hostent *gethostbyname(const char *nam)
{
struct hostent *hp;
register char **cp;
_kernel_oserror *e;
if ((hp = namisipadr((char *)nam)) != (struct hostent *)0)
return (hp);
e = _swix(DNS_GetHostByName, _INR(0,1)|_OUT(1), 0, nam, &hp);
if ((e == NULL) && (hp != NULL))
return (hp);
/*
* only acceptable error is SWI not known
*/
if ((e != NULL) && (e->errnum != 0x1e6))
return (NULL);
sethostent(_host_stayopen);
while (hp = gethostent()) {
if (strcmp(hp->h_name, nam) == 0)
break;
for (cp = hp->h_aliases; cp != 0 && *cp != 0; cp++)
if (strcmp(*cp, nam) == 0)
goto found;
}
found:
if (!_host_stayopen)
endhostent();
return(hp);
}
struct hostent *gethostbyaddr(const char *addr, int length, int type)
{
struct hostent *hp;
_kernel_oserror *e;
char buffer[64];
if (have_gethostbyaddr == -1) {
_swix(OS_SWINumberToString, _INR(0,2),
DNS_GetHostByAddr,
buffer,
sizeof buffer);
have_gethostbyaddr = strstr(buffer, "GetHostByAddr") != NULL;
}
if (have_gethostbyaddr)
e = _swix(DNS_GetHostByAddr, _INR(0,3)|_OUT(1),
0, addr, length, type, &hp);
else if (length == 4 && type == 2 /*AF_INET*/) {
unsigned char *hack = (unsigned char *)addr;
sprintf(buffer, "%d.%d.%d.%d", hack[0], hack[1], hack[2], hack[3]);
e = _swix(DNS_GetHostByName, _INR(0,1)|_OUT(1),
0, buffer, &hp);
}
else
goto odd;
if (e == NULL && hp != NULL)
return (hp);
if (e != NULL && e->errnum != 0x1e6)
return (NULL);
odd:
sethostent(_host_stayopen);
while (hp = gethostent()) {
if (hp->h_addrtype == type && hp->h_length == length
&& memcmp(hp->h_addr, addr, length) == 0)
break;
}
if (!_host_stayopen)
endhostent();
return (hp);
}
/* EOF gethnod.c */
/* -*-C-*-
*
* $Header$
* $Source$
*
* Copyright (c) 1995 Acorn Computers Ltd., Cambridge, England
*
* :RCS Log discontinued:
* Revision 1.2 95/04/20 12:39:38 kwelton
* All library functions are now prototyped in inetlib.h.
*
* Revision 1.1 95/04/18 16:47:48 kwelton
* Initial revision
*
*/
/*
* Copyright (c) 1983 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)getnetbyaddr.c 5.3 (Berkeley) 5/19/86";
#endif /* LIBC_SCCS and not lint */
#include "netdb.h"
#include "inetlib.h"
struct netent *getnetbyaddr(long net, int type)
{
register struct netent *p;
setnetent(_net_stayopen);
while (p = getnetent())
if (p->n_addrtype == type && p->n_net == net)
break;
if (!_net_stayopen)
endnetent();
return (p);
}
/* EOF getnbyad.c */
/* -*-C-*-
*
* $Header$
* $Source$
*
* Copyright (c) 1995 Acorn Computers Ltd., Cambridge, England
*
* :RCS Log discontinued:
* Revision 1.2 95/04/20 12:39:40 kwelton
* All library functions are now prototyped in inetlib.h.
*
* Revision 1.1 95/04/18 16:47:49 kwelton
* Initial revision
*
*/
/*
* Copyright (c) 1983 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)getnetbyname.c 5.3 (Berkeley) 5/19/86";
#endif /* LIBC_SCCS and not lint */
#include <string.h>
#include "netdb.h"
#include "inetlib.h"
struct netent *getnetbyname(const char *name)
{
register struct netent *p;
register char **cp;
setnetent(_net_stayopen);
while (p = getnetent()) {
if (strcmp(p->n_name, name) == 0)
break;
for (cp = p->n_aliases; *cp != 0; cp++)
if (strcmp(*cp, name) == 0)
goto found;
}
found:
if (!_net_stayopen)
endnetent();
return (p);
}
/* EOF getnbyna.c */
/* -*-C-*-
*
* $Header$
* $Source$
*
* Copyright (c) 1995 Acorn Computers Ltd., Cambridge, England
*
* :RCS Log discontinued:
* Revision 1.2 95/04/20 12:39:42 kwelton
* All library functions are now prototyped in inetlib.h.
*
* Revision 1.1 95/04/18 16:47:50 kwelton
* Initial revision
*
*/
/*
* Copyright (c) 1983 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)getnetent.c 5.3 (Berkeley) 5/19/86";
#endif /* LIBC_SCCS and not lint */
#include <stdio.h>
#include <ctype.h>
#include "netdb.h"
#include "sys/types.h"
#include "sys/socket.h"
#include "inetlib.h"
#define MAXALIASES 35
#define LBUFSIZ 255
static char NETDB[] = "InetDBase:Networks";
static FILE *netf = NULL;
static char line[LBUFSIZ+1];
static struct netent net;
static char *net_aliases[MAXALIASES];
static char *any(char *, char *);
int _net_stayopen = 0;
void setnetent(int f)
{
if (netf == NULL)
netf = fopen(NETDB, "r" );
else
rewind(netf);
_net_stayopen |= f;
}
void endnetent(void)
{
if (netf) {
fclose(netf);
netf = NULL;
}
_net_stayopen = 0;
}
struct netent *getnetent(void)
{
char *p;
register char *cp, **q;
if (netf == NULL && (netf = fopen(NETDB, "r" )) == NULL)
return (NULL);
again:
p = fgets(line, LBUFSIZ, netf);
if (p == NULL)
return (NULL);
if (*p == '#')
goto again;
cp = any(p, "#\n");
if (cp == NULL)
goto again;
*cp = '\0';
net.n_name = p;
cp = any(p, " \t");
if (cp == NULL)
goto again;
*cp++ = '\0';
while (*cp == ' ' || *cp == '\t')
cp++;
p = any(cp, " \t");
if (p != NULL)
*p++ = '\0';
net.n_net = inet_network(cp);
net.n_addrtype = AF_INET;
q = net.n_aliases = net_aliases;
if (p != NULL)
cp = p;
while (cp && *cp) {
if (*cp == ' ' || *cp == '\t') {
cp++;
continue;
}
if (q < &net_aliases[MAXALIASES - 1])
*q++ = cp;
cp = any(cp, " \t");
if (cp != NULL)
*cp++ = '\0';
}
*q = NULL;
return (&net);
}
static char *any(char *cp, char *match)
{
register char *mp, c;
while (c = *cp) {
for (mp = match; *mp; mp++)
if (*mp == c)
return (cp);
cp++;
}
return ((char *)0);
}
/* EOF getnent.c */
/* -*-C-*-
*
* $Header$
* $Source$
*
* Copyright (c) 1995 Acorn Computers Ltd., Cambridge, England
*
* :RCS Log discontinued:
* Revision 1.3 96/04/01 10:20:47 kbracey
* Patched to know about TCP and UDP in the absence of a protocols file.
*
* Revision 1.2 95/04/20 12:39:44 kwelton
* All library functions are now prototyped in inetlib.h.
*
* Revision 1.1 95/04/18 16:47:52 kwelton
* Initial revision
*
*/
/*
* Copyright (c) 1983 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)getprotoent.c 5.3 (Berkeley) 5/19/86";
#endif /* LIBC_SCCS and not lint */
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include "netdb.h"
#include "sys/types.h"
#include "sys/socket.h"
#include "inetlib.h"
#define MAXALIASES 35
#define LBUFSIZ 255
static const char PROTODB[] = "InetDBase:Protocols";
static FILE *protof = NULL;
static char line[LBUFSIZ+1];
static struct protoent proto;
static char *proto_aliases[MAXALIASES];
static char *any(char *, char *);
static int dummy_stage;
int _proto_stayopen = 0;
void setprotoent(int f)
{
if (protof == NULL)
protof = fopen(PROTODB, "r" );
else
rewind(protof);
_proto_stayopen |= f;
dummy_stage=0;
}
void endprotoent(void)
{
if (protof) {
fclose(protof);
protof = NULL;
}
_proto_stayopen = 0;
dummy_stage = 0;
}
struct protoent *getprotoent(void)
{
char *p;
char *cp, **q;
if (protof == NULL && (protof = fopen(PROTODB, "r" )) == NULL)
{
/* Right, we don't have a protocols file - do something sensible */
if (dummy_stage == 0)
{
strcpy(line, "udp\t17\tUDP\n");
dummy_stage++;
p=line;
goto fake;
}
else if (dummy_stage == 1)
{
strcpy(line, "tcp\t6\tTCP\n");
dummy_stage++;
p=line;
goto fake;
}
/* sent the two dummy entries - return now */
return (NULL);
}
again:
if ((p = fgets(line, LBUFSIZ, protof)) == NULL)
return (NULL);
fake:
if (*p == '#')
goto again;
cp = any(p, "#\n");
if (cp == NULL)
goto again;
*cp = '\0';
proto.p_name = p;
cp = any(p, " \t");
if (cp == NULL)
goto again;
*cp++ = '\0';
while (*cp == ' ' || *cp == '\t')
cp++;
p = any(cp, " \t");
if (p != NULL)
*p++ = '\0';
proto.p_proto = atoi(cp);
q = proto.p_aliases = proto_aliases;
if (p != NULL) {
cp = p;
while (cp && *cp) {
if (*cp == ' ' || *cp == '\t') {
cp++;
continue;
}
if (q < &proto_aliases[MAXALIASES - 1])
*q++ = cp;
cp = any(cp, " \t");
if (cp != NULL)
*cp++ = '\0';
}
}
*q = NULL;
return (&proto);
}
static char *any(char *cp, char *match)
{
char *mp, c;
while (c = *cp) {
for (mp = match; *mp; mp++)
if (*mp == c)
return (cp);
cp++;
}
return ((char *)0);
}
/* EOF getprent.c */
/* -*-C-*-
*
* $Header$
* $Source$
*
* Copyright (c) 1995 Acorn Computers Ltd., Cambridge, England
*
* :RCS Log discontinued:
* Revision 1.2 95/04/20 12:39:49 kwelton
* All library functions are now prototyped in inetlib.h.
*
* Revision 1.1 95/04/18 16:47:53 kwelton
* Initial revision
*
*/
/*
* Copyright (c) 1983 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)getprotoname.c 5.3 (Berkeley) 5/19/86";
#endif /* LIBC_SCCS and not lint */
#include <string.h>
#include "netdb.h"
#include "inetlib.h"
struct protoent *getprotobyname(const char *name)
{
register struct protoent *p;
register char **cp;
setprotoent(_proto_stayopen);
while (p = getprotoent()) {
if (strcmp(p->p_name, name) == 0)
break;
for (cp = p->p_aliases; *cp != 0; cp++)
if (strcmp(*cp, name) == 0)
goto found;
}
found:
if (!_proto_stayopen)
endprotoent();
return (p);
}
/* EOF getprnam.c */
/* -*-C-*-
*
* $Header$
* $Source$
*
* Copyright (c) 1995 Acorn Computers Ltd., Cambridge, England
*
* :RCS Log discontinued:
* Revision 1.2 95/04/20 12:39:51 kwelton
* All library functions are now prototyped in inetlib.h.
*
* Revision 1.1 95/04/18 16:47:54 kwelton
* Initial revision
*
*/
/*
* Copyright (c) 1983 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)getproto.c 5.3 (Berkeley) 5/19/86";
#endif /* LIBC_SCCS and not lint */
#include "netdb.h"
#include "inetlib.h"
struct protoent *getprotobynumber(int proto)
{
register struct protoent *p;
setprotoent(_proto_stayopen);
while (p = getprotoent())
if (p->p_proto == proto)
break;
if (!_proto_stayopen)
endprotoent();
return (p);
}
/* EOF getproto.c */
/* -*-C-*-
*
* $Header$
* $Source$
*
* Copyright (c) 1995 Acorn Computers Ltd., Cambridge, England
*
* :RCS Log discontinued:
* Revision 1.2 95/04/20 12:39:53 kwelton
* All library functions are now prototyped in inetlib.h.
*
* Revision 1.1 95/04/18 16:47:55 kwelton
* Initial revision
*
*/
/*
* Copyright (c) 1983 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)getservbyname.c 5.3 (Berkeley) 5/19/86";
#endif /* LIBC_SCCS and not lint */
#include <string.h>
#include "netdb.h"
#include "inetlib.h"
struct servent *getservbyname(const char *name, const char *proto)
{
register struct servent *p;
register char **cp;
setservent(_serv_stayopen);
while (p = getservent()) {
if (strcmp(name, p->s_name) == 0)
goto gotname;
for (cp = p->s_aliases; *cp; cp++)
if (strcmp(name, *cp) == 0)
goto gotname;
continue;
gotname:
if (proto == 0 || strcmp(p->s_proto, proto) == 0)
break;
}
if (!_serv_stayopen)
endservent();
return (p);
}
/* EOF getsbyna.c */
/* -*-C-*-
*
* $Header$
* $Source$
*
* Copyright (c) 1995 Acorn Computers Ltd., Cambridge, England
*
* :RCS Log discontinued:
* Revision 1.2 95/04/20 12:39:55 kwelton
* All library functions are now prototyped in inetlib.h.
*
* Revision 1.1 95/04/18 16:47:56 kwelton
* Initial revision
*
*/
/*
* Copyright (c) 1983 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)getservbyport.c 5.3 (Berkeley) 5/19/86";
#endif /* LIBC_SCCS and not lint */
#include <string.h>
#include "netdb.h"
#include "inetlib.h"
struct servent *getservbyport(int port, const char *proto)
{
register struct servent *p;
setservent(_serv_stayopen);
while (p = getservent()) {
if (p->s_port != port)
continue;
if (proto == 0 || strcmp(p->s_proto, proto) == 0)
break;
}
if (!_serv_stayopen)
endservent();
return (p);
}
/* EOF getsbypo.c */
/* -*-C-*-
*
* $Header$
* $Source$
*
* Copyright (c) 1995 Acorn Computers Ltd., Cambridge, England
*
* :RCS Log discontinued:
* Revision 1.2 95/04/20 12:39:57 kwelton
* All library functions are now prototyped in inetlib.h.
*
* Revision 1.1 95/04/18 16:47:57 kwelton
* Initial revision
*
*/
/*
* Copyright (c) 1983 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)getservent.c 5.3 (Berkeley) 5/19/86";
#endif /* LIBC_SCCS and not lint */
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
#include "netdb.h"
#include "sys/types.h"
#include "sys/socket.h"
#include "inetlib.h"
#define MAXALIASES 35
#define LBUFSIZ 255
static char SERVDB[] = "InetDBase:Services";
static FILE *servf = NULL;
static char line[LBUFSIZ+1];
static struct servent serv;
static char *serv_aliases[MAXALIASES];
static char *any(char *, char *);
int _serv_stayopen = 0;
void setservent(int f)
{
if (servf == NULL)
servf = fopen(SERVDB, "r" );
else
rewind(servf);
_serv_stayopen |= f;
}
void endservent(void)
{
if (servf) {
fclose(servf);
servf = NULL;
}
_serv_stayopen = 0;
}
struct servent *getservent(void)
{
char *p;
register char *cp, **q;
if (servf == NULL && (servf = fopen(SERVDB, "r" )) == NULL)
return (NULL);
again:
if ((p = fgets(line, LBUFSIZ, servf)) == NULL)
return (NULL);
if (*p == '#')
goto again;
cp = any(p, "#\n");
if (cp == NULL)
goto again;
*cp = '\0';
serv.s_name = p;
p = any(p, " \t");
if (p == NULL)
goto again;
*p++ = '\0';
while (*p == ' ' || *p == '\t')
p++;
cp = any(p, ",/");
if (cp == NULL)
goto again;
*cp++ = '\0';
serv.s_port = htons((u_short)atoi(p));
serv.s_proto = cp;
q = serv.s_aliases = serv_aliases;
cp = any(cp, " \t");
if (cp != NULL)
*cp++ = '\0';
while (cp && *cp) {
if (*cp == ' ' || *cp == '\t') {
cp++;
continue;
}
if (q < &serv_aliases[MAXALIASES - 1])
*q++ = cp;
cp = any(cp, " \t");
if (cp != NULL)
*cp++ = '\0';
}
*q = NULL;
return (&serv);
}
static char *any(char *cp, char *match)
{
register char *mp, c;
while (c = *cp) {
for (mp = match; *mp; mp++)
if (*mp == c)
return (cp);
cp++;
}
return ((char *)0);
}
/* EOF getsent.c */
/* Copyright 1997 Acorn Computers Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* -*-C-*-
*
* $Header$
* $Source$
*
* Copyright (c) 1995 Acorn Computers Ltd., Cambridge, England
*
* :RCS Log discontinued:
* Revision 1.2 95/04/20 12:40:01 kwelton
* All library functions are now prototyped in inetlib.h.
*
* Revision 1.1 95/04/18 16:47:58 kwelton
* Initial revision
*
*/
#include "sys/types.h"
#include "inetlib.h"
#define ROR(x, n) (((x) << (32-(n))) | ((x) >> (n)))
#undef htonl
#undef htons
u_long htonl(u_long x)
{
return(ntohl(x));
}
int htons(int x)
{
return(ntohs(x));
}
u_long ntohl(u_long x)
{
#ifdef __arm
/*
* This compiles to the neat four cycle byte-swap code
* from the ARM Architecture Reference (section 4.1.4).
* (Seven cycles on the ARM 8, but that's 'cos it's
* slow).
*/
u_long t;
/* x = A , B , C , D */
t = x ^ ROR(x, 16); /* t = A^C,B^D,C^A,D^B */
t &=~ 0x00ff0000; /* t = A^C, 0 ,C^A,D^B */
x = ROR(x, 8); /* x = D , A , B , C */
x = x ^ (t >> 8); /* x = D , C , B , A */
return x;
#else
return(((x & 0xff) << 24) | ((x & 0xff00) << 8) |
((x & 0xff0000) >> 8) | ((x & 0xff000000) >> 24));
#endif
}
int ntohs(int x)
{
return(((x & 0xff) << 8) | ((x & 0xff00) >> 8));
}
/* EOF htonl.c */
/*
* Copyright (c) 1983, 1990, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)inet_addr.c 8.1 (Berkeley) 6/17/93";
#endif /* LIBC_SCCS and not lint */
#include <sys/param.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <ctype.h>
#include "inetlib.h"
#define isascii(d) 1
/*
* Ascii internet address interpretation routine.
* The value returned is in network order.
*/
u_long
inet_addr(cp)
register const char *cp;
{
struct in_addr val;
if (inet_aton(cp, &val))
return (val.s_addr);
return (INADDR_NONE);
}
/*
* Check whether "cp" is a valid ascii representation
* of an Internet address and convert to a binary address.
* Returns 1 if the address is valid, 0 if not.
* This replaces inet_addr, the return value from which
* cannot distinguish between failure and a local broadcast address.
*/
int
inet_aton(cp, addr)
register const char *cp;
struct in_addr *addr;
{
register u_long val;
register int base, n;
register char c;
u_int parts[4];
register u_int *pp = parts;
for (;;) {
/*
* Collect number up to ``.''.
* Values are specified as for C:
* 0x=hex, 0=octal, other=decimal.
*/
val = 0; base = 10;
if (*cp == '0') {
if (*++cp == 'x' || *cp == 'X')
base = 16, cp++;
else
base = 8;
}
while ((c = *cp) != '\0') {
if (isascii(c) && isdigit(c)) {
val = (val * base) + (c - '0');
cp++;
continue;
}
if (base == 16 && isascii(c) && isxdigit(c)) {
val = (val << 4) +
(c + 10 - (islower(c) ? 'a' : 'A'));
cp++;
continue;
}
break;
}
if (*cp == '.') {
/*
* Internet format:
* a.b.c.d
* a.b.c (with c treated as 16-bits)
* a.b (with b treated as 24 bits)
*/
if (pp >= parts + 3 || val > 0xff)
return (0);
*pp++ = val, cp++;
} else
break;
}
/*
* Check for trailing characters.
*/
if (*cp && (!isascii(*cp) || !isspace(*cp)))
return (0);
/*
* Concoct the address according to
* the number of parts specified.
*/
n = pp - parts + 1;
switch (n) {
case 1: /* a -- 32 bits */
break;
case 2: /* a.b -- 8.24 bits */
if (val > 0xffffff)
return (0);
val |= parts[0] << 24;
break;
case 3: /* a.b.c -- 8.8.16 bits */
if (val > 0xffff)
return (0);
val |= (parts[0] << 24) | (parts[1] << 16);
break;
case 4: /* a.b.c.d -- 8.8.8.8 bits */
if (val > 0xff)
return (0);
val |= (parts[0] << 24) | (parts[1] << 16) | (parts[2] << 8);
break;
}
if (addr)
addr->s_addr = htonl(val);
return (1);
}
/* -*-C-*-
*
* $Header$
* $Source$
*
* Copyright (c) 1995 Acorn Computers Ltd., Cambridge, England
*
* :RCS Log discontinued:
* Revision 1.2 95/04/20 12:40:07 kwelton
* All library functions are now prototyped in inetlib.h.
*
* Revision 1.1 95/04/18 16:48:00 kwelton
* Initial revision
*
*/
/*
* Copyright (c) 1983 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)inet_lnaof.c 5.2 (Berkeley) 3/9/86";
#endif /* LIBC_SCCS and not lint */
#include "sys/types.h"
#include "netinet/in.h"
#include "inetlib.h"
/*
* Return the local network address portion of an
* internet address; handles class a/b/c network
* number formats.
*/
u_long inet_lnaof(struct in_addr in)
{
register u_long i = ntohl(in.s_addr);
if (IN_CLASSA(i))
return ((i)&IN_CLASSA_HOST);
else if (IN_CLASSB(i))
return ((i)&IN_CLASSB_HOST);
else
return ((i)&IN_CLASSC_HOST);
}
/* EOF inet_lnaof.c */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment