2 Copyright © 1995-2006, The AROS Development Team. All rights reserved.
6 /*********************************************************************************************/
11 #include <libraries/coolimages.h>
12 #include <aros/debug.h>
14 #include <zune/clock.h>
15 #include <zune/calendar.h>
17 #include <stdlib.h> /* for exit() */
21 /*********************************************************************************************/
23 #define ARG_TEMPLATE "FROM,EDIT/S,USE/S,SAVE/S,PUBSCREEN/K"
29 #define ARG_PUBSCREEN 4
33 #define RETURNID_USE 1
34 #define RETURNID_SAVE 2
36 /*********************************************************************************************/
47 {&IntuitionBase
, "intuition.library" , 39, TRUE
},
48 {&GfxBase
, "graphics.library" , 40, TRUE
}, /* 40, because of WriteChunkyPixels */
49 {&UtilityBase
, "utility.library" , 39, TRUE
},
50 {&IFFParseBase
, "iffparse.library" , 39, TRUE
},
51 {&MUIMasterBase
, "muimaster.library" , 0 , TRUE
},
55 /*********************************************************************************************/
57 static struct RDArgs
*myargs
;
58 static IPTR args
[NUM_ARGS
];
60 /*********************************************************************************************/
62 static void CloseLibs(void);
63 static void FreeArguments(void);
66 /*********************************************************************************************/
68 WORD
ShowMessage(STRPTR title
, STRPTR text
, STRPTR gadtext
)
72 es
.es_StructSize
= sizeof(es
);
75 es
.es_TextFormat
= text
;
76 es
.es_GadgetFormat
= gadtext
;
78 return EasyRequestArgs(NULL
, &es
, NULL
, NULL
);
81 /*********************************************************************************************/
83 void Cleanup(STRPTR msg
)
87 if (IntuitionBase
&& !((struct Process
*)FindTask(NULL
))->pr_CLI
)
89 ShowMessage("IControl", msg
, MSG(MSG_OK
));
93 printf("IControl: %s\n", msg
);
107 /*********************************************************************************************/
109 static void OpenLibs(void)
113 for(li
= libtable
; li
->var
; li
++)
115 if (!((*(struct Library
**)li
->var
) = OpenLibrary(li
->name
, li
->version
)))
119 sprintf(s
, MSG(MSG_CANT_OPEN_LIB
), li
->name
, li
->version
);
127 /*********************************************************************************************/
129 static void CloseLibs(void)
133 for(li
= libtable
; li
->var
; li
++)
135 if (*(struct Library
**)li
->var
) CloseLibrary((*(struct Library
**)li
->var
));
139 /*********************************************************************************************/
141 static void GetArguments(void)
143 if (!(myargs
= ReadArgs(ARG_TEMPLATE
, args
, NULL
)))
145 Fault(IoErr(), 0, s
, 256);
149 if (!args
[ARG_FROM
]) args
[ARG_FROM
] = (IPTR
)CONFIGNAME_ENV
;
152 /*********************************************************************************************/
154 static void FreeArguments(void)
156 if (myargs
) FreeArgs(myargs
);
159 /*********************************************************************************************/
173 static void HandleAll(void)
178 set (wnd
, MUIA_Window_Open
, TRUE
);
182 returnid
= (LONG
) DoMethod(app
, MUIM_Application_NewInput
, (IPTR
) &sigs
);
184 if ((returnid
== MUIV_Application_ReturnID_Quit
) ||
185 (returnid
== RETURNID_SAVE
) || (returnid
== RETURNID_USE
)) break;
189 sigs
= Wait(sigs
| SIGBREAKF_CTRL_C
);
190 if (sigs
& SIGBREAKF_CTRL_C
) break;
196 /*********************************************************************************************/
200 InitLocale("System/Prefs/IControl.catalog", 1);
204 InitPrefs((STRPTR
)args
[ARG_FROM
], (args
[ARG_USE
] ? TRUE
: FALSE
), (args
[ARG_SAVE
] ? TRUE
: FALSE
));
213 /*********************************************************************************************/