List for cgit developers and users
 help / color / mirror / Atom feed
From: Jason at zx2c4.com (Jason A. Donenfeld)
Subject: Adding Filter Types to cgit [was: RFE: .so filters]
Date: Sun, 12 Jan 2014 23:26:59 +0100	[thread overview]
Message-ID: <CAHmME9pjRcEEjxt1c8MOLzvhezrqGJWDAU84jf0_6mCbOVx4VQ@mail.gmail.com> (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


             reply	other threads:[~2014-01-12 22:26 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-12 22:26 Jason [this message]
2014-01-13  0:12 ` Jason
2014-01-13  1:14   ` Jason
2014-01-13  2:51     ` Jason
2014-01-13  3:53       ` Jason

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAHmME9pjRcEEjxt1c8MOLzvhezrqGJWDAU84jf0_6mCbOVx4VQ@mail.gmail.com \
    --to=cgit@lists.zx2c4.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).