Numerous patches for OS/2 and Windows NT. lstat detects executables

(stat is broken in Borland C). Help looks better.
This commit is contained in:
Pavel Machek 1998-03-23 23:06:36 +00:00
parent ee7dc74ff8
commit b8da58830e
16 changed files with 233 additions and 305 deletions

View File

@ -24,7 +24,6 @@
#if defined(OS2_NT)
# include <io.h>
# include <fcntl.h>
# include <sys\stat.h>
#endif
#include "edit.h"

View File

@ -24,7 +24,6 @@
#ifdef OS2_NT
#include <io.h>
#include <fcntl.h>
#include <sys/stat.h>
#endif
#include <ctype.h>
#include "edit.h"

View File

@ -33,7 +33,7 @@ OBJS_DIR=debug
EXTRA_MC_SRCS=util.debug.c
SPECIFIC_DEFINES=-DHAVE_TRACE
SPECIFIC_MC_CFLAGS=-v -y $(MC_MISC_CFLAGS)
SPECIFIC_MC_LFLAGS_EXTRA=-v -y -lm
SPECIFIC_MC_LFLAGS_EXTRA=-lv
SPECIFIC_SLANG_CFLAGS=$(SPECIFIC_MC_CFLAGS)
SPECIFIC_MCEDIT_CFLAGS=$(SPECIFIC_MC_CFLAGS) -I../edit -I../src
RC_DEFINES=-D_DEBUG
@ -59,4 +59,4 @@ SPECIFIC_MC_LFLAGS= \
$(SPECIFIC_MC_LFLAGS_EXTRA)
$(MC_EXE): $(MC_RES) $(OBJS) $(MCEDIT_OBJS) $(SLANG_OBJS)
$(LINK) $(EXE_PLACE)$(MC_EXE) $(MC_LIBS) $(SPECIFIC_MC_LFLAGS) $+
$(LINK) $(EXE_PLACE)$(MC_EXE) $(SPECIFIC_MC_LFLAGS) $+ $(MC_LIBS)

View File

@ -1,5 +1,5 @@
/****************************************************************************
CONFIG.HPP - Midnight Commander Configuration for Win32
CONFIG.H - Midnight Commander Configuration for Win32
This program is free software; you can redistribute it and/or modify
@ -27,8 +27,8 @@
- Typedefs
- etc.
****************************************************************************/
#ifndef __CONFIG_HPP //Prevent multiple includes
#define __CONFIG_HPP
#ifndef __CONFIG_H
#define __CONFIG_H
#ifndef __BORLANDC__
# include <../VERSION>
@ -57,19 +57,13 @@
#define FLOAT_TYPE
#define MIDNIGHT
// ---------------------------------------------------------------------------
// Headers
#define STDC_HEADERS
#define HAVE_STDLIB_H
#define HAVE_STRING_H
#define HAVE_DIRENT_H
#define HAVE_LIMITS_H
#define HAVE_FCNTL_H
#define NO_UNISTD_H
#pragma include_alias(<utime.h>, <sys/utime.h>) /* Only works for MSVC */
// ---------------------------------------------------------------------------
// "Standard" Library
#define HAVE_MEMSET
#define HAVE_MEMCHR
#define HAVE_MEMCPY
@ -81,11 +75,8 @@
#define REGEX_MALLOC
#define NO_TERM
#define NO_INFOMOUNT
// ---------------------------------------------------------------------------
// Windowing library
#if !defined(HAVE_SLANG) && !defined (USE_NCURSES)
#define HAVE_SLANG
#endif
@ -94,84 +85,76 @@
#define RENAMED_NCURSES
#endif
// ---------------------------------------------------------------------------
// Typedefs (some useless under NT)
typedef int gid_t; // Not defined in <sys/types.h>
typedef int uid_t;
typedef int pid_t;
typedef unsigned int umode_t;
#define S_IFLNK 0
#define S_ISLNK(x) 0
#ifndef __BORLANDC__
typedef int mode_t;
typedef unsigned int nlink_t;
#endif
#ifdef _MSC_VER
#pragma include_alias(<utime.h>, <sys/utime.h>)
#define INLINE
#define inline
// ---------------------------------------------------------------------------
// File attributes
#define S_ISLNK(x) 0
#define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
#ifndef __WATCOMC__ // Already defined in Watcom C headers
#define S_IFLNK 0010000
#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 S_ISUID 0004000
#define S_ISGID 0002000
#define S_ISVTX 0001000
#ifndef __BORLANDC__
#define S_ISBLK( m ) 0 /* Some of these are not actual values*/
#define S_IFBLK 0010000 /* but don't worry, these are yet not possible on NT */
#define S_ISFIFO(m) 0
#define S_ISBLK(x) 0
#define S_IRWXU 0000700
#define S_IRUSR 0000400
#define S_IWUSR 0000200
#define S_IXUSR 0000100
#define S_IFIFO _S_IFIFO /* pipe */
#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 S_ISCHR( m ) (((m) & S_IFMT) == S_IFCHR)
#define S_ISDIR( m ) (((m) & S_IFMT) == S_IFDIR)
#define S_ISREG( m ) (((m) & S_IFMT) == S_IFREG)
#define S_ISFIFO( m ) (((m) & S_IFMT) == S_IFIFO)
/* FIXME: is this definition correct? */
#define R_OK 4
/* Missing mask definition */
#define O_ACCMODE 0003
#endif /* not __BORLANDC__ */
/* Symbolic constants for the access() function */
#define R_OK 4 /* Test for read permission */
#define W_OK 2 /* Test for write permission */
#define X_OK 1 /* Test for execute permission */
#define F_OK 0 /* Test for existence of file */
/* Missing Errno definitions */
#define ELOOP 40 /* Too many symbolic links encountered */
#endif /* not __WATCOMC__ */
// ---------------------------------------------------------------------------
// Inline definitions
// Pipes
#define pipe(p) _pipe(p, 4096, 0x8000 /* O_BINARY */)
#define popen _popen
#define pclose _pclose
#define pipe(p) _pipe(p, 4096, 0x8000 /*_O_BINARY*/)
#endif //__CONFIG_HPP
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
typedef int pid_t;
#endif /* __BORLANDC__ */
#endif /* __CONFIG_H */

