示例#1
0
static void doClose( HFILE hdl )
{
    BreakPoint( DosClose( hdl ) );
}
示例#2
0
int main(int argc, char **argv) {
	HFILE drive;
	ULONG action, ulParmLen, ulDataLen;
	GetAudioDiskParm parmGAD;
	GetAudioDiskData dataGAD;
	GetAudioTrackParm parmGAT;
	GetAudioTrackData dataGAT;
	APIRET rc;
	int track;

	if (argc != 2) { usage(argv[0]); }
	if (strlen(argv[1]) != 2) { usage(argv[0]); }
	if (argv[1][1] != ':') { usage(argv[0]); }
	strupr(argv[1]);
	if ((argv[1][0] < 'A') || (argv[1][0] > 'Z')) { usage(argv[0]); }
																/* open the cd player */
	rc = DosOpen(
		argv[1], &drive, &action, 0, 0,
		OPEN_ACTION_FAIL_IF_NEW | OPEN_ACTION_OPEN_IF_EXISTS,
		OPEN_FLAGS_DASD | OPEN_FLAGS_FAIL_ON_ERROR |
		OPEN_FLAGS_NO_CACHE | OPEN_SHARE_DENYNONE |
		OPEN_ACCESS_READONLY,
		NULL
	);
	if (rc) {
		sprintf(errbuf, "error %ld opening cdrom device '%s'\n", rc, argv[1]);
		whoops(errbuf);
		exit(1);
	}
																/* get the track range */
	memcpy(parmGAD.signature, "CD01", 4);
	memset(&dataGAD, 0, sizeof(dataGAD));
	rc = DosDevIOCtl(
		drive, IOCTL_CDROMAUDIO, CDROMAUDIO_GETAUDIODISK,
		&parmGAD, ulParmLen = sizeof(parmGAD), &ulParmLen,
		&dataGAD, ulDataLen = sizeof(dataGAD), &ulDataLen
	);
	if (rc) {
		sprintf(errbuf, "Could not acquire start and end track numbers: %ld", rc);
		whoops(errbuf);
		exit(1);
	}

	for (track = dataGAD.start_track; track <= dataGAD.final_track; track++) {
		memcpy(parmGAT.signature, "CD01", 4);
		parmGAT.track_number = track;
		memset(&dataGAT, 0, sizeof(dataGAT));
		rc = DosDevIOCtl(
			drive, IOCTL_CDROMAUDIO, CDROMAUDIO_GETAUDIOTRACK,
			&parmGAT, ulParmLen = sizeof(parmGAT), &ulParmLen,
			&dataGAT, ulDataLen = sizeof(dataGAT), &ulDataLen
		);
		if (rc) {
			sprintf(errbuf, "Could not get info for track %d: error %ld", track, rc);
			whoops(errbuf);
			exit(1);
		}

		printf(
			"%d\t%d\t%d\t%d\n",
			track,
			dataGAT.track_address.mins,
			dataGAT.track_address.secs,
			dataGAT.track_address.frames
		);
	}
	printf(
		"999\t%d\t%d\t%d\n",
		dataGAD.lead_out_address.mins,
		dataGAD.lead_out_address.secs,
		dataGAD.lead_out_address.frames
	);

	DosClose(drive);

	return(0);
}
ULONG       FileGetJPEGInfo( CAMJpgInfo * pji, char * szFile, ULONG cbFile)

{
    ULONG       rc;
    ULONG       ul;
    ULONG       cbAlloc;
    BOOL        fHandler = FALSE;
    CAMJXRR     reg;

do
{
    memset( &reg, 0, sizeof(CAMJXRR));
    memset( pji, 0, sizeof(CAMJpgInfo));

    rc = DosOpen( szFile, &reg.hFile, &ul, 0, 0,
                  OPEN_ACTION_FAIL_IF_NEW | OPEN_ACTION_OPEN_IF_EXISTS,
                  OPEN_FLAGS_SEQUENTIAL | OPEN_SHARE_DENYWRITE |
                  OPEN_ACCESS_READONLY, 0);
    if (rc) {
        printf( "DosOpen - rc= 0x%x\n", (int)rc);
        break;
    }

    // allocate a lot of uncommited memory
    cbAlloc = ((cbFile + 0xfff) & ~0xfff);
    rc = DosAllocMem( (void**)(&reg.pBase), cbAlloc,
                      PAG_READ | PAG_WRITE);
    if (rc) {
        printf( "DosAllocMem - rc= 0x%x\n", (int)rc);
        break;
    }

    // get up to the first 16k of the file - this is enough
    // for my Canon but not enough for a Sony I've tried

    ul = (cbFile >= 0x4000) ? 0x4000 : cbAlloc;
    rc = DosSetMem( reg.pBase, ul, PAG_COMMIT | PAG_DEFAULT);
    if (rc) {
        printf( "FileGetJPEGInfo - DosSetMem - rc= 0x%x\n", (int)rc);
        break;
    }

    ul = (cbFile >= 0x4000) ? 0x4000 : cbFile;
    ul = FileReadFile( reg.hFile, reg.pBase, ul, szFile);
    if (!ul) {
        rc = CAMERR_NEEDDATA;
        break;
    }

    // any access beyond 16k will generate an exception;
    // the handler will commit the page and read the corresponding
    // 4k from the file;  if it encounters a file error, it will
    // longjmp() back to here so we can abort
    reg.lFilePtr += ul;
    reg.lEOF = cbFile;
    reg.pEnd = reg.pBase + cbAlloc;
    reg.szFile = szFile;
    reg.xrr.ExceptionHandler = FileExceptionHandler;

    // since the handler is lower on the stack than the jmpbuf,
    // longjmp() will unwind it before returning, so prevent
    // the cleanup code below from unsetting it
    if (setjmp( reg.jmpbuf)) {
        fHandler = FALSE;
        break;
    }

    rc = DosSetExceptionHandler( &reg.xrr);
    if (rc) {
        printf( "DosSetExceptionHandler - rc= 0x%x\n", (int)rc);
        break;
    }
    fHandler = TRUE;

    // parse the file
    rc = FileIdentifyFile( pji, reg.pBase);
    if (rc) {
        printf( "FileIdentifyFile - rc= 0x%x\n", (int)rc);
        break;
    }

    // change the address of the thumb into an offset into the file
    if (pji->pThumb)
        pji->offsThumb = pji->pThumb - reg.pBase;

} while (0);

    if (fHandler) {
        rc = DosUnsetExceptionHandler( &reg.xrr);
        if (rc)
            printf( "DosUnsetExceptionHandler - rc= 0x%lx\n", rc);
    }

    if (reg.pBase) {
        rc = DosFreeMem( reg.pBase);
        if (rc)
            printf( "DosFreeMem - rc= 0x%x\n", (int)rc);
    }

    if (reg.hFile) {
        rc = DosClose( reg.hFile);
        if (rc)
            printf( "DosClose - rc= 0x%x\n", (int)rc);
    }

    return (0);
}
示例#4
0
文件: MAIN.C 项目: jskripsky/ancient
BOOL SortList( BYTE Type )
    {
    struct Eintrag FAR *Eintraege;

    HFILE File;
    WORD  NumEntries;

    BOOL  Sorted;

    switch( Type )
	{
	case BEGRUENDUNGEN:
	    DosOpen( BEGRUENDFILENAME, &File, OPEN_RDONLY );
	    break;

	case ABTEILUNGEN:
	    DosOpen( ABTEILFILENAME, &File, OPEN_RDONLY );
	    break;

	case ZEITKONTI:
	    DosOpen( ZEITKFILENAME, &File, OPEN_RDONLY );
	    break;
	}

    DosRead( File, &NumEntries, sizeof( NumEntries ), NULL );

    Eintraege = DosAllocFarMem( sizeof( *Eintraege ) * (NumEntries + 1) );
    DosRead( File, Eintraege, sizeof( *Eintraege ) * NumEntries, NULL );
    DosClose( File );

    do
	{
	WORD Counter;
	Sorted = TRUE;

	for( Counter = 0; Counter < NumEntries - 1; Counter++ )
	    if( StdFarMemCmp( Eintraege[Counter].Code, Eintraege[Counter + 1].Code, sizeof( Eintraege[Counter].Code ) ) > 0 )
		{
		Sorted = FALSE;
		StdFarMemCpy( &Eintraege[NumEntries], &Eintraege[Counter], sizeof( Eintraege[Counter] ) );
		StdFarMemCpy( &Eintraege[Counter], &Eintraege[Counter + 1], sizeof( Eintraege[Counter] ) );
		StdFarMemCpy( &Eintraege[Counter + 1], &Eintraege[NumEntries], sizeof( Eintraege[Counter] ) );
		}
	}
    while( !Sorted );

    switch( Type )
	{
	case BEGRUENDUNGEN:
	    DosCreate( BEGRUENDFILENAME, &File, FILE_NORMAL );
	    break;

	case ABTEILUNGEN:
	    DosCreate( ABTEILFILENAME, &File, FILE_NORMAL );
	    break;

	case ZEITKONTI:
	    DosCreate( ZEITKFILENAME, &File, FILE_NORMAL );
	    break;
	}

    DosWrite( File, &NumEntries, sizeof( NumEntries ), NULL );
    DosWrite( File, Eintraege, sizeof( *Eintraege ) * NumEntries, NULL );

    DosClose( File );
    DosFreeFarMem( Eintraege );

    return( TRUE );
    }
示例#5
0
int main(VOID) {

   APIRET   rc                     = NO_ERROR;   /* Return code */

   CHAR     message[256]           = "";         /* Message buffer */

   HFILE    PipeHandle             = NULLHANDLE; /* Pipe handle */

   PIPEINFO PipeBuffer[4]          = {{0}};

   struct   _AVAILDATA  BytesAvail = {0};

   UCHAR    Buffer[200]            = {0};

   ULONG    bytes                  = 0;

   ULONG    Action                 = 0;

   ULONG    PipeState              = 0;

   ULONG    HandType               = 0;

   ULONG    FlagWord               = 0;

   ULONG    BytesRead              = 0;



   rc = DosOpen("\\PIPE\\EXAMPLE", &PipeHandle, &Action, 0, 0, FILE_OPEN,

                OPEN_ACCESS_READWRITE | OPEN_SHARE_DENYREADWRITE |

                OPEN_FLAGS_FAIL_ON_ERROR, NULL);

   if (rc != NO_ERROR) {

      printf("DosOpen error: error code = %u\n", rc);

      return 1;

   }  else printf("Connected to pipe.\n");

   rc = DosQueryHType(PipeHandle, &HandType, &FlagWord);

   if (rc != NO_ERROR) {

      printf("DosQueryHType error: error code = %u\n", rc);

      return 1;

   }  else printf("Handle type value is %u\n", HandType);



   rc = DosPeekNPipe(PipeHandle, Buffer, sizeof(Buffer),

                     &BytesRead, &BytesAvail, &PipeState);

   if (rc != NO_ERROR) {

      printf("DosPeekNPipe error: error code = %u\n", rc);

      return 1;

   }  else printf("Pipe status value is %u\n\n", PipeState);



   printf("Enter message to send to PIPEHOST: ");



   fflush(NULL);   /* Flush above printf out to display */

   gets(message);



   rc = DosWrite(PipeHandle, message, strlen(message), &bytes);

   if (rc != NO_ERROR) {

      printf("DosWrite error: error code = %u\n", rc);

      return 1;

   }



   rc = DosRead(PipeHandle, message, sizeof(message), &bytes);

   if (rc != NO_ERROR) {

      printf("DosRead error: error code = %u\n", rc);

      return 1;

   }



   printf("\nMessage received from PIPEHOST: %s\n\n", message);



   rc = DosClose(PipeHandle);

   /* Should check if (rc != NO_ERROR) here... */



   printf("...Disconnected\n");

   return NO_ERROR;

}
VOID GameThread(VOID *hpTempPipe)
{
   HPIPE   hpGamePipe;
   BOOL    fQuit=FALSE;
   PPIB    dummy;
   PTIB    ptibThrdInfo;
   ULONG   ulID;
   USHORT  usMsg, usData, GameBoard[DIVISIONS][DIVISIONS], usTotalMoves=0;

   /* save pipe handle in own memory */
   hpGamePipe = *(HPIPE *)hpTempPipe;

   /* get thread ID for use in displaying messages */
   if((BOOL)DosGetInfoBlocks(&ptibThrdInfo, &dummy))
   {
      ulID = 0;
   }

   else
   {
      ulID = ptibThrdInfo->tib_ptib2->tib2_ultid;
   }

   InitBoard(GameBoard);

   /* initialize random number generator */
   srand((unsigned) ulID);

   if(!(BOOL)DosConnectNPipe(hpGamePipe))
   {
      while (!fAppExit &&
             !fQuit &&
             !(BOOL)(Pipe_IO(CLIENT, hpGamePipe, &usMsg, &usData, ulID)) &&
             !fAppExit)
      {
         switch (usMsg)
         {
            case CLIENT_MOVE:
               /* enter move from message */
               *((USHORT *)GameBoard + usData) = CLIENT_NUM;
               usTotalMoves++;

               /* test for win if total moves >= DIVISIONS*2-1 */
               if (usTotalMoves >= DIVISIONS*2-1 &&
                   ((BOOL)(usData=WinTest(GameBoard)) ||
                    usTotalMoves == DIVISIONS*DIVISIONS))
               {
                  /* notify of win or draw, and break (switch) on return */
                  if (!usData)
                  {
                     usData = DIVISIONS*DIVISIONS;
                     usMsg = WIN_DRAW;
                  }

                  else
                  {
                     usMsg = WIN_CLIENT;
                  }

                  if ((BOOL)Pipe_IO(SERVER, hpGamePipe, &usMsg, &usData, ulID))
                  {
                     WinPostMsg(hwndMain, WM_MSG, MPFROMLONG(IDMSG_PIPE_WRITE_FAILED), MPVOID);
                     fQuit = TRUE;
                     break;
                  }

                  /* call InitBoard on win */
                  InitBoard(GameBoard);
                  usTotalMoves = 0;

                  break;  /* switch */
               }

               /* NO BREAK */

            case YOU_FIRST:
               /* get move if there are moves left */
               usData = GetMove(GameBoard, usTotalMoves);
               usTotalMoves++;

               /* test for win if total moves >= DIVISIONS*2-1 */
               if (usTotalMoves >= DIVISIONS*2-1 &&
                   ((BOOL)(usMsg=WinTest(GameBoard)) ||
                    usTotalMoves == DIVISIONS*DIVISIONS))
               {
                  /* write game_won message with winning move */
                  if (!usMsg)
                  {
                     usMsg = WIN_DRAW;
                  }

                  else
                  {
                     usMsg = WIN_SERVER;
                  }

                  if ((BOOL)Pipe_IO(SERVER, hpGamePipe, &usMsg, &usData, ulID))
                  {
                     WinPostMsg(hwndMain, WM_MSG, MPFROMLONG(IDMSG_PIPE_WRITE_FAILED), MPVOID);
                     fQuit = TRUE;
                     break;
                  }

                  /* call InitBoard on win */
                  InitBoard(GameBoard);
                  usTotalMoves = 0;
               }

               /* else */
               else
               {
                  /* write move to client */
                  usMsg = SERVER_MOVE;
                  if ((BOOL)Pipe_IO(SERVER, hpGamePipe, &usMsg, &usData, ulID))
                  {
                     WinPostMsg(hwndMain, WM_MSG, MPFROMLONG(IDMSG_PIPE_WRITE_FAILED), MPVOID);
                     fQuit = TRUE;
                  }
               }
               break;

            case ERROR_MSG:
               /* post the error to message queue */
               WinPostMsg(hwndMain, WM_MSG, MPFROMSHORT(usData), MPVOID);

            case CLIENT_QUIT:
               /* quit while */
               fQuit = TRUE;
         }
      }

      DosDisConnectNPipe(hpGamePipe);
   }

   DosClose(hpGamePipe);
}
示例#7
0
文件: MAIN.C 项目: jskripsky/ancient
BOOL CreateList( HFILE File, BYTE Type )
    {
    struct Eintrag Eintrag;

    DWORD Distance;
    WORD  NumEntries;
    WORD  NumEffEntries;
    DWORD FileLength;
    DWORD FilePos;

    CHAR  PresentMark;
    BYTE  LengthMark;
    BYTE  EndMark;

    WORD  BytesRead;

    BYTE  CodeLength;
    WORD  Counter;
    HFILE OutFile;

    Distance = 0;
    DosSetFilePtr( File, &Distance, FILE_END, &FileLength );

    Distance = 0x80;
    DosSetFilePtr( File, &Distance, FILE_BEGIN, &FilePos );
    NumEntries = 0;
    NumEffEntries = 0;

    while( FilePos < FileLength )
	{
	DosRead( File, &PresentMark, sizeof( PresentMark ), &BytesRead );
	FilePos += BytesRead;

	NumEntries++;
	if( PresentMark == '@' )
	    NumEffEntries++;

	DosRead( File, &LengthMark, sizeof( LengthMark ), &BytesRead );
	FilePos += BytesRead;

	Distance = LengthMark;
	DosSetFilePtr( File, &Distance, FILE_CURRENT, &FilePos );
	DosRead( File, &EndMark, sizeof( EndMark ), &BytesRead );
	if( Type == ZEITKONTI )
	    DosRead( File, &EndMark, sizeof( EndMark ), &BytesRead );

	FilePos += BytesRead;
	}

    switch( Type )
	{
	case BEGRUENDUNGEN:
	    CodeLength = BEGRUENDCODELENGTH;
	    DosCreate( BEGRUENDFILENAME, &OutFile, FILE_NORMAL );
	    break;

	case ABTEILUNGEN:
	    CodeLength = ABTEILCODELENGTH;
	    DosCreate( ABTEILFILENAME, &OutFile, FILE_NORMAL );
	    break;

	case ZEITKONTI:
	    CodeLength = ZEITKCODELENGTH;
	    DosCreate( ZEITKFILENAME, &OutFile, FILE_NORMAL );
	    break;
	}

    Distance = 0x80;
    DosSetFilePtr( File, &Distance, FILE_BEGIN, &FilePos );

    if( Type == ABTEILUNGEN )
	{
	DosRead( File, &PresentMark, sizeof( PresentMark ), &BytesRead );
	DosRead( File, &LengthMark, sizeof( LengthMark ), &BytesRead );

	DosRead( File, Eintrag.Code, CodeLength, NULL );
	DosRead( File, Eintrag.Description, BESCHREIBUNGSLENGTH, NULL );

	Distance = LengthMark - BESCHREIBUNGSLENGTH - CodeLength;
	DosSetFilePtr( File, &Distance, FILE_CURRENT, NULL );

	DosRead( File, &EndMark, sizeof( EndMark ), &BytesRead );
	if( Type == ZEITKONTI )
	    DosRead( File, &EndMark, sizeof( EndMark ), &BytesRead );

	NumEntries--;
	NumEffEntries--;
	}

    if( Type == ZEITKONTI )
	{
	NumEntries--;
	NumEffEntries--;
	}

    DosWrite( OutFile, &NumEffEntries, sizeof( NumEffEntries ), NULL );

    for( Counter = 0; Counter < NumEntries; Counter++ )
	{
	memset( &Eintrag, SPACECHAR, sizeof( Eintrag ) );

	DosRead( File, &PresentMark, sizeof( PresentMark ), &BytesRead );
	DosRead( File, &LengthMark, sizeof( LengthMark ), &BytesRead );

	DosRead( File, Eintrag.Code, CodeLength, NULL );
	DosRead( File, Eintrag.Description, BESCHREIBUNGSLENGTH, NULL );

	Eintrag.Code[JSCODELENGTH] = 0;
	Eintrag.CodeLength = JSCODELENGTH;

	while( Eintrag.Code[Eintrag.CodeLength - 1] == SPACECHAR && Eintrag.CodeLength > 0 )
	    {
	    Eintrag.Code[Eintrag.CodeLength - 1] = 0;
	    Eintrag.CodeLength--;
	    }

	Eintrag.Description[BESCHREIBUNGSLENGTH] = 0;
	Eintrag.DescriptionLength = BESCHREIBUNGSLENGTH;

	while( Eintrag.Description[Eintrag.DescriptionLength - 1] == SPACECHAR && Eintrag.DescriptionLength > 0 )
	    {
	    Eintrag.Description[Eintrag.DescriptionLength - 1] = 0;
	    Eintrag.DescriptionLength--;
	    }

	Distance = LengthMark - BESCHREIBUNGSLENGTH - CodeLength;
	DosSetFilePtr( File, &Distance, FILE_CURRENT, NULL );

	DosRead( File, &EndMark, sizeof( EndMark ), &BytesRead );
	if( Type == ZEITKONTI )
	    DosRead( File, &EndMark, sizeof( EndMark ), &BytesRead );

	if( PresentMark == '@' )
	    DosWrite( OutFile, &Eintrag, sizeof( Eintrag ), NULL );
	}

    DosClose( OutFile );

    if( NumEffEntries == 0 )
	return( FALSE );
    else
	return( TRUE );
    }
示例#8
0
文件: task.c 项目: TijmenW/FreeDOS
COUNT DosExeLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode)
{
  COUNT rc,
    /*err,     */
    /*env_size,*/
    i;
  UCOUNT nBytesRead;
  UWORD mem,
    env,
    asize,
    start_seg;
  ULONG image_size;
  ULONG image_offset;
  BYTE FAR *sp;
  psp FAR *p;
  psp FAR *q = MK_FP(cu_psp, 0);
  mcb FAR *mp;
  iregs FAR *irp;
  UWORD reloc[2];
  seg FAR *spot;
  LONG exe_size;

  int  ModeLoadHigh = mode & 0x80;
  UBYTE UMBstate = uppermem_link;

  mode &= 0x7f;
    

  /* Clone the environement and create a memory arena     */
  if (mode != OVERLAY)
  {
    if ((rc = ChildEnv(exp, &env, namep)) != SUCCESS)
      return rc;
  }
  else
    mem = exp->load.load_seg;

  /* compute image offset from the header                 */
  asize = 16;
  image_offset = (ULONG)header.exHeaderSize * asize;

  /* compute image size by removing the offset from the   */
  /* number pages scaled to bytes plus the remainder and  */
  /* the psp                                              */
  /*  First scale the size                                */
  asize = 512;
  image_size = (ULONG)header.exPages * asize;
  /* remove the offset                                    */
  image_size -= image_offset;

  /* and finally add in the psp size                      */
  if (mode != OVERLAY)
    image_size += sizeof(psp);             /*TE 03/20/01*/
    
  if (mode != OVERLAY)
  {
    if (  ModeLoadHigh && uppermem_root)
    {
      DosUmbLink(1);                          /* link in UMB's */
      mem_access_mode |= ModeLoadHigh;
    }
  
    /* Now find out how many paragraphs are available       */
    if ((rc = DosMemLargest((seg FAR *) & asize)) != SUCCESS)
    {
      DosMemFree(env);
      return rc;
    }

    exe_size = (LONG) long2para(image_size) + header.exMinAlloc;
    
    
    /* + long2para((LONG) sizeof(psp)); ?? see above
       image_size += sizeof(psp) -- 1999/04/21 ska */
    if (exe_size > asize && (mem_access_mode & 0x80))
    {
      /* First try low memory */
      mem_access_mode &= ~0x80;
      rc = DosMemLargest((seg FAR *) & asize);
      mem_access_mode |= 0x80;
      if (rc != SUCCESS)
      {
        DosMemFree(env);
        return rc;
      }
    }
    if (exe_size > asize)
    {
      DosMemFree(env);
      return DE_NOMEM;
    }
    exe_size = (LONG) long2para(image_size) + header.exMaxAlloc;
    /* + long2para((LONG) sizeof(psp)); ?? -- 1999/04/21 ska */
    if (exe_size > asize)
      exe_size = asize;
    
    /* TE if header.exMinAlloc == header.exMaxAlloc == 0,
       DOS will allocate the largest possible memory area
       and load the image as high as possible into it.
       discovered (and after that found in RBIL), when testing NET */
       
    if ((header.exMinAlloc | header.exMaxAlloc ) == 0)
      exe_size = asize;
      
      
/* /// Removed closing curly brace.  We should not attempt to allocate
       memory if we are overlaying the current process, because the new
       process will simply re-use the block we already have allocated.
       This was causing execl() to fail in applications which use it to
       overlay (replace) the current exe file with a new one.
       Jun 11, 2000 - rbc
  } */


  /* Allocate our memory and pass back any errors         */
  /* We can still get an error on first fit if the above  */
  /* returned size was a bet fit case                     */
  /* ModeLoadHigh = 80 = try high, then low                   */
  if ((rc = DosMemAlloc((seg) exe_size, mem_access_mode | ModeLoadHigh, (seg FAR *) & mem
                        ,(UWORD FAR *) & asize)) < 0)
  {
    if (rc == DE_NOMEM)
    {
      if ((rc = DosMemAlloc(0, LARGEST, (seg FAR *) & mem
                            ,(UWORD FAR *) & asize)) < 0)
      {
        DosMemFree(env);
        return rc;
      }
      /* This should never happen, but ... */
      if (asize < exe_size)
      {
        DosMemFree(mem);
        DosMemFree(env);
        return rc;
      }
    }
    else
    {
      DosMemFree(env);
      return rc;
    }
  }
  else
    /* with no error, we got exactly what we asked for      */
    asize = exe_size;

#ifdef DEBUG  
  printf("loading '%S' at %04x\n", namep, mem);
#endif    

/* /// Added open curly brace and "else" clause.  We should not attempt
       to allocate memory if we are overlaying the current process, because
       the new process will simply re-use the block we already have allocated.
       This was causing execl() to fail in applications which use it to
       overlay (replace) the current exe file with a new one.
       Jun 11, 2000 - rbc */
  }
  else
    asize = exe_size;
/* /// End of additions.  Jun 11, 2000 - rbc */

  if (  ModeLoadHigh && uppermem_root)
    {
    mem_access_mode &= ~ModeLoadHigh;              /* restore old situation */
    DosUmbLink(UMBstate);                          /* restore link state */
    }

   
  if (mode != OVERLAY)
  {
    /* memory found large enough - continue processing      */
    mp = MK_FP(mem, 0);
    ++mem;
  }
  else
    mem = exp->load.load_seg;

  /* create the start seg for later computations          */
  if (mode == OVERLAY)
    start_seg = mem;
  else
  {
    start_seg = mem + long2para((LONG) sizeof(psp));
  }

  /* Now load the executable                              */
  /* If file not found - error                            */
  /* NOTE - this is fatal because we lost it in transit   */
  /* from DosExec!                                        */
  if ((rc = DosOpen(namep, 0)) < 0)
  {
    fatal("(DosExeLoader) exe file lost in transit");
  }
  /* offset to start of image                             */
  if (doslseek(rc, image_offset, 0) != image_offset)
  {
    if (mode != OVERLAY)
    {
      DosMemFree(--mem);
      DosMemFree(env);
    }
    return DE_INVLDDATA;
  }

  /* read in the image in 32K chunks                      */
  if (mode != OVERLAY)
  {
    exe_size = image_size - sizeof(psp);
  }
  else
    exe_size = image_size;

  if (exe_size > 0)
  {
    if (mode != OVERLAY)
    {
      if ((header.exMinAlloc == 0) && (header.exMaxAlloc == 0))
      {
                             /* then the image should be placed as high as possible */
        start_seg = start_seg + mp->m_size - (image_size + 15) / 16;
      }
    }

    sp = MK_FP(start_seg, 0x0);

    do
    {
      nBytesRead = DosRead((COUNT) rc, (COUNT) (exe_size < CHUNK ? exe_size : CHUNK), (VOID FAR *) sp, &UnusedRetVal);
      sp = add_far((VOID FAR *) sp, (ULONG) nBytesRead);
      exe_size -= nBytesRead;
    }
    while (nBytesRead && exe_size > 0);
  }

  /* relocate the image for new segment                   */
  doslseek(rc, (LONG) header.exRelocTable, 0);
  for (i = 0; i < header.exRelocItems; i++)
  {
    if (DosRead(rc, sizeof(reloc), (VOID FAR *) & reloc[0], &UnusedRetVal) != sizeof(reloc))
    {
      return DE_INVLDDATA;
    }
    if (mode == OVERLAY)
    {
      spot = MK_FP(reloc[1] + mem, reloc[0]);
      *spot += exp->load.reloc;
    }
    else
    {
      /*      spot = MK_FP(reloc[1] + mem + 0x10, reloc[0]); */
      spot = MK_FP(reloc[1] + start_seg, reloc[0]);
      *spot += start_seg;
    }
  }

  /* and finally close the file                           */
  DosClose(rc);

  /* exit here for overlay                                */
  if (mode == OVERLAY)
    return SUCCESS;

  /* point to the PSP so we can build it                  */
  p = MK_FP(mem, 0);
  setvec(0x22, (VOID(INRPT FAR *) (VOID)) MK_FP(user_r->CS, user_r->IP));
  new_psp(p, mem + asize);

  asize = patchPSP(mem - 1, env, exp, namep); /* asize = fcbcode */

  /* Transfer control to the executable                   */
  p->ps_parent = cu_psp;
  p->ps_prevpsp = (BYTE FAR *) MK_FP(cu_psp, 0);
  q->ps_stack = (BYTE FAR *) user_r;
  user_r->FLAGS &= ~FLG_CARRY;

  switch (mode)
  {
    case LOADNGO:
      /* build the user area on the stack                     */
      irp = MK_FP(header.exInitSS + start_seg,
              ((header.exInitSP - sizeof(iregs)) & 0xffff));

      /* start allocating REGs                                */
      /* Note: must match es & ds memory segment              */
      irp->ES = irp->DS = mem;
      irp->CS = header.exInitCS + start_seg;
      irp->IP = header.exInitIP;
      irp->AX = asize;             /* asize = fcbcode    */
      irp->BX =
      irp->CX =
      irp->DX =
      irp->SI =
      irp->DI =
      irp->BP = 0;
      irp->FLAGS = 0x200;

      cu_psp = mem;
      dta = p->ps_dta;

      if (InDOS)
        --InDOS;
      exec_user(irp);
      /* We should never be here                      */
      fatal("KERNEL RETURNED!!!");
      break;

    case LOAD:
      cu_psp = mem;
      exp->exec.stack = MK_FP(header.exInitSS + start_seg, header.exInitSP);
      *((UWORD FAR *) exp->exec.stack) = asize; /* fcbcode */
      exp->exec.start_addr = MK_FP(header.exInitCS + start_seg, header.exInitIP);
      return SUCCESS;
  }
  return DE_INVLDFMT;
}
示例#9
0
main()


