some code snippets, from apue