Annotation of Amaya/amaya/query.c, revision 1.93

1.14      cvs         1: /*
                      2:  *
                      3:  *  (c) COPYRIGHT MIT and INRIA, 1996.
                      4:  *  Please first read the full copyright statement in file COPYRIGHT.
                      5:  *
                      6:  */
1.4       cvs         7: 
1.19      cvs         8: /*
1.83      cvs         9:  * query.c : contains all the functions for requesting and publishing
1.19      cvs        10:  * URLs via libwww. It handles any eventual HTTP error code
                     11:  * (redirection, authentication needed, not found, etc.)
                     12:  *
1.69      cvs        13:  * Author: J. Kahan
1.92      cvs        14:  *         J. Kahan/R. Guetari Windows 95/NT routines
1.19      cvs        15:  */
1.17      cvs        16: 
1.44      cvs        17: #ifndef AMAYA_JAVA
                     18: 
1.12      cvs        19: /* Amaya includes  */
1.25      cvs        20: #define THOT_EXPORT extern
1.4       cvs        21: #include "amaya.h"
1.70      cvs        22: #ifdef _WINDOWS 
                     23: #include <fcntl.h>
                     24: #endif /* _WINDOWS */
1.7       cvs        25: 
1.4       cvs        26: #if defined(__svr4__)
                     27: #define CATCH_SIG
                     28: #endif
                     29: 
                     30: /* local structures coming from libwww and which are
1.17      cvs        31:    not found in any .h file
1.7       cvs        32:  */
1.68      cvs        33: 
1.7       cvs        34: struct _HTStream
                     35:   {
1.15      cvs        36:      const HTStreamClass *isa;
                     37:      FILE               *fp;
1.45      cvs        38:      BOOL                leave_open;   /* Close file when TtaFreeMemory? */
1.15      cvs        39:      char               *end_command;  /* Command to execute       */
                     40:      BOOL                remove_on_close;      /* Remove file?             */
                     41:      char               *filename;     /* Name of file             */
                     42:      HTRequest          *request;      /* saved for callback       */
                     43:      HTRequestCallback  *callback;
1.7       cvs        44:   };
                     45: 
1.15      cvs        46: 
1.7       cvs        47: struct _HTError
                     48:   {
                     49:      HTErrorElement      element;      /* Index number into HTError */
                     50:      HTSeverity          severity;     /* A la VMS */
                     51:      BOOL                ignore;       /* YES if msg should not go to user */
                     52:      void               *par;  /* Explanation, e.g. filename  */
                     53:      int                 length;       /* For copying by generic routine */
                     54:      char               *where;        /* Which function */
                     55:   };
                     56: 
                     57: 
                     58: struct _HTHost
                     59:   {
                     60:      char               *hostname;     /* name of host + optional port */
                     61:      time_t              ntime;        /* Creation time */
                     62:      char               *type; /* Peer type */
                     63:      int                 version;      /* Peer version */
                     64:      HTMethod            methods;      /* Public methods (bit-flag) */
                     65:      char               *server;       /* Server name */
                     66:      char               *user_agent;   /* User Agent */
                     67:      char               *range_units;  /* Acceptable range units */
                     68:      HTTransportMode     mode; /* Supported mode */
                     69:      HTChannel          *channel;      /* Persistent channel */
                     70:      HTList             *pipeline;     /* Pipe line of net objects */
                     71:      HTList             *pending;      /* List of pending Net objects */
                     72:      time_t              expires;      /* Persistent channel expires time */
                     73:   };
1.4       cvs        74: 
                     75: /* Type definitions and global variables etc. local to this module */
                     76: 
1.17      cvs        77: /*----------------------------------------------------------------------*/
                     78: 
1.4       cvs        79: /*** private variables ***/
1.17      cvs        80: 
1.4       cvs        81: static HTList      *converters = NULL; /* List of global converters */
1.27      cvs        82: static HTList      *acceptTypes = NULL; /* List of types for the Accept header */
1.4       cvs        83: static HTList      *encodings = NULL;
1.16      cvs        84: static int          object_counter = 0;        /* loaded objects counter */
1.24      cvs        85: static  boolean    AmayaIsAlive;
1.4       cvs        86: 
1.15      cvs        87: #include "answer_f.h"
                     88: #include "query_f.h"
                     89: #include "AHTURLTools_f.h"
                     90: #include "AHTBridge_f.h"
                     91: #include "AHTMemConv_f.h"
                     92: #include "AHTFWrite_f.h"
1.4       cvs        93: 
1.70      cvs        94: #ifdef _WINDOWS
                     95: #ifdef __STDC__
                     96: int WIN_Activate_Request (HTRequest* , HTAlertOpcode, int, const char*, void*, HTAlertPar*);
                     97: #else
                     98: int WIN_Activate_Request ();
                     99: #endif /* __STDC__ */
                    100: #endif /* _WINDOWS */
1.15      cvs       101: 
                    102: /*----------------------------------------------------------------------
1.17      cvs       103:   GetDocIdStatus
                    104:   gets the status associated to a docid                         
1.15      cvs       105:   ----------------------------------------------------------------------*/
                    106: #ifdef __STDC__
                    107: AHTDocId_Status    *GetDocIdStatus (int docid, HTList * documents)
                    108: #else
                    109: AHTDocID_Status    *GetDocIdStatus (docid, documents)
                    110: int                 docid;
                    111: HTList             *documents;
                    112: 
                    113: #endif
                    114: {
                    115:    AHTDocId_Status    *me;
                    116:    HTList             *cur;
                    117: 
                    118:    if (documents)
                    119:      {
                    120:        cur = documents;
                    121: 
                    122:        while ((me = (AHTDocId_Status *) HTList_nextObject (cur)))
                    123:          {
                    124:             if (me->docid == docid)
                    125:                return (me);
1.18      cvs       126:          }
                    127:      }
1.15      cvs       128:    return (AHTDocId_Status *) NULL;
                    129: 
                    130: }
                    131: 
1.5       cvs       132: /*----------------------------------------------------------------------
1.27      cvs       133:   AHTGuessAtom_for
                    134:   Converts an Amaya type descriptor into the equivalent MIME type.
                    135:   ----------------------------------------------------------------------*/
                    136: #ifdef __STDC__
                    137: static  HTAtom *AHTGuessAtom_for (char *urlName, PicType contentType)
                    138: #else
                    139: static  HTAtom *AHTGuessAtom_for (urlName, contentType)
                    140: char *urlName;
                    141: PicType contentType;
                    142: #endif
                    143: {
                    144:  HTAtom           *atom;
                    145:  char             *filename;
                    146:  HTEncoding        enc;
                    147:  HTEncoding        cte;
                    148:  HTLanguage        lang;
1.50      cvs       149:  double            quality = 1.0;
1.27      cvs       150: 
                    151:  switch (contentType)
                    152:    {
                    153:     case xbm_type:
                    154:       atom = HTAtom_for("image/xbm");
                    155:       break;
                    156:     case eps_type:
1.35      cvs       157:       atom = HTAtom_for("application/postscript");
1.27      cvs       158:       break;
                    159:    case xpm_type:
                    160:       atom = HTAtom_for("image/xpm");
                    161:      break;
                    162:     case gif_type:
                    163:       atom = HTAtom_for("image/gif");
                    164:       break;
                    165:     case jpeg_type:
                    166:       atom = HTAtom_for("image/jpeg");
                    167:       break;
                    168:     case png_type:
                    169:       atom = HTAtom_for("image/png");
                    170:       break;
                    171:    case unknown_type:
                    172:    default:
                    173:      /* 
                    174:      ** Amaya could not detect the type, so 
                    175:      ** we try to use the filename's suffix to do so.
                    176:      */
1.45      cvs       177:      filename = AmayaParseUrl (urlName, "", AMAYA_PARSE_PATH | AMAYA_PARSE_PUNCTUATION);
1.27      cvs       178:      HTBind_getFormat (filename, &atom, &enc, &cte, &lang, &quality);
1.45      cvs       179:      TtaFreeMemory (filename);
1.27      cvs       180:      if (atom ==  WWW_UNKNOWN)
                    181:         /*
                    182:         ** we could not identify the suffix, so we assign it
                    183:         ** a default type
                    184:         */
                    185:         atom = HTAtom_for ("text/html");
                    186:      break;
                    187:    }
                    188: 
                    189:  return atom;
                    190: }
                    191: 
                    192: /*----------------------------------------------------------------------
1.17      cvs       193:   AHTReqContext_new
                    194:   create a new Amaya Context Object and update the global Amaya
                    195:   request status.
1.5       cvs       196:   ----------------------------------------------------------------------*/
1.4       cvs       197: #ifdef __STDC__
                    198: static AHTReqContext *AHTReqContext_new (int docid)
                    199: #else
                    200: static AHTReqContext *AHTReqContext_new (docid)
                    201: int                 docid;
                    202: 
                    203: #endif
                    204: {
                    205:    AHTReqContext      *me;
                    206:    AHTDocId_Status    *docid_status;
                    207: 
                    208:    if ((me = (AHTReqContext *) TtaGetMemory (sizeof (AHTReqContext))) == NULL)
                    209:       outofmem (__FILE__, "Context_new");
                    210: 
1.81      cvs       211:    /* Bind the Context object together with the Request Object */
                    212:    me->request = HTRequest_new ();
                    213:   
1.80      cvs       214:    /* clean the associated file structure) */
1.79      cvs       215:    HTRequest_setOutputStream (me->request, NULL);
1.81      cvs       216:  
1.4       cvs       217:    /* Initialize the other members of the structure */
1.17      cvs       218:    me->reqStatus = HT_NEW; /* initial status of a request */
1.4       cvs       219:    me->output = NULL;
1.89      cvs       220:    me->content_type = NULL;
1.51      cvs       221: #  ifndef _WINDOWS
1.4       cvs       222:    me->read_xtinput_id = (XtInputId) NULL;
                    223:    me->write_xtinput_id = (XtInputId) NULL;
                    224:    me->except_xtinput_id = (XtInputId) NULL;
1.51      cvs       225: #  endif
1.4       cvs       226:    me->docid = docid;
                    227:    HTRequest_setMethod (me->request, METHOD_GET);
                    228:    HTRequest_setOutputFormat (me->request, WWW_SOURCE);
                    229:    HTRequest_setContext (me->request, me);
                    230:    me->read_ops = 0;
                    231:    me->write_ops = 0;
                    232:    me->except_ops = 0;
1.36      cvs       233:    /* experimental */
                    234:    me->read_sock = INVSOC;
                    235:    me->write_sock = INVSOC;
                    236:    me->except_sock = INVSOC;
1.4       cvs       237: 
                    238:    /* Update the global context */
                    239:    HTList_appendObject (Amaya->reqlist, (void *) me);
                    240: 
                    241:    docid_status = GetDocIdStatus (docid, Amaya->docid_status);
                    242: 
1.7       cvs       243:    if (docid_status == NULL)
                    244:      {
                    245:        docid_status = (AHTDocId_Status *) TtaGetMemory (sizeof (AHTDocId_Status));
                    246:        docid_status->docid = docid;
                    247:        docid_status->counter = 1;
                    248:        HTList_addObject (Amaya->docid_status, (void *) docid_status);
                    249:      }
                    250:    else
1.4       cvs       251:       docid_status->counter++;
                    252: 
                    253: 
                    254:    Amaya->open_requests++;
                    255: 
                    256:    /* error stream handling */
                    257:    me->error_stream = (char *) NULL;
                    258:    me->error_stream_size = 0;
1.74      cvs       259: 
                    260: #ifdef DEBUG_LIBWWW
                    261:    fprintf (stderr, "AHTReqContext_new: Created object %p\n", me);
                    262: #endif   
1.4       cvs       263:    return me;
1.74      cvs       264: 
1.4       cvs       265: }
                    266: 
1.5       cvs       267: /*----------------------------------------------------------------------
1.17      cvs       268:   AHTReqContext_delete
                    269:   Delete an Amaya Context Object and update the global Amaya request
                    270:   status.
1.5       cvs       271:   ----------------------------------------------------------------------*/
1.4       cvs       272: 
                    273: #ifdef __STDC__
