Initial commit of files
This commit is contained in:
63
include/libnet++/Client.h
Normal file
63
include/libnet++/Client.h
Normal file
@ -0,0 +1,63 @@
|
||||
//
|
||||
// Client
|
||||
//
|
||||
|
||||
/* prevent multiple inclusions */
|
||||
#ifndef __Client__
|
||||
#define __Client__
|
||||
|
||||
/* includes *****************************************************************/
|
||||
|
||||
#include "Socket.h"
|
||||
|
||||
/* defines ******************************************************************/
|
||||
|
||||
/* macros *******************************************************************/
|
||||
|
||||
/* structs & typedefs *******************************************************/
|
||||
|
||||
/* c class definitions ******************************************************/
|
||||
|
||||
class Client {
|
||||
// public data
|
||||
public:
|
||||
|
||||
// protected data
|
||||
protected:
|
||||
|
||||
// private data
|
||||
private:
|
||||
|
||||
// static data
|
||||
|
||||
// public methods
|
||||
public:
|
||||
// constructors
|
||||
Client();
|
||||
|
||||
// destructor
|
||||
virtual ~Client();
|
||||
|
||||
// public methods
|
||||
int ConnectUri( const char *uri );
|
||||
int ListenUri( const char *uri );
|
||||
|
||||
// virtual functions
|
||||
virtual int Connect( const char *host, const char *service=NULL )
|
||||
{return -1;};
|
||||
virtual int Listen( const char *host, const char *service=NULL )
|
||||
{return 0;};
|
||||
|
||||
// exceptions
|
||||
class ClientException
|
||||
{
|
||||
char *toString(void) { return strerror(errno); };
|
||||
};
|
||||
|
||||
// static methods
|
||||
|
||||
// private methods
|
||||
private:
|
||||
};
|
||||
|
||||
#endif
|
||||
79
include/libnet++/Clock.h
Normal file
79
include/libnet++/Clock.h
Normal file
@ -0,0 +1,79 @@
|
||||
//
|
||||
// Linux Daemon
|
||||
//
|
||||
|
||||
/* prevent multiple inclusions */
|
||||
#ifndef __Clock__
|
||||
#define __Clock__
|
||||
|
||||
/* includes *****************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <time.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
/* defines ******************************************************************/
|
||||
|
||||
/* macros *******************************************************************/
|
||||
|
||||
/* structs & typedefs *******************************************************/
|
||||
|
||||
/* c class definitions ******************************************************/
|
||||
|
||||
class Clock {
|
||||
// public data
|
||||
public:
|
||||
|
||||
// protected data
|
||||
protected:
|
||||
struct timespec Time;
|
||||
|
||||
// private data
|
||||
private:
|
||||
|
||||
// public methods
|
||||
public:
|
||||
// constructors
|
||||
Clock();
|
||||
Clock( time_t tic );
|
||||
|
||||
// destructor
|
||||
virtual ~Clock();
|
||||
|
||||
Clock( const Clock& );
|
||||
const Clock& operator=( const Clock& );
|
||||
|
||||
// public methods
|
||||
time_t GetUtc( void ) { return Time.tv_sec; };
|
||||
struct timespec GetTimeSpec() { return Time; };
|
||||
|
||||
int Format( char *buf, int max );
|
||||
struct timespec Parse( const char *buf );
|
||||
|
||||
void SetTime( void );
|
||||
void SetTime( time_t sec, suseconds_t usec=0L );
|
||||
void SetTime( const struct timespec &tv ) { Time = tv; };
|
||||
|
||||
// microsecond time stamp
|
||||
unsigned long long GetTimeStamp();
|
||||
void SetTimeStamp( unsigned long long ts );
|
||||
|
||||
// virtual functions
|
||||
|
||||
// exceptions
|
||||
|
||||
// static methods
|
||||
static int Format( const struct timespec &tv, char **buf, int *max );
|
||||
|
||||
// private methods
|
||||
private:
|
||||
|
||||
// signal catchers (do not override)
|
||||
};
|
||||
|
||||
#endif
|
||||
64
include/libnet++/ClockTimer.h
Normal file
64
include/libnet++/ClockTimer.h
Normal file
@ -0,0 +1,64 @@
|
||||
//
|
||||
// Linux Daemon
|
||||
//
|
||||
|
||||
/* prevent multiple inclusions */
|
||||
#ifndef __ClockTimer__
|
||||
#define __ClockTimer__
|
||||
|
||||
/* includes *****************************************************************/
|
||||
|
||||
#include "Timer.h"
|
||||
|
||||
/* defines ******************************************************************/
|
||||
|
||||
/* macros *******************************************************************/
|
||||
|
||||
/* structs & typedefs *******************************************************/
|
||||
|
||||
/* c class definitions ******************************************************/
|
||||
|
||||
class ClockTimer : public Timer {
|
||||
// public data
|
||||
public:
|
||||
|
||||
// protected data
|
||||
protected:
|
||||
|
||||
// private data
|
||||
private:
|
||||
long m_timeout; // usec
|
||||
|
||||
// public methods
|
||||
public:
|
||||
// constructors
|
||||
ClockTimer();
|
||||
ClockTimer(unsigned long usec);
|
||||
|
||||
// destructor
|
||||
virtual ~ClockTimer();
|
||||
|
||||
ClockTimer( const ClockTimer& );
|
||||
const ClockTimer& operator=( const ClockTimer& );
|
||||
|
||||
// public methods
|
||||
int Restart(void);
|
||||
int Start( unsigned long usec );
|
||||
void Stop(void);
|
||||
unsigned long Remaining(void);
|
||||
int Wait(void);
|
||||
int Sync(void); // Wait()+Restart()
|
||||
|
||||
// virtual functions
|
||||
|
||||
// exceptions
|
||||
|
||||
// static methods
|
||||
|
||||
// private methods
|
||||
private:
|
||||
|
||||
// signal catchers (do not override)
|
||||
};
|
||||
|
||||
#endif
|
||||
89
include/libnet++/Daemon.h
Normal file
89
include/libnet++/Daemon.h
Normal file
@ -0,0 +1,89 @@
|
||||
//
|
||||
// Linux Daemon
|
||||
//
|
||||
|
||||
/* prevent multiple inclusions */
|
||||
#ifndef __Daemon__
|
||||
#define __Daemon__
|
||||
|
||||
/* includes *****************************************************************/
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <signal.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
|
||||
#include "LogData.h"
|
||||
|
||||
/* defines ******************************************************************/
|
||||
|
||||
/* macros *******************************************************************/
|
||||
|
||||
/* structs & typedefs *******************************************************/
|
||||
|
||||
/* c class definitions ******************************************************/
|
||||
|
||||
class Daemon {
|
||||
// public data
|
||||
public:
|
||||
|
||||
// protected data
|
||||
protected:
|
||||
|
||||
// private data
|
||||
private:
|
||||
char m_name[32];
|
||||
bool m_debug;
|
||||
int m_pid;
|
||||
|
||||
// public methods
|
||||
public:
|
||||
// constructors
|
||||
Daemon();
|
||||
Daemon( const char *name, int debug, int noclose );
|
||||
|
||||
// destructor
|
||||
virtual ~Daemon();
|
||||
|
||||
// public methods
|
||||
int Daemonize( const char *name, int debug=0, int noclose=0 );
|
||||
void Die( int code );
|
||||
|
||||
void SetDebug(bool debug) {m_debug = debug;};
|
||||
bool GetDebug(void) {return m_debug;};
|
||||
bool IsDebug(void) {return m_debug;};
|
||||
void Dprintf( const char *fmt, ... );
|
||||
|
||||
void SetName(const char *s) {strncpy(m_name,s,sizeof(m_name)-1);};
|
||||
char *GetName(void) {return m_name;};
|
||||
|
||||
int GetPid(void) {return m_pid;};
|
||||
|
||||
// virtual functions
|
||||
virtual void DaemonStartup(void) {};
|
||||
virtual void DaemonShutdown(void) {};
|
||||
virtual void DaemonReload(void) {};
|
||||
|
||||
// exceptions
|
||||
class DaemonException
|
||||
{
|
||||
char *toString(void) { return strerror(errno); };
|
||||
};
|
||||
|
||||
// static methods to override
|
||||
static int SignalAlarm(void) {return 1;};
|
||||
static int SignalDeath(void) {return 1;};
|
||||
static int SignalInterrupt(void) {return 1;};
|
||||
static void SignalHup(void) {;};
|
||||
|
||||
// private methods
|
||||
private:
|
||||
// signal catchers (do not override)
|
||||
static void signal_alarm(int signum);
|
||||
static void signal_child(int signum);
|
||||
static void signal_death(int signum);
|
||||
static void signal_intrp(int signum);
|
||||
static void signal_hup(int signum);
|
||||
};
|
||||
|
||||
#endif
|
||||
91
include/libnet++/LogData.h
Normal file
91
include/libnet++/LogData.h
Normal file
@ -0,0 +1,91 @@
|
||||
//
|
||||
// GPS Daemon
|
||||
// Neal Probert
|
||||
//
|
||||
|
||||
/* prevent multiple inclusions */
|
||||
#ifndef __LogData__
|
||||
#define __LogData__
|
||||
|
||||
/* includes *****************************************************************/
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <syslog.h>
|
||||
|
||||
#include "UdpClient.h"
|
||||
|
||||
#ifdef MYSQL_LOGGING
|
||||
#include "mysql/mysql.h"
|
||||
#endif
|
||||
#ifdef BZIP2_LOGGING
|
||||
#include "bzlib.h"
|
||||
#endif
|
||||
|
||||
/* defines ******************************************************************/
|
||||
|
||||
#define LOGD_PORT "2940"
|
||||
|
||||
/* macros *******************************************************************/
|
||||
|
||||
/* structs & typedefs *******************************************************/
|
||||
|
||||
/* c class definitions ******************************************************/
|
||||
|
||||
//
|
||||
// Uses the Peak Systems CAN Linux driver and Nissan CAN data
|
||||
//
|
||||
class LogData : public UdpClient {
|
||||
// public data
|
||||
public:
|
||||
|
||||
// private data
|
||||
private:
|
||||
// MySQL logging
|
||||
int nfields;
|
||||
char myfields[2048];
|
||||
FILE *pFile;
|
||||
#ifdef MYSQL_LOGGING
|
||||
MYSQL *myconn;
|
||||
char mytable[256];
|
||||
MYSQL_RES *myres;
|
||||
#endif
|
||||
long nrecords;
|
||||
|
||||
// formats
|
||||
bool m_logging;
|
||||
bool m_syslog;
|
||||
bool m_binary;
|
||||
|
||||
// static data
|
||||
|
||||
// public methods
|
||||
public:
|
||||
// constructors
|
||||
LogData();
|
||||
|
||||
// destructor
|
||||
virtual ~LogData();
|
||||
|
||||
// public methods
|
||||
FILE *LogOpen( const char *log = NULL, int bz2=0 );
|
||||
int LogRead( timeval *tv, char *buf, int max );
|
||||
int LogPrintf( const char *fmt, ... );
|
||||
int LogWrite( const char *buf, int max );
|
||||
void LogClose( void );
|
||||
void LogRotate( void );
|
||||
|
||||
// text only csv logging
|
||||
void LogFields( const char *flds );
|
||||
int CsvSplit( char *buf, char *field[], int max );
|
||||
|
||||
// logging control
|
||||
bool IsLogging(void) {return m_logging;};
|
||||
void SetBinary(void) { m_binary=true; };
|
||||
|
||||
// static methods
|
||||
|
||||
// private methods
|
||||
private:
|
||||
};
|
||||
|
||||
#endif
|
||||
59
include/libnet++/Logging.h
Normal file
59
include/libnet++/Logging.h
Normal file
@ -0,0 +1,59 @@
|
||||
//
|
||||
// Linux Daemon
|
||||
//
|
||||
|
||||
/* prevent multiple inclusions */
|
||||
#ifndef __Logging__
|
||||
#define __Logging__
|
||||
|
||||
/* includes *****************************************************************/
|
||||
|
||||
#include "LogData.h"
|
||||
|
||||
/* defines ******************************************************************/
|
||||
|
||||
/* macros *******************************************************************/
|
||||
|
||||
/* structs & typedefs *******************************************************/
|
||||
|
||||
/* c class definitions ******************************************************/
|
||||
|
||||
class Logging {
|
||||
// public data
|
||||
public:
|
||||
LogData Log;
|
||||
|
||||
protected:
|
||||
// logfile
|
||||
|
||||
// pid
|
||||
|
||||
// private data
|
||||
private:
|
||||
|
||||
// static data
|
||||
|
||||
// public methods
|
||||
public:
|
||||
// constructors
|
||||
Logging();
|
||||
|
||||
// destructor
|
||||
virtual ~Logging();
|
||||
|
||||
// public methods
|
||||
FILE *LogOpen( const char *log, int bz2 )
|
||||
{ return Log.LogOpen( log, bz2 ); };
|
||||
FILE *LogOpen( const char *log )
|
||||
{ return Log.LogOpen( log ); };
|
||||
bool IsLogging(void) {return Log.IsLogging();};
|
||||
|
||||
// virtual functions
|
||||
|
||||
// exceptions
|
||||
|
||||
// private methods
|
||||
private:
|
||||
};
|
||||
|
||||
#endif
|
||||
72
include/libnet++/Mutex.h
Normal file
72
include/libnet++/Mutex.h
Normal file
@ -0,0 +1,72 @@
|
||||
//
|
||||
// Linux Daemon
|
||||
//
|
||||
|
||||
/* prevent multiple inclusions */
|
||||
#ifndef __Mutex__
|
||||
#define __Mutex__
|
||||
|
||||
/* includes *****************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <errno.h>
|
||||
#include <memory.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
/* defines ******************************************************************/
|
||||
|
||||
/* macros *******************************************************************/
|
||||
|
||||
/* structs & typedefs *******************************************************/
|
||||
|
||||
/* c class definitions ******************************************************/
|
||||
|
||||
class Mutex {
|
||||
// public data
|
||||
public:
|
||||
|
||||
// protected data
|
||||
protected:
|
||||
pthread_mutexattr_t m_attr;
|
||||
pthread_mutex_t m_mutex;
|
||||
|
||||
// private data
|
||||
private:
|
||||
|
||||
// public methods
|
||||
public:
|
||||
// constructors
|
||||
Mutex();
|
||||
|
||||
// destructor
|
||||
virtual ~Mutex();
|
||||
|
||||
Mutex( const Mutex& );
|
||||
const Mutex& operator=( const Mutex& );
|
||||
|
||||
// public methods
|
||||
void Init( void );
|
||||
int Lock( void );
|
||||
int TryLock( void );
|
||||
int Unlock( void );
|
||||
|
||||
// virtual functions
|
||||
|
||||
// exceptions
|
||||
class MutexException
|
||||
{
|
||||
char *toString(void) { return strerror(errno); };
|
||||
};
|
||||
|
||||
// static methods to override
|
||||
|
||||
// private methods
|
||||
private:
|
||||
};
|
||||
|
||||
#endif
|
||||
66
include/libnet++/PosixTimer.h
Normal file
66
include/libnet++/PosixTimer.h
Normal file
@ -0,0 +1,66 @@
|
||||
//
|
||||
// Linux Daemon
|
||||
//
|
||||
|
||||
/* prevent multiple inclusions */
|
||||
#ifndef __PosixTimer__
|
||||
#define __PosixTimer__
|
||||
|
||||
/* includes *****************************************************************/
|
||||
|
||||
#include "Timer.h"
|
||||
|
||||
/* defines ******************************************************************/
|
||||
|
||||
/* macros *******************************************************************/
|
||||
|
||||
/* structs & typedefs *******************************************************/
|
||||
|
||||
/* c class definitions ******************************************************/
|
||||
|
||||
class PosixTimer : public Timer {
|
||||
// public data
|
||||
public:
|
||||
|
||||
// protected data
|
||||
protected:
|
||||
|
||||
// private data
|
||||
private:
|
||||
timer_t m_timerid;
|
||||
struct itimerspec m_value;
|
||||
int m_signal; // signal used
|
||||
bool m_running;
|
||||
bool m_oneshot;
|
||||
|
||||
// public methods
|
||||
public:
|
||||
// constructors
|
||||
PosixTimer();
|
||||
PosixTimer(unsigned long usec);
|
||||
|
||||
// destructor
|
||||
virtual ~PosixTimer();
|
||||
|
||||
// public methods
|
||||
int Restart(void);
|
||||
int Start( unsigned long usec, bool one_shot=true );
|
||||
void Stop(void);
|
||||
unsigned long Remaining(void);
|
||||
int Wait(void);
|
||||
int Sync(void); // Wait()+Restart()
|
||||
|
||||
// virtual functions
|
||||
|
||||
// exceptions
|
||||
|
||||
// static methods
|
||||
|
||||
// private methods
|
||||
private:
|
||||
void Init(void);
|
||||
|
||||
// signal catchers (do not override)
|
||||
};
|
||||
|
||||
#endif
|
||||
67
include/libnet++/QueryString.h
Normal file
67
include/libnet++/QueryString.h
Normal file
@ -0,0 +1,67 @@
|
||||
//
|
||||
// URI Parser
|
||||
// Neal Probert
|
||||
//
|
||||
|
||||
/* prevent multiple inclusions */
|
||||
#ifndef __QueryString__
|
||||
#define __QueryString__
|
||||
|
||||
/* includes *****************************************************************/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
/* defines ******************************************************************/
|
||||
|
||||
/* macros *******************************************************************/
|
||||
|
||||
/* structs & typedefs *******************************************************/
|
||||
|
||||
/* c class definitions ******************************************************/
|
||||
|
||||
//
|
||||
// Chop up the URI into it's component parts
|
||||
//
|
||||
class QueryString {
|
||||
// public data
|
||||
public:
|
||||
std::string Name;
|
||||
std::string Value;
|
||||
|
||||
// private data
|
||||
private:
|
||||
|
||||
// static data
|
||||
|
||||
// public methods
|
||||
public:
|
||||
// constructors
|
||||
QueryString();
|
||||
QueryString(const QueryString ©);
|
||||
|
||||
// destructor
|
||||
virtual ~QueryString();
|
||||
|
||||
// operators
|
||||
QueryString &operator=(const QueryString &rhs);
|
||||
|
||||
// access methods
|
||||
void setName( const char *s );
|
||||
void setValue( const char *s );
|
||||
void setValue( int v );
|
||||
void Set( const char *name, const char *value=NULL );
|
||||
|
||||
const char *getName(void) { return Name.c_str(); };
|
||||
int getLength(void) { return Value.length(); };
|
||||
const char *getValue(void) { return Value.c_str(); };
|
||||
const char *Get(void) { return Value.c_str(); };
|
||||
|
||||
// static methods
|
||||
|
||||
// private methods
|
||||
private:
|
||||
};
|
||||
|
||||
#endif
|
||||
78
include/libnet++/RawSocket.h
Normal file
78
include/libnet++/RawSocket.h
Normal file
@ -0,0 +1,78 @@
|
||||
//
|
||||
// Socket
|
||||
//
|
||||
|
||||
/* prevent multiple inclusions */
|
||||
#ifndef __RawSocket__
|
||||
#define __RawSocket__
|
||||
|
||||
/* includes *****************************************************************/
|
||||
|
||||
#include "Socket.h"
|
||||
|
||||
#include<netinet/ip_icmp.h> //Provides declarations for icmp header
|
||||
#include<netinet/udp.h> //Provides declarations for udp header
|
||||
#include<netinet/tcp.h> //Provides declarations for tcp header
|
||||
#include<netinet/ip.h> //Provides declarations for ip header
|
||||
#include<sys/socket.h>
|
||||
#include<arpa/inet.h>
|
||||
|
||||
/* defines ******************************************************************/
|
||||
|
||||
/* macros *******************************************************************/
|
||||
|
||||
/* structs & typedefs *******************************************************/
|
||||
|
||||
/* c class definitions ******************************************************/
|
||||
|
||||
class RawSocket : public Socket {
|
||||
// public data
|
||||
public:
|
||||
struct sockaddr_storage sock_addr;
|
||||
socklen_t sock_len;
|
||||
|
||||
// protected data
|
||||
protected:
|
||||
|
||||
// private data
|
||||
private:
|
||||
|
||||
// static data
|
||||
|
||||
// public methods
|
||||
public:
|
||||
// constructors
|
||||
RawSocket();
|
||||
|
||||
// destructor
|
||||
virtual ~RawSocket();
|
||||
|
||||
// copy constructor
|
||||
RawSocket( const RawSocket &src ) ;
|
||||
const RawSocket& operator=( const RawSocket &src );
|
||||
|
||||
// public methods
|
||||
int Socket();
|
||||
int RecvFrom( void *buf, int max );
|
||||
|
||||
// control
|
||||
|
||||
// status
|
||||
int GetIPHdrLen( const void *buf );
|
||||
int GetProtocol( const void *buf );
|
||||
struct iphdr *GetIPHeader( const void *buf ) {return (struct iphdr*)buf;};
|
||||
struct tcphdr *GetTcpHeader( const void *buf );
|
||||
struct udphdr *GetUdpHeader( const void *buf );
|
||||
unsigned char *GetData( const void *buf, int *length, int proto=0 );
|
||||
|
||||
// virtual functions
|
||||
|
||||
// exceptions
|
||||
|
||||
// static methods
|
||||
|
||||
// private methods
|
||||
private:
|
||||
};
|
||||
|
||||
#endif
|
||||
94
include/libnet++/SerialIO.h
Normal file
94
include/libnet++/SerialIO.h
Normal file
@ -0,0 +1,94 @@
|
||||
//
|
||||
// Socket
|
||||
//
|
||||
|
||||
/* prevent multiple inclusions */
|
||||
#ifndef __SerialIO__
|
||||
#define __SerialIO__
|
||||
|
||||
/* includes *****************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/types.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <termios.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#include "netlib.h"
|
||||
|
||||
/* defines ******************************************************************/
|
||||
|
||||
/* macros *******************************************************************/
|
||||
|
||||
/* structs & typedefs *******************************************************/
|
||||
|
||||
/* c class definitions ******************************************************/
|
||||
|
||||
/** \class
|
||||
*
|
||||
* Serial I/O wrapper and support class, Linux only
|
||||
*/
|
||||
|
||||
class SerialIO {
|
||||
// public data
|
||||
public:
|
||||
|
||||
// protected data
|
||||
protected:
|
||||
|
||||
// private data
|
||||
private:
|
||||
int m_fd; // handle
|
||||
unsigned long m_sentcnt; // # bytes sent
|
||||
unsigned long m_recvcnt; // # bytes recv
|
||||
|
||||
// serial config
|
||||
struct termios termios;
|
||||
|
||||
// public methods
|
||||
public:
|
||||
// constructors
|
||||
SerialIO();
|
||||
|
||||
// destructor
|
||||
virtual ~SerialIO();
|
||||
|
||||
// public methods
|
||||
|
||||
// control
|
||||
int GetFd( void ) { return m_fd; };
|
||||
|
||||
void SetBaud( int baud );
|
||||
void SetCanonical( bool canonical, int bs=0, int wt=0 );
|
||||
void Canonical(void) { SetCanonical(true); };
|
||||
void NonCanonical(void) { SetCanonical(false); };
|
||||
|
||||
// i/o
|
||||
int Open( const char *dev, int baud );
|
||||
int Read( void *buf, int len );
|
||||
int Write( const void *buf, int len );
|
||||
void Close( void );
|
||||
|
||||
// status
|
||||
unsigned long GetBytesSent(void) {return m_sentcnt;};
|
||||
unsigned long GetBytesRecv(void) {return m_recvcnt;};
|
||||
|
||||
// virtual functions (must be overridden!)
|
||||
|
||||
// exceptions
|
||||
class SerialIOException
|
||||
{
|
||||
char *toString(void) { return strerror(errno); };
|
||||
};
|
||||
|
||||
// private methods
|
||||
private:
|
||||
};
|
||||
|
||||
#endif
|
||||
82
include/libnet++/Server.h
Normal file
82
include/libnet++/Server.h
Normal file
@ -0,0 +1,82 @@
|
||||
//
|
||||
// Server
|
||||
//
|
||||
|
||||
/* prevent multiple inclusions */
|
||||
#ifndef __Server__
|
||||
#define __Server__
|
||||
|
||||
/* includes *****************************************************************/
|
||||
|
||||
#include "Socket.h"
|
||||
|
||||
/* defines ******************************************************************/
|
||||
|
||||
/* macros *******************************************************************/
|
||||
|
||||
/* structs & typedefs *******************************************************/
|
||||
|
||||
/* c class definitions ******************************************************/
|
||||
|
||||
class Server {
|
||||
// public data
|
||||
public:
|
||||
|
||||
protected:
|
||||
// socket
|
||||
int m_nfds; /* number of descriptors */
|
||||
fd_set m_rfds; /* set of open sockets */
|
||||
|
||||
// select
|
||||
fd_set m_sfds;
|
||||
struct timeval m_timeout;
|
||||
struct timeval m_seltime;
|
||||
|
||||
bool m_client_to; // reset timeout on client
|
||||
|
||||
// private data
|
||||
private:
|
||||
|
||||
// static data
|
||||
|
||||
// public methods
|
||||
public:
|
||||
// constructors
|
||||
Server();
|
||||
|
||||
// destructor
|
||||
virtual ~Server();
|
||||
|
||||
// public methods
|
||||
// control
|
||||
void SetTimeout(time_t to);
|
||||
void SetTimeout(timeval &tv);
|
||||
void ResetTimeout(void);
|
||||
void ResetClientTimeout(void) {if(m_client_to)ResetTimeout();};
|
||||
void ResetServerTimeout(void) {ResetTimeout();};
|
||||
void SetClientTimeout(bool ct) {m_client_to=ct;};
|
||||
|
||||
// select
|
||||
void AddFd(int sock) {if(sock>=0)m_nfds=fd_add(sock,&m_rfds,m_nfds);};
|
||||
void DelFd(int sock) {if(sock>=0)FD_CLR(sock,&m_rfds);};
|
||||
bool IsSet(int sock) {if(sock>=0)return FD_ISSET(sock,&m_sfds);return 0;};
|
||||
int Select( void );
|
||||
|
||||
// service
|
||||
int ServiceUri( const char *uri );
|
||||
|
||||
// virtual functions
|
||||
virtual int Service( const char *host, const char *service=NULL ) {return -1;};
|
||||
virtual int Listen( void ) {return 0;};
|
||||
virtual int ServerTimeout(void) {return 0;};
|
||||
virtual int ServerSocket(void) {return 0;}; // other socket
|
||||
|
||||
// exceptions
|
||||
|
||||
// static methods
|
||||
|
||||
// private methods
|
||||
private:
|
||||
};
|
||||
|
||||
#endif
|
||||
165
include/libnet++/Socket.h
Normal file
165
include/libnet++/Socket.h
Normal file
@ -0,0 +1,165 @@
|
||||
//
|
||||
// Socket
|
||||
//
|
||||
|
||||
/* prevent multiple inclusions */
|
||||
#ifndef __Socket__
|
||||
#define __Socket__
|
||||
|
||||
/* includes *****************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/types.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <sys/time.h>
|
||||
#include <byteswap.h>
|
||||
#include <netdb.h>
|
||||
#include <net/if.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/tcp.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include <linux/sockios.h>
|
||||
|
||||
#include "netlib.h"
|
||||
|
||||
/* defines ******************************************************************/
|
||||
|
||||
/* macros *******************************************************************/
|
||||
|
||||
#if defined(__BIG_ENDIAN)
|
||||
# define ntohll(x) (x)
|
||||
# define htonll(x) (x)
|
||||
#elif defined(__LITTLE_ENDIAN)
|
||||
# define ntohll(x) bswap_64(x)
|
||||
# define htonll(x) bswap_64(x)
|
||||
#endif
|
||||
|
||||
/* structs & typedefs *******************************************************/
|
||||
|
||||
/* c class definitions ******************************************************/
|
||||
|
||||
class Socket {
|
||||
// public data
|
||||
public:
|
||||
|
||||
// protected data
|
||||
protected:
|
||||
// socket
|
||||
int m_family; // AF_UNIX, AF_INET or AF_INET6
|
||||
int m_proto; // protocol
|
||||
int m_sock; // socket
|
||||
|
||||
void LogSocket( const char *str );
|
||||
|
||||
// private data
|
||||
private:
|
||||
// reference
|
||||
static char g_hostname[256];
|
||||
char m_host[256];
|
||||
char m_port[32];
|
||||
|
||||
// stats
|
||||
unsigned long m_sentcnt;
|
||||
unsigned long m_recvcnt;
|
||||
|
||||
// static data
|
||||
|
||||
// public methods
|
||||
public:
|
||||
// constructors
|
||||
Socket();
|
||||
|
||||
// destructor
|
||||
virtual ~Socket();
|
||||
|
||||
// copy constructor
|
||||
Socket( const Socket& );
|
||||
const Socket& operator=( const Socket& );
|
||||
|
||||
// public methods
|
||||
int ClientUri( const char *uri );
|
||||
int ServerUri( const char *uri );
|
||||
|
||||
// control
|
||||
void SetFamily( int family ) {m_family = family;};
|
||||
void SetProto( int proto ) {m_proto = proto;};
|
||||
void SetHost(const char *host) {if(host)strncpy(m_host,host,sizeof(m_host)-1);};
|
||||
void SetPort(const char *port) {if(port)strncpy(m_port,port,sizeof(m_port)-1);};
|
||||
void SetHostPort(const char *host, const char *port)
|
||||
{SetHost(host);SetPort(port);};
|
||||
void SetSocket( int sock ) {m_sock=sock;};
|
||||
|
||||
// i/o
|
||||
int Bind( const struct sockaddr_storage *sa, int len )
|
||||
{return Bind(m_sock,sa,len);};
|
||||
void Close( void );
|
||||
|
||||
int Recv( void *buf, int len );
|
||||
int Send( const void *buf, int len );
|
||||
int RecvFrom( void *buf, int max, struct sockaddr_storage *sa, socklen_t *len );
|
||||
int SendTo( const void *buf, int max, const struct sockaddr_storage *sa, socklen_t len );
|
||||
|
||||
// status
|
||||
unsigned long GetBytesSent(void) {return m_sentcnt;};
|
||||
unsigned long GetBytesRecv(void) {return m_recvcnt;};
|
||||
const char *GetHostName(void) {return g_hostname;};
|
||||
const char *GetHost(void) {return m_host;};
|
||||
const char *GetPort(void) {return m_port;};
|
||||
|
||||
int GetFamily(void) {return m_family;};
|
||||
int GetProto(void) {return m_proto;};
|
||||
int GetSock(void) {return m_sock;};
|
||||
int GetSocket(void) {return m_sock;};
|
||||
int SockAddr( struct sockaddr_storage *sa ) {return SockAddr(m_sock,sa);};
|
||||
int SockName( char *buf, int max ) {return SockName(m_sock,buf,max); };
|
||||
|
||||
// virtual functions (must be overridden!)
|
||||
virtual int Client( const char *host, const char *port ) {return -1;};
|
||||
virtual int Server( const char *host, const char *port ) {return -1;};
|
||||
virtual void Closed(void) {;};
|
||||
|
||||
// exceptions
|
||||
class SocketException
|
||||
{
|
||||
char *toString(void) { return strerror(errno); };
|
||||
};
|
||||
|
||||
// static methods
|
||||
static int Bind( int sock, const struct sockaddr_storage *sa, socklen_t len );
|
||||
static int Recv( int sock, void *buf, int max );
|
||||
static int Send( int sock, const void *buf, int len );
|
||||
static int RecvFrom( int sock, void *buf, int n,
|
||||
struct sockaddr_storage *sa, socklen_t *len );
|
||||
static int SendTo( int sock, const void *buf, int len,
|
||||
const struct sockaddr_storage *sa, int salen );
|
||||
|
||||
static int Host2Addr(const char *host, const char *service,
|
||||
struct sockaddr_storage *sa, socklen_t *len);
|
||||
static const char *Host2Name( const struct sockaddr_storage *sa,
|
||||
char *buf, int max );
|
||||
static int Name2Host( const char *buf, struct sockaddr_storage *sa );
|
||||
static int SockAddr( int sock, struct sockaddr_storage *sa );
|
||||
static int SockName( int sock, char *buf, int max );
|
||||
|
||||
static int String2Mac( const char *str, unsigned char *mac );
|
||||
static int Mac2String( const unsigned char *mac, char *str );
|
||||
static int Interface2MacAddr( const char *name, unsigned char *mac );
|
||||
static int Service2Port( const char *service, int port, const char *proto );
|
||||
|
||||
// protected methods
|
||||
protected:
|
||||
void Copy( const Socket &sock );
|
||||
|
||||
// private methods
|
||||
private:
|
||||
};
|
||||
|
||||
#endif
|
||||
56
include/libnet++/TcpArchdaemon.h
Normal file
56
include/libnet++/TcpArchdaemon.h
Normal file
@ -0,0 +1,56 @@
|
||||
//
|
||||
// TCP Daemon
|
||||
//
|
||||
|
||||
/* prevent multiple inclusions */
|
||||
#ifndef __TcpArchdaemon__
|
||||
#define __TcpArchdaemon__
|
||||
|
||||
/* includes *****************************************************************/
|
||||
|
||||
#include "TcpDaemon.h"
|
||||
#include "TcpThread.h"
|
||||
|
||||
/* defines ******************************************************************/
|
||||
|
||||
/* macros *******************************************************************/
|
||||
|
||||
/* structs & typedefs *******************************************************/
|
||||
|
||||
/* c class definitions ******************************************************/
|
||||
|
||||
class TcpArchdaemon : public TcpDaemon {
|
||||
// public data
|
||||
public:
|
||||
|
||||
// protected data
|
||||
protected:
|
||||
|
||||
// private data
|
||||
private:
|
||||
|
||||
// static data
|
||||
|
||||
// public methods
|
||||
public:
|
||||
// constructors
|
||||
TcpArchdaemon();
|
||||
|
||||
// destructor
|
||||
virtual ~TcpArchdaemon();
|
||||
|
||||
// public methods
|
||||
int StartService(const char *n,const char *h,const char *p,int d=0,int c=0);
|
||||
int RunService(void);
|
||||
|
||||
// overidden methods
|
||||
int Listen( void *arg=NULL );
|
||||
virtual TcpThread *ClientThread( void **parg ) {return NULL;};
|
||||
|
||||
// static methods
|
||||
|
||||
// private methods
|
||||
private:
|
||||
};
|
||||
|
||||
#endif
|
||||
64
include/libnet++/TcpClient.h
Normal file
64
include/libnet++/TcpClient.h
Normal file
@ -0,0 +1,64 @@
|
||||
//
|
||||
// TCP Client
|
||||
//
|
||||
|
||||
/* prevent multiple inclusions */
|
||||
#ifndef __TcpClient__
|
||||
#define __TcpClient__
|
||||
|
||||
/* includes *****************************************************************/
|
||||
|
||||
#include "TcpSocket.h"
|
||||
#include "Client.h"
|
||||
|
||||
/* defines ******************************************************************/
|
||||
|
||||
/* macros *******************************************************************/
|
||||
|
||||
/* structs & typedefs *******************************************************/
|
||||
|
||||
/* c class definitions ******************************************************/
|
||||
|
||||
class TcpClient : public Client, public TcpSocket {
|
||||
// public data
|
||||
public:
|
||||
|
||||
// protected data
|
||||
protected:
|
||||
|
||||
// private data
|
||||
private:
|
||||
|
||||
// static data
|
||||
|
||||
// public methods
|
||||
public:
|
||||
// constructors
|
||||
TcpClient();
|
||||
TcpClient( const char *host, const char *service=NULL );
|
||||
|
||||
// destructor
|
||||
virtual ~TcpClient();
|
||||
|
||||
// public methods
|
||||
int ConnectUri( const char *uri );
|
||||
int Connect( const char *host, const char *service=NULL );
|
||||
int Reconnect(void) { Close();return Connect(GetHost(),GetPort()); };
|
||||
|
||||
// virtual functions
|
||||
|
||||
// exceptions
|
||||
class TcpClientException
|
||||
{
|
||||
char *toString(void) { return strerror(errno); };
|
||||
};
|
||||
|
||||
// static methods
|
||||
|
||||
// private methods
|
||||
void Init( void );
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
#endif
|
||||
52
include/libnet++/TcpDaemon.h
Normal file
52
include/libnet++/TcpDaemon.h
Normal file
@ -0,0 +1,52 @@
|
||||
//
|
||||
// TCP Daemon
|
||||
//
|
||||
|
||||
/* prevent multiple inclusions */
|
||||
#ifndef __TcpDaemon__
|
||||
#define __TcpDaemon__
|
||||
|
||||
/* includes *****************************************************************/
|
||||
|
||||
#include "Daemon.h"
|
||||
#include "TcpServer.h"
|
||||
|
||||
/* defines ******************************************************************/
|
||||
|
||||
/* macros *******************************************************************/
|
||||
|
||||
/* structs & typedefs *******************************************************/
|
||||
|
||||
/* c class definitions ******************************************************/
|
||||
|
||||
class TcpDaemon : public TcpServer, public Daemon {
|
||||
// public data
|
||||
public:
|
||||
|
||||
// protected data
|
||||
protected:
|
||||
|
||||
// private data
|
||||
private:
|
||||
|
||||
// static data
|
||||
|
||||
// public methods
|
||||
public:
|
||||
// constructors
|
||||
TcpDaemon();
|
||||
|
||||
// destructor
|
||||
virtual ~TcpDaemon();
|
||||
|
||||
// public methods
|
||||
int StartService(const char *n,const char *h,const char *p,int d=0,int c=0);
|
||||
int RunService(void);
|
||||
|
||||
// static methods
|
||||
|
||||
// private methods
|
||||
private:
|
||||
};
|
||||
|
||||
#endif
|
||||
81
include/libnet++/TcpServer.h
Normal file
81
include/libnet++/TcpServer.h
Normal file
@ -0,0 +1,81 @@
|
||||
//
|
||||
// TCP Server
|
||||
//
|
||||
|
||||
/* prevent multiple inclusions */
|
||||
#ifndef __TcpServer__
|
||||
#define __TcpServer__
|
||||
|
||||
/* includes *****************************************************************/
|
||||
|
||||
#include "TcpSocket.h"
|
||||
#include "Daemon.h"
|
||||
#include "Server.h"
|
||||
|
||||
/* defines ******************************************************************/
|
||||
|
||||
/* macros *******************************************************************/
|
||||
|
||||
/* structs & typedefs *******************************************************/
|
||||
|
||||
/* c class definitions ******************************************************/
|
||||
|
||||
class TcpServer : public Server, public TcpSocket {
|
||||
// public data
|
||||
public:
|
||||
|
||||
// protected data
|
||||
protected:
|
||||
// logfile
|
||||
|
||||
// private data
|
||||
private:
|
||||
// socket
|
||||
int m_clients;
|
||||
fd_set m_cfds; /* client sockets */
|
||||
|
||||
// static data
|
||||
|
||||
// public methods
|
||||
public:
|
||||
// constructors
|
||||
TcpServer();
|
||||
TcpServer( const char *host, const char *service );
|
||||
|
||||
// destructor
|
||||
virtual ~TcpServer();
|
||||
|
||||
// public methods
|
||||
int ServiceUri( const char *uri );
|
||||
int Service( const char *host, const char *service=NULL );
|
||||
int Listen( void );
|
||||
int Restart( void );
|
||||
int NumClients(void) {return m_clients;};
|
||||
|
||||
// virtual functions
|
||||
virtual int ServerTimeout(void) {return 0;};
|
||||
virtual int ServerSocket(void) {return 0;}; // other socket (not client)
|
||||
|
||||
virtual int ClientUp( int sock ) { return 1; };
|
||||
virtual void ClientDown( int sock ) {;};
|
||||
virtual int ClientSock( int sock ) {return 0;};
|
||||
virtual int ClientIn( int client, const char *buf, int n );
|
||||
virtual int ClientOut( int client, char *buf, int max );
|
||||
virtual void ClientCast( const char *buf, int len );
|
||||
|
||||
// exceptions
|
||||
class TcpServerException
|
||||
{
|
||||
char *toString(void) { return strerror(errno); };
|
||||
};
|
||||
|
||||
// static methods
|
||||
|
||||
// private methods
|
||||
void Init(void);
|
||||
|
||||
private:
|
||||
void ClientAdd(int sock);
|
||||
};
|
||||
|
||||
#endif
|
||||
69
include/libnet++/TcpSocket.h
Normal file
69
include/libnet++/TcpSocket.h
Normal file
@ -0,0 +1,69 @@
|
||||
//
|
||||
// Socket
|
||||
//
|
||||
|
||||
/* prevent multiple inclusions */
|
||||
#ifndef __TcpSocket__
|
||||
#define __TcpSocket__
|
||||
|
||||
/* includes *****************************************************************/
|
||||
|
||||
#include "Socket.h"
|
||||
|
||||
/* defines ******************************************************************/
|
||||
|
||||
/* macros *******************************************************************/
|
||||
|
||||
/* structs & typedefs *******************************************************/
|
||||
|
||||
/* c class definitions ******************************************************/
|
||||
|
||||
class TcpSocket : public Socket {
|
||||
// public data
|
||||
public:
|
||||
|
||||
protected:
|
||||
// socket
|
||||
|
||||
// stats
|
||||
|
||||
// private data
|
||||
private:
|
||||
|
||||
// static data
|
||||
|
||||
// public methods
|
||||
public:
|
||||
// constructors
|
||||
TcpSocket();
|
||||
|
||||
// destructor
|
||||
virtual ~TcpSocket();
|
||||
|
||||
// copy constructor
|
||||
TcpSocket( const TcpSocket &src ) {Copy(src);};
|
||||
const TcpSocket& operator=( const TcpSocket &src ) {this->Copy(src);return *this;};
|
||||
|
||||
// public methods
|
||||
int Client( const char *host, const char *port );
|
||||
int Server( const char *host, const char *port );
|
||||
int Accept( struct sockaddr_storage *sa );
|
||||
int SendStr( const char *str );
|
||||
|
||||
// control
|
||||
int Nagle( int flag ) {return Nagle(m_sock,flag);};
|
||||
|
||||
// status
|
||||
|
||||
// virtual functions
|
||||
|
||||
// exceptions
|
||||
|
||||
// static methods
|
||||
static int Nagle( int sock, int flag );
|
||||
|
||||
// private methods
|
||||
private:
|
||||
};
|
||||
|
||||
#endif
|
||||
60
include/libnet++/TcpThread.h
Normal file
60
include/libnet++/TcpThread.h
Normal file
@ -0,0 +1,60 @@
|
||||
//
|
||||
// TCP Thread
|
||||
//
|
||||
|
||||
/* prevent multiple inclusions */
|
||||
#ifndef __TcpThread__
|
||||
#define __TcpThread__
|
||||
|
||||
/* includes *****************************************************************/
|
||||
|
||||
#include "TcpClient.h"
|
||||
#include "Thread.h"
|
||||
|
||||
/* defines ******************************************************************/
|
||||
|
||||
/* macros *******************************************************************/
|
||||
|
||||
/* structs & typedefs *******************************************************/
|
||||
|
||||
/* c class definitions ******************************************************/
|
||||
|
||||
class TcpThread : public TcpClient, public Thread {
|
||||
// public data
|
||||
public:
|
||||
|
||||
// protected data
|
||||
protected:
|
||||
|
||||
// private data
|
||||
private:
|
||||
|
||||
// static data
|
||||
|
||||
// public methods
|
||||
public:
|
||||
// constructors
|
||||
TcpThread();
|
||||
|
||||
// destructor
|
||||
virtual ~TcpThread();
|
||||
|
||||
// public methods
|
||||
void SetSocket( int sock ) {Socket::SetSocket(sock);};
|
||||
int Detach(void) {return pthread_detach(pthread_self());};
|
||||
|
||||
// virtual functions
|
||||
virtual void *Run(void *);
|
||||
|
||||
// exceptions
|
||||
class TcpThreadException
|
||||
{
|
||||
char *toString(void) { return strerror(errno); };
|
||||
};
|
||||
|
||||
// static methods
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
#endif
|
||||
81
include/libnet++/Thread.h
Normal file
81
include/libnet++/Thread.h
Normal file
@ -0,0 +1,81 @@
|
||||
//
|
||||
// Linux Daemon
|
||||
//
|
||||
|
||||
/* prevent multiple inclusions */
|
||||
#ifndef __Thread__
|
||||
#define __Thread__
|
||||
|
||||
/* includes *****************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <errno.h>
|
||||
#include <memory.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
#include "netlib.h"
|
||||
|
||||
/* defines ******************************************************************/
|
||||
|
||||
/* macros *******************************************************************/
|
||||
|
||||
/* structs & typedefs *******************************************************/
|
||||
|
||||
/* c class definitions ******************************************************/
|
||||
|
||||
class Thread {
|
||||
// public data
|
||||
public:
|
||||
void *m_arg;
|
||||
|
||||
// protected data
|
||||
protected:
|
||||
pthread_t m_thread;
|
||||
pthread_attr_t m_attr;
|
||||
|
||||
// private data
|
||||
private:
|
||||
bool m_join;
|
||||
|
||||
// public methods
|
||||
public:
|
||||
// constructors
|
||||
Thread();
|
||||
|
||||
// destructor
|
||||
virtual ~Thread();
|
||||
|
||||
Thread( const Thread& );
|
||||
const Thread& operator=( const Thread& );
|
||||
|
||||
// public methods
|
||||
void Init(void);
|
||||
int Start( void *arg = NULL, bool detach = false );
|
||||
int Stop( void );
|
||||
int Join( void **pptr = NULL );
|
||||
|
||||
pthread_t GetTid(void) {return m_thread;};
|
||||
|
||||
// virtual functions
|
||||
virtual bool Prep(void);
|
||||
virtual void *Run(void *) = 0; // {return NULL;};
|
||||
|
||||
// exceptions
|
||||
class ThreadException
|
||||
{
|
||||
char *toString(void) { return strerror(errno); };
|
||||
};
|
||||
|
||||
// static methods to override
|
||||
|
||||
// private methods
|
||||
private:
|
||||
// signal catchers (do not override)
|
||||
};
|
||||
|
||||
#endif
|
||||
80
include/libnet++/Timer.h
Normal file
80
include/libnet++/Timer.h
Normal file
@ -0,0 +1,80 @@
|
||||
//
|
||||
// Linux Daemon
|
||||
//
|
||||
|
||||
/* prevent multiple inclusions */
|
||||
#ifndef __Timer__
|
||||
#define __Timer__
|
||||
|
||||
/* includes *****************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <signal.h>
|
||||
#include <time.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#include "netlib.h"
|
||||
|
||||
/* defines ******************************************************************/
|
||||
|
||||
/* macros *******************************************************************/
|
||||
|
||||
/* structs & typedefs *******************************************************/
|
||||
|
||||
/* c class definitions ******************************************************/
|
||||
|
||||
class Timer {
|
||||
// public data
|
||||
public:
|
||||
|
||||
// protected data
|
||||
protected:
|
||||
struct timespec m_timespec;
|
||||
bool m_running;
|
||||
|
||||
// private data
|
||||
private:
|
||||
|
||||
// public methods
|
||||
public:
|
||||
// constructors
|
||||
Timer();
|
||||
|
||||
// destructor
|
||||
virtual ~Timer();
|
||||
|
||||
// public methods
|
||||
|
||||
// virtual functions
|
||||
virtual int Restart(void);
|
||||
virtual int Start( unsigned long usec );
|
||||
virtual void Stop(void);
|
||||
virtual unsigned long Remaining(void);
|
||||
virtual int Wait(void);
|
||||
virtual int Sync(void); // Wait()+Restart()
|
||||
|
||||
// exceptions
|
||||
class TimerException
|
||||
{
|
||||
char *toString(void) { return strerror(errno); };
|
||||
};
|
||||
|
||||
// static methods
|
||||
static void Sleep( unsigned int sec ) { sleep(sec); };
|
||||
static void MilliSleep( unsigned long msec ) { msleep(msec); };
|
||||
static void MicroSleep( unsigned long usec ) { usleep(usec); };
|
||||
static void NanoSleep( unsigned long nsleep );
|
||||
|
||||
// private methods
|
||||
private:
|
||||
|
||||
// signal catchers (do not override)
|
||||
};
|
||||
|
||||
#endif
|
||||
56
include/libnet++/UdpArchdaemon.h
Normal file
56
include/libnet++/UdpArchdaemon.h
Normal file
@ -0,0 +1,56 @@
|
||||
//
|
||||
// TCP Daemon
|
||||
//
|
||||
|
||||
/* prevent multiple inclusions */
|
||||
#ifndef __UdpArchdaemon__
|
||||
#define __UdpArchdaemon__
|
||||
|
||||
/* includes *****************************************************************/
|
||||
|
||||
#include "UdpDaemon.h"
|
||||
#include "UdpThread.h"
|
||||
|
||||
/* defines ******************************************************************/
|
||||
|
||||
/* macros *******************************************************************/
|
||||
|
||||
/* structs & typedefs *******************************************************/
|
||||
|
||||
/* c class definitions ******************************************************/
|
||||
|
||||
class UdpArchdaemon : public UdpDaemon {
|
||||
// public data
|
||||
public:
|
||||
|
||||
// protected data
|
||||
protected:
|
||||
|
||||
// private data
|
||||
private:
|
||||
|
||||
// static data
|
||||
|
||||
// public methods
|
||||
public:
|
||||
// constructors
|
||||
UdpArchdaemon();
|
||||
|
||||
// destructor
|
||||
virtual ~UdpArchdaemon();
|
||||
|
||||
// public methods
|
||||
int StartService(const char *n,const char *h,const char *p,int d=0,int c=0);
|
||||
int RunService(void);
|
||||
|
||||
// overidden methods
|
||||
int Listen( void *arg=NULL );
|
||||
virtual UdpThread *ClientThread( void **parg ) {return NULL;};
|
||||
|
||||
// static methods
|
||||
|
||||
// private methods
|
||||
private:
|
||||
};
|
||||
|
||||
#endif
|
||||
65
include/libnet++/UdpCaster.h
Normal file
65
include/libnet++/UdpCaster.h
Normal file
@ -0,0 +1,65 @@
|
||||
//
|
||||
// UDP Caster
|
||||
//
|
||||
|
||||
/* prevent multiple inclusions */
|
||||
#ifndef __UdpCaster__
|
||||
#define __UdpCaster__
|
||||
|
||||
/* includes *****************************************************************/
|
||||
|
||||
#include "UdpSocket.h"
|
||||
|
||||
/* defines ******************************************************************/
|
||||
|
||||
/* macros *******************************************************************/
|
||||
|
||||
/* structs & typedefs *******************************************************/
|
||||
|
||||
/* c class definitions ******************************************************/
|
||||
|
||||
class UdpCaster : public UdpSocket {
|
||||
// public data
|
||||
public:
|
||||
|
||||
protected:
|
||||
|
||||
// private data
|
||||
private:
|
||||
|
||||
// static data
|
||||
|
||||
// public methods
|
||||
public:
|
||||
// constructors
|
||||
UdpCaster();
|
||||
UdpCaster( const char *host, const char *service );
|
||||
|
||||
// destructor
|
||||
virtual ~UdpCaster();
|
||||
|
||||
// public methods
|
||||
int BroadcasterUri( const char *uri );
|
||||
int Broadcaster( const char *host, const char *service=NULL );
|
||||
int CasterUri( const char *uri );
|
||||
int Caster( const char *host, const char *service=NULL );
|
||||
int Restart( void );
|
||||
|
||||
// virtual functions
|
||||
virtual int SendTo( const void *buf, int max );
|
||||
|
||||
// exceptions
|
||||
class UdpCasterException
|
||||
{
|
||||
char *toString(void) { return strerror(errno); };
|
||||
};
|
||||
|
||||
// static methods
|
||||
|
||||
// private methods
|
||||
void Init( void );
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
#endif
|
||||
63
include/libnet++/UdpClient.h
Normal file
63
include/libnet++/UdpClient.h
Normal file
@ -0,0 +1,63 @@
|
||||
//
|
||||
// TCP Client
|
||||
//
|
||||
|
||||
/* prevent multiple inclusions */
|
||||
#ifndef __UdpClient__
|
||||
#define __UdpClient__
|
||||
|
||||
/* includes *****************************************************************/
|
||||
|
||||
#include "UdpSocket.h"
|
||||
#include "Client.h"
|
||||
|
||||
/* defines ******************************************************************/
|
||||
|
||||
/* macros *******************************************************************/
|
||||
|
||||
/* structs & typedefs *******************************************************/
|
||||
|
||||
/* c class definitions ******************************************************/
|
||||
|
||||
class UdpClient : public Client, public UdpSocket {
|
||||
// public data
|
||||
public:
|
||||
|
||||
// protected data
|
||||
protected:
|
||||
|
||||
// private data
|
||||
private:
|
||||
|
||||
// static data
|
||||
|
||||
// public methods
|
||||
public:
|
||||
// constructors
|
||||
UdpClient();
|
||||
UdpClient( const char *host, const char *service );
|
||||
|
||||
// destructor
|
||||
virtual ~UdpClient();
|
||||
|
||||
// public methods
|
||||
int ConnectUri( const char *uri );
|
||||
int Connect( const char *host, const char *service=NULL );
|
||||
int Reconnect() { Close();return Connect(GetHost(),GetPort()); };
|
||||
int ListenUri( const char *uri );
|
||||
int Listen( const char *host, const char *port );
|
||||
|
||||
// virtual functions
|
||||
|
||||
// exceptions
|
||||
class UdpClientException
|
||||
{
|
||||
char *toString(void) { return strerror(errno); };
|
||||
};
|
||||
|
||||
// static methods
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
#endif
|
||||
52
include/libnet++/UdpDaemon.h
Normal file
52
include/libnet++/UdpDaemon.h
Normal file
@ -0,0 +1,52 @@
|
||||
//
|
||||
// TCP Daemon
|
||||
//
|
||||
|
||||
/* prevent multiple inclusions */
|
||||
#ifndef __UdpDaemon__
|
||||
#define __UdpDaemon__
|
||||
|
||||
/* includes *****************************************************************/
|
||||
|
||||
#include "Daemon.h"
|
||||
#include "UdpServer.h"
|
||||
|
||||
/* defines ******************************************************************/
|
||||
|
||||
/* macros *******************************************************************/
|
||||
|
||||
/* structs & typedefs *******************************************************/
|
||||
|
||||
/* c class definitions ******************************************************/
|
||||
|
||||
class UdpDaemon : public UdpServer, public Daemon {
|
||||
// public data
|
||||
public:
|
||||
|
||||
// protected data
|
||||
protected:
|
||||
|
||||
// private data
|
||||
private:
|
||||
|
||||
// static data
|
||||
|
||||
// public methods
|
||||
public:
|
||||
// constructors
|
||||
UdpDaemon();
|
||||
|
||||
// destructor
|
||||
virtual ~UdpDaemon();
|
||||
|
||||
// public methods
|
||||
int StartService(const char *n,const char *h,const char *p,int d=0,int c=0);
|
||||
int RunService(void);
|
||||
|
||||
// static methods
|
||||
|
||||
// private methods
|
||||
private:
|
||||
};
|
||||
|
||||
#endif
|
||||
65
include/libnet++/UdpServer.h
Normal file
65
include/libnet++/UdpServer.h
Normal file
@ -0,0 +1,65 @@
|
||||
//
|
||||
// TCP Server
|
||||
//
|
||||
|
||||
/* prevent multiple inclusions */
|
||||
#ifndef __UdpServer__
|
||||
#define __UdpServer__
|
||||
|
||||
/* includes *****************************************************************/
|
||||
|
||||
#include "UdpSocket.h"
|
||||
#include "Daemon.h"
|
||||
#include "Server.h"
|
||||
|
||||
/* defines ******************************************************************/
|
||||
|
||||
/* macros *******************************************************************/
|
||||
|
||||
/* structs & typedefs *******************************************************/
|
||||
|
||||
/* c class definitions ******************************************************/
|
||||
|
||||
class UdpServer : public Server, public UdpSocket {
|
||||
// public data
|
||||
public:
|
||||
|
||||
// protected data
|
||||
protected:
|
||||
|
||||
// private data
|
||||
private:
|
||||
|
||||
// static data
|
||||
|
||||
// public methods
|
||||
public:
|
||||
// constructors
|
||||
UdpServer();
|
||||
UdpServer( const char *host, const char *service );
|
||||
|
||||
// destructor
|
||||
virtual ~UdpServer();
|
||||
|
||||
// public methods
|
||||
int ServiceUri( const char *uri );
|
||||
int Service( const char *host, const char *service=NULL );
|
||||
int Listen( void );
|
||||
int Restart( void );
|
||||
|
||||
// virtual functions
|
||||
virtual int ClientSock( int sock ) {return 0;};
|
||||
virtual int ClientInOut( char *buf, int n, int max ) {return n;};
|
||||
|
||||
// exceptions
|
||||
class UdpServerException
|
||||
{
|
||||
char *toString(void) { return strerror(errno); };
|
||||
};
|
||||
|
||||
// static methods
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
#endif
|
||||
74
include/libnet++/UdpSocket.h
Normal file
74
include/libnet++/UdpSocket.h
Normal file
@ -0,0 +1,74 @@
|
||||
//
|
||||
// Socket
|
||||
//
|
||||
|
||||
/* prevent multiple inclusions */
|
||||
#ifndef __UdpSocket__
|
||||
#define __UdpSocket__
|
||||
|
||||
/* includes *****************************************************************/
|
||||
|
||||
#include "Socket.h"
|
||||
|
||||
/* defines ******************************************************************/
|
||||
|
||||
/* macros *******************************************************************/
|
||||
|
||||
/* structs & typedefs *******************************************************/
|
||||
|
||||
/* c class definitions ******************************************************/
|
||||
|
||||
class UdpSocket : public Socket {
|
||||
// public data
|
||||
public:
|
||||
|
||||
// protected data
|
||||
protected:
|
||||
struct sockaddr_storage sock_addr;
|
||||
socklen_t sock_len;
|
||||
|
||||
// private data
|
||||
private:
|
||||
|
||||
// static data
|
||||
|
||||
// public methods
|
||||
public:
|
||||
// constructors
|
||||
UdpSocket();
|
||||
|
||||
// destructor
|
||||
virtual ~UdpSocket();
|
||||
|
||||
// copy constructor
|
||||
UdpSocket( const UdpSocket &src ) ;
|
||||
const UdpSocket& operator=( const UdpSocket &src );
|
||||
|
||||
// public methods
|
||||
int Socket( const char *host, const char *port );
|
||||
int Client( const char *host, const char *port );
|
||||
int Server( const char *host, const char *port );
|
||||
int Broadcast( const char *host, const char *port,
|
||||
struct sockaddr_storage *sa, socklen_t *len );
|
||||
int Listener( const char *host, const char *port );
|
||||
int Multicast( const char *host, const char *port,
|
||||
struct sockaddr_storage *sa, socklen_t *len );
|
||||
|
||||
int RecvFrom( void *buf, int max );
|
||||
int SendTo( const void *buf, int len );
|
||||
|
||||
// control
|
||||
|
||||
// status
|
||||
|
||||
// virtual functions
|
||||
|
||||
// exceptions
|
||||
|
||||
// static methods
|
||||
|
||||
// private methods
|
||||
private:
|
||||
};
|
||||
|
||||
#endif
|
||||
59
include/libnet++/UdpThread.h
Normal file
59
include/libnet++/UdpThread.h
Normal file
@ -0,0 +1,59 @@
|
||||
//
|
||||
// UDP Thread
|
||||
//
|
||||
|
||||
/* prevent multiple inclusions */
|
||||
#ifndef __UdpThread__
|
||||
#define __UdpThread__
|
||||
|
||||
/* includes *****************************************************************/
|
||||
|
||||
#include "UdpClient.h"
|
||||
#include "Thread.h"
|
||||
|
||||
/* defines ******************************************************************/
|
||||
|
||||
/* macros *******************************************************************/
|
||||
|
||||
/* structs & typedefs *******************************************************/
|
||||
|
||||
/* c class definitions ******************************************************/
|
||||
|
||||
class UdpThread : public UdpClient, public Thread {
|
||||
// public data
|
||||
public:
|
||||
|
||||
// protected data
|
||||
protected:
|
||||
|
||||
// private data
|
||||
private:
|
||||
|
||||
// static data
|
||||
|
||||
// public methods
|
||||
public:
|
||||
// constructors
|
||||
UdpThread();
|
||||
|
||||
// destructor
|
||||
virtual ~UdpThread();
|
||||
|
||||
// public methods
|
||||
void SetSocket( int sock ) {Socket::SetSocket(sock);};
|
||||
|
||||
// virtual functions
|
||||
virtual void *Run(void *);
|
||||
|
||||
// exceptions
|
||||
class UdpThreadException
|
||||
{
|
||||
char *toString(void) { return strerror(errno); };
|
||||
};
|
||||
|
||||
// static methods
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
#endif
|
||||
59
include/libnet++/UdsClient.h
Normal file
59
include/libnet++/UdsClient.h
Normal file
@ -0,0 +1,59 @@
|
||||
//
|
||||
// TCP Client
|
||||
//
|
||||
|
||||
/* prevent multiple inclusions */
|
||||
#ifndef __UdsClient__
|
||||
#define __UdsClient__
|
||||
|
||||
/* includes *****************************************************************/
|
||||
|
||||
#include "UdsSocket.h"
|
||||
#include "Client.h"
|
||||
|
||||
/* defines ******************************************************************/
|
||||
|
||||
/* macros *******************************************************************/
|
||||
|
||||
/* structs & typedefs *******************************************************/
|
||||
|
||||
/* c class definitions ******************************************************/
|
||||
|
||||
class UdsClient : public Client, public UdsSocket {
|
||||
// public data
|
||||
public:
|
||||
|
||||
// protected data
|
||||
protected:
|
||||
|
||||
// private data
|
||||
private:
|
||||
|
||||
// static data
|
||||
|
||||
// public methods
|
||||
public:
|
||||
// constructors
|
||||
UdsClient();
|
||||
UdsClient( const char *file );
|
||||
|
||||
// destructor
|
||||
virtual ~UdsClient();
|
||||
|
||||
// public methods
|
||||
int Connect( const char *file );
|
||||
|
||||
// virtual functions
|
||||
|
||||
// exceptions
|
||||
class UdsClientException
|
||||
{
|
||||
char *toString(void) { return strerror(errno); };
|
||||
};
|
||||
|
||||
// static methods
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
#endif
|
||||
52
include/libnet++/UdsDaemon.h
Normal file
52
include/libnet++/UdsDaemon.h
Normal file
@ -0,0 +1,52 @@
|
||||
//
|
||||
// TCP Daemon
|
||||
//
|
||||
|
||||
/* prevent multiple inclusions */
|
||||
#ifndef __UdsDaemon__
|
||||
#define __UdsDaemon__
|
||||
|
||||
/* includes *****************************************************************/
|
||||
|
||||
#include "Daemon.h"
|
||||
#include "UdsServer.h"
|
||||
|
||||
/* defines ******************************************************************/
|
||||
|
||||
/* macros *******************************************************************/
|
||||
|
||||
/* structs & typedefs *******************************************************/
|
||||
|
||||
/* c class definitions ******************************************************/
|
||||
|
||||
class UdsDaemon : public UdsServer, public Daemon {
|
||||
// public data
|
||||
public:
|
||||
|
||||
// protected data
|
||||
protected:
|
||||
|
||||
// private data
|
||||
private:
|
||||
|
||||
// static data
|
||||
|
||||
// public methods
|
||||
public:
|
||||
// constructors
|
||||
UdsDaemon();
|
||||
|
||||
// destructor
|
||||
virtual ~UdsDaemon();
|
||||
|
||||
// public methods
|
||||
int StartService(const char *f,int d=0,int c=0);
|
||||
int RunService(void);
|
||||
|
||||
// static methods
|
||||
|
||||
// private methods
|
||||
private:
|
||||
};
|
||||
|
||||
#endif
|
||||
64
include/libnet++/UdsServer.h
Normal file
64
include/libnet++/UdsServer.h
Normal file
@ -0,0 +1,64 @@
|
||||
//
|
||||
// TCP Server
|
||||
//
|
||||
|
||||
/* prevent multiple inclusions */
|
||||
#ifndef __UdsServer__
|
||||
#define __UdsServer__
|
||||
|
||||
/* includes *****************************************************************/
|
||||
|
||||
#include "UdsSocket.h"
|
||||
#include "Daemon.h"
|
||||
#include "Server.h"
|
||||
|
||||
/* defines ******************************************************************/
|
||||
|
||||
/* macros *******************************************************************/
|
||||
|
||||
/* structs & typedefs *******************************************************/
|
||||
|
||||
/* c class definitions ******************************************************/
|
||||
|
||||
class UdsServer : public Server, public UdsSocket {
|
||||
// public data
|
||||
public:
|
||||
|
||||
// protected data
|
||||
protected:
|
||||
|
||||
// private data
|
||||
private:
|
||||
|
||||
// static data
|
||||
|
||||
// public methods
|
||||
public:
|
||||
// constructors
|
||||
UdsServer();
|
||||
UdsServer( const char *file );
|
||||
|
||||
// destructor
|
||||
virtual ~UdsServer();
|
||||
|
||||
// public methods
|
||||
int Service( const char *file );
|
||||
int Listen( void );
|
||||
int Restart( void );
|
||||
|
||||
// virtual functions
|
||||
virtual int ClientSock( int sock ) {return 0;};
|
||||
virtual int ClientInOut( char *buf, int n, int max ) {return n;};
|
||||
|
||||
// exceptions
|
||||
class UdsServerException
|
||||
{
|
||||
char *toString(void) { return strerror(errno); };
|
||||
};
|
||||
|
||||
// static methods
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
#endif
|
||||
70
include/libnet++/UdsSocket.h
Normal file
70
include/libnet++/UdsSocket.h
Normal file
@ -0,0 +1,70 @@
|
||||
//
|
||||
// Socket
|
||||
//
|
||||
|
||||
/* prevent multiple inclusions */
|
||||
#ifndef __UdsSocket__
|
||||
#define __UdsSocket__
|
||||
|
||||
/* includes *****************************************************************/
|
||||
|
||||
#include "Socket.h"
|
||||
#include <sys/un.h>
|
||||
|
||||
/* defines ******************************************************************/
|
||||
|
||||
#define MAX_UDS_CLIENTS 10
|
||||
|
||||
/* macros *******************************************************************/
|
||||
|
||||
/* structs & typedefs *******************************************************/
|
||||
|
||||
/* c class definitions ******************************************************/
|
||||
|
||||
class UdsSocket : public Socket {
|
||||
// public data
|
||||
public:
|
||||
|
||||
// protected data
|
||||
protected:
|
||||
char m_file[1024];
|
||||
struct sockaddr_storage sock_addr;
|
||||
socklen_t sock_len;
|
||||
|
||||
// private data
|
||||
private:
|
||||
|
||||
// static data
|
||||
|
||||
// public methods
|
||||
public:
|
||||
// constructors
|
||||
UdsSocket();
|
||||
|
||||
// destructor
|
||||
virtual ~UdsSocket();
|
||||
|
||||
// copy constructor
|
||||
UdsSocket( const UdsSocket &src ) ;
|
||||
const UdsSocket& operator=( const UdsSocket &src );
|
||||
|
||||
// public methods
|
||||
int Socket( const char *file );
|
||||
int Client( const char *file );
|
||||
int Server( const char *file );
|
||||
|
||||
// control
|
||||
|
||||
// status
|
||||
|
||||
// virtual functions
|
||||
|
||||
// exceptions
|
||||
|
||||
// static methods
|
||||
|
||||
// private methods
|
||||
private:
|
||||
};
|
||||
|
||||
#endif
|
||||
59
include/libnet++/UdsThread.h
Normal file
59
include/libnet++/UdsThread.h
Normal file
@ -0,0 +1,59 @@
|
||||
//
|
||||
// UDP Thread
|
||||
//
|
||||
|
||||
/* prevent multiple inclusions */
|
||||
#ifndef __UdsThread__
|
||||
#define __UdsThread__
|
||||
|
||||
/* includes *****************************************************************/
|
||||
|
||||
#include "UdsClient.h"
|
||||
#include "Thread.h"
|
||||
|
||||
/* defines ******************************************************************/
|
||||
|
||||
/* macros *******************************************************************/
|
||||
|
||||
/* structs & typedefs *******************************************************/
|
||||
|
||||
/* c class definitions ******************************************************/
|
||||
|
||||
class UdsThread : public UdsClient, public Thread {
|
||||
// public data
|
||||
public:
|
||||
|
||||
// protected data
|
||||
protected:
|
||||
|
||||
// private data
|
||||
private:
|
||||
|
||||
// static data
|
||||
|
||||
// public methods
|
||||
public:
|
||||
// constructors
|
||||
UdsThread();
|
||||
|
||||
// destructor
|
||||
virtual ~UdsThread();
|
||||
|
||||
// public methods
|
||||
void SetSocket( int sock ) {Socket::SetSocket(sock);};
|
||||
|
||||
// virtual functions
|
||||
virtual void *Run(void *);
|
||||
|
||||
// exceptions
|
||||
class UdsThreadException
|
||||
{
|
||||
char *toString(void) { return strerror(errno); };
|
||||
};
|
||||
|
||||
// static methods
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
#endif
|
||||
91
include/libnet++/UriParse.h
Normal file
91
include/libnet++/UriParse.h
Normal file
@ -0,0 +1,91 @@
|
||||
//
|
||||
// URI Parser
|
||||
// Neal Probert
|
||||
//
|
||||
|
||||
/* prevent multiple inclusions */
|
||||
#ifndef __UriParse__
|
||||
#define __UriParse__
|
||||
|
||||
/* includes *****************************************************************/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "QueryString.h"
|
||||
|
||||
/* defines ******************************************************************/
|
||||
|
||||
/* macros *******************************************************************/
|
||||
|
||||
/* structs & typedefs *******************************************************/
|
||||
|
||||
/* c class definitions ******************************************************/
|
||||
|
||||
//
|
||||
// Chop up the URI into it's component parts
|
||||
//
|
||||
class UriParse {
|
||||
// public data
|
||||
public:
|
||||
std::string Proto;
|
||||
std::string User;
|
||||
std::string Pass;
|
||||
std::string Host;
|
||||
std::string Port;
|
||||
std::string Path;
|
||||
std::vector<QueryString> Queries;
|
||||
|
||||
// private data
|
||||
private:
|
||||
int Rate;
|
||||
|
||||
// static data
|
||||
|
||||
// public methods
|
||||
public:
|
||||
// constructors
|
||||
UriParse();
|
||||
UriParse( const char *uri );
|
||||
|
||||
// destructor
|
||||
virtual ~UriParse();
|
||||
|
||||
// access methods
|
||||
int setUri( const char *uri ); // parse
|
||||
int getUri( char *buf, int size );
|
||||
|
||||
void setProto( const char *s ) { Proto = s; };
|
||||
void setUser( const char *s ) { User = s; };
|
||||
void setPassword( const char *s ) { Pass = s; };
|
||||
void setHost( const char *s ) { Host = s; };
|
||||
void setService( const char *s ){ Port = s; };
|
||||
void setPort( int p ) { Port = p; };
|
||||
void setPath( const char *s ) { Path = s; };
|
||||
void setRate( int r ) { Rate = r; };
|
||||
|
||||
const char *getProto(void) { return Proto.c_str(); };
|
||||
const char *getUser(void) { return User.c_str(); };
|
||||
const char *getPassword(void) { return Pass.c_str(); };
|
||||
const char *getHost(void) { return Host.c_str(); };
|
||||
const char *getService(void) { return Port.c_str(); };
|
||||
int getPort(void);
|
||||
const char *getPath(void) { return Path.c_str(); };
|
||||
int getRate(void) { return Rate; };
|
||||
|
||||
void setQuery( const char *name, const char *value );
|
||||
const char *getQuery( const char *name );
|
||||
|
||||
// static methods
|
||||
|
||||
// private methods
|
||||
private:
|
||||
void Init(void);
|
||||
int Parse( const char *uri );
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user