apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Greg Stein <gst...@lyra.org>
Subject Re: cvs commit: apr-util/dbm/sdbm sdbm.c
Date Sat, 20 Jan 2001 22:40:44 GMT
On Sat, Jan 20, 2001 at 04:23:24PM -0600, William A. Rowe, Jr. wrote:
> If we want to be notified, I'd suggest the high bit of the wanted arg
> is passed as APR_FINFO_FAIL.  When we -must- have a user, we can do
> this instead;
>    if (((status = apr_getfileinfo(&finfo, APR_FINFO_USER | APR_FINFO_FAIL,
>                                   db->dirf)) != APR_SUCCESS))
> Pretty gosh darned straightforward.  But so is the current;
>    if (((status = apr_getfileinfo(&finfo, APR_FINFO_USER, db->dirf))
>           != APR_SUCCESS) || !(finfo.valid & APR_FINFO_USER))
> Thoughts, folks?

Reverse the logic.

In most cases, the caller wants exactly what was asked for. *If* the caller
can deal with some items left out, then they can declare that.

Thus, you have:

    if ((status = apr_getfileinfo(&finfo, APR_FINFO_USER, db->dirf))
           == APR_SUCCESS)
	   /* we know we have the info */


    if ((status = apr_getfileinfo(&finfo, APR_FINFO_USER | APR_FINFO_FLEXIBLE,
                                  db->dirf)) == APR_SUCCESS)
	   /* we have some/all of the info. look at finfo.valid */

When _FLEXIBLE is passed, apr_getfileinfo() will almost never fail. It would
need to be pretty drastic :-)

In the above scheme, all of the conversions that you did will operate just
like they used to. For code that can be flexible with the values, they have
that chance.

[ but most code can't be flexible ]


Greg Stein, http://www.lyra.org/

View raw message