server/get1fe.cxx

Go to the documentation of this file.
00001 /**********************************************************************
00002  * Copyright 2002 Jeff Rush <jrush@taupro.com>
00003  * Original Copyright 1979-2002 Udanax.com
00004  *
00005  * This file is part of the Udanax xanalogical storage system.
00006  *
00007  * Udanax is free software; you can redistribute it and/or modify it
00008  * under the terms of the GNU General Public License as published by
00009  * the Free Software Foundation; either version 2 of the License, or
00010  * (at your option) any later version.
00011  *
00012  * Udanax is distributed in the hope that it will be useful, but
00013  * WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with Udanax; if not, write to the Free Software Foundation,
00019  * Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00020  **********************************************************************/
00021 
00030 /* Modification History:
00031  * $Log: get1fe.cxx,v $
00032  * Revision 1.15  2004/09/11 15:02:00  jrush
00033  * Fixed Doxygen tags on all Session parameter arguments.
00034  *
00035  * Revision 1.14  2004/09/11 13:59:21  jrush
00036  * Changed all fprintf's to stderr to use the Nana library L() macro.  Also
00037  * removed a 2-3 minor compiler warnings.
00038  *
00039  * Revision 1.13  2004/09/04 16:02:18  jrush
00040  * Added Doxygen headers before each and every function definition.
00041  *
00042  * Revision 1.12  2002/05/28 03:58:42  jrush
00043  * Sources modified to comply with GPL licensing.
00044  *
00045  * Revision 1.11  2002/04/16 22:39:50  jrush
00046  * Converted many #defines into enumeration types instead, and adjusted
00047  * function prototypes accordingly.
00048  *
00049  * Revision 1.10  2002/04/12 11:48:50  jrush
00050  * Major reorganization of includes into a single base-include style.
00051  *
00052  * Revision 1.9  2002/04/10 18:01:54  jrush
00053  * Renamed class typeisa to IStreamAddr.
00054  *
00055  * Revision 1.8  2002/04/09 21:45:46  jrush
00056  * Renamed class 'tumbler' to 'Tumbler', for consistency with Python sources,
00057  * and changed typeisa from typedef to a subclass, in preparation for cleaning
00058  * up the type/class tree.
00059  *
00060  * Revision 1.7  2002/04/06 19:51:30  jrush
00061  * Renamed TRUE/FALSE constant use to the C++ standard of true/false.
00062  *
00063  * Revision 1.6  2002/04/06 17:05:57  jrush
00064  * Switched from referring to 'task' for a client connection to 'session',
00065  * and converted the typetask typedef/struct into a Session C++ class.
00066  *
00067  * Revision 1.5  2002/04/06 15:01:45  jrush
00068  * Changed INT to just 'int'.
00069  *
00070  * Revision 1.4  2002/02/14 10:08:25  jrush
00071  * Cleaned up source:
00072  *
00073  * 1. ran thru the indent tool to achieve a standard look,
00074  * 2. added structured comments at top for use with DOxygen reporting
00075  *    as well as CVS keywords,
00076  * 3. centralized prototypes in protos.h, removing incomplete ones,
00077  * 4. cleaned up use of bool/BOOLEAN type to suit C++ type,
00078  * 5. fixed initializer nesting in tumbler constants,
00079  * 6. converted select() int bits into ANSI fd_set type,
00080  * 7. added Makefile.am for use by automake.
00081  *
00082  */
00083 
00084 #include "udanax.h"
00085 #include "requests.h"
00086 
00087 extern FILE *logfile;
00088 extern FILE *nulllog;
00089 extern FILE *reallog;
00090 extern bool logstuff;
00091 extern FILE *interfaceinput;
00092 
00093 bool  gettumbler(Session * sess, Tumbler * tumblerptr);
00094 bool  gettextset(Session * sess, typetextset * textsetptr);
00095 bool  getspecset(Session * sess, typespecset * specsetptr);
00096 bool  getcutseq(Session * sess, typecutseq * cutseqptr);
00097 bool  getspanset(Session * sess, typespanset * spansetptr, typeitemid id);
00098 bool  kluge();
00099 bool  getnumber(Session * sess, int * numptr);
00100 bool  getspan(Session * sess, typespan * spanptr, typeitemid id);
00101 void  prompt(Session * sess, char *string);
00102 bool  getfindlinksfromtothree(Session * sess, typespecset * fromvspecsetptr, typespecset * tovspecsetptr, typespecset * threevspecsetptr, typeispanset * homesetptr);
00103 bool  validaccount(Session * sess, IStreamAddr * accountptr);
00104 
00112     bool
00113 getinsert(
00114     Session     *sess,    
00115     IStreamAddr *docisaptr,
00116     Tumbler     *vsaptr,
00117     typetextset *textsetptr)
00118 {
00119 /* logfile = reallog; fprintf (logfile, "\nINSERT\n"); */
00120     logstuff = true;
00121     fprintf(interfaceinput, "%d~", INSERT);
00122     return (gettumbler(sess, docisaptr)
00123             && gettumbler(sess, vsaptr)
00124             && gettextset(sess, textsetptr));
00125 /* 
00126  * if (! gettumbler (sess, docisaptr)) return (false);
00127  * L("\ndocid "); puttumbler(stderr,docisaptr); if (! gettumbler 
00128  * (sess, vsaptr)) return (false); L("\nvsa ");
00129  * puttumbler(stderr,vsaptr); L("\n"); if (! gettextset
00130  * (sess, textsetptr)) return (false); return (true); */
00131 }
00132 
00140     bool
00141 getretrievedocvspanset(
00142     Session     *sess,    
00143     IStreamAddr *docisaptr)
00144 {
00145 /* fprintf (logfile, "\nRETRIEVEDOCVSPANSET\n"); */
00146     return (gettumbler(sess, docisaptr));
00147 }
00148 
00156     bool
00157 getcopy(
00158     Session     *sess,    
00159     IStreamAddr *docisaptr,
00160     IStreamAddr *vsaptr,
00161     typespecset *localspecsetptr)
00162 {
00163 /* logfile = reallog; fprintf (logfile, "\nCOPY\n"); */
00164     logstuff = true;
00165     fprintf(interfaceinput, "%d~", COPY);
00166     return (gettumbler(sess, docisaptr)
00167             && gettumbler(sess, vsaptr)
00168             && getspecset(sess, localspecsetptr));
00169 }
00170 
00178     bool
00179 getrearrange(
00180     Session     *sess,    
00181     IStreamAddr *docisaptr,
00182     typecutseq  *cutseqptr)
00183 {
00184 /* logfile = reallog; fprintf (logfile, "\nREARRANGE\n"); */
00185     logstuff = true;
00186     fprintf(interfaceinput, "%d~", REARRANGE);
00187     return (gettumbler(sess, docisaptr)
00188             && getcutseq(sess, cutseqptr));
00189 }
00190 
00198     bool
00199 getcreatelink(
00200     Session     *sess,    
00201     IStreamAddr *docisaptr,
00202     typespecset *fromspecsetptr,
00203     typespecset *tospecsetptr,
00204     typespecset *threespecsetptr)
00205 {
00206     logstuff = true;
00207     fprintf(interfaceinput, "%d~", CREATELINK);
00208     return (gettumbler(sess, docisaptr)
00209             && getspecset(sess, fromspecsetptr)
00210             && getspecset(sess, tospecsetptr)
00211             && getspecset(sess, threespecsetptr));
00212 }
00213 
00221     bool
00222 getretrievev(
00223     Session     *sess,    
00224     typespecset *specsetptr)
00225 {
00226 /* fprintf (logfile, "\nRETRIEVEV\n"); */
00227 
00228     if (getspecset(sess, specsetptr)) {
00229         return (true);
00230     } else {
00231         return (false);
00232     }
00233 }
00234 
00242     bool
00243 getfindnumoflinksfromtothree(
00244     Session      *sess,    
00245     typespecset  *fromvspecsetptr,
00246     typespecset  *tovspecsetptr,
00247     typespecset  *threevspecsetptr,
00248     typeispanset *homesetptr)
00249 {
00250     return (getfindlinksfromtothree(sess, fromvspecsetptr, tovspecsetptr, threevspecsetptr, homesetptr));
00251 }
00252 
00260     bool
00261 getfindlinksfromtothree(
00262     Session      *sess,    
00263     typespecset  *fromvspecsetptr,
00264     typespecset  *tovspecsetptr,
00265     typespecset  *threevspecsetptr,
00266     typeispanset *homesetptr)
00267 {
00268     return (getspecset(sess, fromvspecsetptr)
00269             && getspecset(sess, tovspecsetptr)
00270             && getspecset(sess, threevspecsetptr)
00271             && getspanset(sess, homesetptr, ISPANID) && kluge());
00272 }
00273 
00281     bool
00282 getfindnextnlinksfromtothree(
00283     Session      *sess,    
00284     typespecset  *fromvspecsetptr,
00285     typespecset  *tovspecsetptr,
00286     typespecset  *threevspecsetptr,
00287     typeispanset *homesetptr,
00288     IStreamAddr  *lastlinkptr,
00289     int          *nptr)
00290 {
00291     return getfindlinksfromtothree(sess, fromvspecsetptr, tovspecsetptr, threevspecsetptr, homesetptr)
00292             && gettumbler(sess, lastlinkptr)
00293             && getnumber(sess, nptr);
00294 }
00295 
00303     bool
00304 getshowrelationof2versions(
00305     Session     *sess,    
00306     typespecset *version1ptr,
00307     typespecset *version2ptr)
00308 {
00309     return getspecset(sess, version1ptr)
00310             && getspecset(sess, version2ptr);
00311 }
00312 
00320 /* createnewdocument - no get routine */
00321     void
00322 getcreatenewdocument()
00323 {
00324     logstuff = true;
00325     fprintf(interfaceinput, "%d~", CREATENEWDOCUMENT);
00326 }
00327 
00335     bool
00336 getdeletevspan(
00337     Session     *sess,    
00338     IStreamAddr *docisaptr,
00339     typevspan   *vspanptr)
00340 {
00341 /* logfile = reallog; fprintf (logfile, "\nDELETEVSPAN\n"); */
00342     logstuff = true;
00343     fprintf(interfaceinput, "%d~", DELETEVSPAN);
00344     return (gettumbler(sess, docisaptr)
00345             && getspan(sess, vspanptr, VSPANID));
00346 }
00347 
00355     bool
00356 getcreatenewversion(
00357     Session     *sess,    
00358     IStreamAddr *docisaptr)
00359 {
00360 /* logfile = reallog; fprintf (logfile, "\nCREATENEWVERSION\n"); */
00361     logstuff = true;
00362     fprintf(interfaceinput, "%d~", CREATENEWVERSION);
00363     return (gettumbler(sess, docisaptr));
00364 }
00365 
00373     bool
00374 getretrievedocvspan(
00375     Session     *sess,    
00376     IStreamAddr *docisaptr)
00377 {
00378 /* fprintf (logfile, "\nRETRIEVEDOCVSPAN\n"); */
00379     return (gettumbler(sess, docisaptr));
00380 }
00381 
00389     void
00390 setdebug(
00391     Session *sess)    
00392 {
00393     getnumber(sess, &debug);
00394 }
00395 
00396 /* disk exit */
00397 
00398 /* show enfilades */
00399 
00407     bool
00408 getfollowlink(
00409     Session     *sess,    
00410     IStreamAddr *linkisaptr,
00411     int         *whichendptr)
00412 {
00413 /* fprintf (logfile, "\nFOLLOWLINK\n"); */
00414     return getnumber(sess, whichendptr)
00415             && gettumbler(sess, linkisaptr);
00416 }
00417 
00418 /* examine */
00419 
00420 /* source unix command */
00421 
00429     bool
00430 getfinddocscontaining(
00431     Session     *sess,    
00432     typespecset *specsetptr)
00433 {
00434 /* fprintf (logfile, "\nFINDDOCSCONTAINING\n"); */
00435     return getspecset(sess, specsetptr);
00436 }
00437 
00445     bool
00446 getretrieveendsets(
00447     Session     *sess,    
00448     typespecset *specsetptr)
00449 {
00450 /* fprintf (logfile, "\nRETRIEVEENDSETS\n"); */
00451     return getspecset(sess, specsetptr);
00452 }
00453 
00461     bool
00462 kluge()
00463 {
00464    /* fclose (reallog); reallog = fopen("xueditlog","a"); */ return (true);
00465 }
00466 
00474     void
00475 playwithalloc(
00476     Session *sess)    
00477 {
00478     prompt(sess, "playwithalloc\n");
00479     lookatalloc();
00480 }
00481 
00482 #include "players.h"
00483 
00491     bool
00492 getxaccount(
00493     Session     *sess,    
00494     IStreamAddr *accountptr)
00495 {
00496     logstuff = true;
00497     if (interfaceinput)
00498         fprintf(interfaceinput, "%d~", XACCOUNT);
00499 
00500     gettumbler(sess, accountptr)
00501             && validaccount(sess, accountptr);
00502     player[user].account = *accountptr;
00503     sess->account = *accountptr;
00504     return (true);
00505 }
00506 
00514     bool
00515 getcreatenode_or_account(
00516     Session *sess,    
00517     Tumbler *tp)
00518 {
00519     logstuff = true;
00520     if (interfaceinput)
00521         fprintf(interfaceinput, "%d~", CREATENODE_OR_ACCOUNT);
00522     gettumbler(sess, tp);
00523     return (true);
00524 
00525 }
00526 
00534     void
00535 logaccount(
00536     Tumbler *tp)
00537 {
00538     if (interfaceinput) {
00539         fprintf(interfaceinput, "%d~", XACCOUNT);
00540         puttumbler(interfaceinput, tp);
00541     }
00542 }
00543 
00551     bool
00552 getclose(
00553     Session *sess,    
00554     Tumbler *tp)
00555 {
00556     logstuff = true;
00557     if (interfaceinput)
00558         fprintf(interfaceinput, "%d~", CLOSE);
00559     gettumbler(sess, tp);
00560     return (true);
00561 }
00562 
00570     bool
00571 getopen(
00572     Session *sess,    
00573     Tumbler *tp,
00574     int     *typep,
00575     int     *modep)
00576 {
00577     logstuff = true;
00578     if (interfaceinput)
00579         fprintf(interfaceinput, "%d~", OPEN);
00580     gettumbler(sess, tp);
00581     getnumber(sess, typep);
00582     getnumber(sess, modep);
00583     return (*typep != NOBERTREQUIRED);
00584 }

Generated on Sun Aug 21 04:18:15 2005 for Udanax-Green by doxygen1.3.4