help-gengetopt
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [help-gengetopt] restricting an array to 3 args


From: Lorenzo Bettini
Subject: Re: [help-gengetopt] restricting an array to 3 args
Date: Sun, 26 Mar 2006 21:47:07 +0200
User-agent: Mail/News 1.5 (X11/20060228)

BuildSmart wrote:
I wish to first thank the authors of gengetopt for such a lovely peice of work as it has saved me countless hours of programming.

I'm trying to set the default values for an int array and to establish that it requires 3 args.

I've gone over the manual and I'm unable to find a solution to enter in the '.ggo' file which leaves me to do some manual editing.


I assigned the following in ggo file:
_______________________________

option "font_color_selected" - "RColor[0] of selected font text" int default="51" no multiple
_______________________________


then I edited the cmdline1.c file and changed the following:
_______________________________

  else /* set the default value */
    {
if (! args_info->font_color_selected_arg && ! args_info->font_color_selected_given)
        {
args_info->font_color_selected_arg = (int *) malloc (sizeof (int));
          args_info->font_color_selected_arg [0] = 51;
args_info->font_color_selected_orig = (char **) malloc (sizeof (char *));
          args_info->font_color_selected_orig [0] = NULL;
        }
    }
_______________________________


to:
_______________________________

  else /* set the default value */
    {
if (! args_info->font_color_selected_arg && ! args_info->font_color_selected_given)
        {
args_info->font_color_selected_arg = (int *) malloc (sizeof (int));
          args_info->font_color_selected_arg [0] = 51;
          args_info->font_color_selected_arg [1] = 51;
          args_info->font_color_selected_arg [2] = 51;
args_info->font_color_selected_orig = (char **) malloc (sizeof (char *));
          args_info->font_color_selected_orig [0] = NULL;
          args_info->font_color_selected_orig [1] = NULL;
          args_info->font_color_selected_orig [2] = NULL;
        }
    }
_______________________________



The issue now is ensuring that 3 values are passed from the command line or config file and if the value is < or > 3 complain about it.

Hi

I've put up a release candidate that implements this feature (please take a look at the documentation):

here's the temporary link

http://rap.dsi.unifi.it/~bettini/gengetopt-2.17rc.tar.gz

hope to hear from you soon
cheers
    Lorenzo

--
+-----------------------------------------------------+
|  Lorenzo Bettini          ICQ# lbetto, 16080134     |
|  PhD in Computer Science                            |
|  Dip. Sistemi e Informatica, Univ. di Firenze       |
|  Florence - Italy        (GNU/Linux User # 158233)  |
|  Home Page        : http://www.lorenzobettini.it    |
|  http://music.dsi.unifi.it         XKlaim language  |
|  http://www.purplesucker.com Deep Purple Cover Band |
|  http://www.gnu.org/software/src-highlite           |
|  http://www.gnu.org/software/gengetopt              |
|  http://www.lorenzobettini.it/software/gengen       |
|  http://www.lorenzobettini.it/software/doublecpp    |
+-----------------------------------------------------+




reply via email to

[Prev in Thread] Current Thread [Next in Thread]