Commit e76d4c91 authored by Andreas Gustafsson's avatar Andreas Gustafsson
Browse files

coding style

parent 9d99e3fd
......@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: app.c,v 1.42 2001/03/20 21:45:20 bwelling Exp $ */
/* $Id: app.c,v 1.43 2001/07/09 21:05:57 gson Exp $ */
#include <config.h>
......@@ -255,10 +255,6 @@ isc_app_onrun(isc_mem_t *mctx, isc_task_t *task, isc_taskaction_t action,
isc_task_t *cloned_task = NULL;
isc_result_t result;
/*
* Request delivery of an event when the application is run.
*/
LOCK(&lock);
if (running) {
......@@ -414,10 +410,6 @@ isc_app_run(void) {
int sig;
#endif
/*
* Run an ISC library application.
*/
#ifdef HAVE_LINUXTHREADS
REQUIRE(main_thread == pthread_self());
#endif
......@@ -541,10 +533,6 @@ isc_result_t
isc_app_shutdown(void) {
isc_boolean_t want_kill = ISC_TRUE;
/*
* Request application shutdown.
*/
LOCK(&lock);
REQUIRE(running);
......@@ -584,10 +572,6 @@ isc_result_t
isc_app_reload(void) {
isc_boolean_t want_kill = ISC_TRUE;
/*
* Request application reload.
*/
LOCK(&lock);
REQUIRE(running);
......@@ -626,10 +610,6 @@ isc_app_reload(void) {
void
isc_app_finish(void) {
/*
* Finish an ISC library application.
*/
DESTROYLOCK(&lock);
}
......
......@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: ifiter_ioctl.c,v 1.18 2001/06/04 19:33:33 tale Exp $ */
/* $Id: ifiter_ioctl.c,v 1.19 2001/07/09 21:05:58 gson Exp $ */
/*
* Obtain the list of network interfaces using the SIOCGLIFCONF ioctl.
......@@ -124,7 +124,7 @@ isc_interfaceiter_create(isc_mem_t *mctx, isc_interfaceiter_t **iterp) {
iter->ifc.lifc_buf = iter->buf;
/*
* Ignore the HP/UX warning about "interger overflow during
* conversion. It comes from its own macro definition,
* conversion". It comes from its own macro definition,
* and is really hard to shut up.
*/
if (ioctl(iter->socket, SIOCGLIFCONF, (char *)&iter->ifc)
......
......@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: net.c,v 1.21 2001/07/09 08:07:40 marka Exp $ */
/* $Id: net.c,v 1.22 2001/07/09 21:05:59 gson Exp $ */
#include <config.h>
......@@ -136,22 +136,12 @@ initialize(void) {
isc_result_t
isc_net_probeipv4(void) {
/*
* Check if the system's kernel supports IPv4.
*/
initialize();
return (ipv4_result);
}
isc_result_t
isc_net_probeipv6(void) {
/*
* Check if the system's kernel supports IPv6.
*/
initialize();
return (ipv6_result);
}
......@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: socket.c,v 1.202 2001/06/07 00:21:53 bwelling Exp $ */
/* $Id: socket.c,v 1.203 2001/07/09 21:06:01 gson Exp $ */
#include <config.h>
......@@ -1284,7 +1284,8 @@ isc_socket_create(isc_socketmgr_t *manager, int pf, isc_sockettype_t type,
(void)close(sock->fd);
isc_log_iwrite(isc_lctx, ISC_LOGCATEGORY_GENERAL,
ISC_LOGMODULE_SOCKET, ISC_LOG_ERROR,
isc_msgcat, ISC_MSGSET_SOCKET, ISC_MSG_TOOMANYFDS,
isc_msgcat, ISC_MSGSET_SOCKET,
ISC_MSG_TOOMANYFDS,
"%s: too many open file descriptors", "socket");
free_socket(&sock);
return (ISC_R_NORESOURCES);
......
......@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: time.c,v 1.33 2001/02/24 10:22:20 marka Exp $ */
/* $Id: time.c,v 1.34 2001/07/09 21:06:02 gson Exp $ */
#include <config.h>
......@@ -83,13 +83,6 @@ void
isc_interval_set(isc_interval_t *i,
unsigned int seconds, unsigned int nanoseconds)
{
/*
* Set 'i' to a value representing an interval of 'seconds' seconds
* and 'nanoseconds' nanoseconds, suitable for use in isc_time_add()
* and isc_time_subtract().
*/
REQUIRE(i != NULL);
REQUIRE(nanoseconds < NS_PER_S);
......@@ -99,11 +92,6 @@ isc_interval_set(isc_interval_t *i,
isc_boolean_t
isc_interval_iszero(isc_interval_t *i) {
/*
* Returns ISC_TRUE iff. 'i' is the zero interval.
*/
REQUIRE(i != NULL);
INSIST(i->nanoseconds < NS_PER_S);
......@@ -123,10 +111,6 @@ isc_time_t *isc_time_epoch = &epoch;
void
isc_time_set(isc_time_t *t, unsigned int seconds, unsigned int nanoseconds) {
/*
* Set 't' to a particular number of seconds + nanoseconds since the
* epoch.
*/
REQUIRE(t != NULL);
REQUIRE(nanoseconds < NS_PER_S);
......@@ -136,10 +120,6 @@ isc_time_set(isc_time_t *t, unsigned int seconds, unsigned int nanoseconds) {
void
isc_time_settoepoch(isc_time_t *t) {
/*
* Set 't' to the time of the epoch.
*/
REQUIRE(t != NULL);
t->seconds = 0;
......@@ -148,11 +128,6 @@ isc_time_settoepoch(isc_time_t *t) {
isc_boolean_t
isc_time_isepoch(isc_time_t *t) {
/*
* Returns ISC_TRUE iff. 't' is the epoch ("time zero").
*/
REQUIRE(t != NULL);
INSIST(t->nanoseconds < NS_PER_S);
......@@ -167,10 +142,6 @@ isc_result_t
isc_time_now(isc_time_t *t) {
struct timeval tv;
/*
* Set *t to the current absolute time.
*/
REQUIRE(t != NULL);
if (gettimeofday(&tv, NULL) == -1) {
......@@ -211,10 +182,6 @@ isc_result_t
isc_time_nowplusinterval(isc_time_t *t, isc_interval_t *i) {
struct timeval tv;
/*
* Set *t to the current absolute time + i.
*/
REQUIRE(t != NULL);
REQUIRE(i != NULL);
INSIST(i->nanoseconds < NS_PER_S);
......@@ -262,11 +229,6 @@ isc_time_nowplusinterval(isc_time_t *t, isc_interval_t *i) {
int
isc_time_compare(isc_time_t *t1, isc_time_t *t2) {
/*
* Compare the times referenced by 't1' and 't2'
*/
REQUIRE(t1 != NULL && t2 != NULL);
INSIST(t1->nanoseconds < NS_PER_S && t2->nanoseconds < NS_PER_S);
......@@ -283,10 +245,6 @@ isc_time_compare(isc_time_t *t1, isc_time_t *t2) {
isc_result_t
isc_time_add(isc_time_t *t, isc_interval_t *i, isc_time_t *result) {
/*
* Add 't' to 'i', storing the result in 'result'.
*/
REQUIRE(t != NULL && i != NULL && result != NULL);
INSIST(t->nanoseconds < NS_PER_S && i->nanoseconds < NS_PER_S);
......@@ -312,10 +270,6 @@ isc_time_add(isc_time_t *t, isc_interval_t *i, isc_time_t *result) {
isc_result_t
isc_time_subtract(isc_time_t *t, isc_interval_t *i, isc_time_t *result) {
/*
* Subtract 'i' from 't', storing the result in 'result'.
*/
REQUIRE(t != NULL && i != NULL && result != NULL);
INSIST(t->nanoseconds < NS_PER_S && i->nanoseconds < NS_PER_S);
......
......@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: app.c,v 1.2 2001/07/08 05:08:55 mayer Exp $ */
/* $Id: app.c,v 1.3 2001/07/09 21:06:03 gson Exp $ */
#include <config.h>
......@@ -65,6 +65,7 @@ enum {
RELOAD_EVENT,
SHUTDOWN_EVENT
};
static HANDLE hEvents[NUM_EVENTS];
DWORD dwWaitResult;
......@@ -104,9 +105,6 @@ isc_app_onrun(isc_mem_t *mctx, isc_task_t *task, isc_taskaction_t action,
isc_task_t *cloned_task = NULL;
isc_result_t result;
/*
* Request delivery of an event when the application is run.
*/
LOCK(&lock);
if (running) {
......@@ -140,10 +138,6 @@ isc_app_run(void) {
isc_task_t *task;
HANDLE *pHandles = NULL;
/*
* Run an ISC library application.
*/
REQUIRE(main_thread == GetCurrentThread());
LOCK(&lock);
if (!running) {
......@@ -172,19 +166,21 @@ isc_app_run(void) {
*/
while (!want_shutdown) {
dwWaitResult = WaitForMultipleObjects(NUM_EVENTS,hEvents, FALSE, INFINITE);
/* See why we returned */
dwWaitResult = WaitForMultipleObjects(NUM_EVENTS, hEvents,
FALSE, INFINITE);
/* See why we returned */
if (WaitSucceeded(dwWaitResult, NUM_EVENTS)) {
/*
* The return was due to one of the events being signaled
* The return was due to one of the events
* being signaled
*/
switch (WaitSucceededIndex(dwWaitResult)) {
case RELOAD_EVENT:
want_reload = ISC_TRUE;
break;
case SHUTDOWN_EVENT:
want_shutdown = ISC_TRUE;
break;
......@@ -206,10 +202,6 @@ isc_result_t
isc_app_shutdown(void) {
isc_boolean_t want_kill = ISC_TRUE;
/*
* Request application shutdown.
*/
LOCK(&lock);
REQUIRE(running);
......@@ -219,9 +211,8 @@ isc_app_shutdown(void) {
shutdown_requested = ISC_TRUE;
UNLOCK(&lock);
if (want_kill) {
if (want_kill)
SetEvent(hEvents[SHUTDOWN_EVENT]);
}
return (ISC_R_SUCCESS);
}
......@@ -230,10 +221,6 @@ isc_result_t
isc_app_reload(void) {
isc_boolean_t want_reload = ISC_TRUE;
/*
* Request application reload.
*/
LOCK(&lock);
REQUIRE(running);
......@@ -244,18 +231,14 @@ isc_app_reload(void) {
want_reload = ISC_FALSE;
UNLOCK(&lock);
if (want_reload) {
if (want_reload)
SetEvent(hEvents[RELOAD_EVENT]);
}
return (ISC_R_SUCCESS);
}
void
isc_app_finish(void) {
/*
* Finish an ISC library application.
*/
DESTROYLOCK(&lock);
}
......@@ -270,10 +253,8 @@ isc_app_block(void) {
void
isc_app_unblock(void) {
REQUIRE(running);
REQUIRE(blocked);
blocked = ISC_FALSE;
REQUIRE(blockedthread == GetCurrentThread());
}
......@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: errno2result.c,v 1.2 2001/07/08 05:08:58 mayer Exp $ */
/* $Id: errno2result.c,v 1.3 2001/07/09 21:06:04 gson Exp $ */
#include <config.h>
......@@ -62,11 +62,13 @@ isc__errno2result(int posixerrno) {
return (ISC_R_UNEXPECTED);
}
}
/*
* 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 |
......@@ -74,7 +76,8 @@ char * FormatError(int error) {
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
error,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), /* Default language */
/* Default language */
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR) &lpMsgBuf,
0,
NULL);
......@@ -82,10 +85,12 @@ char * FormatError(int error) {
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 */
/* Copy the error value first in case of other errors */
DWORD errval = err;
/* Get the Winsock2 error messages */
if (errval >= WSABASEERR && errval <= (WSABASEERR + 1015)) {
......@@ -99,14 +104,15 @@ char * __cdecl NTstrMessage(int err) {
*/
if (errval > (DWORD) _sys_nerr) {
return (FormatError(errval));
}
else {
} else {
return (strerror(errval));
}
}
char * __cdecl NTstrerror(int err) {
DWORD errval = err; /* Copy the error value first in case of other errors */
char * __cdecl
NTstrerror(int err) {
/* Copy the error value first in case of other errors */
DWORD errval = err;
return (NTstrMessage(errval));
}
......@@ -114,19 +120,21 @@ char * __cdecl NTstrerror(int err) {
/*
* This is a replacement for perror, but it also reports the error value.
*/
void __cdecl NTperror(char *errmsg) {
int errval = errno; /* Copy the error value first in case of other errors */
void __cdecl
NTperror(char *errmsg) {
/* Copy the error value first in case of other errors */
int errval = errno;
fprintf(stderr, "%s: %s\n", errmsg, NTstrMessage(errval));
}
/*
* This function returns the error string related to Winsock2 errors.
* Return the error string related to Winsock2 errors.
* This function is necessary since FormatMessage knows nothing about them
* and there is no function to get them.
*/
char * GetWSAErrorMessage(int errval) {
char *
GetWSAErrorMessage(int errval) {
char *msg;
switch (errval) {
......@@ -339,8 +347,8 @@ char * GetWSAErrorMessage(int errval) {
* standard error messages
*/
char * GetCryptErrorMessage(int errval) {
char *
GetCryptErrorMessage(int errval) {
char *msg;
switch (errval) {
......@@ -349,64 +357,71 @@ char * GetCryptErrorMessage(int errval) {
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.";
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.";
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.";
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.";
msg = "The provider DLL signature did not verify "
"correctly. Either the DLL or the digital "
"signature has been tampered with.";
break;
case NTE_EXISTS:
msg = "The dwFlags parameter is CRYPT_NEWKEYSET, but the key"
" container already exists.";
break;
case NTE_KEYSET_ENTRY_BAD:
msg = "The Registry entry for the pszContainer key container"
" was found (in the HKEY_CURRENT_USER window), but is"
" corrupt. See the section System Administration for"
" details about CryptoAPI's Registry usage.";
msg = "The Registry entry for the pszContainer key container "
"was found (in the HKEY_CURRENT_USER window), but is "
"corrupt. See the section System Administration for "
" etails about CryptoAPI's Registry usage.";
break;
case NTE_KEYSET_NOT_DEF:
msg = "No Registry entry exists in the HKEY_CURRENT_USER"
" window for the key container specified by pszContainer.";
msg = "No Registry entry exists in the HKEY_CURRENT_USER "
"window for the key container specified by "
"pszContainer.";
break;
case NTE_NO_MEMORY:
msg = "The CSP ran out of memory during the operation.";
break;
case NTE_PROV_DLL_NOT_FOUND:
msg = "The provider DLL file does not exist or is not on the"
" current path.";
msg = "The provider DLL file does not exist or is not on the "
"current path.";
break;
case NTE_PROV_TYPE_ENTRY_BAD:
msg = "The Registry entry for the provider type specified by"
" dwProvType is corrupt. This error may relate to"
" either the user default CSP list or the machine"
" default CSP list. See the section System"
" Administration for details about CryptoAPI's"
" Registry usage.";
msg = "The Registry entry for the provider type specified by "
"dwProvType is corrupt. This error may relate to "
"either the user default CSP list or the machine "
"default CSP list. See the section System "
"Administration for details about CryptoAPI's "
"Registry usage.";
break;
case NTE_PROV_TYPE_NO_MATCH:
msg = "The provider type specified by dwProvType does not"
" match the provider type found in the Registry. Note"
" that this error can only occur when pszProvider"
" specifies an actual CSP name.";
msg = "The provider type specified by dwProvType does not "
"match the provider type found in the Registry. Note "
"that this error can only occur when pszProvider "
"specifies an actual CSP name.";
break;
case NTE_PROV_TYPE_NOT_DEF:
msg = "No Registry entry exists for the provider type"
" specified by dwProvType.";
msg = "No Registry entry exists for the provider type "
"specified by dwProvType.";
break;
case NTE_PROVIDER_DLL_FAIL:
msg = "The provider DLL file could not be loaded, and"
" may not exist. If it exists, then the file is"
" not a valid DLL.";
msg = "The provider DLL file could not be loaded, and "
"may not exist. If it exists, then the file is "
"not a valid DLL.";
break;
case NTE_SIGNATURE_FILE_BAD:
msg = "An error occurred while loading the DLL file image,"
" prior to verifying its signature.";
msg = "An error occurred while loading the DLL file image, "
"prior to verifying its signature.";
break;
default:
......
......@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: errno2result.h,v 1.2 2001/07/08 05:08:59 mayer Exp $ */
/* $Id: errno2result.h,v 1.3 2001/07/09 21:06:05 gson Exp $ */
#ifndef UNIX_ERRNO2RESULT_H
#define UNIX_ERRNO2RESULT_H 1
......@@ -32,10 +32,15 @@ ISC_LANG_BEGINDECLS
isc_result_t
isc__errno2result(int posixerrno);
char * isc_FormatError(int error);
char *
isc_FormatError(int error);
char *
GetWSAErrorMessage(int errval);
char * __cdecl
NTstrerror(int err);
char * GetWSAErrorMessage(int errval);
char * __cdecl NTstrerror(int err);
ISC_LANG_ENDDECLS
#endif /* UNIX_ERRNO2RESULT_H */
......@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: file.c,v 1.10 2001/07/08 05:16:13 mayer Exp $ */
/* $Id: file.c,v 1.11 2001/07/09 21:06:06 gson Exp $ */
#include <config.h>
......@@ -79,12 +79,12 @@ gettemp(char *path, int *doopen) {
for (;;) {
if (doopen) {
if ((*doopen =
open(path, O_CREAT|O_EXCL|O_RDWR, _S_IREAD | _S_IWRITE)) >= 0)
open(path, O_CREAT|O_EXCL|O_RDWR,
_S_IREAD | _S_IWRITE)) >= 0)
return (1);
if (errno != EEXIST)
return (0);
}
else if (stat(path, &sbuf))
} else if (stat(path, &sbuf))
return (errno == ENOENT ? 1 : 0);
/* tricky little algorithm for backward compatibility */
......@@ -130,9 +130,11 @@ file_stats(const char *file, struct stat *stats) {
return (result);
}
/* isc_file_safemovefile is needed to be defined here to ensure that any file with
* the new name is renamed to a backup name and then the rename is done. If all goes
* well then the backup can be deleted, otherwise it gets renamed back.
/*
* isc_file_safemovefile is needed to be defined here to ensure that
</