{
    HFILE inhandle, outhandle;
    ULONG action, status, speed;
    ULONG numread;
    ULONG parlen, datlen;
    int   i, maxreadsize;

    printf("Opening SBDSP device driver\n");
    status = DosOpen( "SBDSP$", &outhandle, &action, 0,
                          FILE_NORMAL, FILE_OPEN,
   OPEN_ACCESS_READWRITE | OPEN_SHARE_DENYNONE | OPEN_FLAGS_WRITE_THROUGH,
			  NULL );

    printf("Result of DosOpen = %d\n",status);
    printf("Action taken      = %d\n",action);
    printf("File handle       = %d\n",outhandle);

    printf("\n Now opening sample.voc\n");
    status = DosOpen( "sample.voc", &inhandle, &action, 0,
                          FILE_NORMAL, FILE_OPEN,
              OPEN_ACCESS_READWRITE | OPEN_SHARE_DENYNONE,
			  NULL );

    printf("Result of DosOpen = %d\n",status);
    printf("Action taken      = %d\n",action);
    printf("File handle       = %d\n",inhandle);

    maxreadsize=20000;

/* note  - need emx-0.8e for following to work */

    printf("Enter speed for playback: ");
    scanf("%u", &speed);

    /* set speed */
    datlen=2;
    parlen=0;
    status=DosDevIOCtl(outhandle, DSP_CAT, DSP_IOCTL_SPEED,
                    NULL, 0, &parlen,
                    &speed, 2, &datlen);
    printf("Status of setting speed to %u is %u\n",speed,status);


    /* now read some bytes from device */
  do{
    status = DosRead(inhandle, &buf,maxreadsize, &numread);

    if (numread==0) break;
    
    /* now write some bytes to device */
    i=numread;
    status = DosWrite(outhandle, &buf, i, &numread);

  }while(1);



    status = DosClose(inhandle);
    printf("Result of DosClose = %d\n",status);
    status = DosClose(outhandle);
    printf("Result of DosClose = %d\n",status);
  }
示例#10
0
/**
 * Implementation of VbglR3Init and VbglR3InitUser
 */
static int vbglR3Init(const char *pszDeviceName)
{
    uint32_t cInits = ASMAtomicIncU32(&g_cInits);
    Assert(cInits > 0);
    if (cInits > 1)
    {
        /*
         * This will fail if two (or more) threads race each other calling VbglR3Init.
         * However it will work fine for single threaded or otherwise serialized
         * processed calling us more than once.
         */
#ifdef RT_OS_WINDOWS
        if (g_hFile == INVALID_HANDLE_VALUE)
#elif !defined (VBOX_VBGLR3_XFREE86)
        if (g_File == NIL_RTFILE)
#else
        if (g_File == -1)
#endif
            return VERR_INTERNAL_ERROR;
        return VINF_SUCCESS;
    }
#if defined(RT_OS_WINDOWS)
    if (g_hFile != INVALID_HANDLE_VALUE)
#elif !defined(VBOX_VBGLR3_XFREE86)
    if (g_File != NIL_RTFILE)
#else
    if (g_File != -1)
#endif
        return VERR_INTERNAL_ERROR;

#if defined(RT_OS_WINDOWS)
    /*
     * Have to use CreateFile here as we want to specify FILE_FLAG_OVERLAPPED
     * and possible some other bits not available thru iprt/file.h.
     */
    HANDLE hFile = CreateFile(pszDeviceName,
                              GENERIC_READ | GENERIC_WRITE,
                              FILE_SHARE_READ | FILE_SHARE_WRITE,
                              NULL,
                              OPEN_EXISTING,
                              FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED,
                              NULL);

    if (hFile == INVALID_HANDLE_VALUE)
        return VERR_OPEN_FAILED;
    g_hFile = hFile;

#elif defined(RT_OS_OS2)
    /*
     * We might wish to compile this with Watcom, so stick to
     * the OS/2 APIs all the way. And in any case we have to use
     * DosDevIOCtl for the requests, why not use Dos* for everything.
     */
    HFILE hf = NULLHANDLE;
    ULONG ulAction = 0;
    APIRET rc = DosOpen((PCSZ)pszDeviceName, &hf, &ulAction, 0, FILE_NORMAL,
                        OPEN_ACTION_OPEN_IF_EXISTS,
                        OPEN_FLAGS_FAIL_ON_ERROR | OPEN_FLAGS_NOINHERIT | OPEN_SHARE_DENYNONE | OPEN_ACCESS_READWRITE,
                        NULL);
    if (rc)
        return RTErrConvertFromOS2(rc);

    if (hf < 16)
    {
        HFILE ahfs[16];
        unsigned i;
        for (i = 0; i < RT_ELEMENTS(ahfs); i++)
        {
            ahfs[i] = 0xffffffff;
            rc = DosDupHandle(hf, &ahfs[i]);
            if (rc)
                break;
        }

        if (i-- > 1)
        {
            ULONG fulState = 0;
            rc = DosQueryFHState(ahfs[i], &fulState);
            if (!rc)
            {
                fulState |= OPEN_FLAGS_NOINHERIT;
                fulState &= OPEN_FLAGS_WRITE_THROUGH | OPEN_FLAGS_FAIL_ON_ERROR | OPEN_FLAGS_NO_CACHE | OPEN_FLAGS_NOINHERIT; /* Turn off non-participating bits. */
                rc = DosSetFHState(ahfs[i], fulState);
            }
            if (!rc)
            {
                rc = DosClose(hf);
                AssertMsg(!rc, ("%ld\n", rc));
                hf = ahfs[i];
            }
            else
                i++;
            while (i-- > 0)
                DosClose(ahfs[i]);
        }
    }
    g_File = (RTFILE)hf;

#elif defined(VBOX_VBGLR3_XFREE86)
    int File = xf86open(pszDeviceName, XF86_O_RDWR);
    if (File == -1)
        return VERR_OPEN_FAILED;
    g_File = File;

#else

    /* The default implementation. (linux, solaris, freebsd) */
    RTFILE File;
    int rc = RTFileOpen(&File, pszDeviceName, RTFILE_O_READWRITE | RTFILE_O_OPEN | RTFILE_O_DENY_NONE);
    if (RT_FAILURE(rc))
        return rc;
    g_File = File;

#endif

#ifndef VBOX_VBGLR3_XFREE86
    /*
     * Create release logger
     */
    PRTLOGGER pReleaseLogger;
    static const char * const s_apszGroups[] = VBOX_LOGGROUP_NAMES;
    int rc2 = RTLogCreate(&pReleaseLogger, 0, "all", "VBOX_RELEASE_LOG",
                          RT_ELEMENTS(s_apszGroups), &s_apszGroups[0], RTLOGDEST_USER, NULL);
    /* This may legitimately fail if we are using the mini-runtime. */
    if (RT_SUCCESS(rc2))
        RTLogRelSetDefaultInstance(pReleaseLogger);
#endif

    return VINF_SUCCESS;
}
示例#11
0
文件: task.c 项目: TijmenW/FreeDOS
COUNT DosComLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode)
{
  COUNT rc
    /* err     */
    /*,env_size*/;
  COUNT nread;
  UWORD mem;
  UWORD env,
    asize;
  BYTE FAR *sp;
  psp FAR *p;
  psp FAR *q = MK_FP(cu_psp, 0);
  iregs FAR *irp;
  LONG com_size;

  int  ModeLoadHigh = mode & 0x80;
  UBYTE  UMBstate     = uppermem_link;

  mode &= 0x7f;

  if (mode != OVERLAY)
  {

    if ((rc = ChildEnv(exp, &env, namep)) != SUCCESS)
    {
      return rc;
    }
    /* Now find out how many paragraphs are available       */
    if ((rc = DosMemLargest((seg FAR *) & asize)) != SUCCESS)
    {
      DosMemFree(env);
      return rc;
    }
    com_size = asize;
    
    if (  ModeLoadHigh && uppermem_root)
        {
        DosUmbLink(1);                          /* link in UMB's */
        }
    
    /* Allocate our memory and pass back any errors         */
    if ((rc = DosMemAlloc((seg) com_size, mem_access_mode, (seg FAR *) & mem
                        ,(UWORD FAR *) & asize)) < 0)
    {
        if (rc == DE_NOMEM)
        {
            if ((rc = DosMemAlloc(0, LARGEST, (seg FAR *) & mem
                                  ,(UWORD FAR *) & asize)) < 0)
            {
                DosMemFree(env);
                return rc;
            }
            /* This should never happen, but ... */
            if (asize < com_size)
            {
                DosMemFree(mem);
                DosMemFree(env);
                return rc;
            }
        }
        else
        {
            DosMemFree(env);           /* env may be 0 */
            return rc;
        }
    }
    ++mem;
  }
  else
    mem = exp->load.load_seg;
    
  if (  ModeLoadHigh && uppermem_root)
    {
    DosUmbLink(UMBstate);               /* restore link state */
    }
    

  /* Now load the executable                              */
  /* If file not found - error                            */
  /* NOTE - this is fatal because we lost it in transit   */
  /* from DosExec!                                        */
  if ((rc = DosOpen(namep, 0)) < 0)
    fatal("(DosComLoader) com file lost in transit");

  /* do it in 32K chunks                                  */
  if ((com_size = DosGetFsize(rc)) != 0)
  {
    if (mode == OVERLAY)        /* memory already allocated */
      sp = MK_FP(mem, 0);
    else
    {                 /* test the filesize against the allocated memory */
      UWORD tmp = 16;
        
      sp = MK_FP(mem, sizeof(psp));

      /* This is a potential problem, what to do with .COM files larger than
         the allocated memory?
         MS DOS always only loads the very first 64KB - sizeof(psp) bytes.
         -- 1999/04/21 ska */
      if ((ULONG)com_size > (ULONG)asize * tmp)  /* less memory than the .COM file has */
        (ULONG)com_size = (ULONG)asize * tmp; /* << 4 */
    }
    do
    {
      nread = DosRead(rc, CHUNK, sp, &UnusedRetVal);
      sp = add_far((VOID FAR *) sp, (ULONG) nread);
    }
    while ((com_size -= nread) > 0 && nread == CHUNK);
  }
  DosClose(rc);

  if (mode == OVERLAY)
    return SUCCESS;

  /* point to the PSP so we can build it                  */
  p = MK_FP(mem, 0);
  setvec(0x22, (VOID(INRPT FAR *) (VOID)) MK_FP(user_r->CS, user_r->IP));
  new_psp(p, mem + asize);

  asize = patchPSP(mem - 1, env, exp, namep); /* asize=fcbcode for ax */

  /* Transfer control to the executable                   */
  p->ps_parent = cu_psp;
  p->ps_prevpsp = (BYTE FAR *) MK_FP(cu_psp, 0);
  q->ps_stack = (BYTE FAR *) user_r;
  user_r->FLAGS &= ~FLG_CARRY;
  cu_psp = mem;
  dta = p->ps_dta;

  switch (mode)
  {
    case LOADNGO:
      {
        *((UWORD FAR *) MK_FP(mem, 0xfffe)) = (UWORD) 0;
  
        /* build the user area on the stack                     */
        irp = MK_FP(mem, (0xfffe - sizeof(iregs)));

        /* start allocating REGs                                */
        irp->ES = irp->DS = mem;
        irp->CS = mem;
        irp->IP = 0x100;
        irp->AX = asize; /* fcbcode */
        irp->BX =
        irp->CX =
        irp->DX =
        irp->SI =
        irp->DI =
        irp->BP = 0;
        irp->FLAGS = 0x200;

        if (InDOS)
          --InDOS;
        exec_user(irp);

        /* We should never be here                      */
        fatal("KERNEL RETURNED!!!");
        break;
      }
    case LOAD:
      exp->exec.stack = MK_FP(mem, 0xfffe);
      *((UWORD FAR *)exp->exec.stack) = asize;
      exp->exec.start_addr = MK_FP(mem, 0x100);
      return SUCCESS;
  }

  return DE_INVLDFMT;
}
MRESULT EXPENTRY MyWindowProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 )
{
   RECTL    clientrect;                     /* Rectangle coordinates        */
   HPS      hpsPaint;
   POINTL   pt;                            /* String screen coordinates    */
   BOOL     Invalid;
   int      Line;
   ERRORID  Err;
   HWND     Focus,Active;
   HMQ      hmqDeb;
   PID      pid,cpid;
   TID      tid,ctid;
   switch( msg )
   {
   case WM_CREATE:
      WinStartTimer(hab,hwnd,1234,500);
      break;                                /* end the application.     */
   case WM_TIMER:
      rc=DosOpen("KBD$", &hKbd, &Action, 0, FILE_NORMAL, FILE_OPEN,
                 OPEN_ACCESS_READONLY | OPEN_SHARE_DENYNONE |
                 OPEN_FLAGS_FAIL_ON_ERROR, 0);
      if (rc) {
         char Buf[80];
         sprintf(Buf,"Open rc = %d",rc);
         WinMessageBox(HWND_DESKTOP, HWND_DESKTOP,
                       Buf,
                       "TRAPIT",
                        1234,
                        MB_OK);
      } /* endif */
      Dlen= sizeof(State);
      rc = DosDevIOCtl( hKbd, 4, 0x73, 0, 0, 0, &State, sizeof(State), &Dlen );
      Shift=(USHORT)State;
      DosClose(hKbd);
      Invalid=FALSE;
      if ((State&0x0500)==0x0500) {
         if (Color!=CLR_RED) {
            Color=CLR_RED;
            Invalid=TRUE;
         } /* endif */
         Focus=WinQueryFocus(HWND_DESKTOP);
         Active=WinQueryActiveWindow(HWND_DESKTOP);
         WinQueryWindowProcess(Focus,&pid,&tid);
         hmqDeb=(HMQ)WinQueryWindowULong(Focus,QWL_HMQ);
         if (hmqDeb==hmq) {
            sprintf(Buffer,"Sorry Can't unhang Myself");
         } else {
            DosKillProcess(DKP_PROCESS,pid);
         } /* endif */
      } else {
         if ((State&0x0A00)==0x0A00) {
            if (Color!=CLR_BLUE) {
               Color=CLR_BLUE;
               Invalid=TRUE;
            } /* endif */
            Focus=WinQueryFocus(HWND_DESKTOP);
            Active=WinQueryActiveWindow(HWND_DESKTOP);
            WinQueryWindowProcess(Focus,&pid,&tid);
            hmqDeb=(HMQ)WinQueryWindowULong(Focus,QWL_HMQ);
            if (hmqDeb==hmq) {
               sprintf(Buffer,"Sorry Can't trap Myself");
            } else {
               HENUM hEnum;
               CHAR Class[20];
               HWND Child;
               hEnum = WinBeginEnumWindows(HWND_OBJECT);
               while ( (Child=WinGetNextWindow(hEnum)) != 0) {
                   WinQueryWindowProcess(Child,&cpid,&ctid);
                   if (cpid==pid) {
                       Class[0]=0;
                       WinQueryClassName(Child,sizeof(Class)-1,Class);
                       if (strcmp(Class,"Killer")==0) {
                           if (WinPostMsg(Child,WM_USER+1,0,0)) {
                              DosBeep(1800,80);
                              DosBeep(600,80);
                              DosBeep(1800,80);
                           }
                       } /* endif */
                   } /* endif */
               }
               WinEndEnumWindows(hEnum);
            } /* endif */
         } else {
            if (Color!=CLR_BACKGROUND) {
               Color=CLR_BACKGROUND;
               Invalid=TRUE;
            }
         } /* endif */
      } /* endif */
      if (Invalid) {
            WinInvalidateRect( hwnd, NULL, TRUE );
      } /* endif */
      break;
   case WM_PAINT:
      hpsPaint=WinBeginPaint( hwnd,0, &clientrect );
      WinFillRect( hpsPaint, &clientrect,Color );/* Fill invalid rectangle       */
      pt.x = 10; pt.y = 190;                    /* Set the text coordinates,    */
      GpiCharStringAt( hpsPaint, &pt, (LONG)strlen(Buffer),Buffer);
      for (Line=0;Line<8;Line++ ) {
         pt.x = 10; pt.y = 170-(20*Line);   /* Set the text coordinates,    */
         GpiCharStringAt( hpsPaint, &pt, (LONG)strlen(LabelText[Line]),LabelText[Line]);
      } /* endfor */
      WinEndPaint( hpsPaint );                        /* Drawing is complete   */
      break;
    case WM_CLOSE:
      /******************************************************************/
      /* This is the place to put your termination routines             */
      /******************************************************************/
      WinPostMsg( hwnd, WM_QUIT, 0L, 0L );  /* Cause termination        */
      break;
    default:
      /******************************************************************/
      /* Everything else comes here.  This call MUST exist              */
      /* in your window procedure.                                      */
      /******************************************************************/
      return WinDefWindowProc( hwnd, msg, mp1, mp2 );
  }
  return FALSE;
}
示例#13
0
int main(int argc, char *argv[])
{
    char buf[200];
    APIRET rc;
    ULONG action,arg,argsz, nread;
    HFILE fd;

    /* open device */
    rc = DosOpen((PSZ)"\\dev\\console$", &fd, &action, 0,
                 FILE_NORMAL, FILE_OPEN,
                 OPEN_ACCESS_READWRITE|OPEN_SHARE_DENYNONE, (PEAOP2)NULL);
    if (rc) {
        fprintf(stderr,
                "!!! Cannot open console device, rc=%d\n",
                rc);
        fputs("Probably the XF86SUP device driver was not properly installed.\n",
              stderr);
        exit(1);
    }

    /* grab the console */
    arg = 1;
    rc = DosDevIOCtl(fd, XFREE86_CONS, CONS_TIOCCONS,
                     &arg, sizeof(arg),&argsz,
                     NULL, 0, NULL);
    if (rc) {
        fprintf(stderr,"!!! Cannot grab console, status = %d\n",rc);
        fputs("Possibly another process currently owns the console\n",
              stderr);
        DosClose(fd);
        exit(2);
    }

    rc = DosDevIOCtl(fd, XFREE86_CONS, CONS_OWNER,
                     NULL, 0, NULL,
                     (PULONG)&buf, sizeof(buf),&argsz);
    if (rc) {
        fprintf(stderr,"!!! Cannot get console owner, status = %d\n",rc);
        fputs("Possibly another process currently owns the console\n",
              stderr);
        DosClose(fd);
        exit(2);
    }
    printf("Owner of console is: %s\n",buf);

    fd = _imphandle(fd);


    for(;;) {
        fd_set rfds,wfds,efds;
        int rc;

        /* read some chars */
        memset(buf,0,200);

        FD_ZERO(&rfds);
        FD_ZERO(&wfds);
        FD_ZERO(&efds);
        FD_SET(fd,&rfds);
        printf("%d %x %x %x\n",fd+1,(&rfds)[0],(&rfds)[1],(&rfds)[2]);
        rc = select(fd+1,&rfds,&wfds,&efds,NULL);
        printf("rc(select)=%d\n",rc);


        rc = DosRead(fd,(PVOID)buf,199,&nread);
        if (rc) {
            fprintf(stderr,
                    "!!! Read from console returned status=%d\n",
                    rc);
            break;
        }
        if (nread) {
            fputs(buf,stdout);
            if (nread < 199) {
                /* wait some time */
                DosSleep(50); /* 50 msec */
            }
        }
    }
    DosClose(fd);
    exit(0);
    return 0;
}
示例#14
0
文件: ulibos2.c 项目: swhobbit/UUPC
void ncloseline(void)
{
   APIRET rc;
   USHORT com_error;

#ifdef __OS2__
   ULONG ParmLengthInOut;
   ULONG DataLengthInOut;
#endif

   if ( ! portActive )
   {
      printmsg(0,"ncloseline: Internal error, port already closed");
      return;
   }

   portActive = KWFalse; /* flag port closed for error handler  */
   hangupNeeded = KWFalse;  /* Don't fiddle with port any more  */

/*--------------------------------------------------------------------*/
/*                             Lower DTR                              */
/*--------------------------------------------------------------------*/

   com_signals.fbModemOn  = 0x00;
   com_signals.fbModemOff = DTR_OFF;

   printmsg(2,"Restoring port attributes and speed %lu",
               (unsigned long) saveSpeed );

#ifdef __OS2__

   ParmLengthInOut = sizeof(com_signals);
   DataLengthInOut = sizeof(com_error);

   rc = DosDevIOCtl( commHandle,
                     IOCTL_ASYNC,
                     ASYNC_SETMODEMCTRL,
                     (PVOID)&com_signals,
                     sizeof(com_signals),
                     &ParmLengthInOut,
                     (PVOID) &com_error,
                     sizeof(com_error),
                     &DataLengthInOut);

#else

   rc = DosDevIOCtl( &com_error,
                     &com_signals,
                     ASYNC_SETMODEMCTRL,
                     IOCTL_ASYNC,
                     commHandle);

#endif

   if ( rc )
      printOS2error( "ASYNC_SETMODEMCTRL", rc );
   else if ( com_error )
      ShowError( com_error );

#ifdef __OS2__

   ParmLengthInOut = sizeof(save_com_attrib);
   DataLengthInOut = 0;
   rc = DosDevIOCtl( commHandle,
                     IOCTL_ASYNC,
                     ASYNC_SETLINECTRL,
                     (PVOID) &save_com_attrib,
                     sizeof(save_com_attrib),
                     &ParmLengthInOut,
                     NULL,
                     0L,
                     &DataLengthInOut);

#else

   rc = DosDevIOCtl( FAR_NULL,
                     &save_com_attrib,
                     ASYNC_SETLINECTRL,
                     IOCTL_ASYNC,
                     commHandle);
#endif

   if (rc)
      printOS2error( "ASYNC_SETLINECTRL", rc );

/*--------------------------------------------------------------------*/
/*               Restore original modem DCB information               */
/*--------------------------------------------------------------------*/

#ifdef __OS2__

   ParmLengthInOut = sizeof(save_com_dcbinfo);
   DataLengthInOut = 0;
   rc = DosDevIOCtl( commHandle,
                     IOCTL_ASYNC,
                     ASYNC_SETDCBINFO,
                     (PVOID) &save_com_dcbinfo,
                     sizeof(save_com_dcbinfo),
                     &ParmLengthInOut,
                     NULL,
                     0L,
                     &DataLengthInOut);

#else

   rc = DosDevIOCtl( FAR_NULL,
                     &save_com_dcbinfo,
                     ASYNC_SETDCBINFO,
                     IOCTL_ASYNC,
                     commHandle);

#endif

   if ( rc )
      printOS2error( "ASYNC_SETDCBINFO", rc );

/*--------------------------------------------------------------------*/
/*                    Restore original port speed                     */
/*--------------------------------------------------------------------*/

   SIOSpeed( saveSpeed );

/*--------------------------------------------------------------------*/
/*                      Actually close the port                       */
/*--------------------------------------------------------------------*/

   rc = DosClose( commHandle );
   commHandle = -1;

   if ( rc != 0 )
      printOS2error( "DosClose", rc );

/*--------------------------------------------------------------------*/
/*                   Stop logging the data to disk                    */
/*--------------------------------------------------------------------*/

   traceStop();

} /* ncloseline */
示例#15
0
/*
 * NAME:	jfs_logform
 * FUNCTION:	format file system log
 *
 * RETURN:	0 -	successful
 *		-1 -	error occur 
 *
 */
