home *** CD-ROM | disk | FTP | other *** search
/ vsiftp.vmssoftware.com / VSIPUBLIC@vsiftp.vmssoftware.com.tar / FREEWARE / FREEWARE40.ZIP / flistfrontend / src / syrights.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-10-19  |  1.2 KB  |  59 lines

  1. #ifndef NO_IDENT
  2. static char *Id = "$Id: syrights.c,v 1.5 1995/10/19 10:35:36 tom Exp $";
  3. #endif
  4.  
  5. /*
  6.  * Title:    sysrights.c
  7.  * Author:    T.E.Dickey
  8.  * Created:    01 Aug 1984
  9.  * Last update:
  10.  *        19 Oct 1995, casts needed for DEC-C on AXP.
  11.  *        19 Feb 1995, sys utils prototypes
  12.  *        05 Dec 1989, pass mask,word_num as args rather than vshift,
  13.  *                 to accommodate VMS 5.1
  14.  *        30 Sep 1985, use SYS$GETJPIw in VMS 4.x
  15.  *        01 Aug 1984
  16.  *
  17.  * Function:    Test for current-process privilege, returning TRUE if the
  18.  *        specified privilege is enabled.
  19.  *
  20.  * Parameters:    mask    = privilege-mask (e.g., PRV$M_BYPASS) from <prvdef.h>.
  21.  *        word_num= 0 (for the one-bit masks!)
  22.  */
  23.  
  24. #include    <starlet.h>
  25. #include    <jpidef.h>
  26.  
  27. #include    "sysutils.h"
  28.  
  29. #define    ITEM(code,len)    ((code<<16)+len)
  30.  
  31. typedef    int    QUAD[2];
  32.  
  33. static
  34. QUAD    iosb,    priv_buf;
  35.  
  36. static
  37. int    ret_len;
  38.  
  39. static
  40. unsigned    itmlst[] = {    /* list of 'longword' */
  41.         ITEM(JPI$_CURPRIV,sizeof(QUAD)),
  42.         (unsigned) &priv_buf,    (unsigned) &ret_len,
  43.         JPI$C_LISTEND
  44.         };
  45.  
  46. int
  47. sysrights (int mask, int word_num)
  48. {
  49.     sys$getjpiw (    0,    /* efn        */
  50.             0,    /* pidadr    */
  51.             0,    /* prcnam    */
  52.             &itmlst,
  53.             &iosb,
  54.             0,    /* astadr    */
  55.             0);    /* astprm    */
  56.  
  57.     return ((priv_buf[word_num] & (mask)) != 0);
  58. }
  59.