CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
-SET(this_target osp-appinfo)
+SET(this_target appinfo)
-SET(VERSION 0.1.1)
SET(VERSION_MAJOR 0)
+SET(VERSION "${VERSION_MAJOR}.1.0")
-INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
-INCLUDE_DIRECTORIES(
- /usr/include/dlog
+#INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/inc)
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(pkgs REQUIRED
+ dlog
)
+FOREACH(flag ${pkgs_CFLAGS})
+ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+
SET (${this_target}_SOURCE_FILES
${CMAKE_CURRENT_SOURCE_DIR}/appinfo.c
- )
-
-#CONFIGURE_FILE(appinfo.pc.in appinfo.pc @ONLY)
+)
ADD_LIBRARY(${this_target} SHARED ${${this_target}_SOURCE_FILES})
SET(CMAKE_CXX_FLAGS "${OSP_DEBUG_FLAGS} ${OSP_OPT_FLAGS} ${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS} ${OSP_COMPILER_FLAGS}")
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined -Wl,--as-needed")
-TARGET_LINK_LIBRARIES(${this_target} "-ldlog")
+TARGET_LINK_LIBRARIES(${this_target} ${pkgs_LDFLAGS})
+
+SET(PC_NAME ${this_target})
+SET(PC_REQUIRED ${pc_requires})
+SET(PC_LDFLAGS -l${this_target})
-INSTALL(TARGETS ${this_target} DESTINATION ${LIB_INSTALL_DIR}
+CONFIGURE_FILE(appinfo.pc.in appinfo.pc @ONLY)
+
+INSTALL(TARGETS ${this_target} DESTINATION ${LIB_INSTALL_DIR}/osp
PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ
GROUP_EXECUTE GROUP_READ
WORLD_EXECUTE WORLD_READ)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/appinfo.h DESTINATION include/osp)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/appinfo.pc DESTINATION lib/pkgconfig)
+
static int _compat_mode = 0;
static int _app_info_init = 0;
-static int _argc;
-static char** _argv;
+static int _argc = 0;
+static char** _argv = NULL;
#define MAX_OSP_PKGID 10
#define MAX_APPID 256
static const char* _appid = NULL;
static const char* _execname = NULL;
-static app_info_version_e __get_api_version_from_str(const char * ver_str)
-{
-
- if(ver_str == NULL)
- return APP_INFO_VERSION_INVALID;
-
- if(!strcmp(ver_str,"3.0"))
- {
- return APP_INFO_VERSION_3_0;
- }
- else if(!strcmp(ver_str,"2.2"))
- {
- return APP_INFO_VERSION_2_2;
- }
- else if(!strcmp(ver_str,"2.1"))
- {
- return APP_INFO_VERSION_2_1;
- }
- else if(!strcmp(ver_str,"2.0"))
- {
- return APP_INFO_VERSION_2_0;
- }
- else if(!strcmp(ver_str,"1.2"))
- {
- return APP_INFO_VERSION_1_2;
- }
- else if(!strcmp(ver_str,"1.1"))
- {
- return APP_INFO_VERSION_1_1;
- }
- else if(!strcmp(ver_str,"1.0.2"))
- {
- return APP_INFO_VERSION_1_0_2;
- }
- else if(!strcmp(ver_str,"1.0"))
- {
- return APP_INFO_VERSION_1_0;
- }
- else
- {
- return APP_INFO_VERSION_INVALID;
- }
-
-}
/**
* @brief Initializes the appinfo structure
}
}
+app_info_version_e appinfo_get_api_version_from_str(const char * ver_str)
+{
+ if(ver_str == NULL)
+ {
+ return APP_INFO_VERSION_INVALID;
+ }
+
+ if(!strcmp(ver_str,"3.0"))
+ {
+ return APP_INFO_VERSION_3_0;
+ }
+ else if(!strcmp(ver_str,"2.2"))
+ {
+ return APP_INFO_VERSION_2_2;
+ }
+ else if(!strcmp(ver_str,"2.1"))
+ {
+ return APP_INFO_VERSION_2_1;
+ }
+ else if(!strcmp(ver_str,"2.0"))
+ {
+ return APP_INFO_VERSION_2_0;
+ }
+ else if(!strcmp(ver_str,"1.2"))
+ {
+ return APP_INFO_VERSION_1_2;
+ }
+ else if(!strcmp(ver_str,"1.1"))
+ {
+ return APP_INFO_VERSION_1_1;
+ }
+ else if(!strcmp(ver_str,"1.0.2"))
+ {
+ return APP_INFO_VERSION_1_0_2;
+ }
+ else if(!strcmp(ver_str,"1.0"))
+ {
+ return APP_INFO_VERSION_1_0;
+ }
+ else
+ {
+ return APP_INFO_VERSION_INVALID;
+ }
+}
+
/**
* @brief Returns whether the application is compat mode or not
*
int
appinfo_set_argv(int argc, char** argv)
{
- if(argc > 0 && !argv)
+ if(argc > 0 && argv)
{
_argc = argc;
_argv = argv;
int appinfo_get_argv(int* argc, char*** argv)
{
- if(_app_info_init)
+ if(_app_info_init && argc && argv)
{
- _argc = _argc;
- _argv = _argv;
+ *argc = _argc;
+ *argv = _argv;
+
return 1;
}
return 0;
}
+#define MIN(a,b) ((a) < (b) ? (a) : (b))
+
+int appinfo_update_submode_execname_and_appid(const char* execname)
+{
+ if (execname == NULL)
+ {
+ return 0;
+ }
+
+ const size_t max_len = MAX_APPID - MAX_OSP_PKGID - 1;
+ const size_t size = MIN(strlen(execname), max_len);
+ strncpy(__appid + MAX_OSP_PKGID + 1, execname, size);
+ __appid[size + MAX_OSP_PKGID + 1] = '\0';
+
+ return 1;
+}
+
#ifdef __cplusplus
}
#endif
APP_INFO_VERSION_MAX = 65535,
} app_info_version_e;
-const char* app_info_version_str[] = {
- "1.0",
- "1.02",
- "1.1",
- "2.0",
- "2.1",
- "2.2",
- "3.0"
-};
/**
* @brief Enumerations of error code
const char* appinfo_get_api_str_by_version(int ver);
/**
+ * @brief Returns the API version by given version string
+ *
+ * @param[in] ver_str Given version string
+ * @return the API version
+ */
+app_info_version_e appinfo_get_api_version_from_str(const char* ver_str);
+
+/**
* @brief Returns whether the application is compat mode or not
*
* @return @c 1 for compat mode, @c 0 otherwise
int appinfo_get_argv(int* argc, char*** argv);
+int appinfo_update_submode_execname_and_appid(const char* execname);
+
#ifdef __cplusplus
}
#endif
Name: osp-env-config
Summary: osp application environment cofiguration serivce
-Version: 1.2.2.0
+Version: 1.2.2.1
Release: 2
Group: System/Libraries
License: Apache-2.0
BuildRequires: pkgconfig(vconf)
Requires(post): coreutils
+Requires(post): /sbin/ldconfig
%description
osp application environment cofiguration serivce
+%package devel
+Summary: osp application environment cofiguration serivce (devel)
+Group: System/Libraries
+Requires: %{name} = %{version}-%{release}
+
+%description devel
+osp application environment cofiguration serivce (devel)
+
%prep
%setup -q
%manifest osp-env-config.manifest
/usr/share/license/%{name}
%{_libdir}/*.so*
+%{_libdir}/osp/libappinfo.so*
+%files devel
+%{_includedir}/osp/*.h
+%{_libdir}/pkgconfig/appinfo.pc