📄 error.c
字号:
#include <phigs.h> /* get HP-PHIGS definitions for C */#include <stdio.h> /* get standard I/O definitions */main() /* file "Error.c" */{ Pint WorkstnID = 1; /* workstation identifier */ Pint ConnID; /* connection identifier */ Pint WorkstnType = POIDDX; /* out/in, direct, dbl bfr, Xwindow */ static Plimit BadLimits = /* deliberately illegal values */ {0.0, 0.0, 0.0, 0.0}; Pint ErrorRtn; /* returned from "pescape_u700" */ void MyErrorHandler(); /* forward reference */ void (*OldHandler)(); /* pointer for previous handler */ popen_phigs((char *) stderr, 0); /* errors go to "stderr" */ pescape_u4("/dev/screen/phigs_window", &ConnID); popen_ws(WorkstnID, (void *) ConnID, WorkstnType); /*--- make an error with the default error-handler in effect -----------*/ printf("--- Default error-handler in effect -------------------------\n"); pset_ws_win(WorkstnID, &BadLimits); /*--- turn off error handling completely -------------------------------*/ printf("--- No error-handler in effect ------------------------------\n"); pset_err_hand_mode(PERR_OFF); pset_ws_win(WorkstnID, &BadLimits); /*--- install custom error-handler and make error again ----------------*/ printf("--- Custom error-handler in effect --------------------------\n"); pset_err_hand_mode(PERR_ON); pset_err_hand(MyErrorHandler, &OldHandler); /* replace handler */ pset_ws_win(WorkstnID, &BadLimits); pclose_ws(WorkstnID); pclose_phigs();}/****************************************************************************/void MyErrorHandler(ErrorNo, FuncID, ErrorFile)int *ErrorNo; /* which error happened? */ int *FuncID; /* which routine had the error? */void *ErrorFile; /* print error messages where? */{ printf("MyErrorHandler: Error %d occurred in routine %d.\n", *ErrorNo, *FuncID); printf("My own call to the ERROR LOGGING routine (perr_log):\n"); perr_log(*ErrorNo, *FuncID, ErrorFile);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -