1 /* 2 * Generation of include directives. 3 * 4 * Copyright (C) 2019 Paul Boddie <paul@boddie.org.uk> 5 * 6 * This program is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU General Public License as 8 * published by the Free Software Foundation; either version 2 of 9 * the License, or (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, 19 * Boston, MA 02110-1301, USA 20 */ 21 22 #include "includes.h" 23 24 25 26 /* Write include directives having certain forms. */ 27 28 void write_general_include(const char *filename, FILE *fp) 29 { 30 fprintf(fp, "#include %s\n", filename); 31 } 32 33 void write_include(const char *name, const char *suffix, FILE *fp) 34 { 35 fprintf(fp, "#include \"%s%s\"\n", name, suffix); 36 } 37 38 /* Write include statements. */ 39 40 void write_includes(struct include *inc, FILE *fp) 41 { 42 if (inc == NULL) 43 return; 44 45 /* The list is reversed. */ 46 47 write_includes(inc->tail, fp); 48 write_general_include(inc->filename, fp); 49 } 50 51 void write_includes_separator(struct include *inc, FILE *fp) 52 { 53 if (inc != NULL) 54 fputs("\n", fp); 55 }