* 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.
Этот коммит содержится в:
родитель
1dcc3e89bc
Коммит
182da213b2
@ -1,3 +1,10 @@
|
||||
2002-01-03 Pavel Roskin <proski@gnu.org>
|
||||
|
||||
* 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
|
||||
|
@ -1,57 +0,0 @@
|
||||
# Makefile.BC2
|
||||
#
|
||||
# Midnight Commander for OS/2 makefile
|
||||
# for Borland C++ 2
|
||||
#
|
||||
# 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=OS2
|
||||
|
||||
CC=bcc.exe
|
||||
LINK=bcc.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=-D__MT__ -I../src -I../edit
|
||||
|
||||
ifndef RELEASE
|
||||
# ---- Debug build
|
||||
OBJS_DIR=debug
|
||||
EXTRA_MC_SRCS=
|
||||
SPECIFIC_DEFINES=
|
||||
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=-O2 $(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
|
||||
|
||||
MC_LIBS=c2mt.lib
|
||||
SPECIFIC_MC_LFLAGS=$(SPECIFIC_MC_LFLAGS_EXTRA)
|
||||
|
||||
$(MC_EXE): $(MC_RES) $(OBJS) $(MCEDIT_OBJS) $(SLANG_OBJS)
|
||||
$(LINK) $(EXE_PLACE)$(MC_EXE) $(SPECIFIC_MC_LFLAGS) $+ $(MC_LIBS)
|
@ -1,56 +0,0 @@
|
||||
# Makefile.EMX
|
||||
#
|
||||
# Midnight Commander for OS/2 makefile
|
||||
# for EMX+GCC
|
||||
#
|
||||
# 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=OS2
|
||||
|
||||
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=rc.exe
|
||||
# RES_PLACE=-fo
|
||||
|
||||
# ---- Compiler-specific optional stuff
|
||||
MC_MISC_CFLAGS=-Zmt
|
||||
|
||||
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=-D_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=-DRELEASE=$(RELEASE)
|
||||
endif
|
||||
|
||||
# ---- Compiler independent defines
|
||||
include Makefile.PC
|
||||
|
||||
# ---- Linkers are very compiler-specific
|
||||
|
||||
SPECIFIC_MC_LFLAGS= -Zmt $(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) $+
|
@ -1,62 +0,0 @@
|
||||
# Makefile.IBM
|
||||
#
|
||||
# Midnight Commander for OS/2 makefile
|
||||
# for IBM CSet and Visual Age C++
|
||||
#
|
||||
# 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
|
||||
# 980327 hacked by Pavel Roskin to make it work with Visual Age C++
|
||||
# --------------------------------------------------------------------------
|
||||
|
||||
TARGET_OS=OS2
|
||||
|
||||
CC=icc.exe
|
||||
LINK=icc.exe
|
||||
OBJ_SUFFIX=obj
|
||||
OBJ_PLACE=-Fo
|
||||
EXE_PLACE=-Fe
|
||||
# Just comment RSC out if you have problems with resources
|
||||
# RSC=rc.exe
|
||||
# RES_PLACE=-fo
|
||||
|
||||
# ---- Compiler-specific optional stuff
|
||||
MC_MISC_CFLAGS=-Q -Gm -I../src
|
||||
|
||||
ifndef RELEASE
|
||||
# ---- Debug build
|
||||
OBJS_DIR=debug
|
||||
EXTRA_MC_SRCS=
|
||||
SPECIFIC_DEFINES=
|
||||
SPECIFIC_MC_CFLAGS=-Ti $(MC_MISC_CFLAGS)
|
||||
SPECIFIC_MC_LFLAGS_EXTRA=-Ti
|
||||
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=-O $(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 very compiler-specific
|
||||
|
||||
SPECIFIC_MC_LFLAGS= -Q -Gm $(SPECIFIC_MC_LFLAGS_EXTRA)
|
||||
MC_LIBS=
|
||||
MC_DEF=$(MC_PC_DIR)/mc.def
|
||||
|
||||
LINK_CMD=$(LINK) $(EXE_PLACE)$(MC_EXE) $(SPECIFIC_MC_LFLAGS) $(MC_RES) \
|
||||
$(OBJS) $(MCEDIT_OBJS) $(SLANG_OBJS) $(MC_LIBS) $(MC_DEF)
|
||||
_LINK_CMD=$(subst /,\\,$(LINK_CMD))
|
||||
|
||||
$(MC_EXE): $(MC_RES) $(OBJS) $(MCEDIT_OBJS) $(SLANG_OBJS)
|
||||
$(_LINK_CMD)
|
@ -7,11 +7,8 @@
|
||||
# the Midnight Commander for Windows NT or OS/2
|
||||
#
|
||||
|
||||
EXTRA_DIST = BUGS Makefile.BC2 Makefile.BC5 Makefile.EMX \
|
||||
Makefile.MIN Makefile.IBM Makefile.PC Makefile.VC4 \
|
||||
Makefile.RSX README TODO ChangeLog chmod.c config.h \
|
||||
cons_nt.c cons_os2.c dirent.h dirent_nt.c dirent_os2.c \
|
||||
drive.c drive.h key_nt.c key_os2.c mc.def mc.rc mc_nt.ico \
|
||||
mc_os2.ico regex.c regex.h slint_pc.c trace_nt.c trace_nt.h \
|
||||
util_nt.c util_os2.c util_win32.c util_win32.h util_winnt.c \
|
||||
sys/time.h
|
||||
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 regex.c \
|
||||
regex.h slint_pc.c trace_nt.c trace_nt.h util_nt.c \
|
||||
util_win32.c util_win32.h util_winnt.c
|
||||
|
110
pc/cons_os2.c
110
pc/cons_os2.c
@ -1,110 +0,0 @@
|
||||
/* Client interface for General purpose OS/2 console save/restore server.
|
||||
1997 Alexander Dong <ado@software-ag.de>
|
||||
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.
|
||||
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#ifdef __os2__
|
||||
#define INCL_BASE
|
||||
#define INCL_NOPM
|
||||
#define INCL_VIO
|
||||
#define INCL_KBD
|
||||
#define INCL_DOS
|
||||
#define INCL_SUB
|
||||
#define INCL_DOSERRORS
|
||||
#include <os2.h>
|
||||
#endif
|
||||
|
||||
#include "../src/tty.h"
|
||||
#include "../src/util.h"
|
||||
#include "../src/win.h"
|
||||
#include "../src/cons.saver.h"
|
||||
|
||||
signed char console_flag = 1;
|
||||
static unsigned char *scr_buffer;
|
||||
static unsigned char *pointer;
|
||||
|
||||
static int GetScrRows();
|
||||
static int GetScrCols();
|
||||
|
||||
static int GetScrRows()
|
||||
{
|
||||
VIOMODEINFO pvMode = {80};
|
||||
unsigned int hVio = 0;
|
||||
VioGetMode(&pvMode, hVio);
|
||||
return (pvMode.row ? pvMode.row: 25);
|
||||
}
|
||||
|
||||
static int GetScrCols()
|
||||
{
|
||||
VIOMODEINFO pvMode = {80};
|
||||
unsigned int hVio = 0;
|
||||
VioGetMode(&pvMode, hVio);
|
||||
return (pvMode.col ? pvMode.col: 80);
|
||||
}
|
||||
|
||||
void show_console_contents (int starty, unsigned char begin_line, unsigned char end_line)
|
||||
{
|
||||
int col = GetScrCols();
|
||||
int row = GetScrRows();
|
||||
int n;
|
||||
register int z;
|
||||
|
||||
pointer = scr_buffer;
|
||||
for (z=0; z<(begin_line * col); z++) {
|
||||
pointer++; pointer++;
|
||||
}
|
||||
n = (end_line - begin_line + 1) * col;
|
||||
VioWrtCellStr((PCH) pointer, (USHORT) n, begin_line, 0, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
void handle_console (unsigned char action)
|
||||
{
|
||||
static int col;
|
||||
static int row;
|
||||
int n;
|
||||
|
||||
switch (action) {
|
||||
case CONSOLE_INIT: /* Initialize */
|
||||
col = GetScrCols();
|
||||
row = GetScrRows();
|
||||
scr_buffer = (unsigned char *) malloc(col * row * 2); /* short values */
|
||||
n = col * row * 2;
|
||||
VioReadCellStr((PCH) scr_buffer, (USHORT *) &n, 0, 0, 0); /* Just save it */
|
||||
break;
|
||||
case CONSOLE_DONE:
|
||||
free(scr_buffer);
|
||||
break;
|
||||
case CONSOLE_SAVE: /* Save the screen */
|
||||
n = col * row * 2;
|
||||
VioReadCellStr((PCH) scr_buffer, (USHORT *) &n, 0, 0, 0);
|
||||
break;
|
||||
case CONSOLE_RESTORE:
|
||||
n = col * row * 2;
|
||||
VioWrtCellStr ((PCH) scr_buffer, (USHORT) n, 0, 0, 0); /* Write it back */
|
||||
break;
|
||||
default:
|
||||
/* This is not possible, but if we are here, just save the screen */
|
||||
handle_console(CONSOLE_SAVE);
|
||||
break;
|
||||
}
|
||||
return;
|
||||
}
|
35
pc/dirent.h
35
pc/dirent.h
@ -1,35 +0,0 @@
|
||||
/*
|
||||
* direct.h Defines the types and structures used by the directory routines
|
||||
*
|
||||
*/
|
||||
#ifndef _DIRENT_H_incl
|
||||
#define _DIRENT_H_incl
|
||||
|
||||
#ifdef __cplupplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#define NAME_MAX 255 /* maximum filename for HPFS or NTFS */
|
||||
|
||||
typedef struct dirent {
|
||||
unsigned long* d_handle;
|
||||
unsigned d_attr; /* file's attribute */
|
||||
unsigned short int d_time; /* file's time */
|
||||
unsigned short int d_date; /* file's date */
|
||||
long d_size; /* file's size */
|
||||
char d_name[ NAME_MAX + 1 ]; /* file's name */
|
||||
unsigned short d_ino; /* serial number (not used) */
|
||||
char d_first; /* flag for 1st time */
|
||||
} DIR;
|
||||
|
||||
extern int closedir( DIR * );
|
||||
extern DIR *opendir( const char * );
|
||||
extern struct dirent *readdir( DIR * );
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif /* _DIRENT_H_incl */
|
110
pc/dirent_os2.c
110
pc/dirent_os2.c
@ -1,110 +0,0 @@
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#define INCL_DOSFILEMGR
|
||||
#define INCL_DOSERRORS
|
||||
#include <os2.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include "dirent.h"
|
||||
|
||||
DIR *opendir (const char * a_dir)
|
||||
{
|
||||
APIRET rc;
|
||||
FILEFINDBUF3 FindBuffer = {0};
|
||||
ULONG FileCount = 1;
|
||||
DIR *dd_dir = (DIR*) malloc (sizeof(DIR));
|
||||
char *c_dir = (char*) malloc (strlen(a_dir) + 5);
|
||||
|
||||
strcpy (c_dir, a_dir);
|
||||
strcat (c_dir, "\\*.*");
|
||||
dd_dir->d_handle = (unsigned long*) HDIR_CREATE;
|
||||
|
||||
rc = DosFindFirst(c_dir,
|
||||
(PHDIR) &dd_dir->d_handle,
|
||||
FILE_SYSTEM | FILE_HIDDEN | FILE_DIRECTORY,
|
||||
(PVOID) &FindBuffer,
|
||||
sizeof(FILEFINDBUF3),
|
||||
&FileCount,
|
||||
FIL_STANDARD);
|
||||
|
||||
if (rc) {
|
||||
switch (rc) {
|
||||
case ERROR_NO_MORE_FILES:
|
||||
case ERROR_FILE_NOT_FOUND:
|
||||
case ERROR_PATH_NOT_FOUND:
|
||||
errno = ENOENT;
|
||||
break;
|
||||
case ERROR_BUFFER_OVERFLOW:
|
||||
errno = ENOMEM;
|
||||
break;
|
||||
default:
|
||||
errno = EINVAL;
|
||||
break;
|
||||
}
|
||||
free(dd_dir);
|
||||
return NULL;
|
||||
}
|
||||
dd_dir->d_attr = FindBuffer.attrFile;
|
||||
dd_dir->d_time = dd_dir->d_date = 10;
|
||||
dd_dir->d_size = FindBuffer.cbFile;
|
||||
strcpy (dd_dir->d_name, FindBuffer.achName);
|
||||
dd_dir->d_first = 1;
|
||||
|
||||
free (c_dir);
|
||||
return dd_dir;
|
||||
}
|
||||
|
||||
DIR *readdir( DIR * dd_dir)
|
||||
{
|
||||
APIRET rc;
|
||||
FILEFINDBUF3 FindBuffer = {0};
|
||||
ULONG FileCount = 1;
|
||||
DIR *ret_dir = (DIR*) malloc (sizeof(DIR));
|
||||
|
||||
if (dd_dir->d_first) {
|
||||
dd_dir->d_first = 0;
|
||||
return dd_dir;
|
||||
}
|
||||
|
||||
rc = DosFindNext((HDIR) dd_dir->d_handle,
|
||||
(PVOID) &FindBuffer,
|
||||
sizeof(FILEFINDBUF3),
|
||||
&FileCount);
|
||||
|
||||
if (rc) {
|
||||
switch (rc) {
|
||||
case ERROR_NO_MORE_FILES:
|
||||
case ERROR_FILE_NOT_FOUND:
|
||||
case ERROR_PATH_NOT_FOUND:
|
||||
errno = ENOENT;
|
||||
break;
|
||||
case ERROR_BUFFER_OVERFLOW:
|
||||
errno = ENOMEM;
|
||||
break;
|
||||
default:
|
||||
errno = EINVAL;
|
||||
break;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ret_dir->d_attr = FindBuffer.attrFile;
|
||||
ret_dir->d_time = ret_dir->d_date = 10;
|
||||
ret_dir->d_size = FindBuffer.cbFile;
|
||||
strcpy (ret_dir->d_name, FindBuffer.achName);
|
||||
return ret_dir;
|
||||
}
|
||||
|
||||
int closedir (DIR *dd_dir)
|
||||
{
|
||||
if (dd_dir->d_handle != (unsigned long*) HDIR_CREATE) {
|
||||
DosFindClose((HDIR) dd_dir->d_handle);
|
||||
}
|
||||
free (dd_dir);
|
||||
return 1;
|
||||
}
|
408
pc/key_os2.c
408
pc/key_os2.c
@ -1,408 +0,0 @@
|
||||
/* Keyboard support routines.
|
||||
for OS/2 system.
|
||||
|
||||
20. April 97: Alexander Dong (ado)
|
||||
|
||||
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>
|
||||
#ifndef __os2__
|
||||
#error "This file is for OS/2 systems only"
|
||||
#else
|
||||
|
||||
#define INCL_BASE
|
||||
#define INCL_NOPM
|
||||
#define INCL_VIO
|
||||
#define INCL_KBD
|
||||
#define INCL_DOS
|
||||
#define INCL_DOSERRORS
|
||||
#define INCL_WININPUT
|
||||
#include <os2.h>
|
||||
#include <stdio.h>
|
||||
#include "../src/mouse.h"
|
||||
#include "../src/global.h"
|
||||
#include "../src/main.h"
|
||||
#include "../src/key.h"
|
||||
#include "../vfs/vfs.h"
|
||||
#include "../src/tty.h"
|
||||
|
||||
/* Code to read keystrokes in a separate thread */
|
||||
|
||||
typedef struct kbdcodes {
|
||||
UCHAR ascii;
|
||||
UCHAR scan;
|
||||
USHORT shift; /* .ado: change for mc */
|
||||
} KBDCODES;
|
||||
|
||||
/* 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 int VKtoCurses (int vkcode);
|
||||
|
||||
/* -------------------------------------------------------------- */
|
||||
/* DEFINITIONS:
|
||||
Return from SLANG: KeyCode: 0xaaaabbcc
|
||||
|
||||
where: aaaa = Flags
|
||||
bb = Scan code
|
||||
cc = ASCII-code (if available)
|
||||
|
||||
if no flags (CTRL and ALT) is set, cc will be returned.
|
||||
If CTRL is pressed, cc is already the XCTRL(code).
|
||||
case cc is:
|
||||
0xE0: The scan code will be used for the following keys:
|
||||
Insert: 0x52, DEL: 0x53,
|
||||
Page_Up: 0x49, Page_Down: 0x51,
|
||||
Pos1: 0x47, Ende: 0x4F,
|
||||
Up: 0x48, Down: 0x50,
|
||||
Left: 0x4B, Right: 0x4D,
|
||||
|
||||
0x00: The function keys are defined as:
|
||||
F1: 3b00, F2: 3c00 ... F10: 4400, F11: 8500, F12: 8600.
|
||||
With ALT-bit set:
|
||||
ALT(F1): 6800, 6900,... ALT(F10): 7100, ALT(F11): 8b00
|
||||
ALT(F12): 8c00
|
||||
|
||||
Mapping for ALT(key_code):
|
||||
For Mapping with normal keys, only the scan code can be
|
||||
used. (see struct ALT_table)
|
||||
|
||||
Special keys:
|
||||
ENTER (number block): 0xaaaaE00D
|
||||
+ (number block): 0xaaaa4E2B Normal: 1B2B
|
||||
- (number block): 0xaaaa4A2D Normal: 352D
|
||||
* (number block): 0xaaaa372A Normal: 1B2A
|
||||
/ (number block): 0xaaaaE02F
|
||||
*/
|
||||
/* -------------------------------------------------------------- */
|
||||
#define RIGHT_SHIFT_PRESSED 1
|
||||
#define LEFT_SHIFT_PRESSED 2
|
||||
#define CTRL_PRESSED 4
|
||||
#define ALT_PRESSED 8
|
||||
#define SCROLL_LOCK_MODE 16
|
||||
#define NUM_LOCK_MODE 32
|
||||
#define CAPS_LOCK_MODE 64
|
||||
#define INSERT_MODE 128
|
||||
#define LEFT_CTRL_PRESSED 256
|
||||
#define LEFT_ALT_PRESSED 512
|
||||
#define RIGHT_CTRL_PRESSED 1024
|
||||
#define RIGHT_ALT_PRESSED 2048
|
||||
#define SCROLL_LOCK_PRESSED 4096
|
||||
#define NUM_LOCK_PRESSED 8192
|
||||
#define CAPS_LOCK_PRESSED 16384
|
||||
#define SYSREQ 32768
|
||||
/* -------------------------------------------------------------- */
|
||||
|
||||
/* Static Tables */
|
||||
struct {
|
||||
int key_code;
|
||||
int vkcode;
|
||||
} fkt_table [] = {
|
||||
{ KEY_F(1), 0x3B },
|
||||
{ KEY_F(2), 0x3C },
|
||||
{ KEY_F(3), 0x3D },
|
||||
{ KEY_F(4), 0x3E },
|
||||
{ KEY_F(5), 0x3F },
|
||||
{ KEY_F(6), 0x40 },
|
||||
{ KEY_F(7), 0x41 },
|
||||
{ KEY_F(8), 0x42 },
|
||||
{ KEY_F(9), 0x43 },
|
||||
{ KEY_F(10), 0x44 },
|
||||
{ KEY_F(11), 0x85 },
|
||||
{ KEY_F(12), 0x86 },
|
||||
{ 0, 0}
|
||||
};
|
||||
|
||||
|
||||
struct {
|
||||
int key_code;
|
||||
int vkcode;
|
||||
} ALT_table [] = {
|
||||
{ ALT('a'), 0x1E },
|
||||
{ ALT('b'), 0x30 },
|
||||
{ ALT('c'), 0x2E },
|
||||
{ ALT('d'), 0x20 },
|
||||
{ ALT('e'), 0x12 },
|
||||
{ ALT('f'), 0x21 },
|
||||
{ ALT('g'), 0x22 },
|
||||
{ ALT('h'), 0x23 },
|
||||
{ ALT('i'), 0x17 },
|
||||
{ ALT('j'), 0x24 },
|
||||
{ ALT('k'), 0x25 },
|
||||
{ ALT('l'), 0x26 },
|
||||
{ ALT('m'), 0x32 },
|
||||
{ ALT('n'), 0x31 },
|
||||
{ ALT('o'), 0x18 },
|
||||
{ ALT('p'), 0x19 },
|
||||
{ ALT('q'), 0x10 },
|
||||
{ ALT('r'), 0x13 },
|
||||
{ ALT('s'), 0x1F },
|
||||
{ ALT('t'), 0x14 },
|
||||
{ ALT('u'), 0x16 },
|
||||
{ ALT('v'), 0x2F },
|
||||
{ ALT('w'), 0x11 },
|
||||
{ ALT('x'), 0x2D },
|
||||
{ ALT('y'), 0x15 },
|
||||
{ ALT('z'), 0x2C },
|
||||
{ ALT('\n'), 0x1c },
|
||||
{ ALT('\n'), 0xA6 },
|
||||
{ ALT(KEY_F(1)), 0x68 },
|
||||
{ ALT(KEY_F(2)), 0x69 },
|
||||
{ ALT(KEY_F(3)), 0x6A },
|
||||
{ ALT(KEY_F(4)), 0x6B },
|
||||
{ ALT(KEY_F(5)), 0x6C },
|
||||
{ ALT(KEY_F(6)), 0x6D },
|
||||
{ ALT(KEY_F(7)), 0x6E },
|
||||
{ ALT(KEY_F(8)), 0x6F },
|
||||
{ ALT(KEY_F(9)), 0x70 },
|
||||
{ ALT(KEY_F(10)), 0x71 },
|
||||
{ ALT(KEY_F(11)), 0x8B },
|
||||
{ ALT(KEY_F(12)), 0x8C },
|
||||
{ 0, 0}
|
||||
};
|
||||
|
||||
|
||||
struct {
|
||||
int key_code;
|
||||
int vkcode;
|
||||
} movement [] = {
|
||||
{ KEY_IC, 0x52 },
|
||||
{ KEY_DC, 0x53 },
|
||||
{ KEY_PPAGE, 0x49 },
|
||||
{ KEY_NPAGE, 0x51 },
|
||||
{ KEY_LEFT, 0x4B },
|
||||
{ KEY_RIGHT, 0x4D },
|
||||
{ KEY_UP, 0x48 },
|
||||
{ KEY_DOWN, 0x50 },
|
||||
{ KEY_HOME, 0x47 },
|
||||
{ KEY_END, 0x4F },
|
||||
{ 0, 0}
|
||||
};
|
||||
|
||||
|
||||
/* init_key -- to make linker happy */
|
||||
void init_key (void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* The maximum sequence length (32 + null terminator) */
|
||||
static int seq_buffer[33];
|
||||
static int *seq_append = 0;
|
||||
|
||||
static int push_char (int c)
|
||||
{
|
||||
if (!seq_append)
|
||||
seq_append = seq_buffer;
|
||||
|
||||
if (seq_append == &(seq_buffer [sizeof (seq_buffer)-2]))
|
||||
return 0;
|
||||
*(seq_append++) = c;
|
||||
*seq_append = 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int get_key_code (int no_delay)
|
||||
{
|
||||
unsigned int inp_ch;
|
||||
|
||||
if (no_delay) {
|
||||
/* Check if any input pending, otherwise return */
|
||||
nodelay (stdscr, TRUE);
|
||||
inp_ch = SLang_input_pending(0);
|
||||
if (inp_ch == 0) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (no_delay) {
|
||||
return (VKtoCurses(inp_ch));
|
||||
}
|
||||
|
||||
do {
|
||||
inp_ch = SLang_getkey();
|
||||
if (!inp_ch)
|
||||
inp_ch = (SLang_getkey() << 8);
|
||||
if (inp_ch) return (VKtoCurses(inp_ch));
|
||||
} while (!no_delay);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int VKtoCurses (int a_vkc)
|
||||
{
|
||||
int ctrlState = 0;
|
||||
int altState = 0;
|
||||
|
||||
int fsState;
|
||||
char scanCode;
|
||||
char asciiCode;
|
||||
register int i;
|
||||
int rtnCode = 0;
|
||||
|
||||
fsState = (a_vkc & 0xFFFF0000) >> 16;
|
||||
fsState &= (~INSERT_MODE); /* Ignore Insertion mode */
|
||||
|
||||
scanCode = (char) ((a_vkc & 0x0000FFFF) >> 8);
|
||||
asciiCode = (char) (a_vkc & 0x000000FF);
|
||||
|
||||
ctrlState = (fsState & CTRL_PRESSED);
|
||||
altState = (fsState & ALT_PRESSED);
|
||||
|
||||
rtnCode = asciiCode;
|
||||
|
||||
if (ctrlState) {
|
||||
/* CTRL pressed */
|
||||
rtnCode = XCTRL(asciiCode);
|
||||
}
|
||||
|
||||
if (altState) {
|
||||
/* ALT pressed
|
||||
* rtnCode = ALT(asciiCode);
|
||||
*
|
||||
* With German keyboards, the Values between 7B -> 7D
|
||||
* and 5b, 5d, 40, fd, fc and e6 are only reachable with the AltGr
|
||||
* key. If such a combination is used, asciiCode will not be zero.
|
||||
* With the normal ALT key, the asciiCode will always be zero.
|
||||
*/
|
||||
if (asciiCode) {
|
||||
return asciiCode;
|
||||
}
|
||||
}
|
||||
|
||||
/* Scan Movement codes */
|
||||
if (asciiCode == 0) {
|
||||
/* Replace key code with that in table */
|
||||
for (i=0; movement[i].vkcode != 0 || movement[i].key_code != 0; i++)
|
||||
if (scanCode == movement[i].vkcode)
|
||||
return (movement[i].key_code);
|
||||
}
|
||||
|
||||
if (asciiCode == 0) {
|
||||
/* Function-key detected */
|
||||
for (i=0; fkt_table[i].vkcode != 0 || fkt_table[i].key_code != 0; i++)
|
||||
if (scanCode == fkt_table[i].vkcode)
|
||||
return (fkt_table[i].key_code);
|
||||
/* ALT - KEY */
|
||||
/* if (altState) */ {
|
||||
for (i=0; ALT_table[i].vkcode != 0 || ALT_table[i].key_code != 0; i++)
|
||||
if (scanCode == ALT_table[i].vkcode)
|
||||
return (ALT_table[i].key_code);
|
||||
}
|
||||
}
|
||||
|
||||
if (asciiCode == 0x0d) {
|
||||
return '\n';
|
||||
}
|
||||
|
||||
return rtnCode;
|
||||
}
|
||||
|
||||
|
||||
static int getch_with_delay (void)
|
||||
{
|
||||
int c;
|
||||
|
||||
while (1) {
|
||||
/* Try to get a character */
|
||||
c = get_key_code (0);
|
||||
if (c != ERR)
|
||||
break;
|
||||
}
|
||||
/* Success -> return the character */
|
||||
return c;
|
||||
}
|
||||
|
||||
int get_event (Gpm_Event *event, int redo_event, int block)
|
||||
{
|
||||
int c;
|
||||
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 */
|
||||
*event = evSaved_Event;
|
||||
return EV_NONE; /* FIXME: when should we return EV_MOUSE ? */
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* get_modifier */
|
||||
int get_modifier()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ctrl_pressed ()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* void functions for UNIX copatibility */
|
||||
void define_sequence (int code, char* vkcode, int action) {}
|
||||
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 /* __os2__ */
|
@ -1,4 +0,0 @@
|
||||
NAME MC WINDOWCOMPAT
|
||||
DESCRIPTION 'Midnight Commander'
|
||||
EXETYPE OS2
|
||||
PROTMODE
|
Двоичные данные
pc/mc_os2.ico
Двоичные данные
pc/mc_os2.ico
Двоичный файл не отображается.
@ -1,16 +0,0 @@
|
||||
|
||||
#ifndef _SYS_TIME_H
|
||||
#define _SYS_TIME_H
|
||||
|
||||
#ifndef _WINSOCKAPI_ /* winsock.h defines struct timeval */
|
||||
|
||||
struct timeval {
|
||||
long tv_sec;
|
||||
long tv_usec;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
int gettimeofday (struct timeval*, void *);
|
||||
|
||||
#endif
|
897
pc/util_os2.c
897
pc/util_os2.c
@ -1,897 +0,0 @@
|
||||
/* Various utilities - OS/2 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>
|
||||
|
||||
#define INCL_DOS
|
||||
#define INCL_PM
|
||||
#define INCL_DOSPROCESS
|
||||
#define INCL_DOSFILEMGR
|
||||
#define INCL_DOSDEVICES /* Device values */
|
||||
#define INCL_DOSDATETIME
|
||||
#define INCL_DOSERRORS
|
||||
#include <os2.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <ctype.h>
|
||||
#include <sys/stat.h>
|
||||
#include <errno.h>
|
||||
#include <io.h>
|
||||
#include <fcntl.h>
|
||||
#include <signal.h> /* my_system */
|
||||
#include <limits.h> /* INT_MAX */
|
||||
#include <sys/time.h> /* select: timeout */
|
||||
#include <sys/param.h>
|
||||
#include <sys/stat.h>
|
||||
#include <stdarg.h>
|
||||
#include <process.h>
|
||||
#include "../src/fs.h"
|
||||
#include "../src/util.h"
|
||||
#include "../src/dialog.h"
|
||||
|
||||
#ifdef get_default_editor
|
||||
#undef get_default_editor
|
||||
#endif
|
||||
|
||||
char *get_default_shell();
|
||||
|
||||
|
||||
#ifndef ENOTEMPTY
|
||||
#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)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
close_error_pipe (int error, char *text)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
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 = read (error_pipe[0], error + len, 1);
|
||||
len ++;
|
||||
if (rvalue <= 0)
|
||||
break;
|
||||
}
|
||||
error[len] = 0;
|
||||
close (error_pipe[0]);
|
||||
}
|
||||
if (len > 0)
|
||||
message (0, " Warning ", error);
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
StartWindowsProg (char *name, SHORT type)
|
||||
{
|
||||
#if 0 /* FIXME: PM DDL's should be loaded (or not loaded) at run time */
|
||||
PROGDETAILS pDetails;
|
||||
|
||||
memset(&pDetails, 0, sizeof(PROGDETAILS)) ;
|
||||
pDetails.Length = sizeof(pDetails);
|
||||
pDetails.pszExecutable = name; /* program name */
|
||||
pDetails.pszStartupDir = NULL; /* default directory for new app. */
|
||||
pDetails.pszParameters = NULL; /* command line */
|
||||
pDetails.progt.fbVisible = SHE_VISIBLE ;
|
||||
pDetails.pszEnvironment = NULL;
|
||||
|
||||
switch (type) {
|
||||
case 0:
|
||||
/* Win Standard */
|
||||
pDetails.progt.progc = PROG_31_ENHSEAMLESSCOMMON ;
|
||||
break;
|
||||
case 1:
|
||||
/* Win 3.1 Protect */
|
||||
pDetails.progt.progc = PROG_31_ENHSEAMLESSCOMMON ;
|
||||
break;
|
||||
case 2:
|
||||
/* Win 3.1 Enh. Protect */
|
||||
pDetails.progt.progc = PROG_31_ENHSEAMLESSCOMMON ;
|
||||
break;
|
||||
default:
|
||||
pDetails.progt.progc = PROG_31_ENHSEAMLESSCOMMON ;
|
||||
break;
|
||||
}
|
||||
WinStartApp(NULLHANDLE,
|
||||
&pDetails,
|
||||
NULL,
|
||||
NULL,
|
||||
SAF_INSTALLEDCMDLINE|SAF_STARTCHILDAPP) ;
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
os2_system (int as_shell_command, const char *shell, const char *command, char *parm);
|
||||
|
||||
/*
|
||||
as_shell_command = 1: If a program is started during input line, CTRL-O
|
||||
or RETURN
|
||||
= 0: F3, F4
|
||||
*/
|
||||
int
|
||||
my_system (int as_shell_command, const char *shell, const char *command)
|
||||
{
|
||||
char *sh; /* This is the shell -- always! */
|
||||
char *cmd; /* This is the command (only the command) */
|
||||
char *parm; /* This is the parameter (can be more than one) */
|
||||
register int length, i;
|
||||
char temp[4096]; /* That's enough! */
|
||||
char *t, *t1;
|
||||
|
||||
sh = get_default_shell();
|
||||
if (!strcmp("/bin/sh", shell)) { /* Translate "/bin/sh" to "sh" */
|
||||
return spawnlp(P_WAIT, "sh", shell, "-c", command, NULL);
|
||||
} else if (( (t = strrchr(shell,'/')) /* Specialcase Bourne */
|
||||
|| (t = strrchr(shell,'\\')))
|
||||
&& (t1 = strchr(t, '.'))
|
||||
&& (
|
||||
((t1 - t == 4) && strncmp("bash", t, 4))
|
||||
|| ((t1 - t == 3) && strncmp("ksh", t, 3))
|
||||
|| ((t1 - t == 2) && strncmp("sh", t, 2))
|
||||
)) {
|
||||
return spawnlp(P_WAIT, shell, shell, "-c", command, NULL);
|
||||
} else if (strcmp(sh, shell)) {
|
||||
/*
|
||||
Not equal -- That means: shell is the program and command is the
|
||||
parameter
|
||||
*/
|
||||
cmd = (char *) shell;
|
||||
parm = (char *) command;
|
||||
} else {
|
||||
/* look into the command and take out the program */
|
||||
if (command) {
|
||||
strcpy(temp, command);
|
||||
length = strlen(command);
|
||||
for (i=length-1; i>=0; i--) {
|
||||
if (command[i] == ' ') {
|
||||
temp[i] = (char) 0;
|
||||
length--;
|
||||
} else
|
||||
break;
|
||||
}
|
||||
if (i==-1) {
|
||||
/* only blanks */
|
||||
return -1;
|
||||
}
|
||||
if (parm = strchr(temp, (char) ' ')) {
|
||||
*parm = (char) 0;
|
||||
parm++;
|
||||
}
|
||||
cmd = (char *) temp;
|
||||
} else {
|
||||
/* command is NULL */
|
||||
cmd = parm = NULL;
|
||||
}
|
||||
}
|
||||
return os2_system (as_shell_command, sh, cmd, parm);
|
||||
}
|
||||
|
||||
static int
|
||||
ux_startp (const char *shell, const char *command, const char *parm)
|
||||
{
|
||||
if (parm) {
|
||||
spawnlp (P_WAIT,
|
||||
(char *) shell,
|
||||
(char *) shell,
|
||||
"/c",
|
||||
(char *) command,
|
||||
(char *) parm,
|
||||
(char *) 0);
|
||||
} else {
|
||||
spawnlp (P_WAIT,
|
||||
(char *) shell,
|
||||
(char *) shell,
|
||||
"/c",
|
||||
(char *) command,
|
||||
(char *) 0);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
os2_system (int as_shell_command, const char *shell, const char *command, char *parm)
|
||||
{
|
||||
register int i, j;
|
||||
ULONG AppType = 0; /* Application type flags (returned) */
|
||||
APIRET rc = NO_ERROR; /* Return Code */
|
||||
char pathValue[5] = "PATH"; /* For DosSearchPath */
|
||||
UCHAR searchResult[MC_MAXPATHLEN * 2 + 1]; /* For DosSearchPath */
|
||||
|
||||
char *cmdString;
|
||||
char *postFix[3];
|
||||
char *line;
|
||||
/* ------------------------------------------------------- */
|
||||
STARTDATA StartData;
|
||||
CHAR ObjBuf[100];
|
||||
ULONG SessionID;
|
||||
PID pid;
|
||||
|
||||
if (command == NULL) {
|
||||
/* .ado: just start a shell, we don't need the parameter */
|
||||
spawnl (P_WAIT,
|
||||
(char *) shell,
|
||||
(char *) shell,
|
||||
(char *) command, (char *) 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
memset(&StartData, 0, sizeof(StartData)) ;
|
||||
StartData.Length = sizeof(StartData);
|
||||
StartData.Related = SSF_RELATED_CHILD;
|
||||
StartData.FgBg = SSF_FGBG_BACK;
|
||||
StartData.TraceOpt = SSF_TRACEOPT_NONE;
|
||||
StartData.PgmTitle = NULL;
|
||||
StartData.TermQ = NULL;
|
||||
StartData.InheritOpt = SSF_INHERTOPT_PARENT;
|
||||
StartData.IconFile = 0;
|
||||
StartData.PgmHandle = 0;
|
||||
StartData.PgmControl = SSF_CONTROL_VISIBLE ;
|
||||
StartData.ObjectBuffer = ObjBuf;
|
||||
StartData.ObjectBuffLen = 100;
|
||||
StartData.PgmInputs = parm;
|
||||
|
||||
postFix[0] = ".exe";
|
||||
postFix[1] = ".cmd";
|
||||
postFix[2] = ".bat";
|
||||
|
||||
i = strlen(command);
|
||||
if (command[i-1] == ' ') {
|
||||
/* The user has used ALT-RETURN */
|
||||
i--;
|
||||
}
|
||||
cmdString = (char *) malloc(i+1);
|
||||
for (j=0; j<i; j++) {
|
||||
cmdString[j] = command[j];
|
||||
}
|
||||
cmdString[j] = (char) 0;
|
||||
|
||||
if ((i < 5) || ((i > 4) && (cmdString[i-4]) != '.')) {
|
||||
/* without Extension */
|
||||
line = (char *) malloc(i+5);
|
||||
rc = 1;
|
||||
for (i=0; (i<3 && rc); i++) {
|
||||
/* Search for the file */
|
||||
strcpy(line, cmdString);
|
||||
strcat(line, postFix[i]);
|
||||
rc = DosSearchPath((SEARCH_IGNORENETERRS | SEARCH_ENVIRONMENT | SEARCH_CUR_DIRECTORY),
|
||||
(PSZ) pathValue,
|
||||
line,
|
||||
searchResult,
|
||||
sizeof(searchResult));
|
||||
}
|
||||
free (line);
|
||||
} else {
|
||||
/* Just search */
|
||||
rc = DosSearchPath((SEARCH_IGNORENETERRS | SEARCH_ENVIRONMENT | SEARCH_CUR_DIRECTORY),
|
||||
(PSZ) pathValue,
|
||||
cmdString,
|
||||
searchResult,
|
||||
sizeof(searchResult));
|
||||
}
|
||||
free(cmdString);
|
||||
if (rc != 0) {
|
||||
/* Internal command or the program was written with absolut path */
|
||||
return ux_startp(shell, command, parm);
|
||||
}
|
||||
|
||||
/* Application to be started */
|
||||
StartData.PgmName = searchResult;
|
||||
StartData.Environment = NULL;
|
||||
rc = DosQueryAppType(searchResult, &AppType);
|
||||
if (rc == NO_ERROR) {
|
||||
StartData.SessionType = PROG_WINDOWABLEVIO;
|
||||
if ((AppType & 0x00000007) == FAPPTYP_WINDOWAPI) {
|
||||
/* Window API */
|
||||
StartData.SessionType = PROG_PM;
|
||||
return DosStartSession(&StartData, &SessionID, &pid);
|
||||
}
|
||||
if ((AppType & 0x00000007) == FAPPTYP_WINDOWCOMPAT) {
|
||||
/* Window compat */
|
||||
return ux_startp(shell, command, parm);
|
||||
}
|
||||
if (AppType & 0x0000ffff & FAPPTYP_DOS) {
|
||||
/* PC/DOS Format */
|
||||
StartData.SessionType = PROG_WINDOWEDVDM;
|
||||
return DosStartSession(&StartData, &SessionID, &pid);
|
||||
}
|
||||
if (AppType & 0x0000ffff & FAPPTYP_WINDOWSREAL) {
|
||||
/* Windows real mode app */
|
||||
return StartWindowsProg(searchResult, 0);
|
||||
}
|
||||
if (AppType & 0x0000ffff & FAPPTYP_WINDOWSPROT) {
|
||||
/* Windows Protect mode app*/
|
||||
return StartWindowsProg(searchResult, 1);
|
||||
}
|
||||
if (AppType & 0x0000ffff & FAPPTYP_WINDOWSPROT31) {
|
||||
/* Windows 3.1 Protect mode app*/
|
||||
return StartWindowsProg(searchResult, 2);
|
||||
}
|
||||
rc = DosStartSession(&StartData, &SessionID, &pid) ;
|
||||
} else {
|
||||
/* It's not a known exe type or it's a CMD/BAT file */
|
||||
i = strlen(searchResult);
|
||||
if ((toupper(searchResult[--i]) == 'T') &&
|
||||
(toupper(searchResult[--i]) == 'A') &&
|
||||
(toupper(searchResult[--i]) == 'B') &&
|
||||
(searchResult[--i] == '.') ) {
|
||||
StartData.SessionType = PROG_WINDOWEDVDM;
|
||||
rc = DosStartSession(&StartData, &SessionID, &pid) ;
|
||||
} else {
|
||||
rc = ux_startp (shell, command, parm);
|
||||
}
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
char *tilde_expand (char *directory)
|
||||
{
|
||||
return strdup (directory);
|
||||
}
|
||||
|
||||
|
||||
/* Canonicalize path, and return a new path. Do everything in situ.
|
||||
The new path differs from path in:
|
||||
Multiple BACKSLASHs are collapsed to a single BACKSLASH.
|
||||
Leading `./'s and trailing `/.'s are removed.
|
||||
Trailing BACKSLASHs 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 BACKSLASHs 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 BACKSLASH. */
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
my_statfs (struct my_statfs *myfs_stats, char *path)
|
||||
{
|
||||
PFSALLOCATE pBuf;
|
||||
PFSINFO pFsInfo;
|
||||
ULONG lghBuf;
|
||||
|
||||
ULONG diskNum = 0;
|
||||
ULONG logical = 0;
|
||||
|
||||
UCHAR szDeviceName[3] = "A:";
|
||||
PBYTE pszFSDName = NULL; /* pointer to FS name */
|
||||
APIRET rc = NO_ERROR; /* Return code */
|
||||
BYTE fsqBuffer[sizeof(FSQBUFFER2) + (3 * CCHMAXPATH)] = {0};
|
||||
ULONG cbBuffer = sizeof(fsqBuffer); /* Buffer length) */
|
||||
PFSQBUFFER2 pfsqBuffer = (PFSQBUFFER2) fsqBuffer;
|
||||
|
||||
int i, len = 0;
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
|
||||
lghBuf = sizeof(FSALLOCATE);
|
||||
pBuf = (PFSALLOCATE) malloc(lghBuf);
|
||||
|
||||
/* Get the free number of Bytes */
|
||||
rc = DosQueryFSInfo(0L, FSIL_ALLOC, (PVOID) pBuf, lghBuf);
|
||||
/* KBytes available */
|
||||
myfs_stats->avail = pBuf->cSectorUnit * pBuf->cUnitAvail * pBuf->cbSector / 1024;
|
||||
/* KBytes total */
|
||||
myfs_stats->total = pBuf->cSectorUnit * pBuf->cUnit * pBuf->cbSector / 1024;
|
||||
myfs_stats->nfree = pBuf->cUnitAvail;
|
||||
myfs_stats->nodes = pBuf->cbSector;
|
||||
|
||||
lghBuf = sizeof(FSINFO);
|
||||
pFsInfo = (PFSINFO) malloc(lghBuf);
|
||||
rc = DosQueryFSInfo(0L,
|
||||
FSIL_VOLSER,
|
||||
(PVOID) pFsInfo,
|
||||
lghBuf);
|
||||
/* Get name */
|
||||
myfs_stats->device = strdup(pFsInfo->vol.szVolLabel); /* Label of the Disk */
|
||||
|
||||
/* Get the current disk for DosQueryFSAttach */
|
||||
rc = DosQueryCurrentDisk(&diskNum, &logical);
|
||||
|
||||
szDeviceName[0] = (UCHAR) (diskNum + (ULONG) 'A' - 1);
|
||||
/* Now get the type of the disk */
|
||||
rc = DosQueryFSAttach(szDeviceName,
|
||||
0L,
|
||||
FSAIL_QUERYNAME,
|
||||
pfsqBuffer,
|
||||
&cbBuffer);
|
||||
|
||||
pszFSDName = pfsqBuffer->szName + pfsqBuffer->cbName + 1;
|
||||
myfs_stats->mpoint = strdup(pszFSDName); /* FAT, HPFS ... */
|
||||
|
||||
myfs_stats->type = pBuf->idFileSystem;
|
||||
/* What is about 3 ?*/
|
||||
if (myfs_stats->type == 0) {
|
||||
myfs_stats->typename = (char *) malloc(11);
|
||||
strcpy(myfs_stats->typename, "Local Disk");
|
||||
} else {
|
||||
myfs_stats->typename = (char *) malloc(13);
|
||||
strcpy(myfs_stats->typename, "Other Device");
|
||||
}
|
||||
|
||||
free(pBuf);
|
||||
free(pFsInfo);
|
||||
}
|
||||
|
||||
#ifndef __EMX__
|
||||
int
|
||||
gettimeofday (struct timeval* tvp, void *p)
|
||||
{
|
||||
DATETIME pdt = {0};
|
||||
if (p != NULL) /* what is "p"? */
|
||||
return 0;
|
||||
|
||||
/* Since MC only calls this func from get_random_hint we return
|
||||
* some value, not exactly the "correct" one
|
||||
*/
|
||||
DosGetDateTime(&pdt);
|
||||
tvp->tv_usec = (pdt.hours * 60 + pdt.minutes) * 60 + pdt.seconds;
|
||||
/* Number of milliseconds since Windows started */
|
||||
tvp->tv_sec = tvp->tv_usec * 1000 + pdt.hundredths * 10;
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* 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++;
|
||||
}
|
||||
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 ()
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
int
|
||||
mc_doublepopen (int inhandle, int inlen, pid_t *the_pid, char *command, ...)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
int
|
||||
mc_doublepclose (int pipe, pid_t pid)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifndef HAVE_VFS
|
||||
/*hacks to get it compile, remove these after vfs works */
|
||||
char *
|
||||
vfs_get_current_dir (void)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
int
|
||||
vfs_current_is_extfs (void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifndef HAVE_VFS
|
||||
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
|
||||
|
||||
void *
|
||||
getgrent(void) { return NULL; }
|
||||
|
||||
void
|
||||
setgrent(void) {}
|
||||
|
||||
void
|
||||
endgrent(void) {}
|
||||
|
||||
int
|
||||
setreuid(uid_t ruid, uid_t euid) { return -1; }
|
||||
|
||||
pid_t
|
||||
setsid(void) { return (pid_t)-1; }
|
||||
|
||||
int
|
||||
mkfifo(const char *path, mode_t mode) { return -1; }
|
||||
|
||||
int
|
||||
socketpair(int i, int i1, int i2, int *i3)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
#ifndef HAVE_VFS
|
||||
int
|
||||
mc_chdir(char *pathname)
|
||||
{
|
||||
APIRET ret;
|
||||
register int lgh = strlen(pathname);
|
||||
|
||||
/* Set the current drive */
|
||||
if (lgh == 0) {
|
||||
return -1;
|
||||
} else {
|
||||
/* First set the default drive */
|
||||
if (lgh > 1) {
|
||||
if (pathname[1] == ':') {
|
||||
ret = DosSetDefaultDisk(toupper(pathname[0]) - 'A' + 1);
|
||||
}
|
||||
}
|
||||
/* After that, set the current dir! */
|
||||
ret = DosSetCurrentDir(pathname);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int
|
||||
mc_chmod(char *pathName, int unxmode)
|
||||
{
|
||||
/* OS/2 does not need S_REG */
|
||||
int os2Mode = unxmode & 0x0FFF;
|
||||
return chmod(pathName, os2Mode);
|
||||
}
|
||||
#endif
|
||||
|
||||
static int
|
||||
conv_os2_unx_rc(int os2rc)
|
||||
{
|
||||
int errCode;
|
||||
switch (os2rc) {
|
||||
case ERROR_FILE_NOT_FOUND:
|
||||
case ERROR_PATH_NOT_FOUND:
|
||||
case ERROR_FILENAME_EXCED_RANGE:
|
||||
errCode = ENOENT;
|
||||
break;
|
||||
case ERROR_NOT_DOS_DISK:
|
||||
case ERROR_SHARING_VIOLATION:
|
||||
case ERROR_SHARING_BUFFER_EXCEEDED:
|
||||
case ERROR_ACCESS_DENIED:
|
||||
errCode = EACCES;
|
||||
break;
|
||||
case ERROR_INVALID_PARAMETER:
|
||||
errCode = EINVAL;
|
||||
break;
|
||||
default:
|
||||
errCode = EINVAL;
|
||||
break;
|
||||
}
|
||||
return errCode;
|
||||
}
|
||||
|
||||
#ifndef HAVE_VFS
|
||||
int
|
||||
mc_open (char *file, int flags, int pmode)
|
||||
{
|
||||
return open(file, (flags | O_BINARY), pmode);
|
||||
}
|
||||
|
||||
int
|
||||
mc_unlink(char *pathName)
|
||||
{
|
||||
/* Use OS/2 API to delete a file, if the file is set as read-only,
|
||||
the file will be deleted without asking the user! */
|
||||
APIRET rc;
|
||||
rc = DosDelete(pathName);
|
||||
if (!rc) {
|
||||
return 0;
|
||||
}
|
||||
if (rc == ERROR_ACCESS_DENIED) {
|
||||
chmod(pathName, (S_IREAD|S_IWRITE));
|
||||
rc = DosDelete(pathName);
|
||||
if (rc) {
|
||||
errno = conv_os2_unx_rc(rc) ;
|
||||
return -1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
errno = conv_os2_unx_rc(rc) ;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
char *
|
||||
get_default_editor (void)
|
||||
{
|
||||
char *tmp;
|
||||
APIRET rc;
|
||||
char pathValue[5] = "PATH";
|
||||
UCHAR searchResult[MC_MAXPATHLEN + 1];
|
||||
|
||||
/* EPM is not always be installed */
|
||||
rc = DosSearchPath((SEARCH_IGNORENETERRS | SEARCH_ENVIRONMENT | SEARCH_CUR_DIRECTORY),
|
||||
(PSZ) pathValue,
|
||||
"EPM.EXE",
|
||||
searchResult,
|
||||
sizeof(searchResult));
|
||||
if (rc != 0) {
|
||||
/* The system editor is always there */
|
||||
return strdup("e.exe");
|
||||
} else {
|
||||
/* Let it be searched from my_system */
|
||||
return strdup("epm.exe");
|
||||
}
|
||||
}
|
||||
|
||||
/* get_default_shell
|
||||
Get the default shell for the current hardware platform
|
||||
TODO: Get the value of %OS2_SHELL% or %SHELL%: which one?
|
||||
*/
|
||||
char *
|
||||
get_default_shell()
|
||||
{
|
||||
return getenv ("COMSPEC");
|
||||
}
|
||||
|
||||
int
|
||||
errno_dir_not_empty (int err)
|
||||
{
|
||||
if (err == ENOTEMPTY)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* The MC library directory is by default the directory where mc.exe
|
||||
is situated. It is recommended to specify this directory via MCHOME
|
||||
environment variable, otherwise you will be unable to rename mc.exe */
|
||||
char *
|
||||
get_mc_lib_dir ()
|
||||
{
|
||||
HMODULE mc_hm;
|
||||
int rc;
|
||||
char *cur = NULL;
|
||||
char *mchome = getenv("MCHOME");
|
||||
|
||||
if (mchome && *mchome)
|
||||
return mchome;
|
||||
mchome = malloc(MC_MAXPATHLEN);
|
||||
rc = DosQueryModuleHandle ("MC.EXE", &mc_hm);
|
||||
if (!rc)
|
||||
rc = DosQueryModuleName (mc_hm, MC_MAXPATHLEN, mchome);
|
||||
if (!rc)
|
||||
{
|
||||
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)
|
||||
{
|
||||
}
|
Загрузка…
Ссылка в новой задаче
Block a user