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

Discussion in 'C++' started by Greg Shaw, Mar 18, 2009.

  1. Greg Shaw

    Greg Shaw Guest

    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
     
    Greg Shaw, Mar 18, 2009
    #1
    1. Advertising

  2. * 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

    --
    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!
     
    Alf P. Steinbach, Mar 18, 2009
    #2
    1. Advertising

  3. Greg Shaw

    red floyd Guest

    On Mar 18, 8:15 am, "Alf P. Steinbach" <> 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.
     
    red floyd, Mar 19, 2009
    #3
  4. Greg Shaw

    Greg Shaw Guest

    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.
     
    Greg Shaw, Mar 19, 2009
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. dorayme

    The Guardian's website Sudoku

    dorayme, May 31, 2006, in forum: HTML
    Replies:
    12
    Views:
    862
    Jim Higson
    Jun 4, 2006
  2. malcolm
    Replies:
    19
    Views:
    473
    John J. Lee
    Jan 27, 2004
  3. Matthew Moss

    [QUIZ] Guardian of Middle-earth (#159)

    Matthew Moss, Apr 4, 2008, in forum: Ruby
    Replies:
    8
    Views:
    108
    Matthew Moss
    Apr 10, 2008
  4. malcolm
    Replies:
    0
    Views:
    99
    malcolm
    Jan 25, 2004
  5. David Mark

    jQuery takes down the Guardian

    David Mark, Nov 3, 2011, in forum: Javascript
    Replies:
    11
    Views:
    644
    Michael Haufe (TNO)
    Nov 5, 2011
Loading...

Share This Page