project_files/Android-build/SDL-android-project/jni/sdl_net/SDLnetselect.c
author Xeli
Tue, 05 Jul 2011 23:30:35 +0200
branchhedgeroid
changeset 5408 1c2f0dfbe759
parent 5317 86984c1034a5
permissions -rw-r--r--
removed some left over artifact of DataPackage in CMakeLists.txt
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5317
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
     1
/*
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
     2
    SDL_net:  An example cross-platform network library for use with SDL
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
     3
    Copyright (C) 1997-2004 Sam Lantinga
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
     4
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
     5
    This library is free software; you can redistribute it and/or
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
     6
    modify it under the terms of the GNU Library General Public
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
     7
    License as published by the Free Software Foundation; either
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
     8
    version 2 of the License, or (at your option) any later version.
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
     9
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
    10
    This library is distributed in the hope that it will be useful,
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
    11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
    12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
    13
    Library General Public License for more details.
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
    14
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
    15
    You should have received a copy of the GNU Library General Public
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
    16
    License along with this library; if not, write to the Free
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
    17
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
    18
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
    19
    Sam Lantinga
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
    20
    slouken@libsdl.org
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
    21
*/
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
    22
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
    23
/* $Id: SDLnetselect.c 1192 2004-01-04 17:41:55Z slouken $ */
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
    24
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
    25
#include "SDLnetsys.h"
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
    26
#include "SDL_net.h"
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
    27
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
    28
/* The select() API for network sockets */
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
    29
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
    30
struct SDLNet_Socket {
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
    31
	int ready;
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
    32
	SOCKET channel;
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
    33
#ifdef MACOS_OPENTRANSPORT
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
    34
	OTEventCode curEvent;
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
    35
#endif
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
    36
};
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
    37
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
    38
struct _SDLNet_SocketSet {
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
    39
	int numsockets;
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
    40
	int maxsockets;
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
    41
	struct SDLNet_Socket **sockets;
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
    42
};
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
    43
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
    44
/* Allocate a socket set for use with SDLNet_CheckSockets() 
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
    45
   This returns a socket set for up to 'maxsockets' sockets, or NULL if 
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
    46
   the function ran out of memory. 
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
    47
 */
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
    48
SDLNet_SocketSet SDLNet_AllocSocketSet(int maxsockets)
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
    49
{
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
    50
	struct _SDLNet_SocketSet *set;
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
    51
	int i;
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
    52
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
    53
	set = (struct _SDLNet_SocketSet *)malloc(sizeof(*set));
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
    54
	if ( set != NULL ) {
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
    55
		set->numsockets = 0;
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
    56
		set->maxsockets = maxsockets;
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
    57
		set->sockets = (struct SDLNet_Socket **)malloc
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
    58
					(maxsockets*sizeof(*set->sockets));
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
    59
		if ( set->sockets != NULL ) {
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
    60
			for ( i=0; i<maxsockets; ++i ) {
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
    61
				set->sockets[i] = NULL;
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
    62
			}
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
    63
		} else {
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
    64
			free(set);
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
    65
			set = NULL;
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
    66
		}
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
    67
	}
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
    68
	return(set);
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
    69
}
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
    70
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
    71
/* Add a socket to a set of sockets to be checked for available data */
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
    72
int SDLNet_AddSocket(SDLNet_SocketSet set, SDLNet_GenericSocket sock)
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
    73
{
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
    74
	if ( sock != NULL ) {
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
    75
		if ( set->numsockets == set->maxsockets ) {
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
    76
			SDLNet_SetError("socketset is full");
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
    77
			return(-1);
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
    78
		}
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
    79
		set->sockets[set->numsockets++] = (struct SDLNet_Socket *)sock;
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
    80
	}
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
    81
	return(set->numsockets);
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
    82
}
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
    83
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
    84
/* Remove a socket from a set of sockets to be checked for available data */
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
    85
