finally the biggest changes together with makefile. hardcoded flag removed.
[AROS-Contrib.git] / dopus / Program / main20.c
blob5108c9071715947ea6825c6506effdb6b9f14f1f
1 /*
3 Directory Opus 4
4 Original GPL release version 4.12
5 Copyright 1993-2000 Jonathan Potter
7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License
9 as published by the Free Software Foundation; either version 2
10 of the License, or (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 All users of Directory Opus 4 (including versions distributed
22 under the GPL) are entitled to upgrade to the latest version of
23 Directory Opus version 5 at a reduced price. Please see
24 http://www.gpsoft.com.au for more information.
26 The release of Directory Opus 4 under the GPL in NO WAY affects
27 the existing commercial status of Directory Opus 5.
31 #include "dopus.h"
32 #ifndef __AROS__
33 #include <proto/inovamusic.h>
34 #include <proto/screennotify.h>
35 #include <proto/sysinfo.h>
36 #include <proto/multiuser.h>
37 #include <proto/pm.h>
38 #else
39 #include "music.h"
40 #endif
41 #include <proto/locale.h>
42 #define NO_INLINE_STDARG
44 void quit()
46 int a;
48 remclock();
49 removehotkeys();
50 endnotifies();
52 if (keyboard_req) {
53 CloseDevice((struct IORequest *)keyboard_req);
54 LDeleteExtIO((struct IORequest *)keyboard_req);
57 if (input_req) {
58 CloseDevice((struct IORequest *)input_req);
59 LDeleteExtIO((struct IORequest *)input_req);
62 #ifndef __AROS__
63 if (ScreenNotifyBase && snm_port) while (! RemWorkbenchClient(snm_handle)) Delay(10);
64 if (snm_port) LDeletePort(snm_port);
65 CloseLibrary(ScreenNotifyBase);
66 #endif
68 close_rexx_port();
70 main_proc->pr_WindowPtr=windowptr_save;
71 closedisplay();
73 remove_arbiter();
75 allocdirbuffers(0);
76 D(bug("Freeing special dirs\n"));
77 for (a=0;a<2;a++) {
78 freedir(dopus_specialwin[a],-1);
79 if ( completion[a].memory ) LFreeRemember(&completion[a].memory); // HUX
81 if (dir_memory_pool) LibDeletePool(dir_memory_pool);
82 for (a=0;a<NUMFONTS;a++) freefont(a);
83 freedynamiccfg();
84 freehelp();
85 LFreeRemember(&general_key);
86 LFreeRemember(&border_key);
87 LFreeRemember(&menu_key);
88 FreeStringFile(&stringdata);
90 if (configopus_segment) UnLoadSeg(configopus_segment);
91 for (a=0;a<3;a++) {
92 if (external_mod_segment[a]) UnLoadSeg(external_mod_segment[a]);
95 if ( user_appicon ) FreeDiskObject ( user_appicon ); // HUX
97 if (nil_file_handle) Close(nil_file_handle);
98 UnLock(ramdisk_lock);
99 if (func_reselection.reselection_list)
100 FreeMem(func_reselection.reselection_list,func_reselection.reselection_size);
101 if (count_port) LDeletePort(count_port);
102 if (arexx_port) LDeletePort(arexx_port);
103 if (general_port) LDeletePort(general_port);
104 if (appmsg_port) LDeletePort(appmsg_port);
106 #ifndef __AROS__
107 if (sortmenu) PM_FreePopupMenu(sortmenu);
108 #endif
109 /*if (IconBase)*/ CloseLibrary(IconBase);
110 /*if (DiskfontBase)*/ CloseLibrary(DiskfontBase);
111 // /*if (PPBase)*/ CloseLibrary((struct Library *)PPBase);
112 /*if (WorkbenchBase)*/ CloseLibrary(WorkbenchBase);
113 /*if (CxBase)*/ CloseLibrary(CxBase);
114 /*if (RexxSysBase)*/ CloseLibrary((struct Library *)RexxSysBase);
115 /*if (UtilityBase)*/ CloseLibrary((struct Library *)UtilityBase);
116 CloseLibrary(CyberGfxBase);
117 #ifndef __AROS__
118 CLOSE_PM_LIB;
119 #endif
120 CloseLibrary((struct Library *)xfdMasterBase);
121 CloseLibrary((struct Library *)xadMasterBase);
122 #ifndef __AROS__
123 if (sysinfo)
125 FreeSysInfo(sysinfo);
126 CloseLibrary(SysInfoBase);
128 if (AccountsBase) {
129 if (user_info) FreeUserInfo(user_info);
130 if (group_info) FreeGroupInfo(group_info);
131 CloseLibrary(AccountsBase);
133 if (muBase) {
134 if (mu_userinfo) muFreeUserInfo(mu_userinfo);
135 if (mu_groupinfo) muFreeGroupInfo(mu_groupinfo);
136 CloseLibrary((struct Library *)muBase);
138 if (MUSICBase) {
139 FlushModule();
140 CloseLibrary((struct Library *)MUSICBase);
142 #endif
143 CloseLocale(locale);
144 CloseLibrary(LocaleBase);
145 CloseLibrary(DataTypesBase);
146 CloseLibrary(AmigaGuideBase);
147 CloseLibrary(GadToolsBase);
149 /*if (DOpusBase)*/ CloseLibrary((struct Library *) DOpusBase);
151 main_proc->pr_CIS=old_pr_cis;
152 main_proc->pr_COS=old_pr_cos;
153 main_proc->pr_ConsoleTask=old_pr_consoletask;
155 #ifdef __SASC_60
156 __exit(0);
157 #else
158 exit(0);
159 #endif
162 void remclock()
164 if (clockmsg_port) {
165 dotaskmsg(clockmsg_port,TASK_QUIT,0,0,NULL,0);
166 /*DeleteTask(clock_task);*/ clock_task=NULL;
170 void removehotkeys()
172 if (hotkeymsg_port) {
173 dotaskmsg(hotkeymsg_port,TASK_QUIT,0,0,NULL,0);
174 DeleteTask(hotkey_task); hotkey_task=NULL;
178 void freefont(num)
179 int num;
181 if (scr_font[num]) CloseFont(scr_font[num]);
182 scr_font[num]=NULL;
185 void freehelp()
187 LFreeRemember(&help_key);
188 dopus_firsthelp=NULL;
191 void freedynamiccfg()
193 struct ConfigStuff cstuff;
195 fixcstuff(&cstuff);
196 FreeConfig(&cstuff);
197 cstufffix(&cstuff);
200 int checkwindowquit()
202 struct Window *wind,*temp;
203 // int a;
205 if (!MainScreen) return(1);
207 for (a = 1, wind = MainScreen->FirstWindow; wind; wind = wind->NextWindow)
209 if (wind != Window)
211 a = 0;
212 break;
215 if (a) return(1);
217 if ((PubScreenStatus(MainScreen, PSNF_PRIVATE) & PSNF_PRIVATE) == 0)
219 busy();
220 if (!(simplerequest(globstring[STR_ALIEN_WINDOWS],globstring[STR_CLOSE],
221 str_cancelstring,NULL))) {
222 unbusy();
223 PubScreenStatus(MainScreen, 0);
224 return(0);
226 for (wind = MainScreen->FirstWindow; wind; )
228 temp = wind->NextWindow;
229 if (wind != Window) CloseWindow(wind);
230 wind = temp;
232 unbusy();
234 return(1);
237 void dotaskmsg(port,command,value,total,data,flag)
238 struct MsgPort *port;
239 int command,value,total;
240 char *data;
241 int flag;
243 if (port) {
244 struct dopustaskmsg taskmsg;
246 taskmsg.msg.mn_Node.ln_Type=NT_MESSAGE;
247 taskmsg.msg.mn_ReplyPort=general_port;
248 taskmsg.msg.mn_Length=(UWORD)sizeof(struct dopustaskmsg);
249 taskmsg.command=command;
250 taskmsg.value=value;
251 taskmsg.total=total;
252 taskmsg.data=data;
253 taskmsg.flag=flag;
254 Forbid();
255 PutMsg(port,(struct Message *)&taskmsg);
256 Permit();
257 WaitPort(general_port);
258 /* cut by Jacek Rzeuski (31.03.2000) to avoid on-copy-exit crashes
259 GetMsg(general_port);
261 /* inserted by Jacek Rzeuski (31.03.2000) to avoid on-copy-exit crashes */
262 while(GetMsg(general_port) != (struct Message *)&taskmsg);
263 /* end of */
267 void closedisplay()
269 if (status_iconified) cleanupiconify();
270 else {
271 if (MainScreen) ScreenToBack(MainScreen);
272 freedragbuffers();
273 Forbid();
274 if (Window) {
275 if (Window->MenuStrip) ClearMenuStrip(Window);
276 if (WorkbenchBase && dopus_appwindow) {
277 RemoveAppWindow(dopus_appwindow);
278 dopus_appwindow=NULL;
280 free_colour_table();
281 CloseWindow(Window);
282 Window=NULL;
284 if (MainScreen) {
285 if (! CloseScreen(MainScreen))
287 simplerequest(globstring[STR_CANNOT_CLOSE_SCREEN],str_okaystring,NULL);
288 while(!(CloseScreen(MainScreen))) Delay(50);
290 MainScreen=NULL;
292 Permit();