View File

@ -87,5 +87,6 @@ int closedir (DIR *dd_dir)
{
FindClose(dd_dir->d_handle);
free (dd_dir);
return 1;
}

View File

@ -532,13 +532,44 @@ int gettimeofday (struct timeval* tvp, void *p)
// FAKE funcs
/* lstat - Because of symlinks in Unix, stat will give info
on the file pointed to and lstat on the symlink itself.
We have no such a difference/trouble.
*/
int lstat (const char* pathname, struct stat *buffer)
int
look_for_exe(const char* pathname)
{
return stat (pathname, buffer);
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 ()

View File

@ -29,7 +29,7 @@ OBJS_DIR=debug
EXTRA_MC_SRCS=
SPECIFIC_DEFINES=
SPECIFIC_MC_CFLAGS=-v -y $(MC_MISC_CFLAGS)
SPECIFIC_MC_LFLAGS_EXTRA=-v -y -lm -D__MT__
SPECIFIC_MC_LFLAGS_EXTRA=-lv
SPECIFIC_SLANG_CFLAGS=$(SPECIFIC_MC_CFLAGS)
SPECIFIC_MCEDIT_CFLAGS=$(SPECIFIC_MC_CFLAGS) -I../edit -I../src
RC_DEFINES=-D_DEBUG
@ -38,8 +38,8 @@ else
OBJS_DIR=release
EXTRA_MC_SRCS=
SPECIFIC_DEFINES=
SPECIFIC_MC_CFLAGS=$(MC_MISC_CFLAGS)
SPECIFIC_MC_LFLAGS_EXTRA=-D__MT__
SPECIFIC_MC_CFLAGS=-O2 $(MC_MISC_CFLAGS)
SPECIFIC_MC_LFLAGS_EXTRA=
SPECIFIC_SLANG_CFLAGS=$(SPECIFIC_MC_CFLAGS)
SPECIFIC_MCEDIT_CFLAGS=$(SPECIFIC_MC_CFLAGS) -I../edit -I../src
RC_DEFINES=-DRELEASE=$(RELEASE)
@ -55,4 +55,4 @@ SPECIFIC_MC_LFLAGS= \
$(SPECIFIC_MC_LFLAGS_EXTRA)
$(MC_EXE): $(MC_RES) $(OBJS) $(MCEDIT_OBJS) $(SLANG_OBJS)
$(LINK) $(EXE_PLACE)$(MC_EXE) $(MC_LIBS) $(SPECIFIC_MC_LFLAGS) $+
$(LINK) $(EXE_PLACE)$(MC_EXE) $(SPECIFIC_MC_LFLAGS) $+ $(MC_LIBS)

View File

@ -111,7 +111,6 @@ SRCS= $(EXTRA_MC_SRCS) \
dirhist.c \
main.c \
popt.c \
mouse.c \
text.c \
screen.c

View File

@ -259,7 +259,7 @@ static void init_chmod (void)
}
}
static int stat_file (char *filename, struct stat *st)
int stat_file (char *filename, struct stat *st)
{
HFILE fHandle = 0L;
ULONG fInfoLevel = 1; /* 1st Level Info: Standard attributs */
@ -279,7 +279,7 @@ static int stat_file (char *filename, struct stat *st)
(PEAOP2) NULL);
if (rc != 0) {
return 0;
} /* endif */
}
rc = DosQueryFileInfo(fHandle, fInfoLevel, &fInfoBuf, fInfoBufSize);
DosClose(fHandle);
@ -287,7 +287,7 @@ static int stat_file (char *filename, struct stat *st)
return 0; /* error ! */
} else {
st->st_mode = fInfoBuf.attrFile;
} /* endif */
}
if (st->st_mode & FILE_DIRECTORY)
return 0;
@ -329,13 +329,13 @@ static int os2_chmod (char *filename, ULONG st)
0L);
if (rc != 0) {
return rc;
} /* endif */
}
rc = DosQueryFileInfo(fHandle, fInfoLevel, &fInfoBuf, fInfoBufSize);
if (rc!=0) {
DosClose(fHandle);
return rc;
} /* endif */
}
fInfoBuf.attrFile = st;
rc = DosSetFileInfo(fHandle, fInfoLevel, &fInfoBuf, fInfoBufSize);
rc = DosClose(fHandle);
@ -375,7 +375,7 @@ static void mk_chmod (char *filename, ULONG st)
rc = chmod(filename, fileMode);
// Then set the other flags
os2_chmod(filename, st);
} /* endif */
}
return;
}

