Mail Archives: cygwin/2002/02/23/19:25:17
------=_NextPart_000_10a1_44ff_2321
Content-Type: text/plain; format=flowed
Hi All...
OOPS! I forgot to update the usage and error strings. You may like this
patch file better.
Thanks,
...Karl
>From: "Karl M" <karlm30 AT hotmail DOT com>
>To: cygwin AT cygwin DOT com
>Subject: cygrunsrv patch proposal
>Date: Sat, 23 Feb 2002 15:57:11 -0800
>
>Hi All...
>
>The attached patch adds the ability for cygrunsrv to set the service
>description field in the registry.
>
>Thanks,
>
>...Karl
>
>
>_________________________________________________________________
>Chat with friends online, try MSN Messenger: http://messenger.msn.com
><< cygrunsrv-description-patch.txt >>
>--
>Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
>Bug reporting: http://cygwin.com/bugs.html
>Documentation: http://cygwin.com/docs.html
>FAQ: http://cygwin.com/faq/
_________________________________________________________________
Join the world’s largest e-mail service with MSN Hotmail.
http://www.hotmail.com
------=_NextPart_000_10a1_44ff_2321
Content-Type: text/plain; name="cygrunsrv-description-patch.txt"; format=flowed
Content-Transfer-Encoding: 8bit
Content-Disposition: attachment; filename="cygrunsrv-description-patch.txt"
diff -up old/cygrunsrv.cc new/cygrunsrv.cc
--- old/cygrunsrv.cc Fri Oct 19 02:12:14 2001
+++ new/cygrunsrv.cc Sat Feb 23 14:57:41 2002
@@ -55,6 +55,7 @@ struct option longopts[] = {
{ "chdir", required_argument, NULL, 'c' },
{ "env", required_argument, NULL, 'e' },
{ "disp", required_argument, NULL, 'd' },
+ { "desc", required_argument, NULL, 'f' },
{ "user", required_argument, NULL, 'u' },
{ "passwd", required_argument, NULL, 'w' },
{ "type", required_argument, NULL, 't' },
@@ -69,7 +70,7 @@ struct option longopts[] = {
{ 0, no_argument, NULL, 0 }
};
-char *opts = "I:R:S:E:p:a:c:e:d:ou:w:t:s:y:0:1:2:hv";
+char *opts = "I:R:S:E:p:a:c:e:d:f:ou:w:t:s:y:0:1:2:hv";
char *appname;
char *svcname;
@@ -123,20 +124,33 @@ eval_wait_time (register DWORD wait)
/* Installs the subkeys of the service registry entry so that cygrunsrv
can determine what application to start on service startup. */
int
-install_registry_keys (const char *name, const char *path,
+install_registry_keys (const char *name, const char *desc, const char
*path,
char *args, char *dir, env_t *env, DWORD termsig,
const char *in_stdin, const char *in_stdout,
const char *in_stderr, DWORD shutdown)
{
HKEY srv_key = NULL;
HKEY env_key = NULL;
+ HKEY desc_key = NULL;
DWORD disp;
- char param_key[MAX_PATH];
+ char reg_key[MAX_PATH];
char *err_func;
DWORD err = 0;
- strcat (strcat (strcpy (param_key, SRV_KEY), name), PARAM_KEY);
- if (RegCreateKeyEx (HKEY_LOCAL_MACHINE, param_key, 0, "",
+ strcat (strcpy (reg_key, SRV_KEY), name);
+ if (desc)
+ {
+ if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, reg_key, 0,
+ KEY_ALL_ACCESS, &desc_key) != ERROR_SUCCESS)
+ err_out (RegOpenKeyEx);
+ if (RegSetValueEx (desc_key, DESC, 0, REG_SZ,
+ (const BYTE *) desc, strlen (desc) + 1) !=
ERROR_SUCCESS)
+ err_out (RegSetValueEx);
+ RegFlushKey (desc_key);
+ }
+
+ strcat (reg_key, PARAM_KEY);
+ if (RegCreateKeyEx (HKEY_LOCAL_MACHINE, reg_key, 0, "",
REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS,
NULL, &srv_key, &disp) != ERROR_SUCCESS)
err_out (RegCreateKeyEx);
@@ -193,6 +207,8 @@ install_registry_keys (const char *name,
out:
if (env_key)
RegCloseKey (env_key);
+ if (desc_key)
+ RegCloseKey (desc_key);
if (srv_key)
RegCloseKey (srv_key);
return err == 0 ? 0 : error (InstallErr, err_func, err);
@@ -1029,6 +1045,7 @@ main (int argc, char **argv)
int c;
action_t action = Undefined;
char *in_name = NULL;
+ char *in_desc = NULL;
char *in_path = NULL;
char *in_args = NULL;
char *in_dir = NULL;
@@ -1124,6 +1141,13 @@ main (int argc, char **argv)
return error (OnlyOneDisp);
in_disp = optarg;
break;
+ case 'f':
+ if (action != Install)
+ return error (DescNotAllowed);
+ if (in_desc)
+ return error (OnlyOneDesc);
+ in_desc = optarg;
+ break;
case 'o':
if (action != Install)
return error (ShutdownNotAllowed);
@@ -1221,8 +1245,8 @@ main (int argc, char **argv)
return error (InvalidPath);
if (ret = install_service (in_name, in_disp, in_type, in_user,
in_pass, in_deps))
return ret;
- if (ret = install_registry_keys (in_name, in_path, in_args, in_dir,
- in_env, in_termsig,
+ if (ret = install_registry_keys (in_name, in_desc, in_path, in_args,
+ in_dir, in_env, in_termsig,
in_stdin, in_stdout, in_stderr,
in_shutdown))
remove_service (in_name);
diff -up old/cygrunsrv.h new/cygrunsrv.h
--- old/cygrunsrv.h Fri Jun 22 18:10:56 2001
+++ new/cygrunsrv.h Sat Feb 23 15:05:28 2002
@@ -21,7 +21,8 @@
#ifndef _CYGRUNSRV_H
#define _CYGRUNSRV_H
-#define SRV_KEY "SYSTEM\\CurrentControlSet\\Services\\"
+#define SRV_KEY "SYSTEM\\CurrentControlSet\\Services\\"
+#define DESC "Description"
#define PARAM_KEY "\\Parameters"
#define PARAM_PATH "AppPath"
#define PARAM_ARGS "AppArgs"
diff -up old/utils.cc new/utils.cc
--- old/utils.cc Fri Jun 22 18:10:56 2001
+++ new/utils.cc Sat Feb 23 16:21:34 2002
@@ -44,6 +44,8 @@ char *reason_list[] = {
"--env is only allowed with --install",
"--disp is only allowed with --install",
"Only one --disp is allowed",
+ "--desc is only allowed with --install",
+ "Only one --desc is allowed",
"--user is only allowed with --install",
"Only one --user is allowed",
"--pass is only allowed with --install",
@@ -139,6 +141,7 @@ usage ()
uprint (" started applications to find at
least cygwin1.dll.");
uprint (" -d, --disp <display name> Optional string which contains the
display name");
uprint (" of the service. Defaults to service
name.");
+ uprint (" -f, --desc <description> Optional string which contains the
service description.");
uprint (" -t, --type [auto|manual] Optional start type of service.
Defaults to `auto'.");
uprint (" -u, --user <user name> Optional user name to start service
as.");
uprint (" Defaults to SYSTEM account.");
diff -up old/utils.h new/utils.h
--- old/utils.h Fri Jun 22 18:10:56 2001
+++ new/utils.h Sat Feb 23 16:10:24 2002
@@ -35,6 +35,8 @@ enum reason_t {
EnvNotAllowed,
DispNotAllowed,
OnlyOneDisp,
+ DescNotAllowed,
+ OnlyOneDesc,
UserNotAllowed,
OnlyOneUser,
PassNotAllowed,
------=_NextPart_000_10a1_44ff_2321
Content-Type: text/plain; charset=us-ascii
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
------=_NextPart_000_10a1_44ff_2321--
- Raw text -