home *** CD-ROM | disk | FTP | other *** search
-
- /*******************************************************************
- $CRT 05 Feb 1997 : hb
-
- $AUT Holger Burkarth
- $DAT >>WaitForChar.c<< 05 Feb 1997 10:10:14 - (C) ProDAD
- *******************************************************************/
-
- //##ex mcpp:cppc -gs -o pos:pos/ex/WaitForChar p:pLib/StartCode.o p:/pOS_RKRM/pDos/WaitForChar.c p:pLib/StdIO.o -l pOSStub -l pOS
-
- /***********************************************************
- pOS programing example - Copyright (C) 1995-97 proDAD
-
- This code was written as an easy to understand example,
- how to program pOS features. It is provided 'as-is',
- without any express or implied warranty.
-
- Permission is hereby granted to use, copy and modify
- this source code for any purpose, without fee, subject
- to the following conditions:
-
- (1) This notice may not be removed or altered from any
- source distribution.
-
- (2) Altered source versions must be plainly marked as
- such, and must not be misrepresented as being
- the original source code.
-
- (3) If only executable code is distributed, then the
- accompanying documentation have to state that
- "this software is based in part on examples of
- the pOS developer packet".
-
- (4) Permission for use of this code is granted only
- if the user accepts full responsibility for any
- undesirable consequences. proDAD accept NO LIABILITY
- for damages of any kind.
-
- ©proDAD
- ***********************************************************/
-
- /*\
- *** Example:
- ***
- \*/
-
-
- #define __COMPUTER_AMIGA 1
- #define NOMYDEBUG
-
- #include "p:pExec/Types.h"
- #include "p:pDOS/ArgTags.h"
- #include "p:pDOS/DosSig.h"
- #include "p:pDOS/DosErrors.h"
- #include "p:pDOS/Process.h"
- #include "p:pDos/Files.h"
- #include "p:Device/Timer.h"
- #include "p:pDOS/DosDev.h"
- #include "p:proto/pLibExt.h"
- #include "p:proto/pExec2.h"
- #include "p:proto/pDOS2.h"
-
- #ifdef _____ME_____
- #include "grund/inc_string.h"
- #include "grund/inc_stdio.h"
- #else
- #ifdef __cplusplus
- extern "C" {
- #endif
- #include <string.h>
- #include <stdio.h>
- #ifdef __cplusplus
- }
- #endif
- #endif
-
-
- const CHAR *HelpText=
- ""
- ;
-
- const CHAR *PrgHeader=
- "Control Dos-Buffers";
-
- const CHAR *PrgVerText=
- "$VER: 1.0 ("__DATE2__") (Copyright 1997 by proDAD) (Created by Holger Burkarth)";
-
-
-
- /*----------------------------------
- -----------------------------------*/
- #ifdef __cplusplus
- extern "C"
- #endif
-
- VOID main()
- {
- struct pOS_DosArgs* Args;
- ULONG Ops[3]={(ULONG)"CONSOLE:",8,1};
-
- Args=pOS_ReadDosArgs(
- // 0 1 2
- "NAME, SECS/N, RAW/S",
- Ops,sizeof(Ops)/sizeof(ULONG),
-
- ARGTAG_PrgHeaderText, (ULONG)PrgHeader, /* kurze Programm-Beschreibung */
- ARGTAG_HelpText, (ULONG)HelpText, /* Help-Texte */
- ARGTAG_PrgVerText, (ULONG)PrgVerText, /* VER-String */
- TAG_END);
-
- if(Args) {
- pOS_FileHandle* FH;
-
- if(FH=pOS_OpenFile(NULL,(dosname_t*)Ops[0],FILEHDMOD_Read)) {
- pOS_DosIOReq IOReq;
- pOS_TimeVal TV={*((ULONG*)Ops[1]),0};
- CHAR Buffer[32]={0};
-
- if(Ops[2]) pOS_SetDosScreenMode(FH,1);
-
- pOS_InitDosIOReq(FH->fh_DosDev,&IOReq);
- IOReq.dr_Command = DOSCMD_WaitForChar;
-
- IOReq.dr_U.dr_WaitForChar.drwc_FH=FH;
- IOReq.dr_U.dr_WaitForChar.drwc_Time=&TV;
- pOS_DoIO((pOS_IORequest*)&IOReq);
- if(IOReq.dr_Error2==0) {
- if(IOReq.dr_U.dr_WaitForChar.drwc_ResSize>0) {
- pOS_ReadFile(FH,Buffer,IOReq.dr_U.dr_WaitForChar.drwc_ResSize);
- printf("Result=%ld %lp\n",IOReq.dr_U.dr_WaitForChar.drwc_ResSize,Buffer);
- }
- else printf("timeout\n");
- }
- else pOS_PrintDosErr(NULL,(CHAR*)Ops[0],IOReq.dr_Error2);
-
- if(Ops[2]) pOS_SetDosScreenMode(FH,0);
- pOS_CloseFile(FH);
- }
- else pOS_PrintDosErr(NULL,(CHAR*)Ops[0],0);
-
- pOS_DeleteDosArgs(Args);
- }
- }
-
-
-