├── .gitignore ├── LICENSE ├── README.md ├── STL ├── README.md └── src │ ├── algo.h │ ├── algobase.h │ ├── algorithm │ ├── alloc.h │ ├── bitset │ ├── bvector.h │ ├── char_traits.h │ ├── concept_checks.h │ ├── container_concepts.h │ ├── defalloc.h │ ├── deque │ ├── deque.h │ ├── function.h │ ├── functional │ ├── hash_map │ ├── hash_map.h │ ├── hash_set │ ├── hash_set.h │ ├── hashtable.h │ ├── heap.h │ ├── iterator │ ├── iterator.h │ ├── limits │ ├── list │ ├── list.h │ ├── map │ ├── map.h │ ├── memory │ ├── multimap.h │ ├── multiset.h │ ├── numeric │ ├── pair.h │ ├── pthread_alloc │ ├── pthread_alloc.h │ ├── queue │ ├── rope │ ├── rope.h │ ├── ropeimpl.h │ ├── sequence_concepts.h │ ├── set │ ├── set.h │ ├── slist │ ├── slist.h │ ├── stack │ ├── stack.h │ ├── stdexcept │ ├── stl_algo.h │ ├── stl_algobase.h │ ├── stl_alloc.h │ ├── stl_bvector.h │ ├── stl_config.h │ ├── stl_construct.h │ ├── stl_ctraits_fns.h │ ├── stl_deque.h │ ├── stl_exception.h │ ├── stl_function.h │ ├── stl_hash_fun.h │ ├── stl_hash_map.h │ ├── stl_hash_set.h │ ├── stl_hashtable.h │ ├── stl_heap.h │ ├── stl_iterator.h │ ├── stl_iterator_base.h │ ├── stl_list.h │ ├── stl_map.h │ ├── stl_multimap.h │ ├── stl_multiset.h │ ├── stl_numeric.h │ ├── stl_pair.h │ ├── stl_queue.h │ ├── stl_range_errors.h │ ├── stl_raw_storage_iter.h │ ├── stl_relops.h │ ├── stl_rope.h │ ├── stl_set.h │ ├── stl_slist.h │ ├── stl_stack.h │ ├── stl_string_fwd.h │ ├── stl_tempbuf.h │ ├── stl_threads.h │ ├── stl_tree.h │ ├── stl_uninitialized.h │ ├── stl_vector.h │ ├── string │ ├── tempbuf.h │ ├── tree.h │ ├── type_traits.h │ ├── utility │ ├── valarray │ ├── vector │ └── vector.h ├── anet ├── docs │ ├── definitions.txt │ ├── httpstreamer_testing_cases.txt │ └── rfcs │ │ └── rfc2616.txt ├── scripts │ ├── newclass.pl │ └── rule.txt ├── src │ └── anet │ │ ├── Makefile.am │ │ ├── anet.h │ │ ├── aneterror.cpp │ │ ├── aneterror.h │ │ ├── atomic.h │ │ ├── channel.cpp │ │ ├── channel.h │ │ ├── channelpool.cpp │ │ ├── channelpool.h │ │ ├── connection.cpp │ │ ├── connection.h │ │ ├── controlpacket.cpp │ │ ├── controlpacket.h │ │ ├── databuffer.h │ │ ├── defaultpacket.cpp │ │ ├── defaultpacket.h │ │ ├── defaultpacketfactory.cpp │ │ ├── defaultpacketfactory.h │ │ ├── defaultpacketstreamer.cpp │ │ ├── defaultpacketstreamer.h │ │ ├── epollsocketevent.cpp │ │ ├── epollsocketevent.h │ │ ├── filecontrol.cpp │ │ ├── filecontrol.h │ │ ├── httppacket.cpp │ │ ├── httppacket.h │ │ ├── httppacketfactory.cpp │ │ ├── httppacketfactory.h │ │ ├── httppacketstreamer.cpp │ │ ├── httppacketstreamer.h │ │ ├── httprequestpacket.cpp │ │ ├── httprequestpacket.h │ │ ├── httpresponsepacket.cpp │ │ ├── httpresponsepacket.h │ │ ├── httpstreamer.cpp │ │ ├── httpstreamer.h │ │ ├── httpstreamingcontext.cpp │ │ ├── httpstreamingcontext.h │ │ ├── iocomponent.cpp │ │ ├── iocomponent.h │ │ ├── ipacketfactory.h │ │ ├── ipackethandler.h │ │ ├── ipacketstreamer.h │ │ ├── iserveradapter.h │ │ ├── log.cpp │ │ ├── log.h │ │ ├── logconfig.h.in │ │ ├── packet.cpp │ │ ├── packet.h │ │ ├── packetqueue.cpp │ │ ├── packetqueue.h │ │ ├── runnable.h │ │ ├── serversocket.cpp │ │ ├── serversocket.h │ │ ├── socket.cpp │ │ ├── socket.h │ │ ├── socketevent.cpp │ │ ├── socketevent.h │ │ ├── stats.cpp │ │ ├── stats.h │ │ ├── streamingcontext.cpp │ │ ├── streamingcontext.h │ │ ├── tags │ │ ├── tcpacceptor.cpp │ │ ├── tcpacceptor.h │ │ ├── tcpcomponent.cpp │ │ ├── tcpcomponent.h │ │ ├── tcpconnection.cpp │ │ ├── tcpconnection.h │ │ ├── thread.h │ │ ├── threadcond.h │ │ ├── threadmutex.h │ │ ├── timeutil.cpp │ │ ├── timeutil.h │ │ ├── transport.cpp │ │ ├── transport.h │ │ ├── udpacceptor.h │ │ ├── udpcomponent.cpp │ │ ├── udpcomponent.h │ │ ├── udpconnection.cpp │ │ └── udpconnection.h ├── test │ ├── Makefile.am │ ├── channelpooltf.cpp │ ├── channelpooltf.h │ ├── channeltf.cpp │ ├── channeltf.h │ ├── connectiontf.cpp │ ├── connectiontf.h │ ├── controlpackettf.cpp │ ├── controlpackettf.h │ ├── databuffertf.cpp │ ├── databuffertf.h │ ├── defaultpacketfactorytf.h │ ├── defaultpacketstreamertf.cpp │ ├── defaultpacketstreamertf.h │ ├── defaultpackettf.cpp │ ├── defaultpackettf.h │ ├── dotest.cpp │ ├── epollsocketeventtf.cpp │ ├── epollsocketeventtf.h │ ├── filecontroltf.cpp │ ├── filecontroltf.h │ ├── httpcomponenttf.cpp │ ├── httpcomponenttf.h │ ├── httpconnectiontf.cpp │ ├── httpconnectiontf.h │ ├── httppacketfactorytf.cpp │ ├── httppacketfactorytf.h │ ├── httppacketstreamertf.cpp │ ├── httppacketstreamertf.h │ ├── httppackettf.cpp │ ├── httppackettf.h │ ├── httprequestandresponsepackettf.cpp │ ├── httprequestandresponsepackettf.h │ ├── httpstreamertf.cpp │ ├── httpstreamertf.h │ ├── httpstreamingcontexttf.cpp │ ├── httpstreamingcontexttf.h │ ├── maliciousstreamer.cpp │ ├── maliciousstreamer.h │ ├── packetqueuetf.cpp │ ├── packetqueuetf.h │ ├── sockettf.cpp │ ├── sockettf.h │ ├── streamingcontexttf.cpp │ ├── streamingcontexttf.h │ ├── synchronoustf.cpp │ ├── synchronoustf.h │ ├── tcpcomponenttf.cpp │ ├── tcpcomponenttf.h │ ├── tcpconnectiontf.cpp │ ├── tcpconnectiontf.h │ ├── template.cpp │ ├── template.h │ ├── testadapter.h │ ├── transporttf.cpp │ └── transporttf.h └── util │ ├── Makefile.am │ ├── benchmark.cpp │ ├── echoclient.cpp │ ├── echoclient_syn.cpp │ ├── echoserver.cpp │ ├── fork_test.cpp │ ├── helloworld_c.cpp │ ├── helloworld_c_syn.cpp │ ├── helloworld_httpd.cpp │ ├── helloworld_httpd_2.cpp │ ├── helloworld_s.cpp │ ├── helloworld_s_2.cpp │ ├── helloworld_wget.cpp │ ├── helloworld_wget_syn.cpp │ ├── httpserver.cpp │ ├── httpserver_new.cpp │ ├── signal_test.cpp │ ├── tags │ └── wait.cpp ├── cJSON ├── LICENSE ├── README ├── README.md ├── cJSON.c ├── cJSON.h ├── test.c └── tests │ ├── test1 │ ├── test2 │ ├── test3 │ ├── test4 │ └── test5 ├── jwSMTP ├── README.md ├── demo1.cpp ├── demo2.cpp └── jwsmtp │ ├── .deps │ ├── base64.Plo │ ├── compat.Plo │ └── mailer.Plo │ ├── base64.cpp │ ├── base64.h │ ├── compat.cpp │ ├── compat.h │ ├── jwsmtp.h │ ├── mailer.cpp │ └── mailer.h ├── larbin-2.6.3 ├── COPYING ├── CREDITS ├── Makefile ├── README ├── adns │ ├── Makefile │ ├── adns.h │ ├── check.c │ ├── config.h.in │ ├── configure │ ├── dlist.h │ ├── event.c │ ├── general.c │ ├── install-sh │ ├── internal.h │ ├── parse.c │ ├── poll.c │ ├── query.c │ ├── reply.c │ ├── setup.c │ ├── transmit.c │ ├── tvarith.h │ └── types.c ├── configure ├── doc │ ├── custom-eng.html │ ├── download.html │ ├── index-eng.html │ ├── index.html │ ├── l-en.jpg │ ├── l-fr.jpg │ └── use-eng.html ├── larbin.conf ├── options.h └── src │ ├── Makefile │ ├── fetch │ ├── Makefile │ ├── checker.cc │ ├── checker.h │ ├── defaultspecbuf.cc │ ├── dynamicspecbuf.cc │ ├── dynamicspecbuf.h │ ├── fetchOpen.cc │ ├── fetchOpen.h │ ├── fetchPipe.cc │ ├── fetchPipe.h │ ├── file.cc │ ├── file.h │ ├── hashTable.cc │ ├── hashTable.h │ ├── savespecbuf.cc │ ├── savespecbuf.h │ ├── sequencer.cc │ ├── sequencer.h │ ├── site.cc │ ├── site.h │ ├── specbuf.cc │ └── specbuf.h │ ├── global.cc │ ├── global.h │ ├── interf │ ├── Makefile │ ├── defaultuseroutput.cc │ ├── input.cc │ ├── input.h │ ├── mirrorsaveuseroutput.cc │ ├── output.cc │ ├── output.h │ ├── saveuseroutput.cc │ ├── statsuseroutput.cc │ ├── useroutput.cc │ └── useroutput.h │ ├── larbin.make │ ├── main.cc │ ├── types.h │ └── utils │ ├── ConstantSizedFifo.h │ ├── Fifo.h │ ├── Makefile │ ├── PersistentFifo.cc │ ├── PersistentFifo.h │ ├── SyncFifo.h │ ├── Vector.h │ ├── connexion.cc │ ├── connexion.h │ ├── debug.cc │ ├── debug.h │ ├── hashDup.cc │ ├── hashDup.h │ ├── histogram.cc │ ├── histogram.h │ ├── mypthread.cc │ ├── mypthread.h │ ├── string.cc │ ├── string.h │ ├── text.cc │ ├── text.h │ ├── url.cc │ ├── url.h │ ├── webserver.cc │ └── webserver.h ├── libevent-1.4.9-stable ├── README ├── WIN32-Code │ ├── config.h │ ├── tree.h │ └── win32.c ├── WIN32-Prj │ ├── event_test │ │ ├── event_test.dsp │ │ └── test.txt │ ├── libevent.dsp │ ├── libevent.dsw │ ├── libevent.sln │ ├── libevent.vcproj │ ├── regress │ │ └── regress.vcproj │ ├── signal_test │ │ └── signal_test.dsp │ └── time_test │ │ └── time_test.dsp ├── buffer.c ├── compat │ └── sys │ │ ├── _time.h │ │ └── queue.h ├── devpoll.c ├── epoll.c ├── epoll_sub.c ├── evbuffer.c ├── evdns.c ├── evdns.h ├── event-config.h ├── event-internal.h ├── event.c ├── event.h ├── event_rpcgen.py ├── event_tagging.c ├── evhttp.h ├── evport.c ├── evrpc-internal.h ├── evrpc.c ├── evrpc.h ├── evsignal.h ├── evutil.c ├── evutil.h ├── http-internal.h ├── http.c ├── kqueue.c ├── log.c ├── log.h ├── min_heap.h ├── poll.c ├── sample │ ├── Makefile.am │ ├── Makefile.in │ ├── event-test.c │ ├── signal-test.c │ └── time-test.c ├── select.c ├── signal.c ├── strlcpy-internal.h ├── strlcpy.c ├── tags └── test │ ├── Makefile.am │ ├── Makefile.in │ ├── bench.c │ ├── regress.c │ ├── regress.gen.c │ ├── regress.gen.h │ ├── regress.h │ ├── regress.rpc │ ├── regress_dns.c │ ├── regress_http.c │ ├── regress_rpc.c │ ├── test-eof.c │ ├── test-init.c │ ├── test-time.c │ ├── test-weof.c │ └── test.sh ├── spiderq ├── LICENSE.md ├── Makefile ├── README.md ├── modules │ ├── Makefile │ ├── domainlimit.cpp │ ├── headerfilter.cpp │ ├── maxdepth.cpp │ ├── savehtml.cpp │ └── saveimage.cpp ├── spiderq.conf ├── src │ ├── Makefile │ ├── bloomfilter.cpp │ ├── bloomfilter.h │ ├── confparser.cpp │ ├── confparser.h │ ├── crc32.cpp │ ├── crc32.h │ ├── dso.cpp │ ├── dso.h │ ├── hashs.cpp │ ├── hashs.h │ ├── md5.cpp │ ├── md5.h │ ├── qstring.cpp │ ├── qstring.h │ ├── sha1.cpp │ ├── sha1.h │ ├── socket.cpp │ ├── socket.h │ ├── spider.cpp │ ├── spider.h │ ├── tags │ ├── threads.cpp │ ├── threads.h │ ├── url.cpp │ └── url.h └── tags ├── tinyhttpd ├── Makefile ├── README ├── README.md ├── htdocs │ ├── README │ ├── check.cgi │ ├── color.cgi │ └── index.html ├── httpd.c └── simpleclient.c └── webbench-1.5 ├── Makefile ├── socket.c └── webbench.c /.gitignore: -------------------------------------------------------------------------------- 1 | # Object files 2 | *.o 3 | *.ko 4 | *.obj 5 | *.elf 6 | 7 | # Precompiled Headers 8 | *.gch 9 | *.pch 10 | 11 | # Libraries 12 | *.lib 13 | *.a 14 | *.la 15 | *.lo 16 | 17 | # Shared objects (inc. Windows DLLs) 18 | *.dll 19 | *.so 20 | *.so.* 21 | *.dylib 22 | 23 | # Executables 24 | *.exe 25 | *.out 26 | *.app 27 | *.i*86 28 | *.x86_64 29 | *.hex 30 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 armsword 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 记录阅读过的开源代码程序和注释 2 | ## Webbench 3 | - Webbench是一个在Linux下使用的非常简单的网站压力测试工具。它使用fork()模拟多个客户端同时访问我们设定的URL,测试网站在压力下工作的性能,最多可以模拟3万个并发连接去测试网站的负载能力。Webbench使用C语言编写, 源码加起来不到600行。 4 | 5 | ## tinyhttp 6 | - tinyhttpd是一个超轻量型Http Server,使用C语言开发,全部代码只有500、600行,并附带一个简单的Client,可以通过阅读这段代码理解一个Http Server的本质。 7 | 8 | ## cJSON 9 | - cJSON是C语言编写的一个JSON编解码器,非常轻量级,单文件,代码不到1K行,速度也非常理想,并且其代码也被非常好地维护着。里面用到的数据结构和算法都是非常值的阅读学习的。 10 | 11 | ## jwSMTP 12 | - jwSMTP是一个由C++编写的邮件发送库,支持Linux、Windows等平台。可使用HTML或纯文本方式发送邮件,也可添加附件,支持多个收件人,并且支持LOGIN和PLAIN两种服务器验证方式,此代码可以帮助简单理解SMTP协议和DNS协议。 13 | -------------------------------------------------------------------------------- /STL/README.md: -------------------------------------------------------------------------------- 1 | SGI-STL V3.3 2 | 3 | The STL was developed on SGI MIPSproTM C++ 7.0, 7.1, 7.2, and 7.2.1. If you are using the 7.0 compiler, you must compile using either the -n32 or the -64 flag; if you are using 7.1 or later, you may use -o32, -n32, or -64. The STL has also been tested on Microsoft Visual C++ 5.0, on g++ 2.8.1, and on recent egcs snapshots. All of the STL except for the , , and headers has also been tested on Borland 5.02. 4 | 5 | It should not be difficult to use the STL with other compilers that have good support for templates, especially compilers that use the EDG front end. 6 | 7 | This distribution of the STL consists entirely of header files: there is no need to link to any library files. You can view or download a header file individually, or you can download all of them as a tar or zip file. (Note that v3 has many more header files than v1 and v2 did, because it provides both old-style and new-style header names. Many of the files in v3 are very short, and do little other than forwarding.) 8 | -------------------------------------------------------------------------------- /STL/src/algorithm: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 1994 4 | * Hewlett-Packard Company 5 | * 6 | * Permission to use, copy, modify, distribute and sell this software 7 | * and its documentation for any purpose is hereby granted without fee, 8 | * provided that the above copyright notice appear in all copies and 9 | * that both that copyright notice and this permission notice appear 10 | * in supporting documentation. Hewlett-Packard Company makes no 11 | * representations about the suitability of this software for any 12 | * purpose. It is provided "as is" without express or implied warranty. 13 | * 14 | * 15 | * Copyright (c) 1996,1997 16 | * Silicon Graphics Computer Systems, Inc. 17 | * 18 | * Permission to use, copy, modify, distribute and sell this software 19 | * and its documentation for any purpose is hereby granted without fee, 20 | * provided that the above copyright notice appear in all copies and 21 | * that both that copyright notice and this permission notice appear 22 | * in supporting documentation. Silicon Graphics makes no 23 | * representations about the suitability of this software for any 24 | * purpose. It is provided "as is" without express or implied warranty. 25 | */ 26 | 27 | #ifndef __SGI_STL_ALGORITHM 28 | #define __SGI_STL_ALGORITHM 29 | 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | 36 | #endif /* __SGI_STL_ALGORITHM */ 37 | 38 | // Local Variables: 39 | // mode:C++ 40 | // End: 41 | -------------------------------------------------------------------------------- /STL/src/alloc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1996-1997 3 | * Silicon Graphics Computer Systems, Inc. 4 | * 5 | * Permission to use, copy, modify, distribute and sell this software 6 | * and its documentation for any purpose is hereby granted without fee, 7 | * provided that the above copyright notice appear in all copies and 8 | * that both that copyright notice and this permission notice appear 9 | * in supporting documentation. Silicon Graphics makes no 10 | * representations about the suitability of this software for any 11 | * purpose. It is provided "as is" without express or implied warranty. 12 | */ 13 | 14 | #ifndef __SGI_STL_ALLOC_H 15 | #define __SGI_STL_ALLOC_H 16 | 17 | #ifndef __STL_CONFIG_H 18 | #include 19 | #endif 20 | #ifndef __SGI_STL_INTERNAL_ALLOC_H 21 | #include 22 | #endif 23 | 24 | #ifdef __STL_USE_NAMESPACES 25 | 26 | using __STD::__malloc_alloc_template; 27 | using __STD::malloc_alloc; 28 | using __STD::simple_alloc; 29 | using __STD::debug_alloc; 30 | using __STD::__default_alloc_template; 31 | using __STD::alloc; 32 | using __STD::single_client_alloc; 33 | #ifdef __STL_STATIC_TEMPLATE_MEMBER_BUG 34 | using __STD::__malloc_alloc_oom_handler; 35 | #endif /* __STL_STATIC_TEMPLATE_MEMBER_BUG */ 36 | #ifdef __STL_USE_STD_ALLOCATORS 37 | using __STD::allocator; 38 | #endif /* __STL_USE_STD_ALLOCATORS */ 39 | 40 | #endif /* __STL_USE_NAMESPACES */ 41 | 42 | #endif /* __SGI_STL_ALLOC_H */ 43 | 44 | // Local Variables: 45 | // mode:C++ 46 | // End: 47 | -------------------------------------------------------------------------------- /STL/src/bvector.h: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 1994 4 | * Hewlett-Packard Company 5 | * 6 | * Permission to use, copy, modify, distribute and sell this software 7 | * and its documentation for any purpose is hereby granted without fee, 8 | * provided that the above copyright notice appear in all copies and 9 | * that both that copyright notice and this permission notice appear 10 | * in supporting documentation. Hewlett-Packard Company makes no 11 | * representations about the suitability of this software for any 12 | * purpose. It is provided "as is" without express or implied warranty. 13 | * 14 | * 15 | * Copyright (c) 1996 16 | * Silicon Graphics Computer Systems, Inc. 17 | * 18 | * Permission to use, copy, modify, distribute and sell this software 19 | * and its documentation for any purpose is hereby granted without fee, 20 | * provided that the above copyright notice appear in all copies and 21 | * that both that copyright notice and this permission notice appear 22 | * in supporting documentation. Silicon Graphics makes no 23 | * representations about the suitability of this software for any 24 | * purpose. It is provided "as is" without express or implied warranty. 25 | */ 26 | 27 | #ifndef __SGI_STL_BVECTOR_H 28 | #define __SGI_STL_BVECTOR_H 29 | 30 | #include 31 | #ifdef __STL_CLASS_PARTIAL_SPECIALIZATION 32 | #include 33 | #else 34 | #include 35 | #include 36 | #endif 37 | 38 | #include 39 | 40 | #ifdef __STL_USE_NAMESPACES 41 | 42 | using __STD::bit_vector; 43 | 44 | #endif /* __STL_USE_NAMESPACES */ 45 | 46 | #endif /* __SGI_STL_BVECTOR_H */ 47 | 48 | // Local Variables: 49 | // mode:C++ 50 | // End: 51 | 52 | 53 | -------------------------------------------------------------------------------- /STL/src/deque: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 1994 4 | * Hewlett-Packard Company 5 | * 6 | * Permission to use, copy, modify, distribute and sell this software 7 | * and its documentation for any purpose is hereby granted without fee, 8 | * provided that the above copyright notice appear in all copies and 9 | * that both that copyright notice and this permission notice appear 10 | * in supporting documentation. Hewlett-Packard Company makes no 11 | * representations about the suitability of this software for any 12 | * purpose. It is provided "as is" without express or implied warranty. 13 | * 14 | * 15 | * Copyright (c) 1997 16 | * Silicon Graphics Computer Systems, Inc. 17 | * 18 | * Permission to use, copy, modify, distribute and sell this software 19 | * and its documentation for any purpose is hereby granted without fee, 20 | * provided that the above copyright notice appear in all copies and 21 | * that both that copyright notice and this permission notice appear 22 | * in supporting documentation. Silicon Graphics makes no 23 | * representations about the suitability of this software for any 24 | * purpose. It is provided "as is" without express or implied warranty. 25 | */ 26 | 27 | #ifndef __SGI_STL_DEQUE 28 | #define __SGI_STL_DEQUE 29 | 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | 37 | #endif /* __SGI_STL_DEQUE */ 38 | 39 | // Local Variables: 40 | // mode:C++ 41 | // End: 42 | -------------------------------------------------------------------------------- /STL/src/deque.h: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 1994 4 | * Hewlett-Packard Company 5 | * 6 | * Permission to use, copy, modify, distribute and sell this software 7 | * and its documentation for any purpose is hereby granted without fee, 8 | * provided that the above copyright notice appear in all copies and 9 | * that both that copyright notice and this permission notice appear 10 | * in supporting documentation. Hewlett-Packard Company makes no 11 | * representations about the suitability of this software for any 12 | * purpose. It is provided "as is" without express or implied warranty. 13 | * 14 | * 15 | * Copyright (c) 1997 16 | * Silicon Graphics Computer Systems, Inc. 17 | * 18 | * Permission to use, copy, modify, distribute and sell this software 19 | * and its documentation for any purpose is hereby granted without fee, 20 | * provided that the above copyright notice appear in all copies and 21 | * that both that copyright notice and this permission notice appear 22 | * in supporting documentation. Silicon Graphics makes no 23 | * representations about the suitability of this software for any 24 | * purpose. It is provided "as is" without express or implied warranty. 25 | */ 26 | 27 | #ifndef __SGI_STL_DEQUE_H 28 | #define __SGI_STL_DEQUE_H 29 | 30 | #include 31 | #include 32 | #include 33 | #include 34 | 35 | #ifdef __STL_USE_NAMESPACES 36 | using __STD::deque; 37 | #endif /* __STL_USE_NAMESPACES */ 38 | 39 | #endif /* __SGI_STL_DEQUE_H */ 40 | 41 | // Local Variables: 42 | // mode:C++ 43 | // End: 44 | -------------------------------------------------------------------------------- /STL/src/functional: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1997 3 | * Silicon Graphics Computer Systems, Inc. 4 | * 5 | * Permission to use, copy, modify, distribute and sell this software 6 | * and its documentation for any purpose is hereby granted without fee, 7 | * provided that the above copyright notice appear in all copies and 8 | * that both that copyright notice and this permission notice appear 9 | * in supporting documentation. Silicon Graphics makes no 10 | * representations about the suitability of this software for any 11 | * purpose. It is provided "as is" without express or implied warranty. 12 | * 13 | */ 14 | 15 | #ifndef __SGI_STL_FUNCTIONAL 16 | #define __SGI_STL_FUNCTIONAL 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | #endif /* __SGI_STL_FUNCTIONAL */ 23 | 24 | // Local Variables: 25 | // mode:C++ 26 | // End: 27 | -------------------------------------------------------------------------------- /STL/src/hash_map: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1996 3 | * Silicon Graphics Computer Systems, Inc. 4 | * 5 | * Permission to use, copy, modify, distribute and sell this software 6 | * and its documentation for any purpose is hereby granted without fee, 7 | * provided that the above copyright notice appear in all copies and 8 | * that both that copyright notice and this permission notice appear 9 | * in supporting documentation. Silicon Graphics makes no 10 | * representations about the suitability of this software for any 11 | * purpose. It is provided "as is" without express or implied warranty. 12 | * 13 | * 14 | * Copyright (c) 1994 15 | * Hewlett-Packard Company 16 | * 17 | * Permission to use, copy, modify, distribute and sell this software 18 | * and its documentation for any purpose is hereby granted without fee, 19 | * provided that the above copyright notice appear in all copies and 20 | * that both that copyright notice and this permission notice appear 21 | * in supporting documentation. Hewlett-Packard Company makes no 22 | * representations about the suitability of this software for any 23 | * purpose. It is provided "as is" without express or implied warranty. 24 | * 25 | */ 26 | 27 | #ifndef __SGI_STL_HASH_MAP 28 | #define __SGI_STL_HASH_MAP 29 | 30 | #ifndef __SGI_STL_INTERNAL_HASHTABLE_H 31 | #include 32 | #endif 33 | 34 | #include 35 | 36 | #endif /* __SGI_STL_HASH_MAP */ 37 | 38 | // Local Variables: 39 | // mode:C++ 40 | // End: 41 | -------------------------------------------------------------------------------- /STL/src/hash_map.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1996 3 | * Silicon Graphics Computer Systems, Inc. 4 | * 5 | * Permission to use, copy, modify, distribute and sell this software 6 | * and its documentation for any purpose is hereby granted without fee, 7 | * provided that the above copyright notice appear in all copies and 8 | * that both that copyright notice and this permission notice appear 9 | * in supporting documentation. Silicon Graphics makes no 10 | * representations about the suitability of this software for any 11 | * purpose. It is provided "as is" without express or implied warranty. 12 | * 13 | * 14 | * Copyright (c) 1994 15 | * Hewlett-Packard Company 16 | * 17 | * Permission to use, copy, modify, distribute and sell this software 18 | * and its documentation for any purpose is hereby granted without fee, 19 | * provided that the above copyright notice appear in all copies and 20 | * that both that copyright notice and this permission notice appear 21 | * in supporting documentation. Hewlett-Packard Company makes no 22 | * representations about the suitability of this software for any 23 | * purpose. It is provided "as is" without express or implied warranty. 24 | * 25 | */ 26 | 27 | #ifndef __SGI_STL_HASH_MAP_H 28 | #define __SGI_STL_HASH_MAP_H 29 | 30 | #ifndef __SGI_STL_INTERNAL_HASHTABLE_H 31 | #include 32 | #endif 33 | 34 | #include 35 | #include 36 | 37 | #ifdef __STL_USE_NAMESPACES 38 | using __STD::hash; 39 | using __STD::hashtable; 40 | using __STD::hash_map; 41 | using __STD::hash_multimap; 42 | #endif /* __STL_USE_NAMESPACES */ 43 | 44 | 45 | #endif /* __SGI_STL_HASH_MAP_H */ 46 | 47 | // Local Variables: 48 | // mode:C++ 49 | // End: 50 | -------------------------------------------------------------------------------- /STL/src/hash_set: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1996 3 | * Silicon Graphics Computer Systems, Inc. 4 | * 5 | * Permission to use, copy, modify, distribute and sell this software 6 | * and its documentation for any purpose is hereby granted without fee, 7 | * provided that the above copyright notice appear in all copies and 8 | * that both that copyright notice and this permission notice appear 9 | * in supporting documentation. Silicon Graphics makes no 10 | * representations about the suitability of this software for any 11 | * purpose. It is provided "as is" without express or implied warranty. 12 | * 13 | * 14 | * Copyright (c) 1994 15 | * Hewlett-Packard Company 16 | * 17 | * Permission to use, copy, modify, distribute and sell this software 18 | * and its documentation for any purpose is hereby granted without fee, 19 | * provided that the above copyright notice appear in all copies and 20 | * that both that copyright notice and this permission notice appear 21 | * in supporting documentation. Hewlett-Packard Company makes no 22 | * representations about the suitability of this software for any 23 | * purpose. It is provided "as is" without express or implied warranty. 24 | * 25 | */ 26 | 27 | #ifndef __SGI_STL_HASH_SET 28 | #define __SGI_STL_HASH_SET 29 | 30 | #ifndef __SGI_STL_INTERNAL_HASHTABLE_H 31 | #include 32 | #endif 33 | 34 | #include 35 | 36 | #endif /* __SGI_STL_HASH_SET */ 37 | 38 | // Local Variables: 39 | // mode:C++ 40 | // End: 41 | -------------------------------------------------------------------------------- /STL/src/hash_set.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1996 3 | * Silicon Graphics Computer Systems, Inc. 4 | * 5 | * Permission to use, copy, modify, distribute and sell this software 6 | * and its documentation for any purpose is hereby granted without fee, 7 | * provided that the above copyright notice appear in all copies and 8 | * that both that copyright notice and this permission notice appear 9 | * in supporting documentation. Silicon Graphics makes no 10 | * representations about the suitability of this software for any 11 | * purpose. It is provided "as is" without express or implied warranty. 12 | * 13 | * 14 | * Copyright (c) 1994 15 | * Hewlett-Packard Company 16 | * 17 | * Permission to use, copy, modify, distribute and sell this software 18 | * and its documentation for any purpose is hereby granted without fee, 19 | * provided that the above copyright notice appear in all copies and 20 | * that both that copyright notice and this permission notice appear 21 | * in supporting documentation. Hewlett-Packard Company makes no 22 | * representations about the suitability of this software for any 23 | * purpose. It is provided "as is" without express or implied warranty. 24 | * 25 | */ 26 | 27 | #ifndef __SGI_STL_HASH_SET_H 28 | #define __SGI_STL_HASH_SET_H 29 | 30 | #ifndef __SGI_STL_INTERNAL_HASHTABLE_H 31 | #include 32 | #endif 33 | 34 | #include 35 | #include 36 | 37 | #ifdef __STL_USE_NAMESPACES 38 | using __STD::hash; 39 | using __STD::hashtable; 40 | using __STD::hash_set; 41 | using __STD::hash_multiset; 42 | #endif /* __STL_USE_NAMESPACES */ 43 | 44 | #endif /* __SGI_STL_HASH_SET_H */ 45 | -------------------------------------------------------------------------------- /STL/src/hashtable.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1996,1997 3 | * Silicon Graphics Computer Systems, Inc. 4 | * 5 | * Permission to use, copy, modify, distribute and sell this software 6 | * and its documentation for any purpose is hereby granted without fee, 7 | * provided that the above copyright notice appear in all copies and 8 | * that both that copyright notice and this permission notice appear 9 | * in supporting documentation. Silicon Graphics makes no 10 | * representations about the suitability of this software for any 11 | * purpose. It is provided "as is" without express or implied warranty. 12 | * 13 | * 14 | * Copyright (c) 1994 15 | * Hewlett-Packard Company 16 | * 17 | * Permission to use, copy, modify, distribute and sell this software 18 | * and its documentation for any purpose is hereby granted without fee, 19 | * provided that the above copyright notice appear in all copies and 20 | * that both that copyright notice and this permission notice appear 21 | * in supporting documentation. Hewlett-Packard Company makes no 22 | * representations about the suitability of this software for any 23 | * purpose. It is provided "as is" without express or implied warranty. 24 | * 25 | */ 26 | 27 | /* NOTE: This is an internal header file, included by other STL headers. 28 | * You should not attempt to use it directly. 29 | */ 30 | 31 | #ifndef __SGI_STL_HASHTABLE_H 32 | #define __SGI_STL_HASHTABLE_H 33 | 34 | #include 35 | #include 36 | #include 37 | #include 38 | 39 | #ifdef __STL_USE_NAMESPACES 40 | using __STD::hash; 41 | using __STD::hashtable; 42 | #endif /* __STL_USE_NAMESPACES */ 43 | 44 | #endif /* __SGI_STL_HASHTABLE_H */ 45 | 46 | // Local Variables: 47 | // mode:C++ 48 | // End: 49 | -------------------------------------------------------------------------------- /STL/src/heap.h: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 1994 4 | * Hewlett-Packard Company 5 | * 6 | * Permission to use, copy, modify, distribute and sell this software 7 | * and its documentation for any purpose is hereby granted without fee, 8 | * provided that the above copyright notice appear in all copies and 9 | * that both that copyright notice and this permission notice appear 10 | * in supporting documentation. Hewlett-Packard Company makes no 11 | * representations about the suitability of this software for any 12 | * purpose. It is provided "as is" without express or implied warranty. 13 | * 14 | * Copyright (c) 1997 15 | * Silicon Graphics Computer Systems, Inc. 16 | * 17 | * Permission to use, copy, modify, distribute and sell this software 18 | * and its documentation for any purpose is hereby granted without fee, 19 | * provided that the above copyright notice appear in all copies and 20 | * that both that copyright notice and this permission notice appear 21 | * in supporting documentation. Silicon Graphics makes no 22 | * representations about the suitability of this software for any 23 | * purpose. It is provided "as is" without express or implied warranty. 24 | */ 25 | 26 | #ifndef __SGI_STL_HEAP_H 27 | #define __SGI_STL_HEAP_H 28 | 29 | #include 30 | #include 31 | 32 | #ifdef __STL_USE_NAMESPACES 33 | 34 | using __STD::push_heap; 35 | using __STD::pop_heap; 36 | using __STD::make_heap; 37 | using __STD::sort_heap; 38 | 39 | #endif /* __STL_USE_NAMESPACES */ 40 | 41 | 42 | #endif /* __SGI_STL_HEAP_H */ 43 | 44 | // Local Variables: 45 | // mode:C++ 46 | // End: 47 | -------------------------------------------------------------------------------- /STL/src/iterator: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 1994 4 | * Hewlett-Packard Company 5 | * 6 | * Permission to use, copy, modify, distribute and sell this software 7 | * and its documentation for any purpose is hereby granted without fee, 8 | * provided that the above copyright notice appear in all copies and 9 | * that both that copyright notice and this permission notice appear 10 | * in supporting documentation. Hewlett-Packard Company makes no 11 | * representations about the suitability of this software for any 12 | * purpose. It is provided "as is" without express or implied warranty. 13 | * 14 | * 15 | * Copyright (c) 1996,1997 16 | * Silicon Graphics Computer Systems, Inc. 17 | * 18 | * Permission to use, copy, modify, distribute and sell this software 19 | * and its documentation for any purpose is hereby granted without fee, 20 | * provided that the above copyright notice appear in all copies and 21 | * that both that copyright notice and this permission notice appear 22 | * in supporting documentation. Silicon Graphics makes no 23 | * representations about the suitability of this software for any 24 | * purpose. It is provided "as is" without express or implied warranty. 25 | */ 26 | 27 | #ifndef __SGI_STL_ITERATOR 28 | #define __SGI_STL_ITERATOR 29 | 30 | #include 31 | #include 32 | #include 33 | 34 | #ifdef __STL_USE_NEW_IOSTREAMS 35 | #include 36 | #else /* __STL_USE_NEW_IOSTREAMS */ 37 | #include 38 | #endif /* __STL_USE_NEW_IOSTREAMS */ 39 | 40 | #include 41 | #include 42 | 43 | #endif /* __SGI_STL_ITERATOR */ 44 | 45 | // Local Variables: 46 | // mode:C++ 47 | // End: 48 | -------------------------------------------------------------------------------- /STL/src/list: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 1994 4 | * Hewlett-Packard Company 5 | * 6 | * Permission to use, copy, modify, distribute and sell this software 7 | * and its documentation for any purpose is hereby granted without fee, 8 | * provided that the above copyright notice appear in all copies and 9 | * that both that copyright notice and this permission notice appear 10 | * in supporting documentation. Hewlett-Packard Company makes no 11 | * representations about the suitability of this software for any 12 | * purpose. It is provided "as is" without express or implied warranty. 13 | * 14 | * 15 | * Copyright (c) 1996,1997 16 | * Silicon Graphics Computer Systems, Inc. 17 | * 18 | * Permission to use, copy, modify, distribute and sell this software 19 | * and its documentation for any purpose is hereby granted without fee, 20 | * provided that the above copyright notice appear in all copies and 21 | * that both that copyright notice and this permission notice appear 22 | * in supporting documentation. Silicon Graphics makes no 23 | * representations about the suitability of this software for any 24 | * purpose. It is provided "as is" without express or implied warranty. 25 | */ 26 | 27 | #ifndef __SGI_STL_LIST 28 | #define __SGI_STL_LIST 29 | 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | 36 | #endif /* __SGI_STL_LIST */ 37 | 38 | // Local Variables: 39 | // mode:C++ 40 | // End: 41 | -------------------------------------------------------------------------------- /STL/src/list.h: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 1994 4 | * Hewlett-Packard Company 5 | * 6 | * Permission to use, copy, modify, distribute and sell this software 7 | * and its documentation for any purpose is hereby granted without fee, 8 | * provided that the above copyright notice appear in all copies and 9 | * that both that copyright notice and this permission notice appear 10 | * in supporting documentation. Hewlett-Packard Company makes no 11 | * representations about the suitability of this software for any 12 | * purpose. It is provided "as is" without express or implied warranty. 13 | * 14 | * 15 | * Copyright (c) 1996,1997 16 | * Silicon Graphics Computer Systems, Inc. 17 | * 18 | * Permission to use, copy, modify, distribute and sell this software 19 | * and its documentation for any purpose is hereby granted without fee, 20 | * provided that the above copyright notice appear in all copies and 21 | * that both that copyright notice and this permission notice appear 22 | * in supporting documentation. Silicon Graphics makes no 23 | * representations about the suitability of this software for any 24 | * purpose. It is provided "as is" without express or implied warranty. 25 | */ 26 | 27 | #ifndef __SGI_STL_LIST_H 28 | #define __SGI_STL_LIST_H 29 | 30 | #include 31 | #include 32 | #include 33 | 34 | #ifdef __STL_USE_NAMESPACES 35 | using __STD::list; 36 | #endif /* __STL_USE_NAMESPACES */ 37 | 38 | #endif /* __SGI_STL_LIST_H */ 39 | 40 | // Local Variables: 41 | // mode:C++ 42 | // End: 43 | -------------------------------------------------------------------------------- /STL/src/map: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 1994 4 | * Hewlett-Packard Company 5 | * 6 | * Permission to use, copy, modify, distribute and sell this software 7 | * and its documentation for any purpose is hereby granted without fee, 8 | * provided that the above copyright notice appear in all copies and 9 | * that both that copyright notice and this permission notice appear 10 | * in supporting documentation. Hewlett-Packard Company makes no 11 | * representations about the suitability of this software for any 12 | * purpose. It is provided "as is" without express or implied warranty. 13 | * 14 | * 15 | * Copyright (c) 1996,1997 16 | * Silicon Graphics Computer Systems, Inc. 17 | * 18 | * Permission to use, copy, modify, distribute and sell this software 19 | * and its documentation for any purpose is hereby granted without fee, 20 | * provided that the above copyright notice appear in all copies and 21 | * that both that copyright notice and this permission notice appear 22 | * in supporting documentation. Silicon Graphics makes no 23 | * representations about the suitability of this software for any 24 | * purpose. It is provided "as is" without express or implied warranty. 25 | */ 26 | 27 | #ifndef __SGI_STL_MAP 28 | #define __SGI_STL_MAP 29 | 30 | #ifndef __SGI_STL_INTERNAL_TREE_H 31 | #include 32 | #endif 33 | #include 34 | #include 35 | 36 | #endif /* __SGI_STL_MAP */ 37 | 38 | // Local Variables: 39 | // mode:C++ 40 | // End: 41 | -------------------------------------------------------------------------------- /STL/src/map.h: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 1994 4 | * Hewlett-Packard Company 5 | * 6 | * Permission to use, copy, modify, distribute and sell this software 7 | * and its documentation for any purpose is hereby granted without fee, 8 | * provided that the above copyright notice appear in all copies and 9 | * that both that copyright notice and this permission notice appear 10 | * in supporting documentation. Hewlett-Packard Company makes no 11 | * representations about the suitability of this software for any 12 | * purpose. It is provided "as is" without express or implied warranty. 13 | * 14 | * 15 | * Copyright (c) 1996,1997 16 | * Silicon Graphics Computer Systems, Inc. 17 | * 18 | * Permission to use, copy, modify, distribute and sell this software 19 | * and its documentation for any purpose is hereby granted without fee, 20 | * provided that the above copyright notice appear in all copies and 21 | * that both that copyright notice and this permission notice appear 22 | * in supporting documentation. Silicon Graphics makes no 23 | * representations about the suitability of this software for any 24 | * purpose. It is provided "as is" without express or implied warranty. 25 | */ 26 | 27 | #ifndef __SGI_STL_MAP_H 28 | #define __SGI_STL_MAP_H 29 | 30 | #ifndef __SGI_STL_INTERNAL_TREE_H 31 | #include 32 | #endif 33 | #include 34 | #include 35 | #include 36 | 37 | #ifdef __STL_USE_NAMESPACES 38 | using __STD::rb_tree; 39 | using __STD::map; 40 | #endif /* __STL_USE_NAMESPACES */ 41 | 42 | #endif /* __SGI_STL_MAP_H */ 43 | 44 | // Local Variables: 45 | // mode:C++ 46 | // End: 47 | -------------------------------------------------------------------------------- /STL/src/multimap.h: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 1994 4 | * Hewlett-Packard Company 5 | * 6 | * Permission to use, copy, modify, distribute and sell this software 7 | * and its documentation for any purpose is hereby granted without fee, 8 | * provided that the above copyright notice appear in all copies and 9 | * that both that copyright notice and this permission notice appear 10 | * in supporting documentation. Hewlett-Packard Company makes no 11 | * representations about the suitability of this software for any 12 | * purpose. It is provided "as is" without express or implied warranty. 13 | * 14 | * 15 | * Copyright (c) 1996,1997 16 | * Silicon Graphics Computer Systems, Inc. 17 | * 18 | * Permission to use, copy, modify, distribute and sell this software 19 | * and its documentation for any purpose is hereby granted without fee, 20 | * provided that the above copyright notice appear in all copies and 21 | * that both that copyright notice and this permission notice appear 22 | * in supporting documentation. Silicon Graphics makes no 23 | * representations about the suitability of this software for any 24 | * purpose. It is provided "as is" without express or implied warranty. 25 | */ 26 | 27 | #ifndef __SGI_STL_MULTIMAP_H 28 | #define __SGI_STL_MULTIMAP_H 29 | 30 | #ifndef __SGI_STL_INTERNAL_TREE_H 31 | #include 32 | #endif 33 | #include 34 | #include 35 | #include 36 | 37 | #ifdef __STL_USE_NAMESPACES 38 | using __STD::rb_tree; 39 | using __STD::multimap; 40 | #endif /* __STL_USE_NAMESPACES */ 41 | 42 | #endif /* __SGI_STL_MULTIMAP_H */ 43 | 44 | // Local Variables: 45 | // mode:C++ 46 | // End: 47 | -------------------------------------------------------------------------------- /STL/src/multiset.h: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 1994 4 | * Hewlett-Packard Company 5 | * 6 | * Permission to use, copy, modify, distribute and sell this software 7 | * and its documentation for any purpose is hereby granted without fee, 8 | * provided that the above copyright notice appear in all copies and 9 | * that both that copyright notice and this permission notice appear 10 | * in supporting documentation. Hewlett-Packard Company makes no 11 | * representations about the suitability of this software for any 12 | * purpose. It is provided "as is" without express or implied warranty. 13 | * 14 | * 15 | * Copyright (c) 1996,1997 16 | * Silicon Graphics Computer Systems, Inc. 17 | * 18 | * Permission to use, copy, modify, distribute and sell this software 19 | * and its documentation for any purpose is hereby granted without fee, 20 | * provided that the above copyright notice appear in all copies and 21 | * that both that copyright notice and this permission notice appear 22 | * in supporting documentation. Silicon Graphics makes no 23 | * representations about the suitability of this software for any 24 | * purpose. It is provided "as is" without express or implied warranty. 25 | */ 26 | 27 | #ifndef __SGI_STL_MULTISET_H 28 | #define __SGI_STL_MULTISET_H 29 | 30 | #ifndef __SGI_STL_INTERNAL_TREE_H 31 | #include 32 | #endif 33 | #include 34 | #include 35 | #include 36 | 37 | #ifdef __STL_USE_NAMESPACES 38 | using __STD::rb_tree; 39 | using __STD::multiset; 40 | #endif /* __STL_USE_NAMESPACES */ 41 | 42 | #endif /* __SGI_STL_MULTISET_H */ 43 | 44 | // Local Variables: 45 | // mode:C++ 46 | // End: 47 | -------------------------------------------------------------------------------- /STL/src/numeric: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 1994 4 | * Hewlett-Packard Company 5 | * 6 | * Permission to use, copy, modify, distribute and sell this software 7 | * and its documentation for any purpose is hereby granted without fee, 8 | * provided that the above copyright notice appear in all copies and 9 | * that both that copyright notice and this permission notice appear 10 | * in supporting documentation. Hewlett-Packard Company makes no 11 | * representations about the suitability of this software for any 12 | * purpose. It is provided "as is" without express or implied warranty. 13 | * 14 | * 15 | * Copyright (c) 1996,1997 16 | * Silicon Graphics Computer Systems, Inc. 17 | * 18 | * Permission to use, copy, modify, distribute and sell this software 19 | * and its documentation for any purpose is hereby granted without fee, 20 | * provided that the above copyright notice appear in all copies and 21 | * that both that copyright notice and this permission notice appear 22 | * in supporting documentation. Silicon Graphics makes no 23 | * representations about the suitability of this software for any 24 | * purpose. It is provided "as is" without express or implied warranty. 25 | */ 26 | 27 | #ifndef __SGI_STL_NUMERIC 28 | #define __SGI_STL_NUMERIC 29 | 30 | #include 31 | #include 32 | #include 33 | 34 | #ifdef __STL_USE_NEW_IOSTREAMS 35 | #include 36 | #else /* __STL_USE_NEW_IOSTREAMS */ 37 | #include 38 | #endif /* __STL_USE_NEW_IOSTREAMS */ 39 | 40 | #include 41 | #include 42 | #include 43 | #include 44 | 45 | #endif /* __SGI_STL_NUMERIC */ 46 | 47 | // Local Variables: 48 | // mode:C++ 49 | // End: 50 | -------------------------------------------------------------------------------- /STL/src/pair.h: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 1994 4 | * Hewlett-Packard Company 5 | * 6 | * Permission to use, copy, modify, distribute and sell this software 7 | * and its documentation for any purpose is hereby granted without fee, 8 | * provided that the above copyright notice appear in all copies and 9 | * that both that copyright notice and this permission notice appear 10 | * in supporting documentation. Hewlett-Packard Company makes no 11 | * representations about the suitability of this software for any 12 | * purpose. It is provided "as is" without express or implied warranty. 13 | * 14 | * 15 | * Copyright (c) 1996,1997 16 | * Silicon Graphics Computer Systems, Inc. 17 | * 18 | * Permission to use, copy, modify, distribute and sell this software 19 | * and its documentation for any purpose is hereby granted without fee, 20 | * provided that the above copyright notice appear in all copies and 21 | * that both that copyright notice and this permission notice appear 22 | * in supporting documentation. Silicon Graphics makes no 23 | * representations about the suitability of this software for any 24 | * purpose. It is provided "as is" without express or implied warranty. 25 | */ 26 | 27 | #ifndef __SGI_STL_PAIR_H 28 | #define __SGI_STL_PAIR_H 29 | 30 | #ifndef __STL_CONFIG_H 31 | #include 32 | #endif 33 | #ifndef __SGI_STL_INTERNAL_RELOPS 34 | #include 35 | #endif 36 | #ifndef __SGI_STL_INTERNAL_PAIR_H 37 | #include 38 | #endif 39 | 40 | #ifdef __STL_USE_NAMESPACES 41 | 42 | using __STD::pair; 43 | using __STD::make_pair; 44 | 45 | #endif /* __STL_USE_NAMESPACES */ 46 | 47 | #endif /* __SGI_STL_PAIR_H */ 48 | 49 | // Local Variables: 50 | // mode:C++ 51 | // End: 52 | -------------------------------------------------------------------------------- /STL/src/pthread_alloc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1996-1997 3 | * Silicon Graphics Computer Systems, Inc. 4 | * 5 | * Permission to use, copy, modify, distribute and sell this software 6 | * and its documentation for any purpose is hereby granted without fee, 7 | * provided that the above copyright notice appear in all copies and 8 | * that both that copyright notice and this permission notice appear 9 | * in supporting documentation. Silicon Graphics makes no 10 | * representations about the suitability of this software for any 11 | * purpose. It is provided "as is" without express or implied warranty. 12 | */ 13 | 14 | #ifndef __SGI_STL_PTHREAD_ALLOC_H 15 | #define __SGI_STL_PTHREAD_ALLOC_H 16 | 17 | #include 18 | 19 | #ifdef __STL_USE_NAMESPACES 20 | 21 | using __STD::_Pthread_alloc_template; 22 | using __STD::pthread_alloc; 23 | 24 | #endif /* __STL_USE_NAMESPACES */ 25 | 26 | 27 | #endif /* __SGI_STL_PTHREAD_ALLOC_H */ 28 | 29 | // Local Variables: 30 | // mode:C++ 31 | // End: 32 | -------------------------------------------------------------------------------- /STL/src/queue: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 1994 4 | * Hewlett-Packard Company 5 | * 6 | * Permission to use, copy, modify, distribute and sell this software 7 | * and its documentation for any purpose is hereby granted without fee, 8 | * provided that the above copyright notice appear in all copies and 9 | * that both that copyright notice and this permission notice appear 10 | * in supporting documentation. Hewlett-Packard Company makes no 11 | * representations about the suitability of this software for any 12 | * purpose. It is provided "as is" without express or implied warranty. 13 | * 14 | * 15 | * Copyright (c) 1996,1997 16 | * Silicon Graphics Computer Systems, Inc. 17 | * 18 | * Permission to use, copy, modify, distribute and sell this software 19 | * and its documentation for any purpose is hereby granted without fee, 20 | * provided that the above copyright notice appear in all copies and 21 | * that both that copyright notice and this permission notice appear 22 | * in supporting documentation. Silicon Graphics makes no 23 | * representations about the suitability of this software for any 24 | * purpose. It is provided "as is" without express or implied warranty. 25 | */ 26 | 27 | #ifndef __SGI_STL_QUEUE 28 | #define __SGI_STL_QUEUE 29 | 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | 41 | #endif /* __SGI_STL_QUEUE */ 42 | 43 | // Local Variables: 44 | // mode:C++ 45 | // End: 46 | -------------------------------------------------------------------------------- /STL/src/rope: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1997 3 | * Silicon Graphics Computer Systems, Inc. 4 | * 5 | * Permission to use, copy, modify, distribute and sell this software 6 | * and its documentation for any purpose is hereby granted without fee, 7 | * provided that the above copyright notice appear in all copies and 8 | * that both that copyright notice and this permission notice appear 9 | * in supporting documentation. Silicon Graphics makes no 10 | * representations about the suitability of this software for any 11 | * purpose. It is provided "as is" without express or implied warranty. 12 | */ 13 | 14 | #ifndef __SGI_STL_ROPE 15 | #define __SGI_STL_ROPE 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | #endif /* __SGI_STL_ROPE */ 29 | 30 | // Local Variables: 31 | // mode:C++ 32 | // End: 33 | -------------------------------------------------------------------------------- /STL/src/rope.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1997 3 | * Silicon Graphics Computer Systems, Inc. 4 | * 5 | * Permission to use, copy, modify, distribute and sell this software 6 | * and its documentation for any purpose is hereby granted without fee, 7 | * provided that the above copyright notice appear in all copies and 8 | * that both that copyright notice and this permission notice appear 9 | * in supporting documentation. Silicon Graphics makes no 10 | * representations about the suitability of this software for any 11 | * purpose. It is provided "as is" without express or implied warranty. 12 | */ 13 | 14 | #ifndef __SGI_STL_ROPE_H 15 | #define __SGI_STL_ROPE_H 16 | 17 | #include 18 | #include 19 | 20 | #ifdef __STL_USE_NAMESPACES 21 | 22 | using __STD::char_producer; 23 | using __STD::sequence_buffer; 24 | using __STD::rope; 25 | using __STD::crope; 26 | using __STD::wrope; 27 | 28 | #endif /* __STL_USE_NAMESPACES */ 29 | 30 | #endif /* __SGI_STL_ROPE_H */ 31 | 32 | // Local Variables: 33 | // mode:C++ 34 | // End: 35 | -------------------------------------------------------------------------------- /STL/src/set: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 1994 4 | * Hewlett-Packard Company 5 | * 6 | * Permission to use, copy, modify, distribute and sell this software 7 | * and its documentation for any purpose is hereby granted without fee, 8 | * provided that the above copyright notice appear in all copies and 9 | * that both that copyright notice and this permission notice appear 10 | * in supporting documentation. Hewlett-Packard Company makes no 11 | * representations about the suitability of this software for any 12 | * purpose. It is provided "as is" without express or implied warranty. 13 | * 14 | * 15 | * Copyright (c) 1996,1997 16 | * Silicon Graphics Computer Systems, Inc. 17 | * 18 | * Permission to use, copy, modify, distribute and sell this software 19 | * and its documentation for any purpose is hereby granted without fee, 20 | * provided that the above copyright notice appear in all copies and 21 | * that both that copyright notice and this permission notice appear 22 | * in supporting documentation. Silicon Graphics makes no 23 | * representations about the suitability of this software for any 24 | * purpose. It is provided "as is" without express or implied warranty. 25 | */ 26 | 27 | #ifndef __SGI_STL_SET 28 | #define __SGI_STL_SET 29 | 30 | #ifndef __SGI_STL_INTERNAL_TREE_H 31 | #include 32 | #endif 33 | #include 34 | #include 35 | 36 | #endif /* __SGI_STL_SET */ 37 | 38 | // Local Variables: 39 | // mode:C++ 40 | // End: 41 | -------------------------------------------------------------------------------- /STL/src/set.h: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 1994 4 | * Hewlett-Packard Company 5 | * 6 | * Permission to use, copy, modify, distribute and sell this software 7 | * and its documentation for any purpose is hereby granted without fee, 8 | * provided that the above copyright notice appear in all copies and 9 | * that both that copyright notice and this permission notice appear 10 | * in supporting documentation. Hewlett-Packard Company makes no 11 | * representations about the suitability of this software for any 12 | * purpose. It is provided "as is" without express or implied warranty. 13 | * 14 | * 15 | * Copyright (c) 1996,1997 16 | * Silicon Graphics Computer Systems, Inc. 17 | * 18 | * Permission to use, copy, modify, distribute and sell this software 19 | * and its documentation for any purpose is hereby granted without fee, 20 | * provided that the above copyright notice appear in all copies and 21 | * that both that copyright notice and this permission notice appear 22 | * in supporting documentation. Silicon Graphics makes no 23 | * representations about the suitability of this software for any 24 | * purpose. It is provided "as is" without express or implied warranty. 25 | */ 26 | 27 | #ifndef __SGI_STL_SET_H 28 | #define __SGI_STL_SET_H 29 | 30 | #ifndef __SGI_STL_INTERNAL_TREE_H 31 | #include 32 | #endif 33 | #include 34 | #include 35 | #include 36 | 37 | #ifdef __STL_USE_NAMESPACES 38 | using __STD::rb_tree; 39 | using __STD::set; 40 | #endif /* __STL_USE_NAMESPACES */ 41 | 42 | #endif /* __SGI_STL_SET_H */ 43 | 44 | // Local Variables: 45 | // mode:C++ 46 | // End: 47 | -------------------------------------------------------------------------------- /STL/src/slist: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1997 3 | * Silicon Graphics Computer Systems, Inc. 4 | * 5 | * Permission to use, copy, modify, distribute and sell this software 6 | * and its documentation for any purpose is hereby granted without fee, 7 | * provided that the above copyright notice appear in all copies and 8 | * that both that copyright notice and this permission notice appear 9 | * in supporting documentation. Silicon Graphics makes no 10 | * representations about the suitability of this software for any 11 | * purpose. It is provided "as is" without express or implied warranty. 12 | * 13 | */ 14 | 15 | #ifndef __SGI_STL_SLIST 16 | #define __SGI_STL_SLIST 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | #endif /* __SGI_STL_SLIST */ 25 | 26 | // Local Variables: 27 | // mode:C++ 28 | // End: 29 | -------------------------------------------------------------------------------- /STL/src/slist.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1997 3 | * Silicon Graphics Computer Systems, Inc. 4 | * 5 | * Permission to use, copy, modify, distribute and sell this software 6 | * and its documentation for any purpose is hereby granted without fee, 7 | * provided that the above copyright notice appear in all copies and 8 | * that both that copyright notice and this permission notice appear 9 | * in supporting documentation. Silicon Graphics makes no 10 | * representations about the suitability of this software for any 11 | * purpose. It is provided "as is" without express or implied warranty. 12 | * 13 | */ 14 | 15 | #ifndef __SGI_STL_SLIST_H 16 | #define __SGI_STL_SLIST_H 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | #ifdef __STL_USE_NAMESPACES 23 | using __STD::slist; 24 | #endif /* __STL_USE_NAMESPACES */ 25 | 26 | #endif /* __SGI_STL_SLIST_H */ 27 | 28 | // Local Variables: 29 | // mode:C++ 30 | // End: 31 | -------------------------------------------------------------------------------- /STL/src/stack: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 1994 4 | * Hewlett-Packard Company 5 | * 6 | * Permission to use, copy, modify, distribute and sell this software 7 | * and its documentation for any purpose is hereby granted without fee, 8 | * provided that the above copyright notice appear in all copies and 9 | * that both that copyright notice and this permission notice appear 10 | * in supporting documentation. Hewlett-Packard Company makes no 11 | * representations about the suitability of this software for any 12 | * purpose. It is provided "as is" without express or implied warranty. 13 | * 14 | * 15 | * Copyright (c) 1996,1997 16 | * Silicon Graphics Computer Systems, Inc. 17 | * 18 | * Permission to use, copy, modify, distribute and sell this software 19 | * and its documentation for any purpose is hereby granted without fee, 20 | * provided that the above copyright notice appear in all copies and 21 | * that both that copyright notice and this permission notice appear 22 | * in supporting documentation. Silicon Graphics makes no 23 | * representations about the suitability of this software for any 24 | * purpose. It is provided "as is" without express or implied warranty. 25 | */ 26 | 27 | #ifndef __SGI_STL_STACK 28 | #define __SGI_STL_STACK 29 | 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | 37 | #endif /* __SGI_STL_STACK */ 38 | 39 | // Local Variables: 40 | // mode:C++ 41 | // End: 42 | -------------------------------------------------------------------------------- /STL/src/stack.h: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 1994 4 | * Hewlett-Packard Company 5 | * 6 | * Permission to use, copy, modify, distribute and sell this software 7 | * and its documentation for any purpose is hereby granted without fee, 8 | * provided that the above copyright notice appear in all copies and 9 | * that both that copyright notice and this permission notice appear 10 | * in supporting documentation. Hewlett-Packard Company makes no 11 | * representations about the suitability of this software for any 12 | * purpose. It is provided "as is" without express or implied warranty. 13 | * 14 | * 15 | * Copyright (c) 1996,1997 16 | * Silicon Graphics Computer Systems, Inc. 17 | * 18 | * Permission to use, copy, modify, distribute and sell this software 19 | * and its documentation for any purpose is hereby granted without fee, 20 | * provided that the above copyright notice appear in all copies and 21 | * that both that copyright notice and this permission notice appear 22 | * in supporting documentation. Silicon Graphics makes no 23 | * representations about the suitability of this software for any 24 | * purpose. It is provided "as is" without express or implied warranty. 25 | */ 26 | 27 | #ifndef __SGI_STL_STACK_H 28 | #define __SGI_STL_STACK_H 29 | 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | 36 | #ifdef __STL_USE_NAMESPACES 37 | using __STD::stack; 38 | using __STD::queue; 39 | using __STD::priority_queue; 40 | #endif /* __STL_USE_NAMESPACES */ 41 | 42 | #endif /* __SGI_STL_STACK_H */ 43 | 44 | // Local Variables: 45 | // mode:C++ 46 | // End: 47 | -------------------------------------------------------------------------------- /STL/src/stl_string_fwd.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1997 3 | * Silicon Graphics Computer Systems, Inc. 4 | * 5 | * Permission to use, copy, modify, distribute and sell this software 6 | * and its documentation for any purpose is hereby granted without fee, 7 | * provided that the above copyright notice appear in all copies and 8 | * that both that copyright notice and this permission notice appear 9 | * in supporting documentation. Silicon Graphics makes no 10 | * representations about the suitability of this software for any 11 | * purpose. It is provided "as is" without express or implied warranty. 12 | */ 13 | 14 | #ifndef __SGI_STL_STRING_FWD_H 15 | #define __SGI_STL_STRING_FWD_H 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | __STL_BEGIN_NAMESPACE 23 | 24 | template , 26 | class _Alloc = __STL_DEFAULT_ALLOCATOR(_CharT) > 27 | class basic_string; 28 | 29 | typedef basic_string string; 30 | typedef basic_string wstring; 31 | 32 | static const char* __get_c_string(const string&); 33 | 34 | __STL_END_NAMESPACE 35 | 36 | #endif /* __SGI_STL_STRING_FWD_H */ 37 | 38 | // Local Variables: 39 | // mode:C++ 40 | // End: 41 | -------------------------------------------------------------------------------- /STL/src/tree.h: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 1996,1997 4 | * Silicon Graphics Computer Systems, Inc. 5 | * 6 | * Permission to use, copy, modify, distribute and sell this software 7 | * and its documentation for any purpose is hereby granted without fee, 8 | * provided that the above copyright notice appear in all copies and 9 | * that both that copyright notice and this permission notice appear 10 | * in supporting documentation. Silicon Graphics makes no 11 | * representations about the suitability of this software for any 12 | * purpose. It is provided "as is" without express or implied warranty. 13 | * 14 | * 15 | * Copyright (c) 1994 16 | * Hewlett-Packard Company 17 | * 18 | * Permission to use, copy, modify, distribute and sell this software 19 | * and its documentation for any purpose is hereby granted without fee, 20 | * provided that the above copyright notice appear in all copies and 21 | * that both that copyright notice and this permission notice appear 22 | * in supporting documentation. Hewlett-Packard Company makes no 23 | * representations about the suitability of this software for any 24 | * purpose. It is provided "as is" without express or implied warranty. 25 | * 26 | * 27 | */ 28 | 29 | #ifndef __SGI_STL_TREE_H 30 | #define __SGI_STL_TREE_H 31 | 32 | #ifndef __SGI_STL_INTERNAL_TREE_H 33 | #include 34 | #endif 35 | #include 36 | #include 37 | 38 | #ifdef __STL_USE_NAMESPACES 39 | using __STD::rb_tree; 40 | #endif /* __STL_USE_NAMESPACES */ 41 | 42 | #endif /* __SGI_STL_TREE_H */ 43 | 44 | // Local Variables: 45 | // mode:C++ 46 | // End: 47 | -------------------------------------------------------------------------------- /STL/src/utility: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 1994 4 | * Hewlett-Packard Company 5 | * 6 | * Permission to use, copy, modify, distribute and sell this software 7 | * and its documentation for any purpose is hereby granted without fee, 8 | * provided that the above copyright notice appear in all copies and 9 | * that both that copyright notice and this permission notice appear 10 | * in supporting documentation. Hewlett-Packard Company makes no 11 | * representations about the suitability of this software for any 12 | * purpose. It is provided "as is" without express or implied warranty. 13 | * 14 | * 15 | * Copyright (c) 1996,1997 16 | * Silicon Graphics Computer Systems, Inc. 17 | * 18 | * Permission to use, copy, modify, distribute and sell this software 19 | * and its documentation for any purpose is hereby granted without fee, 20 | * provided that the above copyright notice appear in all copies and 21 | * that both that copyright notice and this permission notice appear 22 | * in supporting documentation. Silicon Graphics makes no 23 | * representations about the suitability of this software for any 24 | * purpose. It is provided "as is" without express or implied warranty. 25 | */ 26 | 27 | #ifndef __SGI_STL_UTILITY 28 | #define __SGI_STL_UTILITY 29 | 30 | #include 31 | #include 32 | #include 33 | 34 | #endif /* __SGI_STL_UTILITY */ 35 | 36 | // Local Variables: 37 | // mode:C++ 38 | // End: 39 | -------------------------------------------------------------------------------- /STL/src/vector: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 1994 4 | * Hewlett-Packard Company 5 | * 6 | * Permission to use, copy, modify, distribute and sell this software 7 | * and its documentation for any purpose is hereby granted without fee, 8 | * provided that the above copyright notice appear in all copies and 9 | * that both that copyright notice and this permission notice appear 10 | * in supporting documentation. Hewlett-Packard Company makes no 11 | * representations about the suitability of this software for any 12 | * purpose. It is provided "as is" without express or implied warranty. 13 | * 14 | * 15 | * Copyright (c) 1996 16 | * Silicon Graphics Computer Systems, Inc. 17 | * 18 | * Permission to use, copy, modify, distribute and sell this software 19 | * and its documentation for any purpose is hereby granted without fee, 20 | * provided that the above copyright notice appear in all copies and 21 | * that both that copyright notice and this permission notice appear 22 | * in supporting documentation. Silicon Graphics makes no 23 | * representations about the suitability of this software for any 24 | * purpose. It is provided "as is" without express or implied warranty. 25 | */ 26 | 27 | #ifndef __SGI_STL_VECTOR 28 | #define __SGI_STL_VECTOR 29 | 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | 38 | #endif /* __SGI_STL_VECTOR */ 39 | 40 | // Local Variables: 41 | // mode:C++ 42 | // End: 43 | -------------------------------------------------------------------------------- /STL/src/vector.h: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 1994 4 | * Hewlett-Packard Company 5 | * 6 | * Permission to use, copy, modify, distribute and sell this software 7 | * and its documentation for any purpose is hereby granted without fee, 8 | * provided that the above copyright notice appear in all copies and 9 | * that both that copyright notice and this permission notice appear 10 | * in supporting documentation. Hewlett-Packard Company makes no 11 | * representations about the suitability of this software for any 12 | * purpose. It is provided "as is" without express or implied warranty. 13 | * 14 | * 15 | * Copyright (c) 1996 16 | * Silicon Graphics Computer Systems, Inc. 17 | * 18 | * Permission to use, copy, modify, distribute and sell this software 19 | * and its documentation for any purpose is hereby granted without fee, 20 | * provided that the above copyright notice appear in all copies and 21 | * that both that copyright notice and this permission notice appear 22 | * in supporting documentation. Silicon Graphics makes no 23 | * representations about the suitability of this software for any 24 | * purpose. It is provided "as is" without express or implied warranty. 25 | */ 26 | 27 | #ifndef __SGI_STL_VECTOR_H 28 | #define __SGI_STL_VECTOR_H 29 | 30 | #include 31 | #include 32 | #include 33 | #include 34 | 35 | #ifdef __STL_USE_NAMESPACES 36 | using __STD::vector; 37 | #endif /* __STL_USE_NAMESPACES */ 38 | 39 | #endif /* __SGI_STL_VECTOR_H */ 40 | 41 | // Local Variables: 42 | // mode:C++ 43 | // End: 44 | -------------------------------------------------------------------------------- /anet/scripts/rule.txt: -------------------------------------------------------------------------------- 1 | ^[ ]*char [a-zA-z0-9_]*; 2 | ^[ ]*char \*[a-zA-z0-9_]*; 3 | ^[ ]*int [a-zA-z0-9_]*; 4 | ^[ ]*int \*[a-zA-z0-9_]*; 5 | ^[ ]*long [a-zA-z0-9_]*; 6 | ^[ ]*long \*[a-zA-z0-9_]*; 7 | ^[ ]*float [a-zA-z0-9_]*; 8 | ^[ ]*float \*[a-zA-z0-9_]*; 9 | ^[ ]*double [a-zA-z0-9_]*; 10 | ^[ ]*double \*[a-zA-z0-9_]*; 11 | ^[ ]*unsigned char [a-zA-z0-9_]*; 12 | ^[ ]*unsigned char \*[a-zA-z0-9_]*; 13 | ^[ ]*unsigned int [a-zA-z0-9_]*; 14 | ^[ ]*unsigned int \*[a-zA-z0-9_]*; 15 | ^[ ]*unsigned long [a-zA-z0-9_]*; 16 | ^[ ]*unsigned long \*[a-zA-z0-9_]*; 17 | ^[ ]*unsigned float [a-zA-z0-9_]*; 18 | ^[ ]*unsigned float \*[a-zA-z0-9_]*; 19 | ^[ ]*unsigned double [a-zA-z0-9_]*; 20 | ^[ ]*unsigned double \*[a-zA-z0-9_]*; 21 | ^[ ]*size_t [a-zA-z0-9_]*; 22 | ^[ ]*size_t \*[a-zA-z0-9_]*; 23 | ^[ ]*bool [a-zA-z0-9_]*; 24 | ^[ ]*bool \*[a-zA-z0-9_]*; 25 | -------------------------------------------------------------------------------- /anet/src/anet/anet.h: -------------------------------------------------------------------------------- 1 | #ifndef ANET_ANET_H 2 | #define ANET_ANET_H 3 | #include 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #include 11 | #include 12 | 13 | #include "defaultpacket.h" 14 | #include "defaultpacketfactory.h" 15 | #include "defaultpacketstreamer.h" 16 | 17 | #include "httppacket.h" 18 | #include "httppacketfactory.h" 19 | #include "httpstreamer.h" 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | #include 27 | 28 | //DO NOT export interfaces about logging implicitly 29 | //#include 30 | 31 | /**legacy http related header files*/ 32 | #include 33 | #include 34 | #include 35 | 36 | #endif/*End of ANET_ANET_H*/ 37 | 38 | -------------------------------------------------------------------------------- /anet/src/anet/aneterror.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * File name: aneterror.cpp 3 | * Author: zhangli 4 | * Create time: 2008-12-21 15:29:40 5 | * $Id$ 6 | * 7 | * Description: ***add description here*** 8 | * 9 | */ 10 | 11 | #include 12 | 13 | // 定义错误 14 | namespace anet { 15 | const int AnetError::INVALID_DATA = 1; 16 | const char* AnetError::INVALID_DATA_S = "Invalid Data"; 17 | 18 | const int AnetError::CONNECTION_CLOSED = 2; 19 | const char* AnetError::CONNECTION_CLOSED_S = "Connection closed"; 20 | 21 | const int AnetError::PKG_TOO_LARGE = 3; 22 | const char* AnetError::PKG_TOO_LARGE_S = "Packet Too Large"; 23 | 24 | const int AnetError::LENGTH_REQUIRED = 411; 25 | const char* AnetError::LENGTH_REQUIRED_S = "Length Required"; 26 | 27 | const int AnetError::URI_TOO_LARGE = 414; 28 | const char* AnetError::URI_TOO_LARGE_S = "Request-URI Too Long"; 29 | 30 | const int AnetError::VERSION_NOT_SUPPORT = 505; 31 | const char* AnetError::VERSION_NOT_SUPPORT_S = "HTTP Version Not Supported"; 32 | 33 | const int AnetError::TOO_MANY_HEADERS = 499; 34 | const char* AnetError::TOO_MANY_HEADERS_S = "Too Many Headers"; 35 | 36 | }/*end namespace anet*/ 37 | -------------------------------------------------------------------------------- /anet/src/anet/aneterror.h: -------------------------------------------------------------------------------- 1 | /** 2 | * File name: aneterror.h 3 | * Author: zhangli 4 | * Create time: 2008-12-21 15:29:40 5 | * $Id$ 6 | * 7 | * Description: ***add description here*** 8 | * 9 | */ 10 | 11 | #ifndef ANET_ANETERROR_H_ 12 | #define ANET_ANETERROR_H_ 13 | //*****add include headers here... 14 | namespace anet { 15 | class AnetError 16 | { 17 | public: 18 | static const int INVALID_DATA; 19 | static const char *INVALID_DATA_S; 20 | 21 | static const int CONNECTION_CLOSED; 22 | static const char *CONNECTION_CLOSED_S; 23 | 24 | static const int PKG_TOO_LARGE; 25 | static const char *PKG_TOO_LARGE_S; 26 | 27 | /** 28 | * HTTP related error no 29 | */ 30 | static const int LENGTH_REQUIRED; 31 | static const char *LENGTH_REQUIRED_S; 32 | 33 | static const int URI_TOO_LARGE; 34 | static const char *URI_TOO_LARGE_S; 35 | 36 | static const int VERSION_NOT_SUPPORT; 37 | static const char *VERSION_NOT_SUPPORT_S; 38 | 39 | static const int TOO_MANY_HEADERS; 40 | static const char *TOO_MANY_HEADERS_S; 41 | }; 42 | 43 | }/*end namespace anet*/ 44 | #endif /*ANET_ANETERROR_H_*/ 45 | -------------------------------------------------------------------------------- /anet/src/anet/channel.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imyouxia/Source/624df9ffeb73d9ce918d5f7ef77bae6b9919e30a/anet/src/anet/channel.cpp -------------------------------------------------------------------------------- /anet/src/anet/channel.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imyouxia/Source/624df9ffeb73d9ce918d5f7ef77bae6b9919e30a/anet/src/anet/channel.h -------------------------------------------------------------------------------- /anet/src/anet/channelpool.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imyouxia/Source/624df9ffeb73d9ce918d5f7ef77bae6b9919e30a/anet/src/anet/channelpool.cpp -------------------------------------------------------------------------------- /anet/src/anet/channelpool.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imyouxia/Source/624df9ffeb73d9ce918d5f7ef77bae6b9919e30a/anet/src/anet/channelpool.h -------------------------------------------------------------------------------- /anet/src/anet/connection.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imyouxia/Source/624df9ffeb73d9ce918d5f7ef77bae6b9919e30a/anet/src/anet/connection.cpp -------------------------------------------------------------------------------- /anet/src/anet/connection.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imyouxia/Source/624df9ffeb73d9ce918d5f7ef77bae6b9919e30a/anet/src/anet/connection.h -------------------------------------------------------------------------------- /anet/src/anet/controlpacket.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | namespace anet { 5 | ControlPacket ControlPacket::BadPacket(CMD_BAD_PACKET, false); 6 | ControlPacket ControlPacket::TimeoutPacket(CMD_TIMEOUT_PACKET, false); 7 | ControlPacket ControlPacket::ConnectionClosedPacket(CMD_CONNECTION_CLOSED, false); 8 | 9 | ControlPacket::ControlPacket(int c, bool freeDelete) { 10 | _command = c; 11 | _freeDelete = freeDelete; 12 | } 13 | 14 | void ControlPacket::free() { 15 | if (_freeDelete) { 16 | delete this; 17 | } 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /anet/src/anet/controlpacket.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imyouxia/Source/624df9ffeb73d9ce918d5f7ef77bae6b9919e30a/anet/src/anet/controlpacket.h -------------------------------------------------------------------------------- /anet/src/anet/databuffer.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imyouxia/Source/624df9ffeb73d9ce918d5f7ef77bae6b9919e30a/anet/src/anet/databuffer.h -------------------------------------------------------------------------------- /anet/src/anet/defaultpacket.h: -------------------------------------------------------------------------------- 1 | /** 2 | * File name: defaultpacket.h 3 | * Author: zhangli 4 | * Create time: 2008-12-25 11:10:50 5 | * $Id$ 6 | * 7 | * Description: ***add description here*** 8 | * 9 | */ 10 | 11 | #ifndef ANET_DEFAULTPACKET_H_ 12 | #define ANET_DEFAULTPACKET_H_ 13 | #include 14 | 15 | namespace anet { 16 | class DefaultPacket : public Packet 17 | { 18 | public: 19 | DefaultPacket(); 20 | ~DefaultPacket(); 21 | 22 | bool setBody(const char *, size_t); 23 | bool appendBody(const char *, size_t); 24 | const char* getBody(size_t&) const; 25 | char* getBody(size_t&); 26 | const char* getBody() const; 27 | char* getBody(); 28 | 29 | bool encode(DataBuffer *output); 30 | bool decode(DataBuffer *input, PacketHeader *header); 31 | 32 | size_t getBodyLen(); 33 | bool setCapacity(size_t size); 34 | size_t getCapacity(); 35 | 36 | protected: 37 | char *_body; 38 | size_t _bodyLength; 39 | size_t _capacity; 40 | 41 | }; 42 | 43 | }/*end namespace anet*/ 44 | #endif /*ANET_DEFAULTPACKET_H_*/ 45 | -------------------------------------------------------------------------------- /anet/src/anet/defaultpacketfactory.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * File name: defaultpacketfactory.cpp 3 | * Author: zhangli 4 | * Create time: 2008-12-25 11:38:19 5 | * $Id$ 6 | * 7 | * Description: ***add description here*** 8 | * 9 | */ 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | namespace anet { 16 | Packet *DefaultPacketFactory::createPacket(int pcode) { 17 | return new DefaultPacket; 18 | } 19 | 20 | }/*end namespace anet*/ 21 | -------------------------------------------------------------------------------- /anet/src/anet/defaultpacketfactory.h: -------------------------------------------------------------------------------- 1 | /** 2 | * File name: defaultpacketfactory.h 3 | * Author: zhangli 4 | * Create time: 2008-12-25 11:38:19 5 | * $Id$ 6 | * 7 | * Description: ***add description here*** 8 | * 9 | */ 10 | 11 | #ifndef ANET_DEFAULTPACKETFACTORY_H_ 12 | #define ANET_DEFAULTPACKETFACTORY_H_ 13 | #include 14 | 15 | namespace anet { 16 | class Packet; 17 | class DefaultPacketFactory : public IPacketFactory 18 | { 19 | public: 20 | Packet *createPacket(int pcode); 21 | }; 22 | 23 | }/*end namespace anet*/ 24 | #endif /*ANET_DEFAULTPACKETFACTORY_H_*/ 25 | -------------------------------------------------------------------------------- /anet/src/anet/defaultpacketstreamer.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imyouxia/Source/624df9ffeb73d9ce918d5f7ef77bae6b9919e30a/anet/src/anet/defaultpacketstreamer.cpp -------------------------------------------------------------------------------- /anet/src/anet/defaultpacketstreamer.h: -------------------------------------------------------------------------------- 1 | #ifndef ANET_DEFAULT_PACKET_STREAMER_H_ 2 | #define ANET_DEFAULT_PACKET_STREAMER_H_ 3 | 4 | #include 5 | 6 | namespace anet { 7 | 8 | class DefaultPacketStreamer : public IPacketStreamer { 9 | friend class DEFAULTPACKETSTREAMERTF; 10 | public: 11 | 12 | DefaultPacketStreamer(IPacketFactory *factory); 13 | 14 | ~DefaultPacketStreamer(); 15 | 16 | virtual StreamingContext* createContext(); 17 | 18 | /** 19 | * get information about the packet in input data buffer 20 | * 21 | * @param input input data buffer 22 | * @param header packet header 23 | * @return retrun true if we get the packet header; return false if not. 24 | */ 25 | bool getPacketInfo(DataBuffer *input, PacketHeader *header, bool *broken); 26 | 27 | /** 28 | * decode the data in input buffer to get a packet 29 | * 30 | * @param input 31 | * @param header 32 | * @return return a packet if we get it. return NULL if not 33 | */ 34 | Packet *decode(DataBuffer *input, PacketHeader *header); 35 | 36 | /** 37 | * encode a packet into output data buffer 38 | * 39 | * @param packet packet to be encoded 40 | * @param output output data buffer 41 | * @return return true if we finished encode. return false if not 42 | */ 43 | bool encode(Packet *packet, DataBuffer *output); 44 | 45 | bool processData(DataBuffer *dataBuffer, StreamingContext *context); 46 | 47 | }; 48 | } 49 | 50 | #endif /*DEFAULT_PACKET_STREAMER_H_*/ 51 | -------------------------------------------------------------------------------- /anet/src/anet/epollsocketevent.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imyouxia/Source/624df9ffeb73d9ce918d5f7ef77bae6b9919e30a/anet/src/anet/epollsocketevent.cpp -------------------------------------------------------------------------------- /anet/src/anet/epollsocketevent.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imyouxia/Source/624df9ffeb73d9ce918d5f7ef77bae6b9919e30a/anet/src/anet/epollsocketevent.h -------------------------------------------------------------------------------- /anet/src/anet/filecontrol.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | namespace anet { 4 | // http://blog.csdn.net/chrisniu1984/article/details/7050663 5 | // 关闭子进程无用文件描述符 6 | bool FileControl::setCloseOnExec(int fd) { 7 | int flags; 8 | flags = fcntl(fd, F_GETFD); 9 | if (flags == -1) { 10 | return false; 11 | } 12 | flags |= FD_CLOEXEC; 13 | return fcntl(fd, F_SETFD, flags) != -1; 14 | } 15 | 16 | bool FileControl::clearCloseOnExec(int fd) { 17 | int flags; 18 | flags = fcntl(fd, F_GETFD); 19 | if (flags == -1) { 20 | return false; 21 | } 22 | flags &= ~FD_CLOEXEC; 23 | return fcntl(fd, F_SETFD, flags) != -1; 24 | } 25 | 26 | bool FileControl::isCloseOnExec(int fd) { 27 | int flags; 28 | flags = fcntl(fd, F_GETFD); 29 | if (flags == -1) { 30 | return false; 31 | } 32 | return flags & FD_CLOEXEC; 33 | } 34 | 35 | } 36 | 37 | 38 | -------------------------------------------------------------------------------- /anet/src/anet/filecontrol.h: -------------------------------------------------------------------------------- 1 | #ifndef ANET_FILECONTROL_H_ 2 | #define ANET_FILECONTROL_H_ 3 | namespace anet { 4 | class FileControl { 5 | public: 6 | static bool setCloseOnExec(int fd); 7 | static bool clearCloseOnExec(int fd); 8 | static bool isCloseOnExec(int fd); 9 | }; 10 | } 11 | 12 | #endif /*FILECONTROL_H_*/ 13 | -------------------------------------------------------------------------------- /anet/src/anet/httppacketfactory.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * File name: httppacketfactory.cpp 3 | * Author: zhangli 4 | * Create time: 2008-12-19 16:36:39 5 | * $Id$ 6 | * 7 | * Description: ***add description here*** 8 | * 9 | */ 10 | 11 | #include 12 | #include 13 | 14 | namespace anet { 15 | HTTPPacketFactory::HTTPPacketFactory() { 16 | } 17 | 18 | Packet* HTTPPacketFactory::createPacket(int pcode) { 19 | return new HTTPPacket; 20 | } 21 | 22 | }/*end namespace anet*/ 23 | -------------------------------------------------------------------------------- /anet/src/anet/httppacketfactory.h: -------------------------------------------------------------------------------- 1 | /** 2 | * File name: httppacketfactory.h 3 | * Author: zhangli 4 | * Create time: 2008-12-19 16:36:39 5 | * $Id$ 6 | * 7 | * Description: ***add description here*** 8 | * 9 | */ 10 | 11 | #ifndef ANET_HTTPPACKETFACTORY_H_ 12 | #define ANET_HTTPPACKETFACTORY_H_ 13 | #include 14 | 15 | namespace anet { 16 | 17 | class HTTPPacketFactory : public IPacketFactory 18 | { 19 | public: 20 | HTTPPacketFactory(); 21 | Packet *createPacket(int pcode); 22 | }; 23 | 24 | }/*end namespace anet*/ 25 | #endif /*ANET_HTTPPACKETFACTORY_H_*/ 26 | -------------------------------------------------------------------------------- /anet/src/anet/httppacketstreamer.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imyouxia/Source/624df9ffeb73d9ce918d5f7ef77bae6b9919e30a/anet/src/anet/httppacketstreamer.cpp -------------------------------------------------------------------------------- /anet/src/anet/httppacketstreamer.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imyouxia/Source/624df9ffeb73d9ce918d5f7ef77bae6b9919e30a/anet/src/anet/httppacketstreamer.h -------------------------------------------------------------------------------- /anet/src/anet/httprequestpacket.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imyouxia/Source/624df9ffeb73d9ce918d5f7ef77bae6b9919e30a/anet/src/anet/httprequestpacket.cpp -------------------------------------------------------------------------------- /anet/src/anet/httprequestpacket.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imyouxia/Source/624df9ffeb73d9ce918d5f7ef77bae6b9919e30a/anet/src/anet/httprequestpacket.h -------------------------------------------------------------------------------- /anet/src/anet/httpresponsepacket.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imyouxia/Source/624df9ffeb73d9ce918d5f7ef77bae6b9919e30a/anet/src/anet/httpresponsepacket.cpp -------------------------------------------------------------------------------- /anet/src/anet/httpresponsepacket.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imyouxia/Source/624df9ffeb73d9ce918d5f7ef77bae6b9919e30a/anet/src/anet/httpresponsepacket.h -------------------------------------------------------------------------------- /anet/src/anet/httpstreamingcontext.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | namespace anet { 5 | HTTPStreamingContext::HTTPStreamingContext() { 6 | _step = HSS_START_LINE; 7 | _dataLength = 0; 8 | _drainedLength = 0; 9 | _headersCount = 0; 10 | _chunkState = CHUNK_SIZE; 11 | } 12 | 13 | HTTPStreamingContext:: ~HTTPStreamingContext() { 14 | } 15 | 16 | void HTTPStreamingContext::reset() { 17 | _step = HSS_START_LINE; 18 | _dataLength = 0; 19 | _drainedLength = 0; 20 | _headersCount = 0; 21 | _chunkState = CHUNK_SIZE; 22 | StreamingContext::reset(); 23 | } 24 | 25 | void HTTPStreamingContext::setErrorNo(int errorNo) { 26 | setBroken(true); 27 | _errorNo = errorNo; 28 | if (errorNo == AnetError::INVALID_DATA) { 29 | _errorString = AnetError::INVALID_DATA_S; 30 | } else if (errorNo == AnetError::PKG_TOO_LARGE) { 31 | _errorString = AnetError::PKG_TOO_LARGE_S; 32 | } else if (errorNo == AnetError::LENGTH_REQUIRED) { 33 | _errorString = AnetError::LENGTH_REQUIRED_S; 34 | } else if (errorNo == AnetError::URI_TOO_LARGE) { 35 | _errorString = AnetError::URI_TOO_LARGE_S; 36 | } else if (errorNo == AnetError::VERSION_NOT_SUPPORT) { 37 | _errorString = AnetError::VERSION_NOT_SUPPORT_S; 38 | } else if (errorNo == AnetError::TOO_MANY_HEADERS) { 39 | _errorString = AnetError::TOO_MANY_HEADERS_S; 40 | } else if (errorNo == AnetError::CONNECTION_CLOSED) { 41 | _errorString = AnetError::CONNECTION_CLOSED_S; 42 | } else { 43 | _errorString = NULL; 44 | } 45 | } 46 | 47 | }/*end namespace anet*/ 48 | -------------------------------------------------------------------------------- /anet/src/anet/httpstreamingcontext.h: -------------------------------------------------------------------------------- 1 | #ifndef ANET_HTTPSTREAMINGCONTEXT_H_ 2 | #define ANET_HTTPSTREAMINGCONTEXT_H_ 3 | #include 4 | #include 5 | 6 | namespace anet { 7 | class HTTPStreamingContext : public StreamingContext 8 | { 9 | public: 10 | HTTPStreamingContext(); 11 | virtual ~HTTPStreamingContext(); 12 | 13 | enum HTTPStreamingStep 14 | { 15 | HSS_START_LINE = 0, 16 | HSS_MESSAGE_HEADER, 17 | HSS_MESSAGE_BODY 18 | }; 19 | enum HTTPEncodingType { 20 | HET_NO_BODY = 0, 21 | HET_LENGTH, 22 | HET_CHUNKED, 23 | HET_EOF 24 | }; 25 | enum HTTPChunkedState { 26 | CHUNK_SIZE = 0, 27 | CHUNK_DATA, 28 | CHUNK_DATA_CRLF, 29 | TRAILER 30 | }; 31 | virtual void reset(); 32 | void setErrorNo(int errorNo); 33 | 34 | public: 35 | HTTPStreamingStep _step; 36 | HTTPChunkedState _chunkState; 37 | HTTPEncodingType _encodingType; 38 | size_t _dataLength; 39 | size_t _drainedLength; 40 | size_t _headersCount; 41 | }; 42 | 43 | }/*end namespace anet*/ 44 | #endif /*ANET_HTTPSTREAMINGCONTEXT_H_*/ 45 | -------------------------------------------------------------------------------- /anet/src/anet/iocomponent.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imyouxia/Source/624df9ffeb73d9ce918d5f7ef77bae6b9919e30a/anet/src/anet/iocomponent.cpp -------------------------------------------------------------------------------- /anet/src/anet/iocomponent.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imyouxia/Source/624df9ffeb73d9ce918d5f7ef77bae6b9919e30a/anet/src/anet/iocomponent.h -------------------------------------------------------------------------------- /anet/src/anet/ipacketfactory.h: -------------------------------------------------------------------------------- 1 | #ifndef ANET_IPACKET_FACTORY_H_ 2 | #define ANET_IPACKET_FACTORY_H_ 3 | 4 | namespace anet { 5 | 6 | class Packet; 7 | 8 | /** 9 | * IPacketFactory is used to construct IPacketStreamer. 10 | * When ANET read response form peer, it will use IPacketFactory 11 | * to construct a new packet. 12 | */ 13 | class IPacketFactory { 14 | public: 15 | virtual ~IPacketFactory(){} 16 | 17 | /** 18 | * The function is called when ANET need to construct a new 19 | * Packet. Which type of Packet will be generated in ANET is 20 | * indicated in this function. 21 | * 22 | * @param pcode type of Packet 23 | * @return address of new Packet. NULL if no Packet generated. 24 | */ 25 | virtual Packet *createPacket(int pcode) = 0; 26 | }; 27 | } 28 | 29 | #endif /*IPACKET_FACTORY_H_*/ 30 | -------------------------------------------------------------------------------- /anet/src/anet/ipackethandler.h: -------------------------------------------------------------------------------- 1 | #ifndef ANET_IPACKETHANDLER_H_ 2 | #define ANET_IPACKETHANDLER_H_ 3 | 4 | namespace anet { 5 | class Packet; 6 | 7 | class IPacketHandler { 8 | public: 9 | enum HPRetCode { 10 | KEEP_CHANNEL = 0, 11 | CLOSE_CHANNEL = 1, 12 | FREE_CHANNEL = 2 13 | }; 14 | 15 | /** 16 | * This function is used in Client. When ANET receive response, 17 | * it will call handlePacket() to deal with response packet. 18 | * User use ANET send requests and use handlePacket() deal 19 | * with response. This function is Called in 20 | * Connection::handlePacket(). 21 | * In some exceptions, ControlPacket(such as TimeoutPacket, 22 | * BadPacket) will be received. Obviously, you should consider 23 | * all these exceptions in you implementation. 24 | * 25 | * @param packet response packet or ControlPacket 26 | * @param args it's used to indicate which request packet this 27 | * respose packet corresponding. It's the same as args you used 28 | * in Connection::posePacket(). 29 | * @return not used temporary. 30 | */ 31 | virtual HPRetCode handlePacket(Packet *packet, void *args) = 0; 32 | }; 33 | } 34 | 35 | #endif /*IPACHETHANDLER_H_*/ 36 | -------------------------------------------------------------------------------- /anet/src/anet/ipacketstreamer.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imyouxia/Source/624df9ffeb73d9ce918d5f7ef77bae6b9919e30a/anet/src/anet/ipacketstreamer.h -------------------------------------------------------------------------------- /anet/src/anet/iserveradapter.h: -------------------------------------------------------------------------------- 1 | #ifndef ANET_ISERVERADAPTER_H 2 | #define ANET_ISERVERADAPTER_H 3 | #include 4 | #include 5 | #include 6 | namespace anet { 7 | 8 | class IServerAdapter { 9 | public: 10 | 11 | /** 12 | * This function is used in Server. When ANET receive request, 13 | * it will call handlePacket() to deal with request packet. 14 | * This function is Called in Connection::handlePacket(). 15 | * In some exceptions, ControlPacket(such as TimeoutPacket, 16 | * BadPacket) will be received. Obviously, you should consider 17 | * all these exceptions in you implementation. 18 | * 19 | * @param connection indicate where the request packet comes 20 | * from, you can use this connection to send a response. 21 | * @param packet request packet or ControlPacket 22 | * @return not used temporary. 23 | */ 24 | virtual IPacketHandler::HPRetCode 25 | handlePacket(Connection *connection, Packet *packet) = 0; 26 | }; 27 | } 28 | 29 | #endif /*ISERVERADAPTER_H*/ 30 | -------------------------------------------------------------------------------- /anet/src/anet/log.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imyouxia/Source/624df9ffeb73d9ce918d5f7ef77bae6b9919e30a/anet/src/anet/log.cpp -------------------------------------------------------------------------------- /anet/src/anet/logconfig.h.in: -------------------------------------------------------------------------------- 1 | /* Defined if logging with alog */ 2 | #@ALOG_FLAG@ 3 | -------------------------------------------------------------------------------- /anet/src/anet/packet.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imyouxia/Source/624df9ffeb73d9ce918d5f7ef77bae6b9919e30a/anet/src/anet/packet.cpp -------------------------------------------------------------------------------- /anet/src/anet/packet.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imyouxia/Source/624df9ffeb73d9ce918d5f7ef77bae6b9919e30a/anet/src/anet/packet.h -------------------------------------------------------------------------------- /anet/src/anet/packetqueue.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imyouxia/Source/624df9ffeb73d9ce918d5f7ef77bae6b9919e30a/anet/src/anet/packetqueue.cpp -------------------------------------------------------------------------------- /anet/src/anet/packetqueue.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imyouxia/Source/624df9ffeb73d9ce918d5f7ef77bae6b9919e30a/anet/src/anet/packetqueue.h -------------------------------------------------------------------------------- /anet/src/anet/runnable.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imyouxia/Source/624df9ffeb73d9ce918d5f7ef77bae6b9919e30a/anet/src/anet/runnable.h -------------------------------------------------------------------------------- /anet/src/anet/serversocket.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imyouxia/Source/624df9ffeb73d9ce918d5f7ef77bae6b9919e30a/anet/src/anet/serversocket.cpp -------------------------------------------------------------------------------- /anet/src/anet/serversocket.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imyouxia/Source/624df9ffeb73d9ce918d5f7ef77bae6b9919e30a/anet/src/anet/serversocket.h -------------------------------------------------------------------------------- /anet/src/anet/socket.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imyouxia/Source/624df9ffeb73d9ce918d5f7ef77bae6b9919e30a/anet/src/anet/socket.cpp -------------------------------------------------------------------------------- /anet/src/anet/socket.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imyouxia/Source/624df9ffeb73d9ce918d5f7ef77bae6b9919e30a/anet/src/anet/socket.h -------------------------------------------------------------------------------- /anet/src/anet/socketevent.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imyouxia/Source/624df9ffeb73d9ce918d5f7ef77bae6b9919e30a/anet/src/anet/socketevent.cpp -------------------------------------------------------------------------------- /anet/src/anet/socketevent.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imyouxia/Source/624df9ffeb73d9ce918d5f7ef77bae6b9919e30a/anet/src/anet/socketevent.h -------------------------------------------------------------------------------- /anet/src/anet/stats.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imyouxia/Source/624df9ffeb73d9ce918d5f7ef77bae6b9919e30a/anet/src/anet/stats.cpp -------------------------------------------------------------------------------- /anet/src/anet/stats.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imyouxia/Source/624df9ffeb73d9ce918d5f7ef77bae6b9919e30a/anet/src/anet/stats.h -------------------------------------------------------------------------------- /anet/src/anet/streamingcontext.h: -------------------------------------------------------------------------------- 1 | #ifndef ANET_STREAMINGCONTEXT_H_ 2 | #define ANET_STREAMINGCONTEXT_H_ 3 | #include 4 | namespace anet { 5 | class StreamingContext 6 | { 7 | public: 8 | StreamingContext(); 9 | virtual ~StreamingContext(); 10 | 11 | bool isCompleted(); 12 | void setCompleted(bool compleled); 13 | bool isBroken(); 14 | void setBroken(bool broken); 15 | void setEndOfFile(bool eof); 16 | bool isEndOfFile(); 17 | Packet *getPacket(); 18 | 19 | virtual void setErrorNo(int errorNo); 20 | int getErrorNo(); 21 | void setErrorString(const char *errorString); 22 | const char *getErrorString(); 23 | 24 | /** 25 | * get the packet from context, then set _packet to NULL. 26 | **/ 27 | Packet *stealPacket(); 28 | void setPacket(Packet *packet); 29 | virtual void reset(); 30 | protected: 31 | Packet *_packet; 32 | bool _completed; 33 | bool _broken; 34 | bool _eof; 35 | int _errorNo; 36 | const char *_errorString; 37 | }; 38 | 39 | }/*end namespace anet*/ 40 | #endif /*ANET_STREAMINGCONTEXT_H_*/ 41 | -------------------------------------------------------------------------------- /anet/src/anet/tags: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imyouxia/Source/624df9ffeb73d9ce918d5f7ef77bae6b9919e30a/anet/src/anet/tags -------------------------------------------------------------------------------- /anet/src/anet/tcpacceptor.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imyouxia/Source/624df9ffeb73d9ce918d5f7ef77bae6b9919e30a/anet/src/anet/tcpacceptor.cpp -------------------------------------------------------------------------------- /anet/src/anet/tcpacceptor.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imyouxia/Source/624df9ffeb73d9ce918d5f7ef77bae6b9919e30a/anet/src/anet/tcpacceptor.h -------------------------------------------------------------------------------- /anet/src/anet/tcpcomponent.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imyouxia/Source/624df9ffeb73d9ce918d5f7ef77bae6b9919e30a/anet/src/anet/tcpcomponent.h -------------------------------------------------------------------------------- /anet/src/anet/tcpconnection.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imyouxia/Source/624df9ffeb73d9ce918d5f7ef77bae6b9919e30a/anet/src/anet/tcpconnection.cpp -------------------------------------------------------------------------------- /anet/src/anet/tcpconnection.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imyouxia/Source/624df9ffeb73d9ce918d5f7ef77bae6b9919e30a/anet/src/anet/tcpconnection.h -------------------------------------------------------------------------------- /anet/src/anet/thread.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imyouxia/Source/624df9ffeb73d9ce918d5f7ef77bae6b9919e30a/anet/src/anet/thread.h -------------------------------------------------------------------------------- /anet/src/anet/threadcond.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imyouxia/Source/624df9ffeb73d9ce918d5f7ef77bae6b9919e30a/anet/src/anet/threadcond.h -------------------------------------------------------------------------------- /anet/src/anet/threadmutex.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imyouxia/Source/624df9ffeb73d9ce918d5f7ef77bae6b9919e30a/anet/src/anet/threadmutex.h -------------------------------------------------------------------------------- /anet/src/anet/timeutil.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imyouxia/Source/624df9ffeb73d9ce918d5f7ef77bae6b9919e30a/anet/src/anet/timeutil.cpp -------------------------------------------------------------------------------- /anet/src/anet/timeutil.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imyouxia/Source/624df9ffeb73d9ce918d5f7ef77bae6b9919e30a/anet/src/anet/timeutil.h -------------------------------------------------------------------------------- /anet/src/anet/transport.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imyouxia/Source/624df9ffeb73d9ce918d5f7ef77bae6b9919e30a/anet/src/anet/transport.cpp -------------------------------------------------------------------------------- /anet/src/anet/transport.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imyouxia/Source/624df9ffeb73d9ce918d5f7ef77bae6b9919e30a/anet/src/anet/transport.h -------------------------------------------------------------------------------- /anet/src/anet/udpacceptor.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imyouxia/Source/624df9ffeb73d9ce918d5f7ef77bae6b9919e30a/anet/src/anet/udpacceptor.h -------------------------------------------------------------------------------- /anet/src/anet/udpcomponent.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imyouxia/Source/624df9ffeb73d9ce918d5f7ef77bae6b9919e30a/anet/src/anet/udpcomponent.cpp -------------------------------------------------------------------------------- /anet/src/anet/udpcomponent.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imyouxia/Source/624df9ffeb73d9ce918d5f7ef77bae6b9919e30a/anet/src/anet/udpcomponent.h -------------------------------------------------------------------------------- /anet/src/anet/udpconnection.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imyouxia/Source/624df9ffeb73d9ce918d5f7ef77bae6b9919e30a/anet/src/anet/udpconnection.cpp -------------------------------------------------------------------------------- /anet/src/anet/udpconnection.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imyouxia/Source/624df9ffeb73d9ce918d5f7ef77bae6b9919e30a/anet/src/anet/udpconnection.h -------------------------------------------------------------------------------- /anet/test/channelpooltf.h: -------------------------------------------------------------------------------- 1 | /** 2 | * $Id: channelpooltf.h 15689 2008-12-26 13:27:52Z zhangli $ 3 | */ 4 | 5 | #ifndef CHANNELPOOLTF_H_ 6 | #define CHANNELPOOLTF_H_ 7 | #include 8 | #include 9 | 10 | namespace anet { 11 | class CHANNELPOOLTF : public CppUnit::TestFixture { 12 | CPPUNIT_TEST_SUITE(CHANNELPOOLTF); 13 | CPPUNIT_TEST(testAllocChannel); 14 | CPPUNIT_TEST(testFreeChannel); 15 | CPPUNIT_TEST(testFindChannel); 16 | CPPUNIT_TEST(testGetTimeoutList); 17 | CPPUNIT_TEST(testAppendFreeList); 18 | // CPPUNIT_TEST(testAllocateWhenExceedMax); 19 | CPPUNIT_TEST_SUITE_END(); 20 | public: 21 | void setUp(); 22 | void tearDown(); 23 | void testAllocChannel(); 24 | void testFreeChannel(); 25 | void testFindChannel(); 26 | void testGetTimeoutList(); 27 | void testAppendFreeList(); 28 | void testAllocateWhenExceedMax(); 29 | 30 | private: 31 | ChannelPool *_channelPool; 32 | int threadCount; 33 | size_t getChannelListSize(Channel *); 34 | size_t getChannelListSizeByTail(Channel *); 35 | }; 36 | } 37 | 38 | #endif /*CHANNELPOOLTF_H_*/ 39 | -------------------------------------------------------------------------------- /anet/test/channeltf.cpp: -------------------------------------------------------------------------------- 1 | #include "channeltf.h" 2 | 3 | using namespace std; 4 | 5 | namespace anet { 6 | 7 | CPPUNIT_TEST_SUITE_REGISTRATION(CHANNELTF); 8 | 9 | void CHANNELTF::setUp() { 10 | } 11 | 12 | void CHANNELTF::tearDown() { 13 | } 14 | 15 | void CHANNELTF::testGetId() { 16 | srand(time(NULL)); 17 | uint32_t cid = rand(); 18 | _channel.setId(cid); 19 | CPPUNIT_ASSERT_EQUAL(cid, _channel.getId()); 20 | } 21 | 22 | void CHANNELTF::testGetArgs() { 23 | } 24 | 25 | void CHANNELTF::testSetHandler() { 26 | } 27 | 28 | void CHANNELTF::testGetHandler() { 29 | } 30 | 31 | void CHANNELTF::testSetExpireTime() { 32 | } 33 | 34 | void CHANNELTF::testGetNext() { 35 | } 36 | 37 | 38 | 39 | } 40 | -------------------------------------------------------------------------------- /anet/test/channeltf.h: -------------------------------------------------------------------------------- 1 | /** 2 | * $Id: channeltf.h 15845 2009-01-04 09:33:25Z zhangli $ 3 | */ 4 | 5 | #ifndef CHANNELTF_H_ 6 | #define CHANNELTF_H_ 7 | #include 8 | #include 9 | #include 10 | 11 | namespace anet { 12 | class CHANNELTF : public CppUnit::TestFixture { 13 | CPPUNIT_TEST_SUITE(CHANNELTF); 14 | CPPUNIT_TEST(testGetId); 15 | CPPUNIT_TEST(testGetArgs); 16 | CPPUNIT_TEST(testSetHandler); 17 | CPPUNIT_TEST(testGetHandler); 18 | CPPUNIT_TEST(testSetExpireTime); 19 | CPPUNIT_TEST(testGetNext); 20 | CPPUNIT_TEST_SUITE_END(); 21 | public: 22 | void setUp(); 23 | void tearDown(); 24 | void testGetId(); 25 | void testGetArgs(); 26 | void testSetHandler(); 27 | void testGetHandler(); 28 | void testSetExpireTime(); 29 | void testGetNext(); 30 | 31 | private: 32 | Channel _channel; 33 | }; 34 | } 35 | 36 | #endif /*CHANNELTF_H_*/ 37 | -------------------------------------------------------------------------------- /anet/test/controlpackettf.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "controlpackettf.h" 4 | #include 5 | using namespace std; 6 | namespace anet { 7 | CPPUNIT_TEST_SUITE_REGISTRATION(ControlPacketTF); 8 | 9 | void ControlPacketTF::testWhat() { 10 | static const char *badStr = "Bad Packet received"; 11 | static const char *timeoutStr = "Packet Timeout"; 12 | static const char *closing = "Connection closing"; 13 | const char *r = NULL; 14 | 15 | ControlPacket *badPacket = &ControlPacket::BadPacket; 16 | r = badPacket->what(); 17 | CPPUNIT_ASSERT_EQUAL(string(badStr),string(r)); 18 | 19 | ControlPacket *timeoutPacket = &ControlPacket::TimeoutPacket; 20 | r = timeoutPacket->what(); 21 | CPPUNIT_ASSERT_EQUAL(string(timeoutStr),string(r)); 22 | 23 | ControlPacket *closingPacket = &ControlPacket::ConnectionClosedPacket; 24 | r = closingPacket->what(); 25 | CPPUNIT_ASSERT_EQUAL(string(closing),string(r)); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /anet/test/controlpackettf.h: -------------------------------------------------------------------------------- 1 | /** 2 | * $Id: controlpackettf.h 15405 2008-12-12 10:02:04Z zhangli $ 3 | */ 4 | 5 | #ifndef CONTROLPACKETTF_H_ 6 | #define CONTROLPACKETTF_H_ 7 | #include 8 | #include 9 | #include 10 | 11 | namespace anet { 12 | class ControlPacketTF : public CppUnit::TestFixture 13 | { 14 | CPPUNIT_TEST_SUITE(ControlPacketTF); 15 | CPPUNIT_TEST(testWhat); 16 | CPPUNIT_TEST_SUITE_END(); 17 | public: 18 | void setUp(){} 19 | void testWhat(); 20 | void tearDown(){} 21 | }; 22 | } 23 | 24 | #endif /*CONTROLPACKETTF_H_*/ 25 | -------------------------------------------------------------------------------- /anet/test/databuffertf.h: -------------------------------------------------------------------------------- 1 | #ifndef DATABUFFERTF_H_ 2 | #define DATABUFFERTF_H_ 3 | 4 | #include 5 | #include 6 | 7 | namespace anet { 8 | class DataBufferTF : public CppUnit::TestFixture{ 9 | 10 | CPPUNIT_TEST_SUITE(DataBufferTF); 11 | CPPUNIT_TEST(testShrink); 12 | CPPUNIT_TEST(testExpand); 13 | CPPUNIT_TEST(testFindBytes); 14 | CPPUNIT_TEST(testWriteAndRead); 15 | CPPUNIT_TEST(testDrainData); 16 | CPPUNIT_TEST_SUITE_END(); 17 | 18 | public: 19 | void setUp(); 20 | void tearDown(); 21 | void testShrink(); 22 | void testExpand(); 23 | void testFindBytes(); 24 | void testFindBytes_KMP(); 25 | void testWriteAndRead(); 26 | void testDrainData(); 27 | }; 28 | } 29 | 30 | 31 | #endif /*DATABUFFERTF_H*/ 32 | -------------------------------------------------------------------------------- /anet/test/defaultpacketfactorytf.h: -------------------------------------------------------------------------------- 1 | /** 2 | * File name: defaultpacketfactorytf.h 3 | * Author: zhangli 4 | * Create time: 2008-12-25 11:29:15 5 | * $Id$ 6 | * 7 | * Description: ***add description here*** 8 | * 9 | */ 10 | 11 | #ifndef ANET_DEFAULTPACKETFACTORYTF_H_ 12 | #define ANET_DEFAULTPACKETFACTORYTF_H_ 13 | #include 14 | 15 | namespace anet { 16 | class DefaultPacketFactoryTF : public CppUnit::TestFixture 17 | { 18 | CPPUNIT_TEST_SUITE(DefaultPacketFactoryTF); 19 | CPPUNIT_TEST(testDefaultPacketFactory); 20 | CPPUNIT_TEST_SUITE_END(); 21 | public: 22 | void setUp(); 23 | void tearDown(); 24 | void testDefaultPacketFactory(); 25 | }; 26 | 27 | }/*end namespace anet*/ 28 | #endif/* ANET_DEFAULTPACKETFACTORYTF_H_*/ 29 | -------------------------------------------------------------------------------- /anet/test/defaultpacketstreamertf.h: -------------------------------------------------------------------------------- 1 | /** 2 | * defaultpacketstreamertf.h 2008-8-6 hua.huangrh 3 | */ 4 | 5 | #ifndef DEFAULTPACKETSTREAMERTF_H_ 6 | #define DEFAULTPACKETSTREAMERTF_H_ 7 | 8 | #define DATA_MAX_SIZE 1024 9 | 10 | #include 11 | #include 12 | 13 | namespace anet{ 14 | class MyPacketFactory; 15 | class DEFAULTPACKETSTREAMERTF : public CppUnit::TestFixture{ 16 | CPPUNIT_TEST_SUITE(DEFAULTPACKETSTREAMERTF); 17 | CPPUNIT_TEST(testGetPacketInfo); 18 | CPPUNIT_TEST(testDecode); 19 | CPPUNIT_TEST(testEncode); 20 | CPPUNIT_TEST(testProcessData); 21 | CPPUNIT_TEST(testProcessDataMultiStep); 22 | CPPUNIT_TEST(testProcessDataErrorHttpRequestPacket); 23 | CPPUNIT_TEST_SUITE_END(); 24 | public: 25 | void setUp(); 26 | void tearDown(); 27 | void testGetPacketInfo(); 28 | void testDecode(); 29 | void testEncode(); 30 | void testProcessData(); 31 | void testProcessDataMultiStep(); 32 | void testProcessDataErrorHttpRequestPacket(); 33 | private: 34 | MyPacketFactory *_factory; 35 | }; 36 | } 37 | 38 | #endif /* DEFAULTPACKETSTREAMERTF_H_ */ 39 | -------------------------------------------------------------------------------- /anet/test/defaultpackettf.h: -------------------------------------------------------------------------------- 1 | /** 2 | * File name: defaultpackettf.h 3 | * Author: zhangli 4 | * Create time: 2008-12-25 11:10:50 5 | * $Id$ 6 | * 7 | * Description: ***add description here*** 8 | * 9 | */ 10 | 11 | #ifndef ANET_DEFAULTPACKETTF_H_ 12 | #define ANET_DEFAULTPACKETTF_H_ 13 | #include 14 | #include 15 | #include 16 | 17 | namespace anet { 18 | class DefaultPacketTF : public CppUnit::TestFixture 19 | { 20 | CPPUNIT_TEST_SUITE(DefaultPacketTF); 21 | CPPUNIT_TEST(testSetGetBody); 22 | CPPUNIT_TEST(testEncodeDecode); 23 | CPPUNIT_TEST(testSetGetCapacity); 24 | CPPUNIT_TEST_SUITE_END(); 25 | public: 26 | void setUp(); 27 | void tearDown(); 28 | void testSetGetBody(); 29 | void testEncodeDecode(); 30 | void testSetGetCapacity(); 31 | private: 32 | DefaultPacket *_packet; 33 | DataBuffer *_dataBuffer; 34 | }; 35 | 36 | }/*end namespace anet*/ 37 | #endif/* ANET_DEFAULTPACKETTF_H_*/ 38 | -------------------------------------------------------------------------------- /anet/test/dotest.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @author Zhang Li 3 | * @date 2008-06-25 17:09:40 4 | * @version $Id: dotest.cpp 15405 2008-12-12 10:02:04Z zhangli $ 5 | * 6 | * @Descriptions: 7 | * Testing Suite for ANet library 8 | */ 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | using namespace CppUnit; 17 | using namespace std; 18 | 19 | int main( int argc, char **argv) 20 | { 21 | anet::Logger::logSetup(); 22 | anet::Logger::setLogLevel("DEBUG"); 23 | signal(SIGPIPE, SIG_IGN); 24 | TextUi::TestRunner runner; 25 | CompilerOutputter *outputter 26 | = new CompilerOutputter(&runner.result(), std::cerr); 27 | runner.setOutputter(outputter); 28 | TestFactoryRegistry ®istry = TestFactoryRegistry::getRegistry(); 29 | runner.addTest( registry.makeTest() ); 30 | bool ok = runner.run("", false); 31 | anet::Logger::logTearDown(); 32 | return ok ? 0 : 1; 33 | } 34 | -------------------------------------------------------------------------------- /anet/test/epollsocketeventtf.h: -------------------------------------------------------------------------------- 1 | /** 2 | * $Id: epollsocketeventtf.h 15845 2009-01-04 09:33:25Z zhangli $ 3 | */ 4 | 5 | #ifndef EPOLLSOCKETEVENTTF_H_ 6 | #define EPOLLSOCKETEVENTTF_H_ 7 | #include 8 | #include 9 | 10 | namespace anet { 11 | class EPollSocketEventTF : public CppUnit::TestFixture { 12 | CPPUNIT_TEST_SUITE(EPollSocketEventTF); 13 | CPPUNIT_TEST(testAddEvent); 14 | CPPUNIT_TEST(testEmptyEvent); 15 | CPPUNIT_TEST(testSetEvent); 16 | CPPUNIT_TEST(testRemoveEvent); 17 | CPPUNIT_TEST(testClose); 18 | CPPUNIT_TEST(testWakeUp); 19 | CPPUNIT_TEST(testDup); 20 | CPPUNIT_TEST_SUITE_END(); 21 | public: 22 | EPollSocketEventTF(); 23 | void setUp(); 24 | void tearDown(); 25 | void testAddEvent(); 26 | void testEmptyEvent(); 27 | void testSetEvent(); 28 | void testRemoveEvent(); 29 | void testClose(); 30 | void testWakeUp(); 31 | void testDup(); 32 | protected: 33 | Socket _tcpClient; 34 | ServerSocket _tcpListener; 35 | Socket *_tcpAccepted; 36 | Socket udpSocket1; 37 | Socket udpSocket2; 38 | 39 | IOComponent *_dummyClient; 40 | IOComponent *_dummyListener; 41 | IOComponent *_dummyAccepted; 42 | }; 43 | } 44 | 45 | #endif /*EPOLLSOCKETEVENTTF_H_*/ 46 | -------------------------------------------------------------------------------- /anet/test/filecontroltf.h: -------------------------------------------------------------------------------- 1 | /** 2 | * $Id:$ 3 | */ 4 | 5 | #ifndef FILECONTROLTF_H_ 6 | #define FILECONTROLTF_H_ 7 | #include 8 | #include 9 | #include 10 | 11 | namespace anet { 12 | class FileControlTF : public CppUnit::TestFixture { 13 | CPPUNIT_TEST_SUITE(FileControlTF); 14 | CPPUNIT_TEST(testIsNotCloseOnExec); 15 | CPPUNIT_TEST(testIsCloseOnExec); 16 | CPPUNIT_TEST(testIsCloseOnExecNegtiveFd); 17 | CPPUNIT_TEST(testIsCloseOnExecNegtiveTooLarge); 18 | CPPUNIT_TEST(testClearCloseOnExec); 19 | CPPUNIT_TEST(testClearCloseOnExecNegtiveFd); 20 | CPPUNIT_TEST(testClearCloseOnExecNegtiveTooLarge); 21 | CPPUNIT_TEST(testSetCloseOnExec); 22 | CPPUNIT_TEST(testSetCloseOnExecNegtiveFd); 23 | CPPUNIT_TEST(testSetCloseOnExecNegtiveTooLarge); 24 | CPPUNIT_TEST_SUITE_END(); 25 | public: 26 | void setUp(); 27 | void tearDown(); 28 | void testIsNotCloseOnExec(); 29 | void testIsCloseOnExec(); 30 | void testIsCloseOnExecNegtiveFd(); 31 | void testIsCloseOnExecNegtiveTooLarge(); 32 | void testClearCloseOnExec(); 33 | void testClearCloseOnExecNegtiveFd(); 34 | void testClearCloseOnExecNegtiveTooLarge(); 35 | void testSetCloseOnExec(); 36 | void testSetCloseOnExecNegtiveFd(); 37 | void testSetCloseOnExecNegtiveTooLarge(); 38 | private: 39 | int _pipes[2]; 40 | }; 41 | } 42 | 43 | #endif /*FILECONTROLTF_H_*/ 44 | -------------------------------------------------------------------------------- /anet/test/httpcomponenttf.cpp: -------------------------------------------------------------------------------- 1 | #include "httpcomponenttf.h" 2 | 3 | namespace anet{ 4 | CPPUNIT_TEST_SUITE_REGISTRATION(HTTPComponentTF); 5 | 6 | void HTTPComponentTF::setUp() 7 | { 8 | } 9 | 10 | void HTTPComponentTF::tearDown() 11 | { 12 | } 13 | 14 | void HTTPComponentTF::testCreateConnection() { 15 | /* Transport tran; 16 | Socket *socket = new Socket(); 17 | HTTPComponent httpComponent(&tran, socket); 18 | IPacketStreamer *fakeStreamer = new DefaultPacketStreamer; 19 | IServerAdapter *fakeAdapter = (IServerAdapter*)0xfa43212; 20 | CPPUNIT_ASSERT(socket->setAddress("localhost",12345)); 21 | CPPUNIT_ASSERT(!httpComponent.createConnection(NULL, NULL)); 22 | CPPUNIT_ASSERT(httpComponent.init(true)); 23 | CPPUNIT_ASSERT(!httpComponent.createConnection(fakeStreamer,NULL)); 24 | CPPUNIT_ASSERT(!httpComponent.createConnection(fakeStreamer, NULL)); 25 | Connection *conn = httpComponent.createConnection(fakeStreamer, fakeAdapter); 26 | CPPUNIT_ASSERT(conn); 27 | CPPUNIT_ASSERT( dynamic_cast(conn)); 28 | CPPUNIT_ASSERT(conn->isServer());*/ 29 | CPPUNIT_ASSERT(false); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /anet/test/httpcomponenttf.h: -------------------------------------------------------------------------------- 1 | #ifndef HTTPCOMPONENTTF_H_ 2 | #define HTTPCOMPONENTTF_H_ 3 | 4 | #include 5 | #include 6 | 7 | namespace anet { 8 | class HTTPComponentTF : public CppUnit::TestFixture{ 9 | 10 | CPPUNIT_TEST_SUITE(HTTPComponentTF); 11 | CPPUNIT_TEST(testCreateConnection); 12 | CPPUNIT_TEST_SUITE_END(); 13 | 14 | public: 15 | void setUp(); 16 | void tearDown(); 17 | void testCreateConnection(); 18 | }; 19 | } 20 | 21 | 22 | #endif /*HTTPCOMPONENTTF_H*/ 23 | -------------------------------------------------------------------------------- /anet/test/httpconnectiontf.cpp: -------------------------------------------------------------------------------- 1 | #include "httpconnectiontf.h" 2 | #include 3 | 4 | namespace anet { 5 | CPPUNIT_TEST_SUITE_REGISTRATION(HttpConnectionTF); 6 | 7 | void HttpConnectionTF::setUp() {} 8 | 9 | void HttpConnectionTF::tearDown() {} 10 | 11 | void HttpConnectionTF::testHttpConnectionTF() { 12 | 13 | } 14 | 15 | }/*end namespace anet*/ 16 | -------------------------------------------------------------------------------- /anet/test/httpconnectiontf.h: -------------------------------------------------------------------------------- 1 | #ifndef ANET_HTTPCONNECTIONTF_H_ 2 | #define ANET_HTTPCONNECTIONTF_H_ 3 | 4 | #include 5 | 6 | namespace anet { 7 | class HttpConnectionTF : public CppUnit::TestFixture 8 | { 9 | CPPUNIT_TEST_SUITE(HttpConnectionTF); 10 | CPPUNIT_TEST(testHttpConnection); 11 | CPPUNIT_TEST_SUITE_END(); 12 | public: 13 | void setUp(); 14 | void tearDown(); 15 | void testHttpConnection(); 16 | }; 17 | 18 | }/*end namespace anet*/ 19 | #endif/* ANET_HTTPCONNECTIONTF_H_*/ 20 | -------------------------------------------------------------------------------- /anet/test/httppacketfactorytf.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * File name: httppacketfactorytf.cpp 3 | * Author: zhangli 4 | * Create time: 2008-12-19 16:36:39 5 | * $Id$ 6 | * 7 | * Description: ***add description here*** 8 | * 9 | */ 10 | 11 | #include "httppacketfactorytf.h" 12 | #include 13 | 14 | namespace anet { 15 | CPPUNIT_TEST_SUITE_REGISTRATION(HTTPPacketFactoryTF); 16 | 17 | void HTTPPacketFactoryTF::setUp() {} 18 | 19 | void HTTPPacketFactoryTF::tearDown() {} 20 | 21 | void HTTPPacketFactoryTF::testHTTPPacketFactoryTF() { 22 | 23 | } 24 | 25 | }/*end namespace anet*/ 26 | -------------------------------------------------------------------------------- /anet/test/httppacketfactorytf.h: -------------------------------------------------------------------------------- 1 | /** 2 | * File name: httppacketfactorytf.h 3 | * Author: zhangli 4 | * Create time: 2008-12-19 16:36:39 5 | * $Id$ 6 | * 7 | * Description: ***add description here*** 8 | * 9 | */ 10 | 11 | #ifndef ANET_HTTPPACKETFACTORYTF_H_ 12 | #define ANET_HTTPPACKETFACTORYTF_H_ 13 | #include 14 | 15 | namespace anet { 16 | class HTTPPacketFactoryTF : public CppUnit::TestFixture 17 | { 18 | CPPUNIT_TEST_SUITE(HTTPPacketFactoryTF); 19 | CPPUNIT_TEST(testHTTPPacketFactory); 20 | CPPUNIT_TEST_SUITE_END(); 21 | public: 22 | void setUp(); 23 | void tearDown(); 24 | void testHTTPPacketFactory(); 25 | }; 26 | 27 | }/*end namespace anet*/ 28 | #endif/* ANET_HTTPPACKETFACTORYTF_H_*/ 29 | -------------------------------------------------------------------------------- /anet/test/httppacketstreamertf.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "httppacketstreamertf.h" 3 | #include 4 | 5 | 6 | using namespace std; 7 | 8 | namespace anet{ 9 | CPPUNIT_TEST_SUITE_REGISTRATION(HttpPacketStreamerTF); 10 | 11 | void HttpPacketStreamerTF::setUp() { 12 | } 13 | 14 | void HttpPacketStreamerTF::tearDown() { 15 | } 16 | 17 | 18 | void HttpPacketStreamerTF::testGetPacketInfo() { 19 | DataBuffer input; 20 | PacketHeader header; 21 | bool broken; 22 | DefaultHttpPacketFactory *factory = new DefaultHttpPacketFactory(); 23 | HttpPacketStreamer streamer(factory); 24 | input.writeBytes("wrong", 5); 25 | CPPUNIT_ASSERT(!streamer.getPacketInfo(&input, &header, &broken)); 26 | input.drainData(6); 27 | input.writeBytes("GET ", 4); 28 | CPPUNIT_ASSERT(!streamer.getPacketInfo(&input, &header, &broken)); 29 | input.writeBytes("this is the content ", 16); 30 | input.writeBytes("\r\n\r\n", 4); 31 | CPPUNIT_ASSERT(streamer.getPacketInfo(&input, &header, &broken)); 32 | CPPUNIT_ASSERT_EQUAL(24, header._dataLen); 33 | delete factory; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /anet/test/httppacketstreamertf.h: -------------------------------------------------------------------------------- 1 | #ifndef HTTPPACKETSTREAMERTF_H_ 2 | #define HTTPPACKETSTREAMERTF_H__ 3 | 4 | #include 5 | #include 6 | 7 | namespace anet { 8 | class HttpPacketStreamerTF : public CppUnit::TestFixture{ 9 | 10 | CPPUNIT_TEST_SUITE(HttpPacketStreamerTF); 11 | CPPUNIT_TEST(testGetPacketInfo); 12 | CPPUNIT_TEST_SUITE_END(); 13 | 14 | public: 15 | void setUp(); 16 | void tearDown(); 17 | void testGetPacketInfo(); 18 | }; 19 | } 20 | 21 | 22 | #endif /*HTTPPACKETSTREAMERTF_H_*/ 23 | -------------------------------------------------------------------------------- /anet/test/httprequestandresponsepackettf.h: -------------------------------------------------------------------------------- 1 | #ifndef HTTPREQUESTANDRESPONSEPACKETTF_H_ 2 | #define HTTPREQUESTANDRESPONSEPACKETTF_H_ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | namespace anet { 10 | class HttpRequestAndResponsePacketTF : public CppUnit::TestFixture{ 11 | 12 | CPPUNIT_TEST_SUITE(HttpRequestAndResponsePacketTF); 13 | CPPUNIT_TEST(testDecodeAndEncode); 14 | CPPUNIT_TEST(testSetBody); 15 | CPPUNIT_TEST_SUITE_END(); 16 | 17 | public: 18 | void setUp(); 19 | void tearDown(); 20 | void testDecodeAndEncode(); 21 | void testSetBody(); 22 | HttpResponsePacket* doReply(HttpRequestPacket *); 23 | }; 24 | } 25 | 26 | 27 | #endif /*HTTPREQUESTANDRESPONSEPACKETTF_H_*/ 28 | -------------------------------------------------------------------------------- /anet/test/httpstreamingcontexttf.h: -------------------------------------------------------------------------------- 1 | #ifndef ANET_HTTPSTREAMINGCONTEXTTF_H_ 2 | #define ANET_HTTPSTREAMINGCONTEXTTF_H_ 3 | 4 | #include 5 | 6 | namespace anet { 7 | class HTTPStreamingContextTF : public CppUnit::TestFixture 8 | { 9 | CPPUNIT_TEST_SUITE(HTTPStreamingContextTF); 10 | CPPUNIT_TEST(testHTTPStreamingContext); 11 | CPPUNIT_TEST(testSetGetErrorNo); 12 | CPPUNIT_TEST(testSetGetErrorString); 13 | CPPUNIT_TEST_SUITE_END(); 14 | public: 15 | void setUp(); 16 | void tearDown(); 17 | void testHTTPStreamingContext(); 18 | void testSetGetErrorNo(); 19 | void testSetGetErrorString(); 20 | }; 21 | 22 | }/*end namespace anet*/ 23 | #endif/* ANET_HTTPSTREAMINGCONTEXTTF_H_*/ 24 | -------------------------------------------------------------------------------- /anet/test/maliciousstreamer.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "maliciousstreamer.h" 3 | namespace anet { 4 | bool MaliciousStreamer::encode(Packet *packet, DataBuffer *output) { 5 | ANET_LOG(DEBUG, "Malicious Encode() called"); 6 | PacketHeader *header = packet->getPacketHeader(); 7 | 8 | // 为了当encode失败恢复时用 9 | int oldLen = output->getDataLen(); 10 | // dataLençäç 11 | int dataLenOffset = -1; 12 | int headerSize = 0; 13 | 14 | // 允许存在头信息,写出头信息 15 | if (_existPacketHeader) { 16 | output->writeInt32(ANET_PACKET_FLAG); 17 | output->writeInt32(header->_chid); 18 | output->writeInt32(header->_pcode); 19 | dataLenOffset = output->getDataLen(); 20 | output->writeInt32(0); 21 | headerSize = 4 * sizeof(int32_t); 22 | } 23 | // 写数据 24 | if (packet->encode(output) == false) { 25 | ANET_LOG(ERROR, "encode error"); 26 | output->stripData(output->getDataLen() - oldLen); 27 | return false; 28 | } 29 | // 计算包长度 30 | header->_dataLen = output->getDataLen() - oldLen - headerSize; 31 | // 最终把长度回到buffer中 32 | if (dataLenOffset >= 0) { 33 | unsigned char *ptr = (unsigned char *)(output->getData() + dataLenOffset); 34 | ANET_LOG(DEBUG, "Write a malicious length(%08x)", _maliciousLen); 35 | output->fillInt32(ptr, _maliciousLen); 36 | 37 | } 38 | return true; 39 | ANET_LOG(DEBUG, "Malicious Encode() call return"); 40 | } 41 | 42 | }//end of namespace anet 43 | -------------------------------------------------------------------------------- /anet/test/maliciousstreamer.h: -------------------------------------------------------------------------------- 1 | #include 2 | #ifndef ANET_MALICIOUS_STREAMER_H_ 3 | #define ANET_MALICIOUS_STREAMER_H_ 4 | 5 | namespace anet { 6 | class MaliciousStreamer : public DefaultPacketStreamer { 7 | public: 8 | MaliciousStreamer(IPacketFactory *factory) : 9 | DefaultPacketStreamer(factory) , _maliciousLen(0x7fffffff){} 10 | bool encode(Packet *packet, DataBuffer *output); 11 | public: 12 | int _maliciousLen; 13 | }; 14 | 15 | }//end of namespace anet 16 | #endif //ANET_MALICIOUS_STREAMER_H_ 17 | -------------------------------------------------------------------------------- /anet/test/packetqueuetf.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imyouxia/Source/624df9ffeb73d9ce918d5f7ef77bae6b9919e30a/anet/test/packetqueuetf.cpp -------------------------------------------------------------------------------- /anet/test/packetqueuetf.h: -------------------------------------------------------------------------------- 1 | /** 2 | * $Id: packetqueuetf.h 15405 2008-12-12 10:02:04Z zhangli $ 3 | */ 4 | 5 | #ifndef ANET__H_ 6 | #define PACKETQUEUETF_H_ 7 | #include 8 | 9 | namespace anet { 10 | class PacketQueueTF : public CppUnit::TestFixture { 11 | CPPUNIT_TEST_SUITE(PacketQueueTF); 12 | CPPUNIT_TEST(testPush); 13 | CPPUNIT_TEST(testPop); 14 | CPPUNIT_TEST(testMoveTo); 15 | CPPUNIT_TEST(testGetTimeoutList); 16 | CPPUNIT_TEST_SUITE_END(); 17 | public: 18 | void setUp(); 19 | void tearDown(); 20 | void testPush(); 21 | void testPop(); 22 | void testMoveTo(); 23 | void testGetTimeoutList(); 24 | }; 25 | } 26 | 27 | #endif /*PACKETQUEUETF_H_*/ 28 | -------------------------------------------------------------------------------- /anet/test/sockettf.h: -------------------------------------------------------------------------------- 1 | /** 2 | * $Id: sockettf.h 15405 2008-12-12 10:02:04Z zhangli $ 3 | */ 4 | 5 | #ifndef SOCKETTF_H_ 6 | #define SOCKETTF_H_ 7 | #include 8 | #include 9 | 10 | namespace anet { 11 | class SocketTF : public CppUnit::TestFixture { 12 | CPPUNIT_TEST_SUITE(SocketTF); 13 | CPPUNIT_TEST(testSetGetAddress); // you can register more methods here 14 | CPPUNIT_TEST(testReadWrite); // you can register more methods here 15 | CPPUNIT_TEST(testConnect); 16 | CPPUNIT_TEST(testListenZeroIPZeroPort); 17 | CPPUNIT_TEST_SUITE_END(); 18 | public: 19 | void setUp(); 20 | void tearDown(); 21 | void testSetGetAddress(); 22 | void testReadWrite(); 23 | void testConnect(); 24 | void testListenZeroIPZeroPort(); 25 | }; 26 | } 27 | 28 | #endif /*SOCKETTF_H_*/ 29 | -------------------------------------------------------------------------------- /anet/test/streamingcontexttf.h: -------------------------------------------------------------------------------- 1 | #ifndef ANET_STREAMINGCONTEXTTF_H_ 2 | #define ANET_STREAMINGCONTEXTTF_H_ 3 | 4 | #include 5 | #include 6 | 7 | namespace anet { 8 | class StreamingContextTF : public CppUnit::TestFixture 9 | { 10 | CPPUNIT_TEST_SUITE(StreamingContextTF); 11 | CPPUNIT_TEST(testIsAndSetCompleted); 12 | CPPUNIT_TEST(testIsAndSetBroken); 13 | CPPUNIT_TEST(testIsAndSetEndOfFile); 14 | CPPUNIT_TEST(testGetAndSetPacket); 15 | CPPUNIT_TEST(testStealPacket); 16 | CPPUNIT_TEST(reset); 17 | CPPUNIT_TEST(testDestructor); 18 | CPPUNIT_TEST(testSetGetErrorNo); 19 | CPPUNIT_TEST(testSetGetErrorString); 20 | CPPUNIT_TEST_SUITE_END(); 21 | public: 22 | void setUp(); 23 | void tearDown(); 24 | void testIsAndSetCompleted(); 25 | void testIsAndSetBroken(); 26 | void testIsAndSetEndOfFile(); 27 | void testGetAndSetPacket(); 28 | void testStealPacket(); 29 | void reset(); 30 | void testDestructor(); 31 | void testSetGetErrorNo(); 32 | void testSetGetErrorString(); 33 | StreamingContext *_context; 34 | }; 35 | 36 | }/*end namespace anet*/ 37 | #endif/* ANET_STREAMINGCONTEXTTF_H_*/ 38 | -------------------------------------------------------------------------------- /anet/test/synchronoustf.h: -------------------------------------------------------------------------------- 1 | #ifndef SYNCHRONOUSTF_H_ 2 | #define SYNCHRONOUSTF_H_ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | namespace anet { 9 | 10 | class SynchronousTestingServer; 11 | class SynchronousTF : public CppUnit::TestFixture { 12 | 13 | CPPUNIT_TEST_SUITE(SynchronousTF); 14 | CPPUNIT_TEST(testSynchronous); 15 | CPPUNIT_TEST(testSynchronousTimeOut); 16 | CPPUNIT_TEST(testSynchronousClosedByPeer); 17 | CPPUNIT_TEST(testSynchronousClosed); 18 | CPPUNIT_TEST_SUITE_END(); 19 | 20 | public: 21 | SynchronousTF(); 22 | ~SynchronousTF(); 23 | void setUp(); 24 | void tearDown(); 25 | void testSynchronous(); 26 | void testSynchronousTimeOut(); 27 | void testSynchronousClosedByPeer(); 28 | void testSynchronousClosed(); 29 | private: 30 | Transport *_transport; 31 | DefaultPacketFactory _factory; 32 | DefaultPacketStreamer *_streamer; 33 | SynchronousTestingServer *_server; 34 | std::string _spec; 35 | IOComponent *_listener; 36 | Connection *_connection; 37 | DefaultPacket *_packet; 38 | ControlPacket *_cmd; 39 | }; 40 | } 41 | 42 | 43 | #endif /*SYNCHRONOUSTF_H*/ 44 | -------------------------------------------------------------------------------- /anet/test/tcpcomponenttf.h: -------------------------------------------------------------------------------- 1 | /** 2 | * p$Id: tcpcomponenttf.h 15689 2008-12-26 13:27:52Z zhangli $ 3 | */ 4 | 5 | #ifndef TCPCOMPONENTTF_H_ 6 | #define TCPCOMPONENTTF_H_ 7 | #include 8 | #include 9 | #include 10 | 11 | namespace anet { 12 | class TCPCOMPONENTTF : public CppUnit::TestFixture { 13 | CPPUNIT_TEST_SUITE(TCPCOMPONENTTF); 14 | CPPUNIT_TEST(testSocketConnectAndClose); 15 | CPPUNIT_TEST(testHandleWriteEvent); 16 | CPPUNIT_TEST(testHandleWriteEventReconnect); 17 | CPPUNIT_TEST(testHandleReadEvent); 18 | CPPUNIT_TEST(testHandleErrorEventConnecting); 19 | CPPUNIT_TEST(testHandleErrorEventConnected); 20 | CPPUNIT_TEST(testInit); 21 | CPPUNIT_TEST(testCreateConnection); 22 | CPPUNIT_TEST(testCheckTimeout); 23 | CPPUNIT_TEST(testIdleTime); 24 | CPPUNIT_TEST(testCloseSocketNoLock); 25 | CPPUNIT_TEST_SUITE_END(); 26 | 27 | public: 28 | TCPCOMPONENTTF(); 29 | ~TCPCOMPONENTTF(); 30 | void setUp(); 31 | void tearDown(); 32 | void testSocketConnectAndClose(); 33 | void testHandleWriteEvent(); 34 | void testHandleWriteEventReconnect(); 35 | void testHandleReadEvent(); 36 | void testHandleErrorEventConnecting(); 37 | void testHandleErrorEventConnected(); 38 | void testInit(); 39 | void testCreateConnection(); 40 | void testCheckTimeout(); 41 | void testIdleTime(); 42 | void testCloseSocketNoLock(); 43 | int getListCountFromHead(IOComponent *); 44 | private: 45 | DefaultPacketStreamer *_streamer; 46 | DefaultPacketFactory *_factory; 47 | }; 48 | } 49 | 50 | #endif /*TCPCOMPONENTTF_H_*/ 51 | -------------------------------------------------------------------------------- /anet/test/tcpconnectiontf.h: -------------------------------------------------------------------------------- 1 | /** 2 | * $Id: tcpconnectiontf.h 15849 2009-01-04 12:09:57Z hua.huangrh $ 3 | */ 4 | 5 | #ifndef TCPCONNECTIONTF_H_ 6 | #define TCPCONNECTIONTF_H_ 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | namespace anet { 13 | class ConnPacketFactory; 14 | class DefaultPacketStreamer; 15 | class DefaultPacketHandler; 16 | 17 | class TCPCONNECTIONTF : public CppUnit::TestFixture { 18 | CPPUNIT_TEST_SUITE(TCPCONNECTIONTF); 19 | CPPUNIT_TEST(testLock); 20 | CPPUNIT_TEST(testWriteData); 21 | CPPUNIT_TEST(testReadData); 22 | CPPUNIT_TEST(testClose); 23 | CPPUNIT_TEST(testMemLeak); 24 | CPPUNIT_TEST(testReadMaliciousDataTooLarge); 25 | CPPUNIT_TEST(testReadMaliciousDataInfinitLoop); 26 | CPPUNIT_TEST_SUITE_END(); 27 | public: 28 | void setUp(); 29 | void tearDown(); 30 | void testWriteData(); 31 | void testReadData(); 32 | void testClose(); 33 | void testLock(); 34 | void testMemLeak(); 35 | void testReadMaliciousDataTooLarge(); 36 | void testReadMaliciousDataInfinitLoop(); 37 | 38 | TCPCONNECTIONTF(); 39 | ~TCPCONNECTIONTF(); 40 | private: 41 | int getListCountFromHead(IOComponent *); 42 | ConnPacketFactory *_factory; 43 | DefaultPacketStreamer *_streamer; 44 | DefaultPacketHandler *_handler; 45 | 46 | Transport *_transport; 47 | ServerSocket *_server; 48 | Socket *_accept; 49 | TCPConnection *_conn; 50 | }; 51 | } 52 | 53 | #endif /*TCPCONNECTIONTF_H_*/ 54 | -------------------------------------------------------------------------------- /anet/test/template.cpp: -------------------------------------------------------------------------------- 1 | #include "template.h" 2 | 3 | namespace anet{ 4 | CPPUNIT_TEST_SUITE_REGISTRATION(TemplateTF); 5 | 6 | void TemplateTF::setUp() { 7 | 8 | } 9 | 10 | void TemplateTF::tearDown() { 11 | 12 | } 13 | 14 | void TemplateTF::testTemplate() { 15 | CPPUNIT_ASSERT(false); 16 | CPPUNIT_ASSERT_EQUAL(0, 1); 17 | } 18 | 19 | }//end namespace anet 20 | -------------------------------------------------------------------------------- /anet/test/template.h: -------------------------------------------------------------------------------- 1 | #ifndef TEMPLATETF_H_ 2 | #define TEMPLATETF_H_ 3 | 4 | #include 5 | #include 6 | 7 | namespace anet { 8 | class TemplateTF : public CppUnit::TestFixture { 9 | 10 | CPPUNIT_TEST_SUITE(TemplateTF); 11 | CPPUNIT_TEST(testTemplate); 12 | CPPUNIT_TEST_SUITE_END(); 13 | 14 | public: 15 | void setUp(); 16 | void tearDown(); 17 | void testTemplate(); 18 | }; 19 | } 20 | 21 | 22 | #endif /*TEMPLATETF_H*/ 23 | -------------------------------------------------------------------------------- /anet/test/transporttf.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imyouxia/Source/624df9ffeb73d9ce918d5f7ef77bae6b9919e30a/anet/test/transporttf.h -------------------------------------------------------------------------------- /anet/util/Makefile.am: -------------------------------------------------------------------------------- 1 | AM_CPPFLAGS=-I$(top_srcdir)/src 2 | LDADD=../src/anet/libanet.la -lpthread 3 | AM_LDFLAGS=-static-libtool-libs 4 | 5 | noinst_PROGRAMS=echoserver echoclient httpserver helloworld_s helloworld_c httpserver_new helloworld_httpd \ 6 | helloworld_wget helloworld_httpd_2 helloworld_s_2 benchmark helloworld_wget_syn \ 7 | helloworld_c_syn echoclient_syn fork_test wait signal_test 8 | 9 | echoserver_SOURCES=echoserver.cpp 10 | echoclient_SOURCES=echoclient.cpp 11 | echoclient_syn_SOURCES=echoclient_syn.cpp 12 | httpserver_SOURCES=httpserver.cpp 13 | httpserver_new_SOURCES=httpserver_new.cpp 14 | 15 | helloworld_s_LDFLAGS= 16 | helloworld_s_SOURCES=helloworld_s.cpp 17 | helloworld_c_LDFLAGS= 18 | helloworld_c_SOURCES=helloworld_c.cpp 19 | 20 | helloworld_httpd_SOURCES=helloworld_httpd.cpp 21 | helloworld_wget_SOURCES=helloworld_wget.cpp 22 | 23 | helloworld_httpd_2_SOURCES=helloworld_httpd_2.cpp 24 | helloworld_s_2_SOURCES=helloworld_s_2.cpp 25 | benchmark_SOURCES=benchmark.cpp 26 | 27 | helloworld_wget_syn_SOURCES=helloworld_wget_syn.cpp 28 | 29 | helloworld_c_syn_LDFLAGS= 30 | helloworld_c_syn_SOURCES=helloworld_c_syn.cpp 31 | 32 | fork_test_SOURCES=fork_test.cpp 33 | wait_SOURCES=wait.cpp 34 | signal_test_SOURCES=signal_test.cpp -------------------------------------------------------------------------------- /anet/util/echoclient.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imyouxia/Source/624df9ffeb73d9ce918d5f7ef77bae6b9919e30a/anet/util/echoclient.cpp -------------------------------------------------------------------------------- /anet/util/echoclient_syn.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imyouxia/Source/624df9ffeb73d9ce918d5f7ef77bae6b9919e30a/anet/util/echoclient_syn.cpp -------------------------------------------------------------------------------- /anet/util/httpserver.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imyouxia/Source/624df9ffeb73d9ce918d5f7ef77bae6b9919e30a/anet/util/httpserver.cpp -------------------------------------------------------------------------------- /anet/util/signal_test.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imyouxia/Source/624df9ffeb73d9ce918d5f7ef77bae6b9919e30a/anet/util/signal_test.cpp -------------------------------------------------------------------------------- /anet/util/wait.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | using namespace std; 8 | int main(int argc, char *argv[]) { 9 | signal(SIGHUP, SIG_IGN); 10 | int seconds = 100; 11 | if (argc > 1) { 12 | seconds = atoi(argv[1]); 13 | } 14 | time_t quit = time(NULL) + seconds; 15 | while(quit > time(NULL)) { 16 | sleep(quit - time(NULL)); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /cJSON/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009 Dave Gamble 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | 21 | -------------------------------------------------------------------------------- /cJSON/README.md: -------------------------------------------------------------------------------- 1 | # cJSON 源码剖析 2 | ## 简介 3 | cJSON是C语言中的一个JSON编解码器,非常轻量级,单文件,代码不到1K行,速度也非常理想。其代码被非常好地维护着,虽然代码较短,但是里面用到的数据结构和算法都是非常值的学习的。 4 | 5 | ## 编译和运行 6 | - 编译:gcc cJSON.c test.c -o test -lm 7 | 8 | - 运行:./test 9 | 10 | 11 | -------------------------------------------------------------------------------- /cJSON/tests/test1: -------------------------------------------------------------------------------- 1 | { 2 | "glossary": { 3 | "title": "example glossary", 4 | "GlossDiv": { 5 | "title": "S", 6 | "GlossList": { 7 | "GlossEntry": { 8 | "ID": "SGML", 9 | "SortAs": "SGML", 10 | "GlossTerm": "Standard Generalized Markup Language", 11 | "Acronym": "SGML", 12 | "Abbrev": "ISO 8879:1986", 13 | "GlossDef": { 14 | "para": "A meta-markup language, used to create markup languages such as DocBook.", 15 | "GlossSeeAlso": ["GML", "XML"] 16 | }, 17 | "GlossSee": "markup" 18 | } 19 | } 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /cJSON/tests/test2: -------------------------------------------------------------------------------- 1 | {"menu": { 2 | "id": "file", 3 | "value": "File", 4 | "popup": { 5 | "menuitem": [ 6 | {"value": "New", "onclick": "CreateNewDoc()"}, 7 | {"value": "Open", "onclick": "OpenDoc()"}, 8 | {"value": "Close", "onclick": "CloseDoc()"} 9 | ] 10 | } 11 | }} 12 | -------------------------------------------------------------------------------- /cJSON/tests/test3: -------------------------------------------------------------------------------- 1 | {"widget": { 2 | "debug": "on", 3 | "window": { 4 | "title": "Sample Konfabulator Widget", 5 | "name": "main_window", 6 | "width": 500, 7 | "height": 500 8 | }, 9 | "image": { 10 | "src": "Images/Sun.png", 11 | "name": "sun1", 12 | "hOffset": 250, 13 | "vOffset": 250, 14 | "alignment": "center" 15 | }, 16 | "text": { 17 | "data": "Click Here", 18 | "size": 36, 19 | "style": "bold", 20 | "name": "text1", 21 | "hOffset": 250, 22 | "vOffset": 100, 23 | "alignment": "center", 24 | "onMouseUp": "sun1.opacity = (sun1.opacity / 100) * 90;" 25 | } 26 | }} -------------------------------------------------------------------------------- /cJSON/tests/test5: -------------------------------------------------------------------------------- 1 | {"menu": { 2 | "header": "SVG Viewer", 3 | "items": [ 4 | {"id": "Open"}, 5 | {"id": "OpenNew", "label": "Open New"}, 6 | null, 7 | {"id": "ZoomIn", "label": "Zoom In"}, 8 | {"id": "ZoomOut", "label": "Zoom Out"}, 9 | {"id": "OriginalView", "label": "Original View"}, 10 | null, 11 | {"id": "Quality"}, 12 | {"id": "Pause"}, 13 | {"id": "Mute"}, 14 | null, 15 | {"id": "Find", "label": "Find..."}, 16 | {"id": "FindAgain", "label": "Find Again"}, 17 | {"id": "Copy"}, 18 | {"id": "CopyAgain", "label": "Copy Again"}, 19 | {"id": "CopySVG", "label": "Copy SVG"}, 20 | {"id": "ViewSVG", "label": "View SVG"}, 21 | {"id": "ViewSource", "label": "View Source"}, 22 | {"id": "SaveAs", "label": "Save As"}, 23 | null, 24 | {"id": "Help"}, 25 | {"id": "About", "label": "About Adobe CVG Viewer..."} 26 | ] 27 | }} 28 | -------------------------------------------------------------------------------- /jwSMTP/README.md: -------------------------------------------------------------------------------- 1 | ## 简介 2 | jwSMTP是一个由C++编写的邮件发送库,支持Linux、Windows等平台。可使用HTML或纯文本方式发送邮件, 也可添加附件,支持多个收件人,并且支持LOGIN和PLAIN两种服务器验证方式,此代码可以帮助简单理解SMTP协议和DNS协议。 3 | 4 | ## 分析 5 | 博客里对原理做了一些说明,见此:[http://armsword.com/2015/01/26/jwsmtp-analyse/](http://armsword.com/2015/01/26/jwsmtp-analyse/) 6 | 7 | 8 | -------------------------------------------------------------------------------- /jwSMTP/jwsmtp/.deps/base64.Plo: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /jwSMTP/jwsmtp/.deps/compat.Plo: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /jwSMTP/jwsmtp/.deps/mailer.Plo: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /jwSMTP/jwsmtp/jwsmtp.h: -------------------------------------------------------------------------------- 1 | // Note that the only valid version of the GPL as far as jwSMTP 2 | // is concerned is v2 of the license (ie v2, not v2.2 or v3.x or whatever), 3 | // unless explicitly otherwise stated. 4 | // 5 | // This file is part of the jwSMTP library. 6 | // 7 | // jwSMTP library is free software; you can redistribute it and/or modify 8 | // it under the terms of the GNU General Public License as published by 9 | // the Free Software Foundation; version 2 of the License. 10 | // 11 | // jwSMTP library is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with jwSMTP library; if not, write to the Free Software 18 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | // 20 | // jwSMTP library 21 | // http://johnwiggins.net 22 | // smtplib@johnwiggins.net 23 | // 24 | 25 | #ifndef __JWSMTP_H__ 26 | #define __JWSMTP_H__ 27 | 28 | #include "mailer.h" 29 | #include "compat.h" 30 | #include "base64.h" 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /larbin-2.6.3/CREDITS: -------------------------------------------------------------------------------- 1 | This is credits-file of people that have contributed to larbin. It is 2 | sorted by name and formatted to allow easy grepping and beautification 3 | by scripts. The fields are: name (N), email (E), web-address (W), 4 | description (D), and snail-mail address (S). 5 | 6 | Thanks, 7 | 8 | Sebastien 9 | ---------- 10 | 11 | N: Sebastien Ailleret 12 | E: sebastien@ailleret.com 13 | W: http://www.ailleret.com/ 14 | D: Main developper 15 | S: France 16 | 17 | N: Craig Baker 18 | E: cdb@cdbsystems.com 19 | D: Bug report and ideas 20 | 21 | N: Osman Burchan Bayazit 22 | E: burchanb@cs.tamu.edu 23 | D: Bug report with patch 24 | 25 | N: Tim Fitz 26 | E: fitzboy@iparadigms.com 27 | D: clean up patch 28 | 29 | N: Otis Gospodnetic 30 | E: otisgospodnetic@britannica.com 31 | D: Bug report, feed back and ideas 32 | 33 | N: Niels Provos 34 | E: provos@citi.umich.edu 35 | D: Bug report with patch concerning configuration file parsing 36 | 37 | N: Hsiao Ruey-Lung 38 | E: b2506023@csie.ntu.edu.tw 39 | D: Bug report with patch concerning frame management 40 | 41 | N: Christian Storm 42 | E: storm@iparadigms.com 43 | D: various patches and comments 44 | 45 | N: Laurent Viennot 46 | E: laurent.viennot@inria.fr 47 | D: patch for better tolerance to buggy html, histograms 48 | S: INRIA Rocquencourt 49 | S: France 50 | 51 | N: Ira Joseph Woodhead 52 | E: ira@av.com 53 | D: patches and comments 54 | -------------------------------------------------------------------------------- /larbin-2.6.3/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY : all crash clean distclean 2 | 3 | BASEDIR=src 4 | include src/larbin.make 5 | 6 | dep: 7 | (cd src; $(MAKE) dep) 8 | 9 | all debug prof: 10 | (cd adns; $(MAKE)) 11 | (cd src; $(MAKE) $@) 12 | cp src/larbin . 13 | 14 | clean: cleanhere 15 | (cd src; $(MAKE) clean) 16 | (cd adns; $(MAKE) clean) 17 | 18 | distclean: cleanhere 19 | (cd src; $(MAKE) distclean) 20 | (cd adns; $(MAKE) distclean) 21 | $(RM) config.h config.make .depend 22 | $(RM) larbin 23 | 24 | cleanhere: 25 | $(RM) *~ doc/*~ 26 | $(RM) core gmon.out 27 | $(RM) fifo* 28 | $(RM) hashtable.* dupfile.* 29 | -------------------------------------------------------------------------------- /larbin-2.6.3/README: -------------------------------------------------------------------------------- 1 | ****************************************************************** 2 | Larbin web crawler by Sebastien Ailleret 3 | ****************************************************************** 4 | 5 | ****************** 6 | Table of content : 7 | 8 | - Compiling 9 | - Configuring 10 | - Running 11 | - Supported platforms 12 | - Contact 13 | 14 | *********** 15 | Compiling : 16 | 17 | have a look at options.h to choose options you need 18 | ./configure 19 | gmake 20 | 21 | ************* 22 | Configuring : 23 | 24 | see larbin.conf. Please be sure to specify your mail 25 | 26 | There is also some documentation in the doc directory in html format 27 | 28 | ********* 29 | Running : 30 | 31 | Be sure you did the configuration 32 | 33 | ./larbin 34 | 35 | to see how it works, http://localhost:8081/ 36 | 37 | ********************* 38 | Supported platforms : 39 | 40 | Larbin has mainly been developped under Linux 41 | I've tested larbin with success on Linux and freeBSD. 42 | 43 | It probably won't compile right out of the box on any other platform, 44 | but i'll work on it for future versions. Please report success or 45 | failure on any platform. 46 | 47 | ********* 48 | Contact : 49 | 50 | mailto:sebastien@ailleret.com 51 | http://www.ailleret.com/ 52 | -------------------------------------------------------------------------------- /larbin-2.6.3/adns/Makefile: -------------------------------------------------------------------------------- 1 | BASEDIR=../src 2 | include ../src/larbin.make 3 | 4 | TARGETS=libadns.a 5 | 6 | LIBOBJS=types.o event.o query.o reply.o general.o setup.o transmit.o \ 7 | parse.o poll.o check.o 8 | 9 | all: libadns.a 10 | 11 | libadns.a: $(LIBOBJS) 12 | rm -f $@ 13 | $(AR) cq $@ $(LIBOBJS) 14 | 15 | clean: 16 | rm -f $(LIBOBJS) libadns.a *~ config.status 17 | 18 | distclean: clean 19 | rm -f config.h .depend 20 | 21 | $(LIBOBJS): adns.h internal.h config.h 22 | -------------------------------------------------------------------------------- /larbin-2.6.3/adns/tvarith.h: -------------------------------------------------------------------------------- 1 | /* 2 | * tvarith.h 3 | * - static inline functions for doing arithmetic on timevals 4 | */ 5 | /* 6 | * This file is 7 | * Copyright (C) 1997-1999 Ian Jackson 8 | * 9 | * It is part of adns, which is 10 | * Copyright (C) 1997-2000 Ian Jackson 11 | * Copyright (C) 1999-2000 Tony Finch 12 | * 13 | * This program is free software; you can redistribute it and/or modify 14 | * it under the terms of the GNU General Public License as published by 15 | * the Free Software Foundation; either version 2, or (at your option) 16 | * any later version. 17 | * 18 | * This program is distributed in the hope that it will be useful, 19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 | * GNU General Public License for more details. 22 | * 23 | * You should have received a copy of the GNU General Public License 24 | * along with this program; if not, write to the Free Software Foundation, 25 | * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 26 | */ 27 | 28 | #ifndef ADNS_TVARITH_H_INCLUDED 29 | #define ADNS_TVARITH_H_INCLUDED 30 | 31 | static inline void timevaladd(struct timeval *tv_io, long ms) { 32 | struct timeval tmp; 33 | assert(ms>=0); 34 | tmp= *tv_io; 35 | tmp.tv_usec += (ms%1000)*1000; 36 | tmp.tv_sec += ms/1000; 37 | if (tmp.tv_usec >= 1000000) { tmp.tv_sec++; tmp.tv_usec -= 1000000; } 38 | *tv_io= tmp; 39 | } 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /larbin-2.6.3/configure: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # configure adns 4 | (cd adns; ./configure) 5 | 6 | #configure larbin itself 7 | cat /dev/null > config.h 8 | cat /dev/null > config.make 9 | 10 | if [ -e /proc/self/status ]; then 11 | echo "#define HAS_PROC_SELF_STATUS" >> config.h 12 | fi 13 | 14 | # find existing programs 15 | function exists () { 16 | command -v $1 2> /dev/null > /dev/null; 17 | } 18 | 19 | if exists gmake; then 20 | echo "MAKE=gmake" >> config.make 21 | export MAKE=gmake 22 | else 23 | echo "MAKE=make" >> config.make 24 | export MAKE=make 25 | fi 26 | 27 | if exists gcc; then 28 | echo "CC=gcc" >> config.make 29 | export CC=gcc 30 | fi 31 | 32 | if exists g++; then 33 | echo "CXX=g++" >> config.make 34 | fi 35 | 36 | #find libraries to use 37 | echo "int main () { return 0; }" > test.c 38 | 39 | function testlib () { 40 | if $CC $1 -o test test.c 2> /dev/null > /dev/null; then 41 | echo "LIBS +=" $1 >> config.make 42 | fi 43 | } 44 | 45 | testlib -pthread 46 | testlib -lpthread 47 | testlib -lresolv 48 | testlib -lsocket 49 | testlib -lnsl 50 | 51 | rm -f test test.c test.o 52 | 53 | # run make dep 54 | touch .depend 55 | touch adns/.depend 56 | touch src/.depend 57 | touch src/fetch/.depend 58 | touch src/interf/.depend 59 | touch src/utils/.depend 60 | $MAKE dep 61 | -------------------------------------------------------------------------------- /larbin-2.6.3/doc/index-eng.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imyouxia/Source/624df9ffeb73d9ce918d5f7ef77bae6b9919e30a/larbin-2.6.3/doc/index-eng.html -------------------------------------------------------------------------------- /larbin-2.6.3/doc/index.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imyouxia/Source/624df9ffeb73d9ce918d5f7ef77bae6b9919e30a/larbin-2.6.3/doc/index.html -------------------------------------------------------------------------------- /larbin-2.6.3/doc/l-en.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imyouxia/Source/624df9ffeb73d9ce918d5f7ef77bae6b9919e30a/larbin-2.6.3/doc/l-en.jpg -------------------------------------------------------------------------------- /larbin-2.6.3/doc/l-fr.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imyouxia/Source/624df9ffeb73d9ce918d5f7ef77bae6b9919e30a/larbin-2.6.3/doc/l-fr.jpg -------------------------------------------------------------------------------- /larbin-2.6.3/larbin.conf: -------------------------------------------------------------------------------- 1 | ############################################### 2 | # Who are you ? 3 | # mail of the one who launched larbin (YOUR mail) 4 | From larbin2.6.3@unspecified.mail 5 | # name of the bot (sent with http headers) 6 | UserAgent larbin_2.6.3 7 | 8 | ############################################ 9 | # What are the inputs and ouputs of larbin 10 | # port on which is launched the http statistic webserver 11 | # if unset or set to 0, no webserver is launched 12 | httpPort 8081 13 | # port on which you can submit urls to fetch 14 | # no input is possible if you comment this line or use port 0 15 | #inputPort 1976 16 | 17 | ############################################ 18 | # parameters to adapt depending on your network 19 | # Number of connexions in parallel (to adapt depending of your network speed) 20 | pagesConnexions 100 21 | # Number of dns calls in parallel 22 | dnsConnexions 5 23 | # How deep do you want to go in a site 24 | depthInSite 5 25 | # do you want to follow external links 26 | #noExternalLinks 27 | # time between 2 calls on the same server (in sec) : NEVER less than 30 28 | waitDuration 60 29 | # Make requests through a proxy (use with care) 30 | #proxy www 8080 31 | 32 | ############################################## 33 | # now, let's customize the search 34 | 35 | # first page to fetch (you can specify several urls) 36 | startUrl http://slashdot.org/ 37 | 38 | # Do you want to limit your search to a specific domain ? 39 | # if yes, uncomment the following line 40 | #limitToDomain .fr .dk .uk end 41 | 42 | # What are the extensions you surely don't want 43 | # never forbid .html, .htm and so on : larbin needs them 44 | forbiddenExtensions 45 | .tar .gz .tgz .zip .Z .rpm .deb 46 | .ps .dvi .pdf 47 | .png .jpg .jpeg .bmp .smi .tiff .gif 48 | .mov .avi .mpeg .mpg .mp3 .qt .wav .ram .rm 49 | .jar .java .class .diff 50 | .doc .xls .ppt .mdb .rtf .exe .pps .so .psd 51 | end 52 | -------------------------------------------------------------------------------- /larbin-2.6.3/src/Makefile: -------------------------------------------------------------------------------- 1 | BASEDIR:=. 2 | 3 | include larbin.make 4 | 5 | MF:= 6 | 7 | SUBDIR=utils interf fetch 8 | 9 | all: config.h options.h subdirs-all larbin 10 | 11 | subdirs-all: 12 | for d in $(SUBDIR); do (cd $$d; $(MAKE) all); done 13 | 14 | clean distclean dep prof debug: options.h config.h 15 | for d in $(SUBDIR); do (cd $$d; $(MAKE) $@-in); done 16 | $(MAKE) $@-here 17 | 18 | larbin: $(ABS-UTILS-OBJ) $(ABS-FETCH-OBJ) $(ABS-INTERF-OBJ) $(ABS-MAIN-OBJ) 19 | $(CXX) $(MF) $(LIBS) -o larbin $(ABS-UTILS-OBJ) \ 20 | $(ABS-FETCH-OBJ) $(ABS-INTERF-OBJ) $(ABS-MAIN-OBJ) ../adns/libadns.a 21 | 22 | dep-here: 23 | makedepend -f- -I$(BASEDIR) -Y *.cc 2> /dev/null > .depend 24 | 25 | redo-here: larbin 26 | 27 | debug-here: CXXFLAGS += -g 28 | debug-here: MF += -g 29 | debug-here: redo-here 30 | 31 | prof-here: CXXFLAGS += -pg -DPROF 32 | prof-here: MF += -pg 33 | prof-here: redo-here 34 | 35 | clean-here: 36 | $(RM) *~ *.o 37 | $(RM) *.bak 38 | $(RM) larbin 39 | 40 | distclean-here: clean-here 41 | $(RM) options.h config.h .depend 42 | 43 | options.h: ../options.h 44 | cp ../options.h . 45 | 46 | config.h: ../config.h 47 | cp ../config.h . 48 | -------------------------------------------------------------------------------- /larbin-2.6.3/src/fetch/Makefile: -------------------------------------------------------------------------------- 1 | BASEDIR=.. 2 | 3 | include ../larbin.make 4 | 5 | all: $(FETCH-OBJ) 6 | -------------------------------------------------------------------------------- /larbin-2.6.3/src/fetch/checker.h: -------------------------------------------------------------------------------- 1 | // Larbin 2 | // Sebastien Ailleret 3 | // 15-11-99 -> 13-04-00 4 | 5 | #ifndef CHECKER_H 6 | #define CHECKER_H 7 | 8 | #include "types.h" 9 | #include "utils/Vector.h" 10 | 11 | /** check if an url is allready known 12 | * if not send it 13 | * @param u the url to check 14 | */ 15 | void check (url *u); 16 | 17 | /** Check the extension of an url 18 | * @return true if it might be interesting, false otherwise 19 | */ 20 | bool filter1 (char *host, char *file); 21 | 22 | #endif // CHECKER_H 23 | -------------------------------------------------------------------------------- /larbin-2.6.3/src/fetch/defaultspecbuf.cc: -------------------------------------------------------------------------------- 1 | // Larbin 2 | // Sebastien Ailleret 3 | // 09-12-01 -> 09-12-01 4 | 5 | void initSpecific () { } 6 | 7 | #define constrSpec() ((void) 0) 8 | #define newSpec() ((void) 0) 9 | #define pipeSpec() 0 10 | #define endOfInput() 0 11 | #define getContent() contentStart 12 | #define getSize() (buffer + pos - contentStart) 13 | #define destructSpec() ((void) 0) 14 | -------------------------------------------------------------------------------- /larbin-2.6.3/src/fetch/dynamicspecbuf.cc: -------------------------------------------------------------------------------- 1 | // Larbin 2 | // Sebastien Ailleret 3 | // 10-12-01 -> 10-12-01 4 | 5 | // use dynamic buffers when downloading specific pages 6 | 7 | void initSpecific () { } 8 | 9 | #define newSpec() ((void) 0) 10 | #define endOfInput() 0 11 | 12 | bool html::pipeSpec () { 13 | if (dynbuf == NULL) { 14 | if (pos > nearlyFullPage) { 15 | // need a dyn buf (big file) 16 | szDyn = 2*maxPageSize; 17 | dynbuf = new char[szDyn]; 18 | nbSpec = buffer + pos - posParse; 19 | memcpy(dynbuf, posParse, nbSpec); 20 | dynbuf[nbSpec] = 0; 21 | pos = posParse - buffer; 22 | } 23 | return false; 24 | } else { 25 | int nb = buffer + pos - posParse; 26 | int newnb = nbSpec + nb; 27 | if (newnb >= maxSpecSize) { 28 | errno = tooBig; 29 | return true; 30 | } 31 | if (newnb >= szDyn) { 32 | // resize buffer 33 | szDyn *= 2; 34 | char *tmp = new char[szDyn]; 35 | memcpy(tmp, dynbuf, nbSpec); 36 | delete[] dynbuf; 37 | dynbuf = tmp; 38 | } 39 | memcpy(dynbuf+nbSpec, posParse, nb); 40 | nbSpec = newnb; 41 | dynbuf[nbSpec] = 0; 42 | pos = posParse - buffer; 43 | return false; 44 | } 45 | } 46 | 47 | char * html::getContent() { 48 | if (dynbuf != NULL) 49 | return dynbuf; 50 | else 51 | return contentStart; 52 | } 53 | 54 | int html::getSize() { 55 | if (dynbuf != NULL) { 56 | return nbSpec; 57 | } else { 58 | return (buffer + pos - contentStart); 59 | } 60 | } 61 | 62 | #define constrSpec() dynbuf = NULL 63 | 64 | #define destructSpec() if (dynbuf != NULL) { delete[] dynbuf; } 65 | -------------------------------------------------------------------------------- /larbin-2.6.3/src/fetch/dynamicspecbuf.h: -------------------------------------------------------------------------------- 1 | // Larbin 2 | // Sebastien Ailleret 3 | // 10-12-01 -> 10-12-01 4 | 5 | // this file is included in the definition of class html (file.h) 6 | 7 | /* number of bits written */ 8 | int nbSpec; 9 | /* feed file descriptor, 10 | * return true and set errno = tooBig if necessary */ 11 | bool pipeSpec (); 12 | /* the dynamic buffer in which everything is saved */ 13 | char *dynbuf; 14 | int szDyn; 15 | /** get the content of the page */ 16 | char *getContent (); 17 | int getSize(); 18 | -------------------------------------------------------------------------------- /larbin-2.6.3/src/fetch/fetchOpen.cc: -------------------------------------------------------------------------------- 1 | // Larbin 2 | // Sebastien Ailleret 3 | // 15-11-99 -> 04-12-01 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | #include 10 | 11 | #include "options.h" 12 | 13 | #include "global.h" 14 | #include "utils/Fifo.h" 15 | #include "utils/debug.h" 16 | #include "fetch/site.h" 17 | 18 | /* Opens sockets 19 | * Never block (only opens sockets on already known sites) 20 | * work inside the main thread 21 | */ 22 | void fetchOpen () { 23 | static time_t next_call = 0; 24 | if (global::now < next_call) { // too early to come back 25 | return; 26 | } 27 | int cont = 1; 28 | while (cont && global::freeConns->isNonEmpty()) { 29 | IPSite *s = global::okSites->tryGet(); 30 | if (s == NULL) { 31 | cont = 0; 32 | } else { 33 | next_call = s->fetch(); 34 | cont = (next_call == 0); 35 | } 36 | } 37 | } 38 | 39 | /* Opens sockets 40 | * this function perform dns calls, using adns 41 | */ 42 | void fetchDns () { 43 | // Submit queries 44 | while (global::nbDnsCallsisNonEmpty() 46 | && global::IPUrl < maxIPUrls) { // try to avoid too many dns calls 47 | NamedSite *site = global::dnsSites->tryGet(); 48 | if (site == NULL) { 49 | break; 50 | } else { 51 | site->newQuery(); 52 | } 53 | } 54 | 55 | // Read available answers 56 | while (global::nbDnsCalls && global::freeConns->isNonEmpty()) { 57 | NamedSite *site; 58 | adns_query quer = NULL; 59 | adns_answer *ans; 60 | int res = adns_check(global::ads, &quer, &ans, (void**)&site); 61 | if (res == ESRCH || res == EAGAIN) { 62 | // No more query or no more answers 63 | break; 64 | } 65 | global::nbDnsCalls--; 66 | site->dnsAns(ans); 67 | free(ans); // ans has been allocated with malloc 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /larbin-2.6.3/src/fetch/fetchOpen.h: -------------------------------------------------------------------------------- 1 | // Larbin 2 | // Sebastien Ailleret 3 | // 15-11-99 -> 12-12-01 4 | 5 | #ifndef FETCHOPEN_H 6 | #define FETCHOPEN_H 7 | 8 | /* Opens sockets 9 | * this function perform dns calls, using adns 10 | */ 11 | void fetchDns (); 12 | 13 | /* Opens sockets 14 | * Never block (only opens sockets on allready known sites) 15 | * work inside the main thread 16 | */ 17 | void fetchOpen (); 18 | 19 | #endif // FETCHOPEN_H 20 | -------------------------------------------------------------------------------- /larbin-2.6.3/src/fetch/fetchPipe.h: -------------------------------------------------------------------------------- 1 | // Larbin 2 | // Sebastien Ailleret 3 | // 15-11-99 -> 22-07-01 4 | 5 | #ifndef FETCHPIPE_H 6 | #define FETCHPIPE_H 7 | 8 | void checkTimeout (); 9 | 10 | void checkAll (); 11 | 12 | #endif // FETCH_H 13 | -------------------------------------------------------------------------------- /larbin-2.6.3/src/fetch/hashTable.h: -------------------------------------------------------------------------------- 1 | // Larbin 2 | // Sebastien Ailleret 3 | // 23-11-99 -> 14-01-00 4 | 5 | /* class hashTable 6 | * This class is in charge of making sure we don't crawl twice the same url 7 | */ 8 | 9 | #ifndef HASHTABLE_H 10 | #define HASHTABLE_H 11 | 12 | #include "types.h" 13 | #include "utils/url.h" 14 | 15 | class hashTable { 16 | private: 17 | ssize_t size; 18 | char *table; 19 | 20 | public: 21 | /* constructor */ 22 | hashTable (bool create); 23 | 24 | /* destructor */ 25 | ~hashTable (); 26 | 27 | /* save the hashTable in a file */ 28 | void save(); 29 | 30 | /* test if this url is allready in the hashtable 31 | * return true if it has been added 32 | * return false if it has allready been seen 33 | */ 34 | bool test (url *U); 35 | 36 | /* set a url as present in the hashtable 37 | */ 38 | void set (url *U); 39 | 40 | /* add a new url in the hashtable 41 | * return true if it has been added 42 | * return false if it has allready been seen 43 | */ 44 | bool testSet (url *U); 45 | }; 46 | 47 | #endif // HASHTABLE_H 48 | -------------------------------------------------------------------------------- /larbin-2.6.3/src/fetch/savespecbuf.h: -------------------------------------------------------------------------------- 1 | // Larbin 2 | // Sebastien Ailleret 3 | // 09-12-01 -> 09-12-01 4 | 5 | // this file is included in the definition of class html (file.h) 6 | 7 | /** file descriptor number */ 8 | int fdsSpec; 9 | /** number of bits written */ 10 | int nbSpec; 11 | /** open file descriptor */ 12 | void newSpec (); 13 | /** feed file descriptor, 14 | * return true and set errno = tooBig if necessary */ 15 | bool pipeSpec (); 16 | /** get the content of the page */ 17 | char *getContent (); 18 | /** number of file and directory when saved on disk */ 19 | int mydir; 20 | int myfile; 21 | -------------------------------------------------------------------------------- /larbin-2.6.3/src/fetch/sequencer.h: -------------------------------------------------------------------------------- 1 | // Larbin 2 | // Sebastien Ailleret 3 | // 15-11-99 -> 15-11-99 4 | 5 | #ifndef SEQUENCER_H 6 | #define SEQUENCER_H 7 | 8 | /** only for debugging, handle with care */ 9 | extern uint space; 10 | 11 | /** Call the sequencer */ 12 | void sequencer (); 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /larbin-2.6.3/src/fetch/specbuf.cc: -------------------------------------------------------------------------------- 1 | // Larbin 2 | // Sebastien Ailleret 3 | // 09-12-01 -> 10-12-01 4 | 5 | /* this module defines how specific pages are handled 6 | * the following functions must be defined : 7 | * - initSpecific : this function is called when larbin is launched. This 8 | * must be a function because it is defined in file.h. 9 | * - constrSpec : this function is called in the constructor of class html 10 | * - newSpec : a new specific page has been discovered 11 | * - pipeSpec : some data has arrived on the stream 12 | * - endInput : the end of the input : be careful, this function 13 | * might not be called in case of timeout or other reasons 14 | * - getPage : someone needs the content of the page 15 | * - getSize : gives the size of the document 16 | * - destructSpec : this function is called in the destructor of class html 17 | * 18 | * All this function are only called if SPECIFICSEARCH is defined 19 | * constrSpec is called for every page 20 | * other functions are only called if state==SPECIFIC 21 | */ 22 | 23 | #ifdef SAVE_SPECIFIC 24 | #include "fetch/savespecbuf.cc" 25 | 26 | #elif defined(DYNAMIC_SPECIFIC) 27 | #include "fetch/dynamicspecbuf.cc" 28 | 29 | #else // DEFAULT_SPECIFIC 30 | #include "fetch/defaultspecbuf.cc" 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /larbin-2.6.3/src/fetch/specbuf.h: -------------------------------------------------------------------------------- 1 | // Larbin 2 | // Sebastien Ailleret 3 | // 09-12-01 -> 09-12-01 4 | 5 | /* This is a really bad hack, but i have not found a better way 6 | * for doing this... 7 | * 8 | * This file is included in the definition of class html 9 | * You can put inside definitions you need for specificBuf 10 | */ 11 | 12 | 13 | #ifdef SAVE_SPECIFIC 14 | #include "fetch/savespecbuf.h" 15 | 16 | #elif defined(DYNAMIC_SPECIFIC) 17 | #include "fetch/dynamicspecbuf.h" 18 | 19 | #else // DEFAULT_SPECIFIC 20 | // nothing special 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /larbin-2.6.3/src/interf/Makefile: -------------------------------------------------------------------------------- 1 | BASEDIR=.. 2 | 3 | include ../larbin.make 4 | 5 | all: $(INTERF-OBJ) 6 | -------------------------------------------------------------------------------- /larbin-2.6.3/src/interf/defaultuseroutput.cc: -------------------------------------------------------------------------------- 1 | // Larbin 2 | // Sebastien Ailleret 3 | // 07-12-01 -> 07-12-01 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | #include "options.h" 10 | 11 | #include "types.h" 12 | #include "global.h" 13 | #include "fetch/file.h" 14 | #include "utils/text.h" 15 | #include "utils/debug.h" 16 | #include "interf/output.h" 17 | 18 | /** A page has been loaded successfully 19 | * @param page the page that has been fetched 20 | */ 21 | void loaded (html *page) { 22 | // Here should be the code for managing everything 23 | // page->getHeaders() gives a char* containing the http headers 24 | // page->getPage() gives a char* containing the page itself 25 | // those char* are statically allocated, so you should copy 26 | // them if you want to keep them 27 | // in order to accept \000 in the page, you can use page->getLength() 28 | #ifdef BIGSTATS 29 | cout << "fetched : "; 30 | page->getUrl()->print(); 31 | // cout << page->getHeaders() << "\n" << page->getPage() << "\n"; 32 | #endif // BIGSTATS 33 | } 34 | 35 | /** The fetch failed 36 | * @param u the URL of the doc 37 | * @param reason reason of the fail 38 | */ 39 | void failure (url *u, FetchError reason) { 40 | // Here should be the code for managing everything 41 | #ifdef BIGSTATS 42 | cout << "fetched failed (" << (int) reason << ") : "; 43 | u->print(); 44 | #endif // BIGSTATS 45 | } 46 | 47 | /** initialisation function 48 | */ 49 | void initUserOutput () { 50 | 51 | } 52 | 53 | /** stats, called in particular by the webserver 54 | * the webserver is in another thread, so be careful 55 | * However, if it only reads things, it is probably not useful 56 | * to use mutex, because incoherence in the webserver is not as critical 57 | * as efficiency 58 | */ 59 | void outputStats(int fds) { 60 | ecrire(fds, "Nothing to declare"); 61 | } 62 | -------------------------------------------------------------------------------- /larbin-2.6.3/src/interf/input.h: -------------------------------------------------------------------------------- 1 | // Larbin 2 | // Sebastien Ailleret 3 | // 03-02-00 -> 22-07-01 4 | 5 | #ifndef INPUT_H 6 | #define INPUT_H 7 | 8 | #include "global.h" 9 | 10 | /** see if there is some input and manage it */ 11 | int input (); 12 | 13 | /** init everything */ 14 | void initInput (); 15 | 16 | #endif // INPUT_H 17 | -------------------------------------------------------------------------------- /larbin-2.6.3/src/interf/output.h: -------------------------------------------------------------------------------- 1 | // Larbin 2 | // Sebastien Ailleret 3 | // 03-02-00 -> 20-11-01 4 | 5 | #ifndef OUTPUT_H 6 | #define OUTPUT_H 7 | 8 | #include "global.h" 9 | 10 | /** The fetch failed 11 | * @param u the URL of the doc 12 | * @param reason reason of the fail 13 | */ 14 | void fetchFail (url *u, FetchError reason, bool interesting=false); 15 | 16 | /** It's over with this file 17 | * report the situation ! (and make some stats) 18 | */ 19 | void endOfLoad (html *parser, FetchError err); 20 | 21 | /** Initialise output */ 22 | void initOutput (); 23 | 24 | #endif // OUTPUT_H 25 | -------------------------------------------------------------------------------- /larbin-2.6.3/src/interf/useroutput.cc: -------------------------------------------------------------------------------- 1 | // Larbin 2 | // Sebastien Ailleret 3 | // 07-12-01 -> 10-12-01 4 | 5 | /* This is the file you should change if you want to 6 | * use the data fetched by larbin. 7 | * 8 | * See useroutput.h for the interface 9 | * 10 | * See the files XXXuserouput.cc for examples */ 11 | 12 | #include "options.h" 13 | 14 | #ifdef SIMPLE_SAVE 15 | #include "interf/saveuseroutput.cc" 16 | 17 | #elif defined(MIRROR_SAVE) 18 | #include "interf/mirrorsaveuseroutput.cc" 19 | 20 | #elif defined(STATS_OUTPUT) 21 | #include "interf/statsuseroutput.cc" 22 | 23 | #else // DEFAULT_OUTPUT 24 | #include "interf/defaultuseroutput.cc" 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /larbin-2.6.3/src/interf/useroutput.h: -------------------------------------------------------------------------------- 1 | // Larbin 2 | // Sebastien Ailleret 3 | // 07-12-01 -> 03-01-02 4 | 5 | #ifndef USEROUTPUT_H 6 | #define USEROUTPUT_H 7 | 8 | #include "utils/url.h" 9 | #include "fetch/file.h" 10 | 11 | /** A page has been loaded successfully 12 | * @param page the page that has been fetched 13 | */ 14 | void loaded (html *page); 15 | // This function should manage anything 16 | // page->getHeaders() gives a char* containing the http headers 17 | // page->getPage() gives a char* containing the page itself 18 | // those char* are statically allocated, so you should copy 19 | // them if you want to keep them 20 | // in order to accept \000 in the page, you can use page->getLength() 21 | 22 | /** The fetch failed 23 | * @param u the URL of the doc 24 | * @param reason reason of the fail 25 | */ 26 | void failure (url *u, FetchError reason); 27 | 28 | /** initialisation function 29 | * This function is called at the end of global initialisation 30 | */ 31 | void initUserOutput (); 32 | 33 | /** stats, called in particular by the webserver 34 | * the webserver is in another thread, so be careful 35 | * However, if it only reads things, it is probably not useful 36 | * to use mutex, because incoherence in the webserver is not as critical 37 | * as efficiency 38 | */ 39 | void outputStats(int fds); 40 | 41 | #endif // USEROUTPUT_H 42 | -------------------------------------------------------------------------------- /larbin-2.6.3/src/larbin.make: -------------------------------------------------------------------------------- 1 | ADNSDIR=$(BASEDIR)/../adns 2 | LIBS:= 3 | 4 | include $(BASEDIR)/../config.make 5 | 6 | UTILS-OBJ:=string.o debug.o url.o connexion.o text.o \ 7 | histogram.o webserver.o PersistentFifo.o hashDup.o mypthread.o 8 | INTERF-OBJ:=input.o useroutput.o output.o 9 | FETCH-OBJ:=site.o sequencer.o hashTable.o checker.o file.o \ 10 | fetchOpen.o fetchPipe.o 11 | MAIN-OBJ:=global.o main.o 12 | 13 | ABS-UTILS-OBJ:=utils/string.o utils/debug.o utils/url.o \ 14 | utils/connexion.o utils/text.o utils/histogram.o \ 15 | utils/webserver.o utils/PersistentFifo.o utils/hashDup.o \ 16 | utils/mypthread.o 17 | ABS-INTERF-OBJ:=interf/input.o interf/useroutput.o interf/output.o 18 | ABS-FETCH-OBJ:=fetch/site.o fetch/sequencer.o fetch/hashTable.o \ 19 | fetch/checker.o fetch/file.o fetch/fetchOpen.o fetch/fetchPipe.o 20 | ABS-MAIN-OBJ:=$(MAIN-OBJ) 21 | 22 | CFLAGS:=-O3 -Wall -D_REENTRANT 23 | CXXFLAGS:= -Wno-deprecated -Wall -O3 -D_REENTRANT -I- -I$(BASEDIR) -I$(ADNSDIR) 24 | RM:=rm -f 25 | 26 | first: all 27 | 28 | dep-in: 29 | makedepend -f- -I$(BASEDIR) -Y *.cc 2> /dev/null > .depend 30 | 31 | clean-in: 32 | $(RM) *.o 33 | $(RM) *~ 34 | $(RM) *.bak 35 | 36 | distclean-in: clean-in 37 | $(RM) .depend 38 | 39 | redo-in: all 40 | 41 | debug-in: CXXFLAGS += -g 42 | debug-in: redo-in 43 | 44 | prof-in: CXXFLAGS += -pg -DPROF 45 | prof-in: redo-in 46 | 47 | include .depend 48 | -------------------------------------------------------------------------------- /larbin-2.6.3/src/utils/Makefile: -------------------------------------------------------------------------------- 1 | BASEDIR=.. 2 | 3 | include ../larbin.make 4 | 5 | all: $(UTILS-OBJ) 6 | -------------------------------------------------------------------------------- /larbin-2.6.3/src/utils/connexion.h: -------------------------------------------------------------------------------- 1 | // Larbin 2 | // Sebastien Ailleret 3 | // 15-11-99 -> 14-12-99 4 | 5 | #ifndef CONNEXION_H 6 | #define CONNEXION_H 7 | 8 | /* make write until everything is written 9 | * return 0 on success, 1 otherwise 10 | * Don't work on non-blocking fds... 11 | */ 12 | int ecrire (int fd, char *buf); 13 | 14 | /* make write until everything is written 15 | * return 0 on success, 1 otherwise 16 | * Don't work on non-blocking fds... 17 | */ 18 | int ecrireBuff (int fd, char *buf, int count); 19 | 20 | /** Write an int on a fds 21 | * (uses ecrire) 22 | */ 23 | int ecrireInt (int fd, int i); 24 | int ecrireInt2 (int fd, int i); 25 | int ecrireInti (int fd, int i, char *f); 26 | int ecrireIntl (int fd, long i, char *f); 27 | 28 | /** Write an int on a fds 29 | * (uses ecrire) 30 | */ 31 | int ecrireLong (int fd, long i); 32 | 33 | /* Write a char on a fds 34 | * return 0 on success, 1 otherwise 35 | * Don't work on non-blocking fds... 36 | */ 37 | int ecrireChar (int fd, char c); 38 | 39 | 40 | #endif // CONNEXION_H 41 | -------------------------------------------------------------------------------- /larbin-2.6.3/src/utils/debug.cc: -------------------------------------------------------------------------------- 1 | // Larbin 2 | // Sebastien Ailleret 3 | // 15-11-99 -> 03-04-01 4 | 5 | #include 6 | 7 | #include "options.h" 8 | 9 | #include "types.h" 10 | 11 | #ifndef NDEBUG 12 | 13 | uint stateMain; // where is the main loop 14 | uint debug = 0; 15 | 16 | uint sites = 0; // Number of occupied sites 17 | uint ipsites = 0; // Number of occupied ip sites 18 | uint debUrl = 0; // How many urls in ram 19 | uint namedUrl = 0; 20 | uint missUrl = 0; // Number of urls reput in ram 21 | uint debPars = 0; // How many parsers are there 22 | 23 | unsigned long byte_read = 0; 24 | unsigned long byte_write = 0; 25 | 26 | unsigned long readRate = 0; 27 | unsigned long readPrev = 0; 28 | unsigned long writeRate = 0; 29 | unsigned long writePrev = 0; 30 | 31 | #endif // NDEBUG 32 | 33 | #ifndef NOSTATS 34 | 35 | uint siteSeen = 0; 36 | uint siteDNS = 0; // has a DNS entry 37 | uint siteRobots = 0; 38 | uint robotsOK = 0; 39 | 40 | uint hashUrls = 0; 41 | uint urls = 0; 42 | uint pages = 0; 43 | uint interestingPage = 0; 44 | uint interestingSeen = 0; 45 | uint interestingExtension = 0; 46 | uint extensionTreated = 0; 47 | uint answers[nbAnswers] = {0,0,0,0,0,0,0,0,0}; 48 | 49 | // variables for rates 50 | uint urlsRate = 0; 51 | uint urlsPrev = 0; 52 | uint pagesRate = 0; 53 | uint pagesPrev = 0; 54 | uint successRate = 0; 55 | uint successPrev = 0; 56 | uint siteSeenRate = 0; 57 | uint siteSeenPrev = 0; 58 | uint siteDNSRate = 0; 59 | uint siteDNSPrev = 0; 60 | 61 | #endif // NOSTATS 62 | -------------------------------------------------------------------------------- /larbin-2.6.3/src/utils/hashDup.h: -------------------------------------------------------------------------------- 1 | // Larbin 2 | // Sebastien Ailleret 3 | // 27-08-01 -> 27-08-01 4 | 5 | /* class hashTable 6 | * This class is in charge of making sure we don't crawl twice the same url 7 | */ 8 | 9 | #ifndef HASHDUP_H 10 | #define HASHDUP_H 11 | 12 | class hashDup { 13 | private: 14 | ssize_t size; 15 | char *table; 16 | char *file; 17 | 18 | public: 19 | /* constructor */ 20 | hashDup (ssize_t size, char *init, bool scratch); 21 | 22 | /* destructor */ 23 | ~hashDup (); 24 | 25 | /* set a page in the hashtable 26 | * return false if it was already there 27 | * return true if it was not (ie it is new) 28 | */ 29 | bool testSet (char *doc); 30 | 31 | /* save in a file */ 32 | void save (); 33 | }; 34 | 35 | #endif // HASHDUP_H 36 | -------------------------------------------------------------------------------- /larbin-2.6.3/src/utils/histogram.h: -------------------------------------------------------------------------------- 1 | // Larbin 2 | // Laurent Viennot 3 | // 10-10-01 -> 10-10-01 4 | 5 | // modified by Sebastien Ailleret 6 | // 19-10-01 -> 19-10-01 7 | 8 | /* histogram of number of pages retrieved for graphical stats */ 9 | 10 | #ifndef HISTOGRAM_H 11 | #define HISTOGRAM_H 12 | 13 | #include "options.h" 14 | 15 | #ifdef GRAPH 16 | 17 | /* call this every sec to report downloads */ 18 | void histoHit (uint p, uint s); 19 | 20 | /* call this in webserver for printing */ 21 | void histoWrite (int fds); 22 | 23 | #else // GRAPH NOT DEFINED 24 | 25 | #define histoHit(p,s) ((void) 0) 26 | #define histoWrite(f) ((void) 0) 27 | 28 | #endif // GRAPH 29 | 30 | #endif // HISTOGRAM_H 31 | -------------------------------------------------------------------------------- /larbin-2.6.3/src/utils/mypthread.cc: -------------------------------------------------------------------------------- 1 | // Larbin 2 | // Sebastien Ailleret 3 | // 07-12-01 -> 07-12-01 4 | 5 | #include 6 | #include 7 | 8 | #include "utils/mypthread.h" 9 | 10 | /* Launch a new thread 11 | * return 0 in case of success 12 | */ 13 | void startThread (StartFun run, void *arg) { 14 | pthread_t t; 15 | pthread_attr_t attr; 16 | if (pthread_attr_init(&attr) != 0 17 | || pthread_create(&t, &attr, run, arg) != 0 18 | || pthread_attr_destroy(&attr) != 0 19 | || pthread_detach(t) != 0) { 20 | cerr << "Unable to launch a thread\n"; 21 | exit(1); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /larbin-2.6.3/src/utils/mypthread.h: -------------------------------------------------------------------------------- 1 | // Larbin 2 | // Sebastien Ailleret 3 | // 13-06-01 -> 07-12-01 4 | 5 | #ifndef MYTHREAD_H 6 | #define MYTHREAD_H 7 | 8 | #include 9 | 10 | #include "options.h" 11 | 12 | #ifdef THREAD_OUTPUT 13 | 14 | #define mypthread_cond_init(x,y) pthread_cond_init(x,y) 15 | #define mypthread_cond_destroy(x) pthread_cond_destroy(x) 16 | #define mypthread_cond_wait(c,x,y) while (c) { pthread_cond_wait(x,y); } 17 | #define mypthread_cond_broadcast(x) pthread_cond_broadcast(x) 18 | 19 | #define mypthread_mutex_init(x,y) pthread_mutex_init(x,y) 20 | #define mypthread_mutex_destroy(x) pthread_mutex_destroy(x) 21 | #define mypthread_mutex_lock(x) pthread_mutex_lock(x) 22 | #define mypthread_mutex_unlock(x) pthread_mutex_unlock(x) 23 | 24 | #else 25 | 26 | #define mypthread_cond_init(x,y) ((void) 0) 27 | #define mypthread_cond_destroy(x) ((void) 0) 28 | #define mypthread_cond_wait(c,x,y) ((void) 0) 29 | #define mypthread_cond_broadcast(x) ((void) 0) 30 | 31 | #define mypthread_mutex_init(x,y) ((void) 0) 32 | #define mypthread_mutex_destroy(x) ((void) 0) 33 | #define mypthread_mutex_lock(x) ((void) 0) 34 | #define mypthread_mutex_unlock(x) ((void) 0) 35 | 36 | #endif // THREAD_OUTPUT 37 | 38 | typedef void* (*StartFun) (void *); 39 | void startThread (StartFun run, void *arg); 40 | 41 | #endif // MYTHREAD_H 42 | -------------------------------------------------------------------------------- /larbin-2.6.3/src/utils/string.h: -------------------------------------------------------------------------------- 1 | // Larbin 2 | // Sebastien Ailleret 3 | // 20-12-99 -> 05-05-01 4 | 5 | #ifndef STRING_HH 6 | #define STRING_HH 7 | 8 | #include 9 | 10 | #include "types.h" 11 | #include "utils/debug.h" 12 | 13 | class LarbinString { 14 | private: 15 | char *chaine; 16 | uint pos; 17 | uint size; 18 | public: 19 | // Constructor 20 | LarbinString (uint size=STRING_SIZE); 21 | // Destructor 22 | ~LarbinString (); 23 | // Recycle this string 24 | void recycle (uint size=STRING_SIZE); 25 | // get the char * : it is deleted when you delete this String Object 26 | char *getString (); 27 | // give a char * : it creates a new one : YOU MUST DELETE IT YOURSELF 28 | char *giveString (); 29 | // append a char 30 | void addChar (char c); 31 | // append a char * 32 | void addString (char *s); 33 | // append a buffer 34 | void addBuffer (char *s, uint len); 35 | // length of this string 36 | inline uint getLength () { return pos; }; 37 | // get a char of this string 38 | inline char operator [] (uint i) { 39 | assert(i<=pos); 40 | return chaine[i]; 41 | } 42 | // change a char 43 | void setChar (uint i, char c); 44 | }; 45 | 46 | #endif // STRING_HH 47 | -------------------------------------------------------------------------------- /larbin-2.6.3/src/utils/text.h: -------------------------------------------------------------------------------- 1 | // Larbin 2 | // Sebastien Ailleret 3 | // 18-11-99 -> 21-05-01 4 | 5 | #ifndef TEXT_H 6 | #define TEXT_H 7 | 8 | #include "utils/string.h" 9 | 10 | /* lowercase a char */ 11 | char lowerCase (char a); 12 | 13 | /* tests if b starts with a */ 14 | bool startWith (char *a, char *b); 15 | 16 | /* test if b is forbidden by pattern a */ 17 | bool robotsMatch (char *a, char *b); 18 | 19 | /* tests if b starts with a ignoring case */ 20 | bool startWithIgnoreCase (char *a, char *b); 21 | 22 | /* test if b end with a */ 23 | bool endWith (char *a, char *b); 24 | 25 | /* test if b end with a ignoring case 26 | * a can use min char, '.' (a[i] = a[i] | 32) 27 | */ 28 | bool endWithIgnoreCase (char *amin, char *b, int lb); 29 | 30 | /* tests if b contains a */ 31 | bool caseContain (char *a, char *b); 32 | 33 | /* create a copy of a string */ 34 | char *newString (char *arg); 35 | 36 | /* Read a whole file 37 | */ 38 | char *readfile (int fds); 39 | 40 | /* find the next token in the robots.txt, or in config file 41 | * must delete comments 42 | * no allocation (cf strtok); content is changed 43 | * param c is a bad hack for using the same function for robots and configfile 44 | */ 45 | char *nextToken(char **posParse, char c=' '); 46 | 47 | /* does this char * match privilegedExt */ 48 | bool matchPrivExt(char *file); 49 | 50 | /* does this char * match contentType */ 51 | bool matchContentType(char *ct); 52 | 53 | #endif // TEXT_H 54 | -------------------------------------------------------------------------------- /larbin-2.6.3/src/utils/webserver.h: -------------------------------------------------------------------------------- 1 | // Larbin 2 | // Sebastien Ailleret 3 | // 07-03-00 -> 17-03-02 4 | 5 | #ifndef WEBSERVER_H 6 | #define WEBSERVER_H 7 | 8 | #ifndef NOWEBSERVER 9 | void *startWebserver (void *none); 10 | #endif // NOWEBSERVER 11 | 12 | #endif // WEBSERVER_H 13 | -------------------------------------------------------------------------------- /libevent-1.4.9-stable/README: -------------------------------------------------------------------------------- 1 | To build libevent, type 2 | 3 | $ ./configure && make 4 | 5 | (If you got libevent from the subversion repository, you will 6 | first need to run the included "autogen.sh" script in order to 7 | generate the configure script.) 8 | 9 | Install as root via 10 | 11 | # make install 12 | 13 | You can run the regression tests by 14 | 15 | $ make verify 16 | 17 | Before, reporting any problems, please run the regression tests. 18 | 19 | To enable the low-level tracing build the library as: 20 | 21 | CFLAGS=-DUSE_DEBUG ./configure [...] 22 | 23 | Acknowledgements: 24 | ----------------- 25 | 26 | The following people have helped with suggestions, ideas, code or 27 | fixing bugs: 28 | 29 | Alejo 30 | Weston Andros Adamson 31 | William Ahern 32 | Stas Bekman 33 | Andrew Danforth 34 | Mike Davis 35 | Shie Erlich 36 | Alexander von Gernler 37 | Artur Grabowski 38 | Aaron Hopkins 39 | Claudio Jeker 40 | Scott Lamb 41 | Adam Langley 42 | Philip Lewis 43 | David Libenzi 44 | Nick Mathewson 45 | Andrey Matveev 46 | Richard Nyberg 47 | Jon Oberheide 48 | Phil Oleson 49 | Dave Pacheco 50 | Tassilo von Parseval 51 | Pierre Phaneuf 52 | Jon Poland 53 | Bert JW Regeer 54 | Dug Song 55 | Taral 56 | 57 | If I have forgotten your name, please contact me. 58 | -------------------------------------------------------------------------------- /libevent-1.4.9-stable/WIN32-Prj/libevent.dsw: -------------------------------------------------------------------------------- 1 | Microsoft Developer Studio Workspace File, Format Version 6.00 2 | # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! 3 | 4 | ############################################################################### 5 | 6 | Project: "event_test"=".\event_test\event_test.dsp" - Package Owner=<4> 7 | 8 | Package=<5> 9 | {{{ 10 | }}} 11 | 12 | Package=<4> 13 | {{{ 14 | Begin Project Dependency 15 | Project_Dep_Name libevent 16 | End Project Dependency 17 | }}} 18 | 19 | ############################################################################### 20 | 21 | Project: "libevent"=".\libevent.dsp" - Package Owner=<4> 22 | 23 | Package=<5> 24 | {{{ 25 | }}} 26 | 27 | Package=<4> 28 | {{{ 29 | }}} 30 | 31 | ############################################################################### 32 | 33 | Project: "signal_test"=".\signal_test\signal_test.dsp" - Package Owner=<4> 34 | 35 | Package=<5> 36 | {{{ 37 | }}} 38 | 39 | Package=<4> 40 | {{{ 41 | Begin Project Dependency 42 | Project_Dep_Name libevent 43 | End Project Dependency 44 | }}} 45 | 46 | ############################################################################### 47 | 48 | Project: "time_test"=".\time_test\time_test.dsp" - Package Owner=<4> 49 | 50 | Package=<5> 51 | {{{ 52 | }}} 53 | 54 | Package=<4> 55 | {{{ 56 | Begin Project Dependency 57 | Project_Dep_Name libevent 58 | End Project Dependency 59 | }}} 60 | 61 | ############################################################################### 62 | 63 | Global: 64 | 65 | Package=<5> 66 | {{{ 67 | }}} 68 | 69 | Package=<3> 70 | {{{ 71 | }}} 72 | 73 | ############################################################################### 74 | 75 | -------------------------------------------------------------------------------- /libevent-1.4.9-stable/sample/Makefile.am: -------------------------------------------------------------------------------- 1 | AUTOMAKE_OPTIONS = foreign no-dependencies 2 | 3 | LDADD = ../libevent.la 4 | AM_CFLAGS = -I$(top_srcdir) -I$(top_srcdir)/compat 5 | 6 | noinst_PROGRAMS = event-test time-test signal-test 7 | 8 | event_test_sources = event-test.c 9 | time_test_sources = time-test.c 10 | signal_test_sources = signal-test.c 11 | 12 | verify: 13 | 14 | DISTCLEANFILES = *~ 15 | -------------------------------------------------------------------------------- /libevent-1.4.9-stable/sample/signal-test.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Compile with: 3 | * cc -I/usr/local/include -o time-test time-test.c -L/usr/local/lib -levent 4 | */ 5 | 6 | #include 7 | 8 | #ifdef HAVE_CONFIG_H 9 | #include "config.h" 10 | #endif 11 | 12 | #include 13 | #ifndef WIN32 14 | #include 15 | #include 16 | #include 17 | #else 18 | #include 19 | #endif 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | #include 28 | 29 | int called = 0; 30 | 31 | static void 32 | signal_cb(int fd, short event, void *arg) 33 | { 34 | struct event *signal = arg; 35 | 36 | printf("%s: got signal %d\n", __func__, EVENT_SIGNAL(signal)); 37 | 38 | if (called >= 2) 39 | event_del(signal); 40 | 41 | called++; 42 | } 43 | 44 | int 45 | main (int argc, char **argv) 46 | { 47 | struct event signal_int; 48 | 49 | /* Initalize the event library */ 50 | event_init(); 51 | 52 | /* Initalize one event */ 53 | event_set(&signal_int, SIGINT, EV_SIGNAL|EV_PERSIST, signal_cb, 54 | &signal_int); 55 | 56 | event_add(&signal_int, NULL); 57 | 58 | event_dispatch(); 59 | 60 | return (0); 61 | } 62 | 63 | -------------------------------------------------------------------------------- /libevent-1.4.9-stable/sample/time-test.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Compile with: 3 | * cc -I/usr/local/include -o time-test time-test.c -L/usr/local/lib -levent 4 | */ 5 | 6 | #include 7 | 8 | #ifdef HAVE_CONFIG_H 9 | #include "config.h" 10 | #endif 11 | 12 | #include 13 | #ifndef WIN32 14 | #include 15 | #include 16 | #endif 17 | #include 18 | #ifdef HAVE_SYS_TIME_H 19 | #include 20 | #endif 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | #include 28 | #include 29 | 30 | int lasttime; 31 | 32 | static void 33 | timeout_cb(int fd, short event, void *arg) 34 | { 35 | struct timeval tv; 36 | struct event *timeout = arg; 37 | int newtime = time(NULL); 38 | 39 | printf("%s: called at %d: %d\n", __func__, newtime, 40 | newtime - lasttime); 41 | lasttime = newtime; 42 | 43 | evutil_timerclear(&tv); 44 | tv.tv_sec = 2; 45 | event_add(timeout, &tv); 46 | } 47 | 48 | int 49 | main (int argc, char **argv) 50 | { 51 | struct event timeout; 52 | struct timeval tv; 53 | 54 | /* Initalize the event library */ 55 | event_init(); 56 | 57 | /* Initalize one event */ 58 | evtimer_set(&timeout, timeout_cb, &timeout); 59 | 60 | evutil_timerclear(&tv); 61 | tv.tv_sec = 2; 62 | event_add(&timeout, &tv); 63 | 64 | lasttime = time(NULL); 65 | 66 | event_dispatch(); 67 | 68 | return (0); 69 | } 70 | 71 | -------------------------------------------------------------------------------- /libevent-1.4.9-stable/strlcpy-internal.h: -------------------------------------------------------------------------------- 1 | #ifndef _STRLCPY_INTERNAL_H_ 2 | #define _STRLCPY_INTERNAL_H_ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #ifdef HAVE_CONFIG_H 9 | #include "config.h" 10 | #endif /* HAVE_CONFIG_H */ 11 | 12 | #ifndef HAVE_STRLCPY 13 | #include 14 | size_t _event_strlcpy(char *dst, const char *src, size_t siz); 15 | #define strlcpy _event_strlcpy 16 | #endif 17 | 18 | #ifdef __cplusplus 19 | } 20 | #endif 21 | 22 | #endif 23 | 24 | -------------------------------------------------------------------------------- /libevent-1.4.9-stable/test/Makefile.am: -------------------------------------------------------------------------------- 1 | AUTOMAKE_OPTIONS = foreign no-dependencies 2 | 3 | AM_CFLAGS = -I$(top_srcdir) -I$(top_srcdir)/compat 4 | 5 | EXTRA_DIST = regress.rpc regress.gen.h regress.gen.c 6 | 7 | noinst_PROGRAMS = test-init test-eof test-weof test-time regress bench 8 | 9 | BUILT_SOURCES = regress.gen.c regress.gen.h 10 | test_init_SOURCES = test-init.c 11 | test_init_LDADD = ../libevent_core.la 12 | test_eof_SOURCES = test-eof.c 13 | test_eof_LDADD = ../libevent_core.la 14 | test_weof_SOURCES = test-weof.c 15 | test_weof_LDADD = ../libevent_core.la 16 | test_time_SOURCES = test-time.c 17 | test_time_LDADD = ../libevent_core.la 18 | regress_SOURCES = regress.c regress.h regress_http.c regress_dns.c \ 19 | regress_rpc.c \ 20 | regress.gen.c regress.gen.h 21 | regress_LDADD = ../libevent.la 22 | bench_SOURCES = bench.c 23 | bench_LDADD = ../libevent.la 24 | 25 | regress.gen.c regress.gen.h: regress.rpc $(top_srcdir)/event_rpcgen.py 26 | $(top_srcdir)/event_rpcgen.py $(srcdir)/regress.rpc || echo "No Python installed" 27 | 28 | DISTCLEANFILES = *~ 29 | 30 | test: test-init test-eof test-weof test-time regress 31 | 32 | verify: test 33 | @$(srcdir)/test.sh 34 | 35 | bench test-init test-eof test-weof test-time: ../libevent.la 36 | -------------------------------------------------------------------------------- /libevent-1.4.9-stable/test/regress.rpc: -------------------------------------------------------------------------------- 1 | /* tests data packing and unpacking */ 2 | 3 | struct msg { 4 | string from_name = 1; 5 | string to_name = 2; 6 | optional struct[kill] attack = 3; 7 | array struct[run] run = 4; 8 | } 9 | 10 | struct kill { 11 | string weapon = 0x10121; 12 | string action = 2; 13 | optional int how_often = 3; 14 | } 15 | 16 | struct run { 17 | string how = 1; 18 | optional bytes some_bytes = 2; 19 | bytes fixed_bytes[24] = 3; 20 | } 21 | -------------------------------------------------------------------------------- /libevent-1.4.9-stable/test/test-eof.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Compile with: 3 | * cc -I/usr/local/include -o time-test time-test.c -L/usr/local/lib -levent 4 | */ 5 | #ifdef HAVE_CONFIG_H 6 | #include "config.h" 7 | #endif 8 | 9 | 10 | #ifdef WIN32 11 | #include 12 | #endif 13 | #include 14 | #include 15 | #include 16 | #ifdef HAVE_SYS_SOCKET_H 17 | #include 18 | #endif 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | #include 27 | #include 28 | 29 | int test_okay = 1; 30 | int called = 0; 31 | 32 | static void 33 | read_cb(int fd, short event, void *arg) 34 | { 35 | char buf[256]; 36 | int len; 37 | 38 | len = read(fd, buf, sizeof(buf)); 39 | 40 | printf("%s: read %d%s\n", __func__, 41 | len, len ? "" : " - means EOF"); 42 | 43 | if (len) { 44 | if (!called) 45 | event_add(arg, NULL); 46 | } else if (called == 1) 47 | test_okay = 0; 48 | 49 | called++; 50 | } 51 | 52 | #ifndef SHUT_WR 53 | #define SHUT_WR 1 54 | #endif 55 | 56 | int 57 | main (int argc, char **argv) 58 | { 59 | struct event ev; 60 | const char *test = "test string"; 61 | int pair[2]; 62 | 63 | if (evutil_socketpair(AF_UNIX, SOCK_STREAM, 0, pair) == -1) 64 | return (1); 65 | 66 | 67 | write(pair[0], test, strlen(test)+1); 68 | shutdown(pair[0], SHUT_WR); 69 | 70 | /* Initalize the event library */ 71 | event_init(); 72 | 73 | /* Initalize one event */ 74 | event_set(&ev, pair[1], EV_READ, read_cb, &ev); 75 | 76 | event_add(&ev, NULL); 77 | 78 | event_dispatch(); 79 | 80 | return (test_okay); 81 | } 82 | 83 | -------------------------------------------------------------------------------- /libevent-1.4.9-stable/test/test-init.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Compile with: 3 | * cc -I/usr/local/include -o time-test time-test.c -L/usr/local/lib -levent 4 | */ 5 | #ifdef HAVE_CONFIG_H 6 | #include "config.h" 7 | #endif 8 | 9 | 10 | #include 11 | #include 12 | #include 13 | #ifdef HAVE_SYS_SOCKET_H 14 | #include 15 | #endif 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | #include 24 | 25 | int 26 | main(int argc, char **argv) 27 | { 28 | /* Initalize the event library */ 29 | event_init(); 30 | 31 | return (0); 32 | } 33 | 34 | -------------------------------------------------------------------------------- /libevent-1.4.9-stable/test/test-time.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Compile with: 3 | * cc -I/usr/local/include -o time-test time-test.c -L/usr/local/lib -levent 4 | */ 5 | #ifdef HAVE_CONFIG_H 6 | #include "config.h" 7 | #endif 8 | 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | #include 21 | 22 | int called = 0; 23 | 24 | #define NEVENT 20000 25 | 26 | struct event *ev[NEVENT]; 27 | 28 | static int 29 | rand_int(int n) 30 | { 31 | #ifdef WIN32 32 | return (int)(rand() * n); 33 | #else 34 | return (int)(random() % n); 35 | #endif 36 | } 37 | 38 | static void 39 | time_cb(int fd, short event, void *arg) 40 | { 41 | struct timeval tv; 42 | int i, j; 43 | 44 | called++; 45 | 46 | if (called < 10*NEVENT) { 47 | for (i = 0; i < 10; i++) { 48 | j = rand_int(NEVENT); 49 | tv.tv_sec = 0; 50 | tv.tv_usec = rand_int(50000); 51 | if (tv.tv_usec % 2) 52 | evtimer_add(ev[j], &tv); 53 | else 54 | evtimer_del(ev[j]); 55 | } 56 | } 57 | } 58 | 59 | int 60 | main (int argc, char **argv) 61 | { 62 | struct timeval tv; 63 | int i; 64 | 65 | /* Initalize the event library */ 66 | event_init(); 67 | 68 | for (i = 0; i < NEVENT; i++) { 69 | ev[i] = malloc(sizeof(struct event)); 70 | 71 | /* Initalize one event */ 72 | evtimer_set(ev[i], time_cb, ev[i]); 73 | tv.tv_sec = 0; 74 | tv.tv_usec = rand_int(50000); 75 | evtimer_add(ev[i], &tv); 76 | } 77 | 78 | event_dispatch(); 79 | 80 | return (called < NEVENT); 81 | } 82 | 83 | -------------------------------------------------------------------------------- /libevent-1.4.9-stable/test/test-weof.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Compile with: 3 | * cc -I/usr/local/include -o time-test time-test.c -L/usr/local/lib -levent 4 | */ 5 | #ifdef HAVE_CONFIG_H 6 | #include "config.h" 7 | #endif 8 | 9 | 10 | #ifdef WIN32 11 | #include 12 | #endif 13 | #include 14 | #include 15 | #include 16 | #ifdef HAVE_SYS_SOCKET_H 17 | #include 18 | #endif 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | #include 28 | #include 29 | 30 | int pair[2]; 31 | int test_okay = 1; 32 | int called = 0; 33 | 34 | static void 35 | write_cb(int fd, short event, void *arg) 36 | { 37 | const char *test = "test string"; 38 | int len; 39 | 40 | len = write(fd, test, strlen(test) + 1); 41 | 42 | printf("%s: write %d%s\n", __func__, 43 | len, len ? "" : " - means EOF"); 44 | 45 | if (len > 0) { 46 | if (!called) 47 | event_add(arg, NULL); 48 | close(pair[0]); 49 | } else if (called == 1) 50 | test_okay = 0; 51 | 52 | called++; 53 | } 54 | 55 | int 56 | main (int argc, char **argv) 57 | { 58 | struct event ev; 59 | 60 | #ifndef WIN32 61 | if (signal(SIGPIPE, SIG_IGN) == SIG_ERR) 62 | return (1); 63 | #endif 64 | 65 | if (evutil_socketpair(AF_UNIX, SOCK_STREAM, 0, pair) == -1) 66 | return (1); 67 | 68 | /* Initalize the event library */ 69 | event_init(); 70 | 71 | /* Initalize one event */ 72 | event_set(&ev, pair[1], EV_WRITE, write_cb, &ev); 73 | 74 | event_add(&ev, NULL); 75 | 76 | event_dispatch(); 77 | 78 | return (test_okay); 79 | } 80 | 81 | -------------------------------------------------------------------------------- /libevent-1.4.9-stable/test/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | setup () { 4 | EVENT_NOKQUEUE=yes; export EVENT_NOKQUEUE 5 | EVENT_NODEVPOLL=yes; export EVENT_NODEVPOLL 6 | EVENT_NOPOLL=yes; export EVENT_NOPOLL 7 | EVENT_NOSELECT=yes; export EVENT_NOSELECT 8 | EVENT_NOEPOLL=yes; export EVENT_NOEPOLL 9 | EVENT_NOEVPORT=yes; export EVENT_NOEVPORT 10 | } 11 | 12 | test () { 13 | if ./test-init 2>/dev/null ; 14 | then 15 | true 16 | else 17 | echo Skipping test 18 | return 19 | fi 20 | 21 | echo -n " test-eof: " 22 | if ./test-eof >/dev/null ; 23 | then 24 | echo OKAY ; 25 | else 26 | echo FAILED ; 27 | fi 28 | echo -n " test-weof: " 29 | if ./test-weof >/dev/null ; 30 | then 31 | echo OKAY ; 32 | else 33 | echo FAILED ; 34 | fi 35 | echo -n " test-time: " 36 | if ./test-time >/dev/null ; 37 | then 38 | echo OKAY ; 39 | else 40 | echo FAILED ; 41 | fi 42 | echo -n " regress: " 43 | if ./regress >/dev/null ; 44 | then 45 | echo OKAY ; 46 | else 47 | echo FAILED ; 48 | fi 49 | } 50 | 51 | echo "Running tests:" 52 | 53 | # Need to do this by hand? 54 | setup 55 | unset EVENT_NOKQUEUE 56 | export EVENT_NOKQUEUE 57 | echo "KQUEUE" 58 | test 59 | 60 | setup 61 | unset EVENT_NODEVPOLL 62 | export EVENT_NODEVPOLL 63 | echo "DEVPOLL" 64 | test 65 | 66 | setup 67 | unset EVENT_NOPOLL 68 | export EVENT_NOPOLL 69 | echo "POLL" 70 | test 71 | 72 | setup 73 | unset EVENT_NOSELECT 74 | export EVENT_NOSELECT 75 | echo "SELECT" 76 | test 77 | 78 | setup 79 | unset EVENT_NOEPOLL 80 | export EVENT_NOEPOLL 81 | echo "EPOLL" 82 | test 83 | 84 | setup 85 | unset EVENT_NOEVPORT 86 | export EVENT_NOEVPORT 87 | echo "EVPORT" 88 | test 89 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /spiderq/LICENSE.md: -------------------------------------------------------------------------------- 1 | Spiderq is available for use under the following license, commonly known 2 | as the 3-clause (or "modified") BSD license: 3 | 4 | ============================== 5 | Copyright (c) 2012-2012 qteqpid 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions 9 | are met: 10 | 1. Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following disclaimer. 12 | 2. Redistributions in binary form must reproduce the above copyright 13 | notice, this list of conditions and the following disclaimer in the 14 | documentation and/or other materials provided with the distribution. 15 | 3. The name of the author may not be used to endorse or promote products 16 | derived from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 19 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 20 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 21 | IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 23 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 27 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | ============================== 29 | -------------------------------------------------------------------------------- /spiderq/Makefile: -------------------------------------------------------------------------------- 1 | # This is top level makefile. The real shit is at src/Makefile 2 | 3 | default:all 4 | 5 | .DEFAULT: 6 | @cd ./modules && $(MAKE) $@ 7 | @cd ./src && $(MAKE) $@ 8 | 9 | .PHONY: 10 | default 11 | -------------------------------------------------------------------------------- /spiderq/README.md: -------------------------------------------------------------------------------- 1 | What is spiderq? 2 | ================ 3 | Spiderq is a Web Spider to crawl webpage(html) by Qteqpid. The performance depends on your server configuration and network. I will continue maintain it and list some TODOs at the end of this file. More people are welcome to join! 4 | 5 | 6 | Building spiderq 7 | ================ 8 | Spiderq can be compiled and used on Centos 5.8 . 9 | It is as simple as: 10 | 11 | % make 12 | % make install 13 | 14 | Then you will get an executable file named spider. After configurating spiderq.conf, run program: 15 | 16 | % ./spider 17 | 18 | For more informations, see Makefile. 19 | 20 | 21 | Contact 22 | ================ 23 | For any question, just contact me at any time. Enjoy! 24 | mailto: qteqpid 25 | blog: http://hi.baidu.com/qteqpid_pku 26 | 27 | 28 | TODO 29 | =============== 30 | @线程池 31 | @信号处理 32 | @网页内容排重 33 | @同一ip间隔抓取 34 | @层次结构存储网页 35 | @是否遵守robots.txt 36 | @支持更新抓取,不重复抓 37 | @定义对外api和html类,方便用户自定义处理html,动态加载方式 38 | -------------------------------------------------------------------------------- /spiderq/modules/Makefile: -------------------------------------------------------------------------------- 1 | # Spiderq Makefile 2 | # Copyright (C) 2012-2013 Qteqpid 3 | # This file is released under the BSD license, see the COPYING file 4 | 5 | SPIDERQ_MAJOR=0 6 | SPIDERQ_MINOR=1 7 | DYLIBSUFFIX=so 8 | DYLIBMAJORSUFFIX=$(SPIDERQ_MAJOR) 9 | DYLIBMINORSUFFIX=$(SPIDERQ_MAJOR).$(SPIDERQ_MINOR) 10 | 11 | SOURCES=$(wildcard *.cpp) 12 | OBJS=$(patsubst %.cpp,%.o,$(SOURCES)) 13 | DYLIBNAMES=$(patsubst %.cpp,%.$(DYLIBSUFFIX),$(SOURCES)) 14 | 15 | 16 | # Fallback to gcc when $CC is not in $PATH. 17 | CXX:=g++ 18 | OPTIMIZATION?=-O2 -DNDEBUG 19 | WARNINGS=-Wall 20 | CXXFLAGS=-I../src 21 | REAL_CXXFLAGS=$(OPTIMIZATION) -fPIC $(CXXFLAGS) $(WARNINGS) $(DEBUG) $(PROF) 22 | 23 | 24 | all: $(DYLIBNAMES) 25 | 26 | #$(DYLIBNAMES): $(OBJS) 27 | %.so:%.o 28 | $(CXX) -shared -Wl,-soname,$@.$(DYLIBMINORSUFFIX) $(LDFLAGS) $< -o $@ 29 | 30 | 31 | .cpp.o: 32 | $(CXX) -c $(REAL_CXXFLAGS) $< 33 | 34 | clean: 35 | rm -rf $(DYLIBNAMES) $(OBJS) 36 | 37 | 38 | # Installation related variables and target 39 | PREFIX:=/etc/spiderq 40 | MODULEDIR=$(PREFIX)/modules 41 | 42 | ifeq ($(uname_S),SunOS) 43 | INSTALL?= cp -r 44 | endif 45 | INSTALL?= cp -af 46 | 47 | install: $(DYLIBNAMES) 48 | @mkdir -p $(MODULEDIR) 49 | -$(INSTALL) $^ $(MODULEDIR) 50 | 51 | debug: 52 | $(MAKE) OPTIMIZATION="" DEBUG="-g -ggdb -g3" 53 | 54 | gprof: 55 | $(MAKE) PROF="-pg" 56 | 57 | .PHONY: all clean debug gprof install 58 | -------------------------------------------------------------------------------- /spiderq/modules/headerfilter.cpp: -------------------------------------------------------------------------------- 1 | #include "dso.h" 2 | #include "socket.h" 3 | 4 | static int handler(void * data) { 5 | Header *h = (Header *)data; 6 | int i = 0; 7 | 8 | /* skip if not 2xx */ 9 | if (h->status_code < 200 || h->status_code >= 300) 10 | return MODULE_ERR; 11 | 12 | if (h->content_type != NULL) { 13 | if (strstr(h->content_type, "text/html") != NULL) 14 | return MODULE_OK; 15 | 16 | for (i = 0; i < g_conf->accept_types.size(); i++) { 17 | if (strstr(h->content_type, g_conf->accept_types[i]) != NULL) 18 | return MODULE_OK; 19 | } 20 | 21 | return MODULE_ERR; 22 | } 23 | 24 | return MODULE_OK; 25 | } 26 | 27 | static void init(Module *mod) 28 | { 29 | SPIDER_ADD_MODULE_POST_HEADER(mod); 30 | } 31 | 32 | Module headerfilter = { 33 | STANDARD_MODULE_STUFF, 34 | init, 35 | handler 36 | }; 37 | -------------------------------------------------------------------------------- /spiderq/modules/maxdepth.cpp: -------------------------------------------------------------------------------- 1 | #include "dso.h" 2 | #include "url.h" 3 | 4 | static int handler(void * data) { 5 | Surl *url = (Surl *)data; 6 | if (url->level > g_conf->max_depth) 7 | return MODULE_ERR; 8 | return MODULE_OK; 9 | } 10 | 11 | static void init(Module *mod) 12 | { 13 | SPIDER_ADD_MODULE_PRE_SURL(mod); 14 | } 15 | 16 | Module maxdepth = { 17 | STANDARD_MODULE_STUFF, 18 | init, 19 | handler 20 | }; 21 | -------------------------------------------------------------------------------- /spiderq/modules/savehtml.cpp: -------------------------------------------------------------------------------- 1 | #include "dso.h" 2 | #include "socket.h" 3 | #include 4 | 5 | static int handler(void * data) { 6 | Response *r = (Response *)data; 7 | 8 | if (strstr(r->header->content_type, "text/html") == NULL) 9 | return MODULE_ERR; 10 | 11 | char *fn = url2fn(r->url); 12 | int fd = -1; 13 | if ((fd = open(fn, O_WRONLY|O_CREAT|O_TRUNC, 0666)) < 0) { 14 | return MODULE_ERR; 15 | } 16 | 17 | int left = r->body_len; 18 | int n = -1; 19 | while (left) { 20 | if ((n = write(fd, r->body, left)) < 0) { 21 | // error 22 | close(fd); 23 | unlink(fn); 24 | free(fn); 25 | return MODULE_ERR; 26 | } else { 27 | left -= n; 28 | } 29 | } 30 | close(fd); 31 | free(fn); 32 | return MODULE_OK; 33 | } 34 | 35 | static void init(Module *mod) 36 | { 37 | SPIDER_ADD_MODULE_POST_HTML(mod); 38 | } 39 | 40 | Module savehtml = { 41 | STANDARD_MODULE_STUFF, 42 | init, 43 | handler 44 | }; 45 | -------------------------------------------------------------------------------- /spiderq/src/Makefile: -------------------------------------------------------------------------------- 1 | # Spiderq Makefile 2 | # Copyright (C) 2012-2012 Qteqpid 3 | # This file is released under the BSD license, see the LICENSE file 4 | 5 | TARGET=spider 6 | SOURCES=$(wildcard *.cpp) 7 | OBJS=$(patsubst %.cpp,%.o,$(SOURCES)) 8 | 9 | CXX:=g++ 10 | OPTIMIZATION?=-O2 -DNDEBUG 11 | WARNINGS=-Wall 12 | #WARNINGS=-Wall -Werror 13 | REAL_CXXFLAGS=$(OPTIMIZATION) $(CXXFLAGS) $(WARNINGS) $(DEBUG) $(PROF) 14 | REAL_LDFLAGS=$(LDFLAGS) $(PROF) -rdynamic -lpthread -levent -lcrypt -ldl 15 | 16 | 17 | 18 | all: $(TARGET) 19 | @if [ ! -d ../download ]; then mkdir ../download; fi 20 | 21 | $(TARGET): $(OBJS) 22 | $(CXX) -o $@ $(REAL_LDFLAGS) $^ 23 | 24 | .cpp.o: 25 | $(CXX) -c $(REAL_CXXFLAGS) $< 26 | 27 | clean: 28 | -rm -rf $(TARGET) $(OBJS) 29 | -rm -rf ../$(TARGET) 30 | 31 | debug: 32 | $(MAKE) OPTIMIZATION="" DEBUG="-g -ggdb -g3" 33 | 34 | gprof: 35 | $(MAKE) PROF="-pg" 36 | 37 | install: 38 | -cp -f $(TARGET) ../ 39 | 40 | .PHONY: all clean debug gprof install 41 | -------------------------------------------------------------------------------- /spiderq/src/bloomfilter.h: -------------------------------------------------------------------------------- 1 | #ifndef BLOOMFILTER_H 2 | #define BLOOMFILTER_H 3 | 4 | #include 5 | #include 6 | 7 | /* search if this url has been crawled */ 8 | extern int search(char *url); 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /spiderq/src/confparser.h: -------------------------------------------------------------------------------- 1 | #ifndef CONFPARSER_H 2 | #define CONFPARSER_H 3 | 4 | #include 5 | using namespace std; 6 | 7 | #define MAX_CONF_LEN 1024 8 | #define CONF_FILE "spiderq.conf" 9 | 10 | /* see the spiderq.conf to get meaning for each member variable below */ 11 | typedef struct Config { 12 | int max_job_num; 13 | char *seeds; 14 | char *include_prefixes; 15 | char *exclude_prefixes; 16 | char *logfile; 17 | int log_level; 18 | int max_depth; 19 | int make_hostdir; 20 | int stat_interval; 21 | 22 | char * module_path; 23 | vector modules; 24 | vector accept_types; 25 | }; 26 | 27 | /* give default values to member variables in struct Config */ 28 | extern Config * initconfig(); 29 | 30 | /* load configuration in conf file to Config object */ 31 | extern void loadconfig(Config *conf); 32 | 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /spiderq/src/crc32.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "crc32.h" 5 | 6 | static unsigned int CRC32[256]; 7 | static char init = 0; 8 | 9 | //初始化表 10 | static void init_table() 11 | { 12 | int i,j; 13 | unsigned int crc; 14 | for(i = 0;i < 256;i++) { 15 | crc = i; 16 | for(j = 0;j < 8;j++) { 17 | if(crc & 1) 18 | crc = (crc >> 1) ^ 0xEDB88320; 19 | else 20 | crc = crc >> 1; 21 | } 22 | CRC32[i] = crc; 23 | } 24 | } 25 | 26 | //crc32实现函数 27 | unsigned int crc32( unsigned char *buf, int len) 28 | { 29 | unsigned int ret = 0xFFFFFFFF; 30 | int i; 31 | if( !init ) { 32 | init_table(); 33 | init = 1; 34 | } 35 | for(i = 0; i < len;i++) 36 | ret = CRC32[((ret & 0xFF) ^ buf[i])] ^ (ret >> 8); 37 | 38 | return ~ret; 39 | } 40 | 41 | /* 42 | int main(int argc, char *argv[]) 43 | { 44 | if (argc < 2) { 45 | fprintf (stderr, "usage: crc32 string\n"); 46 | exit (1); 47 | } 48 | printf("%s: %u\n", argv[1], crc32((unsigned char *)argv[1], strlen(argv[1]))); 49 | return 0; 50 | } 51 | */ 52 | -------------------------------------------------------------------------------- /spiderq/src/crc32.h: -------------------------------------------------------------------------------- 1 | #ifndef CRC32_H 2 | #define CRC32_H 3 | 4 | extern unsigned int crc32(unsigned char *buf, int len); 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /spiderq/src/dso.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "dso.h" 3 | #include "spider.h" 4 | #include "qstring.h" 5 | 6 | vector modules_pre_surl; 7 | vector modules_post_header; 8 | vector modules_post_html; 9 | 10 | // 加载动态链接库 11 | Module * dso_load(const char *path, const char *name) 12 | { 13 | void *rv = NULL; 14 | void *handle = NULL; 15 | Module *module = NULL; 16 | 17 | char * npath = strcat2(3, path, name, ".so"); 18 | 19 | if ((handle = dlopen(npath, RTLD_GLOBAL | RTLD_NOW)) == NULL) { 20 | SPIDER_LOG(SPIDER_LEVEL_ERROR, "Load module fail(dlopen): %s", dlerror()); 21 | } 22 | if ((rv = dlsym(handle, name)) == NULL) { 23 | SPIDER_LOG(SPIDER_LEVEL_ERROR, "Load module fail(dlsym): %s", dlerror()); 24 | } 25 | module = (Module *)rv; 26 | module->init(module); 27 | 28 | return module; 29 | } 30 | -------------------------------------------------------------------------------- /spiderq/src/dso.h: -------------------------------------------------------------------------------- 1 | #ifndef DSO_H 2 | #define DSO_H 3 | 4 | #include 5 | using namespace std; 6 | 7 | #define MODULE_OK 0 8 | #define MODULE_ERR 1 9 | 10 | #define MAGIC_MAJOR_NUMBER 20130101 11 | #define MAGIC_MINOR_NUMBER 0 12 | 13 | 14 | #define STANDARD_MODULE_STUFF MAGIC_MAJOR_NUMBER, \ 15 | MAGIC_MINOR_NUMBER, \ 16 | __FILE__ 17 | 18 | typedef struct Module{ 19 | int version; 20 | int minor_version; 21 | const char *name; 22 | void (*init)(Module *); 23 | int (*handle)(void *); 24 | } Module; 25 | 26 | /* The modules in this queue are used before pushing Url object into surl_queue */ 27 | extern vector modules_pre_surl; 28 | 29 | #define SPIDER_ADD_MODULE_PRE_SURL(module) do {\ 30 | modules_pre_surl.push_back(module); \ 31 | } while(0) 32 | 33 | 34 | /* The modules in this queue are used after parsing out http header */ 35 | extern vector modules_post_header; 36 | 37 | #define SPIDER_ADD_MODULE_POST_HEADER(module) do {\ 38 | modules_post_header.push_back(module); \ 39 | } while(0) 40 | 41 | 42 | /* The modules in this queue are used after finishing read html */ 43 | extern vector modules_post_html; 44 | 45 | #define SPIDER_ADD_MODULE_POST_HTML(module) do {\ 46 | modules_post_html.push_back(module); \ 47 | } while(0) 48 | 49 | /* Dynamic load modules while spiderq is starting */ 50 | extern Module * dso_load(const char *path, const char *name); 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /spiderq/src/hashs.cpp: -------------------------------------------------------------------------------- 1 | #include "hashs.h" 2 | 3 | unsigned int times33(char *str) 4 | { 5 | unsigned int val = 0; 6 | while (*str) 7 | val = (val << 5) + val + (*str++); 8 | return val; 9 | } 10 | 11 | unsigned int timesnum(char *str, int num) 12 | { 13 | unsigned int val = 0; 14 | while (*str) 15 | val = val * num + (*str++); 16 | return val; 17 | } 18 | 19 | unsigned int aphash(char *str) 20 | { 21 | unsigned int val = 0; 22 | int i = 0; 23 | for (i = 0; *str; i++) 24 | if ((i & 1) == 0) 25 | val ^= ((val << 7)^(*str++)^(val>>3)); 26 | else 27 | val ^= (~((val << 11)^(*str++)^(val>>5))); 28 | 29 | return (val & 0x7FFFFFFF); 30 | } 31 | 32 | 33 | unsigned int hash16777619(char *str) 34 | { 35 | unsigned int val = 0; 36 | while (*str) { 37 | val *= 16777619; 38 | val ^= (unsigned int)(*str++); 39 | } 40 | return val; 41 | } 42 | 43 | unsigned int mysqlhash(char *str) 44 | { 45 | register unsigned int nr = 1, nr2 = 4; 46 | while(*str) { 47 | nr ^= (((nr & 63) + nr2)*((unsigned int)*str++)) + (nr << 8); 48 | nr2 += 3; 49 | } 50 | return (unsigned int)nr; 51 | } 52 | 53 | 54 | -------------------------------------------------------------------------------- /spiderq/src/hashs.h: -------------------------------------------------------------------------------- 1 | #ifndef HASHS_H 2 | #define HASHS_H 3 | 4 | extern unsigned int times33(char *str); 5 | extern unsigned int timesnum(char *str, int num); 6 | extern unsigned int aphash(char *str); 7 | extern unsigned int hash16777619(char *str); 8 | extern unsigned int mysqlhash(char *str); 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /spiderq/src/md5.h: -------------------------------------------------------------------------------- 1 | #ifndef MD5_H 2 | #define MD5_H 3 | 4 | typedef struct 5 | { 6 | unsigned int count[2]; 7 | unsigned int state[4]; 8 | unsigned char buffer[64]; 9 | }MD5_CTX; 10 | 11 | 12 | #define F(x,y,z) ((x & y) | (~x & z)) 13 | #define G(x,y,z) ((x & z) | (y & ~z)) 14 | #define H(x,y,z) (x^y^z) 15 | #define I(x,y,z) (y ^ (x | ~z)) 16 | #define ROTATE_LEFT(x,n) ((x << n) | (x >> (32-n))) 17 | #define FF(a,b,c,d,x,s,ac) \ 18 | { \ 19 | a += F(b,c,d) + x + ac; \ 20 | a = ROTATE_LEFT(a,s); \ 21 | a += b; \ 22 | } 23 | #define GG(a,b,c,d,x,s,ac) \ 24 | { \ 25 | a += G(b,c,d) + x + ac; \ 26 | a = ROTATE_LEFT(a,s); \ 27 | a += b; \ 28 | } 29 | #define HH(a,b,c,d,x,s,ac) \ 30 | { \ 31 | a += H(b,c,d) + x + ac; \ 32 | a = ROTATE_LEFT(a,s); \ 33 | a += b; \ 34 | } 35 | #define II(a,b,c,d,x,s,ac) \ 36 | { \ 37 | a += I(b,c,d) + x + ac; \ 38 | a = ROTATE_LEFT(a,s); \ 39 | a += b; \ 40 | } 41 | 42 | extern void MD5Init(MD5_CTX *context); 43 | extern void MD5Update(MD5_CTX *context,unsigned char *input,unsigned int inputlen); 44 | extern void MD5Final(MD5_CTX *context,unsigned char digest[16]); 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /spiderq/src/qstring.h: -------------------------------------------------------------------------------- 1 | #ifndef QSTRING_H 2 | #define QSTRING_H 3 | 4 | /* Concat multi strings into one. 5 | * argc: the number of strings 6 | */ 7 | extern char * strcat2(int argc, const char *str1, const char * str2, ...); 8 | 9 | /* Trim the string. This function will NOT allocate new memory */ 10 | extern char * strim(char *str); 11 | 12 | /* Split string. 13 | * count: size of splitted strings 14 | * limit: how many times to split string 15 | */ 16 | extern char ** strsplit(char *line, char delimeter, int *count, int limit); 17 | 18 | /* Turn 'yes' or 'no' to integer, or -1 if error 19 | * Case insensitive! 20 | */ 21 | extern int yesnotoi(char *str); 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /spiderq/src/sha1.h: -------------------------------------------------------------------------------- 1 | #ifndef SHA1_H 2 | #define SHA1_H 3 | 4 | typedef unsigned int u32; 5 | 6 | typedef struct { 7 | u32 h0,h1,h2,h3,h4; 8 | u32 nblocks; 9 | unsigned char buf[64]; 10 | int count; 11 | } SHA1_CONTEXT; 12 | 13 | 14 | extern void sha1_init(SHA1_CONTEXT *hd); 15 | extern void sha1_write(SHA1_CONTEXT *hd, unsigned char *inbuf, size_t inlen); 16 | extern void sha1_final(SHA1_CONTEXT *hd); 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /spiderq/src/socket.h: -------------------------------------------------------------------------------- 1 | #ifndef QSOCKET_H 2 | #define QSOCKET_H 3 | 4 | #include "url.h" 5 | 6 | /* struct for http header */ 7 | typedef struct Header { 8 | char *content_type; 9 | int status_code; 10 | } Header; 11 | 12 | typedef struct Response { 13 | Header *header; 14 | char *body; 15 | int body_len; 16 | 17 | struct Url *url; 18 | } Response; 19 | 20 | /* create socket and connect */ 21 | extern int build_connect(int *fd, char *ip, int port); 22 | 23 | /* write http request to socket */ 24 | extern int send_request(int fd, void *arg); 25 | 26 | /* set socket nonblock */ 27 | extern void set_nonblocking(int fd); 28 | 29 | /* read and deal data from socket triggered by epoll_wait */ 30 | extern void * recv_response(void *arg); 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /spiderq/src/spider.h: -------------------------------------------------------------------------------- 1 | #ifndef SPIDER_H 2 | #define SPIDER_H 3 | 4 | #include 5 | #include 6 | #include "url.h" 7 | #include "socket.h" 8 | #include "threads.h" 9 | #include "confparser.h" 10 | #include "dso.h" 11 | 12 | /* macros */ 13 | #define MAX_MESG_LEN 1024 14 | 15 | #define SPIDER_LEVEL_DEBUG 0 16 | #define SPIDER_LEVEL_INFO 1 17 | #define SPIDER_LEVEL_WARN 2 18 | #define SPIDER_LEVEL_ERROR 3 19 | #define SPIDER_LEVEL_CRIT 4 20 | 21 | static const char * LOG_STR[] = { 22 | "DEBUG", 23 | "INFO", 24 | "WARN", 25 | "ERROR", 26 | "CRIT" 27 | }; 28 | 29 | extern Config *g_conf; 30 | 31 | #define SPIDER_LOG(level, format, ...) do{ \ 32 | if (level >= g_conf->log_level) {\ 33 | time_t now = time(NULL); \ 34 | char msg[MAX_MESG_LEN]; \ 35 | char buf[32]; \ 36 | sprintf(msg, format, ##__VA_ARGS__); \ 37 | strftime(buf, sizeof(buf), "%Y%m%d %H:%M:%S", localtime(&now)); \ 38 | fprintf(stdout, "[%s] [%s] %s\n", buf, LOG_STR[level], msg); \ 39 | fflush(stdout); \ 40 | } \ 41 | if (level == SPIDER_LEVEL_ERROR) {\ 42 | exit(-1); \ 43 | } \ 44 | } while(0) 45 | 46 | 47 | extern int attach_epoll_task(); 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /spiderq/src/threads.cpp: -------------------------------------------------------------------------------- 1 | #include "threads.h" 2 | #include "spider.h" 3 | #include "confparser.h" 4 | 5 | /* the number of current running thread */ 6 | int g_cur_thread_num = 0; 7 | 8 | /* lock for changing g_cur_thread_num's value */ 9 | pthread_mutex_t gctn_lock = PTHREAD_MUTEX_INITIALIZER; 10 | 11 | // 设置线程可分离 12 | // http://blog.csdn.net/lhf_tiger/article/details/8291984 13 | int create_thread(void *(*start_func)(void *), void * arg, pthread_t *pid, pthread_attr_t * pattr) 14 | { 15 | pthread_attr_t attr; 16 | pthread_t pt; 17 | 18 | if (pattr == NULL) { 19 | pattr = &attr; 20 | pthread_attr_init(pattr); 21 | pthread_attr_setstacksize(pattr, 1024*1024); 22 | pthread_attr_setdetachstate(pattr, PTHREAD_CREATE_DETACHED); 23 | } 24 | 25 | if (pid == NULL) 26 | pid = &pt; 27 | 28 | int rv = pthread_create(pid, pattr, start_func, arg); 29 | pthread_attr_destroy(pattr); 30 | return rv; 31 | } 32 | 33 | void begin_thread() 34 | { 35 | SPIDER_LOG(SPIDER_LEVEL_DEBUG, "Begin Thread %lu", pthread_self()); 36 | } 37 | 38 | void end_thread() 39 | { 40 | pthread_mutex_lock(&gctn_lock); 41 | int left = g_conf->max_job_num - (--g_cur_thread_num); 42 | if (left == 1) { 43 | /* can start one thread */ 44 | attach_epoll_task(); 45 | } else if (left > 1) { 46 | /* can start two thread */ 47 | attach_epoll_task(); 48 | attach_epoll_task(); 49 | } else { 50 | /* have reached g_conf->max_job_num , do nothing */ 51 | } 52 | SPIDER_LOG(SPIDER_LEVEL_DEBUG, "End Thread %lu, cur_thread_num=%d", pthread_self(), g_cur_thread_num); 53 | pthread_mutex_unlock(&gctn_lock); 54 | } 55 | -------------------------------------------------------------------------------- /spiderq/src/threads.h: -------------------------------------------------------------------------------- 1 | #ifndef QTHREADS_H 2 | #define QTHREADS_H 3 | 4 | #include 5 | 6 | extern int create_thread(void *(*start_routine) (void *), void *arg, pthread_t * thread, pthread_attr_t * pAttr); 7 | extern void begin_thread(); 8 | extern void end_thread(); 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /spiderq/src/url.h: -------------------------------------------------------------------------------- 1 | #ifndef QURL_H 2 | #define QURL_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include "spider.h" 14 | #include "bloomfilter.h" 15 | 16 | using namespace std; 17 | 18 | #define MAX_LINK_LEN 128 19 | 20 | #define TYPE_HTML 0 21 | #define TYPE_IMAGE 1 22 | 23 | typedef struct Surl { 24 | char *url; 25 | int level; 26 | int type; 27 | } Surl; 28 | 29 | typedef struct Url { 30 | char *domain; 31 | char *path; 32 | int port; 33 | char *ip; 34 | int level; 35 | } Url; 36 | 37 | typedef struct evso_arg { 38 | int fd; 39 | Url *url; 40 | } evso_arg; 41 | 42 | extern void push_surlqueue(Surl * url); 43 | extern Url * pop_ourlqueue(); 44 | extern void * urlparser(void * arg); 45 | extern char * url2fn(const Url * url); 46 | extern char * url_normalized(char *url); 47 | extern void free_url(Url * ourl); 48 | extern int is_ourlqueue_empty(); 49 | extern int is_surlqueue_empty(); 50 | extern int get_surl_queue_size(); 51 | extern int get_ourl_queue_size(); 52 | extern int extract_url(regex_t *re, char *str, Url *domain); 53 | extern int iscrawled(char * url); 54 | extern char * attach_domain(char *url, const char *domain); 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /tinyhttpd/Makefile: -------------------------------------------------------------------------------- 1 | all: httpd 2 | 3 | httpd: httpd.c 4 | gcc -W -Wall -o httpd httpd.c -lpthread 5 | 6 | clean: 7 | rm httpd 8 | -------------------------------------------------------------------------------- /tinyhttpd/README.md: -------------------------------------------------------------------------------- 1 | # tinyhttpd-0.1.0 源码分析 2 | ## 简介 3 | tinyhttpd是一个超轻量型Http Server,使用C语言开发,全部代码只有502行(包括注释),附带一个简单的Client,可以通过阅读这段代码理解一个 Http Server 的本质。 4 | 5 | ## 编译 6 | 7 | 错误比较多,我博客里对此做了些说明: 8 | [tinyhttpd源码改正和剖析](http://armsword.com/2014/10/29/tinyhttpd-code-analyse.html) 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /tinyhttpd/htdocs/README: -------------------------------------------------------------------------------- 1 | These are sample CGI scripts and webpages for tinyhttpd. They can 2 | be redistributed under the terms of the GPL. 3 | 4 | The most impressive demonstration I gave of tinyhttpd to my 5 | professor and my classmates was to load color.cgi with a value of 6 | "chartreuse." :) It's actually a very simple script, guys. 7 | 8 | jdb 9 | -------------------------------------------------------------------------------- /tinyhttpd/htdocs/check.cgi: -------------------------------------------------------------------------------- 1 | #!/usr/local/bin/perl -Tw 2 | 3 | use strict; 4 | use CGI; 5 | 6 | my($cgi) = new CGI; 7 | 8 | print $cgi->header('text/html'); 9 | print $cgi->start_html(-title => "Example CGI script", 10 | -BGCOLOR => 'red'); 11 | print $cgi->h1("CGI Example"); 12 | print $cgi->p, "This is an example of CGI\n"; 13 | print $cgi->p, "Parameters given to this script:\n"; 14 | print "
    \n"; 15 | foreach my $param ($cgi->param) 16 | { 17 | print "
  • ", "$param ", $cgi->param($param), "\n"; 18 | } 19 | print "
