summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorblythe%netscape.com <devnull@localhost>2002-02-08 00:00:28 +0000
committerblythe%netscape.com <devnull@localhost>2002-02-08 00:00:28 +0000
commit8f071db0da0531f0a311f8544f1f41ff031e0491 (patch)
treebee3235277cbfbd53331f58bab9cb04244277303
parent1cfd560e3ca584a681af2645964161fb1e42bdf8 (diff)
downloadnspr-hg-8f071db0da0531f0a311f8544f1f41ff031e0491.tar.gz
More work to support unimplemented library functions for Wince.
-rw-r--r--pr/include/md/_win32_time.h16
-rw-r--r--pr/include/md/_wince.h39
-rw-r--r--pr/src/md/windows/Makefile.in1
-rw-r--r--pr/src/md/windows/objs.mk3
-rw-r--r--pr/src/md/windows/w32netdb.c109
-rw-r--r--pr/src/md/windows/w32time.c40
-rw-r--r--pr/src/misc/prnetdb.c4
-rw-r--r--pr/src/misc/prtime.c9
8 files changed, 199 insertions, 22 deletions
diff --git a/pr/include/md/_win32_time.h b/pr/include/md/_win32_time.h
index bfd7a16e..f60ca18d 100644
--- a/pr/include/md/_win32_time.h
+++ b/pr/include/md/_win32_time.h
@@ -161,20 +161,4 @@
FileTimeToSystemTime(&localConversion, &outSystemTime); \
PR_END_MACRO
-/*
- * tm is needed.
- * Used by Winlocaltime.
- */
-struct tm {
- int tm_sec;
- int tm_min;
- int tm_hour;
- int tm_mday;
- int tm_mon;
- int tm_year;
- int tm_wday;
- int tm_yday;
- int tm_isdst;
-};
-
#endif /* nspr_win32_time_h___ */
diff --git a/pr/include/md/_wince.h b/pr/include/md/_wince.h
index 6cc30b43..b9706c24 100644
--- a/pr/include/md/_wince.h
+++ b/pr/include/md/_wince.h
@@ -506,7 +506,9 @@ extern PRStatus _MD_CloseFileMap(struct PRFileMap *fmap);
typedef long _off_t; /* file offset value */
/*
- * Missing structs that are assumed by nspr.
+ * struct stat
+ *
+ * Assumed by NSPR in a place or two.
*/
struct stat {
unsigned short st_mode;
@@ -533,4 +535,39 @@ struct stat {
#define _S_IWRITE 0000200 /* stat, can write */
#define ENOMEM 12 /* errno, out of memory */
+/*
+ * struct tm
+ *
+ * And related windows specific functions to mimic LIBC's tm funcs.
+ */
+struct tm {
+ int tm_sec;
+ int tm_min;
+ int tm_hour;
+ int tm_mday;
+ int tm_mon;
+ int tm_year;
+ int tm_wday;
+ int tm_yday;
+ int tm_isdst;
+};
+extern struct tm* Winlocaltime(const time_t* inTimeT);
+extern time_t Winmktime(struct tm* inTM);
+extern size_t Winstrftime(char *strDest, size_t maxsize, const char *format, const struct tm *timeptr);
+
+/*
+ * struct protoent is actually defined, but the functions that use it are not.
+ *
+ * And related windows specific functions to mimic these absent sockets funcs.
+ */
+#if 0
+struct protoent {
+ char* p_name;
+ char** p_aliases;
+ short p_proto;
+};
+#endif
+extern struct protoent* Wingetprotobyname(const char* inName);
+extern struct protoent* Wingetprotobynumber(int inNumber);
+
#endif /* nspr_wince_defs_h___ */
diff --git a/pr/src/md/windows/Makefile.in b/pr/src/md/windows/Makefile.in
index 49a38eb6..8b203ee2 100644
--- a/pr/src/md/windows/Makefile.in
+++ b/pr/src/md/windows/Makefile.in
@@ -77,6 +77,7 @@ CSRCS = \
w95dllmain.c \
w32time.c \
w32unicode.c \
+ w32netdb.c \
$(NULL)
else
ifeq ($(OS_TARGET), WIN95)
diff --git a/pr/src/md/windows/objs.mk b/pr/src/md/windows/objs.mk
index 7023f308..2bb5aa93 100644
--- a/pr/src/md/windows/objs.mk
+++ b/pr/src/md/windows/objs.mk
@@ -64,7 +64,8 @@ CSRCS = ntmisc.c \
w32shm.c \
w95dllmain.c \
w32time.c \
- w32unicode.c
+ w32unicode.c \
+ w32netdb.c
else
ifeq ($(OS_TARGET),WIN95)
CSRCS = ntmisc.c \
diff --git a/pr/src/md/windows/w32netdb.c b/pr/src/md/windows/w32netdb.c
new file mode 100644
index 00000000..9118bbda
--- /dev/null
+++ b/pr/src/md/windows/w32netdb.c
@@ -0,0 +1,109 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/*
+ * The contents of this file are subject to the Mozilla Public
+ * License Version 1.1 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS
+ * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ * The Original Code is the Netscape Portable Runtime (NSPR).
+ *
+ * The Initial Developer of the Original Code is Netscape
+ * Communications Corporation. Portions created by Netscape are
+ * Copyright (C) 1998-2000 Netscape Communications Corporation. All
+ * Rights Reserved.
+ *
+ * Contributor(s):
+ * Garrett Arch Blythe, 02/07/2002
+ *
+ * Alternatively, the contents of this file may be used under the
+ * terms of the GNU General Public License Version 2 or later (the
+ * "GPL"), in which case the provisions of the GPL are applicable
+ * instead of those above. If you wish to allow use of your
+ * version of this file only under the terms of the GPL and not to
+ * allow others to use your version of this file under the MPL,
+ * indicate your decision by deleting the provisions above and
+ * replace them with the notice and other provisions required by
+ * the GPL. If you do not delete the provisions above, a recipient
+ * may use your version of this file under either the MPL or the
+ * GPL.
+ */
+
+/*
+ * w32netdb.c
+ *
+ * This file exists mainly to provide an implementation of the socket
+ * functions that are missing from certain toolsets; namely
+ * MS eMbedded Visual Tools (Windows CE).
+ */
+
+#include "primpl.h"
+
+/*
+ * Our static protocols entries.
+ */
+static struct protoent sProtos[] = {
+ { "tcp", NULL, IPPROTO_TCP },
+ { "udp", NULL, IPPROTO_UDP },
+ { "ip", NULL, IPPROTO_IP },
+ { "icmp", NULL, IPPROTO_ICMP },
+ { "ggp", NULL, IPPROTO_GGP },
+ { "pup", NULL, IPPROTO_PUP },
+ { "idp", NULL, IPPROTO_IDP },
+ { "nd", NULL, IPPROTO_ND },
+ { "raw", NULL, IPPROTO_RAW }
+};
+
+#define MAX_PROTOS (sizeof(sProtos) / sizeof(struct protoent))
+
+/*
+ * Wingetprotobyname
+ *
+ * As getprotobyname
+ */
+struct protoent* Wingetprotobyname(const char* inName)
+{
+ struct protoent* retval = NULL;
+
+ if(NULL != inName)
+ {
+ unsigned uLoop;
+
+ for(uLoop = 0; uLoop < MAX_PROTOS; uLoop++)
+ {
+ if(0 == stricmp(inName, sProtos[uLoop].p_name))
+ {
+ retval = &sProtos[uLoop];
+ break;
+ }
+ }
+ }
+
+ return retval;
+}
+
+/*
+ * Wingetprotobynumber
+ *
+ * As getprotobynumber
+ */
+struct protoent* Wingetprotobynumber(int inNumber)
+{
+ struct protoent* retval = NULL;
+ unsigned uLoop;
+
+ for(uLoop = 0; uLoop < MAX_PROTOS; uLoop++)
+ {
+ if(inNumber == sProtos[uLoop].p_proto)
+ {
+ retval = &sProtos[uLoop];
+ break;
+ }
+ }
+
+ return retval;
+}
diff --git a/pr/src/md/windows/w32time.c b/pr/src/md/windows/w32time.c
index c359b7d8..0b27ac5a 100644
--- a/pr/src/md/windows/w32time.c
+++ b/pr/src/md/windows/w32time.c
@@ -111,4 +111,42 @@ struct tm* Winlocaltime(const time_t* inTimeT)
}
return retval;
-} \ No newline at end of file
+}
+
+/*
+ * Winmktime
+ *
+ * As LIBCs mktime
+ */
+time_t Winmktime(struct tm* inTM)
+{
+ time_t retval = (time_t)-1;
+
+ /*
+ ** FIXME TODO
+ **
+ ** More here
+ */
+
+ return retval;
+}
+
+/*
+ * Winstrftime
+ *
+ * As LIBCs strftime
+ */
+size_t Winstrftime(char *strDest, size_t maxsize, const char *format, const struct tm *timeptr)
+{
+ size_t retval = 0;
+
+ /*
+ ** FIXME TODO
+ **
+ ** More here.
+ **
+ ** Use GetTimeFormat and GetDateFormat
+ */
+
+ return retval;
+}
diff --git a/pr/src/misc/prnetdb.c b/pr/src/misc/prnetdb.c
index a54a5fb4..d9e255c2 100644
--- a/pr/src/misc/prnetdb.c
+++ b/pr/src/misc/prnetdb.c
@@ -843,7 +843,7 @@ static struct protoent *getprotobyname_r(const char* name)
#ifdef XP_OS2_VACPP
return getprotobyname((char *)name);
#elif defined(WINCE)
- return NULL;
+ return Wingetprotobyname(name);
#else
return getprotobyname(name);
#endif
@@ -854,7 +854,7 @@ static struct protoent *getprotobynumber_r(PRInt32 number)
#if !defined(WINCE)
return getprotobynumber(number);
#else
- return NULL;
+ return Wingetprotobynumber(number);
#endif
} /* getprotobynumber_r */
diff --git a/pr/src/misc/prtime.c b/pr/src/misc/prtime.c
index 2cf0611d..9a0444b0 100644
--- a/pr/src/misc/prtime.c
+++ b/pr/src/misc/prtime.c
@@ -571,7 +571,6 @@ PR_NormalizeTime(PRExplodedTime *time, PRTimeParamFn params)
extern struct tm *Maclocaltime(const time_t * t);
#endif
#if defined(WINCE)
-extern struct tm* Winlocaltime(const time_t* inTimeT);
#endif
static PRLock *monitor = NULL;
@@ -1590,7 +1589,11 @@ PR_ParseTimeString(
date you are handing it is in daylight savings mode or not;
and if you're wrong, it will "fix" it for you. */
localTime.tm_isdst = -1;
+#if !defined(WINCE)
secs = mktime(&localTime);
+#else
+ secs = Winmktime(&localTime);
+#endif
if (secs != (time_t) -1)
{
#if defined(XP_MAC) && (__MSL__ < 0x6000)
@@ -1683,7 +1686,11 @@ PR_FormatTime(char *buf, int buflen, const char *fmt, const PRExplodedTime *tm)
}
#endif
+#if !defined(WINCE)
return strftime(buf, buflen, fmt, &a);
+#else
+ return Winstrftime(buf, buflen, fmt, &a);
+#endif
}