Commits

Ondřej Surý committed e5d9ea1

Rename E_{ERROR,WARNING,...} to GD_{ERROR,WARNING,...} and install the header

Comments (0)

Files changed (8)

 
 EXTRA_DIST = bdftogd demoin.png entities.html entities.tcl CMakeLists.txt
 
-include_HEADERS = gd.h gdfx.h gd_io.h gdcache.h gdfontg.h gdfontl.h gdfontmb.h gdfonts.h gdfontt.h entities.h gd_color_map.h
+include_HEADERS = gd.h gdfx.h gd_io.h gdcache.h gdfontg.h gdfontl.h gdfontmb.h gdfonts.h gdfontt.h entities.h gd_color_map.h gd_errors.h
 
 lib_LTLIBRARIES = libgd.la
 
 
         va_start(args, format);
 	switch (priority) {
-	case E_ERROR:
+	case GD_ERROR:
 		fputs("GD Error: ", stderr);
 		break;
-	case E_WARNING:
+	case GD_WARNING:
 		fputs("GD Warning: ", stderr);
 		break;
-	case E_NOTICE:
+	case GD_NOTICE:
 		fputs("GD Notice: ", stderr);
 		break;
-	case E_INFO:
+	case GD_INFO:
 		fputs("GD Info: ", stderr);
 		break;
-	case E_DEBUG:
+	case GD_DEBUG:
 		fputs("GD Debug: ", stderr);
 		break;
 	}
         va_list args;
 
         va_start(args, format);
-	gd_error_ex(E_WARNING, format, args);
+	gd_error_ex(GD_WARNING, format, args);
         va_end(args);
 }
 void gd_error_ex(int priority, const char *format, ...)
 LOG_DEBUG      debug-level message
 */
 
-#define E_ERROR LOG_ERR
-#define E_WARNING LOG_WARNING
-#define E_NOTICE LOG_NOTICE
-#define E_INFO LOG_INFO
-#define E_DEBUG LOG_DEBUG
+#define GD_ERROR LOG_ERR
+#define GD_WARNING LOG_WARNING
+#define GD_NOTICE LOG_NOTICE
+#define GD_INFO LOG_INFO
+#define GD_DEBUG LOG_DEBUG
 
 void gd_error(const char *format, ...);
 void gd_error_ex(int priority, const char *format, ...);
 		goto error;
 	}
 #if BITS_IN_JSAMPLE == 12
-	gd_error_ex(E_ERROR,
+	gd_error_ex(GD_ERROR,
 		    "gd-jpeg: error: jpeg library was compiled for 12-bit\n"
 		    "precision. This is mostly useless, because JPEGs on the web are\n"
 		    "8-bit and such versions of the jpeg library won't read or write\n"
 	for (i=0; i<rad; i++)
 		nnq->radpower[i] = alpha*(((rad*rad - i*i)*radbias)/(rad*rad));
 
-	if (verbose) gd_error_ex(E_NOTICE, "beginning 1D learning: initial radius=%d\n", rad);
+	if (verbose) gd_error_ex(GD_NOTICE, "beginning 1D learning: initial radius=%d\n", rad);
 
 	if ((nnq->lengthcount%prime1) != 0) step = 4*prime1;
 	else {
 				nnq->radpower[j] = alpha*(((rad*rad - j*j)*radbias)/(rad*rad));
 		}
 	}
-	if (verbose) gd_error_ex(E_NOTICE, "finished 1D learning: final alpha=%f !\n",((float)alpha)/initalpha);
+	if (verbose) gd_error_ex(GD_NOTICE, "finished 1D learning: final alpha=%f !\n",((float)alpha)/initalpha);
 }
 
 BGD_DECLARE(gdImagePtr) gdImageNeuQuant(gdImagePtr im, const int max_color, int sample_factor)