int32 jfs_logform(
        int32   fd, 	   /* for inline log, this is a file descriptor
			    * for an opened device to write log.
			    * for outline log, it is -1 */
	int32   aggr_blk_size, /* aggregate block size in bytes */
        int32   s_l2bsize, /* log2 of aggregate block size in bytes */
	uint32  s_flag,    /* fs superblock s_flag is passed in   */
        int64   log_start, /* offset of the start of inline log in 
			    * number of aggr. blocks. for outline log
			    * it is set as zero */
        int32   log_len,   /* inline log length in number of aggr. blks 
			    * for outline log, it is zero */
	char *  dev_name,  /* logical volume of the outline log device  
			    * for inline log, it is NULL */
	int32   nblks      /* size of the outline log in 512 byte blocks
			    * for inline log, it is zero */
)
{
        ULONG Action;
        int64	log_len_in_bytes;
        char  parms = 0;
        unsigned long parmlen = sizeof(parms);
        ULONG actual;
        struct DPB dev;
        unsigned long devlen = sizeof(dev);

	int32 oflag,logfd,npages,rc,k,dblks,total_blks;
	char  logpages[4 * LOGPSIZE];
	logpage_t *logp;		/* array of 4 log pages */
	static logsuper_t log_sup;
	struct lrd *lrd_ptr;
	int64  log_begin;  /* the location of the beginning of the log inside
			    * of the file system. ( in bytes )
			    */
	int64 log_contwt;
	char answer;
	int16 inlinelog = (s_flag & JFS_INLINELOG );
	int    Working_counter;
	char *Working[5];

#define LOGBUFSIZE	4 * LOGPSIZE
	logp = (logpage_t *) &logpages;
	Working[0] = "   |\r";
	Working[1] = "   /\r";
	Working[2] = "   -\r";
	Working[3] = "   \\\r";

   /*
    * check to see whether standard out has been redirected, and
    * set the flag accordingly.
    */
  if( (ujfs_stdout_redirected()) != 0 ) {
    stdout_redirected = 1;
    }
  else {
    stdout_redirected = 0;
    }

	/* 
	 * if it is an outline log, do device check and open device
	 */
	if (!inlinelog )
	{
		/*  open the device 
	 	*/
		if (DosOpen(dev_name, (unsigned long *)&logfd, &Action, 0, 0, 
			OPEN_ACTION_OPEN_IF_EXISTS,
			OPEN_FLAGS_DASD | OPEN_FLAGS_FAIL_ON_ERROR |
			OPEN_SHARE_DENYREADWRITE | OPEN_ACCESS_READWRITE, 0))
                	goto errout;
		fd = logfd;

		/*
		 * Lock the drive
		 */
		rc = DosDevIOCtl(fd, IOCTL_DISK, DSK_LOCKDRIVE, 
				&parms, sizeof(parms),
				&parmlen, &parms, sizeof(parms), &parmlen);

		/*
	 	* validate/determine device size.
	 	* for bringup allow ioctl to fail or to report zero size.
	 	*/
		rc = DosDevIOCtl(fd, IOCTL_DISK, DSK_GETDEVICEPARAMS, &parms,
                         sizeof(parms), &parmlen, &dev, sizeof(dev), &devlen);
		if (rc == NO_ERROR)
		{
			total_blks = dev.dev_bpb.total_sectors +
			dev.dev_bpb.large_total_sectors;
			if (total_blks > 0)
			{
				dblks = (nblks == 0) ? total_blks :
					MIN(nblks,total_blks);
			}
		}

		if ((npages = dblks/(LOGPSIZE/512)) == 0)
		{
			printf("ioctl failed \n");
			printf("try again but specify number of blocks \n");
			return -1;
		}	

		/* before we destroy anything in the log, try to
		 * confirm with the user
	 	 */
			while(TRUE) {
				printf("logform: destroy %s (y)?",dev_name);
				fflush(stdout);
				answer = getchar();
				if(answer == 'n' || answer == 'N') exit(1);
				else if(answer == 'y' || answer == 'Y' ||
							answer == '\n') break;
				while((answer = getchar()) != '\n');
			}
        rc = write_bootsec(fd, &(dev.dev_bpb), "jfslog", 1);

	}
/***************************************************************************/
	else {  /* the fs has an inlinelog  */
		log_len_in_bytes = ((int64) log_len) << s_l2bsize;
		npages = log_len_in_bytes / LOGPSIZE; 
		}

		/* 
		 * init log superblock: log page 1
		 */
	log_sup.magic = LOGMAGIC;
	log_sup.version = LOGVERSION;
	log_sup.state = LOGREDONE;
	log_sup.flag = s_flag;  /* assign fs s_flag to log superblock.
				 * currently s_flag carries the inlinelog
				 * info and commit option ( i.e. group commit
				 * or lazy commit, etc.. )
				 */
	log_sup.size = npages;
	log_sup.bsize = aggr_blk_size;
	log_sup.l2bsize = s_l2bsize; 
	log_sup.end = 2*LOGPSIZE + LOGPHDRSIZE + LOGRDSIZE;

	/* find the log superblock location 
	 */
	log_begin = log_start << s_l2bsize;
	rc = ujfs_rw_diskblocks(fd, (log_begin+LOGPSIZE), (unsigned)LOGPSIZE,
					(char *)&log_sup, PUT);
	if ( rc != 0 )
		goto errout;

	/*
	 * init device pages 2 to npages-1 as log data pages:
	 *
	 * log page sequence number (lpsn) initialization:
	 * the N (= npages-2) data pages of the log is maintained as 
	 * a circular file for the log records;
	 * lpsn grows by 1 monotonically as each log page is written 
	 * to the circular file of the log;
	 * Since the AIX DUMMY log record is dropped for this XJFS, 
	 * and setLogpage() will not reset the page number even if
	 * the eor is equal to LOGPHDRSIZE. In order for binary search
	 * still work in find log end process, we have to simulate the
	 * log wrap situation at the log format time.
	 * The 1st log page written will have the highest lpsn. Then
	 * the succeeding log pages will have ascending order of
	 * the lspn starting from 0, ... (N-2)
	 */

	/* 
		initialize 1st 2 log pages to be written: lpsn = N-1, 0
		and also a SYNCPT log record is written to the N-1 page 
	
		Since the log is always an even number of meg, if we
		write 2 pages before entering the loop, we are assured
		that the log will end after a 4 page buffer.
	*/

	logp[0].h.eor = logp[0].t.eor = LOGPHDRSIZE + LOGRDSIZE;
	logp[0].h.page = logp[0].t.page = npages - 3;
	lrd_ptr = (struct lrd *)&logp[0].data;
	lrd_ptr->logtid = 0;
	lrd_ptr->backchain = 0;
	lrd_ptr->type = LOG_SYNCPT;
	lrd_ptr->length = 0;
	lrd_ptr->log.syncpt.sync = 0;

	logp[1].h.eor = logp[1].t.eor = LOGPHDRSIZE;
	logp[1].h.page = logp[1].t.page = 0;
	lrd_ptr = (struct lrd *)&logp[1].data;
	lrd_ptr->logtid = 0;
	lrd_ptr->backchain = 0;
	lrd_ptr->type = LOG_SYNCPT;
	lrd_ptr->length = 0;
	lrd_ptr->log.syncpt.sync = 0;

	rc = ujfs_rw_diskblocks(fd, (log_begin+2*LOGPSIZE), 
					(unsigned) 2*LOGPSIZE,
					(char *)&(logp[0]), PUT);
	if ( rc != 0 )
{
printf("Error RW 2\n");
		goto errout;
}

	/* initialize buffer to write 4 pages at a time */
	logp[0].h.eor = logp[0].t.eor = LOGPHDRSIZE;

	logp[2].h.eor = logp[2].t.eor = LOGPHDRSIZE;
	lrd_ptr = (struct lrd *)&logp[2].data;
	lrd_ptr->logtid = 0;
	lrd_ptr->backchain = 0;
	lrd_ptr->type = LOG_SYNCPT;
	lrd_ptr->length = 0;
	lrd_ptr->log.syncpt.sync = 0;

	logp[3].h.eor = logp[3].t.eor = LOGPHDRSIZE;
	lrd_ptr = (struct lrd *)&logp[3].data;
	lrd_ptr->logtid = 0;
	lrd_ptr->backchain = 0;
	lrd_ptr->type = LOG_SYNCPT;
	lrd_ptr->length = 0;
	lrd_ptr->log.syncpt.sync = 0;

	/* initialize succeeding log  pages: lpsn = 1, 2, ..., (N-2) */
	Working_counter = 0;
	log_contwt = log_begin + LOGBUFSIZE;
	for ( k = 1; k < npages - 4; k+=4 )
	{
		logp[0].h.page = logp[0].t.page = k;
		logp[1].h.page = logp[1].t.page = k + 1;
		logp[2].h.page = logp[2].t.page = k + 2;
		logp[3].h.page = logp[3].t.page = k + 3;
		rc = ujfs_rw_diskblocks(fd, log_contwt, 
				(unsigned) LOGBUFSIZE, (char *)&(logp[0]), PUT);
		if (rc != 0 )
{
printf("Error RW 3\n");
		goto errout;
}
		log_contwt += LOGBUFSIZE;

		if( !stdout_redirected ) {
  			Working_counter++;
			switch( Working_counter ) {
			    case( 100 ):
				DosPutMessage( 1, strlen(Working[0]), Working[0] );
				fflush( stdout );
				break;
			    case( 200 ):
				DosPutMessage( 1, strlen(Working[1]), Working[1] );
				fflush( stdout );
				break;
			    case( 300 ):
				DosPutMessage( 1, strlen(Working[2]), Working[2] );
				fflush( stdout );
				break;
			    case( 400 ):
				DosPutMessage( 1, strlen(Working[3]), Working[3] );
				fflush( stdout );
				Working_counter = 0;
				break;
			    default:
				break;
			}
		}
	}
	if (!inlinelog)
	{
        	rc = DosDevIOCtl(fd, IOCTL_DISK, DSK_UNLOCKDRIVE, &parms,
				 sizeof(parms), &parmlen, &parms,
				 sizeof(parms), &parmlen);
        	rc = DosClose(fd);
	}

	return(0);

errout:
	if (rc == ERROR_WRITE_PROTECT)
		message_user(ERROR_WRITE_PROTECT, NULL, 0, STDOUT_CODE,
			     NO_RESPONSE, OSO_MSG);
	return(-1);

}
示例#16
0
文件: osprg.c 项目: wolfpython/nelvis
/*
 * Declares which program we'll run, and what we'll be doing with it.
 * This function should return ElvTrue if successful.  If there is an error,
 * it should issue an error message via msg(), and return ElvFalse.
 *
 * For UNIX, the behavior of this function depends on willwrite.
 * If willwrite, then the command is saved and a temporary file is
 * is created to store the data that will become the program's stdin,
 * and the function succeeds if the temp file was created successfully.
 * Else the program is forked (with stdout/stderr redirected to a pipe
 * if willread) and the function succedes if pipe() and fork()
 * succeed.
 */
