Change concept
This commit is contained in:
27
src/cookies/COOKIES.D
Normal file
27
src/cookies/COOKIES.D
Normal file
@@ -0,0 +1,27 @@
|
||||
(****************************************************************************
|
||||
* Module: Cookies
|
||||
* Author: jali <jali@orca-central.de
|
||||
* Created On: Sun 01 Nov 2020 05:45:06 PM CET
|
||||
* Last Modified: Sun 01 Nov 2020 05:45:06 PM CET
|
||||
* Description: Cookiejar code, based on toshyp.atari.org
|
||||
****************************************************************************)
|
||||
|
||||
DEFINITION MODULE Cookies;
|
||||
|
||||
(*
|
||||
* Basic structure for a a cookie-jar.
|
||||
* Defines an entry in the jar.
|
||||
*)
|
||||
TYPE CookieJar = RECORD
|
||||
id : LONGCARD;
|
||||
value : LONGCARD;
|
||||
END;
|
||||
|
||||
(*
|
||||
* Finds and returns the cookie from the system cookie jar.
|
||||
*)
|
||||
PROCEDURE GetCookie(cookieId : LONGCARD, VAR value : LONGCARD) : BOOLEAN;
|
||||
|
||||
END Cookies.
|
||||
|
||||
(* vim: set filetype=modula2: set nospell: set fileformat=dos: *)
|
||||
29
src/cookies/COOKIES.I
Normal file
29
src/cookies/COOKIES.I
Normal file
@@ -0,0 +1,29 @@
|
||||
(****************************************************************************
|
||||
* Module: Cookies
|
||||
* Author: jali <jali@orca-central.de
|
||||
* Created On: Sun 01 Nov 2020 05:58:31 PM CET
|
||||
* Last Modified: Sun 01 Nov 2020 05:58:31 PM CET
|
||||
* Description: Cookiejar code, based on toshyp.atari.org
|
||||
****************************************************************************)
|
||||
|
||||
IMPLEMENTATION MODULE Cookies;
|
||||
|
||||
(*
|
||||
* Finds and returns the cookie from the system cookie jar.
|
||||
*)
|
||||
PROCEDURE GetCookie(cookieId : LONGCARD, VAR value : LONGCARD) : BOOLEAN
|
||||
VAR
|
||||
jar : POINTER TO CookieJar;
|
||||
val : LONGCARD;
|
||||
i : LONGCARD;
|
||||
|
||||
BEGIN
|
||||
val = 0;
|
||||
jar := Setexc(0x5A0/4) (* What exactly does this do? *)
|
||||
IF jar != NIL THEN
|
||||
|
||||
END;
|
||||
END Cookies;
|
||||
|
||||
(* vim: set filetype=modula2: set nospell: set fileformat=dos: *)
|
||||
|
||||
@@ -1,84 +0,0 @@
|
||||
(****************************************************************************
|
||||
* File name: CSTRINGS.D
|
||||
* Created On: Fri 02 Oct 2020 07:27:00 PM CEST
|
||||
* Last Modified: Tue 13 Oct 2020 05:15:30 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;
|
||||
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: *)
|
||||
111
src/cstrings.i
111
src/cstrings.i
@@ -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 <jali@orca-central.de>
|
||||
****************************************************************************
|
||||
* 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: *)
|
||||
@@ -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 <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: set nospell: set fileformat=dos: *)
|
||||
@@ -1,2 +0,0 @@
|
||||
|
||||
(* vim: set filetype=modula2: set nospell: set fileformat=dos: *)
|
||||
Reference in New Issue
Block a user