[1178] in BarnOwl Developers
[D-O-H] r1119 - trunk/owl
daemon@ATHENA.MIT.EDU (nelhage@MIT.EDU)
Thu Oct 29 18:13:49 2009
Resent-From: nelhage@mit.edu
Resent-To: barnowl-dev-mtg@charon.mit.edu
X-Original-To: nelhage@nelhage.com
To: dirty-owl-hackers@mit.edu
From: nelhage@MIT.EDU
Reply-to: dirty-owl-hackers@MIT.EDU
Date: Mon, 1 Sep 2008 22:39:10 -0400 (EDT)
Author: nelhage
Date: 2008-09-01 22:39:10 -0400 (Mon, 01 Sep 2008)
New Revision: 1119
Modified:
trunk/owl/commands.c
Log:
Make :subscribe and :unsubscribe default to an instance of '*'
Modified: trunk/owl/commands.c
===================================================================
--- trunk/owl/commands.c 2008-08-26 00:11:16 UTC (rev 1118)
+++ trunk/owl/commands.c 2008-09-02 02:39:10 UTC (rev 1119)
@@ -192,24 +192,26 @@
OWLCMD_ARGS("subscribe", owl_command_subscribe, OWL_CTX_ANY,
"subscribe to a zephyr class, instance, recipient",
- "subscribe [-t] <class> <instance> [recipient]",
- "Subscribe the specified class and instance. If the recipient\n"
- "is not listed on the command line it defaults\n"
- "to * (the wildcard recipient). If the -t option is present\n"
- "the subscription will only be temporary, i.e., it will not\n"
- "be written to the subscription file and will therefore not\n"
- "be present the next time owl is started.\n"),
+ "subscribe [-t] <class> [instance] [recipient]",
+ "Subscribe the specified class and instance. If the\n"
+ "instance or recipient is not listed on the command\n"
+ "line they default to * (the wildcard recipient).\n"
+ "If the -t option is present the unsubscription will\n"
+ "only be temporary, i.e., it will not be written to\n"
+ "the subscription file and will therefore not be\n"
+ "present the next time owl is started.\n"),
OWLCMD_ALIAS("sub", "subscribe"),
OWLCMD_ARGS("unsubscribe", owl_command_unsubscribe, OWL_CTX_ANY,
"unsubscribe from a zephyr class, instance, recipient",
- "unsubscribe [-t] <class> <instance> [recipient]",
+ "unsubscribe [-t] <class> [instance] [recipient]",
"Unsubscribe from the specified class and instance. If the\n"
- "recipient is not listed on the command line it defaults\n"
- "to * (the wildcard recipient). If the -t option is present\n"
- "the unsubscription will only be temporary, i.e., it will not\n"
- "be updated in the subscription file and will therefore not\n"
- "be in effect the next time owl is started.\n"),
+ "instance or recipient is not listed on the command\n"
+ "line they default to * (the wildcard recipient).\n"
+ "If the -t option is present the subscription will\n"
+ "only be temporary, i.e., it will not be written to\n"
+ "the subscription file and will therefore not be\n"
+ "present the next time owl is started.\n"),
OWLCMD_ALIAS("unsub", "unsubscribe"),
OWLCMD_VOID("unsuball", owl_command_unsuball, OWL_CTX_ANY,
@@ -1742,11 +1744,11 @@
char *owl_command_subscribe(int argc, char **argv, char *buff)
{
- char *recip="";
+ char *class, *instance, *recip="";
int temp=0;
int ret=0;
-
- if (argc<3) {
+
+ if (argc < 2) {
owl_function_makemsg("Not enough arguments to the subscribe command");
return(NULL);
}
@@ -1758,25 +1760,33 @@
argc--;
argv++;
}
- if (argc<2) {
+ if (argc < 1) {
owl_function_makemsg("Not enough arguments to the subscribe command");
return(NULL);
}
- if (argc>3) {
+ if (argc > 3) {
owl_function_makemsg("Too many arguments to the subscribe command");
return(NULL);
}
- if (argc==2) {
+ class = argv[0];
+
+ if (argc == 1) {
+ instance = "*";
+ } else {
+ instance = argv[1];
+ }
+
+ if (argc <= 2) {
recip="";
} else if (argc==3) {
recip=argv[2];
}
- ret = owl_function_subscribe(argv[0], argv[1], recip);
+ ret = owl_function_subscribe(class, instance, recip);
if (!temp && !ret) {
- owl_zephyr_addsub(NULL, argv[0], argv[1], recip);
+ owl_zephyr_addsub(NULL, class, instance, recip);
}
return(NULL);
}
@@ -1784,10 +1794,10 @@
char *owl_command_unsubscribe(int argc, char **argv, char *buff)
{
- char *recip="";
+ char *class, *instance, *recip="";
int temp=0;
- if (argc<3) {
+ if (argc < 2) {
owl_function_makemsg("Not enough arguments to the unsubscribe command");
return(NULL);
}
@@ -1799,25 +1809,33 @@
argc--;
argv++;
}
- if (argc<2) {
- owl_function_makemsg("Not enough arguments to the subscribe command");
+ if (argc < 1) {
+ owl_function_makemsg("Not enough arguments to the unsubscribe command");
return(NULL);
}
- if (argc>3) {
+ if (argc > 3) {
owl_function_makemsg("Too many arguments to the unsubscribe command");
return(NULL);
}
- if (argc==2) {
+ class = argv[0];
+
+ if (argc == 1) {
+ instance = "*";
+ } else {
+ instance = argv[1];
+ }
+
+ if (argc <= 2) {
recip="";
} else if (argc==3) {
recip=argv[2];
}
- owl_function_unsubscribe(argv[0], argv[1], recip);
+ owl_function_unsubscribe(class, instance, recip);
if (!temp) {
- owl_zephyr_delsub(NULL, argv[0], argv[1], recip);
+ owl_zephyr_delsub(NULL, class, instance, recip);
}
return(NULL);
}