1.15      cvs       274: boolean   AHTReqContext_delete (AHTReqContext * me)
1.4       cvs       275: #else
1.15      cvs       276: boolean   AHTReqContext_delete (me)
1.4       cvs       277: AHTReqContext      *me;
                    278: 
                    279: #endif
                    280: {
                    281:    AHTDocId_Status    *docid_status;
                    282: 
1.7       cvs       283:    if (me)
                    284:      {
1.4       cvs       285: 
1.74      cvs       286: #ifdef DEBUG_LIBWWW
                    287:         fprintf (stderr, "AHTReqContext_delete: Deleting object %p\n", me);
                    288: #endif   
                    289: 
1.7       cvs       290:        if (Amaya->reqlist)
                    291:           HTList_removeObject (Amaya->reqlist, (void *) me);
1.4       cvs       292: 
1.7       cvs       293:        docid_status = GetDocIdStatus (me->docid, Amaya->docid_status);
1.4       cvs       294: 
1.7       cvs       295:        if (docid_status)
                    296:          {
                    297:             docid_status->counter--;
                    298: 
                    299:             if (docid_status->counter == 0)
                    300:               {
                    301:                  HTList_removeObject (Amaya->docid_status, (void *) docid_status);
                    302:                  TtaFreeMemory ((void *) docid_status);
                    303:               }
                    304:          }
1.79      cvs       305: 
                    306:        if (HTRequest_outputStream (me->request))
                    307:          AHTFWriter_FREE (me->request->output_stream);
1.91      cvs       308: 
1.7       cvs       309:        HTRequest_delete (me->request);
1.85      cvs       310: 
1.89      cvs       311:        if (me->output && me->output != stdout)
1.85      cvs       312:          {     
                    313: #ifdef DEBUG_LIBWWW       
                    314:            fprintf (stderr, "AHTReqContext_delete: URL is  %s, closing "
                    315:                     "FILE %p\n", me->urlName, me->output); 
                    316: #endif
                    317:            fclose (me->output);
                    318:            me->output = NULL;
                    319:          }
1.79      cvs       320:          
1.7       cvs       321:        if (me->error_stream != (char *) NULL)
1.70      cvs       322:          HT_FREE (me->error_stream);
                    323: #     ifndef _WINDOWS
                    324: #     ifdef WWW_XWINDOWS       
1.21      cvs       325:        if (me->read_xtinput_id || me->write_xtinput_id ||
                    326:             me->except_xtinput_id)
                    327:           RequestKillAllXtevents(me);
1.70      cvs       328: #     endif /* WWW_XWINDOWS */
                    329: #     endif /* !_WINDOWS */
1.74      cvs       330: 
                    331:        if ((me->mode & AMAYA_ASYNC) || (me->mode & AMAYA_IASYNC))
                    332:          /* for the ASYNC mode, free the memory we allocated in GetObjectWWW
                    333:             or in PutObjectWWW */
                    334:          {
1.79      cvs       335:             if (me->urlName)
                    336:               TtaFreeMemory (me->urlName);
                    337:             if (me->outputfile)
                    338:               TtaFreeMemory (me->outputfile);
1.74      cvs       339:          }
                    340:    
1.7       cvs       341:        TtaFreeMemory ((void *) me);
1.4       cvs       342: 
1.7       cvs       343:        Amaya->open_requests--;
1.4       cvs       344: 
1.15      cvs       345:        return TRUE;
1.4       cvs       346: 
1.7       cvs       347:      }
1.15      cvs       348:    return FALSE;
1.4       cvs       349: }
                    350: 
                    351: 
1.15      cvs       352: /*----------------------------------------------------------------------
                    353:   AHTUpload_callback
1.17      cvs       354:   callback handler for executing the PUT command
1.15      cvs       355:   ----------------------------------------------------------------------*/
1.4       cvs       356: #ifdef __STDC__
                    357: static int          AHTUpload_callback (HTRequest * request, HTStream * target)
                    358: #else
                    359: static int          AHTUpload_callback (request, target)
                    360: HTRequest          *request;
                    361: HTStream           *target;
                    362: 
                    363: #endif
                    364: {
                    365:    AHTReqContext      *me = HTRequest_context (request);
1.7       cvs       366:    HTParentAnchor     *entity = HTRequest_entityAnchor (request);
                    367:    int                 len = HTAnchor_length (entity);
1.4       cvs       368:    int                 status;
                    369: 
                    370:    /* Send the data down the pipe */
1.7       cvs       371: 
1.4       cvs       372:    status = (*target->isa->put_block) (target, me->mem_ptr, len);
                    373: 
1.7       cvs       374:    if (status == HT_LOADED || status == HT_OK)
                    375:      {
1.13      cvs       376:        if (PROT_TRACE)
                    377:         HTTrace ("Posting Data Target is SAVED\n");
                    378:        (*target->isa->flush) (target);
                    379:        return (HT_LOADED);
1.7       cvs       380:      }
                    381:    if (status == HT_WOULD_BLOCK)
                    382:      {
                    383:        if (PROT_TRACE)
                    384:           HTTrace ("Posting Data Target WOULD BLOCK\n");
1.74      cvs       385: #ifdef _WINDOWS
                    386:        return HT_CONTINUE;
                    387: #else
                    388:        return HT_WOULD_BLOCK;
                    389: #endif /* _WINDOWS */
                    390: 
1.7       cvs       391:        return HT_WOULD_BLOCK;
                    392:      }
                    393:    else if (status == HT_PAUSE)
                    394:      {
                    395:        if (PROT_TRACE)
                    396:           HTTrace ("Posting Data Target PAUSED\n");
                    397:        return HT_PAUSE;
                    398:      }
                    399:    else if (status > 0)
                    400:      {                         /* Stream specific return code */
                    401:        if (PROT_TRACE)
                    402:           HTTrace ("Posting Data. Target returns %d\n", status);
                    403:        return status;
                    404:      }
                    405:    else
                    406:      {                         /* we have a real error */
                    407:        if (PROT_TRACE)
                    408:           HTTrace ("Posting Data Target ERROR %d\n", status);
                    409:        return status;
                    410:      }
1.4       cvs       411: }
                    412: 
1.5       cvs       413: /*----------------------------------------------------------------------
1.17      cvs       414:   Thread_deleteAll
                    415:   this function deletes the whole list of active threads.           
1.5       cvs       416:   ----------------------------------------------------------------------*/
1.4       cvs       417: #ifdef __STDC__
                    418: static void         Thread_deleteAll (void)
                    419: #else
                    420: static void         Thread_deleteAll ()
                    421: #endif
                    422: {
1.21      cvs       423:   HTList             *cur;
                    424:   AHTReqContext      *me;
                    425:   AHTDocId_Status    *docid_status;
                    426: 
1.74      cvs       427:   if (Amaya && Amaya->reqlist)
                    428:     {
                    429:       if (Amaya->open_requests > 0)
                    430: #ifdef DEBUG_LIBWWW
                    431:       fprintf (stderr, "Thread_deleteAll: Killing %d outstanding "
                    432:                       "requests\n", Amaya->open_requests);
                    433: #endif   
                    434:        {
                    435:          cur = Amaya->reqlist;
                    436:          
                    437:          /* erase the requests */
                    438:          while ((me = (AHTReqContext *) HTList_removeLastObject (cur)))
                    439:            {
                    440:              if (me->request)
                    441:                {
1.70      cvs       442: #              ifndef _WINDOWS 
1.74      cvs       443:                  RequestKillAllXtevents (me);
1.70      cvs       444: #              endif /* !_WINDOWS */
1.92      cvs       445: 
                    446:                  if (me->request->net)
                    447:                    HTRequest_kill (me->request);
                    448:                  else
                    449:                    AHTReqContext_delete (me);
1.74      cvs       450:                }
                    451:            }           /* while */
                    452:          
                    453:          /* erase the docid_status entities */
                    454:          while ((docid_status = (AHTDocId_Status *) HTList_removeLastObject ((void *) Amaya->docid_status)))
                    455:            TtaFreeMemory ((void *) docid_status);
                    456:          
                    457:        }                       /* if */
1.84      cvs       458:        
1.74      cvs       459:     }
1.4       cvs       460: }
                    461: 
1.5       cvs       462: /*----------------------------------------------------------------------
1.83      cvs       463:   AHTOpen_file
                    464:   ----------------------------------------------------------------------*/
                    465: #ifdef __STDC__
1.85      cvs       466: int                 AHTOpen_file (HTRequest * request)
1.83      cvs       467: #else
1.85      cvs       468: int                 AHTOpen_file (request)
1.83      cvs       469: HTRequest           *request;
                    470: 
                    471: #endif /* __STDC__ */
                    472: {
                    473:   AHTReqContext      *me;      /* current request */
                    474: 
                    475:   me = HTRequest_context (request);
                    476: 
1.93    ! cvs       477: 
        !           478:   if (!me)
        !           479:       return HT_ERROR;
        !           480: 
1.83      cvs       481: #ifdef DEBUG_LIBWWW
1.85      cvs       482:   fprintf(stderr, "AHTOpen_file: start\n");
                    483: #endif /* DEBUG_LIBWWW */
                    484: 
                    485:   if (me->reqStatus == HT_ABORT) 
                    486:     {
                    487: #ifdef DEBUG_LIBWWW
                    488:       fprintf(stderr, "AHTOpen_file: caught an abort request, skipping it\n");
1.83      cvs       489: #endif /* DEBUG_LIBWWW */
                    490: 
1.85      cvs       491:       return HT_OK;
                    492:     }
                    493: 
                    494:   if (HTRequest_outputStream (me->request)) 
                    495:     {
                    496: 
                    497: #ifdef DEBUG_LIBWWW
                    498:       fprintf(stderr, "AHTOpen_file: output stream already existed for url %s\n", me->urlName);
                    499: #endif /* DEBUG_LIBWWW */      
                    500:       return HT_OK;
                    501:     }
                    502: 
                    503: #ifdef DEBUG_LIBWWW
                    504:       fprintf(stderr, "AHTOpen_file: opening output stream for url %s\n", me->urlName);
                    505: #endif /* DEBUG_LIBWWW */      
                    506: 
1.83      cvs       507:   if (!(me->output) && 
                    508:       (me->output != stdout) && 
                    509: #ifndef _WINDOWS
                    510:       (me->output = fopen (me->outputfile, "w")) == NULL)
                    511:     {
                    512: #else
                    513:     (me->output = fopen (me->outputfile, "wb")) == NULL) 
                    514:     {
                    515: #endif /* !_WINDOWS */
                    516: 
                    517:       me->outputfile[0] = '\0';        /* file could not be opened */
1.85      cvs       518: #ifdef DEBUG_LIBWWW
                    519:       fprintf(stderr, "AHTOpen_file: couldn't open output stream for url %s\n", me->urlName);
                    520: #endif
1.83      cvs       521:       TtaSetStatus (me->docid, 1, 
                    522:                    TtaGetMessage (AMAYA, AM_CANNOT_CREATE_FILE),
                    523:                    me->outputfile);
                    524:       me->reqStatus = HT_ERR;
                    525:       return (HT_ERROR);
                    526:     }
                    527:          
                    528:   HTRequest_setOutputStream (me->request,
                    529:                             AHTFWriter_new (me->request, 
                    530:                                             me->output, YES));
                    531:   me->reqStatus = HT_WAITING;
                    532:   
                    533:   return HT_OK;
                    534: }
                    535: 
                    536: /*----------------------------------------------------------------------
1.17      cvs       537:   redirection_handler
                    538:   this function is registered to handle permanent and temporary
                    539:   redirections.
                    540:   ----------------------------------------------------------------------*/
