00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include <string.h>
00026 #include <stdio.h>
00027 #include <stdlib.h>
00028 #include <stdarg.h>
00029 #include "types.h"
00030 #include "globals.h"
00031 #include "util.h"
00032
00033
00034
00035
00036 void error_message(short error_type, int line_number, int file, char *message, ...)
00037 {
00038 va_list ap;
00039
00040 printf("--------------\nOdin has decided you have failed ;)\n\n");
00041
00042 printf("ERROR:");
00043 if (file != -1)
00044 printf(" (File: %s)", configuration.list_of_file_names[file]);
00045 if (line_number != 0)
00046 printf(" (Line number: %d)", line_number);
00047 if (message != NULL)
00048 {
00049 printf(" ");
00050 va_start(ap, message);
00051 vprintf(message, ap);
00052 va_end(ap);
00053 }
00054
00055 printf("\n");
00056
00057 exit(error_type);
00058 }
00059
00060
00061
00062
00063 void warning_message(short error_type, int line_number, int file, char *message, ...)
00064 {
00065 va_list ap;
00066 static short is_warned = FALSE;
00067 static long warning_count = 0;
00068 warning_count++;
00069
00070 if (is_warned == FALSE)
00071 {
00072 printf("-------------------------\nOdin has decided you may fail ... WARNINGS:\n\n");
00073 is_warned = TRUE;
00074 }
00075
00076 printf("WARNING (%ld):", warning_count);
00077 if (file != -1)
00078 printf(" (File: %s)", configuration.list_of_file_names[file]);
00079 if (line_number != 0)
00080 printf(" (Line number: %d)", line_number);
00081 if (message != NULL)
00082 {
00083 printf(" ");
00084
00085 va_start(ap, message);
00086 vprintf(message, ap);
00087 va_end(ap);
00088 }
00089
00090 printf("\n");
00091 }