1 /* 2 * Copyright 2010 John-Mark Bell <jmb@netsurf-browser.org> 3 * Copyright 2014 Chris Young <chris@unsatisfactorysoftware.co.uk> 4 * 5 * This file is part of NetSurf, http://www.netsurf-browser.org/ 6 * 7 * NetSurf is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation; version 2 of the License. 10 * 11 * NetSurf is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program. If not, see <http://www.gnu.org/licenses/>. 18 */ 19 20 /** \file 21 * Minimal compatibility header for AmigaOS 3 22 */ 23 24 #ifndef AMIGA_OS3SUPPORT_H_ 25 #define AMIGA_OS3SUPPORT_H_ 26 27 #ifndef __amigaos4__ 28 29 #include <stdint.h> 30 #include <dirent.h> 31 32 #include <proto/exec.h> 33 #include <proto/dos.h> 34 35 /* Include prototypes for amigalib */ 36 #include <clib/alib_protos.h> 37 38 #ifndef EXEC_MEMORY_H 39 #include <exec/memory.h> 40 #endif 41 42 /* C macros */ 43 #ifndef ASM 44 #define ASM 45 #endif 46 47 #ifndef REG 48 #define REG(reg,arg) arg __asm(#reg) 49 #endif 50 51 #define MIN(a,b) (((a)<(b))?(a):(b)) 52 53 /* Macros */ 54 #define IsMinListEmpty(L) (L)->mlh_Head->mln_Succ == 0 55 #define LIB_IS_AT_LEAST(B,V,R) ((B)->lib_Version>(V)) || \ 56 ((B)->lib_Version==(V) && (B)->lib_Revision>=(R)) 57 #define EAD_IS_FILE(E) ((E)->ed_Type<0) 58 59 /* Define extra memory type flags */ 60 #define MEMF_PRIVATE MEMF_ANY 61 #define MEMF_SHARED MEMF_ANY 62 63 /* Ignore unsupported tags */ 64 #define ASO_NoTrack TAG_IGNORE 65 #define BITMAP_DisabledSourceFile TAG_IGNORE 66 #define BITMAP_HasAlpha TAG_IGNORE 67 #define BLITA_UseSrcAlpha TAG_IGNORE 68 #define BLITA_MaskPlane TAG_IGNORE 69 #define CLICKTAB_CloseImage TAG_IGNORE 70 #define CLICKTAB_FlagImage TAG_IGNORE 71 #define CLICKTAB_LabelTruncate TAG_IGNORE 72 #define CLICKTAB_NodeClosed TAG_IGNORE 73 #define GETFONT_OTagOnly TAG_IGNORE 74 #define GETFONT_ScalableOnly TAG_IGNORE 75 #define PDTA_PromoteMask TAG_IGNORE 76 #define RPTAG_APenColor TAG_IGNORE 77 #define GA_ContextMenu TAG_IGNORE 78 #define GA_HintInfo TAG_IGNORE 79 #define GAUGEIA_Level TAG_IGNORE 80 #define IA_InBorder TAG_IGNORE 81 #define IA_Label TAG_IGNORE 82 #define LBNCA_SoftStyle TAG_IGNORE 83 #define LISTBROWSER_Striping TAG_IGNORE 84 #define SA_Compositing TAG_IGNORE 85 #define SBNA_Text TAG_IGNORE 86 #define SBNA_HintInfo TAG_IGNORE 87 #define TNA_CloseGadget TAG_IGNORE 88 #define TNA_HintInfo TAG_IGNORE 89 #define WA_ContextMenuHook TAG_IGNORE 90 #define WA_ToolBox TAG_IGNORE 91 #define WINDOW_BuiltInScroll TAG_IGNORE 92 #define WINDOW_NewMenu TAG_IGNORE 93 #define WINDOW_NewPrefsHook TAG_IGNORE 94 95 /* raw keycodes */ 96 #define RAWKEY_BACKSPACE 0x41 97 #define RAWKEY_TAB 0x42 98 #define RAWKEY_ESC 0x45 99 #define RAWKEY_DEL 0x46 100 #define RAWKEY_PAGEUP 0x48 101 #define RAWKEY_PAGEDOWN 0x49 102 #define RAWKEY_CRSRUP 0x4C 103 #define RAWKEY_CRSRDOWN 0x4D 104 #define RAWKEY_CRSRRIGHT 0x4E 105 #define RAWKEY_CRSRLEFT 0x4F 106 #define RAWKEY_F5 0x54 107 #define RAWKEY_F8 0x57 108 #define RAWKEY_F9 0x58 109 #define RAWKEY_F10 0x59 110 #define RAWKEY_F12 0x6F 111 #define RAWKEY_HELP 0x5F 112 #define RAWKEY_HOME 0x70 113 #define RAWKEY_END 0x71 114 115 /* New pens - these may not be equivalent */ 116 #define DISABLEDTEXTPEN HIGHLIGHTTEXTPEN 117 #define TITLEPEN FILLPEN 118 119 /* Other constants */ 120 #define BVS_DISPLAY BVS_NONE 121 #define IDCMP_EXTENDEDMOUSE 0 122 #define WINDOW_BACKMOST 0 123 #define DN_FULLPATH 0 124 #define BGBACKFILL JAM1 125 #define OFF_OPEN 0 126 #define AFF_OTAG 0 127 #define ML_SEPARATOR NM_BARLABEL 128 #define LBS_ROWS 0 129 130 /* Renamed structures */ 131 #define AnchorPathOld AnchorPath 132 133 /* ReAction (ClassAct) macros */ 134 #define GetFileEnd End 135 #define GetFontEnd End 136 #define GetScreenModeEnd End 137 138 /* MinTerm stuff */ 139 #define MINTERM_SRCMASK (ABC|ABNC|ANBC) 140 141 /* Easy compat macros */ 142 /* application */ 143 #define Notify(...) (void)0 144 145 /* DataTypes */ 146 #define SaveDTObjectA(O,W,R,F,M,I,A) DoDTMethod(O,W,R,DTM_WRITE,F,M,NULL) 147 148 /* diskfont */ 149 #define EReleaseInfo ReleaseInfo 150 #define EObtainInfo ObtainInfo 151 #define ESetInfo SetInfo 152 153 /* Only used in one place we haven't ifdeffed, where it returns the charset name */ 154 #define ObtainCharsetInfo(A,B,C) (const char *)nsoption_charp(local_charset) 155 156 /* DOS */ 157 #define AllocSysObjectTags(A,B,C,D) CreateMsgPort() /* Assume ASOT_PORT for now */ 158 #define FOpen(A,B,C) Open(A,B) 159 #define FClose(A) Close(A) 160 #define CreateDirTree(D) CreateDir(D) /*\todo This isn't quite right */ 161 #define SetCurrentDir(L) CurrentDir(L) 162 #define DevNameFromLock(A,B,C,D) NameFromLock(A,B,C) 163 164 /* Exec */ 165 #define FindIName FindName 166 167 /* Intuition */ 168 #define ICoerceMethod CoerceMethod 169 #define IDoMethod DoMethod 170 #define IDoMethodA DoMethodA 171 #define IDoSuperMethodA DoSuperMethodA 172 #define ShowWindow(...) (void)0 173 174 /* Utility */ 175 #define SetMem memset 176 #define SNPrintf snprintf 177 178 /* Integral type definitions */ 179 typedef int8_t int8; 180 typedef uint8_t uint8; 181 typedef int16_t int16; 182 typedef uint16_t uint16; 183 typedef int32_t int32; 184 typedef uint32_t uint32; 185 typedef int64_t int64; 186 typedef uint64_t uint64; 187 188 /* TimeVal */ 189 struct TimeVal { 190 uint32 Seconds; 191 uint32 Microseconds; 192 }; 193 194 /* TimeRequest */ 195 struct TimeRequest { 196 struct IORequest Request; 197 struct TimeVal Time; 198 }; 199 200 /* OutlineFont */ 201 struct OutlineFont { 202 struct BulletBase *BulletBase; 203 struct GlyphEngine *GEngine; 204 STRPTR OTagPath; 205 struct TagItem *olf_OTagList; 206 }; 207 208 /* BackFillMessage */ 209 struct BackFillMessage { 210 struct Layer *Layer; 211 struct Rectangle Bounds; 212 LONG OffsetX; 213 LONG OffsetY; 214 }; 215 216 /* icon.library v51 (ie. AfA_OS version) */ 217 #define ICONCTRLA_SetImageDataFormat (ICONA_Dummy + 0x67) /*103*/ 218 #define ICONCTRLA_GetImageDataFormat (ICONA_Dummy + 0x68) /*104*/ 219 220 #define IDFMT_BITMAPPED (0) /* Bitmapped icon (planar, legacy) */ 221 #define IDFMT_PALETTEMAPPED (1) /* Palette mapped icon (chunky, V44+) */ 222 #define IDFMT_DIRECTMAPPED (2) /* Direct mapped icon (truecolor 0xAARRGGBB, V51+) */ 223 224 /* Object types */ 225 enum { 226 ASOT_PORT = 1, 227 ASOT_IOREQUEST 228 }; 229 230 /* Requester types */ 231 enum { 232 TDRIMAGE_ERROR = 1, 233 TDRIMAGE_WARNING 234 }; 235 236 /* Functions */ 237 /* Diskfont */ 238 void CloseOutlineFont(struct OutlineFont *of, struct List *list); 239 struct OutlineFont *OpenOutlineFont(STRPTR fileName, struct List *list, ULONG flags); 240 241 /* DOS */ 242 int64 GetFileSize(BPTR fh); 243 void FreeSysObject(ULONG type, APTR obj); 244 245 /* Exec */ 246 struct Node *GetHead(struct List *list); 247 struct Node *GetPred(struct Node *node); 248 struct Node *GetSucc(struct Node *node); 249 250 /* Intuition */ 251 uint32 GetAttrs(Object *obj, Tag tag1, ...); 252 ULONG RefreshSetGadgetAttrs(struct Gadget *g, struct Window *w, struct Requester *r, Tag tag1, ...); 253 ULONG RefreshSetGadgetAttrsA(struct Gadget *g, struct Window *w, struct Requester *r, struct TagItem *tags); 254 APTR NewObject(struct IClass * classPtr, CONST_STRPTR classID, ULONG tagList, ...); 255 256 /* Utility */ 257 char *ASPrintf(const char *fmt, ...); 258 259 /* C */ 260 char *strlwr(char *str); 261 int alphasort(const struct dirent **d1, const struct dirent **d2); 262 int scandir(const char *dir, struct dirent ***namelist, 263 int (*filter)(const struct dirent *), 264 int (*compar)(const struct dirent **, const struct dirent **)); 265 #endif 266 #endif 267 268