1.4       cvs       541: #ifdef __STDC__
1.7       cvs       542: static int          redirection_handler (HTRequest * request, HTResponse * response, void *param, int status)
1.4       cvs       543: #else
                    544: static int          redirection_handler (request, context, status)
                    545: HTRequest          *request;
                    546: HTResponse         *response;
                    547: void               *param;
                    548: int                 status;
                    549: 
                    550: #endif
                    551: {
                    552: 
                    553:    char               *ref;
                    554:    HTAnchor           *new_anchor = HTResponse_redirection (response);
1.7       cvs       555:    AHTReqContext      *me = HTRequest_context (request);
1.4       cvs       556:    HTMethod            method = HTRequest_method (request);
                    557: 
                    558: 
1.7       cvs       559:    if (!new_anchor)
                    560:      {
                    561:        if (PROT_TRACE)
                    562:           HTTrace ("Redirection. No destination\n");
                    563:        return HT_OK;
                    564:      }
1.4       cvs       565: 
                    566:    /*
                    567:       ** Only do redirect on GET and HEAD
                    568:     */
1.7       cvs       569:    if (!HTMethod_isSafe (method))
                    570:      {
                    571:        HTAlertCallback    *prompt = HTAlert_find (HT_A_CONFIRM);
                    572: 
                    573:        if (prompt)
                    574:          {
                    575:             if ((*prompt) (request, HT_A_CONFIRM, HT_MSG_REDIRECTION,
                    576:                            NULL, NULL, NULL) != YES)
                    577:                return HT_ERROR;
                    578:          }
                    579:      }
1.4       cvs       580: 
                    581:    /*
                    582:     **  Start new request with the redirect anchor found in the headers.
                    583:     **  Note that we reuse the same request object which means that we must
                    584:     **  keep this around until the redirected request has terminated. It also           
                    585:     **  allows us in an easy way to keep track of the number of redirections
                    586:     **  so that we can detect endless loops.
                    587:     */
1.17      cvs       588:    
1.7       cvs       589:    if (HTRequest_doRetry (request))
                    590:      {
                    591:        /* do we need to normalize the URL? */
                    592:        if (strncmp (new_anchor->parent->address, "http:", 5))
                    593:          {
                    594:             /* Yes, so we use the pre-redirection anchor as a base name */
1.74      cvs       595:             ref = AmayaParseUrl (new_anchor->parent->address, 
                    596:                                  me->urlName, AMAYA_PARSE_ALL);
1.7       cvs       597:             if (ref)
                    598:               {
1.74      cvs       599:                 TtaFreeMemory (new_anchor->parent->address);
                    600:                 new_anchor->parent->address = ref;
1.7       cvs       601:               }
                    602:          }
                    603: 
                    604:        /* update the current file name */
1.21      cvs       605:        if (strlen (new_anchor->parent->address) > (MAX_LENGTH - 2))
1.7       cvs       606:          {
1.74      cvs       607:             strncpy (me->urlName, new_anchor->parent->address, 
                    608:                      MAX_LENGTH - 1);
1.21      cvs       609:             me->urlName[MAX_LENGTH - 1] = EOS;
1.7       cvs       610:          }
                    611:        else
1.74      cvs       612:          strcpy (me->urlName, new_anchor->parent->address);
1.7       cvs       613: 
1.38      cvs       614:        ChopURL (me->status_urlName, me->urlName);
                    615: 
1.7       cvs       616:        TtaSetStatus (me->docid, 1, TtaGetMessage (AMAYA, AM_RED_FETCHING),
1.38      cvs       617:                      me->status_urlName);
1.7       cvs       618: 
                    619:        /* Start request with new credentials */
1.64      cvs       620: 
1.79      cvs       621:        if (HTRequest_outputStream (me->request) != NULL) {
1.85      cvs       622:          AHTFWriter_FREE (request->output_stream);
                    623:          if (me->output != stdout) { /* Are we writing to a file? */
1.74      cvs       624: #ifdef DEBUG_LIBWWW
1.79      cvs       625:          fprintf (stderr, "redirection_handler: New URL is  %s, closing "
1.74      cvs       626:                             "FILE %p\n", me->urlName, me->output); 
                    627: #endif 
1.79      cvs       628:            fclose (me->output);
                    629:            me->output = NULL;
                    630:          }
1.64      cvs       631:        }
1.68      cvs       632: 
1.69      cvs       633:        me->reqStatus = HT_NEW; /* reset the status */
1.7       cvs       634:        if (me->method == METHOD_PUT || me->method == METHOD_POST)      /* PUT, POST etc. */
1.74      cvs       635:          status = HTLoadAbsolute (me->urlName, request);
1.7       cvs       636:        else
1.74      cvs       637:          HTLoadAnchor (new_anchor, request);
1.7       cvs       638:      }
                    639:    else
1.68      cvs       640:      {
1.74      cvs       641:        HTRequest_addError (request, ERR_FATAL, NO, HTERR_MAX_REDIRECT,
                    642:                           NULL, 0, "HTRedirectFilter");
                    643:        TtaSetStatus (me->docid, 1, TtaGetMessage (AMAYA, AM_REDIRECTIONS_LIMIT),
                    644:                     NULL);
                    645:        if (me->error_html)
                    646:         DocNetworkStatus[me->docid] |= AMAYA_NET_ERROR; 
                    647:        /* so that we can show the error message */
1.68      cvs       648:      }
                    649: 
1.4       cvs       650:    /*
1.74      cvs       651:    **  By returning HT_ERROR we make sure that this is the last handler to be
                    652:    **  called. We do this as we don't want any other filter to delete the 
                    653:    **  request object now when we have just started a new one ourselves
                    654:    */
1.4       cvs       655:    return HT_ERROR;
                    656: }
                    657: 
1.5       cvs       658: /*----------------------------------------------------------------------
1.17      cvs       659:   terminate_handler
                    660:   this function is registered to handle the result of the request
1.5       cvs       661:   ----------------------------------------------------------------------*/
1.4       cvs       662: #if __STDC__
1.7       cvs       663: static int          terminate_handler (HTRequest * request, HTResponse * response, void *context, int status)
1.4       cvs       664: #else
                    665: static int          terminate_handler (request, response, context, status)
                    666: HTRequest          *request;
                    667: HTResponse         *response;
                    668: void               *context;
                    669: int                 status;
                    670: #endif
                    671: {
                    672:    AHTReqContext      *me = (AHTReqContext *) HTRequest_context (request);
1.13      cvs       673:    boolean             error_flag;
1.4       cvs       674: 
                    675:    if (!me)
1.74      cvs       676:      return HT_OK;             /* not an Amaya request */
                    677:    
1.80      cvs       678:    /* if Amaya was killed, treat with this request as if it were
                    679:       issued by a Stop button event */
                    680:    if (!AmayaIsAlive)           
                    681:       me->reqStatus = HT_ABORT; 
1.74      cvs       682:    
1.77      cvs       683:    if (status == HT_LOADED || 
                    684:        status == HT_CREATED || 
1.79      cvs       685:        status == HT_NO_DATA ||
                    686:        me->reqStatus == HT_ABORT)
1.74      cvs       687:      error_flag = FALSE;
1.13      cvs       688:    else
1.74      cvs       689:      error_flag = TRUE;
                    690:    
1.4       cvs       691:    /* output any errors from the server */
1.74      cvs       692:    
1.77      cvs       693:    /*
1.74      cvs       694:    ** me->output = output file which will receive an html file
                    695:    ** me->error_html = yes, output HTML errors in the screen
                    696:    ** request->error_stack == if there are any errors, they will be here
                    697:    ** me->error_stream_size If it's != 0 means an error message has already
                    698:    **                       been written to the stack
                    699:    */
                    700:    
1.4       cvs       701:    /* First, we verify if there are any errors and if they are not
1.17      cvs       702:    ** yet written to the error stack. If no, then let's try to write them
                    703:    ** ourselves
                    704:    */
1.74      cvs       705:    
                    706: #ifdef DEBUG_LIBWWW
                    707:    fprintf (stderr, "terminate_handler: URL is "
                    708:            "%s, closing FILE %p status is %d\n", me->urlName, me->output, 
                    709:            status); 
1.69      cvs       710: #endif
1.74      cvs       711:    
1.69      cvs       712:    if (me->output && me->output != stdout)
                    713:      {
1.74      cvs       714:        /* we are writing to a file */
                    715:        if (me->reqStatus != HT_ABORT)
                    716:         {                      /* if the request was not aborted and */
1.80      cvs       717:           if (error_flag &&
                    718:               me->error_html == TRUE)
                    719:               /* there were some errors and we want to print them */
                    720:             {          
                    721:               if (me->error_stream_size == 0)/* and the stream is empty */
                    722:                 AHTError_MemPrint (request); /* copy errors from 
1.74      cvs       723:                                                  **the error stack 
1.77      cvs       724:                                                  ** into the error stream */
1.80      cvs       725:               if (me->error_stream)
                    726:                 {      /* if the stream is non-empty */
                    727:                   fprintf (me->output, me->error_stream);/* output the errors */
1.85      cvs       728:                   /* Clear the error context, so that we can deal with
                    729:                      this answer as if it were a normal reply */
                    730:                    HTError_deleteAll( HTRequest_error (request));
                    731:                    HTRequest_setError (request, NULL);
                    732:                    error_flag = 0;
1.74      cvs       733:                 }
                    734:             }                  /* if error_stack */
1.85      cvs       735:         }
                    736: 
                    737:        /* if != HT_ABORT */
                    738:        
                    739: #ifdef DEBUG_LIBWWW       
                    740:        fprintf (stderr, "terminate_handler: URL is  %s, closing "
                    741:                "FILE %p\n", me->urlName, me->output); 
                    742: #endif
1.74      cvs       743:        fclose (me->output);
                    744:        me->output = NULL;
1.69      cvs       745:      }
1.80      cvs       746: 
1.74      cvs       747:    
1.80      cvs       748:    if (error_flag)
                    749:      me->reqStatus = HT_ERR;
                    750:    else if (me->reqStatus != HT_ABORT)
                    751:      me->reqStatus = HT_END;
                    752: 
1.88      cvs       753:    /* copy the content_type */
                    754:   
                    755:    {
                    756:     char *content_type = request->anchor->content_type->name;
                    757:  
                    758:    if (content_type && content_type [0] && me->content_type)  
                    759:      {
                    760:         /* libwww gives www/unknown when it gets an error. As this is 
                    761:            an HTML test, we force the type to text/html */
                    762:        if (!strcmp (content_type, "www/unknown"))
                    763:           {
                    764:            strcpy (me->content_type, "text/html");
                    765:           }
                    766:         else 
                    767:           { 
                    768:           strncpy (me->content_type, content_type, 
                    769:                    NAME_LENGTH -1);
                    770:            me->content_type [NAME_LENGTH-1] = '\0';
                    771:            
                    772:            /* Content-Type can be specified by a server's admin. To be on
                    773:               the safe side, we normalize its case */
                    774:            ConvertToLowerCase (me->content_type);
                    775:           } 
                    776: #ifdef DEBUG_LIBWWW
                    777:         fprintf (stderr, "content type is: %s\n", me->content_type);
                    778: #endif /* DEBUG_LIBWWW */
                    779:      }
                    780:    }
                    781:  
1.80      cvs       782:   /* don't remove or Xt will hang up during the PUT */
                    783: 
1.28      cvs       784:    if (AmayaIsAlive  && ((me->method == METHOD_POST) ||
                    785:                         (me->method == METHOD_PUT)))
1.7       cvs       786:      {
1.80      cvs       787:        PrintTerminateStatus (me, status);
                    788: 
                    789:      } 
                    790: 
1.72      cvs       791: #ifdef _WINDOWS
1.80      cvs       792:    /* Try to add this to AHTEventrg.c */
1.91      cvs       793:   ProcessTerminateRequest (me);
1.92      cvs       794:   /* kill the windows request here, of course */
1.80      cvs       795: #endif /* WINDOWS */
1.71      cvs       796: 
                    797:   return HT_OK;
1.4       cvs       798: }
                    799: 
1.5       cvs       800: /*----------------------------------------------------------------------
1.17      cvs       801:   AHTLoadTerminate_handler
1.74      cvs       802:   this is an application "AFTER" Callback. It's called by the library
                    803:   when a request has ended, so that we can setup the correct status.
1.5       cvs       804:   ----------------------------------------------------------------------*/
1.4       cvs       805: 
                    806: #ifdef __STDC__
1.7       cvs       807: static int          AHTLoadTerminate_handler (HTRequest * request, HTResponse * response, void *param, int status)
1.4       cvs       808: #else
                    809: static int          AHTLoadTerminate_handler (request, response, param, status)
                    810: HTRequest          *request;
                    811: HTResponse         *response;
                    812: void               *param;
                    813: int                 status;
