1
- /* ********** File AM Zip C++ Program Source Code File (.CPP) ***********/
2
- /* PROGRAM NAME: FILAMZIP */
1
+ /* *********** File AM GZ C++ Program Source Code File (.CPP) ***********/
2
+ /* PROGRAM NAME: FILAMGZ */
3
3
/* ------------- */
4
4
/* Version 1.5 */
5
5
/* */
6
6
/* COPYRIGHT: */
7
7
/* ---------- */
8
- /* (C) Copyright to the author Olivier BERTRAND 2005-2015 */
8
+ /* (C) Copyright to the author Olivier BERTRAND 2005-2016 */
9
9
/* */
10
10
/* WHAT THIS PROGRAM DOES: */
11
11
/* ----------------------- */
56
56
/* **********************************************************************/
57
57
// #define ZLIB_DLL
58
58
59
- #include " filamzip .h"
59
+ #include " filamgz .h"
60
60
61
61
/* **********************************************************************/
62
62
/* DB static variables. */
@@ -66,13 +66,13 @@ extern int num_read, num_there, num_eq[]; // Statistics
66
66
/* ------------------------------------------------------------------- */
67
67
68
68
/* **********************************************************************/
69
- /* Implementation of the ZIPFAM class. */
69
+ /* Implementation of the GZFAM class. */
70
70
/* **********************************************************************/
71
- ZIPFAM::ZIPFAM (PZIPFAM txfp) : TXTFAM(txfp)
71
+ GZFAM::GZFAM (PGZFAM txfp) : TXTFAM(txfp)
72
72
{
73
73
Zfile = txfp->Zfile ;
74
74
Zpos = txfp->Zpos ;
75
- } // end of ZIPFAM copy constructor
75
+ } // end of GZFAM copy constructor
76
76
77
77
/* **********************************************************************/
78
78
/* Zerror: Error function for gz calls. */
@@ -82,7 +82,7 @@ ZIPFAM::ZIPFAM(PZIPFAM txfp) : TXTFAM(txfp)
82
82
/* library, errnum is set to Z_ERRNO and the application may consult */
83
83
/* errno to get the exact error code. */
84
84
/* **********************************************************************/
85
- int ZIPFAM ::Zerror (PGLOBAL g)
85
+ int GZFAM ::Zerror (PGLOBAL g)
86
86
{
87
87
int errnum;
88
88
@@ -101,18 +101,18 @@ int ZIPFAM::Zerror(PGLOBAL g)
101
101
/* **********************************************************************/
102
102
/* Reset: reset position values at the beginning of file. */
103
103
/* **********************************************************************/
104
- void ZIPFAM ::Reset (void )
104
+ void GZFAM ::Reset (void )
105
105
{
106
106
TXTFAM::Reset ();
107
107
// gzrewind(Zfile); // Useful ?????
108
108
Zpos = 0 ;
109
109
} // end of Reset
110
110
111
111
/* **********************************************************************/
112
- /* ZIP GetFileLength: returns an estimate of what would be the */
112
+ /* GZ GetFileLength: returns an estimate of what would be the */
113
113
/* uncompressed file size in number of bytes. */
114
114
/* **********************************************************************/
115
- int ZIPFAM ::GetFileLength (PGLOBAL g)
115
+ int GZFAM ::GetFileLength (PGLOBAL g)
116
116
{
117
117
int len = TXTFAM::GetFileLength (g);
118
118
@@ -124,9 +124,9 @@ int ZIPFAM::GetFileLength(PGLOBAL g)
124
124
} // end of GetFileLength
125
125
126
126
/* **********************************************************************/
127
- /* ZIP Access Method opening routine. */
127
+ /* GZ Access Method opening routine. */
128
128
/* **********************************************************************/
129
- bool ZIPFAM ::OpenTableFile (PGLOBAL g)
129
+ bool GZFAM ::OpenTableFile (PGLOBAL g)
130
130
{
131
131
char opmode[4 ], filename[_MAX_PATH];
132
132
MODE mode = Tdbp->GetMode ();
@@ -137,7 +137,7 @@ bool ZIPFAM::OpenTableFile(PGLOBAL g)
137
137
break ;
138
138
case MODE_UPDATE:
139
139
/* ****************************************************************/
140
- /* Updating ZIP files not implemented yet. */
140
+ /* Updating GZ files not implemented yet. */
141
141
/* ****************************************************************/
142
142
strcpy (g->Message , MSG (UPD_ZIP_NOT_IMP));
143
143
return true ;
@@ -152,7 +152,7 @@ bool ZIPFAM::OpenTableFile(PGLOBAL g)
152
152
// Last = Nrec; // For ZBKFAM
153
153
Tdbp->ResetSize ();
154
154
} else {
155
- sprintf (g->Message , MSG (NO_PART_DEL), " ZIP " );
155
+ sprintf (g->Message , MSG (NO_PART_DEL), " GZ " );
156
156
return true ;
157
157
} // endif filter
158
158
@@ -196,7 +196,7 @@ bool ZIPFAM::OpenTableFile(PGLOBAL g)
196
196
/* Allocate the line buffer. For mode Delete a bigger buffer has to */
197
197
/* be allocated because is it also used to move lines into the file. */
198
198
/* **********************************************************************/
199
- bool ZIPFAM ::AllocateBuffer (PGLOBAL g)
199
+ bool GZFAM ::AllocateBuffer (PGLOBAL g)
200
200
{
201
201
MODE mode = Tdbp->GetMode ();
202
202
@@ -223,33 +223,33 @@ bool ZIPFAM::AllocateBuffer(PGLOBAL g)
223
223
/* **********************************************************************/
224
224
/* GetRowID: return the RowID of last read record. */
225
225
/* **********************************************************************/
226
- int ZIPFAM ::GetRowID (void )
226
+ int GZFAM ::GetRowID (void )
227
227
{
228
228
return Rows;
229
229
} // end of GetRowID
230
230
231
231
/* **********************************************************************/
232
232
/* GetPos: return the position of last read record. */
233
233
/* **********************************************************************/
234
- int ZIPFAM ::GetPos (void )
234
+ int GZFAM ::GetPos (void )
235
235
{
236
236
return (int )Zpos;
237
237
} // end of GetPos
238
238
239
239
/* **********************************************************************/
240
240
/* GetNextPos: return the position of next record. */
241
241
/* **********************************************************************/
242
- int ZIPFAM ::GetNextPos (void )
242
+ int GZFAM ::GetNextPos (void )
243
243
{
244
244
return gztell (Zfile);
245
245
} // end of GetNextPos
246
246
247
247
/* **********************************************************************/
248
248
/* SetPos: Replace the table at the specified position. */
249
249
/* **********************************************************************/
250
- bool ZIPFAM ::SetPos (PGLOBAL g, int pos __attribute__ ((unused)))
250
+ bool GZFAM ::SetPos (PGLOBAL g, int pos __attribute__ ((unused)))
251
251
{
252
- sprintf (g->Message , MSG (NO_SETPOS_YET), " ZIP " );
252
+ sprintf (g->Message , MSG (NO_SETPOS_YET), " GZ " );
253
253
return true ;
254
254
#if 0
255
255
Fpos = pos;
@@ -267,7 +267,7 @@ bool ZIPFAM::SetPos(PGLOBAL g, int pos __attribute__((unused)))
267
267
/* **********************************************************************/
268
268
/* Record file position in case of UPDATE or DELETE. */
269
269
/* **********************************************************************/
270
- bool ZIPFAM ::RecordPos (PGLOBAL)
270
+ bool GZFAM ::RecordPos (PGLOBAL)
271
271
{
272
272
Zpos = gztell (Zfile);
273
273
return false ;
@@ -276,7 +276,7 @@ bool ZIPFAM::RecordPos(PGLOBAL)
276
276
/* **********************************************************************/
277
277
/* Skip one record in file. */
278
278
/* **********************************************************************/
279
- int ZIPFAM ::SkipRecord (PGLOBAL g, bool header)
279
+ int GZFAM ::SkipRecord (PGLOBAL g, bool header)
280
280
{
281
281
// Skip this record
282
282
if (gzeof (Zfile))
@@ -293,7 +293,7 @@ int ZIPFAM::SkipRecord(PGLOBAL g, bool header)
293
293
/* **********************************************************************/
294
294
/* ReadBuffer: Read one line from a compressed text file. */
295
295
/* **********************************************************************/
296
- int ZIPFAM ::ReadBuffer (PGLOBAL g)
296
+ int GZFAM ::ReadBuffer (PGLOBAL g)
297
297
{
298
298
char *p;
299
299
int rc;
@@ -357,7 +357,7 @@ int ZIPFAM::ReadBuffer(PGLOBAL g)
357
357
/* WriteDB: Data Base write routine for ZDOS access method. */
358
358
/* Update is not possible without using a temporary file (NIY). */
359
359
/* **********************************************************************/
360
- int ZIPFAM ::WriteBuffer (PGLOBAL g)
360
+ int GZFAM ::WriteBuffer (PGLOBAL g)
361
361
{
362
362
/* ********************************************************************/
363
363
/* Prepare the write buffer. */
@@ -376,7 +376,7 @@ int ZIPFAM::WriteBuffer(PGLOBAL g)
376
376
/* **********************************************************************/
377
377
/* Data Base delete line routine for ZDOS access method. (NIY) */
378
378
/* **********************************************************************/
379
- int ZIPFAM ::DeleteRecords (PGLOBAL g, int )
379
+ int GZFAM ::DeleteRecords (PGLOBAL g, int )
380
380
{
381
381
strcpy (g->Message , MSG (NO_ZIP_DELETE));
382
382
return RC_FX;
@@ -385,21 +385,21 @@ int ZIPFAM::DeleteRecords(PGLOBAL g, int)
385
385
/* **********************************************************************/
386
386
/* Data Base close routine for DOS access method. */
387
387
/* **********************************************************************/
388
- void ZIPFAM ::CloseTableFile (PGLOBAL, bool )
388
+ void GZFAM ::CloseTableFile (PGLOBAL, bool )
389
389
{
390
390
int rc = gzclose (Zfile);
391
391
392
392
if (trace)
393
- htrc (" ZIP CloseDB: closing %s rc=%d\n " , To_File, rc);
393
+ htrc (" GZ CloseDB: closing %s rc=%d\n " , To_File, rc);
394
394
395
395
Zfile = NULL ; // So we can know whether table is open
396
396
// To_Fb->Count = 0; // Avoid double closing by PlugCloseAll
397
397
} // end of CloseTableFile
398
398
399
399
/* **********************************************************************/
400
- /* Rewind routine for ZIP access method. */
400
+ /* Rewind routine for GZ access method. */
401
401
/* **********************************************************************/
402
- void ZIPFAM ::Rewind (void )
402
+ void GZFAM ::Rewind (void )
403
403
{
404
404
gzrewind (Zfile);
405
405
} // end of Rewind
@@ -409,7 +409,7 @@ void ZIPFAM::Rewind(void)
409
409
/* **********************************************************************/
410
410
/* Constructors. */
411
411
/* **********************************************************************/
412
- ZBKFAM::ZBKFAM (PDOSDEF tdp) : ZIPFAM (tdp)
412
+ ZBKFAM::ZBKFAM (PDOSDEF tdp) : GZFAM (tdp)
413
413
{
414
414
Blocked = true ;
415
415
Block = tdp->GetBlock ();
@@ -421,7 +421,7 @@ ZBKFAM::ZBKFAM(PDOSDEF tdp) : ZIPFAM(tdp)
421
421
BlkPos = tdp->GetTo_Pos ();
422
422
} // end of ZBKFAM standard constructor
423
423
424
- ZBKFAM::ZBKFAM (PZBKFAM txfp) : ZIPFAM (txfp)
424
+ ZBKFAM::ZBKFAM (PZBKFAM txfp) : GZFAM (txfp)
425
425
{
426
426
CurLine = txfp->CurLine ;
427
427
NxtLine = txfp->NxtLine ;
@@ -505,7 +505,7 @@ int ZBKFAM::GetPos(void)
505
505
/* **********************************************************************/
506
506
bool ZBKFAM::RecordPos (PGLOBAL /* g*/ )
507
507
{
508
- // strcpy(g->Message, "RecordPos not implemented for zip blocked tables");
508
+ // strcpy(g->Message, "RecordPos not implemented for gz blocked tables");
509
509
// return true;
510
510
return RC_OK;
511
511
} // end of RecordPos
@@ -515,7 +515,7 @@ bool ZBKFAM::RecordPos(PGLOBAL /*g*/)
515
515
/* **********************************************************************/
516
516
int ZBKFAM::SkipRecord (PGLOBAL /* g*/ , bool )
517
517
{
518
- // strcpy(g->Message, "SkipRecord not implemented for zip blocked tables");
518
+ // strcpy(g->Message, "SkipRecord not implemented for gz blocked tables");
519
519
// return RC_FX;
520
520
return RC_OK;
521
521
} // end of SkipRecord
@@ -615,7 +615,7 @@ int ZBKFAM::WriteBuffer(PGLOBAL g)
615
615
616
616
/* ********************************************************************/
617
617
/* In Insert mode, blocs are added sequentialy to the file end. */
618
- /* Note: Update mode is not handled for zip files. */
618
+ /* Note: Update mode is not handled for gz files. */
619
619
/* ********************************************************************/
620
620
if (++CurNum == Rbuf) {
621
621
/* ******************************************************************/
@@ -703,7 +703,7 @@ void ZBKFAM::CloseTableFile(PGLOBAL g, bool)
703
703
rc = gzclose (Zfile);
704
704
705
705
if (trace)
706
- htrc (" ZIP CloseDB: closing %s rc=%d\n " , To_File, rc);
706
+ htrc (" GZ CloseDB: closing %s rc=%d\n " , To_File, rc);
707
707
708
708
Zfile = NULL ; // So we can know whether table is open
709
709
// To_Fb->Count = 0; // Avoid double closing by PlugCloseAll
@@ -854,7 +854,7 @@ int ZIXFAM::WriteBuffer(PGLOBAL g)
854
854
{
855
855
/* ********************************************************************/
856
856
/* In Insert mode, blocs are added sequentialy to the file end. */
857
- /* Note: Update mode is not handled for zip files. */
857
+ /* Note: Update mode is not handled for gz files. */
858
858
/* ********************************************************************/
859
859
if (++CurNum == Rbuf) {
860
860
/* ******************************************************************/
@@ -1062,7 +1062,7 @@ int ZLBFAM::GetNextPos(void)
1062
1062
/* **********************************************************************/
1063
1063
bool ZLBFAM::SetPos (PGLOBAL g, int pos __attribute__ ((unused)))
1064
1064
{
1065
- sprintf (g->Message , MSG (NO_SETPOS_YET), " ZIP " );
1065
+ sprintf (g->Message , MSG (NO_SETPOS_YET), " GZ " );
1066
1066
return true ;
1067
1067
#if 0 // All this must be checked
1068
1068
if (pos < 0) {
@@ -1423,4 +1423,4 @@ void ZLBFAM::Rewind(void)
1423
1423
// Rbuf = 0; commented out in case we reuse last read block
1424
1424
} // end of Rewind
1425
1425
1426
- /* ------------------------ End of ZipFam ---------------------------- */
1426
+ /* ------------------------ End of GzFam ---------------------------- */
0 commit comments