diff --git a/lib/isc/unix/app.c b/lib/isc/unix/app.c index a0657726aa..a9f7359bb1 100644 --- a/lib/isc/unix/app.c +++ b/lib/isc/unix/app.c @@ -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 @@ -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); } diff --git a/lib/isc/unix/ifiter_ioctl.c b/lib/isc/unix/ifiter_ioctl.c index 2d700bde91..33bfabca77 100644 --- a/lib/isc/unix/ifiter_ioctl.c +++ b/lib/isc/unix/ifiter_ioctl.c @@ -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) diff --git a/lib/isc/unix/net.c b/lib/isc/unix/net.c index 24af6a101e..6de3143ccf 100644 --- a/lib/isc/unix/net.c +++ b/lib/isc/unix/net.c @@ -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 @@ -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); } diff --git a/lib/isc/unix/socket.c b/lib/isc/unix/socket.c index aa4fef13cf..17ae179a0a 100644 --- a/lib/isc/unix/socket.c +++ b/lib/isc/unix/socket.c @@ -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 @@ -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); diff --git a/lib/isc/unix/time.c b/lib/isc/unix/time.c index 683bff20c8..136cf45f22 100644 --- a/lib/isc/unix/time.c +++ b/lib/isc/unix/time.c @@ -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 @@ -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); diff --git a/lib/isc/win32/app.c b/lib/isc/win32/app.c index d0336d9750..b30ffd537b 100644 --- a/lib/isc/win32/app.c +++ b/lib/isc/win32/app.c @@ -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 @@ -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()); } - diff --git a/lib/isc/win32/errno2result.c b/lib/isc/win32/errno2result.c index c1f24700c1..4189320e6c 100644 --- a/lib/isc/win32/errno2result.c +++ b/lib/isc/win32/errno2result.c @@ -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 @@ -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: diff --git a/lib/isc/win32/errno2result.h b/lib/isc/win32/errno2result.h index eae6e638d2..368167cf4a 100644 --- a/lib/isc/win32/errno2result.h +++ b/lib/isc/win32/errno2result.h @@ -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 */ diff --git a/lib/isc/win32/file.c b/lib/isc/win32/file.c index c1022f1791..deb72c9152 100644 --- a/lib/isc/win32/file.c +++ b/lib/isc/win32/file.c @@ -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 @@ -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 + * 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. */ int @@ -172,8 +174,9 @@ isc_file_safemovefile(const char *oldname, const char *newname) { filestatus = MoveFile(oldname, newname); if (filestatus == 0) { - - /* Try and rename the backup back to the original name if the backup got created + /* + * Try to rename the backup back to the original name + * if the backup got created */ if (exists == TRUE) { filestatus = MoveFile(buf, newname); @@ -184,11 +187,11 @@ isc_file_safemovefile(const char *oldname, const char *newname) { return (-1); } - /* Delete the backup file if it got created + /* + * Delete the backup file if it got created */ - if (exists == TRUE) { + if (exists == TRUE) filestatus = DeleteFile(buf); - } return (0); } @@ -288,9 +291,9 @@ isc_file_renameunique(const char *file, char *templet) { isc_result_t result = ISC_R_SUCCESS; fd = mkstemp(templet); - if (fd == -1) { + if (fd == -1) result = isc__errno2result(errno); - } + if (result == ISC_R_SUCCESS) { res = isc_file_safemovefile(file, templet); if (res != 0) { @@ -325,7 +328,6 @@ isc_file_openunique(char *templet, FILE **fp) { result = isc__errno2result(errno); (void)remove(templet); (void)close(fd); - } else *fp = f; } @@ -366,10 +368,13 @@ isc_boolean_t isc_file_isabsolute(const char *filename) { /* - * Look for c:\path\... style or \\computer\shar\path... UNC style file specs + * Look for c:\path\... style or \\computer\shar\path... + * UNC style file specs */ - return ((ISC_TF(filename[1] == ':') && ISC_TF(filename[2] == '\\')) || - (ISC_TF(filename[0] == '\\') && ISC_TF(filename[1] == '\\'))); + return ((ISC_TF(filename[1] == ':') && + ISC_TF(filename[2] == '\\')) || + (ISC_TF(filename[0] == '\\') && + ISC_TF(filename[1] == '\\'))); } isc_boolean_t diff --git a/lib/isc/win32/fsaccess.c b/lib/isc/win32/fsaccess.c index e397694640..ea8755eedb 100644 --- a/lib/isc/win32/fsaccess.c +++ b/lib/isc/win32/fsaccess.c @@ -15,16 +15,16 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: fsaccess.c,v 1.8 2001/07/08 05:09:01 mayer Exp $ */ +/* $Id: fsaccess.c,v 1.9 2001/07/09 21:06:07 gson Exp $ */ /* - * Note that Win32 does not have the concept of files having access and ownership - * bits. The FAT File system only has a readonly flag for everyone and that's - * all. NTFS uses ACL's which is a totally different concept of controlling - * access. + * Note that Win32 does not have the concept of files having access + * and ownership bits. The FAT File system only has a readonly flag + * for everyone and that's all. NTFS uses ACL's which is a totally + * different concept of controlling access. * - * This code needs to be revisited to set up proper access control for NTFS file systems. - * Nothing can be done for FAT file systems. + * This code needs to be revisited to set up proper access control for + * NTFS file systems. Nothing can be done for FAT file systems. */ #include @@ -90,15 +90,16 @@ isc_fsaccess_set(const char *path, isc_fsaccess_t access) { SET_AND_CLEAR(S_IWUSR, S_IWGRP, S_IWOTH); +#ifdef notyet /* * WIN32 doesn't have the concept of execute bits. We leave this here * for when we review this module. - * + */ bits = ISC_FSACCESS_EXECUTE | ISC_FSACCESS_ACCESSCHILD; SET_AND_CLEAR(S_IXUSR, S_IXGRP, S_IXOTH); -*/ +#endif INSIST(access == 0); if (_chmod(path, mode) < 0) diff --git a/lib/isc/win32/include/isc/bind_registry.h b/lib/isc/win32/include/isc/bind_registry.h index 0b5528ff1b..d2afb30a3a 100644 --- a/lib/isc/win32/include/isc/bind_registry.h +++ b/lib/isc/win32/include/isc/bind_registry.h @@ -15,23 +15,26 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: bind_registry.h,v 1.2 2001/07/08 05:09:21 mayer Exp $ */ +/* $Id: bind_registry.h,v 1.3 2001/07/09 21:06:25 gson Exp $ */ #ifndef _BIND_REGISTRY_H #define _BIND_REGISTRY_H /* * BIND makes use of the following Registry keys in various places, especially - * furing startup and installation + * during startup and installation */ #define BIND_SUBKEY "Software\\ISC\\BIND" #define BIND_SESSION "CurrentSession" #define BIND_SESSION_SUBKEY "Software\\ISC\\BIND\\CurrentSession" -#define BIND_UNINSTALL_SUBKEY "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\ISC BIND" +#define BIND_UNINSTALL_SUBKEY \ + "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\ISC BIND" -#define EVENTLOG_APP_SUBKEY "SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application" -#define BIND_MESSAGE_SUBKEY "SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\named" +#define EVENTLOG_APP_SUBKEY \ + "SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application" +#define BIND_MESSAGE_SUBKEY \ + "SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\named" #define BIND_MESSAGE_NAME "named" #define BIND_CONFIGFILE 0 @@ -40,4 +43,4 @@ #define BIND_FOREGROUND 3 #define BIND_PORT 4 -#endif \ No newline at end of file +#endif diff --git a/lib/isc/win32/include/isc/int.h b/lib/isc/win32/include/isc/int.h index 8961cfe0e3..46430c3a8b 100644 --- a/lib/isc/win32/include/isc/int.h +++ b/lib/isc/win32/include/isc/int.h @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: int.h,v 1.9 2001/07/08 05:09:25 mayer Exp $ */ +/* $Id: int.h,v 1.10 2001/07/09 21:06:26 gson Exp $ */ #ifndef ISC_INT_H #define ISC_INT_H 1 @@ -23,7 +23,6 @@ #define _INTEGRAL_MAX_BITS 64 #include - typedef __int8 isc_int8_t; typedef unsigned __int8 isc_uint8_t; typedef __int16 isc_int16_t; diff --git a/lib/isc/win32/include/isc/mutex.h b/lib/isc/win32/include/isc/mutex.h index 0031a8e488..cb168ac3f0 100644 --- a/lib/isc/win32/include/isc/mutex.h +++ b/lib/isc/win32/include/isc/mutex.h @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: mutex.h,v 1.15 2001/07/08 05:09:28 mayer Exp $ */ +/* $Id: mutex.h,v 1.16 2001/07/09 21:06:27 gson Exp $ */ #ifndef ISC_MUTEX_H #define ISC_MUTEX_H 1 @@ -30,9 +30,7 @@ typedef CRITICAL_SECTION isc_mutex_t; /* This definition is here since WINBASE.H omits it for some reason */ WINBASEAPI BOOL WINAPI -TryEnterCriticalSection( - LPCRITICAL_SECTION lpCriticalSection - ); +TryEnterCriticalSection(LPCRITICAL_SECTION lpCriticalSection); #define isc_mutex_init(mp) \ (InitializeCriticalSection((mp)), ISC_R_SUCCESS) diff --git a/lib/isc/win32/include/isc/ntfile.h b/lib/isc/win32/include/isc/ntfile.h index 18628af42e..f728b910cb 100644 --- a/lib/isc/win32/include/isc/ntfile.h +++ b/lib/isc/win32/include/isc/ntfile.h @@ -15,9 +15,10 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: ntfile.h,v 1.2 2001/07/08 05:09:30 mayer Exp $ */ +/* $Id: ntfile.h,v 1.3 2001/07/09 21:06:28 gson Exp $ */ -/* This file has been necessitated by the fact that the iov array is local +/* + * This file has been necessitated by the fact that the iov array is local * to the module, so passing the FILE ptr to a file I/O function in a * different module or DLL will cause the application to fail to find the * I/O channel and the application will terminate. The standard file I/O diff --git a/lib/isc/win32/include/isc/platform.h b/lib/isc/win32/include/isc/platform.h index 3a451e1c3f..205c43b9d9 100644 --- a/lib/isc/win32/include/isc/platform.h +++ b/lib/isc/win32/include/isc/platform.h @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: platform.h,v 1.2 2001/07/08 05:09:33 mayer Exp $ */ +/* $Id: platform.h,v 1.3 2001/07/09 21:06:29 gson Exp $ */ #ifndef ISC_PLATFORM_H #define ISC_PLATFORM_H 1 @@ -23,10 +23,13 @@ /***** ***** Platform-dependent defines. *****/ + #define ISC_PLATFORM_USETHREADS + /*** *** Network. ***/ + #define ISC_PLATFORM_HAVEIPV6 #define ISC_PLATFORM_NEEDPORTT #undef MSG_TRUNC diff --git a/lib/isc/win32/include/isc/stat.h b/lib/isc/win32/include/isc/stat.h index b4dc52aecb..04c9279755 100644 --- a/lib/isc/win32/include/isc/stat.h +++ b/lib/isc/win32/include/isc/stat.h @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: stat.h,v 1.2 2001/07/08 05:09:34 mayer Exp $ */ +/* $Id: stat.h,v 1.3 2001/07/09 21:06:30 gson Exp $ */ #ifndef ISC_STAT_H #define ISC_STAT_H 1 @@ -40,5 +40,4 @@ # define S_ISDIR(m) ((m & S_IFMT) == S_IFDIR) #endif - -#endif /* ISC_STDIO_H */ +#endif /* ISC_STAT_H */ diff --git a/lib/isc/win32/interfaceiter.c b/lib/isc/win32/interfaceiter.c index 238c8f1c7c..97ecd06ad3 100644 --- a/lib/isc/win32/interfaceiter.c +++ b/lib/isc/win32/interfaceiter.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: interfaceiter.c,v 1.2 2001/07/08 05:09:02 mayer Exp $ */ +/* $Id: interfaceiter.c,v 1.3 2001/07/09 21:06:09 gson Exp $ */ /* * Note that this code will need to be revisited to support IPv6 Interfaces. @@ -60,7 +60,8 @@ struct isc_interfaceiter { int socket; INTERFACE_INFO IFData; /* Current Interface Info */ int numIF; /* Current Interface count */ - int totalIF; /* Total Number of Interfaces */ + int totalIF; /* Total Number + of Interfaces */ INTERFACE_INFO *buf; /* Buffer for WSAIoctl data. */ unsigned int bufsize; /* Bytes allocated. */ INTERFACE_INFO *pos; /* Current offset in IF List */ @@ -117,7 +118,8 @@ isc_interfaceiter_create(isc_mem_t *mctx, isc_interfaceiter_t **iterp) { iter->buf = NULL; /* - * Create an unbound datagram socket to do the SIO_GET_INTERFACE_LIST WSAIoctl on. + * Create an unbound datagram socket to do the + * SIO_GET_INTERFACE_LIST WSAIoctl on. */ if ((iter->socket = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { UNEXPECTED_ERROR(__FILE__, __LINE__, @@ -140,9 +142,11 @@ isc_interfaceiter_create(isc_mem_t *mctx, isc_interfaceiter_t **iterp) { goto alloc_failure; } - if (WSAIoctl(iter->socket, SIO_GET_INTERFACE_LIST, 0, 0, iter->buf, iter->bufsize, - &bytesReturned, 0, 0) - == SOCKET_ERROR) { + if (WSAIoctl(iter->socket, SIO_GET_INTERFACE_LIST, + 0, 0, iter->buf, iter->bufsize, + &bytesReturned, 0, 0) + == SOCKET_ERROR) + { error = WSAGetLastError(); if (error != WSAEFAULT && error != WSAENOBUFS) { errno = error; @@ -158,10 +162,12 @@ isc_interfaceiter_create(isc_mem_t *mctx, isc_interfaceiter_t **iterp) { } else { /* * The WSAIoctl succeeded. - * If the number of the returned bytes is the same as the buffer size, - * we will grow it just in case and retry. + * If the number of the returned bytes is the same + * as the buffer size, we will grow it just in + * case and retry. */ - if (bytesReturned > 0 && (bytesReturned < iter->bufsize)) + if (bytesReturned > 0 && + (bytesReturned < iter->bufsize)) break; } if (iter->bufsize >= IFCONF_SIZE_MAX*sizeof(INTERFACE_INFO)) { @@ -173,7 +179,8 @@ isc_interfaceiter_create(isc_mem_t *mctx, isc_interfaceiter_t **iterp) { } isc_mem_put(mctx, iter->buf, iter->bufsize); - iter->bufsize += IFCONF_SIZE_INCREMENT*sizeof(INTERFACE_INFO); + iter->bufsize += IFCONF_SIZE_INCREMENT * + sizeof(INTERFACE_INFO); } /* @@ -213,9 +220,9 @@ isc_interfaceiter_create(isc_mem_t *mctx, isc_interfaceiter_t **iterp) { static isc_result_t internal_current(isc_interfaceiter_t *iter, int family) { - BOOL ifNamed = FALSE; unsigned long flags; + REQUIRE(VALID_IFITER(iter)); REQUIRE(iter->numIF >= 0); @@ -235,21 +242,19 @@ internal_current(isc_interfaceiter_t *iter, int family) { if ((flags & IFF_UP) != 0) iter->current.flags |= INTERFACE_F_UP; - if ((flags & IFF_POINTTOPOINT) != 0) - { + if ((flags & IFF_POINTTOPOINT) != 0) { iter->current.flags |= INTERFACE_F_POINTTOPOINT; sprintf(iter->current.name, "PPP Interface %d", iter->numIF); ifNamed = TRUE; } - if ((flags & IFF_LOOPBACK) != 0) - { + if ((flags & IFF_LOOPBACK) != 0) { iter->current.flags |= INTERFACE_F_LOOPBACK; - sprintf(iter->current.name, "Loopback Interface %d", iter->numIF); + sprintf(iter->current.name, "Loopback Interface %d", + iter->numIF); ifNamed = TRUE; } - /* * If the interface is point-to-point, get the destination address. */ @@ -259,17 +264,14 @@ internal_current(isc_interfaceiter_t *iter, int family) { } if (ifNamed == FALSE) - sprintf(iter->current.name, "TCP/IP Interface %d", iter->numIF); + sprintf(iter->current.name, + "TCP/IP Interface %d", iter->numIF); + /* * Get the network mask. */ switch (family) { case AF_INET: - /* - * Ignore the HP/UX warning about "interger overflow during - * conversion. It comes from its own macro definition, - * and is really hard to shut up. - */ get_addr(family, &iter->current.netmask, (struct sockaddr *)&(iter->IFData.iiNetmask)); break; @@ -289,7 +291,6 @@ internal_current(isc_interfaceiter_t *iter, int family) { */ static isc_result_t internal_next(isc_interfaceiter_t *iter) { - if (iter->numIF >= iter->totalIF) return (ISC_R_NOMORE); @@ -301,9 +302,8 @@ internal_next(isc_interfaceiter_t *iter) { */ if (iter->numIF == 0) - { iter->pos = (INTERFACE_INFO *)(iter->buf + (iter->totalIF)); - } + iter->pos--; if (&(iter->pos) < &(iter->buf)) return (ISC_R_NOMORE); @@ -315,10 +315,6 @@ internal_next(isc_interfaceiter_t *iter) { return (ISC_R_SUCCESS); } -/* - * The remaining code is common to the sysctl and ioctl case. - */ - isc_result_t isc_interfaceiter_current(isc_interfaceiter_t *iter, isc_interface_t *ifdata) { @@ -366,8 +362,7 @@ isc_interfaceiter_next(isc_interfaceiter_t *iter) { } void -isc_interfaceiter_destroy(isc_interfaceiter_t **iterp) -{ +isc_interfaceiter_destroy(isc_interfaceiter_t **iterp) { isc_interfaceiter_t *iter; REQUIRE(iterp != NULL); iter = *iterp; diff --git a/lib/isc/win32/ipv6.c b/lib/isc/win32/ipv6.c index 99867876fa..0e1614f29c 100644 --- a/lib/isc/win32/ipv6.c +++ b/lib/isc/win32/ipv6.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: ipv6.c,v 1.2 2001/07/08 05:09:03 mayer Exp $ */ +/* $Id: ipv6.c,v 1.3 2001/07/09 21:06:10 gson Exp $ */ #define LIBISC_EXTERNAL_DATA __declspec( dllexport ) @@ -23,5 +23,8 @@ #include -LIBISC_EXTERNAL_DATA const struct in6_addr in6addr_any = IN6ADDR_ANY_INIT; -LIBISC_EXTERNAL_DATA const struct in6_addr in6addr_loopback = IN6ADDR_LOOPBACK_INIT; +LIBISC_EXTERNAL_DATA const struct in6_addr in6addr_any = + IN6ADDR_ANY_INIT; + +LIBISC_EXTERNAL_DATA const struct in6_addr in6addr_loopback = + IN6ADDR_LOOPBACK_INIT; diff --git a/lib/isc/win32/keyboard.c b/lib/isc/win32/keyboard.c index 33f19220b3..8b0d14a36f 100644 --- a/lib/isc/win32/keyboard.c +++ b/lib/isc/win32/keyboard.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: keyboard.c,v 1.2 2001/07/08 05:09:04 mayer Exp $ */ +/* $Id: keyboard.c,v 1.3 2001/07/09 21:06:11 gson Exp $ */ #include @@ -49,7 +49,6 @@ isc_keyboard_open(isc_keyboard_t *keyboard) { keyboard->result = ISC_R_SUCCESS; return (ISC_R_SUCCESS); - } isc_result_t diff --git a/lib/isc/win32/net.c b/lib/isc/win32/net.c index 5d1febaf84..53540118f1 100644 --- a/lib/isc/win32/net.c +++ b/lib/isc/win32/net.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: net.c,v 1.2 2001/07/08 05:09:05 mayer Exp $ */ +/* $Id: net.c,v 1.3 2001/07/09 21:06:12 gson Exp $ */ #include @@ -74,7 +74,8 @@ try_proto(int domain) { * Check to see if IPv6 is broken, as is common on Linux. */ len = sizeof(sin6); - if (getsockname(s, (struct sockaddr *)&sin6, (void *)&len) < 0) { + if (getsockname(s, (struct sockaddr *)&sin6, (void *)&len) < 0) + { isc_log_write(isc_lctx, ISC_LOGCATEGORY_GENERAL, ISC_LOGMODULE_SOCKET, ISC_LOG_ERROR, "retrieving the address of an IPv6 " @@ -130,22 +131,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); } diff --git a/lib/isc/win32/ntfile.c b/lib/isc/win32/ntfile.c index fa85fe84f3..e99d0fb35d 100644 --- a/lib/isc/win32/ntfile.c +++ b/lib/isc/win32/ntfile.c @@ -15,9 +15,10 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: ntfile.c,v 1.2 2001/07/08 05:09:08 mayer Exp $ */ +/* $Id: ntfile.c,v 1.3 2001/07/09 21:06:14 gson Exp $ */ -/* This file has been necessitated by the fact that the iov array is local +/* + * This file has been necessitated by the fact that the iov array is local * to the module, so passing the FILE ptr to a file I/O function in a * different module or DLL will cause the application to fail to find the * I/O channel and the application will terminate. The standard file I/O @@ -31,23 +32,21 @@ FILE * isc_ntfile_fopen(const char *filename, const char *mode) { - return (fopen(filename, mode)); } int isc_ntfile_fclose(FILE *f) { - return (fclose(f)); } + int isc_ntfile_fseek(FILE *f, long offset, int whence) { - return (fseek(f, offset, whence)); } + size_t isc_ntfile_fread(void *ptr, size_t size, size_t nmemb, FILE *f) { - return (fread(ptr, size, nmemb, f)); } @@ -61,13 +60,11 @@ isc_ntfile_fwrite(const void *ptr, size_t size, size_t nmemb, FILE *f) { int isc_ntfile_flush(FILE *f) { - return (fflush(f)); } int isc_ntfile_sync(FILE *f) { - return (_commit(_fileno(f))); } @@ -152,6 +149,7 @@ FILE * isc_ntfile_fdopen(int handle, const char *mode) { return (fdopen(handle, mode)); } + /* * open(), close(), read(), write(), fsync() * sockets are file descriptors in UNIX. This is not so in NT diff --git a/lib/isc/win32/ntpaths.c b/lib/isc/win32/ntpaths.c index fa2f8e396e..37eef86218 100644 --- a/lib/isc/win32/ntpaths.c +++ b/lib/isc/win32/ntpaths.c @@ -15,10 +15,10 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: ntpaths.c,v 1.2 2001/07/08 05:09:09 mayer Exp $ */ +/* $Id: ntpaths.c,v 1.3 2001/07/09 21:06:15 gson Exp $ */ /* - * This file fetches the required path information that is specific + * This module fetches the required path information that is specific * to NT systems which can have its configuration and system files * almost anywhere. It can be used to override whatever the application * had previously assigned to the pointer. Basic information about the @@ -45,8 +45,7 @@ static DWORD baseLen = MAX_PATH; static BOOL Initialized = FALSE; void -isc_ntpaths_init() -{ +isc_ntpaths_init() { HKEY hKey; BOOL keyFound = TRUE; @@ -55,8 +54,7 @@ isc_ntpaths_init() != ERROR_SUCCESS) keyFound = FALSE; - if (keyFound == TRUE) - { + if (keyFound == TRUE) { /* Get the named directory */ if (RegQueryValueEx(hKey, "InstallDir", NULL, NULL, (LPBYTE)namedBase, &baseLen) != ERROR_SUCCESS) @@ -94,10 +92,9 @@ isc_ntpaths_init() char * isc_ntpaths_get(int ind) { - - if (!Initialized) { + if (!Initialized) isc_ntpaths_init(); - } + switch (ind) { case NAMED_CONF_PATH: return (ns_confFile); @@ -121,4 +118,3 @@ isc_ntpaths_get(int ind) { return (NULL); } } - diff --git a/lib/isc/win32/once.c b/lib/isc/win32/once.c index ef19d18b54..0dac16934c 100644 --- a/lib/isc/win32/once.c +++ b/lib/isc/win32/once.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: once.c,v 1.8 2001/07/08 05:09:10 mayer Exp $ */ +/* $Id: once.c,v 1.9 2001/07/09 21:06:16 gson Exp $ */ /* Principal Authors: DCL */ @@ -28,9 +28,7 @@ #include isc_result_t -isc_once_do(isc_once_t *controller, void(*function)(void)) - -{ +isc_once_do(isc_once_t *controller, void(*function)(void)) { REQUIRE(controller != NULL && function != NULL); if (controller->status == ISC_ONCE_INIT_NEEDED) { diff --git a/lib/isc/win32/os.c b/lib/isc/win32/os.c index c741575e8f..ddf5751c04 100644 --- a/lib/isc/win32/os.c +++ b/lib/isc/win32/os.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: os.c,v 1.2 2001/07/08 05:09:11 mayer Exp $ */ +/* $Id: os.c,v 1.3 2001/07/09 21:06:17 gson Exp $ */ #include @@ -49,14 +49,12 @@ isc_os_ncpus(void) { unsigned int isc_os_majorversion(void) { - initialize_action(); return ((unsigned int)osVer.dwMajorVersion); } unsigned int isc_os_minorversion(void) { - initialize_action(); return ((unsigned int)osVer.dwMinorVersion); -} \ No newline at end of file +} diff --git a/lib/isc/win32/socket.c b/lib/isc/win32/socket.c index fa2f3b6291..d3dd42e73e 100644 --- a/lib/isc/win32/socket.c +++ b/lib/isc/win32/socket.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: socket.c,v 1.2 2001/07/08 05:09:12 mayer Exp $ */ +/* $Id: socket.c,v 1.3 2001/07/09 21:06:18 gson Exp $ */ #define MAKE_EXTERNAL 1 #include @@ -138,10 +138,9 @@ typedef isc_event_t intev_t; * Message header for recvmsg and sendmsg calls. * Used value-result for recvmsg, value only for sendmsg. */ - struct iovec { - void *iov_base; /* startin address of buffer */ - size_t iov_len; /* size of buffer */ + void *iov_base; /* starting address of buffer */ + size_t iov_len; /* size of buffer */ }; struct msghdr { @@ -262,15 +261,14 @@ long bpipe_written = 0; #define SOCK_DEAD(s) ((s)->references == 0) /* - * The following routines are here to handle Unix emulation until we can rewrite the - * the routines in Winsock2 style. + * The following routines are here to handle Unix emulation until we + * can rewrite the the routines in Winsock2 style. */ /* * Initialize socket services */ -BOOL InitSockets() -{ +BOOL InitSockets() { WORD wVersionRequested; WSADATA wsaData; int err; @@ -279,17 +277,16 @@ BOOL InitSockets() wVersionRequested = MAKEWORD(2, 0); err = WSAStartup(wVersionRequested, &wsaData); - if ( err != 0 ) - { + if ( err != 0 ) { /* Tell the user that we could not find a usable Winsock DLL */ return (FALSE); } -return (TRUE); + return (TRUE); } -int internal_pipe( int filedes[2]) -{ +int +internal_pipe(int filedes[2]) { int status; unsigned int pipesize = 65535; int mode = _O_TEXT; @@ -300,8 +297,7 @@ int internal_pipe( int filedes[2]) } int -internal_sendmsg(int sock, const struct msghdr *msg, int flags) -{ +internal_sendmsg(int sock, const struct msghdr *msg, int flags) { int Error; DWORD BytesSent; DWORD Flags = flags; @@ -317,81 +313,72 @@ internal_sendmsg(int sock, const struct msghdr *msg, int flags) NULL); if (Error == SOCKET_ERROR) { - - BytesSent = -1; - /* There is an error... */ - Error = WSAGetLastError(); - if (Error == WSAEWOULDBLOCK) { + BytesSent = -1; + /* There is an error... */ + Error = WSAGetLastError(); + if (Error == WSAEWOULDBLOCK) { - /* - * WSAEWOULDBLOCK means we have to wait for an FD_WRITE - * before we can send. - */ - errno = EWOULDBLOCK; - - } else if (Error == WSA_IO_PENDING) { - - /* Overlapped send successfully initiated. */ - errno = EAGAIN; - } - else { - - /* An unexpected error occurred. */ - errno = Error; - } + /* + * WSAEWOULDBLOCK means we have to wait for an FD_WRITE + * before we can send. + */ + errno = EWOULDBLOCK; + } else if (Error == WSA_IO_PENDING) { + /* Overlapped send successfully initiated. */ + errno = EAGAIN; + } else { + /* An unexpected error occurred. */ + errno = Error; + } } /* No error -- the I/O request was completed immediately... */ return (BytesSent); - } int -internal_recvmsg(int sock, struct msghdr *msg, int flags) -{ +internal_recvmsg(int sock, struct msghdr *msg, int flags) { DWORD Flags = flags; DWORD NumBytes; int Result; int Error; - isc_buffer_t *b=malloc(256); + isc_buffer_t *b = malloc(256); - Result = WSARecvFrom((SOCKET) sock, - msg->msg_iov, - msg->msg_iovlen, - &NumBytes, - &Flags, - msg->msg_name, - (int *)&(msg->msg_namelen), - NULL, - NULL); + Result = WSARecvFrom((SOCKET) sock, + msg->msg_iov, + msg->msg_iovlen, + &NumBytes, + &Flags, + msg->msg_name, + (int *)&(msg->msg_namelen), + NULL, + NULL); - /* Check for errors. */ - if (Result == SOCKET_ERROR) { - - Error = WSAGetLastError(); + /* Check for errors. */ + if (Result == SOCKET_ERROR) { + Error = WSAGetLastError(); NumBytes = -1; - switch (Error) { + switch (Error) { + case WSAEWOULDBLOCK: + /* + * No data received; return to wait for another + * read event. + */ + errno = EAGAIN; + break; - case WSAEWOULDBLOCK: - - /* No data received; return to wait for another read event. */ - errno = EAGAIN; - break; - - default: - - /* Some other error...hit the panic button. */ - errno = Error; - break; + default: + /* Some other error... hit the panic button. */ + errno = Error; + break; + } } - } - msg->msg_flags = Flags; /* Return the flags received in header */ - - return (NumBytes); - -} /* Internal_recvmsg() */ + msg->msg_flags = Flags; /* Return the flags received in header */ + + return (NumBytes); +} static void manager_log(isc_socketmgr_t *sockmgr, @@ -498,20 +485,21 @@ select_poke(isc_socketmgr_t *mgr, int fd, int msg) { if (cc < 0) FATAL_ERROR(__FILE__, __LINE__, - isc_msgcat_get(isc_msgcat, ISC_MSGSET_SOCKET, + isc_msgcat_get(isc_msgcat, + ISC_MSGSET_SOCKET, ISC_MSG_WRITEFAILED, - "_write() failed " - "during watcher poke: %s"), - strerror(errno)); + "_write() failed " + "during watcher poke: %s"), + strerror(errno)); INSIST(cc == sizeof(buf)); InterlockedIncrement(&bpipe_written); - } - else { + } else { wakeup_socket(mgr, fd, msg); } } + /* * Read a message on the internal fd. */ @@ -532,7 +520,6 @@ select_readmsg(isc_socketmgr_t *mgr, int *fd, int *msg) { "_read() failed " "during watcher poke: %s"), strerror(errno)); - return; } INSIST(cc == sizeof(buf)); @@ -1008,7 +995,8 @@ doio_recv(isc_socket_t *sock, isc_socketevent_t *dev) { socket_log(sock, NULL, IOEVENT, isc_msgcat, ISC_MSGSET_SOCKET, ISC_MSG_DOIORECV, - "doio_recv: internal_recvmsg(%d) %d bytes, err %d/%s", + "doio_recv: internal_recvmsg(%d) %d bytes, " + "err %d/%s", sock->fd, cc, errno, strerror(errno)); #define SOFT_OR_HARD(_system, _isc) \ @@ -3298,4 +3286,3 @@ isc_socket_isbound(isc_socket_t *sock) { return (val); } - diff --git a/lib/isc/win32/syslog.c b/lib/isc/win32/syslog.c index 8292c7b1fb..7720f8f02c 100644 --- a/lib/isc/win32/syslog.c +++ b/lib/isc/win32/syslog.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: syslog.c,v 1.2 2001/07/08 05:09:15 mayer Exp $ */ +/* $Id: syslog.c,v 1.3 2001/07/09 21:06:19 gson Exp $ */ #include @@ -85,7 +85,6 @@ isc_syslog_facilityfromstring(const char *str, int *facilityp) { } } return (ISC_R_NOTFOUND); - } /* diff --git a/lib/isc/win32/syslog.h b/lib/isc/win32/syslog.h index 9207309eb1..b4d62cdb44 100644 --- a/lib/isc/win32/syslog.h +++ b/lib/isc/win32/syslog.h @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: syslog.h,v 1.2 2001/07/08 05:09:16 mayer Exp $ */ +/* $Id: syslog.h,v 1.3 2001/07/09 21:06:20 gson Exp $ */ #ifndef _SYSLOG_H #define _SYSLOG_H @@ -53,13 +53,16 @@ void syslog(int level, const char *fmt, ...); + void openlog(const char *, int, ...); + void closelog(void); void ModifyLogLevel(int level); + void InitNTLogging(FILE *, int); diff --git a/lib/isc/win32/thread.c b/lib/isc/win32/thread.c index 7811613a7c..d38b77854c 100644 --- a/lib/isc/win32/thread.c +++ b/lib/isc/win32/thread.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: thread.c,v 1.16 2001/07/08 05:09:17 mayer Exp $ */ +/* $Id: thread.c,v 1.17 2001/07/09 21:06:21 gson Exp $ */ #include @@ -25,7 +25,8 @@ isc_result_t isc_thread_create(isc_threadfunc_t start, isc_threadarg_t arg, - isc_thread_t *threadp) { + isc_thread_t *threadp) +{ isc_thread_t thread; unsigned int id; @@ -60,9 +61,8 @@ isc_thread_join(isc_thread_t thread, isc_threadresult_t *rp) { void isc_thread_setconcurrency(unsigned int level) { - -/* - * This is unnecessary on Win32 systems, but is here so that the - * call exists - */ + /* + * This is unnecessary on Win32 systems, but is here so that the + * call exists + */ } diff --git a/lib/isc/win32/time.c b/lib/isc/win32/time.c index bb4bb2be91..8f039a0998 100644 --- a/lib/isc/win32/time.c +++ b/lib/isc/win32/time.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: time.c,v 1.22 2001/07/08 05:09:18 mayer Exp $ */ +/* $Id: time.c,v 1.23 2001/07/09 21:06:22 gson Exp $ */ /* * Windows has a different epoch than Unix. Therefore this code sets the epoch @@ -66,9 +66,10 @@ TimetToFileTime(time_t t, LPFILETIME pft) { LONGLONG i; i = Int32x32To64(t, 10000000) + 116444736000000000; - pft->dwLowDateTime = (DWORD) i; - pft->dwHighDateTime = (DWORD) (i >>32); + pft->dwLowDateTime = (DWORD) i; + pft->dwHighDateTime = (DWORD) (i >>32); } + /*** *** Intervals ***/ @@ -77,15 +78,9 @@ static isc_interval_t zero_interval = { 0 }; isc_interval_t *isc_interval_zero = &zero_interval; 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(). - */ - +isc_interval_set(isc_interval_t *i, unsigned int seconds, + unsigned int nanoseconds) +{ REQUIRE(i != NULL); REQUIRE(nanoseconds < NS_PER_S); @@ -95,11 +90,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); if (i->interval == 0) return (ISC_TRUE); @@ -112,10 +102,6 @@ void isc_time_set(isc_time_t *t, unsigned int seconds, unsigned int nanoseconds) { ULARGE_INTEGER i; - /* - * Set 't' to a particular number of seconds + nanoseconds since the - * epoch. - */ REQUIRE(t != NULL); REQUIRE(nanoseconds < NS_PER_S); @@ -134,10 +120,6 @@ isc_time_initepoch() { void isc_time_settoepoch(isc_time_t *t) { - /* - * Set 't' to the time of the epoch. - */ - REQUIRE(t != NULL); t->absolute.dwLowDateTime = epoch.absolute.dwLowDateTime; @@ -146,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); if (t->absolute.dwLowDateTime == epoch.absolute.dwLowDateTime && @@ -162,11 +139,7 @@ isc_time_isepoch(isc_time_t *t) { isc_result_t isc_time_now(isc_time_t *t) { - char dtime[10]; - /* - * Set *t to the current absolute time. - */ REQUIRE(t != NULL); @@ -180,10 +153,6 @@ isc_result_t isc_time_nowplusinterval(isc_time_t *t, isc_interval_t *i) { ULARGE_INTEGER i1; - /* - * Set *t to the current absolute time + i. - */ - REQUIRE(t != NULL); REQUIRE(i != NULL); @@ -205,10 +174,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); return ((int)CompareFileTime(&t1->absolute, &t2->absolute)); @@ -218,10 +183,6 @@ isc_result_t isc_time_add(isc_time_t *t, isc_interval_t *i, isc_time_t *result) { ULARGE_INTEGER i1; - /* - * Add 't' to 'i', storing the result in 'result'. - */ - REQUIRE(t != NULL && i != NULL && result != NULL); i1.LowPart = t->absolute.dwLowDateTime; @@ -242,10 +203,6 @@ isc_result_t isc_time_subtract(isc_time_t *t, isc_interval_t *i, isc_time_t *result) { ULARGE_INTEGER i1; - /* - * Subtract 'i' from 't', storing the result in 'result'. - */ - REQUIRE(t != NULL && i != NULL && result != NULL); i1.LowPart = t->absolute.dwLowDateTime; @@ -286,9 +243,9 @@ isc_time_microdiff(isc_time_t *t1, isc_time_t *t2) { } /* - * Note that the value returned is the seconds relative to the Unix epoch rather than - * the seconds since Windows epoch. - * This is for compatibility with the Unix side. + * Note that the value returned is the seconds relative to the Unix + * epoch rather than the seconds since Windows epoch. This is for + * compatibility with the Unix side. */ isc_uint32_t isc_time_seconds(isc_time_t *t) { @@ -296,8 +253,10 @@ isc_time_seconds(isc_time_t *t) { REQUIRE(t != NULL); - i.LowPart = t->absolute.dwLowDateTime - epoch.absolute.dwLowDateTime; - i.HighPart = t->absolute.dwHighDateTime - epoch.absolute.dwHighDateTime; + i.LowPart = t->absolute.dwLowDateTime - + epoch.absolute.dwLowDateTime; + i.HighPart = t->absolute.dwHighDateTime - + epoch.absolute.dwHighDateTime; return ((isc_uint32_t)(i.QuadPart / INTERVALS_PER_S)); } diff --git a/lib/isc/win32/unistd.h b/lib/isc/win32/unistd.h index a1a7c341d2..c5683b90e4 100644 --- a/lib/isc/win32/unistd.h +++ b/lib/isc/win32/unistd.h @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: unistd.h,v 1.2 2001/07/08 05:09:19 mayer Exp $ */ +/* $Id: unistd.h,v 1.3 2001/07/09 21:06:23 gson Exp $ */ /* None of these are defined in NT, so define them for our use */ #define O_NONBLOCK 1 @@ -33,6 +33,6 @@ */ #undef F_DUPFD -int fcntl(int, int,...); -#include +int fcntl(int, int, ...); +#include