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

Go to the source code of this file.

Functions

static int irowdelete (const int ihandle, off_t trownumber)
 
static int iprocessdelete (const int ihandle, off_t trownumber)
 
int isdelete (const int ihandle, char *pcrow)
 
int isdelcurr (const int ihandle)
 
int isdelrec (const int ihandle, long long trownumber)
 

Variables

static char * pcwritebuffer
 

Function Documentation

static int iprocessdelete ( const int  ihandle,
off_t  trownumber 
)
static

Definition at line 68 of file isdelete.c.

References DICTINFO::iopenmode, irowdelete(), iserrno, isreclen, isrecnum, ivbdatafree(), ivbdatalock(), ivbdataread(), ivbdatawrite(), ivbintrans, ivbtransdelete(), MAX_RESERVED_LENGTH, pcwritebuffer, DICTINFO::ppcrowbuffer, psvbfile, pvvbmalloc(), DICTINFO::trownumber, VBCOMMIT, VBNOTRANS, VBROLLBACK, and VBWRLOCK.

Referenced by isdelcurr(), isdelete(), and isdelrec().

69 {
70  struct DICTINFO *psvbptr;
71  int ideleted;
72 
73  psvbptr = psvbfile[ihandle];
74  if (psvbptr->iopenmode & ISTRANS) {
75  iserrno = ivbdatalock (ihandle, VBWRLOCK, trownumber);
76  if (iserrno) {
77  return -1;
78  }
79  }
80  iserrno = ivbdataread (ihandle, psvbptr->ppcrowbuffer,
81  &ideleted, trownumber);
82  if (!iserrno && ideleted) {
83  iserrno = ENOREC;
84  }
85  if (iserrno) {
86  return -1;
87  }
88  if (irowdelete (ihandle, trownumber)) {
89  return -1;
90  }
91  if (!pcwritebuffer) {
93  if (!pcwritebuffer) {
94  iserrno = EBADMEM;
95  return -1;
96  }
97  }
99  if (iserrno) {
100  return -1;
101  }
102  if (!(psvbptr->iopenmode & ISTRANS) || ivbintrans == VBNOTRANS
104  iserrno = ivbdatafree (ihandle, trownumber);
105  if (iserrno) {
106  return -1;
107  }
108  }
110  if (trownumber == psvbptr->trownumber) {
111  psvbptr->trownumber = 0;
112  }
113  ivbtransdelete (ihandle, trownumber, isreclen); /* BUG - retval */
114  return 0;
115 }
int ivbtransdelete(const int ihandle, off_t trownumber, int irowlength)
Definition: istrans.c:698
int ivbdatafree(const int ihandle, const off_t trownumber)
Definition: vbindexio.c:150
#define VBCOMMIT
Definition: isinternal.h:309
int isreclen
Definition: vbmemio.c:29
int ivbdatawrite(const int ihandle, char *pcbuffer, int ideletedrow, const off_t trownumber)
Definition: vbdataio.c:611
#define VBNOTRANS
Definition: isinternal.h:306
int ivbdatalock(const int ihandle, const int imode, const off_t trownumber)
Definition: vblocking.c:432
int ivbdataread(const int ihandle, char *pcbuffer, int *pideletedrow, const off_t trownumber)
Definition: vbdataio.c:493
void * pvvbmalloc(const size_t size)
Definition: vbmemio.c:45
#define VBWRLOCK
Definition: isinternal.h:297
struct DICTINFO * psvbfile[128+1]
Definition: vblowlevel.c:23
int iopenmode
Definition: isinternal.h:412
#define MAX_RESERVED_LENGTH
Definition: isinternal.h:290
#define VBROLLBACK
Definition: isinternal.h:310
off_t trownumber
Definition: isinternal.h:416
static int irowdelete(const int ihandle, off_t trownumber)
Definition: isdelete.c:27
char * ppcrowbuffer
Definition: isinternal.h:423
int iserrno
Definition: vbmemio.c:27
int isrecnum
Definition: vbmemio.c:30
int ivbintrans
Definition: istrans.c:23
static char * pcwritebuffer
Definition: isdelete.c:22

Here is the call graph for this function:

Here is the caller graph for this function:

