source: rxutilex/trunk/FUNCTIONS@ 25

Last change on this file since 25 was 25, checked in by Alex Taylor, 10 years ago

Added Sys2SyncBuffer function. Updated version number to 0.1.2.

File size: 20.5 KB
Line 
1FUNCTIONS IN RXUTILEX.DLL
2
3(See file 'TODO' for functions which are under consideration to be added.)
4
5Sys2CheckNamedPipe - Check the status of a named pipe (server side)
6Sys2Close - Close a file or named pipe
7Sys2ConnectNamedPipe - Enable client sessions on a named pipe
8Sys2CreateNamedPipe - Create a named pipe
9Sys2DisconnectNamedPipe - Acknowledge that a named pipe session has ended
10Sys2DropFuncs - Deregister all functions
11Sys2FormatNumber - Format a number with thousands-grouping characters
12Sys2FormatTime - Format calender time (strftime wrapper)
13Sys2GetClipboardText - Retrieve the current clipboard text
14Sys2GetEpochTime - Get or convert calender time (seconds from epoch)
15Sys2KillProcess - Kill a process by name or PID
16Sys2LoadFuncs - Register all functions
17Sys2LocateDLL - Search for a loaded/loadable DLL
18Sys2Open - Open a file or stream (with >2GB support)
19Sys2PutClipboardText - Copy a text string to the clipboard
20Sys2QueryForegroundProcess - Get the PID of the current foreground process
21Sys2QueryPhysicalMemory - Get the amount of installed RAM
22Sys2QueryProcess - Get information about a process
23Sys2QueryProcessList - Get the list of running processes
24Sys2Read - Read bytes from a file or named pipe
25Sys2ReplaceModule - Unlock a DLL (DosReplaceModule wrapper)
26Sys2Seek - Set file read/write pointer (with >2GB support)
27Sys2Version - Get the version of this library
28Sys2Write - Write bytes to a file or named pipe
29
30
31If an internal error occurs in any function, the variable SYS2ERR will contain
32an error message of the form "RC: description" where RC is a non-zero error
33code, and description indicates the internal function call that failed. If
34no error occurs, SYS2ERR will be "0".
35
36
37-------------------------------------------------------------------------
38Sys2CheckNamedPipe
39
40Checks the status of a named pipe that was previously created using
41Sys2CreateNamedPipe.
42
43This function is designed for use by the process that created the pipe
44(i.e. the server side). Clients which are accessing a named pipe should
45use the standard REXX STREAM and/or CHARS functions to determine the
46pipe's status.
47
48REXX ARGUMENTS:
49 1. The pipe handle (from Sys2CreateNamedPipe or DosOpen). (REQUIRED)
50
51REXX RETURN VALUE:
52 String of the format "bytes status", where bytes is the number of bytes
53 currently waiting in the pipe, and status is one of: DISCONNECTED,
54 LISTENING, CONNECTED, or CLOSING.
55
56
57-------------------------------------------------------------------------
58Sys2Close
59
60Close a file or stream (wrapper to DosClose).
61
62REXX ARGUMENTS:
63 1. File handle (returned by Sys2Open). (REQUIRED)
64
65REXX RETURN VALUE:
66 1 on success, or 0 if an error occurred.
67
68
69-------------------------------------------------------------------------
70Sys2ConnectNamedPipe
71
72Start 'listening' by allowing clients to connect to a previously-created
73named pipe.
74
75REXX ARGUMENTS:
76 1. The pipe handle, as returned by Sys2CreateNamedPipe. (REQUIRED)
77
78REXX RETURN VALUE:
79 1 on success, or 0 if an error occurred.
80
81
82-------------------------------------------------------------------------
83Sys2CreateNamedPipe
84
85Creates a named pipe with the specified name and parameters. Only byte
86mode is supported; message mode is not.
87
88Note that the standard REXX functions such as CHARIN/OUT, which operate
89directly on file names, are not capable of using the pipe handle returned
90from this function. While the client end can use such functions after
91using STREAM to issue an OPEN WRITE or OPEN READ command, the server end
92needs to use the pipe handle from this function, and must therefore use
93Sys2Read/Sys2Write in order to read and write data from the pipe.
94
95Named pipes can be created in inbound-only, outbound-only, or duplex
96(inbound/outbound) mode. An error will result if attempting to write
97to an inbound-only pipe, or read from an outbound-only pipe.
98
99To activate a named pipe so that client processes can connect to it, use
100Sys2ConnectNamedPipe. To check the pipe's connection status, as well as
101the amount of data currently in the pipe, use Sys2CheckNamedPipe. To
102unlock a named pipe after a client has closed the connection, use
103Sys2DisconnectNamedPipe. Finally, the pipe can be destroyed using
104Sys2Close.
105
106REXX ARGUMENTS:
107 1. The name of the pipe, in the form "\PIPE\something". (REQUIRED)
108 2. The size of the outbound buffer, in bytes. (REQUIRED)
109 3. The size of the inbound buffer, in bytes. (REQUIRED)
110 4. The pipe's timeout value, in milliseconds. (DEFAULT: 3000)
111 5. The number of simultaneous instances of this pipe which are allowed.
112 Must be between 1 and 254, or 0 indicating no limit. (DEFAULT: 1)
113 6. Pipe blocking mode, one of:
114 W = WAIT mode, read and write block waiting for data (DEFAULT)
115 N = NOWAIT mode, read and write return immediately
116 7. Pipe mode, one of:
117 I = Inbound pipe (DEFAULT)
118 O = Outbound pipe
119 D = Duplex (inbound/outbound) pipe
120 8. Privacy/inheritance flag, one of:
121 0 = The pipe handle is inherited by child processes (DEFAULT)
122 1 = The pipe handle is private to the current process
123 9. Write-through flag, one of:
124 0 = Allow delayed writes (write-behind) to remote pipes (DEFAULT)
125 1 = Force immediate writes (write-through) to remote pipes
126
127REXX RETURN VALUE: A four-byte pipe handle.
128
129
130-------------------------------------------------------------------------
131Sys2DisconnectNamedPipe
132
133Unlocks a named pipe after a client has closed its connection.
134
135REXX ARGUMENTS:
136 1. The pipe handle, as returned by Sys2CreateNamedPipe. (REQUIRED)
137
138REXX RETURN VALUE:
139 1 on success, or 0 if an error occurred.
140
141
142-------------------------------------------------------------------------
143Sys2DropFuncs
144
145Deregisters all Sys2* REXX functions.
146
147REXX ARGUMENTS: None
148REXX RETURN VALUE: ""
149
150
151-------------------------------------------------------------------------
152Sys2FormatNumber
153
154Formats a number to use thousands-grouping characters. The system values
155for the current locale are used for the thousands-grouping character and
156the decimal place, if any. Note that the IBM C runtime's locale
157definitions are used; these may not correspond precisely to the system
158locales as defined in the OS/2 Locale object.
159
160The input number may be a positive or negative integer or floating point
161value. It must be a simple, non-localized number value; in other words,
162it must not contain any thousands-grouping characters, and any decimal
163point which it contains must be a period (rather than any localized
164decimal symbol).
165
166REXX ARGUMENTS:
167 1. Number to be formatted. (REQUIRED)
168 2. Number of decimal places to use for floating point values.
169 Ignored for integer values. (DEFAULT: 2)
170
171REXX RETURN VALUE: The formatted number, or '' on error.
172
173
174-------------------------------------------------------------------------
175Sys2FormatTime
176
177Converts a number of seconds from the epoch (1970-01-01 0:00:00 UTC) into
178a formatted date and time string.
179
180REXX ARGUMENTS:
181 1. Number of seconds (a positive integer) to be converted. (REQUIRED)
182 This value cannot be greater than 2,147,483,647.
183 2. Format type, one of:
184 D = return in the form 'yyyy-mm-dd hh:mm:ss (w)' where w
185 represents the weekday (0-6 where 0=Sunday) (DEFAULT)
186 I = return in ISO8601 combined form 'yyyy-mm-ddThh:mm:ss[Z]'
187 L = return in the form 'day month year (weekday) time' where month
188 and weekday are language-dependent abbreviations
189 Note: With D and I, time is returned in 24-hour format; L may vary.
190 3. TZ conversion flag (indicates whether to convert to UTC from local
191 time), one of:
192 U = return UTC or unconverted time
193 L = assume the input is in Coordinated Universal Time, and convert
194 to local time using the current TZ (DEFAULT)
195
196REXX RETURN VALUE: The formatted time string, or "" on error.
197
198
199-------------------------------------------------------------------------
200Sys2GetClipboardText
201
202Retrieves a plain-text string from the clipboard if one is available.
203
204This function requires Presentation Manager to be active, although the
205REXX program itself need not be running in a PM process.
206
207REXX ARGUMENTS:
208 None.
209
210REXX RETURN VALUE: The retrieved clipboard string
211
212
213-------------------------------------------------------------------------
214Sys2GetEpochTime
215
216Converts formatted date and time into a number of seconds (UTC) from the
217epoch (defined as 1970-01-01 0:00:00). The input time is assumed to
218refer to the current timezone as defined in the TZ environment variable.
219
220If no parameters are specified, the current system time is used. If at
221least one parameter is specified, then any missing parameter is assumed
222to be its minimum possible value (1 for day or month, 0 for all others).
223
224The time is formatted according to the C runtime's locale support, as
225configured via the LANG and LC_* environment variables.
226
227NOTE: Any date prior to 1 January 1970, or later than 19 January 2038,
228 cannot be supported due to the limitations in how the C library
229 calculates epoch time. Specifying any date before 1970 will generate
230 a REXX error. Any time/date later than 12:14:07 on 19 January 2038
231 will return the latter value.
232
233REXX ARGUMENTS:
234 1. The year (1970-2037)
235 A 2-digit year can be specified, in which case the number will be
236 added to 1900 if it is 70 or higher, or to 2000 otherwise.
237 e.g. '20' ==> 2020
238 '75' ==> 1975
239 (This is subject to the limitation noted above.)
240 2. The month (1-12)
241 3. The day (1-31)
242 4. Hours (0-23)
243 5. Minutes (0-59)
244 6. Seconds (0-61)
245
246REXX RETURN VALUE: The number of seconds since the epoch, or 0 on error.
247
248
249-------------------------------------------------------------------------
250Sys2KillProcess
251
252Terminates the (first) running process with the specified executable name
253or process-ID.
254
255REXX ARGUMENTS:
256 1. The process identifier (program name or process ID) (REQUIRED)
257 2. Flag indicicating the identifier type:
258 'P': decimal process ID
259 'H': hexadecimal process ID
260 'N': executable program name (with or without extension) (DEFAULT)
261
262REXX RETURN VALUE: 1 on success or 0 on failure.
263
264
265-------------------------------------------------------------------------
266Sys2LoadFuncs
267
268Registers all Sys2* REXX functions (except this one, obviously).
269
270REXX ARGUMENTS: None
271REXX RETURN VALUE: ""
272
273
274-------------------------------------------------------------------------
275Sys2LocateDLL
276
277Searches for a DLL by name and returns its fully-qualified path.
278
279If a DLL with the given name is currently loaded, that instance of the
280DLL will be returned. Otherwise, standard DLL loading rules (according
281to the current LIBPATH and/or extended LIBPATH configuration) are used to
282search for a DLL whose module name matches the one specified.
283
284REXX ARGUMENTS:
285 1. The name of the DLL to search for. (REQUIRED)
286
287
288REXX RETURN VALUE:
289 The fully-qualified path of the DLL, if found; "" otherwise.
290
291
292-------------------------------------------------------------------------
293Sys2Open
294
295Opens a file or other stream; files larger than 2GB are supported (this
296function is a wrapper to DosOpenL). Direct-DASD mode is not supported by
297this function, nor is setting the initial extended attributes.
298
299REXX ARGUMENTS:
300 1. Name of file or stream to open. (REQUIRED)
301 2. Open action flags, must be either "O" (open if exists), "R" (replace
302 if exists), or nothing (fail if exists), optionally followed by "C"
303 (create if file does not exist). If "C" is not specified, the
304 operation will fail if the file does not exist. Note that a value
305 of "" alone will therefore fail automatically. (DEFAULT: "O")
306 In summary, the possible combinations are:
307 O = Open only (if file exists, open it; if not, fail)
308 OC= Open/create (if file exists, open it; if not, create it)
309 R = Replace only (if file exists, replace it; if not, fail)
310 RC= Replace/create (if file exists, replace it; if not, create it)
311 C = Create only (if file exists, fail; if not, create it)
312 (empty) = No-op (if file exists, fail; if not, fail)
313 3. Access mode flags, one or both of: (DEFAULT: "RW")
314 R = Open file with read access.
315 W = Open file with write access.
316 4. Sharing mode flags, any combination of: (DEFAULT: "W")
317 R = Deny read access to other processes
318 W = Deny write access to other processes
319 5. Deny legacy DosOpen access, one of:
320 0 = Allow DosOpen to access the file (DEFAULT)
321 1 = Deny access using the DosOpen API
322 6. Privacy/inheritance flag, one of:
323 0 = The file handle is inherited by child processes. (DEFAULT)
324 1 = The file handle is private to the current process.
325 7. Initial file attributes when creating a file: (DEFAULT: "")
326 A = Archive attribute set
327 D = Directory attribute set
328 S = System attribute set
329 H = Hidden attribute set
330 R = Read-only attribute set
331 8. Initial file size when creating or replacing a file; ignored if
332 access mode is read-only. (DEFAULT: 0)
333 9. I/O mode flags, any or all of: (DEFAULT: "")
334 T = Write-through mode (default is normal write)
335 N = No-cache mode (default is to use filesystem cache)
336 S = Sequential access
337 R = Random access
338 * S and R can combine as follows:
339 Neither: No locality known (default)
340 S only: Mainly sequential access
341 R only: Mainly random access
342 Both: Random/sequential (i.e. random with some locality)
343
344REXX RETURN VALUE:
345 File handle, or "" in case of error.
346
347
348-------------------------------------------------------------------------
349Sys2PutClipboardText
350
351Writes a string to the clipboard in plain-text format. Specifying either
352no value or an empty string in the first argument will simply clear the
353clipboard of CF_TEXT data.
354
355This function requires Presentation Manager to be active, although the
356REXX program itself need not be running in a PM process.
357
358REXX ARGUMENTS:
359 1. String to be written to the clipboard (DEFAULT: "")
360 2. Flag indicating whether other clipboard formats should be cleared:
361 Y = yes, call WinEmptyClipbrd() before writing text (DEFAULT)
362 N = no, leave (non-CF_TEXT) clipboard data untouched
363
364REXX RETURN VALUE: 1 on success, 0 on failure
365
366
367-------------------------------------------------------------------------
368Sys2QueryForegroundProcess
369
370Queries the PID of the current foreground process. (Note that this is not
371necessarily the same as the process which is calling this function, which
372could, for example, be running in the background and/or as a child of the
373foreground process.)
374
375REXX ARGUMENTS: None
376
377REXX RETURN VALUE:
378 Integer representing the process ID (in decimal), or 0 if an error
379 occurred.
380
381
382-------------------------------------------------------------------------
383Sys2QueryPhysicalMemory
384
385Queries the amount of physical memory (RAM) installed in the system.
386
387REXX ARGUMENTS: None
388
389REXX RETURN VALUE:
390 Integer representing the amount of installed memory, in KiB, or 0 if an
391 error occurred.
392
393
394-------------------------------------------------------------------------
395Sys2QueryProcess
396
397Queries information about the specified process.
398
399Specifying a process ID of 0 will return the information for the
400current process (that is, the process calling this function); note that
401this requires the second parameter to specify that the identifier is in
402fact a process ID ('P' or 'H') rather than an executable name.
403
404REXX ARGUMENTS:
405 1. The process identifier (program name or process ID) (REQUIRED)
406 2. Flag indicicating the identifier type:
407 'P': decimal process ID
408 'H': hexadecimal process ID
409 'N': executable program name (with or without extension) (DEFAULT)
410
411REXX RETURN VALUE:
412 A string of the format
413 pid parent-pid process-type priority cpu-time executable-name
414 "priority" is in hexadecimal notation, all other numbers are decimal.
415 "" is returned if the process was not found or if an internal error
416 occurred.
417
418
419-------------------------------------------------------------------------
420Sys2QueryProcessList
421
422Gets a list of running processes. The results will be returned in a stem
423variable, where stem.0 contains number of items, and each stem item is a
424string of the form:
425 pid parent-pid process-type priority cpu-time executable-name
426"priority" is in hexadecimal notation, all other numbers are decimal.
427
428Notes:
429 - "process-type" will be one of:
430 0 Full screen protect-mode session
431 1 Requires real mode. Dos emulation.
432 2 VIO windowable protect-mode session
433 3 Presentation Manager protect-mode session
434 4 Detached protect-mode process.
435 - If "priority" is 0 then the priority class could not be determined.
436 - If "executable-name" is "--" then the name could not be identified.
437
438REXX ARGUMENTS:
439 1. The name of the stem in which to return the results (REQUIRED)
440
441REXX RETURN VALUE: Number of processes found, or "" in case of error.
442
443
444-------------------------------------------------------------------------
445Sys2Read
446
447Read bytes from a previously-opened stream (wrapper to DosRead).
448
449REXX ARGUMENTS:
450 1. File handle (as returned by Sys2Open or Sys2CreateNamedPipe).
451 (REQUIRED)
452 2. Number of bytes to read. (REQUIRED)
453
454REXX RETURN VALUE:
455 String containing the bytes read, or "" in case of error.
456
457
458-------------------------------------------------------------------------
459Sys2ReplaceModule
460
461Unlocks and optionally replaces an in-use (locked) DLL or EXE.
462
463REXX ARGUMENTS:
464 1. The filespec of the module to be replaced. (REQUIRED)
465 2. The filespec of the new module to replace it with. (DEFAULT: none)
466 3. The filespec of the backup file to be created. (DEFAULT: none)
467
468REXX RETURN VALUE:
469 1 on success, or 0 if an error occurred.
470
471
472-------------------------------------------------------------------------
473Sys2Seek
474
475Move the read/write pointer to the specified location in an open
476file/stream; files larger than 2GB are supported (this function is a
477wrapper to DosSetFilePtrL).
478
479REXX ARGUMENTS:
480 1. File handle (returned by Sys2Open). (REQUIRED)
481 2. The signed distance in bytes to move. (REQUIRED)
482 3. Move method, one of:
483 B = Beginning of file
484 C = Current position (DEFAULT)
485 E = End of file
486
487REXX RETURN VALUE:
488 The new file position, in bytes.
489
490
491-------------------------------------------------------------------------
492Sys2SyncBuffer
493
494Used to synchronize buffer read/write transactions (wrapper to
495DosResetBuffer) For external files, writes the buffer to disk.
496For named pipes, blocks until the remote client end of the pipe has read
497the contents.
498
499REXX ARGUMENTS:
500 1. File handle (as returned by Sys2Open or Sys2CreateNamedPipe).
501 (REQUIRED)
502
503REXX RETURN VALUE: 1 on success, 0 on failure
504
505-------------------------------------------------------------------------
506Sys2Version
507
508Returns the current library version.
509
510REXX ARGUMENTS: None
511REXX RETURN VALUE: Current version in the form "major.minor.refresh"
512
513
514-------------------------------------------------------------------------
515Sys2Write
516
517Write bytes to a previously-opened stream (wrapper to DosWrite).
518
519REXX ARGUMENTS:
520 1. File handle (as returned by Sys2Open or Sys2CreateNamedPipe).
521 (REQUIRED)
522 2. Data to be written. (REQUIRED)
523
524REXX RETURN VALUE:
525 The number of bytes successfully written.
526
Note: See TracBrowser for help on using the repository browser.