Diff for /Amaya/amaya/query.c between versions 1.55 and 1.56

version 1.55, 1997/05/31 08:11:00 version 1.56, 1997/06/02 10:19:27
Line 229  int                 docid; Line 229  int                 docid;
    me->read_sock = INVSOC;     me->read_sock = INVSOC;
    me->write_sock = INVSOC;     me->write_sock = INVSOC;
    me->except_sock = INVSOC;     me->except_sock = INVSOC;
   #if 0
 #ifdef _WINDOWS  #ifdef _WINDOWS
    me->read_fd_state  = 0;     me->read_fd_state  = 0;
    me->write_fd_state  = 0;     me->write_fd_state  = 0;
    me->except_fd_state  = 0;     me->except_fd_state  = 0;
   #endif /* 0 */
 #endif  #endif
   
    /* Update the global context */     /* Update the global context */
Line 1235  static int          LoopForStop (AHTReqC Line 1237  static int          LoopForStop (AHTReqC
              TtaHandleOneEvent (&ev);               TtaHandleOneEvent (&ev);
           }            }
 #       else  /* _WINDOWS */  #       else  /* _WINDOWS */
         /* WIN_ProcessSocketActivity ();        */          WIN_ProcessSocketActivity ();
         /**     if (GetMessage (&ev, NULL, 0, 0))  
            TtaHandleOneWindowEvent (&ev); **/  
 #       endif /* !_WINDOWS */  #       endif /* !_WINDOWS */
      }       }
   
Line 1540  boolean error_html; Line 1540  boolean error_html;
    me->context_tcbf = context_tcbf;     me->context_tcbf = context_tcbf;
    me->output = tmp_fp;     me->output = tmp_fp;
   
 #                         ifndef _WINDOWS  /* TEST TEST */  
    HTRequest_setOutputStream (me->request, AHTFWriter_new (me->request, me->output, YES));     HTRequest_setOutputStream (me->request, AHTFWriter_new (me->request, me->output, YES));
 #else     /*
    HTRequest_setOutputStream (me->request, HTFWriter_new (me->request, me->output, YES));     HTRequest_setOutputStream (me->request, HTFWriter_new (me->request, me->output, YES));
 #endif /* _WINDOWS */     */
   
    /*for the async. request modes, we need to have our     /*for the async. request modes, we need to have our
       own copy of outputfile and urlname        own copy of outputfile and urlname
Line 1660  generated Line 1659  generated
                           if (THD_TRACE)                            if (THD_TRACE)
                              fprintf (stderr, "GetObjectWWW: %s is pending. Closing fd %d\n", me->urlName, (int) me->output);                               fprintf (stderr, "GetObjectWWW: %s is pending. Closing fd %d\n", me->urlName, (int) me->output);
                           /* free the allocated stream object */                            /* free the allocated stream object */
 #                         ifndef _WINDOWS  /* TEST TEST */  
                           AHTFWriter_FREE (HTRequest_outputStream(me->request));                            AHTFWriter_FREE (HTRequest_outputStream(me->request));
 #                         endif /* _WINDOWS  */  
                           HTRequest_setOutputStream (me->request, (HTStream *) NULL);                            HTRequest_setOutputStream (me->request, (HTStream *) NULL);
                           fclose (me->output);                            fclose (me->output);
                           me->output = NULL;                            me->output = NULL;
Line 1807  void               *context_tcbf; Line 1804  void               *context_tcbf;
    return (status);     return (status);
 }  }
   
 #ifdef _WINDOWS  
 /*----------------------------------------------------------------------  
   WIN_GetObjectWWW  
   ----------------------------------------------------------------------*/  
 #ifdef __STDC__  
 int WIN_GetObjectWWW (int doc_id, char* URL_name, char* output_file, boolean error_HTML)  
 #else /* __STDC__ */  
 int WIN_GetObjectWWW (int doc_id, char* URL_name, char* output_file, boolean error_HTML)  
 int     doc_id;  
 char*   URL_name;  
 char*   output_file;  
 boolean error_HTML;  
 #endif /* __STDC__ */  
 {  
    HTRequest* WIN_request    = HTRequest_new ();  
    HTList*    WIN_converters = HTList_new ();           /* List of converters */  
    HTList*    WIN_encodings  = HTList_new ();           /* List of encoders */  
    HTChunk*   WIN_chunk      = NULL;  
   
    FILE*      WIN_tmp_fp;  
    char*      WIN_tmp_dir;  
    char*      WIN_ref;  
    DWORD      WIN_attribs;  
   
    if (URL_name == NULL || doc_id == 0 || output_file == NULL) {  
       /* no file to be loaded */  
       TtaSetStatus (doc_id, 1, TtaGetMessage (AMAYA, AM_BAD_URL), URL_name);  
   
       if (error_HTML)  
          DocNetworkStatus[doc_id] |= AMAYA_NET_ERROR; /* so we can show the error message */  
       return HT_ERROR;  
    }  
   
    /* do we support this protocol? */  
    if (IsValidProtocol (URL_name) == NO) {  
       /* return error */  
       output_file[0] = EOS;     /* file could not be opened */  
       TtaSetStatus (doc_id, 1, TtaGetMessage (AMAYA, AM_GET_UNSUPPORTED_PROTOCOL), URL_name);  
      
       if (error_HTML)  
          DocNetworkStatus[doc_id] |= AMAYA_NET_ERROR; /* so we can show the error message */  
       return HT_ERROR;  
    }  
   
    /* verify if a docid directory exists */  
    WIN_tmp_dir = TtaGetMemory (strlen (TempFileDirectory) + 5 + 1);  
    sprintf (WIN_tmp_dir, "C:\\TEMP\\AMAYA\\%d", doc_id);  
   
    WIN_attribs = GetFileAttributes (WIN_tmp_dir) ;  
   
    if (WIN_attribs == 0xFFFFFFFF) {  
       /*directory did not exist */  
       if (mkdir (WIN_tmp_dir, S_IRWXU) == -1) {  
          /*error */  
           output_file[0] = EOS;  
           TtaSetStatus (doc_id, 1, TtaGetMessage (AMAYA, AM_CACHE_ERROR), URL_name);  
              
           if (error_HTML)  
              DocNetworkStatus[doc_id] |= AMAYA_NET_ERROR; /* so we can show the error message */  
           return HT_ERROR;  
       }  
    }  
   
    /*create a tempfilename */  
    sprintf (output_file, "%s\\%04dAM", WIN_tmp_dir, object_counter);  
    TtaFreeMemory (WIN_tmp_dir);  
   
    /* update the object_counter */  
    object_counter++;  
   
    /* normalize the URL */  
    WIN_ref = AmayaParseUrl (URL_name, "", AMAYA_PARSE_ALL);  
   
    /* should we abort the request if we could not normalize the url? */  
   
    if (WIN_ref == (char*) NULL || WIN_ref[0] == EOS) {  
       /*error */  
       output_file[0] = EOS;  
       TtaSetStatus (doc_id, 1, TtaGetMessage (AMAYA, AM_BAD_URL), URL_name);  
   
       if (error_HTML)  
          DocNetworkStatus[doc_id] |= AMAYA_NET_ERROR; /* so we can show the error message */  
       return HT_ERROR;  
    }  
    /* verify if that file name existed */  
    if (TtaFileExist (output_file))  
       TtaFileUnlink (output_file);  
   
    /* try to open the outputfile */  
    if ((WIN_tmp_fp = fopen (output_file, "wb")) == NULL) {  
       output_file[0] = EOS;     /* file could not be opened */  
       TtaSetStatus (doc_id, 1, TtaGetMessage (AMAYA, AM_CANNOT_CREATE_FILE), output_file);  
       TtaFreeMemory (WIN_ref);  
       
       if (error_HTML)  
          DocNetworkStatus[doc_id] |= AMAYA_NET_ERROR; /* so we can show the error message */  
       return (HT_ERROR);  
    }  
   
    HTLibInit ("Amaya for Windows", "1.0a");  
   
    /* Register the default set of transport protocols */  
    HTTransportInit ();  
      
    /* Register the default set of protocol modules */  
    HTProtocolInit ();  
      
    /* Register the default set of BEFORE and AFTER callback functions */  
    HTNetInit ();  
      
    /* Register the default set of converters */  
    HTConverterInit (WIN_converters);  
    HTFormat_setConversion (WIN_converters);  
      
    /* Register the default set of transfer encoders and decoders */  
    HTEncoderInit (WIN_encodings);  
    HTFormat_setTransferCoding (WIN_encodings);  
      
    /* Register the default set of MIME header parsers */  
    HTMIMEInit ();  
      
    /* Set up the request and pass it to the Library */  
    HTRequest_setOutputFormat (WIN_request, WWW_SOURCE);  
    HTRequest_setPreemptive (WIN_request, YES);  
    if (WIN_ref) {  
       char*     WIN_cwd          = HTGetCurrentDirectoryURL ();  
       char*     WIN_absolute_url = HTParse (WIN_ref, WIN_cwd, PARSE_ALL);  
       HTAnchor* WIN_anchor       = HTAnchor_findAddress (WIN_absolute_url);  
       WIN_chunk                  = HTLoadAnchorToChunk (WIN_anchor, WIN_request);  
       HT_FREE (WIN_absolute_url);  
       HT_FREE (WIN_cwd);  
         
        /* If chunk != NULL then we have the data */  
       if (WIN_chunk) {  
          char* WIN_string = HTChunk_toCString (WIN_chunk);  
          if (WIN_string)  
             fprintf (WIN_tmp_fp, "%s", WIN_string);  
          HT_FREE (WIN_string);  
       }  
    }  
      
    /* Clean up the request */  
    HTRequest_delete(WIN_request);  
    HTFormat_deleteAll();  
      
    /* Terminate the Library */  
    HTLibTerminate();  
    fclose (WIN_tmp_fp);  
    return 0;  
 }  
 #endif /* _WINDOWS */  
   
 /*----------------------------------------------------------------------  /*----------------------------------------------------------------------
   UploadMemWWW    UploadMemWWW
   low level interface function to libwww for uploading a block of    low level interface function to libwww for uploading a block of
Line 2033  char               *outputfile; Line 1878  char               *outputfile;
       output stream */        output stream */
   
    HTRequest_setPostCallback (me->request, AHTUpload_callback);     HTRequest_setPostCallback (me->request, AHTUpload_callback);
 #  ifndef _WINDOWS  /* TEST TEST */     HTRequest_setOutputStream (me->request, AHTFWriter_new (me->request, me->output, YES));
    HTRequest_setOutputStream (me->request,     /*
                               AHTFWriter_new (me->request, me->output, YES));     HTRequest_setOutputStream (me->request, HTFWriter_new (me->request, me->output, YES));
 #  else     */
    HTRequest_setOutputStream (me->request,  
                               HTFWriter_new (me->request, me->output, YES));  
 #endif /* WINDOWS */  
    me->anchor = (HTParentAnchor *) HTAnchor_findAddress (urlName);     me->anchor = (HTParentAnchor *) HTAnchor_findAddress (urlName);
   
    /* Set the Content-Type of the file we are uploading */     /* Set the Content-Type of the file we are uploading */

Removed from v.1.55  
changed lines
  Added in v.1.56


Webmaster