root/src/noit_console_state.c

Revision 58a84d386885a444866925f495594b50f1bc4623, 19.7 kB (checked in by Theo Schlossnagle <jesus@omniti.com>, 8 years ago)

expose jobq info

  • 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) return -1;
114   jobq = eventer_jobq_retrieve(argv[0]);
115   if(!jobq) {
116     nc_printf(ncct, "no jobq found for '%s'\n", argv[0] ? argv[0] : "");
117     return 0;
118   }
119   noit_console_spit_jobq(jobq, ncct);
120   return 0;
121 }
122
123 cmd_info_t console_command_help = {
124   "help", noit_console_help, noit_console_opt_delegate, NULL, NULL
125 };
126 cmd_info_t console_command_exit = {
127   "exit", noit_console_state_pop, NULL, NULL, NULL
128 };
129 cmd_info_t console_command_shutdown = {
130   "shutdown", noit_console_shutdown, NULL, NULL, NULL
131 };
132 cmd_info_t console_command_restart = {
133   "restart", noit_console_restart, NULL, NULL, NULL
134 };
135 cmd_info_t console_command_eventer_timers = {
136   "timers", noit_console_eventer_timers, NULL, NULL, NULL
137 };
138 cmd_info_t console_command_eventer_sockets = {
139   "sockets", noit_console_eventer_sockets, NULL, NULL, NULL
140 };
141 cmd_info_t console_command_eventer_jobq = {
142   "jobq", noit_console_eventer_jobq, NULL, NULL, NULL
143 };
144
145 void
146 noit_console_add_help(const char *topic, console_cmd_func_t topic_func,
147                       console_opt_func_t ac) {
148   noit_console_state_t *s = console_command_help.dstate;
149   if(!s) {
150     console_command_help.dstate = s = calloc(1, sizeof(*s));
151     noit_skiplist_init(&s->cmds);
152     noit_skiplist_set_compare(&s->cmds, cmd_info_compare, cmd_info_comparek);
153   }
154   noit_console_state_add_cmd(s, NCSCMD(topic, topic_func, ac, NULL, NULL));
155 }
156
157 static char *default_prompt = NULL;
158
159 void
160 noit_console_set_default_prompt(const char *prompt) {
161   char *tofree = default_prompt;
162   default_prompt = strdup(prompt);
163   if(tofree) free(tofree);
164 }
165 static char *
166 noit_console_state_prompt(EditLine *el) {
167   static char *tl = "noit# ";
168   if(default_prompt) return default_prompt;
169   return tl;
170 }
171
172 static char *
173 apply_replace(const char *src, const char *name, const char *value) {
174   char *result, *cp;
175   const char *nextpat, *searchstart;
176   char pat[256];
177   int maxlen, patlen, vlen, slen;
178   snprintf(pat, sizeof(pat), "{%s}", name);
179   patlen = strlen(pat);
180   vlen = strlen(value);
181   slen = strlen(src);
182   /* Worst case is just a stream of replacements. */
183   maxlen = (slen / patlen) * MAX(vlen,patlen) + (slen % patlen) + 1;
184   cp = result = malloc(maxlen);
185   searchstart = src;
186   while((nextpat = strstr(searchstart, pat)) != NULL) {
187     memcpy(cp, searchstart, nextpat - searchstart); /* pull the prefix */
188     cp += nextpat - searchstart;                    /* advance destination */
189     memcpy(cp, value, vlen);                        /* copy replacement */
190     cp += vlen;                                     /* advance destination */
191     searchstart = nextpat + patlen;                 /* set new searchstart */
192   }
193   /* Pick up the trailer (plus '\0') */
194   memcpy(cp, searchstart, strlen(searchstart)+1);
195   return result;
196 }
197 static pcre *IP_match = NULL;
198 static pcre *numeric_match = NULL;
199 static int
200 expand_range(const char *range, char ***set, int max_count, const char **err) {
201   int count, erroff, ovector[30], rv;
202   char buff[32]; /* submatches */
203   const char *pcre_err;
204   *err = NULL;
205   if(!IP_match) {
206     IP_match = pcre_compile("^(full:)?(\\d+\\.\\d+\\.\\d+\\.\\d+)/(\\d+)$",
207                             0, &pcre_err, &erroff, NULL);
208     if(!IP_match) {
209       *err = "IP match pattern failed to compile!";
210       noitL(noit_error, "pcre_compiled failed offset %d: %s\n", erroff, pcre_err);
211       return -1;
212     }
213   }
214   if(!numeric_match) {
215     numeric_match = pcre_compile("^(\\d+)(?:,(\\d+))?\\.\\.(\\d+)$",
216                                  0, &pcre_err, &erroff, NULL);
217     if(!numeric_match) {
218       *err = "numeric match pattern failed to compile!";
219       noitL(noit_error, "pcre_compiled failed offset %d: %s\n", erroff, pcre_err);
220       return -1;
221     }
222   }
223   rv = pcre_exec(IP_match, NULL, range, strlen(range), 0, 0, ovector, 30);
224   if(rv >= 0) {
225     int mask, full = 0, i;
226     u_int32_t host_addr;
227     struct in_addr addr;
228     /* 0 is the full monty, 1 is "" or "full:", 2 is the IP, 3 is the mask */
229     pcre_copy_substring(range, ovector, rv, 1, buff, sizeof(buff));
230     full = buff[0] ? 1 : 0;
231     pcre_copy_substring(range, ovector, rv, 3, buff, sizeof(buff));
232     mask = atoi(buff);
233     if(mask == 32) full = 1; /* host implies.. the host */
234     if(mask < 0 || mask > 32) {
235       *err = "invalid netmask";
236       return 0;
237     }
238     count = 1 << (32-mask);
239     pcre_copy_substring(range, ovector, rv, 2, buff, sizeof(buff));
240     if(inet_pton(AF_INET, buff, &addr) != 1) {
241       *err = "could not parse IP address";
242       return 0;
243     }
244     host_addr = ntohl(addr.s_addr);
245     host_addr &= ~((u_int32_t)count - 1);
246
247     if(!full) count -= 2; /* No network or broadcast */
248     if(count > max_count || !count) return -count;
249     if(!full) host_addr++; /* Skip the network address */
250
251     *set = malloc(count * sizeof(**set));
252     for(i=0; i<count; i++)  {
253       addr.s_addr = htonl(host_addr + i);
254       inet_ntop(AF_INET, &addr, buff, sizeof(buff));
255       (*set)[i] = strdup(buff);
256     }
257     return count;
258   }
259   rv = pcre_exec(numeric_match, NULL, range, strlen(range), 0, 0, ovector, 30);
260   if(rv >= 0) {
261     int s, n, e, i;
262     pcre_copy_substring(range, ovector, rv, 1, buff, sizeof(buff));
263     s = atoi(buff);
264     pcre_copy_substring(range, ovector, rv, 3, buff, sizeof(buff));
265     e = atoi(buff);
266     pcre_copy_substring(range, ovector, rv, 2, buff, sizeof(buff));
267     if(buff[0]) n = atoi(buff);
268     else n = (s<e) ? s+1 : s-1;
269
270     /* Ensure that s < n < e */
271     if((s<e && s>n) || (s>e && s<n)) {
272       *err = "mixed up sequence";
273       return 0;
274     }
275     i = n - s; /* Our increment */
276     count = (e - s) / i + 1;
277     *set = malloc(count * sizeof(**set));
278     count = 0;
279     for(; (i>0 && s<=e) || (i<0 && s>=e); s += i) {
280       snprintf(buff, sizeof(buff), "%d", s);
281       (*set)[count] = strdup(buff);
282       count++;
283     }
284     return count;
285   }
286   *err = "cannot understand range";
287   return 0;
288 }
289 int
290 noit_console_generic_apply(noit_console_closure_t ncct,
291                            int argc, char **argv,
292                            noit_console_state_t *dstate,
293                            void *closure) {
294   int i, j, count;
295   char *name, *range;
296   char **nargv, **expanded = NULL;
297   const char *err;
298   int problems = 0;
299   if(argc < 3) {
300     nc_printf(ncct, "apply <name> <range> cmd ...\n");
301     return -1;
302   }
303   name = argv[0];
304   range = argv[1];
305   argc -= 2;
306   argv += 2;
307
308   count = expand_range(range, &expanded, 256, &err);
309   if(!count) {
310     nc_printf(ncct, "apply error: '%s' range produced nothing [%s]\n",
311               range, err ? err : "unknown error");
312     return -1;
313   }
314   if(count < 0) {
315     nc_printf(ncct, "apply error: '%s' range would produce %d items.\n",
316               range, count);
317     return -1;
318   }
319   nargv = malloc(argc * sizeof(*nargv));
320   for(i=0; i<count; i++) {
321     for(j=0; j<argc; j++) nargv[j] = apply_replace(argv[j], name, expanded[i]);
322     if(noit_console_state_do(ncct, argc, nargv)) problems = -1;
323     for(j=0; j<argc; j++) free(nargv[j]);
324     free(expanded[i]);
325   }
326   free(nargv);
327   free(expanded);
328   return problems;
329 }
330
331 int
332 noit_console_render_help(noit_console_closure_t ncct,
333                          noit_console_state_t *dstate) {
334   noit_skiplist_node *iter = NULL;
335   if(!dstate) {
336     nc_printf(ncct, "No help available.\n");
337     return -1;
338   }
339   for(iter = noit_skiplist_getlist(&dstate->cmds); iter;
340       noit_skiplist_next(&dstate->cmds,&iter)) {
341     cmd_info_t *cmd = iter->data;
342     if(strcmp(cmd->name, "help")) nc_printf(ncct, "  ==> '%s'\n", cmd->name);
343   }
344   return 0;
345 }
346
347 int
348 noit_console_state_delegate(noit_console_closure_t ncct,
349                             int argc, char **argv,
350                             noit_console_state_t *dstate,
351                             void *closure) {
352   noit_console_state_stack_t tmps = { 0 };
353
354   if(argc == 0) {
355     noit_console_render_help(ncct, dstate);
356     nc_printf(ncct, "incomplete command.\n");
357     return -1;
358   }
359   if(!dstate) {
360     nc_printf(ncct, "internal error: no delegate state\n");
361     return -1;
362   }
363   tmps.state = dstate;
364   return _noit_console_state_do(ncct, &tmps, argc, argv);
365 }
366
367 int
368 _noit_console_state_do(noit_console_closure_t ncct,
369                        noit_console_state_stack_t *stack,
370                        int argc, char **argv) {
371   noit_skiplist_node *next, *amb = NULL;
372   cmd_info_t *cmd;
373
374   if(!argc) {
375     noit_console_render_help(ncct, stack->state);
376     nc_printf(ncct, "arguments expected\n");
377     return -1;
378   }
379   cmd = noit_skiplist_find_neighbors(&stack->state->cmds, argv[0],
380                                      NULL, NULL, &next);
381   if(!cmd) {
382     int ambiguous = 0;
383     if(next) {
384       cmd_info_t *pcmd = NULL;
385       cmd = next->data;
386       amb = next;
387       noit_skiplist_next(&stack->state->cmds, &amb);
388       if(amb) pcmd = amb->data;
389       /* So cmd is the next in line... pcmd is the one after that.
390        * If they both strncasecmp to 0, we're ambiguous,
391        *    neither, then we're not found.
392        *    only cmd, then we've found a partial, unambiguous.
393        */
394       if(strncasecmp(cmd->name, argv[0], strlen(argv[0])) == 0) {
395         if(pcmd && strncasecmp(pcmd->name, argv[0], strlen(argv[0])) == 0) {
396           cmd = NULL;
397           ambiguous = 1;
398         }
399       }
400       else
401         cmd = NULL;
402     }
403     if(!cmd) {
404       if(ambiguous || !strcmp(argv[0], "?")) {
405         char *partial = ambiguous ? argv[0] : "";
406         if(ambiguous) nc_printf(ncct, "Ambiguous command: '%s'\n", argv[0]);
407         amb = ambiguous ? next : noit_skiplist_getlist(&stack->state->cmds);
408         for(; amb; noit_skiplist_next(&stack->state->cmds, &amb)) {
409           cmd = amb->data;
410           if(!strlen(partial) || strncasecmp(cmd->name, partial, strlen(partial)) == 0)
411             nc_printf(ncct, "\t%s\n", cmd->name);
412           else
413             break;
414         }
415       }
416       else
417         nc_printf(ncct, "No such command: '%s'\n", argv[0]);
418       return -1;
419     }
420   }
421   if(ncct->state_stack->name) free(ncct->state_stack->name);
422   ncct->state_stack->name = strdup(cmd->name);
423   return cmd->func(ncct, argc-1, argv+1, cmd->dstate, cmd->closure);
424 }
425 int
426 noit_console_state_do(noit_console_closure_t ncct, int argc, char **argv) {
427   return _noit_console_state_do(ncct, ncct->state_stack, argc, argv);
428 }
429
430 noit_console_state_t *
431 noit_console_state_alloc(void) {
432   noit_console_state_t *s;
433   s = calloc(1, sizeof(*s));
434   noit_skiplist_init(&s->cmds);
435   noit_skiplist_set_compare(&s->cmds, cmd_info_compare, cmd_info_comparek);
436   noit_console_state_add_cmd(s,
437       NCSCMD("apply", noit_console_generic_apply, NULL, NULL, NULL));
438   noit_console_state_add_cmd(s, &console_command_help);
439   return s;
440 }
441
442 int
443 noit_console_state_add_cmd(noit_console_state_t *state,
444                            cmd_info_t *cmd) {
445   return (noit_skiplist_insert(&state->cmds, cmd) != NULL);
446 }
447
448 cmd_info_t *
449 noit_console_state_get_cmd(noit_console_state_t *state,
450                            const char *name) {
451   cmd_info_t *cmd;
452   cmd = noit_skiplist_find(&state->cmds, name, NULL);
453   return cmd;
454 }
455
456 noit_console_state_t *
457 noit_console_state_build(console_prompt_func_t promptf, cmd_info_t **clist,
458                          state_free_func_t sfreef) {
459   noit_console_state_t *state;
460   state = noit_console_state_alloc();
461   state->console_prompt_function = promptf;
462   while(*clist) {
463     noit_skiplist_insert(&state->cmds, *clist);
464     clist++;
465   }
466   state->statefree = sfreef;
467   return state;
468 }
469
470 cmd_info_t *NCSCMD(const char *name, console_cmd_func_t func,
471                    console_opt_func_t ac,
472                    noit_console_state_t *dstate, void *closure) {
473   cmd_info_t *cmd;
474   cmd = calloc(1, sizeof(*cmd));
475   cmd->name = strdup(name);
476   cmd->func = func;
477   cmd->autocomplete = ac;
478   cmd->dstate = dstate;
479   cmd->closure = closure;
480   return cmd;
481 }
482
483 noit_console_state_t *
484 noit_console_mksubdelegate(noit_console_state_t *parent, const char *cmd) {
485   noit_console_state_t *child;
486   cmd_info_t *existing;
487   existing = noit_console_state_get_cmd(parent, cmd);
488   if(existing) return existing->dstate;
489   child = noit_console_state_alloc();
490   noit_console_state_add_cmd(parent,
491                               NCSCMD(cmd, noit_console_state_delegate,
492                                      noit_console_opt_delegate, child, NULL));
493   return child;
494 }
495
496 noit_console_state_t *
497 noit_console_state_initial() {
498   static noit_console_state_t *_top_level_state = NULL;
499   if(!_top_level_state) {
500     static noit_console_state_t *no_state, *show_state, *evdeb;
501     _top_level_state = noit_console_state_alloc();
502     noit_console_state_add_cmd(_top_level_state, &console_command_exit);
503     show_state = noit_console_mksubdelegate(_top_level_state, "show");
504     no_state = noit_console_mksubdelegate(_top_level_state, "no");
505
506     noit_console_state_add_cmd(_top_level_state, &console_command_shutdown);
507     noit_console_state_add_cmd(_top_level_state, &console_command_restart);
508
509     evdeb = noit_console_mksubdelegate(
510               noit_console_mksubdelegate(show_state,
511                                          "eventer"),
512                                        "debug");
513     noit_console_state_add_cmd(evdeb, &console_command_eventer_timers);
514     noit_console_state_add_cmd(evdeb, &console_command_eventer_sockets);
515     noit_console_state_add_cmd(evdeb, &console_command_eventer_jobq);
516   }
517   return _top_level_state;
518 }
519
520 void
521 noit_console_state_push_state(noit_console_closure_t ncct,
522                               noit_console_state_t *state) {
523   noit_console_state_stack_t *stack;
524   stack = calloc(1, sizeof(*stack));
525   stack->last = ncct->state_stack;
526   stack->state = state;
527   ncct->state_stack = stack;
528 }
529
530 int
531 noit_console_shutdown(noit_console_closure_t ncct, int argc, char **argv,
532                       noit_console_state_t *dstate, void *unused) {
533   exit(2);
534 }
535 int
536 noit_console_restart(noit_console_closure_t ncct, int argc, char **argv,
537                      noit_console_state_t *dstate, void *unused) {
538   exit(1);
539 }
540 int
541 noit_console_help(noit_console_closure_t ncct, int argc, char **argv,
542                   noit_console_state_t *dstate, void *unused) {
543   noit_console_state_stack_t *current;
544   current = ncct->state_stack;
545
546   if(!argc) {
547     noit_console_state_stack_t *i;
548     if(!current) {
549       nc_printf(ncct, "no state!\n");
550       return -1;
551     }
552     for(i=current;i;i=i->last) {
553       if(i != current)
554         nc_printf(ncct, " -> '%s'\n", i->name ? i->name : "(null)");
555     }
556     if(dstate) {
557       nc_printf(ncct, "= Topics =\n");
558       noit_console_render_help(ncct, dstate);
559     }
560     if(current->state) {
561       nc_printf(ncct, "\n= Commands =\n");
562       noit_console_render_help(ncct, current->state);
563     }
564     return 0;
565   }
566   else if(argc > 0) {
567     nc_printf(ncct, "Help for '%s':\n", argv[0]);
568     if(noit_console_state_delegate(ncct, argc, argv, dstate, NULL) == 0)
569       return 0;
570   }
571   nc_printf(ncct, "command not understood.\n");
572   return -1;
573 }
574 int
575 noit_console_state_pop(noit_console_closure_t ncct, int argc, char **argv,
576                        noit_console_state_t *dstate, void *unused) {
577   noit_console_state_stack_t *current;
578
579   if(argc) {
580     nc_printf(ncct, "no arguments allowed to this command.\n");
581     return -1;
582   }
583   if(!ncct->state_stack || !ncct->state_stack->last) {
584     ncct->wants_shutdown = 1;
585     return 0;
586   }
587
588   current = ncct->state_stack;
589   ncct->state_stack = current->last;
590   current->last = NULL;
591   if(current->state->statefree) current->state->statefree(current->state);
592   if(current->name) free(current->name);
593   free(current);
594   noit_console_state_init(ncct);
595   return 0;
596 }
597
598 int
599 noit_console_state_init(noit_console_closure_t ncct) {
600   if(ncct->el) {
601     console_prompt_func_t f;
602     f = ncct->state_stack->state->console_prompt_function;
603     el_set(ncct->el, EL_PROMPT, f ? f : noit_console_state_prompt);
604   }
605   return 0;
606 }
Note: See TracBrowser for help on using the browser.