For a long time I've been aware of Ncurses,
but I've never actually used it. So when I accidentally wandered across
tutorial for using Ncurses in Xcode, I decided that it would be worth checking out.
But, when I found myself with a few spare minutes... I was sitting in front of a machine
running Debian Linux rather than Mac OS X. So I experimented there instead. To get the
snakey program to run I
had to do the following:
- First of all, I had to get the ncurses stuff:
sudo apt-get install libncurses5-dev
- Then I had to compile the example code (I had renamed the program to box.c):
gcc box.c -lncurses -o box
- Then finally, I could run it:
So that was pretty easy. Ncurses is one of those things that I'd like to mess about
with some more, because I still like running stuff in a console window.
For some time I've admired the simple web server code called nweb, which can be found here. It's written in C and shows how you can build a nice simple little HTTP server without scary amounts of code. The code even runs on the Raspberry Pi.
It's written for Unix and Linux systems, but I wanted to see if it would work on my MacBook (which runs Mac OS X, obviously). Since Mac OS X has a Unix heritage, I hoped it would work without too much trouble...
So I fired up Xcode and created a blank "Command Line" application in C, then I just pasted in the nweb source code. It gave just one compilation error.
All I needed to do was replace SIGCLD with SIGCHLD in one line of code. Then it worked! Nice.
So that's awesome, a very handy little command line web server for Mac OS X.
I'm sure I will find a use for that. The old brain cogs are whirring as I type this in fact.