ELVBOOL 
prgopen (char  *cmd,    /* command string */
         ELVBOOL  willwrite,  /* if ElvTrue, redirect command's stdin */
         ELVBOOL  willread)  /* if ElvTrue, redirect command's stdout */
{
  HFILE r_pipe, w_pipe;  /* two ends of a pipe */
  SAVE_IO save_io;
  HFILE fd;
  APIRET rc;

  /* Mark both fd's as being unused */
  writefd = readfd = -1;

  /* Next step depends on what I/O we expect to do with this program */
  if (willwrite && willread)
    {
      /* save the command */
      command = strdup (cmd);

      /* create a temporary file for feeding the program's stdin */
      sprintf (tempfname, "%s/elvis%d.tmp", TMPDIR, (int)getpid ());
      writefd = open (tempfname, O_WRONLY|O_CREAT|O_EXCL, S_IREAD|S_IWRITE);
      if (writefd < 0)
        {
          msg (MSG_ERROR, "can't make temporary file");
          free (command);
          return ElvFalse;
        }
    }
  else if (willwrite || willread) /* but not both */
    {
      /* Create a pipe. */
      rc = DosCreatePipe (&r_pipe, &w_pipe, 4096);
      if (rc != NO_ERROR)
        {
          msg(MSG_ERROR, "can't create pipe");
          goto Error;
        }

      /*
       * Redirect standard file handles for the CHILD PROCESS.
       */

      if (willwrite)
        {
          /* Save the standard input handle. */
          if (!SaveStdIOHandles (save_io, SAVE_STDIN))
            goto Error;

          /* Get standard input from the read end of the pipe. */
          fd = 0;
          if (DosDupHandle (r_pipe, &fd) != NO_ERROR)
            goto DupError;

          /*
           * Prevent the child process from inheriting the write end
           * of the pipe.  This will ensure that the pipe closes
           * cleanly when the parent process (elvis) is done with it.
           */
          if (DosSetFHState (w_pipe, OPEN_FLAGS_NOINHERIT) != NO_ERROR)
            {
              msg (MSG_ERROR, "can't set file inheritance");
              goto Error;
            }
        }
      else
        {
          /* Save the standard output and error handles. */
          if (!SaveStdIOHandles (save_io, SAVE_STDOUT | SAVE_STDERR))
            {
              goto Error;
            }

          /* Send standard output to the write end of the pipe. */
          fd = 1;
          if (DosDupHandle (w_pipe, &fd) != NO_ERROR)
            {
              goto DupError;
            }

          /* Send error output to the write end of the pipe. */
          fd = 2;
          if (DosDupHandle (w_pipe, &fd) != NO_ERROR)
            {
              goto DupError;
            }
        }

      /* Launch the command. */
      if ((pid = RunCommand (cmd)) < 0)
        {
          msg (MSG_ERROR, "can't spawn");
          goto Error;
        }

      if (willwrite)
        {
          /*
           * Close the read end of the pipe and remember the fd 
           * of the write end.
           */
          DosClose (r_pipe);
          r_pipe = NULLHANDLE;
          writefd = w_pipe;
        }
      else
        {
          /*
           * Close the write end of the pipe and remember the fd 
           * of the read end.
           */
          DosClose (w_pipe);
          w_pipe = NULLHANDLE;
          readfd = r_pipe;
        }

      /* Restore standard file handles for the PARENT PROCESS. */
      RestoreStdIOHandles (save_io);
    }
  else /* no redirection */
    {
      /* Launch the command. */
      if ((pid = RunCommand (cmd)) < 0)
        {
          msg(MSG_ERROR, "can't spawn");
          goto Error;
        }
    }

  /* if we get here, we must have succeeded */
  return ElvTrue;

DupError:
  msg(MSG_ERROR, "can't dup file handle");

Error:
  /* Restore standard I/O handles if necessary. */
  RestoreStdIOHandles (save_io);
  return ElvFalse;
}
示例#17
0
int xf86CloseSerial (int fd)
{
	APIRET rc = DosClose((HFILE)fd);
	return rc ? -1 : 0;
}
示例#18
0
文件: osprg.c 项目: wolfpython/nelvis
/*
 * Marks the end of writing.  Returns ElvTrue if all is okay, or ElvFalse if
 * error.
 *
 * For UNIX, the temp file is closed, and the program is forked.
 * (Since this function is only called when willwrite, the program
 * wasn't forked when prgopen() was called.)  Returns ElvTrue if the
 * fork was successful, or ElvFalse if it failed.
 */
