当前位置: 首页>>代码示例>>C++>>正文


C++ DosRead函数代码示例

本文整理汇总了C++中DosRead函数的典型用法代码示例。如果您正苦于以下问题:C++ DosRead函数的具体用法?C++ DosRead怎么用?C++ DosRead使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了DosRead函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: TimeIt

VOID TimeIt()
{
    TIMESTAMP   tsStart, tsStop;
    ULONG       ulRC, ulMsecs, ulNsecs, ulBytes;

    printf( "\nHit Ctrl-C to terminate this test program...\n" );
    for( ; ; )
    {
        printf( "\nSleeping for %u milliseconds...", ulTimePeriod );
        fflush( stdout );
        ulRC = DosRead( hfTimer, &tsStart, sizeof( TIMESTAMP ), &ulBytes );
        if( ulRC )
        {
            printf( "\nDosRead for start got a retcode of %u", ulRC );
            return;
        }
        DosSleep( ulTimePeriod );
        ulRC = DosRead( hfTimer, &tsStop, sizeof( TIMESTAMP ), &ulBytes );
        if( ulRC )
        {
            printf( "\nDosRead for stop got a retcode of %u", ulRC );
            return;
        }
        ulMsecs = CalcElapsedTime( &tsStart, &tsStop,
                                   ulOverheadMs, ulOverheadNs, &ulNsecs );
        printf( " elapsed time (ms:ns) = %06u:%06u", ulMsecs, ulNsecs );
    }
}
开发者ID:ABratovic,项目名称:open-watcom-v2,代码行数:28,代码来源:hrtest.c

示例2: ReadData

BOOL ReadData( HFILE handle )
   {
   BOOL   ret = FALSE;
   char * p1;
   int    dif;
   char   crc[2];
   ULONG  bytesread;
   ULONG  actual;

   DosRead( handle, tmpbuf, BUFSIZE, &bytesread );

   if ( bytesread )
      {
      if (p1=memchr( tmpbuf, EOFFLAG, bytesread ) )
         {
         dif        = bytesread - (int)(p1-tmpbuf);
         bytesread -= dif;
         if (dif < 3)
            {
            DosRead( handle, crc+dif, 3-dif, &bytesread );
            if (dif==1)
               crc[0] = *(p1+1);
            rc = *(unsigned int *)crc;
            }
         else
            rc = *(unsigned int *)(p1+1);

         ret = TRUE;
         } /* endif */

      DosWrite( 1, tmpbuf, bytesread, &actual );
      }

   return( ret );
   }
开发者ID:OS2World,项目名称:DEV-SAMPLES-WorkFrame2,代码行数:35,代码来源:DOSCL1.C

示例3: SERIAL_getextchar

int SERIAL_getextchar(COMPORT port) {
	ULONG dwRead = 0;	// Number of chars read
	char chRead;

	int retval = 0;
	// receive a byte; TODO communicate failure
	if (DosRead(port->porthandle, &chRead, 1, &dwRead) == NO_ERROR) {
		if (dwRead) {
			// check for errors; will OS/2 clear the error on reading its data?
			// if yes then this is in wrong order
			USHORT errors = 0, event = 0;
			ULONG ulParmLen = sizeof(errors);
			DosDevIOCtl(port->porthandle, IOCTL_ASYNC, ASYNC_GETCOMMEVENT,
				0, 0, 0, &event, ulParmLen, &ulParmLen);
			if (event & (64 + 128) ) { // Break (Bit 6) or Frame or Parity (Bit 7) error
				Bit8u errreg = 0;
				if (event & 64) retval |= SERIAL_BREAK_ERR;
				if (event & 128) {
					DosDevIOCtl(port->porthandle, IOCTL_ASYNC, ASYNC_GETCOMMERROR,
						0, 0, 0, &errors, ulParmLen, &ulParmLen);
					if (errors & 8) retval |= SERIAL_FRAMING_ERR;
					if (errors & 4) retval |= SERIAL_PARITY_ERR;
				}
			}
			retval |= (chRead & 0xff);
			retval |= 0x10000; 
		}
	}
	return retval;
}
开发者ID:GREYFOXRGR,项目名称:em-dosbox,代码行数:30,代码来源:libserial.cpp

