2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
5 Desc: Unix filedescriptor/socket IO
9 #include <exec/execbase.h>
10 #include <hidd/unixio.h>
12 #include <proto/oop.h>
13 #include <aros/debug.h>
19 #define OOPBase (OOP_OCLASS(o)->OOPBasePtr)
21 IPTR
Hidd_UnixIO_Wait(HIDD
*o
, ULONG fd
, ULONG mode
, APTR callback
, APTR callbackdata
, struct ExecBase
* SysBase
)
23 static OOP_MethodID mid
;
24 struct uioMsg p
, *msg
= &p
;
27 mid
= OOP_GetMethodID(IID_Hidd_UnixIO
, moHidd_UnixIO_Wait
);
32 p
.um_CallBack
= callback
;
33 p
.um_CallBackData
= callbackdata
;
35 return OOP_DoMethod((OOP_Object
*)o
, (OOP_Msg
)msg
);
38 IPTR
Hidd_UnixIO_AsyncIO(HIDD
*o
, ULONG fd
, ULONG fd_type
, struct MsgPort
* port
, ULONG mode
, struct ExecBase
* SysBase
)
40 static OOP_MethodID mid
;
41 struct uioMsgAsyncIO p
, *msg
= &p
;
44 mid
= OOP_GetMethodID(IID_Hidd_UnixIO
, moHidd_UnixIO_AsyncIO
);
48 p
.um_Filedesc_Type
= fd_type
;
49 p
.um_ReplyPort
= port
;
52 return OOP_DoMethod((OOP_Object
*)o
, (OOP_Msg
)msg
);
56 VOID
Hidd_UnixIO_AbortAsyncIO(HIDD
*o
, ULONG fd
, struct ExecBase
* SysBase
)
58 static OOP_MethodID mid
;
59 struct uioMsgAbortAsyncIO p
, *msg
= &p
;
62 mid
= OOP_GetMethodID(IID_Hidd_UnixIO
, moHidd_UnixIO_AbortAsyncIO
);
67 OOP_DoMethod((OOP_Object
*)o
, (OOP_Msg
)msg
);
70 int Hidd_UnixIO_OpenFile(HIDD
*o
, const char *filename
, int flags
, int mode
, int *errno_ptr
)
72 static OOP_MethodID mid
;
73 struct uioMsgOpenFile p
, *msg
= &p
;
76 mid
= OOP_GetMethodID(IID_Hidd_UnixIO
, moHidd_UnixIO_OpenFile
);
79 p
.um_FileName
= (STRPTR
)filename
;
80 p
.um_Flags
= (STACKULONG
)flags
;
81 p
.um_Mode
= (STACKULONG
)mode
;
82 p
.um_ErrNoPtr
= errno_ptr
;
84 return (int)OOP_DoMethod((OOP_Object
*)o
, (OOP_Msg
)msg
);
87 VOID
Hidd_UnixIO_CloseFile(HIDD
*o
, int fd
, int *errno_ptr
)
89 static OOP_MethodID mid
;
90 struct uioMsgCloseFile p
, *msg
= &p
;
93 mid
= OOP_GetMethodID(IID_Hidd_UnixIO
, moHidd_UnixIO_CloseFile
);
97 p
.um_ErrNoPtr
= errno_ptr
;
99 OOP_DoMethod((OOP_Object
*)o
, (OOP_Msg
)msg
);
102 int Hidd_UnixIO_ReadFile(HIDD
*o
, int fd
, void *buffer
, int count
, int *errno_ptr
)
104 static OOP_MethodID mid
;
105 struct uioMsgReadFile p
, *msg
= &p
;
108 mid
= OOP_GetMethodID(IID_Hidd_UnixIO
, moHidd_UnixIO_ReadFile
);
112 p
.um_Buffer
= (APTR
)buffer
;
113 p
.um_Count
= (STACKULONG
)count
;
114 p
.um_ErrNoPtr
= errno_ptr
;
116 return (int)OOP_DoMethod((OOP_Object
*)o
, (OOP_Msg
)msg
);
119 int Hidd_UnixIO_WriteFile(HIDD
*o
, int fd
, const void *buffer
, int count
, int *errno_ptr
)
121 static OOP_MethodID mid
;
122 struct uioMsgWriteFile p
, *msg
= &p
;
125 mid
= OOP_GetMethodID(IID_Hidd_UnixIO
, moHidd_UnixIO_WriteFile
);
129 p
.um_Buffer
= (APTR
)buffer
;
130 p
.um_Count
= (STACKULONG
)count
;
131 p
.um_ErrNoPtr
= errno_ptr
;
133 return (int)OOP_DoMethod((OOP_Object
*)o
, (OOP_Msg
)msg
);
136 int Hidd_UnixIO_IOControlFile(HIDD
*o
, int fd
, int request
, void *param
, int *errno_ptr
)
138 static OOP_MethodID mid
;
139 struct uioMsgIOControlFile p
, *msg
= &p
;
142 mid
= OOP_GetMethodID(IID_Hidd_UnixIO
, moHidd_UnixIO_IOControlFile
);
146 p
.um_Request
= (STACKULONG
)request
;
147 p
.um_Param
= (APTR
)param
;
148 p
.um_ErrNoPtr
= errno_ptr
;
150 return (int)OOP_DoMethod((OOP_Object
*)o
, (OOP_Msg
)msg
);
153 /* The below function is just a hack to avoid
154 name conflicts inside intuition_driver.c
159 HIDD
*New_UnixIO(struct Library
*OOPBase
, struct ExecBase
* SysBase
)
161 struct TagItem tags
[] = {{ TAG_END
, 0 }};
163 return (HIDD
)OOP_NewObject (NULL
, CLID_Hidd_UnixIO
, (struct TagItem
*)tags
);