home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1998 / MacHack 1998.toast / Programming Contest / MacHack Contest.sit / MacHack Contest / Test Code Folder / Problem 05 Test Code / Main.cp
MacBinary  |  1998-05-24  |  4.0 KB  |  [TEXT/CWIE]

open in: MacOS 8.1     |     Win98     |     DOS

browse contents    |     view JSON data     |     view as text


This file was processed as: MacBinary (archive/macBinary).

ConfidenceProgramDetectionMatch TypeSupport
10% dexvert MacBinary (archive/macBinary) fallback Supported
1% dexvert MS-DOS Code Page Info (other/dosCodePage) ext Unsupported
1% dexvert Text File (text/txt) fallback Supported
100% file MacBinary II, Sun May 24 18:00:57 1998, modified Sun May 24 18:00:57 1998, creator 'CWIE', type ASCII, 3452 bytes "Main.cp" , at 0xdfc 410 bytes resource default (weak)
99% file data default
74% TrID Macintosh plain text (MacBinary) default
25% TrID MacBinary 2 default (weak)
100% siegfried fmt/1762 MacBinary (II) default
100% lsar MacBinary default


id metadata
keyvalue
macFileType[TEXT]
macFileCreator[CWIE]



hex view
+--------+-------------------------+-------------------------+--------+--------+
|00000000| 00 07 4d 61 69 6e 2e 63 | 70 00 00 00 00 00 00 00 |..Main.c|p.......|
|00000010| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000020| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000030| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000040| 00 54 45 58 54 43 57 49 | 45 00 00 00 00 00 00 00 |.TEXTCWI|E.......|
|00000050| 00 00 00 00 00 0d 7c 00 | 00 01 9a b1 8e 49 19 b1 |......|.|.....I..|
|00000060| 8e 49 19 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |.I......|........|
|00000070| 00 00 00 00 00 00 00 00 | 00 00 81 81 2c 50 00 00 |........|....,P..|
|00000080| 23 69 6e 63 6c 75 64 65 | 20 22 53 6f 6c 75 74 69 |#include| "Soluti|
|00000090| 6f 6e 2e 68 22 0d 0d 23 | 69 6e 63 6c 75 64 65 20 |on.h"..#|include |
|000000a0| 22 50 72 6f 62 6c 65 6d | 55 74 69 6c 73 2e 68 22 |"Problem|Utils.h"|
|000000b0| 0d 0d 23 69 6e 63 6c 75 | 64 65 20 3c 73 74 64 69 |..#inclu|de <stdi|
|000000c0| 6f 2e 68 3e 0d 23 69 6e | 63 6c 75 64 65 20 3c 73 |o.h>.#in|clude <s|
|000000d0| 74 72 69 6e 67 2e 68 3e | 0d 23 69 6e 63 6c 75 64 |tring.h>|.#includ|
|000000e0| 65 20 3c 46 69 6c 65 73 | 2e 68 3e 0d 23 69 6e 63 |e <Files|.h>.#inc|
|000000f0| 6c 75 64 65 20 3c 45 72 | 72 6f 72 73 2e 68 3e 0d |lude <Er|rors.h>.|
|00000100| 0d 73 74 61 74 69 63 20 | 4f 53 45 72 72 20 57 72 |.static |OSErr Wr|
|00000110| 69 74 65 45 6e 74 72 79 | 54 6f 48 61 6e 64 6c 65 |iteEntry|ToHandle|
|00000120| 28 20 48 61 6e 64 6c 65 | 20 6f 75 74 70 75 74 2c |( Handle| output,|
|00000130| 20 55 49 6e 74 33 32 20 | 66 69 65 6c 64 5f 63 6f | UInt32 |field_co|
|00000140| 75 6e 74 2c 20 53 74 72 | 69 6e 67 73 48 61 6e 64 |unt, Str|ingsHand|
|00000150| 6c 65 20 65 6e 74 72 79 | 20 29 0d 7b 0d 09 4f 53 |le entry| ).{..OS|
|00000160| 45 72 72 20 65 72 72 3b | 0d 09 53 74 72 32 35 35 |Err err;|..Str255|
|00000170| 20 66 69 65 6c 64 3b 0d | 09 75 6e 73 69 67 6e 65 | field;.|.unsigne|
|00000180| 64 20 63 68 61 72 20 2a | 70 3b 0d 09 6c 6f 6e 67 |d char *|p;..long|
|00000190| 20 69 3b 0d 0d 09 69 66 | 20 28 20 65 6e 74 72 79 | i;...if| ( entry|
|000001a0| 20 29 20 7b 0d 09 09 48 | 4c 6f 63 6b 28 20 65 6e | ) {...H|Lock( en|
|000001b0| 74 72 79 20 29 3b 0d 09 | 09 70 20 3d 20 28 75 6e |try );..|.p = (un|
|000001c0| 73 69 67 6e 65 64 20 63 | 68 61 72 20 2a 29 20 2a |signed c|har *) *|
|000001d0| 65 6e 74 72 79 3b 0d 09 | 09 66 6f 72 20 28 20 69 |entry;..|.for ( i|
|000001e0| 20 3d 20 31 3b 20 69 20 | 3c 3d 20 66 69 65 6c 64 | = 1; i |<= field|
|000001f0| 5f 63 6f 75 6e 74 3b 20 | 69 2b 2b 20 29 20 7b 0d |_count; |i++ ) {.|
|00000200| 09 09 09 42 6c 6f 63 6b | 4d 6f 76 65 44 61 74 61 |...Block|MoveData|
|00000210| 28 20 70 2c 20 66 69 65 | 6c 64 2c 20 2a 70 20 2b |( p, fie|ld, *p +|
|00000220| 20 31 20 29 3b 0d 09 09 | 09 70 20 3d 20 70 20 2b | 1 );...|.p = p +|
|00000230| 20 2a 70 20 2b 20 31 3b | 0d 09 09 09 50 72 6f 62 | *p + 1;|....Prob|
|00000240| 6c 65 6d 50 32 43 53 74 | 72 69 6e 67 28 20 26 66 |lemP2CSt|ring( &f|
|00000250| 69 65 6c 64 20 29 3b 0d | 09 09 09 65 72 72 20 3d |ield );.|...err =|
|00000260| 20 50 72 6f 62 6c 65 6d | 57 72 69 74 65 53 74 72 | Problem|WriteStr|
|00000270| 69 6e 67 54 6f 48 61 6e | 64 6c 65 28 20 6f 75 74 |ingToHan|dle( out|
|00000280| 70 75 74 2c 20 28 63 68 | 61 72 20 2a 29 66 69 65 |put, (ch|ar *)fie|
|00000290| 6c 64 20 29 3b 0d 09 09 | 09 69 66 20 28 20 65 72 |ld );...|.if ( er|
|000002a0| 72 20 21 3d 20 6e 6f 45 | 72 72 20 29 20 62 72 65 |r != noE|rr ) bre|
|000002b0| 61 6b 3b 0d 09 09 09 69 | 66 20 28 20 69 20 3c 20 |ak;....i|f ( i < |
|000002c0| 66 69 65 6c 64 5f 63 6f | 75 6e 74 20 29 20 7b 0d |field_co|unt ) {.|
|000002d0| 09 09 09 09 65 72 72 20 | 3d 20 50 72 6f 62 6c 65 |....err |= Proble|
|000002e0| 6d 57 72 69 74 65 53 74 | 72 69 6e 67 54 6f 48 61 |mWriteSt|ringToHa|
|000002f0| 6e 64 6c 65 28 20 6f 75 | 74 70 75 74 2c 20 22 2c |ndle( ou|tput, ",|
|00000300| 22 20 29 3b 0d 09 09 09 | 09 69 66 20 28 20 65 72 |" );....|.if ( er|
|00000310| 72 20 21 3d 20 6e 6f 45 | 72 72 20 29 20 62 72 65 |r != noE|rr ) bre|
|00000320| 61 6b 3b 0d 09 09 09 7d | 0d 09 09 7d 0d 09 09 48 |ak;....}|...}...H|
|00000330| 55 6e 6c 6f 63 6b 28 20 | 65 6e 74 72 79 20 29 3b |Unlock( |entry );|
|00000340| 0d 09 09 69 66 20 28 20 | 65 72 72 20 21 3d 20 6e |...if ( |err != n|
|00000350| 6f 45 72 72 20 29 20 72 | 65 74 75 72 6e 20 65 72 |oErr ) r|eturn er|
|00000360| 72 3b 0d 09 09 65 72 72 | 20 3d 20 50 72 6f 62 6c |r;...err| = Probl|
|00000370| 65 6d 57 72 69 74 65 4c | 69 6e 65 54 6f 48 61 6e |emWriteL|ineToHan|
|00000380| 64 6c 65 28 20 6f 75 74 | 70 75 74 2c 20 22 22 20 |dle( out|put, "" |
|00000390| 29 3b 0d 09 7d 20 65 6c | 73 65 20 7b 0d 09 09 65 |);..} el|se {...e|
|000003a0| 72 72 20 3d 20 50 72 6f | 62 6c 65 6d 57 72 69 74 |rr = Pro|blemWrit|
|000003b0| 65 4c 69 6e 65 54 6f 48 | 61 6e 64 6c 65 28 20 6f |eLineToH|andle( o|
|000003c0| 75 74 70 75 74 2c 20 22 | 4e 75 6c 6c 20 45 6e 74 |utput, "|Null Ent|
|000003d0| 72 79 22 20 29 3b 0d 09 | 7d 0d 09 72 65 74 75 72 |ry" );..|}..retur|
|000003e0| 6e 20 65 72 72 3b 0d 7d | 0d 0d 70 61 73 63 61 6c |n err;.}|..pascal|
|000003f0| 20 4f 53 45 72 72 20 43 | 68 65 63 6b 44 61 74 61 | OSErr C|heckData|
|00000400| 62 61 73 65 28 20 63 6f | 6e 73 74 20 46 53 53 70 |base( co|nst FSSp|
|00000410| 65 63 2a 20 69 6e 66 69 | 6c 65 2c 20 63 6f 6e 73 |ec* infi|le, cons|
|00000420| 74 20 46 53 53 70 65 63 | 2a 20 6f 75 74 66 69 6c |t FSSpec|* outfil|
|00000430| 65 20 29 0d 7b 0d 09 4f | 53 45 72 72 20 65 72 72 |e ).{..O|SErr err|
|00000440| 3b 0d 09 48 61 6e 64 6c | 65 20 64 61 74 61 3b 0d |;..Handl|e data;.|
|00000450| 09 48 61 6e 64 6c 65 20 | 72 65 73 75 6c 74 3b 0d |.Handle |result;.|
|00000460| 09 63 68 61 72 20 6c 69 | 6e 65 5b 4d 41 58 5f 4c |.char li|ne[MAX_L|
|00000470| 49 4e 45 5f 4c 45 4e 5d | 3b 0d 09 63 68 61 72 20 |INE_LEN]|;..char |
|00000480| 2a 6c 69 6e 65 70 3b 0d | 09 63 68 61 72 20 63 6f |*linep;.|.char co|
|00000490| 6d 6d 61 6e 64 5b 4d 41 | 58 5f 4c 49 4e 45 5f 4c |mmand[MA|X_LINE_L|
|000004a0| 45 4e 5d 3b 0d 09 63 68 | 61 72 20 6e 75 6d 62 65 |EN];..ch|ar numbe|
|000004b0| 72 73 5b 4d 41 58 5f 4c | 49 4e 45 5f 4c 45 4e 5d |rs[MAX_L|INE_LEN]|
|000004c0| 3b 0d 09 53 74 72 32 35 | 35 20 66 69 65 6c 64 3b |;..Str25|5 field;|
|000004d0| 0d 09 55 49 6e 74 33 32 | 20 66 69 65 6c 64 5f 63 |..UInt32| field_c|
|000004e0| 6f 75 6e 74 2c 69 3b 0d | 09 44 61 74 61 62 61 73 |ount,i;.|.Databas|
|000004f0| 65 48 61 6e 64 6c 65 20 | 64 61 74 61 62 61 73 65 |eHandle |database|
|00000500| 3b 0d 09 53 74 72 69 6e | 67 73 48 61 6e 64 6c 65 |;..Strin|gsHandle|
|00000510| 20 65 6e 74 72 79 3b 0d | 09 0d 09 72 65 73 75 6c | entry;.|...resul|
|00000520| 74 20 3d 20 4e 65 77 48 | 61 6e 64 6c 65 28 20 30 |t = NewH|andle( 0|
|00000530| 20 29 3b 0d 09 65 72 72 | 20 3d 20 4d 65 6d 45 72 | );..err| = MemEr|
|00000540| 72 6f 72 28 29 3b 0d 09 | 50 72 6f 62 6c 65 6d 4c |ror();..|ProblemL|
|00000550| 6f 67 45 72 72 6f 72 28 | 20 65 72 72 2c 20 22 43 |ogError(| err, "C|
|00000560| 68 65 63 6b 44 61 74 61 | 62 61 73 65 3a 20 4e 65 |heckData|base: Ne|
|00000570| 77 48 61 6e 64 6c 65 3a | 20 72 65 73 75 6c 74 22 |wHandle:| result"|
|00000580| 20 29 3b 0d 0d 09 65 72 | 72 20 3d 20 50 72 6f 62 | );...er|r = Prob|
|00000590| 6c 65 6d 46 69 6c 65 52 | 65 61 64 28 20 69 6e 66 |lemFileR|ead( inf|
|000005a0| 69 6c 65 2c 20 26 64 61 | 74 61 20 29 3b 0d 09 50 |ile, &da|ta );..P|
|000005b0| 72 6f 62 6c 65 6d 4c 6f | 67 45 72 72 6f 72 28 20 |roblemLo|gError( |
|000005c0| 65 72 72 2c 20 22 43 68 | 65 63 6b 44 61 74 61 62 |err, "Ch|eckDatab|
|000005d0| 61 73 65 3a 20 50 72 6f | 62 6c 65 6d 46 69 6c 65 |ase: Pro|blemFile|
|000005e0| 52 65 61 64 22 20 29 3b | 0d 09 69 66 20 28 20 65 |Read" );|..if ( e|
|000005f0| 72 72 20 3d 3d 20 6e 6f | 45 72 72 20 29 20 7b 0d |rr == no|Err ) {.|
|00000600| 09 09 6c 69 6e 65 70 20 | 3d 20 6c 69 6e 65 3b 0d |..linep |= line;.|
|00000610| 09 09 69 66 20 28 20 21 | 50 72 6f 62 6c 65 6d 52 |..if ( !|ProblemR|
|00000620| 65 61 64 4c 69 6e 65 46 | 72 6f 6d 48 61 6e 64 6c |eadLineF|romHandl|
|00000630| 65 28 20 64 61 74 61 2c | 20 6c 69 6e 65 2c 20 4d |e( data,| line, M|
|00000640| 41 58 5f 4c 49 4e 45 5f | 4c 45 4e 20 29 20 7c 7c |AX_LINE_|LEN ) |||
|00000650| 20 21 50 72 6f 62 6c 65 | 6d 47 65 74 55 49 6e 74 | !Proble|mGetUInt|
|00000660| 33 32 28 20 26 6c 69 6e | 65 70 2c 20 26 66 69 65 |32( &lin|ep, &fie|
|00000670| 6c 64 5f 63 6f 75 6e 74 | 20 29 20 29 20 7b 0d 09 |ld_count| ) ) {..|
|00000680| 09 09 65 72 72 20 3d 20 | 2d 31 3b 0d 09 09 09 50 |..err = |-1;....P|
|00000690| 72 6f 62 6c 65 6d 4c 6f | 67 45 72 72 6f 72 28 20 |roblemLo|gError( |
|000006a0| 65 72 72 2c 20 22 43 68 | 65 63 6b 44 61 74 61 62 |err, "Ch|eckDatab|
|000006b0| 61 73 65 3a 20 66 69 65 | 6c 64 5f 63 6f 75 6e 74 |ase: fie|ld_count|
|000006c0| 22 20 29 3b 0d 09 09 7d | 0d 09 7d 0d 09 69 66 20 |" );...}|..}..if |
|000006d0| 28 20 65 72 72 20 3d 3d | 20 6e 6f 45 72 72 20 29 |( err ==| noErr )|
|000006e0| 20 7b 0d 09 09 44 61 74 | 61 62 61 73 65 49 6e 69 | {...Dat|abaseIni|
|000006f0| 74 28 20 26 64 61 74 61 | 62 61 73 65 2c 20 66 69 |t( &data|base, fi|
|00000700| 65 6c 64 5f 63 6f 75 6e | 74 20 29 3b 0d 09 09 0d |eld_coun|t );....|
|00000710| 09 09 77 68 69 6c 65 20 | 28 20 28 65 72 72 20 3d |..while |( (err =|
|00000720| 3d 20 6e 6f 45 72 72 29 | 20 26 26 20 50 72 6f 62 |= noErr)| && Prob|
|00000730| 6c 65 6d 52 65 61 64 4c | 69 6e 65 46 72 6f 6d 48 |lemReadL|ineFromH|
|00000740| 61 6e 64 6c 65 28 20 64 | 61 74 61 2c 20 6c 69 6e |andle( d|ata, lin|
|00000750| 65 2c 20 4d 41 58 5f 4c | 49 4e 45 5f 4c 45 4e 20 |e, MAX_L|INE_LEN |
|00000760| 29 20 29 20 7b 0d 09 09 | 09 6c 69 6e 65 70 20 3d |) ) {...|.linep =|
|00000770| 20 6c 69 6e 65 3b 0d 09 | 09 09 50 72 6f 62 6c 65 | line;..|..Proble|
|00000780| 6d 47 65 74 43 53 74 72 | 69 6e 67 28 20 26 6c 69 |mGetCStr|ing( &li|
|00000790| 6e 65 70 2c 20 63 6f 6d | 6d 61 6e 64 2c 20 4d 41 |nep, com|mand, MA|
|000007a0| 58 5f 4c 49 4e 45 5f 4c | 45 4e 20 29 3b 0d 09 09 |X_LINE_L|EN );...|
|000007b0| 09 69 66 20 28 20 73 74 | 72 63 6d 70 28 20 63 6f |.if ( st|rcmp( co|
|000007c0| 6d 6d 61 6e 64 2c 20 22 | 41 44 44 22 20 29 20 3d |mmand, "|ADD" ) =|
|000007d0| 3d 20 30 20 29 20 7b 0d | 09 09 09 09 65 6e 74 72 |= 0 ) {.|....entr|
|000007e0| 79 20 3d 20 4e 65 77 48 | 61 6e 64 6c 65 28 20 30 |y = NewH|andle( 0|
|000007f0| 20 29 3b 0d 09 09 09 09 | 65 72 72 20 3d 20 4d 65 | );.....|err = Me|
|00000800| 6d 45 72 72 6f 72 28 29 | 3b 0d 09 09 09 09 50 72 |mError()|;.....Pr|
|00000810| 6f 62 6c 65 6d 4c 6f 67 | 45 72 72 6f 72 28 20 65 |oblemLog|Error( e|
|00000820| 72 72 2c 20 22 43 68 65 | 63 6b 44 61 74 61 62 61 |rr, "Che|ckDataba|
|00000830| 73 65 3a 20 4e 65 77 48 | 61 6e 64 6c 65 3a 20 65 |se: NewH|andle: e|
|00000840| 6e 74 72 79 22 20 29 3b | 0d 09 09 09 09 66 6f 72 |ntry" );|.....for|
|00000850| 20 28 20 69 20 3d 20 31 | 3b 20 69 20 3c 3d 20 66 | ( i = 1|; i <= f|
|00000860| 69 65 6c 64 5f 63 6f 75 | 6e 74 3b 20 69 2b 2b 20 |ield_cou|nt; i++ |
|00000870| 29 20 7b 0d 09 09 09 09 | 09 50 72 6f 62 6c 65 6d |) {.....|.Problem|
|00000880| 47 65 74 53 74 72 69 6e | 67 28 20 26 6c 69 6e 65 |GetStrin|g( &line|
|00000890| 70 2c 20 66 69 65 6c 64 | 20 29 3b 0d 09 09 09 09 |p, field| );.....|
|000008a0| 09 65 72 72 20 3d 20 50 | 74 72 41 6e 64 48 61 6e |.err = P|trAndHan|
|000008b0| 64 28 20 66 69 65 6c 64 | 2c 20 65 6e 74 72 79 2c |d( field|, entry,|
|000008c0| 20 66 69 65 6c 64 5b 30 | 5d 20 2b 20 31 20 29 3b | field[0|] + 1 );|
|000008d0| 0d 09 09 09 09 09 69 66 | 20 28 20 65 72 72 20 21 |......if| ( err !|
|000008e0| 3d 20 6e 6f 45 72 72 20 | 29 20 62 72 65 61 6b 3b |= noErr |) break;|
|000008f0| 0d 09 09 09 09 09 50 72 | 6f 62 6c 65 6d 4c 6f 67 |......Pr|oblemLog|
|00000900| 45 72 72 6f 72 28 20 65 | 72 72 2c 20 22 43 68 65 |Error( e|rr, "Che|
|00000910| 63 6b 44 61 74 61 62 61 | 73 65 3a 20 50 74 72 41 |ckDataba|se: PtrA|
|00000920| 6e 64 48 61 6e 64 22 20 | 29 3b 0d 09 09 09 09 7d |ndHand" |);.....}|
|00000930| 0d 09 09 09 09 69 66 20 | 28 20 65 72 72 20 3d 3d |.....if |( err ==|
|00000940| 20 6e 6f 45 72 72 20 29 | 20 7b 0d 09 09 09 09 09 | noErr )| {......|
|00000950| 44 61 74 61 62 61 73 65 | 41 64 64 45 6e 74 72 79 |Database|AddEntry|
|00000960| 28 20 64 61 74 61 62 61 | 73 65 2c 20 65 6e 74 72 |( databa|se, entr|
|00000970| 79 20 29 3b 0d 09 09 09 | 09 7d 0d 09 09 09 09 44 |y );....|.}.....D|
|00000980| 69 73 70 6f 73 65 48 61 | 6e 64 6c 65 28 20 65 6e |isposeHa|ndle( en|
|00000990| 74 72 79 20 29 3b 0d 09 | 09 09 7d 20 65 6c 73 65 |try );..|..} else|
|000009a0| 20 69 66 20 28 20 73 74 | 72 63 6d 70 28 20 63 6f | if ( st|rcmp( co|
|000009b0| 6d 6d 61 6e 64 2c 20 22 | 46 49 4e 44 22 20 29 20 |mmand, "|FIND" ) |
|000009c0| 3d 3d 20 30 20 29 20 7b | 0d 09 09 09 09 50 72 6f |== 0 ) {|.....Pro|
|000009d0| 62 6c 65 6d 47 65 74 55 | 49 6e 74 33 32 28 20 26 |blemGetU|Int32( &|
|000009e0| 6c 69 6e 65 70 2c 20 26 | 69 20 29 3b 0d 09 09 09 |linep, &|i );....|
|000009f0| 09 50 72 6f 62 6c 65 6d | 47 65 74 53 74 72 69 6e |.Problem|GetStrin|
|00000a00| 67 28 20 26 6c 69 6e 65 | 70 2c 20 66 69 65 6c 64 |g( &line|p, field|
|00000a10| 20 29 3b 0d 09 09 09 09 | 44 61 74 61 62 61 73 65 | );.....|Database|
|00000a20| 46 69 6e 64 45 6e 74 72 | 79 28 20 64 61 74 61 62 |FindEntr|y( datab|
|00000a30| 61 73 65 2c 20 69 2c 20 | 66 69 65 6c 64 2c 20 26 |ase, i, |field, &|
|00000a40| 65 6e 74 72 79 20 29 3b | 0d 09 09 09 09 65 72 72 |entry );|.....err|
|00000a50| 20 3d 20 57 72 69 74 65 | 45 6e 74 72 79 54 6f 48 | = Write|EntryToH|
|00000a60| 61 6e 64 6c 65 28 20 72 | 65 73 75 6c 74 2c 20 66 |andle( r|esult, f|
|00000a70| 69 65 6c 64 5f 63 6f 75 | 6e 74 2c 20 65 6e 74 72 |ield_cou|nt, entr|
|00000a80| 79 20 29 3b 0d 09 09 09 | 7d 20 65 6c 73 65 20 69 |y );....|} else i|
|00000a90| 66 20 28 20 73 74 72 63 | 6d 70 28 20 63 6f 6d 6d |f ( strc|mp( comm|
|00000aa0| 61 6e 64 2c 20 22 44 45 | 4c 45 54 45 22 20 29 20 |and, "DE|LETE" ) |
|00000ab0| 3d 3d 20 30 20 29 20 7b | 0d 09 09 09 09 50 72 6f |== 0 ) {|.....Pro|
|00000ac0| 62 6c 65 6d 47 65 74 55 | 49 6e 74 33 32 28 20 26 |blemGetU|Int32( &|
|00000ad0| 6c 69 6e 65 70 2c 20 26 | 69 20 29 3b 0d 09 09 09 |linep, &|i );....|
|00000ae0| 09 50 72 6f 62 6c 65 6d | 47 65 74 53 74 72 69 6e |.Problem|GetStrin|
|00000af0| 67 28 20 26 6c 69 6e 65 | 70 2c 20 66 69 65 6c 64 |g( &line|p, field|
|00000b00| 20 29 3b 0d 09 09 09 09 | 44 61 74 61 62 61 73 65 | );.....|Database|
|00000b10| 44 65 6c 65 74 65 45 6e | 74 72 79 28 20 64 61 74 |DeleteEn|try( dat|
|00000b20| 61 62 61 73 65 2c 20 69 | 2c 20 66 69 65 6c 64 20 |abase, i|, field |
|00000b30| 29 3b 0d 09 09 09 7d 20 | 65 6c 73 65 20 69 66 20 |);....} |else if |
|00000b40| 28 20 73 74 72 63 6d 70 | 28 20 63 6f 6d 6d 61 6e |( strcmp|( comman|
|00000b50| 64 2c 20 22 43 4f 55 4e | 54 22 20 29 20 3d 3d 20 |d, "COUN|T" ) == |
|00000b60| 30 20 29 20 7b 0d 09 09 | 09 09 69 20 3d 20 44 61 |0 ) {...|..i = Da|
|00000b70| 74 61 62 61 73 65 43 6f | 75 6e 74 28 20 64 61 74 |tabaseCo|unt( dat|
|00000b80| 61 62 61 73 65 20 29 3b | 0d 09 09 09 09 73 70 72 |abase );|.....spr|
|00000b90| 69 6e 74 66 28 20 6e 75 | 6d 62 65 72 73 2c 20 22 |intf( nu|mbers, "|
|00000ba0| 25 6c 64 22 2c 20 69 20 | 29 3b 0d 09 09 09 09 65 |%ld", i |);.....e|
|00000bb0| 72 72 20 3d 20 50 72 6f | 62 6c 65 6d 57 72 69 74 |rr = Pro|blemWrit|
|00000bc0| 65 4c 69 6e 65 54 6f 48 | 61 6e 64 6c 65 28 20 72 |eLineToH|andle( r|
|00000bd0| 65 73 75 6c 74 2c 20 6e | 75 6d 62 65 72 73 20 29 |esult, n|umbers )|
|00000be0| 3b 0d 09 09 09 7d 0d 09 | 09 09 69 66 20 28 20 65 |;....}..|..if ( e|
|00000bf0| 72 72 20 21 3d 20 6e 6f | 45 72 72 20 29 20 62 72 |rr != no|Err ) br|
|00000c00| 65 61 6b 3b 0d 09 09 7d | 0d 09 09 0d 09 09 69 66 |eak;...}|......if|
|00000c10| 20 28 20 65 72 72 20 3d | 3d 20 6e 6f 45 72 72 20 | ( err =|= noErr |
|00000c20| 29 20 7b 0d 09 09 09 65 | 72 72 20 3d 20 50 72 6f |) {....e|rr = Pro|
|00000c30| 62 6c 65 6d 57 72 69 74 | 65 4c 69 6e 65 54 6f 48 |blemWrit|eLineToH|
|00000c40| 61 6e 64 6c 65 28 20 72 | 65 73 75 6c 74 2c 20 22 |andle( r|esult, "|
|00000c50| 44 75 6d 70 69 6e 67 22 | 20 29 3b 0d 09 09 09 66 |Dumping"| );....f|
|00000c60| 6f 72 20 28 20 69 20 3d | 20 31 3b 20 69 20 3c 3d |or ( i =| 1; i <=|
|00000c70| 20 44 61 74 61 62 61 73 | 65 43 6f 75 6e 74 28 20 | Databas|eCount( |
|00000c80| 64 61 74 61 62 61 73 65 | 20 29 3b 20 69 2b 2b 20 |database| ); i++ |
|00000c90| 29 20 7b 0d 09 09 09 09 | 44 61 74 61 62 61 73 65 |) {.....|Database|
|00000ca0| 47 65 74 49 6e 64 45 6e | 74 72 79 28 20 64 61 74 |GetIndEn|try( dat|
|00000cb0| 61 62 61 73 65 2c 20 69 | 2c 20 26 65 6e 74 72 79 |abase, i|, &entry|
|00000cc0| 20 29 3b 0d 09 09 09 09 | 65 72 72 20 3d 20 57 72 | );.....|err = Wr|
|00000cd0| 69 74 65 45 6e 74 72 79 | 54 6f 48 61 6e 64 6c 65 |iteEntry|ToHandle|
|00000ce0| 28 20 72 65 73 75 6c 74 | 2c 20 66 69 65 6c 64 5f |( result|, field_|
|00000cf0| 63 6f 75 6e 74 2c 20 65 | 6e 74 72 79 20 29 3b 0d |count, e|ntry );.|
|00000d00| 09 09 09 7d 0d 09 09 7d | 0d 09 09 0d 09 09 44 69 |...}...}|......Di|
|00000d10| 73 70 6f 73 65 48 61 6e | 64 6c 65 28 20 64 61 74 |sposeHan|dle( dat|
|00000d20| 61 62 61 73 65 20 29 3b | 0d 09 7d 0d 09 0d 09 65 |abase );|..}....e|
|00000d30| 72 72 20 3d 20 50 72 6f | 62 6c 65 6d 46 69 6c 65 |rr = Pro|blemFile|
|00000d40| 57 72 69 74 65 28 20 6f | 75 74 66 69 6c 65 2c 20 |Write( o|utfile, |
|00000d50| 72 65 73 75 6c 74 20 29 | 3b 0d 09 0d 09 44 69 73 |result )|;....Dis|
|00000d60| 70 6f 73 65 48 61 6e 64 | 6c 65 28 20 72 65 73 75 |poseHand|le( resu|
|00000d70| 6c 74 20 29 3b 0d 09 44 | 69 73 70 6f 73 65 48 61 |lt );..D|isposeHa|
|00000d80| 6e 64 6c 65 28 20 64 61 | 74 61 20 29 3b 0d 09 72 |ndle( da|ta );..r|
|00000d90| 65 74 75 72 6e 20 65 72 | 72 3b 0d 7d 0d 0d 69 6e |eturn er|r;.}..in|
|00000da0| 74 20 6d 61 69 6e 28 29 | 0d 7b 0d 09 70 72 69 6e |t main()|.{..prin|
|00000db0| 74 66 28 20 22 53 74 61 | 72 74 69 6e 67 5c 6e 22 |tf( "Sta|rting\n"|
|00000dc0| 20 29 3b 0d 09 0d 09 50 | 72 6f 62 6c 65 6d 52 75 | );....P|roblemRu|
|00000dd0| 6e 46 69 6c 65 54 65 73 | 74 73 28 20 43 68 65 63 |nFileTes|ts( Chec|
|00000de0| 6b 44 61 74 61 62 61 73 | 65 20 29 3b 0d 0d 09 72 |kDatabas|e );...r|
|00000df0| 65 74 75 72 6e 20 30 3b | 0d 7d 0d 0d 00 00 00 00 |eturn 0;|.}......|
|00000e00| 00 00 01 00 00 00 01 54 | 00 00 00 54 00 00 00 46 |.......T|...T...F|
|00000e10| 2b 30 38 30 30 31 35 3a | 35 35 3a 33 32 20 31 39 |+080015:|55:32 19|
|00000e20| 39 38 00 00 00 00 00 00 | 00 00 b1 78 6a 77 00 00 |98......|...xjw..|
|00000e30| 07 4d 61 69 6e 2e 63 70 | 65 64 20 4d 61 63 48 61 |.Main.cp|ed MacHa|
|00000e40| 63 6b 20 43 6f 6e 74 65 | 73 74 31 2e 73 69 74 69 |ck Conte|st1.siti|
|00000e50| 02 4a 50 61 72 74 53 49 | 54 21 00 00 00 00 00 00 |.JPartSI|T!......|
|00000e60| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000e70| 00 00 b1 b0 40 90 00 00 | 00 00 00 00 01 9a 00 00 |....@...|........|
|00000e80| 00 00 29 bc 7f 92 00 00 | 00 00 20 52 65 3a 20 46 |..).....|.. Re: F|
|00000e90| 6f 6c 64 65 72 20 48 69 | 65 72 61 72 63 68 79 20 |older Hi|erarchy |
|00000ea0| 44 75 70 6c 69 63 61 74 | 69 6f 6e 0d 00 00 00 00 |Duplicat|ion.....|
|00000eb0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000ec0| 00 00 00 00 00 00 00 00 | 00 04 36 35 37 a4 00 00 |........|..657...|
|00000ed0| 00 00 00 00 00 00 00 00 | 00 01 be ab 00 00 05 f2 |........|........|
|00000ee0| 00 00 02 90 02 07 31 32 | 2f 35 2f 39 38 34 30 30 |......12|/5/98400|
|00000ef0| 30 32 31 3a 30 31 3a 35 | 36 20 31 39 39 38 00 00 |021:01:5|6 1998..|
|00000f00| 00 00 00 48 00 0a 47 65 | 6e 65 76 61 00 00 00 00 |...H..Ge|neva....|
|00000f10| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000f20| 00 00 00 00 00 00 00 02 | 00 02 00 33 00 24 02 5f |........|...3.$._|
|00000f30| 02 95 00 33 00 24 02 5f | 02 95 b1 8e 02 c9 00 00 |...3.$._|........|
|00000f40| 00 00 00 00 0d 7c 00 00 | 00 00 01 00 00 00 00 04 |.....|..|........|
|00000f50| 00 01 00 01 00 00 01 00 | 00 00 01 54 00 00 00 54 |........|...T...T|
|00000f60| 00 00 00 46 04 dc 54 d8 | 34 84 00 00 00 1c 00 46 |...F..T.|4......F|
|00000f70| 00 01 4d 50 53 52 00 00 | 00 12 4d 57 42 42 00 00 |..MPSR..|..MWBB..|
|00000f80| 00 1e 03 ed ff ff 00 00 | 00 00 00 00 00 00 03 f0 |........|........|
|00000f90| ff ff 00 00 00 4c 00 00 | 00 00 00 00 00 00 00 00 |.....L..|........|
|00000fa0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000fb0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000fc0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000fd0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000fe0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000ff0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
+--------+-------------------------+-------------------------+--------+--------+