code in apue by hand