From 08b8a6cf2c62b85dba0eb34d790f10296a04e932 Mon Sep 17 00:00:00 2001 From: "dougt@meer.net" Date: Wed, 20 Feb 2008 09:57:01 -0800 Subject: [PATCH] Adding map functionality. Including stub Usp10.h. NPODB --- build/wince/shunt/include/Usp10.h | 0 build/wince/shunt/include/map.h | 45 ++++++++++++++++++++++++++ build/wince/shunt/map.cpp | 54 +++++++++++++++++++++++++++++++ 3 files changed, 99 insertions(+) create mode 100644 build/wince/shunt/include/Usp10.h create mode 100755 build/wince/shunt/include/map.h create mode 100755 build/wince/shunt/map.cpp diff --git a/build/wince/shunt/include/Usp10.h b/build/wince/shunt/include/Usp10.h new file mode 100644 index 00000000000..e69de29bb2d diff --git a/build/wince/shunt/include/map.h b/build/wince/shunt/include/map.h new file mode 100755 index 00000000000..9daa65cc365 --- /dev/null +++ b/build/wince/shunt/include/map.h @@ -0,0 +1,45 @@ +#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); + +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++)}, + {"XRE_PROFILE_NAME","default",0} +}; + +static mapping* head = initial_map; + + +#if 0 +{ +#endif +} /* extern "C" */ + +#endif \ No newline at end of file diff --git a/build/wince/shunt/map.cpp b/build/wince/shunt/map.cpp new file mode 100755 index 00000000000..e723a4d1e37 --- /dev/null +++ b/build/wince/shunt/map.cpp @@ -0,0 +1,54 @@ +#include "map.h" +#include "stdlib.h" + +//right now, I'm assuming this stucture won't be huge, so implmenting with a linked list +extern "C" { +#if 0 +} +#endif + + +mapping* getMapping(const char* key) +{ + mapping* cur = head; + while(cur != NULL){ + if(!strcmp(cur->key,key)) + return cur; + cur = cur->next; + } + return NULL; +} + +int map_put(const char* key,const char* val) +{ + mapping* map = getMapping(key); + if(map){ + if(!((map > initial_map) && + (map < (initial_map + init_i)))) + free( map->value); + }else{ + map = (mapping*)malloc(sizeof(mapping)); + map->key = (char*)malloc((strlen(key)+1)*sizeof(char)); + strcpy(map->key,key); + map->next = head; + head = map; + } + map->value = (char*)malloc((strlen(val)+1)*sizeof(char)); + strcpy(map->value,val); + return 0; +} + +char* map_get(const char* key) +{ + mapping* map = getMapping(key); + if(map) + return map->value; + return NULL; +} + + +#if 0 +{ +#endif +} /* extern "C" */ +