mirror of
https://github.com/digarok/gsplus.git
synced 2024-11-27 12:50:04 +00:00
cleanup to build with MSVC.
This commit is contained in:
parent
b0764fb93c
commit
1700285fd2
@ -12,6 +12,7 @@ endif()
|
||||
if(MSVC)
|
||||
include_directories(include/msvc)
|
||||
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
|
||||
add_compile_options(/wd4996)
|
||||
endif()
|
||||
|
||||
# add pcap headers for win32. assume os/x, linux, etc, already have them.
|
||||
|
@ -19,9 +19,12 @@
|
||||
#endif
|
||||
|
||||
#if defined _MSC_VER
|
||||
#include <direct.h>
|
||||
#define snprintf _snprintf
|
||||
|
||||
typedef unsigned int mode_t;
|
||||
|
||||
#define strcasecmp stricmp
|
||||
#define strncasecmp strnicmp
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -1,14 +1,9 @@
|
||||
#define _BSD_SOURCE
|
||||
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <dirent.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <libgen.h>
|
||||
|
||||
#include "defc.h"
|
||||
#include "gsos.h"
|
||||
@ -18,6 +13,12 @@
|
||||
#include <Windows.h>
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define strcasecmp stricmp
|
||||
#define strncasecmp strnicmp
|
||||
#endif
|
||||
|
||||
|
||||
#include "host_common.h"
|
||||
|
||||
|
||||
@ -149,59 +150,6 @@ void host_text_to_merlin(byte *buffer, size_t size) {
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* error remapping.
|
||||
* NOTE - GS/OS errors are a superset of P8 errors
|
||||
*/
|
||||
|
||||
static word32 enoent(const char *path) {
|
||||
/*
|
||||
some op on path return ENOENT. check if it's
|
||||
fileNotFound or pathNotFound
|
||||
*/
|
||||
char *p = (char *)path;
|
||||
for(;;) {
|
||||
struct stat st;
|
||||
p = dirname(p);
|
||||
if (p == NULL) break;
|
||||
if (p[0] == '.' && p[1] == 0) break;
|
||||
if (p[0] == '/' && p[1] == 0) break;
|
||||
if (stat(p, &st) < 0) return pathNotFound;
|
||||
}
|
||||
return fileNotFound;
|
||||
}
|
||||
|
||||
word32 host_map_errno(int xerrno) {
|
||||
switch(xerrno) {
|
||||
case 0: return 0;
|
||||
case EBADF:
|
||||
return invalidAccess;
|
||||
#ifdef EDQUOT
|
||||
case EDQUOT:
|
||||
#endif
|
||||
case EFBIG:
|
||||
return volumeFull;
|
||||
case ENOENT:
|
||||
return fileNotFound;
|
||||
case ENOTDIR:
|
||||
return pathNotFound;
|
||||
case ENOMEM:
|
||||
return outOfMem;
|
||||
case EEXIST:
|
||||
return dupPathname;
|
||||
case ENOTEMPTY:
|
||||
return invalidAccess;
|
||||
|
||||
default:
|
||||
return drvrIOError;
|
||||
}
|
||||
}
|
||||
|
||||
word32 host_map_errno_path(int xerrno, const char *path) {
|
||||
if (xerrno == ENOENT) return enoent(path);
|
||||
return host_map_errno(xerrno);
|
||||
}
|
||||
|
||||
const char *host_error_name(word16 error) {
|
||||
static char *errors[] = {
|
||||
"",
|
||||
|
@ -26,6 +26,11 @@
|
||||
|
||||
#include "host_common.h"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define strcasecmp stricmp
|
||||
#define strncasecmp strnicmp
|
||||
#endif
|
||||
|
||||
|
||||
#define LEVEL 0xBFD8 // current file level
|
||||
#define DEVNUM 0xBF30 // last slot / drive
|
||||
|
@ -8,10 +8,15 @@
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/stat.h>
|
||||
#include "options.h"
|
||||
#include "glog.h"
|
||||
#include "defc.h"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
|
||||
#endif
|
||||
|
||||
// config is parsed in config.c :: config_parse_config_gsplus_file()
|
||||
// cli is parsed here. would be nice to reuse some code
|
||||
|
||||
|
@ -7,6 +7,8 @@
|
||||
#include <string.h>
|
||||
#include <sys/time.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
#include <libgen.h>
|
||||
|
||||
#if defined(__APPLE__)
|
||||
#include <sys/xattr.h>
|
||||
@ -510,3 +512,58 @@ unsigned host_storage_type(const char *path, word16 *error) {
|
||||
*error = badStoreType;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* error remapping.
|
||||
* NOTE - GS/OS errors are a superset of P8 errors
|
||||
*/
|
||||
|
||||
static word32 enoent(const char *path) {
|
||||
/*
|
||||
some op on path return ENOENT. check if it's
|
||||
fileNotFound or pathNotFound
|
||||
*/
|
||||
char *p = (char *)path;
|
||||
for(;;) {
|
||||
struct stat st;
|
||||
p = dirname(p);
|
||||
if (p == NULL) break;
|
||||
if (p[0] == '.' && p[1] == 0) break;
|
||||
if (p[0] == '/' && p[1] == 0) break;
|
||||
if (stat(p, &st) < 0) return pathNotFound;
|
||||
}
|
||||
return fileNotFound;
|
||||
}
|
||||
|
||||
word32 host_map_errno(int xerrno) {
|
||||
switch(xerrno) {
|
||||
case 0: return 0;
|
||||
case EBADF:
|
||||
return invalidAccess;
|
||||
#ifdef EDQUOT
|
||||
case EDQUOT:
|
||||
#endif
|
||||
case EFBIG:
|
||||
return volumeFull;
|
||||
case ENOENT:
|
||||
return fileNotFound;
|
||||
case ENOTDIR:
|
||||
return pathNotFound;
|
||||
case ENOMEM:
|
||||
return outOfMem;
|
||||
case EEXIST:
|
||||
return dupPathname;
|
||||
case ENOTEMPTY:
|
||||
return invalidAccess;
|
||||
|
||||
default:
|
||||
return drvrIOError;
|
||||
}
|
||||
}
|
||||
|
||||
word32 host_map_errno_path(int xerrno, const char *path) {
|
||||
if (xerrno == ENOENT) return enoent(path);
|
||||
return host_map_errno(xerrno);
|
||||
}
|
||||
|
||||
|
@ -11,6 +11,11 @@
|
||||
|
||||
#include "host_common.h"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define strcasecmp stricmp
|
||||
#define strncasecmp strnicmp
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
void afp_init(struct AFP_Info *info, word16 file_type, word32 aux_type) {
|
||||
@ -66,7 +71,7 @@ void afp_synchronize(struct AFP_Info *info, int preference) {
|
||||
|
||||
|
||||
|
||||
static DWORD root_file_id[3] = {};
|
||||
static DWORD root_file_id[3] = { 0 };
|
||||
|
||||
unsigned host_startup(void) {
|
||||
|
||||
@ -97,10 +102,8 @@ unsigned host_startup(void) {
|
||||
|
||||
if (!(fbi.FileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
|
||||
fprintf(stderr, "%s is not a directory\n", host_root);
|
||||
CloseHandle(h);
|
||||
return invalidFSTop;
|
||||
}
|
||||
CloseHandle(h);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -231,8 +234,8 @@ FILETIME host_get_date_time(word32 ptr) {
|
||||
|
||||
|
||||
TzSpecificLocalTimeToSystemTime(NULL, &tmLocal, &tmUTC);
|
||||
if (!SystemTimeToFileTime(&tmUTC, &utc)) utc =(FILETIME){0, 0};
|
||||
|
||||
if (!SystemTimeToFileTime(&tmUTC, &utc)) memset(&utc, 0, sizeof(utc));
|
||||
|
||||
return utc;
|
||||
}
|
||||
|
||||
@ -249,6 +252,7 @@ FILETIME host_get_date_time_rec(word32 ptr) {
|
||||
SYSTEMTIME tmUTC;
|
||||
memset(&tmLocal, 0, sizeof(tmLocal));
|
||||
memset(&tmUTC, 0, sizeof(tmUTC));
|
||||
memset(&utc, 0, sizeof(utc));
|
||||
|
||||
tmLocal.wSecond = buffer[0];
|
||||
tmLocal.wMinute = buffer[1];
|
||||
@ -258,7 +262,7 @@ FILETIME host_get_date_time_rec(word32 ptr) {
|
||||
tmLocal.wMonth = buffer[5] + 1;
|
||||
|
||||
TzSpecificLocalTimeToSystemTime(NULL, &tmLocal, &tmUTC);
|
||||
if (!SystemTimeToFileTime(&tmUTC, &utc)) utc =(FILETIME){0, 0};
|
||||
if (!SystemTimeToFileTime(&tmUTC, &utc)) memset(&utc, 0, sizeof(utc));
|
||||
|
||||
return utc;
|
||||
}
|
||||
|
@ -20,6 +20,12 @@
|
||||
|
||||
#include "host_common.h"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define strcasecmp stricmp
|
||||
#define strncasecmp strnicmp
|
||||
#endif
|
||||
|
||||
|
||||
extern Engine_reg engine;
|
||||
|
||||
|
||||
@ -62,7 +68,7 @@ static struct directory *read_directory(const char *path, word16 *error);
|
||||
|
||||
#define COOKIE_BASE 0x8000
|
||||
|
||||
static word32 cookies[32] = {};
|
||||
static word32 cookies[32] = { 0 };
|
||||
|
||||
static int alloc_cookie() {
|
||||
for (int i = 0; i < 32; ++i) {
|
||||
@ -746,7 +752,7 @@ static struct directory *read_directory(const char *path, word16 *error) {
|
||||
size = sizeof(struct directory) + capacity * sizeof(char *);
|
||||
struct directory * tmp = realloc(dd, size);
|
||||
if (!tmp) {
|
||||
*error = host_map_errno(errno);
|
||||
*error = outOfMem;
|
||||
free_directory(dd);
|
||||
FindClose(h);
|
||||
return NULL;
|
||||
|
Loading…
Reference in New Issue
Block a user