示例4: Thread

VOID APIENTRY Thread(VOID)
{
   APIRET rc;
   ULONG ulNumBytes;
   TRACE_EVENT te;

   printf("Thread() started\n");
   rc = DosSetPriority(PRTYS_THREAD, PRTYC_TIMECRITICAL, 0, 0);
   if (rc) {
      printf("Thread() DosSetPriority failed with RC = %lu\n", rc);
      return;
   }

   fRunning = TRUE;
   while (!fQuit) {
      rc = DosRead(hfile, &te, sizeof(TRACE_EVENT), &ulNumBytes);
      if (rc) {
         printf("Error %d while calling device driver\n", rc);
         return;
      }
      ShowTrace(te);
   }

   printf("Thread() stopped\n");
   fRunning = FALSE;
}
开发者ID:OS2World,项目名称:DRV-MPU-401,代码行数:26,代码来源:mputrace.cpp

示例5: fread

/****************************************************************************
REMARKS:
VDD implementation of the ANSI C fread function. Note that unlike Windows VxDs,
OS/2 VDDs are not limited to 64K reads or writes.
****************************************************************************/
size_t fread(
    void *ptr,
    size_t size,
    size_t n,
    FILE *f)
{
    char    *buf = ptr;
    int     bytes,readbytes,totalbytes = 0;

    /* First copy any data already read into our buffer */
    if ((bytes = (f->curp - f->startp)) > 0) {
	memcpy(buf,f->curp,bytes);
	f->startp = f->curp = f->buf;
	buf += bytes;
	totalbytes += bytes;
	bytes = (size * n) - bytes;
	}
    else
	bytes = size * n;
    if (bytes) {
	#ifdef __OS2_VDD__
	readbytes = VDHRead((HFILE)f->handle, buf, bytes);
	#else
	DosRead((HFILE)f->handle, buf, bytes, &readbytes);
	#endif
	totalbytes += readbytes;
	f->offset += readbytes;
	}
    return totalbytes / size;
}
开发者ID:A1DEVS,项目名称:lenovo_a1_07_uboot,代码行数:35,代码来源:fileio.c

示例6: ServiceRequests

static VOID APIENTRY ServiceRequests( VOID )
{
    USHORT              len;
    pmhelp_packet       data;

    WinCreateMsgQueue( Hab, 0 );
    for( ;; ) {
        if( DosRead( InStream, &data, sizeof( data ), &len ) != 0 ) break;
        if( len != sizeof( data ) ) break;
        switch( data.command ) {
        case PMHELP_LOCK:
            PidDebugee = data.pid;
            TidDebugee = data.tid;
            LockIt();
            break;
        case PMHELP_UNLOCK:
            PidDebugee = data.pid;
            TidDebugee = data.tid;
            UnLockIt();
            break;
        case PMHELP_EXIT:
            WinPostMsg( hwndClient, WM_QUIT, 0, 0 );/* Cause termination*/
            break;
        }
        WinInvalidateRegion( hwndClient, 0L, FALSE );
    }
    Say( "Read Failed" );
}
开发者ID:Azarien,项目名称:open-watcom-v2,代码行数:28,代码来源:pmhelp.c

示例7: Reader

void _System Reader(ULONG arg)
{
    int        data;
    ULONG      read;
    int        new_index;
    APIRET     rc;

    OverRun = FALSE;
    for( ;; ) {
        rc = DosRead( ComPort, &data, 1, &read );
        if( rc != NO_ERROR )
            break;
        if( read == 1 ) {
            new_index = ReadBuffAdd + 1;
            new_index &= BSIZE-1;
            if( new_index == ReadBuffRemove ) {
                OverRun = TRUE;
            } else {
                ReadBuff[ ReadBuffAdd ] = data;
                ReadBuffAdd = new_index;
            }
            DosPostEventSem( ReadSemaphore );
        }
    }
}
开发者ID:Ukusbobra,项目名称:open-watcom-v2,代码行数:25,代码来源:seros22.c

示例8: while

