typedef struct xlg_filter_struct {
    ...
    const char *name, *desc;
    int (*proc)(XLG_pic *, XLG_pic **, int, char **);
    int (*proc_gs)(XLG_pic *, XLG_pic **, int, char **);
    int show;
} XLG_filter;

Base definition. .proc is a pointer to the function that does the actual filtering. That function must allocate the new picture itself and store it in the second pointer. .proc_gs can point to a specially-tuned function for grayscale operation, otherwise NULL to indicate that .proc is to be used for any color model.

.show specifies whether this filter should be listed in a user-visible list. (See the run utility's -L option.)


int xlg_flt_register(XLG_filter *);
int xlg_flt_unregister(XLG_filter *);

(Un)registers a filter within the internal database. This is really only needed by base/filter.c itself.

Adding a new filter to libxlg (that is, libxlg itself, not your application) requires its manual registration in the source file(s).

A filter does not need to be registered to be used.


int xlg_flt_list(XLG_filter ***p);

xlg_flt_list() returns a list of available filters. The list is allocated with malloc() and is stored in *p (so you have to free(*p), only). The number of available filters is returned. If there are no filters currently registered, nothing is allocated and 0 is returned. Also, nothing is done upon error, in which case -errno is returned.

Applications may NOT rely on .Next, since this is only an internal field for the xlg_flt code.


XLG_filter *xlg_flt_get(const char *name);

Returns the XLG_filter structure for a given filter. Returns NULL if no such filter was found in the list.