Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ISC Open Source Projects
BIND
Commits
68c2ccc9
Commit
68c2ccc9
authored
Jul 08, 2001
by
Danny Mayer
Browse files
code style cleanup
parent
0a2d5c99
Changes
26
Hide whitespace changes
Inline
Side-by-side
lib/isc/win32/DLLMain.c
View file @
68c2ccc9
...
...
@@ -15,48 +15,51 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: DLLMain.c,v 1.
1
2001/07/0
6
05:
20:33
mayer Exp $ */
/* $Id: DLLMain.c,v 1.
2
2001/07/0
8
05:
08:54
mayer Exp $ */
#include <windows.h>
#include <stdio.h>
BOOL
InitSockets
(
void
);
void
isc_time_initepoch
();
//__declspec(dllexport) extern FILE (*__imp__iob)[];
/*
* Called when we enter the DLL
*/
__declspec
(
dllexport
)
BOOL
WINAPI
DllMain
(
HINSTANCE
hinstDLL
,
DWORD
fdwReason
,
LPVOID
lpvReserved
)
__declspec
(
dllexport
)
BOOL
WINAPI
DllMain
(
HINSTANCE
hinstDLL
,
DWORD
fdwReason
,
LPVOID
lpvReserved
)
{
switch
(
fdwReason
)
{
// The DLL is loading due to process
// initialization or a call to LoadLibrary.
case
DLL_PROCESS_ATTACH
:
if
(
!
InitSockets
())
return
(
FALSE
);
isc_time_initepoch
();
break
;
switch
(
fdwReason
)
{
/*
* The DLL is loading due to process
* initialization or a call to LoadLibrary.
*/
case
DLL_PROCESS_ATTACH
:
if
(
!
InitSockets
())
return
(
FALSE
);
isc_time_initepoch
();
break
;
/
/
The attached process creates a new thread.
case
DLL_THREAD_ATTACH
:
break
;
/
*
The attached process creates a new thread.
*/
case
DLL_THREAD_ATTACH
:
break
;
/
/
The thread of the attached process terminates.
case
DLL_THREAD_DETACH
:
break
;
/
*
The thread of the attached process terminates.
*/
case
DLL_THREAD_DETACH
:
break
;
// The DLL is unloading from a process due to
// process termination or a call to FreeLibrary.
case
DLL_PROCESS_DETACH
:
break
;
/*
* The DLL is unloading from a process due to
* process termination or a call to FreeLibrary.
*/
case
DLL_PROCESS_DETACH
:
break
;
default:
break
;
default:
break
;
}
return
(
TRUE
);
return
(
TRUE
);
}
lib/isc/win32/app.c
View file @
68c2ccc9
...
...
@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: app.c,v 1.
1
2001/07/0
6
05:
21:44
mayer Exp $ */
/* $Id: app.c,v 1.
2
2001/07/0
8
05:
08:55
mayer Exp $ */
#include <config.h>
...
...
@@ -41,7 +41,7 @@
#include <isc/thread.h>
static
isc_eventlist_t
on_run
;
static
isc_mutex_t
lock
;
static
isc_mutex_t
lock
;
static
isc_boolean_t
shutdown_requested
=
ISC_FALSE
;
static
isc_boolean_t
running
=
ISC_FALSE
;
/*
...
...
@@ -55,9 +55,9 @@ static isc_boolean_t want_reload = ISC_FALSE;
static
isc_boolean_t
blocked
=
ISC_FALSE
;
static
isc_thread_t
blockedthread
;
static
isc_thread_t
blockedthread
;
/
/
Events to wait for
/
*
Events to wait for
*/
#define NUM_EVENTS 2
...
...
@@ -71,7 +71,7 @@ DWORD dwWaitResult;
/*
* We need to remember which thread is the main thread...
*/
static
isc_thread_t
main_thread
;
static
isc_thread_t
main_thread
;
isc_result_t
isc_app_start
(
void
)
{
...
...
@@ -87,10 +87,10 @@ isc_app_start(void) {
if
(
result
!=
ISC_R_SUCCESS
)
return
(
result
);
/
/
Create the reload event in a non-signaled state
/
*
Create the reload event in a non-signaled state
*/
hEvents
[
RELOAD_EVENT
]
=
CreateEvent
(
NULL
,
FALSE
,
FALSE
,
NULL
);
/
/
Create the shutdown event in a non-signaled state
/
*
Create the shutdown event in a non-signaled state
*/
hEvents
[
SHUTDOWN_EVENT
]
=
CreateEvent
(
NULL
,
FALSE
,
FALSE
,
NULL
);
ISC_LIST_INIT
(
on_run
);
...
...
@@ -99,8 +99,7 @@ isc_app_start(void) {
isc_result_t
isc_app_onrun
(
isc_mem_t
*
mctx
,
isc_task_t
*
task
,
isc_taskaction_t
action
,
void
*
arg
)
{
void
*
arg
)
{
isc_event_t
*
event
;
isc_task_t
*
cloned_task
=
NULL
;
isc_result_t
result
;
...
...
@@ -175,13 +174,13 @@ isc_app_run(void) {
while
(
!
want_shutdown
)
{
dwWaitResult
=
WaitForMultipleObjects
(
NUM_EVENTS
,
hEvents
,
FALSE
,
INFINITE
);
/
/
See why we returned
/
*
See why we returned
*/
if
(
WaitSucceeded
(
dwWaitResult
,
NUM_EVENTS
))
{
if
(
WaitSucceeded
(
dwWaitResult
,
NUM_EVENTS
))
{
/*
* The return was due to one of the events being signaled
*/
switch
(
WaitSucceededIndex
(
dwWaitResult
))
{
switch
(
WaitSucceededIndex
(
dwWaitResult
))
{
case
RELOAD_EVENT
:
want_reload
=
ISC_TRUE
;
break
;
...
...
lib/isc/win32/condition.c
View file @
68c2ccc9
...
...
@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: condition.c,v 1.1
6
2001/07/0
6
05:0
5
:5
1
mayer Exp $ */
/* $Id: condition.c,v 1.1
7
2001/07/0
8
05:0
8
:5
6
mayer Exp $ */
#include <config.h>
...
...
@@ -131,8 +131,7 @@ isc_condition_wait(isc_condition_t *cond, isc_mutex_t *mutex) {
isc_result_t
isc_condition_waituntil
(
isc_condition_t
*
cond
,
isc_mutex_t
*
mutex
,
isc_time_t
*
t
)
{
isc_time_t
*
t
)
{
DWORD
milliseconds
;
isc_uint64_t
microseconds
;
isc_time_t
now
;
...
...
lib/isc/win32/entropy.c
View file @
68c2ccc9
...
...
@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: entropy.c,v 1.
2
2001/07/0
6
05:
22:46
mayer Exp $ */
/* $Id: entropy.c,v 1.
3
2001/07/0
8
05:
08:57
mayer Exp $ */
/*
* This is the system depenedent part of the ISC entropy API.
...
...
@@ -57,7 +57,7 @@ get_from_filesource(isc_entropysource_t *source, isc_uint32_t desired) {
added
=
0
;
while
(
desired
>
0
)
{
ndesired
=
ISC_MIN
(
desired
,
sizeof
(
buf
));
if
(
!
CryptGenRandom
(
hcryptprov
,
ndesired
,
buf
))
{
if
(
!
CryptGenRandom
(
hcryptprov
,
ndesired
,
buf
))
{
CryptReleaseContext
(
hcryptprov
,
0
);
source
->
bad
=
ISC_TRUE
;
goto
out
;
...
...
@@ -248,11 +248,11 @@ isc_entropy_createfilesource(isc_entropy_t *ent, const char *fname) {
*/
err
=
CryptAcquireContext
(
&
hcryptprov
,
NULL
,
NULL
,
PROV_RSA_FULL
,
CRYPT_VERIFYCONTEXT
);
if
(
!
err
){
if
(
!
err
){
errval
=
GetLastError
();
ret
=
ISC_R_IOERROR
;
goto
errout
;
}
ret
=
ISC_R_IOERROR
;
goto
errout
;
}
source
=
isc_mem_get
(
ent
->
mctx
,
sizeof
(
isc_entropysource_t
));
if
(
source
==
NULL
)
{
...
...
lib/isc/win32/errno2result.c
View file @
68c2ccc9
...
...
@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: errno2result.c,v 1.
1
2001/07/0
6
05:
23
:58 mayer Exp $ */
/* $Id: errno2result.c,v 1.
2
2001/07/0
8
05:
08
:58 mayer Exp $ */
#include <config.h>
...
...
@@ -66,8 +66,7 @@ isc__errno2result(int posixerrno) {
* Note this will cause a memory leak unless the memory allocated here
* is freed by calling LocalFree
*/
char
*
FormatError
(
int
error
)
{
char
*
FormatError
(
int
error
)
{
LPVOID
lpMsgBuf
;
FormatMessage
(
FORMAT_MESSAGE_ALLOCATE_BUFFER
|
...
...
@@ -75,39 +74,37 @@ char * FormatError(int error)
FORMAT_MESSAGE_IGNORE_INSERTS
,
NULL
,
error
,
MAKELANGID
(
LANG_NEUTRAL
,
SUBLANG_DEFAULT
),
/
/
Default language
MAKELANGID
(
LANG_NEUTRAL
,
SUBLANG_DEFAULT
),
/
*
Default language
*/
(
LPTSTR
)
&
lpMsgBuf
,
0
,
NULL
);
return
(
lpMsgBuf
);
return
(
lpMsgBuf
);
}
char
*
__cdecl
NTstrMessage
(
int
err
)
{
char
*
__cdecl
NTstrMessage
(
int
err
)
{
char
*
retmsg
=
NULL
;
DWORD
errval
=
err
;
/* Copy the error value first in case of other errors */
/* Get the Winsock2 error messages */
if
(
errval
>=
WSABASEERR
&&
errval
<=
(
WSABASEERR
+
1015
))
{
if
(
errval
>=
WSABASEERR
&&
errval
<=
(
WSABASEERR
+
1015
))
{
retmsg
=
GetWSAErrorMessage
(
errval
);
if
(
retmsg
!=
NULL
)
return
(
retmsg
);
if
(
retmsg
!=
NULL
)
return
(
retmsg
);
}
/*
* If it's not one of the standard Unix error codes,
* try a system error message
*/
if
(
errval
>
(
DWORD
)
_sys_nerr
)
{
if
(
errval
>
(
DWORD
)
_sys_nerr
)
{
return
(
FormatError
(
errval
));
}
else
{
return
(
strerror
(
errval
));
return
(
strerror
(
errval
));
}
}
char
*
__cdecl
NTstrerror
(
int
err
)
{
char
*
__cdecl
NTstrerror
(
int
err
)
{
DWORD
errval
=
err
;
/* Copy the error value first in case of other errors */
...
...
@@ -117,12 +114,10 @@ char * __cdecl NTstrerror(int err)
/*
* This is a replacement for perror, but it also reports the error value.
*/
void
__cdecl
NTperror
(
char
*
errmsg
)
{
void
__cdecl
NTperror
(
char
*
errmsg
)
{
int
errval
=
errno
;
/* Copy the error value first in case of other errors */
fprintf
(
stderr
,
"%s: %s
\n
"
,
errmsg
,
NTstrMessage
(
errval
));
}
/*
* This function returns the error string related to Winsock2 errors.
...
...
@@ -134,159 +129,209 @@ char * GetWSAErrorMessage(int errval) {
char
*
msg
;
switch
(
errval
)
{
switch
(
errval
)
{
case
WSAEINTR
:
msg
=
"Interrupted system call"
;
break
;
case
WSAEINTR
:
msg
=
"Interrupted system call"
;
break
;
case
WSAEBADF
:
msg
=
"Bad file number"
;
break
;
case
WSAEBADF
:
msg
=
"Bad file number"
;
break
;
case
WSAEACCES
:
msg
=
"Permission denied"
;
break
;
case
WSAEACCES
:
msg
=
"Permission denied"
;
break
;
case
WSAEFAULT
:
msg
=
"Bad address"
;
break
;
case
WSAEFAULT
:
msg
=
"Bad address"
;
break
;
case
WSAEINVAL
:
msg
=
"Invalid argument"
;
break
;
case
WSAEINVAL
:
msg
=
"Invalid argument"
;
break
;
case
WSAEMFILE
:
msg
=
"Too many open sockets"
;
break
;
case
WSAEMFILE
:
msg
=
"Too many open sockets"
;
break
;
case
WSAEWOULDBLOCK
:
msg
=
"Operation would block"
;
break
;
case
WSAEWOULDBLOCK
:
msg
=
"Operation would block"
;
break
;
case
WSAEINPROGRESS
:
msg
=
"Operation now in progress"
;
break
;
case
WSAEINPROGRESS
:
msg
=
"Operation now in progress"
;
break
;
case
WSAEALREADY
:
msg
=
"Operation already in progress"
;
break
;
case
WSAEALREADY
:
msg
=
"Operation already in progress"
;
break
;
case
WSAENOTSOCK
:
msg
=
"Socket operation on non-socket"
;
break
;
case
WSAENOTSOCK
:
msg
=
"Socket operation on non-socket"
;
break
;
case
WSAEDESTADDRREQ
:
msg
=
"Destination address required"
;
break
;
case
WSAEDESTADDRREQ
:
msg
=
"Destination address required"
;
break
;
case
WSAEMSGSIZE
:
msg
=
"Message too long"
;
break
;
case
WSAEMSGSIZE
:
msg
=
"Message too long"
;
break
;
case
WSAEPROTOTYPE
:
msg
=
"Protocol wrong type for socket"
;
break
;
case
WSAEPROTOTYPE
:
msg
=
"Protocol wrong type for socket"
;
break
;
case
WSAENOPROTOOPT
:
msg
=
"Bad protocol option"
;
break
;
case
WSAENOPROTOOPT
:
msg
=
"Bad protocol option"
;
break
;
case
WSAEPROTONOSUPPORT
:
msg
=
"Protocol not supported"
;
break
;
case
WSAEPROTONOSUPPORT
:
msg
=
"Protocol not supported"
;
break
;
case
WSAESOCKTNOSUPPORT
:
msg
=
"Socket type not supported"
;
break
;
case
WSAESOCKTNOSUPPORT
:
msg
=
"Socket type not supported"
;
break
;
case
WSAEOPNOTSUPP
:
msg
=
"Operation not supported on socket"
;
break
;
case
WSAEOPNOTSUPP
:
msg
=
"Operation not supported on socket"
;
break
;
case
WSAEPFNOSUPPORT
:
msg
=
"Protocol family not supported"
;
break
;
case
WSAEPFNOSUPPORT
:
msg
=
"Protocol family not supported"
;
break
;
case
WSAEAFNOSUPPORT
:
msg
=
"Address family not supported"
;
break
;
case
WSAEAFNOSUPPORT
:
msg
=
"Address family not supported"
;
break
;
case
WSAEADDRINUSE
:
msg
=
"Address already in use"
;
break
;
case
WSAEADDRINUSE
:
msg
=
"Address already in use"
;
break
;
case
WSAEADDRNOTAVAIL
:
msg
=
"Can't assign requested address"
;
break
;
case
WSAEADDRNOTAVAIL
:
msg
=
"Can't assign requested address"
;
break
;
case
WSAENETDOWN
:
msg
=
"Network is down"
;
break
;
case
WSAENETDOWN
:
msg
=
"Network is down"
;
break
;
case
WSAENETUNREACH
:
msg
=
"Network is unreachable"
;
break
;
case
WSAENETUNREACH
:
msg
=
"Network is unreachable"
;
break
;
case
WSAENETRESET
:
msg
=
"Net connection reset"
;
break
;
case
WSAENETRESET
:
msg
=
"Net connection reset"
;
break
;
case
WSAECONNABORTED
:
msg
=
"Software caused connection abort"
;
break
;
case
WSAECONNABORTED
:
msg
=
"Software caused connection abort"
;
break
;
case
WSAECONNRESET
:
msg
=
"Connection reset by peer"
;
break
;
case
WSAECONNRESET
:
msg
=
"Connection reset by peer"
;
break
;
case
WSAENOBUFS
:
msg
=
"No buffer space available"
;
break
;
case
WSAENOBUFS
:
msg
=
"No buffer space available"
;
break
;
case
WSAEISCONN
:
msg
=
"Socket is already connected"
;
break
;
case
WSAEISCONN
:
msg
=
"Socket is already connected"
;
break
;
case
WSAENOTCONN
:
msg
=
"Socket is not connected"
;
break
;
case
WSAENOTCONN
:
msg
=
"Socket is not connected"
;
break
;
case
WSAESHUTDOWN
:
msg
=
"Can't send after socket shutdown"
;
break
;
case
WSAESHUTDOWN
:
msg
=
"Can't send after socket shutdown"
;
break
;
case
WSAETOOMANYREFS
:
msg
=
"Too many references: can't splice"
;
break
;
case
WSAETOOMANYREFS
:
msg
=
"Too many references: can't splice"
;
break
;
case
WSAETIMEDOUT
:
msg
=
"Connection timed out"
;
break
;
case
WSAETIMEDOUT
:
msg
=
"Connection timed out"
;
break
;
case
WSAECONNREFUSED
:
msg
=
"Connection refused"
;
break
;
case
WSAECONNREFUSED
:
msg
=
"Connection refused"
;
break
;
case
WSAELOOP
:
msg
=
"Too many levels of symbolic links"
;
break
;
case
WSAELOOP
:
msg
=
"Too many levels of symbolic links"
;
break
;
case
WSAENAMETOOLONG
:
msg
=
"File name too long"
;
break
;
case
WSAENAMETOOLONG
:
msg
=
"File name too long"
;
break
;
case
WSAEHOSTDOWN
:
msg
=
"Host is down"
;
break
;
case
WSAEHOSTDOWN
:
msg
=
"Host is down"
;
break
;
case
WSAEHOSTUNREACH
:
msg
=
"No route to host"
;
break
;
case
WSAEHOSTUNREACH
:
msg
=
"No route to host"
;
break
;
case
WSAENOTEMPTY
:
msg
=
"Directory not empty"
;
break
;
case
WSAENOTEMPTY
:
msg
=
"Directory not empty"
;
break
;
case
WSAEPROCLIM
:
msg
=
"Too many processes"
;
break
;
case
WSAEPROCLIM
:
msg
=
"Too many processes"
;
break
;
case
WSAEUSERS
:
msg
=
"Too many users"
;
break
;
case
WSAEUSERS
:
msg
=
"Too many users"
;
break
;
case
WSAEDQUOT
:
msg
=
"Disc quota exceeded"
;
break
;
case
WSAEDQUOT
:
msg
=
"Disc quota exceeded"
;
break
;
case
WSAESTALE
:
msg
=
"Stale NFS file handle"
;
break
;
case
WSAESTALE
:
msg
=
"Stale NFS file handle"
;
break
;
case
WSAEREMOTE
:
msg
=
"Too many levels of remote in path"
;
break
;
case
WSAEREMOTE
:
msg
=
"Too many levels of remote in path"
;
break
;
case
WSASYSNOTREADY
:
msg
=
"Network system is unavailable"
;
break
;
case
WSASYSNOTREADY
:
msg
=
"Network system is unavailable"
;
break
;
case
WSAVERNOTSUPPORTED
:
msg
=
"Winsock version out of range"
;
break
;
case
WSAVERNOTSUPPORTED
:
msg
=
"Winsock version out of range"
;
break
;
case
WSANOTINITIALISED
:
msg
=
"WSAStartup not yet called"
;
break
;
case
WSANOTINITIALISED
:
msg
=
"WSAStartup not yet called"
;
break
;
case
WSAEDISCON
:
msg
=
"Graceful shutdown in progress"
;
break
;
case
WSAEDISCON
:
msg
=
"Graceful shutdown in progress"
;
break
;
/*
case WSAHOST_NOT_FOUND: msg = "Host not found";
break;
case WSAHOST_NOT_FOUND:
msg = "Host not found";
break;
case WSANO_DATA: msg = "No host data of that type was found";
break;
case WSANO_DATA:
msg = "No host data of that type was found";
break;
*/
default:
msg
=
NULL
;
break
;
default:
msg
=
NULL
;
break
;
}
return
msg
;
return
(
msg
)
;
}
/*
...
...
@@ -298,56 +343,75 @@ char * GetCryptErrorMessage(int errval) {
char
*
msg
;
switch
(
errval
)
{
switch
(
errval
)
{
case
NTE_BAD_FLAGS
:
msg
=
"The dwFlags parameter has an illegal value."
;
break
;
msg
=
"The dwFlags parameter has an illegal value."
;
break
;
case
NTE_BAD_KEYSET
:
msg
=
"The Registry entry for the key container could not be opened and may not exist."
;
break
;
msg
=
"The Registry entry for the key container could not be opened and may not exist."
;
break
;
case
NTE_BAD_KEYSET_PARAM
:
msg
=
"The pszContainer or pszProvider parameter is set to an illegal value."
;
break
;
msg
=
"The pszContainer or pszProvider parameter is set to an illegal value."
;
break
;
case
NTE_BAD_PROV_TYPE
:
msg
=
"The value of the dwProvType parameter is out of range. All provider types must be from 1 to 999, inclusive."
;
break
;
msg
=
"The value of the dwProvType parameter is out of range. All provider types must be from 1 to 999, inclusive."
;
break
;
case
NTE_BAD_SIGNATURE
:
msg
=
"The provider DLL signature did not verify correctly. Either the DLL or the digital signature has been tampered with."
;
break
;
msg
=
"The provider DLL signature did not verify correctly. Either the DLL or the digital signature has been tampered with."
;
break
;