1.69      cvs       814: 
1.4       cvs       815: #endif
                    816: {
                    817:    AHTReqContext      *me = HTRequest_context (request);
                    818:    HTAlertCallback    *cbf;
                    819:    AHTDocId_Status    *docid_status;
                    820: 
1.7       cvs       821:    switch (status)
                    822:         {
                    823:            case HT_LOADED:
                    824:               if (PROT_TRACE)
                    825:                  HTTrace ("Load End.... OK: `%s\' has been accessed\n",
1.38      cvs       826:                           me->status_urlName);
1.4       cvs       827: 
1.7       cvs       828:               docid_status = GetDocIdStatus (me->docid,
                    829:                                              Amaya->docid_status);
                    830: 
                    831:               if (docid_status != NULL && docid_status->counter > 1)
1.74      cvs       832:                  TtaSetStatus (me->docid, 1, 
                    833:                                TtaGetMessage (AMAYA, AM_ELEMENT_LOADED),
                    834:                                me->status_urlName);
1.7       cvs       835:               break;
                    836: 
                    837:            case HT_NO_DATA:
                    838:               if (PROT_TRACE)
1.74      cvs       839:                  HTTrace ("Load End.... OK BUT NO DATA: `%s\'\n", 
                    840:                           me->status_urlName);
                    841:               TtaSetStatus (me->docid, 1, 
                    842:                             TtaGetMessage (AMAYA, AM_LOADED_NO_DATA),
1.38      cvs       843:                             me->status_urlName);
1.7       cvs       844:               break;
                    845: 
                    846:            case HT_INTERRUPTED:
                    847:               if (PROT_TRACE)
1.74      cvs       848:                  HTTrace ("Load End.... INTERRUPTED: `%s\'\n", 
                    849:                           me->status_urlName);
                    850:               TtaSetStatus (me->docid, 1, 
                    851:                             TtaGetMessage (AMAYA, AM_LOAD_ABORT), 
                    852:                             NULL);
1.7       cvs       853:               break;
                    854: 
                    855:            case HT_RETRY:
                    856:               if (PROT_TRACE)
                    857:                  HTTrace ("Load End.... NOT AVAILABLE, RETRY AT %ld\n",
                    858:                           HTResponse_retryTime (response));
1.74      cvs       859:               TtaSetStatus (me->docid, 1, 
                    860:                             TtaGetMessage (AMAYA, AM_NOT_AVAILABLE_RETRY),
1.38      cvs       861:                             me->status_urlName);
1.7       cvs       862:               break;
                    863: 
                    864:            case HT_ERROR:
                    865: 
                    866:               cbf = HTAlert_find (HT_A_MESSAGE);
                    867:               if (cbf)
                    868:                  (*cbf) (request, HT_A_MESSAGE, HT_MSG_NULL, NULL,
                    869:                          HTRequest_error (request), NULL);
                    870:               break;
                    871: 
                    872:               if (PROT_TRACE)
                    873:                  HTTrace ("Load End.... ERROR: Can't access `%s\'\n",
1.74      cvs       874:                           me->status_urlName ? me->status_urlName :"<UNKNOWN>");
                    875:               TtaSetStatus (me->docid, 1,
                    876:                             TtaGetMessage (AMAYA, AM_CANNOT_LOAD),
1.38      cvs       877:                             me->status_urlName ? me->status_urlName : "<UNKNOWN>");
1.7       cvs       878:               break;
                    879:            default:
                    880:               if (PROT_TRACE)
                    881:                  HTTrace ("Load End.... UNKNOWN RETURN CODE %d\n", status);
                    882:               break;
                    883:         }
                    884: 
1.4       cvs       885:    return HT_OK;
                    886: }
                    887: 
1.27      cvs       888: /*----------------------------------------------------------------------
                    889:   AHTAcceptTypesInit
1.74      cvs       890:   This function prepares the Accept header used by Amaya during
                    891:   the HTTP content negotiation phase
1.27      cvs       892:   ----------------------------------------------------------------------*/
                    893: #ifdef __STDC__
                    894: static void           AHTAcceptTypesInit (HTList *c)
                    895: #else  /* __STDC__ */
                    896: static void           AHTAcceptTypesInit (c)
                    897: HTList             *c;
                    898: #endif /* __STDC__ */
                    899: {
                    900:   if (c == (HTList *) NULL) 
                    901:       return;
                    902: 
                    903:       /* define here all the mime types that Amaya can accept */
                    904: 
1.74      cvs       905:       HTConversion_add (c, "image/png",  "www/present", 
                    906:                        HTThroughLine, 1.0, 0.0, 0.0);
                    907:       HTConversion_add (c, "image/jpeg", "www/present", 
                    908:                        HTThroughLine, 1.0, 0.0, 0.0);
                    909:       HTConversion_add (c, "image/gif",  "www/present", 
                    910:                        HTThroughLine, 1.0, 0.0, 0.0);
                    911:       HTConversion_add (c, "image/xbm",  "www/present", 
                    912:                        HTThroughLine, 1.0, 0.0, 0.0);
                    913:       HTConversion_add (c, "image/xpm",  "www/present", 
                    914:                        HTThroughLine, 1.0, 0.0, 0.0);
                    915:       HTConversion_add (c, "application/postscript",  
                    916:                        "www/present", HTThroughLine, 1.0, 0.0, 0.0);
1.4       cvs       917: 
1.27      cvs       918:    /* Define here the equivalences between MIME types and file extensions for
                    919:     the types that Amaya can display */
                    920: 
                    921:    /* Register the default set of file suffix bindings */
                    922:    HTFileInit ();
                    923: 
                    924:    /* Don't do any case distinction */
                    925:    HTBind_caseSensitive (FALSE);
                    926: }
1.4       cvs       927: 
1.5       cvs       928: /*----------------------------------------------------------------------
1.17      cvs       929:   AHTConverterInit
                    930:   Bindings between a source media type and a destination media type
                    931:   (conversion).
1.5       cvs       932:   ----------------------------------------------------------------------*/
1.15      cvs       933: #ifdef __STDC__
                    934: static void         AHTConverterInit (HTList *c)
                    935: #else  /* __STDC__ */
                    936: static void         AHTConverterInit (c)
                    937: HTList             *c;
                    938: #endif /* __STDC__ */
1.4       cvs       939: {
                    940: 
                    941:    /* Handler for custom http error messages */
1.7       cvs       942:    HTConversion_add (c, "*/*", "www/debug", AHTMemConverter, 1.0, 0.0, 0.0);
1.4       cvs       943: 
                    944:    /*
                    945:     ** These are converters that converts to something other than www/present,
                    946:     ** that is not directly outputting someting to the user on the screen
                    947:     */
                    948: 
                    949:    HTConversion_add (c, "message/rfc822", "*/*", HTMIMEConvert, 1.0, 0.0, 0.0);
                    950:    HTConversion_add (c, "message/x-rfc822-foot", "*/*", HTMIMEFooter,
                    951:                     1.0, 0.0, 0.0);
                    952:    HTConversion_add (c, "message/x-rfc822-head", "*/*", HTMIMEHeader,
                    953:                     1.0, 0.0, 0.0);
                    954:    HTConversion_add (c, "multipart/*", "*/*", HTBoundary,
                    955:                     1.0, 0.0, 0.0);
                    956:    HTConversion_add (c, "text/plain", "text/html", HTPlainToHTML,
                    957:                     1.0, 0.0, 0.0);
                    958: 
                    959: 
                    960:    /*
                    961:       ** The following conversions are converting ASCII output from various
                    962:       ** protocols to HTML objects.
                    963:     */
                    964:    HTConversion_add (c, "text/x-http", "*/*", HTTPStatus_new,
                    965:                     1.0, 0.0, 0.0);
                    966:    HTConversion_add (c, "text/x-nntp-list", "*/*", HTNewsList,
                    967:                     1.0, 0.0, 0.0);
                    968:    HTConversion_add (c, "text/x-nntp-over", "*/*", HTNewsGroup,
                    969:                     1.0, 0.0, 0.0);
                    970: 
                    971: 
                    972:    /*
                    973:     ** We also register a special content type guess stream that can figure out
                    974:     ** the content type by reading the first bytes of the stream
                    975:     */
                    976:    HTConversion_add (c, "www/unknown", "*/*", HTGuess_new,
                    977:                     1.0, 0.0, 0.0);
                    978: 
                    979:    /*
                    980:       ** Register a persistent cache stream which can save an object to local
                    981:       ** file
                    982:     */
                    983:    HTConversion_add (c, "www/cache", "*/*", HTCacheWriter,
                    984:                     1.0, 0.0, 0.0);
                    985: 
                    986:    /*
                    987:       ** This dumps all other formats to local disk without any further
                    988:       ** action taken
                    989:     */
                    990:    HTConversion_add (c, "*/*", "www/present", HTSaveLocally,
                    991:                     0.3, 0.0, 0.0);
                    992: 
                    993: }
                    994: 
1.27      cvs       995: 
1.15      cvs       996: /*----------------------------------------------------------------------
1.17      cvs       997:   AHTProtocolInit
                    998:   Registers all amaya supported protocols.
1.15      cvs       999:   ----------------------------------------------------------------------*/
1.4       cvs      1000: static void         AHTProtocolInit (void)
                   1001: {
                   1002: 
1.17      cvs      1003:    /* 
1.74      cvs      1004:       NB. Preemptive == YES means Blocking requests
                   1005:       Non-preemptive == NO means Non-blocking requests
1.17      cvs      1006:    */
1.4       cvs      1007: 
1.63      cvs      1008:    HTProtocol_add ("http", "buffered_tcp", NO, HTLoadHTTP, NULL);
1.4       cvs      1009:    /*   HTProtocol_add ("http", "tcp", NO, HTLoadHTTP, NULL); */
                   1010:    HTProtocol_add ("file", "local", NO, HTLoadFile, NULL);
                   1011:    HTProtocol_add ("cache", "local", NO, HTLoadCache, NULL);
1.36      cvs      1012:    HTProtocol_add ("ftp", "tcp", NO, HTLoadFTP, NULL);
1.17      cvs      1013: #if 0 /* experimental code */
1.4       cvs      1014:    HTProtocol_add ("telnet", "", YES, HTLoadTelnet, NULL);
                   1015:    HTProtocol_add ("tn3270", "", YES, HTLoadTelnet, NULL);
                   1016:    HTProtocol_add ("rlogin", "", YES, HTLoadTelnet, NULL);
                   1017:    HTProtocol_add ("nntp", "tcp", NO, HTLoadNews, NULL);
                   1018:    HTProtocol_add ("news", "tcp", NO, HTLoadNews, NULL);
1.17      cvs      1019: #endif
1.4       cvs      1020: }
                   1021: 
1.15      cvs      1022: /*----------------------------------------------------------------------
1.17      cvs      1023:   AHTNetInit
                   1024:   Reegisters "before" and "after" request filters.
1.15      cvs      1025:   ----------------------------------------------------------------------*/
1.4       cvs      1026: static void         AHTNetInit (void)
                   1027: {
                   1028: 
                   1029: /*      Register BEFORE filters
1.74      cvs      1030: **      The BEFORE filters handle proxies, caches, rule files etc.
                   1031: **      The filters are called in the order by which the are registered
                   1032: **      Not done automaticly - may be done by application!
                   1033: */
                   1034:   
1.4       cvs      1035: 
1.74      cvs      1036:   HTNet_addBefore (HTCredentialsFilter, "http://*", NULL, 6);
                   1037:   HTNet_addBefore (HTProxyFilter, NULL, NULL, 10);
1.85      cvs      1038:   /*  HTNet_addBefore (AHTOpen_file, NULL, NULL, 11); */
                   1039:   HTHost_setActivateRequestCallback (AHTOpen_file);
1.4       cvs      1040: 
                   1041: /*      register AFTER filters
1.74      cvs      1042: **      The AFTER filters handle error messages, logging, redirection,
                   1043: **      authentication etc.
                   1044: **      The filters are called in the order by which the are registered
                   1045: **      Not done automaticly - may be done by application!
                   1046: */
1.4       cvs      1047: 
1.82      cvs      1048:    HTNet_addAfter (HTAuthFilter, "http://*", NULL, HT_NO_ACCESS, HT_FILTER_MIDDLE);
                   1049:    HTNet_addAfter (redirection_handler, "http://*", NULL, HT_TEMP_REDIRECT, HT_FILTER_MIDDLE);
                   1050:    HTNet_addAfter (redirection_handler, "http://*", NULL, HT_PERM_REDIRECT, HT_FILTER_MIDDLE);
                   1051:    HTNet_addAfter (HTUseProxyFilter, "http://*", NULL, HT_USE_PROXY, HT_FILTER_MIDDLE);
1.51      cvs      1052:    HTNet_addAfter (AHTLoadTerminate_handler, NULL, NULL, HT_ALL, HT_FILTER_LAST);      
                   1053:    /* handles all errors */
1.7       cvs      1054:    HTNet_addAfter (terminate_handler, NULL, NULL, HT_ALL, HT_FILTER_LAST);
1.4       cvs      1055: }
                   1056: 
