# Generalised Subdivision of surfaces - where am I going wrong?

/* Rename the file and save as gendiv.c */

#include<stdio.h>
#include<stdlib.h>
#include<GL/glut.h>
#include<X11/X.h>
#include<X11/Xlib.h>
#include<GL/gl.h>
#include<GL/glx.h>
#include<GL/glu.h>
#include<math.h>

main() {
/* Generalized Subdivision */

void subdivide(float u1[2], float u2[2], float u3[2],
float cutoff, long depth)
{
GLfloat v1[3], v2[3], v3[3], n1[3], n2[3], n3[3];
GLfloat u12[2], u23[2], u32[2];
GLint i;

if (depth == maxdepth || (curv(u1) < cutoff &&
curv(u2) < cutoff && curv(u3) < cutoff)) {
surf(u1, v1, n1); surf(u2, v2, n2); surf(u3, v3, n3);
glBegin(GL_POLYGON);
glNormal3fv(n1); glVertex3fv(v1);
glNormal3fv(n2); glVertex3fv(v2);
glNormal3fv(n3); glVertex3fv(v3);
glEnd();
return;
}
for (i = 0; i < 2; i++) {
u12[i] = (u1[i] + u2[i])/2.0;
u23[i] = (u2[i] + u3[i])/2.0;
u31[i] = (u3[i] + u1[i])/2.0;
}
subdivide(u1, u12, u31, cutoff, depth+1);
subdivide(u2, u23, u12, cutoff, depth+1);
subdivide(u3, u31, u23, cutoff, depth+1);
subdivide(u12, u23, u31, cutoff, depth+1);
}

return 0;
}

What do you expect this code to do?
surf() is undefined, subdivide() is never called, moreover it`s defined inside main() while C / C++ explicitly prohibit nested functions.
OpenGL is left uninitialized, no window is createdâ€¦ this code is just utterly incapable of working.

Okay, please feel free to remove the main and return nest, and make it draw what it is supposed to draw, sudivide faces, in a window.