Merge branch 'master' of serenade.mutabah.net:acess2
[tpg/acess2.git] / AcessNative / ld-acess.so_src / request.c
1 /*
2  */
3 #include <windows.h>
4 #include <stdio.h>
5 #include <winsock.h>
6
7 #define SERVER_PORT     0xACE
8
9 // === GLOBALS ===
10 #ifdef __WIN32__
11 WSADATA gWinsock;
12 SOCKET  gSocket;
13 #endif
14
15 // === CODE ===
16 int _InitSyscalls()
17 {
18         struct sockaddr_in      server;
19         struct sockaddr_in      client;
20         
21         #ifdef __WIN32__
22         /* Open windows connection */
23         if (WSAStartup(0x0101, &gWinsock) != 0)
24         {
25                 fprintf(stderr, "Could not open Windows connection.\n");
26                 exit(0);
27         }
28         #endif
29         
30         // Open UDP Connection
31         gSocket = socket(AF_INET, SOCK_DGRAM, 0);
32         if (gSocket == INVALID_SOCKET)
33         {
34                 fprintf(stderr, "Could not create socket.\n");
35                 WSACleanup();
36                 exit(0);
37         }
38         
39         // Set server address
40         memset((void *)&server, '\0', sizeof(struct sockaddr_in));
41         server.sin_family = AF_INET;
42         server.sin_port = htons(SERVER_PORT);
43         server.sin_addr.S_un.S_un_b.s_b1 = (unsigned char)127;
44         server.sin_addr.S_un.S_un_b.s_b2 = (unsigned char)0;
45         server.sin_addr.S_un.S_un_b.s_b3 = (unsigned char)0;
46         server.sin_addr.S_un.S_un_b.s_b4 = (unsigned char)1;
47         
48         // Set client address
49         memset((void *)&client, '\0', sizeof(struct sockaddr_in));
50         client.sin_family = AF_INET;
51         client.sin_port = htons(0);
52         client.sin_addr.S_un.S_un_b.s_b1 = (unsigned char)127;
53         client.sin_addr.S_un.S_un_b.s_b2 = (unsigned char)0;
54         client.sin_addr.S_un.S_un_b.s_b3 = (unsigned char)0;
55         client.sin_addr.S_un.S_un_b.s_b4 = (unsigned char)1;
56         
57         // Bind
58         if( bind(gSocket, (struct sockaddr *)&client, sizeof(struct sockaddr_in)) == -1 )
59         {
60                 fprintf(stderr, "Cannot bind address to socket.\n");
61                 closesocket(gSocket);
62                 WSACleanup();
63                 exit(0);
64         }
65 }
66
67 int _Syscall(const char *ArgTypes, ...)
68 {
69         return 0;
70 }

UCC git Repository :: git.ucc.asn.au