ASM(void) sz_Free(REG(a0, struct xadArchiveInfo *ai), REG(a6, struct xadMasterBase *xadMasterBase)) #endif { /* This function needs to free all the stuff allocated in info or unarchive function. It may be called multiple times, so clear freed entries! */ ISzAlloc allocImp; /* memory functions for main pool */ ISzAlloc allocTempImp; /* memory functions for temporary pool */ allocImp.Alloc = SzAlloc; allocImp.Free = SzFree; allocTempImp.Alloc = SzAllocTemp; allocTempImp.Free = SzFreeTemp; struct xad7zprivate *xad7z = ai->xai_PrivateClient; CSzArEx *db = &xad7z->db; UInt32 *blockIndex = &xad7z->blockIndex; Byte **outBuffer = &xad7z->outBuffer; size_t *outBufferSize = &xad7z->outBufferSize; // allocImp.Free(NULL,*outBuffer); SzArEx_Free(db, &allocImp); *outBuffer=0; *blockIndex = 0xfffffff; *outBufferSize = 0; if(g_buffer) { FreeVec(g_buffer); g_buffer = NULL; } // CrcFreeTable(); xadFreeObjectA(ai->xai_PrivateClient,NULL); ai->xai_PrivateClient = NULL; #ifdef __amigaos4__ DropInterface(INewlib); CloseLibrary(newlibbase); INewlib = NULL; newlibbase = NULL; #endif #ifdef __AROS__ CloseLibrary(aroscbase); aroscbase = NULL; #endif }
void cleanup() { if ( IExpat != 0 ) { DropInterface((struct Interface*)IExpat); IExpat = 0; } if ( ExpatBase != 0 ) { CloseLibrary(ExpatBase); ExpatBase = 0; } }
static void closeAmigaInput (void) { if (IAIN) { DropInterface ((struct Interface *)IAIN); IAIN = NULL; } if (AIN_Base) { CloseLibrary (AIN_Base); AIN_Base = NULL; } }
VOID DriverCleanup( struct DriverBase* AHIsubBase ) { struct FilesaveBase* FilesaveBase = (struct FilesaveBase*) AHIsubBase; #ifdef __AMIGAOS4__ if (IUtility) DropInterface( (struct Interface *) IUtility); if (IAHIsub) DropInterface( (struct Interface *) IAHIsub); if (IDOS) DropInterface( (struct Interface *) IDOS); if (IAsl) DropInterface( (struct Interface *) IAsl); if (IDataTypes) DropInterface( (struct Interface *) IDataTypes); #endif CloseLibrary( FilesaveBase->dosbase ); CloseLibrary( FilesaveBase->gfxbase ); CloseLibrary( FilesaveBase->aslbase ); CloseLibrary( FilesaveBase->dtsbase ); }
void close_libs(void) { int i = 0; while (amiga_libs[i].lib_name) { #ifdef AMIGA_OS4 if (amiga_libs[i].interface_base) { DropInterface((struct Interface *)amiga_libs[i].interface_base[0]); } #endif if (amiga_libs[i].lib_base) { CloseLibrary(amiga_libs[i].lib_base[0]); } i++; } }
// Convert a key from the raw key code BOOL LIBFUNC L_ConvertRawKey( REG(d0, UWORD code), REG(d1, UWORD qual), REG(a0, char *key)) { struct Device *ConsoleDevice; #ifdef __amigaos4__ struct ConsoleIFace *IConsole; #endif struct IOStdReq console_req; BOOL ret=0; // Open console device if (!OpenDevice("console.device",-1,(struct IORequest *)&console_req,0)) { struct InputEvent event; // Get device base pointer ConsoleDevice=console_req.io_Device; #ifdef __amigaos4__ IConsole = (struct ConsoleIFace *)GetInterface((struct Library *)ConsoleDevice,"main",1,NULL); #endif // Build fake input event event.ie_NextEvent=0; event.ie_Class=IECLASS_RAWKEY; event.ie_SubClass=0; event.ie_Code=code; event.ie_Qualifier=qual; event.ie_EventAddress=0; // Convert key if ((RawKeyConvert(&event,key,1,0))>0) ret=1; #ifdef __amigaos4__ DropInterface((struct Interface *)IConsole); #endif // Close device CloseDevice((struct IORequest *)&console_req); } return ret; }
static void ai_exit(void) { if (CTX != NULL) { AIN_DeleteContext(CTX); CTX = NULL; } if (ai_port != NULL) { DeleteMsgPort(ai_port); ai_port = NULL; } if (IAIN) { DropInterface((struct Interface *)IAIN); IAIN = NULL; } if (AIN_Base) { CloseLibrary(AIN_Base); AIN_Base = NULL; } amigainput_lib_loaded = 0; }
void close_xfd(struct xfdBufferInfo *xfdobj, struct local_data *data) { if(xfdobj) { xfdFreeObject((APTR)xfdobj); xfdobj=NULL; } #ifdef __amigaos4__ if(data->IxfdMaster) { DropInterface((struct Interface *)data->IxfdMaster); data->IxfdMaster=NULL; } #endif if(data->xfdMasterBase) { CloseLibrary(data->xfdMasterBase); data->xfdMasterBase=NULL; } }
// Open dopus5.library void startup_open_dopuslib() { // Open the library #ifdef __amigaos4__ if (!OpenLibIFace("dopus5:libs/dopus5.library", (APTR)&DOpusBase, (APTR)&IDOpus, LIB_VERSION)) #else if (!(DOpusBase=OpenLibrary("dopus5:libs/dopus5.library",LIB_VERSION))) #endif { #ifndef __amigaos3__ struct Library *IntuitionBase; //Crashes OS3 binary #endif // Get Intuition #ifdef __amigaos4__ if (OpenLibIFace("intuition.library", (APTR)&IntuitionBase, (APTR)&IIntuition, 0)) #else if ((IntuitionBase=(struct IntuitionBase *)OpenLibrary("intuition.library",0))) #endif { struct EasyStruct easy; // Fill out EasyStruct easy.es_StructSize=sizeof(easy); easy.es_Flags=0; easy.es_Title=dopus_name; easy.es_TextFormat="Unable to open dopus5.library!"; easy.es_GadgetFormat="Ok"; // Show error EasyRequestArgs(0,&easy,0,0); // Close library #ifdef __amigaos4__ DropInterface((struct Interface *)IIntuition); #endif CloseLibrary((struct Library *)IntuitionBase); } exit(0); } }
/** * Close the AmiSSL3 library for the given thread. * * @param thread * @return */ static void close_amissl3(struct thread_s *thread) { CleanupAmiSSL(TAG_DONE); #ifdef __AMIGAOS4__ DropInterface((struct Interface*)thread->iamissl); thread->iamissl = NULL; #endif /* FIXME: Closing amissl will lead to crashes on subsequent calls to socket() * at least on OS4. Therefore, this is disabled when compiling for this * operating system. */ #ifndef __AMIGAOS4__ CloseAmiSSL(); #endif thread->amissllib = NULL; CloseLibraryInterface(thread->amisslmasterlib,thread->iamisslmaster); thread->iamisslmaster = NULL; thread->amisslmasterlib = NULL; CloseLibraryInterface(thread->amissllib,thread->iamissl); thread->amissllib = NULL; thread->iamissl = NULL; }
// Open/close MUFS library void env_fix_mufs() { if (environment->env->settings.general_flags&GENERALF_ENABLE_MUFS) { if (!muBase) { #ifdef __amigaos4__ OpenLibIFace("multiuser.library", (APTR)&muBase, (APTR)&Imu, 39); #else muBase = OpenLibrary("multiuser.library",39); #endif } } else if (muBase) { #ifdef __amigaos4__ DropInterface((struct Interface *)Imu); #endif CloseLibrary(muBase); muBase=0; } }
// Free font data void font_free(font_data *data) { if (data) { // Close stuff font_close(data); // Free font if (data->font) CloseFont(data->font); // Free port DeleteMsgPort(data->appport); // Close locale stuff if (data->locale.li_Locale) { CloseLocale(data->locale.li_Locale); CloseCatalog(data->locale.li_Catalog); } // Free args FreeArgs(data->args); // Free labels FreeVec(data->size_labels); // Free data FreeVec(data); } // Close library #ifdef __amigaos4__ DropInterface((struct Interface *)IDOpus); #endif CloseLibrary(DOpusBase); }
void gui_create_form_select_menu(struct gui_window *g, struct form_control *control) { struct Library *PopupMenuBase = NULL; struct PopupMenuIFace *IPopupMenu = NULL; struct Hook selectmenuhook; Object *selectmenuobj; Object *smenu = NULL; Object *currentmenu; Object *submenu = NULL; char *selectmenu_item[AMI_SELECTMENU_MAX]; char *more_label; struct form_option *opt = form_select_get_option(control, 0); int i = 0; int n = 0; if(ami_selectmenu_is_safe() == FALSE) return; if((PopupMenuBase = OpenLibrary("popupmenu.class", 0))) { IPopupMenu = (struct PopupMenuIFace *)GetInterface(PopupMenuBase, "main", 1, NULL); } if(IPopupMenu == NULL) return; ClearMem(selectmenu_item, AMI_SELECTMENU_MAX * 4); more_label = ami_utf8_easy(messages_get("More")); selectmenuhook.h_Entry = ami_popup_hook; selectmenuhook.h_SubEntry = NULL; selectmenuhook.h_Data = g; g->shared->control = control; selectmenuobj = PMMENU(form_control_get_name(control)), PMA_MenuHandler, &selectmenuhook, End; currentmenu = selectmenuobj; while(opt) { selectmenu_item[i] = ami_utf8_easy(opt->text); IDoMethod(currentmenu, PM_INSERT, NewObject(POPUPMENU_GetItemClass(), NULL, PMIA_Title, (ULONG)selectmenu_item[i], PMIA_ID, i, PMIA_CheckIt, TRUE, PMIA_Checked, opt->selected, TAG_DONE), ~0); opt = opt->next; i++; n++; if(n == AMI_SELECTMENU_PAGE_MAX) { if(submenu != NULL) { /* attach the previous submenu */ IDoMethod(smenu, PM_INSERT, NewObject(NULL, "popupmenuitem.class", PMIA_Title, more_label, PMIA_CheckIt, TRUE, PMIA_SubMenu, submenu, TAG_DONE), ~0); } submenu = NewObject(NULL, "popupmenu.class", TAG_DONE); smenu = currentmenu; currentmenu = submenu; n = 0; } if(i >= AMI_SELECTMENU_MAX) break; } if((submenu != NULL) && (n != 0)) { /* attach the previous submenu */ IDoMethod(smenu, PM_INSERT, NewObject(NULL, "popupmenuitem.class", PMIA_Title, more_label, PMIA_CheckIt, TRUE, PMIA_SubMenu, submenu, TAG_DONE), ~0); } ami_set_pointer(g->shared, GUI_POINTER_DEFAULT, false); // Clear the menu-style pointer IDoMethod(selectmenuobj, PM_OPEN, g->shared->win); /* PM_OPEN is blocking, so dispose menu immediately... */ if(selectmenuobj) DisposeObject(selectmenuobj); /* ...and get rid of popupmenu.class ASAP */ if(IPopupMenu) DropInterface((struct Interface *)IPopupMenu); if(PopupMenuBase) CloseLibrary(PopupMenuBase); /* Free the menu labels */ if(more_label) ami_utf8_free(more_label); for(i = 0; i < AMI_SELECTMENU_MAX; i++) { if(selectmenu_item[i] != NULL) { ami_utf8_free(selectmenu_item[i]); selectmenu_item[i] = NULL; } } }
// 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 _AHI_GetAudioAttrsA( ULONG id, struct AHIPrivAudioCtrl* actrl, struct TagItem* tags, struct AHIBase* AHIBase ) { struct AHI_AudioDatabase *audiodb; struct TagItem *dbtags,*tag1,*tag2,*tstate=tags; ULONG *ptr; ULONG stringlen; struct Library *AHIsubBase=NULL; struct AHIAudioCtrlDrv *audioctrl=NULL; BOOL rc=TRUE; // TRUE == _everything_ went well struct TagItem idtag[2] = { {AHIA_AudioID, 0} , {TAG_DONE, 0} }; if(AHIBase->ahib_DebugLevel >= AHI_DEBUG_HIGH) { Debug_GetAudioAttrsA(id, actrl, tags); } if((audiodb=LockDatabase())) { if(id == AHI_INVALID_ID) { if(!(audioctrl= (struct AHIAudioCtrlDrv*) actrl)) rc=FALSE; else idtag[0].ti_Data=((struct AHIPrivAudioCtrl *)actrl)->ahiac_AudioID; } else { idtag[0].ti_Data = (id == AHI_DEFAULT_ID ? AHIBase->ahib_AudioMode : id); audioctrl=(struct AHIAudioCtrlDrv *)CreateAudioCtrl(idtag); } if(audioctrl && rc ) { if((dbtags=GetDBTagList(audiodb, idtag[0].ti_Data))) { stringlen=GetTagData(AHIDB_BufferLen,0,tags); if((AHIsubBase=OpenLibrary(((struct AHIPrivAudioCtrl *)audioctrl)->ahiac_DriverName,DriverVersion))) { #ifdef __AMIGAOS4__ struct AHIsubIFace *IAHIsub; if ((IAHIsub = (struct AHIsubIFace *) GetInterface((struct Library *) AHIsubBase, "main", 1, NULL)) != NULL) { #endif while((tag1=NextTagItem(&tstate))) { ptr=(ULONG *)tag1->ti_Data; switch(tag1->ti_Tag) { case AHIDB_Driver: case AHIDB_Name: if((tag2=FindTagItem(tag1->ti_Tag,dbtags))) stccpy((char *)tag1->ti_Data,(char *)tag2->ti_Data,stringlen); break; // Skip these! case AHIDB_FrequencyArg: case AHIDB_IndexArg: case AHIDB_InputArg: case AHIDB_OutputArg: break; // Strings case AHIDB_Author: case AHIDB_Copyright: case AHIDB_Version: case AHIDB_Annotation: stccpy((char *)tag1->ti_Data,(char *)AHIsub_GetAttr(tag1->ti_Tag,0,(ULONG)"",dbtags,audioctrl),stringlen); break; // Input & Output strings case AHIDB_Input: stccpy((char *)tag1->ti_Data,(char *)AHIsub_GetAttr(tag1->ti_Tag, GetTagData(AHIDB_InputArg,0,tags), (ULONG) GetahiString(msgDefault),dbtags,audioctrl),stringlen); break; case AHIDB_Output: stccpy((char *)tag1->ti_Data,(char *)AHIsub_GetAttr(tag1->ti_Tag, GetTagData(AHIDB_OutputArg,0,tags), (ULONG) GetahiString(msgDefault),dbtags,audioctrl),stringlen); break; // Other case AHIDB_Bits: *ptr=AHIsub_GetAttr(tag1->ti_Tag,0,0,dbtags,audioctrl); break; case AHIDB_MaxChannels: *ptr=AHIsub_GetAttr(tag1->ti_Tag,0,128,dbtags,audioctrl); break; case AHIDB_MinMixFreq: *ptr=AHIsub_GetAttr(AHIDB_Frequency,0,0,dbtags,audioctrl); break; case AHIDB_MaxMixFreq: *ptr=AHIsub_GetAttr(AHIDB_Frequency,(AHIsub_GetAttr(AHIDB_Frequencies,1,0,dbtags,audioctrl)-1),0,dbtags,audioctrl); break; case AHIDB_Frequencies: *ptr=AHIsub_GetAttr(tag1->ti_Tag,0,1,dbtags,audioctrl); break; case AHIDB_Frequency: *ptr=AHIsub_GetAttr(tag1->ti_Tag,GetTagData(AHIDB_FrequencyArg,0,tags),0,dbtags,audioctrl); break; case AHIDB_Index: *ptr=AHIsub_GetAttr(tag1->ti_Tag,GetTagData(AHIDB_IndexArg,0,tags),0,dbtags,audioctrl); break; case AHIDB_MaxPlaySamples: *ptr=AHIsub_GetAttr(tag1->ti_Tag,0,audioctrl->ahiac_MaxBuffSamples,dbtags,audioctrl); break; case AHIDB_MaxRecordSamples: *ptr=AHIsub_GetAttr(tag1->ti_Tag,0,0,dbtags,audioctrl); break; case AHIDB_MinMonitorVolume: case AHIDB_MaxMonitorVolume: *ptr=AHIsub_GetAttr(tag1->ti_Tag,0,0x00000,dbtags,audioctrl); break; case AHIDB_MinInputGain: case AHIDB_MaxInputGain: case AHIDB_MinOutputVolume: case AHIDB_MaxOutputVolume: *ptr=AHIsub_GetAttr(tag1->ti_Tag,0,0x10000,dbtags,audioctrl); break; case AHIDB_Inputs: *ptr=AHIsub_GetAttr(tag1->ti_Tag,0,0,dbtags,audioctrl); break; case AHIDB_Outputs: *ptr=AHIsub_GetAttr(tag1->ti_Tag,0,1,dbtags,audioctrl); break; // Booleans that defaults to FALSE case AHIDB_Realtime: case AHIDB_Record: case AHIDB_FullDuplex: *ptr=AHIsub_GetAttr(tag1->ti_Tag,0,FALSE,dbtags,audioctrl); break; // Booleans that defaults to TRUE case AHIDB_PingPong: *ptr=AHIsub_GetAttr(tag1->ti_Tag,0,TRUE,dbtags,audioctrl); break; // Tags from the database. default: if((tag2=FindTagItem(tag1->ti_Tag,dbtags))) *ptr=tag2->ti_Data; break; } } #ifdef __AMIGAOS4__ if (IAHIsub) { DropInterface((struct Interface *) IAHIsub); IAHIsub = NULL; } } #endif } else // no AHIsubBase rc=FALSE; } else // no database taglist rc=FALSE; } else // no valid audioctrl rc=FALSE; if(id != AHI_INVALID_ID) FreeVec(audioctrl); if(AHIsubBase) CloseLibrary(AHIsubBase); UnlockDatabase(audiodb); } else // unable to lock database rc=FALSE; if(AHIBase->ahib_DebugLevel >= AHI_DEBUG_HIGH) { KPrintF("=>%s\n", rc ? (ULONG) "TRUE" : (ULONG) "FALSE" ); } return (ULONG) rc; }
void CloseLibraryInterface(struct Library *lib, void *interface) { DropInterface((struct Interface *)interface); CloseLibrary(lib); }
ULONG ConvertFileTime(CNtfsFileTime *ft) { #define PERIOD_4 (4 * 365 + 1) #define PERIOD_100 (PERIOD_4 * 25 - 1) #define PERIOD_400 (PERIOD_100 * 4 + 1) struct ClockData cd; ULONG adate = 0; struct Library *UtilityBase; #ifdef __amigaos4__ struct ExecIFace *IExec = (struct ExecIFace *)(*(struct ExecBase **)4)->MainInterface; struct UtilityIFace *IUtility; #elif defined(__AROS__) // handled in link time #else struct Library *SysBase = *(struct ExecBase **)4; #endif unsigned year, mon, day, hour, min, sec; UInt64 v64 = ft->Low | ((UInt64)ft->High << 32); Byte ms[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; unsigned temp; UInt32 v; v64 /= 10000000; sec = (unsigned)(v64 % 60); v64 /= 60; min = (unsigned)(v64 % 60); v64 /= 60; hour = (unsigned)(v64 % 24); v64 /= 24; v = (UInt32)v64; year = (unsigned)(1601 + v / PERIOD_400 * 400); v %= PERIOD_400; temp = (unsigned)(v / PERIOD_100); if (temp == 4) temp = 3; year += temp * 100; v -= temp * PERIOD_100; temp = v / PERIOD_4; if (temp == 25) temp = 24; year += temp * 4; v -= temp * PERIOD_4; temp = v / 365; if (temp == 4) temp = 3; year += temp; v -= temp * 365; if (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0)) ms[1] = 29; for (mon = 1; mon <= 12; mon++) { unsigned s = ms[mon - 1]; if (v < s) break; v -= s; } day = (unsigned)v + 1; cd.sec = sec; cd.min = min; cd.hour = hour; cd.mday = day; cd.month = mon; cd.year = year; cd.wday = 0; if(UtilityBase = OpenLibrary("utility.library",37)) { #ifdef __amigaos4__ if(IUtility = (struct UtilityIFace *)GetInterface(UtilityBase,"main",1,NULL)) { #endif adate = Date2Amiga(&cd); #ifdef __amigaos4__ DropInterface((struct Interface *)IUtility); } #endif CloseLibrary(UtilityBase); } return(adate); }
int main ( int argc, char *argv[] ) { struct RDArgs *rda = NULL; ULONG sigs; globalEvents = -1; globalCurrentTool = LUNA_TOOL_BRUSH; // Init brush brushTool.antialias = TRUE; // TODO: load from config set toolbox cycle! brushTool.width = 1; brushTool.height = 1; brushTool.feather = TRUE; // TODO: load from config and set toolbox cycle! // Set the colors prevColor = 0; currColor = 0; globalColor = 0; BOOL keyIsDown = FALSE; keyboardEnabled = TRUE; // Starts up the application #ifdef __amigaos4__ MUIMasterBase = OpenLibrary("muimaster.library", 0); if (!MUIMasterBase) { printf("Error opening muimaster library\n"); exit(0); }; IMUIMaster = (struct MUIMasterIFace *) GetInterface(MUIMasterBase, "main", 1, NULL); if (!MUIMasterBase && !IMUIMaster) { printf("Error opening muimaster library\n"); exit(0); }; CyberGfxBase = OpenLibrary("cybergraphics.library", 0); if (!CyberGfxBase) { printf("Error opening cybergraphics library\n"); exit(0); }; ICyberGfx = (struct CyberGfxIFace *) GetInterface(CyberGfxBase, "main", 1, NULL); if (!CyberGfxBase && !ICyberGfx) { printf("Error opening muimaster library\n"); exit(0); }; #endif struct MsgPort *port; Forbid(); port = FindPort("LUNAPAINT"); Permit(); if ( port == NULL) { Locale_Initialize(); Init_Application ( ); } else { // Double Start // TODO: open projects when clicking on icons from there goto quit; } if (argc) { IPTR args[ ARG_CNT ] = {0}; rda = ReadArgs ( ARG_TEMPLATE, args, NULL ); if ( ! rda ) { PrintFault( IoErr ( ), argv[0] ); goto exit; } if ( args[ARG_FILE] ) { STRPTR *file = (STRPTR *)args[ARG_FILE]; while ( *file ) { LoadProject ( *file, FALSE ); file++; } } } // Main loop while ( getSignals ( &sigs ) ) { // Check for signals from GUI if ( checkSignalBreak ( &sigs ) ) break; if ( keyboardEnabled ) { // Execute keyboard events on key press if ( evalRawKey >= IECODE_ASCII_FIRST && evalRawKey < IECODE_ASCII_LAST ) { if ( !keyIsDown ) { keyIsDown = TRUE; checkKeyboardShortcuts ( evalRawKey ); } } } // We always register keyup strokes if ( evalRawKey & IECODE_UP_PREFIX ) keyIsDown = FALSE; // Execute pending events if ( globalActiveWindow && globalActiveCanvas ) doEvents ( ); // Reset events globalEvents = -1; // Mouse clicks if ( mouseClickCount > 0 ) mouseClickCount--; // Delayed canvas redraw if ( redrawTimes == 1 ) { if ( globalActiveWindow ) DoMethod ( globalActiveWindow->area, MUIM_Draw ); redrawTimes--; } if ( redrawTimes > 0 ) redrawTimes--; } // Exists the application and cleans up reserved resources exit: Exit_Application ( ); Locale_Deinitialize(); #ifdef __amigaos4__ if(MUIMasterBase && IMUIMaster) DropInterface((struct Interface *)IMUIMaster); if (MUIMasterBase) CloseLibrary(MUIMasterBase); if(CyberGfxBase && ICyberGfx) DropInterface((struct Interface *)ICyberGfx); if(CyberGfxBase) CloseLibrary(CyberGfxBase); #endif if (rda) FreeArgs(rda); quit: return 0; }