ELVBOOL 
prggo (void)
{
  HFILE r_pipe, w_pipe;  /* two ends of a pipe */
  SAVE_IO save_io;
  HFILE fd, tmp_fd;
  APIRET rc;

  /* If we weren't writing, then there's nothing to be done here */
  if (writefd < 0)
    {
      return ElvTrue;
    }

  /*
   * If we're using a temp file, close it for writing, then spawn
   * the program with its stdin redirected to come from the file.
   */
  if (command)
    {
      /* Close the temp file for writing. */
      close (writefd);
      writefd = -1;

      /* Make a pipe to use for reading stdout/stderr. */
      rc = DosCreatePipe (&r_pipe, &w_pipe, 4096);
      if (rc != NO_ERROR)
        {
          msg (MSG_ERROR, "can't create pipe");
          goto Error;
        }

      /* Save all of the standard I/O handles. */
      if (!SaveStdIOHandles (save_io, 
                             SAVE_STDIN | SAVE_STDOUT | SAVE_STDERR))
        {
          goto Error;
        }

      /*
       * Redirect standard file handles for the CHILD PROCESS.
       */

      /* Get stdin from the temporary file. */
      tmp_fd = open (tempfname, O_RDONLY);
      fd = 0;
      if (DosDupHandle (tmp_fd, &fd) != NO_ERROR)
        {
          goto DupError;
        }
      close(tmp_fd);

      /* Connect the write end of the pipe to stdout/stderr. */
      fd = 1;
      if (DosDupHandle (w_pipe, &fd) != NO_ERROR)
        {
          goto DupError;
        }
      fd = 2;
      if (DosDupHandle (w_pipe, &fd) != NO_ERROR)
        {
          goto DupError;
        }

      /*
       * Prevent the child process from inheriting the read end
       * of the pipe.  This will ensure that the pipe closes
       * cleanly when the parent process (elvis) is done with it.
       */
      if (DosSetFHState (r_pipe, OPEN_FLAGS_NOINHERIT) != NO_ERROR)
        {
          msg (MSG_ERROR, "can't set file inheritance");
          goto Error;
        }

      /* Launch the command. */
      if ((pid = RunCommand (command)) < 0)
        {
          msg (MSG_ERROR, "can't spawn");
          goto Error;
        }

      /* Restore standard file handles for the PARENT PROCESS. */
      RestoreStdIOHandles (save_io);

      /*
       * Close the write end of the pipe; the read end becomes 
       * 'readfd'.
       */
      DosClose (w_pipe);
      w_pipe = NULLHANDLE;
      readfd = r_pipe;

      /* We don't need the command string any more. */
      free (command);
    }
  else /* writing but not reading */
    {
      /* close the writefd */
      close (writefd);
      writefd = -1;
    }

  return ElvTrue;

DupError:
  msg (MSG_ERROR, "can't dup file handle");

Error:
  /* Restore standard I/O handles if necessary. */
  RestoreStdIOHandles (save_io);
  return ElvFalse;
}
示例#19
0
文件: hbproces.c 项目: alcz/harbour
HB_FHANDLE hb_fsProcessOpen( const char * pszFileName,
                             HB_FHANDLE * phStdin, HB_FHANDLE * phStdout,
                             HB_FHANDLE * phStderr,
                             HB_BOOL fDetach, HB_ULONG * pulPID )
{
   HB_FHANDLE hPipeIn [ 2 ] = { FS_ERROR, FS_ERROR },
              hPipeOut[ 2 ] = { FS_ERROR, FS_ERROR },
              hPipeErr[ 2 ] = { FS_ERROR, FS_ERROR };
   HB_FHANDLE hResult = FS_ERROR;
   HB_BOOL fError = HB_FALSE;

   HB_TRACE( HB_TR_DEBUG, ( "hb_fsProcessOpen(%s, %p, %p, %p, %d, %p)", pszFileName, ( void * ) phStdin, ( void * ) phStdout, ( void * ) phStderr, fDetach, ( void * ) pulPID ) );

   if( phStdin != NULL )
      fError = ! hb_fsPipeCreate( hPipeIn );
   if( ! fError && phStdout != NULL )
      fError = ! hb_fsPipeCreate( hPipeOut );
   if( ! fError && phStderr != NULL )
   {
      if( phStdout == phStderr )
      {
         hPipeErr[ 0 ] = hPipeOut[ 0 ];
         hPipeErr[ 1 ] = hPipeOut[ 1 ];
      }
      else
         fError = ! hb_fsPipeCreate( hPipeErr );
   }

   if( ! fError )
   {
#if defined( HB_OS_WIN )

      PROCESS_INFORMATION pi;
      STARTUPINFO si;
      DWORD dwFlags = 0;
      LPTSTR lpCommand = HB_CHARDUP( pszFileName );

#  if ! defined( HB_OS_WIN_CE )
      if( phStdin != NULL )
         SetHandleInformation( ( HANDLE ) hb_fsGetOsHandle( hPipeIn [ 1 ] ), HANDLE_FLAG_INHERIT, 0 );
      if( phStdout != NULL )
         SetHandleInformation( ( HANDLE ) hb_fsGetOsHandle( hPipeOut[ 0 ] ), HANDLE_FLAG_INHERIT, 0 );
      if( phStderr != NULL && phStdout != phStderr )
         SetHandleInformation( ( HANDLE ) hb_fsGetOsHandle( hPipeErr[ 0 ] ), HANDLE_FLAG_INHERIT, 0 );
#  endif

      memset( &pi, 0, sizeof( pi ) );
      memset( &si, 0, sizeof( si ) );
      si.cb = sizeof( si );
#  ifdef STARTF_USESTDHANDLES
      si.dwFlags = STARTF_USESTDHANDLES;
#  endif
      if( fDetach )
      {
#  ifdef STARTF_USESHOWWINDOW
         si.dwFlags |= STARTF_USESHOWWINDOW;
#  endif
         si.wShowWindow = SW_HIDE;
         si.hStdInput  = ( HANDLE ) hb_fsGetOsHandle( hPipeIn [ 0 ] );
         si.hStdOutput = ( HANDLE ) hb_fsGetOsHandle( hPipeOut[ 1 ] );
         si.hStdError  = ( HANDLE ) hb_fsGetOsHandle( hPipeErr[ 1 ] );
#  ifdef DETACHED_PROCESS
         dwFlags |= DETACHED_PROCESS;
#  endif
      }
      else
      {
         si.hStdInput  = phStdin  ? ( HANDLE ) hb_fsGetOsHandle( hPipeIn [ 0 ] ) : GetStdHandle( STD_INPUT_HANDLE );
         si.hStdOutput = phStdout ? ( HANDLE ) hb_fsGetOsHandle( hPipeOut[ 1 ] ) : GetStdHandle( STD_OUTPUT_HANDLE );
         si.hStdError  = phStderr ? ( HANDLE ) hb_fsGetOsHandle( hPipeErr[ 1 ] ) : GetStdHandle( STD_ERROR_HANDLE );
      }
      fError = ! CreateProcess( NULL,           /* lpAppName */
                                lpCommand,
                                NULL,           /* lpProcessAttr */
                                NULL,           /* lpThreadAttr */
                                TRUE,           /* bInheritHandles */
                                dwFlags,        /* dwCreationFlags */
                                NULL,           /* lpEnvironment */
                                NULL,           /* lpCurrentDirectory */
                                &si,
                                &pi );
      hb_fsSetIOError( ! fError, 0 );
      hb_xfree( lpCommand );
      if( ! fError )
      {
         if( phStdin != NULL )
         {
            *phStdin = ( HB_FHANDLE ) hPipeIn[ 1 ];
            hPipeIn[ 1 ] = FS_ERROR;
         }
         if( phStdout != NULL )
         {
            *phStdout = ( HB_FHANDLE ) hPipeOut[ 0 ];
            hPipeOut[ 0 ] = FS_ERROR;
         }
         if( phStderr != NULL )
         {
            *phStderr = ( HB_FHANDLE ) hPipeErr[ 0 ];
            hPipeErr[ 0 ] = FS_ERROR;
         }
         if( pulPID )
            *pulPID = pi.dwProcessId;
         CloseHandle( pi.hThread );
         hResult = ( HB_FHANDLE ) pi.hProcess;
      }

#elif defined( HB_OS_OS2 )

      HFILE hNull = ( HFILE ) FS_ERROR;
      ULONG ulState = 0;
      APIRET ret = NO_ERROR;
      PID pid = ( PID ) -1;
      PHB_GT pGT;

      if( fDetach && ( ! phStdin || ! phStdout || ! phStderr ) )
      {
         HB_FHANDLE hFile;

         ret = hb_fsOS2DosOpen( "NUL:", &hFile, &ulState, 0,
                                FILE_NORMAL, OPEN_ACCESS_READWRITE,
                                OPEN_ACTION_OPEN_IF_EXISTS );
         if( ret == NO_ERROR )
            hNull = ( HFILE ) hFile;
      }

      if( ret == NO_ERROR && phStdin != NULL )
      {
         ret = DosQueryFHState( hPipeIn[ 1 ], &ulState );
         if( ret == NO_ERROR && ( ulState & OPEN_FLAGS_NOINHERIT ) == 0 )
            ret = DosSetFHState( hPipeIn[ 1 ], ( ulState & 0xFF00 ) | OPEN_FLAGS_NOINHERIT );
      }
      if( ret == NO_ERROR && phStdout != NULL )
      {
         ret = DosQueryFHState( hPipeOut[ 0 ], &ulState );
         if( ret == NO_ERROR && ( ulState & OPEN_FLAGS_NOINHERIT ) == 0 )
            ret = DosSetFHState( hPipeOut[ 0 ], ( ulState & 0xFF00 ) | OPEN_FLAGS_NOINHERIT );
      }
      if( ret == NO_ERROR && phStderr != NULL && phStdout != phStderr )
      {
         ret = DosQueryFHState( hPipeErr[ 0 ], &ulState );
         if( ret == NO_ERROR && ( ulState & OPEN_FLAGS_NOINHERIT ) == 0 )
            ret = DosSetFHState( hPipeErr[ 0 ], ( ulState & 0xFF00 ) | OPEN_FLAGS_NOINHERIT );
      }

      if( ret == NO_ERROR && ( pGT = hb_gt_Base() ) != NULL )
      {
         ULONG ulStateIn, ulStateOut, ulStateErr;
         HFILE hStdIn, hStdErr, hStdOut, hDup;

         ulStateIn = ulStateOut = ulStateErr = OPEN_FLAGS_NOINHERIT;
         hStdIn  = hStdErr = hStdOut = ( HFILE ) FS_ERROR;

         if( ret == NO_ERROR && ( phStdin != NULL || fDetach ) )
         {
            hDup = 0;
            ret = DosDupHandle( hDup, &hStdIn );
            if( ret == NO_ERROR )
            {
               ret = DosQueryFHState( hStdIn, &ulStateIn );
               if( ret == NO_ERROR && ( ulStateIn & OPEN_FLAGS_NOINHERIT ) == 0 )
                  ret = DosSetFHState( hStdIn, ( ulStateIn & 0xFF00 ) | OPEN_FLAGS_NOINHERIT );
               if( ret == NO_ERROR )
                  ret = DosDupHandle( phStdin != NULL ? ( HFILE ) hPipeIn[ 0 ] : hNull, &hDup );
            }
         }

         if( ret == NO_ERROR && ( phStdout != NULL || fDetach ) )
         {
            hDup = 1;
            ret = DosDupHandle( hDup, &hStdOut );
            if( ret == NO_ERROR )
            {
               ret = DosQueryFHState( hStdOut, &ulStateOut );
               if( ret == NO_ERROR && ( ulStateOut & OPEN_FLAGS_NOINHERIT ) == 0 )
                  ret = DosSetFHState( hStdOut, ( ulStateOut & 0xFF00 ) | OPEN_FLAGS_NOINHERIT );
               if( ret == NO_ERROR )
                  ret = DosDupHandle( phStdout != NULL ? ( HFILE ) hPipeOut[ 1 ] : hNull, &hDup );
            }
         }

         if( ret == NO_ERROR && ( phStderr != NULL || fDetach ) )
         {
            hDup = 2;
            ret = DosDupHandle( hDup, &hStdErr );
            if( ret == NO_ERROR )
            {
               ret = DosQueryFHState( hStdErr, &ulStateErr );
               if( ret == NO_ERROR && ( ulStateErr & OPEN_FLAGS_NOINHERIT ) == 0 )
                  ret = DosSetFHState( hStdErr, ( ulStateErr & 0xFF00 ) | OPEN_FLAGS_NOINHERIT );
               if( ret == NO_ERROR )
                  ret = DosDupHandle( phStderr != NULL ? ( HFILE ) hPipeErr[ 1 ] : hNull, &hDup );
            }
         }

         if( ret == NO_ERROR )
         {
            char * pArgs = hb_buildArgsOS2( pszFileName, &ret );
            char uchLoadError[ CCHMAXPATH ] = { 0 };
            RESULTCODES ChildRC = { 0, 0 };

            if( pArgs )
            {
               ret = DosExecPgm( uchLoadError, sizeof( uchLoadError ),
                                 fDetach ? EXEC_BACKGROUND : EXEC_ASYNCRESULT,
                                 ( PCSZ ) pArgs, NULL /* env */,
                                 &ChildRC,
                                 ( PCSZ ) pArgs );
               if( ret == NO_ERROR )
                  pid = ChildRC.codeTerminate;
               hb_freeArgsOS2( pArgs );
            }
         }

         if( hNull != ( HFILE ) FS_ERROR )
            DosClose( hNull );

         if( hStdIn != ( HFILE ) FS_ERROR )
         {
            hDup = 0;
            DosDupHandle( hStdIn, &hDup );
            DosClose( hStdIn );
            if( ( ulStateIn & OPEN_FLAGS_NOINHERIT ) == 0 )
               DosSetFHState( hDup, ulStateIn & 0xFF00 );
         }
         if( hStdOut != ( HFILE ) FS_ERROR )
         {
            hDup = 1;
            DosDupHandle( hStdOut, &hDup );
            DosClose( hStdOut );
            if( ( ulStateOut & OPEN_FLAGS_NOINHERIT ) == 0 )
               DosSetFHState( hDup, ulStateOut & 0xFF00 );
         }
         if( hStdErr != ( HFILE ) FS_ERROR )
         {
            hDup = 2;
            DosDupHandle( hStdErr, &hDup );
            DosClose( hStdErr );
            if( ( ulStateErr & OPEN_FLAGS_NOINHERIT ) == 0 )
               DosSetFHState( hDup, ulStateErr & 0xFF00 );
         }

         hb_gt_BaseFree( pGT );
      }
      else
      {
         if( hNull != ( HFILE ) FS_ERROR )
            DosClose( hNull );
         if( ret == NO_ERROR )
            ret = ( APIRET ) FS_ERROR;
      }

      fError = ret != NO_ERROR;
      if( ! fError )
      {
         if( phStdin != NULL )
         {
            *phStdin = ( HB_FHANDLE ) hPipeIn[ 1 ];
            hPipeIn[ 1 ] = FS_ERROR;
         }
         if( phStdout != NULL )
         {
            *phStdout = ( HB_FHANDLE ) hPipeOut[ 0 ];
            hPipeOut[ 0 ] = FS_ERROR;
         }
         if( phStderr != NULL )
         {
            *phStderr = ( HB_FHANDLE ) hPipeErr[ 0 ];
            hPipeErr[ 0 ] = FS_ERROR;
         }
         if( pulPID )
            *pulPID = pid;
         hResult = ( HB_FHANDLE ) pid;
      }

      hb_fsSetError( ( HB_ERRCODE ) ret );

#elif defined( HB_OS_UNIX ) && \
      ! defined( HB_OS_VXWORKS ) && ! defined( HB_OS_SYMBIAN )

      char ** argv = hb_buildArgs( pszFileName );
      pid_t pid = fork();

      if( pid == -1 )
         fError = HB_TRUE;
      else if( pid != 0 )    /* parent process */
      {
         if( phStdin != NULL )
         {
            *phStdin = ( HB_FHANDLE ) hPipeIn[ 1 ];
            hPipeIn[ 1 ] = FS_ERROR;
         }
         if( phStdout != NULL )
         {
            *phStdout = ( HB_FHANDLE ) hPipeOut[ 0 ];
            hPipeOut[ 0 ] = FS_ERROR;
         }
         if( phStderr != NULL )
         {
            *phStderr = ( HB_FHANDLE ) hPipeErr[ 0 ];
            hPipeErr[ 0 ] = FS_ERROR;
         }
         if( pulPID )
            *pulPID = pid;
         hResult = ( HB_FHANDLE ) pid;
      }
      else                    /* child process */
      {
         if( fDetach && ( ! phStdin || ! phStdout || ! phStderr ) )
         {
            HB_FHANDLE hNull = open( "/dev/null", O_RDWR );

            if( ! phStdin )
               dup2( hNull, 0 );
            if( ! phStdout )
               dup2( hNull, 1 );
            if( ! phStderr )
               dup2( hNull, 2 );

            if( hNull != FS_ERROR )
               hb_fsClose( hNull );
         }

         if( phStdin != NULL )
         {
            dup2( hPipeIn[ 0 ], 0 );
            hb_fsClose( hPipeIn[ 1 ] );
         }
         if( phStdout != NULL )
         {
            dup2( hPipeOut[ 1 ], 1 );
            hb_fsClose( hPipeOut[ 0 ] );
         }
         if( phStderr != NULL )
         {
            dup2( hPipeErr[ 1 ], 2 );
            if( phStdout != phStderr )
               hb_fsClose( hPipeErr[ 0 ] );
         }

         /* close all non std* handles */
         {
            int iMaxFD, i;
            iMaxFD = sysconf( _SC_OPEN_MAX );
            if( iMaxFD < 3 )
               iMaxFD = 1024;
            for( i = 3; i < iMaxFD; ++i )
               hb_fsClose( i );
         }

         /* reset extended process attributes */
         if( setuid( getuid() ) == -1 ) {}
         if( setgid( getgid() ) == -1 ) {}

         /* execute command */
         {
#  if defined( __WATCOMC__ )
            execvp( argv[ 0 ], ( const char ** ) argv );
#  else
            execvp( argv[ 0 ], argv );
#  endif
            exit( -1 );
         }
      }
      hb_fsSetIOError( ! fError, 0 );

      hb_freeArgs( argv );

#elif defined( HB_OS_OS2 ) || defined( HB_OS_WIN )

      int hStdIn, hStdOut, hStdErr;
      char ** argv;
      int pid;

      hStdIn  = dup( 0 );
      hStdOut = dup( 1 );
      hStdErr = dup( 2 );

      if( fDetach && ( ! phStdin || ! phStdout || ! phStderr ) )
      {
         HB_FHANDLE hNull = open( "NUL:", O_RDWR );

         if( ! phStdin )
            dup2( hNull, 0 );
         if( ! phStdout )
            dup2( hNull, 1 );
         if( ! phStderr )
            dup2( hNull, 2 );

         if( hNull != FS_ERROR )
            close( hNull );
      }

      if( phStdin != NULL )
         dup2( hPipeIn[ 0 ], 0 );
      if( phStdout != NULL )
         dup2( hPipeOut[ 1 ], 1 );
      if( phStderr != NULL )
         dup2( hPipeErr[ 1 ], 2 );

      argv = hb_buildArgs( pszFileName );

#if defined( _MSC_VER ) || defined( __LCC__ ) || \
    defined( __XCC__ ) || defined( __POCC__ )
      pid = _spawnvp( _P_NOWAIT, argv[ 0 ], argv );
#elif defined( __MINGW32__ ) || defined( __WATCOMC__ )
      pid = spawnvp( P_NOWAIT, argv[ 0 ], ( const char * const * ) argv );
#else
      pid = spawnvp( P_NOWAIT, argv[ 0 ], ( char * const * ) argv );
#endif
      hb_freeArgs( argv );

      dup2( hStdIn,  0 );
      close( hStdIn );

      dup2( hStdOut, 1 );
      close( hStdOut );

      dup2( hStdErr, 2 );
      close( hStdErr );

      if( pid < 0 )
         fError = HB_TRUE;
      else if( pid != 0 )    /* parent process */
      {
         if( phStdin != NULL )
         {
            *phStdin = ( HB_FHANDLE ) hPipeIn[ 1 ];
            hPipeIn[ 1 ] = FS_ERROR;
         }
         if( phStdout != NULL )
         {
            *phStdout = ( HB_FHANDLE ) hPipeOut[ 0 ];
            hPipeOut[ 0 ] = FS_ERROR;
         }
         if( phStderr != NULL )
         {
            *phStderr = ( HB_FHANDLE ) hPipeErr[ 0 ];
            hPipeErr[ 0 ] = FS_ERROR;
         }
         if( pulPID )
            *pulPID = pid;
         hResult = ( HB_FHANDLE ) pid;
      }

      hb_fsSetIOError( ! fError, 0 );

#else
      int iTODO; /* TODO: for given platform */

      HB_SYMBOL_UNUSED( pszFileName );
      HB_SYMBOL_UNUSED( fDetach );
      HB_SYMBOL_UNUSED( pulPID );

      hb_fsSetError( ( HB_ERRCODE ) FS_ERROR );
#endif
   }

   if( hPipeIn[ 0 ] != FS_ERROR )
      hb_fsCloseRaw( hPipeIn[ 0 ] );
   if( hPipeIn[ 1 ] != FS_ERROR )
      hb_fsCloseRaw( hPipeIn[ 1 ] );
   if( hPipeOut[ 0 ] != FS_ERROR )
      hb_fsCloseRaw( hPipeOut[ 0 ] );
   if( hPipeOut[ 1 ] != FS_ERROR )
      hb_fsCloseRaw( hPipeOut[ 1 ] );
   if( phStdout != phStderr )
   {
      if( hPipeErr[ 0 ] != FS_ERROR )
         hb_fsCloseRaw( hPipeErr[ 0 ] );
      if( hPipeErr[ 1 ] != FS_ERROR )
         hb_fsCloseRaw( hPipeErr[ 1 ] );
   }

   return hResult;
}
示例#20
0
文件: specific.c 项目: etix/vlc
void system_Configure( libvlc_int_t *p_this, int i_argc, const char *const ppsz_argv[] )
{
    if( var_InheritBool( p_this, "high-priority" ) )
    {
        if( !DosSetPriority( PRTYS_PROCESS, PRTYC_REGULAR, PRTYD_MAXIMUM, 0 ) )
        {
            msg_Dbg( p_this, "raised process priority" );
        }
        else
        {
            msg_Dbg( p_this, "could not raise process priority" );
        }
    }

    if( var_InheritBool( p_this, "one-instance" )
        || ( var_InheritBool( p_this, "one-instance-when-started-from-file" )
             && var_InheritBool( p_this, "started-from-file" ) ) )
    {
        HPIPE hpipe;
        ULONG ulAction;
        ULONG rc;

        msg_Info( p_this, "one instance mode ENABLED");

        /* Use a named pipe to check if another instance is already running */
        for(;;)
        {
            rc = DosOpen( VLC_IPC_PIPE, &hpipe, &ulAction, 0, 0,
                          OPEN_ACTION_OPEN_IF_EXISTS,
                          OPEN_ACCESS_READWRITE | OPEN_SHARE_DENYREADWRITE |
                          OPEN_FLAGS_FAIL_ON_ERROR,
                          NULL );

            if( rc == ERROR_PIPE_BUSY )
                DosWaitNPipe( VLC_IPC_PIPE, -1 );
            else
                break;
        }

        if( rc )
        {
            rc = DosCreateNPipe( VLC_IPC_PIPE,  &hpipeIPC,
                                 NP_ACCESS_DUPLEX,
                                 NP_WAIT | NP_TYPE_MESSAGE |
                                 NP_READMODE_MESSAGE | 0x01,
                                 32768, 32768, 0 );
            if( rc )
            {
                /* Failed to create a named pipe. Just ignore the option and
                 * go on as normal. */
                msg_Err( p_this, "one instance mode DISABLED "
                         "(a named pipe couldn't be created)" );
                return;
            }

            /* We are the 1st instance. */

            /* Save the tid of the first instance */
            tidIPCFirst = _gettid();

            /* Run the helper thread */
            tidIPCHelper = _beginthread( IPCHelperThread, NULL, 1024 * 1024,
                                         p_this );
            if( tidIPCHelper == -1 )
            {
                msg_Err( p_this, "one instance mode DISABLED "
                         "(IPC helper thread couldn't be created)");

                tidIPCFirst = -1;
            }
        }
        else
        {
            /* Another instance is running */
            ULONG ulCmd = var_InheritBool( p_this, "playlist-enqueue") ?
                              IPC_CMD_ENQUEUE : IPC_CMD_GO;
            ULONG cbActual;

            /* Write a command */
            DosWrite( hpipe, &ulCmd, sizeof( ulCmd ), &cbActual );

            /* We assume that the remaining parameters are filenames
             * and their input options */

            /* Write a count of arguments */
            DosWrite( hpipe, &i_argc, sizeof( i_argc ), &cbActual );

            for( int i_opt = 0; i_opt < i_argc; i_opt++ )
            {
                /* We need to resolve relative paths in this instance */
                char *mrl;
                if( strstr( ppsz_argv[ i_opt ], "://" ))
                    mrl = strdup( ppsz_argv[ i_opt ] );
                else
                    mrl = vlc_path2uri( ppsz_argv[ i_opt ], NULL );

                if( !mrl )
                    mrl = ( char * )ppsz_argv[ i_opt ];

                size_t i_len = strlen( mrl ) + 1;

                /* Write a length of an argument */
                DosWrite( hpipe, &i_len, sizeof( i_len ), &cbActual );

                /* Write an argument */
                DosWrite( hpipe, mrl, i_len, &cbActual );

                if( mrl != ppsz_argv[ i_opt ])
                    free( mrl );
            }

            /* Close a named pipe of a client side */
            DosClose( hpipe );

            /* Bye bye */
            system_End();
            exit( 0 );
        }
    }
}
示例#21
0
文件: MAIN.C 项目: jskripsky/ancient
VOID _cdecl Main( WORD NumArgs, CHAR *Args[], CHAR *EnvStrings[] )
    {
    MSG     Msg;
    WORD    Key;

    CHAR FileName[65];
    CHAR PrinterPort[65];

    HFILE TMSBegrFile;
    HFILE TMSAbtFile;
    HFILE TMSZKontFile;

    DWORD EffTime;

    WinInitialize( MAXNUMWINDOWS );
    WinCreateWindow( Desktop, &Desktop, NULL, 0, 0, 0, 0, 0, 0 );

    WinHideCursor();
    WinColor( Desktop, NORMAL, 0, 0, WinGetx2( Desktop ), WinGety2( Desktop ) );

    WinCreateWindow( Desktop, &Bottomline, BottomlineProc, 0, 0, BOTTOMLINEX1, BOTTOMLINEY1, BOTTOMLINEX2, BOTTOMLINEY2 );

    if( !ReadConfigData() )
	{
	static struct HelpKey HelpKeys[NUMLAUFWERKHELPKEYS] =
	    { {	0,   0, "</>    Wert erh�hen/erniedrigen" },
	      { 0,   1, "<Enter>  Wert akzeptieren" },
	      { 40,  1, "<Esc>    Programm verlassen" } };

	HWND TMSLaufwerk;
	BOOL LaufwerkOK;

	WinFill( Desktop, '�',	0, 22, 79, 22 );
	InitConfigData();

	WinString( Desktop, "TMS Laufwerk", CENTER, 0, 7 );
	WinString( Desktop, "������������", CENTER, 0, 8 );
	WinColor( Desktop, HIGHLIGHT, 33, 7, 46, 7 );
	WinCreateWindow( Desktop, &TMSLaufwerk, TMSLaufWerkProc, 0, 0, 37, 10, 40, 10 );
	WinString( Desktop, "Geben Sie bitte an, in welchem Laufwerk sich TMS befindet.", CENTER, 0, 14 );

	WinSendMsg( Bottomline, WM_HELP, (WORD)&HelpKeys, NUMLAUFWERKHELPKEYS );

	WinSendMsg( TMSLaufwerk, WM_SHOW, 0, 0 );
	WinSendMsg( TMSLaufwerk, WM_SETFOCUS, 0, 0 );

	do
	    {
	    LaufwerkOK = TRUE;
	    do
		{
		Key = BiosGetKey();
		Msg = WinSendMsg( TMSLaufwerk, WM_CHAR, (MPARAM)Key, 0 );
		}
	    while( (WORD)Msg != KBENTER && (WORD)Msg != KBESC );

	    if( (WORD)Msg == KBESC )
		{
		DosFreeFarMem( ConfigData );

		WinDestroyWindow( TMSLaufwerk );
		WinDestroyWindow( Bottomline );
		WinDestroyWindow( Desktop );
		return;
		}

	    if( !OpenPathFile() )
		{
		LaufwerkOK = FALSE;
		}
	    }
	while( !LaufwerkOK );

	ClosePathFile();
	WinDestroyWindow( TMSLaufwerk );
	WinColor( Desktop, NORMAL, 0, 0, WinGetx2( Desktop ), 21 );
	WinFill( Desktop, SPACECHAR, 0, 0, WinGetx2( Desktop ), WinGety2( Desktop ) );
	}

    switch( NumArgs )
	{
	case 2:
	    StdStrLwr( Args[1] );
	    if( StdStrCmp( Args[1], "exportfile" ) == 0 ||
		StdStrCmp( Args[1], "export" ) == 0 )
		{
		WinFill( Desktop, '�',	0, 22, 79, 22 );
		ExportFileConversion();
		}
	    else
		{
		; // Debug!!!!
		}
	    break;

	case 1:
	    if( !OpenPathFile() )
		; // Debug!!!!!

	    ReadPathFileEntry( TMSBEGRUENDNO, FileName, FALSE );

	    DosOpen( FileName, &TMSBegrFile, OPEN_RDONLY );
	    DosLastModTime( TMSBegrFile, &EffTime );
	    if( ConfigData->TMSBegruendungsDatum != EffTime )
		{
		if( !CreateList( TMSBegrFile, BEGRUENDUNGEN ) )
		    {
		    WinString( Desktop, "In TMS sind 0 Begr�ndungen verzeichnet!", LEFT, 0, 0 );
		    return; // Debug-Version!!!!!
		    }

		SortList( BEGRUENDUNGEN );
		ConfigData->TMSBegruendungsDatum = EffTime;
		StdFarMemSet( ConfigData->BegrCheckListe, TRUE, sizeof( ConfigData->BegrCheckListe ) );
		}
	    DosClose( TMSBegrFile );

	    ReadPathFileEntry( TMSABTEILNO, FileName, FALSE );

	    DosOpen( FileName, &TMSAbtFile, OPEN_RDONLY );
	    DosLastModTime( TMSAbtFile, &EffTime );
	    if( ConfigData->TMSAbteilungsDatum != EffTime )
		{
		if( !CreateList( TMSAbtFile, ABTEILUNGEN ) )
		    {
		    WinString( Desktop, "In TMS sind 0 Abteilungen verzeichnet!", LEFT, 0, 0 );
		    return; // Debug-Version!!!!!
		    }
		SortList( ABTEILUNGEN );
		ConfigData->TMSAbteilungsDatum = EffTime;
		StdFarMemSet( ConfigData->AbtCheckListe, TRUE, sizeof( ConfigData->AbtCheckListe ) );
		}
	    DosClose( TMSAbtFile );

	    ReadPathFileEntry( TMSZEITKNO, FileName, FALSE );

	    DosOpen( FileName, &TMSZKontFile, OPEN_RDONLY );
	    DosLastModTime( TMSZKontFile, &EffTime );
	    if( ConfigData->TMSZeitKontiDatum != EffTime )
		{
		if( !CreateList( TMSZKontFile, ZEITKONTI ) )
		    {
		    WinString( Desktop, "In TMS sind 0 Zeitkonti verzeichnet!", LEFT, 0, 0 );
		    return; // Debug-Version!!!!!
		    }
		// SortList( ZEITKONTI );
		ConfigData->TMSZeitKontiDatum = EffTime;
		StdFarMemSet( ConfigData->ZKontCheckListe, TRUE, sizeof( ConfigData->ZKontCheckListe ) );
		}
	    DosClose( TMSZKontFile );

	    ReadPathFileEntry( TMSPRINTERINFONO, FileName, FALSE );
	    ReadPathFileEntry( TMSPRINTERPORTNO, PrinterPort, TRUE );
	    GetPrinterInfo( FileName, PrinterPort );

	    ClosePathFile();

	    LoadList( BEGRUENDUNGEN );
	    LoadList( ABTEILUNGEN );
	    LoadList( ZEITKONTI );

	    WinString( Desktop, "������������������������������������Ŀ", CENTER, 0,  3 );
	    WinString( Desktop, "�                                    �", CENTER, 0,  4 );
	    WinString( Desktop, "�      Statistik - Generierung       �", CENTER, 0,  5 );
	    WinString( Desktop, "�      �����������������������       �", CENTER, 0,  6 );
	    WinString( Desktop, "�                und                 �", CENTER, 0,  7 );
	    WinString( Desktop, "�                ���                 �", CENTER, 0,  8 );
	    WinString( Desktop, "�     Verwaltung der Exportdaten     �", CENTER, 0,  9 );
	    WinString( Desktop, "�     ��������������������������     �", CENTER, 0, 10 );
	    WinString( Desktop, "�                                    �", CENTER, 0, 11 );
	    WinString( Desktop, "�              von TMS               �", CENTER, 0, 12 );
	    WinString( Desktop, "�                                    �", CENTER, 0, 13 );
	    WinString( Desktop, "��������������������������������������", CENTER, 0, 14 );

	    WinString( Desktop, " (c) Copyright 1992, 1993 J.Skripsky  ", CENTER, 0, 16 );

	    WinString( Desktop, "      Designed and Developed by       ", CENTER, 0, 18 );
	    WinString( Desktop, "           Juraj Skripsky             ", CENTER, 0, 19 );
	    WinString( Desktop, "         CH-8952 Schlieren            ", CENTER, 0, 20 );

	    BiosGetKey();
	    WinFill( Desktop, SPACECHAR, 0, 0, WinGetx2( Desktop ), WinGety2( Desktop ) );

	    WinFill( Desktop, '�', 0, 22, 79, 22 );

	    WinFill( Desktop, '�', 27,	0, 27, 21 );
	    WinFill( Desktop, '�',  0, 22, 79, 22 );
	    WinCreateWindow( Desktop, &Menu, MenuProc, 0, 0, 1, 1, 25, 20 );

	    WinSendMsg( Menu, WM_SHOW, 0, 0 );
	    WinSendMsg( Menu, WM_SETFOCUS, 0, 0 );

	    do
		{
		Key = BiosGetKey();
		Msg = WinSendMsg( Menu, WM_CHAR, (MPARAM)Key, 0 );
		}
	    while( (WORD)Msg != KBESC );


	    FreeList( BEGRUENDUNGEN );
	    FreeList( ABTEILUNGEN );
	    FreeList( ZEITKONTI );

	    FreePrinterInfo();

	    WinDestroyWindow( Menu );
	    break;
	 }

    if( !WriteConfigData() )
	; // Debug!!!!!

    WinDestroyWindow( Bottomline );
    WinDestroyWindow( Desktop );
    WinTerminate();
    }
