root/src/noit_console_state.c

Revision 9be14abfe879c074d58adf36e86a38e2882a8b28, 19.8 kB (checked in by Theo Schlossnagle <jesus@omniti.com>, 3 years ago)

clearer error message

  • Property mode set to 100644
Line 
1 /*
2  * Copyright (c) 2007, OmniTI Computer Consulting, Inc.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are
7  * met:
8  *
9  *     * Redistributions of source code must retain the above copyright
10  *       notice, this list of conditions and the following disclaimer.
11  *     * Redistributions in binary form must reproduce the above
12  *       copyright notice, this list of conditions and the following
13  *       disclaimer in the documentation and/or other materials provided
14  *       with the distribution.
15  *     * Neither the name OmniTI Computer Consulting, Inc. nor the names
16  *       of its contributors may be used to endorse or promote products
17  *       derived from this software without specific prior written
18  *       permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32
33 #include "noit_defines.h"
34
35 #include "eventer/eventer.h"
36 #include "eventer/eventer_jobq.h"
37 #include "utils/noit_log.h"
38 #include "utils/noit_hash.h"
39 #include "noit_listener.h"
40 #include "noit_console.h"
41 #include "noit_tokenizer.h"
42 #include "noit_module.h"
43
44 #include <netinet/in.h>
45 #include <arpa/inet.h>
46 #include <pcre.h>
47
48 int cmd_info_comparek(const void *akv, const void *bv) {
49   char *ak = (char *)akv;
50   cmd_info_t *b = (cmd_info_t *)bv;
51   return strcasecmp(ak, b->name);
52 }
53 int cmd_info_compare(const void *av, const void *bv) {
54   cmd_info_t *a = (cmd_info_t *)av;
55   cmd_info_t *b = (cmd_info_t *)bv;
56   return strcasecmp(a->name, b->name);
57 }
58 static void
59 noit_console_spit_event(eventer_t e, void *c) {
60   struct timeval now, diff;
61   noit_console_closure_t ncct = c;
62   char fdstr[12];
63   char wfn[42];
64   char funcptr[20];
65   const char *cname;
66
67   cname = eventer_name_for_callback(e->callback);
68   snprintf(fdstr, sizeof(fdstr), " fd: %d", e->fd);
69   gettimeofday(&now, NULL);
70   sub_timeval(e->whence, now, &diff);
71   snprintf(wfn, sizeof(wfn), " fires: %lld.%06ds", (long long)diff.tv_sec, (int)diff.tv_usec);
72   snprintf(funcptr, sizeof(funcptr), "%p", e->callback);
73   nc_printf(ncct, "  [%p]%s%s [%c%c%c%c] -> %s(%p)\n",
74             e,
75             e->mask & (EVENTER_READ | EVENTER_WRITE | EVENTER_EXCEPTION) ? fdstr : "",
76             e->mask & (EVENTER_TIMER) ?  wfn : "",
77             e->mask & EVENTER_READ ? 'r' : '-',
78             e->mask & EVENTER_WRITE ? 'w' : '-',
79             e->mask & EVENTER_EXCEPTION ? 'e' : '-',
80             e->mask & EVENTER_TIMER ? 't' : '-',
81             cname ? cname : funcptr, e->closure);
82 }
83 static void
84 noit_console_spit_jobq(eventer_jobq_t *jobq, void *c) {
85   noit_console_closure_t ncct = c;
86   int qlen = 0;
87   const char *bqn = "(undefined)";
88   if(jobq->backq && jobq->backq->queue_name) bqn = jobq->backq->queue_name;
89   nc_printf(ncct, "=== %s ===\n", jobq->queue_name);
90   nc_printf(ncct, " concurrency: %d\n", jobq->concurrency);
91   nc_printf(ncct, " backq: %s\n", bqn);
92   sem_getvalue(&jobq->semaphore, &qlen);
93   nc_printf(ncct, " queue size: %d\n", qlen);
94 }
95 static int
96 noit_console_eventer_timers(noit_console_closure_t ncct, int argc, char **argv,
97                             noit_console_state_t *dstate, void *unused) {
98   if(argc != 0) return -1;
99   eventer_foreach_timedevent(noit_console_spit_event, ncct);
100   return 0;
101 }
102 static int
103 noit_console_eventer_sockets(noit_console_closure_t ncct, int argc, char **argv,
104                              noit_console_state_t *dstate, void *unused) {
105   if(argc != 0) return -1;
106   eventer_foreach_fdevent(noit_console_spit_event, ncct);
107   return 0;
108 }
109 static int
110 noit_console_eventer_jobq(noit_console_closure_t ncct, int argc, char **argv,
111                              noit_console_state_t *dstate, void *unused) {
112   eventer_jobq_t *jobq;
113   if(argc != 1) {
114     nc_printf(ncct, "jobq <queue_name>\n");
115     return -1;
116   }
117   jobq = eventer_jobq_retrieve(argv[0]);
118   if(!jobq) {
119     nc_printf(ncct, "no jobq found for '%s'\n", argv[0] ? argv[0] : "");
120     return 0;
121   }
122   noit_console_spit_jobq(jobq, ncct);
123   return 0;
124 }
125
126 cmd_info_t console_command_help = {
127   "help", noit_console_help, noit_console_opt_delegate, NULL, NULL
128 };
129 cmd_info_t console_command_exit = {
130   "exit", noit_console_state_pop, NULL, NULL, NULL
131 };
132 cmd_info_t console_command_shutdown = {
133   "shutdown", noit_console_shutdown, NULL, NULL, NULL
134 };
135 cmd_info_t console_command_restart = {
136   "restart", noit_console_restart, NULL, NULL, NULL
137 };
138 cmd_info_t console_command_eventer_timers = {
139   "timers", noit_console_eventer_timers, NULL, NULL, NULL
140 };
141 cmd_info_t console_command_eventer_sockets = {
142   "sockets", noit_console_eventer_sockets, NULL, NULL, NULL
143 };
144 cmd_info_t console_command_eventer_jobq = {
145   "jobq", noit_console_eventer_jobq, NULL, NULL, NULL
146 };
147
148 void
149 noit_console_add_help(const char *topic, console_cmd_func_t topic_func,
150                       console_opt_func_t ac) {
151   noit_console_state_t *s = console_command_help.dstate;
152   if(!s) {
153     console_command_help.dstate = s = calloc(1, sizeof(*s));
154     noit_skiplist_init(&s->cmds);
155     noit_skiplist_set_compare(&s->cmds, cmd_info_compare, cmd_info_comparek);
156   }
157   noit_console_state_add_cmd(s, NCSCMD(topic, topic_func, ac, NULL, NULL));
158 }
159
160 static char *default_prompt = NULL;
161
162 void
163 noit_console_set_default_prompt(const char *prompt) {
164   char *tofree = default_prompt;
165   default_prompt = strdup(prompt);
166   if(tofree) free(tofree);
167 }
168 static char *
169 noit_console_state_prompt(EditLine *el) {
170   static char *tl = "noit# ";
171   if(default_prompt) return default_prompt;
172   return tl;
173 }
174
175 static char *
176 apply_replace(const char *src, const char *name, const char *value) {
177   char *result, *cp;
178   const char *nextpat, *searchstart;
179   char pat[256];
180   int maxlen, patlen, vlen, slen;
181   snprintf(pat, sizeof(pat), "{%s}", name);
182   patlen = strlen(pat);
183   vlen = strlen(value);
184   slen = strlen(src);
185   /* Worst case is just a stream of replacements. */
186   maxlen = (slen / patlen) * MAX(vlen,patlen) + (slen % patlen) + 1;
187   cp = result = malloc(maxlen);
188   searchstart = src;
189   while((nextpat = strstr(searchstart, pat)) != NULL) {
190     memcpy(cp, searchstart, nextpat - searchstart); /* pull the prefix */
191     cp += nextpat - searchstart;                    /* advance destination */
192     memcpy(cp, value, vlen);                        /* copy replacement */
193     cp += vlen;                                     /* advance destination */
194     searchstart = nextpat + patlen;                 /* set new searchstart */
195   }
196   /* Pick up the trailer (plus '\0') */
197   memcpy(cp, searchstart, strlen(searchstart)+1);
198   return result;
199 }
200 static pcre *IP_match = NULL;
201 static pcre *numeric_match = NULL;
202 static int
203 expand_range(const char *range, char ***set, int max_count, const char **err) {
204   int count, erroff, ovector[30], rv;
205   char buff[32]; /* submatches */
206   const char *pcre_err;
207   *err = NULL;
208   if(!IP_match) {
209     IP_match = pcre_compile("^(full:)?(\\d+\\.\\d+\\.\\d+\\.\\d+)/(\\d+)$",
210                             0, &pcre_err, &erroff, NULL);
211     if(!IP_match) {
212       *err = "IP match pattern failed to compile!";
213       noitL(noit_error, "pcre_compiled failed offset %d: %s\n", erroff, pcre_err);
214       return -1;
215     }
216   }
217   if(!numeric_match) {
218     numeric_match = pcre_compile("^(\\d+)(?:,(\\d+))?\\.\\.(\\d+)$",
219                                  0, &pcre_err, &erroff, NULL);
220     if(!numeric_match) {
221       *err = "numeric match pattern failed to compile!";
222       noitL(noit_error, "pcre_compiled failed offset %d: %s\n", erroff, pcre_err);
223       return -1;
224     }
225   }
226   rv = pcre_exec(IP_match, NULL, range, strlen(range), 0, 0, ovector, 30);
227   if(rv >= 0) {
228     int mask, full = 0, i;
229     u_int32_t host_addr;
230     struct in_addr addr;
231     /* 0 is the full monty, 1 is "" or "full:", 2 is the IP, 3 is the mask */
232     pcre_copy_substring(range, ovector, rv, 1, buff, sizeof(buff));
233     full = buff[0] ? 1 : 0;
234     pcre_copy_substring(range, ovector, rv, 3, buff, sizeof(buff));
235     mask = atoi(buff);
236     if(mask == 32) full = 1; /* host implies.. the host */
237     if(mask < 0 || mask > 32) {
238       *err = "invalid netmask";
239       return 0;
240     }
241     count = 1 << (32-mask);
242     pcre_copy_substring(range, ovector, rv, 2, buff, sizeof(buff));
243     if(inet_pton(AF_INET, buff, &addr) != 1) {
244       *err = "could not parse IP address";
245       return 0;
246     }
247     host_addr = ntohl(addr.s_addr);
248     host_addr &= ~((u_int32_t)count - 1);
249
250     if(!full) count -= 2; /* No network or broadcast */
251     if(count > max_count || !count) return -count;
252     if(!full) host_addr++; /* Skip the network address */
253
254     *set = malloc(count * sizeof(**set));
255     for(i=0; i<count; i++)  {
256       addr.s_addr = htonl(host_addr + i);
257       inet_ntop(AF_INET, &addr, buff, sizeof(buff));
258       (*set)[i] = strdup(buff);
259     }
260     return count;
261   }
262   rv = pcre_exec(numeric_match, NULL, range, strlen(range), 0, 0, ovector, 30);
263   if(rv >= 0) {
264     int s, n, e, i;
265     pcre_copy_substring(range, ovector, rv, 1, buff, sizeof(buff));
266     s = atoi(buff);
267     pcre_copy_substring(range, ovector, rv, 3, buff, sizeof(buff));
268     e = atoi(buff);
269     pcre_copy_substring(range, ovector, rv, 2, buff, sizeof(buff));
270     if(buff[0]) n = atoi(buff);
271     else n = (s<e) ? s+1 : s-1;
272
273     /* Ensure that s < n < e */
274     if((s<e && s>n) || (s>e && s<n)) {
275       *err = "mixed up sequence";
276       return 0;
277     }
278     i = n - s; /* Our increment */
279     count = (e - s) / i + 1;
280     *set = malloc(count * sizeof(**set));
281     count = 0;
282     for(; (i>0 && s<=e) || (i<0 && s>=e); s += i) {
283       snprintf(buff, sizeof(buff), "%d", s);
284       (*set)[count] = strdup(buff);
285       count++;
286     }
287     return count;
288   }
289   *err = "cannot understand range";
290   return 0;
291 }
292 int
293 noit_console_generic_apply(noit_console_closure_t ncct,
294                            int argc, char **argv,
295                            noit_console_state_t *dstate,
296                            void *closure) {
297   int i, j, count;
298   char *name, *range;
299   char **nargv, **expanded = NULL;
300   const char *err;
301   int problems = 0;
302   if(argc < 3) {
303     nc_printf(ncct, "apply <name> <range> cmd ...\n");
304     return -1;
305   }
306   name = argv[0];
307   range = argv[1];
308   argc -= 2;
309   argv += 2;
310
311   count = expand_range(range, &expanded, 256, &err);
312   if(!count) {
313     nc_printf(ncct, "apply error: '%s' range produced nothing [%s]\n",
314               range, err ? err : "unknown error");
315     return -1;
316   }
317   if(count < 0) {
318     nc_printf(ncct, "apply error: '%s' range would produce %d items.\n",
319               range, count);
320     return -1;
321   }
322   nargv = malloc(argc * sizeof(*nargv));
323   for(i=0; i<count; i++) {
324     for(j=0; j<argc; j++) nargv[j] = apply_replace(argv[j], name, expanded[i]);
325     if(noit_console_state_do(ncct, argc, nargv)) problems = -1;
326     for(j=0; j<argc; j++) free(nargv[j]);
327     free(expanded[i]);
328   }
329   free(nargv);
330   free(expanded);
331   return problems;
332 }
333
334 int
335 noit_console_render_help(noit_console_closure_t ncct,
336                          noit_console_state_t *dstate) {
337   noit_skiplist_node *iter = NULL;
338   if(!dstate) {
339     nc_printf(ncct, "No help available.\n");
340     return -1;
341   }
342   for(iter = noit_skiplist_getlist(&dstate->cmds); iter;
343       noit_skiplist_next(&dstate->cmds,&iter)) {
344     cmd_info_t *cmd = iter->data;
345     if(strcmp(cmd->name, "help")) nc_printf(ncct, "  ==> '%s'\n", cmd->name);
346   }
347   return 0;
348 }
349
350 int
351 noit_console_state_delegate(noit_console_closure_t ncct,
352                             int argc, char **argv,
353                             noit_console_state_t *dstate,
354                             void *closure) {
355   noit_console_state_stack_t tmps = { 0 };
356
357   if(argc == 0) {
358     noit_console_render_help(ncct, dstate);
359     nc_printf(ncct, "incomplete command.\n");
360     return -1;
361   }
362   if(!dstate) {
363     nc_printf(ncct, "internal error: no delegate state\n");
364     return -1;
365   }
366   tmps.state = dstate;
367   return _noit_console_state_do(ncct, &tmps, argc, argv);
368 }
369
370 int
371 _noit_console_state_do(noit_console_closure_t ncct,
372                        noit_console_state_stack_t *stack,
373                        int argc, char **argv) {
374   noit_skiplist_node *next, *amb = NULL;
375   cmd_info_t *cmd;
376
377   if(!argc) {
378     noit_console_render_help(ncct, stack->state);
379     nc_printf(ncct, "arguments expected\n");
380     return -1;
381   }
382   cmd = noit_skiplist_find_neighbors(&stack->state->cmds, argv[0],
383                                      NULL, NULL, &next);
384   if(!cmd) {
385     int ambiguous = 0;
386     if(next) {
387       cmd_info_t *pcmd = NULL;
388       cmd = next->data;
389       amb = next;
390       noit_skiplist_next(&stack->state->cmds, &amb);
391       if(amb) pcmd = amb->data;
392       /* So cmd is the next in line... pcmd is the one after that.
393        * If they both strncasecmp to 0, we're ambiguous,
394        *    neither, then we're not found.
395        *    only cmd, then we've found a partial, unambiguous.
396        */
397       if(strncasecmp(cmd->name, argv[0], strlen(argv[0])) == 0) {
398         if(pcmd && strncasecmp(pcmd->name, argv[0], strlen(argv[0])) == 0) {
399           cmd = NULL;
400           ambiguous = 1;
401         }
402       }
403       else
404         cmd = NULL;
405     }
406     if(!cmd) {
407       if(ambiguous || !strcmp(argv[0], "?")) {
408         char *partial = ambiguous ? argv[0] : "";
409         if(ambiguous) nc_printf(ncct, "Ambiguous command: '%s'\n", argv[0]);
410         amb = ambiguous ? next : noit_skiplist_getlist(&stack->state->cmds);
411         for(; amb; noit_skiplist_next(&stack->state->cmds, &amb)) {
412           cmd = amb->data;
413           if(!strlen(partial) || strncasecmp(cmd->name, partial, strlen(partial)) == 0)
414             nc_printf(ncct, "\t%s\n", cmd->name);
415           else
416             break;
417         }
418       }
419       else
420         nc_printf(ncct, "No such command: '%s'\n", argv[0]);
421       return -1;
422     }
423   }
424   if(ncct->state_stack->name) free(ncct->state_stack->name);
425   ncct->state_stack->name = strdup(cmd->name);
426   return cmd->func(ncct, argc-1, argv+1, cmd->dstate, cmd->closure);
427 }
428 int
429 noit_console_state_do(noit_console_closure_t ncct, int argc, char **argv) {
430   return _noit_console_state_do(ncct, ncct->state_stack, argc, argv);
431 }
432
433 noit_console_state_t *
434 noit_console_state_alloc(void) {
435   noit_console_state_t *s;
436   s = calloc(1, sizeof(*s));
437   noit_skiplist_init(&s->cmds);
438   noit_skiplist_set_compare(&s->cmds, cmd_info_compare, cmd_info_comparek);
439   noit_console_state_add_cmd(s,
440       NCSCMD("apply", noit_console_generic_apply, NULL, NULL, NULL));
441   noit_console_state_add_cmd(s, &console_command_help);
442   return s;
443 }
444
445 int
446 noit_console_state_add_cmd(noit_console_state_t *state,
447                            cmd_info_t *cmd) {
448   return (noit_skiplist_insert(&state->cmds, cmd) != NULL);
449 }
450
451 cmd_info_t *
452 noit_console_state_get_cmd(noit_console_state_t *state,
453                            const char *name) {
454   cmd_info_t *cmd;
455   cmd = noit_skiplist_find(&state->cmds, name, NULL);
456   return cmd;
457 }
458
459 noit_console_state_t *
460 noit_console_state_build(console_prompt_func_t promptf, cmd_info_t **clist,
461                          state_free_func_t sfreef) {
462   noit_console_state_t *state;
463   state = noit_console_state_alloc();
464   state->console_prompt_function = promptf;
465   while(*clist) {
466     noit_skiplist_insert(&state->cmds, *clist);
467     clist++;
468   }
469   state->statefree = sfreef;
470   return state;
471 }
472
473 cmd_info_t *NCSCMD(const char *name, console_cmd_func_t func,
474                    console_opt_func_t ac,
475                    noit_console_state_t *dstate, void *closure) {
476   cmd_info_t *cmd;
477   cmd = calloc(1, sizeof(*cmd));
478   cmd->name = strdup(name);
479   cmd->func = func;
480   cmd->autocomplete = ac;
481   cmd->dstate = dstate;
482   cmd->closure = closure;
483   return cmd;
484 }
485
486 noit_console_state_t *
487 noit_console_mksubdelegate(noit_console_state_t *parent, const char *cmd) {
488   noit_console_state_t *child;
489   cmd_info_t *existing;
490   existing = noit_console_state_get_cmd(parent, cmd);
491   if(existing) return existing->dstate;
492   child = noit_console_state_alloc();
493   noit_console_state_add_cmd(parent,
494                               NCSCMD(cmd, noit_console_state_delegate,
495                                      noit_console_opt_delegate, child, NULL));
496   return child;
497 }
498
499 noit_console_state_t *
500 noit_console_state_initial() {
501   static noit_console_state_t *_top_level_state = NULL;
502   if(!_top_level_state) {
503     static noit_console_state_t *no_state, *show_state, *evdeb;
504     _top_level_state = noit_console_state_alloc();
505     noit_console_state_add_cmd(_top_level_state, &console_command_exit);
506     show_state = noit_console_mksubdelegate(_top_level_state, "show");
507     no_state = noit_console_mksubdelegate(_top_level_state, "no");
508
509     noit_console_state_add_cmd(_top_level_state, &console_command_shutdown);
510     noit_console_state_add_cmd(_top_level_state, &console_command_restart);
511
512     evdeb = noit_console_mksubdelegate(
513               noit_console_mksubdelegate(show_state,
514                                          "eventer"),
515                                        "debug");
516     noit_console_state_add_cmd(evdeb, &console_command_eventer_timers);
517     noit_console_state_add_cmd(evdeb, &console_command_eventer_sockets);
518     noit_console_state_add_cmd(evdeb, &console_command_eventer_jobq);
519   }
520   return _top_level_state;
521 }
522
523 void
524 noit_console_state_push_state(noit_console_closure_t ncct,
525                               noit_console_state_t *state) {
526   noit_console_state_stack_t *stack;
527   stack = calloc(1, sizeof(*stack));
528   stack->last = ncct->state_stack;
529   stack->state = state;
530   ncct->state_stack = stack;
531 }
532
533 int
534 noit_console_shutdown(noit_console_closure_t ncct, int argc, char **argv,
535                       noit_console_state_t *dstate, void *unused) {
536   exit(2);
537 }
538 int
539 noit_console_restart(noit_console_closure_t ncct, int argc, char **argv,
540                      noit_console_state_t *dstate, void *unused) {
541   exit(1);
542 }
543 int
544 noit_console_help(noit_console_closure_t ncct, int argc, char **argv,
545                   noit_console_state_t *dstate, void *unused) {
546   noit_console_state_stack_t *current;
547   current = ncct->state_stack;
548
549   if(!argc) {
550     noit_console_state_stack_t *i;
551     if(!current) {
552       nc_printf(ncct, "no state!\n");
553       return -1;
554     }
555     for(i=current;i;i=i->last) {
556       if(i != current)
557         nc_printf(ncct, " -> '%s'\n", i->name ? i->name : "(null)");
558     }
559     if(dstate) {
560       nc_printf(ncct, "= Topics =\n");
561       noit_console_render_help(ncct, dstate);
562     }
563     if(current->state) {
564       nc_printf(ncct, "\n= Commands =\n");
565       noit_console_render_help(ncct, current->state);
566     }
567     return 0;
568   }
569   else if(argc > 0) {
570     nc_printf(ncct, "Help for '%s':\n", argv[0]);
571     if(noit_console_state_delegate(ncct, argc, argv, dstate, NULL) == 0)
572       return 0;
573   }
574   nc_printf(ncct, "command not understood.\n");
575   return -1;
576 }
577 int
578 noit_console_state_pop(noit_console_closure_t ncct, int argc, char **argv,
579                        noit_console_state_t *dstate, void *unused) {
580   noit_console_state_stack_t *current;
581
582   if(argc) {
583     nc_printf(ncct, "no arguments allowed to this command.\n");
584     return -1;
585   }
586   if(!ncct->state_stack || !ncct->state_stack->last) {
587     ncct->wants_shutdown = 1;
588     return 0;
589   }
590
591   current = ncct->state_stack;
592   ncct->state_stack = current->last;
593   current->last = NULL;
594   if(current->state->statefree) current->state->statefree(current->state);
595   if(current->name) free(current->name);
596   free(current);
597   noit_console_state_init(ncct);
598   return 0;
599 }
600
601 int
602 noit_console_state_init(noit_console_closure_t ncct) {
603   if(ncct->el) {
604     console_prompt_func_t f;
605     f = ncct->state_stack->state->console_prompt_function;
606     el_set(ncct->el, EL_PROMPT, f ? f : noit_console_state_prompt);
607   }
608   return 0;
609 }
Note: See TracBrowser for help on using the browser.