From: Matthew Harrison <matth@3d-computers.co.uk>
To: Mariano Moreyra <moremari@aca.org.ar>
Cc: linux-c-programming@vger.kernel.org
Subject: Re: named structure members
Date: Fri, 12 Sep 2003 15:33:41 +0100 [thread overview]
Message-ID: <20030912143341.GB5893@3d-computers.co.uk> (raw)
In-Reply-To: <000701c37935$2ab5f020$0b04a8c0@aca.org.ar>
[-- Attachment #1.1: Type: text/plain, Size: 4620 bytes --]
my mistake, i'm always doing that.
lets try this one :)
On Fri, Sep 12, 2003 at 10:52:54AM -0300, Mariano Moreyra wrote:
> It seems like there is no attached version :)
>
>
> -----Mensaje original-----
> De: Matthew Harrison [mailto:matth@3d-computers.co.uk]
> Enviado el: Viernes, 12 de Septiembre de 2003 10:47
> Para: Mariano Moreyra
> CC: linux-c-programming@vger.kernel.org
> Asunto: Re: named structure members
>
>
> well it's all changed a bit now. i have been learning how to use gdb
> and as a result have managed to replace the strcpy's and other bit that
> cause segfaults. The app now runs cleanly but i am running into trouble
> with my config-file-reading function. it was not my function, i copied
> it off the web so i might just write myself a quick one.
>
> attached is a version that should not segfault and only stops working
> because the configfile isn't read properly.
>
> what part if the configure script did you have trouble with.
>
> thanks
>
> On Fri, Sep 12, 2003 at 10:22:40AM -0300, Mariano Moreyra wrote:
> > 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
>
> --
> Mat Harrison
> Technical Developer
> 3d Computer Systems Ltd.
> matth@3d-computers.co.uk
--
Mat Harrison
Technical Developer
3d Computer Systems Ltd.
matth@3d-computers.co.uk
[-- Attachment #1.2: inventory-0.1.tar.gz --]
[-- Type: application/x-tar-gz, Size: 52766 bytes --]
[-- Attachment #2: Type: application/pgp-signature, Size: 187 bytes --]
prev parent reply other threads:[~2003-09-12 14:33 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
2003-09-12 13:47 ` Matthew Harrison
2003-09-12 13:52 ` Mariano Moreyra
2003-09-12 14:33 ` Matthew Harrison [this message]
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=20030912143341.GB5893@3d-computers.co.uk \
--to=matth@3d-computers.co.uk \
--cc=linux-c-programming@vger.kernel.org \
--cc=moremari@aca.org.ar \
/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).