* Added KMessage to libroot_build.

* libbe_build: Where possible we directly use the actual Haiku headers and
  sources, now. In the headers/build headers we just include the respective
  Haiku headers as needed. That still allows overrides where necessary. The
  intention is to make it easier to keep the build stuff in sync.
* Fixed a few printf() format and signed/unsigned comparison warnings.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42179 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold
2011-06-14 11:42:49 +00:00
parent 45ec6bf344
commit 4cc4f7bb18
100 changed files with 136 additions and 20869 deletions
+30 -1
View File
@@ -1,5 +1,5 @@
/*
* Copyright 2009-2010, Haiku, Inc. All Rights Reserved.
* Copyright 2009-2011, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _CONFIG_BUILD_TYPES_H
@@ -70,13 +70,42 @@ typedef __haiku_std_uint64 __haiku_uint64;
#endif
#define __HAIKU_PHYS_SADDR_MIN (-__HAIKU_SADDR_MAX-1)
/* printf()/scanf() format prefixes */
/* TODO: The following are only guesses! We should define them in the
build/host headers. */
#define __HAIKU_STD_PRI_PREFIX_32 ""
#ifdef __HAIKU_ARCH_64_BIT
# define __HAIKU_STD_PRI_PREFIX_64 "l"
#else
# define __HAIKU_STD_PRI_PREFIX_64 "ll"
#endif
#define __HAIKU_PRI_PREFIX_32 __HAIKU_STD_PRI_PREFIX_32
#define __HAIKU_PRI_PREFIX_64 __HAIKU_STD_PRI_PREFIX_64
#ifdef __HAIKU_ARCH_64_BIT
# define __HAIKU_PRI_PREFIX_ADDR __HAIKU_PRI_PREFIX_64
#else
# define __HAIKU_PRI_PREFIX_ADDR __HAIKU_PRI_PREFIX_32
#endif
#ifdef __HAIKU_ARCH_PHYSICAL_64_BIT
# define __HAIKU_PRI_PREFIX_PHYS_ADDR __HAIKU_PRI_PREFIX_64
#else
# define __HAIKU_PRI_PREFIX_PHYS_ADDR __HAIKU_PRI_PREFIX_32
#endif
/* a generic address type wide enough for virtual and physical addresses */
#if __HAIKU_ARCH_BITS >= __HAIKU_ARCH_PHYSICAL_BITS
typedef __haiku_addr_t __haiku_generic_addr_t;
# define __HAIKU_GENERIC_ADDR_MAX __HAIKU_ADDR_MAX
# define __HAIKU_PRI_PREFIX_GENERIC_ADDR __HAIKU_PRI_PREFIX_ADDR
#else
typedef __haiku_phys_addr_t __haiku_generic_addr_t;
# define __HAIKU_GENERIC_ADDR_MAX __HAIKU_PHYS_ADDR_MAX
# define __HAIKU_PRI_PREFIX_GENERIC_ADDR __HAIKU_PRI_PREFIX_PHYS_ADDR
#endif
+1 -170
View File
@@ -1,170 +1 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// File Name: AppDefs.h
// Author: Erik Jaesler ([email protected])
// Description: Message codes and the global cursors.
//------------------------------------------------------------------------------
#ifndef _APP_DEFS_H
#define _APP_DEFS_H
// Standard Includes -----------------------------------------------------------
// System Includes -------------------------------------------------------------
#include <BeBuild.h>
// Project Includes ------------------------------------------------------------
// Local Includes --------------------------------------------------------------
// Local Defines ---------------------------------------------------------------
// Globals ---------------------------------------------------------------------
// Global Cursors --------------------------------------------------------------
// Old-style cursors
extern const unsigned char B_HAND_CURSOR[];
extern const unsigned char B_I_BEAM_CURSOR[];
// New-style cursors
#ifdef __cplusplus
class BCursor;
extern const BCursor *B_CURSOR_SYSTEM_DEFAULT;
extern const BCursor *B_CURSOR_I_BEAM;
#endif
// System Message Codes --------------------------------------------------------
enum {
B_ABOUT_REQUESTED = '_ABR',
B_WINDOW_ACTIVATED = '_ACT',
B_APP_ACTIVATED = '_ACT', // Same as B_WINDOW_ACTIVATED
B_ARGV_RECEIVED = '_ARG',
B_QUIT_REQUESTED = '_QRQ',
B_CLOSE_REQUESTED = '_QRQ', // Obsolete; use B_QUIT_REQUESTED
B_CANCEL = '_CNC',
B_KEY_DOWN = '_KYD',
B_KEY_UP = '_KYU',
B_UNMAPPED_KEY_DOWN = '_UKD',
B_UNMAPPED_KEY_UP = '_UKU',
B_MODIFIERS_CHANGED = '_MCH',
B_MINIMIZE = '_WMN',
B_MOUSE_DOWN = '_MDN',
B_MOUSE_MOVED = '_MMV',
B_MOUSE_ENTER_EXIT = '_MEX',
B_MOUSE_UP = '_MUP',
B_MOUSE_WHEEL_CHANGED = '_MWC',
B_OPEN_IN_WORKSPACE = '_OWS',
B_PRINTER_CHANGED = '_PCH',
B_PULSE = '_PUL',
B_READY_TO_RUN = '_RTR',
B_REFS_RECEIVED = '_RRC',
B_RELEASE_OVERLAY_LOCK = '_ROV',
B_ACQUIRE_OVERLAY_LOCK = '_AOV',
B_SCREEN_CHANGED = '_SCH',
B_VALUE_CHANGED = '_VCH',
B_VIEW_MOVED = '_VMV',
B_VIEW_RESIZED = '_VRS',
B_WINDOW_MOVED = '_WMV',
B_WINDOW_RESIZED = '_WRS',
B_WORKSPACES_CHANGED = '_WCG',
B_WORKSPACE_ACTIVATED = '_WAC',
B_ZOOM = '_WZM',
_COLORS_UPDATED = '_CLU', // Currently internal-use only. Later, public as B_COLORS_UPDATED
_FONTS_UPDATED = '_FNU', // Currently internal-use only. Later, public as B_FONTS_UPDATED
_APP_MENU_ = '_AMN',
_BROWSER_MENUS_ = '_BRM',
_MENU_EVENT_ = '_MEV',
_PING_ = '_PBL',
_QUIT_ = '_QIT',
_VOLUME_MOUNTED_ = '_NVL',
_VOLUME_UNMOUNTED_ = '_VRM',
_MESSAGE_DROPPED_ = '_MDP',
_DISPOSE_DRAG_ = '_DPD',
_MENUS_DONE_ = '_MND',
_SHOW_DRAG_HANDLES_ = '_SDH',
_EVENTS_PENDING_ = '_EVP',
_UPDATE_ = '_UPD',
_UPDATE_IF_NEEDED_ = '_UPN',
_PRINTER_INFO_ = '_PIN',
_SETUP_PRINTER_ = '_SUP',
_SELECT_PRINTER_ = '_PSL'
// Media Kit reserves all reserved codes starting in '_TR'
};
// Other Commands --------------------------------------------------------------
enum {
B_SET_PROPERTY = 'PSET',
B_GET_PROPERTY = 'PGET',
B_CREATE_PROPERTY = 'PCRT',
B_DELETE_PROPERTY = 'PDEL',
B_COUNT_PROPERTIES = 'PCNT',
B_EXECUTE_PROPERTY = 'PEXE',
B_GET_SUPPORTED_SUITES = 'SUIT',
B_UNDO = 'UNDO',
B_REDO = 'REDO',
B_CUT = 'CCUT',
B_COPY = 'COPY',
B_PASTE = 'PSTE',
B_SELECT_ALL = 'SALL',
B_SAVE_REQUESTED = 'SAVE',
B_MESSAGE_NOT_UNDERSTOOD = 'MNOT',
B_NO_REPLY = 'NONE',
B_REPLY = 'RPLY',
B_SIMPLE_DATA = 'DATA',
B_MIME_DATA = 'MIME',
B_ARCHIVED_OBJECT = 'ARCV',
B_UPDATE_STATUS_BAR = 'SBUP',
B_RESET_STATUS_BAR = 'SBRS',
B_NODE_MONITOR = 'NDMN',
B_QUERY_UPDATE = 'QUPD',
B_ENDORSABLE = 'ENDO',
B_COPY_TARGET = 'DDCP',
B_MOVE_TARGET = 'DDMV',
B_TRASH_TARGET = 'DDRM',
B_LINK_TARGET = 'DDLN',
B_INPUT_DEVICES_CHANGED = 'IDCH',
B_INPUT_METHOD_EVENT = 'IMEV',
B_WINDOW_MOVE_TO = 'WDMT',
B_WINDOW_MOVE_BY = 'WDMB',
B_SILENT_RELAUNCH = 'AREL',
B_OBSERVER_NOTICE_CHANGE = 'NTCH',
B_CONTROL_INVOKED = 'CIVK',
B_CONTROL_MODIFIED = 'CMOD'
// Media Kit reserves all reserved codes starting in 'TRI'
};
//------------------------------------------------------------------------------
#endif // _APP_DEFS_H
/*
* $Log $
*
* $Id $
*
*/
#include <../os/app/AppDefs.h>
+1 -149
View File
@@ -1,149 +1 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// File Name: Handler.cpp
// Author: Erik Jaesler ([email protected])
// Description: BHandler defines the message-handling protocol.
// MessageReceived() is its lynchpin.
//------------------------------------------------------------------------------
#ifndef _HANDLER_H
#define _HANDLER_H
// Standard Includes -----------------------------------------------------------
// System Includes -------------------------------------------------------------
#include <BeBuild.h>
#include <Archivable.h>
// Project Includes ------------------------------------------------------------
// Local Includes --------------------------------------------------------------
// Local Defines ---------------------------------------------------------------
// Globals ---------------------------------------------------------------------
class BLooper;
class BMessageFilter;
class BMessage;
class BMessenger;
class BList;
class _ObserverList;
#define B_OBSERVE_WHAT_CHANGE "be:observe_change_what"
#define B_OBSERVE_ORIGINAL_WHAT "be:observe_orig_what"
const uint32 B_OBSERVER_OBSERVE_ALL = 0xffffffff;
// BHandler class --------------------------------------------------------------
class BHandler : public BArchivable {
public:
BHandler(const char* name = NULL);
virtual ~BHandler();
// Archiving
BHandler(BMessage* data);
static BArchivable* Instantiate(BMessage* data);
virtual status_t Archive(BMessage* data, bool deep = true) const;
// BHandler guts.
virtual void MessageReceived(BMessage* message);
BLooper* Looper() const;
void SetName(const char* name);
const char* Name() const;
virtual void SetNextHandler(BHandler* handler);
BHandler* NextHandler() const;
// Message filtering
virtual void AddFilter(BMessageFilter* filter);
virtual bool RemoveFilter(BMessageFilter* filter);
virtual void SetFilterList(BList* filters);
BList* FilterList();
bool LockLooper();
status_t LockLooperWithTimeout(bigtime_t timeout);
void UnlockLooper();
// Scripting
virtual BHandler* ResolveSpecifier(BMessage* msg,
int32 index,
BMessage* specifier,
int32 form,
const char* property);
virtual status_t GetSupportedSuites(BMessage* data);
// Observer calls, inter-looper and inter-team
status_t StartWatching(BMessenger, uint32 what);
status_t StartWatchingAll(BMessenger);
status_t StopWatching(BMessenger, uint32 what);
status_t StopWatchingAll(BMessenger);
// Observer calls for observing targets in the same BLooper
status_t StartWatching(BHandler* , uint32 what);
status_t StartWatchingAll(BHandler* );
status_t StopWatching(BHandler* , uint32 what);
status_t StopWatchingAll(BHandler* );
// Reserved
virtual status_t Perform(perform_code d, void* arg);
// Notifier calls
virtual void SendNotices(uint32 what, const BMessage* = 0);
bool IsWatched() const;
//----- Private or reserved -----------------------------------------
private:
typedef BArchivable _inherited;
friend inline int32 _get_object_token_(const BHandler* );
friend class BLooper;
friend class BMessageFilter;
virtual void _ReservedHandler2();
virtual void _ReservedHandler3();
virtual void _ReservedHandler4();
void InitData(const char* name);
BHandler(const BHandler&);
BHandler& operator=(const BHandler&);
void SetLooper(BLooper* loop);
int32 fToken;
char* fName;
BLooper* fLooper;
BHandler* fNextHandler;
BList* fFilters;
_ObserverList* fObserverList;
uint32 _reserved[3];
};
//------------------------------------------------------------------------------
#endif // _HANDLER_H
/*
* $Log $
*
* $Id $
*
*/
#include <../os/app/Handler.h>
+1 -238
View File
@@ -1,238 +1 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// File Name: Looper.h
// Author(s): Erik Jaesler ([email protected])
// DarkWyrm ([email protected])
// Description: BLooper class spawns a thread that runs a message loop.
//------------------------------------------------------------------------------
#ifndef _LOOPER_H
#define _LOOPER_H
// Standard Includes -----------------------------------------------------------
// System Includes -------------------------------------------------------------
#include <BeBuild.h>
#include <Handler.h>
#include <List.h>
#include <OS.h>
// Project Includes ------------------------------------------------------------
// Local Includes --------------------------------------------------------------
// Local Defines ---------------------------------------------------------------
// Globals ---------------------------------------------------------------------
class BMessage;
class BMessageQueue;
namespace BPrivate {
class BLooperList;
}
struct _loop_data_;
// Port (Message Queue) Capacity -----------------------------------------------
#define B_LOOPER_PORT_DEFAULT_CAPACITY 100
// BLooper class ---------------------------------------------------------------
class BLooper : public BHandler {
public:
BLooper(const char* name = NULL,
int32 priority = B_NORMAL_PRIORITY,
int32 port_capacity = B_LOOPER_PORT_DEFAULT_CAPACITY);
virtual ~BLooper();
// Archiving
BLooper(BMessage* data);
static BArchivable* Instantiate(BMessage* data);
virtual status_t Archive(BMessage* data, bool deep = true) const;
// Message transmission
status_t PostMessage(uint32 command);
status_t PostMessage(BMessage* message);
status_t PostMessage(uint32 command,
BHandler* handler,
BHandler* reply_to = NULL);
status_t PostMessage(BMessage* message,
BHandler* handler,
BHandler* reply_to = NULL);
virtual void DispatchMessage(BMessage* message, BHandler* handler);
virtual void MessageReceived(BMessage* msg);
BMessage* CurrentMessage() const;
BMessage* DetachCurrentMessage();
BMessageQueue* MessageQueue() const;
bool IsMessageWaiting() const;
// Message handlers
void AddHandler(BHandler* handler);
bool RemoveHandler(BHandler* handler);
int32 CountHandlers() const;
BHandler* HandlerAt(int32 index) const;
int32 IndexOf(BHandler* handler) const;
BHandler* PreferredHandler() const;
void SetPreferredHandler(BHandler* handler);
// Loop control
virtual thread_id Run();
virtual void Quit();
virtual bool QuitRequested();
bool Lock();
void Unlock();
bool IsLocked() const;
status_t LockWithTimeout(bigtime_t timeout);
thread_id Thread() const;
team_id Team() const;
static BLooper* LooperForThread(thread_id tid);
// Loop debugging
thread_id LockingThread() const;
int32 CountLocks() const;
int32 CountLockRequests() const;
sem_id Sem() const;
// Scripting
virtual BHandler* ResolveSpecifier(BMessage* msg,
int32 index,
BMessage* specifier,
int32 form,
const char* property);
virtual status_t GetSupportedSuites(BMessage* data);
// Message filters (also see BHandler).
virtual void AddCommonFilter(BMessageFilter* filter);
virtual bool RemoveCommonFilter(BMessageFilter* filter);
virtual void SetCommonFilterList(BList* filters);
BList* CommonFilterList() const;
// Private or reserved ---------------------------------------------------------
virtual status_t Perform(perform_code d, void* arg);
protected:
// called from overridden task_looper
BMessage* MessageFromPort(bigtime_t = B_INFINITE_TIMEOUT);
private:
typedef BHandler _inherited;
friend class BWindow;
friend class BApplication;
friend class BMessenger;
friend class BView;
friend class BHandler;
friend class BPrivate::BLooperList;
friend port_id _get_looper_port_(const BLooper* );
friend status_t _safe_get_server_token_(const BLooper* , int32* );
friend team_id _find_cur_team_id_();
virtual void _ReservedLooper1();
virtual void _ReservedLooper2();
virtual void _ReservedLooper3();
virtual void _ReservedLooper4();
virtual void _ReservedLooper5();
virtual void _ReservedLooper6();
BLooper(const BLooper&);
BLooper& operator=(const BLooper&);
BLooper(int32 priority, port_id port, const char* name);
status_t _PostMessage(BMessage* msg,
BHandler* handler,
BHandler* reply_to);
static status_t _Lock(BLooper* loop,
port_id port,
bigtime_t timeout);
static status_t _LockComplete(BLooper* loop,
int32 old,
thread_id this_tid,
sem_id sem,
bigtime_t timeout);
void InitData();
void InitData(const char* name, int32 prio, int32 capacity);
void AddMessage(BMessage* msg);
void _AddMessagePriv(BMessage* msg);
static status_t _task0_(void* arg);
void* ReadRawFromPort(int32* code,
bigtime_t tout = B_INFINITE_TIMEOUT);
BMessage* ReadMessageFromPort(bigtime_t tout = B_INFINITE_TIMEOUT);
virtual BMessage* ConvertToMessage(void* raw, int32 code);
virtual void task_looper();
void do_quit_requested(BMessage* msg);
bool AssertLocked() const;
BHandler* top_level_filter(BMessage* msg, BHandler* t);
BHandler* handler_only_filter(BMessage* msg, BHandler* t);
BHandler* apply_filters( BList* list,
BMessage* msg,
BHandler* target);
void check_lock();
BHandler* resolve_specifier(BHandler* target, BMessage* msg);
void UnlockFully();
static uint32 sLooperID;
static team_id sTeamID;
// DEPRECATED
static void AddLooper(BLooper* l);
static bool IsLooperValid(const BLooper* l);
static void RemoveLooper(BLooper* l);
static void GetLooperList(BList* list);
static BLooper* LooperForName(const char* name);
static BLooper* LooperForPort(port_id port);
uint32 fLooperID;
BMessageQueue* fQueue;
BMessage* fLastMessage;
port_id fMsgPort;
long fAtomicCount;
sem_id fLockSem;
long fOwnerCount;
thread_id fOwner;
thread_id fTaskID;
uint32 _unused1;
int32 fInitPriority;
BHandler* fPreferred;
BList fHandlers;
BList* fCommonFilters;
bool fTerminating;
bool fRunCalled;
thread_id fCachedPid;
size_t fCachedStack;
void* fMsgBuffer;
size_t fMsgBufferSize;
uint32 _reserved[6];
};
//------------------------------------------------------------------------------
#endif // _LOOPER_H
/*
* $Log $
*
* $Id $
*
*/
#include <../os/app/Looper.h>
+1 -65
View File
@@ -1,65 +1 @@
//
// $Id: MessageQueue.h 1686 2002-10-26 18:59:16Z beveloper $
//
// This is the BMessageQueue interface for OpenBeOS. It has been created
// to be source and binary compatible with the BeOS version of
// BMessageQueue.
//
#ifndef _OPENBEOS_MESSAGEQUEUE_H
#define _OPENBEOS_MESSAGEQUEUE_H
#include <Locker.h>
#include <Message.h> /* For convenience */
#ifdef USE_OPENBEOS_NAMESPACE
namespace OpenBeOS {
#endif
class BMessageQueue {
public:
BMessageQueue();
virtual ~BMessageQueue();
void AddMessage(BMessage *message);
void RemoveMessage(BMessage *message);
int32 CountMessages(void) const;
bool IsEmpty(void) const;
BMessage *FindMessage(int32 index) const;
BMessage *FindMessage(uint32 what, int32 index=0) const;
bool Lock(void);
void Unlock(void);
bool IsLocked(void);
BMessage *NextMessage(void);
private:
// Reserved space in the vtable for future changes to BMessageQueue
virtual void _ReservedMessageQueue1(void);
virtual void _ReservedMessageQueue2(void);
virtual void _ReservedMessageQueue3(void);
BMessageQueue(const BMessageQueue &);
BMessageQueue &operator=(const BMessageQueue &);
BMessage *fTheQueue;
BMessage *fQueueTail;
int32 fMessageCount;
BLocker fLocker;
// Reserved space for future changes to BMessageQueue
uint32 fReservedSpace[3];
};
#ifdef USE_OPENBEOS_NAMESPACE
}
#endif
#endif // _OPENBEOS_MESSAGEQUEUE_H
#include <../os/app/MessageQueue.h>
+3
View File
@@ -0,0 +1,3 @@
#define dprintf haiku_dprintf
#include <../os/drivers/KernelExport.h>
#undef dprintf
+1 -337
View File
@@ -1,337 +1 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// File Name: GraphicsDefs.h
// Author: Frans van Nispen
// Description: BMessageFilter class creates objects that filter
// in-coming BMessages.
//------------------------------------------------------------------------------
#ifndef _GRAPHICS_DEFS_H
#define _GRAPHICS_DEFS_H
// Standard Includes -----------------------------------------------------------
// System Includes -------------------------------------------------------------
#include <BeBuild.h>
#include <SupportDefs.h>
// Project Includes ------------------------------------------------------------
// Local Includes --------------------------------------------------------------
// Local Defines ---------------------------------------------------------------
// Globals ---------------------------------------------------------------------
//------------------------------------------------------------------------------
typedef struct pattern {
uint8 data[8];
} pattern;
#ifdef __cplusplus
inline bool
operator==(const pattern& a, const pattern& b)
{
return (*(uint64*)a.data == *(uint64*)b.data);
}
#endif // __cplusplus
extern _IMPEXP_BE const pattern B_SOLID_HIGH;
extern _IMPEXP_BE const pattern B_MIXED_COLORS;
extern _IMPEXP_BE const pattern B_SOLID_LOW;
//------------------------------------------------------------------------------
typedef struct rgb_color {
uint8 red;
uint8 green;
uint8 blue;
uint8 alpha;
#if defined(__cplusplus)
// some convenient additions
inline bool
operator==(const rgb_color& other) const
{
return *(const uint32 *)this == *(const uint32 *)&other;
}
inline bool
operator!=(const rgb_color& other) const
{
return *(const uint32 *)this != *(const uint32 *)&other;
}
#endif
} rgb_color;
//------------------------------------------------------------------------------
extern _IMPEXP_BE const rgb_color B_TRANSPARENT_COLOR;
extern _IMPEXP_BE const uint8 B_TRANSPARENT_MAGIC_CMAP8;
extern _IMPEXP_BE const uint16 B_TRANSPARENT_MAGIC_RGBA15;
extern _IMPEXP_BE const uint16 B_TRANSPARENT_MAGIC_RGBA15_BIG;
extern _IMPEXP_BE const uint32 B_TRANSPARENT_MAGIC_RGBA32;
extern _IMPEXP_BE const uint32 B_TRANSPARENT_MAGIC_RGBA32_BIG;
extern _IMPEXP_BE const uint8 B_TRANSPARENT_8_BIT;
extern _IMPEXP_BE const rgb_color B_TRANSPARENT_32_BIT;
//------------------------------------------------------------------------------
typedef struct color_map {
int32 id;
rgb_color color_list[256];
uint8 inversion_map[256];
uint8 index_map[32768];
} color_map;
typedef struct overlay_rect_limits {
uint16 horizontal_alignment;
uint16 vertical_alignment;
uint16 width_alignment;
uint16 height_alignment;
uint16 min_width;
uint16 max_width;
uint16 min_height;
uint16 max_height;
uint32 reserved[8];
} overlay_rect_limits;
typedef struct overlay_restrictions {
overlay_rect_limits source;
overlay_rect_limits destination;
float min_width_scale;
float max_width_scale;
float min_height_scale;
float max_height_scale;
uint32 reserved[8];
} overlay_restrictions;
//------------------------------------------------------------------------------
struct screen_id { int32 id; };
extern _IMPEXP_BE const struct screen_id B_MAIN_SCREEN_ID;
//------------------------------------------------------------------------------
typedef enum
{
B_NO_COLOR_SPACE = 0x0000, //* byte in memory order, high bit first
// linear color space (little endian is the default)
B_RGB32 = 0x0008, //* B[7:0] G[7:0] R[7:0] -[7:0]
B_RGBA32 = 0x2008, // B[7:0] G[7:0] R[7:0] A[7:0]
B_RGB24 = 0x0003, // B[7:0] G[7:0] R[7:0]
B_RGB16 = 0x0005, // G[2:0],B[4:0] R[4:0],G[5:3]
B_RGB15 = 0x0010, // G[2:0],B[4:0] -[0],R[4:0],G[4:3]
B_RGBA15 = 0x2010, // G[2:0],B[4:0] A[0],R[4:0],G[4:3]
B_CMAP8 = 0x0004, // D[7:0]
B_GRAY8 = 0x0002, // Y[7:0]
B_GRAY1 = 0x0001, // Y0[0],Y1[0],Y2[0],Y3[0],Y4[0],Y5[0],Y6[0],Y7[0]
// big endian version, when the encoding is not endianess independant
B_RGB32_BIG = 0x1008, // -[7:0] R[7:0] G[7:0] B[7:0]
B_RGBA32_BIG = 0x3008, // A[7:0] R[7:0] G[7:0] B[7:0]
B_RGB24_BIG = 0x1003, // R[7:0] G[7:0] B[7:0]
B_RGB16_BIG = 0x1005, // R[4:0],G[5:3] G[2:0],B[4:0]
B_RGB15_BIG = 0x1010, // -[0],R[4:0],G[4:3] G[2:0],B[4:0]
B_RGBA15_BIG = 0x3010, // A[0],R[4:0],G[4:3] G[2:0],B[4:0]
// little-endian declarations, for completness
B_RGB32_LITTLE = B_RGB32,
B_RGBA32_LITTLE = B_RGBA32,
B_RGB24_LITTLE = B_RGB24,
B_RGB16_LITTLE = B_RGB16,
B_RGB15_LITTLE = B_RGB15,
B_RGBA15_LITTLE = B_RGBA15,
// non linear color space -- note that these are here for exchange purposes;
// a BBitmap or BView may not necessarily support all these color spaces.
// Loss/Saturation points are Y 16-235 (absoulte); Cb/Cr 16-240 (center 128)
B_YCbCr422 = 0x4000, // Y0[7:0] Cb0[7:0] Y1[7:0] Cr0[7:0] Y2[7:0]...
// Cb2[7:0] Y3[7:0] Cr2[7:0]
B_YCbCr411 = 0x4001, // Cb0[7:0] Y0[7:0] Cr0[7:0] Y1[7:0] Cb4[7:0]...
// Y2[7:0] Cr4[7:0] Y3[7:0] Y4[7:0] Y5[7:0]...
// Y6[7:0] Y7[7:0]
B_YCbCr444 = 0x4003, // Y0[7:0] Cb0[7:0] Cr0[7:0]
B_YCbCr420 = 0x4004, // Non-interlaced only, Cb0 Y0 Y1 Cb2 Y2 Y3
// on even scan lines, Cr0 Y0 Y1 Cr2 Y2 Y3
// on odd scan lines
// Extrema points are
// Y 0 - 207 (absolute)
// U -91 - 91 (offset 128)
// V -127 - 127 (offset 128)
// note that YUV byte order is different from YCbCr
// USE YCbCr, not YUV, when that's what you mean!
B_YUV422 = 0x4020, // U0[7:0] Y0[7:0] V0[7:0] Y1[7:0] ...
// U2[7:0] Y2[7:0] V2[7:0] Y3[7:0]
B_YUV411 = 0x4021, // U0[7:0] Y0[7:0] Y1[7:0] V0[7:0] Y2[7:0] Y3[7:0]
// U4[7:0] Y4[7:0] Y5[7:0] V4[7:0] Y6[7:0] Y7[7:0]
B_YUV444 = 0x4023, // U0[7:0] Y0[7:0] V0[7:0] U1[7:0] Y1[7:0] V1[7:0]
B_YUV420 = 0x4024, // Non-interlaced only, U0 Y0 Y1 U2 Y2 Y3
// on even scan lines, V0 Y0 Y1 V2 Y2 Y3
// on odd scan lines
B_YUV9 = 0x402C, // planar? 410?
B_YUV12 = 0x402D, // planar? 420?
B_UVL24 = 0x4030, // U0[7:0] V0[7:0] L0[7:0] ...
B_UVL32 = 0x4031, // U0[7:0] V0[7:0] L0[7:0] X0[7:0]...
B_UVLA32 = 0x6031, // U0[7:0] V0[7:0] L0[7:0] A0[7:0]...
B_LAB24 = 0x4032, // L0[7:0] a0[7:0] b0[7:0] ... (a is not alpha!)
B_LAB32 = 0x4033, // L0[7:0] a0[7:0] b0[7:0] X0[7:0] ... (b is not alpha!)
B_LABA32 = 0x6033, // L0[7:0] a0[7:0] b0[7:0] A0[7:0] ... (A is alpha)
// red is at hue = 0
B_HSI24 = 0x4040, // H[7:0] S[7:0] I[7:0]
B_HSI32 = 0x4041, // H[7:0] S[7:0] I[7:0] X[7:0]
B_HSIA32 = 0x6041, // H[7:0] S[7:0] I[7:0] A[7:0]
B_HSV24 = 0x4042, // H[7:0] S[7:0] V[7:0]
B_HSV32 = 0x4043, // H[7:0] S[7:0] V[7:0] X[7:0]
B_HSVA32 = 0x6043, // H[7:0] S[7:0] V[7:0] A[7:0]
B_HLS24 = 0x4044, // H[7:0] L[7:0] S[7:0]
B_HLS32 = 0x4045, // H[7:0] L[7:0] S[7:0] X[7:0]
B_HLSA32 = 0x6045, // H[7:0] L[7:0] S[7:0] A[7:0]
B_CMY24 = 0xC001, // C[7:0] M[7:0] Y[7:0] No gray removal done
B_CMY32 = 0xC002, // C[7:0] M[7:0] Y[7:0] X[7:0] No gray removal done
B_CMYA32 = 0xE002, // C[7:0] M[7:0] Y[7:0] A[7:0] No gray removal done
B_CMYK32 = 0xC003, // C[7:0] M[7:0] Y[7:0] K[7:0]
// compatibility declarations
B_MONOCHROME_1_BIT = B_GRAY1,
B_GRAYSCALE_8_BIT = B_GRAY8,
B_COLOR_8_BIT = B_CMAP8,
B_RGB_32_BIT = B_RGB32,
B_RGB_16_BIT = B_RGB15,
B_BIG_RGB_32_BIT = B_RGB32_BIG,
B_BIG_RGB_16_BIT = B_RGB15_BIG
} color_space;
// Find out whether a specific color space is supported by BBitmaps.
// Support_flags will be set to what kinds of support are available.
// If support_flags is set to 0, false will be returned.
enum {
B_VIEWS_SUPPORT_DRAW_BITMAP = 0x1,
B_BITMAPS_SUPPORT_ATTACHED_VIEWS = 0x2
};
_IMPEXP_BE bool bitmaps_support_space(color_space space, uint32 * support_flags);
//------------------------------------------------------------------------------
// "pixel_chunk" is the native increment from one pixel starting on an integral byte
// to the next. "row_alignment" is the native alignment for pixel scanline starts.
// "pixels_per_chunk" is the number of pixels in a pixel_chunk. For instance, B_GRAY1
// sets pixel_chunk to 1, row_alignment to 4 and pixels_per_chunk to 8, whereas
// B_RGB24 sets pixel_chunk to 3, row_alignment to 4 and pixels_per_chunk to 1.
//------------------------------------------------------------------------------
_IMPEXP_BE status_t get_pixel_size_for(color_space space, size_t * pixel_chunk,
size_t * row_alignment, size_t * pixels_per_chunk);
enum buffer_orientation {
B_BUFFER_TOP_TO_BOTTOM,
B_BUFFER_BOTTOM_TO_TOP
};
enum buffer_layout {
B_BUFFER_NONINTERLEAVED = 1
};
//------------------------------------------------------------------------------
enum drawing_mode {
B_OP_COPY,
B_OP_OVER,
B_OP_ERASE,
B_OP_INVERT,
B_OP_ADD,
B_OP_SUBTRACT,
B_OP_BLEND,
B_OP_MIN,
B_OP_MAX,
B_OP_SELECT,
B_OP_ALPHA
};
enum source_alpha {
B_PIXEL_ALPHA=0,
B_CONSTANT_ALPHA
};
enum alpha_function {
B_ALPHA_OVERLAY=0,
B_ALPHA_COMPOSITE
};
enum {
B_8_BIT_640x480 = 0x00000001,
B_8_BIT_800x600 = 0x00000002,
B_8_BIT_1024x768 = 0x00000004,
B_8_BIT_1280x1024 = 0x00000008,
B_8_BIT_1600x1200 = 0x00000010,
B_16_BIT_640x480 = 0x00000020,
B_16_BIT_800x600 = 0x00000040,
B_16_BIT_1024x768 = 0x00000080,
B_16_BIT_1280x1024 = 0x00000100,
B_16_BIT_1600x1200 = 0x00000200,
B_32_BIT_640x480 = 0x00000400,
B_32_BIT_800x600 = 0x00000800,
B_32_BIT_1024x768 = 0x00001000,
B_32_BIT_1280x1024 = 0x00002000,
B_32_BIT_1600x1200 = 0x00004000,
B_8_BIT_1152x900 = 0x00008000,
B_16_BIT_1152x900 = 0x00010000,
B_32_BIT_1152x900 = 0x00020000,
B_15_BIT_640x480 = 0x00040000,
B_15_BIT_800x600 = 0x00080000,
B_15_BIT_1024x768 = 0x00100000,
B_15_BIT_1280x1024 = 0x00200000,
B_15_BIT_1600x1200 = 0x00400000,
B_15_BIT_1152x900 = 0x00800000,
// do not use B_FAKE_DEVICE--it will go away!
B_FAKE_DEVICE = 0x40000000,
B_8_BIT_640x400 = (int)0x80000000
};
#endif // _GRAPHICSDEFS_H
/*
* $Log $
*
* $Id $
*
*/
#include <../os/interface/GraphicsDefs.h>
+1 -392
View File
@@ -1,392 +1 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// File Name: InterfaceDefs.h
// Author: Erik Jaesler ([email protected])
// Description: General Interface Kit definitions and global functions.
//------------------------------------------------------------------------------
#ifndef _INTERFACE_DEFS_H
#define _INTERFACE_DEFS_H
// Standard Includes -----------------------------------------------------------
// System Includes -------------------------------------------------------------
#include <BeBuild.h>
#include <GraphicsDefs.h>
#include <OS.h>
// Project Includes ------------------------------------------------------------
// Local Includes --------------------------------------------------------------
// Local Defines ---------------------------------------------------------------
// Globals ---------------------------------------------------------------------
class BRect;
/*----------------------------------------------------------------*/
struct key_info {
uint32 modifiers;
uint8 key_states[16];
};
/*----------------------------------------------------------------*/
#define B_UTF8_ELLIPSIS "\xE2\x80\xA6"
#define B_UTF8_OPEN_QUOTE "\xE2\x80\x9C"
#define B_UTF8_CLOSE_QUOTE "\xE2\x80\x9D"
#define B_UTF8_COPYRIGHT "\xC2\xA9"
#define B_UTF8_REGISTERED "\xC2\xAE"
#define B_UTF8_TRADEMARK "\xE2\x84\xA2"
#define B_UTF8_SMILING_FACE "\xE2\x98\xBB"
#define B_UTF8_HIROSHI "\xE5\xBC\x98"
#ifdef COMPILE_FOR_R5
#define B_MAX_MOUSE_BUTTONS 3
#else
#define B_MAX_MOUSE_BUTTONS 16
#endif
/*----------------------------------------------------------------*/
enum { B_BACKSPACE = 0x08,
B_RETURN = 0x0a,
B_ENTER = 0x0a,
B_SPACE = 0x20,
B_TAB = 0x09,
B_ESCAPE = 0x1b,
B_SUBSTITUTE = 0x1a,
B_LEFT_ARROW = 0x1c,
B_RIGHT_ARROW = 0x1d,
B_UP_ARROW = 0x1e,
B_DOWN_ARROW = 0x1f,
B_INSERT = 0x05,
B_DELETE = 0x7f,
B_HOME = 0x01,
B_END = 0x04,
B_PAGE_UP = 0x0b,
B_PAGE_DOWN = 0x0c,
B_FUNCTION_KEY = 0x10 };
enum { B_F1_KEY = 0x02,
B_F2_KEY = 0x03,
B_F3_KEY = 0x04,
B_F4_KEY = 0x05,
B_F5_KEY = 0x06,
B_F6_KEY = 0x07,
B_F7_KEY = 0x08,
B_F8_KEY = 0x09,
B_F9_KEY = 0x0a,
B_F10_KEY = 0x0b,
B_F11_KEY = 0x0c,
B_F12_KEY = 0x0d,
B_PRINT_KEY = 0x0e,
B_SCROLL_KEY = 0x0f,
B_PAUSE_KEY = 0x10 };
struct key_map {
uint32 version;
uint32 caps_key;
uint32 scroll_key;
uint32 num_key;
uint32 left_shift_key;
uint32 right_shift_key;
uint32 left_command_key;
uint32 right_command_key;
uint32 left_control_key;
uint32 right_control_key;
uint32 left_option_key;
uint32 right_option_key;
uint32 menu_key;
uint32 lock_settings;
int32 control_map[128];
int32 option_caps_shift_map[128];
int32 option_caps_map[128];
int32 option_shift_map[128];
int32 option_map[128];
int32 caps_shift_map[128];
int32 caps_map[128];
int32 shift_map[128];
int32 normal_map[128];
int32 acute_dead_key[32];
int32 grave_dead_key[32];
int32 circumflex_dead_key[32];
int32 dieresis_dead_key[32];
int32 tilde_dead_key[32];
uint32 acute_tables;
uint32 grave_tables;
uint32 circumflex_tables;
uint32 dieresis_tables;
uint32 tilde_tables;
};
struct mouse_map {
uint32 button[B_MAX_MOUSE_BUTTONS];
};
/*----------------------------------------------------------------*/
enum border_style {
B_PLAIN_BORDER,
B_FANCY_BORDER,
B_NO_BORDER
};
/*----------------------------------------------------------------*/
enum orientation {
B_HORIZONTAL,
B_VERTICAL
};
/*----------------------------------------------------------------*/
enum button_width {
B_WIDTH_AS_USUAL,
B_WIDTH_FROM_WIDEST,
B_WIDTH_FROM_LABEL
};
/*----------------------------------------------------------------*/
enum join_mode {
B_ROUND_JOIN=0,
B_MITER_JOIN,
B_BEVEL_JOIN,
B_BUTT_JOIN,
B_SQUARE_JOIN
};
enum cap_mode {
B_ROUND_CAP=B_ROUND_JOIN,
B_BUTT_CAP=B_BUTT_JOIN,
B_SQUARE_CAP=B_SQUARE_JOIN
};
const float B_DEFAULT_MITER_LIMIT = 10.0F;
/*----------------------------------------------------------------*/
struct scroll_bar_info {
bool proportional;
bool double_arrows;
int32 knob;
int32 min_knob_size;
};
/*----------------------------------------------------------------*/
enum alignment {
B_ALIGN_LEFT,
B_ALIGN_RIGHT,
B_ALIGN_CENTER
};
enum vertical_alignment {
B_ALIGN_TOP = 0x10L,
B_ALIGN_MIDDLE = 0x20,
B_ALIGN_BOTTOM = 0x30,
B_ALIGN_NO_VERTICAL = -1L
};
/*----------------------------------------------------------------*/
enum {
B_CONTROL_TABLE = 0x00000001,
B_OPTION_CAPS_SHIFT_TABLE = 0x00000002,
B_OPTION_CAPS_TABLE = 0x00000004,
B_OPTION_SHIFT_TABLE = 0x00000008,
B_OPTION_TABLE = 0x00000010,
B_CAPS_SHIFT_TABLE = 0x00000020,
B_CAPS_TABLE = 0x00000040,
B_SHIFT_TABLE = 0x00000080,
B_NORMAL_TABLE = 0x00000100
};
/*----------------------------------------------------------------*/
enum {
B_SHIFT_KEY = 0x00000001,
B_COMMAND_KEY = 0x00000002,
B_CONTROL_KEY = 0x00000004,
B_CAPS_LOCK = 0x00000008,
B_SCROLL_LOCK = 0x00000010,
B_NUM_LOCK = 0x00000020,
B_OPTION_KEY = 0x00000040,
B_MENU_KEY = 0x00000080,
B_LEFT_SHIFT_KEY = 0x00000100,
B_RIGHT_SHIFT_KEY = 0x00000200,
B_LEFT_COMMAND_KEY = 0x00000400,
B_RIGHT_COMMAND_KEY = 0x00000800,
B_LEFT_CONTROL_KEY = 0x00001000,
B_RIGHT_CONTROL_KEY = 0x00002000,
B_LEFT_OPTION_KEY = 0x00004000,
B_RIGHT_OPTION_KEY = 0x00008000
};
/*----------------------------------------------------------------*/
enum bitmap_tiling {
B_TILE_BITMAP_X = 0x00000001,
B_TILE_BITMAP_Y = 0x00000002,
B_TILE_BITMAP = 0x00000003
};
enum overlay_options {
B_OVERLAY_FILTER_HORIZONTAL = 0x00010000,
B_OVERLAY_FILTER_VERTICAL = 0x00020000,
B_OVERLAY_MIRROR = 0x00040000,
B_OVERLAY_TRANSFER_CHANNEL = 0x00080000
};
/*----------------------------------------------------------------*/
_IMPEXP_BE status_t get_deskbar_frame(BRect *frame);
_IMPEXP_BE const color_map *system_colors();
_IMPEXP_BE status_t set_screen_space(int32 index, uint32 res,
bool stick = true);
_IMPEXP_BE status_t get_scroll_bar_info(scroll_bar_info *info);
_IMPEXP_BE status_t set_scroll_bar_info(scroll_bar_info *info);
_IMPEXP_BE status_t get_mouse_type(int32 *type);
_IMPEXP_BE status_t set_mouse_type(int32 type);
_IMPEXP_BE status_t get_mouse_map(mouse_map *map);
_IMPEXP_BE status_t set_mouse_map(mouse_map *map);
_IMPEXP_BE status_t get_click_speed(bigtime_t *speed);
_IMPEXP_BE status_t set_click_speed(bigtime_t speed);
_IMPEXP_BE status_t get_mouse_speed(int32 *speed);
_IMPEXP_BE status_t set_mouse_speed(int32 speed);
_IMPEXP_BE status_t get_mouse_acceleration(int32 *speed);
_IMPEXP_BE status_t set_mouse_acceleration(int32 speed);
_IMPEXP_BE status_t get_key_repeat_rate(int32 *rate);
_IMPEXP_BE status_t set_key_repeat_rate(int32 rate);
_IMPEXP_BE status_t get_key_repeat_delay(bigtime_t *delay);
_IMPEXP_BE status_t set_key_repeat_delay(bigtime_t delay);
_IMPEXP_BE uint32 modifiers();
_IMPEXP_BE status_t get_key_info(key_info *info);
_IMPEXP_BE void get_key_map(key_map **map, char **key_buffer);
_IMPEXP_BE status_t get_keyboard_id(uint16 *id);
_IMPEXP_BE void set_modifier_key(uint32 modifier, uint32 key);
_IMPEXP_BE void set_keyboard_locks(uint32 modifiers);
_IMPEXP_BE rgb_color keyboard_navigation_color();
_IMPEXP_BE int32 count_workspaces();
_IMPEXP_BE void set_workspace_count(int32 count);
_IMPEXP_BE int32 current_workspace();
_IMPEXP_BE void activate_workspace(int32 workspace);
_IMPEXP_BE bigtime_t idle_time();
_IMPEXP_BE void run_select_printer_panel();
_IMPEXP_BE void run_add_printer_panel();
_IMPEXP_BE void run_be_about();
_IMPEXP_BE void set_focus_follows_mouse(bool follow);
_IMPEXP_BE bool focus_follows_mouse();
enum mode_mouse {
B_NORMAL_MOUSE = 0,
B_FOCUS_FOLLOWS_MOUSE = 1,
B_WARP_MOUSE = 3,
B_INSTANT_WARP_MOUSE = 7
};
_IMPEXP_BE void set_mouse_mode(mode_mouse mode);
_IMPEXP_BE mode_mouse mouse_mode();
enum color_which {
B_PANEL_BACKGROUND_COLOR = 1,
B_PANEL_TEXT_COLOR = 10,
B_DOCUMENT_BACKGROUND_COLOR = 11,
B_DOCUMENT_TEXT_COLOR = 12,
B_CONTROL_BACKGROUND_COLOR = 13,
B_CONTROL_TEXT_COLOR = 14,
B_CONTROL_BORDER_COLOR = 15,
B_CONTROL_HIGHLIGHT_COLOR = 16,
B_NAVIGATION_BASE_COLOR = 4,
B_NAVIGATION_PULSE_COLOR = 17,
B_SHINE_COLOR = 18,
B_SHADOW_COLOR = 19,
B_MENU_BACKGROUND_COLOR = 2,
B_MENU_SELECTED_BACKGROUND_COLOR = 6,
B_MENU_ITEM_TEXT_COLOR = 7,
B_MENU_SELECTED_ITEM_TEXT_COLOR = 8,
B_MENU_SELECTED_BORDER_COLOR = 9,
B_TOOLTIP_BACKGROUND_COLOR = 20,
B_TOOLTIP_TEXT_COLOR = 21,
B_SUCCESS_COLOR = 100,
B_FAILURE_COLOR = 101,
// Old name synonyms.
B_KEYBOARD_NAVIGATION_COLOR = B_NAVIGATION_BASE_COLOR,
B_MENU_SELECTION_BACKGROUND_COLOR = B_MENU_SELECTED_BACKGROUND_COLOR,
// These are deprecated -- do not use in new code. See BScreen for
// the replacement for B_DESKTOP_COLOR.
B_DESKTOP_COLOR = 5,
B_WINDOW_TAB_COLOR = 3,
B_RANDOM_COLOR = 0x80000000,
B_MICHELANGELO_FAVORITE_COLOR,
B_DSANDLER_FAVORITE_SKY_COLOR,
B_DSANDLER_FAVORITE_INK_COLOR,
B_DSANDLER_FAVORITE_SHOES_COLOR
};
_IMPEXP_BE rgb_color ui_color(color_which which);
_IMPEXP_BE rgb_color tint_color(rgb_color color, float tint);
extern "C" status_t _init_interface_kit_();
/* effects on standard gray level */
const float B_LIGHTEN_MAX_TINT = 0.0F; /* 216 --> 255.0 (255) */
const float B_LIGHTEN_2_TINT = 0.385F; /* 216 --> 240.0 (240) */
const float B_LIGHTEN_1_TINT = 0.590F; /* 216 --> 232.0 (232) */
const float B_NO_TINT = 1.0F; /* 216 --> 216.0 (216) */
const float B_DARKEN_1_TINT = 1.147F; /* 216 --> 184.2 (184) */
const float B_DARKEN_2_TINT = 1.295F; /* 216 --> 152.3 (152) */
const float B_DARKEN_3_TINT = 1.407F; /* 216 --> 128.1 (128) */
const float B_DARKEN_4_TINT = 1.555F; /* 216 --> 96.1 (96) */
const float B_DARKEN_MAX_TINT = 2.0F; /* 216 --> 0.0 (0) */
const float B_DISABLED_LABEL_TINT = B_DARKEN_3_TINT;
const float B_HIGHLIGHT_BACKGROUND_TINT = B_DARKEN_2_TINT;
const float B_DISABLED_MARK_TINT = B_LIGHTEN_2_TINT;
/*-------------------------------------------------------------*/
/*-------------------------------------------------------------*/
#endif // _INTERFACE_DEFS_H
#include <../os/interface/InterfaceDefs.h>
+1 -114
View File
@@ -1,114 +1 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// File Name: Point.h
// Author: Frans van Nispen
// Description: BPoint represents a single x,y coordinate.
//------------------------------------------------------------------------------
#ifndef _POINT_H
#define _POINT_H
// Standard Includes -----------------------------------------------------------
// System Includes -------------------------------------------------------------
#include <BeBuild.h>
#include <SupportDefs.h>
// Project Includes ------------------------------------------------------------
// Local Includes --------------------------------------------------------------
// Local Defines ---------------------------------------------------------------
// Globals ---------------------------------------------------------------------
class BRect;
// BPoint class ----------------------------------------------------------------
class BPoint {
public:
float x;
float y;
BPoint();
BPoint(float X, float Y);
BPoint(const BPoint &p);
BPoint &operator=(const BPoint &p);
void Set(float X, float Y);
void ConstrainTo(BRect r);
void PrintToStream() const;
BPoint operator+(const BPoint &p) const;
BPoint operator-(const BPoint &p) const;
BPoint& operator+=(const BPoint &p);
BPoint& operator-=(const BPoint &p);
bool operator!=(const BPoint &p) const;
bool operator==(const BPoint &p) const;
};
//------------------------------------------------------------------------------
extern _IMPEXP_BE const BPoint B_ORIGIN; // returns (0,0)
//------------------------------------------------------------------------------
inline BPoint::BPoint()
{
x = y = 0;
}
//------------------------------------------------------------------------------
inline BPoint::BPoint(float X, float Y)
{
x = X;
y = Y;
}
//------------------------------------------------------------------------------
inline BPoint::BPoint(const BPoint& pt)
{
x = pt.x;
y = pt.y;
}
//------------------------------------------------------------------------------
inline BPoint &BPoint::operator=(const BPoint& from)
{
x = from.x;
y = from.y;
return *this;
}
//------------------------------------------------------------------------------
inline void BPoint::Set(float X, float Y)
{
x = X;
y = Y;
}
//------------------------------------------------------------------------------
#endif // _POINT_H
/*
* $Log $
*
* $Id $
*
*/
#include <../os/interface/Point.h>
+1 -213
View File
@@ -1,213 +1 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2005, Haiku
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// File Name: Rect.h
// Author: Frans van Nispen ([email protected])
// Description: BRect represents a rectangular area.
//------------------------------------------------------------------------------
#ifndef _RECT_H
#define _RECT_H
#include <SupportDefs.h>
#include <Point.h>
#include <math.h>
class BRect {
public:
float left;
float top;
float right;
float bottom;
BRect();
BRect(const BRect &r);
BRect(float l, float t, float r, float b);
BRect(BPoint lt, BPoint rb);
BRect &operator=(const BRect &r);
void Set(float l, float t, float r, float b);
void PrintToStream() const;
BPoint LeftTop() const;
BPoint RightBottom() const;
BPoint LeftBottom() const;
BPoint RightTop() const;
void SetLeftTop(const BPoint p);
void SetRightBottom(const BPoint p);
void SetLeftBottom(const BPoint p);
void SetRightTop(const BPoint p);
// transformation
void InsetBy(BPoint p);
void InsetBy(float dx, float dy);
void OffsetBy(BPoint p);
void OffsetBy(float dx, float dy);
void OffsetTo(BPoint p);
void OffsetTo(float x, float y);
// expression transformations
BRect& InsetBySelf(BPoint);
BRect& InsetBySelf(float dx, float dy);
BRect InsetByCopy(BPoint);
BRect InsetByCopy(float dx, float dy);
BRect& OffsetBySelf(BPoint);
BRect& OffsetBySelf(float dx, float dy);
BRect OffsetByCopy(BPoint);
BRect OffsetByCopy(float dx, float dy);
BRect& OffsetToSelf(BPoint);
BRect& OffsetToSelf(float dx, float dy);
BRect OffsetToCopy(BPoint);
BRect OffsetToCopy(float dx, float dy);
// comparison
bool operator==(BRect r) const;
bool operator!=(BRect r) const;
// intersection and union
BRect operator&(BRect r) const;
BRect operator|(BRect r) const;
bool Intersects(BRect r) const;
bool IsValid() const;
float Width() const;
int32 IntegerWidth() const;
float Height() const;
int32 IntegerHeight() const;
bool Contains(BPoint p) const;
bool Contains(BRect r) const;
};
// inline definitions ----------------------------------------------------------
inline BPoint
BRect::LeftTop() const
{
return *(const BPoint *)&left;
}
inline BPoint
BRect::RightBottom() const
{
return *(const BPoint *)&right;
}
inline BPoint
BRect::LeftBottom() const
{
return BPoint(left, bottom);
}
inline BPoint
BRect::RightTop() const
{
return BPoint(right, top);
}
inline
BRect::BRect()
{
top = left = 0;
bottom = right = -1;
}
inline
BRect::BRect(float l, float t, float r, float b)
{
left = l;
top = t;
right = r;
bottom = b;
}
inline
BRect::BRect(const BRect &r)
{
left = r.left;
top = r.top;
right = r.right;
bottom = r.bottom;
}
inline
BRect::BRect(BPoint leftTop, BPoint rightBottom)
{
left = leftTop.x;
top = leftTop.y;
right = rightBottom.x;
bottom = rightBottom.y;
}
inline BRect &
BRect::operator=(const BRect& from)
{
left = from.left;
top = from.top;
right = from.right;
bottom = from.bottom;
return *this;
}
inline void
BRect::Set(float l, float t, float r, float b)
{
left = l;
top = t;
right = r;
bottom = b;
}
inline bool
BRect::IsValid() const
{
return left <= right && top <= bottom;
}
inline int32
BRect::IntegerWidth() const
{
return (int32)ceil(right - left);
}
inline float
BRect::Width() const
{
return right - left;
}
inline int32
BRect::IntegerHeight() const
{
return (int32)ceil(bottom - top);
}
inline float
BRect::Height() const
{
return bottom - top;
}
#endif // _RECT_H
#include <../os/interface/Rect.h>
+1 -95
View File
@@ -1,95 +1 @@
/*
* Copyright 2007, Haiku. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _REGION_H
#define _REGION_H
#include <BeBuild.h>
#include <Rect.h>
namespace BPrivate {
class ServerLink;
class LinkReceiver;
};
/* Integer rect used to define a clipping rectangle. All bounds are inclusive. */
/* Moved from DirectWindow.h */
typedef struct {
int32 left;
int32 top;
int32 right;
int32 bottom;
} clipping_rect;
class BRegion {
public:
BRegion();
BRegion(const BRegion& region);
BRegion(const BRect rect);
virtual ~BRegion();
BRegion &operator=(const BRegion &from);
void Set(BRect newBounds);
void Set(clipping_rect newBounds);
BRect Frame() const;
clipping_rect FrameInt() const;
BRect RectAt(int32 index) /*const*/;
clipping_rect RectAtInt(int32 index) /*const*/;
int32 CountRects() /*const*/;
bool Intersects(BRect rect) const;
bool Intersects(clipping_rect rect) const;
bool Contains(BPoint point) const;
bool Contains(int32 x, int32 y) /*const*/;
void PrintToStream() const;
void OffsetBy(int32 x, int32 y);
void MakeEmpty();
void Include(BRect rect);
void Include(clipping_rect rect);
void Include(const BRegion*);
void Exclude(BRect r);
void Exclude(clipping_rect r);
void Exclude(const BRegion* region);
void IntersectWith(const BRegion* region);
private:
friend class BDirectWindow;
friend class BPrivate::ServerLink;
friend class BPrivate::LinkReceiver;
class Support;
friend class Support;
private:
BRegion(const clipping_rect& rect);
void _AdoptRegionData(BRegion& region);
bool _SetSize(long newSize);
clipping_rect _Convert(const BRect& rect) const;
clipping_rect _ConvertToInternal(const BRect& rect) const;
clipping_rect _ConvertToInternal(
const clipping_rect& rect) const;
private:
long fCount;
long fDataSize;
clipping_rect fBounds;
clipping_rect* fData;
};
#endif // _REGION_H
#include <../os/interface/Region.h>
+1
View File
@@ -0,0 +1 @@
#include <../os/interface/Size.h>
+1 -627
View File
@@ -1,627 +1 @@
/* Kernel specific structures and functions
*
* Copyright 2004, Haiku Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _OS_H
#define _OS_H
#include <stdarg.h>
#include <SupportDefs.h>
#include <StorageDefs.h>
#ifdef __cplusplus
extern "C" {
#endif
/*-------------------------------------------------------------*/
/* System constants */
#define B_OS_NAME_LENGTH 32
#define B_PAGE_SIZE 4096
#define B_INFINITE_TIMEOUT (9223372036854775807LL)
enum {
B_TIMEOUT = 8, /* relative timeout */
B_RELATIVE_TIMEOUT = 8, /* fails after a relative timeout with B_WOULD_BLOCK */
B_ABSOLUTE_TIMEOUT = 16, /* fails after an absolute timeout with B_WOULD BLOCK */
};
/*-------------------------------------------------------------*/
/* Types */
typedef int32 area_id;
typedef int32 port_id;
typedef int32 sem_id;
typedef int32 team_id;
typedef int32 thread_id;
/*-------------------------------------------------------------*/
/* Areas */
typedef struct area_info {
area_id area;
char name[B_OS_NAME_LENGTH];
size_t size;
uint32 lock;
uint32 protection;
team_id team;
uint32 ram_size;
uint32 copy_count;
uint32 in_count;
uint32 out_count;
void *address;
} area_info;
/* area locking */
#define B_NO_LOCK 0
#define B_LAZY_LOCK 1
#define B_FULL_LOCK 2
#define B_CONTIGUOUS 3
#define B_LOMEM 4
/* address spec for create_area(), and clone_area() */
#define B_ANY_ADDRESS 0
#define B_EXACT_ADDRESS 1
#define B_BASE_ADDRESS 2
#define B_CLONE_ADDRESS 3
#define B_ANY_KERNEL_ADDRESS 4
/* area protection */
#define B_READ_AREA 1
#define B_WRITE_AREA 2
extern area_id create_area(const char *name, void **start_addr, uint32 addr_spec,
size_t size, uint32 lock, uint32 protection);
extern area_id clone_area(const char *name, void **dest_addr, uint32 addr_spec,
uint32 protection, area_id source);
extern area_id find_area(const char *name);
extern area_id area_for(void *address);
extern status_t delete_area(area_id id);
extern status_t resize_area(area_id id, size_t new_size);
extern status_t set_area_protection(area_id id, uint32 new_protection);
/* system private, use macros instead */
extern status_t _get_area_info(area_id id, area_info *areaInfo, size_t size);
extern status_t _get_next_area_info(team_id team, int32 *cookie, area_info *areaInfo, size_t size);
#define get_area_info(id, ainfo) \
_get_area_info((id), (ainfo),sizeof(*(ainfo)))
#define get_next_area_info(team, cookie, ainfo) \
_get_next_area_info((team), (cookie), (ainfo), sizeof(*(ainfo)))
/*-------------------------------------------------------------*/
/* Ports */
typedef struct port_info {
port_id port;
team_id team;
char name[B_OS_NAME_LENGTH];
int32 capacity; /* queue depth */
int32 queue_count; /* # msgs waiting to be read */
int32 total_count; /* total # msgs read so far */
} port_info;
extern port_id create_port(int32 capacity, const char *name);
extern port_id find_port(const char *name);
extern ssize_t read_port(port_id port, int32 *code, void *buffer, size_t bufferSize);
extern ssize_t read_port_etc(port_id port, int32 *code, void *buffer, size_t bufferSize,
uint32 flags, bigtime_t timeout);
extern status_t write_port(port_id port, int32 code, const void *buffer, size_t bufferSize);
extern status_t write_port_etc(port_id port, int32 code, const void *buffer, size_t bufferSize,
uint32 flags, bigtime_t timeout);
extern status_t close_port(port_id port);
extern status_t delete_port(port_id port);
extern ssize_t port_buffer_size(port_id port);
extern ssize_t port_buffer_size_etc(port_id port, uint32 flags, bigtime_t timeout);
extern ssize_t port_count(port_id port);
extern status_t set_port_owner(port_id port, team_id team);
/* system private, use the macros instead */
extern status_t _get_port_info(port_id port, port_info *portInfo, size_t portInfoSize);
extern status_t _get_next_port_info(team_id team, int32 *cookie, port_info *portInfo,
size_t portInfoSize);
#define get_port_info(port, info) \
_get_port_info((port), (info), sizeof(*(info)))
#define get_next_port_info(team, cookie, info) \
_get_next_port_info((team), (cookie), (info), sizeof(*(info)))
/*-------------------------------------------------------------*/
/* Semaphores */
typedef struct sem_info {
sem_id sem;
team_id team;
char name[B_OS_NAME_LENGTH];
int32 count;
thread_id latest_holder;
} sem_info;
/* semaphore flags */
enum {
B_CAN_INTERRUPT = 0x01, // acquisition of the semaphore can be
// interrupted (system use only)
B_CHECK_PERMISSION = 0x04, // ownership will be checked (system use
// only)
B_KILL_CAN_INTERRUPT = 0x20, // acquisition of the semaphore can be
// interrupted by SIGKILL[THR], even
// if not B_CAN_INTERRUPT (system use
// only)
/* release_sem_etc() only flags */
B_DO_NOT_RESCHEDULE = 0x02, // thread is not rescheduled
B_RELEASE_ALL = 0x08, // all waiting threads will be woken up,
// count will be zeroed
B_RELEASE_IF_WAITING_ONLY = 0x10, // release count only if there are any
// threads waiting
};
extern sem_id create_sem(int32 count, const char *name);
extern status_t delete_sem(sem_id id);
extern status_t acquire_sem(sem_id id);
extern status_t acquire_sem_etc(sem_id id, int32 count, uint32 flags, bigtime_t timeout);
extern status_t release_sem(sem_id id);
extern status_t release_sem_etc(sem_id id, int32 count, uint32 flags);
// ToDo: the following two calls are not part of the BeOS API, and might be
// changed or even removed for the final release of Haiku R1
extern status_t switch_sem(sem_id semToBeReleased, sem_id id);
extern status_t switch_sem_etc(sem_id semToBeReleased, sem_id id, int32 count,
uint32 flags, bigtime_t timeout);
extern status_t get_sem_count(sem_id id, int32 *threadCount);
extern status_t set_sem_owner(sem_id id, team_id team);
/* system private, use the macros instead */
extern status_t _get_sem_info(sem_id id, struct sem_info *info, size_t infoSize);
extern status_t _get_next_sem_info(team_id team, int32 *cookie, struct sem_info *info,
size_t infoSize);
#define get_sem_info(sem, info) \
_get_sem_info((sem), (info), sizeof(*(info)))
#define get_next_sem_info(team, cookie, info) \
_get_next_sem_info((team), (cookie), (info), sizeof(*(info)))
/*-------------------------------------------------------------*/
/* Teams */
typedef struct {
team_id team;
int32 thread_count;
int32 image_count;
int32 area_count;
thread_id debugger_nub_thread;
port_id debugger_nub_port;
int32 argc;
char args[64];
uid_t uid;
gid_t gid;
} team_info;
#define B_CURRENT_TEAM 0
#define B_SYSTEM_TEAM 2
extern status_t kill_team(team_id team);
/* see also: send_signal() */
/* system private, use macros instead */
extern status_t _get_team_info(team_id id, team_info *info, size_t size);
extern status_t _get_next_team_info(int32 *cookie, team_info *info, size_t size);
#define get_team_info(id, info) \
_get_team_info((id), (info), sizeof(*(info)))
#define get_next_team_info(cookie, info) \
_get_next_team_info((cookie), (info), sizeof(*(info)))
/* team usage info */
typedef struct {
bigtime_t user_time;
bigtime_t kernel_time;
} team_usage_info;
enum {
/* compatible to sys/resource.h RUSAGE_SELF and RUSAGE_CHILDREN */
B_TEAM_USAGE_SELF = 0,
B_TEAM_USAGE_CHILDREN = -1,
};
/* system private, use macros instead */
extern status_t _get_team_usage_info(team_id team, int32 who, team_usage_info *info, size_t size);
#define get_team_usage_info(team, who, info) \
_get_team_usage_info((team), (who), (info), sizeof(*(info)))
/*-------------------------------------------------------------*/
/* Threads */
typedef enum {
B_THREAD_RUNNING = 1,
B_THREAD_READY,
B_THREAD_RECEIVING,
B_THREAD_ASLEEP,
B_THREAD_SUSPENDED,
B_THREAD_WAITING
} thread_state;
typedef struct {
thread_id thread;
team_id team;
char name[B_OS_NAME_LENGTH];
thread_state state;
int32 priority;
sem_id sem;
bigtime_t user_time;
bigtime_t kernel_time;
void *stack_base;
void *stack_end;
} thread_info;
#define B_IDLE_PRIORITY 0
#define B_LOWEST_ACTIVE_PRIORITY 1
#define B_LOW_PRIORITY 5
#define B_NORMAL_PRIORITY 10
#define B_DISPLAY_PRIORITY 15
#define B_URGENT_DISPLAY_PRIORITY 20
#define B_REAL_TIME_DISPLAY_PRIORITY 100
#define B_URGENT_PRIORITY 110
#define B_REAL_TIME_PRIORITY 120
#define B_FIRST_REAL_TIME_PRIORITY B_REAL_TIME_DISPLAY_PRIORITY
#define B_MIN_PRIORITY B_IDLE_PRIORITY
#define B_MAX_PRIORITY B_REAL_TIME_PRIORITY
#define B_SYSTEM_TIMEBASE 0
typedef int32 (*thread_func) (void *);
#define thread_entry thread_func /* thread_entry is for backward compatibility only! Use thread_func */
extern thread_id spawn_thread(thread_func, const char *name, int32 priority, void *data);
extern status_t kill_thread(thread_id thread);
extern status_t resume_thread(thread_id thread);
extern status_t suspend_thread(thread_id thread);
extern status_t rename_thread(thread_id thread, const char *newName);
extern status_t set_thread_priority (thread_id thread, int32 newPriority);
extern void exit_thread(status_t status);
extern status_t wait_for_thread (thread_id thread, status_t *threadReturnValue);
extern status_t on_exit_thread(void (*callback)(void *), void *data);
extern thread_id find_thread(const char *name);
extern status_t send_data(thread_id thread, int32 code, const void *buffer,
size_t bufferSize);
extern int32 receive_data(thread_id *sender, void *buffer, size_t bufferSize);
extern bool has_data(thread_id thread);
extern status_t snooze(bigtime_t amount);
extern status_t snooze_etc(bigtime_t amount, int timeBase, uint32 flags);
extern status_t snooze_until(bigtime_t time, int timeBase);
/* system private, use macros instead */
extern status_t _get_thread_info(thread_id id, thread_info *info, size_t size);
extern status_t _get_next_thread_info(team_id team, int32 *cookie,
thread_info *info, size_t size);
#define get_thread_info(id, info) \
_get_thread_info((id), (info), sizeof(*(info)))
#define get_next_thread_info(team, cookie, info) \
_get_next_thread_info((team), (cookie), (info), sizeof(*(info)))
/*-------------------------------------------------------------*/
/* Time */
extern uint32 real_time_clock(void);
extern void set_real_time_clock(uint32 secs_since_jan1_1970);
extern bigtime_t real_time_clock_usecs(void);
extern status_t set_timezone(char *timezone);
extern bigtime_t system_time(void); /* time since booting in microseconds */
/*-------------------------------------------------------------*/
/* Alarm */
enum {
B_ONE_SHOT_ABSOLUTE_ALARM = 1,
B_ONE_SHOT_RELATIVE_ALARM,
B_PERIODIC_ALARM /* "when" specifies the period */
};
extern bigtime_t set_alarm(bigtime_t when, uint32 flags);
/*-------------------------------------------------------------*/
/* Debugger */
extern void debugger(const char *message);
/*
calling this function with a non-zero value will cause your thread
to receive signals for any exceptional conditions that occur (i.e.
you'll get SIGSEGV for data access exceptions, SIGFPE for floating
point errors, SIGILL for illegal instructions, etc).
to re-enable the default debugger pass a zero.
*/
extern int disable_debugger(int state);
// TODO: Remove. Temporary debug helper.
extern void debug_printf(const char *format, ...)
__attribute__ ((format (__printf__, 1, 2)));
extern void debug_vprintf(const char *format, va_list args);
/*-------------------------------------------------------------*/
/* System information */
#if __INTEL__
# define B_MAX_CPU_COUNT 8
#elif __POWERPC__
# define B_MAX_CPU_COUNT 8
#endif
#define OBOS_CPU_TYPES
typedef enum cpu_types {
// ToDo: add latest models
/* Motorola/IBM */
B_CPU_PPC_601 = 1,
B_CPU_PPC_603 = 2,
B_CPU_PPC_603e = 3,
B_CPU_PPC_604 = 4,
B_CPU_PPC_604e = 5,
B_CPU_PPC_750 = 6,
B_CPU_PPC_686 = 13,
/* Intel */
/* Updated according to Intel(R) Processor Identification and
* the CPUID instruction (Table 4)
* AP-485 Intel - 24161828.pdf
*/
B_CPU_INTEL_x86 = 0x1000,
B_CPU_INTEL_PENTIUM = 0x1051,
B_CPU_INTEL_PENTIUM75,
B_CPU_INTEL_PENTIUM_486_OVERDRIVE,
B_CPU_INTEL_PENTIUM_MMX,
B_CPU_INTEL_PENTIUM_MMX_MODEL_4 = B_CPU_INTEL_PENTIUM_MMX,
B_CPU_INTEL_PENTIUM_MMX_MODEL_8 = 0x1058,
B_CPU_INTEL_PENTIUM75_486_OVERDRIVE,
B_CPU_INTEL_PENTIUM_PRO = 0x1061,
B_CPU_INTEL_PENTIUM_II = 0x1063,
B_CPU_INTEL_PENTIUM_II_MODEL_3 = 0x1063,
B_CPU_INTEL_PENTIUM_II_MODEL_5 = 0x1065,
B_CPU_INTEL_CELERON = 0x1066,
B_CPU_INTEL_PENTIUM_III = 0x1067,
B_CPU_INTEL_PENTIUM_III_MODEL_8 = 0x1068,
B_CPU_INTEL_PENTIUM_M = 0x1069,
B_CPU_INTEL_PENTIUM_III_XEON = 0x106a,
B_CPU_INTEL_PENTIUM_III_MODEL_11 = 0x106b,
B_CPU_INTEL_PENTIUM_M_MODEL_13 = 0x106d, /* Dothan */
B_CPU_INTEL_PENTIUM_IV = 0x10f0,
B_CPU_INTEL_PENTIUM_IV_MODEL_1,
B_CPU_INTEL_PENTIUM_IV_MODEL_2,
B_CPU_INTEL_PENTIUM_IV_MODEL_3,
B_CPU_INTEL_PENTIUM_IV_MODEL_4,
/* AMD */
/* Checked with "AMD Processor Recognition Application Note"
* (Table 3)
* 20734.pdf
*/
B_CPU_AMD_x86 = 0x1100,
B_CPU_AMD_K5_MODEL_0 = 0x1150,
B_CPU_AMD_K5_MODEL_1,
B_CPU_AMD_K5_MODEL_2,
B_CPU_AMD_K5_MODEL_3,
B_CPU_AMD_K6_MODEL_6 = 0x1156,
B_CPU_AMD_K6_MODEL_7 = 0x1157,
B_CPU_AMD_K6_MODEL_8 = 0x1158,
B_CPU_AMD_K6_2 = 0x1158,
B_CPU_AMD_K6_MODEL_9 = 0x1159,
B_CPU_AMD_K6_III = 0x1159,
B_CPU_AMD_K6_III_MODEL_13 = 0x115d,
B_CPU_AMD_ATHLON_MODEL_1 = 0x1161,
B_CPU_AMD_ATHLON_MODEL_2 = 0x1162,
B_CPU_AMD_DURON = 0x1163,
B_CPU_AMD_ATHLON_THUNDERBIRD = 0x1164,
B_CPU_AMD_ATHLON_XP = 0x1166,
B_CPU_AMD_ATHLON_XP_MODEL_7,
B_CPU_AMD_ATHLON_XP_MODEL_8,
B_CPU_AMD_ATHLON_XP_MODEL_10 = 0x116a, /* Barton */
B_CPU_AMD_SEMPRON_MODEL_8 = B_CPU_AMD_ATHLON_XP_MODEL_8,
B_CPU_AMD_SEMPRON_MODEL_10 = B_CPU_AMD_ATHLON_XP_MODEL_10,
/* According to "Revision guide for AMD Athlon 64
* and AMD Opteron Processors" (25759.pdf)
*/
B_CPU_AMD_ATHLON_64_MODEL_4 = 0x11f4,
B_CPU_AMD_ATHLON_64_MODEL_5,
B_CPU_AMD_OPTERON = B_CPU_AMD_ATHLON_64_MODEL_5,
B_CPU_AMD_ATHLON_64_FX = B_CPU_AMD_ATHLON_64_MODEL_5,
B_CPU_AMD_ATHLON_64_MODEL_7 = 0x11f7,
B_CPU_AMD_ATHLON_64_MODEL_8,
B_CPU_AMD_ATHLON_64_MODEL_11 = 0x11fb,
B_CPU_AMD_ATHLON_64_MODEL_12,
B_CPU_AMD_ATHLON_64_MODEL_14 = 0x11fe,
B_CPU_AMD_ATHLON_64_MODEL_15,
/* VIA/Cyrix */
B_CPU_CYRIX_x86 = 0x1200,
B_CPU_VIA_CYRIX_x86 = 0x1200,
B_CPU_CYRIX_GXm = 0x1254,
B_CPU_CYRIX_6x86MX = 0x1260,
/* VIA/IDT */
B_CPU_IDT_x86 = 0x1300,
B_CPU_VIA_IDT_x86 = 0x1300,
B_CPU_IDT_WINCHIP_C6 = 0x1354,
B_CPU_IDT_WINCHIP_2 = 0x1358,
B_CPU_IDT_WINCHIP_3,
B_CPU_VIA_EDEN = 0x1367,
B_CPU_VIA_EDEN_EZRA_T = 0x1368,
/* Transmeta */
B_CPU_TRANSMETA_x86 = 0x1600,
B_CPU_TRANSMETA_CRUSOE = 0x1654,
/* Rise */
B_CPU_RISE_x86 = 0x1400,
B_CPU_RISE_mP6 = 0x1450,
/* National Semiconductor */
B_CPU_NATIONAL_x86 = 0x1500,
B_CPU_NATIONAL_GEODE_GX1 = 0x1554,
B_CPU_NATIONAL_GEODE_GX2,
/* For compatibility */
B_CPU_AMD_29K = 14,
B_CPU_x86,
B_CPU_MC6502,
B_CPU_Z80,
B_CPU_ALPHA,
B_CPU_MIPS,
B_CPU_HPPA,
B_CPU_M68K,
B_CPU_ARM,
B_CPU_SH,
B_CPU_SPARC,
} cpu_type;
#define B_CPU_x86_VENDOR_MASK 0xff00
#ifdef __INTEL__
typedef union {
struct {
uint32 max_eax;
char vendor_id[12];
} eax_0;
struct {
uint32 stepping : 4;
uint32 model : 4;
uint32 family : 4;
uint32 type : 2;
uint32 reserved_0 : 2;
uint32 extended_model : 4;
uint32 extended_family : 8;
uint32 reserved_1 : 4;
uint32 reserved_2;
uint32 features;
uint32 reserved_3;
} eax_1;
struct {
uint8 call_num;
uint8 cache_descriptors[15];
} eax_2;
struct {
uint32 reserved[2];
uint32 serial_number_high;
uint32 serial_number_low;
} eax_3;
char as_chars[16];
struct {
uint32 eax;
uint32 ebx;
uint32 edx;
uint32 ecx;
} regs;
} cpuid_info;
extern status_t get_cpuid(cpuid_info *info, uint32 eaxRegister, uint32 cpuNum);
#endif
typedef enum platform_types {
B_BEBOX_PLATFORM = 0,
B_MAC_PLATFORM,
B_AT_CLONE_PLATFORM,
B_ENIAC_PLATFORM,
B_APPLE_II_PLATFORM,
B_CRAY_PLATFORM,
B_LISA_PLATFORM,
B_TI_994A_PLATFORM,
B_TIMEX_SINCLAIR_PLATFORM,
B_ORAC_1_PLATFORM,
B_HAL_PLATFORM,
B_BESM_6_PLATFORM,
B_MK_61_PLATFORM,
B_NINTENDO_64_PLATFORM
} platform_type;
typedef struct {
bigtime_t active_time; /* usec of doing useful work since boot */
} cpu_info;
typedef int32 machine_id[2]; /* unique machine ID */
typedef struct {
machine_id id; /* unique machine ID */
bigtime_t boot_time; /* time of boot (usecs since 1/1/1970) */
int32 cpu_count; /* number of cpus */
enum cpu_types cpu_type; /* type of cpu */
int32 cpu_revision; /* revision # of cpu */
cpu_info cpu_infos[B_MAX_CPU_COUNT]; /* info about individual cpus */
int64 cpu_clock_speed; /* processor clock speed (Hz) */
int64 bus_clock_speed; /* bus clock speed (Hz) */
enum platform_types platform_type; /* type of machine we're on */
int32 max_pages; /* total # physical pages */
int32 used_pages; /* # physical pages in use */
int32 page_faults; /* # of page faults */
int32 max_sems;
int32 used_sems;
int32 max_ports;
int32 used_ports;
int32 max_threads;
int32 used_threads;
int32 max_teams;
int32 used_teams;
char kernel_name[B_FILE_NAME_LENGTH]; /* name of kernel */
char kernel_build_date[B_OS_NAME_LENGTH]; /* date kernel built */
char kernel_build_time[B_OS_NAME_LENGTH]; /* time kernel built */
int64 kernel_version; /* version of this kernel */
bigtime_t _busy_wait_time; /* reserved for whatever */
int32 pad[4]; /* just in case... */
} system_info;
/* system private, use macro instead */
extern status_t _get_system_info(system_info *returned_info, size_t size);
#define get_system_info(info) \
_get_system_info((info), sizeof(*(info)))
extern int32 is_computer_on(void);
extern double is_computer_on_fire(void);
#ifdef __cplusplus
}
#endif
#endif /* _OS_H */
#include <../os/kernel/OS.h>
-10
View File
@@ -13,11 +13,7 @@
#include <Node.h>
#include <EntryList.h>
#include <StorageDefs.h>
#include <StorageDefs.Private.h>
#ifdef USE_OPENBEOS_NAMESPACE
namespace OpenBeOS {
#endif
class BFile;
class BSymLink;
@@ -107,10 +103,4 @@ private:
status_t create_directory(const char *path, mode_t mode);
#ifdef USE_OPENBEOS_NAMESPACE
}; // namespace OpenBeOS
#endif
#endif // _DIRECTORY_H
+1 -156
View File
@@ -1,156 +1 @@
/*
* Copyright 2003-2006, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _DISK_DEVICE_DEFS_H
#define _DISK_DEVICE_DEFS_H
#include <SupportDefs.h>
typedef int32 partition_id;
typedef int32 disk_system_id;
typedef int32 disk_job_id;
// partition flags
enum {
B_PARTITION_IS_DEVICE = 0x01,
B_PARTITION_FILE_SYSTEM = 0x02,
B_PARTITION_PARTITIONING_SYSTEM = 0x04,
B_PARTITION_READ_ONLY = 0x08,
B_PARTITION_MOUNTED = 0x10, // needed?
B_PARTITION_BUSY = 0x20,
B_PARTITION_DESCENDANT_BUSY = 0x40,
};
// partition statuses
enum {
B_PARTITION_VALID,
B_PARTITION_CORRUPT,
B_PARTITION_UNRECOGNIZED,
B_PARTITION_UNINITIALIZED, // Only when uninitialized manually.
// When not recognized while scanning it's
// B_PARTITION_UNRECOGNIZED.
};
// partition change flags
enum {
B_PARTITION_CHANGED_OFFSET = 0x000001,
B_PARTITION_CHANGED_SIZE = 0x000002,
B_PARTITION_CHANGED_CONTENT_SIZE = 0x000004,
B_PARTITION_CHANGED_BLOCK_SIZE = 0x000008,
B_PARTITION_CHANGED_STATUS = 0x000010,
B_PARTITION_CHANGED_FLAGS = 0x000020,
B_PARTITION_CHANGED_VOLUME = 0x000040,
B_PARTITION_CHANGED_NAME = 0x000080,
B_PARTITION_CHANGED_CONTENT_NAME = 0x000100,
B_PARTITION_CHANGED_TYPE = 0x000200,
B_PARTITION_CHANGED_CONTENT_TYPE = 0x000400,
B_PARTITION_CHANGED_PARAMETERS = 0x000800,
B_PARTITION_CHANGED_CONTENT_PARAMETERS = 0x001000,
B_PARTITION_CHANGED_CHILDREN = 0x002000,
B_PARTITION_CHANGED_DESCENDANTS = 0x004000,
B_PARTITION_CHANGED_DEFRAGMENTATION = 0x008000,
B_PARTITION_CHANGED_CHECK = 0x010000,
B_PARTITION_CHANGED_REPAIR = 0x020000,
B_PARTITION_CHANGED_INITIALIZATION = 0x040000,
};
// disk device flags
enum {
B_DISK_DEVICE_REMOVABLE = 0x01,
B_DISK_DEVICE_HAS_MEDIA = 0x02,
B_DISK_DEVICE_READ_ONLY = 0x04,
B_DISK_DEVICE_WRITE_ONCE = 0x08,
};
// disk system flags
enum {
B_DISK_SYSTEM_IS_FILE_SYSTEM = 0x0001,
// flags common for both file and partitioning systems
B_DISK_SYSTEM_SUPPORTS_CHECKING = 0x0002,
B_DISK_SYSTEM_SUPPORTS_REPAIRING = 0x0004,
B_DISK_SYSTEM_SUPPORTS_RESIZING = 0x0008,
B_DISK_SYSTEM_SUPPORTS_MOVING = 0x0010,
B_DISK_SYSTEM_SUPPORTS_SETTING_CONTENT_NAME = 0x0020,
B_DISK_SYSTEM_SUPPORTS_SETTING_CONTENT_PARAMETERS = 0x0040,
// file system specific flags
B_DISK_SYSTEM_SUPPORTS_DEFRAGMENTING = 0x0100,
B_DISK_SYSTEM_SUPPORTS_DEFRAGMENTING_WHILE_MOUNTED = 0x0200,
B_DISK_SYSTEM_SUPPORTS_CHECKING_WHILE_MOUNTED = 0x0400,
B_DISK_SYSTEM_SUPPORTS_REPAIRING_WHILE_MOUNTED = 0x0800,
B_DISK_SYSTEM_SUPPORTS_RESIZING_WHILE_MOUNTED = 0x1000,
B_DISK_SYSTEM_SUPPORTS_MOVING_WHILE_MOUNTED = 0x2000,
B_DISK_SYSTEM_SUPPORTS_SETTING_CONTENT_NAME_WHILE_MOUNTED = 0x4000,
B_DISK_SYSTEM_SUPPORTS_SETTING_CONTENT_PARAMETERS_WHILE_MOUNTED = 0x8000,
// partitioning system specific flags
B_DISK_SYSTEM_SUPPORTS_RESIZING_CHILD = 0x0100,
B_DISK_SYSTEM_SUPPORTS_MOVING_CHILD = 0x0200,
B_DISK_SYSTEM_SUPPORTS_SETTING_NAME = 0x0400,
B_DISK_SYSTEM_SUPPORTS_SETTING_TYPE = 0x0800,
B_DISK_SYSTEM_SUPPORTS_SETTING_PARAMETERS = 0x1000,
B_DISK_SYSTEM_SUPPORTS_CREATING_CHILD = 0x2000,
B_DISK_SYSTEM_SUPPORTS_DELETING_CHILD = 0x4000,
B_DISK_SYSTEM_SUPPORTS_INITIALIZING = 0x8000,
};
// disk device job types
enum {
B_DISK_DEVICE_JOB_BAD_TYPE,
B_DISK_DEVICE_JOB_DEFRAGMENT,
B_DISK_DEVICE_JOB_REPAIR,
B_DISK_DEVICE_JOB_RESIZE,
B_DISK_DEVICE_JOB_MOVE,
B_DISK_DEVICE_JOB_SET_NAME,
B_DISK_DEVICE_JOB_SET_CONTENT_NAME,
B_DISK_DEVICE_JOB_SET_TYPE,
B_DISK_DEVICE_JOB_SET_PARMETERS,
B_DISK_DEVICE_JOB_SET_CONTENT_PARMETERS,
B_DISK_DEVICE_JOB_INITIALIZE,
B_DISK_DEVICE_JOB_UNINITIALIZE,
B_DISK_DEVICE_JOB_CREATE,
B_DISK_DEVICE_JOB_DELETE,
B_DISK_DEVICE_JOB_SCAN,
};
// disk device job statuses
enum {
B_DISK_DEVICE_JOB_UNINITIALIZED,
B_DISK_DEVICE_JOB_SCHEDULED,
B_DISK_DEVICE_JOB_IN_PROGRESS,
B_DISK_DEVICE_JOB_SUCCEEDED,
B_DISK_DEVICE_JOB_FAILED,
B_DISK_DEVICE_JOB_CANCELED,
};
// disk device job progress info
typedef struct disk_device_job_progress_info {
uint32 status;
uint32 interrupt_properties;
int32 task_count;
int32 completed_tasks;
float current_task_progress;
char current_task_description[256];
} disk_device_job_progress_info;
// disk device job interrupt properties
enum {
B_DISK_DEVICE_JOB_CAN_CANCEL = 0x01,
B_DISK_DEVICE_JOB_STOP_ON_CANCEL = 0x02,
B_DISK_DEVICE_JOB_REVERSE_ON_CANCEL = 0x04,
B_DISK_DEVICE_JOB_CAN_PAUSE = 0x08,
};
// string length constants, all of which include the NULL terminator
#define B_DISK_DEVICE_TYPE_LENGTH B_FILE_NAME_LENGTH
#define B_DISK_DEVICE_NAME_LENGTH B_FILE_NAME_LENGTH
#define B_DISK_SYSTEM_NAME_LENGTH B_PATH_NAME_LENGTH
// max size of parameter string buffers, including NULL terminator
#define B_DISK_DEVICE_MAX_PARAMETER_SIZE (32 * 1024)
#endif // _DISK_DEVICE_DEFS_H
#include <../os/storage/DiskDeviceDefs.h>
+1 -62
View File
@@ -1,62 +1 @@
//----------------------------------------------------------------------
// This software is part of the OpenBeOS distribution and is covered
// by the OpenBeOS license.
//---------------------------------------------------------------------
/*!
\file EntryList.h
BEntryList interface declaration.
*/
#ifndef _ENTRY_LIST_H
#define _ENTRY_LIST_H
#include <dirent.h>
#include <SupportDefs.h>
#ifdef USE_OPENBEOS_NAMESPACE
namespace OpenBeOS {
#endif
// Forward declarations
class BEntry;
struct entry_ref;
//! Interface for iterating through a list of filesystem entries
/*! Defines a general interface for iterating through a list of entries (i.e.
files in a folder
@author <a href='mailto:[email protected]'>Tyler Dauwalder</a>
@author Be Inc.
@version 0.0.0
*/
class BEntryList {
public:
BEntryList();
virtual ~BEntryList();
virtual status_t GetNextEntry(BEntry *entry, bool traverse = false) = 0;
virtual status_t GetNextRef(entry_ref *ref) = 0;
virtual int32 GetNextDirents(struct dirent *buf, size_t length,
int32 count = INT_MAX) = 0;
virtual status_t Rewind() = 0;
virtual int32 CountEntries() = 0;
private:
virtual void _ReservedEntryList1();
virtual void _ReservedEntryList2();
virtual void _ReservedEntryList3();
virtual void _ReservedEntryList4();
virtual void _ReservedEntryList5();
virtual void _ReservedEntryList6();
virtual void _ReservedEntryList7();
virtual void _ReservedEntryList8();
};
#ifdef USE_OPENBEOS_NAMESPACE
}; // namespace OpenBeOS
#endif
#endif // _ENTRY_LIST_H
#include <../os/storage/EntryList.h>
+5 -12
View File
@@ -1,5 +1,5 @@
//----------------------------------------------------------------------
// This software is part of the OpenBeOS distribution and is covered
// This software is part of the OpenBeOS distribution and is covered
// by the OpenBeOS license.
//---------------------------------------------------------------------
/*!
@@ -9,25 +9,22 @@
#ifndef _FILE_H
#define _FILE_H
#include <DataIO.h>
#include <Node.h>
#include <StorageDefs.Private.h>
#ifdef USE_OPENBEOS_NAMESPACE
namespace OpenBeOS {
#endif
/*!
\class BFile
\brief BFile is a wrapper class for common operations on files providing
access to the file's content data and its attributes.
A BFile represents a file in some file system. It implements the
BPositionIO interface and thus the methods to read from and write to the
file, and is derived of BNode to provide access to the file's attributes.
\author <a href='mailto:[email protected]'>Ingo Weinhold</a>
\version 0.0.0
*/
class BFile : public BNode, public BPositionIO {
@@ -57,6 +54,7 @@ public:
virtual off_t Position() const;
virtual status_t SetSize(off_t size);
virtual status_t GetSize(off_t* size) const;
BFile &operator=(const BFile &file);
@@ -79,10 +77,5 @@ private:
uint32 fMode;
};
#ifdef USE_OPENBEOS_NAMESPACE
}; // namespace OpenBeOS
#endif
#endif // _FILE_H
+1 -137
View File
@@ -1,137 +1 @@
//----------------------------------------------------------------------
// This software is part of the OpenBeOS distribution and is covered
// by the OpenBeOS license.
//---------------------------------------------------------------------
/*!
\file FindDirectory.h
Declarations of find_directory() functions and associated types.
*/
#ifndef _FIND_DIRECTORY_H
#define _FIND_DIRECTORY_H
#include <SupportDefs.h>
#ifdef USE_OPENBEOS_NAMESPACE
namespace OpenBeOS {
#endif
#ifdef __cplusplus
extern "C" {
#endif
typedef enum {
/* ---
Per volume directories. When asking for these
directories, a volume must be specified, or the call will assume
the boot volume.
--- */
B_DESKTOP_DIRECTORY = 0,
B_TRASH_DIRECTORY,
/* ---
BeOS directories. These are mostly accessed read-only.
--- */
B_BEOS_DIRECTORY = 1000,
B_BEOS_SYSTEM_DIRECTORY,
B_BEOS_ADDONS_DIRECTORY,
B_BEOS_BOOT_DIRECTORY,
B_BEOS_FONTS_DIRECTORY,
B_BEOS_LIB_DIRECTORY,
B_BEOS_SERVERS_DIRECTORY,
B_BEOS_APPS_DIRECTORY,
B_BEOS_BIN_DIRECTORY,
B_BEOS_ETC_DIRECTORY,
B_BEOS_DOCUMENTATION_DIRECTORY,
B_BEOS_PREFERENCES_DIRECTORY,
B_BEOS_TRANSLATORS_DIRECTORY,
B_BEOS_MEDIA_NODES_DIRECTORY,
B_BEOS_SOUNDS_DIRECTORY,
/* ---
Common directories, shared among all users.
--- */
B_COMMON_DIRECTORY = 2000,
B_COMMON_SYSTEM_DIRECTORY,
B_COMMON_ADDONS_DIRECTORY,
B_COMMON_BOOT_DIRECTORY,
B_COMMON_FONTS_DIRECTORY,
B_COMMON_LIB_DIRECTORY,
B_COMMON_SERVERS_DIRECTORY,
B_COMMON_BIN_DIRECTORY,
B_COMMON_ETC_DIRECTORY,
B_COMMON_DOCUMENTATION_DIRECTORY,
B_COMMON_SETTINGS_DIRECTORY,
B_COMMON_DEVELOP_DIRECTORY,
B_COMMON_LOG_DIRECTORY,
B_COMMON_SPOOL_DIRECTORY,
B_COMMON_TEMP_DIRECTORY,
B_COMMON_VAR_DIRECTORY,
B_COMMON_TRANSLATORS_DIRECTORY,
B_COMMON_MEDIA_NODES_DIRECTORY,
B_COMMON_SOUNDS_DIRECTORY,
/* ---
User directories. These are interpreted in the context
of the user making the find_directory call.
--- */
B_USER_DIRECTORY = 3000,
B_USER_CONFIG_DIRECTORY,
B_USER_ADDONS_DIRECTORY,
B_USER_BOOT_DIRECTORY,
B_USER_FONTS_DIRECTORY,
B_USER_LIB_DIRECTORY,
B_USER_SETTINGS_DIRECTORY,
B_USER_DESKBAR_DIRECTORY,
B_USER_PRINTERS_DIRECTORY,
B_USER_TRANSLATORS_DIRECTORY,
B_USER_MEDIA_NODES_DIRECTORY,
B_USER_SOUNDS_DIRECTORY,
/* ---
Global directories.
--- */
B_APPS_DIRECTORY = 4000,
B_PREFERENCES_DIRECTORY,
B_UTILITIES_DIRECTORY
} directory_which;
/* ---
The C interface
--- */
status_t find_directory(directory_which which, dev_t volume, bool createIt,
char *pathString, int32 length);
#ifdef __cplusplus
}
#endif
#ifdef __cplusplus
class BVolume;
class BPath;
/* ---
C++ interface
--- */
status_t find_directory(directory_which which, BPath *path,
bool createIt = false, BVolume *volume = NULL);
#endif
#ifdef USE_OPENBEOS_NAMESPACE
}; // namespace OpenBeOS
#endif
#endif // _FIND_DIRECTORY_H
#include <../os/storage/FindDirectory.h>
+1 -93
View File
@@ -1,93 +1 @@
#ifndef _NODE_MONITOR_H
#define _NODE_MONITOR_H
/* Node monitor calls for kernel add-ons
**
** Distributed under the terms of the OpenBeOS License.
*/
#include <StorageDefs.h>
/* Flags for the watch_node() call.
*
* Note that B_WATCH_MOUNT is NOT included in B_WATCH_ALL.
* You may prefer to use BVolumeRoster for volume watching.
*/
enum {
B_STOP_WATCHING = 0x0000,
B_WATCH_NAME = 0x0001,
B_WATCH_STAT = 0x0002,
B_WATCH_ATTR = 0x0004,
B_WATCH_DIRECTORY = 0x0008,
B_WATCH_ALL = 0x000f,
B_WATCH_MOUNT = 0x0010
};
/* The "opcode" field of the B_NODE_MONITOR notification message you get.
*
* The presence and meaning of the other fields in that message specifying what
* exactly caused the notification depend on this value.
*/
#define B_ENTRY_CREATED 1
#define B_ENTRY_REMOVED 2
#define B_ENTRY_MOVED 3
#define B_STAT_CHANGED 4
#define B_ATTR_CHANGED 5
#define B_DEVICE_MOUNTED 6
#define B_DEVICE_UNMOUNTED 7
// More specific info in the "cause" field of B_ATTR_CHANGED notification
// messages. (Haiku only)
#define B_ATTR_CREATED 1
#define B_ATTR_REMOVED 2
// B_ATTR_CHANGED is reused
// More specific info in the "fields" field of B_STAT_CHANGED notification
// messages, specifying what parts of the stat data have actually been
// changed. (Haiku only)
enum {
B_STAT_MODE = 0x01,
B_STAT_UID = 0x02,
B_STAT_GID = 0x04,
B_STAT_SIZE = 0x08,
B_STAT_ACCESS_TIME = 0x10,
B_STAT_MODIFICATION_TIME = 0x20,
B_STAT_CREATION_TIME = 0x40,
B_STAT_CHANGE_TIME = 0x80,
};
/* C++ callable Prototypes
*
* Since you are not able to parse BMessages from plain C, there is no
* API exported.
*/
#if defined(__cplusplus) && !defined(_KERNEL_MODE)
// these are only needed for the function exports
#include <Node.h>
#include <Messenger.h>
class BLooper;
class BHandler;
extern status_t watch_node(const node_ref *node, uint32 flags, BMessenger target);
extern status_t watch_node(const node_ref *node, uint32 flags,
const BHandler *handler,
const BLooper *looper = NULL);
extern status_t stop_watching(BMessenger target);
extern status_t stop_watching(const BHandler *handler, const BLooper *looper = NULL);
#endif /* __cplusplus && !_KERNEL_MODE */
#endif /* _NODE_MONITOR_H*/
#include <../os/storage/NodeMonitor.h>
+1 -103
View File
@@ -1,103 +1 @@
//----------------------------------------------------------------------
// This software is part of the OpenBeOS distribution and is covered
// by the OpenBeOS license.
//---------------------------------------------------------------------
/*!
\file Path.h
BPath interface declaration.
*/
#ifndef _PATH_H
#define _PATH_H
#include <Flattenable.h>
#include <StorageDefs.h>
#include <Message.h> /* for convenience, as in R5 */
#ifdef USE_OPENBEOS_NAMESPACE
namespace OpenBeOS {
#endif
// Forward declarations
class BDirectory;
class BEntry;
struct entry_ref;
/*!
\class BPath
\brief An absolute pathname wrapper class
Provides a convenient means of managing pathnames.
\author <a href='mailto:[email protected]'>Ingo Weinhold</a>
\author <a href="mailto:[email protected]">Tyler Dauwalder</a>
\version 0.0.0
*/
class BPath : public BFlattenable {
public:
BPath();
BPath(const BPath &path);
BPath(const entry_ref *ref);
BPath(const BEntry *entry);
BPath(const char *dir, const char *leaf = NULL, bool normalize = false);
BPath(const BDirectory *dir, const char *leaf, bool normalize = false);
virtual ~BPath();
status_t InitCheck() const;
status_t SetTo(const entry_ref *ref);
status_t SetTo(const BEntry *entry);
status_t SetTo(const char *path, const char *leaf = NULL,
bool normalize = false);
status_t SetTo(const BDirectory *dir, const char *path,
bool normalize = false);
void Unset();
status_t Append(const char *path, bool normalize = false);
const char *Path() const;
const char *Leaf() const;
status_t GetParent(BPath *path) const;
bool operator==(const BPath &item) const;
bool operator==(const char *path) const;
bool operator!=(const BPath &item) const;
bool operator!=(const char *path) const;
BPath& operator=(const BPath &item);
BPath& operator=(const char *path);
// BFlattenable protocol
virtual bool IsFixedSize() const;
virtual type_code TypeCode() const;
virtual ssize_t FlattenedSize() const;
virtual status_t Flatten(void *buffer, ssize_t size) const;
virtual bool AllowsTypeCode(type_code code) const;
virtual status_t Unflatten(type_code c, const void *buf, ssize_t size);
private:
virtual void _WarPath1();
virtual void _WarPath2();
virtual void _WarPath3();
uint32 _warData[4];
char *fName;
status_t fCStatus;
class EBadInput { };
status_t set_path(const char *path);
static bool MustNormalize(const char *path);
};
#ifdef USE_OPENBEOS_NAMESPACE
}; // namespace OpenBeOS
#endif
#endif // _PATH_H
#include <../os/storage/Path.h>
+1 -92
View File
@@ -1,92 +1 @@
//----------------------------------------------------------------------
// This software is part of the OpenBeOS distribution and is covered
// by the OpenBeOS license.
//---------------------------------------------------------------------
/*!
\file ResourceStrings.h
BResourceStrings interface declaration.
*/
#ifndef _RESOURCE_STRINGS_H
#define _RESOURCE_STRINGS_H
#include <Entry.h>
#include <Locker.h>
class BResources;
class BString;
/*!
\class BResourceStrings
\brief Simple class to access the string resources in a file.
A BResourceStrings object reads the string type resources from a given
resource file and provides fast read only access to them.
\author <a href='mailto:[email protected]'>Ingo Weinhold</a>
\version 0.0.0
*/
class BResourceStrings {
public:
BResourceStrings();
BResourceStrings(const entry_ref &ref);
virtual ~BResourceStrings();
status_t InitCheck();
virtual BString *NewString(int32 id);
virtual const char *FindString(int32 id);
virtual status_t SetStringFile(const entry_ref *ref);
status_t GetStringFile(entry_ref *outRef);
public:
enum {
RESOURCE_TYPE = 'CSTR'
};
protected:
struct _string_id_hash {
_string_id_hash();
~_string_id_hash();
void assign_string(const char *str, bool makeCopy);
_string_id_hash *next;
int32 id;
char *data;
bool data_alloced;
bool _reserved1[3];
uint32 _reserved2;
};
protected:
BLocker _string_lock;
status_t _init_error;
private:
entry_ref fFileRef;
BResources *fResources;
_string_id_hash **fHashTable;
int32 fHashTableSize;
int32 fStringCount;
uint32 _reserved[16]; // FBC
private:
void _Cleanup();
void _MakeEmpty();
status_t _Rehash(int32 newSize);
_string_id_hash *_AddString(char *str, int32 id, bool wasMalloced);
virtual _string_id_hash *_FindString(int32 id);
// FBC
virtual status_t _Reserved_ResourceStrings_0(void *);
virtual status_t _Reserved_ResourceStrings_1(void *);
virtual status_t _Reserved_ResourceStrings_2(void *);
virtual status_t _Reserved_ResourceStrings_3(void *);
virtual status_t _Reserved_ResourceStrings_4(void *);
virtual status_t _Reserved_ResourceStrings_5(void *);
};
#endif // _RESOURCE_STRINGS_H
#include <../os/storage/ResourceStrings.h>
+1 -118
View File
@@ -1,118 +1 @@
//----------------------------------------------------------------------
// This software is part of the OpenBeOS distribution and is covered
// by the OpenBeOS license.
//---------------------------------------------------------------------
/*!
\file Resources.h
BResources interface declaration.
*/
#ifndef _RESOURCES_H
#define _RESOURCES_H
#include <File.h>
#ifdef USE_OPENBEOS_NAMESPACE
namespace OpenBeOS {
#endif
namespace BPrivate {
namespace Storage {
class ResourcesContainer;
class ResourceFile;
};
};
/*!
\class BResources
\brief Represent the resources in a file
Provides an interface for accessing and manipulating resources.
\author <a href='mailto:[email protected]'>Ingo Weinhold</a>
\version 0.0.0
*/
class BResources {
public:
BResources();
BResources(const BFile *file, bool clobber = false);
virtual ~BResources();
status_t SetTo(const BFile *file, bool clobber = false);
void Unset();
status_t InitCheck() const;
const BFile &File() const;
const void *LoadResource(type_code type, int32 id, size_t *outSize);
const void *LoadResource(type_code type, const char *name,
size_t *outSize);
status_t PreloadResourceType(type_code type = 0);
status_t Sync();
status_t MergeFrom(BFile *fromFile);
status_t WriteTo(BFile *file);
status_t AddResource(type_code type, int32 id, const void *data,
size_t length, const char *name = NULL);
bool HasResource(type_code type, int32 id);
bool HasResource(type_code type, const char *name);
bool GetResourceInfo(int32 byIndex, type_code *typeFound, int32 *idFound,
const char **nameFound, size_t *lengthFound);
bool GetResourceInfo(type_code byType, int32 andIndex, int32 *idFound,
const char **nameFound, size_t *lengthFound);
bool GetResourceInfo(type_code byType, int32 andID,
const char **nameFound, size_t *lengthFound);
bool GetResourceInfo(type_code byType, const char *andName, int32 *idFound,
size_t *lengthFound);
bool GetResourceInfo(const void *byPointer, type_code *typeFound,
int32 *idFound, size_t *lengthFound,
const char **nameFound);
status_t RemoveResource(const void *resource);
status_t RemoveResource(type_code type, int32 id);
// deprecated
status_t WriteResource(type_code type, int32 id, const void *data,
off_t offset, size_t length);
status_t ReadResource(type_code type, int32 id, void *data, off_t offset,
size_t length);
void *FindResource(type_code type, int32 id, size_t *lengthFound);
void *FindResource(type_code type, const char *name, size_t *lengthFound);
private:
// FBC
virtual void _ReservedResources1();
virtual void _ReservedResources2();
virtual void _ReservedResources3();
virtual void _ReservedResources4();
virtual void _ReservedResources5();
virtual void _ReservedResources6();
virtual void _ReservedResources7();
virtual void _ReservedResources8();
private:
BFile fFile;
BPrivate::Storage::ResourcesContainer *fContainer;
BPrivate::Storage::ResourceFile *fResourceFile;
bool fReadOnly;
bool _pad[3];
uint32 _reserved[3]; // FBC
};
#ifdef USE_OPENBEOS_NAMESPACE
}; // namespace OpenBeOS
#endif
#endif // _RESOURCES_H
#include <../os/storage/Resources.h>
@@ -1,21 +0,0 @@
//----------------------------------------------------------------------
// This software is part of the OpenBeOS distribution and is covered
// by the OpenBeOS license.
//---------------------------------------------------------------------
/*!
\file StorageDefs.Private.h
Private Storage Kit declarations needed in public headers.
*/
#ifndef _DEF_STORAGE_PRIVATE_H
#define _DEF_STORAGE_PRIVATE_H
namespace BPrivate {
namespace Storage {
typedef int FileDescriptor;
};
};
#endif // _DEF_STORAGE_PRIVATE_H
+4 -57
View File
@@ -1,58 +1,5 @@
//----------------------------------------------------------------------
// This software is part of the OpenBeOS distribution and is covered
// by the OpenBeOS license.
//---------------------------------------------------------------------
/*!
\file StorageDefs.h
Miscellaneous Storage Kit definitions and includes.
*/
#ifndef _DEF_STORAGE_H
#define _DEF_STORAGE_H
#include <fcntl.h>
#include <sys/param.h>
#include <limits.h>
#ifdef USE_OPENBEOS_NAMESPACE
namespace OpenBeOS {
#endif // USE_OPENBEOS_NAMESPACE
// Limits
#define B_DEV_NAME_LENGTH 128
#define B_FILE_NAME_LENGTH NAME_MAX
#define B_PATH_NAME_LENGTH MAXPATHLEN
#define B_ATTR_NAME_LENGTH (B_FILE_NAME_LENGTH-1)
#define B_MIME_TYPE_LENGTH (B_ATTR_NAME_LENGTH - 15)
#define B_MAX_SYMLINKS SYMLINK_MAX
// Open Modes
#define B_READ_ONLY O_RDONLY // read only
#define B_WRITE_ONLY O_WRONLY // write only
#define B_READ_WRITE O_RDWR // read and write
#define B_FAIL_IF_EXISTS O_EXCL // exclusive create
#define B_CREATE_FILE O_CREAT // create the file
#define B_ERASE_FILE O_TRUNC // erase the file's data
#define B_OPEN_AT_END O_APPEND // point to the end of the data
// Node Flavors
enum node_flavor {
B_FILE_NODE = 0x01,
B_SYMLINK_NODE = 0x02,
B_DIRECTORY_NODE = 0x04,
B_ANY_NODE = 0x07
};
#ifdef USE_OPENBEOS_NAMESPACE
}; // namespace OpenBeOS
#endif // USE_OPENBEOS_NAMESPACE
#endif // _DEF_STORAGE_H
#include <../os/storage/StorageDefs.h>
#ifndef SYMLOOP_MAX
# define SYMLOOP_MAX 16
#endif
+1 -70
View File
@@ -1,70 +1 @@
//----------------------------------------------------------------------
// This software is part of the OpenBeOS distribution and is covered
// by the OpenBeOS license.
//
// File Name: SymLink.h
//---------------------------------------------------------------------
/*!
\file SymLink.h
BSymLink interface declaration.
*/
#ifndef _SYM_LINK_H
#define _SYM_LINK_H
#include <Node.h>
#include <StorageDefs.h>
#ifdef USE_OPENBEOS_NAMESPACE
namespace OpenBeOS {
#endif
class BPath;
/*!
\class BSymLink
\brief A symbolic link in the filesystem
Provides an interface for manipulating symbolic links.
\author <a href='mailto:[email protected]'>Ingo Weinhold</a>
\version 0.0.0
*/
class BSymLink : public BNode {
public:
BSymLink();
BSymLink(const BSymLink &link);
BSymLink(const entry_ref *ref);
BSymLink(const BEntry *entry);
BSymLink(const char *path);
BSymLink(const BDirectory *dir, const char *path);
virtual ~BSymLink();
ssize_t ReadLink(char *buf, size_t size);
ssize_t MakeLinkedPath(const char *dirPath, BPath *path);
ssize_t MakeLinkedPath(const BDirectory *dir, BPath *path);
bool IsAbsolute();
private:
virtual void _MissingSymLink1();
virtual void _MissingSymLink2();
virtual void _MissingSymLink3();
virtual void _MissingSymLink4();
virtual void _MissingSymLink5();
virtual void _MissingSymLink6();
uint32 _reservedData[4];
BEntry *fSecretEntry;
private:
int get_fd() const;
};
#ifdef USE_OPENBEOS_NAMESPACE
}; // namespace OpenBeOS
#endif
#endif // _SYM_LINK_H
#include <../os/storage/SymLink.h>
+1 -73
View File
@@ -1,73 +1 @@
/*
* Copyright (c) 2003 Marcus Overhagen
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
#ifndef _BLOCK_CACHE_H
#define _BLOCK_CACHE_H
#include <BeBuild.h>
#include <Locker.h>
/* The OpenBeOS implementation of the BBlockCache.
* A class used to manage a pool of memory blocks.
*/
/* The allocation type to be used in the constructor
*/
enum {
B_OBJECT_CACHE = 0,
B_MALLOC_CACHE = 1
};
/* The BBlockCache class:
*/
class BBlockCache
{
public:
BBlockCache(uint32 blockCount,
size_t blockSize,
uint32 allocationType);
virtual ~BBlockCache();
void * Get(size_t blockSize);
void Save(void *pointer, size_t blockSize);
/* Private or reserved functions and data
*/
private:
virtual void _ReservedBlockCache1();
virtual void _ReservedBlockCache2();
BBlockCache(const BBlockCache &);
BBlockCache &operator=(const BBlockCache &);
struct _FreeBlock;
_FreeBlock *fFreeList;
size_t fBlockSize;
int32 fFreeBlocks;
int32 fBlockCount;
BLocker fLocker;
void * (*fAlloc)(size_t size);
void (*fFree)(void *pointer);
uint32 _reserved[2];
};
#endif
#include <../os/support/BlockCache.h>
+1 -132
View File
@@ -1,132 +1 @@
/*
* Copyright 2007, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _BYTEORDER_H
#define _BYTEORDER_H
#include <BeBuild.h>
#include <endian.h>
#include <SupportDefs.h>
#include <TypeConstants.h>
/* for convenience */
/* swap directions */
typedef enum {
B_SWAP_HOST_TO_LENDIAN,
B_SWAP_HOST_TO_BENDIAN,
B_SWAP_LENDIAN_TO_HOST,
B_SWAP_BENDIAN_TO_HOST,
B_SWAP_ALWAYS
} swap_action;
/* BSD/networking macros */
#ifndef htonl
# define htonl(x) B_HOST_TO_BENDIAN_INT32(x)
# define ntohl(x) B_BENDIAN_TO_HOST_INT32(x)
# define htons(x) B_HOST_TO_BENDIAN_INT16(x)
# define ntohs(x) B_BENDIAN_TO_HOST_INT16(x)
#endif
/* always swap macros */
#define B_SWAP_DOUBLE(arg) __swap_double(arg)
#define B_SWAP_FLOAT(arg) __swap_float(arg)
#define B_SWAP_INT64(arg) __swap_int64(arg)
#define B_SWAP_INT32(arg) __swap_int32(arg)
#define B_SWAP_INT16(arg) __swap_int16(arg)
#if BYTE_ORDER == __LITTLE_ENDIAN
/* Host is little endian */
#define B_HOST_IS_LENDIAN 1
#define B_HOST_IS_BENDIAN 0
/* Host native to little endian */
#define B_HOST_TO_LENDIAN_DOUBLE(arg) (double)(arg)
#define B_HOST_TO_LENDIAN_FLOAT(arg) (float)(arg)
#define B_HOST_TO_LENDIAN_INT64(arg) (uint64)(arg)
#define B_HOST_TO_LENDIAN_INT32(arg) (uint32)(arg)
#define B_HOST_TO_LENDIAN_INT16(arg) (uint16)(arg)
/* Little endian to host native */
#define B_LENDIAN_TO_HOST_DOUBLE(arg) (double)(arg)
#define B_LENDIAN_TO_HOST_FLOAT(arg) (float)(arg)
#define B_LENDIAN_TO_HOST_INT64(arg) (uint64)(arg)
#define B_LENDIAN_TO_HOST_INT32(arg) (uint32)(arg)
#define B_LENDIAN_TO_HOST_INT16(arg) (uint16)(arg)
/* Host native to big endian */
#define B_HOST_TO_BENDIAN_DOUBLE(arg) __swap_double(arg)
#define B_HOST_TO_BENDIAN_FLOAT(arg) __swap_float(arg)
#define B_HOST_TO_BENDIAN_INT64(arg) __swap_int64(arg)
#define B_HOST_TO_BENDIAN_INT32(arg) __swap_int32(arg)
#define B_HOST_TO_BENDIAN_INT16(arg) __swap_int16(arg)
/* Big endian to host native */
#define B_BENDIAN_TO_HOST_DOUBLE(arg) __swap_double(arg)
#define B_BENDIAN_TO_HOST_FLOAT(arg) __swap_float(arg)
#define B_BENDIAN_TO_HOST_INT64(arg) __swap_int64(arg)
#define B_BENDIAN_TO_HOST_INT32(arg) __swap_int32(arg)
#define B_BENDIAN_TO_HOST_INT16(arg) __swap_int16(arg)
#else /* BYTE_ORDER */
/* Host is big endian */
#define B_HOST_IS_LENDIAN 0
#define B_HOST_IS_BENDIAN 1
/* Host native to little endian */
#define B_HOST_TO_LENDIAN_DOUBLE(arg) __swap_double(arg)
#define B_HOST_TO_LENDIAN_FLOAT(arg) __swap_float(arg)
#define B_HOST_TO_LENDIAN_INT64(arg) __swap_int64(arg)
#define B_HOST_TO_LENDIAN_INT32(arg) __swap_int32(arg)
#define B_HOST_TO_LENDIAN_INT16(arg) __swap_int16(arg)
/* Little endian to host native */
#define B_LENDIAN_TO_HOST_DOUBLE(arg) __swap_double(arg)
#define B_LENDIAN_TO_HOST_FLOAT(arg) __swap_float(arg)
#define B_LENDIAN_TO_HOST_INT64(arg) __swap_int64(arg)
#define B_LENDIAN_TO_HOST_INT32(arg) __swap_int32(arg)
#define B_LENDIAN_TO_HOST_INT16(arg) __swap_int16(arg)
/* Host native to big endian */
#define B_HOST_TO_BENDIAN_DOUBLE(arg) (double)(arg)
#define B_HOST_TO_BENDIAN_FLOAT(arg) (float)(arg)
#define B_HOST_TO_BENDIAN_INT64(arg) (uint64)(arg)
#define B_HOST_TO_BENDIAN_INT32(arg) (uint32)(arg)
#define B_HOST_TO_BENDIAN_INT16(arg) (uint16)(arg)
/* Big endian to host native */
#define B_BENDIAN_TO_HOST_DOUBLE(arg) (double)(arg)
#define B_BENDIAN_TO_HOST_FLOAT(arg) (float)(arg)
#define B_BENDIAN_TO_HOST_INT64(arg) (uint64)(arg)
#define B_BENDIAN_TO_HOST_INT32(arg) (uint32)(arg)
#define B_BENDIAN_TO_HOST_INT16(arg) (uint16)(arg)
#endif /* BYTE_ORDER */
#ifdef __cplusplus
extern "C" {
#endif
extern status_t swap_data(type_code type, void *data, size_t length,
swap_action action);
extern bool is_type_swapped(type_code type);
/* Private implementations */
extern double __swap_double(double arg);
extern float __swap_float(float arg);
extern uint64 __swap_int64(uint64 arg);
extern uint32 __swap_int32(uint32 arg);
extern uint16 __swap_int16(uint16 arg);
#ifdef __cplusplus
}
#endif
#endif /* _BYTEORDER_H */
#include <../os/support/ByteOrder.h>
+1 -165
View File
@@ -1,165 +1 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// File Name: DataIO.cpp
// Author(s): Ingo Weinhold ([email protected])
// Stefano Ceccherini ([email protected])
// The Storage Team
// Description: Pure virtual BDataIO and BPositionIO classes provide
// the protocol for Read()/Write()/Seek().
//
// BMallocIO and BMemoryIO classes implement the protocol,
// as does BFile in the Storage Kit.
//------------------------------------------------------------------------------
#ifndef _DATA_IO_H
#define _DATA_IO_H
#include <SupportDefs.h>
// DataIO
class BDataIO {
public:
BDataIO();
virtual ~BDataIO();
virtual ssize_t Read(void *buffer, size_t size) = 0;
virtual ssize_t Write(const void *buffer, size_t size) = 0;
private:
BDataIO(const BDataIO &);
BDataIO &operator=(const BDataIO &);
virtual void _ReservedDataIO1();
virtual void _ReservedDataIO2();
virtual void _ReservedDataIO3();
virtual void _ReservedDataIO4();
virtual void _ReservedDataIO5();
virtual void _ReservedDataIO6();
virtual void _ReservedDataIO7();
virtual void _ReservedDataIO8();
virtual void _ReservedDataIO9();
virtual void _ReservedDataIO10();
virtual void _ReservedDataIO11();
virtual void _ReservedDataIO12();
uint32 _reserved[2];
};
// BPositionIO
class BPositionIO : public BDataIO {
public:
BPositionIO();
virtual ~BPositionIO();
virtual ssize_t Read(void *buffer, size_t size);
virtual ssize_t Write(const void *buffer, size_t size);
virtual ssize_t ReadAt(off_t position, void *buffer, size_t size) = 0;
virtual ssize_t WriteAt(off_t position, const void *buffer,
size_t size) = 0;
virtual off_t Seek(off_t position, uint32 seekMode) = 0;
virtual off_t Position() const = 0;
virtual status_t SetSize(off_t size);
private:
virtual void _ReservedPositionIO1();
virtual void _ReservedPositionIO2();
virtual void _ReservedPositionIO3();
virtual void _ReservedPositionIO4();
virtual void _ReservedPositionIO5();
virtual void _ReservedPositionIO6();
virtual void _ReservedPositionIO7();
virtual void _ReservedPositionIO8();
virtual void _ReservedPositionIO9();
virtual void _ReservedPositionIO10();
virtual void _ReservedPositionIO11();
virtual void _ReservedPositionIO12();
uint32 _reserved[2];
};
// BMemoryIO
class BMemoryIO : public BPositionIO {
public:
BMemoryIO(void *data, size_t len);
BMemoryIO(const void *data, size_t len);
virtual ~BMemoryIO();
virtual ssize_t ReadAt(off_t position, void *buffer, size_t size);
virtual ssize_t WriteAt(off_t position, const void *buffer, size_t size);
virtual off_t Seek(off_t position, uint32 seekMode);
virtual off_t Position() const;
virtual status_t SetSize(off_t size);
private:
BMemoryIO(const BMemoryIO &);
BMemoryIO &operator=(const BMemoryIO &);
virtual void _ReservedMemoryIO1();
virtual void _ReservedMemoryIO2();
bool fReadOnly;
char *fBuf;
size_t fLen;
size_t fPhys;
size_t fPos;
uint32 _reserved[1];
};
// BMallocIO
class BMallocIO : public BPositionIO {
public:
BMallocIO();
virtual ~BMallocIO();
virtual ssize_t ReadAt(off_t position, void *buffer, size_t size);
virtual ssize_t WriteAt(off_t position, const void *buffer, size_t size);
virtual off_t Seek(off_t position, uint32 seekMode);
virtual off_t Position() const;
virtual status_t SetSize(off_t size);
void SetBlockSize(size_t blockSize);
const void *Buffer() const;
size_t BufferLength() const;
private:
BMallocIO(const BMallocIO &);
BMallocIO &operator=(const BMallocIO &);
virtual void _ReservedMallocIO1();
virtual void _ReservedMallocIO2();
size_t fBlockSize;
size_t fMallocSize;
size_t fLength;
char *fData;
off_t fPosition;
uint32 _reserved[1];
};
#endif
#include <../os/support/DataIO.h>
+1 -114
View File
@@ -1,114 +1 @@
/******************************************************************************
/
/ File: Debug.h
/
/ Description: Compile time and runtime switchable debug macros.
/
/ Copyright 1993-98, Be Incorporated
/
******************************************************************************/
#ifndef _DEBUG_H
#define _DEBUG_H
#include <BeBuild.h>
#include <SupportDefs.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <OS.h>
/*------------------------------*/
/*----- Private... -------------*/
#ifdef __cplusplus
extern "C" {
#endif
extern _IMPEXP_ROOT bool _rtDebugFlag;
_IMPEXP_ROOT bool _debugFlag(void);
_IMPEXP_ROOT bool _setDebugFlag(bool);
_IMPEXP_ROOT int _debugPrintf(const char *, ...);
_IMPEXP_ROOT int _sPrintf(const char *, ...);
_IMPEXP_ROOT int _xdebugPrintf(const char *, ...);
_IMPEXP_ROOT int _debuggerAssert(const char *, int, char *);
#ifdef __cplusplus
}
#endif
/*-------- ...to here ----------*/
/*-------------------------------------------------------------*/
/*----- Debug macros ------------------------------------------*/
#if DEBUG
#define SET_DEBUG_ENABLED(FLAG) _setDebugFlag(FLAG)
#define IS_DEBUG_ENABLED() _debugFlag()
#define SERIAL_PRINT(ARGS) _sPrintf ARGS
#define PRINT(ARGS) _debugPrintf ARGS
#define PRINT_OBJECT(OBJ) if (_rtDebugFlag) { \
PRINT(("%s\t", #OBJ)); \
(OBJ).PrintToStream(); \
} ((void) 0)
#define TRACE() _debugPrintf("File: %s, Line: %d, Thread: %d\n", \
__FILE__, __LINE__, find_thread(NULL))
#define SERIAL_TRACE() _sPrintf("File: %s, Line: %d, Thread: %d\n", \
__FILE__, __LINE__, find_thread(NULL))
#define DEBUGGER(MSG) if (_rtDebugFlag) debugger(MSG)
#if !defined(ASSERT)
#define ASSERT(E) (!(E) ? _debuggerAssert(__FILE__,__LINE__, #E) \
: (int)0)
#endif
#define ASSERT_WITH_MESSAGE(expr, msg) \
(!(expr) ? _debuggerAssert( __FILE__,__LINE__, msg) \
: (int)0)
#define TRESPASS() DEBUGGER("Should not be here");
#define DEBUG_ONLY(arg) arg
#else /* DEBUG == 0 */
#define SET_DEBUG_ENABLED(FLAG) (void)0
#define IS_DEBUG_ENABLED() (void)0
#define SERIAL_PRINT(ARGS) (void)0
#define PRINT(ARGS) (void)0
#define PRINT_OBJECT(OBJ) (void)0
#define TRACE() (void)0
#define SERIAL_TRACE() (void)0
#define DEBUGGER(MSG) (void)0
#if !defined(ASSERT)
#define ASSERT(E) (void)0
#endif
#define ASSERT_WITH_MESSAGE(expr, msg) \
(void)0
#define TRESPASS() (void)0
#define DEBUG_ONLY(x)
#endif
#if !__MWERKS__
// STATIC_ASSERT is a compile-time check that can be used to
// verify static expressions such as: STATIC_ASSERT(sizeof(int64) == 8);
#define STATIC_ASSERT(x) \
do { \
struct __staticAssertStruct__ { \
char __static_assert_failed__[2*(x) - 1]; \
}; \
} while (false)
#else
#define STATIC_ASSERT(x)
// the STATIC_ASSERT above doesn't work too well with mwcc because
// of scoping bugs; for now make it do nothing
#endif
/*-------------------------------------------------------------*/
/*-------------------------------------------------------------*/
#endif /* _DEBUG_H */
#include <../os/support/Debug.h>
+1 -36
View File
@@ -1,36 +1 @@
// Modified BeOS header. Just here to be able to compile and test BPath.
// To be replaced by the OpenBeOS version to be provided by the IK Team.
#ifndef __sk_flattenable_h__
#define __sk_flattenable_h__
#include <SupportDefs.h>
/*-------------------------------------------------------------*/
/*----- BFlattenable class ------------------------------------*/
class BFlattenable {
public:
virtual bool IsFixedSize() const = 0;
virtual type_code TypeCode() const = 0;
virtual ssize_t FlattenedSize() const = 0;
virtual status_t Flatten(void *buffer, ssize_t size) const = 0;
virtual bool AllowsTypeCode(type_code code) const;
virtual status_t Unflatten(type_code c, const void *buf, ssize_t size) = 0;
virtual ~BFlattenable(); // was a reserved virtual in R4.0
/*----- Private or reserved ---------------*/
private:
void _ReservedFlattenable1();
virtual void _ReservedFlattenable2();
virtual void _ReservedFlattenable3();
};
/*-------------------------------------------------------------*/
/*-------------------------------------------------------------*/
#endif // __sk_flattenable_h__
#include <../os/support/Flattenable.h>
+1 -98
View File
@@ -1,98 +1 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// File Name: List.h
// Author(s): The Storage kit Team
// Description: BList class provides storage for pointers.
// Not thread safe..
//------------------------------------------------------------------------------
#ifndef _BE_LIST_H
#define _BE_LIST_H
#include <SupportDefs.h>
/*----- BList class --------------------------------------*/
class BList {
public:
BList(int32 count = 20);
BList(const BList& anotherList);
virtual ~BList();
BList& operator =(const BList &);
/* Adding and removing items. */
bool AddItem(void *item, int32 index);
bool AddItem(void *item);
bool AddList(const BList *list, int32 index);
bool AddList(const BList *list);
bool RemoveItem(void *item);
void *RemoveItem(int32 index);
bool RemoveItems(int32 index, int32 count);
bool ReplaceItem(int32 index, void *newItem);
void MakeEmpty();
/* Reordering items. */
void SortItems(int (*compareFunc)(const void *, const void *));
bool SwapItems(int32 indexA, int32 indexB);
bool MoveItem(int32 fromIndex, int32 toIndex);
/* Retrieving items. */
void *ItemAt(int32 index) const;
void *FirstItem() const;
/* Be careful when using this function, since it doesn't */
/* check if the index you pass is valid, and can lead to */
/* unexpected results when it isn't. */
void *ItemAtFast(int32) const;
void *LastItem() const;
void *Items() const;
/* Querying the list. */
bool HasItem(void *item) const;
int32 IndexOf(void *item) const;
int32 CountItems() const;
bool IsEmpty() const;
/* Iterating over the list. */
void DoForEach(bool (*func)(void *));
void DoForEach(bool (*func)(void *, void *), void *arg2);
/*----- Private or reserved ---------------*/
private:
virtual void _ReservedList1();
virtual void _ReservedList2();
// return type differs from BeOS version
bool _ResizeArray(int32 count);
private:
void** fObjectList;
int32 fPhysicalSize;
int32 fItemCount;
int32 fBlockSize;
int32 fResizeThreshold;
uint32 _reserved[1];
};
#endif // _BE_LIST_H
#include <../os/support/List.h>
+1 -62
View File
@@ -1,62 +1 @@
//
// $Id: Locker.h 10 2002-07-09 12:24:59Z ejakowatz $
//
// This is the BLocker interface for OpenBeOS. It has been created to
// be source and binary compatible with the BeOS version of BLocker.
//
#ifndef _OPENBEOS_LOCKER_H
#define _OPENBEOS_LOCKER_H
#include <OS.h>
#include <SupportDefs.h>
#ifdef USE_OPENBEOS_NAMESPACE
namespace OpenBeOS {
#endif
class BLocker {
public:
BLocker();
BLocker(const char *name);
BLocker(bool benaphore_style);
BLocker(const char *name, bool benaphore_style);
// The following constructor is not documented in the BeBook
// and is only listed here to ensure binary compatibility.
// DO NOT USE THIS CONSTRUCTOR!
BLocker(const char *name, bool benaphore_style, bool);
virtual ~BLocker();
bool Lock(void);
status_t LockWithTimeout(bigtime_t timeout);
void Unlock(void);
thread_id LockingThread(void) const;
bool IsLocked(void) const;
int32 CountLocks(void) const;
int32 CountLockRequests(void) const;
sem_id Sem(void) const;
private:
void InitLocker(const char *name, bool benaphore_style);
bool AcquireLock(bigtime_t timeout, status_t *error);
int32 fBenaphoreCount;
sem_id fSemaphoreID;
thread_id fLockOwner;
int32 fRecursiveCount;
// Reserved space for future changes to BLocker
int32 fReservedSpace[4];
};
#ifdef USE_OPENBEOS_NAMESPACE
}
#endif
#endif // _OPENBEOS_LOCKER_H
#include <../os/support/Locker.h>
+1
View File
@@ -0,0 +1 @@
#include <../os/support/ObjectList.h>
+1 -572
View File
@@ -1,572 +1 @@
/*
* Copyright 2001-2010, Haiku Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef __BSTRING__
#define __BSTRING__
#include <BeBuild.h>
#include <SupportDefs.h>
#include <string.h>
class BStringRef;
class BString {
public:
BString();
BString(const char* string);
BString(const BString& string);
BString(const char* string, int32 maxLength);
~BString();
// Access
const char* String() const;
int32 Length() const;
int32 CountChars() const;
int32 CountBytes(int32 fromCharOffset,
int32 charCount) const;
// Assignment
BString& operator=(const BString& string);
BString& operator=(const char* string);
BString& operator=(char c);
BString& SetTo(const char* string);
BString& SetTo(const char* string, int32 maxLength);
BString& SetTo(const BString& string);
BString& Adopt(BString& from);
BString& SetTo(const BString& string, int32 maxLength);
BString& Adopt(BString& from, int32 maxLength);
BString& SetTo(char c, int32 count);
BString& SetToChars(const char* string, int32 charCount);
BString& SetToChars(const BString& string, int32 charCount);
BString& AdoptChars(BString& from, int32 charCount);
// Substring copying
BString& CopyInto(BString& into, int32 fromOffset,
int32 length) const;
void CopyInto(char* into, int32 fromOffset,
int32 length) const;
BString& CopyCharsInto(BString& into, int32 fromCharOffset,
int32 charCount) const;
bool CopyCharsInto(char* into, int32* intoLength,
int32 fromCharOffset, int32 charCount) const;
// Appending
BString& operator+=(const BString& string);
BString& operator+=(const char* string);
BString& operator+=(char c);
BString& Append(const BString& string);
BString& Append(const char* string);
BString& Append(const BString& string, int32 length);
BString& Append(const char* string, int32 length);
BString& Append(char c, int32 count);
BString& AppendChars(const BString& string, int32 charCount);
BString& AppendChars(const char* string, int32 charCount);
// Prepending
BString& Prepend(const char* string);
BString& Prepend(const BString& string);
BString& Prepend(const char* string, int32 length);
BString& Prepend(const BString& string, int32 length);
BString& Prepend(char c, int32 count);
BString& PrependChars(const char* string, int32 charCount);
BString& PrependChars(const BString& string,
int32 charCount);
// Inserting
BString& Insert(const char* string, int32 position);
BString& Insert(const char* string, int32 length,
int32 position);
BString& Insert(const char* string, int32 fromOffset,
int32 length, int32 position);
BString& Insert(const BString& string, int32 position);
BString& Insert(const BString& string, int32 length,
int32 position);
BString& Insert(const BString& string, int32 fromOffset,
int32 length, int32 position);
BString& Insert(char c, int32 count, int32 position);
BString& InsertChars(const char* string, int32 charPosition);
BString& InsertChars(const char* string, int32 charCount,
int32 charPosition);
BString& InsertChars(const char* string,
int32 fromCharOffset, int32 charCount,
int32 charPosition);
BString& InsertChars(const BString& string,
int32 charPosition);
BString& InsertChars(const BString& string, int32 charCount,
int32 charPosition);
BString& InsertChars(const BString& string,
int32 fromCharOffset, int32 charCount,
int32 charPosition);
// Removing
BString& Truncate(int32 newLength, bool lazy = true);
BString& TruncateChars(int32 newCharCount, bool lazy = true);
BString& Remove(int32 from, int32 length);
BString& RemoveChars(int32 fromCharOffset, int32 charCount);
BString& RemoveFirst(const BString& string);
BString& RemoveLast(const BString& string);
BString& RemoveAll(const BString& string);
BString& RemoveFirst(const char* string);
BString& RemoveLast(const char* string);
BString& RemoveAll(const char* string);
BString& RemoveSet(const char* setOfBytesToRemove);
BString& RemoveCharsSet(const char* setOfCharsToRemove);
BString& MoveInto(BString& into, int32 from, int32 length);
void MoveInto(char* into, int32 from, int32 length);
BString& MoveCharsInto(BString& into, int32 fromCharOffset,
int32 charCount);
bool MoveCharsInto(char* into, int32* intoLength,
int32 fromCharOffset, int32 charCount);
// Compare functions
bool operator<(const BString& string) const;
bool operator<=(const BString& string) const;
bool operator==(const BString& string) const;
bool operator>=(const BString& string) const;
bool operator>(const BString& string) const;
bool operator!=(const BString& string) const;
bool operator<(const char* string) const;
bool operator<=(const char* string) const;
bool operator==(const char* string) const;
bool operator>=(const char* string) const;
bool operator>(const char* string) const;
bool operator!=(const char* string) const;
operator const char*() const;
// strcmp()-style compare functions
int Compare(const BString& string) const;
int Compare(const char* string) const;
int Compare(const BString& string, int32 length) const;
int Compare(const char* string, int32 length) const;
int CompareChars(const BString& string,
int32 charCount) const;
int CompareChars(const char* string,
int32 charCount) const;
int ICompare(const BString& string) const;
int ICompare(const char* string) const;
int ICompare(const BString& string, int32 length) const;
int ICompare(const char* string, int32 length) const;
// Searching
int32 FindFirst(const BString& string) const;
int32 FindFirst(const char* string) const;
int32 FindFirst(const BString& string,
int32 fromOffset) const;
int32 FindFirst(const char* string,
int32 fromOffset) const;
int32 FindFirst(char c) const;
int32 FindFirst(char c, int32 fromOffset) const;
int32 FindFirstChars(const BString& string,
int32 fromCharOffset) const;
int32 FindFirstChars(const char* string,
int32 fromCharOffset) const;
int32 FindLast(const BString& string) const;
int32 FindLast(const char* string) const;
int32 FindLast(const BString& string,
int32 beforeOffset) const;
int32 FindLast(const char* string,
int32 beforeOffset) const;
int32 FindLast(char c) const;
int32 FindLast(char c, int32 beforeOffset) const;
int32 FindLastChars(const BString& string,
int32 beforeCharOffset) const;
int32 FindLastChars(const char* string,
int32 beforeCharOffset) const;
int32 IFindFirst(const BString& string) const;
int32 IFindFirst(const char* string) const;
int32 IFindFirst(const BString& string,
int32 fromOffset) const;
int32 IFindFirst(const char* string,
int32 fromOffset) const;
int32 IFindLast(const BString& string) const;
int32 IFindLast(const char* string) const;
int32 IFindLast(const BString& string,
int32 beforeOffset) const;
int32 IFindLast(const char* string,
int32 beforeOffset) const;
// Replacing
BString& ReplaceFirst(char replaceThis, char withThis);
BString& ReplaceLast(char replaceThis, char withThis);
BString& ReplaceAll(char replaceThis, char withThis,
int32 fromOffset = 0);
BString& Replace(char replaceThis, char withThis,
int32 maxReplaceCount, int32 fromOffset = 0);
BString& ReplaceFirst(const char* replaceThis,
const char* withThis);
BString& ReplaceLast(const char* replaceThis,
const char* withThis);
BString& ReplaceAll(const char* replaceThis,
const char* withThis, int32 fromOffset = 0);
BString& Replace(const char* replaceThis,
const char* withThis, int32 maxReplaceCount,
int32 fromOffset = 0);
BString& ReplaceAllChars(const char* replaceThis,
const char* withThis, int32 fromCharOffset);
BString& ReplaceChars(const char* replaceThis,
const char* withThis, int32 maxReplaceCount,
int32 fromCharOffset);
BString& IReplaceFirst(char replaceThis, char withThis);
BString& IReplaceLast(char replaceThis, char withThis);
BString& IReplaceAll(char replaceThis, char withThis,
int32 fromOffset = 0);
BString& IReplace(char replaceThis, char withThis,
int32 maxReplaceCount, int32 fromOffset = 0);
BString& IReplaceFirst(const char* replaceThis,
const char* withThis);
BString& IReplaceLast(const char* replaceThis,
const char* withThis);
BString& IReplaceAll(const char* replaceThis,
const char* withThis, int32 fromOffset = 0);
BString& IReplace(const char* replaceThis,
const char* withThis, int32 maxReplaceCount,
int32 fromOffset = 0);
BString& ReplaceSet(const char* setOfBytes, char with);
BString& ReplaceSet(const char* setOfBytes,
const char* with);
BString& ReplaceCharsSet(const char* setOfChars,
const char* with);
// Unchecked char access
char operator[](int32 index) const;
#if __GNUC__ > 3
BStringRef operator[](int32 index);
#else
char& operator[](int32 index);
#endif
// Checked char access
char ByteAt(int32 index) const;
const char* CharAt(int32 charIndex, int32* bytes = NULL) const;
bool CharAt(int32 charIndex, char* buffer,
int32* bytes) const;
// Fast low-level manipulation
char* LockBuffer(int32 maxLength);
BString& UnlockBuffer(int32 length = -1);
// Upercase <-> Lowercase
BString& ToLower();
BString& ToUpper();
BString& Capitalize();
BString& CapitalizeEachWord();
// Escaping and De-escaping
BString& CharacterEscape(const char* original,
const char* setOfCharsToEscape,
char escapeWith);
BString& CharacterEscape(const char* setOfCharsToEscape,
char escapeWith);
BString& CharacterDeescape(const char* original,
char escapeChar);
BString& CharacterDeescape(char escapeChar);
// Trimming
BString& Trim();
// Insert
BString& operator<<(const char* string);
BString& operator<<(const BString& string);
BString& operator<<(char c);
BString& operator<<(int value);
BString& operator<<(unsigned int value);
BString& operator<<(unsigned long value);
BString& operator<<(long value);
BString& operator<<(unsigned long long value);
BString& operator<<(long long value);
// float output hardcodes %.2f style formatting
BString& operator<<(float value);
private:
class PosVect;
friend class BStringRef;
// Management
status_t _MakeWritable();
status_t _MakeWritable(int32 length, bool copy);
static char* _Allocate(int32 length);
char* _Resize(int32 length);
void _Init(const char* src, int32 length);
char* _Clone(const char* data, int32 length);
char* _OpenAtBy(int32 offset, int32 length);
char* _ShrinkAtBy(int32 offset, int32 length);
// Data
void _SetLength(int32 length);
bool _DoAppend(const char* string, int32 length);
bool _DoPrepend(const char* string, int32 length);
bool _DoInsert(const char* string, int32 offset,
int32 length);
// Search
int32 _ShortFindAfter(const char* string,
int32 length) const;
int32 _FindAfter(const char* string, int32 offset,
int32 length) const;
int32 _IFindAfter(const char* string, int32 offset,
int32 length) const;
int32 _FindBefore(const char* string, int32 offset,
int32 length) const;
int32 _IFindBefore(const char* string, int32 offset,
int32 length) const;
// Escape
BString& _DoCharacterEscape(const char* string,
const char *setOfCharsToEscape, char escapeChar);
BString& _DoCharacterDeescape(const char* string,
char escapeChar);
// Replace
BString& _DoReplace(const char* findThis,
const char* replaceWith, int32 maxReplaceCount,
int32 fromOffset, bool ignoreCase);
void _ReplaceAtPositions(const PosVect* positions,
int32 searchLength, const char* with,
int32 withLength);
private:
vint32& _ReferenceCount();
const vint32& _ReferenceCount() const;
bool _IsShareable() const;
void _FreePrivateData();
char* fPrivateData;
};
// Commutative compare operators
bool operator<(const char* a, const BString& b);
bool operator<=(const char* a, const BString& b);
bool operator==(const char* a, const BString& b);
bool operator>(const char* a, const BString& b);
bool operator>=(const char* a, const BString& b);
bool operator!=(const char* a, const BString& b);
// Non-member compare for sorting, etc.
int Compare(const BString& a, const BString& b);
int ICompare(const BString& a, const BString& b);
int Compare(const BString* a, const BString* b);
int ICompare(const BString* a, const BString* b);
inline int32
BString::Length() const
{
// the most significant bit is reserved; accessing
// it in any way will cause the computer to explode
return fPrivateData ? (*(((int32 *)fPrivateData) - 1) & 0x7fffffff) : 0;
}
inline const char*
BString::String() const
{
if (!fPrivateData)
return "";
return fPrivateData;
}
inline BString &
BString::SetTo(const char* string)
{
return operator=(string);
}
inline char
BString::operator[](int32 index) const
{
return fPrivateData[index];
}
inline char
BString::ByteAt(int32 index) const
{
if (!fPrivateData || index < 0 || index >= Length())
return 0;
return fPrivateData[index];
}
inline BString &
BString::operator+=(const BString &string)
{
_DoAppend(string.String(), string.Length());
return *this;
}
inline BString &
BString::Append(const BString &string)
{
_DoAppend(string.String(), string.Length());
return *this;
}
inline BString &
BString::Append(const char* string)
{
return operator+=(string);
}
inline bool
BString::operator==(const BString &string) const
{
return strcmp(String(), string.String()) == 0;
}
inline bool
BString::operator<(const BString &string) const
{
return strcmp(String(), string.String()) < 0;
}
inline bool
BString::operator<=(const BString &string) const
{
return strcmp(String(), string.String()) <= 0;
}
inline bool
BString::operator>=(const BString &string) const
{
return strcmp(String(), string.String()) >= 0;
}
inline bool
BString::operator>(const BString &string) const
{
return strcmp(String(), string.String()) > 0;
}
inline bool
BString::operator!=(const BString &string) const
{
return strcmp(String(), string.String()) != 0;
}
inline bool
BString::operator!=(const char* string) const
{
return !operator==(string);
}
inline
BString::operator const char*() const
{
return String();
}
inline bool
operator<(const char *str, const BString &string)
{
return string > str;
}
inline bool
operator<=(const char *str, const BString &string)
{
return string >= str;
}
inline bool
operator==(const char *str, const BString &string)
{
return string == str;
}
inline bool
operator>(const char *str, const BString &string)
{
return string < str;
}
inline bool
operator>=(const char *str, const BString &string)
{
return string <= str;
}
inline bool
operator!=(const char *str, const BString &string)
{
return string != str;
}
// #pragma mark - BStringRef
class BStringRef {
public:
BStringRef(BString& string, int32 position);
~BStringRef() {}
operator char() const;
char* operator&();
const char* operator&() const;
BStringRef& operator=(char c);
BStringRef& operator=(const BStringRef& rc);
private:
BString& fString;
int32 fPosition;
};
#endif // __BSTRING__
#include <../os/support/String.h>
+1 -241
View File
@@ -1,242 +1,2 @@
/*
* Copyright 2004-2010, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*
* Author:
* Erik Jaesler ([email protected])
*/
#ifndef _SUPPORT_DEFS_H
#define _SUPPORT_DEFS_H
#include <config_build/types.h>
#include <BeBuild.h>
#include <Errors.h>
#include <inttypes.h>
#include <sys/types.h>
/* fixed-size integer types */
typedef __haiku_int8 int8;
typedef __haiku_uint8 uint8;
typedef __haiku_int16 int16;
typedef __haiku_uint16 uint16;
typedef __haiku_int32 int32;
typedef __haiku_uint32 uint32;
typedef __haiku_int64 int64;
typedef __haiku_uint64 uint64;
/* shorthand types */
typedef volatile int8 vint8;
typedef volatile uint8 vuint8;
typedef volatile int16 vint16;
typedef volatile uint16 vuint16;
typedef volatile int32 vint32;
typedef volatile uint32 vuint32;
typedef volatile int64 vint64;
typedef volatile uint64 vuint64;
typedef volatile long vlong;
typedef volatile int vint;
typedef volatile short vshort;
typedef volatile char vchar;
typedef volatile unsigned long vulong;
typedef volatile unsigned int vuint;
typedef volatile unsigned short vushort;
typedef volatile unsigned char vuchar;
typedef unsigned char uchar;
typedef unsigned short unichar;
/* descriptive types */
typedef int32 status_t;
typedef int64 bigtime_t;
typedef uint32 type_code;
typedef uint32 perform_code;
#ifdef HAIKU_HOST_PLATFORM_64_BIT
typedef uint64 phys_addr_t;
#else
typedef uint32 phys_addr_t;
#endif
typedef phys_addr_t phys_size_t;
typedef addr_t generic_addr_t;
typedef size_t generic_size_t;
/* printf()/scanf() format strings for [u]int* types */
#define B_PRId8 PRId8
#define B_PRIi8 PRIi8
#define B_PRId16 PRId16
#define B_PRIi16 PRIi16
#define B_PRId32 PRId32
#define B_PRIi32 PRIi32
#define B_PRId64 PRId64
#define B_PRIi64 PRIi64
#define B_PRIu8 PRIu8
#define B_PRIo8 PRIo8
#define B_PRIx8 PRIx8
#define B_PRIX8 PRIX8
#define B_PRIu16 PRIu16
#define B_PRIo16 PRIo16
#define B_PRIx16 PRIx16
#define B_PRIX16 PRIX16
#define B_PRIu32 PRIu32
#define B_PRIo32 PRIo32
#define B_PRIx32 PRIx32
#define B_PRIX32 PRIX32
#define B_PRIu64 PRIu64
#define B_PRIo64 PRIo64
#define B_PRIx64 PRIx64
#define B_PRIX64 PRIX64
#define B_SCNd8 SCNd8
#define B_SCNi8 SCNi8
#define B_SCNd16 SCNd16
#define B_SCNi16 SCNi16
#define B_SCNd32 SCNd32
#define B_SCNi32 SCNi32
#define B_SCNd64 SCNd64
#define B_SCNi64 SCNi64
#define B_SCNu8 SCNu8
#define B_SCNo8 SCNo8
#define B_SCNx8 SCNx8
#define B_SCNu16 SCNu16
#define B_SCNu16 SCNu16
#define B_SCNx16 SCNx16
#define B_SCNu32 SCNu32
#define B_SCNo32 SCNo32
#define B_SCNx32 SCNx32
#define B_SCNu64 SCNu64
#define B_SCNo64 SCNo64
#define B_SCNx64 SCNx64
/* printf() format strings for some standard types */
/* addr_t, size_t, ssize_t */
#ifdef HAIKU_HOST_PLATFORM_64_BIT
# define B_PRIuADDR B_PRIu64
# define B_PRIoADDR B_PRIo64
# define B_PRIxADDR B_PRIx64
# define B_PRIXADDR B_PRIX64
# define B_PRIuSIZE B_PRIu64
# define B_PRIoSIZE B_PRIo64
# define B_PRIxSIZE B_PRIx64
# define B_PRIXSIZE B_PRIX64
# define B_PRIdSSIZE B_PRId64
# define B_PRIiSSIZE B_PRIi64
#else
# define B_PRIuADDR B_PRIu32
# define B_PRIoADDR B_PRIo32
# define B_PRIxADDR B_PRIx32
# define B_PRIXADDR B_PRIX32
# define B_PRIuSIZE B_PRIu32
# define B_PRIoSIZE B_PRIo32
# define B_PRIxSIZE B_PRIx32
# define B_PRIXSIZE B_PRIX32
# define B_PRIdSSIZE B_PRId32
# define B_PRIiSSIZE B_PRIi32
#endif
/* phys_addr_t */
#ifdef HAIKU_HOST_PLATFORM_64_BIT
# define B_PRIuPHYSADDR B_PRIu64
# define B_PRIoPHYSADDR B_PRIo64
# define B_PRIxPHYSADDR B_PRIx64
# define B_PRIXPHYSADDR B_PRIX64
#else
# define B_PRIuPHYSADDR B_PRIu32
# define B_PRIoPHYSADDR B_PRIo32
# define B_PRIxPHYSADDR B_PRIx32
# define B_PRIXPHYSADDR B_PRIX32
#endif
/* generic_addr_t */
#define B_PRIuGENADDR B_PRIuADDR
#define B_PRIoGENADDR B_PRIoADDR
#define B_PRIxGENADDR B_PRIxADDR
#define B_PRIXGENADDR B_PRIXADDR
/* off_t */
#define B_PRIdOFF B_PRId64
#define B_PRIiOFF B_PRIi64
/* dev_t */
#define B_PRIdDEV B_PRId32
#define B_PRIiDEV B_PRIi32
/* ino_t */
#define B_PRIdINO B_PRId64
#define B_PRIiINO B_PRIi64
/* time_t */
#define B_PRIdTIME B_PRId32
#define B_PRIiTIME B_PRIi32
/* Empty string ("") */
#ifdef __cplusplus
extern const char *B_EMPTY_STRING;
#endif
/* min and max comparisons */
#ifndef __cplusplus
# ifndef min
# define min(a,b) ((a)>(b)?(b):(a))
# endif
# ifndef max
# define max(a,b) ((a)>(b)?(a):(b))
# endif
#endif
/* min() and max() are functions in C++ */
#define min_c(a,b) ((a)>(b)?(b):(a))
#define max_c(a,b) ((a)>(b)?(a):(b))
/* Grandfathering */
#ifndef __cplusplus
# include <stdbool.h>
#endif
#ifndef NULL
# define NULL (0)
#endif
#ifdef __cplusplus
extern "C" {
#endif
/* Atomic functions; previous value is returned */
extern int32 atomic_set(vint32 *value, int32 newValue);
extern int32 atomic_test_and_set(vint32 *value, int32 newValue, int32 testAgainst);
extern int32 atomic_add(vint32 *value, int32 addValue);
extern int32 atomic_and(vint32 *value, int32 andValue);
extern int32 atomic_or(vint32 *value, int32 orValue);
extern int32 atomic_get(vint32 *value);
extern int64 atomic_set64(vint64 *value, int64 newValue);
extern int64 atomic_test_and_set64(vint64 *value, int64 newValue, int64 testAgainst);
extern int64 atomic_add64(vint64 *value, int64 addValue);
extern int64 atomic_and64(vint64 *value, int64 andValue);
extern int64 atomic_or64(vint64 *value, int64 orValue);
extern int64 atomic_get64(vint64 *value);
/* Other stuff */
extern void* get_stack_frame(void);
#ifdef __cplusplus
}
#endif
/* Obsolete or discouraged API */
/* use 'true' and 'false' */
#ifndef FALSE
# define FALSE 0
#endif
#ifndef TRUE
# define TRUE 1
#endif
#endif /* _SUPPORT_DEFS_H */
#include <../os/support/SupportDefs.h>
+1 -78
View File
@@ -1,78 +1 @@
/*
* Copyright 2005-2007, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*
* Author:
* Erik Jaesler ([email protected])
*/
#ifndef _TYPE_CONSTANTS_H
#define _TYPE_CONSTANTS_H
#include <BeBuild.h>
enum {
B_ANY_TYPE = 'ANYT',
B_ATOM_TYPE = 'ATOM',
B_ATOMREF_TYPE = 'ATMR',
B_BOOL_TYPE = 'BOOL',
B_CHAR_TYPE = 'CHAR',
B_COLOR_8_BIT_TYPE = 'CLRB',
B_DOUBLE_TYPE = 'DBLE',
B_FLOAT_TYPE = 'FLOT',
B_GRAYSCALE_8_BIT_TYPE = 'GRYB',
B_INT16_TYPE = 'SHRT',
B_INT32_TYPE = 'LONG',
B_INT64_TYPE = 'LLNG',
B_INT8_TYPE = 'BYTE',
B_LARGE_ICON_TYPE = 'ICON',
B_MEDIA_PARAMETER_GROUP_TYPE = 'BMCG',
B_MEDIA_PARAMETER_TYPE = 'BMCT',
B_MEDIA_PARAMETER_WEB_TYPE = 'BMCW',
B_MESSAGE_TYPE = 'MSGG',
B_MESSENGER_TYPE = 'MSNG',
B_MIME_TYPE = 'MIME',
B_MINI_ICON_TYPE = 'MICN',
B_MONOCHROME_1_BIT_TYPE = 'MNOB',
B_OBJECT_TYPE = 'OPTR',
B_OFF_T_TYPE = 'OFFT',
B_PATTERN_TYPE = 'PATN',
B_POINTER_TYPE = 'PNTR',
B_POINT_TYPE = 'BPNT',
B_PROPERTY_INFO_TYPE = 'SCTD',
B_RAW_TYPE = 'RAWT',
B_RECT_TYPE = 'RECT',
B_REF_TYPE = 'RREF',
B_RGB_32_BIT_TYPE = 'RGBB',
B_RGB_COLOR_TYPE = 'RGBC',
B_SIZE_T_TYPE = 'SIZT',
B_SSIZE_T_TYPE = 'SSZT',
B_STRING_TYPE = 'CSTR',
B_TIME_TYPE = 'TIME',
B_UINT16_TYPE = 'USHT',
B_UINT32_TYPE = 'ULNG',
B_UINT64_TYPE = 'ULLG',
B_UINT8_TYPE = 'UBYT',
B_VECTOR_ICON_TYPE = 'VICN',
// deprecated, do not use
B_ASCII_TYPE = 'TEXT' // use B_STRING_TYPE instead
};
// System-wide MIME types for handling URL's
extern const char *B_URL_HTTP; // application/x-vnd.Be.URL.http
extern const char *B_URL_HTTPS; // application/x-vnd.Be.URL.https
extern const char *B_URL_FTP; // application/x-vnd.Be.URL.ftp
extern const char *B_URL_GOPHER; // application/x-vnd.Be.URL.gopher
extern const char *B_URL_MAILTO; // application/x-vnd.Be.URL.mailto
extern const char *B_URL_NEWS; // application/x-vnd.Be.URL.news
extern const char *B_URL_NNTP; // application/x-vnd.Be.URL.nntp
extern const char *B_URL_TELNET; // application/x-vnd.Be.URL.telnet
extern const char *B_URL_RLOGIN; // application/x-vnd.Be.URL.rlogin
extern const char *B_URL_TN3270; // application/x-vnd.Be.URL.tn3270
extern const char *B_URL_WAIS; // application/x-vnd.Be.URL.wais
extern const char *B_URL_FILE; // application/x-vnd.Be.URL.file
#endif // _TYPE_CONSTANTS_H
#include <../os/support/TypeConstants.h>
+1 -126
View File
@@ -1,126 +1 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// File Name: LooperList.h
// Author(s): Erik Jaesler ([email protected])
// Description: Maintains a global list of all loopers in a given team.
//------------------------------------------------------------------------------
#ifndef LOOPERLIST_H
#define LOOPERLIST_H
// Standard Includes -----------------------------------------------------------
#include <vector>
// System Includes -------------------------------------------------------------
#include <Locker.h>
#include <OS.h>
#include <SupportDefs.h>
// Project Includes ------------------------------------------------------------
// Local Includes --------------------------------------------------------------
// Local Defines ---------------------------------------------------------------
// Globals ---------------------------------------------------------------------
class BLooper;
namespace BPrivate {
class BLooperList
{
public:
BLooperList();
bool Lock();
void Unlock();
bool IsLocked();
void AddLooper(BLooper* l);
bool IsLooperValid(const BLooper* l);
bool RemoveLooper(BLooper* l);
void GetLooperList(BList* list);
int32 CountLoopers();
BLooper* LooperAt(int32 index);
BLooper* LooperForThread(thread_id tid);
BLooper* LooperForName(const char* name);
BLooper* LooperForPort(port_id port);
struct LooperData
{
LooperData();
LooperData(BLooper* loop, uint32 i);
LooperData(const LooperData& rhs);
LooperData& operator=(const LooperData& rhs);
BLooper* looper;
uint32 id;
};
private:
static bool EmptySlotPred(LooperData& Data);
struct FindLooperPred
{
FindLooperPred(const BLooper* loop) : looper(loop) {;}
bool operator()(LooperData& Data);
const BLooper* looper;
};
struct FindThreadPred
{
FindThreadPred(thread_id tid) : thread(tid) {;}
bool operator()(LooperData& Data);
thread_id thread;
};
struct FindNamePred
{
FindNamePred(const char* n) : name(n) {;}
bool operator()(LooperData& Data);
const char* name;
};
struct FindPortPred
{
FindPortPred(port_id pid) : port(pid) {;}
bool operator()(LooperData& Data);
port_id port;
};
void AssertLocked();
BLocker fLock;
uint32 fLooperID;
std::vector<LooperData> fData;
};
extern _IMPEXP_BE BLooperList gLooperList;
}
#endif //LOOPERLIST_H
/*
* $Log $
*
* $Id $
*
*/
#include <../private/app/LooperList.h>
+1 -51
View File
@@ -1,51 +1 @@
/*
* Copyright 2007, Haiku Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
* Michael Lotz <mmlr@mlotz.ch>
*/
#ifndef _MESSAGE_ADAPTER_H_
#define _MESSAGE_ADAPTER_H_
#include <Message.h>
// message formats
#define MESSAGE_FORMAT_R5 'FOB1'
#define MESSAGE_FORMAT_R5_SWAPPED '1BOF'
#define MESSAGE_FORMAT_DANO 'FOB2'
#define MESSAGE_FORMAT_DANO_SWAPPED '2BOF'
#define MESSAGE_FORMAT_HAIKU '1FMH'
#define MESSAGE_FORMAT_HAIKU_SWAPPED 'HMF1'
namespace BPrivate {
class MessageAdapter {
public:
static ssize_t FlattenedSize(uint32 format, const BMessage *from);
static status_t Flatten(uint32 format, const BMessage *from,
char *buffer, ssize_t *size);
static status_t Flatten(uint32 format, const BMessage *from,
BDataIO *stream, ssize_t *size);
static status_t Unflatten(uint32 format, BMessage *into,
const char *buffer);
static status_t Unflatten(uint32 format, BMessage *into,
BDataIO *stream);
private:
static ssize_t _R5FlattenedSize(const BMessage *from);
static status_t _FlattenR5Message(uint32 format, const BMessage *from,
char *buffer, ssize_t *size);
static status_t _UnflattenR5Message(uint32 format, BMessage *into,
BDataIO *stream);
static status_t _UnflattenDanoMessage(uint32 format, BMessage *into,
BDataIO *stream);
};
} // namespace BPrivate
#endif // _MESSAGE_ADAPTER_H_
#include <../private/app/MessageAdapter.h>
+1 -187
View File
@@ -1,187 +1 @@
#ifndef _MESSAGE_UTILS_H_
#define _MESSAGE_UTILS_H_
#include <ByteOrder.h>
#include <DataIO.h>
#include <Entry.h>
#include <Message.h>
#include <SupportDefs.h>
namespace BPrivate { // Only putting these here because Be did
status_t entry_ref_flatten(char* buffer, size_t* size, const entry_ref* ref);
status_t entry_ref_unflatten(entry_ref* ref, const char* buffer, size_t size);
status_t entry_ref_swap(char* buffer, size_t size);
uint32 CalculateChecksum(const uint8 *buffer, int32 size);
} // namespace BPrivate
template<class T>
inline void
byte_swap(T &/*data*/)
{
// Specialize for data types which actually swap
}
inline void
write_helper(BDataIO *stream, const void *data, size_t size)
{
status_t error = stream->Write(data, size);
if (error < B_OK)
throw error;
}
class TReadHelper {
public:
TReadHelper(BDataIO *stream)
: fStream(stream),
fError(B_OK),
fSwap(false)
{
}
TReadHelper(BDataIO *stream, bool swap)
: fStream(stream),
fError(B_OK),
fSwap(swap)
{
}
template<class T>
inline void operator()(T &data)
{
fError = fStream->Read((void *)&data, sizeof(T));
if (fError > B_OK) {
if (IsSwapping())
byte_swap(data);
return;
}
if (fError == 0)
fError = B_ERROR;
throw fError;
}
template<class T>
inline void operator()(T data, size_t len)
{
fError = fStream->Read((void *)data, len);
if (fError >= B_OK)
return;
throw fError;
}
status_t Status() { return fError >= B_OK ? B_OK : fError; };
void SetSwap(bool yesNo) { fSwap = yesNo; };
bool IsSwapping() { return fSwap; };
private:
BDataIO *fStream;
status_t fError;
bool fSwap;
};
class TChecksumHelper {
public:
TChecksumHelper(uchar* buffer)
: fBuffer(buffer),
fBufPtr(buffer)
{
}
template<class T>
inline void Cache(const T &data)
{
*((T*)fBufPtr) = data;
fBufPtr += sizeof (T);
}
int32 CheckSum();
private:
uchar *fBuffer;
uchar *fBufPtr;
};
template<>
inline void
byte_swap(double &data)
{
data = __swap_double(data);
}
template<>
inline void
byte_swap(float &data)
{
data = __swap_float(data);
}
template<>
inline void
byte_swap(int64 &data)
{
data = __swap_int64(data);
}
template<>
inline void
byte_swap(uint64 &data)
{
data = __swap_int64(data);
}
template<>
inline void
byte_swap(int32 &data)
{
data = __swap_int32(data);
}
template<>
inline void
byte_swap(uint32 &data)
{
data = __swap_int32(data);
}
template<>
inline void
byte_swap(int16 &data)
{
data = __swap_int16(data);
}
template<>
inline void
byte_swap(uint16 &data)
{
data = __swap_int16(data);
}
template<>
inline void
byte_swap(entry_ref &data)
{
byte_swap(data.device);
byte_swap(data.directory);
}
#endif // _MESSAGE_UTILS_H_
#include <../private/app/MessageUtils.h>
+1 -177
View File
@@ -1,177 +1 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// File Name: RegistrarDefs.h
// Author(s): Ingo Weinhold ([email protected])
// Description: API classes - registrar interface.
//------------------------------------------------------------------------------
#ifndef REGISTRAR_DEFS_H
#define REGISTRAR_DEFS_H
#include <Errors.h>
#include <Roster.h>
namespace BPrivate {
// names
extern const char *kRegistrarSignature;
extern const char *kRosterThreadName;
extern const char *kRAppLooperPortName;
extern const char *get_roster_port_name();
// message constants
enum {
// replies
B_REG_SUCCESS = 'rgsu',
B_REG_ERROR = 'rger',
B_REG_RESULT = 'rgrz',
// general requests
B_REG_GET_MIME_MESSENGER = 'rgmm',
B_REG_GET_CLIPBOARD_MESSENGER = 'rgcm',
B_REG_GET_DISK_DEVICE_MESSENGER = 'rgdm',
B_REG_SHUT_DOWN = 'rgsh',
// roster requests
B_REG_ADD_APP = 'rgaa',
B_REG_COMPLETE_REGISTRATION = 'rgcr',
B_REG_IS_APP_PRE_REGISTERED = 'rgip',
B_REG_REMOVE_PRE_REGISTERED_APP = 'rgrp',
B_REG_REMOVE_APP = 'rgra',
B_REG_SET_THREAD_AND_TEAM = 'rgtt',
B_REG_SET_SIGNATURE = 'rgss',
B_REG_GET_APP_INFO = 'rgai',
B_REG_GET_APP_LIST = 'rgal',
B_REG_ACTIVATE_APP = 'rgac',
B_REG_BROADCAST = 'rgbc',
B_REG_START_WATCHING = 'rgwa',
B_REG_STOP_WATCHING = 'rgsw',
B_REG_GET_RECENT_DOCUMENTS = 'rggd',
B_REG_GET_RECENT_FOLDERS = 'rggf',
B_REG_GET_RECENT_APPS = 'rgga',
B_REG_ADD_TO_RECENT_DOCUMENTS = 'rg2d',
B_REG_ADD_TO_RECENT_FOLDERS = 'rg2f',
B_REG_ADD_TO_RECENT_APPS = 'rg2a',
B_REG_CLEAR_RECENT_DOCUMENTS = 'rgxd',
B_REG_CLEAR_RECENT_FOLDERS = 'rgxf',
B_REG_CLEAR_RECENT_APPS = 'rgxa',
B_REG_LOAD_RECENT_LISTS = 'rglr',
B_REG_SAVE_RECENT_LISTS = 'rgsr',
// MIME requests
B_REG_MIME_SET_PARAM = 'rgsp',
B_REG_MIME_DELETE_PARAM = 'rgdp',
B_REG_MIME_START_WATCHING = 'rgwb',
B_REG_MIME_STOP_WATCHING = 'rgwe',
B_REG_MIME_INSTALL = 'rgin',
B_REG_MIME_DELETE = 'rgdl',
B_REG_MIME_GET_INSTALLED_TYPES = 'rgit',
B_REG_MIME_GET_INSTALLED_SUPERTYPES = 'rgis',
B_REG_MIME_GET_SUPPORTING_APPS = 'rgsa',
B_REG_MIME_GET_ASSOCIATED_TYPES = 'rgat',
B_REG_MIME_SNIFF = 'rgsn',
B_REG_MIME_UPDATE_MIME_INFO = 'rgup',
B_REG_MIME_CREATE_APP_META_MIME = 'rgca',
B_REG_MIME_UPDATE_THREAD_FINISHED = 'rgtf',
// message runner requests
B_REG_REGISTER_MESSAGE_RUNNER = 'rgrr',
B_REG_UNREGISTER_MESSAGE_RUNNER = 'rgru',
B_REG_SET_MESSAGE_RUNNER_PARAMS = 'rgrx',
B_REG_GET_MESSAGE_RUNNER_INFO = 'rgri',
// internal registrar messages
B_REG_ROSTER_SANITY_EVENT = 'rgir',
B_REG_SHUTDOWN_FINISHED = 'rgsf',
B_REG_ROSTER_DEVICE_RESCAN = 'rgrs',
// clipboard handler requests
B_REG_ADD_CLIPBOARD = 'rgCa',
B_REG_GET_CLIPBOARD_COUNT = 'rgCc',
B_REG_CLIPBOARD_START_WATCHING = 'rgCw',
B_REG_CLIPBOARD_STOP_WATCHING = 'rgCx',
B_REG_DOWNLOAD_CLIPBOARD = 'rgCd',
B_REG_UPLOAD_CLIPBOARD = 'rgCu',
// disk device request
B_REG_NEXT_DISK_DEVICE = 'rgnx',
B_REG_GET_DISK_DEVICE = 'rgdd',
B_REG_UPDATE_DISK_DEVICE = 'rgud',
B_REG_DEVICE_START_WATCHING = 'rgwd',
B_REG_DEVICE_STOP_WATCHING = 'rgsd',
};
// B_REG_MIME_SET_PARAM "which" constants
enum {
B_REG_MIME_APP_HINT = 'rgmh',
B_REG_MIME_ATTR_INFO = 'rgma',
B_REG_MIME_DESCRIPTION = 'rgmd',
B_REG_MIME_FILE_EXTENSIONS = 'rgmf',
B_REG_MIME_ICON = 'rgmi',
B_REG_MIME_ICON_FOR_TYPE = 'rgm4',
B_REG_MIME_PREFERRED_APP = 'rgmp',
B_REG_MIME_SNIFFER_RULE = 'rgmr',
B_REG_MIME_SUPPORTED_TYPES = 'rgms',
};
// B_REG_UPDATE_DISK_DEVICE "update_policy" constants
enum {
B_REG_DEVICE_UPDATE_CHECK,
B_REG_DEVICE_UPDATE_CHANGED,
B_REG_DEVICE_UPDATE_DEVICE_CHANGED,
};
// type constants
enum {
B_REG_APP_INFO_TYPE = 'rgai', // app_info
};
// error constants
#define B_REGISTRAR_ERROR_BASE (B_ERRORS_END + 1)
enum {
B_REG_ALREADY_REGISTERED = B_REGISTRAR_ERROR_BASE,
// A team tries to register a second time.
B_REG_APP_NOT_REGISTERED,
B_REG_APP_NOT_PRE_REGISTERED,
};
// misc constants
enum {
B_REG_DEFAULT_APP_FLAGS = B_MULTIPLE_LAUNCH | B_ARGV_ONLY
| _B_APP_INFO_RESERVED1_,
B_REG_APP_LOOPER_PORT_CAPACITY = 100,
};
// structs
// a flat app_info -- to be found in B_REG_APP_INFO_TYPE message fields
struct flat_app_info {
app_info info;
char ref_name[B_FILE_NAME_LENGTH + 1];
};
} // namespace BPrivate
#endif // REGISTRAR_DEFS_H
#include <../private/app/RegistrarDefs.h>
+1 -82
View File
@@ -1,82 +1 @@
/*
* Copyright 2001-2005, Haiku.
* Distributed under the terms of the MIT License.
*
* Authors:
* Erik Jaesler (erik@cgsoftware.com)
* Axel Dörfler, axeld@pinc-software.de
*/
#ifndef _TOKEN_SPACE_H
#define _TOKEN_SPACE_H
#include <map>
#include <stack>
#include <BeBuild.h>
#include <Locker.h>
#include <SupportDefs.h>
// token types as specified in targets
#define B_PREFERRED_TOKEN -2 /* A little bird told me about this one */
#define B_NULL_TOKEN -1
#define B_ANY_TOKEN 0
// token types in the token list
#define B_HANDLER_TOKEN 1
#define B_SERVER_TOKEN 2
namespace BPrivate {
typedef void (*new_token_callback)(int16, void*);
typedef void (*remove_token_callback)(int16, void*);
typedef bool (*get_token_callback)(int16, void*);
class BTokenSpace : public BLocker {
public:
BTokenSpace();
~BTokenSpace();
int32 NewToken(int16 type, void* object,
new_token_callback callback = NULL);
bool RemoveToken(int32 token, remove_token_callback callback = NULL);
bool CheckToken(int32 token, int16 type) const;
status_t GetToken(int32 token, int16 type, void** object,
get_token_callback callback = NULL) const;
status_t GetList(int32*& tokens, int32& count) const;
// Possible expansion
// void Dump(BDataIO&, bool) const;
// int32 NewToken(void*, BDirectMessageTarget*, void (*)(short, void*));
// bool SetTokenTarget(uint32, BDirectMessageTarget*);
// BDirectMessageTarget* TokenTarget(uint32 token, int16 type);
private:
struct TTokenInfo {
int16 type;
void* object;
};
typedef std::map<int32, TTokenInfo> TTokenMap;
TTokenMap fTokenMap;
std::stack<int32> fTokenBin;
int32 fTokenCount;
};
// Possible expansion
//_delete_tokens_();
//_init_tokens_();
//get_handler_token(short, void*);
//get_token_list(long, long*);
//new_handler_token(short, void*);
//remove_handler_token(short, void*);
extern _IMPEXP_BE BTokenSpace gDefaultTokens;
} // namespace BPrivate
#endif // _TOKEN_SPACE_H
#include <../private/app/TokenSpace.h>
+1 -152
View File
@@ -1,152 +1 @@
/* $Xorg: region.h,v 1.4 2001/02/09 02:03:40 xorgcvs Exp $ */
/************************************************************************
Copyright 1987, 1998 The Open Group
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of The Open Group shall not be
used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from The Open Group.
Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
All Rights Reserved
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
supporting documentation, and that the name of Digital not be
used in advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
SOFTWARE.
************************************************************************/
#ifndef __REGION_SUPPORT_H
#define __REGION_SUPPORT_H
#include <Region.h>
class BRegion::Support {
public:
static int XUnionRegion(const BRegion* reg1,
const BRegion* reg2, BRegion* newReg);
static int XIntersectRegion(const BRegion* reg1,
const BRegion* reg2, BRegion* newReg);
static int XSubtractRegion(const BRegion* regM,
const BRegion* regS, BRegion* regD);
static int XXorRegion(const BRegion* sra,
const BRegion* srb, BRegion* dr);
static int XPointInRegion(const BRegion* region,
int x, int y);
enum {
RectangleOut = 0,
RectanglePart = 1,
RectangleIn = 2
};
static int XRectInRegion(const BRegion* region,
const clipping_rect& rect);
private:
static BRegion* CreateRegion();
static void DestroyRegion(BRegion* r);
static void XOffsetRegion(BRegion* pRegion, int x, int y);
static void miSetExtents(BRegion* pReg);
static int miIntersectO(BRegion* pReg,
clipping_rect* r1, clipping_rect* r1End,
clipping_rect* r2, clipping_rect* r2End,
int top, int bottom);
static void miRegionCopy(BRegion* dstrgn, const BRegion* rgn);
static int miCoalesce(BRegion* pReg,
int prevStart, int curStart);
static int miUnionNonO(BRegion* pReg, clipping_rect* r,
clipping_rect* rEnd, int top, int bottom);
static int miUnionO(BRegion* pReg,
clipping_rect* r1, clipping_rect* r1End,
clipping_rect* r2, clipping_rect* r2End,
int top, int bottom);
static int miSubtractO(BRegion* pReg,
clipping_rect* r1, clipping_rect* r1End,
clipping_rect* r2, clipping_rect* r2End,
int top, int bottom);
static int miSubtractNonO1(BRegion* pReg,
clipping_rect* r, clipping_rect* rEnd,
int top, int bottom);
typedef int (*overlapProcp)(
BRegion* pReg,
clipping_rect* r1,
clipping_rect* r1End,
register clipping_rect* r2,
clipping_rect* r2End,
int top,
int bottom);
typedef int (*nonOverlapProcp)(
BRegion* pReg,
clipping_rect* r,
clipping_rect* rEnd,
int top,
int bottom);
static void miRegionOp(BRegion* newReg,
const BRegion* reg1, const BRegion* reg2,
int (*overlapFunc)(
register BRegion* pReg,
register clipping_rect* r1,
clipping_rect* r1End,
register clipping_rect* r2,
clipping_rect* r2End,
int top,
int bottom),
int (*nonOverlap1Func)(
register BRegion* pReg,
register clipping_rect* r,
clipping_rect* rEnd,
register int top,
register int bottom),
int (*nonOverlap2Func)(
register BRegion* pReg,
register clipping_rect* r,
clipping_rect* rEnd,
register int top,
register int bottom));
};
#endif // __REGION_SUPPORT_H
#include <../private/interface/RegionSupport.h>
+1 -172
View File
@@ -1,172 +1 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2004, Haiku, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// File Name: clipping.h
// Author: Stefano Ceccherini ([email protected])
// Description: Helper methods to manipulate clipping_rects
//------------------------------------------------------------------------------
#ifndef __CLIPPING_H
#define __CLIPPING_H
#include <Region.h>
#include <SupportDefs.h>
/* Some methods to manipulate clipping_rects.
basically you can do almost everything you do with
BRects, just that clipping_rects can only have integer
coordinates (a thing that makes these perfect for drawing
calculations).
*/
// Returns the union of the given rects.
static inline clipping_rect
union_rect(const clipping_rect &r1, const clipping_rect &r2)
{
clipping_rect rect;
rect.left = min_c(r1.left, r2.left);
rect.top = min_c(r1.top, r2.top);
rect.right = max_c(r1.right, r2.right);
rect.bottom = max_c(r1.bottom, r2.bottom);
return rect;
}
// Returns the intersection of the given rects.
// The caller should check if the returned rect is valid. If it isn't valid,
// then the two rectangles don't intersect.
static inline clipping_rect
sect_rect(const clipping_rect &r1, const clipping_rect &r2)
{
clipping_rect rect;
rect.left = max_c(r1.left, r2.left);
rect.top = max_c(r1.top, r2.top);
rect.right = min_c(r1.right, r2.right);
rect.bottom = min_c(r1.bottom, r2.bottom);
return rect;
}
// Adds the given offsets to the given rect.
static inline void
offset_rect(clipping_rect &rect, int32 x, int32 y)
{
rect.left += x;
rect.top += y;
rect.right += x;
rect.bottom += y;
}
// Converts the given clipping_rect to a BRect
static inline BRect
to_BRect(const clipping_rect &rect)
{
return BRect((float)rect.left, (float)rect.top, (float)rect.right, (float)rect.bottom);
}
// Converts the given BRect to a clipping_rect.
static inline clipping_rect
to_clipping_rect(const BRect &rect)
{
clipping_rect clipRect;
clipRect.left = (int32)floor(rect.left);
clipRect.top = (int32)floor(rect.top);
clipRect.right = (int32)ceil(rect.right);
clipRect.bottom = (int32)ceil(rect.bottom);
return clipRect;
}
// Checks if the given point lies in the given rect's area
static inline bool
point_in(const clipping_rect &rect, int32 px, int32 py)
{
if (px >= rect.left && px <= rect.right
&& py >= rect.top && py <= rect.bottom)
return true;
return false;
}
// Same as above, but it accepts a BPoint parameter
static inline bool
point_in(const clipping_rect &rect, const BPoint &pt)
{
if (pt.x >= rect.left && pt.x <= rect.right
&& pt.y >= rect.top && pt.y <= rect.bottom)
return true;
return false;
}
// Checks if the rect is valid
static inline bool
valid_rect(const clipping_rect &rect)
{
if (rect.left <= rect.right && rect.top <= rect.bottom)
return true;
return false;
}
// Checks if the two rects intersect.
static inline bool
rects_intersect(const clipping_rect &rectA, const clipping_rect &rectB)
{
// We behave like BRect::Intersects() does:
// we return false if one of the two rects is not valid
if (!valid_rect(rectA) || !valid_rect(rectB))
return false;
// TODO: Is there a better algorithm ?
// the one we used is faster than
// ' return valid_rect(sect_rect(rectA, rectB)); ', though.
return !(rectA.left > rectB.right || rectA.top > rectB.bottom
|| rectA.right < rectB.left || rectA.bottom < rectB.top);
}
// Returns the width of the given rect.
static inline int32
rect_width(const clipping_rect &rect)
{
return rect.right - rect.left;
}
// Returns the height of the given rect.
static inline int32
rect_height(const clipping_rect &rect)
{
return rect.bottom - rect.top;
}
#endif // __CLIPPING_H
#include <../private/interface/clipping.h>
@@ -1,181 +1 @@
/*
* Copyright 2004-2010, Haiku, Inc.
* Distributed under the terms of the MIT License.
*/
#ifndef _UTF8_FUNCTIONS_H
#define _UTF8_FUNCTIONS_H
#include <SupportDefs.h>
static inline bool
IsInsideGlyph(uchar ch)
{
return (ch & 0xc0) == 0x80;
}
static inline uint32
UTF8NextCharLenUnsafe(const char *text)
{
const char *ptr = text;
do {
ptr++;
} while (IsInsideGlyph(*ptr));
return ptr - text;
}
static inline uint32
UTF8NextCharLen(const char *text)
{
if (text == NULL || *text == 0)
return 0;
return UTF8NextCharLenUnsafe(text);
}
static inline uint32
UTF8PreviousCharLen(const char *text, const char *limit)
{
const char *ptr = text;
if (ptr == NULL || limit == NULL)
return 0;
do {
if (ptr == limit)
break;
ptr--;
} while (IsInsideGlyph(*ptr));
return text - ptr;
}
/*! UTF8CountBytes gets the length (in bytes) of a UTF8 string. Up to
numChars characters are read. If numChars is a negative value it is ignored
and the string is read up to the terminating 0.
*/
static inline uint32
UTF8CountBytes(const char *bytes, int32 numChars)
{
if (bytes == NULL)
return 0;
if (numChars < 0)
numChars = INT_MAX;
const char *base = bytes;
while (bytes[0] != '\0') {
if ((bytes[0] & 0xc0) != 0x80) {
if (--numChars < 0)
break;
}
bytes++;
}
return bytes - base;
}
/*! UTF8CountChars gets the length (in characters) of a UTF8 string. Up to
numBytes bytes are read. If numBytes is a negative value it is ignored
and the string is read up to the terminating 0.
*/
static inline uint32
UTF8CountChars(const char *bytes, int32 numBytes)
{
if (bytes == NULL)
return 0;
uint32 length = 0;
const char *last;
if (numBytes < 0)
last = (const char *)SIZE_MAX;
else
last = bytes + numBytes - 1;
while (bytes[0] && bytes <= last) {
if ((bytes++[0] & 0xc0) != 0x80)
length++;
}
return length;
}
/*! UTF8ToCharCode converts the input that includes potential multibyte chars
to UTF-32 char codes that can be used by FreeType. The string pointer is
then advanced to the next character in the string. In case the terminating
0 is reached, the string pointer is not advanced anymore and nulls are
returned. This makes it safe to overruns and enables streamed processing
of UTF8 strings.
*/
static inline uint32
UTF8ToCharCode(const char **bytes)
{
#define UTF8_SUBSTITUTE_CHARACTER 0xfffd
uint32 result;
if (((*bytes)[0] & 0x80) == 0) {
// a single byte character
result = (*bytes)[0];
if (result != '\0') {
// do not advance beyond the terminating '\0'
(*bytes)++;
}
return result;
}
if (((*bytes)[0] & 0xc0) == 0x80) {
// not a proper multibyte start
(*bytes)++;
return UTF8_SUBSTITUTE_CHARACTER;
}
// start of a multibyte character
uint8 mask = 0x80;
result = (uint32)((*bytes)[0] & 0xff);
(*bytes)++;
while (result & mask) {
if (mask == 0x02) {
// seven byte char - invalid
return UTF8_SUBSTITUTE_CHARACTER;
}
result &= ~mask;
mask >>= 1;
}
while (((*bytes)[0] & 0xc0) == 0x80) {
result <<= 6;
result += (*bytes)[0] & 0x3f;
(*bytes)++;
mask <<= 1;
if (mask == 0x40)
return result;
}
if (mask == 0x40)
return result;
if ((*bytes)[0] == '\0') {
// string terminated within multibyte char
return 0x00;
}
// not enough bytes in multibyte char
return UTF8_SUBSTITUTE_CHARACTER;
#undef UTF8_SUBSTITUTE_CHARACTER
}
#endif // _UTF8_FUNCTIONS_H
#include <../private/interface/utf8_functions.h>
@@ -0,0 +1 @@
#include <../private/kernel/util/KMessage.h>
+1 -220
View File
@@ -1,220 +1 @@
/*
* Copyright 2001-2007, Ingo Weinhold, bonefish@users.sf.net. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _AUTO_DELETER_H
#define _AUTO_DELETER_H
/*! Scope-based automatic deletion of objects/arrays.
ObjectDeleter - deletes an object
ArrayDeleter - deletes an array
MemoryDeleter - free()s malloc()ed memory
CObjectDeleter - calls an arbitrary specified destructor function
*/
#include <stdlib.h>
namespace BPrivate {
// AutoDeleter
template<typename C, typename DeleteFunc>
class AutoDeleter {
public:
inline AutoDeleter()
: fObject(NULL)
{
}
inline AutoDeleter(C *object)
: fObject(object)
{
}
inline ~AutoDeleter()
{
fDelete(fObject);
}
inline void SetTo(C *object)
{
if (object != fObject) {
fDelete(fObject);
fObject = object;
}
}
inline void Unset()
{
SetTo(NULL);
}
inline void Delete()
{
SetTo(NULL);
}
inline C *Get() const
{
return fObject;
}
inline C *Detach()
{
C *object = fObject;
fObject = NULL;
return object;
}
protected:
C *fObject;
DeleteFunc fDelete;
};
// ObjectDeleter
template<typename C>
struct ObjectDelete
{
inline void operator()(C *object)
{
delete object;
}
};
template<typename C>
struct ObjectDeleter : AutoDeleter<C, ObjectDelete<C> >
{
ObjectDeleter() : AutoDeleter<C, ObjectDelete<C> >() {}
ObjectDeleter(C *object) : AutoDeleter<C, ObjectDelete<C> >(object) {}
};
// ArrayDeleter
template<typename C>
struct ArrayDelete
{
inline void operator()(C *array)
{
delete[] array;
}
};
template<typename C>
struct ArrayDeleter : AutoDeleter<C, ArrayDelete<C> >
{
ArrayDeleter() : AutoDeleter<C, ArrayDelete<C> >() {}
ArrayDeleter(C *array) : AutoDeleter<C, ArrayDelete<C> >(array) {}
};
// MemoryDeleter
struct MemoryDelete
{
inline void operator()(void *memory)
{
free(memory);
}
};
struct MemoryDeleter : AutoDeleter<void, MemoryDelete >
{
MemoryDeleter() : AutoDeleter<void, MemoryDelete >() {}
MemoryDeleter(void *memory) : AutoDeleter<void, MemoryDelete >(memory) {}
};
// CObjectDeleter
template<typename Type, typename DestructorReturnType>
struct CObjectDelete
{
inline void operator()(Type *object)
{
if (fDestructor != NULL && object != NULL)
fDestructor(object);
}
template<typename Destructor>
inline void operator=(Destructor destructor)
{
fDestructor = destructor;
}
private:
DestructorReturnType (*fDestructor)(Type*);
};
template<typename Type, typename DestructorReturnType = void>
struct CObjectDeleter
: AutoDeleter<Type, CObjectDelete<Type, DestructorReturnType> >
{
typedef AutoDeleter<Type, CObjectDelete<Type, DestructorReturnType> > Base;
template<typename Destructor>
CObjectDeleter(Destructor destructor) : Base()
{
Base::fDelete = destructor;
}
template<typename Destructor>
CObjectDeleter(Type *object, Destructor destructor) : Base(object)
{
Base::fDelete = destructor;
}
};
// MethodDeleter
template<typename Type, typename DestructorReturnType>
struct MethodDelete
{
inline void operator()(Type *object)
{
if (fDestructor && object != NULL)
(object->*fDestructor)();
}
template<typename Destructor>
inline void operator=(Destructor destructor)
{
fDestructor = destructor;
}
private:
DestructorReturnType (Type::*fDestructor)();
};
template<typename Type, typename DestructorReturnType = void>
struct MethodDeleter
: AutoDeleter<Type, MethodDelete<Type, DestructorReturnType> >
{
typedef AutoDeleter<Type, MethodDelete<Type, DestructorReturnType> > Base;
template<typename Destructor>
MethodDeleter(Destructor destructor) : Base()
{
Base::fDelete = destructor;
}
template<typename Destructor>
MethodDeleter(Type *object, Destructor destructor) : Base(object)
{
Base::fDelete = destructor;
}
};
} // namespace BPrivate
using BPrivate::ObjectDeleter;
using BPrivate::ArrayDeleter;
using BPrivate::MemoryDeleter;
using BPrivate::CObjectDeleter;
using BPrivate::MethodDeleter;
#endif // _AUTO_DELETER_H
#include <../private/shared/AutoDeleter.h>
@@ -0,0 +1 @@
#include <../private/shared/AutoLocker.h>
+1 -61
View File
@@ -1,61 +1 @@
/*
* Copyright 2004-2010, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
* Jérôme Duval
* Axel Dörfler, axeld@pinc-software.de.
*/
#ifndef _KEYMAP_H
#define _KEYMAP_H
#include <DataIO.h>
#include <InterfaceDefs.h>
class BKeymap {
public:
BKeymap();
virtual ~BKeymap();
status_t SetTo(const char* path);
status_t SetTo(BDataIO& stream);
status_t SetToCurrent();
status_t SetToDefault();
void Unset();
bool IsModifierKey(uint32 keyCode) const;
uint32 Modifier(uint32 keyCode) const;
uint32 KeyForModifier(uint32 modifier) const;
uint8 ActiveDeadKey(uint32 keyCode,
uint32 modifiers) const;
uint8 DeadKey(uint32 keyCode, uint32 modifiers,
bool* _isEnabled) const;
bool IsDeadSecondKey(uint32 keyCode,
uint32 modifiers,
uint8 activeDeadKey) const;
void GetChars(uint32 keyCode, uint32 modifiers,
uint8 activeDeadKey, char** chars,
int32* numBytes) const;
const key_map& Map() const { return fKeys; }
bool operator==(const BKeymap& other) const;
bool operator!=(const BKeymap& other) const;
BKeymap& operator=(const BKeymap& other);
protected:
int32 Offset(uint32 keyCode, uint32 modifiers,
uint32* _table = NULL) const;
uint8 DeadKeyIndex(int32 offset) const;
protected:
char* fChars;
key_map fKeys;
uint32 fCharsSize;
};
#endif // KEYMAP_H
#include <../private/shared/Keymap.h>
-100
View File
@@ -1,100 +0,0 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// File Name: ObjectLocker.h
// Author(s): Erik Jaesler ([email protected])
// Description: A templatized version of BAutolock. Client class needs to
// supply:
// bool Lock() -- returns whether lock succeeded
// void Unlock() -- unlocks the class
//------------------------------------------------------------------------------
#ifndef OBJECTLOCKER_H
#define OBJECTLOCKER_H
// Standard Includes -----------------------------------------------------------
// System Includes -------------------------------------------------------------
// Project Includes ------------------------------------------------------------
// Local Includes --------------------------------------------------------------
// Local Defines ---------------------------------------------------------------
// Globals ---------------------------------------------------------------------
namespace BPrivate {
template<class T>
class BObjectLocker
{
public:
inline BObjectLocker(T* looper);
inline BObjectLocker(T& locker);
inline ~BObjectLocker();
inline bool IsLocked(void);
private:
T* fLockClient;
bool fIsLocked;
};
template<class T>
BObjectLocker<T>::BObjectLocker(T* client)
: fLockClient(client), fIsLocked(client->Lock())
{
}
template<class T>
BObjectLocker<T>::BObjectLocker(T& client)
: fLockClient(&client), fIsLocked(client.Lock())
{
}
template<class T>
BObjectLocker<T>::~BObjectLocker()
{
if (fIsLocked)
{
fLockClient->Unlock();
}
}
template<class T>
bool BObjectLocker<T>::IsLocked(void)
{
return fIsLocked;
}
} // namespace BPrivate
#endif //OBJECTLOCKER_H
/*
* $Log $
*
* $Id $
*
*/
+1 -94
View File
@@ -1,94 +1 @@
/*
* Copyright 2002-2009, Ingo Weinhold, ingo_weinhold@gmx.de.
* Distributed under the terms of the MIT License.
*/
#ifndef _ELF_H
#define _ELF_H
#include <SupportDefs.h>
// types
typedef uint32 Elf32_Addr;
typedef uint32 Elf32_Off;
typedef uint16 Elf32_Half;
typedef int32 Elf32_Sword;
typedef uint32 Elf32_Word;
typedef uint32 Elf32_Xword;
typedef int32 Elf32_Sxword;
typedef uint64 Elf64_Addr;
typedef uint64 Elf64_Off;
typedef uint16 Elf64_Half;
typedef int32 Elf64_Sword;
typedef uint32 Elf64_Word;
typedef uint64 Elf64_Xword;
typedef int64 Elf64_Sxword;
// e_ident indices
#define EI_MAG0 0
#define EI_MAG1 1
#define EI_MAG2 2
#define EI_MAG3 3
#define EI_CLASS 4
#define EI_DATA 5
#define EI_VERSION 6
#define EI_PAD 7
#define EI_NIDENT 16
// e_ident EI_VERSION values
#define EV_NONE 0
#define EV_CURRENT 1
// e_ident EI_CLASS and EI_DATA values
#define ELFCLASSNONE 0
#define ELFCLASS32 1
#define ELFCLASS64 2
#define ELFDATANONE 0
#define ELFDATA2LSB 1
#define ELFDATA2MSB 2
// p_type
#define PT_NULL 0
#define PT_LOAD 1
#define PT_DYNAMIC 2
#define PT_INTERP 3
#define PT_NOTE 4
#define PT_SHLIB 5
#define PT_PHDIR 6
#define PT_LOPROC 0x70000000
#define PT_HIPROC 0x7fffffff
// sh_type values
#define SHT_NULL 0
#define SHT_PROGBITS 1
#define SHT_SYMTAB 2
#define SHT_STRTAB 3
#define SHT_RELA 4
#define SHT_HASH 5
#define SHT_DYNAMIC 6
#define SHT_NOTE 7
#define SHT_NOBITS 8
#define SHT_REL 9
#define SHT_SHLIB 10
#define SHT_DYNSYM 11
#define SHT_LOPROC 0x70000000
#define SHT_HIPROC 0x7fffffff
#define SHT_LOUSER 0x80000000
#define SHT_HIUSER 0xffffffff
// 32 bit definitions
#undef _ELFX_BITS
#define _ELFX_BITS 32
#include <ElfX.h>
// 64 bit definitions
#undef _ELFX_BITS
#define _ELFX_BITS 64
#include <ElfX.h>
#undef _ELFX_BITS
#endif // _ELF_H
#include <../private/storage/Elf.h>
+1 -68
View File
@@ -1,68 +1 @@
/*
* Copyright 2002-2009, Ingo Weinhold, ingo_weinhold@gmx.de.
* Distributed under the terms of the MIT License.
*/
// No header guard: The file is included twice by <Elf.h> and must not be
// included elsewhere. The _ELFX_BITS macro must be define before inclusion.
#undef ElfX
#if _ELFX_BITS == 32
# define ElfX(x) Elf32_##x
#elif _ELFX_BITS == 64
# define ElfX(x) Elf64_##x
#endif
// object file header
typedef struct {
unsigned char e_ident[EI_NIDENT];
ElfX(Half) e_type;
ElfX(Half) e_machine;
ElfX(Word) e_version;
ElfX(Addr) e_entry;
ElfX(Off) e_phoff;
ElfX(Off) e_shoff;
ElfX(Word) e_flags;
ElfX(Half) e_ehsize;
ElfX(Half) e_phentsize;
ElfX(Half) e_phnum;
ElfX(Half) e_shentsize;
ElfX(Half) e_shnum;
ElfX(Half) e_shstrndx;
} ElfX(Ehdr);
// program header
typedef struct {
ElfX(Word) p_type;
#if _ELFX_BITS == 64
ElfX(Word) p_flags;
#endif
ElfX(Off) p_offset;
ElfX(Addr) p_vaddr;
ElfX(Addr) p_paddr;
ElfX(Xword) p_filesz;
ElfX(Xword) p_memsz;
#if _ELFX_BITS == 32
ElfX(Word) p_flags;
#endif
ElfX(Xword) p_align;
} ElfX(Phdr);
// section header
typedef struct {
ElfX(Word) sh_name;
ElfX(Word) sh_type;
ElfX(Xword) sh_flags;
ElfX(Addr) sh_addr;
ElfX(Off) sh_offset;
ElfX(Xword) sh_size;
ElfX(Word) sh_link;
ElfX(Word) sh_info;
ElfX(Xword) sh_addralign;
ElfX(Xword) sh_entsize;
} ElfX(Shdr);
#undef ElfX
#include <../private/storage/ElfX.h>
+1 -115
View File
@@ -1,115 +1 @@
// Exception
#ifndef _EXCEPTION_H
#define _EXCEPTION_H
#include <stdarg.h>
#include <stdio.h>
#include <String.h>
namespace BPrivate {
namespace Storage {
class Exception {
public:
// constructor
Exception()
: fError(B_OK),
fDescription()
{
}
// constructor
Exception(BString description)
: fError(B_OK),
fDescription(description)
{
}
// constructor
Exception(const char* format,...)
: fError(B_OK),
fDescription()
{
va_list args;
va_start(args, format);
SetTo(B_OK, format, args);
va_end(args);
}
// constructor
Exception(status_t error)
: fError(error),
fDescription()
{
}
// constructor
Exception(status_t error, BString description)
: fError(error),
fDescription(description)
{
}
// constructor
Exception(status_t error, const char* format,...)
: fError(error),
fDescription()
{
va_list args;
va_start(args, format);
SetTo(error, format, args);
va_end(args);
}
// copy constructor
Exception(const Exception& exception)
: fError(exception.fError),
fDescription(exception.fDescription)
{
}
// destructor
~Exception()
{
}
// SetTo
void SetTo(status_t error, BString description)
{
fError = error;
fDescription.SetTo(description);
}
// SetTo
void SetTo(status_t error, const char* format, va_list arg)
{
char buffer[2048];
vsprintf(buffer, format, arg);
SetTo(error, BString(buffer));
}
// GetError
status_t Error() const
{
return fError;
}
// GetDescription
const char* Description() const
{
return fDescription.String();
}
private:
status_t fError;
BString fDescription;
};
}; // namespace Storage
}; // namespace BPrivate
#endif // _EXCEPTION_H
#include <../private/storage/Exception.h>
+1 -46
View File
@@ -1,46 +1 @@
/*
* Copyright 2009-2010, Ingo Weinhold, ingo_weinhold@gmx.de.
* Distributed under the terms of the MIT License.
*/
#ifndef _FILE_IO_H
#define _FILE_IO_H
#include <stdio.h>
#include <DataIO.h>
class BFileIO : public BPositionIO {
public:
BFileIO(FILE* file,
bool takeOverOwnership = false);
virtual ~BFileIO();
virtual ssize_t Read(void *buffer, size_t size);
virtual ssize_t Write(const void *buffer, size_t size);
virtual ssize_t ReadAt(off_t position, void *buffer,
size_t size);
virtual ssize_t WriteAt(off_t position, const void *buffer,
size_t size);
virtual off_t Seek(off_t position, uint32 seekMode);
virtual off_t Position() const;
virtual status_t SetSize(off_t size);
virtual status_t GetSize(off_t* size) const;
private:
BFileIO(const BFileIO& other);
BFileIO& operator=(const BFileIO& other);
off_t _Seek(off_t position, uint32 seekMode) const;
private:
FILE* fFile;
bool fOwnsFile;
};
#endif // _FILE_IO_H
#include <../private/storage/FileIO.h>
+1 -21
View File
@@ -1,21 +1 @@
/*
** Copyright 2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
** Distributed under the terms of the OpenBeOS License.
*/
#ifndef _MIME_TYPES_H
#define _MIME_TYPES_H
#include <Mime.h>
// Additional MIME types that are not defined in Mime.h but are
// standard values. We should move them into a public space some
// day.
#define B_DIRECTORY_MIME_TYPE "application/x-vnd.Be-directory"
#define B_VOLUME_MIME_TYPE "application/x-vnd.Be-volume"
#define B_SYMLINK_MIME_TYPE "application/x-vnd.Be-symlink"
#define B_ROOT_MIME_TYPE "application/x-vnd.Be-root"
#endif /* _MIME_TYPES_H */
#include <../private/storage/MimeTypes.h>
+1 -67
View File
@@ -1,67 +1 @@
//----------------------------------------------------------------------
// This software is part of the OpenBeOS distribution and is covered
// by the OpenBeOS license.
//---------------------------------------------------------------------
/*!
\file OffsetFile.h
OffsetFile interface declaration.
*/
#ifndef _OFFSET_FILE_H
#define _OFFSET_FILE_H
#include <DataIO.h>
#include <File.h>
namespace BPrivate {
namespace Storage {
/*!
\class OffsetFile
\brief Provides access to a file skipping a certain amount of bytes at
the beginning.
This class implements the BPositionIO interface to provide access to the
data of a file past a certain offset. This is very handy e.g. for dealing
with resources, as they always reside at the end of a file, but may start
at arbitrary offsets.
\author <a href='mailto:bonefish@users.sf.net'>Ingo Weinhold</a>
\version 0.0.0
*/
class OffsetFile : public BPositionIO {
public:
OffsetFile();
OffsetFile(BFile *file, off_t offset);
virtual ~OffsetFile();
status_t SetTo(BFile *file, off_t offset);
void Unset();
status_t InitCheck() const;
BFile *File() const;
ssize_t ReadAt(off_t pos, void *buffer, size_t size);
ssize_t WriteAt(off_t pos, const void *buffer,
size_t size);
off_t Seek(off_t position, uint32 seekMode);
off_t Position() const;
status_t SetSize(off_t size);
status_t GetSize(off_t *size) const;
off_t Offset() const;
private:
BFile* fFile;
off_t fOffset;
off_t fCurrentPosition;
};
}; // namespace Storage
}; // namespace BPrivate
#endif // _OFFSET_FILE_H
#include <../private/storage/OffsetFile.h>
+1 -48
View File
@@ -1,48 +1 @@
// Pef.h
#ifndef _PEF_H
#define _PEF_H
#include <SupportDefs.h>
typedef char PefOSType[4];
// container header
struct PEFContainerHeader {
PefOSType tag1;
PefOSType tag2;
PefOSType architecture;
uint32 formatVersion;
uint32 dateTimeStamp;
uint32 oldDefVersion;
uint32 oldImpVersion;
uint32 currentVersion;
uint16 sectionCount;
uint16 instSectionCount;
uint32 reservedA;
};
const char kPEFFileMagic1[4] = { 'J', 'o', 'y', '!' };
const char kPEFFileMagic2[4] = { 'p', 'e', 'f', 'f' };
const char kPEFArchitecturePPC[4] = { 'p', 'w', 'p', 'c' };
const char kPEFContainerHeaderSize = 40;
// section header
struct PEFSectionHeader {
int32 nameOffset;
uint32 defaultAddress;
uint32 totalSize;
uint32 unpackedSize;
uint32 packedSize;
uint32 containerOffset;
uint8 sectionKind;
uint8 shareKind;
uint8 alignment;
uint8 reservedA;
};
const uint32 kPEFSectionHeaderSize = 28;
#endif // _PEF_H
#include <../private/storage/Pef.h>
+1 -162
View File
@@ -1,162 +1 @@
/*
* Copyright 2002-2009, Ingo Weinhold, ingo_weinhold@gmx.de.
* Distributed under the terms of the MIT License.
*/
#ifndef _RESOURCE_FILE_H
#define _RESOURCE_FILE_H
/*!
\file ResourceFile.h
ResourceFile interface declaration.
*/
#include <ByteOrder.h>
#include "OffsetFile.h"
struct resource_info;
struct PEFContainerHeader;
namespace BPrivate {
namespace Storage {
class Exception;
struct MemArea;
class ResourceItem;
struct resource_parse_info;
class ResourcesContainer;
/*!
\class ResourceFile
\brief Represents a file capable of containing resources.
This class provides access to the resources of a file.
Basically a ResourceFile object can be set to a file, load infos for the
resources without loading their data (InitContainer()), read the data of
one (ReadResource()) or all resources (ReadResources()) and write all
resources to the file (WriteResources()).
Note, that the object does only provide the I/O functionality, it does
not store any information about the resources -- this is done via a
ResourcesContainer. We gain flexibility using this approach, since e.g.
a certain resource may be represented by more than one ResourceItem and
we can have as many ResourcesContainers for the resources as we like.
In particular it is nice, that at any time we can write an arbitrary set
of resources to the file.
\author <a href='mailto:bonefish@users.sf.net'>Ingo Weinhold</a>
\version 0.0.0
*/
class ResourceFile {
public:
ResourceFile();
virtual ~ResourceFile();
status_t SetTo(BFile* file, bool clobber = false);
void Unset();
status_t InitCheck() const;
status_t InitContainer(ResourcesContainer& container);
status_t ReadResource(ResourceItem& resource,
bool force = false);
status_t ReadResources(ResourcesContainer& container,
bool force = false);
status_t WriteResources(ResourcesContainer& container);
private:
void _InitFile(BFile& file, bool clobber);
void _InitELFFile(BFile& file);
template<typename ElfHeader, typename ElfProgramHeader,
typename ElfSectionHeader>
void _InitELFXFile(BFile& file, uint64 fileSize);
void _InitPEFFile(BFile& file,
const PEFContainerHeader& pefHeader);
void _ReadHeader(resource_parse_info& parseInfo);
void _ReadIndex(resource_parse_info& parseInfo);
bool _ReadIndexEntry(resource_parse_info& parseInfo,
int32 index, uint32 tableOffset,
bool peekAhead);
void _ReadInfoTable(resource_parse_info& parseInfo);
bool _ReadInfoTableEnd(const void* data,
int32 dataSize);
const void* _ReadResourceInfo(
resource_parse_info& parseInfo,
const MemArea& area,
const resource_info* info, type_code type,
bool* readIndices);
status_t _WriteResources(ResourcesContainer& container);
status_t _MakeEmptyResourceFile();
inline int16 _GetInt(int16 value) const;
inline uint16 _GetInt(uint16 value) const;
inline int32 _GetInt(int32 value) const;
inline uint32 _GetInt(uint32 value) const;
inline int64 _GetInt(int64 value) const;
inline uint64 _GetInt(uint64 value) const;
private:
OffsetFile fFile;
uint32 fFileType;
bool fHostEndianess;
bool fEmptyResources;
};
inline int16
ResourceFile::_GetInt(int16 value) const
{
return fHostEndianess ? value : (int16)B_SWAP_INT16((uint16)value);
}
inline uint16
ResourceFile::_GetInt(uint16 value) const
{
return fHostEndianess ? value : B_SWAP_INT16(value);
}
inline int32
ResourceFile::_GetInt(int32 value) const
{
return fHostEndianess ? value : (int32)B_SWAP_INT32((uint32)value);
}
inline uint32
ResourceFile::_GetInt(uint32 value) const
{
return fHostEndianess ? value : B_SWAP_INT32(value);
}
inline int64
ResourceFile::_GetInt(int64 value) const
{
return fHostEndianess ? value : (int64)B_SWAP_INT64((uint64)value);
}
inline uint64
ResourceFile::_GetInt(uint64 value) const
{
return fHostEndianess ? value : B_SWAP_INT64(value);
}
}; // namespace Storage
}; // namespace BPrivate
#endif // _RESOURCE_FILE_H
#include <../private/storage/ResourceFile.h>
+1 -91
View File
@@ -1,91 +1 @@
//----------------------------------------------------------------------
// This software is part of the OpenBeOS distribution and is covered
// by the OpenBeOS license.
//---------------------------------------------------------------------
/*!
\file ResourcesItem.h
ResourceItem interface declaration.
*/
#ifndef _RESOURCE_ITEM_H
#define _RESOURCE_ITEM_H
#include <DataIO.h>
#include <String.h>
namespace BPrivate {
namespace Storage {
/*!
\class ResourceItem
\brief Represents a resource loaded into memory.
This class represents a resource completely or partially loaded into
memory. The minimal information stored in the object should be its
type, ID and name and the size of its data. If the data are not loaded
then additionally the offset (into a resource file) should be valid.
As soon as the data are loaded as well, the offset is more or less
meaningless.
Creating a new resource can be done by calling SetIdentity() after the
default construction. The object then represents a resource with the
specified type, ID and name and with empty data. Data can arbitrarily
be read and written using the methods the super class BMallocIO provides.
The memory for the resource data is owned by the ResourceItem object and
freed on destruction.
\author <a href='mailto:bonefish@users.sf.net'>Ingo Weinhold</a>
\version 0.0.0
*/
class ResourceItem : public BMallocIO {
public:
ResourceItem();
virtual ~ResourceItem();
virtual ssize_t WriteAt(off_t pos, const void *buffer, size_t size);
virtual status_t SetSize(off_t size);
void SetLocation(int32 offset, size_t initialSize);
void SetIdentity(type_code type, int32 id, const char *name);
void SetOffset(int32 offset);
int32 Offset() const;
size_t InitialSize() const;
size_t DataSize() const;
void SetType(type_code type);
type_code Type() const;
void SetID(int32 id);
int32 ID() const;
void SetName(const char *name);
const char *Name() const;
void *Data() const;
void SetLoaded(bool loaded);
bool IsLoaded() const;
void SetModified(bool modified);
bool IsModified() const;
private:
int32 fOffset;
size_t fInitialSize;
type_code fType;
int32 fID;
BString fName;
bool fIsLoaded;
bool fIsModified;
};
}; // namespace Storage
}; // namespace BPrivate
#endif // _RESOURCE_ITEM_H
#include <../private/storage/ResourceItem.h>
@@ -1,79 +1 @@
//----------------------------------------------------------------------
// This software is part of the OpenBeOS distribution and is covered
// by the OpenBeOS license.
//---------------------------------------------------------------------
/*!
\file ResourcesContainer.h
ResourcesContainer interface declaration.
*/
#ifndef _RESOURCES_CONTAINER_H
#define _RESOURCES_CONTAINER_H
#include <List.h>
namespace BPrivate {
namespace Storage {
class ResourceItem;
/*!
\class ResourcesContainer
\brief Represents a collection of resources.
This class can be used to manage a collection of resources represented
by ResourceItem's. Usually it does never contain two resources with the
same type \em and ID, since AddResource() replaces an old item with the
new one, unless explicitly told not to do so. This should only be done
by ResourceFile, when type and ID of the items are not yet known.
Asside from the basic vector features like Add/RemoveResource()/
ResourceAt() and MakeEmpty() a bunch of IndexOf() methods are provided
and AssimilateResources() which incorporates all resources of another
container into this one (replacing old resources, if necessary), emptying
the other one.
The ResourceItem's in a container are deleted on destruction, unless
removed before via RemoveResource(). MakeEmpty() deletes the items as
well.
\author <a href='mailto:bonefish@users.sf.net'>Ingo Weinhold</a>
\version 0.0.0
*/
class ResourcesContainer {
public:
ResourcesContainer();
virtual ~ResourcesContainer();
bool AddResource(ResourceItem *item, int32 index = -1,
bool replace = true);
ResourceItem *RemoveResource(int32 index);
bool RemoveResource(ResourceItem *item);
void MakeEmpty();
void AssimilateResources(ResourcesContainer &container);
int32 IndexOf(ResourceItem *item) const;
int32 IndexOf(const void *data) const;
int32 IndexOf(type_code type, int32 id) const;
int32 IndexOf(type_code type, const char *name) const;
int32 IndexOfType(type_code type, int32 index) const;
ResourceItem *ResourceAt(int32 index) const;
int32 CountResources() const;
void SetModified(bool modified);
bool IsModified() const;
private:
BList fResources;
bool fIsModified;
};
}; // namespace Storage
}; // namespace BPrivate
#endif // _RESOURCES_CONTAINER_H
#include <../private/storage/ResourcesContainer.h>
+1 -107
View File
@@ -1,107 +1 @@
// ResourcesDefs.h
#ifndef _DEF_RESOURCES_H
#define _DEF_RESOURCES_H
#include <SupportDefs.h>
// x86 resource file constants
const char kX86ResourceFileMagic[4] = { 'R', 'S', 0, 0 };
const uint32 kX86ResourcesOffset = 0x00000004;
// PPC resource file constants
const char kPPCResourceFileMagic[4] = { 'r', 'e', 's', 'f' };
const uint32 kPPCResourcesOffset = 0x00000028;
// ELF file related constants
const uint32 kELFMinResourceAlignment = 32;
// the unused data pattern
const uint32 kUnusedResourceDataPattern[3] = {
0xffffffff, 0x000003e9, 0x00000000
};
// the resources header
struct resources_header {
uint32 rh_resources_magic;
uint32 rh_resource_count;
uint32 rh_index_section_offset;
uint32 rh_admin_section_size;
uint32 rh_pad[13];
};
const uint32 kResourcesHeaderMagic = 0x444f1000;
const uint32 kResourceIndexSectionOffset = 0x00000044;
const uint32 kResourceIndexSectionAlignment = 0x00000600;
const uint32 kResourcesHeaderSize = 68;
// the header of the index section
struct resource_index_section_header {
uint32 rish_index_section_offset;
uint32 rish_index_section_size;
uint32 rish_unused_data1;
uint32 rish_unknown_section_offset;
uint32 rish_unknown_section_size;
uint32 rish_unused_data2[25];
uint32 rish_info_table_offset;
uint32 rish_info_table_size;
uint32 rish_unused_data3;
};
const uint32 kUnknownResourceSectionSize = 0x00000168;
const uint32 kResourceIndexSectionHeaderSize = 132;
// an entry of the index table
struct resource_index_entry {
uint32 rie_offset;
uint32 rie_size;
uint32 rie_pad;
};
const uint32 kResourceIndexEntrySize = 12;
// a resource info
struct resource_info {
int32 ri_id;
int32 ri_index;
uint16 ri_name_size;
char ri_name[1];
};
const uint32 kMinResourceInfoSize = 10;
// a resource info block
struct resource_info_block {
type_code rib_type;
resource_info rib_info[1];
};
const uint32 kMinResourceInfoBlockSize = 4 + kMinResourceInfoSize;
// the structure separating resource info blocks
struct resource_info_separator {
uint32 ris_value1;
uint32 ris_value2;
};
const uint32 kResourceInfoSeparatorSize = 8;
// the end of the info table
struct resource_info_table_end {
uint32 rite_check_sum;
uint32 rite_terminator;
};
const uint32 kResourceInfoTableEndSize = 8;
#endif // _DEF_RESOURCES_H
#include <../private/storage/ResourcesDefs.h>
+1 -146
View File
@@ -1,146 +1 @@
//----------------------------------------------------------------------
// This software is part of the OpenBeOS distribution and is covered
// by the OpenBeOS license.
//---------------------------------------------------------------------
/*!
\file storage_support.h
Interface declarations for miscellaneous internal
Storage Kit support functions.
*/
#ifndef _STORAGE_SUPPORT_H
#define _STORAGE_SUPPORT_H
#include <dirent.h>
#include <string>
namespace BPrivate {
namespace Storage {
// For convenience:
struct LongDirEntry : dirent { char _buffer[B_FILE_NAME_LENGTH]; };
//! Returns whether the supplied path is absolute.
bool is_absolute_path(const char *path);
status_t parse_path(const char *fullPath, int &dirEnd, int &leafStart,
int &leafEnd);
status_t parse_path(const char *fullPath, char *dirPath, char *leaf);
//! splits a path name into directory path and leaf name
status_t split_path(const char *fullPath, char *&path, char *&leaf);
//! splits a path name into directory path and leaf name
status_t split_path(const char *fullPath, char **path, char **leaf);
//! Parses the first component of a path name.
status_t parse_first_path_component(const char *path, int32& length,
int32& nextComponent);
//! Parses the first component of a path name.
status_t parse_first_path_component(const char *path, char *&component,
int32& nextComponent);
//! Checks whether an entry name is a valid entry name.
status_t check_entry_name(const char *entry);
//! Checks whether a path name is a valid path name.
status_t check_path_name(const char *path);
/*! \brief Returns a copy of \c str in which all alphabetic characters
are lowercase.
Returns \c "(null)" if you're a bonehead and pass in a \c NULL pointer.
*/
std::string to_lower(const char *str);
/*! \brief Places a copy of \c str in \c result in which all alphabetic
characters are lowercase.
Returns \c "(null)" if you're a bonehead and pass in a \c NULL pointer.
*/
void to_lower(const char *str, std::string &result);
/*! \brief Copies \c str into \c result, converting any uppercase alphabetics
to lowercase.
\a str and \a result may point to the same string. \a result is
assumed to be as long as or longer than \a str.
*/
void to_lower(const char *str, char *result);
//! Converts \c str to lowercase.
void to_lower(char *str);
/*! \brief Escapes any whitespace or other special characters in the path
\a result must be large enough to accomodate the addition of
escape sequences to \a str. \a str and \a result may *NOT* point to
the same string.
Note that this function was designed for use with the registrar's
RecentEntries class, and may not create escapes exactly like you're
hoping. Please double check the code for the function to see if this
is the case.
*/
void escape_path(const char *str, char *result);
/*! \brief Escapes any whitespace or other special characters in the path
\a str must be large enough to accomodate the addition of
escape sequences.
*/
void escape_path(char *str);
/*! \brief Returns whether the supplied device ID refers to the root FS.
*/
bool device_is_root_device(dev_t device);
// FDCloser
class FDCloser {
public:
FDCloser(int fd)
: fFD(fd)
{
}
~FDCloser()
{
Close();
}
void SetTo(int fd)
{
Close();
fFD = fd;
}
// implemented in the source file to not expose syscalls to the unit tests
// which include this file too
void Close();
// void Close()
// {
// if (fFD >= 0)
// _kern_close(fFD);
// fFD = -1;
// }
int Detach()
{
int fd = fFD;
fFD = -1;
return fd;
}
private:
int fFD;
};
}; // namespace Storage
}; // namespace BPrivate
using BPrivate::Storage::FDCloser;
#endif // _STORAGE_SUPPORT_H
#include <../private/storage/storage_support.h>