9
#include <libipv1/ip_lib.h>
10
#include <libciomr/libciomr.h>
13
/* Definitions of global structs */
15
psio_address PSIO_ZERO = {0,0};
17
/* Library state variable */
18
int _psi3_libpsio_state_ = 0;
26
** PSIO_INIT(): Allocates global memory needed by the I/O routines.
37
char filename[PSIO_MAXSTR];
40
psio_unit = (psio_ud *) malloc(sizeof(psio_ud)*PSIO_MAXUNIT);
43
psio_readlen = (ULI *) malloc(sizeof(ULI) * PSIO_MAXUNIT);
44
psio_writlen = (ULI *) malloc(sizeof(ULI) * PSIO_MAXUNIT);
47
if(psio_unit == NULL) {
48
fprintf(stderr, "Error in PSIO_INIT()!\n");
49
exit(PSI_RETURN_FAILURE);
52
for(i=0; i < PSIO_MAXUNIT; i++) {
54
psio_readlen[i] = psio_writlen[i] = 0;
56
psio_unit[i].numvols = 0;
57
for(j=0; j < PSIO_MAXVOL; j++) {
58
psio_unit[i].vol[j].path = NULL;
59
psio_unit[i].vol[j].stream = -1;
61
psio_unit[i].tocaddress.page = 0;
62
psio_unit[i].tocaddress.offset = 0;
63
psio_unit[i].toclen = 0;
64
psio_unit[i].toc = NULL;
67
/* Open user's general .psirc file, if extant */
68
userhome = getenv("HOME");
69
sprintf(filename, "%s%s", userhome, "/.psirc");
70
psirc = fopen(filename, "r");
72
ip_append(psirc, stdout);
76
/* Set library's state variable to initialized value (1) */
77
_psi3_libpsio_state_ = 1;
83
** PSIO_STATE(): Returns state of the library (1=initialized, 0=noninitialized).
92
return _psi3_libpsio_state_;