How to abstract matrix

Basically what i wanna do is to get the current matrix on the stack.
Is there any method that returns the matrix?
what does glPopMatrix() return?

Use glGetFloatv(GLenum pname, GLfloat *params) where pname is either GL_MODELVIEW_MATRIX or GL_PROJECTION_MATRIX and params is a pointer to a 4x4 matrix of GLfloat or equivalent size of equivalent type where you want matrix to be stored.