Repeatedly in a grapple, you need to make opposed grapple checks against an opponent. A grapple check is something like a melee attack roll.
SNIP
When you are grappling (regardless of who started the grapple), you can make an opposed grapple check as an attack. If you win, you can do the following:
Damage Your Opponent: You deal damage as with an unarmed strike (1d3 points for Medium-size attackers or 1d2 points for Small attackers, plus Strength modifiers). If you want to deal normal damage, you suffer a –4 penalty on your grapple check.
Pin: You hold your opponent immobile for 1 round. (If you get multiple attacks, you can use subsequent attacks to damage your opponent. You can’t use a weapon on a pinned character or attempt to damage or pin a second opponent while holding a pin on the first.) While you’re pinned, opponents other than the one pinning you get a +4 bonus on attack rolls against you (but you’re not helpless).
Break Another’s Pin: You can break the hold that an opponent has over an ally.
Escape: You can escape the grapple. You can take whatever movement you get. If more than one opponent is grappling you, your grapple check result has to beat all their check results to escape. (Opponents don’t have to try to hold you if they don’t want to.)
Pinned: When an opponent has pinned you, you are held immobile (but not helpless) for 1 round. You can make an opposed grapple check as a melee attack. If you win, you escape the pin, but you’re still grappling.
SNIP
Wriggle Free: You can make an Escape Artist check (opposed by your opponent’s grapple check) to get out of a grapple or out of being pinned (so that you’re just being grappled). Doing so counts as a standard action; if you escape a grapple, you can also move in the same round.