static int idaapi init(void) { const char * plugin_options = NULL; msg(LPREFIX "idarub loaded, " COPYZ "\n"); // Support batch mode local file evaluation, via -OIdaRub:file:blah.rb // will eventually support a way to launch the server if(plugin_options = get_plugin_options("IdaRub")) { init_ruby(); if(strncmp(plugin_options, "file:", 5) == 0) run_ruby_file(plugin_options + 5); } return PLUGIN_KEEP; }
static void idaapi run(int arg) { unsigned short loadfile = 0; unsigned int sport = 1234, eport = 1239; char ip[16] = "0.0.0.0"; const char * filename; char foo[] = "STARTITEM 3\n" // shortcut to quickly load files, etc "IdaRub!\n" "Sucka Free!\n\n" "<Listen IP :A:15:15::>\n" "<Start Port :D:5:5::>\n" "<End Port :D:5:5::>\n" "<Start Server:R><Load File:R><Load Last File:R>>\n\n\n\n"; // make sure ruby has been loaded... init_ruby(); if(server_running()) { if(!AskUsingForm_c("IdaRub!\nStop Server\n\n")) return; stop_server(); msg(LPREFIX "stopped the rub\n"); } else { if(!AskUsingForm_c(foo, &ip, &sport, &eport, &loadfile)) return; switch(loadfile) { case 2: // Load Last File run_ruby_file(NULL); break; case 1: // Load File filename = askfile_c(0, "*.rb", "Select Ruby script..."); if(filename) run_ruby_file(filename); break; case 0: // Start Server start_server(ip, sport, eport); break; } } }
int main(int argc, char *argv[]) { #ifndef _WIN32 if (geteuid() == 0) { fprintf(stderr, "Running IRC services is root is not recommended."); return 1; } setup_corefile(); #endif memset(&ServicesInfo, 0, sizeof(ServicesInfo)); memset(&ServicesState, 0, sizeof(ServicesState)); ServicesState.configfile = CPATH; ServicesState.logfile = LPATH; ServicesState.pidfile = PPATH; ServicesState.fully_connected = 0; parseargs(&argc, &argv, myopts); if(ServicesState.printversion) { printf("oftc-ircservices: version: %s\n", VERSION); exit(EXIT_SUCCESS); } if(chdir(DPATH)) { perror("chdir"); exit(EXIT_FAILURE); } #ifndef _WIN32 if(!ServicesState.foreground) make_daemon(); else print_startup(getpid()); #endif setup_signals(); memset(&me, 0, sizeof(me)); libio_init(!ServicesState.foreground); init_events(); iorecv_cb = register_callback("iorecv", iorecv_default); connected_cb = register_callback("server connected", server_connected); iosend_cb = register_callback("iosend", iosend_default); OpenSSL_add_all_digests(); init_interface(); check_pidfile(ServicesState.pidfile); init_log(ServicesState.logfile); #ifdef HAVE_RUBY init_ruby(); signal(SIGSEGV, SIG_DFL); #endif init_channel(); init_conf(); init_client(); init_parser(); init_channel_modes(); init_mqueue(); init_tor(); me.from = me.servptr = &me; SetServer(&me); SetMe(&me); dlinkAdd(&me, &me.node, &global_client_list); read_services_conf(TRUE); init_db(); init_uid(); #ifdef HAVE_PYTHON init_python(); #endif init_kill(); write_pidfile(ServicesState.pidfile); ilog(L_NOTICE, "Services Ready"); db_load_driver(); #ifdef USE_SHARED_MODULES if(chdir(MODPATH)) { ilog(L_ERROR, "Could not load core modules from %s: %s", MODPATH, strerror(errno)); exit(EXIT_FAILURE); } /* Go back to DPATH after checking to see if we can chdir to MODPATH */ chdir(DPATH); #else load_all_modules(1); #endif boot_modules(1); connect_server(); for(;;) { while (eventNextTime() <= CurrentTime) eventRun(); execute_callback(do_event_cb); if(events_loop() == -1) { ilog(L_CRIT, "libevent returned error %d", errno); services_die("Libevent returned some sort of error", NO); break; } comm_select(); send_queued_all(); if(dorehash) { ilog(L_INFO, "Got SIGHUP, reloading configuration"); read_services_conf(NO); dorehash = 0; } } return 0; }