-
Notifications
You must be signed in to change notification settings - Fork 3
/
support.e
191 lines (141 loc) · 3.68 KB
/
support.e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
-> ECX/support.e
/* ECX by Leif Salomonsson [ecx tele2 se] is Copyright (c) 2002-2008 */
/* Released under the ECX COMPILER LICENSE, See ECXCOMPILERLICENSE.TXT */
OPT MODULE
OPT PREPROCESS
MODULE 'utility' -> v55
MODULE 'utility/date' -> v55
MODULE 'dos/datetime' -> 1.8.0
MODULE 'dos/dos'
DEF utilitybase
#ifndef ECX_VERSION
MODULE 'mathieeedoubtrans'
DEF mathieeedoubtransbase
EXPORT PROC initSupport()
mathieeedoubtransbase := OpenLibrary('mathieeedoubtrans.library', 37)
IF mathieeedoubtransbase = NIL THEN Throw("LIB", 'mathieeedoubtrans.library')
utilitybase := OpenLibrary('utility.library', 39)
IF utilitybase = NIL THEN Throw("LIB", 'utility.library')
ENDPROC
EXPORT PROC endSupport()
IF utilitybase THEN CloseLibrary(utilitybase) -> v55
IF mathieeedoubtransbase THEN CloseLibrary(mathieeedoubtransbase)
ENDPROC
EXPORT PROC singToDoub(sing)
DEF x, y
x, y := IeeeDPFieee(sing)
ENDPROC x, y
#endif /* ECX_VERSION */
#ifdef ECX_VERSION
#ifdef __AMIGAOS4__
DEF utilityiface
#endif
EXPORT PROC initSupport()
utilitybase := OpenLibrary('utility.library', 39)
IF utilitybase = NIL THEN Throw("LIB", 'utility.library')
#ifdef __AMIGAOS4__
utilityiface := GetInterface(utilitybase, 'main', 1, NIL)
IF utilityiface = NIL THEN Throw("LIB", 'utility.library->interface')
#endif
ENDPROC
EXPORT PROC endSupport()
#ifdef __AMIGAOS4__
IF utilityiface THEN DropInterface(utilityiface)
#endif
IF utilitybase THEN CloseLibrary(utilitybase) -> v55
ENDPROC
EXPORT PROC singToDoub(sing)
DEF d:DOUBLE
d := sing
ENDPROC Long({d}), Long({d}+4) -> fixed 1.8.2
#endif /* ECX_VERSION */
EXPORT PROC writeNewExeFile(buf,size, name) HANDLE
DEF fh=NIL
fh := Open(name, NEWFILE)
IF fh = NIL THEN Raise("OPEN")
IF Write(fh, buf, size) <> size THEN Raise("WRIT")
EXCEPT DO
IF fh THEN Close(fh)
IF exception
RETURN NIL
ELSE
-> os4's JXFS does not set e bit by default
SetProtection(name, NIL)
ENDIF
ENDPROC size
EXPORT PROC writeNewFile(buf,size, name) HANDLE
DEF fh=NIL
fh := Open(name, NEWFILE)
IF fh = NIL THEN Raise("OPEN")
IF Write(fh, buf, size) <> size THEN Raise("WRIT")
EXCEPT DO
IF fh THEN Close(fh)
IF exception THEN RETURN NIL
ENDPROC size
-> 2.0
EXPORT PROC makeVersiondateStr(estr)
DEF dt:datetime, s
DEF buf[100]:ARRAY
DateStamp(dt)
dt.flags := NIL
dt.strday := NIL
dt.strdate := buf+2
dt.strtime := NIL
buf[0] := "'"
buf[1] := "("
dt.format := FORMAT_CDN
IF DateToStr(dt)
s := buf
s := s + InStr(s, '-')
s[]++ := "."
s := s + InStr(s, '-')
s[]++ := "."
s[3] := s[1]
s[2] := s[0]
s[0] := "2"
s[1] := "0"
s[4] := ")"
s[5] := "'"
s[6] := NIL
StrCopy(estr, buf)
ELSE
SetStr(estr, 0)
ENDIF
ENDPROC
EXPORT PROC makeDateStr(estr)
DEF dt:datetime, s
DEF buf[100]:ARRAY
DateStamp(dt)
dt.flags := NIL
dt.strday := NIL
dt.strdate := buf+1
dt.strtime := NIL
buf[0] := "'"
dt.format := FORMAT_DOS
IF DateToStr(dt)
s := buf
s := s + InStr(s, '-') + 1
s := s + InStr(s, '-') + 1
s[3] := s[1]
s[2] := s[0]
s[0] := "2"
s[1] := "0"
s[4] := "'"
s[5] := NIL
StrCopy(estr, buf)
ELSE
SetStr(estr, 0)
ENDIF
ENDPROC
EXPORT PROC makeTimeStr(estr)
DEF secs
DEF cd:clockdata
secs := getSeconds()
Amiga2Date(secs, cd)
StringF(estr, '\a\z\d[2]:\z\d[2]:\z\d[2]\a', cd.hour, cd.min, cd.sec)
ENDPROC
PROC getSeconds()
DEF seconds,now:datestamp
DateStamp(now) -> datestamp datum
seconds := Mul(now.days, 86400) + Mul(now.minute, 60) + Div(now.tick, TICKS_PER_SECOND)
ENDPROC seconds