forked from patrickTingen/DataDigger
-
Notifications
You must be signed in to change notification settings - Fork 0
/
getVersionInfo.p
52 lines (38 loc) · 2.01 KB
/
getVersionInfo.p
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
/*------------------------------------------------------------------------
File : getVersionInfo.p
Desc : Give back latest versions from DataDigger on GitHub
Notes:
The version nr is increased when it is ready for production, the
build nr is increaded when something is ready for beta testing.
----------------------------------------------------------------------*/
DEFINE OUTPUT PARAMETER pcVersion AS CHARACTER NO-UNDO.
DEFINE OUTPUT PARAMETER pcBuildNr AS CHARACTER NO-UNDO.
FUNCTION getRemoteFile RETURNS CHARACTER (pcRemoteFile AS CHARACTER) FORWARD.
pcVersion = getRemoteFile('https://raw.githubusercontent.com/patrickTingen/DataDigger/master/version.i').
pcBuildNr = getRemoteFile('https://raw.githubusercontent.com/patrickTingen/DataDigger/master/build.i').
pcVersion = TRIM(pcVersion).
pcBuildNr = TRIM(pcBuildNr).
/* ---------- implementation ---------- */
PROCEDURE URLDownloadToFileA EXTERNAL "URLMON.DLL" :
DEFINE INPUT PARAMETER pCaller AS LONG.
DEFINE INPUT PARAMETER szURL AS CHARACTER.
DEFINE INPUT PARAMETER szFilename AS CHARACTER.
DEFINE INPUT PARAMETER dwReserved AS LONG.
DEFINE INPUT PARAMETER lpfnCB AS LONG.
DEFINE RETURN PARAMETER ReturnValue AS LONG.
END PROCEDURE. /* URLDownloadToFileA */
PROCEDURE DeleteUrlCacheEntry EXTERNAL "WININET.DLL" :
DEFINE INPUT PARAMETER lbszUrlName AS CHARACTER.
END PROCEDURE. /* DeleteUrlCacheEntry */
FUNCTION getRemoteFile RETURNS CHARACTER (pcRemoteFile AS CHARACTER):
DEFINE VARIABLE cLocalFile AS CHARACTER NO-UNDO.
DEFINE VARIABLE cContents AS LONGCHAR NO-UNDO.
DEFINE VARIABLE iResult AS INTEGER NO-UNDO.
cLocalFile = SESSION:TEMP-DIR + 'VersionInfo.txt'.
OS-DELETE cLocalFile.
RUN DeleteURLCacheEntry (INPUT pcRemoteFile).
RUN urlDownloadToFileA (0, pcRemoteFile, cLocalFile, 0, 0, OUTPUT iResult).
IF SEARCH(cLocalFile) <> ? THEN
COPY-LOB FILE cLocalFile TO cContents.
RETURN STRING(cContents).
END FUNCTION. /* getRemoteFile */