/***********************************************************************/ /* Open Visualization Data Explorer */ /* (C) Copyright IBM Corp. 1989,1999 */ /* ALL RIGHTS RESERVED */ /* This code licensed under the */ /* "IBM PUBLIC LICENSE - Open Visualization Data Explorer" */ /***********************************************************************/ /* * $Header: /home/gda/dxcvs/dx/src/exec/dxmods/keyin.c,v 1.3 1999/05/10 15:45:27 gda Exp $ */ #include /*** MODULE: KeyIn SHORTDESCRIPTION: Stops execution until an Enter keystroke is received. CATEGORY: Debugging INPUTS: string; String; Type to continue; message to print OUTPUTS: BUGS: this routine only works in completely serial mode (-S). AUTHOR: nancy s collins END: ***/ #include #include static char defmessage[] = "Type to continue"; int m_KeyIn(Object *in, Object *out) { int fh; char c, *s; if(in[0]) { if(!DXExtractString(in[0], &s)) { DXSetError(ERROR_BAD_PARAMETER, "#10200", "prompt"); return NULL; } } else s = defmessage; #ifdef DXD_OS_NON_UNIX _cprintf("%s", s); /* { char tmpStr[1024]; _cgets(tmpStr); } */ while(1) { c = getche(); if( c == '\n' || c == 13) break; } putch('\n'); #else fh = open("/dev/tty", 2); if (fh < 0) { DXSetError(ERROR_INVALID_DATA, "cannot open /dev/tty"); return NULL; } write(fh, s, strlen(s)); do { read(fh, &c, 1); } while(c != '\n'); close(fh); #endif return OK; }