Archive for September, 2006

NSPredicate and regular expressions

I’ve managed to figure out how to implement wildmat patterns inside of Wombat. It turns out NSPredicate does in fact support regular expressions, as documented in Using Predicates. You simply use the MATCHES operator to specify a regular expression, as shown in a couple of examples in Apple’s documentation. It’s implemented using ICU’s Regular Expressions package, which provides much better documentation than Apple.

The gotcha to note is that the MATCHES operator does not compile down to SQL, so you can’t give it directly to Core Data. Instead you have to pull out all the entities then post-process the array using NSArray’s filteredArrayUsingPredicate: method. It works, but it’s not as efficient as it would be if it were compiled down to SQL.

In a related news, Mike Zornek was kind enough to point out a small Core Data mailing list. Hopefully it will be a source of useful information in the future.

Core Data fetch queries

I’m currently trying to implement the wildmat matching algorithm as described in RFC 2980 for my NNTP server, Wombat. Since I’m implementing the article database using Core Data, I’d like to use as much as the built in functionality as possible.

Wildmat isn’t regular expressions, but supports five allegedly different operations. It’s really just three (they count character sets as three):

  1. * – matches any character zero or more times.
  2. ? – matches any one, and only one, character.
  3. [] – character sets. This includes using ^ to specify negative character sets and using \ to escape special characters in the set.

I’ve actually figured out that Core Data supports the first two right out of the box. That’s right, if you use the LIKE operator to match strings, you can use * and ? in the string and Core Data will do the magic for you:


NSString* wildmat = @"foo*bar??";
NSPredicate* predicate = [NSPredicate predicateWithFormat:@"name LIKE %@", wildmat];

In the above example Core Data would match any of the follow names:

foobar12
fooSTUFFbarNO
foojunk12barG1

I’m trying to figure out if Core Data supports character sets in anyway. It’d be a lot easier, and more efficient, if I can get Core Data to do all the heavy lifting for me. I’m also looking for any mailing list or discussion group that covers Core Data. I checked Apple’s mailing lists, but I couldn’t find anything.

Wombat NNTP progress

I’ve been making some progress on Wombat, my NNTP server. I got XHDR, LIST OVERVIEW.FMT, and XOVER all implemented, so all the NNTP clients that I have work with it. The interesting thing is XHDR and XOVER do basically the same thing, except that XOVER is much more efficient. Instead of sending one header at a time for a range of articles, XOVER sends all the standard headers for a range of articles all at once. I can see why NNTP clients want it implemented, but it also makes me wonder why newer NNTP clients would bother with XHDR (MaxNews and some others do).

I also implemented some extended headers like Xref, Lines, and Bytes, since every client I tested with wanted them. Also both Lines and Bytes are required to be sent with the XOVER headers (XOVER has required and optional headers). Now, Xref and Lines were fairly easy to implement. Xref just lists each group the article is on the server, and its article number in that group. Lines is simply the number of lines in the body of article. But Bytes, oy.

RFC 2980 says XOVER requires Bytes, but nowhere does it say what the value is. Only by interrogating an existing news server was I able to guess that it’s most likely the total number of bytes of the article. But I’m not sure, I could very easily be wrong. I googled for it several times and came up with nothing. The other thing about Bytes is that it isn’t really stored in the headers. That would alter the size of the article. So its kept external of that. Me, I just added another long long field to the database and jammed it in there.

In related news, I’ve found that only Unison, NewsWatcher, and Thunderbird are really worth testing against. The others that I mentioned last time are so flaky I have to track down whether it’s a bug in my server or a bug in their client. Of the good ones, NewsWatcher is actually my favorite despite its age. It seems to have the most robust and flexible NNTP client implementation. Its about the only news client that notices when groups are added/removed on the server, and allows me to select certain useful options (i.e. does it use XHDR or XOVER to get header information). Very useful for testing.

