Changeset 36
- Timestamp:
- Feb 12, 2017, 8:48:39 AM (8 years ago)
- Location:
- rxutilex/trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
rxutilex/trunk/TODO
r21 r36 1 1 FUNCTION WISHLIST 2 2 3 * Sys2ReplaceModule - A wrapper for DosReplaceModule()4 3 - Sys2TokenizeString - A string tokenizer 5 4 - Sys2FormatCurrency - A strfmon wrapper … … 20 19 ? Access to the Win32 registry <-- exists in sp1utils 21 20 ? Sys2CloseWindow & Sys2ExitWindow <-- exists in pr1util 22 ? Sys2ReplaceObjectClass <-- exists in rexxutil replacement21 ? Sys2ReplaceObjectClass <-- exists in pr1util 23 22 ? Query/extract an object's icon <-- exists in RWS? 24 23 -
rxutilex/trunk/readme.txt
r18 r36 1 1 REXX Utility Functions - Extended (RXUTILEX.DLL) 2 2 http://trac.netlabs.org/rexxlibs/ 3 4 This library requires OS/2 4.5x, as it makes use of large file support 5 functions (e.g. DosOpenL). 6 3 7 4 8 OBJECTIVE … … 51 55 52 56 REXX Utility Functions - Extended (RXUTILEX) 53 (C) 2011, 201 4Alex Taylor.57 (C) 2011, 2017 Alex Taylor. 54 58 55 59 Redistribution and use in source and binary forms, with or without -
rxutilex/trunk/rxutilex.c
r33 r36 1 1 /****************************************************************************** 2 2 * REXX Utility Functions - Extended (RXUTILEX.DLL) * 3 * (C) 2011, 201 4Alex Taylor. *3 * (C) 2011, 2017 Alex Taylor. * 4 4 * * 5 5 * LICENSE: * … … 45 45 #define INCL_WINCLIPBOARD 46 46 #define INCL_WINERRORS 47 #define INCL_DOS 48 #define INCL_DOSDEVIOCTL 47 49 #define INCL_DOSERRORS 48 50 #define INCL_DOSMISC … … 55 57 #endif 56 58 59 #include <ctype.h> 57 60 #include <stdio.h> 58 61 #include <stdlib.h> … … 88 91 #define SZ_LIBRARY_NAME "RXUTILEX" // Name of this library 89 92 //#define SZ_ERROR_NAME "SYS2ERR" // REXX variable used to store error codes 90 #define SZ_VERSION "0.1. 3" // Current version of this library93 #define SZ_VERSION "0.1.4" // Current version of this library 91 94 92 95 // Maximum string lengths... … … 106 109 #define US_NUMSTR_MAXZ 64 // ...of a formatted number string 107 110 #define US_PIPESTATUS_MAXZ 128 // ...of a pipe status string 111 #define US_DISKINFO_MAXZ 128 // ...of a disk information string 108 112 109 113 #define UL_SSBUFSIZE 0xFFFF // Buffer size for the DosQuerySysState() data … … 124 128 "Sys2QueryProcessList", 125 129 "Sys2KillProcess", 130 "Sys2QueryDriveInfo", 126 131 "Sys2QueryForegroundProcess", 127 132 "Sys2QueryPhysicalMemory", … … 163 168 RexxFunctionHandler Sys2QueryForegroundProcess; 164 169 170 RexxFunctionHandler Sys2QueryDriveInfo; 171 165 172 RexxFunctionHandler Sys2QueryPhysicalMemory; 166 173 167 174 RexxFunctionHandler Sys2LocateDLL; 168 175 RexxFunctionHandler Sys2ReplaceModule; 169 170 // RexxFunctionHandler Sys2ReplaceObjectClass;171 176 172 177 RexxFunctionHandler Sys2CreateNamedPipe; … … 181 186 RexxFunctionHandler Sys2Write; 182 187 RexxFunctionHandler Sys2SyncBuffer; 188 183 189 184 190 // Private internal functions … … 2279 2285 2280 2286 2287 /* ------------------------------------------------------------------------- * 2288 * Sys2QueryDriveInfo * 2289 * * 2290 * Get non-filesystem-dependent information about a logical drive (volume). * 2291 * * 2292 * REXX ARGUMENTS: * 2293 * 1. Drive/volume letter to query, trailing colon optional. (REQUIRED) * 2294 * * 2295 * REXX RETURN VALUE: * 2296 * On success, returns a string in the format * 2297 * <drive> <size> <type> <flag> * 2298 * where <drive> is the uppercase drive letter followed by a colon, * 2299 * <size> is the total size of the drive/volume in binary kilobytes,* 2300 * <type> is one of: * 2301 * FLOPPY_5L - 48 TPI low-density diskette drive * 2302 * FLOPPY_5H - 96 TPI high-density diskette drive * 2303 * FLOPPY_3L - 3.5-inch 720KB drive * 2304 * FLOPPY_3H - 3.5-inch high-density 1.44MB diskette drive * 2305 * FLOPPY_3X - 3.5-inch ext-density 2.88MB diskette drive * 2306 * FLOPPY_8L - 8-inch single-density diskette drive * 2307 * FLOPPY_8H - 8-inch double-density diskette drive * 2308 * OTHER - other (including CD drive with no media) * 2309 * HDD - hard disk drive (including PRM) * 2310 * TAPE - tape drive * 2311 * OPTICAL - read/write optical drive * 2312 * and <flag> is 1 for non-partitionable removable media (e.g. floppies) * 2313 * or 0 otherwise (including both fixed and PRM disks) * 2314 * ------------------------------------------------------------------------- */ 2315 ULONG APIENTRY Sys2QueryDriveInfo( PSZ pszName, ULONG argc, RXSTRING argv[], PSZ pszQueue, PRXSTRING prsResult ) 2316 { 2317 BIOSPARAMETERBLOCK data; 2318 CHAR szDiskInfo[ US_DISKINFO_MAXZ ]; 2319 UCHAR achPP[ 2 ], 2320 chVol; 2321 ULONG cbPP, 2322 cbData, 2323 ulSectors, 2324 ulSize; 2325 BOOL bRemovable; 2326 APIRET rc; 2327 2328 2329 // Reset the error indicator 2330 WriteErrorCode( 0, NULL ); 2331 2332 // Make sure we have exactly one valid argument (the drive letter) 2333 if ( argc != 1 || ( !RXVALIDSTRING(argv[0]) )) 2334 return ( 40 ); 2335 chVol = toupper( argv[0].strptr[0] ); 2336 if (( chVol < 'A') || ( chVol > 'Z')) 2337 return ( 40 ); 2338 2339 cbPP = 2; 2340 achPP[ 0 ] = 0; 2341 achPP[ 1 ] = chVol - 65; 2342 cbData = sizeof( data ); 2343 rc = DosDevIOCtl( (HFILE) -1, IOCTL_DISK, DSK_GETDEVICEPARAMS, 2344 (PVOID) achPP, 2, &cbPP, &data, cbData, &cbData ); 2345 if ( rc != NO_ERROR ) { 2346 WriteErrorCode( rc, "DosDevIOCtl"); 2347 SaveResultString( prsResult, NULL, 0 ); 2348 return ( 0 ); 2349 } 2350 2351 ulSectors = data.cSectors? data.cSectors: data.cLargeSectors; 2352 ulSize = (data.usBytesPerSector > 1024) ? 2353 (ULONG) (ulSectors * ( data.usBytesPerSector / 1024 )) : 2354 (ULONG) (ulSectors / ( 1024 / data.usBytesPerSector )); 2355 bRemovable = !( data.fsDeviceAttr & 1 ); 2356 2357 sprintf( szDiskInfo, "%c: %u ", chVol, ulSize ); 2358 switch( data.bDeviceType ) { 2359 case 0: // 48 TPI low-density diskette drive 2360 strncat( szDiskInfo, "FLOPPY_5L", US_DISKINFO_MAXZ-1 ); 2361 break; 2362 case 1: // 96 TPI high-density diskette drive 2363 strncat( szDiskInfo, "FLOPPY_5H", US_DISKINFO_MAXZ-1 ); 2364 break; 2365 case 2: // Small (3.5-inch) 720KB drive 2366 strncat( szDiskInfo, "FLOPPY_3L", US_DISKINFO_MAXZ-1 ); 2367 break; 2368 case 3: // 8-inch single-density diskette drive 2369 strncat( szDiskInfo, "FLOPPY_8L", US_DISKINFO_MAXZ-1 ); 2370 break; 2371 case 4: // 8-inch double-density diskette drive 2372 strncat( szDiskInfo, "FLOPPY_8H", US_DISKINFO_MAXZ-1 ); 2373 break; 2374 case 5: // Fixed disk 2375 strncat( szDiskInfo, "HDD", US_DISKINFO_MAXZ-1 ); 2376 break; 2377 case 6: // Tape drive 2378 strncat( szDiskInfo, "TAPE", US_DISKINFO_MAXZ-1 ); 2379 break; 2380 case 7: // Other (includes 1.44MB 3.5-inch diskette drive) 2381 if ( ulSize == 1440 ) 2382 strncat( szDiskInfo, "FLOPPY_3H", US_DISKINFO_MAXZ-1 ); 2383 else 2384 strncat( szDiskInfo, "OTHER", US_DISKINFO_MAXZ-1 ); 2385 break; 2386 case 8: // R/W optical disk 2387 strncat( szDiskInfo, "OPTICAL", US_DISKINFO_MAXZ-1 ); 2388 break; 2389 case 9: // 3.5-inch 4.0MB diskette drive (2.88MB formatted) 2390 strncat( szDiskInfo, "FLOPPY_3X", US_DISKINFO_MAXZ-1 ); 2391 break; 2392 default: 2393 strncat( szDiskInfo, "UNKNOWN", US_DISKINFO_MAXZ-1 ); 2394 break; 2395 } 2396 strncat( szDiskInfo, ( bRemovable? " 1": " 0" ), US_DISKINFO_MAXZ-1 ); 2397 2398 SaveResultString( prsResult, szDiskInfo, strlen(szDiskInfo) ); 2399 return ( 0 ); 2400 } 2401 2402 2281 2403 2282 2404 // ------------------------------------------------------------------------- … … 2477 2599 2478 2600 2479 /* MOVED */ 2601 2602 2480 2603 #ifdef NO_SHARED_SOURCE 2604 2605 /**** 2606 **** MOVED TO shfuncs.c 2607 ****/ 2481 2608 2482 2609 /* ------------------------------------------------------------------------- * … … 2501 2628 // 2016-02-20 SHL Rework for easier usage 2502 2629 if (!pchBytes) 2503 ulBytes = 0; // Sync for caller2630 ulBytes = 0; // Sync for caller 2504 2631 if ( ulBytes > 256 ) { 2505 2632 // REXX provides 256 bytes by default; allocate more if necessary … … 2515 2642 } 2516 2643 if (ulBytes) 2517 memcpy( prsResult->strptr, pchBytes, ulBytes );2644 memcpy( prsResult->strptr, pchBytes, ulBytes ); 2518 2645 prsResult->strlength = ulBytes; 2519 2646 … … 2607 2734 } 2608 2735 2609 #endif 2736 #endif // NO_SHARED_SOURCE 2737 -
rxutilex/trunk/rxutilex.def
r33 r36 1 1 LIBRARY RXUTILEX INITINSTANCE TERMINSTANCE 2 2 DATA MULTIPLE NONSHARED 3 DESCRIPTION '@#Alex Taylor:0.1. 3#@##1## 10 May 2016 22:01:20REINFORCE::::::@@Extended REXX Utility Functions'3 DESCRIPTION '@#Alex Taylor:0.1.4#@##1## 12 Feb 2017 16:36:51 REINFORCE::::::@@Extended REXX Utility Functions' 4 4 5 5 EXPORTS Sys2LoadFuncs … … 28 28 Sys2Write 29 29 Sys2SyncBuffer 30 Sys2QueryDriveInfo -
rxutilex/trunk/rxutilex.txt
r33 r36 1 1 FUNCTIONS IN RXUTILEX.DLL 2 3 (See file 'TODO' for functions which are under consideration to be added.)4 2 5 3 Sys2CheckNamedPipe - Check the status of a named pipe (server side) … … 18 16 Sys2Open - Open a file or stream (with >2GB support) 19 17 Sys2PutClipboardText - Copy a text string to the clipboard 18 Sys2QueryDriveInfo - Get non-filesystem-dependent info about a drive 20 19 Sys2QueryForegroundProcess - Get the PID of the current foreground process 21 20 Sys2QueryPhysicalMemory - Get the amount of installed RAM … … 40 39 41 40 Checks the status of a named pipe that was previously created using 42 Sys2CreateNamedPipe. 43 44 This function is designed for use by the process that created the pipe 45 (i.e. the server side). Clients which are accessing a named pipe should 46 use the standard REXX STREAM and/or CHARS functions to determine the 41 Sys2CreateNamedPipe. 42 43 This 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 45 use the standard REXX STREAM and/or CHARS functions to determine the 47 46 pipe's status. 48 47 49 48 REXX ARGUMENTS: 50 1. The pipe handle (from Sys2CreateNamedPipe or DosOpen). (REQUIRED)49 1. The pipe handle (from Sys2CreateNamedPipe or Sys2Open). (REQUIRED) 51 50 52 51 REXX RETURN VALUE: … … 151 150 152 151 ------------------------------------------------------------------------- 153 Sys2FormatNumber 154 152 Sys2FormatNumber 153 155 154 Formats a number to use thousands-grouping characters. The system values 156 155 for the current locale are used for the thousands-grouping character and 157 the decimal place, if any. Note that the IBM C runtime's locale 158 definitions are used; these may not correspond precisely to the system 156 the decimal place, if any. Note that the IBM C runtime's locale 157 definitions are used; these may not correspond precisely to the system 159 158 locales as defined in the OS/2 Locale object. 160 159 161 160 The input number may be a positive or negative integer or floating point 162 161 value. It must be a simple, non-localized number value; in other words, 163 it must not contain any thousands-grouping characters, and any decimal 164 point which it contains must be a period (rather than any localized 162 it must not contain any thousands-grouping characters, and any decimal 163 point which it contains must be a period (rather than any localized 165 164 decimal symbol). 166 167 REXX ARGUMENTS: 168 1. Number to be formatted. (REQUIRED) 169 2. Number of decimal places to use for floating point values. 165 166 REXX ARGUMENTS: 167 1. Number to be formatted. (REQUIRED) 168 2. Number of decimal places to use for floating point values. 170 169 Ignored for integer values. (DEFAULT: 2) 171 172 REXX RETURN VALUE: The formatted number, or '' on error. 170 171 REXX RETURN VALUE: The formatted number, or '' on error. 173 172 174 173 … … 177 176 178 177 Converts a number of seconds from the epoch (1970-01-01 0:00:00 UTC) into 179 a formatted date and time string. 178 a formatted date and time string. 180 179 181 180 REXX ARGUMENTS: … … 279 278 280 279 If a DLL with the given name is currently loaded, that instance of the 281 DLL will be returned. Otherwise, unless 'L' is specified in the second 282 parameter, standard DLL loading rules (which will be governed by the 280 DLL will be returned. Otherwise, unless 'L' is specified in the second 281 parameter, standard DLL loading rules (which will be governed by the 283 282 current LIBPATH and/or extended LIBPATH configuration) are used to 284 283 search for a loadable DLL whose module name matches the one specified. … … 288 287 REXX ARGUMENTS: 289 288 1. The name of the DLL to search for. (REQUIRED) 290 2. Flag to limit search context, must be one of: 289 2. Flag to limit search context, must be one of: 291 290 A : 'All', search for both loaded and loadable DLLs (DEFAULT) 292 L : 'Loaded', search only for currently-loaded DLLs 291 L : 'Loaded', search only for currently-loaded DLLs 293 292 294 293 … … 373 372 374 373 ------------------------------------------------------------------------- 374 Sys2QueryDriveInfo 375 376 Get non-filesystem-dependent information about a logical drive (volume). 377 378 REXX ARGUMENTS: 379 1. Drive/volume letter to query, trailing colon optional. (REQUIRED) 380 381 REXX RETURN VALUE: 382 On success, returns a string in the format 383 <drive> <size> <type> <flag> 384 where <drive> is the uppercase drive letter followed by a colon, 385 <size> is the total size of the drive/volume in binary kilobytes, 386 <type> is one of: 387 FLOPPY_5L - 48 TPI low-density diskette drive 388 FLOPPY_5H - 96 TPI high-density diskette drive 389 FLOPPY_3L - 3.5-inch 720KB drive 390 FLOPPY_3H - 3.5-inch high-density 1.44MB diskette drive 391 FLOPPY_3X - 3.5-inch ext-density 2.88MB diskette drive 392 FLOPPY_8L - 8-inch single-density diskette drive 393 FLOPPY_8H - 8-inch double-density diskette drive 394 OTHER - other (including CD drive with no media) 395 HDD - hard disk drive (including PRM) 396 TAPE - tape drive 397 OPTICAL - read/write optical drive 398 and <flag> is 1 for non-partitionable removable media (e.g. floppies) 399 or 0 otherwise (including both fixed and PRM disks) 400 On error, returns "". 401 402 ------------------------------------------------------------------------- 375 403 Sys2QueryForegroundProcess 376 404 377 405 Queries the PID of the current foreground process. (Note that this is not 378 necessarily the same as the process which is calling this function, which 406 necessarily the same as the process which is calling this function, which 379 407 could, for example, be running in the background and/or as a child of the 380 408 foreground process.) … … 404 432 Queries information about the specified process. 405 433 406 Specifying a process ID of 0 will return the information for the 434 Specifying a process ID of 0 will return the information for the 407 435 current process (that is, the process calling this function); note that 408 436 this requires the second parameter to specify that the identifier is in … … 499 527 Sys2SyncBuffer 500 528 501 Used to synchronize buffer read/write transactions (wrapper to 502 DosResetBuffer). For external files, writes the buffer to disk. 503 For named pipes, blocks until the remote client end of the pipe has read 529 Used to synchronize buffer read/write transactions (wrapper to 530 DosResetBuffer). For external files, writes the buffer to disk. 531 For named pipes, blocks until the remote client end of the pipe has read 504 532 the contents. 505 506 REXX ARGUMENTS: 533 534 REXX ARGUMENTS: 507 535 1. File handle (as returned by Sys2Open or Sys2CreateNamedPipe). 508 536 (REQUIRED) 509 537 510 538 REXX RETURN VALUE: 1 on success, 0 on failure 511 539 -
rxutilex/trunk/testlib.cmd
r29 r36 39 39 say Sys2LocateDLL('ehxdlmri', 'l') 40 40 say Sys2LocateDLL('gcc1', 'l') 41 say 41 42 43 map = SysDriveMap('A', 'USED') 44 do i = 1 to words( map ) 45 info = Sys2QueryDriveInfo( WORD( map, i )) 46 if info == '' then info = WORD( map, i ) 'Unable to get drive data ('SYS2ERR')' 47 say info 48 end 42 49 43 50 call Sys2DropFuncs
Note:
See TracChangeset
for help on using the changeset viewer.