diff --git a/src/cookies/COOKIES.D b/src/cookies/COOKIES.D new file mode 100644 index 0000000..08c57c2 --- /dev/null +++ b/src/cookies/COOKIES.D @@ -0,0 +1,27 @@ +(**************************************************************************** + * Module: Cookies + * 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; - CompareResult = ( Before, Equal, After ); (* The sort order for Compare() *) - -(* - * Compare two CStrings and return a CompareResult - * that indicates their relative position in the sort order - * - * # Parameters: - * - strA: The first string to compare - * - strB: The second string to compare - * - * # Returns: - * An integer, which is - * - less than zero, if strA is before strB in the sort order - * - zero if both strings are identical - * - greater than zero, if str - *) -PROCEDURE Compare(strA, strB : CString) : CompareResult; - -(* - * Concatanates two strings, and returns a new string, that contains of both - * strings. - * - * # Parameters: - * - strA: The original string - * - strB: The second string to add to strA - * - * # Retruns: - * A new CString, that consists of strA followed by strB - *) -PROCEDURE Concat(strA, strB : CString) : CString; - -(* - * Checks, if the CString is NIL or the the string only contains a NULL char. - * - * # Parameters: - * - string: The string to check - * - * # Returns: - * TRUE, if the CString is NIL, or only contains the NULL character - *) -PROCEDURE IsNilOrEmpty(string : CString) : BOOLEAN; - -(* - * Returns the length of the string stored in - * the CString. - *) -PROCEDURE Length(str : CString) : LONGCARD; - -(* - * Converts the string into a dynamic ARRAY OF CHAR. - * - * # Parameters: - * - string: The string to convert - * - * # Returns: - * An ARRAY OF CHAR that contains the original string. - *) -PROCEDURE ToArray(string : CString) : ARRAY OF CHAR; - -END CStrings; - -(* vim: set filetype=modula2: set nospell: set fileformat=dos: *) diff --git a/src/cstrings.i b/src/cstrings.i deleted file mode 100644 index fb382f4..0000000 --- a/src/cstrings.i +++ /dev/null @@ -1,111 +0,0 @@ -(**************************************************************************** - * File name: CSTRINGS.I - * Created On: Sat 03 Oct 2020 03:18:19 PM CEST - * Last Modified: Tue 13 Oct 2020 05:40:24 PM CEST - * Author: Jali - **************************************************************************** - * Implementation for handling C-Like strings - ****************************************************************************) - -IMPLEMENTATION MODULE CStrings; - -FROM Storage IMPORT ALLOCATE; - -PROCEDURE Compare(strA, strB : CString) : CompareResult -BEGIN -(* $L- *) - ASSEMBLER - MOVE.L -(A3),A1 ; Read strB from the stack - MOVE.L -(A3),A0 ; Read strA from the stack - MOVE.W #1,D2 ; Preset the return value to CompareResult.Equal - Loop: - MOVE.B (A0)+,D0 ; Read a byte from strA into D0, and increase the pointer - CMP.B #0,D0 ; Check if the value is NULL - BEQ Return ; Reached the end of the first string; break - MOVE.B (A1)+,D1 ; Read a byte from strB into S1 and increase the pointer - CMP.B #0,D0 ; Check if the byte is NULL - BEQ Return ; Reached the end of the second string; break - CMP.B D0,D1 ; Compare the two values for equality - BEQ Loop ; If equal, continue with the next bytes. - MOVE.W #2,D2 ; Set the result register to ComepareResult.After - BHI Return ; Break and retrun result - MOVE.W #0,D2 ; Set the result register to CompareResult.Before - Return: - MOVE.W D2,(A3)+ ; Push the result to the stack - END; -(* $L+ *) -END Compare; - -PROCEDURE CopyMem(src, tgt : CString, len : CARDINAL) -BEGIN -(* $L- *) - ASSEMBLER - MOVE.W -(A3),D1 ; Read the len parameter - MOVE.L -(A3),A1 ; Read tgt from the stack - MOVE.L -(A3),A0 ; Read src from the stack - BRA Entry ; Forces the loop condition to be checked before - ; anything else. Cheaper than decrementing D1 - Loop: - MOVE.B (A0)+,D0 ; Read a byte from src into D0, and increase the pointer - MOVE.B D0,(A1)+ ; Copy the byte into the target buffer - Entry: - DBF D1,Loop ; Decrement the counter and branch to loop, until done - END; -(* $L+ *) -END CopyStr; - -PROCEDURE Concat(strA, strB : CString) : CString - VAR - r : POINTER TO CHAR; - lenA : LONGCARD; - lenB : LONGCARD; -BEGIN - lenA := Length(strA); - lenB := Length(strB); - ALLOCATE(r, lenA + lenB + 1); - CopyMem(r, strA, lenA); - CopyMem(r + lenA, strB, lenB); - CopyMem(r + lenA + lenB, ASC(0), 1); - RETURN r; -END Concat; - -PROCEDURE IsNilOrEmpty(string : CString) : BOOLEAN -BEGIN - (* $L- *) - ASSEMBLER - MOVE.L -(A3),A0 ; Get the parameter - MOVE.W #0,D1 ; Set the result value to false - CMP.L #0,A0 ; Is address == NULL? - BEQ IsNil ; We have to return TRUE here - CMP.B #0,(A0) ; Is the value of the parameter also NULL? - BEQ IsNil ; Set the return value to TRUE - BRA End ; Otherwise, return FALSE - IsNil: - MOVE.W #1,D1 ; Set result TRUE - End: - MOVE.W D1,(A3)+ - END; - (* $L+ *) -END IsNilOrEmpty; - -PROCEDURE Length(string : CString) : LONGCARD -BEGIN - (* $L- *) - ASSEMBLER - MOVE.L -(A3),A0 ; Get the address of the string - MOVE.L #0,D1 ; Set the return value to 0 - Loop: - MOVE.B (A0)+,D0 ; Load the value from (A0) - CMP.B #0,D0 ; Check if D0 is NULL - BEQ End ; Jump to the end, when end of string is reached - ADDI #1,D1 ; Increase the result value - BRA Loop ; Continue the loop - End: - MOVE.L D1,(A3)+ ; Push the result onto the stack - END - (* $L+ *) -END Length; - -END CStrings; - -(* vim: set filetype=modula2: set nospell: set fileformat=dos: *) diff --git a/src/transprt.d b/src/transprt.d deleted file mode 100644 index cab1339..0000000 --- a/src/transprt.d +++ /dev/null @@ -1,38 +0,0 @@ -(**************************************************************************** - * File name: TRANSPRT.D - * Created On: Fri 02 Oct 2020 07:27:00 PM CEST - * Last Modified: Tue 13 Oct 2020 12:43:09 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: set nospell: set fileformat=dos: *) diff --git a/src/transprt.i b/src/transprt.i deleted file mode 100644 index 58717b8..0000000 --- a/src/transprt.i +++ /dev/null @@ -1,2 +0,0 @@ - -(* vim: set filetype=modula2: set nospell: set fileformat=dos: *)