Changeset 10 for trunk/txlib
- Timestamp:
- 02/22/06 13:03:35 (3 years ago)
- Location:
- trunk/txlib
- Files:
-
- 7 modified
-
include/txlib.h (modified) (3 diffs)
-
txfsys.c (modified) (8 diffs)
-
txosapi.c (modified) (2 diffs)
-
txscript.c (modified) (5 diffs)
-
txvers.h (modified) (2 diffs)
-
txwproc.c (modified) (2 diffs)
-
txwstdlg.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/txlib/include/txlib.h
r7 r10 550 550 ); 551 551 552 // Substitute $n parameters in a string by supplied values; n = 0..9 (maximum) 553 ULONG txsSubstituteParams // RET nr of substitutions 554 ( 555 char *string, // IN base string 556 char **values, // IN values to substitute 557 int count, // IN number of values 558 int size, // IN size of output buffer 559 char *result // OUT substituted (MAXLIN) 560 ); 561 552 562 #if defined (DEV32) 553 563 … … 805 815 ); 806 816 807 #define TXFSV_HD 0 808 #define TXFSV_FLOP 1 809 #define TXFSV_LAN 2 810 #define TXFSV_CD 4 811 #define TXFSV_ALL 7 817 #define TXFSV_HD 0x0000 818 #define TXFSV_FLOP 0x0001 819 #define TXFSV_LAN 0x0002 820 #define TXFSV_CD 0x0004 821 #define TXFSV_ALL 0x0007 822 #define TXFSV_REM 0x0100 // removables only 812 823 // Build string with present volumes 813 824 int TxFsVolumes // RET nr of drives listed … … 847 858 ); 848 859 860 // Eject a removable medium specified by driveletter 861 ULONG TxFsEjectRemovable 862 ( 863 char *drive // IN Driveletter to eject 864 ); 865 866 // Determine if a driveletter represents a removable medium/device 867 BOOL TxFsIsRemovable // RET drive is removable 868 ( 869 char *drive // IN Driveletter to test 870 ); 849 871 850 872 // Determine free and total-available space (sectors) on specified drive -
trunk/txlib/txfsys.c
r7 r10 40 40 41 41 42 #if defined (LINUX) // LINUX specific 43 44 #define BLKGETSIZE 0x1260 45 #define BLKSSZGET 0x1268 46 47 #define ROOT_DEVICE "/dev/root" 42 #if defined (WIN32) 43 #elif defined (DOS32) 44 45 #define DRIVETYPE_REMOTE 0x1000 // BIT 12 from Ioctl 4409 dx 46 #define DRIVETYPE_RAMDRV 0x0800 // BIT 11 from Ioctl 4409 dx 47 48 #elif defined (LINUX) 49 50 #define BLKGETSIZE 0x1260 51 #define BLKSSZGET 0x1268 52 53 #define ROOT_DEVICE "/dev/root" 48 54 49 55 // Translate root-devicename to disk-partition device name using cached /etc/fstab info … … 54 60 ); 55 61 56 #elif defined (DOS32) // DOS specific local stuff 57 58 #define DRIVETYPE_REMOTE 0x1000 // BIT 12 from Ioctl 4409 dx 59 #define DRIVETYPE_RAMDRV 0x0800 // BIT 11 from Ioctl 4409 dx 62 #else 63 64 #define TXFSDC_BLOCKR 0x00 // block device removable 65 #define TXFSDC_GETBPB 0x00 // get device bpb info 66 67 #define TXFSDC_UNLOCK 0x00 // unlock logical drive 68 #define TXFSDC_LOCK 0x01 // lock logical drive 69 #define TXFSDC_EJECT 0x02 // eject removable 70 #define TXFSDC_LOAD 0x03 // load removable 71 72 typedef struct drivecmd 73 { 74 BYTE cmd; // 0=unlock 1=lock 2=eject 75 BYTE drv; // 0=A, 1=B 2=C ... 76 } DRIVECMD; // end of struct "drivecmd" 77 78 #define TXFSBPB_REMOVABLE 0x08 // BPB attribute for removable 79 80 typedef struct drivebpb 81 { 82 TXFS_EBPB ebpb; // extended BPB 83 BYTE reserved[6]; 84 USHORT cyls; 85 BYTE type; 86 USHORT attributes; // device attributes 87 BYTE fill[6]; // documented for IOCtl 88 } DRIVEBPB; // end of struct "drivebpb" 60 89 61 90 #endif 91 62 92 63 93 /*****************************************************************************/ … … 135 165 if (drivemap & (1 << ml)) 136 166 { 137 BOOL incl = TRUE;138 167 TXTT fstype; 139 168 … … 141 170 if (TxFsType( drive, fstype, NULL)) 142 171 { 172 BOOL removable = TxFsIsRemovable( drive); 173 BOOL incl = TRUE; 174 143 175 //- Note, connected Win-NT drives use the REAL FS-name like NTFS! 144 176 if ((strnicmp( fstype, "LAN", 3) == 0) || //- OS/2 LAN drives … … 149 181 else if (strnicmp( fstype, "CD", 2) == 0) // OS2:CDFS, DOS/WIN:CDROM 150 182 { 151 incl = (flags & TXFSV_CD); 183 removable = TRUE; // overrule for any CDROM 184 incl = (flags & TXFSV_CD); 185 } 186 if ((flags & TXFSV_REM) && (removable == FALSE)) 187 { 188 incl = FALSE; // just want removables ... 152 189 } 153 190 if (incl) … … 358 395 strcat( leader, "Mounted device"); 359 396 #else 360 strcat( leader, "Volume info on"); 397 if (TxFsIsRemovable( drive)) 398 { 399 strcat( leader, "RemovableDrive"); 400 } 401 else 402 { 403 strcat( leader, "Volume info on"); 404 } 361 405 #endif 362 406 … … 609 653 } 610 654 #endif 655 if (list == NULL) // empty sofar ? 656 { 657 list = TxSelEmptyList( "- No volumes matching the criteria -", 658 "No volumes found that match the criteria for this list"); 659 } 611 660 RETURN( list); 612 661 } // end 'TxFsDriveSelist' … … 785 834 786 835 /*****************************************************************************/ 836 // Eject a removable medium specified by driveletter 837 /*****************************************************************************/ 838 ULONG TxFsEjectRemovable 839 ( 840 char *drive // IN Driveletter to eject 841 ) 842 { 843 ULONG rc = NO_ERROR; // DOS rc 844 #if defined (WIN32) 845 #elif defined (DOS32) 846 #elif defined (LINUX) 847 #else 848 DRIVECMD IOCtl; 849 ULONG DataLen; 850 ULONG ParmLen; 851 #endif 852 853 ENTER(); 854 TxFsAutoFailCriticalErrors( TRUE); // avoid Not-ready pop-ups 855 856 TRACES(("Drive: %s\n", drive)); 857 #if defined (WIN32) 858 #elif defined (DOS32) 859 #elif defined (LINUX) 860 #else 861 ParmLen = sizeof(DRIVECMD); 862 IOCtl.cmd = TXFSDC_EJECT; 863 IOCtl.drv = toupper(drive[0]) - 'A'; 864 DataLen = 0; 865 866 rc = DosDevIOCtl((HFILE) -1, IOCTL_DISK, 867 DSK_UNLOCKEJECTMEDIA, 868 &IOCtl, ParmLen, &ParmLen, 869 NULL, DataLen, &DataLen); 870 #endif 871 TxFsAutoFailCriticalErrors( FALSE); // enable criterror handler 872 RETURN (rc); 873 } // end 'TxFsEjectRemovable' 874 /*---------------------------------------------------------------------------*/ 875 876 877 /*****************************************************************************/ 878 // Determine if a driveletter represents a removable medium/device 879 /*****************************************************************************/ 880 BOOL TxFsIsRemovable // RET drive is removable 881 ( 882 char *drive // IN Driveletter to test 883 ) 884 { 885 BOOL rc = FALSE; 886 #if defined (WIN32) 887 #elif defined (DOS32) 888 #elif defined (LINUX) 889 #else 890 DRIVECMD IOCtl; 891 DRIVEBPB RemAt; 892 ULONG DataLen; 893 ULONG ParmLen; 894 BYTE NoRem; 895 #endif 896 897 ENTER(); 898 TxFsAutoFailCriticalErrors( TRUE); // avoid Not-ready pop-ups 899 900 TRACES(("Drive: %s\n", drive)); 901 #if defined (WIN32) 902 #elif defined (DOS32) 903 #elif defined (LINUX) 904 #else 905 ParmLen = sizeof(IOCtl); 906 IOCtl.cmd = TXFSDC_BLOCKR; 907 IOCtl.drv = toupper(drive[0]) - 'A'; 908 DataLen = sizeof(NoRem); 909 910 if (DosDevIOCtl((HFILE) -1, IOCTL_DISK, 911 DSK_BLOCKREMOVABLE, 912 &IOCtl, ParmLen, &ParmLen, 913 &NoRem, DataLen, &DataLen) == NO_ERROR) 914 { 915 if (NoRem) // non-removable sofar, check 916 { // BPB as well (USB devices) 917 ParmLen = sizeof(IOCtl); 918 IOCtl.cmd = TXFSDC_GETBPB; 919 IOCtl.drv = toupper(drive[0]) - 'A'; 920 DataLen = sizeof(RemAt); 921 922 if (DosDevIOCtl((HFILE) -1, IOCTL_DISK, 923 DSK_GETDEVICEPARAMS, 924 &IOCtl, ParmLen, &ParmLen, 925 &RemAt, DataLen, &DataLen) == NO_ERROR) 926 927 { 928 if (RemAt.attributes & TXFSBPB_REMOVABLE) 929 { 930 TRACES(( "BPB removable, like USB\n")); 931 rc = TRUE; // removable, probably USB 932 } 933 } 934 } 935 else 936 { 937 TRACES(( "Block removable\n")); 938 rc = TRUE; // removable block device 939 } 940 } 941 #endif 942 TxFsAutoFailCriticalErrors( FALSE); // enable criterror handler 943 BRETURN (rc); 944 } // end 'TxFsIsRemovable' 945 /*---------------------------------------------------------------------------*/ 946 947 948 /*****************************************************************************/ 787 949 // Determine free and total-available space (sectors) on specified drive 788 950 /*****************************************************************************/ -
trunk/txlib/txosapi.c
r1 r10 253 253 if (txfLargeAPItested == FALSE) 254 254 { 255 rc = DosLoadModule( dlmerror, 256 TXMAXLN, // error buffer and size 257 TXF_DOSCALLS, // name of dll 258 &doscalls); // module handle 259 if (rc == NO_ERROR) 255 if ((DosLoadModule( dlmerror, TXMAXLN, TXF_DOSCALLS, &doscalls)) == NO_ERROR) 260 256 { 261 257 TRACES(("Txf DOSCALLS module handle: %lu\n", doscalls)); … … 285 281 } 286 282 287 if (txfLargeAPIentryp.DosOpenLarge != NULL) 283 if ((txfLargeAPIentryp.DosOpenLarge != NULL) && 284 (txfLargeAPIentryp.DosSeekLarge != NULL) ) 288 285 { 289 286 rc = TRUE; -
trunk/txlib/txscript.c
r5 r10 50 50 #define TXSC_P_PROMPT ";;prompt" 51 51 #define TXSC_P_ERRORS ";;error" 52 53 #define TXSC_PARAMS 10 // substitutable parameters 52 54 53 55 static char *runhelp[] = … … 105 107 }; 106 108 #endif 107 108 109 // Substitute $n parameters in a string by supplied values; n = 0..9110 static ULONG txsSubstituteParams // RET nr of substitutions111 (112 char *string, // IN base string113 char **values, // IN values to substitute114 char *result // OUT substituted (MAXLIN)115 );116 109 117 110 … … 184 177 TxRepl( scrline, '\n', '\0'); 185 178 TxRepl( scrline, '\r', '\0'); // mainly for Linux/Unix ... 186 txsSubstituteParams( scrline, params, command); 179 txsSubstituteParams( scrline, params, TXSC_PARAMS, 180 TXMAXLN, command); 187 181 188 182 if ( (strlen( command) > 0) && // not empty, and … … 413 407 /*---------------------------------------------------------------------------*/ 414 408 415 /*****************************************************************************/ 416 // Substitute $n parameters in a string by supplied values; n = 0..9 417 /*****************************************************************************/ 418 static ULONG txsSubstituteParams // RET nr of substitutions 409 410 /*****************************************************************************/ 411 // Substitute $n parameters in a string by supplied values; n = 0..9 (maximum) 412 /*****************************************************************************/ 413 ULONG txsSubstituteParams // RET nr of substitutions 419 414 ( 420 415 char *string, // IN base string 421 416 char **values, // IN values to substitute 417 int count, // IN number of values 418 int size, // IN size of output buffer 422 419 char *result // OUT substituted (MAXLIN) 423 420 ) … … 438 435 bs++; // skip $ 439 436 si = (int) ((*bs) - '0'); // index 0..9 440 if (values[si] != NULL) // value available ? 437 if ((si < count) && 438 (values[si] != NULL)) // value available ? 441 439 { 442 440 rl += strlen( values[si]); 443 if (rl < TXMAXLN)// room to grow ?441 if (rl < size) // room to grow ? 444 442 { 445 443 strcpy( rs, values[si]); // copy value -
trunk/txlib/txvers.h
r9 r10 40 40 // Originally developed for LPTool/DFSee utilities, open-sourced in 2005 41 41 // 42 #define TXLIB_V "1.06 05-01-2006" // JvW Topline feedback on alt-/ trace toggle 42 #define TXLIB_V "1.06 26-01-2006" // JvW SubstituteParams now external function 43 //efine TXLIB_V "1.06 06-01-2006" // JvW Fixed trap in FileDlg due to USER ptr 44 //efine TXLIB_V "1.06 05-01-2006" // JvW Topline feedback on alt-/ trace toggle 43 45 //efine TXLIB_V "1.06 05-01-2006" // JvW Added usrdata ptr to txwWidgetDialog() 44 46 //efine TXLIB_V "1.05 29-12-2005" // JvW Fixed Radio-repaint bug on (x == TRUE) … … 407 409 408 410 #define TXLIB_N "TX-library" 409 #define TXLIB_C "(c) 1995-200 5: Fsys Software"411 #define TXLIB_C "(c) 1995-2006: Fsys Software" 410 412 411 413 #endif -
trunk/txlib/txwproc.c
r9 r10 208 208 txwPostMsg( hwnd, TXWM_ACTIVATE, TRUE, 0); 209 209 } 210 txwSetWindowPtr( hwnd, TXQWP_USER, (void *) mp2); // user data211 210 break; 212 211 … … 1425 1424 wnd->us[TXQWS_FLAGS] &= ~TXFF_DLGDISMISSED; //- clear dismissed flag 1426 1425 1426 if (cData != NULL) // optional, USER PTR could be 1427 { // set by caller already! 1428 wnd->ul[TXQWP_USER] = (ULONG) cData; 1429 } 1427 1430 txwPostMsg( (TXWHANDLE) wnd, TXWM_INITDLG, focus, (ULONG) cData); 1428 1431 -
trunk/txlib/txwstdlg.c
r7 r10 1644 1644 bframe = txwCreateWindow( parent, TXW_CANVAS, 0, 0, &window, NULL); 1645 1645 txwSetWindowUShort( bframe, TXQWS_ID, TXWD_WID_MBAR); 1646 txwSetWindowPtr( bframe, TXQWP_USER, mbar); // make mbar available1647 1646 1648 1647 for (m = 0, line = 0, lwidth = 1; m < mbar->count; m++) … … 1690 1689 txwa->mainmenu = bframe; 1691 1690 } 1692 rc = txwDlgBox( parent, owner, txwMenuDlgWinProc, bframe, NULL);1691 rc = txwDlgBox( parent, owner, txwMenuDlgWinProc, bframe, mbar); 1693 1692 if (flags & TXMN_MAIN_MENU) 1694 1693 { … … 2229 2228 fframe = txwCreateWindow( parent, TXW_CANVAS, 0, 0, &window, NULL); 2230 2229 txwSetWindowUShort( fframe, TXQWS_ID, TXFD_WID_DFRAME); 2231 txwSetWindowPtr( fframe, TXQWP_USER, fd); // make filedata available2232 2230 TRACES(("Attached filedata structure at %8.8lx to FD-frame\n", fd)); 2233 2231 … … 2418 2416 } 2419 2417 2420 fd->result = txwDlgBox( parent, parent, txwDefFileDlgProc, 2421 fframe, NULL); 2418 fd->result = txwDlgBox( parent, parent, txwDefFileDlgProc, fframe, fd); 2422 2419 } 2423 2420 txSelDestroy( &fdpriv.direct); // free directory list