int SDLNet_DelSocket(SDLNet_SocketSet set, SDLNet_GenericSocket sock)
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
    86
{
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
    87
	int i;
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
    88
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
    89
	if ( sock != NULL ) {
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
    90
		for ( i=0; i<set->numsockets; ++i ) {
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
    91
			if ( set->sockets[i] == (struct SDLNet_Socket *)sock ) {
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
    92
				break;
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
    93
			}
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
    94
		}
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
    95
		if ( i == set->numsockets ) {
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
    96
			SDLNet_SetError("socket not found in socketset");
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
    97
			return(-1);
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
    98
		}
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
    99
		--set->numsockets;
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   100
		for ( ; i<set->numsockets; ++i ) {
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   101
			set->sockets[i] = set->sockets[i+1];
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   102
		}
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   103
	}
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   104
	return(set->numsockets);
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   105
}
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   106
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   107
/* This function checks to see if data is available for reading on the
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   108
   given set of sockets.  If 'timeout' is 0, it performs a quick poll,
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   109
   otherwise the function returns when either data is available for
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   110
   reading, or the timeout in milliseconds has elapsed, which ever occurs
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   111
   first.  This function returns the number of sockets ready for reading,
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   112
   or -1 if there was an error with the select() system call.
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   113
*/
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   114
#ifdef MACOS_OPENTRANSPORT
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   115
int SDLNet_CheckSockets(SDLNet_SocketSet set, Uint32 timeout)
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   116
{
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   117
Uint32	stop;
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   118
int 	numReady;
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   119
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   120
	/* Loop, polling the network devices */
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   121
	
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   122
	stop = SDL_GetTicks() + timeout;
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   123
	
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   124
	do 
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   125
	{
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   126
	OTResult status;
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   127
	size_t	numBytes;
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   128
	int 	i;
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   129
		
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   130
		numReady = 0;
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   131
	
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   132
		for (i = set->numsockets-1;i >= 0;--i) 
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   133
		{
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   134
			status = OTLook( set->sockets[i]->channel );
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   135
			if( status > 0 )
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   136
			{
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   137
				switch( status )
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   138
				{
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   139
					case T_UDERR:
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   140
						OTRcvUDErr( set->sockets[i]->channel , nil);
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   141
						break;
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   142
					case T_DISCONNECT:
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   143
						OTRcvDisconnect( set->sockets[i]->channel, nil );
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   144
						break;
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   145
					case T_ORDREL:
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   146
						OTRcvOrderlyDisconnect(set->sockets[i]->channel );
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   147
						break;
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   148
					case T_CONNECT:
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   149
						OTRcvConnect( set->sockets[i]->channel, nil );
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   150
						break;
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   151
					
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   152
				
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   153
					default:
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   154
						set->sockets[i]->ready = 1;
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   155
						++numReady;
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   156
				}
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   157
			}
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   158
			else if( OTCountDataBytes(set->sockets[i]->channel, &numBytes ) != kOTNoDataErr )
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   159
			{
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   160
				set->sockets[i]->ready = 1;
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   161
				++numReady;
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   162
			}
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   163
			else
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   164
				set->sockets[i]->ready = 0;
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   165
		}
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   166
		
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   167
	} while (!numReady && (SDL_GetTicks() < stop));
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   168
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   169
	return(numReady);
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   170
}
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   171
#else
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   172
int SDLNet_CheckSockets(SDLNet_SocketSet set, Uint32 timeout)
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   173
{
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   174
	int i;
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   175
	SOCKET maxfd;
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   176
	int retval;
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   177
	struct timeval tv;
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   178
	fd_set mask;
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   179
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   180
	/* Find the largest file descriptor */
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   181
	maxfd = 0;
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   182
	for ( i=set->numsockets-1; i>=0; --i ) {
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   183
		if ( set->sockets[i]->channel > maxfd ) {
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   184
			maxfd = set->sockets[i]->channel;
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   185
		}
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   186
	}
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   187
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   188
	/* Check the file descriptors for available data */
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   189
	do {
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   190
		errno = 0;
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   191
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   192
		/* Set up the mask of file descriptors */
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   193
		FD_ZERO(&mask);
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   194
		for ( i=set->numsockets-1; i>=0; --i ) {
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   195
			FD_SET(set->sockets[i]->channel, &mask);
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   196
		}
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   197
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   198
		/* Set up the timeout */
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   199
		tv.tv_sec = timeout/1000;
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   200
		tv.tv_usec = (timeout%1000)*1000;
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   201
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   202
		/* Look! */
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   203
		retval = select(maxfd+1, &mask, NULL, NULL, &tv);
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   204
	} while ( errno == EINTR );
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   205
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   206
	/* Mark all file descriptors ready that have data available */
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   207
	if ( retval > 0 ) {
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   208
		for ( i=set->numsockets-1; i>=0; --i ) {
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   209
			if ( FD_ISSET(set->sockets[i]->channel, &mask) ) {
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   210
				set->sockets[i]->ready = 1;
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   211
			}
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   212
		}
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   213
	}
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   214
	return(retval);
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   215
}
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   216
#endif /* MACOS_OPENTRANSPORT */
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   217
   
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   218
/* Free a set of sockets allocated by SDL_NetAllocSocketSet() */
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   219
extern void SDLNet_FreeSocketSet(SDLNet_SocketSet set)
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   220
{
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   221
	if ( set ) {
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   222
		free(set->sockets);
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   223
		free(set);
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   224
	}
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   225
}
86984c1034a5 Added sdl_net from the unofficial android port: http://www.anddev.org/sdl_port_for_android_sdk-ndk_16-t9218.html
Xeli
parents:
diff changeset
   226