src/gd_security.c

 int overflow2(int a, int b)
 {
 	if(a <= 0 || b <= 0) {
-		gd_error(E_WARNING, "one parameter to a memory allocation multiplication is negative or zero, failing operation gracefully\n");
+		gd_error(GD_WARNING, "one parameter to a memory allocation multiplication is negative or zero, failing operation gracefully\n");
 		return 1;
 	}
 	if(a > INT_MAX / b) {
-		gd_error_ex(E_WARNING, "product of memory allocation multiplication would exceed INT_MAX, failing operation gracefully\n");
+		gd_error_ex(GD_WARNING, "product of memory allocation multiplication would exceed INT_MAX, failing operation gracefully\n");
 		return 1;
 	}
 	return 0;
 
 #ifdef DEBUG
 	if (whatcode == ASCII)
-		gd_error_ex(E_DEBUG, "Kanji code not included.");
+		gd_error_ex(GD_DEBUG, "Kanji code not included.");
 	else if (whatcode == EUCORSJIS)
-		gd_error_ex(E_DEBUG, "Kanji code not detected.");
+		gd_error_ex(GD_DEBUG, "Kanji code not detected.");
 	else
-		gd_error_ex(E_DEBUG, "Kanji code detected at %d byte.", i);
+		gd_error_ex(GD_DEBUG, "Kanji code detected at %d byte.", i);
 #endif
 
 	if (whatcode == EUCORSJIS && oldcode != ASCII)
 
 	switch (DetectKanjiCode (from)) {
 	case NEW:
-		gd_error_ex(E_DEBUG, "Kanji code is New JIS.");
+		gd_error_ex(GD_DEBUG, "Kanji code is New JIS.");
 		do_convert (&tmp_p, &from, NEWJISSTR);
 		break;
 	case OLD:
-		gd_error_ex(E_DEBUG, "Kanji code is Old JIS.");
+		gd_error_ex(GD_DEBUG, "Kanji code is Old JIS.");
 		do_convert (&tmp_p, &from, OLDJISSTR);
 		break;
 	case ESCI:
-		gd_error_ex(E_DEBUG, "This string includes Hankaku-Kana (jisx0201) escape sequence [ESC] + ( + I.");
+		gd_error_ex(GD_DEBUG, "This string includes Hankaku-Kana (jisx0201) escape sequence [ESC] + ( + I.");
 		do_convert (&tmp_p, &from, NEWJISSTR);
 		break;
 	case NEC:
-		gd_error_ex(E_DEBUG, "Kanji code is NEC Kanji.");
+		gd_error_ex(GD_DEBUG, "Kanji code is NEC Kanji.");
 		gd_error("cannot convert NEC Kanji.");
 		ustrcpy (tmp, from);
 		kanji = FALSE;
 		break;
 	case EUC:
-		gd_error_ex(E_DEBUG, "Kanji code is EUC.");
+		gd_error_ex(GD_DEBUG, "Kanji code is EUC.");
 		ustrcpy (tmp, from);
 		break;
 	case SJIS:
-		gd_error_ex(E_DEBUG, "Kanji code is SJIS.");
+		gd_error_ex(GD_DEBUG, "Kanji code is SJIS.");
 		do_convert (&tmp_p, &from, SJISSTR);
 		break;
 	case EUCORSJIS:
-		gd_error_ex(E_DEBUG, "Kanji code is EUC or SJIS.");
+		gd_error_ex(GD_DEBUG, "Kanji code is EUC or SJIS.");
 		ustrcpy (tmp, from);
 		kanji = FALSE;
 		break;
 	case ASCII:
-		gd_error_ex(E_DEBUG, "This is ASCII string.");
+		gd_error_ex(GD_DEBUG, "This is ASCII string.");
 		ustrcpy (tmp, from);
 		kanji = FALSE;
 		break;
 	default:
-		gd_error_ex(E_DEBUG, "This string includes unknown code.");
+		gd_error_ex(GD_DEBUG, "This string includes unknown code.");
 		ustrcpy (tmp, from);
 		kanji = FALSE;
 		break;
 BGD_DECLARE(gdImagePtr) gdImageCreateFromXpm(char *filename)
 {
 	(void)filename;
-	gd_error_ex(E_ERROR, "libgd was not built with xpm support\n");
+	gd_error_ex(GD_ERROR, "libgd was not built with xpm support\n");
 	return NULL;
 }
 #else