1. call source //call.h char* (*get_f)(char*, char*); //call.c lib_handle = dlopen("lib_so.so", RTLD_NOW); get_f = dlsym(lib_handle, "get_v"); const char *value = NULL; char *str_air = "air"; char *str_key = "key"; value = get_f(str_air, str_key); 2. shared library //shared_lib.h EXPORT_API char *get_v(char *str_air, char *str_key); //shared_lib.c char *get_v(char *str_air, char *str_key) { int ret = CKMC_ERROR_NONE; char *str; //str = calloc(1, sizeof(char) * 251); //strcpy(str, str_air); //strcat(str, str_key); char str[251] = {'\0'}; eina_strlcpy(str, str_air, strlen(str_air)+1); eina_strlcat(str, str_key, strlen(str_air)+strlen(str_key)+1); char* alias = str; char* key_password = NULL; char* error_c = NULL; ckmc_raw_buffer_s *_data; ret = ckmc_get_data(alias, key_password, &_data); //-31522804 if (CKMC_ERROR_NONE != ret) { switch (ret) { case CKMC_ERROR_INVALID_PARAMETER : snprintf(error_c, DISP_STR_SIZE, "%s", "error : 1"); return error_c; case CKMC_ERROR_DB_LOCKED : snprintf(error_c, DISP_STR_SIZE, "%s", "error : 2"); return error_c; case CKMC_ERROR_DB_ALIAS_EXISTS : snprintf(error_c, DISP_STR_SIZE, "%s", "error : 3"); return error_c; case CKMC_ERROR_INVALID_FORMAT : snprintf(error_c, DISP_STR_SIZE, "%s", "error : 4"); return error_c; case CKMC_ERROR_DB_ERROR : snprintf(error_c, DISP_STR_SIZE, "%s", "error : 5"); return error_c; case CKMC_ERROR_PERMISSION_DENIED : snprintf(error_c, DISP_STR_SIZE, "%s", "error : 5"); return error_c; default : snprintf(error_c, DISP_STR_SIZE, "error code : %d", ret); return error_c; // => -31522804 Returned } char *ret_str; ret_str = calloc(1, sizeof(char) * DISP_STR_SIZE); eina_strlcpy(ret_str, magic_data->data, magic_data->size+1); ckmc_buffer_free(magic_data); return ret_str; }
~ret = ckmc_get_data (alias, key_password, & _data); // -31522804
- The return value is the value does not get inflated the value of returns as -31522804.
- The general non-shared library code gets the normal value.
What do you have problems?