Newbie C++ on HP NonStop - how to integrate Guardian Procedures?

G

Greg Shaw

All,

Hi there! This is my first post, so hello everybody. I've been banging
my head against the wall writing my first C++ program which calls a
Guardian Procedure, on a HP NonStop (Tandem) machine. I have RTFM good
and hard with no success, tried various syntax blags, and asked around
at my place of work, and no-one can help, so I thought I'd ask you
lot. And yes, I have tried running it in debug using INSPECT, but when
trying to STEP IN to the call to the Guardian procedure, the source is
not available so I can't follow what's going on.

The task I set myself was the most basic one - wrap up in C++ a nice
safe Guardian procedure which can't do any damage. I chose
PROCESS_GETINFO_ . I ended up putting loads of cout statements at the
end of the program just so I can see everything - a more useful
version would be supplying So, can anyone tell me why the program
below results in this response (return code 2 is Parameter error) from
the NonStop, please?

returnCode is 2
processHandle is 8003de8
*processHandle is 0
errorDetail is 8003e08
*errorDetail is 1
============================================
// process_getinfo_.cpp
//
// A first attempt to write C++ which calls a Guardian procedure.

// inclusion guard:
#ifndef MY_PROCESS_GETINFO
#define MY_PROCESS_GETINFO

// Begin
#include < cextdecs(PROCESS_GETINFO_)>
#include <iostream>
using std::cout;
using std::endl;

int main()
{
short returnCode=0;
short *processHandle = new short[10];
for (int i = 0; i<10 ; i++ )
{
processHandle = '\0';
}
short *errorDetail = new short[1];
errorDetail[0] = '\0';
cout << "\nHello. This is designed to use C++ to call the" << endl;
cout << "Guardian procedure PROCESS_GETINFO_ with no processhandle"
<< endl;
cout << "argument - so designed to return the processhandle of the"
<< endl;
cout << "caller, plus any error information. Good luck...." << endl;

returnCode = PROCESS_GETINFO_ (processHandle // [ short
*processhandle ] /*i,o 1 */
,// [ char *proc-
fname ] /* o 2 */
,// [ short maxlen ] /
* o 2 */
,// [ short *proc-
fname-len ] /* o 3 */
,// [ short
*priority ] /* i 4 */
,// [ short *mom’s-
processhandle ] /*i 5 */
,// [ char
*hometerm ] /* i 6 */
,// [ short maxlen ] /
* i 6 */
,// [ short *hometerm-
len ] /* i 7 */
,// [ long long
*process-time ]/* i 8 */
,// [ short *creator-
access-id ]/*i 9 */
,// [ short *process-
access-id ]/*i 10 */
,// [ short *gmom’s-
processhandle ]/* i11 */
,// [ short *jobid ] /
* i 12 */
,// [ char *program-
file ] /* i 13 */
,// [ short maxlen ] /
* i 13 */
,// [ short *program-
len ] /* i 14 */
,// [ char *swap-
file ] /* i 15 */
,// [ short maxlen ] /
* i 15 */
,// [ short *swap-
len ] /* i 16 */
, errorDetail // [ short *error-
detail ] /* i 17 */
,// [ short *proc-
type ] /* i 18 */
,// [ __int32_t *oss-
pid ] /* i 19*/;
);

cout << endl;
cout << "returnCode is " << returnCode << endl;
cout << "processHandle is " << processHandle << endl;
cout << "*processHandle is " << *processHandle << endl;
cout << "errorDetail is " << errorDetail << endl;
cout << "*errorDetail is " << *errorDetail << endl;
cout << endl;
cout << "That's all for now, Mr Guardian programmer." << endl;
delete [] processHandle;
delete [] errorDetail;
return 0;
}


// End inclusion guard
#endif
 
A

Alf P. Steinbach

* Greg Shaw:
Hi there! This is my first post, so hello everybody. I've been banging
my head against the wall writing my first C++ program which calls a
Guardian Procedure, on a HP NonStop (Tandem) machine. I have RTFM good
and hard with no success, tried various syntax blags, and asked around
at my place of work, and no-one can help, so I thought I'd ask you
lot. And yes, I have tried running it in debug using INSPECT, but when
trying to STEP IN to the call to the Guardian procedure, the source is
not available so I can't follow what's going on.

I'm not familiar with any of the tools or APIs you're using.

They don't matter though.

