Exact solutions for the buckling and postbuckling of shear-deformable beams