well, it took me almost all day, but I finally got the C-port for ClamAV working the way I wanted it to.
Turned out there is a bug somewhere that makes it not like some of the file names I had. I use the Maildir naming convention and in the middle of the file it had R23P45 or something like that. it was an R two numbers and a P then two numbers and when ever this pattern came up it would segment fault with no useful information.
After collecting enough examples of the exact messages that were causing the problem and noticing that they worked fine when I renamed then I rewrote my maildir naming function and I generate a temporary name before I can the message.
It’s working quite well and is already integrated into the email system.