Changeset bde7714 for commands.c


Ignore:
Timestamp:
Sep 22, 2002, 3:20:00 PM (22 years ago)
Author:
James M. Kretchmar <kretch@mit.edu>
Branches:
master, barnowl_perlaim, debian, owl, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
5a6e6b9
Parents:
f9c43ae
Message:
Started updating the intro document
Small changes to help / about
The 'subscribe' and 'unsubscribe' commands (and their aliases)
  update .zephyr.subs by default.  If either is given the '-t'
  (for "temporary") option the .zephyr.subs will not be updated
File:
1 edited

Legend:

Unmodified
Added
Removed
  • commands.c

    r42abb10 rbde7714  
    132132  OWLCMD_ARGS("subscribe", owl_command_subscribe, OWL_CTX_ANY,
    133133              "subscribe to a zephyr class, instance, recipient",
    134               "subscribe <class> <instance> [recipient]",
     134              "subscribe [-t] <class> <instance> [recipient]",
    135135              "Subscribe the specified class and instance.  If the recipient\n"
    136136              "is not listed on the command line it defaults\n"
    137               "to * (the wildcard recipient).\n"),
     137              "to * (the wildcard recipient).  If the -t option is present\n"
     138              "the subscription will only be temporary, i.e., it will not\n"
     139              "be written to the subscription file and will therefore not\n"
     140              "be present the next time owl is started.\n"),
    138141  OWLCMD_ALIAS("sub", "subscribe"),
    139142
    140143  OWLCMD_ARGS("unsubscribe", owl_command_unsubscribe, OWL_CTX_ANY,
    141144              "unsubscribe from a zephyr class, instance, recipient",
    142               "unsubscribe <class> <instance> [recipient]",
     145              "unsubscribe [-t] <class> <instance> [recipient]",
    143146              "Unsubscribe from the specified class and instance.  If the\n"
    144147              "recipient is not listed on the command line it defaults\n"
    145               "to * (the wildcard recipient).\n"),
     148              "to * (the wildcard recipient).  If the -t option is present\n"
     149              "the unsubscription will only be temporary, i.e., it will not\n"
     150              "be updated in the subscription file and will therefore not\n"
     151              "be in effect the next time owl is started.\n"),
    146152  OWLCMD_ALIAS("unsub", "unsubscribe"),
    147153
     
    724730}
    725731
    726 char *owl_command_zlist(int argc, char **argv) {
     732char *owl_command_zlist(int argc, char **argv, char *buff) {
    727733  int elapsed=0, timesort=0;
    728734  char *file=NULL;
     
    11311137char *owl_command_subscribe(int argc, char **argv, char *buff) {
    11321138  char *recip="";
    1133 
     1139  int temp=0;
     1140 
    11341141  if (argc<3) {
    11351142    owl_function_makemsg("Not enough arguments to the subscribe command");
    1136     return NULL;
    1137   } else if (argc>4) {
     1143    return(NULL);
     1144  }
     1145  argc--;
     1146  argv++;
     1147
     1148  if (!strcmp(argv[0], "-t")) {
     1149    temp=1;
     1150    argc--;
     1151    argv++;
     1152  }
     1153  if (argc<2) {
     1154    owl_function_makemsg("Not enough arguments to the subscribe command");
     1155    return(NULL);
     1156  }
     1157
     1158  if (argc>3) {
    11381159    owl_function_makemsg("Too many arguments to the subscribe command");
    1139     return NULL;
    1140   }
    1141 
    1142   if (argc==3) {
     1160    return(NULL);
     1161  }
     1162
     1163  if (argc==2) {
    11431164    recip="";
    1144   } else if (argc==4) {
    1145     recip=argv[3];
    1146   }
    1147 
    1148   owl_function_subscribe(argv[1], argv[2], recip);
    1149   return NULL;
     1165  } else if (argc==3) {
     1166    recip=argv[2];
     1167  }
     1168
     1169  owl_function_subscribe(argv[0], argv[1], recip);
     1170  if (!temp) {
     1171    owl_zephyr_addsub(NULL, argv[0], argv[1], recip);
     1172  }
     1173  return(NULL);
    11501174}
    11511175
     
    11531177char *owl_command_unsubscribe(int argc, char **argv, char *buff) {
    11541178  char *recip="";
     1179  int temp=0;
    11551180
    11561181  if (argc<3) {
    11571182    owl_function_makemsg("Not enough arguments to the unsubscribe command");
    1158     return NULL;
    1159   } else if (argc>4) {
     1183    return(NULL);
     1184  }
     1185  argc--;
     1186  argv++;
     1187
     1188  if (!strcmp(argv[0], "-t")) {
     1189    temp=1;
     1190    argc--;
     1191    argv++;
     1192  }
     1193  if (argc<2) {
     1194    owl_function_makemsg("Not enough arguments to the subscribe command");
     1195    return(NULL);
     1196  }
     1197
     1198  if (argc>3) {
    11601199    owl_function_makemsg("Too many arguments to the unsubscribe command");
    1161     return NULL;
    1162   }
    1163 
    1164   if (argc==3) {
     1200    return(NULL);
     1201  }
     1202
     1203  if (argc==2) {
    11651204    recip="";
    1166   } else if (argc==4) {
    1167     recip=argv[3];
    1168   }
    1169 
    1170   owl_function_unsubscribe(argv[1], argv[2], recip);
    1171   return NULL;
     1205  } else if (argc==3) {
     1206    recip=argv[2];
     1207  }
     1208
     1209  owl_function_unsubscribe(argv[0], argv[1], recip);
     1210  if (!temp) {
     1211    owl_zephyr_delsub(NULL, argv[0], argv[1], recip);
     1212  }
     1213  return(NULL);
    11721214}
    11731215
     
    16751717  owl_global_set_needrefresh(&g);
    16761718}
    1677 
Note: See TracChangeset for help on using the changeset viewer.