Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Use global vars for common options.
Vsevolod Stakhov committed 11 years ago
commit aa44906ded9940ebe8d0503337e5dcec9f1a1ae5
parent cf29af9
4 files changed +50 -0
modified src/Makefile.am
@@ -13,6 +13,7 @@ pkg_SOURCES= add.c \
			delete.c \
			event.c \
			fetch.c \
+
			globals.c \
			info.c \
			install.c \
			lock.c \
added src/globals.c
@@ -0,0 +1,40 @@
+
/* Copyright (c) 2014, Vsevolod Stakhov
+
 * All rights reserved.
+
 *
+
 * Redistribution and use in source and binary forms, with or without
+
 * modification, are permitted provided that the following conditions are met:
+
 *       * Redistributions of source code must retain the above copyright
+
 *         notice, this list of conditions and the following disclaimer.
+
 *       * Redistributions in binary form must reproduce the above copyright
+
 *         notice, this list of conditions and the following disclaimer in the
+
 *         documentation and/or other materials provided with the distribution.
+
 *
+
 * THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY
+
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+
 * DISCLAIMED. IN NO EVENT SHALL AUTHOR BE LIABLE FOR ANY
+
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
 */
+

+
#include <pkg.h>
+

+
int yes; /* Assume always yes */
+
int dry_run; /* Do not perform any actions */
+
int auto_update; /* Do not update repo */
+
int case_sensitive; /* Case sensitive queries */
+
int force; /* Forced operation */
+

+
void
+
set_globals(void)
+
{
+
	yes = pkg_object_bool(pkg_config_get("ASSUME_ALWAYS_YES"));
+
	dry_run = 0;
+
	auto_update = pkg_object_bool(pkg_config_get("REPO_AUTOUPDATE"));
+
	case_sensitive = pkg_object_bool(pkg_config_get("CASE_SENSITIVE_MATCH"));
+
	force = 0;
+
}
modified src/main.c
@@ -862,6 +862,8 @@ main(int argc, char **argv)
		}
	}

+
	set_globals();
+

	if (command == NULL) {
		/* Check if a plugin provides the requested command */
		ret = EPKG_FATAL;
modified src/pkgcli.h
@@ -274,4 +274,11 @@ int analyse_query_string(char *qstr, struct query_flags *q_flags,
			 const unsigned int q_flags_len, int *flags,
			 char *multiline);

+
extern int yes;
+
extern int dry_run;
+
extern int auto_update;
+
extern int case_sensitive;
+
extern int force;
+
void set_globals(void);
+

#endif