fix doxygen and put everything besides main function in namespace ebusd

This commit is contained in:
john30
2017-02-25 16:12:09 +01:00
parent d365cb1f9c
commit ca164185dc
31 changed files with 212 additions and 99 deletions
+1
View File
@@ -31,6 +31,7 @@ using std::hex;
using std::setfill; using std::setfill;
using std::setw; using std::setw;
// the string used for answering to a scan request (07h 04h) // the string used for answering to a scan request (07h 04h)
#define SCAN_ANSWER ("ebusd.eu;" PACKAGE_NAME ";" SCAN_VERSION ";100") #define SCAN_ANSWER ("ebusd.eu;" PACKAGE_NAME ";" SCAN_VERSION ";100")
+3 -3
View File
@@ -33,7 +33,9 @@
#include "lib/utils/queue.h" #include "lib/utils/queue.h"
#include "lib/utils/thread.h" #include "lib/utils/thread.h"
/** @file bushandler.h namespace ebusd {
/** @file ebusd/bushandler.h
* Classes, functions, and constants related to handling of symbols on the eBUS. * Classes, functions, and constants related to handling of symbols on the eBUS.
* *
* The following table shows the possible states, symbols, and state transition * The following table shows the possible states, symbols, and state transition
@@ -41,8 +43,6 @@
* @image html states.png "ebusd BusHandler states" * @image html states.png "ebusd BusHandler states"
*/ */
namespace ebusd {
using std::string; using std::string;
/** the default time [us] for retrieving a symbol from an addressed slave. */ /** the default time [us] for retrieving a symbol from an addressed slave. */
+3 -3
View File
@@ -26,14 +26,14 @@
#include "ebusd/bushandler.h" #include "ebusd/bushandler.h"
#include "lib/ebus/message.h" #include "lib/ebus/message.h"
/** @file datahandler.h namespace ebusd {
/** @file ebusd/datahandler.h
* Classes and functions for implementing and registering generic data sinks * Classes and functions for implementing and registering generic data sinks
* and sources that allow listening to received data updates and sending on * and sources that allow listening to received data updates and sending on
* the bus. * the bus.
*/ */
namespace ebusd {
using std::list; using std::list;
using std::map; using std::map;
+8 -5
View File
@@ -1038,9 +1038,6 @@ result_t loadScanConfigFile(MessageMap* messages, unsigned char address, SymbolS
return RESULT_OK; return RESULT_OK;
} }
} // namespace ebusd
using namespace ebusd;
/** the version string of the program. */ /** the version string of the program. */
const char *argp_program_version = "" PACKAGE_STRING "." REVISION ""; const char *argp_program_version = "" PACKAGE_STRING "." REVISION "";
@@ -1049,10 +1046,10 @@ const char *argp_program_version = "" PACKAGE_STRING "." REVISION "";
const char *argp_program_bug_address = "" PACKAGE_BUGREPORT ""; const char *argp_program_bug_address = "" PACKAGE_BUGREPORT "";
/** /**
* Main method. * Main function.
*
* @param argc the number of command line arguments. * @param argc the number of command line arguments.
* @param argv the command line arguments. * @param argv the command line arguments.
* @return the exit code.
*/ */
int main(int argc, char* argv[]) { int main(int argc, char* argv[]) {
struct argp aargp = { argpoptions, parse_opt, NULL, argpdoc, datahandler_getargs(), NULL, NULL }; struct argp aargp = { argpoptions, parse_opt, NULL, argpdoc, datahandler_getargs(), NULL, NULL };
@@ -1153,3 +1150,9 @@ int main(int argc, char* argv[]) {
shutdown(); shutdown();
return 0; return 0;
} }
} // namespace ebusd
int main(int argc, char* argv[]) {
return ebusd::main(argc, argv);
}
+3 -3
View File
@@ -26,12 +26,12 @@
#include "lib/ebus/result.h" #include "lib/ebus/result.h"
#include "lib/utils/log.h" #include "lib/utils/log.h"
/** \file main.h namespace ebusd {
/** \file ebusd/main.h
* The main entry method doing all the startup handling. * The main entry method doing all the startup handling.
*/ */
namespace ebusd {
/** A structure holding all program options. */ /** A structure holding all program options. */
struct options { struct options {
const char* device; //!< eBUS device (serial device or [udp:]ip:port) [/dev/ttyUSB0] const char* device; //!< eBUS device (serial device or [udp:]ip:port) [/dev/ttyUSB0]
+3 -3
View File
@@ -31,12 +31,12 @@
#include "lib/ebus/message.h" #include "lib/ebus/message.h"
#include "lib/utils/rotatefile.h" #include "lib/utils/rotatefile.h"
/** \file mainloop.h namespace ebusd {
/** \file ebusd/mainloop.h
* The main loop for the TCP client interface and regular tasks such as resolving scanned data. * The main loop for the TCP client interface and regular tasks such as resolving scanned data.
*/ */
namespace ebusd {
/** /**
* Helper class for user authentication. * Helper class for user authentication.
*/ */
+3 -3
View File
@@ -27,12 +27,12 @@
#include "ebusd/bushandler.h" #include "ebusd/bushandler.h"
#include "lib/ebus/message.h" #include "lib/ebus/message.h"
/** @file mqtthandler.h namespace ebusd {
/** @file ebusd/mqtthandler.h
* A data handler enabling MQTT support via mosquitto. * A data handler enabling MQTT support via mosquitto.
*/ */
namespace ebusd {
using std::map; using std::map;
using std::string; using std::string;
using std::vector; using std::vector;
+3 -3
View File
@@ -28,12 +28,12 @@
#include "lib/utils/notify.h" #include "lib/utils/notify.h"
#include "lib/utils/thread.h" #include "lib/utils/thread.h"
/** \file network.h namespace ebusd {
/** \file ebusd/network.h
* The TCP and HTTP client request handling. * The TCP and HTTP client request handling.
*/ */
namespace ebusd {
/** Forward declaration for @a Connection. */ /** Forward declaration for @a Connection. */
class Connection; class Connection;
+3 -3
View File
@@ -19,13 +19,13 @@
#ifndef LIB_EBUS_CONTRIB_CONTRIB_H_ #ifndef LIB_EBUS_CONTRIB_CONTRIB_H_
#define LIB_EBUS_CONTRIB_CONTRIB_H_ #define LIB_EBUS_CONTRIB_CONTRIB_H_
/** @file contrib.h namespace ebusd {
/** @file lib/ebus/contrib/contrib.h
* Contributed sources that may be excluded from regular builds. * Contributed sources that may be excluded from regular builds.
* configure switch: --without-contrib * configure switch: --without-contrib
*/ */
namespace ebusd {
/** /**
* Registration function that is called once during initialization. * Registration function that is called once during initialization.
* @return true if registration was successful. * @return true if registration was successful.
+4 -4
View File
@@ -30,12 +30,12 @@
#include "lib/ebus/result.h" #include "lib/ebus/result.h"
#include "lib/ebus/datatype.h" #include "lib/ebus/datatype.h"
/** @file tem.h
* Contributed data types for TEM devices not part of regular releases.
*/
namespace ebusd { namespace ebusd {
/** @file lib/ebus/contrib/tem.h
* Contributed data types for TEM devices not necessarily part of regular releases.
*/
/** /**
* A special variant of @a NumberDataType for TEM/Dungs ParamID in master/slave * A special variant of @a NumberDataType for TEM/Dungs ParamID in master/slave
* data. * data.
+3 -3
View File
@@ -30,7 +30,9 @@
#include "lib/ebus/filereader.h" #include "lib/ebus/filereader.h"
#include "lib/ebus/datatype.h" #include "lib/ebus/datatype.h"
/** @file data.h namespace ebusd {
/** @file lib/ebus/data.h
* Classes related to defining fields based on data types in symbols on the * Classes related to defining fields based on data types in symbols on the
* eBUS. * eBUS.
* *
@@ -46,8 +48,6 @@
* class. * class.
*/ */
namespace ebusd {
class DataFieldTemplates; class DataFieldTemplates;
class SingleDataField; class SingleDataField;
+55 -24
View File
@@ -31,7 +31,9 @@
#include "lib/ebus/result.h" #include "lib/ebus/result.h"
#include "lib/ebus/filereader.h" #include "lib/ebus/filereader.h"
/** @file datatype.h namespace ebusd {
/** @file lib/ebus/datatype.h
* Classes, functions, and constants related to decoding/encoding of symbols * Classes, functions, and constants related to decoding/encoding of symbols
* on the eBUS to/from readable values and registry of data types. * on the eBUS to/from readable values and registry of data types.
* *
@@ -47,8 +49,6 @@
* an @a istringstream to a @a SymbolString (see @a DataType#writeSymbols()). * an @a istringstream to a @a SymbolString (see @a DataType#writeSymbols()).
*/ */
namespace ebusd {
using std::map; using std::map;
using std::list; using std::list;
@@ -80,12 +80,20 @@ using std::list;
/** the type for data output format options. */ /** the type for data output format options. */
typedef int OutputFormat; typedef int OutputFormat;
/* the bit flags for @a OutputFormat. */ /** bit flag for @a OutputFormat: include names. */
static const unsigned int OF_NAMES = 0x01; //!< include names. #define OF_NAMES 0x01
static const unsigned int OF_UNITS = 0x02; //!< include units.
static const unsigned int OF_COMMENTS = 0x04; //!< include comments. /** bit flag for @a OutputFormat: include units. */
static const unsigned int OF_NUMERIC = 0x08; //!< numeric format (keep numeric value of value=name pairs). #define OF_UNITS 0x02
static const unsigned int OF_JSON = 0x10; //!< JSON format.
/** bit flag for @a OutputFormat: include comments. */
#define OF_COMMENTS 0x04
/** bit flag for @a OutputFormat: numeric format (keep numeric value of value=name pairs). */
#define OF_NUMERIC 0x08
/** bit flag for @a OutputFormat: JSON format. */
#define OF_JSON 0x10
/** the message part in which a data field is stored. */ /** the message part in which a data field is stored. */
enum PartType { enum PartType {
@@ -94,21 +102,44 @@ enum PartType {
pt_slaveData, //!< stored in slave data pt_slaveData, //!< stored in slave data
}; };
/* flags for @a DataType. */ /** bit flag for @a DataType: adjustable length, bitCount is maximum length. */
static const unsigned int ADJ = 0x01; //!< adjustable length, bitCount is maximum length #define ADJ 0x01
static const unsigned int BCD = 0x02; //!< binary representation is BCD
static const unsigned int REV = 0x04; //!< reverted binary representation (most significant byte first) /** bit flag for @a DataType: binary representation is BCD. */
static const unsigned int SIG = 0x08; //!< signed value #define BCD 0x02
static const unsigned int IGN = 0x10; //!< ignore value during read and write
static const unsigned int FIX = 0x20; //!< fixed width formatting /** bit flag for @a DataType: reverted binary representation (most significant byte first). */
static const unsigned int REQ = 0x40; //!< value may not be NULL #define REV 0x04
/** binary representation is hex converted to decimal and interpreted as 2 digits (also requires #BCD). */
static const unsigned int HCD = 0x80; /** bit flag for @a DataType: signed value. */
static const unsigned int EXP = 0x100; //!< exponential numeric representation #define SIG 0x08
static const unsigned int DAY = 0x200; //!< forced value list defaulting to week days
static const unsigned int NUM = 0x400; //!< numeric type with base class @a NumberDataType /** bit flag for @a DataType: ignore value during read and write. */
static const unsigned int SPE = 0x800; //!< special marker for certain types #define IGN 0x10
static const unsigned int CON = 0x1000; //!< marker for a constant value
/** bit flag for @a DataType: fixed width formatting. */
#define FIX 0x20
/** bit flag for @a DataType: value may not be NULL. */
#define REQ 0x40
/** bit flag for @a DataType: binary representation is hex converted to decimal and interpreted as 2 digits (also requires #BCD). */
#define HCD 0x80
/** bit flag for @a DataType: exponential numeric representation. */
#define EXP 0x100
/** bit flag for @a DataType: forced value list defaulting to week days. */
#define DAY 0x200
/** bit flag for @a DataType: numeric type with base class @a NumberDataType. */
#define NUM 0x400
/** bit flag for @a DataType: special marker for certain types. */
#define SPE 0x800
/** bit flag for @a DataType: marker for a constant value. */
#define CON 0x1000
/** /**
+3 -3
View File
@@ -27,7 +27,9 @@
#include <fstream> #include <fstream>
#include "lib/ebus/result.h" #include "lib/ebus/result.h"
/** @file device.h namespace ebusd {
/** @file lib/ebus/device.h
* Classes providing access to the eBUS. * Classes providing access to the eBUS.
* *
* A @a Device is either a @a SerialDevice directly connected to a local tty * A @a Device is either a @a SerialDevice directly connected to a local tty
@@ -36,8 +38,6 @@
* to a file and/or forwarding it to a logging function. * to a file and/or forwarding it to a logging function.
*/ */
namespace ebusd {
/** /**
* Interface for listening to data received on/sent to a device. * Interface for listening to data received on/sent to a device.
*/ */
+3 -3
View File
@@ -29,7 +29,9 @@
#include "lib/ebus/symbol.h" #include "lib/ebus/symbol.h"
#include "lib/ebus/result.h" #include "lib/ebus/result.h"
/** @file filereader.h namespace ebusd {
/** @file lib/ebus/filereader.h
* Helper class and constants for reading configuration files. * Helper class and constants for reading configuration files.
* *
* The @a FileReader template class allows to read CSV compliant text files * The @a FileReader template class allows to read CSV compliant text files
@@ -39,8 +41,6 @@
* with a "*" symbol. * with a "*" symbol.
*/ */
namespace ebusd {
using std::string; using std::string;
using std::ostream; using std::ostream;
using std::ostringstream; using std::ostringstream;
+3 -3
View File
@@ -30,7 +30,9 @@
#include "lib/ebus/result.h" #include "lib/ebus/result.h"
#include "lib/ebus/symbol.h" #include "lib/ebus/symbol.h"
/** @file message.h namespace ebusd {
/** @file lib/ebus/message.h
* Classes and functions for decoding and encoding of complete messages on the * Classes and functions for decoding and encoding of complete messages on the
* eBUS to and from readable values. * eBUS to and from readable values.
* *
@@ -57,8 +59,6 @@
* template class. * template class.
*/ */
namespace ebusd {
using std::binary_function; using std::binary_function;
using std::priority_queue; using std::priority_queue;
using std::deque; using std::deque;
+4 -4
View File
@@ -19,16 +19,16 @@
#ifndef LIB_EBUS_RESULT_H_ #ifndef LIB_EBUS_RESULT_H_
#define LIB_EBUS_RESULT_H_ #define LIB_EBUS_RESULT_H_
/** @file result.h namespace ebusd {
/** @file lib/ebus/result.h
* Functions, and constants related to execution results. * Functions, and constants related to execution results.
* *
* The #result_t codes defined here are used by many functions to emit the * The @a result_t codes defined here are used by many functions to emit the
* result of the function call. Zero and positive values indicate success, * result of the function call. Zero and positive values indicate success,
* whereas negative values indicate failure. * whereas negative values indicate failure.
*/ */
namespace ebusd {
/** type for result code. */ /** type for result code. */
enum result_t { enum result_t {
RESULT_OK = 0, //!< success RESULT_OK = 0, //!< success
+12 -8
View File
@@ -27,7 +27,9 @@
#include <vector> #include <vector>
#include "lib/ebus/result.h" #include "lib/ebus/result.h"
/** @file symbol.h namespace ebusd {
/** @file lib/ebus/symbol.h
* Classes, functions, and constants related to symbols on the eBUS. * Classes, functions, and constants related to symbols on the eBUS.
* *
* The @a SymbolString class is used for escaping or unescaping a sequence of * The @a SymbolString class is used for escaping or unescaping a sequence of
@@ -63,17 +65,19 @@
* non-acknowledge, the receiving slave has to repeat its data once. * non-acknowledge, the receiving slave has to repeat its data once.
*/ */
namespace ebusd {
using std::string; using std::string;
using std::vector; using std::vector;
/** escape symbol, either followed by 0x00 for the value 0xA9, or 0x01 for the value 0xAA. */ /** escape symbol, either followed by 0x00 for the value 0xA9, or 0x01 for the value 0xAA. */
static const unsigned char ESC = 0xA9; #define ESC 0xA9
static const unsigned char SYN = 0xAA; //!< synchronization symbol /** synchronization symbol. */
static const unsigned char ACK = 0x00; //!< positive acknowledge #define SYN 0xAA
static const unsigned char NAK = 0xFF; //!< negative acknowledge /** positive acknowledge symbol. */
static const unsigned char BROADCAST = 0xFE; //!< the broadcast destination address #define ACK 0x00
/** negative acknowledge symbol. */
#define NAK 0xFF
/** the broadcast destination address. */
#define BROADCAST 0xFE
/** /**
+4
View File
@@ -22,6 +22,8 @@
# include <mach/mach.h> # include <mach/mach.h>
#endif #endif
namespace ebusd {
#ifdef __MACH__ #ifdef __MACH__
static bool clockInitialized = false; static bool clockInitialized = false;
static clock_serv_t clockServ; static clock_serv_t clockServ;
@@ -41,3 +43,5 @@ void clockGettime(struct timespec* t) {
clock_gettime(CLOCK_REALTIME, t); clock_gettime(CLOCK_REALTIME, t);
#endif #endif
} }
} // namespace ebusd
+5 -1
View File
@@ -21,7 +21,9 @@
#include <time.h> #include <time.h>
/** \file clock.h */ namespace ebusd {
/** \file lib/utils/clock.h */
/** /**
* Get the real time system clock. * Get the real time system clock.
@@ -29,4 +31,6 @@
*/ */
void clockGettime(struct timespec* t); void clockGettime(struct timespec* t);
} // namespace ebusd
#endif // LIB_UTILS_CLOCK_H_ #endif // LIB_UTILS_CLOCK_H_
+4
View File
@@ -25,6 +25,8 @@
#include <string.h> #include <string.h>
#include "lib/utils/clock.h" #include "lib/utils/clock.h"
namespace ebusd {
/** the name of each @a LogFacility. */ /** the name of each @a LogFacility. */
static const char *facilityNames[] = { static const char *facilityNames[] = {
"main", "main",
@@ -182,3 +184,5 @@ void logWrite(const char* facility, const LogLevel level, const char* message, .
logWrite(facility, levelNames[level], message, ap); logWrite(facility, levelNames[level], message, ap);
va_end(ap); va_end(ap);
} }
} // namespace ebusd
+6 -2
View File
@@ -19,7 +19,9 @@
#ifndef LIB_UTILS_LOG_H_ #ifndef LIB_UTILS_LOG_H_
#define LIB_UTILS_LOG_H_ #define LIB_UTILS_LOG_H_
/** \file log.h */ namespace ebusd {
/** \file lib/utils/log.h */
/** the available log facilities. */ /** the available log facilities. */
enum LogFacility { enum LogFacility {
@@ -60,7 +62,7 @@ int parseLogFacilities(const char* facilities);
/** /**
* Get the log facility as string. * Get the log facility as string.
* @param level the @a LogFacility. * @param facility the @a LogFacility.
* @return the log facility as string. * @return the log facility as string.
*/ */
const char* getLogFacilityStr(LogFacility facility); const char* getLogFacilityStr(LogFacility facility);
@@ -163,4 +165,6 @@ void logWrite(const char* facility, const LogLevel level, const char* message, .
#define logOtherDebug(facility, ...) \ #define logOtherDebug(facility, ...) \
(needsLog(lf_other, ll_debug) ? logWrite(facility, ll_debug, __VA_ARGS__) : void(0)) (needsLog(lf_other, ll_debug) ? logWrite(facility, ll_debug, __VA_ARGS__) : void(0))
} // namespace ebusd
#endif // LIB_UTILS_LOG_H_ #endif // LIB_UTILS_LOG_H_
+5 -3
View File
@@ -22,7 +22,9 @@
#include <unistd.h> #include <unistd.h>
#include <fcntl.h> #include <fcntl.h>
/** \file notify.h */ namespace ebusd {
/** \file lib/utils/notify.h */
/** /**
* class to notify other thread per pipe. * class to notify other thread per pipe.
@@ -69,6 +71,6 @@ class Notify {
int m_sendfd; int m_sendfd;
}; };
} // namespace ebusd
#endif // LIB_UTILS_NOTIFY_H_ #endif // LIB_UTILS_NOTIFY_H_
+5 -1
View File
@@ -24,7 +24,9 @@
#include <list> #include <list>
#include "lib/utils/clock.h" #include "lib/utils/clock.h"
/** \file queue.h */ namespace ebusd {
/** \file lib/utils/queue.h */
using std::list; using std::list;
@@ -152,4 +154,6 @@ class Queue {
pthread_cond_t m_cond; pthread_cond_t m_cond;
}; };
} // namespace ebusd
#endif // LIB_UTILS_QUEUE_H_ #endif // LIB_UTILS_QUEUE_H_
+4
View File
@@ -27,6 +27,8 @@
#include <string> #include <string>
#include "lib/utils/clock.h" #include "lib/utils/clock.h"
namespace ebusd {
using std::streamsize; using std::streamsize;
RotateFile::~RotateFile() { RotateFile::~RotateFile() {
@@ -86,3 +88,5 @@ void RotateFile::write(unsigned char* value, unsigned int size, bool received) {
} }
} }
} }
} // namespace ebusd
+5 -2
View File
@@ -25,7 +25,9 @@
#include <fstream> #include <fstream>
#include <string> #include <string>
/** @file rotatefile.h namespace ebusd {
/** \file lib/utils/rotatefile.h
* Helpers for writing to rotating files. * Helpers for writing to rotating files.
*/ */
@@ -92,5 +94,6 @@ class RotateFile {
uint64_t m_fileSize; uint64_t m_fileSize;
}; };
#endif // LIB_UTILS_ROTATEFILE_H_ } // namespace ebusd
#endif // LIB_UTILS_ROTATEFILE_H_
+7 -4
View File
@@ -23,7 +23,9 @@
#include <string.h> #include <string.h>
#include <cstdlib> #include <cstdlib>
TCPSocket::TCPSocket(int sfd, struct sockaddr_in* address) : m_sfd(sfd) { namespace ebusd {
TCPSocket::TCPSocket(int sfd, socketaddress* address) : m_sfd(sfd) {
char ip[17]; char ip[17];
inet_ntop(AF_INET, (struct in_addr*)&(address->sin_addr.s_addr), ip, (socklen_t)sizeof(ip)-1); inet_ntop(AF_INET, (struct in_addr*)&(address->sin_addr.s_addr), ip, (socklen_t)sizeof(ip)-1);
m_ip = ip; m_ip = ip;
@@ -36,7 +38,7 @@ bool TCPSocket::isValid() {
TCPSocket* TCPClient::connect(const string& server, const uint16_t& port) { TCPSocket* TCPClient::connect(const string& server, const uint16_t& port) {
struct sockaddr_in address; socketaddress address;
int ret; int ret;
memset(reinterpret_cast<char*>(&address), 0, sizeof(address)); memset(reinterpret_cast<char*>(&address), 0, sizeof(address));
@@ -76,7 +78,7 @@ int TCPServer::start() {
return 0; return 0;
} }
m_lfd = socket(AF_INET, SOCK_STREAM, 0); m_lfd = socket(AF_INET, SOCK_STREAM, 0);
struct sockaddr_in address; socketaddress address;
memset(&address, 0, sizeof(address)); memset(&address, 0, sizeof(address));
@@ -107,7 +109,7 @@ TCPSocket* TCPServer::newSocket() {
if (!m_listening) { if (!m_listening) {
return NULL; return NULL;
} }
struct sockaddr_in address; socketaddress address;
socklen_t len = sizeof(address); socklen_t len = sizeof(address);
memset(&address, 0, sizeof(address)); memset(&address, 0, sizeof(address));
@@ -119,3 +121,4 @@ TCPSocket* TCPServer::newSocket() {
return new TCPSocket(sfd, &address); return new TCPSocket(sfd, &address);
} }
} // namespace ebusd
+12 -6
View File
@@ -24,7 +24,12 @@
#include <stdint.h> #include <stdint.h>
#include <string> #include <string>
/** \file tcpsocket.h */ /** typedef for referencing @a sockaddr_in within namespace. */
typedef struct sockaddr_in socketaddress;
namespace ebusd {
/** \file lib/utils/tcpsocket.h */
using std::string; using std::string;
@@ -35,7 +40,7 @@ using std::string;
#endif #endif
/** /**
* class for low level tcp socket operations. (open, close, send, receive). * Class for low level tcp socket operations. (open, close, send, receive).
*/ */
class TCPSocket { class TCPSocket {
public: public:
@@ -99,14 +104,14 @@ class TCPSocket {
uint16_t m_port; uint16_t m_port;
/** ip address of tcp socket */ /** ip address of tcp socket */
string m_ip; string m_ip;
/** /**
* private constructor, limited access only for friend classes. * private constructor, limited access only for friend classes.
* @param sfd the file desctriptor of tcp socket. * @param sfd the file descriptor of tcp socket.
* @param address struct which holds the ip address. * @param address struct which holds the ip address.
*/ */
TCPSocket(int sfd, struct sockaddr_in* address); TCPSocket(int sfd, socketaddress* address);
}; };
/** /**
@@ -174,5 +179,6 @@ class TCPServer {
bool m_listening; bool m_listening;
}; };
#endif // LIB_UTILS_TCPSOCKET_H_ } // namespace ebusd
#endif // LIB_UTILS_TCPSOCKET_H_
+4
View File
@@ -23,6 +23,8 @@
#include "lib/utils/thread.h" #include "lib/utils/thread.h"
#include "lib/utils/clock.h" #include "lib/utils/clock.h"
namespace ebusd {
void* Thread::runThread(void* arg) { void* Thread::runThread(void* arg) {
reinterpret_cast<Thread*>(arg)->enter(); reinterpret_cast<Thread*>(arg)->enter();
return NULL; return NULL;
@@ -102,3 +104,5 @@ bool WaitThread::Wait(int seconds) {
pthread_mutex_unlock(&m_mutex); pthread_mutex_unlock(&m_mutex);
return isRunning(); return isRunning();
} }
} // namespace ebusd
+5 -1
View File
@@ -21,7 +21,9 @@
#include <pthread.h> #include <pthread.h>
/** \file thread.h */ namespace ebusd {
/** \file lib/utils/thread.h */
/** /**
* wrapper class for pthread. * wrapper class for pthread.
@@ -140,4 +142,6 @@ class WaitThread : public Thread {
pthread_cond_t m_cond; pthread_cond_t m_cond;
}; };
} // namespace ebusd
#endif // LIB_UTILS_THREAD_H_ #endif // LIB_UTILS_THREAD_H_
+16 -1
View File
@@ -32,9 +32,12 @@
#include <string> #include <string>
#include "lib/utils/tcpsocket.h" #include "lib/utils/tcpsocket.h"
namespace ebusd {
using std::ostringstream; using std::ostringstream;
using std::cin; using std::cin;
using std::cout; using std::cout;
using std::string;
using std::endl; using std::endl;
/** A structure holding all program options. */ /** A structure holding all program options. */
@@ -117,7 +120,7 @@ error_t parse_opt(int key, char *arg, struct argp_state *state) {
return 0; return 0;
} }
string fetchData(TCPSocket* socket, bool& listening) { string fetchData(ebusd::TCPSocket* socket, bool& listening) {
char data[1024]; char data[1024];
ssize_t datalen; ssize_t datalen;
ostringstream ostream; ostringstream ostream;
@@ -289,6 +292,13 @@ void connect(const char* host, uint16_t port, char* const *args, int argCount) {
delete client; delete client;
} }
/**
* Main function.
* @param argc the number of command line arguments.
* @param argv the command line arguments.
* @return the exit code.
*/
int main(int argc, char* argv[]) { int main(int argc, char* argv[]) {
struct argp argp = { argpoptions, parse_opt, argpargsdoc, argpdoc, NULL, NULL, NULL }; struct argp argp = { argpoptions, parse_opt, argpargsdoc, argpdoc, NULL, NULL, NULL };
setenv("ARGP_HELP_FMT", "no-dup-args-note", 0); setenv("ARGP_HELP_FMT", "no-dup-args-note", 0);
@@ -300,3 +310,8 @@ int main(int argc, char* argv[]) {
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
} }
} // namespace ebusd
int main(int argc, char* argv[]) {
return ebusd::main(argc, argv);
}
+13
View File
@@ -30,6 +30,8 @@
#include "lib/ebus/device.h" #include "lib/ebus/device.h"
#include "lib/ebus/result.h" #include "lib/ebus/result.h"
namespace ebusd {
using std::hex; using std::hex;
using std::fstream; using std::fstream;
using std::cout; using std::cout;
@@ -130,6 +132,12 @@ error_t parse_opt(int key, char *arg, struct argp_state *state) {
} }
/**
* Main function.
* @param argc the number of command line arguments.
* @param argv the command line arguments.
* @return the exit code.
*/
int main(int argc, char* argv[]) { int main(int argc, char* argv[]) {
struct argp argp = { argpoptions, parse_opt, argpargsdoc, argpdoc, NULL, NULL, NULL }; struct argp argp = { argpoptions, parse_opt, argpargsdoc, argpdoc, NULL, NULL, NULL };
setenv("ARGP_HELP_FMT", "no-dup-args-note", 0); setenv("ARGP_HELP_FMT", "no-dup-args-note", 0);
@@ -171,3 +179,8 @@ int main(int argc, char* argv[]) {
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
} }
} // namespace ebusd
int main(int argc, char* argv[]) {
return ebusd::main(argc, argv);
}