The task I set myself was the most basic one - wrap up in C++ a nice
safe Guardian procedure which can't do any damage. I chose
PROCESS_GETINFO_ . I ended up putting loads of cout statements at the
end of the program just so I can see everything - a more useful
version would be supplying So, can anyone tell me why the program
below results in this response (return code 2 is Parameter error) from
the NonStop, please?

returnCode is 2
processHandle is 8003de8
*processHandle is 0
errorDetail is 8003e08
*errorDetail is 1

No. That's to do with the internals of PROCESS_GETINFO_, and nothing to do with
C++. I.e., it's off-topic.

============================================
// process_getinfo_.cpp
//
// A first attempt to write C++ which calls a Guardian procedure.

// inclusion guard:
#ifndef MY_PROCESS_GETINFO
#define MY_PROCESS_GETINFO

You don't need include guards for a main program or other implementation file.

Include guarads are used for header files.

// Begin
#include < cextdecs(PROCESS_GETINFO_)>

Are you sure that 'cextdecs' is a macro that expands to a header file name?

Anyway I'm not sure of the syntax here.

Macros as header names is a very seldom used feature.

#include <iostream>
using std::cout;
using std::endl;

int main()
{
short returnCode=0;
short *processHandle = new short[10];

Here you should just use std::vector, i.e.,

std::vector<short> processHandle( 10 );

You then need to

#include <vector>

among the other includes.

for (int i = 0; i<10 ; i++ )
{
processHandle = '\0';


Presumably process handles are not characters.

Anyway this zeroing loop is unnecessary when using std::vector.

}
short *errorDetail = new short[1];

Here you can just use

short errorDetail;

and that's that.

errorDetail[0] = '\0';
cout << "\nHello. This is designed to use C++ to call the" << endl;
cout << "Guardian procedure PROCESS_GETINFO_ with no processhandle"
<< endl;
cout << "argument - so designed to return the processhandle of the"
<< endl;
cout << "caller, plus any error information. Good luck...." << endl;

returnCode = PROCESS_GETINFO_ (processHandle // [ short *processhandle ] /*i,o 1 */
,// [ char *proc-fname ] /* o 2 */
,// [ short maxlen ] / * o 2 */
,// [ short *proc-fname-len ] /* o 3 */
,// [ short *priority ] /* i 4 */
,// [ short *mom’s-processhandle ] /*i 5 */
,// [ char *hometerm ] /* i 6 */
,// [ short maxlen ] / * i 6 */
,// [ short *hometerm-len ] /* i 7 */
,// [ long long *process-time ]/* i 8 */
,// [ short *creator- access-id ]/*i 9 */
,// [ short *process- access-id ]/*i 10 */
,// [ short *gmom’s- processhandle ]/* i11 */
,// [ short *jobid ] / * i 12 */
,// [ char *program- file ] /* i 13 */
,// [ short maxlen ] / * i 13 */
,// [ short *program- len ] /* i 14 */
,// [ char *swap- file ] /* i 15 */
,// [ short maxlen ] / * i 15 */
,// [ short *swap- len ] /* i 16 */
, errorDetail // [ short *error- detail ] /* i 17 */
,// [ short *proc- type ] /* i 18 */
,// [ __int32_t *oss- pid ] /* i 19*/;
);

C++ does not have default arguments.

I can't think of any definition of PROCESS_GETINFO_ where the above would compile.



Cheers & hth.,

- Alf
 
R

red floyd

* Greg Shaw:

You're better off asking this in comp.sys.tandem
[redacted]
Are you sure that 'cextdecs' is a macro that expands to a header file name?

It's a Nonstop extension.

Again, OP should go to comp.sys.tandem, where the OS API and C++
language extensions are on-topic.
 
G

Greg Shaw

Both,

Thanks for the hint about using a vector instead of an array, and for
the pointer to comp.tandem.sys . A user there gave me the solution
within hours, and the combined C++/TAL program now works as required -
I am officially dangerous.

I'm slightly concerned about the repeated cries of "Off topic! Off
topic!" No-one in their right mind wants the msesage board to be
filled up with irrelevance, but seeing as my request was one regarding
an unknown error in a combined C++/TAL program, I don't think I was
being flippant posting here. Anyway, I'll take it in good heart,
seeing as the positive side of joining this group has outweighed it so
much.

Have fun, thanks again, and I will keep reading with interest.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top