Text of llvm.org › doxygen › AutoConvert_8h_source.html as Styx crawled it on Oct 8, 2026. The page may have changed since. Only its words are kept, without pictures or layout.

Open the live page

LLVM: include/llvm/Support/AutoConvert.h Source File

LLVM 24.0.0git include llvm Support AutoConvert.h Go to the documentation of this file. 1 /*===- AutoConvert.h - Auto conversion between ASCII/EBCDIC -----*- C++ -*-===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 // 9 // This file contains functions used for auto conversion between 10 // ASCII/EBCDIC codepages specific to z/OS.

11 // 12 //===----------------------------------------------------------------------===*/ 13 14 #ifndef LLVM_SUPPORT_AUTOCONVERT_H 15 #define LLVM_SUPPORT_AUTOCONVERT_H 16 17 #ifdef __MVS__ 18 #include <_Ccsid.h> 19 #endif 20 #ifdef __cplusplus 21 #include " llvm/ADT/Twine.h " 22 #include " llvm/Support/Error.h " 23 #include " llvm/Support/File.h " 24 #include <system_error> 25 #endif /* __cplusplus */ 26 27 #define CCSID_IBM_1047 1047 28 #define CCSID_UTF_8 1208 29 #define CCSID_ISO8859_1 819 30 31 #ifdef __cplusplus 32 extern "C" { 33 #endif /* __cplusplus */ 34 35 int enablezOSAutoConversion ( int FD); 36 int enablezOSAutoConversionCcsid ( int FD, int ccsid); 37 int disablezOSAutoConversion ( int FD); 38 int restorezOSStdHandleAutoConversion ( int FD); 39 40 #ifdef __cplusplus 41 } 42 #endif /* __cplusplus */ 43 44 #ifdef __cplusplus 45 namespace llvm { 46 47 #ifdef __MVS__ 48 49 /** \brief Set the tag information for a file descriptor. */ 50 std::error_code setzOSFileTag( sys::fs::file_t FD, int CCSID, bool IsText); 51 52 /** \brief Get the the tag ccsid for a file name or a file descriptor. */ 53 ErrorOr<__ccsid_t> getzOSFileTag( const Twine &FileName, 54 const sys::fs::file_t FD = {}); 55 56 /** \brief Query the file tag to determine if it needs conversion to UTF-8 57 * codepage.

58 */ 59 ErrorOr<bool> needzOSConversion( const Twine &FileName, 60 const sys::fs::file_t FD = {}); 61 62 /** Copy the tag attributes from \a source to \a destination. 63 * 64 * @param Source The name of the source file. 65 * @param Destination The file descriptor of the destination file. 66 * @returns errc::success if the tag attributes were copied successfully, 67 * otherwise returns a specific error_code. 68 */ 69 std::error_code copyFileTagAttributes( const std::string &Source, 70 const sys::fs::file_t DestinationFD); 71 72 #endif /* __MVS__*/ 73 74 inline std::error_code disableAutoConversion( sys::fs::file_t FD) { 75 #ifdef __MVS__ 76 if ( ::disablezOSAutoConversion (FD.get()) == -1) 77 return errnoAsErrorCode (); 78 #endif 79 return std::error_code(); 80 } 81 82 inline std::error_code enableAutoConversion( int FD) { 83 #ifdef __MVS__ 84 if ( ::enablezOSAutoConversion (FD) == -1) 85 return errnoAsErrorCode (); 86 #endif 87 return std::error_code(); 88 } 89 90 inline std::error_code enableAutoConversion( sys::fs::file_t FD) { 91 #ifdef __MVS__ 92 return enableAutoConversion(FD.get()); 93 #endif 94 return std::error_code(); 95 } 96 97 inline std::error_code enableAutoConversion( sys::fs::file_t FD, int ccsid) { 98 #ifdef __MVS__ 99 if ( ::enablezOSAutoConversionCcsid (FD.get(), ccsid) == -1) 100 return errnoAsErrorCode (); 101 #endif 102 return std::error_code(); 103 } 104 105 inline std::error_code restoreStdHandleAutoConversion( int FD) { 106 #ifdef __MVS__ 107 if ( ::restorezOSStdHandleAutoConversion (FD) == -1) 108 return errnoAsErrorCode (); 109 #endif 110 return std::error_code(); 111 } 112 113 inline std::error_code restoreStdHandleAutoConversion( sys::fs::file_t FD) { 114 #ifdef __MVS__ 115 return restoreStdHandleAutoConversion(FD.get()); 116 #endif 117 return std::error_code(); 118 } 119 120 inline std::error_code setFileTag( sys::fs::file_t FD, int CCSID, bool IsText) { 121 #ifdef __MVS__ 122 return setzOSFileTag(FD.get(), CCSID, IsText); 123 #endif 124 return std::error_code(); 125 } 126 127 inline ErrorOr<bool> needConversion( const Twine &FileName, 128 const sys::fs::file_t FD = {}) { 129 #ifdef __MVS__ 130 return needzOSConversion(FileName, FD.get()); 131 #endif 132 return false ; 133 } 134 135 } /* namespace llvm */ 136 #endif /* __cplusplus */ 137 138 #endif /* LLVM_SUPPORT_AUTOCONVERT_H */ restorezOSStdHandleAutoConversion int restorezOSStdHandleAutoConversion(int FD) enablezOSAutoConversionCcsid int enablezOSAutoConversionCcsid(int FD, int ccsid) enablezOSAutoConversion int enablezOSAutoConversion(int FD) disablezOSAutoConversion int disablezOSAutoConversion(int FD) File.h This file declares llvm::sys::fs::file_t type.

Twine.h llvm::ErrorOr Represents either an error or a value T. Definition ErrorOr.h:56 llvm::Twine Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu... Definition Twine.h:82 Error.h llvm This is an optimization pass for GlobalISel generic memory operations. Definition DefaultTargetInfo.h:21 llvm::errnoAsErrorCode std::error_code errnoAsErrorCode() Helper to get errno as an std::error_code.

Definition Error.h:1256 llvm::sys::fs::file_t This class wraps the platform specific file handle/descriptor type to provide an unified representati... Definition File.h:21 Generated on for LLVM by 1.14.0