LibNRG  0.0.1
Networking for Real-time Games library
 All Classes Files Functions Variables Friends
nrg_core.h
Go to the documentation of this file.
1 /*
2  LibNRG - Networking for Real-time Games
3 
4  Copyright (C) 2012-2014 Alex Baines <alex@abaines.me.uk>
5 
6  This software is provided 'as-is', without any express or implied
7  warranty. In no event will the authors be held liable for any damages
8  arising from the use of this software.
9 
10  Permission is granted to anyone to use this software for any purpose,
11  including commercial applications, and to alter it and redistribute it
12  freely, subject to the following restrictions:
13 
14  1. The origin of this software must not be misrepresented; you must not
15  claim that you wrote the original software. If you use this software
16  in a product, an acknowledgment in the product documentation would be
17  appreciated but is not required.
18  2. Altered source versions must be plainly marked as such, and must not be
19  misrepresented as being the original software.
20  3. This notice may not be removed or altered from any source distribution.
21 */
25 #ifndef NRG_CORE_H
26 #define NRG_CORE_H
27 #ifdef _WIN32
28  #define WIN32_LEAN_AND_MEAN
29  #include "windows.h"
30  #include "winsock2.h"
31  #include "ws2tcpip.h"
32  typedef int socklen_t;
33 #else
34  #include <unistd.h>
35  #include <sys/types.h>
36  #include <sys/socket.h>
37  #include <sys/time.h>
38  #include <netdb.h>
39  #include <netinet/in.h>
40  #include <arpa/inet.h>
41 #endif
42 #include "stdint.h"
43 #include "nrg_status.h"
44 
45 #ifndef INET6_ADDRSTRLEN
46 #define INET6_ADDRSTRLEN 46
47 #endif
48 
49 // adapted from http://gcc.gnu.org/wiki/Visibility
50 #if defined _WIN32 || defined __CYGWIN__
51  #ifdef BUILDING_NRG
52  #define NRG_PUBLIC __declspec(dllexport)
53  #else
54  #define NRG_PUBLIC __declspec(dllimport)
55  #endif
56  #define NRG_PRIVATE
57 #elif __GNUC__ >= 4
58  #define NRG_PUBLIC __attribute__ ((visibility ("default")))
59  #define NRG_PRIVATE __attribute__ ((visibility ("hidden")))
60 #else
61  #define NRG_PUBLIC
62  #define NRG_PRIVATE
63 #endif
64 
65 #ifdef DEBUG
66  #define NRG_DEBUG(fmt, ...) do { fprintf(stderr, fmt, __VA_ARGS__); } while (0)
67 #else
68  #define NRG_DEBUG(fmt, ...) do { } while(0)
69 #endif
70 
100 #endif
Error-handling functionality.