View File

@ -28,7 +28,7 @@
- Typedefs
- etc.
****************************************************************************/
#ifndef __CONFIG_H //Prevent multiple includes
#ifndef __CONFIG_H
#define __CONFIG_H
#ifndef __BORLANDC__
@ -53,18 +53,13 @@
#define FLOAT_TYPE
#define MIDNIGHT
// ---------------------------------------------------------------------------
// Headers
#define STDC_HEADERS
#define HAVE_STDLIB_H
#define HAVE_STRING_H
#define HAVE_DIRENT_H
#define HAVE_LIMITS_H
#define HAVE_FCNTL_H
#define NO_UNISTD_H
// ---------------------------------------------------------------------------
// "Standard" Library
#define HAVE_MEMSET
#define HAVE_MEMCHR
#define HAVE_MEMCPY
@ -76,11 +71,8 @@
#define REGEX_MALLOC
#define NO_TERM
#define NO_INFOMOUNT
// ---------------------------------------------------------------------------
// Windowing library
#if !defined(HAVE_SLANG) && !defined (USE_NCURSES)
#define HAVE_SLANG
#endif
@ -89,92 +81,41 @@
#define RENAMED_NCURSES
#endif
// ---------------------------------------------------------------------------
// Typedefs (some useless under NT)
#ifndef __EMX__
typedef int gid_t; // Not defined in <sys/types.h>
typedef int uid_t;
typedef int pid_t;
#endif
typedef unsigned int umode_t;
#ifndef __BORLANDC__
typedef int mode_t;
typedef unsigned int nlink_t;
#endif
#define S_IFLNK 0
#define S_ISLNK(x) 0
#ifdef __EMX__
#define S_IFBLK 0
#define S_ISBLK(x) 0
#endif /* __EMX__ */
#ifdef __BORLANDC__
#define INLINE
#define inline
// ---------------------------------------------------------------------------
// File attributes
#define S_ISLNK(x) 0
#ifndef __WATCOMC__ // Already defined in Watcom C headers
#define S_IFLNK 0010000
#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 S_ISUID 0004000
#define S_ISGID 0002000
#define S_ISVTX 0001000
/* FIXME: is this definition correct? */
#define R_OK 4
#ifndef __BORLANDC__
#define S_ISBLK( m ) 0 /* Some of these are not actual values*/
#define S_IFBLK 0010000 /* but don't worry, these are yet not possible on NT */
#define S_IRWXU 0000700
#define S_IRUSR 0000400
#define S_IWUSR 0000200
#define S_IXUSR 0000100
#define S_IFIFO _S_IFIFO /* pipe */
#define S_ISCHR( m ) (((m) & S_IFMT) == S_IFCHR)
#define S_ISDIR( m ) (((m) & S_IFMT) == S_IFDIR)
#define S_ISREG( m ) (((m) & S_IFMT) == S_IFREG)
#define S_ISFIFO( m ) (((m) & S_IFMT) == S_IFIFO)
/* Missing mask definition */
#define O_ACCMODE 0003
#endif /* not __BORLANDC__ */
/* Symbolic constants for the access() function */
#define R_OK 4 /* Test for read permission */
#define W_OK 2 /* Test for write permission */
#define X_OK 1 /* Test for execute permission */
#define F_OK 0 /* Test for existence of file */
/* Missing Errno definitions */
#define ELOOP 40 /* Too many symbolic links encountered */
#endif /* not __WATCOMC__ */
// ---------------------------------------------------------------------------
// Inline definitions
// Pipes
#ifndef __EMX__
#define popen _popen
#define pclose _pclose
#define pipe(p) _pipe(p, 4096, 0x8000 /*_O_BINARY*/)
#endif
#define sleep _sleep
#ifndef MAX_PATH
# define MAX_PATH 260
#endif
typedef int pid_t;
#endif //__CONFIG_H
#endif /* __BORLANDC__ */
#endif /* __CONFIG_H */

