[GRASS-dev] possible etc file finder function

Glynn Clements glynn at gclements.plus.com
Tue Apr 3 12:24:16 EDT 2007


William Kyngesburye wrote:

> >> Any comments on the C itself?  I wasn't sure about memory allocation
> >> stuff, I'm not good with that.
> >
> > The main issue I see is that sprintf() doesn't return a pointer to the
> > buffer, so you can't you it as an argument to access().
> 
> How would this be done, then?

	sprintf(path, "%s/%s/%s", G_home(), ETC_PATH_USER, name);
	if (access(path,0) == 0)
		...

> > Also, what is "if (ETC_PATH_USER)" etc supposed to be testing?
> >
> Testing whether it is not empty.  I tried to use an example from  
> elsewhere, but maybe the difference between a variable and a define  
> makes this not usable?

If you want to test whether a macro is defined, you need to use
"#ifdef ..." or "#if defined(...)".

-- 
Glynn Clements <glynn at gclements.plus.com>




More information about the grass-dev mailing list