• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ dlerror函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中dlerror函数的典型用法代码示例。如果您正苦于以下问题:C++ dlerror函数的具体用法?C++ dlerror怎么用?C++ dlerror使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了dlerror函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: gather_sd_fds

static int gather_sd_fds(void) {
#ifdef SUPERVISOR_SUPPORT
    if (ssh_fd == 0) {
#else
    if (main_fd == 0 && ssh_fd == 0 && scdaemon_fd == 0) {
#endif
        int num_fds;
        char **fdmap = NULL;
        void *libsystemd = NULL;
        int (*_sd_listen_fds_with_names)(int, char ***);

        if ((libsystemd = dlopen(LIBSYSTEMD, RTLD_LAZY)) == NULL) {
            fprintf(stderr, "dlopen %s\n", dlerror());
            return -4;
        }

        _sd_listen_fds_with_names =
            dlsym(libsystemd, "sd_listen_fds_with_names");

        if (_sd_listen_fds_with_names == NULL) {
            fprintf(stderr, "dlsym %s\n", dlerror());
            return -4;
        }

        num_fds = _sd_listen_fds_with_names(0, &fdmap);

        if (num_fds <= 0) {
            fputs("No suitable file descriptors in LISTEN_FDS.\n", stderr);
            if (num_fds == 0)
                return -3;
            return -4;
        }

        if (fdmap != NULL) {
            for (int i = 0; i < num_fds; i++) {
                if (strncmp(fdmap[i], "ssh", 4) == 0)
                    ssh_fd = SD_LISTEN_FDS_START + i;
#ifndef SUPERVISOR_SUPPORT
                else if (strncmp(fdmap[i], "main", 5) == 0)
                    main_fd = SD_LISTEN_FDS_START + i;
                else if (strncmp(fdmap[i], "scdaemon", 9) == 0)
                    scdaemon_fd = SD_LISTEN_FDS_START + i;
#endif
                free(fdmap[i]);
            }
            free(fdmap);
        }

        if (dlclose(libsystemd) != 0)
            return -1;
    }

    return 0;
}

#ifndef SUPERVISOR_SUPPORT

/* Get a systemd file descriptor corresponding to the specified socket path.
 *
 * Return values:
 *   -1 Socket path not a systemd socket
 *   -2 Provided socket path is not absolute
 *   -3 No suitable file descriptors in LISTEN_FDS
 *   -4 Error while determining LISTEN_FDS
 */
static int get_sd_fd(const char *sockpath)
{
    int ret;

    if ((ret = gather_sd_fds()) != 0)
        return ret;

    char *basename = strrchr(sockpath, '/');
    if (basename == NULL)
        return -2;
    else
        basename++;

    if (strncmp(basename, "S.gpg-agent", 12) == 0)
        return main_fd;
    else if (strncmp(basename, "S.gpg-agent.ssh", 16) == 0)
        return ssh_fd;
    else if (strncmp(basename, "S.scdaemon", 11) == 0)
        return scdaemon_fd;

    return -1;
}
开发者ID:openlab-aux,项目名称:vuizvui,代码行数:87,代码来源:agent-wrapper.c


示例2: Atcleci_Init

int Atcleci_Init(Tcl_Interp *interp) {
  int rc;
  size_t chunk_bytes = 0;
  void *eciHandle;
  void *eciLib;
  //< configure shared library symbols

  eciLib = dlopen(ECILIBRARYNAME, RTLD_LAZY);
  if (eciLib == NULL) {
    Tcl_AppendResult(interp, "Could not load ", ECILIBRARYNAME, "\n", dlerror(),
                     "\nPlease install the IBM ViaVoice Outloud RTK", NULL);
    return TCL_ERROR;
  }

  _eciVersion = (void (*)(char *))(unsigned long)dlsym(eciLib, "eciVersion");
  _eciGetAvailableLanguages = (int (*)(enum ECILanguageDialect *, int *))(
      unsigned long)dlsym(eciLib, "eciGetAvailableLanguages");
  _eciNewEx = (void *(*)(enum ECILanguageDialect))(unsigned long)dlsym(
      eciLib, "eciNewEx");
  _eciDelete = (void (*)(void *))(unsigned long)dlsym(eciLib, "eciDelete");
  _eciReset = (int (*)(void *))(unsigned long)dlsym(eciLib, "eciReset");
  _eciStop = (int (*)(void *))(unsigned long)dlsym(eciLib, "eciStop");
  _eciClearInput =
      (int (*)(void *))(unsigned long)dlsym(eciLib, "eciClearInput");
  _eciPause = (int (*)(void *, int))(unsigned long)dlsym(eciLib, "eciPause");
  _eciSynthesize =
      (int (*)(void *))(unsigned long)dlsym(eciLib, "eciSynthesize");
  _eciSynchronize =
      (int (*)(void *))(unsigned long)dlsym(eciLib, "eciSynchronize");
  _eciSpeaking = (int (*)(void *))(unsigned long)dlsym(eciLib, "eciSpeaking");
  _eciInsertIndex =
      (int (*)(void *, int))(unsigned long)dlsym(eciLib, "eciInsertIndex");
  _eciAddText =
      (int (*)(void *, char *))(unsigned long)dlsym(eciLib, "eciAddText");
  _eciSetParam =
      (int (*)(void *, int, int))(unsigned long)dlsym(eciLib, "eciSetParam");
  _eciGetVoiceParam = (int (*)(void *, int, int))(unsigned long)dlsym(
      eciLib, "eciGetVoiceParam");
  _eciSetVoiceParam = (int (*)(void *, int, int, int))(unsigned long)dlsym(
      eciLib, "eciSetVoiceParam");
  _eciRegisterCallback =
      (void (*)(void *, int (*)(void *, int, long, void *), void *))(
          unsigned long)dlsym(eciLib, "eciRegisterCallback");
  _eciSetOutputBuffer = (int (*)(void *, int, short *))(unsigned long)dlsym(
      eciLib, "eciSetOutputBuffer");
  _eciSetOutputDevice =
      (int (*)(void *, int))(unsigned long)dlsym(eciLib, "eciSetOutputDevice");

  //>
  //< check for needed symbols

  int okay = 1;
  if (!_eciNewEx) {
    okay = 0;
    Tcl_AppendResult(interp, "eciNewEx undef\n", NULL);
  }
  if (!_eciDelete) {
    okay = 0;
    Tcl_AppendResult(interp, "eciDelete undef\n", NULL);
  }
  if (!_eciReset) {
    okay = 0;
    Tcl_AppendResult(interp, "eciReset undef\n", NULL);
  }
  if (!_eciStop) {
    okay = 0;
    Tcl_AppendResult(interp, "eciStop undef\n", NULL);
  }
  if (!_eciClearInput) {
    okay = 0;
    Tcl_AppendResult(interp, "eciClearInput undef\n", NULL);
  }
  if (!_eciPause) {
    okay = 0;
    Tcl_AppendResult(interp, "eciPause undef\n", NULL);
  }
  if (!_eciSynthesize) {
    okay = 0;
    Tcl_AppendResult(interp, "eciSynthesize undef\n", NULL);
  }
  if (!_eciSpeaking) {
    okay = 0;
    Tcl_AppendResult(interp, "eciSpeaking undef\n", NULL);
  }
  if (!_eciInsertIndex) {
    okay = 0;
    Tcl_AppendResult(interp, "eciInsertIndex undef\n", NULL);
  }
  if (!_eciAddText) {
    okay = 0;
    Tcl_AppendResult(interp, "eciAddText undef\n", NULL);
  }
  if (!_eciSetParam) {
    okay = 0;
    Tcl_AppendResult(interp, "eciSetParam undef\n", NULL);
  }
  if (!_eciSetParam) {
    okay = 0;
    Tcl_AppendResult(interp, "eciSetParam undef\n", NULL);
  }
//.........这里部分代码省略.........
开发者ID:hussainmkj,项目名称:emacspeak_espeak_mod,代码行数:101,代码来源:atcleci.cpp


示例3: dlopen

static void *ll_load (lua_State *L, const char *path) {
  void *lib = dlopen(path, RTLD_NOW);
  if (lib == NULL) lua_pushstring(L, dlerror());
  return lib;
}
开发者ID:GodLesZ,项目名称:svn-dump,代码行数:5,代码来源:loadlib.c


示例4: neb_load_module

/* load a particular module */
int neb_load_module(nebmodule *mod) {
	int (*initfunc)(int, char *, void *);
	int *module_version_ptr = NULL;
	char output_file[PATH_MAX];
	int dest_fd, result = OK;

	if(mod == NULL || mod->filename == NULL)
		return ERROR;

	/* don't reopen the module */
	if(mod->is_currently_loaded == TRUE)
		return OK;

	/* don't load modules unless they should be loaded */
	if(mod->should_be_loaded == FALSE)
		return ERROR;

	/**********
	   Using dlopen() is great, but a real danger as-is.  The problem with loaded modules is that if you overwrite the original file (e.g. using 'mv'),
	   you do not alter the inode of the original file.  Since the original file/module is memory-mapped in some fashion, Nagios will segfault the next
	   time an event broker call is directed to one of the module's callback functions.  This is extremely problematic when it comes to upgrading NEB
	   modules while Nagios is running.  A workaround is to (1) 'mv' the original/loaded module file to another name (on the same filesystem)
	   and (2) copy the new module file to the location of the original one (using the original filename).  In this scenario, dlopen() will keep referencing
	   the original file/inode for callbacks.  This is not an ideal solution.   A better one is to delete the module file once it is loaded by dlopen().
	   This prevents other processed from unintentially overwriting the original file, which would cause Nagios to crash.  However, if we delete the file
	   before anyone else can muck with it, things should be good.  'lsof' shows that a deleted file is still referenced by the kernel and callback
	   functions continue to work once the module has been loaded.  Long story, but this took quite a while to figure out, as there isn't much
	   of anything I could find on the subject other than some sketchy info on similar problems on HP-UX.  Hopefully this will save future coders some time.
	   So... the trick is to (1) copy the module to a temp file, (2) dlopen() the temp file, and (3) immediately delete the temp file.
	************/

	/*
	 * open a temp file for copying the module. We use my_fdcopy() so
	 * we re-use the destination file descriptor returned by mkstemp(3),
	 * which we have to close ourselves.
	 */
	snprintf(output_file, sizeof(output_file) - 1, "%s/nebmodXXXXXX", temp_path);
	dest_fd = mkstemp(output_file);
	result = my_fdcopy(mod->filename, output_file, dest_fd);
	close(dest_fd);
	if(result == ERROR) {
		logit(NSLOG_RUNTIME_ERROR, FALSE, "Error: Failed to safely copy module '%s'. The module will not be loaded\n", mod->filename);
		return ERROR;
		}

	/* load the module (use the temp copy we just made) */
	mod->module_handle = dlopen(output_file, RTLD_NOW | RTLD_GLOBAL);
	if(mod->module_handle == NULL) {
		logit(NSLOG_RUNTIME_ERROR, FALSE, "Error: Could not load module '%s' -> %s\n", mod->filename, dlerror());

		return ERROR;
		}

	/* mark the module as being loaded */
	mod->is_currently_loaded = TRUE;

	/* delete the temp copy of the module we just created and loaded */
	/* this will prevent other processes from overwriting the file (using the same inode), which would cause Nagios to crash */
	/* the kernel will keep the deleted file in memory until we unload it */
	/* NOTE: This *should* be portable to most Unices, but I've only tested it on Linux */
	if(unlink(output_file) == -1) {
		logit(NSLOG_RUNTIME_ERROR, FALSE, "Error: Could not delete temporary file '%s' used for module '%s'.  The module will be unloaded: %s\n", output_file, mod->filename, strerror(errno));
		neb_unload_module(mod, NEBMODULE_FORCE_UNLOAD, NEBMODULE_ERROR_API_VERSION);

		return ERROR;
		}

	/*
	 * now that it's loaded and removed, we create a new file in
	 * its place so debuggers can find the correct symbols properly,
	 * but only if we're supposed to dump core
	 */
	if(daemon_dumps_core == TRUE) {
		dest_fd = open(output_file, O_CREAT | O_WRONLY, S_IRWXU | S_IRGRP | S_IROTH);
		result = my_fdcopy(mod->filename, output_file, dest_fd);
		mod->dl_file = strdup(output_file);
		}

	/* find module API version */
	module_version_ptr = (int *)dlsym(mod->module_handle, "__neb_api_version");

	/* check the module API version */
	if(module_version_ptr == NULL || ((*module_version_ptr) != CURRENT_NEB_API_VERSION)) {

		logit(NSLOG_RUNTIME_ERROR, FALSE, "Error: Module '%s' is using an old or unspecified version of the event broker API.  Module will be unloaded.\n", mod->filename);

		neb_unload_module(mod, NEBMODULE_FORCE_UNLOAD, NEBMODULE_ERROR_API_VERSION);

		return ERROR;
		}

	/* locate the initialization function */
	mod->init_func = dlsym(mod->module_handle, "nebmodule_init");

	/* if the init function could not be located, unload the module */
	if(mod->init_func == NULL) {

		logit(NSLOG_RUNTIME_ERROR, FALSE, "Error: Could not locate nebmodule_init() in module '%s'.  Module will be unloaded.\n", mod->filename);

//.........这里部分代码省略.........
开发者ID:alexanderhsiang,项目名称:nagios,代码行数:101,代码来源:nebmods.c


示例5: a52_decode_init

static av_cold int a52_decode_init(AVCodecContext *avctx)
{
    AC3DecodeState *s = avctx->priv_data;

#ifdef CONFIG_LIBA52BIN
    s->handle = dlopen(liba52name, RTLD_LAZY);
    if (!s->handle)
    {
        av_log( avctx, AV_LOG_ERROR, "A52 library %s could not be opened! \n%s\n", liba52name, dlerror());
        return -1;
    }
    s->a52_init = (a52_state_t* (*)(uint32_t)) dlsymm(s->handle, "a52_init");
    s->a52_samples = (sample_t* (*)(a52_state_t*)) dlsymm(s->handle, "a52_samples");
    s->a52_syncinfo = (int (*)(uint8_t*, int*, int*, int*)) dlsymm(s->handle, "a52_syncinfo");
    s->a52_frame = (int (*)(a52_state_t*, uint8_t*, int*, sample_t*, sample_t)) dlsymm(s->handle, "a52_frame");
    s->a52_block = (int (*)(a52_state_t*)) dlsymm(s->handle, "a52_block");
    s->a52_free = (void (*)(a52_state_t*)) dlsymm(s->handle, "a52_free");
    if (!s->a52_init || !s->a52_samples || !s->a52_syncinfo
        || !s->a52_frame || !s->a52_block || !s->a52_free)
    {
        dlclose(s->handle);
        return -1;
    }
#else
    s->handle = 0;
    s->a52_init = a52_init;
    s->a52_samples = a52_samples;
    s->a52_syncinfo = a52_syncinfo;
    s->a52_frame = a52_frame;
    s->a52_block = a52_block;
    s->a52_free = a52_free;
#endif
    s->state = s->a52_init(0); /* later use CPU flags */
    s->samples = s->a52_samples(s->state);

    /* allow downmixing to stereo or mono */
    if (avctx->channels > 0 && avctx->request_channels > 0 &&
            avctx->request_channels < avctx->channels &&
            avctx->request_channels <= 2) {
        avctx->channels = avctx->request_channels;
    }

    return 0;
}
开发者ID:OESF-DLNA,项目名称:upnp-extension,代码行数:44,代码来源:liba52.c


示例6: FcitxUILoadInternal

boolean FcitxUILoadInternal(FcitxInstance* instance, FcitxAddon* addon)
{
    boolean success = false;
    char *modulePath;

    switch (addon->type) {

    case AT_SHAREDLIBRARY: {
        FILE *fp = FcitxXDGGetLibFile(addon->library, "r", &modulePath);
        void *handle;

        if (!fp)
            break;

        fclose(fp);

        handle = dlopen(modulePath, RTLD_NOW | (addon->loadLocal ? RTLD_LOCAL : RTLD_GLOBAL));

        if (!handle) {
            FcitxLog(ERROR, _("UI: open %s fail %s") , modulePath , dlerror());
            break;
        }

        if (!FcitxCheckABIVersion(handle, addon->name)) {
            FcitxLog(ERROR, "%s ABI Version Error", addon->name);
            dlclose(handle);
            break;
        }

        addon->ui = FcitxGetSymbol(handle, addon->name, "ui");

        if (!addon->ui || !addon->ui->Create) {
            FcitxLog(ERROR, _("UI: bad ui"));
            dlclose(handle);
            break;
        }

        if ((addon->addonInstance = addon->ui->Create(instance)) == NULL) {
            dlclose(handle);
            break;
        }

        /* some may register before ui load, so load it here */
        if (addon->ui->RegisterStatus) {
            UT_array* uistats = &instance->uistats;
            FcitxUIStatus *status;

            for (status = (FcitxUIStatus *) utarray_front(uistats);
                    status != NULL;
                    status = (FcitxUIStatus *) utarray_next(uistats, status))
                addon->ui->RegisterStatus(addon->addonInstance, status);
        }

        /* some may register before ui load, so load it here */
        if (addon->ui->RegisterComplexStatus) {
            UT_array* uicompstats = &instance->uicompstats;
            FcitxUIComplexStatus *status;

            for (status = (FcitxUIComplexStatus *) utarray_front(uicompstats);
                 status != NULL;
                 status = (FcitxUIComplexStatus *) utarray_next(uicompstats, status))
                addon->ui->RegisterComplexStatus(addon->addonInstance, status);
        }

        if (addon->ui->RegisterMenu) {
            UT_array* uimenus = &instance->uimenus;
            FcitxUIMenu **menupp;

            for (menupp = (FcitxUIMenu **) utarray_front(uimenus);
                    menupp != NULL;
                    menupp = (FcitxUIMenu **) utarray_next(uimenus, menupp))
                addon->ui->RegisterMenu(addon->addonInstance, *menupp);
        }

        success = true;
    }

    break;

    default:
        break;
    }

    free(modulePath);
    return success;
}
开发者ID:haobug,项目名称:fcitx,代码行数:86,代码来源:ui.c


示例7: pam_server

/*
 * Background process -- runs with privilege.
 */
static void
pam_server (int fd, const char *service, int verb, const struct name_value_list *name_value_list)
{
  struct user_pass up;
  int command;
#if DLOPEN_PAM
  static const char pam_so[] = "libpam.so";
#endif

  /*
   * Do initialization
   */
  if (DEBUG (verb))
    fprintf (stderr, "AUTH-PAM: BACKGROUND: INIT service='%s'\n", service);

#if DLOPEN_PAM
  /*
   * Load PAM shared object
   */
  if (!dlopen_pam (pam_so))
    {
      fprintf (stderr, "AUTH-PAM: BACKGROUND: could not load PAM lib %s: %s\n", pam_so, dlerror());
      send_control (fd, RESPONSE_INIT_FAILED);
      goto done;
    }
#endif

  /*
   * Tell foreground that we initialized successfully
   */
  if (send_control (fd, RESPONSE_INIT_SUCCEEDED) == -1)
    {
      fprintf (stderr, "AUTH-PAM: BACKGROUND: write error on response socket [1]\n");
      goto done;
    }

  /*
   * Event loop
   */
  while (1)
    {
      memset (&up, 0, sizeof (up));
      up.verb = verb;
      up.name_value_list = name_value_list;

      /* get a command from foreground process */
      command = recv_control (fd);

      if (DEBUG (verb))
	fprintf (stderr, "AUTH-PAM: BACKGROUND: received command code: %d\n", command);

      switch (command)
	{
	case COMMAND_VERIFY:
	  if (recv_string (fd, up.username, sizeof (up.username)) == -1
	      || recv_string (fd, up.password, sizeof (up.password)) == -1)
	    {
	      fprintf (stderr, "AUTH-PAM: BACKGROUND: read error on command channel: code=%d, exiting\n",
		       command);
	      goto done;
	    }

	  if (DEBUG (verb))
	    {
#if 0
	      fprintf (stderr, "AUTH-PAM: BACKGROUND: USER/PASS: %s/%s\n",
		       up.username, up.password);
#else
	      fprintf (stderr, "AUTH-PAM: BACKGROUND: USER: %s\n", up.username);
#endif
	    }

	  if (pam_auth (service, &up)) /* Succeeded */
	    {
	      if (send_control (fd, RESPONSE_VERIFY_SUCCEEDED) == -1)
		{
		  fprintf (stderr, "AUTH-PAM: BACKGROUND: write error on response socket [2]\n");
		  goto done;
		}
	    }
	  else /* Failed */
	    {
	      if (send_control (fd, RESPONSE_VERIFY_FAILED) == -1)
		{
		  fprintf (stderr, "AUTH-PAM: BACKGROUND: write error on response socket [3]\n");
		  goto done;
		}
	    }
	  break;

	case COMMAND_EXIT:
	  goto done;

	case -1:
	  fprintf (stderr, "AUTH-PAM: BACKGROUND: read error on command channel\n");
	  goto done;

//.........这里部分代码省略.........
开发者ID:BeyondAosp,项目名称:android_external_openvpn,代码行数:101,代码来源:auth-pam.c


示例8: ExecuteManagedAssembly


//.........这里部分代码省略.........
                useServerGc = "0";
            }

            // CoreCLR expects strings "true" and "false" instead of "1" and "0".
            useServerGc = std::strcmp(useServerGc, "1") == 0 ? "true" : "false";

            // Allowed property names:
            // APPBASE
            // - The base path of the application from which the exe and other assemblies will be loaded
            //
            // TRUSTED_PLATFORM_ASSEMBLIES
            // - The list of complete paths to each of the fully trusted assemblies
            //
            // APP_PATHS
            // - The list of paths which will be probed by the assembly loader
            //
            // APP_NI_PATHS
            // - The list of additional paths that the assembly loader will probe for ngen images
            //
            // NATIVE_DLL_SEARCH_DIRECTORIES
            // - The list of paths that will be probed for native DLLs called by PInvoke
            //
            const char *propertyKeys[] = {
                "TRUSTED_PLATFORM_ASSEMBLIES",
                "APP_PATHS",
                "APP_NI_PATHS",
                "NATIVE_DLL_SEARCH_DIRECTORIES",
                "AppDomainCompatSwitch",
                "System.GC.Server",
            };
            const char *propertyValues[] = {
                // TRUSTED_PLATFORM_ASSEMBLIES
                tpaList.c_str(),
                // APP_PATHS
                appPath.c_str(),
                // APP_NI_PATHS
                appPath.c_str(),
                // NATIVE_DLL_SEARCH_DIRECTORIES
                nativeDllSearchDirs.c_str(),
                // AppDomainCompatSwitch
                "UseLatestBehaviorWhenTFMNotSpecified",
                // System.GC.Server
                useServerGc,
            };

            void* hostHandle;
            unsigned int domainId;

            int st = initializeCoreCLR(
                        currentExeAbsolutePath, 
                        "unixcorerun", 
                        sizeof(propertyKeys) / sizeof(propertyKeys[0]), 
                        propertyKeys, 
                        propertyValues, 
                        &hostHandle, 
                        &domainId);

            if (!SUCCEEDED(st))
            {
                fprintf(stderr, "coreclr_initialize failed - status: 0x%08x\n", st);
                exitCode = -1;
            }
            else 
            {
                st = executeAssembly(
                        hostHandle,
                        domainId,
                        managedAssemblyArgc,
                        managedAssemblyArgv,
                        managedAssemblyAbsolutePath,
                        (unsigned int*)&exitCode);

                if (!SUCCEEDED(st))
                {
                    fprintf(stderr, "coreclr_execute_assembly failed - status: 0x%08x\n", st);
                    exitCode = -1;
                }

                st = shutdownCoreCLR(hostHandle, domainId);
                if (!SUCCEEDED(st))
                {
                    fprintf(stderr, "coreclr_shutdown failed - status: 0x%08x\n", st);
                    exitCode = -1;
                }
            }
        }

        if (dlclose(coreclrLib) != 0)
        {
            fprintf(stderr, "Warning - dlclose failed\n");
        }
    }
    else
    {
        char* error = dlerror();
        fprintf(stderr, "dlopen failed to open the libcoreclr.so with error %s\n", error);
    }

    return exitCode;
}
开发者ID:eriawan,项目名称:coreclr,代码行数:101,代码来源:coreruncommon.cpp


示例9: getPropertyMap

// Call back Declaration
ReturnType InertiaMeasurementUnitComp::onInitialize()
{
	Property parameter;
	std::map<std::string, std::string> temp = getPropertyMap();
	parameter.SetProperty(temp);
	
	if(parameter.FindName("ApiName") == false) {
		PrintMessage("ERROR : InertiaMeasurementUnitComp::onInitialize() -> Can't find the APIName in property\n");
		return lastError = OPROS_FIND_PROPERTY_ERROR;
	}
	
#if defined(WIN32)
	//	DLL 로드
	hOprosAPI = LoadLibrary((LPCSTR)parameter.GetValue("ApiName").c_str());
	if(hOprosAPI == NULL) {
		PrintMessage("ERROR : InertiaMeasurementUnitComp::onInitialize() -> Can't find the %s\n", parameter.GetValue("ApiName").c_str());
		return lastError = OPROS_FIND_DLL_ERROR;
	}
	
	//	API 로드
	GET_OPROS_API getOprosAPI;
	getOprosAPI = (GET_OPROS_API)GetProcAddress(hOprosAPI, "GetAPI");
	if(getOprosAPI == NULL) {
		PrintMessage("ERROR : InertiaMeasurementUnitComp::onInitialize() -> Can't get a handle of GetAPI Funtion\n");
		FreeLibrary(hOprosAPI);
		hOprosAPI = NULL;
		return lastError = OPROS_LOAD_DLL_ERROR;
	}

	//	API Casting
	imu = dynamic_cast<InertiaMeasurementUnit *>(getOprosAPI());
	if(imu == NULL) {
		PrintMessage("ERROR : InertiaMeasurementUnitComp::onInitialize() -> Can't get a handle of AccelerationSensor API\n");
		FreeLibrary(hOprosAPI);
		hOprosAPI = NULL;
		return lastError = OPROS_LOAD_DLL_ERROR;
	}
#else
	//	Shared Library 로드
	hOprosAPI = dlopen(parameter.GetValue("ApiName").c_str(), RTLD_NOW);
	if(hOprosAPI == NULL) {
		PrintMessage("ERROR : InertiaMeasurementUnitComp::onInitialize() -> Can't find the %s\n", parameter.GetValue("ApiName").c_str());
		return lastError = OPROS_FIND_DLL_ERROR;
	}

	//	API 로드
	GET_OPROS_API getOprosAPI = (GET_OPROS_API)dlsym(hOprosAPI, "GetAPI");
	char *error = dlerror();
	if(error != NULL) {
		PrintMessage("ERROR : InertiaMeasurementUnitComp::onInitialize() -> Can't get a handle of GetAPI Funtion\n");
		dlclose(hOprosAPI);
		hOprosAPI = NULL;
		return lastError = OPROS_LOAD_DLL_ERROR;
	}
	
	//	API Casting
	imu = static_cast<InertiaMeasurementUnit *>(getOprosAPI());
	if(imu == NULL) {
		PrintMessage("ERROR : InertiaMeasurementUnitComp::onInitialize() -> Can't get a handle of AccelerationSensor API\n");
		dlclose(hOprosAPI);
		hOprosAPI = NULL;
		return lastError = OPROS_LOAD_DLL_ERROR;
	}
#endif

	if(imu->Initialize(parameter) != API_SUCCESS) {
		delete imu;
		imu = NULL;

#if defined(WIN32)
		FreeLibrary(hOprosAPI);
#else
		dlclose(hOprosAPI);
#endif
		hOprosAPI = NULL;
		return lastError = OPROS_INITIALIZE_API_ERROR;
	}

	return lastError = OPROS_SUCCESS;
}
开发者ID:OPRoS,项目名称:Component,代码行数:81,代码来源:InertiaMeasurementUnitComp.cpp


示例10: load_sym_fail

static int load_sym_fail(const char* sym)
{
  fprintf(stderr, LPF "ERROR: dlsym(\"%s\") failed\n", sym);
  fprintf(stderr, LPF "ERROR: dlerror '%s'\n", dlerror());
  exit(-1);
}
开发者ID:davenso,项目名称:openonload,代码行数:6,代码来源:sfcaffinity.c


示例11: UpdatePluginsBIOS

void UpdatePluginsBIOS() {
	DIR *dir;
	struct dirent *ent;
	void *Handle;
	char name[256];
	gchar *linkname;

	GpuConfS.plugins  = 0;
	SpuConfS.plugins  = 0;
	CdrConfS.plugins  = 0;
#ifdef ENABLE_SIO1API
	Sio1ConfS.plugins = 0;
#endif
	Pad1ConfS.plugins = 0;
	Pad2ConfS.plugins = 0;
	BiosConfS.plugins = 0;
	GpuConfS.glist  = NULL;
	SpuConfS.glist  = NULL;
	CdrConfS.glist  = NULL;
#ifdef ENABLE_SIO1API
	Sio1ConfS.glist  = NULL;
#endif
	Pad1ConfS.glist = NULL;
	Pad2ConfS.glist = NULL;
	BiosConfS.glist = NULL;
	GpuConfS.plist[0][0]  = '\0';
	SpuConfS.plist[0][0]  = '\0';
	CdrConfS.plist[0][0]  = '\0';
#ifdef ENABLE_SIO1API
	Sio1ConfS.plist[0][0]  = '\0';
#endif
	Pad1ConfS.plist[0][0] = '\0';
	Pad2ConfS.plist[0][0] = '\0';
	BiosConfS.plist[0][0] = '\0';

	// Load and get plugin info
	dir = opendir(Config.PluginsDir);
	if (dir == NULL) {
		printf(_("Could not open directory: '%s'\n"), Config.PluginsDir);
		return;
	}
	while ((ent = readdir(dir)) != NULL) {
		long type, v;
		linkname = g_build_filename(Config.PluginsDir, ent->d_name, NULL);

		// only libraries past this point, not config tools
		if (strstr(linkname, ".so") == NULL && strstr(linkname, ".dylib") == NULL)
			continue;

		Handle = dlopen(linkname, RTLD_NOW);
		if (Handle == NULL) {
			printf("%s\n", dlerror());
			g_free(linkname);
			continue;
		}

		PSE_getLibType = (PSEgetLibType)dlsym(Handle, "PSEgetLibType");
		if (PSE_getLibType == NULL) {
			if (strstr(linkname, "gpu") != NULL) type = PSE_LT_GPU;
			else if (strstr(linkname, "cdr") != NULL) type = PSE_LT_CDR;
#ifdef ENABLE_SIO1API
			else if (strstr(linkname, "sio1") != NULL) type = PSE_LT_SIO1;
#endif
			else if (strstr(linkname, "spu") != NULL) type = PSE_LT_SPU;
			else if (strstr(linkname, "pad") != NULL) type = PSE_LT_PAD;
			else { g_free(linkname); continue; }
		}
		else type = PSE_getLibType();

		PSE_getLibName = (PSEgetLibName) dlsym(Handle, "PSEgetLibName");
		if (PSE_getLibName != NULL) {
			sprintf(name, "%s", PSE_getLibName());
			PSE_getLibVersion = (PSEgetLibVersion) dlsym(Handle, "PSEgetLibVersion");
			if (PSE_getLibVersion != NULL) {
				char ver[32];

				v = PSE_getLibVersion();
				sprintf(ver, " %ld.%ld.%ld", v >> 16, (v >> 8) & 0xff, v & 0xff);
				strcat(name, ver);
			}
		}
开发者ID:SonofUgly,项目名称:PCSX-Reloaded,代码行数:81,代码来源:ConfDlg.c


示例12: dlopen

static void *ll_load(lua_State *L, const char *path, int gl)
{
  void *lib = dlopen(path, RTLD_NOW | (gl ? RTLD_GLOBAL : RTLD_LOCAL));
  if (lib == NULL) lua_pushstring(L, dlerror());
  return lib;
}
开发者ID:wenhulove333,项目名称:ScutServer,代码行数:6,代码来源:lib_package.c


示例13: OS_ModuleLoad

/*--------------------------------------------------------------------------------------
    Name: OS_ModuleLoad

    Purpose: Loads an object file into the running operating system

    Parameters:

    Returns: OS_ERROR if the module cannot be loaded
             OS_INVALID_POINTER if one of the parameters is NULL
             OS_ERR_NO_FREE_IDS if the module table is full
             OS_ERR_NAME_TAKEN if the name is in use
             OS_SUCCESS if the module is loaded successfuly
---------------------------------------------------------------------------------------*/
int32 OS_ModuleLoad ( uint32 *module_id, char *module_name, char *filename )
{
   int         i;
   uint32      possible_moduleid;
   char        translated_path[OS_MAX_LOCAL_PATH_LEN];
   int32       return_code;
   void       *function_lib;     /*  Handle to shared lib file */
   const char *dl_error;    /*  Pointer to error string   */
   sigset_t    previous;
   sigset_t    mask;

   /*
   ** Check parameters
   */
   if (( filename == NULL ) || (module_id == NULL ) || (module_name == NULL))
   {
      return(OS_INVALID_POINTER);
   }

   OS_InterruptSafeLock(&OS_module_table_mut, &mask, &previous);

   /*
   ** Find a free module id
   */
   for( possible_moduleid = 0; possible_moduleid < OS_MAX_MODULES; possible_moduleid++)
   {
       if (OS_module_table[possible_moduleid].free == TRUE)
       {
           break;
       }
   }

   /*
   ** Check to see if the id is out of bounds
   */
   if( possible_moduleid >= OS_MAX_MODULES || OS_module_table[possible_moduleid].free != TRUE)
   {
       OS_InterruptSafeUnlock(&OS_module_table_mut, &previous);
       return OS_ERR_NO_FREE_IDS;
   }

   /*
   ** Check to see if the module file is already loaded
   */
   for (i = 0; i < OS_MAX_MODULES; i++)
   {
       if ((OS_module_table[i].free == FALSE) &&
          ( strcmp((char*) module_name, OS_module_table[i].name) == 0))
       {
           OS_InterruptSafeUnlock(&OS_module_table_mut, &previous);
           return OS_ERR_NAME_TAKEN;
       }
   }

   /*
   ** Set the possible task Id to not free so that
   ** no other task can try to use it
   */
   OS_module_table[possible_moduleid].free = FALSE ;
   OS_InterruptSafeUnlock(&OS_module_table_mut, &previous);

   /*
   ** Translate the filename to the Host System
   */
   return_code = OS_TranslatePath((const char *)filename, (char *)translated_path);
   if ( return_code != OS_SUCCESS )
   {
      OS_module_table[possible_moduleid].free = TRUE;
      return(return_code);
   }

   /*
   ** File is ready to load
   */

   /*
   ** Open the loadble bundle .. just opening it loads it into the system.
   */
   function_lib = dlopen(translated_path, RTLD_LAZY | RTLD_GLOBAL);
   dl_error = dlerror();
   if( dl_error )
   {
      OS_module_table[possible_moduleid].free = TRUE;
      return(OS_ERROR);
   }

   /*
//.........这里部分代码省略.........
开发者ID:TomCrowley-ME,项目名称:me_sim_test,代码行数:101,代码来源:osloader.c


示例14: driOpenDriver

/**
 * Try to \c dlopen the named driver.
 *
 * This function adds the "_dri.so" suffix to the driver name and searches the
 * directories specified by the \c LIBGL_DRIVERS_PATH environment variable in
 * order to find the driver.
 *
 * \param driverName - a name like "tdfx", "i810", "mga", etc.
 *
 * \returns
 * A handle from \c dlopen, or \c NULL if driver file not found.
 */
_X_HIDDEN void *
driOpenDriver(const char *driverName)
{
   void *glhandle, *handle;
   const char *libPaths, *p, *next;
   char realDriverName[200];
   int len;

   /* Attempt to make sure libGL symbols will be visible to the driver */
   glhandle = dlopen("libGL.so.1", RTLD_NOW | RTLD_GLOBAL);

   libPaths = NULL;
   if (geteuid() == getuid()) {
      /* don't allow setuid apps to use LIBGL_DRIVERS_PATH */
      libPaths = getenv("LIBGL_DRIVERS_PATH");
      if (!libPaths)
         libPaths = getenv("LIBGL_DRIVERS_DIR");        /* deprecated */
   }
   if (libPaths == NULL)
      libPaths = DEFAULT_DRIVER_DIR;

   handle = NULL;
   for (p = libPaths; *p; p = next) {
      next = strchr(p, ':');
      if (next == NULL) {
         len = strlen(p);
         next = p + len;
      }
      else {
         len = next - p;
         next++;
      }

#ifdef GLX_USE_TLS
      snprintf(realDriverName, sizeof realDriverName,
               "%.*s/tls/%s_dri.so", len, p, driverName);
      InfoMessageF("OpenDriver: trying %s\n", realDriverName);
      handle = dlopen(realDriverName, RTLD_NOW | RTLD_GLOBAL);
#endif

      if (handle == NULL) {
         snprintf(realDriverName, sizeof realDriverName,
                  "%.*s/%s_dri.so", len, p, driverName);
         InfoMessageF("OpenDriver: trying %s\n", realDriverName);
         handle = dlopen(realDriverName, RTLD_NOW | RTLD_GLOBAL);
      }

      if (handle != NULL)
         break;
      else
         ErrorMessageF("dlopen %s failed (%s)\n", realDriverName, dlerror());
   }

   if (!handle)
      ErrorMessageF("unable to load driver: %s_dri.so\n", driverName);

   if (glhandle)
      dlclose(glhandle);

   return handle;
}
开发者ID:nikai3d,项目名称:mesa,代码行数:73,代码来源:dri_common.c


示例15: _module_free

static void _module_free(struct module *module) {
	pixel_alloc((void *)module->name, 0);
	if (dlclose(module->dl))
		pixel_log(0, "dlclose: %s\n", dlerror());
}
开发者ID:zhoukk,项目名称:routine,代码行数:5,代码来源:module.c


示例16: _ftpl_time

/*
 *  Our version of time() allows us to return fake values, so the calling
 *  program thinks it's retrieving the current date and time, while it is
 *  not
 *  Note that this routine is split into two parts so that the initialization
 *  piece can call the 'real' time function to establish a base time.
 */
static time_t _ftpl_time(time_t *time_tptr) {
#ifdef __APPLE__
    struct timeval tvm, *tv = &tvm;
#else
    static time_t (*real_time)(time_t *);
    static int has_real_time = 0;
#endif

    time_t result;

    time_t null_dummy;

    /* Handle null pointers correctly, fix as suggested by Andres Ojamaa */
    if (time_tptr == NULL) {
        time_tptr = &null_dummy;
        /* (void) fprintf(stderr, "NULL pointer caught in time().\n"); */
    }

#ifdef __APPLE__
    /* Check whether we've got a pointer to the real ftime() function yet */
    SINGLE_IF(has_real_gettimeofday==0)
        real_gettimeofday = NULL;
        real_gettimeofday = dlsym(RTLD_NEXT, "gettimeofday");

        /* check whether dlsym() worked */
        if (dlerror() == NULL) {
            has_real_gettimeofday = 1;
        }
    END_SINGLE_IF
    if (!has_real_gettimeofday) {  /* dlsym() failed */
#ifdef DEBUG
            (void) fprintf(stderr, "faketime problem: original gettimeofday() not found.\n");
#endif
            return -1; /* propagate error to caller */
    }

    /* initialize our result with the real current time */
    result = (*real_gettimeofday)(tv, NULL);
    if (result == -1) return result; /* original function failed */
    if (time_tptr != NULL)
        *time_tptr = tv->tv_sec;
    result = tv->tv_sec;
#else
    /* Check whether we've got a pointer to the real time function yet */
    SINGLE_IF(has_real_time==0)
        real_time = NULL;
        real_time = dlsym(RTLD_NEXT, "time");

        /* check whether dlsym() worked */
        if (dlerror() == NULL) {
            has_real_time = 1;
        }
    END_SINGLE_IF
    if (!has_real_time) {  /* dlsym() failed */
#ifdef DEBUG
            (void) fprintf(stderr, "faketime problem: original time() not found.\n");
#endif
            if (time_tptr != NULL)
                *time_tptr = -1;
            return -1; /* propagate error to caller */
    }

    /* initialize our result with the real current time */
    result = (*real_time)(time_tptr);
#endif

    return result;
}
开发者ID:bitland,项目名称:libfaketime,代码行数:75,代码来源:faketime.c


示例17: load_handlers

/**
 * @brief load all handlers found in the ::HANDLERS_DIR
 * @returns 0 on success, -1 on error.
 */
int load_handlers() {
    DIR *d;
    struct dirent *de;
    handler *h;
    char *path, *cwd;
    void *handle;
    size_t len;

    len = 50;
    cwd = malloc(len);

    while(cwd && len < PATH_MAX) {
        if(getcwd(cwd, len)) break;
        if(errno != ERANGE) {
            print( ERROR, "getcwd: %s", strerror(errno));
            free(cwd);
            return -1;
        }
        len += 50;
        cwd = realloc(cwd, len);
    }

    if(!cwd) {
        print( ERROR, "malloc(%d): %s", len, strerror(errno));
        return -1;
    }

    d = opendir(HANDLERS_DIR);

    if(!d) {
        print( ERROR, "opendir: %s", strerror(errno) );
        free(cwd);
        return -1;
    }

    while((de=readdir(d))) {
        if(!strncmp(de->d_name, ".", 2) || !strncmp(de->d_name, "..", 3)) {
            continue;
        }

        len = strlen(de->d_name);

        if(strncmp(de->d_name + (len - 3), ".so", 3))
            continue;

        if(asprintf(&path, "%s/" HANDLERS_DIR "/%s", cwd, de->d_name) == -1) {
            print( ERROR, "asprintf: %s", strerror(errno) );
            continue;
        }

        if(!(handle = dlopen(path, RTLD_NOW))) {
            print( ERROR, "dlopen: %s", dlerror() );
            free(path);
            continue;
        }

        if(!(h = (handler *)dlsym(handle, "handler_info"))) {
            print( ERROR, "\"%s\": undefined reference to 'handler_info'", path );
            goto close;
        }

        if(check_handler(h)) {
            goto close;
        }

        h->dl_handle = handle;

        list_add(&(handlers), (node *) h);

        free(path);
        continue;

close:

        if(dlclose(handle))
            print( ERROR, "dlclose(\"%s\"): %s", path, dlerror() );

        free(path);
    }

    closedir(d);

    free(cwd);

    if(!handlers.head) {
        print( ERROR, "no handlers found" );
        return -1;
    }

    return 0;
}
开发者ID:Katarzynasrom,项目名称:daemon,代码行数:95,代码来源:handler.c


示例18: vcc_ParseImport

void
vcc_ParseImport(struct vcc *tl)
{
	void *hdl;
	char fn[1024];
	struct token *mod, *t1;
	const char *modname;
	const char *proto;
	const char *abi;
	const char **spec;
	struct symbol *sym;
	const struct symbol *osym;
	const char *p;
	// int *modlen;

	t1 = tl->t;
	SkipToken(tl, ID);		/* "import" */

	ExpectErr(tl, ID);
	mod = tl->t;
	vcc_NextToken(tl);

	osym = VCC_FindSymbol(tl, mod, SYM_NONE);
	if (osym != NULL && osym->kind != SYM_VMOD) {
		VSB_printf(tl->sb, "Module %.*s conflics with other symbol.\n",
		    PF(mod));
		vcc_ErrWhere2(tl, t1, tl->t);
		return;
	}
	if (osym != NULL) {
		VSB_printf(tl->sb, "Module %.*s already imported.\n",
		    PF(mod));
		vcc_ErrWhere2(tl, t1, tl->t);
		VSB_printf(tl->sb, "Previous import was here:\n");
		vcc_ErrWhere2(tl, osym->def_b, osym->def_e);
		return;
	}

	bprintf(fn, "%.*s", PF(mod));
	sym = VCC_AddSymbolStr(tl, fn, SYM_VMOD);
	ERRCHK(tl);
	AN(sym);
	sym->def_b = t1;
	sym->def_e = tl->t;

	if (tl->t->tok == ID) {
		if (!tl->unsafe_path) {
			VSB_printf(tl->sb,
			    "'import ... from path...'"
			    " not allowed.\nAt:");
			vcc_ErrToken(tl, tl->t);
			vcc_ErrWhere(tl, tl->t);
			return;
		}
		if (!vcc_IdIs(tl->t, "from")) {
			VSB_printf(tl->sb, "Expected 'from path...'\n");
			vcc_ErrWhere(tl, tl->t);
			return;
		 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ dlfree函数代码示例发布时间:2022-05-30
下一篇:
C++ dlaset_函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap