GnuCOBOL  2.0
A free COBOL compiler
isopen.c File Reference
#include "isinternal.h"
Include dependency graph for isopen.c:

Go to the source code of this file.

Functions

int ivbforceexit (const int ihandle)
 
int ivbclose2 (const int ihandle)
 
void ivbclose3 (const int ihandle)
 
int iscleanup (void)
 
int isclose (const int ihandle)
 
int isfullclose (const int ihandle)
 
int isindexinfo (const int ihandle, void *pskeydesc, const int ikeynumber)
 
int isopen (const char *pcfilename, int imode)
 
int issetcollate (const int ihandle, const unsigned char *collating_sequence)
 

Function Documentation

int iscleanup ( void  )

Definition at line 152 of file isopen.c.

References DICTINFO::iisopen, isclose(), iserrno, islogclose(), ivbclose2(), ivbclose3(), ivblogfilehandle, ivbmaxusedhandle, and psvbfile.

Referenced by cob_exit_fileio().

153 {
154  int iloop, iresult, iresult2 = 0;
155 
156  for (iloop = 0; iloop <= ivbmaxusedhandle; iloop++)
157  if (psvbfile[iloop]) {
158  if (psvbfile[iloop]->iisopen == 0) {
159  iresult = isclose (iloop);
160  if (iresult) {
161  iresult2 = iserrno;
162  }
163  }
164  if (psvbfile[iloop]->iisopen == 1) {
165  iresult = ivbclose2 (iloop);
166  if (iresult) {
167  iresult2 = iserrno;
168  }
169  }
170  ivbclose3 (iloop);
171  }
172  if (ivblogfilehandle >= 0) {
173  iresult = islogclose ();
174  if (iresult) {
175  iresult2 = iserrno;
176  }
177  }
178  return iresult2;
179 }
int ivbclose2(const int ihandle)
Definition: isopen.c:83
int ivbmaxusedhandle
Definition: vblocking.c:26
void ivbclose3(const int ihandle)
Definition: isopen.c:125
struct DICTINFO * psvbfile[128+1]
Definition: vblowlevel.c:23
int islogclose(void)
Definition: istrans.c:509
int isclose(const int ihandle)
Definition: isopen.c:182
int ivblogfilehandle
Definition: istrans.c:24
int iserrno
Definition: vbmemio.c:27

Here is the call graph for this function:

Here is the caller graph for this function:

int isclose ( const int  ihandle)

Definition at line 182 of file isopen.c.

References DICTINFO::iindexchanged, DICTINFO::iisopen, DICTINFO::iopenmode, iserrno, ivbclose2(), ivbforceexit(), ivbintrans, ivbmaxusedhandle, psvbfile, unlikely, VBBEGIN, VBNEEDFLUSH, and VBRECOVER.

Referenced by ircvbuild(), ircvfileclose(), isbuild(), iscleanup(), iserase(), isfullclose(), ivbrollmeback(), ivbrollmeforward(), and vcloseall().

183 {
184  struct DICTINFO *psvbptr;
185 
186  if (unlikely(ihandle < 0 || ihandle > ivbmaxusedhandle)) {
187  iserrno = EBADARG;
188  return -1;
189  }
190  psvbptr = psvbfile[ihandle];
191  if (!psvbptr || psvbptr->iisopen) {
192  iserrno = ENOTOPEN;
193  return -1;
194  }
195  if (psvbptr->iopenmode & ISEXCLLOCK) {
196  ivbforceexit (ihandle); /* BUG retval */
197  }
198  psvbptr->iindexchanged = 0;
199  psvbptr->iisopen = 1;
201  if (ivbclose2 (ihandle)) {
202  return -1;
203  }
204  }
205  return 0;
206 }
int ivbclose2(const int ihandle)
Definition: isopen.c:83
#define VBBEGIN
Definition: isinternal.h:307
unsigned char iindexchanged
Definition: isinternal.h:434
#define VBRECOVER
Definition: isinternal.h:311
int ivbmaxusedhandle
Definition: vblocking.c:26
int iisopen
Definition: isinternal.h:407
#define VBNEEDFLUSH
Definition: isinternal.h:308
#define unlikely(x)
Definition: common.h:437
int ivbforceexit(const int ihandle)
Definition: isopen.c:50
struct DICTINFO * psvbfile[128+1]
Definition: vblowlevel.c:23
int iopenmode
Definition: isinternal.h:412
int iserrno
Definition: vbmemio.c:27
int ivbintrans
Definition: istrans.c:23

Here is the call graph for this function:

Here is the caller graph for this function:

int isfullclose ( const int  ihandle)

Definition at line 209 of file isopen.c.

References isclose(), iserrno, ivbclose3(), ivbmaxusedhandle, and unlikely.

Referenced by indexed_close(), indexed_open(), and ischeck().

210 {
211  if (unlikely(ihandle < 0 || ihandle > ivbmaxusedhandle)) {
212  iserrno = EBADARG;
213  return -1;
214  }
215  isclose (ihandle);
216  ivbclose3 (ihandle);
217  return 0;
218 }
int ivbmaxusedhandle
Definition: vblocking.c:26
#define unlikely(x)
Definition: common.h:437
void ivbclose3(const int ihandle)
Definition: isopen.c:125
int isclose(const int ihandle)
Definition: isopen.c:182
int iserrno
Definition: vbmemio.c:27

Here is the call graph for this function:

Here is the caller graph for this function:

int isindexinfo ( const int  ihandle,
void *  pskeydesc,
const int  ikeynumber 
)

Definition at line 221 of file isopen.c.

References DICTINFO::iisopen, DICTINFO::imaxrowlength, DICTINFO::iminrowlength, DICTINFO::inkeys, DICTINFO::inodesize, DICTINFO::iopenmode, iserrno, isreclen, ivbenter(), ivbexit(), ivbmaxusedhandle, DICTINFO::pskeydesc, psvbfile, and unlikely.

Referenced by indexed_open().

222 {
223  char *pctemp;
224  struct DICTINFO *psvbptr;
225  struct dictinfo sdict;
226 
227  if (unlikely(ihandle < 0 || ihandle > ivbmaxusedhandle)) {
228  iserrno = EBADARG;
229  return -1;
230  }
231  psvbptr = psvbfile[ihandle];
232  if (!psvbptr || psvbptr->iisopen) {
233  iserrno = ENOTOPEN;
234  return -1;
235  }
236  iserrno = EBADKEY;
237  if (ikeynumber < 0 || ikeynumber > psvbptr->inkeys) {
238  return -1;
239  }
240  iserrno = 0;
241  if (ikeynumber) {
242  memcpy (pskeydesc, psvbptr->pskeydesc[ikeynumber - 1],
243  sizeof (struct keydesc));
244  return 0;
245  }
246 
247  if (ivbenter (ihandle, 1, 0)) {
248  return -1;
249  }
250 
251  sdict.di_nkeys = psvbptr->inkeys;
252  if (psvbptr->iopenmode & ISVARLEN) {
253  pctemp = (char *)&sdict.di_nkeys;
254  *pctemp |= 0x80;
255  }
256  sdict.di_recsize = psvbptr->imaxrowlength;
257  sdict.di_idxsize = psvbptr->inodesize;
258 /* RXW
259  sdict.di_nrecords = tcountrows (ihandle);
260 */
261  sdict.di_nrecords = 0;
262  isreclen = psvbptr->iminrowlength;
263  memcpy (pskeydesc, &sdict, sizeof (struct dictinfo));
264 
265  ivbexit (ihandle);
266  return 0;
267 }
int inkeys
Definition: isinternal.h:400
int imaxrowlength
Definition: isinternal.h:404
int isreclen
Definition: vbmemio.c:29
int ivbenter(const int ihandle, const unsigned int imodifying, const unsigned int ispecial)
Definition: vblocking.c:178
int iminrowlength
Definition: isinternal.h:403
int ivbmaxusedhandle
Definition: vblocking.c:26
int iisopen
Definition: isinternal.h:407
#define unlikely(x)
Definition: common.h:437
struct DICTINFO * psvbfile[128+1]
Definition: vblowlevel.c:23
int ivbexit(const int ihandle)
Definition: vblocking.c:290
int iopenmode
Definition: isinternal.h:412
struct keydesc * pskeydesc[32]
Definition: isinternal.h:445
int iserrno
Definition: vbmemio.c:27
int inodesize
Definition: isinternal.h:402

Here is the call graph for this function:

Here is the caller graph for this function:

int isopen ( const char *  pcfilename,
int  imode 
)

Definition at line 270 of file isopen.c.

References DICTINFO::cfilename, DICTNODE::cindexcount, DICTNODE::cmaxrowlength, DICTNODE::cminrowlength, DICTNODE::cnodekeydesc, DICTNODE::cnodesize, DICTNODE::cvalidation, cvbnodetmp, DICTINFO::idatahandle, DICTINFO::iindexhandle, DICTINFO::iisopen, DICTINFO::imaxrowlength, DICTINFO::iminrowlength, DICTINFO::inkeys, inl_ldint(), inl_ldquad(), DICTINFO::inodesize, DICTINFO::iopenmode, iserrno, isstart(), DICTINFO::itransyet, ivbblockread(), ivbclose(), ivbenter(), ivbexit(), ivbfileopenlock(), ivbintrans, ivblogfilehandle, ivbmaxusedhandle, ivbopen(), ivbtransopen(), MAX_NODE_LENGTH, MAX_RESERVED_LENGTH, MAXSUBS, NULL, O_BINARY, DICTINFO::ppcrowbuffer, DICTINFO::pskeydesc, psvbfile, pvvbmalloc(), QUADSIZE, DICTINFO::sdictnode, VB_MAX_FILES, VB_NODE_MAX, VBNOTRANS, and vvbfree().

Referenced by indexed_open(), ircvfileopen(), isbuild(), ischeck(), ivbrollmeback(), and ivbrollmeforward().

271 {
272  struct DICTINFO *psvbptr;
273  char *pctemp;
274  struct keydesc *pkptr;
275  off_t tnodenumber;
276  int iflags;
277  int ihandle, iindexnumber = 0, iindexpart;
278  int ikeydesclength, ilengthused, iloop, iresult;
279  struct stat sstat;
280  char tmpfname[1024];
281  char cvbnodetmp[VB_NODE_MAX];
282 
283  if ((imode & ISTRANS) && ivblogfilehandle < 0) {
284  iserrno = EBADARG; /* I'd have expected ENOLOG or ENOTRANS! */
285  return -1;
286  }
287  iflags = imode & 0x03;
288  if (iflags == 3) {
289  /* Cannot be BOTH ISOUTPUT and ISINOUT */
290  iserrno = EBADARG;
291  return -1;
292  }
293  if (strlen (pcfilename) > sizeof(tmpfname) - 5) {
294  iserrno = EFNAME;
295  return -1;
296  }
297  /*
298  * The following for loop deals with the concept of re-opening a file
299  * that was closed within the SAME transaction. Since we were not
300  * allowed to perform the FULL close during the transaction because we
301  * needed to retain all the transactional locks, we can tremendously
302  * simplify the re-opening process.
303  */
304  for (ihandle = 0; ihandle <= ivbmaxusedhandle; ihandle++) {
305  psvbptr = psvbfile[ihandle];
306  if (psvbptr && psvbptr->iisopen != 0) {
307  if (!strcmp (psvbptr->cfilename, pcfilename)) {
308  if (psvbptr->iisopen == 2) {
309  sprintf (tmpfname, "%s.idx", pcfilename);
310  psvbptr->iindexhandle =
311  ivbopen (tmpfname, O_RDWR | O_BINARY, 0);
312  sprintf (tmpfname, "%s.dat", pcfilename);
313  psvbptr->idatahandle =
314  ivbopen (tmpfname, O_RDWR | O_BINARY, 0);
315  if (imode & ISEXCLLOCK) {
316  iresult = ivbfileopenlock (ihandle, 2);
317  } else {
318  iresult = ivbfileopenlock (ihandle, 1);
319  }
320  if (iresult) {
321  errno = EFLOCKED;
322  goto open_err;
323  }
324  }
325  psvbptr->iisopen = 0;
326  psvbptr->iopenmode = imode;
327  return ihandle;
328  }
329  }
330  }
331  for (ihandle = 0; ; ihandle++) {
332  if (ihandle > ivbmaxusedhandle) {
334  iserrno = ETOOMANY;
335  return -1;
336  }
337  ivbmaxusedhandle = ihandle;
338  break;
339  }
340  if (psvbfile[ihandle] == NULL) {
341  break;
342  }
343  }
344  psvbfile[ihandle] = pvvbmalloc (sizeof (struct DICTINFO));
345  if (psvbfile[ihandle] == NULL) {
346  errno = EBADMEM;
347  goto open_err;
348  }
349  psvbptr = psvbfile[ihandle];
350  psvbptr->cfilename = strdup (pcfilename);
351  if (psvbptr->cfilename == NULL) {
352  errno = EBADMEM;
353  goto open_err;
354  }
356  if (psvbptr->ppcrowbuffer == NULL) {
357  errno = EBADMEM;
358  goto open_err;
359  }
360  psvbptr->idatahandle = -1;
361  psvbptr->iindexhandle = -1;
362  sprintf (tmpfname, "%s.dat", pcfilename);
363  if (stat (tmpfname, &sstat)) {
364  errno = ENOENT;
365  goto open_err;
366  }
367  sprintf (tmpfname, "%s.idx", pcfilename);
368  if (stat (tmpfname, &sstat)) {
369  errno = ENOENT;
370  goto open_err;
371  }
372  psvbptr->iindexhandle = ivbopen (tmpfname, O_RDWR | O_BINARY, 0);
373  if (psvbptr->iindexhandle < 0) {
374  goto open_err;
375  }
376  sprintf (tmpfname, "%s.dat", pcfilename);
377  psvbptr->idatahandle = ivbopen (tmpfname, O_RDWR | O_BINARY, 0);
378  if (psvbptr->idatahandle < 0) {
379  goto open_err;
380  }
381  psvbptr->iisopen = 0;
382 
383  psvbptr->inodesize = MAX_NODE_LENGTH;
384  /* Get dictionary node and set node size */
385  if (ivbenter (ihandle, 1, 1)) {
386  errno = iserrno;
387  goto open_err;
388  }
389  errno = EBADFILE;
390 #if ISAMMODE == 1
391  if (psvbptr->sdictnode.cvalidation[0] != 0x56
392  || psvbptr->sdictnode.cvalidation[1] != 0x42) {
393  goto open_err;
394  }
395 #else
396  if (psvbptr->sdictnode.cvalidation[0] != -2
397  || psvbptr->sdictnode.cvalidation[1] != 0x53) {
398  goto open_err;
399  }
400 #endif
401  psvbptr->inodesize = inl_ldint (psvbptr->sdictnode.cnodesize) + 1;
402  psvbptr->inkeys = inl_ldint (psvbptr->sdictnode.cindexcount);
403  psvbptr->iminrowlength = inl_ldint (psvbptr->sdictnode.cminrowlength);
404  if (imode & ISVARLEN) {
405  psvbptr->imaxrowlength = inl_ldint (psvbptr->sdictnode.cmaxrowlength);
406  } else {
407  psvbptr->imaxrowlength = psvbptr->iminrowlength;
408  }
409 
410  errno = EROWSIZE;
411  if (psvbptr->imaxrowlength && psvbptr->imaxrowlength != psvbptr->iminrowlength) {
412  if (!(imode & ISVARLEN)) {
413  goto open_err;
414  }
415  } else {
416  if (imode & ISVARLEN) {
417  goto open_err;
418  }
419  }
420  psvbptr->iopenmode = imode;
421  tnodenumber = inl_ldquad (psvbptr->sdictnode.cnodekeydesc);
422 
423  /* Fill in the keydesc stuff */
424  while (tnodenumber) {
425  iresult = ivbblockread (ihandle, 1, tnodenumber, cvbnodetmp);
426  errno = EBADFILE;
427  if (iresult) {
428  goto open_err;
429  }
430  pctemp = cvbnodetmp;
431  if (*(cvbnodetmp + psvbptr->inodesize - 3) != -1
432  || *(cvbnodetmp + psvbptr->inodesize - 2) != 0x7e) {
433  goto open_err;
434  }
435  ilengthused = inl_ldint (pctemp);
436  pctemp += INTSIZE;
437  tnodenumber = inl_ldquad (pctemp);
438  pctemp += QUADSIZE;
439  ilengthused -= (INTSIZE + QUADSIZE);
440  while (ilengthused > 0) {
441  errno = EBADFILE;
442  if (iindexnumber >= MAXSUBS) {
443  goto open_err;
444  }
445  ikeydesclength = inl_ldint (pctemp);
446  ilengthused -= ikeydesclength;
447  pctemp += INTSIZE;
448  psvbptr->pskeydesc[iindexnumber] = pvvbmalloc (sizeof (struct keydesc));
449  pkptr = psvbptr->pskeydesc[iindexnumber];
450  if (pkptr == NULL) {
451  errno = EBADMEM;
452  goto open_err;
453  }
454  pkptr->k_nparts = 0;
455  pkptr->k_len = 0;
456  pkptr->k_rootnode = inl_ldquad (pctemp);
457 /* RXW
458  memcpy (&(pkptr->k_rootnode), pctemp, QUADSIZE);
459 */
460  pctemp += QUADSIZE;
461  pkptr->k_flags = (*pctemp) * 2;
462  pctemp++;
463  ikeydesclength -= (QUADSIZE + INTSIZE + 1);
464  iindexpart = 0;
465  if (*pctemp & 0x80) {
466  pkptr->k_flags |= ISDUPS;
467  }
468  *pctemp &= ~0x80;
469  while (ikeydesclength > 0) {
470  pkptr->k_nparts++;
471  pkptr->k_part[iindexpart].kp_leng = inl_ldint (pctemp);
472  pkptr->k_len += pkptr->k_part[iindexpart].kp_leng;
473  pctemp += INTSIZE;
474  pkptr->k_part[iindexpart].kp_start = inl_ldint (pctemp);
475  pctemp += INTSIZE;
476  pkptr->k_part[iindexpart].kp_type = *pctemp;
477  pctemp++;
478  ikeydesclength -= ((INTSIZE * 2) + 1);
479  errno = EBADFILE;
480  if (ikeydesclength < 0) {
481  goto open_err;
482  }
483  iindexpart++;
484  }
485  iindexnumber++;
486  }
487  if (ilengthused < 0) {
488  goto open_err;
489  }
490  }
491  if (imode & ISEXCLLOCK) {
492  iresult = ivbfileopenlock (ihandle, 2);
493  } else {
494  iresult = ivbfileopenlock (ihandle, 1);
495  }
496  if (iresult) {
497  errno = EFLOCKED;
498  goto open_err;
499  }
500  ivbexit (ihandle);
501  iresult = isstart (ihandle, psvbptr->pskeydesc[0], 0, NULL, ISFIRST);
502  if (iresult) {
503  errno = iserrno;
504  goto open_err;
505  }
506 
507  if (ivbintrans == VBNOTRANS) {
508  ivbtransopen (ihandle, pcfilename);
509  psvbptr->itransyet = 1;
510  }
511  return ihandle;
512 open_err:
513  ivbexit (ihandle);
514  psvbptr = psvbfile[ihandle];
515  if (psvbptr != NULL) {
516  for (iloop = 0; iloop < MAXSUBS; iloop++) {
517  if (psvbptr->pskeydesc[iloop]) {
518  vvbfree (psvbptr->pskeydesc[iloop]);
519  }
520  }
521  if (psvbptr->idatahandle != -1) {
522  ivbclose (psvbptr->idatahandle);
523  }
524  if (psvbptr->idatahandle != -1) {
525  ivbclose (psvbptr->iindexhandle);
526  }
527  if (psvbptr->cfilename) {
528  free (psvbptr->cfilename);
529  }
530  if (psvbptr->ppcrowbuffer) {
531  free (psvbptr->ppcrowbuffer);
532  }
533  vvbfree (psvbptr);
534  }
535  psvbfile[ihandle] = NULL;
536  iserrno = errno;
537  return -1;
538 }
int ivbopen(const char *pcfilename, const int iflags, const mode_t tmode)
Definition: vblowlevel.c:32
int inkeys
Definition: isinternal.h:400
int imaxrowlength
Definition: isinternal.h:404
static int inl_ldint(void *pclocation)
Definition: isinternal.h:170
int ivbblockread(const int ihandle, const int iisindex, const off_t tblocknumber, char *cbuffer)
Definition: vblowlevel.c:137
char cminrowlength[2]
Definition: isinternal.h:369
int iindexhandle
Definition: isinternal.h:406
int ivbenter(const int ihandle, const unsigned int imodifying, const unsigned int ispecial)
Definition: vblocking.c:178
char cnodekeydesc[8]
Definition: isinternal.h:370
#define VBNOTRANS
Definition: isinternal.h:306
void vvbfree(void *mptr)
Definition: vbmemio.c:59
int iminrowlength
Definition: isinternal.h:403
int isstart(const int ihandle, struct keydesc *pskeydesc, int ilength, char *pcrow, int imode)
Definition: isread.c:469
#define O_BINARY
Definition: fileio.c:90
char * cfilename
Definition: isinternal.h:422
int ivbmaxusedhandle
Definition: vblocking.c:26
#define VB_NODE_MAX
Definition: isinternal.h:288
int iisopen
Definition: isinternal.h:407
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
char cvalidation[2]
Definition: isinternal.h:360
#define MAX_NODE_LENGTH
Definition: isinternal.h:283
struct DICTNODE sdictnode
Definition: isinternal.h:444
#define VB_MAX_FILES
Definition: isinternal.h:120
void * pvvbmalloc(const size_t size)
Definition: vbmemio.c:45
int ivbfileopenlock(const int ihandle, const int imode)
Definition: vblocking.c:380
char cmaxrowlength[2]
Definition: isinternal.h:382
char cnodesize[2]
Definition: isinternal.h:365
struct DICTINFO * psvbfile[128+1]
Definition: vblowlevel.c:23
#define QUADSIZE
Definition: isinternal.h:108
char cindexcount[2]
Definition: isinternal.h:366
int ivbclose(const int ihandle)
Definition: vblowlevel.c:93
int ivbexit(const int ihandle)
Definition: vblocking.c:290
int iopenmode
Definition: isinternal.h:412
#define MAX_RESERVED_LENGTH
Definition: isinternal.h:290
int ivblogfilehandle
Definition: istrans.c:24
static char * cvbnodetmp
Definition: ischeck.c:25
struct keydesc * pskeydesc[32]
Definition: isinternal.h:445
static off_t inl_ldquad(void *pclocation)
Definition: isinternal.h:238
unsigned char itransyet
Definition: isinternal.h:438
int idatahandle
Definition: isinternal.h:405
char * ppcrowbuffer
Definition: isinternal.h:423
int ivbtransopen(const int ihandle, const char *pcfilename)
Definition: istrans.c:843
int iserrno
Definition: vbmemio.c:27
int inodesize
Definition: isinternal.h:402
#define MAXSUBS
Definition: isinternal.h:119
int ivbintrans
Definition: istrans.c:23

