From: Waldemar Schultz Newsgroups: comp.os.msdos.djgpp Subject: Fool_Proof Date: Tue, 02 Nov 1999 12:37:52 +0100 Organization: [posted via] Leibniz-Rechenzentrum, Muenchen (Germany) Lines: 72 Distribution: world Message-ID: <381ECD10.8D177FC8@ma.tum.de> NNTP-Posting-Host: pcritter1.mathematik.tu-muenchen.de Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Mailer: Mozilla 4.6 [de] (Win95; I) X-Accept-Language: de,en-US To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com I used to use some code as posted below for intercept certain events under my old Symantec-C / Zortech-C platform. Now I'd like to have a similar functionality with DJGPP. I was reading the manuals/FAQ's but the only thing I found, was how to intercept CONTROL_C using signal(); Any hints ? Thank you. ===================================================== #include #include #include #include #define INT_PRT_SCR 0x05 /* PrintScreen [Druck] */ #define INT_CNTRL_P 0x17 /* Control-P [Strg-P] */ #define INT_C_BREAK 0x1B /* Control-Break [Strg-Pause] */ #define INT_CNTRL_C 0x23 /* Control-C | -2(???) [Strg-C | -2 (???)] */ #if 0 #define INT_PAUSE 0x?? /*Pause (or ^S) HOW TO ??*/ #endif int Intoff=0; int do_ctrl(struct INT_DATA *pd) { pd=pd; return 1; //rti } /*this should intercept EVERYTHING that could crash/hang/abort the program */ void Int_Off(void) { if(Intoff) return; int_intercept(INT_CNTRL_P,do_ctrl, 0); int_intercept(INT_PRT_SCR,do_ctrl, 0); int_intercept(INT_C_BREAK,do_ctrl, 0); int_intercept(INT_CNTRL_C,do_ctrl, 0); /* more stuff ?? */ Intoff=1; } /* this should restore EVERYTHING to it's initial state */ void Int_On(void) { if(!Intoff) return; int_restore (INT_CNTRL_C); int_restore (INT_C_BREAK); int_restore (INT_CNTRL_P); int_restore (INT_PRT_SCR); /* more stuff ?? */ Intoff=0; } int main(void) { int c=0; Int_Off(); do { if(kbhit()) c=getch(); printf("."); fflush(stdout); /* any action */ } while(c!='\x1b'); /*Escape*/ Int_On(); return 0; } -- Gruss Waldemar Schultz. Technische Universität München, Zentrum Mathematik M1, D 80290 München Tel: +49 (0)89 2892 8226 FAX: +49 (0)89 2892 8228