httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Sutton <p...@ukweb.com>
Subject OS abstraction
Date Wed, 13 Aug 1997 22:01:22 GMT
Now the re-org's done we can actually start on an OS abstraction. This is
something that has been waiting in the wings for some time now.  I have a
lot of information ready for what needs abstracting. I've gone through the
entire source looking for #ifdef __EMX__ or #ifdef WIN32 and identified
all the OS-specific aspects of the Apache code.

But I don't just want to come up with a huge and unmanageable diff, so
here is a simple example. Of course you could think it is too close the
the 1.3 beta release to worry about these sorts of changes now, so if that
is I won't spend any more time on it for now.

Here is an example: symbolic links only exist on Unix and not on EMX or
Win32. There is a function in http_request.c called check_symlinks which
returns OK on those two OSes, and does real work on Unix. It is defined
like this:

int check_symlinks(...)
{
#if defined(__EMX__) || defined(WIN32)
  return OK
#else
  ...
  lots of stuff
  ...
#endif
}

As an abstraction we could define a constant (say HAVE_SYMLINKS) for OSes
with symlinks, and use that constant to determine what part of the code
gets compiled. The use of a constant will make it easier to identify why
parts of code are excluded because of missing features. Although this is a
simple case with just one conditional compilation other missing features
cause whole bunches of #ifdef's throughout the code which are difficult to
manage. 

So now we have a simple: 

#ifdef HAVE_SYMLINKS
  int check_symlinks(...)
  {
    ...
  }
#else
  #define check_symlinks(...) (OK)
#endif

What I think I'll do is post a list of all the things which could be
extracted (like symlinks, checks for absolute pathnames, dir section
conversions, opening files in binary mode, etc). Some are a bit more
complex than this, and Dean has suggested we use inlineable functions
rather than complex and possibly side-effect causing macros. 

//pcs




Mime
View raw message