mirror of
https://github.com/digarok/gsplus.git
synced 2024-06-14 18:29:40 +00:00
cleanup to build with MSVC.
This commit is contained in:
parent
b0764fb93c
commit
1700285fd2
|
@ -12,6 +12,7 @@ endif()
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
include_directories(include/msvc)
|
include_directories(include/msvc)
|
||||||
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
|
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
|
||||||
|
add_compile_options(/wd4996)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# add pcap headers for win32. assume os/x, linux, etc, already have them.
|
# add pcap headers for win32. assume os/x, linux, etc, already have them.
|
||||||
|
|
|
@ -19,9 +19,12 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined _MSC_VER
|
#if defined _MSC_VER
|
||||||
#include <direct.h>
|
|
||||||
#define snprintf _snprintf
|
|
||||||
typedef unsigned int mode_t;
|
typedef unsigned int mode_t;
|
||||||
|
|
||||||
|
#define strcasecmp stricmp
|
||||||
|
#define strncasecmp strnicmp
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,9 @@
|
||||||
#define _BSD_SOURCE
|
#define _BSD_SOURCE
|
||||||
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <dirent.h>
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <unistd.h>
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <libgen.h>
|
|
||||||
|
|
||||||
#include "defc.h"
|
#include "defc.h"
|
||||||
#include "gsos.h"
|
#include "gsos.h"
|
||||||
|
@ -18,6 +13,12 @@
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#define strcasecmp stricmp
|
||||||
|
#define strncasecmp strnicmp
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#include "host_common.h"
|
#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) {
|
const char *host_error_name(word16 error) {
|
||||||
static char *errors[] = {
|
static char *errors[] = {
|
||||||
"",
|
"",
|
||||||
|
|
|
@ -26,6 +26,11 @@
|
||||||
|
|
||||||
#include "host_common.h"
|
#include "host_common.h"
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#define strcasecmp stricmp
|
||||||
|
#define strncasecmp strnicmp
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#define LEVEL 0xBFD8 // current file level
|
#define LEVEL 0xBFD8 // current file level
|
||||||
#define DEVNUM 0xBF30 // last slot / drive
|
#define DEVNUM 0xBF30 // last slot / drive
|
||||||
|
|
|
@ -8,10 +8,15 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
#include "options.h"
|
#include "options.h"
|
||||||
#include "glog.h"
|
#include "glog.h"
|
||||||
#include "defc.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()
|
// config is parsed in config.c :: config_parse_config_gsplus_file()
|
||||||
// cli is parsed here. would be nice to reuse some code
|
// cli is parsed here. would be nice to reuse some code
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,8 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <libgen.h>
|
||||||
|
|
||||||
#if defined(__APPLE__)
|
#if defined(__APPLE__)
|
||||||
#include <sys/xattr.h>
|
#include <sys/xattr.h>
|
||||||
|
@ -510,3 +512,58 @@ unsigned host_storage_type(const char *path, word16 *error) {
|
||||||
*error = badStoreType;
|
*error = badStoreType;
|
||||||
return 0;
|
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"
|
#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) {
|
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) {
|
unsigned host_startup(void) {
|
||||||
|
|
||||||
|
@ -97,10 +102,8 @@ unsigned host_startup(void) {
|
||||||
|
|
||||||
if (!(fbi.FileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
|
if (!(fbi.FileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
|
||||||
fprintf(stderr, "%s is not a directory\n", host_root);
|
fprintf(stderr, "%s is not a directory\n", host_root);
|
||||||
CloseHandle(h);
|
|
||||||
return invalidFSTop;
|
return invalidFSTop;
|
||||||
}
|
}
|
||||||
CloseHandle(h);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -231,8 +234,8 @@ FILETIME host_get_date_time(word32 ptr) {
|
||||||
|
|
||||||
|
|
||||||
TzSpecificLocalTimeToSystemTime(NULL, &tmLocal, &tmUTC);
|
TzSpecificLocalTimeToSystemTime(NULL, &tmLocal, &tmUTC);
|
||||||
if (!SystemTimeToFileTime(&tmUTC, &utc)) utc =(FILETIME){0, 0};
|
if (!SystemTimeToFileTime(&tmUTC, &utc)) memset(&utc, 0, sizeof(utc));
|
||||||
|
|
||||||
return utc;
|
return utc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -249,6 +252,7 @@ FILETIME host_get_date_time_rec(word32 ptr) {
|
||||||
SYSTEMTIME tmUTC;
|
SYSTEMTIME tmUTC;
|
||||||
memset(&tmLocal, 0, sizeof(tmLocal));
|
memset(&tmLocal, 0, sizeof(tmLocal));
|
||||||
memset(&tmUTC, 0, sizeof(tmUTC));
|
memset(&tmUTC, 0, sizeof(tmUTC));
|
||||||
|
memset(&utc, 0, sizeof(utc));
|
||||||
|
|
||||||
tmLocal.wSecond = buffer[0];
|
tmLocal.wSecond = buffer[0];
|
||||||
tmLocal.wMinute = buffer[1];
|
tmLocal.wMinute = buffer[1];
|
||||||
|
@ -258,7 +262,7 @@ FILETIME host_get_date_time_rec(word32 ptr) {
|
||||||
tmLocal.wMonth = buffer[5] + 1;
|
tmLocal.wMonth = buffer[5] + 1;
|
||||||
|
|
||||||
TzSpecificLocalTimeToSystemTime(NULL, &tmLocal, &tmUTC);
|
TzSpecificLocalTimeToSystemTime(NULL, &tmLocal, &tmUTC);
|
||||||
if (!SystemTimeToFileTime(&tmUTC, &utc)) utc =(FILETIME){0, 0};
|
if (!SystemTimeToFileTime(&tmUTC, &utc)) memset(&utc, 0, sizeof(utc));
|
||||||
|
|
||||||
return utc;
|
return utc;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,12 @@
|
||||||
|
|
||||||
#include "host_common.h"
|
#include "host_common.h"
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#define strcasecmp stricmp
|
||||||
|
#define strncasecmp strnicmp
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
extern Engine_reg engine;
|
extern Engine_reg engine;
|
||||||
|
|
||||||
|
|
||||||
|
@ -62,7 +68,7 @@ static struct directory *read_directory(const char *path, word16 *error);
|
||||||
|
|
||||||
#define COOKIE_BASE 0x8000
|
#define COOKIE_BASE 0x8000
|
||||||
|
|
||||||
static word32 cookies[32] = {};
|
static word32 cookies[32] = { 0 };
|
||||||
|
|
||||||
static int alloc_cookie() {
|
static int alloc_cookie() {
|
||||||
for (int i = 0; i < 32; ++i) {
|
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 *);
|
size = sizeof(struct directory) + capacity * sizeof(char *);
|
||||||
struct directory * tmp = realloc(dd, size);
|
struct directory * tmp = realloc(dd, size);
|
||||||
if (!tmp) {
|
if (!tmp) {
|
||||||
*error = host_map_errno(errno);
|
*error = outOfMem;
|
||||||
free_directory(dd);
|
free_directory(dd);
|
||||||
FindClose(h);
|
FindClose(h);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user