archivelib-sys 0.2.0

An implementaton(in C++) of the Greenleaf ArchiveLib compression/decompression algorithm
Documentation
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
/*
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
*/


#include "arclib.h"
#pragma hdrstop

#include <string.h>
#include <ctype.h>

#include "_match.h"

//
//  void strupr( char *s )
//
// ARGUMENTS:
//
//  A pointer to a string.
//
// RETURNS
//
//  Nothing.
//
// DESCRIPTION
//
//  I was kind of surprised to see that SUN UNIX doesn't have either strlwr()
//  or strupr() in their library.  So I had to whip up this quick and dirty
//  replacement routine.
//
// REVISION HISTORY
//
//   July 7, 1994  1.0B  : First release
//

#ifdef AL_UNIX

static void strupr( char *s )
{
    while ( *s ){
        *s = toupper( *s );
        s++;
    }

}

#endif

//
//  void strlwr( char *s )
//
// ARGUMENTS:
//
//  A pointer to a string.
//
// RETURNS
//
//  Nothing.
//
// DESCRIPTION
//
//  I was kind of surprised to see that SUN UNIX doesn't have either strlwr()
//  or strupr() in their library.  So I had to whip up this quick and dirty
//  replacement routine.
//
// REVISION HISTORY
//
//   July 7, 1994  1.0B  : First release
//


#ifdef AL_UNIX

static void strlwr( char *s )
{
    while ( *s ) {
        *s = tolower( *s );
        s++;
    }
}

#endif

//
// void * ALName::operator new( size_t size )
//
// ARGUMENTS:
//
//  size  :  The number of bytes needed to create a new ALName 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 get into 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 scheme, 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 26, 1994  1.0A  : First release
//

#if defined( AL_BUILDING_DLL )
void AL_DLL_FAR * AL_PROTO ALName::operator new( size_t size )
{
    return ::new char[ size ];
}
#endif

//
// ALName ALName::operator+( const char *rhs )
//
// ARGUMENTS:
//
//  rhs  : The character pointer that is going to be added to the
//         ALName object.  This will often be the string component
//         of another ALName object, cast to type const char *.
//
// RETURNS
//
//  A newly created ALName object.  This disappears quickly, but can
//  be copied into a result object using either the assignment operator
//  or the copy constructor.
//
// DESCRIPTION
//
//  This is one of those C++ functions that makes converts out of C
//  programmers.  It allows me to add two strings together to create
//  a third.  I really like that.
//
//  The implementation is pretty easy.  I allocate a new character buffer of
//  the correct length, the copy the two strings into it.  I use this
//  result as the initializer for a new ALName object, and return that.
//
//  Note that the new string will have the same case sensitivity as this.
//
// REVISION HISTORY
//
//   May 26, 1994  1.0A  : First release
//

ALName ALName::operator+( const char AL_DLL_FAR *rhs )
{
    int l1 = ( rhs ) ? strlen( rhs ) : 0;
    int l2 = ( mszName ) ? strlen( mszName ) : 0;
    char *p = new char[ l1 + l2 + 1 ];
    if ( p ) {
        strcpy( p, mszName );
        if ( rhs )
            strcat( p, rhs );
    }
    ALName result( p, mCase );
    if ( p )
        delete[] p;
    return result;
}


//
// ALName::ALName( const char *s = "", ALCase name_case = AL_MIXED )
//
// ARGUMENTS:
//
//  s        : The initial string value of the new object.  Note that
//             you can pass a null pointer here and all will still be okay.
//
//  name_case: The case sensitivity of the new ALName object.  Will its
//             contents be mixed, or will it always be forced to upper
//             or lower.
//
// RETURNS
//
//  Nothing, a constructor.
//
// DESCRIPTION
//
//  This constructor first initializes the mCase member in an initializer.
//  mCase is a const member, which is nice, because you can make it public.
//  But, it means you can't initialize it *in* the constructor, you have
//  to do it before the body.
//
//  Things are pretty easy after that.  We allocate enough space to hold
//  the initializer string and copy it in.  The old name gets set to 0, since
//  this name hasn't been around long enough to have been renamed.
//  And that's it.
//
// REVISION HISTORY
//
//   May 26, 1994  1.0A  : First release
//

