3 ms·
For those of us who kind of know C but want to learn it really in depth, I like it as well. It makes compiling open source programs really easily. I took a cur
by leftnode 17y ago
For those of us who kind of know C but want to learn it really in depth, I like it as well. It makes compiling open source programs really easily.
I took a cursory glance of the code and it seems good, but is it good code to learn from?
- tptacek 17y agoYes. Start with "analysis.c" --- the code in their works with completed request/response pairs. Look for "scrape_response()". Note how the strcspn's and pointer math approximate simple, unrolled regular expressions. The database code (the "pivot tree") is a bit tangley as a data structure. http_client.c has really tight URL parsing code. This isn't written in a very modern style (I like that about it, though). For instance, look at "check_for_stuff()", which implements basic content sniffing. In a modern C program, you'd probably see an array of structs containing function pointers and names, each pointing to a tiny function looking for a different bit of content. Here it's one big unrolled function. Likewise, modern C code would probably just regex the HTML responses instead of hand-coding HTML parsing. But on the other hand this actually exists and works, and that's a good goal to have too. The I/O loop in Skipfish is definitely the right way to do network programming in C. This program is simpler and faster because it doesn't waste time with threads. But if you do something similar, use libevent.