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
00026
00027
00028
00029
00030
00031
00032
#include <stdio.h>
00033
#include <stdlib.h>
00034
#include <stdarg.h>
00035
#include <string.h>
00036
00037
#include "avrerror.h"
00038
00039
#if MACRO_DOCUMENTATION
00040
00041
00042 #define avr_message(fmt, args...) \
00043
private_avr_message(__FILE__, __LINE__, fmt, ## args)
00044
00045
00046 #define avr_warning(fmt, args...) \
00047
private_avr_warning(__FILE__, __LINE__, fmt, ## args)
00048
00049
00050 #define avr_error(fmt, args...) \
00051
private_avr_error(__FILE__, __LINE__, fmt, ## args)
00052
00053
#else
00054
00055
void
00056 private_avr_message (
char *file,
int line,
char *fmt, ...)
00057 {
00058 va_list ap;
00059
char ffmt[128];
00060
00061 snprintf (ffmt,
sizeof (ffmt),
"MESSAGE: file %s: line %d: %s", file,
00062 line, fmt);
00063 ffmt[127] =
'\0';
00064
00065 va_start (ap, fmt);
00066 vfprintf (stdout, ffmt, ap);
00067 va_end (ap);
00068 }
00069
00070
void
00071 private_avr_warning (
char *file,
int line,
char *fmt, ...)
00072 {
00073 va_list ap;
00074
char ffmt[128];
00075
00076 snprintf (ffmt,
sizeof (ffmt),
"WARNING: file %s: line %d: %s", file,
00077 line, fmt);
00078 ffmt[127] =
'\0';
00079
00080 va_start (ap, fmt);
00081 vfprintf (stderr, ffmt, ap);
00082 va_end (ap);
00083 }
00084
00085
void
00086 private_avr_error (
char *file,
int line,
char *fmt, ...)
00087 {
00088 va_list ap;
00089
char ffmt[128];
00090
00091 snprintf (ffmt,
sizeof (ffmt),
"\nERROR: file %s: line %d: %s\n\n", file,
00092 line, fmt);
00093 ffmt[127] =
'\0';
00094
00095 va_start (ap, fmt);
00096 vfprintf (stderr, ffmt, ap);
00097 va_end (ap);
00098
00099 exit (1);
00100 }
00101
00102
#endif