Compare commits
18 Commits
src
...
tags/scull
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
11f241c065 | ||
|
|
ace27f0975 | ||
|
|
3b0d417b55 | ||
|
|
158dab3a00 | ||
|
|
f7ad201d6b | ||
|
|
cdb1e55563 | ||
|
|
c9e6d616b6 | ||
|
|
06a7be79ad | ||
|
|
bdf9af1afa | ||
|
|
9bfeb196fe | ||
|
|
9e9f40a286 | ||
|
|
d77c04e102 | ||
|
|
ee24f8de18 | ||
|
|
c8f85bcb17 | ||
|
|
13501cced3 | ||
|
|
a80d9bd169 | ||
|
|
0cd7b6fe38 | ||
|
|
8bba0a259f |
2107
mozilla/include/net.h
Normal file
2107
mozilla/include/net.h
Normal file
File diff suppressed because it is too large
Load Diff
37
mozilla/network/Makefile
Normal file
37
mozilla/network/Makefile
Normal file
@@ -0,0 +1,37 @@
|
||||
#! gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
#
|
||||
#
|
||||
|
||||
DEPTH = ..
|
||||
|
||||
DIRS = \
|
||||
cache \
|
||||
client \
|
||||
cnvts \
|
||||
mimetype \
|
||||
main \
|
||||
protocol \
|
||||
util
|
||||
|
||||
ifdef MODULAR_NETLIB
|
||||
DIRS += module
|
||||
endif
|
||||
|
||||
include $(DEPTH)/config/rules.mk
|
||||
|
||||
@@ -2,5 +2,5 @@
|
||||
# This is a list of local files which get copied to the mozilla:dist directory
|
||||
#
|
||||
|
||||
nsISoftwareUpdate.h
|
||||
nsSoftwareUpdateIIDs.h
|
||||
extcache.h
|
||||
netcache.h
|
||||
@@ -15,20 +15,22 @@
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH=../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
DEPTH = ../..
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
include $(topsrcdir)/config/config.mk
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
MODULE = netcache
|
||||
LIBRARY_NAME = netcache
|
||||
|
||||
EXPORT_RESOURCE_XPINSTALL = \
|
||||
$(srcdir)/progress.xul \
|
||||
$(srcdir)/progress.html \
|
||||
$(srcdir)/progress.css \
|
||||
CSRCS = \
|
||||
cachedump.c \
|
||||
extcache.c \
|
||||
mkcache.c \
|
||||
mkextcac.c \
|
||||
mkmemcac.c \
|
||||
$(NULL)
|
||||
|
||||
install::
|
||||
$(INSTALL) $(EXPORT_RESOURCE_XPINSTALL) $(DIST)/bin/res/xpinstall
|
||||
EXPORTS= netcache.h mkcache.h mkmemcac.h extcache.h
|
||||
|
||||
REQUIRES = network nspr2 dbm util pref js java fileurl security layer img jtools
|
||||
|
||||
include $(DEPTH)/config/rules.mk
|
||||
|
||||
139
mozilla/network/cache/cachedump.c
vendored
Normal file
139
mozilla/network/cache/cachedump.c
vendored
Normal file
@@ -0,0 +1,139 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
/* this little program will sequentially dump out
|
||||
* every record in the database
|
||||
*/
|
||||
#include "mkcache.h"
|
||||
#include "extcache.h"
|
||||
#include "plstr.h"
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <assert.h>
|
||||
|
||||
#ifdef _sgi
|
||||
#include <sys/endian.h>
|
||||
#endif /* _sgi */
|
||||
|
||||
/* URL methods
|
||||
*/
|
||||
#define URL_GET_METHOD 0
|
||||
#define URL_POST_METHOD 1
|
||||
#define URL_HEAD_METHOD 2
|
||||
|
||||
static DB *
|
||||
net_OpenExtCacheFatDB(char *filename)
|
||||
{
|
||||
DB *rv;
|
||||
HASHINFO hash_info = {
|
||||
16*1024, /* bucket size */
|
||||
0, /* fill factor */
|
||||
0, /* number of elements */
|
||||
0, /* bytes to cache */
|
||||
0, /* hash function */
|
||||
0}; /* byte order */
|
||||
|
||||
|
||||
rv = dbopen(filename,
|
||||
O_RDWR | O_CREAT,
|
||||
0644,
|
||||
DB_HASH,
|
||||
&hash_info);
|
||||
|
||||
if(!rv)
|
||||
{
|
||||
printf("Could not open cache database: %s\n", filename);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
return(rv);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
char url[4028];
|
||||
struct stat stat_s;
|
||||
net_CacheObject * cache_obj;
|
||||
DB * ext_cache_database=0;
|
||||
DBT key;
|
||||
DBT data;
|
||||
int len;
|
||||
char *end;
|
||||
|
||||
memset(&cache_obj, 0, sizeof(net_CacheObject));
|
||||
|
||||
if(argc != 2)
|
||||
{
|
||||
printf("Usage:\n"
|
||||
"%s database\n"
|
||||
"\n"
|
||||
"database: path and name of the database\n", argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* open the cache database */
|
||||
ext_cache_database = net_OpenExtCacheFatDB(argv[1]);
|
||||
|
||||
if(!ext_cache_database)
|
||||
{
|
||||
perror("Could not open cache database");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
while(!(ext_cache_database->seq)(ext_cache_database, &key, &data, 0))
|
||||
{
|
||||
|
||||
if(key.size == PL_strlen(EXT_CACHE_NAME_STRING)
|
||||
&& !PL_strcmp(key.data, EXT_CACHE_NAME_STRING))
|
||||
{
|
||||
/* make sure it's a terminated string */
|
||||
if(((char *)data.data)[data.size-1] == '\0')
|
||||
printf("\n\nDatabase Name: %s\n", (char*)data.data);
|
||||
else
|
||||
printf("\n\nDatabase Name is corrupted!\n");
|
||||
printf("\n--------------------------------------\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
/* try and convert the db struct to a cache struct */
|
||||
cache_obj = net_DBDataToCacheStruct(&data);
|
||||
|
||||
if(!cache_obj)
|
||||
{
|
||||
printf("Malformed database entry:\n");
|
||||
printf("key: ");
|
||||
fwrite(key.data, 1, key.size, stdout);
|
||||
printf("\ndata: ");
|
||||
fwrite(data.data, 1, data.size, stdout);
|
||||
printf("\n");
|
||||
printf("--------------------------------------\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
/* the URL is 8 bytes into the key struct
|
||||
*/
|
||||
printf("URL: %s\n",(char*)key.data+8);
|
||||
printf("file: %s\n", cache_obj->filename);
|
||||
printf("is_relative_path: %s\n", cache_obj->is_relative_path ? "TRUE" : "FALSE");
|
||||
printf("content_type: %s\n", cache_obj->content_type);
|
||||
printf("content_length: %d\n", cache_obj->content_length);
|
||||
printf("last_modified: %s\n", ctime(&cache_obj->last_modified));
|
||||
printf("--------------------------------------\n");
|
||||
}
|
||||
}
|
||||
|
||||
6
mozilla/network/cache/export.mac
vendored
Normal file
6
mozilla/network/cache/export.mac
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
#
|
||||
# This is a list of local files which get copied to the mozilla:dist directory
|
||||
#
|
||||
|
||||
extcache.h
|
||||
netcache.h
|
||||
883
mozilla/network/cache/extcache.c
vendored
Normal file
883
mozilla/network/cache/extcache.c
vendored
Normal file
@@ -0,0 +1,883 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/* Please leave outside of ifdef for window precompiled headers */
|
||||
#include "mkcache.h"
|
||||
|
||||
#ifdef MOZILLA_CLIENT
|
||||
#include "mktrace.h"
|
||||
#include "prmem.h"
|
||||
#include "plstr.h"
|
||||
|
||||
/* Publicly released Netscape cache access routines.
|
||||
*
|
||||
* These routines are shared between the netscape executable
|
||||
* and the programs released as a cache developers kit.
|
||||
*
|
||||
* Created: Lou Montulli <montulli@netscape.com>, July-95.
|
||||
* Modifications/Addition: Gagan Saksena, 97
|
||||
*/
|
||||
|
||||
#ifndef EXT_DB_ROUTINES
|
||||
#include "secnav.h"
|
||||
#include "sechash.h"
|
||||
#endif
|
||||
|
||||
#include "extcache.h" /* include this for everything */
|
||||
|
||||
#ifdef EXT_DB_ROUTINES
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <assert.h>
|
||||
|
||||
typedef struct {
|
||||
int32 len;
|
||||
char *data;
|
||||
} SECItem;
|
||||
|
||||
#ifdef _sgi
|
||||
#include <sys/endian.h>
|
||||
#endif /* _sgi */
|
||||
|
||||
|
||||
/* URL methods
|
||||
*/
|
||||
#define URL_GET_METHOD 0
|
||||
#define URL_POST_METHOD 1
|
||||
#define URL_HEAD_METHOD 2
|
||||
|
||||
#endif /* DB_STORE */
|
||||
|
||||
|
||||
MODULE_PRIVATE DBT *
|
||||
net_CacheDBTDup(DBT *obj)
|
||||
{
|
||||
DBT * rv = PR_NEW(DBT);
|
||||
|
||||
if(!rv)
|
||||
return(NULL);
|
||||
|
||||
rv->size = obj->size;
|
||||
rv->data = PR_Malloc(rv->size);
|
||||
|
||||
if(!rv->data)
|
||||
{
|
||||
PR_Free(rv);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
memcpy(rv->data, obj->data, rv->size);
|
||||
|
||||
return(rv);
|
||||
|
||||
}
|
||||
|
||||
/* free the cache object
|
||||
*/
|
||||
MODULE_PRIVATE void net_freeCacheObj (net_CacheObject * cache_obj)
|
||||
{
|
||||
|
||||
PR_FREEIF(cache_obj->address);
|
||||
PR_FREEIF(cache_obj->post_data);
|
||||
PR_FREEIF(cache_obj->post_headers);
|
||||
PR_FREEIF(cache_obj->content_type);
|
||||
PR_FREEIF(cache_obj->charset);
|
||||
PR_FREEIF(cache_obj->content_encoding);
|
||||
PR_FREEIF(cache_obj->page_services_url);
|
||||
PR_FREEIF(cache_obj->filename);
|
||||
|
||||
#ifndef EXT_DB_ROUTINES
|
||||
PR_FREEIF(cache_obj->sec_info);
|
||||
#endif
|
||||
|
||||
PR_Free(cache_obj);
|
||||
}
|
||||
|
||||
/* returns true if this DBT looks like a valid
|
||||
* entry. It looks at the checksum and the
|
||||
* version number to see if it's valid
|
||||
*/
|
||||
#define MAX_VALID_DBT_SIZE 10000
|
||||
|
||||
MODULE_PRIVATE PRBool
|
||||
net_IsValidCacheDBT(DBT *obj)
|
||||
{
|
||||
char *cur_ptr, *max_ptr;
|
||||
uint32 len;
|
||||
|
||||
if(!obj || obj->size < 9 || obj->size > MAX_VALID_DBT_SIZE)
|
||||
return(FALSE);
|
||||
|
||||
cur_ptr = (char *)obj->data;
|
||||
max_ptr = cur_ptr+obj->size;
|
||||
|
||||
/* get the total size of the struct out of
|
||||
* the first field to check it
|
||||
*/
|
||||
COPY_INT32(&len, cur_ptr);
|
||||
cur_ptr += sizeof(int32);
|
||||
|
||||
if(len != obj->size)
|
||||
{
|
||||
TRACEMSG(("Size going in is not the same as size coming out"));
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
/* get the version number of the written structure
|
||||
*/
|
||||
if(cur_ptr > max_ptr)
|
||||
return(FALSE);
|
||||
COPY_INT32(&len, cur_ptr);
|
||||
cur_ptr += sizeof(int32);
|
||||
|
||||
if(len != CACHE_FORMAT_VERSION)
|
||||
{
|
||||
TRACEMSG(("Version of cache structure is wrong!: %d", len));
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
/* looks good to me... */
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
|
||||
/* takes a cache object and returns a malloc'd
|
||||
* (void *) suitible for passing in as a database
|
||||
* data storage object
|
||||
*/
|
||||
MODULE_PRIVATE DBT *
|
||||
net_CacheStructToDBData(net_CacheObject * old_obj)
|
||||
{
|
||||
int32 len;
|
||||
char *cur_ptr;
|
||||
void *new_obj;
|
||||
int32 total_size;
|
||||
DBT *rv;
|
||||
|
||||
rv = PR_NEW(DBT);
|
||||
|
||||
if(!rv)
|
||||
return(NULL);
|
||||
|
||||
total_size = sizeof(net_CacheObject);
|
||||
|
||||
#define ADD_STRING_SIZE(string) \
|
||||
total_size += old_obj->string ? PL_strlen(old_obj->string)+1 : 0
|
||||
|
||||
ADD_STRING_SIZE(address);
|
||||
total_size += old_obj->post_data_size+1;
|
||||
ADD_STRING_SIZE(post_headers);
|
||||
ADD_STRING_SIZE(content_type);
|
||||
ADD_STRING_SIZE(content_encoding);
|
||||
ADD_STRING_SIZE(charset);
|
||||
ADD_STRING_SIZE(filename);
|
||||
total_size += sizeof(uint32); /* size of secinfo */
|
||||
total_size += SECNAV_SSLSocketStatusLength(old_obj->sec_info);
|
||||
ADD_STRING_SIZE(page_services_url);
|
||||
|
||||
#undef ADD_STRING_SIZE
|
||||
|
||||
new_obj = PR_Malloc(total_size * sizeof(char));
|
||||
|
||||
if(!new_obj)
|
||||
{
|
||||
PR_Free(rv);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memset(new_obj, 0, total_size * sizeof(char));
|
||||
|
||||
/*
|
||||
* order is:
|
||||
* int32 size of the entire structure;
|
||||
*
|
||||
* int32 version of the structure format (CACHE_FORMAT_VERSION)
|
||||
*
|
||||
* time_t last_modified;
|
||||
* time_t last_accessed;
|
||||
* time_t expires;
|
||||
* uint32 content_length;
|
||||
* XP_Bool is_netsite;
|
||||
*
|
||||
* time_t lock_date;
|
||||
*
|
||||
* char * filename;
|
||||
* int32 filename_len;
|
||||
*
|
||||
* int32 security_on;
|
||||
* unsigned char * sec_info;
|
||||
*
|
||||
* int32 method;
|
||||
*
|
||||
* # don't store address, or post_data stuff
|
||||
* # char * address;
|
||||
* # uint32 post_data_size;
|
||||
* # char * post_data;
|
||||
*
|
||||
* char * post_headers;
|
||||
* char * content_type;
|
||||
* char * content_encoding;
|
||||
* char * charset;
|
||||
*
|
||||
* XP_Bool incomplete_file;
|
||||
* uint32 total_content_length;
|
||||
*
|
||||
* char * page_services_url;
|
||||
*
|
||||
* string lengths all include null terminators
|
||||
* all integer constants are stored as 4 bytes
|
||||
* all booleans are stored as one byte
|
||||
*/
|
||||
|
||||
/* VERY VERY IMPORTANT. Whenever the
|
||||
* format of the record structure changes
|
||||
* you must verify that the byte positions
|
||||
* in extcache.h are updated
|
||||
*/
|
||||
|
||||
#define STUFF_STRING(string) \
|
||||
{ \
|
||||
len = (old_obj->string ? PL_strlen(old_obj->string)+1 : 0); \
|
||||
COPY_INT32((void *)cur_ptr, &len); \
|
||||
cur_ptr = cur_ptr + sizeof(int32); \
|
||||
if(len) \
|
||||
memcpy((void *)cur_ptr, old_obj->string, len); \
|
||||
cur_ptr += len; \
|
||||
}
|
||||
|
||||
#define STUFF_NUMBER(number) \
|
||||
{ \
|
||||
COPY_INT32((void *)cur_ptr, &old_obj->number); \
|
||||
cur_ptr = cur_ptr + sizeof(int32); \
|
||||
}
|
||||
|
||||
#define STUFF_TIMET(number) \
|
||||
{ \
|
||||
COPY_INT32((void *)cur_ptr, &old_obj->number); \
|
||||
cur_ptr = cur_ptr + sizeof(time_t); \
|
||||
}
|
||||
|
||||
#define STUFF_BOOL(bool_val) \
|
||||
{ \
|
||||
if(old_obj->bool_val) \
|
||||
((char *)(cur_ptr))[0] = 1; \
|
||||
else \
|
||||
((char *)(cur_ptr))[0] = 0; \
|
||||
cur_ptr = cur_ptr + sizeof(char); \
|
||||
}
|
||||
|
||||
cur_ptr = (char *)new_obj;
|
||||
|
||||
/* put the total size of the struct into
|
||||
* the first field so that we have
|
||||
* a cross check against corruption
|
||||
*/
|
||||
COPY_INT32((void *)cur_ptr, &total_size);
|
||||
cur_ptr = cur_ptr + sizeof(int32);
|
||||
|
||||
/* put the version number of the structure
|
||||
* format that we are using
|
||||
* By using a version string when writting
|
||||
* we can support backwards compatibility
|
||||
* in our reading code
|
||||
* (use "len" as a temp variable)
|
||||
*/
|
||||
len = CACHE_FORMAT_VERSION;
|
||||
COPY_INT32((void *)cur_ptr, &len);
|
||||
cur_ptr = cur_ptr + sizeof(int32);
|
||||
|
||||
STUFF_TIMET(last_modified);
|
||||
STUFF_TIMET(last_accessed);
|
||||
STUFF_TIMET(expires);
|
||||
STUFF_NUMBER(content_length);
|
||||
STUFF_BOOL(is_netsite);
|
||||
|
||||
STUFF_TIMET(lock_date);
|
||||
|
||||
STUFF_STRING(filename);
|
||||
STUFF_NUMBER(filename_len);
|
||||
|
||||
STUFF_BOOL(is_relative_path);
|
||||
|
||||
STUFF_NUMBER(security_on);
|
||||
|
||||
#ifndef EXT_DB_ROUTINES
|
||||
/* save the security info */
|
||||
if ( old_obj->sec_info ) {
|
||||
len = SECNAV_SSLSocketStatusLength(old_obj->sec_info);
|
||||
COPY_INT32((void *)cur_ptr, &len);
|
||||
cur_ptr = cur_ptr + sizeof(int32);
|
||||
|
||||
memcpy((void *)cur_ptr, old_obj->sec_info, len);
|
||||
cur_ptr += len;
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
len = 0;
|
||||
COPY_INT32((void *)cur_ptr, &len);
|
||||
cur_ptr = cur_ptr + sizeof(int32);
|
||||
}
|
||||
|
||||
STUFF_NUMBER(method);
|
||||
|
||||
#ifdef STORE_ADDRESS_AND_POST_DATA
|
||||
|
||||
STUFF_STRING(address);
|
||||
STUFF_NUMBER(post_data_size);
|
||||
|
||||
/* post_data
|
||||
* this is special since it not necessarily a string
|
||||
*/
|
||||
if(old_obj->post_data_size)
|
||||
{
|
||||
memcpy(cur_ptr, old_obj->post_data, old_obj->post_data_size+1);
|
||||
cur_ptr += old_obj->post_data_size+1;
|
||||
}
|
||||
|
||||
#endif /* STORE_ADDRESS_AND_POST_DATA */
|
||||
|
||||
STUFF_STRING(post_headers);
|
||||
|
||||
STUFF_STRING(content_type);
|
||||
STUFF_STRING(content_encoding);
|
||||
STUFF_STRING(charset);
|
||||
|
||||
STUFF_BOOL(incomplete_file);
|
||||
STUFF_NUMBER(real_content_length);
|
||||
|
||||
STUFF_STRING(page_services_url);
|
||||
|
||||
#undef STUFF_STRING
|
||||
#undef STUFF_NUMBER
|
||||
#undef STUFF_BOOL
|
||||
|
||||
rv->data = new_obj;
|
||||
rv->size = total_size;
|
||||
|
||||
return(rv);
|
||||
|
||||
}
|
||||
|
||||
/* takes a database storage object and returns a malloc'd
|
||||
* cache data object. The cache object needs all of
|
||||
* it's parts free'd.
|
||||
*
|
||||
* returns NULL on parse error
|
||||
*/
|
||||
MODULE_PRIVATE net_CacheObject *
|
||||
net_DBDataToCacheStruct(DBT * db_obj)
|
||||
{
|
||||
net_CacheObject * rv = PR_NEW(net_CacheObject);
|
||||
char * cur_ptr;
|
||||
char * max_ptr;
|
||||
uint32 len;
|
||||
int32 version;
|
||||
|
||||
if(!rv)
|
||||
return NULL;
|
||||
|
||||
memset(rv, 0, sizeof(net_CacheObject));
|
||||
|
||||
/* if any strings are larger than this then
|
||||
* there was a serious database error
|
||||
*/
|
||||
#define MAX_HUGE_STRING_SIZE 10000
|
||||
|
||||
#define RETRIEVE_STRING(string) \
|
||||
{ \
|
||||
if(cur_ptr > max_ptr) \
|
||||
{ \
|
||||
net_freeCacheObj(rv); \
|
||||
return(NULL); \
|
||||
} \
|
||||
COPY_INT32(&len, cur_ptr); \
|
||||
cur_ptr += sizeof(int32); \
|
||||
if(len) \
|
||||
{ \
|
||||
if(len > MAX_HUGE_STRING_SIZE) \
|
||||
{ \
|
||||
net_freeCacheObj(rv); \
|
||||
return(NULL); \
|
||||
} \
|
||||
rv->string = (char*)PR_Malloc(len); \
|
||||
if(!rv->string) \
|
||||
{ \
|
||||
net_freeCacheObj(rv); \
|
||||
return(NULL); \
|
||||
} \
|
||||
memcpy(rv->string, cur_ptr, len); \
|
||||
cur_ptr += len; \
|
||||
} \
|
||||
}
|
||||
|
||||
#define RETRIEVE_NUMBER(number) \
|
||||
{ \
|
||||
if(cur_ptr > max_ptr) \
|
||||
return(rv); \
|
||||
COPY_INT32(&rv->number, cur_ptr); \
|
||||
cur_ptr += sizeof(int32); \
|
||||
}
|
||||
|
||||
#define RETRIEVE_TIMET(number) \
|
||||
{ \
|
||||
if(cur_ptr > max_ptr) \
|
||||
return(rv); \
|
||||
COPY_INT32(&rv->number, cur_ptr); \
|
||||
cur_ptr += sizeof(time_t); \
|
||||
}
|
||||
|
||||
#define RETRIEVE_BOOL(bool) \
|
||||
{ \
|
||||
if(cur_ptr > max_ptr) \
|
||||
return(rv); \
|
||||
if(((char *)(cur_ptr))[0]) \
|
||||
rv->bool = TRUE; \
|
||||
else \
|
||||
rv->bool = FALSE; \
|
||||
cur_ptr += sizeof(char); \
|
||||
}
|
||||
|
||||
cur_ptr = (char *)db_obj->data;
|
||||
|
||||
max_ptr = cur_ptr+db_obj->size;
|
||||
|
||||
/* get the total size of the struct out of
|
||||
* the first field to check it
|
||||
*/
|
||||
COPY_INT32(&len, cur_ptr);
|
||||
cur_ptr += sizeof(int32);
|
||||
|
||||
if(len != db_obj->size)
|
||||
{
|
||||
TRACEMSG(("Size going in is not the same as size coming out"));
|
||||
PR_Free(rv);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
/* get the version number of the written structure
|
||||
*/
|
||||
if(cur_ptr > max_ptr)
|
||||
return(rv);
|
||||
COPY_INT32(&version, cur_ptr);
|
||||
cur_ptr += sizeof(int32);
|
||||
|
||||
if(version != CACHE_FORMAT_VERSION)
|
||||
{
|
||||
TRACEMSG(("Version of cache structure is wrong!: %d", version));
|
||||
PR_Free(rv);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
RETRIEVE_TIMET(last_modified);
|
||||
RETRIEVE_TIMET(last_accessed);
|
||||
RETRIEVE_TIMET(expires);
|
||||
RETRIEVE_NUMBER(content_length);
|
||||
RETRIEVE_BOOL(is_netsite);
|
||||
|
||||
RETRIEVE_TIMET(lock_date);
|
||||
|
||||
RETRIEVE_STRING(filename);
|
||||
RETRIEVE_NUMBER(filename_len);
|
||||
|
||||
RETRIEVE_BOOL(is_relative_path);
|
||||
|
||||
RETRIEVE_NUMBER(security_on);
|
||||
|
||||
/* security info */
|
||||
if(cur_ptr > max_ptr)
|
||||
return(rv);
|
||||
COPY_INT32(&len, cur_ptr);
|
||||
cur_ptr += sizeof(int32);
|
||||
|
||||
if ( len == 0 ) {
|
||||
rv->sec_info = NULL;
|
||||
} else {
|
||||
rv->sec_info = PR_Malloc(len);
|
||||
if ( rv->sec_info == NULL ) {
|
||||
return(rv);
|
||||
}
|
||||
|
||||
memcpy(rv->sec_info, cur_ptr, len);
|
||||
cur_ptr += len;
|
||||
}
|
||||
|
||||
|
||||
RETRIEVE_NUMBER(method);
|
||||
|
||||
#ifdef STORE_ADDRESS_AND_POST_DATA
|
||||
|
||||
RETRIEVE_STRING(address);
|
||||
RETRIEVE_NUMBER(post_data_size);
|
||||
|
||||
/* post_data
|
||||
* this is special since it not necessarily a string
|
||||
*/
|
||||
if(rv->post_data_size)
|
||||
{
|
||||
rv->post_data = PR_Malloc(rv->post_data_size+1);
|
||||
if(rv->post_data)
|
||||
memcpy(rv->post_data, cur_ptr, rv->post_data_size+1);
|
||||
cur_ptr += rv->post_data_size+1;
|
||||
}
|
||||
|
||||
#endif /* STORE_ADDRESS_AND_POST_DATA */
|
||||
|
||||
RETRIEVE_STRING(post_headers);
|
||||
|
||||
RETRIEVE_STRING(content_type);
|
||||
RETRIEVE_STRING(content_encoding);
|
||||
RETRIEVE_STRING(charset);
|
||||
|
||||
RETRIEVE_BOOL(incomplete_file);
|
||||
RETRIEVE_NUMBER(real_content_length);
|
||||
|
||||
RETRIEVE_STRING(page_services_url);
|
||||
#undef RETRIEVE_STRING
|
||||
#undef RETRIEVE_NUMBER
|
||||
#undef RETRIEVE_BOOL
|
||||
|
||||
return(rv);
|
||||
}
|
||||
|
||||
#if defined(DEBUG) && defined(UNIX)
|
||||
int
|
||||
cache_test_me()
|
||||
{
|
||||
|
||||
net_CacheObject test;
|
||||
net_CacheObject *rv;
|
||||
int32 total_size;
|
||||
DBT *db_obj;
|
||||
|
||||
memset(&test, 0, sizeof(net_CacheObject));
|
||||
StrAllocCopy(test.address, "test1");
|
||||
db_obj = net_CacheStructToDBData(&test);
|
||||
rv = net_DBDataToCacheStruct(db_obj);
|
||||
printf("test1: %s\n", rv->address);
|
||||
|
||||
memset(&test, 0, sizeof(net_CacheObject));
|
||||
StrAllocCopy(test.address, "test2");
|
||||
StrAllocCopy(test.charset, "test2");
|
||||
db_obj = net_CacheStructToDBData(&test);
|
||||
rv = net_DBDataToCacheStruct(db_obj);
|
||||
printf("test2: %s %s\n", rv->address, rv->charset);
|
||||
|
||||
memset(&test, 0, sizeof(net_CacheObject));
|
||||
StrAllocCopy(test.address, "test3");
|
||||
StrAllocCopy(test.charset, "test3");
|
||||
test.content_length = 3 ;
|
||||
test.method = 3 ;
|
||||
test.is_netsite = 3 ;
|
||||
db_obj = net_CacheStructToDBData(&test);
|
||||
rv = net_DBDataToCacheStruct(db_obj);
|
||||
printf("test3: %s %s %d %d %s\n",
|
||||
rv->address, rv->charset,
|
||||
rv->content_length, rv->method,
|
||||
(rv->is_netsite == 3 ? "TRUE" : "FALSE"));
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
/* generates a key for use in the cache database
|
||||
* from a CacheObject struct
|
||||
*
|
||||
* Key is based on the address and the post_data
|
||||
*
|
||||
* looks like:
|
||||
* size checksum | size of address | ADDRESS | size of post data | POST DATA
|
||||
*/
|
||||
MODULE_PRIVATE DBT *
|
||||
net_GenCacheDBKey(char *address, char *post_data, int32 post_data_size)
|
||||
{
|
||||
DBT *rv = PR_NEW(DBT);
|
||||
char *hash;
|
||||
char *data_ptr;
|
||||
int32 str_len;
|
||||
int32 size;
|
||||
|
||||
#define MD5_HASH_SIZE 16 /* always 16 due to md5 hash type */
|
||||
|
||||
if(!rv)
|
||||
return(NULL);
|
||||
|
||||
if(!address)
|
||||
{
|
||||
PR_ASSERT(0);
|
||||
rv->size = 0;
|
||||
return(rv);
|
||||
}
|
||||
|
||||
hash = PL_strchr(address, '#');
|
||||
|
||||
/* don't include '#' in a key */
|
||||
if(hash)
|
||||
*hash = '\0';
|
||||
|
||||
str_len = PL_strlen(address)+1;
|
||||
|
||||
size = sizeof(int32); /* for check sum */
|
||||
size += sizeof(int32); /* for size of address */
|
||||
size += str_len; /* for address string */
|
||||
size += sizeof(int32); /* for size of post_data */
|
||||
|
||||
if(post_data_size)
|
||||
size += MD5_HASH_SIZE;
|
||||
|
||||
rv->size = size;
|
||||
rv->data = PR_Malloc(size);
|
||||
|
||||
if(!rv->data)
|
||||
{
|
||||
PR_Free(rv);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
data_ptr = (char *) rv->data;
|
||||
|
||||
/* put in the checksum size */
|
||||
COPY_INT32(data_ptr, &size);
|
||||
data_ptr = data_ptr + sizeof(int32);
|
||||
|
||||
/* put in the size of the address string */
|
||||
COPY_INT32(data_ptr, &str_len);
|
||||
data_ptr = data_ptr + sizeof(int32);
|
||||
|
||||
/* put in the address string data */
|
||||
memcpy(data_ptr, address, str_len);
|
||||
data_ptr = data_ptr + str_len;
|
||||
|
||||
/* set the address back to it's original form */
|
||||
if(hash)
|
||||
*hash = '#';
|
||||
|
||||
/* put in the size of the post data */
|
||||
if(post_data_size)
|
||||
{
|
||||
int32 size_of_md5 = MD5_HASH_SIZE;
|
||||
unsigned char post_data_hash[MD5_HASH_SIZE];
|
||||
|
||||
MD5_HashBuf(post_data_hash, (unsigned char*)post_data, post_data_size);
|
||||
|
||||
COPY_INT32(data_ptr, &size_of_md5);
|
||||
data_ptr = data_ptr + sizeof(int32);
|
||||
|
||||
/* put in the post data if there is any */
|
||||
memcpy(data_ptr, post_data_hash, sizeof(post_data_hash));
|
||||
}
|
||||
else
|
||||
{
|
||||
COPY_INT32(data_ptr, &post_data_size);
|
||||
data_ptr = data_ptr + sizeof(int32);
|
||||
}
|
||||
|
||||
return(rv);
|
||||
}
|
||||
|
||||
/* returns a static string that contains the
|
||||
* URL->address of the key
|
||||
*
|
||||
* returns NULL on error
|
||||
*/
|
||||
MODULE_PRIVATE char *
|
||||
net_GetAddressFromCacheKey(DBT *key)
|
||||
{
|
||||
uint32 size;
|
||||
char *data;
|
||||
|
||||
/* check for minimum size */
|
||||
if(key->size < 10)
|
||||
return(NULL);
|
||||
|
||||
/* validate size checksum */
|
||||
data = (char *)key->data;
|
||||
COPY_INT32(&size, data);
|
||||
data += sizeof(int32);
|
||||
|
||||
if(size != key->size)
|
||||
return(NULL);
|
||||
|
||||
/* get size of address string */
|
||||
COPY_INT32(&size, data);
|
||||
data += sizeof(int32);
|
||||
|
||||
/* make sure it's a valid c string */
|
||||
if(data[size] != '\0')
|
||||
return(NULL);
|
||||
|
||||
/* it's valid return it */
|
||||
return(data);
|
||||
}
|
||||
|
||||
|
||||
/* checks a date within a DBT struct so
|
||||
* that we don't have to convert it into a CacheObject
|
||||
*
|
||||
* This works because of the fixed length record format
|
||||
* of the first part of the specific DBT format I'm
|
||||
* using
|
||||
*
|
||||
* returns 0 on error
|
||||
*/
|
||||
MODULE_PRIVATE time_t
|
||||
net_GetTimeInCacheDBT(DBT *data, int byte_position)
|
||||
{
|
||||
time_t date;
|
||||
char *ptr = (char *)data->data;
|
||||
|
||||
if(data->size < byte_position+sizeof(time_t))
|
||||
return(0);
|
||||
|
||||
if(!net_IsValidCacheDBT(data))
|
||||
return(0);
|
||||
|
||||
COPY_INT32(&date, ptr+byte_position);
|
||||
|
||||
/* TRACEMSG(("Got date from cache DBT: %d", date)); */
|
||||
|
||||
return(date);
|
||||
|
||||
}
|
||||
|
||||
/* Sets a date within a DBT struct so
|
||||
* that we don't have to convert it into a CacheObject
|
||||
*
|
||||
* This works because of the fixed length record format
|
||||
* of the first part of the specific DBT format I'm
|
||||
* using
|
||||
*
|
||||
* returns 0 on error
|
||||
*/
|
||||
MODULE_PRIVATE void
|
||||
net_SetTimeInCacheDBT(DBT *data, int byte_position, time_t date)
|
||||
{
|
||||
char *ptr = (char *)data->data;
|
||||
|
||||
if(data->size < byte_position+sizeof(time_t))
|
||||
return;
|
||||
|
||||
if(!net_IsValidCacheDBT(data))
|
||||
return;
|
||||
|
||||
COPY_INT32(ptr+byte_position, &date);
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
/* Gets the filename within a cache DBT struct so
|
||||
* that we don't have to convert it into a CacheObject
|
||||
*
|
||||
* This works because of the fixed length record format
|
||||
* of the first part of the specific DBT format I'm
|
||||
* using
|
||||
*
|
||||
* returns NULL on error
|
||||
*/
|
||||
#define MAX_FILE_SIZE 2048
|
||||
MODULE_PRIVATE char *
|
||||
net_GetFilenameInCacheDBT(DBT *data)
|
||||
{
|
||||
int32 size;
|
||||
char *rv;
|
||||
char *ptr = (char*)data->data;
|
||||
|
||||
if(data->size < FILENAME_BYTE_POSITION)
|
||||
return(NULL);
|
||||
|
||||
if(!net_IsValidCacheDBT(data))
|
||||
return(0);
|
||||
|
||||
COPY_INT32(&size, ptr+FILENAME_SIZE_BYTE_POSITION);
|
||||
|
||||
if(data->size < FILENAME_BYTE_POSITION+size
|
||||
|| size > MAX_FILE_SIZE)
|
||||
return(NULL);
|
||||
|
||||
rv = (char *)PR_Malloc(size);
|
||||
if(!rv)
|
||||
return(NULL);
|
||||
memcpy(rv, ptr+FILENAME_BYTE_POSITION, size);
|
||||
|
||||
TRACEMSG(("Got filename: %s from DBT", rv));
|
||||
|
||||
return(rv);
|
||||
}
|
||||
|
||||
/* Gets a int32 within a DBT struct so
|
||||
* that we don't have to convert it into a CacheObject
|
||||
*
|
||||
* This works because of the fixed length record format
|
||||
* of the first part of the specific DBT format I'm
|
||||
* using
|
||||
*
|
||||
* returns 0 on error
|
||||
*/
|
||||
MODULE_PRIVATE time_t
|
||||
net_GetInt32InCacheDBT(DBT *data, int byte_position)
|
||||
{
|
||||
int32 num;
|
||||
char *ptr = (char *)data->data;
|
||||
|
||||
if(!net_IsValidCacheDBT(data))
|
||||
return(0);
|
||||
|
||||
if(data->size < byte_position+sizeof(time_t))
|
||||
return(0);
|
||||
|
||||
COPY_INT32(&num, ptr+byte_position);
|
||||
|
||||
/* TRACEMSG(("Got int32 from cache DBT: %d", num)); */
|
||||
|
||||
return(num);
|
||||
|
||||
}
|
||||
|
||||
MODULE_PRIVATE void
|
||||
net_FreeCacheDBTdata(DBT *stuff)
|
||||
{
|
||||
if(stuff)
|
||||
{
|
||||
PR_Free(stuff->data);
|
||||
PR_Free(stuff);
|
||||
}
|
||||
}
|
||||
|
||||
/* takes a database storage object and returns an un-malloc'd
|
||||
* cache data object. The structure returned has pointers
|
||||
* directly into the database memory and are only valid
|
||||
* until the next call to any database function
|
||||
*
|
||||
* do not free anything returned by this structure
|
||||
*/
|
||||
MODULE_PRIVATE net_CacheObject *
|
||||
net_Fast_DBDataToCacheStruct(DBT *obj)
|
||||
{
|
||||
static net_CacheObject *rv=0;
|
||||
|
||||
/* free any previous one */
|
||||
if(rv)
|
||||
net_freeCacheObj(rv);
|
||||
|
||||
rv = net_DBDataToCacheStruct(obj);
|
||||
|
||||
return(rv);
|
||||
|
||||
}
|
||||
|
||||
#endif /* MOZILLA_CLIENT */
|
||||
272
mozilla/network/cache/extcache.h
vendored
Normal file
272
mozilla/network/cache/extcache.h
vendored
Normal file
@@ -0,0 +1,272 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef EXT_CACHE_H
|
||||
#define EXT_CACHE_H
|
||||
|
||||
#ifndef EXT_DB_ROUTINES
|
||||
#include "mcom_db.h"
|
||||
#endif
|
||||
|
||||
#ifdef EXT_DB_ROUTINES
|
||||
#define PRBool char
|
||||
#define uint32 unsigned int
|
||||
#define int32 int
|
||||
#define PR_NEW(structure) ((structure *) malloc(sizeof(structure)))
|
||||
#define PR_Malloc (void *) malloc
|
||||
#define memcpy memcpy
|
||||
#define memset memset
|
||||
#define TRACEMSG(x) printf x
|
||||
#define FREEIF(x) do { if(x) free(x); } while(0)
|
||||
#define FREE free
|
||||
#define PL_strlen strlen
|
||||
#define PL_strchr strchr
|
||||
#define PL_strcmp strcmp
|
||||
#define PR_ASSERT assert
|
||||
#define MODULE_PRIVATE
|
||||
#define PRIVATE static
|
||||
#define TRUE !0
|
||||
#define FALSE 0
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <db.h>
|
||||
#endif
|
||||
|
||||
#ifndef EXT_DB_ROUTINES
|
||||
|
||||
#ifndef NSPR20
|
||||
#include "prosdep.h" /* for IS_LITTLE_ENDIAN / IS_BIG_ENDIAN */
|
||||
#else
|
||||
#include "prtypes.h"
|
||||
#endif
|
||||
|
||||
#endif /* EXT_DB_ROUTINES */
|
||||
|
||||
#if !defined(IS_LITTLE_ENDIAN) && !defined(IS_BIG_ENDIAN)
|
||||
ERROR! Must have a byte order
|
||||
#endif
|
||||
|
||||
#ifdef IS_LITTLE_ENDIAN
|
||||
#define COPY_INT32(_a,_b) memcpy(_a, _b, sizeof(int32));
|
||||
#else
|
||||
#define COPY_INT32(_a,_b) /* swap */ \
|
||||
do { \
|
||||
((char *)(_a))[0] = ((char *)(_b))[3]; \
|
||||
((char *)(_a))[1] = ((char *)(_b))[2]; \
|
||||
((char *)(_a))[2] = ((char *)(_b))[1]; \
|
||||
((char *)(_a))[3] = ((char *)(_b))[0]; \
|
||||
} while(0)
|
||||
#endif
|
||||
|
||||
#define EXT_CACHE_NAME_STRING "INT_ExternalCacheNameString"
|
||||
|
||||
/* Internal WARNING!! Some slots of this structure
|
||||
* are shared with URL_Struct and
|
||||
* History_entry. If you add a slot, decide whether it needs to be shared
|
||||
* as well.
|
||||
*/
|
||||
typedef struct _net_CacheObject {
|
||||
time_t last_modified;
|
||||
time_t last_accessed;
|
||||
time_t expires;
|
||||
PRBool is_netsite;
|
||||
uint32 content_length;
|
||||
|
||||
char * filename; /* cache file name */
|
||||
int32 filename_len; /* optimization */
|
||||
PRBool is_relative_path; /* is the path relative? */
|
||||
|
||||
/* Security information */
|
||||
int32 security_on; /* is security on? */
|
||||
unsigned char *sec_info;
|
||||
|
||||
time_t lock_date; /* the file is locked if this
|
||||
* is non-zero. The date
|
||||
* represents the time the
|
||||
* lock was put in place.
|
||||
* Locks are only valid for
|
||||
* one session
|
||||
*/
|
||||
|
||||
int32 method;
|
||||
char * address;
|
||||
uint32 post_data_size;
|
||||
char * post_data;
|
||||
char * post_headers;
|
||||
char * content_type;
|
||||
char * content_encoding;
|
||||
char * charset;
|
||||
|
||||
PRBool incomplete_file; /* means that the whole
|
||||
* file is not there.
|
||||
* This can only be true
|
||||
* if the server supports byteranges
|
||||
*/
|
||||
uint32 real_content_length; /* the whole content length
|
||||
* i.e. the server size of a truncated
|
||||
* client file
|
||||
*/
|
||||
char * page_services_url;
|
||||
char * etag; /* HTTP/1.1 Etag */
|
||||
|
||||
} net_CacheObject;
|
||||
|
||||
/* this is the version number of the cache database entry.
|
||||
* It should be incremented in integer ingrements up
|
||||
* to MAXINT32
|
||||
*/
|
||||
#define CACHE_FORMAT_VERSION 5
|
||||
|
||||
/* these defines specify the exact byte position
|
||||
* of the first 4 elements in the DBT data struct
|
||||
* Change these if you change the order of entry into
|
||||
* the DBT
|
||||
*/
|
||||
#define LAST_MODIFIED_BYTE_POSITION \
|
||||
sizeof(int32)+sizeof(int32)
|
||||
#define LAST_ACCESSED_BYTE_POSITION \
|
||||
sizeof(int32)+sizeof(int32)+sizeof(time_t)
|
||||
#define EXPIRES_BYTE_POSITION \
|
||||
sizeof(int32)+sizeof(int32)+sizeof(time_t)+sizeof(time_t)
|
||||
#define CONTENT_LENGTH_BYTE_POSITION \
|
||||
sizeof(int32)+sizeof(int32)+sizeof(time_t)+sizeof(time_t) \
|
||||
+sizeof(time_t)
|
||||
#define IS_NETSITE_BYTE_POSITION \
|
||||
sizeof(int32)+sizeof(int32)+sizeof(time_t)+sizeof(time_t) \
|
||||
+sizeof(time_t)+sizeof(int32)
|
||||
|
||||
#define LOCK_DATE_BYTE_POSITION \
|
||||
sizeof(int32)+sizeof(int32)+sizeof(time_t)+sizeof(time_t) \
|
||||
+sizeof(time_t)+sizeof(int32)+sizeof(char)
|
||||
|
||||
#define FILENAME_SIZE_BYTE_POSITION \
|
||||
sizeof(int32)+sizeof(int32)+sizeof(time_t)+sizeof(time_t) \
|
||||
+sizeof(time_t)+sizeof(uint32)+sizeof(char)+sizeof(time_t)
|
||||
#define FILENAME_BYTE_POSITION \
|
||||
sizeof(int32)+sizeof(int32)+sizeof(time_t)+sizeof(time_t) \
|
||||
+sizeof(time_t)+sizeof(uint32)+sizeof(char)+sizeof(time_t) \
|
||||
+sizeof(int32)
|
||||
|
||||
/* generates a key for use in the cache database
|
||||
* from a CacheObject struct
|
||||
*
|
||||
* Key is based on the address and the post_data
|
||||
*/
|
||||
extern DBT *
|
||||
net_GenCacheDBKey(char *address, char *post_data, int32 post_data_size);
|
||||
|
||||
/* returns a static string that contains the
|
||||
* URL->address of the key
|
||||
*
|
||||
* returns NULL on error
|
||||
*/
|
||||
extern char *
|
||||
net_GetAddressFromCacheKey(DBT *key);
|
||||
|
||||
|
||||
/* allocs and copies a new DBT from an existing DBT
|
||||
*/
|
||||
extern DBT * net_CacheDBTDup(DBT *obj);
|
||||
|
||||
/* free the cache object
|
||||
*/
|
||||
extern void net_freeCacheObj (net_CacheObject * cache_obj);
|
||||
|
||||
/* takes a cache object and returns a malloc'd
|
||||
* (void *) suitible for passing in as a database
|
||||
* data storage object
|
||||
*/
|
||||
extern DBT * net_CacheStructToDBData(net_CacheObject * old_obj);
|
||||
|
||||
/* takes a database storage object and returns a malloc'd
|
||||
* cache data object. The cache object needs all of
|
||||
* it's parts free'd.
|
||||
*
|
||||
* returns NULL on parse error
|
||||
*/
|
||||
extern net_CacheObject * net_DBDataToCacheStruct(DBT * db_obj);
|
||||
|
||||
/* checks a date within a DBT struct so
|
||||
* that we don't have to convert it into a CacheObject
|
||||
*
|
||||
* This works because of the fixed length record format
|
||||
* of the first part of the specific DBT format I'm
|
||||
* using
|
||||
*
|
||||
* returns 0 on error
|
||||
*/
|
||||
extern time_t net_GetTimeInCacheDBT(DBT *data, int byte_position);
|
||||
|
||||
/* Sets a date within a DBT struct so
|
||||
* that we don't have to convert it into a CacheObject
|
||||
*
|
||||
* This works because of the fixed length record format
|
||||
* of the first part of the specific DBT format I'm
|
||||
* using
|
||||
*
|
||||
* returns 0 on error
|
||||
*/
|
||||
extern void net_SetTimeInCacheDBT(DBT *data, int byte_position, time_t date);
|
||||
|
||||
/* Gets the filename within a cache DBT struct so
|
||||
* that we don't have to convert it into a CacheObject
|
||||
*
|
||||
* This works because of the fixed length record format
|
||||
* of the first part of the specific DBT format I'm
|
||||
* using
|
||||
*
|
||||
* returns NULL on error
|
||||
*/
|
||||
extern char * net_GetFilenameInCacheDBT(DBT *data);
|
||||
|
||||
/* Gets a int32 within a DBT struct so
|
||||
* that we don't have to convert it into a CacheObject
|
||||
*
|
||||
* This works because of the fixed length record format
|
||||
* of the first part of the specific DBT format I'm
|
||||
* using
|
||||
*
|
||||
* returns 0 on error
|
||||
*/
|
||||
extern time_t net_GetInt32InCacheDBT(DBT *data, int byte_position);
|
||||
|
||||
/* free's a DBT struct
|
||||
*/
|
||||
extern void net_FreeCacheDBTdata(DBT *stuff);
|
||||
|
||||
/* stores a cache object in the DBM database
|
||||
*/
|
||||
extern void net_ExtCacheStore(DB *database, net_CacheObject * obj);
|
||||
|
||||
/* takes a database storage object and returns an un-malloc'd
|
||||
* cache data object. The structure returned has pointers
|
||||
* directly into the database memory and are only valid
|
||||
* until the next call to any database function
|
||||
*
|
||||
* do not free anything returned by this structure
|
||||
*/
|
||||
extern net_CacheObject * net_Fast_DBDataToCacheStruct(DBT *obj);
|
||||
|
||||
/* returns true if this DBT looks like a valid
|
||||
* entry. It looks at the checksum and the
|
||||
* version number to see if it's valid
|
||||
*/
|
||||
extern PRBool net_IsValidCacheDBT(DBT *obj);
|
||||
|
||||
#endif /* EXT_CACHE_H */
|
||||
101
mozilla/network/cache/makefile.win
vendored
Normal file
101
mozilla/network/cache/makefile.win
vendored
Normal file
@@ -0,0 +1,101 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
IGNORE_MANIFEST=1
|
||||
#
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
# Makefile to build the cache LIB
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
|
||||
#!ifdef MOZ_JAVA
|
||||
#LOCAL_JMC_SUBDIR = .
|
||||
#!endif
|
||||
|
||||
#
|
||||
# Make sure we have MOZILLA_CLIENT defined so we get the
|
||||
# proper JS includes
|
||||
#
|
||||
LCFLAGS = $(LCFLAGS) -DMOZILLA_CLIENT
|
||||
!ifdef OPAQUE_MWCONTEXT
|
||||
LCFLAGS = $(LCFLAGS) -DOPAQUE_MWCONTEXT
|
||||
!endif
|
||||
|
||||
!ifdef BUILD_DEBUG_GC
|
||||
LCFLAGS = $(LCFLAGS) -DDEBUG_GC
|
||||
!endif
|
||||
|
||||
LLIBS= \
|
||||
$(NULL)
|
||||
MISCDEP=$(LLIBS)
|
||||
OBJS= \
|
||||
.\$(OBJDIR)\extcache.obj \
|
||||
.\$(OBJDIR)\mkcache.obj \
|
||||
.\$(OBJDIR)\mkextcac.obj \
|
||||
.\$(OBJDIR)\mkmemcac.obj \
|
||||
$(NULL)
|
||||
|
||||
|
||||
CSRCS = \
|
||||
cachedump.c \
|
||||
extcache.c \
|
||||
mkcache.c \
|
||||
mkextcac.c \
|
||||
mkmemcac.c \
|
||||
$(NULL)
|
||||
|
||||
|
||||
LIBRARY_NAME=netcache
|
||||
|
||||
MODULE=netcache
|
||||
DEPTH=..\..
|
||||
|
||||
EXTRA_LIBS=
|
||||
|
||||
REQUIRES= network nspr2
|
||||
EXPORTS= netcache.h
|
||||
|
||||
C_OBJS = \
|
||||
$(NULL)
|
||||
|
||||
|
||||
# use LINCS on win32 for now since REQUIRES seems to be broken
|
||||
#!if "$(MOZ_BITS)" != "16"
|
||||
LINCS= \
|
||||
-I$(XPDIST)\public\nspr2 \
|
||||
-I$(XPDIST)\public\dbm \
|
||||
-I$(XPDIST)\public\util \
|
||||
-I$(XPDIST)\public\pref \
|
||||
-I$(XPDIST)\public\network \
|
||||
-I$(XPDIST)\public\js \
|
||||
-I$(XPDIST)\public\java \
|
||||
-I$(XPDIST)\public\fileurl \
|
||||
-I$(XPDIST)\public\security \
|
||||
-I$(XPDIST)\public\jtools
|
||||
#!endif
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
||||
libs:: $(LIBRARY)
|
||||
$(MAKE_INSTALL) $(LIBRARY) $(DIST)\lib
|
||||
|
||||
|
||||
symbols::
|
||||
@echo "LIBRARY_NAME is $(LIBRARY_NAME)"
|
||||
@echo "LIBRARY is $(LIBRARY)"
|
||||
3450
mozilla/network/cache/mkcache.c
vendored
Normal file
3450
mozilla/network/cache/mkcache.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
38
mozilla/network/cache/mkcache.h
vendored
Normal file
38
mozilla/network/cache/mkcache.h
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef MKCACHE_H
|
||||
#define MKCACHE_H
|
||||
|
||||
#include "xp.h"
|
||||
|
||||
#ifndef EXT_CACHE_H
|
||||
#include "extcache.h"
|
||||
#endif
|
||||
|
||||
/* trace variable for cache testing */
|
||||
extern PRBool NET_CacheTraceOn;
|
||||
|
||||
PR_BEGIN_EXTERN_C
|
||||
|
||||
/* public accessor function for netcaster */
|
||||
extern PRBool NET_CacheStore(net_CacheObject *cacheObject, URL_Struct *url_s, PRBool accept_partial_files);
|
||||
|
||||
PR_END_EXTERN_C
|
||||
|
||||
#endif /* MKCACHE_H */
|
||||
1555
mozilla/network/cache/mkextcac.c
vendored
Normal file
1555
mozilla/network/cache/mkextcac.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,5 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/*
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
@@ -16,9 +16,7 @@
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "nsWinRegValue.h"
|
||||
#ifndef MKEXTCACHE_H
|
||||
#define MKEXTCACHE_H
|
||||
|
||||
PR_BEGIN_EXTERN_C
|
||||
|
||||
|
||||
PR_END_EXTERN_C
|
||||
#endif /* MKEXTCACHE_H */
|
||||
2010
mozilla/network/cache/mkmemcac.c
vendored
Normal file
2010
mozilla/network/cache/mkmemcac.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
61
mozilla/network/cache/mkmemcac.h
vendored
Normal file
61
mozilla/network/cache/mkmemcac.h
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef MK_MEMORY_CACHE_H
|
||||
|
||||
#include "mkgeturl.h"
|
||||
|
||||
/* A pointer to this struct is passed as the converter_obj argument to
|
||||
* NET_MemCacheConverter.
|
||||
*/
|
||||
typedef struct net_MemCacheConverterObject {
|
||||
NET_StreamClass *next_stream;
|
||||
PRBool dont_hold_URL_s;
|
||||
} net_MemCacheConverterObject;
|
||||
|
||||
extern NET_StreamClass *
|
||||
NET_MemCacheConverter (FO_Present_Types format_out,
|
||||
void *converter_obj,
|
||||
URL_Struct *URL_s,
|
||||
MWContext *window_id);
|
||||
|
||||
/* remove a URL from the memory cache
|
||||
*/
|
||||
extern void
|
||||
NET_RemoveURLFromMemCache(URL_Struct *URL_s);
|
||||
|
||||
/* set or unset a lock on a memory cache object
|
||||
*/
|
||||
extern void
|
||||
NET_ChangeMemCacheLock(URL_Struct *URL_s, PRBool set);
|
||||
|
||||
/* Create a wysiwyg cache converter to a copy of the current entry for URL_s.
|
||||
*/
|
||||
extern NET_StreamClass *
|
||||
net_CloneWysiwygMemCacheEntry(MWContext *window_id, URL_Struct *URL_s,
|
||||
uint32 nbytes, const char * wysiwyg_url,
|
||||
const char * base_href);
|
||||
/* return the first cache object in memory */
|
||||
extern net_CacheObject *
|
||||
NET_FirstMemCacheObject(XP_List* list_ptr);
|
||||
|
||||
/* return the next cache object in memory */
|
||||
extern net_CacheObject *
|
||||
NET_NextMemCacheObject(XP_List* list_ptr);
|
||||
|
||||
#endif /* MK_MEMORY_CACHE_H */
|
||||
89
mozilla/network/cache/netcache.h
vendored
Normal file
89
mozilla/network/cache/netcache.h
vendored
Normal file
@@ -0,0 +1,89 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef NETCACHE_H
|
||||
#define NETCACHE_H
|
||||
|
||||
#include "mkgeturl.h"
|
||||
|
||||
PR_BEGIN_EXTERN_C
|
||||
|
||||
extern void NET_CleanupCache (char * filename);
|
||||
extern int NET_FindURLInCache(URL_Struct * URL_s, MWContext *ctxt);
|
||||
extern void NET_RefreshCacheFileExpiration(URL_Struct * URL_s);
|
||||
|
||||
extern void NET_CacheInit(void);
|
||||
|
||||
extern void NET_InitMemCacProtocol(void);
|
||||
|
||||
|
||||
extern PRBool NET_IsCacheTraceOn(void);
|
||||
|
||||
/* remove a URL from the cache
|
||||
*/
|
||||
extern void NET_RemoveURLFromCache(URL_Struct *URL_s);
|
||||
|
||||
/* create an HTML stream and push a bunch of HTML about
|
||||
* the cache
|
||||
*/
|
||||
extern void NET_DisplayCacheInfoAsHTML(ActiveEntry * cur_entry);
|
||||
|
||||
/* return TRUE if the URL is in the cache and
|
||||
* is a partial cache file
|
||||
*/
|
||||
extern PRBool NET_IsPartialCacheFile(URL_Struct *URL_s);
|
||||
|
||||
/* encapsulated access to the first object in cache_database */
|
||||
extern int NET_FirstCacheObject(DBT *key, DBT *data);
|
||||
|
||||
/* encapsulated access to the next object in the cache_database */
|
||||
extern int NET_NextCacheObject(DBT *key, DBT *data);
|
||||
|
||||
/* Max size for displaying in the cache browser */
|
||||
extern int32 NET_GetMaxDiskCacheSize();
|
||||
|
||||
extern void
|
||||
NET_OpenExtCacheFAT(MWContext *ctxt, char * cache_name, char * instructions);
|
||||
|
||||
extern void
|
||||
CACHE_CloseAllOpenSARCache();
|
||||
|
||||
extern void
|
||||
CACHE_OpenAllSARCache();
|
||||
|
||||
/* create an HTML stream and push a bunch of HTML about
|
||||
* the memory cache
|
||||
*/
|
||||
extern void
|
||||
NET_DisplayMemCacheInfoAsHTML(ActiveEntry * cur_entry);
|
||||
|
||||
extern int
|
||||
NET_FindURLInMemCache(URL_Struct * URL_s, MWContext *ctxt);
|
||||
|
||||
/* lookup routine
|
||||
*
|
||||
* builds a key and looks for it in
|
||||
* the database. Returns an access
|
||||
* method and sets a filename in the
|
||||
* URL struct if found
|
||||
*/
|
||||
extern int NET_FindURLInExtCache(URL_Struct * URL_s, MWContext *ctxt);
|
||||
|
||||
PR_END_EXTERN_C
|
||||
|
||||
#endif /* NETCACHE_H */
|
||||
26
mozilla/network/cache/nu/Makefile
vendored
Normal file
26
mozilla/network/cache/nu/Makefile
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
|
||||
|
||||
DEPTH = ../../..
|
||||
|
||||
DIRS = public src
|
||||
|
||||
include $(DEPTH)/config/config.mk
|
||||
|
||||
include $(DEPTH)/config/rules.mk
|
||||
24
mozilla/network/cache/nu/include/Makefile
vendored
Normal file
24
mozilla/network/cache/nu/include/Makefile
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
|
||||
|
||||
DEPTH = ../../../..
|
||||
|
||||
MODULE = cache
|
||||
|
||||
include $(DEPTH)/config/rules.mk
|
||||
18
mozilla/network/cache/nu/include/makefile.win
vendored
Normal file
18
mozilla/network/cache/nu/include/makefile.win
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
!include $(MOZ_SRC)\ns\config\rules.mak
|
||||
62
mozilla/network/cache/nu/include/nsCacheTrace.h
vendored
Normal file
62
mozilla/network/cache/nu/include/nsCacheTrace.h
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
#ifndef _nsCacheTrace_H_
|
||||
#define _nsCacheTrace_H_
|
||||
/*
|
||||
* nsCacheTrace
|
||||
*
|
||||
* Gagan Saksena
|
||||
* 02/02/98
|
||||
*
|
||||
*/
|
||||
#ifndef CRLF
|
||||
# define CRLF "\r\n"
|
||||
#endif
|
||||
|
||||
#include <xp_core.h>
|
||||
#include <xp_str.h>
|
||||
|
||||
class nsCacheTrace
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
static void Trace(const char* msg);
|
||||
static void Traceln(const char* msg);
|
||||
static void Use(char* buffer);
|
||||
static char* m_TraceBuffer;
|
||||
private:
|
||||
nsCacheTrace();
|
||||
};
|
||||
|
||||
inline void nsCacheTrace::Trace(const char* msg)
|
||||
{
|
||||
printf(msg);
|
||||
}
|
||||
|
||||
inline void nsCacheTrace::Traceln(const char* msg)
|
||||
{
|
||||
Trace(msg);
|
||||
Trace(CRLF);
|
||||
}
|
||||
|
||||
inline void nsCacheTrace::Use(char* buffer)
|
||||
{
|
||||
m_TraceBuffer = buffer;
|
||||
}
|
||||
#endif
|
||||
25
mozilla/network/cache/nu/include/nsTimeIt.h
vendored
Normal file
25
mozilla/network/cache/nu/include/nsTimeIt.h
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
/* A class to time excursion events */
|
||||
/* declare an object of this class within the scope to be timed. */
|
||||
#include <prtypes.h>
|
||||
#include <prinrval.h>
|
||||
|
||||
class nsTimeIt
|
||||
{
|
||||
public:
|
||||
nsTimeIt(PRUint32& tmp);
|
||||
~nsTimeIt();
|
||||
private:
|
||||
PRIntervalTime t;
|
||||
PRUint32& dest;
|
||||
};
|
||||
|
||||
inline
|
||||
nsTimeIt::nsTimeIt(PRUint32& tmp):t(PR_IntervalNow()), dest(tmp)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
nsTimeIt::~nsTimeIt()
|
||||
{
|
||||
dest = PR_IntervalToMicroseconds(PR_IntervalNow()-t);
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
#!nmake
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
@@ -14,36 +14,9 @@
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
DEPTH=..\..
|
||||
|
||||
MAKE_OBJ_TYPE = EXE
|
||||
PROGRAM = .\$(OBJDIR)\xpinstall.exe
|
||||
DEPTH=..\..\..
|
||||
|
||||
OBJS = \
|
||||
.\$(OBJDIR)\standalone.obj \
|
||||
.\$(OBJDIR)\nsSimpleConsoleProgressNotifier.obj \
|
||||
$(NULL)
|
||||
|
||||
LLIBS = \
|
||||
$(DIST)\lib\xpinstall.lib \
|
||||
$(DIST)\lib\raptorbase.lib \
|
||||
$(DIST)\lib\xpcom32.lib \
|
||||
$(LIBNSPR) \
|
||||
$(NULL)
|
||||
|
||||
LINCS = \
|
||||
-I$(PUBLIC)\xpcom \
|
||||
-I$(PUBLIC)\xpinstall \
|
||||
-I$(PUBLIC)\raptor \
|
||||
$(NULL)
|
||||
DIRS=public src
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
||||
export:: $(PROGRAM)
|
||||
$(MAKE_INSTALL) $(PROGRAM) $(DIST)\bin
|
||||
|
||||
clobber::
|
||||
rm -f $(DIST)\bin\xpinstall.exe
|
||||
|
||||
$(PROGRAM):: $(OBJS) $(LLIBS)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
@@ -16,15 +16,34 @@
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
#include "nsGeneric.h"
|
||||
|
||||
[uuid(eea90d40-b059-11d2-915e-c12b696c9333)]
|
||||
interface nsIXPInstallProgress : nsISupports
|
||||
nsGeneric::nsGeneric()
|
||||
{
|
||||
void BeforeJavascriptEvaluation();
|
||||
void AfterJavascriptEvaluation();
|
||||
void InstallStarted([const] in string UIPackageName);
|
||||
void ItemScheduled([const] in string message );
|
||||
void InstallFinalization([const] in string message, in long itemNum, in long totNum );
|
||||
void InstallAborted();
|
||||
};
|
||||
}
|
||||
|
||||
nsGeneric::~nsGeneric()
|
||||
{
|
||||
}
|
||||
|
||||
nsrefcnt nsGeneric::AddRef(void)
|
||||
{
|
||||
return ++m_RefCnt;
|
||||
}
|
||||
nsrefcnt nsGeneric::Release(void)
|
||||
{
|
||||
if (--m_RefCnt == 0)
|
||||
{
|
||||
delete this;
|
||||
return 0;
|
||||
}
|
||||
return m_RefCnt;
|
||||
}
|
||||
|
||||
nsresult nsGeneric::QueryInterface(const nsIID& aIID,
|
||||
void** aInstancePtrResult)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsGeneric::
|
||||
44
mozilla/network/cache/nu/nsGeneric.h
vendored
Normal file
44
mozilla/network/cache/nu/nsGeneric.h
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef nsGeneric_h__
|
||||
#define nsGeneric_h__
|
||||
|
||||
#include "nsISupports.h"
|
||||
|
||||
class nsGeneric: public nsISupports
|
||||
{
|
||||
|
||||
public:
|
||||
nsGeneric();
|
||||
virtual ~nsGeneric();
|
||||
|
||||
NS_IMETHOD QueryInterface(const nsIID& aIID,
|
||||
void** aInstancePtr);
|
||||
NS_IMETHOD_(nsrefcnt) AddRef(void);
|
||||
NS_IMETHOD_(nsrefcnt) Release(void);
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
nsGeneric(const nsGeneric& o);
|
||||
nsGeneric& operator=(const nsGeneric& o);
|
||||
};
|
||||
|
||||
#endif // nsGeneric_h__
|
||||
|
||||
34
mozilla/network/cache/nu/public/Makefile
vendored
Normal file
34
mozilla/network/cache/nu/public/Makefile
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH=../../../..
|
||||
|
||||
EXPORTS = \
|
||||
nsMemModule.h \
|
||||
nsCacheManager.h \
|
||||
nsDiskModule.h \
|
||||
nsCacheModule.h \
|
||||
nsMemCacheObject.h \
|
||||
nsCacheObject.h \
|
||||
nsCachePref.h \
|
||||
$(NULL)
|
||||
|
||||
MODULE = cache
|
||||
|
||||
include $(DEPTH)/config/config.mk
|
||||
|
||||
include $(DEPTH)/config/rules.mk
|
||||
@@ -15,17 +15,15 @@
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH=..\..
|
||||
DEPTH=..\..\..\..
|
||||
IGNORE_MANIFEST=1
|
||||
|
||||
MODULE=cache
|
||||
|
||||
EXPORTS=nsCacheObject.h nsMemModule.h nsCacheManager.h \
|
||||
nsDiskModule.h nsCacheModule.h nsMemCacheObject.h \
|
||||
nsCachePref.h \
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
||||
install:: $(DLL)
|
||||
$(MAKE_INSTALL) progress.xul $(DIST)\bin\res\xpinstall
|
||||
$(MAKE_INSTALL) progress.css $(DIST)\bin\res\xpinstall
|
||||
$(MAKE_INSTALL) progress.html $(DIST)\bin\res\xpinstall
|
||||
|
||||
clobber::
|
||||
rm -f $(DIST)\res\xpinstall\progress.xul
|
||||
rm -f $(DIST)\res\xpinstall\progress.css
|
||||
rm -f $(DIST)\res\xpinstall\progress.html
|
||||
86
mozilla/network/cache/nu/public/nsCacheManager.h
vendored
Normal file
86
mozilla/network/cache/nu/public/nsCacheManager.h
vendored
Normal file
@@ -0,0 +1,86 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef _CacheManager_H_
|
||||
#define _CacheManager_H_
|
||||
/*
|
||||
* nsCacheManager
|
||||
*
|
||||
* Gagan Saksena 02/02/98
|
||||
*
|
||||
*/
|
||||
|
||||
#if 0
|
||||
#include "nsISupports.h"
|
||||
#endif
|
||||
|
||||
#include "nsCacheModule.h"
|
||||
#include "nsCacheObject.h"
|
||||
|
||||
class nsMemModule;
|
||||
class nsDiskModule;
|
||||
class nsCachePref;
|
||||
|
||||
class nsCacheManager //: public nsISupports
|
||||
{
|
||||
/* Change entries from 32 to 16 bit */
|
||||
public:
|
||||
enum modules
|
||||
{
|
||||
MEM =0,
|
||||
DISK=1
|
||||
};
|
||||
|
||||
nsCacheManager();
|
||||
~nsCacheManager();
|
||||
|
||||
PRInt32 AddModule(nsCacheModule* i_cacheModule);
|
||||
|
||||
PRBool Contains(const char* i_url) const;
|
||||
|
||||
/* Number of modules in the cache manager */
|
||||
PRInt32 Entries() const;
|
||||
|
||||
/* Singleton */
|
||||
static nsCacheManager*
|
||||
GetInstance();
|
||||
|
||||
nsCacheObject* GetObject(const char* i_url) const;
|
||||
nsCacheModule* GetModule(PRInt32 i_index) const;
|
||||
|
||||
nsMemModule* GetMemModule() const;
|
||||
nsDiskModule* GetDiskModule() const;
|
||||
|
||||
const char* Trace() const;
|
||||
|
||||
/* Performance measure- microseconds */
|
||||
PRUint32 WorstCaseTime(void) const;
|
||||
|
||||
protected:
|
||||
void Init();
|
||||
nsCacheModule*
|
||||
LastModule() const;
|
||||
|
||||
private:
|
||||
nsCacheModule* m_pFirstModule;
|
||||
|
||||
nsCacheManager(const nsCacheManager& cm);
|
||||
nsCacheManager& operator=(const nsCacheManager& cm);
|
||||
};
|
||||
|
||||
#endif
|
||||
130
mozilla/network/cache/nu/public/nsCacheModule.h
vendored
Normal file
130
mozilla/network/cache/nu/public/nsCacheModule.h
vendored
Normal file
@@ -0,0 +1,130 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef nsCacheModule_h__
|
||||
#define nsCacheModule_h__
|
||||
|
||||
/*
|
||||
* nsCacheModule
|
||||
*
|
||||
* Gagan Saksena 02/03/98
|
||||
*
|
||||
*/
|
||||
//#include <nsISupports.h>
|
||||
#include "nsCacheObject.h"
|
||||
|
||||
/* Why the hell is forward decl. not working? */
|
||||
//class nsCacheObject;
|
||||
|
||||
/*
|
||||
// {5D51B24F-E6C2-11d1-AFE5-006097BFC036}
|
||||
static const NS_CACHEMODULE_ID =
|
||||
{ 0x5d51b24f, 0xe6c2, 0x11d1, { 0xaf, 0xe5, 0x0, 0x60, 0x97, 0xbf, 0xc0, 0x36 } };
|
||||
*/
|
||||
|
||||
class nsCacheModule /*: public nsISupports */
|
||||
{
|
||||
|
||||
public:
|
||||
nsCacheModule(const PRUint32 i_size /*= DEFAULT_SIZE */);
|
||||
|
||||
virtual
|
||||
~nsCacheModule();
|
||||
|
||||
virtual
|
||||
PRBool AddObject(nsCacheObject* i_pObject)=0;
|
||||
virtual
|
||||
PRBool Contains(const char* i_url) const=0;
|
||||
virtual
|
||||
PRBool Contains(nsCacheObject* i_pObject) const=0;
|
||||
void Enable(PRBool i_Enable);
|
||||
const PRUint32 Entries() const;
|
||||
|
||||
nsCacheObject* GetFirstObject() const ;//TODO-?/
|
||||
|
||||
virtual
|
||||
nsCacheObject* GetObject(const char* i_url) const=0;
|
||||
|
||||
virtual
|
||||
nsCacheObject* GetObject(const PRUint32 i_index) const =0;
|
||||
|
||||
PRBool IsEnabled() const;
|
||||
|
||||
nsCacheModule* Next() const;
|
||||
void Next(nsCacheModule*);
|
||||
|
||||
const PRUint32 Size() const;
|
||||
void Size(const PRUint32 i_size);
|
||||
|
||||
const char* Trace() const;
|
||||
|
||||
protected:
|
||||
|
||||
PRUint32 m_Entries;
|
||||
PRUint32 m_Size;
|
||||
PRBool m_Enabled;
|
||||
|
||||
nsCacheModule* m_pNext;
|
||||
|
||||
private:
|
||||
nsCacheModule(const nsCacheModule& cm);
|
||||
nsCacheModule& operator=(const nsCacheModule& cm);
|
||||
|
||||
};
|
||||
|
||||
inline void nsCacheModule::Enable(PRBool i_Enable)
|
||||
{
|
||||
m_Enabled = i_Enable;
|
||||
}
|
||||
|
||||
inline PRBool nsCacheModule::IsEnabled() const
|
||||
{
|
||||
return m_Enabled;
|
||||
}
|
||||
|
||||
inline const PRUint32 nsCacheModule::Entries() const
|
||||
{
|
||||
return m_Entries;
|
||||
}
|
||||
|
||||
inline nsCacheObject* nsCacheModule::GetFirstObject() const
|
||||
{
|
||||
return this->GetObject((PRUint32)0);
|
||||
}
|
||||
|
||||
inline nsCacheModule* nsCacheModule::Next() const
|
||||
{
|
||||
return m_pNext;
|
||||
}
|
||||
|
||||
inline void nsCacheModule::Next(nsCacheModule* pNext)
|
||||
{
|
||||
m_pNext = pNext;
|
||||
}
|
||||
|
||||
inline const PRUint32 nsCacheModule::Size() const
|
||||
{
|
||||
return m_Size;
|
||||
}
|
||||
|
||||
inline void nsCacheModule::Size(const PRUint32 size)
|
||||
{
|
||||
m_Size = size;
|
||||
}
|
||||
|
||||
#endif // nsCacheModule_h__
|
||||
189
mozilla/network/cache/nu/public/nsCacheObject.h
vendored
Normal file
189
mozilla/network/cache/nu/public/nsCacheObject.h
vendored
Normal file
@@ -0,0 +1,189 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef nsCacheObject_h__
|
||||
#define nsCacheObject_h__
|
||||
|
||||
#if 0
|
||||
#include "nsISupports.h"
|
||||
#endif
|
||||
|
||||
#include <prtypes.h>
|
||||
#include <prinrval.h>
|
||||
|
||||
static const PRUint32 kCACHE_VERSION = 5;
|
||||
|
||||
class nsCacheObject //: public nsISupports
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
enum state_flags
|
||||
{
|
||||
INIT=0x000000,
|
||||
PARTIAL=0x000001
|
||||
};
|
||||
|
||||
nsCacheObject();
|
||||
nsCacheObject(const nsCacheObject& another);
|
||||
nsCacheObject(const char* i_url);
|
||||
|
||||
virtual ~nsCacheObject();
|
||||
|
||||
/*
|
||||
NS_IMETHOD QueryInterface(const nsIID& aIID,
|
||||
void** aInstancePtr);
|
||||
NS_IMETHOD_(nsrefcnt) AddRef(void);
|
||||
NS_IMETHOD_(nsrefcnt) Release(void);
|
||||
|
||||
*/
|
||||
|
||||
void Address(const char* i_url);
|
||||
const char* Address(void) const;
|
||||
|
||||
void Etag(const char* i_etag);
|
||||
const char* Etag(void) const;
|
||||
|
||||
PRIntervalTime
|
||||
Expires(void) const;
|
||||
void Expires(PRIntervalTime i_Expires);
|
||||
|
||||
PRUint16 Hits(void) const;
|
||||
|
||||
/* Read and write info about this cache object */
|
||||
void* Info(void) const;
|
||||
PRBool Info(void*);
|
||||
PRUint32 InfoSize(void) const;
|
||||
|
||||
PRBool IsExpired(void) const;
|
||||
PRBool IsPartial(void) const;
|
||||
PRIntervalTime
|
||||
LastAccessed(void) const;
|
||||
|
||||
PRIntervalTime
|
||||
LastModified(void) const;
|
||||
void LastModified(PRIntervalTime i_lastModified);
|
||||
|
||||
PRInt16 Module(void) const;
|
||||
void Module(PRUint16 i_m);
|
||||
|
||||
PRUint32 Size(void) const;
|
||||
void Size(PRUint32 s);
|
||||
|
||||
const char*
|
||||
Trace() const;
|
||||
|
||||
// virtual void getReadStream();
|
||||
// virtual void getWriteStream();
|
||||
|
||||
protected:
|
||||
|
||||
void Init();
|
||||
|
||||
char* m_Etag;
|
||||
PRIntervalTime
|
||||
m_Expires;
|
||||
int m_Flags;
|
||||
PRUint16 m_Hits;
|
||||
PRIntervalTime
|
||||
m_LastAccessed, m_LastModified;
|
||||
PRUint32 m_Size;
|
||||
char* m_Url;
|
||||
|
||||
PRInt16 m_Module;
|
||||
|
||||
void* m_pInfo;
|
||||
PRUint32 m_info_size;
|
||||
|
||||
private:
|
||||
nsCacheObject& operator=(const nsCacheObject& x);
|
||||
};
|
||||
|
||||
inline const char* nsCacheObject::Address(void) const
|
||||
{
|
||||
return m_Url;
|
||||
};
|
||||
|
||||
inline const char* nsCacheObject::Etag(void) const
|
||||
{
|
||||
return m_Etag;
|
||||
};
|
||||
|
||||
inline PRIntervalTime nsCacheObject::Expires(void) const
|
||||
{
|
||||
return m_Expires;
|
||||
};
|
||||
|
||||
inline void nsCacheObject::Expires(PRIntervalTime i_Expires)
|
||||
{
|
||||
m_Expires = i_Expires;
|
||||
};
|
||||
|
||||
inline PRUint16 nsCacheObject::Hits(void) const
|
||||
{
|
||||
return m_Hits;
|
||||
};
|
||||
|
||||
inline PRBool nsCacheObject::IsExpired(void) const
|
||||
{
|
||||
PRIntervalTime now = PR_IntervalNow();
|
||||
return (m_Expires <= now);
|
||||
};
|
||||
|
||||
inline PRBool nsCacheObject::IsPartial(void) const
|
||||
{
|
||||
return (m_Flags & nsCacheObject::PARTIAL);
|
||||
};
|
||||
|
||||
inline PRIntervalTime nsCacheObject::LastAccessed(void) const
|
||||
{
|
||||
return m_LastAccessed;
|
||||
};
|
||||
|
||||
inline PRIntervalTime nsCacheObject::LastModified(void) const
|
||||
{
|
||||
return m_LastModified;
|
||||
};
|
||||
|
||||
inline void nsCacheObject::LastModified(PRIntervalTime i_LastModified)
|
||||
{
|
||||
m_LastModified = i_LastModified;
|
||||
};
|
||||
|
||||
inline PRInt16 nsCacheObject::Module(void) const
|
||||
{
|
||||
return m_Module;
|
||||
};
|
||||
|
||||
inline void nsCacheObject::Module(PRUint16 i_Module)
|
||||
{
|
||||
m_Module = i_Module;
|
||||
};
|
||||
|
||||
inline PRUint32 nsCacheObject::Size(void) const
|
||||
{
|
||||
return m_Size;
|
||||
};
|
||||
|
||||
inline void nsCacheObject::Size(PRUint32 i_Size)
|
||||
{
|
||||
m_Size = i_Size;
|
||||
};
|
||||
|
||||
#endif // nsCacheObject_h__
|
||||
|
||||
64
mozilla/network/cache/nu/public/nsCachePref.h
vendored
Normal file
64
mozilla/network/cache/nu/public/nsCachePref.h
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef nsCachePref_h__
|
||||
#define nsCachePref_h__
|
||||
|
||||
//#include "nsISupports.h"
|
||||
#include <prtypes.h>
|
||||
|
||||
class nsCachePref //: public nsISupports
|
||||
{
|
||||
|
||||
public:
|
||||
static nsCachePref* GetInstance(void);
|
||||
|
||||
// should really be protected/private
|
||||
nsCachePref(void);
|
||||
~nsCachePref();
|
||||
|
||||
enum Refresh
|
||||
{
|
||||
NEVER,
|
||||
ONCE,
|
||||
ALWAYS
|
||||
} r;
|
||||
|
||||
static const char* DiskCacheDBFilename(void); /* like Fat.db */
|
||||
static const char* DiskCacheFolder(void); /* Cache dir */
|
||||
|
||||
static PRUint32 DiskCacheSize(void);
|
||||
static PRUint32 MemCacheSize(void);
|
||||
|
||||
static nsCachePref::Refresh
|
||||
Frequency(void);
|
||||
|
||||
/*
|
||||
NS_IMETHOD QueryInterface(const nsIID& aIID,
|
||||
void** aInstancePtr);
|
||||
NS_IMETHOD_(nsrefcnt) AddRef(void);
|
||||
NS_IMETHOD_(nsrefcnt) Release(void);
|
||||
*/
|
||||
private:
|
||||
nsCachePref(const nsCachePref& o);
|
||||
nsCachePref& operator=(const nsCachePref& o);
|
||||
static nsCachePref* m_pPref;
|
||||
};
|
||||
|
||||
#endif // nsCachePref_h__
|
||||
|
||||
61
mozilla/network/cache/nu/public/nsDiskModule.h
vendored
Normal file
61
mozilla/network/cache/nu/public/nsDiskModule.h
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef _nsDiskModule_H_
|
||||
#define _nsDiskModule_H_
|
||||
/*
|
||||
* nsDiskModule
|
||||
*
|
||||
* Gagan Saksena 02/03/98
|
||||
*
|
||||
*/
|
||||
#include "nsCacheModule.h"
|
||||
#include "nsCachePref.h"
|
||||
#include "mcom_db.h"
|
||||
|
||||
class nsDiskModule : public nsCacheModule
|
||||
{
|
||||
|
||||
public:
|
||||
nsDiskModule(const PRUint32 size = nsCachePref::DiskCacheSize());
|
||||
~nsDiskModule();
|
||||
|
||||
// Cache module interface
|
||||
PRBool AddObject(nsCacheObject* io_pObject);
|
||||
PRBool Contains(nsCacheObject* io_pObject) const;
|
||||
PRBool Contains(const char* i_url) const;
|
||||
nsCacheObject* GetObject(const PRUint32 i_index) const;
|
||||
nsCacheObject* GetObject(const char* i_url) const;
|
||||
|
||||
private:
|
||||
enum sync_frequency
|
||||
{
|
||||
EVERYTIME,
|
||||
IDLE,
|
||||
NEVER
|
||||
} m_Sync;
|
||||
|
||||
PRBool InitDB(void);
|
||||
|
||||
nsDiskModule(const nsDiskModule& dm);
|
||||
nsDiskModule& operator=(const nsDiskModule& dm);
|
||||
|
||||
DB* m_pDB;
|
||||
};
|
||||
|
||||
#endif
|
||||
101
mozilla/network/cache/nu/public/nsMemCacheObject.h
vendored
Normal file
101
mozilla/network/cache/nu/public/nsMemCacheObject.h
vendored
Normal file
@@ -0,0 +1,101 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef _nsMemCacheObject_h_
|
||||
#define _nsMemCacheObject_h_
|
||||
|
||||
#include <prtypes.h>
|
||||
|
||||
#include "nsCacheObject.h"
|
||||
|
||||
class nsMemCacheObject
|
||||
{
|
||||
public:
|
||||
|
||||
nsMemCacheObject(void);
|
||||
nsMemCacheObject(nsCacheObject* io_pObject);
|
||||
nsMemCacheObject(const char* i_url);
|
||||
~nsMemCacheObject();
|
||||
|
||||
void* Data(void) const;
|
||||
|
||||
void Next(nsMemCacheObject* pObject);
|
||||
void Next(nsCacheObject* io_pObject);
|
||||
|
||||
nsMemCacheObject* Next(void) const;
|
||||
|
||||
nsCacheObject* ThisObject(void) const;
|
||||
|
||||
private:
|
||||
nsMemCacheObject* m_pNextObject;
|
||||
nsCacheObject* m_pObject;
|
||||
void* m_pData;
|
||||
|
||||
nsMemCacheObject& operator=(const nsMemCacheObject& mco);
|
||||
nsMemCacheObject(const nsMemCacheObject&);
|
||||
|
||||
};
|
||||
|
||||
inline nsMemCacheObject::nsMemCacheObject(void):
|
||||
m_pObject(new nsCacheObject()),
|
||||
m_pNextObject(0),
|
||||
m_pData(0)
|
||||
{
|
||||
}
|
||||
|
||||
inline nsMemCacheObject::nsMemCacheObject(nsCacheObject* io_pObject):
|
||||
m_pObject(io_pObject),
|
||||
m_pNextObject(0),
|
||||
m_pData(0)
|
||||
{
|
||||
}
|
||||
|
||||
inline nsMemCacheObject::nsMemCacheObject(const char* i_url):
|
||||
m_pObject(new nsCacheObject(i_url)),
|
||||
m_pNextObject(0),
|
||||
m_pData(0)
|
||||
{
|
||||
}
|
||||
|
||||
inline void* nsMemCacheObject::Data(void) const
|
||||
{
|
||||
// PR_ASSERT(m_pData);
|
||||
return m_pData;
|
||||
}
|
||||
|
||||
inline nsMemCacheObject* nsMemCacheObject::Next(void) const
|
||||
{
|
||||
return m_pNextObject;
|
||||
}
|
||||
|
||||
inline void nsMemCacheObject::Next(nsMemCacheObject* pObject)
|
||||
{
|
||||
m_pNextObject = pObject;
|
||||
}
|
||||
|
||||
inline void nsMemCacheObject::Next(nsCacheObject* pObject)
|
||||
{
|
||||
m_pNextObject = new nsMemCacheObject(pObject);
|
||||
}
|
||||
|
||||
inline nsCacheObject* nsMemCacheObject::ThisObject(void) const
|
||||
{
|
||||
return m_pObject;
|
||||
}
|
||||
|
||||
#endif //_nsMemCacheObject_h_
|
||||
89
mozilla/network/cache/nu/public/nsMemModule.h
vendored
Normal file
89
mozilla/network/cache/nu/public/nsMemModule.h
vendored
Normal file
@@ -0,0 +1,89 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
#ifndef _nsMemModule_H_
|
||||
#define _nsMemModule_H_
|
||||
/*
|
||||
* nsMemModule
|
||||
*
|
||||
* Gagan Saksena
|
||||
* 02/03/98
|
||||
*
|
||||
*/
|
||||
|
||||
#include "nsCacheModule.h"
|
||||
#include "nsMemCacheObject.h"
|
||||
#include "nsCachePref.h"
|
||||
|
||||
//#include "nsHash.h" // TODO - replace with nsHashtable when the XPCOM_BRANCH merges
|
||||
|
||||
//#include <nsHashtable.h>
|
||||
/*
|
||||
// {5D51B250-E6C2-11d1-AFE5-006097BFC036}
|
||||
static const NS_MEMMODULE_IID =
|
||||
{ 0x5d51b250, 0xe6c2, 0x11d1, { 0xaf, 0xe5, 0x0, 0x60, 0x97, 0xbf, 0xc0, 0x36 } };
|
||||
*/
|
||||
|
||||
class nsMemModule : public nsCacheModule
|
||||
{
|
||||
|
||||
public:
|
||||
nsMemModule(const PRUint32 size=nsCachePref::MemCacheSize());
|
||||
~nsMemModule();
|
||||
|
||||
/*
|
||||
NS_IMETHOD QueryInterface(const nsIID& aIID,
|
||||
void** aInstancePtr);
|
||||
NS_IMETHOD_(nsrefcnt) AddRef(void);
|
||||
NS_IMETHOD_(nsrefcnt) Release(void);
|
||||
|
||||
*/
|
||||
PRBool AddObject(nsCacheObject* io_pObject);
|
||||
PRBool Contains(nsCacheObject* io_pObject) const;
|
||||
PRBool Contains(const char* i_url) const;
|
||||
nsCacheObject* GetObject(const PRUint32 i_index) const;
|
||||
nsCacheObject* GetObject(const char* i_url) const;
|
||||
|
||||
// Start of nsMemModule specific stuff...
|
||||
// Here is a sample implementation using linked list
|
||||
protected:
|
||||
nsMemCacheObject* LastObject(void) const;
|
||||
|
||||
private:
|
||||
nsMemCacheObject* m_pFirstObject;
|
||||
|
||||
//nsHash m_ht; //TODO replace with nsHashtable
|
||||
//Optimization
|
||||
nsMemCacheObject* m_pLastObject;
|
||||
|
||||
nsMemModule(const nsMemModule& mm);
|
||||
nsMemModule& operator=(const nsMemModule& mm);
|
||||
|
||||
/*
|
||||
class nsMemKey : public nsHashKey
|
||||
{
|
||||
public:
|
||||
nsMemKey();
|
||||
~nsMemKey();
|
||||
PRUint32 HashValue();
|
||||
PRBool Equals(nsHashKey *aKey);
|
||||
nsHashKey* Clone();
|
||||
};
|
||||
*/
|
||||
};
|
||||
|
||||
#endif
|
||||
53
mozilla/network/cache/nu/src/Makefile
vendored
Normal file
53
mozilla/network/cache/nu/src/Makefile
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH=../../../..
|
||||
|
||||
TARGET = $(LIBRARY)
|
||||
|
||||
LIBRARY_NAME=cachelib
|
||||
|
||||
MISCDEP = \
|
||||
$(LIBNSPR) \
|
||||
$(DIST)/lib/xpcom32.lib \
|
||||
$(NULL)
|
||||
|
||||
MODULE = cache
|
||||
|
||||
CPPSRCS = nsCacheObject.cpp \
|
||||
nsCacheModule.cpp \
|
||||
nsCacheManager.cpp \
|
||||
nsMemModule.cpp \
|
||||
nsDiskModule.cpp \
|
||||
nsCacheTrace.cpp \
|
||||
nsCachePref.cpp \
|
||||
nsMemCacheObject.cpp \
|
||||
$(NULL)
|
||||
|
||||
REQUIRES = dbm nspr pref xpcom
|
||||
|
||||
LLIBS = \
|
||||
$(DIST)/lib/xpcom32.lib \
|
||||
$(LIBNSPR) \
|
||||
$(NULL)
|
||||
|
||||
include $(DEPTH)/config/rules.mk
|
||||
|
||||
INCLUDES += -I../include \
|
||||
-I../public \
|
||||
$(NULL)
|
||||
|
||||
73
mozilla/network/cache/nu/src/makefile.win
vendored
Normal file
73
mozilla/network/cache/nu/src/makefile.win
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
IGNORE_MANIFEST = 1
|
||||
|
||||
DEPTH=..\..\..\..
|
||||
|
||||
MAKE_OBJ_TYPE = EXE
|
||||
DLLNAME = cachelib
|
||||
#DLL = .\$(OBJDIR)\$(DLLNAME).dll
|
||||
|
||||
LIBRARY_NAME=cachelib
|
||||
|
||||
# Remember to change libplc21 to $whatever it is...
|
||||
LLIBS = \
|
||||
$(LIBNSPR) \
|
||||
$(DIST)\lib\libplc21.lib \
|
||||
$(DIST)\lib\dbm32.lib \
|
||||
$(DIST)\lib\xpcom32.lib \
|
||||
$(NULL)
|
||||
|
||||
MISCDEP = $(LLIBS)
|
||||
|
||||
MODULE = cache
|
||||
|
||||
OBJS = \
|
||||
.\$(OBJDIR)\nsCacheObject.obj \
|
||||
.\$(OBJDIR)\nsCacheModule.obj \
|
||||
.\$(OBJDIR)\nsMemModule.obj \
|
||||
.\$(OBJDIR)\nsDiskModule.obj \
|
||||
.\$(OBJDIR)\nsCacheTrace.obj \
|
||||
.\$(OBJDIR)\nsCacheManager.obj \
|
||||
.\$(OBJDIR)\nsCachePref.obj \
|
||||
.\$(OBJDIR)\nsMemCacheObject.obj \
|
||||
$(NULL)
|
||||
|
||||
# .\$(OBJDIR)\nsHash.obj \
|
||||
|
||||
LINCS = \
|
||||
-I$(PUBLIC)\xpcom \
|
||||
-I$(PUBLIC)\dbm \
|
||||
-I..\public \
|
||||
-I..\include \
|
||||
$(NULL)
|
||||
|
||||
LCFLAGS = \
|
||||
$(LCFLAGS) \
|
||||
$(NULL)
|
||||
#-DNS_DLLNAME=$(DLLNAME).dll \
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
||||
install:: $(EXE)
|
||||
$(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).$(LIB_SUFFIX) $(DIST)\lib
|
||||
# $(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).$(DLL_SUFFIX) $(DIST)\bin
|
||||
|
||||
clobber::
|
||||
rm -f $(DIST)\lib\$(DLLNAME).$(LIB_SUFFIX)
|
||||
|
||||
196
mozilla/network/cache/nu/src/nsCacheManager.cpp
vendored
Normal file
196
mozilla/network/cache/nu/src/nsCacheManager.cpp
vendored
Normal file
@@ -0,0 +1,196 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Gagan Saksena 02/02/98
|
||||
*
|
||||
*/
|
||||
|
||||
#include <prtypes.h>
|
||||
#include <prinrval.h>
|
||||
|
||||
#include <xp_core.h>
|
||||
#include <xpassert.h>
|
||||
#include <xp_str.h>
|
||||
|
||||
#include "nsCacheManager.h"
|
||||
#include "nsCacheTrace.h"
|
||||
#include "nsCachePref.h"
|
||||
#include "nsCacheModule.h"
|
||||
#include "nsMemModule.h"
|
||||
#include "nsDiskModule.h"
|
||||
|
||||
static nsCacheManager TheManager;
|
||||
|
||||
nsCacheManager::nsCacheManager(): m_pFirstModule(0)
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
nsCacheManager::~nsCacheManager()
|
||||
{
|
||||
if (m_pFirstModule)
|
||||
delete m_pFirstModule;
|
||||
}
|
||||
|
||||
nsCacheManager*
|
||||
nsCacheManager::GetInstance()
|
||||
{
|
||||
return &TheManager;
|
||||
}
|
||||
|
||||
/* Caller must free returned char* */
|
||||
const char*
|
||||
nsCacheManager::Trace() const
|
||||
{
|
||||
|
||||
char linebuffer[128];
|
||||
char* total;
|
||||
|
||||
sprintf(linebuffer, "nsCacheManager: Modules = %d\n", Entries());
|
||||
|
||||
total = new char[strlen(linebuffer) + 1];
|
||||
strcpy(total, linebuffer);
|
||||
return total;
|
||||
}
|
||||
|
||||
PRInt32
|
||||
nsCacheManager::AddModule(nsCacheModule* pModule)
|
||||
{
|
||||
if (pModule)
|
||||
{
|
||||
if (m_pFirstModule)
|
||||
LastModule()->Next(pModule);
|
||||
else
|
||||
m_pFirstModule = pModule;
|
||||
|
||||
return Entries()-1;
|
||||
}
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsCacheManager::Contains(const char* i_url) const
|
||||
{
|
||||
if (m_pFirstModule)
|
||||
{
|
||||
nsCacheModule* pModule = m_pFirstModule;
|
||||
while (pModule)
|
||||
{
|
||||
if (pModule->Contains(i_url))
|
||||
{
|
||||
return PR_TRUE;
|
||||
}
|
||||
pModule = pModule->Next();
|
||||
}
|
||||
}
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
nsCacheObject*
|
||||
nsCacheManager::GetObject(const char* i_url) const
|
||||
{
|
||||
if (m_pFirstModule)
|
||||
{
|
||||
nsCacheModule* pModule = m_pFirstModule;
|
||||
nsCacheObject* obj = 0;
|
||||
while (pModule)
|
||||
{
|
||||
obj = pModule->GetObject(i_url);
|
||||
if (obj)
|
||||
return obj;
|
||||
pModule = pModule->Next();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
PRInt32
|
||||
nsCacheManager::Entries() const
|
||||
{
|
||||
if (m_pFirstModule)
|
||||
{
|
||||
PRInt32 count=1;
|
||||
nsCacheModule* pModule = m_pFirstModule;
|
||||
while (pModule = pModule->Next())
|
||||
{
|
||||
count++;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
nsCacheModule*
|
||||
nsCacheManager::GetModule(PRInt32 i_index) const
|
||||
{
|
||||
if ((i_index < 0) || (i_index >= Entries()))
|
||||
return 0;
|
||||
nsCacheModule* pModule = m_pFirstModule;
|
||||
for (PRInt32 i=0; i<=i_index; pModule = pModule->Next())
|
||||
i++;
|
||||
PR_ASSERT(pModule);
|
||||
return pModule;
|
||||
}
|
||||
|
||||
nsMemModule*
|
||||
nsCacheManager::GetMemModule() const
|
||||
{
|
||||
return (nsMemModule*) m_pFirstModule;
|
||||
}
|
||||
|
||||
nsDiskModule*
|
||||
nsCacheManager::GetDiskModule() const
|
||||
{
|
||||
return (m_pFirstModule) ? (nsDiskModule*) m_pFirstModule->Next() : NULL;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
nsCacheManager::Init()
|
||||
{
|
||||
if (m_pFirstModule)
|
||||
delete m_pFirstModule;
|
||||
|
||||
m_pFirstModule = new nsMemModule(nsCachePref::MemCacheSize());
|
||||
// m_pFirstModule->Next((new nsDiskModule(nsCachePref::DiskCacheSize()));
|
||||
|
||||
}
|
||||
|
||||
nsCacheModule*
|
||||
nsCacheManager::LastModule() const
|
||||
{
|
||||
if (m_pFirstModule)
|
||||
{
|
||||
nsCacheModule* pModule = m_pFirstModule;
|
||||
while(pModule->Next()) {
|
||||
pModule = pModule->Next();
|
||||
}
|
||||
return pModule;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
PRUint32
|
||||
nsCacheManager::WorstCaseTime(void) const
|
||||
{
|
||||
PRIntervalTime start = PR_IntervalNow();
|
||||
while (this->Contains("a vague string that should not be in any of the modules"));
|
||||
return PR_IntervalToMicroseconds(PR_IntervalNow() - start);
|
||||
}
|
||||
63
mozilla/network/cache/nu/src/nsCacheModule.cpp
vendored
Normal file
63
mozilla/network/cache/nu/src/nsCacheModule.cpp
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include <xp_core.h>
|
||||
#include <xp_str.h>
|
||||
|
||||
#include "nsCacheModule.h"
|
||||
#include "nsCacheTrace.h"
|
||||
|
||||
|
||||
/*
|
||||
* nsCacheModule
|
||||
*
|
||||
* Gagan Saksena 02/02/98
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#define DEFAULT_SIZE 10*0x100000L
|
||||
|
||||
nsCacheModule::nsCacheModule(const PRUint32 i_size=DEFAULT_SIZE):
|
||||
m_Size(i_size),
|
||||
m_pNext(0),
|
||||
m_Entries(0)
|
||||
{
|
||||
}
|
||||
|
||||
nsCacheModule::~nsCacheModule()
|
||||
{
|
||||
if (m_pNext)
|
||||
{
|
||||
delete m_pNext;
|
||||
m_pNext = 0;
|
||||
}
|
||||
}
|
||||
|
||||
const char* nsCacheModule::Trace() const
|
||||
{
|
||||
char linebuffer[128];
|
||||
char* total;
|
||||
|
||||
sprintf(linebuffer, "nsCacheModule: Objects = %d\n", Entries());
|
||||
|
||||
total = new char[strlen(linebuffer) + 1];
|
||||
strcpy(total, linebuffer);
|
||||
|
||||
return total;
|
||||
}
|
||||
355
mozilla/network/cache/nu/src/nsCacheObject.cpp
vendored
Normal file
355
mozilla/network/cache/nu/src/nsCacheObject.cpp
vendored
Normal file
@@ -0,0 +1,355 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
#include <xp_core.h>
|
||||
#include <xp_str.h>
|
||||
#include <xpassert.h>
|
||||
|
||||
#include <prmem.h>
|
||||
#include <prprf.h>
|
||||
#include <plstr.h>
|
||||
|
||||
#include "nsCacheObject.h"
|
||||
#include "nsCacheTrace.h"
|
||||
|
||||
/*
|
||||
* nsCacheObject
|
||||
*
|
||||
* Gagan Saksena 02/02/98
|
||||
*
|
||||
*/
|
||||
|
||||
static const PRIntervalTime DEFAULT_EXPIRES = PR_SecondsToInterval(86400);
|
||||
|
||||
// m_Etag, m_Expires, m_Flags, m_Hits, m_LastAccessed, m_LastModified, m_Module, m_Size, m_Url
|
||||
#define READ_WRITE_FORMAT "%s,%d,%d,%d,%d,%d,%d,%d,%s"
|
||||
#define READ_WRITE_ELEMENTS m_Etag,m_Expires,m_Flags,m_Hits,m_LastAccessed,m_LastModified,m_Module,m_Size,m_Url
|
||||
|
||||
#if !defined(IS_LITTLE_ENDIAN) && !defined(IS_BIG_ENDIAN)
|
||||
ERROR! Must have a byte order
|
||||
#endif
|
||||
|
||||
#ifdef IS_LITTLE_ENDIAN
|
||||
#define COPY_INT32(_a,_b) memcpy(_a, _b, sizeof(int32));
|
||||
#else
|
||||
#define COPY_INT32(_a,_b) /* swap */ \
|
||||
do { \
|
||||
((char *)(_a))[0] = ((char *)(_b))[3]; \
|
||||
((char *)(_a))[1] = ((char *)(_b))[2]; \
|
||||
((char *)(_a))[2] = ((char *)(_b))[1]; \
|
||||
((char *)(_a))[3] = ((char *)(_b))[0]; \
|
||||
} while(0)
|
||||
#endif
|
||||
|
||||
/* Convenient macros used in stuffing and reading back cache object to a void * */
|
||||
/* TODO: Change these to file scope functions */
|
||||
#define STUFF_STRING(string) \
|
||||
{ \
|
||||
len = (string ? PL_strlen(string)+1 : 0); \
|
||||
COPY_INT32((void *)cur_ptr, &len); \
|
||||
cur_ptr = cur_ptr + sizeof(int32); \
|
||||
if(len) \
|
||||
memcpy((void *)cur_ptr, string, len); \
|
||||
cur_ptr += len; \
|
||||
}
|
||||
|
||||
#define STUFF_NUMBER(number) \
|
||||
{ \
|
||||
COPY_INT32((void *)cur_ptr, &number); \
|
||||
cur_ptr = cur_ptr + sizeof(PRUint32); \
|
||||
}
|
||||
|
||||
#define STUFF_TIME(number) \
|
||||
{ \
|
||||
COPY_INT32((void *)cur_ptr, &number); \
|
||||
cur_ptr = cur_ptr + sizeof(PRIntervalTime); \
|
||||
}
|
||||
|
||||
#define STUFF_BOOL(bool_val) \
|
||||
{ \
|
||||
if(bool_val) \
|
||||
((char *)(cur_ptr))[0] = 1; \
|
||||
else \
|
||||
((char *)(cur_ptr))[0] = 0; \
|
||||
cur_ptr = cur_ptr + sizeof(char); \
|
||||
}
|
||||
|
||||
/* if any strings are larger than this then
|
||||
* there was a serious database error
|
||||
*/
|
||||
#define MAX_HUGE_STRING_SIZE 10000
|
||||
|
||||
#define RETRIEVE_STRING(string) \
|
||||
{ \
|
||||
if(cur_ptr > max_ptr) \
|
||||
{ \
|
||||
return PR_TRUE; \
|
||||
} \
|
||||
COPY_INT32(&len, cur_ptr); \
|
||||
cur_ptr += sizeof(int32); \
|
||||
if(len) \
|
||||
{ \
|
||||
if(len > MAX_HUGE_STRING_SIZE) \
|
||||
{ \
|
||||
return PR_FALSE; \
|
||||
} \
|
||||
string = (char*)PR_Malloc(len); \
|
||||
if(!string) \
|
||||
{ \
|
||||
return PR_FALSE; \
|
||||
} \
|
||||
memcpy(string, cur_ptr, len); \
|
||||
cur_ptr += len; \
|
||||
} \
|
||||
}
|
||||
|
||||
#define RETRIEVE_NUMBER(number) \
|
||||
{ \
|
||||
if(cur_ptr > max_ptr) \
|
||||
return PR_TRUE; \
|
||||
COPY_INT32(&number, cur_ptr); \
|
||||
cur_ptr += sizeof(int32); \
|
||||
}
|
||||
|
||||
#define RETRIEVE_TIME(number) \
|
||||
{ \
|
||||
if(cur_ptr > max_ptr) \
|
||||
return PR_TRUE; \
|
||||
COPY_INT32(&number, cur_ptr); \
|
||||
cur_ptr += sizeof(PRIntervalTime); \
|
||||
}
|
||||
|
||||
#define RETRIEVE_BOOL(bool) \
|
||||
{ \
|
||||
if(cur_ptr > max_ptr) \
|
||||
return PR_TRUE; \
|
||||
if(((char *)(cur_ptr))[0]) \
|
||||
bool = TRUE; \
|
||||
else \
|
||||
bool = FALSE; \
|
||||
cur_ptr += sizeof(char); \
|
||||
}
|
||||
|
||||
nsCacheObject::nsCacheObject():
|
||||
m_Flags(INIT),
|
||||
m_Url(new char[1]),
|
||||
m_Etag(new char[1]),
|
||||
m_Module(-1),
|
||||
m_pInfo(0)
|
||||
{
|
||||
Init();
|
||||
*m_Url = '\0';
|
||||
*m_Etag = '\0';
|
||||
}
|
||||
|
||||
nsCacheObject::~nsCacheObject()
|
||||
{
|
||||
delete[] m_Url;
|
||||
delete[] m_Etag;
|
||||
}
|
||||
|
||||
nsCacheObject::nsCacheObject(const nsCacheObject& another):
|
||||
m_Flags(another.m_Flags),
|
||||
m_Url(new char[strlen(another.m_Url)+1]),
|
||||
m_Etag(new char[strlen(another.m_Etag)+1]),
|
||||
m_pInfo(0)
|
||||
{
|
||||
strcpy(m_Url, another.m_Url);
|
||||
strcpy(m_Etag, another.m_Etag);
|
||||
|
||||
m_Hits = another.m_Hits;
|
||||
m_LastAccessed = another.m_LastAccessed;
|
||||
m_LastModified = another.m_LastModified;
|
||||
m_Size = another.m_Size;
|
||||
m_Module = another.m_Module;
|
||||
}
|
||||
|
||||
nsCacheObject::nsCacheObject(const char* i_url):
|
||||
m_Flags(INIT),
|
||||
m_Url(new char[strlen(i_url)+1]),
|
||||
m_Etag(new char[1]),
|
||||
m_Module(-1),
|
||||
m_pInfo(0)
|
||||
{
|
||||
Init();
|
||||
PR_ASSERT(i_url);
|
||||
strcpy(m_Url, i_url);
|
||||
*m_Etag = '\0';
|
||||
}
|
||||
|
||||
void nsCacheObject::Address(const char* i_url)
|
||||
{
|
||||
PR_ASSERT(i_url && *i_url);
|
||||
if (m_Url)
|
||||
delete[] m_Url;
|
||||
m_Url = new char[strlen(i_url) + 1];
|
||||
strcpy(m_Url, i_url);
|
||||
}
|
||||
|
||||
void nsCacheObject::Etag(const char* i_etag)
|
||||
{
|
||||
PR_ASSERT(i_etag && *i_etag);
|
||||
if (m_Etag)
|
||||
delete[] m_Etag;
|
||||
m_Etag = new char[strlen(i_etag) + 1];
|
||||
strcpy(m_Etag, i_etag);
|
||||
}
|
||||
|
||||
void* nsCacheObject::Info(void) const
|
||||
{
|
||||
if (m_pInfo)
|
||||
return m_pInfo;
|
||||
|
||||
nsCacheObject* pThis = (nsCacheObject*) this;
|
||||
if (m_Url){
|
||||
/*
|
||||
char* tmpBuff = PR_smprintf(READ_WRITE_FORMAT, READ_WRITE_ELEMENTS);
|
||||
int tmpLen = PL_strlen(tmpBuff);
|
||||
pThis->m_pInfo = PR_Malloc(tmpLen);
|
||||
memcpy(pThis->m_pInfo, tmpBuff, tmpLen);
|
||||
PR_Free(tmpBuff);
|
||||
*/
|
||||
pThis->m_info_size = sizeof(nsCacheObject);
|
||||
pThis->m_info_size -= sizeof(void*); //m_info is not being serialized
|
||||
|
||||
//Add the strings sizes
|
||||
pThis->m_info_size += PL_strlen(m_Etag)+1;
|
||||
pThis->m_info_size += PL_strlen(m_Url)+1;
|
||||
|
||||
void* new_obj = PR_Malloc(m_info_size * sizeof(char));
|
||||
|
||||
memset(new_obj, 0, m_info_size *sizeof(char));
|
||||
|
||||
if (!new_obj)
|
||||
{
|
||||
PR_Free(new_obj);
|
||||
return 0;
|
||||
}
|
||||
|
||||
PRUint32 len;
|
||||
|
||||
char* cur_ptr = (char*) new_obj;
|
||||
/* put the total size of the struct into
|
||||
* the first field so that we have
|
||||
* a cross check against corruption
|
||||
*/
|
||||
COPY_INT32((void *)cur_ptr, &m_info_size);
|
||||
cur_ptr += sizeof(PRUint32);
|
||||
|
||||
/* put the version number of the structure
|
||||
* format that we are using. By using a version
|
||||
* string when writting we can support
|
||||
* backwards compatibility in our reading code
|
||||
*/
|
||||
COPY_INT32((void *)cur_ptr, &kCACHE_VERSION);
|
||||
cur_ptr += sizeof(PRUint32);
|
||||
|
||||
STUFF_STRING(m_Etag);
|
||||
STUFF_TIME(m_Expires);
|
||||
STUFF_NUMBER(m_Flags);
|
||||
STUFF_NUMBER(m_Hits);
|
||||
STUFF_TIME(m_LastAccessed);
|
||||
STUFF_TIME(m_LastModified);
|
||||
STUFF_NUMBER(m_Module);
|
||||
STUFF_NUMBER(m_Size);
|
||||
STUFF_STRING(m_Url);
|
||||
|
||||
// Important Assertion. Dont remove!
|
||||
PR_ASSERT(cur_ptr == (char*) new_obj + m_info_size);
|
||||
pThis->m_pInfo = new_obj;
|
||||
}
|
||||
return m_pInfo;
|
||||
}
|
||||
|
||||
PRBool nsCacheObject::Info(void* i_data)
|
||||
{
|
||||
if (!i_data)
|
||||
return PR_FALSE;
|
||||
|
||||
char* cur_ptr = (char*) i_data;
|
||||
|
||||
//Reset the m_pInfo;
|
||||
PR_FREEIF(m_pInfo);
|
||||
|
||||
COPY_INT32(&m_info_size, cur_ptr);
|
||||
char* max_ptr = cur_ptr + m_info_size;
|
||||
cur_ptr += sizeof(PRUint32);
|
||||
|
||||
PRUint32 version;
|
||||
COPY_INT32(&version, cur_ptr);
|
||||
cur_ptr += sizeof(PRUint32);
|
||||
|
||||
PR_ASSERT(version == kCACHE_VERSION);
|
||||
if (version != kCACHE_VERSION)
|
||||
{
|
||||
//TODO Bad cache version
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
PRUint32 len;
|
||||
//m_Etag,m_Expires,m_Flags,m_Hits,m_LastAccessed,m_LastModified,m_Module,m_Size,m_Url
|
||||
RETRIEVE_STRING(m_Etag);
|
||||
RETRIEVE_TIME(m_Expires);
|
||||
RETRIEVE_NUMBER(m_Flags);
|
||||
RETRIEVE_NUMBER(m_Hits);
|
||||
RETRIEVE_TIME(m_LastAccessed);
|
||||
RETRIEVE_TIME(m_LastModified);
|
||||
RETRIEVE_NUMBER(m_Module);
|
||||
RETRIEVE_NUMBER(m_Size);
|
||||
RETRIEVE_STRING(m_Url);
|
||||
|
||||
// Most important assertion! Don't ever remove!
|
||||
PR_ASSERT(cur_ptr == max_ptr);
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
PRUint32 nsCacheObject::InfoSize(void) const
|
||||
{
|
||||
if (!m_pInfo)
|
||||
{
|
||||
((nsCacheObject*) this)->Info();
|
||||
}
|
||||
return m_info_size;
|
||||
}
|
||||
|
||||
void nsCacheObject::Init()
|
||||
{
|
||||
m_Expires = PR_IntervalNow() + DEFAULT_EXPIRES;
|
||||
m_Hits = 0;
|
||||
}
|
||||
|
||||
/* Caller must free returned string */
|
||||
// TODO change to use PR_stuff...
|
||||
const char* nsCacheObject::Trace() const
|
||||
{
|
||||
char linebuffer[256];
|
||||
char* total;
|
||||
|
||||
sprintf(linebuffer, "nsCacheObject:URL=%s,SIZE=%d,ET=%s,\n\tLM=%d,LA=%d,EXP=%d,HITS=%d\n",
|
||||
m_Url,
|
||||
m_Size,
|
||||
m_Etag,
|
||||
m_LastModified,
|
||||
m_LastAccessed,
|
||||
m_Expires,
|
||||
m_Hits);
|
||||
|
||||
total = new char[PL_strlen(linebuffer) +1];
|
||||
strcpy(total, linebuffer);
|
||||
|
||||
return total;
|
||||
}
|
||||
81
mozilla/network/cache/nu/src/nsCachePref.cpp
vendored
Normal file
81
mozilla/network/cache/nu/src/nsCachePref.cpp
vendored
Normal file
@@ -0,0 +1,81 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "nsCachePref.h"
|
||||
|
||||
static const PRUint32 MEM_CACHE_SIZE_DEFAULT = 1024*1024;
|
||||
static const PRUint32 DISK_CACHE_SIZE_DEFAULT = 5*MEM_CACHE_SIZE_DEFAULT;
|
||||
|
||||
static nsCachePref ThePrefs;
|
||||
|
||||
nsCachePref::nsCachePref(void)
|
||||
{
|
||||
//Read all the stuff from pref here.
|
||||
}
|
||||
|
||||
nsCachePref::~nsCachePref()
|
||||
{
|
||||
}
|
||||
|
||||
PRUint32 nsCachePref::DiskCacheSize()
|
||||
{
|
||||
return DISK_CACHE_SIZE_DEFAULT;
|
||||
}
|
||||
|
||||
const char* nsCachePref::DiskCacheDBFilename(void)
|
||||
{
|
||||
return "fat.db";
|
||||
}
|
||||
|
||||
const char* nsCachePref::DiskCacheFolder(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
nsCachePref* nsCachePref::GetInstance()
|
||||
{
|
||||
return &ThePrefs;
|
||||
}
|
||||
|
||||
PRUint32 nsCachePref::MemCacheSize()
|
||||
{
|
||||
return MEM_CACHE_SIZE_DEFAULT;
|
||||
}
|
||||
|
||||
/*
|
||||
nsrefcnt nsCachePref::AddRef(void)
|
||||
{
|
||||
return ++m_RefCnt;
|
||||
}
|
||||
nsrefcnt nsCachePref::Release(void)
|
||||
{
|
||||
if (--m_RefCnt == 0)
|
||||
{
|
||||
delete this;
|
||||
return 0;
|
||||
}
|
||||
return m_RefCnt;
|
||||
}
|
||||
|
||||
nsresult nsCachePref::QueryInterface(const nsIID& aIID,
|
||||
void** aInstancePtrResult)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
*/
|
||||
|
||||
@@ -16,10 +16,16 @@
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef __NS_JSWINREG_H__
|
||||
#define __NS_JSWINREG_H__
|
||||
/*
|
||||
* nsCacheTrace
|
||||
*
|
||||
* Gagan Saksena 02/02/98
|
||||
*
|
||||
*/
|
||||
|
||||
PRInt32
|
||||
InitWinRegPrototype(JSContext *jscontext, JSObject *global, JSObject **winRegPrototype);
|
||||
#include "nsCacheTrace.h"
|
||||
|
||||
#endif
|
||||
nsCacheTrace::nsCacheTrace()
|
||||
{
|
||||
|
||||
}
|
||||
196
mozilla/network/cache/nu/src/nsDiskModule.cpp
vendored
Normal file
196
mozilla/network/cache/nu/src/nsDiskModule.cpp
vendored
Normal file
@@ -0,0 +1,196 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
* nsDiskModule
|
||||
*
|
||||
* Gagan Saksena 02/02/98
|
||||
*
|
||||
*/
|
||||
|
||||
#include <prtypes.h>
|
||||
#include <prmem.h>
|
||||
#include <plstr.h>
|
||||
|
||||
#include "nsDiskModule.h"
|
||||
#include "nsCacheObject.h"
|
||||
#include "nsCacheManager.h"
|
||||
|
||||
#include "mcom_db.h"
|
||||
|
||||
//
|
||||
// Constructor: nsDiskModule
|
||||
//
|
||||
nsDiskModule::nsDiskModule(const PRUint32 size):
|
||||
nsCacheModule(size),
|
||||
m_pDB(0)
|
||||
{
|
||||
}
|
||||
|
||||
nsDiskModule::~nsDiskModule()
|
||||
{
|
||||
if (m_pDB)
|
||||
{
|
||||
(*m_pDB->sync)(m_pDB, 0);
|
||||
(*m_pDB->close)(m_pDB);
|
||||
m_pDB = 0;
|
||||
}
|
||||
}
|
||||
|
||||
PRBool nsDiskModule::AddObject(nsCacheObject* io_pObject)
|
||||
{
|
||||
if (!InitDB())
|
||||
{
|
||||
// Set some error state TODO
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
if (io_pObject && io_pObject->Address())
|
||||
{
|
||||
static DBT key,data;
|
||||
|
||||
io_pObject->Module(nsCacheManager::DISK);
|
||||
|
||||
PR_FREEIF(key.data);
|
||||
PR_FREEIF(data.data);
|
||||
|
||||
key.data = (void*)io_pObject->Address(); /* Later on change this to include post data- io_pObject->KeyData() */
|
||||
key.size = PL_strlen(io_pObject->Address());
|
||||
|
||||
data.data = io_pObject->Info();
|
||||
data.size = io_pObject->InfoSize();
|
||||
|
||||
int status = (*m_pDB->put)(m_pDB, &key, &data, 0);
|
||||
if (status == 0)
|
||||
{
|
||||
// if (m_Sync == EVERYTIME)
|
||||
status = (*m_pDB->sync)(m_pDB, 0);
|
||||
}
|
||||
return (status == 0);
|
||||
}
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
PRBool nsDiskModule::Contains(nsCacheObject* io_pObject) const
|
||||
{
|
||||
if (!m_pDB)
|
||||
{
|
||||
nsDiskModule* pThis = (nsDiskModule*) this;
|
||||
pThis->InitDB();
|
||||
}
|
||||
|
||||
if (!m_pDB || !io_pObject)
|
||||
return PR_FALSE;
|
||||
|
||||
nsCacheObject* pTemp = GetObject(io_pObject->Address());
|
||||
if (pTemp)
|
||||
{
|
||||
io_pObject = pTemp;
|
||||
return PR_TRUE;
|
||||
}
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
PRBool nsDiskModule::Contains(const char* i_url) const
|
||||
{
|
||||
if (!m_pDB)
|
||||
{
|
||||
nsDiskModule* pThis = (nsDiskModule*) this;
|
||||
pThis->InitDB();
|
||||
}
|
||||
|
||||
if (!m_pDB || !i_url || !*i_url)
|
||||
return PR_FALSE;
|
||||
|
||||
DBT key, data;
|
||||
|
||||
key.data = (void*) i_url;
|
||||
key.size = PL_strlen(i_url);
|
||||
|
||||
int status = (*m_pDB->get)(m_pDB, &key, &data, 0);
|
||||
|
||||
return (status == 0);
|
||||
|
||||
}
|
||||
|
||||
nsCacheObject* nsDiskModule::GetObject(const PRUint32 i_index) const
|
||||
{
|
||||
if (!m_pDB)
|
||||
{
|
||||
nsDiskModule* pThis = (nsDiskModule*) this;
|
||||
pThis->InitDB();
|
||||
}
|
||||
|
||||
if (!m_pDB)
|
||||
return 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
nsCacheObject* nsDiskModule::GetObject(const char* i_url) const
|
||||
{
|
||||
if (!m_pDB)
|
||||
{
|
||||
nsDiskModule* pThis = (nsDiskModule*) this;
|
||||
pThis->InitDB();
|
||||
}
|
||||
|
||||
if (!m_pDB || !i_url || !*i_url)
|
||||
return 0;
|
||||
|
||||
DBT key, data;
|
||||
|
||||
key.data = (void*) i_url;
|
||||
key.size = PL_strlen(i_url);
|
||||
|
||||
if (0 == (*m_pDB->get)(m_pDB, &key, &data, 0))
|
||||
{
|
||||
nsCacheObject* pTemp = new nsCacheObject();
|
||||
pTemp->Info(data.data);
|
||||
return pTemp;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
PRBool nsDiskModule::InitDB(void)
|
||||
{
|
||||
|
||||
if (m_pDB)
|
||||
return PR_TRUE;
|
||||
|
||||
HASHINFO hash_info = {
|
||||
16*1024, /* bucket size */
|
||||
0, /* fill factor */
|
||||
0, /* number of elements */
|
||||
0, /* bytes to cache */
|
||||
0, /* hash function */
|
||||
0}; /* byte order */
|
||||
|
||||
m_pDB = dbopen(
|
||||
nsCachePref::DiskCacheDBFilename(),
|
||||
O_RDWR | O_CREAT,
|
||||
0600,
|
||||
DB_HASH,
|
||||
&hash_info);
|
||||
|
||||
if (!m_pDB)
|
||||
return PR_FALSE;
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
44
mozilla/network/cache/nu/src/nsMemCacheObject.cpp
vendored
Normal file
44
mozilla/network/cache/nu/src/nsMemCacheObject.cpp
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
* nsMemCacheObject
|
||||
*
|
||||
* Gagan Saksena 04/22/98
|
||||
*
|
||||
*/
|
||||
#include <prtypes.h>
|
||||
#include "nsMemCacheObject.h"
|
||||
|
||||
nsMemCacheObject::~nsMemCacheObject()
|
||||
{
|
||||
if (m_pNextObject)
|
||||
{
|
||||
delete m_pNextObject;
|
||||
m_pNextObject = 0;
|
||||
}
|
||||
|
||||
if (m_pObject)
|
||||
{
|
||||
delete m_pObject;
|
||||
m_pObject = 0;
|
||||
}
|
||||
|
||||
// Free the void* if allocated - TODO
|
||||
|
||||
}
|
||||
185
mozilla/network/cache/nu/src/nsMemModule.cpp
vendored
Normal file
185
mozilla/network/cache/nu/src/nsMemModule.cpp
vendored
Normal file
@@ -0,0 +1,185 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include <prtypes.h>
|
||||
#include <plstr.h>
|
||||
|
||||
#include "nsMemModule.h"
|
||||
#include "nsMemCacheObject.h"
|
||||
#include "nsCacheManager.h"
|
||||
|
||||
/*
|
||||
* nsMemModule
|
||||
*
|
||||
* Gagan Saksena 02/02/98
|
||||
*
|
||||
*/
|
||||
|
||||
//NS_DEFINE_IID(kMemModuleIID, NS_MEMMODULE_IID);
|
||||
|
||||
nsMemModule::nsMemModule(const PRUint32 size):
|
||||
m_pFirstObject(0),
|
||||
nsCacheModule(size)
|
||||
{
|
||||
Size(size);
|
||||
}
|
||||
|
||||
nsMemModule::~nsMemModule()
|
||||
{
|
||||
if (m_pFirstObject) {
|
||||
delete m_pFirstObject;
|
||||
m_pFirstObject = 0;
|
||||
}
|
||||
}
|
||||
|
||||
PRBool nsMemModule::AddObject(nsCacheObject* io_pObject)
|
||||
{
|
||||
|
||||
#if 0
|
||||
if (io_pObject)
|
||||
{
|
||||
m_ht.Put(io_pObject->Address(), io_pObject);
|
||||
}
|
||||
return PR_FALSE;
|
||||
#endif
|
||||
|
||||
if (io_pObject)
|
||||
{
|
||||
if (m_pFirstObject)
|
||||
{
|
||||
LastObject()->Next(new nsMemCacheObject(io_pObject));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pFirstObject = new nsMemCacheObject(io_pObject);
|
||||
}
|
||||
m_Entries++;
|
||||
|
||||
io_pObject->Module(nsCacheManager::MEM);
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
PRBool nsMemModule::Contains(const char* i_url) const
|
||||
{
|
||||
if (m_pFirstObject && i_url && *i_url)
|
||||
{
|
||||
nsMemCacheObject* pObj = m_pFirstObject;
|
||||
PRUint32 inlen = PL_strlen(i_url);
|
||||
do
|
||||
{
|
||||
if (0 == PL_strncasecmp(pObj->ThisObject()->Address(), i_url, inlen))
|
||||
return PR_TRUE;
|
||||
pObj = pObj->Next();
|
||||
}
|
||||
while (pObj);
|
||||
}
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
PRBool nsMemModule::Contains(nsCacheObject* i_pObject) const
|
||||
{
|
||||
if (i_pObject && *i_pObject->Address())
|
||||
{
|
||||
return this->Contains(i_pObject->Address());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
nsCacheObject* nsMemModule::GetObject(const PRUint32 i_index) const
|
||||
{
|
||||
nsMemCacheObject* pNth = 0;
|
||||
if (m_pFirstObject)
|
||||
{
|
||||
PRUint32 index = 0;
|
||||
pNth = m_pFirstObject;
|
||||
while (pNth->Next() && (index++ != i_index ))
|
||||
{
|
||||
pNth = pNth->Next();
|
||||
}
|
||||
}
|
||||
return pNth->ThisObject();
|
||||
}
|
||||
|
||||
nsCacheObject* nsMemModule::GetObject(const char* i_url) const
|
||||
{
|
||||
if (m_pFirstObject && i_url && *i_url)
|
||||
{
|
||||
nsMemCacheObject* pObj = m_pFirstObject;
|
||||
int inlen = PL_strlen(i_url);
|
||||
do
|
||||
{
|
||||
if (0 == PL_strncasecmp(pObj->ThisObject()->Address(), i_url, inlen))
|
||||
return pObj->ThisObject();
|
||||
pObj = pObj->Next();
|
||||
}
|
||||
while (pObj);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
nsMemCacheObject* nsMemModule::LastObject(void) const
|
||||
{
|
||||
nsMemCacheObject* pLast = 0;
|
||||
if (m_pFirstObject)
|
||||
{
|
||||
pLast = m_pFirstObject;
|
||||
while (pLast->Next())
|
||||
pLast = pLast->Next();
|
||||
}
|
||||
return pLast;
|
||||
}
|
||||
|
||||
/*
|
||||
NS_IMETHOD nsMemModule::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
||||
{
|
||||
|
||||
}
|
||||
NS_IMETHOD_(nsrefcnt) nsMemModule::AddRef(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
NS_IMETHOD_(nsrefcnt) nsMemModule::Release(void)
|
||||
{
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
PRUint32 nsMemModule::nsMemKey::HashValue()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
PRBool nsMemModule::nsMemKey::Equals(nsHashKey *aKey)
|
||||
{
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
nsHashKey* nsMemModule::nsMemKey::Clone()
|
||||
{
|
||||
return new nsMemModule::nsMemKey();
|
||||
}
|
||||
|
||||
nsMemModule::nsMemKey::neMemKey()
|
||||
{
|
||||
}
|
||||
|
||||
*/
|
||||
104
mozilla/network/cache/nu/tests/cb/CacheTreeView.cpp
vendored
Normal file
104
mozilla/network/cache/nu/tests/cb/CacheTreeView.cpp
vendored
Normal file
@@ -0,0 +1,104 @@
|
||||
// CacheTreeView.cpp : implementation file
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "cb.h"
|
||||
#include "CacheTreeView.h"
|
||||
#include "cbdoc.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CCacheTreeView
|
||||
|
||||
IMPLEMENT_DYNCREATE(CCacheTreeView, CTreeView)
|
||||
|
||||
CCacheTreeView::CCacheTreeView()
|
||||
{
|
||||
m_pImgList = new CImageList();
|
||||
}
|
||||
|
||||
CCacheTreeView::~CCacheTreeView()
|
||||
{
|
||||
delete m_pImgList;
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(CCacheTreeView, CTreeView)
|
||||
//{{AFX_MSG_MAP(CCacheTreeView)
|
||||
ON_WM_CREATE()
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
int CCacheTreeView::OnCreate(LPCREATESTRUCT lpCreateStruct)
|
||||
{
|
||||
|
||||
lpCreateStruct->style = TVS_HASLINES | TVS_HASBUTTONS | TVS_LINESATROOT;
|
||||
if (CView::OnCreate(lpCreateStruct) == -1)
|
||||
return -1;
|
||||
|
||||
GetDocument()->m_pTreeView = this;
|
||||
|
||||
// Create the Image List
|
||||
m_pImgList->Create(IDB_CACHEICONS,16,0,RGB(255,0,255));
|
||||
m_pImgList->SetBkColor(GetSysColor(COLOR_WINDOW));
|
||||
|
||||
// Attach image list to Tree
|
||||
GetTreeCtrl().SetImageList(m_pImgList, TVSIL_NORMAL);
|
||||
GetTreeCtrl().SetIndent(10);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void CCacheTreeView::OnDraw(CDC* pDC)
|
||||
{
|
||||
CDocument* pDoc = GetDocument();
|
||||
// TODO: add draw code here
|
||||
}
|
||||
|
||||
|
||||
#ifdef _DEBUG
|
||||
void CCacheTreeView::AssertValid() const
|
||||
{
|
||||
CTreeView::AssertValid();
|
||||
}
|
||||
|
||||
void CCacheTreeView::Dump(CDumpContext& dc) const
|
||||
{
|
||||
CTreeView::Dump(dc);
|
||||
}
|
||||
|
||||
CCbDoc* CCacheTreeView::GetDocument()
|
||||
{
|
||||
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CCbDoc)));
|
||||
return (CCbDoc*)m_pDocument;
|
||||
}
|
||||
|
||||
#endif //_DEBUG
|
||||
|
||||
void CCacheTreeView::Populate() {
|
||||
AssertValid();
|
||||
GetTreeCtrl().DeleteAllItems();
|
||||
|
||||
TV_INSERTSTRUCT insertStruct;
|
||||
TV_ITEM itemStruct;
|
||||
|
||||
insertStruct.hParent = TVI_ROOT;
|
||||
insertStruct.hInsertAfter = TVI_FIRST;
|
||||
insertStruct.item = itemStruct;
|
||||
|
||||
HTREEITEM hti = GetTreeCtrl().InsertItem(&insertStruct);
|
||||
GetTreeCtrl().SetItemText(hti, "Your Cache");
|
||||
|
||||
insertStruct.hParent = hti;
|
||||
insertStruct.hInsertAfter = hti;
|
||||
insertStruct.item = itemStruct;
|
||||
|
||||
HTREEITEM htiDisk = GetTreeCtrl().InsertItem(&insertStruct);
|
||||
GetTreeCtrl().SetItemText(htiDisk, "Disk");
|
||||
HTREEITEM htiMem = GetTreeCtrl().InsertItem(&insertStruct);
|
||||
GetTreeCtrl().SetItemText(htiMem, "Memory");
|
||||
}
|
||||
54
mozilla/network/cache/nu/tests/cb/CacheTreeView.h
vendored
Normal file
54
mozilla/network/cache/nu/tests/cb/CacheTreeView.h
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
// CacheTreeView.h : header file
|
||||
//
|
||||
#ifndef _CacheTreeView_h_
|
||||
#define _CacheTreeView_h_
|
||||
|
||||
#include <afxcview.h>
|
||||
class CImageList;
|
||||
class CCbDoc;
|
||||
class CCacheTreeView : public CTreeView
|
||||
{
|
||||
protected:
|
||||
CCacheTreeView(); // protected constructor used by dynamic creation
|
||||
DECLARE_DYNCREATE(CCacheTreeView)
|
||||
|
||||
// Attributes
|
||||
public:
|
||||
CCbDoc* GetDocument();
|
||||
void Populate();
|
||||
// Operations
|
||||
public:
|
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CCacheTreeView)
|
||||
protected:
|
||||
virtual void OnDraw(CDC* pDC); // overridden to draw this view
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
protected:
|
||||
virtual ~CCacheTreeView();
|
||||
#ifdef _DEBUG
|
||||
virtual void AssertValid() const;
|
||||
virtual void Dump(CDumpContext& dc) const;
|
||||
#endif
|
||||
|
||||
// Generated message map functions
|
||||
protected:
|
||||
//{{AFX_MSG(CCacheTreeView)
|
||||
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
|
||||
//}}AFX_MSG
|
||||
|
||||
DECLARE_MESSAGE_MAP()
|
||||
|
||||
CImageList* m_pImgList;
|
||||
};
|
||||
|
||||
#ifndef _DEBUG // debug version in AnimalView.cpp
|
||||
inline CCbDoc* CCacheTreeView::GetDocument()
|
||||
{ return (CCbDoc*)m_pDocument; }
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
128
mozilla/network/cache/nu/tests/cb/MainFrm.cpp
vendored
Normal file
128
mozilla/network/cache/nu/tests/cb/MainFrm.cpp
vendored
Normal file
@@ -0,0 +1,128 @@
|
||||
// MainFrm.cpp : implementation of the CMainFrame class
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "cb.h"
|
||||
|
||||
#include "MainFrm.h"
|
||||
#include "CacheTreeView.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CMainFrame
|
||||
|
||||
IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)
|
||||
|
||||
BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
|
||||
//{{AFX_MSG_MAP(CMainFrame)
|
||||
ON_WM_CREATE()
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
static UINT indicators[] =
|
||||
{
|
||||
ID_SEPARATOR, // status line indicator
|
||||
ID_INDICATOR_CAPS,
|
||||
ID_INDICATOR_NUM,
|
||||
ID_INDICATOR_SCRL,
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CMainFrame construction/destruction
|
||||
|
||||
CMainFrame::CMainFrame()
|
||||
{
|
||||
}
|
||||
|
||||
CMainFrame::~CMainFrame()
|
||||
{
|
||||
}
|
||||
|
||||
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
|
||||
{
|
||||
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
|
||||
return -1;
|
||||
|
||||
if (!m_wndToolBar.Create(this) ||
|
||||
!m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
|
||||
{
|
||||
TRACE0("Failed to create toolbar\n");
|
||||
return -1; // fail to create
|
||||
}
|
||||
|
||||
if (!m_wndStatusBar.Create(this) ||
|
||||
!m_wndStatusBar.SetIndicators(indicators,
|
||||
sizeof(indicators)/sizeof(UINT)))
|
||||
{
|
||||
TRACE0("Failed to create status bar\n");
|
||||
return -1; // fail to create
|
||||
}
|
||||
|
||||
m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() |
|
||||
CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
|
||||
|
||||
m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
|
||||
EnableDocking(CBRS_ALIGN_ANY);
|
||||
DockControlBar(&m_wndToolBar);
|
||||
return 0;
|
||||
}
|
||||
|
||||
BOOL CMainFrame::OnCreateClient( LPCREATESTRUCT /*lpcs*/,
|
||||
CCreateContext* pContext)
|
||||
{
|
||||
// create a splitter with 1 row, 2 columns
|
||||
if (!m_wndSplitter.CreateStatic(this, 1, 2))
|
||||
{
|
||||
TRACE0("Failed to CreateStaticSplitter\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// add the first splitter pane - the default view in column 0
|
||||
if (!m_wndSplitter.CreateView(0, 0,
|
||||
RUNTIME_CLASS(CCacheTreeView), CSize(250, 50), pContext))
|
||||
{
|
||||
TRACE0("Failed to create first pane\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// add the second splitter pane - an input view in column 1
|
||||
if (!m_wndSplitter.CreateView(0, 1, pContext->m_pNewViewClass, CSize(0, 0), pContext))
|
||||
{
|
||||
TRACE0("Failed to create second pane\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// activate the tree view
|
||||
SetActiveView((CView*)m_wndSplitter.GetPane(0,1));
|
||||
return TRUE;
|
||||
|
||||
}
|
||||
|
||||
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
|
||||
{
|
||||
return CFrameWnd::PreCreateWindow(cs);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CMainFrame diagnostics
|
||||
|
||||
#ifdef _DEBUG
|
||||
void CMainFrame::AssertValid() const
|
||||
{
|
||||
CFrameWnd::AssertValid();
|
||||
}
|
||||
|
||||
void CMainFrame::Dump(CDumpContext& dc) const
|
||||
{
|
||||
CFrameWnd::Dump(dc);
|
||||
}
|
||||
|
||||
#endif //_DEBUG
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CMainFrame message handlers
|
||||
48
mozilla/network/cache/nu/tests/cb/MainFrm.h
vendored
Normal file
48
mozilla/network/cache/nu/tests/cb/MainFrm.h
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
// MainFrm.h : interface of the CMainFrame class
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class CMainFrame : public CFrameWnd
|
||||
{
|
||||
protected: // create from serialization only
|
||||
CMainFrame();
|
||||
DECLARE_DYNCREATE(CMainFrame)
|
||||
|
||||
// Attributes
|
||||
protected:
|
||||
CSplitterWnd m_wndSplitter;
|
||||
public:
|
||||
|
||||
void Status(const char* mesg);
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CMainFrame)
|
||||
public:
|
||||
virtual BOOL OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext);
|
||||
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
public:
|
||||
virtual ~CMainFrame();
|
||||
#ifdef _DEBUG
|
||||
virtual void AssertValid() const;
|
||||
virtual void Dump(CDumpContext& dc) const;
|
||||
#endif
|
||||
|
||||
protected: // control bar embedded members
|
||||
CStatusBar m_wndStatusBar;
|
||||
CToolBar m_wndToolBar;
|
||||
|
||||
// Generated message map functions
|
||||
protected:
|
||||
//{{AFX_MSG(CMainFrame)
|
||||
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
inline void CMainFrame::Status(const char* mesg) {
|
||||
m_wndStatusBar.SetPaneText(0, mesg);
|
||||
}
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
6
mozilla/network/cache/nu/tests/cb/StdAfx.cpp
vendored
Normal file
6
mozilla/network/cache/nu/tests/cb/StdAfx.cpp
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
// stdafx.cpp : source file that includes just the standard includes
|
||||
// cb.pch will be the pre-compiled header
|
||||
// stdafx.obj will contain the pre-compiled type information
|
||||
|
||||
#include "stdafx.h"
|
||||
|
||||
16
mozilla/network/cache/nu/tests/cb/StdAfx.h
vendored
Normal file
16
mozilla/network/cache/nu/tests/cb/StdAfx.h
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
// stdafx.h : include file for standard system include files,
|
||||
// or project specific include files that are used frequently, but
|
||||
// are changed infrequently
|
||||
//
|
||||
|
||||
#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
|
||||
|
||||
#include <afxwin.h> // MFC core and standard components
|
||||
#include <afxext.h> // MFC extensions
|
||||
#ifndef _AFX_NO_AFXCMN_SUPPORT
|
||||
#include <afxcmn.h> // MFC support for Windows Common Controls
|
||||
#endif // _AFX_NO_AFXCMN_SUPPORT
|
||||
|
||||
|
||||
|
||||
|
||||
140
mozilla/network/cache/nu/tests/cb/cb.cpp
vendored
Normal file
140
mozilla/network/cache/nu/tests/cb/cb.cpp
vendored
Normal file
@@ -0,0 +1,140 @@
|
||||
// cb.cpp : Defines the class behaviors for the application.
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "cb.h"
|
||||
|
||||
#include "MainFrm.h"
|
||||
#include "cbDoc.h"
|
||||
#include "cbView.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CCbApp
|
||||
|
||||
BEGIN_MESSAGE_MAP(CCbApp, CWinApp)
|
||||
//{{AFX_MSG_MAP(CCbApp)
|
||||
ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
|
||||
//}}AFX_MSG_MAP
|
||||
// Standard file based document commands
|
||||
ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
|
||||
ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
|
||||
// Standard print setup command
|
||||
ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup)
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CCbApp construction
|
||||
|
||||
CCbApp::CCbApp()
|
||||
{
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// The one and only CCbApp object
|
||||
|
||||
CCbApp theApp;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CCbApp initialization
|
||||
|
||||
BOOL CCbApp::InitInstance()
|
||||
{
|
||||
// Standard initialization
|
||||
|
||||
#ifdef _AFXDLL
|
||||
Enable3dControls(); // Call this when using MFC in a shared DLL
|
||||
#else
|
||||
Enable3dControlsStatic(); // Call this when linking to MFC statically
|
||||
#endif
|
||||
|
||||
LoadStdProfileSettings(0); // Load standard INI file options (including MRU)
|
||||
|
||||
// Register document templates
|
||||
|
||||
CSingleDocTemplate* pDocTemplate;
|
||||
pDocTemplate = new CSingleDocTemplate(
|
||||
IDR_MAINFRAME,
|
||||
RUNTIME_CLASS(CCbDoc),
|
||||
RUNTIME_CLASS(CMainFrame), // main SDI frame window
|
||||
RUNTIME_CLASS(CCbView));
|
||||
AddDocTemplate(pDocTemplate);
|
||||
|
||||
// Enable DDE Execute open
|
||||
EnableShellOpen();
|
||||
RegisterShellFileTypes(TRUE);
|
||||
|
||||
// Parse command line for standard shell commands, DDE, file open
|
||||
CCommandLineInfo cmdInfo;
|
||||
ParseCommandLine(cmdInfo);
|
||||
|
||||
// Dispatch commands specified on the command line
|
||||
if (!ProcessShellCommand(cmdInfo))
|
||||
return FALSE;
|
||||
|
||||
// Enable drag/drop open
|
||||
m_pMainWnd->DragAcceptFiles();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CAboutDlg dialog used for App About
|
||||
|
||||
class CAboutDlg : public CDialog
|
||||
{
|
||||
public:
|
||||
CAboutDlg();
|
||||
|
||||
// Dialog Data
|
||||
//{{AFX_DATA(CAboutDlg)
|
||||
enum { IDD = IDD_ABOUTBOX };
|
||||
//}}AFX_DATA
|
||||
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CAboutDlg)
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
protected:
|
||||
//{{AFX_MSG(CAboutDlg)
|
||||
// No message handlers
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
|
||||
{
|
||||
//{{AFX_DATA_INIT(CAboutDlg)
|
||||
//}}AFX_DATA_INIT
|
||||
}
|
||||
|
||||
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
//{{AFX_DATA_MAP(CAboutDlg)
|
||||
//}}AFX_DATA_MAP
|
||||
}
|
||||
|
||||
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
|
||||
//{{AFX_MSG_MAP(CAboutDlg)
|
||||
// No message handlers
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
// App command to run the dialog
|
||||
void CCbApp::OnAppAbout()
|
||||
{
|
||||
CAboutDlg aboutDlg;
|
||||
aboutDlg.DoModal();
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CCbApp commands
|
||||
36
mozilla/network/cache/nu/tests/cb/cb.h
vendored
Normal file
36
mozilla/network/cache/nu/tests/cb/cb.h
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
// cb.h : main header file for the CB application
|
||||
//
|
||||
|
||||
#ifndef __AFXWIN_H__
|
||||
#error include 'stdafx.h' before including this file for PCH
|
||||
#endif
|
||||
|
||||
#include "resource.h" // main symbols
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CCbApp:
|
||||
// See cb.cpp for the implementation of this class
|
||||
//
|
||||
|
||||
class CCbApp : public CWinApp
|
||||
{
|
||||
public:
|
||||
CCbApp();
|
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CCbApp)
|
||||
public:
|
||||
virtual BOOL InitInstance();
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
|
||||
//{{AFX_MSG(CCbApp)
|
||||
afx_msg void OnAppAbout();
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
504
mozilla/network/cache/nu/tests/cb/cb.mak
vendored
Normal file
504
mozilla/network/cache/nu/tests/cb/cb.mak
vendored
Normal file
@@ -0,0 +1,504 @@
|
||||
# Microsoft Developer Studio Generated NMAKE File, Format Version 4.20
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Application" 0x0101
|
||||
|
||||
!IF "$(CFG)" == ""
|
||||
CFG=cb - Win32 Debug
|
||||
!MESSAGE No configuration specified. Defaulting to cb - Win32 Debug.
|
||||
!ENDIF
|
||||
|
||||
!IF "$(CFG)" != "cb - Win32 Release" && "$(CFG)" != "cb - Win32 Debug"
|
||||
!MESSAGE Invalid configuration "$(CFG)" specified.
|
||||
!MESSAGE You can specify a configuration when running NMAKE on this makefile
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "cb.mak" CFG="cb - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "cb - Win32 Release" (based on "Win32 (x86) Application")
|
||||
!MESSAGE "cb - Win32 Debug" (based on "Win32 (x86) Application")
|
||||
!MESSAGE
|
||||
!ERROR An invalid configuration is specified.
|
||||
!ENDIF
|
||||
|
||||
!IF "$(OS)" == "Windows_NT"
|
||||
NULL=
|
||||
!ELSE
|
||||
NULL=nul
|
||||
!ENDIF
|
||||
################################################################################
|
||||
# Begin Project
|
||||
# PROP Target_Last_Scanned "cb - Win32 Debug"
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
MTL=mktyplib.exe
|
||||
|
||||
!IF "$(CFG)" == "cb - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 6
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 6
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release"
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Target_Dir ""
|
||||
OUTDIR=.\Release
|
||||
INTDIR=.\Release
|
||||
|
||||
ALL : "$(OUTDIR)\cb.exe"
|
||||
|
||||
CLEAN :
|
||||
-@erase "$(INTDIR)\CacheTreeView.obj"
|
||||
-@erase "$(INTDIR)\cb.obj"
|
||||
-@erase "$(INTDIR)\cb.pch"
|
||||
-@erase "$(INTDIR)\cb.res"
|
||||
-@erase "$(INTDIR)\cbDoc.obj"
|
||||
-@erase "$(INTDIR)\cbView.obj"
|
||||
-@erase "$(INTDIR)\MainFrm.obj"
|
||||
-@erase "$(INTDIR)\StdAfx.obj"
|
||||
-@erase "$(OUTDIR)\cb.exe"
|
||||
|
||||
"$(OUTDIR)" :
|
||||
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
|
||||
|
||||
# ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /Yu"stdafx.h" /c
|
||||
# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\..\..\..\..\dist\public\cache" /I "..\..\..\..\..\dist\win32_d.obj\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /Yu"stdafx.h" /c
|
||||
CPP_PROJ=/nologo /MD /W3 /GX /O2 /I "..\..\..\..\..\dist\public\cache" /I\
|
||||
"..\..\..\..\..\dist\win32_d.obj\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS"\
|
||||
/D "_AFXDLL" /D "_MBCS" /Fp"$(INTDIR)/cb.pch" /Yu"stdafx.h" /Fo"$(INTDIR)/" /c
|
||||
CPP_OBJS=.\Release/
|
||||
CPP_SBRS=.\.
|
||||
# ADD BASE MTL /nologo /D "NDEBUG" /win32
|
||||
# ADD MTL /nologo /D "NDEBUG" /win32
|
||||
MTL_PROJ=/nologo /D "NDEBUG" /win32
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG" /d "_AFXDLL"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG" /d "_AFXDLL"
|
||||
RSC_PROJ=/l 0x409 /fo"$(INTDIR)/cb.res" /d "NDEBUG" /d "_AFXDLL"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
BSC32_FLAGS=/nologo /o"$(OUTDIR)/cb.bsc"
|
||||
BSC32_SBRS= \
|
||||
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 /nologo /subsystem:windows /machine:I386
|
||||
# ADD LINK32 /nologo /subsystem:windows /machine:I386
|
||||
LINK32_FLAGS=/nologo /subsystem:windows /incremental:no /pdb:"$(OUTDIR)/cb.pdb"\
|
||||
/machine:I386 /out:"$(OUTDIR)/cb.exe"
|
||||
LINK32_OBJS= \
|
||||
"$(INTDIR)\CacheTreeView.obj" \
|
||||
"$(INTDIR)\cb.obj" \
|
||||
"$(INTDIR)\cb.res" \
|
||||
"$(INTDIR)\cbDoc.obj" \
|
||||
"$(INTDIR)\cbView.obj" \
|
||||
"$(INTDIR)\MainFrm.obj" \
|
||||
"$(INTDIR)\StdAfx.obj" \
|
||||
"..\..\..\..\..\dist\WIN32_D.OBJ\lib\cachelib.lib"
|
||||
|
||||
"$(OUTDIR)\cb.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
|
||||
$(LINK32) @<<
|
||||
$(LINK32_FLAGS) $(LINK32_OBJS)
|
||||
<<
|
||||
|
||||
!ELSEIF "$(CFG)" == "cb - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 6
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 6
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Debug"
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Target_Dir ""
|
||||
OUTDIR=.\Debug
|
||||
INTDIR=.\Debug
|
||||
|
||||
ALL : "$(OUTDIR)\cb.exe" "$(OUTDIR)\cb.bsc"
|
||||
|
||||
CLEAN :
|
||||
-@erase "$(INTDIR)\CacheTreeView.obj"
|
||||
-@erase "$(INTDIR)\CacheTreeView.sbr"
|
||||
-@erase "$(INTDIR)\cb.obj"
|
||||
-@erase "$(INTDIR)\cb.pch"
|
||||
-@erase "$(INTDIR)\cb.res"
|
||||
-@erase "$(INTDIR)\cb.sbr"
|
||||
-@erase "$(INTDIR)\cbDoc.obj"
|
||||
-@erase "$(INTDIR)\cbDoc.sbr"
|
||||
-@erase "$(INTDIR)\cbView.obj"
|
||||
-@erase "$(INTDIR)\cbView.sbr"
|
||||
-@erase "$(INTDIR)\MainFrm.obj"
|
||||
-@erase "$(INTDIR)\MainFrm.sbr"
|
||||
-@erase "$(INTDIR)\StdAfx.obj"
|
||||
-@erase "$(INTDIR)\StdAfx.sbr"
|
||||
-@erase "$(INTDIR)\vc40.idb"
|
||||
-@erase "$(INTDIR)\vc40.pdb"
|
||||
-@erase "$(OUTDIR)\cb.bsc"
|
||||
-@erase "$(OUTDIR)\cb.exe"
|
||||
-@erase "$(OUTDIR)\cb.ilk"
|
||||
-@erase "$(OUTDIR)\cb.pdb"
|
||||
|
||||
"$(OUTDIR)" :
|
||||
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
|
||||
|
||||
# ADD BASE CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /Yu"stdafx.h" /c
|
||||
# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\..\..\..\dist\public\cache" /I "..\..\..\..\..\dist\win32_d.obj\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /FR /Yu"stdafx.h" /V"ERBOSE:lib" /c
|
||||
CPP_PROJ=/nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\..\..\..\dist\public\cache"\
|
||||
/I "..\..\..\..\..\dist\win32_d.obj\include" /D "WIN32" /D "_DEBUG" /D\
|
||||
"_WINDOWS" /D "_AFXDLL" /D "_MBCS" /FR"$(INTDIR)/" /Fp"$(INTDIR)/cb.pch"\
|
||||
/Yu"stdafx.h" /Fo"$(INTDIR)/" /Fd"$(INTDIR)/" /V"ERBOSE:lib" /c
|
||||
CPP_OBJS=.\Debug/
|
||||
CPP_SBRS=.\Debug/
|
||||
# ADD BASE MTL /nologo /D "_DEBUG" /win32
|
||||
# ADD MTL /nologo /D "_DEBUG" /win32
|
||||
MTL_PROJ=/nologo /D "_DEBUG" /win32
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG" /d "_AFXDLL"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG" /d "_AFXDLL"
|
||||
RSC_PROJ=/l 0x409 /fo"$(INTDIR)/cb.res" /d "_DEBUG" /d "_AFXDLL"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
BSC32_FLAGS=/nologo /o"$(OUTDIR)/cb.bsc"
|
||||
BSC32_SBRS= \
|
||||
"$(INTDIR)\CacheTreeView.sbr" \
|
||||
"$(INTDIR)\cb.sbr" \
|
||||
"$(INTDIR)\cbDoc.sbr" \
|
||||
"$(INTDIR)\cbView.sbr" \
|
||||
"$(INTDIR)\MainFrm.sbr" \
|
||||
"$(INTDIR)\StdAfx.sbr"
|
||||
|
||||
"$(OUTDIR)\cb.bsc" : "$(OUTDIR)" $(BSC32_SBRS)
|
||||
$(BSC32) @<<
|
||||
$(BSC32_FLAGS) $(BSC32_SBRS)
|
||||
<<
|
||||
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 /nologo /subsystem:windows /debug /machine:I386
|
||||
# ADD LINK32 ..\..\..\..\..\dist\win32_d.obj\lib\cachelib.lib;..\..\..\..\..\dist\win32_d.obj\lib\libnspr21.lib /nologo /subsystem:windows /debug /machine:I386
|
||||
# SUBTRACT LINK32 /nodefaultlib
|
||||
LINK32_FLAGS=\
|
||||
..\..\..\..\..\dist\win32_d.obj\lib\cachelib.lib;..\..\..\..\..\dist\win32_d.obj\lib\libnspr21.lib\
|
||||
/nologo /subsystem:windows /incremental:yes /pdb:"$(OUTDIR)/cb.pdb" /debug\
|
||||
/machine:I386 /out:"$(OUTDIR)/cb.exe"
|
||||
LINK32_OBJS= \
|
||||
"$(INTDIR)\CacheTreeView.obj" \
|
||||
"$(INTDIR)\cb.obj" \
|
||||
"$(INTDIR)\cb.res" \
|
||||
"$(INTDIR)\cbDoc.obj" \
|
||||
"$(INTDIR)\cbView.obj" \
|
||||
"$(INTDIR)\MainFrm.obj" \
|
||||
"$(INTDIR)\StdAfx.obj" \
|
||||
"..\..\..\..\..\dist\WIN32_D.OBJ\lib\cachelib.lib"
|
||||
|
||||
"$(OUTDIR)\cb.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
|
||||
$(LINK32) @<<
|
||||
$(LINK32_FLAGS) $(LINK32_OBJS)
|
||||
<<
|
||||
|
||||
!ENDIF
|
||||
|
||||
.c{$(CPP_OBJS)}.obj:
|
||||
$(CPP) $(CPP_PROJ) $<
|
||||
|
||||
.cpp{$(CPP_OBJS)}.obj:
|
||||
$(CPP) $(CPP_PROJ) $<
|
||||
|
||||
.cxx{$(CPP_OBJS)}.obj:
|
||||
$(CPP) $(CPP_PROJ) $<
|
||||
|
||||
.c{$(CPP_SBRS)}.sbr:
|
||||
$(CPP) $(CPP_PROJ) $<
|
||||
|
||||
.cpp{$(CPP_SBRS)}.sbr:
|
||||
$(CPP) $(CPP_PROJ) $<
|
||||
|
||||
.cxx{$(CPP_SBRS)}.sbr:
|
||||
$(CPP) $(CPP_PROJ) $<
|
||||
|
||||
################################################################################
|
||||
# Begin Target
|
||||
|
||||
# Name "cb - Win32 Release"
|
||||
# Name "cb - Win32 Debug"
|
||||
|
||||
!IF "$(CFG)" == "cb - Win32 Release"
|
||||
|
||||
!ELSEIF "$(CFG)" == "cb - Win32 Debug"
|
||||
|
||||
!ENDIF
|
||||
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\cb.cpp
|
||||
DEP_CPP_CB_CP=\
|
||||
".\cb.h"\
|
||||
".\cbDoc.h"\
|
||||
".\cbView.h"\
|
||||
".\MainFrm.h"\
|
||||
".\StdAfx.h"\
|
||||
|
||||
|
||||
!IF "$(CFG)" == "cb - Win32 Release"
|
||||
|
||||
|
||||
"$(INTDIR)\cb.obj" : $(SOURCE) $(DEP_CPP_CB_CP) "$(INTDIR)" "$(INTDIR)\cb.pch"
|
||||
|
||||
|
||||
!ELSEIF "$(CFG)" == "cb - Win32 Debug"
|
||||
|
||||
|
||||
"$(INTDIR)\cb.obj" : $(SOURCE) $(DEP_CPP_CB_CP) "$(INTDIR)" "$(INTDIR)\cb.pch"
|
||||
|
||||
"$(INTDIR)\cb.sbr" : $(SOURCE) $(DEP_CPP_CB_CP) "$(INTDIR)" "$(INTDIR)\cb.pch"
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\StdAfx.cpp
|
||||
DEP_CPP_STDAF=\
|
||||
".\StdAfx.h"\
|
||||
|
||||
|
||||
!IF "$(CFG)" == "cb - Win32 Release"
|
||||
|
||||
# ADD CPP /Yc"stdafx.h"
|
||||
|
||||
BuildCmds= \
|
||||
$(CPP) /nologo /MD /W3 /GX /O2 /I "..\..\..\..\..\dist\public\cache" /I\
|
||||
"..\..\..\..\..\dist\win32_d.obj\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS"\
|
||||
/D "_AFXDLL" /D "_MBCS" /Fp"$(INTDIR)/cb.pch" /Yc"stdafx.h" /Fo"$(INTDIR)/" /c\
|
||||
$(SOURCE) \
|
||||
|
||||
|
||||
"$(INTDIR)\StdAfx.obj" : $(SOURCE) $(DEP_CPP_STDAF) "$(INTDIR)"
|
||||
$(BuildCmds)
|
||||
|
||||
"$(INTDIR)\cb.pch" : $(SOURCE) $(DEP_CPP_STDAF) "$(INTDIR)"
|
||||
$(BuildCmds)
|
||||
|
||||
!ELSEIF "$(CFG)" == "cb - Win32 Debug"
|
||||
|
||||
# ADD CPP /Yc"stdafx.h"
|
||||
|
||||
BuildCmds= \
|
||||
$(CPP) /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\..\..\..\dist\public\cache"\
|
||||
/I "..\..\..\..\..\dist\win32_d.obj\include" /D "WIN32" /D "_DEBUG" /D\
|
||||
"_WINDOWS" /D "_AFXDLL" /D "_MBCS" /FR"$(INTDIR)/" /Fp"$(INTDIR)/cb.pch"\
|
||||
/Yc"stdafx.h" /Fo"$(INTDIR)/" /Fd"$(INTDIR)/" /V"ERBOSE:lib" /c $(SOURCE) \
|
||||
|
||||
|
||||
"$(INTDIR)\StdAfx.obj" : $(SOURCE) $(DEP_CPP_STDAF) "$(INTDIR)"
|
||||
$(BuildCmds)
|
||||
|
||||
"$(INTDIR)\StdAfx.sbr" : $(SOURCE) $(DEP_CPP_STDAF) "$(INTDIR)"
|
||||
$(BuildCmds)
|
||||
|
||||
"$(INTDIR)\cb.pch" : $(SOURCE) $(DEP_CPP_STDAF) "$(INTDIR)"
|
||||
$(BuildCmds)
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\MainFrm.cpp
|
||||
DEP_CPP_MAINF=\
|
||||
".\CacheTreeView.h"\
|
||||
".\cb.h"\
|
||||
".\MainFrm.h"\
|
||||
".\StdAfx.h"\
|
||||
|
||||
|
||||
!IF "$(CFG)" == "cb - Win32 Release"
|
||||
|
||||
|
||||
"$(INTDIR)\MainFrm.obj" : $(SOURCE) $(DEP_CPP_MAINF) "$(INTDIR)"\
|
||||
"$(INTDIR)\cb.pch"
|
||||
|
||||
|
||||
!ELSEIF "$(CFG)" == "cb - Win32 Debug"
|
||||
|
||||
|
||||
"$(INTDIR)\MainFrm.obj" : $(SOURCE) $(DEP_CPP_MAINF) "$(INTDIR)"\
|
||||
"$(INTDIR)\cb.pch"
|
||||
|
||||
"$(INTDIR)\MainFrm.sbr" : $(SOURCE) $(DEP_CPP_MAINF) "$(INTDIR)"\
|
||||
"$(INTDIR)\cb.pch"
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\cbDoc.cpp
|
||||
DEP_CPP_CBDOC=\
|
||||
".\CacheTreeView.h"\
|
||||
".\cb.h"\
|
||||
".\cbDoc.h"\
|
||||
".\StdAfx.h"\
|
||||
|
||||
|
||||
!IF "$(CFG)" == "cb - Win32 Release"
|
||||
|
||||
|
||||
"$(INTDIR)\cbDoc.obj" : $(SOURCE) $(DEP_CPP_CBDOC) "$(INTDIR)"\
|
||||
"$(INTDIR)\cb.pch"
|
||||
|
||||
|
||||
!ELSEIF "$(CFG)" == "cb - Win32 Debug"
|
||||
|
||||
|
||||
"$(INTDIR)\cbDoc.obj" : $(SOURCE) $(DEP_CPP_CBDOC) "$(INTDIR)"\
|
||||
"$(INTDIR)\cb.pch"
|
||||
|
||||
"$(INTDIR)\cbDoc.sbr" : $(SOURCE) $(DEP_CPP_CBDOC) "$(INTDIR)"\
|
||||
"$(INTDIR)\cb.pch"
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\cbView.cpp
|
||||
|
||||
!IF "$(CFG)" == "cb - Win32 Release"
|
||||
|
||||
DEP_CPP_CBVIE=\
|
||||
"..\..\..\..\..\dist\public\cache\nsCacheManager.h"\
|
||||
"..\..\..\..\..\dist\public\cache\nsCacheModule.h"\
|
||||
"..\..\..\..\..\dist\public\cache\nsCacheObject.h"\
|
||||
"..\..\..\..\..\dist\public\cache\nsDiskModule.h"\
|
||||
"..\..\..\..\..\dist\public\cache\nsMemCacheObject.h"\
|
||||
"..\..\..\..\..\dist\public\cache\nsMemModule.h"\
|
||||
"..\..\..\..\..\dist\win32_d.obj\include\obsolete\protypes.h"\
|
||||
"..\..\..\..\..\dist\win32_d.obj\include\prcpucfg.h"\
|
||||
"..\..\..\..\..\dist\win32_d.obj\include\prinrval.h"\
|
||||
"..\..\..\..\..\dist\win32_d.obj\include\prtypes.h"\
|
||||
".\cb.h"\
|
||||
".\cbDoc.h"\
|
||||
".\cbView.h"\
|
||||
".\MainFrm.h"\
|
||||
".\StdAfx.h"\
|
||||
|
||||
NODEP_CPP_CBVIE=\
|
||||
"..\..\..\..\..\dist\public\cache\nsISupports.h"\
|
||||
"..\..\..\..\..\dist\win32_d.obj\include\protypes.h"\
|
||||
|
||||
|
||||
"$(INTDIR)\cbView.obj" : $(SOURCE) $(DEP_CPP_CBVIE) "$(INTDIR)"\
|
||||
"$(INTDIR)\cb.pch"
|
||||
|
||||
|
||||
!ELSEIF "$(CFG)" == "cb - Win32 Debug"
|
||||
|
||||
DEP_CPP_CBVIE=\
|
||||
"..\..\..\..\..\dist\public\cache\nsCacheManager.h"\
|
||||
"..\..\..\..\..\dist\public\cache\nsCacheModule.h"\
|
||||
"..\..\..\..\..\dist\public\cache\nsCacheObject.h"\
|
||||
"..\..\..\..\..\dist\public\cache\nsDiskModule.h"\
|
||||
"..\..\..\..\..\dist\public\cache\nsMemCacheObject.h"\
|
||||
"..\..\..\..\..\dist\public\cache\nsMemModule.h"\
|
||||
"..\..\..\..\..\dist\win32_d.obj\include\obsolete\protypes.h"\
|
||||
"..\..\..\..\..\dist\win32_d.obj\include\prcpucfg.h"\
|
||||
"..\..\..\..\..\dist\win32_d.obj\include\prinrval.h"\
|
||||
"..\..\..\..\..\dist\win32_d.obj\include\prtypes.h"\
|
||||
".\cb.h"\
|
||||
".\cbDoc.h"\
|
||||
".\cbView.h"\
|
||||
".\MainFrm.h"\
|
||||
".\StdAfx.h"\
|
||||
|
||||
NODEP_CPP_CBVIE=\
|
||||
"..\..\..\..\..\dist\public\cache\nsISupports.h"\
|
||||
"..\..\..\..\..\dist\win32_d.obj\include\protypes.h"\
|
||||
|
||||
|
||||
"$(INTDIR)\cbView.obj" : $(SOURCE) $(DEP_CPP_CBVIE) "$(INTDIR)"\
|
||||
"$(INTDIR)\cb.pch"
|
||||
|
||||
"$(INTDIR)\cbView.sbr" : $(SOURCE) $(DEP_CPP_CBVIE) "$(INTDIR)"\
|
||||
"$(INTDIR)\cb.pch"
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\cb.rc
|
||||
DEP_RSC_CB_RC=\
|
||||
".\res\cacheico.bmp"\
|
||||
".\res\cb.ico"\
|
||||
".\res\cb.rc2"\
|
||||
".\res\cbDoc.ico"\
|
||||
".\res\Toolbar.bmp"\
|
||||
|
||||
|
||||
"$(INTDIR)\cb.res" : $(SOURCE) $(DEP_RSC_CB_RC) "$(INTDIR)"
|
||||
$(RSC) $(RSC_PROJ) $(SOURCE)
|
||||
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\CacheTreeView.cpp
|
||||
DEP_CPP_CACHE=\
|
||||
".\CacheTreeView.h"\
|
||||
".\cb.h"\
|
||||
".\cbDoc.h"\
|
||||
".\StdAfx.h"\
|
||||
|
||||
|
||||
!IF "$(CFG)" == "cb - Win32 Release"
|
||||
|
||||
|
||||
"$(INTDIR)\CacheTreeView.obj" : $(SOURCE) $(DEP_CPP_CACHE) "$(INTDIR)"\
|
||||
"$(INTDIR)\cb.pch"
|
||||
|
||||
|
||||
!ELSEIF "$(CFG)" == "cb - Win32 Debug"
|
||||
|
||||
|
||||
"$(INTDIR)\CacheTreeView.obj" : $(SOURCE) $(DEP_CPP_CACHE) "$(INTDIR)"\
|
||||
"$(INTDIR)\cb.pch"
|
||||
|
||||
"$(INTDIR)\CacheTreeView.sbr" : $(SOURCE) $(DEP_CPP_CACHE) "$(INTDIR)"\
|
||||
"$(INTDIR)\cb.pch"
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=\work\mozilla\dist\WIN32_D.OBJ\lib\cachelib.lib
|
||||
|
||||
!IF "$(CFG)" == "cb - Win32 Release"
|
||||
|
||||
!ELSEIF "$(CFG)" == "cb - Win32 Debug"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
||||
################################################################################
|
||||
BIN
mozilla/network/cache/nu/tests/cb/cb.mdp
vendored
Normal file
BIN
mozilla/network/cache/nu/tests/cb/cb.mdp
vendored
Normal file
Binary file not shown.
387
mozilla/network/cache/nu/tests/cb/cb.rc
vendored
Normal file
387
mozilla/network/cache/nu/tests/cb/cb.rc
vendored
Normal file
@@ -0,0 +1,387 @@
|
||||
//Microsoft Developer Studio generated resource script.
|
||||
//
|
||||
#include "resource.h"
|
||||
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 2 resource.
|
||||
//
|
||||
#include "afxres.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// English (U.S.) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
|
||||
#ifdef _WIN32
|
||||
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||
#pragma code_page(1252)
|
||||
#endif //_WIN32
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TEXTINCLUDE
|
||||
//
|
||||
|
||||
1 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"resource.h\0"
|
||||
END
|
||||
|
||||
2 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"#include ""afxres.h""\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
3 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"#define _AFX_NO_OLE_RESOURCES\r\n"
|
||||
"#define _AFX_NO_TRACKER_RESOURCES\r\n"
|
||||
"#define _AFX_NO_PROPERTY_RESOURCES\r\n"
|
||||
"\r\n"
|
||||
"#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n"
|
||||
"#ifdef _WIN32\r\n"
|
||||
"LANGUAGE 9, 1\r\n"
|
||||
"#pragma code_page(1252)\r\n"
|
||||
"#endif\r\n"
|
||||
"#include ""res\\cb.rc2"" // non-Microsoft Visual C++ edited resources\r\n"
|
||||
"#include ""afxres.rc"" // Standard components\r\n"
|
||||
"#include ""afxprint.rc"" // printing/print preview resources\r\n"
|
||||
"#endif\0"
|
||||
END
|
||||
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Icon
|
||||
//
|
||||
|
||||
// Icon with lowest ID value placed first to ensure application icon
|
||||
// remains consistent on all systems.
|
||||
IDR_MAINFRAME ICON DISCARDABLE "res\\cb.ico"
|
||||
IDR_DBTYPE ICON DISCARDABLE "res\\cbDoc.ico"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Bitmap
|
||||
//
|
||||
|
||||
IDR_MAINFRAME BITMAP MOVEABLE PURE "res\\Toolbar.bmp"
|
||||
IDB_CACHEICONS BITMAP DISCARDABLE "res\\cacheico.bmp"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Toolbar
|
||||
//
|
||||
|
||||
IDR_MAINFRAME TOOLBAR DISCARDABLE 16, 15
|
||||
BEGIN
|
||||
BUTTON ID_FILE_NEW
|
||||
BUTTON ID_FILE_OPEN
|
||||
BUTTON ID_FILE_SAVE
|
||||
SEPARATOR
|
||||
BUTTON ID_EDIT_CUT
|
||||
BUTTON ID_EDIT_COPY
|
||||
BUTTON ID_EDIT_PASTE
|
||||
SEPARATOR
|
||||
BUTTON ID_FILE_PRINT
|
||||
BUTTON ID_APP_ABOUT
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Menu
|
||||
//
|
||||
|
||||
IDR_MAINFRAME MENU PRELOAD DISCARDABLE
|
||||
BEGIN
|
||||
POPUP "&File"
|
||||
BEGIN
|
||||
MENUITEM "&New\tCtrl+N", ID_FILE_NEW
|
||||
MENUITEM "&Open...\tCtrl+O", ID_FILE_OPEN
|
||||
MENUITEM "&Save\tCtrl+S", ID_FILE_SAVE
|
||||
MENUITEM "Save &As...", ID_FILE_SAVE_AS
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Print...\tCtrl+P", ID_FILE_PRINT
|
||||
MENUITEM "Print Pre&view", ID_FILE_PRINT_PREVIEW
|
||||
MENUITEM "P&rint Setup...", ID_FILE_PRINT_SETUP
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "E&xit", ID_APP_EXIT
|
||||
END
|
||||
POPUP "&Edit"
|
||||
BEGIN
|
||||
MENUITEM "&Undo\tCtrl+Z", ID_EDIT_UNDO
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Cu&t\tCtrl+X", ID_EDIT_CUT
|
||||
MENUITEM "&Copy\tCtrl+C", ID_EDIT_COPY
|
||||
MENUITEM "&Paste\tCtrl+V", ID_EDIT_PASTE
|
||||
END
|
||||
POPUP "&View"
|
||||
BEGIN
|
||||
MENUITEM "&Toolbar", ID_VIEW_TOOLBAR
|
||||
MENUITEM "&Status Bar", ID_VIEW_STATUS_BAR
|
||||
MENUITEM "S&plit", ID_WINDOW_SPLIT
|
||||
END
|
||||
POPUP "&Help"
|
||||
BEGIN
|
||||
MENUITEM "&About cb...", ID_APP_ABOUT
|
||||
END
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Accelerator
|
||||
//
|
||||
|
||||
IDR_MAINFRAME ACCELERATORS PRELOAD MOVEABLE PURE
|
||||
BEGIN
|
||||
"N", ID_FILE_NEW, VIRTKEY, CONTROL
|
||||
"O", ID_FILE_OPEN, VIRTKEY, CONTROL
|
||||
"S", ID_FILE_SAVE, VIRTKEY, CONTROL
|
||||
"P", ID_FILE_PRINT, VIRTKEY, CONTROL
|
||||
"Z", ID_EDIT_UNDO, VIRTKEY, CONTROL
|
||||
"X", ID_EDIT_CUT, VIRTKEY, CONTROL
|
||||
"C", ID_EDIT_COPY, VIRTKEY, CONTROL
|
||||
"V", ID_EDIT_PASTE, VIRTKEY, CONTROL
|
||||
VK_BACK, ID_EDIT_UNDO, VIRTKEY, ALT
|
||||
VK_DELETE, ID_EDIT_CUT, VIRTKEY, SHIFT
|
||||
VK_INSERT, ID_EDIT_COPY, VIRTKEY, CONTROL
|
||||
VK_INSERT, ID_EDIT_PASTE, VIRTKEY, SHIFT
|
||||
VK_F6, ID_NEXT_PANE, VIRTKEY
|
||||
VK_F6, ID_PREV_PANE, VIRTKEY, SHIFT
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Dialog
|
||||
//
|
||||
|
||||
IDD_ABOUTBOX DIALOG DISCARDABLE 0, 0, 217, 55
|
||||
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "About cb"
|
||||
FONT 8, "MS Sans Serif"
|
||||
BEGIN
|
||||
ICON IDR_MAINFRAME,IDC_STATIC,11,17,20,20
|
||||
LTEXT "cb Version 1.0",IDC_STATIC,40,10,119,8,SS_NOPREFIX
|
||||
LTEXT "Copyright © 1998",IDC_STATIC,40,25,119,8
|
||||
DEFPUSHBUTTON "OK",IDOK,178,7,32,14,WS_GROUP
|
||||
END
|
||||
|
||||
|
||||
#ifndef _MAC
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Version
|
||||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 1,0,0,1
|
||||
PRODUCTVERSION 1,0,0,1
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
#else
|
||||
FILEFLAGS 0x0L
|
||||
#endif
|
||||
FILEOS 0x4L
|
||||
FILETYPE 0x1L
|
||||
FILESUBTYPE 0x0L
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "040904B0"
|
||||
BEGIN
|
||||
VALUE "CompanyName", "\0"
|
||||
VALUE "FileDescription", "CB MFC Application\0"
|
||||
VALUE "FileVersion", "1, 0, 0, 1\0"
|
||||
VALUE "InternalName", "CB\0"
|
||||
VALUE "LegalCopyright", "Copyright © 1998\0"
|
||||
VALUE "LegalTrademarks", "\0"
|
||||
VALUE "OriginalFilename", "CB.EXE\0"
|
||||
VALUE "ProductName", "CB Application\0"
|
||||
VALUE "ProductVersion", "1, 0, 0, 1\0"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x409, 1200
|
||||
END
|
||||
END
|
||||
|
||||
#endif // !_MAC
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// DESIGNINFO
|
||||
//
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
GUIDELINES DESIGNINFO DISCARDABLE
|
||||
BEGIN
|
||||
IDD_ABOUTBOX, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 210
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 48
|
||||
END
|
||||
END
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// String Table
|
||||
//
|
||||
|
||||
STRINGTABLE PRELOAD DISCARDABLE
|
||||
BEGIN
|
||||
IDR_MAINFRAME "Cache Browser\n\nDB\n\n.DB\nCb.Document\nDB Document"
|
||||
END
|
||||
|
||||
STRINGTABLE PRELOAD DISCARDABLE
|
||||
BEGIN
|
||||
AFX_IDS_APP_TITLE "cb"
|
||||
AFX_IDS_IDLEMESSAGE "Ready"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
ID_INDICATOR_EXT "EXT"
|
||||
ID_INDICATOR_CAPS "CAP"
|
||||
ID_INDICATOR_NUM "NUM"
|
||||
ID_INDICATOR_SCRL "SCRL"
|
||||
ID_INDICATOR_OVR "OVR"
|
||||
ID_INDICATOR_REC "REC"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
ID_FILE_NEW "Create a new document\nNew"
|
||||
ID_FILE_OPEN "Open an existing document\nOpen"
|
||||
ID_FILE_CLOSE "Close the active document\nClose"
|
||||
ID_FILE_SAVE "Save the active document\nSave"
|
||||
ID_FILE_SAVE_AS "Save the active document with a new name\nSave As"
|
||||
ID_FILE_PAGE_SETUP "Change the printing options\nPage Setup"
|
||||
ID_FILE_PRINT_SETUP "Change the printer and printing options\nPrint Setup"
|
||||
ID_FILE_PRINT "Print the active document\nPrint"
|
||||
ID_FILE_PRINT_PREVIEW "Display full pages\nPrint Preview"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
ID_APP_ABOUT "Display program information, version number and copyright\nAbout"
|
||||
ID_APP_EXIT "Quit the application; prompts to save documents\nExit"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
ID_FILE_MRU_FILE1 "Open this document"
|
||||
ID_FILE_MRU_FILE2 "Open this document"
|
||||
ID_FILE_MRU_FILE3 "Open this document"
|
||||
ID_FILE_MRU_FILE4 "Open this document"
|
||||
ID_FILE_MRU_FILE5 "Open this document"
|
||||
ID_FILE_MRU_FILE6 "Open this document"
|
||||
ID_FILE_MRU_FILE7 "Open this document"
|
||||
ID_FILE_MRU_FILE8 "Open this document"
|
||||
ID_FILE_MRU_FILE9 "Open this document"
|
||||
ID_FILE_MRU_FILE10 "Open this document"
|
||||
ID_FILE_MRU_FILE11 "Open this document"
|
||||
ID_FILE_MRU_FILE12 "Open this document"
|
||||
ID_FILE_MRU_FILE13 "Open this document"
|
||||
ID_FILE_MRU_FILE14 "Open this document"
|
||||
ID_FILE_MRU_FILE15 "Open this document"
|
||||
ID_FILE_MRU_FILE16 "Open this document"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
ID_NEXT_PANE "Switch to the next window pane\nNext Pane"
|
||||
ID_PREV_PANE "Switch back to the previous window pane\nPrevious Pane"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
ID_WINDOW_SPLIT "Split the active window into panes\nSplit"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
ID_EDIT_CLEAR "Erase the selection\nErase"
|
||||
ID_EDIT_CLEAR_ALL "Erase everything\nErase All"
|
||||
ID_EDIT_COPY "Copy the selection and put it on the Clipboard\nCopy"
|
||||
ID_EDIT_CUT "Cut the selection and put it on the Clipboard\nCut"
|
||||
ID_EDIT_FIND "Find the specified text\nFind"
|
||||
ID_EDIT_PASTE "Insert Clipboard contents\nPaste"
|
||||
ID_EDIT_REPEAT "Repeat the last action\nRepeat"
|
||||
ID_EDIT_REPLACE "Replace specific text with different text\nReplace"
|
||||
ID_EDIT_SELECT_ALL "Select the entire document\nSelect All"
|
||||
ID_EDIT_UNDO "Undo the last action\nUndo"
|
||||
ID_EDIT_REDO "Redo the previously undone action\nRedo"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
ID_VIEW_TOOLBAR "Show or hide the toolbar\nToggle ToolBar"
|
||||
ID_VIEW_STATUS_BAR "Show or hide the status bar\nToggle StatusBar"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
AFX_IDS_SCSIZE "Change the window size"
|
||||
AFX_IDS_SCMOVE "Change the window position"
|
||||
AFX_IDS_SCMINIMIZE "Reduce the window to an icon"
|
||||
AFX_IDS_SCMAXIMIZE "Enlarge the window to full size"
|
||||
AFX_IDS_SCNEXTWINDOW "Switch to the next document window"
|
||||
AFX_IDS_SCPREVWINDOW "Switch to the previous document window"
|
||||
AFX_IDS_SCCLOSE "Close the active window and prompts to save the documents"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
AFX_IDS_SCRESTORE "Restore the window to normal size"
|
||||
AFX_IDS_SCTASKLIST "Activate Task List"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
AFX_IDS_PREVIEW_CLOSE "Close print preview mode\nCancel Preview"
|
||||
END
|
||||
|
||||
#endif // English (U.S.) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#ifndef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 3 resource.
|
||||
//
|
||||
#define _AFX_NO_OLE_RESOURCES
|
||||
#define _AFX_NO_TRACKER_RESOURCES
|
||||
#define _AFX_NO_PROPERTY_RESOURCES
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
|
||||
#ifdef _WIN32
|
||||
LANGUAGE 9, 1
|
||||
#pragma code_page(1252)
|
||||
#endif
|
||||
#include "res\cb.rc2" // non-Microsoft Visual C++ edited resources
|
||||
#include "afxres.rc" // Standard components
|
||||
#include "afxprint.rc" // printing/print preview resources
|
||||
#endif
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#endif // not APSTUDIO_INVOKED
|
||||
|
||||
75
mozilla/network/cache/nu/tests/cb/cbDoc.cpp
vendored
Normal file
75
mozilla/network/cache/nu/tests/cb/cbDoc.cpp
vendored
Normal file
@@ -0,0 +1,75 @@
|
||||
// cbDoc.cpp : implementation of the CCbDoc class
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "cb.h"
|
||||
|
||||
#include "cbDoc.h"
|
||||
#include "CacheTreeView.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CCbDoc
|
||||
|
||||
IMPLEMENT_DYNCREATE(CCbDoc, CDocument)
|
||||
|
||||
BEGIN_MESSAGE_MAP(CCbDoc, CDocument)
|
||||
//{{AFX_MSG_MAP(CCbDoc)
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CCbDoc construction/destruction
|
||||
|
||||
CCbDoc::CCbDoc()
|
||||
{
|
||||
}
|
||||
|
||||
CCbDoc::~CCbDoc()
|
||||
{
|
||||
}
|
||||
|
||||
BOOL CCbDoc::OnNewDocument()
|
||||
{
|
||||
if (!CDocument::OnNewDocument())
|
||||
return FALSE;
|
||||
if (m_pTreeView)
|
||||
m_pTreeView->Populate();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CCbDoc serialization
|
||||
|
||||
void CCbDoc::Serialize(CArchive& ar)
|
||||
{
|
||||
if (ar.IsStoring())
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CCbDoc diagnostics
|
||||
|
||||
#ifdef _DEBUG
|
||||
void CCbDoc::AssertValid() const
|
||||
{
|
||||
CDocument::AssertValid();
|
||||
}
|
||||
|
||||
void CCbDoc::Dump(CDumpContext& dc) const
|
||||
{
|
||||
CDocument::Dump(dc);
|
||||
}
|
||||
#endif //_DEBUG
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CCbDoc commands
|
||||
43
mozilla/network/cache/nu/tests/cb/cbDoc.h
vendored
Normal file
43
mozilla/network/cache/nu/tests/cb/cbDoc.h
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
// cbDoc.h : interface of the CCbDoc class
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
class CCacheTreeView;
|
||||
class CCbDoc : public CDocument
|
||||
{
|
||||
protected: // create from serialization only
|
||||
CCbDoc();
|
||||
DECLARE_DYNCREATE(CCbDoc)
|
||||
|
||||
// Attributes
|
||||
public:
|
||||
CCacheTreeView* m_pTreeView;
|
||||
// Operations
|
||||
public:
|
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CCbDoc)
|
||||
public:
|
||||
virtual BOOL OnNewDocument();
|
||||
virtual void Serialize(CArchive& ar);
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
public:
|
||||
virtual ~CCbDoc();
|
||||
#ifdef _DEBUG
|
||||
virtual void AssertValid() const;
|
||||
virtual void Dump(CDumpContext& dc) const;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
|
||||
// Generated message map functions
|
||||
protected:
|
||||
//{{AFX_MSG(CCbDoc)
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
168
mozilla/network/cache/nu/tests/cb/cbView.cpp
vendored
Normal file
168
mozilla/network/cache/nu/tests/cb/cbView.cpp
vendored
Normal file
@@ -0,0 +1,168 @@
|
||||
// cbView.cpp : implementation of the CCbView class
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "cb.h"
|
||||
|
||||
#include "cbDoc.h"
|
||||
#include "cbView.h"
|
||||
#include <afxcmn.h>
|
||||
#include "MainFrm.h"
|
||||
|
||||
#include "nsCacheManager.h"
|
||||
#include "nsMemModule.h"
|
||||
#include "nsDiskModule.h"
|
||||
#include "nsCacheObject.h"
|
||||
#include "nsTimeIt.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
#define ID_TREECTRL (WM_USER +1)
|
||||
|
||||
#define STATUS(s) ((CMainFrame*)GetParentFrame())->Status(s)
|
||||
|
||||
IMPLEMENT_DYNCREATE(CCbView, CView)
|
||||
|
||||
BEGIN_MESSAGE_MAP(CCbView, CView)
|
||||
//{{AFX_MSG_MAP(CCbView)
|
||||
//}}AFX_MSG_MAP
|
||||
// Standard printing commands
|
||||
ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
|
||||
ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
|
||||
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CCbView construction/destruction
|
||||
|
||||
CCbView::CCbView()
|
||||
{
|
||||
}
|
||||
|
||||
CCbView::~CCbView()
|
||||
{
|
||||
}
|
||||
|
||||
BOOL CCbView::PreCreateWindow(CREATESTRUCT& cs)
|
||||
{
|
||||
return CView::PreCreateWindow(cs);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CCbView drawing
|
||||
|
||||
void CCbView::OnDraw(CDC* pDC)
|
||||
{
|
||||
CRect rect;
|
||||
GetClientRect(&rect);
|
||||
|
||||
pDC->SetBkColor(RGB(192,192,192));
|
||||
pDC->FillSolidRect(rect, RGB(192,192,192));
|
||||
|
||||
rect.DeflateRect(10,10);
|
||||
pDC->DrawText(m_Mesg.GetBuffer(m_Mesg.GetLength()), -1, rect, DT_WORDBREAK | DT_EXPANDTABS);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CCbView printing
|
||||
|
||||
BOOL CCbView::OnPreparePrinting(CPrintInfo* pInfo)
|
||||
{
|
||||
// default preparation
|
||||
return DoPreparePrinting(pInfo);
|
||||
}
|
||||
|
||||
void CCbView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
|
||||
{
|
||||
}
|
||||
|
||||
void CCbView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
|
||||
{
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CCbView diagnostics
|
||||
|
||||
#ifdef _DEBUG
|
||||
void CCbView::AssertValid() const
|
||||
{
|
||||
CView::AssertValid();
|
||||
}
|
||||
|
||||
void CCbView::Dump(CDumpContext& dc) const
|
||||
{
|
||||
CView::Dump(dc);
|
||||
}
|
||||
|
||||
CCbDoc* CCbView::GetDocument() // non-debug version is inline
|
||||
{
|
||||
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CCbDoc)));
|
||||
return (CCbDoc*)m_pDocument;
|
||||
}
|
||||
#endif //_DEBUG
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CCbView message handlers
|
||||
|
||||
void CCbView::OnInitialUpdate()
|
||||
{
|
||||
STATUS("Loading lib...");
|
||||
|
||||
nsCacheManager* pCM = nsCacheManager::GetInstance();
|
||||
nsMemModule* pMM = new nsMemModule();
|
||||
pCM->AddModule(pMM);
|
||||
|
||||
nsCacheObject* pCO = new nsCacheObject("http://www.netscape.com/");
|
||||
pCO->Etag("Etag-testing");
|
||||
pCO->Size(2250);
|
||||
pCO->LastModified(time(0));
|
||||
pMM->AddObject(pCO);
|
||||
|
||||
int j = 10000;
|
||||
char tmpBuff[10];
|
||||
while (j--)
|
||||
{
|
||||
pCO = new nsCacheObject(itoa(j,tmpBuff,10));
|
||||
pMM->AddObject(pCO);
|
||||
}
|
||||
m_Mesg += itoa(pMM->Entries(), tmpBuff, 10);
|
||||
m_Mesg += " nsCacheObject(s) added.\n";
|
||||
|
||||
char* traceBuff = (char*) pCM->Trace();
|
||||
m_Mesg += "-----------------\n";
|
||||
m_Mesg += traceBuff;
|
||||
delete[] traceBuff;
|
||||
traceBuff = (char*) pMM->Trace();
|
||||
m_Mesg += traceBuff;
|
||||
delete[] traceBuff;
|
||||
|
||||
m_Mesg += "-----------------\n";
|
||||
|
||||
|
||||
char buffer[10];
|
||||
m_Mesg += "Worst case time= ";
|
||||
m_Mesg += itoa(pCM->WorstCaseTime(), buffer, 10);
|
||||
m_Mesg += " microsec.\n";
|
||||
|
||||
PRUint32 t;
|
||||
{
|
||||
nsTimeIt tmp(t);
|
||||
if (pMM->Contains("999"))
|
||||
m_Mesg += "!";
|
||||
}
|
||||
m_Mesg += "-----------------\n";
|
||||
m_Mesg += "Found in ";
|
||||
m_Mesg += itoa(t, buffer, 10);
|
||||
m_Mesg += " microsec.\n";
|
||||
|
||||
// delete pMM;
|
||||
// pMM = 0;
|
||||
|
||||
CView::OnInitialUpdate();
|
||||
}
|
||||
|
||||
|
||||
54
mozilla/network/cache/nu/tests/cb/cbView.h
vendored
Normal file
54
mozilla/network/cache/nu/tests/cb/cbView.h
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
// cbView.h : interface of the CCbView class
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
class CCbView : public CView
|
||||
{
|
||||
protected: // create from serialization only
|
||||
CCbView();
|
||||
DECLARE_DYNCREATE(CCbView)
|
||||
|
||||
// Attributes
|
||||
public:
|
||||
CCbDoc* GetDocument();
|
||||
|
||||
// Operations
|
||||
public:
|
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CCbView)
|
||||
public:
|
||||
virtual void OnDraw(CDC* pDC); // overridden to draw this view
|
||||
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
|
||||
virtual void OnInitialUpdate();
|
||||
protected:
|
||||
virtual BOOL OnPreparePrinting(CPrintInfo* pInfo);
|
||||
virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo);
|
||||
virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo);
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
public:
|
||||
virtual ~CCbView();
|
||||
#ifdef _DEBUG
|
||||
virtual void AssertValid() const;
|
||||
virtual void Dump(CDumpContext& dc) const;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
|
||||
// Generated message map functions
|
||||
protected:
|
||||
//{{AFX_MSG(CCbView)
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
|
||||
CString m_Mesg;
|
||||
};
|
||||
|
||||
#ifndef _DEBUG // debug version in cbView.cpp
|
||||
inline CCbDoc* CCbView::GetDocument()
|
||||
{ return (CCbDoc*)m_pDocument; }
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
25
mozilla/network/cache/nu/tests/cb/nsTimeIt.h
vendored
Normal file
25
mozilla/network/cache/nu/tests/cb/nsTimeIt.h
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
/* A class to time excursion events */
|
||||
/* declare an object of this class within the scope to be timed. */
|
||||
#include <prtypes.h>
|
||||
#include <prinrval.h>
|
||||
|
||||
class nsTimeIt
|
||||
{
|
||||
public:
|
||||
nsTimeIt(PRUint32& tmp);
|
||||
~nsTimeIt();
|
||||
private:
|
||||
PRIntervalTime t;
|
||||
PRUint32& dest;
|
||||
};
|
||||
|
||||
inline
|
||||
nsTimeIt::nsTimeIt(PRUint32& tmp):t(PR_IntervalNow()), dest(tmp)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
nsTimeIt::~nsTimeIt()
|
||||
{
|
||||
dest = PR_IntervalToMicroseconds(PR_IntervalNow()-t);
|
||||
}
|
||||
BIN
mozilla/network/cache/nu/tests/cb/res/Toolbar.bmp
vendored
Normal file
BIN
mozilla/network/cache/nu/tests/cb/res/Toolbar.bmp
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
BIN
mozilla/network/cache/nu/tests/cb/res/cacheico.bmp
vendored
Normal file
BIN
mozilla/network/cache/nu/tests/cb/res/cacheico.bmp
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 502 B |
BIN
mozilla/network/cache/nu/tests/cb/res/cb.ico
vendored
Normal file
BIN
mozilla/network/cache/nu/tests/cb/res/cb.ico
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
13
mozilla/network/cache/nu/tests/cb/res/cb.rc2
vendored
Normal file
13
mozilla/network/cache/nu/tests/cb/res/cb.rc2
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
//
|
||||
// CB.RC2 - resources Microsoft Visual C++ does not edit directly
|
||||
//
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#error this file is not editable by Microsoft Visual C++
|
||||
#endif //APSTUDIO_INVOKED
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Add manually edited resources here...
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
BIN
mozilla/network/cache/nu/tests/cb/res/cbDoc.ico
vendored
Normal file
BIN
mozilla/network/cache/nu/tests/cb/res/cbDoc.ico
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
20
mozilla/network/cache/nu/tests/cb/resource.h
vendored
Normal file
20
mozilla/network/cache/nu/tests/cb/resource.h
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Developer Studio generated include file.
|
||||
// Used by cb.rc
|
||||
//
|
||||
#define IDD_ABOUTBOX 100
|
||||
#define IDR_MAINFRAME 128
|
||||
#define IDR_DBTYPE 129
|
||||
#define IDB_CACHEICONS 130
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_3D_CONTROLS 1
|
||||
#define _APS_NEXT_RESOURCE_VALUE 131
|
||||
#define _APS_NEXT_COMMAND_VALUE 32771
|
||||
#define _APS_NEXT_CONTROL_VALUE 1000
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
#endif
|
||||
5
mozilla/network/client/MANIFEST
Normal file
5
mozilla/network/client/MANIFEST
Normal file
@@ -0,0 +1,5 @@
|
||||
#
|
||||
# This is a list of local files which get copied to the mozilla:dist directory
|
||||
#
|
||||
|
||||
cnetinit.h
|
||||
36
mozilla/network/client/Makefile
Normal file
36
mozilla/network/client/Makefile
Normal file
@@ -0,0 +1,36 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH = ../..
|
||||
|
||||
MODULE = cnetinit
|
||||
|
||||
ifndef MODULAR_NETLIB
|
||||
LIBRARY_NAME = cnetinit
|
||||
|
||||
CSRCS = \
|
||||
cnetinit.c \
|
||||
mkfe.c \
|
||||
$(NULL)
|
||||
endif
|
||||
|
||||
EXPORTS= cnetinit.h
|
||||
|
||||
REQUIRES = netcache network img layer fileurl httpurl ftpurl abouturl \
|
||||
gophurl jsurl remoturl dataurl util java jtools
|
||||
|
||||
include $(DEPTH)/config/rules.mk
|
||||
293
mozilla/network/client/cnetinit.c
Normal file
293
mozilla/network/client/cnetinit.c
Normal file
@@ -0,0 +1,293 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "xp.h"
|
||||
#include "mkutils.h"
|
||||
#include "netutils.h"
|
||||
#include "mkselect.h"
|
||||
#include "mktcp.h"
|
||||
#include "mkgeturl.h"
|
||||
#include "plstr.h"
|
||||
#include "prmem.h"
|
||||
|
||||
#include "fileurl.h"
|
||||
#include "httpurl.h"
|
||||
#include "ftpurl.h"
|
||||
#include "abouturl.h"
|
||||
#include "gophurl.h"
|
||||
#include "jsurl.h"
|
||||
#include "fileurl.h"
|
||||
#include "remoturl.h"
|
||||
#include "dataurl.h"
|
||||
#include "netcache.h"
|
||||
|
||||
#if defined(JAVA)
|
||||
#include "marimurl.h"
|
||||
#endif
|
||||
|
||||
/* For random protocols */
|
||||
#include "htmldlgs.h"
|
||||
#include "libevent.h"
|
||||
#include "libi18n.h"
|
||||
#include "secnav.h"
|
||||
extern int MK_MALFORMED_URL_ERROR;
|
||||
|
||||
/* For about handlers */
|
||||
#include "il_strm.h"
|
||||
#include "glhist.h"
|
||||
|
||||
PRIVATE void net_InitTotallyRandomStuffPeopleAddedProtocols(void);
|
||||
PRIVATE void net_InitAboutURLs();
|
||||
|
||||
PUBLIC void
|
||||
NET_ClientProtocolInitialize(void)
|
||||
{
|
||||
|
||||
NET_InitFileProtocol();
|
||||
NET_InitHTTPProtocol();
|
||||
NET_InitMemCacProtocol();
|
||||
NET_InitFTPProtocol();
|
||||
NET_InitAboutProtocol();
|
||||
NET_InitGopherProtocol();
|
||||
NET_InitMochaProtocol();
|
||||
NET_InitRemoteProtocol();
|
||||
NET_InitDataURLProtocol();
|
||||
|
||||
#ifdef JAVA
|
||||
NET_InitMarimbaProtocol();
|
||||
#endif
|
||||
|
||||
net_InitTotallyRandomStuffPeopleAddedProtocols();
|
||||
|
||||
net_InitAboutURLs();
|
||||
}
|
||||
|
||||
/* print out security URL
|
||||
*/
|
||||
PRIVATE int net_output_security_url(ActiveEntry * cur_entry, MWContext *cx)
|
||||
{
|
||||
NET_StreamClass * stream;
|
||||
char * content_type;
|
||||
char * which = cur_entry->URL_s->address;
|
||||
char * colon = PL_strchr (which, ':');
|
||||
|
||||
if (colon)
|
||||
{
|
||||
/* found the first colon; now find the question mark
|
||||
(as in "about:security?certs"). */
|
||||
which = colon + 1;
|
||||
colon = PL_strchr (which, '?');
|
||||
if (colon)
|
||||
which = colon + 1;
|
||||
else
|
||||
which = which + PL_strlen (which); /* give it "" */
|
||||
}
|
||||
|
||||
content_type = SECNAV_SecURLContentType(which);
|
||||
if (!content_type) {
|
||||
cur_entry->status = MK_MALFORMED_URL_ERROR;
|
||||
|
||||
} else if (!PL_strcasecmp(content_type, "advisor")) {
|
||||
cur_entry->status = SECNAV_SecHandleSecurityAdvisorURL(cx, which);
|
||||
|
||||
} else {
|
||||
int status;
|
||||
|
||||
StrAllocCopy(cur_entry->URL_s->content_type, content_type);
|
||||
|
||||
cur_entry->format_out = CLEAR_CACHE_BIT(cur_entry->format_out);
|
||||
|
||||
stream = NET_StreamBuilder(cur_entry->format_out,
|
||||
cur_entry->URL_s, cur_entry->window_id);
|
||||
|
||||
if (!stream)
|
||||
return(MK_UNABLE_TO_CONVERT);
|
||||
|
||||
status = SECNAV_SecURLData(which, stream, cx);
|
||||
|
||||
if (status >= 0) {
|
||||
(*stream->complete) (stream);
|
||||
} else {
|
||||
(*stream->abort) (stream, status);
|
||||
}
|
||||
|
||||
cur_entry->status = status;
|
||||
|
||||
FREE(stream);
|
||||
}
|
||||
|
||||
return(-1);
|
||||
}
|
||||
|
||||
PRIVATE int32
|
||||
net_SecurityURLLoad(ActiveEntry *ce)
|
||||
{
|
||||
if(ce->URL_s)
|
||||
StrAllocCopy(ce->URL_s->charset, INTL_ResourceCharSet());
|
||||
return net_output_security_url(ce, ce->window_id);
|
||||
}
|
||||
|
||||
PRIVATE int32
|
||||
net_SeclibURLLoad(ActiveEntry *ce)
|
||||
{
|
||||
if(ce->URL_s)
|
||||
StrAllocCopy(ce->URL_s->charset, INTL_ResourceCharSet());
|
||||
SECNAV_HandleInternalSecURL(ce->URL_s, ce->window_id);
|
||||
return -1;
|
||||
}
|
||||
|
||||
PRIVATE int32
|
||||
net_HTMLPanelLoad(ActiveEntry *ce)
|
||||
{
|
||||
if(ce->URL_s)
|
||||
StrAllocCopy(ce->URL_s->charset, INTL_ResourceCharSet());
|
||||
XP_HandleHTMLPanel(ce->URL_s);
|
||||
return -1;
|
||||
}
|
||||
|
||||
PRIVATE int32
|
||||
net_HTMLDialogLoad(ActiveEntry *ce)
|
||||
{
|
||||
if(ce->URL_s)
|
||||
StrAllocCopy(ce->URL_s->charset, INTL_ResourceCharSet());
|
||||
XP_HandleHTMLDialog(ce->URL_s);
|
||||
return -1;
|
||||
}
|
||||
|
||||
PRIVATE int32
|
||||
net_WysiwygLoad(ActiveEntry *ce)
|
||||
{
|
||||
const char *real_url = LM_SkipWysiwygURLPrefix(ce->URL_s->address);
|
||||
char *new_address;
|
||||
|
||||
/* XXX can't use StrAllocCopy because it frees dest first */
|
||||
if (real_url && (new_address = PL_strdup(real_url)) != NULL)
|
||||
{
|
||||
PR_Free(ce->URL_s->address);
|
||||
ce->URL_s->address = new_address;
|
||||
FREE_AND_CLEAR(ce->URL_s->wysiwyg_url);
|
||||
}
|
||||
|
||||
/* no need to free real_url */
|
||||
|
||||
ce->status = MK_DO_REDIRECT;
|
||||
return MK_DO_REDIRECT;
|
||||
}
|
||||
|
||||
PRIVATE int32
|
||||
net_ProtoMainStub(ActiveEntry *ce)
|
||||
{
|
||||
#ifdef DO_ANNOYING_ASSERTS_IN_STUBS
|
||||
PR_ASSERT(0);
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
|
||||
PRIVATE void
|
||||
net_ProtoCleanupStub(void)
|
||||
{
|
||||
}
|
||||
|
||||
PRIVATE void
|
||||
net_reg_random_protocol(NET_ProtoInitFunc *LoadRoutine, int type)
|
||||
{
|
||||
NET_ProtoImpl *random_proto_impl;
|
||||
|
||||
random_proto_impl = PR_NEW(NET_ProtoImpl);
|
||||
|
||||
if(!random_proto_impl)
|
||||
return;
|
||||
|
||||
random_proto_impl->init = LoadRoutine;
|
||||
random_proto_impl->process = net_ProtoMainStub;
|
||||
random_proto_impl->interrupt = net_ProtoMainStub;
|
||||
random_proto_impl->cleanup = net_ProtoCleanupStub;
|
||||
|
||||
NET_RegisterProtocolImplementation(random_proto_impl, type);
|
||||
}
|
||||
|
||||
/* don't you just hate it when people come along and hack this
|
||||
* kind of stuff into your code.
|
||||
*
|
||||
* @@@ clean this up some time
|
||||
*/
|
||||
PRIVATE void
|
||||
net_InitTotallyRandomStuffPeopleAddedProtocols(void)
|
||||
{
|
||||
net_reg_random_protocol(net_SecurityURLLoad, SECURITY_TYPE_URL);
|
||||
net_reg_random_protocol(net_SeclibURLLoad, INTERNAL_SECLIB_TYPE_URL);
|
||||
net_reg_random_protocol(net_HTMLPanelLoad, HTML_PANEL_HANDLER_TYPE_URL);
|
||||
net_reg_random_protocol(net_HTMLDialogLoad, HTML_DIALOG_HANDLER_TYPE_URL);
|
||||
net_reg_random_protocol(net_WysiwygLoad, WYSIWYG_TYPE_URL);
|
||||
}
|
||||
|
||||
#ifdef XP_UNIX
|
||||
extern void FE_ShowMinibuffer(MWContext *);
|
||||
|
||||
PRBool net_AboutMinibuffer(const char *token,
|
||||
FO_Present_Types format_out,
|
||||
URL_Struct *URL_s,
|
||||
MWContext *window_id)
|
||||
{
|
||||
FE_ShowMinibuffer(window_id);
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef WEBFONTS
|
||||
PRBool net_AboutFonts(const char *token,
|
||||
FO_Present_Types format_out,
|
||||
URL_Struct *URL_s,
|
||||
MWContext *window_id)
|
||||
{
|
||||
NF_AboutFonts(window_id, which);
|
||||
return PR_TRUE;
|
||||
}
|
||||
#endif /* WEBFONTS */
|
||||
|
||||
PRBool net_AboutImageCache(const char *token,
|
||||
FO_Present_Types format_out,
|
||||
URL_Struct *URL_s,
|
||||
MWContext *window_id)
|
||||
{
|
||||
IL_DisplayMemCacheInfoAsHTML(format_out, URL_s, window_id);
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
PRBool net_AboutGlobalHistory(const char *token,
|
||||
FO_Present_Types format_out,
|
||||
URL_Struct *URL_s,
|
||||
MWContext *window_id)
|
||||
{
|
||||
NET_DisplayGlobalHistoryInfoAsHTML(window_id, URL_s, format_out);
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
PRIVATE void net_InitAboutURLs()
|
||||
{
|
||||
NET_RegisterAboutProtocol("image-cache?", net_AboutImageCache);
|
||||
NET_RegisterAboutProtocol("global", net_AboutGlobalHistory);
|
||||
#ifdef XP_UNIX
|
||||
NET_RegisterAboutProtocol("minibuffer", net_AboutMinibuffer);
|
||||
#endif
|
||||
#ifdef WEBFONTS
|
||||
NET_RegisterAboutProtocol("fonts?", net_AboutFonts);
|
||||
#endif
|
||||
}
|
||||
9
mozilla/network/client/cnetinit.h
Normal file
9
mozilla/network/client/cnetinit.h
Normal file
@@ -0,0 +1,9 @@
|
||||
|
||||
|
||||
#ifndef CLINIT_H
|
||||
#define CLINIT_H
|
||||
|
||||
void
|
||||
NET_ClientProtocolInitialize(void);
|
||||
|
||||
#endif /* CLINIT_H */
|
||||
5
mozilla/network/client/export.mac
Normal file
5
mozilla/network/client/export.mac
Normal file
@@ -0,0 +1,5 @@
|
||||
#
|
||||
# This is a list of local files which get copied to the mozilla:dist directory
|
||||
#
|
||||
|
||||
cnetinit.h
|
||||
95
mozilla/network/client/makefile.win
Normal file
95
mozilla/network/client/makefile.win
Normal file
@@ -0,0 +1,95 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
IGNORE_MANIFEST=1
|
||||
#
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
# Makefile to build the Network file protocol LIB
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
|
||||
DEPTH=..\..
|
||||
MODULE=cnetinit
|
||||
EXPORTS= cnetinit.h
|
||||
|
||||
!ifndef MODULAR_NETLIB
|
||||
#
|
||||
# Make sure we have MOZILLA_CLIENT defined so we get the
|
||||
# proper JS includes
|
||||
#
|
||||
LCFLAGS = $(LCFLAGS) -DMOZILLA_CLIENT
|
||||
|
||||
!ifdef BUILD_DEBUG_GC
|
||||
LCFLAGS = $(LCFLAGS) -DDEBUG_GC
|
||||
!endif
|
||||
|
||||
LLIBS= \
|
||||
$(NULL)
|
||||
MISCDEP=$(LLIBS)
|
||||
OBJS= \
|
||||
.\$(OBJDIR)\cnetinit.obj \
|
||||
.\$(OBJDIR)\mkfe.obj \
|
||||
$(NULL)
|
||||
|
||||
|
||||
LIBRARY_NAME=cnetinit
|
||||
|
||||
LOCAL_INCLUDES=-I.
|
||||
INCLUDES = $(LOCAL_INCLUDES)
|
||||
|
||||
|
||||
EXTRA_LIBS=
|
||||
|
||||
REQUIRES= network
|
||||
|
||||
# use LINCS on win32 for now since REQUIRES seems to be broken
|
||||
#!if "$(MOZ_BITS)" != "16"
|
||||
LINCS= \
|
||||
-I$(PUBLIC)\java \
|
||||
-I$(PUBLIC)\jtools \
|
||||
-I$(PUBLIC)\js \
|
||||
-I$(PUBLIC)\htmldlgs \
|
||||
-I$(PUBLIC)\security \
|
||||
-I$(PUBLIC)\network \
|
||||
-I$(PUBLIC)\netcache \
|
||||
-I$(PUBLIC)\abouturl \
|
||||
-I$(PUBLIC)\dataurl \
|
||||
-I$(PUBLIC)\fileurl \
|
||||
-I$(PUBLIC)\ftpurl \
|
||||
-I$(PUBLIC)\gophurl \
|
||||
-I$(PUBLIC)\httpurl \
|
||||
-I$(PUBLIC)\jsurl \
|
||||
-I$(PUBLIC)\certurl \
|
||||
-I$(PUBLIC)\remoturl \
|
||||
-I$(PUBLIC)\marimurl
|
||||
#!endif
|
||||
|
||||
!endif
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
||||
!ifndef MODULAR_NETLIB
|
||||
libs:: $(LIBRARY)
|
||||
$(MAKE_INSTALL) $(LIBRARY) $(DIST)\lib
|
||||
|
||||
symbols::
|
||||
@echo "LIBRARY_NAME is $(LIBRARY_NAME)"
|
||||
@echo "LIBRARY is $(LIBRARY)"
|
||||
|
||||
!endif
|
||||
110
mozilla/network/client/mkfe.c
Normal file
110
mozilla/network/client/mkfe.c
Normal file
@@ -0,0 +1,110 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
#include "mkutils.h"
|
||||
#include "mkfe.h"
|
||||
|
||||
/* print network progress to the front end
|
||||
*/
|
||||
MODULE_PRIVATE void
|
||||
NET_Progress(MWContext *window_id, char *msg)
|
||||
{
|
||||
FE_Progress(window_id, msg);
|
||||
}
|
||||
|
||||
MODULE_PRIVATE PRBool
|
||||
NET_Confirm(MWContext *window_id, const char *msg)
|
||||
{
|
||||
return FE_Confirm(window_id, msg);
|
||||
}
|
||||
|
||||
MODULE_PRIVATE void
|
||||
NET_Alert(MWContext *window_id, const char *msg)
|
||||
{
|
||||
FE_Alert(window_id, msg);
|
||||
}
|
||||
|
||||
MODULE_PRIVATE PRBool
|
||||
NET_PromptUsernameAndPassword(MWContext *window_id,
|
||||
const char *msg,
|
||||
char **username,
|
||||
char **password)
|
||||
{
|
||||
return FE_PromptUsernameAndPassword(window_id, msg, username, password);
|
||||
}
|
||||
|
||||
MODULE_PRIVATE void
|
||||
NET_EnableClicking(MWContext *window_id)
|
||||
{
|
||||
FE_EnableClicking(window_id);
|
||||
}
|
||||
|
||||
MODULE_PRIVATE void NET_GraphProgressInit(MWContext *window_id,
|
||||
URL_Struct *URL_s,
|
||||
int32 content_length)
|
||||
{
|
||||
FE_GraphProgressInit(window_id, URL_s, content_length);
|
||||
}
|
||||
|
||||
MODULE_PRIVATE void NET_GraphProgress(MWContext *window_id,
|
||||
URL_Struct *URL_s,
|
||||
int32 bytes_received,
|
||||
int32 chunk_size,
|
||||
int32 content_length)
|
||||
{
|
||||
FE_GraphProgress(window_id, URL_s, bytes_received, chunk_size,
|
||||
content_length);
|
||||
}
|
||||
|
||||
MODULE_PRIVATE void NET_SetProgressBarPercent(MWContext *window_id,
|
||||
int32 percent)
|
||||
{
|
||||
FE_SetProgressBarPercent(window_id, percent);
|
||||
}
|
||||
|
||||
MODULE_PRIVATE void NET_GraphProgressDestroy(MWContext *window_id,
|
||||
URL_Struct *URL_s,
|
||||
int32 content_length,
|
||||
int32 bytes_received)
|
||||
{
|
||||
FE_GraphProgressDestroy(window_id, URL_s, content_length, bytes_received);
|
||||
}
|
||||
|
||||
MODULE_PRIVATE void NET_AllConnectionsComplete(MWContext *window_id)
|
||||
{
|
||||
FE_AllConnectionsComplete(window_id);
|
||||
}
|
||||
|
||||
MODULE_PRIVATE History *NET_GetHistory(MWContext *window_id)
|
||||
{
|
||||
return &window_id->hist;
|
||||
}
|
||||
|
||||
MODULE_PRIVATE PRBool NET_IsEditor(MWContext *window_id)
|
||||
{
|
||||
return EDT_IS_EDITOR(window_id);
|
||||
}
|
||||
|
||||
MODULE_PRIVATE MWContext *NET_GetParent(MWContext *window_id)
|
||||
{
|
||||
return window_id->grid_parent;
|
||||
}
|
||||
|
||||
MODULE_PRIVATE MWContextType NET_GetWindowType(MWContext *window_id)
|
||||
{
|
||||
return window_id->type;
|
||||
}
|
||||
13
mozilla/network/cnvts/MANIFEST
Normal file
13
mozilla/network/cnvts/MANIFEST
Normal file
@@ -0,0 +1,13 @@
|
||||
#
|
||||
# This is a list of local files which get copied to the mozilla:dist directory
|
||||
#
|
||||
|
||||
cvactive.h
|
||||
cvchunk.h
|
||||
cvcolor.h
|
||||
cvdisk.h
|
||||
cvmime.h
|
||||
cvpics.h
|
||||
cvsimple.h
|
||||
cvunzip.h
|
||||
cvjscfg.h
|
||||
66
mozilla/network/cnvts/Makefile
Normal file
66
mozilla/network/cnvts/Makefile
Normal file
@@ -0,0 +1,66 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH = ../..
|
||||
|
||||
MODULE = netcnvts
|
||||
LIBRARY_NAME = netcnvts
|
||||
|
||||
CSRCS = \
|
||||
cvactive.c \
|
||||
cvchunk.c \
|
||||
cvcolor.c \
|
||||
cvdisk.c \
|
||||
cvextcon.c \
|
||||
cvjscfg.c \
|
||||
cvsimple.c \
|
||||
cvunzip.c \
|
||||
txview.c \
|
||||
$(NULL)
|
||||
|
||||
ifndef MODULAR_NETLIB
|
||||
CSRCS += \
|
||||
cvmime.c \
|
||||
cvpics.c \
|
||||
cvview.c \
|
||||
$(NULL)
|
||||
endif
|
||||
|
||||
EXPORTS= \
|
||||
cvactive.h \
|
||||
cvview.h \
|
||||
cvproxy.h \
|
||||
cvextcon.h \
|
||||
txview.h \
|
||||
cvchunk.h \
|
||||
cvcolor.h \
|
||||
cvdisk.h \
|
||||
cvsimple.h \
|
||||
cvunzip.h \
|
||||
cvjscfg.h
|
||||
|
||||
ifndef MODULAR_NETLIB
|
||||
EXPORTS += \
|
||||
cvmime.h \
|
||||
cvpics.h \
|
||||
$(NULL)
|
||||
endif
|
||||
|
||||
REQUIRES = network img lay layer util parse pref js \
|
||||
security marimurl style zlib softupdt mimetype
|
||||
|
||||
include $(DEPTH)/config/rules.mk
|
||||
487
mozilla/network/cnvts/cvactive.c
Normal file
487
mozilla/network/cnvts/cvactive.c
Normal file
@@ -0,0 +1,487 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
#include "xp.h"
|
||||
#include "mkfe.h"
|
||||
#include "plstr.h"
|
||||
#include "prmem.h"
|
||||
#include "netutils.h"
|
||||
#include "mkselect.h"
|
||||
#include "mktcp.h"
|
||||
#include "cvactive.h"
|
||||
#include "mkgeturl.h"
|
||||
#include "mkstream.h"
|
||||
#include "glhist.h"
|
||||
#include "merrors.h"
|
||||
|
||||
|
||||
extern int MK_OUT_OF_MEMORY;
|
||||
|
||||
|
||||
typedef struct _DataObject {
|
||||
int state;
|
||||
NET_StreamClass *next_stream;
|
||||
char *prev_buffer;
|
||||
int32 prev_buffer_len;
|
||||
MWContext *window_id;
|
||||
int format_out;
|
||||
URL_Struct *URL_s;
|
||||
PRBool signal_at_end_of_multipart;
|
||||
} DataObject;
|
||||
|
||||
#define NORMAL_S 1
|
||||
#define FOUND_BOUNDARY_S 2
|
||||
|
||||
#define MAX_MIME_LINE 200
|
||||
|
||||
/* parse a mime/multipart stream. The boundary is already
|
||||
* known and we start off in the content of the original
|
||||
* message/822 body.
|
||||
*
|
||||
* buffer data up to the size of the passed in data length
|
||||
* for efficiency of the upstream module.
|
||||
*/
|
||||
PRIVATE int net_MultipleDocumentWrite (NET_StreamClass *stream, CONST char* s, int32 l)
|
||||
{
|
||||
int32 i=0;
|
||||
int32 line_length=1;
|
||||
int rv=0;
|
||||
char *cp;
|
||||
char *line;
|
||||
char *push_buffer=NULL;
|
||||
int32 push_buffer_size=0;
|
||||
PRBool all_done=PR_FALSE;
|
||||
DataObject *obj=stream->data_object;
|
||||
BlockAllocCat(obj->prev_buffer, obj->prev_buffer_len, s, l);
|
||||
obj->prev_buffer_len += l;
|
||||
|
||||
if(!obj->prev_buffer)
|
||||
return(MK_OUT_OF_MEMORY);
|
||||
|
||||
line = obj->prev_buffer;
|
||||
|
||||
/* try and find a line
|
||||
*/
|
||||
for(cp=obj->prev_buffer; i < obj->prev_buffer_len; cp++, i++, line_length++)
|
||||
{
|
||||
if(*cp == '\n')
|
||||
{
|
||||
|
||||
switch(obj->state)
|
||||
{
|
||||
case NORMAL_S:
|
||||
{
|
||||
char *cp2 = line;
|
||||
int blength = PL_strlen(obj->URL_s->boundary);
|
||||
|
||||
/* look for boundary. We can rest assured that these
|
||||
PL_strncmp() calls are safe, because we know that the
|
||||
valid portion of the string starting at cp2 has a
|
||||
newline in it (at *cp), and we know that boundary
|
||||
strings never have newlines in them. */
|
||||
if((!PL_strncmp(cp2, "--",2) &&
|
||||
!PL_strncmp(cp2+2,
|
||||
obj->URL_s->boundary,
|
||||
blength))
|
||||
|| (!PL_strncmp(cp2,
|
||||
obj->URL_s->boundary,
|
||||
blength)))
|
||||
{
|
||||
TRACEMSG(("Found boundary: %s", obj->URL_s->boundary));
|
||||
obj->state = FOUND_BOUNDARY_S;
|
||||
|
||||
if(obj->next_stream)
|
||||
{
|
||||
|
||||
if(push_buffer)
|
||||
{
|
||||
/* strip the last newline before the
|
||||
* boundary
|
||||
*/
|
||||
push_buffer_size--;
|
||||
/* if there is a CR as well as a LF
|
||||
* strip that too
|
||||
*/
|
||||
if(push_buffer_size > 0 && push_buffer[push_buffer_size-1] == CR)
|
||||
push_buffer_size--;
|
||||
rv = (*obj->next_stream->put_block)
|
||||
(obj->next_stream,
|
||||
push_buffer,
|
||||
push_buffer_size);
|
||||
PR_Free(push_buffer);
|
||||
push_buffer = NULL;
|
||||
push_buffer_size = 0;
|
||||
}
|
||||
|
||||
TRACEMSG(("Completeing an open stream"));
|
||||
/* if this stream is not the last one, set a flag
|
||||
before completion to let completion do special stuff */
|
||||
PR_ASSERT(cp2 + blength <= cp);
|
||||
/* Because the above PL_strcmp calls succeeded.
|
||||
Because this is true, we know the first call
|
||||
to PL_strncmp below is always safe, but we
|
||||
need to check lengths before we can be sure
|
||||
the other call is safe. */
|
||||
|
||||
if( (cp2 + blength + 2 < cp &&
|
||||
!PL_strncmp(cp2+2+blength, "--",2))
|
||||
|| !PL_strncmp(cp2+blength, "--",2))
|
||||
{
|
||||
/* very last boundary */
|
||||
obj->next_stream->is_multipart = PR_FALSE;
|
||||
|
||||
/* set the all_done flag when
|
||||
* we have found the final boundary
|
||||
*/
|
||||
all_done = PR_TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
obj->next_stream->is_multipart = PR_TRUE;
|
||||
}
|
||||
|
||||
/* complete the last stream
|
||||
*/
|
||||
(*obj->next_stream->complete)
|
||||
(obj->next_stream);
|
||||
PR_Free(obj->next_stream);
|
||||
obj->next_stream = NULL;
|
||||
}
|
||||
|
||||
/* move the line ptr up to new data */
|
||||
line = cp+1;
|
||||
line_length=1; /* reset */
|
||||
|
||||
if(all_done && obj->signal_at_end_of_multipart)
|
||||
return(MK_MULTIPART_MESSAGE_COMPLETED);
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
TRACEMSG(("Pushing line (actually buffering)"));
|
||||
|
||||
/* didn't find the boundary
|
||||
*/
|
||||
if(obj->next_stream)
|
||||
{
|
||||
|
||||
BlockAllocCat(push_buffer, push_buffer_size,
|
||||
line, line_length);
|
||||
push_buffer_size += line_length;
|
||||
if(!push_buffer)
|
||||
return(MK_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
/* move the line ptr up to new data */
|
||||
line = cp+1;
|
||||
line_length=0; /* reset */
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case FOUND_BOUNDARY_S:
|
||||
|
||||
PR_ASSERT(*cp == '\n'); /* from the 'if' above */
|
||||
|
||||
/* terminate at the newline.
|
||||
* now 'line' points to a valid NULL terminated C string
|
||||
*/
|
||||
*cp = '\0';
|
||||
|
||||
TRACEMSG(("Parsing header: >%s<", line));
|
||||
|
||||
/* parse mime headers
|
||||
* stop when a blank line is encountered
|
||||
*/
|
||||
if(*line == '\0' || *line == '\r')
|
||||
{
|
||||
int format_out;
|
||||
obj->state = NORMAL_S;
|
||||
|
||||
TRACEMSG(("Found end of headers"));
|
||||
if (obj->URL_s->content_type == NULL)
|
||||
StrAllocCopy(obj->URL_s->content_type, TEXT_PLAIN);
|
||||
|
||||
/* abort all existing streams. We
|
||||
* have to do this to prevent the
|
||||
* image lib and other things from
|
||||
* continuing to load the page after
|
||||
* we left.
|
||||
*
|
||||
* don't abort other streams if it's
|
||||
* just a new inline image or if the
|
||||
* stream is not going to the screen
|
||||
*/
|
||||
if(CLEAR_CACHE_BIT(obj->format_out) != FO_INTERNAL_IMAGE
|
||||
&& (!PL_strncasecmp(obj->URL_s->content_type,
|
||||
"text", 4)
|
||||
||
|
||||
!PL_strncasecmp(obj->URL_s->content_type,
|
||||
"image", 4)) )
|
||||
{
|
||||
NET_SilentInterruptWindow(obj->window_id);
|
||||
format_out = obj->format_out;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* don't cache image animations... */
|
||||
format_out = CLEAR_CACHE_BIT(obj->format_out);
|
||||
}
|
||||
|
||||
/* libimg and libplugin use the fe_data to store
|
||||
* urls data, so clear it only if its not them */
|
||||
if( (CLEAR_CACHE_BIT(obj->format_out) != FO_INTERNAL_IMAGE)
|
||||
&& (CLEAR_CACHE_BIT(obj->format_out) != FO_PLUGIN)
|
||||
&& (CLEAR_CACHE_BIT(obj->format_out) != FO_BYTERANGE)
|
||||
&& PL_strncasecmp(obj->URL_s->content_type, "image", 5))
|
||||
{
|
||||
obj->URL_s->fe_data = NULL;
|
||||
}
|
||||
|
||||
/* build a stream
|
||||
*/
|
||||
obj->next_stream = NET_StreamBuilder(format_out,
|
||||
obj->URL_s,
|
||||
obj->window_id);
|
||||
|
||||
if(!obj->next_stream)
|
||||
return(MK_UNABLE_TO_CONVERT);
|
||||
|
||||
}
|
||||
else if(!PL_strncasecmp(line, "CONTENT-TYPE:", 13))
|
||||
{
|
||||
|
||||
strtok(line+13, ";"); /* terminate at ; */
|
||||
|
||||
StrAllocCopy(obj->URL_s->content_type,
|
||||
XP_StripLine(line+13));
|
||||
|
||||
if(!obj->URL_s->content_type || !*obj->URL_s->content_type)
|
||||
StrAllocCopy(obj->URL_s->content_type, TEXT_PLAIN);
|
||||
|
||||
TRACEMSG(("found new content_type: %s",
|
||||
obj->URL_s->content_type));
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Pass all other headers to the MIME header parser
|
||||
*/
|
||||
char *value = PL_strchr(line, ':');
|
||||
if(value)
|
||||
value++;
|
||||
NET_ParseMimeHeader(NET_AllowForeignCookies,
|
||||
obj->window_id,
|
||||
obj->URL_s,
|
||||
line,
|
||||
value, PR_FALSE);
|
||||
}
|
||||
line = cp+1;
|
||||
line_length = 0;
|
||||
break;
|
||||
|
||||
default:
|
||||
assert(0);
|
||||
break;
|
||||
|
||||
}
|
||||
} /* end if */
|
||||
} /* end for */
|
||||
|
||||
if(line_length > MAX_MIME_LINE * 2)
|
||||
{
|
||||
int32 new_size;
|
||||
|
||||
TRACEMSG(("Line too long pushing it"));
|
||||
|
||||
if(obj->next_stream)
|
||||
{
|
||||
if(push_buffer)
|
||||
{
|
||||
rv = (*obj->next_stream->put_block)(obj->next_stream,
|
||||
push_buffer,
|
||||
push_buffer_size);
|
||||
rv = (*obj->next_stream->put_block)(obj->next_stream,
|
||||
line,
|
||||
MAX_MIME_LINE);
|
||||
PR_Free(push_buffer);
|
||||
push_buffer = 0;
|
||||
push_buffer_size = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
rv = (*obj->next_stream->put_block)(obj->next_stream,
|
||||
line,
|
||||
MAX_MIME_LINE);
|
||||
}
|
||||
|
||||
if(rv < 0)
|
||||
return(rv);
|
||||
}
|
||||
|
||||
/* newsize equals the old size minus the difference
|
||||
* between line and the start of the old buffer and
|
||||
* the MAX_MIME_LENGTH that we just wrote out
|
||||
*/
|
||||
new_size = obj->prev_buffer_len -
|
||||
((line - obj->prev_buffer) + MAX_MIME_LINE);
|
||||
|
||||
memmove(obj->prev_buffer, line+MAX_MIME_LINE, new_size);
|
||||
obj->prev_buffer_len = new_size;
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
if(line != obj->prev_buffer)
|
||||
{
|
||||
/* some part of the line has been digested, get rid of
|
||||
* the part that has been used
|
||||
*/
|
||||
obj->prev_buffer_len -= (line - obj->prev_buffer);
|
||||
memmove(obj->prev_buffer, line, obj->prev_buffer_len);
|
||||
}
|
||||
|
||||
/* if there is anything in the push buffer send it now
|
||||
*/
|
||||
if(push_buffer)
|
||||
{
|
||||
if(obj->next_stream)
|
||||
{
|
||||
TRACEMSG(("Pushing buffered data"));
|
||||
rv = (*obj->next_stream->put_block)(obj->next_stream,
|
||||
push_buffer,
|
||||
push_buffer_size);
|
||||
}
|
||||
PR_Free(push_buffer);
|
||||
if (rv < 0)
|
||||
return rv;
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
/* is the stream ready for writeing?
|
||||
*/
|
||||
PRIVATE unsigned int net_MultipleDocumentWriteReady (NET_StreamClass * stream)
|
||||
{
|
||||
DataObject *obj=stream->data_object;
|
||||
if(obj->next_stream)
|
||||
return((*obj->next_stream->is_write_ready)(obj->next_stream));
|
||||
else
|
||||
return(MAX_WRITE_READY);
|
||||
}
|
||||
|
||||
|
||||
PRIVATE void net_MultipleDocumentComplete (NET_StreamClass *stream)
|
||||
{
|
||||
DataObject *obj=stream->data_object;
|
||||
|
||||
if(obj->next_stream)
|
||||
{
|
||||
(*obj->next_stream->complete)(obj->next_stream);
|
||||
PR_Free(obj->next_stream);
|
||||
}
|
||||
|
||||
PR_FREEIF(obj->prev_buffer);
|
||||
PR_Free(obj);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
PRIVATE void net_MultipleDocumentAbort (NET_StreamClass *stream, int status)
|
||||
{
|
||||
DataObject *obj=stream->data_object;
|
||||
if(obj->next_stream)
|
||||
{
|
||||
(*obj->next_stream->abort)(obj->next_stream, status);
|
||||
PR_Free(obj->next_stream);
|
||||
}
|
||||
|
||||
PR_FREEIF(obj->prev_buffer);
|
||||
PR_Free(obj);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
PUBLIC NET_StreamClass *
|
||||
CV_MakeMultipleDocumentStream (int format_out,
|
||||
void *data_object,
|
||||
URL_Struct *URL_s,
|
||||
MWContext *window_id)
|
||||
{
|
||||
DataObject* obj;
|
||||
NET_StreamClass* stream;
|
||||
|
||||
TRACEMSG(("Setting up display stream. Have URL: %s\n", URL_s->address));
|
||||
|
||||
GH_UpdateGlobalHistory(URL_s);
|
||||
|
||||
URL_s->is_active = PR_TRUE; /* set to disable view source */
|
||||
|
||||
stream = PR_NEW(NET_StreamClass);
|
||||
if(stream == NULL)
|
||||
return(NULL);
|
||||
|
||||
obj = PR_NEW(DataObject);
|
||||
if (obj == NULL)
|
||||
return(NULL);
|
||||
|
||||
memset(obj, 0, sizeof(DataObject));
|
||||
|
||||
if(CVACTIVE_SIGNAL_AT_END_OF_MULTIPART == (int) data_object)
|
||||
obj->signal_at_end_of_multipart = PR_TRUE;
|
||||
|
||||
stream->name = "Multiple Document";
|
||||
stream->complete = (MKStreamCompleteFunc) net_MultipleDocumentComplete;
|
||||
stream->abort = (MKStreamAbortFunc) net_MultipleDocumentAbort;
|
||||
stream->put_block = (MKStreamWriteFunc) net_MultipleDocumentWrite;
|
||||
stream->is_write_ready = (MKStreamWriteReadyFunc) net_MultipleDocumentWriteReady;
|
||||
stream->data_object = obj; /* document info object */
|
||||
stream->window_id = window_id;
|
||||
|
||||
/* don't cache these
|
||||
format_out = CLEAR_CACHE_BIT(format_out);
|
||||
*/
|
||||
|
||||
/* enable clicking since it doesnt go through the cache
|
||||
* code
|
||||
*/
|
||||
NET_EnableClicking(window_id);
|
||||
|
||||
obj->next_stream = NULL;
|
||||
obj->window_id = window_id;
|
||||
obj->format_out = format_out;
|
||||
obj->URL_s = URL_s;
|
||||
obj->state = NORMAL_S;
|
||||
|
||||
/* make sure that we have a real boundary.
|
||||
* if not fill in '--' as a boundary
|
||||
*/
|
||||
if(!URL_s->boundary)
|
||||
StrAllocCopy(URL_s->boundary, "--");
|
||||
|
||||
/* overwrite the current content type with TEXT/PLAIN since
|
||||
* we want that as the default content-type for
|
||||
* body parts
|
||||
*/
|
||||
StrAllocCopy(URL_s->content_type, TEXT_PLAIN);
|
||||
|
||||
TRACEMSG(("Returning stream from NET_MultipleDocumentConverter\n"));
|
||||
|
||||
return stream;
|
||||
}
|
||||
41
mozilla/network/cnvts/cvactive.h
Normal file
41
mozilla/network/cnvts/cvactive.h
Normal file
@@ -0,0 +1,41 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef CV_ACTIVE
|
||||
#define CV_ACTIVE
|
||||
|
||||
#include "net.h"
|
||||
|
||||
/* define a constant to be passed to CV_MakeMultipleDocumentStream
|
||||
* as the data_object to signify that it should return
|
||||
* MK_END_OF_MULTIPART_MESSAGE when it gets to the end
|
||||
* of the multipart instead of waiting for the complete
|
||||
* function to be called
|
||||
*/
|
||||
#define CVACTIVE_SIGNAL_AT_END_OF_MULTIPART 999
|
||||
|
||||
PR_BEGIN_EXTERN_C
|
||||
|
||||
extern NET_StreamClass *
|
||||
CV_MakeMultipleDocumentStream (int format_out,
|
||||
void *data_object,
|
||||
URL_Struct *URL_s,
|
||||
MWContext *window_id);
|
||||
PR_END_EXTERN_C
|
||||
|
||||
#endif /* CV_ACTIVE */
|
||||
324
mozilla/network/cnvts/cvchunk.c
Normal file
324
mozilla/network/cnvts/cvchunk.c
Normal file
@@ -0,0 +1,324 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
/* Please leave outside of ifdef for windows precompiled headers */
|
||||
#include "xp.h"
|
||||
#include "plstr.h"
|
||||
#include "prmem.h"
|
||||
#include "netutils.h"
|
||||
#include "mkselect.h"
|
||||
#include "mktcp.h"
|
||||
#include "mkgeturl.h"
|
||||
|
||||
#ifdef MOZILLA_CLIENT
|
||||
|
||||
#include "cvchunk.h" /* prototype */
|
||||
|
||||
extern int MK_OUT_OF_MEMORY;
|
||||
|
||||
typedef enum {
|
||||
FIND_CHUNK_SIZE,
|
||||
READ_CHUNK,
|
||||
STRIP_CRLF,
|
||||
PARSE_FOOTER
|
||||
} States;
|
||||
|
||||
typedef struct _DataObject {
|
||||
NET_StreamClass *next_stream;
|
||||
char *in_buf;
|
||||
uint32 in_buf_size;
|
||||
uint32 chunk_size;
|
||||
uint32 amount_of_chunk_parsed;
|
||||
States cur_state;
|
||||
FO_Present_Types format_out;
|
||||
MWContext *context;
|
||||
URL_Struct *URL_s;
|
||||
} DataObject;
|
||||
|
||||
|
||||
/* unchunk the message and return MK_MULTIPART_MESSAGE_COMPLETED
|
||||
* when end detected
|
||||
*/
|
||||
PRIVATE int net_ChunkedWrite (NET_StreamClass *stream, char* s, int32 l)
|
||||
{
|
||||
DataObject *obj=stream->data_object;
|
||||
BlockAllocCat(obj->in_buf, obj->in_buf_size, s, l);
|
||||
if(!obj->in_buf)
|
||||
return MK_OUT_OF_MEMORY;
|
||||
obj->in_buf_size += l;
|
||||
|
||||
while(obj->in_buf_size > 0)
|
||||
{
|
||||
if(obj->cur_state == FIND_CHUNK_SIZE)
|
||||
{
|
||||
char *line_feed;
|
||||
char *semicolon;
|
||||
char *end;
|
||||
|
||||
/* we don't have a current chunk size
|
||||
* look for a new chunk size
|
||||
*
|
||||
* make sure the line has a CRLF
|
||||
*/
|
||||
if((line_feed = PL_strnchr(obj->in_buf, LF, obj->in_buf_size)) == NULL)
|
||||
{
|
||||
return 1; /* need more data */
|
||||
}
|
||||
|
||||
*line_feed = '\0';
|
||||
|
||||
semicolon = PL_strnchr(obj->in_buf, ';', line_feed-obj->in_buf);
|
||||
|
||||
if(semicolon)
|
||||
*semicolon = '\0';
|
||||
|
||||
end = semicolon ? semicolon : line_feed;
|
||||
|
||||
/* read the first integer and ignore any thing
|
||||
* else on the line. Extensions are allowed
|
||||
*/
|
||||
obj->chunk_size = strtol(obj->in_buf, &end, 16);
|
||||
|
||||
/* strip everything up to the line feed */
|
||||
obj->in_buf_size -= (line_feed+1) - obj->in_buf;
|
||||
if(obj->in_buf_size)
|
||||
memmove(obj->in_buf,
|
||||
line_feed+1,
|
||||
obj->in_buf_size);
|
||||
|
||||
if(obj->chunk_size == 0)
|
||||
{
|
||||
/* the stream should be done now */
|
||||
obj->cur_state = PARSE_FOOTER;
|
||||
}
|
||||
else
|
||||
{
|
||||
obj->cur_state = READ_CHUNK;
|
||||
}
|
||||
|
||||
}
|
||||
else if(obj->cur_state == READ_CHUNK)
|
||||
{
|
||||
uint32 data_size;
|
||||
int32 status;
|
||||
|
||||
/* take as much data as we have and push it up the stream
|
||||
*/
|
||||
|
||||
data_size = MIN(obj->in_buf_size, obj->chunk_size-obj->amount_of_chunk_parsed);
|
||||
|
||||
status = (obj->next_stream->put_block)(obj->next_stream,
|
||||
obj->in_buf,
|
||||
data_size);
|
||||
if(status < 0)
|
||||
return status;
|
||||
|
||||
/* remove the part that has been pushed */
|
||||
obj->in_buf_size -= data_size;
|
||||
if(obj->in_buf_size)
|
||||
memmove(obj->in_buf,
|
||||
obj->in_buf+data_size,
|
||||
obj->in_buf_size);
|
||||
|
||||
obj->amount_of_chunk_parsed += data_size;
|
||||
|
||||
if(obj->amount_of_chunk_parsed >= obj->chunk_size)
|
||||
{
|
||||
PR_ASSERT(obj->amount_of_chunk_parsed == obj->chunk_size);
|
||||
/* reinit */
|
||||
obj->amount_of_chunk_parsed = 0;
|
||||
obj->cur_state = STRIP_CRLF;
|
||||
}
|
||||
}
|
||||
else if(obj->cur_state == STRIP_CRLF)
|
||||
{
|
||||
if(obj->in_buf_size > 1 && obj->in_buf[0] == CR && obj->in_buf[1] == LF)
|
||||
{
|
||||
/* strip two bytes */
|
||||
obj->in_buf_size -= 2;
|
||||
if(obj->in_buf_size)
|
||||
memmove(obj->in_buf,
|
||||
obj->in_buf+2,
|
||||
obj->in_buf_size);
|
||||
obj->cur_state = FIND_CHUNK_SIZE;
|
||||
}
|
||||
else if(obj->in_buf[0] == LF)
|
||||
{
|
||||
/* strip one bytes */
|
||||
obj->in_buf_size -= 1;
|
||||
if(obj->in_buf_size)
|
||||
memmove(obj->in_buf,
|
||||
obj->in_buf+1,
|
||||
obj->in_buf_size);
|
||||
obj->cur_state = FIND_CHUNK_SIZE;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(obj->in_buf_size >= 2)
|
||||
{
|
||||
int status;
|
||||
|
||||
/* a fatal parse error */
|
||||
PR_ASSERT(0);
|
||||
|
||||
/* just spew the buf to the screen */
|
||||
status = (obj->next_stream->put_block)(obj->next_stream,
|
||||
obj->in_buf,
|
||||
obj->in_buf_size);
|
||||
if(status < 0)
|
||||
return status;
|
||||
|
||||
/* remove the part that has been pushed */
|
||||
obj->in_buf_size = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(obj->cur_state == PARSE_FOOTER)
|
||||
{
|
||||
char *line_feed;
|
||||
char *value;
|
||||
|
||||
/* parse until we see two CRLF's in a row */
|
||||
if((line_feed = PL_strnchr(obj->in_buf, LF, obj->in_buf_size)) == NULL)
|
||||
{
|
||||
return 1; /* need more data */
|
||||
}
|
||||
|
||||
*line_feed = '\0';
|
||||
|
||||
/* strip the CR */
|
||||
if(line_feed != obj->in_buf && *(line_feed-1) == CR)
|
||||
*(line_feed-1) = '\0';
|
||||
|
||||
if(*obj->in_buf == '\0')
|
||||
{
|
||||
/* end of parse stream */
|
||||
return MK_MULTIPART_MESSAGE_COMPLETED;
|
||||
}
|
||||
|
||||
/* names are separated from values with a colon
|
||||
*/
|
||||
value = PL_strchr(obj->in_buf, ':');
|
||||
if(value)
|
||||
value++;
|
||||
|
||||
/* otherwise parse the line as a mime header */
|
||||
NET_ParseMimeHeader(obj->format_out,
|
||||
obj->context,
|
||||
obj->URL_s,
|
||||
obj->in_buf,
|
||||
value,
|
||||
FALSE);
|
||||
|
||||
/* strip the line from the buffer */
|
||||
obj->in_buf_size -= (line_feed+1) - obj->in_buf;
|
||||
if(obj->in_buf_size)
|
||||
memmove(obj->in_buf,
|
||||
line_feed+1,
|
||||
obj->in_buf_size);
|
||||
}
|
||||
}
|
||||
|
||||
PR_ASSERT(obj->in_buf_size == 0);
|
||||
|
||||
return(1);
|
||||
}
|
||||
|
||||
/* is the stream ready for writeing?
|
||||
*/
|
||||
PRIVATE unsigned int net_ChunkedWriteReady (NET_StreamClass * stream)
|
||||
{
|
||||
DataObject *obj=stream->data_object;
|
||||
return (*obj->next_stream->is_write_ready)(obj->next_stream);
|
||||
}
|
||||
|
||||
|
||||
PRIVATE void net_ChunkedComplete (NET_StreamClass *stream)
|
||||
{
|
||||
DataObject *obj=stream->data_object;
|
||||
(*obj->next_stream->complete)(obj->next_stream);
|
||||
|
||||
PR_Free(obj);
|
||||
return;
|
||||
}
|
||||
|
||||
PRIVATE void net_ChunkedAbort (NET_StreamClass *stream, int status)
|
||||
{
|
||||
DataObject *obj=stream->data_object;
|
||||
(*obj->next_stream->abort)(obj->next_stream, status);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
MODULE_PRIVATE NET_StreamClass *
|
||||
NET_ChunkedDecoderStream (int format_out,
|
||||
void *data_obj,
|
||||
URL_Struct *URL_s,
|
||||
MWContext *window_id)
|
||||
{
|
||||
DataObject* obj;
|
||||
NET_StreamClass* stream;
|
||||
|
||||
TRACEMSG(("Setting up display stream. Have URL: %s\n", URL_s->address));
|
||||
|
||||
stream = PR_NEW(NET_StreamClass);
|
||||
if(stream == NULL)
|
||||
return(NULL);
|
||||
|
||||
obj = PR_NEWZAP(DataObject);
|
||||
if (obj == NULL)
|
||||
return(NULL);
|
||||
|
||||
stream->name = "Chunked decoder";
|
||||
stream->complete = (MKStreamCompleteFunc) net_ChunkedComplete;
|
||||
stream->abort = (MKStreamAbortFunc) net_ChunkedAbort;
|
||||
stream->put_block = (MKStreamWriteFunc) net_ChunkedWrite;
|
||||
stream->is_write_ready = (MKStreamWriteReadyFunc) net_ChunkedWriteReady;
|
||||
stream->data_object = obj; /* document info object */
|
||||
stream->window_id = window_id;
|
||||
|
||||
/* clear the "chunked" encoding */
|
||||
if(URL_s->transfer_encoding)
|
||||
{
|
||||
PR_FREEIF(URL_s->transfer_encoding);
|
||||
URL_s->transfer_encoding = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
PR_FREEIF(URL_s->content_encoding);
|
||||
URL_s->content_encoding = NULL;
|
||||
}
|
||||
obj->next_stream = NET_StreamBuilder(format_out, URL_s, window_id);
|
||||
|
||||
if(!obj->next_stream)
|
||||
{
|
||||
PR_Free(obj);
|
||||
PR_Free(stream);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
obj->context = window_id;
|
||||
obj->format_out = format_out;
|
||||
obj->URL_s = URL_s;
|
||||
|
||||
TRACEMSG(("Returning stream from NET_ChunkedConverter\n"));
|
||||
|
||||
return stream;
|
||||
}
|
||||
|
||||
#endif /* MOZILLA_CLIENT */
|
||||
28
mozilla/network/cnvts/cvchunk.h
Normal file
28
mozilla/network/cnvts/cvchunk.h
Normal file
@@ -0,0 +1,28 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef CVCHUNK_H
|
||||
#define CVCHUNK_H
|
||||
|
||||
MODULE_PRIVATE NET_StreamClass *
|
||||
NET_ChunkedDecoderStream (int format_out,
|
||||
void *data_obj,
|
||||
URL_Struct *URL_s,
|
||||
MWContext *window_id);
|
||||
|
||||
#endif /* CVCHUNK_H */
|
||||
612
mozilla/network/cnvts/cvcolor.c
Normal file
612
mozilla/network/cnvts/cvcolor.c
Normal file
@@ -0,0 +1,612 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
/* Please leave outside of ifdef for windows precompiled headers */
|
||||
#include "xp.h"
|
||||
#include "plstr.h"
|
||||
#include "prmem.h"
|
||||
#include "netutils.h"
|
||||
#include "mkselect.h"
|
||||
#include "mktcp.h"
|
||||
#include "mkgeturl.h"
|
||||
|
||||
#ifdef MOZILLA_CLIENT
|
||||
|
||||
/* take an HTML stream. Escape all the HTML and
|
||||
* use <FONT color=> to color the different syntactical parts
|
||||
* of the HTML stream
|
||||
*/
|
||||
#ifndef MODULAR_NETLIB
|
||||
#include "pa_parse.h"
|
||||
#endif
|
||||
#include "xpgetstr.h"
|
||||
#include "intl_csi.h"
|
||||
#define VIEW_SOURCE_TARGET_WINDOW_NAME "%ViewSourceWindow"
|
||||
|
||||
typedef enum StatesEnum {
|
||||
IN_CONTENT,
|
||||
IN_SCRIPT,
|
||||
ABOUT_TO_BEGIN_TAG,
|
||||
IN_BEGIN_TAG,
|
||||
IN_TAG,
|
||||
BEGIN_ATTRIBUTE_VALUE,
|
||||
IN_QUOTED_ATTRIBUTE_VALUE,
|
||||
IN_BROKEN_QUOTED_ATTRIBUTE_VALUE,
|
||||
IN_UNQUOTED_ATTRIBUTE_VALUE,
|
||||
IN_COMMENT,
|
||||
IN_AMPERSAND_THINGY
|
||||
} StatesEnum;
|
||||
|
||||
#define MAXTAGLEN 15
|
||||
|
||||
typedef struct _DataObject {
|
||||
NET_StreamClass * next_stream;
|
||||
StatesEnum state;
|
||||
char tag[MAXTAGLEN+1];
|
||||
uint tag_index;
|
||||
#ifndef MODULAR_NETLIB
|
||||
int tag_type;
|
||||
#endif
|
||||
PRBool in_broken_html;
|
||||
} DataObject;
|
||||
|
||||
#define BEGIN_TAG_MARKUP "<B>"
|
||||
#define END_TAG_MARKUP "</B>"
|
||||
#define BEGIN_TAG_NAME_MARKUP "<FONT SIZE=+0 COLOR=\"#551A8B\">"
|
||||
#define END_TAG_NAME_MARKUP "</FONT>"
|
||||
#define BEGIN_ATTRIBUTE_VALUE_MARKUP "</B><FONT SIZE=+0 COLOR=\"003E98\">"
|
||||
#define END_ATTRIBUTE_VALUE_MARKUP "</FONT><B>"
|
||||
#define BEGIN_BROKEN_ATTRIBUTE_MARKUP "<FONT COLOR=#0000FF><BLINK>"
|
||||
#define END_BROKEN_ATTRIBUTE_MARKUP "</BLINK></FONT>"
|
||||
#define BEGIN_COMMENT_MARKUP "<I>"
|
||||
#define END_COMMENT_MARKUP "</I>"
|
||||
#define BEGIN_AMPERSAND_THINGY_MARKUP "<FONT SIZE=+0 COLOR=\"#2F4F2F\">"
|
||||
#define END_AMPERSAND_THINGY_MARKUP "</FONT>"
|
||||
|
||||
extern int MK_CVCOLOR_SOURCE_OF;
|
||||
|
||||
PRIVATE char *net_BeginColorHTMLTag (DataObject *obj)
|
||||
{
|
||||
char *new_markup = 0;
|
||||
|
||||
#ifndef MODULAR_NETLIB
|
||||
if (obj->tag_type == P_SCRIPT)
|
||||
{
|
||||
StrAllocCopy(new_markup, "</XMP><PRE>");
|
||||
obj->tag_type = P_UNKNOWN;
|
||||
}
|
||||
#endif
|
||||
StrAllocCat(new_markup, BEGIN_TAG_MARKUP);
|
||||
StrAllocCat(new_markup, "<");
|
||||
StrAllocCat(new_markup, BEGIN_TAG_NAME_MARKUP);
|
||||
obj->state = ABOUT_TO_BEGIN_TAG;
|
||||
return new_markup;
|
||||
}
|
||||
|
||||
PRIVATE char *net_EndColorHTMLTag (DataObject *obj)
|
||||
{
|
||||
char *new_markup = 0;
|
||||
|
||||
if(obj->in_broken_html)
|
||||
{
|
||||
StrAllocCopy(new_markup, END_BROKEN_ATTRIBUTE_MARKUP);
|
||||
obj->in_broken_html = PR_FALSE;
|
||||
}
|
||||
StrAllocCat(new_markup, ">");
|
||||
StrAllocCat(new_markup, END_TAG_MARKUP);
|
||||
#ifndef MODULAR_NETLIB
|
||||
if (obj->tag_type == P_SCRIPT)
|
||||
{
|
||||
StrAllocCat(new_markup, "</PRE><XMP>");
|
||||
obj->state = IN_SCRIPT;
|
||||
}
|
||||
else
|
||||
{
|
||||
obj->state = IN_CONTENT;
|
||||
}
|
||||
#endif
|
||||
return new_markup;
|
||||
}
|
||||
|
||||
PRIVATE int net_ColorHTMLWrite (NET_StreamClass *stream, CONST char *s, int32 l)
|
||||
{
|
||||
int32 i;
|
||||
int32 last_output_point;
|
||||
char *new_markup=0;
|
||||
char *tmp_markup=0;
|
||||
char tiny_buf[4];
|
||||
CONST char *cp;
|
||||
int status;
|
||||
DataObject *obj=stream->data_object;
|
||||
|
||||
last_output_point = 0;
|
||||
|
||||
for(i = 0, cp = s; i < l; i++, cp++)
|
||||
{
|
||||
switch(obj->state)
|
||||
{
|
||||
case IN_CONTENT:
|
||||
/* do nothing until you find a '<' "<!--" or '&' */
|
||||
if(*cp == '<')
|
||||
{
|
||||
/* XXX we can miss a comment spanning a block boundary */
|
||||
if(i+4 <= l && !PL_strncmp(cp, "<!--", 4))
|
||||
{
|
||||
StrAllocCopy(new_markup, BEGIN_COMMENT_MARKUP);
|
||||
StrAllocCat(new_markup, "<");
|
||||
obj->state = IN_COMMENT;
|
||||
}
|
||||
else
|
||||
{
|
||||
new_markup = net_BeginColorHTMLTag(obj);
|
||||
}
|
||||
}
|
||||
else if(*cp == '&')
|
||||
{
|
||||
StrAllocCopy(new_markup, BEGIN_AMPERSAND_THINGY_MARKUP);
|
||||
StrAllocCat(new_markup, "&");
|
||||
obj->state = IN_AMPERSAND_THINGY;
|
||||
}
|
||||
break;
|
||||
case IN_SCRIPT:
|
||||
/* do nothing until you find '</SCRIPT>' */
|
||||
if(*cp == '<')
|
||||
{
|
||||
/* XXX we can miss a </SCRIPT> spanning a block boundary */
|
||||
if(i+8 <= l && !PL_strncasecmp(cp, "</SCRIPT", 8))
|
||||
{
|
||||
new_markup = net_BeginColorHTMLTag(obj);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ABOUT_TO_BEGIN_TAG:
|
||||
/* we have seen the first '<'
|
||||
* once we see a non-whitespace character
|
||||
* we will be in the tag identifier
|
||||
*/
|
||||
if(*cp == '>')
|
||||
{
|
||||
StrAllocCopy(new_markup, END_TAG_NAME_MARKUP);
|
||||
tmp_markup = net_EndColorHTMLTag(obj);
|
||||
StrAllocCat(new_markup, tmp_markup);
|
||||
PR_FREEIF(tmp_markup);
|
||||
tmp_markup = NULL;
|
||||
}
|
||||
else if(!NET_IS_SPACE(*cp))
|
||||
{
|
||||
obj->state = IN_BEGIN_TAG;
|
||||
obj->tag_index = 0;
|
||||
obj->tag[obj->tag_index++] = *cp;
|
||||
if(*cp == '<')
|
||||
StrAllocCopy(new_markup, "<");
|
||||
|
||||
}
|
||||
break;
|
||||
case IN_BEGIN_TAG:
|
||||
/* go to the IN_TAG state when we see
|
||||
* the first whitespace
|
||||
*/
|
||||
if(NET_IS_SPACE(*cp))
|
||||
{
|
||||
StrAllocCopy(new_markup, END_TAG_NAME_MARKUP);
|
||||
sprintf(tiny_buf, "%c", *cp);
|
||||
StrAllocCat(new_markup, tiny_buf);
|
||||
obj->state = IN_TAG;
|
||||
obj->tag[obj->tag_index] = '\0';
|
||||
#ifndef MODULAR_NETLIB
|
||||
obj->tag_type = pa_tokenize_tag(obj->tag);
|
||||
#endif
|
||||
}
|
||||
else if(*cp == '>')
|
||||
{
|
||||
StrAllocCopy(new_markup, END_TAG_NAME_MARKUP);
|
||||
tmp_markup = net_EndColorHTMLTag(obj);
|
||||
StrAllocCat(new_markup, tmp_markup);
|
||||
PR_FREEIF(tmp_markup);
|
||||
tmp_markup = NULL;
|
||||
}
|
||||
else if(*cp == '<')
|
||||
{
|
||||
/* protect ourselves from markup */
|
||||
if(!obj->in_broken_html)
|
||||
{
|
||||
obj->in_broken_html = PR_TRUE;
|
||||
StrAllocCopy(new_markup, BEGIN_BROKEN_ATTRIBUTE_MARKUP);
|
||||
StrAllocCat(new_markup, "<");
|
||||
}
|
||||
else
|
||||
{
|
||||
StrAllocCopy(new_markup, "<");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (obj->tag_index < MAXTAGLEN)
|
||||
obj->tag[obj->tag_index++] = *cp;
|
||||
}
|
||||
break;
|
||||
case IN_TAG:
|
||||
/* do nothing until you find a opening '=' or end '>' */
|
||||
if(*cp == '=')
|
||||
{
|
||||
StrAllocCopy(new_markup, "=");
|
||||
StrAllocCat(new_markup, BEGIN_ATTRIBUTE_VALUE_MARKUP);
|
||||
obj->state = BEGIN_ATTRIBUTE_VALUE;
|
||||
}
|
||||
else if(*cp == '>')
|
||||
{
|
||||
new_markup = net_EndColorHTMLTag(obj);
|
||||
}
|
||||
else if(*cp == '<')
|
||||
{
|
||||
/* protect ourselves from markup */
|
||||
StrAllocCopy(new_markup, "<");
|
||||
}
|
||||
break;
|
||||
case BEGIN_ATTRIBUTE_VALUE:
|
||||
/* when we reach the first non-whitespace
|
||||
* we will enter the UNQUOTED or the QUOTED
|
||||
* ATTRIBUTE state
|
||||
*/
|
||||
if(!NET_IS_SPACE(*cp))
|
||||
{
|
||||
if(*cp == '"')
|
||||
{
|
||||
obj->state = IN_QUOTED_ATTRIBUTE_VALUE;
|
||||
/* no need to jump to the quoted attr handler
|
||||
* since this char can't be a dangerous char
|
||||
*/
|
||||
}
|
||||
else
|
||||
{
|
||||
obj->state = IN_UNQUOTED_ATTRIBUTE_VALUE;
|
||||
/* need to jump to the unquoted attr handler
|
||||
* since this char can be a dangerous character
|
||||
*/
|
||||
goto unquoted_attribute_jump_point;
|
||||
}
|
||||
}
|
||||
else if(*cp == '>')
|
||||
{
|
||||
StrAllocCopy(new_markup, END_ATTRIBUTE_VALUE_MARKUP);
|
||||
tmp_markup = net_EndColorHTMLTag(obj);
|
||||
StrAllocCat(new_markup, tmp_markup);
|
||||
PR_FREEIF(tmp_markup);
|
||||
tmp_markup = NULL;
|
||||
}
|
||||
else if(*cp == '<')
|
||||
{
|
||||
/* protect ourselves from markup */
|
||||
StrAllocCopy(new_markup, "<");
|
||||
}
|
||||
break;
|
||||
case IN_UNQUOTED_ATTRIBUTE_VALUE:
|
||||
unquoted_attribute_jump_point:
|
||||
/* do nothing until you find a whitespace */
|
||||
if(NET_IS_SPACE(*cp))
|
||||
{
|
||||
StrAllocCopy(new_markup, END_ATTRIBUTE_VALUE_MARKUP);
|
||||
sprintf(tiny_buf, "%c", *cp);
|
||||
StrAllocCat(new_markup, tiny_buf);
|
||||
obj->state = IN_TAG;
|
||||
}
|
||||
else if(*cp == '>')
|
||||
{
|
||||
StrAllocCopy(new_markup, END_ATTRIBUTE_VALUE_MARKUP);
|
||||
tmp_markup = net_EndColorHTMLTag(obj);
|
||||
StrAllocCat(new_markup, tmp_markup);
|
||||
PR_FREEIF(tmp_markup);
|
||||
tmp_markup = NULL;
|
||||
}
|
||||
else if(*cp == '<')
|
||||
{
|
||||
/* protect ourselves from markup */
|
||||
StrAllocCopy(new_markup, "<");
|
||||
}
|
||||
else if(*cp == '&')
|
||||
{
|
||||
/* protect ourselves from markup */
|
||||
StrAllocCopy(new_markup, "&");
|
||||
}
|
||||
break;
|
||||
case IN_QUOTED_ATTRIBUTE_VALUE:
|
||||
/* do nothing until you find a closing '"' */
|
||||
if(*cp == '\"')
|
||||
{
|
||||
if(obj->in_broken_html)
|
||||
{
|
||||
StrAllocCopy(new_markup, END_BROKEN_ATTRIBUTE_MARKUP);
|
||||
obj->in_broken_html = PR_FALSE;
|
||||
}
|
||||
StrAllocCat(new_markup, "\"");
|
||||
StrAllocCat(new_markup, END_ATTRIBUTE_VALUE_MARKUP);
|
||||
obj->state = IN_TAG;
|
||||
}
|
||||
else if(*cp == '<')
|
||||
{
|
||||
/* protect ourselves from markup */
|
||||
StrAllocCopy(new_markup, "<");
|
||||
}
|
||||
else if(*cp == '&')
|
||||
{
|
||||
/* protect ourselves from markup */
|
||||
StrAllocCopy(new_markup, "&");
|
||||
}
|
||||
else if(*cp == '>')
|
||||
{
|
||||
/* probably a broken attribute value */
|
||||
if(!obj->in_broken_html)
|
||||
{
|
||||
obj->in_broken_html = PR_TRUE;
|
||||
StrAllocCopy(new_markup, BEGIN_BROKEN_ATTRIBUTE_MARKUP);
|
||||
StrAllocCat(new_markup, ">");
|
||||
}
|
||||
}
|
||||
break;
|
||||
case IN_COMMENT:
|
||||
/* do nothing until you find a closing '-->' */
|
||||
if(!PL_strncmp(cp, "-->", 3))
|
||||
{
|
||||
StrAllocCopy(new_markup, ">");
|
||||
cp += 2;
|
||||
i += 2;
|
||||
StrAllocCat(new_markup, END_COMMENT_MARKUP);
|
||||
obj->state = IN_CONTENT;
|
||||
}
|
||||
else if(*cp == '<')
|
||||
{
|
||||
/* protect ourselves from markup */
|
||||
StrAllocCopy(new_markup, "<");
|
||||
}
|
||||
break;
|
||||
case IN_AMPERSAND_THINGY:
|
||||
/* do nothing until you find a ';' or space */
|
||||
if(*cp == ';' || NET_IS_SPACE(*cp))
|
||||
{
|
||||
sprintf(tiny_buf, "%c", *cp);
|
||||
StrAllocCopy(new_markup, tiny_buf);
|
||||
StrAllocCat(new_markup, END_AMPERSAND_THINGY_MARKUP);
|
||||
obj->state = IN_CONTENT;
|
||||
}
|
||||
else if(*cp == '<')
|
||||
{
|
||||
/* protect ourselves from markup */
|
||||
StrAllocCopy(new_markup, "<");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
PR_ASSERT(0);
|
||||
break;
|
||||
}
|
||||
|
||||
if(new_markup)
|
||||
{
|
||||
/* push all the way up to but not including *cp */
|
||||
status = (*obj->next_stream->put_block)
|
||||
(obj->next_stream,
|
||||
&s[last_output_point],
|
||||
i-last_output_point);
|
||||
last_output_point = i+1;
|
||||
|
||||
if(status < 0)
|
||||
{
|
||||
PR_Free(new_markup);
|
||||
return(status);
|
||||
}
|
||||
|
||||
/* add new markup */
|
||||
status = (*obj->next_stream->put_block)
|
||||
(obj->next_stream,
|
||||
new_markup, PL_strlen(new_markup));
|
||||
if(status < 0)
|
||||
{
|
||||
PR_Free(new_markup);
|
||||
return(status);
|
||||
}
|
||||
|
||||
PR_FREEIF(new_markup);
|
||||
new_markup = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if(last_output_point < l)
|
||||
return((*obj->next_stream->put_block)(obj->next_stream,
|
||||
&s[last_output_point],
|
||||
(l-last_output_point)));
|
||||
else
|
||||
return(0);
|
||||
}
|
||||
|
||||
/* is the stream ready for writeing?
|
||||
*/
|
||||
PRIVATE unsigned int net_ColorHTMLWriteReady (NET_StreamClass * stream)
|
||||
{
|
||||
DataObject *obj=stream->data_object;
|
||||
return((*obj->next_stream->is_write_ready)(obj->next_stream));
|
||||
}
|
||||
|
||||
|
||||
PRIVATE void net_ColorHTMLComplete (NET_StreamClass *stream)
|
||||
{
|
||||
DataObject *obj=stream->data_object;
|
||||
(*obj->next_stream->complete)(obj->next_stream);
|
||||
}
|
||||
|
||||
PRIVATE void net_ColorHTMLAbort (NET_StreamClass *stream, int status)
|
||||
{
|
||||
DataObject *obj=stream->data_object;
|
||||
(*obj->next_stream->abort)(obj->next_stream, status);
|
||||
}
|
||||
|
||||
PUBLIC NET_StreamClass *
|
||||
net_ColorHTMLStream (int format_out,
|
||||
void *data_obj,
|
||||
URL_Struct *URL_s,
|
||||
MWContext *window_id)
|
||||
{
|
||||
DataObject* obj;
|
||||
char *new_markup=0;
|
||||
char *new_url=0;
|
||||
char *old_url;
|
||||
int status, type;
|
||||
NET_StreamClass *next_stream, *new_stream;
|
||||
PRBool is_html_stream = PR_FALSE;
|
||||
INTL_CharSetInfo csi = LO_GetDocumentCharacterSetInfo(window_id);
|
||||
INTL_CharSetInfo next_csi;
|
||||
|
||||
TRACEMSG(("Setting up ColorHTML stream. Have URL: %s\n", URL_s->address));
|
||||
|
||||
/* treat the stream as html if the closure data says
|
||||
* it's HTML and it is also not a mail or news message
|
||||
*/
|
||||
type = NET_URL_Type(URL_s->address);
|
||||
if(data_obj
|
||||
&& !PL_strcmp((char *)data_obj, TEXT_HTML)
|
||||
&& type != MAILBOX_TYPE_URL
|
||||
&& type != IMAP_TYPE_URL
|
||||
&& type != NEWS_TYPE_URL)
|
||||
is_html_stream = PR_TRUE;
|
||||
|
||||
/* use a new named window */
|
||||
StrAllocCopy(URL_s->window_target, VIEW_SOURCE_TARGET_WINDOW_NAME);
|
||||
|
||||
/* add the url address to the name so that there can be
|
||||
* one view source window per url
|
||||
*/
|
||||
StrAllocCat(URL_s->window_target, URL_s->address);
|
||||
|
||||
/* zero position_tag to prevent hash lossage */
|
||||
URL_s->position_tag = 0;
|
||||
|
||||
/* alloc a new chrome struct and stick it in the URL
|
||||
* so that we can turn off the relavent stuff
|
||||
*/
|
||||
URL_s->window_chrome = PR_NEW(Chrome);
|
||||
if(URL_s->window_chrome)
|
||||
{
|
||||
/* zero everything to turn off all chrome */
|
||||
memset(URL_s->window_chrome, 0, sizeof(Chrome));
|
||||
URL_s->window_chrome->type = MWContextDialog;
|
||||
URL_s->window_chrome->show_scrollbar = PR_TRUE;
|
||||
URL_s->window_chrome->allow_resize = PR_TRUE;
|
||||
URL_s->window_chrome->allow_close = PR_TRUE;
|
||||
}
|
||||
|
||||
/* call the HTML parser */
|
||||
StrAllocCopy(URL_s->content_type, INTERNAL_PARSER);
|
||||
|
||||
/* use the view-source: url instead */
|
||||
StrAllocCopy(new_url, VIEW_SOURCE_URL_PREFIX);
|
||||
StrAllocCat(new_url, URL_s->address);
|
||||
old_url = URL_s->address;
|
||||
URL_s->address = new_url;
|
||||
|
||||
format_out = FO_PRESENT;
|
||||
|
||||
/* open next stream */
|
||||
next_stream = NET_StreamBuilder(format_out, URL_s, window_id);
|
||||
|
||||
if(!next_stream)
|
||||
{
|
||||
PR_Free(old_url);
|
||||
return(NULL);
|
||||
}
|
||||
next_csi = LO_GetDocumentCharacterSetInfo(next_stream->window_id);
|
||||
|
||||
/* jliu: for international's reason,
|
||||
set the value ASAP, so the following stream can share it */
|
||||
INTL_SetCSIWinCSID(next_csi, INTL_GetCSIWinCSID(csi));
|
||||
INTL_SetCSIDocCSID(next_csi, INTL_GetCSIDocCSID(csi));
|
||||
|
||||
|
||||
#define DEF_PICS_LABEL "<META http-equiv=PICS-Label content='(PICS-1.0 \"http://home.netscape.com/default_rating\" l gen true r (s 0))'>"
|
||||
|
||||
/* add a PICS label */
|
||||
StrAllocCopy(new_markup, DEF_PICS_LABEL);
|
||||
StrAllocCat(new_markup, "<TITLE>");
|
||||
StrAllocCat(new_markup, XP_GetString(MK_CVCOLOR_SOURCE_OF));
|
||||
StrAllocCat(new_markup, old_url);
|
||||
StrAllocCat(new_markup, "</TITLE><BODY BGCOLOR=#C0C0C0>");
|
||||
|
||||
|
||||
if(!is_html_stream)
|
||||
StrAllocCat(new_markup, "<PLAINTEXT>");
|
||||
else
|
||||
StrAllocCat(new_markup, "<PRE>");
|
||||
|
||||
PR_Free(old_url);
|
||||
|
||||
status = (*next_stream->put_block)(next_stream,
|
||||
new_markup,
|
||||
PL_strlen(new_markup));
|
||||
PR_Free(new_markup);
|
||||
|
||||
if(status < 0)
|
||||
{
|
||||
(*next_stream->abort)(next_stream, status);
|
||||
PR_Free(next_stream);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
if(!is_html_stream)
|
||||
return(next_stream);
|
||||
|
||||
/* else; continue on and build up this stream module
|
||||
* and attach the next stream to it
|
||||
*/
|
||||
|
||||
new_stream = PR_NEW(NET_StreamClass);
|
||||
if(new_stream == NULL)
|
||||
{
|
||||
(*next_stream->abort)(next_stream, status);
|
||||
PR_Free(next_stream);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
obj = PR_NEW(DataObject);
|
||||
|
||||
if (obj == NULL)
|
||||
{
|
||||
(*next_stream->abort)(next_stream, status);
|
||||
PR_Free(next_stream);
|
||||
PR_Free(new_stream);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
memset(obj, 0, sizeof(DataObject));
|
||||
|
||||
obj->state = IN_CONTENT;
|
||||
|
||||
obj->next_stream = next_stream;
|
||||
#ifndef MODULAR_NETLIB
|
||||
obj->tag_type = P_UNKNOWN;
|
||||
#endif
|
||||
|
||||
new_stream->name = "HTML Colorer";
|
||||
new_stream->complete = (MKStreamCompleteFunc) net_ColorHTMLComplete;
|
||||
new_stream->abort = (MKStreamAbortFunc) net_ColorHTMLAbort;
|
||||
new_stream->put_block = (MKStreamWriteFunc) net_ColorHTMLWrite;
|
||||
new_stream->is_write_ready = (MKStreamWriteReadyFunc)
|
||||
net_ColorHTMLWriteReady;
|
||||
new_stream->data_object = (void *) obj; /* document info object */
|
||||
new_stream->window_id = window_id;
|
||||
|
||||
TRACEMSG(("Returning stream from HTMLColorConverter\n"));
|
||||
|
||||
return new_stream;
|
||||
}
|
||||
#endif /* MOZILLA_CLIENT */
|
||||
29
mozilla/network/cnvts/cvcolor.h
Normal file
29
mozilla/network/cnvts/cvcolor.h
Normal file
@@ -0,0 +1,29 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef CVCOLOR_H
|
||||
#define CVCOLOR_H
|
||||
|
||||
extern NET_StreamClass *
|
||||
net_ColorHTMLStream (int format_out,
|
||||
void *data_obj,
|
||||
URL_Struct *URL_s,
|
||||
MWContext *window_id);
|
||||
|
||||
#endif /* CVCOLOR_H */
|
||||
118
mozilla/network/cnvts/cvdisk.c
Normal file
118
mozilla/network/cnvts/cvdisk.c
Normal file
@@ -0,0 +1,118 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
/* Please leave outside of ifdef for windows precompiled headers */
|
||||
#include "xp.h"
|
||||
#include "prmem.h"
|
||||
#include "netutils.h"
|
||||
#include "mkselect.h"
|
||||
#include "mktcp.h"
|
||||
#include "mkgeturl.h"
|
||||
|
||||
#ifdef MOZILLA_CLIENT
|
||||
|
||||
typedef struct _DataObject {
|
||||
FILE * fp;
|
||||
char * filename;
|
||||
} DataObject;
|
||||
|
||||
|
||||
PRIVATE int net_SaveToDiskWrite (NET_StreamClass *stream, CONST char* s, int32 l)
|
||||
{
|
||||
DataObject *obj=stream->data_object;
|
||||
fwrite(s, 1, l, obj->fp);
|
||||
return(1);
|
||||
}
|
||||
|
||||
/* is the stream ready for writeing?
|
||||
*/
|
||||
PRIVATE unsigned int net_SaveToDiskWriteReady (NET_StreamClass * stream)
|
||||
{
|
||||
DataObject *obj=stream->data_object;
|
||||
return(MAX_WRITE_READY); /* always ready for writing */
|
||||
}
|
||||
|
||||
|
||||
PRIVATE void net_SaveToDiskComplete (NET_StreamClass *stream)
|
||||
{
|
||||
DataObject *obj=stream->data_object;
|
||||
fclose(obj->fp);
|
||||
|
||||
PR_FREEIF(obj->filename);
|
||||
|
||||
PR_Free(obj);
|
||||
return;
|
||||
}
|
||||
|
||||
PRIVATE void net_SaveToDiskAbort (NET_StreamClass *stream, int status)
|
||||
{
|
||||
DataObject *obj=stream->data_object;
|
||||
fclose(obj->fp);
|
||||
|
||||
if(obj->filename)
|
||||
{
|
||||
remove(obj->filename);
|
||||
PR_Free(obj->filename);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
PUBLIC NET_StreamClass *
|
||||
fe_MakeSaveAsStream (int format_out,
|
||||
void *data_obj,
|
||||
URL_Struct *URL_s,
|
||||
MWContext *window_id)
|
||||
{
|
||||
DataObject* obj;
|
||||
NET_StreamClass* stream;
|
||||
static int count=0;
|
||||
char filename[256];
|
||||
FILE *fp = stdout;
|
||||
|
||||
TRACEMSG(("Setting up display stream. Have URL: %s\n", URL_s->address));
|
||||
|
||||
PR_snprintf(filename, sizeof(filename), "foo%d.unknown",count++);
|
||||
fp = fopen(filename,"w");
|
||||
|
||||
stream = PR_NEW(NET_StreamClass);
|
||||
if(stream == NULL)
|
||||
return(NULL);
|
||||
|
||||
obj = PR_NEW(DataObject);
|
||||
if (obj == NULL)
|
||||
return(NULL);
|
||||
|
||||
stream->name = "FileWriter";
|
||||
stream->complete = (MKStreamCompleteFunc) net_SaveToDiskComplete;
|
||||
stream->abort = (MKStreamAbortFunc) net_SaveToDiskAbort;
|
||||
stream->put_block = (MKStreamWriteFunc) net_SaveToDiskWrite;
|
||||
stream->is_write_ready = (MKStreamWriteReadyFunc) net_SaveToDiskWriteReady;
|
||||
stream->data_object = obj; /* document info object */
|
||||
stream->window_id = window_id;
|
||||
|
||||
obj->fp = fp;
|
||||
obj->filename = 0;
|
||||
StrAllocCopy(obj->filename, filename);
|
||||
|
||||
TRACEMSG(("Returning stream from NET_SaveToDiskConverter\n"));
|
||||
|
||||
return stream;
|
||||
}
|
||||
|
||||
#endif /* MOZILLA_CLIENT */
|
||||
27
mozilla/network/cnvts/cvdisk.h
Normal file
27
mozilla/network/cnvts/cvdisk.h
Normal file
@@ -0,0 +1,27 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef CVDISK_H
|
||||
#define CVDISK_H
|
||||
|
||||
extern NET_StreamClass* fe_MakeSaveAsStream (FO_Present_Types format_out,
|
||||
void *data_obj,
|
||||
URL_Struct *URL_s,
|
||||
MWContext *window_id);
|
||||
|
||||
#endif /* CVDISK_H */
|
||||
415
mozilla/network/cnvts/cvextcon.c
Normal file
415
mozilla/network/cnvts/cvextcon.c
Normal file
@@ -0,0 +1,415 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
/* cvextcon.c --- using external Unix programs as content-encoding filters.
|
||||
*/
|
||||
|
||||
#include "xp.h"
|
||||
#include "plstr.h"
|
||||
#include "netutils.h"
|
||||
#include "mkselect.h"
|
||||
#include "mktcp.h"
|
||||
#include "mkgeturl.h"
|
||||
#include "cvextcon.h"
|
||||
#include "mkformat.h"
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <sys/wait.h>
|
||||
#include <signal.h>
|
||||
|
||||
#ifdef __sgi
|
||||
#include <bstring.h> /* FD_ZERO uses bzero() which needs this */
|
||||
/* file for its prototype. */
|
||||
#endif
|
||||
|
||||
typedef struct _CVG_DataObject {
|
||||
NET_StreamClass *next_stream; /* Where the output goes */
|
||||
pid_t pid; /* process in which the filter is running */
|
||||
int infd; /* for reading from the process */
|
||||
int outfd; /* for writing to the process */
|
||||
struct sigaction oldact; /* Old SIGCHLD handler */
|
||||
} CVG_DataObject;
|
||||
|
||||
|
||||
PRIVATE int net_ExtConverterRead (CVG_DataObject *data, PRBool block_p)
|
||||
{
|
||||
char input_buffer [1024];
|
||||
int bytes_read;
|
||||
|
||||
AGAIN:
|
||||
while ((bytes_read = read (data->infd, input_buffer, sizeof (input_buffer)))
|
||||
> 0)
|
||||
{
|
||||
if (data->next_stream)
|
||||
{
|
||||
int status = ((*data->next_stream->put_block)
|
||||
(data->next_stream,
|
||||
input_buffer, bytes_read));
|
||||
/* abort */
|
||||
if (status < 0)
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
||||
/* It's necessary that we block here waiting for the process to produce
|
||||
the rest of its output before we allow the `complete' method to return.
|
||||
We've already set the socket to be nonblocking, and there doesn't appear
|
||||
to be any way to set it to do blocking reads again, so instead, we'll
|
||||
use select() to block for it. That will return when there is some input
|
||||
available, and we'll read it, and (maybe) block again, repeating until
|
||||
we get an EOF.
|
||||
|
||||
To implement this in a non-blocking way would require the input and
|
||||
output sides of this to be disconnected - the output side would be as in
|
||||
this file, but the input side would need to be a new stream type in
|
||||
NET_ProcessNet(), at the level of http, ftp, and file streams.
|
||||
*/
|
||||
if (bytes_read == -1 && block_p &&
|
||||
(errno == EAGAIN || errno == EWOULDBLOCK))
|
||||
{
|
||||
fd_set rset;
|
||||
FD_ZERO (&rset);
|
||||
FD_SET (data->infd, &rset);
|
||||
if (select (data->infd+1, &rset, 0, 0, 0) < 0)
|
||||
perror ("select");
|
||||
goto AGAIN;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
PRIVATE int net_ExtConverterWrite (NET_StreamClass *stream,
|
||||
CONST char* output_buffer,
|
||||
int32 output_length)
|
||||
{
|
||||
CVG_DataObject *data = (CVG_DataObject *) stream->data_object;
|
||||
|
||||
while (output_length > 0)
|
||||
{
|
||||
int bytes_written = 0;
|
||||
|
||||
/* write as much as possible (until done, or the pipe is full.)
|
||||
*/
|
||||
while (output_length > 0 &&
|
||||
(bytes_written = write (data->outfd, output_buffer,
|
||||
output_length))
|
||||
> 0)
|
||||
{
|
||||
output_buffer += bytes_written;
|
||||
output_length -= bytes_written;
|
||||
}
|
||||
|
||||
if (bytes_written == -1 && errno != EAGAIN && errno != EWOULDBLOCK)
|
||||
{
|
||||
perror ("write");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Now read as much as possible (until done, or the pipe is drained.)
|
||||
*/
|
||||
{
|
||||
int status = net_ExtConverterRead (data, PR_FALSE);
|
||||
/* abort */
|
||||
if (status < 0)
|
||||
return status;
|
||||
}
|
||||
|
||||
/* Now go around the loop again, if we weren't able to write all of
|
||||
the output buffer at once (because the pipe filled up.) Now that
|
||||
we've read the available data from the pipe, we will presumably
|
||||
be able to write to it again.
|
||||
*/
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
PRIVATE int net_ExtConverterWriteReady (NET_StreamClass *stream)
|
||||
{
|
||||
/* #### I'm not sure what the right thing to do here is. --jwz */
|
||||
#if 1
|
||||
return (MAX_WRITE_READY);
|
||||
#else
|
||||
CVG_DataObject *data = (CVG_DataObject *) stream->data_object;
|
||||
if(data->next_stream)
|
||||
return ((*data->next_stream->is_write_ready)
|
||||
(data->next_stream));
|
||||
else
|
||||
return (MAX_WRITE_READY);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
PRIVATE void
|
||||
net_KillConverterProcess (CVG_DataObject *data)
|
||||
{
|
||||
pid_t wait_status;
|
||||
/* It may not actually be necessary to kill the process here if we have
|
||||
exited normally, since in that case it has already closed its stdout;
|
||||
but it can't hurt.
|
||||
|
||||
After it dies, we have to wait() for it, or it becomes a zombie.
|
||||
I'm not entirely sure that the perror() is correct - it could be that
|
||||
0 is a legitimate value from waitpid() if the process had already
|
||||
exited before we kill()ed it, but I'm not sure.
|
||||
*/
|
||||
|
||||
kill (data->pid, SIGINT);
|
||||
wait_status = waitpid (data->pid, 0, 0);
|
||||
#ifdef DEBUG_dp
|
||||
fprintf(stderr, "Restoring sigchild handler for pid %d.\n", data->pid);
|
||||
#endif
|
||||
/* Reset SIGCHLD signal hander before returning */
|
||||
sigaction(SIGCHLD, &data->oldact, NULL);
|
||||
|
||||
if (wait_status != data->pid)
|
||||
perror ("waitpid");
|
||||
}
|
||||
|
||||
PRIVATE void net_ExtConverterComplete (NET_StreamClass *stream)
|
||||
{
|
||||
CVG_DataObject *data = (CVG_DataObject *) stream->data_object;
|
||||
|
||||
/* Send an EOF to the stdin of the subprocess; then wait for the rest
|
||||
of its output to show up on its stdout; then close stdout, and kill
|
||||
the process. */
|
||||
close (data->outfd);
|
||||
net_ExtConverterRead (data, PR_TRUE);
|
||||
close (data->infd);
|
||||
net_KillConverterProcess (data);
|
||||
|
||||
/* complete the next stream */
|
||||
if (data->next_stream)
|
||||
{
|
||||
(*data->next_stream->complete) (data->next_stream);
|
||||
free (data->next_stream);
|
||||
}
|
||||
free (data);
|
||||
}
|
||||
|
||||
PRIVATE void net_ExtConverterAbort (NET_StreamClass *stream, int status)
|
||||
{
|
||||
CVG_DataObject *data = (CVG_DataObject *) stream->data_object;
|
||||
|
||||
/* Close the streams and kill the process, discarding any output still
|
||||
in the pipe. */
|
||||
close (data->outfd);
|
||||
close (data->infd);
|
||||
net_KillConverterProcess (data);
|
||||
|
||||
/* abort the next stream */
|
||||
if (data->next_stream)
|
||||
{
|
||||
(*data->next_stream->abort) (data->next_stream, status);
|
||||
free (data->next_stream);
|
||||
}
|
||||
free (data);
|
||||
}
|
||||
|
||||
|
||||
PUBLIC NET_StreamClass *
|
||||
NET_ExtConverterConverter (int format_out,
|
||||
void *data_obj,
|
||||
URL_Struct *URL_s,
|
||||
MWContext *window_id)
|
||||
{
|
||||
CVG_DataObject* obj;
|
||||
CV_ExtConverterStruct * ext_con_obj = (CV_ExtConverterStruct *) data_obj;
|
||||
NET_StreamClass* stream;
|
||||
struct sigaction newact;
|
||||
|
||||
TRACEMSG(("Setting up display stream. Have URL: %s\n", URL_s->address));
|
||||
|
||||
stream = PR_NEW(NET_StreamClass);
|
||||
if(stream == NULL)
|
||||
return(NULL);
|
||||
|
||||
memset(stream, 0, sizeof(NET_StreamClass));
|
||||
|
||||
obj = PR_NEW(CVG_DataObject);
|
||||
if (obj == NULL)
|
||||
return(NULL);
|
||||
memset(obj, 0, sizeof(CVG_DataObject));
|
||||
|
||||
stream->name = "Filter Stream";
|
||||
stream->complete = (MKStreamCompleteFunc) net_ExtConverterComplete;
|
||||
stream->abort = (MKStreamAbortFunc) net_ExtConverterAbort;
|
||||
stream->put_block = (MKStreamWriteFunc) net_ExtConverterWrite;
|
||||
stream->is_write_ready = (MKStreamWriteReadyFunc) net_ExtConverterWriteReady;
|
||||
stream->data_object = obj; /* document info object */
|
||||
stream->window_id = window_id;
|
||||
|
||||
/* Open the next stream.
|
||||
First, swap in the content-encoding or content-type of the document
|
||||
as we are about to convert it, to look up the proper next converter
|
||||
(and to avoid looping.) But once we have set up the stream, put the
|
||||
original encoding back, so that the URL_Struct is not permanently
|
||||
altered - foo.html.gz must still have content-encoding x-gzip even
|
||||
though it has been decoded for display.
|
||||
*/
|
||||
{
|
||||
char *old, *new;
|
||||
if (ext_con_obj->is_encoding_converter)
|
||||
{
|
||||
old = URL_s->content_encoding;
|
||||
new = PL_strdup (ext_con_obj->new_format);
|
||||
if (!new) return (NULL);
|
||||
URL_s->content_encoding = new;
|
||||
}
|
||||
else
|
||||
{
|
||||
old = URL_s->content_type;
|
||||
new = PL_strdup (ext_con_obj->new_format);
|
||||
if (!new) return (NULL);
|
||||
URL_s->content_type = new;
|
||||
}
|
||||
|
||||
obj->next_stream = NET_StreamBuilder (format_out, URL_s, window_id);
|
||||
|
||||
if (ext_con_obj->is_encoding_converter)
|
||||
{
|
||||
PR_Free (URL_s->content_encoding);
|
||||
URL_s->content_encoding = old;
|
||||
}
|
||||
else
|
||||
{
|
||||
PR_Free (URL_s->content_type);
|
||||
URL_s->content_type = old;
|
||||
}
|
||||
}
|
||||
|
||||
if (!obj->next_stream)
|
||||
return (NULL);
|
||||
|
||||
/* Open two pipes, one for writing to a subprocess, and one for reading
|
||||
from it (for a total of four file descriptors, I/O for us, and O/I
|
||||
for the kid.)
|
||||
*/
|
||||
{
|
||||
int infds [2];
|
||||
int outfds[2];
|
||||
pid_t forked;
|
||||
|
||||
if (pipe (infds))
|
||||
{
|
||||
perror ("creating input pipe");
|
||||
free (stream);
|
||||
free (obj);
|
||||
return 0;
|
||||
}
|
||||
if (pipe (outfds))
|
||||
{
|
||||
perror ("creating output pipe");
|
||||
free (stream);
|
||||
free (obj);
|
||||
return 0;
|
||||
}
|
||||
obj->infd = infds [0];
|
||||
obj->outfd = outfds [1];
|
||||
|
||||
/* Set our side of the pipes to be nonblocking. (It's important not
|
||||
to set the other side of the pipes to be nonblocking - that
|
||||
decision must be left up to the process on the other end. */
|
||||
|
||||
#if defined(O_NONBLOCK)
|
||||
# define NONBLOCK_FLAG O_NONBLOCK
|
||||
#elif defined(O_NDELAY)
|
||||
# define NONBLOCK_FLAG O_NDELAY
|
||||
#else
|
||||
ERROR!! neither O_NONBLOCK nor O_NDELAY are defined.
|
||||
#endif
|
||||
fcntl (obj->infd, F_SETFL, NONBLOCK_FLAG);
|
||||
fcntl (obj->outfd, F_SETFL, NONBLOCK_FLAG);
|
||||
#undef NONBLOCK_FLAG
|
||||
|
||||
obj->pid = 0;
|
||||
|
||||
#ifdef DEBUG_dp
|
||||
fprintf(stderr, "Ignoring sigchild.\n");
|
||||
#endif
|
||||
/* Setup signals so that SIGCHLD is ignored as we want to do waitpid
|
||||
* when the helperapp ends
|
||||
*/
|
||||
newact.sa_handler = SIG_DFL;
|
||||
newact.sa_flags = 0;
|
||||
sigfillset(&newact.sa_mask);
|
||||
sigaction (SIGCHLD, &newact, &obj->oldact);
|
||||
|
||||
switch (forked = fork ())
|
||||
{
|
||||
case -1:
|
||||
perror ("fork");
|
||||
close (outfds[0]);
|
||||
close (outfds[1]);
|
||||
close (infds [0]);
|
||||
close (infds [1]);
|
||||
free (stream);
|
||||
free (obj);
|
||||
/* Reset SIGCHLD signal hander before returning */
|
||||
sigaction(SIGCHLD, &obj->oldact, NULL);
|
||||
return 0;
|
||||
case 0:
|
||||
{
|
||||
/* This is the new process. exec() the filter here.
|
||||
We do this with sh to get tokenization and pipelines
|
||||
and all that junk.
|
||||
*/
|
||||
char *av[10];
|
||||
int ac = 0;
|
||||
|
||||
av [ac++] = "/bin/sh";
|
||||
av [ac++] = "-c";
|
||||
av [ac++] = ext_con_obj->command;
|
||||
av [ac++] = 0;
|
||||
|
||||
dup2 (outfds[0], 0); /* stdin */
|
||||
dup2 (infds [1], 1); /* stdout */
|
||||
/* dup2 (infds [1], 2); * stderr */
|
||||
|
||||
/* We have copied the two pipes to stdin/stdout.
|
||||
We no longer need the other file descriptors hanging around.
|
||||
(Actually I think we need to close these, or the other side
|
||||
of the pipe doesn't see an eof when we close stdout...)
|
||||
*/
|
||||
close (outfds[0]);
|
||||
close (outfds[1]);
|
||||
close (infds [0]);
|
||||
close (infds [1]);
|
||||
|
||||
execv (av[0], av);
|
||||
/* exec() should never return. */
|
||||
perror ("execv");
|
||||
exit (1); /* This only exits a child fork. */
|
||||
break;
|
||||
}
|
||||
default:
|
||||
/* This is the "old" process (subproc pid is in `forked'.) */
|
||||
obj->pid = forked;
|
||||
|
||||
/* These are the file descriptors we created for the benefit
|
||||
of the child process - we don't need them in the parent. */
|
||||
close (outfds[0]);
|
||||
close (infds [1]);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
TRACEMSG(("Returning stream from NET_ExtConverterConverter\n"));
|
||||
|
||||
return stream;
|
||||
}
|
||||
34
mozilla/network/cnvts/cvextcon.h
Normal file
34
mozilla/network/cnvts/cvextcon.h
Normal file
@@ -0,0 +1,34 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef CVEXTCON_H
|
||||
#define CVEXTCON_H
|
||||
|
||||
typedef struct _CV_ExtConverterStruct {
|
||||
char * command;
|
||||
char * new_format;
|
||||
Bool is_encoding_converter;
|
||||
} CV_ExtConverterStruct;
|
||||
|
||||
extern NET_StreamClass *
|
||||
NET_ExtConverterConverter(FO_Present_Types format_out,
|
||||
void *data_obj,
|
||||
URL_Struct *URL_s,
|
||||
MWContext *window_id);
|
||||
|
||||
#endif /* CVEXTCON_H */
|
||||
54
mozilla/network/cnvts/cvjscfg.c
Normal file
54
mozilla/network/cnvts/cvjscfg.c
Normal file
@@ -0,0 +1,54 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "cvjscfg.h"
|
||||
#include "cvsimple.h"
|
||||
#include "prefapi.h"
|
||||
|
||||
/*
|
||||
* jsc_complete
|
||||
*/
|
||||
PRIVATE void
|
||||
jsc_complete(void* bytes, int32 num_bytes)
|
||||
{
|
||||
#ifdef DEBUG_malmer
|
||||
extern FILE* real_stderr;
|
||||
|
||||
fwrite(bytes, sizeof(char), num_bytes, real_stderr);
|
||||
#endif
|
||||
|
||||
if ( bytes ) {
|
||||
PREF_EvaluateConfigScript(bytes, num_bytes, NULL, TRUE, TRUE);
|
||||
} else {
|
||||
/* If failover is ok, read the local cached config */
|
||||
}
|
||||
|
||||
/* Need to hash and save to disk here */
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* NET_JavascriptConfig
|
||||
*/
|
||||
MODULE_PRIVATE NET_StreamClass*
|
||||
NET_JavascriptConfig(int fmt, void* data_obj, URL_Struct* URL_s, MWContext* w)
|
||||
{
|
||||
return NET_SimpleStream(fmt, (void*) jsc_complete, URL_s, w);
|
||||
}
|
||||
|
||||
|
||||
28
mozilla/network/cnvts/cvjscfg.h
Normal file
28
mozilla/network/cnvts/cvjscfg.h
Normal file
@@ -0,0 +1,28 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/* By Daniel Malmer <malmer@netscape.com> */
|
||||
#ifndef __mkjscfg_h
|
||||
#define __mkjscfg_h
|
||||
|
||||
#include "net.h"
|
||||
|
||||
MODULE_PRIVATE NET_StreamClass*
|
||||
NET_JavascriptConfig(int fmt, void* data_obj, URL_Struct* URL_s, MWContext* w);
|
||||
|
||||
#endif
|
||||
1057
mozilla/network/cnvts/cvmime.c
Normal file
1057
mozilla/network/cnvts/cvmime.c
Normal file
File diff suppressed because it is too large
Load Diff
25
mozilla/network/cnvts/cvmime.h
Normal file
25
mozilla/network/cnvts/cvmime.h
Normal file
@@ -0,0 +1,25 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef CVMIME_H
|
||||
#define CVMIME_H
|
||||
|
||||
extern NET_StreamClass *
|
||||
NET_MimeEncodingConverter(int, void *, URL_Struct *, MWContext *);
|
||||
|
||||
#endif /* CVMIME_H */
|
||||
386
mozilla/network/cnvts/cvpics.c
Normal file
386
mozilla/network/cnvts/cvpics.c
Normal file
@@ -0,0 +1,386 @@
|
||||
|
||||
/* this set of functions parses an incoming stream of HTML and tries to find
|
||||
* any PICS label within it. It doesn't do anything accept parse the pics label
|
||||
* and finish
|
||||
*/
|
||||
#include "xp.h"
|
||||
#include "plstr.h"
|
||||
#include "prmem.h"
|
||||
#include "netutils.h"
|
||||
#include "mkselect.h"
|
||||
#include "mktcp.h"
|
||||
#include "mkgeturl.h"
|
||||
#include "mkstream.h"
|
||||
#include "pa_parse.h"
|
||||
#include "xpgetstr.h"
|
||||
#include "layout.h"
|
||||
#include "pics.h"
|
||||
|
||||
typedef enum StatesEnum {
|
||||
IN_CONTENT,
|
||||
IN_SCRIPT,
|
||||
ABOUT_TO_BEGIN_TAG,
|
||||
IN_BEGIN_TAG,
|
||||
IN_TAG,
|
||||
BEGIN_ATTRIBUTE_VALUE,
|
||||
IN_QUOTED_ATTRIBUTE_VALUE,
|
||||
IN_BROKEN_QUOTED_ATTRIBUTE_VALUE,
|
||||
IN_UNQUOTED_ATTRIBUTE_VALUE,
|
||||
IN_COMMENT,
|
||||
IN_AMPERSAND_THINGY
|
||||
} StatesEnum;
|
||||
|
||||
#define MAXTAGLEN 15
|
||||
|
||||
typedef struct _DataObject {
|
||||
MWContext *context;
|
||||
URL_Struct *URL_s;
|
||||
StatesEnum state;
|
||||
char tag[MAXTAGLEN+1];
|
||||
uint tag_index;
|
||||
int tag_type;
|
||||
PRBool in_broken_html;
|
||||
char *tag_data; /* the contents of the current tag */
|
||||
} DataObject;
|
||||
|
||||
extern int MK_CVCOLOR_SOURCE_OF;
|
||||
|
||||
PRIVATE void net_BeginPICSLabelFinderTag (DataObject *obj)
|
||||
{
|
||||
if(obj->tag_data)
|
||||
*obj->tag_data = '\0'; /* empty tag_data */
|
||||
|
||||
if (obj->tag_type == P_SCRIPT)
|
||||
{
|
||||
obj->tag_type = P_UNKNOWN;
|
||||
}
|
||||
obj->state = ABOUT_TO_BEGIN_TAG;
|
||||
return ;
|
||||
}
|
||||
|
||||
PRIVATE void net_EndPICSLabelFinderTag (DataObject *obj)
|
||||
{
|
||||
if(obj->in_broken_html)
|
||||
{
|
||||
obj->in_broken_html = PR_FALSE;
|
||||
}
|
||||
|
||||
if (obj->tag_type == P_SCRIPT)
|
||||
{
|
||||
obj->state = IN_SCRIPT;
|
||||
}
|
||||
else
|
||||
{
|
||||
obj->state = IN_CONTENT;
|
||||
}
|
||||
|
||||
/* check tag_data for a META tag */
|
||||
if(obj->tag_data && !PL_strncasecmp(obj->tag_data, "META", 4))
|
||||
{
|
||||
PA_Tag tmp_tag;
|
||||
char *name;
|
||||
|
||||
tmp_tag.type = P_META;
|
||||
tmp_tag.data = (void*)obj->tag_data;
|
||||
tmp_tag.data_len = PL_strlen((char*)tmp_tag.data);
|
||||
|
||||
name = (char *)lo_FetchParamValue(obj->context, &tmp_tag, PARAM_HTTP_EQUIV);
|
||||
|
||||
#define PICS_HEADER "PICS-Label"
|
||||
if(name && !PL_strcasecmp(name, PICS_HEADER))
|
||||
{
|
||||
char *label = (char *)lo_FetchParamValue(obj->context, &tmp_tag, PARAM_CONTENT);
|
||||
|
||||
if(label)
|
||||
{
|
||||
PICS_RatingsStruct * rs = PICS_ParsePICSLable(label);
|
||||
PR_Free(label);
|
||||
PICS_CompareToUserSettings(rs, obj->URL_s->address);
|
||||
PICS_FreeRatingsStruct(rs); /* handles NULL */
|
||||
}
|
||||
}
|
||||
|
||||
PR_FREEIF(name);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
PRIVATE int net_PICSLabelFinderWrite (NET_StreamClass *stream, CONST char *s, int32 l)
|
||||
{
|
||||
int32 i;
|
||||
CONST char *cp;
|
||||
DataObject *obj = (DataObject *)stream->data_object;
|
||||
char tiny_buf[8];
|
||||
|
||||
for(i = 0, cp = s; i < l; i++, cp++)
|
||||
{
|
||||
switch(obj->state)
|
||||
{
|
||||
case IN_CONTENT:
|
||||
/* do nothing until you find a '<' "<!--" or '&' */
|
||||
if(*cp == '<')
|
||||
{
|
||||
/* XXX we can miss a comment spanning a block boundary */
|
||||
if(i+4 <= l && !PL_strncmp(cp, "<!--", 4))
|
||||
{
|
||||
obj->state = IN_COMMENT;
|
||||
}
|
||||
else
|
||||
{
|
||||
net_BeginPICSLabelFinderTag(obj);
|
||||
}
|
||||
}
|
||||
else if(*cp == '&')
|
||||
{
|
||||
obj->state = IN_AMPERSAND_THINGY;
|
||||
}
|
||||
break;
|
||||
case IN_SCRIPT:
|
||||
/* do nothing until you find '</SCRIPT>' */
|
||||
if(*cp == '<')
|
||||
{
|
||||
/* XXX we can miss a </SCRIPT> spanning a block boundary */
|
||||
if(i+8 <= l && !PL_strncasecmp(cp, "</SCRIPT", 8))
|
||||
{
|
||||
net_BeginPICSLabelFinderTag(obj);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ABOUT_TO_BEGIN_TAG:
|
||||
/* we have seen the first '<'
|
||||
* once we see a non-whitespace character
|
||||
* we will be in the tag identifier
|
||||
*/
|
||||
if(*cp == '>')
|
||||
{
|
||||
net_EndPICSLabelFinderTag(obj);
|
||||
}
|
||||
else if(!NET_IS_SPACE(*cp))
|
||||
{
|
||||
/* capture all tag data */
|
||||
tiny_buf[0] = *cp;
|
||||
tiny_buf[1] = '\0';
|
||||
StrAllocCat(obj->tag_data, tiny_buf);
|
||||
|
||||
obj->state = IN_BEGIN_TAG;
|
||||
obj->tag_index = 0;
|
||||
obj->tag[obj->tag_index++] = *cp;
|
||||
|
||||
}
|
||||
break;
|
||||
case IN_BEGIN_TAG:
|
||||
/* go to the IN_TAG state when we see
|
||||
* the first whitespace
|
||||
*/
|
||||
|
||||
/* capture all tag data */
|
||||
tiny_buf[0] = *cp;
|
||||
tiny_buf[1] = '\0';
|
||||
StrAllocCat(obj->tag_data, tiny_buf);
|
||||
|
||||
if(NET_IS_SPACE(*cp))
|
||||
{
|
||||
obj->state = IN_TAG;
|
||||
obj->tag[obj->tag_index] = '\0';
|
||||
obj->tag_type = pa_tokenize_tag(obj->tag);
|
||||
}
|
||||
else if(*cp == '>')
|
||||
{
|
||||
net_EndPICSLabelFinderTag(obj);
|
||||
}
|
||||
else if(*cp == '<')
|
||||
{
|
||||
/* protect ourselves from markup */
|
||||
if(!obj->in_broken_html)
|
||||
{
|
||||
obj->in_broken_html = PR_TRUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (obj->tag_index < MAXTAGLEN)
|
||||
obj->tag[obj->tag_index++] = *cp;
|
||||
}
|
||||
break;
|
||||
case IN_TAG:
|
||||
/* capture all tag data */
|
||||
tiny_buf[0] = *cp;
|
||||
tiny_buf[1] = '\0';
|
||||
StrAllocCat(obj->tag_data, tiny_buf);
|
||||
|
||||
/* do nothing until you find a opening '=' or end '>' */
|
||||
if(*cp == '=')
|
||||
{
|
||||
obj->state = BEGIN_ATTRIBUTE_VALUE;
|
||||
}
|
||||
else if(*cp == '>')
|
||||
{
|
||||
net_EndPICSLabelFinderTag(obj);
|
||||
}
|
||||
break;
|
||||
case BEGIN_ATTRIBUTE_VALUE:
|
||||
/* capture all tag data */
|
||||
tiny_buf[0] = *cp;
|
||||
tiny_buf[1] = '\0';
|
||||
StrAllocCat(obj->tag_data, tiny_buf);
|
||||
|
||||
/* when we reach the first non-whitespace
|
||||
* we will enter the UNQUOTED or the QUOTED
|
||||
* ATTRIBUTE state
|
||||
*/
|
||||
if(!NET_IS_SPACE(*cp))
|
||||
{
|
||||
if(*cp == '"')
|
||||
{
|
||||
obj->state = IN_QUOTED_ATTRIBUTE_VALUE;
|
||||
/* no need to jump to the quoted attr handler
|
||||
* since this char can't be a dangerous char
|
||||
*/
|
||||
}
|
||||
else
|
||||
{
|
||||
obj->state = IN_UNQUOTED_ATTRIBUTE_VALUE;
|
||||
/* need to jump to the unquoted attr handler
|
||||
* since this char can be a dangerous character
|
||||
*/
|
||||
goto unquoted_attribute_jump_point;
|
||||
}
|
||||
}
|
||||
else if(*cp == '>')
|
||||
{
|
||||
net_EndPICSLabelFinderTag(obj);
|
||||
}
|
||||
break;
|
||||
case IN_UNQUOTED_ATTRIBUTE_VALUE:
|
||||
/* capture all tag data */
|
||||
tiny_buf[0] = *cp;
|
||||
tiny_buf[1] = '\0';
|
||||
StrAllocCat(obj->tag_data, tiny_buf);
|
||||
|
||||
unquoted_attribute_jump_point:
|
||||
/* do nothing until you find a whitespace */
|
||||
if(NET_IS_SPACE(*cp))
|
||||
{
|
||||
obj->state = IN_TAG;
|
||||
}
|
||||
else if(*cp == '>')
|
||||
{
|
||||
net_EndPICSLabelFinderTag(obj);
|
||||
}
|
||||
break;
|
||||
case IN_QUOTED_ATTRIBUTE_VALUE:
|
||||
/* capture all tag data */
|
||||
tiny_buf[0] = *cp;
|
||||
tiny_buf[1] = '\0';
|
||||
StrAllocCat(obj->tag_data, tiny_buf);
|
||||
|
||||
/* do nothing until you find a closing '"' */
|
||||
if(*cp == '\"')
|
||||
{
|
||||
if(obj->in_broken_html)
|
||||
{
|
||||
obj->in_broken_html = PR_FALSE;
|
||||
}
|
||||
obj->state = IN_TAG;
|
||||
}
|
||||
else if(*cp == '>')
|
||||
{
|
||||
/* probably a broken attribute value */
|
||||
if(!obj->in_broken_html)
|
||||
{
|
||||
obj->in_broken_html = PR_TRUE;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case IN_COMMENT:
|
||||
/* do nothing until you find a closing '-->' */
|
||||
if(!PL_strncmp(cp, "-->", 3))
|
||||
{
|
||||
cp += 2;
|
||||
i += 2;
|
||||
obj->state = IN_CONTENT;
|
||||
}
|
||||
break;
|
||||
case IN_AMPERSAND_THINGY:
|
||||
/* do nothing until you find a ';' or space */
|
||||
if(*cp == ';' || NET_IS_SPACE(*cp))
|
||||
{
|
||||
sprintf(tiny_buf, "%c", *cp);
|
||||
obj->state = IN_CONTENT;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
PR_ASSERT(0);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
/* is the stream ready for writeing?
|
||||
*/
|
||||
PRIVATE unsigned int net_PICSLabelFinderWriteReady (NET_StreamClass *stream)
|
||||
{
|
||||
return(MAX_WRITE_READY);
|
||||
}
|
||||
|
||||
|
||||
PRIVATE void net_PICSLabelFinderComplete (NET_StreamClass *stream)
|
||||
{
|
||||
}
|
||||
|
||||
PRIVATE void net_PICSLabelFinderAbort (NET_StreamClass *stream, int status)
|
||||
{
|
||||
}
|
||||
|
||||
PUBLIC NET_StreamClass *
|
||||
net_PICSLabelFinderStream (int format_out,
|
||||
void *data_obj,
|
||||
URL_Struct *URL_s,
|
||||
MWContext *window_id)
|
||||
{
|
||||
DataObject* obj;
|
||||
NET_StreamClass *new_stream;
|
||||
PRBool is_html_stream = PR_FALSE;
|
||||
|
||||
TRACEMSG(("Setting up PICSLabelFinder stream. Have URL: %s\n", URL_s->address));
|
||||
|
||||
new_stream = PR_NEWZAP(NET_StreamClass);
|
||||
|
||||
if(!new_stream)
|
||||
return NULL;
|
||||
|
||||
obj = PR_NEW(DataObject);
|
||||
|
||||
if (obj == NULL)
|
||||
{
|
||||
PR_Free(new_stream);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
memset(obj, 0, sizeof(DataObject));
|
||||
|
||||
obj->state = IN_CONTENT;
|
||||
|
||||
obj->tag_type = P_UNKNOWN;
|
||||
|
||||
obj->context = window_id;
|
||||
obj->URL_s = URL_s;
|
||||
|
||||
new_stream->name = "PICSLabelFinder";
|
||||
new_stream->complete = (MKStreamCompleteFunc) net_PICSLabelFinderComplete;
|
||||
new_stream->abort = (MKStreamAbortFunc) net_PICSLabelFinderAbort;
|
||||
new_stream->put_block = (MKStreamWriteFunc) net_PICSLabelFinderWrite;
|
||||
new_stream->is_write_ready = (MKStreamWriteReadyFunc)
|
||||
net_PICSLabelFinderWriteReady;
|
||||
new_stream->data_object = (void *) obj; /* document info object */
|
||||
new_stream->window_id = window_id;
|
||||
|
||||
/* don't cache this URL, since the content type is wrong */
|
||||
URL_s->dont_cache = PR_TRUE;
|
||||
|
||||
return new_stream;
|
||||
}
|
||||
11
mozilla/network/cnvts/cvpics.h
Normal file
11
mozilla/network/cnvts/cvpics.h
Normal file
@@ -0,0 +1,11 @@
|
||||
|
||||
#ifndef CVPICS_H
|
||||
#define CVPICS_H
|
||||
|
||||
PUBLIC NET_StreamClass *
|
||||
net_PICSLabelFinderStream (int format_out,
|
||||
void *data_obj,
|
||||
URL_Struct *URL_s,
|
||||
MWContext *window_id);
|
||||
|
||||
#endif /* CVPICS_H */
|
||||
133
mozilla/network/cnvts/cvproxy.c
Normal file
133
mozilla/network/cnvts/cvproxy.c
Normal file
@@ -0,0 +1,133 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
#include "xp.h"
|
||||
#include "netutils.h"
|
||||
#include "mkselect.h"
|
||||
#include "mktcp.h"
|
||||
#include "mkgeturl.h"
|
||||
#include "mkstream.h"
|
||||
|
||||
typedef struct _ProxyObj {
|
||||
PRBool past_first_line;
|
||||
PRBool definately_send_headers;
|
||||
char *content_type;
|
||||
char *content_encoding;
|
||||
} ProxyObj;
|
||||
|
||||
PRIVATE int net_proxy_write (NET_StreamClass *stream, CONST char* s, int32 len)
|
||||
{
|
||||
ProxyObj *obj=stream->data_object;
|
||||
/* send HTTP headers if not already getting an HTTP doc
|
||||
*/
|
||||
if(!obj->past_first_line)
|
||||
{
|
||||
if(obj->definately_send_headers || strncmp(s, "HTTP/", len >= 5 ? 5 : len))
|
||||
{
|
||||
write(1, "HTTP/1.0 200 OK\r\n",17);
|
||||
write(1, "Content-type: ",14);
|
||||
write(1, obj->content_type, PL_strlen(obj->content_type));
|
||||
if(obj->content_encoding)
|
||||
{
|
||||
write(1, "\r\nContent-encoding: ",18);
|
||||
write(1, obj->content_encoding, PL_strlen(obj->content_encoding));
|
||||
}
|
||||
write(1, "\r\nServer: MKLib proxy agent\r\n",29);
|
||||
write(1, "\r\n", 2); /* finish it */
|
||||
}
|
||||
|
||||
obj->past_first_line = PR_TRUE;
|
||||
}
|
||||
|
||||
write(1, s, len);
|
||||
return(1);
|
||||
}
|
||||
|
||||
PRIVATE unsigned int net_proxy_WriteReady (NET_StreamClass *stream)
|
||||
{
|
||||
return(MAX_WRITE_READY); /* always ready for writing */
|
||||
}
|
||||
|
||||
|
||||
PRIVATE void net_proxy_complete (NET_StreamClass *stream)
|
||||
{
|
||||
ProxyObj *obj=stream->data_object;
|
||||
FREEIF(obj->content_type);
|
||||
FREEIF(obj->content_encoding);
|
||||
FREE(obj);
|
||||
return;
|
||||
}
|
||||
|
||||
PRIVATE void net_proxy_abort (NET_StreamClass *stream, int status)
|
||||
{
|
||||
ProxyObj *obj=stream->data_object;
|
||||
FREEIF(obj->content_type);
|
||||
FREEIF(obj->content_encoding);
|
||||
FREE(obj);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
PUBLIC NET_StreamClass *
|
||||
NET_ProxyConverter(int format_out,
|
||||
void *data_obj,
|
||||
URL_Struct *URL_s,
|
||||
MWContext *window_id)
|
||||
{
|
||||
NET_StreamClass* stream;
|
||||
ProxyObj * obj;
|
||||
|
||||
TRACEMSG(("Setting up display stream. Have URL: %s \n%s\n",
|
||||
URL_s->address, URL_s->content_type));
|
||||
|
||||
stream = PR_NEW(NET_StreamClass);
|
||||
if(stream == NULL)
|
||||
return(NULL);
|
||||
|
||||
obj = PR_NEW(ProxyObj);
|
||||
if(obj == NULL)
|
||||
{
|
||||
FREE(stream);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
memset(obj, 0, sizeof(ProxyObj));
|
||||
|
||||
stream->data_object = obj;
|
||||
|
||||
|
||||
stream->name = "ProxyWriter";
|
||||
stream->complete = (MKStreamCompleteFunc) net_proxy_complete;
|
||||
stream->abort = (MKStreamAbortFunc) net_proxy_abort;
|
||||
stream->put_block = (MKStreamWriteFunc) net_proxy_write;
|
||||
stream->is_write_ready = (MKStreamWriteReadyFunc) net_proxy_WriteReady;
|
||||
stream->window_id = window_id;
|
||||
|
||||
TRACEMSG(("Returning stream from display_converter\n"));
|
||||
|
||||
/* send HTTP headers if not already getting an HTTP doc
|
||||
*/
|
||||
if(PL_strncasecmp(URL_s->address,"http:",5))
|
||||
{
|
||||
obj->definately_send_headers = TRUE;
|
||||
}
|
||||
StrAllocCopy(obj->content_type, URL_s->content_type);
|
||||
StrAllocCopy(obj->content_encoding, URL_s->content_encoding);
|
||||
|
||||
return stream;
|
||||
}
|
||||
22
mozilla/network/cnvts/cvproxy.h
Normal file
22
mozilla/network/cnvts/cvproxy.h
Normal file
@@ -0,0 +1,22 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
extern NET_StreamClass* NET_ProxyConverter (FO_Present_Types format_out,
|
||||
void *data_obj,
|
||||
URL_Struct *URL_s,
|
||||
MWContext *window_id);
|
||||
124
mozilla/network/cnvts/cvsimple.c
Normal file
124
mozilla/network/cnvts/cvsimple.c
Normal file
@@ -0,0 +1,124 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
/**********************************************************************
|
||||
cvsimple.c
|
||||
By Daniel Malmer <malmer@netscape.com>
|
||||
1/14/98
|
||||
|
||||
Simple converter that just saves the data in a buffer.
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
#include "cvsimple.h"
|
||||
#include "xp.h"
|
||||
#include "prmem.h"
|
||||
|
||||
typedef void (*simple_complete_t)(void* bytes, int32 bytes_written);
|
||||
|
||||
typedef struct {
|
||||
unsigned char* bytes;
|
||||
int32 bytes_written;
|
||||
int32 max_bytes;
|
||||
simple_complete_t complete;
|
||||
} NET_SimpleStreamData;
|
||||
|
||||
|
||||
/*
|
||||
* simple_complete
|
||||
*/
|
||||
PRIVATE void
|
||||
simple_complete(NET_StreamClass *stream)
|
||||
{
|
||||
NET_SimpleStreamData* obj = (NET_SimpleStreamData*) stream->data_object;
|
||||
|
||||
if ( obj && obj->complete ) {
|
||||
(obj->complete)(obj->bytes, obj->bytes_written);
|
||||
}
|
||||
|
||||
if ( obj && obj->bytes ) PR_Free(obj->bytes);
|
||||
if ( obj ) PR_Free(obj);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* simple_abort
|
||||
*/
|
||||
PRIVATE void
|
||||
simple_abort(NET_StreamClass *stream, int status)
|
||||
{
|
||||
NET_SimpleStreamData* obj = (NET_SimpleStreamData*) stream->data_object;
|
||||
|
||||
if ( obj && obj->bytes ) PR_Free(obj->bytes);
|
||||
if ( obj ) PR_Free(obj);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* simple_write
|
||||
*/
|
||||
PRIVATE int
|
||||
simple_write(NET_StreamClass *stream, const char* str, int32 len)
|
||||
{
|
||||
NET_SimpleStreamData* obj = (NET_SimpleStreamData*) stream->data_object;
|
||||
|
||||
if ( obj->bytes_written + len > obj->max_bytes ) {
|
||||
/* Round to nearest 1024 */
|
||||
obj->max_bytes = ( ( ( (obj->max_bytes + len) >> 10) + 1) << 10);
|
||||
obj->bytes = PR_Realloc(obj->bytes, obj->max_bytes);
|
||||
}
|
||||
|
||||
memcpy(obj->bytes + obj->bytes_written, str, len);
|
||||
obj->bytes_written+= len;
|
||||
|
||||
return MK_DATA_LOADED;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* simple_write_ready
|
||||
*/
|
||||
PRIVATE unsigned int
|
||||
simple_write_ready(NET_StreamClass *stream)
|
||||
{
|
||||
return MAX_WRITE_READY;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* NET_SimpleStream
|
||||
* Simple stream constructor.
|
||||
*/
|
||||
MODULE_PRIVATE NET_StreamClass*
|
||||
NET_SimpleStream(int fmt, void* data_obj, URL_Struct* URL_s, MWContext* w)
|
||||
{
|
||||
NET_SimpleStreamData* obj;
|
||||
|
||||
if ( (obj = PR_NEWZAP(NET_SimpleStreamData)) == NULL ) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
obj->bytes = NULL;
|
||||
obj->bytes_written = 0;
|
||||
obj->max_bytes = 0;
|
||||
obj->complete = (simple_complete_t) data_obj;
|
||||
|
||||
return NET_NewStream("SimpleStream", simple_write, simple_complete,
|
||||
simple_abort, simple_write_ready, obj, w);
|
||||
}
|
||||
|
||||
|
||||
36
mozilla/network/cnvts/cvsimple.h
Normal file
36
mozilla/network/cnvts/cvsimple.h
Normal file
@@ -0,0 +1,36 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
/**********************************************************************
|
||||
cvsimple.h
|
||||
By Daniel Malmer <malmer@netscape.com>
|
||||
1/14/98
|
||||
|
||||
Simple converter that just saves the data in a buffer.
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
|
||||
#ifndef __cvsimple_h
|
||||
#define __cvsimple_h
|
||||
|
||||
#include "net.h"
|
||||
|
||||
MODULE_PRIVATE NET_StreamClass*
|
||||
NET_SimpleStream(int fmt, void* data_obj, URL_Struct* URL_s, MWContext* w);
|
||||
|
||||
#endif
|
||||
486
mozilla/network/cnvts/cvunzip.c
Normal file
486
mozilla/network/cnvts/cvunzip.c
Normal file
@@ -0,0 +1,486 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/* Please leave outside of ifdef for windows precompiled headers */
|
||||
#include "xp.h"
|
||||
#include "prmem.h"
|
||||
#include "netutils.h"
|
||||
#include "mkselect.h"
|
||||
#include "mktcp.h"
|
||||
#include "mkgeturl.h"
|
||||
#include "cvunzip.h"
|
||||
|
||||
#ifdef MOZILLA_CLIENT
|
||||
|
||||
#include "mkstream.h"
|
||||
#include "zlib.h"
|
||||
|
||||
extern int MK_OUT_OF_MEMORY;
|
||||
extern int MK_BAD_GZIP_HEADER;
|
||||
|
||||
typedef struct _DataObject {
|
||||
NET_StreamClass *next_stream;
|
||||
z_stream d_stream; /* decompression stream */
|
||||
unsigned char *dcomp_buf;
|
||||
uint32 dcomp_buf_size;
|
||||
PRBool is_done;
|
||||
PRBool checking_crc_footer;
|
||||
unsigned char *incoming_buf;
|
||||
uint32 incoming_buf_size;
|
||||
PRBool header_skipped;
|
||||
URL_Struct *URL_s;
|
||||
uint32 crc_check;
|
||||
} DataObject;
|
||||
|
||||
#define DECOMP_BUF_SIZE NET_Socket_Buffer_Size*2
|
||||
|
||||
enum check_header_response {
|
||||
HEADER_OK,
|
||||
BAD_HEADER,
|
||||
NEED_MORE_HEADER
|
||||
};
|
||||
|
||||
static uint32 gz_magic[2] = {0x1f, 0x8b}; /* gzip magic header */
|
||||
|
||||
/* gzip flag byte */
|
||||
#define ASCII_FLAG 0x01 /* bit 0 set: file probably ascii text */
|
||||
#define HEAD_CRC 0x02 /* bit 1 set: header CRC present */
|
||||
#define EXTRA_FIELD 0x04 /* bit 2 set: extra field present */
|
||||
#define ORIG_NAME 0x08 /* bit 3 set: original file name present */
|
||||
#define COMMENT 0x10 /* bit 4 set: file comment present */
|
||||
#define RESERVED 0xE0 /* bits 5..7: reserved */
|
||||
|
||||
/* code copied from Zlib please see zlib.h for copyright statement */
|
||||
/* ===========================================================================
|
||||
Check the gzip header of a gz_stream opened for reading. Set the stream
|
||||
mode to transparent if the gzip magic header is not present; set s->err
|
||||
to Z_DATA_ERROR if the magic header is present but the rest of the header
|
||||
is incorrect.
|
||||
IN assertion: the stream s has already been created sucessfully;
|
||||
s->stream.avail_in is zero for the first time, but may be non-zero
|
||||
for concatenated .gz files.
|
||||
*/
|
||||
static enum check_header_response
|
||||
check_header(unsigned char *header, uint32 header_length, uint32 *actual_header_size)
|
||||
{
|
||||
int method; /* method byte */
|
||||
int flags; /* flags byte */
|
||||
uInt len;
|
||||
uint32 c;
|
||||
uint32 orig_header_size = header_length;
|
||||
|
||||
/* header must be at least 10 bytes */
|
||||
if(header_length < 10)
|
||||
return NEED_MORE_HEADER;
|
||||
|
||||
/* Check the gzip magic header */
|
||||
for (len = 0; len < 2; len++) {
|
||||
c = (uint32) *header++;
|
||||
header_length--;
|
||||
if (c != gz_magic[len]) {
|
||||
return BAD_HEADER;
|
||||
}
|
||||
}
|
||||
method = *header++;
|
||||
header_length--;
|
||||
flags = *header++;
|
||||
header_length--;
|
||||
if (method != Z_DEFLATED || (flags & RESERVED) != 0) {
|
||||
return BAD_HEADER;
|
||||
}
|
||||
|
||||
/* Discard time, xflags and OS code: */
|
||||
for (len = 0; len < 6; len++)
|
||||
{
|
||||
header++;
|
||||
header_length--;
|
||||
}
|
||||
|
||||
/* OK we now passed the safe 10 byte boundary, we need to check from here
|
||||
* on out to make sure we have enough data
|
||||
*/
|
||||
|
||||
if ((flags & EXTRA_FIELD) != 0) { /* skip the extra field */
|
||||
if(header_length < 2)
|
||||
return NEED_MORE_HEADER;
|
||||
|
||||
len = (uInt)*header++;
|
||||
header_length--;
|
||||
len += ((uInt)*header++)<<8;
|
||||
header_length--;
|
||||
|
||||
/* len is garbage if EOF but the loop below will quit anyway */
|
||||
|
||||
if(header_length < len)
|
||||
return NEED_MORE_HEADER;
|
||||
|
||||
while (len-- != 0)
|
||||
{
|
||||
header++;
|
||||
header_length--;
|
||||
}
|
||||
}
|
||||
if ((flags & ORIG_NAME) != 0) { /* skip the original file name */
|
||||
|
||||
if(header_length < 1)
|
||||
return NEED_MORE_HEADER;
|
||||
|
||||
while (*header != '\0')
|
||||
{
|
||||
header++;
|
||||
header_length--;
|
||||
|
||||
if(header_length == 0)
|
||||
return NEED_MORE_HEADER;
|
||||
}
|
||||
|
||||
/* skip null byte */
|
||||
header++;
|
||||
header_length--;
|
||||
}
|
||||
if ((flags & COMMENT) != 0) { /* skip the .gz file comment */
|
||||
|
||||
if(header_length < 1)
|
||||
return NEED_MORE_HEADER;
|
||||
|
||||
while (*header != '\0')
|
||||
{
|
||||
header++;
|
||||
header_length--;
|
||||
|
||||
if(header_length == 0)
|
||||
return NEED_MORE_HEADER;
|
||||
}
|
||||
|
||||
/* skip null byte */
|
||||
header++;
|
||||
header_length--;
|
||||
|
||||
}
|
||||
if ((flags & HEAD_CRC) != 0) { /* skip the header crc */
|
||||
|
||||
if(header_length < 2)
|
||||
return NEED_MORE_HEADER;
|
||||
|
||||
for (len = 0; len < 2; len++)
|
||||
{
|
||||
header++;
|
||||
header_length--;
|
||||
}
|
||||
}
|
||||
|
||||
*actual_header_size = orig_header_size - header_length;
|
||||
|
||||
return HEADER_OK;
|
||||
}
|
||||
|
||||
PRIVATE int
|
||||
do_end_crc_check(DataObject *obj)
|
||||
{
|
||||
|
||||
if(obj->incoming_buf_size >= 8)
|
||||
{
|
||||
uint32 crc_int;
|
||||
uint32 size_int;
|
||||
|
||||
obj->checking_crc_footer = PR_FALSE;
|
||||
obj->is_done = PR_TRUE;
|
||||
|
||||
crc_int = (uint32)obj->incoming_buf[0];
|
||||
crc_int += (uint32)obj->incoming_buf[1]<<8;
|
||||
crc_int += (uint32)obj->incoming_buf[2]<<16;
|
||||
crc_int += (uint32)obj->incoming_buf[3]<<24;
|
||||
|
||||
size_int = (uint32)obj->incoming_buf[4];
|
||||
size_int += (uint32)obj->incoming_buf[5]<<8;
|
||||
size_int += (uint32)obj->incoming_buf[6]<<16;
|
||||
size_int += (uint32)obj->incoming_buf[7]<<24;
|
||||
|
||||
if(obj->crc_check != crc_int
|
||||
|| obj->d_stream.total_out != size_int)
|
||||
{
|
||||
/* crc or size checksum failure */
|
||||
obj->URL_s->error_msg = NET_ExplainErrorDetails(MK_BAD_GZIP_HEADER);
|
||||
return MK_BAD_GZIP_HEADER;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0; /* need more data */
|
||||
}
|
||||
|
||||
PRIVATE int net_UnZipWrite (NET_StreamClass *stream, CONST char* s, int32 l)
|
||||
{
|
||||
int err;
|
||||
uint32 prev_total_out;
|
||||
uint32 new_data_total_out;
|
||||
uint32 input_used_up, input_left_over;
|
||||
char * tempPtr = NULL;
|
||||
DataObject *obj=stream->data_object;
|
||||
if(obj->is_done)
|
||||
{
|
||||
/* multipart gzip? */
|
||||
PR_ASSERT(0);
|
||||
return (1);
|
||||
}
|
||||
|
||||
BlockAllocCat( tempPtr, obj->incoming_buf_size, s, l);
|
||||
obj->incoming_buf = (unsigned char*)tempPtr;
|
||||
|
||||
if(!obj->incoming_buf)
|
||||
return MK_OUT_OF_MEMORY;
|
||||
obj->incoming_buf_size += l;
|
||||
|
||||
/* parse and skip the header */
|
||||
if(!obj->header_skipped)
|
||||
{
|
||||
uint32 actual_header_size;
|
||||
enum check_header_response status;
|
||||
|
||||
status = check_header((unsigned char *)obj->incoming_buf, obj->incoming_buf_size, &actual_header_size);
|
||||
|
||||
if(status == HEADER_OK)
|
||||
{
|
||||
/* squash the header */
|
||||
obj->incoming_buf_size -= actual_header_size;
|
||||
memmove(obj->incoming_buf,
|
||||
obj->incoming_buf+actual_header_size,
|
||||
obj->incoming_buf_size);
|
||||
|
||||
obj->header_skipped = PR_TRUE;
|
||||
}
|
||||
else if(status == BAD_HEADER)
|
||||
{
|
||||
obj->URL_s->error_msg = NET_ExplainErrorDetails(MK_BAD_GZIP_HEADER);
|
||||
return MK_BAD_GZIP_HEADER;
|
||||
}
|
||||
else if(status == NEED_MORE_HEADER)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
PR_ASSERT(0);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else if(obj->checking_crc_footer)
|
||||
{
|
||||
return do_end_crc_check(obj);
|
||||
}
|
||||
|
||||
obj->d_stream.next_in = (unsigned char *)obj->incoming_buf;
|
||||
obj->d_stream.avail_in = obj->incoming_buf_size;
|
||||
obj->d_stream.next_out = (unsigned char *)obj->dcomp_buf;
|
||||
obj->d_stream.avail_out = obj->dcomp_buf_size;
|
||||
|
||||
if(obj->d_stream.avail_in <= 0)
|
||||
return 1; /* wait for more data */
|
||||
|
||||
prev_total_out = obj->d_stream.total_out;
|
||||
|
||||
/* need to loop to finish for small output bufs */
|
||||
while(1)
|
||||
{
|
||||
err = inflate(&obj->d_stream, Z_NO_FLUSH);
|
||||
|
||||
/* the amount of new uncompressed data is: */
|
||||
new_data_total_out = obj->d_stream.total_out - prev_total_out;
|
||||
|
||||
if(new_data_total_out > 0)
|
||||
{
|
||||
obj->crc_check = crc32(obj->crc_check,
|
||||
obj->dcomp_buf,
|
||||
new_data_total_out);
|
||||
|
||||
(*obj->next_stream->put_block)(obj->next_stream,
|
||||
(char *) obj->dcomp_buf,
|
||||
new_data_total_out);
|
||||
|
||||
|
||||
}
|
||||
|
||||
obj->d_stream.avail_out = obj->dcomp_buf_size;
|
||||
obj->d_stream.next_out = (unsigned char *)obj->dcomp_buf;
|
||||
prev_total_out = obj->d_stream.total_out;
|
||||
|
||||
if(err == Z_STREAM_END)
|
||||
{
|
||||
obj->checking_crc_footer = PR_TRUE;
|
||||
break;
|
||||
}
|
||||
else if(err != Z_OK)
|
||||
{
|
||||
/* need to get more data on next pass
|
||||
* @@@ should check for more critical errors
|
||||
*/
|
||||
break;
|
||||
}
|
||||
else if(obj->d_stream.avail_in <= 0)
|
||||
{
|
||||
/* need more data */
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* remove the part that has already been decoding from the incoming buf */
|
||||
input_left_over = obj->d_stream.avail_in;
|
||||
|
||||
if(input_left_over > 0)
|
||||
{
|
||||
input_used_up = obj->incoming_buf_size - input_left_over;
|
||||
memmove(obj->incoming_buf, obj->incoming_buf+input_used_up, input_left_over);
|
||||
obj->incoming_buf_size = input_left_over;
|
||||
}
|
||||
else
|
||||
{
|
||||
obj->incoming_buf_size = 0;
|
||||
}
|
||||
|
||||
if(obj->checking_crc_footer == PR_TRUE)
|
||||
{
|
||||
return do_end_crc_check(obj);
|
||||
}
|
||||
|
||||
return(1);
|
||||
}
|
||||
|
||||
/* is the stream ready for writeing?
|
||||
*/
|
||||
PRIVATE unsigned int net_UnZipWriteReady (NET_StreamClass * stream)
|
||||
{
|
||||
DataObject *obj=stream->data_object;
|
||||
return((*obj->next_stream->is_write_ready)(obj->next_stream)); /* always ready for writing */
|
||||
}
|
||||
|
||||
|
||||
PRIVATE void net_UnZipComplete (NET_StreamClass *stream)
|
||||
{
|
||||
DataObject *obj=stream->data_object;
|
||||
int err;
|
||||
|
||||
(*obj->next_stream->complete)(obj->next_stream);
|
||||
|
||||
err = inflateEnd(&(obj->d_stream));
|
||||
PR_ASSERT(err == Z_OK);
|
||||
|
||||
if(!obj->is_done)
|
||||
{
|
||||
/* we didn't complete the crc and size checks */
|
||||
/* @@@ not sure what to do here yet */
|
||||
PR_ASSERT(0);
|
||||
}
|
||||
|
||||
PR_Free(obj->dcomp_buf);
|
||||
PR_Free(obj);
|
||||
return;
|
||||
}
|
||||
|
||||
PRIVATE void net_UnZipAbort (NET_StreamClass *stream, int status)
|
||||
{
|
||||
DataObject *obj=stream->data_object;
|
||||
int err;
|
||||
|
||||
(*obj->next_stream->abort)(obj->next_stream, status);
|
||||
|
||||
err = inflateEnd(&(obj->d_stream));
|
||||
PR_ASSERT(err == Z_OK);
|
||||
|
||||
PR_Free(obj->dcomp_buf);
|
||||
PR_Free(obj);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
PUBLIC NET_StreamClass *
|
||||
NET_UnZipConverter (int format_out,
|
||||
void *data_obj,
|
||||
URL_Struct *URL_s,
|
||||
MWContext *window_id)
|
||||
{
|
||||
DataObject* obj;
|
||||
NET_StreamClass* stream;
|
||||
int err;
|
||||
|
||||
TRACEMSG(("Setting up display stream. Have URL: %s\n", URL_s->address));
|
||||
|
||||
stream = PR_NEW(NET_StreamClass);
|
||||
if(stream == NULL)
|
||||
return(NULL);
|
||||
|
||||
obj = PR_NEWZAP(DataObject);
|
||||
if (obj == NULL)
|
||||
{
|
||||
PR_Free(stream);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
stream->name = "UnZiper";
|
||||
stream->complete = (MKStreamCompleteFunc) net_UnZipComplete;
|
||||
stream->abort = (MKStreamAbortFunc) net_UnZipAbort;
|
||||
stream->put_block = (MKStreamWriteFunc) net_UnZipWrite;
|
||||
stream->is_write_ready = (MKStreamWriteReadyFunc) net_UnZipWriteReady;
|
||||
stream->data_object = obj; /* document info object */
|
||||
stream->window_id = window_id;
|
||||
|
||||
obj->dcomp_buf = PR_Malloc(DECOMP_BUF_SIZE);
|
||||
obj->dcomp_buf_size = DECOMP_BUF_SIZE;
|
||||
|
||||
if(!obj->dcomp_buf)
|
||||
{
|
||||
PR_Free(stream);
|
||||
PR_Free(obj);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
obj->URL_s = URL_s;
|
||||
|
||||
obj->d_stream.zalloc = (alloc_func)0;
|
||||
obj->d_stream.zfree = (free_func)0;
|
||||
obj->d_stream.opaque = (voidpf)0;
|
||||
|
||||
err = inflateInit2(&obj->d_stream, -15);
|
||||
|
||||
if(err != Z_OK)
|
||||
{
|
||||
PR_Free(stream);
|
||||
PR_Free(obj);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* create the next stream, but strip the compressed encoding */
|
||||
PR_FREEIF(URL_s->content_encoding);
|
||||
URL_s->content_encoding = NULL;
|
||||
obj->next_stream = NET_StreamBuilder(format_out, URL_s, window_id);
|
||||
|
||||
if(!obj->next_stream)
|
||||
{
|
||||
inflateEnd(&obj->d_stream);
|
||||
PR_Free(stream);
|
||||
PR_Free(obj);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
TRACEMSG(("Returning stream from NET_UnZipConverter\n"));
|
||||
|
||||
return stream;
|
||||
}
|
||||
|
||||
#endif /* MOZILLA_CLIENT */
|
||||
28
mozilla/network/cnvts/cvunzip.h
Normal file
28
mozilla/network/cnvts/cvunzip.h
Normal file
@@ -0,0 +1,28 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef CVUNZIP_H
|
||||
#define CVUNZIP_H
|
||||
|
||||
NET_StreamClass *
|
||||
NET_UnZipConverter (int format_out,
|
||||
void *data_obj,
|
||||
URL_Struct *URL_s,
|
||||
MWContext *window_id);
|
||||
|
||||
#endif /* CVUNZIP_H */
|
||||
585
mozilla/network/cnvts/cvview.c
Normal file
585
mozilla/network/cnvts/cvview.c
Normal file
@@ -0,0 +1,585 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/* Please leave outside of ifdef for windows precompiled headers */
|
||||
#include "xp.h"
|
||||
#include "plstr.h"
|
||||
#include "netutils.h"
|
||||
#include "mkfe.h"
|
||||
#include "mkselect.h"
|
||||
#include "mktcp.h"
|
||||
#include "mkgeturl.h"
|
||||
#include <signal.h>
|
||||
|
||||
#ifdef MOZILLA_CLIENT
|
||||
|
||||
#include "mkstream.h"
|
||||
#include "mkparse.h"
|
||||
#include "cvview.h"
|
||||
|
||||
#include "libmime.h"
|
||||
|
||||
|
||||
/* for XP_GetString() */
|
||||
#include <xpgetstr.h>
|
||||
extern int XP_CONFIRM_EXEC_UNIXCMD_ARE;
|
||||
extern int XP_CONFIRM_EXEC_UNIXCMD_MAYBE;
|
||||
extern int XP_ALERT_UNABLE_INVOKEVIEWER;
|
||||
extern int MK_UNABLE_TO_OPEN_TMP_FILE;
|
||||
|
||||
|
||||
typedef struct _CV_DataObject {
|
||||
FILE * fp;
|
||||
char * filename;
|
||||
char * command;
|
||||
char * url;
|
||||
unsigned int stream_block_size;
|
||||
int32 cur_size;
|
||||
int32 tot_size;
|
||||
MWContext * context;
|
||||
} CV_DataObject;
|
||||
|
||||
|
||||
/*
|
||||
** build_viewer_cmd
|
||||
** Build up the command for forking the external viewer.
|
||||
** Argument list is the template for the command and the a set of
|
||||
** (char,char*) pairs of characters to be recognized as '%' escapes
|
||||
** and what they should expand to, terminated with a 0.
|
||||
**
|
||||
** Return value is a malloc'ed string, must be freed when command is done.
|
||||
**
|
||||
** Example:
|
||||
** char* s=build_viewer(line_from_mailcap, 's', tmpFile, 'u', url, 0);
|
||||
**
|
||||
** I'm completely unsure what to do about security considerations and
|
||||
** encodings. Should the URL get % encoded. What if it contains "bad"
|
||||
** characters. etc. etc. etc
|
||||
*/
|
||||
|
||||
char*
|
||||
build_viewer_cmd(char *template, ...)
|
||||
{
|
||||
va_list args;
|
||||
char *ret, *from, *to;
|
||||
int len;
|
||||
|
||||
if (template == NULL)
|
||||
return NULL;
|
||||
|
||||
len = strlen(template);
|
||||
ret = (char*) malloc(len+1);
|
||||
if (ret == NULL)
|
||||
return NULL;
|
||||
|
||||
from = template, to = ret;
|
||||
|
||||
while (*from) {
|
||||
if (*from != '%' || *++from == '%') {
|
||||
*to++ = *from++;
|
||||
} else {
|
||||
|
||||
/*
|
||||
** We have a % escape, now look through all the arguments for
|
||||
** a matching one. When one is found, substitute in the
|
||||
** passed value. If none is found, the % and following character
|
||||
** get swallowed.
|
||||
*/
|
||||
char argc;
|
||||
char* argv;
|
||||
|
||||
va_start(args, template);
|
||||
while ((argc = va_arg(args, int)) != 0) {
|
||||
argv = va_arg(args, char*);
|
||||
if (*from == argc) {
|
||||
int off = to - ret;
|
||||
int arglen = strlen(argv);
|
||||
|
||||
len = len + arglen - 2;
|
||||
ret = (char*) realloc(ret, len + 1);
|
||||
if (ret == NULL)
|
||||
return NULL;
|
||||
PL_strcpy(ret + off, argv);
|
||||
to = ret + off + arglen;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (*from) from++; /* skip char following % unless it was last */
|
||||
va_end(args);
|
||||
}
|
||||
}
|
||||
*to = '\0';
|
||||
return ret;
|
||||
}
|
||||
|
||||
PRIVATE int net_ExtViewWrite (NET_StreamClass *stream, CONST char* s, int32 l)
|
||||
{
|
||||
CV_DataObject *obj=stream->data_object;
|
||||
if(obj->tot_size)
|
||||
{
|
||||
obj->cur_size += l;
|
||||
|
||||
obj->context->funcs->SetProgressBarPercent(obj->context, (obj->cur_size*100)/obj->tot_size);
|
||||
}
|
||||
|
||||
/* TRACEMSG(("Length of string passed to display: %d\n",l));
|
||||
*/
|
||||
return(fwrite((char *) s, 1, l, obj->fp));
|
||||
}
|
||||
|
||||
PRIVATE int net_ExtViewWriteReady (NET_StreamClass * stream)
|
||||
{
|
||||
CV_DataObject *obj=stream->data_object;
|
||||
fd_set write_fds;
|
||||
struct timeval timeout;
|
||||
int ret;
|
||||
|
||||
if(obj->command)
|
||||
{
|
||||
return(MAX_WRITE_READY); /* never wait for files */
|
||||
}
|
||||
|
||||
timeout.tv_sec = 0;
|
||||
timeout.tv_usec = 1; /* minimum hopefully */
|
||||
|
||||
memset(&write_fds, 0, sizeof(fd_set));
|
||||
|
||||
FD_SET(fileno(obj->fp), &write_fds);
|
||||
|
||||
ret = select(fileno(obj->fp)+1, NULL, &write_fds, NULL, &timeout);
|
||||
|
||||
if(ret)
|
||||
return(obj->stream_block_size); /* read in a max of 8000 bytes */
|
||||
else
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
PRIVATE void net_ExtViewComplete (NET_StreamClass *stream)
|
||||
{
|
||||
CV_DataObject *obj=stream->data_object;
|
||||
obj->context->funcs->SetProgressBarPercent(obj->context, 100);
|
||||
|
||||
if(obj->command)
|
||||
{
|
||||
char *p_tmp;
|
||||
char *command;
|
||||
|
||||
/* restrict to allowed url chars
|
||||
*
|
||||
*/
|
||||
for(p_tmp = obj->url; *p_tmp != '\0'; p_tmp++)
|
||||
if( (*p_tmp >= '0' && *p_tmp <= '9')
|
||||
|| (*p_tmp >= 'A' && *p_tmp <= 'Z')
|
||||
|| (*p_tmp >= 'a' && *p_tmp <= 'z')
|
||||
|| (*p_tmp == '_')
|
||||
|| (*p_tmp == '?')
|
||||
|| (*p_tmp == '#')
|
||||
|| (*p_tmp == '&')
|
||||
|| (*p_tmp == '%')
|
||||
|| (*p_tmp == '/')
|
||||
|| (*p_tmp == ':')
|
||||
|| (*p_tmp == '+')
|
||||
|| (*p_tmp == '.')
|
||||
|| (*p_tmp == '~')
|
||||
|| (*p_tmp == '=')
|
||||
|| (*p_tmp == '-'))
|
||||
{
|
||||
/* this is a good character. Allow it.
|
||||
*/
|
||||
}
|
||||
else
|
||||
{
|
||||
*p_tmp = '\0';
|
||||
break;
|
||||
}
|
||||
|
||||
command=build_viewer_cmd(obj->command,
|
||||
's', obj->filename,
|
||||
'u', obj->url, 0);
|
||||
|
||||
fclose(obj->fp);
|
||||
TRACEMSG(("Invoking: %s", command));
|
||||
|
||||
system(command);
|
||||
PR_FREEIF(obj->command);
|
||||
}
|
||||
else
|
||||
{
|
||||
pclose(obj->fp);
|
||||
}
|
||||
|
||||
PR_FREEIF(obj->filename);
|
||||
PR_FREEIF(obj->url);
|
||||
PR_Free(obj);
|
||||
return;
|
||||
}
|
||||
|
||||
PRIVATE void net_ExtViewAbort (NET_StreamClass *stream, int status)
|
||||
{
|
||||
CV_DataObject *obj=stream->data_object;
|
||||
obj->context->funcs->SetProgressBarPercent(obj->context, 100);
|
||||
|
||||
fclose(obj->fp);
|
||||
|
||||
if(obj->filename)
|
||||
{
|
||||
remove(obj->filename);
|
||||
PR_Free(obj->filename);
|
||||
}
|
||||
|
||||
PR_FREEIF(obj->url);
|
||||
PR_FREEIF(obj->command);
|
||||
|
||||
PR_Free(obj);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef XP_UNIX
|
||||
extern char **fe_encoding_extensions; /* gag! */
|
||||
#endif
|
||||
|
||||
|
||||
PUBLIC NET_StreamClass *
|
||||
NET_ExtViewerConverter (int format_out,
|
||||
void *data_obj,
|
||||
URL_Struct *URL_s,
|
||||
MWContext *window_id)
|
||||
{
|
||||
CV_DataObject* obj;
|
||||
NET_StreamClass* stream;
|
||||
char *tmp_filename;
|
||||
char *dot;
|
||||
char *path;
|
||||
CV_ExtViewStruct * view_struct = (CV_ExtViewStruct *)data_obj;
|
||||
char small_buf[256];
|
||||
int yes_stream=0;
|
||||
|
||||
/* If this URL is a mail or news attachment, use the name of that
|
||||
attachment as the URL -- this is so the temp file gets the right
|
||||
extension on it (some helper apps are picky about that...)
|
||||
*/
|
||||
path = MimeGuessURLContentName(window_id, URL_s->address);
|
||||
if (!path)
|
||||
path = NET_ParseURL(URL_s->address, GET_PATH_PART);
|
||||
if (!path)
|
||||
return 0;
|
||||
|
||||
|
||||
TRACEMSG(("Setting up display stream. Have URL: %s\n", URL_s->address));
|
||||
|
||||
stream = PR_NEW(NET_StreamClass);
|
||||
if(stream == NULL)
|
||||
return(NULL);
|
||||
|
||||
memset(stream, 0, sizeof(NET_StreamClass));
|
||||
|
||||
obj = PR_NEW(CV_DataObject);
|
||||
if (obj == NULL)
|
||||
return(NULL);
|
||||
memset(obj, 0, sizeof(CV_DataObject));
|
||||
|
||||
obj->context = window_id;
|
||||
|
||||
if(URL_s->content_length)
|
||||
{
|
||||
obj->tot_size = URL_s->content_length;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* start the progress bar cyloning
|
||||
*/
|
||||
obj->context->funcs->SetProgressBarPercent(window_id, -1);
|
||||
}
|
||||
|
||||
stream->name = "Execute external viewer";
|
||||
stream->complete = (MKStreamCompleteFunc) net_ExtViewComplete;
|
||||
stream->abort = (MKStreamAbortFunc) net_ExtViewAbort;
|
||||
stream->put_block = (MKStreamWriteFunc) net_ExtViewWrite;
|
||||
stream->is_write_ready = (MKStreamWriteReadyFunc) net_ExtViewWriteReady;
|
||||
stream->data_object = obj; /* document info object */
|
||||
stream->window_id = window_id;
|
||||
|
||||
#ifdef XP_UNIX
|
||||
/* Some naive people may have trustingly put
|
||||
|
||||
application/x-sh; sh %s
|
||||
application/x-csh; csh %s
|
||||
|
||||
in their mailcap files without realizing how dangerous that is.
|
||||
Worse, it might be there and they might not realize it. So, if
|
||||
we're about to execute a shell, pop up a dialog box first.
|
||||
*/
|
||||
{
|
||||
char *prog = PL_strdup (view_struct->system_command);
|
||||
char *s, *start, *end;
|
||||
int danger = 0;
|
||||
|
||||
/* strip end space */
|
||||
end = XP_StripLine(prog);
|
||||
|
||||
/* Extract the leaf name of the program: " /bin/sh -foo" ==> "sh". */
|
||||
for (; *end && !NET_IS_SPACE(*end); end++)
|
||||
;
|
||||
*end = 0;
|
||||
|
||||
if ((start = PL_strrchr (prog, '/')))
|
||||
start++;
|
||||
else
|
||||
start = XP_StripLine(prog); /* start at first non-white space */
|
||||
|
||||
/* Strip off everything after the first nonalphabetic.
|
||||
This is so "perl-4.0" is compared as "perl" and
|
||||
"emacs19" is compared as "emacs".
|
||||
*/
|
||||
for (s = start; *s; s++)
|
||||
if (!isalpha (*s))
|
||||
*s = 0;
|
||||
|
||||
/* These are things known to be shells - very bad. */
|
||||
if (!PL_strcmp (start, "ash") ||
|
||||
!PL_strcmp (start, "bash") ||
|
||||
!PL_strcmp (start, "csh") ||
|
||||
!PL_strcmp (start, "jsh") ||
|
||||
!PL_strcmp (start, "ksh") ||
|
||||
!PL_strcmp (start, "pdksh") ||
|
||||
!PL_strcmp (start, "sh") ||
|
||||
!PL_strcmp (start, "tclsh") ||
|
||||
!PL_strcmp (start, "tcsh") ||
|
||||
!PL_strcmp (start, "wish") || /* a tcl thing */
|
||||
!PL_strcmp (start, "wksh") ||
|
||||
!PL_strcmp (start, "zsh"))
|
||||
danger = 2;
|
||||
|
||||
/* Remote shells are potentially dangerous, in the case of
|
||||
"rsh somehost some-dangerous-program", but it's hard to
|
||||
parse that out, since rsh could take arbitrarily complicated
|
||||
args, like "rsh somehost -u something -pass8 /bin/sh %s".
|
||||
And we don't want to squawk about "rsh somehost playulaw -".
|
||||
So... allow rsh to possibly be a security hole.
|
||||
*/
|
||||
else if (!PL_strcmp (start, "remsh") || /* remote shell */
|
||||
!PL_strcmp (start, "rksh") ||
|
||||
!PL_strcmp (start, "rsh") /* remote- or restricted- */
|
||||
)
|
||||
danger = 0;
|
||||
|
||||
/* These are things which aren't really shells, but can do the
|
||||
same damage anyway since they can write files and/or execute
|
||||
other programs. */
|
||||
else if (!PL_strcmp (start, "awk") ||
|
||||
!PL_strcmp (start, "e") ||
|
||||
!PL_strcmp (start, "ed") ||
|
||||
!PL_strcmp (start, "ex") ||
|
||||
!PL_strcmp (start, "gawk") ||
|
||||
!PL_strcmp (start, "m4") ||
|
||||
!PL_strcmp (start, "sed") ||
|
||||
!PL_strcmp (start, "vi") ||
|
||||
!PL_strcmp (start, "emacs") ||
|
||||
!PL_strcmp (start, "lemacs") ||
|
||||
!PL_strcmp (start, "xemacs") ||
|
||||
!PL_strcmp (start, "temacs") ||
|
||||
|
||||
/* Other dangerous interpreters */
|
||||
!PL_strcmp (start, "basic") ||
|
||||
!PL_strcmp (start, "expect") ||
|
||||
!PL_strcmp (start, "expectk") ||
|
||||
!PL_strcmp (start, "perl") ||
|
||||
!PL_strcmp (start, "python") ||
|
||||
!PL_strcmp (start, "rexx")
|
||||
)
|
||||
danger = 1;
|
||||
|
||||
/* Be suspicious of anything ending in "sh". */
|
||||
else if (PL_strlen (start) > 2 &&
|
||||
!PL_strcmp (start + PL_strlen (start) - 2, "sh"))
|
||||
danger = 1;
|
||||
|
||||
if (danger)
|
||||
{
|
||||
char msg [2048];
|
||||
PR_snprintf (msg,
|
||||
sizeof(msg),
|
||||
(danger > 1 ? XP_GetString(XP_CONFIRM_EXEC_UNIXCMD_ARE) : XP_GetString(XP_CONFIRM_EXEC_UNIXCMD_MAYBE)),
|
||||
start
|
||||
);
|
||||
if (!FE_Confirm (window_id, msg))
|
||||
{
|
||||
PR_Free (stream);
|
||||
PR_Free (obj);
|
||||
PR_Free (path);
|
||||
PR_Free (prog);
|
||||
return(NULL);
|
||||
}
|
||||
}
|
||||
PR_Free (prog);
|
||||
}
|
||||
#endif /* XP_UNIX */
|
||||
|
||||
if(view_struct->stream_block_size)
|
||||
{
|
||||
/* asks the user if they want to stream data.
|
||||
* -1 cancel
|
||||
* 0 No, don't stream data, play from the file
|
||||
* 1 Yes, stream the data from the network
|
||||
*/
|
||||
int XFE_AskStreamQuestion(MWContext * window_id); /* definition */
|
||||
|
||||
if (NET_URL_Type (URL_s->address) == ABOUT_TYPE_URL)
|
||||
yes_stream = 1;
|
||||
else
|
||||
yes_stream = XFE_AskStreamQuestion(window_id);
|
||||
|
||||
if(yes_stream == -1)
|
||||
{
|
||||
PR_Free(stream);
|
||||
PR_Free(obj);
|
||||
PR_Free(path);
|
||||
return(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
if(yes_stream && view_struct->stream_block_size)
|
||||
{
|
||||
/* use popen */
|
||||
obj->fp = popen(view_struct->system_command, "w");
|
||||
|
||||
if(!obj->fp)
|
||||
{
|
||||
NET_Alert(window_id, XP_GetString(XP_ALERT_UNABLE_INVOKEVIEWER));
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
obj->stream_block_size = view_struct->stream_block_size;
|
||||
|
||||
signal(SIGPIPE, SIG_IGN);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
dot = PL_strrchr(path, '.');
|
||||
|
||||
#ifdef XP_UNIX
|
||||
/* Gag. foo.ps.gz --> tmpXXXXX.ps, not tmpXXXXX.gz. */
|
||||
if (dot && fe_encoding_extensions)
|
||||
{
|
||||
int i = 0;
|
||||
while (fe_encoding_extensions [i])
|
||||
{
|
||||
if (!PL_strcmp (dot, fe_encoding_extensions [i]))
|
||||
{
|
||||
*dot = 0;
|
||||
dot--;
|
||||
while (dot > path && *dot != '.')
|
||||
dot--;
|
||||
if (*dot != '.')
|
||||
dot = 0;
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
#endif /* XP_UNIX */
|
||||
|
||||
tmp_filename = WH_TempName(xpTemporary, "MO");
|
||||
if (!tmp_filename) {
|
||||
PR_FREEIF(stream);
|
||||
PR_FREEIF(obj);
|
||||
return NULL;
|
||||
}
|
||||
if (dot)
|
||||
{
|
||||
char * p_tmp;
|
||||
|
||||
StrAllocCopy(obj->filename, tmp_filename);
|
||||
|
||||
/* restrict to ascii alphanumeric chars
|
||||
*
|
||||
* this fixes really bad security hole
|
||||
*/
|
||||
for(p_tmp = dot+1; *p_tmp != '\0'; p_tmp++)
|
||||
if( (*p_tmp >= '0' && *p_tmp <= '9')
|
||||
|| (*p_tmp >= 'A' && *p_tmp <= 'Z')
|
||||
|| (*p_tmp >= 'a' && *p_tmp <= 'z')
|
||||
|| (*p_tmp == '_')
|
||||
|| (*p_tmp == '+')
|
||||
|| (*p_tmp == '-'))
|
||||
{
|
||||
/* this is a good character. Allow it.
|
||||
*/
|
||||
}
|
||||
else
|
||||
{
|
||||
*p_tmp = '\0';
|
||||
break;
|
||||
}
|
||||
|
||||
StrAllocCat(obj->filename, dot);
|
||||
}
|
||||
else
|
||||
{
|
||||
StrAllocCopy(obj->filename, tmp_filename);
|
||||
}
|
||||
|
||||
PR_Free(path);
|
||||
PR_Free(tmp_filename);
|
||||
|
||||
obj->fp = XP_FileOpen(obj->filename, xpTemporary, XP_FILE_WRITE);
|
||||
|
||||
TRACEMSG(("Trying to open output file: %s\n", obj->filename));
|
||||
|
||||
if(!obj->fp)
|
||||
{
|
||||
char *s = NET_ExplainErrorDetails (MK_UNABLE_TO_OPEN_TMP_FILE,
|
||||
obj->filename);
|
||||
if (s)
|
||||
{
|
||||
NET_Alert (window_id, s);
|
||||
PR_Free (s);
|
||||
}
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
/* construct the command like this
|
||||
*
|
||||
* (( COMMAND ); rm %s )&
|
||||
*/
|
||||
StrAllocCopy(obj->command, "((");
|
||||
|
||||
/* this is a stream writable program that the user wants
|
||||
* to use non streaming
|
||||
*/
|
||||
if(view_struct->stream_block_size)
|
||||
StrAllocCat(obj->command, "cat %s | ");
|
||||
|
||||
StrAllocCat(obj->command, view_struct->system_command);
|
||||
|
||||
PR_snprintf(small_buf, sizeof(small_buf), "); rm %.200s )&", obj->filename);
|
||||
StrAllocCat(obj->command, small_buf);
|
||||
}
|
||||
|
||||
StrAllocCopy(obj->url, URL_s->address);
|
||||
|
||||
TRACEMSG(("Returning stream from NET_ExtViewer\n"));
|
||||
|
||||
return stream;
|
||||
}
|
||||
|
||||
#endif /* MOZILLA_CLIENT */
|
||||
32
mozilla/network/cnvts/cvview.h
Normal file
32
mozilla/network/cnvts/cvview.h
Normal file
@@ -0,0 +1,32 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef CVVIEW_H
|
||||
#define CVVIEW_H
|
||||
|
||||
extern NET_StreamClass* NET_ExtViewerConverter ( FO_Present_Types format_out,
|
||||
void *data_obj,
|
||||
URL_Struct *URL_s,
|
||||
MWContext *window_id);
|
||||
|
||||
typedef struct _CV_ExtViewStruct {
|
||||
char * system_command;
|
||||
unsigned int stream_block_size;
|
||||
} CV_ExtViewStruct;
|
||||
|
||||
#endif /* CVVIEW_H */
|
||||
13
mozilla/network/cnvts/export.mac
Normal file
13
mozilla/network/cnvts/export.mac
Normal file
@@ -0,0 +1,13 @@
|
||||
#
|
||||
# This is a list of local files which get copied to the mozilla:dist directory
|
||||
#
|
||||
|
||||
cvactive.h
|
||||
cvchunk.h
|
||||
cvcolor.h
|
||||
cvdisk.h
|
||||
cvmime.h
|
||||
cvpics.h
|
||||
cvsimple.h
|
||||
cvunzip.h
|
||||
cvjscfg.h
|
||||
125
mozilla/network/cnvts/makefile.win
Normal file
125
mozilla/network/cnvts/makefile.win
Normal file
@@ -0,0 +1,125 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
IGNORE_MANIFEST=1
|
||||
#
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
# Makefile to build the Network protocol converters LIB
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
|
||||
|
||||
#
|
||||
# Make sure we have MOZILLA_CLIENT defined so we get the
|
||||
# proper JS includes
|
||||
#
|
||||
LCFLAGS = $(LCFLAGS) -DMOZILLA_CLIENT
|
||||
!ifdef OPAQUE_MWCONTEXT
|
||||
LCFLAGS = $(LCFLAGS) -DOPAQUE_MWCONTEXT
|
||||
!endif
|
||||
|
||||
!ifdef BUILD_DEBUG_GC
|
||||
LCFLAGS = $(LCFLAGS) -DDEBUG_GC
|
||||
!endif
|
||||
|
||||
LLIBS= \
|
||||
$(NULL)
|
||||
MISCDEP=$(LLIBS)
|
||||
OBJS= \
|
||||
.\$(OBJDIR)\cvactive.obj \
|
||||
.\$(OBJDIR)\cvchunk.obj \
|
||||
.\$(OBJDIR)\cvcolor.obj \
|
||||
.\$(OBJDIR)\cvdisk.obj \
|
||||
.\$(OBJDIR)\cvsimple.obj \
|
||||
.\$(OBJDIR)\cvunzip.obj \
|
||||
.\$(OBJDIR)\cvjscfg.obj \
|
||||
.\$(OBJDIR)\txview.obj \
|
||||
!ifndef MODULAR_NETLIB
|
||||
.\$(OBJDIR)\cvmime.obj \
|
||||
.\$(OBJDIR)\cvpics.obj \
|
||||
!endif
|
||||
$(NULL)
|
||||
|
||||
|
||||
TMP_CSRCS = \
|
||||
cvactive.c \
|
||||
cvchunk.c \
|
||||
!ifndef MODULAR_NETLIB
|
||||
cvcolor.c \
|
||||
cvmime.c \
|
||||
cvpics.c \
|
||||
!endif
|
||||
cvdisk.c \
|
||||
cvsimple.c \
|
||||
cvunzip.c \
|
||||
cvjscfg.c \
|
||||
txview.c \
|
||||
$(NULL)
|
||||
|
||||
|
||||
LIBRARY_NAME=netcnvts
|
||||
MODULE=netcnvts
|
||||
DEPTH=..\..
|
||||
|
||||
LOCAL_INCLUDES=-I. -I$(DEPTH)/dist/public/zlib -I$(DEPTH)/dist/public/parse
|
||||
INCLUDES = $(LOCAL_INCLUDES)
|
||||
|
||||
|
||||
EXTRA_LIBS=
|
||||
|
||||
REQUIRES= network
|
||||
EXPORTS= \
|
||||
cvactive.h \
|
||||
cvchunk.h \
|
||||
cvcolor.h \
|
||||
cvdisk.h \
|
||||
cvmime.h \
|
||||
cvpics.h \
|
||||
cvsimple.h \
|
||||
cvunzip.h \
|
||||
cvjscfg.h
|
||||
|
||||
# use LINCS on win32 for now since REQUIRES seems to be broken
|
||||
#!if "$(MOZ_BITS)" != "16"
|
||||
LINCS= \
|
||||
-I$(PUBLIC)\nspr2 \
|
||||
-I$(PUBLIC)\util \
|
||||
-I$(PUBLIC)\java \
|
||||
-I$(PUBLIC)\pref \
|
||||
-I$(PUBLIC)\js \
|
||||
-I$(PUBLIC)\parse \
|
||||
-I$(PUBLIC)\security \
|
||||
-I$(PUBLIC)\marimurl \
|
||||
-I$(PUBLIC)\lay \
|
||||
-I$(PUBLIC)\style \
|
||||
-I$(PUBLIC)\zlib \
|
||||
-I$(PUBLIC)\softupdt \
|
||||
-I$(PUBLIC)\network \
|
||||
-I$(PUBLIC)\mimetype \
|
||||
$(NULL)
|
||||
#!endif
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
||||
libs:: $(LIBRARY)
|
||||
$(MAKE_INSTALL) $(LIBRARY) $(DIST)\lib
|
||||
|
||||
symbols::
|
||||
@echo "LIBRARY_NAME is $(LIBRARY_NAME)"
|
||||
@echo "LIBRARY is $(LIBRARY)"
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user