-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathyaAGC.h
125 lines (99 loc) · 3.68 KB
/
yaAGC.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/*
Copyright 2003-2005,2009 Ronald S. Burkey <[email protected]>
This file is part of yaAGC.
yaAGC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
yaAGC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with yaAGC; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
In addition, as a special exception, Ronald S. Burkey gives permission to
link the code of this program with the Orbiter SDK library (or with
modified versions of the Orbiter SDK library that use the same license as
the Orbiter SDK library), and distribute linked combinations including
the two. You must obey the GNU General Public License in all respects for
all of the code used other than the Orbiter SDK library. If you modify
this file, you may extend this exception to your version of the file,
but you are not obligated to do so. If you do not wish to do so, delete
this exception statement from your version.
Filename: yaAGC.h
Purpose: Header file for common yaAGC-project functionality.
Contact: Ron Burkey <[email protected]>
Compiler: GNU gcc
Reference: http://www.ibiblio.org/apollo/index.html
Mods: 04/21/03 RSB. Began.
08/20/03 RSB. Added uBit to ParseIoPacket.
10/20/03 RSB. Defined MSG_NOSIGNAL for Win32.
11/24/03 RSB. Began trying to adjust for Mac OS X.
07/12/04 RSB Q is now 16 bits
08/18/04 RSB Added the __embedded__ type system.
02/27/05 RSB Added the license exception, as required by
the GPL, for linking to Orbiter SDK libraries.
05/29/05 RSB Added AGS equivalents for a couple of
AGC packet functions.
08/13/05 RSB Added the extern "C" stuff.
02/28/09 RSB Added FORMAT_64U, FORMAT_64O for bypassing
some compiler warnings on 64-bit machines.
*/
#ifdef __cplusplus
extern "C" {
#endif
#ifndef YAAGC_H
#define YAAGC_H
#if defined(__APPLE_CC__) && !defined(unix)
#define unix
#endif
// Figure out the right include-files for socket stuff.
#if defined(unix)
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <netinet/in.h>
#include <fcntl.h>
#include <stdint.h>
#ifndef __WORDSIZE
#define FORMAT_64U "%llu"
#define FORMAT_64O "%llo"
#elif __WORDSIZE < 64
#define FORMAT_64U "%llu"
#define FORMAT_64O "%llo"
#else
#define FORMAT_64U "%lu"
#define FORMAT_64O "%lo"
#endif
#elif defined(WIN32)
#include <windows.h>
#include <winsock2.h>
#define FORMAT_64U "%llu"
#define FORMAT_64O "%llo"
#elif defined(__embedded__)
#define FORMAT_64U "%llu"
#define FORMAT_64O "%llo"
#elif defined(SDCC)
#else
#error Sorry, cannot determine the target operating system.
#endif
#ifndef MSG_NOSIGNAL
#define MSG_NOSIGNAL 0
#endif
//--------------------------------------------------------------------------
// Function prototypes.
int FormIoPacket (int Channel, int Value, unsigned char *Packet);
int ParseIoPacket (unsigned char *Packet, int *Channel, int *Value,
int *uBit);
int FormIoPacketAGS (int Type, int Data, unsigned char *Packet);
int ParseIoPacketAGS (unsigned char *Packet, int *Type, int *Data);
int InitializeSocketSystem (void);
void UnblockSocket (int SocketNum);
int EstablishSocket (unsigned short portnum, int MaxClients);
int CallSocket (char *hostname, unsigned short portnum);
#endif // YAAGC_H
#ifdef __cplusplus
}
#endif