View File

@ -1,4 +1,3 @@
/* Client interface for General purpose OS/2 console save/restore server.
/* 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:
@ -40,7 +39,7 @@
#include "win.h"
#include "cons.saver.h"
extern signed char console_flag = 1;
signed char console_flag = 1;
static unsigned char *scr_buffer;
static unsigned char *pointer;
@ -73,7 +72,7 @@ void show_console_contents (int starty, unsigned char begin_line, unsigned char
pointer = scr_buffer;
for (z=0; z<(begin_line * col); z++) {
pointer++; pointer++;
} /* endfor */
}
n = (end_line - begin_line + 1) * col;
VioWrtCellStr((PCH) pointer, (USHORT) n, begin_line, 0, 0);
return; /* .ado */
@ -108,9 +107,8 @@ void handle_console (unsigned char action)
/* This is not possible, but if we are here, just save the screen */
handle_console(CONSOLE_SAVE);
break;
} /* endswitch */
}
return; /* .ado */
}
#endif // !__os2__

View File

@ -52,7 +52,7 @@ DIR *opendir (const char * a_dir)
free(dd_dir);
return NULL;
break;
} /* endswitch */
}
dd_dir->d_attr = FindBuffer.attrFile;
/* dd_dir->d_attr = (wfd.dwFileAttributes == FILE_ATTRIBUTE_NORMAL)
? 0 : wfd.dwFileAttributes; */
@ -100,7 +100,7 @@ DIR *readdir( DIR * dd_dir)
errno = EINVAL;
return NULL;
break;
} /* endswitch */
}
/* dd_dir->d_attr = (wfd.dwFileAttributes == FILE_ATTRIBUTE_NORMAL)
? 0 : wfd.dwFileAttributes; */
/* #define FILE_NORMAL 0x0000
@ -123,7 +123,7 @@ int closedir (DIR *dd_dir)
{
if (dd_dir->d_handle != 0xFFFF) {
DosFindClose(dd_dir->d_handle);
} /* endif */
}
free (dd_dir);
return 1;
}

View File

@ -58,12 +58,12 @@ void drive_cmd_a(WPanel *p)
if (p == this_panel) {
if (get_current_type() != view_listing) {
return;
} /* endif */
}
} else {
if (get_other_type() != view_listing) {
return;
} /* endif */
} /* endif */
}
}
drive_cmd();
}
@ -75,12 +75,12 @@ void drive_cmd_b(WPanel *p)
if (p == this_panel) {
if (get_current_type() != view_listing) {
return;
} /* endif */
}
} else {
if (get_other_type() != view_listing) {
return;
} /* endif */
} /* endif */
}
}
drive_cmd();
}
@ -122,15 +122,15 @@ static void drive_cmd()
if (rc != NO_ERROR) {
message(0, " ERROR ", " Internal Error with drive_cmd ");
return;
} /* endif */
}
j = 0;
for (i=0; i < 26; i++) {
if ( (uDriveMap<<(31-i)) >> 31) {
sDrvs[j++] = (char) ((int) 'A' + i);
nDrivesAvail++;
} /* endif */
} /* endfor */
}
}
/* Create Dialog */
do_refresh ();
@ -210,7 +210,7 @@ static void drive_cmd()
this_panel->total = 0;
show_dir(this_panel);
reread_cmd();
} /* endif */
}
// rc = DosSetDefaultDisk(uDriveNum);
}
}

