? woutsup.h
Index: cygserver.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/cygserver.cc,v
retrieving revision 1.4
diff -u -w -u -r1.4 cygserver.cc
--- cygserver.cc	15 Mar 2002 21:52:05 -0000	1.4
+++ cygserver.cc	10 Jun 2002 19:42:07 -0000
@@ -10,6 +10,8 @@
    Cygwin license.  Please consult the file "CYGWIN_LICENSE" for
    details. */
 
+#include "woutsup.h"
+
 #include <errno.h>
 #include <stdio.h>
 #include <unistd.h>
@@ -19,7 +21,6 @@
 #include <netdb.h>
 #include <signal.h>
 #include <stdlib.h>
-#include "wincap.h"
 #include "cygwin_version.h"
 
 #include "getopt.h"
@@ -32,10 +33,6 @@
 #include "cygwin/cygserver.h"
 #include "cygserver_shm.h"
 
-/* for quieter operation, set to 0 */
-#define DEBUG 0
-#define debug_printf if (DEBUG) printf
-
 GENERIC_MAPPING access_mapping;
 static class transport_layer_base *transport;
 
@@ -51,14 +48,14 @@
   rc = OpenProcessToken (GetCurrentProcess() , TOKEN_ALL_ACCESS , &hToken) ;
   if (!rc)
     {
-      printf ("error opening process token (%lu)\n", GetLastError ());
+      system_printf ("error opening process token (%lu)", GetLastError ());
       ret_val = FALSE;
       goto out;
     }
   rc = LookupPrivilegeValue (NULL, SE_DEBUG_NAME, &sPrivileges.Privileges[0].Luid);
   if (!rc)
     {
-      printf ("error getting prigilege luid (%lu)\n", GetLastError ());
+      system_printf ("error getting privilege luid (%lu)", GetLastError ());
       ret_val = FALSE;
       goto out;
     }
@@ -67,7 +64,7 @@
   rc = AdjustTokenPrivileges (hToken, FALSE, &sPrivileges, 0, NULL, NULL) ;
   if (!rc)
     {
-      printf ("error adjusting prigilege level. (%lu)\n", GetLastError ());
+      system_printf ("error adjusting privilege level. (%lu)", GetLastError ());
       ret_val = FALSE;
       goto out;
     }
@@ -108,7 +105,7 @@
 			0, bInheritHandle,
 			DUPLICATE_SAME_ACCESS))
     {
-      printf ("error getting handle(%u) to server (%lu)\n", (unsigned int)from_handle, GetLastError ());
+	  system_printf ("error getting handle(%u) to server (%lu)", (unsigned int)from_handle, GetLastError ());
       goto out;
     }
 } else
@@ -118,7 +115,7 @@
 				OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION	| DACL_SECURITY_INFORMATION,
 				sd, sizeof (sd_buf), &bytes_needed))
     {
-      printf ("error getting handle SD (%lu)\n", GetLastError ());
+      system_printf ("error getting handle SD (%lu)", GetLastError ());
       goto out;
     }
 
@@ -127,13 +124,13 @@
   if (!AccessCheck (sd, from_process_token, access, &access_mapping,
 		    &ps, &ps_len, &access, &status))
     {
-      printf ("error checking access rights (%lu)\n", GetLastError ());
+      system_printf ("error checking access rights (%lu)", GetLastError ());
       goto out;
     }
 
   if (!status)
     {
-      printf ("access to object denied\n");
+      system_printf ("access to object denied");
       goto out;
     }
 
@@ -141,10 +138,10 @@
 			to_process, to_handle_ptr,
 			access, bInheritHandle, 0))
     {
-      printf ("error getting handle to client (%lu)\n", GetLastError ());
+      system_printf ("error getting handle to client (%lu)", GetLastError ());
       goto out;
     }
-  debug_printf ("Duplicated %p to %p\n", from_handle, *to_handle_ptr);
+  debug_printf ("Duplicated %p to %p", from_handle, *to_handle_ptr);
 
   ret_val = 0;
 
@@ -158,9 +155,9 @@
 void
 client_request::serve (transport_layer_base *conn, class process_cache *cache)
 {
-  printf ("*****************************************\n"
-	  "A call to the base client_request class has occured\n"
-	  "This indicates a mismatch in a virtual function definition somewhere\n");
+  system_printf ("*****************************************");
+  system_printf ("A call to the base client_request class has occured");
+  system_printf ("This indicates a mismatch in a virtual function definition somewhere");
   exit (1);
 }
 
@@ -178,36 +175,36 @@
       return;
     }
 
-  debug_printf ("pid %ld:(%p,%p) -> pid %ld\n", req.master_pid,
+  debug_printf ("pid %ld:(%p,%p) -> pid %ld", req.master_pid,
 				req.from_master, req.to_master,
 				req.pid);
 
-  debug_printf ("opening process %ld\n", req.master_pid);
+  debug_printf ("opening process %ld", req.master_pid);
   from_process_handle = OpenProcess (PROCESS_DUP_HANDLE, FALSE, req.master_pid);
-  debug_printf ("opening process %ld\n", req.pid);
+  debug_printf ("opening process %ld", req.pid);
   to_process_handle = OpenProcess (PROCESS_DUP_HANDLE, FALSE, req.pid);
   if (!from_process_handle || !to_process_handle)
     {
-      printf ("error opening process (%lu)\n", GetLastError ());
+      system_printf ("error opening process (%lu)", GetLastError ());
       header.error_code = EACCES;
       goto out;
     }
 
-  debug_printf ("Impersonating client\n");
+  debug_printf ("Impersonating client");
   conn->impersonate_client ();
 
-  debug_printf ("about to open thread token\n");
+  debug_printf ("about to open thread token");
   rc = OpenThreadToken (GetCurrentThread (),
 			TOKEN_QUERY,
 			TRUE,
 			&token_handle);
 
-  debug_printf ("opened thread token, rc=%lu\n", rc);
+  debug_printf ("opened thread token, rc=%lu", rc);
   conn->revert_to_self ();
 
   if (!rc)
     {
-      printf ("error opening thread token (%lu)\n", GetLastError ());
+      system_printf ("error opening thread token (%lu)", GetLastError ());
       header.error_code = EACCES;
       goto out;
     }
@@ -218,7 +215,7 @@
 			    req.from_master,
 			    &req.from_master, TRUE) != 0)
     {
-      printf ("error duplicating from_master handle (%lu)\n", GetLastError ());
+      system_printf ("error duplicating from_master handle (%lu)", GetLastError ());
       header.error_code = EACCES;
       goto out;
     }
