Commit 4f01233d authored by cvs2snv's avatar cvs2snv
Browse files

This commit was manufactured by cvs2svn to create tag 'init'.

parent d1f68b96
/*
Version 1.0.1
Ronny Wichers Schreur
ronny@cs.kun.nl
*/
definition module ArgEnv
:: EnvironmentVariable
= EnvironmentVariableUndefined
| EnvironmentVariable !.{#Char}
// get the value of an environment variable
getEnvironmentVariable :: !{#Char} -> *EnvironmentVariable
// get the command line, first element is the command name,
// arguments that are interpreted by the run-time system
// (for example to set the heap size) are excluded
// Clean 1.1: getCommandLine :: {{#Char}}
getCommandLine :: {.{#Char}}
implementation module ArgEnv
import code from "ArgEnvC.obj"
import StdEnv
:: CString :== Int
NULL :== 0
:: EnvironmentVariable
= EnvironmentVariableUndefined
| EnvironmentVariable !.{#Char}
getEnvSize :: !{#Char} -> Int
getEnvSize _
= code {
.inline getEnvSize
ccall ArgEnvGetEnvironmentVariableSizeC "S-I"
.end
}
copyEnv :: !Int !{#Char} -> {#.Char}
copyEnv _ _
= code {
.inline copyEnv
| Clean 1.1: use create_array
| pushC '?'
| push_b 1
| update_b 1 2
| update_b 0 1
| pop_b 1
| create_array CHAR 0 1
| Clean 1.2 and later: use create_array_
create_array_ CHAR 0 1
push_a 1
push_a 1
ccall ArgEnvGetEnvironmentVariableCharsC "SS-I"
pop_b 1
update_a 0 1
pop_a 1
.end
}
getEnvironmentVariable :: !{#Char} -> *EnvironmentVariable
getEnvironmentVariable name
| size == 0
= EnvironmentVariableUndefined
| otherwise
= EnvironmentVariable (copyEnv size name`)
where
size
= getEnvSize name`
name`
= name +++ "\0"
copy :: !Int !CString -> {#.Char}
copy length cString
= code {
.inline copy
| Clean 1.1: use create_array
| pushC '\000'
| push_b 1
| update_b 1 2
| update_b 0 1
| pop_b 1
| create_array CHAR 0 1
| Clean 1.2 and later: use create_array_
create_array_ CHAR 0 1
push_a 0
ccall ArgEnvCopyCStringToCleanStringC "IS-I"
pop_b 1
.end
}
getCommandLineCount :: Int
getCommandLineCount
= code {
.inline getCommandLineCount
ccall ArgEnvGetCommandLineCountC "-I"
.end
}
getCommandLineArgument :: !Int -> (!Int, !Int)
getCommandLineArgument _
= code {
.inline getCommandLineArgument
ccall ArgEnvGetCommandLineArgumentC "I-II"
.end
}
getArg :: !Int -> {#.Char}
getArg i
= copy size cString
where
(size, cString)
= getCommandLineArgument i
// Clean 1.1: getCommandLine :: {{#Char}}
getCommandLine :: {.{#Char}}
getCommandLine
= {getArg i \\ i <- [0 .. getCommandLineCount-1]}
ArgEnv
Version 1.0.1
Ronny Wichers Schreur
ronny@cs.kun.nl
The ArgEnv package provides a Clean interface to the command line
arguments and the environment variables.
This is the README for the Windows version. The Windows version has
been tested on Windows NT client 4.0 with Clean 1.2 & 1.3, but it
should work with all Windows versions with Clean 1.2 or better. To
use the package with Clean version 1.1 you will have to make a few
changes, which are documented in the source.
FILES
README
This file
ArgEnv.dcl
Definition of the interface
ArgEnv.icl
Implementation of the interface
ArgEnvC.c
Implementation of the C side of the interface
(You do not have to compile this file, it is included
in the modified cdebug.obj)
cdebug.obj
A modified version of cdebug.obj that includes the
C side of the ArgEnv interface
kernel_library
A modified version of kernel_library that defines
some extra symbols from kernel32.dll
printenv.icl
An example program that prints the value of an environment
variable
printenv.prj
Project file for the example program
USAGE
To use the ArgEnv interface you have to link the object module that
is created from the module ArgEnvC.c.
There is no easy way to link additional object files with the older
CleanIDEs (version 1.2 and before). Therefore I have made a new
cdebug.obj that contains the object code from ArgEnvC.c. You should
replace cdebug.obj in the Clean System Files of the StdEnv with the
cdebug.obj that comes with this release.
If you use CleanIDE 1.3 or later you can just add this extra object
file to the Object Modules section in the Options->Link Options dialogue.
If you forget this, you will get the link error:
Undefined symbols:
_ArgEnvGetEnvironmentVariableSizeC
_ArgEnvGetEnvironmentVariableCharsC
_ArgEnvCopyCStringToCleanStringC
_ArgEnvGetCommandLineCountC
_ArgEnvGetCommandLineArgumentC
The ArgEnv interface also uses two additional symbols from kernel32.dll.
You should replace kernel_library in the Clean System Files of the StdEnv
with the kernel_library that comes with this release. If you forget this,
you will get the link error:
Undefined symbols:
__imp__GetEnvironmentVariableA@12
BUGS
There is no way to stop the Clean run-time system from interpreting
some of the command-line arguments.
If you start a Clean program from the command-line prompt, you still
have to "press any key" before the program quits.
/*
Version 1.0.1
Ronny Wichers Schreur
ronny@cs.kun.nl
*/
module printenv
import StdEnv, ArgEnv
Start
| argc == 1
= format (getEnvironmentVariable argv.[1])
| otherwise
= "usage: " +++ argv.[0] +++ " <variable>\n"
where
argc
= size argv - 1
argv
= getCommandLine
format EnvironmentVariableUndefined
= ""
format (EnvironmentVariable value)
= value +++ "\n"
Project Built: Yes
Check Stacks: No
Check Indices: No
Keep ABC Files: No
Target Processor: CurrentProcessor
Heap Size: 204800
Stack Size: 40960
Extra Memory: 2048
Next Heap Size Factor: 640
Initial Heap Size: 20480
Show Execution Time: No
Show Garbage Collections: No
Print Stack Size: No
Marking Collection: Yes
Output: BasicValuesOnly
Font: MS Sans Serif
Font size: 8 points
Be verbose: No
Path: {Project};
Path:;
Module: printenv
Dir: {Project}
Font : Monaco
Font size : 9 points
Tab stop every: 4 spaces
Auto indent : Yes
Win pos x : 173
Win pos y : 200
Win size x : 646
Win size y : 300
Font : Monaco
Font size : 9 points
Tab stop every: 4 spaces
Auto indent : Yes
Win pos x : 292
Win pos y : 15
Win size x : 663
Win size y : 384
Type Checker: Yes
Strictness Analyzer: Yes
Attributes: No
Types: NoTypes
Give Warnings: No
Be Verbose: No
Generate Comments: No
Def Window Open: No
Imp Window Open: Yes
Modified: Yes 1997 11 19 10 25 15
Dependency: ArgEnv;
Dependency: StdArray;
Dependency: StdBool;
Dependency: StdChar;
Dependency: StdCharList;
Dependency: StdClass;
Dependency: StdEnum;
Dependency: StdEnv;
Dependency: StdFile;
Dependency: StdFunc;
Dependency: StdInt;
Dependency: StdList;
Dependency: StdMisc;
Dependency: StdOverloaded;
Dependency: StdReal;
Dependency: StdString;
Dependency: StdTuple;
Dependency: _SystemArray;
Dependency: _SystemEnum;
Dependency: printenv;
Dependency:;
Module: ArgEnv
Dir: {Project}
Font : Monaco
Font size : 9 points
Tab stop every: 4 spaces
Auto indent : Yes
Win pos x : 173
Win pos y : 200
Win size x : 646
Win size y : 300
Font : Monaco
Font size : 9 points
Tab stop every: 4 spaces
Auto indent : Yes
Win pos x : 73
Win pos y : 3
Win size x : 581
Win size y : 596
Type Checker: Yes
Strictness Analyzer: Yes
Attributes: No
Types: NoTypes
Give Warnings: No
Be Verbose: No
Generate Comments: No
Def Window Open: No
Imp Window Open: No
Modified: Yes 1997 11 18 21 30 24
Dependency: _SystemEnum;
Dependency: _SystemArray;
Dependency: StdTuple;
Dependency: StdString;
Dependency: StdReal;
Dependency: StdOverloaded;
Dependency: StdMisc;
Dependency: StdList;
Dependency: StdInt;
Dependency: StdFunc;
Dependency: StdFile;
Dependency: StdEnv;
Dependency: StdEnum;
Dependency: StdClass;
Dependency: StdCharList;
Dependency: StdChar;
Dependency: StdBool;
Dependency: StdArray;
Dependency: ArgEnv;
Dependency:;
Module: _SystemEnum
Dir: {Application}\StdEnv
Font : Monaco
Font size : 9 points
Tab stop every: 4 spaces
Auto indent : Yes
Win pos x : 173
Win pos y : 200
Win size x : 646
Win size y : 300
Font : Monaco
Font size : 9 points
Tab stop every: 4 spaces
Auto indent : Yes
Win pos x : 173
Win pos y : 200
Win size x : 646
Win size y : 300
Type Checker: Yes
Strictness Analyzer: Yes
Attributes: No
Types: NoTypes
Give Warnings: No
Be Verbose: No
Generate Comments: No
Def Window Open: No
Imp Window Open: No
Modified: Yes 1997 10 2 10 11 10
Dependency: _SystemEnum;
Dependency: _SystemArray;
Dependency: StdTuple;
Dependency: StdString;
Dependency: StdReal;
Dependency: StdOverloaded;
Dependency: StdMisc;
Dependency: StdList;
Dependency: StdInt;
Dependency: StdFunc;
Dependency: StdFile;
Dependency: StdEnv;
Dependency: StdEnum;
Dependency: StdClass;
Dependency: StdCharList;
Dependency: StdChar;
Dependency: StdBool;
Dependency: StdArray;
Dependency:;
Module: StdEnum
Dir: {Application}\StdEnv
Font : Monaco
Font size : 9 points
Tab stop every: 4 spaces
Auto indent : Yes
Win pos x : 173
Win pos y : 200
Win size x : 646
Win size y : 300
Font : Monaco
Font size : 9 points
Tab stop every: 4 spaces
Auto indent : Yes
Win pos x : 173
Win pos y : 200
Win size x : 646
Win size y : 300
Type Checker: Yes
Strictness Analyzer: Yes
Attributes: No
Types: NoTypes
Give Warnings: No
Be Verbose: No
Generate Comments: No
Def Window Open: No
Imp Window Open: No
Modified: Yes 1997 10 2 10 11 10
Dependency: _SystemEnum;
Dependency: StdOverloaded;
Dependency: StdInt;
Dependency: StdEnum;
Dependency: StdClass;
Dependency: StdChar;
Dependency: StdBool;
Dependency:;
Module: StdMisc
Dir: {Application}\StdEnv
Font : Monaco
Font size : 9 points
Tab stop every: 4 spaces
Auto indent : Yes
Win pos x : 173
Win pos y : 200
Win size x : 646
Win size y : 300
Font : Monaco
Font size : 9 points
Tab stop every: 4 spaces
Auto indent : Yes
Win pos x : 173
Win pos y : 200
Win size x : 646
Win size y : 300
Type Checker: Yes
Strictness Analyzer: Yes
Attributes: No
Types: NoTypes
Give Warnings: Yes
Be Verbose: No
Generate Comments: No
Def Window Open: No
Imp Window Open: No
Modified: Yes 1997 3 4 10 3 36
Dependency: StdString;
Dependency: StdOverloaded;
Dependency: StdMisc;
Dependency:;
Module: StdFunc
Dir: {Application}\StdEnv
Font : Monaco
Font size : 9 points
Tab stop every: 4 spaces
Auto indent : Yes
Win pos x : 173
Win pos y : 200
Win size x : 646
Win size y : 300
Font : Monaco
Font size : 9 points
Tab stop every: 4 spaces
Auto indent : Yes
Win pos x : 173
Win pos y : 200
Win size x : 646
Win size y : 300
Type Checker: Yes
Strictness Analyzer: Yes
Attributes: No
Types: NoTypes
Give Warnings: No
Be Verbose: No
Generate Comments: No
Def Window Open: No
Imp Window Open: No
Modified: Yes 1997 10 2 10 11 12
Dependency: StdOverloaded;
Dependency: StdMisc;
Dependency: StdInt;
Dependency: StdFunc;
Dependency: StdClass;
Dependency: StdBool;
Dependency:;
Module: StdCharList
Dir: {Application}\StdEnv
Font : Monaco
Font size : 9 points
Tab stop every: 4 spaces
Auto indent : Yes
Win pos x : 173
Win pos y : 200
Win size x : 646
Win size y : 300
Font : Monaco
Font size : 9 points
Tab stop every: 4 spaces
Auto indent : Yes
Win pos x : 173
Win pos y : 200
Win size x : 646
Win size y : 300
Type Checker: Yes
Strictness Analyzer: Yes
Attributes: No
Types: NoTypes
Give Warnings: No
Be Verbose: No
Generate Comments: No
Def Window Open: No
Imp Window Open: No
Modified: Yes 1997 10 2 10 11 12
Dependency: StdOverloaded;
Dependency: StdList;
Dependency: StdInt;
Dependency: StdClass;
Dependency: StdCharList;
Dependency: StdChar;
Dependency: StdBool;
Dependency:;
Module: _SystemArray
Dir: {Application}\StdEnv
Font : Monaco
Font size : 9 points
Tab stop every: 4 spaces
Auto indent : Yes
Win pos x : 173
Win pos y : 200
Win size x : 646
Win size y : 300
Font : Monaco
Font size : 9 points
Tab stop every: 4 spaces
Auto indent : Yes
Win pos x : 173
Win pos y : 200
Win size x : 646
Win size y : 300
Type Checker: Yes
Strictness Analyzer: Yes
Attributes: No
Types: NoTypes
Give Warnings: Yes
Be Verbose: No
Generate Comments: No
Def Window Open: No
Imp Window Open: No
Modified: Yes 1997 3 5 12 28 14
Dependency: _SystemArray;
Dependency:;
Module: StdArray
Dir: {Application}\StdEnv
Font : Monaco
Font size : 9 points
Tab stop every: 4 spaces
Auto indent : Yes
Win pos x : 173
Win pos y : 200
Win size x : 646
Win size y : 300
Font : Monaco
Font size : 9 points
Tab stop every: 4 spaces
Auto indent : Yes
Win pos x : 173
Win pos y : 200
Win size x : 646
Win size y : 300
Type Checker: Yes
Strictness Analyzer: Yes
Attributes: No
Types: NoTypes
Give Warnings: No
Be Verbose: No
Generate Comments: No
Def Window Open: No
Imp Window Open: No
Modified: Yes 1997 10 2 10 11 12
Dependency: _SystemArray;
Dependency: StdArray;
Dependency:;
Module: StdTuple
Dir: {Application}\StdEnv
Font : Monaco
Font size : 9 points
Tab stop every: 4 spaces
Auto indent : Yes
Win pos x : 173
Win pos y : 200
Win size x : 646
Win size y : 300
Font : Monaco
Font size : 9 points
Tab stop every: 4 spaces
Auto indent : Yes
Win pos x : 173
Win pos y : 200
Win size x : 646
Win size y : 300
Type Checker: Yes
Strictness Analyzer: Yes
Attributes: No
Types: NoTypes
Give Warnings: No
Be Verbose: No
Generate Comments: No
Def Window Open: No
Imp Window Open: No
Modified: Yes 1997 10 2 10 11 12
Dependency: StdTuple;
Dependency: StdOverloaded;
Dependency: StdClass;
Dependency: StdBool;
Dependency:;
Module: StdList
Dir: {Application}\StdEnv
Font : Monaco
Font size : 9 points
Tab stop every: 4 spaces
Auto indent : Yes
Win pos x : 173
Win pos y : 200
Win size x : 646
Win size y : 300
Font : Monaco
Font size : 9 points
Tab stop every: 4 spaces
Auto indent : Yes
Win pos x : 173
Win pos y : 200