home *** CD-ROM | disk | FTP | other *** search
-
- /*******************************************************************
- $CRT 08 Jan 1997 : hb
-
- $AUT Holger Burkarth
- $DAT >>DosNotiM.c<< 08 Jan 1997 13:01:44 - (C) ProDAD
- *******************************************************************/
-
- //##ex mcpp:cppc -gs -o pos:pos/ex/DosNotiM p:pLib/StartCode.o p:/pOS_RKRM/pDos/DosNotiM.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:pExec/Memory.h"
- #include "p:pExec/MsgPort.h"
- #include "p:pDOS/ArgTags.h"
- #include "p:pDOS/DosBase.h"
- #include "p:pDOS/DosSig.h"
- #include "p:pDOS/DosErrors.h"
- #include "p:pDOS/Notify.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 1996 by proDAD) (Created by Holger Burkarth)";
-
-
-
- /*----------------------------------
- -----------------------------------*/
- #ifdef __cplusplus
- extern "C"
- #endif
-
- VOID main()
- {
- struct pOS_DosArgs* Args;
- ULONG Ops[1]={0};
-
- Args=pOS_ReadDosArgs(
- // 0
- "NAME/A/M",
- 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_MsgPort Port;
- pOS_DosNotifyReq *Notify;
- dosname_t **Names;
- ULONG Sigs=0;
- UWORD i,Num;
-
- for(Num=0, Names=(dosname_t**)Ops[0]; Names[Num]; ++Num); // Counting Names
-
- if(Notify=(pOS_DosNotifyReq*)
- pOS_AllocMem(sizeof(pOS_DosNotifyReq)*Num,MEMF_PUBLIC)) {
-
- pOS_ConstructMsgPort(&Port);
- for(i=0; i<Num; ++i) pOS_ConstructDosMsgNotify(&Notify[i],Names[i],0,&Port);
-
- for(i=0; i<Num; ++i) {
- if(!pOS_DosStartNotify(&Notify[i])) {
- Notify[i].nr_Name=NULL;
- pOS_PrintDosErr(NULL,Names[i],0);
- }
- }
- printf("Notification is installed, press Ctrl-C for abort.\n");
-
- while( !(Sigs & DOSSIGF_CTRL_C) ) {
- const pOS_DosNotifyReq* Req;
- pOS_DosNotifyMessage *Msg;
-
- Sigs=pOS_WaitSignal(DOSSIGF_CTRL_C | (1<<Port.mp_SigBit) );
-
- while(Msg=(pOS_DosNotifyMessage*)pOS_GetMsg(&Port)) {
- Req=Msg->nm_NReq;
- printf("Notification: <%s> Code=%ld\n",Req->nr_FullName,Msg->nm_Code);
- pOS_ReplyMsg(&Msg->nm_Message);
- }
- }
-
-
- for(i=0; i<Num; ++i) {
- if(Notify[i].nr_Name) pOS_DestructDosNotify(&Notify[i]);
- }
-
- printf("Notification is removed.\n");
-
- pOS_DestructMsgPort(&Port);
- pOS_FreeMem(Notify,sizeof(pOS_DosNotifyReq)*Num);
- }
- else printf("No Mem\n");
-
- pOS_DeleteDosArgs(Args);
- }
- }
-
-
-