AL_PROTO ALName::ALName( const char AL_DLL_FAR *s /* = "" */,
                         ALCase name_case /* = AL_MIXED */ )
     : mCase( name_case )
{
    mszName = new AL_DLL_FAR char[ strlen( s ) + 1 ];
    if ( mszName )
        Strcpy( s );
     mszOldName = 0;
}

//
// ALName::ALName( const ALName &rhs )
//
// ARGUMENTS:
//
//  rhs   :  A reference to another ALName object.  This is the ALName
//           we are going to copy.
//
// RETURNS
//
//  Nothing, a constructor.
//
// DESCRIPTION
//
//  This is the copy constructor.  It is very nearly the same as the
//  other constructor.
//
//  This constructor first initializes the mCase member in an initializer.
//  mCase is a const member, which is nice, because you can make it public.
//  But, it means you can't initialize it *in* the constructor, you have
//  to do it before the body.
//
//  Things are pretty easy after that.  We allocate enough space to hold
//  a copy of the string in the rhs, and then copy it.  The old name gets
//  set to 0, since this name hasn't been around long enough to have been
//  renamed.  We could have copied the old name from the rhs, but I think
//  this way makes more sense.
//  And that's it.
//
// REVISION HISTORY
//
//   May 26, 1994  1.0A  : First release
//

AL_PROTO ALName::ALName( const ALName AL_DLL_FAR &rhs )
     : mCase( rhs.mCase )
{
     const char *s = rhs.GetSafeName();
     mszName = new AL_DLL_FAR char[ strlen( s ) + 1 ];
     if ( mszName )
          Strcpy( s );
     mszOldName = 0;
}

//
// ALName & ALName::operator = ( const char * rhs )
//
// ARGUMENTS:
//
//  rhs  :  This is the character string that we are going to assign to this.
//
// RETURNS
//
//  A reference to this.  We need to do it that way so we can do:
//
//    a = b = c = "test";
//
// DESCRIPTION
//
//  This function performs roughly the same function as the first
//  constructor, but there is a twist.  When we assign a new name to
//  an ALName object, we also make a copy of fit and place it in
//  the old name data member.
//
// REVISION HISTORY
//
//   May 26, 1994  1.0A  : First release
//

ALName AL_DLL_FAR & AL_PROTO ALName::
operator = ( const char AL_DLL_FAR * rhs )
{
    if ( rhs == 0 )
        rhs = "";
    if ( rhs == mszName ) // Pathological?
        return *this;

    char AL_DLL_FAR *new_name = new AL_DLL_FAR char[ strlen( rhs ) + 1 ];
    if ( new_name ) {
        if ( mszOldName )
            delete[] mszOldName;
        mszOldName = mszName;
        mszName = new_name;
        Strcpy( rhs );
    } else {
        if ( mszOldName )
            delete[] mszOldName;
        mszOldName = mszName;
        mszName = 0;
    }
    return *this;
}

//
// ALName & ALName::operator = ( const ALName & rhs )
//
// ARGUMENTS:
//
//  rhs   :  The right hand side of the assignment operator.
//
// RETURNS
//
//  A reference to this.  Like in the above function, we do this so
//  that you can stack assignments:
//
//      a = b = c = "Dummy";
//
// DESCRIPTION
//
//
//  This function is very similar to the copy constructor, but it has
//  one additional twist.  When we copy the rhs string value into our
//  string, we move our old name into the backup copy member,
//  mszOldName.  That way, if we change our mind, we can easily
//  switch back to the old name.
//
// REVISION HISTORY
//
//   May 26, 1994  1.0A  : First release
//
ALName AL_DLL_FAR & AL_PROTO ALName::
operator = ( const ALName AL_DLL_FAR & rhs )
{
    return *this = rhs.GetName();
}

//
// ALName::~ALName()
//
// ARGUMENTS:
//
//  None, this is a destructor.
//
// RETURNS
//
//  None, destructor.
//
// DESCRIPTION
//
//  All this function has to do is free up the two pieces of
//  dynamic memory.  I just can't get out of that old C habit of
//  checking a pointer for NULL before deleting it.
//
//  In debug mode, I check the state of this before and after freeing
//  the dynamically allocated memory, in hopes of catching any
//  heap errors near their source.
//
// REVISION HISTORY
//
//   May 26, 1994  1.0A  : First release
//

