paul@8 | 1 | /* |
paul@28 | 2 | * Interface summary generation. |
paul@28 | 3 | * |
paul@28 | 4 | * Copyright (C) 2019 Paul Boddie <paul@boddie.org.uk> |
paul@28 | 5 | * |
paul@28 | 6 | * This program is free software; you can redistribute it and/or |
paul@28 | 7 | * modify it under the terms of the GNU General Public License as |
paul@28 | 8 | * published by the Free Software Foundation; either version 2 of |
paul@28 | 9 | * the License, or (at your option) any later version. |
paul@28 | 10 | * |
paul@28 | 11 | * This program is distributed in the hope that it will be useful, |
paul@28 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
paul@28 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
paul@28 | 14 | * GNU General Public License for more details. |
paul@28 | 15 | * |
paul@28 | 16 | * You should have received a copy of the GNU General Public License |
paul@28 | 17 | * along with this program; if not, write to the Free Software |
paul@28 | 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, |
paul@28 | 19 | * Boston, MA 02110-1301, USA |
paul@8 | 20 | */ |
paul@8 | 21 | |
paul@8 | 22 | #include <stdio.h> |
paul@20 | 23 | #include "summary.h" |
paul@8 | 24 | |
paul@9 | 25 | void show_interface(struct interface *iface) |
paul@9 | 26 | { |
paul@9 | 27 | printf("Interface: %s\n", iface->name); |
paul@21 | 28 | show_includes(iface->includes); |
paul@51 | 29 | show_attributes(iface->attributes); |
paul@9 | 30 | show_signatures(iface->signatures); |
paul@9 | 31 | } |
paul@9 | 32 | |
paul@51 | 33 | void show_includes(struct include *inc) |
paul@21 | 34 | { |
paul@23 | 35 | if (inc == NULL) |
paul@23 | 36 | return; |
paul@51 | 37 | show_includes(inc->tail); |
paul@21 | 38 | printf("Include: %s\n", inc->filename); |
paul@21 | 39 | } |
paul@21 | 40 | |
paul@51 | 41 | void show_signatures(struct signature *sig) |
paul@9 | 42 | { |
paul@51 | 43 | if (sig == NULL) |
paul@51 | 44 | return; |
paul@51 | 45 | show_signature(sig); |
paul@51 | 46 | show_signatures(sig->tail); |
paul@9 | 47 | } |
paul@9 | 48 | |
paul@8 | 49 | void show_signature(struct signature *sig) |
paul@8 | 50 | { |
paul@8 | 51 | printf("Signature: %s %s\n", sig->qualifier, sig->operation); |
paul@51 | 52 | show_attributes(sig->attributes); |
paul@8 | 53 | show_parameters(sig->parameters); |
paul@8 | 54 | } |
paul@8 | 55 | |
paul@51 | 56 | void show_attributes(struct attribute *attr) |
paul@25 | 57 | { |
paul@51 | 58 | if (attr == NULL) |
paul@51 | 59 | return; |
paul@51 | 60 | show_attribute(attr); |
paul@51 | 61 | show_attributes(attr->tail); |
paul@25 | 62 | } |
paul@25 | 63 | |
paul@25 | 64 | void show_attribute(struct attribute *attr) |
paul@25 | 65 | { |
paul@25 | 66 | printf("Attribute: %s", attr->attribute); |
paul@51 | 67 | show_identifiers(attr->identifiers); |
paul@25 | 68 | printf("\n"); |
paul@25 | 69 | } |
paul@25 | 70 | |
paul@51 | 71 | void show_parameters(struct parameter *param) |
paul@8 | 72 | { |
paul@51 | 73 | if (param == NULL) |
paul@51 | 74 | return; |
paul@51 | 75 | show_parameter(param); |
paul@51 | 76 | show_parameters(param->tail); |
paul@8 | 77 | } |
paul@9 | 78 | |
paul@9 | 79 | void show_parameter(struct parameter *param) |
paul@9 | 80 | { |
paul@30 | 81 | char *type; |
paul@30 | 82 | |
paul@18 | 83 | printf("Parameter: %s%s", param->specifier & IN_PARAMETER ? "IN" : "", |
paul@18 | 84 | param->specifier & OUT_PARAMETER ? "OUT" : ""); |
paul@18 | 85 | |
paul@30 | 86 | /* Items must have their type identifiers restored. */ |
paul@30 | 87 | |
paul@57 | 88 | if (param->cls & ITEM_CLASS) |
paul@30 | 89 | { |
paul@57 | 90 | type = param->cls == FPAGE_ITEM ? "fpage" : "cap"; |
paul@30 | 91 | printf(" %s", type); |
paul@30 | 92 | } |
paul@30 | 93 | |
paul@51 | 94 | show_identifiers(param->identifiers); |
paul@18 | 95 | printf("\n"); |
paul@9 | 96 | } |
paul@25 | 97 | |
paul@51 | 98 | void show_identifiers(struct identifier *ident) |
paul@25 | 99 | { |
paul@51 | 100 | while (ident != NULL) |
paul@25 | 101 | { |
paul@51 | 102 | printf(" %s", ident->identifier); |
paul@51 | 103 | ident = ident->tail; |
paul@25 | 104 | } |
paul@25 | 105 | } |