(PYVMS LOGO) Python on OpenVMS

(go to: table of contents, index, list of vms_lib, prev: PARSE_ACCESS_CODE, next: PUT_COMMON)


PARSE_SOGW_PROT - Parse Protection String

Format:
    status, protection-mask, ownership-mask, end-position =\
        vms_lib.parse_sogw_prot (protection-string, [access-names])
Returns:
status
Condition value as returned by LIB$PARSE_SOGW_PROT.
protection-mask
Translated OpenVMS protection mask. A 16-bit value in a Python integer.
ownership-mask
Indicates which ownership names (e.g. SYSTEM) were present in 'protection-string'. A 16-bit value in a Python integer.
end-position
Indicates the offending location when a parse error occured.
Arguments:
protection-string
See the RTL manual for details.
access-names
Object of type 'vmsobj__access_names'.
Examples:
>>> import vms_lib
>>> import vms_sys

>>> # define ownership categories
>>> own_cat_sys = 0x000f
>>> own_cat_own = 0x00f0
>>> own_cat_grp = 0x0f00
>>> own_cat_wld = 0xf000

>>> status, protection_mask, ownership_mask, end_position = \
...     vms_lib.parse_sogw_prot ('S:RW', None)
>>> print (status, hex(protection_mask), \
...        hex(ownership_mask), end_position)
(1, '0xfffc', '0xf', 4)
>>> print vms_sys.getmsg (status) [0]
%SYSTEM-S-NORMAL, normal successful completion
>>>
>>> # did protection string contain the system ownership ?
>>> print ((ownership_mask & own_cat_sys) <> 0)
1        <-- yes
>>> # did protection string contain the owner ownership ?
>>> print ((ownership_mask & own_cat_own) <> 0)
0        <-- no
>>>


>>> status, protection_mask, ownership_mask, end_position = \
...     vms_lib.parse_sogw_prot ('S:R,O:W,G:E,W:D', None)
>>> print (status, hex(protection_mask), \
...        hex(ownership_mask), end_position)
(1, '0x7bde', '0xffff', 15)
>>>


>>> accnam = vms_lib.get_accnam ()
>>> print accnam [0:4]
['READ', 'WRITE', 'EXECUTE', 'DELETE']
>>> accnam [0] = 'A'
>>> accnam [1] = 'B'
>>> accnam [2] = 'C'
>>> accnam [3] = 'D'
>>> print accnam [0:4]
['A', 'B', 'C', 'D']
>>>
>>> status, protection_mask, ownership_mask, end_position = \
...     vms_lib.parse_sogw_prot ('S:A,O:AB,G:ABC,W:CD', None)
>>> print (status, hex(protection_mask), \
...        hex(ownership_mask), end_position)
(1409668, '0x0', '0x0', 2)
>>> print vms_sys.getmsg(status)[0]
%LIB-F-SYNTAXERR, string syntax error detected by LIB$TPARSE
>>>
>>> status, protection_mask, ownership_mask, end_position = \
...     vms_lib.parse_sogw_prot ('S:A,O:AB,G:ABC,W:CD', accnam)
>>> print (status, hex(protection_mask), \
...        hex(ownership_mask), end_position)
(1, '0x38ce', '0xffff', 19)
>>>


>>> long_string = 65536 * 'X'
>>> status, protection_mask, ownership_mask, end_position = \
...     vms_lib.parse_sogw_prot (long_string, None)
Traceback (innermost last):
  File "<stdin>", line 1, in ?
ValueError: argument 1: protection_string - string size limited\
 to 65535 characters
>>>

>>> status, protection_mask, ownership_mask, end_position = \
...     vms_lib.parse_sogw_prot ('S:R', 'X')
Traceback (innermost last):
  File "<stdin>", line 1, in ?
TypeError: argument 2: access_names - must be\
 vmsobj__access_names or None
>>>

(go to: table of contents, index, list of vms_lib, prev: PARSE_ACCESS_CODE, next: PUT_COMMON)

13-AUG-1999 ZE.