static int irowdelete ( const int  ihandle,
off_t  trownumber 
)
static

Definition at line 27 of file isdelete.c.

References DICTINFO::inkeys, iserrno, ivbkeydelete(), ivbkeylocaterow(), MAXSUBS, DICTINFO::pskeycurr, DICTINFO::pskeydesc, psvbfile, VBKEY::tdupnumber, and DICTINFO::tdupnumber.

Referenced by iprocessdelete().

28 {
29  struct DICTINFO *psvbptr;
30  int ikeynumber, iresult;
31  off_t tdupnumber[MAXSUBS];
32 
33  psvbptr = psvbfile[ihandle];
34  /*
35  * Step 1:
36  * Check each index for existance of trownumber
37  */
38  for (ikeynumber = 0; ikeynumber < psvbptr->inkeys; ikeynumber++) {
39  if (psvbptr->pskeydesc[ikeynumber]->k_nparts == 0) {
40  continue;
41  }
42  if (ivbkeylocaterow (ihandle, ikeynumber, trownumber)) {
43  iserrno = EBADFILE;
44  return -1;
45  }
46  tdupnumber[ikeynumber] = psvbptr->pskeycurr[ikeynumber]->tdupnumber;
47  }
48 
49  /*
50  * Step 2:
51  * Perform the actual deletion from each index
52  */
53  for (ikeynumber = 0; ikeynumber < psvbptr->inkeys; ikeynumber++) {
54  if (psvbptr->pskeydesc[ikeynumber]->k_nparts == 0) {
55  continue;
56  }
57  iresult = ivbkeydelete (ihandle, ikeynumber);
58  if (iresult) {
59  iserrno = iresult;
60  return -1;
61  }
62  }
63 
64  return 0;
65 }
int inkeys
Definition: isinternal.h:400
int ivbkeylocaterow(const int ihandle, const int ikeynumber, off_t trownumber)
Definition: vbkeysio.c:435
int ivbkeydelete(const int ihandle, const int ikeynumber)
Definition: vbkeysio.c:777
off_t tdupnumber
Definition: isinternal.h:417
struct VBKEY * pskeycurr[32]
Definition: isinternal.h:448
struct DICTINFO * psvbfile[128+1]
Definition: vblowlevel.c:23
off_t tdupnumber
Definition: isinternal.h:329
struct keydesc * pskeydesc[32]
Definition: isinternal.h:445
off_t trownumber
Definition: isinternal.h:416
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:

int isdelcurr ( const int  ihandle)

Definition at line 164 of file isdelete.c.

References DICTINFO::iisdictlocked, iprocessdelete(), iserrno, ivbenter(), ivbexit(), psvbfile, and DICTINFO::trownumber.

165 {
166  struct DICTINFO *psvbptr;
167  int iresult = 0;
168 
169  if (ivbenter (ihandle, 1, 0)) {
170  return -1;
171  }
172  psvbptr = psvbfile[ihandle];
173 
174  if (psvbptr->trownumber > 0) {
175  iresult = iprocessdelete (ihandle, psvbptr->trownumber);
176  } else {
177  iserrno = ENOREC;
178  iresult = -1;
179  }
180 
181  if (iresult == 0) {
182  psvbptr->iisdictlocked |= 0x02;
183  }
184  iresult |= ivbexit (ihandle);
185  return iresult;
186 }
int ivbenter(const int ihandle, const unsigned int imodifying, const unsigned int ispecial)
Definition: vblocking.c:178
unsigned char iisdictlocked
Definition: isinternal.h:427
struct DICTINFO * psvbfile[128+1]
Definition: vblowlevel.c:23
int ivbexit(const int ihandle)
Definition: vblocking.c:290
off_t trownumber
Definition: isinternal.h:416
static int iprocessdelete(const int ihandle, off_t trownumber)
Definition: isdelete.c:68
int iserrno
Definition: vbmemio.c:27

Here is the call graph for this function:

int isdelete ( const int  ihandle,
char *  pcrow 
)

Definition at line 120 of file isdelete.c.

References DICTINFO::iisdictlocked, iprocessdelete(), iserrno, ivbenter(), ivbexit(), ivbkeysearch(), DICTINFO::pskeycurr, DICTINFO::pskeydesc, psvbfile, VBKEY::trownode, and vvbmakekey().

