vsam.js 3.0.1 → 3.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/VsamFile.cpp +43 -40
- package/VsamFile.h +21 -21
- package/VsamThread.cpp +4 -1
- package/WrappedVsam.cpp +11 -7
- package/binding.gyp +10 -5
- package/package.json +3 -3
- package/vsam.cpp +4 -2
- package/o +0 -1225
package/VsamFile.cpp
CHANGED
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* Licensed Materials - Property of IBM
|
|
3
|
-
* (C) Copyright IBM Corp. 2017,
|
|
3
|
+
* (C) Copyright IBM Corp. 2017, 2022. All Rights Reserved.
|
|
4
4
|
* US Government Users Restricted Rights - Use, duplication or disclosure
|
|
5
5
|
* restricted by GSA ADP Schedule Contract with IBM Corp.
|
|
6
6
|
*/
|
|
7
|
-
#include
|
|
8
|
-
#include "VsamThread.h"
|
|
7
|
+
#include <assert.h>
|
|
9
8
|
#include <dynit.h>
|
|
9
|
+
#include <unistd.h>
|
|
10
|
+
|
|
11
|
+
#include <algorithm>
|
|
10
12
|
#include <numeric>
|
|
11
13
|
#include <sstream>
|
|
12
|
-
|
|
14
|
+
|
|
15
|
+
#include "VsamFile.h"
|
|
16
|
+
#include "VsamThread.h"
|
|
17
|
+
|
|
13
18
|
|
|
14
19
|
// VSAM register 15 for interpreting some of the errors:
|
|
15
20
|
// https://www.ibm.com/support/knowledgecenter/SSB27H_6.2.0/fa2mc2_vsevsam_return_and_error_codes.html
|
|
@@ -18,6 +23,8 @@
|
|
|
18
23
|
static std::string &createErrorMsg(std::string &errmsg, int err, int err2,
|
|
19
24
|
int r15, const std::string &errPrefix);
|
|
20
25
|
|
|
26
|
+
#if 0
|
|
27
|
+
// Currently not used, but keep it in case it's needed.
|
|
21
28
|
static void print_amrc() {
|
|
22
29
|
__amrc_type currErr = *__amrc;
|
|
23
30
|
printf("R15 value = %d\n", currErr.__code.__feedback.__rc);
|
|
@@ -25,10 +32,11 @@ static void print_amrc() {
|
|
|
25
32
|
printf("RBA = %d\n", currErr.__RBA);
|
|
26
33
|
printf("Last op = %d\n", currErr.__last_op);
|
|
27
34
|
}
|
|
35
|
+
#endif
|
|
28
36
|
|
|
29
37
|
int VsamFile::freadRecord(UvWorkData *pdata, int *pr15, bool expectEOF,
|
|
30
38
|
const char *pDisplayPrefix, const char *pErrPrefix) {
|
|
31
|
-
|
|
39
|
+
size_t nread = fread(pdata->recbuf_, 1, reclen_, stream_);
|
|
32
40
|
*pr15 = R15;
|
|
33
41
|
if (feof(stream_)) {
|
|
34
42
|
if (expectEOF)
|
|
@@ -115,8 +123,6 @@ int VsamFile::FindExecute(UvWorkData *pdata, const char *buf, int buflen) {
|
|
|
115
123
|
|
|
116
124
|
void VsamFile::FindExecute(UvWorkData *pdata) {
|
|
117
125
|
DCHECK(pdata->rc_ != 0);
|
|
118
|
-
char *buf;
|
|
119
|
-
|
|
120
126
|
DCHECK(pdata->recbuf_ == nullptr);
|
|
121
127
|
pdata->recbuf_ = (char *)malloc(reclen_);
|
|
122
128
|
DCHECK(pdata->recbuf_ != nullptr);
|
|
@@ -134,7 +140,7 @@ void VsamFile::FindUpdateExecute(UvWorkData *pdata) {
|
|
|
134
140
|
memcpy(pupdrecbuf, pdata->recbuf_, reclen_);
|
|
135
141
|
|
|
136
142
|
pdata->rc_ = FindExecute(pdata, pdata->keybuf_, pdata->keybuf_len_);
|
|
137
|
-
int
|
|
143
|
+
int r15;
|
|
138
144
|
|
|
139
145
|
for (pdata->count_ = 0; pdata->rc_ == 0;) {
|
|
140
146
|
for (auto i = pdata->pFieldsToUpdate_->begin();
|
|
@@ -202,7 +208,7 @@ void VsamFile::FindDeleteExecute(UvWorkData *pdata) {
|
|
|
202
208
|
DCHECK(pdata->recbuf_ != nullptr);
|
|
203
209
|
|
|
204
210
|
pdata->rc_ = FindExecute(pdata, pdata->keybuf_, pdata->keybuf_len_);
|
|
205
|
-
int
|
|
211
|
+
int r15;
|
|
206
212
|
|
|
207
213
|
for (pdata->count_ = 0; pdata->rc_ == 0;) {
|
|
208
214
|
pdata->rc_ = 1;
|
|
@@ -290,16 +296,16 @@ void VsamFile::DeleteExecute(UvWorkData *pdata) {
|
|
|
290
296
|
}
|
|
291
297
|
|
|
292
298
|
void VsamFile::displayRecord(const char *recbuf, const char *pSuffix) {
|
|
293
|
-
int
|
|
299
|
+
int pos = 0;
|
|
294
300
|
fprintf(stderr, "REC=|");
|
|
295
301
|
for (auto l = layout_.begin(); l != layout_.end(); ++l) {
|
|
296
302
|
// fprintf(stderr, "%s:", l->name.c_str());
|
|
297
303
|
if (l->type == LayoutItem::HEXADECIMAL) {
|
|
298
|
-
for (i = 0; i < l->maxLength; i++, pos++)
|
|
304
|
+
for (size_t i = 0; i < l->maxLength; i++, pos++)
|
|
299
305
|
fprintf(stderr, "%02x", recbuf[pos]);
|
|
300
306
|
} else {
|
|
301
307
|
assert(l->type == LayoutItem::STRING);
|
|
302
|
-
for (i = 0; i < l->maxLength; i++, pos++)
|
|
308
|
+
for (size_t i = 0; i < l->maxLength; i++, pos++)
|
|
303
309
|
fprintf(stderr, "%c", recbuf[pos] ? recbuf[pos] : '.');
|
|
304
310
|
}
|
|
305
311
|
fprintf(stderr, "|");
|
|
@@ -317,7 +323,7 @@ void VsamFile::WriteExecute(UvWorkData *pdata) {
|
|
|
317
323
|
fprintf(stderr, "%02x ", pdata->recbuf_[i]);
|
|
318
324
|
fprintf(stderr, "\n");
|
|
319
325
|
#endif
|
|
320
|
-
|
|
326
|
+
size_t nelem = fwrite(pdata->recbuf_, 1, reclen_, stream_);
|
|
321
327
|
int r15 = R15;
|
|
322
328
|
#ifdef DEBUG
|
|
323
329
|
fprintf(stderr, "WriteExecute fwrite() wrote %d bytes, errno=%d, errno2=%d\n",
|
|
@@ -348,7 +354,7 @@ void VsamFile::UpdateExecute(UvWorkData *pdata) {
|
|
|
348
354
|
fprintf(stderr, "%02x ", pdata->recbuf_[i]);
|
|
349
355
|
fprintf(stderr, "\n");
|
|
350
356
|
#endif
|
|
351
|
-
|
|
357
|
+
size_t nbytes = fupdate(pdata->recbuf_, reclen_, stream_);
|
|
352
358
|
int r15 = R15;
|
|
353
359
|
#ifdef DEBUG
|
|
354
360
|
fprintf(stderr, "UpdateExecute fupdate() wrote %d bytes\n", nbytes);
|
|
@@ -421,11 +427,11 @@ bool VsamFile::isDatasetExist(const std::string &path, int *perr, int *perr2,
|
|
|
421
427
|
fclose(stream);
|
|
422
428
|
return true;
|
|
423
429
|
}
|
|
424
|
-
if (err2 == 0xC00B0641) {
|
|
430
|
+
if (err2 == static_cast<int>(0xC00B0641)) {
|
|
425
431
|
// 0xC00B0641 is file not found
|
|
426
432
|
return false;
|
|
427
433
|
}
|
|
428
|
-
if (err2 == 0xC00A0022) {
|
|
434
|
+
if (err2 == static_cast<int>(0xC00A0022)) {
|
|
429
435
|
// 0xC00A0022 could be if opening an empty dataset as read-only,
|
|
430
436
|
// double-check:
|
|
431
437
|
stream = fopen(dataset.c_str(), "rb+,type=record");
|
|
@@ -461,9 +467,6 @@ void VsamFile::open(UvWorkData *pdata) {
|
|
|
461
467
|
fprintf(stderr, "VsamFile: fopen(%s, %s) returned %p, tid=%d\n",
|
|
462
468
|
dsname.c_str(), omode_.c_str(), stream_, gettid());
|
|
463
469
|
#endif
|
|
464
|
-
int err = errno;
|
|
465
|
-
int err2 = __errno2();
|
|
466
|
-
|
|
467
470
|
if (stream_ == nullptr) {
|
|
468
471
|
createErrorMsg(errmsg_, errno, __errno2(), r15,
|
|
469
472
|
"open error: fopen() failed");
|
|
@@ -485,7 +488,7 @@ void VsamFile::alloc(UvWorkData *pdata) {
|
|
|
485
488
|
errmsg_ = "Dataset already exists";
|
|
486
489
|
return;
|
|
487
490
|
}
|
|
488
|
-
if (err2 != 0xC00B0641) {
|
|
491
|
+
if (err2 != static_cast<int>(0xC00B0641)) {
|
|
489
492
|
// 0xC00B0641 is file not found
|
|
490
493
|
createErrorMsg(errmsg_, err, err2, r15, "alloc error: fopen() failed");
|
|
491
494
|
return;
|
|
@@ -552,10 +555,10 @@ int VsamFile::setKeyRecordLengths(const std::string &errPrefix) {
|
|
|
552
555
|
}
|
|
553
556
|
|
|
554
557
|
VsamFile::VsamFile(const std::string &path,
|
|
555
|
-
const std::vector<LayoutItem> &layout, int key_i,
|
|
556
|
-
const std::string &omode)
|
|
557
|
-
: path_(path),
|
|
558
|
-
|
|
558
|
+
const std::vector<LayoutItem> &layout, int key_i,
|
|
559
|
+
size_t keypos, const std::string &omode)
|
|
560
|
+
: stream_(nullptr), path_(path), omode_(omode), layout_(layout), rc_(1),
|
|
561
|
+
key_i_(key_i), keypos_(keypos), keylen_(0) {
|
|
559
562
|
#ifdef DEBUG
|
|
560
563
|
fprintf(stderr, "In VsamFile constructor for %s.\n", path_.c_str());
|
|
561
564
|
#endif
|
|
@@ -599,42 +602,42 @@ void VsamFile::Close(UvWorkData *pdata) {
|
|
|
599
602
|
pdata->rc_ = 0;
|
|
600
603
|
}
|
|
601
604
|
|
|
602
|
-
|
|
605
|
+
size_t VsamFile::hexstrToBuffer(char *hexbuf, size_t buflen, const char *hexstr) {
|
|
603
606
|
DCHECK(hexstr != nullptr && hexbuf != nullptr && buflen > 0);
|
|
604
607
|
memset(hexbuf, 0, buflen);
|
|
605
608
|
if (hexstr[0] == 0)
|
|
606
609
|
return 0;
|
|
607
610
|
|
|
608
611
|
char xx[2];
|
|
609
|
-
|
|
612
|
+
size_t i, j, x;
|
|
610
613
|
if (hexstr[0] == '0' && (hexstr[1] == 'x' || hexstr[1] == 'X'))
|
|
611
614
|
hexstr += 2;
|
|
612
615
|
else if (hexstr[0] == 'x' || hexstr[0] == 'X')
|
|
613
616
|
hexstr += 1;
|
|
614
617
|
|
|
615
|
-
|
|
618
|
+
size_t hexstrlen = strlen(hexstr);
|
|
616
619
|
DCHECK(hexstrlen <= (buflen * 2));
|
|
617
620
|
for (i = 0, j = 0; j < buflen && i < hexstrlen - (hexstrlen % 2); ++j) {
|
|
618
621
|
xx[0] = hexstr[i++];
|
|
619
622
|
xx[1] = hexstr[i++];
|
|
620
|
-
sscanf(xx, "%
|
|
623
|
+
sscanf(xx, "%2zx", &x);
|
|
621
624
|
hexbuf[j] = x;
|
|
622
625
|
}
|
|
623
626
|
if (j < buflen && hexstrlen % 2) {
|
|
624
627
|
DCHECK(i < strlen(hexstr));
|
|
625
628
|
xx[0] = hexstr[i];
|
|
626
629
|
xx[1] = '0';
|
|
627
|
-
sscanf(xx, "%
|
|
630
|
+
sscanf(xx, "%2zx", &x);
|
|
628
631
|
hexbuf[j++] = x;
|
|
629
632
|
}
|
|
630
633
|
DCHECK(j <= buflen);
|
|
631
634
|
return j;
|
|
632
635
|
}
|
|
633
636
|
|
|
634
|
-
|
|
635
|
-
|
|
637
|
+
size_t VsamFile::bufferToHexstr(char *hexstr, size_t hexstrlen,
|
|
638
|
+
const char *hexbuf, size_t hexbuflen) {
|
|
636
639
|
DCHECK(hexstr != nullptr && hexbuf != nullptr && hexbuflen > 0);
|
|
637
|
-
|
|
640
|
+
size_t i, j;
|
|
638
641
|
for (i = 0, j = 0; i < hexbuflen; i++, j += 2)
|
|
639
642
|
sprintf(hexstr + j, "%02x", hexbuf[i]);
|
|
640
643
|
|
|
@@ -649,8 +652,8 @@ int VsamFile::bufferToHexstr(char *hexstr, int hexstrlen, const char *hexbuf,
|
|
|
649
652
|
|
|
650
653
|
bool VsamFile::isStrValid(const LayoutItem &item, const std::string &str,
|
|
651
654
|
const std::string &errPrefix, std::string &errmsg) {
|
|
652
|
-
|
|
653
|
-
if (len < item.minLength
|
|
655
|
+
size_t len = str.length();
|
|
656
|
+
if (len < item.minLength) {
|
|
654
657
|
errmsg = errPrefix + " error: length of '" + item.name + "' must be " +
|
|
655
658
|
std::to_string(item.minLength) + " or more.";
|
|
656
659
|
return false;
|
|
@@ -665,10 +668,10 @@ bool VsamFile::isStrValid(const LayoutItem &item, const std::string &str,
|
|
|
665
668
|
return true;
|
|
666
669
|
}
|
|
667
670
|
|
|
668
|
-
bool VsamFile::isHexBufValid(const LayoutItem &item, const char *buf,
|
|
669
|
-
const std::string &errPrefix,
|
|
671
|
+
bool VsamFile::isHexBufValid(const LayoutItem &item, const char *buf,
|
|
672
|
+
size_t len, const std::string &errPrefix,
|
|
670
673
|
std::string &errmsg) {
|
|
671
|
-
if (len < item.minLength
|
|
674
|
+
if (len < item.minLength) {
|
|
672
675
|
errmsg = errPrefix + " error: length of '" + item.name + "' must be " +
|
|
673
676
|
std::to_string(item.minLength) + " or more.";
|
|
674
677
|
return false;
|
|
@@ -686,8 +689,8 @@ bool VsamFile::isHexBufValid(const LayoutItem &item, const char *buf, int len,
|
|
|
686
689
|
bool VsamFile::isHexStrValid(const LayoutItem &item, const std::string &hexstr,
|
|
687
690
|
const std::string &errPrefix,
|
|
688
691
|
std::string &errmsg) {
|
|
689
|
-
|
|
690
|
-
if (len < item.minLength
|
|
692
|
+
size_t len = hexstr.length();
|
|
693
|
+
if (len < item.minLength) {
|
|
691
694
|
errmsg = errPrefix + " error: length of '" + item.name + "' must be " +
|
|
692
695
|
std::to_string(item.minLength) + " or more.";
|
|
693
696
|
return false;
|
|
@@ -707,7 +710,7 @@ bool VsamFile::isHexStrValid(const LayoutItem &item, const std::string &hexstr,
|
|
|
707
710
|
return false;
|
|
708
711
|
}
|
|
709
712
|
len -= start;
|
|
710
|
-
|
|
713
|
+
size_t digits = (len + (len % 2)) / 2;
|
|
711
714
|
if (digits > item.maxLength) {
|
|
712
715
|
errmsg = errPrefix + " error: number of hex digits " +
|
|
713
716
|
std::to_string(digits) + " for '" + item.name +
|
package/VsamFile.h
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* Licensed Materials - Property of IBM
|
|
3
|
-
* (C) Copyright IBM Corp. 2017,
|
|
3
|
+
* (C) Copyright IBM Corp. 2017, 2022. All Rights Reserved.
|
|
4
4
|
* US Government Users Restricted Rights - Use, duplication or disclosure
|
|
5
5
|
* restricted by GSA ADP Schedule Contract with IBM Corp.
|
|
6
6
|
*/
|
|
@@ -31,23 +31,23 @@ struct LayoutItem {
|
|
|
31
31
|
enum DataType { STRING, HEXADECIMAL };
|
|
32
32
|
|
|
33
33
|
std::string name;
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
size_t minLength;
|
|
35
|
+
size_t maxLength;
|
|
36
36
|
DataType type;
|
|
37
|
-
LayoutItem(std::string &n,
|
|
37
|
+
LayoutItem(std::string &n, size_t mn, size_t mx, DataType t)
|
|
38
38
|
: name(n), minLength(mn), maxLength(mx), type(t) {}
|
|
39
39
|
};
|
|
40
40
|
|
|
41
41
|
struct FieldToUpdate {
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
size_t offset;
|
|
43
|
+
size_t len;
|
|
44
44
|
#ifdef DEBUG
|
|
45
45
|
std::string name;
|
|
46
46
|
LayoutItem::DataType type;
|
|
47
|
-
FieldToUpdate(
|
|
47
|
+
FieldToUpdate(size_t ofs, size_t len, const std::string &nm, LayoutItem::DataType t)
|
|
48
48
|
: offset(ofs), len(len), name(nm), type(t) {}
|
|
49
49
|
#else
|
|
50
|
-
FieldToUpdate(
|
|
50
|
+
FieldToUpdate(size_t ofs, size_t len) : offset(ofs), len(len) {}
|
|
51
51
|
#endif
|
|
52
52
|
};
|
|
53
53
|
|
|
@@ -57,12 +57,12 @@ class VsamFile;
|
|
|
57
57
|
struct UvWorkData {
|
|
58
58
|
UvWorkData(VsamFile *pVsamFile, Napi::Function cbfunc, Napi::Env env,
|
|
59
59
|
const std::string &path = "", char *recbuf = nullptr,
|
|
60
|
-
char *keybuf = nullptr,
|
|
60
|
+
char *keybuf = nullptr, size_t keybuf_len = 0, int equality = 0,
|
|
61
61
|
std::vector<FieldToUpdate> *pFieldsToUpdate = nullptr)
|
|
62
62
|
: pVsamFile_(pVsamFile), cb_(Napi::Persistent(cbfunc)), env_(env),
|
|
63
63
|
path_(path), recbuf_(recbuf), keybuf_(keybuf), keybuf_len_(keybuf_len),
|
|
64
|
-
equality_(equality), pFieldsToUpdate_(pFieldsToUpdate),
|
|
65
|
-
|
|
64
|
+
equality_(equality), pFieldsToUpdate_(pFieldsToUpdate), rc_(1),
|
|
65
|
+
count_(1) {}
|
|
66
66
|
|
|
67
67
|
~UvWorkData() {
|
|
68
68
|
if (recbuf_) {
|
|
@@ -85,11 +85,11 @@ struct UvWorkData {
|
|
|
85
85
|
std::string path_;
|
|
86
86
|
char *recbuf_;
|
|
87
87
|
char *keybuf_;
|
|
88
|
-
|
|
88
|
+
size_t keybuf_len_;
|
|
89
89
|
int equality_;
|
|
90
90
|
std::vector<FieldToUpdate> *pFieldsToUpdate_;
|
|
91
91
|
int rc_;
|
|
92
|
-
|
|
92
|
+
size_t count_; // of records updated or deleted to report back
|
|
93
93
|
std::string errmsg_;
|
|
94
94
|
};
|
|
95
95
|
|
|
@@ -117,11 +117,11 @@ typedef struct {
|
|
|
117
117
|
class VsamFile {
|
|
118
118
|
public:
|
|
119
119
|
VsamFile(const std::string &path, const std::vector<LayoutItem> &layout,
|
|
120
|
-
int key_i,
|
|
120
|
+
int key_i, size_t keypos, const std::string &omode);
|
|
121
121
|
~VsamFile();
|
|
122
122
|
|
|
123
123
|
int getKeyNum() const { return key_i_; }
|
|
124
|
-
|
|
124
|
+
size_t getRecordLength() const { return reclen_; }
|
|
125
125
|
int getLastError(std::string &errmsg) const {
|
|
126
126
|
errmsg = errmsg_;
|
|
127
127
|
return rc_;
|
|
@@ -140,13 +140,13 @@ public:
|
|
|
140
140
|
int *perr2 = 0, int *pr15 = 0);
|
|
141
141
|
static bool isStrValid(const LayoutItem &item, const std::string &str,
|
|
142
142
|
const std::string &errPrefix, std::string &errmsg);
|
|
143
|
-
static bool isHexBufValid(const LayoutItem &item, const char *buf,
|
|
143
|
+
static bool isHexBufValid(const LayoutItem &item, const char *buf, size_t len,
|
|
144
144
|
const std::string &errPrefix, std::string &errmsg);
|
|
145
145
|
static bool isHexStrValid(const LayoutItem &item, const std::string &hexstr,
|
|
146
146
|
const std::string &errPrefix, std::string &errmsg);
|
|
147
|
-
static
|
|
148
|
-
static
|
|
149
|
-
|
|
147
|
+
static size_t hexstrToBuffer(char *hexbuf, size_t buflen, const char *hexstr);
|
|
148
|
+
static size_t bufferToHexstr(char *hexstr, size_t hexstrlen, const char *hexbuf,
|
|
149
|
+
size_t hexbuflen);
|
|
150
150
|
|
|
151
151
|
/* static because WrappedVsam::Close() delete its VsamFile object */
|
|
152
152
|
static void DeallocExecute(UvWorkData *pdata);
|
|
@@ -188,8 +188,8 @@ private:
|
|
|
188
188
|
int rc_;
|
|
189
189
|
std::string errmsg_;
|
|
190
190
|
int key_i_;
|
|
191
|
-
|
|
192
|
-
|
|
191
|
+
size_t keypos_;
|
|
192
|
+
size_t keylen_, reclen_;
|
|
193
193
|
#ifdef DEBUG_CRUD
|
|
194
194
|
// to read the record before delete((err)) for display
|
|
195
195
|
fpos_t freadpos_; // =fgetpos() before fread()
|
package/VsamThread.cpp
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* Licensed Materials - Property of IBM
|
|
3
|
-
* (C) Copyright IBM Corp. 2020,
|
|
3
|
+
* (C) Copyright IBM Corp. 2020, 2022. All Rights Reserved.
|
|
4
4
|
* US Government Users Restricted Rights - Use, duplication or disclosure
|
|
5
5
|
* restricted by GSA ADP Schedule Contract with IBM Corp.
|
|
6
6
|
*/
|
|
7
|
+
#include <assert.h>
|
|
8
|
+
|
|
7
9
|
#include "VsamThread.h"
|
|
8
10
|
|
|
11
|
+
|
|
9
12
|
#ifdef DEBUG
|
|
10
13
|
static const char *getMessageStr(VSAM_THREAD_MSGID msgid) {
|
|
11
14
|
switch (msgid) {
|
package/WrappedVsam.cpp
CHANGED
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* Licensed Materials - Property of IBM
|
|
3
|
-
* (C) Copyright IBM Corp. 2020,
|
|
3
|
+
* (C) Copyright IBM Corp. 2020, 2022. All Rights Reserved.
|
|
4
4
|
* US Government Users Restricted Rights - Use, duplication or disclosure
|
|
5
5
|
* restricted by GSA ADP Schedule Contract with IBM Corp.
|
|
6
6
|
*/
|
|
7
|
+
#include <assert.h>
|
|
8
|
+
#include <stdio.h>
|
|
9
|
+
#include <unistd.h>
|
|
10
|
+
|
|
11
|
+
#include <sstream>
|
|
12
|
+
|
|
7
13
|
#include "WrappedVsam.h"
|
|
8
14
|
#include "VsamThread.h"
|
|
9
|
-
|
|
10
|
-
#include <unistd.h>
|
|
15
|
+
|
|
11
16
|
|
|
12
17
|
Napi::FunctionReference WrappedVsam::constructor_;
|
|
13
18
|
|
|
@@ -24,7 +29,7 @@ static void throwError(const Napi::CallbackInfo &info, int errArgNum,
|
|
|
24
29
|
#endif
|
|
25
30
|
Napi::Env env = info.Env();
|
|
26
31
|
if (errArgNum >= 0 && firstArgType != ARG0_TYPE_NONE) {
|
|
27
|
-
for (
|
|
32
|
+
for (size_t i = 0; i < info.Length(); i++) {
|
|
28
33
|
if (!info[i].IsFunction())
|
|
29
34
|
continue;
|
|
30
35
|
Napi::Function cb = info[i].As<Napi::Function>();
|
|
@@ -345,7 +350,7 @@ Napi::Object WrappedVsam::Construct(const Napi::CallbackInfo &info,
|
|
|
345
350
|
int key_i = 0; // for its data type - default to first field if no "key" found
|
|
346
351
|
int curpos = 0, keypos = 0;
|
|
347
352
|
|
|
348
|
-
for (
|
|
353
|
+
for (size_t i = 0; i < properties.Length(); ++i) {
|
|
349
354
|
std::string name(static_cast<std::string>(
|
|
350
355
|
Napi::String(env, properties.Get(i).ToString())));
|
|
351
356
|
|
|
@@ -912,7 +917,6 @@ Napi::Value WrappedVsam::FindSync_(const Napi::CallbackInfo &info,
|
|
|
912
917
|
Napi::Value WrappedVsam::FindEqSync(const Napi::CallbackInfo &info) {
|
|
913
918
|
Napi::HandleScope scope(info.Env());
|
|
914
919
|
UvWorkData *pdata = nullptr;
|
|
915
|
-
int rc;
|
|
916
920
|
if ((info.Length() == 2 && info[0].IsObject() && info[1].IsNumber()) ||
|
|
917
921
|
(info.Length() == 1 && info[0].IsString())) {
|
|
918
922
|
if (Find(info, __KEY_EQ, "findSync", -1, &pdata, ARG0_TYPE_NONE))
|
|
@@ -1018,7 +1022,7 @@ int WrappedVsam::Find(const Napi::CallbackInfo &info, int equality,
|
|
|
1018
1022
|
Napi::HandleScope scope(info.Env());
|
|
1019
1023
|
std::string key;
|
|
1020
1024
|
char *keybuf = nullptr;
|
|
1021
|
-
|
|
1025
|
+
size_t keybuf_len = 0;
|
|
1022
1026
|
int key_i = pVsamFile_->getKeyNum();
|
|
1023
1027
|
std::vector<LayoutItem> &layout = pVsamFile_->getLayout();
|
|
1024
1028
|
std::string errmsg;
|
package/binding.gyp
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
{
|
|
2
|
+
"variables": {
|
|
3
|
+
"NODE_VERSION%":"<!(node -p \"process.versions.node.split(\\\".\\\")[0]\")"
|
|
4
|
+
},
|
|
2
5
|
"targets": [
|
|
3
6
|
{
|
|
4
7
|
"target_name": "vsam.js",
|
|
5
|
-
"cflags!": [ "-fno-exceptions" ],
|
|
6
|
-
"cflags_cc!": [ "-fno-exceptions" ],
|
|
7
|
-
"cflags": [ "-qascii" ],
|
|
8
|
-
"cflags_cc": [ "-qascii" ],
|
|
9
8
|
"sources": [ "vsam.cpp", "WrappedVsam.cpp", "VsamFile.cpp", "VsamThread.cpp" ],
|
|
10
9
|
"include_dirs": [
|
|
11
10
|
"<!@(node -p \"require('node-addon-api').include\")"
|
|
@@ -13,7 +12,13 @@
|
|
|
13
12
|
"dependencies": [
|
|
14
13
|
"<!(node -p \"require('node-addon-api').gyp\")"
|
|
15
14
|
],
|
|
16
|
-
"
|
|
15
|
+
"conditions": [
|
|
16
|
+
[ "NODE_VERSION < 16", {
|
|
17
|
+
"cflags": [ "-qascii" ],
|
|
18
|
+
"defines": [ "_AE_BIMODAL=1", "_ALL_SOURCE", "_ENHANCED_ASCII_EXT=0x42020010", "_LARGE_TIME_API", "_OPEN_MSGQ_EXT", "_OPEN_SYS_FILE_EXT=1", "_OPEN_SYS_SOCK_IPV6", "_UNIX03_SOURCE", "_UNIX03_THREADS", "_UNIX03_WITHDRAWN", "_XOPEN_SOURCE=600", "_XOPEN_SOURCE_EXTENDED" ],
|
|
19
|
+
}],
|
|
20
|
+
],
|
|
21
|
+
"defines+": [ "NAPI_DISABLE_CPP_EXCEPTIONS" ],
|
|
17
22
|
}
|
|
18
23
|
]
|
|
19
24
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vsam.js",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.1.1",
|
|
4
4
|
"description": "Interact with VSAM Data Sets on z/OS",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"repository": "ibmruntimes/vsam.js",
|
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
18
|
"async": "^1.5.0",
|
|
19
|
-
"
|
|
20
|
-
"
|
|
19
|
+
"chai": "^4.1.2",
|
|
20
|
+
"mocha": "^10.0.0"
|
|
21
21
|
},
|
|
22
22
|
"scripts": {
|
|
23
23
|
"build": "node-gyp build",
|
package/vsam.cpp
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* Licensed Materials - Property of IBM
|
|
3
|
-
* (C) Copyright IBM Corp. 2017,
|
|
3
|
+
* (C) Copyright IBM Corp. 2017, 2022. All Rights Reserved.
|
|
4
4
|
* US Government Users Restricted Rights - Use, duplication or disclosure
|
|
5
5
|
* restricted by GSA ADP Schedule Contract with IBM Corp.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
#include "WrappedVsam.h"
|
|
9
8
|
#include <napi.h>
|
|
10
9
|
|
|
10
|
+
#include "WrappedVsam.h"
|
|
11
|
+
|
|
12
|
+
|
|
11
13
|
Napi::Object InitAll(Napi::Env env, Napi::Object exports) {
|
|
12
14
|
WrappedVsam::Init(env, exports);
|
|
13
15
|
|