Unison makes it easy to upload files (it automatically segments them, encodes them, etc) so I played around with that for a while. I found some bugs in Wombat that way. Namely, that I was treating all text as UTF-8 encoded, when it wasn’t. That meant yEnc encoded files got corrupted and couldn’t be properly rebuilt. I found out that using ISO Latin 1 for the encoding resulted in non-corrupted files, but that’s still a big assumption to make. In the end, however, I ended up just treating the headers as text and the body as a big bag of bits.

I’m still using Core Data as the back end, although a little less so now. The other thing I found out from uploading files from Unison was that large articles make the database huge, quick. Also seeing that I was treating most of the article as a binary blob, keeping it in the database wasn’t so useful. So I modified Wombat to keep the headers in the database, but write the article to an external file. I kept what I think is a traditional directory layout for articles. An article posted as the 4th article to com.orderndev.general gets path: com/orderndev/general/4.txt. Unlike traditional systems though, I don’t hard link from other group directories it was cross posted to. I just put the relative path to the article file in the database.

I’m struggling with using Core Data with threads. It has some lock and unlock methods on NSManagedObjectContext with documentation vaguely stating that you should use them, maybe, if you feel like it. Unfortunately, I occasionally get random crashes when I have multiple threads touching the object context, the in memory part of the database. I have already put locks around code anytime I create an entity, modify an entity, or retrieve an entity. I haven’t put locks around accessing attributes of entities, although it looks like I will have to. I just wish there was some good documentation for this.

Meanwhile, I’m still progressing through RFC 2980 and RFC 1036 and getting the standard stuff implemented. Yukon, ho!

NNTP, Core Data, and Wombats

For my new programming side project I’ve started writing an NNTP server. Like many young children, I once looked up into the night sky and wondered, “what would it be like to write my own news server?” I’ve read the RFC before, but never got around to actually implementing one, mainly because writing my own database never really appealed to me. I’m just crazy like that.

That’s where Core Data comes in. It’s an Apple data modeling technology that wraps SQLite. I’ve been looking for an excuse to learn this very cool technology, and this seemed a good excuse as any. I have to say, Core Data is very easy to use. The only problem I had was I kept wanting to design database tables instead of designing an object model. (Where’s my primary and foreign keys??) Way too much MySQL beforehand.

I’ve decided to code name this ill-advised project “Wombat,” for several reasons. First, Wombat is mentioned a few times in the examples in RFC 977. Second, its a really dumb name, and what other kind of a name would you give to an NNTP server that only runs Mac OS X 10.4 and higher? Plus Wombats look ornery, and if this server is anything, it’s ornery.

I’ve actually got RFC 977 implemented now, with a couple of extensions, which is supposed to be the NNTP standard. After I got most of the commands implemented, I decided to try my server with some Mac OS X native newsreaders, just to see them interact.

Hahahaha!

That’s the sound of all the Mac OS X newsreaders not knowing what the heck to do with a news server that implements the NNTP standard. Or perhaps, more accurately, news servers that only implement the standard.

I tried several NNTP readers: Panic’s Unison, Mozilla’s Thunderbird, the venerable MT-NewsWatcher, and some lesser known ones like Newsflash, OSXnews, MaxNews, and Xnntp. Most of them could get the list of groups and how many articles there were, but that was it.

You see, there’s another RFC, called “Common NNTP Extensions” that describes many ad-hoc extensions that servers started implementing that are not in the standard (RFC 977). Well, it turns out every reader I could find requires at least some of these extensions to be implemented. Namely, most readers want XOVER, LIST OVERVIEW.FMT, and XHDR implemented. Basically, those commands help the reader retrieve header information (subject, from, etc) en masse, and far more efficiently than the standard allows.

