mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-11-14 13:28:31 +00:00
initial check-in of msvc build.
git-svn-id: http://svn.openzap.org/svn/openzap/trunk@8 a93c3328-9c30-0410-af19-c9cd2b2d52af
This commit is contained in:
1 parent
fb39783d83
commit
ae336c4894
7 files changed
+267
-20
No files matched your search
@@ -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;
|
||||
|
||||
@@ -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) \
|
||||
|
||||
@@ -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);
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
@@ -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 <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
@@ -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++;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in new issue
Block a user