/* * Copyright 2014 Chris Young * * This file is part of NetSurf, http://www.netsurf-browser.org/ * * NetSurf is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 2 of the License. * * NetSurf is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ /** \file * Compatibility functions for AmigaOS 3 */ #ifndef __amigaos4__ #include "os3support.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include "utils/log.h" #define SUCCESS (TRUE) #define FAILURE (FALSE) #define NO ! /* Utility */ struct FormatContext { STRPTR Index; LONG Size; BOOL Overflow; }; char *ASPrintf(const char *fmt, ...) { int r; va_list ap; static char buffer[2048]; char *rbuf; va_start(ap, fmt); r = VSNPrintf(buffer, 2048, (const STRPTR)fmt, ap); va_end(ap); r = strlen(buffer); rbuf = AllocVec(r+1, MEMF_CLEAR); if (rbuf != NULL) { strncpy(rbuf, buffer, r); } return rbuf; } /* C */ char *strlwr(char *str) { size_t i; size_t len = strlen(str); for(i=0; ifib_Size; FreeDosObject(DOS_FIB, fib); return (int64)size; } void FreeSysObject(ULONG type, APTR obj) { switch(type) { case ASOT_PORT: DeleteMsgPort(obj); break; case ASOT_IOREQUEST: DeleteIORequest(obj); break; } } /* Exec */ struct Node *GetHead(struct List *list) { struct Node *res = NULL; if ((NULL != list) && (NULL != list->lh_Head->ln_Succ)) { res = list->lh_Head; } return res; } struct Node *GetPred(struct Node *node) { if (node->ln_Pred->ln_Pred == NULL) return NULL; return node->ln_Pred; } struct Node *GetSucc(struct Node *node) { if (node->ln_Succ->ln_Succ == NULL) return NULL; return node->ln_Succ; } /* Intuition */ uint32 GetAttrs(Object *obj, Tag tag1, ...) { va_list ap; Tag tag = tag1; ULONG data = 0; int i = 0; va_start(ap, tag1); while(tag != TAG_DONE) { data = va_arg(ap, ULONG); i += GetAttr(tag, obj, (void *)data); tag = va_arg(ap, Tag); } va_end(ap); return i; } ULONG RefreshSetGadgetAttrsA(struct Gadget *g, struct Window *w, struct Requester *r, struct TagItem *tags) { ULONG retval; BOOL changedisabled = FALSE; BOOL disabled; struct TagItem *ti; if (w) { if ((ti = FindTagItem(GA_Disabled,tags)) && (ti->ti_Data != FALSE)) { changedisabled = TRUE; disabled = g->Flags & GFLG_DISABLED; } } retval = SetGadgetAttrsA(g,w,r,tags); if (w && (retval || (changedisabled && disabled != (g->Flags & GFLG_DISABLED)))) { RefreshGList(g,w,r,1); retval = 1; } return retval; } ULONG RefreshSetGadgetAttrs(struct Gadget *g, struct Window *w, struct Requester *r, Tag tag1, ...) { return RefreshSetGadgetAttrsA(g,w,r,(struct TagItem *) &tag1); } #endif