Here is the call graph for this function:

Here is the caller graph for this function:

int issetcollate ( const int  ihandle,
const unsigned char *  collating_sequence 
)

Definition at line 540 of file isopen.c.

References DICTINFO::collating_sequence, DICTINFO::iisopen, iserrno, ivbmaxusedhandle, psvbfile, and unlikely.

541 {
542  struct DICTINFO *psvbptr;
543 
544  if (unlikely(ihandle < 0 || ihandle > ivbmaxusedhandle)) {
545  iserrno = EBADARG;
546  return -1;
547  }
548  psvbptr = psvbfile[ihandle];
549  if (!psvbptr || psvbptr->iisopen) {
550  iserrno = ENOTOPEN;
551  return -1;
552  }
554  return 0;
555 }
const unsigned char * collating_sequence
Definition: isinternal.h:424
int ivbmaxusedhandle
Definition: vblocking.c:26
int iisopen
Definition: isinternal.h:407
#define unlikely(x)
Definition: common.h:437
struct DICTINFO * psvbfile[128+1]
Definition: vblowlevel.c:23
int iserrno
Definition: vbmemio.c:27
int ivbclose2 ( const int  ihandle)

Definition at line 83 of file isopen.c.

References DICTINFO::cfilename, DICTINFO::idatahandle, DICTINFO::iindexhandle, DICTINFO::iisopen, iserrno, isrelease(), DICTINFO::itransyet, ivbclose(), ivbtransclose(), MAXSUBS, NULL, DICTINFO::pskeycurr, VBFILE::pslockhead, VBFILE::pslocktail, VBLOCK::psnext, psvbfile, svbfile, DICTINFO::tdupnumber, DICTINFO::trownumber, and vvblockfree().

