[PATCH 1/3] cli: add insert --must-index option

Tomi Ollila tomi.ollila at iki.fi
Wed Oct 23 12:05:26 PDT 2013


On Thu, Oct 10 2013, David Bremner <david at tethera.net> wrote:

> Tomi Ollila <tomi.ollila at iki.fi> writes:
>>> I'm not opposed to doing an SONAME bump for 0.17. Are there other ABI
>>> breaking changes that we have been holding back on? Can these maybe go
>>> through at the same time?
>>
>> Maybe something along these lines...
>>
>> (Quick draft for the API part; to start discussion before working too much
>> for something that is going to be dropped...)
>>
>>  notmuch_status_t
>> -notmuch_database_create (const char *path, notmuch_database_t **database);
>> +notmuch_database_create (const char *path,
>> +			 notmuch_loghook_t *loghook,
>> +			 notmuch_database_t **database);
>
> Another idea floated (by Austin?) was to pass in an options struct, to
> allow future options to be added without changing the function
> signature. I guess with some care this could be done in an upwardly
> compatible way.

Maybe something like

#define NOTMUCH_API_OPTIONS_VERSION 1
typedef struct {
        int options_version;
        void (*log)(void *, int level, int status, const char * format, ...);
        void * logdata;
} notmuch_options_t;        

...

notmuch_status_t
notmuch_database_create (const char *path,
			 notmuch_options_t *options,
			 notmuch_database_t **database);
...

notmuch_status_t
notmuch_database_open (const char *path,
                       notmuch_database_mode_t mode,
                       notmuch_options_t *options,
                       notmuch_database_t **database);

then in use:

notmuch_options_t options = {
       .options_version = NOTMUCH_API_OPTIONS_VERSION,

.. äsh, this has problem that the macro changes in header file
but the structure initialization is not following automatically
(in other fields than that). Therefore perhaps "fixing"
the version macros:

#define NOTMUCH_API_OPTIONS_VERSION_1 1
/* #define NOTMUCH_API_OPTIONS_VERSION_2 2 // added in the future */

notmuch_options_t options = {
       .options_version = NOTMUCH_API_OPTIONS_VERSION_1,
       .log = log_to_stderr,
       .logdata = NULL
};

Well, this is one idea (does not sound as good as I initially
thought...) how does other software tackle this kind of issues...

If something like this is finally chosen we could provide easy
transition path to allow NULL as options -- making notmuch CLI
behave as it used to be (log to stderr...).


> d

Tomi


More information about the notmuch mailing list