* Rewrote headers as necessary; only Errors.h and Debug.h still originate from a Be header now;

feel free to change that ;-)
* Cleaned up existing headers.
* Coding style guide update to BBufferIO (renamed m_* members to f*).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19972 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2007-01-26 16:36:29 +00:00
parent 03d79ead32
commit 087882c26e
16 changed files with 589 additions and 791 deletions
+27 -73
View File
@@ -1,97 +1,51 @@
//------------------------------------------------------------------------------ /*
// Copyright (c) 2001-2002, OpenBeOS * Copyright 2001-2007, Haiku, Inc. All Rights Reserved.
// * Distributed under the terms of the MIT License.
// 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: Archivable.h
// Author: Erik Jaesler ([email protected])
// Description: BArchivable mix-in class defines the archiving
// protocol. Also some global archiving functions.
//------------------------------------------------------------------------------
#ifndef _ARCHIVABLE_H #ifndef _ARCHIVABLE_H
#define _ARCHIVABLE_H #define _ARCHIVABLE_H
// Standard Includes -----------------------------------------------------------
// System Includes -------------------------------------------------------------
#include <BeBuild.h> #include <BeBuild.h>
#include <image.h> #include <image.h>
#include <SupportDefs.h> #include <SupportDefs.h>
// Project Includes ------------------------------------------------------------
// Local Includes --------------------------------------------------------------
// Local Defines ---------------------------------------------------------------
// Globals ---------------------------------------------------------------------
class BMessage; class BMessage;
// BArchivable class -----------------------------------------------------------
class BArchivable { class BArchivable {
public: public:
BArchivable(); BArchivable(BMessage* from);
virtual ~BArchivable(); BArchivable();
virtual ~BArchivable();
BArchivable(BMessage* from); virtual status_t Archive(BMessage* into, bool deep = true) const;
virtual status_t Archive(BMessage* into, bool deep = true) const; static BArchivable* Instantiate(BMessage* archive);
static BArchivable *Instantiate(BMessage* from);
// Private or reserved --------------------------------------------------------- // Private or reserved
virtual status_t Perform(perform_code d, void* arg); virtual status_t Perform(perform_code d, void* arg);
private: private:
virtual void _ReservedArchivable1();
virtual void _ReservedArchivable2();
virtual void _ReservedArchivable3();
virtual void _ReservedArchivable1(); uint32 _reserved[2];
virtual void _ReservedArchivable2();
virtual void _ReservedArchivable3();
uint32 _reserved[2];
}; };
// Global Functions ------------------------------------------------------------ // global functions
typedef BArchivable* (*instantiation_func) (BMessage *); typedef BArchivable* (*instantiation_func)(BMessage*);
_IMPEXP_BE BArchivable* instantiate_object(BMessage *from, image_id *id); BArchivable* instantiate_object(BMessage *from, image_id *id);
_IMPEXP_BE BArchivable* instantiate_object(BMessage *from); BArchivable* instantiate_object(BMessage *from);
_IMPEXP_BE bool validate_instantiation(BMessage* from, bool validate_instantiation(BMessage* from, const char* className);
const char* class_name);
_IMPEXP_BE instantiation_func find_instantiation_func(const char* class_name,
const char* sig);
_IMPEXP_BE instantiation_func find_instantiation_func(const char* class_name);
_IMPEXP_BE instantiation_func find_instantiation_func(BMessage* archive_data);
//------------------------------------------------------------------------------
instantiation_func find_instantiation_func(const char* className,
const char* signature);
instantiation_func find_instantiation_func(const char* className);
instantiation_func find_instantiation_func(BMessage* archive);
#endif // _ARCHIVABLE_H #endif // _ARCHIVABLE_H
/*
* $Log $
*
* $Id $
*
*/
+35 -46
View File
@@ -1,79 +1,68 @@
// /*
// $Id: Autolock.h 3246 2003-05-14 17:21:46Z haydentech $ * Copyright 2001-2007, Haiku, Inc. All Rights Reserved.
// * Distributed under the terms of the MIT License.
// This is the BAutolock interface for OpenBeOS. It has been created to */
// be source and binary compatible with the BeOS version of BAutolock. #ifndef _SUPPORT_AUTOLOCK_H
// To that end, all members are inline just as with the BeOS version. #define _SUPPORT_AUTOLOCK_H
//
#ifndef _OPENBEOS_AUTOLOCK_H
#define _OPENBEOS_AUTOLOCK_H
#include <Locker.h> #include <Locker.h>
#include <Looper.h> #include <Looper.h>
#ifdef USE_OPENBEOS_NAMESPACE
namespace OpenBeOS {
#endif
class BAutolock { class BAutolock {
public: public:
inline BAutolock(BLooper *looper); inline BAutolock(BLooper *looper);
inline BAutolock(BLocker *locker); inline BAutolock(BLocker *locker);
inline BAutolock(BLocker &locker); inline BAutolock(BLocker &locker);
inline ~BAutolock();
inline ~BAutolock();
inline bool IsLocked(void);
private: inline bool IsLocked(void);
BLocker *fTheLocker;
BLooper *fTheLooper; private:
bool fIsLocked; BLocker *fLocker;
BLooper *fLooper;
bool fIsLocked;
}; };
inline BAutolock::BAutolock(BLooper *looper) : inline
fTheLocker(NULL), fTheLooper(looper), fIsLocked(looper->Lock()) BAutolock::BAutolock(BLooper *looper)
: fLocker(NULL), fLooper(looper), fIsLocked(looper->Lock())
{ {
} }
inline BAutolock::BAutolock(BLocker *locker) : inline
fTheLocker(locker), fTheLooper(NULL), fIsLocked(locker->Lock()) BAutolock::BAutolock(BLocker *locker)
: fLocker(locker), fLooper(NULL), fIsLocked(locker->Lock())
{ {
} }
inline BAutolock::BAutolock(BLocker &locker) : inline
fTheLocker(&locker), fTheLooper(NULL), fIsLocked(locker.Lock()) BAutolock::BAutolock(BLocker &locker)
: fLocker(&locker), fLooper(NULL), fIsLocked(locker.Lock())
{ {
} }
inline BAutolock::~BAutolock() inline
BAutolock::~BAutolock()
{ {
if (fIsLocked) { if (fIsLocked) {
if (fTheLooper != NULL) { if (fLooper != NULL)
fTheLooper->Unlock(); fLooper->Unlock();
} else { else
fTheLocker->Unlock(); fLocker->Unlock();
}
} }
} }
inline bool BAutolock::IsLocked() inline bool
BAutolock::IsLocked()
{ {
return fIsLocked; return fIsLocked;
} }
#endif // _SUPPORT_AUTOLOCK_H
#ifdef USE_OPENBEOS_NAMESPACE
}
#endif
#endif // _OPENBEOS_LOCKER_H
+12 -19
View File
@@ -1,29 +1,22 @@
/****************************************************************************** /*
/ * Copyright 2007, Haiku, Inc. All Rights Reserved.
/ File: Beep.h * Distributed under the terms of the MIT License.
/ */
/ Description: System beep function.
/
/ Copyright 1993-98, Be Incorporated
/
******************************************************************************/
#ifndef _BEEP_H #ifndef _BEEP_H
#define _BEEP_H #define _BEEP_H
#include <BeBuild.h> #include <BeBuild.h>
#include <SupportDefs.h> #include <SupportDefs.h>
_IMPEXP_BE status_t beep(); #ifdef __cplusplus
_IMPEXP_BE status_t system_beep(const char * event_name); // These functions are only exported for C++
status_t beep();
status_t system_beep(const char* eventName);
status_t add_system_beep_event(const char* eventName, uint32 flags = 0);
#if defined(__cplusplus)
#define _BEEP_FLAGS = 0
#else
#define _BEEP_FLAGS
#endif #endif
_IMPEXP_BE status_t add_system_beep_event(const char * event_name, uint32 flags _BEEP_FLAGS);
#endif // _BEEP_H
#endif /* _BEEP_H */
+24 -33
View File
@@ -22,52 +22,43 @@
#ifndef _BLOCK_CACHE_H #ifndef _BLOCK_CACHE_H
#define _BLOCK_CACHE_H #define _BLOCK_CACHE_H
#include <BeBuild.h> #include <BeBuild.h>
#include <Locker.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 // The allocation type to be used in the constructor
*/
enum { enum {
B_OBJECT_CACHE = 0, B_OBJECT_CACHE = 0,
B_MALLOC_CACHE = 1 B_MALLOC_CACHE = 1
}; };
/* The BBlockCache class: class BBlockCache {
*/ public:
class BBlockCache BBlockCache(uint32 blockCount, size_t blockSize,
{ uint32 allocationType);
public: virtual ~BBlockCache();
BBlockCache(uint32 blockCount,
size_t blockSize,
uint32 allocationType);
virtual ~BBlockCache();
void * Get(size_t blockSize); void* Get(size_t blockSize);
void Save(void *pointer, size_t blockSize); void Save(void *pointer, size_t blockSize);
/* Private or reserved functions and data private:
*/ virtual void _ReservedBlockCache1();
private: virtual void _ReservedBlockCache2();
virtual void _ReservedBlockCache1();
virtual void _ReservedBlockCache2();
BBlockCache(const BBlockCache &); BBlockCache(const BBlockCache &);
BBlockCache &operator=(const BBlockCache &); BBlockCache &operator=(const BBlockCache &);
struct _FreeBlock; struct _FreeBlock;
_FreeBlock *fFreeList; _FreeBlock* fFreeList;
size_t fBlockSize; size_t fBlockSize;
int32 fFreeBlocks; int32 fFreeBlocks;
int32 fBlockCount; int32 fBlockCount;
BLocker fLocker; BLocker fLocker;
void * (*fAlloc)(size_t size); void* (*fAlloc)(size_t size);
void (*fFree)(void *pointer); void (*fFree)(void *pointer);
uint32 _reserved[2]; uint32 _reserved[2];
}; };
#endif #endif // _BLOCK_CACHE_H
+33 -57
View File
@@ -1,73 +1,49 @@
/****************************************************************************** /*
/ * Copyright 2007, Haiku, Inc. All Rights Reserved.
/ File: BufferIO.h * Distributed under the terms of the MIT License.
/ */
/ Description: A buffered adapter for BPositionIO #ifndef _BUFFER_IO_H
/
/ Copyright 1998, Be Incorporated
/
******************************************************************************/
#if !defined(_BUFFER_IO_H)
#define _BUFFER_IO_H #define _BUFFER_IO_H
#include <DataIO.h> #include <DataIO.h>
class BBufferIO : public BPositionIO
{
public:
enum {
DEFAULT_BUF_SIZE = 65536L
};
BBufferIO( class BBufferIO : public BPositionIO {
BPositionIO * stream, public:
size_t buf_size = DEFAULT_BUF_SIZE, BBufferIO(BPositionIO* stream, size_t bufferSize = 65536L,
bool owns_stream = true); bool ownsStream = true);
virtual ~BBufferIO(); virtual ~BBufferIO();
virtual ssize_t ReadAt( virtual ssize_t ReadAt(off_t pos, void* buffer, size_t size);
off_t pos, virtual ssize_t WriteAt(off_t pos, const void* buffer, size_t size);
void *buffer, virtual off_t Seek(off_t position, uint32 seekMode);
size_t size); virtual off_t Position() const;
virtual ssize_t WriteAt( virtual status_t SetSize(off_t size);
off_t pos, virtual status_t Flush();
const void *buffer, BPositionIO* Stream() const;
size_t size);
virtual off_t Seek(
off_t position,
uint32 seek_mode);
virtual off_t Position() const;
virtual status_t SetSize(
off_t size);
virtual status_t Flush();
BPositionIO * Stream() const;
size_t BufferSize() const; size_t BufferSize() const;
bool OwnsStream() const; bool OwnsStream() const;
void SetOwnsStream( void SetOwnsStream(bool ownsStream);
bool owns_stream);
void PrintToStream() const; void PrintToStream() const;
private: private:
virtual status_t _Reserved_BufferIO_0(void*);
virtual status_t _Reserved_BufferIO_1(void*);
virtual status_t _Reserved_BufferIO_2(void*);
virtual status_t _Reserved_BufferIO_3(void*);
virtual status_t _Reserved_BufferIO_4(void*);
off_t m_buffer_start; off_t fBufferStart;
BPositionIO * m_stream; BPositionIO* fStream;
char * m_buffer; char* fBuffer;
size_t m_buffer_phys; size_t fBufferSize;
size_t m_buffer_used; size_t fBufferUsed;
uint32 _reserved_ints[6]; uint32 _reserved_ints[6];
bool m_buffer_dirty; bool fBufferIsDirty;
bool m_owns_stream; bool fOwnsStream;
bool _reserved_bools[6]; bool _reserved_bools[6];
virtual status_t _Reserved_BufferIO_0(void *);
virtual status_t _Reserved_BufferIO_1(void *);
virtual status_t _Reserved_BufferIO_2(void *);
virtual status_t _Reserved_BufferIO_3(void *);
virtual status_t _Reserved_BufferIO_4(void *);
}; };
#endif // _BUFFER_IO_H
#endif /* _BUFFER_IO_H */
+104 -116
View File
@@ -1,21 +1,19 @@
// Modified BeOS header. Just here to be able to compile and test BResources. /*
// To be replaced by the OpenBeOS version to be provided by the IK Team. * Copyright 2007, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _BYTEORDER_H
#define _BYTEORDER_H
#ifndef _sk_byte_order_h_
#define _sk_byte_order_h_
#include <BeBuild.h> #include <BeBuild.h>
#include <endian.h> #include <endian.h>
#include <SupportDefs.h> #include <SupportDefs.h>
#include <TypeConstants.h> /* For convenience */ #include <TypeConstants.h>
// for convenience
#ifdef __cplusplus
extern "C" {
#endif
/*----------------------------------------------------------------------*/
/*------- Swap-direction constants, and swapping functions -------------*/
// swap directions
typedef enum { typedef enum {
B_SWAP_HOST_TO_LENDIAN, B_SWAP_HOST_TO_LENDIAN,
B_SWAP_HOST_TO_BENDIAN, B_SWAP_HOST_TO_BENDIAN,
@@ -24,121 +22,111 @@ typedef enum {
B_SWAP_ALWAYS B_SWAP_ALWAYS
} swap_action; } swap_action;
extern status_t swap_data(type_code type, void *data, size_t length,
swap_action action);
extern bool is_type_swapped(type_code type); // BSD/networking macros
#ifndef htonl
# define htonl(x) B_HOST_TO_BENDIAN_INT32(x)
/*-----------------------------------------------------------------------*/ # define ntohl(x) B_BENDIAN_TO_HOST_INT32(x)
/*----- Private implementations -----------------------------------------*/ # define htons(x) B_HOST_TO_BENDIAN_INT16(x)
extern double __swap_double(double arg); # define ntohs(x) B_BENDIAN_TO_HOST_INT16(x)
extern float __swap_float(float arg); #endif
extern uint64 __swap_int64(uint64 uarg);
extern uint32 __swap_int32(uint32 uarg);
extern uint16 __swap_int16(uint16 uarg);
/*-------------------------------------------------------------*/
// always swap macros
/*-------------------------------------------------------------*/
/*--------- Host is Little --------------------------------------*/
#if BYTE_ORDER == __LITTLE_ENDIAN
#define B_HOST_IS_LENDIAN 1
#define B_HOST_IS_BENDIAN 0
/*--------- Host Native -> Little --------------------*/
#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)
/*--------- Host Native -> Big ------------------------*/
#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)
/*--------- Little -> 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)
/*--------- Big -> 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 /* __LITTLE_ENDIAN */
/*-------------------------------------------------------------*/
/*--------- Host is Big --------------------------------------*/
#define B_HOST_IS_LENDIAN 0
#define B_HOST_IS_BENDIAN 1
/*--------- Host Native -> Little -------------------*/
#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)
/*--------- Host Native -> Big ------------------------*/
#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)
/*--------- Little -> 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)
/*--------- Big -> 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 /* __LITTLE_ENDIAN */
/*-------------------------------------------------------------*/
/*--------- Just-do-it macros ---------------------------------*/
#define B_SWAP_DOUBLE(arg) __swap_double(arg) #define B_SWAP_DOUBLE(arg) __swap_double(arg)
#define B_SWAP_FLOAT(arg) __swap_float(arg) #define B_SWAP_FLOAT(arg) __swap_float(arg)
#define B_SWAP_INT64(arg) __swap_int64(arg) #define B_SWAP_INT64(arg) __swap_int64(arg)
#define B_SWAP_INT32(arg) __swap_int32(arg) #define B_SWAP_INT32(arg) __swap_int32(arg)
#define B_SWAP_INT16(arg) __swap_int16(arg) #define B_SWAP_INT16(arg) __swap_int16(arg)
#if BYTE_ORDER == __LITTLE_ENDIAN
// Host is little endian
/*-------------------------------------------------------------*/ #define B_HOST_IS_LENDIAN 1
/*---------Berkeley macros -----------------------------------*/ #define B_HOST_IS_BENDIAN 0
#ifndef htonl /* avoid collision with <netinet/in.h> */
#define htonl(x) B_HOST_TO_BENDIAN_INT32(x) // Host native to little endian
#define ntohl(x) B_BENDIAN_TO_HOST_INT32(x) #define B_HOST_TO_LENDIAN_DOUBLE(arg) (double)(arg)
#define htons(x) B_HOST_TO_BENDIAN_INT16(x) #define B_HOST_TO_LENDIAN_FLOAT(arg) (float)(arg)
#define ntohs(x) B_BENDIAN_TO_HOST_INT16(x) #define B_HOST_TO_LENDIAN_INT64(arg) (uint64)(arg)
#endif #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 #ifdef __cplusplus
} }
#endif /* __cplusplus */ #endif
/*-------------------------------------------------------------*/ #endif // _BYTEORDER_H
/*-------------------------------------------------------------*/
#endif // _sk_byte_order_h_
+16 -30
View File
@@ -1,38 +1,24 @@
/****************************************************************************** /*
/ * Copyright 2007, Haiku, Inc. All Rights Reserved.
/ File: ClassInfo.h * Distributed under the terms of the MIT License.
/ */
/ Description: C++ class identification and casting macros
/
/ Copyright 1993-98, Be Incorporated
/
******************************************************************************/
#ifndef _CLASS_INFO_H #ifndef _CLASS_INFO_H
#define _CLASS_INFO_H #define _CLASS_INFO_H
#include <typeinfo> #include <typeinfo>
// deprecated, use standard RTTI calls instead // deprecated, use standard RTTI calls instead
// TODO: maybe get rid of this header completely?
#ifdef USE_OPENBEOS_NAMESPACE #define class_name(object) \
namespace OpenBeOS { ((typeid(*(object))).name())
#endif #define cast_as(object, class) \
(dynamic_cast<class*>(object))
/*-------------------------------------------------------------*/ #define is_kind_of(object, class) \
/*--------- Class Info Macros ---------------------------------*/ (dynamic_cast<class*>(object) != NULL)
#define is_instance_of(object, class) \
#define class_name(ptr) ((typeid(*(ptr))).name()) (typeid(*(object)) == typeid(class))
#define cast_as(ptr, class) (dynamic_cast<class*>(ptr))
#define is_kind_of(ptr, class) (cast_as(ptr, class) != 0)
#define is_instance_of(ptr, class) (typeid(*(ptr)) == typeid(class))
/*-------------------------------------------------------------*/ #endif // _CLASS_INFO_H
/*-------------------------------------------------------------*/
#ifdef USE_OPENBEOS_NAMESPACE
} // namespace OpenBeOS
using namespace OpenBeOS;
#endif
#endif /* _CLASS_INFO_H */
+19 -26
View File
@@ -1,36 +1,29 @@
// 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. * Copyright 2007, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _FLATTENABLE_H
#define _FLATTENABLE_H
#ifndef __sk_flattenable_h__
#define __sk_flattenable_h__
#include <SupportDefs.h> #include <SupportDefs.h>
/*-------------------------------------------------------------*/
/*----- BFlattenable class ------------------------------------*/
class BFlattenable { class BFlattenable {
public: 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 code, const void* buffer, ssize_t size) = 0;
virtual bool IsFixedSize() const = 0; virtual ~BFlattenable();
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:
void _ReservedFlattenable1();
/*----- Private or reserved ---------------*/ virtual void _ReservedFlattenable2();
virtual void _ReservedFlattenable3();
private:
void _ReservedFlattenable1();
virtual void _ReservedFlattenable2();
virtual void _ReservedFlattenable3();
}; };
/*-------------------------------------------------------------*/ #endif // _FLATTENABLE_H
/*-------------------------------------------------------------*/
#endif // __sk_flattenable_h__
+54 -83
View File
@@ -1,98 +1,69 @@
//------------------------------------------------------------------------------ /*
// Copyright (c) 2001-2002, OpenBeOS * Copyright 2001-2007, Haiku, Inc. All Rights Reserved.
// * Distributed under the terms of the MIT License.
// 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 #ifndef _BE_LIST_H
#define _BE_LIST_H #define _BE_LIST_H
#include <SupportDefs.h> #include <SupportDefs.h>
/*----- BList class --------------------------------------*/
class BList { class BList {
public:
BList(int32 count = 20);
BList(const BList& anotherList);
virtual ~BList();
public: BList& operator =(const BList &);
BList(int32 count = 20);
BList(const BList& anotherList);
virtual ~BList();
BList& operator =(const BList &); /* Adding and removing items. */
bool AddItem(void* item, int32 index);
/* Adding and removing items. */ bool AddItem(void* item);
bool AddItem(void *item, int32 index); bool AddList(const BList* list, int32 index);
bool AddItem(void *item); bool AddList(const BList* list);
bool AddList(const BList *list, int32 index); bool RemoveItem(void* item);
bool AddList(const BList *list); void* RemoveItem(int32 index);
bool RemoveItem(void *item); bool RemoveItems(int32 index, int32 count);
void *RemoveItem(int32 index); bool ReplaceItem(int32 index, void* newItem);
bool RemoveItems(int32 index, int32 count); void MakeEmpty();
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. */ // Reorder items
void *ItemAt(int32 index) const; void SortItems(int (*compareFunc)(const void*, const void*));
void *FirstItem() const; bool SwapItems(int32 indexA, int32 indexB);
bool MoveItem(int32 fromIndex, int32 toIndex);
/* 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. */ // Retrieve items
bool HasItem(void *item) const; void* ItemAt(int32 index) const;
int32 IndexOf(void *item) const; void* FirstItem() const;
int32 CountItems() const; void* ItemAtFast(int32) const;
bool IsEmpty() const; // does not check the array bounds!
/* 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 void* LastItem() const;
bool Resize(int32 count); void* Items() const;
private: // Query
void** fObjectList; bool HasItem(void* item) const;
size_t fPhysicalSize; int32 IndexOf(void* item) const;
int32 fItemCount; int32 CountItems() const;
int32 fBlockSize; bool IsEmpty() const;
uint32 _reserved[2];
// Iteration
void DoForEach(bool (*func)(void* item));
void DoForEach(bool (*func)(void* item, void* arg2), void *arg2);
private:
virtual void _ReservedList1();
virtual void _ReservedList2();
bool Resize(int32 count);
private:
void** fObjectList;
size_t fPhysicalSize;
int32 fItemCount;
int32 fBlockSize;
uint32 _reserved[2];
}; };
#endif // _BE_LIST_H #endif // _BE_LIST_H
+30 -49
View File
@@ -1,62 +1,43 @@
// /*
// $Id: Locker.h 10 2002-07-09 12:24:59Z ejakowatz $ * Copyright 2001-2007, Haiku, Inc. All Rights Reserved.
// * Distributed under the terms of the MIT License.
// This is the BLocker interface for OpenBeOS. It has been created to */
// be source and binary compatible with the BeOS version of BLocker. #ifndef _LOCKER_H
// #define _LOCKER_H
#ifndef _OPENBEOS_LOCKER_H
#define _OPENBEOS_LOCKER_H
#include <OS.h> #include <OS.h>
#include <SupportDefs.h>
#ifdef USE_OPENBEOS_NAMESPACE
namespace OpenBeOS {
#endif
class BLocker { class BLocker {
public: public:
BLocker(); BLocker();
BLocker(const char *name); BLocker(const char* name);
BLocker(bool benaphore_style); BLocker(bool benaphoreStyle);
BLocker(const char *name, bool benaphore_style); BLocker(const char* name, bool benaphoreStyle);
virtual ~BLocker();
// 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);
bool Lock(void); thread_id LockingThread(void) const;
status_t LockWithTimeout(bigtime_t timeout); bool IsLocked(void) const;
void Unlock(void); int32 CountLocks(void) const;
int32 CountLockRequests(void) const;
sem_id Sem(void) const;
thread_id LockingThread(void) const; private:
bool IsLocked(void) const; BLocker(const char *name, bool benaphoreStyle, bool);
int32 CountLocks(void) const; void InitLocker(const char *name, bool benaphore_style);
int32 CountLockRequests(void) const; bool AcquireLock(bigtime_t timeout, status_t *error);
sem_id Sem(void) const;
private: int32 fBenaphoreCount;
void InitLocker(const char *name, bool benaphore_style); sem_id fSemaphoreID;
bool AcquireLock(bigtime_t timeout, status_t *error); thread_id fLockOwner;
int32 fRecursiveCount;
int32 fBenaphoreCount; int32 _reserved[4];
sem_id fSemaphoreID;
thread_id fLockOwner;
int32 fRecursiveCount;
// Reserved space for future changes to BLocker
int32 fReservedSpace[4];
}; };
#ifdef USE_OPENBEOS_NAMESPACE #endif // _LOCKER_H
}
#endif
#endif // _OPENBEOS_LOCKER_H
+27 -30
View File
@@ -1,41 +1,38 @@
#ifndef _BLUE_STOP_WATCH_H /*
#define _BLUE_STOP_WATCH_H * Copyright 2001-2007, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _STOP_WATCH_H
#define _STOP_WATCH_H
#include <BeBuild.h> #include <BeBuild.h>
#include <SupportDefs.h> #include <SupportDefs.h>
#ifdef USE_OPENBEOS_NAMESPACE
namespace OpenBeOS {
#endif
class BStopWatch { class BStopWatch {
public: public:
BStopWatch(const char *name, bool silent = false); BStopWatch(const char* name, bool silent = false);
virtual ~BStopWatch(); virtual ~BStopWatch();
void Suspend(); void Suspend();
void Resume(); void Resume();
bigtime_t Lap(); bigtime_t Lap();
bigtime_t ElapsedTime() const; bigtime_t ElapsedTime() const;
void Reset(); void Reset();
const char *Name() const; const char* Name() const;
private: private:
virtual void _ReservedStopWatch1(); virtual void _ReservedStopWatch1();
virtual void _ReservedStopWatch2(); virtual void _ReservedStopWatch2();
bigtime_t fStart; bigtime_t fStart;
bigtime_t fSuspendTime; bigtime_t fSuspendTime;
bigtime_t fLaps[10]; bigtime_t fLaps[10];
int32 fLap; int32 fLap;
const char *fName; const char* fName;
uint32 _reserved[2]; // these are for fName to be initiased uint32 _reserved[2];
bool fSilent; bool fSilent;
}; };
#ifdef USE_OPENBEOS_NAMESPACE #endif // _STOP_WATCH_H
} // namespace OpenBeOS
using namespace OpenBeOS;
#endif
#endif /* _STOP_WATCH_H */
+40 -62
View File
@@ -1,49 +1,28 @@
//------------------------------------------------------------------------------ /*
// Copyright (c) 2004-2005, Haiku * Copyright 2004-2007, Haiku, Inc. All Rights Reserved.
// * Distributed under the terms of the MIT License.
// Permission is hereby granted, free of charge, to any person obtaining a *
// copy of this software and associated documentation files (the "Software"), * Author:
// to deal in the Software without restriction, including without limitation * Erik Jaesler ([email protected])
// 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: SupportDefs.h
// Author: Erik Jaesler ([email protected])
// Description: Common type definitions.
//------------------------------------------------------------------------------
#ifndef _SUPPORT_DEFS_H #ifndef _SUPPORT_DEFS_H
#define _SUPPORT_DEFS_H #define _SUPPORT_DEFS_H
/* this !must! be located before the include of sys/types.h */
/* this must be located before the include of sys/types.h */
#if !defined(_SYS_TYPES_H) && !defined(_SYS_TYPES_H_) #if !defined(_SYS_TYPES_H) && !defined(_SYS_TYPES_H_)
typedef unsigned long ulong; typedef unsigned long ulong;
typedef unsigned int uint; typedef unsigned int uint;
typedef unsigned short ushort; typedef unsigned short ushort;
#endif #endif
// Standard Includes -----------------------------------------------------------
// System Includes -------------------------------------------------------------
#include <BeBuild.h> #include <BeBuild.h>
#include <sys/types.h>
#include <Errors.h> #include <Errors.h>
// Shorthand type formats ------------------------------------------------------ #include <sys/types.h>
// Shorthand type formats
typedef signed char int8; typedef signed char int8;
typedef unsigned char uint8; typedef unsigned char uint8;
typedef volatile signed char vint8; typedef volatile signed char vint8;
@@ -59,9 +38,9 @@ typedef unsigned long uint32;
typedef volatile long vint32; typedef volatile long vint32;
typedef volatile unsigned long vuint32; typedef volatile unsigned long vuint32;
typedef long long int64; typedef long long int64;
typedef unsigned long long uint64; typedef unsigned long long uint64;
typedef volatile long long vint64; typedef volatile long long vint64;
typedef volatile unsigned long long vuint64; typedef volatile unsigned long long vuint64;
typedef volatile long vlong; typedef volatile long vlong;
@@ -78,24 +57,20 @@ typedef unsigned char uchar;
typedef unsigned short unichar; typedef unsigned short unichar;
// Descriptive formats --------------------------------------------------------- // Descriptive formats
typedef int32 status_t; typedef int32 status_t;
typedef int64 bigtime_t; typedef int64 bigtime_t;
typedef uint32 type_code; typedef uint32 type_code;
typedef uint32 perform_code; typedef uint32 perform_code;
// Empty string ("") ----------------------------------------------------------- // Empty string ("")
#ifdef __cplusplus #ifdef __cplusplus
extern _IMPEXP_BE const char *B_EMPTY_STRING; extern const char *B_EMPTY_STRING;
#endif #endif
// min and max comparisons ----------------------------------------------------- // min and max comparisons
// min() and max() won't work in C++
#define min_c(a,b) ((a)>(b)?(b):(a))
#define max_c(a,b) ((a)>(b)?(a):(b))
#ifndef __cplusplus #ifndef __cplusplus
# ifndef min # ifndef min
# define min(a,b) ((a)>(b)?(b):(a)) # define min(a,b) ((a)>(b)?(b):(a))
@@ -105,8 +80,12 @@ extern _IMPEXP_BE const char *B_EMPTY_STRING;
# endif # endif
#endif #endif
// min() and max() won't work in C++
#define min_c(a,b) ((a)>(b)?(b):(a))
#define max_c(a,b) ((a)>(b)?(a):(b))
// Grandfathering --------------------------------------------------------------
// Grandfathering
#ifndef __cplusplus #ifndef __cplusplus
# include <stdbool.h> # include <stdbool.h>
#endif #endif
@@ -116,34 +95,33 @@ extern _IMPEXP_BE const char *B_EMPTY_STRING;
#endif #endif
//------------------------------------------------------------------------------
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
//----- Atomic functions; old value is returned -------------------------------- // Atomic functions; previous value is returned
extern _IMPEXP_ROOT int32 atomic_set(vint32 *value, int32 newValue); extern int32 atomic_set(vint32 *value, int32 newValue);
extern _IMPEXP_ROOT int32 atomic_test_and_set(vint32 *value, int32 newValue, int32 testAgainst); extern int32 atomic_test_and_set(vint32 *value, int32 newValue, int32 testAgainst);
extern _IMPEXP_ROOT int32 atomic_add(vint32 *value, int32 addValue); extern int32 atomic_add(vint32 *value, int32 addValue);
extern _IMPEXP_ROOT int32 atomic_and(vint32 *value, int32 andValue); extern int32 atomic_and(vint32 *value, int32 andValue);
extern _IMPEXP_ROOT int32 atomic_or(vint32 *value, int32 orValue); extern int32 atomic_or(vint32 *value, int32 orValue);
extern _IMPEXP_ROOT int32 atomic_get(vint32 *value); extern int32 atomic_get(vint32 *value);
extern _IMPEXP_ROOT int64 atomic_set64(vint64 *value, int64 newValue); extern int64 atomic_set64(vint64 *value, int64 newValue);
extern _IMPEXP_ROOT int64 atomic_test_and_set64(vint64 *value, int64 newValue, int64 testAgainst); extern int64 atomic_test_and_set64(vint64 *value, int64 newValue, int64 testAgainst);
extern _IMPEXP_ROOT int64 atomic_add64(vint64 *value, int64 addValue); extern int64 atomic_add64(vint64 *value, int64 addValue);
extern _IMPEXP_ROOT int64 atomic_and64(vint64 *value, int64 andValue); extern int64 atomic_and64(vint64 *value, int64 andValue);
extern _IMPEXP_ROOT int64 atomic_or64(vint64 *value, int64 orValue); extern int64 atomic_or64(vint64 *value, int64 orValue);
extern _IMPEXP_ROOT int64 atomic_get64(vint64 *value); extern int64 atomic_get64(vint64 *value);
// Other stuff ----------------------------------------------------------------- // Other stuff
extern _IMPEXP_ROOT void * get_stack_frame(void); extern void* get_stack_frame(void);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
//-------- Obsolete or discouraged API ----------------------------------------- // Obsolete or discouraged API
// use 'true' and 'false' // use 'true' and 'false'
#ifndef FALSE #ifndef FALSE
+8 -4
View File
@@ -1,17 +1,21 @@
/*
* Copyright 2003-2007, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _TLS_H #ifndef _TLS_H
#define _TLS_H #define _TLS_H
/*
** Distributed under the terms of the OpenBeOS License.
*/
#include <BeBuild.h> #include <BeBuild.h>
#include <SupportDefs.h> #include <SupportDefs.h>
/* A maximum of 64 keys is allowed to store in TLS - the key is reserved /* A maximum of 64 keys is allowed to store in TLS - the key is reserved
* process-wide. Note that tls_allocate() will return B_NO_MEMORY if you * process-wide. Note that tls_allocate() will return B_NO_MEMORY if you
* try to exceed this limit. * try to exceed this limit.
*/ */
#define TLS_MAX_KEYS 64 #define TLS_MAX_KEYS 64
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
+44 -55
View File
@@ -1,70 +1,59 @@
/****************************************************************************** /*
/ * Copyright 2007, Haiku, Inc. All Rights Reserved.
/ File: UTF8.h * Distributed under the terms of the MIT License.
/ */
/ Description: UTF-8 conversion functions.
/
/ Copyright 1993-98, Be Incorporated
/
******************************************************************************/
#ifndef _UTF8_H #ifndef _UTF8_H
#define _UTF8_H #define _UTF8_H
#include <BeBuild.h> #include <BeBuild.h>
#include <InterfaceDefs.h> #include <InterfaceDefs.h>
#include <SupportDefs.h> #include <SupportDefs.h>
/*------------------------------------------------------------*/
/*------- Conversion Flavors ---------------------------------*/ // Conversion Flavors
enum { enum {
B_ISO1_CONVERSION, /* ISO 8859-1 */ B_ISO1_CONVERSION, // ISO 8859-x
B_ISO2_CONVERSION, /* ISO 8859-2 */ B_ISO2_CONVERSION,
B_ISO3_CONVERSION, /* ISO 8859-3 */ B_ISO3_CONVERSION,
B_ISO4_CONVERSION, /* ISO 8859-4 */ B_ISO4_CONVERSION,
B_ISO5_CONVERSION, /* ISO 8859-5 */ B_ISO5_CONVERSION,
B_ISO6_CONVERSION, /* ISO 8859-6 */ B_ISO6_CONVERSION,
B_ISO7_CONVERSION, /* ISO 8859-7 */ B_ISO7_CONVERSION,
B_ISO8_CONVERSION, /* ISO 8859-8 */ B_ISO8_CONVERSION,
B_ISO9_CONVERSION, /* ISO 8859-9 */ B_ISO9_CONVERSION,
B_ISO10_CONVERSION, /* ISO 8859-10 */ B_ISO10_CONVERSION,
B_MAC_ROMAN_CONVERSION, /* Macintosh Roman */ B_MAC_ROMAN_CONVERSION, // Macintosh Roman
B_SJIS_CONVERSION, /* Shift-JIS */ B_SJIS_CONVERSION, // Shift-JIS
B_EUC_CONVERSION, /* EUC Packed Japanese */ B_EUC_CONVERSION, // EUC Packed Japanese
B_JIS_CONVERSION, /* JIS X 0208-1990 */ B_JIS_CONVERSION, // JIS X 0208-1990
B_MS_WINDOWS_CONVERSION, /* MS-Windows Codepage 1252 */ B_MS_WINDOWS_CONVERSION, // Windows Latin-1 Codepage 1252
B_UNICODE_CONVERSION, /* Unicode 2.0 */ B_UNICODE_CONVERSION, // Unicode 2.0, UCS-2
B_KOI8R_CONVERSION, /* KOI8-R */ B_KOI8R_CONVERSION, // KOI8-R
B_MS_WINDOWS_1251_CONVERSION, /* MS-Windows Codepage 1251 */ B_MS_WINDOWS_1251_CONVERSION, // Windows Cyrillic Codepage 1251
B_MS_DOS_866_CONVERSION, /* MS-DOS Codepage 866 */ B_MS_DOS_866_CONVERSION, // MS-DOS Codepage 866
B_MS_DOS_CONVERSION, /* MS-DOS Codepage 437 */ B_MS_DOS_CONVERSION, // MS-DOS Codepage 437
B_EUC_KR_CONVERSION, /* EUC Korean */ B_EUC_KR_CONVERSION, // EUC Korean
B_ISO13_CONVERSION, /* ISO 8859-13 */ B_ISO13_CONVERSION,
B_ISO14_CONVERSION, /* ISO 8859-14 */ B_ISO14_CONVERSION,
B_ISO15_CONVERSION, /* ISO 8859-15 */ B_ISO15_CONVERSION,
B_BIG5_CONVERSION, // Chinese Big5
B_GBK_CONVERSION, // Chinese GB18030
}; };
/*-------------------------------------------------------------*/
/*------- Conversion Functions --------------------------------*/
_IMPEXP_TEXTENCODING status_t convert_to_utf8(uint32 srcEncoding, // Conversion Functions
const char *src,
int32 *srcLen,
char *dst,
int32 *dstLen,
int32 *state,
char substitute = B_SUBSTITUTE);
_IMPEXP_TEXTENCODING status_t convert_from_utf8(uint32 dstEncoding, #ifdef __cplusplus
const char *src,
int32 *srcLen,
char *dst,
int32 *dstLen,
int32 *state,
char substitute = B_SUBSTITUTE);
/*-------------------------------------------------------------*/ status_t convert_to_utf8(uint32 sourceEncoding, const char* source,
/*-------------------------------------------------------------*/ int32* sourceLength, char* dest, int32* destLength, int32* state,
char substitute = B_SUBSTITUTE);
status_t convert_from_utf8(uint32 destEncoding, const char* source,
int32* sourceLength, char* dest, int32* destLength, int32* state,
char substitute = B_SUBSTITUTE);
#endif
#endif /* _UTF8_H */ #endif /* _UTF8_H */
+7 -6
View File
@@ -1,8 +1,9 @@
/*
* Copyright 2003-2007, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _PARSEDATE_H #ifndef _PARSEDATE_H
#define _PARSEDATE_H #define _PARSEDATE_H
/*
** Distributed under the terms of the OpenBeOS License.
*/
#include <time.h> #include <time.h>
@@ -20,10 +21,10 @@
extern "C" { extern "C" {
#endif #endif
extern time_t parsedate(const char *dateString, time_t now); extern time_t parsedate(const char *dateString, time_t now);
extern time_t parsedate_etc(const char *dateString, time_t now, int *_storedFlags); extern time_t parsedate_etc(const char *dateString, time_t now, int *_storedFlags);
extern void set_dateformats(const char *table[]); extern void set_dateformats(const char *table[]);
extern const char **get_dateformats(void); extern const char **get_dateformats(void);
#ifdef __cplusplus #ifdef __cplusplus
+109 -102
View File
@@ -1,17 +1,20 @@
/* /*
* Copyright (c) 2001-2005, Haiku * Copyright (c) 2001-2007, Haiku
* Distributed under the terms of the MIT license * Distributed under the terms of the MIT license
*
* Authors: * Authors:
Stefano Ceccherini ([email protected]) * Stefano Ceccherini ([email protected])
*/ */
// A buffered adapter for BPositionIO objects. //! A buffered adapter for BPositionIO objects.
#include <BufferIO.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <BufferIO.h>
/*! \class BBufferIO /*! \class BBufferIO
\brief A buffered adapter for BPositionIO objects. \brief A buffered adapter for BPositionIO objects.
@@ -28,43 +31,46 @@
\param buf_size The size of the buffer that the object will allocate and use. \param buf_size The size of the buffer that the object will allocate and use.
\param owns_stream Specifies if the object will delete the stream on destruction. \param owns_stream Specifies if the object will delete the stream on destruction.
*/ */
BBufferIO::BBufferIO(BPositionIO *stream, size_t buf_size, bool owns_stream) BBufferIO::BBufferIO(BPositionIO *stream, size_t bufferSize, bool ownsStream)
:m_buffer_start(0), :
m_stream(stream), fBufferStart(0),
m_buffer(NULL), fStream(stream),
m_buffer_used(0), fBuffer(NULL),
m_buffer_dirty(false), fBufferUsed(0),
m_owns_stream(owns_stream) fBufferIsDirty(false),
fOwnsStream(ownsStream)
{ {
if (buf_size < 512) if (bufferSize < 512)
buf_size = 512; bufferSize = 512;
m_buffer_phys = buf_size; fBufferSize = bufferSize;
// What can we do if this malloc fails ? // What can we do if this malloc fails ?
// I think R5 uses new, but doesn't catch the thrown exception // I think R5 uses new, but doesn't catch the thrown exception
// (if you specify a very big buffer, the application just // (if you specify a very big buffer, the application just
// terminates with abort). // terminates with abort).
m_buffer = (char *)malloc(m_buffer_phys * sizeof(char)); fBuffer = (char *)malloc(fBufferSize);
} }
/*! \brief Frees the resources allocated by the object /*! \brief Frees the resources allocated by the object
Flushes pending changes to the stream and frees the allocated memory. Flushes pending changes to the stream and frees the allocated memory.
If the owns_stream property is true, the destructor also If the owns_stream property is true, the destructor also
deletes the stream associated with the BBufferIO object. deletes the stream associated with the BBufferIO object.
*/ */
BBufferIO::~BBufferIO() BBufferIO::~BBufferIO()
{ {
if (m_buffer_dirty) if (fBufferIsDirty) {
Flush(); // Writes pending changes to the stream // Write pending changes to the stream
Flush();
}
free(m_buffer); free(fBuffer);
if (m_owns_stream) if (fOwnsStream)
delete m_stream; delete fStream;
} }
@@ -80,41 +86,40 @@ BBufferIO::ReadAt(off_t pos, void *buffer, size_t size)
// We refuse to crash, even if // We refuse to crash, even if
// you were lazy and didn't give a valid // you were lazy and didn't give a valid
// stream on construction. // stream on construction.
if (m_stream == NULL) if (fStream == NULL)
return B_NO_INIT; return B_NO_INIT;
if (buffer == NULL) if (buffer == NULL)
return B_BAD_VALUE; return B_BAD_VALUE;
// If the amount of data we want doesn't fit in the buffer, just // If the amount of data we want doesn't fit in the buffer, just
// read it directly from the disk (and don't touch the buffer). // read it directly from the disk (and don't touch the buffer).
if (size > m_buffer_phys) { if (size > fBufferSize) {
if (m_buffer_dirty) if (fBufferIsDirty)
Flush(); Flush();
return m_stream->ReadAt(pos, buffer, size); return fStream->ReadAt(pos, buffer, size);
} }
// If the data we are looking for is not in the buffer... // If the data we are looking for is not in the buffer...
if (size > m_buffer_used if (size > fBufferUsed
|| pos < m_buffer_start || pos < fBufferStart
|| pos > m_buffer_start + m_buffer_used || pos > fBufferStart + fBufferUsed
|| pos + size > m_buffer_start + m_buffer_used) { || pos + size > fBufferStart + fBufferUsed) {
if (fBufferIsDirty)
if (m_buffer_dirty)
Flush(); // If there are pending writes, do them. Flush(); // If there are pending writes, do them.
// ...cache as much as we can from the stream // ...cache as much as we can from the stream
m_buffer_used = m_stream->ReadAt(pos, m_buffer, m_buffer_phys); fBufferUsed = fStream->ReadAt(pos, fBuffer, fBufferSize);
if (m_buffer_used > 0) if (fBufferUsed > 0)
m_buffer_start = pos; // The data is buffered starting from this offset fBufferStart = pos; // The data is buffered starting from this offset
} }
size = min_c(size, m_buffer_used); size = min_c(size, fBufferUsed);
// copy data from the cache to the given buffer // copy data from the cache to the given buffer
memcpy(buffer, m_buffer + pos - m_buffer_start, size); memcpy(buffer, fBuffer + pos - fBufferStart, size);
return size; return size;
} }
@@ -128,45 +133,45 @@ BBufferIO::ReadAt(off_t pos, void *buffer, size_t size)
ssize_t ssize_t
BBufferIO::WriteAt(off_t pos, const void *buffer, size_t size) BBufferIO::WriteAt(off_t pos, const void *buffer, size_t size)
{ {
if (m_stream == NULL) if (fStream == NULL)
return B_NO_INIT; return B_NO_INIT;
if (buffer == NULL) if (buffer == NULL)
return B_BAD_VALUE; return B_BAD_VALUE;
// If data doesn't fit into the buffer, write it directly to the stream // If data doesn't fit into the buffer, write it directly to the stream
if (size > m_buffer_phys) if (size > fBufferSize)
return m_stream->WriteAt(pos, buffer, size); return fStream->WriteAt(pos, buffer, size);
// If we have cached data in the buffer, whose offset into the stream // If we have cached data in the buffer, whose offset into the stream
// is > 0, and the buffer isn't dirty, drop the data. // is > 0, and the buffer isn't dirty, drop the data.
if (!m_buffer_dirty && m_buffer_start > pos) { if (!fBufferIsDirty && fBufferStart > pos) {
m_buffer_start = 0; fBufferStart = 0;
m_buffer_used = 0; fBufferUsed = 0;
} }
// If we want to write beyond the cached data... // If we want to write beyond the cached data...
if (pos > m_buffer_start + m_buffer_used if (pos > fBufferStart + fBufferUsed
|| pos < m_buffer_start) { || pos < fBufferStart) {
ssize_t read; ssize_t read;
off_t where = pos; off_t where = pos;
if (pos + size <= m_buffer_phys) // Can we just cache from the beginning ? if (pos + size <= fBufferSize) // Can we just cache from the beginning ?
where = 0; where = 0;
// ...cache more. // ...cache more.
read = m_stream->ReadAt(where, m_buffer, m_buffer_phys); read = fStream->ReadAt(where, fBuffer, fBufferSize);
if (read > 0) { if (read > 0) {
m_buffer_used = read; fBufferUsed = read;
m_buffer_start = where; fBufferStart = where;
} }
} }
memcpy(m_buffer + pos - m_buffer_start, buffer, size); memcpy(fBuffer + pos - fBufferStart, buffer, size);
m_buffer_dirty = true; fBufferIsDirty = true;
m_buffer_used = max_c((size + pos), m_buffer_used); fBufferUsed = max_c((size + pos), fBufferUsed);
return size; return size;
} }
@@ -194,12 +199,12 @@ BBufferIO::WriteAt(off_t pos, const void *buffer, size_t size)
from the beginning of the stream. from the beginning of the stream.
*/ */
off_t off_t
BBufferIO::Seek(off_t position, uint32 seek_mode) BBufferIO::Seek(off_t position, uint32 seekMode)
{ {
if (m_stream == NULL) if (fStream == NULL)
return B_NO_INIT; return B_NO_INIT;
return m_stream->Seek(position, seek_mode); return fStream->Seek(position, seekMode);
} }
@@ -210,10 +215,10 @@ BBufferIO::Seek(off_t position, uint32 seek_mode)
off_t off_t
BBufferIO::Position() const BBufferIO::Position() const
{ {
if (m_stream == NULL) if (fStream == NULL)
return B_NO_INIT; return B_NO_INIT;
return m_stream->Position(); return fStream->Position();
} }
@@ -224,10 +229,10 @@ BBufferIO::Position() const
status_t status_t
BBufferIO::SetSize(off_t size) BBufferIO::SetSize(off_t size)
{ {
if (m_stream == NULL) if (fStream == NULL)
return B_NO_INIT; return B_NO_INIT;
return m_stream->SetSize(size); return fStream->SetSize(size);
} }
@@ -237,16 +242,15 @@ BBufferIO::SetSize(off_t size)
status_t status_t
BBufferIO::Flush() BBufferIO::Flush()
{ {
if (!m_buffer_dirty) if (!fBufferIsDirty)
return B_OK; return B_OK;
// Write the cached data to the stream // Write the cached data to the stream
status_t err = m_stream->WriteAt(m_buffer_start, m_buffer, m_buffer_used); ssize_t bytesWritten = fStream->WriteAt(fBufferStart, fBuffer, fBufferUsed);
if (bytesWritten > 0)
if (err > 0) fBufferIsDirty = false;
m_buffer_dirty = false;
return (bytesWritten < 0) ? bytesWritten : B_OK;
return (err < 0) ? err : B_OK;
} }
@@ -256,7 +260,7 @@ BBufferIO::Flush()
BPositionIO * BPositionIO *
BBufferIO::Stream() const BBufferIO::Stream() const
{ {
return m_stream; return fStream;
} }
@@ -266,7 +270,7 @@ BBufferIO::Stream() const
size_t size_t
BBufferIO::BufferSize() const BBufferIO::BufferSize() const
{ {
return m_buffer_phys; return fBufferSize;
} }
@@ -277,7 +281,7 @@ BBufferIO::BufferSize() const
bool bool
BBufferIO::OwnsStream() const BBufferIO::OwnsStream() const
{ {
return m_owns_stream; return fOwnsStream;
} }
@@ -288,7 +292,7 @@ BBufferIO::OwnsStream() const
void void
BBufferIO::SetOwnsStream(bool owns_stream) BBufferIO::SetOwnsStream(bool owns_stream)
{ {
m_owns_stream = owns_stream; fOwnsStream = owns_stream;
} }
@@ -297,18 +301,21 @@ BBufferIO::SetOwnsStream(bool owns_stream)
void void
BBufferIO::PrintToStream() const BBufferIO::PrintToStream() const
{ {
printf("stream %p\n", m_stream); printf("stream %p\n", fStream);
printf("buffer %p\n", m_buffer); printf("buffer %p\n", fBuffer);
printf("start %lld\n", m_buffer_start); printf("start %lld\n", fBufferStart);
printf("used %ld\n", m_buffer_used); printf("used %ld\n", fBufferUsed);
printf("phys %ld\n", m_buffer_phys); printf("phys %ld\n", fBufferSize);
printf("dirty %s\n", (m_buffer_dirty) ? "true" : "false"); printf("dirty %s\n", (fBufferIsDirty) ? "true" : "false");
printf("owns %s\n", (m_owns_stream) ? "true" : "false"); printf("owns %s\n", (fOwnsStream) ? "true" : "false");
} }
// These functions are here to maintain future binary // #pragma mark -
// compatibility.
// These functions are here to maintain future binary
// compatibility.
status_t BBufferIO::_Reserved_BufferIO_0(void *) { return B_ERROR; } status_t BBufferIO::_Reserved_BufferIO_0(void *) { return B_ERROR; }
status_t BBufferIO::_Reserved_BufferIO_1(void *) { return B_ERROR; } status_t BBufferIO::_Reserved_BufferIO_1(void *) { return B_ERROR; }
status_t BBufferIO::_Reserved_BufferIO_2(void *) { return B_ERROR; } status_t BBufferIO::_Reserved_BufferIO_2(void *) { return B_ERROR; }