Added cpl error codes to errcheck functions

Not sure if this is the right way to do this, but today I realized that the errorcodes for OGR and GDAL are not the same. So I added a gdal flag to the errcheck function, to add control over which error codes and messages should be used.