char far *InitAlias( char far * inname )
/**************************************/
{
    USHORT hdl,read;
    static char b[80];
    char *bp;
    unsigned long ppos,pos;
    USHORT action;
    char far *endname;
    static char noalias = 0;

    endname = inname;
    while( *endname == ' ' ) ++endname;
    for( ;; ) {
        if( *endname == '\0' ) {
            break;
        }
        if( *endname == ' ' ) {
            *endname = '\0';
            ++endname;
            break;
        }
        ++endname;
    }
    bp = b;
    while( *bp = *inname ) {
        ++bp;
        ++inname;
    }
    action=action;
    if( DosOpen( b, &hdl, &action, 0L, 0, 1, 0x10 ,0L ) == 0 ) {
        DosChgFilePtr( hdl, 0L, 2, &ppos );
        pos = ppos;
        DosChgFilePtr( hdl, 0L, 0, &ppos );
#ifdef DOS
        {
            static int alias_seg;
            DosAllocSeg( pos + 1 + ALIAS_SLACK, &alias_seg, 0 );
            *(((int far *)&AliasList)+0) = 0;
            *(((int far *)&AliasList)+1) = alias_seg;
            AliasSize = pos + ALIAS_SLACK;
        }
#else
        AliasList = AliasArea;
        AliasSize = 2047;
#endif
        DosRead( hdl, AliasList, pos, &read );
        if( pos > 0 && AliasList[ pos-1 ] != '\n' ) {
            AliasList[ pos+0 ] = '\r';
            AliasList[ pos+1 ] = '\n';
            AliasList[ pos+2 ] = '\0';
        } else {
            AliasList[ pos ] = '\0';
        }
        DosClose( hdl );
    } else {
        AliasList = &noalias;
    }
    return( endname );
}
开发者ID:ABratovic,项目名称:open-watcom-v2,代码行数:60,代码来源:cmdalias.c

示例9: os2Read

/*
** Read data from a file into a buffer.  Return SQLITE_OK if all
** bytes were read successfully and SQLITE_IOERR if anything goes
** wrong.
*/
static int os2Read(
  sqlite3_file *id,               /* File to read from */
  void *pBuf,                     /* Write content into this buffer */
  int amt,                        /* Number of bytes to read */
  sqlite3_int64 offset            /* Begin reading at this offset */
){
  ULONG fileLocation = 0L;
  ULONG got;
  os2File *pFile = (os2File*)id;
  assert( id!=0 );
  SimulateIOError( return SQLITE_IOERR_READ );
  OSTRACE3( "READ %d lock=%d\n", pFile->h, pFile->locktype );
  if( DosSetFilePtr(pFile->h, offset, FILE_BEGIN, &fileLocation) != NO_ERROR ){
    return SQLITE_IOERR;
  }
  if( DosRead( pFile->h, pBuf, amt, &got ) != NO_ERROR ){
    return SQLITE_IOERR_READ;
  }
  if( got == (ULONG)amt )
    return SQLITE_OK;
  else {
    /* Unread portions of the input buffer must be zero-filled */
    memset(&((char*)pBuf)[got], 0, amt-got);
    return SQLITE_IOERR_SHORT_READ;
  }
}
开发者ID:erik-knudsen,项目名称:eCos-enhancements,代码行数:31,代码来源:os_os2.c

示例10: read_func

size_t read_func(void *ptr, size_t size, size_t nmemb, void *datasource)
{
    ULONG ulActual;

    DosRead( (HFILE)datasource, ptr, (size*nmemb), &ulActual );
    return ulActual / size;
}
开发者ID:OS2World,项目名称:MM-SOUND-PM123-OggPlug,代码行数:7,代码来源:command.c

示例11: TRANS