View File

@ -241,7 +241,7 @@ int get_key_code (int no_delay)
inp_ch = SLang_input_pending(0);
if (inp_ch == 0) {
return 0;
} /* endif */
}
}
/* .ado: I don't know what these codes mean: */
@ -259,7 +259,7 @@ int get_key_code (int no_delay)
/* .ado: We have already the key-code */
if (no_delay) {
return (VKtoCurses(inp_ch));
} /* endif */
}
do {
inp_ch = SLang_getkey();
@ -299,7 +299,7 @@ static int VKtoCurses (int a_vkc)
if (ctrlState) {
// CTRL pressed
rtnCode = XCTRL(asciiCode);
} /* endif */
}
if (altState) {
// ALT pressed
@ -311,8 +311,8 @@ static int VKtoCurses (int a_vkc)
// With the normal ALT key, the asciiCode will always be zero.
if (asciiCode) {
return asciiCode;
} /* endif */
} /* endif */
}
}
// Scan Movement codes
if (asciiCode == 0) {
@ -320,7 +320,7 @@ static int VKtoCurses (int a_vkc)
for (i=0; movement[i].vkcode != 0 || movement[i].key_code != 0; i++)
if (scanCode == movement[i].vkcode)
return (movement[i].key_code);
} /* endif */
}
if (asciiCode == 0) {
// Function-key detected
@ -332,12 +332,12 @@ static int VKtoCurses (int a_vkc)
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);
} /* endif */
} /* endif */
}
}
if (asciiCode == 0x0d) {
return '\n';
} /* endif */
}
return rtnCode;
}
@ -372,16 +372,6 @@ int get_event (Gpm_Event *event, int redo_event, int block)
vfs_timeout_handler ();
/* Repeat if using mouse */
#ifdef HAVE_SLANG
while ((xmouse_flag) && !pending_keys)
{
// SLms_GetEvent (event);
*event = evSaved_Event;
}
#endif
c = block ? getch_with_delay () : get_key_code (1);
if (!c) { /* Code is 0, so this is a Control key or mouse event */
#ifdef HAVE_SLANG

View File

@ -139,7 +139,7 @@ StartWindowsProg (char *name, SHORT type)
default:
pDetails.progt.progc = PROG_31_ENHSEAMLESSCOMMON ;
break;
} /* endswitch */
}
WinStartApp(NULLHANDLE,
&pDetails,
NULL,
@ -151,7 +151,7 @@ StartWindowsProg (char *name, SHORT type)
static int
os2_system (int as_shell_command, const char *shell, const char *command, const char *parm);
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
@ -186,11 +186,11 @@ my_system (int as_shell_command, const char *shell, const char *command)
length--;
} else
break;
} /* endfor */
}
if (i==-1) {
/* only blanks */
return -1;
} /* endif */
}
if (parm = strchr(temp, (char) ' ')) {
*parm = (char) 0;
parm++;
@ -199,8 +199,8 @@ my_system (int as_shell_command, const char *shell, const char *command)
} else {
/* command is NULL */
cmd = parm = NULL;
} /* endif */
} /* endif */
}
}
/* .ado: Konvertierung wenn shell <> get_default_shell */
os2_system (as_shell_command, sh, cmd, parm);
}
@ -223,19 +223,19 @@ ux_startp (const char *shell, const char *command, const char *parm)
"/c",
(char *) command,
(char *) 0);
} /* endif */
}
return 0;
}
static int
os2_system (int as_shell_command, const char *shell, const char *command, const char *parm)
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[MAX_PATH * 2 + 1]; /* For DosSearchPath */
UCHAR searchResult[MC_MAXPATHLEN * 2 + 1]; /* For DosSearchPath */
char *cmdString;
char *postFix[3];
@ -278,11 +278,11 @@ os2_system (int as_shell_command, const char *shell, const char *command, const
if (command[i-1] == ' ') {
/* The user has used ALT-RETURN */
i--;
} /* endif */
}
cmdString = (char *) malloc(i+1);
for (j=0; j<i; j++) {
cmdString[j] = command[j];
} /* endfor */
}
cmdString[j] = (char) 0;
if ((i < 5) || ((i > 4) && (cmdString[i-4]) != '.')) {
@ -298,7 +298,7 @@ os2_system (int as_shell_command, const char *shell, const char *command, const
line,
searchResult,
sizeof(searchResult));
} /* endfor */
}
free (line);
} else {
/* Just search */
@ -307,12 +307,12 @@ os2_system (int as_shell_command, const char *shell, const char *command, const
cmdString,
searchResult,
sizeof(searchResult));
} /* endif */
}
free(cmdString);
if (rc != 0) {
/* Internal command or the program was written with absolut path */
return ux_startp(shell, command, parm);
} /* endif */
}
/* Application to be started */
StartData.PgmName = searchResult;
@ -324,28 +324,28 @@ os2_system (int as_shell_command, const char *shell, const char *command, const
/* Window API */
StartData.SessionType = PROG_PM;
return DosStartSession(&StartData, &SessionID, &pid);
} /* endif */
}
if ((AppType & 0x00000007) == FAPPTYP_WINDOWCOMPAT) {
/* Window compat */
return ux_startp(shell, command, parm);
} /* endif */
}
if (AppType & 0x0000ffff & FAPPTYP_DOS) {
/* PC/DOS Format */
StartData.SessionType = PROG_WINDOWEDVDM;
return DosStartSession(&StartData, &SessionID, &pid);
} /* endif */
}
if (AppType & 0x0000ffff & FAPPTYP_WINDOWSREAL) {
/* Windows real mode app */
return StartWindowsProg(searchResult, 0);
} /* endif */
}
if (AppType & 0x0000ffff & FAPPTYP_WINDOWSPROT) {
/* Windows Protect mode app*/
return StartWindowsProg(searchResult, 1);
} /* endif */
}
if (AppType & 0x0000ffff & FAPPTYP_WINDOWSPROT31) {
/* Windows 3.1 Protect mode app*/
return StartWindowsProg(searchResult, 2);
} /* endif */
}
rc = DosStartSession(&StartData, &SessionID, &pid) ;
} else {
/* It's not a known exe type or it's a CMD/BAT file */
@ -358,8 +358,8 @@ os2_system (int as_shell_command, const char *shell, const char *command, const
rc = DosStartSession(&StartData, &SessionID, &pid) ;
} else {
rc = ux_startp (shell, command, parm);
} /* endif */
} /* endif */
}
}
return rc;
}
@ -368,14 +368,6 @@ char *tilde_expand (char *directory)
return strdup (directory);
}
#ifndef __EMX__
void
sleep(unsigned long dwMiliSecs)
{
DosSleep(dwMiliSecs);
}
#endif
/* Canonicalize path, and return a new path. Do everything in situ.
The new path differs from path in:
@ -527,7 +519,7 @@ my_statfs (struct my_statfs *myfs_stats, char *path)
} else {
myfs_stats->typename = (char *) malloc(13);
strcpy(myfs_stats->typename, "Other Device");
} /* endif */
}
free(pBuf);
free(pFsInfo);
@ -565,33 +557,30 @@ look_for_exe(const char* pathname)
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;
} /* endif */
} /* endif */
}
}
return 0;
}
/* lstat - Because of symlinks in Unix, stat will give info
* on the file pointed to and lstat on the symlink itself.
* We have no such a difference/trouble.
*/
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;
}
if (!look_for_exe(pathname)) {
buffer->st_mode &= !S_IXUSR & !S_IXGRP & !S_IXOTH;
}
}
} /* endif */
}
#endif
return rc;
}
@ -693,35 +682,6 @@ geteuid(void)
return 0;
}
#ifndef __EMX__
char *
getcwd(char *buffer, int size)
{
APIRET rc;
ULONG lgh = size;
ULONG uDriveNum = 0; /* Drive number (A=1, B=2 ...) */
ULONG uDriveMap = 0; /* Mapping */
CHAR p[4] = "A:\\";
char *tmpBuf;
rc = DosQueryCurrentDisk(&uDriveNum, &uDriveMap);
p[0] = (char) (uDriveNum + (int) 'A' - 1);
rc = DosQueryCurrentDir(0L,
(PBYTE) buffer,
&lgh);
if (rc == NO_ERROR) {
tmpBuf = (char *) malloc(strlen(buffer) + 1);
strcpy(tmpBuf, buffer);
strcpy(buffer, p);
strcat(buffer, tmpBuf);
free(tmpBuf);
return strdup(buffer);
} else {
return NULL;
} /* endif */
}
#endif
int
mc_chdir(char *pathname)
@ -737,11 +697,11 @@ mc_chdir(char *pathname)
if (lgh > 1) {
if (pathname[1] == ':') {
ret = DosSetDefaultDisk(toupper(pathname[0]) - 'A' + 1);
} /* endif */
} /* endif */
}
}
/* After that, set the current dir! */
ret = DosSetCurrentDir(pathname);
} /* endif */
}
return ret;
}
@ -775,7 +735,7 @@ conv_os2_unx_rc(int os2rc)
default:
errCode = EINVAL;
break;
} /* endswitch */
}
return errCode;
}
@ -794,7 +754,7 @@ mc_unlink(char *pathName)
rc = DosDelete(pathName);
if (!rc) {
return 0;
} /* endif */
}
if (rc == ERROR_ACCESS_DENIED) {
chmod(pathName, (S_IREAD|S_IWRITE));
rc = DosDelete(pathName);
@ -803,11 +763,11 @@ mc_unlink(char *pathName)
return -1;
} else {
return 0;
} /* endif */
}
} else {
errno = conv_os2_unx_rc(rc) ;
return -1;
} /* endif */
}
}
int
@ -845,7 +805,7 @@ get_default_editor (void)
char *tmp;
APIRET rc;
char pathValue[5] = "PATH";
UCHAR searchResult[MAX_PATH + 1];
UCHAR searchResult[MC_MAXPATHLEN + 1];
/* EPM is not always be installed */
rc = DosSearchPath((SEARCH_IGNORENETERRS | SEARCH_ENVIRONMENT | SEARCH_CUR_DIRECTORY),
@ -859,7 +819,7 @@ get_default_editor (void)
} else {
/* Let it be searched from my_system */
return strdup("epm.exe");
} /* endif */
}
}
/* get_default_shell
@ -894,7 +854,7 @@ get_mc_lib_dir ()
return "D:\\mc";
} else {
return mchome;
} /* endif */
}
}
int get_user_rights (struct stat *buf)

