xref: /haiku/src/system/boot/platform/atari_m68k/Handle.h (revision 6f9e265157ddbaa612ef1ab4b8242b3d08ab6758)
1eb53cd83SFrançois Revol /*
2eb53cd83SFrançois Revol  * Copyright 2003, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
3eb53cd83SFrançois Revol  * Distributed under the terms of the MIT License.
4eb53cd83SFrançois Revol  */
5eb53cd83SFrançois Revol #ifndef HANDLE_H
6eb53cd83SFrançois Revol #define HANDLE_H
7eb53cd83SFrançois Revol 
8eb53cd83SFrançois Revol 
9eb53cd83SFrançois Revol #include <boot/vfs.h>
10eb53cd83SFrançois Revol 
11eb53cd83SFrançois Revol 
12eb53cd83SFrançois Revol #ifdef __cplusplus
13eb53cd83SFrançois Revol 
14eb53cd83SFrançois Revol class Handle : public ConsoleNode {
15eb53cd83SFrançois Revol 	public:
16*6f9e2651SFrançois Revol 		Handle(int handle);
17eb53cd83SFrançois Revol 		Handle();
18eb53cd83SFrançois Revol 		virtual ~Handle();
19eb53cd83SFrançois Revol 
20*6f9e2651SFrançois Revol 		void SetHandle(int handle);
21eb53cd83SFrançois Revol 
22eb53cd83SFrançois Revol 		virtual ssize_t ReadAt(void *cookie, off_t pos, void *buffer, size_t bufferSize);
23eb53cd83SFrançois Revol 		virtual ssize_t WriteAt(void *cookie, off_t pos, const void *buffer, size_t bufferSize);
24eb53cd83SFrançois Revol 
25eb53cd83SFrançois Revol 		virtual off_t Size() const;
26eb53cd83SFrançois Revol 
27eb53cd83SFrançois Revol 	protected:
28eb53cd83SFrançois Revol 		int16		fHandle;
29eb53cd83SFrançois Revol };
30eb53cd83SFrançois Revol 
31*6f9e2651SFrançois Revol /* character devices */
32*6f9e2651SFrançois Revol class CharHandle : public Handle {
33*6f9e2651SFrançois Revol 	public:
34*6f9e2651SFrançois Revol 		CharHandle(int handle);
35*6f9e2651SFrançois Revol 		CharHandle();
36*6f9e2651SFrançois Revol 		virtual ~CharHandle();
37*6f9e2651SFrançois Revol 
38*6f9e2651SFrançois Revol 		virtual ssize_t ReadAt(void *cookie, off_t pos, void *buffer, size_t bufferSize);
39*6f9e2651SFrançois Revol 		virtual ssize_t WriteAt(void *cookie, off_t pos, const void *buffer, size_t bufferSize);
40*6f9e2651SFrançois Revol 
41*6f9e2651SFrançois Revol 	protected:
42*6f9e2651SFrançois Revol };
43*6f9e2651SFrançois Revol 
44*6f9e2651SFrançois Revol /* block devices */
45*6f9e2651SFrançois Revol /* cf. devices.cpp */
46*6f9e2651SFrançois Revol 
47eb53cd83SFrançois Revol #endif	/* __cplusplus */
48eb53cd83SFrançois Revol 
49eb53cd83SFrançois Revol #endif	/* HANDLE_H */
50