Exemple #1
0
/*
** Implementation of ff_unload_dv_module() above.
*/
int unload_dv_module(char* module_name)
{
	Var* v;

	/* v = get_global_sym(module_name); */
	v = search_in_list_of_loaded_modules(module_name);

	if (v) {
		if (VERBOSE) {
			parse_error("Unloading module %s.", module_name);
		}

		/*
		** Print module dependencies. So that the user knows
		** that unloding this module can cause problems.
		*/
		print_dependents(module_name);

		/*
		** free_var() bounces back to ff_modules.c::del_module() above
		** where uninit_dv_module() is called.
		*/
		free_var(v);
	} else {
		parse_error("Module %s is not loaded. So, it cannot be unloaded.", module_name);
	}

	return 1;
}
Exemple #2
0
int main(int argc, char **argv)
{
	struct arguments arguments;

	arguments.action = 0;
	arguments.no_favorite_repo = 0;
	arguments.no_favorite_version = 0;
	arguments.no_deps = 1;
	arguments.all = 0;
	arguments.args = NULL;

	if (argc < 2) {
		char *fake_arg[2];
		fake_arg[0] = "ilenia";
		fake_arg[1] = "--help";
		argp_parse(&argp, 2, fake_arg, 0, 0, &arguments);
	}

	argp_parse(&argp, argc, argv, 0, 0, &arguments);

	if (parse_ileniarc() != 0)
		return (EXIT_FAILURE);

	ilenia_repos = build_repolist();

	if (arguments.action == ACT_CACHE) {
		FILE *file;
		if ((file = fopen(CACHE, "w")))
			fclose(file);
	}

	ilenia_favoriterepo = get_favorite(FAVORITE_REPO);
	ilenia_favoriteversion = get_favorite(FAVORITE_VERSION);
	ilenia_aliases = aliaseslist_build();
	ilenia_ports = lsports();
	ilenia_pkgs = lspkgs();
	ilenia_favoritepkgmk = pkgmklist_build();

	if (arguments.action > 21 || arguments.action == 0)
		error("%s", "please perform an action at a time!");

	int confront_options =
	    arguments.no_favorite_repo + arguments.no_favorite_version;

	int update_options = arguments.no_deps;
	if (confront_options)
		update_options = confront_options * update_options;

	int status = EXIT_SUCCESS;

	if (arguments.action == ACT_UPDATE) {
		if (arguments.args == NULL) {
			status = update_all_repos();
			return (EXIT_SUCCESS);
		}
		while (arguments.args) {
			status = update_repo(arguments.args->data);
			arguments.args = arguments.args->next;
		}
	}

	if (arguments.action == ACT_LIST) {
		if (arguments.args == NULL) {
			pkglist_print(ilenia_ports);
			return (EXIT_SUCCESS);
		}
		while (arguments.args) {
			if (repolist_exists(arguments.args->data,
					    ilenia_repos)) {
				warning("repository %s not found!\n",
					arguments.args->data);
				arguments.args = arguments.args->next;
				continue;
			}
			pkglist_print(pkglist_select_from_repo
				      (arguments.args->data,
				       ilenia_ports));
			arguments.args = arguments.args->next;
		}
	}

	if (arguments.action == ACT_SEARCH) {
		if (arguments.args == NULL)
			error("action search requires an argument!");
		while (arguments.args) {
			pkglist_print(pkglist_find_like
				      (arguments.args->data,
				       ilenia_ports));
			arguments.args = arguments.args->next;
		}
	}

	if (arguments.action == ACT_INFO) {
		if (arguments.args == NULL)
			error("action info requires an argument!");
		while (arguments.args) {
			info(arguments.args->data, confront_options);
			arguments.args = arguments.args->next;
		}
	}

	if (arguments.action == ACT_DIFF)
		pkglist_confront(DIFF, confront_options, 1);

	if (arguments.action == ACT_UPDATED)
		pkglist_confront(UPDATED, confront_options, 1);

	if (arguments.action == ACT_DEPENDENCIES) {
		if (arguments.args == NULL)
			error("action dependencies requires an argument!");
		while (arguments.args) {
			print_dependencies(arguments.args->data);
			arguments.args = arguments.args->next;
		}
	}

	if (arguments.action == ACT_UPDATE_PKG) {
		if (arguments.args == NULL) {
			status = update_system(update_options);
			return status;
		}
		while (arguments.args) {
			status =
			    update_pkg(update_options,
				       arguments.args->data);
			arguments.args = arguments.args->next;
		}
	}

	if (arguments.action == ACT_DEPENDENTS) {
		if (arguments.args == NULL)
			error("action dependents requires an argument!");
		while (arguments.args) {
			print_dependents(arguments.args->data,
					 arguments.all);
			arguments.args = arguments.args->next;
		}
	}

	if (arguments.action == ACT_REMOVE) {
		if (arguments.args == NULL)
			error("action remove requires an argument!");
		while (arguments.args) {
			status =
			    remove_pkg(arguments.args->data,
				       arguments.no_deps, arguments.all);
			arguments.args = arguments.args->next;
		}
	}


	if (arguments.action == ACT_REPOSITORY_LIST) {
		while (ilenia_repos != NULL) {
			printf("name %s path %s\n", ilenia_repos->name,
			       ilenia_repos->path);
			ilenia_repos = ilenia_repos->next;
		}
	}

	return status;
}