1 #ifndef CLIB_ALIB_PROTOS_H
    2 #define CLIB_ALIB_PROTOS_H
    3 
    4 /*
    5 	abox.lib C prototypes
    6 
    7 	Copyright © 2002-2007 The MorphOS Development Team, All Rights Reserved.
    8 */
    9 
   10 
   11 #ifndef EXEC_TYPES_H
   12 # include <exec/types.h>
   13 #endif
   14 
   15 #ifndef DEVICES_TIMER_H
   16 # include <devices/timer.h>
   17 #endif
   18 
   19 #ifndef DEVICES_KEYMAP_H
   20 # include <devices/keymap.h>
   21 #endif
   22 
   23 #ifndef LIBRARIES_COMMODITIES_H
   24 # include <libraries/commodities.h>
   25 #endif
   26 
   27 #ifndef UTILITY_HOOKS_H
   28 # include <utility/hooks.h>
   29 #endif
   30 
   31 #ifndef INTUITION_CLASSES_H
   32 # include <intuition/classes.h>
   33 #endif
   34 
   35 #ifndef INTUITION_CLASSUSR_H
   36 # include <intuition/classusr.h>
   37 #endif
   38 
   39 #ifndef GRAPHICS_GRAPHINT_H
   40 # include <graphics/graphint.h>
   41 #endif
   42 
   43 #ifndef REXX_STORAGE_H
   44 # include <rexx/storage.h>
   45 #endif
   46 
   47 #ifndef DOS_DOS_H
   48 # include <dos/dos.h>
   49 #endif
   50 
   51 #if !defined(_NO_PPCINLINE) && !defined(__MORPHOS_NODIRECTCALL)
   52 # ifndef EMUL_EMULREGS_H
   53 #  include <emul/emulregs.h>
   54 # endif
   55 #endif
   56 
   57 #ifdef __cplusplus
   58 extern "C" {
   59 #endif /* __cplusplus */
   60 
   61 
   62 VOID BeginIO( struct IORequest *ioReq );
   63 
   64 #if !defined(_NO_PPCINLINE) && !defined(__MORPHOS_NODIRECTCALL)
   65 #define BeginIO(MyIORequest) \
   66 do { struct IORequest *_MyIORequest = (struct IORequest *)(MyIORequest); \
   67 	REG_A1 = (ULONG) _MyIORequest; \
   68 	REG_A6 = (ULONG) _MyIORequest->io_Device; \
   69 	(*MyEmulHandle->EmulCallDirectOS)(-30); \
   70 } while (0)
   71 #endif /* !_NO_PPCINLINE && !__MORPHOS_NODIRECTCALL */
   72 
   73 struct IORequest *CreateExtIO( CONST struct MsgPort *port, LONG ioSize );
   74 struct MsgPort *CreatePort( CONST_STRPTR name, LONG pri );
   75 struct IOStdReq *CreateStdIO( CONST struct MsgPort *port );
   76 struct Task *CreateTask( CONST_STRPTR name, LONG pri, CONST APTR initPC, ULONG stackSize );
   77 VOID DeleteExtIO( struct IORequest *ioReq );
   78 VOID DeletePort( struct MsgPort *ioReq );
   79 VOID DeleteStdIO( struct IOStdReq *ioReq );
   80 VOID DeleteTask( struct Task *task );
   81 VOID NewList( struct List *list );
   82 APTR LibAllocPooled( APTR poolHeader, ULONG memSize );
   83 APTR LibCreatePool( ULONG memFlags, ULONG puddleSize, ULONG threshSize );
   84 VOID LibDeletePool( APTR poolHeader );
   85 VOID LibFreePooled( APTR poolHeader, APTR memory, ULONG memSize );
   86 
   87 ULONG FastRand( ULONG seed );
   88 UWORD RangeRand( ULONG maxValue );
   89 
   90 VOID AddTOF( struct Isrvstr *i, LONG (*p) __CLIB_PROTOTYPE((APTR args)), APTR a );
   91 VOID RemTOF( struct Isrvstr *i );
   92 VOID waitbeam( LONG b );
   93 
   94 FLOAT afp( CONST_STRPTR string );
   95 VOID arnd( LONG place, LONG exp, STRPTR string );
   96 FLOAT dbf( ULONG exp, ULONG mant );
   97 LONG fpa( FLOAT fnum, BYTE *string );
   98 VOID fpbcd( FLOAT fnum, BYTE *string );
   99 
  100 LONG TimeDelay( LONG unit, ULONG secs, ULONG microsecs );
  101 LONG DoTimer( struct TimeVal *, LONG unit, LONG command );
  102 
  103 VOID ArgArrayDone( VOID );
  104 STRPTR *ArgArrayInit( LONG argc, CONST_STRPTR *argv );
  105 LONG ArgInt( CONST_STRPTR *tt, CONST_STRPTR entry, LONG defaultval );
  106 STRPTR ArgString( CONST_STRPTR *tt, CONST_STRPTR entry, CONST_STRPTR defaultstring );
  107 CxObj *HotKey( CONST_STRPTR description, struct MsgPort *port, LONG id );
  108 struct InputEvent *InvertString( CONST_STRPTR str, CONST struct KeyMap *km );
  109 VOID FreeIEvents( struct InputEvent *events );
  110 
  111 BOOL CheckRexxMsg( CONST struct RexxMsg *rexxmsg );
  112 LONG GetRexxVar( CONST struct RexxMsg *rexxmsg, CONST_STRPTR name, STRPTR *result );
  113 LONG SetRexxVar( struct RexxMsg *rexxmsg, CONST_STRPTR name, CONST_STRPTR value, LONG length );
  114 
  115 ULONG CallHookA( struct Hook *hookPtr, Boopsiobject *obj, APTR message );
  116 ULONG DoMethodA( Boopsiobject *obj, Msg message );
  117 ULONG DoSuperMethodA( struct IClass *cl, Boopsiobject *obj, Msg message );
  118 ULONG CoerceMethodA( struct IClass *cl, Boopsiobject *obj, Msg message );
  119 ULONG HookEntry( struct Hook *hookPtr, Boopsiobject *obj, APTR message );
  120 
  121 STRPTR ACrypt( STRPTR buffer, CONST_STRPTR password, CONST_STRPTR username );
  122 
  123 LONG MakeDirAll( CONST_STRPTR path );
  124 BPTR OpenMakeDir( CONST_STRPTR path, LONG mode );
  125 
  126 
  127 #if !defined(_NO_PPCINLINE) && !defined(__MORPHOS_NODIRECTCALL) && !defined(__STRICT_ANSI__)
  128 
  129 #define CallHookA(MyHook, MyObject, MyMsg) \
  130 ({ ULONG ret; \
  131 struct Hook *_MyHook = (struct Hook *)(MyHook); \
  132 ULONG _MyMsg = (ULONG)(MyMsg); \
  133 ULONG _MyObject = (ULONG)(MyObject); \
  134 	REG_A0 = (ULONG)_MyHook; \
  135 	REG_A1 = _MyMsg; \
  136 	REG_A2 = _MyObject; \
  137 	ret = (*MyEmulHandle->EmulCallDirect68k)((void *)_MyHook->h_Entry); \
  138 	ret; \
  139 })
  140 
  141 #define DoMethodA(MyObject, MyMsg) \
  142 ({ ULONG ret = 0; \
  143 ULONG _MyMsg = (ULONG)(MyMsg); \
  144 ULONG _MyObject = (ULONG)(MyObject); \
  145 	if (_MyObject) \
  146 	{ \
  147 		struct IClass *_MyClass = (struct IClass *)(((ULONG *)_MyObject)[-1]); \
  148 		REG_A0 = (ULONG)_MyClass; \
  149 		REG_A1 = _MyMsg; \
  150 		REG_A2 = _MyObject; \
  151 		ret = (*MyEmulHandle->EmulCallDirect68k)((void *)_MyClass->cl_Dispatcher.h_Entry); \
  152 	} \
  153 	ret; \
  154 })
  155 
  156 #define DoSuperMethodA(MyClass, MyObject, MyMsg) \
  157 ({ ULONG ret = 0; \
  158 struct IClass *_MyClass = (struct IClass *)(MyClass); \
  159 ULONG _MyMsg = (ULONG)(MyMsg); \
  160 ULONG _MyObject = (ULONG)(MyObject); \
  161 	if (_MyClass && _MyObject) \
  162 	{ \
  163 		REG_A0 = (ULONG)_MyClass->cl_Super; \
  164 		REG_A1 = _MyMsg; \
  165 		REG_A2 = _MyObject; \
  166 		ret = (*MyEmulHandle->EmulCallDirect68k)((void *)_MyClass->cl_Super->cl_Dispatcher.h_Entry); \
  167 	} \
  168 	ret; \
  169 })
  170 
  171 #define CoerceMethodA(MyClass, MyObject, MyMsg) \
  172 ({ ULONG ret = 0; \
  173 struct IClass *_MyClass = (struct IClass *)(MyClass); \
  174 ULONG _MyMsg = (ULONG)(MyMsg); \
  175 ULONG _MyObject = (ULONG)(MyObject); \
  176 	if (_MyClass && _MyObject) \
  177 	{ \
  178 		REG_A0 = (ULONG)_MyClass; \
  179 		REG_A1 = _MyMsg; \
  180 		REG_A2 = _MyObject; \
  181 		ret = (*MyEmulHandle->EmulCallDirect68k)((void *)_MyClass->cl_Dispatcher.h_Entry); \
  182 	} \
  183 	ret; \
  184 })
  185 
  186 #endif /* !_NO_PPCINLINE && !__MORPHOS_NODIRECTCALL && !__STRICT_ANSI__ */
  187 
  188 
  189 #if !defined(USE_INLINE_STDARG) || defined(__STRICT_ANSI__)
  190 
  191 ULONG CallHook( struct Hook *hookPtr, Boopsiobject *obj, ... );
  192 ULONG DoMethod( Boopsiobject *obj, ULONG methodID, ... );
  193 ULONG DoSuperMethod( struct IClass *cl, Boopsiobject *obj, ULONG methodID, ... );
  194 ULONG CoerceMethod( struct IClass *cl, Boopsiobject *obj, ULONG methodID, ... );
  195 ULONG SetSuperAttrs( struct IClass *cl, Boopsiobject *obj, ULONG tag1, ... );
  196 APTR DoSuperNew( struct IClass *cl, APTR obj, ... );
  197 
  198 #else
  199 
  200 #define CallHook(MyHook, MyObject, ...) \
  201 ({ ULONG _tags[] = { __VA_ARGS__ }; CallHookA((MyHook), (MyObject), (APTR)_tags); })
  202 
  203 #define DoMethod(MyObject, ...) \
  204 ({ ULONG _tags[] = { __VA_ARGS__ }; DoMethodA((MyObject), (APTR)_tags); })
  205 
  206 #define DoSuperMethod(MyClass, MyObject, ...) \
  207 ({ ULONG _tags[] = { __VA_ARGS__ }; DoSuperMethodA((MyClass), (MyObject), (APTR)_tags); })
  208 
  209 #define CoerceMethod(MyClass, MyObject, ...) \
  210 ({ ULONG _tags[] = { __VA_ARGS__ }; CoerceMethodA((MyClass), (MyObject), (APTR)_tags); })
  211 
  212 #define SetSuperAttrs(MyClass, MyObject, ...) \
  213 ({ ULONG _tags[] = { __VA_ARGS__ }; \
  214 struct opSet MyopSet; \
  215 	MyopSet.MethodID = OM_SET; \
  216 	MyopSet.ops_AttrList = (struct TagItem*) _tags; \
  217 	MyopSet.ops_GInfo = NULL; \
  218 	DoSuperMethodA((MyClass), (MyObject), (APTR) &MyopSet); \
  219 })
  220 
  221 #define DoSuperNew(MyClass, MyObject, ...) \
  222 ({ ULONG _tags[] = { __VA_ARGS__ }; \
  223 struct opSet MyopSet; \
  224 	MyopSet.MethodID = OM_NEW; \
  225 	MyopSet.ops_AttrList = (struct TagItem*) _tags; \
  226 	MyopSet.ops_GInfo = NULL; \
  227 	DoSuperMethodA((MyClass), (MyObject), (APTR) &MyopSet); \
  228 })
  229 
  230 #endif /* !USE_INLINE_STDARG || __STRICT_ANSI__ */
  231 
  232 
  233 #ifdef __cplusplus
  234 }
  235 #endif /* __cplusplus */
  236 
  237 
  238 #endif /* CLIB_ALIB_PROTOS_H */