//-------------------------------- CMD_DosOpen --------------------------------- void CMD_DosOpen(HFILE hFile,LXIOCPA_DMN_CMDPARMPACKET* pParam ,PLXDOSOPENSTRUCT p) { pParam->rc=DosOpen(p->fileName,&p->hFile,&p->ulAction,p->cbFile ,p->ulAttribute,p->fsOpenFlags,p->fsOpenMode ,NULL); }
BOOL OpenPort(THREAD *pstThd) { ULONG ulAction; APIRET rc; CHAR szMsgString[200]; CHAR szCaption[80]; if ((rc = DosOpen(pstThd->stCfg.szPortName,&pstThd->hCom,&ulAction,0L,0,0x0001,0x21c2,0L)) != 0) { WinQueryWindowText(pstThd->hwndFrame,sizeof(szCaption),szCaption); // WinLoadString(pstThd->habAnchorBlk,NUL,EATM_DOSOPEN, // sizeof(szMsgString),szMsgString); sprintf(szMsgString,"Error opening %s\nError Code = %04X",pstThd->stCfg.szPortName,rc); WinMessageBox( HWND_DESKTOP, pstThd->hwndDlg, (PSZ)szMsgString, (PSZ)szCaption, NUL, MB_MOVEABLE | MB_OK | MB_CUAWARNING ); pstThd->hCom = 0; return(FALSE); } return(TRUE); }
/**************************************************************************** REMARKS: This function returns a pointer to the common graphics driver loaded in the helper VxD. The memory for the VxD is shared between all processes via the VxD, so that the VxD, 16-bit code and 32-bit code all see the same state when accessing the graphics binary portable driver. ****************************************************************************/ GA_sharedInfo * NAPI GA_getSharedInfo( int device) { /* Initialise the PM library and connect to our runtime DLL's */ PM_init(); /* Open our helper device driver */ if (DosOpen(PMHELP_NAME,&hSDDHelp,&result,0,0, FILE_OPEN, OPEN_SHARE_DENYNONE | OPEN_ACCESS_READWRITE, NULL)) PM_fatalError("Unable to open SDDHELP$ helper device driver!"); outLen = sizeof(result); DosDevIOCtl(hSDDHelp,PMHELP_IOCTL,PMHELP_GETSHAREDINFO, NULL, 0, NULL, &result, outLen, &outLen); DosClose(hSDDHelp); if (result) { /* We have found the shared Nucleus packet. Because not all processes * map to SDDPMI.DLL, we need to ensure that we connect to this * DLL so that it gets mapped into our address space (that is * where the shared Nucleus packet is located). Simply doing a * DosLoadModule on it is enough for this. */ HMODULE hModSDDPMI; char buf[80]; DosLoadModule((PSZ)buf,sizeof(buf),(PSZ)"SDDPMI.DLL",&hModSDDPMI); } return (GA_sharedInfo*)result; }
APIRET DosKillFastIo( PID pid ) { APIRET rc; HFILE hfd; ULONG action, plen; if(( rc = DosOpen((PSZ)"/dev/fastio$", (PHFILE)&hfd, (PULONG)&action, (ULONG)0, FILE_SYSTEM, FILE_OPEN, OPEN_SHARE_DENYNONE | OPEN_FLAGS_NOINHERIT | OPEN_ACCESS_READONLY, (ULONG)0)) != NO_ERROR ) { return rc; } if(( rc = DosDevIOCtl( hfd, (ULONG)0x76, (ULONG)0x65, (PULONG*)&pid, sizeof(USHORT), &plen, NULL, 0, NULL)) != 0 ) { DosClose( hfd ); return rc; } DosClose(hfd); return NO_ERROR; }
sys_handle LocalOpen( char *name, open_access access ) { HFILE hdl; USHORT action; USHORT openflags; USHORT openmode; USHORT rc; if( (access & OP_WRITE) == 0 ) { openmode = READONLY; access &= ~(OP_CREATE|OP_TRUNC); } else if( access & OP_READ ) { openmode = READWRITE; } else { openmode = WRITEONLY; } openmode |= 0x20c0; openflags = 0; if( access & OP_CREATE ) openflags |= 0x10; openflags |= (access & OP_TRUNC) ? 0x02 : 0x01; rc = DosOpen( name, /* name */ &hdl, /* handle to be filled in */ &action, /* action taken */ 0, /* initial allocation */ 0, /* normal file */ openflags, /* open the file */ openmode, /* deny-none, inheritance */ 0 ); /* reserved */ if( rc != 0 ) { StashErrCode( rc, OP_LOCAL ); return( NIL_SYS_HANDLE ); } return( hdl ); }
HFILE _wpi_filecreate( LPSTR filename, int format ) /*************************************************/ { #if 0 // this definition seems to interfere with C lib IO PM1632_FILESIZETYPE action; HFILE hfile; if( !(format & (OPEN_SHARE_DENYREAD | OPEN_SHARE_DENYWRITE | OPEN_SHARE_DENYREADWRITE | OPEN_SHARE_DENYNONE)) ) { format |= OPEN_SHARE_DENYNONE; } if( DosOpen( (PSZ)filename, &hfile, &action, 0L, FILE_NORMAL, OPEN_ACTION_CREATE_IF_NEW | OPEN_ACTION_REPLACE_IF_EXISTS, format, 0L ) != 0 ) { hfile = -1; } #ifdef __FLAT__ DosDevIOCtl( hfile, 0x08, 0x00, 0, 0, 0, 0, 512L, 0 ); #else // I don't know what to do here! // DosDevIOCtl( hfile, 0x08, 0x00, 0, 0, 0, 0, 512L, 0 ); #endif return( hfile ); #else return( _wpi_fileopen( filename, format ) ); #endif } /* _wpi_filecreate */
BOOL FcbGetFileSize(xfcb FAR * lpXfcb) { COUNT FcbDrive, hndl; /* Build a traditional DOS file name */ lpFcb = CommonFcbInit(lpXfcb, SecPathName, &FcbDrive); /* check for a device */ if (IsDevice(SecPathName) || (lpFcb->fcb_recsiz == 0)) { return FALSE; } hndl = DosOpen(SecPathName, O_RDONLY); if (hndl >= 0) { LONG fsize; /* Get the size */ fsize = DosGetFsize(hndl); /* compute the size and update the fcb */ lpFcb->fcb_rndm = fsize / lpFcb->fcb_recsiz; if ((fsize % lpFcb->fcb_recsiz) != 0) ++lpFcb->fcb_rndm; /* close the file and leave */ return DosClose(hndl) == SUCCESS; } else return FALSE; }
/***************************************************************************** * NAME: open_device_read * * FUNCTION: Open the specified device for read access. * * PARAMETERS: * Device - input - the device specification * * NOTES: * * RETURNS: * success: LOGDMP_OK * failure: something else */ int32 open_device_read ( char *Device ) { int32 openrd_rc = 0; int32 close_rc = 0; ULONG Action; int i; unsigned char CommandInfo = 0; unsigned long ParmLen = sizeof(CommandInfo); unsigned long DataLen = sizeof(struct DPB); USHORT ulSecsPerTrk; struct DPB *tmp_dpb = &Datap; TRACKLAYOUT *tmplayout; openrd_rc = DosOpen(Device, &Dev_IOPort, &Action, 0, 0, OPEN_ACTION_OPEN_IF_EXISTS, OPEN_FLAGS_DASD | OPEN_FLAGS_FAIL_ON_ERROR | OPEN_SHARE_DENYNONE | OPEN_ACCESS_READONLY, 0); if( openrd_rc != NO_ERROR ) { printf("LOG_DUMP: DosOpen failed with return code = %ld\n\r", openrd_rc ); openrd_rc = LOGDMP_FAILED; } else { /* now open for read, allow read/write */ /* * Get the device parameters */ openrd_rc = DosDevIOCtl(Dev_IOPort, IOCTL_DISK, DSK_GETDEVICEPARAMS, &CommandInfo, sizeof(CommandInfo), &ParmLen, &Datap, sizeof(struct DPB), &DataLen); if( openrd_rc != NO_ERROR ) { printf("LOG_DUMP: DSK_GETDEVICEPARAMS failed with return code = %ld\n\r", openrd_rc ); openrd_rc = LOGDMP_FAILED; } else { Dev_SectorSize = Datap.dev_bpb.bytes_per_sector; Dev_blksize = Dev_SectorSize; ulSecsPerTrk = Datap.dev_bpb.sectors_per_track; ptrklay = (TRACKLAYOUT *)malloc(sizeof(TRACKLAYOUT) + 4 * ulSecsPerTrk ); if( ptrklay == NULL ) { printf("LOG_DUMP: Can't allocate storage for device information\n\r" ); openrd_rc = LOGDMP_FAILED; } else { for( i = 0; i < ulSecsPerTrk; i++ ) { ptrklay->TrackTable[i].usSectorSize = Dev_SectorSize; ptrklay->TrackTable[i].usSectorNumber = i + 1; } device_is_open = -1; } } } /* end successful open for read, allow read/write */ return( openrd_rc ); } /* end of open_device_read ( ) */
static APIRET death(PID pid) { APIRET rc; HFILE hfd; ULONG action,plen; USHORT param; if ((rc=DosOpen((PSZ)"/dev/fastio$", (PHFILE)&hfd, (PULONG)&action, (ULONG)0, FILE_SYSTEM, FILE_OPEN, OPEN_SHARE_DENYNONE|OPEN_FLAGS_NOINHERIT|OPEN_ACCESS_READONLY, (ULONG)0))) { fputs("Error opening fastio$ driver...\n",stderr); fputs("Please install xf86sup.sys in config.sys!\n",stderr); return rc; } param = pid; if ((rc=DosDevIOCtl(hfd, (ULONG)0x76, (ULONG)0x65, (PULONG*)¶m,sizeof(USHORT),&plen, NULL, 0, NULL)) != 0) { fprintf(stderr,"fastio$ driver: kill(%i,9) failed rc=%i\n",pid,rc); DosClose(hfd); return rc; } DosClose(hfd); return 0; }
void main() { USHORT rc, Action; HFILE FileHandle; DosSetSigHandler(BrkHandler, NULL, NULL, SIGA_ACCEPT, SIG_CTRLC); DosSetSigHandler(BrkHandler, NULL, NULL, SIGA_ACCEPT, SIG_KILLPROCESS); DosSetSigHandler(BrkHandler, NULL, NULL, SIGA_ACCEPT, SIG_CTRLBREAK); DosSetPrty(PRTYS_PROCESS, PRTYC_IDLETIME, 0, 0); rc = DosOpen("Idlehlt$", &FileHandle, &Action, 0L, FILE_NORMAL, FILE_OPEN, OPEN_SHARE_DENYNONE, 0L); if(!rc) { while(!ExitWhile) DosDevIOCtl(NULL, NULL, 0x01, 0x91, FileHandle); DosClose(FileHandle); } else { char buf[6], Message[36] = "HLT Driver not installed? rc="; char *src = buf, *dst = &Message[29]; int len; utoa(rc, buf, 10); while(*dst++ = *src++); len = dst - Message; Message[len-1] = '\r'; Message[len] = '\n'; DosWrite(STDERR_FILENO, Message, len+1, &Action); } }
_WCRTLINK unsigned _dos_open( const char *name, unsigned mode, int *handle ) { APIRET rc; OS_UINT rwmode, actiontaken, openmode; HFILE fhandle; int share; unsigned iomode_flags; while( *name == ' ' ) ++name; rwmode = mode & OPENMODE_ACCESS_MASK; if( rwmode == OPENMODE_ACCESS_WRONLY #if defined(__OS2_286__) && !_RWD_osmode /* Can't open WRONLY file in bound application under DOS */ #endif ) { rwmode = OPENMODE_ACCESS_RDWR; } share = mode & OPENMODE_SHARE_MASK; if( share == OPENMODE_DENY_COMPAT ) { share = OPENMODE_DENY_NONE; } openmode = share+rwmode; rc = DosOpen( (PSZ)name, &fhandle, &actiontaken, 0ul, _A_NORMAL, OPENFLAG_OPEN_IF_EXISTS, openmode, 0ul ); if( rc ) { return( __set_errno_dos_reterr( rc ) ); } *handle = fhandle; if( rwmode == O_RDWR ) iomode_flags = _READ | _WRITE; if( rwmode == O_RDONLY) iomode_flags = _READ; if( rwmode == O_WRONLY) iomode_flags = _WRITE; __SetIOMode( fhandle, iomode_flags ); return( 0 ); }
void *__PHYSFS_platformOpenAppend(const char *filename) { ULONG dummy = 0; HFILE hfile = NULLHANDLE; APIRET rc; /* * File must be opened SHARE_DENYWRITE and ACCESS_READWRITE, otherwise * DosQueryFileInfo() will fail if we try to get a file length, etc. */ rc = os2err(DosOpen(filename, &hfile, &dummy, 0, FILE_NORMAL, OPEN_ACTION_OPEN_IF_EXISTS | OPEN_ACTION_CREATE_IF_NEW, OPEN_FLAGS_FAIL_ON_ERROR | OPEN_FLAGS_NO_LOCALITY | OPEN_FLAGS_NOINHERIT | OPEN_SHARE_DENYWRITE | OPEN_ACCESS_READWRITE, NULL)); if (rc == NO_ERROR) { if (os2err(DosSetFilePtr(hfile, 0, FILE_END, &dummy)) != NO_ERROR) { DosClose(hfile); hfile = NULLHANDLE; } /* if */ } /* if */ return((void *) hfile); } /* __PHYSFS_platformOpenAppend */
// Title и String - строки, которые надо записать. VOID Krnl_Debug_Log( PCHAR Title, PCHAR String ) { // Если файла нет - создаем его. HFILE File = NULLHANDLE; ULONG Report = 0; ULONG New_size = 0; PEAOP2 EAs = NULL; ULONG Action = OPEN_ACTION_OPEN_IF_EXISTS | OPEN_ACTION_CREATE_IF_NEW; ULONG Mode = OPEN_FLAGS_FAIL_ON_ERROR | OPEN_SHARE_DENYWRITE | OPEN_ACCESS_WRITEONLY; CHAR Log_file_name[ SIZE_OF_PATH ] = ""; GetCurrentPath( Log_file_name ); strcat( Log_file_name, "\\_log.txt" ); DosOpen( Log_file_name, &File, &Report, New_size, FILE_COMMON_ATTRIBUTES, Action, Mode, EAs ); // Записываем строку. if( Report != FILE_CREATED ) { DosSetFilePtr( File, 0, FILE_END, &Report ); DosWrite( File, "\n", strlen( "\n" ), &Report ); } if( Title[ 0 ] != 0 ) { DosWrite( File, Title, strlen( Title ), &Report ); DosWrite( File, ": ", strlen( ": " ), &Report ); } DosWrite( File, String, strlen( String ), &Report ); // Закрываем файл. DosClose( File ); File = NULLHANDLE; // Возврат. return; }
HFILE CreateFile(int iNr) { BYTE szFileName[20]; HFILE hFile; #ifdef __IBMC__ APIRET rc; ULONG ulAction; #else USHORT rc; USHORT ulAction; #endif sprintf(szFileName, "FILE%4.4u.DAT", iNr); rc = DosOpen(szFileName, &hFile, &ulAction, 0L, /* new size */ 0, /* attributes */ FILE_CREATE | FILE_TRUNCATE, OPEN_ACCESS_READWRITE | OPEN_SHARE_DENYNONE, 0L); if (rc) { printf("DosOpen on %s failed, rc = %u\n", szFileName, rc); getch(); return 0; } return hFile; }
char *ParsePortSpec( char * *spec ) { char *parm; ULONG action; char port; static char name[] = "com?"; parm = (spec == NULL) ? "" : *spec; port = '1'; if( *parm >= '1' && *parm <= '9' ) { port = *parm++; } if( *parm != '\0' && *parm != '.' ) return( TRP_ERR_invalid_serial_port_number ); if( spec != NULL ) *spec = parm; if( ComPort != 0 ) { DosClose( ComPort ); ComPort = 0; } name[sizeof( name ) - 2] = port; if( DosOpen( (PSZ)name, &ComPort, &action, 0, 0, 1, 0x12, 0 ) ) { ComPort = 0; return( TRP_ERR_serial_port_not_available ); } return( NULL ); }
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 ); }
/***************************************************************************** * os2_vcd_open: open vcd drive *****************************************************************************/ static int os2_vcd_open( vlc_object_t * p_this, const char *psz_dev, vcddev_t *p_vcddev ) { char device[] = "X:"; HFILE hcd; ULONG i_action; ULONG rc; p_vcddev->hcd = 0; device[0] = psz_dev[0]; rc = DosOpen( device, &hcd, &i_action, 0, FILE_NORMAL, OPEN_ACTION_OPEN_IF_EXISTS | OPEN_ACTION_FAIL_IF_NEW, OPEN_ACCESS_READONLY | OPEN_SHARE_DENYNONE | OPEN_FLAGS_DASD, NULL); if( rc ) { msg_Err( p_this, "could not open the device %s", psz_dev ); return -1; } p_vcddev->hcd = hcd; return 0; }
/** * Cleans up after system_Init() and system_Configure(). */ void system_End(void) { if( tidIPCFirst == _gettid()) { HPIPE hpipe; ULONG ulAction; ULONG cbActual; ULONG rc; do { 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 if( rc ) DosSleep( 1 ); } while( rc ); /* Ask for IPCHelper to quit */ ULONG ulCmd = IPC_CMD_QUIT; DosWrite( hpipe, &ulCmd, sizeof( ulCmd ), &cbActual ); DosClose( hpipe ); TID tid = tidIPCHelper; DosWaitThread( &tid, DCWW_WAIT ); } }
unsigned long LFileOpen(char *pszFileName) { APIRET rc; HFILE hFileHandle = (HFILE) 0; ULONG ulAction; ULONG ulFileAttribute = FILE_NORMAL; ULONG ulOpenFlags = OPEN_ACTION_FAIL_IF_NEW | OPEN_ACTION_OPEN_IF_EXISTS; ULONG ulOpenMode = OPEN_FLAGS_SEQUENTIAL | OPEN_SHARE_DENYWRITE | OPEN_ACCESS_READONLY /**| 0x10000000; OPEN_SHARE_DENYLEGACY **/ ; rc = DosOpen(pszFileName, &hFileHandle, &ulAction, 0UL, ulFileAttribute, ulOpenFlags, ulOpenMode, (PEAOP2)NULL); if(rc != 0) LSetLastFileError(rc); return (unsigned long) hFileHandle; }
BOOL SetRASectors(PSZ pszArg) { APIRET rc; HFILE hDisk; ULONG ulAction; USHORT usRASectors; ULONG ulDataSize; BYTE szDisk[3]; if (pszArg[1] != ':') { printf("Invalid argument for /R option.\n"); DosExit(EXIT_PROCESS, 1); } memset(szDisk, 0, sizeof szDisk); memcpy(szDisk, pszArg, 2); strupr(szDisk); pszArg+=2; if (*pszArg !=',') { printf("Comma missing in /R:d:,n\n"); DosExit(EXIT_PROCESS, 1); } pszArg++; usRASectors = atoi(pszArg); rc = DosOpen(szDisk, &hDisk, &ulAction, /* action taken */ 0L, /* new size */ 0L, /* attributes */ OPEN_ACTION_OPEN_IF_EXISTS, /* open flags */ OPEN_ACCESS_READONLY | /* open mode */ OPEN_SHARE_DENYNONE | OPEN_FLAGS_DASD, NULL); /* ea data */ if (rc) { printf("Cannot access drive %s, rc = %d\n", szDisk, rc); DosExit(EXIT_PROCESS, 1); } ulDataSize = sizeof usRASectors; rc = DosDevIOCtl(hDisk, IOCTL_FAT32, FAT32_SETRASECTORS, (PVOID)&usRASectors, ulDataSize, &ulDataSize, NULL, 0, NULL); if (rc) { printf("DosDevIOCtl, FAT_SETRASECTORS for drive %s failed, rc = %d\n", szDisk, rc); DosExit(EXIT_PROCESS, 1); } DosClose(hDisk); return TRUE; }
_WCRTLINK int __F_NAME(utime,_wutime)( CHAR_TYPE const *fn, struct utimbuf const *times ) /***************************************************************************************/ { APIRET rc; OS_UINT actiontaken; FILESTATUS stat; HFILE handle; struct tm *split; time_t curr_time; struct utimbuf time_buf; #ifdef __WIDECHAR__ char mbPath[MB_CUR_MAX * _MAX_PATH]; /* single-byte char */ if( wcstombs( mbPath, fn, sizeof( mbPath ) ) == -1 ) { mbPath[0] = '\0'; } #endif rc = DosOpen( (PSZ)__F_NAME(fn,mbPath), &handle, &actiontaken, 0ul, _A_NORMAL, OPENFLAG_FAIL_IF_NOT_EXISTS | OPENFLAG_OPEN_IF_EXISTS, OPENMODE_DENY_NONE | OPENMODE_ACCESS_RDWR, 0ul ); if( rc != 0 ) { return( __set_errno_dos( rc ) ); } if( DosQFileInfo( handle, 1, (PBYTE)&stat, sizeof( FILESTATUS ) ) != 0 ) { DosClose( handle ); __set_errno( EACCES ); return( -1 ); } if( times == NULL ) { curr_time = time( NULL ); time_buf.modtime = curr_time; time_buf.actime = curr_time; times = &time_buf; } split = localtime( &(times->modtime) ); stat.fdateLastWrite.year = split->tm_year - 80; stat.fdateLastWrite.month = split->tm_mon + 1; stat.fdateLastWrite.day = split->tm_mday; stat.ftimeLastWrite.hours = split->tm_hour; stat.ftimeLastWrite.minutes = split->tm_min; stat.ftimeLastWrite.twosecs = split->tm_sec >> 1; /* 5-Apr-90 DJG * Early versions of OS/2 (1.10) do not support this fields properly. * We'll assume that if OS/2 returned a value here that we can set it * ourselves. Day has to be non-zero if the date is valid. */ if( stat.fdateLastAccess.day != 0 ) { split = localtime( &(times->actime) ); stat.fdateLastAccess.year = split->tm_year - 80; stat.fdateLastAccess.month = split->tm_mon + 1; stat.fdateLastAccess.day = split->tm_mday; stat.ftimeLastAccess.hours = split->tm_hour; stat.ftimeLastAccess.minutes = split->tm_min; stat.ftimeLastAccess.twosecs = split->tm_sec >> 1; }
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 ); }
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; }
Bool volume_open (char letter, volh *handle) { char openpath[8]; ULONG resAction, rc; HFILE dh; sprintf(openpath,"%c:",letter); DosError(FERR_DISABLEHARDERR); rc = DosOpen(openpath,&dh,&resAction,0,0,OPEN_ACTION_OPEN_IF_EXISTS, OPEN_FLAGS_DASD|OPEN_FLAGS_NO_CACHE|OPEN_FLAGS_NOINHERIT| OPEN_SHARE_DENYNONE|OPEN_FLAGS_FAIL_ON_ERROR|OPEN_ACCESS_READWRITE,0); // OPEN_SHARE_DENYREADWRITE if (rc==0) { voldata *vh = (voldata*)malloc(sizeof(voldata)); struct { b Infotype, DriveUnit; } DriveRequest; d psize = sizeof(DriveRequest), dsize = sizeof(vh->bpb); memset(vh, 0, sizeof(voldata)); vh->dh = dh; /* good news is that real BPB returned with REAL sectors per track value, not written into FAT spt field. This is actual for 127/255 spt disks, formatted to FAT in Windows (where FAT spt is 63) */ DriveRequest.Infotype =1; //0; DriveRequest.DriveUnit=0; if (DosDevIOCtl(dh,IOCTL_DISK,DSK_GETDEVICEPARAMS,(PVOID)&DriveRequest, sizeof(DriveRequest),&psize,(PVOID)&vh->bpb,sizeof(vh->bpb),&dsize)==0) { u64 sectors = vh->bpb.cSectors; if (!sectors) sectors = vh->bpb.cLargeSectors; vh->volsize = sectors; vh->ssize = vh->bpb.usBytesPerSector; } else { FSALLOCATE fa; if (DosQueryFSInfo(letter-'A'+1,FSIL_ALLOC,&fa,sizeof(fa))) memset(&fa,0,sizeof(fa)); vh->volsize = ((u64)fa.cSectorUnit*fa.cbSector*fa.cUnit)/fa.cbSector; vh->ssize = fa.cbSector; } vh->drive = letter; *handle = vh; return True; } else { printf("Error %d (%X)\n",rc,rc); } *handle = 0; return False; }
void main(int argc, char **argv) { APIRET rc; ULONG ulAction = 0; TID tid = 0; char szTemp[] = "NPU4011$"; char szDevName[128] = "\\DEV\\"; if (argc > 1) { strcpy(szTemp, argv[1]); szTemp[0]++; } strcat(szDevName, szTemp); printf("MPUTRACE - Theta Band Software MPU-401 Driver Trace Utility\n"); printf("%d Trace Messages supported\n", NUM_TRACES); printf("Opening %s\n", szDevName); rc = DosOpen((PSZ) szDevName, &hfile, &ulAction, 0, 0, OPEN_FLAG, OPEN_MODE, NULL); if (rc) { printf("Error %d while trying to open MPU-401 device driver\n", rc); return; } ULONG ulSize1; ULONG ulSize2 = sizeof(STATUS); rc = DosDevIOCtl(hfile, 0x80, 0, NULL, ulSize1, &ulSize1, &status, ulSize2, &ulSize2); if (rc) { printf("Error %d while trying to get MPU-401 status\n", rc); return; } PrintStatus(); printf("Creating thread\n"); rc = DosCreateThread(&tid, (PFNTHREAD) Thread, 0, CREATE_READY | STACK_COMMITTED, 8192); if (rc) { printf("DosCreateThread failed with RC = %lu\n", rc); return; } while (!fRunning) DosSleep(100); printf("Hit any key to quit. Program will then exit after the next message.\n"); getch(); printf("Quitting ...\n"); fQuit = TRUE; while (fRunning) DosSleep(100); DosSleep(500); // wait until the thread really ends DosClose(hfile); }
BOOL LoadList( BYTE Type ) { HFILE File; switch( Type ) { case BEGRUENDUNGEN: if( DosOpen( BEGRUENDFILENAME, &File, OPEN_RDONLY ) ) ; // Debug!!!!! DosRead( File, &NumBegruendungen, sizeof( NumBegruendungen ), NULL ); Begruendungen = DosAllocFarMem( sizeof( *Begruendungen ) * NumBegruendungen ); DosRead( File, Begruendungen, sizeof( *Begruendungen ) * NumBegruendungen, NULL ); DosClose( File ); break; case ABTEILUNGEN: if( DosOpen( ABTEILFILENAME, &File, OPEN_RDONLY ) ) ; // Debug!!!!! DosRead( File, &NumAbteilungen, sizeof( NumAbteilungen ), NULL ); Abteilungen = DosAllocFarMem( sizeof( *Abteilungen ) * NumAbteilungen ); DosRead( File, Abteilungen, sizeof( *Abteilungen ) * NumAbteilungen, NULL ); DosClose( File ); break; case ZEITKONTI: if( DosOpen( ZEITKFILENAME, &File, OPEN_RDONLY ) ) ; // Debug!!!!! DosRead( File, &NumZeitKonti, sizeof( NumZeitKonti ), NULL ); ZeitKonti = DosAllocFarMem( sizeof( *ZeitKonti ) * NumZeitKonti ); DosRead( File, ZeitKonti, sizeof( *ZeitKonti ) * NumZeitKonti, NULL ); DosClose( File ); break; } return( TRUE ); }
ULONG MsdGetThumb( CAMRecPtr pcr, char ** ppBuf) { ULONG rc = 0; ULONG ul; HFILE hFile = 0; char szPath[CCHMAXPATH]; do { *ppBuf = malloc( pcr->tnsize); if (!*ppBuf) { rc = CAMERR_MALLOC; break; } strcpy( szPath, pcr->path); strcat( szPath, (pcr->orgname ? pcr->orgname : pcr->title)); rc = DosOpen( szPath, &hFile, &ul, 0, 0, (OPEN_ACTION_FAIL_IF_NEW | OPEN_ACTION_OPEN_IF_EXISTS), (OPEN_FLAGS_FAIL_ON_ERROR | OPEN_FLAGS_SEQUENTIAL | OPEN_SHARE_DENYWRITE | OPEN_ACCESS_READONLY), 0); if (rc) { printf( "MsdGetThumb - DosOpen - rc= 0x%lx\n", rc); break; } rc = DosSetFilePtr( hFile, pcr->tnoffs, FILE_BEGIN, &ul); if (rc) { printf( "MsdGetThumb - DosSetFilePtr - rc= 0x%lx\n", rc); break; } if (ul != pcr->tnoffs) { rc = CAMERR_NEEDDATA; printf( "MsdGetThumb - DosSetFilePtr - seek failed\n"); break; } ul = FileReadFile( hFile, *ppBuf, pcr->tnsize, szPath); if (!ul) rc = CAMERR_NEEDDATA; } while (0); if (hFile) DosClose( hFile); if (rc && *ppBuf) { free( *ppBuf); *ppBuf = 0; } return (rc); }
/* Initialize joystick support. */ int joy_arch_init(void) { ULONG action; // return value from DosOpen APIRET rc; if (SWhGame) return 0; joylog = log_open("Joystick"); archdep_create_mutex_sem(&hmtxJoystick, "Joystick", TRUE); number_joysticks = JOYDEV_NONE; if (rc=DosOpen("GAME$", &SWhGame, &action, 0, FILE_READONLY, OPEN_ACTION_OPEN_IF_EXISTS/*FILE_OPEN*/, OPEN_ACCESS_READONLY | OPEN_SHARE_DENYNONE, NULL)) { if (rc==ERROR_OPEN_FAILED) { log_warning(joylog, "Cannot open device 'GAME$'."); log_warning(joylog, "Have you installed a MPPM/2 joystick device driver?\n"); } else log_error(joylog, "DosOpen 'GAME$' (rc=%i)", rc); } else { GAME_PARM_STRUCT parms; ULONG dataLen = sizeof(parms); // length of gameStatus if (rc=DosDevIOCtl(SWhGame, IOCTL_CAT_USER, GAME_GET_PARMS, NULL, 0, NULL, &parms, dataLen, &dataLen)) { log_error(joylog, "DosDevIOCtl (rc=%i)", rc); } else { if (parms.useA) { log_message(joylog, "Joystick A found."); number_joysticks |= JOYDEV_HW1; } if (parms.useB) { log_message(joylog, "Joystick B found."); number_joysticks |= JOYDEV_HW2; } if (number_joysticks==JOYDEV_NONE) log_message(joylog, "Sorry, no joystick found!"); } } DosReleaseMutexSem(hmtxJoystick); return 0; }
CDirectSerial::CDirectSerial (IO_ReadHandler * rh, IO_WriteHandler * wh, TIMER_TickHandler th, Bit16u baseAddr, Bit8u initIrq, Bit32u initBps, Bit8u bytesize, const char *parity, Bit8u stopbits,const char *realPort) :CSerial (rh, wh, th,baseAddr,initIrq, initBps, bytesize, parity,stopbits) { InstallationSuccessful = false; InstallTimerHandler(th); lastChance = 0; LOG_MSG ("OS/2 Serial port at %x: Opening %s", base, realPort); LOG_MSG("Opening OS2 serial port"); ULONG ulAction = 0; APIRET rc = DosOpen((unsigned char*)realPort, &hCom, &ulAction, 0L, FILE_NORMAL, FILE_OPEN, OPEN_ACCESS_READWRITE | OPEN_SHARE_DENYNONE | OPEN_FLAGS_SEQUENTIAL, 0L); if (rc != NO_ERROR) { LOG_MSG ("Serial port \"%s\" could not be opened.", realPort); if (rc == 2) { LOG_MSG ("The specified port does not exist."); } else if (rc == 99) { LOG_MSG ("The specified port is already in use."); } else { LOG_MSG ("OS/2 error %d occurred.", rc); } hCom = 0; return; } DCBINFO dcb; ULONG ulParmLen = sizeof(DCBINFO); rc = DosDevIOCtl(hCom, IOCTL_ASYNC, ASYNC_GETDCBINFO, 0, 0, 0, &dcb, ulParmLen, &ulParmLen); if ( rc != NO_ERROR) { DosClose(hCom); hCom = 0; return; } dcb.usWriteTimeout = 0; dcb.usReadTimeout = 0; //65535; dcb.fbTimeout |= 6; rc = DosDevIOCtl(hCom, IOCTL_ASYNC, ASYNC_SETDCBINFO, &dcb, ulParmLen, &ulParmLen, 0, 0, 0); if ( rc != NO_ERROR) { DosClose(hCom); hCom = 0; return; } CSerial::Init_Registers (initBps, bytesize, parity, stopbits); InstallationSuccessful = true; //LOG_MSG("InstSuccess"); }
COUNT csysOpen(void) { COUNT fd; struct nlsCSys_fileHeader header; if((fd = DosOpen((BYTE FAR*)filename, 0)) < 0) { printf("Cannot open: \"%s\"\n", filename); return 1; } if(DosRead(fd, &header, sizeof(header)) != sizeof(header); || strcmp(header.csys_idstring, CSYS_FD_IDSTRING) != 0