version 1.197, 1999/06/23 08:18:02
|
version 1.198, 1999/06/27 16:26:45
|
Line 25
|
Line 25
|
#define AMAYA_WWW_CACHE |
#define AMAYA_WWW_CACHE |
#define AMAYA_LOST_UPDATE |
#define AMAYA_LOST_UPDATE |
|
|
#ifdef _WINDOWS |
#if defined(_I18N_) || defined(__JIS__) |
#define CACHE_DIR_NAME "\\libwww-cache\\" |
# ifdef _WINDOWS |
#else |
# define CACHE_DIR_NAME L"\\libwww-cache\\" |
#define CACHE_DIR_NAME "/libwww-cache/" |
# else |
#endif /* _WINDOWS */ |
# define CACHE_DIR_NAME L"/libwww-cache/" |
|
# endif /* _WINDOWS */ |
|
#else /* */ |
|
# ifdef _WINDOWS |
|
# define CACHE_DIR_NAME "\\libwww-cache\\" |
|
# else |
|
# define CACHE_DIR_NAME "/libwww-cache/" |
|
# endif /* _WINDOWS */ |
|
#endif /* */ |
|
|
#define DEFAULT_CACHE_SIZE 10 |
#define DEFAULT_CACHE_SIZE 10 |
#define DEFAULT_MAX_CACHE_ENTRY_SIZE 3 |
#define DEFAULT_MAX_CACHE_ENTRY_SIZE 3 |
#define DEFAULT_MAX_SOCKET 32 |
#define DEFAULT_MAX_SOCKET 32 |
Line 106 static int fd_cachelock; /* ope
|
Line 115 static int fd_cachelock; /* ope
|
/* prototypes */ |
/* prototypes */ |
|
|
#ifdef __STDC__ |
#ifdef __STDC__ |
static void RecCleanCache (char *dirname); |
static void RecCleanCache (STRING 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 130 int WIN_Activate_Request (/* HTRequest*
|
Line 139 int WIN_Activate_Request (/* HTRequest*
|
filename and fd_cachelock will take its value. |
filename and fd_cachelock will take its value. |
----------------------------------------------------------------------*/ |
----------------------------------------------------------------------*/ |
#ifdef __STDC__ |
#ifdef __STDC__ |
static int set_cachelock (char *filename) |
static int set_cachelock (STRING filename) |
#else |
#else |
static int set_cachelock (filename) |
static int set_cachelock (filename) |
char *filename; |
STRING filename; |
#endif /* __STDC__ */ |
#endif /* __STDC__ */ |
{ |
{ |
int status; |
int status; |
Line 199 int *fd;
|
Line 208 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 (char *filename) |
static int test_cachelock (STRING filename) |
#else |
#else |
static int test_cachelock (filename) |
static int test_cachelock (filename) |
char *filename; |
STRING filename; |
#endif __STDC__ |
#endif /* __STDC__ */ |
{ |
{ |
#ifdef _WINDOWS |
#ifdef _WINDOWS |
/* if the lock is set, we can't unlink the file under Windows */ |
/* if the lock is set, we can't unlink the file under Windows */ |
Line 274 HTList *documents;
|
Line 283 HTList *documents;
|
Converts an Amaya type descriptor into the equivalent MIME type. |
Converts an Amaya type descriptor into the equivalent MIME type. |
----------------------------------------------------------------------*/ |
----------------------------------------------------------------------*/ |
#ifdef __STDC__ |
#ifdef __STDC__ |
static HTAtom *AHTGuessAtom_for (char *urlName, PicType contentType) |
static HTAtom *AHTGuessAtom_for (STRING urlName, PicType contentType) |
#else |
#else |
static HTAtom *AHTGuessAtom_for (urlName, contentType) |
static HTAtom *AHTGuessAtom_for (urlName, contentType) |
char *urlName; |
STRING urlName; |
PicType contentType; |
PicType contentType; |
#endif |
#endif |
{ |
{ |
HTAtom *atom; |
HTAtom *atom; |
char *filename; |
STRING filename; |
HTEncoding enc = NULL; |
HTEncoding enc = NULL; |
HTEncoding cte = NULL; |
HTEncoding cte = NULL; |
HTLanguage lang = NULL; |
HTLanguage lang = NULL; |
Line 314 PicType contentType;
|
Line 323 PicType contentType;
|
** Amaya could not detect the type, so |
** Amaya could not detect the type, so |
** we try to use the filename's suffix to do so. |
** we try to use the filename's suffix to do so. |
*/ |
*/ |
filename = AmayaParseUrl (urlName, "", AMAYA_PARSE_PATH | AMAYA_PARSE_PUNCTUATION); |
filename = AmayaParseUrl (urlName, _EMPTYSTR_, AMAYA_PARSE_PATH | AMAYA_PARSE_PUNCTUATION); |
HTBind_getFormat (filename, &atom, &enc, &cte, &lang, &quality); |
HTBind_getFormat (WideChar2ISO (filename), &atom, &enc, &cte, &lang, &quality); |
TtaFreeMemory (filename); |
TtaFreeMemory (filename); |
if (atom == WWW_UNKNOWN) |
if (atom == WWW_UNKNOWN) |
/* |
/* |
Line 459 AHTReqContext *me;
|
Line 468 AHTReqContext *me;
|
{ |
{ |
if (me->outputfile && me->outputfile[0] != EOS) |
if (me->outputfile && me->outputfile[0] != EOS) |
{ |
{ |
TtaFileUnlink (me->outputfile); |
TtaFileUnlink (ISO2WideChar (me->outputfile)); |
me->outputfile[0] = EOS; |
me->outputfile[0] = EOS; |
} |
} |
} |
} |
Line 540 static void Thread_deleteAll ()
|
Line 549 static void Thread_deleteAll ()
|
|
|
} |
} |
} |
} |
|
|
/*---------------------------------------------------------------------- |
/*---------------------------------------------------------------------- |
AHTOpen_file |
AHTOpen_file |
----------------------------------------------------------------------*/ |
----------------------------------------------------------------------*/ |
Line 607 HTRequest *request;
|
Line 616 HTRequest *request;
|
#endif |
#endif |
TtaSetStatus (me->docid, 1, |
TtaSetStatus (me->docid, 1, |
TtaGetMessage (AMAYA, AM_CANNOT_CREATE_FILE), |
TtaGetMessage (AMAYA, AM_CANNOT_CREATE_FILE), |
me->outputfile); |
ISO2WideChar (me->outputfile)); |
me->reqStatus = HT_ERR; |
me->reqStatus = HT_ERR; |
return (HT_ERROR); |
return (HT_ERROR); |
} |
} |
Line 640 int status;
|
Line 649 int status;
|
HTAnchor *new_anchor = HTResponse_redirection (response); |
HTAnchor *new_anchor = HTResponse_redirection (response); |
AHTReqContext *me = HTRequest_context (request); |
AHTReqContext *me = HTRequest_context (request); |
HTMethod method = HTRequest_method (request); |
HTMethod method = HTRequest_method (request); |
char *ref; |
STRING ref; |
char *tmp; |
char *tmp; |
|
|
if (!me) |
if (!me) |
Line 697 int status;
|
Line 706 int status;
|
*/ |
*/ |
|
|
/* only do a redirect using a network protocol understood by Amaya */ |
/* only do a redirect using a network protocol understood by Amaya */ |
if (IsValidProtocol (new_anchor->parent->address)) |
if (IsValidProtocol (ISO2WideChar (new_anchor->parent->address))) |
{ |
{ |
/* if it's a valid URL, we try to normalize it */ |
/* if it's a valid URL, we try to normalize it */ |
/* We use the pre-redirection anchor as a base name */ |
/* We use the pre-redirection anchor as a base name */ |
ref = AmayaParseUrl (new_anchor->parent->address, |
ref = AmayaParseUrl (ISO2WideChar (new_anchor->parent->address), |
me->urlName, AMAYA_PARSE_ALL); |
ISO2WideChar (me->urlName), AMAYA_PARSE_ALL); |
if (ref) |
if (ref) |
{ |
{ |
HT_FREE (new_anchor->parent->address); |
HT_FREE (new_anchor->parent->address); |
tmp = NULL; |
tmp = NULL; |
HTSACopy (&tmp, ref); |
HTSACopy (&tmp, WideChar2ISO (ref)); |
new_anchor->parent->address = tmp; |
new_anchor->parent->address = tmp; |
TtaFreeMemory (ref); |
TtaFreeMemory (ref); |
} |
} |
Line 721 int status;
|
Line 730 int status;
|
if ((me->mode & AMAYA_ASYNC) || (me->mode & AMAYA_IASYNC)) |
if ((me->mode & AMAYA_ASYNC) || (me->mode & AMAYA_IASYNC)) |
{ |
{ |
TtaFreeMemory (me->urlName); |
TtaFreeMemory (me->urlName); |
me->urlName = TtaStrdup (new_anchor->parent->address); |
me->urlName = WideChar2ISO (TtaStrdup (ISO2WideChar (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 752 int status;
|
Line 761 int status;
|
|
|
/* tell the user what we're doing */ |
/* tell the user what we're doing */ |
TtaSetStatus (me->docid, 1, TtaGetMessage (AMAYA, AM_RED_FETCHING), |
TtaSetStatus (me->docid, 1, TtaGetMessage (AMAYA, AM_RED_FETCHING), |
me->status_urlName); |
ISO2WideChar (me->status_urlName)); |
|
|
|
|
/* |
/* |
Line 1103 int status;
|
Line 1112 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 = TtaStrdup ("text/html"); |
me->content_type = WideChar2ISO (TtaStrdup (TEXT("text/html"))); |
else |
else |
me->content_type = TtaStrdup (content_type); |
me->content_type = WideChar2ISO (TtaStrdup (ISO2WideChar (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 */ |
ConvertToLowerCase (me->content_type); |
ConvertToLowerCase (ISO2WideChar (me->content_type)); |
|
|
#ifdef DEBUG_LIBWWW |
#ifdef DEBUG_LIBWWW |
fprintf (stderr, "content type is: %s\n", me->content_type); |
fprintf (stderr, "content type is: %s\n", me->content_type); |
Line 1121 int status;
|
Line 1130 int status;
|
if (AmayaAlive_flag && (me->mode & AMAYA_LOAD_CSS)) |
if (AmayaAlive_flag && (me->mode & AMAYA_LOAD_CSS)) |
TtaSetStatus (me->docid, 1, |
TtaSetStatus (me->docid, 1, |
TtaGetMessage (AMAYA, AM_ELEMENT_LOADED), |
TtaGetMessage (AMAYA, AM_ELEMENT_LOADED), |
me->status_urlName); |
ISO2WideChar (me->status_urlName)); |
|
|
/* don't remove or Xt will hang up during the PUT */ |
/* don't remove or Xt will hang up during the PUT */ |
if (AmayaIsAlive () && ((me->method == METHOD_POST) || |
if (AmayaIsAlive () && ((me->method == METHOD_POST) || |
Line 1173 int status;
|
Line 1182 int status;
|
if (docid_status != NULL && docid_status->counter > 1) |
if (docid_status != NULL && docid_status->counter > 1) |
TtaSetStatus (me->docid, 1, |
TtaSetStatus (me->docid, 1, |
TtaGetMessage (AMAYA, AM_ELEMENT_LOADED), |
TtaGetMessage (AMAYA, AM_ELEMENT_LOADED), |
me->status_urlName); |
ISO2WideChar (me->status_urlName)); |
break; |
break; |
|
|
case HT_NO_DATA: |
case HT_NO_DATA: |
Line 1182 int status;
|
Line 1191 int status;
|
me->status_urlName); |
me->status_urlName); |
TtaSetStatus (me->docid, 1, |
TtaSetStatus (me->docid, 1, |
TtaGetMessage (AMAYA, AM_LOADED_NO_DATA), |
TtaGetMessage (AMAYA, AM_LOADED_NO_DATA), |
me->status_urlName); |
ISO2WideChar (me->status_urlName)); |
break; |
break; |
|
|
case HT_INTERRUPTED: |
case HT_INTERRUPTED: |
Line 1200 int status;
|
Line 1209 int status;
|
HTResponse_retryTime (response)); |
HTResponse_retryTime (response)); |
TtaSetStatus (me->docid, 1, |
TtaSetStatus (me->docid, 1, |
TtaGetMessage (AMAYA, AM_NOT_AVAILABLE_RETRY), |
TtaGetMessage (AMAYA, AM_NOT_AVAILABLE_RETRY), |
me->status_urlName); |
ISO2WideChar (me->status_urlName)); |
break; |
break; |
|
|
case HT_ERROR: |
case HT_ERROR: |
Line 1215 int status;
|
Line 1224 int status;
|
me->status_urlName ? me->status_urlName :"<UNKNOWN>"); |
me->status_urlName ? me->status_urlName :"<UNKNOWN>"); |
TtaSetStatus (me->docid, 1, |
TtaSetStatus (me->docid, 1, |
TtaGetMessage (AMAYA, AM_CANNOT_LOAD), |
TtaGetMessage (AMAYA, AM_CANNOT_LOAD), |
me->status_urlName ? me->status_urlName : "<UNKNOWN>"); |
me->status_urlName ? ISO2WideChar (me->status_urlName) : TEXT("<UNKNOWN>")); |
break; |
break; |
default: |
default: |
if (PROT_TRACE) |
if (PROT_TRACE) |
Line 1296 HTList *c;
|
Line 1305 HTList *c;
|
if (c == (HTList *) NULL) |
if (c == (HTList *) NULL) |
return; |
return; |
|
|
lang_list = TtaGetEnvString ("ACCEPT_LANGUAGES"); |
lang_list = TtaGetEnvString (TEXT("ACCEPT_LANGUAGES")); |
s[2] = EOS; |
s[2] = EOS; |
if (lang_list && *lang_list != EOS) |
if (lang_list && *lang_list != EOS) |
{ |
{ |
Line 1363 HTList *c;
|
Line 1372 HTList *c;
|
else |
else |
ustrncpy (s, lang_list, 2); |
ustrncpy (s, lang_list, 2); |
count--; |
count--; |
HTLanguage_add (c, s, quality); |
HTLanguage_add (c, WideChar2ISO(s), quality); |
quality += 0.1; |
quality += 0.1; |
} |
} |
ptr--; |
ptr--; |
Line 1461 static void AHTProtocolInit (voi
|
Line 1470 static void AHTProtocolInit (voi
|
HTProtocol_add ("file", "local", 0, YES, HTLoadFile, NULL); |
HTProtocol_add ("file", "local", 0, YES, HTLoadFile, NULL); |
#else |
#else |
HTProtocol_add ("file", "local", 0, NO, HTLoadFile, NULL); |
HTProtocol_add ("file", "local", 0, NO, HTLoadFile, NULL); |
#endif _WINDOWS |
#endif /* _WINDOWS */ |
#ifdef AMAYA_WWW_CACHE |
#ifdef AMAYA_WWW_CACHE |
HTProtocol_add("cache", "local", 0, YES, HTLoadCache, NULL); |
HTProtocol_add("cache", "local", 0, YES, HTLoadCache, NULL); |
#endif /* AMAYA_WWW_CACHE */ |
#endif /* AMAYA_WWW_CACHE */ |
Line 1470 static void AHTProtocolInit (voi
|
Line 1479 static void AHTProtocolInit (voi
|
#endif |
#endif |
|
|
/* initialize pipelining */ |
/* initialize pipelining */ |
strptr = (char *) TtaGetEnvString ("ENABLE_PIPELINING"); |
strptr = (char *) TtaGetEnvString (TEXT ("ENABLE_PIPELINING")); |
if (strptr && *strptr && strcasecmp (strptr,"yes" )) |
if (strptr && *strptr && strcasecmp (strptr,"yes" )) |
HTTP_setConnectionMode (HTTP_11_NO_PIPELINING); |
HTTP_setConnectionMode (HTTP_11_NO_PIPELINING); |
} |
} |
Line 1563 View view;
|
Line 1572 View view;
|
#endif /* __STDC__ */ |
#endif /* __STDC__ */ |
{ |
{ |
#ifdef AMAYA_WWW_CACHE |
#ifdef AMAYA_WWW_CACHE |
char *real_dir; |
STRING real_dir; |
char *cache_dir; |
STRING cache_dir; |
char *tmp; |
STRING tmp; |
int cache_size; |
int cache_size; |
int cache_expire; |
int cache_expire; |
int cache_disconnect; |
int cache_disconnect; |
Line 1576 View view;
|
Line 1585 View view;
|
/* don't do anything if we're not using a cache */ |
/* don't do anything if we're not using a cache */ |
return; |
return; |
/* temporarily close down the cache, purge it, then restart */ |
/* temporarily close down the cache, purge it, then restart */ |
tmp = (char *) HTCacheMode_getRoot (); |
tmp = ISO2WideChar (HTCacheMode_getRoot ()); |
/* don't do anything if we don't have a valid cache dir */ |
/* don't do anything if we don't have a valid cache dir */ |
if (!tmp || *tmp == EOS) |
if (!tmp || *tmp == EOS) |
return; |
return; |
Line 1586 View view;
|
Line 1595 View view;
|
cache_disconnect = HTCacheMode_disconnected (); |
cache_disconnect = HTCacheMode_disconnected (); |
|
|
/* get something we can work on :) */ |
/* get something we can work on :) */ |
tmp = HTWWWToLocal (cache_dir, "file:", NULL); |
tmp = ISO2WideChar (HTWWWToLocal (WideChar2ISO (cache_dir), "file:", NULL)); |
real_dir = TtaGetMemory (strlen (tmp) + 20); |
real_dir = TtaAllocString (ustrlen (tmp) + 20); |
strcpy (real_dir, tmp); |
ustrcpy (real_dir, tmp); |
HT_FREE (tmp); |
HT_FREE (tmp); |
|
|
/* safeguard... abort the operation if cache_dir doesn't end with |
/* safeguard... abort the operation if cache_dir doesn't end with |
CACHE_DIR_NAME */ |
CACHE_DIR_NAME */ |
error = TRUE; |
error = TRUE; |
ptr = strstr (real_dir, CACHE_DIR_NAME); |
ptr = ustrstr (real_dir, CACHE_DIR_NAME); |
#ifdef _WINDOWS |
if (ptr && *ptr && !ustrcasecmp (ptr, CACHE_DIR_NAME)) |
if (ptr && *ptr && !_stricmp (ptr, CACHE_DIR_NAME)) |
|
#else |
|
if (ptr && *ptr && !strcasecmp (ptr, CACHE_DIR_NAME)) |
|
#endif /* _WINDOWS */ |
|
error = FALSE; |
error = FALSE; |
if (error) |
if (error) |
return; |
return; |
Line 1616 View view;
|
Line 1621 View view;
|
|
|
HTCacheMode_setExpires (cache_expire); |
HTCacheMode_setExpires (cache_expire); |
HTCacheMode_setDisconnected (cache_disconnect); |
HTCacheMode_setDisconnected (cache_disconnect); |
HTCacheInit (cache_dir, cache_size); |
HTCacheInit (WideChar2ISO (cache_dir), cache_size); |
/* set a new concurrent cache lock */ |
/* set a new concurrent cache lock */ |
strcat (real_dir, ".lock"); |
ustrcat (real_dir, TEXT(".lock")); |
if (set_cachelock (real_dir) == -1) |
if (set_cachelock (real_dir) == -1) |
/* couldn't open the .lock file, so, we close the cache to |
/* couldn't open the .lock file, so, we close the cache to |
be in the safe side */ |
be in the safe side */ |
Line 1643 View view;
|
Line 1648 View view;
|
Clears an existing cache directory |
Clears an existing cache directory |
----------------------------------------------------------------------*/ |
----------------------------------------------------------------------*/ |
#ifdef __STDC__ |
#ifdef __STDC__ |
static void RecCleanCache (char *dirname) |
static void RecCleanCache (STRING dirname) |
#else |
#else |
static void RecCleanCache (char *dirname) |
static void RecCleanCache (dirname) |
Document doc; |
STRING dirname; |
View view; |
|
#endif /* __STDC__ */ |
#endif /* __STDC__ */ |
|
|
#ifdef _WINDOWS |
#ifdef _WINDOWS |
Line 1656 View view;
|
Line 1660 View view;
|
ThotBool status; |
ThotBool status; |
WIN32_FIND_DATA ffd; |
WIN32_FIND_DATA ffd; |
|
|
char t_dir [MAX_LENGTH]; |
CHAR_T t_dir [MAX_LENGTH]; |
char *ptr; |
STRING ptr; |
|
|
/* create a t_dir name to start searching for files */ |
/* create a t_dir name to start searching for files */ |
if ((strlen (dirname) + 10) > MAX_LENGTH) |
if ((ustrlen (dirname) + 10) > MAX_LENGTH) |
/* ERROR: directory name is too big */ |
/* ERROR: directory name is too big */ |
return; |
return; |
|
|
strcpy (t_dir, dirname); |
ustrcpy (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[strlen (t_dir)]; |
ptr = &t_dir[ustrlen (t_dir)]; |
strcat (t_dir, "*"); |
ustrcat (t_dir, TEXT("*")); |
|
|
hFindFile = FindFirstFile (t_dir, &ffd); |
hFindFile = FindFirstFile (t_dir, &ffd); |
|
|
Line 1682 View view;
|
Line 1686 View view;
|
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 (strcmp (ffd.cFileName, "..") && strcmp (ffd.cFileName, ".")) |
if (ustrcmp (ffd.cFileName, TEXT("..")) && ustrcmp (ffd.cFileName, TEXT("."))) |
{ |
{ |
strcpy (ptr, ffd.cFileName); |
ustrcpy (ptr, ffd.cFileName); |
strcat (ptr, DIR_STR); |
ustrcat (ptr, DIR_STR); |
RecCleanCache (t_dir); |
RecCleanCache (t_dir); |
# ifdef _WINDOWS |
urmdir (t_dir); |
_rmdir (t_dir); |
|
# else /* !_WINDOWS */ |
|
rmdir (t_dir); |
|
# endif /* _WINDOWS */ |
|
} |
} |
} |
} |
else |
else |
{ |
{ |
/* it's a file, erase it */ |
/* it's a file, erase it */ |
strcpy (ptr, ffd.cFileName); |
ustrcpy (ptr, ffd.cFileName); |
TtaFileUnlink (t_dir); |
TtaFileUnlink (t_dir); |
} |
} |
status = FindNextFile (hFindFile, &ffd); |
status = FindNextFile (hFindFile, &ffd); |
Line 1776 static void Cacheinit ()
|
Line 1776 static void Cacheinit ()
|
HTCacheMode_setEnabled (NO); |
HTCacheMode_setEnabled (NO); |
|
|
#else /* AMAYA_WWW_CACHE */ |
#else /* AMAYA_WWW_CACHE */ |
char *strptr; |
STRING strptr; |
char *cache_dir = NULL; |
STRING cache_dir = NULL; |
char *real_dir = NULL; |
STRING real_dir = NULL; |
char *cache_lockfile; |
STRING cache_lockfile; |
int cache_size; |
int cache_size; |
int cache_entry_size; |
int cache_entry_size; |
ThotBool cache_enabled; |
ThotBool cache_enabled; |
Line 1789 static void Cacheinit ()
|
Line 1789 static void Cacheinit ()
|
int i; |
int i; |
|
|
/* activate cache? */ |
/* activate cache? */ |
strptr = (char *) TtaGetEnvString ("ENABLE_CACHE"); |
strptr = TtaGetEnvString (TEXT("ENABLE_CACHE")); |
if (strptr && *strptr && strcasecmp (strptr, "yes" )) |
if (strptr && *strptr && ustrcasecmp (strptr, TEXT("yes"))) |
cache_enabled = NO; |
cache_enabled = NO; |
else |
else |
cache_enabled = YES; |
cache_enabled = YES; |
|
|
/* cache protected documents? */ |
/* cache protected documents? */ |
strptr = (char *) TtaGetEnvString ("CACHE_PROTECTED_DOCS"); |
strptr = TtaGetEnvString (TEXT("CACHE_PROTECTED_DOCS")); |
if (strptr && *strptr && !strcasecmp (strptr, "yes" )) |
if (strptr && *strptr && !ustrcasecmp (strptr, TEXT("yes"))) |
HTCacheMode_setProtected (YES); |
HTCacheMode_setProtected (YES); |
else |
else |
HTCacheMode_setProtected (NO); |
HTCacheMode_setProtected (NO); |
|
|
/* get the cache dir (or use a default one) */ |
/* get the cache dir (or use a default one) */ |
strptr = (char *) TtaGetEnvString ("CACHE_DIR"); |
strptr = TtaGetEnvString (TEXT("CACHE_DIR")); |
if (strptr && *strptr) |
if (strptr && *strptr) |
{ |
{ |
real_dir = TtaGetMemory (strlen (strptr) + strlen (CACHE_DIR_NAME) + 20); |
real_dir = TtaAllocString (ustrlen (strptr) + ustrlen (CACHE_DIR_NAME) + 20); |
strcpy (real_dir, strptr); |
ustrcpy (real_dir, strptr); |
if (*(real_dir + strlen (real_dir) - 1) != DIR_SEP) |
if (*(real_dir + ustrlen (real_dir) - 1) != DIR_SEP) |
strcat (real_dir, DIR_STR); |
ustrcat (real_dir, DIR_STR); |
} |
} |
else |
else |
{ |
{ |
real_dir = TtaGetMemory (strlen (TempFileDirectory) |
real_dir = TtaAllocString (ustrlen (TempFileDirectory) |
+ strlen (CACHE_DIR_NAME) + 20); |
+ ustrlen (CACHE_DIR_NAME) + 20); |
sprintf (real_dir, "%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 = strstr (real_dir, CACHE_DIR_NAME); |
strptr = ustrstr (real_dir, CACHE_DIR_NAME); |
if (!strptr) |
if (!strptr) |
{ |
{ |
strcat (real_dir, CACHE_DIR_NAME); |
ustrcat (real_dir, CACHE_DIR_NAME); |
} |
} |
else |
else |
{ |
{ |
i = strlen (CACHE_DIR_NAME); |
i = ustrlen (CACHE_DIR_NAME); |
if (strptr[i] != EOS) |
if (strptr[i] != EOS) |
strcat (real_dir, CACHE_DIR_NAME); |
ustrcat (real_dir, CACHE_DIR_NAME); |
} |
} |
|
|
|
|
cache_dir = TtaGetMemory (strlen (real_dir) + 10); |
cache_dir = TtaAllocString (ustrlen (real_dir) + 10); |
sprintf (cache_dir, "file:%s", real_dir); |
usprintf (cache_dir, TEXT("file:%s"), real_dir); |
|
|
/* get the cache size (or use a default one) */ |
/* get the cache size (or use a default one) */ |
strptr = (char *) TtaGetEnvString ("CACHE_SIZE"); |
strptr = TtaGetEnvString (TEXT("CACHE_SIZE")); |
if (strptr && *strptr) |
if (strptr && *strptr) |
cache_size = atoi (strptr); |
cache_size = uctoi (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 ("MAX_CACHE_ENTRY_SIZE", &cache_entry_size)) |
if (!TtaGetEnvInt (TEXT("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 = TtaGetMemory (strlen (real_dir) + 20); |
cache_lockfile = TtaAllocString (ustrlen (real_dir) + 20); |
strcpy (cache_lockfile, real_dir); |
ustrcpy (cache_lockfile, real_dir); |
strcat (cache_lockfile, ".lock"); |
ustrcat (cache_lockfile, TEXT(".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))) |
Line 1863 int i;
|
Line 1863 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 = strrchr (cache_lockfile, '.'); |
strptr = ustrrchr (cache_lockfile, TEXT('.')); |
*strptr = EOS; |
*strptr = EOS; |
RecCleanCache (cache_lockfile); |
RecCleanCache (cache_lockfile); |
*strptr = '.'; |
*strptr = '.'; |
Line 1874 int i;
|
Line 1874 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 ("CACHE_EXPIRE_IGNORE", &tmp_bool) |
if (TtaGetEnvBoolean (TEXT("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 ("CACHE_DISCONNECTED_MODE", &tmp_bool); |
TtaGetEnvBoolean (TEXT("CACHE_DISCONNECTED_MODE"), &tmp_bool); |
if (tmp_bool) |
if (tmp_bool) |
HTCacheMode_setDisconnected (HT_DISCONNECT_NORMAL); |
HTCacheMode_setDisconnected (HT_DISCONNECT_NORMAL); |
else |
else |
HTCacheMode_setDisconnected (HT_DISCONNECT_NONE); |
HTCacheMode_setDisconnected (HT_DISCONNECT_NONE); |
if (HTCacheInit (cache_dir, cache_size)) |
if (HTCacheInit (WideChar2ISO (cache_dir), cache_size)) |
{ |
{ |
if (set_cachelock (cache_lockfile) == -1) |
if (set_cachelock (cache_lockfile) == -1) |
/* couldn't open the .lock file, so, we close the cache to |
/* couldn't open the .lock file, so, we close the cache to |
Line 1930 int i;
|
Line 1930 int i;
|
if (cache_enabled && !HTCacheMode_enabled ()) |
if (cache_enabled && !HTCacheMode_enabled ()) |
{ |
{ |
#ifdef _WINDOWS |
#ifdef _WINDOWS |
MessageBox (NULL, TtaGetMessage (AMAYA, AM_CANT_CREATE_CACHE), |
MessageBox (NULL, TtaGetMessage (AMAYA, AM_CANT_CREATE_CACHE), TEXT("Cache"), MB_OK); |
"Cache", MB_OK); |
|
#else /* !_WINDOWS */ |
#else /* !_WINDOWS */ |
TtaDisplayMessage (CONFIRM, TtaGetMessage (AMAYA, AM_CANT_CREATE_CACHE), |
TtaDisplayMessage (CONFIRM, TtaGetMessage (AMAYA, AM_CANT_CREATE_CACHE), |
NULL); |
NULL); |
Line 1951 static void ProxyInit (void)
|
Line 1950 static void ProxyInit (void)
|
static void ProxyInit () |
static void ProxyInit () |
#endif /* __STDC__ */ |
#endif /* __STDC__ */ |
{ |
{ |
char *strptr; |
STRING strptr; |
char *str = NULL; |
STRING str = NULL; |
char *name; |
STRING name; |
|
char* strptrA; |
|
|
/* get the proxy settings from the thot.ini file */ |
/* get the proxy settings from the thot.ini file */ |
strptr = (char *) TtaGetEnvString ("HTTP_PROXY"); |
strptr = TtaGetEnvString (TEXT("HTTP_PROXY")); |
if (strptr && *strptr) |
if (strptr && *strptr) |
HTProxy_add ("http", strptr); |
HTProxy_add ("http", WideChar2ISO (strptr)); |
/* get the no_proxy settings from the thot.ini file */ |
/* get the no_proxy settings from the thot.ini file */ |
strptr = (char *) TtaGetEnvString ("NO_PROXY"); |
strptr = TtaGetEnvString (TEXT("NO_PROXY")); |
if (strptr && *strptr) |
if (strptr && *strptr) |
{ |
{ |
str = TtaStrdup (strptr); /* Get copy we can mutilate */ |
str = TtaStrdup (strptr); /* Get copy we can mutilate */ |
strptr = str; |
strptr = str; |
while ((name = HTNextField (&strptr)) != NULL) { |
strptrA = WideChar2ISO (strptr); |
char *portstr = strchr (name, ':'); |
while ((name = HTNextField (&strptrA) != NULL)) { |
|
STRING portstr = ustrchr (name, TEXT(':')); |
unsigned port=0; |
unsigned port=0; |
if (portstr) { |
if (portstr) { |
*portstr++ = '\0'; |
*portstr++ = EOS; |
if (*portstr) port = (unsigned) atoi (portstr); |
if (*portstr) port = (unsigned) uctoi (portstr); |
} |
} |
/* Register it for all access methods */ |
/* Register it for all access methods */ |
HTNoProxy_add (name, NULL, port); |
HTNoProxy_add (WideChar2ISO (name), NULL, port); |
} |
} |
TtaFreeMemory (str); |
TtaFreeMemory (str); |
} |
} |
Line 1988 static void ProxyInit ()
|
Line 1989 static void ProxyInit ()
|
creates the Amaya client profile for libwww. |
creates the Amaya client profile for libwww. |
----------------------------------------------------------------------*/ |
----------------------------------------------------------------------*/ |
#ifdef __STDC__ |
#ifdef __STDC__ |
static void AHTProfile_newAmaya (char *AppName, char *AppVersion) |
static void AHTProfile_newAmaya (STRING AppName, STRING AppVersion) |
#else /* __STDC__ */ |
#else /* __STDC__ */ |
static void AHTProfile_newAmaya (AppName, AppVersion) |
static void AHTProfile_newAmaya (AppName, AppVersion) |
char *AppName; |
STRING AppName; |
char *AppVersion; |
STRING AppVersion; |
#endif /* __STDC__ */ |
#endif /* __STDC__ */ |
{ |
{ |
char * strptr; |
STRING 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 (AppName, AppVersion); |
HTLibInit (WideChar2ISO (AppName), WideChar2ISO (AppVersion)); |
|
|
if (!converters) |
if (!converters) |
converters = HTList_new (); |
converters = HTList_new (); |
Line 2039 char *AppVersion;
|
Line 2040 char *AppVersion;
|
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 = (char *) TtaGetEnvString ("ENABLE_MDA"); |
strptr = TtaGetEnvString (TEXT("ENABLE_MDA")); |
if (!strptr || (strptr && *strptr && strcasecmp (strptr, "no" ))) |
if (!strptr || (strptr && *strptr && ustrcasecmp (strptr, TEXT("no")))) |
HTAA_newModule ("digest", HTDigest_generate, HTDigest_parse, |
HTAA_newModule ("digest", HTDigest_generate, HTDigest_parse, |
HTDigest_updateInfo, HTDigest_delete); |
HTDigest_updateInfo, HTDigest_delete); |
|
|
Line 2104 static void AHTProfile_delete ()
|
Line 2105 static void AHTProfile_delete ()
|
|
|
#ifdef _WINDOWS |
#ifdef _WINDOWS |
HTEventTerminate (); |
HTEventTerminate (); |
#endif _WINDOWS; |
#endif /* _WINDOWS; */ |
|
|
/* Clean up the persistent cache (if any) */ |
/* Clean up the persistent cache (if any) */ |
#ifdef AMAYA_WWW_CACHE |
#ifdef AMAYA_WWW_CACHE |
Line 2145 void QueryInit ()
|
Line 2146 void QueryInit ()
|
void QueryInit () |
void QueryInit () |
#endif |
#endif |
{ |
{ |
char *strptr; |
STRING strptr; |
int tmp_i; |
int tmp_i; |
long tmp_l; |
long tmp_l; |
|
|
Line 2181 void QueryInit ()
|
Line 2182 void QueryInit ()
|
/* Setting up different network parameters */ |
/* Setting up different network parameters */ |
|
|
/* Maximum number of simultaneous open sockets */ |
/* Maximum number of simultaneous open sockets */ |
strptr = (char *) TtaGetEnvString ("MAX_SOCKET"); |
strptr = TtaGetEnvString (TEXT("MAX_SOCKET")); |
if (strptr && *strptr) |
if (strptr && *strptr) |
tmp_i = atoi (strptr); |
tmp_i = uctoi (strptr); |
else |
else |
tmp_i = DEFAULT_MAX_SOCKET; |
tmp_i = DEFAULT_MAX_SOCKET; |
HTNet_setMaxSocket (tmp_i); |
HTNet_setMaxSocket (tmp_i); |
|
|
/* different network services timeouts */ |
/* different network services timeouts */ |
/* dns timeout */ |
/* dns timeout */ |
strptr = (char *) TtaGetEnvString ("DNS_TIMEOUT"); |
strptr = TtaGetEnvString (TEXT("DNS_TIMEOUT")); |
if (strptr && *strptr) |
if (strptr && *strptr) |
tmp_i = atoi (strptr); |
tmp_i = uctoi (strptr); |
else |
else |
tmp_i = DEFAULT_DNS_TIMEOUT; |
tmp_i = DEFAULT_DNS_TIMEOUT; |
HTDNS_setTimeout (tmp_i); |
HTDNS_setTimeout (tmp_i); |
|
|
/* persistent connections timeout */ |
/* persistent connections timeout */ |
strptr = (char *) TtaGetEnvString ("PERSIST_CX_TIMEOUT"); |
strptr = TtaGetEnvString (TEXT("PERSIST_CX_TIMEOUT")); |
if (strptr && *strptr) |
if (strptr && *strptr) |
tmp_l = atol (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); |
|
|
/* default timeout in ms */ |
/* default timeout in ms */ |
strptr = (char *) TtaGetEnvString ("NET_EVENT_TIMEOUT"); |
strptr = TtaGetEnvString (TEXT("NET_EVENT_TIMEOUT")); |
if (strptr && *strptr) |
if (strptr && *strptr) |
tmp_i = atoi (strptr); |
tmp_i = uctoi (strptr); |
else |
else |
tmp_i = DEFAULT_NET_EVENT_TIMEOUT; |
tmp_i = DEFAULT_NET_EVENT_TIMEOUT; |
HTHost_setEventTimeout (tmp_i); |
HTHost_setEventTimeout (tmp_i); |
Line 2309 void QueryClose ()
|
Line 2310 void QueryClose ()
|
a non-existent Amaya window */ |
a non-existent Amaya window */ |
#ifndef _WINDOWS |
#ifndef _WINDOWS |
HTNet_deleteAfter (AHTLoadTerminate_handler); |
HTNet_deleteAfter (AHTLoadTerminate_handler); |
#endif _WINDOWS |
#endif /* _WINDOWS */ |
HTNet_deleteAfter (redirection_handler); |
HTNet_deleteAfter (redirection_handler); |
HTAlertCall_deleteAll (HTAlert_global () ); |
HTAlertCall_deleteAll (HTAlert_global () ); |
HTAlert_setGlobal ((HTList *) NULL); |
HTAlert_setGlobal ((HTList *) NULL); |
Line 2376 char **value;
|
Line 2377 char **value;
|
PrepareFormdata |
PrepareFormdata |
---------------------------------------------------------------------*/ |
---------------------------------------------------------------------*/ |
#ifdef __STDC__ |
#ifdef __STDC__ |
static HTAssocList * PrepareFormdata (char *string) |
static HTAssocList * PrepareFormdata (STRING string) |
#else |
#else |
static HTAssocList * PrepareFormdata (string) |
static HTAssocList * PrepareFormdata (string) |
char *string; |
STRING string; |
#endif /* __STDC__ */ |
#endif /* __STDC__ */ |
{ |
{ |
char * tmp_string, * tmp_string_ptr; |
char* tmp_string, *tmp_string_ptr; |
char * name; |
char* name; |
char * value; |
char* value; |
HTAssocList * formdata; |
HTAssocList* formdata; |
|
|
if (!string) |
if (!string) |
return NULL; |
return NULL; |
Line 2394 char *string;
|
Line 2395 char *string;
|
change |
change |
*/ |
*/ |
|
|
tmp_string_ptr = tmp_string = TtaStrdup (string); |
tmp_string_ptr = tmp_string = WideChar2ISO (TtaStrdup (string)); |
formdata = HTAssocList_new(); |
formdata = HTAssocList_new(); |
|
|
while (*tmp_string) |
while (*tmp_string) |
Line 2416 char *string;
|
Line 2417 char *string;
|
---------------------------------------------------------------------*/ |
---------------------------------------------------------------------*/ |
|
|
#ifdef __STDC__ |
#ifdef __STDC__ |
void InvokeGetObjectWWW_callback (int docid, char *urlName, char *outputfile, TTcbf *terminate_cbf, void *context_tcbf, int status) |
void InvokeGetObjectWWW_callback (int docid, STRING urlName, STRING outputfile, TTcbf *terminate_cbf, void *context_tcbf, int status) |
#else |
#else |
void InvokeGetObjectWWW_callback (docid, urlName, outputfile, terminate_cbf, context_tcbf, status) |
void InvokeGetObjectWWW_callback (docid, urlName, outputfile, terminate_cbf, context_tcbf, status) |
int docid; |
int docid; |
char *urlName; |
STRING urlName; |
char *outputfile; |
STRING outputfile; |
TTcbf *terminate_cbf; |
TTcbf *terminate_cbf; |
void *context_tcbf; |
void *context_tcbf; |
#endif /* __STDC__ */ |
#endif /* __STDC__ */ |
Line 2497 void *context_tcbf;
|
Line 2498 void *context_tcbf;
|
|
|
----------------------------------------------------------------------*/ |
----------------------------------------------------------------------*/ |
#ifdef __STDC__ |
#ifdef __STDC__ |
int GetObjectWWW (int docid, char* urlName, char* formdata, |
int GetObjectWWW (int docid, STRING urlName, STRING formdata, |
char* outputfile, int mode, TIcbf* incremental_cbf, |
STRING outputfile, int mode, TIcbf* incremental_cbf, |
void* context_icbf, TTcbf* terminate_cbf, |
void* context_icbf, TTcbf* terminate_cbf, |
void* context_tcbf, ThotBool error_html, char *content_type) |
void* context_tcbf, ThotBool error_html, STRING content_type) |
#else |
#else |
int GetObjectWWW (docid, urlName, formdata, outputfile, mode, |
int GetObjectWWW (docid, urlName, formdata, outputfile, mode, |
incremental_cbf, context_icbf, |
incremental_cbf, context_icbf, |
terminate_cbf, context_tcbf, error_html, content_type) |
terminate_cbf, context_tcbf, error_html, content_type) |
int docid; |
int docid; |
char *urlName; |
STRING urlName; |
char *formdata; |
STRING formdata; |
char *outputfile; |
STRING outputfile; |
int mode; |
int mode; |
TIcbf *incremental_cbf; |
TIcbf *incremental_cbf; |
void *context_icbf; |
void *context_icbf; |
TTcbf *terminate_cbf; |
TTcbf *terminate_cbf; |
void *context_tcbf; |
void *context_tcbf; |
ThotBool error_html; |
ThotBool error_html; |
char *content_type; |
STRING content_type; |
#endif |
#endif |
{ |
{ |
AHTReqContext *me; |
AHTReqContext *me; |
char *ref; |
STRING ref; |
int status, l; |
int status, l; |
int tempsubdir; |
int tempsubdir; |
ThotBool bool_tmp; |
ThotBool bool_tmp; |
Line 2538 char *content_type;
|
Line 2539 char *content_type;
|
} |
} |
|
|
/* if it's a 'docImage', we have already downloaded it */ |
/* if it's a 'docImage', we have already downloaded it */ |
if (!strncmp ("internal:", urlName, 9)) |
if (!ustrncmp (TEXT("internal:"), urlName, 9)) |
{ |
{ |
strcpy (outputfile, urlName); |
ustrcpy (outputfile, urlName); |
InvokeGetObjectWWW_callback (docid, urlName, outputfile, |
InvokeGetObjectWWW_callback (docid, urlName, outputfile, |
terminate_cbf, context_tcbf, HT_OK); |
terminate_cbf, context_tcbf, HT_OK); |
return HT_OK; |
return HT_OK; |
Line 2569 char *content_type;
|
Line 2570 char *content_type;
|
tempsubdir = (mode & AMAYA_LOAD_CSS) ? 0 : docid; |
tempsubdir = (mode & AMAYA_LOAD_CSS) ? 0 : docid; |
|
|
/* create a tempfilename */ |
/* create a tempfilename */ |
sprintf (outputfile, "%s%c%d%c%04dAM", |
usprintf (outputfile, TEXT("%s%c%d%c%04dAM"), TempFileDirectory, DIR_SEP, tempsubdir, DIR_SEP, object_counter); |
TempFileDirectory, DIR_SEP, tempsubdir, DIR_SEP, object_counter); |
|
/* update the object_counter (used for the tempfilename) */ |
/* update the object_counter (used for the tempfilename) */ |
object_counter++; |
object_counter++; |
|
|
/* normalize the URL */ |
/* normalize the URL */ |
ref = AmayaParseUrl (urlName, "", AMAYA_PARSE_ALL); |
ref = AmayaParseUrl (urlName, _EMPTYSTR_, AMAYA_PARSE_ALL); |
/* should we abort the request if we could not normalize the url? */ |
/* should we abort the request if we could not normalize the url? */ |
if (ref == (char*) NULL || ref[0] == EOS) { |
if (ref == NULL || ref[0] == EOS) { |
/*error */ |
/*error */ |
outputfile[0] = EOS; |
outputfile[0] = EOS; |
TtaSetStatus (docid, 1, TtaGetMessage (AMAYA, AM_BAD_URL), urlName); |
TtaSetStatus (docid, 1, TtaGetMessage (AMAYA, AM_BAD_URL), urlName); |
Line 2634 char *content_type;
|
Line 2634 char *content_type;
|
|
|
if ((mode & AMAYA_ASYNC) || (mode & AMAYA_IASYNC)) |
if ((mode & AMAYA_ASYNC) || (mode & AMAYA_IASYNC)) |
{ |
{ |
l = strlen (outputfile); |
l = ustrlen (outputfile); |
if (l > MAX_LENGTH) |
if (l > MAX_LENGTH) |
me->outputfile = TtaGetMemory (l + 2); |
me->outputfile = TtaGetMemory (l + 2); |
else |
else |
me->outputfile = TtaGetMemory (MAX_LENGTH + 2); |
me->outputfile = TtaGetMemory (MAX_LENGTH + 2); |
strcpy (me->outputfile, outputfile); |
strcpy (me->outputfile, WideChar2ISO (outputfile)); |
l = strlen (urlName); |
l = ustrlen (urlName); |
if (l > MAX_LENGTH) |
if (l > MAX_LENGTH) |
me->urlName = TtaGetMemory (l + 2); |
me->urlName = TtaGetMemory (l + 2); |
else |
else |
me->urlName = TtaGetMemory (MAX_LENGTH + 2); |
me->urlName = TtaGetMemory (MAX_LENGTH + 2); |
strcpy (me->urlName, urlName); |
strcpy (me->urlName, WideChar2ISO (urlName)); |
#ifdef _WINDOWS |
#ifdef _WINDOWS |
/* force windows ASYNC requests to always be non preemptive */ |
/* force windows ASYNC requests to always be non preemptive */ |
HTRequest_setPreemptive (me->request, NO); |
HTRequest_setPreemptive (me->request, NO); |
Line 2654 char *content_type;
|
Line 2654 char *content_type;
|
else |
else |
#ifdef _WINDOWS |
#ifdef _WINDOWS |
{ |
{ |
me->outputfile = outputfile; |
me->outputfile = WideChar2ISO (outputfile); |
me->urlName = urlName; |
me->urlName = WideChar2ISO (urlName); |
/* force windows SYNC requests to always be non preemptive */ |
/* force windows SYNC requests to always be non preemptive */ |
HTRequest_setPreemptive (me->request, YES); |
HTRequest_setPreemptive (me->request, YES); |
} |
} |
Line 2685 char *content_type;
|
Line 2685 char *content_type;
|
ChopURL (me->status_urlName, me->urlName); |
ChopURL (me->status_urlName, me->urlName); |
TtaSetStatus (me->docid, 1, |
TtaSetStatus (me->docid, 1, |
TtaGetMessage (AMAYA, AM_FETCHING), |
TtaGetMessage (AMAYA, AM_FETCHING), |
me->status_urlName); |
ISO2WideChar (me->status_urlName)); |
|
|
me->anchor = (HTParentAnchor *) HTAnchor_findAddress (ref); |
me->anchor = (HTParentAnchor *) HTAnchor_findAddress (WideChar2ISO (ref)); |
TtaFreeMemory (ref); |
TtaFreeMemory (ref); |
|
|
TtaGetEnvBoolean ("CACHE_DISCONNECTED_MODE", &bool_tmp); |
TtaGetEnvBoolean (TEXT("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); |
|
|
Line 2799 char *content_type;
|
Line 2799 char *content_type;
|
HT_OK |
HT_OK |
----------------------------------------------------------------------*/ |
----------------------------------------------------------------------*/ |
#ifdef __STDC__ |
#ifdef __STDC__ |
int PutObjectWWW (int docid, char *fileName, char *urlName, int mode, PicType contentType, |
int PutObjectWWW (int docid, STRING fileName, STRING urlName, int mode, PicType contentType, |
TTcbf * terminate_cbf, void *context_tcbf) |
TTcbf * terminate_cbf, void *context_tcbf) |
#else |
#else |
int PutObjectWWW (docid, urlName, fileName, mode, contentType, |
int PutObjectWWW (docid, urlName, fileName, mode, contentType, |
,terminate_cbf, context_tcbf) |
,terminate_cbf, context_tcbf) |
int docid; |
int docid; |
char *urlName; |
STRING urlName; |
char *fileName; |
STRING fileName; |
int mode; |
int mode; |
PicType contentType; |
PicType contentType; |
TTcbf *terminate_cbf; |
TTcbf *terminate_cbf; |
Line 2821 void *context_tcbf;
|
Line 2821 void *context_tcbf;
|
char *fileURL; |
char *fileURL; |
char *etag = NULL; |
char *etag = NULL; |
HTParentAnchor *dest_anc_parent; |
HTParentAnchor *dest_anc_parent; |
char *tmp; |
STRING tmp; |
int UsePreconditions; |
int UsePreconditions; |
ThotBool lost_update_check = TRUE; |
ThotBool lost_update_check = TRUE; |
|
|
/* should we protect the PUT against lost updates? */ |
/* should we protect the PUT against lost updates? */ |
tmp = (char *) TtaGetEnvString ("ENABLE_LOST_UPDATE_CHECK"); |
tmp = TtaGetEnvString (TEXT("ENABLE_LOST_UPDATE_CHECK")); |
if (tmp && *tmp && strcasecmp (tmp, "yes" )) |
if (tmp && *tmp && ustrcasecmp (tmp, TEXT("yes"))) |
lost_update_check = FALSE; |
lost_update_check = FALSE; |
|
|
UsePreconditions = mode & AMAYA_USE_PRECONDITIONS; |
UsePreconditions = mode & AMAYA_USE_PRECONDITIONS; |
Line 2843 void *context_tcbf;
|
Line 2843 void *context_tcbf;
|
if (IsValidProtocol (urlName) == NO) |
if (IsValidProtocol (urlName) == NO) |
{ |
{ |
/* return error */ |
/* return error */ |
TtaSetStatus (docid, 1, |
TtaSetStatus (docid, 1, TtaGetMessage (AMAYA, AM_PUT_UNSUPPORTED_PROTOCOL), urlName); |
TtaGetMessage (AMAYA, AM_PUT_UNSUPPORTED_PROTOCOL), |
|
urlName); |
|
return HT_ERROR; |
return HT_ERROR; |
} |
} |
|
|
Line 2853 void *context_tcbf;
|
Line 2851 void *context_tcbf;
|
#ifndef _WINDOWS |
#ifndef _WINDOWS |
if ((fd = open (fileName, O_RDONLY)) == -1) |
if ((fd = open (fileName, O_RDONLY)) == -1) |
#else |
#else |
if ((fd = _open (fileName, _O_RDONLY | _O_BINARY)) == -1) |
if ((fd = uopen (fileName, _O_RDONLY | _O_BINARY)) == -1) |
#endif /* _WINDOWS */ |
#endif /* _WINDOWS */ |
{ |
{ |
/* if we could not open the file, exit */ |
/* if we could not open the file, exit */ |
Line 2892 void *context_tcbf;
|
Line 2890 void *context_tcbf;
|
me->context_icbf = (void *) NULL; |
me->context_icbf = (void *) NULL; |
me->terminate_cbf = terminate_cbf; |
me->terminate_cbf = terminate_cbf; |
me->context_tcbf = context_tcbf; |
me->context_tcbf = context_tcbf; |
me->urlName = urlName; |
me->urlName = WideChar2ISO (urlName); |
me->block_size = file_stat.st_size; |
me->block_size = file_stat.st_size; |
/* select the parameters that distinguish a PUT from a GET/POST */ |
/* select the parameters that distinguish a PUT from a GET/POST */ |
me->method = METHOD_PUT; |
me->method = METHOD_PUT; |
Line 2905 void *context_tcbf;
|
Line 2903 void *context_tcbf;
|
so we sidestep it */ |
so we sidestep it */ |
fileURL = NULL; |
fileURL = NULL; |
StrAllocCopy (fileURL, "file:"); |
StrAllocCopy (fileURL, "file:"); |
StrAllocCat (fileURL, fileName); |
StrAllocCat (fileURL, WideChar2ISO (fileName)); |
#else |
#else |
fileURL = HTParse (fileName, "file:/", PARSE_ALL); |
fileURL = HTParse (fileName, "file:/", PARSE_ALL); |
#endif /* _WINDOWS */ |
#endif /* _WINDOWS */ |
me->source = HTAnchor_findAddress (fileURL); |
me->source = HTAnchor_findAddress (fileURL); |
HT_FREE (fileURL); |
HT_FREE (fileURL); |
me->dest = HTAnchor_findAddress (urlName); |
me->dest = HTAnchor_findAddress (WideChar2ISO (urlName)); |
/* we memorize the anchor's parent @ as we use it a number of times |
/* we memorize the anchor's parent @ as we use it a number of times |
in the following lines */ |
in the following lines */ |
dest_anc_parent = HTAnchor_parent (me->dest); |
dest_anc_parent = HTAnchor_parent (me->dest); |
Line 2922 void *context_tcbf;
|
Line 2920 void *context_tcbf;
|
/* we try to use any content-type previosuly associated |
/* we try to use any content-type previosuly associated |
with the parent. If it doesn't exist, we try to guess it |
with the parent. If it doesn't exist, we try to guess it |
from the URL */ |
from the URL */ |
tmp = HTAtom_name (HTAnchor_format (dest_anc_parent)); |
tmp = ISO2WideChar (HTAtom_name (HTAnchor_format (dest_anc_parent))); |
if (!tmp || !strcmp (tmp, "www/unknown")) |
if (!tmp || !ustrcmp (tmp, TEXT("www/unknown"))) |
{ |
{ |
HTAnchor_setFormat (dest_anc_parent, |
HTAnchor_setFormat (dest_anc_parent, AHTGuessAtom_for (ISO2WideChar (me->urlName), contentType)); |
AHTGuessAtom_for (me->urlName, contentType)); |
tmp = ISO2WideChar (HTAtom_name (HTAnchor_format (dest_anc_parent))); |
tmp = HTAtom_name (HTAnchor_format (dest_anc_parent)); |
|
} |
} |
/* .. and we give the same type to the source anchor */ |
/* .. and we give the same type to the source anchor */ |
/* we go thru setOutputFormat, rather than change the parent's |
/* we go thru setOutputFormat, rather than change the parent's |
anchor, as that's the place that libwww expects it to be */ |
anchor, as that's the place that libwww expects it to be */ |
|
|
HTAnchor_setFormat (HTAnchor_parent (me->source), |
HTAnchor_setFormat (HTAnchor_parent (me->source), |
HTAtom_for (tmp)); |
HTAtom_for (WideChar2ISO (tmp))); |
HTRequest_setOutputFormat (me->request, |
HTRequest_setOutputFormat (me->request, |
HTAtom_for (tmp)); |
HTAtom_for (WideChar2ISO (tmp))); |
/* define other request characteristics */ |
/* define other request characteristics */ |
#ifdef _WINDOWS |
#ifdef _WINDOWS |
HTRequest_setPreemptive (me->request, NO); |
HTRequest_setPreemptive (me->request, NO); |
Line 2992 void *context_tcbf;
|
Line 2989 void *context_tcbf;
|
|
|
/* prepare the URLname that will be displayed in the status bar */ |
/* prepare the URLname that will be displayed in the status bar */ |
ChopURL (me->status_urlName, me->urlName); |
ChopURL (me->status_urlName, me->urlName); |
TtaSetStatus (me->docid, 1, TtaGetMessage (AMAYA, AM_REMOTE_SAVING), |
TtaSetStatus (me->docid, 1, TtaGetMessage (AMAYA, AM_REMOTE_SAVING), ISO2WideChar (me->status_urlName)); |
me->status_urlName); |
|
|
|
/* make the request */ |
/* make the request */ |
if (lost_update_check && (!UsePreconditions || !etag)) |
if (lost_update_check && (!UsePreconditions || !etag)) |
Line 3097 int docid;
|
Line 3093 int docid;
|
else |
else |
{ |
{ |
if (me->terminate_cbf) |
if (me->terminate_cbf) |
(*me->terminate_cbf) (me->docid, -1, me->urlName, |
(*me->terminate_cbf) (me->docid, -1, ISO2WideChar (me->urlName), |
me->outputfile, |
ISO2WideChar (me->outputfile), |
me->content_type, |
ISO2WideChar (me->content_type), |
me->context_tcbf); |
me->context_tcbf); |
|
|
if (async_flag) |
if (async_flag) |