OMCompiler/Compiler/Util/IOStreamExt.mo
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /* | ||
| 2 | * This file is part of OpenModelica. | ||
| 3 | * | ||
| 4 | * Copyright (c) 1998-2026, Open Source Modelica Consortium (OSMC), | ||
| 5 | * c/o Linköpings universitet, Department of Computer and Information Science, | ||
| 6 | * SE-58183 Linköping, Sweden. | ||
| 7 | * | ||
| 8 | * All rights reserved. | ||
| 9 | * | ||
| 10 | * THIS PROGRAM IS PROVIDED UNDER THE TERMS OF AGPL VERSION 3 LICENSE OR | ||
| 11 | * THIS OSMC PUBLIC LICENSE (OSMC-PL) VERSION 1.8. | ||
| 12 | * ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS PROGRAM CONSTITUTES | ||
| 13 | * RECIPIENT'S ACCEPTANCE OF THE OSMC PUBLIC LICENSE OR THE GNU AGPL | ||
| 14 | * VERSION 3, ACCORDING TO RECIPIENTS CHOICE. | ||
| 15 | * | ||
| 16 | * The OpenModelica software and the OSMC (Open Source Modelica Consortium) | ||
| 17 | * Public License (OSMC-PL) are obtained from OSMC, either from the above | ||
| 18 | * address, from the URLs: | ||
| 19 | * http://www.openmodelica.org or | ||
| 20 | * https://github.com/OpenModelica/ or | ||
| 21 | * http://www.ida.liu.se/projects/OpenModelica, | ||
| 22 | * and in the OpenModelica distribution. | ||
| 23 | * | ||
| 24 | * GNU AGPL version 3 is obtained from: | ||
| 25 | * https://www.gnu.org/licenses/licenses.html#GPL | ||
| 26 | * | ||
| 27 | * This program is distributed WITHOUT ANY WARRANTY; without | ||
| 28 | * even the implied warranty of MERCHANTABILITY or FITNESS | ||
| 29 | * FOR A PARTICULAR PURPOSE, EXCEPT AS EXPRESSLY SET FORTH | ||
| 30 | * IN THE BY RECIPIENT SELECTED SUBSIDIARY LICENSE CONDITIONS OF OSMC-PL. | ||
| 31 | * | ||
| 32 | * See the full OSMC Public License conditions for more details. | ||
| 33 | * | ||
| 34 | */ | ||
| 35 | |||
| 36 | encapsulated package IOStreamExt | ||
| 37 | "file: IOStreamExt.mo | ||
| 38 | package: IOStreamExt | ||
| 39 | description: External Stream Utilities | ||
| 40 | @author: Adrian Pop [adrpo@ida.liu.se] | ||
| 41 | @date: 2010-05-19 | ||
| 42 | |||
| 43 | |||
| 44 | This package describes an external interface for streams. | ||
| 45 | The external C implementation is in TOP/Compiler/runtime/IOStreamExt.c" | ||
| 46 | |||
| 47 | ✗ | function createFile | |
| 48 | input String fileName; | ||
| 49 | output Integer fileID; | ||
| 50 | |||
| 51 | external "C" fileID=IOStreamExt_createFile(fileName) annotation(Library = "omcruntime"); | ||
| 52 | end createFile; | ||
| 53 | |||
| 54 | ✗ | function closeFile | |
| 55 | input Integer fileID; | ||
| 56 | |||
| 57 | external "C" IOStreamExt_closeFile(fileID) annotation(Library = "omcruntime"); | ||
| 58 | end closeFile; | ||
| 59 | |||
| 60 | ✗ | function deleteFile | |
| 61 | input Integer fileID; | ||
| 62 | |||
| 63 | external "C" IOStreamExt_deleteFile(fileID) annotation(Library = "omcruntime"); | ||
| 64 | end deleteFile; | ||
| 65 | |||
| 66 | ✗ | function clearFile | |
| 67 | input Integer fileID; | ||
| 68 | |||
| 69 | external "C" IOStreamExt_clearFile(fileID) annotation(Library = "omcruntime"); | ||
| 70 | end clearFile; | ||
| 71 | |||
| 72 | ✗ | function appendFile | |
| 73 | input Integer fileID; | ||
| 74 | input String inString; | ||
| 75 | |||
| 76 | external "C" IOStreamExt_appendFile(fileID,inString) annotation(Library = "omcruntime"); | ||
| 77 | end appendFile; | ||
| 78 | |||
| 79 | ✗ | function readFile | |
| 80 | input Integer fileID; | ||
| 81 | output String outString; | ||
| 82 | |||
| 83 | external "C" outString=IOStreamExt_readFile(fileID) annotation(Library = "omcruntime"); | ||
| 84 | end readFile; | ||
| 85 | |||
| 86 | ✗ | function printFile | |
| 87 | input Integer fileID; | ||
| 88 | input Integer whereToPrint "stdout:1, stderr:2"; | ||
| 89 | |||
| 90 | external "C" IOStreamExt_printFile(fileID,whereToPrint) annotation(Library = "omcruntime"); | ||
| 91 | end printFile; | ||
| 92 | |||
| 93 | ✗ | function createBuffer | |
| 94 | output Integer bufferID; | ||
| 95 | |||
| 96 | external "C" bufferID = IOStreamExt_createBuffer() annotation(Library = "omcruntime"); | ||
| 97 | end createBuffer; | ||
| 98 | |||
| 99 | ✗ | function appendBuffer | |
| 100 | input Integer bufferID; | ||
| 101 | input String inString; | ||
| 102 | |||
| 103 | external "C" IOStreamExt_appendBuffer(bufferID,inString) annotation(Library = "omcruntime"); | ||
| 104 | end appendBuffer; | ||
| 105 | |||
| 106 | ✗ | function deleteBuffer | |
| 107 | input Integer bufferID; | ||
| 108 | |||
| 109 | external "C" IOStreamExt_deleteBuffer(bufferID) annotation(Library = "omcruntime"); | ||
| 110 | end deleteBuffer; | ||
| 111 | |||
| 112 | ✗ | function clearBuffer | |
| 113 | input Integer bufferID; | ||
| 114 | |||
| 115 | external "C" IOStreamExt_clearBuffer(bufferID) annotation(Library = "omcruntime"); | ||
| 116 | end clearBuffer; | ||
| 117 | |||
| 118 | ✗ | function readBuffer | |
| 119 | input Integer bufferID; | ||
| 120 | output String outString; | ||
| 121 | |||
| 122 | external "C" outString=IOStreamExt_readBuffer(bufferID) annotation(Library = "omcruntime"); | ||
| 123 | end readBuffer; | ||
| 124 | |||
| 125 | ✗ | function printBuffer | |
| 126 | input Integer bufferID; | ||
| 127 | input Integer whereToPrint "stdout:1, stderr:2"; | ||
| 128 | |||
| 129 | external "C" IOStreamExt_printBuffer(bufferID,whereToPrint) annotation(Library = "omcruntime"); | ||
| 130 | end printBuffer; | ||
| 131 | |||
| 132 | 1901 | function appendReversedList | |
| 133 | input list<String> inStringLst; | ||
| 134 | output String outString; | ||
| 135 | |||
| 136 | external "C" outString = IOStreamExt_appendReversedList(inStringLst) annotation(Library = "omcruntime"); | ||
| 137 | end appendReversedList; | ||
| 138 | |||
| 139 | 1901 | function printReversedList | |
| 140 | input list<String> inStringLst; | ||
| 141 | input Integer whereToPrint "stdout:1, stderr:2"; | ||
| 142 | |||
| 143 | external "C" IOStreamExt_printReversedList(inStringLst, whereToPrint) annotation(Library = "omcruntime"); | ||
| 144 | end printReversedList; | ||
| 145 | |||
| 146 | annotation(__OpenModelica_Interface="util"); | ||
| 147 | end IOStreamExt; | ||
| 148 |