mainly c code for book SWORD TO OFFER