Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenslang_log.c
Go to the documentation of this file.
00001 /* 00002 * Mesa 3-D graphics library 00003 * Version: 7.3 00004 * 00005 * Copyright (C) 2005-2007 Brian Paul All Rights Reserved. 00006 * Copyright (C) 2009 VMware, Inc. All Rights Reserved. 00007 * 00008 * Permission is hereby granted, free of charge, to any person obtaining a 00009 * copy of this software and associated documentation files (the "Software"), 00010 * to deal in the Software without restriction, including without limitation 00011 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 00012 * and/or sell copies of the Software, and to permit persons to whom the 00013 * Software is furnished to do so, subject to the following conditions: 00014 * 00015 * The above copyright notice and this permission notice shall be included 00016 * in all copies or substantial portions of the Software. 00017 * 00018 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 00019 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00020 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 00021 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 00022 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 00023 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 00024 */ 00025 00026 #include "main/imports.h" 00027 #include "main/context.h" 00028 #include "slang_log.h" 00029 #include "slang_utility.h" 00030 00031 00032 00033 static char *out_of_memory = "Error: Out of memory.\n"; 00034 00035 void 00036 slang_info_log_construct(slang_info_log * log) 00037 { 00038 log->text = NULL; 00039 log->dont_free_text = GL_FALSE; 00040 log->error_flag = GL_FALSE; 00041 } 00042 00043 void 00044 slang_info_log_destruct(slang_info_log * log) 00045 { 00046 if (!log->dont_free_text) 00047 _mesa_free(log->text); 00048 } 00049 00050 static int 00051 slang_info_log_message(slang_info_log * log, const char *prefix, 00052 const char *msg) 00053 { 00054 GLuint size; 00055 00056 if (log->dont_free_text) 00057 return 0; 00058 size = slang_string_length(msg) + 2; 00059 if (prefix != NULL) 00060 size += slang_string_length(prefix) + 2; 00061 if (log->text != NULL) { 00062 GLuint old_len = slang_string_length(log->text); 00063 log->text = (char *) 00064 _mesa_realloc(log->text, old_len + 1, old_len + size); 00065 } 00066 else { 00067 log->text = (char *) (_mesa_malloc(size)); 00068 if (log->text != NULL) 00069 log->text[0] = '\0'; 00070 } 00071 if (log->text == NULL) 00072 return 0; 00073 if (prefix != NULL) { 00074 slang_string_concat(log->text, prefix); 00075 slang_string_concat(log->text, ": "); 00076 } 00077 slang_string_concat(log->text, msg); 00078 slang_string_concat(log->text, "\n"); 00079 00080 if (MESA_VERBOSE & VERBOSE_GLSL) { 00081 _mesa_printf("Mesa: GLSL %s", log->text); 00082 } 00083 00084 return 1; 00085 } 00086 00087 int 00088 slang_info_log_print(slang_info_log * log, const char *msg, ...) 00089 { 00090 va_list va; 00091 char buf[1024]; 00092 00093 va_start(va, msg); 00094 _mesa_vsprintf(buf, msg, va); 00095 va_end(va); 00096 return slang_info_log_message(log, NULL, buf); 00097 } 00098 00099 int 00100 slang_info_log_error(slang_info_log * log, const char *msg, ...) 00101 { 00102 va_list va; 00103 char buf[1024]; 00104 00105 va_start(va, msg); 00106 _mesa_vsprintf(buf, msg, va); 00107 va_end(va); 00108 log->error_flag = GL_TRUE; 00109 if (slang_info_log_message(log, "Error", buf)) 00110 return 1; 00111 slang_info_log_memory(log); 00112 return 0; 00113 } 00114 00115 int 00116 slang_info_log_warning(slang_info_log * log, const char *msg, ...) 00117 { 00118 va_list va; 00119 char buf[1024]; 00120 00121 va_start(va, msg); 00122 _mesa_vsprintf(buf, msg, va); 00123 va_end(va); 00124 if (slang_info_log_message(log, "Warning", buf)) 00125 return 1; 00126 slang_info_log_memory(log); 00127 return 0; 00128 } 00129 00130 void 00131 slang_info_log_memory(slang_info_log * log) 00132 { 00133 if (!slang_info_log_message(log, "Error", "Out of memory.")) { 00134 log->dont_free_text = GL_TRUE; 00135 log->error_flag = GL_TRUE; 00136 log->text = out_of_memory; 00137 } 00138 } Generated on Sat May 26 2012 04:19:27 for ReactOS by
1.7.6.1
|