00001 /* 00002 * Copyright 2004 PathScale, Inc. All Rights Reserved. 00003 */ 00004 00005 /* 00006 00007 Copyright (C) 2000, 2001, Silicon Graphics, Inc. All Rights Reserved. 00008 00009 This program is free software; you can redistribute it and/or modify it 00010 under the terms of version 2.1 of the GNU Lesser General Public License 00011 as published by the Free Software Foundation. 00012 00013 This program is distributed in the hope that it would be useful, but 00014 WITHOUT ANY WARRANTY; without even the implied warranty of 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00016 00017 Further, this software is distributed without any warranty that it is 00018 free of the rightful claim of any third person regarding infringement 00019 or the like. Any license provided herein, whether implied or 00020 otherwise, applies only to this software file. Patent licenses, if 00021 any, provided herein do not apply to combinations of this program with 00022 other software, or any other product whatsoever. 00023 00024 You should have received a copy of the GNU Lesser General Public 00025 License along with this program; if not, write the Free Software 00026 Foundation, Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, 00027 USA. 00028 00029 Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pky, 00030 Mountain View, CA 94043, or: 00031 00032 http://www.sgi.com 00033 00034 For further information regarding this notice, see: 00035 00036 http://oss.sgi.com/projects/GenInfo/NoticeExplan 00037 00038 */ 00039 00040 00041 00042 #pragma ident "@(#) libf/fort/pause.c 92.1 06/24/99 10:18:36" 00043 #include <errno.h> 00044 #include <fortran.h> 00045 #include <signal.h> 00046 #include <stdio.h> 00047 #include <unistd.h> 00048 #include <stdlib.h> 00049 #include "fio.h" 00050 00051 #define MAX_PAS_LEN 80 /* Maximum message length for PAUSE */ 00052 #define PAUSESIG 15 /* Signal used to restart a PAUSEd process */ 00053 00054 /* 00055 * $PAUSE CF77 entry point to process Fortran PAUSE statement 00056 * 00057 * _PAUSE F90 entry point to process Fortran PAUSE statement 00058 * 00059 * Argument 00060 * 00061 * s Fortran character string for the optional "stop code". 00062 * Note that Fortran accepts a digit string or a 00063 * character string for the stop code. The compiler 00064 * converts a digit string (integer) to a character 00065 * string before calling _PAUSE/$PAUSE. 00066 * 00067 * CF77 5.0 and later passes an FCD with 0 length 00068 * if the user omitted the stop code. 00069 * 00070 * F90 passes an FCD for ' ' if the user omitted the 00071 * stop code. 00072 */ 00073 #ifdef _UNICOS 00074 #pragma _CRI duplicate _PAUSE as $PAUSE 00075 #endif 00076 00077 void 00078 _PAUSE(_fcd s) 00079 { 00080 int len; 00081 void _waitpause(); 00082 char *msg; 00083 00084 #ifdef _UNICOS 00085 if (_numargs() == 0) { 00086 msg = ""; 00087 len = 0; 00088 } 00089 else 00090 #endif 00091 { 00092 msg = _fcdtocp(s); 00093 len = _fcdlen(s); 00094 00095 if (len > MAX_PAS_LEN) 00096 len = MAX_PAS_LEN; 00097 } 00098 00099 (void) fprintf(errfile, " PAUSE %.*s\n", len, msg); 00100 (void) fprintf(errfile, " To resume execution, type: "); 00101 00102 if (isatty(fileno(stdin))) { 00103 00104 (void) fprintf(errfile, "go\n"); 00105 (void) fprintf(errfile, 00106 " Any other input will terminate the program\n"); 00107 00108 if (getchar() != 'g' || getchar() != 'o' || getchar() != '\n') { 00109 (void) fprintf(errfile, " STOP\n"); 00110 exit(0); 00111 } 00112 } 00113 else { 00114 (void) fprintf(errfile, "kill -%d %d\n", PAUSESIG, getpid()); 00115 signal(PAUSESIG, _waitpause); 00116 pause(); /* The pause that refreshes */ 00117 } 00118 00119 (void) fprintf(errfile, " Execution resumed after PAUSE\n"); 00120 } 00121 00122 void 00123 _waitpause() 00124 { 00125 return; 00126 }
1.5.6