/*
mktools.c - Part of ardcom - Easy communication over USB with Arduino
Copyright 2013 - Laurent Menu-Kerforn
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __MKTOOLSC
#define __MKTOOLSC

#ifndef __MKOUT
#define __MKOUT stderr
#endif

void syserrorf(char *code, char *reason) {
	fprintf(__MKOUT,"\n?? %s\t%s\t%s (%d)",code,reason,strerror(errno),errno);
	}

void errorf(char *code, char *reason) {
	fprintf(__MKOUT,"\n?? %s\t%s",code,reason);
	}

void exitf(char *code, char *reason) {
	errorf(code,reason);
	fprintf(__MKOUT,"\n");
	exit(1);
	}

void warnf(char *code, char *reason) {
	fprintf(__MKOUT,"\n!! %s\t%s",code,reason);
	}

void sysexitf(char *code,char *reason) {
	syserrorf(code,reason);
	fprintf(__MKOUT,"\n");
	exit(1);
	}
#endif

