With the ILE compiler, in RPG, you can use the PSDS to get information about the current user, job name etc..
How do you get the same information in a C++ program, using ILE?
With the ILE compiler, in RPG, you can use the PSDS to get information about the current user, job name etc..
How do you get the same information in a C++ program, using ILE?
The QUSRJOBI api will get you the info you mentioned. The returned struct jobInfo is defined in header QUSRJOBI.h (QSYSINC.H file) and will return the current job name/user name and job number plus more if called like this:
Qwc_JOBI0600_t jobInfo;
QUSRJOBI(&jobInfo, sizeof(Qwc_JOBI0600_t), "JOBI0600 ", "* ",
" ", &errCode);
There is no direct equivalent to RPG's PSDS in C++.
(For those who are not aware, in the RPG programming language, you can declare a data structure called the "Program Status Data Structure" and it'll be automatically filled in with lots of information about the runtime environment, including the job identifier (like a process id), user name, last error that occurred, and lots of other information.)
If you can tell us specifically which information you're looking for, and what platform you need it on (or whether you need it to be cross-platform) then perhaps we can help.
To add to Scott's reply, a data structure in RPG is like a struct in C++ - it would be possible to construct a struct that would contain that data, and one could probably populate some of it with various calls to system APIs. Some things, however, are just not readily available.
You can get the program name and program library from the first parameter passed to a C or C++ program. argv[0] is a string in the form "MYLIB/MYPGM".
If you ever need the module name, probably the easiest way would be to send yourself a message using QMHSNDPM and then receive it using QMHRCVPM with format RCVM0300 which has "sender information"; the sender information has the sending module name and receiving module name. You could also get the program name and library this way.