Older blog entries for gnutizen (starting at number 14)

8 Nov 2004 (updated 8 Nov 2004 at 06:52 UTC) »

So, I finally get my 802.11b wireless USB network adapter working on my Debian. I had made the mistake of trying to use the Atmelwlandriver on Sourceforge. I recompiled my kernel, I did this, I did that, the program wouldn't compile automagically, the instructions were confusing and so on. I then try at76c503a by Joerg Albert and Oliver Kurth and everything works right away. So anyhow it works. And right after that, I try to do a minor change and the networking for it breaks on my Windows box. This thing has the worst drivers for Windows, I have no idea how I ever got it working on either of my Windows boxes.

After a few months of being busy, I'm checking back on Gnutizen. I had to get myself a bootstrap of good hosts which didn't take too long, although some of the web bootstrap hosts going down didn't help. Unfortunately my last CVS up was after I broke the program so I've been looking to see what I did to break it. I seem to have narrowed it down to my attempt to break down a 324 line functions into smaller parts. Of course, a function with 324 lines is far longer than the 48 line maximum that Mr. Torvalds recommends. Which is why I was (and still am) trying to shrink it. I just have to shrink it without breaking things.

9 Jul 2004 (updated 9 Jul 2004 at 05:21 UTC) »

Ah, so Advogato is back up.

I did get my hands on a Linux - I brought back one of my machines and installed Debian on it via 6 or 7 3.5" floppies and an ethernet connection to ADSL. And I ran Gnutizen on it. No major changes for Linux other than an #include <byteswap.h> for endian stuff.

I was reading the Linux Coding Style document that Linus was just mentioning on the Linux kernel mailing list. Gnutizen is my first big C project so I find such things helpful. He says comments should be put at the head of a function explaining what it does (not how it does it - he says that should be obvious from the code). I went through my code and removed most comments inside functions and put them at the head where I described what the function did.

The really big impact was his advice on functions - he says

Functions should be short and sweet, and do just one thing. They should fit on one or two screenfuls of text (the ISO/ANSI screen size is 80x24, as we all know), and do one thing and do that well.
Some of my functions were longer than 48 lines - a lot more, and unnecessarily so. I went through and broke up many of my longer functions after reading this, which took a while. In the section on functions he talks about variables.

Another measure of the function is the number of local variables. They shouldn't exceed 5-10, or you're doing something wrong. Re-think the function, and split it into smaller pieces. A human brain can generally easily keep track of about 7 different things, anything more and it gets confused. You know you're brilliant, but maybe you'd like to understand what you did 2 weeks from now.

Breaking down the functions helped me lose these variables, but I am trying to trim the functions down to 7, or at least 10 local variables. And not have global variables unless they're necessary.

Well, I now have a cache for Gnutizen that is not out of date for personal use during development. I ran some tests and it looks like many modern servents are rejecting me, probably because of my lack of QRP. But that is not a problem for me now, and I can deal with other things, like bugs, which are more important currently.

Amazingly, I can compile the program with Microsoft Visual C++ now. The main changes needed: For the Sleep() call to work, I had to include the windows.h header file; I changed a variable define from "char variable[0]" to "char variable[1]"; and I also changed the filename of the cache file.

Also, I fixed two threading problems. In both cases I had one constant variable keeping track of multiple threads, which I changed to a variable for each thread. One was minor and just threw off download progress. The other was more serious as it controlled connections and was causing segmentation violations. I found that with gdb, and it is good that has been fixed.

Different operating systems bring out different errors. I want to get back on Linux and try to clean those up. I've been working on FreeBSD errors lately. I am on an OpenBSD system with few open files allowed as well, which shows me how my constant accessing of disk space is probably not a good thing, a lot of which can be moved to memory. I lost access to my Linux, I have to get that back as I want to work on Linux problems. And Windows has had problems too, although I suspect they are similar to the UNIX problems.

