mirror of
https://github.com/reactos/reactos
synced 2025-10-08 09:22:51 +02:00
Compare commits
293 Commits
SVN
...
backups/ex
Author | SHA1 | Date | |
---|---|---|---|
|
9e0b1f1383 | ||
|
b0891d210c | ||
|
aa898e0ba2 | ||
|
68e05d3a8e | ||
|
19a3f56aa7 | ||
|
bebd1855ee | ||
|
395064be78 | ||
|
d31a52e423 | ||
|
b8ed66e011 | ||
|
1141d723c3 | ||
|
5468d049be | ||
|
222cd13d93 | ||
|
0edd21e67f | ||
|
2b7c8d6391 | ||
|
bc33e47045 | ||
|
e247c380dd | ||
|
da5e391c9c | ||
|
e8d6b09951 | ||
|
85cffe692b | ||
|
40847c3fd3 | ||
|
f68079aff3 | ||
|
8a991b772f | ||
|
bb2592ba58 | ||
|
6aa3e62e96 | ||
|
530cd953b8 | ||
|
a0b2f40b73 | ||
|
f387572e84 | ||
|
edc6b71a42 | ||
|
a30c1830c0 | ||
|
d0a2f448f4 | ||
|
030b0867f6 | ||
|
af3dff11b7 | ||
|
56efa291ee | ||
|
8d5fa22d0a | ||
|
0918733dc9 | ||
|
b5c55ab4de | ||
|
e6464bc179 | ||
|
e0adece65b | ||
|
95ba8cd118 | ||
|
1eb8f5f55d | ||
|
4b208cd9ff | ||
|
d8fda17a06 | ||
|
19c59e79f0 | ||
|
5c7b628714 | ||
|
5a27206097 | ||
|
fb6e28b8a0 | ||
|
70a623f0d2 | ||
|
561f4090e1 | ||
|
1f84743388 | ||
|
8d07772195 | ||
|
f887ae590d | ||
|
6ce344b434 | ||
|
54b6cbb3a2 | ||
|
7fb581fc0b | ||
|
e620ebee7f | ||
|
73c479f923 | ||
|
72a6852583 | ||
|
eabf3955a8 | ||
|
85527b3aaa | ||
|
fe687a094d | ||
|
742527875b | ||
|
4702ede529 | ||
|
011cd29d57 | ||
|
b885ecfa57 | ||
|
5c84018967 | ||
|
29ca1c4689 | ||
|
0afc3c7bef | ||
|
2ab1b0f2e1 | ||
|
c1746abda0 | ||
|
8fd760ac87 | ||
|
2a03d2626d | ||
|
31629a61a5 | ||
|
f98b6e4125 | ||
|
75b87b9d2c | ||
|
aeaad43c1d | ||
|
6947ecd976 | ||
|
df756bcc24 | ||
|
2929a492fd | ||
|
5e6907f665 | ||
|
325d499971 | ||
|
5637b9f123 | ||
|
ad6ee8a5e1 | ||
|
c7d2525d45 | ||
|
ec137eeb0e | ||
|
0a7494dd76 | ||
|
de8627877c | ||
|
b8e8ef8580 | ||
|
742da9ba73 | ||
|
cf16395eac | ||
|
a042459d87 | ||
|
6dbed13c78 | ||
|
2c65e4355d | ||
|
c0a9a2be94 | ||
|
014a3fa6f0 | ||
|
5848b2d8e9 | ||
|
f5daa985c6 | ||
|
7d7661d52d | ||
|
8a3239aef3 | ||
|
2637be230f | ||
|
baf1b20d76 | ||
|
a366210998 | ||
|
d6f646a37f | ||
|
3ce0266401 | ||
|
f0c39c8ec6 | ||
|
9e8fbcf903 | ||
|
e008fd8fc6 | ||
|
a2189e5e4b | ||
|
019137fd50 | ||
|
528b35b1df | ||
|
e228aadfe5 | ||
|
f31ecfbd4a | ||
|
5ccc6ee89d | ||
|
f8b923d236 | ||
|
647e34dd0c | ||
|
d33004b441 | ||
|
3d5ec80a67 | ||
|
6801048d57 | ||
|
b0c84d931e | ||
|
f8d9c5d204 | ||
|
be7247ba17 | ||
|
a91d61b02e | ||
|
6f39b3e0e0 | ||
|
76fbb4d0bf | ||
|
7537381804 | ||
|
00e2091fd8 | ||
|
49592c9234 | ||
|
d1a5b105f2 | ||
|
ab8ef4b325 | ||
|
4e4b7cff0b | ||
|
7671e20ce8 | ||
|
f671eb9004 | ||
|
ad60ddbca6 | ||
|
2b9f762918 | ||
|
ff4ae27d2f | ||
|
c645e0d34c | ||
|
f765c59019 | ||
|
4dba0925ac | ||
|
ddd07cb377 | ||
|
c0ba0ea090 | ||
|
d61f6e4c18 | ||
|
fca5c9e765 | ||
|
c0f005d179 | ||
|
2981f57ae6 | ||
|
db2f53dc81 | ||
|
d8b3bb21d1 | ||
|
8caac8b834 | ||
|
e6258f2fa1 | ||
|
d2cca7e010 | ||
|
708b29556c | ||
|
34bf6de206 | ||
|
8c065412f4 | ||
|
b06887c39a | ||
|
27780dc59a | ||
|
abd7686a78 | ||
|
57cef8643d | ||
|
352d524633 | ||
|
a3e3b56cca | ||
|
22244655d6 | ||
|
366252dce4 | ||
|
edc694086f | ||
|
c60fc95e69 | ||
|
d9b4e88284 | ||
|
a4b36e0224 | ||
|
1de5b28f80 | ||
|
28f15433b0 | ||
|
fb1c02d7d1 | ||
|
896ba320b8 | ||
|
5e976e5bad | ||
|
41c18f8e50 | ||
|
10763448ee | ||
|
0f86e212b1 | ||
|
91fc5d1804 | ||
|
b429ae3287 | ||
|
d222bec89c | ||
|
e9c2a13f25 | ||
|
01efd62aff | ||
|
8c1121a5be | ||
|
c60f00807e | ||
|
afbaa12f82 | ||
|
f862727d03 | ||
|
3e2aa03dcf | ||
|
f6466c9edd | ||
|
dd387c42f0 | ||
|
724fce9fd9 | ||
|
e6f2a2f607 | ||
|
7581cc7fb9 | ||
|
59aa5bd203 | ||
|
2644fdc88a | ||
|
d57bd697fd | ||
|
b685e5d6be | ||
|
9837438cb2 | ||
|
d7a8b29d38 | ||
|
100e13b72c | ||
|
81426398fc | ||
|
6299fc1186 | ||
|
b6b2885037 | ||
|
c3b38401e3 | ||
|
f264388c30 | ||
|
b0b4ad8a28 | ||
|
d062e3d562 | ||
|
9b48875031 | ||
|
3be1a720e8 | ||
|
28dff13100 | ||
|
6a5aa2060e | ||
|
38c0b28279 | ||
|
2ee2dcfd7e | ||
|
863fb4e364 | ||
|
1c648feae0 | ||
|
e4f12e6d99 | ||
|
21a0462b92 | ||
|
292272eff4 | ||
|
88c78cbdd8 | ||
|
9e8add4928 | ||
|
4cffccfe6f | ||
|
6bd1cc19a3 | ||
|
38d12a5ce6 | ||
|
adecdb10c6 | ||
|
b95c9c0eba | ||
|
2e5a5b050c | ||
|
879287ceb0 | ||
|
b167684edc | ||
|
576224deec | ||
|
1dc7aa3d70 | ||
|
7060a9893e | ||
|
2d760db23f | ||
|
37d9e18817 | ||
|
635e37f654 | ||
|
aaa5b3b1d4 | ||
|
f0b1beeb8a | ||
|
095823bec8 | ||
|
8f33dd1b68 | ||
|
b9378b35ed | ||
|
67fe83b228 | ||
|
cd9f2f7964 | ||
|
849dcb1be9 | ||
|
d5882cfd80 | ||
|
56f3b59cfb | ||
|
7510a729c6 | ||
|
b11715e1ab | ||
|
7b174da1fd | ||
|
a32ae2ed8f | ||
|
9311f8ddc4 | ||
|
1464aa0ecb | ||
|
73e868d565 | ||
|
438aa3123b | ||
|
9274918700 | ||
|
97b9077773 | ||
|
f68f38c2cc | ||
|
15b937dfec | ||
|
0cfb700271 | ||
|
5a0eafb788 | ||
|
5e732eb747 | ||
|
449ae7cef2 | ||
|
552bbfd1a5 | ||
|
c57663f076 | ||
|
11e2ec38d3 | ||
|
1b515d5749 | ||
|
dc540e8946 | ||
|
038eebbf4e | ||
|
0004a79f81 | ||
|
995dc47fd0 | ||
|
b622dd0602 | ||
|
5bcd5409f3 | ||
|
231d02b6af | ||
|
0069d808c0 | ||
|
9bc23e307d | ||
|
d2b43c9093 | ||
|
448e644f09 | ||
|
d8a1cb88e7 | ||
|
eaf65abccd | ||
|
c270c6db34 | ||
|
53af5ece75 | ||
|
da5c413758 | ||
|
412382b514 | ||
|
c606eeb39a | ||
|
329aa380dd | ||
|
811db616d2 | ||
|
3d47600ac9 | ||
|
7b0b16d102 | ||
|
672316dd13 | ||
|
13db281fa1 | ||
|
0b58caa931 | ||
|
7019e45c1e | ||
|
560189fa51 | ||
|
e0004d8405 | ||
|
2e2a9d4897 | ||
|
6b36db792e | ||
|
12ee80de00 | ||
|
cd7253e298 | ||
|
6e2fe87e5c | ||
|
f8179ef1d9 | ||
|
8fabf8b0ad | ||
|
3a156b0bac |
@@ -1,3 +0,0 @@
|
||||
*.exe
|
||||
*.bin
|
||||
*.h
|
@@ -1,413 +0,0 @@
|
||||
#
|
||||
# FreeLoader
|
||||
# Copyright (C) 1998-2002 Brian Palmer <brianp@sginet.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
#
|
||||
|
||||
#############################################
|
||||
# CHANGE THESE FOR YOUR OUTPUT
|
||||
#
|
||||
TARGET = i386
|
||||
ifeq ($(DEBUG),)
|
||||
# Debugging information on (bigger binary)
|
||||
#DEBUG = yes
|
||||
# Debugging information off (smaller binary)
|
||||
DEBUG = no
|
||||
endif
|
||||
|
||||
OBJDIR = obj
|
||||
OUTPUT_DIR = $(OBJDIR)/$(TARGET)
|
||||
|
||||
BOOTCD_DIR = ../../bootcd
|
||||
|
||||
#############################################
|
||||
# COMPILER AND LINKER PROGRAMS
|
||||
#
|
||||
TOOLSDIR = $(SRCDIR)/../tools
|
||||
|
||||
RM = $(subst /,$(SEP),$(TOOLSDIR))$(SEP)rdel
|
||||
CP = $(subst /,$(SEP),$(TOOLSDIR))$(SEP)rcopy
|
||||
MKDIR = $(subst /,$(SEP),$(TOOLSDIR))$(SEP)rmkdir
|
||||
RMDIR = $(subst /,$(SEP),$(TOOLSDIR))$(SEP)rrmdir
|
||||
OBJCOPY = objcopy
|
||||
NM = nm
|
||||
OBJDUMP = objdump
|
||||
DEPTOOL = $(subst /,$(SEP),$(TOOLSDIR))$(SEP)deptool
|
||||
HOSTTOOL = $(subst /,$(SEP),$(TOOLSDIR))$(SEP)hosttype
|
||||
TOOLS = $(DEPTOOL) $(HOSTTOOL)
|
||||
|
||||
HOSTTYPE = $(shell $(HOSTTOOL))
|
||||
|
||||
#-----------------------------------------------------------------------------------------------------
|
||||
# TEST IF WE ARE IN THE TARGET DIRECTORY
|
||||
# IF NOT WE WILL CHANGE TO THE TARGET DIRECTORY AND RUN MAKE FROM THERE
|
||||
#-----------------------------------------------------------------------------------------------------
|
||||
#ifeq (,$(filter $(CURDIR)/$(OUTPUT_DIR),$(notdir $(CURDIR))))
|
||||
ifneq ($(CURDIR), $(SRCDIR)/$(OUTPUT_DIR))
|
||||
|
||||
SRCDIR = $(CURDIR)
|
||||
|
||||
.SUFFIXES:
|
||||
|
||||
#############################################
|
||||
# VARIABLE TO CHANGE TO TARGET DIRECTORY AND INVOKE MAKE FROM THERE
|
||||
#
|
||||
MAKETARGET = $(MAKE) --no-print-directory -C $(OUTPUT_DIR) \
|
||||
-f ../../Makefile SRCDIR=$(CURDIR) $(MAKECMDGOALS)
|
||||
|
||||
.PHONY: CHANGE_TO_TARGET
|
||||
CHANGE_TO_TARGET setupldr : BUILD_TOOLS $(OBJDIR) $(OBJDIR)/$(TARGET)
|
||||
@echo Calculating source file dependencies...
|
||||
+@$(MAKETARGET)
|
||||
|
||||
.PHONY: BUILD_TOOLS
|
||||
BUILD_TOOLS:
|
||||
@$(MAKE) --no-print-directory -C $(TOOLSDIR)
|
||||
|
||||
$(OBJDIR):
|
||||
@echo Creating directory: $(OBJDIR)
|
||||
@$(MKDIR) $(OBJDIR)
|
||||
|
||||
$(OBJDIR)/$(TARGET): $(OBJDIR)
|
||||
@echo Creating directory: $(OBJDIR)/$(TARGET)
|
||||
@$(MKDIR) $(OBJDIR)/$(TARGET)
|
||||
|
||||
|
||||
Makefile : ;
|
||||
|
||||
% :: CHANGE_TO_TARGET
|
||||
|
||||
#############################################
|
||||
|
||||
.PHONY : clean
|
||||
clean:
|
||||
@$(MAKE) --no-print-directory -C $(TOOLSDIR)
|
||||
@echo Cleaning directory $(OBJDIR)/$(TARGET)
|
||||
@-$(RM) $(OBJDIR)/$(TARGET)/*
|
||||
@echo Removing directory $(OBJDIR)/$(TARGET)
|
||||
@-$(RMDIR) $(OBJDIR)/$(TARGET)
|
||||
@-$(RMDIR) $(OBJDIR)
|
||||
@echo Clean ALL done.
|
||||
|
||||
#############################################
|
||||
|
||||
.PHONY : bootcd
|
||||
bootcd : bootcd_dirs setup_loader boot_loader
|
||||
|
||||
.PHONY : bootcd_dirs
|
||||
bootcd_dirs:
|
||||
$(MKDIR) $(BOOTCD_DIR)
|
||||
$(MKDIR) $(BOOTCD_DIR)/disk
|
||||
$(MKDIR) $(BOOTCD_DIR)/disk/reactos
|
||||
$(MKDIR) $(BOOTCD_DIR)/disk/install
|
||||
$(MKDIR) $(BOOTCD_DIR)/disk/bootdisk
|
||||
$(MKDIR) $(BOOTCD_DIR)/disk/loader
|
||||
|
||||
.PHONY : boot_loader
|
||||
boot_loader : $(OBJDIR)/$(TARGET)/freeldr.sys
|
||||
$(CP) $(OBJDIR)/$(TARGET)/freeldr.sys $(BOOTCD_DIR)/disk/loader/freeldr.sys
|
||||
$(CP) ../freeldr.ini $(BOOTCD_DIR)/disk/loader/freeldr.ini
|
||||
|
||||
.PHONY : setup_loader
|
||||
setup_loader : $(OBJDIR)/$(TARGET)/setupldr.sys
|
||||
$(CP) $(OBJDIR)/$(TARGET)/setupldr.sys $(BOOTCD_DIR)/disk/loader/setupldr.sys
|
||||
|
||||
#############################################
|
||||
|
||||
#-----------------------------------------------------------------------------------------------------
|
||||
# END MAGIC TARGET DIRECTORY CHANGE STUFF
|
||||
#-----------------------------------------------------------------------------------------------------
|
||||
else
|
||||
|
||||
#############################################
|
||||
# COMPILER COMMAND LINE OPTIONS
|
||||
#
|
||||
COMPILER_OPTIONS = -Wall -Werror -nostdlib -nostdinc -ffreestanding -fno-builtin -fno-inline \
|
||||
-fno-zero-initialized-in-bss -O1 -MD
|
||||
# FreeLoader does not use any of the standard libraries, includes, or built-in functions
|
||||
|
||||
#############################################
|
||||
# COMPILER DEFINES
|
||||
#
|
||||
ifeq ($(DEBUG),yes)
|
||||
COMPILER_DEBUG_DEFINES = -DDEBUG
|
||||
else
|
||||
COMPILER_DEBUG_DEFINES =
|
||||
endif
|
||||
|
||||
COMPILER_DEFINES = -D__$(TARGET)__ $(COMPILER_DEBUG_DEFINES)
|
||||
|
||||
#############################################
|
||||
# INCLUDE DIRECTORY OPTIONS
|
||||
#
|
||||
COMPILER_INCLUDES = -I$(SRCDIR)/include
|
||||
|
||||
#############################################
|
||||
# COMPILER FLAGS
|
||||
#
|
||||
CFLAGS = $(COMPILER_OPTIONS) \
|
||||
$(COMPILER_DEFINES) \
|
||||
$(COMPILER_INCLUDES)
|
||||
|
||||
#############################################
|
||||
# LINKER COMMAND LINE OPTIONS
|
||||
#
|
||||
#LINKER_OPTIONS = -N -Ttext=0x8000 --oformat=binary -s
|
||||
LINKER_OPTIONS = -N -Ttext=0x8000
|
||||
|
||||
#############################################
|
||||
# LINKER FLAGS
|
||||
#
|
||||
LFLAGS = $(LINKER_OPTIONS)
|
||||
|
||||
#############################################
|
||||
# NASM FLAGS
|
||||
#
|
||||
ifeq ($(HOSTTYPE), dos)
|
||||
NASMFLAGS = -f coff
|
||||
else
|
||||
ifeq ($(HOSTTYPE), win32)
|
||||
NASMFLAGS = -f win32
|
||||
else
|
||||
NASMFLAGS = -f elf
|
||||
endif
|
||||
endif
|
||||
|
||||
#############################################
|
||||
# LIST ALL THE OBJECT FILE GROUPS
|
||||
#
|
||||
# fathelp.o must come first in the link line because it contains bootsector helper code
|
||||
# arch.o must come second in the link line because it contains the startup code
|
||||
ARCH_OBJS = fathelp.o \
|
||||
arch.o \
|
||||
i386idt.o \
|
||||
i386trap.o \
|
||||
i386cpu.o \
|
||||
i386pnp.o \
|
||||
boot.o \
|
||||
linux.o \
|
||||
mb.o \
|
||||
i386rtl.o \
|
||||
i386vid.o \
|
||||
drvmap.o \
|
||||
int386.o \
|
||||
i386disk.o \
|
||||
portio.o \
|
||||
hardware.o \
|
||||
hwacpi.o \
|
||||
hwapm.o \
|
||||
hwcpu.o \
|
||||
hwpci.o \
|
||||
archmach.o \
|
||||
machpc.o \
|
||||
machxbox.o \
|
||||
pccons.o \
|
||||
pcdisk.o \
|
||||
pcmem.o \
|
||||
pcrtc.o \
|
||||
pcvideo.o \
|
||||
xboxcons.o \
|
||||
xboxdisk.o \
|
||||
xboxfont.o \
|
||||
xboxhw.o \
|
||||
xboxmem.o \
|
||||
xboxrtc.o \
|
||||
xboxvideo.o \
|
||||
_alloca.o # For Mingw32 builds
|
||||
|
||||
|
||||
RTL_OBJS = print.o \
|
||||
stdlib.o \
|
||||
string.o \
|
||||
list.o \
|
||||
memcmp.o \
|
||||
memcpy.o \
|
||||
memmove.o \
|
||||
memset.o
|
||||
|
||||
FS_OBJS = fs.o \
|
||||
fat.o \
|
||||
iso.o \
|
||||
ext2.o \
|
||||
ntfs.o \
|
||||
fsrec.o
|
||||
|
||||
UI_OBJS = tui.o \
|
||||
tuimenu.o \
|
||||
ui.o \
|
||||
gui.o
|
||||
|
||||
REACTOS_OBJS= arcname.o \
|
||||
binhive.o \
|
||||
registry.o
|
||||
|
||||
COMM_OBJS = rs232.o
|
||||
|
||||
DISK_OBJS = disk.o \
|
||||
partition.o
|
||||
|
||||
MM_OBJS = mm.o \
|
||||
meminit.o
|
||||
|
||||
CACHE_OBJS = cache.o \
|
||||
blocklist.o
|
||||
|
||||
INIFILE_OBJS= inifile.o \
|
||||
ini_init.o \
|
||||
parse.o
|
||||
|
||||
INFFILE_OBJS= inffile.o
|
||||
|
||||
VIDEO_OBJS = video.o \
|
||||
fade.o \
|
||||
palette.o \
|
||||
pixel.o \
|
||||
bank.o
|
||||
|
||||
# libgcc2.o contains code (__udivdi3, __umoddi3) necessary to do
|
||||
# 64-bit division on the i386 (and other 32-bit) architectures
|
||||
# This code was taken from the GCC v3.1 source
|
||||
MATH_OBJS = libgcc2.o
|
||||
|
||||
BASE_OBJS = freeldr.o \
|
||||
debug.o \
|
||||
multiboot.o \
|
||||
version.o \
|
||||
cmdline.o \
|
||||
machine.o
|
||||
|
||||
FREELDR_OBJS= bootmgr.o \
|
||||
drivemap.o \
|
||||
miscboot.o \
|
||||
options.o \
|
||||
linuxboot.o \
|
||||
oslist.o \
|
||||
custom.o
|
||||
|
||||
ROSLDR_OBJS = reactos.o
|
||||
|
||||
SETUPLDR_OBJS= setupldr.o
|
||||
|
||||
COMMON_OBJS = $(ARCH_OBJS) \
|
||||
$(RTL_OBJS) \
|
||||
$(FS_OBJS) \
|
||||
$(UI_OBJS) \
|
||||
$(REACTOS_OBJS) \
|
||||
$(COMM_OBJS) \
|
||||
$(DISK_OBJS) \
|
||||
$(MM_OBJS) \
|
||||
$(CACHE_OBJS) \
|
||||
$(VIDEO_OBJS) \
|
||||
$(MATH_OBJS) \
|
||||
$(BASE_OBJS)
|
||||
|
||||
SPECIAL_OBJS = $(INIFILE_OBJS) \
|
||||
$(INFFILE_OBJS) \
|
||||
$(FREELDR_OBJS) \
|
||||
$(ROSLDR_OBJS) \
|
||||
$(SETUPLDR_OBJS)
|
||||
|
||||
|
||||
F_OBJS = $(COMMON_OBJS) \
|
||||
$(INIFILE_OBJS) \
|
||||
$(ROSLDR_OBJS) \
|
||||
$(FREELDR_OBJS)
|
||||
|
||||
S_OBJS = $(COMMON_OBJS) \
|
||||
$(INIFILE_OBJS) \
|
||||
$(INFFILE_OBJS) \
|
||||
$(SETUPLDR_OBJS)
|
||||
|
||||
|
||||
#############################################
|
||||
# ALL THE OBJECTS
|
||||
#
|
||||
ALL_OBJS = $(COMMON_OBJS) \
|
||||
$(SPECIAL_OBJS)
|
||||
|
||||
|
||||
#############################################
|
||||
# SET THE VPATH SO MAKE CAN FIND THE SOURCE FILES
|
||||
#
|
||||
VPATH = $(SRCDIR)/ \
|
||||
$(SRCDIR)/arch/$(TARGET) \
|
||||
$(SRCDIR)/rtl \
|
||||
$(SRCDIR)/fs \
|
||||
$(SRCDIR)/ui \
|
||||
$(SRCDIR)/reactos \
|
||||
$(SRCDIR)/comm \
|
||||
$(SRCDIR)/disk \
|
||||
$(SRCDIR)/mm \
|
||||
$(SRCDIR)/cache \
|
||||
$(SRCDIR)/inifile \
|
||||
$(SRCDIR)/inffile \
|
||||
$(SRCDIR)/video \
|
||||
$(SRCDIR)/math \
|
||||
$(SRCDIR)/include
|
||||
|
||||
#############################################
|
||||
|
||||
all : freeldr.sys setupldr.sys
|
||||
@echo Make ALL done.
|
||||
|
||||
#############################################
|
||||
|
||||
freeldr.sys : $(ALL_OBJS)
|
||||
@echo ===================================================== LINKING $@
|
||||
@$(LD) $(LFLAGS) -o freeldr.exe $(F_OBJS)
|
||||
ifeq ($(FULL_MAP),yes)
|
||||
@$(OBJDUMP) -d -S freeldr.exe > freeldr.map
|
||||
else
|
||||
@$(NM) --numeric-sort freeldr.exe > freeldr.map
|
||||
endif
|
||||
@$(OBJCOPY) -O binary freeldr.exe freeldr.sys
|
||||
|
||||
#############################################
|
||||
|
||||
setupldr.sys : $(ALL_OBJS)
|
||||
@echo ===================================================== LINKING $@
|
||||
@$(LD) $(LFLAGS) -Map setupldr.map -o setupldr.exe $(S_OBJS)
|
||||
ifeq ($(FULL_MAP),yes)
|
||||
@$(OBJDUMP) -d -S setupldr.exe > setupldr.map
|
||||
else
|
||||
@$(NM) --numeric-sort setupldr.exe > setupldr.map
|
||||
endif
|
||||
@$(OBJCOPY) -O binary setupldr.exe setupldr.sys
|
||||
|
||||
#############################################
|
||||
|
||||
%.o :: %.c
|
||||
@echo ===================================================== Compiling $*
|
||||
@$(CC) $(CFLAGS) -o $@ -c $<
|
||||
@$(DEPTOOL) $*.d
|
||||
|
||||
%.o :: %.S
|
||||
@echo ===================================================== Assembling $*
|
||||
@$(CC) $(CFLAGS) -o $@ -c $<
|
||||
@$(DEPTOOL) $*.d
|
||||
|
||||
%.o :: %.asm
|
||||
@echo ===================================================== Assembling $*
|
||||
@$(NASM_CMD) $(NASMFLAGS) -o $@ $<
|
||||
|
||||
#############################################
|
||||
|
||||
# Include the automagically generated dependencies
|
||||
-include $(ALL_OBJS:%.o=%.d)
|
||||
|
||||
#############################################
|
||||
|
||||
endif
|
@@ -1,47 +0,0 @@
|
||||
.EXPORT_ALL_VARIABLES:
|
||||
|
||||
#
|
||||
# Choose various options
|
||||
#
|
||||
ifeq ($(HOST),mingw32-linux)
|
||||
NASM_FORMAT = win32
|
||||
PREFIX = mingw32-
|
||||
EXE_POSTFIX :=
|
||||
EXE_PREFIX := ./
|
||||
DLLTOOL = $(PREFIX)dlltool --as=$(PREFIX)as
|
||||
NASM_CMD = nasm
|
||||
DOSCLI =
|
||||
FLOPPY_DIR = /mnt/floppy
|
||||
SEP := /
|
||||
PIPE :=
|
||||
RM = rm -f
|
||||
CP = cp -f
|
||||
MKDIR = mkdir
|
||||
endif
|
||||
|
||||
ifeq ($(HOST),mingw32-windows)
|
||||
NASM_FORMAT = win32
|
||||
PREFIX =
|
||||
EXE_PREFIX :=
|
||||
EXE_POSTFIX := .exe
|
||||
DLLTOOL = $(PREFIX)dlltool --as=$(PREFIX)as
|
||||
NASM_CMD = nasmw
|
||||
DOSCLI = yes
|
||||
FLOPPY_DIR = A:
|
||||
SEP := \$(EMPTY_VAR)
|
||||
PIPE := -pipe
|
||||
RM = cmd /C del
|
||||
CP = copy /Y
|
||||
MKDIR = md
|
||||
endif
|
||||
|
||||
|
||||
NFLAGS = -fwin32 -dwin32
|
||||
BIN2C = ..$(SEP)tools$(SEP)bin2c
|
||||
TOOLSDIR = ..$(SEP)tools
|
||||
|
||||
CC = $(PREFIX)gcc
|
||||
LD = $(PREFIX)ld
|
||||
AR = $(PREFIX)ar
|
||||
NM = $(PREFIX)nm
|
||||
WINDRES = $(PREFIX)windres
|
@@ -1,22 +0,0 @@
|
||||
dist
|
||||
reactos
|
||||
*.sys
|
||||
*.exe
|
||||
*.dll
|
||||
*.cpl
|
||||
*.a
|
||||
*.o
|
||||
*.d
|
||||
*.coff
|
||||
*.dsp
|
||||
*.dsw
|
||||
*.aps
|
||||
*.ncb
|
||||
*.opt
|
||||
*.sym
|
||||
*.plg
|
||||
*.bak
|
||||
*.zip
|
||||
*.iso
|
||||
*.cab
|
||||
doxy-doc
|
3682
reactos/ChangeLog
3682
reactos/ChangeLog
File diff suppressed because it is too large
Load Diff
105
reactos/Makefile
105
reactos/Makefile
@@ -1,4 +1,4 @@
|
||||
# $Id: Makefile,v 1.277 2004/12/30 18:31:43 ion Exp $
|
||||
# $Id$
|
||||
#
|
||||
# Global makefile
|
||||
#
|
||||
@@ -23,6 +23,9 @@ else
|
||||
IMPLIB = implib
|
||||
endif
|
||||
|
||||
# Boot loaders
|
||||
BOOT_LOADERS = freeldr
|
||||
|
||||
# Required to run the system
|
||||
COMPONENTS = ntoskrnl
|
||||
|
||||
@@ -36,13 +39,13 @@ BUS = acpi isapnp pci
|
||||
|
||||
# Filesystem libraries
|
||||
# vfatlib
|
||||
LIB_FSLIB = vfatlib
|
||||
LIB_FSLIB = vfatlib ext2lib
|
||||
|
||||
# Static libraries
|
||||
LIB_STATIC = string rosrtl epsapi uuid libwine zlib rtl tgetopt pseh adns dxguid strmiids
|
||||
|
||||
# Keyboard layout libraries
|
||||
DLLS_KBD = kbdda kbddv kbdfr kbdgr kbdse kbduk kbdus
|
||||
DLLS_KBD = kbdda kbddv kbdes kbdfr kbdgr kbdse kbduk kbdus
|
||||
|
||||
# Control Panels
|
||||
DLLS_CPL = cpl
|
||||
@@ -57,7 +60,7 @@ DLLS = acledit aclui advapi32 advpack cabinet cards comctl32 crtdll comdlg32 d3d
|
||||
msgina msimg32 msvcrt20 msvideo mswsock netapi32 ntdll ole32 oleaut32 oledlg olepro32 opengl32 \
|
||||
packet psapi riched20 richedit rpcrt4 samlib secur32 setupapi shell32 shlwapi snmpapi syssetup twain \
|
||||
unicode user32 userenv version wininet winmm winspool ws2help ws2_32 wsock32 wshirda dnsapi \
|
||||
dinput dinput8 dxdiagn devenum dsound $(DLLS_KBD) $(DLLS_CPL) $(DLLS_SHELLEXT)
|
||||
urlmon shdocvw dinput dinput8 dxdiagn devenum dsound $(DLLS_KBD) $(DLLS_CPL) $(DLLS_SHELLEXT)
|
||||
|
||||
SUBSYS = smss win32k csrss ntvdm
|
||||
|
||||
@@ -81,7 +84,7 @@ INPUT_DRIVERS = keyboard mouclass psaux sermouse
|
||||
|
||||
# Kernel mode file system drivers
|
||||
# cdfs ext2 fs_rec ms np vfat
|
||||
FS_DRIVERS = cdfs fs_rec ms np vfat mup ntfs
|
||||
FS_DRIVERS = cdfs fs_rec ms np vfat ext2 mup ntfs
|
||||
|
||||
# Kernel mode networking drivers
|
||||
# afd ndis npf tcpip tdi wshtcpip
|
||||
@@ -98,8 +101,8 @@ STORAGE_DRIVERS = atapi cdrom class2 disk floppy scsiport diskdump
|
||||
# System applications
|
||||
# autochk cmd format services setup usetup welcome winlogon msiexec
|
||||
SYS_APPS = autochk calc cmd explorer expand format regedt32 regsvr32 \
|
||||
services setup taskmgr userinit usetup welcome vmwinst winlogon \
|
||||
regedit winefile notepad reactos
|
||||
reporterror services setup taskmgr userinit usetup welcome vmwinst \
|
||||
winlogon regedit winefile notepad reactos
|
||||
|
||||
# System services
|
||||
# rpcss eventlog
|
||||
@@ -124,33 +127,30 @@ KERNEL_DRIVERS = $(DRIVERS_LIB) $(DEVICE_DRIVERS) $(INPUT_DRIVERS) $(FS_DRIVERS)
|
||||
# Regression tests
|
||||
REGTESTS = regtests
|
||||
|
||||
all: bootstrap $(COMPONENTS) $(REGTESTS) $(HALS) $(BUS) $(LIB_FSLIB) $(DLLS) $(SUBSYS) \
|
||||
$(KERNEL_DRIVERS) $(SYS_APPS) $(SYS_SVC) \
|
||||
$(APPS) $(EXT_MODULES)
|
||||
all: bootstrap $(BOOT_LOADERS) $(COMPONENTS) $(REGTESTS) $(HALS) $(BUS) $(LIB_FSLIB) \
|
||||
$(DLLS) $(SUBSYS) $(KERNEL_DRIVERS) $(SYS_APPS) $(SYS_SVC) $(APPS) $(EXT_MODULES)
|
||||
|
||||
bootstrap: dk implib iface_native iface_additional
|
||||
|
||||
#config: $(TOOLS:%=%_config)
|
||||
|
||||
depends: $(LIB_STATIC:%=%_depends) $(LIB_FSLIB:%=%_depends) msvcrt_depends $(DLLS:%=%_depends) \
|
||||
$(SUBSYS:%=%_depends) $(SYS_SVC:%=%_depends) \
|
||||
$(EXT_MODULES:%=%_depends) $(POSIX_LIBS:%=%_depends)
|
||||
|
||||
implib: hallib $(LIB_STATIC) $(COMPONENTS:%=%_implib) $(HALS:%=%_implib) $(BUS:%=%_implib) \
|
||||
$(LIB_STATIC:%=%_implib) $(LIB_FSLIB:%=%_implib) msvcrt_implib $(DLLS:%=%_implib) \
|
||||
$(KERNEL_DRIVERS:%=%_implib) $(SUBSYS:%=%_implib) \
|
||||
$(SYS_APPS:%=%_implib) $(SYS_SVC:%=%_implib) $(EXT_MODULES:%=%_implib) \
|
||||
$(REGTESTS:%=%_implib)
|
||||
implib: hallib $(LIB_STATIC) $(COMPONENTS:%=%_implib) $(HALS:%=%_implib) \
|
||||
$(BUS:%=%_implib) $(LIB_STATIC:%=%_implib) $(LIB_FSLIB:%=%_implib) \
|
||||
msvcrt_implib $(DLLS:%=%_implib) $(KERNEL_DRIVERS:%=%_implib) \
|
||||
$(SUBSYS:%=%_implib) $(SYS_APPS:%=%_implib) $(SYS_SVC:%=%_implib) \
|
||||
$(EXT_MODULES:%=%_implib) $(REGTESTS:%=%_implib)
|
||||
|
||||
test: $(COMPONENTS:%=%_test) $(HALS:%=%_test) $(BUS:%=%_test) \
|
||||
test: $(BOOT_LOADERS:%=%_test) $(COMPONENTS:%=%_test) $(HALS:%=%_test) $(BUS:%=%_test) \
|
||||
$(LIB_STATIC:%=%_test) $(LIB_FSLIB:%=%_test) msvcrt_test $(DLLS:%=%_test) \
|
||||
$(KERNEL_DRIVERS:%=%_test) $(SUBSYS:%=%_test) \
|
||||
$(SYS_SVC:%=%_test) $(EXT_MODULES:%=%_test)
|
||||
|
||||
clean: tools dk_clean iface_native_clean iface_additional_clean hallib_clean \
|
||||
$(HALS:%=%_clean) $(COMPONENTS:%=%_clean) $(BUS:%=%_clean) \
|
||||
$(LIB_STATIC:%=%_clean) $(LIB_FSLIB:%=%_clean) msvcrt_clean \
|
||||
$(DLLS:%=%_clean) $(KERNEL_DRIVERS:%=%_clean) \
|
||||
$(BOOT_LOADERS:%=%_clean) $(HALS:%=%_clean) $(COMPONENTS:%=%_clean) \
|
||||
$(BUS:%=%_clean) $(LIB_STATIC:%=%_clean) $(LIB_FSLIB:%=%_clean) \
|
||||
msvcrt_clean $(DLLS:%=%_clean) $(KERNEL_DRIVERS:%=%_clean) \
|
||||
$(SUBSYS:%=%_clean) $(SYS_APPS:%=%_clean) $(SYS_SVC:%=%_clean) \
|
||||
$(NET_APPS:%=%_clean) $(APPS:%=%_clean) $(EXT_MODULES:%=%_clean) \
|
||||
$(REGTESTS:%=%_clean) clean_after tools_clean
|
||||
@@ -159,18 +159,14 @@ clean_after:
|
||||
$(HALFVERBOSEECHO) [RM] /include/roscfg.h
|
||||
$(RM) $(PATH_TO_TOP)/include/roscfg.h
|
||||
|
||||
fastinstall: tools install_dirs install_before \
|
||||
$(COMPONENTS:%=%_install) $(HALS:%=%_install) $(BUS:%=%_install) \
|
||||
$(LIB_STATIC:%=%_install) $(LIB_FSLIB:%=%_install) msvcrt_install $(DLLS:%=%_install) \
|
||||
$(KERNEL_DRIVERS:%=%_install) $(SUBSYS:%=%_install) \
|
||||
$(SYS_APPS:%=%_install) $(SYS_SVC:%=%_install) \
|
||||
fastinstall: tools install_dirs install_before $(COMPONENTS:%=%_install) $(HALS:%=%_install) \
|
||||
$(BUS:%=%_install) $(LIB_STATIC:%=%_install) $(LIB_FSLIB:%=%_install) \
|
||||
msvcrt_install $(DLLS:%=%_install) $(KERNEL_DRIVERS:%=%_install) \
|
||||
$(SUBSYS:%=%_install) $(SYS_APPS:%=%_install) $(SYS_SVC:%=%_install) \
|
||||
$(APPS:%=%_install) $(EXT_MODULES:%=%_install) $(REGTESTS:%=%_install)
|
||||
install: fastinstall registry
|
||||
|
||||
FREELDR_DIR = ../freeldr
|
||||
|
||||
freeldr:
|
||||
$(MAKE) -C $(FREELDR_DIR)
|
||||
FREELDR_DIR = boot/freeldr
|
||||
|
||||
bootcd_directory_layout:
|
||||
$(HALFVERBOSEECHO) [RMKDIR] $(BOOTCD_DIR)
|
||||
@@ -183,26 +179,11 @@ bootcd_directory_layout:
|
||||
$(RMKDIR) $(BOOTCD_DIR)/reactos
|
||||
$(HALFVERBOSEECHO) [RMKDIR] $(BOOTCD_DIR)/reactos/system32
|
||||
$(RMKDIR) $(BOOTCD_DIR)/reactos/system32
|
||||
$(HALFVERBOSEECHO) [COPY] ${FREELDR_DIR}/bootsect/isoboot.bin to ${BOOTCD_DIR}/../isoboot.bin
|
||||
$(CP) ${FREELDR_DIR}/bootsect/isoboot.bin ${BOOTCD_DIR}/../isoboot.bin
|
||||
$(HALFVERBOSEECHO) [COPY] ${FREELDR_DIR}/bootsect/dosmbr.bin to ${BOOTCD_DIR}/loader/dosmbr.bin
|
||||
$(CP) ${FREELDR_DIR}/bootsect/dosmbr.bin ${BOOTCD_DIR}/loader/dosmbr.bin
|
||||
$(HALFVERBOSEECHO) [COPY] ${FREELDR_DIR}/bootsect/ext2.bin to ${BOOTCD_DIR}/loader/ext2.bin
|
||||
$(CP) ${FREELDR_DIR}/bootsect/ext2.bin ${BOOTCD_DIR}/loader/ext2.bin
|
||||
$(HALFVERBOSEECHO) [COPY] ${FREELDR_DIR}/bootsect/fat.bin to ${BOOTCD_DIR}/loader/fat.bin
|
||||
$(CP) ${FREELDR_DIR}/bootsect/fat.bin ${BOOTCD_DIR}/loader/fat.bin
|
||||
$(HALFVERBOSEECHO) [COPY] ${FREELDR_DIR}/bootsect/fat32.bin to ${BOOTCD_DIR}/loader/fat32.bin
|
||||
$(CP) ${FREELDR_DIR}/bootsect/fat32.bin ${BOOTCD_DIR}/loader/fat32.bin
|
||||
$(HALFVERBOSEECHO) [COPY] ${FREELDR_DIR}/bootsect/isoboot.bin to ${BOOTCD_DIR}/loader/isoboot.bin
|
||||
$(CP) ${FREELDR_DIR}/bootsect/isoboot.bin ${BOOTCD_DIR}/loader/isoboot.bin
|
||||
$(HALFVERBOSEECHO) [COPY] ${FREELDR_DIR}/freeldr/obj/i386/freeldr.sys to ${BOOTCD_DIR}/loader/freeldr.sys
|
||||
$(CP) ${FREELDR_DIR}/freeldr/obj/i386/freeldr.sys ${BOOTCD_DIR}/loader/freeldr.sys
|
||||
$(HALFVERBOSEECHO) [COPY] ${FREELDR_DIR}/freeldr/obj/i386/setupldr.sys to ${BOOTCD_DIR}/loader/setupldr.sys
|
||||
$(CP) ${FREELDR_DIR}/freeldr/obj/i386/setupldr.sys ${BOOTCD_DIR}/loader/setupldr.sys
|
||||
|
||||
bootcd_bootstrap_files: $(COMPONENTS:%=%_bootcd) $(HALS:%=%_bootcd) $(BUS:%=%_bootcd) \
|
||||
$(LIB_STATIC:%=%_bootcd) $(LIB_FSLIB:%=%_bootcd) msvcrt_bootcd $(DLLS:%=%_bootcd) \
|
||||
$(KERNEL_DRIVERS:%=%_bootcd) $(SUBSYS:%=%_bootcd) $(SYS_APPS:%=%_bootcd)
|
||||
bootcd_bootstrap_files: $(BOOT_LOADERS:%=%_bootcd) $(COMPONENTS:%=%_bootcd) \
|
||||
$(HALS:%=%_bootcd) $(BUS:%=%_bootcd) $(LIB_STATIC:%=%_bootcd) \
|
||||
$(LIB_FSLIB:%=%_bootcd) msvcrt_bootcd $(DLLS:%=%_bootcd) \
|
||||
$(KERNEL_DRIVERS:%=%_bootcd) $(SUBSYS:%=%_bootcd) $(SYS_APPS:%=%_bootcd)
|
||||
|
||||
bootcd_install_before:
|
||||
$(HALFVERBOSEECHO) [RLINE] bootdata/autorun.inf to $(BOOTCD_DIR)/autorun.inf
|
||||
@@ -262,8 +243,8 @@ livecd_directory_layout:
|
||||
$(RMKDIR) $(LIVECD_DIR)/Profiles/Default\ User/My\ Documents
|
||||
$(HALFVERBOSEECHO) [COPY] ${FREELDR_DIR}/bootsect/isoboot.bin to ${LIVECD_DIR}/../isoboot.bin
|
||||
$(CP) ${FREELDR_DIR}/bootsect/isoboot.bin ${LIVECD_DIR}/../isoboot.bin
|
||||
$(HALFVERBOSEECHO) [COPY] ${FREELDR_DIR}/freeldr/obj/i386/freeldr.sys to ${LIVECD_DIR}/loader/setupldr.sys
|
||||
$(CP) ${FREELDR_DIR}/freeldr/obj/i386/freeldr.sys ${LIVECD_DIR}/loader/setupldr.sys
|
||||
$(HALFVERBOSEECHO) [COPY] ${FREELDR_DIR}/freeldr/freeldr.sys to ${LIVECD_DIR}/loader/setupldr.sys
|
||||
$(CP) ${FREELDR_DIR}/freeldr/freeldr.sys ${LIVECD_DIR}/loader/setupldr.sys
|
||||
$(HALFVERBOSEECHO) [RLINE] bootdata/livecd.ini to $(LIVECD_DIR)/freeldr.ini
|
||||
$(RLINE) bootdata/livecd.ini $(LIVECD_DIR)/freeldr.ini
|
||||
|
||||
@@ -288,10 +269,28 @@ livecd: livecd_basic livecd_makecd
|
||||
registry: tools
|
||||
$(MKHIVE) bootdata $(INSTALL_DIR)/system32/config bootdata/hiveinst.inf
|
||||
|
||||
.PHONY: all bootstrap depends implib test clean clean_before install freeldr bootcd_directory_layout \
|
||||
.PHONY: all bootstrap depends implib test clean clean_before install bootcd_directory_layout \
|
||||
bootcd_bootstrap_files bootcd_install_before bootcd_basic bootcd_makecd ubootcd_unattend bootcd
|
||||
|
||||
|
||||
#
|
||||
# Boot Loaders
|
||||
#
|
||||
$(BOOT_LOADERS): %:
|
||||
$(MAKE) -C boot/$*
|
||||
|
||||
$(BOOT_LOADERS:%=%_test): %_test:
|
||||
$(MAKE) -C boot/$* test
|
||||
|
||||
$(BOOT_LOADERS:%=%_clean): %_clean:
|
||||
$(MAKE) -C boot/$* clean
|
||||
|
||||
$(BOOT_LOADERS:%=%_bootcd): %_bootcd:
|
||||
$(MAKE) -C boot/$* bootcd
|
||||
|
||||
.PHONY: $(BOOT_LOADERS) $(BOOT_LOADERS:%=%_test) $(BOOT_LOADERS:%=%_clean) \
|
||||
$(BOOT_LOADERS:%=%_bootcd)
|
||||
|
||||
$(COMPONENTS): dk
|
||||
|
||||
#
|
||||
@@ -775,7 +774,7 @@ hallib_bootcd:
|
||||
#
|
||||
# Hardware Abstraction Layers
|
||||
#
|
||||
ifeq ($(MP),1)
|
||||
ifeq ($(CONFIG_SMP),1)
|
||||
halx86: halx86/mp
|
||||
else
|
||||
halx86: halx86/up
|
||||
|
@@ -1 +0,0 @@
|
||||
doxy-doc
|
@@ -1,4 +1,4 @@
|
||||
# $Id: Makefile,v 1.1 2003/12/06 23:10:50 mf Exp $
|
||||
# $Id$
|
||||
#
|
||||
# ReactOS apps and tools makefile to generate Doxygen documentation
|
||||
#
|
||||
|
@@ -1,10 +0,0 @@
|
||||
*.o
|
||||
*.d
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.dsp
|
||||
*.dsw
|
||||
*.ncb
|
||||
*.opt
|
||||
*.map
|
@@ -1,6 +0,0 @@
|
||||
*.o
|
||||
*.d
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
@@ -11,7 +11,7 @@ include $(PATH_TO_TOP)/rules.mak
|
||||
# cabman cat net objdir partinfo pice ps sc stats
|
||||
UTIL_APPS = cat objdir partinfo pnpdump sc shutdown stats tickcount consw rundll32 ps
|
||||
|
||||
UTIL_NET_APPS = arp finger ipconfig netstat ping route telnet whois
|
||||
UTIL_NET_APPS = arp finger ftp ipconfig netstat ping route telnet whois
|
||||
|
||||
|
||||
all: $(UTIL_APPS) $(UTIL_NET_APPS)
|
||||
|
@@ -1,6 +0,0 @@
|
||||
*.o
|
||||
*.d
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
@@ -1,4 +1,4 @@
|
||||
# $Id: makefile,v 1.11 2003/11/14 17:13:22 weiden Exp $
|
||||
# $Id$
|
||||
|
||||
PATH_TO_TOP = ../../..
|
||||
|
||||
|
@@ -1,7 +0,0 @@
|
||||
consw.exe
|
||||
consw.nostrip.exe
|
||||
consw.sym
|
||||
consw.coff
|
||||
*.d
|
||||
*.o
|
||||
*.map
|
@@ -1,4 +1,4 @@
|
||||
/* $Id: consw.c,v 1.2 2003/11/14 17:13:22 weiden Exp $
|
||||
/* $Id$
|
||||
*
|
||||
* DESCRIPTION: Console mode switcher
|
||||
* PROGRAMMER: Art Yerkes
|
||||
|
@@ -1,4 +1,4 @@
|
||||
# $Id: makefile,v 1.2 2003/11/14 17:13:22 weiden Exp $
|
||||
# $Id$
|
||||
|
||||
PATH_TO_TOP = ../../..
|
||||
|
||||
|
@@ -1,6 +0,0 @@
|
||||
*.o
|
||||
*.d
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
@@ -1,6 +0,0 @@
|
||||
*.o
|
||||
*.d
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
@@ -1,6 +0,0 @@
|
||||
*.o
|
||||
*.d
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
@@ -1,17 +0,0 @@
|
||||
*.sys
|
||||
*.exe
|
||||
*.dll
|
||||
*.cpl
|
||||
*.a
|
||||
*.o
|
||||
*.d
|
||||
*.coff
|
||||
*.dsp
|
||||
*.dsw
|
||||
*.aps
|
||||
*.ncb
|
||||
*.opt
|
||||
*.sym
|
||||
*.plg
|
||||
*.bak
|
||||
*.map
|
@@ -1,4 +1,4 @@
|
||||
/* $Id: arp.rc,v 1.1 2004/11/21 22:25:36 chorns Exp $ */
|
||||
/* $Id$ */
|
||||
|
||||
#define REACTOS_STR_FILE_DESCRIPTION "ReactOS TCP/IPv4 Win32 arp\0"
|
||||
#define REACTOS_STR_INTERNAL_NAME "arp\0"
|
||||
|
@@ -1,17 +0,0 @@
|
||||
*.sys
|
||||
*.exe
|
||||
*.dll
|
||||
*.cpl
|
||||
*.a
|
||||
*.o
|
||||
*.d
|
||||
*.coff
|
||||
*.dsp
|
||||
*.dsw
|
||||
*.aps
|
||||
*.ncb
|
||||
*.opt
|
||||
*.sym
|
||||
*.plg
|
||||
*.bak
|
||||
*.map
|
@@ -1,4 +1,4 @@
|
||||
/* $Id: finger.rc,v 1.1 2004/11/21 22:26:13 chorns Exp $ */
|
||||
/* $Id$ */
|
||||
|
||||
#define REACTOS_STR_FILE_DESCRIPTION "ReactOS TCP/IPv4 Win32 finger\0"
|
||||
#define REACTOS_STR_INTERNAL_NAME "finger\0"
|
||||
|
2376
reactos/apps/utils/net/ftp/cmds.c
Normal file
2376
reactos/apps/utils/net/ftp/cmds.c
Normal file
File diff suppressed because it is too large
Load Diff
185
reactos/apps/utils/net/ftp/cmdtab.c
Normal file
185
reactos/apps/utils/net/ftp/cmdtab.c
Normal file
@@ -0,0 +1,185 @@
|
||||
/*
|
||||
* 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
|
||||
static char sccsid[] = "@(#)cmdtab.c 5.9 (Berkeley) 3/21/89";
|
||||
#endif /* not lint */
|
||||
|
||||
#include "ftp_var.h"
|
||||
|
||||
/*
|
||||
* 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";
|
||||
char asciihelp[] = "set ascii transfer type";
|
||||
char beephelp[] = "beep when command completed";
|
||||
char binaryhelp[] = "set binary transfer type";
|
||||
char casehelp[] = "toggle mget upper/lower case id mapping";
|
||||
char cdhelp[] = "change remote working directory";
|
||||
char cduphelp[] = "change remote working directory to parent directory";
|
||||
char chmodhelp[] = "change file permissions of remote file";
|
||||
char connecthelp[] = "connect to remote tftp";
|
||||
char crhelp[] = "toggle carriage return stripping on ascii gets";
|
||||
char deletehelp[] = "delete remote file";
|
||||
char debughelp[] = "toggle/set debugging mode";
|
||||
char dirhelp[] = "list contents of remote directory";
|
||||
char disconhelp[] = "terminate ftp session";
|
||||
char domachelp[] = "execute macro";
|
||||
char formhelp[] = "set file transfer format";
|
||||
char globhelp[] = "toggle metacharacter expansion of local file names";
|
||||
char hashhelp[] = "toggle printing `#' for each buffer transferred";
|
||||
char helphelp[] = "print local help information";
|
||||
char idlehelp[] = "get (set) idle timer on remote side";
|
||||
char lcdhelp[] = "change local working directory";
|
||||
char lshelp[] = "list contents of remote directory";
|
||||
char macdefhelp[] = "define a macro";
|
||||
char mdeletehelp[] = "delete multiple files";
|
||||
char mdirhelp[] = "list contents of multiple remote directories";
|
||||
char mgethelp[] = "get multiple files";
|
||||
char mkdirhelp[] = "make directory on the remote machine";
|
||||
char mlshelp[] = "list contents of multiple remote directories";
|
||||
char modtimehelp[] = "show last modification time of remote file";
|
||||
char modehelp[] = "set file transfer mode";
|
||||
char mputhelp[] = "send multiple files";
|
||||
char newerhelp[] = "get file if remote file is newer than local file ";
|
||||
char nlisthelp[] = "nlist contents of remote directory";
|
||||
char nmaphelp[] = "set templates for default file name mapping";
|
||||
char ntranshelp[] = "set translation table for default file name mapping";
|
||||
char porthelp[] = "toggle use of PORT cmd for each data connection";
|
||||
char prompthelp[] = "force interactive prompting on multiple commands";
|
||||
char proxyhelp[] = "issue command on alternate connection";
|
||||
char pwdhelp[] = "print working directory on remote machine";
|
||||
char quithelp[] = "terminate ftp session and exit";
|
||||
char quotehelp[] = "send arbitrary ftp command";
|
||||
char receivehelp[] = "receive file";
|
||||
char regethelp[] = "get file restarting at end of local file";
|
||||
char remotehelp[] = "get help from remote server";
|
||||
char renamehelp[] = "rename file";
|
||||
char restarthelp[]= "restart file transfer at bytecount";
|
||||
char rmdirhelp[] = "remove directory on the remote machine";
|
||||
char rmtstatushelp[]="show status of remote machine";
|
||||
char runiquehelp[] = "toggle store unique for local files";
|
||||
char resethelp[] = "clear queued command replies";
|
||||
char sendhelp[] = "send one file";
|
||||
char passivehelp[] = "enter passive transfer mode";
|
||||
char sitehelp[] = "send site specific command to remote server\n\t\tTry \"rhelp site\" or \"site help\" for more information";
|
||||
char shellhelp[] = "escape to the shell";
|
||||
char sizecmdhelp[] = "show size of remote file";
|
||||
char statushelp[] = "show current status";
|
||||
char structhelp[] = "set file transfer structure";
|
||||
char suniquehelp[] = "toggle store unique on remote machine";
|
||||
char systemhelp[] = "show remote system type";
|
||||
char tenexhelp[] = "set tenex file transfer type";
|
||||
char tracehelp[] = "toggle packet tracing";
|
||||
char typehelp[] = "set file transfer type";
|
||||
char umaskhelp[] = "get (set) umask on remote side";
|
||||
char userhelp[] = "send new user information";
|
||||
char verbosehelp[] = "toggle verbose mode";
|
||||
|
||||
struct cmd cmdtab[] = {
|
||||
{ "!", shellhelp, 0, 0, 0, shell },
|
||||
{ "$", domachelp, 1, 0, 0, domacro },
|
||||
{ "account", accounthelp, 0, 1, 1, account},
|
||||
{ "append", appendhelp, 1, 1, 1, put },
|
||||
{ "ascii", asciihelp, 0, 1, 1, setascii },
|
||||
{ "bell", beephelp, 0, 0, 0, setbell },
|
||||
{ "binary", binaryhelp, 0, 1, 1, setbinary },
|
||||
{ "bye", quithelp, 0, 0, 0, quit },
|
||||
{ "case", casehelp, 0, 0, 1, setcase },
|
||||
{ "cd", cdhelp, 0, 1, 1, cd },
|
||||
{ "cdup", cduphelp, 0, 1, 1, cdup },
|
||||
{ "chmod", chmodhelp, 0, 1, 1, do_chmod },
|
||||
{ "close", disconhelp, 0, 1, 1, disconnect },
|
||||
{ "cr", crhelp, 0, 0, 0, setcr },
|
||||
{ "delete", deletehelp, 0, 1, 1, delete },
|
||||
{ "debug", debughelp, 0, 0, 0, setdebug },
|
||||
{ "dir", dirhelp, 1, 1, 1, ls },
|
||||
{ "disconnect", disconhelp, 0, 1, 1, disconnect },
|
||||
{ "form", formhelp, 0, 1, 1, setform },
|
||||
{ "get", receivehelp, 1, 1, 1, get },
|
||||
{ "glob", globhelp, 0, 0, 0, setglob },
|
||||
{ "hash", hashhelp, 0, 0, 0, sethash },
|
||||
{ "help", helphelp, 0, 0, 1, help },
|
||||
{ "idle", idlehelp, 0, 1, 1, idle },
|
||||
{ "image", binaryhelp, 0, 1, 1, setbinary },
|
||||
{ "lcd", lcdhelp, 0, 0, 0, lcd },
|
||||
{ "ls", lshelp, 1, 1, 1, ls },
|
||||
{ "macdef", macdefhelp, 0, 0, 0, macdef },
|
||||
{ "mdelete", mdeletehelp, 1, 1, 1, mdelete },
|
||||
{ "mdir", mdirhelp, 1, 1, 1, mls },
|
||||
{ "mget", mgethelp, 1, 1, 1, mget },
|
||||
{ "mkdir", mkdirhelp, 0, 1, 1, makedir },
|
||||
{ "mls", mlshelp, 1, 1, 1, mls },
|
||||
{ "mode", modehelp, 0, 1, 1, setmode },
|
||||
{ "modtime", modtimehelp, 0, 1, 1, modtime },
|
||||
{ "mput", mputhelp, 1, 1, 1, mput },
|
||||
{ "newer", newerhelp, 1, 1, 1, newer },
|
||||
{ "nmap", nmaphelp, 0, 0, 1, setnmap },
|
||||
{ "nlist", nlisthelp, 1, 1, 1, ls },
|
||||
{ "ntrans", ntranshelp, 0, 0, 1, setntrans },
|
||||
{ "open", connecthelp, 0, 0, 1, setpeer },
|
||||
{ "passive",passivehelp,0, 0, 0, setpassive },
|
||||
{ "prompt", prompthelp, 0, 0, 0, setprompt },
|
||||
{ "proxy", proxyhelp, 0, 0, 1, doproxy },
|
||||
{ "sendport", porthelp, 0, 0, 0, setport },
|
||||
{ "put", sendhelp, 1, 1, 1, put },
|
||||
{ "pwd", pwdhelp, 0, 1, 1, pwd },
|
||||
{ "quit", quithelp, 0, 0, 0, quit },
|
||||
{ "quote", quotehelp, 1, 1, 1, quote },
|
||||
{ "recv", receivehelp, 1, 1, 1, get },
|
||||
{ "reget", regethelp, 1, 1, 1, reget },
|
||||
{ "rstatus", rmtstatushelp, 0, 1, 1, rmtstatus },
|
||||
{ "rhelp", remotehelp, 0, 1, 1, rmthelp },
|
||||
{ "rename", renamehelp, 0, 1, 1, renamefile },
|
||||
{ "reset", resethelp, 0, 1, 1, reset },
|
||||
{ "restart", restarthelp, 1, 1, 1, restart },
|
||||
{ "rmdir", rmdirhelp, 0, 1, 1, removedir },
|
||||
{ "runique", runiquehelp, 0, 0, 1, setrunique },
|
||||
{ "send", sendhelp, 1, 1, 1, put },
|
||||
{ "site", sitehelp, 0, 1, 1, site },
|
||||
{ "size", sizecmdhelp, 1, 1, 1, sizecmd },
|
||||
{ "status", statushelp, 0, 0, 1, status },
|
||||
{ "struct", structhelp, 0, 1, 1, setstruct },
|
||||
{ "system", systemhelp, 0, 1, 1, syst },
|
||||
{ "sunique", suniquehelp, 0, 0, 1, setsunique },
|
||||
{ "tenex", tenexhelp, 0, 1, 1, settenex },
|
||||
{ "trace", tracehelp, 0, 0, 0, settrace },
|
||||
{ "type", typehelp, 0, 1, 1, settype },
|
||||
{ "user", userhelp, 0, 1, 1, user },
|
||||
{ "umask", umaskhelp, 0, 1, 1, do_umask },
|
||||
{ "verbose", verbosehelp, 0, 0, 0, setverbose },
|
||||
{ "?", helphelp, 0, 0, 1, help },
|
||||
{ 0 },
|
||||
};
|
||||
|
||||
int NCMDS = (sizeof (cmdtab) / sizeof (cmdtab[0])) - 1;
|
149
reactos/apps/utils/net/ftp/domacro.c
Normal file
149
reactos/apps/utils/net/ftp/domacro.c
Normal file
@@ -0,0 +1,149 @@
|
||||
/*
|
||||
* Copyright (c) 1985 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
|
||||
static char sccsid[] = "@(#)domacro.c 1.6 (Berkeley) 2/28/89";
|
||||
#endif /* not lint */
|
||||
|
||||
#include "ftp_var.h"
|
||||
#include "prototypes.h"
|
||||
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
//#include <errno.h>
|
||||
#include <ctype.h>
|
||||
//#include <sys/ttychars.h>
|
||||
|
||||
void domacro(argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
{
|
||||
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, " ");
|
||||
printf("(macro name) ");
|
||||
(void) fflush(stdout);
|
||||
(void) gets(&line[strlen(line)]);
|
||||
makeargv();
|
||||
argc = margc;
|
||||
argv = margv;
|
||||
}
|
||||
if (argc < 2) {
|
||||
printf("Usage: %s macro_name.\n", argv[0]);
|
||||
(void) fflush(stdout);
|
||||
code = -1;
|
||||
return;
|
||||
}
|
||||
for (i = 0; i < macnum; ++i) {
|
||||
if (!strncmp(argv[1], macros[i].mac_name, 9)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i == macnum) {
|
||||
printf("'%s' macro not found.\n", argv[1]);
|
||||
(void) fflush(stdout);
|
||||
code = -1;
|
||||
return;
|
||||
}
|
||||
(void) strcpy(line2, line);
|
||||
TOP:
|
||||
cp1 = macros[i].mac_start;
|
||||
while (cp1 != macros[i].mac_end) {
|
||||
while (isspace(*cp1)) {
|
||||
cp1++;
|
||||
}
|
||||
cp2 = line;
|
||||
while (*cp1 != '\0') {
|
||||
switch(*cp1) {
|
||||
case '\\':
|
||||
*cp2++ = *++cp1;
|
||||
break;
|
||||
case '$':
|
||||
if (isdigit(*(cp1+1))) {
|
||||
j = 0;
|
||||
while (isdigit(*++cp1)) {
|
||||
j = 10*j + *cp1 - '0';
|
||||
}
|
||||
cp1--;
|
||||
if (argc - 2 >= j) {
|
||||
(void) strcpy(cp2, argv[j+1]);
|
||||
cp2 += strlen(argv[j+1]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (*(cp1+1) == 'i') {
|
||||
loopflg = 1;
|
||||
cp1++;
|
||||
if (count < argc) {
|
||||
(void) strcpy(cp2, argv[count]);
|
||||
cp2 += strlen(argv[count]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
/* intentional drop through */
|
||||
default:
|
||||
*cp2++ = *cp1;
|
||||
break;
|
||||
}
|
||||
if (*cp1 != '\0') {
|
||||
cp1++;
|
||||
}
|
||||
}
|
||||
*cp2 = '\0';
|
||||
makeargv();
|
||||
c = getcmd(margv[0]);
|
||||
if (c == (struct cmd *)-1) {
|
||||
printf("?Ambiguous command\n");
|
||||
code = -1;
|
||||
}
|
||||
else if (c == 0) {
|
||||
printf("?Invalid command\n");
|
||||
code = -1;
|
||||
}
|
||||
else if (c->c_conn && !connected) {
|
||||
printf("Not connected.\n");
|
||||
code = -1;
|
||||
}
|
||||
else {
|
||||
if (verbose) {
|
||||
printf("%s\n",line);
|
||||
}
|
||||
(*c->c_handler)(margc, margv);
|
||||
if (bell && c->c_bell) {
|
||||
(void) putchar('\007');
|
||||
}
|
||||
(void) strcpy(line, line2);
|
||||
makeargv();
|
||||
argc = margc;
|
||||
argv = margv;
|
||||
}
|
||||
if (cp1 != macros[i].mac_end) {
|
||||
cp1++;
|
||||
}
|
||||
(void) fflush(stdout);
|
||||
}
|
||||
if (loopflg && ++count < argc) {
|
||||
goto TOP;
|
||||
}
|
||||
}
|
344
reactos/apps/utils/net/ftp/fake.c
Normal file
344
reactos/apps/utils/net/ftp/fake.c
Normal file
@@ -0,0 +1,344 @@
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include <winsock.h>
|
||||
#include "prototypes.h"
|
||||
|
||||
#define MAX_ASCII 100
|
||||
|
||||
int checkRecv(SOCKET s);
|
||||
|
||||
int checkRecv(SOCKET s)
|
||||
{
|
||||
int testVal;
|
||||
fd_set sSet;
|
||||
struct timeval timeout;
|
||||
timeout.tv_sec = 60;
|
||||
|
||||
FD_ZERO(&sSet);
|
||||
|
||||
FD_SET(s, &sSet);
|
||||
|
||||
testVal = select(0, &sSet, NULL, NULL, &timeout);
|
||||
|
||||
if (testVal == SOCKET_ERROR)
|
||||
fprintf(stderr, "Socket Error");
|
||||
|
||||
return testVal;
|
||||
}
|
||||
|
||||
void blkfree(char **av0)
|
||||
{
|
||||
register char **av = av0;
|
||||
|
||||
while (*av)
|
||||
free(*av++);
|
||||
}
|
||||
|
||||
char *glob(register char *v)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
int sleep(int time)
|
||||
{
|
||||
return time;
|
||||
}
|
||||
|
||||
int herror(char *string)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#if 0
|
||||
|
||||
int gettimeofday(struct timeval *timenow,
|
||||
struct timezone *zone)
|
||||
{
|
||||
time_t t;
|
||||
|
||||
t = clock();
|
||||
|
||||
timenow->tv_usec = t;
|
||||
timenow->tv_sec = t / CLK_TCK;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int fgetcSocket(int s)
|
||||
{
|
||||
int c;
|
||||
char buffer[10];
|
||||
|
||||
// checkRecv(s);
|
||||
|
||||
c = recv(s, buffer, 1, 0);
|
||||
|
||||
#ifdef DEBUG_IN
|
||||
printf("%c", buffer[0]);
|
||||
#endif
|
||||
|
||||
if (c == INVALID_SOCKET)
|
||||
return c;
|
||||
|
||||
if (c == 0)
|
||||
return EOF;
|
||||
|
||||
return buffer[0];
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
int fgetcSocket(int s)
|
||||
{
|
||||
static int index = 0;
|
||||
static int total = 0;
|
||||
static unsigned char buffer[4096];
|
||||
|
||||
if (index == total)
|
||||
{
|
||||
index = 0;
|
||||
total = recv(s, buffer, sizeof(buffer), 0);
|
||||
|
||||
if (total == INVALID_SOCKET)
|
||||
{
|
||||
total = 0;
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
if (total == 0)
|
||||
return EOF;
|
||||
}
|
||||
return buffer[index++];
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
char *fprintfSocket(int s, char *format, ...)
|
||||
{
|
||||
va_list argptr;
|
||||
char buffer[10009];
|
||||
|
||||
va_start(argptr, format);
|
||||
vsprintf(buffer, format, argptr);
|
||||
va_end(argptr);
|
||||
|
||||
send(s, buffer, strlen(buffer), 0);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char *fputsSocket(char *format, int s)
|
||||
{
|
||||
send(s, format, strlen(format), 0);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int fputcSocket(int s, char putChar)
|
||||
{
|
||||
char buffer[2];
|
||||
|
||||
buffer[0] = putChar;
|
||||
buffer[1] = '\0';
|
||||
|
||||
if(SOCKET_ERROR==send(s, buffer, 1, 0)) {
|
||||
int iret=WSAGetLastError ();
|
||||
fprintf(stdout,"fputcSocket: %d\n",iret);
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
return putChar;
|
||||
}
|
||||
}
|
||||
int fputSocket(int s, char *buffer, int len)
|
||||
{
|
||||
int iret;
|
||||
while(len) {
|
||||
if(SOCKET_ERROR==(iret=send(s, buffer, len, 0)))
|
||||
{
|
||||
iret=WSAGetLastError ();
|
||||
fprintf(stdout,"fputcSocket: %d\n",iret);
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
return len-=iret;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
char *fgetsSocket(int s, char *string)
|
||||
{
|
||||
char buffer[2] = {0};
|
||||
int i, count;
|
||||
|
||||
for (i = 0, count = 1; count != 0 && buffer[0] != '\n'; i++)
|
||||
{
|
||||
checkRecv(s);
|
||||
|
||||
count = recv(s, buffer, 1, 0);
|
||||
|
||||
if (count == SOCKET_ERROR)
|
||||
{
|
||||
printf("Error in fgetssocket");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (count == 1)
|
||||
{
|
||||
string[i] = buffer[0];
|
||||
|
||||
if (i == MAX_ASCII - 3)
|
||||
{
|
||||
count = 0;
|
||||
string[++i] = '\n';
|
||||
string[++i] = '\0';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (i == 0)
|
||||
return NULL;
|
||||
else
|
||||
{
|
||||
string[i] = '\n';
|
||||
string[i + 1] = '\0'; // This is risky
|
||||
return string;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
string[i] = '\0';
|
||||
|
||||
#ifdef DEBUG_IN
|
||||
printf("%s", string);
|
||||
#endif
|
||||
return string;
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
char *getpass(const char *prompt)
|
||||
{
|
||||
static char string[64];
|
||||
|
||||
printf("%s", prompt);
|
||||
|
||||
gets(string);
|
||||
|
||||
return string;
|
||||
}
|
||||
#endif
|
||||
char *getpass (const char * prompt)
|
||||
{
|
||||
static char input[256];
|
||||
HANDLE in;
|
||||
HANDLE err;
|
||||
int count;
|
||||
|
||||
in = GetStdHandle (STD_INPUT_HANDLE);
|
||||
err = GetStdHandle (STD_ERROR_HANDLE);
|
||||
|
||||
if (in == INVALID_HANDLE_VALUE || err == INVALID_HANDLE_VALUE)
|
||||
return NULL;
|
||||
|
||||
if (WriteFile (err, prompt, strlen (prompt), &count, NULL))
|
||||
{
|
||||
int istty = (GetFileType (in) == FILE_TYPE_CHAR);
|
||||
DWORD old_flags;
|
||||
int rc;
|
||||
|
||||
if (istty)
|
||||
{
|
||||
if (GetConsoleMode (in, &old_flags))
|
||||
SetConsoleMode (in, ENABLE_LINE_INPUT | ENABLE_PROCESSED_INPUT);
|
||||
else
|
||||
istty = 0;
|
||||
}
|
||||
/* Need to read line one byte at time to avoid blocking, if not a
|
||||
tty, so always do it this way. */
|
||||
count = 0;
|
||||
while (1)
|
||||
{
|
||||
DWORD dummy;
|
||||
char one_char;
|
||||
|
||||
rc = ReadFile (in, &one_char, 1, &dummy, NULL);
|
||||
if (rc == 0)
|
||||
break;
|
||||
if (one_char == '\r')
|
||||
{
|
||||
/* CR is always followed by LF if reading from tty. */
|
||||
if (istty)
|
||||
continue;
|
||||
else
|
||||
break;
|
||||
}
|
||||
if (one_char == '\n')
|
||||
break;
|
||||
/* Silently truncate password string if overly long. */
|
||||
if (count < sizeof (input) - 1)
|
||||
input[count++] = one_char;
|
||||
}
|
||||
input[count] = '\0';
|
||||
|
||||
WriteFile (err, "\r\n", 2, &count, NULL);
|
||||
if (istty)
|
||||
SetConsoleMode (in, old_flags);
|
||||
if (rc)
|
||||
return input;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Stubbed out here. Should be changed in Source code...
|
||||
int access(const char *filename, int accessmethod)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifndef __GNUC__
|
||||
#define EPOCHFILETIME (116444736000000000i64)
|
||||
#else
|
||||
#define EPOCHFILETIME (116444736000000000LL)
|
||||
#endif
|
||||
|
||||
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;
|
||||
__int64 t;
|
||||
static int tzflag;
|
||||
|
||||
if (tv)
|
||||
{
|
||||
GetSystemTimeAsFileTime(&ft);
|
||||
//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 */
|
||||
tv->tv_sec = (long)(t / 1000000);
|
||||
tv->tv_usec = (long)(t % 1000000);
|
||||
}
|
||||
|
||||
if (tz)
|
||||
{
|
||||
if (!tzflag)
|
||||
{
|
||||
_tzset();
|
||||
tzflag++;
|
||||
}
|
||||
tz->tz_minuteswest = _timezone / 60;
|
||||
tz->tz_dsttime = _daylight;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
10
reactos/apps/utils/net/ftp/fake.h
Normal file
10
reactos/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
reactos/apps/utils/net/ftp/ftp.c
Normal file
1805
reactos/apps/utils/net/ftp/ftp.c
Normal file
File diff suppressed because it is too large
Load Diff
372
reactos/apps/utils/net/ftp/ftp.mak
Normal file
372
reactos/apps/utils/net/ftp/ftp.mak
Normal file
@@ -0,0 +1,372 @@
|
||||
# Microsoft Developer Studio Generated NMAKE File, Based on ftp.dsp
|
||||
!IF "$(CFG)" == ""
|
||||
CFG=ftp - Win32 Debug
|
||||
!MESSAGE No configuration specified. Defaulting to ftp - Win32 Debug.
|
||||
!ENDIF
|
||||
|
||||
!IF "$(CFG)" != "ftp - Win32 Release" && "$(CFG)" != "ftp - Win32 Debug"
|
||||
!MESSAGE Invalid configuration "$(CFG)" specified.
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "ftp.mak" CFG="ftp - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "ftp - Win32 Release" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE "ftp - Win32 Debug" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE
|
||||
!ERROR An invalid configuration is specified.
|
||||
!ENDIF
|
||||
|
||||
!IF "$(OS)" == "Windows_NT"
|
||||
NULL=
|
||||
!ELSE
|
||||
NULL=nul
|
||||
!ENDIF
|
||||
|
||||
!IF "$(CFG)" == "ftp - Win32 Release"
|
||||
|
||||
OUTDIR=.\Release
|
||||
INTDIR=.\Release
|
||||
# Begin Custom Macros
|
||||
OutDir=.\Release
|
||||
# End Custom Macros
|
||||
|
||||
!IF "$(RECURSE)" == "0"
|
||||
|
||||
ALL : "$(OUTDIR)\ftp.exe"
|
||||
|
||||
!ELSE
|
||||
|
||||
ALL : "$(OUTDIR)\ftp.exe"
|
||||
|
||||
!ENDIF
|
||||
|
||||
CLEAN :
|
||||
-@erase "$(INTDIR)\cmds.obj"
|
||||
-@erase "$(INTDIR)\cmdtab.obj"
|
||||
-@erase "$(INTDIR)\domacro.obj"
|
||||
-@erase "$(INTDIR)\fake.obj"
|
||||
-@erase "$(INTDIR)\ftp.obj"
|
||||
-@erase "$(INTDIR)\main.obj"
|
||||
-@erase "$(INTDIR)\ruserpass.obj"
|
||||
-@erase "$(INTDIR)\vc*.idb"
|
||||
-@erase "$(OUTDIR)\ftp.exe"
|
||||
-@erase "$(OUTDIR)\ftp.pch"
|
||||
|
||||
"$(OUTDIR)" :
|
||||
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
|
||||
|
||||
CPP=cl.exe
|
||||
CPP_PROJ=/nologo /ML /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" \
|
||||
/D "HAVE_TIMEVAL" /Fp"$(INTDIR)\ftp.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD\
|
||||
/c
|
||||
CPP_OBJS=.\Release/
|
||||
CPP_SBRS=.
|
||||
|
||||
.c{$(CPP_OBJS)}.obj::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cpp{$(CPP_OBJS)}.obj::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cxx{$(CPP_OBJS)}.obj::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.c{$(CPP_SBRS)}.sbr::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cpp{$(CPP_SBRS)}.sbr::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cxx{$(CPP_SBRS)}.sbr::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
RSC=rc.exe
|
||||
BSC32=bscmake.exe
|
||||
BSC32_FLAGS=/nologo /o"$(OUTDIR)\ftp.bsc"
|
||||
BSC32_SBRS= \
|
||||
|
||||
LINK32=link.exe
|
||||
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib\
|
||||
advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib\
|
||||
odbccp32.lib wsock32.lib /nologo /subsystem:console /incremental:no\
|
||||
/pdb:"$(OUTDIR)\ftp.pdb" /machine:I386 /out:"$(OUTDIR)\ftp.exe"
|
||||
LINK32_OBJS= \
|
||||
"$(INTDIR)\cmds.obj" \
|
||||
"$(INTDIR)\cmdtab.obj" \
|
||||
"$(INTDIR)\domacro.obj" \
|
||||
"$(INTDIR)\fake.obj" \
|
||||
"$(INTDIR)\ftp.obj" \
|
||||
"$(INTDIR)\main.obj" \
|
||||
"$(INTDIR)\ruserpass.obj"
|
||||
|
||||
"$(OUTDIR)\ftp.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
|
||||
$(LINK32) @<<
|
||||
$(LINK32_FLAGS) $(LINK32_OBJS)
|
||||
<<
|
||||
|
||||
TargetPath=.\Release\ftp.exe
|
||||
InputPath=.\Release\ftp.exe
|
||||
SOURCE=$(InputPath)
|
||||
|
||||
!ELSEIF "$(CFG)" == "ftp - Win32 Debug"
|
||||
|
||||
OUTDIR=.\Debug
|
||||
INTDIR=.\Debug
|
||||
# Begin Custom Macros
|
||||
OutDir=.\Debug
|
||||
# End Custom Macros
|
||||
|
||||
!IF "$(RECURSE)" == "0"
|
||||
|
||||
ALL : "$(OUTDIR)\ftp.exe"
|
||||
|
||||
!ELSE
|
||||
|
||||
ALL : "$(OUTDIR)\ftp.exe"
|
||||
|
||||
!ENDIF
|
||||
|
||||
CLEAN :
|
||||
-@erase "$(INTDIR)\cmds.obj"
|
||||
-@erase "$(INTDIR)\cmdtab.obj"
|
||||
-@erase "$(INTDIR)\domacro.obj"
|
||||
-@erase "$(INTDIR)\fake.obj"
|
||||
-@erase "$(INTDIR)\ftp.obj"
|
||||
-@erase "$(INTDIR)\main.obj"
|
||||
-@erase "$(INTDIR)\ruserpass.obj"
|
||||
-@erase "$(INTDIR)\vc*.idb"
|
||||
-@erase "$(INTDIR)\vc*.pdb"
|
||||
-@erase "$(OUTDIR)\ftp.exe"
|
||||
-@erase "$(OUTDIR)\ftp.ilk"
|
||||
-@erase "$(OUTDIR)\ftp.pdb"
|
||||
-@erase "$(OUTDIR)\ftp.pch"
|
||||
|
||||
"$(OUTDIR)" :
|
||||
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
|
||||
|
||||
CPP=cl.exe
|
||||
CPP_PROJ=/nologo /MLd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS"\
|
||||
/Fp"$(INTDIR)\ftp.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c
|
||||
CPP_OBJS=.\Debug/
|
||||
CPP_SBRS=.
|
||||
|
||||
.c{$(CPP_OBJS)}.obj::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cpp{$(CPP_OBJS)}.obj::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cxx{$(CPP_OBJS)}.obj::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.c{$(CPP_SBRS)}.sbr::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cpp{$(CPP_SBRS)}.sbr::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cxx{$(CPP_SBRS)}.sbr::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
RSC=rc.exe
|
||||
BSC32=bscmake.exe
|
||||
BSC32_FLAGS=/nologo /o"$(OUTDIR)\ftp.bsc"
|
||||
BSC32_SBRS= \
|
||||
|
||||
LINK32=link.exe
|
||||
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib\
|
||||
advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib\
|
||||
odbccp32.lib wsock32.lib /nologo /subsystem:console /incremental:yes\
|
||||
/pdb:"$(OUTDIR)\ftp.pdb" /debug /machine:I386 /out:"$(OUTDIR)\ftp.exe"\
|
||||
/pdbtype:sept
|
||||
LINK32_OBJS= \
|
||||
"$(INTDIR)\cmds.obj" \
|
||||
"$(INTDIR)\cmdtab.obj" \
|
||||
"$(INTDIR)\domacro.obj" \
|
||||
"$(INTDIR)\fake.obj" \
|
||||
"$(INTDIR)\ftp.obj" \
|
||||
"$(INTDIR)\main.obj" \
|
||||
"$(INTDIR)\ruserpass.obj"
|
||||
|
||||
"$(OUTDIR)\ftp.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
|
||||
$(LINK32) @<<
|
||||
$(LINK32_FLAGS) $(LINK32_OBJS)
|
||||
<<
|
||||
|
||||
TargetPath=.\Debug\ftp.exe
|
||||
InputPath=.\Debug\ftp.exe
|
||||
SOURCE=$(InputPath)
|
||||
|
||||
!ENDIF
|
||||
|
||||
|
||||
!IF "$(CFG)" == "ftp - Win32 Release" || "$(CFG)" == "ftp - Win32 Debug"
|
||||
SOURCE=.\cmds.c
|
||||
|
||||
!IF "$(CFG)" == "ftp - Win32 Release"
|
||||
|
||||
DEP_CPP_CMDS_=\
|
||||
".\fake.h"\
|
||||
".\ftp_var.h"\
|
||||
".\pathnames.h"\
|
||||
".\prototypes.h"\
|
||||
|
||||
|
||||
"$(INTDIR)\cmds.obj" : $(SOURCE) $(DEP_CPP_CMDS_) "$(INTDIR)"
|
||||
|
||||
|
||||
!ELSEIF "$(CFG)" == "ftp - Win32 Debug"
|
||||
|
||||
DEP_CPP_CMDS_=\
|
||||
".\fake.h"\
|
||||
".\ftp_var.h"\
|
||||
".\pathnames.h"\
|
||||
".\prototypes.h"\
|
||||
{$(INCLUDE)}"sys\stat.h"\
|
||||
{$(INCLUDE)}"sys\types.h"\
|
||||
|
||||
|
||||
"$(INTDIR)\cmds.obj" : $(SOURCE) $(DEP_CPP_CMDS_) "$(INTDIR)"
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
SOURCE=.\cmdtab.c
|
||||
DEP_CPP_CMDTA=\
|
||||
".\fake.h"\
|
||||
".\ftp_var.h"\
|
||||
|
||||
|
||||
"$(INTDIR)\cmdtab.obj" : $(SOURCE) $(DEP_CPP_CMDTA) "$(INTDIR)"
|
||||
|
||||
|
||||
SOURCE=.\domacro.c
|
||||
DEP_CPP_DOMAC=\
|
||||
".\fake.h"\
|
||||
".\ftp_var.h"\
|
||||
".\prototypes.h"\
|
||||
|
||||
|
||||
"$(INTDIR)\domacro.obj" : $(SOURCE) $(DEP_CPP_DOMAC) "$(INTDIR)"
|
||||
|
||||
|
||||
SOURCE=.\fake.c
|
||||
DEP_CPP_FAKE_=\
|
||||
".\prototypes.h"\
|
||||
|
||||
|
||||
"$(INTDIR)\fake.obj" : $(SOURCE) $(DEP_CPP_FAKE_) "$(INTDIR)"
|
||||
|
||||
|
||||
SOURCE=.\ftp.c
|
||||
|
||||
!IF "$(CFG)" == "ftp - Win32 Release"
|
||||
|
||||
DEP_CPP_FTP_C=\
|
||||
".\fake.h"\
|
||||
".\ftp_var.h"\
|
||||
".\prototypes.h"\
|
||||
|
||||
|
||||
"$(INTDIR)\ftp.obj" : $(SOURCE) $(DEP_CPP_FTP_C) "$(INTDIR)"
|
||||
|
||||
|
||||
!ELSEIF "$(CFG)" == "ftp - Win32 Debug"
|
||||
|
||||
DEP_CPP_FTP_C=\
|
||||
".\fake.h"\
|
||||
".\ftp_var.h"\
|
||||
".\prototypes.h"\
|
||||
{$(INCLUDE)}"sys\stat.h"\
|
||||
{$(INCLUDE)}"sys\types.h"\
|
||||
|
||||
|
||||
"$(INTDIR)\ftp.obj" : $(SOURCE) $(DEP_CPP_FTP_C) "$(INTDIR)"
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
SOURCE=.\main.c
|
||||
|
||||
!IF "$(CFG)" == "ftp - Win32 Release"
|
||||
|
||||
DEP_CPP_MAIN_=\
|
||||
".\fake.h"\
|
||||
".\ftp_var.h"\
|
||||
".\prototypes.h"\
|
||||
|
||||
|
||||
"$(INTDIR)\main.obj" : $(SOURCE) $(DEP_CPP_MAIN_) "$(INTDIR)"
|
||||
|
||||
|
||||
!ELSEIF "$(CFG)" == "ftp - Win32 Debug"
|
||||
|
||||
DEP_CPP_MAIN_=\
|
||||
".\fake.h"\
|
||||
".\ftp_var.h"\
|
||||
".\prototypes.h"\
|
||||
{$(INCLUDE)}"sys\types.h"\
|
||||
|
||||
|
||||
"$(INTDIR)\main.obj" : $(SOURCE) $(DEP_CPP_MAIN_) "$(INTDIR)"
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
SOURCE=.\ruserpass.c
|
||||
|
||||
!IF "$(CFG)" == "ftp - Win32 Release"
|
||||
|
||||
DEP_CPP_RUSER=\
|
||||
".\fake.h"\
|
||||
".\ftp_var.h"\
|
||||
".\prototypes.h"\
|
||||
|
||||
|
||||
"$(INTDIR)\ruserpass.obj" : $(SOURCE) $(DEP_CPP_RUSER) "$(INTDIR)"
|
||||
|
||||
|
||||
!ELSEIF "$(CFG)" == "ftp - Win32 Debug"
|
||||
|
||||
DEP_CPP_RUSER=\
|
||||
".\fake.h"\
|
||||
".\ftp_var.h"\
|
||||
".\prototypes.h"\
|
||||
{$(INCLUDE)}"sys\stat.h"\
|
||||
{$(INCLUDE)}"sys\types.h"\
|
||||
|
||||
|
||||
"$(INTDIR)\ruserpass.obj" : $(SOURCE) $(DEP_CPP_RUSER) "$(INTDIR)"
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
|
||||
!ENDIF
|
400
reactos/apps/utils/net/ftp/ftp.mak.orig
Normal file
400
reactos/apps/utils/net/ftp/ftp.mak.orig
Normal file
@@ -0,0 +1,400 @@
|
||||
# Microsoft Developer Studio Generated NMAKE File, Based on ftp.dsp
|
||||
!IF "$(CFG)" == ""
|
||||
CFG=ftp - Win32 Debug
|
||||
!MESSAGE No configuration specified. Defaulting to ftp - Win32 Debug.
|
||||
!ENDIF
|
||||
|
||||
!IF "$(CFG)" != "ftp - Win32 Release" && "$(CFG)" != "ftp - Win32 Debug"
|
||||
!MESSAGE Invalid configuration "$(CFG)" specified.
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "ftp.mak" CFG="ftp - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "ftp - Win32 Release" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE "ftp - Win32 Debug" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE
|
||||
!ERROR An invalid configuration is specified.
|
||||
!ENDIF
|
||||
|
||||
!IF "$(OS)" == "Windows_NT"
|
||||
NULL=
|
||||
!ELSE
|
||||
NULL=nul
|
||||
!ENDIF
|
||||
|
||||
!IF "$(CFG)" == "ftp - Win32 Release"
|
||||
|
||||
OUTDIR=.\Release
|
||||
INTDIR=.\Release
|
||||
# Begin Custom Macros
|
||||
OutDir=.\Release
|
||||
# End Custom Macros
|
||||
|
||||
!IF "$(RECURSE)" == "0"
|
||||
|
||||
ALL : "$(OUTDIR)\ftp.exe" "\emacs-19.34\bin\ftp.exe"
|
||||
|
||||
!ELSE
|
||||
|
||||
ALL : "$(OUTDIR)\ftp.exe" "\emacs-19.34\bin\ftp.exe"
|
||||
|
||||
!ENDIF
|
||||
|
||||
CLEAN :
|
||||
-@erase "$(INTDIR)\cmds.obj"
|
||||
-@erase "$(INTDIR)\cmdtab.obj"
|
||||
-@erase "$(INTDIR)\domacro.obj"
|
||||
-@erase "$(INTDIR)\fake.obj"
|
||||
-@erase "$(INTDIR)\ftp.obj"
|
||||
-@erase "$(INTDIR)\main.obj"
|
||||
-@erase "$(INTDIR)\ruserpass.obj"
|
||||
-@erase "$(INTDIR)\vc50.idb"
|
||||
-@erase "$(OUTDIR)\ftp.exe"
|
||||
-@erase "\emacs-19.34\bin\ftp.exe"
|
||||
|
||||
"$(OUTDIR)" :
|
||||
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
|
||||
|
||||
CPP=cl.exe
|
||||
CPP_PROJ=/nologo /ML /W3 /GX /O2 /I "C:\emacs-19.34\nt\inc" /I\
|
||||
"C:\emacs-19.34\src" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D\
|
||||
"HAVE_TIMEVAL" /Fp"$(INTDIR)\ftp.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD\
|
||||
/c
|
||||
CPP_OBJS=.\Release/
|
||||
CPP_SBRS=.
|
||||
|
||||
.c{$(CPP_OBJS)}.obj::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cpp{$(CPP_OBJS)}.obj::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cxx{$(CPP_OBJS)}.obj::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.c{$(CPP_SBRS)}.sbr::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cpp{$(CPP_SBRS)}.sbr::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cxx{$(CPP_SBRS)}.sbr::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
RSC=rc.exe
|
||||
BSC32=bscmake.exe
|
||||
BSC32_FLAGS=/nologo /o"$(OUTDIR)\ftp.bsc"
|
||||
BSC32_SBRS= \
|
||||
|
||||
LINK32=link.exe
|
||||
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib\
|
||||
advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib\
|
||||
odbccp32.lib /nologo /subsystem:console /incremental:no\
|
||||
/pdb:"$(OUTDIR)\ftp.pdb" /machine:I386 /out:"$(OUTDIR)\ftp.exe"
|
||||
LINK32_OBJS= \
|
||||
"$(INTDIR)\cmds.obj" \
|
||||
"$(INTDIR)\cmdtab.obj" \
|
||||
"$(INTDIR)\domacro.obj" \
|
||||
"$(INTDIR)\fake.obj" \
|
||||
"$(INTDIR)\ftp.obj" \
|
||||
"$(INTDIR)\main.obj" \
|
||||
"$(INTDIR)\ruserpass.obj" \
|
||||
"d:\Program Files\DevStudio\VC\lib\WSOCK32.LIB"
|
||||
|
||||
"$(OUTDIR)\ftp.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
|
||||
$(LINK32) @<<
|
||||
$(LINK32_FLAGS) $(LINK32_OBJS)
|
||||
<<
|
||||
|
||||
TargetPath=.\Release\ftp.exe
|
||||
InputPath=.\Release\ftp.exe
|
||||
SOURCE=$(InputPath)
|
||||
|
||||
"\emacs-19.34\bin\ftp.exe" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
|
||||
# copy $(TargetPath) \emacs-19.34\bin
|
||||
|
||||
!ELSEIF "$(CFG)" == "ftp - Win32 Debug"
|
||||
|
||||
OUTDIR=.\Debug
|
||||
INTDIR=.\Debug
|
||||
# Begin Custom Macros
|
||||
OutDir=.\Debug
|
||||
# End Custom Macros
|
||||
|
||||
!IF "$(RECURSE)" == "0"
|
||||
|
||||
ALL : "$(OUTDIR)\ftp.exe" "\emacs-19.34\bin\ftp.exe"
|
||||
|
||||
!ELSE
|
||||
|
||||
ALL : "$(OUTDIR)\ftp.exe" "\emacs-19.34\bin\ftp.exe"
|
||||
|
||||
!ENDIF
|
||||
|
||||
CLEAN :
|
||||
-@erase "$(INTDIR)\cmds.obj"
|
||||
-@erase "$(INTDIR)\cmdtab.obj"
|
||||
-@erase "$(INTDIR)\domacro.obj"
|
||||
-@erase "$(INTDIR)\fake.obj"
|
||||
-@erase "$(INTDIR)\ftp.obj"
|
||||
-@erase "$(INTDIR)\main.obj"
|
||||
-@erase "$(INTDIR)\ruserpass.obj"
|
||||
-@erase "$(INTDIR)\vc50.idb"
|
||||
-@erase "$(INTDIR)\vc50.pdb"
|
||||
-@erase "$(OUTDIR)\ftp.exe"
|
||||
-@erase "$(OUTDIR)\ftp.ilk"
|
||||
-@erase "$(OUTDIR)\ftp.pdb"
|
||||
-@erase "\emacs-19.34\bin\ftp.exe"
|
||||
|
||||
"$(OUTDIR)" :
|
||||
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
|
||||
|
||||
CPP=cl.exe
|
||||
CPP_PROJ=/nologo /MLd /W3 /Gm /GX /Zi /Od /I "C:\emacs-19.34\nt\inc" /I\
|
||||
"C:\emacs-19.34\src" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS"\
|
||||
/Fp"$(INTDIR)\ftp.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c
|
||||
CPP_OBJS=.\Debug/
|
||||
CPP_SBRS=.
|
||||
|
||||
.c{$(CPP_OBJS)}.obj::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cpp{$(CPP_OBJS)}.obj::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cxx{$(CPP_OBJS)}.obj::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.c{$(CPP_SBRS)}.sbr::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cpp{$(CPP_SBRS)}.sbr::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cxx{$(CPP_SBRS)}.sbr::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
RSC=rc.exe
|
||||
BSC32=bscmake.exe
|
||||
BSC32_FLAGS=/nologo /o"$(OUTDIR)\ftp.bsc"
|
||||
BSC32_SBRS= \
|
||||
|
||||
LINK32=link.exe
|
||||
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib\
|
||||
advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib\
|
||||
odbccp32.lib /nologo /subsystem:console /incremental:yes\
|
||||
/pdb:"$(OUTDIR)\ftp.pdb" /debug /machine:I386 /out:"$(OUTDIR)\ftp.exe"\
|
||||
/pdbtype:sept
|
||||
LINK32_OBJS= \
|
||||
"$(INTDIR)\cmds.obj" \
|
||||
"$(INTDIR)\cmdtab.obj" \
|
||||
"$(INTDIR)\domacro.obj" \
|
||||
"$(INTDIR)\fake.obj" \
|
||||
"$(INTDIR)\ftp.obj" \
|
||||
"$(INTDIR)\main.obj" \
|
||||
"$(INTDIR)\ruserpass.obj" \
|
||||
"d:\Program Files\DevStudio\VC\lib\WSOCK32.LIB"
|
||||
|
||||
"$(OUTDIR)\ftp.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
|
||||
$(LINK32) @<<
|
||||
$(LINK32_FLAGS) $(LINK32_OBJS)
|
||||
<<
|
||||
|
||||
TargetPath=.\Debug\ftp.exe
|
||||
InputPath=.\Debug\ftp.exe
|
||||
SOURCE=$(InputPath)
|
||||
|
||||
"\emacs-19.34\bin\ftp.exe" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
|
||||
# copy $(TargetPath) \emacs-19.34\bin
|
||||
|
||||
!ENDIF
|
||||
|
||||
|
||||
!IF "$(CFG)" == "ftp - Win32 Release" || "$(CFG)" == "ftp - Win32 Debug"
|
||||
SOURCE=.\cmds.c
|
||||
|
||||
!IF "$(CFG)" == "ftp - Win32 Release"
|
||||
|
||||
DEP_CPP_CMDS_=\
|
||||
".\fake.h"\
|
||||
".\ftp_var.h"\
|
||||
".\pathnames.h"\
|
||||
".\prototypes.h"\
|
||||
|
||||
|
||||
"$(INTDIR)\cmds.obj" : $(SOURCE) $(DEP_CPP_CMDS_) "$(INTDIR)"
|
||||
|
||||
|
||||
!ELSEIF "$(CFG)" == "ftp - Win32 Debug"
|
||||
|
||||
DEP_CPP_CMDS_=\
|
||||
"..\..\..\emacs-19.34\nt\inc\netdb.h"\
|
||||
"..\..\..\emacs-19.34\nt\inc\netinet\in.h"\
|
||||
"..\..\..\emacs-19.34\nt\inc\sys\socket.h"\
|
||||
"..\..\..\emacs-19.34\src\nt.h"\
|
||||
".\fake.h"\
|
||||
".\ftp_var.h"\
|
||||
".\pathnames.h"\
|
||||
".\prototypes.h"\
|
||||
{$(INCLUDE)}"sys\stat.h"\
|
||||
{$(INCLUDE)}"sys\types.h"\
|
||||
|
||||
|
||||
"$(INTDIR)\cmds.obj" : $(SOURCE) $(DEP_CPP_CMDS_) "$(INTDIR)"
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
SOURCE=.\cmdtab.c
|
||||
DEP_CPP_CMDTA=\
|
||||
".\fake.h"\
|
||||
".\ftp_var.h"\
|
||||
|
||||
|
||||
"$(INTDIR)\cmdtab.obj" : $(SOURCE) $(DEP_CPP_CMDTA) "$(INTDIR)"
|
||||
|
||||
|
||||
SOURCE=.\domacro.c
|
||||
DEP_CPP_DOMAC=\
|
||||
".\fake.h"\
|
||||
".\ftp_var.h"\
|
||||
".\prototypes.h"\
|
||||
|
||||
|
||||
"$(INTDIR)\domacro.obj" : $(SOURCE) $(DEP_CPP_DOMAC) "$(INTDIR)"
|
||||
|
||||
|
||||
SOURCE=.\fake.c
|
||||
DEP_CPP_FAKE_=\
|
||||
".\prototypes.h"\
|
||||
|
||||
|
||||
"$(INTDIR)\fake.obj" : $(SOURCE) $(DEP_CPP_FAKE_) "$(INTDIR)"
|
||||
|
||||
|
||||
SOURCE=.\ftp.c
|
||||
|
||||
!IF "$(CFG)" == "ftp - Win32 Release"
|
||||
|
||||
DEP_CPP_FTP_C=\
|
||||
".\fake.h"\
|
||||
".\ftp_var.h"\
|
||||
".\prototypes.h"\
|
||||
|
||||
|
||||
"$(INTDIR)\ftp.obj" : $(SOURCE) $(DEP_CPP_FTP_C) "$(INTDIR)"
|
||||
|
||||
|
||||
!ELSEIF "$(CFG)" == "ftp - Win32 Debug"
|
||||
|
||||
DEP_CPP_FTP_C=\
|
||||
"..\..\..\emacs-19.34\nt\inc\netdb.h"\
|
||||
"..\..\..\emacs-19.34\nt\inc\netinet\in.h"\
|
||||
"..\..\..\emacs-19.34\nt\inc\pwd.h"\
|
||||
"..\..\..\emacs-19.34\nt\inc\sys\file.h"\
|
||||
"..\..\..\emacs-19.34\nt\inc\sys\ioctl.h"\
|
||||
"..\..\..\emacs-19.34\nt\inc\sys\param.h"\
|
||||
"..\..\..\emacs-19.34\nt\inc\sys\socket.h"\
|
||||
"..\..\..\emacs-19.34\nt\inc\sys\time.h"\
|
||||
"..\..\..\emacs-19.34\src\nt.h"\
|
||||
".\fake.h"\
|
||||
".\ftp_var.h"\
|
||||
".\prototypes.h"\
|
||||
{$(INCLUDE)}"sys\stat.h"\
|
||||
{$(INCLUDE)}"sys\types.h"\
|
||||
|
||||
|
||||
"$(INTDIR)\ftp.obj" : $(SOURCE) $(DEP_CPP_FTP_C) "$(INTDIR)"
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
SOURCE=.\main.c
|
||||
|
||||
!IF "$(CFG)" == "ftp - Win32 Release"
|
||||
|
||||
DEP_CPP_MAIN_=\
|
||||
".\fake.h"\
|
||||
".\ftp_var.h"\
|
||||
".\prototypes.h"\
|
||||
|
||||
|
||||
"$(INTDIR)\main.obj" : $(SOURCE) $(DEP_CPP_MAIN_) "$(INTDIR)"
|
||||
|
||||
|
||||
!ELSEIF "$(CFG)" == "ftp - Win32 Debug"
|
||||
|
||||
DEP_CPP_MAIN_=\
|
||||
"..\..\..\emacs-19.34\nt\inc\netdb.h"\
|
||||
"..\..\..\emacs-19.34\nt\inc\pwd.h"\
|
||||
"..\..\..\emacs-19.34\nt\inc\sys\ioctl.h"\
|
||||
"..\..\..\emacs-19.34\nt\inc\sys\socket.h"\
|
||||
"..\..\..\emacs-19.34\src\nt.h"\
|
||||
".\fake.h"\
|
||||
".\ftp_var.h"\
|
||||
".\prototypes.h"\
|
||||
{$(INCLUDE)}"sys\types.h"\
|
||||
|
||||
|
||||
"$(INTDIR)\main.obj" : $(SOURCE) $(DEP_CPP_MAIN_) "$(INTDIR)"
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
SOURCE=.\ruserpass.c
|
||||
|
||||
!IF "$(CFG)" == "ftp - Win32 Release"
|
||||
|
||||
DEP_CPP_RUSER=\
|
||||
".\fake.h"\
|
||||
".\ftp_var.h"\
|
||||
".\prototypes.h"\
|
||||
|
||||
|
||||
"$(INTDIR)\ruserpass.obj" : $(SOURCE) $(DEP_CPP_RUSER) "$(INTDIR)"
|
||||
|
||||
|
||||
!ELSEIF "$(CFG)" == "ftp - Win32 Debug"
|
||||
|
||||
DEP_CPP_RUSER=\
|
||||
".\fake.h"\
|
||||
".\ftp_var.h"\
|
||||
".\prototypes.h"\
|
||||
{$(INCLUDE)}"sys\stat.h"\
|
||||
{$(INCLUDE)}"sys\types.h"\
|
||||
|
||||
|
||||
"$(INTDIR)\ruserpass.obj" : $(SOURCE) $(DEP_CPP_RUSER) "$(INTDIR)"
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
|
||||
!ENDIF
|
6
reactos/apps/utils/net/ftp/ftp.rc
Normal file
6
reactos/apps/utils/net/ftp/ftp.rc
Normal file
@@ -0,0 +1,6 @@
|
||||
/* $Id: route.rc 11816 2004-11-26 06:51:47Z arty $ */
|
||||
|
||||
#define REACTOS_STR_FILE_DESCRIPTION "ReactOS TCP/IPv4 FTP Client\0"
|
||||
#define REACTOS_STR_INTERNAL_NAME "ftp\0"
|
||||
#define REACTOS_STR_ORIGINAL_FILENAME "ftp.exe\0"
|
||||
#include <reactos/version.rc>
|
181
reactos/apps/utils/net/ftp/ftp_var.h
Normal file
181
reactos/apps/utils/net/ftp/ftp_var.h
Normal file
@@ -0,0 +1,181 @@
|
||||
#include "fake.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. */
|
||||
|
||||
#define IAC 255
|
||||
#define DONT 254
|
||||
#define DO 253
|
||||
#define WONT 252
|
||||
#define WILL 251
|
||||
#define SB 250
|
||||
#define GA 249
|
||||
#define EL 248
|
||||
#define EC 247
|
||||
#define AYT 246
|
||||
#define AO 245
|
||||
#define IP 244
|
||||
#define BREAK 243
|
||||
#define DM 242
|
||||
#define NOP 241
|
||||
#define SE 240
|
||||
#define EOR 239
|
||||
#define ABORT 238
|
||||
#define SUSP 237
|
||||
#define xEOF 236
|
||||
|
||||
|
||||
#define MAXPATHLEN 255
|
||||
#define TYPE_A 'A'
|
||||
#define TYPE_I 'I'
|
||||
#define TYPE_E 'E'
|
||||
#define TYPE_L 'L'
|
||||
|
||||
#define PRELIM 1
|
||||
#define COMPLETE 2
|
||||
#define CONTINUE 3
|
||||
#define TRANSIENT 4
|
||||
|
||||
#define MODE_S 1
|
||||
#define MODE_B 2
|
||||
#define MODE_C 3
|
||||
|
||||
#define STRU_F 1
|
||||
#define STRU_R 2
|
||||
#define STRU_P 3
|
||||
|
||||
#define SIGQUIT 1
|
||||
#define SIGPIPE 2
|
||||
#define SIGALRM 3
|
||||
|
||||
|
||||
#define FORM_N 1
|
||||
#define FORM_T 2
|
||||
#define FORM_C 3
|
||||
|
||||
|
||||
/*
|
||||
* Copyright (c) 1985 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 MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* @(#)ftp_var.h 5.5 (Berkeley) 6/29/88
|
||||
*/
|
||||
|
||||
/*
|
||||
* FTP global variables.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Options and other state info.
|
||||
*/
|
||||
extern int trace; /* trace packets exchanged */
|
||||
extern int hash; /* print # for each buffer transferred */
|
||||
extern int sendport; /* use PORT cmd for each data connection */
|
||||
extern int verbose; /* print messages coming back from server */
|
||||
extern int connected; /* connected to server */
|
||||
extern int fromatty; /* input is from a terminal */
|
||||
extern int interactive; /* interactively prompt on m* cmds */
|
||||
extern int debug; /* debugging level */
|
||||
extern int bell; /* ring bell on cmd completion */
|
||||
extern int doglob; /* glob local file names */
|
||||
extern int proxy; /* proxy server connection active */
|
||||
extern int proxflag; /* proxy connection exists */
|
||||
extern int sunique; /* store files on server with unique name */
|
||||
extern int runique; /* store local files with unique name */
|
||||
extern int mcase; /* map upper to lower case for mget names */
|
||||
extern int ntflag; /* use ntin ntout tables for name translation */
|
||||
extern int mapflag; /* use mapin mapout templates on file names */
|
||||
extern int code; /* return/reply code for ftp command */
|
||||
extern int crflag; /* if 1, strip car. rets. on ascii gets */
|
||||
extern char pasv[64]; /* passive port for proxy data connection */
|
||||
extern int passivemode; /* passive mode enabled */
|
||||
extern char *altarg; /* argv[1] with no shell-like preprocessing */
|
||||
extern char ntin[17]; /* input translation table */
|
||||
extern char ntout[17]; /* output translation table */
|
||||
|
||||
extern char mapin[MAXPATHLEN]; /* input map template */
|
||||
extern char mapout[MAXPATHLEN]; /* output map template */
|
||||
extern char typename[32]; /* name of file transfer type */
|
||||
extern int type; /* file transfer type */
|
||||
extern char structname[32]; /* name of file transfer structure */
|
||||
extern int stru; /* file transfer structure */
|
||||
extern char formname[32]; /* name of file transfer format */
|
||||
extern int form; /* file transfer format */
|
||||
extern char modename[32]; /* name of file transfer mode */
|
||||
extern int mode; /* file transfer mode */
|
||||
extern char bytename[32]; /* local byte size in ascii */
|
||||
extern int bytesize; /* local byte size in binary */
|
||||
|
||||
extern jmp_buf toplevel; /* non-local goto stuff for cmd scanner */
|
||||
|
||||
extern char line[200]; /* input line buffer */
|
||||
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 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 */
|
||||
|
||||
extern int options; /* used during socket creation */
|
||||
|
||||
/*
|
||||
* Format of command table.
|
||||
*/
|
||||
struct cmd {
|
||||
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 */
|
||||
int (*c_handler)(); /* function to call */
|
||||
};
|
||||
|
||||
struct macel {
|
||||
char mac_name[9]; /* macro name */
|
||||
char *mac_start; /* start of macro in macbuf */
|
||||
char *mac_end; /* end of macro in macbuf */
|
||||
};
|
||||
|
||||
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
|
||||
typedef int sig_t;
|
||||
#endif
|
||||
|
||||
typedef int uid_t;
|
||||
int herror(char *s);
|
602
reactos/apps/utils/net/ftp/main.c
Normal file
602
reactos/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;
|
||||
}
|
26
reactos/apps/utils/net/ftp/makefile
Normal file
26
reactos/apps/utils/net/ftp/makefile
Normal file
@@ -0,0 +1,26 @@
|
||||
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
|
21
reactos/apps/utils/net/ftp/pathnames.h
Normal file
21
reactos/apps/utils/net/ftp/pathnames.h
Normal file
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Copyright (c) 1989 The 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.
|
||||
*
|
||||
* %W% (Berkeley) %G%
|
||||
*/
|
||||
|
||||
#define _PATH_TMP "/tmp/ftpXXXXXX"
|
||||
#define _PATH_BSHELL "/bin/sh"
|
32
reactos/apps/utils/net/ftp/prototypes.h
Normal file
32
reactos/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);
|
271
reactos/apps/utils/net/ftp/ruserpass.c
Normal file
271
reactos/apps/utils/net/ftp/ruserpass.c
Normal file
@@ -0,0 +1,271 @@
|
||||
/*
|
||||
* Copyright (c) 1985 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
|
||||
static char sccsid[] = "@(#)ruserpass.c 5.1 (Berkeley) 3/1/89";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdio.h>
|
||||
//#include <utmp.h>
|
||||
#include <ctype.h>
|
||||
#include <sys/stat.h>
|
||||
#include <errno.h>
|
||||
#include "ftp_var.h"
|
||||
#include "prototypes.h"
|
||||
#include <winsock.h>
|
||||
|
||||
char *renvlook(), *index(), *getenv(), *getpass(), *getlogin();
|
||||
void *malloc();
|
||||
char *strcpy();
|
||||
struct utmp *getutmp();
|
||||
static FILE *cfile;
|
||||
|
||||
#ifndef MAXHOSTNAMELEN
|
||||
#define MAXHOSTNAMELEN 64
|
||||
#endif
|
||||
|
||||
#define DEFAULT 1
|
||||
#define LOGIN 2
|
||||
#define PASSWD 3
|
||||
#define ACCOUNT 4
|
||||
#define MACDEF 5
|
||||
#define ID 10
|
||||
#define MACH 11
|
||||
|
||||
static char tokval[100];
|
||||
|
||||
static struct toktab {
|
||||
char *tokstr;
|
||||
int tval;
|
||||
} toktab[]= {
|
||||
"default", DEFAULT,
|
||||
"login", LOGIN,
|
||||
"password", PASSWD,
|
||||
"passwd", PASSWD,
|
||||
"account", ACCOUNT,
|
||||
"machine", MACH,
|
||||
"macdef", MACDEF,
|
||||
0, 0
|
||||
};
|
||||
|
||||
extern char *hostname;
|
||||
|
||||
int ruserpass(char *host, char **aname, char **apass, char **aacct)
|
||||
{
|
||||
char *hdir, buf[BUFSIZ], *tmp;
|
||||
char myname[MAXHOSTNAMELEN], *mydomain;
|
||||
int t, i, c, usedefault = 0;
|
||||
struct stat stb;
|
||||
extern int errno;
|
||||
|
||||
hdir = getenv("HOME");
|
||||
if (hdir == NULL)
|
||||
hdir = ".";
|
||||
(void) sprintf(buf, "%s/.netrc", hdir);
|
||||
cfile = fopen(buf, "r");
|
||||
if (cfile == NULL) {
|
||||
if (errno != ENOENT)
|
||||
perror(buf);
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
if (gethostname(myname, sizeof(myname)) < 0)
|
||||
myname[0] = '\0';
|
||||
if ((mydomain = index(myname, '.')) == NULL)
|
||||
mydomain = "";
|
||||
next:
|
||||
while ((t = token())) switch(t) {
|
||||
|
||||
case DEFAULT:
|
||||
usedefault = 1;
|
||||
/* FALL THROUGH */
|
||||
|
||||
case MACH:
|
||||
if (!usedefault) {
|
||||
if (token() != ID)
|
||||
continue;
|
||||
/*
|
||||
* Allow match either for user's input host name
|
||||
* or official hostname. Also allow match of
|
||||
* incompletely-specified host in local domain.
|
||||
*/
|
||||
if (strcasecmp(host, tokval) == 0)
|
||||
goto match;
|
||||
if (strcasecmp(hostname, tokval) == 0)
|
||||
goto match;
|
||||
if ((tmp = index(hostname, '.')) != NULL &&
|
||||
strcasecmp(tmp, mydomain) == 0 &&
|
||||
strncasecmp(hostname, tokval, tmp - hostname) == 0 &&
|
||||
tokval[tmp - hostname] == '\0')
|
||||
goto match;
|
||||
if ((tmp = index(host, '.')) != NULL &&
|
||||
strcasecmp(tmp, mydomain) == 0 &&
|
||||
strncasecmp(host, tokval, tmp - host) == 0 &&
|
||||
tokval[tmp - host] == '\0')
|
||||
goto match;
|
||||
continue;
|
||||
}
|
||||
match:
|
||||
while ((t = token()) && t != MACH && t != DEFAULT) switch(t) {
|
||||
|
||||
case LOGIN:
|
||||
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") &&
|
||||
fstat(fileno(cfile), &stb) >= 0 &&
|
||||
(stb.st_mode & 077) != 0) {
|
||||
fprintf(stderr, "Error - .netrc file not correct mode.\n");
|
||||
fprintf(stderr, "Remove password or correct mode.\n");
|
||||
goto bad;
|
||||
}
|
||||
if (token() && *apass == 0) {
|
||||
*apass = malloc((unsigned) strlen(tokval) + 1);
|
||||
(void) strcpy(*apass, tokval);
|
||||
}
|
||||
break;
|
||||
case ACCOUNT:
|
||||
if (fstat(fileno(cfile), &stb) >= 0
|
||||
&& (stb.st_mode & 077) != 0) {
|
||||
fprintf(stderr, "Error - .netrc file not correct mode.\n");
|
||||
fprintf(stderr, "Remove account or correct mode.\n");
|
||||
goto bad;
|
||||
}
|
||||
if (token() && *aacct == 0) {
|
||||
*aacct = malloc((unsigned) strlen(tokval) + 1);
|
||||
(void) strcpy(*aacct, tokval);
|
||||
}
|
||||
break;
|
||||
case MACDEF:
|
||||
if (proxy) {
|
||||
(void) fclose(cfile);
|
||||
return(0);
|
||||
}
|
||||
while ((c=getc(cfile)) != EOF && c == ' ' || c == '\t');
|
||||
if (c == EOF || c == '\n') {
|
||||
printf("Missing macdef name argument.\n");
|
||||
goto bad;
|
||||
}
|
||||
if (macnum == 16) {
|
||||
printf("Limit of 16 macros have already been defined\n");
|
||||
goto bad;
|
||||
}
|
||||
tmp = macros[macnum].mac_name;
|
||||
*tmp++ = c;
|
||||
for (i=0; i < 8 && (c=getc(cfile)) != EOF &&
|
||||
!isspace(c); ++i) {
|
||||
*tmp++ = c;
|
||||
}
|
||||
if (c == EOF) {
|
||||
printf("Macro definition missing null line terminator.\n");
|
||||
goto bad;
|
||||
}
|
||||
*tmp = '\0';
|
||||
if (c != '\n') {
|
||||
while ((c=getc(cfile)) != EOF && c != '\n');
|
||||
}
|
||||
if (c == EOF) {
|
||||
printf("Macro definition missing null line terminator.\n");
|
||||
goto bad;
|
||||
}
|
||||
if (macnum == 0) {
|
||||
macros[macnum].mac_start = macbuf;
|
||||
}
|
||||
else {
|
||||
macros[macnum].mac_start = macros[macnum-1].mac_end + 1;
|
||||
}
|
||||
tmp = macros[macnum].mac_start;
|
||||
while (tmp != macbuf + 4096) {
|
||||
if ((c=getc(cfile)) == EOF) {
|
||||
printf("Macro definition missing null line terminator.\n");
|
||||
goto bad;
|
||||
}
|
||||
*tmp = c;
|
||||
if (*tmp == '\n') {
|
||||
if (*(tmp-1) == '\0') {
|
||||
macros[macnum++].mac_end = tmp - 1;
|
||||
break;
|
||||
}
|
||||
*tmp = '\0';
|
||||
}
|
||||
tmp++;
|
||||
}
|
||||
if (tmp == macbuf + 4096) {
|
||||
printf("4K macro buffer exceeded\n");
|
||||
goto bad;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "Unknown .netrc keyword %s\n", tokval);
|
||||
break;
|
||||
}
|
||||
goto done;
|
||||
}
|
||||
done:
|
||||
(void) fclose(cfile);
|
||||
return(0);
|
||||
bad:
|
||||
(void) fclose(cfile);
|
||||
return(-1);
|
||||
}
|
||||
|
||||
static int token(void)
|
||||
{
|
||||
char *cp;
|
||||
int c;
|
||||
struct toktab *t;
|
||||
|
||||
if (feof(cfile))
|
||||
return (0);
|
||||
while ((c = getc(cfile)) != EOF &&
|
||||
(c == '\r' || c == '\n' || c == '\t' || c == ' ' || c == ','))
|
||||
continue;
|
||||
if (c == EOF)
|
||||
return (0);
|
||||
cp = tokval;
|
||||
if (c == '"') {
|
||||
while ((c = getc(cfile)) != EOF && c != '"') {
|
||||
if (c == '\\')
|
||||
c = getc(cfile);
|
||||
*cp++ = c;
|
||||
}
|
||||
} else {
|
||||
*cp++ = c;
|
||||
while ((c = getc(cfile)) != EOF
|
||||
&& c != '\n' && c != '\t' && c != ' ' && c != ',' && c != '\r') {
|
||||
if (c == '\\')
|
||||
c = getc(cfile);
|
||||
*cp++ = c;
|
||||
}
|
||||
}
|
||||
*cp = 0;
|
||||
if (tokval[0] == 0)
|
||||
return (0);
|
||||
for (t = toktab; t->tokstr; t++)
|
||||
if (!strcmp(t->tokstr, tokval))
|
||||
return (t->tval);
|
||||
return (ID);
|
||||
}
|
@@ -1,17 +0,0 @@
|
||||
*.sys
|
||||
*.exe
|
||||
*.dll
|
||||
*.cpl
|
||||
*.a
|
||||
*.o
|
||||
*.d
|
||||
*.coff
|
||||
*.dsp
|
||||
*.dsw
|
||||
*.aps
|
||||
*.ncb
|
||||
*.opt
|
||||
*.sym
|
||||
*.plg
|
||||
*.bak
|
||||
*.map
|
@@ -1,4 +1,4 @@
|
||||
/* $Id: ipconfig.rc,v 1.1 2004/11/21 22:26:13 chorns Exp $ */
|
||||
/* $Id$ */
|
||||
|
||||
#define REACTOS_STR_FILE_DESCRIPTION "ReactOS TCP/IPv4 Win32 ipconfig\0"
|
||||
#define REACTOS_STR_INTERNAL_NAME "ipconfig\0"
|
||||
|
@@ -1,17 +0,0 @@
|
||||
*.sys
|
||||
*.exe
|
||||
*.dll
|
||||
*.cpl
|
||||
*.a
|
||||
*.o
|
||||
*.d
|
||||
*.coff
|
||||
*.dsp
|
||||
*.dsw
|
||||
*.aps
|
||||
*.ncb
|
||||
*.opt
|
||||
*.sym
|
||||
*.plg
|
||||
*.bak
|
||||
*.map
|
@@ -1,4 +1,4 @@
|
||||
/* $Id: netstat.rc,v 1.1 2004/11/21 22:26:14 chorns Exp $ */
|
||||
/* $Id$ */
|
||||
|
||||
#include <windows.h>
|
||||
#include "resource.h"
|
||||
|
@@ -1,17 +0,0 @@
|
||||
*.sys
|
||||
*.exe
|
||||
*.dll
|
||||
*.cpl
|
||||
*.a
|
||||
*.o
|
||||
*.d
|
||||
*.coff
|
||||
*.dsp
|
||||
*.dsw
|
||||
*.aps
|
||||
*.ncb
|
||||
*.opt
|
||||
*.sym
|
||||
*.plg
|
||||
*.bak
|
||||
*.map
|
@@ -1,4 +1,4 @@
|
||||
/* $Id: ping.c,v 1.7 2004/11/21 22:26:14 chorns Exp $
|
||||
/* $Id$
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS ping utility
|
||||
|
@@ -1,4 +1,4 @@
|
||||
/* $Id: ping.rc,v 1.3 2004/11/21 22:26:14 chorns Exp $ */
|
||||
/* $Id$ */
|
||||
|
||||
#define REACTOS_STR_FILE_DESCRIPTION "ReactOS TCP/IPv4 Win32 Ping\0"
|
||||
#define REACTOS_STR_INTERNAL_NAME "ping\0"
|
||||
|
@@ -1,6 +0,0 @@
|
||||
*.o
|
||||
*.d
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
@@ -1,2 +0,0 @@
|
||||
*.coff
|
||||
*.map
|
@@ -1,4 +1,4 @@
|
||||
/* $Id: roshttpd.rc,v 1.2 2004/10/16 20:27:20 gvg Exp $ */
|
||||
/* $Id$ */
|
||||
|
||||
#define REACTOS_STR_FILE_DESCRIPTION "ReactOS HTTP Win32 Server\0"
|
||||
#define REACTOS_STR_INTERNAL_NAME "roshttpd\0"
|
||||
|
@@ -1,4 +1,4 @@
|
||||
# $Id: makefile,v 1.8 2004/02/23 20:56:50 navaraf Exp $
|
||||
# $Id$
|
||||
|
||||
PATH_TO_TOP = ../../../..
|
||||
|
||||
|
@@ -1,17 +0,0 @@
|
||||
*.sys
|
||||
*.exe
|
||||
*.dll
|
||||
*.cpl
|
||||
*.a
|
||||
*.o
|
||||
*.d
|
||||
*.coff
|
||||
*.dsp
|
||||
*.dsw
|
||||
*.aps
|
||||
*.ncb
|
||||
*.opt
|
||||
*.sym
|
||||
*.plg
|
||||
*.bak
|
||||
*.map
|
@@ -1,4 +1,4 @@
|
||||
/* $Id: route.rc,v 1.1 2004/11/26 06:51:47 arty Exp $ */
|
||||
/* $Id$ */
|
||||
|
||||
#define REACTOS_STR_FILE_DESCRIPTION "ReactOS TCP/IPv4 Win32 Route\0"
|
||||
#define REACTOS_STR_INTERNAL_NAME "route\0"
|
||||
|
@@ -1,17 +0,0 @@
|
||||
*.sys
|
||||
*.exe
|
||||
*.dll
|
||||
*.cpl
|
||||
*.a
|
||||
*.o
|
||||
*.d
|
||||
*.coff
|
||||
*.dsp
|
||||
*.dsw
|
||||
*.aps
|
||||
*.ncb
|
||||
*.opt
|
||||
*.sym
|
||||
*.plg
|
||||
*.bak
|
||||
*.map
|
@@ -1,17 +0,0 @@
|
||||
*.sys
|
||||
*.exe
|
||||
*.dll
|
||||
*.cpl
|
||||
*.a
|
||||
*.o
|
||||
*.d
|
||||
*.coff
|
||||
*.dsp
|
||||
*.dsw
|
||||
*.aps
|
||||
*.ncb
|
||||
*.opt
|
||||
*.sym
|
||||
*.plg
|
||||
*.bak
|
||||
*.map
|
@@ -1,4 +1,4 @@
|
||||
/* $Id: telnet.rc,v 1.3 2004/11/21 22:24:55 chorns Exp $ */
|
||||
/* $Id$ */
|
||||
|
||||
#define REACTOS_STR_FILE_DESCRIPTION "Console Telnet for Win32\0"
|
||||
#define REACTOS_STR_INTERNAL_NAME "telnet\0"
|
||||
|
195
reactos/apps/utils/net/tracert/ip.h
Normal file
195
reactos/apps/utils/net/tracert/ip.h
Normal file
@@ -0,0 +1,195 @@
|
||||
/*
|
||||
* Copyright (c) 1982, 1986, 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. 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.
|
||||
*
|
||||
* @(#)ip.h 8.2 (Berkeley) 6/1/94
|
||||
* $FreeBSD: src/sys/netinet/ip.h,v 1.16 1999/08/28 00:49:19 peter Exp $
|
||||
*/
|
||||
|
||||
#ifndef _NETINET_IP_H_
|
||||
#define _NETINET_IP_H_
|
||||
|
||||
/*
|
||||
* Definitions for internet protocol version 4.
|
||||
* Per RFC 791, September 1981.
|
||||
*/
|
||||
#define IPVERSION 4
|
||||
|
||||
/* A little magic to make the Windows build happy. */
|
||||
#if defined(_MSC_VER) || defined(__MINGW32__)
|
||||
#include <winsock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
#include <time.h>
|
||||
|
||||
typedef u_short n_short;
|
||||
typedef u_int n_long;
|
||||
typedef u_int n_time;
|
||||
|
||||
#define EMSGSIZE WSAEMSGSIZE
|
||||
#define ENETUNREACH WSAENETUNREACH
|
||||
#define EHOSTUNREACH WSAEHOSTUNREACH
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Structure of an internet header, naked of options.
|
||||
*/
|
||||
struct ip {
|
||||
#ifdef _IP_VHL
|
||||
u_char ip_vhl; /* version << 4 | header length >> 2 */
|
||||
#else
|
||||
#if BYTE_ORDER == LITTLE_ENDIAN
|
||||
u_int ip_hl:4, /* header length */
|
||||
ip_v:4; /* version */
|
||||
#endif
|
||||
#if BYTE_ORDER == BIG_ENDIAN
|
||||
u_int ip_v:4, /* version */
|
||||
ip_hl:4; /* header length */
|
||||
#endif
|
||||
#endif /* not _IP_VHL */
|
||||
u_char ip_tos; /* type of service */
|
||||
u_short ip_len; /* total length */
|
||||
u_short ip_id; /* identification */
|
||||
u_short ip_off; /* fragment offset field */
|
||||
#define IP_RF 0x8000 /* reserved fragment flag */
|
||||
#define IP_DF 0x4000 /* don't fragment flag */
|
||||
#define IP_MF 0x2000 /* more fragments flag */
|
||||
#define IP_OFFMASK 0x1fff /* mask for fragmenting bits */
|
||||
u_char ip_ttl; /* time to live */
|
||||
u_char ip_p; /* protocol */
|
||||
u_short ip_sum; /* checksum */
|
||||
struct in_addr ip_src,ip_dst; /* source and dest address */
|
||||
};
|
||||
|
||||
#ifdef _IP_VHL
|
||||
#define IP_MAKE_VHL(v, hl) ((v) << 4 | (hl))
|
||||
#define IP_VHL_HL(vhl) ((vhl) & 0x0f)
|
||||
#define IP_VHL_V(vhl) ((vhl) >> 4)
|
||||
#define IP_VHL_BORING 0x45
|
||||
#endif
|
||||
|
||||
#define IP_MAXPACKET 65535 /* maximum packet size */
|
||||
|
||||
/*
|
||||
* Definitions for IP type of service (ip_tos)
|
||||
*/
|
||||
#define IPTOS_LOWDELAY 0x10
|
||||
#define IPTOS_THROUGHPUT 0x08
|
||||
#define IPTOS_RELIABILITY 0x04
|
||||
#define IPTOS_MINCOST 0x02
|
||||
|
||||
/*
|
||||
* Definitions for IP precedence (also in ip_tos) (hopefully unused)
|
||||
*/
|
||||
#define IPTOS_PREC_NETCONTROL 0xe0
|
||||
#define IPTOS_PREC_INTERNETCONTROL 0xc0
|
||||
#define IPTOS_PREC_CRITIC_ECP 0xa0
|
||||
#define IPTOS_PREC_FLASHOVERRIDE 0x80
|
||||
#define IPTOS_PREC_FLASH 0x60
|
||||
#define IPTOS_PREC_IMMEDIATE 0x40
|
||||
#define IPTOS_PREC_PRIORITY 0x20
|
||||
#define IPTOS_PREC_ROUTINE 0x00
|
||||
|
||||
/*
|
||||
* Definitions for options.
|
||||
*/
|
||||
#define IPOPT_COPIED(o) ((o)&0x80)
|
||||
#define IPOPT_CLASS(o) ((o)&0x60)
|
||||
#define IPOPT_NUMBER(o) ((o)&0x1f)
|
||||
|
||||
#define IPOPT_CONTROL 0x00
|
||||
#define IPOPT_RESERVED1 0x20
|
||||
#define IPOPT_DEBMEAS 0x40
|
||||
#define IPOPT_RESERVED2 0x60
|
||||
|
||||
#define IPOPT_EOL 0 /* end of option list */
|
||||
#define IPOPT_NOP 1 /* no operation */
|
||||
|
||||
#define IPOPT_RR 7 /* record packet route */
|
||||
#define IPOPT_TS 68 /* timestamp */
|
||||
#define IPOPT_SECURITY 130 /* provide s,c,h,tcc */
|
||||
#define IPOPT_LSRR 131 /* loose source route */
|
||||
#define IPOPT_SATID 136 /* satnet id */
|
||||
#define IPOPT_SSRR 137 /* strict source route */
|
||||
#define IPOPT_RA 148 /* router alert */
|
||||
|
||||
/*
|
||||
* Offsets to fields in options other than EOL and NOP.
|
||||
*/
|
||||
#define IPOPT_OPTVAL 0 /* option ID */
|
||||
#define IPOPT_OLEN 1 /* option length */
|
||||
#define IPOPT_OFFSET 2 /* offset within option */
|
||||
#define IPOPT_MINOFF 4 /* min value of above */
|
||||
|
||||
/*
|
||||
* Time stamp option structure.
|
||||
*/
|
||||
struct ip_timestamp {
|
||||
u_char ipt_code; /* IPOPT_TS */
|
||||
u_char ipt_len; /* size of structure (variable) */
|
||||
u_char ipt_ptr; /* index of current entry */
|
||||
#if BYTE_ORDER == LITTLE_ENDIAN
|
||||
u_int ipt_flg:4, /* flags, see below */
|
||||
ipt_oflw:4; /* overflow counter */
|
||||
#endif
|
||||
#if BYTE_ORDER == BIG_ENDIAN
|
||||
u_int ipt_oflw:4, /* overflow counter */
|
||||
ipt_flg:4; /* flags, see below */
|
||||
#endif
|
||||
union ipt_timestamp {
|
||||
n_long ipt_time[1];
|
||||
struct ipt_ta {
|
||||
struct in_addr ipt_addr;
|
||||
n_long ipt_time;
|
||||
} ipt_ta[1];
|
||||
} ipt_timestamp;
|
||||
};
|
||||
|
||||
/* flag bits for ipt_flg */
|
||||
#define IPOPT_TS_TSONLY 0 /* timestamps only */
|
||||
#define IPOPT_TS_TSANDADDR 1 /* timestamps and addresses */
|
||||
#define IPOPT_TS_PRESPEC 3 /* specified modules only */
|
||||
|
||||
/* bits for security (not byte swapped) */
|
||||
#define IPOPT_SECUR_UNCLASS 0x0000
|
||||
#define IPOPT_SECUR_CONFID 0xf135
|
||||
#define IPOPT_SECUR_EFTO 0x789a
|
||||
#define IPOPT_SECUR_MMMM 0xbc4d
|
||||
#define IPOPT_SECUR_RESTR 0xaf13
|
||||
#define IPOPT_SECUR_SECRET 0xd788
|
||||
#define IPOPT_SECUR_TOPSECRET 0x6bc5
|
||||
|
||||
/*
|
||||
* Internet implementation parameters.
|
||||
*/
|
||||
#define MAXTTL 255 /* maximum time to live (seconds) */
|
||||
#define IPDEFTTL 64 /* default ttl, from RFC 1340 */
|
||||
#define IPFRAGTTL 60 /* time to live for frags, slowhz */
|
||||
#define IPTTLDEC 1 /* subtracted when forwarding */
|
||||
|
||||
#define IP_MSS 576 /* default maximum segment size */
|
||||
|
||||
#endif
|
186
reactos/apps/utils/net/tracert/ip_icmp.h
Normal file
186
reactos/apps/utils/net/tracert/ip_icmp.h
Normal file
@@ -0,0 +1,186 @@
|
||||
/*
|
||||
* Copyright (c) 1982, 1986, 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. 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.
|
||||
*
|
||||
* @(#)ip_icmp.h 8.1 (Berkeley) 6/10/93
|
||||
* $FreeBSD: src/sys/netinet/ip_icmp.h,v 1.13 1999/08/28 00:49:24 peter Exp $
|
||||
*/
|
||||
|
||||
#ifndef _NETINET_IP_ICMP_H_
|
||||
#define _NETINET_IP_ICMP_H_
|
||||
|
||||
/*
|
||||
* Interface Control Message Protocol Definitions.
|
||||
* Per RFC 792, September 1981.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Internal of an ICMP Router Advertisement
|
||||
*/
|
||||
struct icmp_ra_addr {
|
||||
u_int32_t ira_addr;
|
||||
u_int32_t ira_preference;
|
||||
};
|
||||
|
||||
/*
|
||||
* Structure of an icmp header.
|
||||
*/
|
||||
struct icmp {
|
||||
u_char icmp_type; /* type of message, see below */
|
||||
u_char icmp_code; /* type sub code */
|
||||
u_short icmp_cksum; /* ones complement cksum of struct */
|
||||
union {
|
||||
u_char ih_pptr; /* ICMP_PARAMPROB */
|
||||
struct in_addr ih_gwaddr; /* ICMP_REDIRECT */
|
||||
struct ih_idseq {
|
||||
n_short icd_id;
|
||||
n_short icd_seq;
|
||||
} ih_idseq;
|
||||
int ih_void;
|
||||
|
||||
/* ICMP_UNREACH_NEEDFRAG -- Path MTU Discovery (RFC1191) */
|
||||
struct ih_pmtu {
|
||||
n_short ipm_void;
|
||||
n_short ipm_nextmtu;
|
||||
} ih_pmtu;
|
||||
|
||||
struct ih_rtradv {
|
||||
u_char irt_num_addrs;
|
||||
u_char irt_wpa;
|
||||
u_int16_t irt_lifetime;
|
||||
} ih_rtradv;
|
||||
} icmp_hun;
|
||||
#define icmp_pptr icmp_hun.ih_pptr
|
||||
#define icmp_gwaddr icmp_hun.ih_gwaddr
|
||||
#define icmp_id icmp_hun.ih_idseq.icd_id
|
||||
#define icmp_seq icmp_hun.ih_idseq.icd_seq
|
||||
#define icmp_void icmp_hun.ih_void
|
||||
#define icmp_pmvoid icmp_hun.ih_pmtu.ipm_void
|
||||
#define icmp_nextmtu icmp_hun.ih_pmtu.ipm_nextmtu
|
||||
#define icmp_num_addrs icmp_hun.ih_rtradv.irt_num_addrs
|
||||
#define icmp_wpa icmp_hun.ih_rtradv.irt_wpa
|
||||
#define icmp_lifetime icmp_hun.ih_rtradv.irt_lifetime
|
||||
union {
|
||||
struct id_ts {
|
||||
n_time its_otime;
|
||||
n_time its_rtime;
|
||||
n_time its_ttime;
|
||||
} id_ts;
|
||||
struct id_ip {
|
||||
struct ip idi_ip;
|
||||
/* options and then 64 bits of data */
|
||||
} id_ip;
|
||||
struct icmp_ra_addr id_radv;
|
||||
u_int32_t id_mask;
|
||||
char id_data[1];
|
||||
} icmp_dun;
|
||||
#define icmp_otime icmp_dun.id_ts.its_otime
|
||||
#define icmp_rtime icmp_dun.id_ts.its_rtime
|
||||
#define icmp_ttime icmp_dun.id_ts.its_ttime
|
||||
#define icmp_ip icmp_dun.id_ip.idi_ip
|
||||
#define icmp_radv icmp_dun.id_radv
|
||||
#define icmp_mask icmp_dun.id_mask
|
||||
#define icmp_data icmp_dun.id_data
|
||||
};
|
||||
|
||||
/*
|
||||
* Lower bounds on packet lengths for various types.
|
||||
* For the error advice packets must first insure that the
|
||||
* packet is large enough to contain the returned ip header.
|
||||
* Only then can we do the check to see if 64 bits of packet
|
||||
* data have been returned, since we need to check the returned
|
||||
* ip header length.
|
||||
*/
|
||||
#define ICMP_MINLEN 8 /* abs minimum */
|
||||
#define ICMP_TSLEN (8 + 3 * sizeof (n_time)) /* timestamp */
|
||||
#define ICMP_MASKLEN 12 /* address mask */
|
||||
#define ICMP_ADVLENMIN (8 + sizeof (struct ip) + 8) /* min */
|
||||
#ifndef _IP_VHL
|
||||
#define ICMP_ADVLEN(p) (8 + ((p)->icmp_ip.ip_hl << 2) + 8)
|
||||
/* N.B.: must separately check that ip_hl >= 5 */
|
||||
#else
|
||||
#define ICMP_ADVLEN(p) (8 + (IP_VHL_HL((p)->icmp_ip.ip_vhl) << 2) + 8)
|
||||
/* N.B.: must separately check that header length >= 5 */
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Definition of type and code field values.
|
||||
*/
|
||||
#define ICMP_ECHOREPLY 0 /* echo reply */
|
||||
#define ICMP_UNREACH 3 /* dest unreachable, codes: */
|
||||
#define ICMP_UNREACH_NET 0 /* bad net */
|
||||
#define ICMP_UNREACH_HOST 1 /* bad host */
|
||||
#define ICMP_UNREACH_PROTOCOL 2 /* bad protocol */
|
||||
#define ICMP_UNREACH_PORT 3 /* bad port */
|
||||
#define ICMP_UNREACH_NEEDFRAG 4 /* IP_DF caused drop */
|
||||
#define ICMP_UNREACH_SRCFAIL 5 /* src route failed */
|
||||
#define ICMP_UNREACH_NET_UNKNOWN 6 /* unknown net */
|
||||
#define ICMP_UNREACH_HOST_UNKNOWN 7 /* unknown host */
|
||||
#define ICMP_UNREACH_ISOLATED 8 /* src host isolated */
|
||||
#define ICMP_UNREACH_NET_PROHIB 9 /* prohibited access */
|
||||
#define ICMP_UNREACH_HOST_PROHIB 10 /* ditto */
|
||||
#define ICMP_UNREACH_TOSNET 11 /* bad tos for net */
|
||||
#define ICMP_UNREACH_TOSHOST 12 /* bad tos for host */
|
||||
#define ICMP_UNREACH_FILTER_PROHIB 13 /* admin prohib */
|
||||
#define ICMP_UNREACH_HOST_PRECEDENCE 14 /* host prec vio. */
|
||||
#define ICMP_UNREACH_PRECEDENCE_CUTOFF 15 /* prec cutoff */
|
||||
#define ICMP_SOURCEQUENCH 4 /* packet lost, slow down */
|
||||
#define ICMP_REDIRECT 5 /* shorter route, codes: */
|
||||
#define ICMP_REDIRECT_NET 0 /* for network */
|
||||
#define ICMP_REDIRECT_HOST 1 /* for host */
|
||||
#define ICMP_REDIRECT_TOSNET 2 /* for tos and net */
|
||||
#define ICMP_REDIRECT_TOSHOST 3 /* for tos and host */
|
||||
#define ICMP_ECHO 8 /* echo service */
|
||||
#define ICMP_ROUTERADVERT 9 /* router advertisement */
|
||||
#define ICMP_ROUTERSOLICIT 10 /* router solicitation */
|
||||
#define ICMP_TIMXCEED 11 /* time exceeded, code: */
|
||||
#define ICMP_TIMXCEED_INTRANS 0 /* ttl==0 in transit */
|
||||
#define ICMP_TIMXCEED_REASS 1 /* ttl==0 in reass */
|
||||
#define ICMP_PARAMPROB 12 /* ip header bad */
|
||||
#define ICMP_PARAMPROB_OPTABSENT 1 /* req. opt. absent */
|
||||
#define ICMP_TSTAMP 13 /* timestamp request */
|
||||
#define ICMP_TSTAMPREPLY 14 /* timestamp reply */
|
||||
#define ICMP_IREQ 15 /* information request */
|
||||
#define ICMP_IREQREPLY 16 /* information reply */
|
||||
#define ICMP_MASKREQ 17 /* address mask request */
|
||||
#define ICMP_MASKREPLY 18 /* address mask reply */
|
||||
|
||||
#define ICMP_MAXTYPE 18
|
||||
|
||||
#define ICMP_INFOTYPE(type) \
|
||||
((type) == ICMP_ECHOREPLY || (type) == ICMP_ECHO || \
|
||||
(type) == ICMP_ROUTERADVERT || (type) == ICMP_ROUTERSOLICIT || \
|
||||
(type) == ICMP_TSTAMP || (type) == ICMP_TSTAMPREPLY || \
|
||||
(type) == ICMP_IREQ || (type) == ICMP_IREQREPLY || \
|
||||
(type) == ICMP_MASKREQ || (type) == ICMP_MASKREPLY)
|
||||
|
||||
#ifdef KERNEL
|
||||
void icmp_error __P((struct mbuf *, int, int, n_long, struct ifnet *));
|
||||
void icmp_input __P((struct mbuf *, int));
|
||||
#endif
|
||||
|
||||
#endif
|
20
reactos/apps/utils/net/tracert/makefile
Normal file
20
reactos/apps/utils/net/tracert/makefile
Normal file
@@ -0,0 +1,20 @@
|
||||
PATH_TO_TOP = ../../../..
|
||||
|
||||
TARGET_TYPE = program
|
||||
|
||||
TARGET_APPTYPE = console
|
||||
|
||||
TARGET_NAME = tracert
|
||||
|
||||
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
|
957
reactos/apps/utils/net/tracert/tracert.c
Normal file
957
reactos/apps/utils/net/tracert/tracert.c
Normal file
@@ -0,0 +1,957 @@
|
||||
/*-
|
||||
* Copyright (c) 1990, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Van Jacobson.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static char copyright[] =
|
||||
"@(#) Copyright (c) 1990, 1993\n\
|
||||
The Regents of the University of California. All rights reserved.\n";
|
||||
#endif /* not lint */
|
||||
|
||||
#ifndef lint
|
||||
static char sccsid[] = "@(#)traceroute.c 8.1 (Berkeley) 6/6/93";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
* traceroute host - trace the route ip packets follow going to "host".
|
||||
*
|
||||
* Attempt to trace the route an ip packet would follow to some
|
||||
* internet host. We find out intermediate hops by launching probe
|
||||
* packets with a small ttl (time to live) then listening for an
|
||||
* icmp "time exceeded" reply from a gateway. We start our probes
|
||||
* with a ttl of one and increase by one until we get an icmp "port
|
||||
* unreachable" (which means we got to "host") or hit a max (which
|
||||
* defaults to 30 hops & can be changed with the -m flag). Three
|
||||
* probes (change with -q flag) are sent at each ttl setting and a
|
||||
* line is printed showing the ttl, address of the gateway and
|
||||
* round trip time of each probe. If the probe answers come from
|
||||
* different gateways, the address of each responding system will
|
||||
* be printed. If there is no response within a 5 sec. timeout
|
||||
* interval (changed with the -w flag), a "*" is printed for that
|
||||
* probe.
|
||||
*
|
||||
* Probe packets are UDP format. We don't want the destination
|
||||
* host to process them so the destination port is set to an
|
||||
* unlikely value (if some clod on the destination is using that
|
||||
* value, it can be changed with the -p flag).
|
||||
*
|
||||
* A sample use might be:
|
||||
*
|
||||
* [yak 71]% traceroute nis.nsf.net.
|
||||
* traceroute to nis.nsf.net (35.1.1.48), 30 hops max, 56 byte packet
|
||||
* 1 helios.ee.lbl.gov (128.3.112.1) 19 ms 19 ms 0 ms
|
||||
* 2 lilac-dmc.Berkeley.EDU (128.32.216.1) 39 ms 39 ms 19 ms
|
||||
* 3 lilac-dmc.Berkeley.EDU (128.32.216.1) 39 ms 39 ms 19 ms
|
||||
* 4 ccngw-ner-cc.Berkeley.EDU (128.32.136.23) 39 ms 40 ms 39 ms
|
||||
* 5 ccn-nerif22.Berkeley.EDU (128.32.168.22) 39 ms 39 ms 39 ms
|
||||
* 6 128.32.197.4 (128.32.197.4) 40 ms 59 ms 59 ms
|
||||
* 7 131.119.2.5 (131.119.2.5) 59 ms 59 ms 59 ms
|
||||
* 8 129.140.70.13 (129.140.70.13) 99 ms 99 ms 80 ms
|
||||
* 9 129.140.71.6 (129.140.71.6) 139 ms 239 ms 319 ms
|
||||
* 10 129.140.81.7 (129.140.81.7) 220 ms 199 ms 199 ms
|
||||
* 11 nic.merit.edu (35.1.1.48) 239 ms 239 ms 239 ms
|
||||
*
|
||||
* Note that lines 2 & 3 are the same. This is due to a buggy
|
||||
* kernel on the 2nd hop system -- lbl-csam.arpa -- that forwards
|
||||
* packets with a zero ttl.
|
||||
*
|
||||
* A more interesting example is:
|
||||
*
|
||||
* [yak 72]% traceroute allspice.lcs.mit.edu.
|
||||
* traceroute to allspice.lcs.mit.edu (18.26.0.115), 30 hops max
|
||||
* 1 helios.ee.lbl.gov (128.3.112.1) 0 ms 0 ms 0 ms
|
||||
* 2 lilac-dmc.Berkeley.EDU (128.32.216.1) 19 ms 19 ms 19 ms
|
||||
* 3 lilac-dmc.Berkeley.EDU (128.32.216.1) 39 ms 19 ms 19 ms
|
||||
* 4 ccngw-ner-cc.Berkeley.EDU (128.32.136.23) 19 ms 39 ms 39 ms
|
||||
* 5 ccn-nerif22.Berkeley.EDU (128.32.168.22) 20 ms 39 ms 39 ms
|
||||
* 6 128.32.197.4 (128.32.197.4) 59 ms 119 ms 39 ms
|
||||
* 7 131.119.2.5 (131.119.2.5) 59 ms 59 ms 39 ms
|
||||
* 8 129.140.70.13 (129.140.70.13) 80 ms 79 ms 99 ms
|
||||
* 9 129.140.71.6 (129.140.71.6) 139 ms 139 ms 159 ms
|
||||
* 10 129.140.81.7 (129.140.81.7) 199 ms 180 ms 300 ms
|
||||
* 11 129.140.72.17 (129.140.72.17) 300 ms 239 ms 239 ms
|
||||
* 12 * * *
|
||||
* 13 128.121.54.72 (128.121.54.72) 259 ms 499 ms 279 ms
|
||||
* 14 * * *
|
||||
* 15 * * *
|
||||
* 16 * * *
|
||||
* 17 * * *
|
||||
* 18 ALLSPICE.LCS.MIT.EDU (18.26.0.115) 339 ms 279 ms 279 ms
|
||||
*
|
||||
* (I start to see why I'm having so much trouble with mail to
|
||||
* MIT.) Note that the gateways 12, 14, 15, 16 & 17 hops away
|
||||
* either don't send ICMP "time exceeded" messages or send them
|
||||
* with a ttl too small to reach us. 14 - 17 are running the
|
||||
* MIT C Gateway code that doesn't send "time exceeded"s. God
|
||||
* only knows what's going on with 12.
|
||||
*
|
||||
* The silent gateway 12 in the above may be the result of a bug in
|
||||
* the 4.[23]BSD network code (and its derivatives): 4.x (x <= 3)
|
||||
* sends an unreachable message using whatever ttl remains in the
|
||||
* original datagram. Since, for gateways, the remaining ttl is
|
||||
* zero, the icmp "time exceeded" is guaranteed to not make it back
|
||||
* to us. The behavior of this bug is slightly more interesting
|
||||
* when it appears on the destination system:
|
||||
*
|
||||
* 1 helios.ee.lbl.gov (128.3.112.1) 0 ms 0 ms 0 ms
|
||||
* 2 lilac-dmc.Berkeley.EDU (128.32.216.1) 39 ms 19 ms 39 ms
|
||||
* 3 lilac-dmc.Berkeley.EDU (128.32.216.1) 19 ms 39 ms 19 ms
|
||||
* 4 ccngw-ner-cc.Berkeley.EDU (128.32.136.23) 39 ms 40 ms 19 ms
|
||||
* 5 ccn-nerif35.Berkeley.EDU (128.32.168.35) 39 ms 39 ms 39 ms
|
||||
* 6 csgw.Berkeley.EDU (128.32.133.254) 39 ms 59 ms 39 ms
|
||||
* 7 * * *
|
||||
* 8 * * *
|
||||
* 9 * * *
|
||||
* 10 * * *
|
||||
* 11 * * *
|
||||
* 12 * * *
|
||||
* 13 rip.Berkeley.EDU (128.32.131.22) 59 ms ! 39 ms ! 39 ms !
|
||||
*
|
||||
* Notice that there are 12 "gateways" (13 is the final
|
||||
* destination) and exactly the last half of them are "missing".
|
||||
* What's really happening is that rip (a Sun-3 running Sun OS3.5)
|
||||
* is using the ttl from our arriving datagram as the ttl in its
|
||||
* icmp reply. So, the reply will time out on the return path
|
||||
* (with no notice sent to anyone since icmp's aren't sent for
|
||||
* icmp's) until we probe with a ttl that's at least twice the path
|
||||
* length. I.e., rip is really only 7 hops away. A reply that
|
||||
* returns with a ttl of 1 is a clue this problem exists.
|
||||
* Traceroute prints a "!" after the time if the ttl is <= 1.
|
||||
* Since vendors ship a lot of obsolete (DEC's Ultrix, Sun 3.x) or
|
||||
* non-standard (HPUX) software, expect to see this problem
|
||||
* frequently and/or take care picking the target host of your
|
||||
* probes.
|
||||
*
|
||||
* Other possible annotations after the time are !H, !N, !P (got a host,
|
||||
* network or protocol unreachable, respectively), !S or !F (source
|
||||
* route failed or fragmentation needed -- neither of these should
|
||||
* ever occur and the associated gateway is busted if you see one). If
|
||||
* almost all the probes result in some kind of unreachable, traceroute
|
||||
* will give up and exit.
|
||||
*
|
||||
* Notes
|
||||
* -----
|
||||
* This program must be run by root or be setuid. (I suggest that
|
||||
* you *don't* make it setuid -- casual use could result in a lot
|
||||
* of unnecessary traffic on our poor, congested nets.)
|
||||
*
|
||||
* This program requires a kernel mod that does not appear in any
|
||||
* system available from Berkeley: A raw ip socket using proto
|
||||
* IPPROTO_RAW must interpret the data sent as an ip datagram (as
|
||||
* opposed to data to be wrapped in a ip datagram). See the README
|
||||
* file that came with the source to this program for a description
|
||||
* of the mods I made to /sys/netinet/raw_ip.c. Your mileage may
|
||||
* vary. But, again, ANY 4.x (x < 4) BSD KERNEL WILL HAVE TO BE
|
||||
* MODIFIED TO RUN THIS PROGRAM.
|
||||
*
|
||||
* The udp port usage may appear bizarre (well, ok, it is bizarre).
|
||||
* The problem is that an icmp message only contains 8 bytes of
|
||||
* data from the original datagram. 8 bytes is the size of a udp
|
||||
* header so, if we want to associate replies with the original
|
||||
* datagram, the necessary information must be encoded into the
|
||||
* udp header (the ip id could be used but there's no way to
|
||||
* interlock with the kernel's assignment of ip id's and, anyway,
|
||||
* it would have taken a lot more kernel hacking to allow this
|
||||
* code to set the ip id). So, to allow two or more users to
|
||||
* use traceroute simultaneously, we use this task's pid as the
|
||||
* source port (the high bit is set to move the port number out
|
||||
* of the "likely" range). To keep track of which probe is being
|
||||
* replied to (so times and/or hop counts don't get confused by a
|
||||
* reply that was delayed in transit), we increment the destination
|
||||
* port number before each probe.
|
||||
*
|
||||
* Don't use this as a coding example. I was trying to find a
|
||||
* routing problem and this code sort-of popped out after 48 hours
|
||||
* without sleep. I was amazed it ever compiled, much less ran.
|
||||
*
|
||||
* I stole the idea for this program from Steve Deering. Since
|
||||
* the first release, I've learned that had I attended the right
|
||||
* IETF working group meetings, I also could have stolen it from Guy
|
||||
* Almes or Matt Mathis. I don't know (or care) who came up with
|
||||
* the idea first. I envy the originators' perspicacity and I'm
|
||||
* glad they didn't keep the idea a secret.
|
||||
*
|
||||
* Tim Seaver, Ken Adelman and C. Philip Wood provided bug fixes and/or
|
||||
* enhancements to the original distribution.
|
||||
*
|
||||
* I've hacked up a round-trip-route version of this that works by
|
||||
* sending a loose-source-routed udp datagram through the destination
|
||||
* back to yourself. Unfortunately, SO many gateways botch source
|
||||
* routing, the thing is almost worthless. Maybe one day...
|
||||
*
|
||||
* -- Van Jacobson (van@helios.ee.lbl.gov)
|
||||
* Tue Dec 20 03:50:13 PST 1988
|
||||
*/
|
||||
|
||||
#define caddr_t void *
|
||||
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <winsock2.h>
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include <winsock.h>
|
||||
|
||||
//void print(buf, cc, from);
|
||||
char * inetname(struct in_addr);
|
||||
double deltaT(struct timeval *, struct timeval *);
|
||||
void usage();
|
||||
void send_probe(int, int);
|
||||
|
||||
#define bzero( ptr, count ) memset( ptr, 0, count )
|
||||
#define bcopy(src,dest,len) memcpy(dest,src,len)
|
||||
|
||||
// setlinebuf is equivalent to the setvbuf call below.
|
||||
inline int setlinebuf(FILE *stream)
|
||||
{
|
||||
return setvbuf( stream, (char*)0, _IONBF, 0 );
|
||||
}
|
||||
|
||||
#ifndef __GNUC__
|
||||
#define EPOCHFILETIME (116444736000000000i64)
|
||||
#else
|
||||
#define EPOCHFILETIME (116444736000000000LL)
|
||||
#endif
|
||||
|
||||
struct timezone {
|
||||
int tz_minuteswest; /* minutes W of Greenwich */
|
||||
int tz_dsttime; /* type of dst correction */
|
||||
};
|
||||
|
||||
int gettimeofday(struct timeval *tv, struct timezone *tz)
|
||||
{
|
||||
FILETIME ft;
|
||||
LARGE_INTEGER li;
|
||||
__int64 t;
|
||||
static int tzflag;
|
||||
|
||||
if (tv)
|
||||
{
|
||||
GetSystemTimeAsFileTime(&ft);
|
||||
//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 */
|
||||
tv->tv_sec = (long)(t / 1000000);
|
||||
tv->tv_usec = (long)(t % 1000000);
|
||||
}
|
||||
|
||||
if (tz)
|
||||
{
|
||||
if (!tzflag)
|
||||
{
|
||||
_tzset();
|
||||
tzflag++;
|
||||
}
|
||||
tz->tz_minuteswest = _timezone / 60;
|
||||
tz->tz_dsttime = _daylight;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Set up endiannes macros for the ip and ip_icmp BSD headers */
|
||||
#ifndef BIG_ENDIAN
|
||||
#define BIG_ENDIAN 4321
|
||||
#endif
|
||||
#ifndef LITTLE_ENDIAN
|
||||
#define LITTLE_ENDIAN 1234
|
||||
#endif
|
||||
#ifndef BYTE_ORDER
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
#define BYTE_ORDER BIG_ENDIAN
|
||||
#else
|
||||
#define BYTE_ORDER LITTLE_ENDIAN
|
||||
#endif
|
||||
#endif /* BYTE_ORDER */
|
||||
|
||||
#define u_int16_t WORD
|
||||
#define u_int32_t DWORD
|
||||
|
||||
/* These are BSD headers. We use these here because they are needed on
|
||||
* libc5 Linux systems. On other platforms they are usually simply more
|
||||
* complete than the native stuff, and cause less portability problems
|
||||
* so we use them anyway.
|
||||
*/
|
||||
#include "ip.h"
|
||||
#include "ip_icmp.h"
|
||||
|
||||
|
||||
#define MAXPACKET 65535 /* max ip packet size */
|
||||
#ifndef MAXHOSTNAMELEN
|
||||
#define MAXHOSTNAMELEN 64
|
||||
#endif
|
||||
|
||||
#ifndef FD_SET
|
||||
#define NFDBITS (8*sizeof(fd_set))
|
||||
#define FD_SETSIZE NFDBITS
|
||||
#define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS)))
|
||||
#define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS)))
|
||||
#define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS)))
|
||||
#define FD_ZERO(p) bzero((char *)(p), sizeof(*(p)))
|
||||
#endif
|
||||
|
||||
#define Fprintf (void)fprintf
|
||||
#define Sprintf (void)sprintf
|
||||
#define Printf (void)printf
|
||||
|
||||
/*
|
||||
* Define the UDP header
|
||||
*/
|
||||
typedef struct udphdr {
|
||||
u_short uh_dport;
|
||||
u_short uh_sport;
|
||||
u_short uh_sum;
|
||||
u_short uh_ulen;
|
||||
} udphdr;
|
||||
|
||||
/*
|
||||
* format of a (udp) probe packet.
|
||||
*/
|
||||
struct opacket {
|
||||
struct ip ip;
|
||||
udphdr udp;
|
||||
u_char seq; /* sequence number of this packet */
|
||||
u_char ttl; /* ttl packet left with */
|
||||
struct timeval tv; /* time packet left */
|
||||
};
|
||||
|
||||
u_char packet[512]; /* last inbound (icmp) packet */
|
||||
struct opacket *outpacket; /* last output (udp) packet */
|
||||
|
||||
#if 0
|
||||
int wait_for_reply __P((int, struct sockaddr_in *));
|
||||
void send_probe __P((int, int));
|
||||
double deltaT __P((struct timeval *, struct timeval *));
|
||||
int packet_ok __P((u_char *, int, struct sockaddr_in *, int));
|
||||
//void print __P((u_char *, int, struct sockaddr_in *));
|
||||
void tvsub __P((struct timeval *, struct timeval *));
|
||||
char *inetname __P((struct in_addr));
|
||||
void usage __P(());
|
||||
#endif
|
||||
|
||||
int s; /* receive (icmp) socket file descriptor */
|
||||
int sndsock; /* send (udp) socket file descriptor */
|
||||
struct timezone tz; /* leftover */
|
||||
|
||||
struct sockaddr whereto; /* Who to try to reach */
|
||||
int datalen; /* How much data */
|
||||
|
||||
char *source = 0;
|
||||
char *hostname;
|
||||
|
||||
int nprobes = 3;
|
||||
int max_ttl = 30;
|
||||
u_short ident;
|
||||
u_short port = 32768+666; /* start udp dest port # for probe packets */
|
||||
int options; /* socket options */
|
||||
int verbose;
|
||||
int waittime = 5; /* time to wait for response (in seconds) */
|
||||
int nflag; /* print addresses numerically */
|
||||
|
||||
void
|
||||
print(buf, cc, from)
|
||||
u_char *buf;
|
||||
int cc;
|
||||
struct sockaddr_in *from;
|
||||
{
|
||||
struct ip *ip;
|
||||
int hlen;
|
||||
|
||||
ip = (struct ip *) buf;
|
||||
hlen = ip->ip_hl << 2;
|
||||
cc -= hlen;
|
||||
|
||||
if (nflag)
|
||||
Printf(" %s", inet_ntoa(from->sin_addr));
|
||||
else
|
||||
Printf(" %s (%s)", inetname(from->sin_addr),
|
||||
inet_ntoa(from->sin_addr));
|
||||
|
||||
if (verbose)
|
||||
Printf (" %d bytes to %s", cc, inet_ntoa (ip->ip_dst));
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
{
|
||||
extern char *optarg;
|
||||
extern int optind;
|
||||
struct hostent *hp;
|
||||
struct protoent *pe;
|
||||
struct sockaddr_in from, *to;
|
||||
int ch, i, on, probe, seq, tos, ttl;
|
||||
WSADATA wsadata;
|
||||
INT status;
|
||||
|
||||
on = 1;
|
||||
seq = tos = 0;
|
||||
to = (struct sockaddr_in *)&whereto;
|
||||
while ((ch = getopt(argc, argv, "dm:np:q:rs:t:w:v")) != EOF)
|
||||
switch(ch) {
|
||||
case 'd':
|
||||
options |= SO_DEBUG;
|
||||
break;
|
||||
case 'm':
|
||||
max_ttl = atoi(optarg);
|
||||
if (max_ttl <= 1) {
|
||||
Fprintf(stderr,
|
||||
"traceroute: max ttl must be >1.\n");
|
||||
WSACleanup();
|
||||
exit(1);
|
||||
}
|
||||
break;
|
||||
case 'n':
|
||||
nflag++;
|
||||
break;
|
||||
case 'p':
|
||||
port = atoi(optarg);
|
||||
if (port < 1) {
|
||||
Fprintf(stderr,
|
||||
"traceroute: port must be >0.\n");
|
||||
WSACleanup();
|
||||
exit(1);
|
||||
}
|
||||
break;
|
||||
case 'q':
|
||||
nprobes = atoi(optarg);
|
||||
if (nprobes < 1) {
|
||||
Fprintf(stderr,
|
||||
"traceroute: nprobes must be >0.\n");
|
||||
WSACleanup();
|
||||
exit(1);
|
||||
}
|
||||
break;
|
||||
case 'r':
|
||||
options |= SO_DONTROUTE;
|
||||
break;
|
||||
case 's':
|
||||
/*
|
||||
* set the ip source address of the outbound
|
||||
* probe (e.g., on a multi-homed host).
|
||||
*/
|
||||
source = optarg;
|
||||
break;
|
||||
case 't':
|
||||
tos = atoi(optarg);
|
||||
if (tos < 0 || tos > 255) {
|
||||
Fprintf(stderr,
|
||||
"traceroute: tos must be 0 to 255.\n");
|
||||
WSACleanup();
|
||||
exit(1);
|
||||
}
|
||||
break;
|
||||
case 'v':
|
||||
verbose++;
|
||||
break;
|
||||
case 'w':
|
||||
waittime = atoi(optarg);
|
||||
if (waittime <= 1) {
|
||||
Fprintf(stderr,
|
||||
"traceroute: wait must be >1 sec.\n");
|
||||
WSACleanup();
|
||||
exit(1);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
usage();
|
||||
}
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
|
||||
if (argc < 1)
|
||||
usage();
|
||||
|
||||
status = WSAStartup(MAKEWORD(2, 2), &wsadata);
|
||||
if (status != 0) {
|
||||
printf("Could not initialize winsock dll.\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
setlinebuf (stdout);
|
||||
|
||||
(void) bzero((char *)&whereto, sizeof(struct sockaddr));
|
||||
to->sin_family = AF_INET;
|
||||
to->sin_addr.s_addr = inet_addr(*argv);
|
||||
if (to->sin_addr.s_addr != -1)
|
||||
hostname = *argv;
|
||||
else {
|
||||
hp = gethostbyname(*argv);
|
||||
if (hp) {
|
||||
to->sin_family = hp->h_addrtype;
|
||||
bcopy(hp->h_addr, (caddr_t)&to->sin_addr, hp->h_length);
|
||||
hostname = hp->h_name;
|
||||
} else {
|
||||
(void)fprintf(stderr,
|
||||
"traceroute: unknown host %s\n", *argv);
|
||||
WSACleanup();
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
if (*++argv)
|
||||
datalen = atoi(*argv);
|
||||
if (datalen < 0 || datalen >= MAXPACKET - sizeof(struct opacket)) {
|
||||
Fprintf(stderr,
|
||||
"traceroute: packet size must be 0 <= s < %ld.\n",
|
||||
MAXPACKET - sizeof(struct opacket));
|
||||
WSACleanup();
|
||||
exit(1);
|
||||
}
|
||||
datalen += sizeof(struct opacket);
|
||||
outpacket = (struct opacket *)malloc((unsigned)datalen);
|
||||
if (! outpacket) {
|
||||
perror("traceroute: malloc");
|
||||
WSACleanup();
|
||||
exit(1);
|
||||
}
|
||||
(void) bzero((char *)outpacket, datalen);
|
||||
outpacket->ip.ip_dst = to->sin_addr;
|
||||
outpacket->ip.ip_tos = tos;
|
||||
outpacket->ip.ip_v = IPVERSION;
|
||||
outpacket->ip.ip_id = 0;
|
||||
|
||||
ident = (getpid() & 0xffff) | 0x8000;
|
||||
|
||||
if ((pe = getprotobyname("icmp")) == NULL) {
|
||||
Fprintf(stderr, "icmp: unknown protocol\n");
|
||||
WSACleanup();
|
||||
exit(10);
|
||||
}
|
||||
if ((s = socket(AF_INET, SOCK_RAW, pe->p_proto)) < 0) {
|
||||
perror("traceroute: icmp socket");
|
||||
WSACleanup();
|
||||
exit(5);
|
||||
}
|
||||
if (options & SO_DEBUG)
|
||||
(void) setsockopt(s, SOL_SOCKET, SO_DEBUG,
|
||||
(char *)&on, sizeof(on));
|
||||
if (options & SO_DONTROUTE)
|
||||
(void) setsockopt(s, SOL_SOCKET, SO_DONTROUTE,
|
||||
(char *)&on, sizeof(on));
|
||||
|
||||
if ((sndsock = socket(AF_INET, SOCK_RAW, IPPROTO_RAW)) < 0) {
|
||||
perror("traceroute: raw socket");
|
||||
WSACleanup();
|
||||
exit(5);
|
||||
}
|
||||
#ifdef SO_SNDBUF
|
||||
if (setsockopt(sndsock, SOL_SOCKET, SO_SNDBUF, (char *)&datalen,
|
||||
sizeof(datalen)) < 0) {
|
||||
perror("traceroute: SO_SNDBUF");
|
||||
WSACleanup();
|
||||
exit(6);
|
||||
}
|
||||
#endif /* SO_SNDBUF */
|
||||
#ifdef IP_HDRINCL
|
||||
if (setsockopt(sndsock, IPPROTO_IP, IP_HDRINCL, (char *)&on,
|
||||
sizeof(on)) < 0) {
|
||||
perror("traceroute: IP_HDRINCL");
|
||||
WSACleanup();
|
||||
exit(6);
|
||||
}
|
||||
#endif /* IP_HDRINCL */
|
||||
if (options & SO_DEBUG)
|
||||
(void) setsockopt(sndsock, SOL_SOCKET, SO_DEBUG,
|
||||
(char *)&on, sizeof(on));
|
||||
if (options & SO_DONTROUTE)
|
||||
(void) setsockopt(sndsock, SOL_SOCKET, SO_DONTROUTE,
|
||||
(char *)&on, sizeof(on));
|
||||
|
||||
if (source) {
|
||||
(void) bzero((char *)&from, sizeof(struct sockaddr));
|
||||
from.sin_family = AF_INET;
|
||||
from.sin_addr.s_addr = inet_addr(source);
|
||||
if (from.sin_addr.s_addr == -1) {
|
||||
Printf("traceroute: unknown host %s\n", source);
|
||||
WSACleanup();
|
||||
exit(1);
|
||||
}
|
||||
outpacket->ip.ip_src = from.sin_addr;
|
||||
#ifndef IP_HDRINCL
|
||||
if (bind(sndsock, (struct sockaddr *)&from, sizeof(from)) < 0) {
|
||||
perror ("traceroute: bind:");
|
||||
WSACleanup();
|
||||
exit (1);
|
||||
}
|
||||
#endif /* IP_HDRINCL */
|
||||
}
|
||||
|
||||
Fprintf(stderr, "traceroute to %s (%s)", hostname,
|
||||
inet_ntoa(to->sin_addr));
|
||||
if (source)
|
||||
Fprintf(stderr, " from %s", source);
|
||||
Fprintf(stderr, ", %d hops max, %d byte packets\n", max_ttl, datalen);
|
||||
(void) fflush(stderr);
|
||||
|
||||
for (ttl = 1; ttl <= max_ttl; ++ttl) {
|
||||
u_long lastaddr = 0;
|
||||
int got_there = 0;
|
||||
int unreachable = 0;
|
||||
|
||||
Printf("%2d ", ttl);
|
||||
for (probe = 0; probe < nprobes; ++probe) {
|
||||
int cc;
|
||||
struct timeval t1, t2;
|
||||
struct timezone tz;
|
||||
struct ip *ip;
|
||||
|
||||
(void) gettimeofday(&t1, &tz);
|
||||
send_probe(++seq, ttl);
|
||||
while (cc = wait_for_reply(s, &from)) {
|
||||
(void) gettimeofday(&t2, &tz);
|
||||
if ((i = packet_ok(packet, cc, &from, seq))) {
|
||||
if (from.sin_addr.s_addr != lastaddr) {
|
||||
print(packet, cc, &from);
|
||||
lastaddr = from.sin_addr.s_addr;
|
||||
}
|
||||
Printf(" %g ms", deltaT(&t1, &t2));
|
||||
switch(i - 1) {
|
||||
case ICMP_UNREACH_PORT:
|
||||
#ifndef ARCHAIC
|
||||
ip = (struct ip *)packet;
|
||||
if (ip->ip_ttl <= 1)
|
||||
Printf(" !");
|
||||
#endif /* ARCHAIC */
|
||||
++got_there;
|
||||
break;
|
||||
case ICMP_UNREACH_NET:
|
||||
++unreachable;
|
||||
Printf(" !N");
|
||||
break;
|
||||
case ICMP_UNREACH_HOST:
|
||||
++unreachable;
|
||||
Printf(" !H");
|
||||
break;
|
||||
case ICMP_UNREACH_PROTOCOL:
|
||||
++got_there;
|
||||
Printf(" !P");
|
||||
break;
|
||||
case ICMP_UNREACH_NEEDFRAG:
|
||||
++unreachable;
|
||||
Printf(" !F");
|
||||
break;
|
||||
case ICMP_UNREACH_SRCFAIL:
|
||||
++unreachable;
|
||||
Printf(" !S");
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (cc == 0)
|
||||
Printf(" *");
|
||||
(void) fflush(stdout);
|
||||
}
|
||||
putchar('\n');
|
||||
if (got_there || unreachable >= nprobes-1) {
|
||||
WSACleanup();
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
WSACleanup();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
wait_for_reply(sock, from)
|
||||
int sock;
|
||||
struct sockaddr_in *from;
|
||||
{
|
||||
fd_set fds;
|
||||
struct timeval wait;
|
||||
int cc = 0;
|
||||
int fromlen = sizeof (*from);
|
||||
|
||||
FD_ZERO(&fds);
|
||||
FD_SET(sock, &fds);
|
||||
wait.tv_sec = waittime; wait.tv_usec = 0;
|
||||
|
||||
if (select(sock+1, &fds, (fd_set *)0, (fd_set *)0, &wait) > 0)
|
||||
cc=recvfrom(s, (char *)packet, sizeof(packet), 0,
|
||||
(struct sockaddr *)from, &fromlen);
|
||||
|
||||
return(cc);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
send_probe(seq, ttl)
|
||||
int seq, ttl;
|
||||
{
|
||||
struct opacket *op = outpacket;
|
||||
struct ip *ip = &op->ip;
|
||||
struct udphdr *up = &op->udp;
|
||||
int i;
|
||||
|
||||
ip->ip_off = 0;
|
||||
ip->ip_hl = sizeof(*ip) >> 2;
|
||||
ip->ip_p = IPPROTO_UDP;
|
||||
ip->ip_len = datalen;
|
||||
ip->ip_ttl = ttl;
|
||||
ip->ip_v = IPVERSION;
|
||||
ip->ip_id = htons(ident+seq);
|
||||
|
||||
up->uh_sport = htons(ident);
|
||||
up->uh_dport = htons(port+seq);
|
||||
up->uh_ulen = htons((u_short)(datalen - sizeof(struct ip)));
|
||||
up->uh_sum = 0;
|
||||
|
||||
op->seq = seq;
|
||||
op->ttl = ttl;
|
||||
(void) gettimeofday(&op->tv, &tz);
|
||||
|
||||
i = sendto(sndsock, (char *)outpacket, datalen, 0, &whereto,
|
||||
sizeof(struct sockaddr));
|
||||
if (i < 0 || i != datalen) {
|
||||
if (i<0)
|
||||
perror("sendto");
|
||||
Printf("traceroute: wrote %s %d chars, ret=%d\n", hostname,
|
||||
datalen, i);
|
||||
(void) fflush(stdout);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
double
|
||||
deltaT(t1p, t2p)
|
||||
struct timeval *t1p, *t2p;
|
||||
{
|
||||
register double dt;
|
||||
|
||||
dt = (double)(t2p->tv_sec - t1p->tv_sec) * 1000.0 +
|
||||
(double)(t2p->tv_usec - t1p->tv_usec) / 1000.0;
|
||||
return (dt);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Convert an ICMP "type" field to a printable string.
|
||||
*/
|
||||
char *
|
||||
pr_type(t)
|
||||
u_char t;
|
||||
{
|
||||
static char *ttab[] = {
|
||||
"Echo Reply", "ICMP 1", "ICMP 2", "Dest Unreachable",
|
||||
"Source Quench", "Redirect", "ICMP 6", "ICMP 7",
|
||||
"Echo", "ICMP 9", "ICMP 10", "Time Exceeded",
|
||||
"Param Problem", "Timestamp", "Timestamp Reply", "Info Request",
|
||||
"Info Reply"
|
||||
};
|
||||
|
||||
if(t > 16)
|
||||
return("OUT-OF-RANGE");
|
||||
|
||||
return(ttab[t]);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
packet_ok(buf, cc, from, seq)
|
||||
u_char *buf;
|
||||
int cc;
|
||||
struct sockaddr_in *from;
|
||||
int seq;
|
||||
{
|
||||
register struct icmp *icp;
|
||||
u_char type, code;
|
||||
int hlen;
|
||||
#ifndef ARCHAIC
|
||||
struct ip *ip;
|
||||
|
||||
ip = (struct ip *) buf;
|
||||
hlen = ip->ip_hl << 2;
|
||||
if (cc < hlen + ICMP_MINLEN) {
|
||||
if (verbose)
|
||||
Printf("packet too short (%d bytes) from %s\n", cc,
|
||||
inet_ntoa(from->sin_addr));
|
||||
return (0);
|
||||
}
|
||||
cc -= hlen;
|
||||
icp = (struct icmp *)(buf + hlen);
|
||||
#else
|
||||
icp = (struct icmp *)buf;
|
||||
#endif /* ARCHAIC */
|
||||
type = icp->icmp_type; code = icp->icmp_code;
|
||||
if ((type == ICMP_TIMXCEED && code == ICMP_TIMXCEED_INTRANS) ||
|
||||
type == ICMP_UNREACH) {
|
||||
struct ip *hip;
|
||||
struct udphdr *up;
|
||||
|
||||
hip = &icp->icmp_ip;
|
||||
hlen = hip->ip_hl << 2;
|
||||
up = (struct udphdr *)((u_char *)hip + hlen);
|
||||
if (hlen + 12 <= cc && hip->ip_p == IPPROTO_UDP &&
|
||||
up->uh_sport == htons(ident) &&
|
||||
up->uh_dport == htons(port+seq))
|
||||
if (hlen + 12 <= cc && hip->ip_p == IPPROTO_UDP)
|
||||
return (type == ICMP_TIMXCEED? -1 : code+1);
|
||||
}
|
||||
#ifndef ARCHAIC
|
||||
if (verbose) {
|
||||
int i;
|
||||
u_long *lp = (u_long *)&icp->icmp_ip;
|
||||
|
||||
Printf("\n%d bytes from %s to %s", cc,
|
||||
inet_ntoa(from->sin_addr), inet_ntoa(ip->ip_dst));
|
||||
Printf(": icmp type %d (%s) code %d\n", type, pr_type(type),
|
||||
icp->icmp_code);
|
||||
for (i = 4; i < cc ; i += sizeof(long))
|
||||
Printf("%2d: x%8.8lx\n", i, *lp++);
|
||||
}
|
||||
#endif /* ARCHAIC */
|
||||
return(0);
|
||||
}
|
||||
|
||||
#ifdef notyet
|
||||
/*
|
||||
* Checksum routine for Internet Protocol family headers (C Version)
|
||||
*/
|
||||
u_short
|
||||
in_cksum(addr, len)
|
||||
u_short *addr;
|
||||
int len;
|
||||
{
|
||||
register int nleft = len;
|
||||
register u_short *w = addr;
|
||||
register u_short answer;
|
||||
register int sum = 0;
|
||||
|
||||
/*
|
||||
* Our algorithm is simple, using a 32 bit accumulator (sum),
|
||||
* we add sequential 16 bit words to it, and at the end, fold
|
||||
* back all the carry bits from the top 16 bits into the lower
|
||||
* 16 bits.
|
||||
*/
|
||||
while (nleft > 1) {
|
||||
sum += *w++;
|
||||
nleft -= 2;
|
||||
}
|
||||
|
||||
/* mop up an odd byte, if necessary */
|
||||
if (nleft == 1)
|
||||
sum += *(u_char *)w;
|
||||
|
||||
/*
|
||||
* add back carry outs from top 16 bits to low 16 bits
|
||||
*/
|
||||
sum = (sum >> 16) + (sum & 0xffff); /* add hi 16 to low 16 */
|
||||
sum += (sum >> 16); /* add carry */
|
||||
answer = ~sum; /* truncate to 16 bits */
|
||||
return (answer);
|
||||
}
|
||||
#endif /* notyet */
|
||||
|
||||
/*
|
||||
* Subtract 2 timeval structs: out = out - in.
|
||||
* Out is assumed to be >= in.
|
||||
*/
|
||||
void
|
||||
tvsub(out, in)
|
||||
register struct timeval *out, *in;
|
||||
{
|
||||
if ((out->tv_usec -= in->tv_usec) < 0) {
|
||||
out->tv_sec--;
|
||||
out->tv_usec += 1000000;
|
||||
}
|
||||
out->tv_sec -= in->tv_sec;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Construct an Internet address representation.
|
||||
* If the nflag has been supplied, give
|
||||
* numeric value, otherwise try for symbolic name.
|
||||
*/
|
||||
char *
|
||||
inetname(in)
|
||||
struct in_addr in;
|
||||
{
|
||||
register char *cp;
|
||||
static char line[50];
|
||||
struct hostent *hp;
|
||||
static char domain[MAXHOSTNAMELEN + 1];
|
||||
static int first = 1;
|
||||
|
||||
if (first && !nflag) {
|
||||
first = 0;
|
||||
if (gethostname(domain, MAXHOSTNAMELEN) == 0 &&
|
||||
(cp = strrchr(domain, '.')))
|
||||
(void) strcpy(domain, cp + 1);
|
||||
else
|
||||
domain[0] = 0;
|
||||
}
|
||||
cp = 0;
|
||||
if (!nflag && in.s_addr != INADDR_ANY) {
|
||||
hp = gethostbyaddr((char *)&in, sizeof (in), AF_INET);
|
||||
if (hp) {
|
||||
if ((cp = strrchr(hp->h_name, '.')) &&
|
||||
!strcmp(cp + 1, domain))
|
||||
*cp = 0;
|
||||
cp = hp->h_name;
|
||||
}
|
||||
}
|
||||
if (cp)
|
||||
(void) strcpy(line, cp);
|
||||
else {
|
||||
in.s_addr = ntohl(in.s_addr);
|
||||
#define C(x) ((x) & 0xff)
|
||||
Sprintf(line, "%lu.%lu.%lu.%lu", C(in.s_addr >> 24),
|
||||
C(in.s_addr >> 16), C(in.s_addr >> 8), C(in.s_addr));
|
||||
}
|
||||
return (line);
|
||||
}
|
||||
|
||||
void
|
||||
usage()
|
||||
{
|
||||
(void)fprintf(stderr,
|
||||
"usage: traceroute [-dnrv] [-m max_ttl] [-p port#] [-q nqueries]\n\t\
|
||||
[-s src_addr] [-t tos] [-w wait] host [data size]\n");
|
||||
exit(1);
|
||||
}
|
6
reactos/apps/utils/net/tracert/tracert.rc
Normal file
6
reactos/apps/utils/net/tracert/tracert.rc
Normal file
@@ -0,0 +1,6 @@
|
||||
/* $Id: route.rc 11816 2004-11-26 06:51:47Z arty $ */
|
||||
|
||||
#define REACTOS_STR_FILE_DESCRIPTION "ReactOS TCP/IPv4 Traceroute\0"
|
||||
#define REACTOS_STR_INTERNAL_NAME "tracert\0"
|
||||
#define REACTOS_STR_ORIGINAL_FILENAME "tracert.exe\0"
|
||||
#include <reactos/version.rc>
|
@@ -1,17 +0,0 @@
|
||||
*.sys
|
||||
*.exe
|
||||
*.dll
|
||||
*.cpl
|
||||
*.a
|
||||
*.o
|
||||
*.d
|
||||
*.coff
|
||||
*.dsp
|
||||
*.dsw
|
||||
*.aps
|
||||
*.ncb
|
||||
*.opt
|
||||
*.sym
|
||||
*.plg
|
||||
*.bak
|
||||
*.map
|
@@ -1,4 +1,4 @@
|
||||
/* $Id: whois.rc,v 1.1 2004/11/21 22:27:01 chorns Exp $ */
|
||||
/* $Id$ */
|
||||
|
||||
#define REACTOS_STR_FILE_DESCRIPTION "ReactOS TCP/IPv4 Win32 Whois\0"
|
||||
#define REACTOS_STR_INTERNAL_NAME "whois\0"
|
||||
|
@@ -1,6 +0,0 @@
|
||||
*.o
|
||||
*.d
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
@@ -1,4 +1,4 @@
|
||||
# $Id: makefile,v 1.1 2004/01/11 17:06:21 ea Exp $
|
||||
# $Id$
|
||||
|
||||
PATH_TO_TOP = ../../..
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
/* $Id: nts2w32err.c,v 1.1 2004/01/11 17:06:21 ea Exp $
|
||||
/* $Id$
|
||||
*
|
||||
* Convert NTSTATUS codes to Win32 error codes: run it
|
||||
* on a NT box AND on a ROS box, then diff the results.
|
||||
|
@@ -1,6 +0,0 @@
|
||||
*.o
|
||||
*.d
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
@@ -1,4 +1,4 @@
|
||||
# $Id: makefile,v 1.11 2003/11/11 17:00:41 ekohl Exp $
|
||||
# $Id$
|
||||
|
||||
PATH_TO_TOP = ../../..
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
/* $Id: objdir.c,v 1.14 2004/08/05 12:11:49 ea Exp $
|
||||
/* $Id$
|
||||
*
|
||||
* DESCRIPTION: Object Manager Simple Explorer
|
||||
* PROGRAMMER: David Welch
|
||||
@@ -173,8 +173,8 @@ ListDirectory (
|
||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||
NTSTATUS Status;
|
||||
HANDLE DirectoryHandle;
|
||||
BYTE DirectoryEntry [MAX_DIR_ENTRY * sizeof(DIRECTORY_BASIC_INFORMATION)];
|
||||
PDIRECTORY_BASIC_INFORMATION pDirectoryEntry = (PDIRECTORY_BASIC_INFORMATION) DirectoryEntry;
|
||||
BYTE DirectoryEntry [MAX_DIR_ENTRY * sizeof(OBJECT_DIRECTORY_INFORMATION)];
|
||||
POBJECT_DIRECTORY_INFORMATION pDirectoryEntry = (POBJECT_DIRECTORY_INFORMATION) DirectoryEntry;
|
||||
ULONG Context = 0;
|
||||
ULONG ReturnLength = 0;
|
||||
ULONG EntryCount = 0;
|
||||
@@ -296,7 +296,7 @@ ListDirectory (
|
||||
*/
|
||||
if (FALSE != Recurse)
|
||||
{
|
||||
pDirectoryEntry = (PDIRECTORY_BASIC_INFORMATION) DirectoryEntry;
|
||||
pDirectoryEntry = (POBJECT_DIRECTORY_INFORMATION) DirectoryEntry;
|
||||
while (0 != pDirectoryEntry->ObjectTypeName.Length)
|
||||
{
|
||||
if (0 == wcscmp (L"Directory", pDirectoryEntry->ObjectTypeName.Buffer))
|
||||
|
@@ -1,6 +0,0 @@
|
||||
*.o
|
||||
*.d
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
@@ -1,4 +1,4 @@
|
||||
# $Id: makefile,v 1.5 2003/11/14 17:13:22 weiden Exp $
|
||||
# $Id$
|
||||
|
||||
PATH_TO_TOP = ../../..
|
||||
|
||||
|
@@ -1,6 +0,0 @@
|
||||
*.o
|
||||
*.d
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
@@ -1,4 +1,4 @@
|
||||
<!-- $Id: nv4_howto.html,v 1.2 2003/11/08 08:13:27 navaraf Exp $ -->
|
||||
<!-- $Id$ -->
|
||||
<HTML>
|
||||
<HEAD>
|
||||
<TITLE>Using NVidia drivers on ReactOS How-to</TITLE>
|
||||
|
@@ -1,4 +1,4 @@
|
||||
/* $Id: patchnv4.c,v 1.1 2003/11/07 20:10:13 gvg Exp $
|
||||
/* $Id$
|
||||
*
|
||||
* Patch the NVidia miniport driver to work with ReactOS
|
||||
*
|
||||
|
@@ -1,4 +0,0 @@
|
||||
*.o
|
||||
*.exe
|
||||
*.sym
|
||||
*.map
|
@@ -1,4 +1,4 @@
|
||||
# $Id: makefile,v 1.1 2004/02/11 21:04:18 hbirr Exp $
|
||||
# $Id$
|
||||
|
||||
PATH_TO_TOP = ../../..
|
||||
|
||||
|
@@ -1,6 +0,0 @@
|
||||
*.o
|
||||
*.d
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
@@ -1,6 +0,0 @@
|
||||
*.o
|
||||
*.d
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
@@ -1,4 +1,4 @@
|
||||
# $Id: makefile,v 1.3 2003/11/24 16:47:44 ekohl Exp $
|
||||
# $Id$
|
||||
|
||||
all:
|
||||
$(MAKE) -C loader
|
||||
|
@@ -1,6 +0,0 @@
|
||||
*.o
|
||||
*.d
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
@@ -1,4 +1,4 @@
|
||||
/* $Id: pice.rc,v 1.2 2004/10/16 20:27:20 gvg Exp $ */
|
||||
/* $Id$ */
|
||||
|
||||
#define REACTOS_VERSION_DLL
|
||||
#define REACTOS_STR_FILE_DESCRIPTION "PICE Debugger\0"
|
||||
|
@@ -1,6 +0,0 @@
|
||||
*.o
|
||||
*.d
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
@@ -1,4 +1,4 @@
|
||||
# $Id: makefile,v 1.2 2003/11/11 17:01:47 ekohl Exp $
|
||||
# $Id$
|
||||
|
||||
PATH_TO_TOP = ../../..
|
||||
|
||||
|
@@ -1,6 +0,0 @@
|
||||
*.o
|
||||
*.d
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
@@ -1,4 +1,4 @@
|
||||
/* $Id: ps.c,v 1.3 2004/07/29 22:31:55 jimtabor Exp $
|
||||
/* $Id$
|
||||
*
|
||||
* ReactOS ps - process list console viewer
|
||||
*
|
||||
|
@@ -1,4 +1,4 @@
|
||||
/* $Id: ps.c.toolhelp,v 1.1 2004/07/29 22:31:56 jimtabor Exp $
|
||||
/* $Id$
|
||||
*
|
||||
* ReactOS ps - process list console viewer
|
||||
*
|
||||
|
@@ -1,6 +0,0 @@
|
||||
*.o
|
||||
*.d
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
@@ -1,4 +1,4 @@
|
||||
# $Id: Makefile,v 1.2 2003/11/07 23:16:22 gvg Exp $
|
||||
# $Id$
|
||||
|
||||
PATH_TO_TOP = ../../..
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
/* $Id: rundll32.rc,v 1.2 2004/10/16 20:27:21 gvg Exp $ */
|
||||
/* $Id$ */
|
||||
|
||||
#define REACTOS_STR_FILE_DESCRIPTION "Run a DLL as an App\0"
|
||||
#define REACTOS_STR_INTERNAL_NAME "rundll32\0"
|
||||
|
@@ -1,8 +0,0 @@
|
||||
*.o
|
||||
*.d
|
||||
sc.exe
|
||||
sc.nostrip.exe
|
||||
sc.coff
|
||||
sc.sym
|
||||
sc.map
|
||||
*.map
|
@@ -1,4 +0,0 @@
|
||||
*.ncb
|
||||
*.plg
|
||||
Debug
|
||||
*.opt
|
@@ -1,4 +1,4 @@
|
||||
/* $Id: test.h,v 1.4 2003/11/18 05:20:00 royce Exp $
|
||||
/* $Id$
|
||||
*/
|
||||
/*
|
||||
* test.h
|
||||
|
@@ -1,6 +0,0 @@
|
||||
*.o
|
||||
*.d
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
@@ -1,4 +1,4 @@
|
||||
# $Id: Makefile,v 1.3 2004/12/13 18:06:38 weiden Exp $
|
||||
# $Id$
|
||||
|
||||
PATH_TO_TOP = ../../..
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
/* $Id: shutdown.c,v 1.2 2004/09/16 12:46:43 gvg Exp $
|
||||
/* $Id$
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS shutdown/logoff utility
|
||||
|
@@ -1,6 +0,0 @@
|
||||
*.o
|
||||
*.d
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
@@ -1,4 +1,4 @@
|
||||
# $Id: Makefile,v 1.4 2003/11/16 22:25:34 sedwards Exp $
|
||||
# $Id$
|
||||
|
||||
PATH_TO_TOP = ../../..
|
||||
|
||||
|
@@ -1,6 +0,0 @@
|
||||
*.~*
|
||||
*.obj
|
||||
*.tds
|
||||
*.exe
|
||||
*.i
|
||||
*.res
|
@@ -1,4 +1,4 @@
|
||||
# $Id: Makefile,v 1.2 2003/10/27 23:20:57 hyperion Exp $
|
||||
# $Id$
|
||||
|
||||
PATH_TO_TOP = ../../../..
|
||||
|
||||
|
@@ -1,6 +0,0 @@
|
||||
*.o
|
||||
*.d
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
@@ -12,7 +12,7 @@ TARGET_SDKLIBS = kernel32.a
|
||||
|
||||
TARGET_OBJECTS = tickcount.o
|
||||
|
||||
TARGET_CFLAGS = -Wall -Werror
|
||||
TARGET_CFLAGS = -Wall -Werror -D__USE_W32API
|
||||
|
||||
include $(PATH_TO_TOP)/rules.mak
|
||||
|
||||
|
@@ -1,30 +1,32 @@
|
||||
/* $Id: tickcount.c,v 1.2 2003/07/06 23:04:18 hyperion Exp $
|
||||
/* $Id$
|
||||
*/
|
||||
/*
|
||||
tickcount -- Display the kernel tick count in human-readable format
|
||||
tickcount -- Display the kernel tick count (or any tick count passed as an
|
||||
argument or as input) in human-readable format
|
||||
|
||||
This is public domain software
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <tchar.h>
|
||||
#include <windows.h>
|
||||
|
||||
typedef __int64 int64_t;
|
||||
typedef unsigned __int64 uint64_t;
|
||||
typedef __int64 int64_;
|
||||
typedef unsigned __int64 uint64_;
|
||||
|
||||
#define TICKS_YEAR (TICKS_DAY * ((uint64_t)365))
|
||||
#define TICKS_MONTH (TICKS_DAY * ((uint64_t)30))
|
||||
#define TICKS_WEEK (TICKS_DAY * ((uint64_t)7))
|
||||
#define TICKS_DAY (TICKS_HOUR * ((uint64_t)24))
|
||||
#define TICKS_HOUR (TICKS_MINUTE * ((uint64_t)60))
|
||||
#define TICKS_MINUTE (TICKS_SECOND * ((uint64_t)60))
|
||||
#define TICKS_SECOND ((uint64_t)1000)
|
||||
#define TICKS_YEAR (TICKS_DAY * ((uint64_)365))
|
||||
#define TICKS_MONTH (TICKS_DAY * ((uint64_)30))
|
||||
#define TICKS_WEEK (TICKS_DAY * ((uint64_)7))
|
||||
#define TICKS_DAY (TICKS_HOUR * ((uint64_)24))
|
||||
#define TICKS_HOUR (TICKS_MINUTE * ((uint64_)60))
|
||||
#define TICKS_MINUTE (TICKS_SECOND * ((uint64_)60))
|
||||
#define TICKS_SECOND ((uint64_)1000)
|
||||
|
||||
#define SLICES_COUNT (sizeof(ticks_per_slice) / sizeof(ticks_per_slice[0]))
|
||||
|
||||
uint64_t ticks_per_slice[] =
|
||||
uint64_ ticks_per_slice[] =
|
||||
{
|
||||
TICKS_YEAR,
|
||||
TICKS_MONTH,
|
||||
@@ -36,7 +38,7 @@ uint64_t ticks_per_slice[] =
|
||||
1
|
||||
};
|
||||
|
||||
_TCHAR * slice_names_singular[] =
|
||||
_TCHAR * slice_names_singular[SLICES_COUNT] =
|
||||
{
|
||||
_T("year"),
|
||||
_T("month"),
|
||||
@@ -48,7 +50,7 @@ _TCHAR * slice_names_singular[] =
|
||||
_T("millisecond")
|
||||
};
|
||||
|
||||
_TCHAR * slice_names_plural[] =
|
||||
_TCHAR * slice_names_plural[SLICES_COUNT] =
|
||||
{
|
||||
_T("years"),
|
||||
_T("months"),
|
||||
@@ -62,16 +64,16 @@ _TCHAR * slice_names_plural[] =
|
||||
|
||||
void print_uptime
|
||||
(
|
||||
uint64_t tickcount,
|
||||
uint64_t prevsliceval,
|
||||
uint64_ tickcount,
|
||||
uint64_ prevsliceval,
|
||||
_TCHAR * prevsliceunit,
|
||||
int curslice
|
||||
)
|
||||
{
|
||||
uint64_t tick_cur = tickcount / ticks_per_slice[curslice];
|
||||
uint64_t tick_residual = tickcount % ticks_per_slice[curslice];
|
||||
uint64_ tick_cur = tickcount / ticks_per_slice[curslice];
|
||||
uint64_ tick_residual = tickcount % ticks_per_slice[curslice];
|
||||
|
||||
assert(tick_cur <= (~((uint64_t)0)));
|
||||
assert(tick_cur <= (~((uint64_)0)));
|
||||
|
||||
if(tick_residual == 0)
|
||||
{
|
||||
@@ -134,9 +136,56 @@ void print_uptime
|
||||
}
|
||||
}
|
||||
|
||||
int _tmain()
|
||||
int parse_print(const _TCHAR * str)
|
||||
{
|
||||
print_uptime((uint64_t)GetTickCount(), 0, NULL, 0);
|
||||
int64_ tickcount;
|
||||
|
||||
tickcount = _ttoi64(str);
|
||||
|
||||
if(tickcount < 0)
|
||||
tickcount = - tickcount;
|
||||
else if(tickcount == 0)
|
||||
return 1;
|
||||
|
||||
print_uptime(tickcount, 0, NULL, 0);
|
||||
_puttc(_T('\n'), stdout);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _tmain(int argc, _TCHAR * argv[])
|
||||
{
|
||||
int r;
|
||||
|
||||
if(argc <= 1)
|
||||
{
|
||||
print_uptime((uint64_)GetTickCount(), 0, NULL, 0);
|
||||
_puttc(_T('\n'), stdout);
|
||||
}
|
||||
else if(argc == 2 && argv[1][0] == _T('-') && argv[1][1] == 0)
|
||||
{
|
||||
while(!feof(stdin))
|
||||
{
|
||||
_TCHAR buf[23];
|
||||
_TCHAR * str;
|
||||
|
||||
str = _fgetts(buf, 22, stdin);
|
||||
|
||||
if(str == NULL)
|
||||
return 0;
|
||||
|
||||
if((r = parse_print(str)) != 0)
|
||||
return r;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int i;
|
||||
|
||||
for(i = 1; i < argc; ++ i)
|
||||
if((r = parse_print(argv[i])) != 0)
|
||||
return r;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user