AL_PROTO ALName::~ALName()
{
    AL_ASSERT( GoodTag(), "~ALName: attempt to delete invalid object" );
    if ( mszName )
        delete[] mszName;
    if ( mszOldName )
        delete[] mszOldName;
    AL_ASSERT( GoodTag(), "~ALName: attempt to delete invalid object" );
}

//
// ALName & ALName::ChangeExtension( const char *new_extension = ".bak" )
//
// ARGUMENTS:
//
//  new_extension  :  The new extension you want to apply to the name.
//
// RETURNS
//
//  A reference to this.  This is nice, because it lets you do things
//  like this:
//
//     fopen( name.ChangeExtension( ".OBJ" ), "rb" );
//
// DESCRIPTION
//
//  This function is used to change the extension of a filename stored
//  in an ALName object.  A lot of times you will want to do this
//  in order to create a backup.  For example, you could change
//  TEMP.DAT to TEMP.BAK.
//
//  This function makes a copy of the current name in mszOldName, so we
//  can keep track of it later.  It then searches for the '.' character
//  in the new file name, and sticks the new extension there.
//
//  If you apply this function to a filename, you can then rename the file
//  by calling ALStorage::Rename() with no argument.  When you do this,
//  the rename function uses the saved OldName and current name as its
//  arguments for the rename() function.
//
// REVISION HISTORY
//
//   May 26, 1994  1.0A  : First release
//
//   July 7, 1994  1.0B  : Had to add a default to the switch() statement,
//                         gcc -Wall was giving me a warning.

//
// I need to fix this code up to handle extensions with and without a
// leading '.' character.  Maybe you can use a leading character
// other than '.' to indicate a different type of extension?
//

ALName AL_DLL_FAR & AL_PROTO ALName::
ChangeExtension( const char AL_DLL_FAR *new_extension /* = ".bak" */ )
{
    AL_ASSERT( new_extension != 0, "ChangeExtension: new extension is null" );
    AL_ASSERT( mszName, "ChangeExtension: current name is null" );

    char *file_name = new char[ strlen( mszName ) + strlen( new_extension ) + 1 ];
    if ( mszOldName )
        delete[] mszOldName;
    mszOldName = mszName;
    mszName = file_name;

    if ( !file_name )
        return *this;
    strcpy( mszName, mszOldName );
    char *p = strrchr( file_name, '.' );
    if ( p )
        strcpy( p, new_extension );
    else
        strcat( mszName, new_extension );
    switch ( mCase ) {
        case AL_UPPER : strupr( mszName ); break;
        case AL_LOWER : strlwr( mszName ); break;
        default       : break;
    }
    return *this;
}

//
// ALName & ALName::ChangeTrailingChar( char new_char = '@' )
//
// ARGUMENTS:
//
//  new_char  :  The new character to use as the last name of the file
//               name.
//
// RETURNS
//
//  A reference to this.  This is nice, because it lets you do things
//  like this:
//
//     fopen( name.ChangeTrailingChar(), "rb" );
//
// DESCRIPTION
//
//  This function is used to change the the last character of the extension
//  in filename stored in an ALName object.  A lot of times you will want to
//  do this in order to create a backup.  For example, you could change
//  TEMP.DAT to TEMP.DA@.
//
//  This function makes a copy of the current name in mszOldName, so we
//  can keep track of it later.  It then searches for the end of the
//  current file name, and changes it.
//
//  Note that if the filename doesn't have an extension, we do something
//  funny.  Instead of just changing the last character, we create a
//  new extension, and append that instead.  So if the filename is
//  "TEST", the new name will be "TEST.@".
//
//  If you apply this function to a filename, you can then rename the file
//  by calling ALStorage::Rename() with no argument.  When you do this,
//  the rename function uses the saved OldName and current name as its
//  arguments for the rename() function.
//
// REVISION HISTORY
//
//   May 26, 1994  1.0A  : First release
//
//   July 7, 1994  1.0B  : Had to add a default to the switch() statement,
//                         gcc -Wall was giving me a warning.