@@ -231,16 +228,14 @@
 				req.to_master,
 				&req.to_master, TRUE) != 0)
 	{
-	  printf ("error duplicating to_master handle (%lu)\n", GetLastError ());
+	  system_printf ("error duplicating to_master handle (%lu)", GetLastError ());
 	  header.error_code = EACCES;
 	  goto out;
 	}
     }
 
-#if DEBUG
-  printf ("%ld -> %ld(%p,%p)\n", req.master_pid, req.pid,
+  debug_printf ("%ld -> %ld(%p,%p)", req.master_pid, req.pid,
 				req.from_master, req.to_master);
-#endif
 
   header.error_code = 0;
 
@@ -346,15 +341,15 @@
   ssize_t bytes_read, bytes_written;
   struct request_header* req_ptr = (struct request_header*) &request_buffer;
   client_request *req = NULL;
-  debug_printf ("about to read\n");
+  debug_printf ("about to read");
 
   bytes_read = conn->read (request_buffer, sizeof (struct request_header));
   if (bytes_read != sizeof (struct request_header))
     {
-      printf ("error reading from connection (%lu)\n", GetLastError ());
+      system_printf ("error reading from connection (%lu)", GetLastError ());
       goto out;
     }
-  debug_printf ("got header (%ld)\n", bytes_read);
+  debug_printf ("got header (%ld)", bytes_read);
 
   switch (req_ptr->req_id)
     {
@@ -369,12 +364,12 @@
     default:
       req = new client_request (CYGSERVER_REQUEST_INVALID, 0);
       req->header.error_code = ENOSYS;
-      debug_printf ("Bad client request - returning ENOSYS\n");
+      debug_printf ("Bad client request - returning ENOSYS");
     }
 
   if (req->header.cb != req_ptr->cb)
     {
-      debug_printf ("Mismatch in request buffer sizes\n");
+      debug_printf ("Mismatch in request buffer sizes");
       goto out;
     }
 
@@ -384,10 +379,10 @@
       bytes_read = conn->read (req->buffer, req->header.cb);
       if (bytes_read != req->header.cb)
 	{
-	  debug_printf ("error reading from connection (%lu)\n", GetLastError ());
+	  debug_printf ("error reading from connection (%lu)", GetLastError ());
 	  goto out;
 	}
-      debug_printf ("got body (%ld)\n",bytes_read);
+      debug_printf ("got body (%ld)",bytes_read);
     }
 
   /* this is not allowed to fail. We must return ENOSYS at a minimum to the client */
@@ -398,11 +393,11 @@
     (bytes_written = conn->write (req->buffer, req->header.cb)) != req->header.cb))
     {
       req->header.error_code = -1;
-      printf ("error writing to connection (%lu)\n", GetLastError ());
+      system_printf ("error writing to connection (%lu)", GetLastError ());
       goto out;
     }
 
-  debug_printf("Sent reply, size (%ld)\n",bytes_written);
+  debug_printf ("Sent reply, size (%ld)",bytes_written);
   printf (".");
 
 out:
@@ -475,7 +470,7 @@
     {
       if (!transport->connect())
 	{
-	  printf ("couldn't establish connection with server\n");
+	  system_printf ("couldn't establish connection with server");
 	  exit (1);
 	}
       client_request_shutdown *request =
@@ -503,26 +498,26 @@
 		 cygwin_version.mount_registry,
 		 cygwin_version.dll_build_date);
   setbuf (stdout, NULL);
-  printf ("daemon version %s starting up", version);
+  system_printf ("daemon version %s starting up", version);
   if (signal (SIGQUIT, handle_signal) == SIG_ERR)
     {
-      printf ("\ncould not install signal handler (%d)- aborting startup\n", errno);
+      system_printf ("could not install signal handler (%d)- aborting startup", errno);
       exit (1);
     }
-  printf (".");
+  debug_printf ("installed signal handler");
   transport->listen ();
-  printf (".");
+  debug_printf ("listening for connections");
   class process_cache cache (2);
   request_queue.initial_workers = 10;
   request_queue.cache = &cache;
   request_queue.create_workers ();
-  printf (".");
+  debug_printf ("created process cache");
   request_queue.process_requests (transport);
-  printf (".");
+  debug_printf ("started request queue");
   cache.create_workers ();
-  printf (".");
+  debug_printf ("created workers");
   cache.process_requests ();
