Main Page | File List | Globals | Related Pages

avrerror.c

Go to the documentation of this file.
00001 /* 00002 * $Id: avrerror.c,v 1.7 2003/12/01 09:10:14 troth Exp $ 00003 * 00004 **************************************************************************** 00005 * 00006 * simulavr - A simulator for the Atmel AVR family of microcontrollers. 00007 * Copyright (C) 2001, 2002, 2003 Theodore A. Roth 00008 * 00009 * This program is free software; you can redistribute it and/or modify 00010 * it under the terms of the GNU General Public License as published by 00011 * the Free Software Foundation; either version 2 of the License, or 00012 * (at your option) any later version. 00013 * 00014 * This program is distributed in the hope that it will be useful, 00015 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 * GNU General Public License for more details. 00018 * 00019 * You should have received a copy of the GNU General Public License 00020 * along with this program; if not, write to the Free Software 00021 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00022 * 00023 **************************************************************************** 00024 */ 00025 00026 /** 00027 \file avrerror.c 00028 \brief Functions for printing messages, warnings and errors. 00029 00030 This module provides output printing facilities. */ 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 /** \brief Print an ordinary message to stdout. */ 00042 #define avr_message(fmt, args...) \ 00043 private_avr_message(__FILE__, __LINE__, fmt, ## args) 00044 00045 /** \brief Print a warning message to stderr. */ 00046 #define avr_warning(fmt, args...) \ 00047 private_avr_warning(__FILE__, __LINE__, fmt, ## args) 00048 00049 /** \brief Print an error message to stderr and terminate program. */ 00050 #define avr_error(fmt, args...) \ 00051 private_avr_error(__FILE__, __LINE__, fmt, ## args) 00052 00053 #else /* Not Documentation */ 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); /* exit instead of abort */ 00100 } 00101 00102 #endif /* Not documenation */

Automatically generated by Doxygen 1.3.8 on 11 Aug 2004.