Convert DiagPort.cpp to C