HP OpenVMS Systemsask the wizard |
The Question is:
I want to use sys$getqui() to check whether a queue is the underlying queue.
For example in DCL :
$ sh queue ibs_batch_gl
Batch queue NFTE16_BATCH, available, on NFTE16::
This shows that ibs_batch_gl is a logical that points to the real queue
NFTE16_BATCH.
I can do this using DCL or LIB$GETQUI (using the QUI$_TRANSLATE_QUEUE
function), but i am unable to do this using SYS$GETQUI (which i have to use
because of other SYS$GETQUI calls).
Program is included below. The entered queue name is ALWAYS returned. What is
wrong ? Thanks
OPTION type = explicit
OPTION SIZE = INTEGER LONG, &
SIZE = REAL DOUBLE, &
CONSTANT TYPE = INTEGER
%include "$QUIDEF" %from %library "SYS$LIBRARY:BASIC$STARLET"
%include "$JBCMSGDEF" %from %library "SYS$LIBRARY:BASIC$STARLET"
external long function SYS$GETQUIW
record ItemList
variant
case
word Buflen
word Item_code
long Buff_address
long Ret_address
case
long End_list
end variant
end record ItemList
record Iosblk
long sts
long zeroed
end record Iosblk
map(qui_map) ItemList trList(1 to 5), &
Iosblk IOSB, &
string tr_search_name = 31%, &
word tr_search_name_len, &
string tr_queue_name = 31%, &
word tr_queue_name_len, &
long getqui_status
declare long cnt
declare string tmp_str
start:
input "queue to find ", tmp_str
tr_search_name = edit$(tmp_str, 39%)
cnt = 1
trlist(cnt)::Buflen = len(tr_search_name)
trlist(cnt)::Item_code = QUI$_SEARCH_NAME
trlist(cnt)::Buff_address= loc(tr_search_name)
trlist(cnt)::Ret_address = 0%
cnt = cnt + 1
trlist(cnt)::Buflen = len(tr_queue_name)
trlist(cnt)::Item_code = QUI$_QUEUE_NAME
trlist(cnt)::Buff_address= loc(tr_queue_name)
trlist(cnt)::Ret_address=loc(tr_queue_name_len)
cnt = cnt + 1
trlist(cnt)::End_list = 0%
getqui_status = sys$getquiw(, &
QUI$_TRANSLATE_QUEUE by value,, &
trlist(1), IOSB,,)
print "returned queue name ", tr_queue_name
end
The Answer is :
Please note that the function code QUI$_TRANSLATE_QUEUE targets
the translation of logical queue names and not OpenVMS logical
name translations.
The only difference between LIB$GETQUI and SYS$GETQUI is the calling
interface -- the LIB$GETQUI interface is specifically tailored for
use from high-level languages, while SYS$GETQUI and other related
system services assume the calling program can pass addresses and
such.
With few exceptions, all OpenVMS system services use very similar or
even entirely identical argument passing schemes. You will be able
to find any example of any similar system service that passes arguments
via an itemlist in your desired language, and you will be able to use
that example as a basis for your call to SYS$GETQUI.
Two common examples of system services that include itemlists among
their arguments are SYS$GETJPIW and SYS$GETDVIW. There are others.
You will also want to explicity check the return status and the status
returned in the IOSB -- topic (1661) contains a list of common programming
bugs, and a failure to check the return status and the IOSB return status
values are among the list.
As for an example of the call you request:
! This BASIC example translates the name of the logical queue
! (this name is NOT an OpenVMS logical name) to the name of an
! associated execution queue. (If you want to translate an
! OpenVMS logical name to its equivilence, use the SYS$TRNLNM
! call or similar.) Please understand the different types of
! queues, and please understand the specific purpose of the
! function code QUI$_TRANSLATE_QUEUE.
!
! The coding in this example shows how a BASIC programmer can
! build an itemlist for many of the OpenVMS system services,
! including the following calls:
!
! o SYS$GETDVI and SYS$GETDVIW
! o SYS$GETJPI and SYS$GETJPIW
! o SYS$GETSYI and SYS$GETSYIW
! o SYS$GETUAI
! o SYS$TRNLNM
! o SYS$QIO and SYS$QIOW
! o etc...
!
OPTION TYPE = EXPLICIT
%include "$QUIDEF" %from %library "SYS$LIBRARY:BASIC$STARLET.TLB"
%include "STARLET" %from %library "SYS$LIBRARY:BASIC$STARLET.TLB"
RECORD itm
WORD buflen
WORD item
LONG bufadr
LONG retlenadr
END RECORD
DECLARE itm quiil(2%)
DECLARE WORD func
DECLARE LONG stat, queue_name_length
map (io_status_block) long iosb_status
map (io_status_block) BASIC$QUADWORD iosb
MAP (strings) &
STRING input_string, &
STRING target_search_name = 31%, &
STRING queue_name = 31%
start:
! Cancel any QUI context
func = qui$_cancel_operation
stat = sys$getquiw(,func BY VALUE,,,,,)
CALL lib$stop(stat by value) IF (stat AND 1%) = 0%
queue_name_length = 0%
! Get the input
input "queue to find ", input_string
target_search_name = edit$(input_string, 39%)
print "The logical queue name... ", target_search_name
! Build the itemlist
quiil(0%)::buflen = len(target_search_name)
quiil(0%)::item = QUI$_SEARCH_NAME
quiil(0%)::bufadr = LOC(target_search_name)
quiil(0%)::retlenadr = 0%
quiil(1%)::buflen = len(queue_name)
quiil(1%)::item = QUI$_QUEUE_NAME
quiil(1%)::bufadr = LOC(queue_name)
quiil(1%)::retlenadr = LOC(queue_name_length)
quiil(2%)::buflen = 0%
quiil(2%)::item = 0%
quiil(2%)::bufadr = 0%
quiil(2%)::retlenadr = 0%
func = QUI$_TRANSLATE_QUEUE
stat = sys$getquiw(,func by value,,quiil() by ref,iosb by ref,,)
CALL lib$stop(stat by value) IF (stat AND 1%) = 0%
CALL lib$stop(iosb_status by value) IF (iosb_status AND 1%) = 0%
! Display the resulting output
print "Execution queue name..... ", queue_name
print "Returned name length..... ", queue_name_length
end
|