-  printf (".complete\n");
+  system_printf ("daemon initialization complete");
   /* TODO: wait on multiple objects - the thread handle for each request loop +
    * all the process handles. This should be done by querying the request_queue and
    * the process cache for all their handles, and then waiting for (say) 30 seconds.
@@ -538,12 +533,12 @@
     {
       sleep (1);
     }
-  printf ("\nShutdown request recieved - new requests will be denied\n");
+  debug_printf ("Shutdown request received - new requests will be denied");
   request_queue.cleanup ();
-  printf ("All pending requests processed\n");
+  debug_printf ("All pending requests processed");
   transport->close ();
-  printf ("No longer accepting requests - cygwin will operate in daemonless mode\n");
+  debug_printf ("No longer accepting requests - cygwin will operate in daemonless mode");
   cache.cleanup ();
-  printf ("All outstanding process-cache activities completed\n");
-  printf ("daemon shutdown\n");
+  debug_printf ("All outstanding process-cache activities completed");
+  debug_printf ("Daemon shutdown");
 }
Index: cygserver_client.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/cygserver_client.cc,v
retrieving revision 1.3
diff -u -w -u -r1.3 cygserver_client.cc
--- cygserver_client.cc	13 Mar 2002 02:34:03 -0000	1.3
+++ cygserver_client.cc	10 Jun 2002 19:42:07 -0000
@@ -11,17 +11,11 @@
    details. */
 
 #ifdef __OUTSIDE_CYGWIN__
-#undef __INSIDE_CYGWIN__
+#include "woutsup.h"
 #else
 #include "winsup.h"
 #endif
 
-#ifndef __INSIDE_CYGWIN__
-#define debug_printf printf
-#define api_fatal printf
-#include <stdio.h>
-#include <windows.h>
-#endif
 #include <sys/socket.h>
 #include <errno.h>
 #include <unistd.h>
@@ -39,6 +33,8 @@
 client_request_get_version::client_request_get_version () : client_request (CYGSERVER_REQUEST_GET_VERSION, sizeof (version))
 {
   buffer = (char *)&version;
+
+  debug_printf ("created");
 }
 
 client_request_attach_tty::client_request_attach_tty () : client_request (CYGSERVER_REQUEST_ATTACH_TTY, sizeof (req))
@@ -48,6 +44,8 @@
   req.master_pid = 0;
   req.from_master = NULL;
   req.to_master = NULL;
+
+  debug_printf ("created");
 }
 
 client_request_attach_tty::client_request_attach_tty (DWORD npid, DWORD nmaster_pid, HANDLE nfrom_master, HANDLE nto_master) : client_request (CYGSERVER_REQUEST_ATTACH_TTY, sizeof (req))
@@ -57,11 +55,15 @@
   req.master_pid = nmaster_pid;
   req.from_master = nfrom_master;
   req.to_master = nto_master;
+
+  debug_printf ("created");
 }
 
 client_request_shutdown::client_request_shutdown () : client_request (CYGSERVER_REQUEST_SHUTDOWN, 0)
 {
   buffer = NULL;
+
+  debug_printf ("created");
 }
 
 client_request::client_request (cygserver_request_code id, ssize_t buffer_size) : header (id, buffer_size)
@@ -82,29 +84,29 @@
 {
   if (!conn)
     return;
-  debug_printf("this=%p, conn=%p\n",this, conn);
+  debug_printf("this=%p, conn=%p",this, conn);
   ssize_t bytes_written, bytes_read;
-  debug_printf("header.cb = %ld\n",header.cb);
+  debug_printf("header.cb = %ld",header.cb);
   if ((bytes_written = conn->write ((char *)&header, sizeof (header)))
     != sizeof(header) || (header.cb &&
     (bytes_written = conn->write (buffer, header.cb)) != header.cb))
     {
       header.error_code = -1;
-      debug_printf ("bytes written != request size\n");
+      debug_printf ("bytes written != request size");
       return;
     }
 
-  debug_printf("Sent request, size (%ld)\n",bytes_written);
+  debug_printf("Sent request, size (%ld)",bytes_written);
 
   if ((bytes_read = conn->read ((char *)&header, sizeof (header)))
     != sizeof (header) || (header.cb &&
     (bytes_read = conn->read (buffer, header.cb)) != header.cb))
     {
       header.error_code = -1;
-      debug_printf("failed reading response \n");
+      debug_printf("failed reading response");
       return;
     }
-  debug_printf ("completed ok\n");
+  debug_printf ("completed ok");
 }
 
 /* Oh, BTW: Fix the procedural basis and make this more intuitive. */
@@ -134,7 +136,7 @@
       return -1;
     }
 
-  debug_printf ("connected to server %p\n", transport);
+  debug_printf ("connected to server %p", transport);
 
   req->send(transport);
 
Index: cygserver_process.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/cygserver_process.cc,v
retrieving revision 1.4
diff -u -w -u -r1.4 cygserver_process.cc
--- cygserver_process.cc	28 May 2002 01:55:39 -0000	1.4
+++ cygserver_process.cc	10 Jun 2002 19:42:08 -0000
@@ -10,6 +10,8 @@
    Cygwin license.  Please consult the file "CYGWIN_LICENSE" for
    details. */
 
+#include "woutsup.h"
+
 #include <errno.h>
 #include <stdio.h>
 #include <unistd.h>
@@ -18,14 +20,10 @@
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <netdb.h>
-#include "wincap.h"
 #include <pthread.h>
 #include <threaded_queue.h>
 #include <cygwin/cygserver_process.h>
 
-#define debug_printf if (DEBUG) printf
-#define DEBUG 1
-
 /* the cache structures and classes are designed for one cache per server process.
  * To make multiple process caches, a redesign will be needed
  */
@@ -38,7 +36,7 @@
   InitializeCriticalSection (&cache_write_access);
   if ((cache_add_trigger = CreateEvent (NULL, FALSE, FALSE, NULL)) == NULL)
     {
-      printf ("Failed to create cache add trigger (%lu), terminating\n",
+      system_printf ("Failed to create cache add trigger (%lu), terminating",
 	      GetLastError ());
       exit (1);
     }
@@ -118,7 +116,7 @@
       entry = (class process *) InterlockedExchangePointer (&head, theprocess->next);
       if (entry != theprocess)
 	{
-	  printf ("Bug encountered, process cache corrupted\n");
+	  system_printf ("Bug encountered, process cache corrupted");
 	  exit (1);
 	}
     }
@@ -129,7 +127,7 @@
       class process *temp = (class process *) InterlockedExchangePointer (&entry->next, theprocess->next);
       if (temp != theprocess)
 	{
-	  printf ("Bug encountered, process cache corrupted\n");
+	  system_printf ("Bug encountered, process cache corrupted");
 	  exit (1);
 	}
     }
@@ -181,7 +179,7 @@
 /* process's */
 /* global process crit section */
 static CRITICAL_SECTION process_access;
-static pthread_once_t process_init;
+static pthread_once_t process_init = PTHREAD_ONCE_INIT;
 
 void
 do_process_init (void)
@@ -198,10 +196,10 @@
   thehandle = OpenProcess (PROCESS_ALL_ACCESS, FALSE, pid);
   if (!thehandle)
     {
-      printf ("unable to obtain handle for new cache process %ld\n", pid);
+      system_printf ("unable to obtain handle for new cache process %ld", pid);
       thehandle = INVALID_HANDLE_VALUE;
     }
-  debug_printf ("Got handle %p for new cache process %ld\n", thehandle, pid);
+  debug_printf ("Got handle %p for new cache process %ld", thehandle, pid);
   InitializeCriticalSection (&access);
   LeaveCriticalSection (&process_access);
 }
@@ -221,10 +219,10 @@
   /* FIXME: call the cleanup list ? */
 
 //  CloseHandle (thehandle);
-//  debug_printf ("Process id %ld has terminated, attempting to open a new handle\n",
+//  debug_printf ("Process id %ld has terminated, attempting to open a new handle",
 //       winpid);
 //  thehandle = OpenProcess (PROCESS_ALL_ACCESS, FALSE, winpid);
-//  debug_printf ("Got handle %p when refreshing cache process %ld\n", thehandle, winpid);
+//  debug_printf ("Got handle %p when refreshing cache process %ld", thehandle, winpid);
 //  /* FIXME: what if OpenProcess fails ? */
 //  if (thehandle)
 //    {
@@ -244,7 +242,7 @@
     err = GetExitCodeProcess (thehandle, &_exit_status);
   if (!err)
     {
-      debug_printf ("Failed to retrieve exit code (%ld)\n", GetLastError ());
+      system_printf ("Failed to retrieve exit code (%ld)", GetLastError ());
       thehandle = INVALID_HANDLE_VALUE;
       return _exit_status;
     }
@@ -333,8 +331,8 @@
 						 HandlesSize + 10);
 	      if (!temp)
 		{
-		  printf
-		    ("cannot allocate more storage for the handle array!\n");
+		  system_printf
+		    ("cannot allocate more storage for the handle array!");
 		  exit (1);
 		}
 	      Handles = temp;
@@ -343,8 +341,8 @@
 						      HandlesSize + 10);
 	      if (!ptemp)
 		{
-		  printf
-		    ("cannot allocate more storage for the handle array!\n");
+		  system_printf
+		    ("cannot allocate more storage for the handle array!");
 		  exit (1);
 		}
 	      Entries = ptemp;
@@ -356,18 +354,18 @@
 				    HandlesSize - 2 - offset, offset);
 	  count += copied;
 	}
