kdecore Library API Documentation

ksocks.h

00001 /* This file is part of the KDE libraries
00002    Copyright (C) 2001 George Staikos <staikos@kde.org>
00003  
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License version 2 as published by the Free Software Foundation.
00007  
00008    This library is distributed in the hope that it will be useful,
00009    but WITHOUT ANY WARRANTY; without even the implied warranty of
00010    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011    Library General Public License for more details.
00012  
00013    You should have received a copy of the GNU Library General Public License
00014    along with this library; see the file COPYING.LIB.  If not, write to
00015    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00016    Boston, MA 02111-1307, USA.
00017 */
00018 #ifndef _KSOCKS_H_
00019 #define _KSOCKS_H_
00020 
00021 #include <qstringlist.h>
00022 #include <ksockaddr.h>
00023 #include <sys/types.h>
00024 #include <sys/time.h>
00025 #include <kstaticdeleter.h>
00026 
00027 class KSocksTable;
00028 class KSocksPrivate;
00029 class KLibrary;
00030 class KConfigBase;
00031 struct sockaddr;
00032 
00033 
00044 class KSocks {
00045    friend class KStaticDeleter<KSocks>;
00046 
00047 public:
00048 
00054    static KSocks *self();
00055 
00060    static bool activated();
00061 
00065    void disableSocks();
00066 
00070    void enableSocks();
00071 
00076    bool usingSocks();
00077 
00082    bool hasSocks();
00083 
00084    /*
00085     **     REIMPLEMENTATIONS OF LIBC SOCKET FUNCTIONS
00086     **/
00091     int     connect     (int sockfd, const sockaddr *serv_addr, 
00092                                 ksocklen_t addrlen);
00097     signed long int read  (int fd, void *buf, unsigned long int count);
00102     signed long int write (int fd, const void *buf, unsigned long int count);
00107     int     recvfrom    (int s, void *buf, unsigned long int len, int flags, 
00108                                 sockaddr *from, ksocklen_t *fromlen);
00113     int     sendto      (int s, const void *msg, unsigned long int len, int flags,
00114                              const sockaddr *to, ksocklen_t tolen);
00119     int     recv        (int s, void *buf, unsigned long int len, int flags);
00124     int     send        (int s, const void *msg, unsigned long int len, int flags);
00129     int     getsockname (int s, sockaddr *name, ksocklen_t *namelen);
00134     int     getpeername (int s, sockaddr *name, ksocklen_t *namelen);
00139     int     accept      (int s, sockaddr *addr, ksocklen_t *addrlen);
00144     int     select      (int n, fd_set *readfds, fd_set *writefds, 
00145                                 fd_set *exceptfds, struct timeval *timeout);
00150     int     listen      (int s, int backlog);
00155     int     bind        (int sockfd, sockaddr *my_addr, 
00156                                      ksocklen_t addrlen);
00157 
00163    void die();
00164 
00169    static void disable();
00170 
00175    static void setConfig(KConfigBase *config);
00176 
00177 private:
00178    KSocks(KConfigBase *config);
00179    ~KSocks();
00180 
00181    void stopSocks();
00182 
00183    static KSocks *_me;
00184    static bool _disabled;
00185    QStringList _libNames;
00186    QStringList _libPaths;
00187    bool _useSocks, _hasSocks;
00188    KLibrary* _socksLib;
00189 
00190 
00191    KSocksTable *_st;
00192    KSocksPrivate *d;
00193 };
00194 
00195 
00196 
00197 
00198 #endif
KDE Logo
This file is part of the documentation for kdelibs Version 3.1.0.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Oct 8 12:20:42 2003 by doxygen 1.2.18 written by Dimitri van Heesch, © 1997-2001