Added code for c-style strings

This commit is contained in:
2020-10-02 19:47:17 +02:00
parent da07023406
commit 9ebae92371
4 changed files with 81 additions and 0 deletions

40
src/cstrings.d Normal file
View File

@@ -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 <jali@orca-central.de>
****************************************************************************
* 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: *)

1
src/cstrings.i Normal file
View File

@@ -0,0 +1 @@
(* vim: set filetype=modula2: *)

38
src/transprt.d Normal file
View File

@@ -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 <jali@orca-central.de>
****************************************************************************
* 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: *)

2
src/transprt.i Normal file
View File

@@ -0,0 +1,2 @@
(* vim: set filetype=modula2: *)