Index: src/bin/pg_ctl/pg_ctl.c
===================================================================
RCS file: /cvsroot/pgsql/src/bin/pg_ctl/pg_ctl.c,v
retrieving revision 1.34
diff -c -c -r1.34 pg_ctl.c
*** src/bin/pg_ctl/pg_ctl.c	12 Oct 2004 21:54:43 -0000	1.34
--- src/bin/pg_ctl/pg_ctl.c	13 Oct 2004 10:32:41 -0000
***************
*** 21,26 ****
--- 21,30 ----
  #include "libpq/pqsignal.h"
  #include "getopt_long.h"
  
+ #if defined(__CYGWIN__)
+ #include <windows.h>
+ #endif
+ 
  #ifndef HAVE_OPTRESET
  int			optreset;
  #endif
***************
*** 95,101 ****
  static void do_status(void);
  static void do_kill(pgpid_t pid);
  
! #ifdef WIN32
  static bool pgwin32_IsInstalled(SC_HANDLE);
  static char *pgwin32_CommandLine(bool);
  static void pgwin32_doRegister();
--- 99,105 ----
  static void do_status(void);
  static void do_kill(pgpid_t pid);
  
! #if defined(WIN32) || defined(__CYGWIN__)
  static bool pgwin32_IsInstalled(SC_HANDLE);
  static char *pgwin32_CommandLine(bool);
  static void pgwin32_doRegister();
***************
*** 116,122 ****
  static char conf_file[MAXPGPATH];
  
  
