src/nexus.c
changeset 93 42ade8285570
parent 92 99661e5aac91
child 98 f357f835f0d5
equal deleted inserted replaced
92:99661e5aac91 93:42ade8285570
   234 
   234 
   235     // ok
   235     // ok
   236     return SUCCESS;
   236     return SUCCESS;
   237 }
   237 }
   238 
   238 
   239 static void on_line (char *line, void *arg)
       
   240 {
       
   241     struct nexus *nexus = arg;
       
   242 
       
   243     (void) nexus;
       
   244 
       
   245     // just dump it
       
   246     log_info("read line from console: '%s'", line);
       
   247 }
       
   248 
       
   249 static struct console_callbacks nexus_console_callbacks = {
       
   250     .on_line        = &on_line,
       
   251 };
       
   252 
       
   253 /**
   239 /**
   254  * Open the console
   240  * Open the console
   255  */
   241  */
   256 static err_t apply_console (struct nexus *nexus, struct error_info *err)
   242 static err_t apply_console (struct nexus *nexus, struct error_info *err)
   257 {
   243 {
   258     struct console_config config = {
   244     struct console_config config = {
   259         .prompt     = " > ",
   245         .prompt     = "> ",
   260     };
   246     };
   261 
   247 
   262     log_info("initializing the console");
   248     log_info("initializing the console");
   263     
   249     
   264     // just init it
   250     // init the console
   265     return console_init(&nexus->console, nexus->ev_base, &config, &nexus_console_callbacks, nexus, err);
   251     if (console_init(&nexus->console, nexus->ev_base, &config, NULL, NULL, err))
       
   252         return ERROR_CODE(err);
       
   253 
       
   254     // create the lua console on top of that
       
   255     if (lua_console_create(&nexus->lua_console, nexus->console, nexus, err))
       
   256         return ERROR_CODE(err);
       
   257 
       
   258     // ok
       
   259     return SUCCESS;
   266 }
   260 }
   267 
   261 
   268 /**
   262 /**
   269  * Parse arguments and apply them to the given nexus
   263  * Parse arguments and apply them to the given nexus
   270  */
   264  */
   333     (void) what;
   327     (void) what;
   334     
   328     
   335     log_info("Quitting...");
   329     log_info("Quitting...");
   336 
   330 
   337     // destroy the console
   331     // destroy the console
   338     if (ctx->console)
   332     if (ctx->lua_console)
   339         console_destroy(ctx->console);
   333         lua_console_destroy(ctx->lua_console);
   340 
   334 
   341     // unload the modules
   335     // unload the modules
   342     modules_unload(ctx->modules);
   336     modules_unload(ctx->modules);
   343 
   337 
   344     // quit the irc client
   338     // quit the irc client