patch for cygserver

Joshua Daniel Franklin joshua@iocc.com
Tue Aug 20 18:24:00 GMT 2002


In my personal opinion, all of the exe's in the cygwin package
should support (at a minimum) the GNU --help and --version options.
With that in mind, here is a patch for cygserver.cc that shoehorns them
in.

Now, I understand that cygserver is in a rather volitile state and it
very well may be better for one of the people who are actually working
on cygserver to create their own similar patch instead of using this
one. I only ask that it be done sometime, since AFAIK there is absolutely
no documentation (other than the mailing list) for cygserver. I would be
happy to create some if someone could give me a good rundown of what
all is/is not supported at this time. Unfortunately my limited understanding
of IPC might make this more trouble than it is worth.

ChangeLog:

2002-08-20  Joshua Daniel Franklin <joshuadfranklin@yahoo.com>

	* cygserver.cc (usage): New function.
	(print_version): New function.
-------------- next part --------------
--- cygserver.cc-orig	2002-08-18 10:57:06.000000000 -0500
+++ cygserver.cc	2002-08-18 11:09:24.000000000 -0500
@@ -449,6 +449,40 @@ struct option longopts[] = {
 
 char opts[] = "s";
 
+static void
+usage (FILE *where = stderr)
+{
+  fprintf (where , ""
+        "Usage: cygserver [-s]\n"
+        " -s, --shutdown  shutdown cygserver\n"
+        " -h, --help      output usage information and exit\n"
+        " -v, --version   output version information and exit\n"
+        "");
+  exit (where == stderr ? 1 : 0);
+}
+
+static void
+print_version ()
+{
+  char version[200];
+  /* Cygwin dll release */
+  snprintf (version, 200, "%d.%d.%d(%d.%d/%d/%d)-(%d.%d.%d.%d) %s",
+		 cygwin_version.dll_major / 1000,
+		 cygwin_version.dll_major % 1000,
+		 cygwin_version.dll_minor,
+		 cygwin_version.api_major,
+		 cygwin_version.api_minor,
+		 cygwin_version.shared_data,
+		 CYGWIN_SERVER_VERSION_MAJOR,
+		 CYGWIN_SERVER_VERSION_API,
+		 CYGWIN_SERVER_VERSION_MINOR,
+		 CYGWIN_SERVER_VERSION_PATCH,
+		 cygwin_version.mount_registry,
+		 cygwin_version.dll_build_date);
+  setbuf (stdout, NULL);
+  printf ("Cygwin IPC daemon version %s\n", version);
+}
+
 int
 main (int argc, char **argv)
 {
@@ -458,9 +492,14 @@ main (int argc, char **argv)
   while ((i = getopt_long (argc, argv, opts, longopts, NULL)) != EOF)
     switch (i)
       {
+      case 'h':
+      	usage (stdout);
       case 's':
 	shutdown = 1;
 	break;
+      case 'v':
+      	print_version ();
+	exit (0);
       default:
 	break;
        /*NOTREACHED*/
@@ -487,23 +526,9 @@ main (int argc, char **argv)
       exit(0);
     }
 
-  char version[200];
-  /* Cygwin dll release */
-  snprintf (version, 200, "%d.%d.%d(%d.%d/%d/%d)-(%d.%d.%d.%d) %s",
-		 cygwin_version.dll_major / 1000,
-		 cygwin_version.dll_major % 1000,
-		 cygwin_version.dll_minor,
-		 cygwin_version.api_major,
-		 cygwin_version.api_minor,
-		 cygwin_version.shared_data,
-		 CYGWIN_SERVER_VERSION_MAJOR,
-		 CYGWIN_SERVER_VERSION_API,
-		 CYGWIN_SERVER_VERSION_MINOR,
-		 CYGWIN_SERVER_VERSION_PATCH,
-		 cygwin_version.mount_registry,
-		 cygwin_version.dll_build_date);
-  setbuf (stdout, NULL);
-  printf ("daemon version %s starting up", version);
+  print_version();
+  printf ("starting up");
+
   if (signal (SIGQUIT, handle_signal) == SIG_ERR)
     {
       printf ("\ncould not install signal handler (%d)- aborting startup\n", errno);


More information about the Cygwin-patches mailing list