egl: add copyright notices
[mesa.git] / src / egl / main / egllog.c
index 11a9bf7275cd3dcf76bb34a50003318b3ec75d4d..43eed64c2992b2897d4a2fff34590587a425ff8f 100644 (file)
@@ -1,3 +1,33 @@
+/**************************************************************************
+ *
+ * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * Copyright 2009-2010 Chia-I Wu <olvaffe@gmail.com>
+ * Copyright 2010 LunarG, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+
 /**
  * Logging facility for debug/info messages.
  * _EGL_FATAL messages are printed to stderr
@@ -11,6 +41,7 @@
 #include <string.h>
 
 #include "egllog.h"
+#include "eglstring.h"
 #include "eglmutex.h"
 
 #define MAXSTRING 1000
@@ -116,7 +147,7 @@ _eglInitLogger(void)
    log_env = getenv("EGL_LOG_LEVEL");
    if (log_env) {
       for (i = 0; level_strings[i]; i++) {
-         if (strcasecmp(log_env, level_strings[i]) == 0) {
+         if (_eglstrcasecmp(log_env, level_strings[i]) == 0) {
             level = i;
             break;
          }
@@ -150,6 +181,7 @@ _eglLog(EGLint level, const char *fmtStr, ...)
 {
    va_list args;
    char msg[MAXSTRING];
+   int ret;
 
    /* one-time initialization; a little race here is fine */
    if (!logging.initialized)
@@ -161,7 +193,9 @@ _eglLog(EGLint level, const char *fmtStr, ...)
 
    if (logging.logger) {
       va_start(args, fmtStr);
-      vsnprintf(msg, MAXSTRING, fmtStr, args);
+      ret = vsnprintf(msg, MAXSTRING, fmtStr, args);
+      if (ret < 0 || ret >= MAXSTRING)
+         strcpy(msg, "<message truncated>");
       va_end(args);
 
       logging.logger(level, msg);