[Freeciv-Dev] mac #defs
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Hi
the folowing diffs are open transport work. Just for reference,
GENERATING_MAC should be used for mac OS native item and HAVE_OPENTRANSPORT
should be used for networing code. Or that's how I plan on having things
work :-)
Andy
Index: meta.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/meta.c,v
retrieving revision 1.21
diff -u -2 -r1.21 meta.c
--- meta.c 1999/09/27 13:17:26 1.21
+++ meta.c 1999/10/02 00:10:02
@@ -69,5 +69,5 @@
#endif
-#ifdef GENERATING_MAC /* mac network globals */
+#ifdef HAVE_OPENTRANSPORT /* opentransport globals */
TEndpointInfo meta_info;
EndpointRef meta_ep;
@@ -83,5 +83,5 @@
{
unsigned char buffer[MAX_LEN_PACKET], *cptr;
-#ifdef GENERATING_MAC /* mac alternate networking */
+#ifdef HAVE_OPENTRANSPORT /* opentransport networking */
struct TUnitData xmit;
OSStatus err;
@@ -96,5 +96,5 @@
cptr=put_string(cptr, info);
put_uint16(buffer, cptr-buffer);
-#ifdef GENERATING_MAC /* mac networking */
+#ifdef HAVE_OPENTRANSPORT /* opentransport networking */
xmit.udata.len=strlen((const char *)buffer);
err=OTSndUData(meta_ep, &xmit);
@@ -108,5 +108,5 @@
void server_close_udp(void)
{
-#ifdef GENERATING_MAC /* mac networking */
+#ifdef HAVE_OPENTRANSPORT /* opentransport networking */
OTUnbind(meta_ep);
#else
@@ -119,5 +119,5 @@
char *servername=metaserver_addr;
int bad;
-#ifdef GENERATING_MAC /* mac networking */
+#ifdef HAVE_OPENTRANSPORT /* opentransport networking */
OSStatus err1;
OSErr err2;
@@ -134,5 +134,5 @@
* is valid, both decimal-dotted and name.
*/
-#ifdef GENERATING_MAC /* mac networking */
+#ifdef HAVE_OPENTRANSPORT /* opentransport networking */
if (err1 == 0)
{
@@ -157,5 +157,5 @@
* Open a UDP socket (an Internet datagram socket).
*/
-#ifdef GENERATING_MAC /* mac networking */
+#ifdef HAVE_OPENTRANSPORT /* opentransport networking */
meta_ep=OTOpenEndpoint(OTCreateConfiguration(kUDPName), 0, &meta_info,
&err1);
bad = (err1 != 0);
@@ -177,5 +177,5 @@
*/
-#ifdef GENERATING_MAC /* mac networking */
+#ifdef HAVE_OPENTRANSPORT /* opentransport networking */
err1=OTBind(meta_ep, NULL, NULL);
bad = (err1 != 0);
Index: packets.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/packets.h,v
retrieving revision 1.55
diff -u -2 -r1.55 packets.h
--- packets.h 1999/10/01 15:09:52 1.55
+++ packets.h 1999/10/02 00:14:32
@@ -14,4 +14,9 @@
#define FC__PACKETS_H
+#ifdef GENERATING_MAC /* mac networking */
+#include <OpenTptInternet.h>
+#include <OpenTransport.h>
+#endif
+
#include "player.h"
#include "shared.h" /* MAX_LEN_NAME, MAX_LEN_ADDR */
@@ -730,5 +735,10 @@
struct connection {
- int sock, used;
+#ifdef GENERATING_MAC /* mac only network data */
+ struct TEndpoint* sock;
+#else
+ int sock;
+#endif
+ int used;
int first_packet; /* check byte order on first packet */
int byte_swap; /* connection uses non-network byte order */
Index: sernet.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/sernet.c,v
retrieving revision 1.29
diff -u -2 -r1.29 sernet.c
--- sernet.c 1999/09/18 01:30:32 1.29
+++ sernet.c 1999/10/02 00:19:52
@@ -57,4 +57,8 @@
#include <arpa/inet.h>
#endif
+#ifdef HAVE_OPENTRANSPORT
+#include <OpenTransport.h>
+#include <OpenTptInternet.h>
+#endif
#include "log.h"
@@ -72,7 +76,8 @@
struct connection connections[MAX_NUM_CONNECTIONS];
-#ifdef GENERATING_MAC /* mac network globals */
+#ifdef HAVE_OPENTRANSPORT /* mac network globals */
TEndpointInfo serv_info;
EndpointRef serv_ep;
+EndpointRef sock;
#else
static int sock;
@@ -85,5 +90,9 @@
void close_connection(struct connection *pconn)
{
+#ifdef HAVE_OPENTRANSPORT
+ OTUnbind(pconn->sock);
+#else
close(pconn->sock);
+#endif
pconn->used=0;
pconn->access_level=ALLOW_NONE;
@@ -100,5 +109,9 @@
}
}
+#ifdef HAVE_OPENTRANSPORT
+ OTUnbind(sock);
+#else
close(sock);
+#endif
}
@@ -118,19 +131,20 @@
{
int i;
+ static int year;
+ static time_t time_at_turn_end;
+#ifndef HAVE_OPENTRANSPORT
int max_desc;
fd_set readfs;
struct timeval tv;
- static time_t time_at_turn_end;
- static int year;
#ifdef SOCKET_ZERO_ISNT_STDIN
char buf[BUF_SIZE+1];
char *bufptr = buf;
#endif
-
+#endif
if(year!=game.year) {
time_at_turn_end = time(NULL) + game.timeout;
if (server_state == RUN_GAME_STATE) year=game.year;
}
-
+
while(1) {
con_prompt_on(); /* accepting new input */
@@ -142,6 +156,6 @@
}
+#ifndef HAVE_OPENTRANSPORT
tv.tv_sec=1; tv.tv_usec=0;
-
MY_FD_ZERO(&readfs);
FD_SET(0, &readfs);
@@ -221,4 +235,14 @@
}
break;
+#else
+ for(i=0; i<MAX_NUM_CONNECTIONS; i++) {
+ if(connections[i].used) { /* if the conection is in use look at it*/
+ FD_SET(connections[i].sock, &readfs);
+ }
+ max_desc=MAX(connections[i].sock, max_desc);
+ }
+ con_prompt_off(); /* output doesn't generate a new prompt */
+
+#endif
}
con_prompt_off();
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Freeciv-Dev] mac #defs,
Andy Black <=
|
|