add missing prototype and move struct definitions to header.