Implement SFB 3 "TP"

Signed-off-by: Michael Buesch <m@bues.ch>
Fix file permissions

Signed-off-by: Michael Buesch <m@bues.ch>
Add checks for DB lengths

Signed-off-by: Michael Buesch <m@bues.ch>