Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Newbie C++ on HP NonStop - how to integrate Guardian Procedures?

Reply
Thread Tools

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

 
 
Greg Shaw
Guest
Posts: n/a
 
      03-18-2009
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[i] = '\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

 
Reply With Quote
 
 
 
 
Alf P. Steinbach
Guest
Posts: n/a
 
      03-18-2009
* 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[i] = '\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

--
Due to hosting requirements I need visits to <url: http://alfps.izfree.com/>.
No ads, and there is some C++ stuff! Just going there is good. Linking
to it is even better! Thanks in advance!
 
Reply With Quote
 
 
 
 
red floyd
Guest
Posts: n/a
 
      03-19-2009
On Mar 18, 8:15*am, "Alf P. Steinbach" <al...@start.no> wrote:
> * 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.


You're better off asking this in comp.sys.tandem
[redacted]
>
> > // Begin
> > #include < cextdecs(PROCESS_GETINFO_)>

>
> 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.
 
Reply With Quote
 
Greg Shaw
Guest
Posts: n/a
 
      03-19-2009
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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Using SETMODE function in C program of Guardian envirnoment-HP Nonstop Tandem kiranbhatter Software 0 01-01-2012 08:09 PM
Core 2 Duo PC keeps shutting down itself after 2 seconds and booting up nonstop ss6nn1@googlemail.com Computer Support 18 08-16-2006 09:59 PM
Review: NZXT Guardian Case Review Silverstrand Reviews & How-To's 0 06-20-2005 02:56 AM
Guardian Backpacks - First Crime-Fighting Backpack Designed to Save Lives posh Computer Support 2 06-07-2005 04:58 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57