t_canvas *z = canvas_getcurrent();
iirc, it's only allowed to call this in the constructor ...
a t_canvas is a _glist possibly you can access it with z->gl_name ... (have a look at g_canvas.h for implementation details) but be aware that you are not allowed to include g_canvas.h, since it's a private header... so your binaries will only work with different versions of pd
hth .... tim