1 /*------------------------------------------------------------\
7 | Author : Picault Stephane |
10 \------------------------------------------------------------*/
18 #include <Xm/FileSB.h>
19 #include <Xm/SelectioB.h>
20 #include <Xm/PushBG.h>
27 #include <sys/types.h>
47 #include "XMT_panel.h"
52 #include "XME_panel.h"
56 #include "XYA_cgvfig.h"
58 extern xyagzoom
*XyagHeadZoom
;
60 static void (*XyagOldExitHandler
) () = NULL
;
66 sigjmp_buf XyagMyEnv
;
67 sigjmp_buf
*XyagJmpEnv
= NULL
;
68 void XyagSetJmpEnv(sigjmp_buf
*buf
)
73 /*------------------------------------------------------------\
75 \------------------------------------------------------------*/
76 void XyagInitFileErr()
81 if (XyagCallbackFileQuitFonction
!= NULL
) return;
83 if (pipe( xya_pfd
) != -1)
90 if (pipe( xya_out
) != -1)
99 /*------------------------------------------------------------\
100 | XyagGetWarningMess |
101 \------------------------------------------------------------*/
102 void XyagGetWarningMess( )
108 if (XYADEBUG
) return;
109 if (XyagCallbackFileQuitFonction
!= NULL
) {
110 XyagGetWarningFunction ();
114 fprintf(stderr
,"\n") ;
116 i
= read(xya_pfd
[0],buffer
,4096) ;
124 while((isspace((int)*pt
) != 0) && (*pt
!= '\0'))
130 XyagWarningMessage( XyagMainWindow
, pt
);
135 /*------------------------------------------------------------\
137 \------------------------------------------------------------*/
141 MBK_EXIT_KILL
= 'N' ;
145 /*------------------------------------------------------------\
147 \------------------------------------------------------------*/
148 void XyagFirePasqua()
153 if(XyagCallbackFileQuitFonction
!= NULL
) {
154 XyagSetJmpEnv (NULL
);
155 XyagFirePasquaFunction ();
158 /*-------------------*/
159 /* Clean up the pipe */
160 /*-------------------*/
161 while ((nb
!= -1) && (nb
!= 0))
163 XyagSetBlock( xya_pfd
[0], False
);
164 nb
= read(xya_pfd
[0], &c
, 1);
168 while ((nb
!= -1) && (nb
!= 0))
170 XyagSetBlock( xya_out
[0], False
);
171 nb
= read(xya_out
[0], &c
, 1);
174 signal(SIGTERM
, XyagOldExitHandler
);
179 /*------------------------------------------------------------\
180 | XyagFatalAppError |
181 \------------------------------------------------------------*/
182 void XyagFatalAppError( message
)
185 //XtasDestroyAllFig() ;
187 XyagErrorMessage( XyagMainWindow
, message
);
188 siglongjmp(XyagMyEnv
, 1);
191 /*------------------------------------------------------------\
192 | XyagGetStdoutMess |
193 \------------------------------------------------------------*/
194 void XyagGetStdoutMess()
196 static char buffer
[4096];
200 i
= read(xya_pfd
[0],buffer
,4096) ;
203 if(strlen(buffer
) == 0)
207 strcpy(buffer
,"Fatal Error Occuring While Reading File") ;
209 XyagFatalAppError(buffer
) ;
216 /*------------------------------------------------------------\
218 \------------------------------------------------------------*/
219 void XyagSetBlock( fd
, on
)
222 static int blockf
, nonblockf
;
223 static int first
= True
;
229 if ((flags
= fcntl(fd
, F_GETFL
, 0)) == -1)
231 fprintf(stderr
,"ERREUR FCNTL\n");fflush(stderr
);
234 blockf
= flags
& ~O_NDELAY
;
235 blockf
= flags
& ~O_NONBLOCK
;
236 nonblockf
= flags
| O_NDELAY
;
237 nonblockf
= flags
| O_NONBLOCK
;
240 if (fcntl(fd
, F_SETFL
, on
? blockf
: nonblockf
) == -1)
242 fprintf(stderr
,"ERREUR FCNTL\n");fflush(stderr
);
246 /*------------------------------------------------------------\
248 \------------------------------------------------------------*/
251 /*---------------------------------*/
252 /* Catch all stdout messages !!! */
253 /*---------------------------------*/
254 if(XyagCallbackFileQuitFonction
!= NULL
) {
255 XyagPasquaFunction ();
258 XyagSetBlock( 2, False
);
259 XyagSetBlock( 1, False
);
260 XyagOldExitHandler
= signal( SIGTERM
, XyagGetStdoutMess
);
263 void updatebacklist(cgvfig_list
*cgvf
)
265 chain_list
*cl
=OPEN_STACK
, *ch
;
266 if (OPEN_STACK
==NULL
) return;
269 OPEN_STACK
=OPEN_STACK
->NEXT
; cl
->NEXT
=NULL
;
276 while (cl
->NEXT
!=NULL
&& cl
->NEXT
->DATA
!=cgvf
)
282 void *sel
, *con
, *zoom
;
287 XyagHeadConnect
=cgvf
->data0
;
288 XyagHeadSelect
=cgvf
->data1
;
289 XyagHeadZoom
=cgvf
->data_ZOOM
;
295 ch
=cl
->NEXT
;cl
->NEXT
=ch
->NEXT
; ch
->NEXT
=NULL
;
302 // else printf("not found??!!\n");