⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cdbfile.ps

📁 操纵DBASEIII文件的程序
💻 PS
📖 第 1 页 / 共 4 页
字号:
b(:)h(:)f(:)g(:)h(:)f(:)g(:)g(:)h(:)f(:)g(:)h(:)f(:)g(:)g(:)h(:)f(:)g(:)h(:)f(:)g(:)g(:)h(:)68 b Fq(8)165 1673 y Fr(4)41 b(An)11b(example:)j(the)c(T)-5 b(estDBF)10 b(\256le)g(editor)719b(10)165 1765 y(5)41 b(Conclusion)1181 b(10)165 1856y(6)41 b(Contributors)1155 b(1)n(1)905 2960 y Fq(1)peop%%Page: 2 22 1 bop 165 197 a Fs(1)60 b(Introduction)165 291 y Fq(Last)10b(term,)g(I)g(had)h(to)e(begin)i(a)f(r)o(eengineering)i(pr)o(oject)e(for)g(the)g(ENSSA)m(T)m(,)i(the)e(Fr)o(ench)i(grad-)165341 y(uate)d(school)h(I)h(am)e(working)h(at.)k(The)d(cor)o(e)g(of)e(the)h(pr)o(oject)g(was)f(a)h(softwar)o(e)f(that)g(drives)i(au-)165391 y(tomatic)f(doors)h(with)g(magnetic)g(car)o(ds,)i(which)f(ar)o(e)f(r)o(eferr)o(ed)i(to)e(in)h(data)f(\256les.)17 b(W)l(ell,)11b(I)h(had)165 441 y(long)f(thought)g(that)g(the)g Fr(dBASE)h(III)24b Fq(\256le)11 b(standar)o(d)h(was)e(no)i(longer)g(in)f(use)g(since)hFr(dBASE)165 491 y(IV)h Fq(and)g Fr(dBASE)h(V)f Fq(had)h(appear)o(ed.)21 b(It)13 b(turned)g(out)f(that)g(the)g(former)h(softwar)o(e)e(that)h(was)165 540 y(running)g(those)e(doors)g(seemed)h(to)f(work)h(very)g(well)g(with)f(those)g(DBF)i(\256les,)f(and)g(yet)g(their)165590 y(structur)o(e)i(was)f(quite)h(simple.)21 b(I)13b(could)h(have)f(chosen)g(to)f(use)h(raw)f(text)h(\256les)g(for)f(that)g(ap-)165 640 y(plication,)g(which)h(woud)e(have)h(made)g(it)f(a)h(gr)o(eat)g(deal)g(easier)f(to)g(pr)o(ogram.)19 b(But)12 b(ther)o(e)g(ar)o(e)165 690 y(quite)g(a)h(few)e(companies)h(and)h(administrations)e(in)i(France)g(that)e(used)i(the)f(same)f(system,)165 740y(and)g(I)f(thought)g(that)f(it)h(would)g(be)g(easier)g(for)g(them)g(to)g(migrate)f(to)h(a)g(new)g(softwar)o(e)f(if)h(they)165789 y(did)h(not)f(have)h(to)e(modify)h(the)g(structur)o(e)g(of)g(their)h(own)e(data)h(\256les.)227 839 y(Br)o(owsing)i(the)g(Net)g(for)g(some)e(documents)i(or)g(some)f(code,)i(I)f(discover)o(ed)h(that)e(har)o(dly)165 889 y(anything)i(had)f(been)h(r)o(eleased)f(under)i(the)e(GPL)964874 y Fo(1)995 889 y Fq(in)h(that)e(\256eld.)21 b(The)13b(only)g(thing)f(I)h(found)165 939 y(was)e(Mark)h(W)l(.)g(Schumann's)fFn("ffld.c")p Fq(,)g(but)h(I)f(needed)i(mor)o(e)e(than)h(that,)f(and)h(I)g(wanted)165 989 y(those)f(tools)g(to)h(be)g(object-oriented.)19b(So)12 b(I)h(decided)h(to)d(distribute)h(the)g(few)g(tools)f(I)h(would)165 1039 y(build)g(under)h(the)e(GPL)h(\(please)f(r)o(ead)h(the)f Fn(COPYING)h Fq(text)f(\256le)g(included)j(in)e(the)f(package\).)1651088 y(They)d(ar)o(e)g(far)f(fr)o(om)g(being)g(compr)o(ehensive,)i(but)e(I)g(hope)g(that)g(their)g(modularity)g(will)g(enable)1651138 y(other)j(developpers)g(to)g(expand)h(them)f(and/or)g(customize)f(them)h(as)g(they)g(like...)165 1281 y Fs(2)60 b(The)14b(dBASE)f(III)i(Database)f(\256le)g(structure)165 1376y Fq(The)8 b(structur)o(e)g(of)g(a)f(dBASE)j(III)e(database)e(\256le)i(is)g(composed)f(of)h(a)f(header)i(and)f(data)f(r)o(ecor)o(ds.)1651425 y(The)k(layout)e(is)h(given)h(below)l(.)p 165 15271498 2 v 164 1572 2 46 v 190 1559 a Fm(BYTE)p 326 1572V 74 w(CONTENTS)p 667 1572 V 165 w(MEANING)p 1662 1572V 165 1574 1498 2 v 165 1582 V 164 1674 2 92 v 190 1614a(0)p 326 1674 V 140 w(1)23 b(byte)p 667 1674 V 208 w(dBASE)i(III)e(version)j(number)e(\(03H)g(without)i(a)693 1660 y(.DBT)e(file\))h(\(83H)f(with)g(a)f(.DBT)h(file\))p 1662 1674 V 165 16751498 2 v 164 1767 2 92 v 190 1707 a(1-3)p 326 1767 V96 w(3)f(bytes)p 667 1767 V 186 w(date)h(of)f(last)h(update)h(\(YY)f(MM)f(DD\))h(in)f(binary)693 1753 y(format)p 1662 1767V 165 1768 1498 2 v 164 1814 2 46 v 190 1800 a(4-7)p326 1814 V 96 w(32)g(bit)h(number)p 667 1814 V 52 w(number)h(of)e(records)j(in)d(data)h(file)p 1662 1814 V 165 1816 14982 v 164 1861 2 46 v 190 1848 a(8-9)p 326 1861 V 96 w(16)f(bit)h(number)p 667 1861 V 52 w(length)h(of)e(header)i(structure)p1662 1861 V 165 1863 1498 2 v 164 1909 2 46 v 190 1895a(10-11)p 326 1909 V 52 w(16)e(bit)h(number)p 667 1909V 52 w(length)h(of)e(the)h(record)p 1662 1909 V 165 19101498 2 v 164 1956 2 46 v 190 1942 a(12-31)p 326 1956V 52 w(20)f(bytes)p 667 1956 V 164 w(reserved)j(bytes)e(\(version)i(1.00\))p 1662 1956 V 165 1958 1498 2 v 164 2003 2 46v 190 1990 a(32-n)p 326 2003 V 74 w(32)d(bytes)i(each)p667 2003 V 51 w(field)g(descriptor)h(array)f(\(see)f(below\))p1662 2003 V 165 2005 1498 2 v 164 2051 2 46 v 190 2037a(n+1)p 326 2051 V 96 w(1)f(byte)p 667 2051 V 208 w(0DH)h(as)f(the)h(field)g(terminato)q(r)p 1662 2051 V 165 2052 1498 2v 549 2128 a Fq(Figur)o(e)11 b(1:)j(dBASE)d(III)g(database)e(\256le)h(header)p 165 2241 V 164 2287 2 46 v 190 2273 a Fm(BYTE)p326 2287 V 74 w(CONTENTS)p 667 2287 V 165 w(MEANING)p1662 2287 V 165 2288 1498 2 v 165 2297 V 164 2342 2 46v 190 2329 a(0-10)p 326 2342 V 74 w(11)23 b(bytes)p 6672342 V 164 w(field)i(name)f(in)f(ASCII)h(zero-fil)q(led)p1662 2342 V 165 2344 1498 2 v 164 2390 2 46 v 190 2376a(11)p 326 2390 V 118 w(1)f(byte)p 667 2390 V 208 w(field)i(type)f(in)f(ASCII)h(\(C)g(N)e(L)h(D)g(or)g(M\))p 1662 2390 V 1652391 1498 2 v 164 2483 2 92 v 190 2423 a(12-15)p 3262483 V 52 w(32)g(bit)h(number)p 667 2483 V 52 w(field)h(data)f(address)h(\(address)h(is)d(set)h(in)693 2469 y(memory\))p 16622483 V 165 2484 1498 2 v 164 2530 2 46 v 190 2516 a(16)p326 2530 V 118 w(1)f(byte)p 667 2530 V 208 w(field)i(length)f(in)g(binary)p 1662 2530 V 165 2532 1498 2 v 164 2577 2 46v 190 2564 a(17)p 326 2577 V 118 w(1)f(byte)p 667 2577V 208 w(field)i(decimal)g(count)f(in)g(binary)p 16622577 V 165 2579 1498 2 v 164 2625 2 46 v 190 2611 a(18-31)p326 2625 V 52 w(14)f(bytes)p 667 2625 V 164 w(reserved)j(bytes)e(\(version)i(1.00\))p 1662 2625 V 165 2626 1498 2 v 6672702 a Fq(Figur)o(e)11 b(2:)j(A)c(\256eld)h(descriptor)p165 2741 600 2 v 207 2767 a Fl(1)225 2779 y Fk(W)m(ell,)d(I)g(discover)o(ed)h(later)e(that)h(a)g(dBASE)i(\256le)d(viewer)h(also)g(existed,)g(written)g(in)g(C)g(for)g(UNIX/Linux...)905 2960 y Fq(2)peop%%Page: 3 33 2 bop 227 195 a Fq(The)11 b(data)f(r)o(ecor)o(ds)i(ar)o(e)e(layed)h(out)e(as)h(follows:)217 278 y(1.)21 b(Data)9 b(r)o(ecor)o(ds)j(ar)o(e)f(pr)o(eceeded)h(by)e(one)g(byte)g(that)g(is)g(a)g(space)gFn(\(20H\))g Fq(if)g(the)g(r)o(ecor)o(d)i(is)269 328y(not)e(deleted)g(and)h(an)f(asterisk)f Fn(\(2AH\))hFq(if)g(it)g(is)g(deleted.)217 411 y(2.)21 b(Data)11b(\256elds)g(ar)o(e)h(packed)g(into)f(r)o(ecor)o(ds)i(with)e(no)h(\256eld)g(separators)e(or)h(r)o(ecor)o(d)j(termi-)269461 y(nators.)217 544 y(3.)21 b(Data)9 b(types)h(ar)o(e)g(stor)o(ed)g(in)h(ASCII)g(format)e(as)h(described)h(in)g(Figur)o(e)g(3.)p165 645 1397 2 v 164 691 2 46 v 190 677 a Fm(DATA)24b(TYPE)p 416 691 V 424 691 V 60 w(DATA)g(RECORD)h(STORAGE)p1560 691 V 165 692 1397 2 v 164 738 2 46 v 190 724 a(Character)p416 738 V 424 738 V 62 w(\(ASCII)g(characters)q(\))p1560 738 V 165 740 1397 2 v 164 785 2 46 v 190 772 a(Numeric)p416 785 V 424 785 V 106 w(-)e(.)45 b(0)23 b(1)g(2)f(3)h(4)g(5)g(6)g(7)g(8)f(9)p 1560 785 V 165 787 1397 2 v 164 833 2 46 v 190819 a(Logical)p 416 833 V 424 833 V 106 w(?)45 b(Y)23b(y)g(N)g(n)f(T)h(t)g(F)g(f)g(\(?)45 b(when)24 b(not)g(initializ)q(ed)q(\))p 1560 833 V 165 834 1397 2 v 164 880 2 46 v 190866 a(Memo)p 416 880 V 424 880 V 172 w(\(10)f(digits)i(represen)q(ti)q(ng)h(a)d(.DBT)h(block)g(number\))p 1560 880 V 165 8821397 2 v 164 973 2 92 v 190 914 a(Date)p 416 973 V 424973 V 172 w(\(8)f(digits)i(in)e(YYYYMMDD)j(format,)f(such)f(as)g(19840704)450 959 y(for)f(July)i(4,)e(1984\))p 1560 973V 165 975 1397 2 v 666 1049 a Fq(Figur)o(e)11 b(3:)j(Data)c(type)g(storage)165 1237 y Fs(3)60 b(Description)13 b(of)i(the)f(object)1651340 y Fj(3.1)50 b(Speci\256cation)165 1419 y Fq(For)13b(the)f(pr)o(oject)h(I)g(was)f(working)h(on,)g(I)g(had)g(to)f(pr)o(ocess)h(various)g(dBASE)h(\256les)e(that)g(wer)o(e)1651469 y(very)f(dif)o(fer)o(ent)f(in)g(their)f(structur)o(es.)14b(The)c(easiest)e(way)h(to)g(solve)g(that)g(pr)o(oblem)h(was)e(to)h(cr)o(e-)165 1519 y(ate)e(a)h(set)f(of)g(tools)g(that)g(would)g(be)h(completely)g(generic,)h(smart)e(enough)h(to)f(pr)o(ocess)h(various)1651568 y(\256les)k(with)f(various)h(kinds)g(of)f(data.)18b(I)12 b(thought)f(that)g(ther)o(e)h(could)g(be)g(a)g(speci\256c)g(object)f(for)165 1618 y(the)f(\256le,)h(which)g(would)f(contain)g(at)g(least)f(the)h(whole)g(description)g(of)g(the)g(header)m(.)2271668 y(The)h(next)f(pr)o(oblem)f(was)g(:)14 b(how)c(will)f(I)h(stor)o(e)f(the)h(r)o(ecor)o(ds?)15 b(The)c(\256rst)e(idea)h(that)f(springs)165 1718 y(to)h(mind)g(is)g(:)269 1801 y(\272Okay)-5b(,)8 b(let's)e(cr)o(eate)i(a)g(generic)g(structur)o(e)g(containing)g(a)f(dynamic)i(list)e(of)g(\256elds,)269 1851 y(each)13b(of)f(which)h(will)f(contain)h(the)f(data.)20 b(Every)14b(\256eld)f(in)g(the)f(list)g(will)h(have)f(a)269 1901y(type)h(identi\256er)m(,)i(a)e(buf)o(fer)g(containing)h(the)f(data,)h(and)f(a)h(pointer)f(to)f(the)h(next)269 1950 y(\256eld.)h(Every)c(r)o(ecor)o(d)h(will)e(be)g(a)g(list)f(of)h(those)f(\256elds,)i(and)f(the)g(r)o(ecor)o(ds)h(will)f(also)269 2000 y(be)h(stor)o(ed)g(in)h(a)f(dynamic)h(list\272.)227 2083 y(This)h(might)g(be)g(an)g(elegant)f(solution,)g(but)h(it)f(is)h(very)h(heavy:)k(suppose)11b(you)h(have)g(256)165 2133 y(\256elds)e(in)h(each)f(r)o(ecor)o(d,)i(each)f(of)e(which)i(containing)f(only)h(one)e(byte)h(of)g(data...)k(W)n(ith)9 b(all)h(the)165 2183 y(pointers)f(involved)i(in)f(the)g(dynamic)g(structur)o(es,)g(the)f(data)g(could)i(take)e(up)h(to)f(ten)g(times)g(as)165 2233 y(much)i(space)f(in)g(memory)g(as)g(on)g(the)g(disk!)227 2282 y(In)i(or)o(der)h(to)d(save)i(memory)-5b(,)12 b(I)f(decided)i(to)e(keep)g(a)h(simple)e(structur)o(e:)17b(every)12 b(r)o(ecor)o(d)h(is)165 2332 y(stor)o(ed)f(as)g(a)g(string)g(of)g(raw)g(ASCII)h(r)o(ead)g(dir)o(ectly)g(fr)o(om)f(the)g(disk,)h(into)f(a)g(dynamic)h(list)f(of)165 2382 y(r)o(ecor)o(ds.)21b(The)13 b(description)g(of)f(the)f(\256elds)i(\(with)e(their)i(types)e(and)i(lengths\))f(is)g(stor)o(ed)g(in)g(a)165 2432 y(separate)7b(list.)13 b(V)l(alues)8 b(ar)o(e)g(r)o(ead)h(fr)o(om)f(and)g(written)g(to)f(the)h(r)o(ecor)o(ds)i(using)e(functions)g(which)1652482 y(format)h(the)h(data)g(accor)o(ding)i(to)e(the)f(\256eld)i(types.)227 2531 y(This)d(solution)f(consumes)f(less)h(memory)g(and)h(is)f(easier)g(to)g(implement.)12 b(Ther)o(e)d(is)e(a)g(price)1652581 y(to)h(pay)-5 b(,)10 b(though,)g(for)f(the)g(genericity)g(of)g(the)g(tools:)j(using)d(the)g(functions)g(to)f(access)h(the)g(data)1652631 y(\(r)o(eading)g(fr)o(om)f(/)g(writing)h(to)e(a)h(r)o(ecor)o(d\))i(you)e(have)g(to)g(pass)f(or)h(to)g(r)o(eceive)h(a)f(void)h(pointer)m(,)g(so)165 2681 y(the)i(pr)o(ogrammer)h(has)f(to)f(know)h(exactly)h(which)g(is)f(the)g(type)g(of)g(the)g(value)g(that)g(is)g(passed)1652731 y(or)f(r)o(eceived.)905 2960 y(3)p eop%%Page: 4 44 3 bop 165 195 a Fj(3.2)50 b(Structure)165 274 y Fq(The)10b Fn(CDBFile)f Fq(object)g(structur)o(e)g(is)g(layed)h(out)f(as)g(described)h(in)g(Figur)o(e)g(4.)k(It)9 b(contains)g(two)165324 y(dynamic)h(lists:)j(one)c(list)g(of)g(\256eld)h(descriptors)g(\(pointers)e(to)h Fn(CField)g Fq(objects\))g(and)g(one)h(list)165374 y(of)g(r)o(ecor)o(ds)h(\(pointers)f(to)g Fn(Record)fFq(structur)o(es\).)p 613 477 597 4 v 613 527 4 50 v841 515 a Fi(CDBFile)p 1206 527 V 613 530 597 4 v 638570 256 4 v 638 608 4 38 v 676 602 a(RecordList)p 890608 V 638 611 256 4 v 3 setlinewidth np 599 813 a closepathst 638 645 V 638 682 4 38 v 690 677 a(Record)h(2)p 890682 V 638 685 256 4 v 638 720 V 638 757 4 38 v 690 752a(Record)g(3)p 890 757 V 638 760 256 4 v 638 794 V 638832 4 38 v 674 827 a(Record)g(n...)p 890 832 V 638 835256 4 v 765 568 2 38 v 766 568 a Fh(?)p 732 645 2 36v 732 645 a(?)p 798 643 V 799 649 a(6)p 732 720 V 732720 a(?)p 798 718 V 799 724 a(6)p 732 794 V 732 794 a(?)p798 792 V 799 799 a(6)p 970 570 223 4 v 970 608 4 38v 1004 602 a Fi(FirstField)p 1189 608 V 970 611 223 4v 970 645 V 970 682 4 38 v 1025 677 a(Field)g(2)p 1189682 V 970 685 223 4 v 970 720 V 970 757 4 38 v 1025 752a(Field)g(3)p 1189 757 V 970 760 223 4 v 1080 568 2 38v 1081 568 a Fh(?)p 1080 645 2 36 v 1081 645 a(?)p 1080720 V 1081 720 a(?)p 1 setlinewidth np 1081 755 a 1081780 li st 1 setlinewidth np 1081 780 a 1230 780 li st1 setlinewidth np 1230 780 a 1230 589 li st 1189 59042 2 v 1189 589 a(\033)587 979 y Fq(Figur)o(e)h(4:)j(CDBFile)d(internal)g(structur)o(e)227 1090 y(The)g(\256eld)g(descriptors)g(ar)o(e)g(or)o(ganized)g(in)g(a)f(ring:)15 b(the)10 b(last)gFn(CField)g Fq(pointer)g(points)g(to)165 1140 y(the)g(\256rst)gFn(CField*)f Fq(in)i(the)f(list.)j(The)e(ring)g(is)f(single-linked.)k(I)d(chose)f(to)f(implement)g(it)h(that)165 1190 y(way)i(because)g(it)g(is)g(easier)g(to)g(maintain)g(than)g(a)g(double-linked)h(dynamic)g(list,)f(and)h(quite)165 1239 y(ef)o(\256cient,)e(given)g(the)f(few)g(number)g(of)g(\256elds)g(that)g(we)g(have)g(in)h(general.)2271289 y(The)h(r)o(ecor)o(ds)h(ar)o(e)f(stor)o(ed)f(in)g(a)h(double-linked)f(list.)17 b(I)11 b(tried)h(to)f(use)g(a)g(single-linked)h(list)165 1339 y(\256rst,)g(but)f(it)g(turned)h(out)e(that)h(I)g(needed)h(a)g(second)f(link)h(in)g(or)o(der)g(to)f(apply)g(the)g(quick)i(sort)165 1389 y(algorithm)d(to)f(the)h(list.)k(Pity)-5b(.)227 1439 y(Another)10 b(thing)f(that)f(worries)h(me)f(about)g(the)h(quality)g(of)g(the)g(tools)e(is)i(that)f(I)h(did)h(not)f(de-)1651488 y(clar)o(e)i Fn(Record)e Fq(as)g(an)h(object,)f(but)h(only)f(as)g(a)h(structur)o(e)g(\(I)f(thought)g(I)h(didn't)g(need)g(to,)f(given)1651538 y(the)i(little)f(data)h(contained)h(in)f(that)g(structur)o(e\).)16b Fr(R)p Fq(eal)11 b Fr(C++)h(P)p Fq(r)o(ogrammers)f(won't)f(like)i(it)f(at)165 1588 y(all...)k(Maybe)10 b(in)h(a)f(later)g(version)h(I)f(\(or)g(someone)f(else\))h(will)g(\256x)h(that.)227 1638y Fr(Nota:)25 b Fq(in)7 b(the)g(next)h(subsections,)e(I)i(will)f(describe)h(the)f(various)g(components)f(of)h(the)g Fn(CD-)1651688 y(BFile)i Fq(object)f(and)i(their)f(behavior)m(.)14b(That)9 b(description)g(will)h(only)f(be)g(a)g(quick)h(overview)g(of)165 1737 y(what)g(every)i(member)f(function)g(does,)g(so)f(if)h(you)g(r)o(eally)h(need)f(mor)o(e)g(details,)g(have)h(a)f(look)1651787 y(at)e(the)g(code)h(in)g Fn("cdbfile.cpp")p Fq(,)f(which)h(is)g(thor)o(oughly)f(commented)g(and)h(should)g(help)1651837 y(you)g(understand)h(my)f(somehow)f(foggy)h(and)g(twisted)f(ideas.)165 1958 y Fj(3.3)50 b(The)13 b(CField)f(object)1652035 y Fq(It)e(is)g(described)h(in)g(the)f(header)h(\256le)f(as)g(follows)f(:)165 2106 y Fg(class)20 b(CField)165 2146y({)165 2185 y(private)f(:)205 2225 y(char)279 b(Name[11];)79

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -