From: "Mariano Moreyra" <moremari@aca.org.ar>
To: 'Matthew Harrison' <matth@3d-computers.co.uk>,
linux-c-programming@vger.kernel.org
Subject: RE: named structure members
Date: Fri, 12 Sep 2003 10:22:40 -0300 [thread overview]
Message-ID: <000001c37930$f1fd3440$0b04a8c0@aca.org.ar> (raw)
In-Reply-To: <20030911171312.GB15184@3d-computers.co.uk>
Hi Matthew,
First of all, I couldn't install the Inventory. I don't know why the
configure script throws me an error.
But looking at the sources:
- Like I said yesterday, if you define db_host as a "char *db_host "
instead of
"char db_host[NN]" you have to alloc some memory to that string before
the strcpy
But you told me that you had it defined like "char db_host[NN]" and already
had that segfault...am I right??
-----Mensaje original-----
De: linux-c-programming-owner@vger.kernel.org
[mailto:linux-c-programming-owner@vger.kernel.org]En nombre de Matthew
Harrison
Enviado el: Jueves, 11 de Septiembre de 2003 14:13
Para: linux-c-programming@vger.kernel.org
Asunto: Re: named structure members
i am going thru all these suggestions at a slow rate, but it's time
to finish work now so I won't be able to reply from home.
please don't think i'm ignoring you, i am very grateful.
On Thu, Sep 11, 2003 at 06:52:13PM +0200, Jan-Benedict Glaw wrote:
> On Thu, 2003-09-11 16:50:05 +0100, Glynn Clements
<glynn.clements@virgin.net>
> wrote in message <16224.39341.204427.234601@cerise.nosuchdomain.co.uk>:
> > Matthew Harrison wrote:
> > > here is the struct that i want my config to go into:
> > There are a number of ways which you could improve upon this, but
> > there isn't anything along the lines of:
> >
> > config.<something involving "keyword"> = value;
> >
> > Structure fields have to be specified explicitly; you can't "index" a
> > structure in the manner of an associative array.
> >
> > One possible solution is:
> >
> > enum cfg_option {
> > cfg_db_host,
> > cfg_db_name,
> > cfg_db_pass,
> > cfg_db_user,
> > CFG_COUNT
> > };
> [...]
> Another approach is to use a union (containing any possible things, in
> your case only char pointers) inside a struct (which also contains a
> char name[] and an int type). Build up an array with these structs, one
> for each config option.
>
> Then have a function which gets on option name as well as an option
> value which searches throuch all ->name's of your array and assigns the
> (properly converted) value to the proper union type.
>
> To access these options, use multiple access functions (ie.
>
> int get_int(char *option)
>
> ) which also searches through the array and returns the int part of the
> union.
>
> MfG, JBG
>
> --
> Jan-Benedict Glaw jbglaw@lug-owl.de . +49-172-7608481
> "Eine Freie Meinung in einem Freien Kopf | Gegen Zensur | Gegen
Krieg
> fuer einen Freien Staat voll Freier Bürger" | im Internet! | im
Irak!
> ret = do_actions((curr | FREE_SPEECH) & ~(IRAQ_WAR_2 | DRM | TCPA));
--
Mat Harrison
Technical Developer
3d Computer Systems Ltd.
matth@3d-computers.co.uk
-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2003-09-12 13:22 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-09-11 11:07 named structure members Matthew Harrison
2003-09-11 11:50 ` Jeff Woods
2003-09-11 14:03 ` Mariano Moreyra
2003-09-11 14:26 ` Matthew Harrison
2003-09-11 14:41 ` Mariano Moreyra
2003-09-11 15:28 ` Matthew Harrison
2003-09-11 15:35 ` Mariano Moreyra
2003-09-11 15:42 ` Matthew Harrison
2003-09-11 15:50 ` Glynn Clements
2003-09-11 16:52 ` Jan-Benedict Glaw
2003-09-11 17:13 ` Matthew Harrison
2003-09-12 13:22 ` Mariano Moreyra [this message]
2003-09-12 13:47 ` Matthew Harrison
2003-09-12 13:52 ` Mariano Moreyra
2003-09-12 14:33 ` Matthew Harrison
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='000001c37930$f1fd3440$0b04a8c0@aca.org.ar' \
--to=moremari@aca.org.ar \
--cc=linux-c-programming@vger.kernel.org \
--cc=mariano_moreyra@aca.org.ar \
--cc=matth@3d-computers.co.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).