~ubuntu-branches/ubuntu/oneiric/preload/oneiric

« back to all changes in this revision

Viewing changes to src/cmdline.c

  • Committer: Bazaar Package Importer
  • Author(s): Kari Pahula
  • Date: 2007-03-20 19:22:06 UTC
  • mfrom: (3.1.3 edgy)
  • Revision ID: james.westby@ubuntu.com-20070320192206-fskqzfwmzyb3fo8t
Tags: 0.4-4
Close the file descriptor when writing state to a file in src/state.c,
preload_state_save() (Closes: #415595)

Show diffs side-by-side

added added

removed removed

Lines of Context:
43
43
  {"debug", 0, 0, 'd'},
44
44
  {NULL, 0, 0, 0},
45
45
};
 
46
 
 
47
static const char *help2man_str = "Display command line parameters and their default values, and exit.";        /* help2man */
46
48
static const char const *opts_help[] = {
47
49
  "Display this information and exit.", /* help */
48
50
  "Display version information and exit.",      /* version */
69
71
 
70
72
 
71
73
static void version_func (void) G_GNUC_NORETURN;
72
 
static void help_func (gboolean err) G_GNUC_NORETURN;
 
74
static void help_func (gboolean err, gboolean help2man) G_GNUC_NORETURN;
73
75
 
74
76
 
75
77
void
78
80
  for (;;)
79
81
    {
80
82
      int i;
81
 
      i = getopt_long (*argc, *argv, "hvc:s:l:fn:V:d", opts, NULL);
 
83
      i = getopt_long (*argc, *argv, "hHvc:s:l:fn:V:d", opts, NULL);
82
84
      if (i == -1)
83
85
        {
84
86
          break;
110
112
          break;
111
113
        case 'v':
112
114
          version_func ();
 
115
        case 'H':
113
116
        case 'h':
114
117
        default:
115
 
          help_func (i != 'h');
 
118
          help_func (i != 'h' && i != 'H', i == 'H');
116
119
        }
117
120
    }
118
121
 
137
140
 
138
141
 
139
142
static void
140
 
help_func (gboolean err)
 
143
help_func (gboolean err, gboolean help2man)
141
144
{
142
145
  FILE *f = err ? stderr : stdout;
143
146
  const struct option *opt;
160
163
       opt->name; opt++, hlp++, dft++)
161
164
    {
162
165
      fprintf (f, "  -%c, --%-*s  %s\n",
163
 
               opt->val, max, opt->name, *hlp);
164
 
      if (*dft)
 
166
               opt->val, max, opt->name,
 
167
               opt->val == 'h' && help2man ? help2man_str : *hlp);
 
168
      if (*dft && !help2man)
165
169
        fprintf (f, "          %*s(default is %s)\n", max, "", *dft);
166
170
    }
167
171