示例#22
0
文件: specific.c 项目: etix/vlc
static void IPCHelperThread( void *arg )
{
    libvlc_int_t *libvlc = arg;

    ULONG  ulCmd;
    int    i_argc;
    char **ppsz_argv;
    size_t i_len;
    ULONG  cbActual;
    int    i_options;

    /* Add files to the playlist */
    playlist_t *p_playlist;

    do
    {
        DosConnectNPipe( hpipeIPC );

        /* Read command */
        DosRead( hpipeIPC, &ulCmd, sizeof( ulCmd ), &cbActual );
        if( ulCmd == IPC_CMD_QUIT )
            continue;

        /* Read a count of arguments */
        DosRead( hpipeIPC, &i_argc, sizeof( i_argc ), &cbActual );

        ppsz_argv = malloc( i_argc * sizeof( *ppsz_argv ));

        for( int i_opt = 0; i_opt < i_argc; i_opt++ )
        {
            /* Read a length of argv */
            DosRead( hpipeIPC, &i_len, sizeof( i_len ), &cbActual );

            ppsz_argv[ i_opt ] = malloc( i_len );

            /* Read argv */
            DosRead( hpipeIPC, ppsz_argv[ i_opt ], i_len, &cbActual );
        }

        p_playlist = libvlc_priv(libvlc)->playlist;

        for( int i_opt = 0; i_opt < i_argc;)
        {
            i_options = 0;

            /* Count the input options */
            while( i_opt + i_options + 1 < i_argc &&
                   *ppsz_argv[ i_opt + i_options + 1 ] == ':' )
                i_options++;


            if( p_playlist )
            {
                playlist_AddExt( p_playlist, ppsz_argv[ i_opt ], NULL,
                                 (( i_opt || ulCmd == IPC_CMD_ENQUEUE ) ?
                                     0 : PLAYLIST_GO ),
                                 i_options,
                                 ( char const ** )
                                     ( i_options ? &ppsz_argv[ i_opt + 1 ] :
                                                   NULL ),
                                 VLC_INPUT_OPTION_TRUSTED,
                                 true );
            }

            for( ; i_options >= 0; i_options-- )
                free( ppsz_argv[ i_opt++ ]);
        }

        free( ppsz_argv );
    } while( !DosDisConnectNPipe( hpipeIPC ) && ulCmd != IPC_CMD_QUIT );

    DosClose( hpipeIPC );
    hpipeIPC = NULLHANDLE;

    tidIPCFirst  = -1;
    tidIPCHelper = -1;
}
示例#23
0
bool CDROM_Interface_Ioctl::ReadSectors(PhysPt buffer, bool raw, unsigned long sector, unsigned long num){
    HFILE cdrom_fd = 0;
    ULONG ulAction = 0;
    APIRET rc = DosOpen((unsigned char*)device_name, &cdrom_fd, &ulAction, 0L, FILE_NORMAL, OPEN_ACTION_OPEN_IF_EXISTS,
            OPEN_FLAGS_DASD | OPEN_SHARE_DENYNONE | OPEN_ACCESS_READONLY, 0L);
    if (rc != NO_ERROR) {
        return false;
    }

    Bitu buflen = raw ? num * CD_FRAMESIZE_RAW : num * CD_FRAMESIZE;
    Bit8u* buf = new Bit8u[buflen];
    int ret = NO_ERROR;

    if (raw) {
    	struct paramseek {
       		UCHAR sig[4];
       		UCHAR mode;
      		ULONG sec;
       		
       		paramseek(ULONG sector)
       		{
       			sig[0] = 'C'; sig[1] = 'D'; sig[2] = '0'; sig[3] = '1';
       			sec = sector;
       		}
    	} param_seek(sector);
       	ULONG paramsize = sizeof (paramseek);
		rc = DosDevIOCtl(cdrom_fd, IOCTL_CDROMDISK, CDROMDISK_SEEK, &param_seek, paramsize, &paramsize,
                 0, 0, 0);
        if (rc != NO_ERROR) {
            return false;
        }

		struct paramread {
			UCHAR sig[4];
			UCHAR mode;
			USHORT number;
			BYTE sec;
       		BYTE reserved;
       		BYTE interleave;
       		
       		paramread(USHORT num)
       		{
       			sig[0] = 'C'; sig[1] = 'D'; sig[2] = '0'; sig[3] = '1';
       			mode = 0; number = num;
       			sec = interleave = 0;
       		}
       	} param_read(num);
       	paramsize = sizeof (paramread);
		ULONG len = buflen;
		rc = DosDevIOCtl(cdrom_fd, IOCTL_CDROMDISK, CDROMDISK_READLONG, &param_read, paramsize, &paramsize,
                 buf, len, &len);
        if (rc != NO_ERROR) {
            return false;
        }
    } else {
        ULONG pos = 0;
        rc = DosSetFilePtr(cdrom_fd, sector * CD_FRAMESIZE, FILE_BEGIN, &pos);
        if (rc != NO_ERROR) {
            return false;
        }
        ULONG read = 0;
        rc = DosRead(cdrom_fd, buf, buflen, &read);
        if (rc != NO_ERROR || read != buflen) {
            return false;
        }
    }
    rc = DosClose(cdrom_fd);
    MEM_BlockWrite(buffer, buf, buflen);
    delete[] buf;

    return (ret == NO_ERROR);
}
示例#24
0
  static  TT_Error  Stream_Activate( PStream_Rec  stream )
  {
    ULONG ulAction;  /* !Mike! */

    if ( !stream->opened )
    {
#if 0
    if ( !(stream->file = fopen( stream->name, "rb" )) )    /* !Mike! */
#endif

/* XXX : Strange.  GCC/EMX wants an (Byte*) for the file name? */
#ifdef __EMX__

      if ( DosOpen( (Byte*)stream->name, &(stream->file),
                    &ulAction, 0,
                    0, OPEN_ACTION_OPEN_IF_EXISTS,
                    OPEN_SHARE_DENYNONE | OPEN_ACCESS_READONLY, NULL ) )
        return TT_Err_Could_Not_ReOpen_File;

#else

      if ( DosOpen( stream->name, &(stream->file),
                    &ulAction, 0,
                    0, OPEN_ACTION_OPEN_IF_EXISTS,
                    OPEN_SHARE_DENYNONE | OPEN_ACCESS_READONLY, NULL ) )
        return TT_Err_Could_Not_ReOpen_File;

#endif /* __EMX__ */

      stream->opened = TRUE;

      /* A newly created stream has a size field of -1 */
      if ( stream->size < 0 )
      {
#if 0
        fseek( stream->file, 0, SEEK_END );             /* !Mike! */
        stream->size = ftell( stream->file );
#endif

        DosSetFilePtr( stream->file, 0, FILE_END, (ULONG *)&(stream->size) );
#if 0
        fseek( stream->file, 0, SEEK_SET );
#endif

        DosSetFilePtr( stream->file, 0, FILE_BEGIN, &ulAction );
      }

      /* Reset cursor in file */
      if ( stream->position )
      {
#if 0   /* !Mike! */
        if ( fseek( stream->file, stream->position, SEEK_SET ) != 0 )
#endif 

        if ( DosSetFilePtr( stream->file, stream->position,
                            FILE_BEGIN, &ulAction ) )
        {
          /* error during seek */
#if 0
          fclose( stream->file );           /* !Mike! */
#endif

          DosClose( stream->file );
          stream->opened = FALSE;
          return TT_Err_Could_Not_ReSeek_File;
        }
      }
    }
    return TT_Err_Ok;
  }
