version 1.18, 2011/07/03 18:18:15 |
version 1.19, 2011/07/08 06:37:57 |
|
|
const char *inputs, *prompts; |
const char *inputs, *prompts; |
struct cmd_command_prompt_cdata *cdata; |
struct cmd_command_prompt_cdata *cdata; |
struct client *c; |
struct client *c; |
char *input = NULL; |
char *prompt, *ptr, *input = NULL; |
char *prompt, *prompt_replaced, *ptr; |
|
size_t n; |
size_t n; |
|
|
if ((c = cmd_find_client(ctx, args_get(args, 't'))) == NULL) |
if ((c = cmd_find_client(ctx, args_get(args, 't'))) == NULL) |
|
|
ptr = strsep(&cdata->next_prompt, ","); |
ptr = strsep(&cdata->next_prompt, ","); |
if (prompts == NULL) |
if (prompts == NULL) |
prompt = xstrdup(ptr); |
prompt = xstrdup(ptr); |
else { |
else |
prompt_replaced = status_replace(c, NULL, NULL, NULL, ptr, |
xasprintf(&prompt, "%s ", ptr); |
time(NULL), 0); |
|
xasprintf(&prompt, "%s ", prompt_replaced); |
|
xfree(prompt_replaced); |
|
} |
|
|
|
/* Get initial prompt input. */ |
/* Get initial prompt input. */ |
if ((inputs = args_get(args, 'I')) != NULL) { |
if ((inputs = args_get(args, 'I')) != NULL) { |
cdata->inputs = xstrdup(inputs); |
cdata->inputs = xstrdup(inputs); |
cdata->next_input = cdata->inputs; |
cdata->next_input = cdata->inputs; |
ptr = strsep(&cdata->next_input, ","); |
input = strsep(&cdata->next_input, ","); |
|
|
input = status_replace(c, NULL, NULL, NULL, ptr, time(NULL), |
|
0); |
|
} |
} |
|
|
status_prompt_set(c, prompt, input, cmd_command_prompt_callback, |
status_prompt_set(c, prompt, input, cmd_command_prompt_callback, |
cmd_command_prompt_free, cdata, 0); |
cmd_command_prompt_free, cdata, 0); |
|
|
if (input != NULL) |
|
xfree(input); |
|
xfree(prompt); |
xfree(prompt); |
|
|
return (0); |
return (0); |
|
|
struct client *c = cdata->c; |
struct client *c = cdata->c; |
struct cmd_list *cmdlist; |
struct cmd_list *cmdlist; |
struct cmd_ctx ctx; |
struct cmd_ctx ctx; |
char *cause, *new_template, *prompt; |
char *cause, *new_template, *prompt, *ptr; |
char *prompt_replaced, *ptr, *input = NULL; |
char *input = NULL; |
|
|
if (s == NULL) |
if (s == NULL) |
return (0); |
return (0); |
|
|
* and update the prompt data. |
* and update the prompt data. |
*/ |
*/ |
if ((ptr = strsep(&cdata->next_prompt, ",")) != NULL) { |
if ((ptr = strsep(&cdata->next_prompt, ",")) != NULL) { |
prompt_replaced = status_replace(c, NULL, NULL, NULL, ptr, |
xasprintf(&prompt, "%s ", ptr); |
time(NULL), 0); |
input = strsep(&cdata->next_input, ","); |
xasprintf(&prompt, "%s ", prompt_replaced); |
|
|
|
/* Find next input and expand special sequences. */ |
|
if ((ptr = strsep(&cdata->next_input, ",")) != NULL) { |
|
input = status_replace(c, NULL, NULL, NULL, ptr, |
|
time(NULL), 0); |
|
} |
|
|
|
status_prompt_update(c, prompt, input); |
status_prompt_update(c, prompt, input); |
|
|
if (input != NULL) |
|
xfree(input); |
|
xfree(prompt_replaced); |
|
xfree(prompt); |
xfree(prompt); |
|
|
cdata->idx++; |
cdata->idx++; |
return (1); |
return (1); |
} |
} |