In the beginning...
In the beginning, I'd begin each project by creating a new directory, typing e main.c, and entering the code (e is a custom version of vi that I use). Then I realized that a lot of the stuff that occurs at the beginning of a new project is always the same. You need:
- a Makefile to hold the project together
- a main.c that contains main(), and the command-line processing,
- a usage message (explained below), and
- some way of tracking versions.
For projects dealing with a resource manager (introduced in the previous book), other common parts are required:
- main.c should set up the resource manager attributes structure(s), register the mount point, determine if it's going to be single-threaded or multi-threaded, and contain the main processing loop, and
- various I/O and connect functions.
This resulted in two simple scripts (and associated data files) that create the project for me: mkmain and mkresmgr (see Threaded Resource Managers, below). You invoke them in an empty directory, and they un-tar template files that you can edit to add your own specific functionality.
You'll see this template approach throughout the examples in this book.
Page updated:
