List for cgit developers and users
 help / color / mirror / Atom feed
* Adding Filter Types to cgit [was: RFE: .so filters]
@ 2014-01-12 22:26 Jason
  2014-01-13  0:12 ` Jason
  0 siblings, 1 reply; 5+ messages in thread
From: Jason @ 2014-01-12 22:26 UTC (permalink / raw)


On Fri, Jan 10, 2014 at 6:20 PM, John Keeping <john at keeping.me.uk> wrote:
> I would have no problem including LuaJIT for this sort of thing.
> I might have a look at the Lua case over the weekend if no one beats me
> to it.

John, Florian --

The infrastructure should be just about complete now, if either of you
want to have a stab at adding Lua (or any other type) of plugin.

The steps are basically as follows:

1) Add documentation in the FILTER API section of cgitrc.5.txt
2) Add a prefix and a new_${type}_filter function in filter_specs in filter.c
3) Add a struct to filter.c called ${type}_filter whose first member
is "struct cgit_filter base".
4) Implement open_${type}_filter(), close_${type}_filter(), and
fprintf_${type}_filter(), and optionally cleanup_${type}_filter(), and
optionally call hook_write() and unhook_write(), depending on needs,
in filter.c.

The basic design of a long-lived filter, that needs to do things over
the course of several opens and closes should be:

1) In new_${type}_filter, make any allocations and setup of the
initial struct, but nothing too heavy weight, in case the filter is
never actually used on that cgit.cgi invocation.
2) In open_${type}_filter, construct any long lived processes or
allocations, if they have not already been done so. Call hook_write()
to a write_${type}_filter function. Then pass on a "filter_open(argv)"
event to the underlying filter engine.
3) In write_${type}_filter, pass on the written buffer and the length
to the underlying filter engine in a "filter_write(data, len)" event.
4) In close_${type}_filter, pass on a "filter_close()" event to the
underlying filter engine. Then call unhook_write().
5) In cleanup_${type}_filter(), deallocate and deconstruct whatever
was initialized on the first invocation to open_${type}_filter, and on
the initial construction of the object in new_${type}_filter.
6) In fprintf_${type}_filter(), reconstruct whatever deconstructed
information might have been originally taken from the configuration
line.


How does this general setup sound?

Jason


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-01-13  3:53 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-01-12 22:26 Adding Filter Types to cgit [was: RFE: .so filters] Jason
2014-01-13  0:12 ` Jason
2014-01-13  1:14   ` Jason
2014-01-13  2:51     ` Jason
2014-01-13  3:53       ` Jason

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).