summaryrefslogtreecommitdiffstats
path: root/scripts/lxdialog/lxdialog.c
diff options
context:
space:
mode:
authorSam Ravnborg <sam@mars.ravnborg.org>2005-11-19 19:13:34 +0100
committerSam Ravnborg <sam@mars.ravnborg.org>2005-11-19 19:13:34 +0100
commitb1c5f1c635f4a821f834ed51ccd8a2a1515fffd2 (patch)
tree7325e59c16a2b90fd6f78ab491f7ef48bfd409b9 /scripts/lxdialog/lxdialog.c
parentb286e39207237e2f6929959372bf66d9a8d05a82 (diff)
downloadlinux-b1c5f1c635f4a821f834ed51ccd8a2a1515fffd2.tar.gz
linux-b1c5f1c635f4a821f834ed51ccd8a2a1515fffd2.tar.bz2
linux-b1c5f1c635f4a821f834ed51ccd8a2a1515fffd2.zip
kconfig: Lindent scripts/lxdialog
The lxdialog code was not easy to read. So as first step the code was run through Lindent. Fix-ups will come in next patchset. Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Diffstat (limited to 'scripts/lxdialog/lxdialog.c')
-rw-r--r--scripts/lxdialog/lxdialog.c238
1 files changed, 112 insertions, 126 deletions
diff --git a/scripts/lxdialog/lxdialog.c b/scripts/lxdialog/lxdialog.c
index f283a8545426..2c34ea1e0a41 100644
--- a/scripts/lxdialog/lxdialog.c
+++ b/scripts/lxdialog/lxdialog.c
@@ -21,30 +21,29 @@
#include "dialog.h"
-static void Usage (const char *name);
+static void Usage(const char *name);
-typedef int (jumperFn) (const char *title, int argc, const char * const * argv);
+typedef int (jumperFn) (const char *title, int argc, const char *const *argv);
struct Mode {
- char *name;
- int argmin, argmax, argmod;
- jumperFn *jumper;
+ char *name;
+ int argmin, argmax, argmod;
+ jumperFn *jumper;
};
jumperFn j_menu, j_checklist, j_radiolist, j_yesno, j_textbox, j_inputbox;
jumperFn j_msgbox, j_infobox;
-static struct Mode modes[] =
-{
- {"--menu", 9, 0, 3, j_menu},
- {"--checklist", 9, 0, 3, j_checklist},
- {"--radiolist", 9, 0, 3, j_radiolist},
- {"--yesno", 5,5,1, j_yesno},
- {"--textbox", 5,5,1, j_textbox},
- {"--inputbox", 5, 6, 1, j_inputbox},
- {"--msgbox", 5, 5, 1, j_msgbox},
- {"--infobox", 5, 5, 1, j_infobox},
- {NULL, 0, 0, 0, NULL}
+static struct Mode modes[] = {
+ {"--menu", 9, 0, 3, j_menu},
+ {"--checklist", 9, 0, 3, j_checklist},
+ {"--radiolist", 9, 0, 3, j_radiolist},
+ {"--yesno", 5, 5, 1, j_yesno},
+ {"--textbox", 5, 5, 1, j_textbox},
+ {"--inputbox", 5, 6, 1, j_inputbox},
+ {"--msgbox", 5, 5, 1, j_msgbox},
+ {"--infobox", 5, 5, 1, j_infobox},
+ {NULL, 0, 0, 0, NULL}
};
static struct Mode *modePtr;
@@ -53,96 +52,92 @@ static struct Mode *modePtr;
#include <locale.h>
#endif
-int
-main (int argc, const char * const * argv)
+int main(int argc, const char *const *argv)
{
- int offset = 0, opt_clear = 0, end_common_opts = 0, retval;
- const char *title = NULL;
+ int offset = 0, opt_clear = 0, end_common_opts = 0, retval;
+ const char *title = NULL;
#ifdef LOCALE
- (void) setlocale (LC_ALL, "");
+ (void)setlocale(LC_ALL, "");
#endif
#ifdef TRACE
- trace(TRACE_CALLS|TRACE_UPDATE);
+ trace(TRACE_CALLS | TRACE_UPDATE);
#endif
- if (argc < 2) {
- Usage (argv[0]);
- exit (-1);
- }
-
- while (offset < argc - 1 && !end_common_opts) { /* Common options */
- if (!strcmp (argv[offset + 1], "--title")) {
- if (argc - offset < 3 || title != NULL) {
- Usage (argv[0]);
- exit (-1);
- } else {
- title = argv[offset + 2];
- offset += 2;
- }
- } else if (!strcmp (argv[offset + 1], "--backtitle")) {
- if (backtitle != NULL) {
- Usage (argv[0]);
- exit (-1);
- } else {
- backtitle = argv[offset + 2];
- offset += 2;
- }
- } else if (!strcmp (argv[offset + 1], "--clear")) {
- if (opt_clear) { /* Hey, "--clear" can't appear twice! */
- Usage (argv[0]);
- exit (-1);
- } else if (argc == 2) { /* we only want to clear the screen */
- init_dialog ();
- refresh (); /* init_dialog() will clear the screen for us */
- end_dialog ();
- return 0;
- } else {
- opt_clear = 1;
- offset++;
- }
- } else /* no more common options */
- end_common_opts = 1;
- }
-
- if (argc - 1 == offset) { /* no more options */
- Usage (argv[0]);
- exit (-1);
- }
- /* use a table to look for the requested mode, to avoid code duplication */
-
- for (modePtr = modes; modePtr->name; modePtr++) /* look for the mode */
- if (!strcmp (argv[offset + 1], modePtr->name))
- break;
-
- if (!modePtr->name)
- Usage (argv[0]);
- if (argc - offset < modePtr->argmin)
- Usage (argv[0]);
- if (modePtr->argmax && argc - offset > modePtr->argmax)
- Usage (argv[0]);
-
-
-
- init_dialog ();
- retval = (*(modePtr->jumper)) (title, argc - offset, argv + offset);
-
- if (opt_clear) { /* clear screen before exit */
- attr_clear (stdscr, LINES, COLS, screen_attr);
- refresh ();
- }
- end_dialog();
-
- exit (retval);
+ if (argc < 2) {
+ Usage(argv[0]);
+ exit(-1);
+ }
+
+ while (offset < argc - 1 && !end_common_opts) { /* Common options */
+ if (!strcmp(argv[offset + 1], "--title")) {
+ if (argc - offset < 3 || title != NULL) {
+ Usage(argv[0]);
+ exit(-1);
+ } else {
+ title = argv[offset + 2];
+ offset += 2;
+ }
+ } else if (!strcmp(argv[offset + 1], "--backtitle")) {
+ if (backtitle != NULL) {
+ Usage(argv[0]);
+ exit(-1);
+ } else {
+ backtitle = argv[offset + 2];
+ offset += 2;
+ }
+ } else if (!strcmp(argv[offset + 1], "--clear")) {
+ if (opt_clear) { /* Hey, "--clear" can't appear twice! */
+ Usage(argv[0]);
+ exit(-1);
+ } else if (argc == 2) { /* we only want to clear the screen */
+ init_dialog();
+ refresh(); /* init_dialog() will clear the screen for us */
+ end_dialog();
+ return 0;
+ } else {
+ opt_clear = 1;
+ offset++;
+ }
+ } else /* no more common options */
+ end_common_opts = 1;
+ }
+
+ if (argc - 1 == offset) { /* no more options */
+ Usage(argv[0]);
+ exit(-1);
+ }
+ /* use a table to look for the requested mode, to avoid code duplication */
+
+ for (modePtr = modes; modePtr->name; modePtr++) /* look for the mode */
+ if (!strcmp(argv[offset + 1], modePtr->name))
+ break;
+
+ if (!modePtr->name)
+ Usage(argv[0]);
+ if (argc - offset < modePtr->argmin)
+ Usage(argv[0]);
+ if (modePtr->argmax && argc - offset > modePtr->argmax)
+ Usage(argv[0]);
+
+ init_dialog();
+ retval = (*(modePtr->jumper)) (title, argc - offset, argv + offset);
+
+ if (opt_clear) { /* clear screen before exit */
+ attr_clear(stdscr, LINES, COLS, screen_attr);
+ refresh();
+ }
+ end_dialog();
+
+ exit(retval);
}
/*
* Print program usage
*/
-static void
-Usage (const char *name)
+static void Usage(const char *name)
{
- fprintf (stderr, "\
+ fprintf(stderr, "\
\ndialog, by Savio Lam (lam836@cs.cuhk.hk).\
\n patched by Stuart Herbert (S.Herbert@shef.ac.uk)\
\n modified/gutted for use as a Linux kernel config tool by \
@@ -162,65 +157,56 @@ Usage (const char *name)
\n --inputbox <text> <height> <width> [<init>]\
\n --yesno <text> <height> <width>\
\n", name, name);
- exit (-1);
+ exit(-1);
}
/*
* These are the program jumpers
*/
-int
-j_menu (const char *t, int ac, const char * const * av)
+int j_menu(const char *t, int ac, const char *const *av)
{
- return dialog_menu (t, av[2], atoi (av[3]), atoi (av[4]),
- atoi (av[5]), av[6], (ac - 6) / 2, av + 7);
+ return dialog_menu(t, av[2], atoi(av[3]), atoi(av[4]),
+ atoi(av[5]), av[6], (ac - 6) / 2, av + 7);
}
-int
-j_checklist (const char *t, int ac, const char * const * av)
+int j_checklist(const char *t, int ac, const char *const *av)
{
- return dialog_checklist (t, av[2], atoi (av[3]), atoi (av[4]),
- atoi (av[5]), (ac - 6) / 3, av + 6, FLAG_CHECK);
+ return dialog_checklist(t, av[2], atoi(av[3]), atoi(av[4]),
+ atoi(av[5]), (ac - 6) / 3, av + 6, FLAG_CHECK);
}
-int
-j_radiolist (const char *t, int ac, const char * const * av)
+int j_radiolist(const char *t, int ac, const char *const *av)
{
- return dialog_checklist (t, av[2], atoi (av[3]), atoi (av[4]),
- atoi (av[5]), (ac - 6) / 3, av + 6, FLAG_RADIO);
+ return dialog_checklist(t, av[2], atoi(av[3]), atoi(av[4]),
+ atoi(av[5]), (ac - 6) / 3, av + 6, FLAG_RADIO);
}
-int
-j_textbox (const char *t, int ac, const char * const * av)
+int j_textbox(const char *t, int ac, const char *const *av)
{
- return dialog_textbox (t, av[2], atoi (av[3]), atoi (av[4]));
+ return dialog_textbox(t, av[2], atoi(av[3]), atoi(av[4]));
}
-int
-j_yesno (const char *t, int ac, const char * const * av)
+int j_yesno(const char *t, int ac, const char *const *av)
{
- return dialog_yesno (t, av[2], atoi (av[3]), atoi (av[4]));
+ return dialog_yesno(t, av[2], atoi(av[3]), atoi(av[4]));
}
-int
-j_inputbox (const char *t, int ac, const char * const * av)
+int j_inputbox(const char *t, int ac, const char *const *av)
{
- int ret = dialog_inputbox (t, av[2], atoi (av[3]), atoi (av[4]),
- ac == 6 ? av[5] : (char *) NULL);
- if (ret == 0)
- fprintf(stderr, dialog_input_result);
- return ret;
+ int ret = dialog_inputbox(t, av[2], atoi(av[3]), atoi(av[4]),
+ ac == 6 ? av[5] : (char *)NULL);
+ if (ret == 0)
+ fprintf(stderr, dialog_input_result);
+ return ret;
}
-int
-j_msgbox (const char *t, int ac, const char * const * av)
+int j_msgbox(const char *t, int ac, const char *const *av)
{
- return dialog_msgbox (t, av[2], atoi (av[3]), atoi (av[4]), 1);
+ return dialog_msgbox(t, av[2], atoi(av[3]), atoi(av[4]), 1);
}
-int
-j_infobox (const char *t, int ac, const char * const * av)
+int j_infobox(const char *t, int ac, const char *const *av)
{
- return dialog_msgbox (t, av[2], atoi (av[3]), atoi (av[4]), 0);
+ return dialog_msgbox(t, av[2], atoi(av[3]), atoi(av[4]), 0);
}
-