CoreFW  Check-in [17c1d8f6b0]

Overview
Comment:Add tcpsocket.

TODO:
* check for getaddrinfo() in configure
* fallback if getaddrinfo() is unavailable

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 17c1d8f6b0d8986206645647a9d77c5bdd1d900e2ff0d908b3ebf750d25ade66
User & Date: js on 2012-09-29 22:34:49
Other Links: manifest | tags
Context
2012-09-29
22:41
Add cfw_stream_write_string(). check-in: 2121a00059 user: js tags: trunk
22:34
Add tcpsocket. check-in: 17c1d8f6b0 user: js tags: trunk
22:12
Update corefw.h. check-in: cbf96fa23f user: js tags: trunk
Changes

Modified src/Makefile from [192d327027] to [51f63f1332].

10
11
12
13
14
15
16
17

18
19
20
21
22
23
       file.c		\
       int.c		\
       map.c		\
       object.c		\
       range.c		\
       refpool.c	\
       stream.c		\
       string.c


INCLUDES = ${SRCS:.c=.h}	\
	   corefw.h		\
	   hash.h

include ../buildsys.mk







|
>






10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
       file.c		\
       int.c		\
       map.c		\
       object.c		\
       range.c		\
       refpool.c	\
       stream.c		\
       string.c		\
       tcpsocket.c

INCLUDES = ${SRCS:.c=.h}	\
	   corefw.h		\
	   hash.h

include ../buildsys.mk

Modified src/corefw.h from [ca7fd1381b] to [24df01e901].

11
12
13
14
15
16
17

18
19
#include "hash.h"
#include "int.h"
#include "map.h"
#include "range.h"
#include "refpool.h"
#include "stream.h"
#include "string.h"


#endif







>


11
12
13
14
15
16
17
18
19
20
#include "hash.h"
#include "int.h"
#include "map.h"
#include "range.h"
#include "refpool.h"
#include "stream.h"
#include "string.h"
#include "tcpsocket.h"

#endif

Modified src/file.c from [707e2e6927] to [6d77e77ea7].

20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */

#include <stdarg.h>
#include <string.h>

#include <fcntl.h>
#include <unistd.h>

#include "stream.h"
#include "file.h"







<







20
21
22
23
24
25
26

27
28
29
30
31
32
33
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */


#include <string.h>

#include <fcntl.h>
#include <unistd.h>

#include "stream.h"
#include "file.h"
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
file_close(void *ptr)
{
	CFWFile *file = ptr;

	close(file->fd);
}

struct cfw_stream_ops stream_ops = {
	.read = file_read,
	.write = file_write,
	.eof = file_eof,
	.close = file_close
};

static bool







|







124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
file_close(void *ptr)
{
	CFWFile *file = ptr;

	close(file->fd);
}

static struct cfw_stream_ops stream_ops = {
	.read = file_read,
	.write = file_write,
	.eof = file_eof,
	.close = file_close
};

static bool

Modified src/stream.c from [4ca19651ff] to [1f3d504a05].

42
43
44
45
46
47
48

49
50
51
52
53



54
55
56
57
58
59
60
	cfw_stream_close(ptr);
}

ssize_t
cfw_stream_read(void *ptr, void *buf, size_t len)
{
	CFWStream *stream = ptr;


	if (stream == NULL || stream->ops == NULL)
		return -1;

	return stream->ops->read(stream, buf, len);



}

bool
cfw_stream_write(void *ptr, const void *buf, size_t len)
{
	CFWStream *stream = ptr;








>




|
>
>
>







42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
	cfw_stream_close(ptr);
}

ssize_t
cfw_stream_read(void *ptr, void *buf, size_t len)
{
	CFWStream *stream = ptr;
	ssize_t ret;

	if (stream == NULL || stream->ops == NULL)
		return -1;

	if ((ret = stream->ops->read(stream, buf, len)) < -1)
		ret = -1;

	return ret;
}

bool
cfw_stream_write(void *ptr, const void *buf, size_t len)
{
	CFWStream *stream = ptr;

Added src/tcpsocket.c version [8af7b73d7d].

Added src/tcpsocket.h version [3d2085d79e].