View File

@ -61,14 +61,6 @@
# include "tkmain.h"
#endif
#ifndef USE_NCURSES
# define ACS_MAP(x) '*'
#else
# ifndef ACS_MAP
# define ACS_MAP(x) acs_map [x]
# endif
#endif
#define MAXLINKNAME 80
#define HISTORY_SIZE 20
#define HELP_WINDOW_WIDTH 62
@ -104,6 +96,37 @@ static int inside_link_area = 0;
static int help_callback (struct Dlg_head *h, int id, int msg);
#ifdef OS2_NT
struct {
int acscode;
int pccode;
} acs2pc_table [] = {
{ 'q', 0xC4 },
{ 'x', 0xB3 },
{ 'l', 0xDA },
{ 'k', 0xBF },
{ 'm', 0xC0 },
{ 'j', 0xD9 },
{ 'a', 0xB0 },
{ 'u', 0xB4 },
{ 't', 0xC3 },
{ 'w', 0xC2 },
{ 'v', 0xC1 },
{ 'n', 0xC5 },
{ 0, 0 } };
static int acs2pc (int acscode)
{
int i;
for (i = 0; acs2pc_table[i].acscode != 0; i++)
if (acscode == acs2pc_table[i].acscode) {
return acs2pc_table[i].pccode;
}
return 0;
}
#endif
/* returns the position where text was found in the start buffer */
/* or 0 if not found */
char *search_string (char *start, char *text)
@ -424,11 +447,15 @@ static void show (Dlg_head *h, char *paint_start)
if (c == ' ' || c == '.')
addch (c);
else
#ifndef OS2_NT
#ifndef HAVE_SLANG
addch (ACS_MAP(c));
addch (acs_map [c]);
#else
SLsmg_draw_object (h->y + line + 2, h->x + col + 2, c);
SLsmg_draw_object (h->y + line + 2, h->x + col + 2, c);
#endif
#else
addch (acs2pc (c));
#endif /* OS2_NT */
} else
addch (c);
col++;