Changeset 17
- Timestamp:
- Sep 21, 2014, 8:45:02 AM (11 years ago)
- Location:
- rxutilex/trunk
- Files:
-
- 7 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
rxutilex/trunk/FUNCTIONS
r16 r17 4 4 5 5 Sys2CheckNamedPipe - Check the status of a named pipe 6 Sys2Close - Close a file or named pipe 6 7 Sys2ConnectNamedPipe - Enable client sessions on a named pipe 7 8 Sys2CreateNamedPipe - Create a named pipe … … 14 15 Sys2LoadFuncs - Register all functions 15 16 Sys2LocateDLL - Search for a loaded/loadable DLL 17 Sys2Open - Open a file or stream (with >2GB support) 16 18 Sys2PutClipboardText - Copy a text string to the clipboard 17 19 Sys2QueryForegroundProcess - Get the PID of the current foreground process … … 19 21 Sys2QueryProcess - Get information about a process 20 22 Sys2QueryProcessList - Get the list of running processes 21 Sys2Read - 23 Sys2Read - Read bytes from a file or named pipe 22 24 Sys2ReplaceModule - Unlock a DLL (DosReplaceModule wrapper) 25 Sys2Seek - Set file read/write pointer (with >2GB support) 23 26 Sys2Version - Get the version of this library 27 Sys2Write - Write bytes to a file or named pipe 24 28 25 29 … … 45 49 46 50 ------------------------------------------------------------------------- 51 Sys2Close 52 53 Close a file or stream (wrapper to DosClose). 54 55 REXX ARGUMENTS: 56 1. File handle (returned by Sys2Open). (REQUIRED) 57 58 REXX RETURN VALUE: 59 1 on success, or 0 if an error occurred. 60 61 62 ------------------------------------------------------------------------- 47 63 Sys2ConnectNamedPipe 48 64 … … 60 76 Sys2CreateNamedPipe 61 77 62 Creates a named pipe with the specified name and parameters. 78 Creates a named pipe with the specified name and parameters. Only byte 79 mode is supported; message mode is not. 63 80 64 81 Note that the standard REXX functions such as CHARIN/OUT, which operate 65 82 directly on file names, are not capable of using the pipe handle returned 66 83 from this function. While the client end can use such functions after 67 using STREAM to issue an OPEN WRITE or OPEN READ command, the hostend84 using STREAM to issue an OPEN WRITE or OPEN READ command, the server end 68 85 needs to use the pipe handle from this function, and must therefore use 69 86 Sys2Read/Sys2Write in order to read and write data from the pipe. 87 88 Named pipes can be created in inbound-only, outbound-only, or duplex 89 (inbound/outbound) mode. An error will result if attempting to write 90 to an inbound-only pipe, or read from an outbound-only pipe. 91 92 To activate a named pipe so that client processes can connect to it, use 93 Sys2ConnectNamedPipe. To check the pipe's connection status, as well as 94 the amount of data currently in the pipe, use Sys2CheckNamedPipe. To 95 unlock a named pipe after a client has closed the connection, use 96 Sys2DisconnectNamedPipe. Finally, the pipe should be destroyed using 97 Sys2Close when no longer needed. 70 98 71 99 REXX ARGUMENTS: … … 232 260 233 261 ------------------------------------------------------------------------- 234 262 Sys2Open 263 264 Opens a file or other stream; files larger than 2GB are supported (this 265 function is a wrapper to DosOpenL). Direct-DASD mode is not supported by 266 this function, nor is setting the initial extended attributes. 267 268 REXX ARGUMENTS: 269 1. Name of file or stream to open. (REQUIRED) 270 2. Open action flags, must be either "O" (open if exists), "R" (replace 271 if exists), or nothing (fail if exists), optionally followed by "C" 272 (create if file does not exist). If "C" is not specified, the 273 operation will fail if the file does not exist. Note that a value 274 of "" alone will therefore fail automatically. (DEFAULT: "O") 275 In summary, the possible combinations are: 276 O = Open only (if file exists, open it; if not, fail) 277 OC= Open/create (if file exists, open it; if not, create it) 278 R = Replace only (if file exists, replace it; if not, fail) 279 RC= Replace/create (if file exists, replace it; if not, create it) 280 C = Create only (if file exists, fail; if not, create it) 281 (empty) = No-op (if file exists, fail; if not, fail) 282 3. Access mode flags, one or both of: (DEFAULT: "RW") 283 R = Open file with read access. 284 W = Open file with write access. 285 4. Sharing mode flags, any combination of: (DEFAULT: "W") 286 R = Deny read access to other processes 287 W = Deny write access to other processes 288 5. Deny legacy DosOpen access, one of: 289 0 = Allow DosOpen to access the file (DEFAULT) 290 1 = Deny access using the DosOpen API 291 6. Privacy/inheritance flag, one of: 292 0 = The file handle is inherited by child processes. (DEFAULT) 293 1 = The file handle is private to the current process. 294 7. Initial file attributes when creating a file: (DEFAULT: "") 295 A = Archive attribute set 296 D = Directory attribute set 297 S = System attribute set 298 H = Hidden attribute set 299 R = Read-only attribute set 300 8. Initial file size when creating or replacing a file; ignored if 301 access mode is read-only. (DEFAULT: 0) 302 9. I/O mode flags, any or all of: (DEFAULT: "") 303 T = Write-through mode (default is normal write) 304 N = No-cache mode (default is to use filesystem cache) 305 S = Sequential access 306 R = Random access 307 * S and R can combine as follows: 308 Neither: No locality known (default) 309 S only: Mainly sequential access 310 R only: Mainly random access 311 Both: Random/sequential (i.e. random with some locality) 312 313 REXX RETURN VALUE: 314 File handle, or "" in case of error. 315 316 317 ------------------------------------------------------------------------- 235 318 Sys2PutClipboardText 236 319 … … 323 406 Sys2Read 324 407 325 Read bytes from a previously-opened stream (wrapper to DosRead). The 326 format of file handles supported by this function is currently limited 327 to those returned by Sys2CreateNamedPipe. 328 329 REXX ARGUMENTS: 330 1. File handle (as returned by Sys2CreateNamedPipe). (REQUIRED) 408 Read bytes from a previously-opened stream (wrapper to DosRead). 409 410 REXX ARGUMENTS: 411 1. File handle (as returned by Sys2Open or Sys2CreateNamedPipe). 412 (REQUIRED) 331 413 2. Number of bytes to read. (REQUIRED) 332 414 … … 350 432 351 433 ------------------------------------------------------------------------- 434 Sys2Seek 435 436 Move the read/write pointer to the specified location in an open 437 file/stream; files larger than 2GB are supported (this function is a 438 wrapper to DosSetFilePtrL). 439 440 REXX ARGUMENTS: 441 1. File handle (returned by Sys2Open). (REQUIRED) 442 2. The signed distance in bytes to move. (REQUIRED) 443 3. Move method, one of: 444 B = Beginning of file 445 C = Current position (DEFAULT) 446 E = End of file 447 448 REXX RETURN VALUE: 449 The new file position, in bytes. 450 451 452 ------------------------------------------------------------------------- 352 453 Sys2Version 353 454 … … 357 458 REXX RETURN VALUE: Current version in the form "major.minor.refresh" 358 459 460 461 ------------------------------------------------------------------------- 462 Sys2Write 463 464 Write bytes to a previously-opened stream (wrapper to DosWrite). 465 466 REXX ARGUMENTS: 467 1. File handle (as returned by Sys2Open or Sys2CreateNamedPipe). 468 (REQUIRED) 469 2. Data to be written. (REQUIRED) 470 471 REXX RETURN VALUE: 472 The number of bytes successfully written. 473 -
rxutilex/trunk/TODO
r16 r17 2 2 3 3 * Sys2ReplaceModule - A wrapper for DosReplaceModule() 4 * Named pipe management functions 5 * Open/Close/Seek/Read/Write functions with large file support 4 6 - Sys2TokenizeString - A string tokenizer 5 7 - Sys2FormatNumber - Format a number according to locale 6 8 - Sys2FormatCurrency - A strfmon wrapper 7 9 - Sys2GetResource - DosGetResource wrapper 8 - Sys2PrintFile - Print a file to a port or queue9 10 - Sys2IsDirectory - Determine if filespec is a directory 10 11 11 12 Under consideration: 12 - BLDLEVEL parser 13 - Sys2PrintFile - Print a file to a port or queue 14 - Sys2StemSort - Sort the values in an array stem 13 15 - SYSLEVEL parser 14 - Functions to open/read/write Large files 15 ? Named pipe creation/deletion? 16 - BLDLEVEL parser <-- exists in rxunlock 16 17 ? Install a font 17 ? Create a printer port18 ? Create a printer queue19 ? Install a printer "driver.device"20 18 ? Sys2IncFileName: find the next available filename according to a pattern 21 19 (e.g. CONFIG.001, log_0004.txt, etc.) 20 ? Create a printer port <-- in rxprtutil 21 ? Create a printer queue <-- in rxprtutil 22 ? Install a printer "driver.device" <-- in rxprtutil 22 23 ? Access to the Win32 registry <-- exists in sp1utils 23 24 ? Sys2CloseWindow & Sys2ExitWindow <-- exists in pr1util -
rxutilex/trunk/readme.txt
r4 r17 1 REXX Utility Functions - Extended (RXUTILEX.DLL) 2 http://trac.netlabs.org/rexxlibs/ 3 1 4 OBJECTIVE 2 5 3 6 The purpose behind the RXUTILEX library is that it should basically provide 4 everything that _should_ have been in RexxUtil, but isn't. Specifically, 7 everything that _should_ have been in RexxUtil, but isn't. Specifically, 5 8 useful system-related functions of a relatively general-purpose nature, 6 9 as well as commonly-needed data formatting routines. 7 8 This includes things like 10 11 This includes things like 9 12 (* = already at least partially implemented): 10 13 - clipboard access * … … 12 15 - system information (like installed RAM*) 13 16 - locked-file replacement * 14 - wrappers for strftime()*, mktime()*, and strfmon() 17 - wrappers for strftime()*, mktime()*, and strfmon() 18 - named pipe creation/deletion * 19 - functions to read/write huge (>2GB) files * 15 20 - a string tokenizer 16 - named pipe creation/deletion17 21 - access to resources (DosGetResource) 18 - functions to read/write huge (>2GB) files19 22 and other things that the community decides is needed. 20 21 While it is true that many of these functions already exist in a scattering of 22 other REXX libraries, many of those other libraries are no longer maintained 23 and/or are closed-source, and cannot be updated by the community. Others are 23 24 While it is true that many of these functions already exist in a scattering of 25 other REXX libraries, many of those other libraries are no longer maintained 26 and/or are closed-source, and cannot be updated by the community. Others are 24 27 relatively special-purpose, and only include one or two general-utility 25 28 functions. 26 27 One of the main motivations of this project is to try and reduce "Yet Another 28 REXX Library" syndrome - where a REXX application requires a myriad of different 29 REXX DLLs purely for the same of one or two useful functions in each one. It 30 would be nice if most of the commonly-required functions were available in a 31 single library. Moreover, that library should be open source and maintained by 32 the OS/2 community, able to be updated and extended as needed. 33 34 On the other hand, it is also important to avoid overloading RXUTILEX with too 35 many functions. RXUTILEX should ideally be limited to providing functions which 36 are generally useful for a wide variety of applications. (There will always be 37 relatively specialized areas of support which SHOULD have their own dedicated 38 REXX libraries - RXLVM and RXULS are obvious examples.) 39 40 29 30 One of the main motivations of this project is to try and reduce "Yet Another 31 REXX Library" syndrome - wherein a REXX application requires a myriad of REXX 32 DLLs purely for the sake of one or two useful functions in each one. It would 33 be nice if most of the commonly-required functions were available in a single 34 library. Moreover, that library should be open source and maintained by the 35 OS/2 community, able to be updated and extended as needed. 36 37 On the other hand, it is also desirable to avoid overloading RXUTILEX with too 38 many functions. RXUTILEX should be limited to providing functions which are 39 generally useful for a wide variety of applications. (There will always be 40 relatively specialized areas of support which should continue to have their 41 own dedicated REXX libraries - RXLVM, for example.) 42 43 44 BUILD NOTES 45 46 The included Makefile is for the IBM C/C++ compiler. Version 3.6 or later 47 is required in order to support the parsing of 64-bit integers. 48 49 41 50 TERMS OF USE 42 51 43 Once the logistics are worked out, the source code for RXUTILEX will become 44 available via SVN under a non-restrictive open source license (which is still 45 to be determined). 52 REXX Utility Functions - Extended (RXUTILEX) 53 (C) 2011, 2014 Alex Taylor. 46 54 47 Until then, this binary-only preview release of RXUTILEX may be used freely and 48 with no restrictions. 55 Redistribution and use in source and binary forms, with or without 56 modification, are permitted provided that the following conditions are 57 met: 49 58 50 This release of RXUTILEX has no warranty, and is not guaranteed to work as 51 advertised or to be fit for any purpose whatsoever. 59 1. Redistributions of source code must retain the above copyright 60 notice, this list of conditions and the following disclaimer. 61 62 2. Redistributions in binary form must reproduce the above copyright 63 notice, this list of conditions and the following disclaimer in the 64 documentation and/or other materials provided with the distribution. 65 66 3. The name of the author may not be used to endorse or promote products 67 derived from this software without specific prior written permission. 68 69 THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR 70 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 71 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 72 DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 73 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 74 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 75 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 76 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 77 STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 78 ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 79 POSSIBILITY OF SUCH DAMAGE. 80 81 The source code for RXUTILEX is available via SVN at 82 http://svn.netlabs.org/repos/rexxlibs/rxutilex/ 83 -
rxutilex/trunk/rxutilex.c
r16 r17 1713 1713 * Sys2Close * 1714 1714 * * 1715 * Wrapper to Dos Write: write bytes to a previously-opened stream.*1715 * Wrapper to DosClose: close a file/stream. * 1716 1716 * * 1717 1717 * REXX ARGUMENTS: * … … 1791 1791 strupr( argv[2].strptr ); 1792 1792 if ( strcspn(argv[2].strptr, "BCE") > 0 ) return ( 40 ); 1793 switch ( argv[ 1].strptr[0] ) {1793 switch ( argv[2].strptr[0] ) { 1794 1794 case 'B': ulMethod = FILE_BEGIN; break; 1795 1795 case 'E': ulMethod = FILE_END; break; … … 1874 1874 * * 1875 1875 * REXX RETURN VALUE: * 1876 * 1 on success, or 0 if an error occurred.*1876 * Number of bytes written. * 1877 1877 * ------------------------------------------------------------------------- */ 1878 1878 ULONG APIENTRY Sys2Write( PSZ pszName, ULONG argc, RXSTRING argv[], PSZ pszQueue, PRXSTRING prsResult ) … … 1880 1880 HFILE hf; 1881 1881 ULONG cbActual; 1882 CHAR szActual[ US_INTEGER_MAXZ ]; 1882 1883 APIRET rc; 1883 1884 … … 1894 1895 // (Second argument can be left in standard RXSTRING form) 1895 1896 1896 rc = DosWrite( hf, argv[ 0].strptr, argv[0].strlength, &cbActual );1897 rc = DosWrite( hf, argv[1].strptr, argv[1].strlength, &cbActual ); 1897 1898 if ( rc != NO_ERROR ) { 1898 1899 WriteErrorCode( rc, "DosWrite"); 1899 1900 MAKERXSTRING( *prsResult, "0", 1 ); 1900 }1901 else {1902 MAKERXSTRING( *prsResult, "1", 1 ); 1903 }1904 1901 return ( 0 ); 1902 } 1903 1904 sprintf( szActual, "%d", cbActual ); 1905 MAKERXSTRING( *prsResult, szActual, strlen( szActual )); 1905 1906 return ( 0 ); 1906 1907 } … … 2182 2183 2183 2184 if ( pszContext == NULL ) 2184 sprintf( szErrorText, "% X", ulError );2185 sprintf( szErrorText, "%u", ulError ); 2185 2186 else 2186 sprintf( szErrorText, "% X: %s", ulError, pszContext );2187 sprintf( szErrorText, "%u: %s", ulError, pszContext ); 2187 2188 MAKERXSTRING( shvVar.shvname, SZ_ERROR_NAME, strlen(SZ_ERROR_NAME) ); 2188 2189 MAKERXSTRING( shvVar.shvvalue, szErrorText, strlen(szErrorText) ); -
rxutilex/trunk/rxutilex.def
r16 r17 1 1 LIBRARY RXUTILEX INITINSTANCE TERMINSTANCE 2 2 DATA MULTIPLE NONSHARED 3 DESCRIPTION '@#Alex Taylor:0.0.5#@##1## 2 0 Sep 2014 20:12:24REINFORCE::::::@@Extra REXX Utility Functions'3 DESCRIPTION '@#Alex Taylor:0.0.5#@##1## 21 Sep 2014 15:39:46 REINFORCE::::::@@Extra REXX Utility Functions' 4 4 5 5 EXPORTS Sys2LoadFuncs -
rxutilex/trunk/testlib.cmd
r16 r17 35 35 say Sys2LocateDLL('ehxdlmri') 36 36 37 hp = Sys2CreateNamedPipe("\PIPE\RNPTEST", 0, 100 )38 if hp == "" then say SYS2ERR39 else do40 ok = Sys2ConnectNamedPipe( hp )41 if ok == 0 then say SYS2ERR42 else do43 PARSE VALUE Sys2CheckNamedPipe( hp ) WITH _cb _state44 say _cb 'bytes waiting'45 /*data = Sys2Read( hp, _cb )*/46 data = charin("\PIPE\RNPTEST",, _cb)47 say 'Data: "'c2x(data)'"'48 end49 ok = Sys2DisconnectNamedPipe( hp )50 if ok == 0 then say SYS2ERR51 end52 53 37 call Sys2DropFuncs 54 38 return 0
Note:
See TracChangeset
for help on using the changeset viewer.