pkg-config and glib, chicken and egg, same thing

I’m setting up a virtual machine using VirtualBox on Ubuntu Gutsy, running Win2000 as the guest OS. I’ve gone and installed Cygwin and MinGW and MSYS in order to build Gnash on Win32. I came across a funny bootstrapping problem trying to install pkg-config: pkg-config 0.22 requires glib 2.x in order to compile. No sweat, I go and download glib 2.13.6 and configure it … and the configure script stops with an error when it can’t find pkg-config installed!

Circular dependencies suck.

Of course, in the README.win32 for pkg-config, Tor Lillqvist acknowledges this at the end of the document:

On Unix, pkg-config is built using its own copy of GLib 1.2.8. On Windows, we use the normal GLib available for Windows (2.0.x). Yes, this does introduce a kind of circular dependency. But, that can be worked around. The circular dependency only appears if one uses the configure mechanism to build GLib. GLib’s configure script checks for pkg-config. pkg-config depends on GLib. Thus, starting from scratch, with no GLib and no pkg-config, using configure, there would indeed be a Catch-22 situation. However, GLib can be built just fine using the manually written makefiles for mingw or MSVC. And if somebody does want to build GLib on Win32 using configure, she can first install a prebuilt pkgconfig.

Unfortunately, as of glib 2.13.6 at least, only the automake files are included–no ordinary makefiles for Win32, either MinGW or MSVC, even. Fortunately, older releases of pkg-config source are still available, and glib 2.13.6 will build with pkg-config 0.14 or newer. pkg-config 0.14 includes glib 1.2.8 and tries to build it as part of its build, so I went ahead and tried to build pkg-config 0.14. Since nothing is ever easy, I ended up having to make a slight change to glib 1.2.8 to get it to compile, adding these lines to the top of glib.h, after the #include <glibconfig.h>:

#undef G_MAXINT
#define G_MAXINT 0xFFFF
#define SIGCHLD 17
#define g_ascii_strcasecmp(a, b) strcmp(a, b)
#include <fcntl.h>
#include <winsock.h>

I also discovered that gthread.o wouldn’t compile right due to some libtool weirdness, so I had to compile everything somewhat manually with this:

$ cd glib-1.2.8/gthread
$ gcc -I.. -DHAVE_CONFIG_H -DG_OS_WIN32 -o gthread.o -c gthread.c
$ touch gthread.lo
$ cd ..
$ make libglib.la
$ cd ..
$ make CFLAGS="-DG_OS_WIN32" parse.o
$ make pkg-config.exe
$ cp pkg-config.exe /mingw/bin

After all that, I finally had a compiled and installed pkg-config 0.14! I went ahead and used it to build glib 2.13.6 and installed that, then went and built pkg-config 0.22 with it.

So, which came first? The chicken or the egg? :-)

Tags: , , ,

Great progress made on npgnash.dll

getgnash.org logo

What have I been furiously hacking on the last few nights? Gnash, the GNU Flash player. Specifically, I’ve been doing a lot of hacking on support for Win32. More specifically, I’ve been working on npgnash, the plugin that embeds Gnash inside Firefox using the Mozilla NPAPI.

I’m not going to get into the ugly details of what I went through to get as far as I have, but I’ll summarize it as: a hell of a lot harder than it ought to have been. I’ll save my rant for why C++ sucks, so badly, for another day. What you really want to see are screenshots, I know!

First, here’s the entry for npgnash from Firefox’s about:plugins page:

Firefox about:plugins showing npgnash

Okay, big deal, so I can load a DLL. Here’s npgnash playing gravity.swf from the Gnash testsuite, right in the browser:

npgnash playing gravity.swf from the gnash testsuite

Who doesn’t love a big bouncing smiley-face animating across their browser, right? But, the true test is playing my favorite YouTube video … to test with, at least:

npgnash playing a YouTube video

Yup, that’s no joke … it’s a screenshot of npgnash playing a YouTube video inside Firefox 2.0.0.12 on my WinXP machine. It’s using the Anti-Grain Geometry (AGG) rendering engine, along with SDL/ffmpeg for audio … and they both work, albeit not very well, yet.  Still, not bad for three or four days of hacking, right?

Despite all this progress and these screenshots, it’s still not ready for general-purpose use, yet. The underlying Gnash code is still isn’t fully re-entrant/thread-safe and the cleanup code isn’t fully baked so I can’t even load one SWF after another without it crashing. I also haven’t implemented any mouse/keyboard support, so you can’t actually use any of the player buttons you see in the YouTube video, etc., yet.

