Fixing open() flag parsing, switching wince port to use sql backend for nss (dbm is very broken), fixing line endings. npodb
authorDoug Turner <dougt@meer.net>
Wed, 08 Oct 2008 20:54:47 -0700
changeset 20188 9a712f8bac315b43aa9cafc0d5568c0fb95ca002
parent 20187 66d756c2c44d03c1876fc95a4f807d20d061d792
child 20189 7e5d581bc86d5c2a7c26025f38c503b53be3c31a
push idunknown
push userunknown
push dateunknown
milestone1.9.1b2pre
Fixing open() flag parsing, switching wince port to use sql backend for nss (dbm is very broken), fixing line endings. npodb
build/wince/shunt/include/map.h
build/wince/shunt/stdio.cpp
--- a/build/wince/shunt/include/map.h
+++ b/build/wince/shunt/include/map.h
@@ -1,45 +1,46 @@
-#ifndef mozce_map_h
-#define mozce_map_h
-
+#ifndef mozce_map_h
+#define mozce_map_h
+
 extern "C" {
 #if 0
 }
 #endif
 struct mapping{
 char* key;
 char* value;
 mapping* next;
 };
 
 
 int map_put(const char* key,const char* val);
 char*  map_get(const char* key);
-
+#define DEBUG_NSPR_ALL
 static int init_i =1;
 static mapping initial_map[] = {
-#ifdef DEBUG_NSPR_ALL
-    {"NSPR_LOG_MODULES", "all:5",initial_map + (init_i++)},
-    {"NSPR_LOG_FILE","nspr.log",initial_map + (init_i++)},
-#endif  
-#ifdef TIMELINE
-    {"NS_TIMELINE_LOG_FILE","\\bin\\timeline.log",initial_map + (init_i++)},
-    {"NS_TIMELINE_ENABLE", "1",initial_map + (init_i++)},
-#endif
-    {"tmp", "/Temp",initial_map + (init_i++)},
-    {"GRE_HOME",".",initial_map + (init_i++)},
-	{ "NSPR_FD_CACHE_SIZE_LOW", "10",initial_map + (init_i++)},              
-    {"NSPR_FD_CACHE_SIZE_HIGH", "30",initial_map + (init_i++)},
-    {"XRE_PROFILE_PATH", "\\Application Data\\Mozilla\\Profiles",initial_map + (init_i++)},
-    {"XRE_PROFILE_LOCAL_PATH","./profile",initial_map + (init_i++)},
+#ifdef DEBUG_NSPR_ALL
+    {"NSPR_LOG_MODULES", "all:5",initial_map + (init_i++)},
+    {"NSPR_LOG_FILE","nspr.log",initial_map + (init_i++)},
+#endif  
+#ifdef TIMELINE
+    {"NS_TIMELINE_LOG_FILE","\\bin\\timeline.log",initial_map + (init_i++)},
+    {"NS_TIMELINE_ENABLE", "1",initial_map + (init_i++)},
+#endif
+    {"tmp", "/Temp",initial_map + (init_i++)},
+    {"GRE_HOME",".",initial_map + (init_i++)},
+    {"NSS_DEFAULT_DB_TYPE", "sql",initial_map + (init_i++)},
+    {"NSPR_FD_CACHE_SIZE_LOW", "10",initial_map + (init_i++)},              
+    {"NSPR_FD_CACHE_SIZE_HIGH", "30",initial_map + (init_i++)},
+    {"XRE_PROFILE_PATH", "\\Application Data\\Mozilla\\Profiles",initial_map + (init_i++)},
+    {"XRE_PROFILE_LOCAL_PATH","./profile",initial_map + (init_i++)},
     {"XRE_PROFILE_NAME","default",0}
 };
 
 static mapping* head = initial_map;
 
 
 #if 0
 {
 #endif
 } /* extern "C" */
 
-#endif
\ No newline at end of file
+#endif
--- a/build/wince/shunt/stdio.cpp
+++ b/build/wince/shunt/stdio.cpp
@@ -207,60 +207,55 @@ MOZCE_SHUNT_API int mozce_printf(const c
 #endif
     
     return 1;
     //#endif
 
     return 0;
 }
 
-static void mode2binstr(int mode, char* buffer)
+static void flags2binstr(int flags, char* buffer)
 {
-    if (mode & O_RDWR || (mode & O_WRONLY))  // write only == read|write
+		// this is not even close to correct.
+		// we need this only temporarly -- we are hoping to remove
+		// open/close/read/write in favor of fopen directly.
+
+    if (flags & O_RDWR || (flags & O_WRONLY))  // write only == read|write
     {
-        if (mode & O_CREAT)
-        {
-            strcpy(buffer, "wb+");
-        }
-        else if (mode & O_APPEND)
+        if (flags & O_APPEND)
         {
             strcpy(buffer, "ab+");
         }
-        else if (mode & O_TRUNC)
+        else
         {
             strcpy(buffer, "wb+");
         }
-        
-        else if (mode == O_RDWR)
-        {
-            strcpy(buffer, "rb+");
-        }
     }
-    else if (mode & O_RDONLY)
+    else
     {
         strcpy(buffer, "rb");
     }
 }
 
 MOZCE_SHUNT_API int open(const char *pathname, int flags, int mode)
 {
     WINCE_LOG_API_CALL("open called\n");
     
     _initfds();
     
     
-    char modestr[10];
-    *modestr = '\0';
+    char flagsstr[10];
+    *flagsstr = '\0';
     
-    mode2binstr(mode, modestr);
-    if (*modestr == '\0')
+    flags2binstr(flags, flagsstr);
+    if (*flagsstr == '\0')
         return -1;
     
     
-    FILE* file = fopen(pathname, modestr);
+    FILE* file = fopen(pathname, flagsstr);
     
     int fd = -1;
     
     if (file)
     {
         fd = _getnewfd();
         
         _fdtab[fd].fd = fd;