1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
/*
Copyright 1990-2008 Light Infocon Tecnologia S/A
Este arquivo é parte do programa LightBase - Banco de Dados Textual Documental
O LightBase é um software livre; você pode redistribui-lo e/ou modifica-lo dentro
dos termos da Licença Pública Geral GNU como publicada pela Fundação do Software
Livre (FSF); na versão 2 da Licença.
Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA
GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou APLICAÇÃO
EM PARTICULAR. Veja a Licença Pública Geral GNU para maiores detalhes.
Você deve ter recebido uma cópia da Licença Pública Geral GNU versao 2, sob o
título "LICENCA.txt", junto com este programa, se não, escreva para a Fundação do
Software Livre(FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
//
// void * ALEntry::operator new( size_t size )
//
// ARGUMENTS:
//
// size : The number of bytes needed to create a new ALEntry object.
//
// RETURNS
//
// A pointer to the newly allocated storage area, or 0 if no storage
// was available.
//
// DESCRIPTION
//
// When using a DLL, it is easy to create a dangerous situation when
// creating objects whose ctor and dtor are both in the DLL. The problem
// arises because when you create an object using new, the memory for
// the object will be allocated from the EXE. However, when you destroy
// the object using delete, the memory is freed inside the DLL. Since
// the DLL doesn't really own that memory, bad things can happen.
//
// But, you say, won't the space just go back to the Windows heap regardless
// of who tries to free it? Maybe, but maybe not. If the DLL is using
// a subsegment allocation schemed, it might do some sort of local free
// before returning the space to the windows heap. That is the point where
// you could conceivably cook your heap.
//
// By providing our own version of operator new inside this class, we
// ensure that all memory allocation for the class will be done from
// inside the DLL, not the EXE calling the DLL.
//
// REVISION HISTORY
//
// May 23, 1994 1.0A : First release
//
void AL_DLL_FAR * AL_PROTO ALEntry::operator new
//
// void * ALEntryList::operator new( size_t size )
//
// ARGUMENTS:
//
// size : The number of bytes that are going to need to be allocated
// to create a new ALEntryList object.
//
// RETURNS
//
// A pointer to the newly allocated storage area. A 0 is returned if no
// storage could be found.
//
// DESCRIPTION
//
// Look at the explanation for ALEntry::operator new(), directly above
// this guy. The description is identical.
//
// REVISION HISTORY
//
// May 23, 1994 1.0A : First release
//
void AL_DLL_FAR * AL_PROTO ALEntryList::operator new
//
// ALEntry::ALEntry( ALEntryList &list,
// ALStorage *object,
// ALCompressionEngine *engine )
//
// ARGUMENTS:
//
// list : A reference to the list the ALEntry object is going to
// be linked into. ALEntry objects aren't allowed to exist
// without being in a list.
//
// object : A pointer to the storage object that is attached to this
// entry. Remember, this is an unopened storage object,
// so it is not consuming very much space. It is okay
// to have a zillion or so of these just lying around.
// Don't forget that the ALEntry dtor is going to destroy
// this guy for you, don't you dare try it!.
//
// engine : A pointer to the compression engine that is going to
// be used to create/insert/extract the storage object
// to/from the archive. Just like with the compression
// engine, it is a low cost object, and you can keep lots
// of them on hand. This engine will be destroyed in the
// ALEntry dtor, so be sure to give up any claim you might
// have on this guy.
//
// RETURNS
//
// Nothing, this is a ctor.
//
// DESCRIPTION
//
// This ctor creates a new ALEntry object. You can do this by hand, but
// frequently you will ask ArchiveLib to create ALEntry objects for you,
// maybe by pulling them out of a list box, or reading them in from and
// archive. Note that ALEntry objects aren't allowed to ever exist
// outside a list, each entry absolutely has to appear in a list.
//
// dtor issues relating to the ALEntry object are very important. Since
// ALEntry objects always are part of a list, it made sense for the
// ALEntryList destructor to clean up all the entries in its list. So
// even though you might have created this ALEntry object, you don't get to
// delete it, that will be done for you.
//
// Also, the storage object and compression engine in the ALEntry object
// are going to be automatically destroyed by the ALEntry dtor. Don't
// even think about trying it yourself!
//
// You can think of an ALEntryList as a directory of an archive, and each
// ALEntry object in the list is a single entry in that directory.
//
// REVISION HISTORY
//
// May 23, 1994 1.0A : First release
//
AL_PROTO : // Initialize our own pointer to the list we will
// be a member of.
//
// ALEntry::~ALEntry()
//
// ARGUMENTS:
//
// Nothing.
//
// RETURNS
//
// Nothing, this is a destructor.
//
// DESCRIPTION
//
// This destructor should normally be called by the ALEntryList dtor. The
// list that owns an entry will always try to delete it when the list
// is deleted.
//
// The ALEntry object tries to delete three dynamically allocated objects
// that it has control over: the storage object, the compression engine,
// and the comment. In each case it won't do it if the object pointer
// is 0. This provides a convenient mechanism for you to steal a storage
// object from an ALEntry. All you have to do is take the pointer, and
// then sent ALEntry::mpStorageObject to 0. This is an especially useful
// thing to do for ALMemory objects.
//
// REVISION HISTORY
//
// May 23, 1994 1.0A : First release
//
AL_PROTO ALEntry::~
//
// int ALEntry::Duplicate( ALEntryList &list )
//
// ARGUMENTS:
//
// list : A list of ALEntry objects to scan.
//
// RETURNS
//
// 0 if the entry is not duplicated, 1 if it is.
//
// DESCRIPTION
//
// This function is used to scan a list of ALEntry objects to see if
// any of them have the same name as this. Unmarked objects are ignored.
// All the function does is zip through the ALEntryList, checking each
// marked member for an ASCII match with the name of the storage object
// pointed to by this. You can see that the case sensitivity of this
// is observed when making the comparison.
//
// REVISION HISTORY
//
// May 23, 1994 1.0A : First release
//
// July 7, 1994 1.0B : The Sun version of UNIX uses strcasecmp() instead
// of the familiar ANSI version stricmp(). Had to
// #ifdef around it.
//
int AL_PROTO
//
// PROTECTED FUNCTION
//
// void ALEntry::InsertBefore( ALEntry &job )
//
// ARGUMENTS:
//
// job : A reference to another job in the target list.
//
// RETURNS
//
// Nothing.
//
// DESCRIPTION
//
// This function is used inside the ALEntryList class to add a new ALEntry
// object to an ALEntryList. Since the list is a doubly linked list, the
// code to do the job is pretty simple. It would have been a little more
// complicated if I used a pair of pointers in the ALEntryList to start
// the list, instead of a dummy ALEntry object.
//
// REVISION HISTORY
//
// May 23, 1994 1.0A : First release
//
void AL_PROTO
//
// int ALEntry::SetComment( const char *comment )
//
// ARGUMENTS:
//
// comment : The new comment that is going to be associated with the
// ALEntry object.
//
// RETURNS
//
// AL_SUCCESS if the new comment was set, < 0 if an error occurred.
//
// DESCRIPTION
//
// Before adding an object to an archive, you may want to change or set
// its comment. You do so by calling this function before performing any
// operation that will write the directory, such as Create() or
// WriteDirectory(). It has to dynamically allocate the space in the
// ALEntry object in order to store the new comment. This is good for
// you, because it means you don't have to worry about who owns the comment
// you just passed in.
//
// REVISION HISTORY
//
// May 23, 1994 1.0A : First release
//
int AL_PROTO
//
// int ALEntry::CompressionRatio()
//
// ARGUMENTS:
//
// None.
//
// RETURNS
//
// The integer representing the compression ratio. The ration is a number
// from 0 to 100 (or maybe more) with 0 being perfect compression.
//
// It is possible to get a -1 back from this routine if the compression
// ratio is not presently known. This will be the case if you have
// not created the archive yet, or have a new object that hasn't been
// inserted yet.
//
// DESCRIPTION
//
// This calculates and returns the compression ratio. We don't store the
// ratio in ALEntry, because it is so darned easy to calculate when
// we need it. However, there are going to be times when we don't have
// it.
//
// REVISION HISTORY
//
// May 23, 1994 1.0A : First release
//
int AL_PROTO
//
// ALEntryList::ALEntryList( ALMonitor * monitor = 0 )
//
// ARGUMENTS:
//
// monitor : A pointer to a monitor that will be used whenever we are
// processing objects in the list. If no argument is supplied,
// the default argument value of 0 is used. When the ctor sees
// that the value of the monitor pointer is 0, it assigns the
// default monitor instead.
//
// RETURNS
//
// No returns from constructors.
//
// DESCRIPTION
//
// Constructing an ALEntryList object doesn't take much work. I have to
// initialize two data members. The first is the pointer to the monitor
// that will be used when processing objects in the list. The second is
// the root of the linked list, which is a dummy ALEntry object. Note
// that the root is created as a dummy by setting the storage object pointer
// to 0.
//
// The default monitor is defined below. If you don't specify a real
// monitor, you get the default, which is a do nothing function. Everyone
// can share one instance of the default monitor, because it doesn't have
// any data members to be concerned about.
//
// REVISION HISTORY
//
// May 23, 1994 1.0A : First release
//
ALMonitor ;
AL_PROTO :
//
// ALEntryList::~ALEntryList()
//
// ARGUMENTS:
//
// None.
//
// RETURNS
//
// None, destructors don't get to return anything.
//
// DESCRIPTION
//
// The destructor for ALEntryList goes through the list and deletes every
// ALEntry object it finds. Note that this also causes the ALEntry
// object to destroy its storage object and compression engine. Once
// the whole list is obliterated, the list head ALEntry object can be
// safely deleted. Then the whole thing is done.
//
// REVISION HISTORY
//
// May 23, 1994 1.0A : First release
//
AL_PROTO ALEntryList::~
// PROTECTED FUNCTION
//
// int ALEntryList::SetMarkState( const char *name,
// short int new_state )
//
// ARGUMENTS:
//
// name : The object name, specifying which storage objects are
// to have their state set. This name can include
// wild card characters. Note that passing a null
// pointer here will cause a match to *every* object name.
//
// new_state : The new state that the ALEntry mark should be set to.
//
// RETURNS
//
// A count of the number of ALEntry objects whose state was changed.
//
// DESCRIPTION
//
// This protected function is used internally to help out a couple of the
// public functions. It rips through every entry of the list, checks to
// see if storage object associate with the entry has a name that matches
// the wildcard specification, and sets the mark if it does.
//
// REVISION HISTORY
//
// May 23, 1994 1.0A : First release
//
int AL_PROTO
//
// int ALEntryList::ToggleMarks()
//
// ARGUMENTS:
//
// None.
//
// RETURNS
//
// A count of the number of entries whose mark was changed.
// (Just the total number of entries.)
//
// DESCRIPTION
//
// This simple member function just goes through the entire list,
// toggling the mark state of every entry. In other words, if the mark
// was previously set, it will now be cleared, and vice versa.
//
// REVISION HISTORY
//
// May 23, 1994 1.0A : First release
//
int AL_PROTO
//
// ALEntry * ALEntry::GetNextEntry()
//
// ARGUMENTS:
//
// None.
//
// RETURNS
//
// A pointer to the next entry in the list. If the next entry is the
// list head, it means we have reached the end of the list, and a value
// of 0 is returned.
//
// DESCRIPTION
//
// This function is used to iterate through the list. Each entry has
// a pointer to the next and previous entries, so this function is really
// simple. The only complications comes from trying to detect the end of
// the list, which is denoted by the list head instance of ALEntry. We
// can tell it apart from all the legitimate entries by the fact that
// its storage object is 0.
//
// REVISION HISTORY
//
// May 23, 1994 1.0A : First release
//
ALEntry AL_DLL_FAR * AL_PROTO
//
// ALEntry * ALEntryList::GetFirstEntry()
//
// ARGUMENTS:
//
// None.
//
// RETURNS
//
// A pointer to the first valid ALEntry object in the list, or 0 if there
// are no entries.
//
// DESCRIPTION
//
// If you are going to iterate through the entire list, this function is
// used to start you off. It gets the first entry in the list by call
// GetNextEntry() for the list head. Don't worry about what happens if
// the list is empty, the GetNextEntry() code figures that out with no
// problem, and returns a 0.
//
// REVISION HISTORY
//
// May 23, 1994 1.0A : First release
//
ALEntry AL_DLL_FAR * AL_PROTO
//
// void ALEntryList::UnmarkDuplicates( ALEntryList &list,
// const char *error_message = 0 )
//
// ARGUMENTS:
//
// list : The list that is going to be compared to this.
//
// error_message : Each entry in this that turns out to have a duplicate
// entry in the list argument will not only be unmarked,
// it will also have its error status set, if an error
// message is provide.
//
// RETURNS
//
// Nothing.
//
// DESCRIPTION
//
// I think this function is a little confusing. At first blush, you would
// probably expect this function to scan all the items in a single list,
// and unmark any object that turn out to have duplicates elsewhere
// in the list. Unfortunately, it doesn't work that way.
//
// Instead, this function goes through the list specified by this, and
// checks to see if each entry in this appears in the list specified by
// the list parameter. This means that we are working with two different
// lists, which certainly offers plenty of chances to get confused.
//
// Anyway, each entry in this that turns out to have a duplicate gets its
// mark cleared. If the calling program specifies and error message,
// the entry also gets its mStatus error member set to flag this as an
// error.
//
// REVISION HISTORY
//
// May 23, 1994 1.0A : First release
//
void AL_PROTO
//
// int ALEntryList::DeleteUnmarked()
//
// ARGUMENTS:
//
// None.
//
// RETURNS
//
// The number of entries that are deleted.
//
// DESCRIPTION
//
// Sometimes you may have a list with a whole bunch of unmarked entries.
// Those unmarked entries are just sitting there taking up space, so it
// would be handle to be able to just delete them. That is what this
// function does.
//
// REVISION HISTORY
//
// May 23, 1994 1.0A : First release
//
int AL_PROTO
//
// in ALEntryList::FillListBox( HWND hDlg, int list_box = -1 )
//
// ARGUMENTS:
//
// hDlg : The handle of the dialog box that contains the list box
// control. If the list box is not a control in a dialog,
// set the next parameter to -1, and just pass the handle
// of the list box in this argument.
//
// list_box : The ID of the list box, if and only if the list box is
// in a dialog box specified by by the hDlg argument.
//
// RETURNS
//
// The number of entries that were stuffed into the list box.
//
// DESCRIPTION
//
// This function is a handy helper when using the Windows GUI. It goes
// through an ALEntryList, and finds all the marked entries. For every
// marked entry, it stuffs the name of the storage object into the list box.
// This means that if you are planning on letting the user select a list
// of storage objects, you can initialize the list with just one
// function call.
//
// REVISION HISTORY
//
// May 23, 1994 1.0A : First release
//
int AL_PROTO
//
// int ALEntryList::SetMarksFromListBox( HWND hDlg, int list_box = - 1 )
//
// ARGUMENTS:
//
// hDlg : The handle of the dialog box that contains the list box.
// If the list box control is standalone window, this parameter
// can be its handle, if the list_box argument is set to -1.
//
// list_box : The ID of the list box, if and only if it is contained in
// a dialog box whose handle is specified in the hDlg param.
//
// RETURNS
//
// A count of the number of items whose marks were set.
//
// DESCRIPTION
//
// This function is called after you have given a user the opportunity
// to set and clear items in a multiselection list box. Once the user
// has done so, you can call this function, which will go through the
// list and set all the marks that have been set in the list box by the
// user. Note that it will not clear the marks on any of the ALEntry
// objects in the list, you might want to do that first.
//
// REVISION HISTORY
//
// May 23, 1994 1.0A : First release
//
int AL_PROTO