Changeset 10

Show
Ignore:
Timestamp:
02/22/06 13:03:35 (3 years ago)
Author:
jvw
Message:

Fix FileDialog? trap, other minor updates

Location:
trunk/txlib
Files:
7 modified

Legend:

Unmodified
Added
Removed
  • trunk/txlib/include/txlib.h

    r7 r10  
    550550); 
    551551 
     552// Substitute $n parameters in a string by supplied values; n = 0..9 (maximum) 
     553ULONG 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 
    552562#if   defined (DEV32) 
    553563 
     
    805815); 
    806816 
    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 
    812823// Build string with present volumes 
    813824int TxFsVolumes                                 // RET   nr of drives listed 
     
    847858); 
    848859 
     860// Eject a removable medium specified by driveletter 
     861ULONG TxFsEjectRemovable 
     862( 
     863   char               *drive                    // IN    Driveletter to eject 
     864); 
     865 
     866// Determine if a driveletter represents a removable medium/device 
     867BOOL TxFsIsRemovable                            // RET   drive is removable 
     868( 
     869   char               *drive                    // IN    Driveletter to test 
     870); 
    849871 
    850872// Determine free and total-available space (sectors) on specified drive 
  • trunk/txlib/txfsys.c

    r7 r10  
    4040 
    4141 
    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" 
    4854 
    4955// Translate root-devicename to disk-partition device name using cached /etc/fstab info 
     
    5460); 
    5561 
    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 
     72typedef 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 
     80typedef 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" 
    6089 
    6190#endif 
     91 
    6292 
    6393/*****************************************************************************/ 
     
    135165      if (drivemap & (1 << ml)) 
    136166      { 
    137          BOOL       incl = TRUE; 
    138167         TXTT       fstype; 
    139168 
     
    141170         if (TxFsType( drive, fstype, NULL)) 
    142171         { 
     172            BOOL       removable = TxFsIsRemovable( drive); 
     173            BOOL       incl = TRUE; 
     174 
    143175            //- Note, connected Win-NT drives use the REAL FS-name like NTFS! 
    144176            if     ((strnicmp( fstype, "LAN",    3) == 0) || //- OS/2 LAN drives 
     
    149181            else if (strnicmp( fstype, "CD", 2) == 0) // OS2:CDFS, DOS/WIN:CDROM 
    150182            { 
    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 ... 
    152189            } 
    153190            if (incl) 
     
    358395      strcat( leader, "Mounted device"); 
    359396   #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      } 
    361405   #endif 
    362406 
     
    609653      } 
    610654   #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   } 
    611660   RETURN( list); 
    612661}                                               // end 'TxFsDriveSelist' 
     
    785834 
    786835/*****************************************************************************/ 
     836// Eject a removable medium specified by driveletter 
     837/*****************************************************************************/ 
     838ULONG 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/*****************************************************************************/ 
     880BOOL 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/*****************************************************************************/ 
    787949// Determine free and total-available space (sectors) on specified drive 
    788950/*****************************************************************************/ 
  • trunk/txlib/txosapi.c

    r1 r10  
    253253   if (txfLargeAPItested == FALSE) 
    254254   { 
    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) 
    260256      { 
    261257         TRACES(("Txf DOSCALLS module handle: %lu\n", doscalls)); 
     
    285281   } 
    286282 
    287    if (txfLargeAPIentryp.DosOpenLarge != NULL) 
     283   if ((txfLargeAPIentryp.DosOpenLarge != NULL) && 
     284       (txfLargeAPIentryp.DosSeekLarge != NULL)  ) 
    288285   { 
    289286      rc = TRUE; 
  • trunk/txlib/txscript.c

    r5 r10  
    5050#define TXSC_P_PROMPT       ";;prompt" 
    5151#define TXSC_P_ERRORS       ";;error" 
     52 
     53#define TXSC_PARAMS         10                  // substitutable parameters 
    5254 
    5355static  char       *runhelp[] = 
     
    105107}; 
    106108#endif 
    107  
    108  
    109 // Substitute $n parameters in a string by supplied values; n = 0..9 
    110 static ULONG txsSubstituteParams                // RET   nr of substitutions 
    111 ( 
    112    char               *string,                  // IN    base string 
    113    char              **values,                  // IN    values to substitute 
    114    char               *result                   // OUT   substituted (MAXLIN) 
    115 ); 
    116109 
    117110 
     
    184177               TxRepl( scrline, '\n', '\0'); 
    185178               TxRepl( scrline, '\r', '\0');    // mainly for Linux/Unix ... 
    186                txsSubstituteParams( scrline, params, command); 
     179               txsSubstituteParams( scrline, params,  TXSC_PARAMS, 
     180                                             TXMAXLN, command); 
    187181 
    188182               if ( (strlen( command) > 0) &&   // not empty, and 
     
    413407/*---------------------------------------------------------------------------*/ 
    414408 
    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/*****************************************************************************/ 
     413ULONG txsSubstituteParams                       // RET   nr of substitutions 
    419414( 
    420415   char               *string,                  // IN    base string 
    421416   char              **values,                  // IN    values to substitute 
     417   int                 count,                   // IN    number of values 
     418   int                 size,                    // IN    size of output buffer 
    422419   char               *result                   // OUT   substituted (MAXLIN) 
    423420) 
     
    438435         bs++;                                  // skip  $ 
    439436         si  = (int) ((*bs) - '0');             // index 0..9 
    440          if (values[si] != NULL)                // value available ? 
     437         if ((si < count) && 
     438             (values[si] != NULL))              // value available ? 
    441439         { 
    442440            rl += strlen( values[si]); 
    443             if (rl < TXMAXLN)                   // room to grow ? 
     441            if (rl < size)                      // room to grow ? 
    444442            { 
    445443               strcpy(  rs,  values[si]);       // copy value 
  • trunk/txlib/txvers.h

    r9 r10  
    4040// Originally developed for LPTool/DFSee utilities, open-sourced in 2005 
    4141// 
    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 
    4345//efine TXLIB_V "1.06 05-01-2006" // JvW Added usrdata ptr to txwWidgetDialog() 
    4446//efine TXLIB_V "1.05 29-12-2005" // JvW Fixed Radio-repaint bug on (x == TRUE) 
     
    407409 
    408410#define TXLIB_N "TX-library" 
    409 #define TXLIB_C "(c) 1995-2005: Fsys Software" 
     411#define TXLIB_C "(c) 1995-2006: Fsys Software" 
    410412 
    411413#endif 
  • trunk/txlib/txwproc.c

    r9 r10  
    208208               txwPostMsg(   hwnd, TXWM_ACTIVATE, TRUE, 0); 
    209209            } 
    210             txwSetWindowPtr( hwnd, TXQWP_USER, (void *) mp2); // user data 
    211210            break; 
    212211 
     
    14251424      wnd->us[TXQWS_FLAGS]  &= ~TXFF_DLGDISMISSED;  //- clear dismissed flag 
    14261425 
     1426      if (cData != NULL)                        // optional, USER PTR could be 
     1427      {                                         // set by caller already! 
     1428         wnd->ul[TXQWP_USER] = (ULONG) cData; 
     1429      } 
    14271430      txwPostMsg( (TXWHANDLE) wnd, TXWM_INITDLG, focus, (ULONG) cData); 
    14281431 
  • trunk/txlib/txwstdlg.c

    r7 r10  
    16441644      bframe = txwCreateWindow( parent, TXW_CANVAS, 0, 0, &window, NULL); 
    16451645      txwSetWindowUShort( bframe, TXQWS_ID, TXWD_WID_MBAR); 
    1646       txwSetWindowPtr( bframe, TXQWP_USER, mbar); // make mbar available 
    16471646 
    16481647      for (m = 0, line = 0, lwidth = 1; m < mbar->count; m++) 
     
    16901689         txwa->mainmenu = bframe; 
    16911690      } 
    1692       rc = txwDlgBox( parent, owner, txwMenuDlgWinProc, bframe, NULL); 
     1691      rc = txwDlgBox( parent, owner, txwMenuDlgWinProc, bframe, mbar); 
    16931692      if (flags & TXMN_MAIN_MENU) 
    16941693      { 
     
    22292228         fframe = txwCreateWindow( parent, TXW_CANVAS, 0, 0, &window, NULL); 
    22302229         txwSetWindowUShort( fframe, TXQWS_ID, TXFD_WID_DFRAME); 
    2231          txwSetWindowPtr( fframe, TXQWP_USER, fd); // make filedata available 
    22322230         TRACES(("Attached filedata structure at %8.8lx to FD-frame\n", fd)); 
    22332231 
     
    24182416            } 
    24192417 
    2420             fd->result = txwDlgBox( parent, parent, txwDefFileDlgProc, 
    2421                                                     fframe, NULL); 
     2418            fd->result = txwDlgBox( parent, parent, txwDefFileDlgProc, fframe, fd); 
    24222419         } 
    24232420         txSelDestroy( &fdpriv.direct);         // free directory list