コード例 #1
0
BOOL SetDisk(HWND hwnd, BYTE newDisk, PBOOL phpfs) {
   APIRET rc;
   BYTE buf[128];
   ULONG ulAct;
   CHAR ch = newDisk;
   newDisk = newDisk > 'Z'? newDisk - 'a' + 1: newDisk - 'A' + 1;
   DosError(0);                  // disabilita dialogo errore drive not ready
   rc = DosQueryFSInfo(newDisk, FSIL_VOLSER, buf, sizeof(buf));
   DosError(1);
   if (rc && rc != 125) {       // se drive not ready-> retry, cancel
      if (WinMessageBox(HWND_DESKTOP, hwnd, DRIVE_NOT_READY, NULL,
                        0, MB_RETRYCANCEL | MB_ERROR | MB_MOVEABLE) ==
          MBID_RETRY) {
         return SetDisk(hwnd, newDisk, phpfs);
      } else {
         return 1;
      } /* endif */
   } /* endif */
   DosSetDefaultDisk(newDisk);
   *phpfs = isHPFS(ch);
   if (hwnd != HWND_DESKTOP) {
      // mostra/nasconde data-ora creazione e ultimo accesso secondo FS
      DlgShowCtl(hwnd, STB_CREATED, *phpfs);
      DlgShowCtl(hwnd, STB_ACCESSED, *phpfs);
   } /* endif */
   return 0;
}
コード例 #2
0
/*@ XFile::SetDefaultDisk(const char drive)
@group disks
@remarks Set the dault disk
@parameters
<t 'ø' c=2>
øchar øthe drive (A, B, ....)
</t>
*/
BOOL XFile::SetDefaultDisk(const char drive)
{
   char d = toupper(drive);
   USHORT number = d - 'A' + 1;

   if (DosSetDefaultDisk(number) == 0)
      return TRUE;
   else
      return FALSE;
}
コード例 #3
0
ファイル: filesys.c プロジェクト: ohmann/checkapi
APR_DECLARE(apr_status_t) apr_filepath_set(const char *path, apr_pool_t *p)
{
    ULONG rv = 0;

    if (path[1] == ':')
        rv = DosSetDefaultDisk(apr_toupper(path[0]) - '@');

    if (rv == 0)
        rv = DosSetCurrentDir(path);

    return APR_FROM_OS_ERROR(rv);
}
コード例 #4
0
static void ProcessConnection( void )
{
    char                buff[MAX_TRANS];
    ULONG               bytes_read;
    unsigned long       max;
    struct _AVAILDATA   BytesAvail;
    ULONG               PipeState;
    APIRET              rc;
    RESULTCODES         res;
    PID                 dummy;
    char                *dir;

    for( ;; ) {
        DosRead( LnkHdl, buff, sizeof( buff ), &bytes_read );
        if( bytes_read == 0 ) break;
        buff[bytes_read] = '\0';
        switch( buff[0] ) {
        case LNK_CWD:
            rc = 0;
            dir = &buff[1];
            if( isalpha( dir[0] ) && dir[1] == ':' ) {
                rc = DosSetDefaultDisk( toupper( dir[0] ) - ('A' - 1) );
                dir += 2;
            }
            if( rc == 0 && dir[0] != '\0' ) {
                rc = DosSetCurrentDir( dir );
            }
            SendStatus( rc );
            break;
        case LNK_RUN:
            DosSetNPHState( RedirHdl, NP_NOWAIT | NP_READMODE_BYTE );
            DosConnectNPipe( RedirHdl );
            DosSetNPHState( RedirHdl, NP_WAIT | NP_READMODE_BYTE );
            RunCmd( &buff[1] );
            break;
        case LNK_QUERY:
            max = *(unsigned long *)&buff[1];
            if( max > sizeof( buff ) ) max = sizeof( buff );
            --max;
            rc = DosPeekNPipe(RedirHdl, buff, 0, &bytes_read,
                        &BytesAvail, &PipeState );
            if( rc == 0 && BytesAvail.cbpipe != 0 ) {
                DosRead( RedirHdl, &buff[1], max, &bytes_read );
                buff[0] = LNK_OUTPUT;
                DosWrite( LnkHdl, buff, bytes_read + 1, &bytes_read );
            } else {
                rc = DosWaitChild( DCWA_PROCESS, DCWW_NOWAIT, &res,
                                        &dummy, ProcId );
                if( rc != ERROR_CHILD_NOT_COMPLETE ) {
                    DosDisConnectNPipe( RedirHdl );
                    SendStatus( res.codeResult );
                    ProcId = 0;
                } else {
                    /* let someone else run */
                    DosSleep( 1 );
                    buff[0] = LNK_NOP;
                    DosWrite( LnkHdl, buff, 1, &bytes_read );
                }
            }
            break;
        case LNK_CANCEL:
            DosSendSignalException( ProcId, XCPT_SIGNAL_INTR );
            break;
        case LNK_ABORT:
            DosKillProcess( DKP_PROCESSTREE, ProcId );
            break;
        case LNK_DONE:
            return;
        case LNK_SHUTDOWN:
            exit( 0 );
            break;
        }
    }
}
コード例 #5
0
ファイル: localos2.c プロジェクト: Ukusbobra/open-watcom-v2
unsigned LocalSetDrv( int drv )
/*************************/
{
    return( StashErrCode( DosSetDefaultDisk( drv + 1 ), OP_LOCAL ) );
}
コード例 #6
0
VOID resizePDF(VOID *hwnd)
{
HAB habT;
HMQ hmqT;
CHAR errMsg1[80];
CHAR sizeStr[15];
ULONG totalSpace, allocated, available;
ULONG drvNum, drvNumOrg, ulDriveMap;
struct find_t ffblk;
struct Smp
   {
   SHORT indx;
   CHAR noteName[NAMESIZE];
   }tplate;

habT = WinInitialize(0);
hmqT = WinCreateMsgQueue(habT, 0);
WinCancelShutdown(hmqT, TRUE);
subClassWin();
disableButtons();
/*
WinEnableMenuItem(hwndMenu, ID_MISC , FALSE);
WinEnableMenuItem(hwndMenu, ID_OPTIONS , FALSE);
WinEnableMenuItem(hwndMenu, ID_HELPME , FALSE);
WinEnableMenuItem(hwndMenu, ID_SETMODULES , FALSE);
WinEnableMenuItem(WinWindowFromID(hwndFrame, FID_SYSMENU), SC_CLOSE , FALSE);
*/

_dos_findfirst(datFile, _A_NORMAL, &ffblk);
DosQueryCurrentDisk(&drvNumOrg, &ulDriveMap);
drvNum = pdf[0].noteText[0] - '@';
DosSetDefaultDisk(drvNum);
QueryDiskSpace (drvNum,
		&totalSpace,
		&allocated,
		&available);
if( ((ffblk.size*2)+44000) >= available )
   {
   strcpy(errMsg1, "You need at least ");
   ultoa((ffblk.size*2)+44000, sizeStr, 10);
   strcat(errMsg1, sizeStr);
   strcat(errMsg1, " bytes free and possibly more to resize this file.");
   WinMessageBox(HWND_DESKTOP,
		 (HWND)hwnd,
		 errMsg1,
		 "Not enough disk space to accomplish task!",
		 0,
		 MB_ICONEXCLAMATION | MB_OK);
   }
else
   {
   INT LRECSIZE;
   INT xx, i;
   FILE *rHan, *hanTMP;
   div_t dvt;
   INT origFL;

   origFL = FIXEDLEN;
   rHan = fopen(datFile, MRW);
   fseek(rHan, 0L, SEEK_SET);
   fread(&recIndex, sizeof(recIndex), 1, rHan);
   xx = WinQueryLboxCount(WinWindowFromID((HWND)hwnd, ID_LISTBOX1));
   LRECSIZE = 0;
   for(i=0;i<xx;i++)
      {
      fread(&tplate, sizeof(tplate), 1, rHan);
      fread(&dataRecs.noteText, FIXEDLEN, 1, rHan);
      if( strlen(dataRecs.noteText) > LRECSIZE )
	 LRECSIZE = strlen(dataRecs.noteText);
      }
   fclose(rHan);
   if( LRECSIZE < 1000 )
      sModSize = 1;
   if( LRECSIZE > 28999 )
      sModSize = 30;
   if( (LRECSIZE > 999) && (LRECSIZE < 29000) )
      {
      dvt = div(LRECSIZE, 1000);
      if( dvt.rem == 0 )
	 sModSize = dvt.quot;
      else
	 sModSize = dvt.quot + 1;
      }
   if( newSizePrompt((HWND)hwnd) )
      {
      rHan = fopen(datFile, MRW);
      fseek(rHan, 0L, SEEK_SET);
      fread(&recIndex, sizeof(recIndex), 1, rHan);
      recIndex[0].alIndex = sModSize;
      hanTMP = fopen("TMP$$$$$.PDF", "w+b" );
      fwrite(&recIndex, sizeof(recIndex), 1, hanTMP);
      for(i=0;i<xx;i++)
	 {
	 fread(&tplate, sizeof(tplate), 1, rHan);
	 fread(&dataRecs.noteText, FIXEDLEN, 1, rHan);
	 fwrite(&tplate, sizeof(tplate), 1, hanTMP);
	 fwrite(&dataRecs.noteText, sModSize, 1, hanTMP);
	 }
      fclose(rHan);
      fclose(hanTMP);
      if( rename(datFile, "X$X$$$$$.PDF") != 0 )
	 {
	 FIXEDLEN = origFL;
	 recIndex[0].alIndex = FIXEDLEN;
	 sModSize = FIXEDLEN;
	 }
      if( rename("TMP$$$$$.PDF", datFile) != 0 )
	 {
	 FIXEDLEN = origFL;
	 recIndex[0].alIndex = FIXEDLEN;
	 rename("X$X$$$$$.PDF", datFile);
	 sModSize = FIXEDLEN;
	 }
      remove("X$X$$$$$.PDF");
      FIXEDLEN = sModSize;
      initLoad(WinWindowFromID((HWND)hwnd, ID_LISTBOX1), datFile);
      setStatus((HWND)hwnd, datFile);
      WinPostMsg(WinWindowFromID((HWND)hwnd, ID_LISTBOX1),
		 LM_SELECTITEM,
		 MPFROMSHORT(0),
		 MPFROMSHORT(TRUE));
      }
   }
DosSetDefaultDisk(drvNumOrg);
enableButtons();
unSubClassWin();
/*
WinEnableMenuItem(hwndMenu, ID_OPTIONS , TRUE);
WinEnableMenuItem(hwndMenu, ID_HELPME , TRUE);
WinEnableMenuItem(hwndMenu, ID_MISC , TRUE);
WinEnableMenuItem(hwndMenu, ID_SETMODULES , TRUE);
WinEnableMenuItem(WinWindowFromID(hwndFrame, FID_SYSMENU), SC_CLOSE , TRUE);
*/
WinDestroyMsgQueue(hmqT);
WinTerminate(habT);
_endthread();
}
コード例 #7
0
ファイル: minicmd.c プロジェクト: ErisBlastar/osfree
BOOL parse_cmd(char *cmd)
{
  unsigned int i, rc;
  int Argc;                // argument count
  #define MAXARGS 32
  char *Argv[MAXARGS];      // argument pointers
  char *pszTemp;

  if (strlen(cmd)==0)
  {
    return FALSE;
  }

  if (strlen(cmd)==2)
    if (cmd[1]==':')
    {
      if (QueryDriveReady(cmd[0]-'a'+1))
        DosSetDefaultDisk(cmd[0]-'a'+1);
      return FALSE;
    }

  while (( *cmd == ' ' ) || ( *cmd == '\t' ))
          cmd++;

  // loop through arguments
  for ( Argc = 0; (( Argc < MAXARGS ) && ( *cmd )); Argc++ )  {

          pszTemp = cmd;              // save start of argument

          while ( isdelim( *cmd ) == 0 ) {
                  if ( *cmd )
                          cmd++;
          }

          // check flag for terminators
          if (Argc == 0) { // '\0' after program name only
                  if (( *cmd != '\0' ))
                          *cmd++ = '\0';
          }

          // update the Argv pointer
          Argv[ Argc ] = pszTemp;
          log("Argv[%d]=%s\n", Argc, pszTemp);

          // skip delimiters for Argv[2] onwards
          while (( *cmd ) && ( isdelim( *cmd )))
                  cmd++;
  }

  while (*cmd && isdelim(*cmd))
    cmd--;

  // change the first trailing delimiter to '\0'
  cmd++;
  *cmd = '\0'; /* second NULL terminator */

  Argv[Argc] = NULL;
  log("Argv[%d]=%s\n", Argc, 0);

  if (!strcmp(Argv[0], "exit"))
  {
    return TRUE;
  }

  for (i = 0; commands[i]; i ++)
  {
    if (!strcmp(Argv[0], commands[i]->cmdname))
    {
      (*(commands[i]->func))(Argc, Argv);
      return FALSE;
    }
  }

  //log("argc=%d\n", Argc);

  //for (i = 0; i < Argc; i++)
  //  log("argv[%d]=%s\n", i, Argv[i]);

  execute_external(Argc, Argv);

  return FALSE;
}
コード例 #8
0
INT ParseFileName (CHAR *pcOut, CHAR *pcIn)
     {
          /*----------------------------------------------------------------
             Input:    pcOut -- Pointer to parsed file specification.
                       pcIn  -- Pointer to raw file specification.
                       
             Returns:  0 -- pcIn had invalid drive or directory.
                       1 -- pcIn was empty or had no filename.
                       2 -- pcOut points to drive, full dir, and file name.

             Changes current drive and directory per pcIn string.
            ----------------------------------------------------------------*/

     CHAR   *pcLastSlash, *pcFileOnly ;
     ULONG  ulDriveNum, ulDriveMap, ulDirLen = CCHMAXPATH ;

     strupr (pcIn) ;

               // If input string is empty, return 1

     if (pcIn [0] == '\0')
          return 1 ;

               // Get drive from input string or current drive

     if (pcIn [1] == ':')
          {
          if (DosSetDefaultDisk (pcIn [0] - '@'))
               return 0 ;

          pcIn += 2 ;
          }
     DosQueryCurrentDisk (&ulDriveNum, &ulDriveMap) ;

     *pcOut++ = (CHAR) ulDriveNum + '@' ;
     *pcOut++ = ':' ;
     *pcOut++ = '\\' ;

               // If rest of string is empty, return 1

     if (pcIn [0] == '\0')
          return 1 ;

               // Search for last backslash.  If none, could be directory.

     if (NULL == (pcLastSlash = strrchr (pcIn, '\\')))
          {
          if (!DosSetCurrentDir (pcIn))
               return 1 ;

                    // Otherwise, get current dir & attach input filename

          DosQueryCurrentDir (0, pcOut, &ulDirLen) ;

          if (strlen (pcIn) > 12)
               return 0 ;

          if (*(pcOut + strlen (pcOut) - 1) != '\\')
               strcat (pcOut++, "\\") ;

          strcat (pcOut, pcIn) ;
          return 2 ;
          }
               // If the only backslash is at beginning, change to root

     if (pcIn == pcLastSlash)
          {
          DosSetCurrentDir ("\\") ;

          if (pcIn [1] == '\0')
               return 1 ;

          strcpy (pcOut, pcIn + 1) ;
          return 2 ;
          }
               // Attempt to change directory -- Get current dir if OK

     *pcLastSlash = '\0' ;

     if (DosSetCurrentDir (pcIn))
          return 0 ;

     DosQueryCurrentDir (0, pcOut, &ulDirLen) ;

               // Append input filename, if any

     pcFileOnly = pcLastSlash + 1 ;

     if (*pcFileOnly == '\0')
          return 1 ;

     if (*(pcOut + strlen (pcOut) - 1) != '\\')
          strcat (pcOut++, "\\") ;

     strcat (pcOut, pcFileOnly) ;
     return 2 ;
     }
コード例 #9
0
MRESULT EXPENTRY OpenDlgProc (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
     {
     static CHAR szCurrentPath [CCHMAXPATH], szBuffer [CCHMAXPATH] ;
     INT         iSelect ;

     switch (msg)
          {
          case WM_INITDLG:
               FillDirListBox (hwnd, szCurrentPath) ;
               FillFileListBox (hwnd) ;

               WinSendDlgItemMsg (hwnd, IDD_FILEEDIT, EM_SETTEXTLIMIT,
                                        MPFROM2SHORT (CCHMAXPATH, 0), NULL) ;
               return 0 ;

          case WM_CONTROL:
               if (SHORT1FROMMP (mp1) == IDD_DIRLIST ||
                   SHORT1FROMMP (mp1) == IDD_FILELIST)
                    {
                    iSelect = (USHORT) WinSendDlgItemMsg (hwnd,
                                                  SHORT1FROMMP (mp1),
                                                  LM_QUERYSELECTION, 0L, 0L) ;

                    WinSendDlgItemMsg (hwnd, SHORT1FROMMP (mp1),
                                       LM_QUERYITEMTEXT,
                                       MPFROM2SHORT (iSelect, sizeof szBuffer),
                                       MPFROMP (szBuffer)) ;
                    }

               switch (SHORT1FROMMP (mp1))             // Control ID
                    {
                    case IDD_DIRLIST:
                         switch (SHORT2FROMMP (mp1))   // notification code
                              {
                              case LN_ENTER:
                                   if (szBuffer [0] == ' ')
                                        DosSetDefaultDisk (szBuffer [1] - '@');
                                   else
                                        DosSetCurrentDir (szBuffer) ;

                                   FillDirListBox (hwnd, szCurrentPath) ;
                                   FillFileListBox (hwnd) ;

                                   WinSetDlgItemText (hwnd, IDD_FILEEDIT, "") ;
                                   return 0 ;
                              }
                         break ;

                    case IDD_FILELIST:
                         switch (SHORT2FROMMP (mp1))   // notification code
                              {
                              case LN_SELECT:
                                   WinSetDlgItemText (hwnd, IDD_FILEEDIT,
                                                      szBuffer) ;
                                   return 0 ;

                              case LN_ENTER:
                                   ParseFileName (szFileName, szBuffer) ;
                                   WinDismissDlg (hwnd, TRUE) ;
                                   return 0 ;
                              }
                         break ;
                    }
               break ;

          case WM_COMMAND:
               switch (COMMANDMSG(&msg)->cmd)
                    {
                    case DID_OK:
                         WinQueryDlgItemText (hwnd, IDD_FILEEDIT,
                                              sizeof szBuffer, szBuffer) ;

                         switch (ParseFileName (szCurrentPath, szBuffer))
                              {
                              case 0:
                                   WinAlarm (HWND_DESKTOP, WA_ERROR) ;
                                   FillDirListBox (hwnd, szCurrentPath) ;
                                   FillFileListBox (hwnd) ;
                                   return 0 ;

                              case 1:
                                   FillDirListBox (hwnd, szCurrentPath) ;
                                   FillFileListBox (hwnd) ;
                                   WinSetDlgItemText (hwnd, IDD_FILEEDIT, "") ;
                                   return 0 ;

                              case 2:
                                   strcpy (szFileName, szCurrentPath) ;
                                   WinDismissDlg (hwnd, TRUE) ;
                                   return 0 ;
                              }
                         break ;

                    case DID_CANCEL:
                         WinDismissDlg (hwnd, FALSE) ;
                         return 0 ;
                    }
               break ;
          }
     return WinDefDlgProc (hwnd, msg, mp1, mp2) ;
     }
コード例 #10
0
ファイル: localos2.c プロジェクト: Azarien/open-watcom-v2
bool LocalInteractive( sys_handle fh )
/************************************/
{
    APIRET type;
    APIRET flags;

    //NYI: really should convert fh to sys_handle, but I know that it's
    // a one-to-one mapping
#ifdef _M_I86
    if( DosQHandType( fh, &type, &flags ) ) {
#else
    if( DosQueryHType( fh, &type, &flags ) ) {
#endif
        return( false );
    }
    if( type == 1 ) {   /* device type */
        return( true );
    }
    return( false );
}

void LocalGetBuff( char *buff, unsigned size )
/********************************************/
{
    struct _STRINGINBUF length;

    if( size > UCHAR_MAX ) {
        size = UCHAR_MAX;
    }
    length.cb = size;
    length.cchIn = 0;
    if( KbdStringIn( buff, &length, 0, 0 ) ) {
        buff[0] = '\r';
        buff[1] = NULLCHAR;
        return;
    }
    buff[length.cchIn] = NULLCHAR;
}

error_handle LocalRename( const char *from, const char *to )
/**********************************************************/
{
#ifdef _M_I86
    return( StashErrCode( DosMove( from, to, 0 ), OP_LOCAL ) );
#else
    return( StashErrCode( DosMove( from, to ), OP_LOCAL ) );
#endif
}

error_handle LocalMkDir( const char *name )
/*****************************************/
{
#ifdef _M_I86
    return( StashErrCode( DosMkDir( name, 0 ), OP_LOCAL ) );
#else
    return( StashErrCode( DosCreateDir( name, NULL ), OP_LOCAL ) );
#endif
}

error_handle LocalRmDir( const char *name )
/*****************************************/
{
#ifdef _M_I86
    return( StashErrCode( DosRmDir( name, 0 ), OP_LOCAL ) );
#else
    return( StashErrCode( DosDeleteDir( name ), OP_LOCAL ) );
#endif
}

error_handle LocalSetDrv( int drv )
/*********************************/
{
#ifdef _M_I86
    return( StashErrCode( DosSelectDisk( drv + 1 ), OP_LOCAL ) );
#else
    return( StashErrCode( DosSetDefaultDisk( drv + 1 ), OP_LOCAL ) );
#endif
}

int LocalGetDrv( void )
/*********************/
{
    APIRET    drive;
    ULONG     map;

#ifdef _M_I86
    if( DosQCurDisk( &drive, &map ) ) {
#else
    if( DosQueryCurrentDisk( &drive, &map ) ) {
#endif
        return( -1 );
    }
    return( drive - 1 );
}

error_handle LocalSetCWD( const char *name )
/******************************************/
{
#ifdef _M_I86
    return( StashErrCode( DosChDir( name, 0 ), OP_LOCAL ) );
#else
    return( StashErrCode( DosSetCurrentDir( name ), OP_LOCAL ) );
#endif
}

long LocalGetFileAttr( const char *name )
/***************************************/
{
#ifdef _M_I86
    USHORT attr;

    if( DosQFileMode( name, &attr, 0 ) ) {
        return( -1L );
    }
    return( attr );
#else
    FILESTATUS3 fileinfo;

    if( DosQueryPathInfo( name, FIL_STANDARD, &fileinfo, sizeof( fileinfo ) ) ) {
        return( -1L );
    }
    return( fileinfo.attrFile );
#endif
}