I guess what was more shocking to me, was that none of the clients fell back to the standard commands, when The Wombat started kicking back “500″ codes (command not implemented). The readers either treated my response like a bug in the server (that’s what they told the user) or just assumed The Wombat returned an empty data set. I’m guessing that the common extensions have been around for long enough (documented in 2000) and widely implemented enough, that all readers simply assume they’re going to be there.

There were also problems with the couple of extension commands I did implement. Namely I wanted a way to require authorization, so I implemented the AUTHINFO command, as described in the “Common NNTP Extensions” RFC. Apparently I’m the only one reading from that document.

The way AUTHINFO works is the client can issue commands like it normally would, but at any time the server can kick back a response that essentially says “Sorry, you have to authenticate before you do that.” At that point the client gives a username and password, the server authenticates it, and the client goes on its merry way. That’s the way it supposed to work anyway.

Unison, on the other hand, wants to start shoving AUTHINFO commands at the server at random intervals. This is contrary to the RFC that says the client should never initiate authentications, but only provide it when requested. The RFC also says that if the client offers AUTHINFO commands when not requested, the server is supposed to reject them. Foolishly believing the spec, that’s how I implemented The Wombat. Well, if you ever turn Unison down, you hurt its little feelings and it starts talking about you behind your back to the user. Stuff like: “the server doesn’t like you anymore. It rejected your username and password.” Unfortunately, the RFC doesn’t have a response for “you dumb client, you’re already logged in as that user!” Of course, I ended up modifying The Wombat to accommodate Unison’s pushy style of authentication.

So at the end of the day I have a fully implemented NNTP server, with respect to RFC 977, and no reader will work with it. I guess I have some work to do.

Ahoy, me mateys

Avast, ye land lubbers, forget not that today is International Talk like a Pirate Day.

So let’s hear some “avasts” and “ayes” out of ye, or be keelhauled!

Aaarrrrrr!

levitra 125 mg
cheapest prices on generic viagra
buy free viagra viagra
buy viagra onli
buy viagra online and get prescription
cheap overnight viagra
huricane ike home repair wanted
buy online pill viagra
cheap viagra online uk
50mg cialis
buy cheap deal viagra viagra viagra
cheap cialis canada
36 hour cialis
mobile home roof repair
cheap levitra online
20 mg cialis
home study computer repair course dvd
buy cheap generic viagra
buy viagra in great britain
buy viagra without prescription
buy viagra in london
buy cheap viagra uk
cheap pill viagra
viagra and coupon
generic viagra 20mg pills erections
voagra online without prescription
viagra 50 mg
viagra and cialis and
bruces home repair salem or
cheap online generic viagra
viagra 100mg price
buy viagra in spain
cialis 5m tablets
cheapest price for generic viagra
mobile home repair rochester wa
buy viagra softtabs
cheapest price viagra
viagra buy it online now
rx cialis 100mg
buy low price viagra
cheapest place to buy viagra
buy cheap online uk viagra
home foundation repair
100mg viagra
buy pill viagra
buy viagra online
voagra online without prescription
buy viagra in canada
generic viagra 100mg
cheap online viagra viagra
buy line viagra where
federal grants for home repair
cheap prescription viagra
cheapest generic price viagra
10 generic levitra for 19.95
buy prescription viagra
levitra online prescription
buy levitra 50mg
cialis brand cialis 100mg
buy cialis online 50mg
in home tv repair canton nc
buy viagra in toronto
viagra by mail canada
home repair tax deductable
100 mg cialis us pharmacy
viagra brand viagra 100mg
mobile home floor repair
buy viagra online
100mg levitra
levitra 25 mg order
viagra 20 mg
buy viagra next day delivery
cheapest uk supplier viagra
viagra and cialis cheap
cialis 10mg 20mg
cheapest 4 quantity of viagra
buy levitra online
buy cialis online viagra
250 mg viagra
home window repair in sc
buy generic viagra viagra
buy cheap generic viagra online
cheap cialis canada
cheapest price on viagra
cheap viagra canada
viagra by the pill
buy keyword online viagra
cheapest prescription viagra
buy viagra on-line
50 mg viagra retail price
buy online drug viagra pharmacy
cheap 25mg levitra
viagra buy ionline
cialis 100mg price
levitra without prescription
home repair denver coloradao
buy discount viagra
buy cheap online prescription viagra
viagra 25 mg
buy now online viagra
levitra 10mg 20mg
buy cost low viagra
purchase levitra online
buy viagra onlines
buy viagra in australia
ron hazelton home repair
buy cheap online viagra viagra
cheap online pill viagra
100 mg levitra us pharmacy
cheap phizer viagra
bruces home repair
viagra by phone
buy online online viagra viagra
buy cheap viagra online u
cheap levitra canada
cialis online prescription
cheap levitra online
buy locally viagra
buy cheap cialis generic levitra viagra
buy cialis internet
cheap viagra uks
sears home repair
buy viagra generic
50 mg cialis retail price
order 50mg levitra
viagra 50mg
cialis online
cialis 20
cheapest price for viagra
buy site viagra
discount drugs levitra 100mg
cheapest brand viagra
buy levitra online 50mg
home repair replacing circuit breakers
buy viagra low cost
buy prescription vaniqa viagra
discount drugs cialis 100mg
buy cheapest viagra
buy discount propecia
home computer repair
buy cheapest online viagra
levitra 50mg
viagra buy online
home cd repair
cialis 25 mg
viagra buy viagra
buy in online uk viagra
home remedies to repair scratched cds
buy discount levitra
cheapest place buy viagra online
buy deal deal price viagra
buy online prescription viagra
viagra by mail order
buy viagra pill
viagra buy uk
250 mg levitra
buy deal herbal viagra viagra
buy pfizer viagra
buy cheap viagra online now uk
buy viagra internet
cheapest line viagra
buy viagra professional
buy cialis without prescription
buy viagra in uk
cialis 10 mg
viagra and cialas
good review sites for home repair
home repair vancouver
cheapest generic viagra and canada
cialis no prescription
10 generic cialis for 19.95
rx viagra 100mg
levitra 25 mg
buy viagra in malaysia
buy online levitra cialis viagra
vista home premium repair
cheap cialis canada
buy discount levitra
cheap viagra uk
buy online sale viagra
home appliance do it yourself repair
viagra by money order
levitra no prescription
cialis 20mg
cialis 20mg reviews
50 mg cialis
cialis reviews
buy cialis no prescription
buy generic viagra online
buy viagra removethis
buy levitra online viagra
cialis 24
buy cheap deal pill viagra
levitra 50 mg
weed eater home repair
mobile home repair remodeling
buy kamagra viagra
cialis 100mg
cialis 20 mg
cheap order site viagra
generic cialis 100mg
cialis 50 mg
buy viagra london
buy cheap discount levitra
cheap discount levitra
viagra no prescription
viagra 25 mg order
buy in online usa viagra
buy sale viagra
10mg cialis
buy viagra pills
viagra brand
buy viagra 50mg
buy viagra locally
cialis no prescription
cheap sale viagra
mobile home skirting repair
cialis 1
cheap prescription viagra without
buy real viagra online pharmacy
cheap viagra st
cialis 32
cheap online softtabs viagra
cheaper viagra levitra cyalis
buy viagra in mexico
buy online uk viagra
buy cheap viagra
cialis 125 mg
buy cialis viagra
viagra without prescription
buy online purchase viagra
cialis 50mg online
order 50mg cialis
buy lady uk viagra
50 mg levitra retail price
cheap site viagra
home repair grants
buy viagra usa
buy viagra uk
levitra 50mg online
36 hour levitra
buy online prescription viagra without
buy 100 mg viagra
cheapest generic viagra and cialis
buy viagra line
cheap online purchase viagra
buy generic viagra buy
cialis 2005
cheapest in uk viagra
buy viagra online alternative viagra
viagra buy oonline
scottsdale home repair
generic cialis wholesale 100mg
buy generic viagra
mobile home repair
buy cheap cialis
cheap viagra online prescription
buy cialis no prescription
buy now viagra
buy viagra sale
home repair grant
buy viagra in the uk
cialis black 800mg
buy pharmacy pill viagra
home electrical repair
order levitra
do it yourself home repair
cheap online sales viagra
buy no online prescription viagra
viagra 100mg
buy real viagra online
viagra by mail
buy viagra in bangkok
50 mg viagra
viagra buy in uk online
home repair frozen pipes
viagra buy viagra online
cheap pharmaceutical viagra
cheapest price for viagra and cialis
buy cheap cialis
buy viagra no prescription
canada pharmacy discounted levitra 100
buy real viagra
50 mg levitra
buy viagra in new zealand
home appliance repair
buy viagra london
buy cheap generic online viagra
buy viagra no prescription
36 hour viagra
mobile home repair parts
buy kamagra viagra india
buy price viagra
buy pill price price viagra
cialis 10
buy now levitra
cheap online viagra
buy cheapest viagra online
canada pharmacy discounted viagra 100
cheapest generic substitute viagra
buy later now pay viagra
cheap online price price viagra
buy say viagra
100 mg viagra us pharmacy
20mg cialis
cialis without prescription
order levitra online
cheapest place to buy viagra online
viagra by overnight delivery
buy cheap deal online viagra viagra
generic levitra wholesale 100mg
buy line viagra
buy viagra phuket
levitra 100mg
cheap price viagra
cialis 10
cheap 25mg viagra
cialis 25 mg order
viagra online prescription
generic cialis
cialis black
cheap online order viagra
buy online order viagra
viagra brazil
levitra 20 mg
buy online sale viagra viagra
viagra buy now pay later
amana refrigerator home repair
buy cialis now
registar repair windows xp home
cheap pill pill sale viagra
generic levitra 20mg pills erections
cialis 36 hours
cheapest online viagra
viagra buy australia
buy viagra online 50mg
buy cheap viagra online uk
cheapest cialis
buy viagra inte
buy prescription viagra without
cheapest generic viagra
levitra 100mg price
viagra 125 mg
viagra buy generic
home repair
buy viagra toronto
home repair handymen in fernley nevada
cialis without prescription
cialis 2005
cheap viagra without prescription
canada pharmacy discounted cialis 100
buy in uk viagra
buy pharmaceutical viagra
30mg cialis
discount drugs viagra 100mg
cialis 2.5
buy real viagra pharmacy online
buy cheap viagra on
cialis 20mg
home repair maintenance
home window repair
buy cheap viagra in uk
250 mg cialis
buy viagra in united kingdom
cialis 30mg
buy generic viagra pharmacy online
buy cheap viagra online now
cialis 20
tamiflu
100mg cialis
buy online price viagra
buy online online pill viagra viagra
10mg levitra
buy viagra soft
buy levitra no prescription
home repair plumbing
american pacific home repair
cheapest regalis viagra
home repair business
buy in spain viagra
buy free online sale viagra viagra
buy cheapest online place viagra
cialis 20 mg
buy generic no online prescription viagra
buy viagra line
10 generic viagra for 19.95
cialis 5mg
buy internet viagra
viagra by mail catalog
buy free viagra on internet
order 50mg viagra
buy cialis 50mg
cheapest site viagra
buy discount cialis
buy cheap viagra on the net
cheap soft tab viagra
cheap 25mg cialis
buy cialis online now
viagra and cialis
cialis 50mg
voagra online without prescription
cialis 10mg
usa cialis
buy cheap levitra
5mg cialis
viagra 10mg 20mg
buy viagra online at cheap price
cheapest cheap viagra
cheap viagra online order viagra now
home entertainment repair tips
40 grams of cialis
buy levitra canada