+ cr->matches = i9e_complete_commands(ci->word, completers);
+}
+
+static void stat_completer(struct i9e_completion_info *ci,
+ struct i9e_completion_result *cr)
+{
+ char *opts[] = {LSG_SERVER_CMD_STAT_OPTS, NULL};
+ i9e_complete_option(opts, ci, cr);
+}
+
+static void version_completer(struct i9e_completion_info *ci,
+ struct i9e_completion_result *cr)
+{
+ char *opts[] = {LSG_SERVER_CMD_VERSION_OPTS, NULL};
+ i9e_complete_option(opts, ci, cr);
+}
+
+static void sender_completer(struct i9e_completion_info *ci,
+ struct i9e_completion_result *cr)
+{
+ char *senders[] = {"http", "dccp", "udp", NULL};
+ char *http_cmds[] = {"on", "off", "allow", "deny", "help", NULL};
+ char *dccp_cmds[] = {"on", "off", "allow", "deny", "help", NULL};
+ char *udp_cmds[] ={"on", "off", "add", "delete", "help", NULL};
+ char *sender;
+ char **cmds;
+
+ //PARA_CRIT_LOG("wn: %d\n", ci->word_num);
+ if (ci->word_num == 0 || ci->word_num > 3)
+ return;
+ if (ci->word_num == 1 || (ci->word_num == 2 && *ci->word != '\0')) {
+ i9e_extract_completions(ci->word, senders, &cr->matches);
+ return;
+ }
+ sender = ci->argv[1];
+ //PARA_CRIT_LOG("sender: %s\n", sender);
+ if (strcmp(sender, "http") == 0)
+ cmds = http_cmds;
+ else if (strcmp(sender, "dccp") == 0)
+ cmds = dccp_cmds;
+ else if (strcmp(sender, "udp") == 0)
+ cmds = udp_cmds;
+ else
+ return;
+ i9e_extract_completions(ci->word, cmds, &cr->matches);
+}
+
+static void add_completer(struct i9e_completion_info *ci,
+ struct i9e_completion_result *cr)
+{
+ char *opts[] = {LSG_SERVER_CMD_ADD_OPTS, NULL};
+
+ if (ci->word[0] == '-')
+ i9e_complete_option(opts, ci, cr);
+ cr->filename_completion_desired = true;
+}
+
+static void ls_completer(struct i9e_completion_info *ci,
+ struct i9e_completion_result *cr)
+{
+ char *opts[] = {LSG_SERVER_CMD_LS_OPTS, NULL};
+ if (ci->word[0] == '-')
+ i9e_complete_option(opts, ci, cr);
+ cr->filename_completion_desired = true;
+}
+
+static void setatt_completer(struct i9e_completion_info *ci,
+ struct i9e_completion_result *cr)
+{
+ char *buf, **sl;
+ int i, ret, num_atts;
+
+ if (ci->word_num == 0)
+ return;
+
+ if (*ci->word == '/' || *ci->word == '\0')
+ cr->filename_completion_desired = true;
+ if (*ci->word == '/')
+ return;
+ ret = execute_client_command("lsatt", &buf);
+ if (ret < 0)
+ return;
+ ret = create_argv(buf, "\n", &sl);
+ if (ret < 0)
+ goto out;
+ num_atts = ret;
+ sl = para_realloc(sl, (2 * num_atts + 1) * sizeof(char *));
+ for (i = 0; i < num_atts; i++) {
+ char *orig = sl[i];
+ sl[i] = make_message("%s+", orig);
+ sl[num_atts + i] = make_message("%s-", orig);
+ free(orig);
+ }
+ sl[2 * num_atts] = NULL;
+ i9e_extract_completions(ci->word, sl, &cr->matches);
+out:
+ free(buf);
+ free_argv(sl);
+}
+
+static void lsatt_completer(struct i9e_completion_info *ci,
+ struct i9e_completion_result *cr)
+{
+ char *opts[] = {LSG_SERVER_CMD_LSATT_OPTS, NULL};
+ i9e_complete_option(opts, ci, cr);
+}
+
+static void mvatt_completer(struct i9e_completion_info *ci,
+ struct i9e_completion_result *cr)
+{
+ complete_attributes(ci->word, &cr->matches);
+}
+
+static void rmatt_completer(struct i9e_completion_info *ci,
+ struct i9e_completion_result *cr)
+{
+ complete_attributes(ci->word, &cr->matches);
+}
+
+static void check_completer(struct i9e_completion_info *ci,
+ struct i9e_completion_result *cr)
+{
+ char *opts[] = {LSG_SERVER_CMD_CHECK_OPTS, NULL};
+ i9e_complete_option(opts, ci, cr);
+}
+
+static void rm_completer(struct i9e_completion_info *ci,
+ struct i9e_completion_result *cr)
+{
+ char *opts[] = {LSG_SERVER_CMD_RM_OPTS, NULL};
+
+ if (ci->word[0] == '-') {
+ i9e_complete_option(opts, ci, cr);