fgms 0.11.8
The
FlightGear MultiPlayer Server
project
wrappers.c
Go to the documentation of this file.
1 /*
2  * wrappers.c - wrapper functions for various system calls
3  *
4  * Author: Gabor Toth <tgbp@freemail.hu>
5  * License: GPL
6  *
7  * $Log: wrappers.c,v $
8  * Revision 1.2 2006/05/10 21:22:34 koversrac
9  * Comment with author and license has been added.
10  *
11  */
12 
13 #include "wrappers.h"
14 
15 
16 int
17 Accept(int sockfd,struct sockaddr *cliaddr, socklen_t *addrlen)
18 {
19  int n;
20  if ( (n = accept(sockfd,cliaddr,addrlen)) < 0)
21  err_sys("accept error");
22  return (n);
23 }
24 
25 int
26 Bind(int sockfd,const struct sockaddr *serveraddr, socklen_t addrlen)
27 {
28  int n;
29  if ( (n = bind(sockfd,serveraddr,addrlen)) < 0)
30  err_sys("bind error");
31  return (n);
32 }
33 
34 int
35 Close(int sockfd)
36 {
37  int n;
38  if ( (n = SCLOSE(sockfd)) < 0)
39  err_sys("close error");
40  return (n);
41 }
42 
43 int
44 Connect(int sockfd, const struct sockaddr *serveraddr, socklen_t addrlen)
45 {
46  int n;
47  if ( (n = connect(sockfd,serveraddr,addrlen)) < 0)
48  err_sys("connect error");
49  return (n);
50 }
51 
52 int
54 {
55  int n = -1;
56 #ifndef _MSC_VER
57  if ( (n = fork()) <0 )
58 #endif
59  err_sys("fork error");
60  return (n);
61 }
62 
63 int
64 Listen(int sockfd,int backlog)
65 {
66  int n;
67  if ( (n = listen(sockfd,backlog)) < 0)
68  err_sys("listen error");
69  return (n);
70 }
71 
72 int
73 Socket(int family, int type, int protocol)
74 {
75  int n;
76  if ( (n = socket(family, type, protocol)) < 0)
77  err_sys("socket error");
78  return (n);
79 }
80 
81 
int Close(int sockfd)
Definition: wrappers.c:35
int Fork()
Definition: wrappers.c:53
int Accept(int sockfd, struct sockaddr *cliaddr, socklen_t *addrlen)
Definition: wrappers.c:17
int Listen(int sockfd, int backlog)
Definition: wrappers.c:64
int Connect(int sockfd, const struct sockaddr *serveraddr, socklen_t addrlen)
Definition: wrappers.c:44
int Bind(int sockfd, const struct sockaddr *serveraddr, socklen_t addrlen)
Definition: wrappers.c:26
void err_sys(const char *fmt,...)
Definition: fgt_error.c:101
#define SCLOSE
Definition: fgt_common.h:247
int Socket(int family, int type, int protocol)
Definition: wrappers.c:73