-      debug_printf ("waiting on %u objects\n", count);
+      debug_printf ("waiting on %u objects", count);
       DWORD rc = WaitForMultipleObjects (count, Handles, FALSE, INFINITE);
       if (rc == WAIT_FAILED)
 	{
-	  printf ("Could not wait on the process handles (%ld)!\n",
+	  system_printf ("Could not wait on the process handles (%ld)!",
 		  GetLastError ());
 	  exit (1);
 	}
       int objindex = rc - WAIT_OBJECT_0;
       if (objindex > 1 && objindex < count)
 	{
-	  debug_printf ("Process %ld has left the building\n",
+	  debug_printf ("Process %ld has left the building",
 			Entries[objindex]->winpid);
 	  /* fire off the termination routines */
 	  cache->remove_process (Entries[objindex]);
@@ -379,8 +377,8 @@
 	}
       else
 	{
-	  printf
-	    ("unexpected return code from WaitForMultiple objects in process_process_param::request_loop\n");
+	  system_printf
+	    ("unexpected return code from WaitForMultiple objects in process_process_param::request_loop");
 	}
     }
   running = false;
Index: cygserver_shm.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/cygserver_shm.cc,v
retrieving revision 1.7
diff -u -w -u -r1.7 cygserver_shm.cc
--- cygserver_shm.cc	28 May 2002 01:55:39 -0000	1.7
+++ cygserver_shm.cc	10 Jun 2002 19:42:08 -0000
@@ -11,20 +11,11 @@
 details. */
 
 #ifdef __OUTSIDE_CYGWIN__
-#undef __INSIDE_CYGWIN__
+#include "woutsup.h"
 #else
 #include "winsup.h"
 #endif
 
-#ifndef __INSIDE_CYGWIN__
-#define DEBUG 0
-#define system_printf printf
-#define debug_printf if (DEBUG) printf
-#define api_fatal printf
-#include <stdio.h>
-#include <windows.h>
-#endif
-
 #include <sys/stat.h>
 #include <errno.h>
 #include "cygerrno.h"
@@ -220,7 +211,7 @@
    */
   if (!from_process_handle)
     {
-      debug_printf ("error opening process (%lu)\n", GetLastError ());
+      system_printf ("error opening process (%lu)", GetLastError ());
       header.error_code = EACCES;
       return;
     }
@@ -230,22 +221,22 @@
   rc = OpenThreadToken (GetCurrentThread (),
 			TOKEN_QUERY, TRUE, &token_handle);
 
+  const DWORD lasterr = GetLastError ();
+
   conn->revert_to_self ();
 
   if (!rc)
     {
-      debug_printf ("error opening thread token (%lu)\n", GetLastError ());
+      system_printf ("error opening thread token (%lu)", lasterr);
       header.error_code = EACCES;
       CloseHandle (from_process_handle);
       return;
     }
 
-
   /* we trust the clients request - we will be doing it as them, and
    * the worst they can do is open their own permissions
    */
 
-
   SECURITY_ATTRIBUTES sa;
   sa.nLength = sizeof (sa);
   sa.lpSecurityDescriptor = psd;
@@ -270,7 +261,7 @@
 		   DUPLICATE_SAME_ACCESS, tempnode->filemap,
 		   &parameters.out.filemap, TRUE) != 0)
 		{
-		  debug_printf ("error duplicating filemap handle (%lu)\n",
+		  system_printf ("error duplicating filemap handle (%lu)",
 				GetLastError ());
 		  header.error_code = EACCES;
 		}
@@ -279,7 +270,7 @@
 		   DUPLICATE_SAME_ACCESS, tempnode->attachmap,
 		   &parameters.out.attachmap, TRUE) != 0)
 		{
-		  debug_printf ("error duplicating attachmap handle (%lu)\n",
+		  system_printf ("error duplicating attachmap handle (%lu)",
 				GetLastError ());
 		  header.error_code = EACCES;
 		}
@@ -400,9 +391,9 @@
 	  shmname = stringbuf;
 	  snprintf (stringbuf1, 29, "CYGWINSHMD0x%0qx", parameters.in.key);
 	  shmaname = stringbuf1;
-	  debug_printf ("system id strings are \n%s\n%s\n", shmname,
+	  debug_printf ("system id strings are `%s' and `%s'", shmname,
 			shmaname);
-	  debug_printf ("key input value is 0x%0qx\n", parameters.in.key);
+	  debug_printf ("key input value is 0x%0qx", parameters.in.key);
 	}
 
       /* attempt to open the key */
@@ -439,8 +430,8 @@
 		  && (parameters.in.shmflg & IPC_EXCL))
 		{
 		  header.error_code = EEXIST;
-		  debug_printf
-		    ("attempt to exclusively create already created shm_area with key 0x%0qx\n",
+		  system_printf
+		    ("attempt to exclusively create already created shm_area with key 0x%0qx",
 		     parameters.in.key);
 		  // FIXME: free the mutex
 		  CloseHandle (token_handle);
@@ -461,7 +452,7 @@
 		   DUPLICATE_SAME_ACCESS, tempnode->filemap,
 		   &parameters.out.filemap, TRUE) != 0)
 		{
-		  printf ("error duplicating filemap handle (%lu)\n",
+		  system_printf ("error duplicating filemap handle (%lu)",
 			  GetLastError ());
 		  header.error_code = EACCES;
 /*mutex*/
@@ -473,7 +464,7 @@
 		   DUPLICATE_SAME_ACCESS, tempnode->attachmap,
 		   &parameters.out.attachmap, TRUE) != 0)
 		{
-		  printf ("error duplicating attachmap handle (%lu)\n",
+		  system_printf ("error duplicating attachmap handle (%lu)",
 			  GetLastError ());
 		  header.error_code = EACCES;
 /*mutex*/
@@ -505,7 +496,7 @@
       if (filemap == NULL)
 	{
 	  /* We failed to open the filemapping ? */
-	  system_printf ("failed to open file mapping: %lu\n",
+	  system_printf ("failed to open file mapping: %lu",
 			 GetLastError ());
 	  // free the mutex
 	  // we can assume that it exists, and that it was an access problem.
@@ -573,7 +564,7 @@
 
       if (attachmap == NULL)
 	{
-	  system_printf ("failed to get shm attachmap\n");
+	  system_printf ("failed to get shm attachmap");
 	  header.error_code = ENOMEM;
 	  UnmapViewOfFile (mapptr);
 	  CloseHandle (filemap);
@@ -585,7 +576,7 @@
       shmid_ds *shmtemp = new shmid_ds;
       if (!shmtemp)
 	{
-	  system_printf ("failed to malloc shm node\n");
+	  system_printf ("failed to malloc shm node");
 	  header.error_code = ENOMEM;
 	  UnmapViewOfFile (mapptr);
 	  CloseHandle (filemap);
@@ -631,7 +622,7 @@
 				tempnode->filemap, &parameters.out.filemap,
 				TRUE) != 0)
 	{
-	  printf ("error duplicating filemap handle (%lu)\n",
+	  system_printf ("error duplicating filemap handle (%lu)",
 		  GetLastError ());
 	  header.error_code = EACCES;
 	  CloseHandle (token_handle);
@@ -644,7 +635,7 @@
 				tempnode->attachmap,
 				&parameters.out.attachmap, TRUE) != 0)
 	{
-	  printf ("error duplicating attachmap handle (%lu)\n",
+	  system_printf ("error duplicating attachmap handle (%lu)",
 		  GetLastError ());
 	  header.error_code = EACCES;
 	  CloseHandle (from_process_handle);
Index: cygserver_transport.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/cygserver_transport.cc,v
retrieving revision 1.4
diff -u -w -u -r1.4 cygserver_transport.cc
--- cygserver_transport.cc	9 Jun 2002 23:02:00 -0000	1.4
+++ cygserver_transport.cc	10 Jun 2002 19:42:08 -0000
@@ -10,25 +10,19 @@
    Cygwin license.  Please consult the file "CYGWIN_LICENSE" for
    details. */
 
-#include <errno.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <windows.h>
-#include <sys/types.h>
+#ifdef __OUTSIDE_CYGWIN__
+#include "woutsup.h"
+#else
+#include "winsup.h"
+#endif
+
+#include <assert.h>
+
 #include <sys/socket.h>
-#include <netdb.h>
-#include "wincap.h"
 #include "cygwin/cygserver_transport.h"
 #include "cygwin/cygserver_transport_pipes.h"
 #include "cygwin/cygserver_transport_sockets.h"
 
-/* to allow this to link into cygwin and the .dll, a little magic is needed. */
-#ifndef __OUTSIDE_CYGWIN__
-#include "winsup.h"
-#else
-#define debug_printf printf
-#endif
-
 /* The factory */
 class transport_layer_base *create_server_transport()
 {
@@ -39,46 +33,6 @@
   else
     temp = new transport_layer_sockets ();
   return temp;
-}
-
-
-transport_layer_base::transport_layer_base ()
-{
-  /* should we throw an error of some sort ? */
-}
-
-void
-transport_layer_base::listen ()
-{
-}
-
-class transport_layer_base *
-transport_layer_base::accept ()
-{
-  return NULL;
-}
-
-void
-transport_layer_base::close()
-{
-}
-
-ssize_t
-transport_layer_base::read (char *buf, size_t len)
-{
-  return 0;
-}
-
-ssize_t
-transport_layer_base::write (char *buf, size_t len)
-{
-  return 0;
-}
-
-bool
-transport_layer_base::connect ()
-{
-  return false;
 }
 
 void
Index: cygserver_transport_pipes.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/cygserver_transport_pipes.cc,v
retrieving revision 1.4
diff -u -w -u -r1.4 cygserver_transport_pipes.cc
--- cygserver_transport_pipes.cc	13 Mar 2002 02:34:04 -0000	1.4
+++ cygserver_transport_pipes.cc	10 Jun 2002 19:42:08 -0000
@@ -10,6 +10,14 @@
    Cygwin license.  Please consult the file "CYGWIN_LICENSE" for
    details. */
 
+/* to allow this to link into cygwin and the .dll, a little magic is needed. */
+
+#ifdef __OUTSIDE_CYGWIN__
+#include "woutsup.h"
+#else
+#include "winsup.h"
+#endif
+
 #include <errno.h>
 #include <stdio.h>
 #include <unistd.h>
@@ -17,18 +25,9 @@
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <netdb.h>
-#include "wincap.h"
 #include "cygwin/cygserver_transport.h"
 #include "cygwin/cygserver_transport_pipes.h"
 
-/* to allow this to link into cygwin and the .dll, a little magic is needed. */
-#ifndef __OUTSIDE_CYGWIN__
-#include "winsup.h"
-#else
-#define DEBUG 0
-#define debug_printf if (DEBUG) printf
-#endif
-
 //SECURITY_DESCRIPTOR transport_layer_pipes::sd;
 //SECURITY_ATTRIBUTES transport_layer_pipes::sec_none_nih, transport_layer_pipes::sec_all_nih;
 //bool transport_layer_pipes::inited = false;
@@ -75,7 +74,7 @@
 {
   if (pipe)
     {
-      debug_printf ("Already have a pipe in this %p\n",this);
+      system_printf ("Already have a pipe in this %p",this);
       return NULL;
     }
 
@@ -87,14 +86,14 @@
 			  &sec_all_nih );
   if (pipe == INVALID_HANDLE_VALUE)
     {
-      debug_printf ("error creating pipe (%lu)\n.", GetLastError ());
+      system_printf ("error creating pipe (%lu).", GetLastError ());
       return NULL;
     }
 
   if ( !ConnectNamedPipe ( pipe, NULL ) &&
      GetLastError () != ERROR_PIPE_CONNECTED)
     {
-      printf ("error connecting to pipe (%lu)\n.", GetLastError ());
+      system_printf ("error connecting to pipe (%lu).", GetLastError ());
       CloseHandle (pipe);
       pipe = NULL;
       return NULL;
@@ -109,7 +108,7 @@
 void
 transport_layer_pipes::close()
 {
-  debug_printf ("closing pipe %p\n", pipe);
+  debug_printf ("closing pipe %p", pipe);
   if (pipe && pipe != INVALID_HANDLE_VALUE)
     {
       FlushFileBuffers (pipe);
@@ -121,7 +120,7 @@
 ssize_t
 transport_layer_pipes::read (char *buf, size_t len)
 {
-  debug_printf ("reading from pipe %p\n", pipe);
+  debug_printf ("reading from pipe %p", pipe);
   if (!pipe || pipe == INVALID_HANDLE_VALUE)
     return -1;
 
@@ -129,7 +128,7 @@
   DWORD rc = ReadFile (pipe, buf, len, &bytes_read, NULL);
   if (!rc)
     {
-      debug_printf ("error reading from pipe (%lu)\n", GetLastError ());
+      system_printf ("error reading from pipe (%lu)", GetLastError ());
       return -1;
     }
   return bytes_read;
@@ -138,7 +137,7 @@
 ssize_t
 transport_layer_pipes::write (char *buf, size_t len)
 {
-  debug_printf ("writing to pipe %p\n", pipe);
+  debug_printf ("writing to pipe %p", pipe);
   DWORD bytes_written, rc;
   if (!pipe || pipe == INVALID_HANDLE_VALUE)
     return -1;
@@ -146,7 +145,7 @@
   rc = WriteFile (pipe, buf, len, &bytes_written, NULL);
   if (!rc)
     {
-      debug_printf ("error writing to pipe (%lu)\n", GetLastError ());
+      system_printf ("error writing to pipe (%lu)", GetLastError ());
       return -1;
     }
   return bytes_written;
@@ -157,7 +156,7 @@
 {
   if (pipe && pipe != INVALID_HANDLE_VALUE)
     {
-      debug_printf ("Already have a pipe in this %p\n",this);
+      system_printf ("Already have a pipe in this %p",this);
       return false;
     }
 
@@ -176,35 +175,39 @@
 
       if (GetLastError () != ERROR_PIPE_BUSY)
 	{
-	  debug_printf ("Error opening the pipe (%lu)\n", GetLastError ());
+	  debug_printf ("Error opening the pipe (%lu)", GetLastError ());
 	  pipe = NULL;
 	  return false;
 	}
       if (!WaitNamedPipe (pipe_name, 20000))
-	debug_printf ( "error connecting to server pipe after 20 seconds (%lu)\n", GetLastError () );
+	system_printf ( "error connecting to server pipe after 20 seconds (%lu)", GetLastError () );
       /* We loop here, because the pipe exists but is busy. If it doesn't exist
        * the != ERROR_PIPE_BUSY will catch it.
        */
     }
 }
 
+/* FIXME: Can pipe ever be invalid here? Why? */
 void
 transport_layer_pipes::impersonate_client ()
 {
-  debug_printf ("impersonating pipe %p\n", pipe);
+  debug_printf ("impersonating pipe %p", pipe);
   if (pipe && pipe != INVALID_HANDLE_VALUE)
     {
       BOOL rv = ImpersonateNamedPipeClient (pipe);
       if (!rv)
-	debug_printf ("Failed to Impersonate the client, (%lu)\n", GetLastError ());
+	{
+	  system_printf ("Failed to Impersonate the client, (%lu)", GetLastError ());
+	  return;
+	}
     }
-  debug_printf("I am who you are\n");
+  debug_printf ("I am who you are");
+  return;
 }
 
 void
 transport_layer_pipes::revert_to_self ()
 {
   RevertToSelf ();
-  debug_printf("I am who I yam\n");
+  debug_printf ("I am who I yam");
 }
-
Index: cygserver_transport_sockets.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/cygserver_transport_sockets.cc,v
retrieving revision 1.3
diff -u -w -u -r1.3 cygserver_transport_sockets.cc
--- cygserver_transport_sockets.cc	13 Mar 2002 02:34:04 -0000	1.3
+++ cygserver_transport_sockets.cc	10 Jun 2002 19:42:08 -0000
@@ -10,20 +10,23 @@
    Cygwin license.  Please consult the file "CYGWIN_LICENSE" for
    details. */
 
+#ifdef __OUTSIDE_CYGWIN__
+#include "woutsup.h"
+#else
+#include "winsup.h"
+#endif
+
 #include <errno.h>
 #include <stdio.h>
 #include <unistd.h>
-#include <windows.h>
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <netdb.h>
-#include "wincap.h"
 #include "cygwin/cygserver_transport.h"
 #include "cygwin/cygserver_transport_sockets.h"
 
 /* to allow this to link into cygwin and the .dll, a little magic is needed. */
 #ifndef __OUTSIDE_CYGWIN__
-#include "winsup.h"
 extern "C" int
 cygwin_socket (int af, int type, int protocol);
 extern "C" int
@@ -43,7 +46,6 @@
 #define cygwin_listen(A,B)    ::listen(A,B)
 #define cygwin_bind(A,B,C)    ::bind(A,B,C)
 #define cygwin_connect(A,B,C) ::connect(A,B,C)
-#define debug_printf printf
 #endif
 
 transport_layer_sockets::transport_layer_sockets (int newfd): fd(newfd)
@@ -68,11 +70,11 @@
 {
   /* we want a thread pool based approach. */
   if ((fd = cygwin_socket (AF_UNIX, SOCK_STREAM,0)) < 0)
-    printf ("Socket not created error %d\n", errno);
+    system_printf ("Socket not created error %d", errno);
   if (cygwin_bind(fd, &sockdetails, sdlen))
-    printf ("Bind doesn't like you. Tsk Tsk. Bind said %d\n", errno);
+    system_printf ("Bind doesn't like you. Tsk Tsk. Bind said %d", errno);
   if (cygwin_listen(fd, 5) < 0)
-    printf ("And the OS just isn't listening, all it says is %d\n", errno);
+    system_printf ("And the OS just isn't listening, all it says is %d", errno);
 }
 
 class transport_layer_sockets *
@@ -83,7 +85,7 @@
 
   if ((new_fd = cygwin_accept(fd, &sockdetails, &sdlen)) < 0)
     {
-      printf ("Nup, could' accept. %d\n",errno);
+      system_printf ("Nup, could' accept. %d",errno);
       return NULL;
     }
 
@@ -123,7 +125,7 @@
   fd = cygwin_socket (AF_UNIX, SOCK_STREAM, 0);
   if (cygwin_connect (fd, &sockdetails, sdlen) < 0)
     {
-      debug_printf("client connect failure %d\n", errno);
+      debug_printf("client connect failure %d", errno);
       ::close (fd);
       return false;
     }
Index: threaded_queue.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/threaded_queue.cc,v
retrieving revision 1.4
diff -u -w -u -r1.4 threaded_queue.cc
--- threaded_queue.cc	5 Jun 2002 04:01:43 -0000	1.4
+++ threaded_queue.cc	10 Jun 2002 19:42:28 -0000
@@ -10,16 +10,15 @@
    Cygwin license.  Please consult the file "CYGWIN_LICENSE" for
    details. */
 
+#include "woutsup.h"
+
 #include <errno.h>
 #include <stdio.h>
 #include <unistd.h>
 #include <windows.h>
 #include <sys/types.h>
 #include <stdlib.h>
-#include "wincap.h"
 #include "threaded_queue.h"
-#define DEBUG 1
-#define debug_printf if (DEBUG) printf
 
 /* threaded_queue */
 
@@ -38,7 +37,7 @@
 	  DWORD rc = WaitForSingleObject (queue->event, INFINITE);
 	  if (rc == WAIT_FAILED)
 	    {
-	      printf ("Wait for event failed\n");
+	      system_printf ("Wait for event failed");
 	      queue->running--;
 	      ExitThread (0);
 	    }
@@ -69,7 +68,7 @@
   InitializeCriticalSection (&queuelock);
   if ((event = CreateEvent (NULL, FALSE, FALSE, NULL)) == NULL)
     {
-      printf ("Failed to create event queue (%lu), terminating\n",
+      system_printf ("Failed to create event queue (%lu), terminating",
 	      GetLastError ());
       exit (1);
     }
@@ -85,7 +84,7 @@
       hThread = CreateThread (NULL, 0, worker_function, this, 0, &tid);
       if (hThread == NULL)
 	{
-	  printf ("Failed to create thread (%lu), terminating\n",
+	  system_printf ("Failed to create thread (%lu), terminating",
 		  GetLastError ());
 	  exit (1);
 	}
@@ -114,7 +113,7 @@
   LeaveCriticalSection (&queuelock);
   if (!running)
     return;
-  printf ("Waiting for current queue threads to terminate\n");
+  debug_printf ("Waiting for current queue threads to terminate");
   for (int n = running; n; n--)
     PulseEvent (event);
   while (running)
@@ -132,7 +131,7 @@
   EnterCriticalSection (&queuelock);
   if (!running)
     {
-      printf ("No worker threads to handle request!\n");
+      system_printf ("No worker threads to handle request!");
     }
   if (!request)
     request = therequest;
@@ -169,10 +168,10 @@
 {
   if (!interruptible)
     return;
-  debug_printf ("creating an interruptible processing thread\n");
+  debug_printf ("creating an interruptible processing thread");
   if ((interrupt = CreateEvent (NULL, FALSE, FALSE, NULL)) == NULL)
     {
-      printf ("Failed to create interrupt event (%lu), terminating\n",
+      system_printf ("Failed to create interrupt event (%lu), terminating",
 	      GetLastError ());
       exit (1);
     }
@@ -198,7 +197,7 @@
       running = true;
       return true;
     }
-  printf ("Failed to create thread (%lu), terminating\n", GetLastError ());
+  system_printf ("Failed to create thread (%lu), terminating", GetLastError ());
   return false;
 }
 
@@ -217,7 +216,7 @@
       while (n-- && WaitForSingleObject (hThread, 1000) == WAIT_TIMEOUT);
       if (!n)
 	{
-	  printf ("Process thread didn't shutdown cleanly after 200ms!\n");
+	  system_printf ("Process thread didn't shutdown cleanly after 200ms!");
 	  exit (1);
 	}
       else
@@ -225,11 +224,11 @@
     }
   else
     {
-      printf ("killing request loop thread %ld\n", tid);
+      debug_printf ("killing request loop thread %ld", tid);
       int rc;
       if (!(rc = TerminateThread (hThread, 0)))
 	{
-	  printf ("error shutting down request loop worker thread\n");
+	  system_printf ("error shutting down request loop worker thread");
 	}
       running = false;
     }
@@ -244,7 +243,8 @@
 void
 queue_request::process (void)
 {
-  printf ("\n**********************************************\n"
-	  "Oh no! we've hit the base queue_request process() function, and this indicates a coding\n"
-	  "fault !!!\n" "***********************************************\n");
+  system_printf ("**********************************************");
+  system_printf ("Oh no! we've hit the base queue_request process() function");
+  system_printf ("and this indicates a coding fault !!!");
+  system_printf ("***********************************************");
 }
Index: include/cygwin/cygserver_transport.h
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/include/cygwin/cygserver_transport.h,v
retrieving revision 1.3
diff -u -w -u -r1.3 cygserver_transport.h
--- include/cygwin/cygserver_transport.h	13 Mar 2002 02:34:05 -0000	1.3
+++ include/cygwin/cygserver_transport.h	10 Jun 2002 19:42:29 -0000
@@ -18,15 +18,14 @@
 class transport_layer_base
 {
   public:
-    virtual void listen ();
-    virtual class transport_layer_base * accept ();
-    virtual void close ();
-    virtual ssize_t read (char *buf, size_t len);
-    virtual ssize_t write (char *buf, size_t len);
-    virtual bool connect();
+    virtual void listen () = 0;
+    virtual class transport_layer_base * accept () = 0;
+    virtual void close () = 0;
+    virtual ssize_t read (char *buf, size_t len) = 0;
+    virtual ssize_t write (char *buf, size_t len) = 0;
+    virtual bool connect() = 0;
     virtual void impersonate_client ();
     virtual void revert_to_self ();
-    transport_layer_base ();
 };
 
 #endif /* _CYGSERVER_TRANSPORT_ */
