Publish VCC Plus OSS source distribution for 3.6.2 build 60
This commit is contained in:
commit
c652a5276d
1192 files changed
+272368
No files matched your search
@@ -0,0 +1,16 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
#ifndef VCC_COMPAT_CTYPE_H
|
||||
#define VCC_COMPAT_CTYPE_H
|
||||
|
||||
// The CMOC runtime supplies isalnum, isalpha, isdigit, isspace, tolower and toupper.
|
||||
#include <cmoc.h>
|
||||
int isblank(int c);
|
||||
int iscntrl(int c);
|
||||
int isgraph(int c);
|
||||
int islower(int c);
|
||||
int isprint(int c);
|
||||
int ispunct(int c);
|
||||
int isupper(int c);
|
||||
int isxdigit(int c);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
// Both include orders leave CMOC's legacy rewind(FileDesc *) available.
|
||||
#ifndef VCC_COMPAT_DISK_H
|
||||
#define VCC_COMPAT_DISK_H
|
||||
|
||||
#ifdef VCC_COMPAT_STDIO_H
|
||||
#undef rewind
|
||||
#endif
|
||||
#include "../../disk.h"
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,10 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
#ifndef VCC_COMPAT_ERRNO_H
|
||||
#define VCC_COMPAT_ERRNO_H
|
||||
|
||||
// Foreground guest error indicator for strtol and strtoul.
|
||||
extern int errno;
|
||||
#define EINVAL 22
|
||||
#define ERANGE 34
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,27 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
#ifndef VCC_COMPAT_LIMITS_H
|
||||
#define VCC_COMPAT_LIMITS_H
|
||||
|
||||
#define CHAR_BIT 8
|
||||
#define SCHAR_MIN (-127 - 1)
|
||||
#define SCHAR_MAX 127
|
||||
#define UCHAR_MAX 255U
|
||||
#ifdef _CMOC_unsigned_char_
|
||||
#define CHAR_MIN 0
|
||||
#define CHAR_MAX UCHAR_MAX
|
||||
#else
|
||||
#define CHAR_MIN SCHAR_MIN
|
||||
#define CHAR_MAX SCHAR_MAX
|
||||
#endif
|
||||
#define SHRT_MIN (-32767 - 1)
|
||||
#define SHRT_MAX 32767
|
||||
#define USHRT_MAX 65535U
|
||||
#define INT_MIN SHRT_MIN
|
||||
#define INT_MAX SHRT_MAX
|
||||
#define UINT_MAX USHRT_MAX
|
||||
#define LONG_MIN (-2147483647L - 1L)
|
||||
#define LONG_MAX 2147483647L
|
||||
#define ULONG_MAX 4294967295UL
|
||||
#define MB_LEN_MAX 1
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,9 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
#ifndef VCC_COMPAT_STDDEF_H
|
||||
#define VCC_COMPAT_STDDEF_H
|
||||
|
||||
// Reuse CMOC's definitions of size_t, NULL and offsetof.
|
||||
#include <cmoc.h>
|
||||
typedef signed int ptrdiff_t;
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,41 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
#ifndef VCC_COMPAT_STDINT_H
|
||||
#define VCC_COMPAT_STDINT_H
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
// coco.h uses the same guard and types for its exact-width declarations.
|
||||
#ifndef _CMOC_STDINT_
|
||||
#define _CMOC_STDINT_
|
||||
typedef signed char int8_t;
|
||||
typedef unsigned char uint8_t;
|
||||
typedef signed int int16_t;
|
||||
typedef unsigned int uint16_t;
|
||||
typedef signed long int32_t;
|
||||
typedef unsigned long uint32_t;
|
||||
#endif
|
||||
|
||||
typedef signed int intptr_t;
|
||||
typedef unsigned int uintptr_t;
|
||||
typedef signed long intmax_t;
|
||||
typedef unsigned long uintmax_t;
|
||||
#define INT8_MIN SCHAR_MIN
|
||||
#define INT8_MAX SCHAR_MAX
|
||||
#define UINT8_MAX UCHAR_MAX
|
||||
#define INT16_MIN INT_MIN
|
||||
#define INT16_MAX INT_MAX
|
||||
#define UINT16_MAX UINT_MAX
|
||||
#define INT32_MIN LONG_MIN
|
||||
#define INT32_MAX LONG_MAX
|
||||
#define UINT32_MAX ULONG_MAX
|
||||
#define INTPTR_MIN INT_MIN
|
||||
#define INTPTR_MAX INT_MAX
|
||||
#define UINTPTR_MAX UINT_MAX
|
||||
#define INTMAX_MIN LONG_MIN
|
||||
#define INTMAX_MAX LONG_MAX
|
||||
#define UINTMAX_MAX ULONG_MAX
|
||||
#ifndef SIZE_MAX
|
||||
#define SIZE_MAX 0xFFFFu
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,80 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
#ifndef VCC_COMPAT_STDIO_H
|
||||
#define VCC_COMPAT_STDIO_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdarg.h>
|
||||
#define EOF (-1)
|
||||
#define SEEK_SET 0
|
||||
#define SEEK_CUR 1
|
||||
#define SEEK_END 2
|
||||
|
||||
// %% %c %s %d %i %u %o %x %X. Integer forms also accept l. A decimal
|
||||
// width, left alignment, zero padding, and string/integer precision are
|
||||
// supported. Return the full length, or -1 for unsupported formats or lengths
|
||||
// above INT_MAX. If capacity is positive the prefix is always NUL terminated.
|
||||
// A null destination is allowed when capacity is zero. Input and output must
|
||||
// not overlap.
|
||||
int snprintf(char *dest, size_t capacity, const char *format, ...);
|
||||
int vsnprintf(char *dest, size_t capacity, const char *format, va_list args);
|
||||
|
||||
// Two foreground Disk BASIC streams. Names use 8.3 format with an optional
|
||||
// :0 through :3 drive suffix (default :0). Modes r, w and a read, truncate
|
||||
// and append respectively; w/a create missing files. Append b for binary.
|
||||
// Add + for both input and output. r+ requires an existing file. w+ creates
|
||||
// or truncates; a+ creates or preserves. All three start reading at byte zero.
|
||||
// Every a+ write appends, even after a seek. Both +b and b+ select binary.
|
||||
// After input, seek or rewind before writing unless input encountered EOF.
|
||||
// Flush, seek or rewind between output and input.
|
||||
// Text reads fold CR, LF and CRLF to C newline; text writes C newline as CR.
|
||||
// Close streams before changing mounted media or writing through another API.
|
||||
typedef struct VCCFile FILE;
|
||||
FILE *fopen(const char *path, const char *mode);
|
||||
int fclose(FILE *stream);
|
||||
// Disk BASIC file management uses the same paths as fopen. Close participating
|
||||
// files first. rename stays on one drive and refuses an existing destination,
|
||||
// including an alias of the source. remove releases the file's granules.
|
||||
// Both return 0 on success or EOF on failure; inspect vcc_file_error().
|
||||
int rename(const char *oldPath, const char *newPath);
|
||||
int remove(const char *path);
|
||||
int fgetc(FILE *stream);
|
||||
char *fgets(char *dest, int capacity, FILE *stream);
|
||||
size_t fread(void *dest, size_t size, size_t count, FILE *stream);
|
||||
// Same conversions and length limit as snprintf. Return the number of bytes
|
||||
// accepted or a negative value on error. A prefix may already be written.
|
||||
// Check fflush or fclose for delayed disk errors.
|
||||
int fprintf(FILE *stream, const char *format, ...);
|
||||
int vfprintf(FILE *stream, const char *format, va_list args);
|
||||
int fputc(int c, FILE *stream);
|
||||
int fputs(const char *text, FILE *stream);
|
||||
size_t fwrite(const void *source, size_t size, size_t count, FILE *stream);
|
||||
// Publish data and the file's exact length. A fresh reader can open the file
|
||||
// while the writer remains open. Pass NULL to flush all open output streams.
|
||||
// Returns 0 on success or EOF on failure. Check fclose for delayed errors.
|
||||
int fflush(FILE *stream);
|
||||
// Positions are 32-bit offsets in the guest file. Binary streams support
|
||||
// signed offsets from any origin within the existing file. In text mode
|
||||
// restore an ftell bookmark with SEEK_SET, or use zero with any origin.
|
||||
// Seeking flushes pending output. The next append write still goes to EOF.
|
||||
long ftell(FILE *stream);
|
||||
int fseek(FILE *stream, long offset, int origin);
|
||||
// With <stdio.h> alone, rewind is an alias for this function, including
|
||||
// when taking its address. In a file that also includes CMOC's <disk.h>,
|
||||
// rewind keeps its FileDesc meaning; use vcc_rewind for a FILE stream.
|
||||
// A successful rewind clears EOF and errors. Check ferror after a retry.
|
||||
void vcc_rewind(FILE *stream);
|
||||
#ifndef _H_disk
|
||||
#define rewind vcc_rewind
|
||||
#endif
|
||||
int feof(FILE *stream);
|
||||
int ferror(FILE *stream);
|
||||
// Clear this open stream's EOF and error indicators. The position, pending
|
||||
// bytes and last I/O direction are preserved. To retry a failed flush on
|
||||
// the same disk, correct the cause, call clearerr, then call fflush again.
|
||||
void clearerr(FILE *stream);
|
||||
|
||||
// The latest failure (including a failed fopen). A successful fopen resets
|
||||
// this value to DECB_OK. See <decbfile.h> for DECB_ERR_* values.
|
||||
unsigned char vcc_file_error(void);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,32 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
#ifndef VCC_COMPAT_STDLIB_H
|
||||
#define VCC_COMPAT_STDLIB_H
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
// stddef.h has already included cmoc.h. Replace its decimal-only macros in
|
||||
// this opt-in header, leaving the explicitly named CMOC routines available.
|
||||
#undef strtol
|
||||
#undef strtoul
|
||||
long strtol(const char *text, char **endptr, int base);
|
||||
unsigned long strtoul(const char *text, char **endptr, int base);
|
||||
|
||||
// Supply a writable guest array (at least 16 bytes) that stays at the same
|
||||
// address for the lifetime of the heap. Its one-past-end address must fit in
|
||||
// 16 bits. Return 1 on success or 0 if invalid or any allocation is live.
|
||||
// A rejected initialization leaves the current heap and its contents intact.
|
||||
int vcc_heap_init(void *buffer, size_t capacity);
|
||||
|
||||
// Zero-size requests return NULL. Allocation can also fail before initialization
|
||||
// or when no contiguous block fits. calloc checks for multiplication overflow.
|
||||
void *malloc(size_t size);
|
||||
void *calloc(size_t count, size_t size);
|
||||
|
||||
// Growth may move the block. If it fails, the old allocation stays valid.
|
||||
// Shrinking keeps the existing block. realloc(ptr, 0) releases it.
|
||||
void *realloc(void *ptr, size_t size);
|
||||
|
||||
// Accepts NULL or a live pointer returned by this heap.
|
||||
void free(void *ptr);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,15 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
#ifndef VCC_COMPAT_STRING_H
|
||||
#define VCC_COMPAT_STRING_H
|
||||
|
||||
// CMOC declares the byte and string operations, including memmove, strchr,
|
||||
// strcmp and strtok, in its runtime header. Use those same declarations.
|
||||
#include <cmoc.h>
|
||||
|
||||
// POSIX extension. Start with a writable string, then pass NULL to continue.
|
||||
// Give each active scan its own char * and pass its address on every call.
|
||||
// Tokens share the input buffer. Separators are skipped and each delimiter
|
||||
// that ends a returned token becomes a zero byte.
|
||||
char *strtok_r(char *text, const char *delimiters, char **saveptr);
|
||||
|
||||
#endif
|
||||
Reference in new issue
Block a user