static char * mono_extension_handle_native_sigsegv_libunwind (void *ctx, MONO_SIG_HANDLER_INFO_TYPE *info) { char *dl_err; int unw_err; unw_init_local_t unw_init_local_fn; unw_get_reg_t unw_get_reg_fn; unw_get_proc_name_t unw_get_proc_name_fn; unw_step_t unw_step_fn; unw_cursor_t cursor; size_t frames = 0; MonoDl *dl = mono_dl_open ("libunwind.so", MONO_DL_LAZY, &dl_err); if (!dl) return dl_err; LOAD_SYM (dl, dl_err, UNW_OBJ (init_local), unw_init_local_fn); LOAD_SYM (dl, dl_err, UNW_OBJ (get_reg), unw_get_reg_fn); LOAD_SYM (dl, dl_err, UNW_OBJ (get_proc_name), unw_get_proc_name_fn); LOAD_SYM (dl, dl_err, UNW_OBJ (step), unw_step_fn); if ((unw_err = unw_init_local_fn (&cursor, ctx))) { mono_dl_close (dl); return g_strdup_printf ("unw_init_local () returned %d", unw_err); } do { int reg_err; unw_word_t ip, off; char name [FUNC_NAME_LENGTH]; if ((reg_err = unw_get_reg_fn (&cursor, UNW_REG_IP, &ip))) { mono_runtime_printf_err ("unw_get_reg (UNW_REG_IP) returned %d", reg_err); break; } reg_err = unw_get_proc_name_fn (&cursor, name, FUNC_NAME_LENGTH, &off); if (reg_err == -UNW_ENOINFO) strcpy (name, "???"); mono_runtime_printf_err (" at %s+%zu [0x%zx]", name, off, ip); unw_err = unw_step_fn (&cursor); frames++; } while (unw_err > 0 && frames < FRAMES_TO_UNWIND); if (unw_err < 0) mono_runtime_printf_err ("unw_step () returned %d", unw_err); mono_dl_close (dl); return NULL; }
static void init_syms(void) { if (realfopen) return; # define LOAD_SYM(name) \ do { \ if (!(real ## name = dlsym(RTLD_NEXT, #name))) { \ fprintf(stderr, "Cannot find real '%s' symbol\n", #name); \ abort(); \ } \ } while (0) # define LOAD_SYM_ALT(name1, name2) \ do { \ if (!(real ## name1 = dlsym(RTLD_NEXT, #name1)) && \ !(real ## name2 = dlsym(RTLD_NEXT, #name2))) { \ fprintf(stderr, "Cannot find real '%s' or '%s' symbol\n", #name1, #name2); \ abort(); \ } \ } while (0) LOAD_SYM(fopen); LOAD_SYM(access); LOAD_SYM_ALT(lstat, __lxstat); LOAD_SYM_ALT(stat, __xstat); LOAD_SYM(mkdir); LOAD_SYM(open); }
static void init_syms(void) { if (realstatfs) return; #define LOAD_SYM(name) \ do { \ if (!(real ## name = dlsym(RTLD_NEXT, #name))) { \ fprintf(stderr, "Cannot find real '%s' symbol\n", #name); \ abort(); \ } \ } while (0) LOAD_SYM(statfs); LOAD_SYM(security_get_boolean_active); LOAD_SYM(is_selinux_enabled); LOAD_SYM(selinux_virtual_domain_context_path); LOAD_SYM(selinux_virtual_image_context_path); #ifdef HAVE_SELINUX_LXC_CONTEXTS_PATH LOAD_SYM(selinux_lxc_contexts_path); #endif #if HAVE_SELINUX_LABEL_H LOAD_SYM(selabel_open); LOAD_SYM(selabel_close); LOAD_SYM(selabel_lookup_raw); #endif #undef LOAD_SYM }
static bool load_fbo_proc(void) { LOAD_SYM(glGenFramebuffers); LOAD_SYM(glBindFramebuffer); LOAD_SYM(glFramebufferTexture2D); LOAD_SYM(glCheckFramebufferStatus); LOAD_SYM(glDeleteFramebuffers); return pglGenFramebuffers && pglBindFramebuffer && pglFramebufferTexture2D && pglCheckFramebufferStatus && pglDeleteFramebuffers; }
static void init_syms(void) { if (realstatfs) return; #define LOAD_SYM(name) \ do { \ if (!(real ## name = dlsym(RTLD_NEXT, #name))) { \ fprintf(stderr, "Cannot find real '%s' symbol\n", #name); \ abort(); \ } \ } while (0) LOAD_SYM(statfs); LOAD_SYM(security_get_boolean_active); #undef LOAD_SYM }
static int bitforce_autodetect_ftdi(void) { char devpath[] = "\\\\.\\COMnnnnn"; char *devpathnum = &devpath[7]; char **bufptrs; char *buf; int found = 0; int i; FT_STATUS ftStatus; DWORD numDevs; HMODULE dll = LoadLibrary("FTD2XX.DLL"); if (!dll) { applog(LOG_DEBUG, "FTD2XX.DLL failed to load, not using FTDI bitforce autodetect"); return 0; } LOAD_SYM(FT_ListDevices); LOAD_SYM(FT_Open); LOAD_SYM(FT_GetComPortNumber); LOAD_SYM(FT_Close); ftStatus = FT_ListDevices(&numDevs, NULL, FT_LIST_NUMBER_ONLY); if (ftStatus != FT_OK) { applog(LOG_DEBUG, "FTDI device count failed, not using FTDI bitforce autodetect"); goto out; } applog(LOG_DEBUG, "FTDI reports %u devices", (unsigned)numDevs); buf = alloca(65 * numDevs); bufptrs = alloca(numDevs + 1); for (i = 0; i < numDevs; ++i) bufptrs[i] = &buf[i * 65]; bufptrs[numDevs] = NULL; ftStatus = FT_ListDevices(bufptrs, &numDevs, FT_LIST_ALL | FT_OPEN_BY_DESCRIPTION); if (ftStatus != FT_OK) { applog(LOG_DEBUG, "FTDI device list failed, not using FTDI bitforce autodetect"); goto out; } for (i = numDevs; i > 0; ) { --i; bufptrs[i][64] = '\0'; if (!(strstr(bufptrs[i], "BitFORCE") && strstr(bufptrs[i], "SHA256"))) continue; FT_HANDLE ftHandle; if (FT_OK != FT_Open(i, &ftHandle)) continue; LONG lComPortNumber; ftStatus = FT_GetComPortNumber(ftHandle, &lComPortNumber); FT_Close(ftHandle); if (FT_OK != ftStatus || lComPortNumber < 0) continue; sprintf(devpathnum, "%d", (int)lComPortNumber); if (bitforce_detect_one(devpath)) ++found; } out: dlclose(dll); return found; }
/***************************************************************************** * OpenDecoder: probe the decoder and return score *****************************************************************************/ static int OpenDecoder( vlc_object_t *p_this ) { decoder_t *p_dec = (decoder_t*)p_this; decoder_sys_t *p_sys; /* Codec specifics */ uint32_t i_bcm_codec_subtype = 0; switch ( p_dec->fmt_in.i_codec ) { case VLC_CODEC_H264: if( p_dec->fmt_in.i_original_fourcc == VLC_FOURCC( 'a', 'v', 'c', '1' ) ) i_bcm_codec_subtype = BC_MSUBTYPE_AVC1; else i_bcm_codec_subtype = BC_MSUBTYPE_H264; break; case VLC_CODEC_VC1: i_bcm_codec_subtype = BC_MSUBTYPE_VC1; break; case VLC_CODEC_WMV3: i_bcm_codec_subtype = BC_MSUBTYPE_WMV3; break; case VLC_CODEC_WMVA: i_bcm_codec_subtype = BC_MSUBTYPE_WMVA; break; case VLC_CODEC_MPGV: i_bcm_codec_subtype = BC_MSUBTYPE_MPEG2VIDEO; break; /* Not ready for production yet case VLC_CODEC_MP4V: i_bcm_codec_subtype = BC_MSUBTYPE_DIVX; break; case VLC_CODEC_DIV3: i_bcm_codec_subtype = BC_MSUBTYPE_DIVX311; break; */ default: return VLC_EGENERIC; } /* Allocate the memory needed to store the decoder's structure */ p_sys = malloc( sizeof(*p_sys) ); if( !p_sys ) return VLC_ENOMEM; /* Fill decoder_sys_t */ p_dec->p_sys = p_sys; p_sys->i_nal_size = 4; // assume 4 byte start codes p_sys->i_sps_pps_size = 0; p_sys->p_sps_pps_buf = NULL; p_dec->p_sys->p_pic = NULL; p_dec->p_sys->proc_out = NULL; /* Win32 code * * We cannot link and ship BCM dll, even with LGPL license (too big) * and if we don't ship it, the plugin would not work depending on the * installation order => DLopen */ #ifdef USE_DL_OPENING # define DLL_NAME "bcmDIL.dll" # define PATHS_NB 3 static const char *psz_paths[PATHS_NB] = { DLL_NAME, "C:\\Program Files\\Broadcom\\Broadcom CrystalHD Decoder\\" DLL_NAME, "C:\\Program Files (x86)\\Broadcom\\Broadcom CrystalHD Decoder\\" DLL_NAME, }; for( int i = 0; i < PATHS_NB; i++ ) { HINSTANCE p_bcm_dll = LoadLibraryA( psz_paths[i] ); if( p_bcm_dll ) { p_sys->p_bcm_dll = p_bcm_dll; break; } } if( !p_sys->p_bcm_dll ) { msg_Dbg( p_dec, "Couldn't load the CrystalHD dll"); return VLC_EGENERIC; } #define LOAD_SYM( a ) \ BC_FUNC( a ) = (void *)GetProcAddress( p_sys->p_bcm_dll, ( #a ) ); \ if( !BC_FUNC( a ) ) { \ msg_Err( p_dec, "missing symbol " # a ); return VLC_EGENERIC; } #define LOAD_SYM_PSYS( a ) \ p_sys->BC_FUNC( a ) = (void *)GetProcAddress( p_sys->p_bcm_dll, #a ); \ if( !p_sys->BC_FUNC( a ) ) { \ msg_Err( p_dec, "missing symbol " # a ); return VLC_EGENERIC; } BC_STATUS (WINAPI *OurDtsDeviceOpen)( HANDLE *hDevice, U32 mode ); LOAD_SYM( DtsDeviceOpen ); BC_STATUS (WINAPI *OurDtsCrystalHDVersion)( HANDLE hDevice, PBC_INFO_CRYSTAL bCrystalInfo ); LOAD_SYM( DtsCrystalHDVersion ); BC_STATUS (WINAPI *OurDtsSetColorSpace)( HANDLE hDevice, BC_OUTPUT_FORMAT Mode422 ); LOAD_SYM( DtsSetColorSpace ); BC_STATUS (WINAPI *OurDtsSetInputFormat)( HANDLE hDevice, BC_INPUT_FORMAT *pInputFormat ); LOAD_SYM( DtsSetInputFormat ); BC_STATUS (WINAPI *OurDtsOpenDecoder)( HANDLE hDevice, U32 StreamType ); LOAD_SYM( DtsOpenDecoder ); BC_STATUS (WINAPI *OurDtsStartDecoder)( HANDLE hDevice ); LOAD_SYM( DtsStartDecoder ); BC_STATUS (WINAPI *OurDtsStartCapture)( HANDLE hDevice ); LOAD_SYM( DtsStartCapture ); LOAD_SYM_PSYS( DtsCloseDecoder ); LOAD_SYM_PSYS( DtsDeviceClose ); LOAD_SYM_PSYS( DtsFlushInput ); LOAD_SYM_PSYS( DtsStopDecoder ); LOAD_SYM_PSYS( DtsGetDriverStatus ); LOAD_SYM_PSYS( DtsProcInput ); LOAD_SYM_PSYS( DtsProcOutput ); LOAD_SYM_PSYS( DtsIsEndOfStream ); #undef LOAD_SYM #undef LOAD_SYM_PSYS #endif /* USE_DL_OPENING */ #ifdef DEBUG_CRYSTALHD msg_Dbg( p_dec, "Trying to open CrystalHD HW"); #endif /* Get the handle for the device */ if( BC_FUNC(DtsDeviceOpen)( &p_sys->bcm_handle, (DTS_PLAYBACK_MODE | DTS_LOAD_FILE_PLAY_FW | DTS_SKIP_TX_CHK_CPB) ) // | DTS_DFLT_RESOLUTION(vdecRESOLUTION_720p29_97) ) ) != BC_STS_SUCCESS ) { msg_Err( p_dec, "Couldn't find and open the BCM CrystalHD device" ); free( p_sys ); return VLC_EGENERIC; } #ifdef DEBUG_CRYSTALHD BC_INFO_CRYSTAL info; if( BC_FUNC(DtsCrystalHDVersion)( p_sys->bcm_handle, &info ) == BC_STS_SUCCESS ) { msg_Dbg( p_dec, "Using CrystalHD Driver version: %i.%i.%i, " "Library version: %i.%i.%i, Firmware version: %i.%i.%i", info.drvVersion.drvRelease, info.drvVersion.drvMajor, info.drvVersion.drvMinor, info.dilVersion.dilRelease, info.dilVersion.dilMajor, info.dilVersion.dilMinor, info.fwVersion.fwRelease, info.fwVersion.fwMajor, info.fwVersion.fwMinor ); } #endif /* Special case for AVC1 */ if( i_bcm_codec_subtype == BC_MSUBTYPE_AVC1 ) { if( p_dec->fmt_in.i_extra > 0 ) { msg_Dbg( p_dec, "Parsing extra infos for avc1" ); if( crystal_insert_sps_pps( p_dec, (uint8_t*)p_dec->fmt_in.p_extra, p_dec->fmt_in.i_extra ) != VLC_SUCCESS ) goto error; } else { msg_Err( p_dec, "Missing extra infos for avc1" ); goto error; } } /* Always use YUY2 color */ if( BC_FUNC(DtsSetColorSpace)( p_sys->bcm_handle, OUTPUT_MODE422_YUY2 ) != BC_STS_SUCCESS ) { msg_Err( p_dec, "Couldn't set the color space. Please report this!" ); goto error; } /* Prepare Input for the device */ BC_INPUT_FORMAT p_in; memset( &p_in, 0, sizeof(BC_INPUT_FORMAT) ); p_in.OptFlags = 0x51; /* 0b 0 1 01 0001 */ p_in.mSubtype = i_bcm_codec_subtype; p_in.startCodeSz = p_sys->i_nal_size; p_in.pMetaData = p_sys->p_sps_pps_buf; p_in.metaDataSz = p_sys->i_sps_pps_size; p_in.width = p_dec->fmt_in.video.i_width; p_in.height = p_dec->fmt_in.video.i_height; p_in.Progressive = true; if( BC_FUNC(DtsSetInputFormat)( p_sys->bcm_handle, &p_in ) != BC_STS_SUCCESS ) { msg_Err( p_dec, "Couldn't set the color space. Please report this!" ); goto error; } /* Open a decoder */ if( BC_FUNC(DtsOpenDecoder)( p_sys->bcm_handle, BC_STREAM_TYPE_ES ) != BC_STS_SUCCESS ) { msg_Err( p_dec, "Couldn't open the CrystalHD decoder" ); goto error; } /* Start it */ if( BC_FUNC(DtsStartDecoder)( p_sys->bcm_handle ) != BC_STS_SUCCESS ) { msg_Err( p_dec, "Couldn't start the decoder" ); goto error; } if( BC_FUNC(DtsStartCapture)( p_sys->bcm_handle ) != BC_STS_SUCCESS ) { msg_Err( p_dec, "Couldn't start the capture" ); goto error_complete; } /* Set output properties */ p_dec->fmt_out.i_cat = VIDEO_ES; p_dec->fmt_out.i_codec = VLC_CODEC_YUYV; p_dec->fmt_out.video.i_width = p_dec->fmt_in.video.i_width; p_dec->fmt_out.video.i_height = p_dec->fmt_in.video.i_height; /* Set callbacks */ p_dec->pf_decode_video = DecodeBlock; msg_Info( p_dec, "Opened CrystalHD hardware with success" ); return VLC_SUCCESS; error_complete: BC_FUNC_PSYS(DtsCloseDecoder)( p_sys->bcm_handle ); error: BC_FUNC_PSYS(DtsDeviceClose)( p_sys->bcm_handle ); free( p_sys ); return VLC_EGENERIC; }
bool init(QString &error) { #if defined(Q_OS_LINUX) const char *libname = "libftd2xx.so"; #elif defined(Q_OS_WIN32) const char *libname = "ftd2xx.dll"; #elif defined(Q_OS_DARWIN) const char *libname = "libftd2xx.dylib"; #endif handle = dlopen(libname, RTLD_NOW); if (!handle) { error = QString("Couldn't load library ") + libname + "."; return false; } LOAD_SYM(FP_OpenEx, open_ex, "FT_OpenEx"); LOAD_SYM(FP_Close, close, "FT_Close"); LOAD_SYM(FP_SetBaudRate, set_baud_rate, "FT_SetBaudRate"); LOAD_SYM(FP_SetDataCharacteristics, set_data_characteristics, "FT_SetDataCharacteristics"); LOAD_SYM(FP_SetFlowControl, set_flow_control, "FT_SetFlowControl"); LOAD_SYM(FP_GetQueueStatus, get_queue_status, "FT_GetQueueStatus"); LOAD_SYM(FP_SetTimeouts, set_timeouts, "FT_SetTimeouts"); LOAD_SYM(FP_Read, read, "FT_Read"); LOAD_SYM(FP_Write, write, "FT_Write"); LOAD_SYM(FP_CreateDeviceInfoList, create_device_info_list, "FT_CreateDeviceInfoList"); LOAD_SYM(FP_GetDeviceInfoList, get_device_info_list, "FT_GetDeviceInfoList"); return true; }
static char * mono_extension_handle_native_sigsegv_libcorkscrew (void *ctx, MONO_SIG_HANDLER_INFO_TYPE *info) { #if defined (__arm__) || defined (__i386__) char *dl_err; get_backtrace_symbols_t get_backtrace_symbols; free_backtrace_symbols_t free_backtrace_symbols; unwind_backtrace_signal_arch_t unwind_backtrace_signal_arch; acquire_my_map_info_list_t acquire_my_map_info_list; release_my_map_info_list_t release_my_map_info_list; backtrace_frame_t frames [FRAMES_TO_UNWIND]; backtrace_symbol_t symbols [FRAMES_TO_UNWIND]; map_info_t *map_info; ssize_t frames_unwound; size_t i; MonoDl *dl = mono_dl_open ("libcorkscrew.so", MONO_DL_LAZY, &dl_err); if (!dl) return dl_err; LOAD_SYM (dl, dl_err, get_backtrace_symbols, get_backtrace_symbols); LOAD_SYM (dl, dl_err, free_backtrace_symbols, free_backtrace_symbols); LOAD_SYM (dl, dl_err, unwind_backtrace_signal_arch, unwind_backtrace_signal_arch); LOAD_SYM (dl, dl_err, acquire_my_map_info_list, acquire_my_map_info_list); LOAD_SYM (dl, dl_err, release_my_map_info_list, release_my_map_info_list); map_info = acquire_my_map_info_list (); frames_unwound = unwind_backtrace_signal_arch (info, ctx, map_info, frames, 0, FRAMES_TO_UNWIND); release_my_map_info_list (map_info); if (frames_unwound == -1) { mono_dl_close (dl); return g_strdup ("unwind_backtrace_signal_arch () returned -1"); } get_backtrace_symbols (frames, frames_unwound, symbols); for (i = 0; i < frames_unwound; i++) { backtrace_frame_t *frame = frames + i; backtrace_symbol_t *symbol = symbols + i; const char *name = symbol->demangled_name ? symbol->demangled_name : (symbol->symbol_name ? symbol->symbol_name : "???"); uintptr_t off = symbol->relative_pc - symbol->relative_symbol_addr; uintptr_t ip = frame->absolute_pc; mono_runtime_printf_err (" at %s+%zu [0x%zx]", name, off, ip); } free_backtrace_symbols (symbols, frames_unwound); mono_dl_close (dl); return NULL; #else return g_strdup ("libcorkscrew is only supported on 32-bit ARM/x86"); #endif }
int main(int argc, char *argv[]) { uint8_t threadid_main = 0; pthread_key_create(&threadid_key, NULL); pthread_setspecific(threadid_key, &threadid_main); mprintf("University of Wisconsin IPMI MicroTCA System Manager\n"); if (argc > 1 && strcmp(argv[1], "--version") == 0) { mprintf("\nCompiled from %s@%s\n", (GIT_BRANCH[0] ? GIT_BRANCH : "git-archive"), (GIT_COMMIT[0] ? GIT_COMMIT : "27868b9b800d107fbb53b68c2fce207144f97a98")); if (strlen(GIT_DIRTY) > 1) mprintf("%s", GIT_DIRTY); mprintf("\n"); return 0; } /* * Parse Configuration */ cfg_opt_t opts_auth[] = { CFG_STR_LIST(const_cast<char *>("raw"), const_cast<char *>("{}"), CFGF_NONE), CFG_STR_LIST(const_cast<char *>("manage"), const_cast<char *>("{}"), CFGF_NONE), CFG_STR_LIST(const_cast<char *>("read"), const_cast<char *>("{}"), CFGF_NONE), CFG_END() }; cfg_opt_t opts_crate[] = { CFG_STR(const_cast<char *>("host"), const_cast<char *>(""), CFGF_NONE), CFG_STR(const_cast<char *>("description"), const_cast<char *>(""), CFGF_NONE), CFG_STR(const_cast<char *>("username"), const_cast<char *>(""), CFGF_NONE), CFG_STR(const_cast<char *>("password"), const_cast<char *>(""), CFGF_NONE), CFG_INT_CB(const_cast<char *>("authtype"), 0, CFGF_NONE, cfg_parse_authtype), CFG_INT_CB(const_cast<char *>("mch"), 0, CFGF_NONE, cfg_parse_MCH), CFG_BOOL(const_cast<char *>("enabled"), cfg_true, CFGF_NONE), CFG_END() }; cfg_opt_t opts_cardmodule[] = { CFG_STR(const_cast<char *>("module"), const_cast<char *>(""), CFGF_NONE), CFG_STR_LIST(const_cast<char *>("config"), const_cast<char *>("{}"), CFGF_NONE), CFG_END() }; cfg_opt_t opts[] = { CFG_SEC(const_cast<char *>("authentication"), opts_auth, CFGF_NONE), CFG_SEC(const_cast<char *>("crate"), opts_crate, CFGF_MULTI), CFG_SEC(const_cast<char *>("cardmodule"), opts_cardmodule, CFGF_MULTI), CFG_INT(const_cast<char *>("socket_port"), 4681, CFGF_NONE), CFG_INT(const_cast<char *>("ratelimit_delay"), 0, CFGF_NONE), CFG_BOOL(const_cast<char *>("daemonize"), cfg_false, CFGF_NONE), CFG_END() }; cfg_t *cfg = cfg_init(opts, CFGF_NONE); cfg_set_validate_func(cfg, "crate|host", &cfg_validate_hostname); cfg_set_validate_func(cfg, "socket_port", &cfg_validate_port); if (argc >= 2 && access(argv[1], R_OK) == 0) { if(cfg_parse(cfg, argv[1]) == CFG_PARSE_ERROR) exit(1); } else if (access(CONFIG_PATH "/" CONFIG_FILE, R_OK) == 0) { if(cfg_parse(cfg, CONFIG_PATH "/" CONFIG_FILE) == CFG_PARSE_ERROR) exit(1); } else { printf("Config file %s not found, and no argument supplied.\n", CONFIG_PATH "/" CONFIG_FILE); printf("Try: %s sysmgr.conf\n", argv[0]); exit(1); } bool crate_found = false; bool crate_enabled = false; cfg_t *cfgauth = cfg_getsec(cfg, "authentication"); for(unsigned int i = 0; i < cfg_size(cfgauth, "raw"); i++) config_authdata.raw.push_back(std::string(cfg_getnstr(cfgauth, "raw", i))); for(unsigned int i = 0; i < cfg_size(cfgauth, "manage"); i++) config_authdata.manage.push_back(std::string(cfg_getnstr(cfgauth, "manage", i))); for(unsigned int i = 0; i < cfg_size(cfgauth, "read"); i++) config_authdata.read.push_back(std::string(cfg_getnstr(cfgauth, "read", i))); for(unsigned int i = 0; i < cfg_size(cfg, "crate"); i++) { cfg_t *cfgcrate = cfg_getnsec(cfg, "crate", i); crate_found = true; enum Crate::Mfgr MCH; switch (cfg_getint(cfgcrate, "mch")) { case Crate::VADATECH: MCH = Crate::VADATECH; break; case Crate::NAT: MCH = Crate::NAT; break; } const char *user = cfg_getstr(cfgcrate, "username"); const char *pass = cfg_getstr(cfgcrate, "password"); Crate *crate = new Crate(i+1, MCH, cfg_getstr(cfgcrate, "host"), (user[0] ? user : NULL), (pass[0] ? pass : NULL), cfg_getint(cfgcrate, "authtype"), cfg_getstr(cfgcrate, "description")); bool enabled = (cfg_getbool(cfgcrate, "enabled") == cfg_true); if (enabled) crate_enabled = true; threadlocal.push_back(threadlocaldata_t(crate, enabled)); } for(unsigned int i = 0; i < cfg_size(cfg, "cardmodule"); i++) { cfg_t *cfgmodule = cfg_getnsec(cfg, "cardmodule", i); const char *module = cfg_getstr(cfgmodule, "module"); std::vector<std::string> configdata; for(unsigned int i = 0; i < cfg_size(cfgmodule, "config"); i++) configdata.push_back(std::string(cfg_getnstr(cfgmodule, "config", i))); std::string default_module_path = DEFAULT_MODULE_PATH; if (getenv("SYSMGR_MODULE_PATH") != NULL) default_module_path = getenv("SYSMGR_MODULE_PATH"); std::string modulepath = module; if (modulepath.find("/") == std::string::npos) modulepath = default_module_path +"/"+ modulepath; cardmodule_t cm; cm.dl_addr = dlopen(modulepath.c_str(), RTLD_NOW|RTLD_GLOBAL); if (cm.dl_addr == NULL) { printf("Error loading module %s:\n\t%s\n", module, dlerror()); exit(2); } void *sym; #define LOAD_SYM(name, type) \ sym = dlsym(cm.dl_addr, #name); \ if (sym == NULL) { \ mprintf("Error loading module %s " type " " #name ":\n\t%s\n", module, dlerror()); \ exit(2); \ } LOAD_SYM(APIVER, "variable"); cm.APIVER = *reinterpret_cast<uint32_t*>(sym); LOAD_SYM(MIN_APIVER, "variable"); cm.MIN_APIVER = *reinterpret_cast<uint32_t*>(sym); if (cm.APIVER < 2 || cm.MIN_APIVER > 2) { mprintf("Error loading module %s: Incompatible API version %u\n", module, cm.APIVER); } LOAD_SYM(initialize_module, "function"); cm.initialize_module = reinterpret_cast<bool (*)(std::vector<std::string>)>(sym); LOAD_SYM(instantiate_card, "function"); cm.instantiate_card = reinterpret_cast<Card* (*)(Crate*, std::string, void*, uint8_t)>(sym); #undef LOAD_SYM if (!cm.initialize_module(configdata)) { printf("Error loading module %s: initialize_module() returned false\n", module); exit(2); } card_modules.insert(card_modules.begin(), cm); } uint16_t port = cfg_getint(cfg, "socket_port"); config_ratelimit_delay = cfg_getint(cfg, "ratelimit_delay"); bool daemonize = (cfg_getbool(cfg, "daemonize") == cfg_true); cfg_free(cfg); if (!crate_found) { printf("No crate specified in the configuration file.\n"); exit(1); } if (!crate_enabled) { printf("No crates are enabled in the configuration file.\n"); printf("No crates to service.\n"); exit(1); } if (daemonize) { do_fork(); stdout_use_syslog = true; mprintf("University of Wisconsin IPMI MicroTCA System Manager\n"); } /* * Initialize library crypto routines before spawning threads. * This connect will fail due to hostname too long, after running the crypt init functions. * * Max Hostname Limit: 64 */ ipmi_ctx_t dummy_ipmi_ctx = ipmi_ctx_create(); if (ipmi_ctx_open_outofband_2_0(dummy_ipmi_ctx, ".................................................................", // hostname NULL, // username NULL, // password NULL, // k_g 0, // k_g_len, 4, // privilege_level 0, // cipher_suite_id 0, // session_timeout 5, // retransmission_timeout IPMI_WORKAROUND_FLAGS_OUTOFBAND_2_0_OPEN_SESSION_PRIVILEGE, // workaround_flags IPMI_FLAGS_DEFAULT // flags ) == 0) { ipmi_ctx_close(dummy_ipmi_ctx); } ipmi_ctx_destroy(dummy_ipmi_ctx); /* * Instantiate Worker Threads */ for (std::vector<threadlocaldata_t>::iterator it = threadlocal.begin(); it != threadlocal.end(); it++) if (it->enabled) pthread_create(&it->thread, NULL, crate_monitor, (void *)it->crate->get_number()); #ifndef DEBUG_ONESHOT protocol_server(port); #endif for (std::vector<threadlocaldata_t>::iterator it = threadlocal.begin(); it != threadlocal.end(); it++) if (it->enabled) pthread_join(it->thread, NULL); }
static inline bool load_gl_proc(void) { LOAD_SYM(glClientActiveTexture); LOAD_SYM(glActiveTexture); return pglClientActiveTexture && pglActiveTexture; }