mirror of
https://github.com/reactos/reactos
synced 2025-10-07 17:02:50 +02:00
Compare commits
1 Commits
backups/cl
...
backups/um
Author | SHA1 | Date | |
---|---|---|---|
|
b0f6e9a9fe |
11
COPYING
11
COPYING
@@ -3,7 +3,7 @@
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
||||
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
675 Mass Ave, Cambridge, MA 02139, USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
@@ -280,7 +280,7 @@ POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
Appendix: How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
@@ -292,7 +292,7 @@ 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) <year> <name of author>
|
||||
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
|
||||
@@ -306,15 +306,14 @@ the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision version 69, Copyright (C) 19yy name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
125
CREDITS
125
CREDITS
@@ -1,67 +1,78 @@
|
||||
ReactOS is available thanks to the work of:
|
||||
ReactOS is available thanks to the work of
|
||||
|
||||
Aleksey Bragin <aleksey@studiocerebral.com>
|
||||
Alex Ionescu <ionucu@videotron.ca>
|
||||
Andrew Greenwood <lists@silverblade.co.uk>
|
||||
Andrew Munger <waxdragon@gmail.com>
|
||||
Arindam Das
|
||||
Art Yerkes <ayerkes@speakeasy.net>
|
||||
Boudewijn Dekker <ariadne@xs4all.nl>
|
||||
Brandon Turner (turnerb7@msu.edu)
|
||||
Brian Palmer <brianp@sginet.com>
|
||||
Casper S. Hornstrup <chorns@users.sourceforge.net>
|
||||
Christoph von Wittich (Christoph@ApiViewer.de)
|
||||
David Welch <welch@cwcom.net>
|
||||
Emanuele Aliberti <ea@iol.it>
|
||||
Eric Kohl <ekohl@rz-online.de>
|
||||
Eugene Ingerman <geneing@myrealbox.com>
|
||||
Filip Navara <xnavara@volny.cz>
|
||||
Frederik Leemans
|
||||
Ge van Geldorp <ge@gse.nl>
|
||||
Ged Murphy <gedmurphy@gmail.com>
|
||||
Guido de Jong
|
||||
Gunnar Andre' Dalsnes <hardon@online.no>
|
||||
Hans Kremer
|
||||
Hartmut Birr <hartmut.birr@gmx.de>
|
||||
Hernan Ochoa
|
||||
Herve Poussineau <hpoussin@reactos.com>
|
||||
Iwan Fatahi <i_fatahi@hotmail.com>
|
||||
James B. Tabor <jimtabor@adsl-64-217-116-74.dsl.hstntx.swbell.net>
|
||||
Jason Eager
|
||||
Jason Filby <jasonfilby@yahoo.com>
|
||||
Jason Weiler
|
||||
Jean Michault
|
||||
Jim Noeth
|
||||
Johannes Anderwald <johannes.anderwald@student.tugraz.at>
|
||||
Jonathan Wilson <jonwil@tpgi.com.au>
|
||||
Jurgen van Gael <jurgen.vangael@student.kuleuven.ac.be>
|
||||
KJK::Hyperion <noog@libero.it>
|
||||
Klemens R. Friedl <klemens_friedl@gmx.net>
|
||||
Maarten Bosma <maarten.paul@bosma.de>
|
||||
Magnus Olsen (magnus@greatlord.com)
|
||||
Mark Tempel <mtempel@visi.com>
|
||||
Mark Weaver <mark@npsl.co.uk>
|
||||
Martin Fuchs <martin-fuchs@gmx.net>
|
||||
Marty Dill <mdill@uvic.ca>
|
||||
Matt Pyne
|
||||
Mike Nordell ("tamlin")
|
||||
Nathan Woods <npwoods@mess.org>
|
||||
Paolo Pantaleo <paolopan@freemail.it>
|
||||
Phillip Susi <phreak@iag.net>
|
||||
Rex Jolliff <rex@lvcablemodem.com>
|
||||
Richard Campbell <betam4x@gmail.com>
|
||||
Robert Bergkvist <fragdance@hotmail.com>
|
||||
Hartmut Birr <hartmut.birr@gmx.de>
|
||||
Aleksey Bragin <aleksey@studiocerebral.com>
|
||||
Richard Campbell <eek2121@comcast.net>
|
||||
Gunnar Andre' Dalsnes <hardon@online.no>
|
||||
Arindam Das
|
||||
Boudewijn Dekker <ariadne@xs4all.nl>
|
||||
Robert Dickenson <robd@reactos.org>
|
||||
Royce Mitchell III <royce3@ev1.net>
|
||||
Saveliy Tretiakov <saveliyt@mail.ru>
|
||||
Marty Dill <mdill@uvic.ca>
|
||||
Jason Eager
|
||||
Steven Edwards <steven_ed4153@yahoo.com>
|
||||
Thomas Weidenmueller <w3seek@users.sourceforge.net>
|
||||
Iwan Fatahi <i_fatahi@hotmail.com>
|
||||
Jason Filby <jasonfilby@yahoo.com>
|
||||
Martin Fuchs <martin-fuchs@gmx.net>
|
||||
Jurgen van Gael <jurgen.vangael@student.kuleuven.ac.be>
|
||||
Ge van Geldorp <ge@gse.nl>
|
||||
Andrew Greenwood <lists@silverblade.co.uk>
|
||||
Casper S. Hornstrup <chorns@users.sourceforge.net>
|
||||
KJK::Hyperion <noog@libero.it>
|
||||
Eugene Ingerman <geneing@myrealbox.com>
|
||||
Rex Jolliff <rex@lvcablemodem.com>
|
||||
Guido de Jong
|
||||
Victor Kirhenshtein <sauros@iname.com>
|
||||
Eric Kohl <ekohl@rz-online.de>
|
||||
Hans Kremer
|
||||
Frederik Leemans
|
||||
Jean Michault
|
||||
Royce Mitchell III <royce3@ev1.net>
|
||||
Filip Navara <xnavara@volny.cz>
|
||||
Jim Noeth
|
||||
Mike Nordell ("tamlin")
|
||||
Hernan Ochoa
|
||||
Brian Palmer <brianp@sginet.com>
|
||||
Paolo Pantaleo <paolopan@freemail.it>
|
||||
Matt Pyne
|
||||
Phillip Susi <phreak@iag.net>
|
||||
James B. Tabor <jimtabor@adsl-64-217-116-74.dsl.hstntx.swbell.net>
|
||||
Mark Tempel <mtempel@visi.com>
|
||||
Vizzini <vizzini@plasmic.com>
|
||||
|
||||
Mark Weaver <mark@npsl.co.uk>
|
||||
Thomas Weidenmueller <w3seek@users.sourceforge.net>
|
||||
Jason Weiler
|
||||
David Welch <welch@cwcom.net>
|
||||
Jonathan Wilson <jonwil@tpgi.com.au>
|
||||
Art Yerkes <ayerkes@speakeasy.net>
|
||||
|
||||
Graphic Design from
|
||||
|
||||
Mindflyer <mf@mufunyo.net>
|
||||
Tango Desktop Project (http://tango-project.org)
|
||||
Everaldo (http://everaldo.com)
|
||||
Everaldo (http://everaldo.com) for Explorer icons
|
||||
|
||||
Source and inspiration from
|
||||
|
||||
WINE (http://www.winehq.com)
|
||||
WinFree (http://www.stack.nl/~onno/win32/)
|
||||
Linux (http://www.kernel.org)
|
||||
XFree86 (http://www.xfree86.org/)
|
||||
|
||||
References (Rex's at least)
|
||||
|
||||
Baker, Art. The Windows NT Device Driver Book. Prentice Hall, 1997.
|
||||
Borate, Dabak & Phadke. Undocumented Windows NT. M&T Books, 1999.
|
||||
Brain, Marshall. Win32 System Services. Prentice Hall, 1996.
|
||||
Cant, Chris. Writing Windows WDM Device Drivers. R&D Books, 1999.
|
||||
Canton & Sanchez. IBM Microcomputers: A Programmer's Handbook. McGraw Hill, 1990.
|
||||
Davis & Wallace. Windows Undocumented File Formats. R&D Books, 1997.
|
||||
Mason & Viscarola. Windows NT Device Driver Development. Macmillan, 1999.
|
||||
Mitchell, Stan. Inside the Windows 95 File System. O'Reilly, 1997.
|
||||
Murray, James D. Windows NT Event Logging. O'Reilly, 1998.
|
||||
Nagar, Rajeev. Windows NT File System Internals. O'Reilly, 1997.
|
||||
Osbourne, Sandra. Windows NT Registry: A Settings Reference. New Riders, 1998.
|
||||
Pietrek, Matt. Windows 95 System Programming Secrets. IDG, 1995.
|
||||
Richter, Jeffery. Advanced Windows, 3rd ed. Microsoft, 1997.
|
||||
Simon, Richard J. Windows NT Win32 API Superbible. Waite Group, 1996.
|
||||
Solomon, David A. Inside Windows NT, 2nd Ed. Microsoft, 1998.
|
||||
"The NT Insider." Open Systems Resources, 1999-2000.
|
||||
|
83
INSTALL
83
INSTALL
@@ -2,79 +2,72 @@
|
||||
|
||||
To build the system you need either mingw32 installed on Windows or a mingw32
|
||||
cross compiler running on unix. You may obtain MinGW binaries that build
|
||||
ReactOS from http://www.reactos.org/.
|
||||
ReactOS from http://www.reactos.com.
|
||||
|
||||
|
||||
2. Building ReactOS
|
||||
|
||||
2.1 Building the binaries
|
||||
|
||||
To build ReactOS run 'make' (without the quotes) if you are building on Linux
|
||||
or 'mingw32-make' if you are building on Windows (or ReactOS) from the top
|
||||
directory.
|
||||
|
||||
|
||||
2.2 Building a bootable CD image
|
||||
|
||||
To build a bootable CD image run 'make bootcd' (without the quotes) if you are
|
||||
building on Linux or 'mingw32-make bootcd' if you are building on Windows (or
|
||||
ReactOS) from the top directory. This will create a CD image with a filename,
|
||||
ReactOS.iso, in the top directory.
|
||||
To build from Windows run 'make' (wihout the quotes) from the top directory.
|
||||
To build from unix, edit rules.mak and change the PREFIX variable to the
|
||||
correct value for your cross-compiler. Run 'export HOST=mingw32-linux' to
|
||||
tell the ReactOS build system that it is building ReactOS on a linux machine.
|
||||
Now run 'make'.
|
||||
|
||||
|
||||
3. Installation
|
||||
|
||||
ReactOS can only be installed on a machine that has a FAT16 or FAT32 partition
|
||||
as the active (bootable) partition. The partition on which ReactOS is to be
|
||||
installed (which may or may not be the bootable partition) must also be
|
||||
formatted as FAT16 or FAT32. ReactOS Setup can format the partitions if
|
||||
needed.
|
||||
The system can only be installed on the first partition on the first harddisk.
|
||||
The partition must be formatted as FAT16 or FAT32. The system can only be
|
||||
started from DOS and not from a Windows DOS-prompt.
|
||||
|
||||
ReactOS can be installed from the source distribution or from the bootable CD
|
||||
ReactOS can be installed from the source distribution or from the binary
|
||||
distribution. The two ways to install ReactOS are explained below.
|
||||
|
||||
|
||||
3.1 Installation from sources
|
||||
|
||||
If you don't have an existing ReactOS installation you want to upgrade, then
|
||||
build a bootable CD as described above. Burn the CD image, boot from it, and
|
||||
follow the instructions to install ReactOS.
|
||||
To install ReactOS after building it, type 'make install'. This will create
|
||||
the directory 'reactos' in the top directory. Copy this directory to the root
|
||||
of your first partition on your first harddisk. This is usually c:\ on a
|
||||
Windows machine.
|
||||
|
||||
If you have an existing ReactOS installation you want to upgrade, then to
|
||||
install ReactOS after building it, type 'make install' or
|
||||
'mingw32-make install'. This will create the directory 'reactos' in the top
|
||||
directory. Copy the contents of this directory over the existing installation.
|
||||
If you don't want to copy the files manually every time you run a 'make install',
|
||||
you can specify the directory where the files are to be copied to during
|
||||
installation.
|
||||
|
||||
If you don't want to copy the files manually every time you run a
|
||||
'make install' or 'mingw32-make install', then you can specify the directory
|
||||
where the files are to be copied to during installation.
|
||||
In rules.mak find the variable INSTALL_DIR and change the assigned value to the
|
||||
name of the directory where the files are to be copied to. If you are using
|
||||
Windows this could be:
|
||||
|
||||
Set the ROS_INSTALL environment variable. If you are on Windows this could be
|
||||
done by:
|
||||
INSTALL_DIR = c:\reactos
|
||||
|
||||
set ROS_INSTALL=c:\reactos
|
||||
If you are on linux this could be:
|
||||
|
||||
If you are on Linux this could be done by:
|
||||
INSTALL_DIR = /mnt/windows/reactos
|
||||
|
||||
export ROS_INSTALL=/mnt/windows/reactos
|
||||
|
||||
Now run 'make install' or 'mingw32-make install' to install the files to the
|
||||
new location.
|
||||
Save the changes to rules.mak and run 'make install' to install the files to
|
||||
the new location. If you don't want to change rules.mak, you can specify the
|
||||
installtion directory when invoking make. Run
|
||||
'make INSTALL_DIR=c:\reactos install' to install to c:\reactos.
|
||||
|
||||
|
||||
3.2 Installation from bootable CD distribution
|
||||
3.2 Installation from binany distribution
|
||||
|
||||
To install ReactOS from the bootable CD distribution, extract the archive
|
||||
contents. Then burn the CD image, boot from it, and follow instructions.
|
||||
To install ReactOS from the binary distribution, extract the archive contents
|
||||
to c:\reactos. Remember to extract the files with full paths.
|
||||
|
||||
|
||||
4. Booting ReactOS
|
||||
|
||||
Startup in DOS mode. 'cd' to c:\reactos and type 'boot' and press <enter>.
|
||||
A simple shell is started where you can use simple commands like 'cd' and 'dir'.
|
||||
|
||||
|
||||
5. Help
|
||||
|
||||
If you run into problems or have suggestions for making ReactOS better, please
|
||||
visit the address below. Mailing lists are available for a variety of topics,
|
||||
bugs should be submitted to bugzilla and general chat takes place in the forums,
|
||||
or #reactos on freenode
|
||||
surf to the address below and subscribe to one or more of the mailing lists.
|
||||
|
||||
http://www.reactos.org/
|
||||
http://www.reactos.com/index.php?tab=discussion§ion=lists
|
||||
|
||||
ReactOS Development Team
|
||||
|
5
Jamfile
Normal file
5
Jamfile
Normal file
@@ -0,0 +1,5 @@
|
||||
# Main jamfile for ReactOS
|
||||
|
||||
SubDir ROS_TOP ;
|
||||
|
||||
SubInclude ROS_TOP Lib ;
|
54
Jamrules
Normal file
54
Jamrules
Normal file
@@ -0,0 +1,54 @@
|
||||
# customization for ReactOS goes here
|
||||
|
||||
# The SharedLibrary and SharedLibraryFromObjects rules were
|
||||
# borrowed from here:
|
||||
# http://www.differentpla.net/~roger/devel/jam/tutorial/shared_lib/index.html
|
||||
|
||||
SUFSHR = .dll ;
|
||||
RM = rm ; # rm comes with MinGW, and the default del doesn't work in some cases
|
||||
|
||||
rule SharedLibrary
|
||||
{
|
||||
SharedLibraryFromObjects $(<) : $(>:S=$(SUFOBJ)) ;
|
||||
Objects $(>) ;
|
||||
}
|
||||
|
||||
rule SharedLibraryFromObjects
|
||||
{
|
||||
local _s _t ;
|
||||
|
||||
# Add grist to file names
|
||||
# Add suffix to dll
|
||||
|
||||
_s = [ FGristFiles $(>) ] ;
|
||||
_t = [ FAppendSuffix $(<) : $(SUFSHR) ] ;
|
||||
|
||||
if $(_t) != $(<)
|
||||
{
|
||||
DEPENDS $(<) : $(_t) ;
|
||||
NOTFILE $(<) ;
|
||||
}
|
||||
|
||||
# make compiled sources a dependency of target
|
||||
|
||||
DEPENDS exe : $(_t) ;
|
||||
DEPENDS $(_t) : $(_s) ;
|
||||
MakeLocate $(_t) : $(LOCATE_TARGET) ;
|
||||
|
||||
Clean clean : $(_t) ;
|
||||
|
||||
Link $(_t) : $(_s) ;
|
||||
}
|
||||
|
||||
# nasm needs to know the output file first, or it doesn't
|
||||
# recognize -I :(
|
||||
actions As
|
||||
{
|
||||
$(AS) -o $(<) $(ASFLAGS) -I$(HDRS) $(>)
|
||||
}
|
||||
|
||||
AS = nasm ;
|
||||
|
||||
# why isn't DEFINES working? :(
|
||||
#DEFINES += _M_IX86 ;
|
||||
CCFLAGS += -D_M_IX86 ;
|
4
LGPL.txt
4
LGPL.txt
@@ -2,7 +2,7 @@
|
||||
Version 2.1, February 1999
|
||||
|
||||
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
|
||||
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
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.
|
||||
|
||||
@@ -485,7 +485,7 @@ convey the exclusion of warranty; and each file should have at least the
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
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.
|
||||
|
||||
|
8
README
8
README
@@ -1,6 +1,6 @@
|
||||
========================
|
||||
ReactOS Version 0.3.x
|
||||
Updated Aug 21rd, 2005
|
||||
ReactOS Version 0.2.x
|
||||
Updated June 23rd, 2004
|
||||
========================
|
||||
|
||||
1. What is ReactOS?
|
||||
@@ -9,11 +9,11 @@ Updated Aug 21rd, 2005
|
||||
that is compatible with Windows NT applications and drivers.
|
||||
|
||||
The ReactOS project, although currently focused on Windows NT 4.0
|
||||
compatibility, is always keeping an eye toward compatibility with
|
||||
compatibility, is always keeping an eye towards compatibility with
|
||||
future Windows NT releases, that is, Windows 2000 (NT 5.0) and
|
||||
Windows XP (NT 5.1).
|
||||
|
||||
More information is available at http://www.reactos.org/.
|
||||
More information is available at http://www.reactos.com.
|
||||
|
||||
2. Building ReactOS
|
||||
|
||||
|
@@ -1,94 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<!DOCTYPE project SYSTEM "tools/rbuild/project.dtd">
|
||||
<project name="ReactOS" makefile="makefile.ppc" xmlns:xi="http://www.w3.org/2001/XInclude">
|
||||
<xi:include href="config-ppc.rbuild">
|
||||
<xi:fallback>
|
||||
<xi:include href="config-ppc.template.rbuild" />
|
||||
</xi:fallback>
|
||||
</xi:include>
|
||||
|
||||
<xi:include href="baseaddress.rbuild" />
|
||||
|
||||
<property name="BOOTPROG_PREPARE" value="ppc-le2be" />
|
||||
<property name="BOOTPROG_FLATFORMAT" value="-O elf32-powerpc -B powerpc:common" />
|
||||
<property name="BOOTPROG_LINKFORMAT" value="-melf32ppc --no-omagic -Ttext 0xe00000 -Tdata 0xe10000" />
|
||||
<property name="BOOTPROG_COPYFORMAT" value="--only-section=.text --only-section=.data --only-section=.bss -O aixcoff-rs6000" />
|
||||
|
||||
<define name="_M_PPC" />
|
||||
<define name="_PPC_" />
|
||||
<define name="__PowerPC__" />
|
||||
<define name="_REACTOS_" />
|
||||
<define name="__MINGW_IMPORT" empty="true" />
|
||||
<define name="stdcall" empty="true" />
|
||||
<define name="__stdcall__" empty="true" />
|
||||
<define name="fastcall" empty="true" />
|
||||
<define name="cdecl" empty="true" />
|
||||
<define name="__cdecl__" empty="true" />
|
||||
<define name="dllimport" empty="true" />
|
||||
<compilerflag>-v</compilerflag>
|
||||
<if property="MP" value="1">
|
||||
<define name="CONFIG_SMP" value="1" />
|
||||
</if>
|
||||
<if property="DBG" value="1">
|
||||
<define name="DBG" value="1" />
|
||||
<property name="DBG_OR_KDBG" value="true" />
|
||||
</if>
|
||||
<if property="DBG" value="0">
|
||||
<compilerflag>-Os</compilerflag>
|
||||
<compilerflag>-Wno-strict-aliasing</compilerflag>
|
||||
</if>
|
||||
<if property="KDBG" value="1">
|
||||
<define name="KDBG" value="1" />
|
||||
<property name="DBG_OR_KDBG" value="true" />
|
||||
</if>
|
||||
<compilerflag>-Wpointer-arith</compilerflag>
|
||||
|
||||
<include>.</include>
|
||||
<include>include</include>
|
||||
<include>include/reactos</include>
|
||||
<include>include/libs</include>
|
||||
<include>include/drivers</include>
|
||||
<include>include/subsys</include>
|
||||
<include>include/ndk</include>
|
||||
<include>include</include>
|
||||
<include>include/crt</include>
|
||||
<include>include/ddk</include>
|
||||
|
||||
<directory name="base">
|
||||
<xi:include href="base/base.rbuild" />
|
||||
</directory>
|
||||
<directory name="boot">
|
||||
<xi:include href="boot/boot.rbuild" />
|
||||
</directory>
|
||||
<directory name="dll">
|
||||
<xi:include href="dll/dll.rbuild" />
|
||||
</directory>
|
||||
<directory name="drivers">
|
||||
<xi:include href="drivers/drivers.rbuild" />
|
||||
</directory>
|
||||
<directory name="hal">
|
||||
<xi:include href="hal/hal.rbuild" />
|
||||
</directory>
|
||||
<directory name="include">
|
||||
<xi:include href="include/directory.rbuild" />
|
||||
</directory>
|
||||
<directory name="lib">
|
||||
<xi:include href="lib/lib.rbuild" />
|
||||
</directory>
|
||||
<directory name="media">
|
||||
<xi:include href="media/media.rbuild" />
|
||||
</directory>
|
||||
<directory name="modules">
|
||||
<xi:include href="modules/directory.rbuild" />
|
||||
</directory>
|
||||
<directory name="ntoskrnl">
|
||||
<xi:include href="ntoskrnl/ntoskrnl.rbuild" />
|
||||
</directory>
|
||||
<directory name="regtests">
|
||||
<xi:include href="regtests/directory.rbuild" />
|
||||
</directory>
|
||||
<directory name="subsystems">
|
||||
<xi:include href="subsystems/subsystems.rbuild" />
|
||||
</directory>
|
||||
|
||||
</project>
|
@@ -1,84 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<!DOCTYPE project SYSTEM "tools/rbuild/project.dtd">
|
||||
<project name="ReactOS" makefile="makefile.auto" xmlns:xi="http://www.w3.org/2001/XInclude">
|
||||
<xi:include href="config.rbuild">
|
||||
<xi:fallback>
|
||||
<xi:include href="config.template.rbuild" />
|
||||
</xi:fallback>
|
||||
</xi:include>
|
||||
|
||||
<xi:include href="baseaddress.rbuild" />
|
||||
|
||||
<define name="_M_IX86" />
|
||||
<define name="_X86_" />
|
||||
<define name="__i386__" />
|
||||
<define name="_REACTOS_" />
|
||||
<if property="MP" value="1">
|
||||
<define name="CONFIG_SMP" value="1" />
|
||||
</if>
|
||||
<if property="DBG" value="1">
|
||||
<define name="DBG" value="1" />
|
||||
<property name="DBG_OR_KDBG" value="true" />
|
||||
</if>
|
||||
<if property="KDBG" value="1">
|
||||
<define name="KDBG" value="1" />
|
||||
<property name="DBG_OR_KDBG" value="true" />
|
||||
</if>
|
||||
|
||||
<if property="GDB" value="0">
|
||||
<compilerflag>-Os</compilerflag>
|
||||
<compilerflag>-Wno-strict-aliasing</compilerflag>
|
||||
<compilerflag>-ftracer</compilerflag>
|
||||
<compilerflag>-momit-leaf-frame-pointer</compilerflag>
|
||||
<compilerflag>-mpreferred-stack-boundary=2</compilerflag>
|
||||
</if>
|
||||
<compilerflag>-Wpointer-arith</compilerflag>
|
||||
|
||||
<include>.</include>
|
||||
<include>include</include>
|
||||
<include>include/psdk</include>
|
||||
<include>include/crt</include>
|
||||
<include>include/ddk</include>
|
||||
<include>include/GL</include>
|
||||
<include>include/ndk</include>
|
||||
<include>include/reactos</include>
|
||||
<include>include/reactos/libs</include>
|
||||
|
||||
<directory name="base">
|
||||
<xi:include href="base/base.rbuild" />
|
||||
</directory>
|
||||
<directory name="boot">
|
||||
<xi:include href="boot/boot.rbuild" />
|
||||
</directory>
|
||||
<directory name="dll">
|
||||
<xi:include href="dll/dll.rbuild" />
|
||||
</directory>
|
||||
<directory name="drivers">
|
||||
<xi:include href="drivers/drivers.rbuild" />
|
||||
</directory>
|
||||
<directory name="hal">
|
||||
<xi:include href="hal/hal.rbuild" />
|
||||
</directory>
|
||||
<directory name="include">
|
||||
<xi:include href="include/directory.rbuild" />
|
||||
</directory>
|
||||
<directory name="lib">
|
||||
<xi:include href="lib/lib.rbuild" />
|
||||
</directory>
|
||||
<directory name="media">
|
||||
<xi:include href="media/media.rbuild" />
|
||||
</directory>
|
||||
<directory name="modules">
|
||||
<xi:include href="modules/directory.rbuild" />
|
||||
</directory>
|
||||
<directory name="ntoskrnl">
|
||||
<xi:include href="ntoskrnl/ntoskrnl.rbuild" />
|
||||
</directory>
|
||||
<directory name="regtests">
|
||||
<xi:include href="regtests/directory.rbuild" />
|
||||
</directory>
|
||||
<directory name="subsystems">
|
||||
<xi:include href="subsystems/subsystems.rbuild" />
|
||||
</directory>
|
||||
|
||||
</project>
|
@@ -11,11 +11,15 @@ iphlpapi.dll reactos/lib/iphlpapi
|
||||
kernel32.dll reactos/lib/kernel32
|
||||
lz32.dll reactos/lib/lzexpand
|
||||
msvcrt.dll reactos/lib/msvcrt
|
||||
ole32.dll reactos/lib/ole32
|
||||
oleaut32.dll reactos/lib/oleaut32
|
||||
rpcrt4.dll reactos/lib/rpcrt4
|
||||
secur32.dll reactos/lib/secur32
|
||||
shell32.dll reactos/lib/shell32
|
||||
snmpapi.dll reactos/lib/snmpapi
|
||||
user32.dll reactos/lib/user32
|
||||
version.dll reactos/lib/version
|
||||
winmm.dll reactos/lib/winmm
|
||||
winspool.dll reactos/lib/winspool
|
||||
ws2_32.dll reactos/lib/ws2_32
|
||||
wsock32.dll reactos/lib/wsock32
|
||||
|
207
apps/Doxyfile
Normal file
207
apps/Doxyfile
Normal file
@@ -0,0 +1,207 @@
|
||||
# Doxyfile 1.3.5
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Project related configuration options
|
||||
#---------------------------------------------------------------------------
|
||||
PROJECT_NAME = "ReactOS Apps & Tools"
|
||||
PROJECT_NUMBER =
|
||||
OUTPUT_DIRECTORY = doxy-doc
|
||||
OUTPUT_LANGUAGE = English
|
||||
USE_WINDOWS_ENCODING = YES
|
||||
BRIEF_MEMBER_DESC = YES
|
||||
REPEAT_BRIEF = YES
|
||||
ALWAYS_DETAILED_SEC = NO
|
||||
INLINE_INHERITED_MEMB = NO
|
||||
FULL_PATH_NAMES = YES
|
||||
STRIP_FROM_PATH = ..
|
||||
SHORT_NAMES = NO
|
||||
JAVADOC_AUTOBRIEF = YES
|
||||
MULTILINE_CPP_IS_BRIEF = NO
|
||||
DETAILS_AT_TOP = NO
|
||||
INHERIT_DOCS = NO
|
||||
DISTRIBUTE_GROUP_DOC = NO
|
||||
TAB_SIZE = 8
|
||||
ALIASES =
|
||||
OPTIMIZE_OUTPUT_FOR_C = YES
|
||||
OPTIMIZE_OUTPUT_JAVA = NO
|
||||
SUBGROUPING = YES
|
||||
#---------------------------------------------------------------------------
|
||||
# Build related configuration options
|
||||
#---------------------------------------------------------------------------
|
||||
EXTRACT_ALL = YES
|
||||
EXTRACT_PRIVATE = NO
|
||||
EXTRACT_STATIC = NO
|
||||
EXTRACT_LOCAL_CLASSES = NO
|
||||
HIDE_UNDOC_MEMBERS = NO
|
||||
HIDE_UNDOC_CLASSES = NO
|
||||
HIDE_FRIEND_COMPOUNDS = NO
|
||||
HIDE_IN_BODY_DOCS = NO
|
||||
INTERNAL_DOCS = YES
|
||||
CASE_SENSE_NAMES = YES
|
||||
HIDE_SCOPE_NAMES = NO
|
||||
SHOW_INCLUDE_FILES = YES
|
||||
INLINE_INFO = YES
|
||||
SORT_MEMBER_DOCS = YES
|
||||
GENERATE_TODOLIST = YES
|
||||
GENERATE_TESTLIST = YES
|
||||
GENERATE_BUGLIST = YES
|
||||
GENERATE_DEPRECATEDLIST= YES
|
||||
ENABLED_SECTIONS =
|
||||
MAX_INITIALIZER_LINES = 30
|
||||
SHOW_USED_FILES = YES
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to warning and progress messages
|
||||
#---------------------------------------------------------------------------
|
||||
QUIET = NO
|
||||
WARNINGS = NO
|
||||
WARN_IF_UNDOCUMENTED = NO
|
||||
WARN_IF_DOC_ERROR = YES
|
||||
WARN_FORMAT = "$file:$line: $text"
|
||||
WARN_LOGFILE =
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the input files
|
||||
#---------------------------------------------------------------------------
|
||||
INPUT = . \
|
||||
../tools
|
||||
FILE_PATTERNS = *.c \
|
||||
*.h
|
||||
RECURSIVE = YES
|
||||
EXCLUDE =
|
||||
EXCLUDE_SYMLINKS = NO
|
||||
EXCLUDE_PATTERNS =
|
||||
EXAMPLE_PATH =
|
||||
EXAMPLE_PATTERNS =
|
||||
EXAMPLE_RECURSIVE = YES
|
||||
IMAGE_PATH =
|
||||
INPUT_FILTER =
|
||||
FILTER_SOURCE_FILES = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to source browsing
|
||||
#---------------------------------------------------------------------------
|
||||
SOURCE_BROWSER = YES
|
||||
INLINE_SOURCES = YES
|
||||
STRIP_CODE_COMMENTS = YES
|
||||
REFERENCED_BY_RELATION = YES
|
||||
REFERENCES_RELATION = YES
|
||||
VERBATIM_HEADERS = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the alphabetical class index
|
||||
#---------------------------------------------------------------------------
|
||||
ALPHABETICAL_INDEX = YES
|
||||
COLS_IN_ALPHA_INDEX = 5
|
||||
IGNORE_PREFIX =
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the HTML output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_HTML = YES
|
||||
HTML_OUTPUT = html
|
||||
HTML_FILE_EXTENSION = .html
|
||||
HTML_HEADER =
|
||||
HTML_FOOTER =
|
||||
HTML_STYLESHEET =
|
||||
HTML_ALIGN_MEMBERS = YES
|
||||
GENERATE_HTMLHELP = NO
|
||||
CHM_FILE =
|
||||
HHC_LOCATION =
|
||||
GENERATE_CHI = NO
|
||||
BINARY_TOC = NO
|
||||
TOC_EXPAND = NO
|
||||
DISABLE_INDEX = NO
|
||||
ENUM_VALUES_PER_LINE = 4
|
||||
GENERATE_TREEVIEW = YES
|
||||
TREEVIEW_WIDTH = 200
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the LaTeX output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_LATEX = NO
|
||||
LATEX_OUTPUT = latex
|
||||
LATEX_CMD_NAME = latex
|
||||
MAKEINDEX_CMD_NAME = makeindex
|
||||
COMPACT_LATEX = NO
|
||||
PAPER_TYPE = a4wide
|
||||
EXTRA_PACKAGES =
|
||||
LATEX_HEADER =
|
||||
PDF_HYPERLINKS = NO
|
||||
USE_PDFLATEX = NO
|
||||
LATEX_BATCHMODE = NO
|
||||
LATEX_HIDE_INDICES = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the RTF output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_RTF = NO
|
||||
RTF_OUTPUT = rtf
|
||||
COMPACT_RTF = YES
|
||||
RTF_HYPERLINKS = YES
|
||||
RTF_STYLESHEET_FILE =
|
||||
RTF_EXTENSIONS_FILE =
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the man page output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_MAN = NO
|
||||
MAN_OUTPUT = man
|
||||
MAN_EXTENSION = .3
|
||||
MAN_LINKS = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the XML output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_XML = NO
|
||||
XML_OUTPUT = xml
|
||||
XML_SCHEMA =
|
||||
XML_DTD =
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options for the AutoGen Definitions output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_AUTOGEN_DEF = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the Perl module output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_PERLMOD = NO
|
||||
PERLMOD_LATEX = NO
|
||||
PERLMOD_PRETTY = YES
|
||||
PERLMOD_MAKEVAR_PREFIX =
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the preprocessor
|
||||
#---------------------------------------------------------------------------
|
||||
ENABLE_PREPROCESSING = NO
|
||||
MACRO_EXPANSION = NO
|
||||
EXPAND_ONLY_PREDEF = NO
|
||||
SEARCH_INCLUDES = YES
|
||||
INCLUDE_PATH = ../include
|
||||
INCLUDE_FILE_PATTERNS = *.h
|
||||
PREDEFINED =
|
||||
EXPAND_AS_DEFINED =
|
||||
SKIP_FUNCTION_MACROS = YES
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration::addtions related to external references
|
||||
#---------------------------------------------------------------------------
|
||||
TAGFILES =
|
||||
GENERATE_TAGFILE =
|
||||
ALLEXTERNALS = NO
|
||||
EXTERNAL_GROUPS = YES
|
||||
PERL_PATH = /usr/bin/perl
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the dot tool
|
||||
#---------------------------------------------------------------------------
|
||||
CLASS_DIAGRAMS = YES
|
||||
HIDE_UNDOC_RELATIONS = NO
|
||||
HAVE_DOT = YES
|
||||
CLASS_GRAPH = YES
|
||||
COLLABORATION_GRAPH = YES
|
||||
UML_LOOK = NO
|
||||
TEMPLATE_RELATIONS = NO
|
||||
INCLUDE_GRAPH = YES
|
||||
INCLUDED_BY_GRAPH = YES
|
||||
CALL_GRAPH = YES
|
||||
GRAPHICAL_HIERARCHY = YES
|
||||
DOT_IMAGE_FORMAT = png
|
||||
DOT_PATH =
|
||||
DOTFILE_DIRS =
|
||||
MAX_DOT_GRAPH_WIDTH = 1024
|
||||
MAX_DOT_GRAPH_HEIGHT = 1024
|
||||
MAX_DOT_GRAPH_DEPTH = 0
|
||||
GENERATE_LEGEND = YES
|
||||
DOT_CLEANUP = YES
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration::addtions related to the search engine
|
||||
#---------------------------------------------------------------------------
|
||||
SEARCHENGINE = YES
|
13
apps/Makefile
Normal file
13
apps/Makefile
Normal file
@@ -0,0 +1,13 @@
|
||||
# $Id$
|
||||
#
|
||||
# ReactOS apps and tools makefile to generate Doxygen documentation
|
||||
#
|
||||
|
||||
|
||||
docu:
|
||||
doxygen Doxyfile
|
||||
|
||||
.PHONY: docu
|
||||
|
||||
|
||||
# EOF
|
162
apps/testsets/Makefile
Normal file
162
apps/testsets/Makefile
Normal file
@@ -0,0 +1,162 @@
|
||||
#
|
||||
# ReactOS system testsets makefile
|
||||
#
|
||||
|
||||
PATH_TO_TOP = ../..
|
||||
|
||||
include $(PATH_TO_TOP)/rules.mak
|
||||
|
||||
|
||||
# Testset applications
|
||||
TEST_SETS = loadlib
|
||||
|
||||
TEST_KERNEL32 =
|
||||
|
||||
TEST_MSVCRT =
|
||||
|
||||
TEST_COM =
|
||||
|
||||
TEST_SEH =
|
||||
|
||||
TEST_REGRESSIONS =
|
||||
|
||||
all: $(TEST_SETS) $(TEST_KERNEL32) $(TEST_MSVCRT) $(TEST_COM) $(TEST_SEH) $(TEST_REGRESSIONS)
|
||||
|
||||
depends:
|
||||
|
||||
implib: $(TEST_SETS:%=%_implib) \
|
||||
$(TEST_KERNEL32:%=%_implib) \
|
||||
$(TEST_MSVCRT:%=%_implib) \
|
||||
$(TEST_COM:%=%_implib) \
|
||||
$(TEST_SEH:%=%_implib) \
|
||||
$(TEST_REGRESSIONS:%=%_implib)
|
||||
|
||||
clean: $(TEST_SETS:%=%_clean) \
|
||||
$(TEST_KERNEL32:%=%_clean) \
|
||||
$(TEST_MSVCRT:%=%_clean) \
|
||||
$(TEST_COM:%=%_clean) \
|
||||
$(TEST_SEH:%=%_clean) \
|
||||
$(TEST_REGRESSIONS:%=%_clean)
|
||||
|
||||
install: $(TEST_SETS:%=%_install) \
|
||||
$(TEST_KERNEL32:%=%_install) \
|
||||
$(TEST_MSVCRT:%=%_install) \
|
||||
$(TEST_COM:%=%_install) \
|
||||
$(TEST_SEH:%=%_install) \
|
||||
$(TEST_REGRESSIONS:%=%_install)
|
||||
|
||||
.PHONY: all depends implib clean install
|
||||
|
||||
|
||||
#
|
||||
# Testset Applications
|
||||
#
|
||||
$(TEST_SETS): %:
|
||||
$(MAKE) -C $*
|
||||
|
||||
$(TEST_SETS:%=%_implib): %_implib:
|
||||
$(MAKE) -C $* implib
|
||||
|
||||
$(TEST_SETS:%=%_clean): %_clean:
|
||||
$(MAKE) -C $* clean
|
||||
|
||||
$(TEST_SETS:%=%_install): %_install:
|
||||
$(MAKE) -C $* install
|
||||
|
||||
.PHONY: $(TEST_SETS) $(TEST_SETS:%=%_implib) $(TEST_SETS:%=%_clean) $(TEST_SETS:%=%_install)
|
||||
|
||||
|
||||
#
|
||||
# Kernel32 Test Applications
|
||||
#
|
||||
$(TEST_KERNEL32): %:
|
||||
$(MAKE) -C kernel32/$*
|
||||
|
||||
$(TEST_KERNEL32:%=%_implib): %_implib:
|
||||
$(MAKE) -C kernel32/$* implib
|
||||
|
||||
$(TEST_KERNEL32:%=%_clean): %_clean:
|
||||
$(MAKE) -C kernel32/$* clean
|
||||
|
||||
$(TEST_KERNEL32:%=%_install): %_install:
|
||||
$(MAKE) -C kernel32/$* install
|
||||
|
||||
.PHONY: $(TEST_KERNEL32) $(TEST_KERNEL32:%=%_implib) $(TEST_KERNEL32:%=%_clean) $(TEST_KERNEL32:%=%_install)
|
||||
|
||||
|
||||
#
|
||||
# msvcrt Test Applications
|
||||
#
|
||||
$(TEST_MSVCRT): %:
|
||||
$(MAKE) -C msvcrt/$*
|
||||
|
||||
$(TEST_MSVCRT:%=%_implib): %_implib:
|
||||
$(MAKE) -C msvcrt/$* implib
|
||||
|
||||
$(TEST_MSVCRT:%=%_clean): %_clean:
|
||||
$(MAKE) -C msvcrt/$* clean
|
||||
|
||||
$(TEST_MSVCRT:%=%_install): %_install:
|
||||
$(MAKE) -C msvcrt/$* install
|
||||
|
||||
.PHONY: $(TEST_MSVCRT) $(TEST_MSVCRT:%=%_implib) $(TEST_MSVCRT:%=%_clean) $(TEST_MSVCRT:%=%_install)
|
||||
|
||||
|
||||
#
|
||||
# COM Test Applications
|
||||
#
|
||||
$(TEST_COM): %:
|
||||
$(MAKE) -C com/$*
|
||||
|
||||
$(TEST_COM:%=%_implib): %_implib:
|
||||
$(MAKE) -C com/$* implib
|
||||
|
||||
$(TEST_COM:%=%_clean): %_clean:
|
||||
$(MAKE) -C com/$* clean
|
||||
|
||||
$(TEST_COM:%=%_install): %_install:
|
||||
$(MAKE) -C com/$* install
|
||||
|
||||
.PHONY: $(TEST_COM) $(TEST_COM:%=%_implib) $(TEST_COM:%=%_clean) $(TEST_COM:%=%_install)
|
||||
|
||||
|
||||
#
|
||||
# SEH Test Applications
|
||||
#
|
||||
$(TEST_SEH): %:
|
||||
$(MAKE) -C seh/$*
|
||||
|
||||
$(TEST_SEH:%=%_implib): %_implib:
|
||||
$(MAKE) -C seh/$* implib
|
||||
|
||||
$(TEST_SEH:%=%_clean): %_clean:
|
||||
$(MAKE) -C seh/$* clean
|
||||
|
||||
$(TEST_SEH:%=%_install): %_install:
|
||||
$(MAKE) -C seh/$* install
|
||||
|
||||
.PHONY: $(TEST_SEH) $(TEST_SEH:%=%_implib) $(TEST_SEH:%=%_clean) $(TEST_SEH:%=%_install)
|
||||
|
||||
|
||||
#
|
||||
# Regression Test Applications
|
||||
#
|
||||
$(TEST_REGRESSIONS): %:
|
||||
$(MAKE) -C regres/$*
|
||||
|
||||
$(TEST_REGRESSIONS:%=%_implib): %_implib:
|
||||
$(MAKE) -C regres/$* implib
|
||||
|
||||
$(TEST_REGRESSIONS:%=%_clean): %_clean:
|
||||
$(MAKE) -C regres/$* clean
|
||||
|
||||
$(TEST_REGRESSIONS:%=%_install): %_install:
|
||||
$(MAKE) -C regres/$* install
|
||||
|
||||
.PHONY: $(TEST_REGRESSIONS) $(TEST_REGRESSIONS:%=%_implib) $(TEST_REGRESSIONS:%=%_clean) $(TEST_REGRESSIONS:%=%_install)
|
||||
|
||||
|
||||
etags:
|
||||
find . -name "*.[ch]" -print | etags --language=c -
|
||||
|
||||
# EOF
|
24
apps/testsets/loadlib/makefile
Normal file
24
apps/testsets/loadlib/makefile
Normal file
@@ -0,0 +1,24 @@
|
||||
#
|
||||
# $Id: makefile,v 1.0
|
||||
|
||||
PATH_TO_TOP = ../../..
|
||||
|
||||
TARGET_NORC = yes
|
||||
|
||||
TARGET_TYPE = program
|
||||
|
||||
TARGET_APPTYPE = console
|
||||
|
||||
TARGET_NAME = loadlib
|
||||
|
||||
TARGET_CFLAGS = -Wall -Werror -D_USE_W32API -DUNICODE -D_UNICODE
|
||||
|
||||
TARGET_SDKLIBS = kernel32.a ntdll.a
|
||||
|
||||
TARGET_OBJECTS = $(TARGET_NAME).o
|
||||
|
||||
include $(PATH_TO_TOP)/rules.mak
|
||||
|
||||
include $(TOOLS_PATH)/helper.mk
|
||||
|
||||
# EOF
|
27
apps/testsets/msvcrt/fileio/makefile
Normal file
27
apps/testsets/msvcrt/fileio/makefile
Normal file
@@ -0,0 +1,27 @@
|
||||
#
|
||||
# $Id: makefile,v 1.0
|
||||
|
||||
PATH_TO_TOP = ../../../..
|
||||
|
||||
TEST_ROOT = $(PATH_TO_TOP)/apps/testsets/test
|
||||
|
||||
TARGET_NORC = yes
|
||||
|
||||
TARGET_TYPE = program
|
||||
|
||||
TARGET_APPTYPE = console
|
||||
|
||||
TARGET_NAME = fileio
|
||||
|
||||
#TARGET_CFLAGS = -I$(TEST_ROOT) -DDBG -DUNICODE -D_UNICODE
|
||||
TARGET_CFLAGS = -I$(TEST_ROOT) -DDBG
|
||||
|
||||
TARGET_SDKLIBS = ntdll.a kernel32.a
|
||||
|
||||
TARGET_OBJECTS = $(TARGET_NAME).o wfileio.o main.o
|
||||
|
||||
include $(PATH_TO_TOP)/rules.mak
|
||||
|
||||
include $(TOOLS_PATH)/helper.mk
|
||||
|
||||
# EOF
|
71
apps/utils/Makefile
Normal file
71
apps/utils/Makefile
Normal file
@@ -0,0 +1,71 @@
|
||||
#
|
||||
# ReactOS system utilities makefile
|
||||
#
|
||||
|
||||
PATH_TO_TOP = ../..
|
||||
|
||||
include $(PATH_TO_TOP)/rules.mak
|
||||
|
||||
|
||||
# Console system utilities
|
||||
# cabman cat net objdir partinfo pice ps sc stats
|
||||
UTIL_APPS = cat objdir partinfo pnpdump sc shutdown stats tickcount ps
|
||||
|
||||
UTIL_NET_APPS = arp finger ftp ipconfig netstat ping route telnet whois
|
||||
|
||||
|
||||
all: $(UTIL_APPS) $(UTIL_NET_APPS)
|
||||
|
||||
depends:
|
||||
|
||||
implib: $(UTIL_APPS:%=%_implib) \
|
||||
$(UTIL_NET_APPS:%=%_implib)
|
||||
|
||||
clean: $(UTIL_APPS:%=%_clean) \
|
||||
$(UTIL_NET_APPS:%=%_clean)
|
||||
|
||||
install: $(UTIL_APPS:%=%_install) \
|
||||
$(UTIL_NET_APPS:%=%_install)
|
||||
|
||||
.PHONY: all depends implib clean install
|
||||
|
||||
|
||||
#
|
||||
# Utility Applications
|
||||
#
|
||||
$(UTIL_APPS): %:
|
||||
$(MAKE) -C $*
|
||||
|
||||
$(UTIL_APPS:%=%_implib): %_implib:
|
||||
$(MAKE) -C $* implib
|
||||
|
||||
$(UTIL_APPS:%=%_clean): %_clean:
|
||||
$(MAKE) -C $* clean
|
||||
|
||||
$(UTIL_APPS:%=%_install): %_install:
|
||||
$(MAKE) -C $* install
|
||||
|
||||
.PHONY: $(UTIL_APPS) $(UTIL_APPS:%=%_implib) $(UTIL_APPS:%=%_clean) $(UTIL_APPS:%=%_install)
|
||||
|
||||
#
|
||||
# GUI Utility Applications
|
||||
#
|
||||
$(UTIL_NET_APPS): %:
|
||||
$(MAKE) -C net/$*
|
||||
|
||||
$(UTIL_NET_APPS:%=%_implib): %_implib:
|
||||
$(MAKE) -C net/$* implib
|
||||
|
||||
$(UTIL_NET_APPS:%=%_clean): %_clean:
|
||||
$(MAKE) -C net/$* clean
|
||||
|
||||
$(UTIL_NET_APPS:%=%_install): %_install:
|
||||
$(MAKE) -C net/$* install
|
||||
|
||||
.PHONY: $(UTIL_NET_APPS) $(UTIL_NET_APPS:%=%_implib) $(UTIL_NET_APPS:%=%_clean) $(UTIL_NET_APPS:%=%_install)
|
||||
|
||||
|
||||
etags:
|
||||
find . -name "*.[ch]" -print | etags --language=c -
|
||||
|
||||
# EOF
|
21
apps/utils/binpatch/Makefile
Normal file
21
apps/utils/binpatch/Makefile
Normal file
@@ -0,0 +1,21 @@
|
||||
PATH_TO_TOP = ../../..
|
||||
|
||||
TARGET_NORC = yes
|
||||
|
||||
TARGET_TYPE = program
|
||||
|
||||
TARGET_APPTYPE = console
|
||||
|
||||
TARGET_NAME = binpatch
|
||||
|
||||
TARGET_SDKLIBS =
|
||||
|
||||
TARGET_OBJECTS = patch.o
|
||||
|
||||
TARGET_CFLAGS += -Wall -Werror
|
||||
|
||||
include $(PATH_TO_TOP)/rules.mak
|
||||
|
||||
include $(TOOLS_PATH)/helper.mk
|
||||
|
||||
# EOF
|
615
apps/utils/binpatch/patch.c
Normal file
615
apps/utils/binpatch/patch.c
Normal file
@@ -0,0 +1,615 @@
|
||||
#include <conio.h>
|
||||
#include <io.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
/** DEFINES *******************************************************************/
|
||||
|
||||
#define PATCH_BUFFER_SIZE 4096 /* Maximum size of a patch */
|
||||
#define PATCH_BUFFER_MAGIC "\xde\xad\xbe\xef MaGiC MaRk "
|
||||
#define SIZEOF_PATCH_BUFFER_MAGIC (sizeof (PATCH_BUFFER_MAGIC) - 1)
|
||||
|
||||
/** TYPES *********************************************************************/
|
||||
|
||||
typedef struct _PatchedByte
|
||||
{
|
||||
int offset; /*!< File offset of the patched byte. */
|
||||
unsigned char expected; /*!< Expected (original) value of the byte. */
|
||||
unsigned char patched; /*!< Patched (new) value for the byte. */
|
||||
} PatchedByte;
|
||||
|
||||
typedef struct _PatchedFile
|
||||
{
|
||||
const char *name; /*!< Name of the file to be patched. */
|
||||
int fileSize; /*!< Size of the file in bytes. */
|
||||
int patchCount; /*!< Number of patches for the file. */
|
||||
PatchedByte *patches; /*!< Patches for the file. */
|
||||
} PatchedFile;
|
||||
|
||||
typedef struct _Patch
|
||||
{
|
||||
const char *name; /*!< Name of the patch. */
|
||||
int fileCount; /*!< Number of files in the patch. */
|
||||
PatchedFile *files; /*!< Files for the patch. */
|
||||
} Patch;
|
||||
|
||||
/** FUNCTION PROTOTYPES *******************************************************/
|
||||
|
||||
static void printUsage();
|
||||
|
||||
/** GLOBALS *******************************************************************/
|
||||
|
||||
static Patch m_patch = { NULL, 0, NULL };
|
||||
static int m_argc = 0;
|
||||
static char **m_argv = NULL;
|
||||
|
||||
/* patch buffer where we put the patch info into */
|
||||
static unsigned char m_patchBuffer[SIZEOF_PATCH_BUFFER_MAGIC + PATCH_BUFFER_SIZE] =
|
||||
PATCH_BUFFER_MAGIC;
|
||||
|
||||
/** HELPER FUNCTIONS **********************************************************/
|
||||
|
||||
static void *
|
||||
loadFile(const char *fileName, int *fileSize_)
|
||||
{
|
||||
FILE *f;
|
||||
struct stat sb;
|
||||
int fileSize;
|
||||
void *p;
|
||||
|
||||
/* Open the file */
|
||||
f = fopen(fileName, "rb");
|
||||
if (f == NULL)
|
||||
{
|
||||
printf("Couldn't open file %s for reading!\n", fileName);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Get file size */
|
||||
if (fstat(fileno(f), &sb) < 0)
|
||||
{
|
||||
fclose(f);
|
||||
printf("Couldn't get size of file %s!\n", fileName);
|
||||
return NULL;
|
||||
}
|
||||
fileSize = sb.st_size;
|
||||
|
||||
/* Load file */
|
||||
p = malloc(fileSize);
|
||||
if (p == NULL)
|
||||
{
|
||||
fclose(f);
|
||||
printf("Couldn't allocate %d bytes for file %s!\n", fileSize, fileName);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (fread(p, fileSize, 1, f) != 1)
|
||||
{
|
||||
fclose(f);
|
||||
free(p);
|
||||
printf("Couldn't read file %s into memory!\n", fileName);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Close file */
|
||||
fclose(f);
|
||||
|
||||
*fileSize_ = fileSize;
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
saveFile(const char *fileName, void *file, int fileSize)
|
||||
{
|
||||
FILE *f;
|
||||
|
||||
/* Open the file */
|
||||
f = fopen(fileName, "wb");
|
||||
if (f == NULL)
|
||||
{
|
||||
printf("Couldn't open file %s for writing!\n", fileName);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Write file */
|
||||
if (fwrite(file, fileSize, 1, f) != 1)
|
||||
{
|
||||
fclose(f);
|
||||
printf("Couldn't write file %s!\n", fileName);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Close file */
|
||||
fclose(f);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
compareFiles(
|
||||
PatchedFile *patchedFile,
|
||||
const char *originalFileName)
|
||||
{
|
||||
const char *patchedFileName = patchedFile->name;
|
||||
unsigned char *origChunk, *patchedChunk;
|
||||
int origSize, patchedSize, i, patchCount;
|
||||
PatchedByte *patches = NULL;
|
||||
int patchesArrayCount = 0;
|
||||
|
||||
/* Load both files */
|
||||
origChunk = loadFile(originalFileName, &origSize);
|
||||
if (origChunk == NULL)
|
||||
return -1;
|
||||
patchedChunk = loadFile(patchedFileName, &patchedSize);
|
||||
if (patchedChunk == NULL)
|
||||
{
|
||||
free(origChunk);
|
||||
return -1;
|
||||
}
|
||||
if (origSize != patchedSize)
|
||||
{
|
||||
free(origChunk);
|
||||
free(patchedChunk);
|
||||
printf("File size of %s and %s differs (%d != %d)\n",
|
||||
originalFileName, patchedFileName,
|
||||
origSize, patchedSize);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Compare the files and record any differences */
|
||||
printf("Comparing %s to %s", originalFileName, patchedFileName);
|
||||
for (i = 0, patchCount = 0; i < origSize; i++)
|
||||
{
|
||||
if (origChunk[i] != patchedChunk[i])
|
||||
{
|
||||
patchCount++;
|
||||
|
||||
/* Resize patches array if needed */
|
||||
if (patchesArrayCount < patchCount)
|
||||
{
|
||||
PatchedByte *newPatches;
|
||||
newPatches = realloc(patches, patchCount * sizeof (PatchedByte));
|
||||
if (newPatches == NULL)
|
||||
{
|
||||
if (patches != NULL)
|
||||
free(patches);
|
||||
free(origChunk);
|
||||
free(patchedChunk);
|
||||
printf("\nOut of memory (tried to allocated %d bytes)\n",
|
||||
patchCount * sizeof (PatchedByte));
|
||||
return -1;
|
||||
}
|
||||
patches = newPatches;
|
||||
}
|
||||
|
||||
/* Fill in patch info */
|
||||
patches[patchCount - 1].offset = i;
|
||||
patches[patchCount - 1].expected = origChunk[i];
|
||||
patches[patchCount - 1].patched = patchedChunk[i];
|
||||
}
|
||||
if ((i % (origSize / 40)) == 0)
|
||||
printf(".");
|
||||
}
|
||||
printf(" %d changed bytes found.\n", patchCount);
|
||||
|
||||
/* Unload the files */
|
||||
free(origChunk);
|
||||
free(patchedChunk);
|
||||
|
||||
/* Save patch info */
|
||||
patchedFile->fileSize = patchedSize;
|
||||
patchedFile->patchCount = patchCount;
|
||||
patchedFile->patches = patches;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
outputPatch(const char *outputFileName)
|
||||
{
|
||||
unsigned char *patchExe, *patchBuffer;
|
||||
int i, size, patchExeSize, patchSize, stringSize, stringOffset, patchOffset;
|
||||
Patch *patch;
|
||||
PatchedFile *files;
|
||||
|
||||
printf("Putting patch into %s...\n", outputFileName);
|
||||
|
||||
/* Calculate size of the patch */
|
||||
patchSize = sizeof (Patch) + sizeof (PatchedFile) * m_patch.fileCount;
|
||||
stringSize = strlen(m_patch.name) + 1;
|
||||
for (i = 0; i < m_patch.fileCount; i++)
|
||||
{
|
||||
stringSize += strlen(m_patch.files[i].name) + 1;
|
||||
patchSize += sizeof (PatchedByte) * m_patch.files[i].patchCount;
|
||||
}
|
||||
if ((stringSize + patchSize) > PATCH_BUFFER_SIZE)
|
||||
{
|
||||
printf("Patch is too big - %d bytes maximum, %d bytes needed\n",
|
||||
PATCH_BUFFER_SIZE, stringSize + patchSize);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Load patch.exe file into memory... */
|
||||
patchExe = loadFile(m_argv[0], &patchExeSize);
|
||||
if (patchExe == NULL)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Try to find the magic mark for the patch buffer */
|
||||
for (i = 0; i < (patchExeSize - SIZEOF_PATCH_BUFFER_MAGIC); i++)
|
||||
{
|
||||
if (memcmp(patchExe + i, m_patchBuffer, SIZEOF_PATCH_BUFFER_MAGIC) == 0)
|
||||
{
|
||||
patchBuffer = patchExe + i + SIZEOF_PATCH_BUFFER_MAGIC;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!(i < (patchExeSize - SIZEOF_PATCH_BUFFER_MAGIC)))
|
||||
{
|
||||
free(patchExe);
|
||||
printf("Couldn't find patch buffer magic in file %s - this shouldn't happen!!!\n", m_argv[0]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Pack patch together and replace string pointers by offsets */
|
||||
patch = (Patch *)patchBuffer;
|
||||
files = (PatchedFile *)(patchBuffer + sizeof (Patch));
|
||||
patchOffset = sizeof (Patch) + sizeof (PatchedFile) * m_patch.fileCount;
|
||||
stringOffset = patchSize;
|
||||
|
||||
patch->fileCount = m_patch.fileCount;
|
||||
patch->files = (PatchedFile *)sizeof (Patch);
|
||||
|
||||
patch->name = (const char *)stringOffset;
|
||||
strcpy(patchBuffer + stringOffset, m_patch.name);
|
||||
stringOffset += strlen(m_patch.name) + 1;
|
||||
|
||||
for (i = 0; i < m_patch.fileCount; i++)
|
||||
{
|
||||
files[i].fileSize = m_patch.files[i].fileSize;
|
||||
files[i].patchCount = m_patch.files[i].patchCount;
|
||||
|
||||
files[i].name = (const char *)stringOffset;
|
||||
strcpy(patchBuffer + stringOffset, m_patch.files[i].name);
|
||||
stringOffset += strlen(m_patch.files[i].name) + 1;
|
||||
|
||||
size = files[i].patchCount * sizeof (PatchedByte);
|
||||
files[i].patches = (PatchedByte *)patchOffset;
|
||||
memcpy(patchBuffer + patchOffset, m_patch.files[i].patches, size);
|
||||
patchOffset += size;
|
||||
}
|
||||
size = patchSize + stringSize;
|
||||
memset(patchBuffer + size, 0, PATCH_BUFFER_SIZE - size);
|
||||
|
||||
/* Save file */
|
||||
if (saveFile(outputFileName, patchExe, patchExeSize) < 0)
|
||||
{
|
||||
free(patchExe);
|
||||
return -1;
|
||||
}
|
||||
free(patchExe);
|
||||
|
||||
printf("Patch saved!\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
loadPatch()
|
||||
{
|
||||
char *p;
|
||||
Patch *patch;
|
||||
int i;
|
||||
|
||||
p = m_patchBuffer + SIZEOF_PATCH_BUFFER_MAGIC;
|
||||
patch = (Patch *)p;
|
||||
|
||||
if (patch->name == NULL)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
m_patch.name = p + (int)patch->name;
|
||||
m_patch.fileCount = patch->fileCount;
|
||||
m_patch.files = (PatchedFile *)(p + (int)patch->files);
|
||||
|
||||
for (i = 0; i < m_patch.fileCount; i++)
|
||||
{
|
||||
m_patch.files[i].name = p + (int)m_patch.files[i].name;
|
||||
m_patch.files[i].patches = (PatchedByte *)(p + (int)m_patch.files[i].patches);
|
||||
}
|
||||
|
||||
printf("Patch %s loaded...\n", m_patch.name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/** MAIN FUNCTIONS ************************************************************/
|
||||
|
||||
static int
|
||||
createPatch()
|
||||
{
|
||||
int i, status;
|
||||
const char *outputFileName;
|
||||
|
||||
/* Check argument count */
|
||||
if (m_argc < 6 || (m_argc % 2) != 0)
|
||||
{
|
||||
printUsage();
|
||||
return -1;
|
||||
}
|
||||
|
||||
outputFileName = m_argv[3];
|
||||
m_patch.name = m_argv[2];
|
||||
|
||||
/* Allocate PatchedFiles array */
|
||||
m_patch.fileCount = (m_argc - 4) / 2;
|
||||
m_patch.files = malloc(m_patch.fileCount * sizeof (PatchedFile));
|
||||
if (m_patch.files == NULL)
|
||||
{
|
||||
printf("Out of memory!\n");
|
||||
return -1;
|
||||
}
|
||||
memset(m_patch.files, 0, m_patch.fileCount * sizeof (PatchedFile));
|
||||
|
||||
/* Compare original to patched files and fill m_patch.files array */
|
||||
for (i = 0; i < m_patch.fileCount; i++)
|
||||
{
|
||||
m_patch.files[i].name = m_argv[4 + (i * 2) + 1];
|
||||
status = compareFiles(m_patch.files + i, m_argv[4 + (i * 2) + 0]);
|
||||
if (status < 0)
|
||||
{
|
||||
for (i = 0; i < m_patch.fileCount; i++)
|
||||
{
|
||||
if (m_patch.files[i].patches != NULL)
|
||||
free(m_patch.files[i].patches);
|
||||
}
|
||||
free(m_patch.files);
|
||||
m_patch.files = NULL;
|
||||
m_patch.fileCount = 0;
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
||||
/* Output patch */
|
||||
return outputPatch(outputFileName);
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
applyPatch()
|
||||
{
|
||||
int c, i, j, fileSize, makeBackup;
|
||||
unsigned char *file;
|
||||
char *p;
|
||||
const char *fileName;
|
||||
char buffer[MAX_PATH];
|
||||
|
||||
|
||||
if (m_argc > 1 && strcmp(m_argv[1], "-d") != 0)
|
||||
{
|
||||
printUsage();
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Load patch */
|
||||
if (loadPatch() < 0)
|
||||
{
|
||||
printf("This executable doesn't contain a patch, use -c to create one.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (m_argc > 1)
|
||||
{
|
||||
/* Dump patch */
|
||||
printf("Patch name: %s\n", m_patch.name);
|
||||
printf("File count: %d\n", m_patch.fileCount);
|
||||
for (i = 0; i < m_patch.fileCount; i++)
|
||||
{
|
||||
printf("----------------------\n"
|
||||
"File name: %s\n"
|
||||
"File size: %d bytes\n",
|
||||
m_patch.files[i].name, m_patch.files[i].fileSize);
|
||||
printf("Patch count: %d\n", m_patch.files[i].patchCount);
|
||||
for (j = 0; j < m_patch.files[i].patchCount; j++)
|
||||
{
|
||||
printf(" Offset 0x%x 0x%02x -> 0x%02x\n",
|
||||
m_patch.files[i].patches[j].offset,
|
||||
m_patch.files[i].patches[j].expected,
|
||||
m_patch.files[i].patches[j].patched);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Apply patch */
|
||||
printf("Applying patch...\n");
|
||||
for (i = 0; i < m_patch.fileCount; i++)
|
||||
{
|
||||
/* Load original file */
|
||||
fileName = m_patch.files[i].name;
|
||||
applyPatch_retry_file:
|
||||
file = loadFile(fileName, &fileSize);
|
||||
if (file == NULL)
|
||||
{
|
||||
printf("File %s not found! ", fileName);
|
||||
applyPatch_file_open_error:
|
||||
printf("(S)kip, (R)etry, (A)bort, (M)anually enter filename");
|
||||
do
|
||||
{
|
||||
c = getch();
|
||||
}
|
||||
while (c != 's' && c != 'r' && c != 'a' && c != 'm');
|
||||
printf("\n");
|
||||
if (c == 's')
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else if (c == 'r')
|
||||
{
|
||||
goto applyPatch_retry_file;
|
||||
}
|
||||
else if (c == 'a')
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else if (c == 'm')
|
||||
{
|
||||
if (fgets(buffer, sizeof (buffer), stdin) == NULL)
|
||||
{
|
||||
printf("fgets() failed!\n");
|
||||
return -1;
|
||||
}
|
||||
p = strchr(buffer, '\r');
|
||||
if (p != NULL)
|
||||
*p = '\0';
|
||||
p = strchr(buffer, '\n');
|
||||
if (p != NULL)
|
||||
*p = '\0';
|
||||
|
||||
fileName = buffer;
|
||||
goto applyPatch_retry_file;
|
||||
}
|
||||
}
|
||||
|
||||
/* Check file size */
|
||||
if (fileSize != m_patch.files[i].fileSize)
|
||||
{
|
||||
free(file);
|
||||
printf("File %s has unexpected filesize of %d bytes (%d bytes expected)\n",
|
||||
fileName, fileSize, m_patch.files[i].fileSize);
|
||||
if (fileName != m_patch.files[i].name) /* manually entered filename */
|
||||
{
|
||||
goto applyPatch_file_open_error;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Ask for backup */
|
||||
printf("Do you want to make a backup of %s? (Y)es, (N)o, (A)bort", fileName);
|
||||
do
|
||||
{
|
||||
c = getch();
|
||||
}
|
||||
while (c != 'y' && c != 'n' && c != 'a');
|
||||
printf("\n");
|
||||
if (c == 'y')
|
||||
{
|
||||
char buffer[MAX_PATH];
|
||||
snprintf(buffer, MAX_PATH, "%s.bak", fileName);
|
||||
buffer[MAX_PATH-1] = '\0';
|
||||
makeBackup = 1;
|
||||
if (access(buffer, 0) >= 0) /* file exists */
|
||||
{
|
||||
printf("File %s already exists, overwrite? (Y)es, (N)o, (A)bort", buffer);
|
||||
do
|
||||
{
|
||||
c = getch();
|
||||
}
|
||||
while (c != 'y' && c != 'n' && c != 'a');
|
||||
printf("\n");
|
||||
if (c == 'n')
|
||||
makeBackup = 0;
|
||||
else if (c == 'a')
|
||||
{
|
||||
free(file);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if (makeBackup && saveFile(buffer, file, fileSize) < 0)
|
||||
{
|
||||
free(file);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else if (c == 'a')
|
||||
{
|
||||
free(file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Patch file */
|
||||
for (j = 0; j < m_patch.files[i].patchCount; j++)
|
||||
{
|
||||
int offset = m_patch.files[i].patches[j].offset;
|
||||
if (file[offset] != m_patch.files[i].patches[j].expected)
|
||||
{
|
||||
printf("Unexpected value in file %s at offset 0x%x: expected = 0x%02x, found = 0x%02x\n",
|
||||
fileName, offset, m_patch.files[i].patches[j].expected, file[offset]);
|
||||
free(file);
|
||||
return -1;
|
||||
}
|
||||
file[offset] = m_patch.files[i].patches[j].patched;
|
||||
}
|
||||
|
||||
/* Save file */
|
||||
if (saveFile(fileName, file, fileSize) < 0)
|
||||
{
|
||||
free(file);
|
||||
return -1;
|
||||
}
|
||||
free(file);
|
||||
}
|
||||
|
||||
printf("Patch applied sucessfully!\n");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
printUsage()
|
||||
{
|
||||
printf("Usage:\n"
|
||||
"%s -c - Create patch\n"
|
||||
"%s -d - Dump patch\n"
|
||||
"%s - Apply patch\n"
|
||||
"\n"
|
||||
"A patch can be created like this:\n"
|
||||
"%s -c \"patch name\" output.exe file1.orig file1.patched[ file2.orig file2.patched[ ...]]\n",
|
||||
m_argv[0], m_argv[0], m_argv[0], m_argv[0]);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main(
|
||||
int argc,
|
||||
char *argv[])
|
||||
{
|
||||
m_argc = argc;
|
||||
m_argv = argv;
|
||||
|
||||
if (argc >= 2 && (strcmp(argv[1], "-h") == 0 || strcmp(argv[1], "--help") == 0))
|
||||
{
|
||||
printUsage();
|
||||
return 0;
|
||||
}
|
||||
else if (argc >= 2 && argv[1][0] == '-')
|
||||
{
|
||||
if (strcmp(argv[1], "-c") == 0)
|
||||
{
|
||||
return createPatch();
|
||||
}
|
||||
else if (strcmp(argv[1], "-d") == 0)
|
||||
{
|
||||
return applyPatch();
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Unknown option: %s\n"
|
||||
"Use -h for help.\n",
|
||||
argv[1]);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return applyPatch();
|
||||
}
|
||||
|
@@ -6,7 +6,7 @@ int main(int argc, char* argv[])
|
||||
int i;
|
||||
FILE* in;
|
||||
char ch;
|
||||
|
||||
|
||||
for (i=1; i<argc; i++)
|
||||
{
|
||||
in = fopen(argv[i],"r");
|
||||
@@ -15,7 +15,7 @@ int main(int argc, char* argv[])
|
||||
printf("Failed to open file %s\n", argv[i]);
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
while ((ch = fgetc(in)) != EOF)
|
||||
{
|
||||
putchar(ch);
|
21
apps/utils/cat/makefile
Normal file
21
apps/utils/cat/makefile
Normal file
@@ -0,0 +1,21 @@
|
||||
# $Id$
|
||||
|
||||
PATH_TO_TOP = ../../..
|
||||
|
||||
TARGET_NORC = yes
|
||||
|
||||
TARGET_TYPE = program
|
||||
|
||||
TARGET_APPTYPE = console
|
||||
|
||||
TARGET_NAME = cat
|
||||
|
||||
TARGET_OBJECTS = $(TARGET_NAME).o
|
||||
|
||||
TARGET_CFLAGS = -Wall -Werror
|
||||
|
||||
include $(PATH_TO_TOP)/rules.mak
|
||||
|
||||
include $(TOOLS_PATH)/helper.mk
|
||||
|
||||
# EOF
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Load a device driver
|
||||
*/
|
||||
*/
|
||||
#include <windows.h>
|
||||
#include <ntos/zw.h>
|
||||
|
21
apps/utils/driver/load/makefile
Normal file
21
apps/utils/driver/load/makefile
Normal file
@@ -0,0 +1,21 @@
|
||||
PATH_TO_TOP = ../../../..
|
||||
|
||||
TARGET_NORC = yes
|
||||
|
||||
TARGET_TYPE = program
|
||||
|
||||
TARGET_APPTYPE = console
|
||||
|
||||
TARGET_NAME = load
|
||||
|
||||
TARGET_CFLAGS = -DUNICODE -D_UNICODE
|
||||
|
||||
TARGET_SDKLIBS = ntdll.a
|
||||
|
||||
TARGET_OBJECTS = $(TARGET_NAME).o
|
||||
|
||||
include $(PATH_TO_TOP)/rules.mak
|
||||
|
||||
include $(TOOLS_PATH)/helper.mk
|
||||
|
||||
# EOF
|
21
apps/utils/driver/unload/makefile
Normal file
21
apps/utils/driver/unload/makefile
Normal file
@@ -0,0 +1,21 @@
|
||||
PATH_TO_TOP = ../../../..
|
||||
|
||||
TARGET_NORC = yes
|
||||
|
||||
TARGET_TYPE = program
|
||||
|
||||
TARGET_APPTYPE = console
|
||||
|
||||
TARGET_NAME = unload
|
||||
|
||||
TARGET_CFLAGS = -DUNICODE -D_UNICODE
|
||||
|
||||
TARGET_SDKLIBS = ntdll.a
|
||||
|
||||
TARGET_OBJECTS = $(TARGET_NAME).o
|
||||
|
||||
include $(PATH_TO_TOP)/rules.mak
|
||||
|
||||
include $(TOOLS_PATH)/helper.mk
|
||||
|
||||
# EOF
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Unload a device driver
|
||||
*/
|
||||
*/
|
||||
#include <windows.h>
|
||||
#include <ntos/zw.h>
|
||||
|
21
apps/utils/infinst/makefile
Normal file
21
apps/utils/infinst/makefile
Normal file
@@ -0,0 +1,21 @@
|
||||
PATH_TO_TOP = ../../..
|
||||
|
||||
TARGET_NORC = yes
|
||||
|
||||
TARGET_TYPE = program
|
||||
|
||||
TARGET_APPTYPE = windows
|
||||
|
||||
TARGET_NAME = infinst
|
||||
|
||||
TARGET_SDKLIBS = comdlg32.a setupapi.a
|
||||
|
||||
TARGET_OBJECTS = infinst.o
|
||||
|
||||
TARGET_CFLAGS = -Wall -Werror
|
||||
|
||||
include $(PATH_TO_TOP)/rules.mak
|
||||
|
||||
include $(TOOLS_PATH)/helper.mk
|
||||
|
||||
# EOF
|
99
apps/utils/net/arp/arp.c
Normal file
99
apps/utils/net/arp/arp.c
Normal file
@@ -0,0 +1,99 @@
|
||||
/*
|
||||
* arp - display ARP cache from the IP stack parameters.
|
||||
*
|
||||
* This source code is in the PUBLIC DOMAIN and has NO WARRANTY.
|
||||
*
|
||||
* Robert Dickenson <robd@reactos.org>, August 15, 2002.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <windows.h>
|
||||
#include <tchar.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <iptypes.h>
|
||||
#include <ipexport.h>
|
||||
#include <iphlpapi.h>
|
||||
#include <snmp.h>
|
||||
|
||||
#include "trace.h"
|
||||
|
||||
|
||||
VOID SNMP_FUNC_TYPE SnmpSvcInitUptime();
|
||||
DWORD SNMP_FUNC_TYPE SnmpSvcGetUptime();
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
const char szUsage[] = { "\n" \
|
||||
"Displays and modifies the IP Protocol to physical address translation tables\n" \
|
||||
"used by address resolution protocol (ARP).\n" \
|
||||
"\n" \
|
||||
"ARP -s inet_addr eth_addr [if_addr]\n" \
|
||||
"ARP -d inet_addr [if_addr]\n" \
|
||||
"ARP -a [inet_addr] [-N if_addr]\n" \
|
||||
"\n" \
|
||||
" -a Displays the active ARP table by querying the current protocol\n" \
|
||||
" data. If inet_addr is specified, the IP and physical addresses\n" \
|
||||
" for the specified address are displayed. If more than one\n" \
|
||||
" network interface is using ARP, each interfaces ARP table is\n" \
|
||||
" displayed.\n" \
|
||||
" -g Indentical to -a.\n" \
|
||||
" inet_addr Specifies the IP address.\n" \
|
||||
" -N if_addr Displays the ARP table for the specified interface only\n" \
|
||||
" -d Deletes the host entry specified by inet_addr. inet_addr may be\n" \
|
||||
" wildcarded with * to delete all host entries in the ARP table.\n" \
|
||||
" -s Adds the host and associates the IP address inet_addr with the\n" \
|
||||
" physical address eth_addr. The physical address must be specified\n" \
|
||||
" as 6 hexadecimal characters delimited by hyphens. The new entry\n" \
|
||||
" will become permanent in the ARP table.\n" \
|
||||
" eth_addr Specifies the interface physical address.\n" \
|
||||
" if_addr If present, this specifies the IP address of the interface whose\n" \
|
||||
" address translation table should be modified. If not present, the\n" \
|
||||
" first applicable interface will be used.\n" \
|
||||
"Example:\n" \
|
||||
" > arp -s 192.168.0.12 55-AA-55-01-02-03 .... Static entry creation.\n" \
|
||||
" > arp -a .... ARP table display.\n" \
|
||||
" > arp -d * .... Delete all ARP table entries.\n"
|
||||
};
|
||||
|
||||
void usage(void)
|
||||
{
|
||||
// fprintf(stderr,"USAGE:\n");
|
||||
fputs(szUsage, stderr);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
TCHAR szComputerName[50];
|
||||
DWORD dwSize = 50;
|
||||
|
||||
int nBytes = 500;
|
||||
BYTE* pCache;
|
||||
|
||||
if (argc > 1) {
|
||||
usage();
|
||||
return 1;
|
||||
}
|
||||
|
||||
SnmpSvcInitUptime();
|
||||
|
||||
GetComputerName(szComputerName, &dwSize);
|
||||
_tprintf(_T("ReactOS ARP cache on Computer Name: %s\n"), szComputerName);
|
||||
|
||||
pCache = (BYTE*)SnmpUtilMemAlloc(nBytes);
|
||||
|
||||
Sleep(2500);
|
||||
|
||||
if (pCache != NULL) {
|
||||
|
||||
DWORD dwUptime = SnmpSvcGetUptime();
|
||||
|
||||
_tprintf(_T("SNMP uptime: %d\n"), dwUptime);
|
||||
|
||||
SnmpUtilMemFree(pCache);
|
||||
} else {
|
||||
_tprintf(_T("ERROR: call to SnmpUtilMemAlloc() failed\n"));
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
6
apps/utils/net/arp/arp.rc
Normal file
6
apps/utils/net/arp/arp.rc
Normal file
@@ -0,0 +1,6 @@
|
||||
/* $Id$ */
|
||||
|
||||
#define REACTOS_STR_FILE_DESCRIPTION "ReactOS TCP/IPv4 Win32 arp\0"
|
||||
#define REACTOS_STR_INTERNAL_NAME "arp\0"
|
||||
#define REACTOS_STR_ORIGINAL_FILENAME "arp.exe\0"
|
||||
#include <reactos/version.rc>
|
19
apps/utils/net/arp/makefile
Normal file
19
apps/utils/net/arp/makefile
Normal file
@@ -0,0 +1,19 @@
|
||||
PATH_TO_TOP = ../../../..
|
||||
|
||||
TARGET_TYPE = program
|
||||
|
||||
TARGET_APPTYPE = console
|
||||
|
||||
TARGET_NAME = arp
|
||||
|
||||
TARGET_INSTALLDIR = system32
|
||||
|
||||
TARGET_CFLAGS = -D__USE_W32API
|
||||
|
||||
TARGET_SDKLIBS = user32.a snmpapi.a
|
||||
|
||||
TARGET_OBJECTS = $(TARGET_NAME).o
|
||||
|
||||
include $(PATH_TO_TOP)/rules.mak
|
||||
|
||||
include $(TOOLS_PATH)/helper.mk
|
53
apps/utils/net/arp/trace.c
Normal file
53
apps/utils/net/arp/trace.c
Normal file
@@ -0,0 +1,53 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Diagnostic Trace
|
||||
//
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#include <tchar.h>
|
||||
#include "trace.h"
|
||||
|
||||
|
||||
#ifdef _DEBUG
|
||||
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
|
||||
void _DebugBreak(void)
|
||||
{
|
||||
DebugBreak();
|
||||
}
|
||||
|
||||
void Trace(TCHAR* lpszFormat, ...)
|
||||
{
|
||||
va_list args;
|
||||
int nBuf;
|
||||
TCHAR szBuffer[512];
|
||||
|
||||
va_start(args, lpszFormat);
|
||||
nBuf = _vsntprintf(szBuffer, sizeof(szBuffer)/sizeof(TCHAR), lpszFormat, args);
|
||||
OutputDebugString(szBuffer);
|
||||
// was there an error? was the expanded string too long?
|
||||
//ASSERT(nBuf >= 0);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void Assert(void* assert, TCHAR* file, int line, void* msg)
|
||||
{
|
||||
if (msg == NULL) {
|
||||
printf("ASSERT -- %s occured on line %u of file %s.\n",
|
||||
assert, line, file);
|
||||
} else {
|
||||
printf("ASSERT -- %s occured on line %u of file %s: Message = %s.\n",
|
||||
assert, line, file, msg);
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void Trace(TCHAR* lpszFormat, ...) { };
|
||||
void Assert(void* assert, TCHAR* file, int line, void* msg) { };
|
||||
|
||||
#endif //_DEBUG
|
||||
/////////////////////////////////////////////////////////////////////////////
|
61
apps/utils/net/arp/trace.h
Normal file
61
apps/utils/net/arp/trace.h
Normal file
@@ -0,0 +1,61 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Diagnostic Trace
|
||||
//
|
||||
#ifndef __TRACE_H__
|
||||
#define __TRACE_H__
|
||||
|
||||
#ifdef _DEBUG
|
||||
|
||||
#ifdef _X86_
|
||||
#define BreakPoint() _asm { int 3h }
|
||||
#else
|
||||
#define BreakPoint() _DebugBreak()
|
||||
#endif
|
||||
|
||||
#ifndef ASSERT
|
||||
#define ASSERT(exp) \
|
||||
{ \
|
||||
if (!(exp)) { \
|
||||
Assert(#exp, __FILE__, __LINE__, NULL); \
|
||||
BreakPoint(); \
|
||||
} \
|
||||
} \
|
||||
|
||||
#define ASSERTMSG(exp, msg) \
|
||||
{ \
|
||||
if (!(exp)) { \
|
||||
Assert(#exp, __FILE__, __LINE__, msg); \
|
||||
BreakPoint(); \
|
||||
} \
|
||||
}
|
||||
#endif
|
||||
|
||||
//=============================================================================
|
||||
// MACRO: TRACE()
|
||||
//=============================================================================
|
||||
|
||||
#define TRACE Trace
|
||||
|
||||
|
||||
#else // _DEBUG
|
||||
|
||||
//=============================================================================
|
||||
// Define away MACRO's ASSERT() and TRACE() in non debug builds
|
||||
//=============================================================================
|
||||
|
||||
#ifndef ASSERT
|
||||
#define ASSERT(exp)
|
||||
#define ASSERTMSG(exp, msg)
|
||||
#endif
|
||||
|
||||
#define TRACE 0 ? (void)0 : Trace
|
||||
|
||||
#endif // !_DEBUG
|
||||
|
||||
|
||||
void Assert(void* assert, TCHAR* file, int line, void* msg);
|
||||
void Trace(TCHAR* lpszFormat, ...);
|
||||
|
||||
|
||||
#endif // __TRACE_H__
|
||||
/////////////////////////////////////////////////////////////////////////////
|
180
apps/utils/net/finger/err.c
Normal file
180
apps/utils/net/finger/err.c
Normal file
@@ -0,0 +1,180 @@
|
||||
/*-
|
||||
* Copyright (c) 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
static char sccsid[] = "@(#)err.c 8.1 (Berkeley) 6/4/93";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include "err.h"
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef __STDC__
|
||||
#include <stdarg.h>
|
||||
#else
|
||||
#include <varargs.h>
|
||||
#endif
|
||||
|
||||
extern char *__progname; /* Program name, from crt0. */
|
||||
|
||||
void
|
||||
#ifdef __STDC__
|
||||
err(int eval, const char *fmt, ...)
|
||||
#else
|
||||
err(eval, fmt, va_alist)
|
||||
int eval;
|
||||
const char *fmt;
|
||||
va_dcl
|
||||
#endif
|
||||
{
|
||||
va_list ap;
|
||||
#if __STDC__
|
||||
va_start(ap, fmt);
|
||||
#else
|
||||
va_start(ap);
|
||||
#endif
|
||||
verr(eval, fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
void
|
||||
verr(int eval, const char *fmt, va_list ap)
|
||||
{
|
||||
int sverrno;
|
||||
|
||||
sverrno = errno;
|
||||
(void)fprintf(stderr, "%s: ", __progname);
|
||||
if (fmt != NULL) {
|
||||
(void)vfprintf(stderr, fmt, ap);
|
||||
(void)fprintf(stderr, ": ");
|
||||
}
|
||||
(void)fprintf(stderr, "%s\n", strerror(sverrno));
|
||||
exit(eval);
|
||||
}
|
||||
|
||||
void
|
||||
#if __STDC__
|
||||
errx(int eval, const char *fmt, ...)
|
||||
#else
|
||||
errx(eval, fmt, va_alist)
|
||||
int eval;
|
||||
const char *fmt;
|
||||
va_dcl
|
||||
#endif
|
||||
{
|
||||
va_list ap;
|
||||
#if __STDC__
|
||||
va_start(ap, fmt);
|
||||
#else
|
||||
va_start(ap);
|
||||
#endif
|
||||
verrx(eval, fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
void
|
||||
verrx(int eval, const char *fmt, va_list ap)
|
||||
{
|
||||
(void)fprintf(stderr, "%s: ", __progname);
|
||||
if (fmt != NULL)
|
||||
(void)vfprintf(stderr, fmt, ap);
|
||||
(void)fprintf(stderr, "\n");
|
||||
exit(eval);
|
||||
}
|
||||
|
||||
void
|
||||
#if __STDC__
|
||||
warn(const char *fmt, ...)
|
||||
#else
|
||||
warn(fmt, va_alist)
|
||||
const char *fmt;
|
||||
va_dcl
|
||||
#endif
|
||||
{
|
||||
va_list ap;
|
||||
#if __STDC__
|
||||
va_start(ap, fmt);
|
||||
#else
|
||||
va_start(ap);
|
||||
#endif
|
||||
vwarn(fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
void
|
||||
vwarn(fmt, ap)
|
||||
const char *fmt;
|
||||
va_list ap;
|
||||
{
|
||||
int sverrno;
|
||||
|
||||
sverrno = errno;
|
||||
(void)fprintf(stderr, "%s: ", __progname);
|
||||
if (fmt != NULL) {
|
||||
(void)vfprintf(stderr, fmt, ap);
|
||||
(void)fprintf(stderr, ": ");
|
||||
}
|
||||
(void)fprintf(stderr, "%s\n", strerror(sverrno));
|
||||
}
|
||||
|
||||
void
|
||||
#ifdef __STDC__
|
||||
warnx(const char *fmt, ...)
|
||||
#else
|
||||
warnx(fmt, va_alist)
|
||||
const char *fmt;
|
||||
va_dcl
|
||||
#endif
|
||||
{
|
||||
va_list ap;
|
||||
#ifdef __STDC__
|
||||
va_start(ap, fmt);
|
||||
#else
|
||||
va_start(ap);
|
||||
#endif
|
||||
vwarnx(fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
void
|
||||
vwarnx(fmt, ap)
|
||||
const char *fmt;
|
||||
va_list ap;
|
||||
{
|
||||
(void)fprintf(stderr, "%s: ", __progname);
|
||||
if (fmt != NULL)
|
||||
(void)vfprintf(stderr, fmt, ap);
|
||||
(void)fprintf(stderr, "\n");
|
||||
}
|
@@ -41,6 +41,16 @@
|
||||
* Had to remove local handling. Otherwise, same as whois.
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static char copyright[] =
|
||||
"@(#) Copyright (c) 1989, 1993\n\
|
||||
The Regents of the University of California. All rights reserved.\n";
|
||||
#endif /* not lint */
|
||||
|
||||
#ifndef lint
|
||||
static char sccsid[] = "@(#)finger.c 8.5 (Berkeley) 5/4/95";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
* Finger prints out information about users. It is not portable since
|
||||
* certain fields (e.g. the full user name, office, and phone numbers) are
|
||||
@@ -62,6 +72,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include "unistd.h"
|
||||
|
||||
#include "various.h"
|
||||
#include "getopt.h"
|
||||
@@ -73,6 +84,7 @@ int lflag, mflag, pplan, sflag;
|
||||
|
||||
static void userlist(int, char **);
|
||||
void usage();
|
||||
void netfinger(char *);
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
@@ -149,10 +161,10 @@ userlist(int argc, char **argv)
|
||||
fprintf(stderr, "Warning: Can't do local finger\n");
|
||||
}
|
||||
|
||||
/* Start winsock */
|
||||
/* Start winsock */
|
||||
wVersionRequested = MAKEWORD( 1, 1 );
|
||||
iErr = WSAStartup( wVersionRequested, &wsaData );
|
||||
if ( iErr != 0 )
|
||||
if ( iErr != 0 )
|
||||
{
|
||||
/* Tell the user that we couldn't find a usable */
|
||||
/* WinSock DLL. */
|
@@ -42,15 +42,13 @@ static char sccsid[] = "@(#)getopt.c 4.13 (Berkeley) 2/23/91";
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "getopt.h"
|
||||
|
||||
/*
|
||||
* get option letter from argument vector
|
||||
*/
|
||||
int opterr = 1, /* if error message should be printed */
|
||||
optind = 1, /* index into parent argv vector */
|
||||
optopt; /* character checked for validity */
|
||||
const char *optarg; /* argument associated with option */
|
||||
char *optarg; /* argument associated with option */
|
||||
|
||||
#define BADCH (int)'?'
|
||||
#define EMSG ""
|
||||
@@ -58,7 +56,7 @@ const char *optarg; /* argument associated with option */
|
||||
int
|
||||
getopt(int nargc, char * const *nargv, const char *ostr)
|
||||
{
|
||||
static const char *place = EMSG; /* option letter processing */
|
||||
static char *place = EMSG; /* option letter processing */
|
||||
register char *oli; /* option letter list index */
|
||||
char *p;
|
||||
|
7
apps/utils/net/finger/getopt.h
Normal file
7
apps/utils/net/finger/getopt.h
Normal file
@@ -0,0 +1,7 @@
|
||||
/* getopt.h */
|
||||
|
||||
extern char *optarg;
|
||||
extern int optind;
|
||||
|
||||
int
|
||||
getopt(int nargc, char * const *nargv, const char *ostr);
|
24
apps/utils/net/finger/makefile
Normal file
24
apps/utils/net/finger/makefile
Normal file
@@ -0,0 +1,24 @@
|
||||
PATH_TO_TOP = ../../../..
|
||||
|
||||
TARGET_TYPE = program
|
||||
|
||||
TARGET_APPTYPE = console
|
||||
|
||||
TARGET_NAME = finger
|
||||
|
||||
TARGET_SDKLIBS = ws2_32.a
|
||||
|
||||
TARGET_INSTALLDIR = system32
|
||||
|
||||
TARGET_CFLAGS = -D__USE_W32_SOCKETS
|
||||
|
||||
TARGET_OBJECTS = $(TARGET_NAME).o \
|
||||
err.o \
|
||||
getopt.o \
|
||||
net.o
|
||||
|
||||
TARGET_GCCLIBS = iberty
|
||||
|
||||
include $(PATH_TO_TOP)/rules.mak
|
||||
|
||||
include $(TOOLS_PATH)/helper.mk
|
@@ -33,17 +33,20 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static char sccsid[] = "@(#)net.c 8.4 (Berkeley) 4/28/95";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <winsock2.h>
|
||||
|
||||
#include "unistd.h"
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "various.h"
|
||||
|
||||
int close(int);
|
||||
|
||||
void
|
||||
netfinger(char *name)
|
||||
{
|
||||
@@ -53,15 +56,15 @@ netfinger(char *name)
|
||||
struct hostent *hp, def;
|
||||
struct servent *sp;
|
||||
struct sockaddr_in sin;
|
||||
SOCKET s;
|
||||
int s;
|
||||
char *alist[1], *host;
|
||||
|
||||
/* If this is a local request */
|
||||
if (!(host = rindex(name, '@')))
|
||||
return;
|
||||
|
||||
*host++ = '\0';
|
||||
if (isdigit(*host) && (defaddr.s_addr = inet_addr(host)) != (unsigned long)-1) {
|
||||
*host++ = NULL;
|
||||
if (isdigit(*host) && (defaddr.s_addr = inet_addr(host)) != -1) {
|
||||
def.h_name = host;
|
||||
def.h_addr_list = alist;
|
||||
def.h_addr = (char *)&defaddr;
|
||||
@@ -81,7 +84,7 @@ netfinger(char *name)
|
||||
sin.sin_family = hp->h_addrtype;
|
||||
bcopy(hp->h_addr, (char *)&sin.sin_addr, hp->h_length);
|
||||
sin.sin_port = sp->s_port;
|
||||
if ((s = socket(hp->h_addrtype, SOCK_STREAM, 0)) == INVALID_SOCKET) {
|
||||
if ((s = socket(hp->h_addrtype, SOCK_STREAM, 0)) < 0) {
|
||||
perror("finger: socket");
|
||||
return;
|
||||
}
|
||||
@@ -112,7 +115,7 @@ netfinger(char *name)
|
||||
* Otherwise, all high bits are stripped; if it isn't printable and
|
||||
* it isn't a space, we can simply set the 7th bit. Every ASCII
|
||||
* character with bit 7 set is printable.
|
||||
*/
|
||||
*/
|
||||
lastc = 0;
|
||||
while (recv(s, &c, 1, 0) == 1) {
|
||||
c &= 0x7f;
|
@@ -31,6 +31,4 @@ typedef long uid_t; // SunOS 5.5
|
||||
#define index(s, c) strchr(s, c)
|
||||
#define rindex(s, c) strrchr(s, c)
|
||||
|
||||
void netfinger(char *);
|
||||
|
||||
#endif
|
@@ -25,7 +25,7 @@ static char sccsid[] = "@(#)cmds.c 5.18 (Berkeley) 4/20/89";
|
||||
//#include <sys/param.h>
|
||||
//#include <sys/wait.h>
|
||||
#include <sys/stat.h>
|
||||
#ifndef _WIN32
|
||||
#if !defined(WIN32)
|
||||
#include <sys/socket.h>
|
||||
#include <arpa/ftp.h>
|
||||
#include <netinet/in.h>
|
||||
@@ -46,6 +46,7 @@ static char sccsid[] = "@(#)cmds.c 5.18 (Berkeley) 4/20/89";
|
||||
#include "prototypes.h"
|
||||
|
||||
extern char *globerr;
|
||||
extern char **glob();
|
||||
extern char home[];
|
||||
extern char *remglob();
|
||||
extern char *getenv();
|
||||
@@ -53,9 +54,9 @@ extern int allbinary;
|
||||
extern off_t restart_point;
|
||||
extern char reply_string[];
|
||||
|
||||
const char *mname;
|
||||
char *mname;
|
||||
jmp_buf jabort;
|
||||
const char *dotrans(), *domap();
|
||||
char *dotrans(), *domap();
|
||||
|
||||
extern short portnum;
|
||||
extern char *hostname;
|
||||
@@ -64,9 +65,9 @@ extern int autologin;
|
||||
* Connect to peer server and
|
||||
* auto-login, if possible.
|
||||
*/
|
||||
void setpeer(int argc, const char *argv[])
|
||||
void setpeer(int argc, char *argv[])
|
||||
{
|
||||
char *host;
|
||||
char *host, *hookup();
|
||||
|
||||
if (connected) {
|
||||
printf("Already connected to %s, use close first.\n",
|
||||
@@ -154,8 +155,8 @@ void setpeer(int argc, const char *argv[])
|
||||
}
|
||||
|
||||
struct types {
|
||||
const char *t_name;
|
||||
const char *t_mode;
|
||||
char *t_name;
|
||||
char *t_mode;
|
||||
int t_type;
|
||||
char *t_arg;
|
||||
} types[] = {
|
||||
@@ -164,20 +165,20 @@ struct types {
|
||||
{ "image", "I", TYPE_I, 0 },
|
||||
{ "ebcdic", "E", TYPE_E, 0 },
|
||||
{ "tenex", "L", TYPE_L, bytename },
|
||||
{0 }
|
||||
0
|
||||
};
|
||||
|
||||
/*
|
||||
* Set transfer type.
|
||||
*/
|
||||
void settype(argc, argv)
|
||||
const char *argv[];
|
||||
char *argv[];
|
||||
{
|
||||
register struct types *p;
|
||||
int comret;
|
||||
|
||||
if (argc > 2) {
|
||||
const char *sep;
|
||||
char *sep;
|
||||
|
||||
printf("usage: %s [", argv[0]);
|
||||
sep = " ";
|
||||
@@ -216,7 +217,7 @@ void settype(argc, argv)
|
||||
}
|
||||
}
|
||||
|
||||
const char *stype[] = {
|
||||
char *stype[] = {
|
||||
"type",
|
||||
"",
|
||||
0
|
||||
@@ -265,9 +266,9 @@ void setebcdic()
|
||||
/*
|
||||
* Set file transfer mode.
|
||||
*/
|
||||
|
||||
#if 0
|
||||
/*ARGSUSED*/
|
||||
void fsetmode(argc, argv)
|
||||
void setmode(argc, argv)
|
||||
char *argv[];
|
||||
{
|
||||
|
||||
@@ -275,7 +276,7 @@ void fsetmode(argc, argv)
|
||||
(void) fflush(stdout);
|
||||
code = -1;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Set file transfer format.
|
||||
@@ -308,11 +309,11 @@ void setstruct(argc, argv)
|
||||
*/
|
||||
void put(argc, argv)
|
||||
int argc;
|
||||
const char *argv[];
|
||||
char *argv[];
|
||||
{
|
||||
const char *cmd;
|
||||
char *cmd;
|
||||
int loc = 0;
|
||||
const char *oldargv1, *oldargv2;
|
||||
char *oldargv1, *oldargv2;
|
||||
|
||||
if (argc == 2) {
|
||||
argc++;
|
||||
@@ -374,12 +375,13 @@ usage:
|
||||
* Send multiple files.
|
||||
*/
|
||||
void mput(argc, argv)
|
||||
const char *argv[];
|
||||
char *argv[];
|
||||
{
|
||||
register int i;
|
||||
int ointer;
|
||||
void mabort();
|
||||
extern jmp_buf jabort;
|
||||
const char *tp;
|
||||
char *tp;
|
||||
|
||||
if (argc < 2) {
|
||||
(void) strcat(line, " ");
|
||||
@@ -505,13 +507,13 @@ void mput(argc, argv)
|
||||
}
|
||||
|
||||
void reget(argc, argv)
|
||||
const char *argv[];
|
||||
char *argv[];
|
||||
{
|
||||
(void) getit(argc, argv, 1, "r+w");
|
||||
}
|
||||
|
||||
void get(argc, argv)
|
||||
const char *argv[];
|
||||
char *argv[];
|
||||
{
|
||||
(void) getit(argc, argv, 0, restart_point ? "r+w" : "w" );
|
||||
}
|
||||
@@ -520,11 +522,11 @@ void get(argc, argv)
|
||||
* Receive one file.
|
||||
*/
|
||||
int getit(argc, argv, restartit, mode)
|
||||
const char *argv[];
|
||||
const char *mode;
|
||||
char *argv[];
|
||||
char *mode;
|
||||
{
|
||||
int loc = 0;
|
||||
const char *oldargv1, *oldargv2;
|
||||
char *oldargv1, *oldargv2;
|
||||
|
||||
if (argc == 2) {
|
||||
argc++;
|
||||
@@ -565,8 +567,7 @@ usage:
|
||||
return (0);
|
||||
}
|
||||
if (loc && mcase) {
|
||||
const char *tp = argv[1];
|
||||
char *tp2, tmpbuf[MAXPATHLEN];
|
||||
char *tp = argv[1], *tp2, tmpbuf[MAXPATHLEN];
|
||||
|
||||
while (*tp && !islower(*tp)) {
|
||||
tp++;
|
||||
@@ -649,8 +650,7 @@ usage:
|
||||
return (0);
|
||||
}
|
||||
|
||||
#if 0
|
||||
static void
|
||||
void
|
||||
mabort()
|
||||
{
|
||||
int ointer;
|
||||
@@ -670,17 +670,16 @@ mabort()
|
||||
mflag = 0;
|
||||
longjmp(jabort,0);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Get multiple files.
|
||||
*/
|
||||
void mget(argc, argv)
|
||||
const char *argv[];
|
||||
char *argv[];
|
||||
{
|
||||
const char *cp, *tp;
|
||||
char *tp2, tmpbuf[MAXPATHLEN];
|
||||
char *cp, *tp, *tp2, tmpbuf[MAXPATHLEN];
|
||||
int ointer;
|
||||
void mabort();
|
||||
extern jmp_buf jabort;
|
||||
|
||||
if (argc < 2) {
|
||||
@@ -758,8 +757,7 @@ remglob(argv,doswitch)
|
||||
static FILE *ftemp = NULL;
|
||||
static char **args;
|
||||
int oldverbose, oldhash;
|
||||
char *cp;
|
||||
const char *mode;
|
||||
char *cp, *mode;
|
||||
|
||||
if (!mflag) {
|
||||
if (!doglob) {
|
||||
@@ -811,7 +809,7 @@ remglob(argv,doswitch)
|
||||
return (buf);
|
||||
}
|
||||
|
||||
static const char *
|
||||
char *
|
||||
onoff(bool)
|
||||
int bool;
|
||||
{
|
||||
@@ -1005,7 +1003,7 @@ void setdebug(argc, argv)
|
||||
* on remote machine.
|
||||
*/
|
||||
void cd(argc, argv)
|
||||
const char *argv[];
|
||||
char *argv[];
|
||||
{
|
||||
|
||||
if (argc < 2) {
|
||||
@@ -1037,7 +1035,7 @@ void cd(argc, argv)
|
||||
* on local machine.
|
||||
*/
|
||||
void lcd(argc, argv)
|
||||
const char *argv[];
|
||||
char *argv[];
|
||||
{
|
||||
char buf[MAXPATHLEN];
|
||||
|
||||
@@ -1067,7 +1065,7 @@ void lcd(argc, argv)
|
||||
* Delete a single file.
|
||||
*/
|
||||
void delete(argc, argv)
|
||||
const char *argv[];
|
||||
char *argv[];
|
||||
{
|
||||
|
||||
if (argc < 2) {
|
||||
@@ -1092,10 +1090,11 @@ void delete(argc, argv)
|
||||
* Delete multiple files.
|
||||
*/
|
||||
void mdelete(argc, argv)
|
||||
const char *argv[];
|
||||
char *argv[];
|
||||
{
|
||||
char *cp;
|
||||
int ointer;
|
||||
void mabort();
|
||||
extern jmp_buf jabort;
|
||||
|
||||
if (argc < 2) {
|
||||
@@ -1142,7 +1141,7 @@ void mdelete(argc, argv)
|
||||
* Rename a remote file.
|
||||
*/
|
||||
void renamefile(argc, argv)
|
||||
const char *argv[];
|
||||
char *argv[];
|
||||
{
|
||||
|
||||
if (argc < 2) {
|
||||
@@ -1181,9 +1180,9 @@ usage:
|
||||
* of remote files.
|
||||
*/
|
||||
void ls(argc, argv)
|
||||
const char *argv[];
|
||||
char *argv[];
|
||||
{
|
||||
const char *cmd;
|
||||
char *cmd;
|
||||
|
||||
if (argc < 2)
|
||||
argc++, argv[1] = NULL;
|
||||
@@ -1214,11 +1213,11 @@ void ls(argc, argv)
|
||||
* of multiple remote files.
|
||||
*/
|
||||
void mls(argc, argv)
|
||||
const char *argv[];
|
||||
char *argv[];
|
||||
{
|
||||
const char *cmd, *dest;
|
||||
char mode[1];
|
||||
char *cmd, mode[1], *dest;
|
||||
int ointer, i;
|
||||
void mabort();
|
||||
extern jmp_buf jabort;
|
||||
|
||||
if (argc < 2) {
|
||||
@@ -1277,7 +1276,7 @@ void mls(argc, argv)
|
||||
* Do a shell escape
|
||||
*/
|
||||
/*ARGSUSED*/
|
||||
void shell(argc, argv)
|
||||
shell(argc, argv)
|
||||
char *argv[];
|
||||
{
|
||||
#if 0
|
||||
@@ -1345,7 +1344,7 @@ void shell(argc, argv)
|
||||
|
||||
if (NumBytes == 0)
|
||||
{
|
||||
return;
|
||||
return(-1);
|
||||
}
|
||||
|
||||
AppName = ShellCmd;
|
||||
@@ -1392,14 +1391,23 @@ void shell(argc, argv)
|
||||
|
||||
CloseHandle( ProcessInformation.hProcess);
|
||||
}
|
||||
|
||||
if (Result)
|
||||
{
|
||||
return(-1);
|
||||
}
|
||||
else
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Send new user information (re-login)
|
||||
*/
|
||||
void user(argc, argv)
|
||||
user(argc, argv)
|
||||
int argc;
|
||||
const char **argv;
|
||||
char **argv;
|
||||
{
|
||||
char acct[80], *getpass();
|
||||
int n, aflag = 0;
|
||||
@@ -1417,7 +1425,7 @@ void user(argc, argv)
|
||||
printf("usage: %s username [password] [account]\n", argv[0]);
|
||||
(void) fflush(stdout);
|
||||
code = -1;
|
||||
return;
|
||||
return (0);
|
||||
}
|
||||
n = command("USER %s", argv[1]);
|
||||
if (n == CONTINUE) {
|
||||
@@ -1439,11 +1447,12 @@ void user(argc, argv)
|
||||
if (n != COMPLETE) {
|
||||
fprintf(stdout, "Login failed.\n");
|
||||
(void) fflush(stdout);
|
||||
return;
|
||||
return (0);
|
||||
}
|
||||
if (!aflag && argc == 4) {
|
||||
(void) command("ACCT %s", argv[3]);
|
||||
}
|
||||
return (1);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1470,7 +1479,7 @@ void pwd()
|
||||
* Make a directory.
|
||||
*/
|
||||
void makedir(argc, argv)
|
||||
const char *argv[];
|
||||
char *argv[];
|
||||
{
|
||||
|
||||
if (argc < 2) {
|
||||
@@ -1501,7 +1510,7 @@ void makedir(argc, argv)
|
||||
* Remove a directory.
|
||||
*/
|
||||
void removedir(argc, argv)
|
||||
const char *argv[];
|
||||
char *argv[];
|
||||
{
|
||||
|
||||
if (argc < 2) {
|
||||
@@ -1532,7 +1541,7 @@ void removedir(argc, argv)
|
||||
* Send a line, verbatim, to the remote machine.
|
||||
*/
|
||||
void quote(argc, argv)
|
||||
const char *argv[];
|
||||
char *argv[];
|
||||
{
|
||||
int i;
|
||||
char buf[BUFSIZ];
|
||||
@@ -1569,7 +1578,7 @@ void quote(argc, argv)
|
||||
*/
|
||||
|
||||
void site(argc, argv)
|
||||
const char *argv[];
|
||||
char *argv[];
|
||||
{
|
||||
int i;
|
||||
char buf[BUFSIZ];
|
||||
@@ -1601,7 +1610,7 @@ void site(argc, argv)
|
||||
}
|
||||
|
||||
void do_chmod(argc, argv)
|
||||
const char *argv[];
|
||||
char *argv[];
|
||||
{
|
||||
if (argc == 2) {
|
||||
printf("usage: %s mode file-name\n", argv[0]);
|
||||
@@ -1695,8 +1704,8 @@ void disconnect()
|
||||
}
|
||||
}
|
||||
|
||||
int confirm(cmd, file)
|
||||
const char *cmd, *file;
|
||||
confirm(cmd, file)
|
||||
char *cmd, *file;
|
||||
{
|
||||
char line[BUFSIZ];
|
||||
|
||||
@@ -1708,15 +1717,13 @@ int confirm(cmd, file)
|
||||
return (*line != 'n' && *line != 'N');
|
||||
}
|
||||
|
||||
#if 0
|
||||
static void fatal(msg)
|
||||
void fatal(msg)
|
||||
char *msg;
|
||||
{
|
||||
|
||||
fprintf(stderr, "ftp: %s\n", msg);
|
||||
exit(1);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Glob a local file name specification with
|
||||
@@ -1724,8 +1731,8 @@ static void fatal(msg)
|
||||
* Can't control multiple values being expanded
|
||||
* from the expression, we return only the first.
|
||||
*/
|
||||
int globulize(cpp)
|
||||
const char **cpp;
|
||||
globulize(cpp)
|
||||
char **cpp;
|
||||
{
|
||||
char **globbed;
|
||||
|
||||
@@ -1778,8 +1785,7 @@ void account(argc,argv)
|
||||
|
||||
jmp_buf abortprox;
|
||||
|
||||
#if 0
|
||||
static void
|
||||
void
|
||||
proxabort()
|
||||
{
|
||||
extern int proxy;
|
||||
@@ -1796,15 +1802,15 @@ proxabort()
|
||||
pswitch(0);
|
||||
longjmp(abortprox,1);
|
||||
}
|
||||
#endif
|
||||
|
||||
void doproxy(argc,argv)
|
||||
int argc;
|
||||
const char *argv[];
|
||||
char *argv[];
|
||||
{
|
||||
void proxabort();
|
||||
register struct cmd *c;
|
||||
struct cmd *getcmd();
|
||||
// extern struct cmd cmdtab[];
|
||||
extern struct cmd cmdtab[];
|
||||
extern jmp_buf abortprox;
|
||||
|
||||
if (argc < 2) {
|
||||
@@ -1905,13 +1911,12 @@ void setntrans(argc,argv)
|
||||
ntout[16] = '\0';
|
||||
}
|
||||
|
||||
const char *
|
||||
char *
|
||||
dotrans(name)
|
||||
const char *name;
|
||||
char *name;
|
||||
{
|
||||
static char new[MAXPATHLEN];
|
||||
const char *cp1;
|
||||
char *cp2 = new;
|
||||
char *cp1, *cp2 = new;
|
||||
register int i, ostop, found;
|
||||
|
||||
for (ostop = 0; *(ntout + ostop) && ostop < 16; ostop++);
|
||||
@@ -1948,7 +1953,7 @@ setpassive(argc, argv)
|
||||
|
||||
void setnmap(argc, argv)
|
||||
int argc;
|
||||
const char *argv[];
|
||||
char *argv[];
|
||||
{
|
||||
char *cp;
|
||||
|
||||
@@ -1988,14 +1993,13 @@ void setnmap(argc, argv)
|
||||
(void) strncpy(mapout, cp, MAXPATHLEN - 1);
|
||||
}
|
||||
|
||||
const char *
|
||||
char *
|
||||
domap(name)
|
||||
const char *name;
|
||||
char *name;
|
||||
{
|
||||
static char new[MAXPATHLEN];
|
||||
const char *cp1 = name;
|
||||
char *cpn, *cp2 = mapin;
|
||||
const char *tp[9], *te[9];
|
||||
register char *cp1 = name, *cp2 = mapin;
|
||||
char *tp[9], *te[9];
|
||||
int i, toks[9], toknum = 0, match = 1;
|
||||
|
||||
for (i=0; i < 9; ++i) {
|
||||
@@ -2038,34 +2042,33 @@ domap(name)
|
||||
{
|
||||
toks[toknum] = 0;
|
||||
}
|
||||
|
||||
cpn = new;
|
||||
*cpn = '\0';
|
||||
cp1 = new;
|
||||
*cp1 = '\0';
|
||||
cp2 = mapout;
|
||||
while (*cp2) {
|
||||
match = 0;
|
||||
switch (*cp2) {
|
||||
case '\\':
|
||||
if (*(cp2 + 1)) {
|
||||
*cpn++ = *++cp2;
|
||||
*cp1++ = *++cp2;
|
||||
}
|
||||
break;
|
||||
case '[':
|
||||
LOOP:
|
||||
if (*++cp2 == '$' && isdigit(*(cp2+1))) {
|
||||
if (*++cp2 == '0') {
|
||||
const char *cp3 = name;
|
||||
char *cp3 = name;
|
||||
|
||||
while (*cp3) {
|
||||
*cpn++ = *cp3++;
|
||||
*cp1++ = *cp3++;
|
||||
}
|
||||
match = 1;
|
||||
}
|
||||
else if (toks[toknum = *cp2 - '1']) {
|
||||
const char *cp3 = tp[toknum];
|
||||
char *cp3 = tp[toknum];
|
||||
|
||||
while (cp3 != te[toknum]) {
|
||||
*cpn++ = *cp3++;
|
||||
*cp1++ = *cp3++;
|
||||
}
|
||||
match = 1;
|
||||
}
|
||||
@@ -2079,24 +2082,24 @@ LOOP:
|
||||
else if (*cp2 == '$' &&
|
||||
isdigit(*(cp2+1))) {
|
||||
if (*++cp2 == '0') {
|
||||
const char *cp3 = name;
|
||||
char *cp3 = name;
|
||||
|
||||
while (*cp3) {
|
||||
*cpn++ = *cp3++;
|
||||
*cp1++ = *cp3++;
|
||||
}
|
||||
}
|
||||
else if (toks[toknum =
|
||||
*cp2 - '1']) {
|
||||
const char *cp3=tp[toknum];
|
||||
char *cp3=tp[toknum];
|
||||
|
||||
while (cp3 !=
|
||||
te[toknum]) {
|
||||
*cpn++ = *cp3++;
|
||||
*cp1++ = *cp3++;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (*cp2) {
|
||||
*cpn++ = *cp2++;
|
||||
*cp1++ = *cp2++;
|
||||
}
|
||||
}
|
||||
if (!*cp2) {
|
||||
@@ -2133,29 +2136,29 @@ LOOP:
|
||||
case '$':
|
||||
if (isdigit(*(cp2 + 1))) {
|
||||
if (*++cp2 == '0') {
|
||||
const char *cp3 = name;
|
||||
char *cp3 = name;
|
||||
|
||||
while (*cp3) {
|
||||
*cpn++ = *cp3++;
|
||||
*cp1++ = *cp3++;
|
||||
}
|
||||
}
|
||||
else if (toks[toknum = *cp2 - '1']) {
|
||||
const char *cp3 = tp[toknum];
|
||||
char *cp3 = tp[toknum];
|
||||
|
||||
while (cp3 != te[toknum]) {
|
||||
*cpn++ = *cp3++;
|
||||
*cp1++ = *cp3++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
/* intentional drop through */
|
||||
default:
|
||||
*cpn++ = *cp2;
|
||||
*cp1++ = *cp2;
|
||||
break;
|
||||
}
|
||||
cp2++;
|
||||
}
|
||||
*cpn = '\0';
|
||||
*cp1 = '\0';
|
||||
if (!*new) {
|
||||
return(name);
|
||||
}
|
||||
@@ -2214,7 +2217,7 @@ void syst()
|
||||
|
||||
void macdef(argc, argv)
|
||||
int argc;
|
||||
const char *argv[];
|
||||
char *argv[];
|
||||
{
|
||||
char *tmp;
|
||||
int c;
|
||||
@@ -2290,7 +2293,7 @@ void macdef(argc, argv)
|
||||
* get size of file on remote machine
|
||||
*/
|
||||
void sizecmd(argc, argv)
|
||||
const char *argv[];
|
||||
char *argv[];
|
||||
{
|
||||
|
||||
if (argc < 2) {
|
||||
@@ -2315,7 +2318,7 @@ void sizecmd(argc, argv)
|
||||
* get last modification time of file on remote machine
|
||||
*/
|
||||
void modtime(argc, argv)
|
||||
const char *argv[];
|
||||
char *argv[];
|
||||
{
|
||||
int overbose;
|
||||
|
||||
@@ -2354,7 +2357,7 @@ void modtime(argc, argv)
|
||||
* show status on reomte machine
|
||||
*/
|
||||
void rmtstatus(argc, argv)
|
||||
const char *argv[];
|
||||
char *argv[];
|
||||
{
|
||||
(void) command(argc > 1 ? "STAT %s" : "STAT" , argv[1]);
|
||||
}
|
||||
@@ -2363,7 +2366,7 @@ void rmtstatus(argc, argv)
|
||||
* get file if modtime is more recent than current file
|
||||
*/
|
||||
void newer(argc, argv)
|
||||
const char *argv[];
|
||||
char *argv[];
|
||||
{
|
||||
if (getit(argc, argv, -1, "w")) {
|
||||
printf("Local file \"%s\" is newer than remote file \"%s\"\n",
|
@@ -24,6 +24,20 @@ static char sccsid[] = "@(#)cmdtab.c 5.9 (Berkeley) 3/21/89";
|
||||
/*
|
||||
* User FTP -- Command Tables.
|
||||
*/
|
||||
int setascii(), setbell(), setbinary(), setdebug(), setform();
|
||||
int setglob(), sethash(), setmode(), setpeer(), setpassive(), setport();
|
||||
int setprompt(), setstruct();
|
||||
int settenex(), settrace(), settype(), setverbose();
|
||||
int disconnect(), restart(), reget(), syst();
|
||||
int cd(), lcd(), delete(), mdelete(), user();
|
||||
int ls(), mls(), get(), mget(), help(), append(), put(), mput();
|
||||
int quit(), renamefile(), status();
|
||||
int quote(), rmthelp(), shell(), site();
|
||||
int pwd(), makedir(), removedir(), setcr();
|
||||
int account(), doproxy(), reset(), setcase(), setntrans(), setnmap();
|
||||
int setsunique(), setrunique(), cdup(), macdef(), domacro();
|
||||
int sizecmd(), modtime(), newer(), rmtstatus();
|
||||
int do_chmod(), do_umask(), idle();
|
||||
|
||||
char accounthelp[] = "send account command to remote server";
|
||||
char appendhelp[] = "append to a file";
|
||||
@@ -126,7 +140,7 @@ struct cmd cmdtab[] = {
|
||||
{ "mget", mgethelp, 1, 1, 1, mget },
|
||||
{ "mkdir", mkdirhelp, 0, 1, 1, makedir },
|
||||
{ "mls", mlshelp, 1, 1, 1, mls },
|
||||
{ "mode", modehelp, 0, 1, 1, fsetmode },
|
||||
{ "mode", modehelp, 0, 1, 1, setmode },
|
||||
{ "modtime", modtimehelp, 0, 1, 1, modtime },
|
||||
{ "mput", mputhelp, 1, 1, 1, mput },
|
||||
{ "newer", newerhelp, 1, 1, 1, newer },
|
@@ -30,14 +30,15 @@ static char sccsid[] = "@(#)domacro.c 1.6 (Berkeley) 2/28/89";
|
||||
|
||||
void domacro(argc, argv)
|
||||
int argc;
|
||||
const char *argv[];
|
||||
char *argv[];
|
||||
{
|
||||
int i, j;
|
||||
const char *cp1;
|
||||
char *cp2;
|
||||
register int i, j;
|
||||
register char *cp1, *cp2;
|
||||
int count = 2, loopflg = 0;
|
||||
char line2[200];
|
||||
extern char **glob(), *globerr;
|
||||
struct cmd *getcmd(), *c;
|
||||
extern struct cmd cmdtab[];
|
||||
|
||||
if (argc < 2) {
|
||||
(void) strcat(line, " ");
|
@@ -1,7 +1,6 @@
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include <winsock.h>
|
||||
#include "fake.h"
|
||||
#include "prototypes.h"
|
||||
|
||||
#define MAX_ASCII 100
|
||||
@@ -35,11 +34,12 @@ void blkfree(char **av0)
|
||||
free(*av++);
|
||||
}
|
||||
|
||||
char **glob(register char *v)
|
||||
char *glob(register char *v)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
int sleep(int time)
|
||||
{
|
||||
return time;
|
||||
@@ -49,8 +49,8 @@ int herror(char *string)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
||||
int gettimeofday(struct timeval *timenow,
|
||||
struct timezone *zone)
|
||||
{
|
||||
@@ -92,14 +92,14 @@ int fgetcSocket(int s)
|
||||
{
|
||||
static int index = 0;
|
||||
static int total = 0;
|
||||
static char buffer[4096];
|
||||
static unsigned char buffer[4096];
|
||||
|
||||
if (index == total)
|
||||
{
|
||||
index = 0;
|
||||
total = recv(s, buffer, sizeof(buffer), 0);
|
||||
|
||||
if (total == SOCKET_ERROR)
|
||||
if (total == INVALID_SOCKET)
|
||||
{
|
||||
total = 0;
|
||||
return ERROR;
|
||||
@@ -113,7 +113,7 @@ int fgetcSocket(int s)
|
||||
|
||||
#endif
|
||||
|
||||
const char *fprintfSocket(int s, const char *format, ...)
|
||||
char *fprintfSocket(int s, char *format, ...)
|
||||
{
|
||||
va_list argptr;
|
||||
char buffer[10009];
|
||||
@@ -127,7 +127,7 @@ const char *fprintfSocket(int s, const char *format, ...)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char *fputsSocket(const char *format, int s)
|
||||
char *fputsSocket(char *format, int s)
|
||||
{
|
||||
send(s, format, strlen(format), 0);
|
||||
|
||||
@@ -142,7 +142,7 @@ int fputcSocket(int s, char putChar)
|
||||
buffer[1] = '\0';
|
||||
|
||||
if(SOCKET_ERROR==send(s, buffer, 1, 0)) {
|
||||
int iret=WSAGetLastError ();
|
||||
int iret=WSAGetLastError ();
|
||||
fprintf(stdout,"fputcSocket: %d\n",iret);
|
||||
return 0;
|
||||
}
|
||||
@@ -154,9 +154,9 @@ int fputSocket(int s, char *buffer, int len)
|
||||
{
|
||||
int iret;
|
||||
while(len) {
|
||||
if(SOCKET_ERROR==(iret=send(s, buffer, len, 0)))
|
||||
if(SOCKET_ERROR==(iret=send(s, buffer, len, 0)))
|
||||
{
|
||||
iret=WSAGetLastError ();
|
||||
iret=WSAGetLastError ();
|
||||
fprintf(stdout,"fputcSocket: %d\n",iret);
|
||||
return 0;
|
||||
}
|
||||
@@ -187,7 +187,7 @@ char *fgetsSocket(int s, char *string)
|
||||
if (count == 1)
|
||||
{
|
||||
string[i] = buffer[0];
|
||||
|
||||
|
||||
if (i == MAX_ASCII - 3)
|
||||
{
|
||||
count = 0;
|
||||
@@ -235,7 +235,7 @@ char *getpass (const char * prompt)
|
||||
static char input[256];
|
||||
HANDLE in;
|
||||
HANDLE err;
|
||||
DWORD count;
|
||||
int count;
|
||||
|
||||
in = GetStdHandle (STD_INPUT_HANDLE);
|
||||
err = GetStdHandle (STD_ERROR_HANDLE);
|
||||
@@ -293,13 +293,11 @@ char *getpass (const char * prompt)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#if 0
|
||||
// Stubbed out here. Should be changed in Source code...
|
||||
int access(const char *filename, int accessmethod)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef __GNUC__
|
||||
#define EPOCHFILETIME (116444736000000000i64)
|
||||
@@ -307,7 +305,12 @@ int access(const char *filename, int accessmethod)
|
||||
#define EPOCHFILETIME (116444736000000000LL)
|
||||
#endif
|
||||
|
||||
int gettimeofday(struct timeval *tv, struct timezone *tz)
|
||||
struct timezone {
|
||||
int tz_minuteswest; /* minutes W of Greenwich */
|
||||
int tz_dsttime; /* type of dst correction */
|
||||
};
|
||||
|
||||
__inline int gettimeofday(struct timeval *tv, struct timezone *tz)
|
||||
{
|
||||
FILETIME ft;
|
||||
LARGE_INTEGER li;
|
||||
@@ -317,8 +320,8 @@ int gettimeofday(struct timeval *tv, struct timezone *tz)
|
||||
if (tv)
|
||||
{
|
||||
GetSystemTimeAsFileTime(&ft);
|
||||
li.LowPart = ft.dwLowDateTime;
|
||||
li.HighPart = ft.dwHighDateTime;
|
||||
//li.LowPart = ft.dwLowDateTime;
|
||||
//li.HighPart = ft.dwHighDateTime;
|
||||
t = li.QuadPart; /* In 100-nanosecond intervals */
|
||||
t -= EPOCHFILETIME; /* Offset to the Epoch time */
|
||||
t /= 10; /* In microseconds */
|
10
apps/utils/net/ftp/fake.h
Normal file
10
apps/utils/net/ftp/fake.h
Normal file
@@ -0,0 +1,10 @@
|
||||
#define bcopy(s,d,l) memcpy((d),(s),(l))
|
||||
#define bzero(cp,l) memset((cp),0,(l))
|
||||
|
||||
#define rindex strrchr
|
||||
#define index strchr
|
||||
|
||||
#define getwd getcwd
|
||||
|
||||
#define strcasecmp strcmp
|
||||
#define strncasecmp strnicmp
|
1805
apps/utils/net/ftp/ftp.c
Normal file
1805
apps/utils/net/ftp/ftp.c
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,10 +1,18 @@
|
||||
#include <winsock.h>
|
||||
#include "fake.h"
|
||||
#include "prototypes.h"
|
||||
#include <winsock.h>
|
||||
#include <setjmp.h>
|
||||
|
||||
//typedef void (*Sig_t)(int);
|
||||
|
||||
int fgetcSocket(int s);
|
||||
char *fputsSocket(char *format, int s);
|
||||
|
||||
char *fprintfSocket(int s, char *format, ...);
|
||||
|
||||
int fputcSocket(int s, char putChar);
|
||||
int fputSocket(int s, char *putChar, int len);
|
||||
char *fgetsSocket(int s, char *string);
|
||||
|
||||
/* The following defines are from ftp.h and telnet.h from bsd.h */
|
||||
/* All relevent copyrights below apply. */
|
||||
|
||||
@@ -130,7 +138,7 @@ extern char *stringbase; /* current scan point in line buffer */
|
||||
extern char argbuf[200]; /* argument storage buffer */
|
||||
extern char *argbase; /* current storage point in arg buffer */
|
||||
extern int margc; /* count of arguments on input line */
|
||||
extern const char *margv[20]; /* args parsed from input line */
|
||||
extern char *margv[20]; /* args parsed from input line */
|
||||
extern int cpend; /* flag: if != 0, then pending server reply */
|
||||
extern int mflag; /* flag: if != 0, then active multi command */
|
||||
|
||||
@@ -140,12 +148,12 @@ extern int options; /* used during socket creation */
|
||||
* Format of command table.
|
||||
*/
|
||||
struct cmd {
|
||||
const char *c_name; /* name of command */
|
||||
const char *c_help; /* help string */
|
||||
char *c_name; /* name of command */
|
||||
char *c_help; /* help string */
|
||||
char c_bell; /* give bell when command completes */
|
||||
char c_conn; /* must be connected to use command */
|
||||
char c_proxy; /* proxy server may execute */
|
||||
void (*c_handler)(); /* function to call */
|
||||
int (*c_handler)(); /* function to call */
|
||||
};
|
||||
|
||||
struct macel {
|
||||
@@ -158,6 +166,11 @@ int macnum; /* number of defined macros */
|
||||
struct macel macros[16];
|
||||
char macbuf[4096];
|
||||
|
||||
extern char *tail();
|
||||
extern char *remglob();
|
||||
extern int errno;
|
||||
extern char *mktemp();
|
||||
|
||||
#if defined(__ANSI__) || defined(sparc)
|
||||
typedef void sig_t;
|
||||
#else
|
||||
@@ -165,4 +178,4 @@ typedef int sig_t;
|
||||
#endif
|
||||
|
||||
typedef int uid_t;
|
||||
|
||||
int herror(char *s);
|
602
apps/utils/net/ftp/main.c
Normal file
602
apps/utils/net/ftp/main.c
Normal file
@@ -0,0 +1,602 @@
|
||||
/*
|
||||
* Copyright (c) 1985, 1989 Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms are permitted
|
||||
* provided that the above copyright notice and this paragraph are
|
||||
* duplicated in all such forms and that any documentation,
|
||||
* advertising materials, and other materials related to such
|
||||
* distribution and use acknowledge that the software was developed
|
||||
* by the University of California, Berkeley. The name of the
|
||||
* University may not be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
char copyright[] =
|
||||
"@(#) Copyright (c) 1985, 1989 Regents of the University of California.\n\
|
||||
All rights reserved.\n";
|
||||
#endif /* not lint */
|
||||
|
||||
#ifndef lint
|
||||
static char sccsid[] = "@(#)main.c based on 5.13 (Berkeley) 3/14/89";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
* FTP User Program -- Command Interface.
|
||||
*/
|
||||
#if !defined(WIN32)
|
||||
#include <netdb.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <arpa/ftp.h>
|
||||
#include <errno.h>
|
||||
#include <pwd.h>
|
||||
#endif
|
||||
#include "ftp_var.h"
|
||||
#include "prototypes.h"
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <io.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
|
||||
|
||||
#if defined(sun) && !defined(FD_SET)
|
||||
typedef int uid_t;
|
||||
#endif
|
||||
|
||||
uid_t getuid();
|
||||
void intr();
|
||||
void lostpeer();
|
||||
char *getlogin();
|
||||
|
||||
short portnum;
|
||||
|
||||
char home[128];
|
||||
char *globerr;
|
||||
int autologin;
|
||||
|
||||
|
||||
|
||||
/* Lot's of options... */
|
||||
/*
|
||||
* Options and other state info.
|
||||
*/
|
||||
int trace; /* trace packets exchanged */
|
||||
int hash; /* print # for each buffer transferred */
|
||||
int sendport; /* use PORT cmd for each data connection */
|
||||
int verbose; /* print messages coming back from server */
|
||||
int connected; /* connected to server */
|
||||
int fromatty; /* input is from a terminal */
|
||||
int interactive; /* interactively prompt on m* cmds */
|
||||
int debug; /* debugging level */
|
||||
int bell; /* ring bell on cmd completion */
|
||||
int doglob; /* glob local file names */
|
||||
int proxy; /* proxy server connection active */
|
||||
int passivemode;
|
||||
int proxflag; /* proxy connection exists */
|
||||
int sunique; /* store files on server with unique name */
|
||||
int runique; /* store local files with unique name */
|
||||
int mcase; /* map upper to lower case for mget names */
|
||||
int ntflag; /* use ntin ntout tables for name translation */
|
||||
int mapflag; /* use mapin mapout templates on file names */
|
||||
int code; /* return/reply code for ftp command */
|
||||
int crflag; /* if 1, strip car. rets. on ascii gets */
|
||||
char pasv[64]; /* passive port for proxy data connection */
|
||||
char *altarg; /* argv[1] with no shell-like preprocessing */
|
||||
char ntin[17]; /* input translation table */
|
||||
char ntout[17]; /* output translation table */
|
||||
// #include <sys/param.h>
|
||||
char mapin[MAXPATHLEN]; /* input map template */
|
||||
char mapout[MAXPATHLEN]; /* output map template */
|
||||
char typename[32]; /* name of file transfer type */
|
||||
int type; /* file transfer type */
|
||||
char structname[32]; /* name of file transfer structure */
|
||||
int stru; /* file transfer structure */
|
||||
char formname[32]; /* name of file transfer format */
|
||||
int form; /* file transfer format */
|
||||
char modename[32]; /* name of file transfer mode */
|
||||
int mode; /* file transfer mode */
|
||||
char bytename[32]; /* local byte size in ascii */
|
||||
int bytesize; /* local byte size in binary */
|
||||
|
||||
jmp_buf toplevel; /* non-local goto stuff for cmd scanner */
|
||||
|
||||
char line[200]; /* input line buffer */
|
||||
char *stringbase; /* current scan point in line buffer */
|
||||
char argbuf[200]; /* argument storage buffer */
|
||||
char *argbase; /* current storage point in arg buffer */
|
||||
int margc; /* count of arguments on input line */
|
||||
char *margv[20]; /* args parsed from input line */
|
||||
int cpend; /* flag: if != 0, then pending server reply */
|
||||
int mflag; /* flag: if != 0, then active multi command */
|
||||
|
||||
int options; /* used during socket creation */
|
||||
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
register char *cp;
|
||||
int top;
|
||||
struct passwd *pw = NULL;
|
||||
#if 0
|
||||
char homedir[MAXPATHLEN];
|
||||
#endif
|
||||
|
||||
int err;
|
||||
WORD wVerReq;
|
||||
|
||||
WSADATA WSAData;
|
||||
struct servent *sp; /* service spec for tcp/ftp */
|
||||
|
||||
/* Disable output buffering, for the benefit of Emacs. */
|
||||
//setbuf(stdout, NULL);
|
||||
|
||||
_fmode = O_BINARY; // This causes an error somewhere.
|
||||
|
||||
wVerReq = MAKEWORD(1,1);
|
||||
|
||||
err = WSAStartup(wVerReq, &WSAData);
|
||||
if (err != 0)
|
||||
{
|
||||
fprintf(stderr, "Could not initialize Windows socket interface.");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
sp = getservbyname("ftp", "tcp");
|
||||
if (sp == 0) {
|
||||
fprintf(stderr, "ftp: ftp/tcp: unknown service\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
portnum = sp->s_port;
|
||||
|
||||
|
||||
doglob = 1;
|
||||
interactive = 1;
|
||||
autologin = 1;
|
||||
argc--, argv++;
|
||||
while (argc > 0 && **argv == '-') {
|
||||
for (cp = *argv + 1; *cp; cp++)
|
||||
switch (*cp) {
|
||||
|
||||
case 'd':
|
||||
options |= SO_DEBUG;
|
||||
debug++;
|
||||
break;
|
||||
|
||||
case 'v':
|
||||
verbose++;
|
||||
break;
|
||||
|
||||
case 't':
|
||||
trace++;
|
||||
break;
|
||||
|
||||
case 'i':
|
||||
interactive = 0;
|
||||
break;
|
||||
|
||||
case 'n':
|
||||
autologin = 0;
|
||||
break;
|
||||
|
||||
case 'g':
|
||||
doglob = 0;
|
||||
break;
|
||||
|
||||
default:
|
||||
fprintf(stdout,
|
||||
"ftp: %c: unknown option\n", *cp);
|
||||
exit(1);
|
||||
}
|
||||
argc--, argv++;
|
||||
}
|
||||
// fromatty = isatty(fileno(stdin));
|
||||
fromatty = 1; // Strengthen this test
|
||||
/*
|
||||
* Set up defaults for FTP.
|
||||
*/
|
||||
(void) strcpy(typename, "ascii"), type = TYPE_A;
|
||||
(void) strcpy(formname, "non-print"), form = FORM_N;
|
||||
(void) strcpy(modename, "stream"), mode = MODE_S;
|
||||
(void) strcpy(structname, "file"), stru = STRU_F;
|
||||
(void) strcpy(bytename, "8"), bytesize = 8;
|
||||
if (fromatty)
|
||||
verbose++;
|
||||
cpend = 0; /* no pending replies */
|
||||
proxy = 0; /* proxy not active */
|
||||
passivemode = 1; /* passive mode *is* active */
|
||||
crflag = 1; /* strip c.r. on ascii gets */
|
||||
/*
|
||||
* Set up the home directory in case we're globbing.
|
||||
*/
|
||||
#if 0
|
||||
cp = getlogin();
|
||||
if (cp != NULL) {
|
||||
pw = getpwnam(cp);
|
||||
}
|
||||
if (pw == NULL)
|
||||
pw = getpwuid(getuid());
|
||||
if (pw != NULL) {
|
||||
home = homedir;
|
||||
(void) strcpy(home, pw->pw_dir);
|
||||
}
|
||||
#endif
|
||||
strcpy(home, "C:/");
|
||||
if (argc > 0) {
|
||||
if (setjmp(toplevel))
|
||||
exit(0);
|
||||
// (void) signal(SIGINT, intr);
|
||||
// (void) signal(SIGPIPE, lostpeer);
|
||||
setpeer(argc + 1, argv - 1);
|
||||
}
|
||||
top = setjmp(toplevel) == 0;
|
||||
if (top) {
|
||||
// (void) signal(SIGINT, intr);
|
||||
// (void) signal(SIGPIPE, lostpeer);
|
||||
}
|
||||
for (;;) {
|
||||
cmdscanner(top);
|
||||
top = 1;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
intr()
|
||||
{
|
||||
|
||||
longjmp(toplevel, 1);
|
||||
}
|
||||
|
||||
void lostpeer(void)
|
||||
{
|
||||
extern int cout;
|
||||
extern int data;
|
||||
|
||||
if (connected) {
|
||||
if (cout != (int) NULL) {
|
||||
closesocket(cout);
|
||||
cout = (int) NULL;
|
||||
}
|
||||
if (data >= 0) {
|
||||
(void) shutdown(data, 1+1);
|
||||
(void) close(data);
|
||||
data = -1;
|
||||
}
|
||||
connected = 0;
|
||||
}
|
||||
pswitch(1);
|
||||
if (connected) {
|
||||
if (cout != (int)NULL) {
|
||||
closesocket(cout);
|
||||
cout = (int) NULL;
|
||||
}
|
||||
connected = 0;
|
||||
}
|
||||
proxflag = 0;
|
||||
pswitch(0);
|
||||
}
|
||||
|
||||
/*char *
|
||||
tail(filename)
|
||||
char *filename;
|
||||
{
|
||||
register char *s;
|
||||
|
||||
while (*filename) {
|
||||
s = rindex(filename, '/');
|
||||
if (s == NULL)
|
||||
break;
|
||||
if (s[1])
|
||||
return (s + 1);
|
||||
*s = '\0';
|
||||
}
|
||||
return (filename);
|
||||
}
|
||||
*/
|
||||
/*
|
||||
* Command parser.
|
||||
*/
|
||||
void cmdscanner(top)
|
||||
int top;
|
||||
{
|
||||
register struct cmd *c;
|
||||
struct cmd *getcmd();
|
||||
extern int help();
|
||||
|
||||
if (!top)
|
||||
(void) putchar('\n');
|
||||
for (;;) {
|
||||
(void) fflush(stdout);
|
||||
if (fromatty) {
|
||||
printf("ftp> ");
|
||||
(void) fflush(stdout);
|
||||
}
|
||||
if (gets(line) == 0) {
|
||||
if (feof(stdin) || ferror(stdin))
|
||||
quit();
|
||||
break;
|
||||
}
|
||||
if (line[0] == 0)
|
||||
break;
|
||||
makeargv();
|
||||
if (margc == 0) {
|
||||
continue;
|
||||
}
|
||||
c = getcmd(margv[0]);
|
||||
if (c == (struct cmd *)-1) {
|
||||
printf("?Ambiguous command\n");
|
||||
continue;
|
||||
}
|
||||
if (c == 0) {
|
||||
printf("?Invalid command\n");
|
||||
continue;
|
||||
}
|
||||
if (c->c_conn && !connected) {
|
||||
printf ("Not connected.\n");
|
||||
continue;
|
||||
}
|
||||
(*c->c_handler)(margc, margv);
|
||||
if (bell && c->c_bell)
|
||||
(void) putchar('\007');
|
||||
if (c->c_handler != help)
|
||||
break;
|
||||
}
|
||||
(void) fflush(stdout);
|
||||
// (void) signal(SIGINT, intr);
|
||||
// (void) signal(SIGPIPE, lostpeer);
|
||||
}
|
||||
|
||||
struct cmd *
|
||||
getcmd(name)
|
||||
register char *name;
|
||||
{
|
||||
extern struct cmd cmdtab[];
|
||||
register char *p, *q;
|
||||
register struct cmd *c, *found;
|
||||
register int nmatches, longest;
|
||||
|
||||
longest = 0;
|
||||
nmatches = 0;
|
||||
found = 0;
|
||||
for (c = cmdtab; p = c->c_name; c++) {
|
||||
for (q = name; *q == *p++; q++)
|
||||
if (*q == 0) /* exact match? */
|
||||
return (c);
|
||||
if (!*q) { /* the name was a prefix */
|
||||
if (q - name > longest) {
|
||||
longest = q - name;
|
||||
nmatches = 1;
|
||||
found = c;
|
||||
} else if (q - name == longest)
|
||||
nmatches++;
|
||||
}
|
||||
}
|
||||
if (nmatches > 1)
|
||||
return ((struct cmd *)-1);
|
||||
return (found);
|
||||
}
|
||||
|
||||
/*
|
||||
* Slice a string up into argc/argv.
|
||||
*/
|
||||
|
||||
int slrflag;
|
||||
|
||||
void makeargv()
|
||||
{
|
||||
char **argp;
|
||||
char *slurpstring();
|
||||
|
||||
margc = 0;
|
||||
argp = margv;
|
||||
stringbase = line; /* scan from first of buffer */
|
||||
argbase = argbuf; /* store from first of buffer */
|
||||
slrflag = 0;
|
||||
while (*argp++ = slurpstring())
|
||||
margc++;
|
||||
}
|
||||
|
||||
/*
|
||||
* Parse string into argbuf;
|
||||
* implemented with FSM to
|
||||
* handle quoting and strings
|
||||
*/
|
||||
char *
|
||||
slurpstring()
|
||||
{
|
||||
int got_one = 0;
|
||||
register char *sb = stringbase;
|
||||
register char *ap = argbase;
|
||||
char *tmp = argbase; /* will return this if token found */
|
||||
|
||||
if (*sb == '!' || *sb == '$') { /* recognize ! as a token for shell */
|
||||
switch (slrflag) { /* and $ as token for macro invoke */
|
||||
case 0:
|
||||
slrflag++;
|
||||
stringbase++;
|
||||
return ((*sb == '!') ? "!" : "$");
|
||||
/* NOTREACHED */
|
||||
case 1:
|
||||
slrflag++;
|
||||
altarg = stringbase;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
S0:
|
||||
switch (*sb) {
|
||||
|
||||
case '\0':
|
||||
goto OUT1;
|
||||
|
||||
case ' ':
|
||||
case '\t':
|
||||
sb++; goto S0;
|
||||
|
||||
default:
|
||||
switch (slrflag) {
|
||||
case 0:
|
||||
slrflag++;
|
||||
break;
|
||||
case 1:
|
||||
slrflag++;
|
||||
altarg = sb;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
goto S1;
|
||||
}
|
||||
|
||||
S1:
|
||||
switch (*sb) {
|
||||
|
||||
case ' ':
|
||||
case '\t':
|
||||
case '\0':
|
||||
goto OUT1; /* end of token */
|
||||
|
||||
case '\\':
|
||||
sb++; goto S2; /* slurp next character */
|
||||
|
||||
case '"':
|
||||
sb++; goto S3; /* slurp quoted string */
|
||||
|
||||
default:
|
||||
*ap++ = *sb++; /* add character to token */
|
||||
got_one = 1;
|
||||
goto S1;
|
||||
}
|
||||
|
||||
S2:
|
||||
switch (*sb) {
|
||||
|
||||
case '\0':
|
||||
goto OUT1;
|
||||
|
||||
default:
|
||||
*ap++ = *sb++;
|
||||
got_one = 1;
|
||||
goto S1;
|
||||
}
|
||||
|
||||
S3:
|
||||
switch (*sb) {
|
||||
|
||||
case '\0':
|
||||
goto OUT1;
|
||||
|
||||
case '"':
|
||||
sb++; goto S1;
|
||||
|
||||
default:
|
||||
*ap++ = *sb++;
|
||||
got_one = 1;
|
||||
goto S3;
|
||||
}
|
||||
|
||||
OUT1:
|
||||
if (got_one)
|
||||
*ap++ = '\0';
|
||||
argbase = ap; /* update storage pointer */
|
||||
stringbase = sb; /* update scan pointer */
|
||||
if (got_one) {
|
||||
return(tmp);
|
||||
}
|
||||
switch (slrflag) {
|
||||
case 0:
|
||||
slrflag++;
|
||||
break;
|
||||
case 1:
|
||||
slrflag++;
|
||||
altarg = (char *) 0;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return((char *)0);
|
||||
}
|
||||
|
||||
#define HELPINDENT (sizeof ("directory"))
|
||||
|
||||
/*
|
||||
* Help command.
|
||||
* Call each command handler with argc == 0 and argv[0] == name.
|
||||
*/
|
||||
int help(argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
{
|
||||
extern struct cmd cmdtab[];
|
||||
register struct cmd *c;
|
||||
|
||||
if (argc == 1) {
|
||||
register int i, j, w, k;
|
||||
int columns, width = 0, lines;
|
||||
extern int NCMDS;
|
||||
|
||||
printf("Commands may be abbreviated. Commands are:\n\n");
|
||||
for (c = cmdtab; c < &cmdtab[NCMDS]; c++) {
|
||||
int len = strlen(c->c_name);
|
||||
|
||||
if (len > width)
|
||||
width = len;
|
||||
}
|
||||
width = (width + 8) &~ 7;
|
||||
columns = 80 / width;
|
||||
if (columns == 0)
|
||||
columns = 1;
|
||||
lines = (NCMDS + columns - 1) / columns;
|
||||
for (i = 0; i < lines; i++) {
|
||||
for (j = 0; j < columns; j++) {
|
||||
c = cmdtab + j * lines + i;
|
||||
if (c->c_name && (!proxy || c->c_proxy)) {
|
||||
printf("%s", c->c_name);
|
||||
}
|
||||
else if (c->c_name) {
|
||||
for (k=0; k < (int) strlen(c->c_name); k++) {
|
||||
(void) putchar(' ');
|
||||
}
|
||||
}
|
||||
if (c + lines >= &cmdtab[NCMDS]) {
|
||||
printf("\n");
|
||||
break;
|
||||
}
|
||||
w = strlen(c->c_name);
|
||||
while (w < width) {
|
||||
w = (w + 8) &~ 7;
|
||||
(void) putchar('\t');
|
||||
}
|
||||
}
|
||||
}
|
||||
(void) fflush(stdout);
|
||||
return 0;
|
||||
}
|
||||
while (--argc > 0) {
|
||||
register char *arg;
|
||||
arg = *++argv;
|
||||
c = getcmd(arg);
|
||||
if (c == (struct cmd *)-1)
|
||||
printf("?Ambiguous help command %s\n", arg);
|
||||
else if (c == (struct cmd *)0)
|
||||
printf("?Invalid help command %s\n", arg);
|
||||
else
|
||||
printf("%-*s\t%s\n", HELPINDENT,
|
||||
c->c_name, c->c_help);
|
||||
}
|
||||
(void) fflush(stdout);
|
||||
return 0;
|
||||
}
|
27
apps/utils/net/ftp/makefile
Normal file
27
apps/utils/net/ftp/makefile
Normal file
@@ -0,0 +1,27 @@
|
||||
PATH_TO_TOP = ../../../..
|
||||
|
||||
TARGET_TYPE = program
|
||||
|
||||
TARGET_APPTYPE = console
|
||||
|
||||
TARGET_NAME = ftp
|
||||
|
||||
TARGET_INSTALLDIR = system32
|
||||
|
||||
TARGET_SDKLIBS = ws2_32.a iphlpapi.a
|
||||
# ntdll.a
|
||||
|
||||
TARGET_OBJECTS = \
|
||||
cmds.o \
|
||||
cmdtab.o \
|
||||
domacro.o \
|
||||
fake.o \
|
||||
ftp.o \
|
||||
main.o \
|
||||
ruserpass.o
|
||||
|
||||
TARGET_GCCLIBS =
|
||||
|
||||
include $(PATH_TO_TOP)/rules.mak
|
||||
|
||||
include $(TOOLS_PATH)/helper.mk
|
32
apps/utils/net/ftp/prototypes.h
Normal file
32
apps/utils/net/ftp/prototypes.h
Normal file
@@ -0,0 +1,32 @@
|
||||
|
||||
int getreply(int expecteof);
|
||||
int ruserpass(char *host, char **aname, char **apass, char **aacct);
|
||||
char *getpass(const char *prompt);
|
||||
void makeargv(void);
|
||||
void domacro(int argc, char *argv[]);
|
||||
void proxtrans(char *cmd, char *local, char *remote);
|
||||
int null(void);
|
||||
int initconn(void);
|
||||
void disconnect(void);
|
||||
void ptransfer(char *direction, long bytes, struct timeval *t0, struct timeval *t1);
|
||||
void setascii(void);
|
||||
void setbinary(void);
|
||||
void setebcdic(void);
|
||||
void settenex(void);
|
||||
void tvsub(struct timeval *tdiff, struct timeval *t1, struct timeval *t0);
|
||||
void setpassive(int argc, char *argv[]);
|
||||
void setpeer(int argc, char *argv[]);
|
||||
void cmdscanner(int top);
|
||||
void pswitch(int flag);
|
||||
void quit(void);
|
||||
int login(char *host);
|
||||
int command(char *fmt, ...);
|
||||
int globulize(char **cpp);
|
||||
void sendrequest(char *cmd, char *local, char *remote, int printnames);
|
||||
void recvrequest(char *cmd, char *local, char *remote, char *mode,
|
||||
int printnames);
|
||||
int confirm(char *cmd, char *file);
|
||||
void blkfree(char **av0);
|
||||
int getit(int argc, char *argv[], int restartit, char *mode);
|
||||
static int token(void);
|
||||
int sleep(int time);
|
@@ -50,27 +50,25 @@ static FILE *cfile;
|
||||
static char tokval[100];
|
||||
|
||||
static struct toktab {
|
||||
const char *tokstr;
|
||||
char *tokstr;
|
||||
int tval;
|
||||
} toktab[]= {
|
||||
{"default", DEFAULT},
|
||||
{"login", LOGIN},
|
||||
{"password", PASSWD},
|
||||
{"passwd", PASSWD},
|
||||
{"account", ACCOUNT},
|
||||
{"machine", MACH},
|
||||
{"macdef", MACDEF},
|
||||
{0, 0}
|
||||
"default", DEFAULT,
|
||||
"login", LOGIN,
|
||||
"password", PASSWD,
|
||||
"passwd", PASSWD,
|
||||
"account", ACCOUNT,
|
||||
"machine", MACH,
|
||||
"macdef", MACDEF,
|
||||
0, 0
|
||||
};
|
||||
|
||||
extern char *hostname;
|
||||
static int token(void);
|
||||
|
||||
int ruserpass(const char *host, char **aname, char **apass, char **aacct)
|
||||
int ruserpass(char *host, char **aname, char **apass, char **aacct)
|
||||
{
|
||||
const char *hdir, *mydomain;
|
||||
char buf[BUFSIZ], *tmp;
|
||||
char myname[MAXHOSTNAMELEN];
|
||||
char *hdir, buf[BUFSIZ], *tmp;
|
||||
char myname[MAXHOSTNAMELEN], *mydomain;
|
||||
int t, i, c, usedefault = 0;
|
||||
struct stat stb;
|
||||
extern int errno;
|
||||
@@ -127,15 +125,14 @@ next:
|
||||
while ((t = token()) && t != MACH && t != DEFAULT) switch(t) {
|
||||
|
||||
case LOGIN:
|
||||
if (token()) {
|
||||
if (*aname == 0) {
|
||||
if (token())
|
||||
if (*aname == 0) {
|
||||
*aname = malloc((unsigned) strlen(tokval) + 1);
|
||||
(void) strcpy(*aname, tokval);
|
||||
} else {
|
||||
if (strcmp(*aname, tokval))
|
||||
goto next;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case PASSWD:
|
||||
if (strcmp(*aname, "anonymous") &&
|
||||
@@ -167,7 +164,7 @@ next:
|
||||
(void) fclose(cfile);
|
||||
return(0);
|
||||
}
|
||||
while ((c=getc(cfile)) != EOF && (c == ' ' || c == '\t'));
|
||||
while ((c=getc(cfile)) != EOF && c == ' ' || c == '\t');
|
||||
if (c == EOF || c == '\n') {
|
||||
printf("Missing macdef name argument.\n");
|
||||
goto bad;
|
||||
@@ -240,7 +237,7 @@ static int token(void)
|
||||
char *cp;
|
||||
int c;
|
||||
struct toktab *t;
|
||||
|
||||
|
||||
if (feof(cfile))
|
||||
return (0);
|
||||
while ((c = getc(cfile)) != EOF &&
|
299
apps/utils/net/ipconfig/ipconfig.c
Normal file
299
apps/utils/net/ipconfig/ipconfig.c
Normal file
@@ -0,0 +1,299 @@
|
||||
/*
|
||||
* ipconfig - display IP stack parameters.
|
||||
*
|
||||
* This source code is in the PUBLIC DOMAIN and has NO WARRANTY.
|
||||
*
|
||||
* Robert Dickenson <robd@reactos.org>, August 15, 2002.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <windows.h>
|
||||
#include <tchar.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <iptypes.h>
|
||||
#include <ipexport.h>
|
||||
#include <iphlpapi.h>
|
||||
|
||||
#ifdef _DEBUG
|
||||
#include "trace.h"
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/* imported from iphlpapi.dll
|
||||
|
||||
GetAdapterOrderMap
|
||||
GetInterfaceInfo
|
||||
GetIpStatsFromStack
|
||||
NhGetInterfaceNameFromGuid
|
||||
NhpAllocateAndGetInterfaceInfoFromStack
|
||||
|
||||
*/
|
||||
|
||||
static TCHAR* GetNodeTypeName(int nNodeType)
|
||||
{
|
||||
switch (nNodeType) {
|
||||
case 0: return _T("zero");
|
||||
case 1: return _T("one");
|
||||
case 2: return _T("two");
|
||||
case 3: return _T("three");
|
||||
case 4: return _T("mixed");
|
||||
default: return _T("unknown");
|
||||
}
|
||||
}
|
||||
|
||||
static void ShowNetworkFixedInfo()
|
||||
{
|
||||
FIXED_INFO* pFixedInfo = NULL;
|
||||
ULONG OutBufLen = 0;
|
||||
DWORD result;
|
||||
|
||||
result = GetNetworkParams(NULL, &OutBufLen);
|
||||
if (result == ERROR_BUFFER_OVERFLOW) {
|
||||
pFixedInfo = (FIXED_INFO*)malloc(OutBufLen);
|
||||
if (!pFixedInfo) {
|
||||
_tprintf(_T("ERROR: failed to allocate 0x%08X bytes of memory\n"), OutBufLen);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
_tprintf(_T("ERROR: GetNetworkParams() failed to report required buffer size.\n"));
|
||||
return;
|
||||
}
|
||||
|
||||
result = GetNetworkParams(pFixedInfo, &OutBufLen);
|
||||
if (result == ERROR_SUCCESS) {
|
||||
IP_ADDR_STRING* pIPAddr;
|
||||
|
||||
printf("\tHostName. . . . . . . . . . . : %s\n", pFixedInfo->HostName);
|
||||
printf("\tDomainName. . . . . . . . . . : %s\n", pFixedInfo->DomainName);
|
||||
//
|
||||
printf("\tDNS Servers . . . . . . . . . : %s\n", pFixedInfo->DnsServerList.IpAddress.String);
|
||||
pIPAddr = pFixedInfo->DnsServerList.Next;
|
||||
while (pIPAddr) {
|
||||
printf("\t\t\t\t : %s\n", pIPAddr->IpAddress.String);
|
||||
pIPAddr = pIPAddr->Next;
|
||||
}
|
||||
//
|
||||
_tprintf(_T("\tNodeType. . . . . . . . . . . : %d (%s)\n"), pFixedInfo->NodeType, GetNodeTypeName(pFixedInfo->NodeType));
|
||||
printf("\tScopeId . . . . . . . . . . . : %s\n", pFixedInfo->ScopeId);
|
||||
_tprintf(_T("\tEnableRouting . . . . . . . . : %s\n"), pFixedInfo->EnableRouting ? _T("yes") : _T("no"));
|
||||
_tprintf(_T("\tEnableProxy . . . . . . . . . : %s\n"), pFixedInfo->EnableProxy ? _T("yes") : _T("no"));
|
||||
_tprintf(_T("\tEnableDns . . . . . . . . . . : %s\n"), pFixedInfo->EnableDns ? _T("yes") : _T("no"));
|
||||
_tprintf(_T("\n"));
|
||||
//_tprintf(_T("\n"),);
|
||||
//_tprintf(_T("GetNetworkParams() returned with %d\n"), pIfTable->NumAdapters);
|
||||
|
||||
// _tprintf(_T("\tConnection specific DNS suffix: %s\n"), pFixedInfo->EnableDns ? _T("yes") : _T("no"));
|
||||
|
||||
} else {
|
||||
switch (result) {
|
||||
case ERROR_BUFFER_OVERFLOW:
|
||||
_tprintf(_T("The buffer size indicated by the pOutBufLen parameter is too small to hold the adapter information. The pOutBufLen parameter points to the required size\n"));
|
||||
break;
|
||||
case ERROR_INVALID_PARAMETER:
|
||||
_tprintf(_T("The pOutBufLen parameter is NULL, or the calling process does not have read/write access to the memory pointed to by pOutBufLen, or the calling process does not have write access to the memory pointed to by the pAdapterInfo parameter\n"));
|
||||
break;
|
||||
case ERROR_NO_DATA:
|
||||
_tprintf(_T("No adapter information exists for the local computer\n"));
|
||||
break;
|
||||
case ERROR_NOT_SUPPORTED:
|
||||
_tprintf(_T("This function is not supported on the operating system in use on the local system\n"));
|
||||
break;
|
||||
default:
|
||||
_tprintf(_T("0x%08X - Use FormatMessage to obtain the message string for the returned error\n"), result);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void ShowNetworkInterfaces()
|
||||
{
|
||||
IP_INTERFACE_INFO* pIfTable = NULL;
|
||||
DWORD result;
|
||||
DWORD dwNumIf;
|
||||
DWORD dwOutBufLen = 0;
|
||||
|
||||
if ((result = GetNumberOfInterfaces(&dwNumIf)) != NO_ERROR) {
|
||||
_tprintf(_T("GetNumberOfInterfaces() failed with code 0x%08X - Use FormatMessage to obtain the message string for the returned error\n"), result);
|
||||
return;
|
||||
} else {
|
||||
_tprintf(_T("GetNumberOfInterfaces() returned %d\n"), dwNumIf);
|
||||
}
|
||||
|
||||
result = GetInterfaceInfo(pIfTable, &dwOutBufLen);
|
||||
// dwOutBufLen = sizeof(IP_INTERFACE_INFO) + dwNumIf * sizeof(IP_ADAPTER_INDEX_MAP);
|
||||
// _tprintf(_T("GetNumberOfInterfaces() returned %d, dwOutBufLen %d\n"), dwNumIf, dwOutBufLen);
|
||||
// _tprintf(_T("sizeof(IP_INTERFACE_INFO) %d, sizeof(IP_ADAPTER_INDEX_MAP) %d\n"), sizeof(IP_INTERFACE_INFO), sizeof(IP_ADAPTER_INDEX_MAP));
|
||||
|
||||
pIfTable = (IP_INTERFACE_INFO*)malloc(dwOutBufLen);
|
||||
if (!pIfTable) {
|
||||
_tprintf(_T("ERROR: failed to allocate 0x%08X bytes of memory\n"), dwOutBufLen);
|
||||
return;
|
||||
}
|
||||
/*
|
||||
typedef struct _IP_ADAPTER_INDEX_MAP {
|
||||
ULONG Index; // adapter index
|
||||
WCHAR Name[MAX_ADAPTER_NAME]; // name of the adapter
|
||||
} IP_ADAPTER_INDEX_MAP, * PIP_ADAPTER_INDEX_MAP;
|
||||
|
||||
typedef struct _IP_INTERFACE_INFO {
|
||||
LONG NumAdapters; // number of adapters in array
|
||||
IP_ADAPTER_INDEX_MAP Adapter[1]; // adapter indices and names
|
||||
} IP_INTERFACE_INFO,*PIP_INTERFACE_INFO;
|
||||
*/
|
||||
result = GetInterfaceInfo(pIfTable, &dwOutBufLen);
|
||||
if (result == NO_ERROR) {
|
||||
int i;
|
||||
_tprintf(_T("GetInterfaceInfo() returned with %d adaptor entries\n"), pIfTable->NumAdapters);
|
||||
for (i = 0; i < pIfTable->NumAdapters; i++) {
|
||||
wprintf(L"[%d] %s\n", i + 1, pIfTable->Adapter[i].Name);
|
||||
//wprintf(L"[%d] %s\n", pIfTable->Adapter[i].Index, pIfTable->Adapter[i].Name);
|
||||
|
||||
// \DEVICE\TCPIP_{DB0E61C1-3498-4C5F-B599-59CDE8A1E357}
|
||||
// \DEVICE\TCPIP_{BD445697-0945-4591-AE7F-2AB0F383CA87}
|
||||
// \DEVICE\TCPIP_{6D87DC08-6BC5-4E78-AB5F-18CAB785CFFE}
|
||||
|
||||
//HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\NetBT\Parameters\Interfaces\Tcpip_{DB0E61C1-3498-4C5F-B599-59CDE8A1E357}
|
||||
}
|
||||
} else {
|
||||
switch (result) {
|
||||
case ERROR_INVALID_PARAMETER:
|
||||
_tprintf(_T("The dwOutBufLen parameter is NULL, or GetInterfaceInterface is unable to write to the memory pointed to by the dwOutBufLen parameter\n"));
|
||||
break;
|
||||
case ERROR_INSUFFICIENT_BUFFER:
|
||||
_tprintf(_T("The buffer pointed to by the pIfTable parameter is not large enough. The required size is returned in the DWORD variable pointed to by the dwOutBufLen parameter\n"));
|
||||
_tprintf(_T("\tdwOutBufLen: %d\n"), dwOutBufLen);
|
||||
break;
|
||||
case ERROR_NOT_SUPPORTED:
|
||||
_tprintf(_T("This function is not supported on the operating system in use on the local system\n"));
|
||||
break;
|
||||
default:
|
||||
_tprintf(_T("0x%08X - Use FormatMessage to obtain the message string for the returned error\n"), result);
|
||||
break;
|
||||
}
|
||||
}
|
||||
free(pIfTable);
|
||||
}
|
||||
|
||||
/*
|
||||
typedef struct _IP_ADAPTER_INFO {
|
||||
struct _IP_ADAPTER_INFO* Next;
|
||||
DWORD ComboIndex;
|
||||
char AdapterName[MAX_ADAPTER_NAME_LENGTH + 4];
|
||||
1 char Description[MAX_ADAPTER_DESCRIPTION_LENGTH + 4];
|
||||
UINT AddressLength;
|
||||
2 BYTE Address[MAX_ADAPTER_ADDRESS_LENGTH];
|
||||
DWORD Index;
|
||||
UINT Type;
|
||||
3 UINT DhcpEnabled;
|
||||
5 PIP_ADDR_STRING CurrentIpAddress;
|
||||
IP_ADDR_STRING IpAddressList;
|
||||
7 IP_ADDR_STRING GatewayList;
|
||||
8 IP_ADDR_STRING DhcpServer;
|
||||
BOOL HaveWins;
|
||||
IP_ADDR_STRING PrimaryWinsServer;
|
||||
IP_ADDR_STRING SecondaryWinsServer;
|
||||
a time_t LeaseObtained;
|
||||
b time_t LeaseExpires;
|
||||
} IP_ADAPTER_INFO, *PIP_ADAPTER_INFO;
|
||||
*/
|
||||
/*
|
||||
Ethernet adapter VMware Virtual Ethernet Adapter (Network Address Translation (NAT) for VMnet8):
|
||||
|
||||
Connection-specific DNS Suffix . :
|
||||
1 Description . . . . . . . . . . . : VMware Virtual Ethernet Adapter (Network Address Translation (NAT) for VMnet8)
|
||||
2 Physical Address. . . . . . . . . : 00-50-56-C0-00-08
|
||||
3 DHCP Enabled. . . . . . . . . . . : Yes
|
||||
Autoconfiguration Enabled . . . . : Yes
|
||||
5 IP Address. . . . . . . . . . . . : 192.168.136.1
|
||||
Subnet Mask . . . . . . . . . . . : 255.255.255.0
|
||||
7 Default Gateway . . . . . . . . . :
|
||||
8 DHCP Server . . . . . . . . . . . : 192.168.136.254
|
||||
DNS Servers . . . . . . . . . . . :
|
||||
a Lease Obtained. . . . . . . . . . : Monday, 30 December 2002 5:56:53 PM
|
||||
b Lease Expires . . . . . . . . . . : Monday, 30 December 2002 6:26:53 PM
|
||||
*/
|
||||
static void ShowAdapterInfo()
|
||||
{
|
||||
IP_ADAPTER_INFO* pAdaptorInfo;
|
||||
ULONG ulOutBufLen;
|
||||
DWORD dwRetVal;
|
||||
|
||||
_tprintf(_T("\nAdaptor Information\t\n"));
|
||||
pAdaptorInfo = (IP_ADAPTER_INFO*)GlobalAlloc(GPTR, sizeof(IP_ADAPTER_INFO));
|
||||
ulOutBufLen = sizeof(IP_ADAPTER_INFO);
|
||||
|
||||
if (ERROR_BUFFER_OVERFLOW == GetAdaptersInfo(pAdaptorInfo, &ulOutBufLen)) {
|
||||
GlobalFree(pAdaptorInfo);
|
||||
pAdaptorInfo = (IP_ADAPTER_INFO*)GlobalAlloc(GPTR, ulOutBufLen);
|
||||
}
|
||||
if (dwRetVal = GetAdaptersInfo(pAdaptorInfo, &ulOutBufLen)) {
|
||||
_tprintf(_T("Call to GetAdaptersInfo failed. Return Value: %08x\n"), dwRetVal);
|
||||
} else {
|
||||
while (pAdaptorInfo) {
|
||||
printf(" AdapterName: %s\n", pAdaptorInfo->AdapterName);
|
||||
printf(" Description: %s\n", pAdaptorInfo->Description);
|
||||
pAdaptorInfo = pAdaptorInfo->Next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const char szUsage[] = { "USAGE:\n" \
|
||||
" ipconfig [/? | /all | /release [adapter] | /renew [adapter]\n" \
|
||||
" | /flushdns | /registerdns\n" \
|
||||
" | /showclassid adapter\n" \
|
||||
" | /showclassid adapter\n" \
|
||||
" | /setclassid adapter [classidtoset] ]\n" \
|
||||
"\n" \
|
||||
"adapter Full name or pattern with '*' and '?' to 'match',\n" \
|
||||
" * matches any character, ? matches one character.\n" \
|
||||
" Options\n" \
|
||||
" /? Display this help message.\n" \
|
||||
" /all Display full configuration information.\n" \
|
||||
" /release Release the IP address for the specified adapter.\n" \
|
||||
" /renew Renew the IP address for the specified adapter.\n" \
|
||||
" /flushdns Purges the DNS Resolver cache.\n" \
|
||||
" /registerdns Refreshes all DHCP leases and re-registers DNS names\n" \
|
||||
" /displaydns Display the contents of the DNS Resolver Cache.\n" \
|
||||
" /showclassid Displays all the dhcp class IDs allowed for adapter.\n" \
|
||||
" /setclassid Modifies the dhcp class id.\n" \
|
||||
"\n" \
|
||||
"The default is to display only the IP address, subnet mask and\n" \
|
||||
"default gateway for each adapter bound to TCP/IP.\n"
|
||||
};
|
||||
/*
|
||||
"\n" \
|
||||
"For Release and Renew, if no adapter name is specified, then the IP address\n" \
|
||||
"leases for all adapters bound to TCP/IP will be released or renewed.\n" \
|
||||
"\n" \
|
||||
"For SetClassID, if no class id is specified, then the classid is removed.\n" \
|
||||
"\n" \
|
||||
"Examples:\n" \
|
||||
" > ipconfig ... Show information.\n" \
|
||||
" > ipconfig /all ... Show detailed information\n" \
|
||||
" > ipconfig /renew ... renew all adapaters\n" \
|
||||
" > ipconfig /renew EL* ... renew adapters named EL....\n" \
|
||||
" > ipconfig /release *ELINK?21* ... release all matching adapters,\n" \
|
||||
eg. ELINK-21, myELELINKi21adapter.\n"
|
||||
*/
|
||||
|
||||
static void usage(void)
|
||||
{
|
||||
fputs(szUsage, stderr);
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
// 10.0.0.100 // As of build 0.0.20 this is hardcoded in the ip stack
|
||||
|
||||
if (argc > 1) {
|
||||
usage();
|
||||
return 1;
|
||||
}
|
||||
_tprintf(_T("ReactOS IP Configuration\n"));
|
||||
ShowNetworkFixedInfo();
|
||||
ShowNetworkInterfaces();
|
||||
ShowAdapterInfo();
|
||||
return 0;
|
||||
}
|
6
apps/utils/net/ipconfig/ipconfig.rc
Normal file
6
apps/utils/net/ipconfig/ipconfig.rc
Normal file
@@ -0,0 +1,6 @@
|
||||
/* $Id$ */
|
||||
|
||||
#define REACTOS_STR_FILE_DESCRIPTION "ReactOS TCP/IPv4 Win32 ipconfig\0"
|
||||
#define REACTOS_STR_INTERNAL_NAME "ipconfig\0"
|
||||
#define REACTOS_STR_ORIGINAL_FILENAME "ipconfig.exe\0"
|
||||
#include <reactos/version.rc>
|
19
apps/utils/net/ipconfig/makefile
Normal file
19
apps/utils/net/ipconfig/makefile
Normal file
@@ -0,0 +1,19 @@
|
||||
PATH_TO_TOP = ../../../..
|
||||
|
||||
TARGET_TYPE = program
|
||||
|
||||
TARGET_APPTYPE = console
|
||||
|
||||
TARGET_NAME = ipconfig
|
||||
|
||||
TARGET_INSTALLDIR = system32
|
||||
|
||||
TARGET_CFLAGS = -D__USE_W32API
|
||||
|
||||
TARGET_SDKLIBS = user32.a iphlpapi.a
|
||||
|
||||
TARGET_OBJECTS = $(TARGET_NAME).o
|
||||
|
||||
include $(PATH_TO_TOP)/rules.mak
|
||||
|
||||
include $(TOOLS_PATH)/helper.mk
|
53
apps/utils/net/ipconfig/trace.c
Normal file
53
apps/utils/net/ipconfig/trace.c
Normal file
@@ -0,0 +1,53 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Diagnostic Trace
|
||||
//
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#include <tchar.h>
|
||||
#include "trace.h"
|
||||
|
||||
|
||||
#ifdef _DEBUG
|
||||
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
|
||||
void _DebugBreak(void)
|
||||
{
|
||||
DebugBreak();
|
||||
}
|
||||
|
||||
void Trace(TCHAR* lpszFormat, ...)
|
||||
{
|
||||
va_list args;
|
||||
int nBuf;
|
||||
TCHAR szBuffer[512];
|
||||
|
||||
va_start(args, lpszFormat);
|
||||
nBuf = _vsntprintf(szBuffer, sizeof(szBuffer)/sizeof(TCHAR), lpszFormat, args);
|
||||
OutputDebugString(szBuffer);
|
||||
// was there an error? was the expanded string too long?
|
||||
//ASSERT(nBuf >= 0);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void Assert(void* assert, TCHAR* file, int line, void* msg)
|
||||
{
|
||||
if (msg == NULL) {
|
||||
printf("ASSERT -- %s occured on line %u of file %s.\n",
|
||||
assert, line, file);
|
||||
} else {
|
||||
printf("ASSERT -- %s occured on line %u of file %s: Message = %s.\n",
|
||||
assert, line, file, msg);
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void Trace(TCHAR* lpszFormat, ...) { };
|
||||
void Assert(void* assert, TCHAR* file, int line, void* msg) { };
|
||||
|
||||
#endif //_DEBUG
|
||||
/////////////////////////////////////////////////////////////////////////////
|
61
apps/utils/net/ipconfig/trace.h
Normal file
61
apps/utils/net/ipconfig/trace.h
Normal file
@@ -0,0 +1,61 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Diagnostic Trace
|
||||
//
|
||||
#ifndef __TRACE_H__
|
||||
#define __TRACE_H__
|
||||
|
||||
#ifdef _DEBUG
|
||||
|
||||
#ifdef _X86_
|
||||
#define BreakPoint() _asm { int 3h }
|
||||
#else
|
||||
#define BreakPoint() _DebugBreak()
|
||||
#endif
|
||||
|
||||
#ifndef ASSERT
|
||||
#define ASSERT(exp) \
|
||||
{ \
|
||||
if (!(exp)) { \
|
||||
Assert(#exp, __FILE__, __LINE__, NULL); \
|
||||
BreakPoint(); \
|
||||
} \
|
||||
} \
|
||||
|
||||
#define ASSERTMSG(exp, msg) \
|
||||
{ \
|
||||
if (!(exp)) { \
|
||||
Assert(#exp, __FILE__, __LINE__, msg); \
|
||||
BreakPoint(); \
|
||||
} \
|
||||
}
|
||||
#endif
|
||||
|
||||
//=============================================================================
|
||||
// MACRO: TRACE()
|
||||
//=============================================================================
|
||||
|
||||
#define TRACE Trace
|
||||
|
||||
|
||||
#else // _DEBUG
|
||||
|
||||
//=============================================================================
|
||||
// Define away MACRO's ASSERT() and TRACE() in non debug builds
|
||||
//=============================================================================
|
||||
|
||||
#ifndef ASSERT
|
||||
#define ASSERT(exp)
|
||||
#define ASSERTMSG(exp, msg)
|
||||
#endif
|
||||
|
||||
#define TRACE 0 ? (void)0 : Trace
|
||||
|
||||
#endif // !_DEBUG
|
||||
|
||||
|
||||
void Assert(void* assert, TCHAR* file, int line, void* msg);
|
||||
void Trace(TCHAR* lpszFormat, ...);
|
||||
|
||||
|
||||
#endif // __TRACE_H__
|
||||
/////////////////////////////////////////////////////////////////////////////
|
22
apps/utils/net/netstat/makefile
Normal file
22
apps/utils/net/netstat/makefile
Normal file
@@ -0,0 +1,22 @@
|
||||
PATH_TO_TOP = ../../../..
|
||||
|
||||
TARGET_TYPE = program
|
||||
|
||||
TARGET_APPTYPE = console
|
||||
|
||||
TARGET_NAME = netstat
|
||||
|
||||
TARGET_INSTALLDIR = system32
|
||||
|
||||
TARGET_CFLAGS = \
|
||||
-D__USE_W32API \
|
||||
-D_WIN32_IE=0x600 \
|
||||
-D_WIN32_WINNT=0x501
|
||||
|
||||
TARGET_SDKLIBS = user32.a snmpapi.a iphlpapi.a ws2_32.a
|
||||
|
||||
TARGET_OBJECTS = $(TARGET_NAME).o
|
||||
|
||||
include $(PATH_TO_TOP)/rules.mak
|
||||
|
||||
include $(TOOLS_PATH)/helper.mk
|
518
apps/utils/net/netstat/netstat.c
Normal file
518
apps/utils/net/netstat/netstat.c
Normal file
@@ -0,0 +1,518 @@
|
||||
/*
|
||||
* netstat - display IP stack statistics.
|
||||
*
|
||||
* This source code is in the PUBLIC DOMAIN and has NO WARRANTY.
|
||||
*
|
||||
* Robert Dickenson <robd@reactos.org>, August 15, 2002.
|
||||
*/
|
||||
|
||||
// Extensive reference made and use of source to netstatp by:
|
||||
// Copyright (C) 1998-2002 Mark Russinovich
|
||||
// www.sysinternals.com
|
||||
|
||||
#define ANY_SIZE 1
|
||||
|
||||
#include <windows.h>
|
||||
#include <winsock.h>
|
||||
#include <tchar.h>
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <iptypes.h>
|
||||
#include <ipexport.h>
|
||||
#include <tlhelp32.h>
|
||||
#include <iphlpapi.h>
|
||||
#include <snmp.h>
|
||||
|
||||
#include "trace.h"
|
||||
#include "resource.h"
|
||||
|
||||
|
||||
#define MAX_RESLEN 4000
|
||||
|
||||
//
|
||||
// Possible TCP endpoint states
|
||||
//
|
||||
static char TcpState[][32] = {
|
||||
"???",
|
||||
"CLOSED",
|
||||
"LISTENING",
|
||||
"SYN_SENT",
|
||||
"SYN_RCVD",
|
||||
"ESTABLISHED",
|
||||
"FIN_WAIT1",
|
||||
"FIN_WAIT2",
|
||||
"CLOSE_WAIT",
|
||||
"CLOSING",
|
||||
"LAST_ACK",
|
||||
"TIME_WAIT",
|
||||
"DELETE_TCB"
|
||||
};
|
||||
|
||||
VOID PrintError(DWORD ErrorCode)
|
||||
{
|
||||
LPVOID lpMsgBuf;
|
||||
|
||||
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
|
||||
NULL, ErrorCode, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
||||
(LPTSTR)&lpMsgBuf, 0, NULL);
|
||||
printf("%s\n", lpMsgBuf);
|
||||
LocalFree(lpMsgBuf);
|
||||
}
|
||||
|
||||
static void ShowTcpStatistics()
|
||||
{
|
||||
MIB_TCPSTATS TcpStatsMIB;
|
||||
GetTcpStatistics(&TcpStatsMIB);
|
||||
|
||||
_tprintf(_T("TCP/IP Statistics\t\n"));
|
||||
_tprintf(_T(" time-out algorithm:\t\t%d\n"), TcpStatsMIB.dwRtoAlgorithm);
|
||||
_tprintf(_T(" minimum time-out:\t\t%d\n"), TcpStatsMIB.dwRtoMin);
|
||||
_tprintf(_T(" maximum time-out:\t\t%d\n"), TcpStatsMIB.dwRtoMax);
|
||||
_tprintf(_T(" maximum connections:\t\t%d\n"), TcpStatsMIB.dwMaxConn);
|
||||
_tprintf(_T(" active opens:\t\t\t%d\n"), TcpStatsMIB.dwActiveOpens);
|
||||
_tprintf(_T(" passive opens:\t\t\t%d\n"), TcpStatsMIB.dwPassiveOpens);
|
||||
_tprintf(_T(" failed attempts:\t\t%d\n"), TcpStatsMIB.dwAttemptFails);
|
||||
_tprintf(_T(" established connections reset:\t%d\n"), TcpStatsMIB.dwEstabResets);
|
||||
_tprintf(_T(" established connections:\t%d\n"), TcpStatsMIB.dwCurrEstab);
|
||||
_tprintf(_T(" segments received:\t\t%d\n"), TcpStatsMIB.dwInSegs);
|
||||
_tprintf(_T(" segment sent:\t\t\t%d\n"), TcpStatsMIB.dwOutSegs);
|
||||
_tprintf(_T(" segments retransmitted:\t\t%d\n"), TcpStatsMIB.dwRetransSegs);
|
||||
_tprintf(_T(" incoming errors:\t\t%d\n"), TcpStatsMIB.dwInErrs);
|
||||
_tprintf(_T(" outgoing resets:\t\t%d\n"), TcpStatsMIB.dwOutRsts);
|
||||
_tprintf(_T(" cumulative connections:\t\t%d\n"), TcpStatsMIB.dwNumConns);
|
||||
}
|
||||
|
||||
static void ShowUdpStatistics()
|
||||
{
|
||||
MIB_UDPSTATS UDPStatsMIB;
|
||||
GetUdpStatistics(&UDPStatsMIB);
|
||||
|
||||
_tprintf(_T("UDP Statistics\t\n"));
|
||||
_tprintf(_T(" received datagrams:\t\t\t%d\n"), UDPStatsMIB.dwInDatagrams);
|
||||
_tprintf(_T(" datagrams for which no port exists:\t%d\n"), UDPStatsMIB.dwNoPorts);
|
||||
_tprintf(_T(" errors on received datagrams:\t\t%d\n"), UDPStatsMIB.dwInErrors);
|
||||
_tprintf(_T(" sent datagrams:\t\t\t\t%d\n"), UDPStatsMIB.dwOutDatagrams);
|
||||
_tprintf(_T(" number of entries in listener table:\t%d\n"), UDPStatsMIB.dwNumAddrs);
|
||||
}
|
||||
|
||||
static void ShowIpStatistics()
|
||||
{
|
||||
MIB_IPSTATS IPStatsMIB;
|
||||
GetIpStatistics(&IPStatsMIB);
|
||||
|
||||
_tprintf(_T("IP Statistics\t\n"));
|
||||
_tprintf(_T(" IP forwarding enabled or disabled:\t%d\n"), IPStatsMIB.dwForwarding);
|
||||
_tprintf(_T(" default time-to-live:\t\t\t%d\n"), IPStatsMIB.dwDefaultTTL);
|
||||
_tprintf(_T(" datagrams received:\t\t\t%d\n"), IPStatsMIB.dwInReceives);
|
||||
_tprintf(_T(" received header errors:\t\t\t%d\n"), IPStatsMIB.dwInHdrErrors);
|
||||
_tprintf(_T(" received address errors:\t\t%d\n"), IPStatsMIB.dwInAddrErrors);
|
||||
_tprintf(_T(" datagrams forwarded:\t\t\t%d\n"), IPStatsMIB.dwForwDatagrams);
|
||||
_tprintf(_T(" datagrams with unknown protocol:\t%d\n"), IPStatsMIB.dwInUnknownProtos);
|
||||
_tprintf(_T(" received datagrams discarded:\t\t%d\n"), IPStatsMIB.dwInDiscards);
|
||||
_tprintf(_T(" received datagrams delivered:\t\t%d\n"), IPStatsMIB.dwInDelivers);
|
||||
_tprintf(_T(" sent datagrams discarded:\t\t%d\n"), IPStatsMIB.dwOutDiscards);
|
||||
_tprintf(_T(" datagrams for which no route exists:\t%d\n"), IPStatsMIB.dwOutNoRoutes);
|
||||
_tprintf(_T(" datagrams for which frags didn't arrive:%d\n"), IPStatsMIB.dwReasmTimeout);
|
||||
_tprintf(_T(" datagrams requiring reassembly:\t\t%d\n"), IPStatsMIB.dwReasmReqds);
|
||||
_tprintf(_T(" successful reassemblies:\t\t%d\n"), IPStatsMIB.dwReasmOks);
|
||||
_tprintf(_T(" failed reassemblies:\t\t\t%d\n"), IPStatsMIB.dwReasmFails);
|
||||
_tprintf(_T(" successful fragmentations:\t\t%d\n"), IPStatsMIB.dwFragOks);
|
||||
_tprintf(_T(" failed fragmentations:\t\t\t%d\n"), IPStatsMIB.dwFragFails);
|
||||
_tprintf(_T(" datagrams fragmented:\t\t\t%d\n"), IPStatsMIB.dwFragCreates);
|
||||
_tprintf(_T(" number of interfaces on computer:\t%d\n"), IPStatsMIB.dwNumIf);
|
||||
_tprintf(_T(" number of IP address on computer:\t%d\n"), IPStatsMIB.dwNumAddr);
|
||||
_tprintf(_T(" number of routes in routing table:\t%d\n"), IPStatsMIB.dwNumRoutes);
|
||||
}
|
||||
|
||||
static void ShowNetworkParams()
|
||||
{
|
||||
FIXED_INFO* FixedInfo;
|
||||
IP_ADDR_STRING* pIPAddr;
|
||||
ULONG ulOutBufLen;
|
||||
DWORD dwRetVal;
|
||||
|
||||
_tprintf(_T("Network Parameters\t\n"));
|
||||
|
||||
FixedInfo = (FIXED_INFO*)GlobalAlloc(GPTR, sizeof(FIXED_INFO));
|
||||
ulOutBufLen = sizeof(FIXED_INFO);
|
||||
if (ERROR_BUFFER_OVERFLOW == GetNetworkParams(FixedInfo, &ulOutBufLen)) {
|
||||
GlobalFree(FixedInfo);
|
||||
FixedInfo =(FIXED_INFO*)GlobalAlloc(GPTR, ulOutBufLen);
|
||||
}
|
||||
if (dwRetVal = GetNetworkParams(FixedInfo, &ulOutBufLen)) {
|
||||
_tprintf(_T("Call to GetNetworkParams failed. Return Value: %08x\n"), dwRetVal);
|
||||
} else {
|
||||
printf(" Host Name: %s", FixedInfo->HostName);
|
||||
printf("\n Domain Name: %s", FixedInfo->DomainName);
|
||||
printf("\n DNS Servers:\t%s\n", FixedInfo->DnsServerList.IpAddress.String);
|
||||
pIPAddr = FixedInfo->DnsServerList.Next;
|
||||
while (pIPAddr) {
|
||||
printf("\t\t\t%s\n", pIPAddr->IpAddress.String);
|
||||
pIPAddr = pIPAddr->Next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void ShowAdapterInfo()
|
||||
{
|
||||
IP_ADAPTER_INFO* pAdaptorInfo;
|
||||
ULONG ulOutBufLen;
|
||||
DWORD dwRetVal;
|
||||
|
||||
_tprintf(_T("\nAdaptor Information\t\n"));
|
||||
pAdaptorInfo = (IP_ADAPTER_INFO*)GlobalAlloc(GPTR, sizeof(IP_ADAPTER_INFO));
|
||||
ulOutBufLen = sizeof(IP_ADAPTER_INFO);
|
||||
|
||||
if (ERROR_BUFFER_OVERFLOW == GetAdaptersInfo(pAdaptorInfo, &ulOutBufLen)) {
|
||||
GlobalFree(pAdaptorInfo);
|
||||
pAdaptorInfo = (IP_ADAPTER_INFO*)GlobalAlloc(GPTR, ulOutBufLen);
|
||||
}
|
||||
if (dwRetVal = GetAdaptersInfo(pAdaptorInfo, &ulOutBufLen)) {
|
||||
_tprintf(_T("Call to GetAdaptersInfo failed. Return Value: %08x\n"), dwRetVal);
|
||||
} else {
|
||||
while (pAdaptorInfo) {
|
||||
printf(" AdapterName: %s\n", pAdaptorInfo->AdapterName);
|
||||
printf(" Description: %s\n", pAdaptorInfo->Description);
|
||||
pAdaptorInfo = pAdaptorInfo->Next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
typedef struct {
|
||||
UINT idLength;
|
||||
UINT* ids;
|
||||
} AsnObjectIdentifier;
|
||||
|
||||
VOID SnmpUtilPrintAsnAny(AsnAny* pAny); // pointer to value to print
|
||||
VOID SnmpUtilPrintOid(AsnObjectIdentifier* Oid); // object identifier to print
|
||||
|
||||
*/
|
||||
void test_snmp(void)
|
||||
{
|
||||
int nBytes = 500;
|
||||
BYTE* pCache;
|
||||
|
||||
pCache = (BYTE*)SnmpUtilMemAlloc(nBytes);
|
||||
if (pCache != NULL) {
|
||||
AsnObjectIdentifier* pOidSrc = NULL;
|
||||
AsnObjectIdentifier AsnObId;
|
||||
if (SnmpUtilOidCpy(&AsnObId, pOidSrc)) {
|
||||
//
|
||||
//
|
||||
//
|
||||
SnmpUtilOidFree(&AsnObId);
|
||||
}
|
||||
SnmpUtilMemFree(pCache);
|
||||
} else {
|
||||
_tprintf(_T("ERROR: call to SnmpUtilMemAlloc() failed\n"));
|
||||
}
|
||||
}
|
||||
|
||||
// Maximum string lengths for ASCII ip address and port names
|
||||
//
|
||||
#define HOSTNAMELEN 256
|
||||
#define PORTNAMELEN 256
|
||||
#define ADDRESSLEN HOSTNAMELEN+PORTNAMELEN
|
||||
|
||||
//
|
||||
// Our option flags
|
||||
//
|
||||
#define FLAG_SHOW_ALL_ENDPOINTS 1
|
||||
#define FLAG_SHOW_ETH_STATS 2
|
||||
#define FLAG_SHOW_NUMBERS 3
|
||||
#define FLAG_SHOW_PROT_CONNECTIONS 4
|
||||
#define FLAG_SHOW_ROUTE_TABLE 5
|
||||
#define FLAG_SHOW_PROT_STATS 6
|
||||
#define FLAG_SHOW_INTERVAL 7
|
||||
|
||||
|
||||
// Undocumented extended information structures available only on XP and higher
|
||||
|
||||
typedef struct {
|
||||
DWORD dwState; // state of the connection
|
||||
DWORD dwLocalAddr; // address on local computer
|
||||
DWORD dwLocalPort; // port number on local computer
|
||||
DWORD dwRemoteAddr; // address on remote computer
|
||||
DWORD dwRemotePort; // port number on remote computer
|
||||
DWORD dwProcessId;
|
||||
} MIB_TCPEXROW, *PMIB_TCPEXROW;
|
||||
|
||||
typedef struct {
|
||||
DWORD dwNumEntries;
|
||||
MIB_TCPEXROW table[ANY_SIZE];
|
||||
} MIB_TCPEXTABLE, *PMIB_TCPEXTABLE;
|
||||
|
||||
typedef struct {
|
||||
DWORD dwLocalAddr; // address on local computer
|
||||
DWORD dwLocalPort; // port number on local computer
|
||||
DWORD dwProcessId;
|
||||
} MIB_UDPEXROW, *PMIB_UDPEXROW;
|
||||
|
||||
typedef struct {
|
||||
DWORD dwNumEntries;
|
||||
MIB_UDPEXROW table[ANY_SIZE];
|
||||
} MIB_UDPEXTABLE, *PMIB_UDPEXTABLE;
|
||||
|
||||
|
||||
//
|
||||
// GetPortName
|
||||
//
|
||||
// Translate port numbers into their text equivalent if there is one
|
||||
//
|
||||
PCHAR
|
||||
GetPortName(DWORD Flags, UINT port, PCHAR proto, PCHAR name, int namelen)
|
||||
{
|
||||
struct servent *psrvent;
|
||||
|
||||
if (Flags & FLAG_SHOW_NUMBERS) {
|
||||
sprintf(name, "%d", htons((WORD)port));
|
||||
return name;
|
||||
}
|
||||
// Try to translate to a name
|
||||
if (psrvent = getservbyport(port, proto)) {
|
||||
strcpy(name, psrvent->s_name );
|
||||
} else {
|
||||
sprintf(name, "%d", htons((WORD)port));
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// GetIpHostName
|
||||
//
|
||||
// Translate IP addresses into their name-resolved form if possible.
|
||||
//
|
||||
PCHAR
|
||||
GetIpHostName(DWORD Flags, BOOL local, UINT ipaddr, PCHAR name, int namelen)
|
||||
{
|
||||
// struct hostent *phostent;
|
||||
UINT nipaddr;
|
||||
|
||||
// Does the user want raw numbers?
|
||||
nipaddr = htonl(ipaddr);
|
||||
if (Flags & FLAG_SHOW_NUMBERS ) {
|
||||
sprintf(name, "%d.%d.%d.%d",
|
||||
(nipaddr >> 24) & 0xFF,
|
||||
(nipaddr >> 16) & 0xFF,
|
||||
(nipaddr >> 8) & 0xFF,
|
||||
(nipaddr) & 0xFF);
|
||||
return name;
|
||||
}
|
||||
|
||||
name[0] = _T('\0');
|
||||
|
||||
// Try to translate to a name
|
||||
if (!ipaddr) {
|
||||
if (!local) {
|
||||
sprintf(name, "%d.%d.%d.%d",
|
||||
(nipaddr >> 24) & 0xFF,
|
||||
(nipaddr >> 16) & 0xFF,
|
||||
(nipaddr >> 8) & 0xFF,
|
||||
(nipaddr) & 0xFF);
|
||||
} else {
|
||||
//gethostname(name, namelen);
|
||||
}
|
||||
} else if (ipaddr == 0x0100007f) {
|
||||
if (local) {
|
||||
//gethostname(name, namelen);
|
||||
} else {
|
||||
strcpy(name, "localhost");
|
||||
}
|
||||
// } else if (phostent = gethostbyaddr((char*)&ipaddr, sizeof(nipaddr), PF_INET)) {
|
||||
// strcpy(name, phostent->h_name);
|
||||
} else {
|
||||
#if 0
|
||||
int i1, i2, i3, i4;
|
||||
|
||||
i1 = (nipaddr >> 24) & 0x000000FF;
|
||||
i2 = (nipaddr >> 16) & 0x000000FF;
|
||||
i3 = (nipaddr >> 8) & 0x000000FF;
|
||||
i4 = (nipaddr) & 0x000000FF;
|
||||
|
||||
i1 = 10;
|
||||
i2 = 20;
|
||||
i3 = 30;
|
||||
i4 = 40;
|
||||
|
||||
sprintf(name, "%d.%d.%d.%d", i1,i2,i3,i4);
|
||||
#else
|
||||
sprintf(name, "%d.%d.%d.%d",
|
||||
((nipaddr >> 24) & 0x000000FF),
|
||||
((nipaddr >> 16) & 0x000000FF),
|
||||
((nipaddr >> 8) & 0x000000FF),
|
||||
((nipaddr) & 0x000000FF));
|
||||
#endif
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
BOOLEAN usage(void)
|
||||
{
|
||||
TCHAR buffer[MAX_RESLEN];
|
||||
|
||||
int length = LoadString(GetModuleHandle(NULL), IDS_APP_USAGE, buffer, sizeof(buffer)/sizeof(buffer[0]));
|
||||
_fputts(buffer, stderr);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
//
|
||||
// GetOptions
|
||||
//
|
||||
// Parses the command line arguments.
|
||||
//
|
||||
BOOLEAN
|
||||
GetOptions(int argc, char *argv[], PDWORD pFlags)
|
||||
{
|
||||
int i, j;
|
||||
BOOLEAN skipArgument;
|
||||
|
||||
*pFlags = 0;
|
||||
for (i = 1; i < argc; i++) {
|
||||
skipArgument = FALSE;
|
||||
switch (argv[i][0]) {
|
||||
case '-':
|
||||
case '/':
|
||||
j = 1;
|
||||
while (argv[i][j]) {
|
||||
switch (toupper(argv[i][j])) {
|
||||
case 'A':
|
||||
*pFlags |= FLAG_SHOW_ALL_ENDPOINTS;
|
||||
break;
|
||||
case 'E':
|
||||
*pFlags |= FLAG_SHOW_ETH_STATS;
|
||||
break;
|
||||
case 'N':
|
||||
*pFlags |= FLAG_SHOW_NUMBERS;
|
||||
break;
|
||||
case 'P':
|
||||
*pFlags |= FLAG_SHOW_PROT_CONNECTIONS;
|
||||
break;
|
||||
case 'R':
|
||||
*pFlags |= FLAG_SHOW_ROUTE_TABLE;
|
||||
break;
|
||||
case 'S':
|
||||
*pFlags |= FLAG_SHOW_PROT_STATS;
|
||||
break;
|
||||
default:
|
||||
return usage();
|
||||
}
|
||||
if (skipArgument) break;
|
||||
j++;
|
||||
}
|
||||
break;
|
||||
case 'i':
|
||||
*pFlags |= FLAG_SHOW_INTERVAL;
|
||||
break;
|
||||
default:
|
||||
return usage();
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#if 1
|
||||
|
||||
CHAR localname[HOSTNAMELEN], remotename[HOSTNAMELEN];
|
||||
CHAR remoteport[PORTNAMELEN], localport[PORTNAMELEN];
|
||||
CHAR localaddr[ADDRESSLEN], remoteaddr[ADDRESSLEN];
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
PMIB_TCPTABLE tcpTable;
|
||||
PMIB_UDPTABLE udpTable;
|
||||
DWORD error, dwSize;
|
||||
DWORD i, flags;
|
||||
|
||||
// Get options
|
||||
if (!GetOptions(argc, argv, &flags)) {
|
||||
return -1;
|
||||
} else {
|
||||
// Get the table of TCP endpoints
|
||||
dwSize = 0;
|
||||
error = GetTcpTable(NULL, &dwSize, TRUE);
|
||||
if (error != ERROR_INSUFFICIENT_BUFFER) {
|
||||
printf("Failed to snapshot TCP endpoints.\n");
|
||||
PrintError(error);
|
||||
return -1;
|
||||
}
|
||||
tcpTable = (PMIB_TCPTABLE)malloc(dwSize);
|
||||
error = GetTcpTable(tcpTable, &dwSize, TRUE );
|
||||
if (error) {
|
||||
printf("Failed to snapshot TCP endpoints table.\n");
|
||||
PrintError(error);
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Get the table of UDP endpoints
|
||||
dwSize = 0;
|
||||
error = GetUdpTable(NULL, &dwSize, TRUE);
|
||||
if (error != ERROR_INSUFFICIENT_BUFFER) {
|
||||
printf("Failed to snapshot UDP endpoints.\n");
|
||||
PrintError(error);
|
||||
return -1;
|
||||
}
|
||||
udpTable = (PMIB_UDPTABLE)malloc(dwSize);
|
||||
error = GetUdpTable(udpTable, &dwSize, TRUE);
|
||||
if (error) {
|
||||
printf("Failed to snapshot UDP endpoints table.\n");
|
||||
PrintError(error);
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Dump the TCP table
|
||||
for (i = 0; i < tcpTable->dwNumEntries; i++) {
|
||||
if (flags & FLAG_SHOW_ALL_ENDPOINTS ||
|
||||
tcpTable->table[i].dwState == MIB_TCP_STATE_ESTAB) {
|
||||
sprintf(localaddr, "%s:%s",
|
||||
GetIpHostName(flags, TRUE, tcpTable->table[i].dwLocalAddr, localname, HOSTNAMELEN),
|
||||
GetPortName(flags, tcpTable->table[i].dwLocalPort, "tcp", localport, PORTNAMELEN));
|
||||
sprintf(remoteaddr, "%s:%s",
|
||||
GetIpHostName(flags, FALSE, tcpTable->table[i].dwRemoteAddr, remotename, HOSTNAMELEN),
|
||||
tcpTable->table[i].dwRemoteAddr ?
|
||||
GetPortName(flags, tcpTable->table[i].dwRemotePort, "tcp", remoteport, PORTNAMELEN):
|
||||
"0");
|
||||
printf("%4s\tState: %s\n", "[TCP]", TcpState[tcpTable->table[i].dwState]);
|
||||
printf(" Local: %s\n Remote: %s\n", localaddr, remoteaddr);
|
||||
}
|
||||
}
|
||||
// Dump the UDP table
|
||||
if (flags & FLAG_SHOW_ALL_ENDPOINTS) {
|
||||
for (i = 0; i < udpTable->dwNumEntries; i++) {
|
||||
sprintf(localaddr, "%s:%s",
|
||||
GetIpHostName(flags, TRUE, udpTable->table[i].dwLocalAddr, localname, HOSTNAMELEN),
|
||||
GetPortName(flags, udpTable->table[i].dwLocalPort, "tcp", localport, PORTNAMELEN));
|
||||
printf("%4s", "[UDP]");
|
||||
printf(" Local: %s\n Remote: %s\n", localaddr, "*.*.*.*:*");
|
||||
}
|
||||
}
|
||||
}
|
||||
printf("\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
if (argc > 1) {
|
||||
usage();
|
||||
return 1;
|
||||
}
|
||||
|
||||
_tprintf(_T("\nActive Connections\n\n")\
|
||||
_T(" Proto Local Address Foreign Address State\n\n"));
|
||||
test_snmp();
|
||||
|
||||
ShowTcpStatistics();
|
||||
ShowUdpStatistics();
|
||||
ShowIpStatistics();
|
||||
ShowNetworkParams();
|
||||
ShowAdapterInfo();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
40
apps/utils/net/netstat/netstat.rc
Normal file
40
apps/utils/net/netstat/netstat.rc
Normal file
@@ -0,0 +1,40 @@
|
||||
/* $Id$ */
|
||||
|
||||
#include <windows.h>
|
||||
#include "resource.h"
|
||||
|
||||
#define REACTOS_STR_FILE_DESCRIPTION "ReactOS TCP/IPv4 Win32 netstat\0"
|
||||
#define REACTOS_STR_INTERNAL_NAME "netstat\0"
|
||||
#define REACTOS_STR_ORIGINAL_FILENAME "netstat.exe\0"
|
||||
#include <reactos/version.rc>
|
||||
|
||||
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// String Table
|
||||
//
|
||||
|
||||
#ifdef __GNUC__
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDS_APP_TITLE "ReactOS netstat"
|
||||
IDS_APP_USAGE "\n"\
|
||||
"Displays current TCP/IP protocol statistics and network connections.\n\n"\
|
||||
"NETSTAT [-a] [-e] [-n] [-s] [-p proto] [-r] [interval]\n\n"\
|
||||
" -a Displays all connections and listening ports.\n"\
|
||||
" -e Displays Ethernet statistics. May be combined with -s\n"\
|
||||
" -n Displays address and port numbers in numeric form.\n"\
|
||||
" -p proto Shows connections for protocol 'proto' TCP or UDP.\n"\
|
||||
" If used with the -s option to display\n"\
|
||||
" per-protocol statistics, 'proto' may be TCP, UDP, or IP.\n"\
|
||||
" -r Displays the current routing table.\n"\
|
||||
" -s Displays per-protocol statistics. Statistics are shown for\n"\
|
||||
" TCP, UDP and IP by default; use -p option to display\n"\
|
||||
" information about a subset of the protocols only.\n"\
|
||||
" interval Redisplays selected statistics every 'interval' seconds.\n"\
|
||||
" Press CTRL+C to stop redisplaying. By default netstat will\n"\
|
||||
" print the current information only once.\n"
|
||||
END
|
||||
#endif
|
||||
|
7
apps/utils/net/netstat/resource.h
Normal file
7
apps/utils/net/netstat/resource.h
Normal file
@@ -0,0 +1,7 @@
|
||||
|
||||
#define RES_FIRST_INDEX 1
|
||||
#define RES_LAST_INDEX 25
|
||||
|
||||
#define IDS_APP_TITLE 100
|
||||
#define IDS_APP_USAGE 101
|
||||
|
53
apps/utils/net/netstat/trace.c
Normal file
53
apps/utils/net/netstat/trace.c
Normal file
@@ -0,0 +1,53 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Diagnostic Trace
|
||||
//
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#include <tchar.h>
|
||||
#include "trace.h"
|
||||
|
||||
|
||||
#ifdef _DEBUG
|
||||
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
|
||||
void _DebugBreak(void)
|
||||
{
|
||||
DebugBreak();
|
||||
}
|
||||
|
||||
void Trace(TCHAR* lpszFormat, ...)
|
||||
{
|
||||
va_list args;
|
||||
int nBuf;
|
||||
TCHAR szBuffer[512];
|
||||
|
||||
va_start(args, lpszFormat);
|
||||
nBuf = _vsntprintf(szBuffer, sizeof(szBuffer)/sizeof(TCHAR), lpszFormat, args);
|
||||
OutputDebugString(szBuffer);
|
||||
// was there an error? was the expanded string too long?
|
||||
//ASSERT(nBuf >= 0);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void Assert(void* assert, TCHAR* file, int line, void* msg)
|
||||
{
|
||||
if (msg == NULL) {
|
||||
printf("ASSERT -- %s occured on line %u of file %s.\n",
|
||||
assert, line, file);
|
||||
} else {
|
||||
printf("ASSERT -- %s occured on line %u of file %s: Message = %s.\n",
|
||||
assert, line, file, msg);
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void Trace(TCHAR* lpszFormat, ...) { };
|
||||
void Assert(void* assert, TCHAR* file, int line, void* msg) { };
|
||||
|
||||
#endif //_DEBUG
|
||||
/////////////////////////////////////////////////////////////////////////////
|
61
apps/utils/net/netstat/trace.h
Normal file
61
apps/utils/net/netstat/trace.h
Normal file
@@ -0,0 +1,61 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Diagnostic Trace
|
||||
//
|
||||
#ifndef __TRACE_H__
|
||||
#define __TRACE_H__
|
||||
|
||||
#ifdef _DEBUG
|
||||
|
||||
#ifdef _X86_
|
||||
#define BreakPoint() _asm { int 3h }
|
||||
#else
|
||||
#define BreakPoint() _DebugBreak()
|
||||
#endif
|
||||
|
||||
#ifndef ASSERT
|
||||
#define ASSERT(exp) \
|
||||
{ \
|
||||
if (!(exp)) { \
|
||||
Assert(#exp, __FILE__, __LINE__, NULL); \
|
||||
BreakPoint(); \
|
||||
} \
|
||||
} \
|
||||
|
||||
#define ASSERTMSG(exp, msg) \
|
||||
{ \
|
||||
if (!(exp)) { \
|
||||
Assert(#exp, __FILE__, __LINE__, msg); \
|
||||
BreakPoint(); \
|
||||
} \
|
||||
}
|
||||
#endif
|
||||
|
||||
//=============================================================================
|
||||
// MACRO: TRACE()
|
||||
//=============================================================================
|
||||
|
||||
#define TRACE Trace
|
||||
|
||||
|
||||
#else // _DEBUG
|
||||
|
||||
//=============================================================================
|
||||
// Define away MACRO's ASSERT() and TRACE() in non debug builds
|
||||
//=============================================================================
|
||||
|
||||
#ifndef ASSERT
|
||||
#define ASSERT(exp)
|
||||
#define ASSERTMSG(exp, msg)
|
||||
#endif
|
||||
|
||||
#define TRACE 0 ? (void)0 : Trace
|
||||
|
||||
#endif // !_DEBUG
|
||||
|
||||
|
||||
void Assert(void* assert, TCHAR* file, int line, void* msg);
|
||||
void Trace(TCHAR* lpszFormat, ...);
|
||||
|
||||
|
||||
#endif // __TRACE_H__
|
||||
/////////////////////////////////////////////////////////////////////////////
|
19
apps/utils/net/ping/makefile
Normal file
19
apps/utils/net/ping/makefile
Normal file
@@ -0,0 +1,19 @@
|
||||
PATH_TO_TOP = ../../../..
|
||||
|
||||
TARGET_TYPE = program
|
||||
|
||||
TARGET_APPTYPE = console
|
||||
|
||||
TARGET_NAME = ping
|
||||
|
||||
TARGET_INSTALLDIR = system32
|
||||
|
||||
TARGET_CFLAGS = -D__USE_W32_SOCKETS
|
||||
|
||||
TARGET_SDKLIBS = ws2_32.a
|
||||
|
||||
TARGET_OBJECTS = $(TARGET_NAME).o
|
||||
|
||||
include $(PATH_TO_TOP)/rules.mak
|
||||
|
||||
include $(TOOLS_PATH)/helper.mk
|
@@ -1,4 +1,5 @@
|
||||
/*
|
||||
/* $Id$
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS ping utility
|
||||
* FILE: apps/net/ping/ping.c
|
||||
@@ -7,15 +8,16 @@
|
||||
* REVISIONS:
|
||||
* CSH 01/09/2000 Created
|
||||
*/
|
||||
|
||||
//#include <windows.h>
|
||||
#include <winsock2.h>
|
||||
#include <tchar.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#ifndef _MSC_VER
|
||||
|
||||
//#define DBG
|
||||
|
||||
/* FIXME: Where should this be? */
|
||||
#ifdef CopyMemory
|
||||
#undef CopyMemory
|
||||
@@ -31,12 +33,9 @@ typedef long long __int64;
|
||||
|
||||
char * _i64toa(__int64 value, char *string, int radix);
|
||||
|
||||
#endif /* _MSC_VER */
|
||||
|
||||
#ifdef DBG
|
||||
#undef DBG
|
||||
#endif
|
||||
|
||||
|
||||
/* General ICMP constants */
|
||||
#define ICMP_MINSIZE 8 /* Minimum ICMP packet size */
|
||||
#define ICMP_MAXSIZE 65535 /* Maximum ICMP packet size */
|
||||
@@ -105,16 +104,16 @@ LARGE_INTEGER TicksPerMs; /* Ticks per millisecond */
|
||||
LARGE_INTEGER TicksPerUs; /* Ticks per microsecond */
|
||||
BOOL UsePerformanceCounter;
|
||||
|
||||
#ifdef DBG
|
||||
|
||||
/* Display the contents of a buffer */
|
||||
static VOID DisplayBuffer(
|
||||
VOID DisplayBuffer(
|
||||
PVOID Buffer,
|
||||
DWORD Size)
|
||||
{
|
||||
UINT i;
|
||||
PCHAR p;
|
||||
|
||||
printf("Buffer (0x%p) Size (0x%lX).\n", Buffer, Size);
|
||||
printf("Buffer (0x%X) Size (0x%X).\n", Buffer, Size);
|
||||
|
||||
p = (PCHAR)Buffer;
|
||||
for (i = 0; i < Size; i++) {
|
||||
@@ -124,10 +123,9 @@ static VOID DisplayBuffer(
|
||||
printf("%02X ", (p[i]) & 0xFF);
|
||||
}
|
||||
}
|
||||
#endif /* DBG */
|
||||
|
||||
/* Display usage information on screen */
|
||||
static VOID Usage(VOID)
|
||||
VOID Usage(VOID)
|
||||
{
|
||||
printf("\nUsage: ping [-t] [-n count] [-l size] [-w timeout] destination-host\n\n");
|
||||
printf("Options:\n");
|
||||
@@ -139,7 +137,7 @@ static VOID Usage(VOID)
|
||||
}
|
||||
|
||||
/* Reset configuration to default values */
|
||||
static VOID Reset(VOID)
|
||||
VOID Reset(VOID)
|
||||
{
|
||||
LARGE_INTEGER PerformanceCounterFrequency;
|
||||
|
||||
@@ -175,13 +173,13 @@ static VOID Reset(VOID)
|
||||
}
|
||||
|
||||
/* Return ULONG in a string */
|
||||
static ULONG GetULONG(LPSTR String)
|
||||
ULONG GetULONG(LPSTR String)
|
||||
{
|
||||
UINT i, Length;
|
||||
ULONG Value;
|
||||
|
||||
i = 0;
|
||||
Length = (UINT)_tcslen(String);
|
||||
Length = strlen(String);
|
||||
while ((i < Length) && ((String[i] < '0') || (String[i] > '9'))) i++;
|
||||
if ((i >= Length) || ((String[i] < '0') || (String[i] > '9'))) {
|
||||
InvalidOption = TRUE;
|
||||
@@ -193,7 +191,7 @@ static ULONG GetULONG(LPSTR String)
|
||||
}
|
||||
|
||||
/* Return ULONG in a string. Try next paramter if not successful */
|
||||
static ULONG GetULONG2(LPSTR String1, LPSTR String2, PINT i)
|
||||
ULONG GetULONG2(LPSTR String1, LPSTR String2, PINT i)
|
||||
{
|
||||
ULONG Value;
|
||||
|
||||
@@ -211,7 +209,7 @@ static ULONG GetULONG2(LPSTR String1, LPSTR String2, PINT i)
|
||||
}
|
||||
|
||||
/* Parse command line parameters */
|
||||
static BOOL ParseCmdline(int argc, char* argv[])
|
||||
BOOL ParseCmdline(int argc, char* argv[])
|
||||
{
|
||||
INT i;
|
||||
BOOL ShowUsage;
|
||||
@@ -280,7 +278,7 @@ static BOOL ParseCmdline(int argc, char* argv[])
|
||||
}
|
||||
|
||||
/* Calculate checksum of data */
|
||||
static WORD Checksum(PUSHORT data, UINT size)
|
||||
WORD Checksum(PUSHORT data, UINT size)
|
||||
{
|
||||
ULONG sum = 0;
|
||||
|
||||
@@ -299,7 +297,7 @@ static WORD Checksum(PUSHORT data, UINT size)
|
||||
}
|
||||
|
||||
/* Prepare to ping target */
|
||||
static BOOL Setup(VOID)
|
||||
BOOL Setup(VOID)
|
||||
{
|
||||
WORD wVersionRequested;
|
||||
WSADATA WsaData;
|
||||
@@ -308,10 +306,10 @@ static BOOL Setup(VOID)
|
||||
PHOSTENT phe;
|
||||
|
||||
wVersionRequested = MAKEWORD(2, 2);
|
||||
|
||||
|
||||
Status = WSAStartup(wVersionRequested, &WsaData);
|
||||
if (Status != 0) {
|
||||
printf("Could not initialize winsock dll.\n");
|
||||
printf("Could not initialize winsock dll.\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -329,9 +327,9 @@ static BOOL Setup(VOID)
|
||||
if (phe == NULL) {
|
||||
printf("Unknown host %s.\n", TargetName);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (phe != NULL) {
|
||||
CopyMemory(&Target.sin_addr, phe->h_addr, phe->h_length);
|
||||
} else {
|
||||
@@ -343,7 +341,7 @@ static BOOL Setup(VOID)
|
||||
} else {
|
||||
Target.sin_family = AF_INET;
|
||||
}
|
||||
|
||||
|
||||
TargetIP = inet_ntoa(Target.sin_addr);
|
||||
CurrentSeqNum = 0;
|
||||
SentCount = 0;
|
||||
@@ -356,7 +354,7 @@ static BOOL Setup(VOID)
|
||||
}
|
||||
|
||||
/* Close socket */
|
||||
static VOID Cleanup(VOID)
|
||||
VOID Cleanup(VOID)
|
||||
{
|
||||
if (IcmpSock != INVALID_SOCKET)
|
||||
closesocket(IcmpSock);
|
||||
@@ -364,7 +362,7 @@ static VOID Cleanup(VOID)
|
||||
WSACleanup();
|
||||
}
|
||||
|
||||
static VOID QueryTime(PLARGE_INTEGER Time)
|
||||
VOID QueryTime(PLARGE_INTEGER Time)
|
||||
{
|
||||
if (UsePerformanceCounter) {
|
||||
if (QueryPerformanceCounter(Time) == 0) {
|
||||
@@ -386,13 +384,14 @@ static VOID QueryTime(PLARGE_INTEGER Time)
|
||||
}
|
||||
}
|
||||
|
||||
static VOID TimeToMsString(LPSTR String, LARGE_INTEGER Time)
|
||||
VOID TimeToMsString(LPSTR String, LARGE_INTEGER Time)
|
||||
{
|
||||
UINT i, Length;
|
||||
CHAR Convstr[40];
|
||||
LARGE_INTEGER LargeTime;
|
||||
|
||||
LargeTime.QuadPart = Time.QuadPart / TicksPerMs.QuadPart;
|
||||
|
||||
|
||||
_i64toa(LargeTime.QuadPart, Convstr, 10);
|
||||
strcpy(String, Convstr);
|
||||
strcat(String, "ms");
|
||||
@@ -400,7 +399,7 @@ static VOID TimeToMsString(LPSTR String, LARGE_INTEGER Time)
|
||||
|
||||
/* Locate the ICMP data and print it. Returns TRUE if the packet was good,
|
||||
FALSE if not */
|
||||
static BOOL DecodeResponse(PCHAR buffer, UINT size, PSOCKADDR_IN from)
|
||||
BOOL DecodeResponse(PCHAR buffer, UINT size, PSOCKADDR_IN from)
|
||||
{
|
||||
PIPv4_HEADER IpHeader;
|
||||
PICMP_ECHO_PACKET Icmp;
|
||||
@@ -408,7 +407,7 @@ static BOOL DecodeResponse(PCHAR buffer, UINT size, PSOCKADDR_IN from)
|
||||
CHAR Time[100];
|
||||
LARGE_INTEGER RelativeTime;
|
||||
LARGE_INTEGER LargeTime;
|
||||
CHAR Sign[2];
|
||||
CHAR Sign[1];
|
||||
|
||||
IpHeader = (PIPv4_HEADER)buffer;
|
||||
|
||||
@@ -450,26 +449,25 @@ static BOOL DecodeResponse(PCHAR buffer, UINT size, PSOCKADDR_IN from)
|
||||
}
|
||||
|
||||
|
||||
printf("Reply from %s: bytes=%d time%s%s TTL=%d\n", inet_ntoa(from->sin_addr),
|
||||
printf("Reply from %s: bytes=%d time%s%s TTL=%d\n", inet_ntoa(from->sin_addr),
|
||||
size - IphLength - sizeof(ICMP_ECHO_PACKET), Sign, Time, IpHeader->TTL);
|
||||
if (RelativeTime.QuadPart < MinRTT.QuadPart || !MinRTTSet) {
|
||||
MinRTT.QuadPart = RelativeTime.QuadPart;
|
||||
MinRTTSet = TRUE;
|
||||
if (RelativeTime.QuadPart < MinRTT.QuadPart) {
|
||||
MinRTT.QuadPart = RelativeTime.QuadPart;
|
||||
MinRTTSet = TRUE;
|
||||
}
|
||||
if (RelativeTime.QuadPart > MaxRTT.QuadPart)
|
||||
MaxRTT.QuadPart = RelativeTime.QuadPart;
|
||||
|
||||
if (RelativeTime.QuadPart > MaxRTT.QuadPart)
|
||||
MaxRTT.QuadPart = RelativeTime.QuadPart;
|
||||
SumRTT.QuadPart += RelativeTime.QuadPart;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Send and receive one ping */
|
||||
static BOOL Ping(VOID)
|
||||
BOOL Ping(VOID)
|
||||
{
|
||||
INT Status;
|
||||
SOCKADDR From;
|
||||
INT Length;
|
||||
UINT Length;
|
||||
PVOID Buffer;
|
||||
UINT Size;
|
||||
PICMP_ECHO_PACKET Packet;
|
||||
@@ -489,7 +487,7 @@ static BOOL Ping(VOID)
|
||||
Packet->Icmp.Type = ICMPMSG_ECHOREQUEST;
|
||||
Packet->Icmp.Code = 0;
|
||||
Packet->Icmp.Id = (USHORT)GetCurrentProcessId();
|
||||
Packet->Icmp.SeqNum = htons((USHORT)CurrentSeqNum);
|
||||
Packet->Icmp.SeqNum = (USHORT)CurrentSeqNum;
|
||||
Packet->Icmp.Checksum = 0;
|
||||
|
||||
/* Timestamp is part of data area */
|
||||
@@ -588,7 +586,7 @@ int main(int argc, char* argv[])
|
||||
|
||||
printf("\nPinging %s [%s] with %d bytes of data:\n\n",
|
||||
TargetName, TargetIP, DataSize);
|
||||
|
||||
|
||||
Count = 0;
|
||||
while ((NeverStop) || (Count < PingCount)) {
|
||||
Ping();
|
||||
@@ -606,7 +604,11 @@ int main(int argc, char* argv[])
|
||||
}
|
||||
|
||||
/* Calculate loss percent */
|
||||
Count = (LostCount * 100) / SentCount;
|
||||
if (LostCount > 0) {
|
||||
Count = (SentCount * 100) / LostCount;
|
||||
} else {
|
||||
Count = 0;
|
||||
}
|
||||
|
||||
if (!MinRTTSet)
|
||||
MinRTT = MaxRTT;
|
233
apps/utils/net/roshttpd/include/list.h
Normal file
233
apps/utils/net/roshttpd/include/list.h
Normal file
@@ -0,0 +1,233 @@
|
||||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS HTTP Daemon
|
||||
* FILE: include/list.h
|
||||
*/
|
||||
#ifndef __LIST_H
|
||||
#define __LIST_H
|
||||
|
||||
#include <windows.h>
|
||||
#include <iterator.h>
|
||||
|
||||
class CListNode {
|
||||
public:
|
||||
CListNode();
|
||||
CListNode(VOID *element, CListNode *next, CListNode *prev);
|
||||
~CListNode() {};
|
||||
void* operator new(/*size_t s*/ UINT s);
|
||||
VOID operator delete(void* p);
|
||||
|
||||
VOID SetElement(PVOID element);
|
||||
VOID SetNext(CListNode *next);
|
||||
VOID SetPrev(CListNode *prev);
|
||||
PVOID GetElement();
|
||||
CListNode *GetNext();
|
||||
CListNode *GetPrev();
|
||||
private:
|
||||
PVOID Element;
|
||||
CListNode *Next;
|
||||
CListNode *Prev;
|
||||
static HANDLE hHeap;
|
||||
static INT nRef;
|
||||
};
|
||||
|
||||
template <class Item> class CList {
|
||||
public:
|
||||
//CList(CList&);
|
||||
CList();
|
||||
~CList();
|
||||
CList& operator=(CList&);
|
||||
|
||||
CIterator<Item> *CreateIterator() const;
|
||||
LONG Count() const;
|
||||
Item& Get(const LONG index) const;
|
||||
// Can throw bad_alloc
|
||||
VOID Insert(Item& element);
|
||||
VOID Remove(Item& element);
|
||||
VOID RemoveAll();
|
||||
CListNode *GetHeader() const;
|
||||
CListNode *GetTrailer() const;
|
||||
private:
|
||||
CListNode *Search(Item& element) const;
|
||||
LONG NodeCount;
|
||||
CListNode *Header;
|
||||
CListNode *Trailer;
|
||||
};
|
||||
|
||||
template <class Item> class CListIterator : public CIterator<Item> {
|
||||
public:
|
||||
CListIterator(const CList<Item> *list);
|
||||
virtual VOID First();
|
||||
virtual VOID Next();
|
||||
virtual BOOL IsDone() const;
|
||||
virtual Item CurrentItem() const;
|
||||
private:
|
||||
const CList<Item> *List;
|
||||
CListNode *Current;
|
||||
};
|
||||
|
||||
// ****************************** CList ******************************
|
||||
|
||||
// Default constructor
|
||||
template <class Item>
|
||||
CList<Item>::CList()
|
||||
{
|
||||
// Create dummy nodes
|
||||
Trailer = new CListNode;
|
||||
Header = new CListNode;
|
||||
Header->SetNext(Trailer);
|
||||
Trailer->SetPrev(Header);
|
||||
}
|
||||
|
||||
// Default destructor
|
||||
template <class Item>
|
||||
CList<Item>::~CList()
|
||||
{
|
||||
RemoveAll();
|
||||
delete Trailer;
|
||||
delete Header;
|
||||
}
|
||||
|
||||
// Create an iterator for the list
|
||||
template <class Item>
|
||||
CIterator<Item> *CList<Item>::CreateIterator() const
|
||||
{
|
||||
return new CListIterator<Item>((CList<Item> *) this);
|
||||
}
|
||||
|
||||
// Return number of elements in list
|
||||
template <class Item>
|
||||
LONG CList<Item>::Count() const
|
||||
{
|
||||
return NodeCount;
|
||||
}
|
||||
|
||||
// Return element at index
|
||||
template <class Item>
|
||||
Item& CList<Item>::Get(const LONG index) const
|
||||
{
|
||||
CListNode *node;
|
||||
|
||||
if ((index < 0) || (index >= NodeCount))
|
||||
return NULL;
|
||||
|
||||
node = Header;
|
||||
for (int i = 0; i <= index; i++)
|
||||
node = node->GetNext();
|
||||
|
||||
return (Item *) node->GetElement();
|
||||
}
|
||||
|
||||
// Insert an element into the list
|
||||
template <class Item>
|
||||
VOID CList<Item>::Insert(Item& element)
|
||||
{
|
||||
CListNode *node;
|
||||
|
||||
node = new CListNode((PVOID)element, Trailer, Trailer->GetPrev());
|
||||
Trailer->GetPrev()->SetNext(node);
|
||||
Trailer->SetPrev(node);
|
||||
NodeCount++;
|
||||
}
|
||||
|
||||
// Remove an element from the list
|
||||
template <class Item>
|
||||
VOID CList<Item>::Remove(Item& element)
|
||||
{
|
||||
CListNode *node;
|
||||
|
||||
node = Search(element);
|
||||
if (node != NULL) {
|
||||
node->GetPrev()->SetNext(node->GetNext());
|
||||
node->GetNext()->SetPrev(node->GetPrev());
|
||||
NodeCount--;
|
||||
delete node;
|
||||
}
|
||||
}
|
||||
|
||||
// Remove all elements in list
|
||||
template <class Item>
|
||||
VOID CList<Item>::RemoveAll()
|
||||
{
|
||||
CListNode *node;
|
||||
CListNode *tmp;
|
||||
|
||||
node = Header->GetNext();
|
||||
while (node != Trailer) {
|
||||
tmp = node->GetNext();
|
||||
delete node;
|
||||
node = tmp;
|
||||
}
|
||||
Header->SetNext(Trailer);
|
||||
Trailer->SetPrev(Header);
|
||||
NodeCount = 0;
|
||||
}
|
||||
|
||||
// Return header node
|
||||
template <class Item>
|
||||
CListNode *CList<Item>::GetHeader() const
|
||||
{
|
||||
return Header;
|
||||
}
|
||||
|
||||
// Return trailer node
|
||||
template <class Item>
|
||||
CListNode *CList<Item>::GetTrailer() const
|
||||
{
|
||||
return Trailer;
|
||||
}
|
||||
|
||||
// Searches for a node that contains the element. Returns NULL if element is not found
|
||||
template <class Item>
|
||||
CListNode *CList<Item>::Search(Item& element) const
|
||||
{
|
||||
CListNode *node;
|
||||
|
||||
node = Header;
|
||||
while (((node = node->GetNext()) != Trailer) && (node->GetElement() != element));
|
||||
if (node != Trailer)
|
||||
return node;
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
// ************************** CListIterator **************************
|
||||
|
||||
// Default constructor
|
||||
template <class Item>
|
||||
CListIterator<Item>::CListIterator(const CList<Item> *list) : List(list)
|
||||
{
|
||||
First();
|
||||
}
|
||||
|
||||
// Go to first element in list
|
||||
template <class Item>
|
||||
VOID CListIterator<Item>::First()
|
||||
{
|
||||
Current = List->GetHeader()->GetNext();
|
||||
}
|
||||
|
||||
// Go to next element in list
|
||||
template <class Item>
|
||||
VOID CListIterator<Item>::Next()
|
||||
{
|
||||
if (!IsDone())
|
||||
Current = Current->GetNext();
|
||||
}
|
||||
|
||||
// Return FALSE when there are more elements in list and TRUE when there are no more
|
||||
template <class Item>
|
||||
BOOL CListIterator<Item>::IsDone() const
|
||||
{
|
||||
return (Current == List->GetTrailer());
|
||||
}
|
||||
|
||||
// Return current element
|
||||
template <class Item>
|
||||
Item CListIterator<Item>::CurrentItem() const
|
||||
{
|
||||
return IsDone()? NULL : (Item) Current->GetElement();
|
||||
}
|
||||
|
||||
#endif /* __LIST_H */
|
31
apps/utils/net/roshttpd/makefile
Normal file
31
apps/utils/net/roshttpd/makefile
Normal file
@@ -0,0 +1,31 @@
|
||||
# $Id$
|
||||
|
||||
PATH_TO_TOP = ../../../..
|
||||
|
||||
TARGET_PATH = common
|
||||
|
||||
TARGET_TYPE = program
|
||||
|
||||
TARGET_APPTYPE = console
|
||||
|
||||
TARGET_NAME = roshttpd
|
||||
|
||||
TARGET_CPPFLAGS = -I./include -DUNICODE -D_UNICODE -DDBG -D__USE_W32API -Wno-deprecated
|
||||
|
||||
TARGET_GCCLIBS = stdc++
|
||||
|
||||
TARGET_SDKLIBS = kernel32.a ws2_32.a user32.a
|
||||
|
||||
MAIN_OBJECTS = roshttpd.o config.o error.o http.o httpd.o
|
||||
|
||||
COMMON_OBJECTS = common/list.o common/socket.o common/thread.o
|
||||
|
||||
TARGET_OBJECTS = $(MAIN_OBJECTS) $(COMMON_OBJECTS)
|
||||
|
||||
TARGET_CLEAN = common/*.o
|
||||
|
||||
include $(PATH_TO_TOP)/rules.mak
|
||||
|
||||
include $(TOOLS_PATH)/helper.mk
|
||||
|
||||
# EOF
|
19
apps/utils/net/route/makefile
Normal file
19
apps/utils/net/route/makefile
Normal file
@@ -0,0 +1,19 @@
|
||||
PATH_TO_TOP = ../../../..
|
||||
|
||||
TARGET_TYPE = program
|
||||
|
||||
TARGET_APPTYPE = console
|
||||
|
||||
TARGET_NAME = route
|
||||
|
||||
TARGET_INSTALLDIR = system32
|
||||
|
||||
TARGET_SDKLIBS = ws2_32.a iphlpapi.a ntdll.a
|
||||
|
||||
TARGET_OBJECTS = $(TARGET_NAME).o
|
||||
|
||||
TARGET_GCCLIBS =
|
||||
|
||||
include $(PATH_TO_TOP)/rules.mak
|
||||
|
||||
include $(TOOLS_PATH)/helper.mk
|
157
apps/utils/net/route/route.c
Normal file
157
apps/utils/net/route/route.c
Normal file
@@ -0,0 +1,157 @@
|
||||
/* Poor man's route
|
||||
*
|
||||
* Supported commands:
|
||||
*
|
||||
* "print"
|
||||
* "add" target ["mask" mask] gw ["metric" metric]
|
||||
* "delete" target gw
|
||||
*
|
||||
* Goals:
|
||||
*
|
||||
* Flexible, simple
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <windows.h>
|
||||
#include <iphlpapi.h>
|
||||
#include <winsock2.h>
|
||||
|
||||
#define IPBUF 17
|
||||
#define IN_ADDR_OF(x) *((struct in_addr *)&(x))
|
||||
|
||||
int usage() {
|
||||
fprintf( stderr,
|
||||
"route usage:\n"
|
||||
"route print\n"
|
||||
" prints the route table\n"
|
||||
"route add <target> [mask <mask>] <gw> [metric <m>]\n"
|
||||
" adds a route\n"
|
||||
"route delete <target> <gw>\n"
|
||||
" deletes a route\n" );
|
||||
return 1;
|
||||
}
|
||||
|
||||
int print_routes() {
|
||||
PMIB_IPFORWARDTABLE IpForwardTable;
|
||||
DWORD Error;
|
||||
ULONG Size = 0;
|
||||
char Destination[IPBUF], Gateway[IPBUF], Netmask[IPBUF],
|
||||
Index[IPBUF], Metric[IPBUF];
|
||||
int i;
|
||||
|
||||
if( (Error = GetIpForwardTable( NULL, &Size, TRUE )) ==
|
||||
ERROR_INSUFFICIENT_BUFFER ) {
|
||||
IpForwardTable = malloc( Size );
|
||||
Error = GetIpForwardTable( IpForwardTable, &Size, TRUE );
|
||||
}
|
||||
|
||||
if( Error == ERROR_SUCCESS ) {
|
||||
printf( "%-16s%-16s%-16s%-10s%-10s\n",
|
||||
"Destination",
|
||||
"Netmask",
|
||||
"Gateway",
|
||||
"Index",
|
||||
"Metric" );
|
||||
for( i = 0; i < IpForwardTable->dwNumEntries; i++ ) {
|
||||
strcpy( Destination,
|
||||
inet_ntoa( IN_ADDR_OF(IpForwardTable->table[i].
|
||||
dwForwardDest) ) );
|
||||
strcpy( Netmask,
|
||||
inet_ntoa( IN_ADDR_OF(IpForwardTable->table[i].
|
||||
dwForwardMask) ) );
|
||||
strcpy( Gateway,
|
||||
inet_ntoa( IN_ADDR_OF(IpForwardTable->table[i].
|
||||
dwForwardNextHop) ) );
|
||||
|
||||
printf( "%-16s%-16s%-16s%-10d%-10d\n",
|
||||
Destination,
|
||||
Netmask,
|
||||
Gateway,
|
||||
IpForwardTable->table[i].dwForwardIfIndex,
|
||||
IpForwardTable->table[i].dwForwardMetric1 );
|
||||
}
|
||||
|
||||
free( IpForwardTable );
|
||||
|
||||
return ERROR_SUCCESS;
|
||||
} else {
|
||||
fprintf( stderr, "Route enumerate failed\n" );
|
||||
return Error;
|
||||
}
|
||||
}
|
||||
|
||||
int convert_add_cmd_line( PMIB_IPFORWARDROW RowToAdd,
|
||||
int argc, char **argv ) {
|
||||
int i;
|
||||
|
||||
if( argc > 1 ) RowToAdd->dwForwardDest = inet_addr( argv[0] );
|
||||
else return FALSE;
|
||||
for( i = 1; i < argc; i++ ) {
|
||||
if( !strcasecmp( argv[i], "mask" ) ) {
|
||||
i++; if( i >= argc ) return FALSE;
|
||||
RowToAdd->dwForwardMask = inet_addr( argv[i] );
|
||||
} else if( !strcasecmp( argv[i], "metric" ) ) {
|
||||
i++; if( i >= argc ) return FALSE;
|
||||
RowToAdd->dwForwardMetric1 = atoi( argv[i] );
|
||||
} else {
|
||||
RowToAdd->dwForwardNextHop = inet_addr( argv[i] );
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int add_route( int argc, char **argv ) {
|
||||
MIB_IPFORWARDROW RowToAdd = { 0 };
|
||||
DWORD Error;
|
||||
|
||||
if( argc < 2 || !convert_add_cmd_line( &RowToAdd, argc, argv ) ) {
|
||||
fprintf( stderr,
|
||||
"route add usage:\n"
|
||||
"route add <target> [mask <mask>] <gw> [metric <m>]\n"
|
||||
" Adds a route to the IP route table.\n"
|
||||
" <target> is the network or host to add a route to.\n"
|
||||
" <mask> is the netmask to use (autodetected if unspecified)\n"
|
||||
" <gw> is the gateway to use to access the network\n"
|
||||
" <m> is the metric to use (lower is preferred)\n" );
|
||||
return 1;
|
||||
}
|
||||
|
||||
if( (Error = CreateIpForwardEntry( &RowToAdd )) == ERROR_SUCCESS )
|
||||
return 0;
|
||||
|
||||
fprintf( stderr, "Route addition failed\n" );
|
||||
return Error;
|
||||
}
|
||||
|
||||
int del_route( int argc, char **argv ) {
|
||||
MIB_IPFORWARDROW RowToDel = { 0 };
|
||||
DWORD Error;
|
||||
|
||||
if( argc < 2 || !convert_add_cmd_line( &RowToDel, argc, argv ) ) {
|
||||
fprintf( stderr,
|
||||
"route delete usage:\n"
|
||||
"route delete <target> <gw>\n"
|
||||
" Removes a route from the IP route table.\n"
|
||||
" <target> is the network or host to add a route to.\n"
|
||||
" <gw> is the gateway to remove the route from.\n" );
|
||||
return 1;
|
||||
}
|
||||
|
||||
if( (Error = DeleteIpForwardEntry( &RowToDel )) == ERROR_SUCCESS )
|
||||
return 0;
|
||||
|
||||
fprintf( stderr, "Route addition failed\n" );
|
||||
return Error;
|
||||
}
|
||||
|
||||
int main( int argc, char **argv ) {
|
||||
if( argc < 2 ) return usage();
|
||||
else if( !strcasecmp( argv[1], "print" ) )
|
||||
return print_routes();
|
||||
else if( !strcasecmp( argv[1], "add" ) )
|
||||
return add_route( argc-2, argv+2 );
|
||||
else if( !strcasecmp( argv[1], "delete" ) )
|
||||
return del_route( argc-2, argv+2 );
|
||||
else return usage();
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user