Diff for /Amaya/amaya/query.c between versions 1.222 and 1.223

version 1.222, 2000/01/21 14:04:50 version 1.223, 2000/01/28 16:21:35
Line 25 Line 25
 #define AMAYA_WWW_CACHE  #define AMAYA_WWW_CACHE
 #define AMAYA_LOST_UPDATE  #define AMAYA_LOST_UPDATE
   
 #if defined(_I18N_) || defined(__JIS__)  #ifdef _WINDOWS
 #   ifdef _WINDOWS  #      define CACHE_DIR_NAME CUSTEXT("\\libwww-cache\\")
 #         define CACHE_DIR_NAME L"\\libwww-cache\\"  #else
 #   else  #      define CACHE_DIR_NAME CUSTEXT("/libwww-cache/")
 #         define CACHE_DIR_NAME L"/libwww-cache/"  #endif
 #   endif /* _WINDOWS */  
 #else /*  */  
 #     ifdef _WINDOWS  
 #           define CACHE_DIR_NAME "\\libwww-cache\\"  
 #     else  
 #           define CACHE_DIR_NAME "/libwww-cache/"  
 #     endif /* _WINDOWS */  
 #endif /*  */  
   
 /* libwww default parameters */  /* libwww default parameters */
 #define DEFAULT_CACHE_SIZE 10  #define DEFAULT_CACHE_SIZE 10
Line 57 Line 49
 #include <fcntl.h>  #include <fcntl.h>
 #include "HTEvtLst.h"  #include "HTEvtLst.h"
 #include "HTAABrow.h"  #include "HTAABrow.h"
   #include "ustring.h"
   
 #if defined(__svr4__) || defined (_AIX)  #if defined(__svr4__) || defined (_AIX)
 #define CATCH_SIG  #define CATCH_SIG
Line 124  static int          fd_cachelock; /* ope Line 117  static int          fd_cachelock; /* ope
 /* prototypes */  /* prototypes */
   
 #ifdef __STDC__  #ifdef __STDC__
 static void RecCleanCache (STRING dirname);  static void RecCleanCache (CharUnit* dirname);
 #ifdef _WINDOWS  #ifdef _WINDOWS
 int WIN_Activate_Request (HTRequest* , HTAlertOpcode, int, const char*, void*, HTAlertPar*);  int WIN_Activate_Request (HTRequest* , HTAlertOpcode, int, const char*, void*, HTAlertPar*);
 #endif /* _WINDOWS */  #endif /* _WINDOWS */
