Adding map functionality. Including stub Usp10.h. NPODB

This commit is contained in:
dougt@meer.net 2008-02-20 09:57:01 -08:00
Родитель 0896f5b3d6
Коммит 66292a20e5
3 изменённых файлов: 99 добавлений и 0 удалений

Просмотреть файл

45
build/wince/shunt/include/map.h Executable file
Просмотреть файл

@ -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

54
build/wince/shunt/map.cpp Executable file
Просмотреть файл

@ -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" */