1.15      cvs      1057: /*----------------------------------------------------------------------
1.17      cvs      1058:   AHTAlertInit
                   1059:   Register alert messages and their callbacks.
1.15      cvs      1060:   ----------------------------------------------------------------------*/
                   1061: #ifdef __STDC__
                   1062: static void         AHTAlertInit (void)
                   1063: #else
                   1064: static void         AHTAlertInit ()
                   1065: #endif
                   1066: {
                   1067:    HTAlert_add (AHTProgress, HT_A_PROGRESS);
1.70      cvs      1068: #  ifndef _WINDOWS
1.83      cvs      1069:    /*   HTAlert_add ((HTAlertCallback *) Add_NewSocket_to_Loop, HT_PROG_CONNECT); */
1.70      cvs      1070: #  else  /* _WINDOWS */
                   1071:    HTAlert_add ((HTAlertCallback *) WIN_Activate_Request, HT_PROG_CONNECT);
                   1072: #  endif /* _WINDOWS */
1.15      cvs      1073:    HTAlert_add (AHTError_print, HT_A_MESSAGE);
1.48      cvs      1074:    HTError_setShow (~((unsigned int) 0 ) & ~((unsigned int) HT_ERR_SHOW_DEBUG));       /* process all messages except debug ones*/
1.15      cvs      1075:    HTAlert_add (AHTConfirm, HT_A_CONFIRM);
                   1076:    HTAlert_add (AHTPrompt, HT_A_PROMPT);
                   1077:    HTAlert_add (AHTPromptPassword, HT_A_SECRET);
                   1078:    HTAlert_add (AHTPromptUsernameAndPassword, HT_A_USER_PW);
                   1079: }
                   1080: 
                   1081: /*----------------------------------------------------------------------
1.17      cvs      1082:   AHTProfile_newAmaya
                   1083:   creates the Amaya client profile for libwww.
1.15      cvs      1084:   ----------------------------------------------------------------------*/
                   1085: #ifdef __STDC__
                   1086: static void         AHTProfile_newAmaya (char *AppName, char *AppVersion)
                   1087: #else  /* __STDC__ */
                   1088: static void         AHTProfile_newAmaya (AppName, AppVersion)
                   1089: char               *AppName;
                   1090: char               *AppVersion;
                   1091: #endif /* __STDC__ */
1.4       cvs      1092: {
                   1093:    /* If the Library is not already initialized then do it */
                   1094:    if (!HTLib_isInitialized ())
                   1095:       HTLibInit (AppName, AppVersion);
                   1096: 
                   1097:    if (!converters)
                   1098:       converters = HTList_new ();
1.27      cvs      1099:    if (!acceptTypes)
                   1100:       acceptTypes = HTList_new ();
1.4       cvs      1101:    if (!encodings)
                   1102:       encodings = HTList_new ();
                   1103: 
                   1104:    /* Register the default set of transport protocols */
                   1105:    HTTransportInit ();
                   1106: 
                   1107:    /* Register the default set of application protocol modules */
                   1108:    AHTProtocolInit ();
                   1109: 
                   1110:    /* Enable the persistent cache */
                   1111:    /*   HTCacheInit (NULL, 20); */
                   1112: 
                   1113:    /* Register the default set of BEFORE and AFTER filters */
                   1114:    AHTNetInit ();
                   1115: 
                   1116:    /* Set up the default set of Authentication schemes */
                   1117:    HTAAInit ();
                   1118: 
                   1119:    /* Get any proxy or gateway environment variables */
                   1120:    HTProxy_getEnvVar ();
                   1121: 
                   1122:    /* Register the default set of converters */
                   1123:    AHTConverterInit (converters);
1.27      cvs      1124:    AHTAcceptTypesInit (acceptTypes);
1.4       cvs      1125:    HTFormat_setConversion (converters);
                   1126: 
                   1127:    /* Register the default set of transfer encoders and decoders */
                   1128:    HTEncoderInit (encodings);  /* chunks ??? */
                   1129:    HTFormat_setTransferCoding (encodings);
                   1130: 
                   1131:    /* Register the default set of MIME header parsers */
1.74      cvs      1132:    HTMIMEInit ();   /* must be called again for language selector */
1.4       cvs      1133: 
                   1134:    /* Register the default set of Icons for directory listings */
1.27      cvs      1135:    /*HTIconInit(NULL); *//* experimental */
1.4       cvs      1136: 
                   1137:    /* Register the default set of messages and dialog functions */
                   1138:    AHTAlertInit ();
                   1139:    HTAlert_setInteractive (YES);
                   1140: }
                   1141: 
1.5       cvs      1142: /*----------------------------------------------------------------------
1.17      cvs      1143:   AHTProfile_delete
                   1144:   deletes the Amaya client profile.
1.5       cvs      1145:   ----------------------------------------------------------------------*/
1.4       cvs      1146: #ifdef __STDC__
                   1147: static void         AHTProfile_delete (void)
                   1148: #else
                   1149: static void         AHTProfile_delete ()
1.7       cvs      1150: #endif                         /* __STDC__ */
1.4       cvs      1151: {
1.22      cvs      1152:  
                   1153:   /* free the Amaya global context */
1.74      cvs      1154:   if (!converters)
                   1155:     HTConversion_deleteAll (converters);
                   1156:   if (!acceptTypes)
                   1157:     HTConversion_deleteAll (acceptTypes);
                   1158:   if (!encodings)
                   1159:     HTCoding_deleteAll (encodings);
                   1160:   
                   1161:   HTList_delete (Amaya->docid_status);
                   1162:   HTList_delete (Amaya->reqlist);
                   1163:   TtaFreeMemory (Amaya);
                   1164:   {
1.61      cvs      1165: 
1.74      cvs      1166:     if (HTLib_isInitialized ())
                   1167:       
1.61      cvs      1168: #  ifdef _WINDOWS
                   1169:       HTEventTerminate ();
                   1170: #  endif _WINDOWS;             
1.74      cvs      1171:     
                   1172:     /* Clean up the persistent cache (if any) */
                   1173:     HTCacheTerminate ();
                   1174:     
                   1175:     /* Clean up all the global preferences */
                   1176:     HTFormat_deleteAll ();
                   1177:     
                   1178:     /* Terminate libwww */
                   1179:     HTLibTerminate ();
                   1180:   }
1.4       cvs      1181: }
                   1182: 
1.5       cvs      1183: /*----------------------------------------------------------------------
1.17      cvs      1184:   QueryInit
                   1185:   initializes the libwww interface 
1.5       cvs      1186:   ----------------------------------------------------------------------*/
1.4       cvs      1187: #ifdef __STDC__
                   1188: void                QueryInit ()
                   1189: #else
                   1190: void                QueryInit ()
                   1191: #endif
                   1192: {
                   1193: 
1.24      cvs      1194:    AmayaIsAlive = TRUE;
1.4       cvs      1195:    AHTProfile_newAmaya (HTAppName, HTAppVersion);
                   1196: 
1.69      cvs      1197:    /* New AHTBridge stuff */
1.4       cvs      1198: 
1.54      cvs      1199: #  ifdef _WINDOWS
1.75      cvs      1200:    AHTEventInit ();
1.54      cvs      1201: #  endif _WINDOWS;
1.72      cvs      1202: 
1.70      cvs      1203:    HTEvent_setRegisterCallback (AHTEvent_register);
1.78      cvs      1204:    /*** a effacer ***/
                   1205:    HTEvent_setUnregisterCallback (AHTEvent_unregister);
                   1206:        /***  ***/
1.4       cvs      1207: 
1.72      cvs      1208: #  ifndef _WINDOWS
                   1209:    HTEvent_setUnregisterCallback (AHTEvent_unregister);
                   1210: #  endif /* _WINDOWS */
                   1211: 
1.74      cvs      1212: #ifdef DEBUG_LIBWWW
                   1213:   WWW_TraceFlag = SHOW_CORE_TRACE | SHOW_THREAD_TRACE | PROT_TRACE;
                   1214: #endif
1.4       cvs      1215: 
                   1216:    /* Trace activation (for debugging) */
1.7       cvs      1217:    /*
1.4       cvs      1218:       WWW_TraceFlag = SHOW_APP_TRACE | SHOW_UTIL_TRACE |
                   1219:       SHOW_BIND_TRACE | SHOW_THREAD_TRACE |
                   1220:       SHOW_STREAM_TRACE | SHOW_PROTOCOL_TRACE |
                   1221:       SHOW_URI_TRACE | SHOW_AUTH_TRACE | SHOW_ANCHOR_TRACE |
                   1222:       SHOW_CORE_TRACE;
                   1223: 
1.7       cvs      1224:     */
1.4       cvs      1225: 
                   1226:    /***
                   1227:      WWW_TraceFlag = SHOW_CORE_TRACE | SHOW_AUTH_TRACE | SHOW_ANCHOR_TRACE |
                   1228:      SHOW_PROTOCOL_TRACE| SHOW_APP_TRACE | SHOW_UTIL_TRACE;
                   1229:      ***/
                   1230: 
                   1231:    /* Setting up other user interfaces */
                   1232: 
                   1233:    /* Setting up different network parameters */
1.17      cvs      1234:    /* Maximum number of simultaneous open sockets */
1.4       cvs      1235:    HTNet_setMaxSocket (8);
1.75      cvs      1236:    /* different network services timeouts */
1.4       cvs      1237:    HTDNS_setTimeout (3600);
1.75      cvs      1238: #ifdef _WINDOWS
                   1239:    /* under windows, the libwww persistent socket handling has
                   1240:    ** some bugs. The following line inhibits idle socket reusal.
                   1241:    ** this is a bit slower, but avoids crashes and gives us time
                   1242:    ** to distribute Amaya before having to patch up libwww.
                   1243:    */
1.76      cvs      1244:    HTHost_setPersistTimeout (-1L);
1.75      cvs      1245: #else
1.76      cvs      1246:    HTHost_setPersistTimeout (60L);
1.75      cvs      1247: #endif /* _WINDOWS */
                   1248: 
1.17      cvs      1249:    /* Cache is disabled in this version */
1.4       cvs      1250:    HTCacheMode_setEnabled (0);
                   1251: 
                   1252:    /* Initialization of the global context */
                   1253:    Amaya = (AmayaContext *) TtaGetMemory (sizeof (AmayaContext));
                   1254:    Amaya->reqlist = HTList_new ();
                   1255:    Amaya->docid_status = HTList_new ();
                   1256:    Amaya->open_requests = 0;
1.74      cvs      1257:    
1.4       cvs      1258: #ifdef CATCH_SIG
1.18      cvs      1259:    signal (SIGPIPE, SIG_IGN);
1.4       cvs      1260: #endif
1.15      cvs      1261: }
                   1262: 
1.69      cvs      1263: #ifndef _WINDOWS
1.15      cvs      1264: /*----------------------------------------------------------------------
1.17      cvs      1265:   LoopForStop
                   1266:   a copy of the Thop event loop so we can handle the stop button.
1.69      cvs      1267:   Not useful for windows code (Ramzi).
1.15      cvs      1268:   ----------------------------------------------------------------------*/
                   1269: #ifdef __STDC__
                   1270: static int          LoopForStop (AHTReqContext * me)
                   1271: #else
                   1272: static int          LoopForStop (AHTReqContext * me)
                   1273: #endif
                   1274: {
                   1275: 
1.25      cvs      1276:    extern ThotAppContext app_cont;
1.51      cvs      1277:    XEvent                ev;
                   1278:    XtInputMask           status;
1.17      cvs      1279:    int                 status_req = HT_OK;
1.15      cvs      1280: 
                   1281:    /* to test the async calls  */
1.17      cvs      1282:    /* Loop while waiting for new events, exists when the request is over */
1.15      cvs      1283:    while (me->reqStatus != HT_ABORT &&
                   1284:          me->reqStatus != HT_END &&
1.69      cvs      1285:          me->reqStatus != HT_ERR) {
                   1286:         if (!AmayaIsAlive)
                   1287:            /* Amaya was killed by one of the callback handlers */
                   1288:            exit (0);
                   1289: 
                   1290:         status = XtAppPending (app_cont);
                   1291:         if (status & XtIMXEvent) {
                   1292:             XtAppNextEvent (app_cont, &ev);
                   1293:            TtaHandleOneEvent (&ev);
                   1294:         } else if (status & (XtIMAll & (~XtIMXEvent))) {
                   1295:                 XtAppProcessEvent (app_cont, (XtIMAll & (~XtIMXEvent)));
                   1296:         } else {
                   1297:                XtAppNextEvent (app_cont, &ev);
                   1298:               TtaHandleOneEvent (&ev);
                   1299:         }
                   1300:    }
1.4       cvs      1301: 
1.69      cvs      1302:    switch (me->reqStatus) {
                   1303:          case HT_ERR:
                   1304:           case HT_ABORT:
1.15      cvs      1305:               status_req = HT_ERROR;
                   1306:               break;
                   1307: 
1.69      cvs      1308:          case HT_END:
1.15      cvs      1309:               status_req = HT_OK;
                   1310:               break;
                   1311: 
1.69      cvs      1312:          default:
1.15      cvs      1313:               break;
1.69      cvs      1314:    }
1.15      cvs      1315:    return (status_req);
1.4       cvs      1316: }
1.69      cvs      1317: #endif /* _WINDOWS */
1.4       cvs      1318: 
1.5       cvs      1319: /*----------------------------------------------------------------------
1.15      cvs      1320:   QueryClose
1.21      cvs      1321:   closes all existing threads, frees all non-automatically deallocated
                   1322:   memory and then ends libwww.
1.5       cvs      1323:   ----------------------------------------------------------------------*/
1.4       cvs      1324: void                QueryClose ()
                   1325: {
1.24      cvs      1326: 
                   1327:    AmayaIsAlive = FALSE;
                   1328: 
1.21      cvs      1329:    /* remove all the handlers and callbacks that may output a message to
                   1330:       a non-existent Amaya window */
                   1331: 
                   1332:    HTNet_deleteAfter (AHTLoadTerminate_handler);
                   1333:    HTNet_deleteAfter (redirection_handler);
                   1334:    HTAlertCall_deleteAll (HTAlert_global () );
1.23      cvs      1335:    HTAlert_setGlobal ((HTList *) NULL);
1.24      cvs      1336:    HTEvent_setRegisterCallback ((HTEvent_registerCallback *) NULL);
1.27      cvs      1337:    HTEvent_setUnregisterCallback ((HTEvent_unregisterCallback *) NULL);
1.87      cvs      1338:     HTHost_setActivateRequestCallback (NULL);
1.4       cvs      1339:    Thread_deleteAll ();
1.21      cvs      1340:  
1.4       cvs      1341:    HTProxy_deleteAll ();
                   1342:    HTNoProxy_deleteAll ();
                   1343:    HTGateway_deleteAll ();
                   1344:    AHTProfile_delete ();
                   1345: }
                   1346: 
