Software updates by Troy D. Hanson


A sampling of C snippets
December 19, 2010, 5:38 pm
Filed under: snippets
snippets.png

On my Scripts and Snippets page, there are a dozen or so tiny C programs that each show usage of a particular library (like PCRE), technique (like a DNS lookup), tricky task (like writing a parser) or easy “boilerplate” code (like read some options and iterate over lines of a file).

These programs are there to jog my memory, or to give me something to quickly copy and modify when doing something similar in the future. Here’s some of the snippets that are there today. Maybe they’ll be useful to you if you need to see a quick, minimal complete program that does one of these tasks. They’re all placed in the public domain.


C snippets

  • lemon using the Lemon parser generator
  • dns doing DNS lookup
  • udp UDP client and server
  • tcp TCP client and server
  • ifinfo list network interfaces, their IPv4/v6 addresses and MACs
  • pcre using pcre library
  • dlsym using dlsym
  • readline using readline library
  • looper iterating over lines of file
  • slurp using read or mmap to slurp a whole file
  • mworkers a sigsuspend-based parent process managing multiple worker processes
  • bloom building a Bloom filter from lines of one file, and testing other lines on it
  • zlib a simple gzip/gunzip implementation using the zlib C API
  • tconf function to read configuration file entries
  • iconv using the iconv library
Advertisement

Leave a Comment so far
Leave a comment



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s



Follow

Get every new post delivered to your Inbox.