Systems described by an O(n) symmetrical phi(4) Hamiltonian are considered in a d-dimensional film geometry at their bulk critical points. The critical Casimir forces between the film's boundary planes B(j), j = 1,2, are investigated as functions of film thickness L for generic symmetry-preserving boundary conditions partial derivative(n)phi = (c) over circle (j)phi. The L-dependent part of the reduced excess free energy per cross-sectional area takes the scaling form f(res) approximate to D(c(1)L(Phi/nu),c(2)L(Phi/nu))/L(d-1) when d < 4, where c(i) are scaling fields associated with the variables (c) over circle (i) and Phi is a surface crossover exponent. Explicit two-loop renormalization group results for the function D(c(1), c(2)) at d = 4 - epsilon dimensions are presented. These show that (i) the Casimir force can have either sign, depending on c(1) and c(2), and (ii) for appropriate choices of the enhancements (c) over circle (j), crossovers from attraction to repulsion and vice versa occur as L increases.