diff --git a/src/cstrings.d b/src/cstrings.d new file mode 100644 index 0000000..1134b36 --- /dev/null +++ b/src/cstrings.d @@ -0,0 +1,40 @@ +(**************************************************************************** + * File name: CSTRINGS.D + * Created On: Fri 02 Oct 2020 07:27:00 PM CEST + * Last Modified: Fri 02 Oct 2020 07:46:49 PM CEST + * Author: Jali + **************************************************************************** + * Header file for an implementation of C-Like strings + ****************************************************************************) + +DEFINITION MODULE CStrings; + +(* + * The base data type is a POINTER TO CHAR, that is equal + * to the C own char* type. + * This type must be NULL-terminated. + *) + +CONST + NULL = CHR(0); + +TYPE + CString : POINTER TO CHAR; + +PROCEDURE Length(str : CString) : LONGCARD + VAR + count : LONGCARD; + countPtr : POINTER TO CHAR; +BEGIN + count = 0; + countPtr = str; + WHILE (countPtr^ <> NULL) BEGIN + count += 1; + END; (* WHILE *) + + RETURN count; +END Length; + +END CStrings; + +(* vim: set filetype=modula2: set nospell: *) diff --git a/src/cstrings.i b/src/cstrings.i new file mode 100644 index 0000000..9a42203 --- /dev/null +++ b/src/cstrings.i @@ -0,0 +1 @@ +(* vim: set filetype=modula2: *) diff --git a/src/transprt.d b/src/transprt.d new file mode 100644 index 0000000..c08569b --- /dev/null +++ b/src/transprt.d @@ -0,0 +1,38 @@ +(**************************************************************************** + * File name: TRANSPRT.D + * Created On: Fri 02 Oct 2020 07:27:00 PM CEST + * Last Modified: Fri 02 Oct 2020 07:27:23 PM CEST + * Author: Jali + **************************************************************************** + * Header file for all STinG releated source files + ****************************************************************************) + +DEFINITION MODULE Transport; + +(* + * Declare a BOOLEAN type, that is compatible to + * the C-declaration. This implements BOOLEAN as + * a 16 bit signed integer, which is returned + * the STinG call blocks. + * It also ensures this code runs with different + * MODULA2 compilers. + *) + +CONST False = 0; +CONST True = 1; + +TYPE BOOL = [False..True]; + +(* Driver access structure and functions *) +CONST MAGIC = "STiKmagic"; (* Magic for DRV_LIST.magic *) +CONST CJTAG = "STiK"; + +TYPE + DRV_HEADER = RECORD + Module : POINTER TO CHAR; + Author : POINTER TO CHAR + END (* RECORD *) + +END Transport. + +(* vim: set filetype=modula2: *) diff --git a/src/transprt.i b/src/transprt.i new file mode 100644 index 0000000..906c467 --- /dev/null +++ b/src/transprt.i @@ -0,0 +1,2 @@ + +(* vim: set filetype=modula2: *)