summaryrefslogtreecommitdiffstats
path: root/src/VBox/GuestHost/OpenGL/util/devnull.c
blob: 9e7d961894e301ca69deb628cccddf00f9ffe884 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/* Copyright (c) 2001, Stanford University
 * All rights reserved
 *
 * See the file LICENSE.txt for information on redistributing this software.
 */

#include "cr_net.h"
#include "cr_mem.h"
#include "cr_error.h"
#include "net_internals.h"

static void
crDevnullWriteExact( CRConnection *conn, const void *buf, unsigned int len )
{
	(void) conn;
	(void) buf;
	(void) len;
}

static void *
crDevnullAlloc( CRConnection *conn )
{
	return crAlloc( conn->buffer_size );
}

static void
crDevnullSingleRecv( CRConnection *conn, void *buf, unsigned int len )
{
	crError( "You can't receive data on a devnull connection!" );
	(void) conn;
	(void) buf;
	(void) len;
}

static void
crDevnullFree( CRConnection *conn, void *buf )
{
	crFree( buf );
	(void) conn;
}

static void
crDevnullSend( CRConnection *conn, void **bufp,
				 const void *start, unsigned int len )
{
	
	if (bufp)
	{
		/* We're sending something we've allocated.  It's now ours. 
		 * If the callers wants to send something else, he'll allocate 
		 * something else. 
		 * 
		 * ENFORCE IT! */

		crDevnullFree( conn, *bufp );
	}
	(void) conn;
	(void) bufp;
	(void) start;
	(void) len;
}

int
crDevnullRecv( void )
{
	crError( "You can't receive data on a DevNull network, stupid." );
	return 0;
}

void
crDevnullInit( CRNetReceiveFuncList *rfl, CRNetCloseFuncList *cfl, unsigned int mtu )
{
	(void) rfl;
	(void) cfl;
	(void) mtu;
}

static void
crDevnullAccept( CRConnection *conn, const char *hostname, unsigned short port )
{
	crError( "Well, you *could* accept a devnull client, but you'd be disappointed. ");
	(void) conn;
	(void) port;
        (void) hostname;
}

static int
crDevnullDoConnect( CRConnection *conn )
{
	(void) conn; 
	return 1;
}

static void
crDevnullDoDisconnect( CRConnection *conn )
{
	(void) conn;
}

void crDevnullConnection( CRConnection *conn )
{
	conn->type  = CR_DROP_PACKETS;
	conn->Alloc = crDevnullAlloc;
	conn->Send  = crDevnullSend;
	conn->SendExact  = crDevnullWriteExact;
	conn->Recv  = crDevnullSingleRecv;
	conn->Free  = crDevnullFree;
	conn->Accept = crDevnullAccept;
	conn->Connect = crDevnullDoConnect;
	conn->Disconnect = crDevnullDoDisconnect;
	conn->actual_network = 0;
}

CRConnection** crDevnullDump( int * num )
{
	*num = 0;
	return NULL;
}