- PARA_INFO_LOG("status %d\n", p->status);
- t->ret = 1;
- if (p->fd < 0)
- return;
- if (!p->check_r && !p->check_w)
- return;
- if (p->check_r && !FD_ISSET(p->fd, &s->rfds))
- return;
- if (p->check_w && !FD_ISSET(p->fd, &s->wfds))
- return;
- switch (p->status) {
- case CL_CONNECTED: /* receive welcome message */
- t->ret = client_recv_buffer(p);
- if (t->ret > 0)
- p->status = CL_RECEIVED_WELCOME;
- return;
- case CL_RECEIVED_WELCOME: /* send auth command */
- sprintf(p->buf, "auth %s%s", p->conf.plain_given?
- "" : "rc4 ", p->user);
- PARA_INFO_LOG("--> %s\n", p->buf);
- t->ret = send_buffer(p->fd, p->buf);
- if (t->ret >= 0)
- p->status = CL_SENT_AUTH;
+ if (ci->word[0] == '-')
+ return i9e_complete_option(opts, ci, cr);
+ generic_blob_complete(blob_type, ci, cr);
+}
+
+static void complete_rmblob(const char *blob_type,
+ struct i9e_completion_info *ci,
+ struct i9e_completion_result *cr)
+{
+ generic_blob_complete(blob_type, ci, cr);
+}
+
+static void complete_mvblob(const char *blob_type,
+ struct i9e_completion_info *ci,
+ struct i9e_completion_result *cr)
+{
+ generic_blob_complete(blob_type, ci, cr);
+}
+
+/* these don't need any completions */
+I9E_DUMMY_COMPLETER(ff);
+I9E_DUMMY_COMPLETER(hup);
+I9E_DUMMY_COMPLETER(jmp);
+I9E_DUMMY_COMPLETER(next);
+I9E_DUMMY_COMPLETER(nomore);
+I9E_DUMMY_COMPLETER(pause);
+I9E_DUMMY_COMPLETER(play);
+I9E_DUMMY_COMPLETER(si);
+I9E_DUMMY_COMPLETER(term);
+I9E_DUMMY_COMPLETER(version);
+I9E_DUMMY_COMPLETER(stop);
+I9E_DUMMY_COMPLETER(addatt);
+I9E_DUMMY_COMPLETER(init);
+
+static struct i9e_completer completers[];
+
+static void help_completer(struct i9e_completion_info *ci,
+ struct i9e_completion_result *result)
+{
+ result->matches = i9e_complete_commands(ci->word, completers);
+}
+
+static void stat_completer(struct i9e_completion_info *ci,
+ struct i9e_completion_result *cr)
+{
+ char *opts[] = {"-n=", "-p", NULL};
+ //PARA_CRIT_LOG("word: %s\n", ci->word);
+ 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)