diff --git a/libs/openzap/openzap.vcproj b/libs/openzap/openzap.vcproj
new file mode 100644
index 0000000000..001ce13352
--- /dev/null
+++ b/libs/openzap/openzap.vcproj
@@ -0,0 +1,227 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/libs/openzap/src/hashtable.c b/libs/openzap/src/hashtable.c
index 763357edce..e03013ba10 100644
--- a/libs/openzap/src/hashtable.c
+++ b/libs/openzap/src/hashtable.c
@@ -22,13 +22,13 @@ static const unsigned int primes[] = {
805306457, 1610612741
};
const unsigned int prime_table_length = sizeof(primes)/sizeof(primes[0]);
-const float max_load_factor = 0.65;
+const float max_load_factor = 0.65f;
/*****************************************************************************/
struct hashtable *
create_hashtable(unsigned int minsize,
- unsigned int (*hashf) (void*),
- int (*eqf) (void*,void*))
+ unsigned int (*hashf) (const void*),
+ int (*eqf) (const void*,const void*))
{
struct hashtable *h;
unsigned int pindex, size = primes[0];
@@ -54,7 +54,7 @@ create_hashtable(unsigned int minsize,
/*****************************************************************************/
unsigned int
-hash(struct hashtable *h, void *k)
+hash(struct hashtable *h, const void *k)
{
/* Aim to protect against poor hash functions by adding logic here
* - logic taken from java 1.4 hashtable source */
@@ -160,7 +160,7 @@ hashtable_insert(struct hashtable *h, void *k, void *v)
/*****************************************************************************/
void * /* returns value associated with key */
-hashtable_search(struct hashtable *h, void *k)
+hashtable_search(struct hashtable *h, const void *k)
{
struct entry *e;
unsigned int hashvalue, index;
diff --git a/libs/openzap/src/include/hashtable.h b/libs/openzap/src/include/hashtable.h
index b90781abd4..88d76572e8 100644
--- a/libs/openzap/src/include/hashtable.h
+++ b/libs/openzap/src/include/hashtable.h
@@ -73,8 +73,8 @@ struct hashtable;
struct hashtable *
create_hashtable(unsigned int minsize,
- unsigned int (*hashfunction) (void*),
- int (*key_eq_fn) (void*,void*));
+ unsigned int (*hashfunction) (const void*),
+ int (*key_eq_fn) (const void*,const void*));
/*****************************************************************************
* hashtable_insert
@@ -114,7 +114,7 @@ int fnname (struct hashtable *h, keytype *k, valuetype *v) \
*/
void *
-hashtable_search(struct hashtable *h, void *k);
+hashtable_search(struct hashtable *h, const void *k);
#define DEFINE_HASHTABLE_SEARCH(fnname, keytype, valuetype) \
valuetype * fnname (struct hashtable *h, keytype *k) \
diff --git a/libs/openzap/src/include/hashtable_private.h b/libs/openzap/src/include/hashtable_private.h
index cb261e9af2..3087b8eaa1 100644
--- a/libs/openzap/src/include/hashtable_private.h
+++ b/libs/openzap/src/include/hashtable_private.h
@@ -19,8 +19,8 @@ struct hashtable {
unsigned int entrycount;
unsigned int loadlimit;
unsigned int primeindex;
- unsigned int (*hashfn) (void *k);
- int (*eqfn) (void *k1, void *k2);
+ unsigned int (*hashfn) (const void *k);
+ int (*eqfn) (const void *k1, const void *k2);
};
/*****************************************************************************/
diff --git a/libs/openzap/src/include/openzap.h b/libs/openzap/src/include/openzap.h
index a3214c356c..ca80a3874c 100644
--- a/libs/openzap/src/include/openzap.h
+++ b/libs/openzap/src/include/openzap.h
@@ -35,6 +35,24 @@
#define OPENZAP_H
#define _XOPEN_SOURCE 500
+
+#ifdef _MSC_VER
+#if (_MSC_VER >= 1400) // VC8+
+#ifndef _CRT_SECURE_NO_DEPRECATE
+#define _CRT_SECURE_NO_DEPRECATE
+#endif
+#ifndef _CRT_NONSTDC_NO_DEPRECATE
+#define _CRT_NONSTDC_NO_DEPRECATE
+#endif
+#endif
+#ifndef strcasecmp
+#define strcasecmp(s1, s2) _stricmp(s1, s2)
+#endif
+#ifndef snprintf
+#define snprintf _snprintf
+#endif
+#endif
+
#include
#include
#include
diff --git a/libs/openzap/src/openzap.c b/libs/openzap/src/openzap.c
index 4905f230bb..170bc727eb 100644
--- a/libs/openzap/src/openzap.c
+++ b/libs/openzap/src/openzap.c
@@ -45,12 +45,12 @@ static struct {
} globals;
-static int equalkeys(void *k1, void *k2)
+static int equalkeys(const void *k1, const void *k2)
{
return strcmp((char *) k1, (char *) k2) ? 0 : 1;
}
-static unsigned hashfromstring(void *ky)
+static unsigned hashfromstring(const void *ky)
{
unsigned char *str = (unsigned char *) ky;
unsigned hash = 0;
@@ -102,10 +102,9 @@ zap_status_t zap_span_destroy(zap_span_t **span);
zap_status_t zap_channel_open(const char *name, unsigned span_id, unsigned chan_id, zap_channel_t **zchan)
{
- zap_software_interface_t *zint;
+ zap_software_interface_t *zint = (zap_software_interface_t *) hashtable_search(globals.interface_hash, name);
- if (span_id < ZAP_MAX_SPANS_INTERFACE && chan_id < ZAP_MAX_CHANNELS_SPAN &&
- (zint = (zap_software_interface_t *) hashtable_search(globals.interface_hash, (void *)name))) {
+ if (span_id < ZAP_MAX_SPANS_INTERFACE && chan_id < ZAP_MAX_CHANNELS_SPAN && zint) {
zap_channel_t *check;
check = &zint->spans[span_id].channels[chan_id];
if (zap_test_flag(check, ZAP_CHANNEL_READY) && ! zap_test_flag(check, ZAP_CHANNEL_OPEN)) {
@@ -229,10 +228,10 @@ zap_status_t zap_global_init(void)
zap_config_t cfg;
char *var, *val;
unsigned configured = 0;
- zap_software_interface_t *zint;
-
- assert(zint = NULL);
+ zap_software_interface_t *zint = NULL;
+ zint, 0;
+
globals.interface_hash = create_hashtable(16, hashfromstring, equalkeys);
#ifdef ZAP_WANPIPE_SUPPORT
@@ -256,7 +255,8 @@ zap_status_t zap_global_init(void)
if (!strcmp(var, "load")) {
zap_software_interface_t *zint;
- if ((zint = (zap_software_interface_t *) hashtable_search(globals.interface_hash, val))) {
+ zint = (zap_software_interface_t *) hashtable_search(globals.interface_hash, val);
+ if (zint) {
if (zint->configure(zint) == ZAP_SUCCESS) {
configured++;
}
diff --git a/libs/openzap/src/zap_config.c b/libs/openzap/src/zap_config.c
index 17fa4d0596..eb65fb3809 100644
--- a/libs/openzap/src/zap_config.c
+++ b/libs/openzap/src/zap_config.c
@@ -54,7 +54,9 @@ int zap_config_open_file(zap_config_t *cfg, char *file_path)
memset(cfg, 0, sizeof(*cfg));
cfg->lockto = -1;
- if (!(f = fopen(path, "r"))) {
+ f = fopen(path, "r");
+
+ if (!f) {
if (file_path[0] != '/') {
int last = -1;
char *var, *val;