From 3f52e86b3330a425691dde3b362249f60832c228 Mon Sep 17 00:00:00 2001 From: Troy Rollo Date: Sat, 4 Feb 1995 07:50:00 +0100 Subject: [PATCH] TwinSock 1.3 --- LICENSE | 695 +++++++++++++++++++++++++++++++++++++++++++++++++-- about.c | 12 +- build.sh | 15 +- commands.c | 225 +++++++++++++++-- comms.c | 14 +- makefile | 9 +- packet.c | 251 +++++++++++++------ packet.h | 13 +- pterm.c | 49 ++++ showprot.c | 82 ++++++ term.c | 13 +- tshost.c | 47 +++- twinsock.c | 42 +++- twinsock.h | 21 +- twinsock.rc | 33 ++- twinsock.res | Bin 0 -> 2446 bytes tx.h | 13 +- winsock.c | 43 ++-- winsock.def | 117 ++++----- 19 files changed, 1406 insertions(+), 288 deletions(-) create mode 100644 pterm.c create mode 100644 showprot.c create mode 100644 twinsock.res diff --git a/LICENSE b/LICENSE index 23cb790..484535a 100644 --- a/LICENSE +++ b/LICENSE @@ -1,12 +1,176 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 + The TwinSock, TKERN and IRC II for Windows License + Version 1, 16-January-1995 - Copyright (C) 1989, 1991 Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +Preamble: + + The person who made this software possible was billed for + Citizens Utilities toll calls to a number he believed to be + a local (no charge) call, and attempted to the best of his + abilities to verify were local calls. + + Citizens Utilities have refused to withdraw or refund the + charges for those toll calls. + + As the bulk of those toll calls were made while developing, + improving and testing the software products TwinSock and + IRCII for Windows, which are provided free, the Citizens + Utilities Company of California has effectively asked the + author of this software to pay for the privilege of producing + the software and giving it away free of charge. + + Consequently, this license is designed to ensure that + Citizens Utilities and any affiliated companies cannot + derive any benefit from this software without paying license + fees. + + If you have no dealings whatsoever with any company named + Citizens Utilities, this license is effectively identical + to the appropriate GNU license for the package you are + using, or to the standard ircII license if the package is + ircII. If you do have dealings with a company named Citizens + Utilities, there may be additional conditions imposed on + your use of the software. + + This license applies retrospectively to the degree that as of + 16-January-1995, the products TKERN and TwinSock, which had + previously been made available under another license, are + withdrawn, and both current and previous versions of TKERN + and TwinSock are re-released under this license. + + If any licensing fees are payable, they should be fowarded + in the form of American Express Travellers Cheques or + international money orders payable to Troy Rollo to: + + Troy Rollo + Sycomp Pty Ltd + Level 4 + 1 James Place + North Sydney 2060 + AUSTRALIA + + All money amounts are in United States Dollars. + +This product is licensed under the following terms: + + 1. Subject to the remaining conditions of this license, all the + terms of the following licenses shall apply to various parts + of the software: + + i) for ircII, the license for ircII 2.6 for UNIX + + ii) for TwinSock, and for parts of TKERN which are included + in TKFMANGR.EXE, the GNU GENERAL PUBLIC LICENSE, Version 2 + (Included herein as Schedule 1) shall apply to this software. + + iii) For the remainder of TKERN, the GNU LIBRARY GENERAL PUBLIC + LICENSE, Version 2 (Included herein as Schedule 2) + + 2. A license fee of $231.02 (Two hundred and thirty one dollars + and two cents) per machine installed shall be payable by anybody + who is: + + (a) a company named Citizens Utilities incorporated in any + state or territory of the United States of America + + OR + + (b) a parent company of any company covered by (a) + + i) For the purposes of this license, a parent company + is any company holding more than 20% of the shares + of the company by cash value. + + ii) A parent company of any company covered by (b) is + itself considered to be a parent company, and thus + is also covered by (b) + + OR + + (c) an agent of a company covered by (a) or (b) + + OR + + (d) a person holding shares in a company covered by (a) + + OR + + (e) an employee of a company covered by (a) or (b) + + OR + + (f) a person living in the same residence as a person + covered by (e) + + OR + + (g) a govornment or govornment department holding more + than 10% of the shares in a company covered by (a) + + 3. The software may not be transmitted over any communications + service provided by a company named Citizens Utilities + incorporated in any state or territory of the United States + of America. Any copies inadvertantly received by such + transmission must be destroyed. + + 4. If the software is communications software, it may not be + used to transmit or receive data over any communications + service provided by a company named Citizens Utilities + incorporated in any state or territory of the United States + of America. + + 5. If there is no alternative service provider available + in the area, the software may be tansmitted or used over + a communications service provided by a company covered by + (3) and (4) if + + (a) The user of the software witholds payment of all + bills received until the last day payable + + AND + + (b) The user submits, with each bill payment, a complaint + about Citizens Utilities toll charges on account + 916/683-2400 between 15-December-1994 and 15-January-1995, + requesting that the full amount of those charges be + refunded + + AND + + (c) The user request to pay each bill by credit card if they + posess any of the following cards: Visa, Mastercard, + American Express. + + 6. A person whose telephone service is provided by a company + covered by (4), who switches to another provider within + 14 days of receiving the software, or before 22-February-1995, + whichever is later, may continue to use the software over + the existing service until the new service is in place or + for before the 8th day after the request is made to cancel + the original service (whichever is earlier) provided that + they inform the provider covered by (4) that they are + participating in the Citizens Utilities boycott relating + to account 916/683-2400. + + 7. Should any part of this license be held by a court to be + illegal or unenforcable, all licenses to use the software + shall be terminated. + + 8. Within the scope of this license, excluding the scheduled + items, modifying the software shall be considered to be using + the software. + + +SCHEDULE 1 +========== + 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 + Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public @@ -15,7 +179,7 @@ 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 Lesser General Public License instead.) You can apply it to +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 @@ -55,8 +219,8 @@ 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 + + GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains @@ -110,7 +274,7 @@ above, provided that you also meet all of these conditions: 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 @@ -168,7 +332,7 @@ 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 @@ -225,7 +389,7 @@ 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 @@ -255,7 +419,7 @@ 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 + 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 @@ -277,9 +441,9 @@ 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 - - How to Apply These Terms to Your New Programs + 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 @@ -290,8 +454,8 @@ 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. - {description} - Copyright (C) {year} {fullname} + + 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 @@ -303,16 +467,16 @@ the "copyright" line and a pointer to where the full notice is found. 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., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + 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) year name of author + 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. @@ -329,11 +493,496 @@ 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. - {signature of Ty Coon}, 1 April 1989 + , 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 Lesser General +library. If this is what you want to do, use the GNU Library General Public License instead of this License. + + +SCHEDULE 2 +========== + GNU LIBRARY GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 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. + +[This is the first released version of the library GPL. It is + numbered 2 because it goes with version 2 of the ordinary GPL.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Library General Public License, applies to some +specially designated Free Software Foundation software, and to any +other libraries whose authors decide to use it. You can use it for +your libraries, 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 library, or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link a program with the library, you must provide +complete object files to the recipients so that they can relink them +with the library, after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + Our method of protecting your rights has two steps: (1) copyright +the library, and (2) offer you this license which gives you legal +permission to copy, distribute and/or modify the library. + + Also, for each distributor's protection, we want to make certain +that everyone understands that there is no warranty for this free +library. If the library is modified by someone else and passed on, we +want its recipients to know that what they have is not the original +version, 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 companies distributing free +software will individually obtain patent licenses, thus in effect +transforming the program into proprietary software. To prevent this, +we have made it clear that any patent must be licensed for everyone's +free use or not licensed at all. + + Most GNU software, including some libraries, is covered by the ordinary +GNU General Public License, which was designed for utility programs. This +license, the GNU Library General Public License, applies to certain +designated libraries. This license is quite different from the ordinary +one; be sure to read it in full, and don't assume that anything in it is +the same as in the ordinary license. + + The reason we have a separate public license for some libraries is that +they blur the distinction we usually make between modifying or adding to a +program and simply using it. Linking a program with a library, without +changing the library, is in some sense simply using the library, and is +analogous to running a utility program or application program. However, in +a textual and legal sense, the linked executable is a combined work, a +derivative of the original library, and the ordinary General Public License +treats it as such. + + Because of this blurred distinction, using the ordinary General +Public License for libraries did not effectively promote software +sharing, because most developers did not use the libraries. We +concluded that weaker conditions might promote sharing better. + + However, unrestricted linking of non-free programs would deprive the +users of those programs of all benefit from the free status of the +libraries themselves. This Library General Public License is intended to +permit developers of non-free programs to use free libraries, while +preserving your freedom as a user of such programs to change the free +libraries that are incorporated in them. (We have not seen how to achieve +this as regards changes in header files, but we have achieved it as regards +changes in the actual functions of the Library.) The hope is that this +will lead to faster development of free libraries. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, while the latter only +works together with the library. + + Note that it is possible for a library to be covered by the ordinary +General Public License rather than by this special one. + + GNU LIBRARY GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library which +contains a notice placed by the copyright holder or other authorized +party saying it may be distributed under the terms of this Library +General Public License (also called "this License"). Each licensee is +addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, 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 library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete 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 distribute a copy of this License along with the +Library. + + 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 Library or any portion +of it, thus forming a work based on the Library, 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) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +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 Library, 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 Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you 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. + + If distribution of 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 satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also compile or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + c) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + d) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. 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. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library 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. + + 9. 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 Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +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. + + 11. 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 Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library 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 Library. + +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. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library 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. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Library 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 Library +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 Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +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 + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "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 +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. 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 LIBRARY 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 +LIBRARY (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 LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), 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 Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. 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) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; 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. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! diff --git a/about.c b/about.c index c73550e..1467663 100644 --- a/about.c +++ b/about.c @@ -4,18 +4,12 @@ * Copyright (C) 1994 Troy Rollo * * 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. + * it under the terms of the license in the file LICENSE.TXT included + * with the TwinSock distribution. * * 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. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. */ #include diff --git a/build.sh b/build.sh index cc044ca..d9faed3 100644 --- a/build.sh +++ b/build.sh @@ -128,9 +128,18 @@ else fi fi +if [ -f /usr/include/termios.h ] +then + echo "Using POSIX terminals" + TERM_OBJECT=pterm.o +else + echo "Using BSD terminals" + TERM_OBJECT=term.o +fi + rm -f a.out test.c -OBJECTS="tshost.o packet.o commands.o term.o $NEED_MEM" +OBJECTS="tshost.o packet.o commands.o ${TERM_OBJECT} $NEED_MEM" echo "Building makefile" echo ".c.o:" > Makefile @@ -140,7 +149,7 @@ echo "tshost: ${OBJECTS}" >> Makefile echo " ${CC} -o tshost ${OBJECTS} ${L_NSL} ${L_RESOLV} ${L_SOCKET}" >> Makefile echo -echo 'Running "make"' +echo 'Running "make -f Makefile"' echo -exec make +exec make -f Makefile  \ No newline at end of file diff --git a/commands.c b/commands.c index 4a4b75b..55a55d0 100644 --- a/commands.c +++ b/commands.c @@ -1,21 +1,15 @@ /* * TwinSock - "Troy's Windows Sockets" * - * Copyright (C) 1994 Troy Rollo + * Copyright (C) 1994-1995 Troy Rollo * * 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. + * it under the terms of the license in the file LICENSE.TXT included + * with the TwinSock distribution. * * 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. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. */ #include @@ -35,6 +29,192 @@ extern int h_errno; #define h_errno errno #endif +#ifndef AF_UNSPEC +#define AF_UNSPEC 0 +#endif +#ifndef AF_UNIX +#define AF_UNIX -1 +#endif +#ifndef AF_INET +#define AF_INET -1 +#endif +#ifndef AF_IMPLINK +#define AF_IMPLINK -1 +#endif +#ifndef AF_PUP +#define AF_PUP -1 +#endif +#ifndef AF_CHAOS +#define AF_CHAOS -1 +#endif +#ifndef AF_NS +#define AF_NS -1 +#endif +#ifndef AF_ISO +#define AF_ISO -1 +#endif +#ifndef AF_ECMA +#define AF_ECMA -1 +#endif +#ifndef AF_DATAKIT +#define AF_DATAKIT -1 +#endif +#ifndef AF_CCITT +#define AF_CCITT -1 +#endif +#ifndef AF_SNA +#define AF_SNA -1 +#endif +#ifndef AF_DECnet +#define AF_DECnet -1 +#endif +#ifndef AF_DLI +#define AF_DLI -1 +#endif +#ifndef AF_LAT +#define AF_LAT -1 +#endif +#ifndef AF_HYLINK +#define AF_HYLINK -1 +#endif +#ifndef AF_APPLETALK +#define AF_APPLETALK -1 +#endif +#ifndef AF_NETBIOS +#define AF_NETBIOS -1 +#endif + +#define rangeof(x) (sizeof(x) / sizeof(x[0])) + +static int HostSocketFamily[] = +{ + AF_UNSPEC, /* unspecified */ + AF_UNIX, /* local to host (pipes, portals) */ + AF_INET, /* internetwork: UDP, TCP, etc. */ + AF_IMPLINK, /* arpanet imp addresses */ + AF_PUP, /* pup protocols: e.g. BSP */ + AF_CHAOS, /* mit CHAOS protocols */ + AF_NS, /* NS, IPX and SPX */ + AF_ISO, /* ISO protocols */ + AF_ECMA, /* european computer manufacturers */ + AF_DATAKIT, /* datakit protocols */ + AF_CCITT, /* CCITT protocols, X.25 etc */ + AF_SNA, /* IBM SNA */ + AF_DECnet, /* DECnet */ + AF_DLI, /* Direct data link interface */ + AF_LAT, /* LAT */ + AF_HYLINK, /* NSC Hyperchannel */ + AF_APPLETALK, /* AppleTalk */ + AF_NETBIOS /* NetBios-style addresses */ +}; + +static int HostSocketType[] = +{ + 0, + SOCK_STREAM, + SOCK_DGRAM, + SOCK_RAW, + SOCK_RDM, + SOCK_SEQPACKET +}; + +#ifndef IPPROTO_IP +#define IPPROTO_IP 0 +#endif +#ifndef IPPROTO_ICMP +#define IPPROTO_ICMP 1 +#endif +#ifndef IPPROTO_GGP +#define IPPROTO_GGP 2 +#endif +#ifndef IPPROTO_TCP +#define IPPROTO_TCP 6 +#endif +#ifndef IPPROTO_PUP +#define IPPROTO_PUP 12 +#endif +#ifndef IPPROTO_UDP +#define IPPROTO_UDP 18 +#endif +#ifndef IPPROTO_ND +#define IPPROTO_ND 77 +#endif + +static int HostSocketProtocol[] = +{ + IPPROTO_IP, IPPROTO_ICMP, IPPROTO_GGP, 3, 4, + 5, IPPROTO_TCP, 7, 8, 9, + 10, 11, IPPROTO_PUP, 13, 14, 15, 16, IPPROTO_UDP, 18, 19, + 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, + 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, + 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, + 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, + 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, + 70, 71, 72, 73, 74, 75, 76, IPPROTO_ND, 78, 79 +}; + +static struct +{ + int iWindows; + int iHost; +} HostSocketOption[] = +{ + { 0x0001, SO_DEBUG }, + { 0x0002, SO_ACCEPTCONN }, + { 0x0004, SO_REUSEADDR }, + { 0x0008, SO_KEEPALIVE }, + { 0x0010, SO_DONTROUTE }, + { 0x0020, SO_BROADCAST }, + { 0x0040, SO_USELOOPBACK }, + { 0x0080, SO_LINGER }, + { 0x0100, SO_OOBINLINE } +}; + +static int +GetFamily(int x) +{ + return (x < rangeof(HostSocketFamily)) ? HostSocketFamily[x] : x; +} + +static int +RevFamily(int x) +{ + int i; + + for (i = 0; i < rangeof(HostSocketFamily); i++) + { + if (HostSocketFamily[i] == x) + return i; + } + return x; +} + +static int +GetType(int x) +{ + return (x < rangeof(HostSocketType)) ? HostSocketType[x] : x; +} + +static int +GetProtocol(int x) +{ + return (x < rangeof(HostSocketProtocol)) ? HostSocketProtocol[x] : x; +} + +static int +GetOption(int x) +{ + int iOption = 0; + int i; + + for (i = 0; i < rangeof(HostSocketOption); i++) + { + if (x & HostSocketOption[i].iWindows) + iOption |= HostSocketOption[i].iHost; + } + return iOption; +} + extern void PacketTransmitData (void *pvData, int iDataLen, int iStream); struct @@ -160,7 +340,7 @@ struct sockaddr * ConvertSA(struct func_arg *pfa, struct sockaddr_in *sin) { memcpy(sin, pfa->pvData, sizeof(*sin)); - sin->sin_family = ntohs(sin->sin_family); + sin->sin_family = GetFamily(ntohs(sin->sin_family)); return (struct sockaddr *) sin; } @@ -354,6 +534,7 @@ ResponseReceived(struct tx_request *ptxr_) int iLen; int iValue; int iSocket; + int nOptName; int nOptVal; short nError; struct tx_request *ptxr; @@ -471,9 +652,9 @@ ResponseReceived(struct tx_request *ptxr_) break; case FN_Socket: - iSocket = socket(GetIntVal(&pfaArgs[0]), - GetIntVal(&pfaArgs[1]), - GetIntVal(&pfaArgs[2])); + iSocket = socket(GetFamily(GetIntVal(&pfaArgs[0])), + GetType(GetIntVal(&pfaArgs[1])), + GetProtocol(GetIntVal(&pfaArgs[2]))); SetIntVal(&faResult,iSocket); if (iSocket != -1) { @@ -500,6 +681,7 @@ ResponseReceived(struct tx_request *ptxr_) SetIntVal(&pfaArgs[2], iValue); iValue = ((struct sockaddr *) pfaArgs[1].pvData)-> sa_family; + iValue = RevFamily(iValue); iValue = htons((short) iValue); ((struct sockaddr *) pfaArgs[1].pvData)->sa_family = (short) iValue; @@ -517,6 +699,7 @@ ResponseReceived(struct tx_request *ptxr_) SetIntVal(&pfaArgs[2], iValue); iValue = ((struct sockaddr *) pfaArgs[1].pvData)-> sa_family; + iValue = RevFamily(iValue); iValue = htons((short) iValue); ((struct sockaddr *) pfaArgs[1].pvData)->sa_family = (short) iValue; @@ -525,15 +708,16 @@ ResponseReceived(struct tx_request *ptxr_) case FN_GetSockOpt: iLen = GetIntVal(&pfaArgs[4]); + nOptName = GetOption(GetIntVal(&pfaArgs[2])); iValue = getsockopt( GetIntVal(&pfaArgs[0]), GetIntVal(&pfaArgs[1]), - GetIntVal(&pfaArgs[2]), + nOptName, (char *) pfaArgs[3].pvData, &iLen); if (iValue != -1) { SwapSockOptOut(&pfaArgs[3], - GetIntVal(&pfaArgs[2])); + nOptName); SetIntVal(&pfaArgs[4], iLen); } SetIntVal(&faResult, iValue); @@ -541,15 +725,16 @@ ResponseReceived(struct tx_request *ptxr_) case FN_SetSockOpt: iLen = GetIntVal(&pfaArgs[4]); + nOptName = GetOption(GetIntVal(&pfaArgs[2])); SwapSockOptIn(&pfaArgs[3], - GetIntVal(&pfaArgs[2])); + nOptName); iValue = setsockopt( GetIntVal(&pfaArgs[0]), SOL_SOCKET, - GetIntVal(&pfaArgs[2]), + nOptName, (char *) pfaArgs[3].pvData, iLen); SwapSockOptOut(&pfaArgs[3], - GetIntVal(&pfaArgs[2])); + nOptName); SetIntVal(&faResult, iValue); break; @@ -667,7 +852,7 @@ SendSocketData(int iSocket, iDataLen = sizeof(struct sockaddr_in) + iLen; sa = *psa; - sa.sin_family = htons(sa.sin_family); + sa.sin_family = htons(RevFamily(sa.sin_family)); ptxr = (struct tx_request *) malloc(sizeof(short) * 5 + iDataLen); ptxr->nLen = htons(iDataLen + sizeof(short) * 5); ptxr->id = htons(iSocket); diff --git a/comms.c b/comms.c index c0dac40..7563270 100644 --- a/comms.c +++ b/comms.c @@ -4,18 +4,12 @@ * Copyright (C) 1994 Troy Rollo * * 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. + * it under the terms of the license in the file LICENSE.TXT included + * with the TwinSock distribution. * * 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. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. */ #include #include @@ -276,7 +270,7 @@ DialDlgProc( HWND hDlg, iMethod = SendMessage(GetDlgItem(hDlg, DL_TONE), BM_GETCHECK, 0, 0); WritePrivateProfileString("Config", "DialingMethod", iMethod ? "1" : "0", "TWINSOCK.INI"); EndDialog(hDlg, TRUE); - SendData(iMethod ? "\rATDT" : "\rATDP", 5); + SendData(iMethod ? "ATDT" : "ATDP", 4); SendData(achNumber, strlen(achNumber)); SendData("\r", 1); break; diff --git a/makefile b/makefile index 314876f..8fadced 100644 --- a/makefile +++ b/makefile @@ -1,7 +1,7 @@ all: twinsock.exe winsock.dll: winsock.c - bcc -WD -ml -v -w- -lc -lC winsock.c + bcc -WD -ml -v -w- -lc -lm -ls winsock.c winsock.lib : winsock.dll implib winsock.lib winsock.dll @@ -9,6 +9,9 @@ winsock.lib : winsock.dll packet.obj: packet.c bcc -WE -ml -v -w- -c packet.c +showprot.obj: showprot.c + bcc -WE -ml -v -w- -c showprot.c + twinsock.obj: twinsock.c bcc -WE -ml -v -w- -c twinsock.c @@ -18,7 +21,7 @@ about.obj: about.c comms.obj: comms.c bcc -WE -ml -v -w- -c comms.c -twinsock.exe: twinsock.obj packet.obj about.obj comms.obj winsock.lib - bcc -WE -lc -lC -ml -v twinsock.obj packet.obj about.obj comms.obj winsock.lib +twinsock.exe: twinsock.obj packet.obj about.obj comms.obj showprot.obj winsock.lib + bcc -WE -lc -lm -ls -ml -v twinsock.obj packet.obj about.obj comms.obj showprot.obj winsock.lib rc twinsock  \ No newline at end of file diff --git a/packet.c b/packet.c index 461d6c7..f7f0a14 100644 --- a/packet.c +++ b/packet.c @@ -1,21 +1,15 @@ /* * TwinSock - "Troy's Windows Sockets" * - * Copyright (C) 1994 Troy Rollo + * Copyright (C) 1994-1995 Troy Rollo * * 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. + * it under the terms of the license in the file LICENSE.TXT included + * with the TwinSock distribution. * * 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. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. */ #include @@ -27,6 +21,7 @@ #include #endif #include "packet.h" +#include "twinsock.h" #define MAX_STREAMS 256 #define WINDOW_SIZE 4 @@ -34,6 +29,14 @@ short nInSeq = 0; short nOutSeq = 0; +long nCRCErrors = 0; +long nRetransmits = 0; +long nTimeouts = 0; +long nInsane = 0; +long nIncomplete = 0; + +enum Encoding eLine = E_6Bit; + extern int SendData(void *pvData, int nBytes); static unsigned long crc_32_tab[] = { /* CRC polynomial 0xedb88320 */ @@ -152,43 +155,88 @@ int TransmitData(void *pvData, int iDataLen) int nDataOut; char cNow, cTmp; - nDataOut = iDataLen * 4 / 3 + 1; - if (iDataLen % 6) - nDataOut++; pchDataIn = (char *) pvData; - pchDataOut = (char *) malloc(nDataOut); + pchDataOut = (char *) malloc(iDataLen * 2 + 1); /* Worst case */ nBits = nBitsLeft = 0; cNow = 0; - pchDataOut[0] = '@'; /* Signals the receiving end to realign to bit 0 */ - for (iIn = 0, iOut = 1; iOut < nDataOut;) + switch(eLine) { - if (nBitsLeft) + case E_6Bit: + nDataOut = iDataLen * 4 / 3 + 1; + if (iDataLen % 6) + nDataOut++; + pchDataOut[0] = '@'; /* Signals the receiving end to realign to bit 0 */ + for (iIn = 0, iOut = 1; iOut < nDataOut;) { - cTmp = c & ((1 << nBitsLeft) - 1); - nBitsNow = 6 - nBits; - if (nBitsLeft < nBitsNow) - nBitsNow = nBitsLeft; - cNow <<= nBitsNow; - cTmp >>= nBitsLeft - nBitsNow; - cTmp &= ((1 << nBitsNow) - 1); - cNow |= cTmp; - nBits += nBitsNow; - nBitsLeft -= nBitsNow; - if (nBits == 6) + if (nBitsLeft) { - pchDataOut[iOut++] = ach6bit[cNow]; - cNow = 0; - nBits = 0; + cTmp = c & ((1 << nBitsLeft) - 1); + nBitsNow = 6 - nBits; + if (nBitsLeft < nBitsNow) + nBitsNow = nBitsLeft; + cNow <<= nBitsNow; + cTmp >>= nBitsLeft - nBitsNow; + cTmp &= ((1 << nBitsNow) - 1); + cNow |= cTmp; + nBits += nBitsNow; + nBitsLeft -= nBitsNow; + if (nBits == 6) + { + pchDataOut[iOut++] = ach6bit[cNow]; + cNow = 0; + nBits = 0; + } + } + else + { + if (iIn < iDataLen) + c = pchDataIn[iIn++]; + else + c = 0; + nBitsLeft = 8; } } - else + break; + + case E_8Bit: + case E_8NoX: + case E_8NoCtrl: + for (iIn = 0, iOut = 0; iIn < iDataLen; iIn++) { - if (iIn < iDataLen) - c = pchDataIn[iIn++]; + c = pchDataIn[iIn]; + if (c == '@') + { + strcpy(pchDataOut + iOut, "@ "); + iOut += 2; + } + else if (c == '\030') + { + strcpy(pchDataOut + iOut, "@X"); + iOut += 2; + } + else if (eLine == E_8NoX && c == '\023') + { + strcpy(pchDataOut + iOut, "@S"); + iOut += 2; + } + else if (eLine == E_8NoX && c == '\021') + { + strcpy(pchDataOut + iOut, "@Q"); + iOut += 2; + } + else if (eLine == E_8NoCtrl && + c >= 0 && c < '\040') + { + pchDataOut[iOut++] = '@'; + pchDataOut[iOut++] = c + '@'; + } else - c = 0; - nBitsLeft = 8; + { + pchDataOut[iOut++] = c; + } } + nDataOut = iOut; + break; } nDataOut = SendData(pchDataOut, nDataOut); free(pchDataOut); @@ -245,8 +293,12 @@ void TimeoutReceived(void) { struct packet_queue *ppq; + nTimeouts++; for (ppq = ppqSent; ppq; ppq = ppq->ppqNext) + { + nRetransmits++; TransmitPacket(ppq); + } } void InitHead() @@ -281,20 +333,22 @@ void TransmitHead(void) static void AckReceived(int id) { - struct packet_queue **pppq, *ppqTemp; + struct packet_queue **pppq, *ppq, *ppqTemp; for (pppq = &ppqSent; *pppq && (*pppq)->idPacket != id; pppq = &(*pppq)->ppqNext); - if (*pppq) + ppq = *pppq; + if (ppq) { - while (ppqSent != *pppq) + while (ppqSent != ppq) { ppqTemp = ppqSent; ppqSent = ppqTemp->ppqNext; ppqTemp->ppqNext = 0; InsertInQueue(&ppqSent, ppqTemp); TransmitPacket(ppqTemp); + nRetransmits++; } ppqTemp = ppqSent; ppqSent = ppqTemp->ppqNext; @@ -429,6 +483,7 @@ void ProcessData(void *pvData, int nDataLen) if (!pvData) /* Receive timeout */ { + nIncomplete++; nBytes = 0; return; } @@ -453,6 +508,7 @@ void ProcessData(void *pvData, int nDataLen) id = ntohs(pkt.iPacketID); if (iLen > PACKET_MAX || iLen < 0) /* Sanity check */ { + nInsane++; nBytes = 0; nDataLen = 0; KillReceiveTimeout(); @@ -512,6 +568,7 @@ void ProcessData(void *pvData, int nDataLen) * receive timeout because we have already * "flushed" any existing input. */ + nCRCErrors++; KillReceiveTimeout(); if (ppqList) KillTransmitTimeout(); @@ -550,29 +607,75 @@ void PacketReceiveData(void *pvData, int nDataLen) pchDataIn = (char *) pvData; pchDataOut = (char *) malloc(nDataLen); - while (nDataLen || nBitsLeft) + switch(eLine) { - if (nBitsLeft) + case E_6Bit: + while (nDataLen || nBitsLeft) { - nBitsNow = 8 - nBits; - if (nBitsLeft < nBitsNow) - nBitsNow = nBitsLeft; - c <<= nBitsNow; - cTmp = cIn >> (nBitsLeft - nBitsNow); - cTmp &= ((1 << nBitsNow) - 1); - c |= cTmp; - nBits += nBitsNow; - nBitsLeft -= nBitsNow; - if (nBits == 8) + if (nBitsLeft) { - pchDataOut[iOut++] = c; - nBits = 0; + nBitsNow = 8 - nBits; + if (nBitsLeft < nBitsNow) + nBitsNow = nBitsLeft; + c <<= nBitsNow; + cTmp = cIn >> (nBitsLeft - nBitsNow); + cTmp &= ((1 << nBitsNow) - 1); + c |= cTmp; + nBits += nBitsNow; + nBitsLeft -= nBitsNow; + if (nBits == 8) + { + pchDataOut[iOut++] = c; + nBits = 0; + } + } + else + { + cIn = *pchDataIn++; + nDataLen--; + if (cIn == '\030') /* ^X */ + { + nCtlX++; + if (nCtlX >= 5) + Shutdown(); + continue; + } + else + { + nCtlX = 0; + } + if (cIn == '@') + { + cIn = c = 0; + nBitsLeft = 0; + nBits = 0; + } + else + { + if (cIn >= 'A' && cIn <= 'Z') + cIn -= 'A'; + else if (cIn >= 'a' && cIn <= 'z') + cIn = cIn - 'a' + 26; + else if (cIn >= '0' && cIn <= '9') + cIn = cIn - '0' + 52; + else if (cIn == '.') + cIn = 62; + else if (cIn == '/') + cIn = 63; + else + continue; + nBitsLeft = 6; + } } } - else + break; + + case E_8Bit: + case E_8NoX: + case E_8NoCtrl: + while (nDataLen--) { - cIn = *pchDataIn++; - nDataLen--; + cIn = *pchDataIn; if (cIn == '\030') /* ^X */ { nCtlX++; @@ -584,29 +687,33 @@ void PacketReceiveData(void *pvData, int nDataLen) { nCtlX = 0; } - if (cIn == '@') + if (nBits == 1) { - cIn = c = 0; - nBitsLeft = 0; + if (cIn == ' ') + pchDataOut[iOut++] = '@'; + else + pchDataOut[iOut++] = cIn - '@'; nBits = 0; } + else if (nBits == 2) + { + pchDataOut[iOut++] = cIn | 0x80; + } + else if (nBits == 3) + { + pchDataOut[iOut++] = (cIn - '@') | 0x80; + } + else if (cIn == '@') + { + nBits = 1; + } else { - if (cIn >= 'A' && cIn <= 'Z') - cIn -= 'A'; - else if (cIn >= 'a' && cIn <= 'z') - cIn = cIn - 'a' + 26; - else if (cIn >= '0' && cIn <= '9') - cIn = cIn - '0' + 52; - else if (cIn == '.') - cIn = 62; - else if (cIn == '/') - cIn = 63; - else - continue; - nBitsLeft = 6; + pchDataOut[iOut++] = *pchDataIn; } + pchDataIn++; } + break; } ProcessData(pchDataOut, iOut); free(pchDataOut); diff --git a/packet.h b/packet.h index d5eb5fc..04eb063 100644 --- a/packet.h +++ b/packet.h @@ -4,18 +4,12 @@ * Copyright (C) 1994 Troy Rollo * * 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. + * it under the terms of the license in the file LICENSE.TXT included + * with the TwinSock distribution. * * 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. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. */ enum packet_type @@ -38,3 +32,4 @@ struct packet }; + \ No newline at end of file diff --git a/pterm.c b/pterm.c new file mode 100644 index 0000000..d1b2cce --- /dev/null +++ b/pterm.c @@ -0,0 +1,49 @@ +/*Portable POSIX replacement for term.c*/ + +#include +#include + +static struct termios Old; +static struct termios New; + +void InitTerm(void) +{ + if(tcgetattr(0, &Old)<0) /*get current term attributes*/ + { + perror("tcgetattr"); + exit(1); + } + + New=Old; /*in case nonstandard fields*/ + + New.c_iflag = IXOFF|IXON; /*raw except for flow control*/ + New.c_oflag = 0; + New.c_cflag = CREAD|CS8|HUPCL; + New.c_lflag = 0; + + New.c_cc[VSTOP] = '\023'; /*XOFF*/ + New.c_cc[VSTART] = '\021'; /*XON*/ + New.c_cc[VMIN]= 255; /*max*/ + New.c_cc[VTIME]= 1; /*0.1 second*/ + + cfsetispeed(&New, cfgetispeed(&Old)); /*preserve old baud rate*/ + cfsetospeed(&New, cfgetospeed(&Old)); + + if(tcsetattr(0, TCSAFLUSH, &New)<0) /*set new attributes*/ + { + perror("tcsetattr"); + exit(1); + } +} + +void UnInitTerm(void) +{ + if(tcsetattr(0, TCSAFLUSH, &Old)<0) /*restore old attributes*/ + { + perror("tcsetattr"); + exit(1); + } +} + + + \ No newline at end of file diff --git a/showprot.c b/showprot.c new file mode 100644 index 0000000..c184a99 --- /dev/null +++ b/showprot.c @@ -0,0 +1,82 @@ +/* + * TwinSock - "Troy's Windows Sockets" + * + * Copyright (C) 1994-1995 Troy Rollo + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the license in the file LICENSE.TXT included + * with the TwinSock distribution. + * + * 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. + */ +#include +#include + +extern short nInSeq; +extern short nOutSeq; + +extern long nCRCErrors; +extern long nRetransmits; +extern long nTimeouts; +extern long nInsane; +extern long nIncomplete; + +extern long nBytesRecvd; +extern long nDiscarded; + +extern HINSTANCE hinst; + +void SetValue(HWND hDlg, + int idControl, + long iValue) +{ + char achTemp[40]; + + sprintf(achTemp, "%ld", iValue); + SetDlgItemText(hDlg, idControl, achTemp); +} + + +BOOL CALLBACK +ProtoDlgProc( HWND hDlg, + UINT wMsg, + WPARAM wParam, + LPARAM lParam) +{ + if (wMsg == WM_COMMAND && + (wParam == IDOK || wParam == IDCANCEL)) + { + EndDialog(hDlg, TRUE); + return TRUE; + } + else if (wMsg == WM_INITDIALOG) + { + SetValue(hDlg, 100, nOutSeq); + SetValue(hDlg, 101, nInSeq); + SetValue(hDlg, 102, nCRCErrors); + SetValue(hDlg, 103, nRetransmits); + SetValue(hDlg, 104, nTimeouts); + SetValue(hDlg, 105, nInsane); + SetValue(hDlg, 106, nIncomplete); + SetValue(hDlg, 107, nBytesRecvd); + SetValue(hDlg, 108, nDiscarded); + return TRUE; + } + else + { + return FALSE; + } +} + +void +ShowProtoInfo(HWND hwndParent) +{ + FARPROC fpDlgProc; + + fpDlgProc = MakeProcInstance((FARPROC) ProtoDlgProc, hinst); + DialogBox(hinst, "PROTO_DLG", hwndParent, fpDlgProc); + FreeProcInstance(fpDlgProc); +} + \ No newline at end of file diff --git a/term.c b/term.c index 8e7c64a..1072ad8 100644 --- a/term.c +++ b/term.c @@ -4,18 +4,12 @@ * Copyright (C) 1994 Troy Rollo * * 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. + * it under the terms of the license in the file LICENSE.TXT included + * with the TwinSock distribution. * * 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. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. */ #ifndef NO_SGTTY_H @@ -83,3 +77,4 @@ void UnInitTerm(void) { ioctl(0, TIOCSETP, &Old); } + \ No newline at end of file diff --git a/tshost.c b/tshost.c index 20337bd..a97e173 100644 --- a/tshost.c +++ b/tshost.c @@ -4,18 +4,12 @@ * Copyright (C) 1994 Troy Rollo * * 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. + * it under the terms of the license in the file LICENSE.TXT included + * with the TwinSock distribution. * * 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. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. */ #include @@ -29,6 +23,8 @@ #include "twinsock.h" #include "tx.h" +extern enum Encoding eLine; + extern void PacketTransmitData(void *pvData, int iDataLen, int iStream); #define BUFFER_SIZE 1024 @@ -78,15 +74,41 @@ main(int argc, char **argv) struct timeval tvZero; struct timeval tv; - fprintf(stderr, "TwinSock Host 1.1 (pre release)\n"); + while (argc-- > 1) + { + argv++; + if (**argv =='-') + { + while (*++*argv) + { + switch(**argv) + { + case '8': + eLine = E_8Bit; + break; + + case 'n': + eLine = E_8NoCtrl; + break; + + case 'x': + eLine = E_8NoX; + break; + } + } + } + } + + fprintf(stderr, "TwinSock Host 1.3\n"); fprintf(stderr, "Copyright 1994 Troy Rollo\n"); fprintf(stderr, "This program is free software\n"); fprintf(stderr, "See the file COPYING for details\n"); fprintf(stderr, "\nStart your TwinSock client now\n"); - fprintf(stderr, "!@$TSStart$@\n"); + fprintf(stderr, "!@$TSStart%d$@\n", (int) eLine); if (isatty(0)) InitTerm(); + nLargestFD = 0; FD_ZERO(&fdsActive); FD_ZERO(&fdsWrite); @@ -186,7 +208,7 @@ void SetTransmitTimeout(void) { KillTimer(TIMER_ID_SEND); - SetTimer(TIMER_ID_SEND, 3000); + SetTimer(TIMER_ID_SEND, 10000); } void @@ -423,3 +445,4 @@ DataReceived(void *pvData, int iLen) } } } + \ No newline at end of file diff --git a/twinsock.c b/twinsock.c index e075736..c91b7b9 100644 --- a/twinsock.c +++ b/twinsock.c @@ -4,28 +4,25 @@ * Copyright (C) 1994 Troy Rollo * * 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. + * it under the terms of the license in the file LICENSE.TXT included + * with the TwinSock distribution. * * 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. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. */ #include #include +#include #include "twinsock.h" #include "tx.h" HINSTANCE hinst; -extern RegisterManager(HWND hwnd); +extern far pascal RegisterManager(HWND hwnd); +extern far pascal ResponseReceived(struct tx_request *ptxr); +extern far pascal SetInitialised(void); static void SendInitRequest(void); void Shutdown(void); void OpenPort(void); @@ -51,7 +48,11 @@ static int cyRow, cxColumn; #define ROW_INDEX(x) ((x + iScrollRow) % SCREEN_ROWS) static char const achProtoInit[] = "@$TSStart$@"; + +extern enum Encoding eLine; static int iInitChar = 0; +long nDiscarded = 0; +long nBytesRecvd = 0; extern void PacketReceiveData(void *pvData, int iLen); @@ -138,19 +139,28 @@ AddChar(char c) SendInitRequest(); } } - else + else if (iInitChar == 9 && isdigit(c)) + { + eLine = (enum Encoding) (c - '0'); + } + else if (iInitChar) { iInitChar = 0; + eLine = E_6Bit; } } static void DoReading(void) { static char achBuffer[READ_MAX]; + static BOOL bAlreadyHere = FALSE; int nRead; COMSTAT cs; int i; + if (bAlreadyHere) + return; + bAlreadyHere = TRUE; do { nRead = ReadComm(idComm, achBuffer, READ_MAX); @@ -171,14 +181,17 @@ static void DoReading(void) } else if (bFlushing) { + nDiscarded += nRead; FlushInput(); } else { + nBytesRecvd += nRead; PacketReceiveData(achBuffer, nRead); } } - } while (nRead); + } while (nRead || cs.cbInQue); + bAlreadyHere = FALSE; } int SendData(void *pvData, int iDataLen) @@ -292,6 +305,11 @@ WindowProc( HWND hWnd, DialNumber(hWnd); break; + case 106: + if (!bTerminal) + ShowProtoInfo(hWnd); + break; + case 201: About(hWnd); break; diff --git a/twinsock.h b/twinsock.h index 8d707b1..ad01bd7 100644 --- a/twinsock.h +++ b/twinsock.h @@ -4,18 +4,12 @@ * Copyright (C) 1994 Troy Rollo * * 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. + * it under the terms of the license in the file LICENSE.TXT included + * with the TwinSock distribution. * * 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. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. */ enum arg_type @@ -41,6 +35,14 @@ enum arg_type #endif }; +enum Encoding +{ + E_6Bit = 0, + E_8Bit, + E_8NoCtrl, + E_8NoX +}; + enum Functions { FN_Init = 0, @@ -159,3 +161,4 @@ struct per_socket tf.pfaResult = &retval ) #endif + \ No newline at end of file diff --git a/twinsock.rc b/twinsock.rc index 810805e..cea9c51 100644 --- a/twinsock.rc +++ b/twinsock.rc @@ -1,4 +1,3 @@ -#define DIALOG_1 1 #include "c:\bc4\include\windows.h" #define IDHELP 3 @@ -14,6 +13,7 @@ TS_MENU MENU MENUITEM SEPARATOR MENUITEM "Connect", 101 MENUITEM "Disconnect", 102 + MENUITEM "Show protocol summary...", 106 MENUITEM SEPARATOR MENUITEM "About TwinSock...", 201 MENUITEM SEPARATOR @@ -47,10 +47,10 @@ FONT 8, "MS Sans Serif" { DEFPUSHBUTTON "OK", IDOK, 72, 109, 50, 14 ICON "TSICON", -1, 9, 12, 18, 20 - CTEXT "TwinSock 1.2", -1, 33, 7, 127, 8 - CTEXT "Copyright 1994 Troy Rollo", -1, 33, 20, 127, 8 + CTEXT "TwinSock 1.3", -1, 33, 7, 127, 8 + CTEXT "Copyright 1994-1995 Troy Rollo", -1, 33, 20, 127, 8 CTEXT "This Program Is Free Software", -1, 33, 33, 127, 8 - LTEXT "You may redistribute it under the terms of the GNU General Public License, either version 2, or, at your option, any later version.", -1, 33, 44, 127, 43 + LTEXT "You may redistribute it under the terms of the file LICENSE.TXT, included with the TwinSock software.", -1, 33, 44, 127, 43 CTEXT "Please direct questions and comments to twinsock@cbme.unsw.EDU.AU", -1, 30, 83, 142, 22 } @@ -68,4 +68,29 @@ FONT 8, "MS Sans Serif" PUSHBUTTON "Cancel", IDCANCEL, 93, 43, 50, 14 } +PROTO_DLG DIALOG 18, 18, 142, 129 +STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Protocol Summary" +BEGIN + RTEXT "Packets Sent:", -1, 4, 3, 73, 8, SS_RIGHT | WS_CHILD | WS_VISIBLE | WS_GROUP + CONTROL "", 100, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_GROUP, 81, 3, 28, 8 + RTEXT "Packets Received:", -1, 4, 15, 73, 8, SS_RIGHT | WS_CHILD | WS_VISIBLE | WS_GROUP + CONTROL "", 101, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_GROUP, 81, 15, 28, 8 + RTEXT "CRC Errors:", -1, 4, 27, 73, 8, SS_RIGHT | WS_CHILD | WS_VISIBLE | WS_GROUP + CONTROL "", 102, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_GROUP, 81, 27, 28, 8 + RTEXT "Retransmits:", -1, 4, 39, 73, 8, SS_RIGHT | WS_CHILD | WS_VISIBLE | WS_GROUP + CONTROL "", 103, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_GROUP, 81, 39, 28, 8 + RTEXT "Timeouts:", -1, 4, 51, 73, 8, SS_RIGHT | WS_CHILD | WS_VISIBLE | WS_GROUP + CONTROL "", 104, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_GROUP, 81, 51, 28, 8 + DEFPUSHBUTTON "OK", IDOK, 48, 112, 47, 14 + RTEXT "Failed sanity checks:", -1, 4, 63, 73, 8, SS_RIGHT | WS_CHILD | WS_VISIBLE | WS_GROUP + CONTROL "", 105, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_GROUP, 81, 63, 28, 8 + RTEXT "Incomplete packets:", -1, 4, 75, 73, 8, SS_RIGHT | WS_CHILD | WS_VISIBLE | WS_GROUP + CONTROL "", 106, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_GROUP, 81, 75, 28, 8 + RTEXT "Bytes Received:", -1, 4, 87, 73, 8, SS_RIGHT | WS_CHILD | WS_VISIBLE | WS_GROUP + CONTROL "", 107, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_GROUP, 81, 87, 28, 8 + RTEXT "Bytes Discarded:", -1, 4, 99, 73, 8, SS_RIGHT | WS_CHILD | WS_VISIBLE | WS_GROUP + CONTROL "", 108, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_GROUP, 81, 99, 28, 8 +END +  \ No newline at end of file diff --git a/twinsock.res b/twinsock.res new file mode 100644 index 0000000000000000000000000000000000000000..a731d09cdc893f5d021ff32d5381f93d4c986b74 GIT binary patch literal 2446 zcmc&!OK%%h6h2PUxCSn(?&R^=z~4-hNw(%t2oJL6Z9uDQ-k=A84LbI)5&lT6Uu+&@!9 z9}^M7^At~lX7DEJf`9SpLI_E>8~wu@pLn`-a&iKJRDUF8_=N|*kQLI=N%q2%iYY1k zZzpN$fPOWU_migp^oMZj$c_^CWgi!$lCXfElu6mbY2u4o9WW10L%T;Q*#`vTSDm9P zy=Jc|VF8K<{Q;enedu*k0~%Nu>dPVBZyoe{EyxdgE$Bn640n1*)KfIXh-gHIWG{94 z_NW!!Ka3DwDNhFxp5hwt-Wef86A{YE2&J5iP!2stgz5|;PzeBMKu6Mx=s3a{FpTIO z^f1DqL41r#1qY)DBQaw6Uyr;-MLnM>Y}4Z0yz(T0erIe>b$vJq36e9wJm1P~?*jBk z?CxvQxd@t|%9L>%jli)?Ls+ikr_*V0Ymhr-R`R$}XTDW+3>#dFvX)^-2xW*v*>Sij zKvf|0%^|r@dd+RIrsoRRbZzDbjfUa1$CUq~m696>R%}_0?wa+Xs7qDK9aw_oCCU`G zw)E%O&2QlRdV=VL-n@SQ65XJ`DfDR4ccvMh(cpr6K3$?f~b*vFQQsk;2ttT-Fc@qb5*kic*h_0c) z_-Wn32GKFyRIG5(ft4{FlOsvT@Fhe}N9=WOqwYxU%4%V^7^n8PIJL=J*qwjU&wx%A z=UhJ5;mVo&XXz?kr+I8eT%{exok{m7Nge1*tY>6?P;T}xy+jbsj|($yv+Y^cnqUu? zm%sQ7ug9$Dxox)N+O`|Q?~TKYHOpt3=T=d6miO73$2rs8if9=g577^R{uDP;c=Mhc zu!hlQ9xq$I@T^iGII{!`oHF;AsBwnQY52^oD57H7oNeYaxotg{E`C>hz%0kKgEB9( zmL+NmGYrO$FU9cOC7oWYi(Y&O_@?3?aoJ9u0yhk0s9W+YZ zBl-ySuu&=`h+b$fh(4fOlm??hv#48lK?`gj!b;4p#_Xc&fO{4BJX7}{V%C|yLyKuU zg<>Ig`(LzJm)>-5Tt}0M%p)CY zhXi=)BKQtBx%Cq-E0vT|31f{_ZjY;Eb}}sId9LRx@NEUIjKKHD!8=@dSSSq)q(a|U z=;{c)G>$G>4UY8|L6;P?Hh?ZtlRlpu-Whr_uDxcU`^wBW980vBS>t9svh+k*vIdrB zXk%P0@1UicHdY{OM#)p2ZYZVwk * * 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. + * it under the terms of the license in the file LICENSE.TXT included + * with the TwinSock distribution. * * 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. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. */ struct tx_request @@ -42,3 +36,4 @@ struct tx_queue HTASK htask; }; #endif + \ No newline at end of file diff --git a/winsock.c b/winsock.c index 7770cf6..121d04b 100644 --- a/winsock.c +++ b/winsock.c @@ -1,21 +1,15 @@ /* * TwinSock - "Troy's Windows Sockets" * - * Copyright (C) 1994 Troy Rollo + * Copyright (C) 1994-1995 Troy Rollo * * 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. + * it under the terms of the license in the file LICENSE.TXT included + * with the TwinSock distribution. * * 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. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. */ #include @@ -43,13 +37,19 @@ BOOL bEstablished = 0; static void FireAsyncRequest(struct tx_queue *ptxq); -void _export +int FAR PASCAL +LibMain(HINSTANCE hInst, WORD wOne, WORD wTwo, LPSTR lpstr) +{ + return TRUE; +} + +void far pascal _export RegisterManager(HWND hwnd) { hwndManager = hwnd; } -void _export +void far pascal _export SetInitialised(void) { bEstablished = TRUE; @@ -100,7 +100,7 @@ CopyDataOut( void *pvDest, case AT_Int32: case AT_Int32Ptr: - *(short *) pvDest = htonl(*(short *) pvSource); + *(long *) pvDest = htonl(*(long *) pvSource); break; case AT_Char: @@ -247,9 +247,9 @@ DataReceived(SOCKET s, void *pvData, int nLen, enum Functions ft) nLen -= sizeof(struct sockaddr_in); pvData = (char *) pvData + sizeof(struct sockaddr_in); if (nLen == sizeof(long)) - ns = ntohl(*(long *) pvData); + ns = (int) ntohl(*(long *) pvData); else - ns = ntohs(*(short*) pvData); + ns = (int) ntohs(*(short*) pvData); SendEarlyClose(ns); } return; @@ -369,11 +369,12 @@ RemoveTask(struct per_task *ppt) { *pppt = ppt->pptNext; free(ppt); + break; } } }; -void far _export +void far pascal _export ResponseReceived(struct tx_request *ptxr) { int nLen; @@ -627,7 +628,7 @@ CopyHostEntTo(struct per_task *ppt, char *pchData) pchOld = phe->h_addr_list[0]; memcpy(pchData, pchOld, 4 * nAddrs); for (i = 0; i < nAddrs; i++) - phe->h_addr_list[i] = phe->h_addr_list[i] - pchOld + pchData; + phe->h_addr_list[i] = pchData + (phe->h_addr_list[i] - pchOld); pchData += 4 * nAddrs; strcpy(pchData, phe->h_name); @@ -705,7 +706,6 @@ CopyProtoEnt(struct per_task *ppt) { int iLocation; int i; - int nAddrs; ppt->pe.p_proto = ntohs(*(short *) ppt->achProtoEnt); iLocation = sizeof(short); @@ -808,7 +808,6 @@ int pascal far _export bind(SOCKET s, const struct sockaddr FAR *addr, int namelen) { struct per_task *ppt; - struct per_socket *pps; int nReturn; struct func_arg pfaArgs[3]; struct func_arg pfaReturn; @@ -1672,7 +1671,7 @@ int pascal far _export WSAStartup(WORD wVersionRequired, LPWSADATA lpWSAData) lpWSAData->wVersion = 0x0101; lpWSAData->wHighVersion = 0x0101; strcpy(lpWSAData->szDescription, - "TwinSock 1.1 - Proxy sockets system. " + "TwinSock 1.3 - Proxy sockets system. " "Copyright 1994 Troy Rollo. " "TwinSock is free software. " "See the file \"COPYING\" from the " @@ -1709,9 +1708,9 @@ int pascal far _export WSACleanup(void) if (ppt->bBlocking) { iErrno = WSAEINPROGRESS; - RemoveTask(ppt); return -1; } + RemoveTask(ppt); return 0; } @@ -2027,7 +2026,7 @@ int pascal far _export WSAAsyncSelect(SOCKET s, HWND hWnd, u_int wMsg, return 0; } -int FAR PASCAL _export _WSAFDIsSet(SOCKET s, fd_set FAR *pfds) +int FAR PASCAL _export __WSAFDIsSet(SOCKET s, fd_set FAR *pfds) { int i; diff --git a/winsock.def b/winsock.def index 971296c..ef358ec 100644 --- a/winsock.def +++ b/winsock.def @@ -1,65 +1,58 @@ -LIBRARY WINSOCK -DESCRIPTION 'BSD Socket API for Windows' -EXETYPE WINDOWS -CODE PRELOAD FIXED -HEAPSIZE 1024 +LIBRARY WINSOCK -EXPORTS - ACCEPT @1 - BIND @2 - CLOSESOCKET @3 - CONNECT @4 - GETPEERNAME @5 - GETSOCKNAME @6 - GETSOCKOPT @7 - HTONL @8 - HTONS @9 - INET_ADDR @10 - INET_NTOA @11 - IOCTLSOCKET @12 - LISTEN @13 - NTOHL @14 - NTOHS @15 - RECV @16 - RECVFROM @17 - SELECT @18 - SEND @19 - SENDTO @20 - SETSOCKOPT @21 - SHUTDOWN @22 - SOCKET @23 +DESCRIPTION 'BSD Socket API for Windows ' - GETHOSTBYADDR @51 - GETHOSTBYNAME @52 - GETPROTOBYNAME @53 - GETPROTOBYNUMBER @54 - GETSERVBYNAME @55 - GETSERVBYPORT @56 - GETHOSTNAME @57 +EXPORTS + ACCEPT @1 + BIND @2 + CLOSESOCKET @3 + CONNECT @4 + GETPEERNAME @5 + GETSOCKNAME @6 + GETSOCKOPT @7 + HTONL @8 + HTONS @9 + INET_ADDR @10 + INET_NTOA @11 + IOCTLSOCKET @12 + LISTEN @13 + NTOHL @14 + NTOHS @15 + RECV @16 + RECVFROM @17 + SELECT @18 + SEND @19 + SENDTO @20 + SETSOCKOPT @21 + SHUTDOWN @22 + SOCKET @23 + GETHOSTBYADDR @51 + GETHOSTBYNAME @52 + GETPROTOBYNAME @53 + GETPROTOBYNUMBER @54 + GETSERVBYNAME @55 + GETSERVBYPORT @56 + GETHOSTNAME @57 + WSAASYNCSELECT @101 + WSAASYNCGETHOSTBYADDR @102 + WSAASYNCGETHOSTBYNAME @103 + WSAASYNCGETPROTOBYNUMBER @104 + WSAASYNCGETPROTOBYNAME @105 + WSAASYNCGETSERVBYPORT @106 + WSAASYNCGETSERVBYNAME @107 + WSACANCELASYNCREQUEST @108 + WSASETBLOCKINGHOOK @109 + WSAUNHOOKBLOCKINGHOOK @110 + WSAGETLASTERROR @111 + WSASETLASTERROR @112 + WSACANCELBLOCKINGCALL @113 + WSAISBLOCKING @114 + WSASTARTUP @115 + WSACLEANUP @116 + __WSAFDISSET @151 + RESPONSERECEIVED @200 + REGISTERMANAGER @201 + SETINITIALISED @202 + WEP @203 + LIBMAIN @204 - WSAASYNCSELECT @101 - WSAASYNCGETHOSTBYADDR @102 - WSAASYNCGETHOSTBYNAME @103 - WSAASYNCGETPROTOBYNUMBER @104 - WSAASYNCGETPROTOBYNAME @105 - WSAASYNCGETSERVBYPORT @106 - WSAASYNCGETSERVBYNAME @107 - WSACANCELASYNCREQUEST @108 - WSASETBLOCKINGHOOK @109 - WSAUNHOOKBLOCKINGHOOK @110 - WSAGETLASTERROR @111 - WSASETLASTERROR @112 - WSACANCELBLOCKINGCALL @113 - WSAISBLOCKING @114 - WSASTARTUP @115 - WSACLEANUP @116 - - _WSAFDISSET @151 - - WEP @500 RESIDENTNAME - - _ResponseReceived @10000 - _RegisterManager @10001 - _SetInitialised @10002 - - \ No newline at end of file