Follow our own style guide.
[AROS.git] / arch / all-mingw32 / bsdsocket / getprotobyname.c
blobea1cf96ff8cab9f51b05ec38ba47ca282624c198
1 /*
2 Copyright © 1995-2010, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc:
6 Lang: English
7 */
9 #include <sys/errno.h>
10 #include <netdb.h>
12 #include "bsdsocket_intern.h"
13 #include "bsdsocket_util.h"
14 #include "netdb_util.h"
16 /*****************************************************************************
18 NAME */
20 AROS_LH1(struct protoent *, getprotobyname,
22 /* SYNOPSIS */
23 AROS_LHA(char *, name, A0),
25 /* LOCATION */
26 struct TaskBase *, taskBase, 41, BSDSocket)
28 /* FUNCTION
30 INPUTS
32 RESULT
34 NOTES
36 EXAMPLE
38 BUGS
40 SEE ALSO
42 INTERNALS
44 HISTORY
46 *****************************************************************************/
48 AROS_LIBFUNC_INIT
50 struct bsdsocketBase *SocketBase = taskBase->glob;
51 struct PROTOENT *wsentry;
52 struct protoent *arosentry = NULL;
53 int err = 0;
55 Forbid();
57 wsentry = WSgetprotobyname(name);
58 D(bug("[getprotobyname] Name: %s, WinSock protoent: 0x%p\n", name, wsentry));
60 if (wsentry)
62 arosentry = CopyProtoEntry(wsentry, taskBase->pool);
63 D(bug("[getprorobyname] AROS protoent: 0x%p\n", arosentry));
64 if (!arosentry)
65 err = ENOMEM;
67 else
69 err = WSAGetLastError() - WSABASEERR;
70 D(bug("[getprotobyname] WinSock error %u\n", err));
73 Permit();
75 if (arosentry)
77 if (taskBase->pe)
78 FreeProtoEntry(taskBase->pe, taskBase->pool);
79 taskBase->pe = arosentry;
81 else
82 SetError(err, taskBase);
84 return arosentry;
86 AROS_LIBFUNC_EXIT
88 } /* getprotobyname */