Exhaled air is about 17% oxygen, 4% carbon dioxide. So, as previous poster noted, scrubbing the CO2 is your first priority. You can't breathe air with greater than about 4% CO2 indefinitely. Oxygen levels lower than 15% are also bad.
Diving rebreathers are an interesting implementation of these rules in that they are lethal if you get it wrong.