Changeset f830d84 for commands.c


Ignore:
Timestamp:
Sep 1, 2008, 10:39:10 PM (16 years ago)
Author:
Nelson Elhage <nelhage@mit.edu>
Branches:
master, debian, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
fd472a7
Parents:
740d5f7
Message:
Make :subscribe and :unsubscribe default to an instance of '*'
File:
1 edited

Legend:

Unmodified
Added
Removed
  • commands.c

    rcdc6ff1 rf830d84  
    193193  OWLCMD_ARGS("subscribe", owl_command_subscribe, OWL_CTX_ANY,
    194194              "subscribe to a zephyr class, instance, recipient",
    195               "subscribe [-t] <class> <instance> [recipient]",
    196               "Subscribe the specified class and instance.  If the recipient\n"
    197               "is not listed on the command line it defaults\n"
    198               "to * (the wildcard recipient).  If the -t option is present\n"
    199               "the subscription will only be temporary, i.e., it will not\n"
    200               "be written to the subscription file and will therefore not\n"
    201               "be present the next time owl is started.\n"),
     195              "subscribe [-t] <class> [instance] [recipient]",
     196              "Subscribe the specified class and instance.  If the\n"
     197              "instance or recipient is not listed on the command\n"
     198              "line they default to * (the wildcard recipient).\n"
     199              "If the -t option is present the unsubscription will\n"
     200              "only be temporary, i.e., it will not be written to\n"
     201              "the subscription file and will therefore not be\n"
     202              "present the next time owl is started.\n"),
    202203  OWLCMD_ALIAS("sub", "subscribe"),
    203204
    204205  OWLCMD_ARGS("unsubscribe", owl_command_unsubscribe, OWL_CTX_ANY,
    205206              "unsubscribe from a zephyr class, instance, recipient",
    206               "unsubscribe [-t] <class> <instance> [recipient]",
     207              "unsubscribe [-t] <class> [instance] [recipient]",
    207208              "Unsubscribe from the specified class and instance.  If the\n"
    208               "recipient is not listed on the command line it defaults\n"
    209               "to * (the wildcard recipient).  If the -t option is present\n"
    210               "the unsubscription will only be temporary, i.e., it will not\n"
    211               "be updated in the subscription file and will therefore not\n"
    212               "be in effect the next time owl is started.\n"),
     209              "instance or recipient is not listed on the command\n"
     210              "line they default to * (the wildcard recipient).\n"
     211              "If the -t option is present the subscription will\n"
     212              "only be temporary, i.e., it will not be written to\n"
     213              "the subscription file and will therefore not be\n"
     214              "present the next time owl is started.\n"),
    213215  OWLCMD_ALIAS("unsub", "unsubscribe"),
    214216
     
    17431745char *owl_command_subscribe(int argc, char **argv, char *buff)
    17441746{
    1745   char *recip="";
     1747  char *class, *instance, *recip="";
    17461748  int temp=0;
    17471749  int ret=0;
    1748  
    1749   if (argc<3) {
     1750
     1751  if (argc < 2) {
    17501752    owl_function_makemsg("Not enough arguments to the subscribe command");
    17511753    return(NULL);
     
    17591761    argv++;
    17601762  }
    1761   if (argc<2) {
     1763  if (argc < 1) {
    17621764    owl_function_makemsg("Not enough arguments to the subscribe command");
    17631765    return(NULL);
    17641766  }
    17651767
    1766   if (argc>3) {
     1768  if (argc > 3) {
    17671769    owl_function_makemsg("Too many arguments to the subscribe command");
    17681770    return(NULL);
    17691771  }
    17701772
    1771   if (argc==2) {
     1773  class = argv[0];
     1774
     1775  if (argc == 1) {
     1776    instance = "*";
     1777  } else {
     1778    instance = argv[1];
     1779  }
     1780
     1781  if (argc <= 2) {
    17721782    recip="";
    17731783  } else if (argc==3) {
     
    17751785  }
    17761786
    1777   ret = owl_function_subscribe(argv[0], argv[1], recip);
     1787  ret = owl_function_subscribe(class, instance, recip);
    17781788  if (!temp && !ret) {
    1779     owl_zephyr_addsub(NULL, argv[0], argv[1], recip);
     1789    owl_zephyr_addsub(NULL, class, instance, recip);
    17801790  }
    17811791  return(NULL);
     
    17851795char *owl_command_unsubscribe(int argc, char **argv, char *buff)
    17861796{
    1787   char *recip="";
     1797  char *class, *instance, *recip="";
    17881798  int temp=0;
    17891799
    1790   if (argc<3) {
     1800  if (argc < 2) {
    17911801    owl_function_makemsg("Not enough arguments to the unsubscribe command");
    17921802    return(NULL);
     
    18001810    argv++;
    18011811  }
    1802   if (argc<2) {
    1803     owl_function_makemsg("Not enough arguments to the subscribe command");
    1804     return(NULL);
    1805   }
    1806 
    1807   if (argc>3) {
     1812  if (argc < 1) {
     1813    owl_function_makemsg("Not enough arguments to the unsubscribe command");
     1814    return(NULL);
     1815  }
     1816
     1817  if (argc > 3) {
    18081818    owl_function_makemsg("Too many arguments to the unsubscribe command");
    18091819    return(NULL);
    18101820  }
    18111821
    1812   if (argc==2) {
     1822  class = argv[0];
     1823
     1824  if (argc == 1) {
     1825    instance = "*";
     1826  } else {
     1827    instance = argv[1];
     1828  }
     1829
     1830  if (argc <= 2) {
    18131831    recip="";
    18141832  } else if (argc==3) {
     
    18161834  }
    18171835
    1818   owl_function_unsubscribe(argv[0], argv[1], recip);
     1836  owl_function_unsubscribe(class, instance, recip);
    18191837  if (!temp) {
    1820     owl_zephyr_delsub(NULL, argv[0], argv[1], recip);
     1838    owl_zephyr_delsub(NULL, class, instance, recip);
    18211839  }
    18221840  return(NULL);
Note: See TracChangeset for help on using the changeset viewer.