static int
TRANS(Os2Read)(XtransConnInfo ciptr, char *buf, int size)
{
    int ret;
    APIRET rc;
    ULONG ulRead;
    PRMSG(2,"Os2Read(%d,%x,%d)\n", ciptr->fd, buf, size );
    errno = 0;
    rc = DosRead(ciptr->fd, buf, size, &ulRead);
    if (rc == 0){
        ret = ulRead;
        }
    else if ((rc == 232) || (rc == 231)){
        errno = EAGAIN;
        ret = -1;
        }
    else if (rc == 6){
        errno = EBADF;
        ret = -1;
        }
     else if ((rc == 109) || (rc == 230) || (rc == 233)){
        errno = EPIPE;
       ret = -1;
        }
    else {
           PRMSG(2,"Os2Read: Unknown return code from DosRead, fd %d rc=%d\n", ciptr->fd,rc,0 );
           errno = EINVAL;
           ret = -1;
           }
    return (ret);
}
开发者ID:HoMeCracKeR,项目名称:MacOSX-SDKs,代码行数:31,代码来源:Xtransos2.c

示例12: GetDos32Debug

/*
 * get the address of Dos32Debug, and get the flat selectors, too.
 */
int GetDos32Debug( char __far *err )
{
    char        buff[256];
    RESULTCODES resc;
    USHORT      dummy;
    PSZ         start;
    PSZ         p;
    HFILE       inh;
    HFILE       outh;
    USHORT      rc;
    struct {
        ULONG       dos_debug;
        USHORT      cs;
        USHORT      ds;
        USHORT      ss;
    }           data;

    rc = DosGetModName( ThisDLLModHandle, sizeof( buff ), buff );
    if( rc ) {
        StrCopy( TRP_OS2_no_dll, err );
        return( FALSE );
    }
    start = buff;
    for( p = buff; *p != '\0'; ++p ) {
        switch( *p ) {
        case ':':
        case '\\':
        case '/':
           start = p + 1;
           break;
        }
    }
    p = StrCopy( LOCATOR, start );
    if( DosMakePipe( &inh, &outh, sizeof( data ) ) ) {
        StrCopy( TRP_OS2_no_pipe, err );
        return( FALSE );
    }
    *++p = outh + '0';
    *++p = '\0';
    *++p = '\0';
    rc = DosExecPgm( NULL, 0, EXEC_ASYNC, buff, NULL, &resc, buff );
    DosClose( outh );
    if( rc )  {
        DosClose( inh );
        StrCopy( TRP_OS2_no_help, err );
        return( FALSE );
    }
    rc = DosRead( inh, &data, sizeof( data ), &dummy );
    DosClose( inh );
    if( rc ) {
        StrCopy( TRP_OS2_no_help, err );
        return( FALSE );
    }
    DebugFunc = (void __far *)data.dos_debug;
    FlatCS = (USHORT) data.cs;
    FlatDS = (USHORT) data.ds;

    _retaddr = MakeLocalPtrFlat( (void __far *)DoReturn );
    return( TRUE );
}
开发者ID:Azarien,项目名称:open-watcom-v2,代码行数:63,代码来源:os2conv.c

示例13: init

static void init( void )
{
    ULONG     rc;
    ULONG     action;
    ULONG     bytes;

    rc = DosOpen( "WTIMER$", &timerHandle, &action, 0,
                   FILE_NORMAL, FILE_OPEN, OPEN_SHARE_DENYNONE, NULL );
    if( rc == 0 ) {
        DosRead( timerHandle, &startTime, sizeof( TIMESTAMP ), &bytes );
        DosRead( timerHandle, &stopTime, sizeof( TIMESTAMP ), &bytes );
        calc_time( &overHead, &startTime, &stopTime, NULL );
        DosRead( timerHandle, &startTime, sizeof( TIMESTAMP ), &bytes );
    } else {
        printf( "Could not open WTIMER$\n" );
    }
}
开发者ID:ABratovic,项目名称:open-watcom-v2,代码行数:17,代码来源:timer.c

示例14: while

