Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Main
Synchronet
Commits
a4dac0d9
Commit
a4dac0d9
authored
Feb 09, 2014
by
deuce
Browse files
More DLLiciousness.
parent
1f3412f4
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
248 additions
and
246 deletions
+248
-246
src/xpdev/ini_file.c
src/xpdev/ini_file.c
+81
-81
src/xpdev/ini_file.h
src/xpdev/ini_file.h
+81
-81
src/xpdev/sockwrap.c
src/xpdev/sockwrap.c
+11
-11
src/xpdev/sockwrap.h
src/xpdev/sockwrap.h
+12
-11
src/xpdev/str_list.c
src/xpdev/str_list.c
+31
-31
src/xpdev/str_list.h
src/xpdev/str_list.h
+32
-31
No files found.
src/xpdev/ini_file.c
View file @
a4dac0d9
This diff is collapsed.
Click to expand it.
src/xpdev/ini_file.h
View file @
a4dac0d9
...
...
@@ -66,177 +66,177 @@ extern "C" {
/* Read all section names and return as an allocated string list */
/* Optionally (if prefix!=NULL), returns a subset of section names */
str_list_t
iniReadSectionList
(
FILE
*
,
const
char
*
prefix
);
DLLEXPORT
str_list_t
DLLCALL
iniReadSectionList
(
FILE
*
,
const
char
*
prefix
);
/* Returns number (count) of sections */
size_t
iniReadSectionCount
(
FILE
*
,
const
char
*
prefix
);
DLLEXPORT
size_t
DLLCALL
iniReadSectionCount
(
FILE
*
,
const
char
*
prefix
);
/* Read all key names and return as an allocated string list */
str_list_t
iniReadKeyList
(
FILE
*
,
const
char
*
section
);
DLLEXPORT
str_list_t
DLLCALL
iniReadKeyList
(
FILE
*
,
const
char
*
section
);
/* Read all key and value pairs and return as a named string list */
named_string_t
**
DLLEXPORT
named_string_t
**
DLLCALL
iniReadNamedStringList
(
FILE
*
,
const
char
*
section
);
/* Return the supported Log Levels in a string list - for *LogLevel macros */
str_list_t
iniLogLevelStringList
(
void
);
DLLEXPORT
str_list_t
DLLCALL
iniLogLevelStringList
(
void
);
/* These functions read a single key of the specified type */
char
*
iniReadString
(
FILE
*
,
const
char
*
section
,
const
char
*
key
DLLEXPORT
char
*
DLLCALL
iniReadString
(
FILE
*
,
const
char
*
section
,
const
char
*
key
,
const
char
*
deflt
,
char
*
value
);
/* If the key doesn't exist, iniReadExistingString just returns NULL */
char
*
iniReadExistingString
(
FILE
*
,
const
char
*
section
,
const
char
*
key
DLLEXPORT
char
*
DLLCALL
iniReadExistingString
(
FILE
*
,
const
char
*
section
,
const
char
*
key
,
const
char
*
deflt
,
char
*
value
);
str_list_t
iniReadStringList
(
FILE
*
,
const
char
*
section
,
const
char
*
key
DLLEXPORT
str_list_t
DLLCALL
iniReadStringList
(
FILE
*
,
const
char
*
section
,
const
char
*
key
,
const
char
*
sep
,
const
char
*
deflt
);
long
iniReadInteger
(
FILE
*
,
const
char
*
section
,
const
char
*
key
DLLEXPORT
long
DLLCALL
iniReadInteger
(
FILE
*
,
const
char
*
section
,
const
char
*
key
,
long
deflt
);
ushort
iniReadShortInt
(
FILE
*
,
const
char
*
section
,
const
char
*
key
DLLEXPORT
ushort
DLLCALL
iniReadShortInt
(
FILE
*
,
const
char
*
section
,
const
char
*
key
,
ushort
deflt
);
ulong
iniReadLongInt
(
FILE
*
,
const
char
*
section
,
const
char
*
key
DLLEXPORT
ulong
DLLCALL
iniReadLongInt
(
FILE
*
,
const
char
*
section
,
const
char
*
key
,
ulong
deflt
);
int64_t
iniReadBytes
(
FILE
*
,
const
char
*
section
,
const
char
*
key
DLLEXPORT
int64_t
DLLCALL
iniReadBytes
(
FILE
*
,
const
char
*
section
,
const
char
*
key
,
ulong
unit
,
int64_t
deflt
);
double
iniReadFloat
(
FILE
*
,
const
char
*
section
,
const
char
*
key
DLLEXPORT
double
DLLCALL
iniReadFloat
(
FILE
*
,
const
char
*
section
,
const
char
*
key
,
double
deflt
);
BOO
L
iniReadBool
(
FILE
*
,
const
char
*
section
,
const
char
*
key
DLLEXPORT
BOOL
DLLCAL
L
iniReadBool
(
FILE
*
,
const
char
*
section
,
const
char
*
key
,
BOOL
deflt
);
time_t
iniReadDateTime
(
FILE
*
,
const
char
*
section
,
const
char
*
key
DLLEXPORT
time_t
DLLCALL
iniReadDateTime
(
FILE
*
,
const
char
*
section
,
const
char
*
key
,
time_t
deflt
);
unsigned
iniReadEnum
(
FILE
*
,
const
char
*
section
,
const
char
*
key
DLLEXPORT
unsigned
DLLCALL
iniReadEnum
(
FILE
*
,
const
char
*
section
,
const
char
*
key
,
str_list_t
names
,
unsigned
deflt
);
unsigned
*
iniReadEnumList
(
FILE
*
,
const
char
*
section
,
const
char
*
key
DLLEXPORT
unsigned
*
DLLCALL
iniReadEnumList
(
FILE
*
,
const
char
*
section
,
const
char
*
key
,
str_list_t
names
,
unsigned
*
count
,
const
char
*
sep
,
const
char
*
deflt
);
long
iniReadNamedInt
(
FILE
*
,
const
char
*
section
,
const
char
*
key
DLLEXPORT
long
DLLCALL
iniReadNamedInt
(
FILE
*
,
const
char
*
section
,
const
char
*
key
,
named_long_t
*
,
long
deflt
);
double
iniReadNamedFloat
(
FILE
*
,
const
char
*
section
,
const
char
*
key
DLLEXPORT
double
DLLCALL
iniReadNamedFloat
(
FILE
*
,
const
char
*
section
,
const
char
*
key
,
named_double_t
*
,
double
deflt
);
ulong
iniReadBitField
(
FILE
*
,
const
char
*
section
,
const
char
*
key
DLLEXPORT
ulong
DLLCALL
iniReadBitField
(
FILE
*
,
const
char
*
section
,
const
char
*
key
,
ini_bitdesc_t
*
bitdesc
,
ulong
deflt
);
#define iniReadLogLevel(f,s,k,d) iniReadEnum(f,s,k,iniLogLevelStringList(),d)
/* Free string list returned from iniRead*List functions */
void
*
iniFreeStringList
(
str_list_t
list
);
DLLEXPORT
void
*
DLLCALL
iniFreeStringList
(
str_list_t
list
);
/* Free named string list returned from iniReadNamedStringList */
void
*
iniFreeNamedStringList
(
named_string_t
**
list
);
DLLEXPORT
void
*
DLLCALL
iniFreeNamedStringList
(
named_string_t
**
list
);
/* File I/O Functions */
char
*
iniFileName
(
char
*
dest
,
size_t
maxlen
,
const
char
*
dir
,
const
char
*
fname
);
FILE
*
iniOpenFile
(
const
char
*
fname
,
BOOL
create
);
str_list_t
iniReadFile
(
FILE
*
);
BOO
L
iniWriteFile
(
FILE
*
,
const
str_list_t
);
BOO
L
iniCloseFile
(
FILE
*
);
DLLEXPORT
char
*
DLLCALL
iniFileName
(
char
*
dest
,
size_t
maxlen
,
const
char
*
dir
,
const
char
*
fname
);
DLLEXPORT
FILE
*
DLLCALL
iniOpenFile
(
const
char
*
fname
,
BOOL
create
);
DLLEXPORT
str_list_t
DLLCALL
iniReadFile
(
FILE
*
);
DLLEXPORT
BOOL
DLLCAL
L
iniWriteFile
(
FILE
*
,
const
str_list_t
);
DLLEXPORT
BOOL
DLLCAL
L
iniCloseFile
(
FILE
*
);
/* StringList functions */
str_list_t
iniGetSectionList
(
str_list_t
list
,
const
char
*
prefix
);
size_t
iniGetSectionCount
(
str_list_t
list
,
const
char
*
prefix
);
str_list_t
iniGetKeyList
(
str_list_t
list
,
const
char
*
section
);
named_string_t
**
DLLEXPORT
str_list_t
DLLCALL
iniGetSectionList
(
str_list_t
list
,
const
char
*
prefix
);
DLLEXPORT
size_t
DLLCALL
iniGetSectionCount
(
str_list_t
list
,
const
char
*
prefix
);
DLLEXPORT
str_list_t
DLLCALL
iniGetKeyList
(
str_list_t
list
,
const
char
*
section
);
DLLEXPORT
named_string_t
**
DLLCALL
iniGetNamedStringList
(
str_list_t
list
,
const
char
*
section
);
char
*
iniGetString
(
str_list_t
,
const
char
*
section
,
const
char
*
key
DLLEXPORT
char
*
DLLCALL
iniGetString
(
str_list_t
,
const
char
*
section
,
const
char
*
key
,
const
char
*
deflt
,
char
*
value
/* may be NULL */
);
/* If the key doesn't exist, iniGetExistingString just returns NULL */
char
*
iniGetExistingString
(
str_list_t
,
const
char
*
section
,
const
char
*
key
DLLEXPORT
char
*
DLLCALL
iniGetExistingString
(
str_list_t
,
const
char
*
section
,
const
char
*
key
,
const
char
*
deflt
,
char
*
value
/* may be NULL */
);
str_list_t
iniGetStringList
(
str_list_t
,
const
char
*
section
,
const
char
*
key
DLLEXPORT
str_list_t
DLLCALL
iniGetStringList
(
str_list_t
,
const
char
*
section
,
const
char
*
key
,
const
char
*
sep
,
const
char
*
deflt
);
long
iniGetInteger
(
str_list_t
,
const
char
*
section
,
const
char
*
key
DLLEXPORT
long
DLLCALL
iniGetInteger
(
str_list_t
,
const
char
*
section
,
const
char
*
key
,
long
deflt
);
ushort
iniGetShortInt
(
str_list_t
,
const
char
*
section
,
const
char
*
key
DLLEXPORT
ushort
DLLCALL
iniGetShortInt
(
str_list_t
,
const
char
*
section
,
const
char
*
key
,
ushort
deflt
);
ulong
iniGetLongInt
(
str_list_t
,
const
char
*
section
,
const
char
*
key
DLLEXPORT
ulong
DLLCALL
iniGetLongInt
(
str_list_t
,
const
char
*
section
,
const
char
*
key
,
ulong
deflt
);
int64_t
iniGetBytes
(
str_list_t
,
const
char
*
section
,
const
char
*
key
DLLEXPORT
int64_t
DLLCALL
iniGetBytes
(
str_list_t
,
const
char
*
section
,
const
char
*
key
,
ulong
unit
,
int64_t
deflt
);
double
iniGetFloat
(
str_list_t
,
const
char
*
section
,
const
char
*
key
DLLEXPORT
double
DLLCALL
iniGetFloat
(
str_list_t
,
const
char
*
section
,
const
char
*
key
,
double
deflt
);
BOO
L
iniGetBool
(
str_list_t
,
const
char
*
section
,
const
char
*
key
DLLEXPORT
BOOL
DLLCAL
L
iniGetBool
(
str_list_t
,
const
char
*
section
,
const
char
*
key
,
BOOL
deflt
);
time_t
iniGetDateTime
(
str_list_t
,
const
char
*
section
,
const
char
*
key
DLLEXPORT
time_t
DLLCALL
iniGetDateTime
(
str_list_t
,
const
char
*
section
,
const
char
*
key
,
time_t
deflt
);
unsigned
iniGetEnum
(
str_list_t
,
const
char
*
section
,
const
char
*
key
DLLEXPORT
unsigned
DLLCALL
iniGetEnum
(
str_list_t
,
const
char
*
section
,
const
char
*
key
,
str_list_t
names
,
unsigned
deflt
);
unsigned
*
iniGetEnumList
(
str_list_t
,
const
char
*
section
,
const
char
*
key
DLLEXPORT
unsigned
*
DLLCALL
iniGetEnumList
(
str_list_t
,
const
char
*
section
,
const
char
*
key
,
str_list_t
names
,
unsigned
*
count
,
const
char
*
sep
,
const
char
*
deflt
);
long
iniGetNamedInt
(
str_list_t
,
const
char
*
section
,
const
char
*
key
DLLEXPORT
long
DLLCALL
iniGetNamedInt
(
str_list_t
,
const
char
*
section
,
const
char
*
key
,
named_long_t
*
,
long
deflt
);
double
iniGetNamedFloat
(
str_list_t
,
const
char
*
section
,
const
char
*
key
DLLEXPORT
double
DLLCALL
iniGetNamedFloat
(
str_list_t
,
const
char
*
section
,
const
char
*
key
,
named_double_t
*
,
double
deflt
);
ulong
iniGetBitField
(
str_list_t
,
const
char
*
section
,
const
char
*
key
DLLEXPORT
ulong
DLLCALL
iniGetBitField
(
str_list_t
,
const
char
*
section
,
const
char
*
key
,
ini_bitdesc_t
*
bitdesc
,
ulong
deflt
);
str_list_t
iniGetSection
(
str_list_t
,
const
char
*
section
);
DLLEXPORT
str_list_t
DLLCALL
iniGetSection
(
str_list_t
,
const
char
*
section
);
#define iniGetLogLevel(l,s,k,d) iniGetEnum(l,s,k,iniLogLevelStringList(),d)
#if !defined(NO_SOCKET_SUPPORT)
ulong
iniReadIpAddress
(
FILE
*
,
const
char
*
section
,
const
char
*
key
DLLEXPORT
ulong
DLLCALL
iniReadIpAddress
(
FILE
*
,
const
char
*
section
,
const
char
*
key
,
ulong
deflt
);
ulong
iniGetIpAddress
(
str_list_t
,
const
char
*
section
,
const
char
*
key
DLLEXPORT
ulong
DLLCALL
iniGetIpAddress
(
str_list_t
,
const
char
*
section
,
const
char
*
key
,
ulong
deflt
);
char
*
iniSetIpAddress
(
str_list_t
*
,
const
char
*
section
,
const
char
*
key
,
ulong
value
DLLEXPORT
char
*
DLLCALL
iniSetIpAddress
(
str_list_t
*
,
const
char
*
section
,
const
char
*
key
,
ulong
value
,
ini_style_t
*
);
struct
in6_addr
iniReadIp6Address
(
FILE
*
,
const
char
*
section
,
const
char
*
key
DLLEXPORT
struct
in6_addr
DLLCALL
iniReadIp6Address
(
FILE
*
,
const
char
*
section
,
const
char
*
key
,
struct
in6_addr
deflt
);
struct
in6_addr
iniGetIp6Address
(
str_list_t
,
const
char
*
section
,
const
char
*
key
DLLEXPORT
struct
in6_addr
DLLCALL
iniGetIp6Address
(
str_list_t
,
const
char
*
section
,
const
char
*
key
,
struct
in6_addr
deflt
);
char
*
iniSetIp6Address
(
str_list_t
*
,
const
char
*
section
,
const
char
*
key
,
struct
in6_addr
value
DLLEXPORT
char
*
DLLCALL
iniSetIp6Address
(
str_list_t
*
,
const
char
*
section
,
const
char
*
key
,
struct
in6_addr
value
,
ini_style_t
*
);
int
iniGetSocketOptions
(
str_list_t
,
const
char
*
section
DLLEXPORT
int
DLLCALL
iniGetSocketOptions
(
str_list_t
,
const
char
*
section
,
SOCKET
sock
,
char
*
error
,
size_t
errlen
);
#endif
void
iniSetDefaultStyle
(
ini_style_t
);
DLLEXPORT
void
DLLCALL
iniSetDefaultStyle
(
ini_style_t
);
char
*
iniSetString
(
str_list_t
*
,
const
char
*
section
,
const
char
*
key
,
const
char
*
value
DLLEXPORT
char
*
DLLCALL
iniSetString
(
str_list_t
*
,
const
char
*
section
,
const
char
*
key
,
const
char
*
value
,
ini_style_t
*
);
char
*
iniSetInteger
(
str_list_t
*
,
const
char
*
section
,
const
char
*
key
,
long
value
DLLEXPORT
char
*
DLLCALL
iniSetInteger
(
str_list_t
*
,
const
char
*
section
,
const
char
*
key
,
long
value
,
ini_style_t
*
);
char
*
iniSetShortInt
(
str_list_t
*
,
const
char
*
section
,
const
char
*
key
,
ushort
value
DLLEXPORT
char
*
DLLCALL
iniSetShortInt
(
str_list_t
*
,
const
char
*
section
,
const
char
*
key
,
ushort
value
,
ini_style_t
*
);
char
*
iniSetLongInt
(
str_list_t
*
,
const
char
*
section
,
const
char
*
key
,
ulong
value
DLLEXPORT
char
*
DLLCALL
iniSetLongInt
(
str_list_t
*
,
const
char
*
section
,
const
char
*
key
,
ulong
value
,
ini_style_t
*
);
char
*
iniSetBytes
(
str_list_t
*
,
const
char
*
section
,
const
char
*
key
,
ulong
unit
,
int64_t
value
DLLEXPORT
char
*
DLLCALL
iniSetBytes
(
str_list_t
*
,
const
char
*
section
,
const
char
*
key
,
ulong
unit
,
int64_t
value
,
ini_style_t
*
);
char
*
iniSetHexInt
(
str_list_t
*
,
const
char
*
section
,
const
char
*
key
,
ulong
value
DLLEXPORT
char
*
DLLCALL
iniSetHexInt
(
str_list_t
*
,
const
char
*
section
,
const
char
*
key
,
ulong
value
,
ini_style_t
*
);
char
*
iniSetFloat
(
str_list_t
*
,
const
char
*
section
,
const
char
*
key
,
double
value
DLLEXPORT
char
*
DLLCALL
iniSetFloat
(
str_list_t
*
,
const
char
*
section
,
const
char
*
key
,
double
value
,
ini_style_t
*
);
char
*
iniSetBool
(
str_list_t
*
,
const
char
*
section
,
const
char
*
key
,
BOOL
value
DLLEXPORT
char
*
DLLCALL
iniSetBool
(
str_list_t
*
,
const
char
*
section
,
const
char
*
key
,
BOOL
value
,
ini_style_t
*
);
char
*
iniSetDateTime
(
str_list_t
*
,
const
char
*
section
,
const
char
*
key
,
BOOL
include_time
,
time_t
DLLEXPORT
char
*
DLLCALL
iniSetDateTime
(
str_list_t
*
,
const
char
*
section
,
const
char
*
key
,
BOOL
include_time
,
time_t
,
ini_style_t
*
);
char
*
iniSetEnum
(
str_list_t
*
,
const
char
*
section
,
const
char
*
key
,
str_list_t
names
DLLEXPORT
char
*
DLLCALL
iniSetEnum
(
str_list_t
*
,
const
char
*
section
,
const
char
*
key
,
str_list_t
names
,
unsigned
value
,
ini_style_t
*
);
char
*
iniSetEnumList
(
str_list_t
*
,
const
char
*
section
,
const
char
*
key
DLLEXPORT
char
*
DLLCALL
iniSetEnumList
(
str_list_t
*
,
const
char
*
section
,
const
char
*
key
,
const
char
*
sep
,
str_list_t
names
,
unsigned
*
values
,
unsigned
count
,
ini_style_t
*
);
char
*
iniSetNamedInt
(
str_list_t
*
,
const
char
*
section
,
const
char
*
key
,
named_long_t
*
DLLEXPORT
char
*
DLLCALL
iniSetNamedInt
(
str_list_t
*
,
const
char
*
section
,
const
char
*
key
,
named_long_t
*
,
long
value
,
ini_style_t
*
);
char
*
iniSetNamedFloat
(
str_list_t
*
,
const
char
*
section
,
const
char
*
key
,
named_double_t
*
DLLEXPORT
char
*
DLLCALL
iniSetNamedFloat
(
str_list_t
*
,
const
char
*
section
,
const
char
*
key
,
named_double_t
*
,
double
value
,
ini_style_t
*
);
char
*
iniSetBitField
(
str_list_t
*
,
const
char
*
section
,
const
char
*
key
,
ini_bitdesc_t
*
,
ulong
value
DLLEXPORT
char
*
DLLCALL
iniSetBitField
(
str_list_t
*
,
const
char
*
section
,
const
char
*
key
,
ini_bitdesc_t
*
,
ulong
value
,
ini_style_t
*
);
char
*
iniSetStringList
(
str_list_t
*
,
const
char
*
section
,
const
char
*
key
DLLEXPORT
char
*
DLLCALL
iniSetStringList
(
str_list_t
*
,
const
char
*
section
,
const
char
*
key
,
const
char
*
sep
,
str_list_t
value
,
ini_style_t
*
);
#define iniSetLogLevel(l,s,k,v,style) iniSetEnum(l,s,k,iniLogLevelStringList(),v,style)
size_t
iniAddSection
(
str_list_t
*
,
const
char
*
section
DLLEXPORT
size_t
DLLCALL
iniAddSection
(
str_list_t
*
,
const
char
*
section
,
ini_style_t
*
);
size_t
iniAppendSection
(
str_list_t
*
,
const
char
*
section
DLLEXPORT
size_t
DLLCALL
iniAppendSection
(
str_list_t
*
,
const
char
*
section
,
ini_style_t
*
);
BOO
L
iniSectionExists
(
str_list_t
,
const
char
*
section
);
BOO
L
iniKeyExists
(
str_list_t
,
const
char
*
section
,
const
char
*
key
);
BOO
L
iniValueExists
(
str_list_t
,
const
char
*
section
,
const
char
*
key
);
char
*
iniPopKey
(
str_list_t
*
,
const
char
*
section
,
const
char
*
key
,
char
*
value
);
BOO
L
iniRemoveKey
(
str_list_t
*
,
const
char
*
section
,
const
char
*
key
);
BOO
L
iniRemoveValue
(
str_list_t
*
,
const
char
*
section
,
const
char
*
key
);
BOO
L
iniRemoveSection
(
str_list_t
*
,
const
char
*
section
);
BOO
L
iniRenameSection
(
str_list_t
*
,
const
char
*
section
,
const
char
*
newname
);
DLLEXPORT
BOOL
DLLCAL
L
iniSectionExists
(
str_list_t
,
const
char
*
section
);
DLLEXPORT
BOOL
DLLCAL
L
iniKeyExists
(
str_list_t
,
const
char
*
section
,
const
char
*
key
);
DLLEXPORT
BOOL
DLLCAL
L
iniValueExists
(
str_list_t
,
const
char
*
section
,
const
char
*
key
);
DLLEXPORT
char
*
DLLCALL
iniPopKey
(
str_list_t
*
,
const
char
*
section
,
const
char
*
key
,
char
*
value
);
DLLEXPORT
BOOL
DLLCAL
L
iniRemoveKey
(
str_list_t
*
,
const
char
*
section
,
const
char
*
key
);
DLLEXPORT
BOOL
DLLCAL
L
iniRemoveValue
(
str_list_t
*
,
const
char
*
section
,
const
char
*
key
);
DLLEXPORT
BOOL
DLLCAL
L
iniRemoveSection
(
str_list_t
*
,
const
char
*
section
);
DLLEXPORT
BOOL
DLLCAL
L
iniRenameSection
(
str_list_t
*
,
const
char
*
section
,
const
char
*
newname
);
/*
* Too handy to leave internal
*/
unsigned
*
parseEnumList
(
const
char
*
values
,
const
char
*
sep
,
str_list_t
names
,
unsigned
*
count
);
DLLEXPORT
unsigned
*
DLLCALL
parseEnumList
(
const
char
*
values
,
const
char
*
sep
,
str_list_t
names
,
unsigned
*
count
);
#if defined(__cplusplus)
}
...
...
src/xpdev/sockwrap.c
View file @
a4dac0d9
...
...
@@ -144,7 +144,7 @@ static socket_option_t socket_options[] = {
{
NULL
}
};
int
getSocketOptionByName
(
const
char
*
name
,
int
*
level
)
int
DLLCALL
getSocketOptionByName
(
const
char
*
name
,
int
*
level
)
{
int
i
;
...
...
@@ -162,12 +162,12 @@ int getSocketOptionByName(const char* name, int* level)
return
(
strtol
(
name
,
NULL
,
0
));
}
socket_option_t
*
getSocketOptionList
(
void
)
socket_option_t
*
DLLCALL
getSocketOptionList
(
void
)
{
return
(
socket_options
);
}
int
sendfilesocket
(
int
sock
,
int
file
,
off_t
*
offset
,
off_t
count
)
int
DLLCALL
sendfilesocket
(
int
sock
,
int
file
,
off_t
*
offset
,
off_t
count
)
{
char
buf
[
1024
*
16
];
off_t
len
;
...
...
@@ -229,7 +229,7 @@ int sendfilesocket(int sock, int file, off_t *offset, off_t count)
return
(
total
);
}
int
recvfilesocket
(
int
sock
,
int
file
,
off_t
*
offset
,
off_t
count
)
int
DLLCALL
recvfilesocket
(
int
sock
,
int
file
,
off_t
*
offset
,
off_t
count
)
{
/* Writes a file from a socket -
*
...
...
@@ -281,7 +281,7 @@ int recvfilesocket(int sock, int file, off_t *offset, off_t count)
/* Return true if connected, optionally sets *rd_p to true if read data available */
BOOL
socket_check
(
SOCKET
sock
,
BOOL
*
rd_p
,
BOOL
*
wr_p
,
DWORD
timeout
)
BOOL
DLLCALL
socket_check
(
SOCKET
sock
,
BOOL
*
rd_p
,
BOOL
*
wr_p
,
DWORD
timeout
)
{
char
ch
;
int
i
,
rd
;
...
...
@@ -340,7 +340,7 @@ BOOL socket_check(SOCKET sock, BOOL* rd_p, BOOL* wr_p, DWORD timeout)
return
(
FALSE
);
}
int
retry_bind
(
SOCKET
s
,
const
struct
sockaddr
*
addr
,
socklen_t
addrlen
int
DLLCALL
retry_bind
(
SOCKET
s
,
const
struct
sockaddr
*
addr
,
socklen_t
addrlen
,
uint
retries
,
uint
wait_secs
,
const
char
*
prot
,
int
(
*
lprintf
)(
int
level
,
const
char
*
fmt
,
...))
...
...
@@ -369,7 +369,7 @@ int retry_bind(SOCKET s, const struct sockaddr *addr, socklen_t addrlen
return
(
result
);
}
int
nonblocking_connect
(
SOCKET
sock
,
struct
sockaddr
*
addr
,
size_t
size
,
unsigned
timeout
)
int
DLLCALL
nonblocking_connect
(
SOCKET
sock
,
struct
sockaddr
*
addr
,
size_t
size
,
unsigned
timeout
)
{
int
result
;
...
...
@@ -391,7 +391,7 @@ int nonblocking_connect(SOCKET sock, struct sockaddr* addr, size_t size, unsigne
}
union
xp_sockaddr
*
inet_ptoaddr
(
char
*
addr_str
,
union
xp_sockaddr
*
addr
,
size_t
size
)
union
xp_sockaddr
*
DLLCALL
inet_ptoaddr
(
char
*
addr_str
,
union
xp_sockaddr
*
addr
,
size_t
size
)
{
struct
addrinfo
hints
=
{
0
};
struct
addrinfo
*
res
,
*
cur
;
...
...
@@ -413,7 +413,7 @@ union xp_sockaddr *inet_ptoaddr(char *addr_str, union xp_sockaddr *addr, size_t
return
addr
;
}
const
char
*
inet_addrtop
(
union
xp_sockaddr
*
addr
,
char
*
dest
,
size_t
size
)
const
char
*
DLLCALL
inet_addrtop
(
union
xp_sockaddr
*
addr
,
char
*
dest
,
size_t
size
)
{
#ifdef _WIN32
if
(
getnameinfo
(
addr
,
xp_sockaddr_len
(
addr
),
dest
,
size
,
NULL
,
0
,
NI_NUMERICHOST
))
...
...
@@ -436,7 +436,7 @@ const char *inet_addrtop(union xp_sockaddr *addr, char *dest, size_t size)
#endif
}
uint16_t
inet_addrport
(
union
xp_sockaddr
*
addr
)
uint16_t
DLLCALL
inet_addrport
(
union
xp_sockaddr
*
addr
)
{
switch
(
addr
->
addr
.
sa_family
)
{
case
AF_INET
:
...
...
@@ -448,7 +448,7 @@ uint16_t inet_addrport(union xp_sockaddr *addr)
}
}
void
inet_setaddrport
(
union
xp_sockaddr
*
addr
,
uint16_t
port
)
void
DLLCALL
inet_setaddrport
(
union
xp_sockaddr
*
addr
,
uint16_t
port
)
{
switch
(
addr
->
addr
.
sa_family
)
{
case
AF_INET
:
...
...
src/xpdev/sockwrap.h
View file @
a4dac0d9
...
...
@@ -87,6 +87,7 @@
#endif
#include <errno.h>
/* errno */
#include "wrapdll.h"
/* DLLEXPORT/DLLCALL */
typedef
struct
{
char
*
name
;
...
...
@@ -217,21 +218,21 @@ static int wsa_error;
extern
"C"
{
#endif
socket_option_t
*
DLLEXPORT
socket_option_t
*
DLLCALL
getSocketOptionList
(
void
);
int
getSocketOptionByName
(
const
char
*
name
,
int
*
level
);
DLLEXPORT
int
DLLCALL
getSocketOptionByName
(
const
char
*
name
,
int
*
level
);
int
sendfilesocket
(
int
sock
,
int
file
,
off_t
*
offset
,
off_t
count
);
int
recvfilesocket
(
int
sock
,
int
file
,
off_t
*
offset
,
off_t
count
);
BOO
L
socket_check
(
SOCKET
sock
,
BOOL
*
rd_p
,
BOOL
*
wr_p
,
DWORD
timeout
);
int
retry_bind
(
SOCKET
s
,
const
struct
sockaddr
*
addr
,
socklen_t
addrlen
DLLEXPORT
int
DLLCALL
sendfilesocket
(
int
sock
,
int
file
,
off_t
*
offset
,
off_t
count
);
DLLEXPORT
int
DLLCALL
recvfilesocket
(
int
sock
,
int
file
,
off_t
*
offset
,
off_t
count
);
DLLEXPORT
BOOL
DLLCAL
L
socket_check
(
SOCKET
sock
,
BOOL
*
rd_p
,
BOOL
*
wr_p
,
DWORD
timeout
);
DLLEXPORT
int
DLLCALL
retry_bind
(
SOCKET
s
,
const
struct
sockaddr
*
addr
,
socklen_t
addrlen
,
uint
retries
,
uint
wait_secs
,
const
char
*
prot
,
int
(
*
lprintf
)(
int
level
,
const
char
*
fmt
,
...));
int
nonblocking_connect
(
SOCKET
,
struct
sockaddr
*
,
size_t
,
unsigned
timeout
/* seconds */
);
union
xp_sockaddr
*
inet_ptoaddr
(
char
*
addr_str
,
union
xp_sockaddr
*
addr
,
size_t
size
);
const
char
*
inet_addrtop
(
union
xp_sockaddr
*
addr
,
char
*
dest
,
size_t
size
);
uint16_t
inet_addrport
(
union
xp_sockaddr
*
addr
);
void
inet_setaddrport
(
union
xp_sockaddr
*
addr
,
uint16_t
port
);
DLLEXPORT
int
DLLCALL
nonblocking_connect
(
SOCKET
,
struct
sockaddr
*
,
size_t
,
unsigned
timeout
/* seconds */
);
DLLEXPORT
union
xp_sockaddr
*
DLLCALL
inet_ptoaddr
(
char
*
addr_str
,
union
xp_sockaddr
*
addr
,
size_t
size
);
DLLEXPORT
const
char
*
DLLCALL
inet_addrtop
(
union
xp_sockaddr
*
addr
,
char
*
dest
,
size_t
size
);
DLLEXPORT
uint16_t
DLLCALL
inet_addrport
(
union
xp_sockaddr
*
addr
);
DLLEXPORT
void
DLLCALL
inet_setaddrport
(
union
xp_sockaddr
*
addr
,
uint16_t
port
);
#ifdef __cplusplus
}
...
...
src/xpdev/str_list.c
View file @
a4dac0d9
...
...
@@ -43,7 +43,7 @@
#include "genwrap.h"
/* stricmp */
#include "str_list.h"
str_list_t
strListInit
(
void
)
str_list_t
DLLCALL
strListInit
(
void
)
{
str_list_t
list
;
...
...
@@ -54,7 +54,7 @@ str_list_t strListInit(void)
return
(
list
);
}
size_t
strListCount
(
const
str_list_t
list
)
size_t
DLLCALL
strListCount
(
const
str_list_t
list
)
{
size_t
i
;
...
...
@@ -63,7 +63,7 @@ size_t strListCount(const str_list_t list)
return
(
i
);
}
int
strListIndexOf
(
const
str_list_t
list
,
const
char
*
str
)
int
DLLCALL
strListIndexOf
(
const
str_list_t
list
,
const
char
*
str
)
{
size_t
i
;
...
...
@@ -114,7 +114,7 @@ static char* str_list_insert(str_list_t* list, char* str, size_t index)
return
(
str
);
}
char
*
strListRemove
(
str_list_t
*
list
,
size_t
index
)
char
*
DLLCALL
strListRemove
(
str_list_t
*
list
,
size_t
index
)
{
char
*
str
;
size_t
i
;
...
...
@@ -142,7 +142,7 @@ char* strListRemove(str_list_t* list, size_t index)
return
(
str
);
}
BOOL
strListDelete
(
str_list_t
*
list
,
size_t
index
)
BOOL
DLLCALL
strListDelete
(
str_list_t
*
list
,
size_t
index
)
{
char
*
str
;
...
...
@@ -154,7 +154,7 @@ BOOL strListDelete(str_list_t* list, size_t index)
return
(
TRUE
);
}
char
*
strListReplace
(
const
str_list_t
list
,
size_t
index
,
const
char
*
str
)
char
*
DLLCALL
strListReplace
(
const
str_list_t
list
,
size_t
index
,
const
char
*
str
)
{
char
*
buf
;
size_t
count
;
...
...
@@ -179,7 +179,7 @@ char* strListReplace(const str_list_t list, size_t index, const char* str)
return
(
buf
);
}
BOOL
strListSwap
(
const
str_list_t
list
,
size_t
index1
,
size_t
index2
)
BOOL
DLLCALL
strListSwap
(
const
str_list_t
list
,
size_t
index1
,
size_t
index2
)
{
char
*
tmp
;
size_t
count
;
...
...
@@ -202,7 +202,7 @@ BOOL strListSwap(const str_list_t list, size_t index1, size_t index2)
return
(
TRUE
);
}
char
*
strListAppend
(
str_list_t
*
list
,
const
char
*
str
,
size_t
index
)
char
*
DLLCALL
strListAppend
(
str_list_t
*
list
,
const
char
*
str
,
size_t
index
)
{
char
*
buf
;
...
...
@@ -218,7 +218,7 @@ char* strListAppend(str_list_t* list, const char* str, size_t index)
return
(
str_list_append
(
list
,
buf
,
index
));
}
size_t
strListAppendList
(
str_list_t
*
list
,
const
str_list_t
add_list
)
size_t
DLLCALL
strListAppendList
(
str_list_t
*
list
,
const
str_list_t
add_list
)
{
size_t
i
;
size_t
count
;
...
...
@@ -230,7 +230,7 @@ size_t strListAppendList(str_list_t* list, const str_list_t add_list)
return
(
count
);
}
char
*
strListInsert
(
str_list_t
*
list
,
const
char
*
str
,
size_t
index
)
char
*
DLLCALL
strListInsert
(
str_list_t
*
list
,
const
char
*
str
,
size_t
index
)
{
char
*
buf
;
...
...
@@ -243,7 +243,7 @@ char* strListInsert(str_list_t* list, const char* str, size_t index)
return
(
str_list_insert
(
list
,
buf
,
index
));
}
size_t
strListInsertList
(
str_list_t
*
list
,
const
str_list_t
add_list
,
size_t
index
)
size_t
DLLCALL
strListInsertList
(
str_list_t
*
list
,
const
str_list_t
add_list
,
size_t
index
)
{
size_t
i
;
...
...
@@ -254,7 +254,7 @@ size_t strListInsertList(str_list_t* list, const str_list_t add_list, size_t ind
return
(
i
);
}
str_list_t
strListSplit
(
str_list_t
*
lp
,
char
*
str
,
const
char
*
delimit
)
str_list_t
DLLCALL
strListSplit
(
str_list_t
*
lp
,
char
*
str
,
const
char
*
delimit
)
{
size_t
count
;
char
*
token
;
...
...
@@ -279,7 +279,7 @@ str_list_t strListSplit(str_list_t* lp, char* str, const char* delimit)
return
(
*
lp
);
}
str_list_t
strListSplitCopy
(
str_list_t
*
list
,
const
char
*
str
,
const
char
*
delimit
)
str_list_t
DLLCALL
strListSplitCopy
(
str_list_t
*
list
,
const
char
*
str
,
const
char
*
delimit
)
{
char
*
buf
;
str_list_t
new_list
;
...
...
@@ -300,7 +300,7 @@ str_list_t strListSplitCopy(str_list_t* list, const char* str, const char* delim
return
(
new_list
);
}
size_t
strListMerge
(
str_list_t
*
list
,
str_list_t
add_list
)
size_t
DLLCALL
strListMerge
(
str_list_t
*
list
,
str_list_t
add_list
)
{
size_t
i
;
size_t
count
;
...
...
@@ -312,7 +312,7 @@ size_t strListMerge(str_list_t* list, str_list_t add_list)
return
(
i
);
}
char
*
strListCombine
(
str_list_t
list
,
char
*
buf
,
size_t
maxlen
,
const
char
*
delimit
)
char
*
DLLCALL
strListCombine
(
str_list_t
list
,
char
*
buf
,
size_t
maxlen
,
const
char
*
delimit
)
{
size_t
i
;
char
*
end
;
...
...
@@ -359,27 +359,27 @@ static int QSORT_CALLBACK_TYPE strListCompareAlphaCaseReverse(const void *arg1,
return
strcmp
(
*
(
char
**
)
arg2
,
*
(
char
**
)
arg1
);
}
void
strListSortAlpha
(
str_list_t
list
)
void
DLLCALL
strListSortAlpha
(
str_list_t
list
)
{
qsort
(
list
,
strListCount
(
list
),
sizeof
(
char
*
),
strListCompareAlpha
);
}
void
strListSortAlphaReverse
(
str_list_t
list
)
void
DLLCALL
strListSortAlphaReverse
(
str_list_t
list
)
{
qsort
(
list
,
strListCount
(
list
),
sizeof
(
char
*
),
strListCompareAlphaReverse
);
}
void
strListSortAlphaCase
(
str_list_t
list
)
void
DLLCALL
strListSortAlphaCase
(
str_list_t
list
)
{
qsort
(
list
,
strListCount
(
list
),
sizeof
(
char
*
),
strListCompareAlphaCase
);
}
void
strListSortAlphaCaseReverse
(
str_list_t
list
)
void
DLLCALL
strListSortAlphaCaseReverse
(
str_list_t
list
)
{
qsort
(
list
,
strListCount
(
list
),
sizeof
(
char
*
),
strListCompareAlphaCaseReverse
);
}
str_list_t
strListDup
(
str_list_t
list
)
str_list_t
DLLCALL
strListDup
(
str_list_t
list
)
{
str_list_t
ret
;
size_t
count
=
0
;
...
...
@@ -390,7 +390,7 @@ str_list_t strListDup(str_list_t list)
return
ret
;
}
int
strListCmp
(
str_list_t
list1
,
str_list_t
list2
)
int
DLLCALL
strListCmp
(
str_list_t
list1
,
str_list_t
list2
)
{
str_list_t
l1
=
strListDup
(
list1
);
str_list_t
l2
=
strListDup
(
list2
);
...
...
@@ -420,14 +420,14 @@ int strListCmp(str_list_t list1, str_list_t list2)
return
-
1
;
}
void
strListFreeStrings
(
str_list_t
list
)
void
DLLCALL
strListFreeStrings
(
str_list_t
list
)
{
size_t
i
;
FREE_LIST_ITEMS
(
list
,
i
);
}
void
strListFree
(
str_list_t
*
list
)
void
DLLCALL
strListFree
(
str_list_t
*
list
)
{
if
(
*
list
!=
NULL
)
{
strListFreeStrings
(
*
list
);
...
...
@@ -467,7 +467,7 @@ static str_list_t str_list_read_file(FILE* fp, str_list_t* lp, size_t max_line_l
return
(
*
lp
);
}