Referenced by iscleanup(), isclose(), iscommit(), and isrollback().

84 {
85  struct VBLOCK *psrowlock;
86  struct DICTINFO *psvbptr;
87  int iloop;
88  int iindexhandle;
89 
90  psvbptr = psvbfile[ihandle];
91  psvbptr->iisopen = 0; /* It's a LIE, but so what! */
92  isrelease (ihandle);
93  iserrno = ivbtransclose (ihandle, psvbptr->cfilename);
94  if (ivbclose (psvbptr->idatahandle)) {
95  iserrno = errno;
96  }
97  psvbptr->idatahandle = -1;
98  if (ivbclose (psvbptr->iindexhandle)) {
99  iserrno = errno;
100  }
101  iindexhandle = psvbptr->iindexhandle;
102  while (svbfile[iindexhandle].pslockhead) {
103  psrowlock = svbfile[iindexhandle].pslockhead->psnext;
104  vvblockfree (svbfile[iindexhandle].pslockhead);
105  svbfile[iindexhandle].pslockhead = psrowlock;
106  }
108  psvbptr->iindexhandle = -1;
109 /* RXW
110  psvbptr->trownumber = -1;
111  psvbptr->tdupnumber = -1;
112 */
113  psvbptr->trownumber = 0;
114  psvbptr->tdupnumber = 0;
115  psvbptr->iisopen = 2; /* Only buffers remain! */
116  psvbptr->itransyet = 0;
117  for (iloop = 0; iloop < MAXSUBS; iloop++) {
118  psvbptr->pskeycurr[iloop] = NULL;
119  }
120 
121  return (iserrno ? -1 : 0);
122 }
struct VBFILE svbfile[128 *3]
Definition: vblowlevel.c:24
int ivbtransclose(const int ihandle, const char *pcfilename)
Definition: istrans.c:806
struct VBLOCK * pslocktail
Definition: isinternal.h:455
struct VBLOCK * psnext
Definition: isinternal.h:318
int iindexhandle
Definition: isinternal.h:406
struct VBLOCK * pslockhead
Definition: isinternal.h:454
char * cfilename
Definition: isinternal.h:422
int iisopen
Definition: isinternal.h:407
void vvblockfree(struct VBLOCK *pslock)
Definition: vbmemio.c:81
off_t tdupnumber
Definition: isinternal.h:417
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
struct VBKEY * pskeycurr[32]
Definition: isinternal.h:448
struct DICTINFO * psvbfile[128+1]
Definition: vblowlevel.c:23
int ivbclose(const int ihandle)
Definition: vblowlevel.c:93
int isrelease(const int ihandle)
Definition: ishelper.c:126
off_t trownumber
Definition: isinternal.h:416
unsigned char itransyet
Definition: isinternal.h:438
int idatahandle
Definition: isinternal.h:405
int iserrno
Definition: vbmemio.c:27
#define MAXSUBS
Definition: isinternal.h:119

