1 /* 2 * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana 3 * University Research and Technology 4 * Corporation. All rights reserved. 5 * Copyright (c) 2004-2005 The University of Tennessee and The University 6 * of Tennessee Research Foundation. All rights 7 * reserved. 8 * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, 9 * University of Stuttgart. All rights reserved. 10 * Copyright (c) 2004-2005 The Regents of the University of California. 11 * All rights reserved. 12 * Copyright (c) 2018 Cisco Systems, Inc. All rights reserved. 13 * $COPYRIGHT$ 14 * 15 * Additional copyrights may follow 16 * 17 * $HEADER$ 18 */ 19 20 /** @file: 21 * Creates an operating system-acceptable path name. 22 * 23 * The opal_os_path() function takes a variable number of string arguments and 24 * concatenates them into a path name using the path separator character appropriate 25 * to the local operating system. NOTE: the string returned by this function has been 26 * malloc'd - thus, the user is responsible for free'ing the memory used by 27 * the string. 28 * 29 * CRITICAL NOTE: The input variable list MUST be terminated by a NULL value. Failure 30 * to do this will cause the program to suffer a catastrophic failure - usually a 31 * segmentation violation or bus error. 32 * 33 * The function calls orte_sys_info() to ensure that the path separator character 34 * has been identified. If that value cannot be identified for some reason, 35 * the function will return a NULL value. Likewise, specifying a path name that 36 * exceeds the maximum allowable path name length on the local system will result 37 * in the return of a NULL value. 38 * 39 * 40 */ 41 42 #ifndef OPAL_OS_PATH_H 43 #define OPAL_OS_PATH_H 44 45 #include "opal_config.h" 46 47 #include <stdio.h> 48 #include <stdarg.h> 49 50 BEGIN_C_DECLS 51 52 /** 53 * @param relative A boolean that specifies if the path name is to be constructed 54 * relative to the current directory or as an absolute path. If no path 55 * elements are included in the function call, then the function returns 56 * "." for a relative path name and "<path separator char>" - 57 * the top of the directory tree - for an absolute path name. 58 * @param elem1,elem2,... A variable number of (char *)path_elements 59 * can be provided to the function, terminated by a NULL value. These 60 * elements will be concatenated, each separated by the path separator 61 * character, into a path name and returned. 62 * @retval path_name A pointer to a fully qualified path name composed of the 63 * provided path elements, separated by the path separator character 64 * appropriate to the local operating system. The path_name string has been malloc'd 65 * and therefore the user is responsible for free'ing the field. 66 * 67 * Note that the "relative" argument is int instead of bool, because 68 * passing a parameter that undergoes default argument promotion to 69 * va_start() has undefined behavior (according to clang warnings on 70 * MacOS High Sierra). 71 */ 72 OPAL_DECLSPEC char *opal_os_path(int relative, ...) __opal_attribute_malloc__ __opal_attribute_sentinel__ __opal_attribute_warn_unused_result__; 73 74 /** 75 * Convert the path to be OS friendly. On UNIX this function will 76 * be empty. 77 */ 78 #define opal_make_filename_os_friendly(PATH) (PATH) 79 80 END_C_DECLS 81 82 #endif /* OPAL_OS_PATH_H */