Browse files

Updated Mongoose HTTP library.

Workaround for Windows Mongoose hang-at-shutdown problem.
Logging fixup - space after function name.
GL, GLX, WGL API updates.
Support REGAL_NO_HTTP at build-time and runtime.
  • Loading branch information...
1 parent 994fa02 commit bbb623db61c957e47ae3eafc85b184027384924d @nigels-com nigels-com committed Sep 29, 2012
View
10 Makefile
@@ -47,12 +47,6 @@ debug: regal.lib
export:
scripts/Export.py --api gl 4.2 --api wgl 4.0 --api glx 4.0 --api cgl 1.4 --api egl 1.0 --outdir src/regal
-# Disable mongoose and Regal HTTP for NaCL build
-
-ifneq ($(filter nacl%,$(SYSTEM)),)
-CFLAGS += -DREGAL_NO_HTTP
-endif
-
#
LIB.LDFLAGS := -lstdc++ -lpthread -ldl -lm
@@ -85,7 +79,9 @@ LIB.SRCS += src/regal/RegalDispatchMissing.cpp
LIB.SRCS += src/regal/RegalHttp.cpp
LIB.SRCS += src/regal/RegalFavicon.cpp
-ifeq ($(filter -DREGAL_NO_HTTP%,$(CFLAGS)),)
+# Disable mongoose and Regal HTTP for NaCL build
+
+ifeq ($(filter nacl%,$(SYSTEM)),)
LIB.SRCS += src/mongoose/mongoose.c
endif
View
2 Makefile.nacl
@@ -101,8 +101,6 @@ LIB.SOBJS := $(addprefix tmp/$(SYSTEM)/regal/shared/,$(LIB.SRCS.NAMES))
LIB.SOBJS := $(LIB.SOBJS:.c=.o)
LIB.SOBJS := $(LIB.SOBJS:.cpp=.o)
-CFLAGS += -DREGAL_NO_HTTP
-
regal.lib: lib lib/$(LIB.SHARED) lib/$(LIB.STATIC)
lib:
View
303 include/GL/Regal.h
@@ -4856,6 +4856,18 @@ REGAL_DECL void REGAL_CALL glSamplerParameteriv(GLuint sampler, GLenum pname, co
#define GL_ARB_separate_shader_objects 1
#endif
+#ifndef REGAL_NO_ENUM_GL_ARB_SEPARATE_SHADER_OBJECTS
+#define GL_VERTEX_SHADER_BIT 0x1
+#define GL_TESS_EVALUATION_SHADER_BIT 0x10 /* 16 */
+#define GL_FRAGMENT_SHADER_BIT 0x2
+#define GL_GEOMETRY_SHADER_BIT 0x4
+#define GL_TESS_CONTROL_SHADER_BIT 0x8
+#define GL_PROGRAM_SEPARABLE 0x8258 /* 33368 */
+#define GL_ACTIVE_PROGRAM 0x8259 /* 33369 */
+#define GL_PROGRAM_PIPELINE_BINDING 0x825a /* 33370 */
+#define GL_ALL_SHADER_BITS 0xffffffff /* 4294967295 */
+#endif
+
#ifndef REGAL_NO_TYPEDEF_GL_ARB_SEPARATE_SHADER_OBJECTS
typedef GLboolean (REGAL_CALL *PFNGLISPROGRAMPIPELINEPROC)(GLuint pipeline);
typedef GLuint (REGAL_CALL *PFNGLCREATESHADERPROGRAMVPROC)(GLenum type, GLsizei count, const GLchar **strings);
@@ -6526,8 +6538,7 @@ REGAL_DECL void REGAL_CALL glTexImage3DMultisample(GLenum target, GLsizei sample
#endif
#ifndef REGAL_NO_ENUM_GL_ARB_TEXTURE_RGB10_A2UI
-#define GL_RGB10_A2UI 0x906f /* 36975 */
-#define GL_RGB10_A2UI 0x906f /* 36975 */
+#define GL_RGB10_A2UI 0x906f /* 36975 */
#endif
/**
@@ -10002,6 +10013,7 @@ typedef void (REGAL_CALL *PFNGLGETNAMEDPROGRAMLOCALPARAMETERIUIVEXTPROC)(GLuint
typedef void (REGAL_CALL *PFNGLGETNAMEDPROGRAMSTRINGEXTPROC)(GLuint program, GLenum target, GLenum pname, GLvoid *string);
typedef void (REGAL_CALL *PFNGLGETNAMEDRENDERBUFFERPARAMETERIVEXTPROC)(GLuint renderbuffer, GLenum pname, GLint *params);
typedef void (REGAL_CALL *PFNGLGETPOINTERINDEXEDVEXTPROC)(GLenum target, GLuint index, GLvoid **data);
+typedef void (REGAL_CALL *PFNGLGETPOINTERI_VEXTPROC)(GLenum pname, GLuint index, GLvoid **params);
typedef void (REGAL_CALL *PFNGLGETTEXTUREIMAGEEXTPROC)(GLuint texture, GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels);
typedef void (REGAL_CALL *PFNGLGETTEXTURELEVELPARAMETERFVEXTPROC)(GLuint texture, GLenum target, GLint level, GLenum pname, GLfloat *params);
typedef void (REGAL_CALL *PFNGLGETTEXTURELEVELPARAMETERIVEXTPROC)(GLuint texture, GLenum target, GLint level, GLenum pname, GLint *params);
@@ -10231,6 +10243,7 @@ typedef void (REGAL_CALL *PFNGLVERTEXARRAYVERTEXOFFSETEXTPROC)(GLuint vaobj, GLu
#define glGetNamedProgramivEXT rglGetNamedProgramivEXT
#define glGetNamedRenderbufferParameterivEXT rglGetNamedRenderbufferParameterivEXT
#define glGetPointerIndexedvEXT rglGetPointerIndexedvEXT
+#define glGetPointeri_vEXT rglGetPointeri_vEXT
#define glGetTextureImageEXT rglGetTextureImageEXT
#define glGetTextureLevelParameterfvEXT rglGetTextureLevelParameterfvEXT
#define glGetTextureLevelParameterivEXT rglGetTextureLevelParameterivEXT
@@ -10466,6 +10479,7 @@ REGAL_DECL void REGAL_CALL glGetNamedProgramStringEXT(GLuint program, GLenum tar
REGAL_DECL void REGAL_CALL glGetNamedProgramivEXT(GLuint program, GLenum target, GLenum pname, GLint *params);
REGAL_DECL void REGAL_CALL glGetNamedRenderbufferParameterivEXT(GLuint renderbuffer, GLenum pname, GLint *params);
REGAL_DECL void REGAL_CALL glGetPointerIndexedvEXT(GLenum target, GLuint index, GLvoid **data);
+REGAL_DECL void REGAL_CALL glGetPointeri_vEXT(GLenum pname, GLuint index, GLvoid **params);
REGAL_DECL void REGAL_CALL glGetTextureImageEXT(GLuint texture, GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels);
REGAL_DECL void REGAL_CALL glGetTextureLevelParameterfvEXT(GLuint texture, GLenum target, GLint level, GLenum pname, GLfloat *params);
REGAL_DECL void REGAL_CALL glGetTextureLevelParameterivEXT(GLuint texture, GLenum target, GLint level, GLenum pname, GLint *params);
@@ -11899,16 +11913,10 @@ REGAL_DECL void REGAL_CALL glSamplePatternEXT(GLenum pattern);
#define GL_COLOR_TABLE_LUMINANCE_SIZE_EXT 0x80de /* 32990 */
#define GL_COLOR_TABLE_INTENSITY_SIZE_EXT 0x80df /* 32991 */
#define GL_COLOR_INDEX1_EXT 0x80e2 /* 32994 */
-#define GL_COLOR_INDEX1_EXT 0x80e2 /* 32994 */
-#define GL_COLOR_INDEX2_EXT 0x80e3 /* 32995 */
#define GL_COLOR_INDEX2_EXT 0x80e3 /* 32995 */
#define GL_COLOR_INDEX4_EXT 0x80e4 /* 32996 */
-#define GL_COLOR_INDEX4_EXT 0x80e4 /* 32996 */
-#define GL_COLOR_INDEX8_EXT 0x80e5 /* 32997 */
#define GL_COLOR_INDEX8_EXT 0x80e5 /* 32997 */
#define GL_COLOR_INDEX12_EXT 0x80e6 /* 32998 */
-#define GL_COLOR_INDEX12_EXT 0x80e6 /* 32998 */
-#define GL_COLOR_INDEX16_EXT 0x80e7 /* 32999 */
#define GL_COLOR_INDEX16_EXT 0x80e7 /* 32999 */
#define GL_TEXTURE_INDEX_SIZE_EXT 0x80ed /* 33005 */
#define GL_TEXTURE_CUBE_MAP_ARB 0x8513 /* 34067 */
@@ -12009,21 +12017,27 @@ REGAL_DECL void REGAL_CALL glGetColorTableParameterivEXT(GLenum target, GLenum p
typedef void (REGAL_CALL *PFNGLGETPIXELTRANSFORMPARAMETERFVEXTPROC)(GLenum target, GLenum pname, const GLfloat *params);
typedef void (REGAL_CALL *PFNGLGETPIXELTRANSFORMPARAMETERIVEXTPROC)(GLenum target, GLenum pname, const GLint *params);
typedef void (REGAL_CALL *PFNGLPIXELTRANSFORMPARAMETERFEXTPROC)(GLenum target, GLenum pname, const GLfloat param);
+typedef void (REGAL_CALL *PFNGLPIXELTRANSFORMPARAMETERFVEXTPROC)(GLenum target, GLenum pname, const GLfloat *params);
typedef void (REGAL_CALL *PFNGLPIXELTRANSFORMPARAMETERIEXTPROC)(GLenum target, GLenum pname, const GLint param);
+typedef void (REGAL_CALL *PFNGLPIXELTRANSFORMPARAMETERIVEXTPROC)(GLenum target, GLenum pname, const GLint *params);
#endif
#ifndef REGAL_NO_NAMESPACE_GL_EXT_PIXEL_TRANSFORM
#define glGetPixelTransformParameterfvEXT rglGetPixelTransformParameterfvEXT
#define glGetPixelTransformParameterivEXT rglGetPixelTransformParameterivEXT
#define glPixelTransformParameterfEXT rglPixelTransformParameterfEXT
+#define glPixelTransformParameterfvEXT rglPixelTransformParameterfvEXT
#define glPixelTransformParameteriEXT rglPixelTransformParameteriEXT
+#define glPixelTransformParameterivEXT rglPixelTransformParameterivEXT
#endif
#ifndef REGAL_NO_DECLARATION_GL_EXT_PIXEL_TRANSFORM
REGAL_DECL void REGAL_CALL glGetPixelTransformParameterfvEXT(GLenum target, GLenum pname, const GLfloat *params);
REGAL_DECL void REGAL_CALL glGetPixelTransformParameterivEXT(GLenum target, GLenum pname, const GLint *params);
REGAL_DECL void REGAL_CALL glPixelTransformParameterfEXT(GLenum target, GLenum pname, const GLfloat param);
+REGAL_DECL void REGAL_CALL glPixelTransformParameterfvEXT(GLenum target, GLenum pname, const GLfloat *params);
REGAL_DECL void REGAL_CALL glPixelTransformParameteriEXT(GLenum target, GLenum pname, const GLint param);
+REGAL_DECL void REGAL_CALL glPixelTransformParameterivEXT(GLenum target, GLenum pname, const GLint *params);
#endif
/**
@@ -14947,6 +14961,7 @@ typedef void (REGAL_CALL *PFNGLGETOBJECTLABELPROC)(GLenum identifier, GLuint nam
typedef void (REGAL_CALL *PFNGLGETOBJECTPTRLABELPROC)(GLvoid *ptr, GLsizei bufSize, GLsizei *length, GLchar *label);
typedef void (REGAL_CALL *PFNGLOBJECTLABELPROC)(GLenum identifier, GLuint name, GLsizei length, const GLchar *label);
typedef void (REGAL_CALL *PFNGLOBJECTPTRLABELPROC)(GLvoid *ptr, GLsizei length, const GLchar *label);
+typedef void (REGAL_CALL *PFNGLPOPDEBUGGROUPPROC)(void);
typedef void (REGAL_CALL *PFNGLPUSHDEBUGGROUPPROC)(GLenum source, GLuint id, GLsizei length, const GLchar *message);
#endif
@@ -14959,6 +14974,7 @@ typedef void (REGAL_CALL *PFNGLPUSHDEBUGGROUPPROC)(GLenum source, GLuint id, GLs
#define glGetObjectPtrLabel rglGetObjectPtrLabel
#define glObjectLabel rglObjectLabel
#define glObjectPtrLabel rglObjectPtrLabel
+#define glPopDebugGroup rglPopDebugGroup
#define glPushDebugGroup rglPushDebugGroup
#endif
@@ -14971,6 +14987,7 @@ REGAL_DECL void REGAL_CALL glGetObjectLabel(GLenum identifier, GLuint name, GLsi
REGAL_DECL void REGAL_CALL glGetObjectPtrLabel(GLvoid *ptr, GLsizei bufSize, GLsizei *length, GLchar *label);
REGAL_DECL void REGAL_CALL glObjectLabel(GLenum identifier, GLuint name, GLsizei length, const GLchar *label);
REGAL_DECL void REGAL_CALL glObjectPtrLabel(GLvoid *ptr, GLsizei length, const GLchar *label);
+REGAL_DECL void REGAL_CALL glPopDebugGroup(void);
REGAL_DECL void REGAL_CALL glPushDebugGroup(GLenum source, GLuint id, GLsizei length, const GLchar *message);
#endif
@@ -15317,6 +15334,45 @@ REGAL_DECL void REGAL_CALL glWindowPos4svMESA(const GLshort *v);
#endif
/**
+ ** GL_NVX_conditional_render
+ **/
+
+#if (defined(GL_NVX_CONDITIONAL_RENDER) || defined(REGAL_NO_ENUM) || defined(REGAL_NO_GL_NVX_CONDITIONAL_RENDER)) && !defined(REGAL_NO_ENUM_GL_NVX_CONDITIONAL_RENDER)
+#define REGAL_NO_ENUM_GL_NVX_CONDITIONAL_RENDER
+#endif
+
+#if (defined(GL_NVX_CONDITIONAL_RENDER) || defined(REGAL_NO_TYPEDEF) || defined(REGAL_NO_GL_NVX_CONDITIONAL_RENDER)) && !defined(REGAL_NO_TYPEDEF_GL_NVX_CONDITIONAL_RENDER)
+#define REGAL_NO_TYPEDEF_GL_NVX_CONDITIONAL_RENDER
+#endif
+
+#if (defined(GL_NVX_CONDITIONAL_RENDER) || !defined(REGAL_NAMESPACE) || defined(REGAL_NO_GL_NVX_CONDITIONAL_RENDER)) && !defined(REGAL_NO_NAMESPACE_GL_NVX_CONDITIONAL_RENDER)
+#define REGAL_NO_NAMESPACE_GL_NVX_CONDITIONAL_RENDER
+#endif
+
+#if (defined(GL_NVX_CONDITIONAL_RENDER) || defined(REGAL_NO_DECLARATION) || defined(REGAL_NO_GL_NVX_CONDITIONAL_RENDER)) && !defined(REGAL_NO_DECLARATION_GL_NVX_CONDITIONAL_RENDER)
+#define REGAL_NO_DECLARATION_GL_NVX_CONDITIONAL_RENDER
+#endif
+
+#ifndef GL_NVX_conditional_render
+#define GL_NVX_conditional_render 1
+#endif
+
+#ifndef REGAL_NO_TYPEDEF_GL_NVX_CONDITIONAL_RENDER
+typedef void (REGAL_CALL *PFNGLBEGINCONDITIONALRENDERNVXPROC)(GLuint id);
+typedef void (REGAL_CALL *PFNGLENDCONDITIONALRENDERNVXPROC)(void);
+#endif
+
+#ifndef REGAL_NO_NAMESPACE_GL_NVX_CONDITIONAL_RENDER
+#define glBeginConditionalRenderNVX rglBeginConditionalRenderNVX
+#define glEndConditionalRenderNVX rglEndConditionalRenderNVX
+#endif
+
+#ifndef REGAL_NO_DECLARATION_GL_NVX_CONDITIONAL_RENDER
+REGAL_DECL void REGAL_CALL glBeginConditionalRenderNVX(GLuint id);
+REGAL_DECL void REGAL_CALL glEndConditionalRenderNVX(void);
+#endif
+
+/**
** GL_NVX_gpu_memory_info
**/
@@ -15421,6 +15477,35 @@ REGAL_DECL void REGAL_CALL glUniformHandleui64vNV(GLint location, GLsizei count,
#endif
/**
+ ** GL_NV_compute_program5
+ **/
+
+#if (defined(GL_NV_COMPUTE_PROGRAM5) || defined(REGAL_NO_ENUM) || defined(REGAL_NO_GL_NV_COMPUTE_PROGRAM5)) && !defined(REGAL_NO_ENUM_GL_NV_COMPUTE_PROGRAM5)
+#define REGAL_NO_ENUM_GL_NV_COMPUTE_PROGRAM5
+#endif
+
+#if (defined(GL_NV_COMPUTE_PROGRAM5) || defined(REGAL_NO_TYPEDEF) || defined(REGAL_NO_GL_NV_COMPUTE_PROGRAM5)) && !defined(REGAL_NO_TYPEDEF_GL_NV_COMPUTE_PROGRAM5)
+#define REGAL_NO_TYPEDEF_GL_NV_COMPUTE_PROGRAM5
+#endif
+
+#if (defined(GL_NV_COMPUTE_PROGRAM5) || !defined(REGAL_NAMESPACE) || defined(REGAL_NO_GL_NV_COMPUTE_PROGRAM5)) && !defined(REGAL_NO_NAMESPACE_GL_NV_COMPUTE_PROGRAM5)
+#define REGAL_NO_NAMESPACE_GL_NV_COMPUTE_PROGRAM5
+#endif
+
+#if (defined(GL_NV_COMPUTE_PROGRAM5) || defined(REGAL_NO_DECLARATION) || defined(REGAL_NO_GL_NV_COMPUTE_PROGRAM5)) && !defined(REGAL_NO_DECLARATION_GL_NV_COMPUTE_PROGRAM5)
+#define REGAL_NO_DECLARATION_GL_NV_COMPUTE_PROGRAM5
+#endif
+
+#ifndef GL_NV_compute_program5
+#define GL_NV_compute_program5 1
+#endif
+
+#ifndef REGAL_NO_ENUM_GL_NV_COMPUTE_PROGRAM5
+#define GL_COMPUTE_PROGRAM_NV 0x90fb /* 37115 */
+#define GL_COMPUTE_PROGRAM_PARAMETER_BUFFER_NV 0x90fc /* 37116 */
+#endif
+
+/**
** GL_NV_conditional_render
**/
@@ -15532,6 +15617,35 @@ REGAL_DECL void REGAL_CALL glCopyImageSubDataNV(GLuint srcName, GLenum srcTarget
#endif
/**
+ ** GL_NV_deep_texture3D
+ **/
+
+#if (defined(GL_NV_DEEP_TEXTURE3D) || defined(REGAL_NO_ENUM) || defined(REGAL_NO_GL_NV_DEEP_TEXTURE3D)) && !defined(REGAL_NO_ENUM_GL_NV_DEEP_TEXTURE3D)
+#define REGAL_NO_ENUM_GL_NV_DEEP_TEXTURE3D
+#endif
+
+#if (defined(GL_NV_DEEP_TEXTURE3D) || defined(REGAL_NO_TYPEDEF) || defined(REGAL_NO_GL_NV_DEEP_TEXTURE3D)) && !defined(REGAL_NO_TYPEDEF_GL_NV_DEEP_TEXTURE3D)
+#define REGAL_NO_TYPEDEF_GL_NV_DEEP_TEXTURE3D
+#endif
+
+#if (defined(GL_NV_DEEP_TEXTURE3D) || !defined(REGAL_NAMESPACE) || defined(REGAL_NO_GL_NV_DEEP_TEXTURE3D)) && !defined(REGAL_NO_NAMESPACE_GL_NV_DEEP_TEXTURE3D)
+#define REGAL_NO_NAMESPACE_GL_NV_DEEP_TEXTURE3D
+#endif
+
+#if (defined(GL_NV_DEEP_TEXTURE3D) || defined(REGAL_NO_DECLARATION) || defined(REGAL_NO_GL_NV_DEEP_TEXTURE3D)) && !defined(REGAL_NO_DECLARATION_GL_NV_DEEP_TEXTURE3D)
+#define REGAL_NO_DECLARATION_GL_NV_DEEP_TEXTURE3D
+#endif
+
+#ifndef GL_NV_deep_texture3D
+#define GL_NV_deep_texture3D 1
+#endif
+
+#ifndef REGAL_NO_ENUM_GL_NV_DEEP_TEXTURE3D
+#define GL_MAX_DEEP_3D_TEXTURE_WIDTH_HEIGHT_NV 0x90d0 /* 37072 */
+#define GL_MAX_DEEP_3D_TEXTURE_DEPTH_NV 0x90d1 /* 37073 */
+#endif
+
+/**
** GL_NV_depth_buffer_float
**/
@@ -18869,6 +18983,34 @@ REGAL_DECL void REGAL_CALL glVertexAttribs4ubvNV(GLuint index, GLsizei n, const
#endif
/**
+ ** GL_NV_vertex_program4
+ **/
+
+#if (defined(GL_NV_VERTEX_PROGRAM4) || defined(REGAL_NO_ENUM) || defined(REGAL_NO_GL_NV_VERTEX_PROGRAM4)) && !defined(REGAL_NO_ENUM_GL_NV_VERTEX_PROGRAM4)
+#define REGAL_NO_ENUM_GL_NV_VERTEX_PROGRAM4
+#endif
+
+#if (defined(GL_NV_VERTEX_PROGRAM4) || defined(REGAL_NO_TYPEDEF) || defined(REGAL_NO_GL_NV_VERTEX_PROGRAM4)) && !defined(REGAL_NO_TYPEDEF_GL_NV_VERTEX_PROGRAM4)
+#define REGAL_NO_TYPEDEF_GL_NV_VERTEX_PROGRAM4
+#endif
+
+#if (defined(GL_NV_VERTEX_PROGRAM4) || !defined(REGAL_NAMESPACE) || defined(REGAL_NO_GL_NV_VERTEX_PROGRAM4)) && !defined(REGAL_NO_NAMESPACE_GL_NV_VERTEX_PROGRAM4)
+#define REGAL_NO_NAMESPACE_GL_NV_VERTEX_PROGRAM4
+#endif
+
+#if (defined(GL_NV_VERTEX_PROGRAM4) || defined(REGAL_NO_DECLARATION) || defined(REGAL_NO_GL_NV_VERTEX_PROGRAM4)) && !defined(REGAL_NO_DECLARATION_GL_NV_VERTEX_PROGRAM4)
+#define REGAL_NO_DECLARATION_GL_NV_VERTEX_PROGRAM4
+#endif
+
+#ifndef GL_NV_vertex_program4
+#define GL_NV_vertex_program4 1
+#endif
+
+#ifndef REGAL_NO_ENUM_GL_NV_VERTEX_PROGRAM4
+#define GL_VERTEX_ATTRIB_ARRAY_INTEGER_NV 0x88fd /* 35069 */
+#endif
+
+/**
** GL_NV_video_capture
**/
@@ -19036,6 +19178,57 @@ REGAL_DECL void REGAL_CALL glVideoCaptureStreamParameterivNV(GLuint video_captur
#endif
/**
+ ** GL_OES_single_precision
+ **/
+
+#if (defined(GL_OES_SINGLE_PRECISION) || defined(REGAL_NO_ENUM) || defined(REGAL_NO_GL_OES_SINGLE_PRECISION)) && !defined(REGAL_NO_ENUM_GL_OES_SINGLE_PRECISION)
+#define REGAL_NO_ENUM_GL_OES_SINGLE_PRECISION
+#endif
+
+#if (defined(GL_OES_SINGLE_PRECISION) || defined(REGAL_NO_TYPEDEF) || defined(REGAL_NO_GL_OES_SINGLE_PRECISION)) && !defined(REGAL_NO_TYPEDEF_GL_OES_SINGLE_PRECISION)
+#define REGAL_NO_TYPEDEF_GL_OES_SINGLE_PRECISION
+#endif
+
+#if (defined(GL_OES_SINGLE_PRECISION) || !defined(REGAL_NAMESPACE) || defined(REGAL_NO_GL_OES_SINGLE_PRECISION)) && !defined(REGAL_NO_NAMESPACE_GL_OES_SINGLE_PRECISION)
+#define REGAL_NO_NAMESPACE_GL_OES_SINGLE_PRECISION
+#endif
+
+#if (defined(GL_OES_SINGLE_PRECISION) || defined(REGAL_NO_DECLARATION) || defined(REGAL_NO_GL_OES_SINGLE_PRECISION)) && !defined(REGAL_NO_DECLARATION_GL_OES_SINGLE_PRECISION)
+#define REGAL_NO_DECLARATION_GL_OES_SINGLE_PRECISION
+#endif
+
+#ifndef GL_OES_single_precision
+#define GL_OES_single_precision 1
+#endif
+
+#ifndef REGAL_NO_TYPEDEF_GL_OES_SINGLE_PRECISION
+typedef void (REGAL_CALL *PFNGLCLEARDEPTHFOESPROC)(GLclampd depth);
+typedef void (REGAL_CALL *PFNGLCLIPPLANEFOESPROC)(GLenum plane, const GLfloat *equation);
+typedef void (REGAL_CALL *PFNGLDEPTHRANGEFOESPROC)(GLclampf n, GLclampf f);
+typedef void (REGAL_CALL *PFNGLFRUSTUMFOESPROC)(GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f);
+typedef void (REGAL_CALL *PFNGLGETCLIPPLANEFOESPROC)(GLenum plane, GLfloat *equation);
+typedef void (REGAL_CALL *PFNGLORTHOFOESPROC)(GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f);
+#endif
+
+#ifndef REGAL_NO_NAMESPACE_GL_OES_SINGLE_PRECISION
+#define glClearDepthfOES rglClearDepthfOES
+#define glClipPlanefOES rglClipPlanefOES
+#define glDepthRangefOES rglDepthRangefOES
+#define glFrustumfOES rglFrustumfOES
+#define glGetClipPlanefOES rglGetClipPlanefOES
+#define glOrthofOES rglOrthofOES
+#endif
+
+#ifndef REGAL_NO_DECLARATION_GL_OES_SINGLE_PRECISION
+REGAL_DECL void REGAL_CALL glClearDepthfOES(GLclampd depth);
+REGAL_DECL void REGAL_CALL glClipPlanefOES(GLenum plane, const GLfloat *equation);
+REGAL_DECL void REGAL_CALL glDepthRangefOES(GLclampf n, GLclampf f);
+REGAL_DECL void REGAL_CALL glFrustumfOES(GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f);
+REGAL_DECL void REGAL_CALL glGetClipPlanefOES(GLenum plane, GLfloat *equation);
+REGAL_DECL void REGAL_CALL glOrthofOES(GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f);
+#endif
+
+/**
** GL_OML_interlace
**/
@@ -26049,6 +26242,34 @@ REGAL_DECL BOOL REGAL_CALL wglSetPbufferAttribARB(HPBUFFERARB hPbuffer, const in
#endif
/**
+ ** WGL_ARB_robustness_share_group_isolation
+ **/
+
+#if (defined(WGL_ARB_ROBUSTNESS_SHARE_GROUP_ISOLATION) || defined(REGAL_NO_ENUM) || defined(REGAL_NO_WGL_ARB_ROBUSTNESS_SHARE_GROUP_ISOLATION)) && !defined(REGAL_NO_ENUM_WGL_ARB_ROBUSTNESS_SHARE_GROUP_ISOLATION)
+#define REGAL_NO_ENUM_WGL_ARB_ROBUSTNESS_SHARE_GROUP_ISOLATION
+#endif
+
+#if (defined(WGL_ARB_ROBUSTNESS_SHARE_GROUP_ISOLATION) || defined(REGAL_NO_TYPEDEF) || defined(REGAL_NO_WGL_ARB_ROBUSTNESS_SHARE_GROUP_ISOLATION)) && !defined(REGAL_NO_TYPEDEF_WGL_ARB_ROBUSTNESS_SHARE_GROUP_ISOLATION)
+#define REGAL_NO_TYPEDEF_WGL_ARB_ROBUSTNESS_SHARE_GROUP_ISOLATION
+#endif
+
+#if (defined(WGL_ARB_ROBUSTNESS_SHARE_GROUP_ISOLATION) || !defined(REGAL_NAMESPACE) || defined(REGAL_NO_WGL_ARB_ROBUSTNESS_SHARE_GROUP_ISOLATION)) && !defined(REGAL_NO_NAMESPACE_WGL_ARB_ROBUSTNESS_SHARE_GROUP_ISOLATION)
+#define REGAL_NO_NAMESPACE_WGL_ARB_ROBUSTNESS_SHARE_GROUP_ISOLATION
+#endif
+
+#if (defined(WGL_ARB_ROBUSTNESS_SHARE_GROUP_ISOLATION) || defined(REGAL_NO_DECLARATION) || defined(REGAL_NO_WGL_ARB_ROBUSTNESS_SHARE_GROUP_ISOLATION)) && !defined(REGAL_NO_DECLARATION_WGL_ARB_ROBUSTNESS_SHARE_GROUP_ISOLATION)
+#define REGAL_NO_DECLARATION_WGL_ARB_ROBUSTNESS_SHARE_GROUP_ISOLATION
+#endif
+
+#ifndef WGL_ARB_robustness_share_group_isolation
+#define WGL_ARB_robustness_share_group_isolation 1
+#endif
+
+#ifndef REGAL_NO_ENUM_WGL_ARB_ROBUSTNESS_SHARE_GROUP_ISOLATION
+#define WGL_CONTEXT_RESET_ISOLATION_BIT_ARB 0x8
+#endif
+
+/**
** WGL_ATI_pixel_format_float
**/
@@ -27705,6 +27926,42 @@ REGAL_DECL int REGAL_CALL wglSetLayerPaletteEntries(HDC hDC, int iLayerPlane, in
#define GLX_GPU_NUM_SPI_AMD 0x21a8 /* 8616 */
#endif
+#ifndef REGAL_NO_TYPEDEF_GLX_AMD_GPU_ASSOCIATION
+typedef Bool (REGAL_CALL *PFNGLXDELETEASSOCIATEDCONTEXTAMDPROC)(GLXContext ctx);
+typedef Bool (REGAL_CALL *PFNGLXMAKEASSOCIATEDCONTEXTCURRENTAMDPROC)(GLXContext ctx);
+typedef GLXContext (REGAL_CALL *PFNGLXCREATEASSOCIATEDCONTEXTAMDPROC)(unsigned int id, GLXContext share_list);
+typedef GLXContext (REGAL_CALL *PFNGLXCREATEASSOCIATEDCONTEXTATTRIBSAMDPROC)(unsigned int id, GLXContext share_context, const int *attribList);
+typedef GLXContext (REGAL_CALL *PFNGLXGETCURRENTASSOCIATEDCONTEXTAMDPROC)(void);
+typedef int (REGAL_CALL *PFNGLXGETGPUINFOAMDPROC)(unsigned int id, int property, GLenum dataType, unsigned int size, GLvoid *data);
+typedef unsigned int (REGAL_CALL *PFNGLXGETCONTEXTGPUIDAMDPROC)(GLXContext ctx);
+typedef unsigned int (REGAL_CALL *PFNGLXGETGPUIDSAMDPROC)(unsigned int maxCount, unsigned int *ids);
+typedef void (REGAL_CALL *PFNGLXBLITCONTEXTFRAMEBUFFERAMDPROC)(GLXContext dstCtx, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
+#endif
+
+#ifndef REGAL_NO_NAMESPACE_GLX_AMD_GPU_ASSOCIATION
+#define glXBlitContextFramebufferAMD rglXBlitContextFramebufferAMD
+#define glXCreateAssociatedContextAMD rglXCreateAssociatedContextAMD
+#define glXCreateAssociatedContextAttribsAMD rglXCreateAssociatedContextAttribsAMD
+#define glXDeleteAssociatedContextAMD rglXDeleteAssociatedContextAMD
+#define glXGetContextGPUIDAMD rglXGetContextGPUIDAMD
+#define glXGetCurrentAssociatedContextAMD rglXGetCurrentAssociatedContextAMD
+#define glXGetGPUIDsAMD rglXGetGPUIDsAMD
+#define glXGetGPUInfoAMD rglXGetGPUInfoAMD
+#define glXMakeAssociatedContextCurrentAMD rglXMakeAssociatedContextCurrentAMD
+#endif
+
+#ifndef REGAL_NO_DECLARATION_GLX_AMD_GPU_ASSOCIATION
+REGAL_DECL Bool REGAL_CALL glXDeleteAssociatedContextAMD(GLXContext ctx);
+REGAL_DECL Bool REGAL_CALL glXMakeAssociatedContextCurrentAMD(GLXContext ctx);
+REGAL_DECL GLXContext REGAL_CALL glXCreateAssociatedContextAMD(unsigned int id, GLXContext share_list);
+REGAL_DECL GLXContext REGAL_CALL glXCreateAssociatedContextAttribsAMD(unsigned int id, GLXContext share_context, const int *attribList);
+REGAL_DECL GLXContext REGAL_CALL glXGetCurrentAssociatedContextAMD(void);
+REGAL_DECL int REGAL_CALL glXGetGPUInfoAMD(unsigned int id, int property, GLenum dataType, unsigned int size, GLvoid *data);
+REGAL_DECL unsigned int REGAL_CALL glXGetContextGPUIDAMD(GLXContext ctx);
+REGAL_DECL unsigned int REGAL_CALL glXGetGPUIDsAMD(unsigned int maxCount, unsigned int *ids);
+REGAL_DECL void REGAL_CALL glXBlitContextFramebufferAMD(GLXContext dstCtx, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
+#endif
+
/**
** GLX_ARB_create_context
**/
@@ -29010,30 +29267,30 @@ REGAL_DECL void REGAL_CALL glXReleaseVideoCaptureDeviceNV(Display *dpy, GLXVideo
#endif
/**
- ** GLX_NV_video_out
+ ** GLX_NV_video_output
**/
-#if (defined(GLX_NV_VIDEO_OUT) || defined(REGAL_NO_ENUM) || defined(REGAL_NO_GLX_NV_VIDEO_OUT)) && !defined(REGAL_NO_ENUM_GLX_NV_VIDEO_OUT)
-#define REGAL_NO_ENUM_GLX_NV_VIDEO_OUT
+#if (defined(GLX_NV_VIDEO_OUTPUT) || defined(REGAL_NO_ENUM) || defined(REGAL_NO_GLX_NV_VIDEO_OUTPUT)) && !defined(REGAL_NO_ENUM_GLX_NV_VIDEO_OUTPUT)
+#define REGAL_NO_ENUM_GLX_NV_VIDEO_OUTPUT
#endif
-#if (defined(GLX_NV_VIDEO_OUT) || defined(REGAL_NO_TYPEDEF) || defined(REGAL_NO_GLX_NV_VIDEO_OUT)) && !defined(REGAL_NO_TYPEDEF_GLX_NV_VIDEO_OUT)
-#define REGAL_NO_TYPEDEF_GLX_NV_VIDEO_OUT
+#if (defined(GLX_NV_VIDEO_OUTPUT) || defined(REGAL_NO_TYPEDEF) || defined(REGAL_NO_GLX_NV_VIDEO_OUTPUT)) && !defined(REGAL_NO_TYPEDEF_GLX_NV_VIDEO_OUTPUT)
+#define REGAL_NO_TYPEDEF_GLX_NV_VIDEO_OUTPUT
#endif
-#if (defined(GLX_NV_VIDEO_OUT) || !defined(REGAL_NAMESPACE) || defined(REGAL_NO_GLX_NV_VIDEO_OUT)) && !defined(REGAL_NO_NAMESPACE_GLX_NV_VIDEO_OUT)
-#define REGAL_NO_NAMESPACE_GLX_NV_VIDEO_OUT
+#if (defined(GLX_NV_VIDEO_OUTPUT) || !defined(REGAL_NAMESPACE) || defined(REGAL_NO_GLX_NV_VIDEO_OUTPUT)) && !defined(REGAL_NO_NAMESPACE_GLX_NV_VIDEO_OUTPUT)
+#define REGAL_NO_NAMESPACE_GLX_NV_VIDEO_OUTPUT
#endif
-#if (defined(GLX_NV_VIDEO_OUT) || defined(REGAL_NO_DECLARATION) || defined(REGAL_NO_GLX_NV_VIDEO_OUT)) && !defined(REGAL_NO_DECLARATION_GLX_NV_VIDEO_OUT)
-#define REGAL_NO_DECLARATION_GLX_NV_VIDEO_OUT
+#if (defined(GLX_NV_VIDEO_OUTPUT) || defined(REGAL_NO_DECLARATION) || defined(REGAL_NO_GLX_NV_VIDEO_OUTPUT)) && !defined(REGAL_NO_DECLARATION_GLX_NV_VIDEO_OUTPUT)
+#define REGAL_NO_DECLARATION_GLX_NV_VIDEO_OUTPUT
#endif
-#ifndef GLX_NV_video_out
-#define GLX_NV_video_out 1
+#ifndef GLX_NV_video_output
+#define GLX_NV_video_output 1
#endif
-#ifndef REGAL_NO_ENUM_GLX_NV_VIDEO_OUT
+#ifndef REGAL_NO_ENUM_GLX_NV_VIDEO_OUTPUT
#define GLX_VIDEO_OUT_COLOR_NV 0x20c3 /* 8387 */
#define GLX_VIDEO_OUT_ALPHA_NV 0x20c4 /* 8388 */
#define GLX_VIDEO_OUT_DEPTH_NV 0x20c5 /* 8389 */
@@ -29046,7 +29303,7 @@ REGAL_DECL void REGAL_CALL glXReleaseVideoCaptureDeviceNV(Display *dpy, GLXVideo
#define GLX_VIDEO_OUT_STACKED_FIELDS_2_1_NV 0x20cc /* 8396 */
#endif
-#ifndef REGAL_NO_TYPEDEF_GLX_NV_VIDEO_OUT
+#ifndef REGAL_NO_TYPEDEF_GLX_NV_VIDEO_OUTPUT
typedef int (REGAL_CALL *PFNGLXBINDVIDEOIMAGENVPROC)(Display *dpy, GLXVideoDeviceNV VideoDevice, GLXPbuffer pbuf, int iVideoBuffer);
typedef int (REGAL_CALL *PFNGLXGETVIDEODEVICENVPROC)(Display *dpy, int screen, int numVideoDevices, GLXVideoDeviceNV *pVideoDevice);
typedef int (REGAL_CALL *PFNGLXGETVIDEOINFONVPROC)(Display *dpy, int screen, GLXVideoDeviceNV VideoDevice, unsigned long *pulCounterOutputPbuffer, unsigned long *pulCounterOutputVideo);
@@ -29055,7 +29312,7 @@ typedef int (REGAL_CALL *PFNGLXRELEASEVIDEOIMAGENVPROC)(Display *dpy, GLXPbuffer
typedef int (REGAL_CALL *PFNGLXSENDPBUFFERTOVIDEONVPROC)(Display *dpy, GLXPbuffer pbuf, int iBufferType, unsigned long *pulCounterPbuffer, GLboolean bBlock);
#endif
-#ifndef REGAL_NO_NAMESPACE_GLX_NV_VIDEO_OUT
+#ifndef REGAL_NO_NAMESPACE_GLX_NV_VIDEO_OUTPUT
#define glXBindVideoImageNV rglXBindVideoImageNV
#define glXGetVideoDeviceNV rglXGetVideoDeviceNV
#define glXGetVideoInfoNV rglXGetVideoInfoNV
@@ -29064,7 +29321,7 @@ typedef int (REGAL_CALL *PFNGLXSENDPBUFFERTOVIDEONVPROC)(Display *dpy, GLXPbuffe
#define glXSendPbufferToVideoNV rglXSendPbufferToVideoNV
#endif
-#ifndef REGAL_NO_DECLARATION_GLX_NV_VIDEO_OUT
+#ifndef REGAL_NO_DECLARATION_GLX_NV_VIDEO_OUTPUT
REGAL_DECL int REGAL_CALL glXBindVideoImageNV(Display *dpy, GLXVideoDeviceNV VideoDevice, GLXPbuffer pbuf, int iVideoBuffer);
REGAL_DECL int REGAL_CALL glXGetVideoDeviceNV(Display *dpy, int screen, int numVideoDevices, GLXVideoDeviceNV *pVideoDevice);
REGAL_DECL int REGAL_CALL glXGetVideoInfoNV(Display *dpy, int screen, GLXVideoDeviceNV VideoDevice, unsigned long *pulCounterOutputPbuffer, unsigned long *pulCounterOutputVideo);
View
187 scripts/gl.py
@@ -4324,6 +4324,28 @@
defines.add(GL_TEXTURE_CUBE_MAP_SEAMLESS)
+# GL_ARB_separate_shader_objects
+
+GL_ACTIVE_PROGRAM = Enumerant('GL_ACTIVE_PROGRAM', 0x8259, 'GL_ARB_separate_shader_objects')
+GL_ALL_SHADER_BITS = Enumerant('GL_ALL_SHADER_BITS', 0xffffffff, 'GL_ARB_separate_shader_objects')
+GL_FRAGMENT_SHADER_BIT = Enumerant('GL_FRAGMENT_SHADER_BIT', 0x0002, 'GL_ARB_separate_shader_objects')
+GL_GEOMETRY_SHADER_BIT = Enumerant('GL_GEOMETRY_SHADER_BIT', 0x0004, 'GL_ARB_separate_shader_objects')
+GL_PROGRAM_PIPELINE_BINDING = Enumerant('GL_PROGRAM_PIPELINE_BINDING', 0x825a, 'GL_ARB_separate_shader_objects')
+GL_PROGRAM_SEPARABLE = Enumerant('GL_PROGRAM_SEPARABLE', 0x8258, 'GL_ARB_separate_shader_objects')
+GL_TESS_CONTROL_SHADER_BIT = Enumerant('GL_TESS_CONTROL_SHADER_BIT', 0x0008, 'GL_ARB_separate_shader_objects')
+GL_TESS_EVALUATION_SHADER_BIT = Enumerant('GL_TESS_EVALUATION_SHADER_BIT', 0x0010, 'GL_ARB_separate_shader_objects')
+GL_VERTEX_SHADER_BIT = Enumerant('GL_VERTEX_SHADER_BIT', 0x0001, 'GL_ARB_separate_shader_objects')
+
+defines.add(GL_ACTIVE_PROGRAM)
+defines.add(GL_ALL_SHADER_BITS)
+defines.add(GL_FRAGMENT_SHADER_BIT)
+defines.add(GL_GEOMETRY_SHADER_BIT)
+defines.add(GL_PROGRAM_PIPELINE_BINDING)
+defines.add(GL_PROGRAM_SEPARABLE)
+defines.add(GL_TESS_CONTROL_SHADER_BIT)
+defines.add(GL_TESS_EVALUATION_SHADER_BIT)
+defines.add(GL_VERTEX_SHADER_BIT)
+
# GL_ARB_shader_atomic_counters
GL_ACTIVE_ATOMIC_COUNTER_BUFFERS = Enumerant('GL_ACTIVE_ATOMIC_COUNTER_BUFFERS', 0x92d9, 'GL_ARB_shader_atomic_counters')
@@ -5143,10 +5165,8 @@
# GL_ARB_texture_rgb10_a2ui
GL_RGB10_A2UI = Enumerant('GL_RGB10_A2UI', 0x906f, 'GL_ARB_texture_rgb10_a2ui')
-GL_RGB10_A2UI = Enumerant('GL_RGB10_A2UI', 0x906f, 'GL_ARB_texture_rgb10_a2ui')
defines.add(GL_RGB10_A2UI)
-defines.add(GL_RGB10_A2UI)
# GL_ARB_texture_storage
@@ -6660,17 +6680,11 @@
# GL_EXT_paletted_texture
GL_COLOR_INDEX12_EXT = Enumerant('GL_COLOR_INDEX12_EXT', 0x80e6, 'GL_EXT_paletted_texture')
-GL_COLOR_INDEX12_EXT = Enumerant('GL_COLOR_INDEX12_EXT', 0x80e6, 'GL_EXT_paletted_texture')
GL_COLOR_INDEX16_EXT = Enumerant('GL_COLOR_INDEX16_EXT', 0x80e7, 'GL_EXT_paletted_texture')
-GL_COLOR_INDEX16_EXT = Enumerant('GL_COLOR_INDEX16_EXT', 0x80e7, 'GL_EXT_paletted_texture')
-GL_COLOR_INDEX1_EXT = Enumerant('GL_COLOR_INDEX1_EXT', 0x80e2, 'GL_EXT_paletted_texture')
GL_COLOR_INDEX1_EXT = Enumerant('GL_COLOR_INDEX1_EXT', 0x80e2, 'GL_EXT_paletted_texture')
GL_COLOR_INDEX2_EXT = Enumerant('GL_COLOR_INDEX2_EXT', 0x80e3, 'GL_EXT_paletted_texture')
-GL_COLOR_INDEX2_EXT = Enumerant('GL_COLOR_INDEX2_EXT', 0x80e3, 'GL_EXT_paletted_texture')
-GL_COLOR_INDEX4_EXT = Enumerant('GL_COLOR_INDEX4_EXT', 0x80e4, 'GL_EXT_paletted_texture')
GL_COLOR_INDEX4_EXT = Enumerant('GL_COLOR_INDEX4_EXT', 0x80e4, 'GL_EXT_paletted_texture')
GL_COLOR_INDEX8_EXT = Enumerant('GL_COLOR_INDEX8_EXT', 0x80e5, 'GL_EXT_paletted_texture')
-GL_COLOR_INDEX8_EXT = Enumerant('GL_COLOR_INDEX8_EXT', 0x80e5, 'GL_EXT_paletted_texture')
GL_COLOR_TABLE_ALPHA_SIZE_EXT = Enumerant('GL_COLOR_TABLE_ALPHA_SIZE_EXT', 0x80dd, 'GL_EXT_paletted_texture')
GL_COLOR_TABLE_BLUE_SIZE_EXT = Enumerant('GL_COLOR_TABLE_BLUE_SIZE_EXT', 0x80dc, 'GL_EXT_paletted_texture')
GL_COLOR_TABLE_FORMAT_EXT = Enumerant('GL_COLOR_TABLE_FORMAT_EXT', 0x80d8, 'GL_EXT_paletted_texture')
@@ -6686,17 +6700,11 @@
GL_TEXTURE_INDEX_SIZE_EXT = Enumerant('GL_TEXTURE_INDEX_SIZE_EXT', 0x80ed, 'GL_EXT_paletted_texture')
defines.add(GL_COLOR_INDEX12_EXT)
-defines.add(GL_COLOR_INDEX12_EXT)
defines.add(GL_COLOR_INDEX16_EXT)
-defines.add(GL_COLOR_INDEX16_EXT)
-defines.add(GL_COLOR_INDEX1_EXT)
defines.add(GL_COLOR_INDEX1_EXT)
defines.add(GL_COLOR_INDEX2_EXT)
-defines.add(GL_COLOR_INDEX2_EXT)
-defines.add(GL_COLOR_INDEX4_EXT)
defines.add(GL_COLOR_INDEX4_EXT)
defines.add(GL_COLOR_INDEX8_EXT)
-defines.add(GL_COLOR_INDEX8_EXT)
defines.add(GL_COLOR_TABLE_ALPHA_SIZE_EXT)
defines.add(GL_COLOR_TABLE_BLUE_SIZE_EXT)
defines.add(GL_COLOR_TABLE_FORMAT_EXT)
@@ -8253,6 +8261,14 @@
defines.add(GL_GPU_MEMORY_INFO_EVICTION_COUNT_NVX)
defines.add(GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX)
+# GL_NV_compute_program5
+
+GL_COMPUTE_PROGRAM_NV = Enumerant('GL_COMPUTE_PROGRAM_NV', 0x90fb, 'GL_NV_compute_program5')
+GL_COMPUTE_PROGRAM_PARAMETER_BUFFER_NV = Enumerant('GL_COMPUTE_PROGRAM_PARAMETER_BUFFER_NV', 0x90fc, 'GL_NV_compute_program5')
+
+defines.add(GL_COMPUTE_PROGRAM_NV)
+defines.add(GL_COMPUTE_PROGRAM_PARAMETER_BUFFER_NV)
+
# GL_NV_conditional_render
GL_QUERY_BY_REGION_NO_WAIT_NV = Enumerant('GL_QUERY_BY_REGION_NO_WAIT_NV', 0x8e16, 'GL_NV_conditional_render')
@@ -8273,6 +8289,14 @@
defines.add(GL_DEPTH_STENCIL_TO_BGRA_NV)
defines.add(GL_DEPTH_STENCIL_TO_RGBA_NV)
+# GL_NV_deep_texture3D
+
+GL_MAX_DEEP_3D_TEXTURE_DEPTH_NV = Enumerant('GL_MAX_DEEP_3D_TEXTURE_DEPTH_NV', 0x90d1, 'GL_NV_deep_texture3D')
+GL_MAX_DEEP_3D_TEXTURE_WIDTH_HEIGHT_NV = Enumerant('GL_MAX_DEEP_3D_TEXTURE_WIDTH_HEIGHT_NV', 0x90d0, 'GL_NV_deep_texture3D')
+
+defines.add(GL_MAX_DEEP_3D_TEXTURE_DEPTH_NV)
+defines.add(GL_MAX_DEEP_3D_TEXTURE_WIDTH_HEIGHT_NV)
+
# GL_NV_depth_buffer_float
GL_DEPTH32F_STENCIL8_NV = Enumerant('GL_DEPTH32F_STENCIL8_NV', 0x8dac, 'GL_NV_depth_buffer_float')
@@ -9735,6 +9759,12 @@
defines.add(MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB)
+# GL_NV_vertex_program4
+
+GL_VERTEX_ATTRIB_ARRAY_INTEGER_NV = Enumerant('GL_VERTEX_ATTRIB_ARRAY_INTEGER_NV', 0x88fd, 'GL_NV_vertex_program4')
+
+defines.add(GL_VERTEX_ATTRIB_ARRAY_INTEGER_NV)
+
# GL_NV_video_capture
GL_FAILURE_NV = Enumerant('GL_FAILURE_NV', 0x9030, 'GL_NV_video_capture')
@@ -27259,6 +27289,17 @@
glGetPointerIndexedvEXT.play = True
gl.add(glGetPointerIndexedvEXT)
+glGetPointeri_vEXT = Function('glGetPointeri_vEXT')
+glGetPointeri_vEXT.ret = Return('void')
+glGetPointeri_vEXT.add( Input( 'pname','GLenum' ))
+glGetPointeri_vEXT.add( Input( 'index','GLuint' ))
+glGetPointeri_vEXT.add( Output( 'params','GLvoid **' ))
+glGetPointeri_vEXT.version = '2.0'
+glGetPointeri_vEXT.category = 'GL_EXT_direct_state_access'
+glGetPointeri_vEXT.trace = True
+glGetPointeri_vEXT.play = True
+gl.add(glGetPointeri_vEXT)
+
glGetTextureImageEXT = Function('glGetTextureImageEXT')
glGetTextureImageEXT.ret = Return('void')
glGetTextureImageEXT.add( Input( 'texture','GLuint' ))
@@ -30596,6 +30637,17 @@
glPixelTransformParameterfEXT.play = True
gl.add(glPixelTransformParameterfEXT)
+glPixelTransformParameterfvEXT = Function('glPixelTransformParameterfvEXT')
+glPixelTransformParameterfvEXT.ret = Return('void')
+glPixelTransformParameterfvEXT.add( Input( 'target','GLenum' ))
+glPixelTransformParameterfvEXT.add( Input( 'pname','GLenum' ))
+glPixelTransformParameterfvEXT.add( Input( 'params','const GLfloat *' ,size = 1 ))
+glPixelTransformParameterfvEXT.version = '1.1'
+glPixelTransformParameterfvEXT.category = 'GL_EXT_pixel_transform'
+glPixelTransformParameterfvEXT.trace = True
+glPixelTransformParameterfvEXT.play = True
+gl.add(glPixelTransformParameterfvEXT)
+
glPixelTransformParameteriEXT = Function('glPixelTransformParameteriEXT')
glPixelTransformParameteriEXT.ret = Return('void')
glPixelTransformParameteriEXT.add( Input( 'target','GLenum' ))
@@ -30607,6 +30659,17 @@
glPixelTransformParameteriEXT.play = True
gl.add(glPixelTransformParameteriEXT)
+glPixelTransformParameterivEXT = Function('glPixelTransformParameterivEXT')
+glPixelTransformParameterivEXT.ret = Return('void')
+glPixelTransformParameterivEXT.add( Input( 'target','GLenum' ))
+glPixelTransformParameterivEXT.add( Input( 'pname','GLenum' ))
+glPixelTransformParameterivEXT.add( Input( 'params','const GLint *' ,size = 1 ))
+glPixelTransformParameterivEXT.version = '1.1'
+glPixelTransformParameterivEXT.category = 'GL_EXT_pixel_transform'
+glPixelTransformParameterivEXT.trace = True
+glPixelTransformParameterivEXT.play = True
+gl.add(glPixelTransformParameterivEXT)
+
# GL_EXT_point_parameters
glPointParameterfEXT = Function('glPointParameterfEXT')
@@ -32405,6 +32468,14 @@
glObjectPtrLabel.play = True
gl.add(glObjectPtrLabel)
+glPopDebugGroup = Function('glPopDebugGroup')
+glPopDebugGroup.ret = Return('void')
+glPopDebugGroup.version = ''
+glPopDebugGroup.category = 'GL_KHR_debug'
+glPopDebugGroup.trace = True
+glPopDebugGroup.play = True
+gl.add(glPopDebugGroup)
+
glPushDebugGroup = Function('glPushDebugGroup')
glPushDebugGroup.ret = Return('void')
glPushDebugGroup.add( Input( 'source','GLenum' ))
@@ -32725,6 +32796,25 @@
glWindowPos4svMESA.play = True
gl.add(glWindowPos4svMESA)
+# GL_NVX_conditional_render
+
+glBeginConditionalRenderNVX = Function('glBeginConditionalRenderNVX')
+glBeginConditionalRenderNVX.ret = Return('void')
+glBeginConditionalRenderNVX.add( Input( 'id','GLuint' ))
+glBeginConditionalRenderNVX.version = '1.5'
+glBeginConditionalRenderNVX.category = 'GL_NVX_conditional_render'
+glBeginConditionalRenderNVX.trace = True
+glBeginConditionalRenderNVX.play = True
+gl.add(glBeginConditionalRenderNVX)
+
+glEndConditionalRenderNVX = Function('glEndConditionalRenderNVX')
+glEndConditionalRenderNVX.ret = Return('void')
+glEndConditionalRenderNVX.version = '1.5'
+glEndConditionalRenderNVX.category = 'GL_NVX_conditional_render'
+glEndConditionalRenderNVX.trace = True
+glEndConditionalRenderNVX.play = True
+gl.add(glEndConditionalRenderNVX)
+
# GL_NV_bindless_texture
glGetImageHandleNV = Function('glGetImageHandleNV')
@@ -37104,6 +37194,75 @@
glVideoCaptureStreamParameterivNV.play = True
gl.add(glVideoCaptureStreamParameterivNV)
+# GL_OES_single_precision
+
+glClearDepthfOES = Function('glClearDepthfOES')
+glClearDepthfOES.ret = Return('void')
+glClearDepthfOES.add( Input( 'depth','GLclampd' ))
+glClearDepthfOES.version = ''
+glClearDepthfOES.category = 'GL_OES_single_precision'
+glClearDepthfOES.trace = True
+glClearDepthfOES.play = True
+gl.add(glClearDepthfOES)
+
+glClipPlanefOES = Function('glClipPlanefOES')
+glClipPlanefOES.ret = Return('void')
+glClipPlanefOES.add( Input( 'plane','GLenum' ))
+glClipPlanefOES.add( Input( 'equation','const GLfloat *' ))
+glClipPlanefOES.version = ''
+glClipPlanefOES.category = 'GL_OES_single_precision'
+glClipPlanefOES.trace = True
+glClipPlanefOES.play = True
+gl.add(glClipPlanefOES)
+
+glDepthRangefOES = Function('glDepthRangefOES')
+glDepthRangefOES.ret = Return('void')
+glDepthRangefOES.add( Input( 'n','GLclampf' ))
+glDepthRangefOES.add( Input( 'f','GLclampf' ))
+glDepthRangefOES.version = ''
+glDepthRangefOES.category = 'GL_OES_single_precision'
+glDepthRangefOES.trace = True
+glDepthRangefOES.play = True
+gl.add(glDepthRangefOES)
+
+glFrustumfOES = Function('glFrustumfOES')
+glFrustumfOES.ret = Return('void')
+glFrustumfOES.add( Input( 'l','GLfloat' ))
+glFrustumfOES.add( Input( 'r','GLfloat' ))
+glFrustumfOES.add( Input( 'b','GLfloat' ))
+glFrustumfOES.add( Input( 't','GLfloat' ))
+glFrustumfOES.add( Input( 'n','GLfloat' ))
+glFrustumfOES.add( Input( 'f','GLfloat' ))
+glFrustumfOES.version = ''
+glFrustumfOES.category = 'GL_OES_single_precision'
+glFrustumfOES.trace = True
+glFrustumfOES.play = True
+gl.add(glFrustumfOES)
+
+glGetClipPlanefOES = Function('glGetClipPlanefOES')
+glGetClipPlanefOES.ret = Return('void')
+glGetClipPlanefOES.add( Input( 'plane','GLenum' ))
+glGetClipPlanefOES.add( Output( 'equation','GLfloat *' ))
+glGetClipPlanefOES.version = ''
+glGetClipPlanefOES.category = 'GL_OES_single_precision'
+glGetClipPlanefOES.trace = True
+glGetClipPlanefOES.play = True
+gl.add(glGetClipPlanefOES)
+
+glOrthofOES = Function('glOrthofOES')
+glOrthofOES.ret = Return('void')
+glOrthofOES.add( Input( 'l','GLfloat' ))
+glOrthofOES.add( Input( 'r','GLfloat' ))
+glOrthofOES.add( Input( 'b','GLfloat' ))
+glOrthofOES.add( Input( 't','GLfloat' ))
+glOrthofOES.add( Input( 'n','GLfloat' ))
+glOrthofOES.add( Input( 'f','GLfloat' ))
+glOrthofOES.version = ''
+glOrthofOES.category = 'GL_OES_single_precision'
+glOrthofOES.trace = True
+glOrthofOES.play = True
+gl.add(glOrthofOES)
+
# GL_PGI_misc_hints
glHintPGI = Function('glHintPGI')
View
138 scripts/glx.py
@@ -482,18 +482,18 @@
defines.add(GLX_NUM_VIDEO_CAPTURE_SLOTS_NV)
defines.add(GLX_UNIQUE_ID_NV)
-# GLX_NV_video_out
-
-GLX_VIDEO_OUT_ALPHA_NV = Enumerant('GLX_VIDEO_OUT_ALPHA_NV', 0x20c4, 'GLX_NV_video_out')
-GLX_VIDEO_OUT_COLOR_AND_ALPHA_NV = Enumerant('GLX_VIDEO_OUT_COLOR_AND_ALPHA_NV', 0x20c6, 'GLX_NV_video_out')
-GLX_VIDEO_OUT_COLOR_AND_DEPTH_NV = Enumerant('GLX_VIDEO_OUT_COLOR_AND_DEPTH_NV', 0x20c7, 'GLX_NV_video_out')
-GLX_VIDEO_OUT_COLOR_NV = Enumerant('GLX_VIDEO_OUT_COLOR_NV', 0x20c3, 'GLX_NV_video_out')
-GLX_VIDEO_OUT_DEPTH_NV = Enumerant('GLX_VIDEO_OUT_DEPTH_NV', 0x20c5, 'GLX_NV_video_out')
-GLX_VIDEO_OUT_FIELD_1_NV = Enumerant('GLX_VIDEO_OUT_FIELD_1_NV', 0x20c9, 'GLX_NV_video_out')
-GLX_VIDEO_OUT_FIELD_2_NV = Enumerant('GLX_VIDEO_OUT_FIELD_2_NV', 0x20ca, 'GLX_NV_video_out')
-GLX_VIDEO_OUT_FRAME_NV = Enumerant('GLX_VIDEO_OUT_FRAME_NV', 0x20c8, 'GLX_NV_video_out')
-GLX_VIDEO_OUT_STACKED_FIELDS_1_2_NV = Enumerant('GLX_VIDEO_OUT_STACKED_FIELDS_1_2_NV', 0x20cb, 'GLX_NV_video_out')
-GLX_VIDEO_OUT_STACKED_FIELDS_2_1_NV = Enumerant('GLX_VIDEO_OUT_STACKED_FIELDS_2_1_NV', 0x20cc, 'GLX_NV_video_out')
+# GLX_NV_video_output
+
+GLX_VIDEO_OUT_ALPHA_NV = Enumerant('GLX_VIDEO_OUT_ALPHA_NV', 0x20c4, 'GLX_NV_video_output')
+GLX_VIDEO_OUT_COLOR_AND_ALPHA_NV = Enumerant('GLX_VIDEO_OUT_COLOR_AND_ALPHA_NV', 0x20c6, 'GLX_NV_video_output')
+GLX_VIDEO_OUT_COLOR_AND_DEPTH_NV = Enumerant('GLX_VIDEO_OUT_COLOR_AND_DEPTH_NV', 0x20c7, 'GLX_NV_video_output')
+GLX_VIDEO_OUT_COLOR_NV = Enumerant('GLX_VIDEO_OUT_COLOR_NV', 0x20c3, 'GLX_NV_video_output')
+GLX_VIDEO_OUT_DEPTH_NV = Enumerant('GLX_VIDEO_OUT_DEPTH_NV', 0x20c5, 'GLX_NV_video_output')
+GLX_VIDEO_OUT_FIELD_1_NV = Enumerant('GLX_VIDEO_OUT_FIELD_1_NV', 0x20c9, 'GLX_NV_video_output')
+GLX_VIDEO_OUT_FIELD_2_NV = Enumerant('GLX_VIDEO_OUT_FIELD_2_NV', 0x20ca, 'GLX_NV_video_output')
+GLX_VIDEO_OUT_FRAME_NV = Enumerant('GLX_VIDEO_OUT_FRAME_NV', 0x20c8, 'GLX_NV_video_output')
+GLX_VIDEO_OUT_STACKED_FIELDS_1_2_NV = Enumerant('GLX_VIDEO_OUT_STACKED_FIELDS_1_2_NV', 0x20cb, 'GLX_NV_video_output')
+GLX_VIDEO_OUT_STACKED_FIELDS_2_1_NV = Enumerant('GLX_VIDEO_OUT_STACKED_FIELDS_2_1_NV', 0x20cc, 'GLX_NV_video_output')
defines.add(GLX_VIDEO_OUT_ALPHA_NV)
defines.add(GLX_VIDEO_OUT_COLOR_AND_ALPHA_NV)
@@ -876,6 +876,106 @@
defines.add(GLX_SAMPLES)
defines.add(GLX_SAMPLE_BUFFERS)
+# GLX_AMD_gpu_association
+
+glXBlitContextFramebufferAMD = Function('glXBlitContextFramebufferAMD')
+glXBlitContextFramebufferAMD.ret = Return('void')
+glXBlitContextFramebufferAMD.add( Input( 'dstCtx','GLXContext' ))
+glXBlitContextFramebufferAMD.add( Input( 'srcX0','GLint' ))
+glXBlitContextFramebufferAMD.add( Input( 'srcY0','GLint' ))
+glXBlitContextFramebufferAMD.add( Input( 'srcX1','GLint' ))
+glXBlitContextFramebufferAMD.add( Input( 'srcY1','GLint' ))
+glXBlitContextFramebufferAMD.add( Input( 'dstX0','GLint' ))
+glXBlitContextFramebufferAMD.add( Input( 'dstY0','GLint' ))
+glXBlitContextFramebufferAMD.add( Input( 'dstX1','GLint' ))
+glXBlitContextFramebufferAMD.add( Input( 'dstY1','GLint' ))
+glXBlitContextFramebufferAMD.add( Input( 'mask','GLbitfield' ))
+glXBlitContextFramebufferAMD.add( Input( 'filter','GLenum' ))
+glXBlitContextFramebufferAMD.version = ''
+glXBlitContextFramebufferAMD.category = 'GLX_AMD_gpu_association'
+glXBlitContextFramebufferAMD.trace = True
+glXBlitContextFramebufferAMD.play = True
+glx.add(glXBlitContextFramebufferAMD)
+
+glXCreateAssociatedContextAMD = Function('glXCreateAssociatedContextAMD')
+glXCreateAssociatedContextAMD.ret = Return('GLXContext')
+glXCreateAssociatedContextAMD.add( Input( 'id','unsigned int' ))
+glXCreateAssociatedContextAMD.add( Input( 'share_list','GLXContext' ))
+glXCreateAssociatedContextAMD.version = ''
+glXCreateAssociatedContextAMD.category = 'GLX_AMD_gpu_association'
+glXCreateAssociatedContextAMD.trace = True
+glXCreateAssociatedContextAMD.play = True
+glx.add(glXCreateAssociatedContextAMD)
+
+glXCreateAssociatedContextAttribsAMD = Function('glXCreateAssociatedContextAttribsAMD')
+glXCreateAssociatedContextAttribsAMD.ret = Return('GLXContext')
+glXCreateAssociatedContextAttribsAMD.add( Input( 'id','unsigned int' ))
+glXCreateAssociatedContextAttribsAMD.add( Input( 'share_context','GLXContext' ))
+glXCreateAssociatedContextAttribsAMD.add( Input( 'attribList','const int *' ))
+glXCreateAssociatedContextAttribsAMD.version = ''
+glXCreateAssociatedContextAttribsAMD.category = 'GLX_AMD_gpu_association'
+glXCreateAssociatedContextAttribsAMD.trace = True
+glXCreateAssociatedContextAttribsAMD.play = True
+glx.add(glXCreateAssociatedContextAttribsAMD)
+
+glXDeleteAssociatedContextAMD = Function('glXDeleteAssociatedContextAMD')
+glXDeleteAssociatedContextAMD.ret = Return('Bool')
+glXDeleteAssociatedContextAMD.add( Input( 'ctx','GLXContext' ))
+glXDeleteAssociatedContextAMD.version = ''
+glXDeleteAssociatedContextAMD.category = 'GLX_AMD_gpu_association'
+glXDeleteAssociatedContextAMD.trace = True
+glXDeleteAssociatedContextAMD.play = True
+glx.add(glXDeleteAssociatedContextAMD)
+
+glXGetContextGPUIDAMD = Function('glXGetContextGPUIDAMD')
+glXGetContextGPUIDAMD.ret = Return('unsigned int')
+glXGetContextGPUIDAMD.add( Input( 'ctx','GLXContext' ))
+glXGetContextGPUIDAMD.version = ''
+glXGetContextGPUIDAMD.category = 'GLX_AMD_gpu_association'
+glXGetContextGPUIDAMD.trace = True
+glXGetContextGPUIDAMD.play = True
+glx.add(glXGetContextGPUIDAMD)
+
+glXGetCurrentAssociatedContextAMD = Function('glXGetCurrentAssociatedContextAMD')
+glXGetCurrentAssociatedContextAMD.ret = Return('GLXContext')
+glXGetCurrentAssociatedContextAMD.version = ''
+glXGetCurrentAssociatedContextAMD.category = 'GLX_AMD_gpu_association'
+glXGetCurrentAssociatedContextAMD.trace = True
+glXGetCurrentAssociatedContextAMD.play = True
+glx.add(glXGetCurrentAssociatedContextAMD)
+
+glXGetGPUIDsAMD = Function('glXGetGPUIDsAMD')
+glXGetGPUIDsAMD.ret = Return('unsigned int')
+glXGetGPUIDsAMD.add( Input( 'maxCount','unsigned int' ))
+glXGetGPUIDsAMD.add( Input( 'ids','unsigned int *' ))
+glXGetGPUIDsAMD.version = ''
+glXGetGPUIDsAMD.category = 'GLX_AMD_gpu_association'
+glXGetGPUIDsAMD.trace = True
+glXGetGPUIDsAMD.play = True
+glx.add(glXGetGPUIDsAMD)
+
+glXGetGPUInfoAMD = Function('glXGetGPUInfoAMD')
+glXGetGPUInfoAMD.ret = Return('int')
+glXGetGPUInfoAMD.add( Input( 'id','unsigned int' ))
+glXGetGPUInfoAMD.add( Input( 'property','int' ))
+glXGetGPUInfoAMD.add( Input( 'dataType','GLenum' ))
+glXGetGPUInfoAMD.add( Input( 'size','unsigned int' ))
+glXGetGPUInfoAMD.add( Input( 'data','GLvoid *' ))
+glXGetGPUInfoAMD.version = ''
+glXGetGPUInfoAMD.category = 'GLX_AMD_gpu_association'
+glXGetGPUInfoAMD.trace = True
+glXGetGPUInfoAMD.play = True
+glx.add(glXGetGPUInfoAMD)
+
+glXMakeAssociatedContextCurrentAMD = Function('glXMakeAssociatedContextCurrentAMD')
+glXMakeAssociatedContextCurrentAMD.ret = Return('Bool')
+glXMakeAssociatedContextCurrentAMD.add( Input( 'ctx','GLXContext' ))
+glXMakeAssociatedContextCurrentAMD.version = ''
+glXMakeAssociatedContextCurrentAMD.category = 'GLX_AMD_gpu_association'
+glXMakeAssociatedContextCurrentAMD.trace = True
+glXMakeAssociatedContextCurrentAMD.play = True
+glx.add(glXMakeAssociatedContextCurrentAMD)
+
# GLX_ARB_create_context
glXCreateContextAttribsARB = Function('glXCreateContextAttribsARB')
@@ -1302,7 +1402,7 @@
glXReleaseVideoCaptureDeviceNV.play = True
glx.add(glXReleaseVideoCaptureDeviceNV)
-# GLX_NV_video_out
+# GLX_NV_video_output
glXBindVideoImageNV = Function('glXBindVideoImageNV')
glXBindVideoImageNV.ret = Return('int')
@@ -1311,7 +1411,7 @@
glXBindVideoImageNV.add( Input( 'pbuf','GLXPbuffer' ))
glXBindVideoImageNV.add( Input( 'iVideoBuffer','int' ))
glXBindVideoImageNV.version = ''
-glXBindVideoImageNV.category = 'GLX_NV_video_out'
+glXBindVideoImageNV.category = 'GLX_NV_video_output'
glXBindVideoImageNV.trace = True
glXBindVideoImageNV.play = True
glx.add(glXBindVideoImageNV)
@@ -1323,7 +1423,7 @@
glXGetVideoDeviceNV.add( Input( 'numVideoDevices','int' ))
glXGetVideoDeviceNV.add( Output( 'pVideoDevice','GLXVideoDeviceNV *' ,size = 'numVideoDevices' ))
glXGetVideoDeviceNV.version = ''
-glXGetVideoDeviceNV.category = 'GLX_NV_video_out'
+glXGetVideoDeviceNV.category = 'GLX_NV_video_output'
glXGetVideoDeviceNV.trace = True
glXGetVideoDeviceNV.play = True
glx.add(glXGetVideoDeviceNV)
@@ -1336,7 +1436,7 @@
glXGetVideoInfoNV.add( Output( 'pulCounterOutputPbuffer','unsigned long *' ,size = 1 ))
glXGetVideoInfoNV.add( Output( 'pulCounterOutputVideo','unsigned long *' ,size = 1 ))
glXGetVideoInfoNV.version = ''
-glXGetVideoInfoNV.category = 'GLX_NV_video_out'
+glXGetVideoInfoNV.category = 'GLX_NV_video_output'
glXGetVideoInfoNV.trace = True
glXGetVideoInfoNV.play = True
glx.add(glXGetVideoInfoNV)
@@ -1347,7 +1447,7 @@
glXReleaseVideoDeviceNV.add( Input( 'screen','int' ))
glXReleaseVideoDeviceNV.add( Input( 'VideoDevice','GLXVideoDeviceNV' ))
glXReleaseVideoDeviceNV.version = ''
-glXReleaseVideoDeviceNV.category = 'GLX_NV_video_out'
+glXReleaseVideoDeviceNV.category = 'GLX_NV_video_output'
glXReleaseVideoDeviceNV.trace = True
glXReleaseVideoDeviceNV.play = True
glx.add(glXReleaseVideoDeviceNV)
@@ -1357,7 +1457,7 @@
glXReleaseVideoImageNV.add( Input( 'dpy','Display *' ))
glXReleaseVideoImageNV.add( Input( 'pbuf','GLXPbuffer' ))
glXReleaseVideoImageNV.version = ''
-glXReleaseVideoImageNV.category = 'GLX_NV_video_out'
+glXReleaseVideoImageNV.category = 'GLX_NV_video_output'
glXReleaseVideoImageNV.trace = True
glXReleaseVideoImageNV.play = True
glx.add(glXReleaseVideoImageNV)
@@ -1370,7 +1470,7 @@
glXSendPbufferToVideoNV.add( Output( 'pulCounterPbuffer','unsigned long *' ,size = 1 ))
glXSendPbufferToVideoNV.add( Input( 'bBlock','GLboolean' ))
glXSendPbufferToVideoNV.version = ''
-glXSendPbufferToVideoNV.category = 'GLX_NV_video_out'
+glXSendPbufferToVideoNV.category = 'GLX_NV_video_output'
glXSendPbufferToVideoNV.trace = True
glXSendPbufferToVideoNV.play = True
glx.add(glXSendPbufferToVideoNV)
View
6 scripts/wgl.py
@@ -428,6 +428,12 @@
defines.add(WGL_TEXTURE_RGB_ARB)
defines.add(WGL_TEXTURE_TARGET_ARB)
+# WGL_ARB_robustness_share_group_isolation
+
+WGL_CONTEXT_RESET_ISOLATION_BIT_ARB = Enumerant('WGL_CONTEXT_RESET_ISOLATION_BIT_ARB', 0x0008, 'WGL_ARB_robustness_share_group_isolation')
+
+defines.add(WGL_CONTEXT_RESET_ISOLATION_BIT_ARB)
+
# WGL_ATI_pixel_format_float
GL_COLOR_CLEAR_UNCLAMPED_VALUE_ATI = Enumerant('GL_COLOR_CLEAR_UNCLAMPED_VALUE_ATI', 0x8835, 'WGL_ATI_pixel_format_float')
View
24 src/glew/include/GL/glew.h
@@ -1228,7 +1228,6 @@ GLAPI void GLAPIENTRY glViewport (GLint x, GLint y, GLsizei width, GLsizei heigh
#define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365
#define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366
#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367
-#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368
#define GL_ALIASED_POINT_SIZE_RANGE 0x846D
#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E
@@ -2053,8 +2052,6 @@ typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX4X3FVPROC) (GLint location, GLsizei
#define GL_CONTEXT_FLAGS 0x821E
#define GL_DEPTH_BUFFER 0x8223
#define GL_STENCIL_BUFFER 0x8224
-#define GL_COMPRESSED_RED 0x8225
-#define GL_COMPRESSED_RG 0x8226
#define GL_RGBA32F 0x8814
#define GL_RGB32F 0x8815
#define GL_RGBA16F 0x881A
@@ -2361,11 +2358,6 @@ typedef void (GLAPIENTRY * PFNGLGETINTEGER64I_VPROC) (GLenum, GLuint, GLint64 *)
#define GL_VERSION_3_3 1
#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR 0x88FE
-#define GL_TEXTURE_SWIZZLE_R 0x8E42
-#define GL_TEXTURE_SWIZZLE_G 0x8E43
-#define GL_TEXTURE_SWIZZLE_B 0x8E44
-#define GL_TEXTURE_SWIZZLE_A 0x8E45
-#define GL_TEXTURE_SWIZZLE_RGBA 0x8E46
#define GL_RGB10_A2UI 0x906F
typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBDIVISORPROC) (GLuint index, GLuint divisor);
@@ -2381,13 +2373,8 @@ typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBDIVISORPROC) (GLuint index, GLuint d
#ifndef GL_VERSION_4_0
#define GL_VERSION_4_0 1
-#define GL_GEOMETRY_SHADER_INVOCATIONS 0x887F
#define GL_SAMPLE_SHADING 0x8C36
#define GL_MIN_SAMPLE_SHADING_VALUE 0x8C37
-#define GL_MAX_GEOMETRY_SHADER_INVOCATIONS 0x8E5A
-#define GL_MIN_FRAGMENT_INTERPOLATION_OFFSET 0x8E5B
-#define GL_MAX_FRAGMENT_INTERPOLATION_OFFSET 0x8E5C
-#define GL_FRAGMENT_INTERPOLATION_OFFSET_BITS 0x8E5D
#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5E
#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5F
#define GL_MAX_PROGRAM_TEXTURE_GATHER_COMPONENTS 0x8F9F
@@ -6218,13 +6205,6 @@ typedef GLboolean (GLAPIENTRY * PFNGLISVERTEXARRAYPROC) (GLuint array);
#ifndef GL_ARB_vertex_attrib_64bit
#define GL_ARB_vertex_attrib_64bit 1
-#define GL_DOUBLE_MAT2 0x8F46
-#define GL_DOUBLE_MAT3 0x8F47
-#define GL_DOUBLE_MAT4 0x8F48
-#define GL_DOUBLE_VEC2 0x8FFC
-#define GL_DOUBLE_VEC3 0x8FFD
-#define GL_DOUBLE_VEC4 0x8FFE
-
typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBLDVPROC) (GLuint index, GLenum pname, GLdouble* params);
typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL1DPROC) (GLuint index, GLdouble x);
typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL1DVPROC) (GLuint index, const GLdouble* v);
@@ -11689,8 +11669,6 @@ typedef void (GLAPIENTRY * PFNGLPROGRAMBUFFERPARAMETERSFVNVPROC) (GLenum target,
#define GL_ARC_TO_NV 0xFE
#define GL_RELATIVE_ARC_TO_NV 0xFF
#define GL_GLYPH_HAS_KERNING_BIT_NV 0x100
-#define GL_PRIMARY_COLOR_NV 0x852C
-#define GL_SECONDARY_COLOR_NV 0x852D
#define GL_PRIMARY_COLOR 0x8577
#define GL_PATH_FORMAT_SVG_NV 0x9070
#define GL_PATH_FORMAT_PS_NV 0x9071
@@ -13035,8 +13013,6 @@ typedef void (GLAPIENTRY * PFNGLVIDEOCAPTURESTREAMPARAMETERIVNVPROC) (GLuint vid
#ifndef GL_OES_byte_coordinates
#define GL_OES_byte_coordinates 1
-#define GL_BYTE 0x1400
-
#define GLEW_OES_byte_coordinates GLEW_GET_VAR(__GLEW_OES_byte_coordinates)
#endif /* GL_OES_byte_coordinates */
View
758 src/mongoose/mongoose.c
@@ -20,8 +20,10 @@
#if defined(_WIN32)
#define _CRT_SECURE_NO_WARNINGS // Disable deprecation warning in VS2005
-#else
+#else
+#ifdef __linux__
#define _XOPEN_SOURCE 600 // For flockfile() on Linux
+#endif
#define _LARGEFILE_SOURCE // Enable 64-bit file offsets
#define __STDC_FORMAT_MACROS // <inttypes.h> wants this for C++
#define __STDC_LIMIT_MACROS // C++ wants that for INT64_MAX
@@ -31,6 +33,12 @@
#undef WIN32_LEAN_AND_MEAN // Disable WIN32_LEAN_AND_MEAN, if necessary
#endif
+#ifdef _HAS_EXCEPTIONS
+#undef _HAS_EXCEPTIONS
+#endif
+
+#undef NO_SSL
+
#if defined(__SYMBIAN32__)
#define NO_SSL // SSL is not supported
#define NO_CGI // CGI is not supported
@@ -57,7 +65,9 @@
#if defined(_WIN32) && !defined(__SYMBIAN32__) // Windows specific
#define _WIN32_WINNT 0x0400 // To make it link in VS2005
+#include <winsock2.h>
#include <windows.h>
+#include <ws2tcpip.h>
#ifndef PATH_MAX
#define PATH_MAX MAX_PATH
@@ -68,8 +78,6 @@
#include <direct.h>
#include <io.h>
#else // _WIN32_WCE
-#include <winsock2.h>
-#include <ws2tcpip.h>
#define NO_CGI // WinCE has no pipes
typedef long off_t;
@@ -104,8 +112,6 @@ typedef long off_t;
#define NO_SOCKLEN_T
#define SSL_LIB "ssleay32.dll"
#define CRYPTO_LIB "libeay32.dll"
-#define DIRSEP '\\'
-#define IS_DIRSEP_CHAR(c) ((c) == '/' || (c) == '\\')
#define O_NONBLOCK 0
#if !defined(EWOULDBLOCK)
#define EWOULDBLOCK WSAEWOULDBLOCK
@@ -131,6 +137,7 @@ typedef long off_t;
#define read(x, y, z) _read((x), (y), (unsigned) z)
#define flockfile(x) EnterCriticalSection(&global_log_file_lock)
#define funlockfile(x) LeaveCriticalSection(&global_log_file_lock)
+#define sleep(x) Sleep((x) * 1000)
#if !defined(fileno)
#define fileno(x) _fileno(x)
@@ -141,11 +148,6 @@ typedef struct {HANDLE signal, broadcast;} pthread_cond_t;
typedef DWORD pthread_t;
#define pid_t HANDLE // MINGW typedefs pid_t to int. Using #define here.
-struct timespec {
- long tv_nsec;
- long tv_sec;
-};
-
static int pthread_mutex_lock(pthread_mutex_t *);
static int pthread_mutex_unlock(pthread_mutex_t *);
static FILE *mg_fopen(const char *path, const char *mode);
@@ -171,6 +173,9 @@ typedef struct DIR {
struct dirent result;
} DIR;
+// Mark required libraries
+#pragma comment(lib, "Ws2_32.lib")
+
#else // UNIX specific
#include <sys/wait.h>
#include <sys/socket.h>
@@ -200,8 +205,6 @@ typedef struct DIR {
#define CRYPTO_LIB "libcrypto.so"
#endif
#endif
-#define DIRSEP '/'
-#define IS_DIRSEP_CHAR(c) ((c) == '/')
#ifndef O_BINARY
#define O_BINARY 0
#endif // O_BINARY
@@ -221,11 +224,12 @@ typedef int SOCKET;
#include "mongoose.h"
-#define MONGOOSE_VERSION "3.3"
+#define MONGOOSE_VERSION "3.4"
#define PASSWORDS_FILE_NAME ".htpasswd"
#define CGI_ENVIRONMENT_SIZE 4096
#define MAX_CGI_ENVIR_VARS 64
#define MG_BUF_LEN 8192
+#define MAX_REQUEST_SIZE 16384
#define ARRAY_SIZE(array) (sizeof(array) / sizeof(array[0]))
#ifdef _WIN32
@@ -269,6 +273,10 @@ typedef int socklen_t;
#define SOMAXCONN 100
#endif
+#if !defined(PATH_MAX)
+#define PATH_MAX 4096
+#endif
+
static const char *http_500_error = "Internal Server Error";
// Snatched from OpenSSL includes. I put the prototypes here to be independent
@@ -425,8 +433,8 @@ struct socket {
// NOTE(lsm): this enum shoulds be in sync with the config_options below.
enum {
CGI_EXTENSIONS, CGI_ENVIRONMENT, PUT_DELETE_PASSWORDS_FILE, CGI_INTERPRETER,
- MAX_REQUEST_SIZE, PROTECT_URI, AUTHENTICATION_DOMAIN, SSI_EXTENSIONS,
- ACCESS_LOG_FILE, SSL_CHAIN_FILE, ENABLE_DIRECTORY_LISTING, ERROR_LOG_FILE,
+ PROTECT_URI, AUTHENTICATION_DOMAIN, SSI_EXTENSIONS, THROTTLE,
+ ACCESS_LOG_FILE, ENABLE_DIRECTORY_LISTING, ERROR_LOG_FILE,
GLOBAL_PASSWORDS_FILE, INDEX_FILES, ENABLE_KEEP_ALIVE, ACCESS_CONTROL_LIST,
EXTRA_MIME_TYPES, LISTENING_PORTS, DOCUMENT_ROOT, SSL_CERTIFICATE,
NUM_THREADS, RUN_AS_USER, REWRITE, HIDE_FILES,
@@ -438,12 +446,11 @@ static const char *config_options[] = {
"E", "cgi_environment", NULL,
"G", "put_delete_passwords_file", NULL,
"I", "cgi_interpreter", NULL,
- "M", "max_request_size", "16384",
"P", "protect_uri", NULL,
"R", "authentication_domain", "mydomain.com",
"S", "ssi_pattern", "**.shtml$|**.shtm$",
+ "T", "throttle", NULL,
"a", "access_log_file", NULL,
- "c", "ssl_chain_file", NULL,
"d", "enable_directory_listing", "yes",
"e", "error_log_file", NULL,
"g", "global_passwords_file", NULL,
@@ -454,7 +461,7 @@ static const char *config_options[] = {
"p", "listening_ports", "8080",
"r", "document_root", ".",
"s", "ssl_certificate", NULL,
- "t", "num_threads", "10",
+ "t", "num_threads", "20",
"u", "run_as_user", NULL,
"w", "url_rewrite_patterns", NULL,
"x", "hide_files_patterns", NULL,
@@ -494,22 +501,40 @@ struct mg_connection {
int64_t consumed_content; // How many bytes of content have been read
char *buf; // Buffer for received data
char *path_info; // PATH_INFO part of the URL
- char *body; // Pointer to not-read yet buffered body data
- char *next_request; // Pointer to the buffered next request
+ char *log_message; // Placeholder for the mongoose error log message
int must_close; // 1 if connection must be closed
int buf_size; // Buffer size
int request_len; // Size of the request + headers in a buffer
int data_len; // Total size of data in a buffer
+ int status_code; // HTTP reply status code, e.g. 200
+ int throttle; // Throttling, bytes/sec. <= 0 means no throttle
+ time_t last_throttle_time; // Last time throttled data was sent
+ int64_t last_throttle_bytes;// Bytes sent this second
};
const char **mg_get_valid_option_names(void) {
return config_options;
}
static void *call_user(struct mg_connection *conn, enum mg_event event) {
- conn->request_info.user_data = conn->ctx->user_data;
- return conn->ctx->user_callback == NULL ? NULL :
- conn->ctx->user_callback(event, conn);
+ return conn == NULL || conn->ctx == NULL || conn->ctx->user_callback == NULL ?
+ NULL : conn->ctx->user_callback(event, conn);
+}
+
+void *mg_get_user_data(struct mg_connection *conn) {
+ return conn != NULL && conn->ctx != NULL ? conn->ctx->user_data : NULL;
+}
+
+const char *mg_get_log_message(const struct mg_connection *conn) {
+ return conn == NULL ? NULL : conn->log_message;
+}
+
+int mg_get_reply_status_code(const struct mg_connection *conn) {
+ return conn == NULL ? -1 : conn->status_code;
+}
+
+void *mg_get_ssl_context(const struct mg_connection *conn) {
+ return conn == NULL || conn->ctx == NULL ? NULL : conn->ctx->ssl_ctx;
}
static int get_option_index(const char *name) {
@@ -550,6 +575,9 @@ static void sockaddr_to_string(char *buf, size_t len,
#endif
}
+static void cry(struct mg_connection *conn,
+ PRINTF_FORMAT_STRING(const char *fmt), ...) PRINTF_ARGS(2, 3);
+
// Print error message to the opened error log stream.
static void cry(struct mg_connection *conn, const char *fmt, ...) {
char buf[MG_BUF_LEN], src_addr[20];
@@ -564,9 +592,9 @@ static void cry(struct mg_connection *conn, const char *fmt, ...) {
// Do not lock when getting the callback value, here and below.
// I suppose this is fine, since function cannot disappear in the
// same way string option can.
- conn->request_info.log_message = buf;
+ conn->log_message = buf;
if (call_user(conn, MG_EVENT_LOG) == NULL) {
- fp = conn->ctx->config[ERROR_LOG_FILE] == NULL ? NULL :
+ fp = conn->ctx == NULL || conn->ctx->config[ERROR_LOG_FILE] == NULL ? NULL :
mg_fopen(conn->ctx->config[ERROR_LOG_FILE], "a+");
if (fp != NULL) {
@@ -590,7 +618,7 @@ static void cry(struct mg_connection *conn, const char *fmt, ...) {
}
}
}
- conn->request_info.log_message = NULL;
+ conn->log_message = NULL;
}
// Return fake connection structure. Used for logging, if connection
@@ -683,6 +711,10 @@ static int mg_vsnprintf(struct mg_connection *conn, char *buf, size_t buflen,
}
static int mg_snprintf(struct mg_connection *conn, char *buf, size_t buflen,
+ PRINTF_FORMAT_STRING(const char *fmt), ...)
+ PRINTF_ARGS(4, 5);
+
+static int mg_snprintf(struct mg_connection *conn, char *buf, size_t buflen,
const char *fmt, ...) {
va_list ap;
int n;
@@ -848,7 +880,7 @@ static int should_keep_alive(const struct mg_connection *conn) {
const char *http_version = conn->request_info.http_version;
const char *header = mg_get_header(conn, "Connection");
if (conn->must_close ||
- conn->request_info.status_code == 401 ||
+ conn->status_code == 401 ||
mg_strcasecmp(conn->ctx->config[ENABLE_KEEP_ALIVE], "yes") != 0 ||
(header != NULL && mg_strcasecmp(header, "keep-alive") != 0) ||
(header == NULL && http_version && strcmp(http_version, "1.1"))) {
@@ -872,8 +904,7 @@ static void send_http_error(struct mg_connection *conn, int status,
va_list ap;
int len;
- conn->request_info.status_code = status;
-
+ conn->status_code = status;
if (call_user(conn, MG_HTTP_ERROR) == NULL) {
buf[0] = '\0';
len = 0;
@@ -890,7 +921,6 @@ static void send_http_error(struct mg_connection *conn, int status,
DEBUG_TRACE(("[%s]", buf));
mg_printf(conn, "HTTP/1.1 %d %s\r\n"
- "Content-Type: text/plain\r\n"
"Content-Length: %d\r\n"
"Connection: %s\r\n\r\n", status, reason, len,
suggest_connection_header(conn));
@@ -1206,7 +1236,7 @@ static pid_t spawn_process(struct mg_connection *conn, const char *prog,
char *envblk, char *envp[], int fd_stdin,
int fd_stdout, const char *dir) {
HANDLE me;
- char *p, *interp, cmdline[PATH_MAX], buf[PATH_MAX];
+ char *p, *interp, full_interp[PATH_MAX], cmdline[PATH_MAX], buf[PATH_MAX];
FILE *fp;
STARTUPINFOA si = { sizeof(si) };
PROCESS_INFORMATION pi = { 0 };
@@ -1218,34 +1248,40 @@ static pid_t spawn_process(struct mg_connection *conn, const char *prog,
si.wShowWindow = SW_HIDE;
me = GetCurrentProcess();
- (void) DuplicateHandle(me, (HANDLE) _get_osfhandle(fd_stdin), me,
- &si.hStdInput, 0, TRUE, DUPLICATE_SAME_ACCESS);
- (void) DuplicateHandle(me, (HANDLE) _get_osfhandle(fd_stdout), me,
- &si.hStdOutput, 0, TRUE, DUPLICATE_SAME_ACCESS);
+ DuplicateHandle(me, (HANDLE) _get_osfhandle(fd_stdin), me,
+ &si.hStdInput, 0, TRUE, DUPLICATE_SAME_ACCESS);
+ DuplicateHandle(me, (HANDLE) _get_osfhandle(fd_stdout), me,
+ &si.hStdOutput, 0, TRUE, DUPLICATE_SAME_ACCESS);
// If CGI file is a script, try to read the interpreter line
interp = conn->ctx->config[CGI_INTERPRETER];
if (interp == NULL) {
- buf[2] = '\0';
- mg_snprintf(conn, cmdline, sizeof(cmdline), "%s%c%s", dir, DIRSEP, prog);
- if ((fp = fopen(cmdline, "r")) != NULL) {
- (void) fgets(buf, sizeof(buf), fp);
- if (buf[0] != '#' || buf[1] != '!') {
- // First line does not start with "#!". Do not set interpreter.
- buf[2] = '\0';
- } else {
- // Trim whitespace in interpreter name
- for (p = &buf[strlen(buf) - 1]; p > buf && isspace(*p); p--) {
- *p = '\0';
- }
- }
- (void) fclose(fp);
+ buf[0] = buf[2] = '\0';
+
+ // Read the first line of the script into the buffer
+ snprintf(cmdline, sizeof(cmdline), "%s%c%s", dir, '/', prog);
+ if ((fp = mg_fopen(cmdline, "r")) != NULL) {
+ fgets(buf, sizeof(buf), fp);
+ fclose(fp);
+ buf[sizeof(buf) - 1] = '\0';
+ }
+
+ if (buf[0] == '#' && buf[1] == '!') {
+ // Trim whitespace in interpreter name
+ for (p = buf + 2; *p != '\0' && isspace(* (unsigned char *) p); )
+ p++;
+ *p = '\0';
}
interp = buf + 2;
}
- (void) mg_snprintf(conn, cmdline, sizeof(cmdline), "%s%s%s%c%s",
- interp, interp[0] == '\0' ? "" : " ", dir, DIRSEP, prog);
+ if (interp[0] != '\0') {
+ GetFullPathName(interp, sizeof(full_interp), full_interp, NULL);
+ interp = full_interp;
+ }
+
+ mg_snprintf(conn, cmdline, sizeof(cmdline), "%s%s%s",
+ interp, interp[0] == '\0' ? "" : " ", prog);
DEBUG_TRACE(("Running [%s]", cmdline));
if (CreateProcessA(NULL, cmdline, NULL, NULL, TRUE,
@@ -1438,28 +1474,25 @@ static int pull(FILE *fp, struct mg_connection *conn, char *buf, int len) {
int mg_read(struct mg_connection *conn, void *buf, size_t len) {
int n, buffered_len, nread;
+ const char *body;
- assert(conn->next_request != NULL &&
- conn->body != NULL &&
- conn->next_request >= conn->body);
nread = 0;
if (conn->consumed_content < conn->content_len) {
-
// Adjust number of bytes to read.
int64_t to_read = conn->content_len - conn->consumed_content;
if (to_read < (int64_t) len) {
len = (size_t) to_read;
}
// Return buffered data
- buffered_len = conn->next_request - conn->body;
+ body = conn->buf + conn->request_len + conn->consumed_content;
+ buffered_len = &conn->buf[conn->data_len] - body;
if (buffered_len > 0) {
if (len < (size_t) buffered_len) {
buffered_len = (int) len;
}
- memcpy(buf, conn->body, (size_t) buffered_len);
+ memcpy(buf, body, (size_t) buffered_len);
len -= buffered_len;
- conn->body += buffered_len;
conn->consumed_content += buffered_len;
nread += buffered_len;
buf = (char *) buf + buffered_len;
@@ -1485,8 +1518,41 @@ int mg_read(struct mg_connection *conn, void *buf, size_t len) {
}
int mg_write(struct mg_connection *conn, const void *buf, size_t len) {
- return (int) push(NULL, conn->client.sock, conn->ssl, (const char *) buf,
- (int64_t) len);
+ time_t now;
+ int64_t n, total, allowed;
+
+ if (conn->throttle > 0) {
+ if ((now = time(NULL)) != conn->last_throttle_time) {
+ conn->last_throttle_time = now;
+ conn->last_throttle_bytes = 0;
+ }
+ allowed = conn->throttle - conn->last_throttle_bytes;
+ if (allowed > (int64_t) len) {
+ allowed = len;
+ }
+ if ((total = push(NULL, conn->client.sock, conn->ssl, (const char *) buf,
+ (int64_t) allowed)) == allowed) {
+ buf = (char *) buf + total;
+ conn->last_throttle_bytes += total;
+ while (total < (int64_t) len && conn->ctx->stop_flag == 0) {
+ allowed = conn->throttle > (int64_t) len - total ?
+ (int64_t) len - total : conn->throttle;
+ if ((n = push(NULL, conn->client.sock, conn->ssl, (const char *) buf,
+ (int64_t) allowed)) != allowed) {
+ break;
+ }
+ sleep(1);
+ conn->last_throttle_bytes = allowed;
+ conn->last_throttle_time = time(NULL);
+ buf = (char *) buf + n;
+ total += n;
+ }
+ }
+ } else {
+ total = push(NULL, conn->client.sock, conn->ssl, (const char *) buf,
+ (int64_t) len);
+ }
+ return (int) total;
}
int mg_printf(struct mg_connection *conn, const char *fmt, ...) {
@@ -1500,11 +1566,13 @@ int mg_printf(struct mg_connection *conn, const char *fmt, ...) {
len = vsnprintf(mem, sizeof(mem), fmt, ap);
va_end(ap);
- if (len <= 0) {
+ if (len == 0) {
+ // Do nothing. mg_printf(conn, "%s", "") was called.
+ } else if (len < 0) {
// vsnprintf() error, give up
len = -1;
cry(conn, "%s(%s, ...): vsnprintf() error", __func__, fmt);
- } else if (len > (int) sizeof(mem) && (buf = malloc(len + 1)) != NULL) {
+ } else if (len > (int) sizeof(mem) && (buf = (char *) malloc(len + 1)) != NULL) {
// Local buffer is not large enough, allocate big buffer on heap
va_start(ap, fmt);
vsnprintf(buf, len + 1, fmt, ap);
@@ -1654,15 +1722,12 @@ static int convert_uri_to_file_name(struct mg_connection *conn, char *buf,
rewrite = conn->ctx->config[REWRITE];
while ((rewrite = next_option(rewrite, &a, &b)) != NULL) {
if ((match_len = match_prefix(a.ptr, a.len, uri)) > 0) {
- mg_snprintf(conn, buf, buf_len, "%.*s%s", b.len, b.ptr, uri + match_len);
+ mg_snprintf(conn, buf, buf_len, "%.*s%s", (int) b.len, b.ptr,
+ uri + match_len);
break;
}
}
-#if defined(_WIN32) && !defined(__SYMBIAN32__)
- //change_slashes_to_backslashes(buf);
-#endif // _WIN32
-
if ((stat_result = mg_stat(buf, st)) != 0) {
// Support PATH_INFO for CGI scripts.
for (p = buf + strlen(buf); p > buf + 1; p--) {
@@ -1732,6 +1797,10 @@ static int get_month_index(const char *s) {
return -1;
}
+static int num_leap_years(int year) {
+ return year / 4 - year / 100 + year / 400;
+}
+
// Parse UTC date-time string, and return the corresponding time_t value.
static time_t parse_date_string(const char *datetime) {
static const unsigned short days_before_month[] = {
@@ -1751,8 +1820,8 @@ static time_t parse_date_string(const char *datetime) {
&day, month_str, &year, &hour, &minute, &second) == 6)) &&
year > 1970 &&
(month = get_month_index(month_str)) != -1) {
+ leap_days = num_leap_years(year) - num_leap_years(1970);
year -= 1970;
- leap_days = year / 4 - year / 100 + year / 400;
days = year * 365 + days_before_month[month] + (day - 1) + leap_days;
result = days * 24 * 3600 + hour * 3600 + minute * 60 + second;
}
@@ -1767,15 +1836,16 @@ static void remove_double_dots_and_double_slashes(char *s) {
while (*s != '\0') {
*p++ = *s++;
- if (IS_DIRSEP_CHAR(s[-1])) {
- // Skip all following slashes and backslashes
- while (IS_DIRSEP_CHAR(s[0])) {
- s++;
- }
-
- // Skip all double-dots
- while (*s == '.' && s[1] == '.') {
- s += 2;
+ if (s[-1] == '/' || s[-1] == '\\') {
+ // Skip all following slashes, backslashes and double-dots
+ while (s[0] != '\0') {
+ if (s[0] == '/' || s[0] == '\\') {
+ s++;
+ } else if (s[0] == '.' && s[1] == '.') {
+ s += 2;
+ } else {
+ break;
+ }
}
}
}
@@ -2140,15 +2210,15 @@ static FILE *open_auth_file(struct mg_connection *conn, const char *path) {
ctx->config[GLOBAL_PASSWORDS_FILE], strerror(ERRNO));
} else if (!mg_stat(path, &st) && st.is_directory) {
(void) mg_snprintf(conn, name, sizeof(name), "%s%c%s",
- path, DIRSEP, PASSWORDS_FILE_NAME);
+ path, '/', PASSWORDS_FILE_NAME);
fp = mg_fopen(name, "r");
} else {
// Try to find .htpasswd in requested directory.
for (p = path, e = p + strlen(p) - 1; e > p; e--)
- if (IS_DIRSEP_CHAR(*e))
+ if (e[0] == '/')
break;
(void) mg_snprintf(conn, name, sizeof(name), "%.*s%c%s",
- (int) (e - p), p, DIRSEP, PASSWORDS_FILE_NAME);
+ (int) (e - p), p, '/', PASSWORDS_FILE_NAME);
fp = mg_fopen(name, "r");
}
@@ -2264,8 +2334,8 @@ static int check_authorization(struct mg_connection *conn, const char *path) {
list = conn->ctx->config[PROTECT_URI];
while ((list = next_option(list, &uri_vec, &filename_vec)) != NULL) {
if (!memcmp(conn->request_info.uri, uri_vec.ptr, uri_vec.len)) {
- (void) mg_snprintf(conn, fname, sizeof(fname), "%.*s",
- filename_vec.len, filename_vec.ptr);
+ mg_snprintf(conn, fname, sizeof(fname), "%.*s",
+ (int) filename_vec.len, filename_vec.ptr);
if ((fp = mg_fopen(fname, "r")) == NULL) {
cry(conn, "%s: cannot open %s: %s", __func__, fname, strerror(errno));
}
@@ -2286,7 +2356,7 @@ static int check_authorization(struct mg_connection *conn, const char *path) {
}
static void send_authorization_request(struct mg_connection *conn) {
- conn->request_info.status_code = 401;
+ conn->status_code = 401;
(void) mg_printf(conn,
"HTTP/1.1 401 Unauthorized\r\n"
"Content-Length: 0\r\n"
@@ -2411,10 +2481,10 @@ static void print_dir_entry(struct de *de) {
if (de->st.size < 1024) {
(void) mg_snprintf(de->conn, size, sizeof(size),
"%lu", (unsigned long) de->st.size);
- } else if (de->st.size < 1024 * 1024) {
+ } else if (de->st.size < 0x100000) {
(void) mg_snprintf(de->conn, size, sizeof(size),
"%.1fk", (double) de->st.size / 1024.0);
- } else if (de->st.size < 1024 * 1024 * 1024) {
+ } else if (de->st.size < 0x40000000) {
(void) mg_snprintf(de->conn, size, sizeof(size),
"%.1fM", (double) de->st.size / 1048576);
} else {
@@ -2488,7 +2558,7 @@ static int scan_directory(struct mg_connection *conn, const char *dir,
continue;
}
- mg_snprintf(conn, path, sizeof(path), "%s%c%s", dir, DIRSEP, dp->d_name);
+ mg_snprintf(conn, path, sizeof(path), "%s%c%s", dir, '/', dp->d_name);
// If we don't memset stat structure to zero, mtime will have
// garbage and strftime() will segfault later on in
@@ -2579,7 +2649,7 @@ static void handle_directory_request(struct mg_connection *conn,
free(data.entries);
conn->num_bytes_sent += mg_printf(conn, "%s", "</table></body></html>");
- conn->request_info.status_code = 200;
+ conn->status_code = 200;
}
// Send len bytes from the opened file to the client.
@@ -2636,7 +2706,7 @@ static void handle_file_request(struct mg_connection *conn, const char *path,
get_mime_type(conn->ctx, path, &mime_vec);
cl = stp->size;
- conn->request_info.status_code = 200;
+ conn->status_code = 200;
range[0] = '\0';
if ((fp = mg_fopen(path, "rb")) == NULL) {
@@ -2650,7 +2720,7 @@ static void handle_file_request(struct mg_connection *conn, const char *path,
r1 = r2 = 0;
hdr = mg_get_header(conn, "Range");
if (hdr != NULL && (n = parse_range_header(hdr, &r1, &r2)) > 0) {
- conn->request_info.status_code = 206;
+ conn->status_code = 206;
(void) fseeko(fp, r1, SEEK_SET);
cl = n == 2 ? r2 - r1 + 1: cl - r1;
(void) mg_snprintf(conn, range, sizeof(range),
@@ -2677,7 +2747,7 @@ static void handle_file_request(struct mg_connection *conn, const char *path,
"Connection: %s\r\n"
"Accept-Ranges: bytes\r\n"
"%s\r\n",
- conn->request_info.status_code, msg, date, lm, etag, (int) mime_vec.len,
+ conn->status_code, msg, date, lm, etag, (int) mime_vec.len,
mime_vec.ptr, cl, suggest_connection_header(conn), range);
if (strcmp(conn->request_info.request_method, "HEAD") != 0) {
@@ -2726,7 +2796,6 @@ static int parse_http_message(char *buf, int len, struct mg_request_info *ri) {
// Reset attributes. DO NOT TOUCH is_ssl, remote_ip, remote_port
ri->remote_user = ri->request_method = ri->uri = ri->http_version = NULL;
ri->num_headers = 0;
- ri->status_code = -1;
buf[request_length - 1] = '\0';
@@ -2798,10 +2867,10 @@ static int substitute_index_file(struct mg_connection *conn, char *path,
// The 'path' given to us points to the directory. Remove all trailing
// directory separator characters from the end of the path, and
// then append single directory separator character.
- while (n > 0 && IS_DIRSEP_CHAR(path[n - 1])) {
+ while (n > 0 && path[n - 1] == '/') {
n--;
}
- path[n] = DIRSEP;
+ path[n] = '/';
// Traverse index files list. For each entry, append it to the given
// path and see if the file exists. If it exists, break the loop
@@ -2844,7 +2913,7 @@ static int is_not_modified(const struct mg_connection *conn,
static int forward_body_data(struct mg_connection *conn, FILE *fp,
SOCKET sock, SSL *ssl) {
- const char *expect;
+ const char *expect, *body;
char buf[MG_BUF_LEN];
int to_read, nread, buffered_len, success = 0;
@@ -2860,17 +2929,17 @@ static int forward_body_data(struct mg_connection *conn, FILE *fp,
(void) mg_printf(conn, "%s", "HTTP/1.1 100 Continue\r\n\r\n");
}
- buffered_len = conn->next_request - conn->body;
+ body = conn->buf + conn->request_len + conn->consumed_content;
+ buffered_len = &conn->buf[conn->data_len] - body;
assert(buffered_len >= 0);
assert(conn->consumed_content == 0);
if (buffered_len > 0) {
if ((int64_t) buffered_len > conn->content_len) {
buffered_len = (int) conn->content_len;
}
- push(fp, sock, ssl, conn->body, (int64_t) buffered_len);
+ push(fp, sock, ssl, body, (int64_t) buffered_len);
conn->consumed_content += buffered_len;
- conn->body += buffered_len;
}
nread = 0;
@@ -3076,7 +3145,7 @@ static void handle_cgi_request(struct mg_connection *conn, const char *prog) {
// directory containing executable program, 'p' must point to the
// executable program name relative to 'dir'.
(void) mg_snprintf(conn, dir, sizeof(dir), "%s", prog);
- if ((p = strrchr(dir, DIRSEP)) != NULL) {
+ if ((p = strrchr(dir, '/')) != NULL) {
*p++ = '\0';
} else {
dir[0] = '.', dir[1] = '\0';
@@ -3096,7 +3165,15 @@ static void handle_cgi_request(struct mg_connection *conn, const char *prog) {
send_http_error(conn, 500, http_500_error,
"Cannot spawn CGI process [%s]: %s", prog, strerror(ERRNO));
goto done;
- } else if ((in = fdopen(fd_stdin[1], "wb")) == NULL ||
+ }
+
+ // spawn_process() must close those!
+ // If we don't mark them as closed, close() attempt before
+ // return from this function throws an exception on Windows.
+ // Windows does not like when closed descriptor is closed again.
+ fd_stdin[0] = fd_stdout[1] = -1;
+
+ if ((in = fdopen(fd_stdin[1], "wb")) == NULL ||
(out = fdopen(fd_stdout[0], "rb")) == NULL) {
send_http_error(conn, 500, http_500_error,
"fopen: %s", strerror(ERRNO));
@@ -3106,27 +3183,23 @@ static void handle_cgi_request(struct mg_connection *conn, const char *prog) {
setbuf(in, NULL);
setbuf(out, NULL);
- // spawn_process() must close those!
- // If we don't mark them as closed, close() attempt before
- // return from this function throws an exception on Windows.
- // Windows does not like when closed descriptor is closed again.
- fd_stdin[0] = fd_stdout[1] = -1;
-
// Send POST data to the CGI process if needed
if (!strcmp(conn->request_info.request_method, "POST") &&
!forward_body_data(conn, in, INVALID_SOCKET, NULL)) {
goto done;
}
+
// Close so child gets an EOF.
fclose(in);
in = NULL;
+ fd_stdin[1] = -1;
// Now read CGI reply into a buffer. We need to set correct
// status code, thus we need to see all HTTP headers first.
// Do not send anything back to client, until we buffer in all
// HTTP headers.
data_len = 0;
- headers_len = read_request(out, fc(conn->ctx), buf, sizeof(buf), &data_len);
+ headers_len = read_request(out, conn, buf, sizeof(buf), &data_len);
if (headers_len <= 0) {
send_http_error(conn, 500, http_500_error,
"CGI program sent malformed or too big (>%u bytes) "
@@ -3141,21 +3214,21 @@ static void handle_cgi_request(struct mg_connection *conn, const char *prog) {
// Make up and send the status line
status_text = "OK";
if ((status = get_header(&ri, "Status")) != NULL) {
- conn->request_info.status_code = atoi(status);
+ conn->status_code = atoi(status);
status_text = status;
while (isdigit(* (unsigned char *) status_text) || *status_text == ' ') {
status_text++;
}
} else if (get_header(&ri, "Location") != NULL) {
- conn->request_info.status_code = 302;
+ conn->status_code = 302;
} else {
- conn->request_info.status_code = 200;
+ conn->status_code = 200;
}
if (get_header(&ri, "Connection") != NULL &&
!mg_strcasecmp(get_header(&ri, "Connection"), "keep-alive")) {
conn->must_close = 1;
}
- (void) mg_printf(conn, "HTTP/1.1 %d %s\r\n", conn->request_info.status_code,
+ (void) mg_printf(conn, "HTTP/1.1 %d %s\r\n", conn->status_code,
status_text);
// Send headers
@@ -3206,7 +3279,7 @@ static int put_dir(const char *path) {
struct mgstat st;
int len, res = 1;
- for (s = p = path + 2; (p = strchr(s, DIRSEP)) != NULL; s = ++p) {
+ for (s = p = path + 2; (p = strchr(s, '/')) != NULL; s = ++p) {
len = p - path;
if (len >= (int) sizeof(buf)) {
res = -1;
@@ -3238,10 +3311,10 @@ static void put_file(struct mg_connection *conn, const char *path) {
FILE *fp;
int rc;
- conn->request_info.status_code = mg_stat(path, &st) == 0 ? 200 : 201;
+ conn->status_code = mg_stat(path, &st) == 0 ? 200 : 201;
if ((rc = put_dir(path)) == 0) {
- mg_printf(conn, "HTTP/1.1 %d OK\r\n\r\n", conn->request_info.status_code);
+ mg_printf(conn, "HTTP/1.1 %d OK\r\n\r\n", conn->status_code);
} else if (rc == -1) {
send_http_error(conn, 500, http_500_error,
"put_dir(%s): %s", path, strerror(ERRNO));
@@ -3253,13 +3326,13 @@ static void put_file(struct mg_connection *conn, const char *path) {
range = mg_get_header(conn, "Content-Range");
r1 = r2 = 0;
if (range != NULL && parse_range_header(range, &r1, &r2) > 0) {
- conn->request_info.status_code = 206;
+ conn->status_code = 206;
// TODO(lsm): handle seek error
(void) fseeko(fp, r1, SEEK_SET);
}
- if (forward_body_data(conn, fp, INVALID_SOCKET, NULL))
- (void) mg_printf(conn, "HTTP/1.1 %d OK\r\n\r\n",
- conn->request_info.status_code);
+ if (forward_body_data(conn, fp, INVALID_SOCKET, NULL)) {
+ (void) mg_printf(conn, "HTTP/1.1 %d OK\r\n\r\n", conn->status_code);
+ }
(void) fclose(fp);
}
}
@@ -3276,15 +3349,15 @@ static void do_ssi_include(struct mg_connection *conn, const char *ssi,
if (sscanf(tag, " virtual=\"%[^\"]\"", file_name) == 1) {
// File name is relative to the webserver root
(void) mg_snprintf(conn, path, sizeof(path), "%s%c%s",
- conn->ctx->config[DOCUMENT_ROOT], DIRSEP, file_name);
+ conn->ctx->config[DOCUMENT_ROOT], '/', file_name);
} else if (sscanf(tag, " file=\"%[^\"]\"", file_name) == 1) {
// File name is relative to the webserver working directory
// or it is absolute system path
(void) mg_snprintf(conn, path, sizeof(path), "%s", file_name);
} else if (sscanf(tag, " \"%[^\"]\"", file_name) == 1) {
// File name is relative to the currect document
(void) mg_snprintf(conn, path, sizeof(path), "%s", ssi);
- if ((p = strrchr(path, DIRSEP)) != NULL) {
+ if ((p = strrchr(path, '/')) != NULL) {
p[1] = '\0';
}
(void) mg_snprintf(conn, path + strlen(path),
@@ -3409,7 +3482,7 @@ static void handle_ssi_file_request(struct mg_connection *conn,
}
static void send_options(struct mg_connection *conn) {
- conn->request_info.status_code = 200;
+ conn->status_code = 200;
(void) mg_printf(conn,
"HTTP/1.1 200 OK\r\n"
@@ -3453,7 +3526,7 @@ static void handle_propfind(struct mg_connection *conn, const char* path,
const char *depth = mg_get_header(conn, "Depth");
conn->must_close = 1;
- conn->request_info.status_code = 207;
+ conn->status_code = 207;
mg_printf(conn, "HTTP/1.1 207 Multi-Status\r\n"
"Connection: close\r\n"
"Content-Type: text/xml; charset=utf-8\r\n\r\n");
@@ -3475,6 +3548,299 @@ static void handle_propfind(struct mg_connection *conn, const char* path,
conn->num_bytes_sent += mg_printf(conn, "%s\n", "</d:multistatus>");
}
+#if defined(USE_WEBSOCKET)
+
+// START OF SHA-1 code
+// Copyright(c) By Steve Reid <steve@edmweb.com>
+#define SHA1HANDSOFF
+#if defined(__sun)
+#include "solarisfixes.h"
+#endif
+#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
+#if BYTE_ORDER == LITTLE_ENDIAN
+#define blk0(i) (block->l[i] = (rol(block->l[i],24)&0xFF00FF00) \
+ |(rol(block->l[i],8)&0x00FF00FF))
+#elif BYTE_ORDER == BIG_ENDIAN
+#define blk0(i) block->l[i]
+#else
+#error "Endianness not defined!"
+#endif
+#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
+ ^block->l[(i+2)&15]^block->l[i&15],1))
+#define R0(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk0(i)+0x5A827999+rol(v,5);w=rol(w,30);
+#define R1(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk(i)+0x5A827999+rol(v,5);w=rol(w,30);
+#define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30);
+#define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30);
+#define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
+
+typedef struct {
+ uint32_t state[5];
+ uint32_t count[2];
+ unsigned char buffer[64];
+} SHA1_CTX;
+
+static void SHA1Transform(uint32_t state[5], const unsigned char buffer[64]) {
+ uint32_t a, b, c, d, e;
+ typedef union { unsigned char c[64]; uint32_t l[16]; } CHAR64LONG16;
+
+ CHAR64LONG16 block[1];
+ memcpy(block, buffer, 64);
+ a = state[0];
+ b = state[1];
+ c = state[2];
+ d = state[3];
+ e = state[4];
+ R0(a,b,c,d,e, 0); R0(e,a,b,c,d, 1); R0(d,e,a,b,c, 2); R0(c,d,e,a,b, 3);
+ R0(b,c,d,e,a, 4); R0(a,b,c,d,e, 5); R0(e,a,b,c,d, 6); R0(d,e,a,b,c, 7);
+ R0(c,d,e,a,b, 8); R0(b,c,d,e,a, 9); R0(a,b,c,d,e,10); R0(e,a,b,c,d,11);
+ R0(d,e,a,b,c,12); R0(c,d,e,a,b,13); R0(b,c,d,e,a,14); R0(a,b,c,d,e,15);
+ R1(e,a,b,c,d,16); R1(d,e,a,b,c,17); R1(c,d,e,a,b,18); R1(b,c,d,e,a,19);
+ R2(a,b,c,d,e,20); R2(e,a,b,c,d,21); R2(d,e,a,b,c,22); R2(c,d,e,a,b,23);
+ R2(b,c,d,e,a,24); R2(a,b,c,d,e,25); R2(e,a,b,c,d,26); R2(d,e,a,b,c,27);
+ R2(c,d,e,a,b,28); R2(b,c,d,e,a,29); R2(a,b,c,d,e,30); R2(e,a,b,c,d,31);
+ R2(d,e,a,b,c,32); R2(c,d,e,a,b,33); R2(b,c,d,e,a,34); R2(a,b,c,d,e,35);
+ R2(e,a,b,c,d,36); R2(d,e,a,b,c,37); R2(c,d,e,a,b,38); R2(b,c,d,e,a,39);
+ R3(a,b,c,d,e,40); R3(e,a,b,c,d,41); R3(d,e,a,b,c,42); R3(c,d,e,a,b,43);
+ R3(b,c,d,e,a,44); R3(a,b,c,d,e,45); R3(e,a,b,c,d,46); R3(d,e,a,b,c,47);
+ R3(c,d,e,a,b,48); R3(b,c,d,e,a,49); R3(a,b,c,d,e,50); R3(e,a,b,c,d,51);
+ R3(d,e,a,b,c,52); R3(c,d,e,a,b,53); R3(b,c,d,e,a,54); R3(a,b,c,d,e,55);
+ R3(e,a,b,c,d,56); R3(d,e,a,b,c,57); R3(c,d,e,a,b,58); R3(b,c,d,e,a,59);
+ R4(a,b,c,d,e,60); R4(e,a,b,c,d,61); R4(d,e,a,b,c,62); R4(c,d,e,a,b,63);
+ R4(b,c,d,e,a,64); R4(a,b,c,d,e,65); R4(e,a,b,c,d,66); R4(d,e,a,b,c,67);
+ R4(c,d,e,a,b,68); R4(b,c,d,e,a,69); R4(a,b,c,d,e,70); R4(e,a,b,c,d,71);
+ R4(d,e,a,b,c,72); R4(c,d,e,a,b,73); R4(b,c,d,e,a,74); R4(a,b,c,d,e,75);
+ R4(e,a,b,c,d,76); R4(d,e,a,b,c,77); R4(c,d,e,a,b,78); R4(b,c,d,e,a,79);
+ state[0] += a;
+ state[1] += b;
+ state[2] += c;
+ state[3] += d;
+ state[4] += e;
+ a = b = c = d = e = 0;
+ memset(block, '\0', sizeof(block));
+}
+
+static void SHA1Init(SHA1_CTX* context) {
+ context->state[0] = 0x67452301;
+ context->state[1] = 0xEFCDAB89;
+ context->state[2] = 0x98BADCFE;
+ context->state[3] = 0x10325476;
+ context->state[4] = 0xC3D2E1F0;
+ context->count[0] = context->count[1] = 0;
+}
+
+static void SHA1Update(SHA1_CTX* context, const unsigned char* data,
+ uint32_t len) {
+ uint32_t i, j;
+
+ j = context->count[0];
+ if ((context->count[0] += len << 3) < j)
+ context->count[1]++;
+ context->count[1] += (len>>29);
+ j = (j >> 3) & 63;
+ if ((j + len) > 63) {
+ memcpy(&context->buffer[j], data, (i = 64-j));
+ SHA1Transform(context->state, context->buffer);
+ for ( ; i + 63 < len; i += 64) {
+ SHA1Transform(context->state, &data[i]);
+ }
+ j = 0;
+ }
+ else i = 0;
+ memcpy(&context->buffer[j], &data[i], len - i);
+}
+
+static void SHA1Final(unsigned char digest[20], SHA1_CTX* context) {
+ unsigned i;
+ unsigned char finalcount[8], c;
+
+ for (i = 0; i < 8; i++) {
+ finalcount[i] = (unsigned char)((context->count[(i >= 4 ? 0 : 1)]
+ >> ((3-(i & 3)) * 8) ) & 255);
+ }
+ c = 0200;
+ SHA1Update(context, &c, 1);
+ while ((context->count[0] & 504) != 448) {
+ c = 0000;
+ SHA1Update(context, &c, 1);
+ }
+ SHA1Update(context, finalcount, 8);
+ for (i = 0; i < 20; i++) {
+ digest[i] = (unsigned char)
+ ((context->state[i>>2] >> ((3-(i & 3)) * 8) ) & 255);
+ }
+ memset(context, '\0', sizeof(*context));
+ memset(&finalcount, '\0', sizeof(finalcount));
+}
+// END OF SHA1 CODE
+
+static void base64_encode(const unsigned char *src, int src_len, char *dst) {
+ static const char *b64 =
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+ int i, j, a, b, c;
+
+ for (i = j = 0; i < src_len; i += 3) {
+ a = src[i];
+ b = i + 1 >= src_len ? 0 : src[i + 1];
+ c = i + 2 >= src_len ? 0 : src[i + 2];
+
+ dst[j++] = b64[a >> 2];
+ dst[j++] = b64[((a & 3) << 4) | (b >> 4)];
+ if (i + 1 < src_len) {
+ dst[j++] = b64[(b & 15) << 2 | (c >> 6)];
+ }
+ if (i + 2 < src_len) {
+ dst[j++] = b64[c & 63];
+ }
+ }
+ while (j % 4 != 0) {
+ dst[j++] = '=';
+ }
+ dst[j++] = '\0';
+}
+
+static void send_websocket_handshake(struct mg_connection *conn) {
+ static const char *magic = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
+ char buf[100], sha[20], b64_sha[sizeof(sha) * 2];
+ SHA1_CTX sha_ctx;
+
+ mg_snprintf(conn, buf, sizeof(buf), "%s%s",
+ mg_get_header(conn, "Sec-WebSocket-Key"), magic);
+ SHA1Init(&sha_ctx);
+ SHA1Update(&sha_ctx, (unsigned char *) buf, strlen(buf));
+ SHA1Final((unsigned char *) sha, &sha_ctx);
+ base64_encode((unsigned char *) sha, sizeof(sha), b64_sha);
+ mg_printf(conn, "%s%s%s",
+ "HTTP/1.1 101 Switching Protocols\r\n"
+ "Upgrade: websocket\r\n"
+ "Connection: Upgrade\r\n"
+ "Sec-WebSocket-Accept: ", b64_sha, "\r\n\r\n");
+}
+
+static void read_websocket(struct mg_connection *conn) {
+ unsigned char *mask, *buf = (unsigned char *) conn->buf + conn->request_len;
+ int n, len, mask_len, body_len, discard_len;
+
+ for (;;) {
+ if ((body_len = conn->data_len - conn->request_len) >= 2) {
+ len = buf[1] & 127;
+ mask_len = buf[1] & 128 ? 4 : 0;
+ if (len < 126) {
+ conn->content_len = 2 + mask_len + len;
+ mask = buf + 2;
+ } else if (len == 126 && body_len >= 4) {
+ conn->content_len = 2 + mask_len + ((((int) buf[2]) << 8) + buf[3]);
+ mask = buf + 4;
+ } else if (body_len >= 10) {
+ conn->content_len = 2 + mask_len +
+ (((uint64_t) htonl(* (uint32_t *) &buf[2])) << 32) |
+ htonl(* (uint32_t *) &buf[6]);
+ mask = buf + 10;
+ }
+ }
+
+ if (conn->content_len > 0) {
+ if (call_user(conn, MG_WEBSOCKET_MESSAGE) != NULL) {
+ break; // Callback signalled to exit
+ }
+ discard_len = conn->content_len > body_len ?
+ body_len : (int) conn->content_len;
+ memmove(buf, buf + discard_len, conn->data_len - discard_len);
+ conn->data_len -= discard_len;
+ conn->content_len = conn->consumed_content = 0;
+ } else {
+ if (wait_until_socket_is_readable(conn) == 0) {
+ break;
+ }
+ n = pull(NULL, conn, conn->buf + conn->data_len,
+ conn->buf_size - conn->data_len);
+ if (n <= 0) {
+ break;
+ }
+ conn->data_len += n;
+ }
+ }
+}
+
+sta