Here is the call graph for this function:

Here is the caller graph for this function:

void ivbclose3 ( const int  ihandle)

Definition at line 125 of file isopen.c.

References DICTINFO::cfilename, MAXSUBS, NULL, DICTINFO::ppcrowbuffer, DICTINFO::pskeydesc, DICTINFO::pstree, psvbfile, vvbfree(), vvbkeyunmalloc(), and vvbtreeallfree().

Referenced by isbuild(), iscleanup(), iserase(), and isfullclose().

126 {
127  struct DICTINFO *psvbptr;
128  int iloop;
129 
130  psvbptr = psvbfile[ihandle];
131  if (!psvbptr) {
132  return;
133  }
134  for (iloop = 0; iloop < MAXSUBS; iloop++) {
135  vvbtreeallfree (ihandle, iloop, psvbptr->pstree[iloop]);
136  if (psvbptr->pskeydesc[iloop]) {
137  vvbkeyunmalloc (ihandle, iloop);
138  vvbfree (psvbptr->pskeydesc[iloop]);
139  }
140  }
141  if (psvbptr->cfilename) {
142  free (psvbptr->cfilename);
143  }
144  if (psvbptr->ppcrowbuffer) {
145  free (psvbptr->ppcrowbuffer);
146  }
147  vvbfree (psvbptr);
148  psvbfile[ihandle] = NULL;
149 }
void vvbfree(void *mptr)
Definition: vbmemio.c:59
char * cfilename
Definition: isinternal.h:422
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
struct DICTINFO * psvbfile[128+1]
Definition: vblowlevel.c:23
void vvbtreeallfree(const int ihandle, const int ikeynumber, struct VBTREE *pstree)
Definition: vbmemio.c:105
struct VBTREE * pstree[32]
Definition: isinternal.h:446
struct keydesc * pskeydesc[32]
Definition: isinternal.h:445
char * ppcrowbuffer
Definition: isinternal.h:423
void vvbkeyunmalloc(const int ihandle, const int ikeynumber)
Definition: vbmemio.c:196
#define MAXSUBS
Definition: isinternal.h:119

