* pc: Remove. No work has been done on the PC post for years.

* README.PC: Likewise.
* Makefile.am: Adjust for the above.
* configure.in: Likewise.
This commit is contained in:
Pavel Roskin 2003-07-23 03:02:18 +00:00
parent 17a04526cf
commit fe7d3b9a4e
31 changed files with 9 additions and 3784 deletions

View File

@ -1,3 +1,10 @@
2003-07-22 Pavel Roskin <proski@gnu.org>
* pc: Remove. No work has been done on the PC post for years.
* README.PC: Likewise.
* Makefile.am: Adjust for the above.
* configure.in: Likewise.
2003-07-21 Pavel Roskin <proski@gnu.org>
* configure.in: Check posix_openpt() first and fallback to

View File

@ -2,10 +2,9 @@
AUTOMAKE_OPTIONS = 1.5
SUBDIRS = intl po m4 vfs slang edit src lib doc syntax pc
SUBDIRS = intl po m4 vfs slang edit src lib doc syntax
EXTRA_DIST = FAQ INSTALL.FAST MAINTAINERS \
README.PC README.QNX extraconf.h
EXTRA_DIST = FAQ INSTALL.FAST MAINTAINERS README.QNX extraconf.h
noinst_DATA = mc.spec

120
README.PC
View File

@ -1,120 +0,0 @@
------------------------------------------------------------------------
Support for Windows is broken since GNU Midnight Commander started using
glib. If you want to revive the project, it may be your last chance.
If nobody volunteers, all the code for the native Windows port will be
removed from the project.
------------------------------------------------------------------------
GNU Midnight Commander for Win32
--------------------------------
0. Introduction
1. Compiling
2. Changes made
3. Authors and maintainers
0. Introduction
---------------
Yes, Midnight Commander can be compiled for Win32 (all versions of
Microsoft Windows starting with Windows 95 for all platforms, except
Windows CE). It may be tricky to compile, it may be buggy, but it should
be usable. Maybe you can help as a beta tester or as a programmer.
In either case you would like subscribe to the mc-devel list (see README
and FAQ) and contact us.
Please note that Midnight Commander remains primarily a file manager for
UNIX-like systems. You should not expect that it will work on your
system better than a file manager written specifically for your OS.
1. Compiling
------------
1.1. Compiler
-------------
If you really want to enjoy free software under your non-free OS,
you should try free compilers. Two of them are supported: RSXNT and
MinGW. Please visit their respective sites for more information.
RSXNT: http://www.mathematik.uni-bielefeld.de/~rainer/
MinGW: http://www.mingw.org/
MinGW is also included with Cygwin (http://www.cygwin.com/).
Cygwin environment is so close to UNIX, that it's possible to compile
GNU Midnight Commander in the same way as it's done in UNIX (see file
INSTALL for details). However, you should realize that you would get a
UNIX program that has no idea about drives, Windows-style permissions
and some other Windows-specific features. This is not the Win32 port
discussed in this document.
Speaking of non-free compilers, Microsoft Visual C++ (4.0 and above) and
Borland C++ are supported. "Supported" means merely that there are
specific makefiles for those compilers, but it does not even assume that
they will compile GNU Midnight Commander out-of-box.
1.2. General issues
-------------------
See pc/README, pc/BUGS, pc/TODO for the information concerning current
state of the port. You will need to hack the code a lot just to
compile it.
1.3 Windowing Library
---------------------
Currently only support for the S-Lang windowing library is provided.
There are curses clones ported to Win32, but I believe that since we
are not using autoconf for the Win32 port, we should avoid unnecessary
difficulties.
Currently the Win32 port only can use S-Lang included in this
distribution (see slang/ subdirectory). This is a subset of S-Lang
distribution with some bugfixes and MC-specific code changes.
1.4 Features and Limitations
----------------------------
Internal editor is supported (including syntax highlighting).
Internal viewer is supported (including hex editor).
VFS (virtual file system) is not supported.
Concurrent subshell is not supported.
2. Changes made
---------------
2.1. Changes to main code
-------------------------
Changes in the main code are enclosed in #ifdef NATIVE_WIN32 blocks.
In some cases we suppressed code. This is temporal (so that mc can compile).
In the future we will provide fake or true interfaces for these features.
- Links: creation and information on links are not supported. We
should provide a fake interface for the local filesystem and
a true one for networked.
- GID/UID queries (get_user, owner, preserve UID/GID on copy, ...).
- Terminals: all the code directly done with terminals must be suppressed.
- Signals: deleted. Should support the native ones.
- pipes: had some trouble in ext.c and with error_pipes but soon will be
fixed.
- Chown command: Not supported yet.
2.2. Files rewritten
--------------------
There are several files with so many changes that they have been moved
to pc/ subdirectory. Our intention should be, however, to make most code
system-independent. This would increase code reuse and maintainability.
See pc/ subdirectory for further details.
3. Authors and maintainers
--------------------------
The code is not actively maintained, but the patches are applied.
Please send your changes to the mc-devel list.

View File

@ -636,7 +636,6 @@ src/Makefile
slang/Makefile
edit/Makefile
syntax/Makefile
pc/Makefile
m4/Makefile
lib/mc.ext

View File

@ -1,2 +0,0 @@
Makefile
Makefile.in

11
pc/BUGS
View File

@ -1,11 +0,0 @@
BUGS OF the Win32 port
- Troubles with keys (Ctrl-Tab, Gray +,-,*, Alt-Shift-A etc)
- Filtered view hangs in close_pipe() because error is set, but nothing
is available on stderr
- Windows '95 will not delete directory if not empty. (as it does
not return ENOTEMPTY but ENOACCESS)! Already fixed?
- Windows '95 will not allow "''" in root drives
-please report!

View File

@ -1,183 +0,0 @@
2002-11-11 Pavel Roskin <proski@gnu.org>
* key_nt.c: Remove C++ style comments.
2002-11-06 Pavel Roskin <proski@gnu.org>
* key_nt.c: Don't use ERR - it conflicts with sys/ucontext.h
in glibc 2.1.3.
2002-09-02 Pavel Roskin <proski@gnu.org>
* chmod.c: Eliminate x_set_dialog_title().
* drive.c: Likewise.
2002-08-01 Pavel Roskin <proski@gnu.org>
* chmod.c: Don't include mad.h.
* drive.c: Likewise.
* slint_pc.c: Likewise.
2002-07-15 Pavel Roskin <proski@gnu.org>
* chmod.c: Remove all translatable strings - gettext doesn't
work in the PC port, no need to waste translators' time.
2002-07-01 Andrew V. Samoilov <kai@cmail.ru>
* util_nt.c: Eliminate C++ comments everywhere.
(check_error_pipe): Use "%s" in message () to
prevent possible crash.
(close_error_pipe): Likewise.
2002-06-04 Andrew V. Samoilov <kai@cmail.ru>
* key_nt.c (define_sequence): Adjust for declaration.
* util_nt.c (close_error_pipe): Likewise.
(tilde_expand): Likewise.
2002-03-18 Pavel Roskin <proski@gnu.org>
* Makefile.am: Remove regex.h and regex.c.
* regex.h: Remove. We now have complete regex in src.
* regex.c: Likewise.
2002-01-21 Pavel Roskin <proski@gnu.org>
* Makefile.PC: Remove OS/2-specific parts. Substitute
TARGET_OS - it is always NT now.
* config.h: Remove definitions for UNIX-specific permission
bits - they are now in fs.h.
* dirent_nt.c: Trim includes, disable code under MSVC.
* chmod.c: Include ../src/global.h, remove unneeded includes.
* cons_nt.c: Likewise.
* drive.c: Likewise.
* key_nt.c: Likewise.
* slint_pc.c: Likewise.
* util_nt.c: Likewise.
2002-01-17 Pavel Roskin <proski@gnu.org>
* config.h: Remove all HAS_NO_* definitions, they are unused.
* chmod.c: Remove OS/2 specific code.
* config.h: Likewise.
2002-01-03 Pavel Roskin <proski@gnu.org>
* BUGS: Remove obsolete and OS/2 specific parts.
* README: Likewise.
* TODO: Likewise.
* Makefile.am: Remove all files used by OS/2 only. The OS/2
port is discontinued because there is no support for native OS/2
compilers in glib. Remove sys/time.h and dirent.h - they should
not be needed anymore.
2002-01-02 Pavel Roskin <proski@gnu.org>
* config.h: Include VERSION, not ..\VERSION. Use sys/utime.h
instead of utime.h for MSVC and MinGW. Don't use dirent on
Win32 - it's replaced by glib.
2001-11-28 Franco Bez <franco.bez@web.de>
* chmod.c: Fix includes for cross-compiler. Add gettext N_()
and _() calls.
2001-11-28 Pavel Roskin <proski@gnu.org>
* regex.c: Add temporarily to fix the build.
* regex.h: Likewise.
* Makefile.am: Add regex.c and regex.h.
From Franco Bez <franco.bez@web.de>
2001-11-14 Pavel Roskin <proski@gnu.org>
* chmod.c: Remove all occurrences of HAVE_X.
* drive.c: Likewise.
2001-10-23 Pavel Roskin <proski@gnu.org>
* util_nt.c (_win32Trace): Add missing va_end().
2001-07-13 Pavel Roskin <proski@gnu.org>
* util_nt.c (canonicalize_pathname): Don't handle PATH_SEP
after backslash in a special way.
* util_os2.c (canonicalize_pathname): Likewise (was already
commented out).
2001-06-26 Pavel Roskin <proski@gnu.org>
* dirent_nt.c: Include <config.h>.
2001-06-14 Pavel Roskin <proski@gnu.org>
* Makefile.am: Remove src/param.h.
* src/param.h: Remove. Should use HAVE_SYS_PARAM_H everywhere
instead.
* key_nt.c: Use indented #error.
* key_os2.c: Use indented #error.
2001-06-11 Pavel Roskin <proski@gnu.org>
* Makefile.MIN: Add "-mno-cygwin" to MC_MISC_CFLAGS.
* Makefile.PC: Use VERSION, not ../VERSION. Add a rule to
extract package version from ../configure.in.
* mc.rc: Include VERSION, not ../VERSION.
2000-08-01 Pavel Roskin <proski@gnu.org>
* README: Updated e-mail
1999-09-01 Federico Mena Quintero <federico@redhat.com>
* Makefile.PC: Add missing semicolon.
1999-01-08 Miguel de Icaza <miguel@nuclecu.unam.mx>
* chmod.c (chmod_cmd): Killed the tk_end_frame and tk_new_frame
macros.
Wed Oct 14 14:51:23 1998 Franco Bez <franco.bez@augsburg.baynet.de>
* gtkedit/edit.c: Workaround for the CR/LF Translation problem.
This is vital, because otherwise CoolEdit corrupts files -
they keep growing each time you save the file.
* pc/key_nt.c: fixed the problem with the AltGr Key and the
Gray Keys. Still not optimal, but usable.
Especially useful for international keyboard
* pc/util_nt.c: Provide a mc_doublepopen and mc_doublepclose
function. If one has an egrep.exe installed it's now possible
to search for files containing a search pattern.
Tue May 12 17:16:43 1998 Pavel Roskin <pavel_roskin@geocities.com>
* Makefile.RSX, mc.rc: Resources support for RSX
* Makefile.PC, *.c: Some includes corrected for MinGW
compatibility (dir.h exists both in mc and MinGW)
Fri May 8 10:49:21 1998 Pavel Roskin <pavel_roskin@geocities.com>
* Makefile.PC, Makefile.MIN: support for custom extension
for compiled resources
* key_nt.c: Minor changes for MinGW
* mc.rc: WindRes support
* slint_pc.c: support for syntax highlighting
Fri May 1 17:33:11 1998 Pavel Roskin <pavel_roskin@geocities.com>
* chmod.c: Updated call to update_panels()
* config.h, Makefile.MIN: Support for MinGW added

View File

@ -1,56 +0,0 @@
# Makefile.BC5
#
# Midnight Commander for Win32 makefile
# for Borland C++ 5.01
#
# Hacked by Dan Nicolaescu from Visual IDE mak
# Hacked by Pavel Roskin to make it work with cmd.exe from Windows NT4
# 980206 hacked by Pavel Roskin to make it work with GNU make
# 980316 hacked by Pavel Roskin to make it work with Borland C++
# --------------------------------------------------------------------------
TARGET_OS=NT
CC=bcc32.exe
LINK=bcc32.exe
OBJ_SUFFIX=obj
OBJ_PLACE=-o
EXE_PLACE=-e
# Just comment RSC out if you have problems with resources
# RSC=rc.exe
# RES_PLACE=-fo
# ---- Compiler-specific optional stuff
MC_MISC_CFLAGS=-I../edit -I../src
ifndef RELEASE
# ---- Debug build
OBJS_DIR=debug
EXTRA_MC_SRCS=trace_nt.c
SPECIFIC_DEFINES=-DHAVE_TRACE
SPECIFIC_MC_CFLAGS=-v -y $(MC_MISC_CFLAGS)
SPECIFIC_MC_LFLAGS_EXTRA=-lv
SPECIFIC_SLANG_CFLAGS=$(SPECIFIC_MC_CFLAGS)
SPECIFIC_MCEDIT_CFLAGS=$(SPECIFIC_MC_CFLAGS)
RC_DEFINES=-D_DEBUG
else
# ---- Release build
OBJS_DIR=release
EXTRA_MC_SRCS=
SPECIFIC_DEFINES=
SPECIFIC_MC_CFLAGS=$(MC_MISC_CFLAGS)
SPECIFIC_MC_LFLAGS_EXTRA=
SPECIFIC_SLANG_CFLAGS=$(SPECIFIC_MC_CFLAGS)
SPECIFIC_MCEDIT_CFLAGS=$(SPECIFIC_MC_CFLAGS)
RC_DEFINES=-DRELEASE=$(RELEASE)
endif
# ---- Compiler independent defines
include Makefile.PC
# ---- Linkers are usualy compiler-specific
SPECIFIC_MC_LFLAGS=$(SPECIFIC_MC_LFLAGS_EXTRA)
MC_LIBS=
$(MC_EXE): $(MC_RES) $(OBJS) $(MCEDIT_OBJS) $(SLANG_OBJS)
$(LINK) $(EXE_PLACE)$(MC_EXE) $(SPECIFIC_MC_LFLAGS) $+ $(MC_LIBS)

View File

@ -1,57 +0,0 @@
# Makefile.MIN
#
# Midnight Commander for NT makefile
# for MinGW
#
# Hacked by Dan Nicolaescu from Visual IDE mak
# Hacked by Pavel Roskin to make it work with cmd.exe from Windows NT4
# 980206 hacked by Pavel Roskin to make it work with GNU make
# --------------------------------------------------------------------------
TARGET_OS=NT
CC=gcc.exe
LINK=gcc.exe
OBJ_SUFFIX=o
OBJ_PLACE=-o
EXE_PLACE=-o
# Just comment RSC out if you have problems with resources
RSC=windres.exe
RES_PLACE=-o
RES_SUFFIX=o
# ---- Compiler-specific optional stuff
MC_MISC_CFLAGS=-mno-cygwin
ifndef RELEASE
# ---- Debug build
OBJS_DIR=debug
EXTRA_MC_SRCS=
SPECIFIC_DEFINES=
SPECIFIC_MC_CFLAGS=-g -O0 $(MC_MISC_CFLAGS)
SPECIFIC_MC_LFLAGS_EXTRA=
SPECIFIC_SLANG_CFLAGS=$(SPECIFIC_MC_CFLAGS)
SPECIFIC_MCEDIT_CFLAGS=$(SPECIFIC_MC_CFLAGS)
RC_DEFINES=--define WINDRES --define _DEBUG
else
# ---- Release build
OBJS_DIR=release
EXTRA_MC_SRCS=
SPECIFIC_DEFINES=
SPECIFIC_MC_CFLAGS=-O2 $(MC_MISC_CFLAGS)
SPECIFIC_MC_LFLAGS_EXTRA=
SPECIFIC_SLANG_CFLAGS=$(SPECIFIC_MC_CFLAGS)
SPECIFIC_MCEDIT_CFLAGS=$(SPECIFIC_MC_CFLAGS)
RC_DEFINES=--define WINDRES --define RELEASE=$(RELEASE)
endif
# ---- Compiler independent defines
include Makefile.PC
# ---- Linkers are very compiler-specific
SPECIFIC_MC_LFLAGS=$(SPECIFIC_MC_LFLAGS_EXTRA)
MC_LIBS=
$(MC_EXE): $(MC_RES) $(OBJS) $(MCEDIT_OBJS) $(SLANG_OBJS)
$(LINK) $(EXE_PLACE) $(MC_EXE) $(MC_LIBS) $(SPECIFIC_MC_LFLAGS) $+

View File

@ -1,171 +0,0 @@
# Makefile.PC
#
# This is the Makefile for Midnight Commander under Win32
#
# Written by Dan Nicolaescu
# 970423 hacked by Juan f. Grigera
# 970525 hacked again by jfg to add internal editor
# 971127 hacked by Pavel Roskin to make it work with mc-4.1.11
# 980206 hacked by Pavel Roskin to make it work with GNU make
# 980329 changed by Pavel Roskin to make it common for OS/2 and NT
#
# Supported Compilers:
#
# Makefile.VC4: Microsoft Visual C++ 4.0 and above
# Makefile.BC5: Borland C++ 5.x
# Makefile.MIN: MinGW
# Makefile.RSX: RSX
# ---- Directories
MC_PC_DIR=.
MC_SRC_DIR=../src
VFS_DIR=../vfs
MCEDIT_SRC_DIR=../edit
MCGTKEDIT_SRC_DIR=../edit
MCEDIT_OBJS_DIR=$(OBJS_DIR)/edit
SLANG_SRC_DIR=../slang
SLANG_OBJS_DIR=$(OBJS_DIR)/slang
MC_EXE=$(OBJS_DIR)/mc.exe
# --- Midnight Defines
COMMON_DEFINES=-DMC_NT $(SPECIFIC_DEFINES)
MC_DEFINES=$(COMMON_DEFINES) -DHAVE_CONFIG_H
MC_INCLUDES=-I$(MC_PC_DIR) -I$(SLANG_SRC_DIR)
SLANG_DEFINES=$(COMMON_DEFINES)
SLANG_INCLUDES=-I$(MC_PC_DIR) -I$(SLANG_SRC_DIR)
MCEDIT_DEFINES=$(COMMON_DEFINES) -DHAVE_CONFIG_H
MCEDIT_INCLUDES=-I$(MC_PC_DIR) -I$(SLANG_SRC_DIR)
CFLAGS=$(SPECIFIC_MC_CFLAGS) $(MC_INCLUDES) $(MC_DEFINES) -c
SLANG_CFLAGS=$(SPECIFIC_SLANG_CFLAGS) $(SLANG_INCLUDES) $(SLANG_DEFINES) -c
MCEDIT_CFLAGS=$(SPECIFIC_MCEDIT_CFLAGS) $(MCEDIT_INCLUDES) $(MCEDIT_DEFINES) -c
all: object-dirs mc
object-dirs: $(OBJS_DIR) $(SLANG_OBJS_DIR) $(MCEDIT_OBJS_DIR)
mc: $(MC_EXE)
clean:
deltree -y "$(SLANG_OBJS_DIR)"
deltree -y "$(MCEDIT_OBJS_DIR)"
deltree -y "$(OBJS_DIR)"
$(OBJS_DIR):
mkdir "$@"
$(SLANG_OBJS_DIR):
mkdir "$@"
$(MCEDIT_OBJS_DIR):
mkdir "$@"
$(OBJS_DIR)/%.$(OBJ_SUFFIX): $(MC_PC_DIR)/%.c
$(CC) $(CFLAGS) $(OBJ_PLACE)$@ $<
$(OBJS_DIR)/%.$(OBJ_SUFFIX): $(MC_SRC_DIR)/%.c
$(CC) $(CFLAGS) $(OBJ_PLACE)$@ $<
$(SLANG_OBJS_DIR)/%.$(OBJ_SUFFIX): $(SLANG_SRC_DIR)/%.c
$(CC) $(SLANG_CFLAGS) $(OBJ_PLACE)$@ $<
$(MCEDIT_OBJS_DIR)/%.$(OBJ_SUFFIX): $(MCEDIT_SRC_DIR)/%.c
$(CC) $(MCEDIT_CFLAGS) $(OBJ_PLACE)$@ $<
$(MCEDIT_OBJS_DIR)/%.$(OBJ_SUFFIX): $(MCGTKEDIT_SRC_DIR)/%.c
$(CC) -I$(MCGTKEDIT_SRC_DIR) -I$(MCEDIT_SRC_DIR) -I$(MCEDIT_SRC_DIR)/.. $(MCEDIT_CFLAGS) $(OBJ_PLACE)$@ $<
MC_SRCS= \
terms.c \
user.c \
file.c \
filegui.c \
filenot.c \
findme.c \
listmode.c \
cmd.c \
command.c \
help.c \
menu.c \
view.c \
dir.c \
info.c \
widget.c \
option.c \
dlg.c \
panelize.c \
profile.c \
util.c \
dialog.c \
ext.c \
color.c \
layout.c \
setup.c \
regex.c \
hotlist.c \
tree.c \
win.c \
complete.c \
find.c \
wtools.c \
boxes.c \
background.c \
main.c \
popt.c \
text.c \
screen.c
PC_SRCS= \
chmod.c \
cons_nt.c \
drive.c \
dirent_nt.c \
key_nt.c \
slint_pc.c \
util_win32.c \
util_winnt.c \
util_nt.c
SLANG_SRCS= \
slerr.c \
slgetkey.c \
slsmg.c \
slvideo.c \
slw32tty.c
MCEDIT_SRCS= \
edit.c \
editcmd.c \
editdraw.c \
editmenu.c \
editoptions.c \
editwidget.c \
syntax.c \
wordproc.c
SRCS=$(MC_SRCS) $(PC_SRCS) $(EXTRA_MC_SRCS)
OBJS=$(addprefix $(OBJS_DIR)/, \
$(patsubst %.c,%.$(OBJ_SUFFIX),$(SRCS)))
SLANG_OBJS=$(addprefix $(SLANG_OBJS_DIR)/, \
$(patsubst %.c,%.$(OBJ_SUFFIX),$(SLANG_SRCS)))
MCEDIT_OBJS=$(addprefix $(MCEDIT_OBJS_DIR)/, \
$(patsubst %.c,%.$(OBJ_SUFFIX),$(MCEDIT_SRCS)))
ifdef RSC
ifndef RES_SUFFIX
RES_SUFFIX=res
endif # RES_SUFFIX
MC_RES=$(OBJS_DIR)/mc.$(RES_SUFFIX)
$(MC_RES): $(MC_PC_DIR)/mc.rc $(MC_PC_DIR)/mc_nt.ico $(MC_PC_DIR)/config.h VERSION
$(RSC) $(RES_PLACE)$(MC_RES) $(RC_DEFINES) $(MC_PC_DIR)/mc.rc
else
MC_RES=
endif # !RSC
VERSION: ../configure.in
sed -n -e 's/^AM_INIT_AUTOMAKE([^,]*,[ []*\([0-9A-Za-z.-_]*\).*$$/#define VERSION "\1"/p' $< > $@

View File

@ -1,59 +0,0 @@
# Makefile.RSX
#
# Midnight Commander for NT makefile
# for RSX
#
# Hacked by Dan Nicolaescu from Visual IDE mak
# Hacked by Pavel Roskin to make it work with cmd.exe from Windows NT4
# 980206 hacked by Pavel Roskin to make it work with GNU make
# --------------------------------------------------------------------------
TARGET_OS=NT
CC=gcc.exe
LINK=gcc.exe
OBJ_SUFFIX=o
OBJ_PLACE=-o
EXE_PLACE=-o
# Just comment RSC out if you have problems with resources
RSC=grc.exe
RES_PLACE=-o
# ---- Compiler-specific optional stuff
MC_MISC_CFLAGS=-Zrsx32
ifndef RELEASE
# ---- Debug build
OBJS_DIR=debug
EXTRA_MC_SRCS=
SPECIFIC_DEFINES=
SPECIFIC_MC_CFLAGS=-g -O0 $(MC_MISC_CFLAGS)
SPECIFIC_MC_LFLAGS_EXTRA=
SPECIFIC_SLANG_CFLAGS=$(SPECIFIC_MC_CFLAGS)
SPECIFIC_MCEDIT_CFLAGS=$(SPECIFIC_MC_CFLAGS)
RC_DEFINES=
else
# ---- Release build
OBJS_DIR=release
EXTRA_MC_SRCS=
SPECIFIC_DEFINES=
SPECIFIC_MC_CFLAGS=-O2 $(MC_MISC_CFLAGS)
SPECIFIC_MC_LFLAGS_EXTRA=
SPECIFIC_SLANG_CFLAGS=$(SPECIFIC_MC_CFLAGS)
SPECIFIC_MCEDIT_CFLAGS=$(SPECIFIC_MC_CFLAGS)
RC_DEFINES=
endif
# ---- Compiler independent defines
include Makefile.PC
# ---- Linkers are very compiler-specific
SPECIFIC_MC_LFLAGS=-Zrsx32 $(SPECIFIC_MC_LFLAGS_EXTRA)
MC_LIBS=-lvideont -ladvapi32
$(MC_EXE): $(MC_RES) $(OBJS) $(MCEDIT_OBJS) $(SLANG_OBJS)
$(LINK) $(EXE_PLACE) $(MC_EXE) $(SPECIFIC_MC_LFLAGS) $+ $(MC_LIBS)
resources: $(MC_RES)
rsrc $(MC_EXE) $(MC_RES)

View File

@ -1,56 +0,0 @@
# Makefile.VC4
#
# Midnight Commander for Win32 makefile
# for Microsoft Visual C++ 4.x and above
#
# Hacked by Dan Nicolaescu from Visual IDE mak
# Hacked by Pavel Roskin to make it work with cmd.exe from Windows NT4
# 980206 hacked by Pavel Roskin to make it work with GNU make
# --------------------------------------------------------------------------
TARGET_OS=NT
CC=cl.exe
LINK=link.exe
OBJ_SUFFIX=obj
OBJ_PLACE=-Fo
EXE_PLACE=-out:
# Just comment RSC out if you have problems with resources
RSC=rc.exe
RES_PLACE=-fo
# ---- Compiler-specific optional stuff
MC_MISC_CFLAGS=-nologo -YX -Fp$(OBJS_DIR)/mc.pch
ifndef RELEASE
# ---- Debug build
OBJS_DIR=debug
EXTRA_MC_SRCS=trace_nt.c
SPECIFIC_DEFINES=-DHAVE_TRACE
SPECIFIC_MC_CFLAGS=-MLd -W3 -Gm -Zi -Od -Fd$(OBJS_DIR)/mc.pdb $(MC_MISC_CFLAGS)
SPECIFIC_MC_LFLAGS_EXTRA=-debug -incremental:yes
SPECIFIC_SLANG_CFLAGS=$(SPECIFIC_MC_CFLAGS)
SPECIFIC_MCEDIT_CFLAGS=$(SPECIFIC_MC_CFLAGS)
RC_DEFINES=-D_DEBUG
else
# ---- Release build
OBJS_DIR=release
EXTRA_MC_SRCS=
SPECIFIC_DEFINES=
SPECIFIC_MC_CFLAGS=-ML -W3 -O2 $(MC_MISC_CFLAGS)
SPECIFIC_MC_LFLAGS_EXTRA=-incremental:no
SPECIFIC_SLANG_CFLAGS=$(SPECIFIC_MC_CFLAGS)
SPECIFIC_MCEDIT_CFLAGS=$(SPECIFIC_MC_CFLAGS)
RC_DEFINES=-DRELEASE=$(RELEASE)
endif
# ---- Compiler independent defines
include Makefile.PC
# ---- Linkers are usualy compiler-specific
SPECIFIC_MC_LFLAGS=-nologo -subsystem:console -pdb:$(OBJS_DIR)/mc.pdb \
-machine:I386 $(SPECIFIC_MC_LFLAGS_EXTRA)
MC_LIBS=advapi32.lib
$(MC_EXE): $(MC_RES) $(OBJS) $(MCEDIT_OBJS) $(SLANG_OBJS)
$(LINK) $(EXE_PLACE)$(MC_EXE) $(MC_LIBS) $(SPECIFIC_MC_LFLAGS) $+

View File

@ -1,14 +0,0 @@
#
# This makefile is for making the distribution on Unix
# You won't be able to compile with this one the Midnight Commander
# on Win32
#
# Please read the file README in this directory if you want to compile
# the Midnight Commander for Windows NT or OS/2
#
EXTRA_DIST = BUGS Makefile.BC5 Makefile.MIN Makefile.PC Makefile.VC4 \
Makefile.RSX README TODO ChangeLog chmod.c config.h cons_nt.c \
dirent_nt.c drive.c drive.h key_nt.c mc.rc mc_nt.ico \
slint_pc.c trace_nt.c trace_nt.h util_nt.c \
util_win32.c util_win32.h util_winnt.c

View File

@ -1,30 +0,0 @@
This is the port of Midnight Commander for Win32.
The original code was contributed by
Juan Grigera <grigera@isis.unlp.edu.ar>
You need GNU make in order to compile mc. Other implementation of make
don't work! Run
gmake -f Makefile.xxx [RELEASE=1]
where gmake is name of GNU make and Makefile.xxx is the makefile for
your compiler. You may want to add RELEASE=1 if you want to compile an
optimized version without debug information.
Following compilers are supported:
Makefile.VC4: Microsoft Visual C++ 4.0 and above
Makefile.BC5: Borland C++ 5.x
Makefile.RSX: RSXNT (http://www.mathematik.uni-bielefeld.de/~rainer/)
Makefile.MIN: MinGW (http://www.mingw.org/)
Note that "supported" here means only that they used to work in the past
and the specific makefiles are provided for them!
Please note that the Win32 port is not actively developed. The code may
be out-of-date. You may need to fix the code in order to compile it.
If you add a file, don't forget to add it into Makefile.am, or it will
be missing from the release. Note that the release procedure for GNU
Midnight Commander cannot detect missing files in the Win32 port!

10
pc/TODO
View File

@ -1,10 +0,0 @@
TODO
- Move settings from mc.ini to the registry for Windows NT/95 (optionally?)
- Fix opendir/readdir d_date and d_time packing (they return 10).
- Fix gettimeofday()
- Write a better stat function than the one RTL gives us. We can provide
user ID (on NT) and rwx permissions.
- Write the VFS
- Write a better documentation
- Write a better canonify_pathname()

View File

@ -1,406 +0,0 @@
/* Chmod command for Win32
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <config.h>
#include <string.h>
#include <stdio.h>
/* for chmod and stat */
#include <io.h>
#include <sys/types.h>
#include <sys/stat.h>
#include "../src/global.h"
#include "../src/tty.h"
#include "../src/util.h"
#include "../src/win.h"
#include "../src/color.h"
#include "../src/dlg.h"
#include "../src/widget.h"
#include "../src/dialog.h" /* For do_refresh() */
#include "../src/dir.h"
#include "../src/panel.h" /* Needed for the externs */
#include "../src/file.h"
#include "../src/main.h"
#include "../src/chmod.h"
#include "../src/achown.h"
#include "../src/chown.h"
#define FILE_ARCHIVED FILE_ATTRIBUTE_ARCHIVE
#define FILE_DIRECTORY FILE_ATTRIBUTE_DIRECTORY
#define FILE_HIDDEN FILE_ATTRIBUTE_HIDDEN
#define FILE_READONLY FILE_ATTRIBUTE_READONLY
#define FILE_SYSTEM FILE_ATTRIBUTE_SYSTEM
#define mk_chmod(fname,st) SetFileAttributes(fname,st)
static int single_set;
struct Dlg_head *ch_dlg;
#define PX 5
#define PY 2
#define FX 40
#define FY 2
#define BX 6
#define BY 17
#define TX 40
#define TY 12
#define PERMISSIONS 4
#define BUTTONS 6
#define B_MARKED B_USER
#define B_ALL B_USER+1
#define B_SETMRK B_USER+2
#define B_CLRMRK B_USER+3
int mode_change, need_update;
int c_file, end_chmod;
umode_t and_mask, or_mask, c_stat;
char *c_fname, *c_fown, *c_fgrp, *c_fperm;
int c_fsize;
static WLabel *statl;
static int normal_color;
static int title_color;
static int selection_color;
/* bsedos.h */
struct {
mode_t mode;
char *text;
int selected;
WCheck *check;
} check_perm[PERMISSIONS] = {
{
FILE_ARCHIVED, "Archive", 0, 0,
},
{
FILE_READONLY, "Read Only", 0, 0,
},
{
FILE_HIDDEN, "Hidden", 0, 0,
},
{
FILE_SYSTEM, "System", 0, 0,
},
};
struct {
int ret_cmd, flags, y, x;
char *text;
} chmod_but[BUTTONS] = {
{
B_CANCEL, NORMAL_BUTTON, 2, 33, "&Cancel",
},
{
B_ENTER, DEFPUSH_BUTTON, 2, 17, "&Set",
},
{
B_CLRMRK, NORMAL_BUTTON, 0, 42, "C&lear marked",
},
{
B_SETMRK, NORMAL_BUTTON, 0, 27, "S&et marked",
},
{
B_MARKED, NORMAL_BUTTON, 0, 12, "&Marked all",
},
{
B_ALL, NORMAL_BUTTON, 0, 0, "Set &all",
},
};
static void chmod_toggle_select (void)
{
int Id = ch_dlg->current->dlg_id - BUTTONS + single_set * 2;
attrset (normal_color);
check_perm[Id].selected ^= 1;
dlg_move (ch_dlg, PY + PERMISSIONS - Id, PX + 1);
addch ((check_perm[Id].selected) ? '*' : ' ');
dlg_move (ch_dlg, PY + PERMISSIONS - Id, PX + 3);
}
static void chmod_refresh (void)
{
attrset (normal_color);
dlg_erase (ch_dlg);
draw_box (ch_dlg, 1, 2, 20 - single_set, 66);
draw_box (ch_dlg, PY, PX, PERMISSIONS + 2, 33);
draw_box (ch_dlg, FY, FX, 10, 25);
dlg_move (ch_dlg, FY + 1, FX + 2);
addstr ("Name");
dlg_move (ch_dlg, FY + 3, FX + 2);
addstr ("Permissions (Octal)");
dlg_move (ch_dlg, FY + 5, FX + 2);
addstr ("Owner name");
dlg_move (ch_dlg, FY + 7, FX + 2);
addstr ("Group name");
attrset (title_color);
dlg_move (ch_dlg, 1, 28);
addstr (" Chmod command ");
dlg_move (ch_dlg, PY, PX + 1);
addstr (" Permission ");
dlg_move (ch_dlg, FY, FX + 1);
addstr (" File ");
attrset (selection_color);
dlg_move (ch_dlg, TY, TX);
addstr ("Use SPACE to change");
dlg_move (ch_dlg, TY + 1, TX);
addstr ("an option, ARROW KEYS");
dlg_move (ch_dlg, TY + 2, TX);
addstr ("to move between options");
dlg_move (ch_dlg, TY + 3, TX);
addstr ("and T or INS to mark");
}
static int chmod_callback (Dlg_head *h, int Par, int Msg)
{
char buffer [10];
switch (Msg) {
case DLG_ACTION:
if (Par >= BUTTONS - single_set * 2){
c_stat ^= check_perm[Par - BUTTONS + single_set * 2].mode;
sprintf (buffer, "%o", c_stat);
label_set_text (statl, buffer);
chmod_toggle_select ();
mode_change = 1;
}
break;
case DLG_KEY:
if ((Par == 'T' || Par == 't' || Par == KEY_IC) &&
ch_dlg->current->dlg_id >= BUTTONS - single_set * 2) {
chmod_toggle_select ();
if (Par == KEY_IC)
dlg_one_down (ch_dlg);
return 1;
}
break;
case DLG_DRAW:
chmod_refresh ();
break;
}
return 0;
}
static void init_chmod (void)
{
int i;
do_refresh ();
end_chmod = c_file = need_update = 0;
single_set = (cpanel->marked < 2) ? 2 : 0;
if (use_colors){
normal_color = COLOR_NORMAL;
title_color = COLOR_HOT_NORMAL;
selection_color = COLOR_NORMAL;
} else {
normal_color = NORMAL_COLOR;
title_color = SELECTED_COLOR;
selection_color = SELECTED_COLOR;
}
ch_dlg = create_dlg (0, 0, 22 - single_set, 70, dialog_colors,
chmod_callback, "[Chmod]", "Chmod command", DLG_CENTER);
#define XTRACT(i) BY+chmod_but[i].y-single_set, BX+chmod_but[i].x, \
chmod_but[i].ret_cmd, chmod_but[i].flags, chmod_but[i].text, 0, 0, NULL
for (i = 0; i < BUTTONS; i++) {
if (i == 2 && single_set)
break;
else
add_widget (ch_dlg, button_new (XTRACT (i)));
}
#define XTRACT2(i) 0, check_perm [i].text, NULL
for (i = 0; i < PERMISSIONS; i++) {
check_perm[i].check = check_new (PY + (PERMISSIONS - i), PX + 2,
XTRACT2 (i));
add_widget (ch_dlg, check_perm[i].check);
}
}
int pc_stat_file (char *filename)
{
mode_t st;
st = GetFileAttributes (filename);
if (st & FILE_DIRECTORY)
st = -1;
return st;
}
static void chmod_done (void)
{
if (need_update)
update_panels (UP_OPTIMIZE, UP_KEEPSEL);
repaint_screen ();
}
char *next_file (void)
{
while (!cpanel->dir.list[c_file].f.marked)
c_file++;
return cpanel->dir.list[c_file].fname;
}
static void do_chmod (mode_t sf)
{
sf &= and_mask;
sf |= or_mask;
mk_chmod(cpanel->dir.list[c_file].fname, sf);
do_file_mark (cpanel, c_file, 0);
}
static void apply_mask (mode_t sf)
{
char *fname;
mode_t sf_stat;
need_update = end_chmod = 1;
do_chmod (sf);
do {
fname = next_file ();
if ((sf_stat = pc_stat_file (fname)) < 0)
break;
c_stat = sf_stat;
do_chmod (c_stat);
} while (cpanel->marked);
}
void chmod_cmd (void)
{
char buffer [10];
char *fname;
int i;
mode_t sf_stat;
do { /* do while any files remaining */
init_chmod ();
if (cpanel->marked)
fname = next_file (); /* next marked file */
else
fname = selection (cpanel)->fname; /* single file */
if ((sf_stat = pc_stat_file (fname)) < 0) /* get status of file */
break;
c_stat = sf_stat;
mode_change = 0; /* clear changes flag */
/* set check buttons */
for (i = 0; i < PERMISSIONS; i++){
check_perm[i].check->state = (c_stat & check_perm[i].mode) ? 1 : 0;
check_perm[i].selected = 0;
}
/* Set the labels */
c_fname = name_trunc (fname, 21);
add_widget (ch_dlg, label_new (FY+2, FX+2, c_fname, NULL));
c_fown = "unknown";
add_widget (ch_dlg, label_new (FY+6, FX+2, c_fown, NULL));
c_fgrp = "unknown";
add_widget (ch_dlg, label_new (FY+8, FX+2, c_fgrp, NULL));
sprintf (buffer, "%o", c_stat);
statl = label_new (FY+4, FX+2, buffer, NULL);
add_widget (ch_dlg, statl);
run_dlg (ch_dlg); /* retrieve an action */
/* do action */
switch (ch_dlg->ret_value){
case B_ENTER:
if (mode_change)
mk_chmod (fname, c_stat); /*.ado */
need_update = 1;
break;
case B_CANCEL:
end_chmod = 1;
break;
case B_ALL:
case B_MARKED:
and_mask = or_mask = 0;
and_mask = ~and_mask;
for (i = 0; i < PERMISSIONS; i++) {
if (check_perm[i].selected || ch_dlg->ret_value == B_ALL)
if (check_perm[i].check->state & C_BOOL)
or_mask |= check_perm[i].mode;
else
and_mask &= ~check_perm[i].mode;
}
apply_mask (sf_stat);
break;
case B_SETMRK:
and_mask = or_mask = 0;
and_mask = ~and_mask;
for (i = 0; i < PERMISSIONS; i++) {
if (check_perm[i].selected)
or_mask |= check_perm[i].mode;
}
apply_mask (sf_stat);
break;
case B_CLRMRK:
and_mask = or_mask = 0;
and_mask = ~and_mask;
for (i = 0; i < PERMISSIONS; i++) {
if (check_perm[i].selected)
and_mask &= ~check_perm[i].mode;
}
apply_mask (sf_stat);
break;
}
if (cpanel->marked && ch_dlg->ret_value!=B_CANCEL) {
do_file_mark (cpanel, c_file, 0);
need_update = 1;
}
destroy_dlg (ch_dlg);
} while (cpanel->marked && !end_chmod);
chmod_done ();
}

View File

@ -1,228 +0,0 @@
/****************************************************************************
CONFIG.H - Midnight Commander Configuration for Win32
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
----------------------------------------------------------------------------
Changes:
- Created 951204/jfg
- Changed from Alexander Dong (ado) for OS/2
- Changed 980329 by Pavel Roskin for both OS/2 and NT
----------------------------------------------------------------------------
Contents:
- Headers flags
- Library flags
- Typedefs
- etc.
****************************************************************************/
#ifndef __CONFIG_H
#define __CONFIG_H
#define NATIVE_WIN32
#define NEEDS_IO_H
#define NEEDS_DRIVE_H
#define NEEDS_FCNTL_H
#define HAS_ACS_AS_PCCHARS
#ifdef MC_NT
# ifndef WIN32
# define WIN32
# endif
# ifndef __WIN32__
# define __WIN32__
# endif
# ifndef MSWINDOWS
# define MSWINDOWS
# endif
# ifndef NATIVE_WIN32
# define NATIVE_WIN32
# endif
#endif /* MC_NT */
#include "VERSION"
#ifndef pc_system
# define pc_system
#endif
#ifndef HAVE_SLANG
# define HAVE_SLANG
#endif
#ifndef _CONSOLE
# define _CONSOLE
#endif
#define FLOAT_TYPE
#define MIDNIGHT
#define USE_INTERNAL_EDIT
#define STDC_HEADERS
#define HAVE_STDLIB_H
#define HAVE_STRING_H
#define HAVE_LIMITS_H
#if defined (__MINGW32__) || defined (_MSC_VER)
#define HAVE_SYS_UTIME_H
#else
#define HAVE_UTIME_H
#endif
#define HAVE_MEMSET
#define HAVE_MEMCHR
#define HAVE_MEMCPY
#define HAVE_MEMCMP
#define HAVE_MEMMOVE
#define HAVE_STRDUP
#define HAVE_STRERROR
#define HAVE_TRUNCATE
#define REGEX_MALLOC
#define NO_INFOMOUNT
typedef unsigned int umode_t;
#ifdef __MINGW32__
#define S_IRGRP 0000040
#define S_IWGRP 0000020
#define S_IXGRP 0000010
#define S_IROTH 0000004
#define S_IWOTH 0000002
#define S_IXOTH 0000001
#define pipe(p) _pipe(p, 4096, 0x8000 /* O_BINARY */)
typedef int mode_t;
typedef unsigned int nlink_t;
typedef int gid_t;
typedef int uid_t;
typedef int pid_t;
#endif /* __MINGW32__ */
#ifdef _MSC_VER
#define INLINE
#define inline
#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
#define S_IRWXU 0000700
#define S_IRUSR 0000400
#define S_IWUSR 0000200
#define S_IXUSR 0000100
#define S_IRWXG 0000070
#define S_IRGRP 0000040
#define S_IWGRP 0000020
#define S_IXGRP 0000010
#define S_IRWXO 0000007
#define S_IROTH 0000004
#define S_IWOTH 0000002
#define S_IXOTH 0000001
/* FIXME: is this definition correct? */
#define R_OK 4
#define pipe(p) _pipe(p, 4096, 0x8000 /* O_BINARY */)
#define popen _popen
#define pclose _pclose
typedef int mode_t;
typedef unsigned int nlink_t;
typedef int gid_t;
typedef int uid_t;
typedef int pid_t;
#endif /* _MSC_VER */
#ifdef __BORLANDC__
#define INLINE
#define inline
#define S_IRWXG 0000070
#define S_IRGRP 0000040
#define S_IWGRP 0000020
#define S_IXGRP 0000010
#define S_IRWXO 0000007
#define S_IROTH 0000004
#define S_IWOTH 0000002
#define S_IXOTH 0000001
/* FIXME: is this definition correct? */
#define R_OK 4
#define pipe(p) _pipe(p, 4096, 0x8000 /* O_BINARY */)
#define popen _popen
#define pclose _pclose
#define sleep _sleep
typedef int pid_t;
#endif /* __BORLANDC__ */
#ifdef __IBMC__
#define INLINE
#define inline
#define S_ISDIR(m) (((m) & S_IFDIR) != 0)
#define S_ISREG(m) (((m) & S_IFREG) != 0)
#define S_IRWXU 0000700
#define S_IRUSR 0000400
#define S_IWUSR 0000200
#define S_IXUSR 0000100
#define S_IRWXG 0000070
#define S_IRGRP 0000040
#define S_IWGRP 0000020
#define S_IXGRP 0000010
#define S_IRWXO 0000007
#define S_IROTH 0000004
#define S_IWOTH 0000002
#define S_IXOTH 0000001
#define ENOTDIR ENOENT
/* FIXME: is this definition correct? */
#define R_OK 4
#pragma map( chdir , "_chdir" )
#pragma map( getcwd, "_getcwd" )
#pragma map( mkdir , "_mkdir" )
#pragma map( rmdir , "_rmdir" )
#define popen DosCreatePipe
#define pclose DosClose
#define sleep DosSleep
typedef unsigned int nlink_t;
typedef int mode_t;
typedef int gid_t;
typedef int uid_t;
typedef int pid_t;
#endif /* __IBMC__ */
#endif /* __CONFIG_H */

View File

@ -1,110 +0,0 @@
/* Client interface for General purpose Win32 console save/restore server
Having the same interface as its Linux counterpart:
Copyright (C) 1994 Janne Kukonlehto <jtklehto@stekt.oulu.fi>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Note:
show_console_contents doesn't know how to write to its window
the rest works fine.
*/
#include <config.h>
#include "../src/global.h"
#include "trace_nt.h"
int cons_saver_pid = 1;
#include "../src/tty.h"
#include "../src/util.h"
#include "../src/win.h"
#include "../src/cons.saver.h"
signed char console_flag = 1;
static HANDLE hSaved, hNew;
void show_console_contents (int starty, unsigned char begin_line,
unsigned char end_line)
{
COORD c0 = { 0, 0 };
COORD csize;
SMALL_RECT rect;
CHAR_INFO *pchar;
csize.X = COLS;
csize.Y = end_line-begin_line;
rect.Left = 0;
rect.Top = begin_line;
rect.Right = COLS;
rect.Bottom = end_line;
/* -- This code reads characters and attributes */
pchar = malloc (sizeof(CHAR_INFO) * (end_line-begin_line) * COLS);
/* Copy from one console to the curses virtual screen */
win32APICALL(ReadConsoleOutput (hSaved, pchar, csize, c0, &rect));
/* FIXME: this should've work,
but refresh() is called after this write :-( */
win32APICALL(WriteConsoleOutput (hNew, pchar, csize, c0, &rect));
free (pchar);
}
void handle_console (unsigned char action)
{
static SECURITY_ATTRIBUTES sa;
CONSOLE_SCREEN_BUFFER_INFO csbi;
switch (action){
case CONSOLE_INIT:
/* Save Standard handle */
hSaved = GetStdHandle (STD_OUTPUT_HANDLE);
sa.nLength = sizeof(SECURITY_ATTRIBUTES);
sa.lpSecurityDescriptor = NULL;
/* Create a new console buffer */
sa.bInheritHandle = TRUE;
win32APICALL_HANDLE(hNew,
CreateConsoleScreenBuffer (GENERIC_WRITE | GENERIC_READ,
FILE_SHARE_READ | FILE_SHARE_WRITE, &sa,
CONSOLE_TEXTMODE_BUFFER, NULL));
win32APICALL(GetConsoleScreenBufferInfo(hSaved, &csbi));
win32APICALL(SetConsoleScreenBufferSize(hNew, csbi.dwSize));
/* that becomes standard handle */
win32APICALL(SetConsoleActiveScreenBuffer(hNew));
win32APICALL(SetConsoleMode(hNew, ENABLE_PROCESSED_INPUT));
win32APICALL(SetStdHandle(STD_OUTPUT_HANDLE, hNew));
break;
case CONSOLE_DONE:
win32APICALL(CloseHandle (hNew));
break;
case CONSOLE_SAVE:
/* Current = our standard handle */
win32APICALL(SetConsoleActiveScreenBuffer (hNew));
win32APICALL(SetStdHandle (STD_OUTPUT_HANDLE, hNew));
break;
case CONSOLE_RESTORE:
/* Put saved (shell) screen buffer */
win32APICALL(SetConsoleActiveScreenBuffer (hSaved));
win32APICALL(SetStdHandle (STD_OUTPUT_HANDLE, hSaved));
break;
default:
win32Trace(("Invalid action code %d sent to handle_console", action));
}
}

View File

@ -1,96 +0,0 @@
#include <config.h>
/* glib provides a replacement for MSVC */
#ifndef _MSC_VER
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include "../src/global.h"
DIR *opendir (const char * a_dir)
{
int err;
WIN32_FIND_DATA wfd;
DIR* dd_dir = (DIR*) malloc (sizeof(DIR));
char *c_dir = malloc (strlen(a_dir) + 4);
strcpy (c_dir, a_dir);
strcat (c_dir, "\\*");
dd_dir->d_handle = FindFirstFile (c_dir, &wfd);
if (dd_dir->d_handle == INVALID_HANDLE_VALUE) {
err = GetLastError();
switch (err) {
case ERROR_NO_MORE_FILES:
case ERROR_FILE_NOT_FOUND:
case ERROR_PATH_NOT_FOUND:
errno = ENOENT;
break;
case ERROR_NOT_ENOUGH_MEMORY:
errno = ENOMEM;
break;
default:
errno = EINVAL;
break;
}
free(dd_dir);
return NULL;
}
dd_dir->d_attr = (wfd.dwFileAttributes == FILE_ATTRIBUTE_NORMAL)
? 0 : wfd.dwFileAttributes;
dd_dir->d_time = dd_dir->d_date = 10;
dd_dir->d_size = wfd.nFileSizeLow;
strcpy (dd_dir->d_name, wfd.cFileName);
dd_dir->d_first = 1;
free (c_dir);
return dd_dir;
}
DIR *readdir( DIR * dd_dir)
{
int err;
WIN32_FIND_DATA wfd;
if (dd_dir->d_first) {
dd_dir->d_first = 0;
return dd_dir;
}
if(!FindNextFile (dd_dir->d_handle, &wfd)) {
err = GetLastError();
switch (err) {
case ERROR_NO_MORE_FILES:
case ERROR_FILE_NOT_FOUND:
case ERROR_PATH_NOT_FOUND:
errno = ENOENT;
break;
case ERROR_NOT_ENOUGH_MEMORY:
errno = ENOMEM;
break;
default:
errno = EINVAL;
break;
}
return NULL;
}
dd_dir->d_attr = (wfd.dwFileAttributes == FILE_ATTRIBUTE_NORMAL)
? 0 : wfd.dwFileAttributes;
dd_dir->d_time = dd_dir->d_date = 10;
dd_dir->d_size = wfd.nFileSizeLow;
strcpy (dd_dir->d_name, wfd.cFileName);
return dd_dir;
}
int closedir (DIR *dd_dir)
{
FindClose(dd_dir->d_handle);
free (dd_dir);
return 1;
}
#endif /* _MSC_VER */

View File

@ -1,209 +0,0 @@
/* Ch-Drive command for Win32
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Bug:
the code will not work if you have more drives than those that
can fit in a panel.
*/
#include <config.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include "../src/global.h"
#include "../src/tty.h"
#include "../src/util.h"
#include "../src/win.h"
#include "../src/color.h"
#include "../src/dlg.h"
#include "../src/widget.h"
#include "../src/dialog.h"
#include "../src/dir.h"
#include "../src/panel.h"
#include "../src/main.h"
#include "../src/cmd.h"
#include "util_win32.h"
struct Dlg_head *drive_dlg;
WPanel *this_panel;
static int drive_dlg_callback (Dlg_head *h, int Par, int Msg);
static void drive_dlg_refresh (void);
static void drive_cmd(void);
#define B_DRIVE_BASE 100
#define MAX_LGH 13 /* Length for drives */
static void drive_cmd()
{
int i, nNewDrive, nDrivesAvail;
char szTempBuf[7], szDrivesAvail[27*4], *p;
/* Dialogbox position */
int x_pos;
int y_pos = (LINES-6)/2-3;
int y_height;
int x_width;
int m_drv;
/* Get drives name and count */
#ifdef NATIVE_WIN32
GetLogicalDriveStrings (255, szDrivesAvail);
for (nDrivesAvail = 0, p = szDrivesAvail; *p; nDrivesAvail++)
p+=4;
#else
unsigned long uDriveNum, uDriveMap;
nDrivesAvail = 0;
p = szDrivesAvail;
DosQueryCurrentDisk(&uDriveNum, &uDriveMap);
for (i = 0; i < 26; i++) {
if ( uDriveMap & (1 << i) ) {
*p = 'A' + i;
p += 4;
nDrivesAvail++;
}
}
*p = 0;
#endif
/* Create Dialog */
do_refresh ();
m_drv = ((nDrivesAvail > MAX_LGH) ? MAX_LGH: nDrivesAvail);
/* Center on x, relative to panel */
x_pos = this_panel->widget.x + (this_panel->widget.cols - m_drv*3)/2 + 2;
if (nDrivesAvail > MAX_LGH) {
y_height = 8;
x_width = 33;
} else {
y_height = 6;
x_width = (nDrivesAvail - 1) * 2 + 9;
}
drive_dlg = create_dlg (y_pos, x_pos, y_height, x_width, dialog_colors,
drive_dlg_callback, "[ChDrive]", "Change Drive", DLG_NONE);
if (nDrivesAvail>MAX_LGH) {
for (i = 0; i < nDrivesAvail - MAX_LGH; i++) {
p -= 4;
sprintf(szTempBuf, "&%c", *p);
add_widget (drive_dlg,
button_new (5,
(m_drv-i-1)*2+4 - (MAX_LGH*2 - nDrivesAvail) * 2,
B_DRIVE_BASE + nDrivesAvail - i - 1,
HIDDEN_BUTTON,
szTempBuf, 0, NULL, NULL));
}
}
/* Add a button for each drive */
for (i = 0; i < m_drv; i++) {
p -= 4;
sprintf (szTempBuf, "&%c", *p);
add_widget (drive_dlg,
button_new (3, (m_drv-i-1)*2+4, B_DRIVE_BASE+m_drv-i-1,
HIDDEN_BUTTON, szTempBuf, 0, NULL, NULL));
}
run_dlg(drive_dlg);
/* do action */
if (drive_dlg->ret_value != B_CANCEL) {
int errocc = 0; /* no error */
int rtn;
char drvLetter;
nNewDrive = drive_dlg->ret_value - B_DRIVE_BASE;
drvLetter = (char) *(szDrivesAvail + (nNewDrive*4));
#ifdef NATIVE_WIN32
if (win32_GetPlatform() == OS_WinNT) { /* Windows NT */
rtn = _chdrive(drvLetter - 'A' + 1);
} else { /* Windows 95 */
rtn = 1;
SetCurrentDirectory(szDrivesAvail+(nNewDrive*4));
}
#else
rtn = DosSetDefaultDisk(nNewDrive + 1);
#endif
if (rtn == -1)
errocc = 1;
else {
getcwd (this_panel->cwd, sizeof (this_panel->cwd)-2);
if (toupper(drvLetter) == toupper(*(this_panel->cwd))) {
clean_dir (&this_panel->dir, this_panel->count);
this_panel->count = do_load_dir(&this_panel->dir,
this_panel->sort_type,
this_panel->reverse,
this_panel->case_sensitive,
this_panel->filter);
this_panel->top_file = 0;
this_panel->selected = 0;
this_panel->marked = 0;
this_panel->total = 0;
show_dir(this_panel);
reread_cmd();
} else
errocc = 1;
}
if (errocc)
message (1, "Error", " Cannot access drive %c: ",
*(szDrivesAvail+(nNewDrive*4)) );
}
destroy_dlg (drive_dlg);
repaint_screen ();
}
void drive_cmd_a()
{
this_panel = left_panel;
drive_cmd();
}
void drive_cmd_b()
{
this_panel = right_panel;
drive_cmd();
}
void drive_chg(WPanel *panel)
{
this_panel = panel;
drive_cmd();
}
static int drive_dlg_callback (Dlg_head *h, int Par, int Msg)
{
switch (Msg) {
case DLG_DRAW:
drive_dlg_refresh ();
break;
}
return 0;
}
static void drive_dlg_refresh (void)
{
attrset (dialog_colors[0]);
dlg_erase (drive_dlg);
draw_box (drive_dlg, 1, 1, drive_dlg->lines-2, drive_dlg->cols-2);
attrset (dialog_colors[2]);
dlg_move (drive_dlg, 1, drive_dlg->cols/2 - 7);
addstr (" Change Drive ");
}

View File

@ -1,4 +0,0 @@
void drive_cmd_a(WPanel *);
void drive_cmd_b(WPanel *);
void drive_chg(WPanel *panel);

View File

@ -1,317 +0,0 @@
/* Keyboard support routines.
for Windows NT system.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Bugs:
Have trouble with non-US keyboards, "Alt-gr"+keys (API tells CTRL-ALT is pressed)
*/
#include <config.h>
#ifndef NATIVE_WIN32
#error "This file is for Win32 systems only"
#else
#include <stdio.h>
#include "../src/global.h"
#include "../src/mouse.h"
#include "../src/main.h"
#include "../src/key.h"
#include "../vfs/vfs.h"
#include "../src/tty.h"
#include "trace_nt.h"
/* Global variables */
int old_esc_mode = 0;
HANDLE hConsoleInput;
DWORD dwSaved_ControlState;
Gpm_Event evSaved_Event;
/* Unused variables */
int double_click_speed; /* they are here to keep linker happy */
int mou_auto_repeat;
int use_8th_bit_as_meta = 0;
/* Static Tables */
struct {
int key_code;
int vkcode;
} fkt_table [] = {
{ KEY_F(1), VK_F1 },
{ KEY_F(2), VK_F2 },
{ KEY_F(3), VK_F3 },
{ KEY_F(4), VK_F4 },
{ KEY_F(5), VK_F5 },
{ KEY_F(6), VK_F6 },
{ KEY_F(7), VK_F7 },
{ KEY_F(8), VK_F8 },
{ KEY_F(9), VK_F9 },
{ KEY_F(10), VK_F10 },
{ KEY_F(11), VK_F11 },
{ KEY_F(12), VK_F12 },
{ KEY_F(13), VK_F13 },
{ KEY_F(14), VK_F14 },
{ KEY_F(15), VK_F15 },
{ KEY_F(16), VK_F16 },
{ KEY_F(17), VK_F17 },
{ KEY_F(18), VK_F18 },
{ KEY_F(19), VK_F19 },
{ KEY_F(20), VK_F20 },
{ KEY_IC, VK_INSERT },
{ KEY_DC, VK_DELETE },
{ KEY_BACKSPACE, VK_BACK },
{ KEY_PPAGE, VK_PRIOR },
{ KEY_NPAGE, VK_NEXT },
{ KEY_LEFT, VK_LEFT },
{ KEY_RIGHT, VK_RIGHT },
{ KEY_UP, VK_UP },
{ KEY_DOWN, VK_DOWN },
{ KEY_HOME, VK_HOME },
{ KEY_END, VK_END },
{ ALT('*'), VK_MULTIPLY },
{ ALT('+'), VK_ADD },
{ ALT('-'), VK_SUBTRACT },
{ ALT('\t'), VK_PAUSE }, /* Added to make Complete work press Pause */
{ ESC_CHAR, VK_ESCAPE },
{ 0, 0}
};
/* init_key - Called in main.c to initialize ourselves
Get handle to console input
*/
void init_key (void)
{
win32APICALL_HANDLE (hConsoleInput, GetStdHandle (STD_INPUT_HANDLE));
}
int ctrl_pressed ()
{
if(dwSaved_ControlState & RIGHT_ALT_PRESSED) return 0;
/* The line above fixes the BUG with the AltGr Keys*/
return dwSaved_ControlState & (RIGHT_CTRL_PRESSED | LEFT_CTRL_PRESSED);
}
int shift_pressed ()
{
return dwSaved_ControlState & SHIFT_PRESSED;
}
int alt_pressed ()
{
return dwSaved_ControlState & (/* RIGHT_ALT_PRESSED |*/ LEFT_ALT_PRESSED );
}
static int VKtoCurses (int a_vkc)
{
int i;
for (i = 0; fkt_table[i].vkcode != 0; i++)
if (a_vkc == fkt_table[i].vkcode) {
return fkt_table[i].key_code;
}
return 0;
}
static int translate_key_code(int asc, int scan)
{
int c;
switch(scan){
case 106: /* KP_MULT*/
return ALT('*');
case 107: /* KP_PLUS*/
return ALT('+');
case 109: /* KP_MINUS*/
return ALT('-');
}
c = VKtoCurses (scan);
if (!asc && !c)
return 0;
if (asc && c)
return c;
if (!asc || asc=='\t' )
{
if (shift_pressed() && (c >= KEY_F(1)) && (c <= KEY_F(10)))
c += 10;
if (alt_pressed() && (c >= KEY_F(1)) && (c <= KEY_F(2)))
c += 10;
if (alt_pressed() && (c == KEY_F(7)))
c = ALT('?');
if (asc == '\t'){
if(ctrl_pressed())c = ALT('\t');
else c=asc;
}
return c;
}
if (ctrl_pressed())
return XCTRL(asc);
if (alt_pressed())
return ALT(asc);
if (asc == 13)
return 10;
return asc;
}
int get_key_code (int no_delay)
{
INPUT_RECORD ir; /* Input record */
DWORD dw; /* number of records actually read */
int ch, vkcode, j;
if (no_delay) {
/* Check if any input pending, otherwise return */
nodelay (stdscr, TRUE);
win32APICALL(PeekConsoleInput(hConsoleInput, &ir, 1, &dw));
if (!dw)
return 0;
}
do {
win32APICALL(ReadConsoleInput(hConsoleInput, &ir, 1, &dw));
switch (ir.EventType) {
case KEY_EVENT:
if (!ir.Event.KeyEvent.bKeyDown) /* Process key just once: when pressed */
break;
vkcode = ir.Event.KeyEvent.wVirtualKeyCode;
ch = ir.Event.KeyEvent.uChar.AsciiChar;
dwSaved_ControlState = ir.Event.KeyEvent.dwControlKeyState;
j = translate_key_code (ch, vkcode);
if (j)
return j;
break;
case MOUSE_EVENT:
/* Save event as a GPM-like event */
evSaved_Event.x = ir.Event.MouseEvent.dwMousePosition.X;
evSaved_Event.y = ir.Event.MouseEvent.dwMousePosition.Y+1;
evSaved_Event.buttons = ir.Event.MouseEvent.dwButtonState;
switch (ir.Event.MouseEvent.dwEventFlags) {
case 0:
evSaved_Event.type = GPM_DOWN | GPM_SINGLE;
break;
case MOUSE_MOVED:
evSaved_Event.type = GPM_MOVE;
break;
case DOUBLE_CLICK:
evSaved_Event.type = GPM_DOWN | GPM_DOUBLE;
break;
};
return 0;
}
} while (!no_delay);
return 0;
}
static int getch_with_delay (void)
{
int c;
while (1) {
/* Try to get a character */
c = get_key_code (0);
if (c != -1)
break;
}
/* Success -> return the character */
return c;
}
/* Returns a character read from stdin with appropriate interpretation */
int get_event (Gpm_Event *event, int redo_event, int block)
{
int c;
static int flag; /* Return value from select */
static int dirty = 3;
if ((dirty == 1) || is_idle ()){
refresh ();
doupdate ();
dirty = 1;
} else
dirty++;
vfs_timeout_handler ();
c = block ? getch_with_delay () : get_key_code (1);
if (!c) {
/* Code is 0, so this is a Control key or mouse event */
return EV_NONE; /* FIXME: mouse not supported */
}
return c;
}
/* Returns a key press, mouse events are discarded */
int mi_getch ()
{
Gpm_Event ev;
int key;
while ((key = get_event (&ev, 0, 1)) == 0)
;
return key;
}
/*
is_idle - A function to check if we're idle.
It checks for any waiting event (that can be a Key, Mouse event,
and other internal events like focus or menu)
*/
int is_idle (void)
{
DWORD dw;
if (GetNumberOfConsoleInputEvents (hConsoleInput, &dw))
if (dw > 15)
return 0;
return 1;
}
/* get_modifier */
int get_modifier()
{
int retval = 0;
if (dwSaved_ControlState & LEFT_ALT_PRESSED) /* code is not clean, because we return Linux-like bitcodes*/
retval |= ALTL_PRESSED;
if (dwSaved_ControlState & RIGHT_ALT_PRESSED)
retval |= ALTR_PRESSED;
if (dwSaved_ControlState & RIGHT_CTRL_PRESSED ||
dwSaved_ControlState & LEFT_CTRL_PRESSED)
retval |= CONTROL_PRESSED;
if (dwSaved_ControlState & SHIFT_PRESSED)
retval |= SHIFT_PRESSED;
return retval;
}
/* void functions for UNIX compatibility */
int define_sequence (int code, char* vkcode, int action) { return 1; }
void channels_up() {}
void channels_down() {}
void init_key_input_fd (void) {}
void numeric_keypad_mode (void) {}
void application_keypad_mode (void) {}
/* mouse is not yet supported, sorry */
void init_mouse (void) {}
void shut_mouse (void) {}
#endif /* NATIVE_WIN32 */

View File

@ -1,59 +0,0 @@
#include "VERSION"
#ifndef WINDRES
# include "windows.h"
# include "winver.h"
#endif
/* English (U.S.) resources */
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
#ifndef WINDRES
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#endif
#pragma code_page(1252)
#endif /* _WIN32 */
/* Version */
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,0,1
PRODUCTVERSION 3,0,0,1
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x40000L
FILETYPE 0x1L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904E4"
BEGIN
VALUE "CompanyName", "Free Software Foundation"
VALUE "FileDescription", "GNU Midnight Commander"
VALUE "FileVersion", VERSION
VALUE "InternalName", "MC"
VALUE "LegalCopyright", "(c) Free Software Foundation"
VALUE "LegalTrademarks", "see GNU General Public License"
VALUE "OriginalFilename", "MC.EXE"
VALUE "ProductName", "GNU Midnight Commander"
VALUE "ProductVersion", VERSION
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1252
END
END
/* Icon */
0 ICON DISCARDABLE "mc_nt.ico"
#endif /* English (U.S.) resources */

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -1,267 +0,0 @@
/* Slang interface to the Midnight Commander for Win32
This emulates some features of ncurses on top of slang
S-lang is not fully consistent between its Unix and non-Unix versions.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include <config.h>
#include <stdio.h>
#include <string.h>
#include "../src/global.h"
#include "../src/tty.h"
#include "../src/color.h"
#include "../src/util.h"
#include "../src/mouse.h" /* Gpm_Event is required in key.h */
#include "../src/key.h" /* define_sequence */
#include "../src/main.h" /* extern: force_colors */
#include "../src/win.h" /* do_exit_ca_mode */
#ifdef HAVE_SLANG
static void slang_sigterm ()
{
SLsmg_reset_smg ();
}
static int slinterrupt;
void enable_interrupt_key(void)
{
SLang_set_abort_signal(NULL);
slinterrupt = 1;
}
void disable_interrupt_key(void)
{
slinterrupt = 0;
}
int got_interrupt ()
{
int t;
int SLKeyboard_Quit=0; /* FIXME!! */
t = slinterrupt ? SLKeyboard_Quit : 0;
/* SLKeyboard_Quit = 0; */
return t;
}
/* Only done the first time */
void slang_init (void)
{
SLtt_get_terminfo ();
SLang_init_tty (XCTRL('c'), 1, 0);
slang_prog_mode ();
load_terminfo_keys ();
}
/* Done each time we come back from done mode */
void slang_prog_mode (void)
{
SLsmg_init_smg ();
SLsmg_touch_lines (0, LINES);
}
/* Called each time we want to shutdown slang screen manager */
void slang_shell_mode (void)
{
}
void slang_shutdown ()
{
slang_shell_mode ();
do_exit_ca_mode ();
SLang_reset_tty ();
/* reset the colors to those that were
* active when the program was started up
(not written)
*/
}
/* keypad routines */
void slang_keypad (int set)
{
/* enable keypad strings */
}
static int no_slang_delay;
void set_slang_delay (int v)
{
no_slang_delay = v;
}
void hline (int ch, int len)
{
int last_x, last_y;
last_x = SLsmg_get_column ();
last_y = SLsmg_get_row ();
if (ch == 0)
ch = ACS_HLINE;
if (ch == ACS_HLINE){
SLsmg_draw_hline (len);
} else {
while (len--)
addch (ch);
}
move (last_y, last_x);
}
void vline (int character, int len)
{
if (!slow_terminal){
SLsmg_draw_vline (len);
} else {
int last_x, last_y, pos = 0;
last_x = SLsmg_get_column ();
last_y = SLsmg_get_row ();
while (len--){
move (last_y + pos++, last_x);
addch (' ');
}
move (last_x, last_y);
}
}
int has_colors ()
{
/* No terminals on NT, make default color */
if (!disable_colors)
SLtt_Use_Ansi_Colors = 1;
/* Setup emulated colors */
if (SLtt_Use_Ansi_Colors){
init_pair (A_REVERSE, "black", "white");
} else {
/* SLtt_set_mono (A_BOLD, NULL, SLTT_BOLD_MASK);
SLtt_set_mono (A_REVERSE, NULL, SLTT_REV_MASK);
SLtt_set_mono (A_BOLD|A_REVERSE, NULL, SLTT_BOLD_MASK | SLTT_REV_MASK);
*/ }
return SLtt_Use_Ansi_Colors;
}
void attrset (int color)
{
if (!SLtt_Use_Ansi_Colors){
SLsmg_set_color (color);
return;
}
if (color & A_BOLD){
if (color == A_BOLD)
SLsmg_set_color (A_BOLD);
else
SLsmg_set_color ((color & (~A_BOLD)) + 8);
return;
}
if (color == A_REVERSE)
SLsmg_set_color (A_REVERSE);
else
SLsmg_set_color (color);
}
void load_terminfo_keys ()
{
}
int getch ()
{
if (no_slang_delay)
if (SLang_input_pending (0) == 0)
return -1;
return SLang_getkey ();
}
extern int slow_terminal;
#else
/* Non slang builds do not understand got_interrupt */
int got_interrupt ()
{
return 0;
}
#endif /* HAVE_SLANG */
void mc_refresh (void)
{
/* if (!we_are_background) (no background mode yet) */
refresh ();
}
void slang_set_raw_mode (void)
{
return;
}
int max_index = 0;
void
init_pair (int index, char *foreground, char *background)
{
SLtt_set_color (index, "", foreground, background);
if (index > max_index)
max_index = index;
}
int
alloc_color_pair (char *foreground, char *background)
{
init_pair (++max_index, foreground, background);
return max_index;
}
int
try_alloc_color_pair (char *fg, char *bg)
{
static struct colors_avail {
struct colors_avail *next;
char *fg, *bg;
int index;
} *p, c =
{
0, 0, 0, 0
};
c.index = NORMAL_COLOR;
p = &c;
for (;;) {
if (((fg && p->fg) ? !strcmp (fg, p->fg) : fg == p->fg) != 0
&& ((bg && p->bg) ? !strcmp (bg, p->bg) : bg == p->bg) != 0)
return p->index;
if (!p->next)
break;
p = p->next;
}
p->next = malloc (sizeof (c));
p = p->next;
p->next = 0;
p->fg = fg ? strdup (fg) : 0;
p->bg = bg ? strdup (bg) : 0;
if (!fg)
fg = "white";
if (!bg)
bg = "blue";
p->index = alloc_color_pair (fg, bg);
return p->index;
}

View File

@ -1,187 +0,0 @@
/* trace_nt.c - Debugging routines
for Midnight Commander, under Win32
Written 951215 by Juan Grigera <grigera@isis.unlp.edu.ar>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <config.h>
#ifdef HAVE_TRACE
#include <stdio.h>
#ifdef NATIVE_WIN32
#include <windows.h>
#endif
#include <errno.h>
#include "trace_nt.h"
/* Global variables */
int __win32_tracing_enabled = 1;
static int _win32_tracing_started = 0;
static FILE *__win32_trace_f = NULL;
/* Definitions */
#define TRACE_FILE "mcTrace.out"
/* Prototypes - static funcs */
static void _win32InitTrace (void);
static void _win32EndTrace (void);
static const char* GetLastErrorText(void);
static char *visbuf(const char *buf);
/*
void _win32InitTrace()
This func will open file TRACE_FILE for output and add _win32EndTrace to onexit
list of funcs.
*/
static void _win32InitTrace()
{
if (!_win32_tracing_started) {
_win32_tracing_started = 1;
__win32_trace_f = fopen(TRACE_FILE, "wt");
if (__win32_trace_f == NULL) {
printf("Midnight Commander[DEBUG]: Cannot open trace file '" TRACE_FILE "': %s \n", strerror(errno));
}
atexit (&_win32EndTrace);
}
}
/*
void _win32EndTrace()
This func closes file TRACE_FILE if opened.
*/
static void _win32EndTrace()
{
if (_win32_tracing_started) {
_win32_tracing_started = 0;
if (__win32_trace_f)
fclose (__win32_trace_f);
}
}
/*
void _win32Trace (char *fmt, ...)
Format and output debug strings. They are written to TRACE_FILE.
Debug Output is controlled by SetTrace (see below).
Win32: Output is sent to Debug Output also.
*/
void _win32Trace (const char *fmt, ...)
{
va_list ap;
char buffer[256];
char *vp;
if (!_win32_tracing_started)
_win32InitTrace();
va_start(ap, fmt);
vsprintf(buffer, fmt, ap);
va_end(ap);
vp = buffer;
#ifdef NATIVE_WIN32 /* Write Output to Debug monitor also */
OutputDebugString (vp);
#if (_MSC_VER > 800) /* Don't write newline in MSVC++ 1.0, has a dammed bug in Debug Output screen */
OutputDebugString ("\n");
#endif
#endif
if(__win32_trace_f)
fprintf (__win32_trace_f, "%s\n", vp);
}
/*
void SetTrace (int trace)
Control debug output. Turn it of or on.
trace: 0 = off, 1 = on.
*/
void _win32SetTrace (int trace)
{
/* Prototypes - interlan funcs */
__win32_tracing_enabled = trace;
}
void _win32TraceOn ()
{
__win32_tracing_enabled = 1;
}
void _win32TraceOff()
{
__win32_tracing_enabled = 0;
}
#ifdef NATIVE_WIN32
/*
void DebugFailedWin32APICall (const char* name, int line, const char* file)
Report a System call failure.
name - text containing the source code that called the offending API func
line, file - place of "name" in code
See Also: definition of win32APICALL macro.
*/
void _win32DebugFailedWin32APICall (const char* name, int line, const char* file)
{
_win32Trace ("%s(%d): Call to Win32 API Failed. \"%s\".", file, line, name);
_win32Trace (" System Error (%d): %s. ", GetLastError(), GetLastErrorText());
}
#endif
/*
void DebugAssertionFailed (const char* name, int line, const char* file)
Report a logical condition failure. (e.g. a bad argument to a func)
name - text containing the logical condition
line, file - place of "name" in code
See Also: definition of ASSERT macro.
*/
void _win32DebugAssertionFailed (const char* name, int line, const char* file)
{
_win32Trace ("%s(%d): Assertion failed! \"%s\".", file, line, name);
}
/* const char* GetLastErrorText()
Retrieves the text associated with the last system error.
Returns pointer to static buffer. Contents valid till next call
*/
static const char* GetLastErrorText()
{
#define MAX_MSG_SIZE 256
static char szMsgBuf[MAX_MSG_SIZE];
DWORD dwError, dwRes;
dwError = GetLastError ();
dwRes = FormatMessage (
FORMAT_MESSAGE_FROM_SYSTEM,
NULL,
dwError,
MAKELANGID (LANG_ENGLISH, SUBLANG_ENGLISH_US),
szMsgBuf,
MAX_MSG_SIZE,
NULL);
if (0 == dwRes) {
sprintf (szMsgBuf, "FormatMessage failed with %d", GetLastError());
}
return szMsgBuf;
}
#endif /*HAVE_TRACE*/

View File

@ -1,72 +0,0 @@
/* trace_nt.h - Debugging routines
Written by Juan Grigera<grigera@isis.unlp.edu.ar>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* ------------------------------------------------------------------------------------------ *
TRACER FUNCTIONS
* ------------------------------------------------------------------------------------------ */
#ifdef HAVE_TRACE
/************************/
/* Debug version */
/************************/
/* Macros
------
win32Trace(x) - Trace macro. Use double in parenthesis for x. Same args as printf.
win32ASSERT(x) - assert macro, but will not abort program and output sent to trace routine.
win32APICALL(x) - Use to enclose a Win32 system call that should return TRUE.
win32APICALL_HANDLE(h,api) - Use to enclose a Win32 system call that should return a handle.
*/
#define win32Trace(x) if (__win32_tracing_enabled) _win32Trace x
#define win32ASSERT(x) if (!(x)) _win32DebugAssertionFailed (#x, __LINE__, __FILE__)
#define win32APICALL(x) if (!(x)) _win32DebugFailedWin32APICall (#x, __LINE__, __FILE__)
#define win32APICALL_HANDLE(h,api) h=api; if (h==INVALID_HANDLE_VALUE) _win32DebugFailedWin32APICall (#h" = "#api, __LINE__, __FILE__)
/* Prototypes */
void _win32Trace (const char *, ...);
void _win32DebugFailedWin32APICall (const char *name, int line, const char *file);
void _win32DebugAssertionFailed (const char *name, int line, const char *file);
void _win32SetTrace (int trace);
void _win32TraceOn (void);
void _win32TraceOff (void);
#define SetTrace _win32SetTrace
#define TraceOn _win32TraceOn
#define TraceOff _win32TraceOff
/* Global variables */
extern int __win32_tracing_enabled;
#else
/************************/
/* Non-debug version */
/************************/
/* Wipe-out these macros */
#define win32Trace(x)
#define win32ASSERT(x)
#define win32APICALL(x) x
#define win32APICALL_HANDLE(h,api) h=api;
/* Wipe-out these funcs */
#define SetTrace(x)
#define TraceOn()
#define TraceOff()
#endif

View File

@ -1,742 +0,0 @@
/* Various utilities - NT versions
Copyright (C) 1994, 1995, 1996 the Free Software Foundation.
Written 1994, 1995, 1996 by:
Juan Grigera, Miguel de Icaza, Janne Kukonlehto, Dugan Porter,
Jakub Jelinek, Mauricio Plaza.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include <config.h>
#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <io.h>
#include <signal.h> /* my_system */
#include <limits.h> /* INT_MAX */
#include <errno.h>
#include <sys/stat.h>
#include <stdarg.h>
#include <process.h>
#include "../src/global.h"
#include "../src/util.h"
#include "util_win32.h"
#ifdef __BORLANDC__
#define ENOTEMPTY ERROR_DIR_NOT_EMPTY
#endif
char *get_owner (int uid)
{
return "none";
}
char *get_group (int gid)
{
return "none";
}
/* Pipes are guaranteed to be able to hold at least 4096 bytes */
/* More than that would be unportable */
#define MAX_PIPE_SIZE 4096
static int error_pipe[2]; /* File descriptors of error pipe */
static int old_error; /* File descriptor of old standard error */
/* Creates a pipe to hold standard error for a later analysis. */
/* The pipe can hold 4096 bytes. Make sure no more is written */
/* or a deadlock might occur. */
void open_error_pipe (void)
{
if (pipe (error_pipe) < 0){
message (0, "Warning", " Pipe failed ");
}
old_error = dup (2);
if(old_error < 0 || close(2) || dup (error_pipe[1]) != 2){
message (0, "Warning", " Dup failed ");
close (error_pipe[0]);
close (error_pipe[1]);
}
close (error_pipe[1]);
}
/*
* Returns true if an error was displayed
*/
int close_error_pipe (int error, char *text)
{
char *title;
char msg[MAX_PIPE_SIZE];
int len = 0;
if (error)
title = "Error";
else
title = "Warning";
if (old_error >= 0){
close (2);
dup (old_error);
close (old_error);
len = read (error_pipe[0], msg, MAX_PIPE_SIZE);
if (len >= 0)
msg[len] = 0;
close (error_pipe[0]);
}
if (error < 0)
return 0; /* Just ignore error message */
if (text == NULL){
if (len == 0) return 0; /* Nothing to show */
/* Show message from pipe */
message (error, title, "%s", msg);
} else {
/* Show given text and possible message from pipe */
message (error, title, " %s \n %s ", text, msg);
}
return 1;
}
void check_error_pipe (void)
{
char error[MAX_PIPE_SIZE];
int len = 0;
if (old_error >= 0){
while (len < MAX_PIPE_SIZE)
{
int rvalue;
rvalue = -1; /* read (error_pipe[0], error + len, 1); */
if (rvalue <= 0)
break;
len ++;
}
error[len] = 0;
close (error_pipe[0]);
}
if (len > 0)
message (0, "Warning", "%s", error);
}
int my_system (int as_shell_command, const char *shell, const char *command)
{
int status = 0;
#if 0
/* .ado: temp. turn out */
if (as_shell_command) {
/* It is only the shell, /c will not work */
if (command)
spawnlp (P_WAIT, shell, shell, "/c", command, (char *) 0);
else
spawnlp (P_WAIT, shell, (char *) 0);
} else
spawnl (P_WAIT, shell, shell, command, (char *) 0);
if (win32_GetPlatform() == OS_Win95) {
SetConsoleTitle ("GNU Midnight Commander"); /* title is gone after spawn... */
}
#endif
if (as_shell_command) {
if (!access(command, 0)) {
switch(win32_GetEXEType (shell)) {
case EXE_win16: /* Windows 3.x archive or OS/2 */
case EXE_win32GUI: /* NT or Chicago GUI API */
spawnlp (P_NOWAIT, shell, shell, "/c", command, (char *) 0); /* don't wait for GUI programs to end */
break;
case EXE_otherCUI: /* DOS COM, MZ, ZM, Phar Lap */
case EXE_win32CUI: /* NT or Chicago Console API, also OS/2 */
case EXE_Unknown:
default:
spawnlp (P_WAIT, shell, shell, "/c", command, (char *) 0);
break;
}
}
else
spawnlp (P_WAIT, shell, shell, "/c", command, (char *) 0);
}
else
spawnl (P_WAIT, shell, shell, command, (char *) 0);
if (win32_GetPlatform() == OS_Win95) {
SetConsoleTitle ("GNU Midnight Commander"); /* title is gone after spawn... */
}
return status;
}
/* get_default_shell
Get the default shell for the current hardware platform
*/
char* get_default_shell()
{
if (win32_GetPlatform() == OS_WinNT)
return "cmd.exe";
else
return "command.com";
}
char *tilde_expand (const char *directory)
{
return strdup (directory);
}
/* sleep: Call Windows API.
Cannot do simple define. That would need <windows.h> in every source
*/
#ifndef __EMX__
void sleep(unsigned long dwMiliSecs)
{
Sleep(dwMiliSecs);
}
#endif
/* Canonicalize path, and return a new path. Do everything in situ.
The new path differs from path in:
Multiple `/'s are collapsed to a single `/'.
Leading `./'s and trailing `/.'s are removed.
Trailing `/'s are removed.
Non-leading `../'s and trailing `..'s are handled by removing
portions of the path. */
char *canonicalize_pathname (char *path)
{
int i, start;
char stub_char;
stub_char = (*path == PATH_SEP) ? PATH_SEP : '.';
/* Walk along path looking for things to compact. */
i = 0;
for (;;) {
if (!path[i])
break;
while (path[i] && path[i] != PATH_SEP)
i++;
start = i++;
/* If we didn't find any slashes, then there is nothing left to do. */
if (!path[start])
break;
/* Handle multiple `/'s in a row. */
while (path[i] == PATH_SEP)
i++;
if ((start + 1) != i) {
strcpy (path + start + 1, path + i);
i = start + 1;
}
/* Check for trailing `/'. */
if (start && !path[i]) {
zero_last:
path[--i] = '\0';
break;
}
/* Check for `../', `./' or trailing `.' by itself. */
if (path[i] == '.') {
/* Handle trailing `.' by itself. */
if (!path[i + 1])
goto zero_last;
/* Handle `./'. */
if (path[i + 1] == PATH_SEP) {
strcpy (path + i, path + i + 1);
i = start;
continue;
}
/* Handle `../' or trailing `..' by itself.
Remove the previous ?/ part with the exception of
../, which we should leave intact. */
if (path[i + 1] == '.' && (path[i + 2] == PATH_SEP || !path[i + 2])) {
while (--start > -1 && path[start] != PATH_SEP);
if (!strncmp (path + start + 1, "../", 3))
continue;
strcpy (path + start + 1, path + i + 2);
i = start;
continue;
}
}
}
if (!*path) {
*path = stub_char;
path[1] = '\0';
}
return path;
}
#ifndef USE_VFS
/*
int mc_rmdir (char *path);
Fix for Win95 UGLY BUG in rmdir: it will return ENOACCESS instead
of ENOTEMPTY.
*/
int mc_rmdir (char *path)
{
if (win32_GetPlatform() == OS_Win95) {
if (rmdir(path)) {
SetLastError (ERROR_DIR_NOT_EMPTY);
#ifndef __EMX__
/* FIXME: We are always saying the same thing! */
_doserrno = ERROR_DIR_NOT_EMPTY;
#endif
errno = ENOTEMPTY;
return -1;
} else
return 0;
}
else
return rmdir(path); /* No trouble in Windows NT */
}
static int conv_nt_unx_rc(int rc)
{
int errCode;
switch (rc) {
case ERROR_FILE_NOT_FOUND:
case ERROR_PATH_NOT_FOUND:
case ERROR_TOO_MANY_OPEN_FILES:
errCode = ENOENT;
break;
case ERROR_INVALID_HANDLE:
case ERROR_ARENA_TRASHED:
case ERROR_ACCESS_DENIED:
case ERROR_INVALID_ACCESS:
case ERROR_WRITE_PROTECT:
case ERROR_WRITE_FAULT:
case ERROR_READ_FAULT:
case ERROR_SHARING_VIOLATION:
errCode = EACCES;
break;
case ERROR_NOT_ENOUGH_MEMORY:
errCode = ENOMEM;
break;
case ERROR_INVALID_BLOCK:
case ERROR_INVALID_FUNCTION:
case ERROR_INVALID_DRIVE:
errCode = ENODEV;
break;
case ERROR_CURRENT_DIRECTORY:
errCode = ENOTDIR;
break;
case ERROR_NOT_READY:
errCode = EINVAL;
break;
default:
errCode = EINVAL;
break;
} /* endswitch */
return errCode;
}
/*
int mc_unlink (char *pathName)
For Windows 95 and NT, files should be able to be deleted even
if they don't have write-protection. We should build a question box
like: Delete anyway? Yes <No> All
*/
int mc_unlink (char *pathName)
{
char *fileName;
char *trunced_name;
static int erase_all = 0;
BOOL rc;
DWORD returnError;
rc = DeleteFile(pathName);
returnError = GetLastError();
if ((rc == FALSE) && (returnError == ERROR_ACCESS_DENIED)) {
int result;
if (!erase_all) {
errno = conv_nt_unx_rc(returnError);
trunced_name = name_trunc(pathName, 30);
fileName = (char *) malloc(strlen(trunced_name) + 16);
strcpy(fileName, "File ");
strcat(fileName, trunced_name);
strcat(fileName, " protected");
result = query_dialog(fileName, "Delete anyway?", 3, 3, " No ", " Yes ", " All in the future!");
free(fileName);
switch (result) {
case 0:
do_refresh ();
return -1;
case 1:
do_refresh ();
break;
case 2:
do_refresh ();
erase_all = 1;
break;
default:
do_refresh ();
return -1;
break;
}
}
chmod(pathName, S_IWRITE); /* make it writable */
rc = DeleteFile(pathName);
returnError = GetLastError();
if (rc == FALSE) {
errno = conv_nt_unx_rc(returnError);
return -1;
}
}
if (rc == TRUE) return 0;
else
return -1;
}
#endif /*USE_VFS*/
void my_statfs (struct my_statfs *myfs_stats, char *path)
{
int len = 0;
DWORD lpSectorsPerCluster, lpBytesPerSector, lpFreeClusters, lpClusters;
DWORD lpMaximumComponentLength, lpFileSystemFlags;
static char lpVolumeNameBuffer[256], lpFileSystemNameBuffer[30];
GetDiskFreeSpace(NULL, &lpSectorsPerCluster, &lpBytesPerSector,
&lpFreeClusters, &lpClusters);
/* KBytes available */
myfs_stats->avail = lpSectorsPerCluster * lpBytesPerSector * lpFreeClusters / 1024;
/* KBytes total */
myfs_stats->total = lpSectorsPerCluster * lpBytesPerSector * lpClusters / 1024;
myfs_stats->nfree = lpFreeClusters;
myfs_stats->nodes = lpClusters;
GetVolumeInformation(NULL, lpVolumeNameBuffer, 255, NULL,
&lpMaximumComponentLength, &lpFileSystemFlags,
lpFileSystemNameBuffer, 30);
myfs_stats->mpoint = lpFileSystemNameBuffer;
myfs_stats->device = lpVolumeNameBuffer;
myfs_stats->type = GetDriveType(NULL);
switch (myfs_stats->type) {
/*
* mmm. DeviceIoControl may fail if you are not root case
* F5_1Pt2_512, 5.25", 1.2MB, 512 bytes/sector
* myfs_stats->typename = "5.25\" 1.2MB"; break; case
* F3_1Pt44_512, 3.5", 1.44MB, 512 bytes/sector
* myfs_stats->typename = "3.5\" 1.44MB"; break; case
* F3_2Pt88_512, 3.5", 2.88MB, 512 bytes/sector
* myfs_stats->typename = "3.5\" 2.88MB"; break; case
* F3_20Pt8_512, 3.5", 20.8MB, 512 bytes/sector
* myfs_stats->typename = "3.5\" 20.8MB"; break; case
* F3_720_512, 3.5", 720KB, 512 bytes/sector
* myfs_stats->typename = "3.5\" 720MB"; break; case
* F5_360_512, 5.25", 360KB, 512 bytes/sector
* myfs_stats->typename = "5.25\" 360KB"; break; case
* F5_320_512, 5.25", 320KB, 512 bytes/sector
* case F5_320_1024, 5.25", 320KB, 1024
* bytes/sector myfs_stats->typename = "5.25\" 320KB"; break;
* case F5_180_512, 5.25", 180KB, 512
* bytes/sector myfs_stats->typename = "5.25\" 180KB"; break;
* case F5_160_512, 5.25", 160KB, 512
* bytes/sector myfs_stats->typename = "5.25\" 160KB"; break;
* case RemovableMedia, Removable media other than
* floppy myfs_stats->typename = "Removable"; break; case
* FixedMedia Fixed hard disk media
* myfs_stats->typename = "Hard Disk"; break; case Unknown:
* Format is unknown
*/
case DRIVE_REMOVABLE:
myfs_stats->typename = "Removable";
break;
case DRIVE_FIXED:
myfs_stats->typename = "Hard Disk";
break;
case DRIVE_REMOTE:
myfs_stats->typename = "Networked";
break;
case DRIVE_CDROM:
myfs_stats->typename = "CD-ROM";
break;
case DRIVE_RAMDISK:
myfs_stats->typename = "RAM disk";
break;
default:
myfs_stats->typename = "unknown";
break;
};
}
int gettimeofday (struct timeval* tvp, void *p)
{
if (p != NULL)
return 0;
/* Since MC only calls this func from get_random_hint we return
some value, not exactly the "correct" one */
tvp->tv_sec = GetTickCount()/1000; /* Number of milliseconds since Windows started*/
tvp->tv_usec = GetTickCount();
}
/* FAKE functions */
int
look_for_exe(const char* pathname)
{
int j;
char *p;
int lgh = strlen(pathname);
if (lgh < 4) {
return 0;
} else {
p = (char *) pathname;
for (j=0; j<lgh-4; j++) {
p++;
} /* endfor */
if (!stricmp(p, ".exe") ||
!stricmp(p, ".bat") ||
!stricmp(p, ".com") ||
!stricmp(p, ".cmd")) {
return 1;
}
}
return 0;
}
int
lstat (const char* pathname, struct stat *buffer)
{
int rc = stat (pathname, buffer);
#ifdef __BORLANDC__
if (rc == 0) {
if (!(buffer->st_mode & S_IFDIR)) {
if (!look_for_exe(pathname)) {
buffer->st_mode &= !S_IXUSR & !S_IXGRP & !S_IXOTH;
}
}
}
#endif
return rc;
}
int getuid ()
{
/* SID sid;
LookupAccountName (NULL, &sid...
return 0;
*/
return 0;
}
int getgid ()
{
return 0;
}
int readlink (char* path, char* buf, int size)
{
return -1;
}
int symlink (char *n1, char *n2)
{
return -1;
}
int link (char *p1, char *p2)
{
return -1;
}
int chown (char *path, int owner, int group)
{
return -1;
}
int mknod (char *path, int mode, int dev)
{
return -1;
}
void init_uid_gid_cache (void)
{
return;
}
/* INHANDLE is a result of some mc_open call to any vfs, this function
returns a normal handle (to be used with read) of a pipe for reading
of the output of COMMAND with arguments ... (must include argv[0] as
well) which gets as its input at most INLEN bytes from the INHANDLE
using mc_read. You have to call mc_doublepclose to close the returned
handle afterwards. If INLEN is -1, we read as much as we can :) */
int mc_doublepopen (int inhandle, int inlen, pid_t *the_pid, char *command, ...)
{
int pipe0 [2], pipe1 [2], std_sav [2];
#define MAXARGS 16
int argno;
char *args[MAXARGS];
char buffer [8192];
int i;
va_list ap;
pid_t pid;
/* Create the pipes */
if(_pipe(pipe0, 8192, O_BINARY | O_NOINHERIT) == -1)
exit (1);
if(_pipe(pipe1, 8192, O_BINARY | O_NOINHERIT) == -1)
exit (1);
/* Duplicate stdin/stdout handles (next line will close original) */
std_sav[0] = _dup(_fileno(stdin));
std_sav[1] = _dup(_fileno(stdout));
/* Duplicate read end of pipe0 to stdin handle */
if(_dup2(pipe0[0], _fileno(stdin)) != 0)
exit (1);
/* Duplicate write end of pipe1 to stdout handle */
if(_dup2(pipe1[1], _fileno(stdout)) != 0)
exit (1);
/* Close original read end of pipe0 */
close(pipe0[0]);
/* Close original write end of pipe1 */
close(pipe1[1]);
va_start (ap, command);
argno = 0;
while ((args[argno++] = va_arg(ap, char *)) != NULL)
if (argno == (MAXARGS - 1)) {
args[argno] = NULL;
break;
}
va_end (ap);
/* Spawn process */
pid = spawnvp(P_NOWAIT,command, args);/* argv[1], (const char* const*)&argv[1]); */
if(!pid)
exit (1);
/* Duplicate copy of original stdin back into stdin */
if(_dup2(std_sav[0], _fileno(stdin)) != 0)
exit (1);
/* Duplicate copy of original stdout back into stdout */
if(_dup2(std_sav[1], _fileno(stdout)) != 0)
exit (1);
/* Close duplicate copy of original stdout and stdin */
close(std_sav[0]);
close(std_sav[1]);
while ((i = _read (inhandle, buffer,
(inlen == -1 || inlen > 8192)
? 8192 : inlen)) > 0) {
write (pipe0 [1], buffer, i);
if (inlen != -1) {
inlen -= i;
if (!inlen)
break;
}
}
close (pipe0 [1]);
*the_pid = pid;
return pipe1 [0];
}
int mc_doublepclose (int pipe, pid_t pid)
{
int status = 0;
close (pipe);
_cwait ( &status, pid, 0);
return status;
}
/*hacks to get it compile, remove these after vfs works */
/*hacks to get it compile, remove these after vfs works */
#ifndef USE_VFS
char *vfs_get_current_dir (void)
{
return NULL;
}
int vfs_current_is_extfs (void)
{
return 0;
}
int vfs_file_is_ftp (char *filename)
{
return 0;
}
int mc_utime (char *path, void *times)
{
return 0;
}
void extfs_run (char *file)
{
return;
}
#endif
char *
get_default_editor (void)
{
return "notepad.exe";
}
int
errno_dir_not_empty (int err)
{
if (err == ENOTEMPTY || err == EEXIST || err == EACCES)
return 1;
return 0;
}
/* The MC library directory is by default the directory where mc.exe
is situated. It is possible to specify this directory via MCHOME
environment variable */
char *
get_mc_lib_dir ()
{
char *cur;
char *mchome = getenv("MCHOME");
if (mchome && *mchome)
return mchome;
mchome = malloc(MC_MAXPATHLEN);
GetModuleFileName(NULL, mchome, MC_MAXPATHLEN);
for (cur = mchome + strlen(mchome); \
(cur > mchome) && (*cur != PATH_SEP); cur--);
*cur = 0;
cur = strdup(mchome);
free(mchome);
if (!cur || !*cur) {
free(cur);
return "C:\\MC";
}
return cur;
}
int get_user_rights (struct stat *buf)
{
return 2;
}
void init_groups (void)
{
}
void delete_groups (void)
{
}

View File

@ -1,187 +0,0 @@
/* Utilities - Win32 utilities (Windows NT and Windows '95)
Copyright (C) 1994, 1995, 1996 the Free Software Foundation.
Written 1996 by Juan Grigera<grigera@isis.unlp.edu.ar>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <config.h>
#include <windows.h>
#include "util_win32.h"
#include "trace_nt.h"
/* int win32_GetPlatform ()
Checks in which OS Midnight Commander is running.
Returns:
OS_WinNT - Windows NT 3.x
OS_Win95 - Windows 4.x
Note: GetVersionEx (Win32API) is called only once.
*/
int win32_GetPlatform ()
{
static int platform = 0;
return (platform ? platform : (platform = win32_GetVersionEx()) );
}
/* int win32_GetVersionEx ()
intended for use by win32_GetPlatform only
*/
int win32_GetVersionEx ()
{
OSVERSIONINFO ovi;
ovi.dwOSVersionInfoSize = sizeof(ovi);
win32APICALL( GetVersionEx(&ovi) );
return ovi.dwPlatformId;
}
/* int win32_GetEXEType (const char* filename)
Determines whether filename (an Executable) is
a Console application (CUI) or a Graphical application(GUI).
filename - Name of executable file to check
Returns: EXE_win16 - Windows 3.x archive or OS/2
EXE_win32CUI - NT or Chicago Console API, also OS/2
EXE_win32GUI - NT or Chicago GUI API
EXE_otherCUI - DOS COM, MZ, ZM, Phar Lap
EXE_Unknown - Unknown
EXE_Error - Cannot read file/EXE image
TODO: better management of OS/2 images
EXE_CompressedArchive can be easily implemented
Notes: This function parses the executable header (the only ugly way
to do it). If header is not found or not understood,
0 is returned.
Information on NE, LE, LX and MZ taken from Ralf Brown's interrupt
list, under INT 21-function 4B ("EXEC" - LOAD AND/OR EXECUTE PROGRAM),
Tables 0806 - 836.
Parsing of PE header (Win32 signature, "Portable Executable")
taken from MSKBase article Number: Q90493.
*/
/* ---- Executable Signatures ---- */
/* Alternative DOS signagure */
#define IMAGE_DOS_SIGNATURE_ALTERNATIVE 0x4D5A /* ZM */
/* Phar Lap .EXP files */
#define IMAGE_OLDPHARLAP_SIGNATURE 0x504D /* MP */
#define IMAGE_NEWPHARLAP_286_SIGNATURE 0x3250 /* P2 */
#define IMAGE_NEWPHARLAP_386_SIGNATURE 0x3350 /* P3 */
/* New Executables */
#define IMAGE_LX_SIGNATURE 0x584C /* LX */
#define IMAGE_PE_SIGNATURE 0x4550 /* PE */
int win32_GetEXEType (const char* a_szFileName)
{
/* FIXME: MinGW cannot compile this code */
#ifndef __MINGW32__
HANDLE hImage;
DWORD dwDumm;
DWORD SectionOffset;
DWORD CoffHeaderOffset;
WORD wSignature;
/* DWORD MoreDosHeader[16]; */
IMAGE_DOS_HEADER image_dos_header;
IMAGE_FILE_HEADER image_file_header;
IMAGE_OPTIONAL_HEADER image_optional_header;
/* IMAGE_SECTION_HEADER image_section_header; */
/* Open the EXE file - Use Native API for SHARE compatibility */
hImage = CreateFile(a_szFileName, GENERIC_READ, FILE_SHARE_READ, NULL,
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (hImage == INVALID_HANDLE_VALUE) {
win32Trace (("win32_GetEXEType: Cannot open file %s. API Error %d.", a_szFileName, GetLastError()));
return EXE_Error;
}
/* Read the MZ (DOS) image header. */
win32APICALL( ReadFile (hImage, (LPVOID)&image_dos_header, sizeof(IMAGE_DOS_HEADER), &dwDumm, NULL) );
switch (image_dos_header.e_magic) {
case IMAGE_DOS_SIGNATURE: /* MZ or ZM */
case IMAGE_DOS_SIGNATURE_ALTERNATIVE:
break;
case IMAGE_OLDPHARLAP_SIGNATURE: /* MP, P2, P3: Phar Lap executables */
case IMAGE_NEWPHARLAP_286_SIGNATURE:
case IMAGE_NEWPHARLAP_386_SIGNATURE:
return EXE_otherCUI;
default:
return EXE_otherCUI; /* Probably .COM? */
}
/* Read more MS-DOS header. */
/* win32APICALL( ReadFile (hImage, MoreDosHeader, sizeof(MoreDosHeader)); */
/* Get new executable header */
CoffHeaderOffset = SetFilePointer(hImage, image_dos_header.e_lfanew, NULL, FILE_BEGIN);
/* + sizeof(ULONG); */
win32APICALL( ReadFile (hImage, (LPVOID) &wSignature, sizeof(WORD), &dwDumm, NULL) );
switch (wSignature) {
case IMAGE_PE_SIGNATURE: /* PE - Portable Executable */
break;
case IMAGE_OS2_SIGNATURE: /* NE - New Executable OS/2 and Windows 3.x */
case IMAGE_OS2_SIGNATURE_LE: /* LE - Linear Execuable (Windows 3.x) */
case IMAGE_LX_SIGNATURE: /* LX - Linear Execuable (OS/2) */
return EXE_win16;
default:
return EXE_Unknown; /* unknown New Executable or bad pointer */
}
/* Continue parsing PE (COFF-like) */
SectionOffset = CoffHeaderOffset + IMAGE_SIZEOF_FILE_HEADER + IMAGE_SIZEOF_NT_OPTIONAL_HEADER;
win32APICALL( ReadFile(hImage, (LPVOID) &image_file_header, IMAGE_SIZEOF_FILE_HEADER, &dwDumm, NULL) );
/* Read optional header. */
win32APICALL( ReadFile(hImage, (LPVOID) &image_optional_header, IMAGE_SIZEOF_NT_OPTIONAL_HEADER, &dwDumm, NULL) );
switch (image_optional_header.Subsystem) {
case IMAGE_SUBSYSTEM_WINDOWS_GUI:
return EXE_win32GUI;
case IMAGE_SUBSYSTEM_WINDOWS_CUI:
case IMAGE_SUBSYSTEM_OS2_CUI:
case IMAGE_SUBSYSTEM_POSIX_CUI:
return EXE_win32CUI;
case IMAGE_SUBSYSTEM_UNKNOWN:
case IMAGE_SUBSYSTEM_NATIVE:
return EXE_Unknown; /* FIXME: what is "NATIVE??" */
default:
win32Trace(("Unknown type %u.\n", image_optional_header.Subsystem));
return EXE_Unknown;
}
#else
return EXE_Unknown;
#endif /* !__MINGW32__ */
}

View File

@ -1,42 +0,0 @@
/* util.Win32.h - Header
Utilities - Win32 utilities (Windows NT and Windows '95)
Copyright (C) 1994, 1995, 1996 the Free Software Foundation.
Written 1996 by Juan Grigera<grigera@isis.unlp.edu.ar>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* Prototypes */
int win32_GetPlatform ();
int win32_GetEXEType (const char* a_szFileName);
int win32_GetVersionEx ();
/* Constants */
enum {
OS_WinNT = VER_PLATFORM_WIN32_NT, /* windows.h values */
OS_Win95 = VER_PLATFORM_WIN32_WINDOWS,
};
enum {
EXE_Unknown,
EXE_win16,
EXE_win32CUI,
EXE_win32GUI,
EXE_otherCUI,
EXE_Error
};

View File

@ -1,85 +0,0 @@
/* Utilities - Windows NT specific utilities (not in Win95)
Copyright (C) 1994, 1995, 1996 the Free Software Foundation.
Written 1996 by Juan Grigera<grigera@isis.unlp.edu.ar>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <config.h>
#include <windows.h>
#include "util_win32.h"
#include "trace_nt.h"
/* int winnt_IsAdministrator() - Determines whether user has Administrator (root)
priviledges.
Return: 1 if administrator
0 if not
Note: Code taken from MSKbase Number: Q118626.
To determine whether or not a user is an administrator, you need to examine
the user's access token with GetTokenInformation(). The access token
represents the user's privileges and the groups to which the user belongs.
*/
int winnt_IsAdministrator()
{
HANDLE hAccessToken;
UCHAR InfoBuffer[1024];
PTOKEN_GROUPS ptgGroups = (PTOKEN_GROUPS)InfoBuffer;
DWORD dwInfoBufferSize;
PSID psidAdministrators;
SID_IDENTIFIER_AUTHORITY siaNtAuthority = SECURITY_NT_AUTHORITY;
UINT x;
BOOL bSuccess;
if(!OpenProcessToken(GetCurrentProcess(),TOKEN_READ,&hAccessToken))
return 0;
bSuccess = GetTokenInformation(hAccessToken,TokenGroups,InfoBuffer,
1024, &dwInfoBufferSize);
CloseHandle(hAccessToken);
if( !bSuccess )
return 0;
if(!AllocateAndInitializeSid(&siaNtAuthority, 2,
SECURITY_BUILTIN_DOMAIN_RID,
DOMAIN_ALIAS_RID_ADMINS,
0, 0, 0, 0, 0, 0,
&psidAdministrators))
return 0;
bSuccess = 0;
for(x=0;x<ptgGroups->GroupCount;x++) {
if( EqualSid(psidAdministrators, ptgGroups->Groups[x].Sid) ) {
bSuccess = 1;
break;
}
}
FreeSid(psidAdministrators);
return bSuccess;
}
int geteuid ()
{
if (winnt_IsAdministrator())
return 0;
return 1;
}