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:
Michael Jerris 2007-05-16 22:56:27 +00:00
parent fb39783d83
commit ae336c4894
7 changed files with 267 additions and 20 deletions

227
libs/openzap/openzap.vcproj Normal file
View File

@ -0,0 +1,227 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8.00"
Name="openzap"
ProjectGUID="{93B8812C-3EC4-4F78-8970-FFBFC99E167D}"
RootNamespace="openzap"
Keyword="Win32Proj"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="4"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="src/include"
PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
WarningLevel="4"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLibrarianTool"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="4"
CharacterSet="1"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="src/include"
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
RuntimeLibrary="2"
UsePrecompiledHeader="0"
WarningLevel="4"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLibrarianTool"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath=".\src\hashtable.c"
>
</File>
<File
RelativePath=".\src\hashtable_itr.c"
>
</File>
<File
RelativePath=".\src\openzap.c"
>
</File>
<File
RelativePath=".\src\zap_config.c"
>
</File>
<File
RelativePath=".\src\zap_skel.c"
>
</File>
<File
RelativePath=".\src\zap_wanpipe.c"
>
</File>
<File
RelativePath=".\src\zap_zt.c"
>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath=".\src\include\hashtable.h"
>
</File>
<File
RelativePath=".\src\include\hashtable_itr.h"
>
</File>
<File
RelativePath=".\src\include\hashtable_private.h"
>
</File>
<File
RelativePath=".\src\include\openzap.h"
>
</File>
<File
RelativePath=".\src\include\zap_config.h"
>
</File>
<File
RelativePath=".\src\include\zap_skel.h"
>
</File>
<File
RelativePath=".\src\include\zap_wanpipe.h"
>
</File>
<File
RelativePath=".\src\include\zap_zt.h"
>
</File>
</Filter>
<Filter
Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

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

View File

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

View File

@ -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);
};
/*****************************************************************************/

View File

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

View File

@ -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++;
}

View File

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