OS/2 patches so E compiles on Os/2 and works :)

SVN revision: 845
This commit is contained in:
Carsten Haitzler 1999-10-18 17:38:39 +00:00
parent 56d7ccafcc
commit 1efe615a53
2 changed files with 53 additions and 1 deletions

View File

@ -249,7 +249,11 @@ main(int argc, char **argv)
strcpy(s, docdir); strcpy(s, docdir);
strcat(s, "/"); strcat(s, "/");
strcat(s, docfile); strcat(s, docfile);
#ifndef __EMX__
f = fopen(s, "r"); f = fopen(s, "r");
#else
f = fopen(s, "rt");
#endif
if (!f) if (!f)
{ {
printf("Edoc_dir %s does not contain a %s file\n", docdir, docfile); printf("Edoc_dir %s does not contain a %s file\n", docdir, docfile);

View File

@ -22,6 +22,11 @@
* */ * */
#include "dox.h" #include "dox.h"
#ifdef __EMX__
#define chdir _chdir2
#define getcwd _getcwd2
#endif
char * char *
FileExtension(char *file) FileExtension(char *file)
{ {
@ -348,6 +353,7 @@ username(int uid)
static int usr_uid = -1; static int usr_uid = -1;
static char *usr_s = NULL; static char *usr_s = NULL;
char *s; char *s;
#ifndef __EMX__
struct passwd *pwd; struct passwd *pwd;
if (usr_uid < 0) if (usr_uid < 0)
@ -362,6 +368,10 @@ username(int uid)
usr_s = strdup(s); usr_s = strdup(s);
return (s); return (s);
} }
#else
if ((s = getenv("USER")) != NULL)
return (s);
#endif
return (strdup("unknown")); return (strdup("unknown"));
} }
@ -371,6 +381,7 @@ homedir(int uid)
static int usr_uid = -1; static int usr_uid = -1;
static char *usr_s = NULL; static char *usr_s = NULL;
char *s; char *s;
#ifndef __EMX__
struct passwd *pwd; struct passwd *pwd;
if (usr_uid < 0) if (usr_uid < 0)
@ -385,6 +396,12 @@ homedir(int uid)
usr_s = strdup(s); usr_s = strdup(s);
return (s); return (s);
} }
#else
if ((s = getenv("HOME")) != NULL)
return (s);
else if ((s = getenv("TMP")) != NULL)
return (s);
#endif
return (strdup("/tmp")); return (strdup("/tmp"));
} }
@ -394,6 +411,7 @@ usershell(int uid)
static int usr_uid = -1; static int usr_uid = -1;
static char *usr_s = NULL; static char *usr_s = NULL;
char *s; char *s;
#ifndef __EMX__
struct passwd *pwd; struct passwd *pwd;
if (usr_uid < 0) if (usr_uid < 0)
@ -409,6 +427,9 @@ usershell(int uid)
return (s); return (s);
} }
return (strdup("/bin/sh")); return (strdup("/bin/sh"));
#else
return (strdup("sh.exe"));
#endif
} }
char * char *
@ -675,7 +696,11 @@ pathtoexec(char *file)
char *s; char *s;
int len, exelen; int len, exelen;
#ifndef __EMX__
if (file[0] == '/') if (file[0] == '/')
#else
if (_fnisabs(file))
#endif
{ {
if (canexec(file)) if (canexec(file))
return (strdup(file)); return (strdup(file));
@ -687,7 +712,11 @@ pathtoexec(char *file)
return (NULL); return (NULL);
cp = p; cp = p;
exelen = strlen(file); exelen = strlen(file);
#ifndef __EMX__
while ((ep = strchr(cp, ':'))) while ((ep = strchr(cp, ':')))
#else
while ((ep = strchr(cp, ';')))
#endif
{ {
len = ep - cp; len = ep - cp;
s = malloc(len + 1); s = malloc(len + 1);
@ -696,6 +725,9 @@ pathtoexec(char *file)
strncpy(s, cp, len); strncpy(s, cp, len);
s[len] = 0; s[len] = 0;
s = realloc(s, len + 2 + exelen); s = realloc(s, len + 2 + exelen);
#ifdef __EMX__
if (s[len-1] != '/')
#endif
strcat(s, "/"); strcat(s, "/");
strcat(s, file); strcat(s, file);
if (canexec(s)) if (canexec(s))
@ -711,6 +743,9 @@ pathtoexec(char *file)
strncpy(s, cp, len); strncpy(s, cp, len);
s[len] = 0; s[len] = 0;
s = realloc(s, len + 2 + exelen); s = realloc(s, len + 2 + exelen);
#ifdef __EMX__
if (s[len-1] != '/')
#endif
strcat(s, "/"); strcat(s, "/");
strcat(s, file); strcat(s, file);
if (canexec(s)) if (canexec(s))
@ -726,8 +761,11 @@ pathtofile(char *file)
char *p, *cp, *ep; char *p, *cp, *ep;
char *s; char *s;
int len, exelen; int len, exelen;
#ifndef __EMX__
if (file[0] == '/') if (file[0] == '/')
#else
if (_fnisabs(file))
#endif
{ {
if (exists(file)) if (exists(file))
return (strdup(file)); return (strdup(file));
@ -739,7 +777,11 @@ pathtofile(char *file)
return (NULL); return (NULL);
cp = p; cp = p;
exelen = strlen(file); exelen = strlen(file);
#ifndef __EMX__
while ((ep = strchr(cp, ':'))) while ((ep = strchr(cp, ':')))
#else
while ((ep = strchr(cp, ';')))
#endif
{ {
len = ep - cp; len = ep - cp;
s = malloc(len + 1); s = malloc(len + 1);
@ -748,6 +790,9 @@ pathtofile(char *file)
strncpy(s, cp, len); strncpy(s, cp, len);
s[len] = 0; s[len] = 0;
s = realloc(s, len + 2 + exelen); s = realloc(s, len + 2 + exelen);
#ifdef __EMX__
if (s[len-1] != '/')
#endif
strcat(s, "/"); strcat(s, "/");
strcat(s, file); strcat(s, file);
if (exists(s)) if (exists(s))
@ -763,6 +808,9 @@ pathtofile(char *file)
strncpy(s, cp, len); strncpy(s, cp, len);
s[len] = 0; s[len] = 0;
s = realloc(s, len + 2 + exelen); s = realloc(s, len + 2 + exelen);
#ifdef __EMX__
if (s[len-1] != '/')
#endif
strcat(s, "/"); strcat(s, "/");
strcat(s, file); strcat(s, file);
if (exists(s)) if (exists(s))