Branch data Line data Source code
1 : : #include <stdarg.h>
2 : : #include <stdlib.h>
3 : : #include <unistd.h>
4 : : #include <sys/types.h>
5 : :
6 : : #include "class.h"
7 : : #include "stream.h"
8 : : #include "mock_worker.h"
9 : :
10 : : static
11 : : int
12 : 1 : mockWorkerCtor(void * _this, va_list * params)
13 : : {
14 : 1 : MockWorker this = _this;
15 : :
16 : 1 : this->rbuf = &(this->_rbuf[0]);
17 : 1 : this->wbuf = &(this->_wbuf[0]);
18 : :
19 : 1 : return 0;
20 : : }
21 : :
22 : : static
23 : : void
24 : 3 : mockWorkerDtor(void * _this)
25 : : {
26 : 3 : }
27 : :
28 : : static
29 : : void
30 : 1 : mockWorkerClone(void * _this, void * _base)
31 : : {
32 : 1 : MockWorker this = _this;
33 : 1 : MockWorker base = _base;
34 : :
35 : 1 : this->rbuf = &(base->_rbuf[0]);
36 : 1 : this->wbuf = &(base->_wbuf[0]);
37 : 1 : }
38 : :
39 : : static
40 : : ssize_t
41 : 187 : mockWorkerRead(void * _this, Stream st)
42 : : {
43 : 187 : MockWorker this = _this;
44 : : size_t size;
45 : :
46 : 187 : size = read((st->handle).fd, this->rbuf, 1024);
47 : :
48 : 187 : return size;
49 : : }
50 : :
51 : : static
52 : : ssize_t
53 : 1 : mockWorkerWrite(void * _this, Stream st)
54 : : {
55 : 1 : return 0;
56 : : }
57 : :
58 : : INIT_IFACE(Class, mockWorkerCtor, mockWorkerDtor, mockWorkerClone);
59 : : INIT_IFACE(StreamReader, mockWorkerRead);
60 : : INIT_IFACE(StreamWriter, mockWorkerWrite);
61 : 1 : CREATE_CLASS(
62 : : MockWorker,
63 : : NULL,
64 : : IFACE(Class),
65 : : IFACE(StreamReader),
66 : : IFACE(StreamWriter));
67 : :
68 : : // vim: set ts=4 sw=4:
|