Line 155  static ThotBool SafePut_query (/* char * Line 148  static ThotBool SafePut_query (/* char *
   filename and fd_cachelock will take its value.    filename and fd_cachelock will take its value.
   ----------------------------------------------------------------------*/    ----------------------------------------------------------------------*/
 #ifdef __STDC__  #ifdef __STDC__
 static int set_cachelock (STRING filename)  static int set_cachelock (CharUnit* filename)
 #else          #else        
 static int set_cachelock (filename)  static int set_cachelock (filename)
 STRING filename;  CharUniut* filename;
 #endif /* __STDC__ */  #endif /* __STDC__ */
 {  {
   int status;    int status;
Line 224  int *fd; Line 217  int *fd;
   returns the pid of the process who has the lock    returns the pid of the process who has the lock
   ----------------------------------------------------------------------*/    ----------------------------------------------------------------------*/
 #ifdef __STDC__  #ifdef __STDC__
 static int test_cachelock (STRING filename)  static int test_cachelock (CharUnit* filename)
 #else  #else
 static int test_cachelock (filename)  static int test_cachelock (filename)
 STRING filename;  CharUnit*  filename;
 #endif /* __STDC__ */  #endif /* __STDC__ */
 {  {
 #ifdef _WINDOWS  #ifdef _WINDOWS
Line 770  int                 status; Line 763  int                 status;
             || (me->method == METHOD_PUT))               || (me->method == METHOD_PUT)) 
           {            {
             TtaFreeMemory (me->urlName);              TtaFreeMemory (me->urlName);
             me->urlName = WideChar2ISO (TtaStrdup (ISO2WideChar (new_anchor->parent->address)));              me->urlName = TtaStrdup (new_anchor->parent->address);
           }            }
         else          else
           /* it's a SYNC mode, so we should keep the urlName */            /* it's a SYNC mode, so we should keep the urlName */
Line 1176  int                 status; Line 1169  int                 status;
            /* libwww gives www/unknown when it gets an error. As this is              /* libwww gives www/unknown when it gets an error. As this is 
               an HTML test, we force the type to text/html */                an HTML test, we force the type to text/html */
            if (!strcmp (content_type, "www/unknown"))             if (!strcmp (content_type, "www/unknown"))
              me->content_type = WideChar2ISO (TtaStrdup (TEXT("text/html")));               me->content_type = TtaStrdup ("text/html");
            else             else
              me->content_type = WideChar2ISO (TtaStrdup (ISO2WideChar (content_type)));               me->content_type = TtaStrdup (content_type);
                         
            /* Content-Type can be specified by an httpd  server's admin.             /* Content-Type can be specified by an httpd  server's admin.
               To be on the safe side, we normalize its case */                To be on the safe side, we normalize its case */
Line 1318  static void           AHTAcceptTypesInit Line 1311  static void           AHTAcceptTypesInit
 HTList             *c;  HTList             *c;
 #endif /* __STDC__ */  #endif /* __STDC__ */
 {  {
   if (c == (HTList *) NULL)      if (c == (HTList *) NULL) 
       return;        return;
   
       /* define here all the mime types that Amaya can accept */     /* define here all the mime types that Amaya can accept */
   
       HTConversion_add (c, "image/png",  "www/present",      HTConversion_add (c, "image/png",  "www/present", HTThroughLine, 1.0, 0.0, 0.0);
                         HTThroughLine, 1.0, 0.0, 0.0);     HTConversion_add (c, "image/jpeg", "www/present", HTThroughLine, 1.0, 0.0, 0.0);
       HTConversion_add (c, "image/jpeg", "www/present",      HTConversion_add (c, "image/gif",  "www/present", HTThroughLine, 1.0, 0.0, 0.0);
                         HTThroughLine, 1.0, 0.0, 0.0);     HTConversion_add (c, "image/xbm",  "www/present", HTThroughLine, 1.0, 0.0, 0.0);
       HTConversion_add (c, "image/gif",  "www/present",      HTConversion_add (c, "image/xpm",  "www/present", HTThroughLine, 1.0, 0.0, 0.0);
                         HTThroughLine, 1.0, 0.0, 0.0);  
       HTConversion_add (c, "image/xbm",  "www/present",   
                         HTThroughLine, 1.0, 0.0, 0.0);  
       HTConversion_add (c, "image/xpm",  "www/present",   
                         HTThroughLine, 1.0, 0.0, 0.0);  
   
    /* Define here the equivalences between MIME types and file extensions for     /* Define here the equivalences between MIME types and file extensions for
     the types that Amaya can display */        the types that Amaya can display */
   
    /* Initialize suffix bindings for local files */     /* Initialize suffix bindings for local files */
    HTBind_init();     HTBind_init();
Line 1359  static void         AHTAcceptLanguagesIn Line 1347  static void         AHTAcceptLanguagesIn
 HTList             *c;  HTList             *c;
 #endif /* __STDC__ */  #endif /* __STDC__ */
 {  {
   STRING            ptr;    CharUnit*         ptr;
   STRING            lang_list;    CharUnit*         lang_list;
   CHAR_T            s[3];    char              s[3];
   int               count, lg;    int               count, lg;
   double            quality;    double            quality;
   ThotBool          still;    ThotBool          still;
Line 1371  HTList             *c; Line 1359  HTList             *c;
       
   lang_list = TtaGetEnvString ("ACCEPT_LANGUAGES");    lang_list = TtaGetEnvString ("ACCEPT_LANGUAGES");
   s[2] = EOS;    s[2] = EOS;
   if (lang_list && *lang_list != EOS)    if (lang_list && *lang_list != CUS_EOS)
     {      {
       /* add the default language first  */        /* add the default language first  */
       HTLanguage_add (c, "*", -1.0);        HTLanguage_add (c, "*", -1.0);
       /* how many languages do we have? */        /* how many languages do we have? */
       ptr = lang_list;        ptr = lang_list;
       count = 0;        count = 0;
       while (*ptr != EOS)        while (*ptr != CUS_EOS) {
         {              while (*ptr != CUS_EOS && (*ptr < CUSTEXT('A') || (*ptr > CUSTEXT('Z') && *ptr < CUSTEXT('a')) || *ptr > CUSTEXT('z')))
           while (*ptr != EOS &&                    /* skip the whole separator */
                  (*ptr < 'A' || (*ptr > 'Z' && *ptr < 'a') || *ptr > 'z'))                    ptr++;
             /* skip the whole separator */              lg = 0;
             ptr++;              while ((*ptr >= CUSTEXT('A') && *ptr <= CUSTEXT('Z')) || (*ptr >= CUSTEXT('a') && *ptr <= CUSTEXT('z')) || *ptr == CUSTEXT('-')) {
           lg = 0;                    /* it's a new language */
           while ((*ptr >= 'A' && *ptr <= 'Z') || (*ptr >= 'a' && *ptr <= 'z') || *ptr == '-')                    ptr++;
             {                    lg++;
               /* it's a new language */                          }
               ptr++;              if (lg >= 2)
               lg++;                 count++;
             }              if (*ptr != CUS_EOS)
           if (lg >= 2)                 ptr++;
             count++;            }
           if (*ptr != EOS)  
             ptr++;  
         }  
   
       if (count > 0)        if (count > 0)
         quality = 1.1 - (double) count/10.0;           quality = 1.1 - (double) count/10.0;
       else        else
         quality = 1.0;            quality = 1.0;
   
       /*       /* Read the languages from the registry, then inject them one, by one.
         Read the languages from the registry, then inject them one, by one.          The first one is the one with the highest priority.
         The first one is the one with the highest priority.          The libwww ask for the lowest priority first.
         The libwww ask for the lowest priority first.  
       */        */
       ptr--;        ptr--;
       still = TRUE;        still = TRUE;
       while (count)         while (count) {
         {              while (still && (*ptr < CUSTEXT('A') || (*ptr > CUSTEXT('Z') && *ptr < CUSTEXT('a')) || *ptr > CUSTEXT('z')))
           while (still &&                    /* skip the whole separator */
                  (*ptr < 'A' || (*ptr > 'Z' && *ptr < 'a') || *ptr > 'z'))                    if (ptr > lang_list)
             /* skip the whole separator */                       ptr--;
             if (ptr > lang_list)                    else
               ptr--;                        still = FALSE;
             else              lg = 0;
               still = FALSE;              while (still && ((*ptr >= CUSTEXT('A') && *ptr <= CUSTEXT('Z')) || (*ptr >= CUSTEXT('a') && *ptr <= CUSTEXT('z')) || *ptr == CUSTEXT('-'))) {
           lg = 0;                    /* it's a new language */
           while (still &&                    if (ptr > lang_list)
                  ((*ptr >= 'A' && *ptr <= 'Z') || (*ptr >= 'a' && *ptr <= 'z') || *ptr == '-'))                       ptr--;
             {                    else
               /* it's a new language */                        still = FALSE;
               if (ptr > lang_list)                    lg++;
                 ptr--;                          }
               else              if (lg >= 2) {
                 still = FALSE;                 if (still)
               lg++;                    cus2iso_strncpy  (s, &ptr[1], 2);
             }                 else
           if (lg >= 2)                     cus2iso_strncpy (s, lang_list, 2);
             {                 count--;
               if (still)                 HTLanguage_add (c, WideChar2ISO(s), quality);
                 ustrncpy (s, &ptr[1], 2);                 quality += 0.1;
               else                          }
                 ustrncpy (s, lang_list, 2);              ptr--;
               count--;            }
               HTLanguage_add (c, WideChar2ISO(s), quality);    }
               quality += 0.1;  
             }  
           ptr--;  
         }  
     }  
 }  }
   
 /*----------------------------------------------------------------------  /*----------------------------------------------------------------------
Line 1465  HTList             *c; Line 1444  HTList             *c;
     ** that is not directly outputting someting to the user on the screen      ** that is not directly outputting someting to the user on the screen
     */      */
   
    HTConversion_add (c, "message/rfc822", "*/*", HTMIMEConvert,      HTConversion_add (c, "message/rfc822", "*/*", HTMIMEConvert, 1.0, 0.0, 0.0);
                      1.0, 0.0, 0.0);     HTConversion_add (c, "message/x-rfc822-foot", "*/*", HTMIMEFooter, 1.0, 0.0, 0.0);
    HTConversion_add (c, "message/x-rfc822-foot", "*/*", HTMIMEFooter,     HTConversion_add (c, "message/x-rfc822-head", "*/*", HTMIMEHeader, 1.0, 0.0, 0.0);
                      1.0, 0.0, 0.0);     HTConversion_add(c,"message/x-rfc822-cont",  "*/*", HTMIMEContinue, 1.0, 0.0, 0.0);
    HTConversion_add (c, "message/x-rfc822-head", "*/*", HTMIMEHeader,     HTConversion_add(c,"message/x-rfc822-partial","*/*", HTMIMEPartial, 1.0, 0.0, 0.0);
                      1.0, 0.0, 0.0);     HTConversion_add (c, "multipart/*", "*/*", HTBoundary, 1.0, 0.0, 0.0);
    HTConversion_add(c,"message/x-rfc822-cont",  "*/*", HTMIMEContinue,       HTConversion_add (c, "text/plain", "text/html", HTPlainToHTML, 1.0, 0.0, 0.0);
                     1.0, 0.0, 0.0);  
    HTConversion_add(c,"message/x-rfc822-partial","*/*", HTMIMEPartial,  
                     1.0, 0.0, 0.0);  
    HTConversion_add (c, "multipart/*", "*/*", HTBoundary,  
                      1.0, 0.0, 0.0);  
    HTConversion_add (c, "text/plain", "text/html", HTPlainToHTML,  
                      1.0, 0.0, 0.0);  
   
    /*     /*
    ** The following conversions are converting ASCII output from various     ** The following conversions are converting ASCII output from various
    ** protocols to HTML objects.     ** protocols to HTML objects.
    */     */
    HTConversion_add (c, "text/x-http", "*/*", HTTPStatus_new,     HTConversion_add (c, "text/x-http", "*/*", HTTPStatus_new, 1.0, 0.0, 0.0);
                      1.0, 0.0, 0.0);  
   
    /*     /*
    ** We also register a special content type guess stream that can figure out     ** We also register a special content type guess stream that can figure out
    ** the content type by reading the first bytes of the stream     ** the content type by reading the first bytes of the stream
    */     */
    HTConversion_add (c, "www/unknown", "*/*", HTGuess_new,     HTConversion_add (c, "www/unknown", "*/*", HTGuess_new, 1.0, 0.0, 0.0);
                      1.0, 0.0, 0.0);  
   
 #ifdef AMAYA_WWW_CACHE  #ifdef AMAYA_WWW_CACHE
    /*     /*
    ** Register a persistent cache stream which can save an object to local     ** Register a persistent cache stream which can save an object to local
    ** file     ** file
    */     */
    HTConversion_add (c, "www/cache", "*/*", HTCacheWriter,     HTConversion_add (c, "www/cache", "*/*", HTCacheWriter, 1.0, 0.0, 0.0);
                      1.0, 0.0, 0.0);     HTConversion_add(c,"www/cache-append", "*/*", HTCacheAppend, 1.0, 0.0, 0.0);
    HTConversion_add(c,"www/cache-append", "*/*", HTCacheAppend,  
                     1.0, 0.0, 0.0);  
 #endif AMAYA_WWW_CACHE  #endif AMAYA_WWW_CACHE
   
    /*     /*
    ** This dumps all other formats to local disk without any further     ** This dumps all other formats to local disk without any further
    ** action taken     ** action taken
    */     */
    HTConversion_add (c, "*/*", "www/present", HTSaveLocally,     HTConversion_add (c, "*/*", "www/present", HTSaveLocally, 0.3, 0.0, 0.0);  
                      0.3, 0.0, 0.0);    
 }  }
   
   
Line 1520  HTList             *c; Line 1487  HTList             *c;
   ----------------------------------------------------------------------*/    ----------------------------------------------------------------------*/
 static void         AHTProtocolInit (void)  static void         AHTProtocolInit (void)
 {  {
   char *strptr;    CharUnit* strptr;
   
   /*     /* 
      NB. Preemptive == YES means Blocking requests       NB. Preemptive == YES means Blocking requests
Line 1543  static void         AHTProtocolInit (voi Line 1510  static void         AHTProtocolInit (voi
 #endif  #endif
   
    /* initialize pipelining */     /* initialize pipelining */
   strptr = (char *) TtaGetEnvString ("ENABLE_PIPELINING");    strptr = TtaGetEnvString ("ENABLE_PIPELINING");
   if (strptr && *strptr && strcasecmp (strptr,"yes" ))    if (strptr && *strptr && StringCaseCompare (strptr, CUSTEXT("yes")))
     HTTP_setConnectionMode (HTTP_11_NO_PIPELINING);      HTTP_setConnectionMode (HTTP_11_NO_PIPELINING);
 }  }
   
Line 1572  static void         AHTNetInit (void) Line 1539  static void         AHTNetInit (void)
 **      Not done automaticly - may be done by application!  **      Not done automaticly - may be done by application!
 */  */
   
   HTNet_addAfter (HTAuthFilter, "http://*", NULL, HT_NO_ACCESS,    HTNet_addAfter (HTAuthFilter, "http://*", NULL, HT_NO_ACCESS, HT_FILTER_MIDDLE);
                   HT_FILTER_MIDDLE);    HTNet_addAfter (HTAuthFilter, "http://*", NULL, HT_REAUTH, HT_FILTER_MIDDLE);
   HTNet_addAfter(HTAuthFilter, "http://*", NULL, HT_REAUTH,    HTNet_addAfter (redirection_handler, "http://*", NULL, HT_PERM_REDIRECT, HT_FILTER_MIDDLE);
                  HT_FILTER_MIDDLE);    HTNet_addAfter (redirection_handler, "http://*", NULL, HT_FOUND, HT_FILTER_MIDDLE);
   HTNet_addAfter (redirection_handler, "http://*", NULL, HT_PERM_REDIRECT,    HTNet_addAfter (redirection_handler, "http://*", NULL, HT_SEE_OTHER, HT_FILTER_MIDDLE);
                   HT_FILTER_MIDDLE);    HTNet_addAfter (redirection_handler, "http://*", NULL, HT_TEMP_REDIRECT, HT_FILTER_MIDDLE);
   HTNet_addAfter (redirection_handler, "http://*", NULL, HT_FOUND,     HTNet_addAfter (HTAuthInfoFilter,     "http://*", NULL, HT_ALL, HT_FILTER_MIDDLE);
                   HT_FILTER_MIDDLE);    HTNet_addAfter (HTUseProxyFilter, "http://*", NULL, HT_USE_PROXY, HT_FILTER_MIDDLE);
   HTNet_addAfter (redirection_handler, "http://*", NULL, HT_SEE_OTHER,  
                   HT_FILTER_MIDDLE);  
   HTNet_addAfter (redirection_handler, "http://*", NULL, HT_TEMP_REDIRECT,  
                   HT_FILTER_MIDDLE);  
   HTNet_addAfter(HTAuthInfoFilter,      "http://*", NULL, HT_ALL,   
                  HT_FILTER_MIDDLE);  
   HTNet_addAfter (HTUseProxyFilter, "http://*", NULL, HT_USE_PROXY,  
                   HT_FILTER_MIDDLE);  
 #ifdef AMAYA_LOST_UPDATE  #ifdef AMAYA_LOST_UPDATE
   HTNet_addAfter (precondition_handler, NULL, NULL, HT_PRECONDITION_FAILED,    HTNet_addAfter (precondition_handler, NULL, NULL, HT_PRECONDITION_FAILED, HT_FILTER_MIDDLE);
                   HT_FILTER_MIDDLE);  
 #endif /* AMAYA_LOST_UPDATE */  #endif /* AMAYA_LOST_UPDATE */
 #ifndef _WINDOWS  #ifndef _WINDOWS
   HTNet_addAfter (AHTLoadTerminate_handler, NULL, NULL, HT_ALL,     HTNet_addAfter (AHTLoadTerminate_handler, NULL, NULL, HT_ALL, HT_FILTER_LAST);        
                    HT_FILTER_LAST);       
 #endif /* !_WINDOWS */  #endif /* !_WINDOWS */
    /**** for later ?? ****/     /**** for later ?? ****/
    /*  HTNet_addAfter(HTInfoFilter,     NULL,           NULL, HT_ALL,           HT_FILTER_LATE); */     /*  HTNet_addAfter(HTInfoFilter,     NULL,           NULL, HT_ALL,           HT_FILTER_LATE); */
Line 1712  View view; Line 1669  View view;
   Clears an existing cache directory    Clears an existing cache directory
   ----------------------------------------------------------------------*/    ----------------------------------------------------------------------*/
 #ifdef __STDC__  #ifdef __STDC__
 static void RecCleanCache (STRING dirname)  static void RecCleanCache (CharUnit* dirname)
 #else  #else
 static void RecCleanCache (dirname)  static void RecCleanCache (dirname)
 STRING dirname;  CharUnit*   dirname;
 #endif /* __STDC__ */  #endif /* __STDC__ */
   
 #ifdef _WINDOWS  #ifdef _WINDOWS
 {  {
   HANDLE hFindFile;    HANDLE          hFindFile;
   ThotBool status;    ThotBool        status;
   WIN32_FIND_DATA ffd;    WIN32_FIND_DATA ffd;
       CharUnit        t_dir [MAX_LENGTH];
   CHAR_T t_dir [MAX_LENGTH];    CharUnit*       ptr;
   STRING ptr;  
   
   /* create a t_dir name to start searching for files */    /* create a t_dir name to start searching for files */
   if ((ustrlen (dirname) + 10) > MAX_LENGTH)    if ((StringLength (dirname) + 10) > MAX_LENGTH)
     /* ERROR: directory name is too big */      /* ERROR: directory name is too big */
     return;      return;
   
   ustrcpy (t_dir, dirname);    StringCopy (t_dir, dirname);
   /* save the end of the dirname. We'll use it to make    /* save the end of the dirname. We'll use it to make
      a complete pathname when erasing files */       a complete pathname when erasing files */
   ptr = &t_dir[ustrlen (t_dir)];    ptr = &t_dir[StringLength (t_dir)];
   ustrcat (t_dir, TEXT("*"));    StringConcat (t_dir, CUSTEXT("*"));
   
   hFindFile = FindFirstFile (t_dir, &ffd);    hFindFile = FindFirstFile (t_dir, &ffd);
           
Line 1750  STRING dirname; Line 1706  STRING dirname;
       if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)        if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
         {          {
           /* it's a directory, erase it recursively */            /* it's a directory, erase it recursively */
           if (ustrcmp (ffd.cFileName, TEXT("..")) && ustrcmp (ffd.cFileName, TEXT(".")))            if (StringCompare (ffd.cFileName, CUSTEXT("..")) && StringCompare (ffd.cFileName, TEXT(".")))
             {              {
               ustrcpy (ptr, ffd.cFileName);                StringCopy (ptr, ffd.cFileName);
               ustrcat (ptr, DIR_STR);                StringConcat (ptr, CUS_DIR_STR);
               RecCleanCache (t_dir);                RecCleanCache (t_dir);
               urmdir (t_dir);                urmdir (t_dir);
             }              }
Line 1761  STRING dirname; Line 1717  STRING dirname;
         else          else
           {            {
             /* it's a file, erase it */              /* it's a file, erase it */
             ustrcpy (ptr, ffd.cFileName);              StringCopy (ptr, ffd.cFileName);
             TtaFileUnlink (t_dir);              TtaFileUnlink (t_dir);
           }            }
       status = FindNextFile (hFindFile, &ffd);        status = FindNextFile (hFindFile, &ffd);
Line 1840  static void Cacheinit () Line 1796  static void Cacheinit ()
    HTCacheMode_setEnabled (NO);     HTCacheMode_setEnabled (NO);
   
 #else /* AMAYA_WWW_CACHE */  #else /* AMAYA_WWW_CACHE */
   STRING strptr;    CharUnit* strptr;
   STRING cache_dir = NULL;    CharUnit* real_dir = NULL;
   STRING real_dir = NULL;    CharUnit* cache_lockfile;
   STRING cache_lockfile;    char      www_realDir[MAX_LENGTH];
   int cache_size;    char*     cache_dir = NULL;
   int cache_entry_size;    int       cache_size;
   ThotBool cache_enabled;    int       cache_entry_size;
   ThotBool cache_locked;    ThotBool  cache_enabled;
   ThotBool tmp_bool;    ThotBool  cache_locked;
     ThotBool  tmp_bool;
   
 int i;  int i;
   
   /* activate cache? */    /* activate cache? */
   strptr = TtaGetEnvString ("ENABLE_CACHE");    strptr = TtaGetEnvString ("ENABLE_CACHE");
   if (strptr && *strptr && ustrcasecmp (strptr, TEXT("yes")))    if (strptr && *strptr && StringCaseCompare (strptr, CUSTEXT("yes")))
     cache_enabled = NO;      cache_enabled = NO;
   else    else
     cache_enabled = YES;      cache_enabled = YES;
   
   /* cache protected documents? */    /* cache protected documents? */
   strptr = TtaGetEnvString ("CACHE_PROTECTED_DOCS");    strptr = TtaGetEnvString ("CACHE_PROTECTED_DOCS");
   if (strptr && *strptr && !ustrcasecmp (strptr, TEXT("yes")))    if (strptr && *strptr && !StringCaseCompare (strptr, CUSTEXT("yes")))
     HTCacheMode_setProtected (YES);      HTCacheMode_setProtected (YES);
   else    else
     HTCacheMode_setProtected (NO);      HTCacheMode_setProtected (NO);
Line 1870  int i; Line 1827  int i;
   strptr = TtaGetEnvString ("CACHE_DIR");    strptr = TtaGetEnvString ("CACHE_DIR");
   if (strptr && *strptr)     if (strptr && *strptr) 
     {      {
       real_dir = TtaAllocString (ustrlen (strptr) + ustrlen (CACHE_DIR_NAME) + 20);        real_dir = TtaAllocCUString (StringLength (strptr) + StringLength (CACHE_DIR_NAME) + 20);
       ustrcpy (real_dir, strptr);        StringCopy (real_dir, strptr);
           if (*(real_dir + ustrlen (real_dir) - 1) != DIR_SEP)            if (*(real_dir + StringLength (real_dir) - 1) != CUS_DIR_SEP)
             ustrcat (real_dir, DIR_STR);              StringConcat (real_dir, CUS_DIR_STR);
     }      }
   else    else
     {      {
       real_dir = TtaAllocString (ustrlen (TempFileDirectory)        real_dir = TtaAllocCUString (StringLength (TempFileDirectory) + StringLength (CACHE_DIR_NAME) + 20);
                                + ustrlen (CACHE_DIR_NAME) + 20);        cus_sprintf (real_dir, CUSTEXT("%s%s"), TempFileDirectory, CACHE_DIR_NAME);
       usprintf (real_dir, TEXT("%s%s"), TempFileDirectory, CACHE_DIR_NAME);  
     }      }
   
   /* compatiblity with previous versions of Amaya: does real_dir    /* compatiblity with previous versions of Amaya: does real_dir
      include CACHE_DIR_NAME? If not, add it */       include CACHE_DIR_NAME? If not, add it */
   strptr = ustrstr (real_dir, CACHE_DIR_NAME);    strptr = StringSubstring (real_dir, CACHE_DIR_NAME);
   if (!strptr)    if (!strptr)
   {      StringConcat (real_dir, CACHE_DIR_NAME);
     ustrcat (real_dir, CACHE_DIR_NAME);  
   }  
   else    else
     {      {
       i = ustrlen (CACHE_DIR_NAME);        i = StringLength (CACHE_DIR_NAME);
           if (strptr[i] != EOS)            if (strptr[i] != CUS_EOS)
           ustrcat (real_dir, CACHE_DIR_NAME);            StringConcat (real_dir, CACHE_DIR_NAME);
     }      }
   
   /* convert the local cache dir into a file URL, as expected by    /* convert the local cache dir into a file URL, as expected by
      libwww */       libwww */
   cache_dir = HTLocalToWWW (WideChar2ISO (real_dir), "file:");   
     cus2iso_strcpy (www_realDir, real_dir);
   
     cache_dir = HTLocalToWWW (www_realDir, "file:");
   
   /* get the cache size (or use a default one) */    /* get the cache size (or use a default one) */
   strptr = TtaGetEnvString ("CACHE_SIZE");    strptr = TtaGetEnvString ("CACHE_SIZE");
   if (strptr && *strptr)     if (strptr && *strptr) 
     cache_size = uctoi (strptr);      cache_size = custoi (strptr);
   else    else
     cache_size = DEFAULT_CACHE_SIZE;      cache_size = DEFAULT_CACHE_SIZE;
   
   /* get the max cached file size (or use a default one) */    /* get the max cached file size (or use a default one) */
   if (!TtaGetEnvInt (TEXT("MAX_CACHE_ENTRY_SIZE"), &cache_entry_size))    if (!TtaGetEnvInt ("MAX_CACHE_ENTRY_SIZE", &cache_entry_size))
     cache_entry_size = DEFAULT_MAX_CACHE_ENTRY_SIZE;      cache_entry_size = DEFAULT_MAX_CACHE_ENTRY_SIZE;
   
   if (cache_enabled)     if (cache_enabled) 
     {      {
       /* how to remove the lock? force remove it? */        /* how to remove the lock? force remove it? */
       cache_lockfile = TtaAllocString (ustrlen (real_dir) + 20);        cache_lockfile = TtaAllocCUString (StringLength (real_dir) + 20);
       ustrcpy (cache_lockfile, real_dir);        StringCopy (cache_lockfile, real_dir);
       ustrcat (cache_lockfile, TEXT(".lock"));        StringConcat (cache_lockfile, CUSTEXT(".lock"));
       cache_locked = FALSE;        cache_locked = FALSE;
       if (TtaFileExist (cache_lockfile)        if (TtaFileExist (cache_lockfile) && !(cache_locked = test_cachelock (cache_lockfile)))
           && !(cache_locked = test_cachelock (cache_lockfile)))  
         {          {
 #ifdef DEBUG_LIBWWW  #ifdef DEBUG_LIBWWW
           fprintf (stderr, "found a stale cache, removing it\n");            fprintf (stderr, "found a stale cache, removing it\n");
Line 1927  int i; Line 1883  int i;
           /* remove the lock and clean the cache (the clean cache             /* remove the lock and clean the cache (the clean cache 
              will remove all, making the following call unnecessary */               will remove all, making the following call unnecessary */
           /* little trick to win some memory */            /* little trick to win some memory */
           strptr = ustrrchr (cache_lockfile, TEXT('.'));            strptr = StrRChr (cache_lockfile, CUSTEXT('.'));
           *strptr = EOS;            *strptr = CUS_EOS;
           RecCleanCache (cache_lockfile);            RecCleanCache (cache_lockfile);
           *strptr = '.';            *strptr = CUSTEXT('.');
         }          }
   
       if (!cache_locked)         if (!cache_locked) 
Line 1938  int i; Line 1894  int i;
           /* initialize the cache if there's no other amaya            /* initialize the cache if there's no other amaya
              instance running */               instance running */
           HTCacheMode_setMaxCacheEntrySize (cache_entry_size);            HTCacheMode_setMaxCacheEntrySize (cache_entry_size);
           if (TtaGetEnvBoolean (TEXT("CACHE_EXPIRE_IGNORE"), &tmp_bool)             if (TtaGetEnvBoolean ("CACHE_EXPIRE_IGNORE", &tmp_bool) && tmp_bool)
               && tmp_bool)  
             HTCacheMode_setExpires (HT_EXPIRES_IGNORE);              HTCacheMode_setExpires (HT_EXPIRES_IGNORE);
           else            else
             HTCacheMode_setExpires (HT_EXPIRES_AUTO);              HTCacheMode_setExpires (HT_EXPIRES_AUTO);
           TtaGetEnvBoolean (TEXT("CACHE_DISCONNECTED_MODE"), &tmp_bool);            TtaGetEnvBoolean ("CACHE_DISCONNECTED_MODE", &tmp_bool);
           if (tmp_bool)            if (tmp_bool)
             HTCacheMode_setDisconnected (HT_DISCONNECT_NORMAL);              HTCacheMode_setDisconnected (HT_DISCONNECT_NORMAL);
           else            else
Line 2007  static void ProxyInit (void) Line 1962  static void ProxyInit (void)
 static void ProxyInit ()  static void ProxyInit ()
 #endif /* __STDC__ */  #endif /* __STDC__ */
 {  {
   STRING strptr;    CharUnit* strptr;
   STRING str = NULL;    CharUnit* str = NULL;
   STRING name;    char*     name;
   ThotBool proxy_is_onlyproxy;    ThotBool  proxy_is_onlyproxy;
     char*     tmp = (char*) 0;
   char*  strptrA;    char*     strptrA;
   
   /* get the proxy settings from the thot.ini file */    /* get the proxy settings from the thot.ini file */
   strptr = TtaGetEnvString ("HTTP_PROXY");    strptr = TtaGetEnvString ("HTTP_PROXY");
   if (strptr && *strptr)    if (strptr) {
     {       tmp = (char*) TtaGetMemory (StringLength (strptr) + 1);
       /* does the proxy env string has an "http://" prefix? */       cus2iso_strcpy (tmp, strptr);
       if ( !ustrncasecmp( strptr, "http://", 7))    }
         HTProxy_add ("http", WideChar2ISO (strptr));  
       else    if (strptr && *strptr) {
         {       /* does the proxy env string has an "http://" prefix? */
           strptrA = (char *) TtaGetMemory (ustrlen (strptr) + 9);       if (!StringNCaseCompare (strptr, CUSTEXT("http://"), 7)) 
           strcpy (strptrA, "http://");          HTProxy_add ("http", tmp);
           strcat (strptrA, WideChar2ISO (strptr));       else {
           HTProxy_add ("http", strptrA);            strptrA = (char*) TtaGetMemory (ustrlen (strptr) + 9);
           TtaFreeMemory (strptrA);            strcpy (strptrA, "http://");
         }            strcat (strptrA, tmp);
     }            HTProxy_add ("http", strptrA);
             TtaFreeMemory (strptrA);
            }
        TtaFreeMemory (tmp);
        tmp = (char*) 0;
     }
   
   /* get the no_proxy settings from the thot.ini file */    /* get the no_proxy settings from the thot.ini file */
   strptr = TtaGetEnvString ("PROXYDOMAIN");    strptr = TtaGetEnvString ("PROXYDOMAIN");
   if (strptr && *strptr)     if (strptr) {
     {       tmp = (char*) TtaGetMemory (StringLength (strptr) + 1);
       str = TtaStrdup (strptr);          /* Get copy we can mutilate */       cus2iso_strcpy (tmp, strptr);
       strptr = str;    }
       strptrA = WideChar2ISO (strptr);  
       while ((name = ISO2WideChar(HTNextField (&strptrA))) != NULL) {    if (strptr && *strptr) {
         STRING portstr = ustrchr (name, TEXT(':'));       str = StringDuplicate (strptr);          /* Get copy we can mutilate */
         unsigned port=0;       strptr = str;
         if (portstr) {        while ((name = HTNextField (&tmp)) != NULL) {
           *portstr++ = EOS;             char* portstr = strchr (name, ':');
           if (*portstr) port = (unsigned) uctoi (portstr);             unsigned port=0;
         }             if (portstr) { 
         /* Register it for all access methods */                *portstr++ = EOS;
         HTNoProxy_add (WideChar2ISO (name), NULL, port);                if (*portstr) port = (unsigned) atoi (portstr);
       }                     }
       TtaFreeMemory (str);             /* Register it for all access methods */
     }             HTNoProxy_add (name, NULL, port);
            }
        TtaFreeMemory (str);
        TtaFreeMemory (tmp);
        tmp = (char*)0;
     }
   
   /* how should we interpret the proxy domain list? */    /* how should we interpret the proxy domain list? */
   TtaGetEnvBoolean ("PROXYDOMAIN_IS_ONLYPROXY", &proxy_is_onlyproxy);    TtaGetEnvBoolean ("PROXYDOMAIN_IS_ONLYPROXY", &proxy_is_onlyproxy);
Line 2070  static void SafePut_init (void) Line 2035  static void SafePut_init (void)
 static void SafePut_init ()  static void SafePut_init ()
 #endif /* __STDC__ */  #endif /* __STDC__ */
 {  {
   STRING strptr;    CharUnit* strptr;
   STRING str = NULL;    CharUnit* str = NULL;
   char  *strptrA, *ptr;    char*     ptr, strptrA[MAX_LENGTH];
   char *domain;    char*     domain;
   
   /* get the proxy settings from the thot.ini file */    /* get the proxy settings from the thot.ini file */
   strptr = TtaGetEnvString ("SAFE_PUT_REDIRECT");    strptr = TtaGetEnvString ("SAFE_PUT_REDIRECT");
   if (strptr && *strptr)    if (strptr && *strptr)
     {      {
       /* Get copy we can mutilate */        /* Get copy we can mutilate */
       str = TtaStrdup (strptr);                  str = StringDuplicate (strptr);
       strptrA = WideChar2ISO (str);        cus2iso_strcpy (strptrA, strptr);
       /* convert to lowercase */        /* convert to lowercase */
       ptr = strptrA;        ptr = strptrA;
       while (*ptr)         while (*ptr) 
Line 2150  static ThotBool SafePut_query (char *url Line 2115  static ThotBool SafePut_query (char *url
   creates the Amaya client profile for libwww.    creates the Amaya client profile for libwww.
   ----------------------------------------------------------------------*/    ----------------------------------------------------------------------*/
 #ifdef __STDC__  #ifdef __STDC__
 static void         AHTProfile_newAmaya (STRING AppName, STRING AppVersion)  static void         AHTProfile_newAmaya (char* AppName, char* AppVersion)
 #else  /* __STDC__ */  #else  /* __STDC__ */
 static void         AHTProfile_newAmaya (AppName, AppVersion)  static void         AHTProfile_newAmaya (AppName, AppVersion)
 STRING AppName;  char* AppName;
 STRING AppVersion;  char* AppVersion;
 #endif /* __STDC__ */  #endif /* __STDC__ */
 {  {
    STRING strptr;     CharUnit* strptr;
   
    /* If the Library is not already initialized then do it */     /* If the Library is not already initialized then do it */
    if (!HTLib_isInitialized ())     if (!HTLib_isInitialized ())
       HTLibInit (WideChar2ISO (AppName), WideChar2ISO (AppVersion));        HTLibInit (AppName, AppVersion);
   
    if (!converters)     if (!converters)
       converters = HTList_new ();        converters = HTList_new ();
Line 2198  STRING AppVersion; Line 2163  STRING AppVersion;
    AHTNetInit ();     AHTNetInit ();
   
    /* Set up the default set of Authentication schemes */     /* Set up the default set of Authentication schemes */
    HTAA_newModule ("basic", HTBasic_generate, HTBasic_parse, NULL,     HTAA_newModule ("basic", HTBasic_generate, HTBasic_parse, NULL, HTBasic_delete);
                     HTBasic_delete);  
    /* activate MDA by defaul */     /* activate MDA by defaul */
    strptr = TtaGetEnvString ("ENABLE_MDA");     strptr = TtaGetEnvString ("ENABLE_MDA");
    if (!strptr || (strptr && *strptr && ustrcasecmp (strptr, TEXT("no"))))     if (!strptr || (strptr && *strptr && StringCaseCompare (strptr, CUSTEXT("no"))))
      HTAA_newModule ("digest", HTDigest_generate, HTDigest_parse,        HTAA_newModule ("digest", HTDigest_generate, HTDigest_parse, HTDigest_updateInfo, HTDigest_delete);
                      HTDigest_updateInfo, HTDigest_delete);  
   
    /* Get any proxy settings */     /* Get any proxy settings */
    ProxyInit ();     ProxyInit ();
Line 2323  void                QueryInit () Line 2286  void                QueryInit ()
 void                QueryInit ()  void                QueryInit ()
 #endif  #endif
 {  {
   STRING strptr;    CharUnit* strptr;
   int tmp_i;    int tmp_i;
   long tmp_l;    long tmp_l;
   
Line 2370  void                QueryInit () Line 2333  void                QueryInit ()
    /* Maximum number of simultaneous open sockets */     /* Maximum number of simultaneous open sockets */
    strptr = TtaGetEnvString ("MAX_SOCKET");     strptr = TtaGetEnvString ("MAX_SOCKET");
    if (strptr && *strptr)      if (strptr && *strptr) 
      tmp_i = uctoi (strptr);       tmp_i = custoi (strptr);
    else     else
      tmp_i = DEFAULT_MAX_SOCKET;       tmp_i = DEFAULT_MAX_SOCKET;
    HTNet_setMaxSocket (tmp_i);     HTNet_setMaxSocket (tmp_i);
Line 2379  void                QueryInit () Line 2342  void                QueryInit ()
    /* dns timeout */     /* dns timeout */
    strptr = TtaGetEnvString ("DNS_TIMEOUT");     strptr = TtaGetEnvString ("DNS_TIMEOUT");
    if (strptr && *strptr)      if (strptr && *strptr) 
      tmp_i = uctoi (strptr);       tmp_i = custoi (strptr);
    else     else
      tmp_i = DEFAULT_DNS_TIMEOUT;       tmp_i = DEFAULT_DNS_TIMEOUT;
    HTDNS_setTimeout (tmp_i);     HTDNS_setTimeout (tmp_i);
Line 2387  void                QueryInit () Line 2350  void                QueryInit ()
    /* persistent connections timeout */     /* persistent connections timeout */
    strptr = TtaGetEnvString ("PERSIST_CX_TIMEOUT");     strptr = TtaGetEnvString ("PERSIST_CX_TIMEOUT");
    if (strptr && *strptr)      if (strptr && *strptr) 
      tmp_l = uctol (strptr);       tmp_l = uctol (strptr); 
    else     else
      tmp_l = DEFAULT_PERSIST_TIMEOUT;       tmp_l = DEFAULT_PERSIST_TIMEOUT;
    HTHost_setPersistTimeout (tmp_l);     HTHost_setPersistTimeout (tmp_l);
Line 2395  void                QueryInit () Line 2358  void                QueryInit ()
    /* default timeout in ms */     /* default timeout in ms */
    strptr = TtaGetEnvString ("NET_EVENT_TIMEOUT");     strptr = TtaGetEnvString ("NET_EVENT_TIMEOUT");
    if (strptr && *strptr)      if (strptr && *strptr) 
      tmp_i = uctoi (strptr);       tmp_i = custoi (strptr);
    else     else
      tmp_i = DEFAULT_NET_EVENT_TIMEOUT;       tmp_i = DEFAULT_NET_EVENT_TIMEOUT;
    HTHost_setEventTimeout (tmp_i);     HTHost_setEventTimeout (tmp_i);
Line 2909  STRING        content_type; Line 2872  STRING        content_type;
    me->anchor = (HTParentAnchor *) HTAnchor_findAddress (WideChar2ISO (ref));     me->anchor = (HTParentAnchor *) HTAnchor_findAddress (WideChar2ISO (ref));
    TtaFreeMemory (ref);     TtaFreeMemory (ref);
         
    TtaGetEnvBoolean (TEXT("CACHE_DISCONNECTED_MODE"), &bool_tmp);     TtaGetEnvBoolean ("CACHE_DISCONNECTED_MODE", &bool_tmp);
    if (!bool_tmp && (mode & AMAYA_NOCACHE))     if (!bool_tmp && (mode & AMAYA_NOCACHE))
       HTRequest_setReloadMode (me->request, HT_CACHE_FLUSH);        HTRequest_setReloadMode (me->request, HT_CACHE_FLUSH);
   

Removed from v.1.222  
changed lines
  Added in v.1.223


Webmaster