├── .gitignore ├── mem └── media_packet.h ├── srt_live_server.cpp ├── srtserver ├── srt_server.h ├── srt_conn.h └── srt_handle.h ├── Makefile ├── include └── srt │ ├── platform_sys.h │ ├── threadname.h │ ├── srt4udt.h │ ├── srt_compat.h │ ├── logging_api.h │ ├── md5.h │ ├── netinet_any.h │ └── channel.h ├── net └── netpub.h ├── logging ├── log4cplus │ ├── config │ │ ├── macosx.h │ │ ├── windowsh-inc.h │ │ └── defines.hxx │ ├── helpers │ │ ├── sleep.h │ │ ├── logloguser.h │ │ ├── thread-config.h │ │ ├── socketbuffer.h │ │ ├── snprintf.h │ │ ├── fileinfo.h │ │ ├── lockfile.h │ │ ├── appenderattachableimpl.h │ │ ├── socket.h │ │ ├── loglog.h │ │ ├── timehelper.h │ │ ├── queue.h │ │ ├── pointer.h │ │ └── property.h │ ├── fstreams.h │ ├── streams.h │ ├── nullappender.h │ ├── spi │ │ ├── loggerfactory.h │ │ ├── rootlogger.h │ │ ├── appenderattachable.h │ │ └── objectregistry.h │ ├── win32debugappender.h │ ├── tchar.h │ ├── version.h │ ├── internal │ │ ├── cygwin-win32.h │ │ ├── env.h │ │ ├── socket.h │ │ └── internal.h │ ├── tracelogger.h │ ├── hierarchylocker.h │ ├── thread │ │ ├── threads.h │ │ └── impl │ │ │ ├── threads-impl.h │ │ │ ├── tls.h │ │ │ └── syncprims-impl.h │ ├── mdc.h │ ├── nteventlogappender.h │ ├── consoleappender.h │ ├── log4judpappender.h │ ├── clogger.h │ ├── asyncappender.h │ ├── tstring.h │ ├── win32consoleappender.h │ ├── qt4debugappender.h │ ├── syslogappender.h │ ├── boost │ │ └── deviceappender.hxx │ ├── socketappender.h │ └── config.hxx └── logger.h ├── README.md ├── .vscode └── settings.json └── conf └── log.properties /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | *.jar 3 | gradle-wrapper.jar 4 | gradle-wrapper.properties 5 | gradlew 6 | gradlew.bat 7 | *.spec 8 | *.settings 9 | *.status 10 | *.iml 11 | *.idea 12 | *.deps 13 | *.dirstamp 14 | *.o 15 | *.la 16 | *.lo 17 | *.log 18 | *.libs 19 | *.pc 20 | *.pm 21 | *.go.swo 22 | *.go.swp 23 | .vscode* 24 | logs/ 25 | -------------------------------------------------------------------------------- /mem/media_packet.h: -------------------------------------------------------------------------------- 1 | #ifndef MEDIA_PACKET_H 2 | #define MEDIA_PACKET_H 3 | #include 4 | 5 | namespace srt_media { 6 | #define DATA_MAX_LEN (188*7) 7 | 8 | class Media_Packet { 9 | public: 10 | Media_Packet(char* pData, int iLen) { 11 | memcpy(_pData, pData, iLen); 12 | _size = iLen; 13 | } 14 | ~Media_Packet() { 15 | 16 | } 17 | 18 | char* get_data() { 19 | return _pData; 20 | } 21 | 22 | int get_size() { 23 | return _size; 24 | } 25 | private: 26 | char _pData[DATA_MAX_LEN]; 27 | int _size; 28 | }; 29 | } 30 | #endif//MEDIA_PACKET_H -------------------------------------------------------------------------------- /srt_live_server.cpp: -------------------------------------------------------------------------------- 1 | #include "srtserver/srt_server.h" 2 | #include "logging/logger.h" 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | const int SRT_PORT = 9090; 9 | 10 | using namespace srt_media; 11 | 12 | int main(int argn, char** argv) { 13 | srt_startup(); 14 | 15 | InitLog("./conf/log.properties"); 16 | std::shared_ptr srt_server_ptr = std::make_shared(SRT_PORT); 17 | int ret = srt_server_ptr->init(); 18 | if (ret != 0) { 19 | return -1; 20 | } 21 | 22 | ret = srt_server_ptr->run(); 23 | if (ret != 0) { 24 | return -1; 25 | } 26 | 27 | while(true) { 28 | std::this_thread::sleep_for(std::chrono::seconds(5)); 29 | } 30 | 31 | srt_cleanup(); 32 | } -------------------------------------------------------------------------------- /srtserver/srt_server.h: -------------------------------------------------------------------------------- 1 | #ifndef SRT_SERVER_H 2 | #define SRT_SERVER_H 3 | 4 | #include "srt/srt.h" 5 | #include "srt_handle.h" 6 | #include "mem/media_packet.h" 7 | #include "logging/logger.h" 8 | #include 9 | #include 10 | 11 | namespace srt_media { 12 | class srt_server { 13 | public: 14 | srt_server(int port); 15 | ~srt_server(); 16 | 17 | int init(); 18 | int run(); 19 | private: 20 | void on_work(); 21 | SRTSOCKET accept_connection(SRTSOCKET server_srt_socket); 22 | private: 23 | int _port; 24 | SRTSOCKET _rcv_server_socket; 25 | SRTSOCKET _snd_server_socket; 26 | int _pollid; 27 | std::shared_ptr _server_thread; 28 | std::shared_ptr _srt_handle_ptr; 29 | }; 30 | } 31 | #endif//SRT_SERVER_H -------------------------------------------------------------------------------- /srtserver/srt_conn.h: -------------------------------------------------------------------------------- 1 | #ifndef SRT_CONN_H 2 | #define SRT_CONN_H 3 | #include "srt/srt.h" 4 | #include 5 | #include 6 | 7 | namespace srt_media { 8 | #define PULL_SRT_MODE 0x01 9 | #define PUSH_SRT_MODE 0x02 10 | 11 | class srt_conn { 12 | public: 13 | srt_conn(SRTSOCKET conn_fd, int mode):_conn_fd(conn_fd), 14 | _mode(mode) { 15 | 16 | } 17 | 18 | ~srt_conn() { 19 | close(); 20 | } 21 | 22 | void close() { 23 | if (_conn_fd == SRT_INVALID_SOCK) { 24 | return; 25 | } 26 | srt_close(_conn_fd); 27 | _conn_fd = SRT_INVALID_SOCK; 28 | } 29 | 30 | SRTSOCKET get_conn() { 31 | return _conn_fd; 32 | } 33 | int get_mode() { 34 | return _mode; 35 | } 36 | private: 37 | SRTSOCKET _conn_fd; 38 | int _mode; 39 | }; 40 | } 41 | 42 | #endif //SRT_CONN_H -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | CC = gcc 2 | C++ = g++ 3 | LINK = g++ 4 | 5 | LIBS = -L/usr/local/lib -pthread -llog4cplus -lsrt 6 | 7 | #must add -fPIC option 8 | CCFLAGS = $(COMPILER_FLAGS) -c -g -fPIC -Wall 9 | C++FLAGS = $(COMPILER_FLAGS) -c -g -fPIC -Wall -std=c++11 10 | 11 | TARGET=srt_live_server 12 | 13 | INCLUDES = -I. -I./sys -I./net -I./logging -I./rapidjson -I./rapidjson/include 14 | 15 | C++FILES = ./srt_live_server.cpp ./srtserver/srt_server.cpp ./srtserver/srt_handle.cpp 16 | CFILES = 17 | 18 | OBJFILE = $(CFILES:.c=.o) $(C++FILES:.cpp=.o) 19 | 20 | all:$(TARGET) 21 | 22 | $(TARGET): $(OBJFILE) 23 | $(LINK) $^ -Wall $(LIBS) -o $@ 24 | 25 | %.o:%.c 26 | $(CC) -o $@ $(CCFLAGS) $< $(INCLUDES) 27 | 28 | %.o:%.cpp 29 | $(C++) -o $@ $(C++FLAGS) $< $(INCLUDES) 30 | 31 | 32 | clean: 33 | rm -rf $(TARGET) 34 | rm -rf $(OBJFILE) 35 | 36 | 37 | -------------------------------------------------------------------------------- /include/srt/platform_sys.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SRT - Secure, Reliable, Transport 3 | * Copyright (c) 2018 Haivision Systems Inc. 4 | * 5 | * This Source Code Form is subject to the terms of the Mozilla Public 6 | * License, v. 2.0. If a copy of the MPL was not distributed with this 7 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 8 | * 9 | */ 10 | #ifndef INC__PLATFORM_SYS_H 11 | #define INC__PLATFORM_SYS_H 12 | 13 | #ifdef _WIN32 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #if defined(_MSC_VER) 21 | #pragma warning(disable:4251) 22 | #endif 23 | #else 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #endif 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /net/netpub.h: -------------------------------------------------------------------------------- 1 | #ifndef NET_PUB_H 2 | #define NET_PUB_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | namespace srt_media { 13 | inline sockaddr_in create_addr_inet(const std::string& name, unsigned short port) 14 | { 15 | sockaddr_in sa; 16 | memset(&sa, 0, sizeof sa); 17 | sa.sin_family = AF_INET; 18 | sa.sin_port = htons(port); 19 | 20 | if ( name != "" ) 21 | { 22 | if ( inet_pton(AF_INET, name.c_str(), &sa.sin_addr) == 1 ) 23 | return sa; 24 | 25 | // XXX RACY!!! Use getaddrinfo() instead. Check portability. 26 | // Windows/Linux declare it. 27 | // See: 28 | // http://www.winsocketdotnetworkprogramming.com/winsock2programming/winsock2advancedInternet3b.html 29 | hostent* he = gethostbyname(name.c_str()); 30 | if ( !he || he->h_addrtype != AF_INET ) 31 | throw std::invalid_argument("SrtSource: host not found: " + name); 32 | 33 | sa.sin_addr = *(in_addr*)he->h_addr_list[0]; 34 | } 35 | 36 | return sa; 37 | } 38 | } 39 | 40 | #endif //NET_PUB_H -------------------------------------------------------------------------------- /logging/log4cplus/config/macosx.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // Module: Log4CPLUS 3 | // File: config-macosx.h 4 | // Created: 7/2003 5 | // Author: Christopher R. Bailey 6 | // 7 | // 8 | // Copyright 2003-2013 Christopher R. Bailey 9 | // 10 | // Licensed under the Apache License, Version 2.0 (the "License"); 11 | // you may not use this file except in compliance with the License. 12 | // You may obtain a copy of the License at 13 | // 14 | // http://www.apache.org/licenses/LICENSE-2.0 15 | // 16 | // Unless required by applicable law or agreed to in writing, software 17 | // distributed under the License is distributed on an "AS IS" BASIS, 18 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | // See the License for the specific language governing permissions and 20 | // limitations under the License. 21 | 22 | /** @file */ 23 | 24 | #ifndef LOG4CPLUS_CONFIG_MACOSX_HEADER_ 25 | #define LOG4CPLUS_CONFIG_MACOSX_HEADER_ 26 | 27 | #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE) 28 | #pragma once 29 | #endif 30 | 31 | #if (defined(__APPLE__) || (defined(__MWERKS__) && defined(__MACOS__))) 32 | 33 | #define LOG4CPLUS_HAVE_GETTIMEOFDAY 1 34 | #define socklen_t int 35 | 36 | #endif // MACOSX 37 | #endif // LOG4CPLUS_CONFIG_MACOSX_HEADER_ 38 | -------------------------------------------------------------------------------- /srtserver/srt_handle.h: -------------------------------------------------------------------------------- 1 | #ifndef SRT_HANDLE_H 2 | #define SRT_HANDLE_H 3 | #include "srt/srt.h" 4 | #include "srt_conn.h" 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | namespace srt_media { 14 | 15 | class srt_handle { 16 | public: 17 | srt_handle(); 18 | ~srt_handle(); 19 | 20 | int start(); 21 | void stop(); 22 | 23 | void add_newconn(std::shared_ptr conn_ptr, int events); 24 | int get_srt_mode(SRTSOCKET conn_srt_socket); 25 | 26 | private: 27 | void onwork(); 28 | int read_tsfile(char* data_p, int data_len); 29 | 30 | int send_media_data(std::string stream_id, char* data_p, int data_size); 31 | void add_srtsocket(SRTSOCKET write_srtsocket, std::string stream_id); 32 | void remove_srtsocket(SRTSOCKET srtsocket, std::string stream_id); 33 | private: 34 | int _handle_pollid; 35 | std::unordered_map> _conn_map; 36 | std::shared_ptr _work_thread_ptr; 37 | int _file_offset; 38 | 39 | std::unordered_map> _streamid_map;//streamid, list 40 | std::mutex _conn_mutex; 41 | }; 42 | } 43 | 44 | #endif //SRT_HANDLE_H -------------------------------------------------------------------------------- /logging/log4cplus/helpers/sleep.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // Module: Log4CPLUS 3 | // File: sleep.h 4 | // Created: 5/2003 5 | // Author: Tad E. Smith 6 | // 7 | // 8 | // Copyright 2003-2013 Tad E. Smith 9 | // 10 | // Licensed under the Apache License, Version 2.0 (the "License"); 11 | // you may not use this file except in compliance with the License. 12 | // You may obtain a copy of the License at 13 | // 14 | // http://www.apache.org/licenses/LICENSE-2.0 15 | // 16 | // Unless required by applicable law or agreed to in writing, software 17 | // distributed under the License is distributed on an "AS IS" BASIS, 18 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | // See the License for the specific language governing permissions and 20 | // limitations under the License. 21 | 22 | /** @file */ 23 | 24 | #ifndef LOG4CPLUS_HELPERS_SLEEP_HEADER_ 25 | #define LOG4CPLUS_HELPERS_SLEEP_HEADER_ 26 | 27 | #include 28 | 29 | #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE) 30 | #pragma once 31 | #endif 32 | 33 | 34 | namespace log4cplus { 35 | namespace helpers { 36 | LOG4CPLUS_EXPORT void sleep(unsigned long secs, 37 | unsigned long nanosecs = 0); 38 | LOG4CPLUS_EXPORT void sleepmillis(unsigned long millis); 39 | } // end namespace helpers 40 | } // end namespace log4cplus 41 | 42 | #endif // LOG4CPLUS_HELPERS_SLEEP_HEADER_ 43 | 44 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # srt_live_server 2 | live server based on srt protocal
3 | srt_live_server是基于SRT传输协议的直播服务,支持mpegts格式的推流,拉流。
4 | 当前ffmpeg4.1版本以上已经支持srt协议,可以用ffmpeg/ffplay进行测试验证。 5 | 6 | ## 1. 编译简介 7 | ### 1.1 编译libsrt库 8 | 编译方法在srt源代码的readme.md中有详细介绍:[srt_code_in_github](https://github.com/Haivision/srt) 9 | 10 | ### 1.2 编译log4plus 11 | 工程项目的日志,使用的是跨平台的log4plus,所以需要编译。
12 | 下载地址:[log4cplus](https://sourceforge.net/projects/log4cplus/) 13 | 14 | ### 1.3 C++11环境 15 | 工程项目使用C++11开发,所以需要安装C++11以上的版本来进行编译。 16 | 17 | ## 2. srt_live_server 18 | ### 2.1 启动方式 19 |
20 | ./srt_live_server
21 | 
22 | 启动后,开始监听srt推流端口号,和拉流端口号:
23 | * 推流端口号: 9090 24 | * 拉流端口号: 9091 25 | 26 | 固定规则:拉流端口号=推流端口号+1 27 | 28 | 29 | ## 3. 使用简介 30 | ### 3.1 客户端请使用ffmpeg/ffplay 31 | * ffmpeg编译时,请加入选项--enable-libsrt 32 | * ffplay编译前需要有libsdl2.0,请下载,并编译[SDL2.0](http://www.libsdl.org/release/SDL2-2.0.9.tar.gz) 33 | * ffplay编译时,请加入--enable-sdl 34 | 35 | ### 3.2 推流 36 | 输入命令行:
37 |
38 | ffmpeg -re -i 100.flv -c copy -f mpegts srt://127.0.0.1:9090?streamid=100
39 | 
40 | 说明:将本地100.flv的视频文件,不编码,按照时间戳,发送到srt服务器9090端口,streamid为100. 41 | 42 | ### 3.3 拉流 43 | 输入命令行:
44 |
45 | ffplay srt://127.0.0.1:9091?streamid=100
46 | 
47 | 可以观看对应的streamid=100的视频
48 | 注意:端口号是9091,拉流端口号=推流端口号+1 49 | 50 | ## 4. Roadmap 51 | ### 4.1 还未支持gop缓存,2019.02.30前上线。 52 | 53 | ## 5. 相关连接 54 | srt协议文档翻译:[srt_protocal](https://github.com/runner365/read_book/blob/master/SRT/srt_protocol.md) 55 | -------------------------------------------------------------------------------- /logging/log4cplus/fstreams.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // Module: Log4CPLUS 3 | // File: fstreams.h 4 | // Created: 4/2003 5 | // Author: Tad E. Smith 6 | // 7 | // 8 | // Copyright 2003-2013 Tad E. Smith 9 | // 10 | // Licensed under the Apache License, Version 2.0 (the "License"); 11 | // you may not use this file except in compliance with the License. 12 | // You may obtain a copy of the License at 13 | // 14 | // http://www.apache.org/licenses/LICENSE-2.0 15 | // 16 | // Unless required by applicable law or agreed to in writing, software 17 | // distributed under the License is distributed on an "AS IS" BASIS, 18 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | // See the License for the specific language governing permissions and 20 | // limitations under the License. 21 | 22 | /** @file */ 23 | 24 | #ifndef LOG4CPLUS_FSTREAMS_HEADER_ 25 | #define LOG4CPLUS_FSTREAMS_HEADER_ 26 | 27 | #include 28 | 29 | #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE) 30 | #pragma once 31 | #endif 32 | 33 | #include 34 | #include 35 | 36 | 37 | namespace log4cplus 38 | { 39 | 40 | 41 | typedef std::basic_ofstream tofstream; 42 | typedef std::basic_ifstream tifstream; 43 | 44 | //! \def LOG4CPLUS_FSTREAM_PREFERED_FILE_NAME(X) 45 | //! \brief Expands into expression that picks the right type for 46 | //! std::fstream file name parameter. 47 | #if defined (LOG4CPLUS_FSTREAM_ACCEPTS_WCHAR_T) && defined (UNICODE) 48 | # define LOG4CPLUS_FSTREAM_PREFERED_FILE_NAME(X) (X) 49 | #else 50 | # define LOG4CPLUS_FSTREAM_PREFERED_FILE_NAME(X) (LOG4CPLUS_TSTRING_TO_STRING(X)) 51 | #endif 52 | 53 | 54 | } 55 | 56 | #endif // LOG4CPLUS_FSTREAMS_HEADER_ 57 | -------------------------------------------------------------------------------- /logging/log4cplus/streams.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // Module: Log4CPLUS 3 | // File: streams.h 4 | // Created: 4/2003 5 | // Author: Tad E. Smith 6 | // 7 | // 8 | // Copyright 2003-2013 Tad E. Smith 9 | // 10 | // Licensed under the Apache License, Version 2.0 (the "License"); 11 | // you may not use this file except in compliance with the License. 12 | // You may obtain a copy of the License at 13 | // 14 | // http://www.apache.org/licenses/LICENSE-2.0 15 | // 16 | // Unless required by applicable law or agreed to in writing, software 17 | // distributed under the License is distributed on an "AS IS" BASIS, 18 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | // See the License for the specific language governing permissions and 20 | // limitations under the License. 21 | 22 | /** @file */ 23 | 24 | #ifndef LOG4CPLUS_STREAMS_HEADER_ 25 | #define LOG4CPLUS_STREAMS_HEADER_ 26 | 27 | #include 28 | 29 | #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE) 30 | #pragma once 31 | #endif 32 | 33 | #include 34 | 35 | #include 36 | 37 | 38 | namespace log4cplus 39 | { 40 | typedef std::basic_ostream tostream; 41 | typedef std::basic_istream tistream; 42 | typedef std::basic_ostringstream tostringstream; 43 | typedef std::basic_istringstream tistringstream; 44 | extern LOG4CPLUS_EXPORT tostream & tcout; 45 | extern LOG4CPLUS_EXPORT tostream & tcerr; 46 | } 47 | 48 | #if defined (UNICODE) && defined (LOG4CPLUS_ENABLE_GLOBAL_C_STRING_STREAM_INSERTER) 49 | 50 | LOG4CPLUS_EXPORT log4cplus::tostream& operator <<(log4cplus::tostream&, const char* psz ); 51 | 52 | #endif 53 | 54 | #endif // LOG4CPLUS_STREAMS_HEADER_ 55 | 56 | -------------------------------------------------------------------------------- /logging/log4cplus/nullappender.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // Module: Log4CPLUS 3 | // File: nullappender.h 4 | // Created: 6/2003 5 | // Author: Tad E. Smith 6 | // 7 | // 8 | // Copyright 2003-2013 Tad E. Smith 9 | // 10 | // Licensed under the Apache License, Version 2.0 (the "License"); 11 | // you may not use this file except in compliance with the License. 12 | // You may obtain a copy of the License at 13 | // 14 | // http://www.apache.org/licenses/LICENSE-2.0 15 | // 16 | // Unless required by applicable law or agreed to in writing, software 17 | // distributed under the License is distributed on an "AS IS" BASIS, 18 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | // See the License for the specific language governing permissions and 20 | // limitations under the License. 21 | 22 | /** @file */ 23 | 24 | #ifndef LOG4CPLUS_NULL_APPENDER_HEADER_ 25 | #define LOG4CPLUS_NULL_APPENDER_HEADER_ 26 | 27 | #include 28 | 29 | #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE) 30 | #pragma once 31 | #endif 32 | 33 | #include 34 | 35 | 36 | namespace log4cplus { 37 | 38 | /** 39 | * Appends log events to a file. 40 | */ 41 | class LOG4CPLUS_EXPORT NullAppender : public Appender { 42 | public: 43 | // Ctors 44 | NullAppender(); 45 | NullAppender(const log4cplus::helpers::Properties&); 46 | 47 | // Dtor 48 | virtual ~NullAppender(); 49 | 50 | // Methods 51 | virtual void close(); 52 | 53 | protected: 54 | virtual void append(const log4cplus::spi::InternalLoggingEvent& event); 55 | 56 | private: 57 | // Disallow copying of instances of this class 58 | NullAppender(const NullAppender&); 59 | NullAppender& operator=(const NullAppender&); 60 | }; 61 | 62 | } // end namespace log4cplus 63 | 64 | #endif // LOG4CPLUS_NULL_APPENDER_HEADER_ 65 | 66 | -------------------------------------------------------------------------------- /logging/log4cplus/spi/loggerfactory.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // Module: Log4CPLUS 3 | // File: loggerfactory.h 4 | // Created: 6/2001 5 | // Author: Tad E. Smith 6 | // 7 | // 8 | // Copyright 2001-2013 Tad E. Smith 9 | // 10 | // Licensed under the Apache License, Version 2.0 (the "License"); 11 | // you may not use this file except in compliance with the License. 12 | // You may obtain a copy of the License at 13 | // 14 | // http://www.apache.org/licenses/LICENSE-2.0 15 | // 16 | // Unless required by applicable law or agreed to in writing, software 17 | // distributed under the License is distributed on an "AS IS" BASIS, 18 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | // See the License for the specific language governing permissions and 20 | // limitations under the License. 21 | 22 | /** @file */ 23 | 24 | #ifndef LOG4CPLUS_SPI_LOGGER_FACTORY_HEADER 25 | #define LOG4CPLUS_SPI_LOGGER_FACTORY_HEADER 26 | 27 | #include 28 | 29 | #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE) 30 | #pragma once 31 | #endif 32 | 33 | #include 34 | 35 | 36 | namespace log4cplus { 37 | // Forward Declarations 38 | class Logger; 39 | class Hierarchy; 40 | 41 | namespace spi { 42 | /** 43 | * Implement this interface to create new instances of Logger or 44 | * a sub-class of Logger. 45 | */ 46 | class LOG4CPLUS_EXPORT LoggerFactory { 47 | public: 48 | /** 49 | * Creates a new Logger object. 50 | */ 51 | virtual Logger makeNewLoggerInstance(const log4cplus::tstring& name, 52 | Hierarchy& h) = 0; 53 | virtual ~LoggerFactory() = 0; 54 | }; 55 | 56 | } // end namespace spi 57 | } // end namespace log4cplus 58 | 59 | #endif // LOG4CPLUS_SPI_LOGGER_FACTORY_HEADER 60 | 61 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "files.associations": { 3 | "__bit_reference": "cpp", 4 | "__config": "cpp", 5 | "__debug": "cpp", 6 | "__functional_base": "cpp", 7 | "__hash_table": "cpp", 8 | "__locale": "cpp", 9 | "__mutex_base": "cpp", 10 | "__nullptr": "cpp", 11 | "__split_buffer": "cpp", 12 | "__string": "cpp", 13 | "__threading_support": "cpp", 14 | "__tree": "cpp", 15 | "__tuple": "cpp", 16 | "algorithm": "cpp", 17 | "atomic": "cpp", 18 | "bitset": "cpp", 19 | "cctype": "cpp", 20 | "chrono": "cpp", 21 | "cmath": "cpp", 22 | "cstdarg": "cpp", 23 | "cstddef": "cpp", 24 | "cstdint": "cpp", 25 | "cstdio": "cpp", 26 | "cstdlib": "cpp", 27 | "cstring": "cpp", 28 | "ctime": "cpp", 29 | "cwchar": "cpp", 30 | "cwctype": "cpp", 31 | "exception": "cpp", 32 | "fstream": "cpp", 33 | "functional": "cpp", 34 | "initializer_list": "cpp", 35 | "ios": "cpp", 36 | "iosfwd": "cpp", 37 | "iostream": "cpp", 38 | "istream": "cpp", 39 | "iterator": "cpp", 40 | "limits": "cpp", 41 | "list": "cpp", 42 | "locale": "cpp", 43 | "map": "cpp", 44 | "memory": "cpp", 45 | "mutex": "cpp", 46 | "new": "cpp", 47 | "ostream": "cpp", 48 | "ratio": "cpp", 49 | "set": "cpp", 50 | "sstream": "cpp", 51 | "stdexcept": "cpp", 52 | "streambuf": "cpp", 53 | "string": "cpp", 54 | "string_view": "cpp", 55 | "system_error": "cpp", 56 | "thread": "cpp", 57 | "tuple": "cpp", 58 | "type_traits": "cpp", 59 | "typeinfo": "cpp", 60 | "unordered_map": "cpp", 61 | "utility": "cpp", 62 | "vector": "cpp", 63 | "deque": "cpp", 64 | "queue": "cpp" 65 | } 66 | } -------------------------------------------------------------------------------- /logging/log4cplus/helpers/logloguser.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // Module: Log4CPLUS 3 | // File: logloguser.h 4 | // Created: 6/2003 5 | // Author: Tad E. Smith 6 | // 7 | // 8 | // Copyright 2003-2013 Tad E. Smith 9 | // 10 | // Licensed under the Apache License, Version 2.0 (the "License"); 11 | // you may not use this file except in compliance with the License. 12 | // You may obtain a copy of the License at 13 | // 14 | // http://www.apache.org/licenses/LICENSE-2.0 15 | // 16 | // Unless required by applicable law or agreed to in writing, software 17 | // distributed under the License is distributed on an "AS IS" BASIS, 18 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | // See the License for the specific language governing permissions and 20 | // limitations under the License. 21 | 22 | /** @file */ 23 | 24 | #ifndef LOG4CPLUS_HELPERS_LOGLOG_USER 25 | #define LOG4CPLUS_HELPERS_LOGLOG_USER 26 | 27 | #include 28 | 29 | #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE) 30 | #pragma once 31 | #endif 32 | 33 | 34 | namespace log4cplus { 35 | namespace helpers { 36 | // forward declarations 37 | class LogLog; 38 | 39 | /** 40 | * This class used to simplify the use of the LogLog class. Any class 41 | * that uses the LogLog class should extend this class and retrieve 42 | * their reference to LogLog using the method provided. 43 | */ 44 | class LOG4CPLUS_EXPORT LogLogUser 45 | { 46 | public: 47 | // ctor and dtor 48 | LogLogUser(); 49 | LogLogUser(const LogLogUser&); 50 | virtual ~LogLogUser(); 51 | 52 | // public methods 53 | LogLog& getLogLog() const; 54 | 55 | // operators 56 | LogLogUser& operator=(const LogLogUser& rhs); 57 | }; 58 | 59 | } // end namespace helpers 60 | } // end namespace log4cplus 61 | 62 | 63 | #endif // LOG4CPLUS_HELPERS_LOGLOG_USER 64 | 65 | -------------------------------------------------------------------------------- /logging/log4cplus/win32debugappender.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // Module: Log4CPLUS 3 | // File: win32debugappender.h 4 | // Created: 12/2003 5 | // Author: Eduardo Francos, Odalio SARL 6 | // 7 | // 8 | // Copyright 2003-2013 Odalio SARL 9 | // 10 | // Licensed under the Apache License, Version 2.0 (the "License"); 11 | // you may not use this file except in compliance with the License. 12 | // You may obtain a copy of the License at 13 | // 14 | // http://www.apache.org/licenses/LICENSE-2.0 15 | // 16 | // Unless required by applicable law or agreed to in writing, software 17 | // distributed under the License is distributed on an "AS IS" BASIS, 18 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | // See the License for the specific language governing permissions and 20 | // limitations under the License. 21 | 22 | /** @file */ 23 | 24 | #ifndef LOG4CPLUS_WIN32DEBUG_APPENDER_HEADER_ 25 | #define LOG4CPLUS_WIN32DEBUG_APPENDER_HEADER_ 26 | 27 | #include 28 | 29 | #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE) 30 | #pragma once 31 | #endif 32 | 33 | #if defined (LOG4CPLUS_HAVE_OUTPUTDEBUGSTRING) 34 | 35 | #include 36 | 37 | 38 | namespace log4cplus { 39 | 40 | /** 41 | * Prints log events using OutputDebugString(). 42 | */ 43 | class LOG4CPLUS_EXPORT Win32DebugAppender 44 | : public Appender 45 | { 46 | public: 47 | // Ctors 48 | Win32DebugAppender(); 49 | Win32DebugAppender(const log4cplus::helpers::Properties& properties); 50 | 51 | // Dtor 52 | virtual ~Win32DebugAppender(); 53 | 54 | // Methods 55 | virtual void close(); 56 | 57 | protected: 58 | virtual void append(const log4cplus::spi::InternalLoggingEvent& event); 59 | 60 | private: 61 | // Disallow copying of instances of this class 62 | Win32DebugAppender(const Win32DebugAppender&); 63 | Win32DebugAppender& operator=(const Win32DebugAppender&); 64 | }; 65 | 66 | } // end namespace log4cplus 67 | 68 | #endif // LOG4CPLUS_HAVE_OUTPUTDEBUGSTRING 69 | #endif // LOG4CPLUS_WIN32DEBUG_APPENDER_HEADER_ 70 | -------------------------------------------------------------------------------- /logging/log4cplus/helpers/thread-config.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // Module: Log4CPLUS 3 | // File: thread-config.h 4 | // Created: 4/2003 5 | // Author: Tad E. Smith 6 | // 7 | // 8 | // Copyright 2003-2013 Tad E. Smith 9 | // 10 | // Licensed under the Apache License, Version 2.0 (the "License"); 11 | // you may not use this file except in compliance with the License. 12 | // You may obtain a copy of the License at 13 | // 14 | // http://www.apache.org/licenses/LICENSE-2.0 15 | // 16 | // Unless required by applicable law or agreed to in writing, software 17 | // distributed under the License is distributed on an "AS IS" BASIS, 18 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | // See the License for the specific language governing permissions and 20 | // limitations under the License. 21 | /** @file */ 22 | 23 | #ifndef LOG4CPLUS_HELPERS_THREAD_CONFIG_HEADER_ 24 | #define LOG4CPLUS_HELPERS_THREAD_CONFIG_HEADER_ 25 | 26 | #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE) 27 | #pragma once 28 | #endif 29 | 30 | #if defined (LOG4CPLUS_USE_PTHREADS) 31 | # if defined (__APPLE__) 32 | # define LOG4CPLUS_USE_NAMED_POSIX_SEMAPHORE 33 | # endif 34 | 35 | #elif defined(LOG4CPLUS_USE_WIN32_THREADS) 36 | # if defined (_WIN32_WINNT) && _WIN32_WINNT >= 0x0600 37 | # define LOG4CPLUS_USE_SRW_LOCK 38 | # else 39 | # define LOG4CPLUS_POOR_MANS_SHAREDMUTEX 40 | # endif 41 | # undef LOG4CPLUS_HAVE_TLS_SUPPORT 42 | # undef LOG4CPLUS_THREAD_LOCAL_VAR 43 | # if defined (_MSC_VER) && _WIN32_WINNT >= 0x0600 44 | // The __declspec(thread) functionality is not compatible with LoadLibrary(). 45 | // For more information why see and "Windows and TLS" note in README. 46 | // . 47 | # define LOG4CPLUS_HAVE_TLS_SUPPORT 1 48 | # define LOG4CPLUS_THREAD_LOCAL_VAR __declspec(thread) 49 | # endif 50 | 51 | #elif defined(LOG4CPLUS_SINGLE_THREADED) 52 | # undef LOG4CPLUS_HAVE_TLS_SUPPORT 53 | # undef LOG4CPLUS_THREAD_LOCAL_VAR 54 | 55 | #else 56 | # error "You Must define a Threading model" 57 | 58 | #endif 59 | 60 | 61 | #endif // LOG4CPLUS_HELPERS_THREAD_CONFIG_HEADER_ 62 | -------------------------------------------------------------------------------- /conf/log.properties: -------------------------------------------------------------------------------- 1 | log4cplus.rootLogger=TRACE 2 | log4cplus.logger.program=DEBUG, E, D 3 | log4cplus.logger.business=DEBUG, BUSINESS 4 | log4cplus.logger.access=DEBUG, ACCESS 5 | log4cplus.logger.server=DEBUG, SERVER 6 | 7 | 8 | log4cplus.appender.D=log4cplus::DailyRollingFileAppender 9 | log4cplus.appender.D.File=./logs/debug.log 10 | log4cplus.appender.D.Mode=APPEND 11 | log4cplus.appender.D.Schedule=DAILY 12 | log4cplus.appender.D.layout=log4cplus::PatternLayout 13 | log4cplus.appender.D.MaxBackupIndex=0 14 | log4cplus.appender.D.layout.ConversionPattern=%D{%Y-%m-%d %H:%M:%S.%q}|%t|%p|%l|%m%n 15 | 16 | log4cplus.appender.E.Threshold=ERROR 17 | log4cplus.appender.E=log4cplus::DailyRollingFileAppender 18 | log4cplus.appender.E.File=./logs/error.log 19 | log4cplus.appender.E.Mode=APPEND 20 | log4cplus.appender.E.Schedule=DAILY 21 | log4cplus.appender.E.layout=log4cplus::PatternLayout 22 | log4cplus.appender.E.MaxBackupIndex=0 23 | log4cplus.appender.E.layout.ConversionPattern=%D{%Y-%m-%d %H:%M:%S.%q}|%t|%p|%x|%l|%m%n 24 | 25 | log4cplus.appender.BUSINESS=log4cplus::DailyRollingFileAppender 26 | log4cplus.appender.BUSINESS.File=./logs/business.log 27 | log4cplus.appender.BUSINESS.Schedule=DAILY 28 | log4cplus.appender.BUSINESS.MaxBackupIndex=0 29 | log4cplus.appender.BUSINESS.layout=log4cplus::PatternLayout 30 | log4cplus.appender.BUSINESS.layout.ConversionPattern=%D{%Y-%m-%d %H:%M:%S.%q}|%t|%x|%l|%m%n 31 | 32 | log4cplus.appender.ACCESS=log4cplus::DailyRollingFileAppender 33 | log4cplus.appender.ACCESS.File=./logs/access.log 34 | log4cplus.appender.ACCESS.Schedule=DAILY 35 | log4cplus.appender.ACCESS.MaxBackupIndex=0 36 | log4cplus.appender.ACCESS.layout=log4cplus::PatternLayout 37 | log4cplus.appender.ACCESS.layout.ConversionPattern=%D{%Y-%m-%d %H:%M:%S.%q}|%t|%x|%l|%m%n 38 | 39 | log4cplus.appender.SERVER.Threshold=ERROR 40 | log4cplus.appender.SERVER=log4cplus::DailyRollingFileAppender 41 | log4cplus.appender.SERVER.File=./logs/server.log 42 | log4cplus.appender.SERVER.Schedule=DAILY 43 | log4cplus.appender.SERVER.MaxBackupIndex=0 44 | log4cplus.appender.SERVER.layout=log4cplus::PatternLayout 45 | log4cplus.appender.SERVER.layout.ConversionPattern=%D{%Y-%m-%d %H:%M:%S.%q}|%t|%p|%l|%m%n 46 | -------------------------------------------------------------------------------- /include/srt/threadname.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SRT - Secure, Reliable, Transport 3 | * Copyright (c) 2018 Haivision Systems Inc. 4 | * 5 | * This Source Code Form is subject to the terms of the Mozilla Public 6 | * License, v. 2.0. If a copy of the MPL was not distributed with this 7 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 8 | * 9 | */ 10 | 11 | /***************************************************************************** 12 | written by 13 | Haivision Systems Inc. 14 | *****************************************************************************/ 15 | 16 | #ifndef INC__THREADNAME_H 17 | #define INC__THREADNAME_H 18 | 19 | #ifdef __linux__ 20 | 21 | #include 22 | 23 | class ThreadName 24 | { 25 | char old_name[128]; 26 | char new_name[128]; 27 | bool good; 28 | 29 | public: 30 | static const size_t BUFSIZE = 128; 31 | 32 | static bool get(char* namebuf) 33 | { 34 | return prctl(PR_GET_NAME, (unsigned long)namebuf, 0, 0) != -1; 35 | } 36 | 37 | static bool set(const char* name) 38 | { 39 | return prctl(PR_SET_NAME, (unsigned long)name, 0, 0) != -1; 40 | } 41 | 42 | 43 | ThreadName(const char* name) 44 | { 45 | if ( (good = get(old_name)) ) 46 | { 47 | snprintf(new_name, 127, "%s", name); 48 | new_name[127] = 0; 49 | prctl(PR_SET_NAME, (unsigned long)new_name, 0, 0); 50 | } 51 | } 52 | 53 | ~ThreadName() 54 | { 55 | if ( good ) 56 | prctl(PR_SET_NAME, (unsigned long)old_name, 0, 0); 57 | } 58 | }; 59 | 60 | #else 61 | 62 | // Fake class, which does nothing. You can also take a look how 63 | // this works in other systems that are not supported here and add 64 | // the support. This is a fallback for systems that do not support 65 | // thread names. 66 | 67 | class ThreadName 68 | { 69 | public: 70 | 71 | static bool get(char*) { return false; } 72 | static bool set(const char*) { return false; } 73 | 74 | ThreadName(const char*) 75 | { 76 | } 77 | 78 | ~ThreadName() // just to make it "non-trivially-destructible" for compatibility with normal version 79 | { 80 | } 81 | 82 | }; 83 | 84 | 85 | 86 | #endif 87 | #endif 88 | -------------------------------------------------------------------------------- /logging/log4cplus/tchar.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // Copyright (C) 2010-2013, Vaclav Haisman. All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without modifica- 5 | // tion, are permitted provided that the following conditions are met: 6 | // 7 | // 1. Redistributions of source code must retain the above copyright notice, 8 | // this list of conditions and the following disclaimer. 9 | // 10 | // 2. Redistributions in binary form must reproduce the above copyright notice, 11 | // this list of conditions and the following disclaimer in the documentation 12 | // and/or other materials provided with the distribution. 13 | // 14 | // THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 15 | // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 16 | // FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 17 | // APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 18 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- 19 | // DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 20 | // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 21 | // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | 25 | /** @file */ 26 | 27 | #ifndef LOG4CPLUS_TCHAR_HEADER_ 28 | #define LOG4CPLUS_TCHAR_HEADER_ 29 | 30 | #include 31 | 32 | #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE) 33 | #pragma once 34 | #endif 35 | 36 | #if defined (_WIN32) 37 | #include 38 | #endif 39 | 40 | 41 | #ifdef UNICODE 42 | # define LOG4CPLUS_TEXT2(STRING) L##STRING 43 | #else 44 | # define LOG4CPLUS_TEXT2(STRING) STRING 45 | #endif // UNICODE 46 | #define LOG4CPLUS_TEXT(STRING) LOG4CPLUS_TEXT2(STRING) 47 | 48 | 49 | namespace log4cplus 50 | { 51 | 52 | #if defined (UNICODE) 53 | typedef wchar_t tchar; 54 | 55 | #else 56 | typedef char tchar; 57 | 58 | #endif 59 | 60 | } // namespace log4cplus 61 | 62 | 63 | #endif // LOG4CPLUS_TCHAR_HEADER_ 64 | -------------------------------------------------------------------------------- /logging/log4cplus/version.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // Copyright (C) 2010-2013, Vaclav Haisman. All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without modifica- 5 | // tion, are permitted provided that the following conditions are met: 6 | // 7 | // 1. Redistributions of source code must retain the above copyright notice, 8 | // this list of conditions and the following disclaimer. 9 | // 10 | // 2. Redistributions in binary form must reproduce the above copyright notice, 11 | // this list of conditions and the following disclaimer in the documentation 12 | // and/or other materials provided with the distribution. 13 | // 14 | // THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 15 | // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 16 | // FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 17 | // APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 18 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- 19 | // DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 20 | // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 21 | // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | 25 | 26 | #if ! defined (LOG4CPLUS_VERSION_H) 27 | #define LOG4CPLUS_VERSION_H 28 | 29 | #include 30 | 31 | #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE) 32 | #pragma once 33 | #endif 34 | 35 | #define LOG4CPLUS_MAKE_VERSION(major, minor, point) \ 36 | (major * 1000 * 1000u + minor * 1000u + point) 37 | 38 | #define LOG4CPLUS_MAKE_VERSION_STR(major, minor, point) \ 39 | #major "." #minor "." #point 40 | 41 | #define LOG4CPLUS_VERSION LOG4CPLUS_MAKE_VERSION(1, 1, 2) 42 | #define LOG4CPLUS_VERSION_STR LOG4CPLUS_MAKE_VERSION_STR(1, 1, 2) 43 | 44 | 45 | namespace log4cplus 46 | { 47 | 48 | extern LOG4CPLUS_EXPORT unsigned const version; 49 | extern LOG4CPLUS_EXPORT char const versionStr[]; 50 | 51 | } 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /logging/log4cplus/internal/cygwin-win32.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // Module: Log4CPLUS 3 | // File: cygwin-win32.h 4 | // Created: 7/2011 5 | // Author: Vaclav Zeman 6 | // 7 | // Copyright (C) 2011-2013, Vaclav Zeman. All rights reserved. 8 | // 9 | // Redistribution and use in source and binary forms, with or without modifica- 10 | // tion, are permitted provided that the following conditions are met: 11 | // 12 | // 1. Redistributions of source code must retain the above copyright notice, 13 | // this list of conditions and the following disclaimer. 14 | // 15 | // 2. Redistributions in binary form must reproduce the above copyright notice, 16 | // this list of conditions and the following disclaimer in the documentation 17 | // and/or other materials provided with the distribution. 18 | // 19 | // THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 20 | // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 21 | // FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 22 | // APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 23 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- 24 | // DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 25 | // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 26 | // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 | // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | #if ! defined (LOG4CPLUS_CONFIG_CYGWIN_WIN32_H) 31 | #define LOG4CPLUS_CONFIG_CYGWIN_WIN32_H 32 | 33 | #include 34 | 35 | #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE) 36 | #pragma once 37 | #endif 38 | 39 | #if defined (__CYGWIN__) 40 | 41 | #if ! defined (INSIDE_LOG4CPLUS) 42 | # error "This header must not be be used outside log4cplus' implementation files." 43 | #endif 44 | 45 | 46 | namespace log4cplus { namespace cygwin { 47 | 48 | unsigned long get_current_win32_thread_id (); 49 | 50 | } } // namespace log4cplus { namespace cygwin { 51 | 52 | 53 | #endif // defined (__CYGWIN__) 54 | #endif // LOG4CPLUS_CONFIG_CYGWIN_WIN32_H 55 | -------------------------------------------------------------------------------- /logging/log4cplus/helpers/socketbuffer.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // Module: Log4CPLUS 3 | // File: socketbuffer.h 4 | // Created: 5/2003 5 | // Author: Tad E. Smith 6 | // 7 | // 8 | // Copyright 2003-2013 Tad E. Smith 9 | // 10 | // Licensed under the Apache License, Version 2.0 (the "License"); 11 | // you may not use this file except in compliance with the License. 12 | // You may obtain a copy of the License at 13 | // 14 | // http://www.apache.org/licenses/LICENSE-2.0 15 | // 16 | // Unless required by applicable law or agreed to in writing, software 17 | // distributed under the License is distributed on an "AS IS" BASIS, 18 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | // See the License for the specific language governing permissions and 20 | // limitations under the License. 21 | 22 | /** @file */ 23 | 24 | #ifndef LOG4CPLUS_HELPERS_SOCKET_BUFFER_HEADER_ 25 | #define LOG4CPLUS_HELPERS_SOCKET_BUFFER_HEADER_ 26 | 27 | #include 28 | 29 | #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE) 30 | #pragma once 31 | #endif 32 | 33 | #include 34 | 35 | 36 | namespace log4cplus { 37 | namespace helpers { 38 | 39 | /** 40 | * 41 | */ 42 | class LOG4CPLUS_EXPORT SocketBuffer 43 | { 44 | public: 45 | explicit SocketBuffer(std::size_t max); 46 | virtual ~SocketBuffer(); 47 | 48 | char *getBuffer() const { return buffer; } 49 | std::size_t getMaxSize() const { return maxsize; } 50 | std::size_t getSize() const { return size; } 51 | void setSize(std::size_t s) { size = s; } 52 | std::size_t getPos() const { return pos; } 53 | 54 | unsigned char readByte(); 55 | unsigned short readShort(); 56 | unsigned int readInt(); 57 | tstring readString(unsigned char sizeOfChar); 58 | 59 | void appendByte(unsigned char val); 60 | void appendShort(unsigned short val); 61 | void appendInt(unsigned int val); 62 | void appendString(const tstring& str); 63 | void appendBuffer(const SocketBuffer& buffer); 64 | 65 | private: 66 | // Data 67 | std::size_t maxsize; 68 | std::size_t size; 69 | std::size_t pos; 70 | char *buffer; 71 | 72 | SocketBuffer(SocketBuffer const & rhs); 73 | SocketBuffer& operator= (SocketBuffer const& rhs); 74 | }; 75 | 76 | } // end namespace helpers 77 | } // end namespace log4cplus 78 | 79 | #endif // LOG4CPLUS_HELPERS_SOCKET_HEADER_ 80 | -------------------------------------------------------------------------------- /logging/log4cplus/helpers/snprintf.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // Copyright (C) 2010-2013, Vaclav Zeman. All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without modifica- 5 | // tion, are permitted provided that the following conditions are met: 6 | // 7 | // 1. Redistributions of source code must retain the above copyright notice, 8 | // this list of conditions and the following disclaimer. 9 | // 10 | // 2. Redistributions in binary form must reproduce the above copyright notice, 11 | // this list of conditions and the following disclaimer in the documentation 12 | // and/or other materials provided with the distribution. 13 | // 14 | // THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 15 | // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 16 | // FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 17 | // APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 18 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- 19 | // DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 20 | // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 21 | // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | 25 | #ifndef LOG4CPLUS_HELPERS_SNPRINTF_H 26 | #define LOG4CPLUS_HELPERS_SNPRINTF_H 27 | 28 | #include 29 | 30 | #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE) 31 | #pragma once 32 | #endif 33 | 34 | #include 35 | #include 36 | #include 37 | 38 | 39 | namespace log4cplus { namespace helpers { 40 | 41 | 42 | class LOG4CPLUS_EXPORT snprintf_buf 43 | { 44 | public: 45 | snprintf_buf (); 46 | 47 | tchar const * print (tchar const * fmt, ...) 48 | LOG4CPLUS_FORMAT_ATTRIBUTE (__printf__, 2, 3); 49 | 50 | int print_va_list (tchar const * & str, tchar const * fmt, std::va_list) 51 | LOG4CPLUS_FORMAT_ATTRIBUTE (__printf__, 3, 0); 52 | 53 | private: 54 | std::vector buf; 55 | }; 56 | 57 | 58 | } } // namespace log4cplus { namespace helpers 59 | 60 | 61 | 62 | #endif // LOG4CPLUS_HELPERS_SNPRINTF_H 63 | -------------------------------------------------------------------------------- /logging/log4cplus/helpers/fileinfo.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // 3 | // Copyright (C) 2012-2013, Vaclav Zeman. All rights reserved. 4 | // 5 | // Redistribution and use in source and binary forms, with or without modifica- 6 | // tion, are permitted provided that the following conditions are met: 7 | // 8 | // 1. Redistributions of source code must retain the above copyright notice, 9 | // this list of conditions and the following disclaimer. 10 | // 11 | // 2. Redistributions in binary form must reproduce the above copyright notice, 12 | // this list of conditions and the following disclaimer in the documentation 13 | // and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 16 | // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 17 | // FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 18 | // APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 19 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- 20 | // DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 21 | // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 22 | // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 | // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | #if ! defined (LOG4CPLUS_HELPERS_FILEINFO_H) 27 | #define LOG4CPLUS_HELPERS_FILEINFO_H 28 | 29 | #include 30 | 31 | #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE) 32 | #pragma once 33 | #endif 34 | 35 | #include 36 | #ifdef LOG4CPLUS_HAVE_SYS_TYPES_H 37 | #include 38 | #endif 39 | 40 | 41 | namespace log4cplus { namespace helpers { 42 | 43 | //! FileInfo structure is OS independent abstraction of the 44 | //! stat() function. 45 | struct LOG4CPLUS_EXPORT FileInfo 46 | { 47 | helpers::Time mtime; 48 | bool is_link; 49 | off_t size; 50 | }; 51 | 52 | 53 | //! OS independent abstraction of stat() function. 54 | LOG4CPLUS_EXPORT int getFileInfo (FileInfo * fi, tstring const & name); 55 | 56 | 57 | } } // namespace log4cplus { namespace helpers { 58 | 59 | #endif // LOG4CPLUS_HELPERS_FILEINFO_H 60 | -------------------------------------------------------------------------------- /logging/log4cplus/helpers/lockfile.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // 3 | // Copyright (C) 2012-2013, Vaclav Zeman. All rights reserved. 4 | // 5 | // Redistribution and use in source and binary forms, with or without modifica- 6 | // tion, are permitted provided that the following conditions are met: 7 | // 8 | // 1. Redistributions of source code must retain the above copyright notice, 9 | // this list of conditions and the following disclaimer. 10 | // 11 | // 2. Redistributions in binary form must reproduce the above copyright notice, 12 | // this list of conditions and the following disclaimer in the documentation 13 | // and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 16 | // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 17 | // FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 18 | // APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 19 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- 20 | // DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 21 | // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 22 | // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 | // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | #if ! defined (LOG4CPLUS_HELPERS_LOCKFILE_H) 27 | #define LOG4CPLUS_HELPERS_LOCKFILE_H 28 | 29 | #include 30 | 31 | #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE) 32 | #pragma once 33 | #endif 34 | 35 | #include 36 | #include 37 | 38 | 39 | namespace log4cplus { namespace helpers { 40 | 41 | 42 | class LOG4CPLUS_EXPORT LockFile 43 | { 44 | public: 45 | LockFile (tstring const & lock_file); 46 | ~LockFile (); 47 | 48 | void lock () const; 49 | void unlock () const; 50 | 51 | private: 52 | void open (int) const; 53 | void close () const; 54 | 55 | struct Impl; 56 | 57 | tstring lock_file_name; 58 | Impl * data; 59 | }; 60 | 61 | 62 | typedef log4cplus::thread::SyncGuard LockFileGuard; 63 | 64 | 65 | } } // namespace log4cplus { namespace helpers { 66 | 67 | 68 | #endif // LOG4CPLUS_HELPERS_LOCKFILE_H 69 | -------------------------------------------------------------------------------- /logging/log4cplus/tracelogger.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // Module: Log4CPLUS 3 | // File: tracelogger.h 4 | // Created: 1/2009 5 | // Author: Vaclav Haisman 6 | // 7 | // 8 | // Copyright 2009-2013 Tad E. Smith 9 | // 10 | // Licensed under the Apache License, Version 2.0 (the "License"); 11 | // you may not use this file except in compliance with the License. 12 | // You may obtain a copy of the License at 13 | // 14 | // http://www.apache.org/licenses/LICENSE-2.0 15 | // 16 | // Unless required by applicable law or agreed to in writing, software 17 | // distributed under the License is distributed on an "AS IS" BASIS, 18 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | // See the License for the specific language governing permissions and 20 | // limitations under the License. 21 | 22 | /** @file */ 23 | 24 | #ifndef LOG4CPLUS_TRACELOGGER_H 25 | #define LOG4CPLUS_TRACELOGGER_H 26 | 27 | #include 28 | 29 | #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE) 30 | #pragma once 31 | #endif 32 | 33 | #include 34 | 35 | 36 | namespace log4cplus 37 | { 38 | 39 | 40 | /** 41 | * This class is used to produce "Trace" logging. When an instance of 42 | * this class is created, it will log a "ENTER: " + msg 43 | * log message if TRACE_LOG_LEVEL is enabled for logger. 44 | * When an instance of this class is destroyed, it will log a 45 | * "ENTER: " + msg log message if TRACE_LOG_LEVEL is enabled 46 | * for logger. 47 | *

48 | * @see LOG4CPLUS_TRACE 49 | */ 50 | class TraceLogger 51 | { 52 | public: 53 | TraceLogger(const Logger& l, const log4cplus::tstring& _msg, 54 | const char* _file=NULL, int _line=-1) 55 | : logger(l), msg(_msg), file(_file), line(_line) 56 | { if(logger.isEnabledFor(TRACE_LOG_LEVEL)) 57 | logger.forcedLog(TRACE_LOG_LEVEL, LOG4CPLUS_TEXT("ENTER: ") + msg, file, line); 58 | } 59 | 60 | ~TraceLogger() 61 | { if(logger.isEnabledFor(TRACE_LOG_LEVEL)) 62 | logger.forcedLog(TRACE_LOG_LEVEL, LOG4CPLUS_TEXT("EXIT: ") + msg, file, line); 63 | } 64 | 65 | private: 66 | TraceLogger (TraceLogger const &); 67 | TraceLogger & operator = (TraceLogger const &); 68 | 69 | Logger logger; 70 | log4cplus::tstring msg; 71 | const char* file; 72 | int line; 73 | }; 74 | 75 | 76 | } // log4cplus 77 | 78 | 79 | #endif // LOG4CPLUS_TRACELOGGER_H 80 | -------------------------------------------------------------------------------- /logging/log4cplus/hierarchylocker.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // Module: Log4CPLUS 3 | // File: hierarchylocker.h 4 | // Created: 8/2003 5 | // Author: Tad E. Smith 6 | // 7 | // 8 | // Copyright 2003-2013 Tad E. Smith 9 | // 10 | // Licensed under the Apache License, Version 2.0 (the "License"); 11 | // you may not use this file except in compliance with the License. 12 | // You may obtain a copy of the License at 13 | // 14 | // http://www.apache.org/licenses/LICENSE-2.0 15 | // 16 | // Unless required by applicable law or agreed to in writing, software 17 | // distributed under the License is distributed on an "AS IS" BASIS, 18 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | // See the License for the specific language governing permissions and 20 | // limitations under the License. 21 | 22 | /** @file */ 23 | 24 | #ifndef LOG4CPLUS_HIERARCHY_LOCKER_HEADER_ 25 | #define LOG4CPLUS_HIERARCHY_LOCKER_HEADER_ 26 | 27 | #include 28 | 29 | #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE) 30 | #pragma once 31 | #endif 32 | 33 | #include 34 | #include 35 | #include 36 | 37 | 38 | namespace log4cplus 39 | { 40 | 41 | class Hierarchy; 42 | 43 | 44 | /** 45 | * This is used to lock a Hierarchy. The dtor unlocks the Hierarchy. 46 | */ 47 | class LOG4CPLUS_EXPORT HierarchyLocker { 48 | public: 49 | // ctor & dtor 50 | HierarchyLocker(Hierarchy& h); 51 | ~HierarchyLocker(); 52 | 53 | /** 54 | * Calls the resetConfiguration() method on the locked Hierarchy. 55 | */ 56 | void resetConfiguration(); 57 | 58 | /** 59 | * Calls the getInstance() method on the locked Hierarchy. 60 | */ 61 | Logger getInstance(const log4cplus::tstring& name); 62 | 63 | /** 64 | * Calls the getInstance() method on the locked Hierarchy. 65 | */ 66 | Logger getInstance(const log4cplus::tstring& name, spi::LoggerFactory& factory); 67 | 68 | void addAppender(Logger &logger, log4cplus::SharedAppenderPtr& appender); 69 | 70 | private: 71 | // Data 72 | Hierarchy& h; 73 | log4cplus::thread::MutexGuard hierarchyLocker; 74 | LoggerList loggerList; 75 | }; 76 | 77 | } // end namespace log4cplus 78 | 79 | #endif // LOG4CPLUS_HIERARCHY_LOCKER_HEADER_ 80 | 81 | -------------------------------------------------------------------------------- /include/srt/srt4udt.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SRT - Secure, Reliable, Transport 3 | * Copyright (c) 2018 Haivision Systems Inc. 4 | * 5 | * This Source Code Form is subject to the terms of the Mozilla Public 6 | * License, v. 2.0. If a copy of the MPL was not distributed with this 7 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 8 | * 9 | */ 10 | 11 | /***************************************************************************** 12 | written by 13 | Haivision Systems Inc. 14 | *****************************************************************************/ 15 | 16 | #ifndef SRT4UDT_H 17 | #define SRT4UDT_H 18 | 19 | #ifndef INC__SRTC_H 20 | #error "This is protected header, used by udt.h. This shouldn't be included directly" 21 | #endif 22 | 23 | //undef SRT_ENABLE_ECN 1 /* Early Congestion Notification (for source bitrate control) */ 24 | 25 | //undef SRT_DEBUG_TSBPD_OUTJITTER 1 /* Packet Delivery histogram */ 26 | //undef SRT_DEBUG_TSBPD_DRIFT 1 /* Debug Encoder-Decoder Drift) */ 27 | //undef SRT_DEBUG_TSBPD_WRAP 1 /* Debug packet timestamp wraparound */ 28 | //undef SRT_DEBUG_TLPKTDROP_DROPSEQ 1 29 | //undef SRT_DEBUG_SNDQ_HIGHRATE 1 30 | 31 | 32 | /* 33 | * SRT_ENABLE_CONNTIMEO 34 | * Option UDT_CONNTIMEO added to the API to set/get the connection timeout. 35 | * The UDT hard coded default of 3000 msec is too small for some large RTT (satellite) use cases. 36 | * The SRT handshake (2 exchanges) needs 2 times the RTT to complete with no packet loss. 37 | */ 38 | #define SRT_ENABLE_CONNTIMEO 1 39 | 40 | /* 41 | * SRT_ENABLE_NOCWND 42 | * Set the congestion window at its max (then disabling it) to prevent stopping transmission 43 | * when too many packets are not acknowledged. 44 | * The congestion windows is the maximum distance in pkts since the last acknowledged packets. 45 | */ 46 | #define SRT_ENABLE_NOCWND 1 47 | 48 | /* 49 | * SRT_ENABLE_NAKREPORT 50 | * Send periodic NAK report for more efficient retransmission instead of relying on ACK timeout 51 | * to retransmit all non-ACKed packets, very inefficient with real-time and no congestion window. 52 | */ 53 | #define SRT_ENABLE_NAKREPORT 1 54 | 55 | #define SRT_ENABLE_RCVBUFSZ_MAVG 1 /* Recv buffer size moving average */ 56 | #define SRT_ENABLE_SNDBUFSZ_MAVG 1 /* Send buffer size moving average */ 57 | #define SRT_MAVG_SAMPLING_RATE 40 /* Max sampling rate */ 58 | 59 | #define SRT_ENABLE_LOSTBYTESCOUNT 1 60 | 61 | 62 | /* 63 | * SRT_ENABLE_IPOPTS 64 | * Enable IP TTL and ToS setting 65 | */ 66 | #define SRT_ENABLE_IPOPTS 1 67 | 68 | 69 | #define SRT_ENABLE_CLOSE_SYNCH 1 70 | 71 | #endif /* SRT4UDT_H */ 72 | -------------------------------------------------------------------------------- /logging/log4cplus/spi/rootlogger.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // Module: Log4CPLUS 3 | // File: rootlogger.h 4 | // Created: 6/2001 5 | // Author: Tad E. Smith 6 | // 7 | // 8 | // Copyright 2001-2013 Tad E. Smith 9 | // 10 | // Licensed under the Apache License, Version 2.0 (the "License"); 11 | // you may not use this file except in compliance with the License. 12 | // You may obtain a copy of the License at 13 | // 14 | // http://www.apache.org/licenses/LICENSE-2.0 15 | // 16 | // Unless required by applicable law or agreed to in writing, software 17 | // distributed under the License is distributed on an "AS IS" BASIS, 18 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | // See the License for the specific language governing permissions and 20 | // limitations under the License. 21 | 22 | /** @file */ 23 | 24 | #ifndef LOG4CPLUS_SPI_ROOT_LOGGER_HEADER_ 25 | #define LOG4CPLUS_SPI_ROOT_LOGGER_HEADER_ 26 | 27 | #include 28 | 29 | #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE) 30 | #pragma once 31 | #endif 32 | 33 | #include 34 | 35 | namespace log4cplus { 36 | namespace spi { 37 | 38 | /** 39 | * RootLogger sits at the top of the logger hierachy. It is a 40 | * regular logger except that it provides several guarantees. 41 | * 42 | * First, it cannot be assigned a NOT_SET_LOG_LEVEL 43 | * LogLevel. Second, since root logger cannot have a parent, the 44 | * getChainedLogLevel method always returns the value of the 45 | * ll field without walking the hierarchy. 46 | */ 47 | class LOG4CPLUS_EXPORT RootLogger : public LoggerImpl { 48 | public: 49 | // Ctors 50 | /** 51 | * The root logger names itself as "root". However, the root 52 | * logger cannot be retrieved by name. 53 | */ 54 | RootLogger(Hierarchy& h, LogLevel ll); 55 | 56 | // Methods 57 | /** 58 | * Return the assigned LogLevel value without walking the logger 59 | * hierarchy. 60 | */ 61 | virtual LogLevel getChainedLogLevel() const; 62 | 63 | /** 64 | * Setting a NOT_SET_LOG_LEVEL value to the LogLevel of the root logger 65 | * may have catastrophic results. We prevent this here. 66 | */ 67 | void setLogLevel(LogLevel ll); 68 | 69 | }; 70 | 71 | } // end namespace spi 72 | } // end namespace log4cplus 73 | 74 | #endif // LOG4CPLUS_SPI_ROOT_LOGGER_HEADER_ 75 | 76 | -------------------------------------------------------------------------------- /logging/log4cplus/internal/env.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // Module: Log4CPLUS 3 | // File: env.h 4 | // Created: 7/2010 5 | // Author: Vaclav Haisman 6 | // 7 | // 8 | // Copyright (C) 2010-2013, Vaclav Haisman. All rights reserved. 9 | // 10 | // Redistribution and use in source and binary forms, with or without modifica- 11 | // tion, are permitted provided that the following conditions are met: 12 | // 13 | // 1. Redistributions of source code must retain the above copyright notice, 14 | // this list of conditions and the following disclaimer. 15 | // 16 | // 2. Redistributions in binary form must reproduce the above copyright notice, 17 | // this list of conditions and the following disclaimer in the documentation 18 | // and/or other materials provided with the distribution. 19 | // 20 | // THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 21 | // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 22 | // FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 23 | // APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 24 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- 25 | // DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 26 | // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 27 | // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 29 | // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | #ifndef LOG4CPLUS_INTERNAL_ENV_H 32 | #define LOG4CPLUS_INTERNAL_ENV_H 33 | 34 | #include 35 | 36 | #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE) 37 | #pragma once 38 | #endif 39 | 40 | #include 41 | 42 | #if defined (_WIN32) 43 | #include 44 | #endif 45 | #ifdef LOG4CPLUS_HAVE_SYS_TYPES_H 46 | #include 47 | #endif 48 | #ifdef LOG4CPLUS_HAVE_UNISTD_H 49 | #include 50 | #endif 51 | 52 | 53 | namespace log4cplus { namespace internal { 54 | 55 | 56 | bool get_env_var (tstring & value, tstring const & name); 57 | bool parse_bool (bool & val, tstring const & str); 58 | 59 | inline 60 | #if defined (_WIN32) 61 | DWORD 62 | get_process_id () 63 | { 64 | return GetCurrentProcessId (); 65 | } 66 | 67 | #elif defined (LOG4CPLUS_HAVE_GETPID) 68 | pid_t 69 | get_process_id () 70 | { 71 | return getpid (); 72 | } 73 | 74 | #else 75 | int 76 | get_process_id () 77 | { 78 | return 0; 79 | } 80 | 81 | #endif 82 | 83 | 84 | } } // namespace log4cplus { namespace internal { 85 | 86 | 87 | #endif // LOG4CPLUS_INTERNAL_ENV_H 88 | -------------------------------------------------------------------------------- /logging/log4cplus/thread/threads.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // Module: Log4CPLUS 3 | // File: threads.h 4 | // Created: 6/2001 5 | // Author: Tad E. Smith 6 | // 7 | // 8 | // Copyright 2001-2013 Tad E. Smith 9 | // 10 | // Licensed under the Apache License, Version 2.0 (the "License"); 11 | // you may not use this file except in compliance with the License. 12 | // You may obtain a copy of the License at 13 | // 14 | // http://www.apache.org/licenses/LICENSE-2.0 15 | // 16 | // Unless required by applicable law or agreed to in writing, software 17 | // distributed under the License is distributed on an "AS IS" BASIS, 18 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | // See the License for the specific language governing permissions and 20 | // limitations under the License. 21 | 22 | /** @file */ 23 | 24 | #ifndef LOG4CPLUS_THREADS_HEADER_ 25 | #define LOG4CPLUS_THREADS_HEADER_ 26 | 27 | #include 28 | 29 | #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE) 30 | #pragma once 31 | #endif 32 | 33 | #include 34 | #include 35 | 36 | 37 | namespace log4cplus { namespace thread { 38 | 39 | 40 | LOG4CPLUS_EXPORT log4cplus::tstring const & getCurrentThreadName(); 41 | LOG4CPLUS_EXPORT log4cplus::tstring const & getCurrentThreadName2(); 42 | LOG4CPLUS_EXPORT void yield(); 43 | LOG4CPLUS_EXPORT void blockAllSignals(); 44 | 45 | 46 | #ifndef LOG4CPLUS_SINGLE_THREADED 47 | 48 | class ThreadImplBase 49 | : public virtual log4cplus::helpers::SharedObject 50 | { 51 | protected: 52 | virtual ~ThreadImplBase (); 53 | }; 54 | 55 | 56 | /** 57 | * There are many cross-platform C++ Threading libraries. The goal of 58 | * this class is not to replace (or match in functionality) those 59 | * libraries. The goal of this class is to provide a simple Threading 60 | * class with basic functionality. 61 | */ 62 | class LOG4CPLUS_EXPORT AbstractThread 63 | : public virtual log4cplus::helpers::SharedObject 64 | { 65 | public: 66 | AbstractThread(); 67 | bool isRunning() const; 68 | virtual void start(); 69 | void join () const; 70 | virtual void run() = 0; 71 | 72 | protected: 73 | // Force objects to be constructed on the heap 74 | virtual ~AbstractThread(); 75 | 76 | private: 77 | helpers::SharedObjectPtr thread; 78 | 79 | // Disallow copying of instances of this class. 80 | AbstractThread(const AbstractThread&); 81 | AbstractThread& operator=(const AbstractThread&); 82 | }; 83 | 84 | typedef helpers::SharedObjectPtr AbstractThreadPtr; 85 | 86 | 87 | #endif // LOG4CPLUS_SINGLE_THREADED 88 | 89 | 90 | } } // namespace log4cplus { namespace thread { 91 | 92 | 93 | #endif // LOG4CPLUS_THREADS_HEADER_ 94 | 95 | -------------------------------------------------------------------------------- /include/srt/srt_compat.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SRT - Secure, Reliable, Transport 3 | * Copyright (c) 2018 Haivision Systems Inc. 4 | * 5 | * This Source Code Form is subject to the terms of the Mozilla Public 6 | * License, v. 2.0. If a copy of the MPL was not distributed with this 7 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 8 | * 9 | */ 10 | 11 | 12 | /***************************************************************************** 13 | written by 14 | Haivision Systems Inc. 15 | *****************************************************************************/ 16 | 17 | #ifndef HAISRT_COMPAT_H__ 18 | #define HAISRT_COMPAT_H__ 19 | 20 | #include 21 | #include 22 | 23 | #ifndef SRT_API 24 | #ifdef _WIN32 25 | #ifndef __MINGW__ 26 | #ifdef SRT_DYNAMIC 27 | #ifdef SRT_EXPORTS 28 | #define SRT_API __declspec(dllexport) 29 | #else 30 | #define SRT_API __declspec(dllimport) 31 | #endif 32 | #else 33 | #define SRT_API 34 | #endif 35 | #else 36 | #define SRT_API 37 | #endif 38 | #else 39 | #define SRT_API __attribute__ ((visibility("default"))) 40 | #endif 41 | #endif 42 | 43 | #ifdef _WIN32 44 | // https://msdn.microsoft.com/en-us/library/tcxf1dw6.aspx 45 | // printf() Format for ssize_t 46 | #if !defined(PRIzd) 47 | #define PRIzd "Id" 48 | #endif 49 | // printf() Format for size_t 50 | #if !defined(PRIzu) 51 | #define PRIzu "Iu" 52 | #endif 53 | #else 54 | // http://www.gnu.org/software/libc/manual/html_node/Integer-Conversions.html 55 | // printf() Format for ssize_t 56 | #if !defined(PRIzd) 57 | #define PRIzd "zd" 58 | #endif 59 | // printf() Format for size_t 60 | #if !defined(PRIzu) 61 | #define PRIzu "zu" 62 | #endif 63 | #endif 64 | 65 | 66 | #ifdef __cplusplus 67 | extern "C" { 68 | #endif 69 | 70 | /* Ensures that we store the error in the buffer and return the bufer. */ 71 | SRT_API const char * SysStrError(int errnum, char * buf, size_t buflen); 72 | 73 | #ifdef __cplusplus 74 | } // extern C 75 | 76 | 77 | // Extra C++ stuff. Included only in C++ mode. 78 | 79 | 80 | #include 81 | inline std::string SysStrError(int errnum) 82 | { 83 | char buf[1024]; 84 | return SysStrError(errnum, buf, 1024); 85 | } 86 | 87 | inline struct tm SysLocalTime(time_t tt) 88 | { 89 | struct tm tms; 90 | memset(&tms, 0, sizeof tms); 91 | #ifdef _WIN32 92 | errno_t rr = localtime_s(&tms, &tt); 93 | if (rr == 0) 94 | return tms; 95 | #else 96 | tms = *localtime_r(&tt, &tms); 97 | #endif 98 | 99 | return tms; 100 | } 101 | 102 | 103 | #endif // defined C++ 104 | 105 | #endif // HAISRT_COMPAT_H__ 106 | -------------------------------------------------------------------------------- /logging/log4cplus/mdc.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // Copyright (C) 2010-2013, Vaclav Haisman. All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without modifica- 5 | // tion, are permitted provided that the following conditions are met: 6 | // 7 | // 1. Redistributions of source code must retain the above copyright notice, 8 | // this list of conditions and the following disclaimer. 9 | // 10 | // 2. Redistributions in binary form must reproduce the above copyright notice, 11 | // this list of conditions and the following disclaimer in the documentation 12 | // and/or other materials provided with the distribution. 13 | // 14 | // THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 15 | // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 16 | // FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 17 | // APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 18 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- 19 | // DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 20 | // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 21 | // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | 25 | #ifndef LOG4CPLUS_MDC_H_HEADER 26 | #define LOG4CPLUS_MDC_H_HEADER 27 | 28 | #include 29 | 30 | #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE) 31 | #pragma once 32 | #endif 33 | 34 | #include 35 | 36 | #include 37 | 38 | 39 | namespace log4cplus 40 | { 41 | 42 | 43 | typedef std::map MappedDiagnosticContextMap; 44 | 45 | 46 | class LOG4CPLUS_EXPORT MDC 47 | { 48 | public: 49 | /** 50 | * Clear any nested diagnostic information if any. This method is 51 | * useful in cases where the same thread can be potentially used 52 | * over and over in different unrelated contexts. 53 | */ 54 | void clear(); 55 | 56 | void put (tstring const & key, tstring const & value); 57 | bool get (tstring * value, tstring const & key) const; 58 | void remove (tstring const & key); 59 | 60 | MappedDiagnosticContextMap const & getContext () const; 61 | 62 | // Public ctor and dtor but only to be used by internal::DefaultContext. 63 | MDC (); 64 | virtual ~MDC (); 65 | 66 | private: 67 | LOG4CPLUS_PRIVATE static MappedDiagnosticContextMap * getPtr (); 68 | }; 69 | 70 | 71 | LOG4CPLUS_EXPORT MDC & getMDC (); 72 | 73 | 74 | } // namespace log4cplus 75 | 76 | 77 | #endif // LOG4CPLUS_MDC_H_HEADER 78 | -------------------------------------------------------------------------------- /logging/log4cplus/nteventlogappender.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // Module: Log4CPLUS 3 | // File: nteventlogappender.h 4 | // Created: 4/2003 5 | // Author: Michael CATANZARITI 6 | // 7 | // Copyright 2003-2013 Michael CATANZARITI 8 | // 9 | // Licensed under the Apache License, Version 2.0 (the "License"); 10 | // you may not use this file except in compliance with the License. 11 | // You may obtain a copy of the License at 12 | // 13 | // http://www.apache.org/licenses/LICENSE-2.0 14 | // 15 | // Unless required by applicable law or agreed to in writing, software 16 | // distributed under the License is distributed on an "AS IS" BASIS, 17 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | // See the License for the specific language governing permissions and 19 | // limitations under the License. 20 | 21 | /** @file */ 22 | 23 | #ifndef LOG4CPLUS_NT_EVENT_LOG_APPENDER_HEADER_ 24 | #define LOG4CPLUS_NT_EVENT_LOG_APPENDER_HEADER_ 25 | 26 | #include 27 | 28 | #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE) 29 | #pragma once 30 | #endif 31 | 32 | #if defined (LOG4CPLUS_HAVE_NT_EVENT_LOG) 33 | 34 | #include 35 | #include 36 | 37 | 38 | namespace log4cplus { 39 | 40 | /** 41 | * Appends log events to NT EventLog. 42 | */ 43 | class LOG4CPLUS_EXPORT NTEventLogAppender : public Appender { 44 | public: 45 | // ctors 46 | NTEventLogAppender(const log4cplus::tstring& server, 47 | const log4cplus::tstring& log, 48 | const log4cplus::tstring& source); 49 | NTEventLogAppender(const log4cplus::helpers::Properties & properties); 50 | 51 | // dtor 52 | virtual ~NTEventLogAppender(); 53 | 54 | // public Methods 55 | virtual void close(); 56 | 57 | protected: 58 | virtual void append(const spi::InternalLoggingEvent& event); 59 | virtual WORD getEventType(const spi::InternalLoggingEvent& event); 60 | virtual WORD getEventCategory(const spi::InternalLoggingEvent& event); 61 | void init(); 62 | 63 | /* 64 | * Add this source with appropriate configuration keys to the registry. 65 | */ 66 | void addRegistryInfo(); 67 | 68 | // Data 69 | log4cplus::tstring server; 70 | log4cplus::tstring log; 71 | log4cplus::tstring source; 72 | HANDLE hEventLog; 73 | SID* pCurrentUserSID; 74 | 75 | private: 76 | // Disallow copying of instances of this class 77 | NTEventLogAppender(const NTEventLogAppender&); 78 | NTEventLogAppender& operator=(const NTEventLogAppender&); 79 | }; 80 | 81 | } // end namespace log4cplus 82 | 83 | #endif // LOG4CPLUS_HAVE_NT_EVENT_LOG 84 | #endif //LOG4CPLUS_NT_EVENT_LOG_APPENDER_HEADER_ 85 | -------------------------------------------------------------------------------- /logging/log4cplus/consoleappender.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // Module: Log4CPLUS 3 | // File: consoleappender.h 4 | // Created: 6/2001 5 | // Author: Tad E. Smith 6 | // 7 | // 8 | // Copyright 2001-2013 Tad E. Smith 9 | // 10 | // Licensed under the Apache License, Version 2.0 (the "License"); 11 | // you may not use this file except in compliance with the License. 12 | // You may obtain a copy of the License at 13 | // 14 | // http://www.apache.org/licenses/LICENSE-2.0 15 | // 16 | // Unless required by applicable law or agreed to in writing, software 17 | // distributed under the License is distributed on an "AS IS" BASIS, 18 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | // See the License for the specific language governing permissions and 20 | // limitations under the License. 21 | 22 | /** @file */ 23 | 24 | #ifndef LOG4CPLUS_CONSOLE_APPENDER_HEADER_ 25 | #define LOG4CPLUS_CONSOLE_APPENDER_HEADER_ 26 | 27 | #include 28 | 29 | #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE) 30 | #pragma once 31 | #endif 32 | 33 | #include 34 | 35 | namespace log4cplus { 36 | /** 37 | * ConsoleAppender appends log events to std::cout or 38 | * std::cerr using a layout specified by the 39 | * user. The default target is std::cout. 40 | * 41 | *

