zlib port for SGScript