示例#25
0
static void close_mmap()
{
	if (mapdev != -1)
		DosClose(mapdev);
	mapdev = -1;
}
示例#26
0
SDL_bool
SDL_GetPowerInfo_OS2(SDL_PowerState * state, int *seconds, int *percent)
{
    PowerStatus status;
    HFILE hfile = 0;
    ULONG action = 0;
    APIRET rc = 0;

    *state = SDL_POWERSTATE_UNKNOWN;
    *percent = -1;
    *seconds = -1;

    /* open the power management device */
    rc = DosOpen("APM$", &hfile, &action, 0, FILE_NORMAL, FILE_OPEN,
                 OPEN_ACCESS_READONLY | OPEN_SHARE_DENYNONE, 0);

    if (rc == NO_ERROR) {
        USHORT iorc = 0;
        ULONG iorclen = sizeof(iorc);
        ULONG statuslen = sizeof(status);

        SDL_memset(&status, '\0', sizeof(status));
        status.len = sizeof(status);

        rc = DosDevIOCtl(hfile, IOCTL_POWER, POWER_GETPOWERSTATUS, &status,
                         statuslen, &statuslen, &iorc, iorclen, &iorclen);
        DosClose(hfile);

        /* (status.flags & 0x1) == power subsystem enabled. */
        if ((rc == NO_ERROR) && (status.flags & 0x1)) {
            if (statuslen == 7) {       /* older OS/2 APM driver? Less fields. */
                status.battery_time_form = 0xFF;
                status.battery_time = 0;
                if (status.battery_status == 0xFF) {
                    status.battery_flags = 0xFF;
                } else {
                    status.battery_flags = (1 << status.battery_status);
                }
            }

            if (status.battery_flags == 0xFF) { /* unknown state */
                *state = SDL_POWERSTATE_UNKNOWN;
            } else if (status.battery_flags & (1 << 7)) {       /* no battery */
                *state = SDL_POWERSTATE_NO_BATTERY;
            } else if (status.battery_flags & (1 << 3)) {       /* charging */
                *state = SDL_POWERSTATE_CHARGING;
                need_details = SDL_TRUE;
            } else if (status.ac_status == 1) {
                *state = SDL_POWERSTATE_CHARGED;        /* on AC, not charging. */
                need_details = SDL_TRUE;
            } else {
                *state = SDL_POWERSTATE_ON_BATTERY;     /* not on AC. */
                need_details = SDL_TRUE;
            }

            if (need_details) {
                const int pct = (int) status.battery_life;
                const int secs = (int) status.battery_time;

                if (pct != 0xFF) {      /* 255 == unknown */
                    *percent = (pct > 100) ? 100 : pct;
                }

                if (status.battery_time_form == 0xFF) { /* unknown */
                    *seconds = -1;
                } else if (status.battery_time_form == 1) {     /* minutes */
                    *seconds = secs * 60;
                } else {
                    *seconds = secs;
                }
            }
        }
    }

    return SDL_TRUE;            /* always the definitive answer on OS/2. */
}
示例#27
0
uint32_t    os2_get_file( CAMHandle hCam, CAMObjectInfoPtr pObjInfo,
                          uint32_t handle, char* filename, int replace,
                          int thumb)
{
    APIRET      rc = 0;
    uint32_t    rtn = 0;
    HFILE       hFile = 0;
    char *      pBuf = 0;
    char *      pMem = 0;
    char *      pMsg = 0;
    ULONG       ulSize;
    ULONG       ul;
    FILESTATUS3 fs3;
    struct tm * ptm;

do {
    if (!filename) {
        filename = pObjInfo->Filename;
        printf (" Saving %3d  (%s)... ", handle, filename);
    }
    else
        printf (" Saving %3d  (%s) as \"%s\"... ", handle, pObjInfo->Filename, filename);

    ulSize = (thumb ? pObjInfo->ThumbCompressedSize : pObjInfo->ObjectCompressedSize);
    if (ulSize == 0) {
        pMsg = "skipped - file size is zero\n";
        break;
    }

    rc = DosOpen( filename, &hFile, &ul, ulSize,
                  FILE_NORMAL, OPEN_ACTION_CREATE_IF_NEW | (replace ?
                  OPEN_ACTION_REPLACE_IF_EXISTS : OPEN_ACTION_FAIL_IF_EXISTS),
                  (OPEN_FLAGS_FAIL_ON_ERROR | OPEN_FLAGS_SEQUENTIAL |
                  OPEN_SHARE_DENYREADWRITE | OPEN_ACCESS_READWRITE), 0);
    if (rc) {
        if (rc == ERROR_OPEN_FAILED)
            pMsg = "skipped - file exists\n";
        break;
    }

    rc = DosAllocMem( (PVOID)&pMem, ulSize + 0x1000 - CAMCNR_DATASIZE,
                      PAG_COMMIT | OBJ_TILE | PAG_READ | PAG_WRITE);
    if (rc)
        break;

    // this trick eliminates 400 memcpy()s in UsbBulkRead() for a 2mb file;
    // after GetData() reads the first 500 bytes, the buffer it passes
    // to UsbBulkRead() will be page-aligned & can be used as-is
    pBuf = pMem + 0x1000 - CAMCNR_DATASIZE;

    if (thumb)
        rtn = GetThumb( hCam, handle, &pBuf);
    else
        rtn = GetObject( hCam, handle, &pBuf);
    if (rtn) {
        rc = (APIRET)rtn;
        break;
    }

    rc = DosWrite( hFile, pBuf, ulSize, &ul);
    if (rc)
        break;

    if (pObjInfo->CaptureDate == 0) {
        pMsg = "done\n";
        break;
    }

    pMsg = "done - unable to set timestamp\n";

    rc = DosQueryFileInfo( hFile, FIL_STANDARD, &fs3, sizeof(FILESTATUS3));
    if (rc)
        break;

    ptm = localtime( &pObjInfo->CaptureDate);
    if (!ptm)
        break;

    fs3.fdateCreation.year = ptm->tm_year - 80;
    fs3.fdateCreation.month = ptm->tm_mon + 1;
    fs3.fdateCreation.day = ptm->tm_mday;
    fs3.ftimeCreation.hours = ptm->tm_hour;
    fs3.ftimeCreation.minutes = ptm->tm_min;
    fs3.ftimeCreation.twosecs = ptm->tm_sec / 2;
    fs3.fdateLastWrite = fs3.fdateCreation;
    fs3.ftimeLastWrite = fs3.ftimeCreation;

    rc = DosSetFileInfo( hFile, FIL_STANDARD, &fs3, sizeof(FILESTATUS3));
    if (rc)
        break;

    pMsg = "done\n";

} while (0);

    if (pMem)
        DosFreeMem( pMem);

    if (hFile)
        DosClose( hFile);

    if (pMsg)
        printf( pMsg);
    else
        printf( "error - rc= %d\n", (int)rc);

    return rtn;
}
int main(int argc, char * argv[])
{
	int i;
	char cmdLine[CCHMAXPATH*4]={0};
	char cmdLineBuff[CCHMAXPATH*4];
	char * chrPtr;
	HWND hwndNotify;
	char exeName[CCHMAXPATH];//"g:\\projects_working\\audiocpy\\show.exe";
	char chrError[CCHMAXPATH];
	char logName[CCHMAXPATH];
	RESULTCODES resultCodes;
	ULONG rc,ulAction;
	HFILE hf,hfNew;

    if(argc<3) {
      message();
      exit(-1);
    }
	
    hwndNotify=atol(argv[1]);

	sprintf(exeName,"%s",argv[2]);
	sprintf(logName,"%s\\Logfiles\\write.log",argv[3]);
	
	sprintf(cmdLine,exeName);
	chrPtr=strrchr(cmdLine,0);
	chrPtr++;

	/* Build parameters */
    for(i=4;i<argc;i++) {
      sprintf(cmdLineBuff,"%s",chrPtr);
      sprintf(chrPtr,"%s %s",cmdLineBuff,argv[i]);
    }
    /* Replace ' with " */
    changeChar(chrPtr,'\'','\"');

    /* Replace ^ with space */
    changeChar(chrPtr,'^',' ');

	printf("HWND: %ld",hwndNotify);
	printf("\n");	
	printf("cdrecord-executable: %s",exeName);
	printf("\n");
	printf("Logname: %s\n",logName);
	printf("cdrecord parameter: %s",chrPtr);
	printf("\n");

	/* Redirect stderr */
    rc=DosOpen(logName,&hf,&ulAction,0,FILE_NORMAL,OPEN_ACTION_CREATE_IF_NEW|OPEN_ACTION_OPEN_IF_EXISTS,
               OPEN_ACCESS_WRITEONLY|OPEN_SHARE_DENYWRITE,0);
	if(!rc) {
		DosSetFilePtr(hf,0,FILE_END,&ulAction);
		hfNew=2;
		DosDupHandle(hf,&hfNew);
		
		sprintf(logName,"---------------------------------------------------------------------\n");
		write(2,logName,strlen(logName));

		sprintf(logName,"\n");
		write(2,logName,strlen(logName));	
        
		/*	time(&ltime);		
		sprintf(logName,"%s",ctime(&ltime));
		write(2,logName,strlen(logName));	
		sprintf(logName,"\n");
		write(2,logName,strlen(logName));	*/
    
		sprintf(logName,"Starting to write using %s\n",exeName);
		write(2,logName,strlen(logName));
		
		sprintf(logName,"with the following parameters: %s\n",chrPtr);
		write(2,logName,strlen(logName));
	}
	
	DosExecPgm(chrError,sizeof(chrError),EXEC_SYNC,cmdLine,0,&resultCodes,exeName);
	sprintf(logName,"Return code is: %ld\n ",resultCodes.codeResult);
	write(2,logName,strlen(logName));

    DosClose(hf);
    WinPostMsg(hwndNotify,WM_APPTERMINATENOTIFY,MPFROMLONG(ACKEY_WRITEONLY),MPFROMLONG(resultCodes.codeResult));
    return 0;
}
示例#29
0
static void _LNK_CONV PipeThread(void *p) {
  GPipe *pipe = (GPipe *)p;
  int    rc;
  ULONG  ulPostCount;
  ULONG  used;
  PID    pid;
  HPIPE  hfPipe;
  RESULTCODES rc_code;

  rc = CreatePipeChild(pid, hfPipe, pipe->Command);

  if (rc != 0) {
    // fprintf(stderr, "Failed createpipe");
    DosRequestMutexSem(pipe->Access, SEM_INDEFINITE_WAIT);
    pipe->reading = 0;
    DosPostEventSem(pipe->NewData);
    DosReleaseMutexSem(pipe->Access);
    return;
  }

  // fprintf(stderr, "Pipe: Begin: %d %s\n", pipe->id, Args);
  while (1) {
    // fprintf(stderr, "Waiting on pipe\n");
    // fread(pipe->buffer, 1, pipe->buflen, fp);
    rc = DosRead(hfPipe, pipe->buffer, pipe->buflen, &used);

    if (rc < 0) used = 0;

    DosRequestMutexSem(pipe->Access, SEM_INDEFINITE_WAIT);

    // fprintf(stderr, "Waiting on mutex\n");
    pipe->bufused = used;

    // fprintf(stderr, "Pipe: fread: %d %d\n", pipe->id, pipe->bufused);
    DosResetEventSem(pipe->ResumeRead, &ulPostCount);

    if (pipe->bufused == 0) break;

    if (pipe->notify) {
      DosPostEventSem(pipe->NewData);
      pipe->stopped = 0;
    }
    DosReleaseMutexSem(pipe->Access);

    if (pipe->DoTerm) break;

    // fprintf(stderr, "Waiting on sem\n");
    DosWaitEventSem(pipe->ResumeRead, SEM_INDEFINITE_WAIT);

    // fprintf(stderr, "Read: Released mutex\n");
    if (pipe->DoTerm) break;
  }
  DosClose(hfPipe);

  // fprintf(stderr, "Pipe: pClose: %d\n", pipe->id);
  rc = DosWaitChild(DCWA_PROCESS, DCWW_WAIT,
                    &rc_code,
                    &pid,
                    pid);
  pipe->RetCode = rc_code.codeResult;

  // pclose(fp);
  pipe->reading = 0;
  DosPostEventSem(pipe->NewData);
  DosReleaseMutexSem(pipe->Access);

  // fprintf(stderr, "Read: Released mutex\n");
}
示例#30
0
文件: os2.c 项目: UIKit0/paragui
int __PHYSFS_platformClose(void *opaque)
{
    return(os2err(DosClose((HFILE) opaque) == NO_ERROR));
} /* __PHYSFS_platformClose */