× 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.



Good point Nathan. I (foolishly) thought that the prototype was correct. But it is not - there is a fourth parameter and as a minimum it should be passed as null.

C is not a strong point for me but at a glance the logic does an "if (remove)" which I think will be true becuase the "pointer" (which doesn't exist) will have been filled with whatever was on the stack. At some point the will cause an issue.

So the proto needs an extra char field added with options(*string : *Omit)

Then the call needs to add the fourth parm as *Omit.

Without digging further into the C code that's the first guess.

Plus my original comment re *String holds. It appears to be needed.



On May 22, 2020, at 8:49 AM, Nathan Andelin <nandelin@xxxxxxxxx> wrote:

I also wondered about options(*string).

One more thing I noticed in the C source code for pw_rand() is a 4th
parameter, a pointer to a character buffer named "remove". That parameter
appears to be missing in the RPG prototype. That could cause a pointer
exception.

Pointer exceptions are often the hardest to figure out.


On Fri, May 22, 2020 at 6:44 AM Jon Paris <jon.paris@xxxxxxxxxxxxxx> wrote:

The only possibility I can think of is that the C code is expecting a null
terminated string. i.e. one ending in x'00'.

Add Options(*String) to the proto of the 70 char field and the pass
%TrimR(PW_BUFF) as the parm.

OK - I won't nag about free form declarations but MOVE ?


On May 22, 2020, at 5:34 AM, Patrik Schindler <poc@xxxxxxxxxx> wrote:

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

--
This is the RPG programming on IBM i (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/rpg400-l.

Please contact support@xxxxxxxxxxxxxxxxxxxx for any subscription
related questions.

Help support midrange.com by shopping at amazon.com with our affiliate
link: https://amazon.midrange.com

--
This is the RPG programming on IBM i (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/rpg400-l.

Please contact support@xxxxxxxxxxxxxxxxxxxx for any subscription related
questions.

Help support midrange.com by shopping at amazon.com with our affiliate
link: https://amazon.midrange.com

--
This is the RPG programming on IBM i (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/rpg400-l.

Please contact support@xxxxxxxxxxxxxxxxxxxx for any subscription related questions.

Help support midrange.com by shopping at amazon.com with our affiliate link: https://amazon.midrange.com


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

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.