Skip to content

AFNI/NIfTI Server

Sections
Personal tools
You are here: Home » AFNI » Documentation

Doxygen Source Code Documentation


Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals   Search  

main.c

Go to the documentation of this file.
00001 #include "stdlib.h"
00002 /* STARTUP PROCEDURE FOR UNIX FORTRAN PROGRAMS */
00003 
00004 #include "stdio.h"
00005 #include "signal.h"
00006 
00007 #ifndef SIGIOT
00008 #ifdef SIGABRT
00009 #define SIGIOT SIGABRT
00010 #endif
00011 #endif
00012 
00013 #ifndef KR_headers
00014 #undef VOID
00015 #include "stdlib.h"
00016 #endif
00017 
00018 #ifndef VOID
00019 #define VOID void
00020 #endif
00021 
00022 #ifdef __cplusplus
00023 extern "C" {
00024 #endif
00025 
00026 #ifdef NO__STDC
00027 #define ONEXIT onexit
00028 extern VOID f_exit();
00029 #else
00030 #ifndef KR_headers
00031 extern void f_exit(void);
00032 #ifndef NO_ONEXIT
00033 #define ONEXIT atexit
00034 extern int atexit(void (*)(void));
00035 #endif
00036 #else
00037 #ifndef NO_ONEXIT
00038 #define ONEXIT onexit
00039 extern VOID f_exit();
00040 #endif
00041 #endif
00042 #endif
00043 
00044 #ifdef KR_headers
00045 extern VOID f_init(), sig_die();
00046 extern int MAIN__();
00047 #define Int /* int */
00048 #else
00049 extern void f_init(void), sig_die(char*, int);
00050 extern int MAIN__(void);
00051 #define Int int
00052 #endif
00053 
00054 static VOID sigfdie(Int n)
00055 {
00056 sig_die("Floating Exception", 1);
00057 }
00058 
00059 
00060 static VOID sigidie(Int n)
00061 {
00062 sig_die("IOT Trap", 1);
00063 }
00064 
00065 #ifdef SIGQUIT
00066 static VOID sigqdie(Int n)
00067 {
00068 sig_die("Quit signal", 1);
00069 }
00070 #endif
00071 
00072 
00073 static VOID sigindie(Int n)
00074 {
00075 sig_die("Interrupt", 0);
00076 }
00077 
00078 static VOID sigtdie(Int n)
00079 {
00080 sig_die("Killed", 0);
00081 }
00082 
00083 #ifdef SIGTRAP
00084 static VOID sigtrdie(Int n)
00085 {
00086 sig_die("Trace trap", 1);
00087 }
00088 #endif
00089 
00090 
00091 int xargc;
00092 char **xargv;
00093 
00094 #ifdef KR_headers
00095 main(argc, argv) int argc; char **argv;
00096 #else
00097 main(int argc, char **argv)
00098 #endif
00099 {
00100 xargc = argc;
00101 xargv = argv;
00102 signal(SIGFPE, sigfdie);        /* ignore underflow, enable overflow */
00103 #ifdef SIGIOT
00104 signal(SIGIOT, sigidie);
00105 #endif
00106 #ifdef SIGTRAP
00107 signal(SIGTRAP, sigtrdie);
00108 #endif
00109 #ifdef SIGQUIT
00110 if(signal(SIGQUIT,sigqdie) == SIG_IGN)
00111         signal(SIGQUIT, SIG_IGN);
00112 #endif
00113 if(signal(SIGINT, sigindie) == SIG_IGN)
00114         signal(SIGINT, SIG_IGN);
00115 signal(SIGTERM,sigtdie);
00116 
00117 #ifdef pdp11
00118         ldfps(01200); /* detect overflow as an exception */
00119 #endif
00120 
00121 f_init();
00122 #ifndef NO_ONEXIT
00123 ONEXIT(f_exit);
00124 #endif
00125 MAIN__();
00126 #ifdef NO_ONEXIT
00127 f_exit();
00128 #endif
00129 exit(0);        /* exit(0) rather than return(0) to bypass Cray bug */
00130 return 0;       /* For compilers that complain of missing return values; */
00131                 /* others will complain that this is unreachable code. */
00132 }
00133 #ifdef __cplusplus
00134         }
00135 #endif
 

Powered by Plone

This site conforms to the following standards: