Chapter Contents |
Previous |
Next |
The osdynalloc Function |
Portability | SAS/C extension |
SYNOPSIS | |
DESCRIPTION | |
RETURN VALUE | |
DIAGNOSTICS | |
IMPLEMENTATION | |
KEYWORD TABLES | |
EXAMPLE |
SYNOPSIS |
#include <os.h> int osdynalloc(int action, char *keywords, char *libmsgbuf, ...);
DESCRIPTION |
osdynalloc
is used to invoke the MVS dynamic allocation SVC (SVC 99).
You can use
osdynalloc
to allocate, free, concatenate or deconcatenate data sets, as well as to return
information about existing allocations. MVS dynamic allocation is described
in detail in the IBM publication MVS/ESA Application Development Guide:
Authorized Assembler Language Programs. Unless you are already familiar
with dynamic allocation, you should read the sections of this book discussing
dynamic allocation to be aware of the restrictions and other complexities
of this powerful service.
The
action
argument to
osdynalloc
specifies
the required dynamic allocation action. The names of the actions (defined
in
<os.h>
) are:
Note:
The
DYN_DDALLOC
action is very specialized. See IBM documentation for information
about the use of
DYN_DDALLOC
and how it differs from
DYN_ALLOC
.
The
keywords
argument is a pointer to a character string containing a list of keywords.
The keywords specify parameters for the request, for instance the name of
a data set to be allocated or the address of a variable in which to store
a DDname. See below for some simple examples of keyword strings.
The
libmsgbuf
argument specifies the address of an array of characters (containing
at least 128 bytes) in which any error message generated by the library is
to be stored. If
libmsgbuf
is specified as
NULL
, the
library writes any error messages to
stderr
, and the texts are not returned to the caller. Note that in
SPE if
libmsgbuf
is specified
as
NULL
, no messages will
be written unless the
$WARNING
routine has been replaced, as described in the SAS/C Compiler
and Library User's Guide. See "DIAGNOSTICS" later in this section for
further information on error handling.
Additional arguments to
osdynalloc
may optionally be specified after the
libmsgbuf
argument. These arguments are used
to complete the
keywords
string, as shown in the examples below.
Here are a few simple calls to
osdynalloc
, to show how keyword strings are assembled:
rc = osdynalloc(DYN_ALLOC,
"ddn=master,dsn=billing.master.data,disp=shr", NULL);
rc = osdynalloc(DYN_FREE,
"ddn=master,disp=delete,reason=?", NULL, & reason);
reason
.
rc = osdynalloc(DYN_CONCAT,
"ddn=(syslib,syslib1,syslib2),perm", NULL);
rc = osdynalloc(DYN_INQUIRE,
"ddn=master,retdsn=?,retdsorg=?,msgcount=?,errmsgs=?", libmsgbuf, dsnbuf,
& dsorg, & number_msgs, & mvsmsgbuf);
dsnbuf
and
dsorg
. If the request fails, any library message
is stored in
libmsgbuf
,
and the address of an MVS message buffer is stored in
mvsmsgbuf
. Also, the number of MVS messages
is stored in
number_msgs
.
The
keywords
argument to
osdynalloc
is just a list of items separated by commas. Each item is identified
by a keyword, like
"ddn"
,
"disp"
and
"perm"
in the examples above. The permitted keywords
are determined by the particular action requested by
action
, and are described in tables appearing
later in this description. Each keyword in the string is translated by
osdynalloc
into a single dynamic
allocation text unit. (See Authorized Assembler Language Programs
for further information on text units.) Additional keywords are accepted
in calls to
osdynalloc
,
regardless of
action
, such
as
"reason"
and
"errmsgs"
in the examples above. These keywords
correspond to fields in the SVC 99 request block, and generally request special
processing options or deal with error-handling.
Syntactically, there are three kinds of
keywords
items, as follows:
"disp=shr"
. These items have the form
"
keyword
=
value
"
.
"ddn=(syslib,syslib2)"
. These items have the
form
"
keyword
=(
value1
,
value2
,...)"
. If there is only one value, the parentheses can be left off.
"dummy"
. These items
have a keyword, but no value.
Any keyword value may be specified as the single character
"?"
. This indicates that the
actual keyword value is present in the argument list as an additional argument.
The order of any additional arguments is the same as the order of the corresponding
keywords in the
keywords
string. Note that for multiple value keywords, each ? corresponds to a single
value. That is, you could have a call like the following:
osdynalloc(DYN_ALLOC, "...volser=(?,?),...", NULL, "VOLUM1", "VOLUM2")
However, you cannot have a call like the following:
osdynalloc(DYN_ALLOC, "...volser=?,...", NULL, "(VOLUM1,VOLUM2)")
The keywords accepted by
osdynalloc
are classified into various sorts based on the type of the
associated values:
"member=name"
, that have a value
which is a character string. An argument supplied using the
"?"
convention should have type
char *
. With a few exceptions, string values
are automatically translated to upper-case.
"dsn=.project.c"
, that have a
string value that is interpreted as a data set name. If the name begins
with a period, the name is completed by prepending the user's TSO prefix or
(in batch) the userid.
"disp=old"
, that have a string
value which is limited to a prescribed set of values. Except for this limitation,
they are treated as string values. The values permitted for particular keywords
are the values permitted for the corresponding JCL parameter, unless stated
otherwise below.
"blksize=800"
, that have a value
that is a decimal or hexadecimal string. An argument supplied using the
"?"
convention should have type
int
.
"retddn=0xf0328"
, that have a
value that is a decimal or hexadecimal address, pointing to an area where
information is to be returned. This must be the address of a variable of
the appropriate type, either
int
for numeric information, or a
char
array for string information. In many cases, the values returned
via pointers are encoded. For instance, a dsorg (data set organization) is
returned as an integer with different bits set depending on the actual file
organization. Information on interpreting these values is given in the IBM
book cited above.
There are also keywords with specialized value representations
(such as
"secmodel="
and
"expdt="
). These are discussed
individually in the keyword tables below.
RETURN VALUE |
osdynalloc
returns
0
if it was successful. It returns a negative value if an error was detected
by the C library before the dynamic allocation SVC could be invoked. In this
case, a diagnostic message will have been stored in
libmsgbuf
if this address is not
NULL
. If SVC 99 is called and fails,
osdynalloc
returns the value returned in register 15 by SVC 99, as
described in Authorized Assembler Language Programs. Additional
information about the error can be obtained by use of keywords such as
"reason"
,
"inforeason"
and
"errmsgs"
, as described in SVC 99 Request Block Keywords.
DIAGNOSTICS |
osdynalloc
is subject to three different sorts of errors.
The first sort is errors detected before calling SVC
99. Examples of such errors are unrecognized keywords or memory allocation
failures. The SAS/C library generates diagnostics for these failures and either
writes them to
stderr
or
returns them to the user via the
libmsgbuf
argument. SVC 99 is not issued if one of these errors occurs.
The second sort is errors detected by SVC 99. Information
about these errors is returned in the
osdynalloc
return code, and additional information can be obtained
via keywords like
"reason"
.
The library never diagnoses any of these errors. The
"errmsgs"
keyword may additionally be specified
to request that one or more messages about a failure be returned to the caller.
These messages are obtained by a call to the IBM routine IEFDB476. Note
that these messages are frequently unsuitable for particular applications.
(For example, the message for an out-of-disk-space situation exhorts the
user to "
USE THE DELETE COMMAND
TO DELETE UNNEEDED DATA SETS
", even if the program is not running under
TSO.) Also note that the
"issuemsg"
keyword can be used to request that dynamic allocation issue these
messages itself, using either the PUTLINE service or the WTO SVC.
The third sort of error is errors detected by IEFDB476.
These errors are not diagnosed by the library or by MVS, and do not affect
the
osdynalloc
return code.
The IEFDB476 error codes can be accessed using the
"msgerror"
and
"msgreason"
keywords.
IMPLEMENTATION |
osdynalloc
is implemented by the L$UDYNA module, which is provided
in source form. You can modify this module to add or delete keywords. You
might wish to add keywords if functionality is added to SVC 99 by a new release
of MVS. You might wish to delete keywords if you have a storage-constrained
application which does not need to use some of the more obscure dynamic allocation
options or keywords.
KEYWORD TABLES |
SVC 99 Request Block Keywords shows all the keywords that can be used
for any call to
osdynalloc
,
regardless of which action is specified. These keywords are not translated
to text units. Rather, they cause information to be stored in the SVC 99
request block (S99RB) or request block extension (S99RBX). Most options can
be identified by more than one keyword. This is intended to assist you to
easily locate the keywords you need. Short forms correspond to the field
names defined in Authorized Assembler Language Programs, as well
as longer names which may be more understandable or easier to recall.
In SVC 99 Request Block Keywords
Notes
column indicates
the value returned is not the value stored in S99EMSGP.
osdynalloc
calls IEFDB476 to turn the S99EMSGP
value into an array of message buffers, a pointer to which is returned to
the user in the variable specified by the keyword. Each element of the array
is of type
dyn_msgbuf
.
(This type is defined in
<os.h>
.) The buffer should be released by a call to
free
after the messages have been processed.
(char *) -1
is stored in the return area. The return value from
osdynalloc
is not affected.
Notes
column indicates
use of these keywords is not recommended because they store an entire byte
of flags. Use of the keywords for individual flags will result in more easily
understandable programs. If you use one of these keywords, any flag bits
turned on by previous keywords in the string will be lost. For instance,
if you code the keywords
nomount,flag1=0x40
, the nomount bit will not be set.
Notes
column indicates
valid values for this keyword are
0
for all messages,
4
for warning and error messages, and
8
for only error messages.
See Dynamic Allocation Keywords,
Dynamic Free Keywords, Dynamic Deconcatenation Keywords,
Dynamic Mark Not-in-use Keywords, Dynamic DDname Allocation Keywords, and
Dynamic Allocation Inquiry Keywords for each
dynamic allocation action, the supported keywords and their characteristics.
For each keyword, the table shows the JCL equivalent (if any), the corresponding
SVC 99 text unit key (which can be used to locate additional information about
the keyword in Authorized Assembler Language Programs), the expected
C type and format of the keyword value (if any), and a brief description.
For keywords whose values are restricted to a specific size,
char[n]
is shown as the type, where
n
is the array size needed to hold the largest
permitted value. This includes space for a terminating null so that, for
instance, DDnames are shown as
char[9]
, even though the DDname itself is limited to eight characters.
For values shown as pointers to arrays, the array passed must be of exactly
the size shown.
The Format column of the table may contain one or more of the following values:
Dsname | The keyword value is a data set name, and may be specified with an initial period to request that the TSO prefix or userid be prepended. |
Encoded | The stored value is encoded as an integer. See the IBM documentation, the Authorized Assembler Language Programs, book for a description of the encoding for a particular keyword. |
Multiple | The keyword allows more than one value to be specified. |
Optional | The keyword permits a value to be specified, but one is not required. |
Res Word |
The keyword value is a reserved word (for example,
"disp="
) or a string of single-letter
flags (for example,
"recfm="
).
The permitted values are described in the IBM documentation, MVS/ESA
JCL Reference. |
In Dynamic Allocation Keywords
Notes
column indicates
a value of L may be specified for this option in the keywords string. If
the value is specified as an extra argument, it must be numeric. An argument
value of 0x80 is interpreted as L.
Notes
column indicates
an expiration date may be specified in one of three formats. In a five-digit
expiration date, the first two digits are interpreted as the years since
1900. In a seven-digit expiration date, the first four digits are the entire
year. The format "yyyy/ddd", as used with the JCL EXPDT keyword, is also
supported.
Notes
column indicates
a value of X may be specified for this option in the keywords string. If
the value is specified as an extra argument, it must be numeric. An argument
value of 0x8000 is interpreted as X.
Notes
column indicates
this parameter value is not translated to upper case.
Notes
column indicates
this keyword has the same syntax as the JCL SECMODEL keyword. That is, it
may be specified either as "dsname" or as "(dsname,GENERIC)". In the latter
format, the GENERIC must be present in the keyword value and cannot be specified
as an extra argument. With either format, if the "?" notation is used, the
extra argument may specify only the data set name. That is, the following
calls are correct:
osdynalloc(DYN_ALLOC, "secmodel=?", NULL, "SYS1.PARMLIB"); osdynalloc(DYN_ALLOC, "secmodel=(?,GENERIC)", NULL, "SYS1.PARMLIB");
while
the following are not supported:
osdynalloc(DYN_ALLOC, "secmodel=?", NULL, "(SYS1.PARMLIB,GENERIC)"); osdynalloc(DYN_ALLOC, "secmodel=(?,?), NULL, "SYS1.PARMLIB", "GENERIC");
Notes
column
indicates the only value currently accepted for this keyword is SYSIN (requesting
a SYSIN data set).
Identifier | JCL Equiv | SVC 99Key | Value | Format | Description | Notes |
---|---|---|---|---|---|---|
ddname | none | DDCDDNAM | char[9] |
|
DDnames to deconcatenate |
|
In Dynamic Allocation Inquiry Keywords
Notes
column indicates
the value for this keyword is not translated to upper case.
Notes
column indicates
the value for the
"retsecmodel"
keyword is a pointer to an object of type
struct secmodel
, defined in
<os.h>
. This structure includes a field
profile
, in which the model profile name will be stored, and a field
generic
, in which an encoded
indication
of whether the profile is generic will be stored. See the IBM publication,
the Authorized Assembler Language Programs for encoding information.
EXAMPLE |
#include <os.h> #include <stdio.h> #include <stdlib.h> #include <string.h> main() { char dsname[45]; char member[9]; char keywords[100]; char pathname[256]; int reason = 0; int rc; rc = osdynalloc(DYN_INQUIRE, "ddn=sysin,retdsn=?,retmem=?,retpath=?,reason=?", NULL, dsname, member, pathname, &reason); if (rc < 0) abort(); /* if input parm error */ if (rc != 0) { if (reason == 0x0438) /* DDname not found */ printf("SYSIN is not allocated.\n"); else printf("osdynalloc inquiry failed, rc = %d, " "reason = %04x\n", rc, reason); exit(EXIT_FAILURE); } if (dsname[0] != 0) { /* the file is a data set */ int l = strlen(dsname); char *lastdot; if (l > 4 && memcmp(dsname+l-4, ".OBJ", 4) == 0) { printf("SYSIN appears to be a .OBJ dataset.\n"); exit(EXIT_FAILURE); } lastdot = strrchr(dsname, '.'); /* find final qualifier */ if (!lastdot) lastdot = dsname+strlen(dsname); if (lastdot+4 > &dsname[44]) { printf("Object data set name too long.\n"); exit(EXIT_FAILURE); } strcpy(lastdot, ".OBJ"); /* replace with .OBJ */ sprintf(keywords, "ddn=sysin,dsn=%s%s%s,disp=shr,reason=?", dsname, (member[0]? ",member=": ""), member); /* build keywords, with or without a member name */ rc = osdynalloc(DYN_ALLOC, keywords, NULL, &reason); if (rc < 0) abort(); if (rc != 0) { printf("osdynalloc dsn allocation failed, rc = %d, " "reason = %04x\n", rc, reason); exit(EXIT_FAILURE); } } else { /* else, an HFS path name */ int l = strlen(pathname); char *lastdot; if (l > 2 && memcmp(pathname+l-2, ".o", 2) == 0) { printf("SYSIN appears to be a .o HFS file.\n"); exit(EXIT_FAILURE); } lastdot = strrchr(pathname, '.'); /* find extension */ if (!lastdot) lastdot = pathname+strlen(pathname); if (lastdot+2 > &pathname[255]) { printf("Object data set name too long.\n"); exit(EXIT_FAILURE); } strcpy(lastdot, ".o"); /* replace with .o */ rc = osdynalloc(DYN_ALLOC, "ddn=syslin,path=?,pathdisp=keep," "pathopts=ordonly,reason=?", NULL, pathname, &reason); if (rc < 0) abort(); if (rc != 0) { printf("osdynalloc path allocation failed, rc = %d, ' "reason = %04x\n", rc, reason); exit(EXIT_FAILURE); } } puts("SYSLIN successfully allocated."); exit(EXIT_SUCCESS); }
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.