remove useless __yield alias for sched_yield
[oweals/musl.git] / src / network / proto.c
1 #include <netdb.h>
2 #include <string.h>
3
4 /* do we really need all these?? */
5
6 static int idx;
7 static const unsigned char protos[][8] = {
8         "\000ip",
9         "\001icmp",
10         "\002igmp",
11         "\003ggp",
12         "\006tcp",
13         "\014pup",
14         "\021udp",
15         "\026idp",
16         "\051ipv6",
17         "\072icmpv6",
18         "\377raw",
19         "\0\0"
20 };
21
22 void endprotoent(void)
23 {
24         idx = 0;
25 }
26
27 void setprotoent(int stayopen)
28 {
29         idx = 0;
30 }
31
32 struct protoent *getprotoent(void)
33 {
34         static struct protoent p;
35         static const char *aliases;
36         if (!protos[idx][1]) return NULL;
37         p.p_proto = protos[idx][0];
38         p.p_name = (char *)protos[idx++]+1;
39         p.p_aliases = (char **)&aliases;
40         return &p;
41 }
42
43 struct protoent *getprotobyname(const char *name)
44 {
45         struct protoent *p;
46         endprotoent();
47         do p = getprotoent();
48         while (p && strcmp(name, p->p_name));
49         return p;
50 }
51
52 struct protoent *getprotobynumber(int num)
53 {
54         struct protoent *p;
55         endprotoent();
56         do p = getprotoent();
57         while (p && p->p_proto != num);
58         return p;
59 }