char __far *InitAlias( char __far * inname )
/******************************************/
{
    USHORT          hdl,read;
    static char     b[80];
    char            *bp;
    unsigned long   ppos,pos;
    USHORT          action;
    char            __far *endname;
    static char     noalias = 0;
#ifndef DOS
    static char     AliasArea[2048]; /* The DLL seems to need static memory */
#endif

    endname = inname;
    while( *endname == ' ' )
        ++endname;
    for( ; *endname != '\0'; endname++ ) {
        if( *endname == ' ' ) {
            *endname++ = '\0';
            break;
        }
    }
    for( bp = b; (*bp = *inname) != '\0'; bp++ ) {
        ++inname;
    }
    action=action;
    if( DosOpen( b, &hdl, &action, 0L, 0, 1, 0x10 ,0L ) == 0 ) {
        DosChgFilePtr( hdl, 0L, 2, &ppos );
        pos = ppos;
        DosChgFilePtr( hdl, 0L, 0, &ppos );
#ifdef DOS
        {
            static int alias_seg;

            DosAllocSeg( pos + 1 + ALIAS_SLACK, &alias_seg, 0 );
            AliasList = (char __far *)MK_FP( alias_seg, 0 );
            AliasSize = pos + ALIAS_SLACK;
        }
#else
        AliasList = AliasArea;
        AliasSize = 2047;
#endif
        DosRead( hdl, AliasList, pos, &read );
        if( pos > 0 && AliasList[pos - 1] != '\n' ) {
            AliasList[pos + 0] = '\r';
            AliasList[pos + 1] = '\n';
            AliasList[pos + 2] = '\0';
        } else {
            AliasList[pos] = '\0';
        }
        DosClose( hdl );
    } else {
        AliasList = &noalias;
    }
    return( endname );
}
开发者ID:ArmstrongJ,项目名称:open-watcom-v2,代码行数:57,代码来源:cmdalias.c

示例15: CheckSystemConfig

VOID CheckSystemConfig( VOID )
{
 // Проверяем настройки в файле "Config.sys".
 CHAR File_name[ SIZE_OF_NAME ] = "*:\\Config.sys"; ULONG Boot_drive = 0;
 DosQuerySysInfo( QSV_BOOT_DRIVE, QSV_BOOT_DRIVE, (PULONG) &Boot_drive, sizeof( Boot_drive ) );
 File_name[ 0 ] = (CHAR) Boot_drive + 64;

 ULONG Action = OPEN_ACTION_OPEN_IF_EXISTS;
 ULONG Mode = OPEN_FLAGS_FAIL_ON_ERROR | OPEN_SHARE_DENYWRITE | OPEN_ACCESS_READONLY;

 HFILE File = NULLHANDLE; ULONG Report = 0;
 APIRET RC = DosOpen( File_name, &File, &Report, 0, FILE_NORMAL, Action, Mode, NULL );

 // Если файл был открыт:
 if( RC == NO_ERROR )
  {
   // Отводим память для текста.
   PCHAR Text = NULL; ULONG Length = 65536;
   if( DosAllocMem( (PPVOID) &Text, Length, PAG_ALLOCATE ) != NO_ERROR )
    {
     DosClose( File );
     DosExit( EXIT_PROCESS, 0 );
    }

   // Читаем настройки.
   memset( Text, 0, Length );
   DosRead( File, Text, Length, &Length );

   // Проверяем, есть ли в настройках путь к каталогу расширителя.
   BYTE Path_is_present = 1; if( !stristr( "NICE\\ENHANCER", Text ) ) Path_is_present = 0;

   // Освобождаем память.
   DosFreeMem( Text ); Text = NULL;

   // Закрываем файл.
   DosClose( File ); File = NULLHANDLE;

   // Если настройки заданы неправильно:
   if( !Path_is_present )
    {
     // Показываем сообщение.
     CHAR Title[ SIZE_OF_TITLE ] = ""; GetEnhancerWindowTitle( Title );

     if( QuerySystemCodePage() == RUSSIAN )
      WinMessageBox( HWND_DESKTOP, HWND_DESKTOP, StrConst_RU_No_path_in_Config_sys, Title, NULLHANDLE, NULLHANDLE );
     else
      WinMessageBox( HWND_DESKTOP, HWND_DESKTOP, StrConst_EN_No_path_in_Config_sys, Title, NULLHANDLE, NULLHANDLE );

     // Выход.
     DosExit( EXIT_PROCESS, 0 );
    }
  }

 // Возврат.
 return;
}
开发者ID:OS2World,项目名称:UTIL-WPS-Nice_OS2_Enhancer,代码行数:56,代码来源:Nice-os2.cpp


注:本文中的DosRead函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。