! #ifdef WIN32
  static void
  write_eventlog(int level, const char *line)
  {
--- 120,126 ----
  static char conf_file[MAXPGPATH];
  
  
! #if defined(WIN32) || defined(__CYGWIN__)
  static void
  write_eventlog(int level, const char *line)
  {
***************
*** 154,160 ****
  	va_list		ap;
  
  	va_start(ap, fmt);
! #ifndef WIN32
  	/* On Unix, we just fprintf to stderr */
  	vfprintf(stderr, fmt, ap);
  #else
--- 158,164 ----
  	va_list		ap;
  
  	va_start(ap, fmt);
! #if !defined(WIN32) && !defined(__CYGWIN__)
  	/* On Unix, we just fprintf to stderr */
  	vfprintf(stderr, fmt, ap);
  #else
***************
*** 318,324 ****
  	 * http://dev.remotenetworktechnology.com/cmd/cmdfaq.htm
  	 */
  	if (log_file != NULL)
! #ifndef WIN32
  		snprintf(cmd, MAXPGPATH, "%s\"%s\" %s%s < \"%s\" >> \"%s\" 2>&1 &%s",
  #else
  		snprintf(cmd, MAXPGPATH, "%sSTART /B \"\" \"%s\" %s%s < \"%s\" >> \"%s\" 2>&1%s",
--- 322,328 ----
  	 * http://dev.remotenetworktechnology.com/cmd/cmdfaq.htm
  	 */
  	if (log_file != NULL)
! #if !defined(WIN32) && !defined(__CYGWIN__)
  		snprintf(cmd, MAXPGPATH, "%s\"%s\" %s%s < \"%s\" >> \"%s\" 2>&1 &%s",
  #else
  		snprintf(cmd, MAXPGPATH, "%sSTART /B \"\" \"%s\" %s%s < \"%s\" >> \"%s\" 2>&1%s",
***************
*** 326,332 ****
  				 SYSTEMQUOTE, postgres_path, pgdata_opt, post_opts,
  				 DEVNULL, log_file, SYSTEMQUOTE);
  	else
! #ifndef WIN32
  		snprintf(cmd, MAXPGPATH, "%s\"%s\" %s%s < \"%s\" 2>&1 &%s",
  #else
  		snprintf(cmd, MAXPGPATH, "%sSTART /B \"\" \"%s\" %s%s < \"%s\" 2>&1%s",
--- 330,336 ----
  				 SYSTEMQUOTE, postgres_path, pgdata_opt, post_opts,
  				 DEVNULL, log_file, SYSTEMQUOTE);
  	else
! #if !defined(WIN32) && !defined(__CYGWIN__)
  		snprintf(cmd, MAXPGPATH, "%s\"%s\" %s%s < \"%s\" 2>&1 &%s",
  #else
  		snprintf(cmd, MAXPGPATH, "%sSTART /B \"\" \"%s\" %s%s < \"%s\" 2>&1%s",
***************
*** 807,813 ****
  	}
  }
  
! #ifdef WIN32
  
  static bool
  pgwin32_IsInstalled(SC_HANDLE hSCM)
--- 811,817 ----
  	}
  }
  
! #if defined(WIN32) || defined(__CYGWIN__)
  
  static bool
  pgwin32_IsInstalled(SC_HANDLE hSCM)
***************
*** 1085,1098 ****
  	printf(_("  %s reload  [-D DATADIR] [-s]\n"), progname);
  	printf(_("  %s status  [-D DATADIR]\n"), progname);
  	printf(_("  %s kill    SIGNALNAME PROCESSID\n"), progname);
! #ifdef WIN32
  	printf(_("  %s register   [-N SERVICENAME] [-U USERNAME] [-P PASSWORD] [-D DATADIR] [-w] [-o \"OPTIONS\"]\n"), progname);
  	printf(_("  %s unregister [-N SERVICENAME]\n"), progname);
  #endif
  	printf(_("Common options:\n"));
  	printf(_("  -D, --pgdata DATADIR   location of the database storage area\n"));
  	printf(_("  -s, --silent only print errors, no informational messages\n"));
! #ifdef WIN32
  	printf(_("  -N       service name with which to register PostgreSQL server\n"));
  	printf(_("  -P       password of account to register PostgreSQL server\n"));
  	printf(_("  -U       user name of account to register PostgreSQL server\n"));
--- 1089,1102 ----
  	printf(_("  %s reload  [-D DATADIR] [-s]\n"), progname);
  	printf(_("  %s status  [-D DATADIR]\n"), progname);
  	printf(_("  %s kill    SIGNALNAME PROCESSID\n"), progname);
! #if defined(WIN32) || defined(__CYGWIN__)
  	printf(_("  %s register   [-N SERVICENAME] [-U USERNAME] [-P PASSWORD] [-D DATADIR] [-w] [-o \"OPTIONS\"]\n"), progname);
  	printf(_("  %s unregister [-N SERVICENAME]\n"), progname);
  #endif
  	printf(_("Common options:\n"));
  	printf(_("  -D, --pgdata DATADIR   location of the database storage area\n"));
  	printf(_("  -s, --silent only print errors, no informational messages\n"));
! #if defined(WIN32) || defined(__CYGWIN__)
  	printf(_("  -N       service name with which to register PostgreSQL server\n"));
  	printf(_("  -P       password of account to register PostgreSQL server\n"));
  	printf(_("  -U       user name of account to register PostgreSQL server\n"));
***************
*** 1201,1207 ****
  	int			c;
  	pgpid_t		killproc = 0;
  
! #ifdef WIN32
  	setvbuf(stderr, NULL, _IONBF, 0);
  #endif
  
--- 1205,1211 ----
  	int			c;
  	pgpid_t		killproc = 0;
  
! #if defined(WIN32) || defined(__CYGWIN__)
  	setvbuf(stderr, NULL, _IONBF, 0);
  #endif
  
***************
*** 1348,1354 ****
  				set_sig(argv[++optind]);
  				killproc = atol(argv[++optind]);
  			}
! #ifdef WIN32
  			else if (strcmp(argv[optind], "register") == 0)
  				ctl_command = REGISTER_COMMAND;
  			else if (strcmp(argv[optind], "unregister") == 0)
--- 1352,1358 ----
  				set_sig(argv[++optind]);
  				killproc = atol(argv[++optind]);
  			}
! #if defined(WIN32) || defined(__CYGWIN__)
  			else if (strcmp(argv[optind], "register") == 0)
  				ctl_command = REGISTER_COMMAND;
  			else if (strcmp(argv[optind], "unregister") == 0)
***************
*** 1438,1444 ****
  		case KILL_COMMAND:
  			do_kill(killproc);
  			break;
! #ifdef WIN32
  		case REGISTER_COMMAND:
  			pgwin32_doRegister();
  			break;
--- 1442,1448 ----
  		case KILL_COMMAND:
  			do_kill(killproc);
  			break;
! #if defined(WIN32) || defined(__CYGWIN__)
  		case REGISTER_COMMAND:
  			pgwin32_doRegister();
  			break;
