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