Anyhow, there is some stuff I am cleaning up, like the cached queries. Or so that Gnutizen can open without having a broken pipe (this seems like a new error). I want to get it so that Gnutizen can run on most OS's without encountering any errors. Things seem fine on Windows until I start downloading files. Anyhow, I should clean these things up before doing big expansions because the bigger it gets, the harder it may become to discover bugs.

My development of Gnutizen has been off again, on again. Actually, the only real CVS updates I made since September 2002 when I put it on Sourceforge, were in April/May of last year (2003) when I ported it to Linux and made a hack for the htons() call, ignored SIGPIPE/EPIPE signals (which I believe is normal to do), and also made changes so Microsoft's C/C++ compiler would compile it under Windows, and not just gcc/mingw compilers.

Since then I have been mostly working to focus on fixing problems in the existing application before adding new features.

However, getting other servents to connect to has been more of a problem as time goes on. My servent starts with a cache (an out-of-date one nowadays), and finds hosts only by pong (not 0.6 protocol methods like X-Try or X-Try-Ultrapeers, or web caching, or other methods). It also seems to be rejected by Limewire version 3 servents and Bearshare servents - perhaps because it does not know QRP or something. I've been spending the time I've spending on it in the past weeks just finding some servents to connect it to. That's coming along, I will see how it goes. Then I will try to fix bugs. Hopefully the big clients phasing out people using older protocol stuff is not at the point where I have to add QRP and the like, as I'd prefer to try and get the bugs out first.

Me and my friend are writing a commercial software product (mostly in C), this is the end of week 3 of our venture. Week 1 I spent setting up my network connection and computer mostly. Week 2 I wrote a small program. Week 3 (this week) I wrote a small program as well.

My work desktop is a FreeBSD. It has 2 9 gig disks but I want to use the other disk for a dual boot Linux so I am cramped for space. I like to use BASH so I used the existing bash - /usr/compat/linux/bin/bash. This did some weird stuff like make my uname say "Linux" instead of "FreeBSD" and some other things so I installed a new bash from FreeBSD ports. Maybe this was why Mozilla and Gnome wouldn't compile (or maybe not). I'm currently using Epiphany and Wmaker instead.

I only seriously started programming in C starting last year...my partner knows a bit about C so I have been dealing with some new things these past two weeks like linked libraries (static versus dynamic), linked lists and so forth. In terms of my code readability, he prefers gindent use K&R indentation as opposed to GNU indentation, and he also says I need better variable and function names (which is true).

Argh. Sourceforge's CVS is barfing again.

can't create temporary directory /tmp/cvs-serv27134
No space left on device

And no, that's not on my machine. The last time I tried to CVS my project from Sourceforge months ago, their whole server was down. Then there's the ssh change they made from ssh1 to ssh2 or whatever that took me a day to fix. Actually, I see that popular projects like GAIM are having the same problem as well, so. Bleh. I have a version of the code, but the recent changes are all out of sync and this is a pain.

MUDs

I've never really MUDed much, but a few weeks ago I went back to a MUD I was on many years ago, Arctic, and now have a level 8 mage. When I went on years ago I wasn't really interested in playing, I knew one of the "immortals" and just went on to chat with her. I was at a bookstore a few weeks ago though and was reading through a book called something like "How to be a game programmer: interviews with all the awesomest game designers" or something along those lines. I've never played Everquest, I don't even have a credit card to pay however much a month even if I wanted to, but it interests me, so I read the interview with the EQ designer. He said they did a few things to prepare their MMORPG, including play a lot of MUDs and write down what they liked and what they didn't like. Like many people, I have a ton of ideas I'd like to do, but have a definite lack of capital, free time as well as programming skill - in fact I'd say those things are intertwined somewhat. I do have an idea of an MMORPG though - to save on capital, among other reasons, it would try to be more p2p based than server based, and it would have a definite game theme which I won't go into currently.

