dyninit() — Initialize __dyn_t structure

Standards

Standards / Extensions C or C++ Dependencies
C Library both  

Format

#include <dynit.h>

int dyninit(__dyn_t *dyn_parms);

General description

Initializes the __dyn_t structure that is used to build the parameter lists that are passed to the dynalloc() function and the dynfree() function. If you do not initialize the __dyn_t structure using dyninit(), undefined behavior may result.

The __dyn_t structure is defined in the dynit.h header file. A description of the elements is found in dynalloc() — Allocate a data set.

Returned value

If successful under MVS™, dyninit() returns 0.

If unsuccessful, dyninit() returns nonzero.

Example

CELEBD09
/* CELEBD09

   This example initializes a __dyn_t
    structure, called ip.

 */
#include <stdio.h>
#include <string.h>
#include <dynit.h>

main() {
  char dsn[]="USER.TEST.DATASET";
  __dyn_t ip;
  int ret;

  dyninit(&ip);
  ip.__ddname   = "TEST";
  ip.__dsname   = dsn;
  ip.__status   = __DISP_NEW;
  ip.__normdisp = __DISP_DELETE;
  ip.__alcunit  = __TRK;
  ip.__primary  = 1;
  ip.__unit     = "SYSDA  ";

  if ((ret = dynalloc(&ip)) != 0)
    printf("dynalloc() ret=%d, error code %04x, info code %04x\n",
           ret, ip.__errcode, ip.__infocode);

  else {
    dyninit(&ip);
    ip.__ddname   = "TEST";

    if ((ret = dynfree(&ip)) != 0)
      printf("dynfree() ret=%d, error code %04x, info code %04x\n",
             ret, ip.__errcode, ip.__infocode);

    else puts("success!");
  }
}

Related information