[svn-commits] tilghman: trunk r766 - in /trunk: menuselect.c menuselect_curses.c
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Wed May 26 16:20:21 CDT 2010
Author: tilghman
Date: Wed May 26 16:20:15 2010
New Revision: 766
URL: http://svnview.digium.com/svn/menuselect?view=rev&rev=766
Log:
Merged revisions 266146 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk
................
r266146 | tilghman | 2010-05-26 16:17:46 -0500 (Wed, 26 May 2010) | 21 lines
Merged revisions 266142 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r266142 | tilghman | 2010-05-26 16:11:44 -0500 (Wed, 26 May 2010) | 14 lines
Use sigaction for signals which should persist past the initial trigger, not signal.
If you call signal() in a Solaris signal handler, instead of just resetting
the signal handler, it causes the signal to refire, because the signal is not
marked as handled prior to the signal handler being called. This effectively
causes Solaris to immediately exceed the threadstack in recursive signal
handlers and crash.
(closes issue #17000)
Reported by: rmcgilvr
Patches:
20100526__issue17000.diff.txt uploaded by tilghman (license 14)
Tested by: rmcgilvr
........
................
Modified:
trunk/menuselect.c
trunk/menuselect_curses.c
Modified: trunk/menuselect.c
URL: http://svnview.digium.com/svn/menuselect/trunk/menuselect.c?view=diff&rev=766&r1=765&r2=766
==============================================================================
--- trunk/menuselect.c (original)
+++ trunk/menuselect.c Wed May 26 16:20:15 2010
@@ -72,11 +72,8 @@
/*! This is set when the --check-deps argument is provided. */
static int check_deps = 0;
-/*! This is set when the --enable-all argument is provided. */
-static int enable_all = 0;
-
-/*! This is set when the --disable-all argument is provided. */
-static int disable_all = 0;
+/*! These are set when the --list-options or --list-groups arguments are provided. */
+static int list_options = 0, list_groups = 0;
/*! This variable is non-zero when any changes are made */
int changes_made = 0;
@@ -1540,9 +1537,22 @@
return NULL;
}
+static int usage(const char *argv0)
+{
+ fprintf(stderr, "Usage: %s [--enable <option>] [--disable <option>]\n", argv0);
+ fprintf(stderr, " [--enable-category <category>] [--enable-all]\n");
+ fprintf(stderr, " [--disable-category <category>] [--disable-all] [...]\n");
+ fprintf(stderr, " [<config-file> [...]]\n");
+ fprintf(stderr, "Usage: %s { --check-deps | --list-options\n", argv0);
+ fprintf(stderr, " | --list-category <category> | --category-list | --help }\n");
+ fprintf(stderr, " [<config-file> [...]]\n");
+ return 0;
+}
+
int main(int argc, char *argv[])
{
int res = 0;
+ const char *list_group = NULL;
unsigned int x;
static struct option long_options[] = {
/*
@@ -1552,22 +1562,22 @@
* is not the case, an informative message will be printed to the
* user and the build will fail.
*/
- { "check-deps", no_argument, &check_deps, 1 },
- { "enable", required_argument, 0, 'e' },
- { "enable-category", required_argument, 0, 'E' },
- { "enable-all", no_argument, &enable_all, 1 },
- { "disable", required_argument, 0, 'd' },
- { "disable-category", required_argument, 0, 'D' },
- { "disable-all", no_argument, &disable_all, 1 },
+ { "check-deps", no_argument, &check_deps, 1 },
+ { "enable", required_argument, 0, 'e' },
+ { "enable-category", required_argument, 0, 'E' },
+ { "enable-all", no_argument, 0, 'a' },
+ { "disable", required_argument, 0, 'd' },
+ { "disable-category", required_argument, 0, 'D' },
+ { "disable-all", no_argument, 0, 'A' },
+ { "list-options", no_argument, &list_options, 1 },
+ { "list-category", required_argument, 0, 'L' },
+ { "category-list", no_argument, &list_groups, 1 },
+ { "help", no_argument, 0, 'h' },
{ 0, 0, 0, 0 },
};
- int do_menu = 1;
+ int do_menu = 1, do_settings = 1;
int c, option_index = 0;
- const char *enable = NULL;
- const char *enable_cat = NULL;
- const char *disable = NULL;
- const char *disable_cat = NULL;
if (open_debug()) {
exit(1);
@@ -1585,29 +1595,29 @@
while ((c = getopt_long(argc, argv, "", long_options, &option_index)) != -1) {
switch (c) {
+ case 'L':
+ list_group = optarg;
+ do_settings = 0;
+ /* Fall-through */
+ case 'a':
+ case 'A':
case 'e':
- enable = optarg;
+ case 'E':
+ case 'd':
+ case 'D':
do_menu = 0;
break;
- case 'E':
- enable_cat = optarg;
- do_menu = 0;
- break;
- case 'd':
- disable = optarg;
- do_menu = 0;
- break;
- case 'D':
- disable_cat = optarg;
- do_menu = 0;
+ case 'h':
+ return usage(argv[0]);
break;
default:
break;
}
}
- if (check_deps || enable_all || disable_all) {
+ if (check_deps || list_options || list_groups) {
do_menu = 0;
+ do_settings = 0;
}
if (optind < argc) {
@@ -1631,64 +1641,109 @@
while (calc_dep_failures(0, 0) || calc_conflict_failures(0, 0));
+ print_debug("do_menu=%d, do_settings=%d\n", do_menu, do_settings);
+
if (do_menu && !res) {
res = run_menu();
- }
-
- if (!strlen_zero(enable)) {
+ } else if (!do_settings) {
+ if (list_groups) {
+ struct category *cat;
+ AST_LIST_TRAVERSE(&categories, cat, list) {
+ fprintf(stdout, "%s\n", cat->name);
+ }
+ } else if (list_options) {
+ struct category *cat;
+ struct member *mem;
+ AST_LIST_TRAVERSE(&categories, cat, list) {
+ AST_LIST_TRAVERSE(&cat->members, mem, list) {
+ fprintf(stdout, "%c %-30.30s %s\n", mem->enabled ? '+' : '-', mem->name, cat->name);
+ }
+ }
+ } else if (!strlen_zero(list_group)) {
+ struct category *cat;
+ struct member *mem;
+ if ((cat = find_category(list_group))) {
+ AST_LIST_TRAVERSE(&cat->members, mem, list) {
+ fprintf(stdout, "%c %s\n", mem->enabled ? '+' : '-', mem->name);
+ }
+ }
+ }
+ } else if (!do_menu && do_settings) {
struct member *mem;
-
- if ((mem = find_member(enable))) {
- set_member_enabled(mem);
- } else {
- fprintf(stderr, "'%s' not found\n", enable);
- }
- }
-
- if (!strlen_zero(enable_cat)) {
struct category *cat;
- if ((cat = find_category(enable_cat))) {
- set_all(cat, 1);
- } else {
- fprintf(stderr, "'%s' not found\n", enable_cat);
- }
- }
-
- if (!strlen_zero(disable)) {
- struct member *mem;
-
- if ((mem = find_member(disable))) {
- clear_member_enabled(mem);
- } else {
- fprintf(stderr, "'%s' not found\n", disable);
- }
- }
-
- if (!strlen_zero(disable_cat)) {
- struct category *cat;
-
- if ((cat = find_category(disable_cat))) {
- set_all(cat, 0);
- } else {
- fprintf(stderr, "'%s' not found\n", disable_cat);
- }
- }
-
- if (enable_all != disable_all) {
- struct category *cat;
-
- AST_LIST_TRAVERSE(&categories, cat, list) {
- set_all(cat, enable_all);
- }
- }
-
- if (!res)
+ print_debug("Doing settings with argc=%d\n", argc);
+
+ /* Reset options processing */
+ option_index = 0;
+ optind = 1;
+
+ while ((c = getopt_long(argc, argv, "", long_options, &option_index)) != -1) {
+ print_debug("Got option %c\n", c);
+ switch (c) {
+ case 'e':
+ if (!strlen_zero(optarg)) {
+ if ((mem = find_member(optarg))) {
+ set_member_enabled(mem);
+ } else {
+ fprintf(stderr, "'%s' not found\n", optarg);
+ }
+ }
+ break;
+ case 'E':
+ if (!strlen_zero(optarg)) {
+ if ((cat = find_category(optarg))) {
+ set_all(cat, 1);
+ } else {
+ fprintf(stderr, "'%s' not found\n", optarg);
+ }
+ }
+ break;
+ case 'a': /* enable-all */
+ AST_LIST_TRAVERSE(&categories, cat, list) {
+ set_all(cat, 1);
+ }
+ break;
+ case 'd':
+ if (!strlen_zero(optarg)) {
+ if ((mem = find_member(optarg))) {
+ clear_member_enabled(mem);
+ } else {
+ fprintf(stderr, "'%s' not found\n", optarg);
+ }
+ }
+ break;
+ case 'D':
+ if (!strlen_zero(optarg)) {
+ if ((cat = find_category(optarg))) {
+ set_all(cat, 0);
+ } else {
+ fprintf(stderr, "'%s' not found\n", optarg);
+ }
+ }
+ break;
+ case 'A': /* disable-all */
+ AST_LIST_TRAVERSE(&categories, cat, list) {
+ set_all(cat, 0);
+ }
+ break;
+ case '?':
+ break;
+ default:
+ break;
+ }
+ }
+ res = 0;
+ }
+
+ if (!res) {
res = generate_makeopts_file();
+ }
/* Always generate the dependencies file */
- if (!res)
+ if (!res) {
generate_makedeps_file();
+ }
/* free everything we allocated */
free_deps_file();
Modified: trunk/menuselect_curses.c
URL: http://svnview.digium.com/svn/menuselect/trunk/menuselect_curses.c?view=diff&rev=766&r1=765&r2=766
==============================================================================
--- trunk/menuselect_curses.c (original)
+++ trunk/menuselect_curses.c Wed May 26 16:20:15 2010
@@ -82,7 +82,7 @@
};
/*! \brief Handle a window resize in xterm */
-static void winch_handler(int sig)
+static void _winch_handler(int sig)
{
getmaxyx(stdscr, max_y, max_x);
@@ -93,11 +93,19 @@
}
}
+static struct sigaction winch_handler = {
+ .sa_handler = _winch_handler,
+};
+
/*! \brief Handle a SIGQUIT */
-static void sigint_handler(int sig)
-{
-
-}
+static void _sigint_handler(int sig)
+{
+
+}
+
+static struct sigaction sigint_handler = {
+ .sa_handler = _sigint_handler,
+};
/*! \brief Display help information */
static void show_help(WINDOW *win)
@@ -459,8 +467,8 @@
initscr();
getmaxyx(stdscr, max_y, max_x);
- signal(SIGWINCH, winch_handler); /* handle window resizing in xterm */
- signal(SIGINT, sigint_handler); /* handle window resizing in xterm */
+ sigaction(SIGWINCH, &winch_handler, NULL); /* handle window resizing in xterm */
+ sigaction(SIGINT, &sigint_handler, NULL); /* handle window resizing in xterm */
if (max_x < MIN_X || max_y < MIN_Y) {
fprintf(stderr, "Terminal must be at least %d x %d.\n", MIN_X, MIN_Y);
More information about the svn-commits
mailing list