Initial revision
This commit is contained in:
commit
03ec286c0b
16 changed files with 6534 additions and 0 deletions
16
.gitattributes
vendored
Normal file
16
.gitattributes
vendored
Normal file
|
@ -0,0 +1,16 @@
|
|||
* text=auto !eol
|
||||
/ChangeLog -text
|
||||
/LICENSE -text
|
||||
/Makefile.in -text
|
||||
/README.SecureServ -text
|
||||
/SecureServ.c -text
|
||||
/SecureServ.h -text
|
||||
/SecureServ_help.c -text
|
||||
/config.cache -text
|
||||
/config.status -text
|
||||
/configure -text
|
||||
/configure.in -text
|
||||
/http.c -text
|
||||
/http.h -text
|
||||
/install-sh -text
|
||||
/modconfig.h.in -text
|
2
ChangeLog
Normal file
2
ChangeLog
Normal file
|
@ -0,0 +1,2 @@
|
|||
TrojanServ Module for NeoStats Changelog.
|
||||
==============================================================================
|
341
LICENSE
Normal file
341
LICENSE
Normal file
|
@ -0,0 +1,341 @@
|
|||
# $Id: LICENSE,v 1.1 2003/04/18 04:38:37 fishwaldo Exp $
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
||||
59 Temple Place, Suite 330, Boston, MA 02111-1307 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
|
||||
|
||||
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.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) 19yy <name of author>
|
||||
|
||||
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
|
||||
|
||||
|
||||
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.
|
||||
|
||||
<signature of Ty Coon>, 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.
|
37
Makefile.in
Normal file
37
Makefile.in
Normal file
|
@ -0,0 +1,37 @@
|
|||
#Neostats Module Makefile!
|
||||
CC=@CC@
|
||||
CFLAGS=@CFLAGS@
|
||||
LDFLAGS= @LIBS@
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
DIRECTORY=@DIRINST@/dl/
|
||||
INCLUDES=-I@DIRINST@/include/ -I.
|
||||
|
||||
SOURCES= SecureServ.c SecureServ_help.c http.c
|
||||
OBJECTS= SecureServ.o SecureServ_help.o http.o
|
||||
TARGET= SecureServ.so
|
||||
DOCS=README.SecureServ
|
||||
DATA=
|
||||
|
||||
|
||||
all: module
|
||||
|
||||
.c.o:
|
||||
$(CC) -c $(CFLAGS) $(INCLUDES) $<
|
||||
|
||||
module: $(OBJECTS)
|
||||
$(LD) -shared -o $(TARGET) $(LDFLAGS) $(OBJECTS)
|
||||
|
||||
clean:
|
||||
/bin/rm -rf $(TARGET) *.o Makefile *.log modconfig.h
|
||||
|
||||
install: module
|
||||
$(INSTALL) -m 644 $(TARGET) $(DIRECTORY)
|
||||
$(INSTALL) -m 644 $(DOCS) $(DIRECTORY)../doc/
|
||||
|
||||
$(OBJECTS): Makefile
|
||||
|
||||
SecureServ.c: SecureServ.h SecureServ_help.c modconfig.h
|
||||
SecureServ_help.c: SecureServ.h modconfig.h
|
||||
|
0
README.SecureServ
Normal file
0
README.SecureServ
Normal file
413
SecureServ.c
Normal file
413
SecureServ.c
Normal file
|
@ -0,0 +1,413 @@
|
|||
/* NeoStats - IRC Statistical Services Copyright (c) 1999-2002 NeoStats Group Inc.
|
||||
** Copyright (c) 1999-2002 Adam Rutter, Justin Hammond
|
||||
** http://www.neostats.net/
|
||||
**
|
||||
** 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
|
||||
**
|
||||
** NeoStats CVS Identification
|
||||
** $Id: SecureServ.c,v 1.1 2003/04/18 04:38:43 fishwaldo Exp $
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <fnmatch.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <arpa/nameser.h>
|
||||
#include <fnmatch.h>
|
||||
#include "dl.h"
|
||||
#include "log.h"
|
||||
#include "stats.h"
|
||||
#include "SecureServ.h"
|
||||
|
||||
const char tsversion_date[] = __DATE__;
|
||||
const char tsversion_time[] = __TIME__;
|
||||
|
||||
|
||||
|
||||
|
||||
extern const char *ts_help[];
|
||||
static int ScanNick(char **av, int ac);
|
||||
void LoadTSConf();
|
||||
int check_version_reply(char *origin, char **av, int ac);
|
||||
void gotpositive(User *u, virientry *ve, int type);
|
||||
void do_list(User *u);
|
||||
|
||||
Module_Info my_info[] = { {
|
||||
"SecureServ",
|
||||
"A Trojan Scanning Bot",
|
||||
"0.9"
|
||||
} };
|
||||
|
||||
|
||||
int new_m_version(char *origin, char **av, int ac) {
|
||||
snumeric_cmd(351,origin, "Module SecureServ Loaded, Version: %s %s %s",my_info[0].module_version,tsversion_date,tsversion_time);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Functions my_fn_list[] = {
|
||||
{ MSG_VERSION, new_m_version, 1 },
|
||||
#ifdef HAVE_TOKEN_SUP
|
||||
{ TOK_VERSION, new_m_version, 1 },
|
||||
#endif
|
||||
{ MSG_NOTICE, check_version_reply, 1},
|
||||
#ifdef HAVE_TOKEN_SUB
|
||||
{ TOK_NOTICE, check_version_reply, 1},
|
||||
#endif
|
||||
{ NULL, NULL, 0 }
|
||||
};
|
||||
|
||||
|
||||
int findscan(const void *key1, const void *key2) {
|
||||
#if 0
|
||||
const scaninfo *chan1 = key1;
|
||||
return (strcasecmp(chan1->who, key2));
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
unsigned hrand(unsigned upperbound, unsigned lowerbound) {
|
||||
return ((unsigned)(rand()%((int)(upperbound-lowerbound+1))-((int)(lowerbound-1))));
|
||||
}
|
||||
|
||||
|
||||
int __Bot_Message(char *origin, char **argv, int argc)
|
||||
{
|
||||
User *u;
|
||||
|
||||
strcpy(segv_location, "TS:Bot_Message");
|
||||
|
||||
u = finduser(origin);
|
||||
if (!u) {
|
||||
nlog(LOG_WARNING, LOG_CORE, "Unable to find user %s (ts)", origin);
|
||||
return -1;
|
||||
}
|
||||
if (!strcasecmp(argv[1], "help")) {
|
||||
if (argc == 2) {
|
||||
privmsg_list(u->nick, s_ts, ts_help);
|
||||
} else {
|
||||
prefmsg(u->nick, s_ts, "Invalid Syntax. /msg %s help for more info", s_ts);
|
||||
}
|
||||
return 1;
|
||||
} else if (!strcasecmp(argv[1], "list")) {
|
||||
do_list(u);
|
||||
return 1;
|
||||
} else {
|
||||
prefmsg(u->nick, s_ts, "Syntax Error. /msg %s help", s_ts);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
void do_list(User *u) {
|
||||
lnode_t *node;
|
||||
virientry *ve;
|
||||
char type[MAXHOST];
|
||||
char action[MAXHOST];
|
||||
int i;
|
||||
|
||||
i = 0;
|
||||
node = list_first(viri);
|
||||
prefmsg(u->nick, s_ts, "Virus List:");
|
||||
prefmsg(u->nick, s_ts, "===========");
|
||||
while ((node = list_next(viri, node)) != NULL) {
|
||||
ve = lnode_get(node);
|
||||
i++;
|
||||
switch (ve->dettype) {
|
||||
case DET_CTCP:
|
||||
snprintf(type, MAXHOST, "CTCP Version Check");
|
||||
break;
|
||||
case DET_MSG:
|
||||
snprintf(type, MAXHOST, "OnJoin Receive Message");
|
||||
break;
|
||||
default:
|
||||
snprintf(type, MAXHOST, "Any Recieved Message");
|
||||
}
|
||||
switch (ve->action) {
|
||||
case ACT_SVSJOIN:
|
||||
snprintf(action, MAXHOST, "SVSjoin to AV channel");
|
||||
break;
|
||||
case ACT_AKILL:
|
||||
snprintf(action, MAXHOST, "Akill Client");
|
||||
break;
|
||||
case ACT_WARN:
|
||||
snprintf(action, MAXHOST, "Warn Opers");
|
||||
break;
|
||||
default:
|
||||
snprintf(action, MAXHOST, "Warn Client Only");
|
||||
}
|
||||
prefmsg(u->nick, s_ts, "%d) Virus: %s. Detection Via: %s. Action: %s", i, ve->name, type, action);
|
||||
}
|
||||
prefmsg(u->nick, s_ts, "End of List.");
|
||||
}
|
||||
|
||||
int Online(char **av, int ac) {
|
||||
|
||||
strcpy(segv_location, "TS:Online");
|
||||
|
||||
if (init_bot(s_ts,"ts",me.name,"Trojan Scanning Bot", "+xd", my_info[0].module_name) == -1 ) {
|
||||
/* Nick was in use!!!! */
|
||||
s_ts = strcat(s_ts, "_");
|
||||
init_bot(s_ts,"ts",me.name,"Trojan Scanning Bot", "+xd", my_info[0].module_name);
|
||||
}
|
||||
LoadTSConf();
|
||||
chanalert(s_ts, "%d Trojans Patterns loaded", list_count(viri));
|
||||
|
||||
return 1;
|
||||
};
|
||||
|
||||
|
||||
void saveconf() {
|
||||
lnode_t *node;
|
||||
exemptinfo *exempts;
|
||||
FILE *fp = fopen("data/ts.db", "w");
|
||||
|
||||
strcpy(segv_location, "TS:savecache");
|
||||
|
||||
if (!fp) {
|
||||
nlog(LOG_WARNING, LOG_MOD, "TS: warning, Can not open config file for writting");
|
||||
chanalert(s_ts, "Warning, Can not open config file for writting");
|
||||
return;
|
||||
}
|
||||
fprintf(fp, "%d\n", ts.doscan);
|
||||
fprintf(fp, "%d\n", ts.timedif);
|
||||
/* exempts next */
|
||||
node = list_first(exempt);
|
||||
while (node) {
|
||||
exempts = lnode_get(node);
|
||||
fprintf(fp, "%s %d %s %s\n", exempts->host, exempts->server, exempts->who, exempts->reason);
|
||||
node = list_next(exempt, node);
|
||||
}
|
||||
}
|
||||
|
||||
void LoadTSConf() {
|
||||
lnode_t *node;
|
||||
exemptinfo *exempts = NULL;
|
||||
virientry *viridet;
|
||||
char buf[512];
|
||||
FILE *fp = fopen("data/ts.db", "r");
|
||||
|
||||
strcpy(segv_location, "TS:loadcache");
|
||||
|
||||
if (!fp) {
|
||||
nlog(LOG_WARNING, LOG_MOD, "TS: Warning, Can not open Config file for Reading");
|
||||
chanalert(s_ts, "Warning, Can not open Config file for Reading, Using Defaults");
|
||||
} else {
|
||||
fgets(buf, 512, fp);
|
||||
ts.doscan = atoi(buf);
|
||||
fgets(buf, 512, fp);
|
||||
ts.timedif = atoi(buf);
|
||||
while (fgets(buf, 512, fp)) {
|
||||
if (list_isfull(exempt))
|
||||
break;
|
||||
exempts = malloc(sizeof(exemptinfo));
|
||||
snprintf(exempts->host, MAXHOST, "%s", strtok(buf, " "));
|
||||
exempts->server = atoi(strtok(NULL, " "));
|
||||
snprintf(exempts->who, MAXNICK, "%s", strtok(NULL, " "));
|
||||
snprintf(exempts->reason, MAXHOST, "%s", strtok(NULL, "\n"));
|
||||
node = lnode_create(exempts);
|
||||
list_prepend(exempt, node);
|
||||
}
|
||||
fclose(fp);
|
||||
}
|
||||
fp = fopen("data/viri.dat", "r");
|
||||
if (!fp) {
|
||||
nlog(LOG_WARNING, LOG_MOD, "TS: Error, No viri.dat file found. %s is disabled", s_ts);
|
||||
chanalert(s_ts, "Error not viri.dat file found, %s is disabled", s_ts);
|
||||
return;
|
||||
} else {
|
||||
fgets(buf, 512, fp);
|
||||
ts.viriversion = atoi(buf);
|
||||
while (fgets(buf, 512, fp)) {
|
||||
if (list_isfull(viri))
|
||||
break;
|
||||
viridet = malloc(sizeof(virientry));
|
||||
snprintf(viridet->name, MAXHOST, "%s", strtok(buf, " "));
|
||||
viridet->dettype = atoi(strtok(NULL, " "));
|
||||
viridet->var1 = atoi(strtok(NULL, " "));
|
||||
viridet->var2 = atoi(strtok(NULL, " "));
|
||||
snprintf(viridet->recvmsg, MAXHOST, "%s", strtok(NULL, "\""));
|
||||
strtok(NULL, "\"");
|
||||
snprintf(viridet->sendmsg, MAXHOST, "%s", strtok(NULL, "\""));
|
||||
viridet->action = atoi(strtok(NULL, ""));
|
||||
node = lnode_create(viridet);
|
||||
list_prepend(viri, node);
|
||||
nlog(LOG_DEBUG1, LOG_MOD, "loaded %s (Detection %d, with %s, send %s and do %d", viridet->name, viridet->dettype, viridet->recvmsg, viridet->sendmsg, viridet->action);
|
||||
}
|
||||
}
|
||||
ts.init = 1;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
EventFnList my_event_list[] = {
|
||||
{ "ONLINE", Online},
|
||||
{ "SIGNON", ScanNick},
|
||||
{ NULL, NULL}
|
||||
};
|
||||
|
||||
|
||||
|
||||
Module_Info *__module_get_info() {
|
||||
return my_info;
|
||||
};
|
||||
|
||||
Functions *__module_get_functions() {
|
||||
return my_fn_list;
|
||||
};
|
||||
|
||||
EventFnList *__module_get_events() {
|
||||
return my_event_list;
|
||||
};
|
||||
|
||||
|
||||
/* scan the nickname */
|
||||
static int ScanNick(char **av, int ac) {
|
||||
User *u;
|
||||
lnode_t *node;
|
||||
exemptinfo *exempts;
|
||||
|
||||
strcpy(segv_location, "TS:ScanNick");
|
||||
|
||||
/* don't do anything if NeoStats hasn't told us we are online yet */
|
||||
if (!ts.init)
|
||||
return 0;
|
||||
|
||||
u = finduser(av[0]);
|
||||
if (!u) {
|
||||
nlog(LOG_WARNING, LOG_MOD, "TS: Ehhh, Can't find user %s", av[0]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* don't scan users from my own server */
|
||||
if (!strcasecmp(u->server->name, me.name)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* don't scan users from a server that is excluded */
|
||||
node = list_first(exempt);
|
||||
while (node) {
|
||||
exempts = lnode_get(node);
|
||||
if (exempts->server == 1) {
|
||||
/* match a server */
|
||||
if (fnmatch(exempts->host, u->server->name, 0) == 0) {
|
||||
nlog(LOG_DEBUG1, LOG_MOD, "TS: User %s exempt. Matched server entry %s in Exemptions", u->nick, exempts->host);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
node = list_next(exempt, node);
|
||||
}
|
||||
|
||||
if (time(NULL) - u->TS > ts.timedif) {
|
||||
nlog(LOG_DEBUG1, LOG_MOD, "Netsplit Nick %s, Not Scanning", av[0]);
|
||||
return -1;
|
||||
}
|
||||
prefmsg(u->nick, s_ts, ts.signonscanmsg);
|
||||
privmsg(u->nick, s_ts, "\1VERSION\1");
|
||||
return 1;
|
||||
}
|
||||
|
||||
int check_version_reply(char *origin, char **av, int ac) {
|
||||
char *buf;
|
||||
lnode_t *node;
|
||||
virientry *viridetails;
|
||||
|
||||
/* if its not a ctcp message, forget it */
|
||||
if (av[1][0] != '\1')
|
||||
return 0;
|
||||
|
||||
if (!strcasecmp(av[1], "\1version")) {
|
||||
buf = joinbuf(av, ac, 2);
|
||||
node = list_first(viri);
|
||||
while ((node = list_next(viri, node)) != NULL) {
|
||||
viridetails = lnode_get(node);
|
||||
if ((viridetails->dettype == DET_CTCP) || (viridetails->dettype > 1)) {
|
||||
nlog(LOG_DEBUG1, LOG_MOD, "TS: Checking Version %s against %s", buf, viridetails->recvmsg);
|
||||
if (fnmatch(viridetails->recvmsg, buf, 0) == 0) {
|
||||
gotpositive(finduser(origin), viridetails, DET_CTCP);
|
||||
if (ts.breakorcont == 0)
|
||||
continue;
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void gotpositive(User *u, virientry *ve, int type) {
|
||||
|
||||
prefmsg(u->nick, s_ts, "%s has detected that your client is a Trojan/Infected IRC client/Vulnerble Script called %s", s_ts, ve->name);
|
||||
prefmsg(u->nick, s_ts, ve->sendmsg);
|
||||
switch (ve->action) {
|
||||
case ACT_AKILL:
|
||||
if (ts.doakill > 0) {
|
||||
prefmsg(u->nick, s_ts, ts.akillinfo);
|
||||
chanalert(s_ts, "Akilling %s for Virus %s", u->nick, ve->name);
|
||||
break;
|
||||
}
|
||||
case ACT_SVSJOIN:
|
||||
if (ts.dosvsjoin > 0) {
|
||||
if (ts.helpcount > 0) {
|
||||
chanalert(s_ts, "SVSJoining %s Nick to avchan for Virus %s", u->nick, ve->name);
|
||||
break;
|
||||
} else {
|
||||
prefmsg(u->nick, s_ts, ts.nohelp);
|
||||
chanalert(s_ts, "Akilling %s for Virus %s (No Helpers Logged in)", u->nick, ve->name);
|
||||
globops(s_ts, "Akilling %s for Virus %s (No Helpers Logged in)", u->nick, ve->name);
|
||||
break;
|
||||
}
|
||||
}
|
||||
case ACT_WARN:
|
||||
chanalert(s_ts, "Warning, %s is Infected with %s Trojan/Virus. No Action Taken", u->nick, ve->name);
|
||||
globops(s_ts, "Warning, %s is Infected with %s Trojan/Virus. No Action Taken", u->nick, ve->name);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void _init() {
|
||||
|
||||
s_ts = "TrojanServ";
|
||||
exempt = list_create(MAX_EXEMPTS);
|
||||
viri = list_create(MAX_VIRI);
|
||||
ts.init = 0;
|
||||
ts.timedif = 300;
|
||||
ts.doscan = 1;
|
||||
snprintf(ts.signonscanmsg, 512, "Your IRC client is being checked for Trojans. Please dis-regard VERSION messages from %s", s_ts);
|
||||
snprintf(ts.akillinfo, 512, "You have been Akilled from this network. Please get a virus scanner and check your PC");
|
||||
snprintf(ts.nohelp, 512, "No Helpers are online at the moment, so you have been Akilled from this network. Please visit http://www.nohack.org for Trojan/Virus Info");
|
||||
ts.breakorcont = 1;
|
||||
ts.doakill = 1;
|
||||
ts.dosvsjoin = 1;
|
||||
ts.helpcount = 0;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
void _fini() {
|
||||
|
||||
};
|
||||
|
||||
|
85
SecureServ.h
Normal file
85
SecureServ.h
Normal file
|
@ -0,0 +1,85 @@
|
|||
/* NetStats - IRC Statistical Services Copyright (c) 1999 Adam Rutter,
|
||||
** Justin Hammond http://codeworks.kamserve.com
|
||||
*
|
||||
** Based from GeoStats 1.1.0 by Johnathan George net@lite.net
|
||||
*
|
||||
** NetStats CVS Identification
|
||||
** $Id: SecureServ.h,v 1.1 2003/04/18 04:38:43 fishwaldo Exp $
|
||||
*/
|
||||
|
||||
|
||||
#ifndef TS_H
|
||||
#define TS_H
|
||||
|
||||
#include "modconfig.h"
|
||||
|
||||
typedef struct virientry {
|
||||
char name[MAXHOST];
|
||||
int dettype;
|
||||
int var1;
|
||||
int var2;
|
||||
char ctcptype[MAXHOST];
|
||||
char recvmsg[MAXHOST];
|
||||
char sendmsg[MAXHOST];
|
||||
int action;
|
||||
int nofound;
|
||||
int noopen;
|
||||
} virientry;
|
||||
|
||||
/* Detection Types */
|
||||
#define DET_CTCP 0
|
||||
#define DET_MSG 1
|
||||
|
||||
/* Action List */
|
||||
#define ACT_SVSJOIN 0
|
||||
#define ACT_AKILL 1
|
||||
#define ACT_WARN 2
|
||||
#define ACT_NOTHING 3
|
||||
|
||||
|
||||
char *s_ts;
|
||||
|
||||
|
||||
struct ts {
|
||||
int init;
|
||||
int timedif;
|
||||
int doscan;
|
||||
int viriversion;
|
||||
char signonscanmsg[512];
|
||||
char akillinfo[512];
|
||||
char nohelp[512];
|
||||
int breakorcont;
|
||||
int doakill;
|
||||
int dosvsjoin;
|
||||
int helpcount;
|
||||
|
||||
} ts;
|
||||
|
||||
|
||||
struct exempts {
|
||||
char host[MAXHOST];
|
||||
int server;
|
||||
char who[MAXNICK];
|
||||
char reason[MAXHOST];
|
||||
};
|
||||
|
||||
typedef struct exempts exemptinfo;
|
||||
|
||||
|
||||
/* this is the list of viri */
|
||||
|
||||
list_t *viri;
|
||||
|
||||
/* this is the list of exempted hosts/servers */
|
||||
list_t *exempt;
|
||||
|
||||
/* this is the size of the exempt list */
|
||||
#define MAX_EXEMPTS 100
|
||||
#define MAX_VIRI 100
|
||||
|
||||
/* ts.c */
|
||||
int findscan(const void *key1, const void *key2);
|
||||
|
||||
|
||||
|
||||
#endif /* TS_H */
|
121
SecureServ_help.c
Normal file
121
SecureServ_help.c
Normal file
|
@ -0,0 +1,121 @@
|
|||
/* NeoStats - IRC Statistical Services Copyright (c) 1999-2002 NeoStats Group Inc.
|
||||
** Copyright (c) 1999-2002 Adam Rutter, Justin Hammond
|
||||
** http://www.neostats.net/
|
||||
**
|
||||
** 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
|
||||
**
|
||||
** NeoStats CVS Identification
|
||||
** $Id: SecureServ_help.c,v 1.1 2003/04/18 04:38:44 fishwaldo Exp $
|
||||
*/
|
||||
|
||||
#include "stats.h"
|
||||
|
||||
const char *ts_help[] = {
|
||||
"\2Open Proxy Scanning Bot HELP\2",
|
||||
"",
|
||||
" This bot scans the network for insecure clients. For more info",
|
||||
" \2/msg ts info\2",
|
||||
"",
|
||||
"COMMANDS:",
|
||||
" LOOKUP INFO",
|
||||
"",
|
||||
NULL
|
||||
};
|
||||
|
||||
const char *ts_help_oper[] = {
|
||||
"OPERTATOR COMMANDS:",
|
||||
" CHECK STATUS SET EXCLUDE",
|
||||
"",
|
||||
NULL
|
||||
};
|
||||
|
||||
const char *ts_help_lookup[] = {
|
||||
"Usage: \2LOOKUP <ip or Hostname> <flag>\2",
|
||||
"",
|
||||
"This command allows you to lookup DNS records on the Internet",
|
||||
"Different types of Records can be looked up by specifing different flags",
|
||||
"",
|
||||
"The Flags are:",
|
||||
" txt - Lookup Text Records",
|
||||
" rp - Lookup the Responsible Person for this record",
|
||||
" ns - Lookup the NameServers for this record",
|
||||
" soa - Lookup the SOA for this Record",
|
||||
"",
|
||||
"If you do not specify a flag, it defaults to looking up either the IP address for Hostnames, or",
|
||||
"The Hostname for IP addresses",
|
||||
"",
|
||||
NULL
|
||||
};
|
||||
|
||||
const char *ts_help_info[] = {
|
||||
"\2Open Proxy Scanning Bot Information\2",
|
||||
"",
|
||||
"This bot is intended to scan clients connecting to this network for insecure proxies",
|
||||
"Insecure proxies are often used to attack networks or channel with \2clone\2 bots",
|
||||
"This check scans the following ports:",
|
||||
" 3128, 8080, 80 23 and 1080",
|
||||
"if you have Firewall, or IDS software, please ignore any errors that this scan may generate",
|
||||
"",
|
||||
"If you have any futher questions, please contact network adminstration staff",
|
||||
NULL
|
||||
};
|
||||
|
||||
const char *ts_help_check[] = {
|
||||
"Usage: \2CHECK <nickname/IP/hostname>\2",
|
||||
"",
|
||||
"This option will scan either a user connected to your Network",
|
||||
"Or a IP address or Hostname for Insecure proxies, and report the status to you",
|
||||
"If a Insecure proxy is found, the host will be banned from the network",
|
||||
"",
|
||||
NULL
|
||||
};
|
||||
|
||||
const char *ts_help_status[] = {
|
||||
"Usage: \2STATUS\2",
|
||||
"",
|
||||
"View Detailed information about the state of the Open Proxy Scanning Bot",
|
||||
"",
|
||||
NULL
|
||||
};
|
||||
|
||||
const char *ts_help_set[] = {
|
||||
"Usage: \2SET <OPTIONS> <SETTING>\2",
|
||||
"",
|
||||
"This command will set various options relating to OPSB.",
|
||||
"You can view the settings by typing \2SET LIST\2",
|
||||
"The Settings take effect straight away",
|
||||
"The Options are:",
|
||||
" \2TARGETIP\2 - Change the IP address we try to make the proxies connect to",
|
||||
" This should be set to a IP address of on of your IRC Servers.",
|
||||
" \2TARGETPORT\2 - Change the Port number we try to make proxies connect to",
|
||||
" This should be a port that runs on your IRCD",
|
||||
" \2CACHETIME\2 - This sets the amount of time (in Seconds) that a entry will be cached",
|
||||
" \2DISABLESCAN\2 - This disables the actual proxy scan, and only does a lookup in the DNS",
|
||||
" Blacklist to see if this host has been listed as a open proxy",
|
||||
"\2Advanced Settings\2 - These settings should not be changed unless you know the effects in full",
|
||||
" \2OPMDOMAIN\2 - Change the Domain we use to Lookup for Blacklists.",
|
||||
" \2MAXBYTES\2 - This is the maximum number of bytes we recieve from a proxy before disconnecting it",
|
||||
" \2TIMEOUT\2 - This is the ammount of time we wait for a proxy to respond to our servers before",
|
||||
" Disconnecting, and assuming its not a open Proxy",
|
||||
" \2OPENSTRING\2 - This is the string we expect to see if there is a successfull Open Proxy",
|
||||
" \2SPLITTIME\2 - This is used to determine if users connecting to the network are part of a Netjoin",
|
||||
" (when two servers link together)",
|
||||
" \2SCANMSG\2 - This is the message sent to a user when we scan their hosts",
|
||||
" \2BANTIME\2 - This is how long the user will be banned from the network for",
|
||||
"",
|
||||
NULL
|
||||
};
|
||||
|
21
config.cache
Normal file
21
config.cache
Normal file
|
@ -0,0 +1,21 @@
|
|||
# This file is a shell script that caches the results of configure
|
||||
# tests run on this system so they can be shared between configure
|
||||
# scripts and configure runs. It is not useful on other systems.
|
||||
# If it contains results you don't want to keep, you may remove or edit it.
|
||||
#
|
||||
# By default, configure uses ./config.cache as the cache file,
|
||||
# creating it if it does not exist already. You can give configure
|
||||
# the --cache-file=FILE option to use a different cache file; that is
|
||||
# what configure does when it calls configure scripts in
|
||||
# subdirectories, so they share the cache.
|
||||
# Giving --cache-file=/dev/null disables caching, for debugging configure.
|
||||
# config.status only pays attention to the cache file if you give it the
|
||||
# --recheck option to rerun configure.
|
||||
#
|
||||
ac_cv_file__home_fish_NeoStats__include_dl_h=${ac_cv_file__home_fish_NeoStats__include_dl_h=yes}
|
||||
ac_cv_path_install=${ac_cv_path_install='/usr/bin/install -c'}
|
||||
ac_cv_prog_CC=${ac_cv_prog_CC=gcc}
|
||||
ac_cv_prog_cc_cross=${ac_cv_prog_cc_cross=no}
|
||||
ac_cv_prog_cc_g=${ac_cv_prog_cc_g=yes}
|
||||
ac_cv_prog_cc_works=${ac_cv_prog_cc_works=yes}
|
||||
ac_cv_prog_gcc=${ac_cv_prog_gcc=yes}
|
848
config.status
Executable file
848
config.status
Executable file
|
@ -0,0 +1,848 @@
|
|||
#! /bin/sh
|
||||
# Generated by configure.
|
||||
# Run this file to recreate the current configuration.
|
||||
# Compiler output produced by configure, useful for debugging
|
||||
# configure, is in config.log if it exists.
|
||||
|
||||
debug=false
|
||||
ac_cs_recheck=false
|
||||
ac_cs_silent=false
|
||||
SHELL=${CONFIG_SHELL-/bin/sh}
|
||||
## --------------------- ##
|
||||
## M4sh Initialization. ##
|
||||
## --------------------- ##
|
||||
|
||||
# Be Bourne compatible
|
||||
if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
|
||||
emulate sh
|
||||
NULLCMD=:
|
||||
# Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
|
||||
# is contrary to our usage. Disable this feature.
|
||||
alias -g '${1+"$@"}'='"$@"'
|
||||
elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then
|
||||
set -o posix
|
||||
fi
|
||||
|
||||
# Support unset when possible.
|
||||
if (FOO=FOO; unset FOO) >/dev/null 2>&1; then
|
||||
as_unset=unset
|
||||
else
|
||||
as_unset=false
|
||||
fi
|
||||
|
||||
|
||||
# Work around bugs in pre-3.0 UWIN ksh.
|
||||
$as_unset ENV MAIL MAILPATH
|
||||
PS1='$ '
|
||||
PS2='> '
|
||||
PS4='+ '
|
||||
|
||||
# NLS nuisances.
|
||||
for as_var in \
|
||||
LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \
|
||||
LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \
|
||||
LC_TELEPHONE LC_TIME
|
||||
do
|
||||
if (set +x; test -n "`(eval $as_var=C; export $as_var) 2>&1`"); then
|
||||
eval $as_var=C; export $as_var
|
||||
else
|
||||
$as_unset $as_var
|
||||
fi
|
||||
done
|
||||
|
||||
# Required to use basename.
|
||||
if expr a : '\(a\)' >/dev/null 2>&1; then
|
||||
as_expr=expr
|
||||
else
|
||||
as_expr=false
|
||||
fi
|
||||
|
||||
if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then
|
||||
as_basename=basename
|
||||
else
|
||||
as_basename=false
|
||||
fi
|
||||
|
||||
|
||||
# Name of the executable.
|
||||
as_me=`$as_basename "$0" ||
|
||||
$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
|
||||
X"$0" : 'X\(//\)$' \| \
|
||||
X"$0" : 'X\(/\)$' \| \
|
||||
. : '\(.\)' 2>/dev/null ||
|
||||
echo X/"$0" |
|
||||
sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; }
|
||||
/^X\/\(\/\/\)$/{ s//\1/; q; }
|
||||
/^X\/\(\/\).*/{ s//\1/; q; }
|
||||
s/.*/./; q'`
|
||||
|
||||
|
||||
# PATH needs CR, and LINENO needs CR and PATH.
|
||||
# Avoid depending upon Character Ranges.
|
||||
as_cr_letters='abcdefghijklmnopqrstuvwxyz'
|
||||
as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
|
||||
as_cr_Letters=$as_cr_letters$as_cr_LETTERS
|
||||
as_cr_digits='0123456789'
|
||||
as_cr_alnum=$as_cr_Letters$as_cr_digits
|
||||
|
||||
# The user is always right.
|
||||
if test "${PATH_SEPARATOR+set}" != set; then
|
||||
echo "#! /bin/sh" >conf$$.sh
|
||||
echo "exit 0" >>conf$$.sh
|
||||
chmod +x conf$$.sh
|
||||
if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
|
||||
PATH_SEPARATOR=';'
|
||||
else
|
||||
PATH_SEPARATOR=:
|
||||
fi
|
||||
rm -f conf$$.sh
|
||||
fi
|
||||
|
||||
|
||||
as_lineno_1=$LINENO
|
||||
as_lineno_2=$LINENO
|
||||
as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
|
||||
test "x$as_lineno_1" != "x$as_lineno_2" &&
|
||||
test "x$as_lineno_3" = "x$as_lineno_2" || {
|
||||
# Find who we are. Look in the path if we contain no path at all
|
||||
# relative or not.
|
||||
case $0 in
|
||||
*[\\/]* ) as_myself=$0 ;;
|
||||
*) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
|
||||
for as_dir in $PATH
|
||||
do
|
||||
IFS=$as_save_IFS
|
||||
test -z "$as_dir" && as_dir=.
|
||||
test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
|
||||
done
|
||||
|
||||
;;
|
||||
esac
|
||||
# We did not find ourselves, most probably we were run as `sh COMMAND'
|
||||
# in which case we are not to be found in the path.
|
||||
if test "x$as_myself" = x; then
|
||||
as_myself=$0
|
||||
fi
|
||||
if test ! -f "$as_myself"; then
|
||||
{ { echo "$as_me:$LINENO: error: cannot find myself; rerun with an absolute path" >&5
|
||||
echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2;}
|
||||
{ (exit 1); exit 1; }; }
|
||||
fi
|
||||
case $CONFIG_SHELL in
|
||||
'')
|
||||
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
|
||||
for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
|
||||
do
|
||||
IFS=$as_save_IFS
|
||||
test -z "$as_dir" && as_dir=.
|
||||
for as_base in sh bash ksh sh5; do
|
||||
case $as_dir in
|
||||
/*)
|
||||
if ("$as_dir/$as_base" -c '
|
||||
as_lineno_1=$LINENO
|
||||
as_lineno_2=$LINENO
|
||||
as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
|
||||
test "x$as_lineno_1" != "x$as_lineno_2" &&
|
||||
test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then
|
||||
$as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; }
|
||||
$as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; }
|
||||
CONFIG_SHELL=$as_dir/$as_base
|
||||
export CONFIG_SHELL
|
||||
exec "$CONFIG_SHELL" "$0" ${1+"$@"}
|
||||
fi;;
|
||||
esac
|
||||
done
|
||||
done
|
||||
;;
|
||||
esac
|
||||
|
||||
# Create $as_me.lineno as a copy of $as_myself, but with $LINENO
|
||||
# uniformly replaced by the line number. The first 'sed' inserts a
|
||||
# line-number line before each line; the second 'sed' does the real
|
||||
# work. The second script uses 'N' to pair each line-number line
|
||||
# with the numbered line, and appends trailing '-' during
|
||||
# substitution so that $LINENO is not a special case at line end.
|
||||
# (Raja R Harinath suggested sed '=', and Paul Eggert wrote the
|
||||
# second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-)
|
||||
sed '=' <$as_myself |
|
||||
sed '
|
||||
N
|
||||
s,$,-,
|
||||
: loop
|
||||
s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3,
|
||||
t loop
|
||||
s,-$,,
|
||||
s,^['$as_cr_digits']*\n,,
|
||||
' >$as_me.lineno &&
|
||||
chmod +x $as_me.lineno ||
|
||||
{ { echo "$as_me:$LINENO: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&5
|
||||
echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2;}
|
||||
{ (exit 1); exit 1; }; }
|
||||
|
||||
# Don't try to exec as it changes $[0], causing all sort of problems
|
||||
# (the dirname of $[0] is not the place where we might find the
|
||||
# original and so on. Autoconf is especially sensible to this).
|
||||
. ./$as_me.lineno
|
||||
# Exit status is that of the last command.
|
||||
exit
|
||||
}
|
||||
|
||||
|
||||
case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in
|
||||
*c*,-n*) ECHO_N= ECHO_C='
|
||||
' ECHO_T=' ' ;;
|
||||
*c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;;
|
||||
*) ECHO_N= ECHO_C='\c' ECHO_T= ;;
|
||||
esac
|
||||
|
||||
if expr a : '\(a\)' >/dev/null 2>&1; then
|
||||
as_expr=expr
|
||||
else
|
||||
as_expr=false
|
||||
fi
|
||||
|
||||
rm -f conf$$ conf$$.exe conf$$.file
|
||||
echo >conf$$.file
|
||||
if ln -s conf$$.file conf$$ 2>/dev/null; then
|
||||
# We could just check for DJGPP; but this test a) works b) is more generic
|
||||
# and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04).
|
||||
if test -f conf$$.exe; then
|
||||
# Don't use ln at all; we don't have any links
|
||||
as_ln_s='cp -p'
|
||||
else
|
||||
as_ln_s='ln -s'
|
||||
fi
|
||||
elif ln conf$$.file conf$$ 2>/dev/null; then
|
||||
as_ln_s=ln
|
||||
else
|
||||
as_ln_s='cp -p'
|
||||
fi
|
||||
rm -f conf$$ conf$$.exe conf$$.file
|
||||
|
||||
if mkdir -p . 2>/dev/null; then
|
||||
as_mkdir_p=:
|
||||
else
|
||||
as_mkdir_p=false
|
||||
fi
|
||||
|
||||
as_executable_p="test -f"
|
||||
|
||||
# Sed expression to map a string onto a valid CPP name.
|
||||
as_tr_cpp="sed y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g"
|
||||
|
||||
# Sed expression to map a string onto a valid variable name.
|
||||
as_tr_sh="sed y%*+%pp%;s%[^_$as_cr_alnum]%_%g"
|
||||
|
||||
|
||||
# IFS
|
||||
# We need space, tab and new line, in precisely that order.
|
||||
as_nl='
|
||||
'
|
||||
IFS=" $as_nl"
|
||||
|
||||
# CDPATH.
|
||||
$as_unset CDPATH
|
||||
|
||||
exec 6>&1
|
||||
|
||||
# Open the log real soon, to keep \$[0] and so on meaningful, and to
|
||||
# report actual input values of CONFIG_FILES etc. instead of their
|
||||
# values after options handling. Logging --version etc. is OK.
|
||||
exec 5>>config.log
|
||||
{
|
||||
echo
|
||||
sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX
|
||||
## Running $as_me. ##
|
||||
_ASBOX
|
||||
} >&5
|
||||
cat >&5 <<_CSEOF
|
||||
|
||||
This file was extended by $as_me, which was
|
||||
generated by GNU Autoconf 2.57. Invocation command line was
|
||||
|
||||
CONFIG_FILES = $CONFIG_FILES
|
||||
CONFIG_HEADERS = $CONFIG_HEADERS
|
||||
CONFIG_LINKS = $CONFIG_LINKS
|
||||
CONFIG_COMMANDS = $CONFIG_COMMANDS
|
||||
$ $0 $@
|
||||
|
||||
_CSEOF
|
||||
echo "on `(hostname || uname -n) 2>/dev/null | sed 1q`" >&5
|
||||
echo >&5
|
||||
config_files=" Makefile"
|
||||
config_headers=" modconfig.h"
|
||||
|
||||
ac_cs_usage="\
|
||||
\`$as_me' instantiates files from templates according to the
|
||||
current configuration.
|
||||
|
||||
Usage: $0 [OPTIONS] [FILE]...
|
||||
|
||||
-h, --help print this help, then exit
|
||||
-V, --version print version number, then exit
|
||||
-q, --quiet do not print progress messages
|
||||
-d, --debug don't remove temporary files
|
||||
--recheck update $as_me by reconfiguring in the same conditions
|
||||
--file=FILE[:TEMPLATE]
|
||||
instantiate the configuration file FILE
|
||||
--header=FILE[:TEMPLATE]
|
||||
instantiate the configuration header FILE
|
||||
|
||||
Configuration files:
|
||||
$config_files
|
||||
|
||||
Configuration headers:
|
||||
$config_headers
|
||||
|
||||
Report bugs to <bug-autoconf@gnu.org>."
|
||||
ac_cs_version="\
|
||||
config.status
|
||||
configured by ./configure, generated by GNU Autoconf 2.57,
|
||||
with options \"\"
|
||||
|
||||
Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001
|
||||
Free Software Foundation, Inc.
|
||||
This config.status script is free software; the Free Software Foundation
|
||||
gives unlimited permission to copy, distribute and modify it."
|
||||
srcdir=.
|
||||
INSTALL="/usr/bin/install -c"
|
||||
# If no file are specified by the user, then we need to provide default
|
||||
# value. By we need to know if files were specified by the user.
|
||||
ac_need_defaults=:
|
||||
while test $# != 0
|
||||
do
|
||||
case $1 in
|
||||
--*=*)
|
||||
ac_option=`expr "x$1" : 'x\([^=]*\)='`
|
||||
ac_optarg=`expr "x$1" : 'x[^=]*=\(.*\)'`
|
||||
ac_shift=:
|
||||
;;
|
||||
-*)
|
||||
ac_option=$1
|
||||
ac_optarg=$2
|
||||
ac_shift=shift
|
||||
;;
|
||||
*) # This is not an option, so the user has probably given explicit
|
||||
# arguments.
|
||||
ac_option=$1
|
||||
ac_need_defaults=false;;
|
||||
esac
|
||||
|
||||
case $ac_option in
|
||||
# Handling of the options.
|
||||
-recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
|
||||
ac_cs_recheck=: ;;
|
||||
--version | --vers* | -V )
|
||||
echo "$ac_cs_version"; exit 0 ;;
|
||||
--he | --h)
|
||||
# Conflict between --help and --header
|
||||
{ { echo "$as_me:$LINENO: error: ambiguous option: $1
|
||||
Try \`$0 --help' for more information." >&5
|
||||
echo "$as_me: error: ambiguous option: $1
|
||||
Try \`$0 --help' for more information." >&2;}
|
||||
{ (exit 1); exit 1; }; };;
|
||||
--help | --hel | -h )
|
||||
echo "$ac_cs_usage"; exit 0 ;;
|
||||
--debug | --d* | -d )
|
||||
debug=: ;;
|
||||
--file | --fil | --fi | --f )
|
||||
$ac_shift
|
||||
CONFIG_FILES="$CONFIG_FILES $ac_optarg"
|
||||
ac_need_defaults=false;;
|
||||
--header | --heade | --head | --hea )
|
||||
$ac_shift
|
||||
CONFIG_HEADERS="$CONFIG_HEADERS $ac_optarg"
|
||||
ac_need_defaults=false;;
|
||||
-q | -quiet | --quiet | --quie | --qui | --qu | --q \
|
||||
| -silent | --silent | --silen | --sile | --sil | --si | --s)
|
||||
ac_cs_silent=: ;;
|
||||
|
||||
# This is an error.
|
||||
-*) { { echo "$as_me:$LINENO: error: unrecognized option: $1
|
||||
Try \`$0 --help' for more information." >&5
|
||||
echo "$as_me: error: unrecognized option: $1
|
||||
Try \`$0 --help' for more information." >&2;}
|
||||
{ (exit 1); exit 1; }; } ;;
|
||||
|
||||
*) ac_config_targets="$ac_config_targets $1" ;;
|
||||
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
ac_configure_extra_args=
|
||||
|
||||
if $ac_cs_silent; then
|
||||
exec 6>/dev/null
|
||||
ac_configure_extra_args="$ac_configure_extra_args --silent"
|
||||
fi
|
||||
|
||||
if $ac_cs_recheck; then
|
||||
echo "running /bin/sh ./configure " $ac_configure_extra_args " --no-create --no-recursion" >&6
|
||||
exec /bin/sh ./configure $ac_configure_extra_args --no-create --no-recursion
|
||||
fi
|
||||
|
||||
for ac_config_target in $ac_config_targets
|
||||
do
|
||||
case "$ac_config_target" in
|
||||
# Handling of arguments.
|
||||
"Makefile" ) CONFIG_FILES="$CONFIG_FILES Makefile" ;;
|
||||
"modconfig.h" ) CONFIG_HEADERS="$CONFIG_HEADERS modconfig.h" ;;
|
||||
*) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5
|
||||
echo "$as_me: error: invalid argument: $ac_config_target" >&2;}
|
||||
{ (exit 1); exit 1; }; };;
|
||||
esac
|
||||
done
|
||||
|
||||
# If the user did not use the arguments to specify the items to instantiate,
|
||||
# then the envvar interface is used. Set only those that are not.
|
||||
# We use the long form for the default assignment because of an extremely
|
||||
# bizarre bug on SunOS 4.1.3.
|
||||
if $ac_need_defaults; then
|
||||
test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files
|
||||
test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers
|
||||
fi
|
||||
|
||||
# Have a temporary directory for convenience. Make it in the build tree
|
||||
# simply because there is no reason to put it here, and in addition,
|
||||
# creating and moving files from /tmp can sometimes cause problems.
|
||||
# Create a temporary directory, and hook for its removal unless debugging.
|
||||
$debug ||
|
||||
{
|
||||
trap 'exit_status=$?; rm -rf $tmp && exit $exit_status' 0
|
||||
trap '{ (exit 1); exit 1; }' 1 2 13 15
|
||||
}
|
||||
|
||||
# Create a (secure) tmp directory for tmp files.
|
||||
|
||||
{
|
||||
tmp=`(umask 077 && mktemp -d -q "./confstatXXXXXX") 2>/dev/null` &&
|
||||
test -n "$tmp" && test -d "$tmp"
|
||||
} ||
|
||||
{
|
||||
tmp=./confstat$$-$RANDOM
|
||||
(umask 077 && mkdir $tmp)
|
||||
} ||
|
||||
{
|
||||
echo "$me: cannot create a temporary directory in ." >&2
|
||||
{ (exit 1); exit 1; }
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# CONFIG_FILES section.
|
||||
#
|
||||
|
||||
# No need to generate the scripts if there are no CONFIG_FILES.
|
||||
# This happens for instance when ./config.status config.h
|
||||
if test -n "$CONFIG_FILES"; then
|
||||
# Protect against being on the right side of a sed subst in config.status.
|
||||
sed 's/,@/@@/; s/@,/@@/; s/,;t t$/@;t t/; /@;t t$/s/[\\&,]/\\&/g;
|
||||
s/@@/,@/; s/@@/@,/; s/@;t t$/,;t t/' >$tmp/subs.sed <<\CEOF
|
||||
s,@SHELL@,/bin/sh,;t t
|
||||
s,@PATH_SEPARATOR@,:,;t t
|
||||
s,@PACKAGE_NAME@,,;t t
|
||||
s,@PACKAGE_TARNAME@,,;t t
|
||||
s,@PACKAGE_VERSION@,,;t t
|
||||
s,@PACKAGE_STRING@,,;t t
|
||||
s,@PACKAGE_BUGREPORT@,,;t t
|
||||
s,@exec_prefix@,${prefix},;t t
|
||||
s,@prefix@,/home/fish/NeoStats/,;t t
|
||||
s,@program_transform_name@,s,x,x,,;t t
|
||||
s,@bindir@,${exec_prefix}/bin,;t t
|
||||
s,@sbindir@,${exec_prefix}/sbin,;t t
|
||||
s,@libexecdir@,${exec_prefix}/libexec,;t t
|
||||
s,@datadir@,${prefix}/share,;t t
|
||||
s,@sysconfdir@,${prefix}/etc,;t t
|
||||
s,@sharedstatedir@,${prefix}/com,;t t
|
||||
s,@localstatedir@,${prefix}/var,;t t
|
||||
s,@libdir@,${exec_prefix}/lib,;t t
|
||||
s,@includedir@,${prefix}/include,;t t
|
||||
s,@oldincludedir@,/usr/include,;t t
|
||||
s,@infodir@,${prefix}/info,;t t
|
||||
s,@mandir@,${prefix}/man,;t t
|
||||
s,@build_alias@,,;t t
|
||||
s,@host_alias@,,;t t
|
||||
s,@target_alias@,,;t t
|
||||
s,@DEFS@,-DHAVE_CONFIG_H,;t t
|
||||
s,@ECHO_C@,,;t t
|
||||
s,@ECHO_N@,-n,;t t
|
||||
s,@ECHO_T@,,;t t
|
||||
s,@LIBS@,,;t t
|
||||
s,@CC@,gcc,;t t
|
||||
s,@CFLAGS@, -O2 -Wall,;t t
|
||||
s,@LDFLAGS@,,;t t
|
||||
s,@CPPFLAGS@, -I/home/fish/NeoStats//include/,;t t
|
||||
s,@ac_ct_CC@,gcc,;t t
|
||||
s,@EXEEXT@,,;t t
|
||||
s,@OBJEXT@,o,;t t
|
||||
s,@INSTALL_PROGRAM@,${INSTALL},;t t
|
||||
s,@INSTALL_SCRIPT@,${INSTALL},;t t
|
||||
s,@INSTALL_DATA@,${INSTALL} -m 644,;t t
|
||||
s,@DIRINST@,/home/fish/NeoStats/,;t t
|
||||
s,@LIBOBJS@,,;t t
|
||||
s,@LTLIBOBJS@,,;t t
|
||||
CEOF
|
||||
|
||||
# Split the substitutions into bite-sized pieces for seds with
|
||||
# small command number limits, like on Digital OSF/1 and HP-UX.
|
||||
ac_max_sed_lines=48
|
||||
ac_sed_frag=1 # Number of current file.
|
||||
ac_beg=1 # First line for current file.
|
||||
ac_end=$ac_max_sed_lines # Line after last line for current file.
|
||||
ac_more_lines=:
|
||||
ac_sed_cmds=
|
||||
while $ac_more_lines; do
|
||||
if test $ac_beg -gt 1; then
|
||||
sed "1,${ac_beg}d; ${ac_end}q" $tmp/subs.sed >$tmp/subs.frag
|
||||
else
|
||||
sed "${ac_end}q" $tmp/subs.sed >$tmp/subs.frag
|
||||
fi
|
||||
if test ! -s $tmp/subs.frag; then
|
||||
ac_more_lines=false
|
||||
else
|
||||
# The purpose of the label and of the branching condition is to
|
||||
# speed up the sed processing (if there are no `@' at all, there
|
||||
# is no need to browse any of the substitutions).
|
||||
# These are the two extra sed commands mentioned above.
|
||||
(echo ':t
|
||||
/@[a-zA-Z_][a-zA-Z_0-9]*@/!b' && cat $tmp/subs.frag) >$tmp/subs-$ac_sed_frag.sed
|
||||
if test -z "$ac_sed_cmds"; then
|
||||
ac_sed_cmds="sed -f $tmp/subs-$ac_sed_frag.sed"
|
||||
else
|
||||
ac_sed_cmds="$ac_sed_cmds | sed -f $tmp/subs-$ac_sed_frag.sed"
|
||||
fi
|
||||
ac_sed_frag=`expr $ac_sed_frag + 1`
|
||||
ac_beg=$ac_end
|
||||
ac_end=`expr $ac_end + $ac_max_sed_lines`
|
||||
fi
|
||||
done
|
||||
if test -z "$ac_sed_cmds"; then
|
||||
ac_sed_cmds=cat
|
||||
fi
|
||||
fi # test -n "$CONFIG_FILES"
|
||||
|
||||
for ac_file in : $CONFIG_FILES; do test "x$ac_file" = x: && continue
|
||||
# Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
|
||||
case $ac_file in
|
||||
- | *:- | *:-:* ) # input from stdin
|
||||
cat >$tmp/stdin
|
||||
ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
|
||||
ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
|
||||
*:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
|
||||
ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
|
||||
* ) ac_file_in=$ac_file.in ;;
|
||||
esac
|
||||
|
||||
# Compute @srcdir@, @top_srcdir@, and @INSTALL@ for subdirectories.
|
||||
ac_dir=`(dirname "$ac_file") 2>/dev/null ||
|
||||
$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
|
||||
X"$ac_file" : 'X\(//\)[^/]' \| \
|
||||
X"$ac_file" : 'X\(//\)$' \| \
|
||||
X"$ac_file" : 'X\(/\)' \| \
|
||||
. : '\(.\)' 2>/dev/null ||
|
||||
echo X"$ac_file" |
|
||||
sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
|
||||
/^X\(\/\/\)[^/].*/{ s//\1/; q; }
|
||||
/^X\(\/\/\)$/{ s//\1/; q; }
|
||||
/^X\(\/\).*/{ s//\1/; q; }
|
||||
s/.*/./; q'`
|
||||
{ if $as_mkdir_p; then
|
||||
mkdir -p "$ac_dir"
|
||||
else
|
||||
as_dir="$ac_dir"
|
||||
as_dirs=
|
||||
while test ! -d "$as_dir"; do
|
||||
as_dirs="$as_dir $as_dirs"
|
||||
as_dir=`(dirname "$as_dir") 2>/dev/null ||
|
||||
$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
|
||||
X"$as_dir" : 'X\(//\)[^/]' \| \
|
||||
X"$as_dir" : 'X\(//\)$' \| \
|
||||
X"$as_dir" : 'X\(/\)' \| \
|
||||
. : '\(.\)' 2>/dev/null ||
|
||||
echo X"$as_dir" |
|
||||
sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
|
||||
/^X\(\/\/\)[^/].*/{ s//\1/; q; }
|
||||
/^X\(\/\/\)$/{ s//\1/; q; }
|
||||
/^X\(\/\).*/{ s//\1/; q; }
|
||||
s/.*/./; q'`
|
||||
done
|
||||
test ! -n "$as_dirs" || mkdir $as_dirs
|
||||
fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5
|
||||
echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;}
|
||||
{ (exit 1); exit 1; }; }; }
|
||||
|
||||
ac_builddir=.
|
||||
|
||||
if test "$ac_dir" != .; then
|
||||
ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'`
|
||||
# A "../" for each directory in $ac_dir_suffix.
|
||||
ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'`
|
||||
else
|
||||
ac_dir_suffix= ac_top_builddir=
|
||||
fi
|
||||
|
||||
case $srcdir in
|
||||
.) # No --srcdir option. We are building in place.
|
||||
ac_srcdir=.
|
||||
if test -z "$ac_top_builddir"; then
|
||||
ac_top_srcdir=.
|
||||
else
|
||||
ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'`
|
||||
fi ;;
|
||||
[\\/]* | ?:[\\/]* ) # Absolute path.
|
||||
ac_srcdir=$srcdir$ac_dir_suffix;
|
||||
ac_top_srcdir=$srcdir ;;
|
||||
*) # Relative path.
|
||||
ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix
|
||||
ac_top_srcdir=$ac_top_builddir$srcdir ;;
|
||||
esac
|
||||
# Don't blindly perform a `cd "$ac_dir"/$ac_foo && pwd` since $ac_foo can be
|
||||
# absolute.
|
||||
ac_abs_builddir=`cd "$ac_dir" && cd $ac_builddir && pwd`
|
||||
ac_abs_top_builddir=`cd "$ac_dir" && cd ${ac_top_builddir}. && pwd`
|
||||
ac_abs_srcdir=`cd "$ac_dir" && cd $ac_srcdir && pwd`
|
||||
ac_abs_top_srcdir=`cd "$ac_dir" && cd $ac_top_srcdir && pwd`
|
||||
|
||||
|
||||
case $INSTALL in
|
||||
[\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;;
|
||||
*) ac_INSTALL=$ac_top_builddir$INSTALL ;;
|
||||
esac
|
||||
|
||||
if test x"$ac_file" != x-; then
|
||||
{ echo "$as_me:$LINENO: creating $ac_file" >&5
|
||||
echo "$as_me: creating $ac_file" >&6;}
|
||||
rm -f "$ac_file"
|
||||
fi
|
||||
# Let's still pretend it is `configure' which instantiates (i.e., don't
|
||||
# use $as_me), people would be surprised to read:
|
||||
# /* config.h. Generated by config.status. */
|
||||
if test x"$ac_file" = x-; then
|
||||
configure_input=
|
||||
else
|
||||
configure_input="$ac_file. "
|
||||
fi
|
||||
configure_input=$configure_input"Generated from `echo $ac_file_in |
|
||||
sed 's,.*/,,'` by configure."
|
||||
|
||||
# First look for the input files in the build tree, otherwise in the
|
||||
# src tree.
|
||||
ac_file_inputs=`IFS=:
|
||||
for f in $ac_file_in; do
|
||||
case $f in
|
||||
-) echo $tmp/stdin ;;
|
||||
[\\/$]*)
|
||||
# Absolute (can't be DOS-style, as IFS=:)
|
||||
test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5
|
||||
echo "$as_me: error: cannot find input file: $f" >&2;}
|
||||
{ (exit 1); exit 1; }; }
|
||||
echo $f;;
|
||||
*) # Relative
|
||||
if test -f "$f"; then
|
||||
# Build tree
|
||||
echo $f
|
||||
elif test -f "$srcdir/$f"; then
|
||||
# Source tree
|
||||
echo $srcdir/$f
|
||||
else
|
||||
# /dev/null tree
|
||||
{ { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5
|
||||
echo "$as_me: error: cannot find input file: $f" >&2;}
|
||||
{ (exit 1); exit 1; }; }
|
||||
fi;;
|
||||
esac
|
||||
done` || { (exit 1); exit 1; }
|
||||
sed "/^[ ]*VPATH[ ]*=/{
|
||||
s/:*\$(srcdir):*/:/;
|
||||
s/:*\${srcdir}:*/:/;
|
||||
s/:*@srcdir@:*/:/;
|
||||
s/^\([^=]*=[ ]*\):*/\1/;
|
||||
s/:*$//;
|
||||
s/^[^=]*=[ ]*$//;
|
||||
}
|
||||
|
||||
:t
|
||||
/@[a-zA-Z_][a-zA-Z_0-9]*@/!b
|
||||
s,@configure_input@,$configure_input,;t t
|
||||
s,@srcdir@,$ac_srcdir,;t t
|
||||
s,@abs_srcdir@,$ac_abs_srcdir,;t t
|
||||
s,@top_srcdir@,$ac_top_srcdir,;t t
|
||||
s,@abs_top_srcdir@,$ac_abs_top_srcdir,;t t
|
||||
s,@builddir@,$ac_builddir,;t t
|
||||
s,@abs_builddir@,$ac_abs_builddir,;t t
|
||||
s,@top_builddir@,$ac_top_builddir,;t t
|
||||
s,@abs_top_builddir@,$ac_abs_top_builddir,;t t
|
||||
s,@INSTALL@,$ac_INSTALL,;t t
|
||||
" $ac_file_inputs | (eval "$ac_sed_cmds") >$tmp/out
|
||||
rm -f $tmp/stdin
|
||||
if test x"$ac_file" != x-; then
|
||||
mv $tmp/out $ac_file
|
||||
else
|
||||
cat $tmp/out
|
||||
rm -f $tmp/out
|
||||
fi
|
||||
|
||||
done
|
||||
|
||||
#
|
||||
# CONFIG_HEADER section.
|
||||
#
|
||||
|
||||
# These sed commands are passed to sed as "A NAME B NAME C VALUE D", where
|
||||
# NAME is the cpp macro being defined and VALUE is the value it is being given.
|
||||
#
|
||||
# ac_d sets the value in "#define NAME VALUE" lines.
|
||||
ac_dA='s,^\([ ]*\)#\([ ]*define[ ][ ]*\)'
|
||||
ac_dB='[ ].*$,\1#\2'
|
||||
ac_dC=' '
|
||||
ac_dD=',;t'
|
||||
# ac_u turns "#undef NAME" without trailing blanks into "#define NAME VALUE".
|
||||
ac_uA='s,^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)'
|
||||
ac_uB='$,\1#\2define\3'
|
||||
ac_uC=' '
|
||||
ac_uD=',;t'
|
||||
|
||||
for ac_file in : $CONFIG_HEADERS; do test "x$ac_file" = x: && continue
|
||||
# Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
|
||||
case $ac_file in
|
||||
- | *:- | *:-:* ) # input from stdin
|
||||
cat >$tmp/stdin
|
||||
ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
|
||||
ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
|
||||
*:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
|
||||
ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
|
||||
* ) ac_file_in=$ac_file.in ;;
|
||||
esac
|
||||
|
||||
test x"$ac_file" != x- && { echo "$as_me:$LINENO: creating $ac_file" >&5
|
||||
echo "$as_me: creating $ac_file" >&6;}
|
||||
|
||||
# First look for the input files in the build tree, otherwise in the
|
||||
# src tree.
|
||||
ac_file_inputs=`IFS=:
|
||||
for f in $ac_file_in; do
|
||||
case $f in
|
||||
-) echo $tmp/stdin ;;
|
||||
[\\/$]*)
|
||||
# Absolute (can't be DOS-style, as IFS=:)
|
||||
test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5
|
||||
echo "$as_me: error: cannot find input file: $f" >&2;}
|
||||
{ (exit 1); exit 1; }; }
|
||||
echo $f;;
|
||||
*) # Relative
|
||||
if test -f "$f"; then
|
||||
# Build tree
|
||||
echo $f
|
||||
elif test -f "$srcdir/$f"; then
|
||||
# Source tree
|
||||
echo $srcdir/$f
|
||||
else
|
||||
# /dev/null tree
|
||||
{ { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5
|
||||
echo "$as_me: error: cannot find input file: $f" >&2;}
|
||||
{ (exit 1); exit 1; }; }
|
||||
fi;;
|
||||
esac
|
||||
done` || { (exit 1); exit 1; }
|
||||
# Remove the trailing spaces.
|
||||
sed 's/[ ]*$//' $ac_file_inputs >$tmp/in
|
||||
|
||||
# Handle all the #define templates only if necessary.
|
||||
if grep "^[ ]*#[ ]*define" $tmp/in >/dev/null; then
|
||||
# If there are no defines, we may have an empty if/fi
|
||||
:
|
||||
cat >$tmp/defines.sed <<CEOF
|
||||
/^[ ]*#[ ]*define/!b
|
||||
t clr
|
||||
: clr
|
||||
${ac_dA}PACKAGE_NAME${ac_dB}PACKAGE_NAME${ac_dC}""${ac_dD}
|
||||
${ac_dA}PACKAGE_TARNAME${ac_dB}PACKAGE_TARNAME${ac_dC}""${ac_dD}
|
||||
${ac_dA}PACKAGE_VERSION${ac_dB}PACKAGE_VERSION${ac_dC}""${ac_dD}
|
||||
${ac_dA}PACKAGE_STRING${ac_dB}PACKAGE_STRING${ac_dC}""${ac_dD}
|
||||
${ac_dA}PACKAGE_BUGREPORT${ac_dB}PACKAGE_BUGREPORT${ac_dC}""${ac_dD}
|
||||
CEOF
|
||||
sed -f $tmp/defines.sed $tmp/in >$tmp/out
|
||||
rm -f $tmp/in
|
||||
mv $tmp/out $tmp/in
|
||||
|
||||
fi # grep
|
||||
|
||||
# Handle all the #undef templates
|
||||
cat >$tmp/undefs.sed <<CEOF
|
||||
/^[ ]*#[ ]*undef/!b
|
||||
t clr
|
||||
: clr
|
||||
${ac_uA}PACKAGE_NAME${ac_uB}PACKAGE_NAME${ac_uC}""${ac_uD}
|
||||
${ac_uA}PACKAGE_TARNAME${ac_uB}PACKAGE_TARNAME${ac_uC}""${ac_uD}
|
||||
${ac_uA}PACKAGE_VERSION${ac_uB}PACKAGE_VERSION${ac_uC}""${ac_uD}
|
||||
${ac_uA}PACKAGE_STRING${ac_uB}PACKAGE_STRING${ac_uC}""${ac_uD}
|
||||
${ac_uA}PACKAGE_BUGREPORT${ac_uB}PACKAGE_BUGREPORT${ac_uC}""${ac_uD}
|
||||
s,^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*,/* & */,
|
||||
CEOF
|
||||
sed -f $tmp/undefs.sed $tmp/in >$tmp/out
|
||||
rm -f $tmp/in
|
||||
mv $tmp/out $tmp/in
|
||||
|
||||
# Let's still pretend it is `configure' which instantiates (i.e., don't
|
||||
# use $as_me), people would be surprised to read:
|
||||
# /* config.h. Generated by config.status. */
|
||||
if test x"$ac_file" = x-; then
|
||||
echo "/* Generated by configure. */" >$tmp/config.h
|
||||
else
|
||||
echo "/* $ac_file. Generated by configure. */" >$tmp/config.h
|
||||
fi
|
||||
cat $tmp/in >>$tmp/config.h
|
||||
rm -f $tmp/in
|
||||
if test x"$ac_file" != x-; then
|
||||
if diff $ac_file $tmp/config.h >/dev/null 2>&1; then
|
||||
{ echo "$as_me:$LINENO: $ac_file is unchanged" >&5
|
||||
echo "$as_me: $ac_file is unchanged" >&6;}
|
||||
else
|
||||
ac_dir=`(dirname "$ac_file") 2>/dev/null ||
|
||||
$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
|
||||
X"$ac_file" : 'X\(//\)[^/]' \| \
|
||||
X"$ac_file" : 'X\(//\)$' \| \
|
||||
X"$ac_file" : 'X\(/\)' \| \
|
||||
. : '\(.\)' 2>/dev/null ||
|
||||
echo X"$ac_file" |
|
||||
sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
|
||||
/^X\(\/\/\)[^/].*/{ s//\1/; q; }
|
||||
/^X\(\/\/\)$/{ s//\1/; q; }
|
||||
/^X\(\/\).*/{ s//\1/; q; }
|
||||
s/.*/./; q'`
|
||||
{ if $as_mkdir_p; then
|
||||
mkdir -p "$ac_dir"
|
||||
else
|
||||
as_dir="$ac_dir"
|
||||
as_dirs=
|
||||
while test ! -d "$as_dir"; do
|
||||
as_dirs="$as_dir $as_dirs"
|
||||
as_dir=`(dirname "$as_dir") 2>/dev/null ||
|
||||
$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
|
||||
X"$as_dir" : 'X\(//\)[^/]' \| \
|
||||
X"$as_dir" : 'X\(//\)$' \| \
|
||||
X"$as_dir" : 'X\(/\)' \| \
|
||||
. : '\(.\)' 2>/dev/null ||
|
||||
echo X"$as_dir" |
|
||||
sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
|
||||
/^X\(\/\/\)[^/].*/{ s//\1/; q; }
|
||||
/^X\(\/\/\)$/{ s//\1/; q; }
|
||||
/^X\(\/\).*/{ s//\1/; q; }
|
||||
s/.*/./; q'`
|
||||
done
|
||||
test ! -n "$as_dirs" || mkdir $as_dirs
|
||||
fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5
|
||||
echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;}
|
||||
{ (exit 1); exit 1; }; }; }
|
||||
|
||||
rm -f $ac_file
|
||||
mv $tmp/config.h $ac_file
|
||||
fi
|
||||
else
|
||||
cat $tmp/config.h
|
||||
rm -f $tmp/config.h
|
||||
fi
|
||||
done
|
||||
|
||||
{ (exit 0); exit 0; }
|
92
configure.in
Normal file
92
configure.in
Normal file
|
@ -0,0 +1,92 @@
|
|||
dnl Process this file with autoconf to produce a configure script.
|
||||
AC_INIT(SecureServ.c)
|
||||
AC_CONFIG_HEADER(modconfig.h)
|
||||
PACKAGE=TrojanServ
|
||||
VERSION=1.0
|
||||
DIRINST=~/NeoStats/
|
||||
AC_PREFIX_DEFAULT(~/NeoStats/)
|
||||
CFLAGS="$CFLAGS -O2 -Wall"
|
||||
|
||||
dnl Checks for programs.
|
||||
AC_PROG_CC
|
||||
AC_PROG_INSTALL
|
||||
|
||||
AC_MSG_CHECKING(Location of NeoStats...)
|
||||
AC_ARG_WITH(neostats,
|
||||
[ --with-neostats=DIR Location of NeoStats installation],
|
||||
[DIRINST=$withval])
|
||||
AC_MSG_RESULT($DIRINST)
|
||||
|
||||
|
||||
AC_CHECK_FILE($DIRINST/include/dl.h,
|
||||
[INCLUDEDIR="$DIRINST/include/"],
|
||||
[AC_MSG_ERROR(Can't find existing NeoStats Installation please supply with --with-neostats option)])
|
||||
|
||||
CPPFLAGS="$CPPFLAGS -I$INCLUDEDIR"
|
||||
dnl Check we are running the latest supported version of NeoStats
|
||||
AC_MSG_CHECKING(Version of NeoStats...)
|
||||
AC_TRY_RUN(
|
||||
[
|
||||
#include <config.h>
|
||||
#include <stdlib.h>
|
||||
int main(void) {
|
||||
if (MAJOR >= 2) {
|
||||
if (MINOR >= 5) {
|
||||
if (REV >= 2) {
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
exit(1);
|
||||
}
|
||||
], ns_version_ok='yes',
|
||||
ns_version_ok='no',
|
||||
ns_version_ok='no')
|
||||
if test "$ns_version_ok" = "yes"; then
|
||||
AC_MSG_RESULT(Compatible Version);
|
||||
else
|
||||
AC_MSG_ERROR(This Module requires NeoStats 2.5.2 or Higher)
|
||||
fi
|
||||
|
||||
dnl check if we are running with Debug....
|
||||
AC_MSG_CHECKING(Whether to Enable Debuging...)
|
||||
AC_ARG_ENABLE(debug,
|
||||
[ --enable-debug - Enable Debuging],
|
||||
[ case "$enableval" in
|
||||
yes)
|
||||
CFLAGS="$CFLAGS -ggdb"
|
||||
AC_DEFINE(DEBUG,1)
|
||||
AC_MSG_RESULT(yes - Watch your Log Files)
|
||||
;;
|
||||
*)
|
||||
AC_MSG_RESULT(no)
|
||||
;;
|
||||
esac],
|
||||
AC_MSG_RESULT(no)
|
||||
)
|
||||
|
||||
AC_SUBST(DIRINST)
|
||||
AC_SUBST(CFLAGS)
|
||||
AC_OUTPUT(Makefile)
|
||||
echo "(*----------------------------------------------------------*)"
|
||||
echo "(| Important Instructions |)"
|
||||
echo "(*----------------------------------------------------------*)"
|
||||
echo "(| To compile your module, please type 'make' |)"
|
||||
echo "(| If make completes without errors, then you |)"
|
||||
echo "(| Must 'make install', but please be sure that NeoStats |)"
|
||||
echo "(| Is not currently running with a module of the same name |)"
|
||||
echo "(| Running, otherwise Make install will not work |)"
|
||||
echo "(| !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |)"
|
||||
echo "(| If you are running a BSD, make install may produce a |)"
|
||||
echo "(| Error, if that is the case, then please manually copy |)"
|
||||
echo "(| opsb.so to the NeoStats/dl directory |)"
|
||||
echo "(| !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |)"
|
||||
echo "(*----------------------------------------------------------*)"
|
||||
echo "(| For Support please visit: |)"
|
||||
echo "(| IRC: /server irc.irc-chat.org |)"
|
||||
echo "(| #neostats channel |)"
|
||||
echo "(| WWW: http://www.neostats.net/boards/ |)"
|
||||
echo "(*----------------------------------------------------------*)"
|
||||
echo "(|This Module was written by: |)"
|
||||
echo "(| fish (fish@dynam.ac) |)"
|
||||
echo "(*----------------------------------------------------------*)"
|
776
http.c
Normal file
776
http.c
Normal file
|
@ -0,0 +1,776 @@
|
|||
/***************************************************************************
|
||||
*
|
||||
* Library: libhttp
|
||||
*
|
||||
* Description: library for generic http data transfers
|
||||
*
|
||||
***************************************************************************
|
||||
*
|
||||
* HTTPGET/libhttp
|
||||
*
|
||||
* Copyright (C) 1994 by Sami Tikka <sti@iki.fi>
|
||||
* Copyright (C) 2001 by Alan DuBoff <aland@SoftOrchestra.com>
|
||||
*
|
||||
* Last change: 8/27/2001
|
||||
*
|
||||
* The right to use, modify and redistribute this code is allowed
|
||||
* provided the above copyright notice and the below disclaimer appear
|
||||
* on all copies.
|
||||
*
|
||||
* This file is provided AS IS with no warranties of any kind. The author
|
||||
* shall have no liability with respect to the infringement of copyrights,
|
||||
* trade secrets or any patents by this file or any part thereof. In no
|
||||
* event will the author be liable for any lost revenue or profits or
|
||||
* other special, indirect and consequential damages.
|
||||
*
|
||||
* Compile with (g)cc -o httpget httpget.c (-lsocket)
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
#include <ctype.h>
|
||||
#include "http.h"
|
||||
|
||||
#ifdef DEBUG
|
||||
#define debug(path, args...) fprintf(path, ## args)
|
||||
#define debug2(ptr, args...) fwrite(ptr, ## args)
|
||||
#else
|
||||
#define debug(path, args...)
|
||||
#define debug2(ptr, args...)
|
||||
#endif
|
||||
|
||||
char *find_header_end( char *buf, int bytes )
|
||||
{
|
||||
char *end = buf + bytes;
|
||||
|
||||
while( buf < end && !(*buf++ == '\n'
|
||||
&& (*buf == '\n'
|
||||
|| (*buf++ == '\r'
|
||||
&& *buf == '\n'))) ) ;
|
||||
if( *buf == '\n' )
|
||||
return( buf + 1 );
|
||||
return( NULL );
|
||||
}
|
||||
|
||||
#ifdef HF_FIND_HEADER
|
||||
/*
|
||||
* This function try to find the HTTP header specified and return its value.
|
||||
* The 'buf' contains the header is assumed to be terminated by a blank line.
|
||||
* The 'type' must be terminated by a colon, such as "Content-Type:".
|
||||
*/
|
||||
char *find_header( char *buf, int buflen, char *type, char *value, int vsize )
|
||||
{
|
||||
char *end;
|
||||
char *eol;
|
||||
int tl = strlen(type);
|
||||
|
||||
/* Find the end (in case input is not NULL terminated) */
|
||||
if(buflen <= 0)
|
||||
buflen = strlen(buf);
|
||||
end = buf + buflen;
|
||||
|
||||
do /* For each line of header */
|
||||
{
|
||||
/* Note : 'type' *must* be terminated by a ':', otherwise you may
|
||||
* match the wrong header */
|
||||
if( ! strncasecmp( buf, type, tl ) )
|
||||
{
|
||||
buf += tl; /* Skip header type */
|
||||
while( isspace( *buf ) ) /* Skip spaces */
|
||||
buf++;
|
||||
/* We keep the blank line at the end of the header, we are safe */
|
||||
eol = strchr(buf, '\r');
|
||||
/* Unlikely to fail, but let be safe */
|
||||
if( ( eol != NULL ) && ( (eol - buf) < (vsize - 1) ) )
|
||||
{
|
||||
/* Copy, NULL terminate, return */
|
||||
memcpy( value, buf, (eol - buf) );
|
||||
value[(eol - buf)] = '\0';
|
||||
debug( stderr, "Found header %s: %s\n", type, value );
|
||||
return( value );
|
||||
}
|
||||
}
|
||||
} /* Go to start of next line, if any */
|
||||
while( ( ( buf = strchr( buf, '\n' ) ) != NULL ) && ( ++buf < end ) );
|
||||
|
||||
return( NULL );
|
||||
}
|
||||
#endif /* HF_FIND_HEADER */
|
||||
|
||||
/* Separate an URL in its different components.
|
||||
* Note that GET/POST form data is not removed from the "path", and therefore
|
||||
* it can be quite big. That's why we return it and don't copy it.
|
||||
* Jean II */
|
||||
char *parse_url( char *url, char *scheme, char *host, int *port )
|
||||
{
|
||||
char *slash, *colon;
|
||||
char *delim;
|
||||
char *turl;
|
||||
char *t;
|
||||
char *pRet;
|
||||
|
||||
/* All operations on turl so as not to mess contents of url */
|
||||
|
||||
turl = (char *)calloc( 1, strlen( url ) + 1 );
|
||||
if( turl == NULL )
|
||||
return (char *)"";
|
||||
|
||||
strcpy( turl, url );
|
||||
|
||||
delim = "://";
|
||||
|
||||
if( (colon = strstr( turl, delim )) == NULL )
|
||||
{
|
||||
debug( stderr, "Warning: URL is not in format <scheme>://<host>/<path>.\nAssuming scheme = http.\n" );
|
||||
strcpy( scheme, "http" );
|
||||
t = turl;
|
||||
}
|
||||
else
|
||||
{
|
||||
*colon = '\0';
|
||||
strcpy( scheme, turl );
|
||||
t = colon + strlen( delim );
|
||||
}
|
||||
|
||||
/* Now t points to the beginning of host name */
|
||||
|
||||
if( (slash = strchr( t, '/' )) == NULL )
|
||||
{
|
||||
/* If there isn't even one slash, the path must be empty */
|
||||
debug( stderr, "Warning: no slash character after the host name. Empty path. Adding slash.\n" );
|
||||
strcpy( host, t );
|
||||
slash = "/";
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy( host, t, slash - t);
|
||||
host[slash - t] = '\0';
|
||||
}
|
||||
|
||||
/* Check if the hostname includes ":portnumber" at the end */
|
||||
|
||||
if( (colon = strchr( host, ':' )) == NULL )
|
||||
{
|
||||
*port = 80; /* HTTP standard */
|
||||
}
|
||||
else
|
||||
{
|
||||
*colon = '\0';
|
||||
*port = atoi( colon + 1 );
|
||||
}
|
||||
|
||||
pRet = (char *)calloc( 1, strlen( slash ) + 1 );
|
||||
strcpy( pRet, slash );
|
||||
|
||||
if( turl ) free( turl );
|
||||
|
||||
/* Return the path + arguments */
|
||||
return( pRet );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Function Name: http_request
|
||||
*
|
||||
* Parameters: char *in_URL http URL to request
|
||||
* int in_Method enum for method type
|
||||
* (see http.h)
|
||||
* Description: handle a request to an http server. this is being kept
|
||||
* simple for a purpose, call the function with an http URL
|
||||
* and have return the response inside HTTP_Response.
|
||||
*
|
||||
* Returns: HTTP_Response struct
|
||||
*
|
||||
* NOTE: the memory is allocated for the data transfered,
|
||||
* and it is the responsibility of the *CALLER* to free
|
||||
* the memory. it's very easy to accumulate several
|
||||
* megabytes of data.
|
||||
*
|
||||
*/
|
||||
HTTP_Response http_request( char *in_URL, char *in_ReqAddition, HTTP_Method in_Method, unsigned long in_Flags )
|
||||
{
|
||||
char *pBuf;
|
||||
char *pRequest;
|
||||
char *path;
|
||||
char scheme[50], host[MAXPATHLEN];
|
||||
char *pData, *pBase, *pContent, *pHCode, *pHMsgEnd; // *pScheme, *pHost, *pPath,
|
||||
char szContent[32];
|
||||
char *proxy;
|
||||
int port;
|
||||
struct hostent *nameinfo;
|
||||
int s;
|
||||
struct sockaddr_in addr;
|
||||
struct timeval from_request, from_reply, end;
|
||||
unsigned long total_bytes, bytes, header_size = 0UL, data_size = 0UL, alloc_size = 0UL;
|
||||
fd_set set;
|
||||
int in_header;
|
||||
char *h_end_ptr;
|
||||
#ifdef DEBUG
|
||||
long secs, usecs, bytes_per_sec;
|
||||
#endif
|
||||
HTTP_Response hResponse = { 0,0,0,0,0,"","" };
|
||||
|
||||
#ifdef HF_DO_FILE
|
||||
// CRH It's a file or directory
|
||||
if(in_Method == kHMethodGet && !strncasecmp(in_URL, "file://", 7))
|
||||
return do_file( in_URL );
|
||||
#endif /* HF_DO_FILE */
|
||||
|
||||
memset( hResponse.szHCode, '\0', HCODESIZE );
|
||||
memset( hResponse.szHMsg, '\0', HMSGSIZE );
|
||||
memset( host, '\0', MAXPATHLEN );
|
||||
memset( scheme, '\0', 50 );
|
||||
memset( szContent, '\0', 32 );
|
||||
|
||||
pBuf = (char *)calloc( 1, BUFLEN + 1 );
|
||||
if( pBuf == NULL )
|
||||
return( hResponse );
|
||||
// the GET and POST as of 9/4/2001
|
||||
if( in_Method == kHMethodPost )
|
||||
{
|
||||
// add 1024 bytes for the header
|
||||
pRequest = (char *)calloc( 1, strlen( in_URL ) + 1024 );
|
||||
if( pRequest == NULL )
|
||||
{
|
||||
if( pBuf ) free( pBuf );
|
||||
hResponse.iError = errno;
|
||||
hResponse.pError = strerror( errno );
|
||||
return( hResponse );
|
||||
}
|
||||
}
|
||||
else // allocate enough for the
|
||||
{
|
||||
if( strlen( in_URL ) < GETLEN ) // compare against max request
|
||||
{
|
||||
// allocate the size of the URL
|
||||
// add 1024 bytes for the header
|
||||
pRequest = (char *)calloc( 1, strlen( in_URL ) + 1024 );
|
||||
if( pRequest == NULL )
|
||||
{
|
||||
hResponse.iError = errno;
|
||||
hResponse.pError = strerror( errno );
|
||||
return( hResponse );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
debug( stderr, "*** Request too large, truncating to 8192 max size\n*** will try request anyway...\n" );
|
||||
*(in_URL + 8192) = '\0';
|
||||
pRequest = (char *)calloc( 1, GETLEN + 1024 );
|
||||
if( pRequest == NULL )
|
||||
{
|
||||
hResponse.iError = errno;
|
||||
hResponse.pError = strerror( errno );
|
||||
return( hResponse );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// the http_proxy environment setting is common use for a proxy server,
|
||||
// and the way it was setup per httpget.
|
||||
if( (proxy = getenv( "http_proxy" )) == NULL )
|
||||
{
|
||||
path = parse_url( in_URL, scheme, host, &port );
|
||||
debug( stderr, "URL scheme = %s\n", scheme );
|
||||
debug( stderr, "URL host = %s\n", host );
|
||||
debug( stderr, "URL port = %d\n", port );
|
||||
debug( stderr, "URL path = %s\n", path );
|
||||
// check for http scheme to be safe.
|
||||
if( strcasecmp(scheme, "http") != 0 )
|
||||
{
|
||||
fprintf( stderr, "http_request cannot operate on %s URLs without a proxy\n", scheme );
|
||||
if( path ) free( path );
|
||||
if( pBuf ) free( pBuf );
|
||||
if( pRequest ) free( pRequest );
|
||||
return( hResponse );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
path = parse_url( proxy, scheme, host, &port );
|
||||
if( path ) free( path ); // free it, in_URL will be assigned to it
|
||||
debug( stderr, "Using proxy server at %s:%d\n", host, port );
|
||||
// add jjsa 2/17/2002
|
||||
path = (char *)calloc( 1, strlen( in_URL) + 1 );
|
||||
if( path == NULL )
|
||||
{
|
||||
if( pBuf ) free( pBuf );
|
||||
if( pRequest ) free( pRequest );
|
||||
return( hResponse );
|
||||
}
|
||||
path = in_URL;
|
||||
}
|
||||
/* -- Note : --
|
||||
* After this point, in_URL is no longer used and you should only
|
||||
* use "path". - Jean II
|
||||
*/
|
||||
|
||||
/* Find out the IP address */
|
||||
|
||||
if( (nameinfo = gethostbyname( host )) == NULL )
|
||||
{
|
||||
addr.sin_addr.s_addr = inet_addr( host );
|
||||
if( (int)addr.sin_addr.s_addr == -1 )
|
||||
{
|
||||
hResponse.iError = errno;
|
||||
hResponse.pError = strerror( errno );
|
||||
|
||||
fprintf( stderr, "Unknown host %s\n", host );
|
||||
if( path ) free( path );
|
||||
if( pBuf ) free( pBuf );
|
||||
if( pRequest ) free( pRequest );
|
||||
return( hResponse );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy( (char *)&addr.sin_addr.s_addr, nameinfo->h_addr, nameinfo->h_length );
|
||||
}
|
||||
|
||||
/* Create socket and connect */
|
||||
|
||||
if( (s = socket( PF_INET, SOCK_STREAM, 0 )) == -1 )
|
||||
{
|
||||
hResponse.iError = errno;
|
||||
hResponse.pError = strerror( errno );
|
||||
if( path ) free( path );
|
||||
if( pBuf ) free( pBuf );
|
||||
if( pRequest ) free( pRequest );
|
||||
return( hResponse );
|
||||
}
|
||||
addr.sin_family = AF_INET;
|
||||
addr.sin_port = htons( port );
|
||||
|
||||
if( connect( s, (struct sockaddr *)&addr, sizeof(addr) ) == -1 )
|
||||
{
|
||||
hResponse.iError = errno;
|
||||
hResponse.pError = strerror( errno );
|
||||
if( path ) free( path );
|
||||
if( pBuf ) free( pBuf );
|
||||
if( pRequest ) free( pRequest );
|
||||
return( hResponse );
|
||||
}
|
||||
|
||||
debug( stderr, "Connected to %s:%d\n", host, port );
|
||||
|
||||
// at this point we can construct our actual request. I'm trying to
|
||||
// incorporate more methods than the GET method supported by httpget
|
||||
|
||||
switch( in_Method )
|
||||
{
|
||||
case kHMethodPost:
|
||||
{
|
||||
int pathlen;
|
||||
debug( stderr, "top of post\n" );
|
||||
// a post URL should include some type of
|
||||
// data appended with a '?', so we will
|
||||
// require a '?' be present to continue.
|
||||
pContent = strchr( path, '?' );
|
||||
if( pContent != NULL )
|
||||
{
|
||||
/* Real lenght of the path.
|
||||
* We will split the "path" into two parts.
|
||||
* The arguments (after '?') will go in the body of the
|
||||
* request. It's size will be in Content-Length
|
||||
* The real "path" will go in the first line of the request.
|
||||
* Jean II */
|
||||
pathlen = pContent - path;
|
||||
|
||||
pContent++; // increment to first char of content
|
||||
debug( stderr, "path: %.*s\n", pathlen, path );
|
||||
debug( stderr, "content: %s\n", pContent );
|
||||
}
|
||||
else
|
||||
{
|
||||
hResponse.iError = errno;
|
||||
hResponse.pError = "ERROR, invalid URL for POST request";
|
||||
fprintf( stderr, "ERROR: invalid URL for POST request, no content found\n" );
|
||||
if( pBuf ) free( pBuf );
|
||||
if( pRequest ) free( pRequest );
|
||||
return( hResponse );
|
||||
}
|
||||
|
||||
sprintf( pRequest, "POST %.*s HTTP/1.0\r\nHost: %s\r\n",
|
||||
pathlen, path, host );
|
||||
// the following Content-Type may need to be changed
|
||||
// depending on what type of data you are sending,
|
||||
// and/or if the data is encoded. ajd 8/28/2001
|
||||
/* If the caller provides already a Content-Type header, no need
|
||||
* to do it ourselves - Jean II */
|
||||
if( ! (in_Flags & HFLAG_POST_USER_TYPE) )
|
||||
strcat( pRequest, "Content-Type: application/x-www-form-urlencoded\r\n");
|
||||
sprintf( szContent, "%s%d\r\n", "Content-Length: ", strlen( pContent ) );
|
||||
strcat( pRequest, szContent );
|
||||
if( strlen( in_ReqAddition ) ) // add any additional entities
|
||||
{
|
||||
strcat( pRequest, in_ReqAddition );
|
||||
strcat( pRequest, "\r\n" );
|
||||
}
|
||||
strcat( pRequest, "User-Agent: hget/0.5\r\n" );
|
||||
strcat( pRequest, "Pragma: no-cache\r\n" );
|
||||
strcat( pRequest, "Accept: */*\r\n\r\n" );
|
||||
strcat( pRequest, pContent );
|
||||
break;
|
||||
}
|
||||
case kHMethodHead:
|
||||
{
|
||||
sprintf( pRequest, "HEAD %s HTTP/1.0\r\nHost: %s\r\n", path, host );
|
||||
strcat( pRequest, "User-Agent: hget/0.5\r\n" );
|
||||
if( strlen( in_ReqAddition ) )
|
||||
{
|
||||
strcat( pRequest, in_ReqAddition );
|
||||
strcat( pRequest, "\r\n" );
|
||||
}
|
||||
strcat( pRequest, "Pragma: no-cache\r\n" );
|
||||
strcat( pRequest, "Accept: */*\r\n\r\n" );
|
||||
break;
|
||||
}
|
||||
case kHMethodGet:
|
||||
default: // currently GET is default!
|
||||
{
|
||||
// added in the Host: header entity
|
||||
// as that was preventing some servers
|
||||
// from responding properly.
|
||||
sprintf( pRequest, "GET %s HTTP/1.0\r\nHost: %s\r\n", path, host );
|
||||
strcat( pRequest, "User-Agent: hget/0.5\r\n" );
|
||||
if( strlen( in_ReqAddition ) )
|
||||
{
|
||||
strcat( pRequest, in_ReqAddition );
|
||||
strcat( pRequest, "\r\n" );
|
||||
}
|
||||
strcat( pRequest, "Pragma: no-cache\r\n" );
|
||||
strcat( pRequest, "Accept: */*\r\n\r\n" );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
gettimeofday( &from_request, NULL );
|
||||
|
||||
debug( stderr, "----- HTTP request follows -----\n" );
|
||||
debug( stderr, "%s\n", pRequest );
|
||||
debug( stderr, "----- HTTP request end -----\n" );
|
||||
write( s, pRequest, strlen( pRequest) );
|
||||
|
||||
FD_ZERO( &set );
|
||||
FD_SET( s, &set );
|
||||
|
||||
if( select( FD_SETSIZE, &set, NULL, NULL, NULL ) == -1 )
|
||||
{
|
||||
hResponse.iError = errno;
|
||||
hResponse.pError = strerror( errno );
|
||||
if( path ) free( path );
|
||||
if( pBuf ) free( pBuf );
|
||||
if( pRequest ) free( pRequest );
|
||||
return( hResponse );
|
||||
}
|
||||
|
||||
gettimeofday( &from_reply, NULL );
|
||||
|
||||
in_header = 1;
|
||||
|
||||
total_bytes = 0UL;
|
||||
|
||||
// first we'll allocate a 64k chunk of memory. we don't know the exact size of the
|
||||
// response. Most web pages fit in 64k of memory, and the is practical. for larger
|
||||
// transfer I typically like to allocate more up front. Alter to your preference.
|
||||
// I have tested this transfering a 32mb image using 64k allocations of memory and
|
||||
// 8k of read buffer.
|
||||
// ajd 8/27/2001
|
||||
|
||||
data_size = 0UL;
|
||||
pBase = (char *)malloc( XFERLEN );
|
||||
if( pBase == NULL )
|
||||
{
|
||||
hResponse.iError = errno;
|
||||
hResponse.pError = strerror( errno );
|
||||
|
||||
fprintf(stderr, "ERROR (malloc): recv (errno = %d = %s)\n",
|
||||
errno, strerror(errno));
|
||||
fflush( stderr );
|
||||
if( path ) free( path );
|
||||
if( pBuf ) free( pBuf );
|
||||
if( pRequest ) free( pRequest );
|
||||
return( hResponse );
|
||||
}
|
||||
alloc_size = XFERLEN;
|
||||
pData = pBase; // assign the data ptr as base to start
|
||||
|
||||
// for better or worse I've
|
||||
// decided to allocate 64k chunks
|
||||
// and use 8k for a working buffer.
|
||||
while( (bytes = read( s, pBuf, BUFLEN )) != 0 )
|
||||
{
|
||||
total_bytes += bytes;
|
||||
|
||||
debug( stderr, "data_size: %ld, alloc_size: %ld, total_bytes: %ld\n", data_size, alloc_size, total_bytes );
|
||||
|
||||
if( (data_size + bytes ) > alloc_size )
|
||||
{
|
||||
pBase = realloc( pBase, (alloc_size + XFERLEN) );
|
||||
if( pBase == NULL )
|
||||
{
|
||||
// get outta dodge and free the
|
||||
// the allocated memory...there
|
||||
// could be a chance that we ran
|
||||
// out of resource, and we'll
|
||||
// free it.
|
||||
hResponse.iError = errno;
|
||||
hResponse.pError = strerror( errno );
|
||||
|
||||
fprintf(stderr, "ERROR (realloc): (errno = %d = %s)\n",
|
||||
errno, strerror(errno));
|
||||
fflush( stderr );
|
||||
if( path ) free( path );
|
||||
if( pBase ) free( pBase );
|
||||
if( pBuf ) free( pBuf );
|
||||
if( pRequest ) free( pRequest );
|
||||
return( hResponse );
|
||||
}
|
||||
pData = pBase + data_size;
|
||||
alloc_size += XFERLEN;
|
||||
debug( stderr, "." );
|
||||
}
|
||||
|
||||
memcpy( pData, pBuf, bytes ); // copy data
|
||||
pData += bytes; // increment pointer
|
||||
data_size += bytes; // increment size of data
|
||||
}
|
||||
|
||||
gettimeofday( &end, NULL );
|
||||
close( s );
|
||||
debug( stderr, "\nConnection closed.\n" );
|
||||
|
||||
#ifdef DEBUG
|
||||
if( end.tv_usec < from_reply.tv_usec )
|
||||
{
|
||||
end.tv_sec -= 1;
|
||||
end.tv_usec += 1000000;
|
||||
}
|
||||
|
||||
usecs = end.tv_usec - from_reply.tv_usec;
|
||||
secs = end.tv_sec - from_reply.tv_sec;
|
||||
|
||||
debug( stderr, "Total of %ld bytes read in %ld.%ld seconds\n",
|
||||
total_bytes, secs, usecs );
|
||||
if( secs != 0 )
|
||||
{
|
||||
bytes_per_sec = (int)((total_bytes / (float)secs) + 0.5);
|
||||
debug( stderr, "%ld bytes per second\n", bytes_per_sec );
|
||||
fflush( stderr );
|
||||
}
|
||||
#endif
|
||||
|
||||
h_end_ptr = find_header_end( pBase, total_bytes );
|
||||
|
||||
if( h_end_ptr != NULL )
|
||||
{
|
||||
// we'll get response and response message
|
||||
pHCode = strchr( pBase, ' ' );
|
||||
if( pHCode != NULL )
|
||||
{
|
||||
pHCode++;
|
||||
strncpy( hResponse.szHCode, pHCode, 3 );
|
||||
// now get message
|
||||
pHCode += 4; // increment past code
|
||||
// and search for new line
|
||||
pHMsgEnd = strchr( pHCode, '\n' );
|
||||
if( pHMsgEnd != NULL ) // get the rest of line for the response message
|
||||
{
|
||||
strncpy( hResponse.szHMsg, pHCode,
|
||||
(pHMsgEnd - pHCode) <= (HMSGSIZE - 1) ? (pHMsgEnd - pHCode ) : (HMSGSIZE - 1) );
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
header_size = total_bytes;
|
||||
h_end_ptr = pBase + total_bytes;
|
||||
}
|
||||
|
||||
// now we'll store the size of the header, since we'll need to
|
||||
// subtract that from the total of bytes downloaded to get the
|
||||
// real size of the data.
|
||||
header_size = (unsigned long)(h_end_ptr - pBase);
|
||||
|
||||
/* Found, print up to delimiter to stderr and rest to stdout */
|
||||
debug( stderr, "----- HTTP reply header follows -----\n" );
|
||||
debug2( pBase, h_end_ptr - pBase, 1, stderr );
|
||||
debug( stderr, "----- HTTP reply header end -----\n" );
|
||||
debug( stderr, "Header size: %d\n", header_size );
|
||||
|
||||
if( in_Method == kHMethodHead )
|
||||
{
|
||||
if( path ) free( path );
|
||||
if( pBuf ) free( pBuf );
|
||||
if( pRequest ) free( pRequest );
|
||||
pBase = realloc( pBase, header_size );
|
||||
if( pBase == NULL )
|
||||
return( hResponse );
|
||||
hResponse.lSize = (long)header_size;
|
||||
hResponse.pData = pBase;
|
||||
return( hResponse );
|
||||
}
|
||||
|
||||
/* Does the client wants the header ? - Jean II */
|
||||
if( in_Flags & HFLAG_RETURN_HEADER )
|
||||
{
|
||||
/* Allocate it => client will cleanup */
|
||||
hResponse.pHdr = malloc( header_size + 1 );
|
||||
/* Don't make a big deal if it fails */
|
||||
if( hResponse.pHdr != NULL )
|
||||
{
|
||||
memcpy( hResponse.pHdr, pBase, header_size );
|
||||
/* Be nice to client : NULL terminate it */
|
||||
hResponse.pHdr[header_size] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
/* Delete HTTP headers */
|
||||
memcpy(pBase, h_end_ptr, total_bytes - header_size);
|
||||
|
||||
// realloc the data if we've gotten anything. chances are
|
||||
// we'll have more allocated than we've transfered. ajd 8/27/2001
|
||||
if( (total_bytes - header_size) > 0 )
|
||||
{
|
||||
pBase = realloc( pBase, (total_bytes - header_size) + 1 );
|
||||
if( pBase == NULL )
|
||||
{
|
||||
hResponse.iError = errno;
|
||||
hResponse.pError = strerror( errno );
|
||||
|
||||
fprintf(stderr, "ERROR (realloc): (errno = %d = %s)\n",
|
||||
errno, strerror(errno));
|
||||
fflush( stderr );
|
||||
if( pBase ) free( pBase );
|
||||
if( path ) free( path );
|
||||
if( pBuf ) free( pBuf );
|
||||
if( pRequest ) free( pRequest );
|
||||
return( hResponse );
|
||||
}
|
||||
} // now, if we've gotten this far we must
|
||||
// have our data, so store the size and
|
||||
// the pointer to the data in our response
|
||||
// structure for return.
|
||||
if( in_Method != kHMethodHead ) // HEAD would be set already
|
||||
{
|
||||
hResponse.lSize = (long)(total_bytes - header_size);
|
||||
hResponse.pData = pBase;
|
||||
}
|
||||
if( path ) free( path );
|
||||
if( pBuf ) free( pBuf );
|
||||
if( pRequest ) free( pRequest );
|
||||
return( hResponse );
|
||||
}
|
||||
|
||||
#ifdef HF_DO_FILE
|
||||
/*
|
||||
* Function Name: do_file
|
||||
*
|
||||
* Parameters: char *in_URL file://URL to request
|
||||
*
|
||||
* Description: read and format a file or directory as HTML
|
||||
*
|
||||
* Returns: HTTP_Response struct
|
||||
*
|
||||
* NOTE: the memory is allocated for the data transfered,
|
||||
* and it is the responsibility of the *CALLER* to free
|
||||
* the memory. it's very easy to accumulate several
|
||||
* megabytes of data.
|
||||
*
|
||||
*/
|
||||
HTTP_Response do_file(char *in_URL)
|
||||
{
|
||||
HTTP_Response hResponse = { 0,0,0,0,"","" };
|
||||
struct stat status;
|
||||
char temp[BUFLEN];
|
||||
char *buff;
|
||||
FILE *doit;
|
||||
int path;
|
||||
int count;
|
||||
int size;
|
||||
int i;
|
||||
|
||||
memset( hResponse.szHCode, '\0', HCODESIZE );
|
||||
memset( hResponse.szHMsg, '\0', HMSGSIZE );
|
||||
|
||||
in_URL += 7;
|
||||
|
||||
if(stat(in_URL, &status) || !status.st_mode & S_IRGRP)
|
||||
{
|
||||
hResponse.iError = errno;
|
||||
hResponse.pError = strerror(errno);
|
||||
return(hResponse);
|
||||
}
|
||||
|
||||
|
||||
if(S_ISREG(status.st_mode) || S_ISLNK(status.st_mode))
|
||||
{
|
||||
buff = (char *)malloc(status.st_size);
|
||||
if(buff == NULL)
|
||||
return(hResponse);
|
||||
|
||||
if(-1 == (path = open(in_URL, O_RDONLY)))
|
||||
{
|
||||
if(buff) free(buff);
|
||||
hResponse.iError = errno;
|
||||
hResponse.pError = strerror(errno);
|
||||
return(hResponse);
|
||||
}
|
||||
read(path, buff, status.st_size);
|
||||
close(path);
|
||||
|
||||
buff = realloc(buff, status.st_size);
|
||||
hResponse.lSize = (long)(status.st_size);
|
||||
hResponse.pData = buff;
|
||||
return(hResponse);
|
||||
}
|
||||
|
||||
if(S_ISDIR(status.st_mode))
|
||||
{
|
||||
buff = (char *)malloc(XFERLEN);
|
||||
if(buff == NULL)
|
||||
return(hResponse);
|
||||
size = XFERLEN;
|
||||
|
||||
count = sprintf(buff, "<HTML><HEAD><TITLE>Index of %s</TITLE></HEAD>\n<BODY BGCOLOR=\"#99cc99\"><H4>Index of %s</H4>\n<PRE>\n", in_URL, in_URL);
|
||||
|
||||
strcpy(temp, in_URL);
|
||||
i = strlen(temp) - 2;
|
||||
while(temp[i] != '/' && i > 0)
|
||||
temp[i--] = '\0';
|
||||
|
||||
count += sprintf(&buff[count], "<A HREF=\"file://%s\">Parent Directory</A><P>\n", temp);
|
||||
|
||||
(void) sprintf(temp, "ls -lgF '%s' | tail +2 | sed -e 's/^\\([^ ][^ ]* *[^ ][^ ]* *[^ ][^ ]* *[^ ][^ ]* *[^ ][^ ]* *[^ ][^ ]* *[^ ][^ ]* *[^ ][^ ]*\\) *\\(.*\\)$/\\1 |\\2/' -e '/ -> /!s,|\\([^*]*\\)$,|<A HREF=\"\\1\">\\1</A>,' -e '/ -> /!s,|\\(.*\\)\\([*]\\)$,|<A HREF=\"\\1\">\\1</A>\\2,' -e '/ -> /s,|\\([^@]*\\)\\(@* -> \\),|<A HREF=\"\\1\">\\1</A>\\2,' -e 's/|//'", in_URL);
|
||||
doit = popen(temp, "r");
|
||||
while((i = fread(temp, 1, BUFLEN - 1, doit)) > 0)
|
||||
{
|
||||
if(count + i > size)
|
||||
{
|
||||
buff = realloc(buff, size + XFERLEN);
|
||||
if(buff == NULL)
|
||||
{
|
||||
hResponse.iError = errno;
|
||||
hResponse.pError = strerror( errno );
|
||||
fprintf(stderr, "ERROR (realloc): (errno = %d = %s)\n",
|
||||
errno, strerror(errno));
|
||||
fflush( stderr );
|
||||
return( hResponse );
|
||||
}
|
||||
size += XFERLEN;
|
||||
}
|
||||
memcpy(&buff[count], temp, i); // copy data
|
||||
count += i;
|
||||
}
|
||||
pclose(doit);
|
||||
|
||||
count += sprintf(&buff[count], "</PRE>\n</BODY></HTML>\n");
|
||||
|
||||
buff = realloc(buff, count);
|
||||
hResponse.lSize = count;
|
||||
hResponse.pData = buff;
|
||||
return(hResponse);
|
||||
}
|
||||
return(hResponse);
|
||||
}
|
||||
#endif /* HF_DO_FILE */
|
||||
|
98
http.h
Normal file
98
http.h
Normal file
|
@ -0,0 +1,98 @@
|
|||
/***************************************************************************
|
||||
*
|
||||
* Library: http
|
||||
*
|
||||
* Description: header for libhttp
|
||||
*
|
||||
***************************************************************************
|
||||
*
|
||||
* Copyright (C) 1994 by Sami Tikka <sti@iki.fi>
|
||||
* Copyright (C) 2001 by Alan DuBoff <aland@SoftOrchestra.com>
|
||||
*
|
||||
* The right to use, modify and redistribute this code is allowed
|
||||
* provided the above copyright notice and the below disclaimer appear
|
||||
* on all copies.
|
||||
*
|
||||
* This file is provided AS IS with no warranties of any kind. The author
|
||||
* shall have no liability with respect to the infringement of copyrights,
|
||||
* trade secrets or any patents by this file or any part thereof. In no
|
||||
* event will the author be liable for any lost revenue or profits or
|
||||
* other special, indirect and consequential damages.
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netdb.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <sys/time.h>
|
||||
#include <memory.h>
|
||||
#include <errno.h>
|
||||
|
||||
/* Compile time options.
|
||||
* Allow you to disable library functionality you don't need. - Jean II
|
||||
*/
|
||||
#define HF_FIND_HEADER /* find_header() function */
|
||||
#define HF_DO_FILE /* do_file() function & functionality */
|
||||
|
||||
#define BUFLEN 8192
|
||||
#define GETLEN 8192
|
||||
#define XFERLEN 65536
|
||||
#define HCODESIZE 4
|
||||
#define HMSGSIZE 32
|
||||
|
||||
/* Flags is a mask with the xor of the various options - Jean II */
|
||||
#define HFLAG_NONE 0x0000 /* No flags */
|
||||
#define HFLAG_RETURN_HEADER 0x0001 /* Return HTTP headers */
|
||||
#define HFLAG_POST_USER_TYPE 0x0002 /* Do not add post type */
|
||||
/* Maybe FORCE_PROXY/FORCE_NO_PROXY , and HFLAG_USER_ACCEPT */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char *pData; // pointer to data
|
||||
long lSize; // size of data allocated
|
||||
char *pHdr; // pointer to header, if requested
|
||||
int iError; // error upon failures
|
||||
char *pError; // text description of error
|
||||
char szHCode[HCODESIZE]; // http response code
|
||||
char szHMsg[HMSGSIZE]; // message/description of http code
|
||||
} HTTP_Response, *PHTTP_Response;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
kHMethodOptions = 1,
|
||||
kHMethodGet,
|
||||
kHMethodHead,
|
||||
kHMethodPost,
|
||||
kHMethodPut,
|
||||
kHMethodDelete,
|
||||
kHMethodTrace
|
||||
}HTTP_Method;
|
||||
|
||||
char *find_header_end( char *buf, int bytes );
|
||||
char *parse_url( char *url, char *scheme, char *host, int *port );
|
||||
HTTP_Response http_request( char *in_URL, char *in_ReqAddition, HTTP_Method in_Method, unsigned long in_Flags );
|
||||
#ifdef HF_DO_FILE
|
||||
HTTP_Response do_file(char *in_URL);
|
||||
#endif /* HF_DO_FILE */
|
||||
#ifdef HF_FIND_HEADER
|
||||
char *find_header( char *buf, int bytes, char *type, char *value, int maxv );
|
||||
#endif /* HF_FIND_HEADER */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
251
install-sh
Executable file
251
install-sh
Executable file
|
@ -0,0 +1,251 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# install - install a program, script, or datafile
|
||||
# This comes from X11R5 (mit/util/scripts/install.sh).
|
||||
#
|
||||
# Copyright 1991 by the Massachusetts Institute of Technology
|
||||
#
|
||||
# Permission to use, copy, modify, distribute, and sell this software and its
|
||||
# documentation for any purpose is hereby granted without fee, provided that
|
||||
# the above copyright notice appear in all copies and that both that
|
||||
# copyright notice and this permission notice appear in supporting
|
||||
# documentation, and that the name of M.I.T. not be used in advertising or
|
||||
# publicity pertaining to distribution of the software without specific,
|
||||
# written prior permission. M.I.T. makes no representations about the
|
||||
# suitability of this software for any purpose. It is provided "as is"
|
||||
# without express or implied warranty.
|
||||
#
|
||||
# Calling this script install-sh is preferred over install.sh, to prevent
|
||||
# `make' implicit rules from creating a file called install from it
|
||||
# when there is no Makefile.
|
||||
#
|
||||
# This script is compatible with the BSD install script, but was written
|
||||
# from scratch. It can only install one file at a time, a restriction
|
||||
# shared with many OS's install programs.
|
||||
|
||||
|
||||
# set DOITPROG to echo to test this script
|
||||
|
||||
# Don't use :- since 4.3BSD and earlier shells don't like it.
|
||||
doit="${DOITPROG-}"
|
||||
|
||||
|
||||
# put in absolute paths if you don't have them in your path; or use env. vars.
|
||||
|
||||
mvprog="${MVPROG-mv}"
|
||||
cpprog="${CPPROG-cp}"
|
||||
chmodprog="${CHMODPROG-chmod}"
|
||||
chownprog="${CHOWNPROG-chown}"
|
||||
chgrpprog="${CHGRPPROG-chgrp}"
|
||||
stripprog="${STRIPPROG-strip}"
|
||||
rmprog="${RMPROG-rm}"
|
||||
mkdirprog="${MKDIRPROG-mkdir}"
|
||||
|
||||
transformbasename=""
|
||||
transform_arg=""
|
||||
instcmd="$mvprog"
|
||||
chmodcmd="$chmodprog 0755"
|
||||
chowncmd=""
|
||||
chgrpcmd=""
|
||||
stripcmd=""
|
||||
rmcmd="$rmprog -f"
|
||||
mvcmd="$mvprog"
|
||||
src=""
|
||||
dst=""
|
||||
dir_arg=""
|
||||
|
||||
while [ x"$1" != x ]; do
|
||||
case $1 in
|
||||
-c) instcmd="$cpprog"
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-d) dir_arg=true
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-m) chmodcmd="$chmodprog $2"
|
||||
shift
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-o) chowncmd="$chownprog $2"
|
||||
shift
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-g) chgrpcmd="$chgrpprog $2"
|
||||
shift
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-s) stripcmd="$stripprog"
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-t=*) transformarg=`echo $1 | sed 's/-t=//'`
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-b=*) transformbasename=`echo $1 | sed 's/-b=//'`
|
||||
shift
|
||||
continue;;
|
||||
|
||||
*) if [ x"$src" = x ]
|
||||
then
|
||||
src=$1
|
||||
else
|
||||
# this colon is to work around a 386BSD /bin/sh bug
|
||||
:
|
||||
dst=$1
|
||||
fi
|
||||
shift
|
||||
continue;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ x"$src" = x ]
|
||||
then
|
||||
echo "install: no input file specified"
|
||||
exit 1
|
||||
else
|
||||
true
|
||||
fi
|
||||
|
||||
if [ x"$dir_arg" != x ]; then
|
||||
dst=$src
|
||||
src=""
|
||||
|
||||
if [ -d $dst ]; then
|
||||
instcmd=:
|
||||
chmodcmd=""
|
||||
else
|
||||
instcmd=mkdir
|
||||
fi
|
||||
else
|
||||
|
||||
# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
|
||||
# might cause directories to be created, which would be especially bad
|
||||
# if $src (and thus $dsttmp) contains '*'.
|
||||
|
||||
if [ -f $src -o -d $src ]
|
||||
then
|
||||
true
|
||||
else
|
||||
echo "install: $src does not exist"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ x"$dst" = x ]
|
||||
then
|
||||
echo "install: no destination specified"
|
||||
exit 1
|
||||
else
|
||||
true
|
||||
fi
|
||||
|
||||
# If destination is a directory, append the input filename; if your system
|
||||
# does not like double slashes in filenames, you may need to add some logic
|
||||
|
||||
if [ -d $dst ]
|
||||
then
|
||||
dst="$dst"/`basename $src`
|
||||
else
|
||||
true
|
||||
fi
|
||||
fi
|
||||
|
||||
## this sed command emulates the dirname command
|
||||
dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
|
||||
|
||||
# Make sure that the destination directory exists.
|
||||
# this part is taken from Noah Friedman's mkinstalldirs script
|
||||
|
||||
# Skip lots of stat calls in the usual case.
|
||||
if [ ! -d "$dstdir" ]; then
|
||||
defaultIFS='
|
||||
'
|
||||
IFS="${IFS-${defaultIFS}}"
|
||||
|
||||
oIFS="${IFS}"
|
||||
# Some sh's can't handle IFS=/ for some reason.
|
||||
IFS='%'
|
||||
set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
|
||||
IFS="${oIFS}"
|
||||
|
||||
pathcomp=''
|
||||
|
||||
while [ $# -ne 0 ] ; do
|
||||
pathcomp="${pathcomp}${1}"
|
||||
shift
|
||||
|
||||
if [ ! -d "${pathcomp}" ] ;
|
||||
then
|
||||
$mkdirprog "${pathcomp}"
|
||||
else
|
||||
true
|
||||
fi
|
||||
|
||||
pathcomp="${pathcomp}/"
|
||||
done
|
||||
fi
|
||||
|
||||
if [ x"$dir_arg" != x ]
|
||||
then
|
||||
$doit $instcmd $dst &&
|
||||
|
||||
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
|
||||
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
|
||||
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
|
||||
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
|
||||
else
|
||||
|
||||
# If we're going to rename the final executable, determine the name now.
|
||||
|
||||
if [ x"$transformarg" = x ]
|
||||
then
|
||||
dstfile=`basename $dst`
|
||||
else
|
||||
dstfile=`basename $dst $transformbasename |
|
||||
sed $transformarg`$transformbasename
|
||||
fi
|
||||
|
||||
# don't allow the sed command to completely eliminate the filename
|
||||
|
||||
if [ x"$dstfile" = x ]
|
||||
then
|
||||
dstfile=`basename $dst`
|
||||
else
|
||||
true
|
||||
fi
|
||||
|
||||
# Make a temp file name in the proper directory.
|
||||
|
||||
dsttmp=$dstdir/#inst.$$#
|
||||
|
||||
# Move or copy the file name to the temp name
|
||||
|
||||
$doit $instcmd $src $dsttmp &&
|
||||
|
||||
trap "rm -f ${dsttmp}" 0 &&
|
||||
|
||||
# and set any options; do chmod last to preserve setuid bits
|
||||
|
||||
# If any of these fail, we abort the whole thing. If we want to
|
||||
# ignore errors from any of these, just make sure not to ignore
|
||||
# errors from the above "$doit $instcmd $src $dsttmp" command.
|
||||
|
||||
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
|
||||
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
|
||||
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
|
||||
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
|
||||
|
||||
# Now rename the file to the real destination.
|
||||
|
||||
$doit $rmcmd -f $dstdir/$dstfile &&
|
||||
$doit $mvcmd $dsttmp $dstdir/$dstfile
|
||||
|
||||
fi &&
|
||||
|
||||
|
||||
exit 0
|
2
modconfig.h.in
Normal file
2
modconfig.h.in
Normal file
|
@ -0,0 +1,2 @@
|
|||
/* define this to enable debug code for this module */
|
||||
#undef DEBUG
|
Reference in a new issue