From 55162445db4c8ea46be671c2abed4ad4e77e1dcd Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Sun, 31 Jan 2010 00:36:02 +0000 Subject: Add Windows frontend svn path=/trunk/netsurf/; revision=9940 --- utils/config.h | 26 +++++++++++++++++++++++--- utils/filename.c | 10 ++++++---- utils/useragent.c | 3 ++- utils/utils.c | 14 ++++++++++++++ utils/utils.h | 5 +++++ utils/utsname.h | 39 +++++++++++++++++++++++++++++++++++++++ 6 files changed, 89 insertions(+), 8 deletions(-) create mode 100644 utils/utsname.h (limited to 'utils') diff --git a/utils/config.h b/utils/config.h index c86770b6e..ba8d8227b 100644 --- a/utils/config.h +++ b/utils/config.h @@ -26,7 +26,7 @@ #define HAVE_STRNDUP #if defined(__FreeBSD__) || (defined(__SRV4) && defined(__sun)) || \ defined(__APPLE__) || defined(__HAIKU__) || defined(__BEOS__) \ - || defined(__OpenBSD__) + || defined(__OpenBSD__) || defined(_WIN32) /* FreeBSD and Solaris do not have this function, so * we implement it ourselves in util.c */ @@ -35,12 +35,32 @@ char *strndup(const char *s, size_t n); #endif #define HAVE_STRCASESTR -#if !(defined(_GNU_SOURCE) || defined(__NetBSD__) || defined(__OpenBSD__)) \ - || defined(riscos) || defined(__APPLE__) +#if (!(defined(_GNU_SOURCE) || defined(__NetBSD__) || defined(__OpenBSD__)) \ + || defined(riscos) || defined(__APPLE__) || defined(_WIN32)) #undef HAVE_STRCASESTR char *strcasestr(const char *haystack, const char *needle); #endif +#define HAVE_UTSNAME +#if (defined(_WIN32)) +#undef HAVE_UTSNAME +#endif + +#define HAVE_MKDIR +#if (defined(_WIN32)) +#undef HAVE_MKDIR +#endif + +#define HAVE_SIGPIPE +#if (defined(_WIN32)) +#undef HAVE_SIGPIPE +#endif + +#define HAVE_STDOUT +#if (defined(_WIN32)) +#undef HAVE_STDOUT +#endif + #define HAVE_STRCHRNUL /* For some reason, UnixLib defines this unconditionally. * Assume we're using UnixLib if building for RISC OS. */ diff --git a/utils/filename.c b/utils/filename.c index 5ec84b9c3..d4cb34521 100644 --- a/utils/filename.c +++ b/utils/filename.c @@ -32,6 +32,8 @@ #include #include #include + +#include "utils/config.h" #include "utils/filename.h" #include "utils/log.h" #include "utils/url.h" @@ -181,13 +183,13 @@ bool filename_initialise(void) for (start = directory; *start != '\0'; start++) { if (*start == '/') { *start = '\0'; - mkdir(directory, S_IRWXU); + nsmkdir(directory, S_IRWXU); *start = '/'; } } LOG(("Temporary directory location: %s", directory)); - mkdir(directory, S_IRWXU); + nsmkdir(directory, S_IRWXU); free(directory); @@ -481,7 +483,7 @@ static struct directory *filename_create_directory(const char *prefix) new_dir->prefix[8] = '/'; if (!is_dir(filename_directory)) { - if (!mkdir(filename_directory, S_IRWXU)) + if (!nsmkdir(filename_directory, S_IRWXU)) return new_dir; /* the user has probably deleted the parent directory @@ -508,7 +510,7 @@ static struct directory *filename_create_directory(const char *prefix) last_1[0] = '\0'; if (!is_dir(filename_directory)) { - if (mkdir(filename_directory, S_IRWXU)) { + if (nsmkdir(filename_directory, S_IRWXU)) { LOG(("Failed to create directory '%s'", filename_directory)); return NULL; diff --git a/utils/useragent.c b/utils/useragent.c index 48aa010b1..5b8c9e10f 100644 --- a/utils/useragent.c +++ b/utils/useragent.c @@ -17,10 +17,11 @@ * along with this program. If not, see . */ -#include #include #include +#include "utils/config.h" +#include "utils/utsname.h" #include "desktop/netsurf.h" #include "utils/log.h" #include "utils/useragent.h" diff --git a/utils/utils.c b/utils/utils.c index c8cfcb410..175b33073 100644 --- a/utils/utils.c +++ b/utils/utils.c @@ -463,3 +463,17 @@ char *strchrnul (const char *s, int c_in) } #endif + +#ifndef HAVE_UTSNAME +#include "utils/utsname.h" + +int uname(struct utsname *buf) { + strcpy(buf->sysname,"windows"); + strcpy(buf->nodename,"nodename"); + strcpy(buf->release,"release"); + strcpy(buf->version,"version"); + strcpy(buf->machine,"pc"); + + return 0; +} +#endif diff --git a/utils/utils.h b/utils/utils.h index 74c01ec25..c6b07c6b6 100644 --- a/utils/utils.h +++ b/utils/utils.h @@ -72,6 +72,11 @@ typedef struct void (*cancel)(query_id, enum query_response res, void *pw); } query_callback; +#ifdef HAVE_MKDIR +#define nsmkdir(dir, mode) mkdir((dir), (mode)) +#else +#define nsmkdir(dir, mode) mkdir((dir)) +#endif char * strip(char * const s); int whitespace(const char * str); diff --git a/utils/utsname.h b/utils/utsname.h new file mode 100644 index 000000000..cc267c6d3 --- /dev/null +++ b/utils/utsname.h @@ -0,0 +1,39 @@ +/* + * Copyright 2010 Vincent Sanders + * + * This file is part of NetSurf, http://www.netsurf-browser.org/ + * + * NetSurf 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; version 2 of the License. + * + * NetSurf 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, see . + */ + +#ifndef _NETSURF_UTILS_UTSNAME_H_ +#define _NETSURF_UTILS_UTSNAME_H_ + +#ifdef HAVE_UTSNAME +#include +#else +/* from posix spec */ +struct utsname { + char sysname[65]; /* Operating system name (e.g., "Linux") */ + char nodename[65]; /* Name within "some implementation-defined + network" */ + char release[65]; /* OS release (e.g., "2.6.28") */ + char version[65]; /* OS version */ + char machine[65]; /* Hardware identifier */ +}; + +int uname(struct utsname *buf); + +#endif + +#endif -- cgit v1.2.3