A foul ball is a batted ball that lands outside the limits of the baselines.
Regarding batter swings and is hit by pitch, this is an excerpt from Major League Rulebook, 2011 Edition.
I have placed (**** before and after the rule--6.05f that I believe applies):
“ 6.05 A batter is out when—
(a) His fair or foul fly ball (other than a foul tip) is legally caught by a fielder;
Rule 6.05(a) Comment: A fielder may reach into, but not step into, a dugout to make a catch,
and if he holds the ball, the catch shall be allowed. A fielder, in order to make a catch on a foul ball
nearing a dugout or other out-of-play area (such as the stands), must have one or both feet on or over
the playing surface (including the lip of the dugout) and neither foot on the ground inside the dugout
or in any other out-of-play area. Ball is in play, unless the fielder, after making a legal catch, falls
into a dugout or other out-of-play area, in which case the ball is dead. Status of runners shall be as
described in Rule 7.04(c) Comment.
(b) A third strike is legally caught by the catcher;
Rule 6.05(b) Comment: “Legally caught” means in the catcher’s glove before the ball touches the
ground. It is not legal if the ball lodges in his clothing or paraphernalia; or if it touches the umpire and is
caught by the catcher on the rebound.
If a foul tip first strikes the catcher’s glove and then goes on through and is caught by both hands
against his body or protector, before the ball touches the ground, it is a strike, and if third strike, batter is
out. If smothered against his body or protector, it is a catch provided the ball struck the catcher’s glove
or hand first.
(c) A third strike is not caught by the catcher when first base is occupied before two are
(d) He bunts foul on third strike;
(e) An Infield Fly is declared;
********(f) He attempts to hit a third strike and the ball touches him;**************
(g) His fair ball touches him before touching a fielder. If the batter is in a legal position
in the batter’s box, see Rule 6.03, and, in the umpire’s judgment, there was no
intention to interfere with the course of the ball, a batted ball that strikes the batter
or his bat shall be ruled a foul ball;
(h) After hitting or bunting a fair ball, his bat hits the ball a second time in fair territory.
The ball is dead and no runners may advance. If the batter-runner drops his bat and
the ball rolls against the bat in fair territory and, in the umpire’s judgment, there was
no intention to interfere with the course of the ball, the ball is alive and in play. If
the batter is in a legal position in the batter’s box, see Rule 6.03, and, in the
umpire’s judgment, there was no intention to interfere with the course of the ball, a
batted ball that strikes the batter or his bat shall be ruled a foul ball; “ End quote
That's the closest I can get.