1.5       cvs      1347: /*----------------------------------------------------------------------
1.15      cvs      1348:    GetObjectWWW
1.17      cvs      1349:    this function requests a resource designated by a URLname into a
                   1350:    temporary filename. The download can come from a simple GET operation,
                   1351:    or can come from POSTING/GETTING a form. In the latter
                   1352:    case, the function receives a query string to send to the server.
                   1353: 
1.5       cvs      1354:    4  file retrieval modes are proposed:                              
                   1355:    AMAYA_SYNC : blocking mode                            
                   1356:    AMAYA_ISYNC : incremental, blocking mode              
                   1357:    AMAYA_ASYNC : non-blocking mode                       
                   1358:    AMAYA_IASYNC : incremental, non-blocking mode         
                   1359:    
                   1360:    In the incremental mode, each time a package arrives, it will be   
                   1361:    stored in the temporary file. In addition, if an                   
                   1362:    incremental_callback function is defined, this function will be    
                   1363:    called and handled a copy of the newly received data package.      
                   1364:    Finally, if a terminate_callback function is defined, it will be   
                   1365:    invoked when the request terminates. The caller of this function
1.4       cvs      1366:    can define two different contexts to be passed to the callback
                   1367:    functions.
                   1368: 
                   1369:    When the function is called with the SYNC mode, the function will
                   1370:    return only when the requested file has been loaded.
                   1371:    The ASYNC mode will immediately return after setting up the
                   1372:    call.
                   1373: 
                   1374:    Notes:
                   1375:    At the end of a succesful request, the urlName string contains the
                   1376:    name of the actually retrieved URL. As a URL can change over the time,
                   1377:    (e.g., be redirected elsewhere), it is advised that the function
1.17      cvs      1378:    caller verify the value of the urlName variable at the end of
1.4       cvs      1379:    a request.
                   1380: 
                   1381:    Inputs:
                   1382:    - docid  Document identifier for the set of objects being
                   1383:    retrieved.
                   1384:    - urlName The URL to be retrieved (MAX_URL_LENGTH chars length)
                   1385:    - outputfile A pointer to an empty string of MAX_URL_LENGTH.
                   1386:    - mode The retrieval mode.
                   1387:    - incremental_cbf 
                   1388:    - context_icbf
                   1389:    Callback and context for the incremental modes
                   1390:    - terminate_cbf 
                   1391:    - context_icbf
                   1392:    Callback and context for a terminate handler
1.17      cvs      1393:    -error_html if TRUE, then display any server error message as an
                   1394:    HTML document.
1.88      cvs      1395:    - content_type a string
                   1396:  
1.4       cvs      1397:    Outputs:
                   1398:    - urlName The URL that was retrieved
                   1399:    - outputfile The name of the temporary file which holds the
                   1400:    retrieved data. (Only in case of success)
1.88      cvs      1401:    - if content_type wasn't NULL, it will contain a copy of the parameter
                   1402:      sent in the HTTP answer
1.4       cvs      1403:    Returns:
                   1404:    HT_ERROR
                   1405:    HT_OK
1.5       cvs      1406:  
                   1407:   ----------------------------------------------------------------------*/
1.4       cvs      1408: #ifdef __STDC__
1.52      cvs      1409: int GetObjectWWW (int docid, char* urlName, char* postString, char* outputfile, int mode,
                   1410:                  TIcbf* incremental_cbf, void* context_icbf, TTcbf* terminate_cbf, 
1.88      cvs      1411:                  void* context_tcbf, boolean error_html, char *content_type)
1.4       cvs      1412: #else
1.52      cvs      1413: int GetObjectWWW (docid, urlName, postString, outputfile, mode, incremental_cbf, context_icbf, 
1.88      cvs      1414:                  terminate_cbf, context_tcbf, error_html, content_type)
1.73      cvs      1415: int           docid;
                   1416: char         *urlName;
                   1417: char         *postString;
                   1418: char         *outputfile;
                   1419: int           mode;
                   1420: TIcbf        *incremental_cbf;
                   1421: void         *context_icbf;
                   1422: TTcbf        *terminate_cbf;
                   1423: void         *context_tcbf;
                   1424: boolean       error_html;
1.88      cvs      1425: char        *content_type;
1.4       cvs      1426: #endif
                   1427: {
                   1428:    AHTReqContext      *me;
                   1429:    char               *ref;
                   1430:    int                 status;
1.7       cvs      1431: 
1.69      cvs      1432:    if (urlName == NULL || docid == 0 || outputfile == NULL) {
                   1433:       /* no file to be loaded */
                   1434:       TtaSetStatus (docid, 1, TtaGetMessage (AMAYA, AM_BAD_URL), urlName);
                   1435:        
                   1436:       if (error_html)
                   1437:         /* so we can show the error message */
                   1438:         DocNetworkStatus[docid] |= AMAYA_NET_ERROR;
                   1439:       return HT_ERROR;
                   1440:       
                   1441:    }
1.7       cvs      1442: 
1.4       cvs      1443:    /* do we support this protocol? */
1.69      cvs      1444:    if (IsValidProtocol (urlName) == NO) {
                   1445:       /* return error */
                   1446:       outputfile[0] = EOS;     /* file could not be opened */
                   1447:       TtaSetStatus (docid, 1, TtaGetMessage (AMAYA, AM_GET_UNSUPPORTED_PROTOCOL), urlName);
                   1448:       
                   1449:       if (error_html)
                   1450:         /* so we can show the error message */
                   1451:         DocNetworkStatus[docid] |= AMAYA_NET_ERROR;
                   1452:       return HT_ERROR;
                   1453:    }
1.4       cvs      1454: 
1.58      cvs      1455:    /*create a tempfilename */
1.59      cvs      1456:    sprintf (outputfile, "%s%c%d%c%04dAM", TempFileDirectory, DIR_SEP, docid, DIR_SEP, object_counter);
1.4       cvs      1457: 
                   1458:    /* update the object_counter */
                   1459:    object_counter++;
                   1460:    /* normalize the URL */
1.45      cvs      1461:    ref = AmayaParseUrl (urlName, "", AMAYA_PARSE_ALL);
1.4       cvs      1462:    /* should we abort the request if we could not normalize the url? */
1.69      cvs      1463:    if (ref == (char*) NULL || ref[0] == EOS) {
                   1464:       /*error */
                   1465:       outputfile[0] = EOS;
                   1466:       TtaSetStatus (docid, 1, TtaGetMessage (AMAYA, AM_BAD_URL), urlName);
                   1467:       
                   1468:       if (error_html)
                   1469:         /* so we can show the error message */
                   1470:         DocNetworkStatus[docid] |= AMAYA_NET_ERROR;
1.4       cvs      1471: 
1.69      cvs      1472:       return HT_ERROR;
                   1473:    }
1.4       cvs      1474:    /* verify if that file name existed */
1.9       cvs      1475:    if (TtaFileExist (outputfile))
1.77      cvs      1476:      TtaFileUnlink (outputfile);
1.4       cvs      1477: 
                   1478:    /* Initialize the request structure */
                   1479:    me = AHTReqContext_new (docid);
1.69      cvs      1480:    if (me == NULL) {
1.77      cvs      1481:      outputfile[0] = EOS;
                   1482:      /* need an error message here */
                   1483:      TtaFreeMemory (ref);
                   1484:      return (HT_ERROR);
1.69      cvs      1485:    }
1.77      cvs      1486:    
1.4       cvs      1487:    /* Specific initializations for POST and GET */
1.69      cvs      1488:    if (mode & AMAYA_FORM_POST) {
1.77      cvs      1489:      me->method = METHOD_POST;
                   1490:      if (postString) {
                   1491:        me->mem_ptr = postString;
                   1492:        me->block_size = strlen (postString);
                   1493:      } else {
                   1494:        me->mem_ptr = "";
                   1495:        me->block_size = 0;
                   1496:      }
                   1497:      HTRequest_setMethod (me->request, METHOD_POST);
1.69      cvs      1498:       HTRequest_setPostCallback (me->request, AHTUpload_callback);
                   1499:    } else {
1.77      cvs      1500:      me->method = METHOD_GET;
                   1501:      me->dest = (HTParentAnchor *) NULL;       /*useful only for PUT and POST methods */
                   1502:      if (!HasKnownFileSuffix (ref))
                   1503:        HTRequest_setConversion(me->request, acceptTypes, TRUE);
1.69      cvs      1504:    }
1.4       cvs      1505: 
1.93    ! cvs      1506: 
        !          1507: #if !defined(AMAYA_JAVA) && !defined(AMAYA_ILU)        && defined (_WINDOWS)
        !          1508:    /* forces libwww to do sync request if in MakeBook mode */
        !          1509:    if (WinMakeBookFlag)
        !          1510:           mode = AMAYA_SYNC;
        !          1511: #endif /* _WINDOWS */
        !          1512: 
1.4       cvs      1513:    /* Common initialization */
                   1514:    me->mode = mode;
                   1515:    me->error_html = error_html;
                   1516:    me->incremental_cbf = incremental_cbf;
                   1517:    me->context_icbf = context_icbf;
                   1518:    me->terminate_cbf = terminate_cbf;
                   1519:    me->context_tcbf = context_tcbf;
1.88      cvs      1520:    me->content_type = content_type;
1.64      cvs      1521: 
1.69      cvs      1522:    /* for the async. request modes, we need to have our
1.4       cvs      1523:       own copy of outputfile and urlname
                   1524:     */
                   1525: 
1.69      cvs      1526:    if ((mode & AMAYA_ASYNC) || (mode & AMAYA_IASYNC)) {
1.77      cvs      1527:      char* tmp;
                   1528:      
1.69      cvs      1529:       tmp = TtaGetMemory (strlen (outputfile) + 1);
                   1530:       strcpy (tmp, outputfile);
                   1531:       me->outputfile = tmp;
                   1532:       
                   1533:       tmp = TtaGetMemory (MAX_LENGTH + 1);
                   1534:       strncpy (tmp, urlName, MAX_LENGTH);
                   1535:       tmp[MAX_LENGTH] = EOS;
                   1536:       me->urlName = tmp;
                   1537: #  ifdef _WINDOWS
                   1538:       HTRequest_setPreemptive (me->request, NO);
                   1539:    } else {
1.77      cvs      1540:      me->outputfile = outputfile;
                   1541:      me->urlName = urlName;
                   1542:      HTRequest_setPreemptive (me->request, YES);
1.61      cvs      1543:    }
1.69      cvs      1544: #  else /* _WINDOWS */
                   1545:    } else {
1.77      cvs      1546:      me->outputfile = outputfile;
                   1547:      me->urlName = urlName;
1.61      cvs      1548:    }
1.77      cvs      1549:      /***
1.57      cvs      1550:      Change for taking into account the stop button:
                   1551:      The requests will be always asynchronous, however, if mode=AMAYA_SYNC,
                   1552:      we will loop until the document has been received or a stop signal
                   1553:      generated
1.77      cvs      1554:      ****/
                   1555:      HTRequest_setPreemptive (me->request, NO);
1.69      cvs      1556: #  endif /* _WINDOWS */
1.61      cvs      1557: 
                   1558:    /* prepare the URLname that will be displayed in teh status bar */
                   1559:    ChopURL (me->status_urlName, me->urlName);
                   1560: 
1.77      cvs      1561:    TtaSetStatus (me->docid, 1, 
                   1562:                 TtaGetMessage (AMAYA, AM_FETCHING),
                   1563:                 me->status_urlName);
1.4       cvs      1564: 
                   1565:    me->anchor = (HTParentAnchor *) HTAnchor_findAddress (ref);
1.45      cvs      1566:    TtaFreeMemory (ref);
1.4       cvs      1567: 
1.69      cvs      1568:    if (mode & AMAYA_FORM_POST) {
                   1569:       HTAnchor_setFormat ((HTParentAnchor *) me->anchor, HTAtom_for ("application/x-www-form-urlencoded"));
                   1570:       HTAnchor_setLength ((HTParentAnchor *) me->anchor, me->block_size);
                   1571:       HTRequest_setEntityAnchor (me->request, me->anchor);
                   1572:       
                   1573:       status = HTLoadAbsolute (urlName, me->request);
                   1574:    } else
1.77      cvs      1575:      status = HTLoadAnchor ((HTAnchor *) me->anchor, me->request);
1.69      cvs      1576: 
1.72      cvs      1577: #ifndef _WINDOWS
1.77      cvs      1578:    if (status == HT_ERROR ||
                   1579:     me->reqStatus == HT_END ||
                   1580:     me->reqStatus == HT_ERR)
                   1581:    {
                   1582:      /* in case of error, free all allocated memory and exit */
1.82      cvs      1583:      if (me->output) {
1.85      cvs      1584: #ifdef DEBUG_LIBWWW      
                   1585:        fprintf (stderr, "tGetObjectWWW:: URL is  %s, closing "
                   1586:                "FILE %p\n", me->urlName, me->output); 
                   1587: #endif
1.77      cvs      1588:        fclose (me->output);
1.82      cvs      1589:        me->output = NULL;
                   1590:      }
                   1591:      
1.72      cvs      1592:       if (me->reqStatus == HT_ERR) {
1.77      cvs      1593:        status = HT_ERROR;
                   1594:        /* show an error message on the status bar */
                   1595:        DocNetworkStatus[me->docid] |= AMAYA_NET_ERROR;
                   1596:        TtaSetStatus (me->docid, 1, TtaGetMessage (AMAYA, AM_CANNOT_LOAD), me->
                   1597:                      status_urlName);
1.72      cvs      1598:       } else
1.77      cvs      1599:        status = HT_OK;
1.72      cvs      1600: 
                   1601:       AHTReqContext_delete (me);
1.77      cvs      1602:  } else {
1.72      cvs      1603:          /* part of the stop button handler */
                   1604:          if ((mode & AMAYA_SYNC) || (mode & AMAYA_ISYNC)) {
                   1605:             status = LoopForStop (me);
                   1606:            AHTReqContext_delete (me);
                   1607:          }
                   1608:    }
                   1609: 
                   1610: #else  /* !_WINDOWS */
                   1611: 
1.90      cvs      1612:    if (status == HT_ERROR ||
                   1613:           me->reqStatus == HT_ERROR)
                   1614:      {
                   1615:           status = HT_ERROR;
1.71      cvs      1616: 
1.90      cvs      1617:        /* in case of error, close any open files, free all allocated
                   1618:              memory and exit */
                   1619:        if (me->output && me->output != stdout)
                   1620:             {
1.85      cvs      1621: #ifdef DEBUG_LIBWWW      
1.90      cvs      1622:            fprintf (stderr, "GetObjectWWW: URL is  %s, closing "
                   1623:                    "FILE %p\n", me->urlName, me->output); 
1.85      cvs      1624: #endif
1.90      cvs      1625:            fclose (me->output);
                   1626:            me->output = NULL;
                   1627:          }
1.85      cvs      1628:      
1.90      cvs      1629:        if (me->reqStatus == HT_ERR) 
                   1630:             {
                   1631:              /* show an error message on the status bar */
                   1632:              DocNetworkStatus[me->docid] |= AMAYA_NET_ERROR;
                   1633:              TtaSetStatus (me->docid, 1, 
                   1634:                  TtaGetMessage (AMAYA, AM_CANNOT_LOAD),
                   1635:                  me->status_urlName);
                   1636:          }
                   1637:      } 
                   1638:        else 
                   1639:          {
                   1640:            status = HT_OK;
                   1641:       }
                   1642:  
1.93    ! cvs      1643:    /* part of the stop button handler */
        !          1644:      if ((mode & AMAYA_SYNC) || (mode & AMAYA_ISYNC))
        !          1645:        {
        !          1646:         if (HTRequest_net (me->request))
        !          1647:            HTRequest_kill (me->request);
        !          1648:         else
        !          1649:            AHTReqContext_delete (me);
        !          1650:        }
1.4       cvs      1651: 
1.72      cvs      1652: #endif /* !_WINDOWS */
                   1653: 
1.4       cvs      1654:    return (status);
                   1655: }
                   1656: 
1.5       cvs      1657: /*----------------------------------------------------------------------
1.17      cvs      1658:    PutObjectWWW
                   1659:    frontend for uploading a resource to a URL. This function downloads
                   1660:    a file to be uploaded into memory, it then calls UploadMemWWW to
                   1661:    finish the job.
                   1662: 
1.5       cvs      1663:    2 upload modes are proposed:                                       
                   1664:    AMAYA_SYNC : blocking mode                            
                   1665:    AMAYA_ASYNC : non-blocking mode                       
                   1666:    
1.4       cvs      1667:    When the function is called with the SYNC mode, the function will
                   1668:    return only when the file has been uploaded.
                   1669:    The ASYNC mode will immediately return after setting up the
                   1670:    call. Furthermore, at the end of an upload, the ASYNC mode will 
                   1671:    call back terminate_cbf, handling it the context defined in
                   1672:    context_tcbf.
                   1673: 
                   1674:    Notes:
                   1675:    At the end of a succesful request, the urlName string contains the
                   1676:    name of the actually uploaded URL. As a URL can change over the time,
                   1677:    (e.g., be redirected elsewhere), it is advised that the function
                   1678:    caller verifies the value of the urlName variable at the end of
                   1679:    a request.
                   1680: 
                   1681:    Inputs:
                   1682:    - docid  Document identifier for the set of objects being
                   1683:    retrieved.
                   1684:    - fileName A pointer to the local file to upload
                   1685:    - urlName The URL to be uploaded (MAX_URL_LENGTH chars length)
                   1686:    - mode The retrieval mode.
                   1687:    - terminate_cbf 
                   1688:    - context_icbf
                   1689:    Callback and context for a terminate handler
                   1690: 
                   1691:    Outputs:
                   1692:    - urlName The URL that was uploaded
                   1693: 
                   1694:    Returns:
                   1695:    HT_ERROR
                   1696:    HT_OK
1.5       cvs      1697:   ----------------------------------------------------------------------*/
1.4       cvs      1698: #ifdef __STDC__
1.27      cvs      1699: int                 PutObjectWWW (int docid, char *fileName, char *urlName, int mode, PicType contentType,
1.4       cvs      1700:                                  TTcbf * terminate_cbf, void *context_tcbf)
                   1701: #else
1.26      cvs      1702: int                 PutObjectWWW (docid, urlName, fileName, mode, contentType,
1.4       cvs      1703:                                  ,terminate_cbf, context_tcbf)
                   1704: int                 docid;
                   1705: char               *urlName;
                   1706: char               *fileName;
                   1707: int                 mode;
1.27      cvs      1708: PicType             contentType;
1.4       cvs      1709: TTcbf              *terminate_cbf;
                   1710: void               *context_tcbf;
                   1711: 
                   1712: #endif
                   1713: {
1.7       cvs      1714:    /*AHTReqContext      *me; */
1.4       cvs      1715:    int                 status;
                   1716: 
                   1717:    int                 fd;
                   1718:    struct stat         file_stat;
                   1719:    char               *mem_ptr;
                   1720:    unsigned long       block_size;
                   1721: 
1.33      cvs      1722:    AmayaLastHTTPErrorMsg [0] = EOS;
                   1723:    
1.4       cvs      1724:    if (urlName == NULL || docid == 0 || fileName == NULL ||
1.9       cvs      1725:        !TtaFileExist (fileName))
1.4       cvs      1726:       /* no file to be uploaded */
                   1727:       return HT_ERROR;
                   1728: 
                   1729:    /* do we support this protocol? */
1.7       cvs      1730:    if (IsValidProtocol (urlName) == NO)
                   1731:      {
                   1732:        /* return error */
1.77      cvs      1733:        TtaSetStatus (docid, 1, 
                   1734:                       TtaGetMessage (AMAYA, AM_PUT_UNSUPPORTED_PROTOCOL),
1.7       cvs      1735:                      urlName);
                   1736:        return HT_ERROR;
                   1737:      }
1.4       cvs      1738:    /* read the file into memory */
1.70      cvs      1739: #  ifndef _WINDOWS
1.7       cvs      1740:    if ((fd = open (fileName, O_RDONLY)) == -1)
1.70      cvs      1741: #  else /* _WINDOWS */
1.74      cvs      1742:    if ((fd = open (fileName, _O_RDONLY | _O_BINARY)) == -1)
1.70      cvs      1743: #  endif /* _WINDOWS */
1.7       cvs      1744:      {
                   1745:        /* if we could not open the file, exit */
                   1746:        /*error msg here */
                   1747:        return (HT_ERROR);
                   1748:      }
1.4       cvs      1749: 
                   1750:    fstat (fd, &file_stat);
                   1751: 
1.7       cvs      1752:    if (file_stat.st_size == 0)
                   1753:      {
                   1754:        /* file was empty */
                   1755:        /*errmsg here */
                   1756:        close (fd);
                   1757:        return (HT_ERROR);
                   1758:      }
1.4       cvs      1759:    block_size = file_stat.st_size;
                   1760: 
                   1761:    if (THD_TRACE)
                   1762:       fprintf (stderr, "file size == %u\n", (unsigned) block_size);
                   1763: 
                   1764:    mem_ptr = (char *) TtaGetMemory (block_size);
                   1765: 
1.7       cvs      1766:    if (mem_ptr == (char *) NULL)
                   1767:      {
                   1768:        /* could not allocate enough memory */
                   1769:        /*errmsg here */
                   1770:        close (fd);
                   1771:        return (HT_ERROR);
                   1772:      }
1.4       cvs      1773:    read (fd, mem_ptr, block_size);
                   1774: 
                   1775:    close (fd);
                   1776: 
1.27      cvs      1777:    status = UploadMemWWW (docid, METHOD_PUT, urlName, contentType, mem_ptr,
1.4       cvs      1778:                          block_size, mode, terminate_cbf,
                   1779:                          context_tcbf, (char *) NULL);
                   1780: 
                   1781:    TtaFreeMemory (mem_ptr);
1.28      cvs      1782:    TtaHandlePendingEvents ();
1.4       cvs      1783:    return (status);
                   1784: }
                   1785: 
1.5       cvs      1786: /*----------------------------------------------------------------------
1.17      cvs      1787:   UploadMemWWW
                   1788:   low level interface function to libwww for uploading a block of
                   1789:   memory to a URL.
1.5       cvs      1790:   ----------------------------------------------------------------------*/
1.4       cvs      1791: #ifdef __STDC__
                   1792: int                 UploadMemWWW (int docid, HTMethod method,
1.27      cvs      1793:                     char *urlName, PicType contentType, char *mem_ptr, unsigned long block_size,
1.4       cvs      1794:                        int mode, TTcbf * terminate_cbf, void *context_tcbf,
                   1795:                                  char *outputfile)
                   1796: #else
1.27      cvs      1797: int                 UploadMemWWW (docid, method, urlName, contentType, mem_ptr, block_size, mode,
1.4       cvs      1798:                                  terminate_cbf, context_tcbf, outputfile)
                   1799: int                 docid;
                   1800: HTMethod            method;
                   1801: char               *urlName;
1.27      cvs      1802: PicType             contentType;
1.4       cvs      1803: char               *mem_ptr;
                   1804: usigned long        block_size;
                   1805: int                 mode;
                   1806: TTcbf              *terminate_cbf;
                   1807: void               *context_tcbf;
                   1808: char               *outputfile;
1.7       cvs      1809: 
1.4       cvs      1810: #endif
                   1811: {
                   1812:    AHTReqContext      *me;
                   1813:    int                 status;
                   1814: 
                   1815:    if (mem_ptr == (char *) NULL ||
                   1816:        block_size == 0 ||
                   1817:        docid == 0 ||
1.7       cvs      1818:        urlName == (char *) NULL)
                   1819:      {
                   1820:        /* nothing to be uploaded */
                   1821:        return HT_ERROR;
                   1822:      }
1.4       cvs      1823: 
                   1824:    /* Initialize the request structure */
                   1825:    me = AHTReqContext_new (docid);
                   1826: 
1.7       cvs      1827:    if (me == NULL)
                   1828:      {
                   1829:        /* need an error message here */
                   1830:        TtaHandlePendingEvents ();
                   1831:        return (HT_ERROR);
                   1832:      }
1.4       cvs      1833:    me->mode = mode;
                   1834: 
                   1835:    me->incremental_cbf = (TIcbf *) NULL;
                   1836:    me->context_icbf = (void *) NULL;
                   1837:    me->terminate_cbf = terminate_cbf;
                   1838:    me->context_tcbf = context_tcbf;
                   1839: 
                   1840:    me->output = stdout;
                   1841:    me->outputfile = (char *) NULL;
                   1842:    me->urlName = urlName;
                   1843: 
1.70      cvs      1844: #ifdef _WINDOWS
                   1845:    HTRequest_setPreemptive (me->request, YES);
                   1846: #else
1.4       cvs      1847:    HTRequest_setPreemptive (me->request, NO);
1.70      cvs      1848: #endif /* _WINDOWS */
1.74      cvs      1849: 
1.17      cvs      1850:    /* select the parameters that distinguish a PUT from a GET/POST */
1.4       cvs      1851:    me->method = METHOD_PUT;
                   1852:    HTRequest_setMethod (me->request, METHOD_PUT);
                   1853:    me->output = stdout;
1.17      cvs      1854:    /* we are not expecting to receive any input from the server */
                   1855:    me->outputfile = (char *) NULL; 
1.4       cvs      1856: 
                   1857:    me->mem_ptr = mem_ptr;
                   1858:    me->block_size = block_size;
1.17      cvs      1859: 
                   1860:    /* set the callback which will actually copy data into the
                   1861:       output stream */
                   1862: 
1.4       cvs      1863:    HTRequest_setPostCallback (me->request, AHTUpload_callback);
1.72      cvs      1864: 
1.4       cvs      1865:    me->anchor = (HTParentAnchor *) HTAnchor_findAddress (urlName);
1.7       cvs      1866: 
1.28      cvs      1867:    /* Set the Content-Type of the file we are uploading */
1.77      cvs      1868:    HTAnchor_setFormat ((HTParentAnchor *) me->anchor,
                   1869:                       AHTGuessAtom_for (me->urlName, contentType));
1.17      cvs      1870: 
1.7       cvs      1871:    HTAnchor_setLength ((HTParentAnchor *) me->anchor, me->block_size);
1.4       cvs      1872:    HTRequest_setEntityAnchor (me->request, me->anchor);
1.74      cvs      1873:    /* prepare the URLname that will be displayed in teh status bar */
                   1874:    ChopURL (me->status_urlName, me->urlName);
                   1875:    TtaSetStatus (me->docid, 1, TtaGetMessage (AMAYA, AM_REMOTE_SAVING),
                   1876:                     me->status_urlName);
1.4       cvs      1877:    status = HTLoadAbsolute (urlName, me->request);
                   1878: 
1.74      cvs      1879: #ifndef _WINDOWS
1.77      cvs      1880:    if (status == HT_ERROR || 
                   1881:        me->reqStatus == HT_END || 
                   1882:        me->reqStatus == HT_ERR || 
                   1883:        HTError_hasSeverity (HTRequest_error (me->request), ERR_INFO))
1.7       cvs      1884:      {
1.17      cvs      1885:        status = HT_ERROR;
1.28      cvs      1886:      }     
1.7       cvs      1887:    else
                   1888:      {
                   1889:        /* part of the stop button handler */
1.4       cvs      1890: 
1.7       cvs      1891:        if ((mode & AMAYA_SYNC) || (mode & AMAYA_ISYNC))
                   1892:          {
                   1893:             status = LoopForStop (me);
                   1894:          }
1.15      cvs      1895:      }
1.90      cvs      1896: #else /* _WINDOWS */
                   1897:   if (status == HT_ERROR || 
                   1898:          me->reqStatus == HT_ERR) /* || Error_hasSeverity (HTRequest_error (me->request), ERR_INFO)) */
                   1899:          status = HT_ERROR;
                   1900:   else
                   1901:          status = HT_OK;
                   1902: #endif /* _WINDOWS */
                   1903: 
1.92      cvs      1904:     if (HTRequest_net (me->request))
                   1905:        {
                   1906:         HTRequest_kill (me->request);
                   1907:        }
1.93    ! cvs      1908:     else 
        !          1909:         AHTReqContext_delete (me);
1.4       cvs      1910:    return (status);
1.28      cvs      1911: }
1.4       cvs      1912: 
                   1913: 
                   1914: 
1.5       cvs      1915: /*----------------------------------------------------------------------
1.17      cvs      1916:   Stop Request
                   1917:   stops (kills) all active requests associated with a docid 
1.5       cvs      1918:   ----------------------------------------------------------------------*/
1.4       cvs      1919: #ifdef __STDC__
                   1920: void                StopRequest (int docid)
                   1921: #else
                   1922: void                StopRequest (docid)
                   1923: int                 docid;
                   1924: #endif
                   1925: {
                   1926:    HTList             *cur;
                   1927:    AHTDocId_Status    *docid_status;
                   1928:    AHTReqContext      *me;
                   1929:    int                 open_requests;
                   1930: 
1.84      cvs      1931:    HTNet              *reqNet;
                   1932:    HTHost             *reqHost;
1.85      cvs      1933:    HTChannel          *reqChannel;
                   1934:    int                 reqSock;
                   1935:    
1.7       cvs      1936:    if (Amaya)
                   1937:      {
                   1938:        docid_status = (AHTDocId_Status *) GetDocIdStatus (docid,
1.4       cvs      1939:                                                       Amaya->docid_status);
1.7       cvs      1940:        /* verify if there are any requests at all associated with docid */
1.4       cvs      1941: 
1.7       cvs      1942:        if (docid_status == (AHTDocId_Status *) NULL)
                   1943:           return;
1.4       cvs      1944: 
1.7       cvs      1945:        open_requests = docid_status->counter;
1.4       cvs      1946: 
1.85      cvs      1947:        /* First, kill all pending requests */
                   1948:        /* We first inhibit the activation of pending requests */
                   1949:        HTHost_disable_PendingReqLaunch ();
                   1950:        cur = Amaya->reqlist;
                   1951:        while ((me = (AHTReqContext *) HTList_nextObject (cur))) 
                   1952:          {
                   1953:             if (me->docid == docid && me->reqStatus == HT_NEW)
                   1954:               {
                   1955:                 reqNet = HTRequest_net (me->request);
                   1956:                 reqSock = HTNet_socket (reqNet);
                   1957:                 reqChannel = HTChannel_find(reqSock);
                   1958:                 reqHost = HTChannel_host (reqChannel);
1.92      cvs      1959:                 
1.93    ! cvs      1960:                 if ((me->mode & AMAYA_IASYNC) ||
        !          1961:                     (me->mode & AMAYA_ASYNC))
1.85      cvs      1962:                   {
1.93    ! cvs      1963:                     if (HTRequest_net (me->request))
        !          1964:                       HTRequest_kill (me->request);
        !          1965:                     else
        !          1966:                       AHTReqContext_delete (me);                      
1.85      cvs      1967:                   }
                   1968:                 
                   1969:                 if (HTHost_isIdle (reqHost) ) {
                   1970: #ifdef DEBUG_LIBWWW
                   1971:                   fprintf (stderr, "Host is idle, killing socket %d\n",
                   1972:                            reqSock);;
                   1973: #endif /* DEBUG_LIBWWW */
                   1974: 
                   1975:                   HTEvent_unregister (reqSock, FD_ALL);
                   1976:                   HTEvent_register(reqSock, NULL, (SockOps) FD_READ,
                   1977:                                    HTHost_catchClose,  HT_PRIORITY_MAX);
                   1978:                   close (reqSock);
                   1979:                   /*   
                   1980:                   if (reqChannel && reqHost)
                   1981:                   HTHost_clearChannel(reqHost, HT_OK);
                   1982:                   HTHost_catchClose (reqSock, NULL, FD_CLOSE);
                   1983:                   */
                   1984:                 }
                   1985: 
                   1986:                 cur = Amaya->reqlist;
                   1987:                 open_requests--;                  
                   1988:               }
                   1989:          }
                   1990:        /* enable the activation of pending requests */
                   1991:        HTHost_enable_PendingReqLaunch ();
                   1992: 
                   1993:        cur = Amaya->reqlist;
1.7       cvs      1994:        while ((me = (AHTReqContext *) HTList_nextObject (cur)))
                   1995:          {
                   1996:             if (me->docid == docid)
                   1997:               {
1.93    ! cvs      1998:                 /* kill this request */
1.85      cvs      1999: 
1.93    ! cvs      2000:                 switch (me->reqStatus)
        !          2001:                   {
        !          2002:                   case HT_ABORT:
        !          2003:                     break;
        !          2004:                     
        !          2005:                   case HT_BUSY:
        !          2006:                     me->reqStatus = HT_ABORT;
        !          2007:                     break;
        !          2008:                   case HT_NEW_PENDING:
        !          2009:                   case HT_WAITING:
        !          2010:                   default:
        !          2011:                     me->reqStatus = HT_ABORT;
        !          2012:                     
1.70      cvs      2013: #                 ifndef _WINDOWS
1.93    ! cvs      2014:                     RequestKillAllXtevents (me);
1.74      cvs      2015: #                 endif _WINDOWS
1.93    ! cvs      2016:                     
        !          2017:                     reqNet = HTRequest_net (me->request);
        !          2018:                     reqSock = HTNet_socket (reqNet);
        !          2019:                     reqChannel = HTChannel_find(reqSock);
        !          2020:                     reqHost = HTChannel_host (reqChannel);
        !          2021:                     
        !          2022:                     if ((me->mode & AMAYA_IASYNC) ||
        !          2023:                         (me->mode & AMAYA_ASYNC))
        !          2024:                       {
        !          2025:                         if (HTRequest_net (me->request))
        !          2026:                           HTRequest_kill (me->request);
        !          2027:                         else
        !          2028:                           AHTReqContext_delete (me);                  
        !          2029:                       }
        !          2030:                     
        !          2031:                     
        !          2032:                     /* if there are no more requests, then close
        !          2033:                        the connection */
        !          2034:                     
        !          2035:                     if (HTHost_isIdle (reqHost) ) {
1.85      cvs      2036: #ifdef                        DEBUG_LIBWWW
1.93    ! cvs      2037:                       fprintf (stderr, "Host is idle, "
        !          2038:                                "killing socket %d\n",
        !          2039:                                reqSock);
1.85      cvs      2040: #endif                        /* DEBUG_LIBWWW */
1.93    ! cvs      2041:                       HTEvent_unregister (reqSock, FD_ALL);
        !          2042:                       HTEvent_register(reqSock,
        !          2043:                                        NULL,
        !          2044:                                        (SockOps) FD_READ,
        !          2045:                                        HTHost_catchClose,
        !          2046:                                        HT_PRIORITY_MAX);
        !          2047:                       close (reqSock);                         
        !          2048:                       HTHost_clearChannel (reqHost, HT_ERROR);
        !          2049:                       /*
        !          2050:                         if (reqChannel && reqHost)
        !          2051:                         HTHost_clearChannel(reqHost, HT_OK);
        !          2052:                         HTHost_catchClose (reqSock, NULL, FD_CLOSE);
        !          2053:                         */
1.85      cvs      2054: #ifdef                          DEBUG_LIBWWW                           
1.93    ! cvs      2055:                       fprintf (stderr, "After killing, "
        !          2056:                                "HTHost_isIdle gives %d\n",
        !          2057:                                HTHost_isIdle (reqHost));
1.85      cvs      2058: #endif                          /* DEBUG_LIBWWW */
1.93    ! cvs      2059:                     }
        !          2060:                     
        !          2061:                     cur = Amaya->reqlist;
        !          2062:                     open_requests--;
        !          2063:                     
        !          2064:                     break;
        !          2065:                     
        !          2066:                   }    /* switch */
1.7       cvs      2067:               }                /* if me docid */
                   2068:          }                     /* while */
                   2069:      }                         /* if amaya open requests */
1.93    ! cvs      2070:    
1.85      cvs      2071: } /* StopRequest */
1.17      cvs      2072: 
                   2073: /*
                   2074:   end of Module query.c
                   2075: */
                   2076: 
1.69      cvs      2077: #endif /* AMAYA_JAVA */
1.77      cvs      2078: 
                   2079: 
1.17      cvs      2080: 
                   2081: 

Webmaster