# MVDBToolkit

Updated: 8/3/2020, 5:48:21 PM
Created: 8/3/2020, 5:48:21 PM
Last Updated By: Patrick Payne
Read Time: 4 minute(s)

MVDBToolkit contains a series of functions to assist in cross platform MV development. It wraps platform specific functions with toolkit specific functions. Platform differences are handled via inline includes.

# Table of Contents

Function Description
MVDBTOOLKIT.CONFIG Configuration Tool
MVDBTOOLKIT.PACKAGE.INSTALLER Package installer
MVDBTOOLKIT.WCALL Web Client Function (Curl wrapper)
MVDBTOOLKIT.WCALL.DEBUG Web Client debugging subroutine
MVDBTOOLKIT.WEXECUTE Execute O/S commands
MVDBTOOLKIT.WFILEIO Read/Write/Delete O/S commands
MVDBTOOLKIT.WGETENV Get O/S environment Variables
MVDBTOOLKIT.WPLATFORM Get Config information
MVDBTOOLKIT.SWAP Cross platform SWAP statement
MVDBTOOLKIT.TEST Test/QC program
MVSENDGRID Included SendGrid API Package

# Config Entry

A JSON configuration record is stored in the dictionary of MVDBTOOLKIT.BP called MV.PLATFORM.JSON. This item is initially populated by MVDBTOOLKIT.CONFIG. If you wish to make changes you can edit the item directly.

{
  "platform": "LINUX",      /* WINDOWS or LINUX */
  "mvtype": "D3",           /* MV type.  D3, UNIVERSE, UNIDATA, JBASE, QM */
  "filedelim": "/",         /* Platform filesystem delimiter / or \ */
  "tmpdir": "/tmp",         /* Temp directory to use */
  "curllocation": ""        /* curl binary to use */
  }
1
2
3
4
5
6
7

# Usage

All tools in MVDBTOOLKIT are utilized via Objects. Instead of passing a number of params in and out of the functions you pass a single Object. This is not unlike using a single Dynamic arra to pass info in and out of the function. At this moment the only Object type understood by MVDBTOOLKIT are WOBJ objects.

Each Function has it's own define object definition. There is very little syntax checking therefore if you are having issues it is recommended you convert your object to jSON and print out the payload.

# Example

CALL WOBJ(OBJ,"FROMSTRING","","{}","",RERR); * BLANK OBJECT
CALL WOBJ(OBJ,"SET","method","GET","",RERR); * Set method
CALL WOBJ(OBJ,"SET","url","https://api.ipify.org?format=json","",RERR); * Set url

PRINT "jSON pre call"
TOBJ=OBJ; GOSUB debug.object

CALL MVDBTOOLKIT.WCALL(OBJ)

PRINT;PRINT "jSON after call";PRINT
TOBJ=OBJ; GOSUB debug.object

STOP

debug.object: *
CALL WOBJ(TOBJ,"TOSTRING","",OUT.JSON,"PRETTIFY",RERR)
PRINT OUT.JSON
RETURN
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18

# Output

 jsh JBASEADM ~ -->TEST.JSON
pre JSON
{
  "method": "GET",
  "url": "https://api.ipify.org?format=json"
  }
jSON after call
{
  "method": "GET",
  "url": "https://api.ipify.org?format=json",
  "response": {
    "headers": {
      "Server": "Cowboy",
      "Connection": "keep-alive",
      "Content-Type": "application/json",
      "Vary": "Origin",
      "Date": "Mon, 15 Jun 2020 01:15:46 GMT",
      "Content-Length": "21",
      "Via": "1.1 vegur"
      },
    "status": 200,
    "http_type": "HTTP/1.1",
    "statusmsg": "OK",
    "log": [
      "* Rebuilt URL to: https://api.ipify.org/?format=json",
      "*   Trying 50.19.115.217...",
      "* TCP_NODELAY set",
      "* Connected to api.ipify.org (50.19.115.217) port 443 (#0)",
      "* schannel: SSL/TLS connection with api.ipify.org port 443 (step 1/3)",
      "* schannel: checking server certificate revocation",
      "* schannel: sending initial handshake data: sending 184 bytes...",
      "* schannel: sent initial handshake data: sent 184 bytes",
      "* schannel: SSL/TLS connection with api.ipify.org port 443 (step 2/3)",
      "* schannel: failed to receive handshake, need more data",
      "* schannel: SSL/TLS connection with api.ipify.org port 443 (step 2/3)",
      "* schannel: encrypted data got 3900",
      "* schannel: encrypted data buffer: offset 3900 length 4096",
      "* schannel: encrypted data length: 3806",
      "* schannel: encrypted data buffer: offset 3806 length 4096",
      "* schannel: received incomplete message, need more data",
      "* schannel: SSL/TLS connection with api.ipify.org port 443 (step 2/3)",
      "* schannel: encrypted data got 196",
      "* schannel: encrypted data buffer: offset 4002 length 4830",
      "* schannel: received incomplete message, need more data",
      "* schannel: SSL/TLS connection with api.ipify.org port 443 (step 2/3)",
      "* schannel: encrypted data got 771",
      "* schannel: encrypted data buffer: offset 4773 length 5026",
      "* schannel: sending next handshake data: sending 126 bytes...",
      "* schannel: SSL/TLS connection with api.ipify.org port 443 (step 2/3)",
      "* schannel: encrypted data got 51",
      "* schannel: encrypted data buffer: offset 51 length 5026",
      "* schannel: SSL/TLS handshake complete",
      "* schannel: SSL/TLS connection with api.ipify.org port 443 (step 3/3)",
      "* schannel: stored credential handle in session cache",
      "> GET /?format=json HTTP/1.1",
      "> Host: api.ipify.org",
      "> User-Agent: curl/7.55.1",
      "> Accept: */*",
      "> ",
      "* schannel: client wants to read 102400 bytes",
      "* schannel: encdata_buffer resized 103424",
      "* schannel: encrypted data buffer: offset 0 length 103424",
      "* schannel: encrypted data got 228",
      "* schannel: encrypted data buffer: offset 228 length 103424",
      "* schannel: decrypted data length: 199",
      "* schannel: decrypted data added: 199",
      "* schannel: decrypted data cached: offset 199 length 102400",
      "* schannel: encrypted data buffer: offset 0 length 103424",
      "* schannel: decrypted data buffer: offset 199 length 102400",
      "* schannel: schannel_recv cleanup",
      "* schannel: decrypted data returned 199",
      "* schannel: decrypted data buffer: offset 0 length 102400",
      "< HTTP/1.1 200 OK",
      "< Server: Cowboy",
      "< Connection: keep-alive",
      "< Content-Type: application/json",
      "< Vary: Origin",
      "< Date: Mon, 15 Jun 2020 01:15:46 GMT",
      "< Content-Length: 21",
      "< Via: 1.1 vegur",
      "< ",
      "{ [21 bytes data]",
      "* Connection #0 to host api.ipify.org left intact"
      ],
    "data": "{\"ip\":\"98.173.13.82\"}",
    "curl_cmnd": "curl -s -m 45 -X GET -D \"C:\\jBASE\\JBASEADM\\mvdbtoolkit\\tmp\\WCALL-1.headers\" -v --stderr \"C:\\jBASE\\JBASEADM\\mvdbtoolkit\\tmp\\WCALL-1.stderr\" \"https://api.ipify.org?format=json\""
    }
  }
jsh JBASEADM ~ -->
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