"; 20 | print $cgi->end_html, "\n"; 21 | -------------------------------------------------------------------------------- /tinyhttpd/htdocs/color.cgi: -------------------------------------------------------------------------------- 1 | #!/usr/local/bin/perl -Tw 2 | 3 | use strict; 4 | use CGI; 5 | 6 | my($cgi) = new CGI; 7 | 8 | print $cgi->header; 9 | my($color) = "blue"; 10 | $color = $cgi->param('color') if defined $cgi->param('color'); 11 | 12 | print $cgi->start_html(-title => uc($color), 13 | -BGCOLOR => $color); 14 | print $cgi->h1("This is $color"); 15 | print $cgi->end_html; 16 | -------------------------------------------------------------------------------- /tinyhttpd/htdocs/index.html: -------------------------------------------------------------------------------- 1 | 2 | Index 3 | 4 |

Welcome to J. David's webserver. 5 |

CGI demo 6 |
7 | Enter a color: 8 | 9 |
10 | 11 | 12 | -------------------------------------------------------------------------------- /tinyhttpd/simpleclient.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | int main(int argc, char *argv[]) 9 | { 10 | int sockfd; 11 | int len; 12 | struct sockaddr_in address; 13 | int result; 14 | char ch = 'A'; 15 | 16 | sockfd = socket(AF_INET, SOCK_STREAM, 0); 17 | address.sin_family = AF_INET; 18 | address.sin_addr.s_addr = inet_addr("127.0.0.1"); 19 | address.sin_port = htons(9734); 20 | len = sizeof(address); 21 | result = connect(sockfd, (struct sockaddr *)&address, len); 22 | 23 | if (result == -1) 24 | { 25 | perror("oops: client1"); 26 | exit(1); 27 | } 28 | write(sockfd, &ch, 1); 29 | read(sockfd, &ch, 1); 30 | printf("char from server = %c\n", ch); 31 | close(sockfd); 32 | exit(0); 33 | } 34 | -------------------------------------------------------------------------------- /webbench-1.5/Makefile: -------------------------------------------------------------------------------- 1 | CFLAGS?= -Wall -ggdb -W -O 2 | CC?= gcc 3 | LIBS?= 4 | LDFLAGS?= 5 | PREFIX?= /usr/local 6 | VERSION=1.5 7 | TMPDIR=/tmp/webbench-$(VERSION) 8 | 9 | all: webbench tags 10 | 11 | tags: *.c 12 | -ctags *.c 13 | 14 | install: webbench 15 | install -s webbench $(DESTDIR)$(PREFIX)/bin 16 | install -m 644 webbench.1 $(DESTDIR)$(PREFIX)/man/man1 17 | install -d $(DESTDIR)$(PREFIX)/share/doc/webbench 18 | install -m 644 debian/copyright $(DESTDIR)$(PREFIX)/share/doc/webbench 19 | install -m 644 debian/changelog $(DESTDIR)$(PREFIX)/share/doc/webbench 20 | 21 | webbench: webbench.o Makefile 22 | $(CC) $(CFLAGS) $(LDFLAGS) -o webbench webbench.o $(LIBS) 23 | 24 | clean: 25 | -rm -f *.o webbench *~ core *.core tags 26 | 27 | tar: clean 28 | -debian/rules clean 29 | rm -rf $(TMPDIR) 30 | install -d $(TMPDIR) 31 | cp -p Makefile webbench.c socket.c webbench.1 $(TMPDIR) 32 | install -d $(TMPDIR)/debian 33 | -cp -p debian/* $(TMPDIR)/debian 34 | ln -sf debian/copyright $(TMPDIR)/COPYRIGHT 35 | ln -sf debian/changelog $(TMPDIR)/ChangeLog 36 | -cd $(TMPDIR) && cd .. && tar cozf webbench-$(VERSION).tar.gz webbench-$(VERSION) 37 | 38 | webbench.o: webbench.c socket.c Makefile 39 | 40 | .PHONY: clean install all tar 41 | -------------------------------------------------------------------------------- /webbench-1.5/socket.c: -------------------------------------------------------------------------------- 1 | /* $Id: socket.c 1.1 1995/01/01 07:11:14 cthuang Exp $ 2 | * 3 | * This module has been modified by Radim Kolar for OS/2 emx 4 | */ 5 | 6 | /*********************************************************************** 7 | module: socket.c 8 | program: popclient 9 | SCCS ID: @(#)socket.c 1.5 4/1/94 10 | programmer: Virginia Tech Computing Center 11 | compiler: DEC RISC C compiler (Ultrix 4.1) 12 | environment: DEC Ultrix 4.3 13 | description: UNIX sockets code. 14 | ***********************************************************************/ 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | int Socket(const char *host, int clientPort) 30 | { 31 | int sock; 32 | unsigned long inaddr; 33 | struct sockaddr_in ad; 34 | struct hostent *hp; 35 | 36 | memset(&ad, 0, sizeof(ad)); 37 | ad.sin_family = AF_INET; 38 | 39 | // 将字符串转换为32位二进制网络字节序的IPv4地址 40 | inaddr = inet_addr(host); 41 | if (inaddr != INADDR_NONE) 42 | memcpy(&ad.sin_addr, &inaddr, sizeof(inaddr)); 43 | else 44 | { 45 | // 使用域名或主机名获取ip地址 46 | hp = gethostbyname(host); 47 | if (hp == NULL) 48 | return -1; 49 | memcpy(&ad.sin_addr, hp->h_addr, hp->h_length); 50 | } 51 | ad.sin_port = htons(clientPort); 52 | 53 | sock = socket(AF_INET, SOCK_STREAM, 0); 54 | if (sock < 0) 55 | return sock; 56 | if (connect(sock, (struct sockaddr *)&ad, sizeof(ad)) < 0) 57 | return -1; 58 | return sock; 59 | } 60 | 61 | --------------------------------------------------------------------------------