Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
HP.com home

HP OpenVMS Systems

ask the wizard
Content starts here

C example of system service call?

» close window

The Question is:

 
how do i call the sys$sndjbc system service from a c program (DEC C 5.7-004) ?
 


The Answer is :

 
  The same way you call most any OpenVMS system service that uses an
  itemlist from C is the same way you call $sndjbc -- other common system
  services are $getsyi, $getdvi, and $getjpi.  Once you are familiar with
  calling one of these system services, you can use this knowledge to code
  other system service calls.  In other words, once you have an understanding
  of the calling standard and of a specific system service argument passing
  technique, you can generalize that technique and that knowledge to many
  other system services.  Put another way, the OpenVMS Wizard cannot possibly
  provide examples of every system service coded in every available language.
 
  For customers with a Compaq software services contract, DSNlink does have
  a number of source code examples.  Also available are the examples on the
  OpenVMS Freeware, and there are a variety of C modules included on the
  OpenVMS Freeware.  Also available are various code examples in the OpenVMS
  documentation set, and examples here in the Ask The Wizard area.  Also
  topics such as (2945)
 
  Here is an example, slightly altered for posting on the web:
 
 
$ vfyold = f$verify(1)
$ create sys$scratch:accounting.c
#include [efndef.h]
#include [lib$routines.h]
#include [sjcdef.h]
#include [ssdef.h]
#include [starlet.h]
#include [stddef.h]
#include [stsdef.h]
struct ItemList3
    {
    short int ItemLength;
    short int ItemCode;
    void *ItemBuffer;
    void *ItemRetLen;
    };
 
#define MAXITMLST 3
main()
  {
  int i;
  struct ItemList3 JbcIL[MAXITMLST];
  unsigned short int IOSB[4];
  int RetStat, JbcMask, JbcFunc;
 
  /* To start accounting: */
  JbcFunc = SJC$_START_ACCOUNTING;
 
  /* Specify image and interactive */
  JbcMask = SJC$M_ACCT_IMAGE | SJC$M_ACCT_INTERACTIVE;
 
  i = 0;
  JbcIL[i].ItemLength     = sizeof( JbcMask );
  JbcIL[i].ItemCode       = SJC$_ACCOUNTING_TYPES;
  JbcIL[i].ItemBuffer     = (void *) &JbcMask;
  JbcIL[i++].ItemRetLen   = NULL;
  JbcIL[i].ItemLength     = 0;
  JbcIL[i].ItemCode       = 0;
  JbcIL[i].ItemBuffer     = NULL;
  JbcIL[i++].ItemRetLen   = NULL;
 
  RetStat = sys$sndjbcw(EFN$C_ENF,JbcFunc,0, JbcIL,IOSB,0,0);
  if (!$VMS_STATUS_SUCCESS( RetStat ))
    lib$signal( RetStat );
  if (!$VMS_STATUS_SUCCESS( IOSB[0] ))
    lib$signal( IOSB[0] );
 
  return SS$_NORMAL;
  }
$ cc/decc/prefix=all sys$scratch:accounting.c/object=sys$scratch:
$ link/executable=sys$scratch:accounting.exe sys$scratch:accounting
$ show accounting
$ prvold = f$setprv("OPER")
$ run sys$scratch:accounting
$ show accounting
$ priv = f$setprv(prvold)
$ vfyold = f$verify(vfyold)
$ exit
 

answer written or last revised on ( 16-JUL-2001 )

» close window

 

Privacy statement Using this site means you accept its terms Feedback to webmaster
© 2008 Hewlett-Packard Development Company, L.P.