Example #1
0
int SYMEXPORT alpm_option_remove_ignoregrp(const char *grp)
{
	char *vdata = NULL;
	handle->ignoregrp = alpm_list_remove_str(handle->ignoregrp, grp, &vdata);
	if(vdata != NULL) {
		FREE(vdata);
		return(1);
	}
	return(0);
}
Example #2
0
int SYMEXPORT alpm_option_remove_holdpkg(const char *pkg)
{
	char *vdata = NULL;
	handle->holdpkg = alpm_list_remove_str(handle->holdpkg, pkg, &vdata);
	if(vdata != NULL) {
		FREE(vdata);
		return(1);
	}
	return(0);
}
Example #3
0
int SYMEXPORT alpm_option_remove_noextract(const char *pkg)
{
	char *vdata = NULL;
	handle->noextract = alpm_list_remove_str(handle->noextract, pkg, &vdata);
	if(vdata != NULL) {
		FREE(vdata);
		return(1);
	}
	return(0);
}
Example #4
0
alpm_list_t *target_arg_clear (target_arg_t *t, alpm_list_t *targets)
{
	if (t && targets && config.just_one) {
		for (alpm_list_t *i = t->args; i; i = alpm_list_next (i)) {
			char *data = NULL;
			targets = alpm_list_remove_str (targets, i->data, &data);
			if (data) {
				free (data);
			}
		}
	}
	return targets;
}
Example #5
0
int SYMEXPORT alpm_option_remove_cachedir(const char *cachedir)
{
	char *vdata = NULL;
	char *newcachedir;
	size_t cachedirlen;
	/* verify cachedir ends in a '/' */
	cachedirlen = strlen(cachedir);
	if(cachedir[cachedirlen-1] != '/') {
		cachedirlen += 1;
	}
	newcachedir = calloc(cachedirlen + 1, sizeof(char));
	strncpy(newcachedir, cachedir, cachedirlen);
	newcachedir[cachedirlen-1] = '/';
	handle->cachedirs = alpm_list_remove_str(handle->cachedirs, newcachedir, &vdata);
	FREE(newcachedir);
	if(vdata != NULL) {
		FREE(vdata);
		return(1);
	}
	return(0);
}
Example #6
0
/** Main function.
 * @param argc
 * @param argv
 * @return A return code indicating success, failure, etc.
 */
int main(int argc, char *argv[])
{
	int ret = 0;
	size_t i;
	struct sigaction new_action, old_action;
	const int signals[] = { SIGHUP, SIGINT, SIGTERM, SIGSEGV, SIGWINCH };
	uid_t myuid = getuid();

	/* Set signal handlers */
	/* Set up the structure to specify the new action. */
	new_action.sa_handler = handler;
	sigemptyset(&new_action.sa_mask);
	new_action.sa_flags = SA_RESTART;

	/* assign our handler to any signals we care about */
	for(i = 0; i < sizeof(signals) / sizeof(signals[0]); i++) {
		int signal = signals[i];
		sigaction(signal, NULL, &old_action);
		if(old_action.sa_handler != SIG_IGN) {
			sigaction(signal, &new_action, NULL);
		}
	}

	/* i18n init */
#if defined(ENABLE_NLS)
	localize();
#endif

	/* set user agent for downloading */
	setuseragent();

	/* init config data */
	if(!(config = config_new())) {
		/* config_new prints the appropriate error message */
		cleanup(1);
	}

	/* disable progressbar if the output is redirected */
	if(!isatty(fileno(stdout))) {
		config->noprogressbar = 1;
	}

	/* Priority of options:
	 * 1. command line
	 * 2. config file
	 * 3. compiled-in defaults
	 * However, we have to parse the command line first because a config file
	 * location can be specified here, so we need to make sure we prefer these
	 * options over the config file coming second.
	 */

	/* parse the command line */
	ret = parseargs(argc, argv);
	if(ret != 0) {
		cleanup(ret);
	}

	/* we support reading targets from stdin if a cmdline parameter is '-' */
	if(alpm_list_find_str(pm_targets, "-")) {
		if(!isatty(fileno(stdin))) {
			int target_found = 0;
			size_t current_size = PATH_MAX;
			char *vdata, *line = malloc(current_size);
			int c;

			/* remove the '-' from the list */
			pm_targets = alpm_list_remove_str(pm_targets, "-", &vdata);
			free(vdata);

			i = 0;
			do {
				c = fgetc(stdin);
				if(c == EOF || isspace(c)) {
					/* avoid adding zero length arg when multiple spaces separate args */
					if(i > 0) {
						line[i] = '\0';
						pm_targets = alpm_list_add(pm_targets, strdup(line));
						target_found = 1;
						i = 0;
					}
				} else {
					line[i++] = (char)c;
					/* we may be at the end of our allocated buffer now */
					if(i >= current_size) {
						char *new = realloc(line, current_size * 2);
						if(new) {
							line = new;
							current_size *= 2;
						} else {
							free(line);
							pm_printf(ALPM_LOG_ERROR,
									_("memory exhausted in argument parsing\n"));
							cleanup(EXIT_FAILURE);
						}
					}
				}
			} while(c != EOF);
Example #7
0
/**
 * pacman_list_remove_string:
 * @haystack: A #PacmanList.
 * @needle: A string to remove.
 * @removed: A location to hold a string, or %NULL if you do not need to use or free it.
 *
 * Removes a string equal to @needle from @haystack, and places it in @removed.
 *
 * Returns: A new reference to @haystack. Do not use or free @haystack afterwards.
 */
PacmanList *pacman_list_remove_string (PacmanList *haystack, const gchar *needle, gchar **removed) {
	return alpm_list_remove_str (haystack, needle, removed);
}