Check for SYS/GL during library init. Reason is that
[AROS.git] / workbench / network / stacks / AROSTCP / MUI.MiamiPanel / muimiamipanel_funcs.c
blobe423b41369934d82e8891e51638558a0d4287ac8
1 /*
2 Copyright © 2002-2003, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <proto/exec.h>
7 #include <proto/intuition.h>
8 #include <proto/dos.h>
10 #include <dos/dostags.h>
12 #include <proto/alib.h>
14 #include "muimiamipanel_intern.h"
15 #include "muimiamipanel_commands.h"
16 #include "muimiamipanel_message.h"
18 extern void MiamiPanelProc(STRPTR argPtr, ULONG argSize);
19 extern void DoCommand(struct MiamiPanelBase_intern *MiamiPanelBaseIntern, ULONG id,...);
21 /*****************************************************************************
23 NAME */
24 AROS_LH8(LONG, MiamiPanelInit,
26 /* SYNOPSIS */
27 AROS_LHA(IPTR, synccb, A0),
28 AROS_LHA(IPTR, asynccb, A1),
29 AROS_LHA(LONG, flags, D0),
30 AROS_LHA(STRPTR, font, A2),
31 AROS_LHA(STRPTR, screen, A3),
32 AROS_LHA(LONG, xo, D1),
33 AROS_LHA(LONG, yo, D2),
34 AROS_LHA(IPTR, sigbit, A4),
36 /* LOCATION */
37 struct Library *, MiamiPanelBase, 5, MiamiPanel)
39 /* FUNCTION
41 INPUTS
43 RESULT
45 NOTES
47 EXAMPLE
49 BUGS
51 SEE ALSO
53 INTERNALS
55 *****************************************************************************/
57 AROS_LIBFUNC_INIT
58 struct MiamiPanelBase_intern *MiamiPanelBaseIntern = MiamiPanelBase;
60 D(bug("[MiamiPanel] MiamiPanelInit()\n"));
62 struct MsgPort reply;
63 struct Process *proc = NULL;
64 long res;
65 int sig;
67 struct TagItem tags[] = {NP_Entry, 0,
68 #ifdef __MORPHOS__
69 NP_CodeType, CODETYPE_PPC,
70 NP_PPCStackSize, 32000,
71 #endif
72 NP_UserData, MiamiPanelBaseIntern,
73 NP_StackSize, 16000,
74 NP_Name, (ULONG)DEF_Base,
75 NP_CopyVars, FALSE,
76 NP_Input, NULL,
77 NP_CloseInput, FALSE,
78 NP_Output, NULL,
79 NP_CloseOutput, FALSE,
80 NP_Error, NULL,
81 NP_CloseError, FALSE,
82 NP_CurrentDir, NULL,
83 NP_HomeDir, NULL,
84 TAG_DONE};
86 ObtainSemaphore(&MiamiPanelBaseIntern->mpb_libSem);
88 if (!AttemptSemaphore(&MiamiPanelBaseIntern->mpb_procSem))
90 ReleaseSemaphore(&MiamiPanelBaseIntern->mpb_libSem);
91 return 0;
94 ReleaseSemaphore(&MiamiPanelBaseIntern->mpb_procSem);
96 if ((sig = AllocSignal(-1))<0)
98 ReleaseSemaphore(&MiamiPanelBaseIntern->mpb_libSem);
99 return 0;
102 tags[0].ti_Data = (ULONG)MiamiPanelProc;
104 if (proc = CreateNewProcTagList(tags))
106 struct MPS_AppMsg msg;
108 INITPORT(&reply,sig);
109 INITMESSAGE(&msg, &reply, sizeof(msg));
110 msg.flags = flags;
112 MiamiPanelBaseIntern->mpb_synccb = synccb;
113 MiamiPanelBaseIntern->mpb_asynccb = asynccb;
115 Forbid();
116 MiamiPanelBaseIntern->mpb_use++;
117 Permit();
119 PutMsg(&proc->pr_MsgPort, (struct Message *)&msg);
120 WaitPort(&reply);
122 // *sigbit = 0;
123 res = msg.res;
125 else res = 0;
127 FreeSignal(sig);
129 ReleaseSemaphore(&MiamiPanelBaseIntern->mpb_libSem);
131 return res;
133 AROS_LIBFUNC_EXIT
135 } /* MiamiPanelInit */
138 /*****************************************************************************
140 NAME */
141 AROS_LH0(void, MiamiPanelCleanup,
143 /* SYNOPSIS */
145 /* LOCATION */
146 struct Library *, MiamiPanelBase, 6, MiamiPanel)
148 /* FUNCTION
150 INPUTS
152 RESULT
154 NOTES
156 EXAMPLE
158 BUGS
160 SEE ALSO
162 INTERNALS
164 *****************************************************************************/
166 AROS_LIBFUNC_INIT
167 struct MiamiPanelBase_intern *MiamiPanelBaseIntern = MiamiPanelBase;
169 D(bug("[MiamiPanel] MiamiPanelCleanup()\n"));
171 DoCommand(MiamiPanelBaseIntern, MPV_Msg_Type_Cleanup);
173 ObtainSemaphore(&MiamiPanelBaseIntern->mpb_procSem);
174 ReleaseSemaphore(&MiamiPanelBaseIntern->mpb_procSem);
176 AROS_LIBFUNC_EXIT
178 } /* MiamiPanelCleanup */
180 /*****************************************************************************
182 NAME */
183 AROS_LH5(void, MiamiPanelAddInterface,
185 /* SYNOPSIS */
186 AROS_LHA(LONG, unit, D0),
187 AROS_LHA(STRPTR, name, A0),
188 AROS_LHA(LONG, state, D1),
189 AROS_LHA(LONG, ontime, D2),
190 AROS_LHA(STRPTR, speed, A1),
192 /* LOCATION */
193 struct Library *, MiamiPanelBase, 7, MiamiPanel)
195 /* FUNCTION
197 INPUTS
199 RESULT
201 NOTES
203 EXAMPLE
205 BUGS
207 SEE ALSO
209 INTERNALS
211 *****************************************************************************/
213 AROS_LIBFUNC_INIT
214 struct MiamiPanelBase_intern *MiamiPanelBaseIntern = MiamiPanelBase;
216 D(bug("[MiamiPanel] MiamiPanelAddInterface()\n"));
218 DoCommand(MiamiPanelBaseIntern, MPV_Msg_Type_AddInterface,unit,name,state,ontime,speed);
220 AROS_LIBFUNC_EXIT
222 } /* MiamiPanelAddInterface */
224 /*****************************************************************************
226 NAME */
227 AROS_LH1(void, MiamiPanelDelInterface,
229 /* SYNOPSIS */
230 AROS_LHA(LONG, unit, D0),
232 /* LOCATION */
233 struct Library *, MiamiPanelBase, 8, MiamiPanel)
235 /* FUNCTION
237 INPUTS
239 RESULT
241 NOTES
243 EXAMPLE
245 BUGS
247 SEE ALSO
249 INTERNALS
251 *****************************************************************************/
253 AROS_LIBFUNC_INIT
254 struct MiamiPanelBase_intern *MiamiPanelBaseIntern = MiamiPanelBase;
256 D(bug("[MiamiPanel] MiamiPanelDelInterface()\n"));
258 DoCommand(MiamiPanelBaseIntern, MPV_Msg_Type_DelInterface,unit);
260 AROS_LIBFUNC_EXIT
262 } /* MiamiPanelDelInterface */
264 /*****************************************************************************
266 NAME */
267 AROS_LH3(void, MiamiPanelSetInterfaceState,
269 /* SYNOPSIS */
270 AROS_LHA(LONG, unit, D0),
271 AROS_LHA(LONG, state, D1),
272 AROS_LHA(LONG, ontime, D2),
274 /* LOCATION */
275 struct Library *, MiamiPanelBase, 9, MiamiPanel)
277 /* FUNCTION
279 INPUTS
281 RESULT
283 NOTES
285 EXAMPLE
287 BUGS
289 SEE ALSO
291 INTERNALS
293 *****************************************************************************/
295 AROS_LIBFUNC_INIT
296 struct MiamiPanelBase_intern *MiamiPanelBaseIntern = MiamiPanelBase;
298 D(bug("[MiamiPanel] MiamiPanelSetInterfaceState()\n"));
300 DoCommand(MiamiPanelBaseIntern, MPV_Msg_Type_SetInterfaceState,unit,state,ontime);
302 AROS_LIBFUNC_EXIT
304 } /* MiamiPanelSetInterfaceState */
306 /*****************************************************************************
308 NAME */
309 AROS_LH2(void, MiamiPanelSetInterfaceSpeed,
311 /* SYNOPSIS */
312 AROS_LHA(LONG, unit, D0),
313 AROS_LHA(UBYTE *, speed, A0),
315 /* LOCATION */
316 struct Library *, MiamiPanelBase, 10, MiamiPanel)
318 /* FUNCTION
320 INPUTS
322 RESULT
324 NOTES
326 EXAMPLE
328 BUGS
330 SEE ALSO
332 INTERNALS
334 *****************************************************************************/
336 AROS_LIBFUNC_INIT
337 struct MiamiPanelBase_intern *MiamiPanelBaseIntern = MiamiPanelBase;
339 D(bug("[MiamiPanel] MiamiPanelSetInterfaceSpeed()\n"));
341 DoCommand(MiamiPanelBaseIntern, MPV_Msg_Type_SetInterfaceSpeed,unit,speed);
343 AROS_LIBFUNC_EXIT
345 } /* MiamiPanelSetInterfaceSpeed */
347 /*****************************************************************************
349 NAME */
350 AROS_LH5(void, MiamiPanelInterfaceReport,
352 /* SYNOPSIS */
353 AROS_LHA(LONG, unit, D0),
354 AROS_LHA(LONG, rate, D1),
355 AROS_LHA(LONG, now, D2),
356 AROS_LHA(LONG, totalhi, D3),
357 AROS_LHA(ULONG, totallo, D4),
359 /* LOCATION */
360 struct Library *, MiamiPanelBase, 11, MiamiPanel)
362 /* FUNCTION
364 INPUTS
366 RESULT
368 NOTES
370 EXAMPLE
372 BUGS
374 SEE ALSO
376 INTERNALS
378 *****************************************************************************/
380 AROS_LIBFUNC_INIT
381 struct MiamiPanelBase_intern *MiamiPanelBaseIntern = MiamiPanelBase;
383 D(bug("[MiamiPanel] MiamiPanelInterfaceReport()\n"));
385 if (unit>=0)
386 DoCommand(MiamiPanelBaseIntern, MPV_Msg_Type_InterfaceReport,unit,rate,now,totalhi,totallo);
388 AROS_LIBFUNC_EXIT
390 } /* MiamiPanelInterfaceReport */
392 /*****************************************************************************
394 NAME */
395 AROS_LH0(void, MiamiPanelToFront,
397 /* SYNOPSIS */
399 /* LOCATION */
400 struct Library *, MiamiPanelBase, 12, MiamiPanel)
402 /* FUNCTION
404 INPUTS
406 RESULT
408 NOTES
410 EXAMPLE
412 BUGS
414 SEE ALSO
416 INTERNALS
418 *****************************************************************************/
420 AROS_LIBFUNC_INIT
421 struct MiamiPanelBase_intern *MiamiPanelBaseIntern = MiamiPanelBase;
423 D(bug("[MiamiPanel] MiamiPanelToFront()\n"));
425 DoCommand(MiamiPanelBaseIntern, MPV_Msg_Type_ToFront);
427 AROS_LIBFUNC_EXIT
429 } /* MiamiPanelToFront */
431 /*****************************************************************************
433 NAME */
434 AROS_LH1(void, MiamiPanelInhibitRefresh,
436 /* SYNOPSIS */
437 AROS_LHA(LONG, val, D0),
439 /* LOCATION */
440 struct Library *, MiamiPanelBase, 13, MiamiPanel)
442 /* FUNCTION
444 INPUTS
446 RESULT
448 NOTES
450 EXAMPLE
452 BUGS
454 SEE ALSO
456 INTERNALS
458 *****************************************************************************/
460 AROS_LIBFUNC_INIT
461 struct MiamiPanelBase_intern *MiamiPanelBaseIntern = MiamiPanelBase;
463 D(bug("[MiamiPanel] MiamiPanelInhibitRefresh()\n"));
465 DoCommand(MiamiPanelBaseIntern, MPV_Msg_Type_InhibitRefresh,val);
467 AROS_LIBFUNC_EXIT
469 } /* MiamiPanelInhibitRefresh */
471 /*****************************************************************************
473 NAME */
474 AROS_LH2(void, MiamiPanelGetCoord,
476 /* SYNOPSIS */
477 AROS_LHA(LONG *, xp, A0),
478 AROS_LHA(LONG *, yp, A1),
480 /* LOCATION */
481 struct Library *, MiamiPanelBase, 14, MiamiPanel)
483 /* FUNCTION
485 INPUTS
487 RESULT
489 NOTES
491 EXAMPLE
493 BUGS
495 SEE ALSO
497 INTERNALS
499 *****************************************************************************/
501 AROS_LIBFUNC_INIT
502 struct MiamiPanelBase_intern *MiamiPanelBaseIntern = MiamiPanelBase;
504 D(bug("[MiamiPanel] MiamiPanelGetCoord()\n"));
506 *xp = *yp = 0;
508 AROS_LIBFUNC_EXIT
510 } /* MiamiPanelGetCoord */
512 /*****************************************************************************
514 NAME */
515 AROS_LH1(void, MiamiPanelEvent,
517 /* SYNOPSIS */
518 AROS_LHA(ULONG, sigs, D0),
520 /* LOCATION */
521 struct Library *, MiamiPanelBase, 15, MiamiPanel)
523 /* FUNCTION
525 INPUTS
527 RESULT
529 NOTES
531 EXAMPLE
533 BUGS
535 SEE ALSO
537 INTERNALS
539 *****************************************************************************/
541 AROS_LIBFUNC_INIT
542 struct MiamiPanelBase_intern *MiamiPanelBaseIntern = MiamiPanelBase;
544 D(bug("[MiamiPanel] MiamiPanelEvent()\n"));
546 AROS_LIBFUNC_EXIT
548 } /* MiamiPanelEvent */
550 /*****************************************************************************
552 NAME */
553 AROS_LH2(void, MiamiPanelRefreshName,
555 /* SYNOPSIS */
556 AROS_LHA(LONG, unit, D0),
557 AROS_LHA(UBYTE *, name, A0),
559 /* LOCATION */
560 struct Library *, MiamiPanelBase, 16, MiamiPanel)
562 /* FUNCTION
564 INPUTS
566 RESULT
568 NOTES
570 EXAMPLE
572 BUGS
574 SEE ALSO
576 INTERNALS
578 *****************************************************************************/
580 AROS_LIBFUNC_INIT
581 struct MiamiPanelBase_intern *MiamiPanelBaseIntern = MiamiPanelBase;
583 D(bug("[MiamiPanel] MiamiPanelRefreshName()\n"));
585 DoCommand(MiamiPanelBaseIntern, MPV_Msg_Type_RefreshName,unit,name);
587 AROS_LIBFUNC_EXIT
589 } /* MiamiPanelRefreshName */
591 /*****************************************************************************
593 NAME */
594 AROS_LH0(LONG, MiamiPanelGetVersion,
596 /* SYNOPSIS */
598 /* LOCATION */
599 struct Library *, MiamiPanelBase, 17, MiamiPanel)
601 /* FUNCTION
603 INPUTS
605 RESULT
607 NOTES
609 EXAMPLE
611 BUGS
613 SEE ALSO
615 INTERNALS
617 *****************************************************************************/
619 AROS_LIBFUNC_INIT
620 struct MiamiPanelBase_intern *MiamiPanelBaseIntern = MiamiPanelBase;
622 D(bug("[MiamiPanel] MiamiPanelGetVersion()\n"));
624 return 1;
626 AROS_LIBFUNC_EXIT
628 } /* MiamiPanelGetVersion */
630 /*****************************************************************************
632 NAME */
633 AROS_LH0(ULONG, MiamiPanelKill,
635 /* SYNOPSIS */
637 /* LOCATION */
638 struct Library *, MiamiPanelBase, 26, MiamiPanel)
640 /* FUNCTION
642 INPUTS
644 RESULT
646 NOTES
648 EXAMPLE
650 BUGS
652 SEE ALSO
654 INTERNALS
656 *****************************************************************************/
658 AROS_LIBFUNC_INIT
659 struct MiamiPanelBase_intern *MiamiPanelBaseIntern = MiamiPanelBase;
661 D(bug("[MiamiPanel] MiamiPanelKill()\n"));
663 ObtainSemaphore(&MiamiPanelBaseIntern->mpb_libSem);
665 if (AttemptSemaphore(&MiamiPanelBaseIntern->mpb_procSem))
667 ReleaseSemaphore(&MiamiPanelBaseIntern->mpb_procSem);
668 ReleaseSemaphore(&MiamiPanelBaseIntern->mpb_libSem);
669 return FALSE;
672 if (MiamiPanelBaseIntern->mpb_app)
674 DoMethod(MiamiPanelBaseIntern->mpb_app,MUIM_Application_PushMethod,(ULONG)MiamiPanelBaseIntern->mpb_app,2,MUIM_Application_ReturnID,MUIV_Application_ReturnID_Quit);
676 Delay(200);
678 if (AttemptSemaphore(&MiamiPanelBaseIntern->mpb_procSem))
680 ReleaseSemaphore(&MiamiPanelBaseIntern->mpb_procSem);
681 ReleaseSemaphore(&MiamiPanelBaseIntern->mpb_libSem);
682 return FALSE;
686 memset(&MiamiPanelBaseIntern->mpb_procSem,0,sizeof(&MiamiPanelBaseIntern->mpb_procSem));
687 InitSemaphore(&MiamiPanelBaseIntern->mpb_procSem);
688 if (MiamiPanelBaseIntern->mpb_port) DeleteMsgPort(MiamiPanelBaseIntern->mpb_port);
689 MiamiPanelBaseIntern->mpb_port = NULL;
690 MiamiPanelBaseIntern->mpb_app = NULL;
692 ReleaseSemaphore(&MiamiPanelBaseIntern->mpb_libSem);
694 return TRUE;
696 AROS_LIBFUNC_EXIT
698 } /* MiamiPanelKill */