/* $Header: /CVSROOT/tinolib/old/iow_socket.h,v 1.3 2008-09-01 20:18:14 tino Exp $ * * NOT YET IMPLEMENTED * UNIT TEST FAILS * * * IO wrapper for sockets * * This is a simple IO wrapper. The idea is, to have one single * interface to open/read/write/close for any operation needed, such * that the access can be abstract to the calling function. * * Also there is a generic easy error handler, which processes all * errors. * * Copyright (C)2005-2008 Valentin Hilbig * * This is release early code. Use at own risk. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * 02110-1301 USA. * * $Log: iow_socket.h,v $ * Revision 1.3 2008-09-01 20:18:14 tino * GPL fixed * * Revision 1.2 2007-08-06 15:55:39 tino * make test now works as expected * * Revision 1.1 2005/06/28 20:10:28 tino * started to add IOW (IO wrapper) * */ #ifndef tino_INC_iow_socket_h #define tino_INC_iow_socket_h #include "iow.h" #include "sock.h" #include "threads.h" /* this is not reentrant */ static TINO_IOW tino_iow_socket_error_param; static void tino_iow_socket_error(const char *s, va_list list) { TINO_IOW tmp; tmp = tino_iow_socket_error_param; tino_sock_error_unlock(); tino_iow_verror(tmp, s, list); } static int tino_iow_socket_open(TINO_IOW w, const char *what) { tino_iow_set_name(w, what); tino_sock_error_lock(tino_iow_socket_error); tino_iow_socket_error_param = w; w->fd = tino_sock_tcp_connect(what, NULL); tino_sock_error_unlock(); return w->fd; } static TINO_IOW tino_iow_socket(TINO_IOW w, void *user) { w = tino_iow_init(w, user); w->open = tino_iow_socket_open; return w; } #define TINO_IOW_SOCKET_LINK tino_iow_socket_link static struct tino_iow_link tino_iow_socket_link[] = { { "tcp", tino_iow_socket }, { 0 } }; #endif