VOID DriverCleanup( struct DriverBase* AHIsubBase ) { struct EMU10kxBase* EMU10kxBase = (struct EMU10kxBase*) AHIsubBase; int i; if( EMU10kxBase->camd.Semaphore.ss_Link.ln_Name != NULL ) { ObtainSemaphore( &EMU10kxBase->camd.Semaphore ); RemSemaphore( &EMU10kxBase->camd.Semaphore ); ReleaseSemaphore( &EMU10kxBase->camd.Semaphore ); } if( EMU10kxBase->ac97.Semaphore.ss_Link.ln_Name != NULL ) { ObtainSemaphore( &EMU10kxBase->ac97.Semaphore ); RemSemaphore( &EMU10kxBase->ac97.Semaphore ); ReleaseSemaphore( &EMU10kxBase->ac97.Semaphore ); } for( i = 0; i < EMU10kxBase->cards_found; ++i ) { emu10k1_irq_disable( &EMU10kxBase->driverdatas[ i ]->card, INTE_MIDIRXENABLE ); emu10k1_irq_disable( &EMU10kxBase->driverdatas[ i ]->card, INTE_MIDITXENABLE ); FreeDriverData( EMU10kxBase->driverdatas[ i ], AHIsubBase ); } FreeVec( EMU10kxBase->driverdatas ); CloseLibrary( OpenPciBase ); CloseLibrary( (struct Library*) DOSBase ); }
// Quit the program void quit(BOOL script) { // If main status window is open, close it if (main_status) { CloseProgressWindow(main_status); main_status=0; } if (GUI) { // Clear 'startup' flag for scripts GUI->flags&=~GUIF_DONE_STARTUP; // Close commodities cx_remove(GUI->cx); // Update environment settings env_update_settings(1); // Stop notify request RemoveNotifyRequest(GUI->notify_req); GUI->notify_req=0; // Is there a hide appicon? if (GUI->hide_appicon) { RemoveAppIcon(GUI->hide_appicon); FreeCachedDiskObject(GUI->hide_diskobject); } // Or an appmenuitem? if (GUI->hide_appitem) RemoveAppMenuItem(GUI->hide_appitem); // Launch shutdown script if (script) RunScript(SCRIPT_SHUTDOWN,0); // Set quit flag GUI->flags|=GUIF_PENDING_QUIT; // Shut the display down close_display(CLOSE_ALL,TRUE); // Send quit notifications quit_notify(); // Stop notifications stop_file_notify(GUI->pattern_notify); stop_file_notify(GUI->font_notify); stop_file_notify(GUI->modules_notify); stop_file_notify(GUI->commands_notify); stop_file_notify(GUI->env_notify); stop_file_notify(GUI->desktop_notify); stop_file_notify(GUI->filetype_notify); // Free application port if (GUI->appmsg_port) { DOpusAppMessage *amsg; RemPort(GUI->appmsg_port); while ((amsg=(DOpusAppMessage *)GetMsg(GUI->appmsg_port))) ReplyAppMessage(amsg); DeleteMsgPort(GUI->appmsg_port); GUI->appmsg_port=0; // Remove public semaphore RemSemaphore((struct SignalSemaphore *)&pub_semaphore); } // Flush IPC port IPC_Flush(&main_ipc); // Close all processes IPC_ListQuit(&GUI->lister_list,&main_ipc,0,TRUE); IPC_ListQuit(&GUI->group_list,&main_ipc,0,TRUE); IPC_ListQuit(&GUI->buttons_list,&main_ipc,0,TRUE); IPC_ListQuit(&GUI->startmenu_list,&main_ipc,0,TRUE); IPC_ListQuit(&GUI->process_list,&main_ipc,0,TRUE); IPC_ListQuit(&GUI->function_list,&main_ipc,0,TRUE); // Free buffers buffers_clear(0); // Remove all handlers RemFunctionTrap("*","#?"); // Free filetypes FreeMemHandle(GUI->filetype_memory); // Flush the filetype cache ClearFiletypeCache(); // Free lister toolbar FreeToolBar(GUI->toolbar); // Free menus and hotkeys CloseButtonBank(GUI->lister_menu); CloseButtonBank(GUI->hotkeys); // Free user menus CloseButtonBank(GUI->user_menu); FreeVec(GUI->user_menu_data); // Free backdrop list backdrop_free(GUI->backdrop); // Free icons if (GUI->lister_icon) FreeCachedDiskObject(GUI->lister_icon); if (GUI->button_icon) FreeCachedDiskObject(GUI->button_icon); // Free arrow image CloseImage(GUI->toolbar_arrow_image); #ifdef __amigaos3__ FreeVec(arrow_hi_data_chip); FreeVec(arrow_lo_data_chip); FreeVec(small_arrow_chip); FreeVec(big_arrow_chip); #ifndef USE_SCREENTITLE FreeVec(moon_big_data_chip); FreeVec(moon_small_data_chip); #endif FreeVec(command_arrow_chip); FreeVec(parent_arrow_chip); #endif // Free screen signal if (GUI->screen_signal!=-1) FreeSignal(GUI->screen_signal); // Delete notify port if (GUI->notify_port) DeleteMsgPort(GUI->notify_port); // Free position memory FreeMemHandle(GUI->position_memory); // Free command history Att_RemList(GUI->command_history,0); // Delete icon positioning port DeleteMsgPort(GUI->iconpos_port); // Free popup menu PopUpFreeHandle(GUI->desktop_menu); // Clear requester pattern hook in library if (GUI->flags2&GUIF2_BACKFILL_SET) SetReqBackFill(0,0); } // Free scripts FreeScripts(); // Free environment environment_free(environment); // Delete main message ports IPC_Flush(&main_ipc); DeleteMsgPort(main_ipc.command_port); DeleteMsgPort(main_ipc.reply_port); // Pause here for a couple of seconds to let everything clean up Delay(3*50); // Free global data FreeMemHandle(global_memory_pool); // Delete any temporary files delete_temp_files(0); // Free locale data free_locale_data(&locale); // Close input device if (InputBase) { #ifdef __amigaos4__ DropInterface((struct Interface *)IInput); #endif CloseDevice((struct IORequest *)&input_req); } // Close timer device if (TimerBase) { #ifdef __amigaos4__ DropInterface((struct Interface *)ITimer); #endif CloseDevice((struct IORequest *)&timer_req); } // Close console device if (ConsoleDevice) { #ifdef __amigaos4__ DropInterface((struct Interface *)IConsole); #endif CloseDevice((struct IORequest *)&console_req); } // Close libraries #ifdef __amigaos4__ DropInterface((struct Interface *)Imu); #endif CloseLibrary(muBase); #ifndef __amigaos3__ #ifdef __amigaos4__ DropInterface((struct Interface *)INewIcon); #endif CloseLibrary((struct Library *)NewIconBase); #endif #ifdef __amigaos4__ DropInterface((struct Interface *)ICyberGfx); #endif CloseLibrary(CyberGfxBase); #ifdef __amigaos4__ DropInterface((struct Interface *)IAmigaGuide); #endif CloseLibrary(AmigaGuideBase); #ifdef __amigaos4__ DropInterface((struct Interface *)IDataTypes); #endif CloseLibrary(DataTypesBase); #ifdef __amigaos4__ DropInterface((struct Interface *)IAsl); #endif CloseLibrary(AslBase); #ifdef __amigaos4__ DropInterface((struct Interface *)IIcon); #endif CloseLibrary(IconBase); #ifdef __amigaos4__ DropInterface((struct Interface *)IDiskfont); #endif CloseLibrary(DiskfontBase); #ifdef __amigaos4__ DropInterface((struct Interface *)IWorkbench); #endif CloseLibrary(WorkbenchBase); #ifdef __amigaos4__ DropInterface((struct Interface *)ICommodities); #endif CloseLibrary(CxBase); #ifdef __amigaos4__ DropInterface((struct Interface *)IRexxSys); #endif CloseLibrary((struct Library *)RexxSysBase); #ifdef __amigaos4__ DropInterface((struct Interface *)IUtility); #endif CloseLibrary(UtilityBase); #ifdef __amigaos4__ DropInterface((struct Interface *)IGadTools); #endif CloseLibrary(GadToolsBase); #ifdef __amigaos4__ DropInterface((struct Interface *)ILayers); #endif CloseLibrary((struct Library *)LayersBase); #ifdef __amigaos4__ DropInterface((struct Interface *)IGraphics); #endif CloseLibrary((struct Library *)GfxBase); #ifdef __amigaos4__ DropInterface((struct Interface *)IIntuition); #endif CloseLibrary((struct Library *)IntuitionBase); // Restore old current directory? if (old_current_dir) { UnLock(CurrentDir(old_current_dir)); } // Close the dopus5.library #ifdef __amigaos4__ DropInterface((struct Interface *)IDOpus); #endif CloseLibrary(DOpusBase); // Outahere! exit(0); }
ULONG RemoveAudioMode( ULONG id, struct AHIBase* AHIBase ) { struct AHI_AudioMode *node; struct AHI_AudioDatabase *audiodb; ULONG rc=FALSE; if(AHIBase->ahib_DebugLevel >= AHI_DEBUG_HIGH) { Debug_RemoveAudioMode(id); } /* Why ?? */ audiodb = LockDatabaseWrite(); if(audiodb != NULL) { UnlockDatabase(audiodb); } audiodb = LockDatabaseWrite(); if(audiodb != NULL) { if(id != AHI_INVALID_ID) { for(node=(struct AHI_AudioMode *)audiodb->ahidb_AudioModes.mlh_Head; node->ahidbn_MinNode.mln_Succ; node=(struct AHI_AudioMode *)node->ahidbn_MinNode.mln_Succ) { if(id == GetTagData(AHIDB_AudioID, AHI_INVALID_ID, node->ahidbn_Tags)) { Remove((struct Node *) node); FreeVec(node); rc = TRUE; break; } } // Remove the entire database if it's empty Forbid(); if(audiodb->ahidb_AudioModes.mlh_Head->mln_Succ == NULL) { UnlockDatabase(audiodb); audiodb = (struct AHI_AudioDatabase *) FindSemaphore(ADB_NAME); if(audiodb != NULL) { RemSemaphore((struct SignalSemaphore *) audiodb); FreeVec(audiodb); } audiodb = NULL; } Permit(); } UnlockDatabase(audiodb); } if(AHIBase->ahib_DebugLevel >= AHI_DEBUG_HIGH) { KPrintF("=>%ld\n",rc); } return rc; }