00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100 #include "udanax.h"
00101 #include "players.h"
00102 #include "requests.h"
00103
00104 bool getfinddocscontaining(Session * sess, typespecset * specsetptr);
00105 bool getcopy(Session * sess, IStreamAddr * docisaptr, IStreamAddr * vsaptr, typespecset * localspecsetptr);
00106 bool getinsert(Session * sess, IStreamAddr * docisaptr, Tumbler * vsaptr, typetextset * textsetptr);
00107 bool getcreatelink(Session * sess, IStreamAddr * docisaptr, typespecset * fromspecsetptr, typespecset * tospecsetptr, typespecset * threespecsetptr);
00108 bool getfollowlink(Session * sess, IStreamAddr * linkisaptr, int * whichendptr);
00109 bool getcreatenewversion(Session * sess, IStreamAddr * docisaptr);
00110 bool getretrievedocvspanset(Session * sess, IStreamAddr * docisaptr);
00111 bool getretrievedocvspan(Session * sess, IStreamAddr * docisaptr);
00112 bool getrearrange(Session * sess, IStreamAddr * docisaptr, typecutseq * cutseqptr);
00113 bool getretrievev(Session * sess, typespecset * specsetptr);
00114 bool getfindlinksfromtothree(Session * sess, typespecset * fromvspecsetptr, typespecset * tovspecsetptr, typespecset * threevspecsetptr, typeispanset * homesetptr);
00115 bool getfindnumoflinksfromtothree(Session * sess, typespecset * fromvspecsetptr, typespecset * tovspecsetptr, typespecset * threevspecsetptr, typeispanset * homesetptr);
00116 bool getfindnextnlinksfromtothree(Session * sess, typespecset * fromvspecsetptr, typespecset * tovspecsetptr, typespecset * threevspecsetptr, typeispanset * homesetptr, IStreamAddr * lastlinkptr, int * nptr);
00117 bool getshowrelationof2versions(Session * sess, typespecset * version1ptr, typespecset * version2ptr);
00118 void getcreatenewdocument();
00119 bool getdeletevspan(Session * sess, IStreamAddr * docisaptr, typevspan * vspanptr);
00120 void setdebug(Session * sess);
00121 void playwithalloc(Session * sess);
00122 bool getretrieveendsets(Session * sess, typespecset * specsetptr);
00123 bool getxaccount(Session * sess, IStreamAddr * accountptr);
00124 bool getcreatenode_or_account(Session *sess, Tumbler *tp);
00125 bool getopen(Session *sess, Tumbler *tp, int *typep, int *modep);
00126 bool getclose(Session *sess, Tumbler *tp);
00127 bool gettumbler(Session * sess, Tumbler * tumblerptr);
00128
00129 void prompt(Session * sess, char *string);
00130 void error(Session * sess, char *string);
00131 void puttumbler(FILE * outfile, Tumbler * tumblerptr);
00132 void putnum(FILE * outfile, int num);
00133 void putisa(Session * sess, IStreamAddr * isaptr);
00134 void putitemset(Session * sess, typeitemset itemset);
00135 void putitem(Session * sess, typeitem * itemptr);
00136 void putspan(Session * sess, typespan * spanptr);
00137 void puttext(Session * sess, typetext * textptr);
00138 void putspanpairset(Session * sess, typespanpairset spanpairset);
00139 void putspanpair(Session * sess, typespanpair * spanpair);
00140 void putcreatelink(Session * sess, IStreamAddr * istreamptr);
00141 void putfollowlink(Session * sess, typespecset specset);
00142 void putretrievedocvspanset(Session * sess, typespanset * spansetptr);
00143 void putretrievedocvspan(Session * sess, typespan * vspanptr);
00144 void putretrievev(Session * sess, typevstuffset * vstuffsetptr);
00145 void putfindlinksfromtothree(Session * sess, typelinkset linkset);
00146 void putfindnumoflinksfromtothree(Session * sess, int num);
00147 void putfindnextnlinksfromtothree(Session * sess, int n, typelinkset nextlinkset);
00148 void putshowrelationof2versions(Session * sess, typespanpairset relation);
00149 void putcreatenewdocument(Session * sess, IStreamAddr * newdocisaptr);
00150 void putcreatenewversion(Session * sess, IStreamAddr * newdocisaptr);
00151 void putfinddocscontaining(Session * sess, typeitemset addressset);
00152 void putretrieveendsets(Session * sess, typespecset fromset, typespecset toset, typespecset threeset);
00153 void putinsert(Session * sess);
00154 void putcopy(Session * sess);
00155 void putdeletevspan(Session * sess);
00156 void putrearrange(Session * sess);
00157 void putrequestfailed(Session * sess);
00158 void putxaccount(Session * sess);
00159 void putcreatenode_or_account(Session * sess, Tumbler * tp);
00160 void putopen(Session * sess, Tumbler * tp);
00161 void putclose(Session * sess);
00162 void putquitxanadu(Session * sess);
00163
00164 extern FILE *interfaceinput;
00165
00166 extern int backenddaemon;
00167
00168 extern bool docreatenewversion(Session *sess, IStreamAddr *isaptr, IStreamAddr *wheretoputit, IStreamAddr *newisaptr);
00169
00177 void
00178 finddocscontaining(
00179 Session *sess)
00180 {
00181 typespecset specset;
00182 typelinkset addressset;
00183
00184 if (getfinddocscontaining(sess, &specset) && dofinddocscontaining(sess, specset, &addressset))
00185 putfinddocscontaining(sess, (typeitemset) addressset);
00186 else
00187 putrequestfailed(sess);
00188 }
00189
00197 void
00198 copy(
00199 Session *sess)
00200 {
00201 IStreamAddr docisa, vsa;
00202 typespecset localspecset;
00203
00204 if (getcopy(sess, &docisa, &vsa, &localspecset) && docopy(sess, &docisa, &vsa, localspecset))
00205 putcopy(sess);
00206 else
00207 putrequestfailed(sess);
00208 }
00209
00210 #ifdef UnDEfined
00211 void
00212 copy(
00213 Session * sess)
00214 {
00215 IStreamAddr docisa, vsa;
00216 typespecset localspecset;
00217
00218 getcopy(sess, &docisa, &vsa, &localspecset);
00219 putcopy(sess);
00220
00221 if (!docopy(sess, &docisa, &vsa, &localspecset))
00222
00223
00224 #ifndef DISTRIBUTION
00225 L("copy failed \n");
00226 #else
00227 ;
00228 #endif
00229 }
00230 #endif
00231
00232
00233
00234
00235
00243 void
00244 insert(
00245 Session *sess)
00246 {
00247 IStreamAddr docisa, vsa;
00248 typetextset textset;
00249
00250 getinsert(sess, &docisa, &vsa, &textset);
00251 putinsert(sess);
00252
00253 if (!doinsert(sess, &docisa, &vsa, textset))
00254 #ifndef DISTRIBUTION
00255 L("requestfailed in insert\n");
00256 #else
00257 ;
00258 #endif
00259 }
00260
00268 void
00269 createlink(
00270 Session *sess)
00271 {
00272 IStreamAddr docisa, linkisa;
00273 typespecset fromspecset, tospecset, threespecset;
00274
00275 if (getcreatelink(sess, &docisa, &fromspecset, &tospecset, &threespecset)
00276 && docreatelink(sess, &docisa, fromspecset, tospecset, threespecset, &linkisa)) {
00277 putcreatelink(sess, &linkisa);
00278 } else
00279 putrequestfailed(sess);
00280 }
00281
00289 void
00290 followlink(
00291 Session *sess)
00292 {
00293 IStreamAddr linkisa;
00294 typespecset specset;
00295 int whichend;
00296
00297 if (getfollowlink(sess, &linkisa, &whichend)
00298 && dofollowlink(sess, &linkisa, &specset, whichend)) {
00299 putfollowlink(sess, specset);
00300 } else
00301 putrequestfailed(sess);
00302 }
00303
00311 void
00312 retrievedocvspanset(
00313 Session *sess)
00314 {
00315 IStreamAddr docisa;
00316 typevspanset vspanset;
00317
00318 if (getretrievedocvspanset(sess, &docisa)
00319 && doretrievedocvspanset(sess, &docisa, &vspanset))
00320 putretrievedocvspanset(sess, &vspanset);
00321 else
00322 putrequestfailed(sess);
00323 }
00324
00325
00326
00327
00328
00336 void
00337 rearrange(
00338 Session *sess)
00339 {
00340 IStreamAddr docisa;
00341 typecutseq cutseq;
00342
00343 (void)getrearrange(sess, &docisa, &cutseq);
00344 putrearrange(sess);
00345 if (!dorearrange(sess, &docisa, &cutseq))
00346 #ifndef DISTRIBUTION
00347 L("rearrange failed \n");
00348 #else
00349 ;
00350 #endif
00351 }
00352
00360 void
00361 retrievev(
00362 Session *sess)
00363 {
00364 typespecset specset;
00365 typevstuffset vstuffset;
00366
00367 if (getretrievev(sess, &specset)
00368 && doretrievev(sess, specset, &vstuffset))
00369 putretrievev(sess, &vstuffset);
00370 else
00371 putrequestfailed(sess);
00372 }
00373
00381 void
00382 findlinksfromtothree(
00383 Session *sess)
00384 {
00385 typespecset fromvspecset, tovspecset, threevspecset;
00386 typeispanset homeset;
00387 typelinkset linkset;
00388
00389 if (getfindlinksfromtothree(sess, &fromvspecset, &tovspecset, &threevspecset, &homeset)
00390 && dofindlinksfromtothree(sess, fromvspecset, tovspecset, threevspecset, (typeispan *) NULL ,
00391 &linkset))
00392 putfindlinksfromtothree(sess, linkset);
00393 else
00394 putrequestfailed(sess);
00395 }
00396
00404 void
00405 findnumoflinksfromtothree(
00406 Session *sess)
00407 {
00408 typespecset fromvspecset, tovspecset, threevspecset;
00409 typeispanset homeset;
00410 int numberoflinks;
00411
00412 if (getfindnumoflinksfromtothree(sess, &fromvspecset, &tovspecset, &threevspecset, &homeset)
00413 && dofindnumoflinksfromtothree(sess, (typespec **) fromvspecset, (typespec **) tovspecset, (typespec **) threevspecset, homeset, &numberoflinks))
00414 putfindnumoflinksfromtothree(sess, numberoflinks);
00415 else
00416 putrequestfailed(sess);
00417 }
00418
00426 void
00427 findnextnlinksfromtothree(
00428 Session *sess)
00429 {
00430 typespecset fromvspecset, tovspecset, threevspecset;
00431 typeispanset homeset;
00432 IStreamAddr lastlink;
00433 typelinkset nextlinkset;
00434 int n;
00435
00436 if (getfindnextnlinksfromtothree(sess, &fromvspecset, &tovspecset, &threevspecset, &homeset, &lastlink, &n)
00437 && dofindnextnlinksfromtothree(sess, (typevspec *) fromvspecset, (typevspec *) tovspecset, (typevspec *) threevspecset, homeset, &lastlink,
00438 &nextlinkset, &n))
00439 putfindnextnlinksfromtothree(sess, n, nextlinkset);
00440 else
00441 putrequestfailed(sess);
00442 }
00443
00451 void
00452 navigateonht(
00453 Session *sess)
00454 {
00455 #ifndef DISTRIBUTION
00456 error(sess, "GACK ! (historical trace)\n");
00457 #endif
00458
00459
00460
00461
00462
00463
00464 }
00465
00473 void
00474 showrelationof2versions(
00475 Session *sess)
00476 {
00477 typespecset version1, version2;
00478 typespanpairset relation;
00479
00480 if (getshowrelationof2versions(sess, &version1, &version2)
00481 && doshowrelationof2versions(sess, version1, version2, &relation))
00482 putshowrelationof2versions(sess, relation);
00483 else
00484 putrequestfailed(sess);
00485 }
00486
00487
00488
00489
00490
00491
00492
00493
00494
00495
00503 void
00504 createnewdocument(
00505 Session *sess)
00506 {
00507 IStreamAddr newdocisa;
00508
00509 getcreatenewdocument();
00510 if (docreatenewdocument(sess, &newdocisa))
00511 putcreatenewdocument(sess, &newdocisa);
00512 else
00513 putrequestfailed(sess);
00514 }
00515
00523 void
00524 createnewversion(
00525 Session *sess)
00526 {
00527 IStreamAddr originaldocisa, newdocisa;
00528
00529 if (getcreatenewversion(sess, &originaldocisa)
00530 && docreatenewversion(sess, &originaldocisa, &originaldocisa, &newdocisa))
00531 putcreatenewversion(sess, &newdocisa);
00532 else
00533 putrequestfailed(sess);
00534 }
00535
00543 void
00544 retrievedocvspan(
00545 Session *sess)
00546 {
00547 IStreamAddr docisa;
00548 typevspan vspan;
00549
00550 if (getretrievedocvspan(sess, &docisa)
00551 && doretrievedocvspan(sess, &docisa, &vspan))
00552 putretrievedocvspan(sess, &vspan);
00553 else
00554 putrequestfailed(sess);
00555 }
00556
00557
00558
00559
00560
00561
00562
00563
00564
00572 void
00573 deletevspan(
00574 Session *sess)
00575 {
00576 IStreamAddr docisa;
00577 typespan vspan;
00578
00579 (void)getdeletevspan(sess, &docisa, &vspan);
00580 putdeletevspan(sess);
00581 if (!dodeletevspan(sess, &docisa, &vspan))
00582 #ifndef DISTRIBUTION
00583 L("deletevspan failed \n");
00584 #else
00585 ;
00586 #endif
00587 }
00588
00596 void
00597 retrieveendsets(
00598 Session *sess)
00599 {
00600 typespecset specset, fromset, toset, threeset;
00601
00602 if (getretrieveendsets(sess, &specset)
00603 && doretrieveendsets(sess, specset, &fromset, &toset, &threeset)) {
00604
00605 putretrieveendsets(sess, fromset, toset, threeset);
00606 } else
00607 putrequestfailed(sess);
00608 }
00609
00617 void
00618 xaccount(
00619 Session *sess)
00620 {
00621 if (getxaccount(sess, (IStreamAddr *) &(player[user].account))) {
00622 putxaccount(sess);
00623 } else {
00624 putrequestfailed(sess);
00625 }
00626 }
00627
00635 void
00636 createnode_or_account(
00637 Session *sess)
00638 {
00639 IStreamAddr t;
00640
00641 if (getcreatenode_or_account(sess, &t)
00642 && docreatenode_or_account(sess, &t)) {
00643 putcreatenode_or_account(sess, &t);
00644 } else {
00645 putrequestfailed(sess);
00646 }
00647 }
00648
00656 void
00657 myopen(
00658 Session *sess)
00659 {
00660 IStreamAddr t, newt;
00661 int type, mode;
00662
00663 if (getopen(sess, &t, &type, &mode)
00664 && doopen(sess, &t, &newt, type, mode)) {
00665 putopen(sess, &newt);
00666 } else {
00667 putrequestfailed(sess);
00668 }
00669 }
00670
00678 void
00679 myclose(
00680 Session *sess)
00681 {
00682 IStreamAddr t;
00683
00684 if (getclose(sess, &t)
00685 && doclose(sess, &t)) {
00686 putclose(sess);
00687 } else {
00688 putrequestfailed(sess);
00689 }
00690 }
00691
00699 void
00700 quitxanadu(
00701 Session *sess)
00702 {
00703 putquitxanadu(sess);
00704
00705 if (!backenddaemon) {
00706 if (interfaceinput) {
00707 fprintf(interfaceinput, "%d~\n", QUIT);
00708 fclose(interfaceinput);
00709 }
00710 diskexit();
00711 } else
00712 closeberts(sess);
00713 }
00714
00722 void
00723 examine(
00724 Session *sess)
00725 {
00726 #ifndef DISTRIBUTION
00727 char c;
00728
00729
00730
00731 prompt(sess, "\nspanf (s), orgl (o) or istream (i) ? ");
00732 c = getc(sess->inp);
00733 if (c != '\n')
00734 getc(sess->inp);
00735
00736 L("\n");
00737 switch (c) {
00738 case 'i':
00739 showistream((typecuc *) granf);
00740 break;
00741 case 's':
00742 showspanf((typecuc *) spanf);
00743 break;
00744
00745 case 'o':
00746
00747
00748 showorgl(sess);
00749 break;
00750
00751 default:
00752 return;
00753 }
00754 #endif
00755 }
00756
00764 void
00765 showorgl(
00766 Session *sess)
00767 {
00768 #ifndef DISTRIBUTION
00769 typeorgl orgl;
00770 IStreamAddr orglisa;
00771
00772 prompt(sess, "orgl isa => ");
00773 if (!(gettumbler(sess, &orglisa)
00774 && findorgl(sess, granf, &orglisa, &orgl, READBERT))) {
00775 L("\nnot found\n");
00776 } else {
00777 showsubtree((typecorecrum *) orgl);
00778 }
00779 #endif
00780 }
00781
00789 void
00790 showenfilades(
00791 Session *sess)
00792 {
00793 #ifndef DISTRIBUTION
00794 char c;
00795
00796 prompt(sess, "\ngranf (g), spanf (s) or orgl (o) ? ");
00797 c = getc(sess->inp);
00798 if (c != '\n')
00799 getc(sess->inp);
00800
00801 L("\n");
00802
00803 switch (c) {
00804 case 'o': showorgl(sess); break;
00805 case 'g': showsubtree((typecorecrumhedr *) granf); break;
00806 case 's': showsubtree((typecorecrumhedr *) spanf); break;
00807 default: break;
00808 }
00809 #endif
00810 }