So one thing I've become interested in is MUD clients. I'm interested in ones that are free - free as in both meanings. What I'm interested in are Windows clients, and to some extent command-line UNIX clients, and less so graphical UNIX ones. The main one I've been using is TinyFUGUE, which is a command line UNIX one. It's decent, and I've been using it. I just tried JamochaMUD, a Java one that runs on Windows (and I guess UNIX). The display often becomes scrambled though, so I'm not going to use it. So my search goes on for a good free (both meanings) MUD client.

P2P

Well, I guess there are groups using W.A.S.T.E., but it hasn't taken off like I'd expected, which AOL coming down on it didn't help. I'm sure small groups of people are finding it useful, and they're out there. I got somewhere down the list of the client, then got busy, then when I didn't see momentum I tossed in the towel. That "awesomest and successful game designers" book I mentioned before had several people interviewed say that what they really looked for in a designer was someone who didn't just start projects but completed them. Of course, that's not always an axiom, it of course makes sense to abandon a project when it has no utility any more. But that has stuck in my mind and is motivation to look at my Gnutella clone project Gnutizen again. It is true that I have very little free time, but if I can get around that I'll be looking at it again. I have to weed the bugs out, and then add on the non-leech functionality. I did get it to the point where it can download files though so it has reached the first step of acceptability, now I just have to get it to specs of an old Gnutella document which I'm sure no one but me cares anything about any more.

Knuth

Well I keep hearing about Knuth, Knuth, Knuth so I finally went out and plucked down $150 or whatever for the three books he's written so far. A lot of math. A lot. As I said before, I really have no free time, especially to sit down and concentrate intently for a few hours each day, every day. So Knuth will probably have to stay on my shelf for a while.

Economy/Jobs etc.

Well as I said in diary entries before, I am a systems administrator mainly, who just got seriously interested in programming, and I've been learning by doing mostly. I mean, I already know languages like PERL somewhat, but I've been writing stuff in C. Later on I might pick up C++ and Java. But anyhow I am mainly a systems administrator.
Anyhow I will not go into giving my opinion or trying to convince people or get into a discussion or argument. Especially since to me getting into an argument with someone who's here that is a manager and has a different not only point of view, but different interests, often diametrically opposed to mind. So I'm just speaking now to people who are workers - programmers, admins, and whatnot, who are tired of the rising unemployment rates, and tired of falling industry wages and so forth. And my message is - I'm with you. And also - we can't figth this as individuals. The IT employers - Microsoft, Intel, IBM and so forth have been well-organized and funding things like the evil ITAA for years - and the ITAA has taken that millions in funding and gone to Washington DC and screwed us over. And not just DC - they commissioned phony baloney reports about a lack of IT workers and got it all out in the press to fool the public, to "fool" Washington DC (although I'm sure campaign contributed made that easier) and even to fool some of us. Anyhow, they're organized, and now that we're under attack, now that our industry wage is falling, and of course I'm only talking to fellow workers (excluding any managers or whoever who may disagree), what we have to do is organize and fight back. You've been made about this, you've been wondering what you can do as an individual, and what I'm saying is, the employers and ITAA are not doing it as individuals, they're not fighting the system alone, why should we? So check out the Programmers Guild or even some of the more union-associated ones like WashTech. There's an old slogan "educate, agitate, organize". Before you do that you have to get educated, get agitated and get organized though. And the least important thing is the possibility of some AFL-CIO union coming in and getting collective bargaining contracts for X% of the industry (actually, surprisingly enough, they already probably do have 1-2% of the industry, whether you know it or not). What's important is that people wake up and organize together and educated themselves on issues that effect us, and our wallets. The employers are organized, why aren't we? Doctors and lawyers are organized in the AMA and ABA, if we're "professionals" why aren't we? And please don't mention the IEEE or any junk like that. The IEEE is corporate sponsored for one thing (can you imagine the AMA being corporate sponsored?) and for a second thing the leaders have killed anything good that members have proposed over the past few years. Associations like the IEEE see their job beginning and ending with making sure your skill level increases, and any other interest you have goes out the window. So check out the guild and Washtech, watch the Usenet groups like alt computer consultants for discussions and get involved. Believe me, most of the engineers like yourself have the same kinds of ideas and concerns as you do - and the way you would like to see things not going is the same as theirs.

It shows how screwed up American society is that this often has a "debate". Could you imagine IBM, Intel and Microsoft management having debates over whether to fund the ITAA with arguments like "if we're such a good company, we don't need someone in Washington DC looking out for our interests". There's a reason these people are running the world, and Farscape watching dorks full of hubris about their own ability are getting the shaft. But as I said several times, my message is not directed to those people but to those who already agree and hopefully I will be a little nudge that helps push them along, sometimes people want to be invited to the party before coming.

9 Jun 2003 (updated 28 Sep 2003 at 23:33 UTC) »

Well, those guys at Nullsoft have released another p2p application, W.A.S.T.E., and I've been checking it out. They released the C++ code for it, but I don't know C++, so I've begun hacking out the protocol in C.

The documentation says that, when you have a potential host to connect to, WASTE connects, and sends 40 bytes to the other host, which consists of (if there is no network name), 16 random bytes, as well as 24 more bytes which is a blowfish of the random bytes with a 20-byte SHA-1 of my public key plus 4 pad bytes. If the remote host knows my public key, it sends a 40 byte response.

I used Ethereal to sniff a send to a host running WASTE that has my key to get a 40 byte send. I sent that send to the host and also get a 40 byte response. In the C++ code, I see that g_pubkeyhash is the 20 bit public key hash encrypted, and that WASTE uses (a possibly modified version of) Paul Kocher's Blowfish code. So I'm messing around with this for now. The source I'm reading is in C++, a language I don't know, so I guess I can be forgiven for not totally understanding it. I often wonder how much faster I would be at writing code if I had years of experience under my belt. Much faster, I guess.

Well in the C language Gnutella clone that I'm developing, gnutizen, the SIGPIPE from the send() is now caught (although not in CVS), but now it seems in the same relative place that a SIGSEGV (segmentation violation) happens. Most of what I've read says that the SIGPIPE is fairly normal and catching it, or turning it into an EPIPE with a signal from send - the remote end simply breaks the connection and there's not much you can do about it. The segmentation fault looks like something I have to track down more though.

I had access to systems running Solaris, OpenBSD, and Windows previously, now I have access to a FreeBSD and Linux. I noticed while demonstrating to my friend that there is a problem with the file download in Linux. So that's another bug I'll have to fix.

I got a copy of Microsoft Visual C++ 6.0. I guess it's pretty old (1998). That's fine though, I'll run it on my Windows 98, and get ahold of whatever Developer Studio thing compiles C nowadays afterwards. I ran gnutizen through it and encountered a bunch of problems. It choked on "#include <sys/time.h>", as well as an include of unistd.h. It didn't know the call strncasecmp(). More importantly I made a character array with a constant size of 0 that it barfed on. The others I fixed in CVS, the single character "array" I didn't yet, that's next on my plate but I haven't run into any walls...yet. MSVC++6 has some nice features like seeing what calls are made inside a function, and where else in the program the function itself is called, as well as other features. Once I clean up the array thing I guess I'll see if it has any more useful stuff aside from making solely Windows installation easier (I made a nifty icon for Gnutizen for Windows).

So when I've had time to work on this program since early April, that's mostly what I have been doing...dealing with bugs and making sure things run cross-platform. There's not much point in adding new features if there are big bugs around that crash the program or prevent downloading.

I figured out (with a little help from gdb) why gnutizen was dying after a few minutes of running on it's new high speed FreeBSD and Linux development boxes - during a send it would get a SIGPIPE signal, because it would be writing to a socket/"pipe" after the other end had already broken the connection and was not reading. I put in a hack that catches the SIGPIPE signal, so now the program keeps running. I see that send has flags on some systems that turns SIGPIPE into EPIPE. I can attempt a better fix for this later, for now, the hack is OK. I will put it up on CVS, hopefully tonight.

5 older entries...

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!