BOOL CnpadBookApp::InitInstance() { CWinApp::InitInstance(); pluginInit((HANDLE)this->m_hInstance); deleteTempDir(); return TRUE; }
BOOL APIENTRY DllMain( HANDLE hModule, DWORD reasonForCall, LPVOID lpReserved ) { switch (reasonForCall) { case DLL_PROCESS_ATTACH: pluginInit(hModule); break; case DLL_PROCESS_DETACH: pluginCleanUp(); break; case DLL_THREAD_ATTACH: break; case DLL_THREAD_DETACH: break; } return TRUE; }
void *init() { if ((config = malloc(sizeof(CONFIG))) == NULL) { fprintf(stderr, "[CONFIG] First malloc failed. Let's just give up :P\n"); return NULL; } config->net.network_active = "CONFIG"; pluginInit(); configRead("conf/fanbot3.conf", CONFIG_ALL); networkConnectAll(); config->reload = config->reload_filters = 0; for (;!config->reload;) { networkWait(); if (config->reload_filters) { config->net.network_active = "CONFIG"; filterReload("conf/fanbot3.conf"); } } return config; }
ExecutionOptions::ExecutionOptions (int ac, char **av, Description *desc, Driver *driver) { static int verbose_flag; //Flag set by `--verbose` pluginPath = ""; pluginCmd = false; passRef = ""; pluginPos = PASS_POS_UNKNOWN; handlingOkay = true; static option long_options[] = { //These options set a flag { "verbose", no_argument, &verbose_flag, 1 }, { "brief", no_argument, &verbose_flag, 0 }, //These options don't set a flag. We distinguish them by their indices { "asm", no_argument, 0, 'c' }, //Assembly inline { "list-passes", no_argument, 0, 'l' }, //List of passes currently used { "file-number", required_argument, 0, 'n' }, //Number of file to proceed { "help", no_argument, 0, 'h' }, //Help { "version", no_argument, 0, 'v' }, //Version of the tool { "fplugin", required_argument, 0, 'f' }, //Plugin path { 0, 0, 0, 0 } }; //getopt_long stores the option index here int option_index = 0; int opt; //Detect the end of the options while ((opt = getopt_long (ac, av, "cln:hvf:", long_options, &option_index)) != -1) { switch (opt) { case 0: //If this option set a flag, do nothing else now if (long_options[option_index].flag != 0) { break; } std::cout << "option " << long_options[option_index].name; if (optarg) { std::cout << " with arg " << optarg << std::endl; } break; case 'c': { if (desc != NULL) { //Set the c extension to the output desc->setOutputExtension (".c"); //Inlinig the assembly code desc->setAsmVolatile (true); } } break; case 'l': { if (driver != NULL) { PassEngine *currentPassEngine = driver->getPassEngine (); std::list<Pass*> currentListPasses; currentListPasses = currentPassEngine->getListPasses (); //There no passes if size is 0 if (currentListPasses.size () == 0) { Logging::log (1, "Warning: PassEngine has no passes, it is stopping", NULL); return; } std::cout << "The list of passes currenty used by the driver: " << std::endl; //Print the list of passes currently used for (std::list<Pass *>::iterator it = currentListPasses.begin (); it != currentListPasses.end (); it++) { Pass *p = *it; std::cerr << "-> " << p->getName () << std::endl; } } } break; case 'h': { differentOptions (); } break; case 'v': { std::cout << "\033[1mMicro-creator version: 1.0\033[0m" << std::endl; } break; case 'n': { std::istringstream iss (optarg); int startCounter; //Register it iss >> startCounter; desc->setFileCounterStart (startCounter); } break; case 'f': //Plugin execution option { //Get the name of the plugin and the path to this plugin std::string pluginStr = ""; if (getPluginName (optarg, pluginStr) == false) { return; } //Open the shared library void* plugin = dlopen (pluginStr.c_str (), RTLD_LAZY); if (!plugin) { std::cerr << "Cannot load library : " << dlerror () << std::endl; return; } void (*pluginInit) (Driver*, Description*); pluginInit = (void(*) (Driver*, Description*)) dlsym (plugin, "pluginInit"); //Paranoid const char *dlsym_error = dlerror (); if (dlsym_error) { std::cerr << "Cannot load symbol initPlugin: " << dlsym_error << std::endl; return; } if ((driver != NULL) && (desc != NULL)) { pluginInit (driver, desc); } } break; default: // Do nothing break; } //We report the final status resulting from `--verbose` and `--brief` if (desc != NULL) { if (verbose_flag == 1) { desc->setVerbose (true); } else { desc->setVerbose (false); } } } }