ONLamp.com    
 Published on ONLamp.com (http://www.onlamp.com/)
 See this if you're having trouble printing code examples


Big Scary Daemons

The Back Road to Browser Plug-Ins

12/13/2001

FreeBSD is a powerful web server, but it has a few problems as a web client. The issue that annoys me most is plug-ins. Plug-ins are not available for most Unix platforms. While most of the truly important content on the Web (such as, www.sluggy.com) is still in basic HTML or standard graphics format, I keep stumbling across sites that present information in some other manner.

Now, "browser plug-ins" are simply programs that display files. FreeBSD has a wide variety of file viewers in the ports collection -- perhaps I could simply wire those into the browser somehow? A quick Web search shows that someone who can actually write code already thought of this years ago, and wrote glue code to do exactly this. FreeBSD includes two programs that work with the Netscape plug-in API: xswallow (/usr/ports/www/xswallow) and plugger (/usr/ports/www/plugger).

My tests were done with Mozilla built for FreeBSD. The browsers integrated into KDE and Gnome both support the Netscape plug-in API and would probably work just as well. (Mozilla might be big, but it's smaller than either KDE or Gnome.) Other browsers are problematic.

The latest version of FreeBSD Netscape has several gaping security holes, and shouldn't be used for any reason. Also, if you're running a browser in Linux mode (such as Linux Netscape), these programs won't work. You cannot link FreeBSD binaries directly with Linux binaries, although each can call the other as external programs. And if anyone out there decides to implement the Netscape API in Lynx or some other text-mode browser, let me know!

The mailing list archives showed that many people had gotten Xswallow to work well, so I tried that first. This easily swallowed three days of my copious free time. First, xswallow is an a.out binary. a.out binaries do not work with ELF programs. It worked just fine with the obsolete, insecure FreeBSD Netscape, but not with a more modern Web browser in ELF binary format. I eventually got xswallow to compile in ELF format, but it wouldn't work with Mozilla. (I now understand much more about a.out and ELF binaries, though!)

I gave up and installed plugger. The plugger port installed quite a few file-viewing programs. The homepage includes several sample pages that you can use to test your plug-ins. To my surprise, the first sample I tried fired up an embedded xanim and started showing a looped clip from Star Wars. I didn't have to configure anything.

Then I tried the MIDI test page. Everything crashed with the error:

open /dev/sequencer: Device not configured

So I became root, went to /dev, ran sh MAKEDEV snd0, and /dev/sequencer appeared. This sort of thing frequently requires a reboot, so I restarted my laptop and tried again. It still didn't work.

A brief check of the FreeBSD-multimedia mailing-list archives revealed the problem: FreeBSD version 4 does not support MIDI. I needed a software MIDI player. The archives repeatedly suggest /usr/ports/audio/timidity++, which the plugger port already installed. I thought the port might be built wrong, or needed configuring, so I went digging. In the port message file, /usr/ports/audio/timidity++/pkg-message, I found the following hint.

===========================================================
You need "Gravis Ultra Sound" compatible patch files to 
play MIDI files.
See  http://www.goice.co.jp/member/mo/timidity/link.html
===========================================================

If I had installed timidity++ on its own, this would have been the last thing I'd seen. Because it came as part of the plugger port, it zipped past when I wasn't even looking.

The given URL directed me to http://www.stardate.bc.ca/eawpatches/html/default.htm, where I found a set of Gravis Ultra Sound patches called "Eawpatches." It was a big file in RAR format. That meant I needed /usr/ports/archivers/rar.

I downloaded the file, started the RAR install, and went to dinner.

When I returned, I extracted Eawpatches into /usr/local/share/timidity. I also edited the timidity.cfg file in that directory to replace all the Windows C:\ paths with /usr/local/share/timidity. The next time I fired up the web browser, the MIDI music and the rest of the samples played just fine.

Combined, plugger and Mozilla display an astonishing variety of content. Installing the mozilla-flashplugin port took care of Flash sites. Once the FreeBSD Java folks get the Java 1.3.1 plug-in working, I won't ever need a web browser program in Linux-mode again.

Michael W. Lucas


Read more Big Scary Daemons columns.

Return to the BSD DevCenter.

Copyright © 2009 O'Reilly Media, Inc.