Here is the call graph for this function:

Here is the caller graph for this function:

int ivbforceexit ( const int  ihandle)

Definition at line 50 of file isopen.c.

References cvbnodetmp, DICTINFO::iisdictlocked, iserrno, ivbblockwrite(), psvbfile, DICTINFO::sdictnode, and VB_NODE_MAX.

Referenced by isclose().

51 {
52  struct DICTINFO *psvbptr;
53  int iresult = 0;
54  char cvbnodetmp[VB_NODE_MAX];
55 
56  psvbptr = psvbfile[ihandle];
57  if (psvbptr->iisdictlocked & 0x02) {
58  memset (cvbnodetmp, 0, VB_NODE_MAX);
59  memcpy ((void *)cvbnodetmp, (void *)&psvbptr->sdictnode,
60  sizeof (struct DICTNODE));
61  iresult = ivbblockwrite (ihandle, 1, (off_t) 1, cvbnodetmp);
62  if (iresult) {
63  iserrno = EBADFILE;
64  } else {
65  iserrno = 0;
66  }
67  }
68  psvbptr->iisdictlocked = 0;
69  if (iresult) {
70  return -1;
71  }
72  return 0;
73 }
#define VB_NODE_MAX
Definition: isinternal.h:288
unsigned char iisdictlocked
Definition: isinternal.h:427
struct DICTNODE sdictnode
Definition: isinternal.h:444
struct DICTINFO * psvbfile[128+1]
Definition: vblowlevel.c:23
int ivbblockwrite(const int ihandle, const int iisindex, const off_t tblocknumber, const char *cbuffer)
Definition: vblowlevel.c:167
static char * cvbnodetmp
Definition: ischeck.c:25
int iserrno
Definition: vbmemio.c:27

Here is the call graph for this function:

Here is the caller graph for this function: