ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/SHAPES/visualizerCmd.c
(Generate patch)

Comparing trunk/SHAPES/visualizerCmd.c (file contents):
Revision 1315 by chrisfen, Mon Jun 28 23:05:25 2004 UTC vs.
Revision 1361 by gezelter, Tue Jul 20 20:22:43 2004 UTC

# Line 1 | Line 1
1   /*
2    File autogenerated by gengetopt version 2.12.1
3    generated with the following command:
4 <  gengetopt --file-name=visualizerCmd
4 >  gengetopt --file-name=visualizerCmd --unamed-opts=SHAPEFILE [OUTPUTFILE]
5  
6    The developers of gengetopt consider the fixed text that goes in all
7    gengetopt output files to be in the public domain:
# Line 37 | Line 37 | void clear_given (struct gengetopt_args_info *args_inf
37   {
38    args_info->help_given = 0 ;
39    args_info->version_given = 0 ;
40  args_info->shape_given = 0 ;
41  args_info->output_given = 0 ;
40    args_info->grid_given = 0 ;
41    args_info->range_given = 0 ;
42   }
# Line 46 | Line 44 | void clear_args (struct gengetopt_args_info *args_info
44   static
45   void clear_args (struct gengetopt_args_info *args_info)
46   {
49  args_info->shape_arg = NULL;
50  args_info->output_arg = NULL;
47    args_info->grid_arg = 101 ;
48    args_info->range_arg = 10 ;
49   }
# Line 63 | Line 59 | cmdline_parser_print_help (void)
59   {
60    cmdline_parser_print_version ();
61    printf("\n"
62 <  "Usage: %s [OPTIONS]...\n", CMDLINE_PARSER_PACKAGE);
62 >  "Usage: %s [OPTIONS]... [SHAPEFILE [OUTPUTFILE]]...\n", CMDLINE_PARSER_PACKAGE);
63    printf("\n");
64 <  printf("%s\n","  -h, --help             Print help and exit");
65 <  printf("%s\n","  -V, --version          Print version and exit");
66 <  printf("%s\n","  -s, --shape=filename   shape file name");
67 <  printf("%s\n","  -o, --output=filename  output file name");
72 <  printf("%s\n","  -g, --grid=INT         number of grid points in each coordinate  (default=\n                           `101')");
73 <  printf("%s\n","  -r, --range=DOUBLE     the sample range for the points in Angstroms (Ex: 10 =\n                            -10 to 10)  (default=`10')");
64 >  printf("%s\n","  -h, --help          Print help and exit");
65 >  printf("%s\n","  -V, --version       Print version and exit");
66 >  printf("%s\n","  -g, --grid=INT      number of grid points in each coordinate  (default=\n                        `101')");
67 >  printf("%s\n","  -r, --range=DOUBLE  the sample range for the points in Angstroms (Ex: 10 = \n                        -10 to 10)  (default=`10')");
68   }
69  
70   void
# Line 78 | Line 72 | cmdline_parser_init (struct gengetopt_args_info *args_
72   {
73    clear_given (args_info);
74    clear_args (args_info);
75 +
76 +  args_info->inputs = NULL;
77 +  args_info->inputs_num = 0;
78   }
79  
80   void
81   cmdline_parser_free (struct gengetopt_args_info *args_info)
82   {
83    
84 <  if (args_info->shape_arg)
88 <    {
89 <      free (args_info->shape_arg); /* free previous argument */
90 <      args_info->shape_arg = 0;
91 <    }
92 <  if (args_info->output_arg)
93 <    {
94 <      free (args_info->output_arg); /* free previous argument */
95 <      args_info->output_arg = 0;
96 <    }
84 >  int i;
85    
86 +  for (i = 0; i < args_info->inputs_num; ++i)
87 +    free (args_info->inputs [i]);
88 +  
89 +  if (args_info->inputs_num)
90 +    free (args_info->inputs);
91 +  
92    clear_given (args_info);
93   }
94  
# Line 162 | Line 156 | cmdline_parser_internal (int argc, char * const *argv,
156        static struct option long_options[] = {
157          { "help",       0, NULL, 'h' },
158          { "version",    0, NULL, 'V' },
165        { "shape",      1, NULL, 's' },
166        { "output",     1, NULL, 'o' },
159          { "grid",       1, NULL, 'g' },
160          { "range",      1, NULL, 'r' },
161          { NULL, 0, NULL, 0 }
162        };
163  
164        stop_char = 0;
165 <      c = getopt_long (argc, argv, "hVs:o:g:r:", long_options, &option_index);
165 >      c = getopt_long (argc, argv, "hVg:r:", long_options, &option_index);
166  
167        if (c == -1) break;       /* Exit from `while (1)' loop.  */
168  
# Line 184 | Line 176 | cmdline_parser_internal (int argc, char * const *argv,
176            cmdline_parser_print_version ();
177            exit (EXIT_SUCCESS);
178  
187        case 's':       /* shape file name.  */
188          if (local_args_info.shape_given)
189            {
190              fprintf (stderr, "%s: `--shape' (`-s') option given more than once%s\n", CMDLINE_PARSER_PACKAGE, (additional_error ? additional_error : ""));
191              goto failure;
192            }
193          if (args_info->shape_given && ! override)
194            continue;
195          local_args_info.shape_given = 1;
196          args_info->shape_given = 1;
197          if (args_info->shape_arg)
198            free (args_info->shape_arg); /* free previous string */
199          args_info->shape_arg = gengetopt_strdup (optarg);
200          break;
201
202        case 'o':       /* output file name.  */
203          if (local_args_info.output_given)
204            {
205              fprintf (stderr, "%s: `--output' (`-o') option given more than once%s\n", CMDLINE_PARSER_PACKAGE, (additional_error ? additional_error : ""));
206              goto failure;
207            }
208          if (args_info->output_given && ! override)
209            continue;
210          local_args_info.output_given = 1;
211          args_info->output_given = 1;
212          if (args_info->output_arg)
213            free (args_info->output_arg); /* free previous string */
214          args_info->output_arg = gengetopt_strdup (optarg);
215          break;
216
179          case 'g':       /* number of grid points in each coordinate.  */
180            if (local_args_info.grid_given)
181              {
# Line 257 | Line 219 | cmdline_parser_internal (int argc, char * const *argv,
219  
220    if (check_required)
221      {
260      if (! args_info->shape_given)
261        {
262          fprintf (stderr, "%s: '--shape' ('-s') option required%s\n", CMDLINE_PARSER_PACKAGE, (additional_error ? additional_error : ""));
263          error = 1;
264        }
265      if (! args_info->output_given)
266        {
267          fprintf (stderr, "%s: '--output' ('-o') option required%s\n", CMDLINE_PARSER_PACKAGE, (additional_error ? additional_error : ""));
268          error = 1;
269        }
222      }
223  
224    if ( error )
225      return (EXIT_FAILURE);
226  
227 +  if (optind < argc)
228 +    {
229 +      int i = 0 ;
230 +  
231 +      args_info->inputs_num = argc - optind ;
232 +      args_info->inputs =
233 +        (char **)(malloc ((args_info->inputs_num)*sizeof(char *))) ;
234 +      while (optind < argc)
235 +        args_info->inputs[ i++ ] = gengetopt_strdup (argv[optind++]) ;
236 +    }
237 +  
238    return 0;
239  
240   failure:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines