Dovecots header files not optimized for external plugins

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Dovecots header files not optimized for external plugins

Jan Engelhardt

Making third-party plugins for Dovecot is really hard and frustrating.
Using dovecot 2.2.33.2 and the following sources, the compile errors keep
coming. The use of g++ is mandated as the underlying backend this plugin
will access only has a C++ interface.


== Source 1
/* g++-7 -c a.cpp */
#include <byteswap.h>
#include <dovecot/lib.h>
#include <dovecot/auth-request.h>
#include <dovecot/passdb.h>
static enum passdb_result
authdb_mapi_logon(struct auth_request *rq, const char *password)
{
        int x = dev_null_fd + bswap_16(1);
}

== Problems 1
/usr/include/dovecot/compat.h:45:4: error: #error uoff_t size not set
 #  error uoff_t size not set

== Source 2
/* g++-7 -DHAVE_CONFIG_H -c a.cpp */
#include "config.h" /* generated by my configure */
#include <byteswap.h>
#include <dovecot/lib.h>
#include <dovecot/auth-request.h>
#include <dovecot/passdb.h>
static enum passdb_result
authdb_mapi_logon(struct auth_request *rq, const char *password)
{
        int x = dev_null_fd + bswap_16(1);
}

== Problems 2
In file included from /usr/include/bits/byteswap.h:35:0,
                 from /usr/include/byteswap.h:24,
                 from a.cpp:2:
/usr/include/dovecot/byteorder.h:32:24: error: expected unqualified-id before ‘__extension__’
 static inline uint16_t bswap_16(uint16_t in);

== Other problems
dovecot headers files are missing 'extern "C"' lines.
This means the linkage of symbols like dev_null_fd is not what it should be.
I can't use
 extern "C" {
 #include <dovecot/...>
 }
either because then the standardy library headers that are included
by dovecot headers can easily start acting up too.
Reply | Threaded
Open this post in threaded view
|

Re: Dovecots header files not optimized for external plugins

Timo Sirainen
On 19 Nov 2017, at 0.40, Jan Engelhardt <[hidden email]> wrote:
>
>
> Making third-party plugins for Dovecot is really hard and frustrating.
> Using dovecot 2.2.33.2 and the following sources, the compile errors keep
> coming. The use of g++ is mandated as the underlying backend this plugin
> will access only has a C++ interface.

See compile instructions for example here: https://dovecot.org/patches/2.2/imap-logout-plugin.c <https://dovecot.org/patches/2.2/imap-logout-plugin.c>

> == Problems 2
> In file included from /usr/include/bits/byteswap.h:35:0,
>                 from /usr/include/byteswap.h:24,
>                 from a.cpp:2:
> /usr/include/dovecot/byteorder.h:32:24: error: expected unqualified-id before ‘__extension__’
> static inline uint16_t bswap_16(uint16_t in);

Try #undef bswap_16 (and others)? We have a patch pending that does these #undefs to fix compiling issue with uclibc-ng - maybe a similar problem.

> == Other problems
> dovecot headers files are missing 'extern "C"' lines.
> This means the linkage of symbols like dev_null_fd is not what it should be.
> I can't use
> extern "C" {
> #include <dovecot/...>
> }
> either because then the standardy library headers that are included
> by dovecot headers can easily start acting up too.


lucene-wrapper.cc seems to compile fine with this..
Reply | Threaded
Open this post in threaded view
|

Re: Dovecots header files not optimized for external plugins

Jan Engelhardt

On Sunday 2017-11-19 14:19, Timo Sirainen wrote:
>
>See compile instructions for example here: https://dovecot.org/patches/2.2/imap-logout-plugin.c

Mh, that -config script should really have been a pkgconfig .pc file.
(I see it's not really a script, which is probably the reason it is not in
/usr/bin.)

>      == Problems 2
>      In file included from /usr/include/bits/byteswap.h:35:0,
>                      from /usr/include/byteswap.h:24,
>                      from a.cpp:2:
>      /usr/include/dovecot/byteorder.h:32:24: error: expected unqualified-id before
>      ‘__extension__’
>      static inline uint16_t bswap_16(uint16_t in);
>
>
>Try #undef bswap_16 (and others)? We have a patch pending that does these #undefs to fix
>compiling issue with uclibc-ng - maybe a similar problem.

That is inside out. Why mess with libc? Why reimplement byteswapping functions
at all? Why not at least prefix them e.g. dove_bswap to avoid nameclashes?