1 /* 2 * Interface summary generation. 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 <stdio.h> 23 #include "summary.h" 24 25 void show_interface(struct interface *iface) 26 { 27 printf("Interface: %s\n", iface->name); 28 show_includes(iface->includes); 29 show_attributes(iface->attributes); 30 show_signatures(iface->signatures); 31 } 32 33 void show_includes(struct include *inc) 34 { 35 if (inc == NULL) 36 return; 37 show_includes(inc->tail); 38 printf("Include: %s\n", inc->filename); 39 } 40 41 void show_signatures(struct signature *sig) 42 { 43 if (sig == NULL) 44 return; 45 show_signature(sig); 46 show_signatures(sig->tail); 47 } 48 49 void show_signature(struct signature *sig) 50 { 51 printf("Signature: %s %s\n", sig->qualifier, sig->operation); 52 show_attributes(sig->attributes); 53 show_parameters(sig->parameters); 54 } 55 56 void show_attributes(struct attribute *attr) 57 { 58 if (attr == NULL) 59 return; 60 show_attribute(attr); 61 show_attributes(attr->tail); 62 } 63 64 void show_attribute(struct attribute *attr) 65 { 66 printf("Attribute: %s", attr->attribute); 67 show_identifiers(attr->identifiers); 68 printf("\n"); 69 } 70 71 void show_parameters(struct parameter *param) 72 { 73 if (param == NULL) 74 return; 75 show_parameter(param); 76 show_parameters(param->tail); 77 } 78 79 void show_parameter(struct parameter *param) 80 { 81 char *type; 82 83 printf("Parameter: %s%s", param->specifier & IN_PARAMETER ? "IN" : "", 84 param->specifier & OUT_PARAMETER ? "OUT" : ""); 85 86 /* Items must have their type identifiers restored. */ 87 88 if (param->cls & ITEM_CLASS) 89 { 90 type = param->cls == FPAGE_ITEM ? "fpage" : "cap"; 91 printf(" %s", type); 92 } 93 94 show_identifiers(param->identifiers); 95 printf("\n"); 96 } 97 98 void show_identifiers(struct identifier *ident) 99 { 100 while (ident != NULL) 101 { 102 printf(" %s", ident->identifier); 103 ident = ident->tail; 104 } 105 }