C programming help required ....

Ben Duncan bns
Fri Aug 26 11:31:01 PDT 2005


It would be something they entered one time while setting up the file.
Probably will be done thru some sort of Data Entry routine so I can control
it.

After that , the values will be held internally and the user cannot change them.
This is because any "fix" or "rebuild" routines as well as any record routines
will need access to them to modify the secondary index file.

LOL, I am working form the inside out on this database. So far I have gotten
test routines that can create multi-value records. This is to/from a flat file
for testing purposes. Once I complete and test the ability to add/insert/modify/extract
the multi value attributes , and the necessary re-size of said attributes, It is off
to seeing about fitting this to the GDBM datamanager.

After that comes the multi user extensions, and secondary key additions.

I am now wondering how people can do such FOSS projects and still find the time to
earn a living ;-> .......

Roger Oberholtzer wrote:
> On Fri, 2005-08-26 at 14:59, Ben Duncan wrote:
> 
<SNIP>
> 
> The easiest way to do this is to consider the values to be hex, not
> decimal. Otherwise you will be stuck doing arithmetic! Whenever you do
> this sort of bit fiddling, this will make your life easiest. Is this a
> number a person would enter? Or is it internal? There are really many
> ways to do this, but they follow the same basic method. 
> 
> /* Do these defines once in some include file */
> 
> #define ATTRIBUTE_MASK		0x00FFF000
> #define MVN_MASK		0x00000FFF
> 
> #define	GET_ATTRIBUTE(x)		(((x) & ATTRIBUTE_MASK) >> 3)
> #define GET_MULTI_VALUE_NUMBER(x)	((x) & MVN_MASK)
> 
> /* Here is the code that uses this: */
> 
> int sample_value = 0x7001;	/* The 0x IS REQUIRED */
> 
> printf("value %x has attribute %d and mvn %d\n",
> 	value,
> 	GET_ATTRIBUTE(value),
> 	GET_MULTI_VALUE_NUMBER(value));
> 
> This can be made better - depending on your real use. If someone will be
> entering this value in some menu, let them enter 7001, but make your
> program read it as hex (scanf(%x)). The user need not know this is how
> you use it.
> 
> The GET_xxx macros should have equivalent SET_xxx macros. But those can
> have macro expansion side effects. So I would do them as inline
> functions. Still fast - but no nasty side-effects.
> 
> Is this the sort of thing you mean?
> 
> 
-- 
Ben Duncan   - VersAccounting Software LLC 336 Elton Road  Jackson MS, 39212
"Never attribute to malice, that which can be adequately explained by stupidity"
        - Hanlon's Razor



More information about the Linux-users mailing list