From 7ead5b7a9ea99a3e0f1459187b3262f7054f0126 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sun, 21 Nov 2010 16:18:08 +0000 Subject: --- COPYING | 339 ++++++++++++ ChangeLog | 484 ++++++++++++++++ Makefile.in | 12 + README | 256 +++++++++ base.cpp | 65 +++ base.h | 71 +++ chat.cpp | 147 +++++ chat.h | 46 ++ cmnd.cpp | 19 + cmnd.h | 18 + conf.cpp | 75 +++ conf.h | 24 + conf.txt | 63 +++ configure | 1555 ++++++++++++++++++++++++++++++++++++++++++++++++++++ configure.in | 28 + cont.cpp | 24 + cont.h | 26 + glob.h | 68 +++ hmap.cpp | 180 ++++++ hmap.h | 118 ++++ html.cpp | 140 +++++ html.h | 42 ++ html/blank.html | 4 + html/favicon.ico | Bin 0 -> 2238 bytes html/frameset.html | 20 + html/index.html | 32 ++ html/input.html | 34 ++ html/notfound.html | 10 + html/online.html | 7 + html/stream.html | 30 + html/style.css | 11 + html/y_ani.gif | Bin 0 -> 35107 bytes html/y_black.gif | Bin 0 -> 61100 bytes incl.h | 16 + lang.cpp | 78 +++ lang.h | 24 + lang/de | 3 + lang/en | 3 + logd.cpp | 65 +++ logd.h | 24 + main.cpp | 98 ++++ modl.cpp | 98 ++++ modl.h | 29 + msgs.h | 36 ++ mutx.cpp | 20 + mutx.h | 21 + name.cpp | 32 ++ name.h | 28 + pool.cpp | 214 ++++++++ pool.h | 77 +++ reqp.cpp | 291 ++++++++++ reqp.h | 47 ++ room.cpp | 18 + room.h | 34 ++ s_chat.cpp | 10 + s_chat.h | 26 + s_conf.cpp | 10 + s_conf.h | 26 + s_html.cpp | 10 + s_html.h | 26 + s_lang.cpp | 10 + s_lang.h | 26 + s_modl.cpp | 10 + s_modl.h | 26 + s_mutx.cpp | 10 + s_mutx.h | 26 + s_sman.cpp | 10 + s_sman.h | 26 + s_sock.cpp | 10 + s_sock.h | 26 + s_tool.cpp | 111 ++++ s_tool.h | 19 + sess.cpp | 35 ++ sess.h | 28 + sman.cpp | 48 ++ sman.h | 32 ++ sock.cpp | 238 ++++++++ sock.h | 53 ++ thrd.cpp | 28 + thrd.h | 26 + todo.txt | 11 + user.cpp | 170 ++++++ user.h | 84 +++ 83 files changed, 6375 insertions(+) create mode 100644 COPYING create mode 100644 ChangeLog create mode 100644 Makefile.in create mode 100644 README create mode 100644 base.cpp create mode 100644 base.h create mode 100644 chat.cpp create mode 100644 chat.h create mode 100644 cmnd.cpp create mode 100644 cmnd.h create mode 100644 conf.cpp create mode 100644 conf.h create mode 100644 conf.txt create mode 100755 configure create mode 100644 configure.in create mode 100644 cont.cpp create mode 100644 cont.h create mode 100644 glob.h create mode 100644 hmap.cpp create mode 100644 hmap.h create mode 100644 html.cpp create mode 100644 html.h create mode 100644 html/blank.html create mode 100644 html/favicon.ico create mode 100644 html/frameset.html create mode 100644 html/index.html create mode 100644 html/input.html create mode 100644 html/notfound.html create mode 100644 html/online.html create mode 100644 html/stream.html create mode 100644 html/style.css create mode 100644 html/y_ani.gif create mode 100644 html/y_black.gif create mode 100644 incl.h create mode 100644 lang.cpp create mode 100644 lang.h create mode 100644 lang/de create mode 100644 lang/en create mode 100644 logd.cpp create mode 100644 logd.h create mode 100644 main.cpp create mode 100644 modl.cpp create mode 100644 modl.h create mode 100644 msgs.h create mode 100644 mutx.cpp create mode 100644 mutx.h create mode 100644 name.cpp create mode 100644 name.h create mode 100644 pool.cpp create mode 100644 pool.h create mode 100644 reqp.cpp create mode 100644 reqp.h create mode 100644 room.cpp create mode 100644 room.h create mode 100644 s_chat.cpp create mode 100644 s_chat.h create mode 100644 s_conf.cpp create mode 100644 s_conf.h create mode 100644 s_html.cpp create mode 100644 s_html.h create mode 100644 s_lang.cpp create mode 100644 s_lang.h create mode 100644 s_modl.cpp create mode 100644 s_modl.h create mode 100644 s_mutx.cpp create mode 100644 s_mutx.h create mode 100644 s_sman.cpp create mode 100644 s_sman.h create mode 100644 s_sock.cpp create mode 100644 s_sock.h create mode 100644 s_tool.cpp create mode 100644 s_tool.h create mode 100644 sess.cpp create mode 100644 sess.h create mode 100644 sman.cpp create mode 100644 sman.h create mode 100644 sock.cpp create mode 100644 sock.h create mode 100644 thrd.cpp create mode 100644 thrd.h create mode 100644 todo.txt create mode 100644 user.cpp create mode 100644 user.h diff --git a/COPYING b/COPYING new file mode 100644 index 0000000..a43ea21 --- /dev/null +++ b/COPYING @@ -0,0 +1,339 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 675 Mass Ave, Cambridge, MA 02139, USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + Appendix: How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) 19yy + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) 19yy name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/ChangeLog b/ChangeLog new file mode 100644 index 0000000..b3ada67 --- /dev/null +++ b/ChangeLog @@ -0,0 +1,484 @@ +2003-09-14 16:55 snooper + + * cmnd/yc_version.cpp: Added /version command. + +2003-09-14 16:48 snooper + + * README, msgs.h: Changed Version to 0.5 ( Will be released as soon + as possible ). + +2003-09-14 16:34 snooper + + * msgs.h: Changed version description. + +2003-09-14 16:31 snooper + + * README, conf.txt, glob.h, reqp.cpp, sock.cpp, cmnd/compile.sh: + Fixed all known bugs which already have been fixed in yChat++ + Advanced. + +2003-09-13 20:52 snooper + + * gfx/y_ani_black.gif, gfx/y_ani_white.gif, html/favicon.ico: [no + log message] + +2003-09-07 14:49 snooper + + * pool.cpp: + Removed a pthread_cond_signal which has been set twice! + +2003-09-06 23:34 rover + + * pool.cpp: fixed a typo ( multi thread bug ) + +2003-09-03 18:30 rover + + * reqp.cpp: modified End-Of-Headers to RFC compliant version + +2003-07-26 14:30 snooper + + * reqp.cpp: Added Pragma: no-cache and Expires: 0 to the HTTP + header. ( this is a bugfix ). + +2003-04-19 21:39 rover + + * chat.cpp, reqp.cpp, sess.cpp, sess.h, sman.h, sock.cpp, user.h: + identification now only depends on session + +2003-04-19 18:16 rover + + * Makefile.in, chat.cpp, chat.h, conf.txt, main.cpp, s_sman.cpp, + sess.cpp, sman.cpp, s_sman.h, sess.h, sman.h: added session + manager and session object. + +2003-04-10 17:36 rover + + * logd.cpp: fixed a typo + +2003-04-07 15:24 rover + + * hmap.cpp: added a really really important newline ( this is just + a loginfo test ) + +2003-04-07 15:18 rover + + * msgs.h: message templates are now replaced by language manager + +2003-04-05 00:17 rover + + * Makefile.in: language support + +2003-04-05 00:14 rover + + * chat.cpp, chat.h, conf.txt, lang.cpp, lang.h, main.cpp, + s_lang.cpp, s_lang.h, sock.cpp, user.cpp, user.h, lang/de, + lang/en: support for different languages in chat output + +2003-04-04 23:35 rover + + * conf.cpp, conf.txt, glob.h, s_conf.h, sock.cpp: another bug that + was caused due sed conversion + +2003-04-04 17:42 rover + + * Makefile.in: added log_daemon + +2003-04-04 17:19 rover + + * conf.txt, logd.cpp, logd.h, reqp.cpp, reqp.h, sock.cpp, sock.h: + added access log compatible logging + +2003-04-04 13:13 rover + + * sock.cpp: added IP / PORT to map_params to make logging possible + with only this map + +2003-04-04 12:41 rover + + * s_tool.cpp, s_tool.h: added trim() function to strip whitespaces + at the beginning and end of a string + +2003-04-04 12:40 rover + + * reqp.cpp, reqp.h: http headers are now stored in the requestmap + +2003-04-03 01:01 snooper + + * s_modl.cpp, s_modl.h, user.h: Minor modifications. New static + class wrapper. + +2003-04-02 23:57 snooper + + * Makefile.in, chat.h, conf.txt, main.cpp, modl.cpp, sock.cpp, + user.cpp, user.h, cmnd/yc_q.cpp: Added first command. /q ... + Todo: each user should have his own hashmap of executable + modules. Right now all users use the same module hash map. + +2003-04-02 15:23 rover + + * modl.cpp, modl.h: module loader + +2003-04-02 12:52 snooper + + * dltest.cpp, yc_test.cpp, cmnd/yc_q.cpp, cmnd/yc_test.cpp: [no log + message] + +2003-04-02 12:50 snooper + + * Makefile.in, README, base.cpp, base.h, chat.cpp, chat.h, + conf.cpp, dltest.cpp, glob.h, hmap.cpp, hmap.h, html.cpp, msgs.h, + reqp.cpp, reqp.h, sock.cpp: Dynamic module loader class. Better + hash map functionality. Some bugfixes. + +2003-03-30 15:40 paul + + * hmap.h: + Implementation of operator[]. + +2003-03-30 13:12 volker + + * html/: style.css, y_black.gif: added stylesheet and an image + +2003-03-30 03:48 paul + + * todo.txt: [no log message] + +2003-03-30 03:35 paul + + * base.cpp, conf.txt, hmap.cpp, hmap.h: The hach map now supports + explicit key bindings on each value. The [] operator still has to + be implemented. + +2003-03-30 01:34 volker + + * conf.txt, html/index.html, html/input.html, html/online.html, + html/stream.html: modified appearance and added css + +2003-03-30 01:26 paul + + * README, README.txt, cont.h: Renamed. + +2003-03-30 01:14 paul + + * base.cpp, base.h, hmap.cpp, hmap.h: All user objects and all room + objects are stored in a hash map. + +2003-03-30 01:06 volker + + * conf.txt, reqp.cpp, reqp.h, s_tool.cpp, s_tool.h: support for + different content-types + +2003-03-30 00:21 paul + + * hmap.cpp, hmap.h, main.cpp: Now handles pointer of data objects + instead of references. + +2003-03-30 00:18 volker + + * html.cpp: removed possible deadlock + +2003-03-30 00:11 volker + + * conf.txt, html.cpp: changed format how files are read into + templatecache + +2003-03-28 17:16 volker + + * todo.txt: todo is now up to date + +2003-03-28 03:51 paul + + * data.h: + + Removed data.h + +2003-03-28 03:51 paul + + * README.txt, base.h, chat.h, data.h, room.h: + + Put data.h and base.h together. + +2003-03-28 03:08 paul + + * README.txt: + + Actualizing because of the new configure script. + +2003-03-28 03:02 volker + + * configure, configure.in: [no log message] + +2003-03-28 02:59 volker + + * configure, configure.in: -ldl is not needed under *bsd. Added a + check + +2003-03-28 02:38 volker + + * Makefile, Makefile.in, configure, configure.in: added support for + bsd + +2003-03-28 01:38 volker + + * base.cpp: changed a bug in cvs keywords + +2003-03-28 01:32 volker + + * base.cpp: [no log message] + +2003-03-28 01:27 volker + + * COPYING, configure.in: this file should be in every repository ;) + +2003-03-28 01:18 volker + + * Makefile, Makefile.in, configure, configure.in: configure + dependent files + +2003-03-28 00:22 paul + + * hmap.cpp, hmap.h: + + Optimization of the hash map. + +2003-03-27 17:14 volker + + * dltest.cpp, yc_test.cpp: Dynamic module test + +2003-03-26 18:50 paul + + * html/index.html: + + Changed POST back to GET due read bug. + +2003-03-26 17:40 paul + + * reqp.cpp: + + Bugfix. + +2003-03-26 16:44 paul + + * reqp.cpp, sock.cpp, sock.h: + + Fixed segfault bug. ( stream.html request without existing user + object ). + +2003-03-26 16:17 paul + + * sock.cpp: + + Deletion of variables which are no longer needed after procession + ( e.g. map_params ). + +2003-03-26 15:57 paul + + * thrd.cpp: + + Bugfix. Now every socket connection will be closed the right way + ;). + +2003-03-26 00:03 paul + + * chat.cpp, chat.h, sock.cpp: + + Bugfix + added to the class chat a private bool b_strip_html + member. + +2003-03-25 23:52 paul + + * chat.cpp: + + Style fix. + +2003-03-25 23:41 paul + + * msgs.h, sock.cpp: + + Bugfix. + +2003-03-25 23:21 paul + + * name.h: + + Bugfix. + +2003-03-25 23:19 paul + + * Makefile, README.txt, base.cpp, base.h, conf.txt, data.h, + hmap.cpp, hmap.h, name.cpp, name.h: + + Changed because of hashmap integration. base.cpp and base.h still + have to be modified. Afterwards, all user and rooms will be + stored in a hash map. + +2003-03-25 21:06 paul + + * Makefile, hmap.cpp, hmap.h, user.h: + + Hash Map implementation. + +2003-03-25 20:12 volker + + * chat.cpp, conf.txt, s_tool.cpp, s_tool.h: added possibility to + turn html tags on/off in chat messages + +2003-03-25 19:53 paul + + * conf.txt, html.cpp: + + Bugfix. + +2003-03-25 18:44 paul + + * conf.txt: + + Bugfix. + +2003-03-25 17:22 volker + + * conf.txt, main.cpp: removed some typos that where created due to + sed conversation + +2003-03-25 15:54 volker + + * CHAT.cpp, CHAT.h, CONF.cpp, CONF.h, HTML.cpp, HTML.h, MUTX.cpp, + MUTX.h, Makefile, README.txt, SOCK.cpp, SOCK.h, TOOL.cpp, TOOL.h, + chat.cpp, chat.h, cmnd.cpp, conf.cpp, conf.h, conf.txt, cont.cpp, + data.h, glob.h, html.cpp, html.h, main.cpp, msgs.h, mutx.cpp, + mutx.h, pool.cpp, reqp.cpp, s_chat.cpp, s_chat.h, s_conf.cpp, + s_conf.h, s_html.cpp, s_html.h, s_mutx.cpp, s_mutx.h, s_sock.cpp, + s_sock.h, s_tool.cpp, s_tool.h, sock.cpp, sock.h, thrd.cpp, + user.cpp: changed filenames to windows compatible ones + +2003-03-25 00:49 paul + + * README.txt: + + Bugfixes. + +2003-03-25 00:40 paul + + * todo.txt: + + New brainstorming. + +2003-03-25 00:16 paul + + * TOOL.cpp, TOOL.h, chat.cpp, msgs.h: + + Added check routine if a login nick is alphanumeric or not. If + not a message will appear on the startpage instead of logging in + which may would end in a segmentation fault. + +2003-03-24 23:45 paul + + * main.cpp: [no log message] + +2003-03-24 23:43 paul + + * README.txt, chat.cpp, msgs.h, user.cpp, user.h: + + Added support for chat commands ( chat commands still have to be + implemented ). If you type "/testhere" ychat will tell that + there is no such command! + +2003-03-24 00:30 paul + + * Makefile, cmnd.cpp, main.cpp, msgs.h, reqp.cpp, reqp.h, sock.cpp, + sock.h, thrd.cpp, user.cpp, user.h: [no log message] + +2003-03-23 23:34 vrichter + + * reqp.cpp: removed bogus sock.h + +2003-03-23 23:29 vrichter + + * reqp.cpp, sock.cpp: bugfix POST system + +2003-03-23 20:03 vrichter + + * html/index.html: changed the method of the login form to POST + +2003-03-23 20:02 vrichter + + * reqp.cpp, reqp.h: the request parser now supports POST + +2003-03-23 16:16 paul + + * pool.cpp: + + Fixed changing date! ( System clock was set wrong ), + +2003-03-23 16:05 paul + + * pool.cpp: [no log message] + +2003-03-23 12:33 paul + + * conf.txt, pool.cpp: [no log message] + +2003-03-23 06:41 paul + + * base.cpp, chat.cpp, conf.cpp, cont.cpp, html.cpp, main.cpp, + mutx.cpp, name.cpp, reqp.cpp, room.cpp, thrd.cpp, user.cpp, + msgs.h: [no log message] + +2003-03-23 06:26 paul + + * pool.cpp: [no log message] + +2003-03-23 05:55 paul + + * Makefile, README.txt, conf.txt, glob.h, main.cpp, msgs.h, + pool.cpp, pool.h, reqp.h, sock.cpp, sock.h: [no log message] + +2003-03-22 23:07 paul + + * README.txt: [no log message] + +2003-03-22 22:56 paul + + * html.h: [no log message] + +2003-03-22 07:40 vrichter + + * reqp.h: fixed a paste error + ---------------------------------------------------------------------- + +2003-03-21 20:38 vrichter + + * yc.tgz, ychat: removed binary files that were transfered + +2003-03-21 19:31 vrichter + + * reqp.cpp, reqp.h, ychat: added url decoding + +2003-03-21 16:54 root + + * CHAT.cpp, CHAT.h, CONF.cpp, CONF.h, HTML.cpp, HTML.h, MUTX.cpp, + MUTX.h, Makefile, README.txt, SOCK.cpp, SOCK.h, TOOL.cpp, TOOL.h, + base.cpp, base.h, chat.cpp, chat.h, cmnd.cpp, cmnd.h, conf.cpp, + conf.h, conf.txt, cont.cpp, cont.h, data.h, glob.h, html.cpp, + html.h, incl.h, main.cpp, msgs.h, mutx.cpp, mutx.h, name.cpp, + name.h, reqp.cpp, reqp.h, room.cpp, room.h, sock.cpp, sock.h, + thrd.cpp, thrd.h, todo.txt, user.cpp, user.h, yc.tgz, ychat, + gfx/y_ani_black.gif, gfx/y_ani_white.gif, html/blank.html, + html/frameset.html, html/index.html, html/input.html, + html/notfound.html, html/online.html, html/stream.html, + html/y_ani.gif: Initial revision + +2003-03-21 16:54 root + + * CHAT.cpp, CHAT.h, CONF.cpp, CONF.h, HTML.cpp, HTML.h, MUTX.cpp, + MUTX.h, Makefile, README.txt, SOCK.cpp, SOCK.h, TOOL.cpp, TOOL.h, + base.cpp, base.h, chat.cpp, chat.h, cmnd.cpp, cmnd.h, conf.cpp, + conf.h, conf.txt, cont.cpp, cont.h, data.h, glob.h, html.cpp, + html.h, incl.h, main.cpp, msgs.h, mutx.cpp, mutx.h, name.cpp, + name.h, reqp.cpp, reqp.h, room.cpp, room.h, sock.cpp, sock.h, + thrd.cpp, thrd.h, todo.txt, user.cpp, user.h, yc.tgz, ychat, + gfx/y_ani_black.gif, gfx/y_ani_white.gif, html/blank.html, + html/frameset.html, html/index.html, html/input.html, + html/notfound.html, html/online.html, html/stream.html, + html/y_ani.gif: imported files into ychat cvs + diff --git a/Makefile.in b/Makefile.in new file mode 100644 index 0000000..300d035 --- /dev/null +++ b/Makefile.in @@ -0,0 +1,12 @@ +SRCS=chat.cpp s_chat.cpp cmnd.cpp conf.cpp s_conf.cpp cont.cpp html.cpp s_html.cpp lang.cpp s_lang.cpp logd.cpp main.cpp modl.cpp s_modl.cpp mutx.cpp s_mutx.cpp name.cpp pool.cpp reqp.cpp room.cpp sock.cpp s_sock.cpp thrd.cpp s_tool.cpp user.cpp sess.cpp sman.cpp s_sman.cpp +OBJS=$(SRCS:.cpp=.o) +CC=g++ +LDFLAGS=@LDFLAGS@ -lstdc++ -g +LDADD=-pthread -D_THREAD_SAFE +all: ychat +$(SRCS): + $(CC) $(CFLAGS) -c $*.cpp +ychat: $(OBJS) + $(CC) $(LDFLAGS) -o $@ $(OBJS) $(LDADD) +clean: + rm *.o diff --git a/README b/README new file mode 100644 index 0000000..3ae4b74 --- /dev/null +++ b/README @@ -0,0 +1,256 @@ +yChat++ Basic; Homepage: www.yChat.org; Version 0.5.1 +Copyright (C) 2003 Paul C. Buetow, Volker Richter +----------------------------------------------------------------- + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +----------------------------------------------------------------- + +0.0.0 YCHAT++ BASIC TABLE OF CONTENTS +1.0.0 REQUIREMENTS +1.1.0 TESTED PLATFORMS +1.2.0 IMPORTANT NOTES +1.3.0 HOW TO OBTAIN YCHAT++ +1.3.1 INSTALLATION +1.5.0 CUSTOMIZATION +1.6.0 FILES +1.7.0 WRITING BUG REPORTS +1.8.0 CONTACT + +1.0.0 REQUIREMENTS: + +- gcc 3.2 + The GNU C++ compiler. + +1.1.0 TESTED PLATFORMS: + +The following platforms have been tested with success: + +- Linux with GCC 3.2.0, GNU make 3.79.1 +- FreeBSD 5.1-RELEASE-p2, GCC 3.2.2, GNU make 3.80 ( standard make does not seem work on FreeBSD ). + +1.2.0 IMPORTANT NOTES: + +Before you compile the source you have to be sure to use at least GCC +version 3.x with pthreads enabled. ( Type gcc -v to check it ). +GCC 2.95 did not work while testing on linux and WON'T BE SUPPORTED! +If you like to support yChat++, please write us an email and tell what +you can/like/would help ;-]. Please also take a look at the yChat++ +homepage which is located at http://www.yChat.org. + +1.3.0 HOW TO OBTAIN YCHAT++: + +yChat can be downloaded as a source package or through CVS. + +The packages are located at http://www.yChat.org -> Sourcecode -> +Packages or go to http://programming.buetow.org/CPP-yChat . + +For CVS download type also look at the homepage please. + +1.3.1 INSTALLATION: + +Invoke "./configure" and afterwards "make", edit the conf.txt. + +Now we want to compile all the dynamic loadable modules of ychat. +Invoke "cd cmnd && ./compile.sh && cd -". All command modules should get +compiled. + +Now its time to run the server with ./ychat. +Then point your webbrowser to http://yourip:port ! + +... have fun :-). + +1.5.0 CUSTOMIZATION: + +If you like to customize the design/layout/language of yChat, you will have +to edit msgs.h and glob.h before you compile the sources. Afterwards you can +change the html-template files which are placed in the html/ subdirectory. +Dynamic loadable modules can be found in the cmnd/ subdirectory. + +1.6.0 FILES: ( This list is not complete ) + +conf.txt - The yChat configuration file. ( read by conf.cpp ). + +base.cpp - Encapsulates vector fields of room's or user ( may be later + hash_maps ) and provides methods for manipulating data + objects. + +hmap.cpp - The hash map implementation which is a very fast data + structure. is needed for saving users, rooms and so on. + +main.cpp - This includes the required manager headers for starting + the server and finally regulates the correct starting. + +modl.cpp - The module loader. Stores pointers of all dynamic loaded + yChat modules in a hash map object and loads new modules + if desired or returns their pointers. + +pool.cpp - The implementation of the thread pool. all threads are stored + in a queue. Each thread will be reused if the assigned job is + finished. + +reqp.cpp - This class implements the http request parser. If a client + starts a request to the server the reqp class will be + invoked. + +room.cpp - Specifies a chat room. For each chat room an instance of + this class exists. + +thrd.cpp - This class is needed by sock.cpp while creating a POSIX thread. + All data which a thread needs to do its tasks are stored in a + thrd object and then a pointer to it will be passed to the + POSIX thread function. + +user.cpp - Specifies a chat user. For each chat user an instance of + this class exists. + +Abstract classes: + +cont.cpp - All classes which need to store "key - value" data sets + inherit from this class. ( cont for content ). + +name.cpp - All classes which own a private member string name inherit + from this class. It also provides public get_name and + set_name methods. + +As described ( main.cpp ), there are so called managers. Managers are +accessible through their assigned wrapper classes and may be +instanciated only once. + +chat.cpp - The chat manager. Is responsible for managing the internal + data structure of the system and also covers a lot of + important methods of the system. + +conf.cpp - The config manager. Parses the config file specified in + glob.h and stores all the values of it in a map. + +html.cpp - The html-template manager. Reads the requested html-template + files, stores them in an internal cache ( averts reading + template-files from hd twice or more ) and parses the + partivular template in order to substituate dynamic values + of it. + +mutx.cpp - The mutex manager. Contains all global mutex handlers for + synchronizing POSIX thread shared data. until now only the + stdout is synchronized by mutx.cpp because most of objects + use their own mutex'. + +sock.cpp - The socket manager. Manages the socket connections. There + are multiplexed sockets. For each requests a new POSIX thread + will be created. + +Files with a leading s_ contain static C++ classes + +s_chat.cpp - Static wrapper for the dynamic chat class. holds one global + reachable instance of chat until the program shuts down. + +s_conf.cpp - Static wrapper for the dynamic conf class. holds one global + reachable instance of conf until the program shuts down. + +s_html.cpp - Static wrapper for the dynamic html class. holds one global + reachable instance of conf until the program shuts down. + +s_mutx.cpp - Static wrapper for the dynamic mutx class. holds one global + reachable instance of conf until the program shuts down. + +s_sock.cpp - Static wrapper for the dynamic sock class. holds one global + reachable instance of conf until the program shuts down. + +s_tool.cpp - Static class which includes some usefull global reachable + methods which are not integraded in independent classes. + +Special header files ( all other header files which are not listed here +belong to their respective .cpp files ): + +glob.h - Defines global variables which are known by compilation + time. + +incl.h - This file is included from every other header file and + includes a set of headers which every class should be able + to use. + +msgs.h - Defines console output messages for verbosity level 0 ( see + glob.h for setting up verbosity levels ). and also defines + all the system messages. you may edit this file for translating + the system user language. + +The basic class structure: + + base base + | | name + | | / \ + | | / \ + chat room user + + cont + / \ + / \ +conf html + +1.7 WRITING BUG REPORTS + +How to submit a good bug report? + +Send them to Bug@yChat.org. + +First you should give the following information: +- yChat version, if CVS (or devel. tarball) then which day? +- operating system / distribution and it's version +- when did it crash? did you do something? can you reproduce the crash? + +Getting backtrace of the crash also helps a lot, especially if yChat crashes randomly. If after crash you see text: + + "segmentation fault (core dumped)" + +It writes a file named "core" or "ychat.core" depending on your OS to directory where you started yChat. If it doesn't print the "(core dumped)" or you can't find the core file, you'll have to raise the limit for max. core file size before running yChat. To do this, say: + + ulimit -c unlimited + +So, if you have the core file and GNU debugger (gdb), you can get the backtrace with: + + gdb ychat core + bt + +Paste all the lines starting from line having #0 at the beginning. + +Here's an example session: + + in reqp::parse(thrd*, std::string, std::map, std::allocator > >&) () + (gdb) bt + #0 0x0805c287 in reqp::parse(thrd*, std::string, std::map, std::allocator > >&) () + #1 0x0806060f in sock::read_write(thrd*, int) () + #2 0x080612ba in thrd::run() () + #3 0x0805a3b8 in pool::run_func(void*) () + #4 0x0805a375 in pool::tpool_thread(void*) () + #5 0x281d44ae in _thread_start () from /usr/lib/libc_r.so.5 + (gdb) + +1.8 CONTACT: + +You may contact us through the following addresses: + +- Homepage + The yChat homepage is located at http://www.yChat.org + +- E-Mail + Paul C. Buetow: Snooper@yChat.org ( core developer ) + Volker Richter: Rover@yChat.org ( core developer ) + Mail@yChat.org ( reaches everybody of yChat ) + +- ICQ + Paul C. Buetow: 11655527 + +- IRC + #ychat at irc.german-elite.net diff --git a/base.cpp b/base.cpp new file mode 100644 index 0000000..c298ef7 --- /dev/null +++ b/base.cpp @@ -0,0 +1,65 @@ +/* + This file is part of yChat + + $Author: cvs $ + $Date: 2004-04-05 10:37:17 $ + + $Header: /cvs/cvsroot/ychat-0.5/base.cpp,v 1.1.1.1 2004-04-05 10:37:17 cvs Exp $ +*/ +// template class data implementation; + +#ifndef BASE_CPP +#define BASE_CPP + +#include "base.h" + +template +base::base() +{ + map_elem = new hmap(80); + pthread_mutex_init (&mut_map_elem, NULL ); +} + +template +base::~base( ) +{ + pthread_mutex_destroy( &mut_map_elem ); +} + +template void +base::add_elem( type* p_type ) +{ + pthread_mutex_lock ( &mut_map_elem ); + map_elem->add_elem ( p_type, p_type->get_name()); + pthread_mutex_unlock( &mut_map_elem ); +} + +template void +base::del_elem( string &s_name ) +{ + pthread_mutex_lock ( &mut_map_elem ); + map_elem->del_elem ( s_name ); + pthread_mutex_unlock( &mut_map_elem ); +} + +template type* +base::get_elem( string &s_name, bool &b_found ) +{ + pthread_mutex_lock ( &mut_map_elem ); + type* p_type = map_elem->get_elem( s_name ); + pthread_mutex_unlock( &mut_map_elem ); + + b_found = p_type == NULL ? false : true; + + return p_type; +} + +template void +base::run_func( void (*func)(type*, void*), void* v_arg ) +{ + pthread_mutex_lock ( &mut_map_elem ); + map_elem->run_func( func, v_arg ); + pthread_mutex_unlock( &mut_map_elem ); +} + +#endif diff --git a/base.h b/base.h new file mode 100644 index 0000000..6f06e4b --- /dev/null +++ b/base.h @@ -0,0 +1,71 @@ +// template class data declaration; + +#ifndef BASE_H +#define BASE_H + +#include "incl.h" +#include "hmap.h" + +template +class base +{ +private: + hmap* map_elem; + pthread_mutex_t mut_map_elem; + +public: + base(); + ~base(); + + virtual void add_elem( type* p_type ); // add a element. + virtual void del_elem( string &s_name ); // delete a alement. + virtual type* get_elem( string &s_name, bool &b_found ); // get a element. + + // execute func on all elements of map_elem. v_pointer is the argument. + virtual void run_func( void (*func)(type*, void*), void* v_arg ); + + // chat::msg_post sends to all users of the system a message. + // room::msg_post sends to all users of the room a message. + // user::msg_post sends to the user a message. + void msg_post( string *s_msg ) + { + run_func( &base::msg_post_ , (void*)s_msg ); + } + static void msg_post_( type* type_obj, void* v_arg ) + { + string *p_msg = (string*) v_arg; + type_obj -> msg_post( p_msg ); + } + + void get_data( map_string *p_map_string ) + { + run_func( &base::get_data_ , (void*)p_map_string ); + } + static void get_data_( type* type_obj, void* v_arg ) + { + map_string *map_params = (map_string*) v_arg; + type_obj -> get_data ( map_params ); + } + + // chat::get_user_list gets a list of all users of the system. + // room::get_user_list gets a list of all users of the room. + // user::get_user_list gets a "list" of a user usernameseperator + void get_user_list( string &s_list, string &s_seperator ) + { + + container c; + c.elem[0] = (void*) &s_list; + c.elem[1] = (void*) &s_seperator; + + run_func( &base::get_user_list_, (void*)&c ); + } + static void get_user_list_( type* type_obj, void* v_arg ) + { + container *c = (container*) v_arg; + type_obj -> get_user_list( *((string*)c->elem[0]), *((string*)c->elem[1]) ); + } +}; + +#include "base.cpp" + +#endif diff --git a/chat.cpp b/chat.cpp new file mode 100644 index 0000000..b845ec3 --- /dev/null +++ b/chat.cpp @@ -0,0 +1,147 @@ +// class chat implementation. + +#ifndef s_chat_CXX +#define s_chat_CXX + +#include "chat.h" +#include "s_conf.h" +#include "s_mutx.h" +#include "s_tool.h" + +using namespace std; + +chat::chat( ) +{ + if ( s_conf::get().get_val( "HTML" ) == "OFF" ) + b_strip_html = true; + else + b_strip_html = false; + +} + +chat::~chat( ) +{ +} + +user* +chat::get_user( string &s_user ) +{ + bool b_flag; + return get_user( s_user, b_flag ); +} + +user* +chat::get_user( string &s_user, bool &b_found ) +{ + container param; + + param.elem[0] = (void*) &s_user ; + param.elem[1] = (void*) &b_found; + + b_found = false; + + run_func( get_user_, (void*)¶m ); + + if ( *( (bool*)param.elem[1] ) ) + return (user*)param.elem[2]; +} + +void +chat::get_user_( room *room_obj, void *v_arg ) +{ + container* param = (container*) v_arg; + param->elem[2] = (void*)room_obj->get_elem( *((string*)param->elem[0]), *((bool*)param->elem[1]) ); +} + +void +chat::login( map_string &map_params ) +{ + string s_user = map_params["nick"]; + + // prove if nick is empty: + if ( s_user.empty() ) + { + map_params["INFO"] = E_NONICK; + map_params["request"] = s_conf::get().get_val( "STARTMPL" ); // redirect to the startpage. + return; + } + + // prove if the nick ist alphanumeric: + else if ( ! s_tool::is_alpha_numeric( s_user ) ) + { + map_params["INFO"] = E_ALPNUM; + map_params["request"] = s_conf::get().get_val( "STARTMPL" ); // redirect to the startpage. + return; + } + + bool b_flag; + + // prove if nick is already online / logged in. + get_user( s_user, b_flag ); + if ( b_flag ) + { + map_params["INFO"] = E_ONLINE; + map_params["request"] = s_conf::get().get_val( "STARTMPL" ); + return; + } + + string s_room = map_params["room"]; + room* p_room = get_room( s_room , b_flag ); + + // if room does not exist add room to list! + if ( ! b_flag ) + { + p_room = new room( s_room ); + +#ifdef VERBOSE + pthread_mutex_lock ( &s_mutx::get().mut_stdout ); + cout << NEWROOM << s_room << endl; + pthread_mutex_unlock( &s_mutx::get().mut_stdout ); +#endif + + add_elem( p_room ); + } + + user *p_user = new user( s_user ); + + // add user to the room. + p_room->add_user( p_user ); + sess *ns =s_sman::get().createSession(); + ns->setValue(string("nick"), (void *)new string(s_user) ); + map_params["tmpid"]=ns->getId(); + // post "username enters the chat" into the room. + p_room->msg_post( new string( s_user.append( s_lang::get().get_val( "USERENTR" ) ) ) ); + +#ifdef VERBOSE + pthread_mutex_lock ( &s_mutx::get().mut_stdout ); + cout << LOGINPR << s_user << endl; + pthread_mutex_unlock( &s_mutx::get().mut_stdout ); +#endif +} + +void +chat::post( user* p_user, map_string &map_params ) +{ + + string s_msg( map_params["message"] ); + + auto unsigned i_pos = s_msg.find( "/" ); + if ( i_pos == 0 ) + return p_user->command( s_msg ); + + if ( b_strip_html ) + s_tool::strip_html( &s_msg ); + + string s_post( "get_col1() ) + .append( "\">" ) + .append( p_user->get_name() ) + .append( ": " ) + .append( s_msg ) + .append( "
\n" ); + + p_user->get_p_room()->msg_post( &s_post ); +} + +#endif diff --git a/chat.h b/chat.h new file mode 100644 index 0000000..60bcf9d --- /dev/null +++ b/chat.h @@ -0,0 +1,46 @@ +// class chat declaration. + +#ifndef s_chat_H +#define s_chat_H + +#include +#include "incl.h" +#include "base.h" +#include "room.h" +#include "user.h" +#include "sess.h" +#include "s_lang.h" +#include "s_sman.h" + +using namespace std; + +class chat : public base +{ +private: + bool b_strip_html; + +public: + + + room* get_room( string &s_name, bool &b_found ) + { + return static_cast( get_elem( s_name, b_found ) ); + } + + // public methods: + explicit chat(); // a standard constructor. + ~chat(); // destructor. + + // get the object of a specific user. + virtual user* get_user( string &s_nick ); + virtual user* get_user( string &s_nick, bool &b_found ); + static void get_user_( room* room_obj, void *v_arg ); + + // will be called every time a user tries to login. + virtual void login( map_string &map_params ); + + // will be called if a user posts a message. + virtual void post ( user* u_user, map_string &map_params ); +}; + +#endif diff --git a/cmnd.cpp b/cmnd.cpp new file mode 100644 index 0000000..28e73a7 --- /dev/null +++ b/cmnd.cpp @@ -0,0 +1,19 @@ +// class cmnd implementation. + +#ifndef CMND_CXX +#define CMND_CXX + +#include "cmnd.h" +#include "s_mutx.h" + +using namespace std; + +cmnd::cmnd( ) +{ +} + +cmnd::~cmnd() +{ +} + +#endif diff --git a/cmnd.h b/cmnd.h new file mode 100644 index 0000000..2eb1db2 --- /dev/null +++ b/cmnd.h @@ -0,0 +1,18 @@ +// class cmnd declaration. + +#ifndef CMND_H +#define CMND_H + +#include "incl.h" + +using namespace std; + +class cmnd +{ +public: + // public methods: + explicit cmnd( ); // a standard constructor. + ~cmnd( ); +}; + +#endif diff --git a/conf.cpp b/conf.cpp new file mode 100644 index 0000000..3ff71b8 --- /dev/null +++ b/conf.cpp @@ -0,0 +1,75 @@ +// class conf implementation. + +#ifndef s_conf_CXX +#define s_conf_CXX + +#include +#include "conf.h" + +using namespace std; + +conf::conf( string s_conf = CONFILE ) : name( s_conf ) +{ + parse( ); // parse the config file. +} + +conf::~conf() +{ +} + +void +conf::parse() +{ +#ifdef VERBOSE + cout << CFILEOK << get_name() << endl; +#endif + + ifstream fs_conf( get_name().c_str() ); + + if ( ! fs_conf ) + { +#ifdef VERBOSE + cout << CFILENO << get_name() << endl; +#endif + return; + } + + char c_buf[READBUF]; + + while( fs_conf.getline( c_buf, READBUF ) ) + { + string s_token( c_buf ); + unsigned int ui_pos = s_token.find( "#", 0 ); + + // if line is commented out: + if ( ui_pos == 0 ) + continue; + + ui_pos = s_token.find( ";", 0 ); + + // if token has not been found. + if ( ui_pos == string::npos ) + continue; + + s_token = s_token.substr( 0 , --ui_pos ); + ui_pos = s_token.find ( "\"", 0 ); + + if ( ui_pos == string::npos ) + continue; + + string s_val = s_token.substr( ui_pos+1, s_token.length() ); + string s_key = s_token.substr( 0 , --ui_pos ); + +#ifdef VERBOSE2 + cout << s_key << "=" << s_val << endl; +#endif + + // fill the map. + map_vals[s_key] = s_val; + } + + fs_conf.close(); + fs_conf.~ifstream(); +} + +#endif diff --git a/conf.h b/conf.h new file mode 100644 index 0000000..6e2a890 --- /dev/null +++ b/conf.h @@ -0,0 +1,24 @@ +// class conf declaration. this class parses the server config file. + +#ifndef s_conf_H +#define s_conf_H + +#include "incl.h" +#include "cont.h" +#include "name.h" + +using namespace std; + +class conf : public cont, name +{ +private: + +public: + // public methods: + conf ( string s_conf ); // standard constructor. + ~conf(); // standard destructor. + + virtual void parse( ); // parses the config file. +}; + +#endif diff --git a/conf.txt b/conf.txt new file mode 100644 index 0000000..936af92 --- /dev/null +++ b/conf.txt @@ -0,0 +1,63 @@ +# +# please notice this: +# the server parses this configuration file while starting or by an +# administrator's request. +# +# not allowed are semicolons ';' inside or before the quotes " ", +# otherwise this might result in errors. +# +# the syntax is easy: KEYNAME="value"; +# +# all lines which do not contain a semicolon and at least two quotes +# or start with a # will be ignored. +# +# greets, paul c. buetow ( snooper@ychat.org ); +# + +# server specific configurations ( not allowed to be removed ): + +HTMLTEMP="html/"; # directory of the html-template files. +THRDPOOL="50"; # thread pool size. +THRDQUEU="50"; # length of the thread pool queue. +SRVRPORT="3000"; # local port on which the server listens. +STRDROOM="Lounge"; # the name of the standard room. +LANGUAGE="en"; # language of the chat outputs ( CONSOLE OUTPUT IS NOT AFFECTED ) + +# the html template file which will be send if the requested file does not exists. +NOTFOUND="notfound.html"; +# specifies the standard start html-template. +STARTMPL="index.html"; +# user's standard nick color. +USERCOL1="#FFFFFF"; + +# length of the generated session id +SESSION_LENGTH="32"; + +# html = "OFF" strips all html tags from incoming messages +HTML="OFF"; + +# Logging + +# relative or absolute path to logfile +ACCESS_LOG="log/access_log"; + +# we're using buffered logging for performance +# LOG_LINES specifies after how many lines the log is flushed into a file +# if you don't want buffered logging set LOG_LINES to 1 +LOG_LINES="10"; + +# values which are used by the html-templates and are not sticked within the yC++ core source! +GRAPHICS="http://paul.buetow.info/yChat"; # url for graphic files etc. +PGETITLE="yChat++ Basic - Fast Simple Extensible"; + +# do not edit beyond this line + +CT_HTM="text/html"; +CT_HTML="text/html"; +CT_GIF="image/gif"; +CT_JPG="image/jpeg"; +CT_JPEG="image/jpeg"; +CT_PNG="image/png"; +CT_DEFAULT="text/html"; + +# end. diff --git a/configure b/configure new file mode 100755 index 0000000..8c5f0a7 --- /dev/null +++ b/configure @@ -0,0 +1,1555 @@ +#! /bin/sh + +# Guess values for system-dependent variables and create Makefiles. +# Generated automatically using autoconf version 2.13 +# Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc. +# +# This configure script is free software; the Free Software Foundation +# gives unlimited permission to copy, distribute and modify it. + +# Defaults: +ac_help= +ac_default_prefix=/usr/local +# Any additions from configure.in: + +# Initialize some variables set by options. +# The variables have the same names as the options, with +# dashes changed to underlines. +build=NONE +cache_file=./config.cache +exec_prefix=NONE +host=NONE +no_create= +nonopt=NONE +no_recursion= +prefix=NONE +program_prefix=NONE +program_suffix=NONE +program_transform_name=s,x,x, +silent= +site= +srcdir= +target=NONE +verbose= +x_includes=NONE +x_libraries=NONE +bindir='${exec_prefix}/bin' +sbindir='${exec_prefix}/sbin' +libexecdir='${exec_prefix}/libexec' +datadir='${prefix}/share' +sysconfdir='${prefix}/etc' +sharedstatedir='${prefix}/com' +localstatedir='${prefix}/var' +libdir='${exec_prefix}/lib' +includedir='${prefix}/include' +oldincludedir='/usr/include' +infodir='${prefix}/info' +mandir='${prefix}/man' + +# Initialize some other variables. +subdirs= +MFLAGS= MAKEFLAGS= +SHELL=${CONFIG_SHELL-/bin/sh} +# Maximum number of lines to put in a shell here document. +ac_max_here_lines=12 + +ac_prev= +for ac_option +do + + # If the previous option needs an argument, assign it. + if test -n "$ac_prev"; then + eval "$ac_prev=\$ac_option" + ac_prev= + continue + fi + + case "$ac_option" in + -*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;; + *) ac_optarg= ;; + esac + + # Accept the important Cygnus configure options, so we can diagnose typos. + + case "$ac_option" in + + -bindir | --bindir | --bindi | --bind | --bin | --bi) + ac_prev=bindir ;; + -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) + bindir="$ac_optarg" ;; + + -build | --build | --buil | --bui | --bu) + ac_prev=build ;; + -build=* | --build=* | --buil=* | --bui=* | --bu=*) + build="$ac_optarg" ;; + + -cache-file | --cache-file | --cache-fil | --cache-fi \ + | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) + ac_prev=cache_file ;; + -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ + | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) + cache_file="$ac_optarg" ;; + + -datadir | --datadir | --datadi | --datad | --data | --dat | --da) + ac_prev=datadir ;; + -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \ + | --da=*) + datadir="$ac_optarg" ;; + + -disable-* | --disable-*) + ac_feature=`echo $ac_option|sed -e 's/-*disable-//'` + # Reject names that are not valid shell variable names. + if test -n "`echo $ac_feature| sed 's/[-a-zA-Z0-9_]//g'`"; then + { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } + fi + ac_feature=`echo $ac_feature| sed 's/-/_/g'` + eval "enable_${ac_feature}=no" ;; + + -enable-* | --enable-*) + ac_feature=`echo $ac_option|sed -e 's/-*enable-//' -e 's/=.*//'` + # Reject names that are not valid shell variable names. + if test -n "`echo $ac_feature| sed 's/[-_a-zA-Z0-9]//g'`"; then + { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } + fi + ac_feature=`echo $ac_feature| sed 's/-/_/g'` + case "$ac_option" in + *=*) ;; + *) ac_optarg=yes ;; + esac + eval "enable_${ac_feature}='$ac_optarg'" ;; + + -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ + | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ + | --exec | --exe | --ex) + ac_prev=exec_prefix ;; + -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ + | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ + | --exec=* | --exe=* | --ex=*) + exec_prefix="$ac_optarg" ;; + + -gas | --gas | --ga | --g) + # Obsolete; use --with-gas. + with_gas=yes ;; + + -help | --help | --hel | --he) + # Omit some internal or obsolete options to make the list less imposing. + # This message is too long to be a string in the A/UX 3.1 sh. + cat << EOF +Usage: configure [options] [host] +Options: [defaults in brackets after descriptions] +Configuration: + --cache-file=FILE cache test results in FILE + --help print this message + --no-create do not create output files + --quiet, --silent do not print \`checking...' messages + --version print the version of autoconf that created configure +Directory and file names: + --prefix=PREFIX install architecture-independent files in PREFIX + [$ac_default_prefix] + --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX + [same as prefix] + --bindir=DIR user executables in DIR [EPREFIX/bin] + --sbindir=DIR system admin executables in DIR [EPREFIX/sbin] + --libexecdir=DIR program executables in DIR [EPREFIX/libexec] + --datadir=DIR read-only architecture-independent data in DIR + [PREFIX/share] + --sysconfdir=DIR read-only single-machine data in DIR [PREFIX/etc] + --sharedstatedir=DIR modifiable architecture-independent data in DIR + [PREFIX/com] + --localstatedir=DIR modifiable single-machine data in DIR [PREFIX/var] + --libdir=DIR object code libraries in DIR [EPREFIX/lib] + --includedir=DIR C header files in DIR [PREFIX/include] + --oldincludedir=DIR C header files for non-gcc in DIR [/usr/include] + --infodir=DIR info documentation in DIR [PREFIX/info] + --mandir=DIR man documentation in DIR [PREFIX/man] + --srcdir=DIR find the sources in DIR [configure dir or ..] + --program-prefix=PREFIX prepend PREFIX to installed program names + --program-suffix=SUFFIX append SUFFIX to installed program names + --program-transform-name=PROGRAM + run sed PROGRAM on installed program names +EOF + cat << EOF +Host type: + --build=BUILD configure fo