rnd-20100220-1-src
[rocksndiamonds.git] / src / network.c
1 /***********************************************************
2 * Rocks'n'Diamonds -- McDuffin Strikes Back!               *
3 *----------------------------------------------------------*
4 * (c) 1995-2006 Artsoft Entertainment                      *
5 *               Holger Schemel                             *
6 *               Detmolder Strasse 189                      *
7 *               33604 Bielefeld                            *
8 *               Germany                                    *
9 *               e-mail: info@artsoft.org                   *
10 *----------------------------------------------------------*
11 * network.c                                                *
12 ***********************************************************/
13
14 #include "libgame/platform.h"
15
16 #if defined(NETWORK_AVALIABLE)
17
18 #include <signal.h>
19 #include <sys/time.h>
20
21 #if defined(TARGET_SDL)
22 #include "main.h"
23 #else
24 #include <sys/wait.h>
25 #include <sys/socket.h>
26 #include <netinet/in.h>
27 #include <netinet/tcp.h>
28 #include <arpa/inet.h>
29 #include <netdb.h>
30 #endif
31
32 #include "libgame/libgame.h"
33
34 #include "network.h"
35 #include "netserv.h"
36 #include "game.h"
37 #include "tape.h"
38 #include "files.h"
39 #include "tools.h"
40 #include "screens.h"
41
42 struct NetworkClientPlayerInfo
43 {
44   byte nr;
45   char name[MAX_PLAYER_NAME_LEN + 1];
46   struct NetworkClientPlayerInfo *next;
47 };
48
49 static struct NetworkClientPlayerInfo first_player =
50 {
51   0,
52   EMPTY_PLAYER_NAME,
53   NULL
54 };
55
56 /* server stuff */
57
58 #if defined(TARGET_SDL)
59 static TCPsocket sfd;           /* server socket */
60 static SDLNet_SocketSet rfds;   /* socket set */
61 #else
62 static int sfd;                 /* server socket */
63 #endif
64
65 static byte realbuffer[512];
66 static byte readbuffer[MAX_BUFFER_SIZE], writbuffer[MAX_BUFFER_SIZE];
67 static byte *buffer = realbuffer + 4;
68 static int nread = 0, nwrite = 0;
69 static boolean stop_network_game = FALSE;
70
71 static void SendBufferToServer(int size)
72 {
73   if (!options.network)
74     return;
75
76   realbuffer[0] = realbuffer[1] = realbuffer[2] = 0;
77   realbuffer[3] = (byte)size;
78   buffer[0] = 0;
79
80   if (nwrite + 4 + size >= MAX_BUFFER_SIZE)
81     Error(ERR_EXIT, "internal error: network send buffer overflow");
82
83   memcpy(writbuffer + nwrite, realbuffer, 4 + size);
84   nwrite += 4 + size;
85
86   /* directly send the buffer to the network server */
87 #if defined(TARGET_SDL)
88   SDLNet_TCP_Send(sfd, writbuffer, nwrite);
89 #else
90   write(sfd, writbuffer, nwrite);
91 #endif
92   nwrite = 0;
93 }
94
95 struct NetworkClientPlayerInfo *getNetworkPlayer(int player_nr)
96 {
97   struct NetworkClientPlayerInfo *player = NULL;
98
99   for (player = &first_player; player; player = player->next)
100     if (player->nr == player_nr)
101       break;
102
103   if (player == NULL)   /* should not happen */
104     Error(ERR_EXIT, "protocol error: reference to non-existing player %d",
105           player_nr);
106
107   return player;
108 }
109
110 char *getNetworkPlayerName(int player_nr)
111 {
112   struct NetworkClientPlayerInfo *player;
113
114   if (player_nr == 0)
115     return("the network game server");
116   else if (player_nr == first_player.nr)
117     return("you");
118   else
119     for (player = &first_player; player; player = player->next)
120       if (player->nr == player_nr && player->name && strlen(player->name))
121         return(player->name);
122
123   return(EMPTY_PLAYER_NAME);
124 }
125
126 static void StartNetworkServer(int port)
127 {
128 #if defined(TARGET_SDL)
129   static int p;
130
131   p = port;
132   server_thread = SDL_CreateThread(NetworkServerThread, &p);
133   network_server = TRUE;
134
135 #else
136
137   switch (fork())
138   {
139     case 0:
140       NetworkServer(port, options.serveronly);
141
142       /* never reached */
143       exit(0);
144
145     case -1:
146       Error(ERR_WARN,
147             "cannot create network server process - no network playing");
148       options.network = FALSE;
149       return;
150
151     default:
152       /* we are parent process -- resume normal operation */
153       return;
154   }
155 #endif
156 }
157
158 #if defined(TARGET_SDL)
159 boolean ConnectToServer(char *hostname, int port)
160 {
161   IPaddress ip;
162   int i;
163
164   if (port == 0)
165     port = DEFAULT_SERVER_PORT;
166
167   rfds = SDLNet_AllocSocketSet(1);
168
169   if (hostname)
170   {
171     SDLNet_ResolveHost(&ip, hostname, port);
172     if (ip.host == INADDR_NONE)
173       Error(ERR_EXIT, "cannot locate host '%s'", hostname);
174   }
175   else
176   {
177     SDLNet_Write32(0x7f000001, &ip.host);       /* 127.0.0.1 */
178     SDLNet_Write16(port, &ip.port);
179   }
180
181   sfd = SDLNet_TCP_Open(&ip);
182
183   if (sfd)
184   {
185     SDLNet_TCP_AddSocket(rfds, sfd);
186     return TRUE;
187   }
188   else
189   {
190     printf("SDLNet_TCP_Open(): %s\n", SDLNet_GetError());
191   }
192
193   if (hostname)                 /* connect to specified server failed */
194     return FALSE;
195
196   printf("No rocksndiamonds server on localhost -- starting up one ...\n");
197   StartNetworkServer(port);
198
199   /* wait for server to start up and try connecting several times */
200   for (i = 0; i < 6; i++)
201   {
202     Delay(500);                 /* wait 500 ms == 0.5 seconds */
203
204     if ((sfd = SDLNet_TCP_Open(&ip)))           /* connected */
205     {
206       SDLNet_TCP_AddSocket(rfds, sfd);
207       return TRUE;
208     }
209   }
210
211   /* when reaching this point, connect to newly started server has failed */
212   return FALSE;
213 }
214
215 #else
216
217 boolean ConnectToServer(char *hostname, int port)
218 {
219   struct sockaddr_in s;
220   struct protoent *tcpproto;
221   int on = 1, i;
222
223   if (hostname)
224   {
225     if ((s.sin_addr.s_addr = inet_addr(hostname)) == -1)
226     {
227       struct hostent *host;
228
229       if ((host = gethostbyname(hostname)) == NULL)
230         Error(ERR_EXIT, "cannot locate host '%s'", hostname);
231
232       s.sin_addr = *(struct in_addr *)(host->h_addr_list[0]);
233     }
234   }
235   else
236     s.sin_addr.s_addr = inet_addr("127.0.0.1");         /* localhost */
237
238   if (port == 0)
239     port = DEFAULT_SERVER_PORT;
240
241   s.sin_port = htons(port);
242   s.sin_family = AF_INET;
243
244   sfd = socket(PF_INET, SOCK_STREAM, 0);
245   if (sfd < 0)
246     Error(ERR_EXIT, "out of file descriptors");
247
248   if ((tcpproto = getprotobyname("tcp")) != NULL)
249     setsockopt(sfd, tcpproto->p_proto, TCP_NODELAY, (char *)&on, sizeof(int));
250
251   if (connect(sfd, (struct sockaddr *)&s, sizeof(s)) == 0)      /* connected */
252     return TRUE;
253
254   if (hostname) /* connect to specified server failed */
255     return FALSE;
256
257   printf("No rocksndiamonds server on localhost -- starting up one ...\n");
258   StartNetworkServer(port);
259
260   /* wait for server to start up and try connecting several times */
261   for (i = 0; i < 6; i++)
262   {
263     Delay(500);         /* wait 500 ms == 0.5 seconds */
264     close(sfd);
265
266     sfd = socket(PF_INET, SOCK_STREAM, 0);
267     if (sfd < 0)
268       Error(ERR_EXIT, "out of file descriptors");
269
270     setsockopt(sfd, tcpproto->p_proto, TCP_NODELAY, (char *)&on, sizeof(int));
271
272     if (connect(sfd, (struct sockaddr *)&s, sizeof(s)) >= 0)    /* connected */
273       return TRUE;
274   }
275
276   /* when reaching this point, connect to newly started server has failed */
277   return FALSE;
278 }
279 #endif  /* defined(TARGET_SDL) */
280
281 void SendToServer_PlayerName(char *player_name)
282 {
283   int len_player_name = strlen(player_name);
284
285   buffer[1] = OP_PLAYER_NAME;
286   memcpy(&buffer[2], player_name, len_player_name);
287   SendBufferToServer(2 + len_player_name);
288   Error(ERR_NETWORK_CLIENT, "you set your player name to \"%s\"", player_name);
289 }
290
291 void SendToServer_ProtocolVersion()
292 {
293   buffer[1] = OP_PROTOCOL_VERSION;
294   buffer[2] = PROTOCOL_VERSION_1;
295   buffer[3] = PROTOCOL_VERSION_2;
296   buffer[4] = PROTOCOL_VERSION_3;
297
298   SendBufferToServer(5);
299 }
300
301 void SendToServer_NrWanted(int nr_wanted)
302 {
303   buffer[1] = OP_NUMBER_WANTED;
304   buffer[2] = nr_wanted;
305
306   SendBufferToServer(3);
307 }
308
309 void SendToServer_StartPlaying()
310 {
311   unsigned long new_random_seed = InitRND(level.random_seed);
312
313   int dummy = 0;                /* !!! HAS NO MEANING ANYMORE !!! */
314                                 /* the name of the level must be enough */
315
316   buffer[1] = OP_START_PLAYING;
317   buffer[2] = (byte)(level_nr >> 8);
318   buffer[3] = (byte)(level_nr & 0xff);
319   buffer[4] = (byte)(dummy >> 8);
320   buffer[5] = (byte)(dummy & 0xff);
321
322   buffer[6] = (unsigned char)((new_random_seed >> 24) & 0xff);
323   buffer[7] = (unsigned char)((new_random_seed >> 16) & 0xff);
324   buffer[8] = (unsigned char)((new_random_seed >>  8) & 0xff);
325   buffer[9] = (unsigned char)((new_random_seed >>  0) & 0xff);
326
327   strcpy((char *)&buffer[10], leveldir_current->identifier);
328
329   SendBufferToServer(10 + strlen(leveldir_current->identifier) + 1);
330 }
331
332 void SendToServer_PausePlaying()
333 {
334   buffer[1] = OP_PAUSE_PLAYING;
335
336   SendBufferToServer(2);
337 }
338
339 void SendToServer_ContinuePlaying()
340 {
341   buffer[1] = OP_CONTINUE_PLAYING;
342
343   SendBufferToServer(2);
344 }
345
346 void SendToServer_StopPlaying(int cause_for_stopping)
347 {
348   buffer[1] = OP_STOP_PLAYING;
349   buffer[2] = cause_for_stopping;
350
351   SendBufferToServer(3);
352 }
353
354 void SendToServer_MovePlayer(byte player_action)
355 {
356   buffer[1] = OP_MOVE_PLAYER;
357   buffer[2] = player_action;
358
359   SendBufferToServer(3);
360 }
361
362 static void Handle_OP_BAD_PROTOCOL_VERSION()
363 {
364   Error(ERR_WARN, "protocol version mismatch");
365   Error(ERR_EXIT, "server expects %d.%d.x instead of %d.%d.%d",
366         buffer[2], buffer[3],
367         PROTOCOL_VERSION_1, PROTOCOL_VERSION_2, PROTOCOL_VERSION_3);
368 }
369
370 static void Handle_OP_YOUR_NUMBER()
371 {
372   int new_client_nr = buffer[2];
373   int new_index_nr = new_client_nr - 1;
374   struct PlayerInfo *old_local_player = local_player;
375   struct PlayerInfo *new_local_player = &stored_player[new_index_nr];
376
377   printf("OP_YOUR_NUMBER: %d\n", buffer[0]);
378   first_player.nr = new_client_nr;
379
380   if (old_local_player != new_local_player)
381   {
382     /* copy existing player settings and change to new player */
383
384     *new_local_player = *old_local_player;
385     old_local_player->connected = FALSE;
386     local_player = new_local_player;
387   }
388
389   if (first_player.nr > MAX_PLAYERS)
390     Error(ERR_EXIT, "sorry, more than %d players not allowed", MAX_PLAYERS);
391
392   Error(ERR_NETWORK_CLIENT, "you get client # %d", new_client_nr);
393 }
394
395 static void Handle_OP_NUMBER_WANTED()
396 {
397   int client_nr_wanted = buffer[2];
398   int old_client_nr = buffer[0];
399   int new_client_nr = buffer[3];
400   int old_index_nr = old_client_nr - 1;
401   int new_index_nr = new_client_nr - 1;
402   int index_nr_wanted = client_nr_wanted - 1;
403   struct PlayerInfo *old_player = &stored_player[old_index_nr];
404   struct PlayerInfo *new_player = &stored_player[new_index_nr];
405
406   printf("OP_NUMBER_WANTED: %d\n", buffer[0]);
407
408   if (new_client_nr == client_nr_wanted)        /* switching succeeded */
409   {
410     struct NetworkClientPlayerInfo *player;
411
412     if (old_client_nr != client_nr_wanted)      /* client's nr has changed */
413       Error(ERR_NETWORK_CLIENT, "client %d switches to # %d",
414             old_client_nr, new_client_nr);
415     else if (old_client_nr == first_player.nr)  /* local player keeps his nr */
416       Error(ERR_NETWORK_CLIENT, "keeping client # %d", new_client_nr);
417
418     if (old_client_nr != new_client_nr)
419     {
420       /* copy existing player settings and change to new player */
421
422       *new_player = *old_player;
423       old_player->connected = FALSE;
424     }
425
426     player = getNetworkPlayer(old_client_nr);
427     player->nr = new_client_nr;
428
429     if (old_player == local_player)             /* local player switched */
430       local_player = new_player;
431   }
432   else if (old_client_nr == first_player.nr)    /* failed -- local player? */
433   {
434     char request[100];
435
436     sprintf(request, "Sorry ! Player %d already exists ! You are player %d !",
437             index_nr_wanted + 1, new_index_nr + 1);
438
439     Request(request, REQ_CONFIRM);
440
441     Error(ERR_NETWORK_CLIENT, "cannot switch -- you keep client # %d",
442           new_client_nr);
443   }
444 }
445
446 static void Handle_OP_PLAYER_NAME(unsigned int len)
447 {
448   struct NetworkClientPlayerInfo *player;
449   int player_nr = (int)buffer[0];
450
451   printf("OP_PLAYER_NAME: %d\n", player_nr);
452   player = getNetworkPlayer(player_nr);
453   buffer[len] = 0;
454   Error(ERR_NETWORK_CLIENT, "client %d calls itself \"%s\"",
455         buffer[0], &buffer[2]);
456   strncpy(player->name, (char *)&buffer[2], MAX_PLAYER_NAME_LEN);
457 }
458
459 static void Handle_OP_PLAYER_CONNECTED()
460 {
461   struct NetworkClientPlayerInfo *player, *last_player = NULL;
462   int new_client_nr = (int)buffer[0];
463   int new_index_nr = new_client_nr - 1;
464
465   printf("OP_PLAYER_CONNECTED: %d\n", new_client_nr);
466   Error(ERR_NETWORK_CLIENT, "new client %d connected", new_client_nr);
467
468   for (player = &first_player; player; player = player->next)
469   {
470     if (player->nr == new_client_nr)
471       Error(ERR_EXIT, "multiplayer server sent duplicate player id");
472
473     last_player = player;
474   }
475
476   last_player->next = player =
477     checked_malloc(sizeof(struct NetworkClientPlayerInfo));
478   player->nr = new_client_nr;
479   player->name[0] = '\0';
480   player->next = NULL;
481
482   stored_player[new_index_nr].connected = TRUE;
483 }
484
485 static void Handle_OP_PLAYER_DISCONNECTED()
486 {
487   struct NetworkClientPlayerInfo *player, *player_disconnected;
488   int player_nr = (int)buffer[0];
489
490   printf("OP_PLAYER_DISCONNECTED: %d\n", player_nr);
491   player_disconnected = getNetworkPlayer(player_nr);
492   Error(ERR_NETWORK_CLIENT, "client %d (%s) disconnected",
493         player_nr, getNetworkPlayerName(buffer[0]));
494
495   for (player = &first_player; player; player = player->next)
496     if (player->next == player_disconnected)
497       player->next = player_disconnected->next;
498   free(player_disconnected);
499 }
500
501 static void Handle_OP_START_PLAYING()
502 {
503   LevelDirTree *new_leveldir;
504   int new_level_nr;
505   int dummy;
506   unsigned long new_random_seed;
507   char *new_leveldir_identifier;
508
509   new_level_nr = (buffer[2] << 8) + buffer[3];
510   dummy = (buffer[4] << 8) + buffer[5];                 /* (obsolete) */
511   new_random_seed =
512     (buffer[6] << 24) | (buffer[7] << 16) | (buffer[8] << 8) | (buffer[9]);
513   new_leveldir_identifier = (char *)&buffer[10];
514
515   new_leveldir = getTreeInfoFromIdentifier(leveldir_first,
516                                            new_leveldir_identifier);
517   if (new_leveldir == NULL)
518   {
519     Error(ERR_WARN, "no such level identifier: '%s'", new_leveldir_identifier);
520
521     new_leveldir = leveldir_first;
522     Error(ERR_WARN, "using default level set: '%s'", new_leveldir->identifier);
523   }
524
525   printf("OP_START_PLAYING: %d\n", buffer[0]);
526   Error(ERR_NETWORK_CLIENT,
527         "client %d starts game [level %d from level identifier '%s']\n",
528         buffer[0], new_level_nr, new_leveldir->identifier);
529
530   leveldir_current = new_leveldir;
531   level_nr = new_level_nr;
532
533   TapeErase();
534   LoadTape(level_nr);
535   LoadLevel(level_nr);
536
537   StartGameActions(FALSE, setup.autorecord, new_random_seed);
538 }
539
540 static void Handle_OP_PAUSE_PLAYING()
541 {
542   printf("OP_PAUSE_PLAYING: %d\n", buffer[0]);
543   Error(ERR_NETWORK_CLIENT, "client %d pauses game", buffer[0]);
544
545   tape.pausing = TRUE;
546   DrawVideoDisplay(VIDEO_STATE_PAUSE_ON,0);
547 }
548
549 static void Handle_OP_CONTINUE_PLAYING()
550 {
551   printf("OP_CONTINUE_PLAYING: %d\n", buffer[0]);
552   Error(ERR_NETWORK_CLIENT, "client %d continues game", buffer[0]);
553
554   tape.pausing = FALSE;
555   DrawVideoDisplay(VIDEO_STATE_PAUSE_OFF,0);
556 }
557
558 static void Handle_OP_STOP_PLAYING()
559 {
560   printf("OP_STOP_PLAYING: %d [%d]\n", buffer[0], buffer[2]);
561   Error(ERR_NETWORK_CLIENT, "client %d stops game [%d]", buffer[0], buffer[2]);
562
563   if (game_status == GAME_MODE_PLAYING)
564   {
565     if (buffer[2] == NETWORK_STOP_BY_PLAYER)
566       Request("Network game stopped by player!", REQ_CONFIRM);
567     else if (buffer[2] == NETWORK_STOP_BY_ERROR)
568       Request("Network game stopped due to internal error!", REQ_CONFIRM);
569     else
570       Request("Network game stopped !", REQ_CONFIRM);
571   }
572
573   game_status = GAME_MODE_MAIN;
574   DrawMainMenu();
575 }
576
577 static void Handle_OP_MOVE_PLAYER(unsigned int len)
578 {
579   int server_frame_counter;
580   int i;
581
582   if (!network_playing)
583     return;
584
585   server_frame_counter =
586     (buffer[2] << 24) | (buffer[3] << 16) | (buffer[4] << 8) | (buffer[5]);
587
588 #if 0
589   Error(ERR_NETWORK_CLIENT, "receiving server frame counter value %d [%d]",
590         server_frame_counter, FrameCounter);
591 #endif
592
593   if (server_frame_counter != FrameCounter)
594   {
595     Error(ERR_INFO, "client and servers frame counters out of sync");
596     Error(ERR_INFO, "frame counter of client is %d", FrameCounter);
597     Error(ERR_INFO, "frame counter of server is %d", server_frame_counter);
598     Error(ERR_INFO, "this should not happen -- please debug");
599
600     stop_network_game = TRUE;
601
602     return;
603   }
604
605   /* copy valid player actions */
606   for (i = 0; i < MAX_PLAYERS; i++)
607     stored_player[i].effective_action =
608       (i < len - 6 && stored_player[i].active ? buffer[6 + i] : 0);
609
610   network_player_action_received = TRUE;
611 }
612
613 static void HandleNetworkingMessages()
614 {
615   unsigned int message_length;
616
617   stop_network_game = FALSE;
618
619   while (nread >= 4 && nread >= 4 + readbuffer[3])
620   {
621     message_length = readbuffer[3];
622     if (readbuffer[0] || readbuffer[1] || readbuffer[2])
623       Error(ERR_EXIT, "wrong network server line length");
624
625     memcpy(buffer, &readbuffer[4], message_length);
626     nread -= 4 + message_length;
627     memmove(readbuffer, readbuffer + 4 + message_length, nread);
628
629     switch (buffer[1])
630     {
631       case OP_BAD_PROTOCOL_VERSION:
632         Handle_OP_BAD_PROTOCOL_VERSION();
633         break;
634
635       case OP_YOUR_NUMBER:
636         Handle_OP_YOUR_NUMBER();
637         break;
638
639       case OP_NUMBER_WANTED:
640         Handle_OP_NUMBER_WANTED();
641         break;
642
643       case OP_PLAYER_NAME:
644         Handle_OP_PLAYER_NAME(message_length);
645         break;
646
647       case OP_PLAYER_CONNECTED:
648         Handle_OP_PLAYER_CONNECTED();
649         break;
650       
651       case OP_PLAYER_DISCONNECTED:
652         Handle_OP_PLAYER_DISCONNECTED();
653         break;
654
655       case OP_START_PLAYING:
656         Handle_OP_START_PLAYING();
657         break;
658
659       case OP_PAUSE_PLAYING:
660         Handle_OP_PAUSE_PLAYING();
661         break;
662
663       case OP_CONTINUE_PLAYING:
664         Handle_OP_CONTINUE_PLAYING();
665         break;
666
667       case OP_STOP_PLAYING:
668         Handle_OP_STOP_PLAYING();
669         break;
670
671       case OP_MOVE_PLAYER:
672         Handle_OP_MOVE_PLAYER(message_length);
673         break;
674
675       case OP_BROADCAST_MESSAGE:
676         printf("OP_BROADCAST_MESSAGE: %d\n", buffer[0]);
677         Error(ERR_NETWORK_CLIENT, "client %d sends message", buffer[0]);
678         break;
679     }
680   }
681
682   fflush(stdout);
683
684   /* in case of internal error, stop network game */
685   if (stop_network_game)
686     SendToServer_StopPlaying(NETWORK_STOP_BY_ERROR);
687 }
688
689 /* TODO */
690
691 void HandleNetworking()
692 {
693 #if !defined(TARGET_SDL)
694   static struct timeval tv = { 0, 0 };
695   fd_set rfds;
696 #endif
697   int r = 0;
698
699   do
700   {
701 #if defined(TARGET_SDL)
702     if ((r = SDLNet_CheckSockets(rfds, 1)) < 0)
703       Error(ERR_EXIT, "HandleNetworking(): SDLNet_CheckSockets() failed");
704
705 #else
706
707     FD_ZERO(&rfds);
708     FD_SET(sfd, &rfds);
709
710     r = select(sfd + 1, &rfds, NULL, NULL, &tv);
711
712     if (r < 0 && errno != EINTR)
713       Error(ERR_EXIT, "HandleNetworking(): select() failed");
714
715     if (r < 0)
716       FD_ZERO(&rfds);
717 #endif
718
719 #if defined(TARGET_SDL)
720     if (r > 0)
721 #else
722     if (FD_ISSET(sfd, &rfds))
723 #endif
724     {
725 #if defined(TARGET_SDL)
726       r = SDLNet_TCP_Recv(sfd, readbuffer + nread, 1);
727 #else
728       r = read(sfd, readbuffer + nread, MAX_BUFFER_SIZE - nread);
729 #endif
730
731       if (r < 0)
732         Error(ERR_EXIT, "error reading from network server");
733
734       if (r == 0)
735         Error(ERR_EXIT, "connection to network server lost");
736
737       nread += r;
738
739       HandleNetworkingMessages();
740     }
741   }
742   while (r > 0);
743 }
744
745 #endif /* PLATFORM_UNIX */