1 /* 2 * Common routines. 3 * 4 * Copyright (C) 2019, 2020, 2022 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 #pragma once 23 24 #include <stdio.h> 25 #include "types.h" 26 27 /* Error message generation. */ 28 29 void open_error(const char *dir, const char *name); 30 31 /* Filename testing and manipulation. */ 32 33 int is_basename(char *path); 34 char *make_basename(const char *path); 35 char *make_dirname(const char *path); 36 37 /* File opening. */ 38 39 FILE *get_output_file(const char *filename_template, const char *dir, const char *name); 40 41 /* Interface testing. */ 42 43 int is_compound_interface(struct interface *iface); 44 45 /* Interface attribute access. */ 46 47 char *get_attribute_value(struct attribute *attr, const char *name); 48 char *get_opcode(struct attribute *attr); 49 char *get_opcode_type(struct attribute *attr); 50 char *get_protocol(struct attribute *attr); 51 char *get_operation_wrapper_prefix(struct attribute *attr); 52 int have_attribute(struct attribute *attr, const char *name); 53 int have_attribute_value(struct attribute *attr, const char *name, const char *value); 54 int have_identifier(struct identifier *ident, const char *value); 55 56 /* Function role selection. */ 57 58 enum function_role get_server_function_role(struct signature *sig); 59 60 /* Dispatcher object conversion (from compound to individual interfaces). */ 61 62 char *get_object_conversion(struct interface *iface, int compound); 63 64 /* Interface and operation naming. */ 65 66 char *get_interface_class_name(struct interface *iface, 67 enum component_role component); 68 69 char *get_signature_operation_name(struct interface *iface, 70 struct signature *sig, 71 enum component_role component, 72 enum signature_role role, 73 enum language lang); 74 75 char *get_operation_name(struct interface *iface, struct signature *sig); 76 char *get_opcode_identifier(char *protocol, char *opname); 77 78 const char *get_parameter_decoration(struct parameter *param, 79 enum parameter_role role, 80 enum function_role function); 81 82 char *get_parameter_name(struct identifier *ident); 83 char *get_signature_terminator(enum signature_role role); 84 85 void count_parameters(struct parameter *param, int *input_words, 86 int *input_items, int *output_words, int *output_items); 87 88 int get_max_input_items(struct interface *iface); 89 90 /* Message access details. */ 91 92 char *access_name(struct parameter *param, enum component_role component, int writing); 93 char *item_type_name(struct parameter *param, enum component_role component, int writing); 94 int specify_receive_fpage(struct parameter *param, enum component_role component, int writing); 95 char *reference_message(enum component_role component, enum function_role function); 96 char *structure_prefix(enum specifier direction); 97 int writing_to_message(enum component_role component, enum specifier direction);