Still, it’s a great start and hopefully by the time the 0.8.3 release is ready in a few months, there will be a lot more forward progress.

Tags: , , , ,

Adding an “Unsubscribe” button to Google Reader using Greasemonkey

Yesterday, Maki asked on Twitter, “I would love to have a ‘Quick unsubscribe’ button for Google Reader…a greasemonkey script would be terrific. Anyone wanna do one?” Of course, it seems I have a thing for hacking out little web toys for people I know on Twitter, so I gave it a whack.  Here’s the result:

Here’s a screenshot showing what it does:

Google Reader Unsubscribe button screenshot

It’s a pretty simple script. The hardest part was reverse-engineering Google Reader’s packed/minified JavaScript, but that wasn’t too hard.

Do you have a useful idea for a web toy? Perhaps if you run it by me and it interests me, I’ll hack on it for you, too.

Tags: , , ,

Hand-decoding tcpdump’ed SNMPv1 packets

I can’t go into too many details about what I’m working on right now, but it involves processing SNMP requests and generating SNMP responses. The hard part is that I’m writing all my own code to parse and process them, as I can’t use the Net-SNMP library to do it for various reasons. (Trust me, I wish I could.)

What makes this so much fun (not!) is having to debug and troubleshoot my code by hand-decoding the SNMP messages, captured off the network using tcpdump. If you’ve never done this, I’d compare it to performing long division on really large numbers. It’s not particularly hard, but it sure is tedious. Here’s an example of a pair of request/response packets that I’ve hand-annotated:

Screenshot of hand-annotated tcpdump of an SNMP request/response pair

Yeah. This certainly isn’t one of the glorious parts of software development. But, it needs to be done, right?

Tags: ,

I got a fat stack of cash on my desk

Scrooge McDuck swimming in his vault

A few weeks ago, I was talking to a friend of mine who works for the Federal Reserve Bank of New York about how cool it must be to work around so much money. I mean, I could just imagine swimming around in the vault through a few hundred million dollars, just like old Scrooge McDuck.

Well, apparently there’s no special vault for swimming in at the Fed, but they do shred the cash that they remove from circulation. What’s even better, is that after they shred it, they package some of it up and it gets reused for various purposes. I guess they realized that shredded money would make a great gift for someone like me who finds this sort of thing really cool. So, my friend got one of these bricks of shredded cash for me–how awesome is that?!? Check it out:

Fat stack of cash

Apparently this fat stack of cash weighs about 2.2 pounds and contains the remains of approximately 1,000 notes. It contains a variety of shreds: $1, $5, $10, $20, $50 and $100. I don’t know what kind of distribution of notes they regularly shred, but the little blurb on the back label says, “If these shreds were only $100 notes the value would be $100,000.” C’mon, tell me it’s not cool to think you might have $100K in cash just sitting on your desk. Sure, you can’t spend it, but it’s still cool to me.

Tags: , , ,

Figment, “all bands, no music”

Figment: All bands, no music!

My friend Dan just told me that his brother Larry is spreading the word about a new site that just launched called Figment.

In a nutshell, Figment is a site where you can explore and discover new bands without having to listen to any of their crappy music–because, there isn’t any. The goal is to create bands and albums that other people like enough to become fans of, like Pastor Of Muppets or Josie and the LOLcats.

I don’t know if it’ll catch on, but it might be worth a chuckle or two to check out the creativity behind some of these faux bands.

Tags: ,

Debian package of character counting plugin for Pidgin

I finally got around to learning how to create a Debian package using the excellent Debian New Maintainers’ Guide so that I could finally create Debian binaries for the character counting plugin for Pidgin that I whipped up last year.

Screenshot of character counting plugin for Pidgin on Debian 4.0 (etch)

There’s a screenshot of Pidgin 2.3.1 running on Debian 4.0 (etch) with the plugin loaded. You can download it here:

If you need to build the plugin for a different architecture (I only have i386 readily available to me), here’s what I used to package this:

If anyone wants to take this and make an RPM out of it, that’d be nice. If you do, leave a link to it in the comments so others can find it. Thanks!

Tags: , ,

Configuring DD-WRT as a wireless/wired router and bridge

I’ve installed DD-WRT on a WRT54GS and configured it as a router that bridges the wireless AP, the ethernet and WAN connection. I didn’t want DD-WRT configured as a “gateway” as that means NAT and I didn’t want that: my firewall is already doing NAT, so I wanted DD-WRT to just route traffic upstream.

Here’s a diagram of how I set things up:

Network diagram showing WRT54GS running DD-WRT as a router

I wanted the WRT54GS to bridge the 172.16.113.0/24 network on the WAN port (interface vlan1) to the firewall with the 172.16.113.0/24 network on the wireless AP side (interface br0). The firewall’s NIC was configured as 172.16.113.1. The WRT54GS’s WAN port was configured with a static IP of 172.16.113.254 and gateway of 172.16.113.1. The local IP was configured to 172.16.113.253 and no gateway. The VLANs were configured so that everything was assigned to the “LAN” bridge, all 4 wired switch ports, the WAN port, and wireless.

This looks like it all should have worked, but it didn’t. What I finally ended up having to do was to set a small startup script to make the final adjustments. I’m going to share the steps to set that script here, since I know I’ll forget it:

nvram set rc_startup='
echo 1 >/proc/sys/net/ipv4/conf/br0/proxy_arp
echo 1 >/proc/sys/net/ipv4/conf/vlan1/proxy_arp

ip route add 172.16.113.1 dev vlan1
ip route delete default
ip route add default via 172.16.113.1 dev vlan1
'
nvram commit

And with that, everything works. Clients can connect wirelessly or wired, get assigned an IP via DHCP in the 172.16.113.0/24 network, get routed up to the firewall which enforces all my security and routing policies.

What I’d like to do next is play with the AP isolation setting to keep the wireless clients from being able to snoop on the wired connections. I like to keep this configured as an open wi-fi access point, but I don’t want someone who roams up to be able to see the activity of the wired clients. But, for now, what I’ve got working is good enough.

Tags: , , , ,

Covering large areas with some Linksys WRT54GS’es and DD-WRT

I recently helped a friend of a friend with a wireless networking setup who has a Seriously Large House–we’re talking easily 10,000 sq. ft. per floor, and the house has 3 floors. Yeah, it’s that big. They had set up a Linksys WRT54G and two WRE54G repeaters and, no surprise, had horrible signal coverage and frequent packet loss, and this was just trying to provide connectivity to a single floor in the house. Needless to say, they were not pleased, so I was invited to take a look and fix things.

I’ve always heard good things about the third-party firmware DD-WRT, so I decided to give it a shot. I picked up two WRT54GS routers ($70 at Amazon.com) and installed DD-WRT on them. I also installed DD-WRT on the WRT54G they already had.

Oh, a word of advice–if you recall, I bought one of those WRE54G’s back in May 2007–don’t waste your money on them. They cost more than the WRT54GS, can’t run DD-WRT as far as I know, and they only have one antenna, which means losing half your bandwidth per repeater hop. There’s absolutely no reason to  use them, whatsoever–unless you’re not willing to figure out DD-WRT, of course.

Linksys WRT54GS

So, I configured one WRT54GS as the master which has the WAN uplink providing network access to the wi-fi cloud. The remaining WRT54GS and WRT54G were configured as repeater bridges, all with the same SSID to facilitate roaming which worked perfectly–only one (!) packet dropped when roaming between AP’s. I did crank the power up from the default 28mW to 60mW which made a significant difference in signal range and coverage.

With this, there’s reasonable coverage on the first floor, but most importantly full coverage on the second floor which is where they were most interested in. The third floor gets good signal strengh in spots, but that’s adequate for now.

Overall, for the price, the Linksys WRT54GS is a fantastic product and when used with DD-WRT, can be used qutie effectively.

shiobara.com is getting a make-over

It’s been over two years since we’ve taken the photo album down on the family website, shiobara.com–June 2005, to be exact. It’s time to give it some proper care and feeding. The first step was to replace the old site with WordPress, which required some changes to AOLserver in order to get it to work right. I then created a new theme that’s a little less cluttered and with colors that aren’t quite as offensive. Here’s a “before and after” set of screenshots:

shiobara.com, before
(shiobara.com, before)

shiobara.com, after
(shiobara.com, after)

I realize I have no graphic design ability–hell, I can’t even coordinate colors when I dress myself. Someday, I’ll find someone who’s ridiculously talented and wants to do the graphic design for me to save me the embarassment of doing it myself. Until then, I’ll just keep hacking away at it myself.

Now that the site is all in WordPress, the next step is to clean up the photo album. I took it down back in 2005 and wanted to redo it, but never got around to it. So, recently, I’ve started working on a Media Gallery plugin for WordPress that uses jQuery, jCarousel Lite and ThickBox. It’s pretty slick, and once we’ve launched the photo album, I’ll release the plugin as open source. If you’d like a sneak peak to beta test it, just ask.

Tags: , , , , ,