Properties

42 | *
43 | *
logToStdErr
44 | *
When it is set true, the output stream will be 45 | * std::cerr instead of std::cout.
46 | * 47 | *
ImmediateFlush
48 | *
When it is set true, output stream will be flushed after 49 | * each appended event.
50 | * 51 | *
52 | * \sa Appender 53 | */ 54 | class LOG4CPLUS_EXPORT ConsoleAppender : public Appender { 55 | public: 56 | // Ctors 57 | ConsoleAppender(bool logToStdErr = false, bool immediateFlush = false); 58 | ConsoleAppender(const log4cplus::helpers::Properties & properties); 59 | 60 | // Dtor 61 | ~ConsoleAppender(); 62 | 63 | // Methods 64 | virtual void close(); 65 | 66 | //! This mutex is used by ConsoleAppender and helpers::LogLog 67 | //! classes to synchronize output to console. 68 | static log4cplus::thread::Mutex const & getOutputMutex(); 69 | 70 | protected: 71 | virtual void append(const spi::InternalLoggingEvent& event); 72 | 73 | // Data 74 | bool logToStdErr; 75 | /** 76 | * Immediate flush means that the underlying output stream 77 | * will be flushed at the end of each append operation. 78 | */ 79 | bool immediateFlush; 80 | }; 81 | 82 | } // end namespace log4cplus 83 | 84 | #endif // LOG4CPLUS_CONSOLE_APPENDER_HEADER_ 85 | 86 | -------------------------------------------------------------------------------- /logging/log4cplus/log4judpappender.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // Module: LOG4CPLUS 3 | // File: log4judpappender.h 4 | // Created: 7/2012 5 | // Author: Siva Chandran P 6 | // 7 | // 8 | // Copyright 2012-2013 Siva Chandran P 9 | // 10 | // Licensed under the Apache License, Version 2.0 (the "License"); 11 | // you may not use this file except in compliance with the License. 12 | // You may obtain a copy of the License at 13 | // 14 | // http://www.apache.org/licenses/LICENSE-2.0 15 | // 16 | // Unless required by applicable law or agreed to in writing, software 17 | // distributed under the License is distributed on an "AS IS" BASIS, 18 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | // See the License for the specific language governing permissions and 20 | // limitations under the License. 21 | 22 | /** @file */ 23 | 24 | #ifndef LOG4CPLUS_LOG4J_UDP_APPENDER_HEADER_ 25 | #define LOG4CPLUS_LOG4J_UDP_APPENDER_HEADER_ 26 | 27 | #include 28 | #include 29 | #include 30 | 31 | namespace log4cplus { 32 | 33 | /** 34 | * Sends log events as Log4j XML to a remote a log server. 35 | * 36 | * The Log4jUdpAppender has the following properties: 37 | * 38 | *
    39 | *
  • Remote logging is non-intrusive as far as the log event 40 | * is concerned. In other words, the event will be logged with 41 | * the same time stamp, NDC, location info as if it were logged 42 | * locally by the client.
  • 43 | * 44 | *
  • Remote logging uses the UDP protocol.
  • 45 | *
46 | * 47 | *

Properties

48 | *
49 | *
host
50 | *
Remote host name to connect and send events to.
51 | * 52 | *
port
53 | *
Port on remote host to send events to.
54 | * 55 | *
56 | */ 57 | class LOG4CPLUS_EXPORT Log4jUdpAppender : public Appender { 58 | public: 59 | // Ctors 60 | Log4jUdpAppender(const log4cplus::tstring& host, int port); 61 | Log4jUdpAppender(const log4cplus::helpers::Properties & properties); 62 | 63 | // Dtor 64 | ~Log4jUdpAppender(); 65 | 66 | // Methods 67 | virtual void close(); 68 | 69 | protected: 70 | void openSocket(); 71 | virtual void append(const spi::InternalLoggingEvent& event); 72 | 73 | // Data 74 | log4cplus::helpers::Socket socket; 75 | log4cplus::tstring host; 76 | int port; 77 | 78 | private: 79 | // Disallow copying of instances of this class 80 | Log4jUdpAppender(const Log4jUdpAppender&); 81 | Log4jUdpAppender& operator=(const Log4jUdpAppender&); 82 | }; 83 | } // end namespace log4cplus 84 | 85 | #endif // LOG4CPLUS_LOG4J_UDP_APPENDER_HEADER_ 86 | 87 | -------------------------------------------------------------------------------- /logging/log4cplus/clogger.h: -------------------------------------------------------------------------------- 1 | // -*- C -*- 2 | /** 3 | * Module: Log4CPLUS 4 | * File: clogger.h 5 | * Created: 01/2011 6 | * Author: Jens Rehsack 7 | * 8 | * 9 | * Copyright 2011-2013 Jens Rehsack & Tad E. Smith 10 | * 11 | * Licensed under the Apache License, Version 2.0 (the "License"); 12 | * you may not use this file except in compliance with the License. 13 | * You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, software 18 | * distributed under the License is distributed on an "AS IS" BASIS, 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | * See the License for the specific language governing permissions and 21 | * limitations under the License. 22 | */ 23 | 24 | /** @file 25 | * This header defines the C API for log4cplus and the logging macros. */ 26 | 27 | #ifndef LOG4CPLUS_CLOGGERHEADER_ 28 | #define LOG4CPLUS_CLOGGERHEADER_ 29 | 30 | #include 31 | 32 | #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE) 33 | #pragma once 34 | #endif 35 | 36 | 37 | #ifdef __cplusplus 38 | extern "C" 39 | { 40 | #endif 41 | 42 | // TODO UNICDE capable 43 | 44 | typedef void *logger_t; 45 | typedef int loglevel_t; 46 | 47 | #define L4CP_OFF_LOG_LEVEL 60000 48 | #define L4CP_FATAL_LOG_LEVEL 50000 49 | #define L4CP_ERROR_LOG_LEVEL 40000 50 | #define L4CP_WARN_LOG_LEVEL 30000 51 | #define L4CP_INFO_LOG_LEVEL 20000 52 | #define L4CP_DEBUG_LOG_LEVEL 10000 53 | #define L4CP_TRACE_LOG_LEVEL 0 54 | #define L4CP_ALL_LOG_LEVEL TRACE_LOG_LEVEL 55 | #define L4CP_NOT_SET_LOG_LEVEL -1 56 | 57 | #ifdef UNICODE 58 | # define LOG4CPLUS_TEXT2(STRING) L##STRING 59 | typedef wchar_t log4cplus_char_t; 60 | #else 61 | # define LOG4CPLUS_TEXT2(STRING) STRING 62 | typedef char log4cplus_char_t; 63 | #endif // UNICODE 64 | #define LOG4CPLUS_TEXT(STRING) LOG4CPLUS_TEXT2(STRING) 65 | 66 | LOG4CPLUS_EXPORT int log4cplus_file_configure(const log4cplus_char_t *pathname); 67 | LOG4CPLUS_EXPORT int log4cplus_str_configure(const log4cplus_char_t *config); 68 | LOG4CPLUS_EXPORT int log4cplus_basic_configure(void); 69 | LOG4CPLUS_EXPORT void log4cplus_shutdown(void); 70 | 71 | LOG4CPLUS_EXPORT int log4cplus_logger_exists(const log4cplus_char_t *name); 72 | LOG4CPLUS_EXPORT int log4cplus_logger_is_enabled_for( 73 | const log4cplus_char_t *name, loglevel_t ll); 74 | LOG4CPLUS_EXPORT int log4cplus_logger_log(const log4cplus_char_t *name, 75 | loglevel_t ll, const log4cplus_char_t *msgfmt, ...) 76 | LOG4CPLUS_FORMAT_ATTRIBUTE (__printf__, 3, 4); 77 | LOG4CPLUS_EXPORT int log4cplus_logger_force_log(const log4cplus_char_t *name, 78 | loglevel_t ll, const log4cplus_char_t *msgfmt, ...) 79 | LOG4CPLUS_FORMAT_ATTRIBUTE (__printf__, 3, 4); 80 | 81 | #ifdef __cplusplus 82 | } 83 | #endif 84 | 85 | #endif /*?LOG4CPLUS_CLOGGERHEADER_*/ 86 | -------------------------------------------------------------------------------- /logging/log4cplus/spi/appenderattachable.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // Module: Log4CPLUS 3 | // File: appenderattachable.h 4 | // Created: 6/2001 5 | // Author: Tad E. Smith 6 | // 7 | // 8 | // Copyright 2001-2013 Tad E. Smith 9 | // 10 | // Licensed under the Apache License, Version 2.0 (the "License"); 11 | // you may not use this file except in compliance with the License. 12 | // You may obtain a copy of the License at 13 | // 14 | // http://www.apache.org/licenses/LICENSE-2.0 15 | // 16 | // Unless required by applicable law or agreed to in writing, software 17 | // distributed under the License is distributed on an "AS IS" BASIS, 18 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | // See the License for the specific language governing permissions and 20 | // limitations under the License. 21 | 22 | /** @file */ 23 | 24 | #ifndef LOG4CPLUS_SPI_APPENDER_ATTACHABLE_HEADER_ 25 | #define LOG4CPLUS_SPI_APPENDER_ATTACHABLE_HEADER_ 26 | 27 | #include 28 | 29 | #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE) 30 | #pragma once 31 | #endif 32 | 33 | #include 34 | #include 35 | #include 36 | #include 37 | 38 | namespace log4cplus { 39 | // Forward Declarations 40 | typedef helpers::SharedObjectPtr SharedAppenderPtr; 41 | typedef std::vector SharedAppenderPtrList; 42 | 43 | namespace spi { 44 | 45 | /** 46 | * This Interface is for attaching Appenders to objects. 47 | */ 48 | class LOG4CPLUS_EXPORT AppenderAttachable { 49 | public: 50 | // Methods 51 | /** 52 | * Add an appender. 53 | */ 54 | virtual void addAppender(SharedAppenderPtr newAppender) = 0; 55 | 56 | /** 57 | * Get all previously added appenders as an Enumeration. 58 | */ 59 | virtual SharedAppenderPtrList getAllAppenders() = 0; 60 | 61 | /** 62 | * Get an appender by name. 63 | */ 64 | virtual SharedAppenderPtr getAppender(const log4cplus::tstring& name) = 0; 65 | 66 | /** 67 | * Remove all previously added appenders. 68 | */ 69 | virtual void removeAllAppenders() = 0; 70 | 71 | /** 72 | * Remove the appender passed as parameter from the list of appenders. 73 | */ 74 | virtual void removeAppender(SharedAppenderPtr appender) = 0; 75 | 76 | /** 77 | * Remove the appender with the name passed as parameter from the 78 | * list of appenders. 79 | */ 80 | virtual void removeAppender(const log4cplus::tstring& name) = 0; 81 | 82 | // Dtor 83 | virtual ~AppenderAttachable() = 0; 84 | }; 85 | 86 | } // end namespace spi 87 | } // end namespace log4cplus 88 | 89 | #endif // LOG4CPLUS_SPI_APPENDER_ATTACHABLE_HEADER_ 90 | 91 | -------------------------------------------------------------------------------- /logging/log4cplus/asyncappender.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // Module: Log4cplus 3 | // File: asyncappender.h 4 | // Created: 1/2009 5 | // Author: Vaclav Haisman 6 | // 7 | // 8 | // Copyright (C) 2009-2013, Vaclav Haisman. All rights reserved. 9 | // 10 | // Redistribution and use in source and binary forms, with or without modifica- 11 | // tion, are permitted provided that the following conditions are met: 12 | // 13 | // 1. Redistributions of source code must retain the above copyright notice, 14 | // this list of conditions and the following disclaimer. 15 | // 16 | // 2. Redistributions in binary form must reproduce the above copyright notice, 17 | // this list of conditions and the following disclaimer in the documentation 18 | // and/or other materials provided with the distribution. 19 | // 20 | // THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 21 | // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 22 | // FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 23 | // APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 24 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- 25 | // DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 26 | // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 27 | // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 29 | // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | 32 | // 33 | 34 | /** @file */ 35 | 36 | #ifndef LOG4CPLUS_ASYNCAPPENDER_H 37 | #define LOG4CPLUS_ASYNCAPPENDER_H 38 | 39 | #include 40 | 41 | #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE) 42 | #pragma once 43 | #endif 44 | 45 | #ifndef LOG4CPLUS_SINGLE_THREADED 46 | 47 | #include 48 | #include 49 | #include 50 | #include 51 | 52 | 53 | namespace log4cplus 54 | { 55 | 56 | 57 | class LOG4CPLUS_EXPORT AsyncAppender 58 | : public Appender 59 | , public helpers::AppenderAttachableImpl 60 | { 61 | public: 62 | AsyncAppender (SharedAppenderPtr const & app, unsigned max_len); 63 | AsyncAppender (helpers::Properties const &); 64 | virtual ~AsyncAppender (); 65 | 66 | virtual void close (); 67 | 68 | protected: 69 | virtual void append (spi::InternalLoggingEvent const &); 70 | 71 | void init_queue_thread (unsigned); 72 | 73 | thread::AbstractThreadPtr queue_thread; 74 | thread::QueuePtr queue; 75 | 76 | private: 77 | AsyncAppender (AsyncAppender const &); 78 | AsyncAppender & operator = (AsyncAppender const &); 79 | }; 80 | 81 | 82 | typedef helpers::SharedObjectPtr AsyncAppenderPtr; 83 | 84 | 85 | } // namespace log4cplus 86 | 87 | 88 | #endif // LOG4CPLUS_SINGLE_THREADED 89 | 90 | #endif // LOG4CPLUS_ASYNCAPPENDER_H 91 | -------------------------------------------------------------------------------- /logging/log4cplus/tstring.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // Module: Log4CPLUS 3 | // File: tstring.h 4 | // Created: 4/2003 5 | // Author: Tad E. Smith 6 | // 7 | // 8 | // Copyright 2003-2013 Tad E. Smith 9 | // 10 | // Licensed under the Apache License, Version 2.0 (the "License"); 11 | // you may not use this file except in compliance with the License. 12 | // You may obtain a copy of the License at 13 | // 14 | // http://www.apache.org/licenses/LICENSE-2.0 15 | // 16 | // Unless required by applicable law or agreed to in writing, software 17 | // distributed under the License is distributed on an "AS IS" BASIS, 18 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | // See the License for the specific language governing permissions and 20 | // limitations under the License. 21 | 22 | /** @file */ 23 | 24 | #ifndef LOG4CPLUS_TSTRING_HEADER_ 25 | #define LOG4CPLUS_TSTRING_HEADER_ 26 | 27 | #include 28 | 29 | #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE) 30 | #pragma once 31 | #endif 32 | 33 | #include 34 | #include 35 | 36 | namespace log4cplus 37 | { 38 | 39 | typedef std::basic_string tstring; 40 | 41 | 42 | namespace helpers 43 | { 44 | 45 | inline 46 | std::string 47 | tostring (char const * str) 48 | { 49 | return std::string (str); 50 | } 51 | 52 | inline 53 | std::string 54 | tostring (std::string const & str) 55 | { 56 | return str; 57 | } 58 | 59 | inline 60 | std::string const & 61 | tostring (std::string & str) 62 | { 63 | return str; 64 | } 65 | 66 | #ifdef LOG4CPLUS_HAVE_RVALUE_REFS 67 | inline 68 | std::string 69 | tostring (std::string && str) 70 | { 71 | return std::move (str); 72 | } 73 | 74 | #endif 75 | 76 | 77 | 78 | inline 79 | std::wstring 80 | towstring (wchar_t const * str) 81 | { 82 | return std::wstring (str); 83 | } 84 | 85 | inline 86 | std::wstring 87 | towstring (std::wstring const & str) 88 | { 89 | return str; 90 | } 91 | 92 | inline 93 | std::wstring const & 94 | towstring (std::wstring & str) 95 | { 96 | return str; 97 | } 98 | 99 | #ifdef LOG4CPLUS_HAVE_RVALUE_REFS 100 | inline 101 | std::wstring 102 | towstring (std::wstring && str) 103 | { 104 | return std::move (str); 105 | } 106 | 107 | #endif 108 | 109 | LOG4CPLUS_EXPORT std::string tostring(const std::wstring&); 110 | LOG4CPLUS_EXPORT std::string tostring(wchar_t const *); 111 | 112 | LOG4CPLUS_EXPORT std::wstring towstring(const std::string&); 113 | LOG4CPLUS_EXPORT std::wstring towstring(char const *); 114 | 115 | } // namespace helpers 116 | 117 | #ifdef UNICODE 118 | 119 | #define LOG4CPLUS_C_STR_TO_TSTRING(STRING) log4cplus::helpers::towstring(STRING) 120 | #define LOG4CPLUS_STRING_TO_TSTRING(STRING) log4cplus::helpers::towstring(STRING) 121 | #define LOG4CPLUS_TSTRING_TO_STRING(STRING) log4cplus::helpers::tostring(STRING) 122 | 123 | #else // UNICODE 124 | 125 | #define LOG4CPLUS_C_STR_TO_TSTRING(STRING) std::string(STRING) 126 | #define LOG4CPLUS_STRING_TO_TSTRING(STRING) STRING 127 | #define LOG4CPLUS_TSTRING_TO_STRING(STRING) STRING 128 | 129 | #endif // UNICODE 130 | 131 | } // namespace log4cplus 132 | 133 | 134 | #endif // LOG4CPLUS_TSTRING_HEADER_ 135 | -------------------------------------------------------------------------------- /include/srt/logging_api.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SRT - Secure, Reliable, Transport 3 | * Copyright (c) 2018 Haivision Systems Inc. 4 | * 5 | * This Source Code Form is subject to the terms of the Mozilla Public 6 | * License, v. 2.0. If a copy of the MPL was not distributed with this 7 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 8 | * 9 | */ 10 | 11 | /***************************************************************************** 12 | written by 13 | Haivision Systems Inc. 14 | *****************************************************************************/ 15 | 16 | #ifndef INC__SRT_LOGGING_API_H 17 | #define INC__SRT_LOGGING_API_H 18 | 19 | // These are required for access functions: 20 | // - adding FA (requires set) 21 | // - setting a log stream (requires iostream) 22 | #ifdef __cplusplus 23 | #include 24 | #include 25 | #endif 26 | 27 | #include 28 | #ifdef _WIN32 29 | #include "win/syslog_defs.h" 30 | #else 31 | #include 32 | #endif 33 | 34 | // Syslog is included so that it provides log level names. 35 | // Haivision log standard requires the same names plus extra one: 36 | #ifndef LOG_DEBUG_TRACE 37 | #define LOG_DEBUG_TRACE 8 38 | #endif 39 | // It's unused anyway, just for the record. 40 | #define SRT_LOG_LEVEL_MIN LOG_CRIT 41 | #define SRT_LOG_LEVEL_MAX LOG_DEBUG 42 | 43 | // Flags 44 | #define SRT_LOGF_DISABLE_TIME 1 45 | #define SRT_LOGF_DISABLE_THREADNAME 2 46 | #define SRT_LOGF_DISABLE_SEVERITY 4 47 | #define SRT_LOGF_DISABLE_EOL 8 48 | 49 | // Handler type. 50 | typedef void SRT_LOG_HANDLER_FN(void* opaque, int level, const char* file, int line, const char* area, const char* message); 51 | 52 | #ifdef __cplusplus 53 | namespace logging 54 | { 55 | 56 | 57 | struct LogFA 58 | { 59 | private: 60 | int value; 61 | public: 62 | operator int() const { return value; } 63 | 64 | LogFA(int v): value(v) 65 | { 66 | // Generally this was what it has to be used for. 67 | // Unfortunately it couldn't be agreed with the 68 | //logging_fa_all.insert(v); 69 | } 70 | }; 71 | 72 | const LogFA LOGFA_GENERAL = 0; 73 | 74 | 75 | 76 | namespace LogLevel 77 | { 78 | // There are 3 general levels: 79 | 80 | // A. fatal - this means the application WILL crash. 81 | // B. unexpected: 82 | // - error: this was unexpected for the library 83 | // - warning: this was expected by the library, but may be harmful for the application 84 | // C. expected: 85 | // - note: a significant, but rarely occurring event 86 | // - debug: may occur even very often and enabling it can harm performance 87 | 88 | enum type 89 | { 90 | fatal = LOG_CRIT, 91 | // Fatal vs. Error: with Error, you can still continue. 92 | error = LOG_ERR, 93 | // Error vs. Warning: Warning isn't considered a problem for the library. 94 | warning = LOG_WARNING, 95 | // Warning vs. Note: Note means something unusual, but completely correct behavior. 96 | note = LOG_NOTICE, 97 | // Note vs. Debug: Debug may occur even multiple times in a millisecond. 98 | // (Well, worth noting that Error and Warning potentially also can). 99 | debug = LOG_DEBUG 100 | }; 101 | } 102 | 103 | class Logger; 104 | 105 | } 106 | #endif 107 | 108 | #endif 109 | -------------------------------------------------------------------------------- /logging/log4cplus/spi/objectregistry.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // Module: Log4CPLUS 3 | // File: objectregistry.h 4 | // Created: 3/2003 5 | // Author: Tad E. Smith 6 | // 7 | // 8 | // Copyright 2003-2013 Tad E. Smith 9 | // 10 | // Licensed under the Apache License, Version 2.0 (the "License"); 11 | // you may not use this file except in compliance with the License. 12 | // You may obtain a copy of the License at 13 | // 14 | // http://www.apache.org/licenses/LICENSE-2.0 15 | // 16 | // Unless required by applicable law or agreed to in writing, software 17 | // distributed under the License is distributed on an "AS IS" BASIS, 18 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | // See the License for the specific language governing permissions and 20 | // limitations under the License. 21 | 22 | /** @file */ 23 | 24 | #ifndef LOG4CPLUS_SPI_OBJECT_REGISTRY_HEADER_ 25 | #define LOG4CPLUS_SPI_OBJECT_REGISTRY_HEADER_ 26 | 27 | #include 28 | 29 | #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE) 30 | #pragma once 31 | #endif 32 | 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | 39 | 40 | namespace log4cplus { 41 | namespace spi { 42 | 43 | /** 44 | * This is the base class used to implement the functionality required 45 | * by the ObjectRegistry template class. 46 | */ 47 | class LOG4CPLUS_EXPORT ObjectRegistryBase { 48 | public: 49 | // public methods 50 | /** 51 | * Tests to see whether or not an object is bound in the 52 | * registry as name. 53 | */ 54 | bool exists(const log4cplus::tstring& name) const; 55 | 56 | /** 57 | * Returns the names of all registered objects. 58 | */ 59 | std::vector getAllNames() const; 60 | 61 | protected: 62 | // Ctor and Dtor 63 | ObjectRegistryBase(); 64 | virtual ~ObjectRegistryBase(); 65 | 66 | // protected methods 67 | /** 68 | * Used to enter an object into the registry. (The registry now 69 | * owns object.) 70 | */ 71 | bool putVal(const log4cplus::tstring& name, void* object); 72 | 73 | /** 74 | * Used to retrieve an object from the registry. (The registry 75 | * owns the returned pointer.) 76 | */ 77 | void* getVal(const log4cplus::tstring& name) const; 78 | 79 | /** 80 | * Deletes object. 81 | */ 82 | virtual void deleteObject(void *object) const = 0; 83 | 84 | /** 85 | * Deletes all objects from this registry. 86 | */ 87 | virtual void clear(); 88 | 89 | // Types 90 | typedef std::map ObjectMap; 91 | 92 | // Data 93 | thread::Mutex mutex; 94 | ObjectMap data; 95 | 96 | private: 97 | ObjectRegistryBase (ObjectRegistryBase const &); 98 | ObjectRegistryBase & operator = (ObjectRegistryBase const &); 99 | }; 100 | 101 | } 102 | } 103 | 104 | 105 | #endif // LOG4CPLUS_SPI_OBJECT_REGISTRY_HEADER_ 106 | 107 | -------------------------------------------------------------------------------- /logging/log4cplus/internal/socket.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // Module: Log4CPLUS 3 | // File: socket.h 4 | // Created: 1/2010 5 | // Author: Vaclav Haisman 6 | // 7 | // 8 | // Copyright (C) 2010-2013, Vaclav Haisman. All rights reserved. 9 | // 10 | // Redistribution and use in source and binary forms, with or without modifica- 11 | // tion, are permitted provided that the following conditions are met: 12 | // 13 | // 1. Redistributions of source code must retain the above copyright notice, 14 | // this list of conditions and the following disclaimer. 15 | // 16 | // 2. Redistributions in binary form must reproduce the above copyright notice, 17 | // this list of conditions and the following disclaimer in the documentation 18 | // and/or other materials provided with the distribution. 19 | // 20 | // THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 21 | // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 22 | // FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 23 | // APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 24 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- 25 | // DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 26 | // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 27 | // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 29 | // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | /** @file 32 | * This header contains declaration internal to log4cplus. They must never be 33 | * visible from user accesible headers or exported in DLL/shared libray. 34 | */ 35 | 36 | 37 | #ifndef LOG4CPLUS_INTERNAL_SOCKET_H_ 38 | #define LOG4CPLUS_INTERNAL_SOCKET_H_ 39 | 40 | #include 41 | 42 | #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE) 43 | #pragma once 44 | #endif 45 | 46 | #if ! defined (INSIDE_LOG4CPLUS) 47 | # error "This header must not be be used outside log4cplus' implementation files." 48 | #endif 49 | 50 | #if defined(_WIN32) 51 | #include 52 | #endif 53 | #include 54 | 55 | #include 56 | #ifdef LOG4CPLUS_HAVE_ERRNO_H 57 | #include 58 | #endif 59 | 60 | 61 | namespace log4cplus { 62 | 63 | namespace helpers { 64 | 65 | 66 | #if defined(_WIN32) 67 | typedef SOCKET os_socket_type; 68 | #else 69 | typedef int os_socket_type; 70 | #endif 71 | 72 | 73 | os_socket_type const INVALID_OS_SOCKET_VALUE 74 | #if defined(_WIN32) 75 | = INVALID_SOCKET; 76 | #else 77 | = -1; 78 | #endif 79 | 80 | 81 | static inline 82 | os_socket_type 83 | to_os_socket (SOCKET_TYPE const & x) 84 | { 85 | return static_cast(x); 86 | } 87 | 88 | 89 | static inline 90 | SOCKET_TYPE 91 | to_log4cplus_socket (os_socket_type const & x) 92 | { 93 | return static_cast(x); 94 | } 95 | 96 | 97 | static inline 98 | void 99 | set_last_socket_error (int err) 100 | { 101 | errno = err; 102 | } 103 | 104 | 105 | static inline 106 | int 107 | get_last_socket_error () 108 | { 109 | return errno; 110 | } 111 | 112 | 113 | } // namespace helpers { 114 | 115 | } // namespace log4cplus { 116 | 117 | 118 | #endif // LOG4CPLUS_INTERNAL_SOCKET_H_ 119 | -------------------------------------------------------------------------------- /include/srt/md5.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1999, 2002 Aladdin Enterprises. All rights reserved. 3 | 4 | This software is provided 'as-is', without any express or implied 5 | warranty. In no event will the authors be held liable for any damages 6 | arising from the use of this software. 7 | 8 | Permission is granted to anyone to use this software for any purpose, 9 | including commercial applications, and to alter it and redistribute it 10 | freely, subject to the following restrictions: 11 | 12 | 1. The origin of this software must not be misrepresented; you must not 13 | claim that you wrote the original software. If you use this software 14 | in a product, an acknowledgment in the product documentation would be 15 | appreciated but is not required. 16 | 2. Altered source versions must be plainly marked as such, and must not be 17 | misrepresented as being the original software. 18 | 3. This notice may not be removed or altered from any source distribution. 19 | 20 | L. Peter Deutsch 21 | ghost@aladdin.com 22 | 23 | */ 24 | /* $Id: md5.h,v 1.2 2007/12/24 05:58:37 lilyco Exp $ */ 25 | /* 26 | Independent implementation of MD5 (RFC 1321). 27 | 28 | This code implements the MD5 Algorithm defined in RFC 1321, whose 29 | text is available at 30 | http://www.ietf.org/rfc/rfc1321.txt 31 | The code is derived from the text of the RFC, including the test suite 32 | (section A.5) but excluding the rest of Appendix A. It does not include 33 | any code or documentation that is identified in the RFC as being 34 | copyrighted. 35 | 36 | The original and principal author of md5.h is L. Peter Deutsch 37 | . Other authors are noted in the change history 38 | that follows (in reverse chronological order): 39 | 40 | 2002-04-13 lpd Removed support for non-ANSI compilers; removed 41 | references to Ghostscript; clarified derivation from RFC 1321; 42 | now handles byte order either statically or dynamically. 43 | 1999-11-04 lpd Edited comments slightly for automatic TOC extraction. 44 | 1999-10-18 lpd Fixed typo in header comment (ansi2knr rather than md5); 45 | added conditionalization for C++ compilation from Martin 46 | Purschke . 47 | 1999-05-03 lpd Original version. 48 | */ 49 | 50 | #ifndef md5_INCLUDED 51 | # define md5_INCLUDED 52 | 53 | /* 54 | * This package supports both compile-time and run-time determination of CPU 55 | * byte order. If ARCH_IS_BIG_ENDIAN is defined as 0, the code will be 56 | * compiled to run only on little-endian CPUs; if ARCH_IS_BIG_ENDIAN is 57 | * defined as non-zero, the code will be compiled to run only on big-endian 58 | * CPUs; if ARCH_IS_BIG_ENDIAN is not defined, the code will be compiled to 59 | * run on either big- or little-endian CPUs, but will run slightly less 60 | * efficiently on either one than if ARCH_IS_BIG_ENDIAN is defined. 61 | */ 62 | 63 | typedef unsigned char md5_byte_t; /* 8-bit byte */ 64 | typedef unsigned int md5_word_t; /* 32-bit word */ 65 | 66 | /* Define the state of the MD5 Algorithm. */ 67 | typedef struct md5_state_s { 68 | md5_word_t count[2]; /* message length in bits, lsw first */ 69 | md5_word_t abcd[4]; /* digest buffer */ 70 | md5_byte_t buf[64]; /* accumulate block */ 71 | } md5_state_t; 72 | 73 | #ifdef __cplusplus 74 | extern "C" 75 | { 76 | #endif 77 | 78 | /* Initialize the algorithm. */ 79 | void md5_init(md5_state_t *pms); 80 | 81 | /* Append a string to the message. */ 82 | void md5_append(md5_state_t *pms, const md5_byte_t *data, int nbytes); 83 | 84 | /* Finish the message and return the digest. */ 85 | void md5_finish(md5_state_t *pms, md5_byte_t digest[16]); 86 | 87 | #ifdef __cplusplus 88 | } /* end extern "C" */ 89 | #endif 90 | 91 | #endif /* md5_INCLUDED */ 92 | -------------------------------------------------------------------------------- /logging/log4cplus/win32consoleappender.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // Copyright (C) 2009-2013, Vaclav Haisman. All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without modifica- 5 | // tion, are permitted provided that the following conditions are met: 6 | // 7 | // 1. Redistributions of source code must retain the above copyright notice, 8 | // this list of conditions and the following disclaimer. 9 | // 10 | // 2. Redistributions in binary form must reproduce the above copyright notice, 11 | // this list of conditions and the following disclaimer in the documentation 12 | // and/or other materials provided with the distribution. 13 | // 14 | // THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 15 | // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 16 | // FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 17 | // APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 18 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- 19 | // DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 20 | // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 21 | // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | 25 | #ifndef LOG4CPLUS_WIN32CONSOLEAPPENDER_H 26 | #define LOG4CPLUS_WIN32CONSOLEAPPENDER_H 27 | 28 | #include 29 | 30 | #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE) 31 | #pragma once 32 | #endif 33 | 34 | #if defined(_WIN32) && defined (LOG4CPLUS_HAVE_WIN32_CONSOLE) 35 | 36 | #include 37 | 38 | 39 | namespace log4cplus 40 | { 41 | 42 | /** 43 | * Prints events to Win32 console. 44 | * 45 | *

Properties

46 | *
47 | *
AllocConsole
48 | *
This boolean property specifies whether or not this appender 49 | * will try to allocate new console using the 50 | * AllocConsole() Win32 function.
51 | * 52 | *
logToStdErr
53 | *
When it is set true, the output will be into 54 | * STD_ERROR_HANDLE instead of STD_OUTPUT_HANDLE. 55 | *
56 | * 57 | *
TextColor
58 | *
See MSDN documentation for 59 | * 60 | * Character Attributes. 61 | *
62 | */ 63 | class LOG4CPLUS_EXPORT Win32ConsoleAppender 64 | : public Appender 65 | { 66 | public: 67 | explicit Win32ConsoleAppender (bool allocConsole = true, 68 | bool logToStdErr = false, unsigned int textColor = 0); 69 | Win32ConsoleAppender (helpers::Properties const & properties); 70 | virtual ~Win32ConsoleAppender (); 71 | 72 | virtual void close (); 73 | 74 | protected: 75 | virtual void append (spi::InternalLoggingEvent const &); 76 | 77 | void write_handle (void *, tchar const *, std::size_t); 78 | void write_console (void *, tchar const *, std::size_t); 79 | 80 | bool alloc_console; 81 | bool log_to_std_err; 82 | unsigned int text_color; 83 | 84 | private: 85 | Win32ConsoleAppender (Win32ConsoleAppender const &); 86 | Win32ConsoleAppender & operator = (Win32ConsoleAppender const &); 87 | }; 88 | 89 | } // namespace log4cplus 90 | 91 | #endif 92 | 93 | #endif // LOG4CPLUS_WIN32CONSOLEAPPENDER_H 94 | -------------------------------------------------------------------------------- /logging/log4cplus/qt4debugappender.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // Module: Log4cplus 3 | // File: qt4debugappender.h 4 | // Created: 5/2012 5 | // Author: Vaclav Zeman 6 | // 7 | // 8 | // Copyright (C) 2012-2013, Vaclav Zeman. All rights reserved. 9 | // 10 | // Redistribution and use in source and binary forms, with or without modifica- 11 | // tion, are permitted provided that the following conditions are met: 12 | // 13 | // 1. Redistributions of source code must retain the above copyright notice, 14 | // this list of conditions and the following disclaimer. 15 | // 16 | // 2. Redistributions in binary form must reproduce the above copyright notice, 17 | // this list of conditions and the following disclaimer in the documentation 18 | // and/or other materials provided with the distribution. 19 | // 20 | // THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 21 | // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 22 | // FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 23 | // APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 24 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- 25 | // DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 26 | // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 27 | // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 29 | // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | 32 | // 33 | 34 | /** @file */ 35 | 36 | #ifndef LOG4CPLUS_QT4DEBUGAPPENDER_H 37 | #define LOG4CPLUS_QT4DEBUGAPPENDER_H 38 | 39 | #include 40 | 41 | #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE) 42 | #pragma once 43 | #endif 44 | 45 | #include 46 | 47 | #if defined (_WIN32) 48 | #if defined (log4cplusqt4debugappender_EXPORTS) \ 49 | || defined (log4cplusqt4debugappenderU_EXPORTS) \ 50 | || defined (DLL_EXPORT) 51 | #undef LOG4CPLUS_QT4DEBUGAPPENDER_BUILD_DLL 52 | #define LOG4CPLUS_QT4DEBUGAPPENDER_BUILD_DLL 53 | #endif 54 | #if defined (LOG4CPLUS_QT4DEBUGAPPENDER_BUILD_DLL) 55 | #if defined (INSIDE_LOG4CPLUS_QT4DEBUGAPPENDER) 56 | #define LOG4CPLUS_QT4DEBUGAPPENDER_EXPORT __declspec(dllexport) 57 | #else 58 | #define LOG4CPLUS_QT4DEBUGAPPENDER_EXPORT __declspec(dllimport) 59 | #endif 60 | #else 61 | #define LOG4CPLUS_QT4DEBUGAPPENDER_EXPORT 62 | #endif 63 | #else 64 | #if defined (INSIDE_LOG4CPLUS_QT4DEBUGAPPENDER) 65 | #define LOG4CPLUS_QT4DEBUGAPPENDER_EXPORT LOG4CPLUS_DECLSPEC_EXPORT 66 | #else 67 | #define LOG4CPLUS_QT4DEBUGAPPENDER_EXPORT LOG4CPLUS_DECLSPEC_IMPORT 68 | #endif // defined (INSIDE_LOG4CPLUS_QT4DEBUGAPPENDER) 69 | #endif // !_WIN32 70 | 71 | 72 | namespace log4cplus 73 | { 74 | 75 | 76 | class LOG4CPLUS_QT4DEBUGAPPENDER_EXPORT Qt4DebugAppender 77 | : public Appender 78 | { 79 | public: 80 | Qt4DebugAppender (); 81 | explicit Qt4DebugAppender (helpers::Properties const &); 82 | virtual ~Qt4DebugAppender (); 83 | 84 | virtual void close (); 85 | 86 | static void registerAppender (); 87 | 88 | protected: 89 | virtual void append (spi::InternalLoggingEvent const &); 90 | 91 | private: 92 | Qt4DebugAppender (Qt4DebugAppender const &); 93 | Qt4DebugAppender & operator = (Qt4DebugAppender const &); 94 | }; 95 | 96 | 97 | typedef helpers::SharedObjectPtr Qt4DebugAppenderPtr; 98 | 99 | 100 | } // namespace log4cplus 101 | 102 | 103 | #endif // LOG4CPLUS_QT4DEBUGAPPENDER_H 104 | -------------------------------------------------------------------------------- /logging/log4cplus/thread/impl/threads-impl.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // Module: Log4CPLUS 3 | // File: threads.h 4 | // Created: 6/2001 5 | // Author: Tad E. Smith 6 | // 7 | // 8 | // Copyright 2001-2013 Tad E. Smith 9 | // 10 | // Licensed under the Apache License, Version 2.0 (the "License"); 11 | // you may not use this file except in compliance with the License. 12 | // You may obtain a copy of the License at 13 | // 14 | // http://www.apache.org/licenses/LICENSE-2.0 15 | // 16 | // Unless required by applicable law or agreed to in writing, software 17 | // distributed under the License is distributed on an "AS IS" BASIS, 18 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | // See the License for the specific language governing permissions and 20 | // limitations under the License. 21 | 22 | /** @file */ 23 | 24 | #ifndef LOG4CPLUS_IMPL_THREADS_IMPL_HEADER_ 25 | #define LOG4CPLUS_IMPL_THREADS_IMPL_HEADER_ 26 | 27 | #include 28 | 29 | #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE) 30 | #pragma once 31 | #endif 32 | 33 | #if defined (_WIN32) 34 | #include 35 | #endif 36 | #include 37 | #include 38 | #include 39 | 40 | #if ! defined (INSIDE_LOG4CPLUS) 41 | # error "This header must not be be used outside log4cplus' implementation files." 42 | #endif 43 | 44 | 45 | namespace log4cplus { namespace thread { namespace impl { 46 | 47 | 48 | #if defined (LOG4CPLUS_USE_PTHREADS) 49 | 50 | typedef pthread_t os_handle_type; 51 | typedef pthread_t os_id_type; 52 | 53 | 54 | inline 55 | pthread_t 56 | getCurrentThreadId () 57 | { 58 | return pthread_self (); 59 | } 60 | 61 | 62 | #elif defined (LOG4CPLUS_USE_WIN32_THREADS) 63 | 64 | typedef HANDLE os_handle_type; 65 | typedef DWORD os_id_type; 66 | 67 | 68 | inline 69 | DWORD 70 | getCurrentThreadId () 71 | { 72 | return GetCurrentThreadId (); 73 | } 74 | 75 | 76 | #elif defined (LOG4CPLUS_SINGLE_THREADED) 77 | 78 | typedef void * os_handle_type; 79 | typedef int os_id_type; 80 | 81 | 82 | inline 83 | int 84 | getCurrentThreadId () 85 | { 86 | return 1; 87 | } 88 | 89 | 90 | #endif 91 | 92 | 93 | #ifndef LOG4CPLUS_SINGLE_THREADED 94 | 95 | 96 | struct ThreadStart 97 | { 98 | # ifdef LOG4CPLUS_USE_PTHREADS 99 | static void* threadStartFuncWorker(void *); 100 | # elif defined(LOG4CPLUS_USE_WIN32_THREADS) 101 | static unsigned threadStartFuncWorker(void *); 102 | # endif 103 | }; 104 | 105 | 106 | /** 107 | * There are many cross-platform C++ Threading libraries. The goal of 108 | * this class is not to replace (or match in functionality) those 109 | * libraries. The goal of this class is to provide a simple Threading 110 | * class with basic functionality. 111 | */ 112 | class Thread 113 | : public ThreadImplBase 114 | { 115 | public: 116 | Thread(); 117 | bool isRunning() const; 118 | os_id_type getThreadId() const; 119 | os_handle_type getThreadHandle () const; 120 | void start(); 121 | void join (); 122 | 123 | protected: 124 | // Force objects to be constructed on the heap 125 | virtual ~Thread(); 126 | virtual void run() = 0; 127 | 128 | private: 129 | // Friends. 130 | friend struct ThreadStart; 131 | 132 | enum Flags 133 | { 134 | fRUNNING = 0x01, 135 | fJOINED = 0x02 136 | }; 137 | 138 | unsigned flags; 139 | 140 | os_handle_type handle; 141 | 142 | # if defined(LOG4CPLUS_USE_WIN32_THREADS) 143 | unsigned thread_id; 144 | # endif 145 | 146 | // Disallow copying of instances of this class. 147 | Thread(const Thread&); 148 | Thread& operator=(const Thread&); 149 | }; 150 | 151 | typedef helpers::SharedObjectPtr ThreadPtr; 152 | 153 | 154 | #endif // LOG4CPLUS_SINGLE_THREADED 155 | 156 | 157 | } } } // namespace log4cplus { namespace thread { namespace impl { 158 | 159 | 160 | #endif // LOG4CPLUS_IMPL_THREADS_IMPL_HEADER_ 161 | -------------------------------------------------------------------------------- /logging/log4cplus/syslogappender.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // Module: Log4CPLUS 3 | // File: syslogappender.h 4 | // Created: 6/2001 5 | // Author: Tad E. Smith 6 | // 7 | // 8 | // Copyright 2001-2013 Tad E. Smith 9 | // 10 | // Licensed under the Apache License, Version 2.0 (the "License"); 11 | // you may not use this file except in compliance with the License. 12 | // You may obtain a copy of the License at 13 | // 14 | // http://www.apache.org/licenses/LICENSE-2.0 15 | // 16 | // Unless required by applicable law or agreed to in writing, software 17 | // distributed under the License is distributed on an "AS IS" BASIS, 18 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | // See the License for the specific language governing permissions and 20 | // limitations under the License. 21 | 22 | /** @file */ 23 | 24 | #ifndef LOG4CPLUS_SYSLOG_APPENDER_HEADER_ 25 | #define LOG4CPLUS_SYSLOG_APPENDER_HEADER_ 26 | 27 | #include 28 | 29 | #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE) 30 | #pragma once 31 | #endif 32 | 33 | #include 34 | #include 35 | 36 | 37 | namespace log4cplus 38 | { 39 | 40 | /** 41 | * Appends log events to a file. 42 | * 43 | *

Properties

44 | *
45 | *
ident
46 | *
First argument to openlog(), a string that 47 | * will be prepended to every message.
48 | * 49 | *
facility
50 | *
Facility is used in combination with syslog level in first 51 | * argument to syslog(). It can be one of the supported facility 52 | * names (case insensitive), e.g. auth, cron, kern, mail, news 53 | * etc.
54 | * 55 | *
host
56 | *
Destination syslog host. When this property is specified, 57 | * messages are sent using UDP to destination host, otherwise 58 | * messages are logged to local syslog.
59 | * 60 | *
port
61 | *
Destination port of syslog service on host specified by the 62 | * host property. The default value is port 514.
63 | *
64 | * 65 | * \note Messages sent to remote syslog using UDP are conforming 66 | * to RFC5424. 67 | */ 68 | class LOG4CPLUS_EXPORT SysLogAppender : public Appender { 69 | public: 70 | // Ctors 71 | #if defined (LOG4CPLUS_HAVE_SYSLOG_H) 72 | SysLogAppender(const tstring& ident); 73 | #endif 74 | SysLogAppender(const tstring& ident, const tstring & host, 75 | int port = 514, const tstring & facility = tstring ()); 76 | SysLogAppender(const log4cplus::helpers::Properties & properties); 77 | 78 | // Dtor 79 | virtual ~SysLogAppender(); 80 | 81 | // Methods 82 | virtual void close(); 83 | 84 | protected: 85 | virtual int getSysLogLevel(const LogLevel& ll) const; 86 | virtual void append(const spi::InternalLoggingEvent& event); 87 | #if defined (LOG4CPLUS_HAVE_SYSLOG_H) 88 | void appendLocal(const spi::InternalLoggingEvent& event); 89 | #endif 90 | void appendRemote(const spi::InternalLoggingEvent& event); 91 | 92 | // Data 93 | tstring ident; 94 | int facility; 95 | 96 | typedef void (SysLogAppender:: * AppendFuncType) ( 97 | const spi::InternalLoggingEvent&); 98 | AppendFuncType appendFunc; 99 | 100 | tstring host; 101 | int port; 102 | helpers::Socket syslogSocket; 103 | 104 | static tstring const remoteTimeFormat; 105 | 106 | private: 107 | // Disallow copying of instances of this class 108 | SysLogAppender(const SysLogAppender&); 109 | SysLogAppender& operator=(const SysLogAppender&); 110 | 111 | std::string identStr; 112 | tstring hostname; 113 | }; 114 | 115 | } // end namespace log4cplus 116 | 117 | 118 | #endif // LOG4CPLUS_SYSLOG_APPENDER_HEADER_ 119 | -------------------------------------------------------------------------------- /logging/log4cplus/config/windowsh-inc.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // Module: Log4CPLUS 3 | // File: windowsh-inc.h 4 | // Created: 4/2010 5 | // Author: Vaclav Zeman 6 | // 7 | // 8 | // Copyright (C) 2010-2013, Vaclav Zeman. All rights reserved. 9 | // 10 | // Redistribution and use in source and binary forms, with or without modifica- 11 | // tion, are permitted provided that the following conditions are met: 12 | // 13 | // 1. Redistributions of source code must retain the above copyright notice, 14 | // this list of conditions and the following disclaimer. 15 | // 16 | // 2. Redistributions in binary form must reproduce the above copyright notice, 17 | // this list of conditions and the following disclaimer in the documentation 18 | // and/or other materials provided with the distribution. 19 | // 20 | // THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 21 | // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 22 | // FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 23 | // APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 24 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- 25 | // DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 26 | // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 27 | // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 29 | // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | // NOTE: This file is a fragment intentionally left without include guards. 32 | 33 | #if defined (_WIN32) 34 | #undef WIN32_LEAN_AND_MEAN 35 | #define WIN32_LEAN_AND_MEAN 36 | 37 | #undef NOGDICAPMASKS 38 | #define NOGDICAPMASKS 39 | 40 | #undef NOVIRTUALKEYCODES 41 | #define NOVIRTUALKEYCODES 42 | 43 | #undef NOWINMESSAGES 44 | #define NOWINMESSAGES 45 | 46 | #undef NOWINSTYLES 47 | #define NOWINSTYLES 48 | 49 | #undef NOSYSMETRICS 50 | #define NOSYSMETRICS 51 | 52 | #undef NOMENUS 53 | #define NOMENUS 54 | 55 | #undef NOICONS 56 | #define NOICONS 57 | 58 | #undef NOKEYSTATES 59 | #define NOKEYSTATES 60 | 61 | #undef NOSYSCOMMANDS 62 | #define NOSYSCOMMANDS 63 | 64 | #undef NORASTEROPS 65 | #define NORASTEROPS 66 | 67 | #undef NOSHOWWINDOW 68 | #define NOSHOWWINDOW 69 | 70 | #undef NOATOM 71 | #define NOATOM 72 | 73 | #undef NOCLIPBOARD 74 | #define NOCLIPBOARD 75 | 76 | #undef NOCOLOR 77 | #define NOCOLOR 78 | 79 | #undef NOCTLMGR 80 | #define NOCTLMGR 81 | 82 | #undef NODRAWTEXT 83 | #define NODRAWTEXT 84 | 85 | #undef NOGDI 86 | #define NOGDI 87 | 88 | #undef NOKERNEL 89 | #define NOKERNEL 90 | 91 | #undef NOUSER 92 | #define NOUSER 93 | 94 | #undef NONLS 95 | #define NONLS 96 | 97 | #undef NOMB 98 | #define NOMB 99 | 100 | #undef NOMEMMGR 101 | #define NOMEMMGR 102 | 103 | #undef NOMETAFILE 104 | #define NOMETAFILE 105 | 106 | #undef NOMINMAX 107 | #define NOMINMAX 108 | 109 | #undef NOMSG 110 | #define NOMSG 111 | 112 | #undef NOOPENFILE 113 | #define NOOPENFILE 114 | 115 | #undef NOSCROLL 116 | #define NOSCROLL 117 | 118 | #undef NOSERVICE 119 | #define NOSERVICE 120 | 121 | #undef NOSOUND 122 | #define NOSOUND 123 | 124 | #undef NOTEXTMETRIC 125 | #define NOTEXTMETRIC 126 | 127 | #undef NOWH 128 | #define NOWH 129 | 130 | #undef NOWINOFFSETS 131 | #define NOWINOFFSETS 132 | 133 | #undef NOCOMM 134 | #define NOCOMM 135 | 136 | #undef NOKANJI 137 | #define NOKANJI 138 | 139 | #undef NOHELP 140 | #define NOHELP 141 | 142 | #undef NOPROFILER 143 | #define NOPROFILER 144 | 145 | #undef NODEFERWINDOWPOS 146 | #define NODEFERWINDOWPOS 147 | 148 | #undef NOMCX 149 | #define NOMCX 150 | 151 | #include 152 | #include 153 | #include 154 | #if defined (LOG4CPLUS_HAVE_INTRIN_H) 155 | #include 156 | #endif 157 | #endif 158 | 159 | // NOTE: This file is a fragment intentionally left without include guards. 160 | -------------------------------------------------------------------------------- /logging/log4cplus/helpers/appenderattachableimpl.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // Module: Log4CPLUS 3 | // File: appenderattachableimpl.h 4 | // Created: 6/2001 5 | // Author: Tad E. Smith 6 | // 7 | // 8 | // Copyright 2001-2013 Tad E. Smith 9 | // 10 | // Licensed under the Apache License, Version 2.0 (the "License"); 11 | // you may not use this file except in compliance with the License. 12 | // You may obtain a copy of the License at 13 | // 14 | // http://www.apache.org/licenses/LICENSE-2.0 15 | // 16 | // Unless required by applicable law or agreed to in writing, software 17 | // distributed under the License is distributed on an "AS IS" BASIS, 18 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | // See the License for the specific language governing permissions and 20 | // limitations under the License. 21 | 22 | /** @file */ 23 | 24 | #ifndef LOG4CPLUS_HELPERS_APPENDER_ATTACHABLE_IMPL_HEADER_ 25 | #define LOG4CPLUS_HELPERS_APPENDER_ATTACHABLE_IMPL_HEADER_ 26 | 27 | #include 28 | 29 | #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE) 30 | #pragma once 31 | #endif 32 | 33 | #include 34 | #include 35 | #include 36 | #include 37 | 38 | #include 39 | #include 40 | 41 | 42 | namespace log4cplus { 43 | namespace helpers { 44 | 45 | /** 46 | * This Interface is for attaching Appenders to objects. 47 | */ 48 | class LOG4CPLUS_EXPORT AppenderAttachableImpl 49 | : public log4cplus::spi::AppenderAttachable 50 | { 51 | public: 52 | // Data 53 | thread::Mutex appender_list_mutex; 54 | 55 | // Ctors 56 | AppenderAttachableImpl(); 57 | 58 | // Dtor 59 | virtual ~AppenderAttachableImpl(); 60 | 61 | // Methods 62 | /** 63 | * Add an appender. If the appender is already in the list in 64 | * won't be added again. 65 | */ 66 | virtual void addAppender(SharedAppenderPtr newAppender); 67 | 68 | /** 69 | * Get all previously added appenders as an vectory. 70 | */ 71 | virtual SharedAppenderPtrList getAllAppenders(); 72 | 73 | /** 74 | * Look for an attached appender named as name. 75 | * 76 | * Return the appender with that name if in the list. Return null 77 | * otherwise. 78 | */ 79 | virtual SharedAppenderPtr getAppender(const log4cplus::tstring& name); 80 | 81 | /** 82 | * Remove all previously added appenders. 83 | */ 84 | virtual void removeAllAppenders(); 85 | 86 | /** 87 | * Remove the appender passed as parameter from the list of appenders. 88 | */ 89 | virtual void removeAppender(SharedAppenderPtr appender); 90 | 91 | /** 92 | * Remove the appender with the name passed as parameter from the 93 | * list of appenders. 94 | */ 95 | virtual void removeAppender(const log4cplus::tstring& name); 96 | 97 | /** 98 | * Call the doAppend method on all attached appenders. 99 | */ 100 | int appendLoopOnAppenders(const spi::InternalLoggingEvent& event) const; 101 | 102 | protected: 103 | // Types 104 | typedef std::vector ListType; 105 | 106 | // Data 107 | /** Array of appenders. */ 108 | ListType appenderList; 109 | 110 | private: 111 | AppenderAttachableImpl(AppenderAttachableImpl const &); 112 | AppenderAttachableImpl & operator = (AppenderAttachableImpl const &); 113 | }; // end class AppenderAttachableImpl 114 | 115 | } // end namespace helpers 116 | } // end namespace log4cplus 117 | 118 | #endif // LOG4CPLUS_HELPERS_APPENDER_ATTACHABLE_IMPL_HEADER_ 119 | 120 | -------------------------------------------------------------------------------- /include/srt/netinet_any.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SRT - Secure, Reliable, Transport 3 | * Copyright (c) 2018 Haivision Systems Inc. 4 | * 5 | * This Source Code Form is subject to the terms of the Mozilla Public 6 | * License, v. 2.0. If a copy of the MPL was not distributed with this 7 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 8 | * 9 | */ 10 | 11 | /***************************************************************************** 12 | written by 13 | Haivision Systems Inc. 14 | *****************************************************************************/ 15 | 16 | #ifndef INC__NETINET_ANY_H 17 | #define INC__NETINET_ANY_H 18 | 19 | #include 20 | #include "platform_sys.h" 21 | 22 | // This structure should replace every use of sockaddr and its currently 23 | // used specializations, sockaddr_in and sockaddr_in6. This is to simplify 24 | // the use of the original BSD API that relies on type-violating type casts. 25 | // You can use the instances of sockaddr_any in every place where sockaddr is 26 | // required. 27 | 28 | struct sockaddr_any 29 | { 30 | union 31 | { 32 | sockaddr_in sin; 33 | sockaddr_in6 sin6; 34 | sockaddr sa; 35 | }; 36 | socklen_t len; 37 | 38 | sockaddr_any(int domain = AF_INET) 39 | { 40 | memset(this, 0, sizeof *this); 41 | sa.sa_family = domain; 42 | len = size(); 43 | } 44 | 45 | socklen_t size() const 46 | { 47 | switch (sa.sa_family) 48 | { 49 | case AF_INET: return socklen_t(sizeof sin); 50 | case AF_INET6: return socklen_t(sizeof sin6); 51 | 52 | default: return 0; // fallback, impossible 53 | } 54 | } 55 | 56 | int family() const { return sa.sa_family; } 57 | 58 | // port is in exactly the same location in both sin and sin6 59 | // and has the same size. This is actually yet another common 60 | // field, just not mentioned in the sockaddr structure. 61 | uint16_t& r_port() { return sin.sin_port; } 62 | uint16_t r_port() const { return sin.sin_port; } 63 | int hport() const { return ntohs(sin.sin_port); } 64 | 65 | void hport(int value) 66 | { 67 | // Port is fortunately located at the same position 68 | // in both sockaddr_in and sockaddr_in6 and has the 69 | // same size. 70 | sin.sin_port = htons(value); 71 | } 72 | 73 | sockaddr* get() { return &sa; } 74 | sockaddr* operator&() { return &sa; } 75 | 76 | const sockaddr* get() const { return &sa; } 77 | const sockaddr* operator&() const { return &sa; } 78 | 79 | template struct TypeMap; 80 | 81 | template 82 | typename TypeMap::type& get(); 83 | 84 | struct Equal 85 | { 86 | bool operator()(const sockaddr_any& c1, const sockaddr_any& c2) 87 | { 88 | return memcmp(&c1, &c2, sizeof(c1)) == 0; 89 | } 90 | }; 91 | 92 | struct EqualAddress 93 | { 94 | bool operator()(const sockaddr_any& c1, const sockaddr_any& c2) 95 | { 96 | if ( c1.sa.sa_family == AF_INET ) 97 | { 98 | return c1.sin.sin_addr.s_addr == c2.sin.sin_addr.s_addr; 99 | } 100 | 101 | if ( c1.sa.sa_family == AF_INET6 ) 102 | { 103 | return memcmp(&c1.sin6.sin6_addr, &c2.sin6.sin6_addr, sizeof (in6_addr)) == 0; 104 | } 105 | 106 | return false; 107 | } 108 | 109 | }; 110 | 111 | bool equal_address(const sockaddr_any& rhs) const 112 | { 113 | return EqualAddress()(*this, rhs); 114 | } 115 | 116 | struct Less 117 | { 118 | bool operator()(const sockaddr_any& c1, const sockaddr_any& c2) 119 | { 120 | return memcmp(&c1, &c2, sizeof(c1)) < 0; 121 | } 122 | }; 123 | }; 124 | 125 | template<> struct sockaddr_any::TypeMap { typedef sockaddr_in type; }; 126 | template<> struct sockaddr_any::TypeMap { typedef sockaddr_in6 type; }; 127 | 128 | template <> 129 | inline sockaddr_any::TypeMap::type& sockaddr_any::get() { return sin; } 130 | template <> 131 | inline sockaddr_any::TypeMap::type& sockaddr_any::get() { return sin6; } 132 | 133 | #endif 134 | -------------------------------------------------------------------------------- /logging/logger.h: -------------------------------------------------------------------------------- 1 | #ifndef LOGGER_H_4RWVDC5H 2 | #define LOGGER_H_4RWVDC5H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | template 11 | void __LoggerDummyWrapper(T... t) {}; 12 | 13 | template 14 | std::stringstream* __log_unpacker(std::stringstream* os, const T t) { 15 | *os << t; 16 | return os; 17 | } 18 | 19 | template 20 | std::string __log_buffer(T t, Args... data) { 21 | std::stringstream os; 22 | os << t; 23 | __LoggerDummyWrapper(__log_unpacker(&os, data)...); 24 | return std::move(os.str()); 25 | } 26 | 27 | #define InitLog(config_file_name) \ 28 | do { \ 29 | log4cplus::PropertyConfigurator::doConfigure(config_file_name); \ 30 | } while (0) 31 | 32 | #define DebugLogf(fmt, ...) \ 33 | do { \ 34 | log4cplus::Logger log = log4cplus::Logger::getInstance("program"); \ 35 | LOG4CPLUS_DEBUG_FMT(log, fmt, __VA_ARGS__); \ 36 | } while (0) 37 | 38 | #define WarnLogf(fmt, ...) \ 39 | do { \ 40 | log4cplus::Logger log = log4cplus::Logger::getInstance("program"); \ 41 | LOG4CPLUS_WARN_FMT(log, fmt, __VA_ARGS__); \ 42 | } while (0) 43 | 44 | #define InfoLogf(fmt, ...) \ 45 | do { \ 46 | log4cplus::Logger log = log4cplus::Logger::getInstance("program"); \ 47 | LOG4CPLUS_INFO_FMT(log, fmt, __VA_ARGS__); \ 48 | } while (0) 49 | 50 | #define ErrorLogf(fmt, ...) \ 51 | do { \ 52 | log4cplus::Logger log = log4cplus::Logger::getInstance("program"); \ 53 | LOG4CPLUS_ERROR_FMT(log, fmt, __VA_ARGS__); \ 54 | } while (0) 55 | 56 | #define BusinessLogf(fmt, ...) \ 57 | do { \ 58 | log4cplus::Logger log = log4cplus::Logger::getInstance("business"); \ 59 | LOG4CPLUS_INFO_FMT(log, fmt, __VA_ARGS__); \ 60 | } while (0) 61 | 62 | #define AccessLogf(fmt, ...) \ 63 | do { \ 64 | log4cplus::Logger log = log4cplus::Logger::getInstance("access"); \ 65 | LOG4CPLUS_INFO_FMT(log, fmt, __VA_ARGS__); \ 66 | } while (0) 67 | 68 | template 69 | void DebugLog(Args... args) { 70 | log4cplus::Logger log = log4cplus::Logger::getInstance("program"); 71 | LOG4CPLUS_DEBUG(log, __log_buffer(std::forward(args)...)); 72 | } 73 | 74 | template 75 | void WarnLog(Args... args) { 76 | log4cplus::Logger log = log4cplus::Logger::getInstance("program"); 77 | LOG4CPLUS_WARN(log, __log_buffer(std::forward(args)...)); 78 | } 79 | 80 | template 81 | void InfoLog(Args... args) { 82 | log4cplus::Logger log = log4cplus::Logger::getInstance("program"); 83 | LOG4CPLUS_INFO(log, __log_buffer(std::forward(args)...)); 84 | } 85 | 86 | template 87 | void BusinessLog(Args... args) { 88 | log4cplus::Logger log = log4cplus::Logger::getInstance("business"); 89 | LOG4CPLUS_INFO(log, __log_buffer(std::forward(args)...)); 90 | } 91 | 92 | template 93 | void AccessLog(Args... args) { 94 | log4cplus::Logger log = log4cplus::Logger::getInstance("access"); 95 | LOG4CPLUS_INFO(log, __log_buffer(std::forward(args)...)); 96 | } 97 | 98 | inline void InfoLogBody(char* dscr, unsigned char* data_p, int data_size) { 99 | char log_data[4096] = {0}; 100 | int offset = 0; 101 | 102 | for (int index = 0; index < data_size; index++) { 103 | if (offset > 4000) { 104 | break; 105 | } 106 | if (((index % 8) == 0) && (index != 0)) { 107 | offset += sprintf(log_data + offset, "\r\n"); 108 | } 109 | offset += sprintf(log_data + offset, "%02x ", data_p[index]); 110 | } 111 | 112 | InfoLogf("%s: \r\n%s", dscr, log_data); 113 | } 114 | #endif /* end of include guard: LOGGER_H_4RWVDC5H */ 115 | -------------------------------------------------------------------------------- /logging/log4cplus/helpers/socket.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // Module: Log4CPLUS 3 | // File: socket.h 4 | // Created: 4/2003 5 | // Author: Tad E. Smith 6 | // 7 | // 8 | // Copyright 2003-2013 Tad E. Smith 9 | // 10 | // Licensed under the Apache License, Version 2.0 (the "License"); 11 | // you may not use this file except in compliance with the License. 12 | // You may obtain a copy of the License at 13 | // 14 | // http://www.apache.org/licenses/LICENSE-2.0 15 | // 16 | // Unless required by applicable law or agreed to in writing, software 17 | // distributed under the License is distributed on an "AS IS" BASIS, 18 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | // See the License for the specific language governing permissions and 20 | // limitations under the License. 21 | 22 | /** @file */ 23 | 24 | #ifndef LOG4CPLUS_HELPERS_SOCKET_HEADER_ 25 | #define LOG4CPLUS_HELPERS_SOCKET_HEADER_ 26 | 27 | #include 28 | 29 | #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE) 30 | #pragma once 31 | #endif 32 | 33 | #include 34 | #include 35 | 36 | 37 | namespace log4cplus { 38 | namespace helpers { 39 | 40 | enum SocketState { ok, 41 | not_opened, 42 | bad_address, 43 | connection_failed, 44 | broken_pipe, 45 | invalid_access_mode, 46 | message_truncated, 47 | accept_interrupted 48 | }; 49 | 50 | typedef std::ptrdiff_t SOCKET_TYPE; 51 | 52 | extern LOG4CPLUS_EXPORT SOCKET_TYPE const INVALID_SOCKET_VALUE; 53 | 54 | class LOG4CPLUS_EXPORT AbstractSocket { 55 | public: 56 | // ctor and dtor 57 | AbstractSocket(); 58 | AbstractSocket(SOCKET_TYPE sock, SocketState state, int err); 59 | AbstractSocket(const AbstractSocket&); 60 | virtual ~AbstractSocket() = 0; 61 | 62 | // methods 63 | /// Close socket 64 | virtual void close(); 65 | virtual bool isOpen() const; 66 | virtual void shutdown(); 67 | AbstractSocket& operator=(const AbstractSocket& rhs); 68 | 69 | protected: 70 | // Methods 71 | virtual void copy(const AbstractSocket& rhs); 72 | 73 | // Data 74 | SOCKET_TYPE sock; 75 | SocketState state; 76 | int err; 77 | }; 78 | 79 | 80 | 81 | /** 82 | * This class implements client sockets (also called just "sockets"). 83 | * A socket is an endpoint for communication between two machines. 84 | */ 85 | class LOG4CPLUS_EXPORT Socket : public AbstractSocket { 86 | public: 87 | // ctor and dtor 88 | Socket(); 89 | Socket(SOCKET_TYPE sock, SocketState state, int err); 90 | Socket(const tstring& address, unsigned short port, bool udp = false); 91 | virtual ~Socket(); 92 | 93 | // methods 94 | virtual bool read(SocketBuffer& buffer); 95 | virtual bool write(const SocketBuffer& buffer); 96 | virtual bool write(const std::string & buffer); 97 | }; 98 | 99 | 100 | 101 | /** 102 | * This class implements server sockets. A server socket waits for 103 | * requests to come in over the network. It performs some operation 104 | * based on that request, and then possibly returns a result to the 105 | * requester. 106 | */ 107 | class LOG4CPLUS_EXPORT ServerSocket : public AbstractSocket { 108 | public: 109 | // ctor and dtor 110 | ServerSocket(unsigned short port); 111 | virtual ~ServerSocket(); 112 | 113 | Socket accept(); 114 | void interruptAccept (); 115 | 116 | protected: 117 | std::ptrdiff_t interruptHandles[2]; 118 | }; 119 | 120 | 121 | LOG4CPLUS_EXPORT SOCKET_TYPE openSocket(unsigned short port, SocketState& state); 122 | LOG4CPLUS_EXPORT SOCKET_TYPE connectSocket(const log4cplus::tstring& hostn, 123 | unsigned short port, bool udp, 124 | SocketState& state); 125 | LOG4CPLUS_EXPORT SOCKET_TYPE acceptSocket(SOCKET_TYPE sock, SocketState& state); 126 | LOG4CPLUS_EXPORT int closeSocket(SOCKET_TYPE sock); 127 | LOG4CPLUS_EXPORT int shutdownSocket(SOCKET_TYPE sock); 128 | 129 | LOG4CPLUS_EXPORT long read(SOCKET_TYPE sock, SocketBuffer& buffer); 130 | LOG4CPLUS_EXPORT long write(SOCKET_TYPE sock, 131 | const SocketBuffer& buffer); 132 | LOG4CPLUS_EXPORT long write(SOCKET_TYPE sock, 133 | const std::string & buffer); 134 | 135 | LOG4CPLUS_EXPORT tstring getHostname (bool fqdn); 136 | LOG4CPLUS_EXPORT int setTCPNoDelay (SOCKET_TYPE, bool); 137 | 138 | } // end namespace helpers 139 | } // end namespace log4cplus 140 | 141 | #endif // LOG4CPLUS_HELPERS_SOCKET_HEADER_ 142 | -------------------------------------------------------------------------------- /logging/log4cplus/thread/impl/tls.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // Copyright (C) 2010-2013, Vaclav Haisman. All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without modifica- 5 | // tion, are permitted provided that the following conditions are met: 6 | // 7 | // 1. Redistributions of source code must retain the above copyright notice, 8 | // this list of conditions and the following disclaimer. 9 | // 10 | // 2. Redistributions in binary form must reproduce the above copyright notice, 11 | // this list of conditions and the following disclaimer in the documentation 12 | // and/or other materials provided with the distribution. 13 | // 14 | // THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 15 | // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 16 | // FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 17 | // APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 18 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- 19 | // DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 20 | // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 21 | // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | 25 | #ifndef LOG4CPLUS_THREAD_IMPL_TLS_H 26 | #define LOG4CPLUS_THREAD_IMPL_TLS_H 27 | 28 | #include 29 | 30 | #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE) 31 | #pragma once 32 | #endif 33 | 34 | #include 35 | #include 36 | 37 | #if ! defined (INSIDE_LOG4CPLUS) 38 | # error "This header must not be be used outside log4cplus' implementation files." 39 | #endif 40 | 41 | #ifdef LOG4CPLUS_USE_PTHREADS 42 | # include 43 | 44 | #elif defined (LOG4CPLUS_USE_WIN32_THREADS) 45 | # include 46 | 47 | #elif defined (LOG4CPLUS_SINGLE_THREADED) 48 | # include 49 | 50 | #endif 51 | 52 | 53 | namespace log4cplus { namespace thread { namespace impl { 54 | 55 | 56 | typedef void * tls_value_type; 57 | typedef void (* tls_init_cleanup_func_type)(void *); 58 | 59 | #ifdef LOG4CPLUS_USE_PTHREADS 60 | typedef pthread_key_t * tls_key_type; 61 | 62 | #elif defined (LOG4CPLUS_USE_WIN32_THREADS) 63 | typedef DWORD tls_key_type; 64 | 65 | #elif defined (LOG4CPLUS_SINGLE_THREADED) 66 | typedef std::size_t tls_key_type; 67 | 68 | #endif 69 | 70 | 71 | inline tls_key_type tls_init (tls_init_cleanup_func_type); 72 | inline tls_value_type tls_get_value (tls_key_type); 73 | inline void tls_set_value (tls_key_type, tls_value_type); 74 | inline void tls_cleanup (tls_key_type); 75 | 76 | 77 | #if defined (LOG4CPLUS_USE_PTHREADS) 78 | tls_key_type 79 | tls_init (tls_init_cleanup_func_type cleanupfunc) 80 | { 81 | pthread_key_t * key = new pthread_key_t; 82 | pthread_key_create (key, cleanupfunc); 83 | return key; 84 | } 85 | 86 | 87 | tls_value_type 88 | tls_get_value (tls_key_type key) 89 | { 90 | return pthread_getspecific (*key); 91 | } 92 | 93 | 94 | void 95 | tls_set_value (tls_key_type key, tls_value_type value) 96 | { 97 | pthread_setspecific(*key, value); 98 | } 99 | 100 | 101 | void 102 | tls_cleanup (tls_key_type key) 103 | { 104 | pthread_key_delete (*key); 105 | delete key; 106 | } 107 | 108 | 109 | #elif defined (LOG4CPLUS_USE_WIN32_THREADS) 110 | tls_key_type 111 | tls_init (tls_init_cleanup_func_type) 112 | { 113 | return TlsAlloc (); 114 | } 115 | 116 | 117 | tls_value_type tls_get_value (tls_key_type k) 118 | { 119 | return TlsGetValue (k); 120 | } 121 | 122 | 123 | void 124 | tls_set_value (tls_key_type k, tls_value_type value) 125 | { 126 | TlsSetValue (k, value); 127 | } 128 | 129 | 130 | void 131 | tls_cleanup (tls_key_type k) 132 | { 133 | TlsFree (k); 134 | } 135 | 136 | 137 | #elif defined (LOG4CPLUS_SINGLE_THREADED) 138 | extern std::vector * tls_single_threaded_values; 139 | 140 | 141 | tls_key_type 142 | tls_init (tls_init_cleanup_func_type) 143 | { 144 | if (! tls_single_threaded_values) 145 | tls_single_threaded_values = new std::vector; 146 | tls_key_type key = tls_single_threaded_values->size (); 147 | tls_single_threaded_values->resize (key + 1); 148 | return key; 149 | } 150 | 151 | 152 | tls_value_type 153 | tls_get_value (tls_key_type k) 154 | { 155 | assert (k < tls_single_threaded_values->size ()); 156 | return (*tls_single_threaded_values)[k]; 157 | } 158 | 159 | 160 | void 161 | tls_set_value (tls_key_type k, tls_value_type val) 162 | { 163 | assert (k < tls_single_threaded_values->size ()); 164 | (*tls_single_threaded_values)[k] = val; 165 | } 166 | 167 | 168 | void 169 | tls_cleanup (tls_key_type k) 170 | { 171 | assert (k < tls_single_threaded_values->size ()); 172 | (*tls_single_threaded_values)[k] = 0; 173 | } 174 | 175 | #endif 176 | 177 | 178 | } } } // namespace log4cplus { namespace thread { namespace impl { 179 | 180 | #endif // LOG4CPLUS_THREAD_IMPL_TLS_H 181 | -------------------------------------------------------------------------------- /logging/log4cplus/helpers/loglog.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // Module: Log4CPLUS 3 | // File: loglog.h 4 | // Created: 6/2001 5 | // Author: Tad E. Smith 6 | // 7 | // 8 | // Copyright 2001-2013 Tad E. Smith 9 | // 10 | // Licensed under the Apache License, Version 2.0 (the "License"); 11 | // you may not use this file except in compliance with the License. 12 | // You may obtain a copy of the License at 13 | // 14 | // http://www.apache.org/licenses/LICENSE-2.0 15 | // 16 | // Unless required by applicable law or agreed to in writing, software 17 | // distributed under the License is distributed on an "AS IS" BASIS, 18 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | // See the License for the specific language governing permissions and 20 | // limitations under the License. 21 | 22 | /** @file */ 23 | 24 | #ifndef LOG4CPLUS_HELPERS_LOGLOG 25 | #define LOG4CPLUS_HELPERS_LOGLOG 26 | 27 | #include 28 | 29 | #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE) 30 | #pragma once 31 | #endif 32 | 33 | #include 34 | #include 35 | #include 36 | 37 | 38 | namespace log4cplus { 39 | namespace helpers { 40 | 41 | /** 42 | * This class used to output log statements from within the log4cplus package. 43 | * 44 | * Log4cplus components cannot make log4cplus logging calls. However, it is 45 | * sometimes useful for the user to learn about what log4cplus is 46 | * doing. You can enable log4cplus internal logging by defining the 47 | * log4cplus.configDebug variable. 48 | * 49 | * All log4cplus internal debug calls go to cout 50 | * where as internal error messages are sent to 51 | * cerr. All internal messages are prepended with 52 | * the string "log4clus: ". 53 | */ 54 | class LOG4CPLUS_EXPORT LogLog 55 | { 56 | public: 57 | //! Return type of getLogLog(). 58 | typedef LogLog * Ptr; 59 | 60 | /** 61 | * Returns a reference to the LogLog singleton. 62 | */ 63 | static Ptr getLogLog(); 64 | 65 | 66 | /** 67 | * Allows to enable/disable log4cplus internal logging. 68 | */ 69 | void setInternalDebugging(bool enabled); 70 | 71 | /** 72 | * In quite mode no LogLog generates strictly no output, not even 73 | * for errors. 74 | * 75 | * @param quietMode A true for not 76 | */ 77 | void setQuietMode(bool quietMode); 78 | 79 | /** 80 | * This method is used to output log4cplus internal debug 81 | * statements. Output goes to std::cout. 82 | */ 83 | void debug(const log4cplus::tstring& msg) const; 84 | void debug(tchar const * msg) const; 85 | 86 | /** 87 | * This method is used to output log4cplus internal error 88 | * statements. There is no way to disable error 89 | * statements. Output goes to 90 | * std::cerr. Optionally, this method can 91 | * throw std::runtime_error exception too. 92 | */ 93 | void error(const log4cplus::tstring& msg, bool throw_flag = false) const; 94 | void error(tchar const * msg, bool throw_flag = false) const; 95 | 96 | /** 97 | * This method is used to output log4cplus internal warning 98 | * statements. There is no way to disable warning statements. 99 | * Output goes to std::cerr. 100 | */ 101 | void warn(const log4cplus::tstring& msg) const; 102 | void warn(tchar const * msg) const; 103 | 104 | // Public ctor and dtor to be used only by internal::DefaultContext. 105 | LogLog(); 106 | virtual ~LogLog(); 107 | 108 | private: 109 | enum TriState 110 | { 111 | TriUndef = -1, 112 | TriFalse, 113 | TriTrue 114 | }; 115 | 116 | template 117 | LOG4CPLUS_PRIVATE 118 | void logging_worker (tostream & os, 119 | bool (LogLog:: * cond) () const, tchar const *, 120 | StringType const &, bool throw_flag = false) const; 121 | 122 | LOG4CPLUS_PRIVATE static void set_tristate_from_env (TriState *, 123 | tchar const * envvar); 124 | 125 | LOG4CPLUS_PRIVATE bool get_quiet_mode () const; 126 | LOG4CPLUS_PRIVATE bool get_not_quiet_mode () const; 127 | LOG4CPLUS_PRIVATE bool get_debug_mode () const; 128 | 129 | // Data 130 | mutable TriState debugEnabled; 131 | mutable TriState quietMode; 132 | thread::Mutex mutex; 133 | 134 | LOG4CPLUS_PRIVATE LogLog(const LogLog&); 135 | LOG4CPLUS_PRIVATE LogLog & operator = (LogLog const &); 136 | }; 137 | 138 | LOG4CPLUS_EXPORT LogLog & getLogLog (); 139 | 140 | } // end namespace helpers 141 | } // end namespace log4cplus 142 | 143 | 144 | #endif // LOG4CPLUS_HELPERS_LOGLOG 145 | 146 | -------------------------------------------------------------------------------- /logging/log4cplus/boost/deviceappender.hxx: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2009-2013, Vaclav Haisman. All rights reserved. 2 | // 3 | // Redistribution and use in source and binary forms, with or without modifica- 4 | // tion, are permitted provided that the following conditions are met: 5 | // 6 | // 1. Redistributions of source code must retain the above copyright notice, 7 | // this list of conditions and the following disclaimer. 8 | // 9 | // 2. Redistributions in binary form must reproduce the above copyright notice, 10 | // this list of conditions and the following disclaimer in the documentation 11 | // and/or other materials provided with the distribution. 12 | // 13 | // THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 14 | // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 15 | // FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 16 | // APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 17 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- 18 | // DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 19 | // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 20 | // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 22 | // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 | 24 | #ifndef LOG4CPLUS_BOOST_DEVICEAPPENDER_HXX 25 | #define LOG4CPLUS_BOOST_DEVICEAPPENDER_HXX 26 | 27 | #include 28 | 29 | #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE) 30 | #pragma once 31 | #endif 32 | 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | 40 | 41 | namespace log4cplus 42 | { 43 | 44 | 45 | namespace device_appender_detail 46 | { 47 | 48 | 49 | template 50 | struct device_type_traits 51 | { 52 | typedef T & device_type; 53 | 54 | static 55 | device_type 56 | unwrap (device_type x) 57 | { 58 | return x; 59 | } 60 | }; 61 | 62 | 63 | template 64 | struct device_type_traits > 65 | { 66 | typedef boost::shared_ptr device_type; 67 | 68 | static 69 | T & 70 | unwrap (device_type const & ptr) 71 | { 72 | return *ptr; 73 | } 74 | }; 75 | 76 | 77 | } // namespace device_appender_detail 78 | 79 | 80 | template 81 | class DeviceAppender 82 | : public Appender 83 | { 84 | public: 85 | typedef device_appender_detail::device_type_traits device_traits; 86 | typedef typename device_traits::device_type device_type; 87 | 88 | template 89 | DeviceAppender (D & d, bool close_device = true) 90 | : device (d) 91 | , close_flag (close_device) 92 | { } 93 | 94 | template 95 | DeviceAppender (boost::shared_ptr const & d, bool close_device = true) 96 | : device (d) 97 | , close_flag (close_device) 98 | { } 99 | 100 | template 101 | DeviceAppender (D & d, const helpers::Properties & props) 102 | : Appender (props) 103 | , device (d) 104 | { 105 | if (props.exists (LOG4CPLUS_TEXT ("CloseDevice"))) 106 | close_flag = true; 107 | else 108 | close_flag = false; 109 | } 110 | 111 | template 112 | DeviceAppender (boost::shared_ptr const & d, 113 | const helpers::Properties & props) 114 | : Appender (props) 115 | , device (d) 116 | { 117 | if (props.exists (LOG4CPLUS_TEXT ("CloseDevice"))) 118 | close_flag = true; 119 | else 120 | close_flag = false; 121 | } 122 | 123 | virtual 124 | ~DeviceAppender () 125 | { } 126 | 127 | virtual 128 | void 129 | close () 130 | { 131 | if (close_flag) 132 | boost::iostreams::close (device_traits::unwrap (device)); 133 | } 134 | 135 | protected: 136 | virtual 137 | void 138 | append (log4cplus::spi::InternalLoggingEvent const & event) 139 | { 140 | tstring & str = formatEvent (event); 141 | boost::iostreams::write (device_traits::unwrap (device), 142 | str.c_str (), str.size ()); 143 | } 144 | 145 | device_type device; 146 | bool close_flag; 147 | 148 | private: 149 | DeviceAppender (DeviceAppender const &); 150 | DeviceAppender & operator = (DeviceAppender const &); 151 | }; 152 | 153 | 154 | template 155 | inline 156 | SharedAppenderPtr 157 | make_device_appender (T & d, bool close_device = true) 158 | { 159 | SharedAppenderPtr app (new DeviceAppender (d, close_device)); 160 | return app; 161 | } 162 | 163 | 164 | template 165 | inline 166 | SharedAppenderPtr 167 | make_device_appender (T & d, const helpers::Properties & props) 168 | { 169 | SharedAppenderPtr app (new DeviceAppender (d, props)); 170 | return app; 171 | } 172 | 173 | 174 | template 175 | inline 176 | SharedAppenderPtr 177 | make_device_appender_sp (boost::shared_ptr const & p, 178 | bool close_device = true) 179 | { 180 | SharedAppenderPtr app ( 181 | new DeviceAppender > (p, close_device)); 182 | return app; 183 | } 184 | 185 | 186 | template 187 | inline 188 | SharedAppenderPtr 189 | make_device_appender_sp (boost::shared_ptr const & p, 190 | const helpers::Properties & props) 191 | { 192 | SharedAppenderPtr app ( 193 | new DeviceAppender > (p, props)); 194 | return app; 195 | } 196 | 197 | 198 | } // namespace log4cplus 199 | 200 | 201 | #endif // LOG4CPLUS_BOOST_DEVICEAPPENDER_HXX 202 | -------------------------------------------------------------------------------- /logging/log4cplus/helpers/timehelper.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // Module: Log4CPLUS 3 | // File: timehelper.h 4 | // Created: 6/2003 5 | // Author: Tad E. Smith 6 | // 7 | // 8 | // Copyright 2003-2013 Tad E. Smith 9 | // 10 | // Licensed under the Apache License, Version 2.0 (the "License"); 11 | // you may not use this file except in compliance with the License. 12 | // You may obtain a copy of the License at 13 | // 14 | // http://www.apache.org/licenses/LICENSE-2.0 15 | // 16 | // Unless required by applicable law or agreed to in writing, software 17 | // distributed under the License is distributed on an "AS IS" BASIS, 18 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | // See the License for the specific language governing permissions and 20 | // limitations under the License. 21 | 22 | /** @file */ 23 | 24 | #ifndef LOG4CPLUS_HELPERS_TIME_HELPER_HEADER_ 25 | #define LOG4CPLUS_HELPERS_TIME_HELPER_HEADER_ 26 | 27 | #include 28 | 29 | #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE) 30 | #pragma once 31 | #endif 32 | 33 | #include 34 | 35 | #if defined (LOG4CPLUS_HAVE_TIME_H) 36 | #include 37 | #endif 38 | 39 | #include 40 | 41 | 42 | namespace log4cplus { 43 | 44 | namespace helpers { 45 | 46 | 47 | using std::time_t; 48 | using std::tm; 49 | 50 | 51 | /** 52 | * This class represents a Epoch time with microsecond accuracy. 53 | */ 54 | class LOG4CPLUS_EXPORT Time { 55 | public: 56 | Time(); 57 | Time(time_t tv_sec, long tv_usec); 58 | explicit Time(time_t time); 59 | 60 | /** 61 | * Returns the current time using the gettimeofday() 62 | * method if it is available on the current platform. (Not on 63 | * WIN32.) 64 | */ 65 | static Time gettimeofday(); 66 | 67 | // Methods 68 | /** 69 | * Returns seconds value. 70 | */ 71 | time_t sec() const { return tv_sec; } 72 | 73 | /** 74 | * Returns microseconds value. 75 | */ 76 | long usec() const { return tv_usec; } 77 | 78 | /** 79 | * Sets the seconds value. 80 | */ 81 | void sec(time_t s) { tv_sec = s; } 82 | 83 | /** 84 | * Sets the microseconds value. 85 | */ 86 | void usec(long us) { tv_usec = us; } 87 | 88 | /** 89 | * Sets this Time using the mktime function. 90 | */ 91 | time_t setTime(tm* t); 92 | 93 | /** 94 | * Returns this Time as a time_t value. 95 | */ 96 | time_t getTime() const LOG4CPLUS_ATTRIBUTE_PURE; 97 | 98 | /** 99 | * Populates tm using the gmtime() 100 | * function. 101 | */ 102 | void gmtime(tm* t) const; 103 | 104 | /** 105 | * Populates tm using the localtime() 106 | * function. 107 | */ 108 | void localtime(tm* t) const; 109 | 110 | /** 111 | * Returns a string with a "formatted time" specified by 112 | * fmt. It used the strftime() 113 | * function to do this. 114 | * 115 | * Look at your platform's strftime() documentation 116 | * for the formatting options available. 117 | * 118 | * The following additional options are provided:
119 | * %q - 3 character field that provides milliseconds 120 | * %Q - 7 character field that provides fractional 121 | * milliseconds. 122 | */ 123 | log4cplus::tstring getFormattedTime(const log4cplus::tstring& fmt, 124 | bool use_gmtime = false) const; 125 | 126 | // Operators 127 | Time& operator+=(const Time& rhs); 128 | Time& operator-=(const Time& rhs); 129 | Time& operator/=(long rhs); 130 | Time& operator*=(long rhs); 131 | 132 | private: 133 | // Data 134 | time_t tv_sec; /* seconds */ 135 | long tv_usec; /* microseconds */ 136 | }; 137 | 138 | 139 | LOG4CPLUS_EXPORT const log4cplus::helpers::Time operator+ 140 | (const log4cplus::helpers::Time& lhs, 141 | const log4cplus::helpers::Time& rhs); 142 | LOG4CPLUS_EXPORT const log4cplus::helpers::Time operator- 143 | (const log4cplus::helpers::Time& lhs, 144 | const log4cplus::helpers::Time& rhs); 145 | LOG4CPLUS_EXPORT const log4cplus::helpers::Time operator/ 146 | (const log4cplus::helpers::Time& lhs, 147 | long rhs); 148 | LOG4CPLUS_EXPORT const log4cplus::helpers::Time operator* 149 | (const log4cplus::helpers::Time& lhs, 150 | long rhs); 151 | 152 | LOG4CPLUS_EXPORT bool operator<(const log4cplus::helpers::Time& lhs, 153 | const log4cplus::helpers::Time& rhs) 154 | LOG4CPLUS_ATTRIBUTE_PURE; 155 | LOG4CPLUS_EXPORT bool operator<=(const log4cplus::helpers::Time& lhs, 156 | const log4cplus::helpers::Time& rhs) 157 | LOG4CPLUS_ATTRIBUTE_PURE; 158 | 159 | LOG4CPLUS_EXPORT bool operator>(const log4cplus::helpers::Time& lhs, 160 | const log4cplus::helpers::Time& rhs) 161 | LOG4CPLUS_ATTRIBUTE_PURE; 162 | LOG4CPLUS_EXPORT bool operator>=(const log4cplus::helpers::Time& lhs, 163 | const log4cplus::helpers::Time& rhs) 164 | LOG4CPLUS_ATTRIBUTE_PURE; 165 | 166 | LOG4CPLUS_EXPORT bool operator==(const log4cplus::helpers::Time& lhs, 167 | const log4cplus::helpers::Time& rhs) 168 | LOG4CPLUS_ATTRIBUTE_PURE; 169 | LOG4CPLUS_EXPORT bool operator!=(const log4cplus::helpers::Time& lhs, 170 | const log4cplus::helpers::Time& rhs) 171 | LOG4CPLUS_ATTRIBUTE_PURE; 172 | 173 | } // namespace helpers 174 | 175 | } // namespace log4cplus 176 | 177 | 178 | #endif // LOG4CPLUS_HELPERS_TIME_HELPER_HEADER_ 179 | 180 | -------------------------------------------------------------------------------- /logging/log4cplus/socketappender.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // Module: LOG4CPLUS 3 | // File: socketappender.h 4 | // Created: 5/2003 5 | // Author: Tad E. Smith 6 | // 7 | // 8 | // Copyright 2003-2013 Tad E. Smith 9 | // 10 | // Licensed under the Apache License, Version 2.0 (the "License"); 11 | // you may not use this file except in compliance with the License. 12 | // You may obtain a copy of the License at 13 | // 14 | // http://www.apache.org/licenses/LICENSE-2.0 15 | // 16 | // Unless required by applicable law or agreed to in writing, software 17 | // distributed under the License is distributed on an "AS IS" BASIS, 18 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | // See the License for the specific language governing permissions and 20 | // limitations under the License. 21 | 22 | /** @file */ 23 | 24 | #ifndef LOG4CPLUS_SOCKET_APPENDER_HEADER_ 25 | #define LOG4CPLUS_SOCKET_APPENDER_HEADER_ 26 | 27 | #include 28 | 29 | #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE) 30 | #pragma once 31 | #endif 32 | 33 | #include 34 | #include 35 | #include 36 | #include 37 | 38 | 39 | namespace log4cplus 40 | { 41 | 42 | 43 | #ifndef UNICODE 44 | std::size_t const LOG4CPLUS_MAX_MESSAGE_SIZE = 8*1024; 45 | #else 46 | std::size_t const LOG4CPLUS_MAX_MESSAGE_SIZE = 2*8*1024; 47 | #endif 48 | 49 | 50 | /** 51 | * Sends {@link spi::InternalLoggingEvent} objects to a remote a log server. 52 | * 53 | * The SocketAppender has the following properties: 54 | * 55 | *
    56 | * 57 | *
  • Remote logging is non-intrusive as far as the log event 58 | * is concerned. In other words, the event will be logged with 59 | * the same time stamp, NDC, location info as if it were logged 60 | * locally by the client. 61 | * 62 | *
  • SocketAppenders do not use a layout. 63 | * 64 | *
  • Remote logging uses the TCP protocol. Consequently, if 65 | * the server is reachable, then log events will eventually arrive 66 | * at the server. 67 | * 68 | *
  • If the remote server is down, the logging requests are 69 | * simply dropped. However, if and when the server comes back up, 70 | * then event transmission is resumed transparently. This 71 | * transparent reconneciton is performed by a connector 72 | * thread which periodically attempts to connect to the server. 73 | * 74 | *
  • Logging events are automatically buffered by the 75 | * native TCP implementation. This means that if the link to server 76 | * is slow but still faster than the rate of (log) event production 77 | * by the client, the client will not be affected by the slow 78 | * network connection. However, if the network connection is slower 79 | * then the rate of event production, then the client can only 80 | * progress at the network rate. In particular, if the network link 81 | * to the the server is down, the client will be blocked. 82 | * 83 | *
  • On the other hand, if the network link is up, but the server 84 | * is down, the client will not be blocked when making log requests 85 | * but the log events will be lost due to server unavailability. 86 | *
87 | * 88 | *

Properties

89 | *
90 | *
host
91 | *
Remote host name to connect and send events to.
92 | * 93 | *
port
94 | *
Port on remote host to send events to.
95 | * 96 | *
ServerName
97 | *
Host name of event's origin prepended to each event.
98 | * 99 | *
100 | */ 101 | class LOG4CPLUS_EXPORT SocketAppender : public Appender { 102 | public: 103 | // Ctors 104 | SocketAppender(const log4cplus::tstring& host, unsigned short port, 105 | const log4cplus::tstring& serverName = tstring()); 106 | SocketAppender(const log4cplus::helpers::Properties & properties); 107 | 108 | // Dtor 109 | ~SocketAppender(); 110 | 111 | // Methods 112 | virtual void close(); 113 | 114 | protected: 115 | void openSocket(); 116 | void initConnector (); 117 | virtual void append(const spi::InternalLoggingEvent& event); 118 | 119 | // Data 120 | log4cplus::helpers::Socket socket; 121 | log4cplus::tstring host; 122 | unsigned int port; 123 | log4cplus::tstring serverName; 124 | 125 | #if ! defined (LOG4CPLUS_SINGLE_THREADED) 126 | class LOG4CPLUS_EXPORT ConnectorThread; 127 | friend class ConnectorThread; 128 | 129 | class LOG4CPLUS_EXPORT ConnectorThread 130 | : public thread::AbstractThread 131 | { 132 | public: 133 | ConnectorThread (SocketAppender &); 134 | virtual ~ConnectorThread (); 135 | 136 | virtual void run(); 137 | 138 | void terminate (); 139 | void trigger (); 140 | 141 | protected: 142 | SocketAppender & sa; 143 | thread::ManualResetEvent trigger_ev; 144 | bool exit_flag; 145 | }; 146 | 147 | volatile bool connected; 148 | helpers::SharedObjectPtr connector; 149 | #endif 150 | 151 | private: 152 | // Disallow copying of instances of this class 153 | SocketAppender(const SocketAppender&); 154 | SocketAppender& operator=(const SocketAppender&); 155 | }; 156 | 157 | namespace helpers { 158 | LOG4CPLUS_EXPORT 159 | void convertToBuffer (SocketBuffer & buffer, 160 | const log4cplus::spi::InternalLoggingEvent& event, 161 | const log4cplus::tstring& serverName); 162 | 163 | LOG4CPLUS_EXPORT 164 | log4cplus::spi::InternalLoggingEvent readFromBuffer(SocketBuffer& buffer); 165 | } // end namespace helpers 166 | 167 | } // end namespace log4cplus 168 | 169 | #endif // LOG4CPLUS_SOCKET_APPENDER_HEADER_ 170 | 171 | -------------------------------------------------------------------------------- /logging/log4cplus/helpers/queue.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // Copyright (C) 2009-2013, Vaclav Haisman. All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without modifica- 5 | // tion, are permitted provided that the following conditions are met: 6 | // 7 | // 1. Redistributions of source code must retain the above copyright notice, 8 | // this list of conditions and the following disclaimer. 9 | // 10 | // 2. Redistributions in binary form must reproduce the above copyright notice, 11 | // this list of conditions and the following disclaimer in the documentation 12 | // and/or other materials provided with the distribution. 13 | // 14 | // THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 15 | // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 16 | // FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 17 | // APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 18 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- 19 | // DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 20 | // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 21 | // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | 25 | #ifndef LOG4CPLUS_HELPERS_QUEUE_H 26 | #define LOG4CPLUS_HELPERS_QUEUE_H 27 | 28 | #include 29 | 30 | #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE) 31 | #pragma once 32 | #endif 33 | 34 | #if ! defined (LOG4CPLUS_SINGLE_THREADED) 35 | 36 | #include 37 | #include 38 | #include 39 | #include 40 | 41 | 42 | namespace log4cplus { namespace thread { 43 | 44 | 45 | //! Single consumer, multiple producers queue. 46 | class LOG4CPLUS_EXPORT Queue 47 | : public virtual helpers::SharedObject 48 | { 49 | public: 50 | //! Type of the state flags field. 51 | typedef unsigned flags_type; 52 | 53 | //! Queue storage type. 54 | typedef std::deque queue_storage_type; 55 | 56 | Queue (unsigned len = 100); 57 | virtual ~Queue (); 58 | 59 | // Producers' methods. 60 | 61 | //! Puts event ev into queue, sets QUEUE flag and 62 | //! sets internal event object into signaled state. If the EXIT 63 | //! flags is already set upon entering the function, nothing is 64 | //! inserted into the queue. The function can block on internal 65 | //! semaphore if the queue has reached maximal allowed 66 | //! length. Calling thread is unblocked either by consumer thread 67 | //! removing item from queue or by any other thread calling 68 | //! signal_exit(). 69 | //! 70 | //! \param ev spi::InternalLoggingEvent to be put into the queue. 71 | //! \return Flags. 72 | flags_type put_event (spi::InternalLoggingEvent const & ev); 73 | 74 | //! Sets EXIT flag and DRAIN flag and sets internal event object 75 | //! into signaled state. 76 | //! \param drain If true, DRAIN flag will be set, otherwise unset. 77 | //! \return Flags, ERROR_BIT can be set upon error. 78 | flags_type signal_exit (bool drain = true); 79 | 80 | // Consumer's methods. 81 | 82 | //! The get_events() function is used by queue's consumer. It 83 | //! fills buf argument and sets EVENT flag in return 84 | //! value. If EXIT flag is already set in flags member upon 85 | //! entering the function then depending on DRAIN flag it either 86 | //! fills buf argument or does not fill the argument, 87 | //! if the queue is non-empty. The function blocks by waiting for 88 | //! internal event object to be signaled if the queue is empty, 89 | //! unless EXIT flag is set. The calling thread is unblocked when 90 | //! items are added into the queue or when exit is signaled using 91 | //! the signal_exit() function. 92 | //! 93 | //! 94 | //! Upon error, return value has one of the error flags set. 95 | //! 96 | //! \param buf Pointer to storage of spi::InternalLoggingEvent 97 | //! instances to be filled from queue. 98 | //! \return Flags. 99 | flags_type get_events (queue_storage_type * buf); 100 | 101 | //! Possible state flags. 102 | enum Flags 103 | { 104 | //! EVENT flag is set in return value of get_event() call if 105 | //! the ev argument is filled with event from the queue. 106 | EVENT = 0x0001, 107 | 108 | //! QUEUE flag is set by producers when they put item into the 109 | //! queue. 110 | QUEUE = 0x0002, 111 | 112 | //! EXIT flag is set by signal_exit() call, signaling that the 113 | //! queue worker thread should end itself. 114 | EXIT = 0x0004, 115 | 116 | //! When DRAIN flag is set together with EXIT flag, the queue 117 | //! worker thread will first drain the queue before exiting. 118 | DRAIN = 0x0008, 119 | 120 | //! ERROR_BIT signals error. 121 | ERROR_BIT = 0x0010, 122 | 123 | //! ERROR_AFTER signals error that has occured after queue has 124 | //! already been touched. 125 | ERROR_AFTER = 0x0020 126 | }; 127 | 128 | protected: 129 | //! Queue storage. 130 | queue_storage_type queue; 131 | 132 | //! Mutex protecting queue and flags. 133 | Mutex mutex; 134 | 135 | //! Event on which consumer can wait if it finds queue empty. 136 | ManualResetEvent ev_consumer; 137 | 138 | //! Semaphore that limits the queue length. 139 | Semaphore sem; 140 | 141 | //! State flags. 142 | flags_type flags; 143 | 144 | private: 145 | Queue (Queue const &); 146 | Queue & operator = (Queue const &); 147 | }; 148 | 149 | 150 | typedef helpers::SharedObjectPtr QueuePtr; 151 | 152 | 153 | } } // namespace log4cplus { namespace thread { 154 | 155 | 156 | #endif // LOG4CPLUS_SINGLE_THREADED 157 | 158 | #endif // LOG4CPLUS_HELPERS_QUEUE_H 159 | -------------------------------------------------------------------------------- /logging/log4cplus/helpers/pointer.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // Module: Log4CPLUS 3 | // File: pointer.h 4 | // Created: 6/2001 5 | // Author: Tad E. Smith 6 | // 7 | // 8 | // Copyright 2001-2013 Tad E. Smith 9 | // 10 | // Licensed under the Apache License, Version 2.0 (the "License"); 11 | // you may not use this file except in compliance with the License. 12 | // You may obtain a copy of the License at 13 | // 14 | // http://www.apache.org/licenses/LICENSE-2.0 15 | // 16 | // Unless required by applicable law or agreed to in writing, software 17 | // distributed under the License is distributed on an "AS IS" BASIS, 18 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | // See the License for the specific language governing permissions and 20 | // limitations under the License. 21 | 22 | // 23 | // Note: Some of this code uses ideas from "More Effective C++" by Scott 24 | // Myers, Addison Wesley Longmain, Inc., (c) 1996, Chapter 29, pp. 183-213 25 | // 26 | 27 | /** @file */ 28 | 29 | #ifndef LOG4CPLUS_HELPERS_POINTERS_HEADER_ 30 | #define LOG4CPLUS_HELPERS_POINTERS_HEADER_ 31 | 32 | #include 33 | 34 | #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE) 35 | #pragma once 36 | #endif 37 | 38 | #include 39 | #include 40 | #include 41 | #if ! defined (LOG4CPLUS_SINGLE_THREADED) \ 42 | && defined (LOG4CPLUS_HAVE_CXX11_ATOMICS) 43 | #include 44 | #endif 45 | 46 | 47 | namespace log4cplus { 48 | namespace helpers { 49 | 50 | /****************************************************************************** 51 | * Class SharedObject (from pp. 204-205) * 52 | ******************************************************************************/ 53 | 54 | class LOG4CPLUS_EXPORT SharedObject 55 | { 56 | public: 57 | void addReference() const; 58 | void removeReference() const; 59 | 60 | protected: 61 | // Ctor 62 | SharedObject() 63 | : access_mutex() 64 | , count(0) 65 | { } 66 | 67 | SharedObject(const SharedObject&) 68 | : access_mutex() 69 | , count(0) 70 | { } 71 | 72 | // Dtor 73 | virtual ~SharedObject(); 74 | 75 | // Operators 76 | SharedObject& operator=(const SharedObject&) { return *this; } 77 | 78 | public: 79 | thread::Mutex access_mutex; 80 | 81 | private: 82 | #if defined (LOG4CPLUS_SINGLE_THREADED) 83 | typedef unsigned count_type; 84 | #elif defined (LOG4CPLUS_HAVE_CXX11_ATOMICS) 85 | typedef std::atomic count_type; 86 | #elif defined (_WIN32) || defined (__CYGWIN__) 87 | typedef long count_type; 88 | #else 89 | typedef unsigned count_type; 90 | #endif 91 | mutable count_type count; 92 | }; 93 | 94 | 95 | /****************************************************************************** 96 | * Template Class SharedObjectPtr (from pp. 203, 206) * 97 | ******************************************************************************/ 98 | template 99 | class SharedObjectPtr 100 | { 101 | public: 102 | // Ctor 103 | explicit 104 | SharedObjectPtr(T* realPtr = 0) 105 | : pointee(realPtr) 106 | { 107 | addref (); 108 | } 109 | 110 | SharedObjectPtr(const SharedObjectPtr& rhs) 111 | : pointee(rhs.pointee) 112 | { 113 | addref (); 114 | } 115 | 116 | #if defined (LOG4CPLUS_HAVE_RVALUE_REFS) 117 | SharedObjectPtr(SharedObjectPtr && rhs) 118 | : pointee (std::move (rhs.pointee)) 119 | { 120 | rhs.pointee = 0; 121 | } 122 | 123 | SharedObjectPtr & operator = (SharedObjectPtr && rhs) 124 | { 125 | rhs.swap (*this); 126 | return *this; 127 | } 128 | #endif 129 | 130 | // Dtor 131 | ~SharedObjectPtr() 132 | { 133 | if (pointee) 134 | pointee->removeReference(); 135 | } 136 | 137 | // Operators 138 | bool operator==(const SharedObjectPtr& rhs) const { return (pointee == rhs.pointee); } 139 | bool operator!=(const SharedObjectPtr& rhs) const { return (pointee != rhs.pointee); } 140 | bool operator==(const T* rhs) const { return (pointee == rhs); } 141 | bool operator!=(const T* rhs) const { return (pointee != rhs); } 142 | T* operator->() const {assert (pointee); return pointee; } 143 | T& operator*() const {assert (pointee); return *pointee; } 144 | 145 | SharedObjectPtr& operator=(const SharedObjectPtr& rhs) 146 | { 147 | return this->operator = (rhs.pointee); 148 | } 149 | 150 | SharedObjectPtr& operator=(T* rhs) 151 | { 152 | SharedObjectPtr (rhs).swap (*this); 153 | return *this; 154 | } 155 | 156 | // Methods 157 | T* get() const { return pointee; } 158 | 159 | void swap (SharedObjectPtr & other) throw () 160 | { 161 | std::swap (pointee, other.pointee); 162 | } 163 | 164 | typedef T * (SharedObjectPtr:: * unspec_bool_type) () const; 165 | operator unspec_bool_type () const 166 | { 167 | return pointee ? &SharedObjectPtr::get : 0; 168 | } 169 | 170 | bool operator ! () const 171 | { 172 | return ! pointee; 173 | } 174 | 175 | private: 176 | // Methods 177 | void addref() const 178 | { 179 | if (pointee) 180 | pointee->addReference(); 181 | } 182 | 183 | // Data 184 | T* pointee; 185 | }; 186 | 187 | } // end namespace helpers 188 | } // end namespace log4cplus 189 | 190 | 191 | #endif // LOG4CPLUS_HELPERS_POINTERS_HEADER_ 192 | -------------------------------------------------------------------------------- /logging/log4cplus/helpers/property.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // Module: Log4CPLUS 3 | // File: property.h 4 | // Created: 2/2002 5 | // Author: Tad E. Smith 6 | // 7 | // 8 | // Copyright 2002-2013 Tad E. Smith 9 | // 10 | // Licensed under the Apache License, Version 2.0 (the "License"); 11 | // you may not use this file except in compliance with the License. 12 | // You may obtain a copy of the License at 13 | // 14 | // http://www.apache.org/licenses/LICENSE-2.0 15 | // 16 | // Unless required by applicable law or agreed to in writing, software 17 | // distributed under the License is distributed on an "AS IS" BASIS, 18 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | // See the License for the specific language governing permissions and 20 | // limitations under the License. 21 | 22 | /** @file */ 23 | 24 | #ifndef LOG4CPLUS_HELPERS_PROPERTY_HEADER_ 25 | #define LOG4CPLUS_HELPERS_PROPERTY_HEADER_ 26 | 27 | #include 28 | 29 | #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE) 30 | #pragma once 31 | #endif 32 | 33 | #include 34 | #include 35 | #include 36 | #include 37 | 38 | 39 | namespace log4cplus { 40 | namespace helpers { 41 | 42 | //! \sa log4cplus::PropertyConfigurator 43 | class LOG4CPLUS_EXPORT Properties { 44 | public: 45 | enum PFlags 46 | { 47 | // These encoding related options occupy 2 bits of the flags 48 | // and are mutually exclusive. These flags are synchronized 49 | // with PCFlags in PropertyConfigurator. 50 | 51 | fEncodingShift = 3 52 | , fEncodingMask = 0x3 53 | , fUnspecEncoding = (0 << fEncodingShift) 54 | #if defined (LOG4CPLUS_HAVE_CODECVT_UTF8_FACET) && defined (UNICODE) 55 | , fUTF8 = (1 << fEncodingShift) 56 | #endif 57 | #if (defined (LOG4CPLUS_HAVE_CODECVT_UTF16_FACET) || defined (_WIN32)) \ 58 | && defined (UNICODE) 59 | , fUTF16 = (2 << fEncodingShift) 60 | #endif 61 | #if defined (LOG4CPLUS_HAVE_CODECVT_UTF32_FACET) && defined (UNICODE) 62 | , fUTF32 = (3 << fEncodingShift) 63 | #endif 64 | }; 65 | 66 | Properties(); 67 | explicit Properties(log4cplus::tistream& input); 68 | explicit Properties(const log4cplus::tstring& inputFile, unsigned flags = 0); 69 | virtual ~Properties(); 70 | 71 | // constants 72 | static const tchar PROPERTIES_COMMENT_CHAR; 73 | 74 | // methods 75 | /** 76 | * Tests to see if key can be found in this map. 77 | */ 78 | bool exists(const log4cplus::tstring& key) const; 79 | bool exists(tchar const * key) const; 80 | 81 | /** 82 | * Returns the number of entries in this map. 83 | */ 84 | std::size_t size() const 85 | { 86 | return data.size(); 87 | } 88 | 89 | /** 90 | * Searches for the property with the specified key in this property 91 | * list. If the key is not found in this property list, the default 92 | * property list, and its defaults, recursively, are then checked. 93 | * The method returns null if the property is not found. 94 | */ 95 | log4cplus::tstring const & getProperty(const log4cplus::tstring& key) const; 96 | log4cplus::tstring const & getProperty(tchar const * key) const; 97 | 98 | /** 99 | * Searches for the property with the specified key in this property 100 | * list. If the key is not found in this property list, the default 101 | * property list, and its defaults, recursively, are then checked. 102 | * The method returns the default value argument if the property is 103 | * not found. 104 | */ 105 | log4cplus::tstring getProperty(const log4cplus::tstring& key, 106 | const log4cplus::tstring& defaultVal) const; 107 | 108 | /** 109 | * Returns all the keys in this property list. 110 | */ 111 | std::vector propertyNames() const; 112 | 113 | /** 114 | * Inserts value into this map indexed by key. 115 | */ 116 | void setProperty(const log4cplus::tstring& key, const log4cplus::tstring& value); 117 | 118 | /** 119 | * Removed the property index by key from this map. 120 | */ 121 | bool removeProperty(const log4cplus::tstring& key); 122 | 123 | /** 124 | * Returns a subset of the "properties" whose keys start with 125 | * "prefix". The returned "properties" have "prefix" trimmed from 126 | * their keys. 127 | */ 128 | Properties getPropertySubset(const log4cplus::tstring& prefix) const; 129 | 130 | bool getInt (int & val, log4cplus::tstring const & key) const; 131 | bool getUInt (unsigned & val, log4cplus::tstring const & key) const; 132 | bool getLong (long & val, log4cplus::tstring const & key) const; 133 | bool getULong (unsigned long & val, log4cplus::tstring const & key) const; 134 | bool getBool (bool & val, log4cplus::tstring const & key) const; 135 | 136 | protected: 137 | // Types 138 | typedef std::map StringMap; 139 | 140 | // Methods 141 | void init(log4cplus::tistream& input); 142 | 143 | // Data 144 | StringMap data; 145 | unsigned flags; 146 | 147 | private: 148 | template 149 | log4cplus::tstring const & get_property_worker ( 150 | StringType const & key) const; 151 | 152 | template 153 | bool get_type_val_worker (ValType & val, 154 | log4cplus::tstring const & key) const; 155 | }; 156 | } // end namespace helpers 157 | 158 | } 159 | 160 | 161 | #endif // LOG4CPLUS_HELPERS_PROPERTY_HEADER_ 162 | 163 | -------------------------------------------------------------------------------- /logging/log4cplus/config.hxx: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2009-2013, Vaclav Haisman. All rights reserved. 2 | // 3 | // Redistribution and use in source and binary forms, with or without modifica- 4 | // tion, are permitted provided that the following conditions are met: 5 | // 6 | // 1. Redistributions of source code must retain the above copyright notice, 7 | // this list of conditions and the following disclaimer. 8 | // 9 | // 2. Redistributions in binary form must reproduce the above copyright notice, 10 | // this list of conditions and the following disclaimer in the documentation 11 | // and/or other materials provided with the distribution. 12 | // 13 | // THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 14 | // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 15 | // FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 16 | // APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 17 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- 18 | // DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 19 | // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 20 | // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 22 | // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 | 24 | #ifndef LOG4CPLUS_CONFIG_HXX 25 | #define LOG4CPLUS_CONFIG_HXX 26 | 27 | #if defined (_WIN32) 28 | # include 29 | #elif (defined(__MWERKS__) && defined(__MACOS__)) 30 | # include 31 | #else 32 | # include 33 | #endif 34 | 35 | #if ! defined (UNICODE) && ! defined (LOG4CPLUS_HAVE_VSNPRINTF_S) \ 36 | && ! defined (LOG4CPLUS_HAVE__VSNPRINTF_S) \ 37 | && ! defined (LOG4CPLUS_HAVE_VSNPRINTF) \ 38 | && ! defined (LOG4CPLUS_HAVE__VSNPRINTF) 39 | # undef LOG4CPLUS_USE_POOR_MANS_SNPRINTF 40 | # define LOG4CPLUS_USE_POOR_MANS_SNPRINTF 41 | #endif 42 | 43 | # if ! defined (LOG4CPLUS_WORKING_LOCALE) \ 44 | && ! defined (LOG4CPLUS_WORKING_C_LOCALE) \ 45 | && ! defined (LOG4CPLUS_WITH_ICONV) 46 | # define LOG4CPLUS_POOR_MANS_CHCONV 47 | #endif 48 | 49 | #ifndef LOG4CPLUS_DECLSPEC_EXPORT 50 | #define LOG4CPLUS_DECLSPEC_EXPORT /* empty */ 51 | #endif 52 | 53 | #ifndef LOG4CPLUS_DECLSPEC_IMPORT 54 | #define LOG4CPLUS_DECLSPEC_IMPORT /* empty */ 55 | #endif 56 | 57 | #ifndef LOG4CPLUS_DECLSPEC_PRIVATE 58 | #define LOG4CPLUS_DECLSPEC_PRIVATE /* empty */ 59 | #endif 60 | 61 | #define LOG4CPLUS_PRIVATE LOG4CPLUS_DECLSPEC_PRIVATE 62 | 63 | #if !defined(_WIN32) 64 | # define LOG4CPLUS_USE_BSD_SOCKETS 65 | # if !defined(LOG4CPLUS_SINGLE_THREADED) 66 | # define LOG4CPLUS_USE_PTHREADS 67 | # endif 68 | # if defined (INSIDE_LOG4CPLUS) 69 | # define LOG4CPLUS_EXPORT LOG4CPLUS_DECLSPEC_EXPORT 70 | # else 71 | # define LOG4CPLUS_EXPORT LOG4CPLUS_DECLSPEC_IMPORT 72 | # endif // defined (INSIDE_LOG4CPLUS) 73 | 74 | #endif // !_WIN32 75 | 76 | #if defined (LOG4CPLUS_INLINES_ARE_EXPORTED) \ 77 | && defined (LOG4CPLUS_BUILD_DLL) 78 | # define LOG4CPLUS_INLINE_EXPORT inline 79 | #else 80 | # define LOG4CPLUS_INLINE_EXPORT 81 | #endif 82 | 83 | #if defined (UNICODE) 84 | # if defined (_MSC_VER) && _MSC_VER >= 1400 85 | # define LOG4CPLUS_FSTREAM_ACCEPTS_WCHAR_T 86 | # endif 87 | # if defined (_MSC_VER) && _MSC_VER >= 1600 88 | # define LOG4CPLUS_HAVE_CODECVT_UTF8_FACET 89 | # define LOG4CPLUS_HAVE_CODECVT_UTF16_FACET 90 | # endif 91 | #endif 92 | 93 | // C++11 stuff 94 | 95 | #if ! defined (__has_feature) 96 | //! __has_feature(X) is Clangs way for testing features. 97 | //! Define it to 0 if it does not exist. 98 | # define __has_feature(X) 0 99 | #endif 100 | 101 | #if (defined (_MSC_VER) && _MSC_VER >= 1600) \ 102 | || defined (__GXX_EXPERIMENTAL_CXX0X__) \ 103 | || __cplusplus >= 201103L 104 | # define LOG4CPLUS_HAVE_CXX11_SUPPORT 105 | #endif 106 | 107 | #if defined (LOG4CPLUS_HAVE_CXX11_SUPPORT) \ 108 | || __has_feature (cxx_rvalue_references) 109 | # define LOG4CPLUS_HAVE_RVALUE_REFS 110 | #endif 111 | 112 | #if ! defined (UNICODE) && defined (__GNUC__) && __GNUC__ >= 3 113 | # define LOG4CPLUS_FORMAT_ATTRIBUTE(archetype, format_index, first_arg_index) \ 114 | __attribute__ ((format (archetype, format_index, first_arg_index))) 115 | #else 116 | # define LOG4CPLUS_FORMAT_ATTRIBUTE(archetype, fmt_index, first_arg_index) \ 117 | /* empty */ 118 | #endif 119 | 120 | #if defined (__GNUC__) && __GNUC__ >= 3 121 | # define LOG4CPLUS_ATTRIBUTE_NORETURN __attribute__ ((__noreturn__)) 122 | # define LOG4CPLUS_ATTRIBUTE_PURE __attribute__ ((__pure__)) 123 | # define LOG4CPLUS_BUILTIN_EXPECT(exp, c) __builtin_expect ((exp), (c)) 124 | #else 125 | # if ! defined (LOG4CPLUS_ATTRIBUTE_NORETURN) 126 | # define LOG4CPLUS_ATTRIBUTE_NORETURN /* empty */ 127 | # endif 128 | # define LOG4CPLUS_ATTRIBUTE_PURE /* empty */ 129 | # define LOG4CPLUS_BUILTIN_EXPECT(exp, c) (exp) 130 | #endif 131 | 132 | #define LOG4CPLUS_LIKELY(cond) LOG4CPLUS_BUILTIN_EXPECT(!! (cond), 1) 133 | #define LOG4CPLUS_UNLIKELY(cond) LOG4CPLUS_BUILTIN_EXPECT(!! (cond), 0) 134 | 135 | #if defined (_MSC_VER) \ 136 | || (defined (__BORLANDC__) && __BORLANDC__ >= 0x0650) \ 137 | || (defined (__COMO__) && __COMO_VERSION__ >= 400) /* ??? */ \ 138 | || (defined (__DMC__) && __DMC__ >= 0x700) /* ??? */ \ 139 | || (defined (__clang__) && __clang_major__ >= 3) \ 140 | || (defined (__GNUC__) && (__GNUC__ >= 4 \ 141 | || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))) 142 | # define LOG4CPLUS_HAVE_PRAGMA_ONCE 143 | # pragma once 144 | #endif 145 | 146 | #include 147 | 148 | #if defined(__cplusplus) 149 | namespace log4cplus 150 | { 151 | 152 | //! Per thread cleanup function. Users should call this function before 153 | //! a thread ends its execution. It frees resources allocated in thread local 154 | //! storage. It is important only for multi-threaded static library builds 155 | //! of log4cplus and user threads. In all other cases the clean up is provided 156 | //! automatically by other means. 157 | LOG4CPLUS_EXPORT void threadCleanup (); 158 | 159 | //! Initializes log4cplus. 160 | LOG4CPLUS_EXPORT void initialize (); 161 | 162 | } // namespace log4cplus 163 | 164 | #endif 165 | 166 | #endif // LOG4CPLUS_CONFIG_HXX 167 | -------------------------------------------------------------------------------- /include/srt/channel.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SRT - Secure, Reliable, Transport 3 | * Copyright (c) 2018 Haivision Systems Inc. 4 | * 5 | * This Source Code Form is subject to the terms of the Mozilla Public 6 | * License, v. 2.0. If a copy of the MPL was not distributed with this 7 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 8 | * 9 | */ 10 | 11 | /***************************************************************************** 12 | Copyright (c) 2001 - 2011, The Board of Trustees of the University of Illinois. 13 | All rights reserved. 14 | 15 | Redistribution and use in source and binary forms, with or without 16 | modification, are permitted provided that the following conditions are 17 | met: 18 | 19 | * Redistributions of source code must retain the above 20 | copyright notice, this list of conditions and the 21 | following disclaimer. 22 | 23 | * Redistributions in binary form must reproduce the 24 | above copyright notice, this list of conditions 25 | and the following disclaimer in the documentation 26 | and/or other materials provided with the distribution. 27 | 28 | * Neither the name of the University of Illinois 29 | nor the names of its contributors may be used to 30 | endorse or promote products derived from this 31 | software without specific prior written permission. 32 | 33 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 34 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 35 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 36 | PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 37 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 38 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 39 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 40 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 41 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 42 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 43 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 44 | *****************************************************************************/ 45 | 46 | /***************************************************************************** 47 | written by 48 | Yunhong Gu, last updated 01/27/2011 49 | modified by 50 | Haivision Systems Inc. 51 | *****************************************************************************/ 52 | 53 | #ifndef __UDT_CHANNEL_H__ 54 | #define __UDT_CHANNEL_H__ 55 | 56 | 57 | #include "udt.h" 58 | #include "packet.h" 59 | #include "netinet_any.h" 60 | 61 | class CChannel 62 | { 63 | public: 64 | 65 | // XXX There's currently no way to access the socket ID set for 66 | // whatever the channel is currently working for. Required to find 67 | // some way to do this, possibly by having a "reverse pointer". 68 | // Currently just "unimplemented". 69 | std::string CONID() const { return ""; } 70 | 71 | CChannel(); 72 | CChannel(int version); 73 | ~CChannel(); 74 | 75 | /// Open a UDP channel. 76 | /// @param [in] addr The local address that UDP will use. 77 | 78 | void open(const sockaddr* addr = NULL); 79 | 80 | /// Open a UDP channel based on an existing UDP socket. 81 | /// @param [in] udpsock UDP socket descriptor. 82 | 83 | void attach(UDPSOCKET udpsock); 84 | 85 | /// Disconnect and close the UDP entity. 86 | 87 | void close() const; 88 | 89 | /// Get the UDP sending buffer size. 90 | /// @return Current UDP sending buffer size. 91 | 92 | int getSndBufSize(); 93 | 94 | /// Get the UDP receiving buffer size. 95 | /// @return Current UDP receiving buffer size. 96 | 97 | int getRcvBufSize(); 98 | 99 | /// Set the UDP sending buffer size. 100 | /// @param [in] size expected UDP sending buffer size. 101 | 102 | void setSndBufSize(int size); 103 | 104 | /// Set the UDP receiving buffer size. 105 | /// @param [in] size expected UDP receiving buffer size. 106 | 107 | void setRcvBufSize(int size); 108 | 109 | /// Query the socket address that the channel is using. 110 | /// @param [out] addr pointer to store the returned socket address. 111 | 112 | void getSockAddr(sockaddr* addr) const; 113 | 114 | /// Query the peer side socket address that the channel is connect to. 115 | /// @param [out] addr pointer to store the returned socket address. 116 | 117 | void getPeerAddr(sockaddr* addr) const; 118 | 119 | /// Send a packet to the given address. 120 | /// @param [in] addr pointer to the destination address. 121 | /// @param [in] packet reference to a CPacket entity. 122 | /// @return Actual size of data sent. 123 | 124 | int sendto(const sockaddr* addr, CPacket& packet) const; 125 | 126 | /// Receive a packet from the channel and record the source address. 127 | /// @param [in] addr pointer to the source address. 128 | /// @param [in] packet reference to a CPacket entity. 129 | /// @return Actual size of data received. 130 | 131 | EReadStatus recvfrom(sockaddr* addr, CPacket& packet) const; 132 | 133 | #ifdef SRT_ENABLE_IPOPTS 134 | /// Set the IP TTL. 135 | /// @param [in] ttl IP Time To Live. 136 | /// @return none. 137 | 138 | void setIpTTL(int ttl); 139 | 140 | /// Set the IP Type of Service. 141 | /// @param [in] tos IP Type of Service. 142 | 143 | void setIpToS(int tos); 144 | 145 | /// Get the IP TTL. 146 | /// @param [in] ttl IP Time To Live. 147 | /// @return TTL. 148 | 149 | int getIpTTL() const; 150 | 151 | /// Get the IP Type of Service. 152 | /// @return ToS. 153 | 154 | int getIpToS() const; 155 | #endif 156 | 157 | int ioctlQuery(int type) const; 158 | int sockoptQuery(int level, int option) const; 159 | 160 | const sockaddr* bindAddress() { return &m_BindAddr; } 161 | const sockaddr_any& bindAddressAny() { return m_BindAddr; } 162 | 163 | private: 164 | void setUDPSockOpt(); 165 | 166 | private: 167 | int m_iIPversion; // IP version 168 | int m_iSockAddrSize; // socket address structure size (pre-defined to avoid run-time test) 169 | 170 | UDPSOCKET m_iSocket; // socket descriptor 171 | #ifdef SRT_ENABLE_IPOPTS 172 | int m_iIpTTL; 173 | int m_iIpToS; 174 | #endif 175 | int m_iSndBufSize; // UDP sending buffer size 176 | int m_iRcvBufSize; // UDP receiving buffer size 177 | sockaddr_any m_BindAddr; 178 | }; 179 | 180 | 181 | #endif 182 | -------------------------------------------------------------------------------- /logging/log4cplus/internal/internal.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // Module: Log4CPLUS 3 | // File: internal.h 4 | // Created: 1/2009 5 | // Author: Vaclav Haisman 6 | // 7 | // 8 | // Copyright (C) 2009-2013, Vaclav Haisman. All rights reserved. 9 | // 10 | // Redistribution and use in source and binary forms, with or without modifica- 11 | // tion, are permitted provided that the following conditions are met: 12 | // 13 | // 1. Redistributions of source code must retain the above copyright notice, 14 | // this list of conditions and the following disclaimer. 15 | // 16 | // 2. Redistributions in binary form must reproduce the above copyright notice, 17 | // this list of conditions and the following disclaimer in the documentation 18 | // and/or other materials provided with the distribution. 19 | // 20 | // THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 21 | // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 22 | // FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 23 | // APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 24 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- 25 | // DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 26 | // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 27 | // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 29 | // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | /** @file 32 | * This header contains declaration internal to log4cplus. They must never be 33 | * visible from user accesible headers or exported in DLL/shared libray. 34 | */ 35 | 36 | 37 | #ifndef LOG4CPLUS_INTERNAL_INTERNAL_HEADER_ 38 | #define LOG4CPLUS_INTERNAL_INTERNAL_HEADER_ 39 | 40 | #include 41 | 42 | #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE) 43 | #pragma once 44 | #endif 45 | 46 | #if ! defined (INSIDE_LOG4CPLUS) 47 | # error "This header must not be be used outside log4cplus' implementation files." 48 | #endif 49 | 50 | #include 51 | #include 52 | #include 53 | #include 54 | #include 55 | #include 56 | #include 57 | #include 58 | #include 59 | #include 60 | #include 61 | 62 | 63 | namespace log4cplus { 64 | 65 | namespace internal { 66 | 67 | 68 | //! Canonical empty string. It is used when the need to return empty string 69 | //! by reference arises. 70 | extern log4cplus::tstring const empty_str; 71 | 72 | 73 | struct gft_scratch_pad 74 | { 75 | gft_scratch_pad (); 76 | ~gft_scratch_pad (); 77 | 78 | void 79 | reset () 80 | { 81 | uc_q_str_valid = false; 82 | q_str_valid = false; 83 | s_str_valid = false; 84 | ret.clear (); 85 | } 86 | 87 | log4cplus::tstring q_str; 88 | log4cplus::tstring uc_q_str; 89 | log4cplus::tstring s_str; 90 | log4cplus::tstring ret; 91 | log4cplus::tstring fmt; 92 | log4cplus::tstring tmp; 93 | std::vector buffer; 94 | bool uc_q_str_valid; 95 | bool q_str_valid; 96 | bool s_str_valid; 97 | }; 98 | 99 | 100 | struct appender_sratch_pad 101 | { 102 | appender_sratch_pad (); 103 | ~appender_sratch_pad (); 104 | 105 | tostringstream oss; 106 | tstring str; 107 | std::string chstr; 108 | }; 109 | 110 | 111 | //! Per thread data. 112 | struct per_thread_data 113 | { 114 | per_thread_data (); 115 | ~per_thread_data (); 116 | 117 | tostringstream macros_oss; 118 | tostringstream layout_oss; 119 | DiagnosticContextStack ndc_dcs; 120 | MappedDiagnosticContextMap mdc_map; 121 | log4cplus::tstring thread_name; 122 | log4cplus::tstring thread_name2; 123 | gft_scratch_pad gft_sp; 124 | appender_sratch_pad appender_sp; 125 | log4cplus::tstring faa_str; 126 | log4cplus::tstring ll_str; 127 | spi::InternalLoggingEvent forced_log_ev; 128 | std::FILE * fnull; 129 | log4cplus::helpers::snprintf_buf snprintf_buf; 130 | }; 131 | 132 | 133 | per_thread_data * alloc_ptd (); 134 | 135 | // TLS key whose value is pointer struct per_thread_data. 136 | extern log4cplus::thread::impl::tls_key_type tls_storage_key; 137 | 138 | 139 | #if ! defined (LOG4CPLUS_SINGLE_THREADED) \ 140 | && defined (LOG4CPLUS_THREAD_LOCAL_VAR) 141 | 142 | extern LOG4CPLUS_THREAD_LOCAL_VAR per_thread_data * ptd; 143 | 144 | 145 | inline 146 | void 147 | set_ptd (per_thread_data * p) 148 | { 149 | ptd = p; 150 | } 151 | 152 | 153 | inline 154 | per_thread_data * 155 | get_ptd (bool alloc = true) 156 | { 157 | if (LOG4CPLUS_UNLIKELY (! ptd && alloc)) 158 | return alloc_ptd (); 159 | 160 | // The assert() does not belong here. get_ptd() might be called by 161 | // cleanup code that can handle the returned NULL pointer. 162 | //assert (ptd); 163 | 164 | return ptd; 165 | } 166 | 167 | 168 | #else // defined (LOG4CPLUS_THREAD_LOCAL_VAR) 169 | 170 | 171 | inline 172 | void 173 | set_ptd (per_thread_data * p) 174 | { 175 | thread::impl::tls_set_value (tls_storage_key, p); 176 | } 177 | 178 | 179 | inline 180 | per_thread_data * 181 | get_ptd (bool alloc = true) 182 | { 183 | per_thread_data * ptd 184 | = reinterpret_cast( 185 | thread::impl::tls_get_value (tls_storage_key)); 186 | 187 | if (LOG4CPLUS_UNLIKELY (! ptd && alloc)) 188 | return alloc_ptd (); 189 | 190 | return ptd; 191 | } 192 | 193 | 194 | #endif // defined (LOG4CPLUS_THREAD_LOCAL_VAR) 195 | 196 | 197 | inline 198 | tstring & 199 | get_thread_name_str () 200 | { 201 | return get_ptd ()->thread_name; 202 | } 203 | 204 | 205 | inline 206 | tstring & 207 | get_thread_name2_str () 208 | { 209 | return get_ptd ()->thread_name2; 210 | } 211 | 212 | 213 | inline 214 | gft_scratch_pad & 215 | get_gft_scratch_pad () 216 | { 217 | return get_ptd ()->gft_sp; 218 | } 219 | 220 | 221 | inline 222 | appender_sratch_pad & 223 | get_appender_sp () 224 | { 225 | return get_ptd ()->appender_sp; 226 | } 227 | 228 | 229 | } // namespace internal { 230 | 231 | 232 | namespace detail 233 | { 234 | 235 | LOG4CPLUS_EXPORT void clear_tostringstream (tostringstream &); 236 | 237 | } // namespace detail 238 | 239 | 240 | } // namespace log4cplus { 241 | 242 | 243 | #endif // LOG4CPLUS_INTERNAL_INTERNAL_HEADER_ 244 | -------------------------------------------------------------------------------- /logging/log4cplus/thread/impl/syncprims-impl.h: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // Copyright (C) 2009-2013, Vaclav Haisman. All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without modifica- 5 | // tion, are permitted provided that the following conditions are met: 6 | // 7 | // 1. Redistributions of source code must retain the above copyright notice, 8 | // this list of conditions and the following disclaimer. 9 | // 10 | // 2. Redistributions in binary form must reproduce the above copyright notice, 11 | // this list of conditions and the following disclaimer in the documentation 12 | // and/or other materials provided with the distribution. 13 | // 14 | // THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 15 | // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 16 | // FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 17 | // APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 18 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- 19 | // DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 20 | // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 21 | // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | 25 | #ifndef LOG4CPLUS_THREAD_SYNCPRIMS_IMPL_H 26 | #define LOG4CPLUS_THREAD_SYNCPRIMS_IMPL_H 27 | 28 | #include 29 | 30 | #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE) 31 | #pragma once 32 | #endif 33 | 34 | #if ! defined (INSIDE_LOG4CPLUS) 35 | # error "This header must not be be used outside log4cplus' implementation files." 36 | #endif 37 | 38 | #include 39 | #include 40 | #if defined (_WIN32) 41 | # include 42 | 43 | #elif defined (LOG4CPLUS_USE_PTHREADS) 44 | # include 45 | # include 46 | # include 47 | # if defined (LOG4CPLUS_USE_NAMED_POSIX_SEMAPHORE) 48 | # include 49 | # include 50 | # if defined (LOG4CPLUS_HAVE_SYS_TYPES_H) 51 | # include 52 | # endif 53 | # if defined (LOG4CPLUS_HAVE_UNISTD_H) 54 | # include 55 | # endif 56 | # endif 57 | # if defined (LOG4CPLUS_HAVE_FCNTL_H) 58 | # include 59 | # endif 60 | # include 61 | 62 | #endif 63 | 64 | 65 | namespace log4cplus { namespace thread { namespace impl { 66 | 67 | 68 | LOG4CPLUS_EXPORT void LOG4CPLUS_ATTRIBUTE_NORETURN 69 | syncprims_throw_exception (char const * const msg, 70 | char const * const file, int line); 71 | 72 | 73 | #define LOG4CPLUS_THROW_RTE(msg) \ 74 | do { syncprims_throw_exception (msg, __FILE__, __LINE__); } while (0) 75 | 76 | 77 | class ManualResetEvent; 78 | 79 | 80 | class Mutex 81 | : public MutexImplBase 82 | { 83 | public: 84 | explicit Mutex (log4cplus::thread::Mutex::Type); 85 | ~Mutex (); 86 | 87 | void lock () const; 88 | void unlock () const; 89 | 90 | private: 91 | #if defined (LOG4CPLUS_USE_PTHREADS) 92 | mutable pthread_mutex_t mtx; 93 | friend class ManualResetEvent; 94 | #elif defined (LOG4CPLUS_USE_WIN32_THREADS) 95 | mutable CRITICAL_SECTION cs; 96 | #endif 97 | 98 | Mutex (Mutex const &); 99 | Mutex & operator = (Mutex &); 100 | }; 101 | 102 | 103 | typedef SyncGuard MutexGuard; 104 | 105 | 106 | class Semaphore 107 | : public SemaphoreImplBase 108 | { 109 | public: 110 | Semaphore (unsigned max, unsigned initial); 111 | ~Semaphore (); 112 | 113 | void lock () const; 114 | void unlock () const; 115 | 116 | private: 117 | #if defined (LOG4CPLUS_USE_PTHREADS) 118 | # if defined (LOG4CPLUS_USE_NAMED_POSIX_SEMAPHORE) 119 | sem_t * sem; 120 | # else 121 | mutable sem_t sem; 122 | # endif 123 | #elif defined (LOG4CPLUS_USE_WIN32_THREADS) 124 | HANDLE sem; 125 | #endif 126 | 127 | Semaphore (Semaphore const &); 128 | Semaphore & operator = (Semaphore const &); 129 | }; 130 | 131 | 132 | typedef SyncGuard SemaphoreGuard; 133 | 134 | 135 | class FairMutex 136 | : public FairMutexImplBase 137 | { 138 | public: 139 | FairMutex (); 140 | ~FairMutex (); 141 | 142 | void lock () const; 143 | void unlock () const; 144 | 145 | private: 146 | #if defined (LOG4CPLUS_USE_PTHREADS) 147 | Semaphore sem; 148 | #elif defined (LOG4CPLUS_USE_WIN32_THREADS) 149 | HANDLE mtx; 150 | #endif 151 | 152 | FairMutex (FairMutex const &); 153 | FairMutex & operator = (FairMutex &); 154 | }; 155 | 156 | 157 | typedef SyncGuard FairMutexGuard; 158 | 159 | 160 | class ManualResetEvent 161 | : public ManualResetEventImplBase 162 | { 163 | public: 164 | ManualResetEvent (bool = false); 165 | ~ManualResetEvent (); 166 | 167 | void signal () const; 168 | void wait () const; 169 | bool timed_wait (unsigned long msec) const; 170 | void reset () const; 171 | 172 | private: 173 | #if defined (LOG4CPLUS_USE_PTHREADS) 174 | mutable pthread_cond_t cv; 175 | mutable Mutex mtx; 176 | mutable volatile unsigned sigcount; 177 | mutable volatile bool signaled; 178 | #elif defined (LOG4CPLUS_USE_WIN32_THREADS) 179 | HANDLE ev; 180 | #endif 181 | 182 | ManualResetEvent (ManualResetEvent const &); 183 | ManualResetEvent & operator = (ManualResetEvent const &); 184 | }; 185 | 186 | 187 | class SharedMutex 188 | : public SharedMutexImplBase 189 | { 190 | public: 191 | SharedMutex (); 192 | ~SharedMutex (); 193 | 194 | void rdlock () const; 195 | void wrlock () const; 196 | void rdunlock () const; 197 | void wrunlock () const; 198 | 199 | private: 200 | #if defined (LOG4CPLUS_POOR_MANS_SHAREDMUTEX) 201 | Mutex m1; 202 | Mutex m2; 203 | Mutex m3; 204 | Semaphore w; 205 | mutable unsigned writer_count; 206 | Semaphore r; 207 | mutable unsigned reader_count; 208 | 209 | #elif defined (LOG4CPLUS_USE_PTHREADS) 210 | void unlock () const; 211 | 212 | mutable pthread_rwlock_t rwl; 213 | 214 | #elif defined (LOG4CPLUS_USE_SRW_LOCK) 215 | mutable SRWLOCK srwl; 216 | 217 | #endif 218 | 219 | SharedMutex (SharedMutex const &); 220 | SharedMutex & operator = (SharedMutex const &); 221 | }; 222 | 223 | 224 | } } } // namespace log4cplus { namespace thread { namespace impl { 225 | 226 | 227 | // Include the appropriate implementations of the classes declared 228 | // above. 229 | 230 | #if defined (LOG4CPLUS_USE_PTHREADS) 231 | # include 232 | #elif defined (LOG4CPLUS_USE_WIN32_THREADS) 233 | # include 234 | #endif 235 | 236 | 237 | #undef LOG4CPLUS_THROW_RTE 238 | 239 | 240 | #endif // LOG4CPLUS_THREAD_SYNCPRIMS_IMPL_H 241 | -------------------------------------------------------------------------------- /logging/log4cplus/config/defines.hxx: -------------------------------------------------------------------------------- 1 | /* include/log4cplus/config/defines.hxx. Generated from defines.hxx.in by configure. */ 2 | #ifndef LOG4CPLUS_CONFIG_DEFINES_HXX 3 | #define LOG4CPLUS_CONFIG_DEFINES_HXX 4 | 5 | /* */ 6 | #define LOG4CPLUS_HAVE_SYSLOG_H 1 7 | 8 | /* */ 9 | #define LOG4CPLUS_HAVE_ARPA_INET_H 1 10 | 11 | /* */ 12 | #define LOG4CPLUS_HAVE_NETINET_IN_H 1 13 | 14 | /* */ 15 | #define LOG4CPLUS_HAVE_NETINET_TCP_H 1 16 | 17 | /* */ 18 | #define LOG4CPLUS_HAVE_SYS_TIMEB_H 1 19 | 20 | /* */ 21 | #define LOG4CPLUS_HAVE_SYS_TIME_H 1 22 | 23 | /* */ 24 | #define LOG4CPLUS_HAVE_SYS_TYPES_H 1 25 | 26 | /* */ 27 | #define LOG4CPLUS_HAVE_SYS_STAT_H 1 28 | 29 | /* */ 30 | #define LOG4CPLUS_HAVE_SYS_SYSCALL_H 1 31 | 32 | /* */ 33 | #define LOG4CPLUS_HAVE_SYS_FILE_H 1 34 | 35 | /* */ 36 | #define LOG4CPLUS_HAVE_TIME_H 1 37 | 38 | /* */ 39 | #define LOG4CPLUS_HAVE_SYS_SOCKET_H 1 40 | 41 | /* */ 42 | #define LOG4CPLUS_HAVE_NETDB_H 1 43 | 44 | /* */ 45 | #define LOG4CPLUS_HAVE_UNISTD_H 1 46 | 47 | /* */ 48 | #define LOG4CPLUS_HAVE_FCNTL_H 1 49 | 50 | /* */ 51 | #define LOG4CPLUS_HAVE_STDARG_H 1 52 | 53 | /* */ 54 | #define LOG4CPLUS_HAVE_STDIO_H 1 55 | 56 | /* */ 57 | #define LOG4CPLUS_HAVE_STDLIB_H 1 58 | 59 | /* */ 60 | #define LOG4CPLUS_HAVE_ERRNO_H 1 61 | 62 | /* */ 63 | #define LOG4CPLUS_HAVE_WCHAR_H 1 64 | 65 | /* */ 66 | /* #undef LOG4CPLUS_HAVE_ICONV_H */ 67 | 68 | /* */ 69 | #define LOG4CPLUS_HAVE_LIMITS_H 1 70 | 71 | /* */ 72 | #define LOG4CPLUS_HAVE_FTIME 1 73 | 74 | /* */ 75 | #define LOG4CPLUS_HAVE_GETADDRINFO 1 76 | 77 | /* */ 78 | #define LOG4CPLUS_HAVE_GETHOSTBYNAME_R 1 79 | 80 | /* */ 81 | #define LOG4CPLUS_HAVE_GETPID 1 82 | 83 | /* */ 84 | #define LOG4CPLUS_HAVE_GETTIMEOFDAY 1 85 | 86 | /* Define to 1 if you have the `clock_gettime' function. */ 87 | #define LOG4CPLUS_HAVE_CLOCK_GETTIME 1 88 | 89 | /* Define to 1 if you have the `nanosleep' function. */ 90 | #define LOG4CPLUS_HAVE_NANOSLEEP 1 91 | 92 | /* Define to 1 if you have the `clock_nanosleep' function. */ 93 | #define LOG4CPLUS_HAVE_CLOCK_NANOSLEEP 1 94 | 95 | /* */ 96 | #define LOG4CPLUS_HAVE_GMTIME_R 1 97 | 98 | /* */ 99 | #define LOG4CPLUS_HAVE_HTONL 1 100 | 101 | /* */ 102 | #define LOG4CPLUS_HAVE_HTONS 1 103 | 104 | /* */ 105 | #define LOG4CPLUS_HAVE_LOCALTIME_R 1 106 | 107 | /* */ 108 | #define LOG4CPLUS_HAVE_LSTAT 1 109 | 110 | /* */ 111 | #define LOG4CPLUS_HAVE_FCNTL 1 112 | 113 | /* */ 114 | #define LOG4CPLUS_HAVE_LOCKF 1 115 | 116 | /* */ 117 | #define LOG4CPLUS_HAVE_FLOCK 1 118 | 119 | /* */ 120 | #define LOG4CPLUS_HAVE_NTOHL 1 121 | 122 | /* */ 123 | #define LOG4CPLUS_HAVE_NTOHS 1 124 | 125 | /* Define to 1 if you have the `shutdown' function. */ 126 | #define LOG4CPLUS_HAVE_SHUTDOWN 1 127 | 128 | /* */ 129 | #define LOG4CPLUS_HAVE_PIPE 1 130 | 131 | /* */ 132 | #define LOG4CPLUS_HAVE_PIPE2 1 133 | 134 | /* */ 135 | #define LOG4CPLUS_HAVE_POLL 1 136 | 137 | /* */ 138 | #define LOG4CPLUS_HAVE_POLL_H 1 139 | 140 | /* */ 141 | #define LOG4CPLUS_HAVE_STAT 1 142 | 143 | /* Define if this is a single-threaded library. */ 144 | /* #undef LOG4CPLUS_SINGLE_THREADED */ 145 | 146 | /* */ 147 | /* #undef LOG4CPLUS_USE_PTHREADS */ 148 | 149 | /* Define for compilers/standard libraries that support more than just the "C" 150 | locale. */ 151 | /* #undef LOG4CPLUS_WORKING_LOCALE */ 152 | 153 | /* Define for C99 compilers/standard libraries that support more than just the 154 | "C" locale. */ 155 | /* #undef LOG4CPLUS_WORKING_C_LOCALE */ 156 | 157 | /* Define to int if undefined. */ 158 | /* #undef socklen_t */ 159 | 160 | /* Defined for --enable-debugging builds. */ 161 | /* #undef LOG4CPLUS_DEBUGGING */ 162 | 163 | /* Defined if the compiler understands __declspec(dllexport) or 164 | __attribute__((visibility("default"))) construct. */ 165 | #define LOG4CPLUS_DECLSPEC_EXPORT __attribute__ ((visibility("default"))) 166 | 167 | /* Defined if the compiler understands __declspec(dllimport) or 168 | __attribute__((visibility("default"))) construct. */ 169 | #define LOG4CPLUS_DECLSPEC_IMPORT __attribute__ ((visibility("default"))) 170 | 171 | /* Defined if the compiler understands 172 | __attribute__((visibility("hidden"))) construct. */ 173 | #define LOG4CPLUS_DECLSPEC_PRIVATE __attribute__ ((visibility("hidden"))) 174 | 175 | /* */ 176 | #define LOG4CPLUS_HAVE_TLS_SUPPORT 1 177 | 178 | /* */ 179 | #define LOG4CPLUS_THREAD_LOCAL_VAR __thread 180 | 181 | /* Defined if the host OS provides ENAMETOOLONG errno value. */ 182 | #define LOG4CPLUS_HAVE_ENAMETOOLONG 1 183 | 184 | /* Defined if the compiler provides __sync_add_and_fetch(). */ 185 | #define LOG4CPLUS_HAVE___SYNC_ADD_AND_FETCH 1 186 | 187 | /* Defined if the compiler provides __sync_sub_and_fetch(). */ 188 | #define LOG4CPLUS_HAVE___SYNC_SUB_AND_FETCH 1 189 | 190 | /* Defined if the compiler provides C++11 header and increment, 191 | decrement operations. */ 192 | /* #undef LOG4CPLUS_HAVE_CXX11_ATOMICS */ 193 | 194 | /* */ 195 | #define LOG4CPLUS_HAVE_C99_VARIADIC_MACROS 1 196 | 197 | /* */ 198 | #define LOG4CPLUS_HAVE_GNU_VARIADIC_MACROS 1 199 | 200 | /* */ 201 | #define LOG4CPLUS_HAVE_VSNPRINTF 1 202 | 203 | /* Define to 1 if you have the `vsnwprintf' function. */ 204 | /* #undef LOG4CPLUS_HAVE_VSNWPRINTF */ 205 | 206 | /* Define to 1 if you have the `_vsnwprintf' function. */ 207 | /* #undef LOG4CPLUS_HAVE__VSNWPRINTF */ 208 | 209 | /* */ 210 | /* #undef LOG4CPLUS_HAVE__VSNPRINTF */ 211 | 212 | /* Define to 1 if you have the `vfprintf_s' function. */ 213 | /* #undef LOG4CPLUS_HAVE_VFPRINTF_S */ 214 | 215 | /* Define to 1 if you have the `vfwprintf_s' function. */ 216 | /* #undef LOG4CPLUS_HAVE_VFWPRINTF_S */ 217 | 218 | /* Define to 1 if you have the `vsprintf_s' function. */ 219 | /* #undef LOG4CPLUS_HAVE_VSPRINTF_S */ 220 | 221 | /* Define to 1 if you have the `vswprintf_s' function. */ 222 | /* #undef LOG4CPLUS_HAVE_VSWPRINTF_S */ 223 | 224 | /* Define to 1 if you have the `_vsnprintf_s' function. */ 225 | /* #undef LOG4CPLUS_HAVE__VSNPRINTF_S */ 226 | 227 | /* Define to 1 if you have the `_vsnwprintf_s' function. */ 228 | /* #undef LOG4CPLUS_HAVE__VSNWPRINTF_S */ 229 | 230 | /* Defined if the compiler supports __FUNCTION__ macro. */ 231 | #define LOG4CPLUS_HAVE_FUNCTION_MACRO 1 232 | 233 | /* Defined if the compiler supports __PRETTY_FUNCTION__ macro. */ 234 | #define LOG4CPLUS_HAVE_PRETTY_FUNCTION_MACRO 1 235 | 236 | /* Defined if the compiler supports __func__ symbol. */ 237 | #define LOG4CPLUS_HAVE_FUNC_SYMBOL 1 238 | 239 | /* Define to 1 if you have the `mbstowcs' function. */ 240 | #define LOG4CPLUS_HAVE_MBSTOWCS 1 241 | 242 | /* Define to 1 if you have the `wcstombs' function. */ 243 | #define LOG4CPLUS_HAVE_WCSTOMBS 1 244 | 245 | /* Define to 1 if you have Linux style syscall(SYS_gettid). */ 246 | #define LOG4CPLUS_HAVE_GETTID 1 247 | 248 | /* Define when iconv() is available. */ 249 | /* #undef LOG4CPLUS_WITH_ICONV */ 250 | 251 | /* Define to 1 if you have the `iconv' function. */ 252 | /* #undef LOG4CPLUS_HAVE_ICONV */ 253 | 254 | /* Define to 1 if you have the `iconv_close' function. */ 255 | /* #undef LOG4CPLUS_HAVE_ICONV_CLOSE */ 256 | 257 | /* Define to 1 if you have the `iconv_open' function. */ 258 | /* #undef LOG4CPLUS_HAVE_ICONV_OPEN */ 259 | 260 | #endif // LOG4CPLUS_CONFIG_DEFINES_HXX 261 | --------------------------------------------------------------------------------