L4Re/idl4re

Annotated includes.c

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