ALName AL_DLL_FAR & AL_PROTO ALName::
ChangeTrailingChar( char new_char /* = '@' */ )
{
    AL_ASSERT( mszName != 0, "ChangeTrailingChar: current name is null" );

    char *file_name = new char[ strlen( mszName ) + 2 ];
    if ( mszOldName )
        delete[] mszOldName;
    mszOldName = mszName;
    mszName = file_name;
    switch ( mCase ) {
        case AL_UPPER : new_char = (char) toupper( new_char ); break;
        case AL_LOWER : new_char = (char) tolower( new_char ); break;
        default       : break;
    }
    if ( !file_name )
        return *this;
    strcpy( mszName, mszOldName );
    char *p;
    if ( ( p = strrchr( mszName, '.' ) ) != 0 ) {
        if ( p[ 1 ] == '0' ) {
            p[ 1 ] = new_char;
            p[ 2 ] = '\0';
        } else
            mszName[ strlen( mszName ) - 1 ] = new_char;
    } else {
        char new_extension[ 3 ];
        new_extension[ 0 ] ='.';
        new_extension[ 1 ] = new_char;
        new_extension[ 2 ] = 0;
        strcat( mszName, new_extension );
    }
    return *this;
}

//
// const char * ALName::GetSafeName() const
//
// ARGUMENTS:
//
//  None.
//
// RETURNS
//
//  This function normally returns the value of mszName.  However, if
//  mszName is currently a null pointer, we return a pointer to an
//  empty string instead.  This means you can use the return value from
//  this function anywhere you want without checking for its NULLity.
//
// DESCRIPTION
//
//  See above.
//
// REVISION HISTORY
//
//   May 26, 1994  1.0A  : First release
//

const char AL_DLL_FAR * AL_PROTO ALName::GetSafeName() const
{
    if ( mszName )
        return mszName;
    else
        return "";
}

//
// const char * ALName::GetSafeOldName() const
//
// ARGUMENTS:
//
//  None.
//
// RETURNS
//
//  This function normally returns the value of mszOldName.  However, if
//  mszOldName is currently a null pointer, we return a pointer to an
//  empty string instead.  This means you can use the return value from
//  this function anywhere you want without checking for its NULLity.
//
// DESCRIPTION
//
//  See above.
//
// REVISION HISTORY
//
//   May 26, 1994  1.0A  : First release
//

const char AL_DLL_FAR * AL_PROTO ALName::GetSafeOldName() const
{
    if ( mszOldName )
        return mszOldName;
    else
        return "";
}

//
// ALName::operator const char *() const
//
// ARGUMENTS:
//
//  None.
//
// RETURNS
//
//  A pointer to the string inside the object.  If the string is
//  presently a null pointer, we return a pointer to an empty string
//  instead.  See ALName::GetSafeName() for an explanation of why
//  this is.
//
// DESCRIPTION
//
//  This is the casting operator that pretty much lets me use
//  an ALName object anywhere I use a char *.  There are some strange
//  Microsoft compiler problems that make me use this goofy STRINGF
//  typedef instead of char *, but it all adds up the same in
//  the wash.
//
// REVISION HISTORY
//
//   May 26, 1994  1.0A  : First release
//

#if defined( AL_MICROSOFT ) && ( AL_MICROSOFT < 800 ) && defined( AL_BUILDING_DLL ) //??????

AL_PROTO ALName::operator char *()  const
#else
AL_PROTO ALName::operator const STRINGF() const
#endif
{
    if ( mszName )
        return mszName;
    else
        return (char*)"";
}

//
// ALName & ALName::StripFileName()
//
// ARGUMENTS:
//
//  None.
//
// RETURNS
//
//  A reference to this.  This is nice, because you can strip the
//  file name from an object and use it in the same operation.
//
// DESCRIPTION
//
//  In the wildcard parsing code, sometimes I need to get the path
//  of a file, which means stripping off the filename and extension.
//  This is pretty easy to do, I just find the right spot and stick
//  a string termination character in that position.
//
// REVISION HISTORY
//
//   May 26, 1994  1.0A  : First release
//
//   July 7, 1994  1.0B  : Needed to use a different path separator character
//                         for UNIX.

