This is some form of the lib Zed Shaw has you make in "Learn C The Hard Way." I split it into its own repo to use in other projects.