Tested with version 1.4.0.
The website documentation for Within and Contains is reverse of the actual behavior.
http://www.gdal.org/ogr/classOGRGeometry.html
test code:
/* a square (closed) */
double x[] = {0, 1, 0, 1, 0};
double y[] = {1, 1, 0, 0, 1};
OGRLineString ring;
ring.setPoints(5, x, y);
OGRPoint middle;
middle.setX(0.5);
middle.setY(0.5);
std::cout << "**********************************************" << std::endl;
std::cout << "middle.Contains(&ring): " << middle.Contains (&ring) << std::endl;
std::cout << "middle.Within(&ring): " << middle.Within(&ring) << std::endl;
std::cout << "ring.Contains(&middle): " << ring.Contains(&middle) << std::endl;
std::cout << "ring.Within(&middle): " << ring.Within(&middle) << std::endl;
Output:
**********************************************
middle.Contains(&ring): 0
middle.Within(&ring): 1
ring.Contains(&middle): 1
ring.Within(&middle): 0
Additionally, if changes to the docs are going to be made, it could be noted that an geometry is considered to be within/contained with itself (that is, points "on the line" count as in).