Conformal theory of the two-dimensional O(N) model with ordinary, extraordinary, and special boundary conditions