From ca164185dc0f6a266c17e3b5b4fe69c63226c087 Mon Sep 17 00:00:00 2001 From: john30 Date: Sat, 25 Feb 2017 16:12:09 +0100 Subject: [PATCH] fix doxygen and put everything besides main function in namespace ebusd --- src/ebusd/bushandler.cpp | 1 + src/ebusd/bushandler.h | 6 +-- src/ebusd/datahandler.h | 6 +-- src/ebusd/main.cpp | 13 +++--- src/ebusd/main.h | 6 +-- src/ebusd/mainloop.h | 6 +-- src/ebusd/mqtthandler.h | 6 +-- src/ebusd/network.h | 6 +-- src/lib/ebus/contrib/contrib.h | 6 +-- src/lib/ebus/contrib/tem.h | 8 ++-- src/lib/ebus/data.h | 6 +-- src/lib/ebus/datatype.h | 79 +++++++++++++++++++++++----------- src/lib/ebus/device.h | 6 +-- src/lib/ebus/filereader.h | 6 +-- src/lib/ebus/message.h | 6 +-- src/lib/ebus/result.h | 8 ++-- src/lib/ebus/symbol.h | 20 +++++---- src/lib/utils/clock.cpp | 4 ++ src/lib/utils/clock.h | 6 ++- src/lib/utils/log.cpp | 4 ++ src/lib/utils/log.h | 8 +++- src/lib/utils/notify.h | 8 ++-- src/lib/utils/queue.h | 6 ++- src/lib/utils/rotatefile.cpp | 4 ++ src/lib/utils/rotatefile.h | 7 ++- src/lib/utils/tcpsocket.cpp | 11 +++-- src/lib/utils/tcpsocket.h | 18 +++++--- src/lib/utils/thread.cpp | 4 ++ src/lib/utils/thread.h | 6 ++- src/tools/ebusctl.cpp | 17 +++++++- src/tools/ebusfeed.cpp | 13 ++++++ 31 files changed, 212 insertions(+), 99 deletions(-) diff --git a/src/ebusd/bushandler.cpp b/src/ebusd/bushandler.cpp index be045da2..3d972038 100644 --- a/src/ebusd/bushandler.cpp +++ b/src/ebusd/bushandler.cpp @@ -31,6 +31,7 @@ using std::hex; using std::setfill; using std::setw; + // the string used for answering to a scan request (07h 04h) #define SCAN_ANSWER ("ebusd.eu;" PACKAGE_NAME ";" SCAN_VERSION ";100") diff --git a/src/ebusd/bushandler.h b/src/ebusd/bushandler.h index 353a0b72..95944c45 100644 --- a/src/ebusd/bushandler.h +++ b/src/ebusd/bushandler.h @@ -33,7 +33,9 @@ #include "lib/utils/queue.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. * * The following table shows the possible states, symbols, and state transition @@ -41,8 +43,6 @@ * @image html states.png "ebusd BusHandler states" */ -namespace ebusd { - using std::string; /** the default time [us] for retrieving a symbol from an addressed slave. */ diff --git a/src/ebusd/datahandler.h b/src/ebusd/datahandler.h index 1967a835..97597d2c 100644 --- a/src/ebusd/datahandler.h +++ b/src/ebusd/datahandler.h @@ -26,14 +26,14 @@ #include "ebusd/bushandler.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 * and sources that allow listening to received data updates and sending on * the bus. */ -namespace ebusd { - using std::list; using std::map; diff --git a/src/ebusd/main.cpp b/src/ebusd/main.cpp index 951786e8..8b742c89 100644 --- a/src/ebusd/main.cpp +++ b/src/ebusd/main.cpp @@ -1038,9 +1038,6 @@ result_t loadScanConfigFile(MessageMap* messages, unsigned char address, SymbolS return RESULT_OK; } -} // namespace ebusd - -using namespace ebusd; /** the version string of the program. */ 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 ""; /** - * Main method. - * + * 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[]) { struct argp aargp = { argpoptions, parse_opt, NULL, argpdoc, datahandler_getargs(), NULL, NULL }; @@ -1153,3 +1150,9 @@ int main(int argc, char* argv[]) { shutdown(); return 0; } + +} // namespace ebusd + +int main(int argc, char* argv[]) { + return ebusd::main(argc, argv); +} diff --git a/src/ebusd/main.h b/src/ebusd/main.h index 4bed3bec..a8d519aa 100644 --- a/src/ebusd/main.h +++ b/src/ebusd/main.h @@ -26,12 +26,12 @@ #include "lib/ebus/result.h" #include "lib/utils/log.h" -/** \file main.h +namespace ebusd { + +/** \file ebusd/main.h * The main entry method doing all the startup handling. */ -namespace ebusd { - /** A structure holding all program options. */ struct options { const char* device; //!< eBUS device (serial device or [udp:]ip:port) [/dev/ttyUSB0] diff --git a/src/ebusd/mainloop.h b/src/ebusd/mainloop.h index e6d0f581..af7d897f 100644 --- a/src/ebusd/mainloop.h +++ b/src/ebusd/mainloop.h @@ -31,12 +31,12 @@ #include "lib/ebus/message.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. */ -namespace ebusd { - /** * Helper class for user authentication. */ diff --git a/src/ebusd/mqtthandler.h b/src/ebusd/mqtthandler.h index c66514ce..7e9ce314 100644 --- a/src/ebusd/mqtthandler.h +++ b/src/ebusd/mqtthandler.h @@ -27,12 +27,12 @@ #include "ebusd/bushandler.h" #include "lib/ebus/message.h" -/** @file mqtthandler.h +namespace ebusd { + +/** @file ebusd/mqtthandler.h * A data handler enabling MQTT support via mosquitto. */ -namespace ebusd { - using std::map; using std::string; using std::vector; diff --git a/src/ebusd/network.h b/src/ebusd/network.h index d32c284a..a70ececb 100644 --- a/src/ebusd/network.h +++ b/src/ebusd/network.h @@ -28,12 +28,12 @@ #include "lib/utils/notify.h" #include "lib/utils/thread.h" -/** \file network.h +namespace ebusd { + +/** \file ebusd/network.h * The TCP and HTTP client request handling. */ -namespace ebusd { - /** Forward declaration for @a Connection. */ class Connection; diff --git a/src/lib/ebus/contrib/contrib.h b/src/lib/ebus/contrib/contrib.h index dee4aebd..a9e9159c 100644 --- a/src/lib/ebus/contrib/contrib.h +++ b/src/lib/ebus/contrib/contrib.h @@ -19,13 +19,13 @@ #ifndef 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. * configure switch: --without-contrib */ -namespace ebusd { - /** * Registration function that is called once during initialization. * @return true if registration was successful. diff --git a/src/lib/ebus/contrib/tem.h b/src/lib/ebus/contrib/tem.h index f7a72a99..9d69fbab 100644 --- a/src/lib/ebus/contrib/tem.h +++ b/src/lib/ebus/contrib/tem.h @@ -30,12 +30,12 @@ #include "lib/ebus/result.h" #include "lib/ebus/datatype.h" -/** @file tem.h - * Contributed data types for TEM devices not part of regular releases. - */ - 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 * data. diff --git a/src/lib/ebus/data.h b/src/lib/ebus/data.h index c4021a55..ac94dbc6 100644 --- a/src/lib/ebus/data.h +++ b/src/lib/ebus/data.h @@ -30,7 +30,9 @@ #include "lib/ebus/filereader.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 * eBUS. * @@ -46,8 +48,6 @@ * class. */ -namespace ebusd { - class DataFieldTemplates; class SingleDataField; diff --git a/src/lib/ebus/datatype.h b/src/lib/ebus/datatype.h index 6db9319b..658d51c6 100644 --- a/src/lib/ebus/datatype.h +++ b/src/lib/ebus/datatype.h @@ -31,7 +31,9 @@ #include "lib/ebus/result.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 * 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()). */ -namespace ebusd { - using std::map; using std::list; @@ -80,12 +80,20 @@ using std::list; /** the type for data output format options. */ typedef int OutputFormat; -/* the bit flags for @a OutputFormat. */ -static const unsigned int OF_NAMES = 0x01; //!< include names. -static const unsigned int OF_UNITS = 0x02; //!< include units. -static const unsigned int OF_COMMENTS = 0x04; //!< include comments. -static const unsigned int OF_NUMERIC = 0x08; //!< numeric format (keep numeric value of value=name pairs). -static const unsigned int OF_JSON = 0x10; //!< JSON format. +/** bit flag for @a OutputFormat: include names. */ +#define OF_NAMES 0x01 + +/** bit flag for @a OutputFormat: include units. */ +#define OF_UNITS 0x02 + +/** 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. */ enum PartType { @@ -94,21 +102,44 @@ enum PartType { pt_slaveData, //!< stored in slave data }; -/* flags for @a DataType. */ -static const unsigned int ADJ = 0x01; //!< adjustable length, bitCount is maximum length -static const unsigned int BCD = 0x02; //!< binary representation is BCD -static const unsigned int REV = 0x04; //!< reverted binary representation (most significant byte first) -static const unsigned int SIG = 0x08; //!< signed value -static const unsigned int IGN = 0x10; //!< ignore value during read and write -static const unsigned int FIX = 0x20; //!< fixed width formatting -static const unsigned int REQ = 0x40; //!< value may not be NULL -/** binary representation is hex converted to decimal and interpreted as 2 digits (also requires #BCD). */ -static const unsigned int HCD = 0x80; -static const unsigned int EXP = 0x100; //!< exponential numeric representation -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 -static const unsigned int SPE = 0x800; //!< special marker for certain types -static const unsigned int CON = 0x1000; //!< marker for a constant value +/** bit flag for @a DataType: adjustable length, bitCount is maximum length. */ +#define ADJ 0x01 + +/** bit flag for @a DataType: binary representation is BCD. */ +#define BCD 0x02 + +/** bit flag for @a DataType: reverted binary representation (most significant byte first). */ +#define REV 0x04 + +/** bit flag for @a DataType: signed value. */ +#define SIG 0x08 + +/** bit flag for @a DataType: ignore value during read and write. */ +#define IGN 0x10 + +/** 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 /** diff --git a/src/lib/ebus/device.h b/src/lib/ebus/device.h index 429bc4dd..eb80c708 100644 --- a/src/lib/ebus/device.h +++ b/src/lib/ebus/device.h @@ -27,7 +27,9 @@ #include #include "lib/ebus/result.h" -/** @file device.h +namespace ebusd { + +/** @file lib/ebus/device.h * Classes providing access to the eBUS. * * 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. */ -namespace ebusd { - /** * Interface for listening to data received on/sent to a device. */ diff --git a/src/lib/ebus/filereader.h b/src/lib/ebus/filereader.h index 6f4fc8e5..69d18925 100644 --- a/src/lib/ebus/filereader.h +++ b/src/lib/ebus/filereader.h @@ -29,7 +29,9 @@ #include "lib/ebus/symbol.h" #include "lib/ebus/result.h" -/** @file filereader.h +namespace ebusd { + +/** @file lib/ebus/filereader.h * Helper class and constants for reading configuration files. * * The @a FileReader template class allows to read CSV compliant text files @@ -39,8 +41,6 @@ * with a "*" symbol. */ -namespace ebusd { - using std::string; using std::ostream; using std::ostringstream; diff --git a/src/lib/ebus/message.h b/src/lib/ebus/message.h index 6a43edff..297fd5f3 100644 --- a/src/lib/ebus/message.h +++ b/src/lib/ebus/message.h @@ -30,7 +30,9 @@ #include "lib/ebus/result.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 * eBUS to and from readable values. * @@ -57,8 +59,6 @@ * template class. */ -namespace ebusd { - using std::binary_function; using std::priority_queue; using std::deque; diff --git a/src/lib/ebus/result.h b/src/lib/ebus/result.h index de15b2a8..c28041ed 100644 --- a/src/lib/ebus/result.h +++ b/src/lib/ebus/result.h @@ -19,16 +19,16 @@ #ifndef 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. * - * 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, * whereas negative values indicate failure. */ -namespace ebusd { - /** type for result code. */ enum result_t { RESULT_OK = 0, //!< success diff --git a/src/lib/ebus/symbol.h b/src/lib/ebus/symbol.h index ed5415ab..ecb39162 100644 --- a/src/lib/ebus/symbol.h +++ b/src/lib/ebus/symbol.h @@ -27,7 +27,9 @@ #include #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. * * 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. */ -namespace ebusd { - using std::string; using std::vector; /** escape symbol, either followed by 0x00 for the value 0xA9, or 0x01 for the value 0xAA. */ -static const unsigned char ESC = 0xA9; -static const unsigned char SYN = 0xAA; //!< synchronization symbol -static const unsigned char ACK = 0x00; //!< positive acknowledge -static const unsigned char NAK = 0xFF; //!< negative acknowledge -static const unsigned char BROADCAST = 0xFE; //!< the broadcast destination address +#define ESC 0xA9 +/** synchronization symbol. */ +#define SYN 0xAA +/** positive acknowledge symbol. */ +#define ACK 0x00 +/** negative acknowledge symbol. */ +#define NAK 0xFF +/** the broadcast destination address. */ +#define BROADCAST 0xFE /** diff --git a/src/lib/utils/clock.cpp b/src/lib/utils/clock.cpp index 15001dfe..6ca9f9eb 100644 --- a/src/lib/utils/clock.cpp +++ b/src/lib/utils/clock.cpp @@ -22,6 +22,8 @@ # include #endif +namespace ebusd { + #ifdef __MACH__ static bool clockInitialized = false; static clock_serv_t clockServ; @@ -41,3 +43,5 @@ void clockGettime(struct timespec* t) { clock_gettime(CLOCK_REALTIME, t); #endif } + +} // namespace ebusd diff --git a/src/lib/utils/clock.h b/src/lib/utils/clock.h index 7b5c7925..9761648f 100644 --- a/src/lib/utils/clock.h +++ b/src/lib/utils/clock.h @@ -21,7 +21,9 @@ #include -/** \file clock.h */ +namespace ebusd { + +/** \file lib/utils/clock.h */ /** * Get the real time system clock. @@ -29,4 +31,6 @@ */ void clockGettime(struct timespec* t); +} // namespace ebusd + #endif // LIB_UTILS_CLOCK_H_ diff --git a/src/lib/utils/log.cpp b/src/lib/utils/log.cpp index 5f852a10..0829f210 100644 --- a/src/lib/utils/log.cpp +++ b/src/lib/utils/log.cpp @@ -25,6 +25,8 @@ #include #include "lib/utils/clock.h" +namespace ebusd { + /** the name of each @a LogFacility. */ static const char *facilityNames[] = { "main", @@ -182,3 +184,5 @@ void logWrite(const char* facility, const LogLevel level, const char* message, . logWrite(facility, levelNames[level], message, ap); va_end(ap); } + +} // namespace ebusd diff --git a/src/lib/utils/log.h b/src/lib/utils/log.h index 4baf46a4..eaadd3f9 100644 --- a/src/lib/utils/log.h +++ b/src/lib/utils/log.h @@ -19,7 +19,9 @@ #ifndef LIB_UTILS_LOG_H_ #define LIB_UTILS_LOG_H_ -/** \file log.h */ +namespace ebusd { + +/** \file lib/utils/log.h */ /** the available log facilities. */ enum LogFacility { @@ -60,7 +62,7 @@ int parseLogFacilities(const char* facilities); /** * Get the log facility as string. - * @param level the @a LogFacility. + * @param facility the @a LogFacility. * @return the log facility as string. */ const char* getLogFacilityStr(LogFacility facility); @@ -163,4 +165,6 @@ void logWrite(const char* facility, const LogLevel level, const char* message, . #define logOtherDebug(facility, ...) \ (needsLog(lf_other, ll_debug) ? logWrite(facility, ll_debug, __VA_ARGS__) : void(0)) +} // namespace ebusd + #endif // LIB_UTILS_LOG_H_ diff --git a/src/lib/utils/notify.h b/src/lib/utils/notify.h index 1211a045..be7c0703 100644 --- a/src/lib/utils/notify.h +++ b/src/lib/utils/notify.h @@ -22,7 +22,9 @@ #include #include -/** \file notify.h */ +namespace ebusd { + +/** \file lib/utils/notify.h */ /** * class to notify other thread per pipe. @@ -69,6 +71,6 @@ class Notify { int m_sendfd; }; +} // namespace ebusd + #endif // LIB_UTILS_NOTIFY_H_ - - diff --git a/src/lib/utils/queue.h b/src/lib/utils/queue.h index f5a926e2..6181d602 100644 --- a/src/lib/utils/queue.h +++ b/src/lib/utils/queue.h @@ -24,7 +24,9 @@ #include #include "lib/utils/clock.h" -/** \file queue.h */ +namespace ebusd { + +/** \file lib/utils/queue.h */ using std::list; @@ -152,4 +154,6 @@ class Queue { pthread_cond_t m_cond; }; +} // namespace ebusd + #endif // LIB_UTILS_QUEUE_H_ diff --git a/src/lib/utils/rotatefile.cpp b/src/lib/utils/rotatefile.cpp index 15c47847..57f58882 100644 --- a/src/lib/utils/rotatefile.cpp +++ b/src/lib/utils/rotatefile.cpp @@ -27,6 +27,8 @@ #include #include "lib/utils/clock.h" +namespace ebusd { + using std::streamsize; RotateFile::~RotateFile() { @@ -86,3 +88,5 @@ void RotateFile::write(unsigned char* value, unsigned int size, bool received) { } } } + +} // namespace ebusd diff --git a/src/lib/utils/rotatefile.h b/src/lib/utils/rotatefile.h index 0b78918a..57236f6c 100644 --- a/src/lib/utils/rotatefile.h +++ b/src/lib/utils/rotatefile.h @@ -25,7 +25,9 @@ #include #include -/** @file rotatefile.h +namespace ebusd { + +/** \file lib/utils/rotatefile.h * Helpers for writing to rotating files. */ @@ -92,5 +94,6 @@ class RotateFile { uint64_t m_fileSize; }; -#endif // LIB_UTILS_ROTATEFILE_H_ +} // namespace ebusd +#endif // LIB_UTILS_ROTATEFILE_H_ diff --git a/src/lib/utils/tcpsocket.cpp b/src/lib/utils/tcpsocket.cpp index 43b18e38..4e3c5a9c 100644 --- a/src/lib/utils/tcpsocket.cpp +++ b/src/lib/utils/tcpsocket.cpp @@ -23,7 +23,9 @@ #include #include -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]; inet_ntop(AF_INET, (struct in_addr*)&(address->sin_addr.s_addr), ip, (socklen_t)sizeof(ip)-1); m_ip = ip; @@ -36,7 +38,7 @@ bool TCPSocket::isValid() { TCPSocket* TCPClient::connect(const string& server, const uint16_t& port) { - struct sockaddr_in address; + socketaddress address; int ret; memset(reinterpret_cast(&address), 0, sizeof(address)); @@ -76,7 +78,7 @@ int TCPServer::start() { return 0; } m_lfd = socket(AF_INET, SOCK_STREAM, 0); - struct sockaddr_in address; + socketaddress address; memset(&address, 0, sizeof(address)); @@ -107,7 +109,7 @@ TCPSocket* TCPServer::newSocket() { if (!m_listening) { return NULL; } - struct sockaddr_in address; + socketaddress address; socklen_t len = sizeof(address); memset(&address, 0, sizeof(address)); @@ -119,3 +121,4 @@ TCPSocket* TCPServer::newSocket() { return new TCPSocket(sfd, &address); } +} // namespace ebusd diff --git a/src/lib/utils/tcpsocket.h b/src/lib/utils/tcpsocket.h index 46fce6c7..6b8f3263 100644 --- a/src/lib/utils/tcpsocket.h +++ b/src/lib/utils/tcpsocket.h @@ -24,7 +24,12 @@ #include #include -/** \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; @@ -35,7 +40,7 @@ using std::string; #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 { public: @@ -99,14 +104,14 @@ class TCPSocket { uint16_t m_port; /** ip address of tcp socket */ - string m_ip; + string m_ip; /** * 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. */ - TCPSocket(int sfd, struct sockaddr_in* address); + TCPSocket(int sfd, socketaddress* address); }; /** @@ -174,5 +179,6 @@ class TCPServer { bool m_listening; }; -#endif // LIB_UTILS_TCPSOCKET_H_ +} // namespace ebusd +#endif // LIB_UTILS_TCPSOCKET_H_ diff --git a/src/lib/utils/thread.cpp b/src/lib/utils/thread.cpp index 0a2f73f9..bc428d8c 100644 --- a/src/lib/utils/thread.cpp +++ b/src/lib/utils/thread.cpp @@ -23,6 +23,8 @@ #include "lib/utils/thread.h" #include "lib/utils/clock.h" +namespace ebusd { + void* Thread::runThread(void* arg) { reinterpret_cast(arg)->enter(); return NULL; @@ -102,3 +104,5 @@ bool WaitThread::Wait(int seconds) { pthread_mutex_unlock(&m_mutex); return isRunning(); } + +} // namespace ebusd diff --git a/src/lib/utils/thread.h b/src/lib/utils/thread.h index 459347bf..9b860d62 100644 --- a/src/lib/utils/thread.h +++ b/src/lib/utils/thread.h @@ -21,7 +21,9 @@ #include -/** \file thread.h */ +namespace ebusd { + +/** \file lib/utils/thread.h */ /** * wrapper class for pthread. @@ -140,4 +142,6 @@ class WaitThread : public Thread { pthread_cond_t m_cond; }; +} // namespace ebusd + #endif // LIB_UTILS_THREAD_H_ diff --git a/src/tools/ebusctl.cpp b/src/tools/ebusctl.cpp index 570afef1..bce14be9 100644 --- a/src/tools/ebusctl.cpp +++ b/src/tools/ebusctl.cpp @@ -32,9 +32,12 @@ #include #include "lib/utils/tcpsocket.h" +namespace ebusd { + using std::ostringstream; using std::cin; using std::cout; +using std::string; using std::endl; /** A structure holding all program options. */ @@ -117,7 +120,7 @@ error_t parse_opt(int key, char *arg, struct argp_state *state) { return 0; } -string fetchData(TCPSocket* socket, bool& listening) { +string fetchData(ebusd::TCPSocket* socket, bool& listening) { char data[1024]; ssize_t datalen; ostringstream ostream; @@ -289,6 +292,13 @@ void connect(const char* host, uint16_t port, char* const *args, int argCount) { 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[]) { struct argp argp = { argpoptions, parse_opt, argpargsdoc, argpdoc, NULL, NULL, NULL }; setenv("ARGP_HELP_FMT", "no-dup-args-note", 0); @@ -300,3 +310,8 @@ int main(int argc, char* argv[]) { exit(EXIT_SUCCESS); } +} // namespace ebusd + +int main(int argc, char* argv[]) { + return ebusd::main(argc, argv); +} diff --git a/src/tools/ebusfeed.cpp b/src/tools/ebusfeed.cpp index 3132d420..c0212906 100644 --- a/src/tools/ebusfeed.cpp +++ b/src/tools/ebusfeed.cpp @@ -30,6 +30,8 @@ #include "lib/ebus/device.h" #include "lib/ebus/result.h" +namespace ebusd { + using std::hex; using std::fstream; 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[]) { struct argp argp = { argpoptions, parse_opt, argpargsdoc, argpdoc, NULL, NULL, NULL }; setenv("ARGP_HELP_FMT", "no-dup-args-note", 0); @@ -171,3 +179,8 @@ int main(int argc, char* argv[]) { exit(EXIT_SUCCESS); } +} // namespace ebusd + +int main(int argc, char* argv[]) { + return ebusd::main(argc, argv); +}