From a47bfbe189d8ca05683da9dc2732d7fd435112d8 Mon Sep 17 00:00:00 2001 From: Timothy Arceri Date: Mon, 26 Aug 2019 11:23:39 +1000 Subject: [PATCH] mesa: implement glGetNamedStringARB() Reviewed-by: Pierre-Eric Pelloux-Prayer Reviewed-by: Witold Baryluk --- src/mesa/main/shaderapi.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c index 3d764ff075e..82f4bdc8210 100644 --- a/src/mesa/main/shaderapi.c +++ b/src/mesa/main/shaderapi.c @@ -3415,6 +3415,28 @@ GLvoid GLAPIENTRY _mesa_GetNamedStringARB(GLint namelen, const GLchar *name, GLsizei bufSize, GLint *stringlen, GLchar *string) { + GET_CURRENT_CONTEXT(ctx); + const char *caller = "glGetNamedStringARB"; + + char *name_cp = copy_string(ctx, name, namelen, caller); + if (!name_cp) + return; + + const char *source = _mesa_lookup_shader_include(ctx, name_cp); + if (!source) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "%s(no string associated with path %s)", caller, name_cp); + free(name_cp); + return; + } + + size_t size = MIN2(strlen(source), bufSize - 1); + memcpy(string, source, size); + string[size] = '\0'; + + *stringlen = size; + + free(name_cp); } GLvoid GLAPIENTRY -- 2.30.2