X-Git-Url: https://git.draconx.ca/gitweb/upkg.git/blobdiff_plain/0a55ae84545c5e5a45e2240c06bd77a1917f7d3e..7b7fa9198e6872739a50374aebe61b6444611438:/src/uobject/package.c diff --git a/src/uobject/package.c b/src/uobject/package.c index af4ebb3..5b29afd 100644 --- a/src/uobject/package.c +++ b/src/uobject/package.c @@ -37,13 +37,6 @@ struct upkg_priv { G_DEFINE_TYPE(UPkg, u_pkg, G_TYPE_TYPE_MODULE); -/* Package search path. */ -static char *search_path; -static size_t search_path_sz; - -/* List of package file extensions, in descending order of precedence. */ -static const char u_pkg_exts[][5] = { ".u", ".utx", ".umx", ".uax", ".unr" }; - static char *str_cpy_lower(char *dst, const char *src) { size_t i; @@ -55,25 +48,6 @@ static char *str_cpy_lower(char *dst, const char *src) return dst; } -static int str_cmp_lower(const char *s1, const char *s2) -{ - size_t i; - - for (i = 0; s1[i] && s2[i]; i++) { - int c1 = tolower(s1[i]), c2 = tolower(s2[i]); - if (c1 < c2) - return -1; - if (c1 > c2) - return 1; - } - - if (s1[i]) - return 1; - if (s2[i]) - return -1; - return 0; -} - static void dl_print_errors(const char *prefix) { const char *err; @@ -87,15 +61,9 @@ static gboolean u_pkg_load(GTypeModule *m) { struct upkg_priv *priv = U_PKG_GET_PRIV(m); int (*init_func)(GTypeModule *); - const char *file; - file = u_pkg_vfs_lookup(m->name); - if (file) { - U_PKG(m)->pkg = upkg_fopen(file); - if (!U_PKG(m)->pkg) { - return FALSE; - } - } + /* Ignore failure here until we get rid of native-only packages. */ + U_PKG(m)->pkg = u_pkg_vfs_open_by_name(m->name); priv->native = lt_dlopenext(m->name); if (priv->native) { @@ -171,55 +139,6 @@ static void u_pkg_class_init(UPkgClass *class) objclass->finalize = u_pkg_finalize; } -static int expand_search_path(size_t need) -{ - size_t want = search_path_sz; - if (want == 0) want = 1; - - while (want < need) - want *= 2; - - if (want > search_path_sz) { - char *new = realloc(search_path, want); - if (!new) { - return -1; - } - - search_path = new; - search_path_sz = want; - } - - return 0; -} - -const char *u_pkg_get_search_path(void) -{ - return search_path ? search_path : ""; -} - -int u_pkg_set_search_path(const char *path) -{ - if (expand_search_path(strlen(path)+1) != 0) - return -1; - strcpy(search_path, path); - return 0; -} - -int u_pkg_add_search_dir(const char *path) -{ - size_t end = search_path ? strlen(search_path) : 0; - - if (end == 0) { - return u_pkg_set_search_path(path); - } - - if (expand_search_path(end + strlen(path) + 2) != 0) - return -1; - search_path[end] = LT_PATHSEP_CHAR; - strcpy(search_path+end+1, path); - return 0; -} - GTypeModule *u_pkg_open(const char *name) { g_return_val_if_fail(name != NULL, NULL); @@ -238,3 +157,10 @@ GTypeModule *u_pkg_open(const char *name) mod->name = str_cpy_lower(pkgname, name); return mod; } + +bool u_pkg_is_native(GTypeModule *m) +{ + struct upkg_priv *priv = U_PKG_GET_PRIV(m); + + return priv->native; +}