home *** CD-ROM | disk | FTP | other *** search
MacBinary | 1993-07-25 | 12.6 KB | [TEXT/MPS ] |
open in:
MacOS 8.1
|
Win98
|
DOS
browse contents |
view JSON data
|
view as text
This file was processed as: MacBinary
(archive/macBinary).
Confidence | Program | Detection | Match Type | Support
|
---|
66%
| dexvert
| Compact Compressed (Unix) (archive/compact)
| ext
| Supported |
10%
| dexvert
| MacBinary (archive/macBinary)
| fallback
| Supported |
1%
| dexvert
| Text File (text/txt)
| fallback
| Supported |
100%
| file
| MacBinary II, Wed Jul 24 13:20:09 2024, modified Wed Jul 24 13:20:09 2024, creator 'MPS ', type ASCII, 12225 bytes "gdbmopen.c" , at 0x3041 428 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 |
---|
key | value |
---|
macFileType | [TEXT] |
macFileCreator | [MPS ] |
hex view+--------+-------------------------+-------------------------+--------+--------+
|00000000| 00 0a 67 64 62 6d 6f 70 | 65 6e 2e 63 00 00 00 00 |..gdbmop|en.c....|
|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 4d 50 53 | 20 00 00 00 00 00 00 00 |.TEXTMPS| .......|
|00000050| 00 00 00 00 00 2f c1 00 | 00 01 ac e2 c6 e8 49 e2 |...../..|......I.|
|00000060| c6 e8 49 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 31 83 00 00 |........|....1...|
|00000080| 2f 2a 20 67 64 62 6d 6f | 70 65 6e 2e 63 20 2d 20 |/* gdbmo|pen.c - |
|00000090| 4f 70 65 6e 20 74 68 65 | 20 64 62 6d 20 66 69 6c |Open the| dbm fil|
|000000a0| 65 20 61 6e 64 20 69 6e | 69 74 69 61 6c 69 7a 65 |e and in|itialize|
|000000b0| 20 64 61 74 61 20 73 74 | 72 75 63 74 75 72 65 73 | data st|ructures|
|000000c0| 20 66 6f 72 20 75 73 65 | 2e 20 2a 2f 0d 0d 2f 2a | for use|. */../*|
|000000d0| 20 20 54 68 69 73 20 66 | 69 6c 65 20 69 73 20 70 | This f|ile is p|
|000000e0| 61 72 74 20 6f 66 20 47 | 44 42 4d 2c 20 74 68 65 |art of G|DBM, the|
|000000f0| 20 47 4e 55 20 64 61 74 | 61 20 62 61 73 65 20 6d | GNU dat|a base m|
|00000100| 61 6e 61 67 65 72 2c 20 | 62 79 20 50 68 69 6c 69 |anager, |by Phili|
|00000110| 70 20 41 2e 20 4e 65 6c | 73 6f 6e 2e 0d 20 20 20 |p A. Nel|son.. |
|00000120| 20 43 6f 70 79 72 69 67 | 68 74 20 28 43 29 20 31 | Copyrig|ht (C) 1|
|00000130| 39 39 30 2c 20 31 39 39 | 31 20 20 46 72 65 65 20 |990, 199|1 Free |
|00000140| 53 6f 66 74 77 61 72 65 | 20 46 6f 75 6e 64 61 74 |Software| Foundat|
|00000150| 69 6f 6e 2c 20 49 6e 63 | 2e 0d 0d 20 20 20 20 47 |ion, Inc|... G|
|00000160| 44 42 4d 20 69 73 20 66 | 72 65 65 20 73 6f 66 74 |DBM is f|ree soft|
|00000170| 77 61 72 65 3b 20 79 6f | 75 20 63 61 6e 20 72 65 |ware; yo|u can re|
|00000180| 64 69 73 74 72 69 62 75 | 74 65 20 69 74 20 61 6e |distribu|te it an|
|00000190| 64 2f 6f 72 20 6d 6f 64 | 69 66 79 0d 20 20 20 20 |d/or mod|ify. |
|000001a0| 69 74 20 75 6e 64 65 72 | 20 74 68 65 20 74 65 72 |it under| the ter|
|000001b0| 6d 73 20 6f 66 20 74 68 | 65 20 47 4e 55 20 47 65 |ms of th|e GNU Ge|
|000001c0| 6e 65 72 61 6c 20 50 75 | 62 6c 69 63 20 4c 69 63 |neral Pu|blic Lic|
|000001d0| 65 6e 73 65 20 61 73 20 | 70 75 62 6c 69 73 68 65 |ense as |publishe|
|000001e0| 64 20 62 79 0d 20 20 20 | 20 74 68 65 20 46 72 65 |d by. | the Fre|
|000001f0| 65 20 53 6f 66 74 77 61 | 72 65 20 46 6f 75 6e 64 |e Softwa|re Found|
|00000200| 61 74 69 6f 6e 3b 20 65 | 69 74 68 65 72 20 76 65 |ation; e|ither ve|
|00000210| 72 73 69 6f 6e 20 31 2c | 20 6f 72 20 28 61 74 20 |rsion 1,| or (at |
|00000220| 79 6f 75 72 20 6f 70 74 | 69 6f 6e 29 0d 20 20 20 |your opt|ion). |
|00000230| 20 61 6e 79 20 6c 61 74 | 65 72 20 76 65 72 73 69 | any lat|er versi|
|00000240| 6f 6e 2e 0d 0d 20 20 20 | 20 47 44 42 4d 20 69 73 |on... | GDBM is|
|00000250| 20 64 69 73 74 72 69 62 | 75 74 65 64 20 69 6e 20 | distrib|uted in |
|00000260| 74 68 65 20 68 6f 70 65 | 20 74 68 61 74 20 69 74 |the hope| that it|
|00000270| 20 77 69 6c 6c 20 62 65 | 20 75 73 65 66 75 6c 2c | will be| useful,|
|00000280| 0d 20 20 20 20 62 75 74 | 20 57 49 54 48 4f 55 54 |. but| WITHOUT|
|00000290| 20 41 4e 59 20 57 41 52 | 52 41 4e 54 59 3b 20 77 | ANY WAR|RANTY; w|
|000002a0| 69 74 68 6f 75 74 20 65 | 76 65 6e 20 74 68 65 20 |ithout e|ven the |
|000002b0| 69 6d 70 6c 69 65 64 20 | 77 61 72 72 61 6e 74 79 |implied |warranty|
|000002c0| 20 6f 66 0d 20 20 20 20 | 4d 45 52 43 48 41 4e 54 | of. |MERCHANT|
|000002d0| 41 42 49 4c 49 54 59 20 | 6f 72 20 46 49 54 4e 45 |ABILITY |or FITNE|
|000002e0| 53 53 20 46 4f 52 20 41 | 20 50 41 52 54 49 43 55 |SS FOR A| PARTICU|
|000002f0| 4c 41 52 20 50 55 52 50 | 4f 53 45 2e 20 20 53 65 |LAR PURP|OSE. Se|
|00000300| 65 20 74 68 65 0d 20 20 | 20 20 47 4e 55 20 47 65 |e the. | GNU Ge|
|00000310| 6e 65 72 61 6c 20 50 75 | 62 6c 69 63 20 4c 69 63 |neral Pu|blic Lic|
|00000320| 65 6e 73 65 20 66 6f 72 | 20 6d 6f 72 65 20 64 65 |ense for| more de|
|00000330| 74 61 69 6c 73 2e 0d 0d | 20 20 20 20 59 6f 75 20 |tails...| You |
|00000340| 73 68 6f 75 6c 64 20 68 | 61 76 65 20 72 65 63 65 |should h|ave rece|
|00000350| 69 76 65 64 20 61 20 63 | 6f 70 79 20 6f 66 20 74 |ived a c|opy of t|
|00000360| 68 65 20 47 4e 55 20 47 | 65 6e 65 72 61 6c 20 50 |he GNU G|eneral P|
|00000370| 75 62 6c 69 63 20 4c 69 | 63 65 6e 73 65 0d 20 20 |ublic Li|cense. |
|00000380| 20 20 61 6c 6f 6e 67 20 | 77 69 74 68 20 47 44 42 | along |with GDB|
|00000390| 4d 3b 20 73 65 65 20 74 | 68 65 20 66 69 6c 65 20 |M; see t|he file |
|000003a0| 43 4f 50 59 49 4e 47 2e | 20 20 49 66 20 6e 6f 74 |COPYING.| If not|
|000003b0| 2c 20 77 72 69 74 65 20 | 74 6f 0d 20 20 20 20 74 |, write |to. t|
|000003c0| 68 65 20 46 72 65 65 20 | 53 6f 66 74 77 61 72 65 |he Free |Software|
|000003d0| 20 46 6f 75 6e 64 61 74 | 69 6f 6e 2c 20 36 37 35 | Foundat|ion, 675|
|000003e0| 20 4d 61 73 73 20 41 76 | 65 2c 20 43 61 6d 62 72 | Mass Av|e, Cambr|
|000003f0| 69 64 67 65 2c 20 4d 41 | 20 30 32 31 33 39 2c 20 |idge, MA| 02139, |
|00000400| 55 53 41 2e 0d 0d 20 20 | 20 20 59 6f 75 20 6d 61 |USA... | You ma|
|00000410| 79 20 63 6f 6e 74 61 63 | 74 20 74 68 65 20 61 75 |y contac|t the au|
|00000420| 74 68 6f 72 20 62 79 3a | 0d 20 20 20 20 20 20 20 |thor by:|. |
|00000430| 65 2d 6d 61 69 6c 3a 20 | 20 70 68 69 6c 40 63 73 |e-mail: | phil@cs|
|00000440| 2e 77 77 75 2e 65 64 75 | 0d 20 20 20 20 20 20 75 |.wwu.edu|. u|
|00000450| 73 2d 6d 61 69 6c 3a 20 | 20 50 68 69 6c 69 70 20 |s-mail: | Philip |
|00000460| 41 2e 20 4e 65 6c 73 6f | 6e 0d 20 20 20 20 20 20 |A. Nelso|n. |
|00000470| 20 20 20 20 20 20 20 20 | 20 20 43 6f 6d 70 75 74 | | Comput|
|00000480| 65 72 20 53 63 69 65 6e | 63 65 20 44 65 70 61 72 |er Scien|ce Depar|
|00000490| 74 6d 65 6e 74 0d 20 20 | 20 20 20 20 20 20 20 20 |tment. | |
|000004a0| 20 20 20 20 20 20 57 65 | 73 74 65 72 6e 20 57 61 | We|stern Wa|
|000004b0| 73 68 69 6e 67 74 6f 6e | 20 55 6e 69 76 65 72 73 |shington| Univers|
|000004c0| 69 74 79 0d 20 20 20 20 | 20 20 20 20 20 20 20 20 |ity. | |
|000004d0| 20 20 20 20 42 65 6c 6c | 69 6e 67 68 61 6d 2c 20 | Bell|ingham, |
|000004e0| 57 41 20 39 38 32 32 36 | 0d 20 20 20 20 20 20 20 |WA 98226|. |
|000004f0| 20 70 68 6f 6e 65 3a 20 | 20 28 32 30 36 29 20 36 | phone: | (206) 6|
|00000500| 37 36 2d 33 30 33 35 0d | 20 20 20 20 20 20 20 0d |76-3035.| .|
|00000510| 2a 2a 2a 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |********|********|
|00000520| 2a 2a 2a 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |********|********|
|00000530| 2a 2a 2a 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |********|********|
|00000540| 2a 2a 2a 2a 2a 2a 2a 2a | 2a 2a 2a 2a 2a 2a 2a 2a |********|********|
|00000550| 2a 2a 2a 2a 2a 2a 2a 2a | 2a 2f 0d 0d 0d 23 69 6e |********|*/...#in|
|00000560| 63 6c 75 64 65 20 22 67 | 64 62 6d 64 65 66 73 2e |clude "g|dbmdefs.|
|00000570| 68 22 0d 23 69 6e 63 6c | 75 64 65 20 22 67 64 62 |h".#incl|ude "gdb|
|00000580| 6d 65 72 72 6e 6f 2e 68 | 22 0d 0d 65 78 74 65 72 |merrno.h|"..exter|
|00000590| 6e 20 67 64 62 6d 5f 65 | 72 72 6f 72 20 67 64 62 |n gdbm_e|rror gdb|
|000005a0| 6d 5f 65 72 72 6e 6f 3b | 0d 0d 0d 0d 2f 2a 20 49 |m_errno;|..../* I|
|000005b0| 6e 69 74 69 61 6c 69 7a | 65 20 64 62 6d 20 73 79 |nitializ|e dbm sy|
|000005c0| 73 74 65 6d 2e 20 20 46 | 49 4c 45 20 69 73 20 61 |stem. F|ILE is a|
|000005d0| 20 70 6f 69 6e 74 65 72 | 20 74 6f 20 74 68 65 20 | pointer| to the |
|000005e0| 66 69 6c 65 20 6e 61 6d | 65 2e 20 20 49 66 20 74 |file nam|e. If t|
|000005f0| 68 65 20 66 69 6c 65 0d | 20 20 20 68 61 73 20 61 |he file.| has a|
|00000600| 20 73 69 7a 65 20 6f 66 | 20 7a 65 72 6f 20 62 79 | size of| zero by|
|00000610| 74 65 73 2c 20 61 20 66 | 69 6c 65 20 69 6e 69 74 |tes, a f|ile init|
|00000620| 69 61 6c 69 7a 61 74 69 | 6f 6e 20 70 72 6f 63 65 |ializati|on proce|
|00000630| 64 75 72 65 20 69 73 20 | 70 65 72 66 6f 72 6d 65 |dure is |performe|
|00000640| 64 2c 0d 20 20 20 73 65 | 74 74 69 6e 67 20 75 70 |d,. se|tting up|
|00000650| 20 74 68 65 20 69 6e 69 | 74 69 61 6c 20 73 74 72 | the ini|tial str|
|00000660| 75 63 74 75 72 65 20 69 | 6e 20 74 68 65 20 66 69 |ucture i|n the fi|
|00000670| 6c 65 2e 20 20 42 4c 4f | 43 4b 5f 53 49 5a 45 20 |le. BLO|CK_SIZE |
|00000680| 69 73 20 75 73 65 64 20 | 64 75 72 69 6e 67 0d 20 |is used |during. |
|00000690| 20 20 69 6e 69 74 69 61 | 6c 69 7a 61 74 69 6f 6e | initia|lization|
|000006a0| 20 74 6f 20 64 65 74 65 | 72 6d 69 6e 65 20 74 68 | to dete|rmine th|
|000006b0| 65 20 73 69 7a 65 20 6f | 66 20 76 61 72 69 6f 75 |e size o|f variou|
|000006c0| 73 20 63 6f 6e 73 74 72 | 75 63 74 73 2e 20 20 49 |s constr|ucts. I|
|000006d0| 66 20 74 68 65 20 76 61 | 6c 75 65 0d 20 20 20 69 |f the va|lue. i|
|000006e0| 73 20 6c 65 73 73 20 74 | 68 61 6e 20 35 31 32 2c |s less t|han 512,|
|000006f0| 20 74 68 65 20 66 69 6c | 65 20 73 79 73 74 65 6d | the fil|e system|
|00000700| 20 62 6c 6f 63 6b 73 69 | 7a 65 20 69 73 20 75 73 | blocksi|ze is us|
|00000710| 65 64 2c 20 6f 74 68 65 | 72 77 69 73 65 20 74 68 |ed, othe|rwise th|
|00000720| 65 20 76 61 6c 75 65 0d | 20 20 20 6f 66 20 42 4c |e value.| of BL|
|00000730| 4f 43 4b 5f 53 49 5a 45 | 20 69 73 20 75 73 65 64 |OCK_SIZE| is used|
|00000740| 2e 20 20 42 4c 4f 43 4b | 5f 53 49 5a 45 20 69 73 |. BLOCK|_SIZE is|
|00000750| 20 69 67 6e 6f 72 65 64 | 20 69 66 20 74 68 65 20 | ignored| if the |
|00000760| 66 69 6c 65 20 68 61 73 | 20 70 43 63 72 69 6f 75 |file has| pCcriou|
|00000770| 73 6c 79 0d 20 20 20 69 | 6e 69 74 69 61 6c 69 7a |sly. i|nitializ|
|00000780| 65 64 2e 20 20 49 66 20 | 52 45 41 44 5f 57 52 49 |ed. If |READ_WRI|
|00000790| 54 45 20 69 73 20 73 65 | 74 20 74 6f 20 47 44 42 |TE is se|t to GDB|
|000007a0| 4d 5f 52 45 41 44 20 74 | 68 65 20 75 73 65 72 20 |M_READ t|he user |
|000007b0| 77 61 6e 74 73 20 74 6f | 20 6a 75 73 74 0d 20 20 |wants to| just. |
|000007c0| 20 72 65 61 64 20 74 68 | 65 20 64 61 74 61 62 61 | read th|e databa|
|000007d0| 73 65 20 61 6e 64 20 61 | 6e 79 20 63 61 6c 6c 20 |se and a|ny call |
|000007e0| 74 6f 20 64 62 6d 5f 73 | 74 6f 72 65 20 6f 72 20 |to dbm_s|tore or |
|000007f0| 64 62 6d 5f 64 65 6c 65 | 74 65 20 77 69 6c 6c 20 |dbm_dele|te will |
|00000800| 66 61 69 6c 2e 20 4d 61 | 6e 79 0d 20 20 20 72 65 |fail. Ma|ny. re|
|00000810| 61 64 65 72 73 20 63 61 | 6e 20 61 63 63 65 73 73 |aders ca|n access|
|00000820| 20 74 68 65 20 64 61 74 | 61 62 61 73 65 20 61 74 | the dat|abase at|
|00000830| 20 74 68 65 20 73 61 6d | 65 20 74 69 6d 65 2e 20 | the sam|e time. |
|00000840| 20 49 66 20 52 45 41 44 | 5f 57 52 49 54 45 20 69 | If READ|_WRITE i|
|00000850| 73 20 73 65 74 20 74 6f | 0d 20 20 20 47 44 42 4d |s set to|. GDBM|
|00000860| 5f 57 52 49 54 45 2c 20 | 74 68 65 20 75 73 65 72 |_WRITE, |the user|
|00000870| 20 77 61 6e 74 73 20 62 | 6f 74 68 20 72 65 61 64 | wants b|oth read|
|00000880| 20 61 6e 64 20 77 72 69 | 74 65 20 61 63 63 65 73 | and wri|te acces|
|00000890| 73 20 74 6f 20 74 68 65 | 20 64 61 74 61 62 61 73 |s to the| databas|
|000008a0| 65 20 61 6e 64 0d 20 20 | 20 72 65 71 75 69 72 65 |e and. | require|
|000008b0| 73 20 65 78 63 6c 75 73 | 69 76 65 20 61 63 63 65 |s exclus|ive acce|
|000008c0| 73 73 2e 20 20 49 66 20 | 52 45 41 44 5f 57 52 49 |ss. If |READ_WRI|
|000008d0| 54 45 20 69 73 20 47 44 | 42 4d 5f 57 52 43 52 45 |TE is GD|BM_WRCRE|
|000008e0| 41 54 2c 20 74 68 65 20 | 75 73 65 72 20 77 61 6e |AT, the |user wan|
|000008f0| 74 73 0d 20 20 20 62 6f | 74 68 20 72 65 61 64 20 |ts. bo|th read |
|00000900| 61 6e 64 20 77 72 69 74 | 65 20 61 63 63 65 73 73 |and writ|e access|
|00000910| 20 74 6f 20 74 68 65 20 | 64 61 74 61 62 61 73 65 | to the |database|
|00000920| 20 61 6e 64 20 69 66 20 | 74 68 65 20 64 61 74 61 | and if |the data|
|00000930| 62 61 73 65 20 64 6f 65 | 73 20 6e 6f 74 0d 20 20 |base doe|s not. |
|00000940| 20 65 78 69 73 74 2c 20 | 63 72 65 61 74 65 20 61 | exist, |create a|
|00000950| 20 6e 65 77 20 6f 6e 65 | 2e 20 20 49 66 20 52 45 | new one|. If RE|
|00000960| 41 44 5f 57 52 49 54 45 | 20 69 73 20 47 44 42 4d |AD_WRITE| is GDBM|
|00000970| 5f 4e 45 57 44 42 2c 20 | 74 68 65 20 75 73 65 72 |_NEWDB, |the user|
|00000980| 20 77 61 6e 74 20 61 0d | 20 20 20 6e 65 77 20 64 | want a.| new d|
|00000990| 61 74 61 62 61 73 65 20 | 63 72 65 61 74 65 64 2c |atabase |created,|
|000009a0| 20 72 65 67 61 72 64 6c | 65 73 73 20 6f 66 20 77 | regardl|ess of w|
|000009b0| 68 65 74 68 65 72 20 6f | 6e 65 20 65 78 69 73 74 |hether o|ne exist|
|000009c0| 65 64 2c 20 61 6e 64 20 | 77 61 6e 74 73 20 72 65 |ed, and |wants re|
|000009d0| 61 64 0d 20 20 20 61 6e | 64 20 77 72 69 74 65 20 |ad. an|d write |
|000009e0| 61 63 63 65 73 73 20 74 | 6f 20 74 68 65 20 6e 65 |access t|o the ne|
|000009f0| 77 20 64 61 74 61 62 61 | 73 65 2e 20 20 41 6e 79 |w databa|se. Any|
|00000a00| 20 65 72 72 6f 72 20 64 | 65 74 65 63 74 65 64 20 | error d|etected |
|00000a10| 77 69 6c 6c 20 63 61 75 | 73 65 20 61 20 0d 20 20 |will cau|se a . |
|00000a20| 20 72 65 74 75 72 6e 20 | 76 61 6c 75 65 20 6f 66 | return |value of|
|00000a30| 20 6e 75 6c 6c 20 61 6e | 64 20 61 6e 20 61 70 70 | null an|d an app|
|00000a40| 72 6f 70 72 61 74 65 20 | 76 61 6c 75 65 20 77 69 |roprate |value wi|
|00000a50| 6c 6c 20 62 65 20 69 6e | 20 67 64 62 6d 5f 65 72 |ll be in| gdbm_er|
|00000a60| 72 6e 6f 2e 20 20 49 66 | 0d 20 20 20 6e 6f 20 65 |rno. If|. no e|
|00000a70| 72 72 6f 72 73 20 6f 63 | 63 75 72 2c 20 61 20 70 |rrors oc|cur, a p|
|00000a80| 6f 69 6e 74 65 72 20 74 | 6f 20 74 68 65 20 22 67 |ointer t|o the "g|
|00000a90| 64 62 6d 20 66 69 6c 65 | 20 64 65 73 63 72 69 70 |dbm file| descrip|
|00000aa0| 74 6f 72 22 20 77 69 6c | 6c 20 62 65 0d 20 20 20 |tor" wil|l be. |
|00000ab0| 72 65 74 75 72 6e 65 64 | 2e 20 2a 2f 0d 20 20 20 |returned|. */. |
|00000ac0| 0d 0d 67 64 62 6d 5f 66 | 69 6c 65 5f 69 6e 66 6f |..gdbm_f|ile_info|
|00000ad0| 20 2a 0d 67 64 62 6d 5f | 6f 70 65 6e 20 28 66 69 | *.gdbm_|open (fi|
|00000ae0| 6c 65 2c 20 62 6c 6f 63 | 6b 5f 73 69 7a 65 2c 20 |le, bloc|k_size, |
|00000af0| 72 65 61 64 5f 77 72 69 | 74 65 2c 20 6d 6f 64 65 |read_wri|te, mode|
|00000b00| 2c 20 66 61 74 61 6c 5f | 66 75 6e 63 29 0d 20 20 |, fatal_|func). |
|00000b10| 20 20 20 63 68 61 72 20 | 2a 66 69 6c 65 3b 0d 20 | char |*file;. |
|00000b20| 20 20 20 20 69 6e 74 20 | 20 62 6c 6f 63 6b 5f 73 | int | block_s|
|00000b30| 69 7a 65 3b 0d 20 20 20 | 20 20 69 6e 74 20 20 72 |ize;. | int r|
|00000b40| 65 61 64 5f 77 72 69 74 | 65 3b 0d 20 20 20 20 20 |ead_writ|e;. |
|00000b50| 69 6e 74 20 20 6d 6f 64 | 65 3b 0d 20 20 20 20 20 |int mod|e;. |
|00000b60| 76 6f 69 64 20 28 2a 66 | 61 74 61 6c 5f 66 75 6e |void (*f|atal_fun|
|00000b70| 63 29 20 28 29 3b 0d 7b | 0d 23 69 66 64 65 66 20 |c) ();.{|.#ifdef |
|00000b80| 6d 61 63 69 6e 74 6f 73 | 68 0d 23 70 72 61 67 6d |macintos|h.#pragm|
|00000b90| 61 20 75 6e 75 73 65 64 | 28 6d 6f 64 65 29 0d 23 |a unused|(mode).#|
|00000ba0| 65 6e 64 69 66 0d 20 20 | 67 64 62 6d 5f 66 69 6c |endif. |gdbm_fil|
|00000bb0| 65 5f 69 6e 66 6f 20 2a | 64 62 66 3b 09 09 2f 2a |e_info *|dbf;../*|
|00000bc0| 20 54 68 65 20 72 65 63 | 6f 72 64 20 74 6f 20 72 | The rec|ord to r|
|00000bd0| 65 74 75 72 6e 2e 20 2a | 2f 0d 20 20 73 74 72 75 |eturn. *|/. stru|
|00000be0| 63 74 20 73 74 61 74 20 | 66 69 6c 65 5f 73 74 61 |ct stat |file_sta|
|00000bf0| 74 3b 09 2f 2a 20 53 70 | 61 63 65 20 66 6f 72 20 |t;./* Sp|ace for |
|00000c00| 74 68 65 20 73 74 61 74 | 20 69 6e 66 6f 72 6d 61 |the stat| informa|
|00000c10| 74 69 6f 6e 2e 20 2a 2f | 0d 20 20 69 6e 74 20 20 |tion. */|. int |
|00000c20| 20 20 20 20 20 20 20 6c | 65 6e 3b 09 09 2f 2a 20 | l|en;../* |
|00000c30| 4c 65 6e 67 74 68 20 6f | 66 20 74 68 65 20 66 69 |Length o|f the fi|
|00000c40| 6c 65 20 6e 61 6d 65 2e | 20 2a 2f 0d 20 20 69 6e |le name.| */. in|
|00000c50| 74 20 20 20 20 20 20 20 | 20 20 6e 75 6d 5f 62 79 |t | num_by|
|00000c60| 74 65 73 3b 09 2f 2a 20 | 55 73 65 64 20 69 6e 20 |tes;./* |Used in |
|00000c70| 72 65 61 64 69 6e 67 20 | 61 6e 64 20 77 72 69 74 |reading |and writ|
|00000c80| 69 6e 67 2e 20 2a 2f 0d | 20 20 6c 6f 6e 67 20 20 |ing. */.| long |
|00000c90| 20 20 20 20 20 20 66 69 | 6c 65 5f 70 6f 73 3b 09 | fi|le_pos;.|
|00000ca0| 09 2f 2a 20 55 73 65 64 | 20 77 69 74 68 20 73 65 |./* Used| with se|
|00000cb0| 65 6b 73 2e 20 2a 2f 0d | 20 20 69 6e 74 09 20 20 |eks. */.| int. |
|00000cc0| 20 20 20 20 6c 6f 63 6b | 5f 76 61 6c 3b 20 20 20 | lock|_val; |
|00000cd0| 20 20 20 20 20 20 2f 2a | 20 52 65 74 75 72 6e 65 | /*| Returne|
|00000ce0| 64 20 62 79 20 74 68 65 | 20 66 6c 6f 63 6b 20 63 |d by the| flock c|
|00000cf0| 61 6c 6c 2e 20 2a 2f 0d | 20 20 69 6e 74 09 20 20 |all. */.| int. |
|00000d00| 20 20 20 20 66 69 6c 65 | 5f 62 6c 6f 63 6b 5f 73 | file|_block_s|
|00000d10| 69 7a 65 3b 09 2f 2a 20 | 42 6c 6f 63 6b 20 73 69 |ize;./* |Block si|
|00000d20| 7a 65 20 74 6f 20 75 73 | 65 20 66 6f 72 20 61 20 |ze to us|e for a |
|00000d30| 6e 65 77 20 66 69 6c 65 | 2e 20 2a 2f 0d 20 20 69 |new file|. */. i|
|00000d40| 6e 74 20 09 20 20 20 20 | 20 20 69 6e 64 65 78 3b |nt . | index;|
|00000d50| 09 09 2f 2a 20 55 73 65 | 64 20 61 73 20 61 20 6c |../* Use|d as a l|
|00000d60| 6f 6f 70 20 69 6e 64 65 | 78 2e 20 2a 2f 0d 20 20 |oop inde|x. */. |
|00000d70| 63 68 61 72 20 20 20 20 | 20 20 20 20 6e 65 65 64 |char | need|
|00000d80| 5f 74 72 75 6e 63 3b 09 | 2f 2a 20 55 73 65 64 20 |_trunc;.|/* Used |
|00000d90| 77 69 74 68 20 47 44 42 | 4d 5f 4e 45 57 44 42 20 |with GDB|M_NEWDB |
|00000da0| 61 6e 64 20 6c 6f 63 6b | 69 6e 67 20 74 6f 20 61 |and lock|ing to a|
|00000db0| 76 6f 69 64 0d 09 09 09 | 09 20 20 20 74 72 75 6e |void....|. trun|
|00000dc0| 63 61 74 69 6e 67 20 61 | 20 66 69 6c 65 20 66 72 |cating a| file fr|
|00000dd0| 6f 6d 20 75 6e 64 65 72 | 20 61 20 72 65 61 64 65 |om under| a reade|
|00000de0| 72 2e 20 2a 2f 0d 0d 20 | 20 2f 2a 20 41 6c 6c 6f |r. */.. | /* Allo|
|00000df0| 63 61 74 65 20 6e 65 77 | 20 69 6e 66 6f 20 73 74 |cate new| info st|
|00000e00| 72 75 63 74 75 72 65 2e | 20 2a 2f 0d 20 20 64 62 |ructure.| */. db|
|00000e10| 66 20 3d 20 28 67 64 62 | 6d 5f 66 69 6c 65 5f 69 |f = (gdb|m_file_i|
|00000e20| 6e 66 6f 20 2a 29 20 6d | 61 6c 6c 6f 63 20 28 73 |nfo *) m|alloc (s|
|00000e30| 69 7a 65 6f 66 20 28 67 | 64 62 6d 5f 66 69 6c 65 |izeof (g|dbm_file|
|00000e40| 5f 69 6e 66 6f 29 29 3b | 0d 20 20 69 66 20 28 64 |_info));|. if (d|
|00000e50| 62 66 20 3d 3d 20 4e 55 | 4c 4c 29 0d 20 20 20 20 |bf == NU|LL). |
|00000e60| 7b 0d 20 20 20 20 20 20 | 67 64 62 6d 5f 65 72 72 |{. |gdbm_err|
|00000e70| 6e 6f 20 3d 20 47 44 42 | 4d 5f 4d 41 4c 4c 4f 43 |no = GDB|M_MALLOC|
|00000e80| 5f 45 52 52 4f 52 3b 0d | 20 20 20 20 20 20 72 65 |_ERROR;.| re|
|00000e90| 74 75 72 6e 20 4e 55 4c | 4c 3b 0d 20 20 20 20 7d |turn NUL|L;. }|
|00000ea0| 0d 0d 20 20 2f 2a 20 49 | 6e 69 74 69 61 6c 69 7a |.. /* I|nitializ|
|00000eb0| 65 20 73 6f 6d 65 20 66 | 69 65 6c 64 73 20 66 6f |e some f|ields fo|
|00000ec0| 72 20 6b 6e 6f 77 6e 20 | 76 61 6c 75 65 73 2e 20 |r known |values. |
|00000ed0| 20 54 68 69 73 20 69 73 | 20 64 6f 6e 65 20 73 6f | This is| done so|
|00000ee0| 20 67 64 62 6d 5f 63 6c | 6f 73 65 0d 20 20 20 20 | gdbm_cl|ose. |
|00000ef0| 20 77 69 6c 6c 20 77 6f | 72 6b 20 69 66 20 63 61 | will wo|rk if ca|
|00000f00| 6c 6c 65 64 20 62 65 66 | 6f 72 65 20 61 6c 6c 6f |lled bef|ore allo|
|00000f10| 63 61 74 69 6e 67 20 73 | 6f 6d 65 20 73 74 72 75 |cating s|ome stru|
|00000f20| 63 74 75 72 65 73 2e 20 | 2a 2f 0d 20 20 64 62 66 |ctures. |*/. dbf|
|00000f30| 2d 3e 64 69 72 20 20 3d | 20 4e 55 4c 4c 3b 0d 20 |->dir =| NULL;. |
|00000f40| 20 64 62 66 2d 3e 62 75 | 63 6b 65 74 20 3d 20 4e | dbf->bu|cket = N|
|00000f50| 55 4c 4c 3b 0d 20 20 66 | 6f 72 20 28 69 6e 64 65 |ULL;. f|or (inde|
|00000f60| 78 20 3d 20 30 3b 20 69 | 6e 64 65 78 20 3c 20 43 |x = 0; i|ndex < C|
|00000f70| 41 43 48 45 5f 53 49 5a | 45 3b 20 69 6e 64 65 78 |ACHE_SIZ|E; index|
|00000f80| 2b 2b 29 0d 20 20 20 20 | 7b 0d 20 20 20 20 20 20 |++). |{. |
|00000f90| 64 62 66 2d 3e 62 75 63 | 6b 65 74 5f 63 61 63 68 |dbf->buc|ket_cach|
|00000fa0| 65 5b 69 6e 64 65 78 5d | 2e 63 61 5f 62 75 63 6b |e[index]|.ca_buck|
|00000fb0| 65 74 20 3d 20 4e 55 4c | 4c 3b 0d 20 20 20 20 20 |et = NUL|L;. |
|00000fc0| 20 64 62 66 2d 3e 62 75 | 63 6b 65 74 5f 63 61 63 | dbf->bu|cket_cac|
|00000fd0| 68 65 5b 69 6e 64 65 78 | 5d 2e 63 61 5f 64 61 74 |he[index|].ca_dat|
|00000fe0| 61 2e 64 70 74 72 20 3d | 20 4e 55 4c 4c 3b 0d 20 |a.dptr =| NULL;. |
|00000ff0| 20 20 20 7d 0d 20 20 0d | 20 20 2f 2a 20 53 61 76 | }. .| /* Sav|
|00001000| 65 20 6e 61 6d 65 20 6f | 66 20 66 69 6c 65 2e 20 |e name o|f file. |
|00001010| 2a 2f 0d 20 20 6c 65 6e | 20 3d 20 73 74 72 6c 65 |*/. len| = strle|
|00001020| 6e 20 28 66 69 6c 65 29 | 3b 0d 20 20 64 62 66 2d |n (file)|;. dbf-|
|00001030| 3e 6e 61 6d 65 20 3d 20 | 28 63 68 61 72 20 2a 29 |>name = |(char *)|
|00001040| 20 6d 61 6c 6c 6f 63 20 | 28 6c 65 6e 20 2b 20 31 | malloc |(len + 1|
|00001050| 29 3b 0d 20 20 69 66 20 | 28 64 62 66 2d 3e 6e 61 |);. if |(dbf->na|
|00001060| 6d 65 20 3d 3d 20 4e 55 | 4c 4c 29 0d 20 20 20 20 |me == NU|LL). |
|00001070| 7b 0d 20 20 20 20 20 20 | 66 72 65 65 20 28 64 62 |{. |free (db|
|00001080| 66 29 3b 0d 20 20 20 20 | 20 20 67 64 62 6d 5f 65 |f);. | gdbm_e|
|00001090| 72 72 6e 6f 20 3d 20 47 | 44 42 4d 5f 4d 41 4c 4c |rrno = G|DBM_MALL|
|000010a0| 4f 43 5f 45 52 52 4f 52 | 3b 0d 20 20 20 20 20 20 |OC_ERROR|;. |
|000010b0| 72 65 74 75 72 6e 20 4e | 55 4c 4c 3b 0d 20 20 20 |return N|ULL;. |
|000010c0| 20 7d 0d 20 20 73 74 72 | 63 70 79 20 28 64 62 66 | }. str|cpy (dbf|
|000010d0| 2d 3e 6e 61 6d 65 2c 20 | 66 69 6c 65 29 3b 0d 0d |->name, |file);..|
|000010e0| 20 20 2f 2a 20 49 6e 69 | 74 69 61 6c 69 7a 65 20 | /* Ini|tialize |
|000010f0| 74 68 65 20 66 61 74 61 | 6c 20 65 72 72 6f 72 20 |the fata|l error |
|00001100| 72 6f 75 74 69 6e 65 2e | 20 2a 2f 0d 20 20 64 62 |routine.| */. db|
|00001110| 66 2d 3e 66 61 74 61 6c | 5f 65 72 72 20 3d 20 66 |f->fatal|_err = f|
|00001120| 61 74 61 6c 5f 66 75 6e | 63 3b 0d 0d 20 20 2f 2a |atal_fun|c;.. /*|
|00001130| 20 4f 70 65 6e 20 74 68 | 65 20 66 69 6c 65 2e 20 | Open th|e file. |
|00001140| 2a 2f 0d 20 20 6e 65 65 | 64 5f 74 72 75 6e 63 20 |*/. nee|d_trunc |
|00001150| 3d 20 46 41 4c 53 45 3b | 0d 20 20 69 66 20 28 72 |= FALSE;|. if (r|
|00001160| 65 61 64 5f 77 72 69 74 | 65 20 3d 3d 20 47 44 42 |ead_writ|e == GDB|
|00001170| 4d 5f 52 45 41 44 45 52 | 29 0d 20 20 20 20 7b 0d |M_READER|). {.|
|00001180| 20 20 20 20 20 20 64 62 | 66 2d 3e 64 65 73 63 20 | db|f->desc |
|00001190| 3d 20 4f 50 45 4e 28 64 | 62 66 2d 3e 6e 61 6d 65 |= OPEN(d|bf->name|
|000011a0| 2c 20 4f 5f 52 44 4f 4e | 4c 59 2c 20 30 29 3b 0d |, O_RDON|LY, 0);.|
|000011b0| 20 20 20 20 7d 0d 20 20 | 65 6c 73 65 20 69 66 20 | }. |else if |
|000011c0| 28 72 65 61 64 5f 77 72 | 69 74 65 20 3d 3d 20 47 |(read_wr|ite == G|
|000011d0| 44 42 4d 5f 57 52 49 54 | 45 52 29 0d 20 20 20 20 |DBM_WRIT|ER). |
|000011e0| 7b 0d 20 20 20 20 20 20 | 64 62 66 2d 3e 64 65 73 |{. |dbf->des|
|000011f0| 63 20 3d 20 4f 50 45 4e | 28 64 62 66 2d 3e 6e 61 |c = OPEN|(dbf->na|
|00001200| 6d 65 2c 20 4f 5f 52 44 | 57 52 2c 20 30 29 3b 0d |me, O_RD|WR, 0);.|
|00001210| 20 20 20 20 7d 0d 20 20 | 65 6c 73 65 20 69 66 20 | }. |else if |
|00001220| 28 72 65 61 64 5f 77 72 | 69 74 65 20 3d 3d 20 47 |(read_wr|ite == G|
|00001230| 44 42 4d 5f 4e 45 57 44 | 42 29 0d 20 20 20 20 7b |DBM_NEWD|B). {|
|00001240| 0d 20 20 20 20 20 20 64 | 62 66 2d 3e 64 65 73 63 |. d|bf->desc|
|00001250| 20 3d 20 4f 50 45 4e 28 | 64 62 66 2d 3e 6e 61 6d | = OPEN(|dbf->nam|
|00001260| 65 2c 20 4f 5f 52 44 57 | 52 7c 4f 5f 43 52 45 41 |e, O_RDW|R|O_CREA|
|00001270| 54 2c 20 6d 6f 64 65 29 | 3b 0d 20 20 20 20 20 20 |T, mode)|;. |
|00001280| 72 65 61 64 5f 77 72 69 | 74 65 20 3d 20 47 44 42 |read_wri|te = GDB|
|00001290| 4d 5f 57 52 49 54 45 52 | 3b 0d 20 20 20 20 20 20 |M_WRITER|;. |
|000012a0| 6e 65 65 64 5f 74 72 75 | 6e 63 20 3d 20 54 52 55 |need_tru|nc = TRU|
|000012b0| 45 3b 0d 20 20 20 20 7d | 0d 20 20 65 6c 73 65 0d |E;. }|. else.|
|000012c0| 20 20 20 20 7b 0d 20 20 | 20 20 20 20 64 62 66 2d | {. | dbf-|
|000012d0| 3e 64 65 73 63 20 3d 20 | 4f 50 45 4e 28 64 62 66 |>desc = |OPEN(dbf|
|000012e0| 2d 3e 6e 61 6d 65 2c 20 | 4f 5f 52 44 57 52 7c 4f |->name, |O_RDWR|O|
|000012f0| 5f 43 52 45 41 54 2c 20 | 6d 6f 64 65 29 3b 0d 20 |_CREAT, |mode);. |
|00001300| 20 20 20 20 20 72 65 61 | 64 5f 77 72 69 74 65 20 | rea|d_write |
|00001310| 3d 20 47 44 42 4d 5f 57 | 52 49 54 45 52 3b 0d 20 |= GDBM_W|RITER;. |
|00001320| 20 20 20 7d 0d 20 20 69 | 66 20 28 64 62 66 2d 3e | }. i|f (dbf->|
|00001330| 64 65 73 63 20 3c 20 30 | 29 0d 20 20 20 20 7b 0d |desc < 0|). {.|
|00001340| 20 20 20 20 20 20 66 72 | 65 65 20 28 64 62 66 2d | fr|ee (dbf-|
|00001350| 3e 6e 61 6d 65 29 3b 0d | 20 20 20 20 20 20 66 72 |>name);.| fr|
|00001360| 65 65 20 28 64 62 66 29 | 3b 0d 20 20 20 20 20 20 |ee (dbf)|;. |
|00001370| 67 64 62 6d 5f 65 72 72 | 6e 6f 20 3d 20 47 44 42 |gdbm_err|no = GDB|
|00001380| 4d 5f 46 49 4c 45 5f 4f | 50 45 4e 5f 45 52 52 4f |M_FILE_O|PEN_ERRO|
|00001390| 52 3b 0d 20 20 20 20 20 | 20 72 65 74 75 72 6e 20 |R;. | return |
|000013a0| 4e 55 4c 4c 3b 0d 20 20 | 20 20 7d 0d 0d 20 20 2f |NULL;. | }.. /|
|000013b0| 2a 20 47 65 74 20 74 68 | 65 20 73 74 61 74 75 73 |* Get th|e status|
|000013c0| 20 6f 66 20 74 68 65 20 | 66 69 6c 65 2e 20 2a 2f | of the |file. */|
|000013d0| 0d 20 20 66 73 74 61 74 | 20 28 64 62 66 2d 3e 64 |. fstat| (dbf->d|
|000013e0| 65 73 63 2c 20 26 66 69 | 6c 65 5f 73 74 61 74 29 |esc, &fi|le_stat)|
|000013f0| 3b 0d 0d 20 20 2f 2a 20 | 4c 6f 63 6b 20 74 68 65 |;.. /* |Lock the|
|00001400| 20 66 69 6c 65 20 69 6e | 20 74 68 65 20 61 70 70 | file in| the app|
|00001410| 72 6f 70 72 61 74 65 20 | 77 61 79 2e 20 2a 2f 0d |roprate |way. */.|
|00001420| 20 20 69 66 20 28 72 65 | 61 64 5f 77 72 69 74 65 | if (re|ad_write|
|00001430| 20 3d 3d 20 47 44 42 4d | 5f 52 45 41 44 45 52 29 | == GDBM|_READER)|
|00001440| 0d 20 20 20 20 7b 0d 20 | 20 20 20 20 20 69 66 20 |. {. | if |
|00001450| 28 66 69 6c 65 5f 73 74 | 61 74 2e 73 74 5f 73 69 |(file_st|at.st_si|
|00001460| 7a 65 20 3d 3d 20 30 29 | 0d 09 7b 0d 09 20 20 63 |ze == 0)|..{.. c|
|00001470| 6c 6f 73 65 20 28 64 62 | 66 2d 3e 64 65 73 63 29 |lose (db|f->desc)|
|00001480| 3b 0d 09 20 20 66 72 65 | 65 20 28 64 62 66 2d 3e |;.. fre|e (dbf->|
|00001490| 6e 61 6d 65 29 3b 0d 09 | 20 20 66 72 65 65 20 28 |name);..| free (|
|000014a0| 64 62 66 29 3b 0d 09 20 | 20 67 64 62 6d 5f 65 72 |dbf);.. | gdbm_er|
|000014b0| 72 6e 6f 20 3d 20 47 44 | 42 4d 5f 45 4d 50 54 59 |rno = GD|BM_EMPTY|
|000014c0| 5f 44 41 54 41 42 41 53 | 45 3b 0d 09 20 20 72 65 |_DATABAS|E;.. re|
|000014d0| 74 75 72 6e 20 4e 55 4c | 4c 3b 0d 09 7d 0d 20 20 |turn NUL|L;..}. |
|000014e0| 20 20 20 20 2f 2a 20 53 | 65 74 73 20 6c 6f 63 6b | /* S|ets lock|
|000014f0| 5f 76 61 6c 20 74 6f 20 | 30 20 66 6f 72 20 73 75 |_val to |0 for su|
|00001500| 63 63 65 73 73 2e 20 20 | 53 65 65 20 73 79 73 74 |ccess. |See syst|
|00001510| 65 6d 73 2e 68 2e 20 2a | 2f 0d 20 20 20 20 20 20 |ems.h. *|/. |
|00001520| 52 45 41 44 4c 4f 43 4b | 5f 46 49 4c 45 28 64 62 |READLOCK|_FILE(db|
|00001530| 66 29 3b 0d 20 20 20 20 | 7d 0d 20 20 65 6c 73 65 |f);. |}. else|
|00001540| 0d 20 20 20 20 7b 0d 20 | 20 20 20 20 20 2f 2a 20 |. {. | /* |
|00001550| 53 65 74 73 20 6c 6f 63 | 6b 5f 76 61 6c 20 74 6f |Sets loc|k_val to|
|00001560| 20 30 20 66 6f 72 20 73 | 75 63 63 65 73 73 2e 20 | 0 for s|uccess. |
|00001570| 20 53 65 65 20 73 79 73 | 74 65 6d 73 2e 68 2e 20 | See sys|tems.h. |
|00001580| 2a 2f 0d 20 20 20 20 20 | 20 57 52 49 54 45 4c 4f |*/. | WRITELO|
|00001590| 43 4b 5f 46 49 4c 45 28 | 64 62 66 29 3b 0d 20 20 |CK_FILE(|dbf);. |
|000015a0| 20 20 7d 0d 20 20 69 66 | 20 28 6c 6f 63 6b 5f 76 | }. if| (lock_v|
|000015b0| 61 6c 20 21 3d 20 30 29 | 0d 20 20 20 20 7b 0d 20 |al != 0)|. {. |
|000015c0| 20 20 20 20 20 63 6c 6f | 73 65 20 28 64 62 66 2d | clo|se (dbf-|
|000015d0| 3e 64 65 73 63 29 3b 0d | 20 20 20 20 20 20 66 72 |>desc);.| fr|
|000015e0| 65 65 20 28 64 62 66 2d | 3e 6e 61 6d 65 29 3b 0d |ee (dbf-|>name);.|
|000015f0| 20 20 20 20 20 20 66 72 | 65 65 20 28 64 62 66 29 | fr|ee (dbf)|
|00001600| 3b 0d 20 20 20 20 20 20 | 69 66 20 28 72 65 61 64 |;. |if (read|
|00001610| 5f 77 72 69 74 65 20 3d | 3d 20 47 44 42 4d 5f 52 |_write =|= GDBM_R|
|00001620| 45 41 44 45 52 29 0d 09 | 67 64 62 6d 5f 65 72 72 |EADER)..|gdbm_err|
|00001630| 6e 6f 20 3d 20 47 44 42 | 4d 5f 43 41 4e 54 5f 42 |no = GDB|M_CANT_B|
|00001640| 45 5f 52 45 41 44 45 52 | 3b 0d 20 20 20 20 20 20 |E_READER|;. |
|00001650| 65 6c 73 65 0d 09 67 64 | 62 6d 5f 65 72 72 6e 6f |else..gd|bm_errno|
|00001660| 20 3d 20 47 44 42 4d 5f | 43 41 4e 54 5f 42 45 5f | = GDBM_|CANT_BE_|
|00001670| 57 52 49 54 45 52 3b 0d | 20 20 20 20 20 20 72 65 |WRITER;.| re|
|00001680| 74 75 72 6e 20 4e 55 4c | 4c 3b 0d 20 20 20 20 7d |turn NUL|L;. }|
|00001690| 0d 0d 20 20 2f 2a 20 52 | 65 63 6f 72 64 20 74 68 |.. /* R|ecord th|
|000016a0| 65 20 6b 69 6e 64 20 6f | 66 20 75 73 65 72 2e 20 |e kind o|f user. |
|000016b0| 2a 2f 0d 20 20 64 62 66 | 2d 3e 72 65 61 64 5f 77 |*/. dbf|->read_w|
|000016c0| 72 69 74 65 20 3d 20 72 | 65 61 64 5f 77 72 69 74 |rite = r|ead_writ|
|000016d0| 65 3b 0d 0d 20 20 2f 2a | 20 49 66 20 77 65 20 64 |e;.. /*| If we d|
|000016e0| 6f 20 68 61 76 65 20 61 | 20 77 72 69 74 65 20 6c |o have a| write l|
|000016f0| 6f 63 6b 20 61 6e 64 20 | 69 74 20 77 61 73 20 61 |ock and |it was a|
|00001700| 20 47 44 42 4d 5f 4e 45 | 57 44 42 2c 20 69 74 20 | GDBM_NE|WDB, it |
|00001710| 69 73 20 0d 20 20 20 20 | 20 6e 6f 77 20 74 69 6d |is . | now tim|
|00001720| 65 20 74 6f 20 74 72 75 | 6e 63 61 74 65 20 74 68 |e to tru|ncate th|
|00001730| 65 20 66 69 6c 65 2e 20 | 2a 2f 0d 20 20 69 66 20 |e file. |*/. if |
|00001740| 28 6e 65 65 64 5f 74 72 | 75 6e 63 20 26 26 20 66 |(need_tr|unc && f|
|00001750| 69 6c 65 5f 73 74 61 74 | 2e 73 74 5f 73 69 7a 65 |ile_stat|.st_size|
|00001760| 20 21 3d 20 30 29 0d 20 | 20 20 20 7b 0d 20 20 20 | != 0). | {. |
|00001770| 20 20 20 54 52 55 4e 43 | 41 54 45 20 28 64 62 66 | TRUNC|ATE (dbf|
|00001780| 29 3b 0d 20 20 20 20 20 | 20 66 73 74 61 74 20 28 |);. | fstat (|
|00001790| 64 62 66 2d 3e 64 65 73 | 63 2c 20 26 66 69 6c 65 |dbf->des|c, &file|
|000017a0| 5f 73 74 61 74 29 3b 0d | 20 20 20 20 7d 0d 0d 20 |_stat);.| }.. |
|000017b0| 20 2f 2a 20 44 65 63 69 | 64 65 20 69 66 20 74 68 | /* Deci|de if th|
|000017c0| 69 73 20 69 73 20 61 20 | 6e 65 77 20 66 69 6c 65 |is is a |new file|
|000017d0| 20 6f 72 20 61 6e 20 6f | 6c 64 20 66 69 6c 65 2e | or an o|ld file.|
|000017e0| 20 2a 2f 0d 20 20 69 66 | 20 28 66 69 6c 65 5f 73 | */. if| (file_s|
|000017f0| 74 61 74 2e 73 74 5f 73 | 69 7a 65 20 3d 3d 20 30 |tat.st_s|ize == 0|
|00001800| 29 0d 20 20 20 20 7b 0d | 0d 20 20 20 20 20 20 2f |). {.|. /|
|00001810| 2a 20 54 68 69 73 20 69 | 73 20 61 20 6e 65 77 20 |* This i|s a new |
|00001820| 66 69 6c 65 2e 20 20 43 | 72 65 61 74 65 20 61 6e |file. C|reate an|
|00001830| 20 65 6d 70 74 79 20 64 | 61 74 61 62 61 73 65 2e | empty d|atabase.|
|00001840| 20 20 2a 2f 0d 0d 20 20 | 20 20 20 20 2f 2a 20 53 | */.. | /* S|
|00001850| 74 61 72 74 20 77 69 74 | 68 20 74 68 65 20 62 6c |tart wit|h the bl|
|00001860| 6f 63 6b 73 69 7a 65 2e | 20 2a 2f 0d 20 20 20 20 |ocksize.| */. |
|00001870| 20 20 69 66 20 28 62 6c | 6f 63 6b 5f 73 69 7a 65 | if (bl|ock_size|
|00001880| 20 3c 20 35 31 32 29 0d | 09 66 69 6c 65 5f 62 6c | < 512).|.file_bl|
|00001890| 6f 63 6b 5f 73 69 7a 65 | 20 3d 20 53 54 41 54 42 |ock_size| = STATB|
|000018a0| 4c 4b 53 49 5a 45 3b 0d | 20 20 20 20 20 20 65 6c |LKSIZE;.| el|
|000018b0| 73 65 0d 09 66 69 6c 65 | 5f 62 6c 6f 63 6b 5f 73 |se..file|_block_s|
|000018c0| 69 7a 65 20 3d 20 62 6c | 6f 63 6b 5f 73 69 7a 65 |ize = bl|ock_size|
|000018d0| 3b 0d 0d 20 20 20 20 20 | 20 2f 2a 20 47 65 74 20 |;.. | /* Get |
|000018e0| 73 70 61 63 65 20 66 6f | 72 20 74 68 65 20 66 69 |space fo|r the fi|
|000018f0| 6c 65 20 68 65 61 64 65 | 72 2e 20 2a 2f 0d 20 20 |le heade|r. */. |
|00001900| 20 20 20 20 64 62 66 2d | 3e 68 65 61 64 65 72 20 | dbf-|>header |
|00001910| 3d 20 28 67 64 62 6d 5f | 66 69 6c 65 5f 68 65 61 |= (gdbm_|file_hea|
|00001920| 64 65 72 20 2a 29 20 6d | 61 6c 6c 6f 63 20 28 66 |der *) m|alloc (f|
|00001930| 69 6c 65 5f 62 6c 6f 63 | 6b 5f 73 69 7a 65 29 3b |ile_bloc|k_size);|
|00001940| 0d 20 20 20 20 20 20 69 | 66 20 28 64 62 66 2d 3e |. i|f (dbf->|
|00001950| 68 65 61 64 65 72 20 3d | 3d 20 4e 55 4c 4c 29 0d |header =|= NULL).|
|00001960| 09 7b 0d 09 20 20 67 64 | 62 6d 5f 63 6c 6f 73 65 |.{.. gd|bm_close|
|00001970| 20 28 64 62 66 29 3b 0d | 09 20 20 67 64 62 6d 5f | (dbf);.|. gdbm_|
|00001980| 65 72 72 6e 6f 20 3d 20 | 47 44 42 4d 5f 4d 41 4c |errno = |GDBM_MAL|
|00001990| 4c 4f 43 5f 45 52 52 4f | 52 3b 0d 09 20 20 72 65 |LOC_ERRO|R;.. re|
|000019a0| 74 75 72 6e 20 4e 55 4c | 4c 3b 0d 09 7d 0d 0d 20 |turn NUL|L;..}.. |
|000019b0| 20 20 20 20 20 2f 2a 20 | 53 65 74 20 74 68 65 20 | /* |Set the |
|000019c0| 6d 61 67 69 63 20 6e 75 | 6d 62 65 72 20 61 6e 64 |magic nu|mber and|
|000019d0| 20 74 68 65 20 62 6c 6f | 63 6b 5f 73 69 7a 65 2e | the blo|ck_size.|
|000019e0| 20 2a 2f 0d 20 20 20 20 | 20 20 64 62 66 2d 3e 68 | */. | dbf->h|
|000019f0| 65 61 64 65 72 2d 3e 68 | 65 61 64 65 72 5f 6d 61 |eader->h|eader_ma|
|00001a00| 67 69 63 20 3d 20 30 78 | 31 33 35 37 39 61 63 65 |gic = 0x|13579ace|
|00001a10| 3b 0d 20 20 20 20 20 20 | 64 62 66 2d 3e 68 65 61 |;. |dbf->hea|
|00001a20| 64 65 72 2d 3e 62 6c 6f | 63 6b 5f 73 69 7a 65 20 |der->blo|ck_size |
|00001a30| 3d 20 66 69 6c 65 5f 62 | 6c 6f 63 6b 5f 73 69 7a |= file_b|lock_siz|
|00001a40| 65 3b 0d 20 20 20 20 20 | 0d 20 20 20 20 20 20 2f |e;. |. /|
|00001a50| 2a 20 43 72 65 61 74 65 | 20 74 68 65 20 69 6e 69 |* Create| the ini|
|00001a60| 74 69 61 6c 20 68 61 73 | 68 20 74 61 62 6c 65 20 |tial has|h table |
|00001a70| 64 69 72 65 63 74 6f 72 | 79 2e 20 20 2a 2f 0d 20 |director|y. */. |
|00001a80| 20 20 20 20 20 64 62 66 | 2d 3e 68 65 61 64 65 72 | dbf|->header|
|00001a90| 2d 3e 64 69 72 5f 73 69 | 7a 65 20 3d 20 38 20 2a |->dir_si|ze = 8 *|
|00001aa0| 20 73 69 7a 65 6f 66 20 | 28 69 6e 74 29 3b 0d 20 | sizeof |(int);. |
|00001ab0| 20 20 20 20 20 64 62 66 | 2d 3e 68 65 61 64 65 72 | dbf|->header|
|00001ac0| 2d 3e 64 69 72 5f 62 69 | 74 73 20 3d 20 33 3b 0d |->dir_bi|ts = 3;.|
|00001ad0| 20 20 20 20 20 20 77 68 | 69 6c 65 20 28 64 62 66 | wh|ile (dbf|
|00001ae0| 2d 3e 68 65 61 64 65 72 | 2d 3e 64 69 72 5f 73 69 |->header|->dir_si|
|00001af0| 7a 65 20 3c 20 64 62 66 | 2d 3e 68 65 61 64 65 72 |ze < dbf|->header|
|00001b00| 2d 3e 62 6c 6f 63 6b 5f | 73 69 7a 65 29 0d 09 7b |->block_|size)..{|
|00001b10| 0d 09 20 20 64 62 66 2d | 3e 68 65 61 64 65 72 2d |.. dbf-|>header-|
|00001b20| 3e 64 69 72 5f 73 69 7a | 65 20 3c 3c 3d 20 31 3b |>dir_siz|e <<= 1;|
|00001b30| 0d 09 20 20 64 62 66 2d | 3e 68 65 61 64 65 72 2d |.. dbf-|>header-|
|00001b40| 3e 64 69 72 5f 62 69 74 | 73 20 2b 3d 20 31 3b 0d |>dir_bit|s += 1;.|
|00001b50| 09 7d 0d 0d 20 20 20 20 | 20 20 2f 2a 20 43 68 65 |.}.. | /* Che|
|00001b60| 63 6b 20 66 6f 72 20 63 | 6f 72 72 65 63 74 20 62 |ck for c|orrect b|
|00001b70| 6c 6f 63 6b 5f 73 69 7a | 65 2e 20 2a 2f 0d 20 20 |lock_siz|e. */. |
|00001b80| 20 20 20 20 69 66 20 28 | 64 62 66 2d 3e 68 65 61 | if (|dbf->hea|
|00001b90| 64 65 72 2d 3e 64 69 72 | 5f 73 69 7a 65 20 21 3d |der->dir|_size !=|
|00001ba0| 20 64 62 66 2d 3e 68 65 | 61 64 65 72 2d 3e 62 6c | dbf->he|ader->bl|
|00001bb0| 6f 63 6b 5f 73 69 7a 65 | 29 0d 09 7b 0d 09 20 20 |ock_size|)..{.. |
|00001bc0| 67 64 62 6d 5f 63 6c 6f | 73 65 20 28 64 62 66 29 |gdbm_clo|se (dbf)|
|00001bd0| 3b 0d 09 20 20 67 64 62 | 6d 5f 65 72 72 6e 6f 20 |;.. gdb|m_errno |
|00001be0| 3d 20 47 44 42 4d 5f 42 | 4c 4f 43 4b 5f 53 49 5a |= GDBM_B|LOCK_SIZ|
|00001bf0| 45 5f 45 52 52 4f 52 3b | 0d 09 20 20 72 65 74 75 |E_ERROR;|.. retu|
|00001c00| 72 6e 20 4e 55 4c 4c 3b | 0d 09 7d 0d 0d 20 20 20 |rn NULL;|..}.. |
|00001c10| 20 20 20 2f 2a 20 41 6c | 6c 6f 63 61 74 65 20 74 | /* Al|locate t|
|00001c20| 68 65 20 73 70 61 63 65 | 20 66 6f 72 20 74 68 65 |he space| for the|
|00001c30| 20 64 69 72 65 63 74 6f | 72 79 2e 20 2a 2f 0d 20 | directo|ry. */. |
|00001c40| 20 20 20 20 20 64 62 66 | 2d 3e 64 69 72 20 3d 20 | dbf|->dir = |
|00001c50| 28 69 6e 74 20 2a 29 20 | 6d 61 6c 6c 6f 63 20 28 |(int *) |malloc (|
|00001c60| 64 62 66 2d 3e 68 65 61 | 64 65 72 2d 3e 64 69 72 |dbf->hea|der->dir|
|00001c70| 5f 73 69 7a 65 29 3b 0d | 20 20 20 20 20 20 69 66 |_size);.| if|
|00001c80| 20 28 64 62 66 2d 3e 64 | 69 72 20 3d 3d 20 4e 55 | (dbf->d|ir == NU|
|00001c90| 4c 4c 29 0d 09 7b 0d 09 | 20 20 67 64 62 6d 5f 63 |LL)..{..| gdbm_c|
|00001ca0| 6c 6f 73 65 20 28 64 62 | 66 29 3b 0d 09 20 20 67 |lose (db|f);.. g|
|00001cb0| 64 62 6d 5f 65 72 72 6e | 6f 20 3d 20 47 44 42 4d |dbm_errn|o = GDBM|
|00001cc0| 5f 4d 41 4c 4c 4f 43 5f | 45 52 52 4f 52 3b 0d 09 |_MALLOC_|ERROR;..|
|00001cd0| 20 20 72 65 74 75 72 6e | 20 4e 55 4c 4c 3b 0d 09 | return| NULL;..|
|00001ce0| 7d 0d 20 20 20 20 20 20 | 64 62 66 2d 3e 68 65 61 |}. |dbf->hea|
|00001cf0| 64 65 72 2d 3e 64 69 72 | 20 3d 20 64 62 66 2d 3e |der->dir| = dbf->|
|00001d00| 68 65 61 64 65 72 2d 3e | 62 6c 6f 63 6b 5f 73 69 |header->|block_si|
|00001d10| 7a 65 3b 0d 0d 20 20 20 | 20 20 20 2f 2a 20 43 72 |ze;.. | /* Cr|
|00001d20| 65 61 74 65 20 74 68 65 | 20 66 69 72 73 74 20 61 |eate the| first a|
|00001d30| 6e 64 20 6f 6e 6c 79 20 | 68 61 73 68 20 62 75 63 |nd only |hash buc|
|00001d40| 6b 65 74 2e 20 2a 2f 0d | 20 20 20 20 20 20 64 62 |ket. */.| db|
|00001d50| 66 2d 3e 68 65 61 64 65 | 72 2d 3e 62 75 63 6b 65 |f->heade|r->bucke|
|00001d60| 74 5f 65 6c 65 6d 73 20 | 3d 0d 09 28 64 62 66 2d |t_elems |=..(dbf-|
|00001d70| 3e 68 65 61 64 65 72 2d | 3e 62 6c 6f 63 6b 5f 73 |>header-|>block_s|
|00001d80| 69 7a 65 20 2d 20 73 69 | 7a 65 6f 66 20 28 68 61 |ize - si|zeof (ha|
|00001d90| 73 68 5f 62 75 63 6b 65 | 74 29 29 0d 09 2f 20 73 |sh_bucke|t))../ s|
|00001da0| 69 7a 65 6f 66 20 28 62 | 75 63 6b 65 74 5f 65 6c |izeof (b|ucket_el|
|00001db0| 65 6d 65 6e 74 29 20 2b | 20 31 3b 0d 20 20 20 20 |ement) +| 1;. |
|00001dc0| 20 20 64 62 66 2d 3e 68 | 65 61 64 65 72 2d 3e 62 | dbf->h|eader->b|
|00001dd0| 75 63 6b 65 74 5f 73 69 | 7a 65 20 20 3d 20 64 62 |ucket_si|ze = db|
|00001de0| 66 2d 3e 68 65 61 64 65 | 72 2d 3e 62 6c 6f 63 6b |f->heade|r->block|
|00001df0| 5f 73 69 7a 65 3b 0d 20 | 20 20 20 20 20 64 62 66 |_size;. | dbf|
|00001e00| 2d 3e 62 75 63 6b 65 74 | 20 3d 20 28 68 61 73 68 |->bucket| = (hash|
|00001e10| 5f 62 75 63 6b 65 74 20 | 2a 29 20 28 61 6c 6c 6f |_bucket |*) (allo|
|00001e20| 63 61 20 28 64 62 66 2d | 3e 68 65 61 64 65 72 2d |ca (dbf-|>header-|
|00001e30| 3e 62 75 63 6b 65 74 5f | 73 69 7a 65 29 29 3b 0d |>bucket_|size));.|
|00001e40| 20 20 20 20 20 20 69 66 | 20 28 64 62 66 2d 3e 62 | if| (dbf->b|
|00001e50| 75 63 6b 65 74 20 3d 3d | 20 4e 55 4c 4c 29 0d 09 |ucket ==| NULL)..|
|00001e60| 7b 0d 09 20 20 67 64 62 | 6d 5f 63 6c 6f 73 65 20 |{.. gdb|m_close |
|00001e70| 28 64 62 66 29 3b 0d 09 | 20 20 67 64 62 6d 5f 65 |(dbf);..| gdbm_e|
|00001e80| 72 72 6e 6f 20 3d 20 47 | 44 42 4d 5f 4d 41 4c 4c |rrno = G|DBM_MALL|
|00001e90| 4f 43 5f 45 52 52 4f 52 | 3b 0d 09 20 20 72 65 74 |OC_ERROR|;.. ret|
|00001ea0| 75 72 6e 20 4e 55 4c 4c | 3b 0d 09 7d 0d 20 20 20 |urn NULL|;..}. |
|00001eb0| 20 20 20 5f 67 64 62 6d | 5f 6e 65 77 5f 62 75 63 | _gdbm|_new_buc|
|00001ec0| 6b 65 74 20 28 64 62 66 | 2c 20 64 62 66 2d 3e 62 |ket (dbf|, dbf->b|
|00001ed0| 75 63 6b 65 74 2c 20 30 | 29 3b 0d 20 20 20 20 20 |ucket, 0|);. |
|00001ee0| 20 64 62 66 2d 3e 62 75 | 63 6b 65 74 2d 3e 61 76 | dbf->bu|cket->av|
|00001ef0| 5f 63 6f 75 6e 74 20 3d | 20 31 3b 0d 20 20 20 20 |_count =| 1;. |
|00001f00| 20 20 64 62 66 2d 3e 62 | 75 63 6b 65 74 2d 3e 62 | dbf->b|ucket->b|
|00001f10| 75 63 6b 65 74 5f 61 76 | 61 69 6c 5b 30 5d 2e 61 |ucket_av|ail[0].a|
|00001f20| 76 5f 61 64 72 20 3d 20 | 33 2a 64 62 66 2d 3e 68 |v_adr = |3*dbf->h|
|00001f30| 65 61 64 65 72 2d 3e 62 | 6c 6f 63 6b 5f 73 69 7a |eader->b|lock_siz|
|00001f40| 65 3b 0d 20 20 20 20 20 | 20 64 62 66 2d 3e 62 75 |e;. | dbf->bu|
|00001f50| 63 6b 65 74 2d 3e 62 75 | 63 6b 65 74 5f 61 76 61 |cket->bu|cket_ava|
|00001f60| 69 6c 5b 30 5d 2e 61 76 | 5f 73 69 7a 65 20 3d 20 |il[0].av|_size = |
|00001f70| 64 62 66 2d 3e 68 65 61 | 64 65 72 2d 3e 62 6c 6f |dbf->hea|der->blo|
|00001f80| 63 6b 5f 73 69 7a 65 3b | 0d 0d 20 20 20 20 20 20 |ck_size;|.. |
|00001f90| 2f 2a 20 53 65 74 20 74 | 61 62 6c 65 20 65 6e 74 |/* Set t|able ent|
|00001fa0| 72 69 65 73 20 74 6f 20 | 70 6f 69 6e 74 20 74 6f |ries to |point to|
|00001fb0| 20 68 61 73 68 20 62 75 | 63 6b 65 74 73 2e 20 2a | hash bu|ckets. *|
|00001fc0| 2f 0d 20 20 20 20 20 20 | 66 6f 72 20 28 69 6e 64 |/. |for (ind|
|00001fd0| 65 78 20 3d 20 30 3b 20 | 69 6e 64 65 78 20 3c 20 |ex = 0; |index < |
|00001fe0| 64 62 66 2d 3e 68 65 61 | 64 65 72 2d 3e 64 69 72 |dbf->hea|der->dir|
|00001ff0| 5f 73 69 7a 65 20 2f 20 | 73 69 7a 65 6f 66 20 28 |_size / |sizeof (|
|00002000| 69 6e 74 29 3b 20 69 6e | 64 65 78 2b 2b 29 0d 09 |int); in|dex++)..|
|00002010| 64 62 66 2d 3e 64 69 72 | 5b 69 6e 64 65 78 5d 20 |dbf->dir|[index] |
|00002020| 3d 20 32 2a 64 62 66 2d | 3e 68 65 61 64 65 72 2d |= 2*dbf-|>header-|
|00002030| 3e 62 6c 6f 63 6b 5f 73 | 69 7a 65 3b 0d 0d 20 20 |>block_s|ize;.. |
|00002040| 20 20 20 20 2f 2a 20 49 | 6e 69 74 69 61 6c 69 7a | /* I|nitializ|
|00002050| 65 20 74 68 65 20 61 63 | 74 69 76 65 20 61 76 61 |e the ac|tive ava|
|00002060| 69 6c 20 62 6c 6f 63 6b | 2e 20 2a 2f 0d 20 20 20 |il block|. */. |
|00002070| 20 20 20 64 62 66 2d 3e | 68 65 61 64 65 72 2d 3e | dbf->|header->|
|00002080| 61 76 61 69 6c 2e 73 69 | 7a 65 0d 09 3d 20 28 20 |avail.si|ze..= ( |
|00002090| 28 64 62 66 2d 3e 68 65 | 61 64 65 72 2d 3e 62 6c |(dbf->he|ader->bl|
|000020a0| 6f 63 6b 5f 73 69 7a 65 | 20 2d 20 73 69 7a 65 6f |ock_size| - sizeo|
|000020b0| 66 20 28 67 64 62 6d 5f | 66 69 6c 65 5f 68 65 61 |f (gdbm_|file_hea|
|000020c0| 64 65 72 29 29 0d 09 20 | 2f 20 73 69 7a 65 6f 66 |der)).. |/ sizeof|
|000020d0| 20 28 61 76 61 69 6c 5f | 65 6c 65 6d 29 29 20 2b | (avail_|elem)) +|
|000020e0| 20 31 3b 0d 20 20 20 20 | 20 20 64 62 66 2d 3e 68 | 1;. | dbf->h|
|000020f0| 65 61 64 65 72 2d 3e 61 | 76 61 69 6c 2e 63 6f 75 |eader->a|vail.cou|
|00002100| 6e 74 20 3d 20 30 3b 0d | 20 20 20 20 20 20 64 62 |nt = 0;.| db|
|00002110| 66 2d 3e 68 65 61 64 65 | 72 2d 3e 61 76 61 69 6c |f->heade|r->avail|
|00002120| 2e 6e 65 78 74 5f 62 6c | 6f 63 6b 20 3d 20 30 3b |.next_bl|ock = 0;|
|00002130| 0d 20 20 20 20 20 20 64 | 62 66 2d 3e 68 65 61 64 |. d|bf->head|
|00002140| 65 72 2d 3e 6e 65 78 74 | 5f 62 6c 6f 63 6b 20 20 |er->next|_block |
|00002150| 3d 20 34 2a 64 62 66 2d | 3e 68 65 61 64 65 72 2d |= 4*dbf-|>header-|
|00002160| 3e 62 6c 6f 63 6b 5f 73 | 69 7a 65 3b 0d 0d 20 20 |>block_s|ize;.. |
|00002170| 20 20 20 20 2f 2a 20 57 | 72 69 74 65 20 69 6e 69 | /* W|rite ini|
|00002180| 74 69 61 6c 20 63 6f 6e | 66 69 67 75 72 61 74 69 |tial con|figurati|
|00002190| 6f 6e 20 74 6f 20 74 68 | 65 20 66 69 6c 65 2e 20 |on to th|e file. |
|000021a0| 2a 2f 0d 20 20 20 20 20 | 20 2f 2a 20 42 6c 6f 63 |*/. | /* Bloc|
|000021b0| 6b 20 30 20 69 73 20 74 | 68 65 20 66 69 6c 65 20 |k 0 is t|he file |
|000021c0| 68 65 61 64 65 72 20 61 | 6e 64 20 61 63 74 69 76 |header a|nd activ|
|000021d0| 65 20 61 76 61 69 6c 20 | 62 6c 6f 63 6b 2e 20 2a |e avail |block. *|
|000021e0| 2f 0d 20 20 20 20 20 20 | 6e 75 6d 5f 62 79 74 65 |/. |num_byte|
|000021f0| 73 20 3d 20 77 72 69 74 | 65 20 28 64 62 66 2d 3e |s = writ|e (dbf->|
|00002200| 64 65 73 63 2c 20 28 63 | 68 61 72 20 2a 29 20 64 |desc, (c|har *) d|
|00002210| 62 66 2d 3e 68 65 61 64 | 65 72 2c 20 64 62 66 2d |bf->head|er, dbf-|
|00002220| 3e 68 65 61 64 65 72 2d | 3e 62 6c 6f 63 6b 5f 73 |>header-|>block_s|
|00002230| 69 7a 65 29 3b 0d 20 20 | 20 20 20 20 69 66 20 28 |ize);. | if (|
|00002240| 6e 75 6d 5f 62 79 74 65 | 73 20 21 3d 20 64 62 66 |num_byte|s != dbf|
|00002250| 2d 3e 68 65 61 64 65 72 | 2d 3e 62 6c 6f 63 6b 5f |->header|->block_|
|00002260| 73 69 7a 65 29 0d 09 7b | 0d 09 20 20 67 64 62 6d |size)..{|.. gdbm|
|00002270| 5f 63 6c 6f 73 65 20 28 | 64 62 66 29 3b 0d 09 20 |_close (|dbf);.. |
|00002280| 20 67 64 62 6d 5f 65 72 | 72 6e 6f 20 3d 20 47 44 | gdbm_er|rno = GD|
|00002290| 42 4d 5f 46 49 4c 45 5f | 57 52 49 54 45 5f 45 52 |BM_FILE_|WRITE_ER|
|000022a0| 52 4f 52 3b 0d 09 20 20 | 72 65 74 75 72 6e 20 4e |ROR;.. |return N|
|000022b0| 55 4c 4c 3b 0d 09 7d 0d | 0d 20 20 20 20 20 20 2f |ULL;..}.|. /|
|000022c0| 2a 20 42 6c 6f 63 6b 20 | 31 20 69 73 20 74 68 65 |* Block |1 is the|
|000022d0| 20 69 6e 69 74 69 61 6c | 20 62 75 63 6b 65 74 20 | initial| bucket |
|000022e0| 64 69 72 65 63 74 6f 72 | 79 2e 20 2a 2f 0d 20 20 |director|y. */. |
|000022f0| 20 20 20 20 6e 75 6d 5f | 62 79 74 65 73 20 3d 20 | num_|bytes = |
|00002300| 77 72 69 74 65 20 28 64 | 62 66 2d 3e 64 65 73 63 |write (d|bf->desc|
|00002310| 2c 20 28 63 68 61 72 20 | 2a 29 20 64 62 66 2d 3e |, (char |*) dbf->|
|00002320| 64 69 72 2c 20 64 62 66 | 2d 3e 68 65 61 64 65 72 |dir, dbf|->header|
|00002330| 2d 3e 64 69 72 5f 73 69 | 7a 65 29 3b 0d 20 20 20 |->dir_si|ze);. |
|00002340| 20 20 20 69 66 20 28 6e | 75 6d 5f 62 79 74 65 73 | if (n|um_bytes|
|00002350| 20 21 3d 20 64 62 66 2d | 3e 68 65 61 64 65 72 2d | != dbf-|>header-|
|00002360| 3e 64 69 72 5f 73 69 7a | 65 29 0d 09 7b 0d 09 20 |>dir_siz|e)..{.. |
|00002370| 20 67 64 62 6d 5f 63 6c | 6f 73 65 20 28 64 62 66 | gdbm_cl|ose (dbf|
|00002380| 29 3b 0d 09 20 20 67 64 | 62 6d 5f 65 72 72 6e 6f |);.. gd|bm_errno|
|00002390| 20 3d 20 47 44 42 4d 5f | 46 49 4c 45 5f 57 52 49 | = GDBM_|FILE_WRI|
|000023a0| 54 45 5f 45 52 52 4f 52 | 3b 0d 09 20 20 72 65 74 |TE_ERROR|;.. ret|
|000023b0| 75 72 6e 20 4e 55 4c 4c | 3b 0d 09 7d 0d 0d 20 20 |urn NULL|;..}.. |
|000023c0| 20 20 20 20 2f 2a 20 42 | 6c 6f 63 6b 20 32 20 69 | /* B|lock 2 i|
|000023d0| 73 20 74 68 65 20 6f 6e | 6c 79 20 62 75 63 6b 65 |s the on|ly bucke|
|000023e0| 74 2e 20 2a 2f 0d 20 20 | 20 20 20 20 6e 75 6d 5f |t. */. | num_|
|000023f0| 62 79 74 65 73 20 3d 20 | 77 72 69 74 65 20 28 64 |bytes = |write (d|
|00002400| 62 66 2d 3e 64 65 73 63 | 2c 20 28 63 68 61 72 20 |bf->desc|, (char |
|00002410| 2a 29 20 64 62 66 2d 3e | 62 75 63 6b 65 74 2c 20 |*) dbf->|bucket, |
|00002420| 64 62 66 2d 3e 68 65 61 | 64 65 72 2d 3e 62 75 63 |dbf->hea|der->buc|
|00002430| 6b 65 74 5f 73 69 7a 65 | 29 3b 0d 20 20 20 20 20 |ket_size|);. |
|00002440| 20 69 66 20 28 6e 75 6d | 5f 62 79 74 65 73 20 21 | if (num|_bytes !|
|00002450| 3d 20 64 62 66 2d 3e 68 | 65 61 64 65 72 2d 3e 62 |= dbf->h|eader->b|
|00002460| 75 63 6b 65 74 5f 73 69 | 7a 65 29 0d 09 7b 0d 09 |ucket_si|ze)..{..|
|00002470| 20 20 67 64 62 6d 5f 63 | 6c 6f 73 65 20 28 64 62 | gdbm_c|lose (db|
|00002480| 66 29 3b 0d 09 20 20 67 | 64 62 6d 5f 65 72 72 6e |f);.. g|dbm_errn|
|00002490| 6f 20 3d 20 47 44 42 4d | 5f 46 49 4c 45 5f 57 52 |o = GDBM|_FILE_WR|
|000024a0| 49 54 45 5f 45 52 52 4f | 52 3b 0d 09 20 20 72 65 |ITE_ERRO|R;.. re|
|000024b0| 74 75 72 6e 20 4e 55 4c | 4c 3b 0d 09 7d 0d 0d 20 |turn NUL|L;..}.. |
|000024c0| 20 20 20 20 20 2f 2a 20 | 57 61 69 74 20 66 6f 72 | /* |Wait for|
|000024d0| 20 69 6e 69 74 69 61 6c | 20 63 6f 6e 66 69 67 75 | initial| configu|
|000024e0| 72 61 74 69 6f 6e 20 74 | 6f 20 62 65 20 77 72 69 |ration t|o be wri|
|000024f0| 74 74 65 6e 20 74 6f 20 | 64 69 73 6b 2e 20 2a 2f |tten to |disk. */|
|00002500| 0d 20 20 20 20 20 20 66 | 73 79 6e 63 20 28 64 62 |. f|sync (db|
|00002510| 66 2d 3e 64 65 73 63 29 | 3b 0d 0d 20 20 20 20 7d |f->desc)|;.. }|
|00002520| 0d 20 20 65 6c 73 65 0d | 20 20 20 20 7b 0d 20 20 |. else.| {. |
|00002530| 20 20 20 20 2f 2a 20 54 | 68 69 73 20 69 73 20 61 | /* T|his is a|
|00002540| 6e 20 6f 6c 64 20 64 61 | 74 61 62 61 73 65 2e 20 |n old da|tabase. |
|00002550| 20 52 65 61 64 20 69 6e | 20 74 68 65 20 69 6e 66 | Read in| the inf|
|00002560| 6f 72 6d 61 74 69 6f 6e | 20 66 72 6f 6d 20 74 68 |ormation| from th|
|00002570| 65 20 66 69 6c 65 0d 09 | 20 68 65 61 64 65 72 20 |e file..| header |
|00002580| 61 6e 64 20 69 6e 69 74 | 69 61 6c 69 7a 65 20 74 |and init|ialize t|
|00002590| 68 65 20 68 61 73 68 20 | 64 69 72 65 63 74 6f 72 |he hash |director|
|000025a0| 79 2e 20 2a 2f 0d 0d 20 | 20 20 20 20 20 67 64 62 |y. */.. | gdb|
|000025b0| 6d 5f 66 69 6c 65 5f 68 | 65 61 64 65 72 20 70 61 |m_file_h|eader pa|
|000025c0| 72 74 69 61 6c 5f 68 65 | 61 64 65 72 3b 20 20 2f |rtial_he|ader; /|
|000025d0| 2a 20 46 6f 72 20 74 68 | 65 20 66 69 72 73 74 20 |* For th|e first |
|000025e0| 70 61 72 74 20 6f 66 20 | 69 74 2e 20 2a 2f 0d 0d |part of |it. */..|
|000025f0| 20 20 20 20 20 20 2f 2a | 20 52 65 61 64 20 74 68 | /*| Read th|
|00002600| 65 20 70 61 72 74 69 61 | 6c 20 66 69 6c 65 20 68 |e partia|l file h|
|00002610| 65 61 64 65 72 2e 20 2a | 2f 0d 20 20 20 20 20 20 |eader. *|/. |
|00002620| 6e 75 6d 5f 62 79 74 65 | 73 20 3d 20 72 65 61 64 |num_byte|s = read|
|00002630| 20 28 64 62 66 2d 3e 64 | 65 73 63 2c 20 28 63 68 | (dbf->d|esc, (ch|
|00002640| 61 72 20 2a 29 20 26 70 | 61 72 74 69 61 6c 5f 68 |ar *) &p|artial_h|
|00002650| 65 61 64 65 72 2c 20 73 | 69 7a 65 6f 66 20 28 67 |eader, s|izeof (g|
|00002660| 64 62 6d 5f 66 69 6c 65 | 5f 68 65 61 64 65 72 29 |dbm_file|_header)|
|00002670| 29 3b 0d 20 20 20 20 20 | 20 69 66 20 28 6e 75 6d |);. | if (num|
|00002680| 5f 62 79 74 65 73 20 21 | 3d 20 73 69 7a 65 6f 66 |_bytes !|= sizeof|
|00002690| 20 28 67 64 62 6d 5f 66 | 69 6c 65 5f 68 65 61 64 | (gdbm_f|ile_head|
|000026a0| 65 72 29 29 0d 09 7b 0d | 09 20 20 67 64 62 6d 5f |er))..{.|. gdbm_|
|000026b0| 63 6c 6f 73 65 20 28 64 | 62 66 29 3b 0d 09 20 20 |close (d|bf);.. |
|000026c0| 67 64 62 6d 5f 65 72 72 | 6e 6f 20 3d 20 47 44 42 |gdbm_err|no = GDB|
|000026d0| 4d 5f 46 49 4c 45 5f 52 | 45 41 44 5f 45 52 52 4f |M_FILE_R|EAD_ERRO|
|000026e0| 52 3b 0d 09 20 20 72 65 | 74 75 72 6e 20 4e 55 4c |R;.. re|turn NUL|
|000026f0| 4c 3b 0d 09 7d 0d 0d 20 | 20 20 20 20 20 2f 2a 20 |L;..}.. | /* |
|00002700| 49 73 20 74 68 65 20 6d | 61 67 69 63 20 6e 75 6d |Is the m|agic num|
|00002710| 62 65 72 20 67 6f 6f 64 | 3f 20 2a 2f 0d 20 20 20 |ber good|? */. |
|00002720| 20 20 20 69 66 20 28 70 | 61 72 74 69 61 6c 5f 68 | if (p|artial_h|
|00002730| 65 61 64 65 72 2e 68 65 | 61 64 65 72 5f 6d 61 67 |eader.he|ader_mag|
|00002740| 69 63 20 21 3d 20 30 78 | 31 33 35 37 39 61 63 65 |ic != 0x|13579ace|
|00002750| 29 0d 09 7b 0d 09 20 20 | 67 64 62 6d 5f 63 6c 6f |)..{.. |gdbm_clo|
|00002760| 73 65 20 28 64 62 66 29 | 3b 0d 09 20 20 67 64 62 |se (dbf)|;.. gdb|
|00002770| 6d 5f 65 72 72 6e 6f 20 | 3d 20 47 44 42 4d 5f 42 |m_errno |= GDBM_B|
|00002780| 41 44 5f 4d 41 47 49 43 | 5f 4e 55 4d 42 45 52 3b |AD_MAGIC|_NUMBER;|
|00002790| 0d 09 20 20 72 65 74 75 | 72 6e 20 4e 55 4c 4c 3b |.. retu|rn NULL;|
|000027a0| 0d 09 7d 0d 0d 20 20 20 | 20 20 20 2f 2a 20 49 74 |..}.. | /* It|
|000027b0| 20 69 73 20 61 20 67 6f | 6f 64 20 64 61 74 61 62 | is a go|od datab|
|000027c0| 61 73 65 2c 20 72 65 61 | 64 20 74 68 65 20 65 6e |ase, rea|d the en|
|000027d0| 74 69 72 65 20 68 65 61 | 64 65 72 2e 20 2a 2f 0d |tire hea|der. */.|
|000027e0| 20 20 20 20 20 20 64 62 | 66 2d 3e 68 65 61 64 65 | db|f->heade|
|000027f0| 72 20 3d 20 28 67 64 62 | 6d 5f 66 69 6c 65 5f 68 |r = (gdb|m_file_h|
|00002800| 65 61 64 65 72 20 2a 29 | 20 6d 61 6c 6c 6f 63 20 |eader *)| malloc |
|00002810| 28 70 61 72 74 69 61 6c | 5f 68 65 61 64 65 72 2e |(partial|_header.|
|00002820| 62 6c 6f 63 6b 5f 73 69 | 7a 65 29 3b 0d 20 20 20 |block_si|ze);. |
|00002830| 20 20 20 69 66 20 28 64 | 62 66 2d 3e 68 65 61 64 | if (d|bf->head|
|00002840| 65 72 20 3d 3d 20 4e 55 | 4c 4c 29 0d 09 7b 0d 09 |er == NU|LL)..{..|
|00002850| 20 20 67 64 62 6d 5f 63 | 6c 6f 73 65 20 28 64 62 | gdbm_c|lose (db|
|00002860| 66 29 3b 0d 09 20 20 67 | 64 62 6d 5f 65 72 72 6e |f);.. g|dbm_errn|
|00002870| 6f 20 3d 20 47 44 42 4d | 5f 4d 41 4c 4c 4f 43 5f |o = GDBM|_MALLOC_|
|00002880| 45 52 52 4f 52 3b 0d 09 | 20 20 72 65 74 75 72 6e |ERROR;..| return|
|00002890| 20 4e 55 4c 4c 3b 0d 09 | 7d 0d 20 20 20 20 20 20 | NULL;..|}. |
|000028a0| 62 63 6f 70 79 20 28 26 | 70 61 72 74 69 61 6c 5f |bcopy (&|partial_|
|000028b0| 68 65 61 64 65 72 2c 20 | 64 62 66 2d 3e 68 65 61 |header, |dbf->hea|
|000028c0| 64 65 72 2c 20 73 69 7a | 65 6f 66 20 28 67 64 62 |der, siz|eof (gdb|
|000028d0| 6d 5f 66 69 6c 65 5f 68 | 65 61 64 65 72 29 29 3b |m_file_h|eader));|
|000028e0| 0d 20 20 20 20 20 20 6e | 75 6d 5f 62 79 74 65 73 |. n|um_bytes|
|000028f0| 20 3d 20 72 65 61 64 20 | 28 64 62 66 2d 3e 64 65 | = read |(dbf->de|
|00002900| 73 63 2c 20 28 63 68 61 | 72 20 2a 29 20 26 64 62 |sc, (cha|r *) &db|
|00002910| 66 2d 3e 68 65 61 64 65 | 72 2d 3e 61 76 61 69 6c |f->heade|r->avail|
|00002920| 2e 61 76 5f 74 61 62 6c | 65 5b 31 5d 2c 0d 09 09 |.av_tabl|e[1],...|
|00002930| 09 64 62 66 2d 3e 68 65 | 61 64 65 72 2d 3e 62 6c |.dbf->he|ader->bl|
|00002940| 6f 63 6b 5f 73 69 7a 65 | 2d 73 69 7a 65 6f 66 20 |ock_size|-sizeof |
|00002950| 28 67 64 62 6d 5f 66 69 | 6c 65 5f 68 65 61 64 65 |(gdbm_fi|le_heade|
|00002960| 72 29 29 3b 0d 20 20 20 | 20 20 20 69 66 20 28 6e |r));. | if (n|
|00002970| 75 6d 5f 62 79 74 65 73 | 20 21 3d 20 64 62 66 2d |um_bytes| != dbf-|
|00002980| 3e 68 65 61 64 65 72 2d | 3e 62 6c 6f 63 6b 5f 73 |>header-|>block_s|
|00002990| 69 7a 65 2d 73 69 7a 65 | 6f 66 20 28 67 64 62 6d |ize-size|of (gdbm|
|000029a0| 5f 66 69 6c 65 5f 68 65 | 61 64 65 72 29 29 0d 09 |_file_he|ader))..|
|000029b0| 7b 0d 09 20 20 67 64 62 | 6d 5f 63 6c 6f 73 65 20 |{.. gdb|m_close |
|000029c0| 28 64 62 66 29 3b 0d 09 | 20 20 67 64 62 6d 5f 65 |(dbf);..| gdbm_e|
|000029d0| 72 72 6e 6f 20 3d 20 47 | 44 42 4d 5f 46 49 4c 45 |rrno = G|DBM_FILE|
|000029e0| 5f 52 45 41 44 5f 45 52 | 52 4f 52 3b 0d 09 20 20 |_READ_ER|ROR;.. |
|000029f0| 72 65 74 75 72 6e 20 4e | 55 4c 4c 3b 0d 09 7d 0d |return N|ULL;..}.|
|00002a00| 09 0d 20 20 20 20 20 20 | 2f 2a 20 41 6c 6c 6f 63 |.. |/* Alloc|
|00002a10| 61 74 65 20 73 70 61 63 | 65 20 66 6f 72 20 74 68 |ate spac|e for th|
|00002a20| 65 20 68 61 73 68 20 74 | 61 62 6c 65 20 64 69 72 |e hash t|able dir|
|00002a30| 65 63 74 6f 72 79 2e 20 | 20 2a 2f 0d 20 20 20 20 |ectory. | */. |
|00002a40| 20 20 64 62 66 2d 3e 64 | 69 72 20 3d 20 28 69 6e | dbf->d|ir = (in|
|00002a50| 74 20 2a 29 20 6d 61 6c | 6c 6f 63 20 28 64 62 66 |t *) mal|loc (dbf|
|00002a60| 2d 3e 68 65 61 64 65 72 | 2d 3e 64 69 72 5f 73 69 |->header|->dir_si|
|00002a70| 7a 65 29 3b 0d 20 20 20 | 20 20 20 69 66 20 28 64 |ze);. | if (d|
|00002a80| 62 66 2d 3e 64 69 72 20 | 3d 3d 20 4e 55 4c 4c 29 |bf->dir |== NULL)|
|00002a90| 0d 09 7b 0d 09 20 20 67 | 64 62 6d 5f 63 6c 6f 73 |..{.. g|dbm_clos|
|00002aa0| 65 20 28 64 62 66 29 3b | 0d 09 20 20 67 64 62 6d |e (dbf);|.. gdbm|
|00002ab0| 5f 65 72 72 6e 6f 20 3d | 20 47 44 42 4d 5f 4d 41 |_errno =| GDBM_MA|
|00002ac0| 4c 4c 4f 43 5f 45 52 52 | 4f 52 3b 0d 09 20 20 72 |LLOC_ERR|OR;.. r|
|00002ad0| 65 74 75 72 6e 20 4e 55 | 4c 4c 3b 0d 09 7d 0d 0d |eturn NU|LL;..}..|
|00002ae0| 20 20 20 20 20 20 2f 2a | 20 52 65 61 64 20 74 68 | /*| Read th|
|00002af0| 65 20 68 61 73 68 20 74 | 61 62 6c 65 20 64 69 72 |e hash t|able dir|
|00002b00| 65 63 74 6f 72 79 2e 20 | 2a 2f 0d 20 20 20 20 20 |ectory. |*/. |
|00002b10| 20 66 69 6c 65 5f 70 6f | 73 20 3d 20 6c 73 65 65 | file_po|s = lsee|
|00002b20| 6b 20 28 64 62 66 2d 3e | 64 65 73 63 2c 20 64 62 |k (dbf->|desc, db|
|00002b30| 66 2d 3e 68 65 61 64 65 | 72 2d 3e 64 69 72 2c 20 |f->heade|r->dir, |
|00002b40| 4c 5f 53 45 54 29 3b 0d | 20 20 20 20 20 20 69 66 |L_SET);.| if|
|00002b50| 20 28 66 69 6c 65 5f 70 | 6f 73 20 21 3d 20 64 62 | (file_p|os != db|
|00002b60| 66 2d 3e 68 65 61 64 65 | 72 2d 3e 64 69 72 29 0d |f->heade|r->dir).|
|00002b70| 09 7b 0d 09 20 20 67 64 | 62 6d 5f 63 6c 6f 73 65 |.{.. gd|bm_close|
|00002b80| 20 28 64 62 66 29 3b 0d | 09 20 20 67 64 62 6d 5f | (dbf);.|. gdbm_|
|00002b90| 65 72 72 6e 6f 20 3d 20 | 47 44 42 4d 5f 46 49 4c |errno = |GDBM_FIL|
|00002ba0| 45 5f 53 45 45 4b 5f 45 | 52 52 4f 52 3b 0d 09 20 |E_SEEK_E|RROR;.. |
|00002bb0| 20 72 65 74 75 72 6e 20 | 4e 55 4c 4c 3b 0d 09 7d | return |NULL;..}|
|00002bc0| 0d 0d 20 20 20 20 20 20 | 6e 75 6d 5f 62 79 74 65 |.. |num_byte|
|00002bd0| 73 20 3d 20 72 65 61 64 | 20 28 64 62 66 2d 3e 64 |s = read| (dbf->d|
|00002be0| 65 73 63 2c 20 28 63 68 | 61 72 20 2a 29 20 64 62 |esc, (ch|ar *) db|
|00002bf0| 66 2d 3e 64 69 72 2c 20 | 64 62 66 2d 3e 68 65 61 |f->dir, |dbf->hea|
|00002c00| 64 65 72 2d 3e 64 69 72 | 5f 73 69 7a 65 29 3b 0d |der->dir|_size);.|
|00002c10| 20 20 20 20 20 20 69 66 | 20 28 6e 75 6d 5f 62 79 | if| (num_by|
|00002c20| 74 65 73 20 21 3d 20 64 | 62 66 2d 3e 68 65 61 64 |tes != d|bf->head|
|00002c30| 65 72 2d 3e 64 69 72 5f | 73 69 7a 65 29 0d 09 7b |er->dir_|size)..{|
|00002c40| 0d 09 20 20 67 64 62 6d | 5f 63 6c 6f 73 65 20 28 |.. gdbm|_close (|
|00002c50| 64 62 66 29 3b 0d 09 20 | 20 67 64 62 6d 5f 65 72 |dbf);.. | gdbm_er|
|00002c60| 72 6e 6f 20 3d 20 47 44 | 42 4d 5f 46 49 4c 45 5f |rno = GD|BM_FILE_|
|00002c70| 52 45 41 44 5f 45 52 52 | 4f 52 3b 0d 09 20 20 72 |READ_ERR|OR;.. r|
|00002c80| 65 74 75 72 6e 20 4e 55 | 4c 4c 3b 0d 09 7d 0d 0d |eturn NU|LL;..}..|
|00002c90| 20 20 20 20 7d 0d 20 20 | 20 20 20 20 0d 20 20 2f | }. | . /|
|00002ca0| 2a 20 49 6e 69 74 69 61 | 6c 69 7a 65 20 74 68 65 |* Initia|lize the|
|00002cb0| 20 62 75 63 6b 65 74 20 | 63 61 63 68 65 2e 20 2a | bucket |cache. *|
|00002cc0| 2f 0d 20 20 66 6f 72 20 | 28 69 6e 64 65 78 20 3d |/. for |(index =|
|00002cd0| 20 30 3b 20 69 6e 64 65 | 78 20 3c 20 43 41 43 48 | 0; inde|x < CACH|
|00002ce0| 45 5f 53 49 5a 45 3b 20 | 69 6e 64 65 78 2b 2b 29 |E_SIZE; |index++)|
|00002cf0| 0d 20 20 20 20 7b 0d 20 | 20 20 20 20 20 64 62 66 |. {. | dbf|
|00002d00| 2d 3e 62 75 63 6b 65 74 | 5f 63 61 63 68 65 5b 69 |->bucket|_cache[i|
|00002d10| 6e 64 65 78 5d 2e 63 61 | 5f 62 75 63 6b 65 74 0d |ndex].ca|_bucket.|
|00002d20| 09 3d 20 28 68 61 73 68 | 5f 62 75 63 6b 65 74 20 |.= (hash|_bucket |
|00002d30| 2a 29 20 6d 61 6c 6c 6f | 63 20 28 64 62 66 2d 3e |*) mallo|c (dbf->|
|00002d40| 68 65 61 64 65 72 2d 3e | 62 75 63 6b 65 74 5f 73 |header->|bucket_s|
|00002d50| 69 7a 65 29 3b 0d 20 20 | 20 20 20 20 69 66 20 28 |ize);. | if (|
|00002d60| 64 62 66 2d 3e 62 75 63 | 6b 65 74 5f 63 61 63 68 |dbf->buc|ket_cach|
|00002d70| 65 5b 69 6e 64 65 78 5d | 2e 63 61 5f 62 75 63 6b |e[index]|.ca_buck|
|00002d80| 65 74 20 3d 3d 20 4e 55 | 4c 4c 29 0d 09 7b 0d 09 |et == NU|LL)..{..|
|00002d90| 20 20 67 64 62 6d 5f 63 | 6c 6f 73 65 20 28 64 62 | gdbm_c|lose (db|
|00002da0| 66 29 3b 0d 09 20 20 67 | 64 62 6d 5f 65 72 72 6e |f);.. g|dbm_errn|
|00002db0| 6f 20 3d 20 47 44 42 4d | 5f 4d 41 4c 4c 4f 43 5f |o = GDBM|_MALLOC_|
|00002dc0| 45 52 52 4f 52 3b 0d 09 | 20 20 72 65 74 75 72 6e |ERROR;..| return|
|00002dd0| 20 4e 55 4c 4c 3b 0d 09 | 7d 0d 20 20 20 20 20 20 | NULL;..|}. |
|00002de0| 64 62 66 2d 3e 62 75 63 | 6b 65 74 5f 63 61 63 68 |dbf->buc|ket_cach|
|00002df0| 65 5b 69 6e 64 65 78 5d | 2e 63 61 5f 61 64 72 20 |e[index]|.ca_adr |
|00002e00| 3d 20 30 3b 0d 20 20 20 | 20 20 20 64 62 66 2d 3e |= 0;. | dbf->|
|00002e10| 62 75 63 6b 65 74 5f 63 | 61 63 68 65 5b 69 6e 64 |bucket_c|ache[ind|
|00002e20| 65 78 5d 2e 63 61 5f 63 | 68 61 6e 67 65 64 20 3d |ex].ca_c|hanged =|
|00002e30| 20 46 41 4c 53 45 3b 0d | 20 20 20 20 20 20 64 62 | FALSE;.| db|
|00002e40| 66 2d 3e 62 75 63 6b 65 | 74 5f 63 61 63 68 65 5b |f->bucke|t_cache[|
|00002e50| 69 6e 64 65 78 5d 2e 63 | 61 5f 64 61 74 61 2e 68 |index].c|a_data.h|
|00002e60| 61 73 68 5f 76 61 6c 20 | 3d 20 2d 31 3b 0d 20 20 |ash_val |= -1;. |
|00002e70| 20 20 20 20 64 62 66 2d | 3e 62 75 63 6b 65 74 5f | dbf-|>bucket_|
|00002e80| 63 61 63 68 65 5b 69 6e | 64 65 78 5d 2e 63 61 5f |cache[in|dex].ca_|
|00002e90| 64 61 74 61 2e 65 6c 65 | 6d 5f 6c 6f 63 20 3d 20 |data.ele|m_loc = |
|00002ea0| 2d 31 3b 0d 20 20 20 20 | 7d 0d 0d 20 20 2f 2a 20 |-1;. |}.. /* |
|00002eb0| 46 69 6e 69 73 68 20 69 | 6e 69 74 69 61 6c 69 7a |Finish i|nitializ|
|00002ec0| 69 6e 67 20 64 62 66 2e | 20 2a 2f 0d 20 20 64 62 |ing dbf.| */. db|
|00002ed0| 66 2d 3e 6c 61 73 74 5f | 72 65 61 64 20 3d 20 2d |f->last_|read = -|
|00002ee0| 31 3b 0d 20 20 64 62 66 | 2d 3e 62 75 63 6b 65 74 |1;. dbf|->bucket|
|00002ef0| 20 3d 20 64 62 66 2d 3e | 62 75 63 6b 65 74 5f 63 | = dbf->|bucket_c|
|00002f00| 61 63 68 65 5b 30 5d 2e | 63 61 5f 62 75 63 6b 65 |ache[0].|ca_bucke|
|00002f10| 74 3b 0d 20 20 64 62 66 | 2d 3e 62 75 63 6b 65 74 |t;. dbf|->bucket|
|00002f20| 5f 64 69 72 20 3d 20 30 | 3b 0d 20 20 64 62 66 2d |_dir = 0|;. dbf-|
|00002f30| 3e 63 61 63 68 65 5f 65 | 6e 74 72 79 20 3d 20 26 |>cache_e|ntry = &|
|00002f40| 64 62 66 2d 3e 62 75 63 | 6b 65 74 5f 63 61 63 68 |dbf->buc|ket_cach|
|00002f50| 65 5b 30 5d 3b 0d 20 20 | 64 62 66 2d 3e 68 65 61 |e[0];. |dbf->hea|
|00002f60| 64 65 72 5f 63 68 61 6e | 67 65 64 20 3d 20 46 41 |der_chan|ged = FA|
|00002f70| 4c 53 45 3b 0d 20 20 64 | 62 66 2d 3e 64 69 72 65 |LSE;. d|bf->dire|
|00002f80| 63 74 6f 72 79 5f 63 68 | 61 6e 67 65 64 20 3d 20 |ctory_ch|anged = |
|00002f90| 46 41 4c 53 45 3b 0d 20 | 20 64 62 66 2d 3e 62 75 |FALSE;. | dbf->bu|
|00002fa0| 63 6b 65 74 5f 63 68 61 | 6e 67 65 64 20 3d 20 46 |cket_cha|nged = F|
|00002fb0| 41 4c 53 45 3b 0d 20 20 | 64 62 66 2d 3e 73 65 63 |ALSE;. |dbf->sec|
|00002fc0| 6f 6e 64 5f 63 68 61 6e | 67 65 64 20 3d 20 46 41 |ond_chan|ged = FA|
|00002fd0| 4c 53 45 3b 0d 20 20 0d | 20 20 2f 2a 20 45 76 65 |LSE;. .| /* Eve|
|00002fe0| 72 79 74 68 69 6e 67 20 | 69 73 20 66 69 6e 65 2c |rything |is fine,|
|00002ff0| 20 72 65 74 75 72 6e 20 | 74 68 65 20 70 6f 69 6e | return |the poin|
|00003000| 74 65 72 20 74 6f 20 74 | 68 65 20 66 69 6c 65 0d |ter to t|he file.|
|00003010| 20 20 20 20 20 69 6e 66 | 6f 72 6d 61 74 69 6f 6e | inf|ormation|
|00003020| 20 73 74 72 75 63 74 75 | 72 65 2e 20 20 2a 2f 0d | structu|re. */.|
|00003030| 20 20 72 65 74 75 72 6e | 20 64 62 66 3b 0d 0d 7d | return| dbf;..}|
|00003040| 0d 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00003050| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00003060| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00003070| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00003080| 00 00 01 00 00 00 01 6e | 00 00 00 6e 00 00 00 3e |.......n|...n...>|
|00003090| 61 74 69 6f 6e 20 66 75 | 6e 63 74 69 6f 6e 73 0d |ation fu|nctions.|
|000030a0| 20 2a 2f 0d 0d 63 6c 6f | 63 6b 5f 74 20 63 6c 6f | */..clo|ck_t clo|
|000030b0| 0a 67 64 62 6d 6f 70 65 | 6e 2e 63 00 02 00 00 00 |.gdbmope|n.c.....|
|000030c0| 54 45 58 54 4d 50 53 20 | 00 00 00 00 00 00 00 00 |TEXTMPS |........|
|000030d0| 00 00 54 45 58 54 4d 50 | 53 20 00 00 00 00 00 00 |..TEXTMP|S ......|
|000030e0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000030f0| 00 00 a6 04 08 2a 00 00 | 2f c1 00 00 01 ac 43 6f |.....*..|/.....Co|
|00003100| 75 6e 74 28 29 20 2a 2f | 0d 70 61 73 63 61 6c 20 |unt() */|.pascal |
|00003110| 75 6e 73 69 67 6e 65 64 | 20 6c 6f 6e 67 20 5f 5f |unsigned| long __|
|00003120| 74 69 63 6b 63 6f 75 6e | 74 28 76 6f 69 64 29 0d |tickcoun|t(void).|
|00003130| 20 20 20 20 3d 20 30 78 | 41 39 37 35 3b 20 0d 0d | = 0x|A975; ..|
|00003140| 64 6f 75 62 6c 65 20 20 | 64 69 66 66 74 69 6d 65 |double |difftime|
|00003150| 28 74 69 6d 65 5f 74 20 | 74 69 6d 65 31 2c 20 74 |(time_t |time1, t|
|00003160| 69 6d 65 5f 74 20 74 69 | 6d 65 30 29 3b 20 20 20 |ime_t ti|me0); |
|00003170| 20 20 20 20 20 09 09 2f | 2a 20 66 75 6e 63 74 69 | ../|* functi|
|00003180| 00 00 00 48 00 09 4d 6f | 6e 61 63 6f 00 20 73 74 |...H..Mo|naco. st|
|00003190| 72 75 63 74 75 72 65 73 | 20 66 6f 72 20 75 73 65 |ructures| for use|
|000031a0| 2e 20 2a 2f 0d 0d 00 06 | 00 08 00 64 00 1c 01 dd |. */....|...d....|
|000031b0| 02 3d 00 64 00 1c 01 dd | 02 3d a6 04 b7 6d 00 00 |.=.d....|.=...m..|
|000031c0| 14 9a 00 00 14 b4 00 00 | 0a 42 01 00 00 00 00 1e |........|.B......|
|000031d0| 00 64 00 1c 01 dd 02 3d | 00 64 00 1c 01 dd 02 3d |.d.....=|.d.....=|
|000031e0| 00 00 0a 42 00 00 00 00 | 00 00 00 00 00 00 00 00 |...B....|........|
|000031f0| 01 00 00 00 01 6e 00 00 | 00 6e 00 00 00 3e 00 49 |.....n..|.n...>.I|
|00003200| aa 38 14 f0 00 00 00 1c | 00 3e 00 00 4d 50 53 52 |.8......|.>..MPSR|
|00003210| 00 01 00 0a 03 ed ff ff | 00 00 00 00 00 00 00 00 |........|........|
|00003220| 03 f0 ff ff 00 00 00 4c | 00 4f db 34 00 00 00 00 |.......L|.O.4....|
|00003230| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00003240| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00003250| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00003260| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00003270| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
+--------+-------------------------+-------------------------+--------+--------+