libgpio is an open source library with some helpful routines to make common Linux(tm) GPIO operations easier.
Source code is available at https://github.com/animalcreek/libgpio