From e67f770704d13cb1411c5cebbe5ef9c8ca74d724 Mon Sep 17 00:00:00 2001 From: memson Date: Tue, 23 Apr 2002 19:07:22 +0000 Subject: [PATCH] added a number of api conversions to pascal and also a new pascal test app. --- begui/begui/imports/pascal/be_errors.pas | 335 ++++++++++++++++++ begui/begui/imports/pascal/bebuild.pas | 74 ++++ begui/begui/imports/pascal/beutils.pas | 305 ++++++++++++++++ .../imports/pascal/examples/testapp5.pas | 13 + begui/begui/imports/pascal/utf8.pas | 102 ++++++ 5 files changed, 829 insertions(+) create mode 100644 begui/begui/imports/pascal/be_errors.pas create mode 100644 begui/begui/imports/pascal/bebuild.pas create mode 100644 begui/begui/imports/pascal/beutils.pas create mode 100644 begui/begui/imports/pascal/examples/testapp5.pas create mode 100644 begui/begui/imports/pascal/utf8.pas diff --git a/begui/begui/imports/pascal/be_errors.pas b/begui/begui/imports/pascal/be_errors.pas new file mode 100644 index 0000000..0408daa --- /dev/null +++ b/begui/begui/imports/pascal/be_errors.pas @@ -0,0 +1,335 @@ +unit be_errors; +interface + +{$PACKRECORDS C} + +{------------------------------------------------------------- } +{----- Error baselines --------------------------------------- } + +const + B_GENERAL_ERROR_BASE = LONG_MIN; + B_OS_ERROR_BASE = B_GENERAL_ERROR_BASE + $1000; + B_APP_ERROR_BASE = B_GENERAL_ERROR_BASE + $2000; + B_INTERFACE_ERROR_BASE = B_GENERAL_ERROR_BASE + $3000; + B_MEDIA_ERROR_BASE = B_GENERAL_ERROR_BASE + $4000; //* - $41ff */ + B_TRANSLATION_ERROR_BASE = B_GENERAL_ERROR_BASE + $4800 //* - $48ff */ + B_MIDI_ERROR_BASE = B_GENERAL_ERROR_BASE + $5000; + B_STORAGE_ERROR_BASE = B_GENERAL_ERROR_BASE + $6000; + B_POSIX_ERROR_BASE = B_GENERAL_ERROR_BASE + $7000; + B_MAIL_ERROR_BASE = B_GENERAL_ERROR_BASE + $8000; + B_PRINT_ERROR_BASE = B_GENERAL_ERROR_BASE + $9000; + B_DEVICE_ERROR_BASE = B_GENERAL_ERROR_BASE + $a000; + B_WWW_ERROR_BASE = B_GENERAL_ERROR_BASE + $b000; + B_DIALER_ERROR_BASE = B_GENERAL_ERROR_BASE + $c000; + B_REGEXP_ERROR_BASE = B_GENERAL_ERROR_BASE + $d000; + B_BINDER_ERROR_BASE = B_GENERAL_ERROR_BASE + $e000; + + +{--- Developer-defined errors start at (B_ERRORS_END+1)---- } + + B_ERRORS_END = B_GENERAL_ERROR_BASE + $ffff; + +{------------------------------------------------------------- } +{----- General Errors ---------------------------------------- } + B_NO_MEMORY = B_GENERAL_ERROR_BASE; + B_IO_ERROR = B_GENERAL_ERROR_BASE + 1 + B_PERMISSION_DENIED = B_GENERAL_ERROR_BASE + 2; + B_BAD_INDEX = B_GENERAL_ERROR_BASE + 3; + B_BAD_TYPE = B_GENERAL_ERROR_BASE + 4; + B_BAD_VALUE = B_GENERAL_ERROR_BASE + 5; + B_MISMATCHED_VALUES = B_GENERAL_ERROR_BASE + 6; + B_NAME_NOT_FOUND = B_GENERAL_ERROR_BASE + 7; + B_NAME_IN_USE = B_GENERAL_ERROR_BASE + 8; + B_TIMED_OUT = B_GENERAL_ERROR_BASE + 9; + B_INTERRUPTED = B_GENERAL_ERROR_BASE + 10; + B_WOULD_BLOCK = B_GENERAL_ERROR_BASE + 11; + B_CANCELED = B_GENERAL_ERROR_BASE + 12; + B_NO_INIT = B_GENERAL_ERROR_BASE + 13; + B_BUSY = B_GENERAL_ERROR_BASE + 14; + B_NOT_ALLOWED = B_GENERAL_ERROR_BASE + 15; + B_BAD_DATA = B_GENERAL_ERROR_BASE + 16; + B_DATA_TRUNCATED = B_GENERAL_ERROR_BASE + 17; + B_DONT_DO_THAT = B_GENERAL_ERROR_BASE + 18; + + B_ERROR = -1; + B_OK = 0; + B_NO_ERROR = 0; + +{------------------------------------------------------------- } +{----- Kernel Kit Errors ------------------------------------- } + + B_BAD_SEM_ID = B_OS_ERROR_BASE; + B_NO_MORE_SEMS = B_OS_ERROR_BASE + 1; + + B_BAD_THREAD_ID = B_OS_ERROR_BASE + $100; + B_NO_MORE_THREADS = B_OS_ERROR_BASE + $101; + B_BAD_THREAD_STATE = B_OS_ERROR_BASE + $102; + B_BAD_TEAM_ID = B_OS_ERROR_BASE + $103; + B_NO_MORE_TEAMS = B_OS_ERROR_BASE + $104; + + B_BAD_PORT_ID = B_OS_ERROR_BASE + $200; + B_NO_MORE_PORTS = B_OS_ERROR_BASE + $201; + + B_BAD_IMAGE_ID = B_OS_ERROR_BASE + $300; + B_BAD_ADDRESS = B_OS_ERROR_BASE + $301; + B_NOT_AN_EXECUTABLE = B_OS_ERROR_BASE + $302; + B_MISSING_LIBRARY = B_OS_ERROR_BASE + $303; + B_MISSING_SYMBOL = B_OS_ERROR_BASE + $304; + + B_DEBUGGER_ALREADY_INSTALLED = B_OS_ERROR_BASE + $400; + +{------------------------------------------------------------- } +{----- Application Kit Errors -------------------------------- } + + B_BAD_REPLY = B_APP_ERROR_BASE; + B_DUPLICATE_REPLY = B_APP_ERROR_BASE + 1; + B_MESSAGE_TO_SELF = B_APP_ERROR_BASE + 2; + B_BAD_HANDLER = B_APP_ERROR_BASE + 3; + B_ALREADY_RUNNING = B_APP_ERROR_BASE + 4; + B_LAUNCH_FAILED = B_APP_ERROR_BASE + 5; + B_AMBIGUOUS_APP_LAUNCH = B_APP_ERROR_BASE + 6; + B_UNKNOWN_MIME_TYPE = B_APP_ERROR_BASE + 7; + B_BAD_SCRIPT_SYNTAX = B_APP_ERROR_BASE + 8; + B_LAUNCH_FAILED_NO_RESOLVE_LINK = B_APP_ERROR_BASE + 9; + B_LAUNCH_FAILED_EXECUTABLE = B_APP_ERROR_BASE + 10; + B_LAUNCH_FAILED_APP_NOT_FOUND = B_APP_ERROR_BASE + 11; + B_LAUNCH_FAILED_APP_IN_TRASH = B_APP_ERROR_BASE + 12; + B_LAUNCH_FAILED_NO_PREFERRED_APP = B_APP_ERROR_BASE + 13; + B_LAUNCH_FAILED_FILES_APP_NOT_FOUND = B_APP_ERROR_BASE + 14; + B_BAD_MIME_SNIFFER_RULE = B_APP_ERROR_BASE + 15; + B_NOT_A_MESSAGE = B_APP_ERROR_BASE + 16; + +{------------------------------------------------------------- } +{----- Storage Kit/File System Errors ------------------------ } + + B_FILE_ERROR = B_STORAGE_ERROR_BASE; + B_FILE_NOT_FOUND = B_STORAGE_ERROR_BASE + 1; //* discouraged; use B_ENTRY_NOT_FOUND in new code*/ + B_FILE_EXISTS = B_STORAGE_ERROR_BASE + 2; + B_ENTRY_NOT_FOUND = B_STORAGE_ERROR_BASE + 3; + B_NAME_TOO_LONG = B_STORAGE_ERROR_BASE + 4; + B_NOT_A_DIRECTORY = B_STORAGE_ERROR_BASE + 5; + B_DIRECTORY_NOT_EMPTY = B_STORAGE_ERROR_BASE + 6; + B_DEVICE_FULL = B_STORAGE_ERROR_BASE + 7; + B_READ_ONLY_DEVICE = B_STORAGE_ERROR_BASE + 8; + B_IS_A_DIRECTORY = B_STORAGE_ERROR_BASE + 9; + B_NO_MORE_FDS = B_STORAGE_ERROR_BASE + 10; + B_CROSS_DEVICE_LINK = B_STORAGE_ERROR_BASE + 11; + B_LINK_LIMIT = B_STORAGE_ERROR_BASE + 12; + B_BUSTED_PIPE = B_STORAGE_ERROR_BASE + 13; + B_UNSUPPORTED = B_STORAGE_ERROR_BASE + 14; + B_PARTITION_TOO_SMALL = B_STORAGE_ERROR_BASE + 15; + +{------------------------------------------------------------- } +{----- POSIX Errors ------------------------------------------ } + E2BIG = B_POSIX_ERROR_BASE + 1; + ECHILD = B_POSIX_ERROR_BASE + 2; + EDEADLK = B_POSIX_ERROR_BASE + 3; + EFBIG = B_POSIX_ERROR_BASE + 4; + EMLINK = B_POSIX_ERROR_BASE + 5; + ENFILE = B_POSIX_ERROR_BASE + 6; + ENODEV = B_POSIX_ERROR_BASE + 7; + ENOLCK = B_POSIX_ERROR_BASE + 8; + ENOSYS = B_POSIX_ERROR_BASE + 9; + ENOTTY = B_POSIX_ERROR_BASE + 10; + ENXIO = B_POSIX_ERROR_BASE + 11; + ESPIPE = B_POSIX_ERROR_BASE + 12; + ESRCH = B_POSIX_ERROR_BASE + 13; + EFPOS = B_POSIX_ERROR_BASE + 14; + ESIGPARM = B_POSIX_ERROR_BASE + 15; + EDOM = B_POSIX_ERROR_BASE + 16; + ERANGE = B_POSIX_ERROR_BASE + 17; + EPROTOTYPE = B_POSIX_ERROR_BASE + 18; + EPROTONOSUPPORT = B_POSIX_ERROR_BASE + 19; + EPFNOSUPPORT = B_POSIX_ERROR_BASE + 20; + EAFNOSUPPORT = B_POSIX_ERROR_BASE + 21; + EADDRINUSE = B_POSIX_ERROR_BASE + 22; + EADDRNOTAVAIL = B_POSIX_ERROR_BASE + 23; + ENETDOWN = B_POSIX_ERROR_BASE + 24; + ENETUNREACH = B_POSIX_ERROR_BASE + 25; + ENETRESET = B_POSIX_ERROR_BASE + 26; + ECONNABORTED = B_POSIX_ERROR_BASE + 27; + ECONNRESET = B_POSIX_ERROR_BASE + 28; + EISCONN = B_POSIX_ERROR_BASE + 29; + ENOTCONN = B_POSIX_ERROR_BASE + 30; + ESHUTDOWN = B_POSIX_ERROR_BASE + 31; + ECONNREFUSED = B_POSIX_ERROR_BASE + 32; + EHOSTUNREACH = B_POSIX_ERROR_BASE + 33; + ENOPROTOOPT = B_POSIX_ERROR_BASE + 34; + ENOBUFS = B_POSIX_ERROR_BASE + 35; + EINPROGRESS = B_POSIX_ERROR_BASE + 36; + EALREADY = B_POSIX_ERROR_BASE + 37; + EILSEQ = B_POSIX_ERROR_BASE + 38; + ENOMSG = B_POSIX_ERROR_BASE + 39; + ESTALE = B_POSIX_ERROR_BASE + 40; + EOVERFLOW = B_POSIX_ERROR_BASE + 41; + EMSGSIZE = B_POSIX_ERROR_BASE + 42; + EOPNOTSUPP = B_POSIX_ERROR_BASE + 43; + ENOTSOCK = B_POSIX_ERROR_BASE + 44; + ENOMEM = B_NO_MEMORY; + EACCES = B_PERMISSION_DENIED; + EINTR = B_INTERRUPTED; + EIO = B_IO_ERROR; + EBUSY = B_BUSY; + EFAULT = B_BAD_ADDRESS; + ETIMEDOUT = B_TIMED_OUT; + + { SysV compatibility } + EAGAIN = B_WOULD_BLOCK; + + { BSD compatibility } + EWOULDBLOCK = B_WOULD_BLOCK; + EBADF = B_FILE_ERROR; + EEXIST = B_FILE_EXISTS; + EINVAL = B_BAD_VALUE; + ENAMETOOLONG = B_NAME_TOO_LONG; + ENOENT = B_ENTRY_NOT_FOUND; + EPERM = B_NOT_ALLOWED; + ENOTDIR = B_NOT_A_DIRECTORY; + EISDIR = B_IS_A_DIRECTORY; + ENOTEMPTY = B_DIRECTORY_NOT_EMPTY; + ENOSPC = B_DEVICE_FULL; + EROFS = B_READ_ONLY_DEVICE; + EMFILE = B_NO_MORE_FDS; + EXDEV = B_CROSS_DEVICE_LINK; + ELOOP = B_LINK_LIMIT; + ENOEXEC = B_NOT_AN_EXECUTABLE; + EPIPE = B_BUSTED_PIPE; + +{------------------------------------------------------------- } +{----- Media Kit Errors -------------------------------------- } + + B_STREAM_NOT_FOUND = B_MEDIA_ERROR_BASE; + B_SERVER_NOT_FOUND = B_MEDIA_ERROR_BASE + 1; + B_RESOURCE_NOT_FOUND = B_MEDIA_ERROR_BASE + 2; + B_RESOURCE_UNAVAILABLE = B_MEDIA_ERROR_BASE + 3; + B_BAD_SUBSCRIBER = B_MEDIA_ERROR_BASE + 4; + B_SUBSCRIBER_NOT_ENTERED = B_MEDIA_ERROR_BASE + 5; + B_BUFFER_NOT_AVAILABLE = B_MEDIA_ERROR_BASE + 6; + B_LAST_BUFFER_ERROR = B_MEDIA_ERROR_BASE + 7; + +{------------------------------------------------------------- } +{----- Mail Kit Errors --------------------------------------- } + + B_MAIL_NO_DAEMON = B_MAIL_ERROR_BASE; + B_MAIL_UNKNOWN_USER = B_MAIL_ERROR_BASE + 1; + B_MAIL_WRONG_PASSWORD = B_MAIL_ERROR_BASE + 2; + B_MAIL_UNKNOWN_HOST = B_MAIL_ERROR_BASE + 3; + B_MAIL_ACCESS_ERROR = B_MAIL_ERROR_BASE + 4; + B_MAIL_UNKNOWN_FIELD = B_MAIL_ERROR_BASE + 5; + B_MAIL_NO_RECIPIENT = B_MAIL_ERROR_BASE + 6; + B_MAIL_INVALID_MAIL = B_MAIL_ERROR_BASE + 7; + +{------------------------------------------------------------- } +{----- Printing Errors -------------------------------------- } + + B_NO_PRINT_SERVER = B_PRINT_ERROR_BASE; + B_PAPER_JAM = B_PRINT_ERROR_BASE + 1; + B_NO_PAPER = B_PRINT_ERROR_BASE + 2; + B_NO_INK = B_PRINT_ERROR_BASE + 3; + B_NO_TRANSPORT = B_PRINT_ERROR_BASE + 4; + B_BAD_TRANSPORT = B_PRINT_ERROR_BASE + 5; + B_TRANSPORT_INIT_ERROR = B_PRINT_ERROR_BASE + 6; + B_PRINTER_BUSY = B_PRINT_ERROR_BASE + 7; + B_NO_PRINTER = B_PRINT_ERROR_BASE + 8; + B_INVALID_PRINT_SETTINGS = B_PRINT_ERROR_BASE + 9; + B_INVALID_PRINTER = B_PRINT_ERROR_BASE + 10; + B_NO_SPOOL_FILE = B_PRINT_ERROR_BASE + 11; + B_BAD_SPOOL_FILE = B_PRINT_ERROR_BASE + 12; + B_NO_DRIVER = B_PRINT_ERROR_BASE + 13; + B_BAD_DRIVER = B_PRINT_ERROR_BASE + 14; + +{------------------------------------------------------------- } +{----- Device Kit Errors ------------------------------------- } + + B_DEV_INVALID_IOCTL = B_DEVICE_ERROR_BASE; + B_DEV_NO_MEMORY = B_DEVICE_ERROR_BASE + 1; + B_DEV_BAD_DRIVE_NUM = B_DEVICE_ERROR_BASE + 2; + B_DEV_NO_MEDIA = B_DEVICE_ERROR_BASE + 3; + B_DEV_UNREADABLE = B_DEVICE_ERROR_BASE + 4; + B_DEV_FORMAT_ERROR = B_DEVICE_ERROR_BASE + 5; + B_DEV_TIMEOUT = B_DEVICE_ERROR_BASE + 6; + B_DEV_RECALIBRATE_ERROR = B_DEVICE_ERROR_BASE + 7; + B_DEV_SEEK_ERROR = B_DEVICE_ERROR_BASE + 8; + B_DEV_ID_ERROR = B_DEVICE_ERROR_BASE + 9; + B_DEV_READ_ERROR = B_DEVICE_ERROR_BASE + 10; + B_DEV_WRITE_ERROR = B_DEVICE_ERROR_BASE + 11; + B_DEV_NOT_READY = B_DEVICE_ERROR_BASE + 12; + B_DEV_MEDIA_CHANGED = B_DEVICE_ERROR_BASE + 13; + B_DEV_MEDIA_CHANGE_REQUESTED = B_DEVICE_ERROR_BASE + 14; + B_DEV_RESOURCE_CONFLICT = B_DEVICE_ERROR_BASE + 15; + B_DEV_CONFIGURATION_ERROR = B_DEVICE_ERROR_BASE + 16; + B_DEV_DISABLED_BY_USER = B_DEVICE_ERROR_BASE + 17; + B_DEV_DOOR_OPEN = B_DEVICE_ERROR_BASE + 18; + // + B_DEV_INVALID_PIPE = B_DEVICE_ERROR_BASE + 19; + B_DEV_CRC_ERROR = B_DEVICE_ERROR_BASE + 20; + B_DEV_STALLED = B_DEVICE_ERROR_BASE + 21; + B_DEV_BAD_PID = B_DEVICE_ERROR_BASE + 22; + B_DEV_UNEXPECTED_PID = B_DEVICE_ERROR_BASE + 23; + B_DEV_DATA_OVERRUN = B_DEVICE_ERROR_BASE + 24; + B_DEV_DATA_UNDERRUN = B_DEVICE_ERROR_BASE + 25; + B_DEV_FIFO_OVERRUN = B_DEVICE_ERROR_BASE + 26; + B_DEV_FIFO_UNDERRUN = B_DEVICE_ERROR_BASE + 27; + B_DEV_PENDING = B_DEVICE_ERROR_BASE + 28; + B_DEV_MULTIPLE_ERRORS = B_DEVICE_ERROR_BASE + 29; + B_DEV_TOO_LATE = B_DEVICE_ERROR_BASE + 30; + +{------------------------------------------------------------- } +{----- WWW Kit Errors ------------------------------------- } + + B_AUTHENTICATION_ERROR = B_WWW_ERROR_BASE; + B_FINISH_STREAM = B_WWW_ERROR_BASE + 1; + B_NO_RANDOM_ACCESS = B_WWW_ERROR_BASE + 2; + B_NO_CONTENT = B_WWW_ERROR_BASE + 3; + //* compatibility for RealPlayer. Remove after next version */ + FINISH_STREAM = B_FINISH_STREAM; + +{------------------------------------------------------------- } +{-----Dialer Errors (typically returned from modems)---------- } + + B_MODEM_NO_CARRIER = B_DIALER_ERROR_BASE; + B_MODEM_BUSY = B_DIALER_ERROR_BASE + 1; + B_MODEM_NO_DIALTONE = B_DIALER_ERROR_BASE + 2; + B_MODEM_NO_ANSWER = B_DIALER_ERROR_BASE + 3; + B_MODEM_ERROR = B_DIALER_ERROR_BASE + 4; + B_MODEM_RINGING = B_DIALER_ERROR_BASE + 5; + B_MODEM_UNKNOWN = B_DIALER_ERROR_BASE + 6; + B_MODEM_BAD_LOGIN = B_DIALER_ERROR_BASE + 7; + B_MODEM_TIMEOUT = B_DIALER_ERROR_BASE + 8; + +{------------------------------------------------------------- } +{-----RegExp Errors ------------------------------------------ } + + B_REGEXP_UNMATCHED_PARENTHESIS = B_REGEXP_ERROR_BASE; + B_REGEXP_TOO_BIG = B_REGEXP_ERROR_BASE + 1; + B_REGEXP_TOO_MANY_PARENTHESIS = B_REGEXP_ERROR_BASE + 2; + B_REGEXP_JUNK_ON_END = B_REGEXP_ERROR_BASE + 3; + B_REGEXP_STAR_PLUS_OPERAND_EMPTY = B_REGEXP_ERROR_BASE + 4; + B_REGEXP_NESTED_STAR_QUESTION_PLUS = B_REGEXP_ERROR_BASE + 5; + B_REGEXP_INVALID_BRACKET_RANGE = B_REGEXP_ERROR_BASE + 6; + B_REGEXP_UNMATCHED_BRACKET = B_REGEXP_ERROR_BASE + 7; + B_REGEXP_INTERNAL_ERROR = B_REGEXP_ERROR_BASE + 8; + B_REGEXP_QUESTION_PLUS_STAR_FOLLOWS_NOTHING = B_REGEXP_ERROR_BASE + 9; + B_REGEXP_TRAILING_BACKSLASH = B_REGEXP_ERROR_BASE + 10; + B_REGEXP_CORRUPTED_PROGRAM = B_REGEXP_ERROR_BASE + 11; + B_REGEXP_MEMORY_CORRUPTION = B_REGEXP_ERROR_BASE + 12; + B_REGEXP_CORRUPTED_POINTERS = B_REGEXP_ERROR_BASE + 13; + B_REGEXP_CORRUPTED_OPCODE = B_REGEXP_ERROR_BASE + 14; + +{------------------------------------------------------------- } +{-----Binder Errors ------------------------------------------ } + + B_BINDER_MISSING_ARG = B_BINDER_ERROR_BASE; + B_BINDER_BAD_TYPE = B_BINDER_ERROR_BASE + 1; + B_BINDER_DEAD = B_BINDER_ERROR_BASE + 2; + B_BINDER_UNKNOWN_TRANSACT = B_BINDER_ERROR_BASE + 3; + B_BINDER_BAD_TRANSACT = B_BINDER_ERROR_BASE + 4; + +{------------------------------------------------------------- } +{------------------------------------------------------------- } + ENOERR = 0; + { some code assumes EOK exists } + EOK = ENOERR; + +implementation +end. diff --git a/begui/begui/imports/pascal/bebuild.pas b/begui/begui/imports/pascal/bebuild.pas new file mode 100644 index 0000000..51423a9 --- /dev/null +++ b/begui/begui/imports/pascal/bebuild.pas @@ -0,0 +1,74 @@ +unit BeBuild; +interface + +{$PACKRECORDS C} + + { + / + / File: BeBuild.h + / + / Description: Import/export macros + / + / Copyright 1993-98, Be Incorporated + / + } +//{$include } + +const + B_BEOS_VERSION_4 = $0400; + B_BEOS_VERSION_4_5 = $0450; + B_BEOS_VERSION_5 = $0500; + B_BEOS_VERSION_5_0_3 = $0503; + B_BEOS_VERSION_5_0_4 = $0504; + B_BEOS_VERSION_DANO = $0510; + B_BEOS_VERSION_MAUI = B_BEOS_VERSION_5; + B_BEOS_VERSION = B_BEOS_VERSION_5_0_3; + + { Originally, it wasn't possible to unset _R5_COMPATIBLE_, so make the + default behaviour the same. } + +{$ifdef powerc} +const + _PR2_COMPATIBLE_ = 1; + _PR3_COMPATIBLE_ = 1; + _R4_COMPATIBLE_ = 1; + _R4_5_COMPATIBLE_ = 1; + _R5_COMPATIBLE_ = 1; + _R5_0_4_COMPATIBLE_ = 1; +{$else} +const + _PR2_COMPATIBLE_ = 0; + _PR3_COMPATIBLE_ = 0; + _R4_COMPATIBLE_ = 1; + _R4_5_COMPATIBLE_ = 1; + _R5_COMPATIBLE_ = 1; + _R5_0_4_COMPATIBLE_ = 1; +{$endif} + +{ was #define dname(params) para_def_expr } +{ argument types are unknown } +{ return type might be wrong } +function _UNUSED(x : longint) : longint; + +{ was #define dname def_expr } +{ return type might be wrong } +function _PACKED : longint; + +implementation + +{ was #define dname(params) para_def_expr } +{ argument types are unknown } +{ return type might be wrong } +function _UNUSED(x : longint) : longint; +begin + _UNUSED:=x; +end; + +{ was #define dname def_expr } +{ return type might be wrong } +function _PACKED : longint; +begin + _PACKED:=__attribute__(packed); +end; + +end. diff --git a/begui/begui/imports/pascal/beutils.pas b/begui/begui/imports/pascal/beutils.pas new file mode 100644 index 0000000..64ada37 --- /dev/null +++ b/begui/begui/imports/pascal/beutils.pas @@ -0,0 +1,305 @@ +unit beutils; + +interface + +{$PACKRECORDS C} + +const + LIBROOT = 'root'; + LIBBE = 'be'; + LIBBEGUI = 'begui'; + + _BEEP_FLAGS = 0; + +{----- From types.h -------------------------------------------} +type + blkcnt_t = int64; + blksize_t = longint; + fsblkcnt_t = int64; + fsfilcnt_t = int64; + ino_t = int64; + cnt_t = longint; + mode_t = dword; + nlink_t = longint; + dev_t = longint; + off_t = int64; + pid_t = longint; + uid_t = dword; + gid_t = dword; + umode_t = dword; + daddr_t = longint; + + { bsd } + u_char = byte; + u_short = word; + u_int = dword; + u_long = dword; + + { sysv } + unchar = byte; + ushort = word; + uint = dword; + ulong = dword; + caddr_t = char; + +{--------------------------------------------------------------} +{----- From fcntl.h (posix) ----------------------------------} + +const + F_DUPFD = $0001; + F_GETFD = $0002; + F_SETFD = $0004; + F_GETFL = $0008; + F_SETFL = $0010; + F_GETLK = $0020; + F_RDLCK = $0040; + F_SETLK = $0080; + F_SETLKW = $0100; + F_UNLCK = $0200; + F_WRLCK = $0400; + +const + O_RDONLY = 0; { read only } + O_WRONLY = 1; { write only } + O_RDWR = 2; { read and write } + O_RWMASK = 3; { Mask to get open mode } + O_CLOEXEC = $0040; { close fd on exec } + O_NONBLOCK = $0080; { non blocking io } + O_EXCL = $0100; { exclusive creat } + O_CREAT = $0200; { create and open file } + O_TRUNC = $0400; { open with truncation } + O_APPEND = $0800; { to end of file } + O_NOCTTY = $1000; { currently unsupported } + O_NOTRAVERSE = $2000; { do not traverse leaf link } + O_ACCMODE = $0003; { currently unsupported } + O_TEXT = $4000; { CR-LF translation } + O_BINARY = $8000; { no translation } + +const + FD_CLOEXEC = 1; + +const + { #define O_DSYNC XXXdbg } + { #define O_RSYNC XXXdbg } + { #define O_SYNC XXXdbg } + S_IREAD = $0100; { owner may read } + S_IWRITE = $0080; { owner may write } + +type + flock = record + l_type : smallint; + l_whence : smallint; + l_start : off_t; + l_len : off_t; + l_pid : pid_t; + end; + +function creat(path:Pchar; mode:mode_t):longint;cdecl; external LIBROOT; +//function open(pathname:Pchar; oflags:longint; args:array of const):longint; cdecl; external LIBROOT; +function open(pathname:Pchar; oflags:longint):longint; cdecl; external LIBROOT; +{ the third argument is the permissions of the created file when O_CREAT is passed in oflags } +//function fcntl(fd:longint; op:longint; args: array of const):longint; cdecl; external LIBROOT; +function fcntl(fd:longint; op:longint):longint; cdecl; external LIBROOT; + +{------------------------------------------------------------- } +{----- Shorthand type formats -------------------------------- } +type + int8 = char; + uint8 = byte; + int16 = smallint; + uint16 = word; + int32 = longint; + int64 = comp; + uint32 = dword; + uint64 = qword; + uchar = byte; + unichar = word; + + //Volatile types unsupported + //-------------------------- + //typedef volatile signed char vint8; + //typedef volatile unsigned char vuint8; + //typedef volatile short vint16; + //typedef volatile unsigned short vuint16; + //typedef volatile long vint32; + //typedef volatile unsigned long vuint32; + //typedef volatile long long vint64; + //typedef volatile unsigned long long 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; + +{------------------------------------------------------------- } +{----- Descriptive formats ----------------------------------- } +type + status_t = int32; + bigtime_t = comp; + type_code = uint32; + perform_code = uint32; + +{----------------------------------------------------- } +{----- min and max comparisons ----------------------- } +{----- min() and max() won't work in C++ ------------- } +{ was #define dname(params) para_def_expr } +{ argument types are unknown } +{ return type might be wrong } + +function min_c(a,b : longint) : longint; + +{ was #define dname(params) para_def_expr } +{ argument types are unknown } +{ return type might be wrong } + +function max_c(a,b : longint) : longint; + +{ was #define dname(params) para_def_expr } +{ argument types are unknown } +{ return type might be wrong } + +function min(a,b : longint) : longint; + +{ was #define dname(params) para_def_expr } +{ argument types are unknown } +{ return type might be wrong } + +function max(a,b : longint) : longint; + +{----------------------------------------------------- } +{----- Grandfathering -------------------------------- } +type + bool = byte; + +const + bool_false = 0; + bool_true = 1; + +const + NULL = 0; + +{----LIMITS-------------------------------- } + +const + NAME_MAX = 256; + SYMLINK_MAX = 16; + MAXPATHLEN = 1024; //guess... + +const + B_FILE_NAME_LENGTH = NAME_MAX; + B_PATH_NAME_LENGTH = MAXPATHLEN; + B_ATTR_NAME_LENGTH = B_FILE_NAME_LENGTH - 1; + B_MIME_TYPE_LENGTH = B_ATTR_NAME_LENGTH - 15; + B_MAX_SYMLINKS = SYMLINK_MAX; + +{----FILE OPEN MODES-------------------------------- } + +const + B_READ_ONLY = O_RDONLY; { read only } + B_WRITE_ONLY = O_WRONLY; { write only } + B_READ_WRITE = O_RDWR; { read and write } + B_FAIL_IF_EXISTS = O_EXCL; { exclusive create } + B_CREATE_FILE = O_CREAT; { create the file } + B_ERASE_FILE = O_TRUNC; { erase the file's data } + B_OPEN_AT_END = O_APPEND; { point to the end of the data } + +{--------------------------------------------------------------- } +{----- Atomic functions; old value is returned ----------------- } + +//function atomic_add(value:Pvint32; addvalue:int32):int32;cdecl; external LIBROOT; +//function atomic_and(value:Pvint32; andvalue:int32):int32;cdecl; external LIBROOT; +//function atomic_or(value:Pvint32; orvalue:int32):int32;cdecl; external LIBROOT; + +{----- Other stuff --------------------------------------------- } +function get_stack_frame:pointer;cdecl; external LIBROOT; + +{----- From SupportDef.h ----------------------------------------} +{ unlock function, NULL if lock failed } +{ error if "unlock_func" is NULL } +{ locked object if "unlock_func" is non-NULL } +type + lock_status_t = record + unlock_func : procedure (data:pointer);cdecl; + value : record + case longint of + 0 : ( error : status_t ); + 1 : ( data : pointer ); + end; + end; + +const + BEEP_SOUND = 'Beep'; + STARTUP_SOUND = 'Startup'; + NEWEMAIL_SOUND = 'New E-mail'; + +{----- From Beep.h ----------------------------------------------} +//because of the was libbe was compiled, FPC can't link to the exported +//functions from it!! Had to wrap these to get things to work. +function beep: status_t; cdecl; external LIBBEGUI name 'beapi_beep'; +function system_beep(event_name:Pchar): status_t; cdecl; external LIBBEGUI name 'beapi_system_beep'; +function add_system_beep_event(event_name:Pchar; flags:uint32):status_t; cdecl; external LIBBEGUI name 'beapi_add_system_beep_event'; + + +implementation + +{ was #define dname(params) para_def_expr } +{ argument types are unknown } +{ return type might be wrong } +function min_c(a,b : longint) : longint; +var + if_local1 : longint; + (* result types are not known *) +begin + if b > a then + if_local1:=b + else if_local1:=a; + + min_c := if_local1; +end; + +{ was #define dname(params) para_def_expr } +{ argument types are unknown } +{ return type might be wrong } +function max_c(a,b : longint) : longint; +var + if_local1 : longint; + (* result types are not known *) +begin + if b > a then + if_local1:=a + else if_local1:=b; + + max_c := if_local1; +end; + +{ was #define dname(params) para_def_expr } +{ argument types are unknown } +{ return type might be wrong } +function min(a,b : longint) : longint; +var + if_local1 : longint; + (* result types are not known *) +begin + if b > a then + if_local1:=b + else if_local1:=a; + + min:=if_local1; +end; + +function max(a,b : longint) : longint; +var + if_local1 : longint; + (* result types are not known *) +begin + if b > a then + if_local1:=a + else if_local1:=b; + + max:=if_local1; +end; + +end. \ No newline at end of file diff --git a/begui/begui/imports/pascal/examples/testapp5.pas b/begui/begui/imports/pascal/examples/testapp5.pas new file mode 100644 index 0000000..bb17060 --- /dev/null +++ b/begui/begui/imports/pascal/examples/testapp5.pas @@ -0,0 +1,13 @@ +program testapp; + +uses + beutils; + +var + i: status_t; +begin + + i := beep; + + i := system_beep(NEWEMAIL_SOUND); +end. \ No newline at end of file diff --git a/begui/begui/imports/pascal/utf8.pas b/begui/begui/imports/pascal/utf8.pas new file mode 100644 index 0000000..6dcbd5c --- /dev/null +++ b/begui/begui/imports/pascal/utf8.pas @@ -0,0 +1,102 @@ +unit UTF8; +interface + +{$PACKRECORDS C} + + { + / + / File: UTF8.h + / + / Description: UTF-8 conversion functions. + / + / Copyright 1993-98; Be Incorporated + / + } +{------------------------------------------------------------ } +{------- Conversion Flavors --------------------------------- } + +const + B_ISO1_CONVERSION = 0; //* ISO 8859-1 */ + B_ISO2_CONVERSION = 1; //* ISO 8859-2 */ + B_ISO3_CONVERSION = 2; //* ISO 8859-3 */ + B_ISO4_CONVERSION = 3; //* ISO 8859-4 */ + B_ISO5_CONVERSION = 4; //* ISO 8859-5 */ + B_ISO6_CONVERSION = 5; //* ISO 8859-6 */ + B_ISO7_CONVERSION = 6; //* ISO 8859-7 */ + B_ISO8_CONVERSION = 7; //* ISO 8859-8 */ + B_ISO9_CONVERSION = 8; //* ISO 8859-9 */ + B_ISO10_CONVERSION = 9; //* ISO 8859-10 */ + B_ISO13_CONVERSION = 21; //* ISO 8859-13 */ + B_ISO14_CONVERSION = 22; //* ISO 8859-14 */ + B_ISO15_CONVERSION = 23; //* ISO 8859-15 */ + + B_UNICODE_CONVERSION = 15; //* Unicode 2.0 */ + B_SJIS_CONVERSION = 11; //* Shift-JIS */ + B_EUC_CONVERSION = 12; //* EUC Packed Japanese */ + B_JIS_CONVERSION = 13; //* JIS X 0208-1990 */ + B_KOI8R_CONVERSION = 16; //* KOI8-R */ + B_EUC_KR_CONVERSION = 20; //* EUC Korean */ + B_BIG5_CONVERSION = 24; //* Big5 */ + B_GBK_CONVERSION = 25; //* GBK */ + + B_MS_WINDOWS_CONVERSION = 14; //* MS-Windows Codepage 1252 */ + B_MS_WINDOWS_1250_CONVERSION = 26; //* MS-Windows Codepage 1250 */ + B_MS_WINDOWS_1251_CONVERSION = 17; //* MS-Windows Codepage 1251 */ + B_MS_WINDOWS_1252_CONVERSION = B_MS_WINDOWS_CONVERSION; + B_MS_WINDOWS_1253_CONVERSION = 27; //* MS-Windows Codepage 1253 */ + B_MS_WINDOWS_1254_CONVERSION = 28; //* MS-Windows Codepage 1254 */ + B_MS_WINDOWS_1255_CONVERSION = 29; //* MS-Windows Codepage 1255 */ + B_MS_WINDOWS_1256_CONVERSION = 30; //* MS-Windows Codepage 1256 */ + B_MS_WINDOWS_1257_CONVERSION = 31; //* MS-Windows Codepage 1257 */ + B_MS_WINDOWS_1258_CONVERSION = 32; //* MS-Windows Codepage 1258 */ + + B_MS_DOS_CONVERSION = 19; //* MS-DOS Codepage 437 */ + B_MS_DOS_437_CONVERSION = B_MS_DOS_CONVERSION; + B_MS_DOS_737_CONVERSION = 33; //* MS-DOS Codepage 737 (Greek) */ + B_MS_DOS_775_CONVERSION = 34; //* MS-DOS Codepage 775 (Baltic Rim) */ + B_MS_DOS_850_CONVERSION = 35; //* MS-DOS Codepage 850 (Latin 1) */ + B_MS_DOS_852_CONVERSION = 36; //* MS-DOS Codepage 852 (Latin 2) */ + B_MS_DOS_855_CONVERSION = 37; //* MS-DOS Codepage 855 (Cyrillic) */ + B_MS_DOS_857_CONVERSION = 38; //* MS-DOS Codepage 857 (Turkish) */ + B_MS_DOS_860_CONVERSION = 39; //* MS-DOS Codepage 860 (Portugese) */ + B_MS_DOS_861_CONVERSION = 40; //* MS-DOS Codepage 861 (Icelandic) */ + B_MS_DOS_862_CONVERSION = 41; //* MS-DOS Codepage 862 (Hebrew) */ + B_MS_DOS_863_CONVERSION = 42; //* MS-DOS Codepage 863 (French Canada) */ + B_MS_DOS_864_CONVERSION = 43; //* MS-DOS Codepage 864 (Arabic) */ + B_MS_DOS_865_CONVERSION = 44; //* MS-DOS Codepage 865 (Nordic) */ + B_MS_DOS_866_CONVERSION = 18; //* MS-DOS Codepage 866 */ + B_MS_DOS_869_CONVERSION = 45; //* MS-DOS Codepage 869 (Greek2) */ + B_MS_DOS_874_CONVERSION = 46; //* MS-DOS Codepage 874 */ + + B_MAC_ROMAN_CONVERSION = 10; //* Macintosh Roman */ + B_MAC_CENTEURO_CONVERSION = 47; //* Macintosh Central Europe */ + B_MAC_CROATIAN_CONVERSION = 48; //* Macintosh Croatian */ + B_MAC_CYRILLIC_CONVERSION = 49; //* Macintosh Cyrillic */ + B_MAC_GREEK_CONVERSION = 50; //* Macintosh Greek */ + B_MAC_HEBREW_CONVERSION = 51; //* Macintosh Hebrew */ + B_MAC_ICELAND_CONVERSION = 52; //* Macintosh Iceland */ + B_MAC_TURKISH_CONVERSION = 53; //* Macintosh Turkish */ + +{------------------------------------------------------------- } +{------- Conversion Functions -------------------------------- } +(* status_t convert_to_utf8(uint32 srcEncoding, + const char *src, + int32 *srcLen, + char *dst, + int32 *dstLen, + int32 *state, + char substitute = B_SUBSTITUTE); + +status_t convert_from_utf8(uint32 dstEncoding, + const char *src, + int32 *srcLen, + char *dst, + int32 *dstLen, + int32 *state, + char substitute = B_SUBSTITUTE); *) +{------------------------------------------------------------- } +{------------------------------------------------------------- } +implementation + + +end.