/* tripl/error.c * * This file is part of tripl. * * tripl 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. * * tripl 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 tripl. If not, see */ #include #include #include extern char *line_eof; int generic_error(char *msg, char *line, int lno) { char *buffer = strndup(line, line_eof - line + 1); ansi_csi_st(stderr, MODE_HIGHLIGHT, FG_WHITE, BG_BLACK); fprintf(stderr, "tripl: %s:%d: ", fname, lno); ansi_csi_ed(stderr); ansi_csi_st(stderr, MODE_HIGHLIGHT, FG_RED, BG_BLACK); fprintf(stderr, "error: "); ansi_csi_ed(stderr); fprintf(stderr, "%s\n", msg); fprintf(stderr, "%5d | ", lno); ansi_csi_st(stderr, MODE_LINE, FG_WHITE, BG_BLACK); fprintf(stderr, "%s\n", buffer); ansi_csi_ed(stderr); free(buffer); return 1; }