|
|
1.1 ! root 1: .TH CBT 3X ! 2: .CT 2 data_man ! 3: .SH NAME ! 4: bopen, bclose, bseek, bfirst, bkey, breclen, bread, ! 5: bdelete, bwrite \(mi compressed B-tree subroutines ! 6: .SH SYNOPSIS ! 7: .nf ! 8: .PP ! 9: .B #include <cbt.h> ! 10: .PP ! 11: .B "bfile *bopen(name, typ) char *name;" ! 12: .PP ! 13: .B "void bclose(b) bfile *b;" ! 14: .PP ! 15: .B "bseek(b, key) bfile *b; mbuf key;" ! 16: .PP ! 17: .B "bfirst(b) bfile *b;" ! 18: .PP ! 19: .B "mbuf bkey(b) bfile *b;" ! 20: .PP ! 21: .B "breclen(b) bfile *b;" ! 22: .PP ! 23: .B "bread(b, key, val) bfile *b; mbuf *key, *val;" ! 24: .PP ! 25: .B "bdelete(b, key) bfile *b; mbuf key;" ! 26: .PP ! 27: .B "bwrite(b, key, val) bfile *b; mbuf key, val;" ! 28: .fi ! 29: .SH DESCRIPTION ! 30: These functions manipulate ! 31: files of key/value records. ! 32: Such files are created by ! 33: .BR "cbt creat" ; ! 34: see ! 35: .IR cbt (1). ! 36: To load the functions use the ! 37: .IR ld (1) ! 38: option ! 39: .BR \-lcbt . ! 40: .PP ! 41: The records occur sorted ! 42: (increasing lexicographical order) by their keys, ! 43: which must be distinct. ! 44: Both keys and values are arrays of characters accessed through ! 45: the structure ! 46: .EX ! 47: .ta 8n +15n ! 48: .nf ! 49: \fLtypedef struct { ! 50: \fLchar *mdata;\fR address of data bytes ! 51: \fLshort mlen;\fP number of data bytes ! 52: \fL} mbuf;\fR ! 53: .fi ! 54: .EE ! 55: .PP ! 56: .I "Bopen" ! 57: attempts to open a named B-tree, ! 58: and if successful establishes a read pointer ! 59: pointing to the beginning of the file and ! 60: returns a pointer to be used ! 61: in calling the other routines. ! 62: .I Typ ! 63: is 0 for read-only or 2 for read-write. ! 64: .I Bopen ! 65: returns a descriptor that identifies the file to the other functions. ! 66: .PP ! 67: .I "Bclose" ! 68: closes a B-tree. ! 69: .PP ! 70: .I "Bseek" ! 71: positions the read pointer of the file ! 72: to the record whose key is ! 73: the first not less than ! 74: .IR key . ! 75: The routine returns 1 if ! 76: .I key ! 77: is in the file, ! 78: .B EOF ! 79: if ! 80: .I key ! 81: is greater ! 82: than any key in the file, ! 83: and 0 otherwise. ! 84: .PP ! 85: .I "Bfirst" ! 86: sets the read pointer to the beginning of the file. ! 87: It has the same error return as ! 88: .BR bseek . ! 89: .PP ! 90: .I "Bkey" ! 91: returns the current key. ! 92: The element ! 93: .I mdata ! 94: of the returned structure ! 95: is 0 ! 96: on errors, ! 97: otherwise it points to a static buffer. ! 98: .PP ! 99: .I "Breclen" ! 100: returns the length of the value part of the current record. ! 101: .PP ! 102: .I "Bread" ! 103: reads the value at the read pointer into the space ! 104: pointed to by ! 105: .B val->mdata, ! 106: places its length in ! 107: .LR val->mlen , ! 108: and advances the read pointer ! 109: to the record with the next greater key. ! 110: If ! 111: .I key ! 112: is not 0 ! 113: the key of the record is read into the ! 114: space pointed to by ! 115: .B key->mdata ! 116: and its length is placed in ! 117: .BR key->mlen . ! 118: .I Bread ! 119: returns 0 ! 120: if successful. ! 121: .PP ! 122: .I "Bdelete" ! 123: removes the record with the given key, ! 124: returning 1 if the record was found, ! 125: \-1 ! 126: if there was an error, and 0 ! 127: otherwise, ! 128: The read pointer is left undefined. ! 129: .PP ! 130: .I "Bwrite" ! 131: writes the given value with the given key. ! 132: An existing record with that key will be replaced. ! 133: The read pointer is left undefined. ! 134: .SH FILES ! 135: .F \fIname\fP.T ! 136: .br ! 137: .F \fIname\fP.F ! 138: .SH SEE ALSO ! 139: .IR cbt (1), ! 140: .IR dbm (3) ! 141: .SH DIAGNOSTICS ! 142: Routines which return pointers return 0 ! 143: on errors, ! 144: routines which return integers return \-1. ! 145: .SH BUGS ! 146: The length of any key is limited to 255. ! 147: .br ! 148: The ! 149: .B mbuf ! 150: arguments are passed inconsistently to the routines, ! 151: sometimes by value and sometimes by reference. ! 152: .br ! 153: .I Cbt ! 154: files are not directly portable between big-endian and ! 155: little-endian machines.
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.