/** * SCOUT socket header file * * Copyright (C) 2000, 2001, 2002 by * Jeffrey Fulmer - * This file is distributed as part of Scout * * 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef SOCK_H #define SOCK_H #ifdef HAVE_ARPA_INET_H # include #endif/*HAVE_ARPA_INET_H*/ #ifdef HAVE_SYS_SOCKET_H # include #endif/*HAVE_SYS_SOCKET_H*/ #ifdef HAVE_NETINET_IN_H # include #endif/*HAVE_NETINET_IN_H*/ #ifdef HAVE_NETDB_H # include #endif/*HAVE_NETDB_H*/ #ifdef HAVE_SSL # include # include # include # include # include # include #endif/*HAVE_SSL*/ typedef enum { S_CONNECTING = 1, S_READING = 2, S_WRITING = 4, S_DONE = 8 } S_STATUS; typedef enum { READ = 0, WRITE = 1, RDWR = 2 } SDSET; typedef struct { int sock; S_STATUS status; PROTOCOL prot; struct hostent *hp; struct{ int www; int proxy; struct{ TYPE www; TYPE proxy; } type; } auth; #ifdef HAVE_SSL SSL *ssl; SSL_CTX *ctx; #endif/*HAVE_SSL*/ size_t inbuffer; int pos_ini; char buffer[4096]; fd_set rset; fd_set wset; } CONN; /** * create socket * const char *hostname * const char *service */ int SCOUTsocket( CONN *conn, const char *hostname, int port ); /** * checks the socket for both * readability, writeability or both. */ int SCOUTsocket_check( CONN *C, SDSET S ); /** * write int sock * from char *buf, * unsigned int length */ void SCOUTsocket_write( CONN *conn, const void *b, ssize_t n ); /** * CONN *conn, * into void *buf, * size_t length */ ssize_t SCOUTsocket_read( CONN *conn, void *buf, size_t len ); /** * close int socket */ void SCOUTclose( CONN *C ); #endif /* SOCK_H */