• Simple URL scheme handler library

    From Andrew T.@and4y2@turnquist.name.invalid to comp.infosystems.gemini on Sat Mar 21 21:06:53 2026
    From Newsgroup: comp.infosystems.gemini

    I've been playing with gemini for a while now (a year or two?). In
    some of my spare time I've been working on a C/ncurses based browser
    (using gmi100 as a starting point), which I hope to release in some
    form soon.

    While working on that, I ran into a bit of a problem. Often a capsule
    will have links to non-gemini pages (gopher, https, etc.) and I didn't
    know what to do with them.

    So I wrote a very small library to look up handlers in a file,
    /etc/schemecap, similar to the MIME /etc/mailcap file. Now, if my
    gemini client finds a non-gemini URL, it can find what to hand it off
    to.

    I've since found that xdg-open does something similar, but is
    restricted to use in a desktop environment and not terminals/consoles,
    so it might not be ideal for an ncurses client that might be running
    without X or Wayland.

    Anyway, the info/download page is at: https://www.turnquist.name/software/libschemecap/

    It includes man pages for the functions and the /etc/schemecap format.
    There's one main function, scheme_handler() to look up the handler for
    a given scheme or URL. It also takes an arguement for the type of
    handler (graphic, text, or cli).

    You can either "./configure && make && make install" and use the shared library, or just copy schemecap.[ch] into your own project directory.

    It should be easy (trivial?) to port to other languages.

    I've released this under the MIT license in hopes of wider adoption.

    Feedback, suggestions, bug reports and patches are all welcome.

    I should probably post this on c.i.gopher and somewhere else as
    well...

    Cheers,
    --Andrew
    --
    Andrew Turnquist, Glorious Downtown Short Tract, New York, USA
    ... wandering the streets of Usenet ...
    (Remove numbers and .invalid for email address)
    "Do what you can with what you have where you are." -T Roosevelt
    --- Synchronet 3.21f-Linux NewsLink 1.2
  • From gmc@gmc@metro.cx (Koen Martens) to comp.infosystems.gemini on Sat May 9 17:11:15 2026
    From Newsgroup: comp.infosystems.gemini

    Andrew T. <and4y2@turnquist.name.invalid> wrote:
    I've been playing with gemini for a while now (a year or two?). In
    some of my spare time I've been working on a C/ncurses based browser
    (using gmi100 as a starting point), which I hope to release in some
    form soon.

    Cool, looking forward to that! I've found that I want to do less GUI
    and go back to good old console for more and more.

    So I wrote a very small library to look up handlers in a file, /etc/schemecap, similar to the MIME /etc/mailcap file. Now, if my
    gemini client finds a non-gemini URL, it can find what to hand it off
    to.

    I've since found that xdg-open does something similar, but is
    restricted to use in a desktop environment and not terminals/consoles,
    so it might not be ideal for an ncurses client that might be running
    without X or Wayland.

    ...

    I've released this under the MIT license in hopes of wider adoption.

    I was trying to remember what we had back in the day for this, and it
    probably was mailcap. I just checked the one on my laptop, and it's
    all `xdg-open` as you say, so indeed not very useful for terminal
    applications.

    Cheers,

    Koen
    --
    Software architecture & engineering: https://www.sonologic.se/
    Sci-fi: https://www.koenmartens.nl/
    Retrocomputing videos: https://retroscandinavian.eu/

    --- Synchronet 3.22a-Linux NewsLink 1.2