ALName AL_DLL_FAR & AL_PROTO ALName::StripFileName()
{
    if ( mszName ) {
#ifdef AL_UNIX
        char *p = strrchr( mszName, '/' );
#else
        char *p = strrchr( mszName, '\\' );
#endif
        if ( p == 0 )
            p = strrchr( mszName, ':' );
        if ( p )
            p[ 1 ] = '\0';
        else
            mszName[ 0 ] = '\0';
    }
    return *this;
}

//
// ALName & ALName::StripPath()
//
// ARGUMENTS:
//
//  None.
//
// RETURNS
//
//  A reference to this.  This is nice, because you can strip the
//  file name from an object and use it in the same operation.
//
// DESCRIPTION
//
//  In the wildcard parsing code, sometimes I need to get just the
//  filename and extension of a file, which means stripping off the
//  drive and path information.  This is pretty easy to do, I just find
//  the start of the filename, and move it up to the start of the string.
//
// REVISION HISTORY
//
//   May 26, 1994  1.0A  : First release
//
//   July 7, 1994  1.0B  : Needed to use a different path separator character
//                         for UNIX.


ALName AL_DLL_FAR & AL_PROTO ALName::StripPath()
{
    if ( mszName ) {
#ifdef AL_UNIX
        char *p = strrchr( mszName, '/' );
#else
        char *p = strrchr( mszName, '\\' );
#endif
        if ( p == 0 )
            p = strrchr( mszName, ':' );
        if ( p ) {
            p++;
            char *s = mszName;
            while( ( *s++ = *p++ ) != 0 )
                ;
            *s = '\0';
        } //If not p, path is already stripped
    }
    return *this;
}

//
// int ALName::WildCardMatch( const char *pattern )
//
// ARGUMENTS:
//
//  pattern : A pointer to a regular expression, including wildcards
//            and sets.  It can get pretty complicated.
//
// RETURNS
//
//  0 if the pattern doesn't match the object name, 1 if it does.
//
// DESCRIPTION
//
//  This is a super-duper powerful function.  It is used to compare
//  a regular expression to the contents of an ALName.  The real meat
//  here is in the public domain string matching code found in _MATCH.CPP.
//
//  The tricky bit here is that we have to make a comparison based
//  on the case sensitivity of this.  Rather than trying to modify
//  the code in _MATCH.CPP, I just make a new copy of the pattern, and
//  mangle the case according to what this expects.
//
// REVISION HISTORY
//
//   May 26, 1994  1.0A  : First release
//
//   July 7, 1994  1.0B  : Had to add a default case to the switch()
//                         statement to avoid a warning from gcc -Wall.

int AL_PROTO ALName::WildCardMatch( const char AL_DLL_FAR *pattern )
{
    int error;
    int result;
    char *p = new char[ strlen( pattern ) + 1 ];

    if ( !p )
        return 0;
    strcpy( p, pattern );
    switch ( mCase ) {
        case AL_UPPER : strupr( p ); break;
        case AL_LOWER : strlwr( p ); break;
        default       : break;
    }
    if ( !is_valid_pattern( p, &error ) )
        result = 0;
    else if ( matche( p, mszName ) == MATCH_VALID )
        result = 1;
    else
        result = 0;
    delete[] p;
    return result;
}

// PROTECTED MEMBER FUNCTION.
//
// void ALName::Strcpy( const char *s )
//
// ARGUMENTS:
//
//  s  :  A character string to be copied into mszName.
//
// RETURNS
//
//  Nothing.
//
// DESCRIPTION
//
//  Whenever I am going to copy a string into mszName, I need to convert
//  it to the case that this object expects.  If it is AL_UPPER or
//  AL_LOWER, that means copying and then converting to either all upper
//  case or all lower case.  I do that here.
//
// REVISION HISTORY
//
//   May 26, 1994  1.0A  : First release
//
//   July 7, 1994  1.0B  : Had to add a default case to the switch()
//                         statement to avoid a warning from gcc -Wall.


void AL_PROTO ALName::Strcpy( const char *s )
{
    strcpy( mszName, s );
     switch ( mCase ) {
        case AL_UPPER : strupr( mszName ); break;
        case AL_LOWER : strlwr( mszName ); break;
        default       : break;
     }
}