Referenced by indexed_delete().

121 {
122  struct DICTINFO *psvbptr;
123  int iresult = 0;
124  unsigned char ckeyvalue[VB_MAX_KEYLEN];
125 
126  if (ivbenter (ihandle, 1, 0)) {
127  return -1;
128  }
129 
130  psvbptr = psvbfile[ihandle];
131  if (psvbptr->pskeydesc[0]->k_flags & ISDUPS) {
132  iserrno = ENOPRIM;
133  iresult = -1;
134  } else {
135  vvbmakekey (psvbptr->pskeydesc[0], pcrow, ckeyvalue);
136  iresult = ivbkeysearch (ihandle, ISEQUAL, 0, 0, ckeyvalue, (off_t)0);
137  switch (iresult) {
138  case 1: /* Exact match */
139  iresult =
140  iprocessdelete (ihandle, psvbptr->pskeycurr[0]->trownode);
141  break;
142 
143  case 0: /* LESS than */
144  case 2: /* EMPTY file */
145  iserrno = ENOREC;
146  iresult = -1;
147  break;
148 
149  default:
150  iserrno = EBADFILE;
151  iresult = -1;
152  break;
153  }
154  }
155 
156  if (iresult == 0) {
157  psvbptr->iisdictlocked |= 0x02;
158  }
159  iresult |= ivbexit (ihandle);
160  return iresult;
161 }
int ivbkeysearch(const int ihandle, const int imode, const int ikeynumber, int ilength, unsigned char *pckeyvalue, off_t tdupnumber)
Definition: vbkeysio.c:372
int ivbenter(const int ihandle, const unsigned int imodifying, const unsigned int ispecial)
Definition: vblocking.c:178
unsigned char iisdictlocked
Definition: isinternal.h:427
struct VBKEY * pskeycurr[32]
Definition: isinternal.h:448
off_t trownode
Definition: isinternal.h:328
void vvbmakekey(const struct keydesc *pskeydesc, char *pcrow_buffer, unsigned char *pckeyvalue)
Definition: vbkeysio.c:212
struct DICTINFO * psvbfile[128+1]
Definition: vblowlevel.c:23
int ivbexit(const int ihandle)
Definition: vblocking.c:290
struct keydesc * pskeydesc[32]
Definition: isinternal.h:445
static int iprocessdelete(const int ihandle, off_t trownumber)
Definition: isdelete.c:68
int iserrno
Definition: vbmemio.c:27

Here is the call graph for this function:

Here is the caller graph for this function:

int isdelrec ( const int  ihandle,
long long  trownumber 
)

Definition at line 189 of file isdelete.c.

References DICTINFO::iisdictlocked, iprocessdelete(), iserrno, ivbenter(), ivbexit(), and psvbfile.

Referenced by ircvdelete(), and ivbrollmeback().

190 {
191  struct DICTINFO *psvbptr;
192  int iresult = 0;
193 
194  if (ivbenter (ihandle, 1, 0)) {
195  return -1;
196  }
197  psvbptr = psvbfile[ihandle];
198 
199  if (trownumber > 0) {
200  iresult = iprocessdelete (ihandle, trownumber);
201  } else {
202  iserrno = ENOREC;
203  iresult = -1;
204  }
205 
206  if (iresult == 0) {
207  psvbptr->iisdictlocked |= 0x02;
208  }
209  iresult |= ivbexit (ihandle);
210  return iresult;
211 }
int ivbenter(const int ihandle, const unsigned int imodifying, const unsigned int ispecial)
Definition: vblocking.c:178
unsigned char iisdictlocked
Definition: isinternal.h:427
struct DICTINFO * psvbfile[128+1]
Definition: vblowlevel.c:23
int ivbexit(const int ihandle)
Definition: vblocking.c:290
off_t trownumber
Definition: isinternal.h:416
static int iprocessdelete(const int ihandle, off_t trownumber)
Definition: isdelete.c:68
int iserrno
Definition: vbmemio.c:27

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation

char* pcwritebuffer
static

Definition at line 22 of file isdelete.c.

Referenced by iprocessdelete(), and ivbdatawrite().