× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Hello,

I've ported https://github.com/tytso/pwgen to the CL environment (not PASE!), for easy generation of random characters. and calling the resulting *PGM runs fine.

There's one function (pw_rand) I want to call from RPG, by linking (binding) all (necessary) *MODULE objects from pwgen together with the RPGLE module containing the mainline to one *PGM. I'm *not* talking about a service program.

The C prototype is: void pw_rand(char *buf, int size, int pw_flags);

What I expect it to do: I pass a struct predetermined by the existing C code, stating I want to create a 64 char password with the password flags 3. The password buffer is apparently preallocated by RPG (see debug output below), since it's filled with *BLANKs. The function runs and places a (most likely zero-teminated) string into the buffer: 64 bytes password, 1 byte '00'X. I made the buffer a bit larger to be on the safe side. I also looked up proper field sizes in IBM documentation and that seems correct.

That's what I did in positional RPG:

DPW_BUF S 70A
DPW_SIZE S 10I 0
DPW_FLAGS S 10I 0
*
DPW_RAND PR EXTPROC('pw_rand')
D PW_BUF 70A
D PW_SIZE 10I 0 VALUE
D PW_FLAGS 10I 0 VALUE
*----------------
C MOVE 64 PW_SIZE
C MOVE 3 PW_FLAGS
C CALLP PW_RAND ( PW_BUF : PW_SIZE : PW_FLAGS )

( I hope, my MUA will not mess up with the formatting.)

Compiles and links fine, but when I try to run the call, the application crashes with MCH 3601 (Pointer not set for location referenced.). I read some articles in the net about it but I can't find out where or what I do wrong.

Debug:

PW_BUF CHAR(70) ' '
VALUE IN HEX '40404040404040404040404040404040404040404040404040404040404040404040404040404040'X
41 '404040404040404040404040404040404040404040404040404040404040'X
PW_FLAGS ZONED(1,0) 3. 'F3'X
PW_SIZE ZONED(2,0) 64. 'F6F4'X

Help greatly appreciated! Please refrain from "do it with RPG free", because I don't want to open yet another task on my already big stack. (Learning free is on my list, for a later point in time.)

:wq! PoC

PGP-Key: DDD3 4ABF 6413 38DE - https://www.pocnet.net/poc-key.asc


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.