gpgme 0.4.2 setting errno to EOPNOTSUPP

Ralf Doering rdoering@netsys-it.de
Tue Aug 12 22:21:02 2003


Hello,

(if this mail occurs twice: shame on me, the first went straight to the 
list-admin, because I posted with a nonsubcribed sender address)

after porting gpgme 0.3.15 to MinGW to produce a DLL for an internal
project some time ago, I started porting 0.4.2 to actual MinGW versions.
After fiddling with autogen.sh  there were only minor changes necessary
to compile a static lib. I will post a patch in the next few days to
this list, after verifying that everything works as aspected.

One problem still exists. gpgme_data_[read|write|seek] in data.c tries
to set errno to EOPNOTSUPP. This, however is not supported by MingW,
it just does not define this code.
To let the package compile I defined EOPNOTSUPP to be an otherwise
unused errno value, but this can only be an hack. So, I see two options:
change MinGW to include EOPNOTSUPP officialy or to change gpgme to
return an other code.

To illustrate, lets include a code snippet, taken from data.c:

ssize_t
gpgme_data_write (GpgmeData dh, const void *buffer, size_t size)
{
    if (!dh)
      {
        errno = EINVAL;
        return -1;
      }
    if (!dh->cbs->write)
      {
        errno = EOPNOTSUPP;
        return -1;
      }
    return (*dh->cbs->write) (dh, buffer, size);
}


As long as I unterstand errno values, this *could* be changed to use
"more standard values" (meaning: other values, which are supported even
by MinGW;) in one of these ways:
- if dh is NULL, set errno to EBADF, if !dh->cbs->write, set it to
    EINVAL
- just set errno to ENOSYS instead of  EOPNOTSUPP
- set errno to a Windows-specific error code, like WSAEOPNOTSUPP or
ERROR_NOT_SUPPORTED, but these may or do conflict with errno values.

I'm hoping for some advice how to handle this.

TIA,
Ralf

-- 
Ralf Döring
NetSys.IT GbR
www.netsys-it.de