static void _print_help(const char *cmd) { int i; fprintf(stderr, "Usage:\n"); fprintf(stderr, "\n"); fprintf(stderr, "[Get appinfo value]\n"); fprintf(stderr, " %s get \n", cmd); fprintf(stderr, "\n"); fprintf(stderr, " \n"); for (i = 0; prop_tbl[i]; i++) { fprintf(stderr, " %s\n", prop_tbl[i]); } fprintf(stderr, "\n"); fprintf(stderr, " Ex) %s get com.samsung.menu-screen X_SLP_SERVICE\n", cmd); fprintf(stderr, "\n"); } static int _get_property(const char *property) { int i; if (!property) { return 0; } for (i = 0; prop_tbl[i]; i++) { if (!strcasecmp(prop_tbl[i], property)) { return i; } } fprintf(stderr, "%s is not found\n", property); return -1; } static ail_error_e _get_appinfo(const char *package, const char *property) { ail_appinfo_h handle; ail_error_e ret; int prop, ival; bool bval; char *str; struct element e; struct element *p; int t; ret = ail_package_get_appinfo(package, &handle); if (ret != AIL_ERROR_OK) { return AIL_ERROR_FAIL; } prop = _get_property(property); if (prop < 0) { return AIL_ERROR_FAIL; } e.prop = prop; p = &e; ELEMENT_TYPE(p,t); if (t == VAL_TYPE_STR) { ret = ail_appinfo_get_str(handle, prop, &str); if (ret != AIL_ERROR_OK) { return AIL_ERROR_FAIL; } fprintf(stderr, "Package[%s], Property[%s] : %s\n", package, property, str); } else if (t == VAL_TYPE_INT) { ret = ail_appinfo_get_int(handle, prop, &ival); if (ret != AIL_ERROR_OK) { return AIL_ERROR_FAIL; } fprintf(stderr, "Package[%s], Property[%s] : %d\n", package, property, ival); } else if (t == VAL_TYPE_BOOL) { ret = ail_appinfo_get_bool(handle, prop, &bval); if (ret != AIL_ERROR_OK) { return AIL_ERROR_FAIL; } fprintf(stderr, "Package[%s], Property[%s] : %d\n", package, property, bval); } ret = ail_package_destroy_appinfo(handle); if (ret != AIL_ERROR_OK) { return AIL_ERROR_FAIL; } return AIL_ERROR_OK; } int main(int argc, char** argv) { ail_error_e ret = AIL_ERROR_OK; if (4 == argc) { if (!strncmp(argv[1], "get", 3)) { ret = _get_appinfo(argv[2], argv[3]); } } else { _print_help(argv[0]); return EXIT_FAILURE; } if (ret != AIL_ERROR_OK) { fprintf(stderr, "There are some problems\n"); } return EXIT_SUCCESS; }