зеркало из https://github.com/mozilla/pjs.git
smore cleanup and bug fixes
This commit is contained in:
Родитель
726cd48ecd
Коммит
0d6c9e4ad9
|
@ -41,7 +41,6 @@ CSRCS = bmk2mcf.c \
|
|||
pm2rdf.c \
|
||||
es2mcf.c \
|
||||
columns.c \
|
||||
scook.c \
|
||||
rdfjava.c \
|
||||
mcf.c \
|
||||
ht.c \
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
|
||||
/* externs */
|
||||
extern RDF gNCDB;
|
||||
#define ESFTPRT(x) ((resourceType((RDF_Resource)x) == ES_RT) || (resourceType((RDF_Resource)x) == FTP_RT))
|
||||
|
||||
|
||||
|
||||
|
@ -38,24 +39,24 @@ MakeESFTPStore (char* url)
|
|||
RDFT ntr = (RDFT)getMem(sizeof(struct RDF_TranslatorStruct));
|
||||
ntr->assert = ESAssert;
|
||||
ntr->unassert = ESUnassert;
|
||||
ntr->getSlotValue = ESGetSlotValue;
|
||||
ntr->getSlotValues = ESGetSlotValues;
|
||||
ntr->hasAssertion = ESHasAssertion;
|
||||
ntr->nextValue = ESNextValue;
|
||||
ntr->disposeCursor = ESDisposeCursor;
|
||||
ntr->getSlotValue = remoteStoreGetSlotValue;
|
||||
ntr->getSlotValues = remoteStoreGetSlotValues;
|
||||
ntr->hasAssertion = remoteStoreHasAssertion;
|
||||
ntr->nextValue = remoteStoreNextValue;
|
||||
ntr->disposeCursor = remoteStoreDisposeCursor;
|
||||
ntr->possiblyAccessFile = ESFTPPossiblyAccessFile;
|
||||
ntr->url = copyString(url);
|
||||
return ntr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
PRBool
|
||||
ESFTPRT (RDF_Resource u)
|
||||
{
|
||||
return ((resourceType(u) == ES_RT) ||
|
||||
(resourceType(u) == FTP_RT));
|
||||
void ESFTPPossiblyAccessFile (RDFT rdf, RDF_Resource u, RDF_Resource s, PRBool inversep) {
|
||||
if (((resourceType(u) == ES_RT) || (resourceType(u) == FTP_RT)) &&
|
||||
(s == gCoreVocab->RDF_parent) && (containerp(u))) {
|
||||
char* id = resourceID(u);
|
||||
readRDFFile((resourceType(u) == ES_RT ? &id[4] : id), u, false, rdf);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
PRBool
|
||||
|
@ -88,173 +89,6 @@ ESUnassert (RDFT rdf, RDF_Resource u, RDF_Resource s, void* v,
|
|||
|
||||
|
||||
|
||||
PRBool
|
||||
ESDBAdd (RDFT rdf, RDF_Resource u, RDF_Resource s, void* v,
|
||||
RDF_ValueType type)
|
||||
{
|
||||
Assertion nextAs, prevAs, newAs;
|
||||
if ((s == gCoreVocab->RDF_instanceOf) && (v == gWebData->RDF_Container)) {
|
||||
setContainerp(u, true);
|
||||
return 1;
|
||||
}
|
||||
|
||||
nextAs = prevAs = u->rarg1;
|
||||
while (nextAs != null) {
|
||||
if (asEqual(nextAs, u, s, v, type)) return 1;
|
||||
prevAs = nextAs;
|
||||
nextAs = nextAs->next;
|
||||
}
|
||||
newAs = makeNewAssertion(u, s, v, type, 1);
|
||||
if (prevAs == null) {
|
||||
u->rarg1 = newAs;
|
||||
} else {
|
||||
prevAs->next = newAs;
|
||||
}
|
||||
if (type == RDF_RESOURCE_TYPE) {
|
||||
nextAs = prevAs = ((RDF_Resource)v)->rarg2;
|
||||
while (nextAs != null) {
|
||||
prevAs = nextAs;
|
||||
nextAs = nextAs->invNext;
|
||||
}
|
||||
if (prevAs == null) {
|
||||
((RDF_Resource)v)->rarg2 = newAs;
|
||||
} else {
|
||||
prevAs->invNext = newAs;
|
||||
}
|
||||
}
|
||||
sendNotifications2(rdf, RDF_ASSERT_NOTIFY, u, s, v, type, 1);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
PRBool
|
||||
ESDBRemove (RDFT rdf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type)
|
||||
{
|
||||
Assertion nextAs, prevAs, ans;
|
||||
PRBool found = false;
|
||||
nextAs = prevAs = u->rarg1;
|
||||
while (nextAs != null) {
|
||||
if (asEqual(nextAs, u, s, v, type)) {
|
||||
if (prevAs == null) {
|
||||
u->rarg1 = nextAs->next;
|
||||
} else {
|
||||
prevAs->next = nextAs->next;
|
||||
}
|
||||
found = true;
|
||||
ans = nextAs;
|
||||
break;
|
||||
}
|
||||
prevAs = nextAs;
|
||||
nextAs = nextAs->next;
|
||||
}
|
||||
if (found == false) return false;
|
||||
if (type == RDF_RESOURCE_TYPE) {
|
||||
nextAs = prevAs = ((RDF_Resource)v)->rarg2;
|
||||
while (nextAs != null) {
|
||||
if (nextAs == ans) {
|
||||
if (prevAs == nextAs) {
|
||||
((RDF_Resource)v)->rarg2 = nextAs->invNext;
|
||||
} else {
|
||||
prevAs->invNext = nextAs->invNext;
|
||||
}
|
||||
}
|
||||
prevAs = nextAs;
|
||||
nextAs = nextAs->invNext;
|
||||
}
|
||||
}
|
||||
sendNotifications2(rdf, RDF_DELETE_NOTIFY, u, s, v, type, 1);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
PRBool
|
||||
ESHasAssertion (RDFT rdf, RDF_Resource u, RDF_Resource s, void* v,
|
||||
RDF_ValueType type, PRBool tv)
|
||||
{
|
||||
Assertion nextAs;
|
||||
|
||||
if (!ESFTPRT(u)) return 0;
|
||||
|
||||
nextAs = u->rarg1;
|
||||
while (nextAs != NULL)
|
||||
{
|
||||
if (asEqual(nextAs, u, s, v, type) && (nextAs->tv == tv))
|
||||
{
|
||||
return(true);
|
||||
}
|
||||
nextAs = nextAs->next;
|
||||
}
|
||||
possiblyAccessES(rdf, u, s, false);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void *
|
||||
ESGetSlotValue (RDFT rdf, RDF_Resource u, RDF_Resource s, RDF_ValueType type,
|
||||
PRBool inversep, PRBool tv)
|
||||
{
|
||||
if (!ESFTPRT(u)) return NULL;
|
||||
|
||||
if ((s == gCoreVocab->RDF_name) && (type == RDF_STRING_TYPE) && (tv))
|
||||
{
|
||||
char *pathname, *name = NULL;
|
||||
int16 n,len;
|
||||
|
||||
if (pathname = copyString(resourceID(u)))
|
||||
{
|
||||
len = strlen(pathname);
|
||||
if (pathname[len-1] == '/') pathname[--len] = '\0';
|
||||
n = revCharSearch('/', pathname);
|
||||
name = unescapeURL(&pathname[n+1]);
|
||||
freeMem(pathname);
|
||||
}
|
||||
return(name);
|
||||
}
|
||||
else
|
||||
if (u->rarg1 == NULL) possiblyAccessES(rdf, u, s, inversep);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
RDF_Cursor
|
||||
ESGetSlotValues (RDFT rdf, RDF_Resource u, RDF_Resource s,
|
||||
RDF_ValueType type, PRBool inversep, PRBool tv)
|
||||
{
|
||||
Assertion as;
|
||||
if (!ESFTPRT(u)) return 0;
|
||||
as = (inversep ? u->rarg2 : u->rarg1);
|
||||
if (as == null) {
|
||||
possiblyAccessES(rdf, u, s, inversep);
|
||||
return null;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void *
|
||||
ESNextValue (RDFT mcf, RDF_Cursor c)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
RDF_Error
|
||||
ESDisposeCursor (RDFT mcf, RDF_Cursor c)
|
||||
{
|
||||
freeMem(c);
|
||||
return noRDFErr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** To be written **/
|
||||
|
||||
|
||||
|
||||
void
|
||||
|
@ -450,18 +284,6 @@ ESRemoveChild (RDF_Resource parent, RDF_Resource child)
|
|||
|
||||
|
||||
|
||||
void
|
||||
possiblyAccessES(RDFT rdf, RDF_Resource u, RDF_Resource s, PRBool inversep)
|
||||
{
|
||||
if ((ESFTPRT(u)) &&
|
||||
(s == gCoreVocab->RDF_parent) && (containerp(u))) {
|
||||
char* id = resourceID(u);
|
||||
readRDFFile((resourceType(u) == ES_RT ? &id[4] : id), u, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
parseNextESFTPLine (RDFFile f, char* line)
|
||||
{
|
||||
|
@ -496,10 +318,7 @@ parseNextESFTPLine (RDFFile f, char* line)
|
|||
ru = RDF_GetResource(NULL, url, 1);
|
||||
setResourceType(ru, resourceType(f->top));
|
||||
if (directoryp) setContainerp(ru, 1);
|
||||
/*
|
||||
remoteStoreAdd(gRemoteStore, ru, gCoreVocab->RDF_name, NET_UnEscape(line), RDF_STRING_TYPE, 1);
|
||||
*/
|
||||
remoteStoreAdd(gRemoteStore, ru, gCoreVocab->RDF_parent, f->top, RDF_RESOURCE_TYPE, 1);
|
||||
addSlotValue(f, ru, gCoreVocab->RDF_parent, f->top, RDF_RESOURCE_TYPE, 1);
|
||||
}
|
||||
|
||||
|
||||
|
@ -544,3 +363,4 @@ parseNextESFTPBlob(NET_StreamClass *stream, char* blob, int32 size)
|
|||
return(size);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -41,6 +41,7 @@ XP_BEGIN_PROTOS
|
|||
RDFT MakeESFTPStore (char* url);
|
||||
_esFEData * esMakeFEData(RDF_Resource parent, RDF_Resource child, int method);
|
||||
void esFreeFEData(_esFEData *feData);
|
||||
void ESFTPPossiblyAccessFile (RDFT rdf, RDF_Resource u, RDF_Resource s, PRBool inversep) ;
|
||||
RDF_Error ESInit (RDFT ntr);
|
||||
PRBool ESFTPRT (RDF_Resource u);
|
||||
PRBool ESAssert (RDFT rdf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type, PRBool tv);
|
||||
|
|
|
@ -43,7 +43,7 @@ extern int RDF_RELATEDLINKSNAME;
|
|||
|
||||
/* globals */
|
||||
PLHashTable *hostHash = 0;
|
||||
RDF grdf = NULL;
|
||||
RDFT grdf = NULL;
|
||||
RDFT gHistoryStore = 0;
|
||||
PRBool ByDateOpened = 0;
|
||||
|
||||
|
@ -66,7 +66,7 @@ char *intermediateList[] = {
|
|||
|
||||
|
||||
void
|
||||
collateHistory (RDF r, RDF_Resource u, PRBool byDateFlag)
|
||||
collateHistory (RDFT r, RDF_Resource u, PRBool byDateFlag)
|
||||
{
|
||||
HASHINFO hash = { 4*1024, 0, 0, 0, 0, 0};
|
||||
DBT key, data;
|
||||
|
@ -103,7 +103,7 @@ collateHistory (RDF r, RDF_Resource u, PRBool byDateFlag)
|
|||
|
||||
|
||||
void
|
||||
collateOneHist (RDF r, RDF_Resource u, char* url, char* title, time_t lastAccessDate,
|
||||
collateOneHist (RDFT r, RDF_Resource u, char* url, char* title, time_t lastAccessDate,
|
||||
time_t firstAccessDate, uint32 numAccesses, PRBool byDateFlag)
|
||||
{
|
||||
RDF_Resource hostUnit, urlUnit;
|
||||
|
@ -126,17 +126,17 @@ collateOneHist (RDF r, RDF_Resource u, char* url, char* title, time_t lastAccess
|
|||
if (hostUnit != urlUnit) remoteAddParent(urlUnit, hostUnit);
|
||||
remoteStoreAdd(gRemoteStore, urlUnit, gWebData->RDF_lastVisitDate,
|
||||
(void *)lastAccessDate, RDF_INT_TYPE, 1);
|
||||
remoteStoreAdd(gRemoteStore, urlUnit, gWebData->RDF_firstVisitDate,
|
||||
remoteStoreAdd(gHistoryStore, urlUnit, gWebData->RDF_firstVisitDate,
|
||||
(void *)firstAccessDate, RDF_INT_TYPE, 1);
|
||||
if (numAccesses==0) ++numAccesses;
|
||||
remoteStoreAdd(gRemoteStore, urlUnit, gWebData->RDF_numAccesses,
|
||||
remoteStoreAdd(gHistoryStore, urlUnit, gWebData->RDF_numAccesses,
|
||||
(void *)numAccesses, RDF_INT_TYPE, 1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
RDF_Resource
|
||||
hostUnitOfURL (RDF r, RDF_Resource top, RDF_Resource nu, char* title)
|
||||
hostUnitOfURL (RDFT r, RDF_Resource top, RDF_Resource nu, char* title)
|
||||
{
|
||||
char host[100];
|
||||
char* url = resourceID(nu);
|
||||
|
@ -166,7 +166,7 @@ hostUnitOfURL (RDF r, RDF_Resource top, RDF_Resource nu, char* title)
|
|||
} else if (existing == top) {
|
||||
return hostResource;
|
||||
} else {
|
||||
remoteStoreRemove(gRemoteStore, existing, gCoreVocab->RDF_parent, top, RDF_RESOURCE_TYPE);
|
||||
remoteStoreRemove(gHistoryStore, existing, gCoreVocab->RDF_parent, top, RDF_RESOURCE_TYPE);
|
||||
histAddParent(existing, hostResource);
|
||||
histAddParent(hostResource, top);
|
||||
PL_HashTableAdd(hostHash, hostResource, top);
|
||||
|
@ -197,7 +197,7 @@ hourRange(char *buffer, struct tm *theTm)
|
|||
|
||||
|
||||
RDF_Resource
|
||||
hostUnitOfDate (RDF r, RDF_Resource u, time_t lastAccessDate)
|
||||
hostUnitOfDate (RDFT r, RDF_Resource u, time_t lastAccessDate)
|
||||
{
|
||||
RDF_Resource node = NULL, parentNode;
|
||||
/*
|
||||
|
@ -294,9 +294,9 @@ hostUnitOfDate (RDF r, RDF_Resource u, time_t lastAccessDate)
|
|||
}
|
||||
setContainerp(node, 1);
|
||||
setResourceType(node, HISTORY_RT);
|
||||
remoteStoreAdd(gRemoteStore, node, gCoreVocab->RDF_parent,
|
||||
remoteStoreAdd(gHistoryStore, node, gCoreVocab->RDF_parent,
|
||||
parentNode, RDF_RESOURCE_TYPE, 1);
|
||||
remoteStoreAdd(gRemoteStore, node, gCoreVocab->RDF_name,
|
||||
remoteStoreAdd(gHistoryStore, node, gCoreVocab->RDF_name,
|
||||
copyString(weekBuffer), RDF_STRING_TYPE, 1);
|
||||
parentNode = node;
|
||||
}
|
||||
|
@ -314,7 +314,7 @@ hostUnitOfDate (RDF r, RDF_Resource u, time_t lastAccessDate)
|
|||
setResourceType(node, HISTORY_RT);
|
||||
histAddParent(node, parentNode);
|
||||
sprintf(bigBuffer,"%s - %s",weekBuffer,dayBuffer);
|
||||
remoteStoreAdd(gRemoteStore, node, gCoreVocab->RDF_name,
|
||||
remoteStoreAdd(gHistoryStore, node, gCoreVocab->RDF_name,
|
||||
copyString(dayBuffer), RDF_STRING_TYPE, 1);
|
||||
parentNode = node;
|
||||
}
|
||||
|
@ -328,9 +328,9 @@ hostUnitOfDate (RDF r, RDF_Resource u, time_t lastAccessDate)
|
|||
}
|
||||
setContainerp(node, 1);
|
||||
setResourceType(node, HISTORY_RT);
|
||||
remoteStoreAdd(gRemoteStore, node, gCoreVocab->RDF_parent,
|
||||
remoteStoreAdd(gHistoryStore, node, gCoreVocab->RDF_parent,
|
||||
parentNode, RDF_RESOURCE_TYPE, 1);
|
||||
remoteStoreAdd(gRemoteStore, node, gCoreVocab->RDF_name,
|
||||
remoteStoreAdd(gHistoryStore, node, gCoreVocab->RDF_name,
|
||||
copyString(hourBuffer), RDF_STRING_TYPE, 1);
|
||||
parentNode = node;
|
||||
}
|
||||
|
@ -338,28 +338,6 @@ hostUnitOfDate (RDF r, RDF_Resource u, time_t lastAccessDate)
|
|||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
deleteCurrentSitemaps (char *address)
|
||||
{
|
||||
RDF_Resource children[40];
|
||||
int16 n = 0;
|
||||
RDF_Cursor c = remoteStoreGetSlotValues(gRemoteStore, gNavCenter->RDF_Sitemaps, gCoreVocab->RDF_parent,
|
||||
RDF_RESOURCE_TYPE,1, 1);
|
||||
RDF_Resource child;
|
||||
while (c && (child = remoteStoreNextValue(gRemoteStore, c))) {
|
||||
children[n++] = child;
|
||||
}
|
||||
remoteStoreDisposeCursor(gRemoteStore, c);
|
||||
n--;
|
||||
while (n > -1) {
|
||||
remoteStoreRemove(gRemoteStore, children[n--],
|
||||
gCoreVocab->RDF_parent, gNavCenter->RDF_Sitemaps, RDF_RESOURCE_TYPE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
PR_PUBLIC_API(void)
|
||||
updateNewHistItem (DBT *key, DBT *data)
|
||||
{
|
||||
|
@ -455,11 +433,11 @@ histAddParent (RDF_Resource child, RDF_Resource parent)
|
|||
RDF_ValueType type = RDF_RESOURCE_TYPE;
|
||||
nextAs = prevAs = child->rarg1;
|
||||
while (nextAs != null) {
|
||||
if (asEqual(nextAs, child, s, parent, type)) return null;
|
||||
if (asEqual(gHistoryStore, nextAs, child, s, parent, type)) return null;
|
||||
prevAs = nextAs;
|
||||
nextAs = nextAs->next;
|
||||
}
|
||||
newAs = makeNewAssertion(child, s, parent, type, 1);
|
||||
newAs = makeNewAssertion(gHistoryStore, child, s, parent, type, 1);
|
||||
if (prevAs == null) {
|
||||
child->rarg1 = newAs;
|
||||
} else {
|
||||
|
@ -492,7 +470,7 @@ histAddParent (RDF_Resource child, RDF_Resource parent)
|
|||
}
|
||||
sendNotifications2(gHistoryStore, RDF_ASSERT_NOTIFY, child, s, parent, type, 1);
|
||||
/* XXX have to mark the entire subtree XXX */
|
||||
/* sendNotifications(gRemoteStore->rdf, RDF_ASSERT_NOTIFY, child, s, parent, type, 1); */
|
||||
/* sendNotifications(gHistoryStore->rdf, RDF_ASSERT_NOTIFY, child, s, parent, type, 1); */
|
||||
}
|
||||
|
||||
|
||||
|
@ -518,7 +496,7 @@ historyUnassert (RDFT hst, RDF_Resource u, RDF_Resource s, void* v,
|
|||
while (n > 0) {
|
||||
n = n - 1;
|
||||
if (parents[n]) {
|
||||
Assertion nas = remoteStoreRemove (gRemoteStore, u, gCoreVocab->RDF_parent,
|
||||
Assertion nas = remoteStoreRemove (gHistoryStore, u, gCoreVocab->RDF_parent,
|
||||
parents[n], RDF_RESOURCE_TYPE);
|
||||
freeMem(nas);
|
||||
}
|
||||
|
@ -528,35 +506,13 @@ historyUnassert (RDFT hst, RDF_Resource u, RDF_Resource s, void* v,
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
RDF_Cursor
|
||||
historyStoreGetSlotValuesInt (RDFT mcf, RDF_Resource u, RDF_Resource s, RDF_ValueType type,
|
||||
PRBool inversep, PRBool tv)
|
||||
{
|
||||
if ((type == RDF_RESOURCE_TYPE) && (resourceType(u) == HISTORY_RT) && inversep &&
|
||||
(s == gCoreVocab->RDF_parent)) {
|
||||
return remoteStoreGetSlotValuesInt(mcf, u, s, type, inversep, tv);
|
||||
} else {
|
||||
return NULL;
|
||||
void HistPossiblyAccessFile (RDFT rdf, RDF_Resource u, RDF_Resource s, PRBool inversep) {
|
||||
if ((s == gCoreVocab->RDF_parent) && inversep && (rdf == gHistoryStore) &&
|
||||
((u == gNavCenter->RDF_HistoryByDate) || (u == gNavCenter->RDF_HistoryBySite))) {
|
||||
collateHistory(rdf, u, (u == gNavCenter->RDF_HistoryByDate));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
PRBool
|
||||
historyStoreHasAssertion (RDFT mcf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type, PRBool tv)
|
||||
{
|
||||
if ((s == gCoreVocab->RDF_parent) && (type == RDF_RESOURCE_TYPE) && (resourceType((RDF_Resource)v) == HISTORY_RT))
|
||||
{
|
||||
remoteStoreHasAssertionInt(mcf, u, s, v, type, tv);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
RDFT
|
||||
MakeHistoryStore (char* url)
|
||||
{
|
||||
|
@ -566,10 +522,11 @@ MakeHistoryStore (char* url)
|
|||
ntr->assert = NULL;
|
||||
ntr->unassert = historyUnassert;
|
||||
ntr->getSlotValue = remoteStoreGetSlotValue;
|
||||
ntr->getSlotValues = historyStoreGetSlotValuesInt;
|
||||
ntr->hasAssertion = historyStoreHasAssertion;
|
||||
ntr->getSlotValues = remoteStoreGetSlotValues;
|
||||
ntr->hasAssertion = remoteStoreHasAssertion;
|
||||
ntr->nextValue = remoteStoreNextValue;
|
||||
ntr->disposeCursor = remoteStoreDisposeCursor;
|
||||
ntr->possiblyAccessFile = HistPossiblyAccessFile;
|
||||
gHistoryStore = ntr;
|
||||
ntr->url = copyString(url);
|
||||
return ntr;
|
||||
|
@ -579,7 +536,7 @@ MakeHistoryStore (char* url)
|
|||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
void
|
||||
dumpHist ()
|
||||
{
|
||||
|
@ -602,3 +559,5 @@ dumpHist ()
|
|||
fclose(fp);
|
||||
(*db->close)(db);
|
||||
}
|
||||
|
||||
*/
|
||||
|
|
|
@ -75,11 +75,11 @@
|
|||
|
||||
XP_BEGIN_PROTOS
|
||||
|
||||
void collateHistory (RDF r, RDF_Resource u, PRBool byDateFlag);
|
||||
void collateOneHist (RDF r, RDF_Resource u, char* url, char* title, time_t lastAccessDate, time_t firstAccessDate, uint32 numAccesses, PRBool byDateFlag);
|
||||
RDF_Resource hostUnitOfURL (RDF r, RDF_Resource top, RDF_Resource nu, char* title);
|
||||
void collateHistory (RDFT r, RDF_Resource u, PRBool byDateFlag);
|
||||
void collateOneHist (RDFT r, RDF_Resource u, char* url, char* title, time_t lastAccessDate, time_t firstAccessDate, uint32 numAccesses, PRBool byDateFlag);
|
||||
RDF_Resource hostUnitOfURL (RDFT r, RDF_Resource top, RDF_Resource nu, char* title);
|
||||
void hourRange(char *buffer, struct tm *theTm);
|
||||
RDF_Resource hostUnitOfDate (RDF r, RDF_Resource u, time_t lastAccessDate);
|
||||
RDF_Resource hostUnitOfDate (RDFT r, RDF_Resource u, time_t lastAccessDate);
|
||||
void deleteCurrentSitemaps (char *address);
|
||||
void addRelatedLinks (char* address);
|
||||
PRBool displayHistoryItem (char* url);
|
||||
|
|
|
@ -913,7 +913,7 @@ newHTPaneDB()
|
|||
char *
|
||||
gNavCenterDataSources1[15] =
|
||||
{
|
||||
"rdf:localStore", "rdf:remoteStore", "rdf:history",
|
||||
"rdf:localStore", "rdf:remoteStore", "rdf:remoteStore", "rdf:history",
|
||||
/* "rdf:ldap", */
|
||||
"rdf:esftp", "rdf:mail",
|
||||
|
||||
|
@ -925,6 +925,22 @@ gNavCenterDataSources1[15] =
|
|||
"rdf:columns", NULL
|
||||
};
|
||||
|
||||
RDF HTRDF_GetDB () {
|
||||
RDF ans;
|
||||
char* navCenterURL;
|
||||
PREF_SetDefaultCharPref("browser.NavCenter", "http://rdf.netscape.com/rdf/navcntr.rdf");
|
||||
PREF_CopyCharPref("browser.NavCenter", &navCenterURL);
|
||||
if (!strchr(navCenterURL, ':')) {
|
||||
navCenterURL = makeDBURL(navCenterURL);
|
||||
} else {
|
||||
copyString(navCenterURL);
|
||||
}
|
||||
*(gNavCenterDataSources1 + 1) = copyString(navCenterURL);
|
||||
ans = RDF_GetDB(gNavCenterDataSources1);
|
||||
freeMem(navCenterURL);
|
||||
return ans;
|
||||
}
|
||||
|
||||
|
||||
|
||||
PR_PUBLIC_API(HT_Pane)
|
||||
|
@ -951,7 +967,7 @@ HT_NewPane (HT_Notification notify)
|
|||
break;
|
||||
}
|
||||
ev->eventType = HT_EVENT_DEFAULT_NOTIFICATION_MASK;
|
||||
pane->db = RDF_GetDB((char**)gNavCenterDataSources1);
|
||||
pane->db = HTRDF_GetDB();
|
||||
pane->rns = RDF_AddNotifiable(pane->db, htrdfNotifFunc, ev, pane);
|
||||
freeMem(ev);
|
||||
|
||||
|
@ -6839,7 +6855,8 @@ RDF_GetNavCenterDB()
|
|||
#define RDF_RELATED_LINKS 2
|
||||
#define FROM_PAGE 1
|
||||
#define GUESS_FROM_PREVIOUS_PAGE 2
|
||||
|
||||
#define HTADD remoteStoreAdd
|
||||
#define HTDEL remoteStoreRemove
|
||||
|
||||
HT_URLSiteMapAssoc *
|
||||
makeNewSMP (HT_Pane htPane, char* pUrl, char* sitemapUrl)
|
||||
|
@ -6872,6 +6889,7 @@ HT_AddSitemapFor(HT_Pane htPane, char *pUrl, char *pSitemapUrl, char* name)
|
|||
|
||||
|
||||
sp = RDFTNamed(htPane->db, "rdf:ht");
|
||||
if (sp == NULL) return;
|
||||
nu = RDF_GetResource(htPane->db, pSitemapUrl, 1);
|
||||
nsmp = makeNewSMP(htPane, pUrl, pSitemapUrl);
|
||||
nsmp->sitemap = nu;
|
||||
|
@ -6891,8 +6909,8 @@ HT_AddSitemapFor(HT_Pane htPane, char *pUrl, char *pSitemapUrl, char* name)
|
|||
|
||||
nsmp->origin = FROM_PAGE;
|
||||
nsmp->onDisplayp = 1;
|
||||
SCookAssert3(sp, nu, gCoreVocab->RDF_name, nm, RDF_STRING_TYPE, 1);
|
||||
SCookAssert3(sp, nu, gCoreVocab->RDF_parent, gNavCenter->RDF_Top,
|
||||
HTADD(sp, nu, gCoreVocab->RDF_name, nm, RDF_STRING_TYPE, 1);
|
||||
HTADD(sp, nu, gCoreVocab->RDF_parent, gNavCenter->RDF_Top,
|
||||
RDF_RESOURCE_TYPE, 1);
|
||||
|
||||
|
||||
|
@ -6907,6 +6925,7 @@ RetainOldSitemaps (HT_Pane htPane, char *pUrl)
|
|||
RDFT sp;
|
||||
|
||||
sp = RDFTNamed(htPane->db, "rdf:ht");
|
||||
if (sp == NULL) return;
|
||||
nsmp = htPane->smp;
|
||||
while (nsmp != NULL) {
|
||||
if ((nsmp->siteToolType == RDF_SITEMAP)) {
|
||||
|
@ -6918,13 +6937,13 @@ RetainOldSitemaps (HT_Pane htPane, char *pUrl)
|
|||
nsmp->sitemap = nu;
|
||||
nsmp->origin = GUESS_FROM_PREVIOUS_PAGE;
|
||||
nsmp->onDisplayp = 1;
|
||||
SCookAssert3(sp, nu, gCoreVocab->RDF_name, copyString(nsmp->name),
|
||||
HTADD(sp, nu, gCoreVocab->RDF_name, copyString(nsmp->name),
|
||||
RDF_STRING_TYPE, 1);
|
||||
SCookAssert3(sp, nu, gCoreVocab->RDF_parent,
|
||||
HTADD(sp, nu, gCoreVocab->RDF_parent,
|
||||
gNavCenter->RDF_Top, RDF_RESOURCE_TYPE, 1);
|
||||
}
|
||||
} else if (nsmp->onDisplayp) {
|
||||
SCookUnassert(sp, nsmp->sitemap, gCoreVocab->RDF_parent,
|
||||
HTDEL(sp, nsmp->sitemap, gCoreVocab->RDF_parent,
|
||||
gNavCenter->RDF_Top, RDF_RESOURCE_TYPE);
|
||||
nsmp->onDisplayp = 0;
|
||||
}
|
||||
|
@ -6945,7 +6964,7 @@ HT_ExitPage(HT_Pane htPane, char *pUrl)
|
|||
nsmp = htPane->sbp;
|
||||
while (nsmp != NULL) {
|
||||
HT_URLSiteMapAssoc *next;
|
||||
SCookUnassert(sp, nsmp->sitemap, gCoreVocab->RDF_parent,
|
||||
HTDEL(sp, nsmp->sitemap, gCoreVocab->RDF_parent,
|
||||
gNavCenter->RDF_Sitemaps, RDF_RESOURCE_TYPE);
|
||||
next = nsmp->next;
|
||||
freeMem(nsmp->url);
|
||||
|
@ -7156,8 +7175,8 @@ HT_AddRelatedLinksFor(HT_Pane htPane, char *pUrl)
|
|||
nsmp->next = htPane->sbp;
|
||||
htPane->sbp = nsmp;
|
||||
nsmp->siteToolType = RDF_RELATED_LINKS;
|
||||
SCookAssert3(sp, nu, gCoreVocab->RDF_name, copyString(prov->name), RDF_STRING_TYPE, 1);
|
||||
SCookAssert3(sp, nu, gCoreVocab->RDF_parent, gNavCenter->RDF_Sitemaps, RDF_RESOURCE_TYPE, 1);
|
||||
HTADD(sp, nu, gCoreVocab->RDF_name, copyString(prov->name), RDF_STRING_TYPE, 1);
|
||||
HTADD(sp, nu, gCoreVocab->RDF_parent, gNavCenter->RDF_Sitemaps, RDF_RESOURCE_TYPE, 1);
|
||||
prov = prov->next;
|
||||
freeMem(buffer);
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ REQUIRES=nspr dbm java js htmldlgs util img layer pref
|
|||
CSRCS=bmk2mcf.c vocab.c nlcstore.c mcf.c mcff2mcf.c rdfht.c \
|
||||
remstore.c ht.c glue.c utils.c fs2rdf.c hist2rdf.c \
|
||||
rdfparse.c es2mcf.c columns.c \
|
||||
scook.c \
|
||||
|
||||
|
||||
C_OBJS=.\$(OBJDIR)\bmk2mcf.obj .\$(OBJDIR)\vocab.obj \
|
||||
.\$(OBJDIR)\nlcstore.obj \
|
||||
|
@ -54,9 +54,7 @@ C_OBJS=.\$(OBJDIR)\bmk2mcf.obj .\$(OBJDIR)\vocab.obj \
|
|||
.\$(OBJDIR)\remstore.obj .\$(OBJDIR)\ht.obj \
|
||||
.\$(OBJDIR)\glue.obj .\$(OBJDIR)\utils.obj .\$(OBJDIR)\fs2rdf.obj \
|
||||
.\$(OBJDIR)\hist2rdf.obj .\$(OBJDIR)\rdfparse.obj \
|
||||
.\$(OBJDIR)\es2mcf.obj \
|
||||
.\$(OBJDIR)\columns.obj \
|
||||
.\$(OBJDIR)\scook.obj
|
||||
.\$(OBJDIR)\es2mcf.obj .\$(OBJDIR)\columns.obj
|
||||
!if "$(MOZ_BITS)" != "16"
|
||||
LINCS=-I$(XPDIST)\public\nspr -I$(XPDIST)\public\dbm \
|
||||
-I$(XPDIST)\public\java -I$(XPDIST)\public\js \
|
||||
|
|
|
@ -219,6 +219,31 @@ RDF_AssertFalse (RDF rdf, RDF_Resource u, RDF_Resource s, void* value, RDF_Valu
|
|||
|
||||
|
||||
|
||||
PR_PUBLIC_API(PRBool)
|
||||
RDF_CanAssert(RDF r, RDF_Resource u, RDF_Resource s,
|
||||
void* v, RDF_ValueType type)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
PR_PUBLIC_API(PRBool)
|
||||
RDF_CanAssertFalse(RDF r, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
PR_PUBLIC_API(PRBool)
|
||||
RDF_CanUnassert(RDF r, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
PR_PUBLIC_API(PRBool)
|
||||
RDF_Unassert (RDF rdf, RDF_Resource u, RDF_Resource s, void* value, RDF_ValueType type)
|
||||
{
|
||||
|
@ -263,7 +288,7 @@ makeNewID ()
|
|||
id = (char *)getMem(ID_BUF_SIZE);
|
||||
|
||||
#ifdef HAVE_LONG_LONG
|
||||
PR_snprintf(id, ID_BUF_SIZE, "%u", (double)tm);
|
||||
PR_snprintf(id, ID_BUF_SIZE, "%1.0f", (double)tm);
|
||||
#else
|
||||
LL_L2D(doubletm, tm);
|
||||
PR_snprintf(id, ID_BUF_SIZE, "%1.0f", doubletm);
|
||||
|
@ -274,7 +299,7 @@ makeNewID ()
|
|||
{
|
||||
#ifdef HAVE_LONG_LONG
|
||||
tm = tm + (PR_MSEC_PER_SEC * 60); /* fix me - not sure what the increment should be */
|
||||
PR_snprintf(id, ID_BUF_SIZE, "%u", (double)tm);
|
||||
PR_snprintf(id, ID_BUF_SIZE, "%1.0f", (double)tm);
|
||||
#else
|
||||
int64 incr;
|
||||
LL_I2L(incr, (PR_MSEC_PER_SEC * 60));
|
||||
|
|
|
@ -159,7 +159,7 @@ typedef RDF_Error (*destroyProc)(struct RDF_TranslatorStruct*);
|
|||
typedef RDF_Cursor (*arcLabelsOutProc)(RDFT r, RDF_Resource u);
|
||||
typedef RDF_Cursor (*arcLabelsInProc)(RDFT r, RDF_Resource u);
|
||||
typedef PRBool (*fAssert1Proc) (RDFFile file, RDFT mcf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type, PRBool tv) ;
|
||||
|
||||
typedef void (*accessFileProc) (RDFT rdf, RDF_Resource u, RDF_Resource s, PRBool inversep) ;
|
||||
struct RDF_ListStruct {
|
||||
struct RDF_DBStruct* rdf;
|
||||
struct RDF_ListStruct* next;
|
||||
|
@ -182,6 +182,7 @@ struct RDF_TranslatorStruct {
|
|||
disposeResourceProc disposeResource;
|
||||
arcLabelsInProc arcLabelsIn;
|
||||
arcLabelsInProc arcLabelsOut;
|
||||
accessFileProc possiblyAccessFile;
|
||||
};
|
||||
|
||||
|
||||
|
@ -252,7 +253,7 @@ struct RDF_FileStruct {
|
|||
RDF_Resource nextFindValue (RDF_Cursor c) ;
|
||||
PRBool isTypeOf (RDF rdf, RDF_Resource u, RDF_Resource v);
|
||||
RDF getRDFDB (void);
|
||||
RDFFile readRDFFile (char* url, RDF_Resource top, PRBool localp);
|
||||
RDFFile readRDFFile (char* url, RDF_Resource top, PRBool localp, RDFT rdf);
|
||||
void sendNotifications (RDF rdf, RDF_EventType opType, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type, PRBool tv, char* ds);
|
||||
void sendNotifications2 (RDFT rdf, RDF_EventType opType, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type, PRBool tv) ;
|
||||
RDF_Error exitRDF (RDF rdf);
|
||||
|
@ -270,8 +271,9 @@ uint8 resourceType (RDF_Resource r);
|
|||
void setResourceType (RDF_Resource r, uint8 type);
|
||||
char* getBaseURL (const char* url) ;
|
||||
void freeNamespaces (RDFFile f) ;
|
||||
PRBool asEqual(Assertion as, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type);
|
||||
Assertion makeNewAssertion (RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type, PRBool tv);
|
||||
PRBool asEqual(RDFT r, Assertion as, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type);
|
||||
Assertion makeNewAssertion (RDFT r, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type, PRBool tv);
|
||||
|
||||
|
||||
|
||||
void readResourceFile(RDF rdf, RDF_Resource u);
|
||||
|
|
|
@ -43,7 +43,7 @@ static PRBool sRDFInitedB = PR_FALSE;
|
|||
|
||||
|
||||
char * gNavCenterDataSources[15] =
|
||||
{"rdf:localStore", "rdf:remoteStore", "rdf:history",
|
||||
{"rdf:localStore", "rdf:remoteStore", "rdf:remoteStore", "rdf:history",
|
||||
/* "rdf:ldap", */
|
||||
"rdf:esftp",
|
||||
"rdf:lfs",
|
||||
|
@ -69,6 +69,7 @@ RDF_Init(RDF_InitParams params)
|
|||
resourceHash = PL_NewHashTable(500, PL_HashString, PL_CompareStrings, PL_CompareValues,
|
||||
NULL, NULL);
|
||||
RDFglueInitialize();
|
||||
MakeRemoteStore("rdf:remoteStore");
|
||||
createVocabs();
|
||||
sRDFInitedB = PR_TRUE;
|
||||
|
||||
|
@ -136,27 +137,3 @@ RDF_Shutdown ()
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
PR_PUBLIC_API(PRBool)
|
||||
RDF_CanAssert(RDF r, RDF_Resource u, RDF_Resource s,
|
||||
void* v, RDF_ValueType type)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
PR_PUBLIC_API(PRBool)
|
||||
RDF_CanAssertFalse(RDF r, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
PR_PUBLIC_API(PRBool)
|
||||
RDF_CanUnassert(RDF r, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#include "bmk2mcf.h"
|
||||
|
||||
/* globals */
|
||||
RDFFile rdfFiles = 0;
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -47,6 +47,7 @@ MakeRemoteStore (char* url)
|
|||
ntr->hasAssertion = remoteStoreHasAssertion;
|
||||
ntr->nextValue = remoteStoreNextValue;
|
||||
ntr->disposeCursor = remoteStoreDisposeCursor;
|
||||
ntr->possiblyAccessFile = RDFFilePossiblyAccessFile ;
|
||||
gRemoteStore = ntr;
|
||||
ntr->url = copyString(url);
|
||||
return ntr;
|
||||
|
@ -54,25 +55,44 @@ MakeRemoteStore (char* url)
|
|||
} else return NULL;
|
||||
}
|
||||
|
||||
PLHashTable* RDFFileDBHash = 0;
|
||||
|
||||
RDFT existingRDFFileDB (char* url) {
|
||||
if (RDFFileDBHash == 0)
|
||||
RDFFileDBHash = PL_NewHashTable(100, PL_HashString, PL_CompareStrings, PL_CompareValues, NULL, NULL);
|
||||
return PL_HashTableLookup(RDFFileDBHash, url);
|
||||
}
|
||||
|
||||
|
||||
RDFT
|
||||
MakeFileDB (char* url)
|
||||
{
|
||||
if (endsWith(".rdf", url) || endsWith(".mcf", url)) {
|
||||
if (gRemoteStore == 0) MakeRemoteStore("rdf:remoteStore");
|
||||
if (!fileReadp(url, 1)) readRDFFile(url, NULL, 1);
|
||||
return gRemoteStore;
|
||||
RDFT ntr = existingRDFFileDB(url);
|
||||
if (ntr) return ntr;
|
||||
ntr = (RDFT)getMem(sizeof(struct RDF_TranslatorStruct));
|
||||
ntr->assert = NULL;
|
||||
ntr->unassert = NULL;
|
||||
ntr->getSlotValue = remoteStoreGetSlotValue;
|
||||
ntr->getSlotValues = remoteStoreGetSlotValues;
|
||||
ntr->hasAssertion = remoteStoreHasAssertion;
|
||||
ntr->nextValue = remoteStoreNextValue;
|
||||
ntr->disposeCursor = remoteStoreDisposeCursor;
|
||||
ntr->possiblyAccessFile = RDFFilePossiblyAccessFile ;
|
||||
ntr->url = copyString(url);
|
||||
PL_HashTableAdd(RDFFileDBHash, url, ntr);
|
||||
readRDFFile(url, NULL, 1, ntr);
|
||||
return ntr;
|
||||
} else return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
PRBool
|
||||
asEqual(Assertion as, RDF_Resource u, RDF_Resource s, void* v,
|
||||
asEqual(RDFT r, Assertion as, RDF_Resource u, RDF_Resource s, void* v,
|
||||
RDF_ValueType type)
|
||||
{
|
||||
return ((as->u == u) && (as->s == s) && (as->type == type) &&
|
||||
return ((as->db == r) && (as->u == u) && (as->s == s) && (as->type == type) &&
|
||||
((as->value == v) ||
|
||||
((type == RDF_STRING_TYPE) && (strcmp(v, as->value) == 0))));
|
||||
}
|
||||
|
@ -80,7 +100,7 @@ asEqual(Assertion as, RDF_Resource u, RDF_Resource s, void* v,
|
|||
|
||||
|
||||
Assertion
|
||||
makeNewAssertion (RDF_Resource u, RDF_Resource s, void* v,
|
||||
makeNewAssertion (RDFT r, RDF_Resource u, RDF_Resource s, void* v,
|
||||
RDF_ValueType type, PRBool tv)
|
||||
{
|
||||
Assertion newAs = (Assertion) getMem(sizeof(struct RDF_AssertionStruct));
|
||||
|
@ -89,6 +109,10 @@ makeNewAssertion (RDF_Resource u, RDF_Resource s, void* v,
|
|||
newAs->value = v;
|
||||
newAs->type = type;
|
||||
newAs->tv = tv;
|
||||
newAs->db = r;
|
||||
if (strcmp(r->url, "rdf:history")) {
|
||||
int n = 0;
|
||||
}
|
||||
return newAs;
|
||||
}
|
||||
|
||||
|
@ -127,11 +151,11 @@ remoteStoreAdd (RDFT mcf, RDF_Resource u, RDF_Resource s, void* v,
|
|||
nextAs = prevAs = u->rarg1;
|
||||
|
||||
while (nextAs != null) {
|
||||
if (asEqual(nextAs, u, s, v, type)) return null;
|
||||
if (asEqual(mcf, nextAs, u, s, v, type)) return null;
|
||||
prevAs = nextAs;
|
||||
nextAs = nextAs->next;
|
||||
}
|
||||
newAs = makeNewAssertion(u, s, v, type, tv);
|
||||
newAs = makeNewAssertion(mcf, u, s, v, type, tv);
|
||||
if (prevAs == null) {
|
||||
u->rarg1 = newAs;
|
||||
} else {
|
||||
|
@ -163,7 +187,7 @@ remoteStoreRemove (RDFT mcf, RDF_Resource u, RDF_Resource s,
|
|||
PRBool found = false;
|
||||
nextAs = prevAs = u->rarg1;
|
||||
while (nextAs != null) {
|
||||
if (asEqual(nextAs, u, s, v, type)) {
|
||||
if (asEqual(mcf, nextAs, u, s, v, type)) {
|
||||
if (prevAs == null) {
|
||||
u->rarg1 = nextAs->next;
|
||||
} else {
|
||||
|
@ -198,9 +222,10 @@ remoteStoreRemove (RDFT mcf, RDF_Resource u, RDF_Resource s,
|
|||
|
||||
|
||||
static PRBool
|
||||
fileReadp (char* url, PRBool mark)
|
||||
fileReadp (RDFT rdf, char* url, PRBool mark)
|
||||
{
|
||||
RDFFile f;
|
||||
RDFFile rdfFiles = (RDFFile) rdf->pdata;
|
||||
uint n = 0;
|
||||
for (f = rdfFiles; (f != NULL) ; f = f->next) {
|
||||
if (urlEquals(url, f->url)) {
|
||||
|
@ -216,46 +241,32 @@ fileReadp (char* url, PRBool mark)
|
|||
static void
|
||||
possiblyAccessFile (RDFT mcf, RDF_Resource u, RDF_Resource s, PRBool inversep)
|
||||
{
|
||||
if ((s == gCoreVocab->RDF_parent) && inversep &&
|
||||
((u == gNavCenter->RDF_HistoryByDate) || (u == gNavCenter->RDF_HistoryBySite))) {
|
||||
collateHistory(mcf->rdf->rdf, u, (u == gNavCenter->RDF_HistoryByDate));
|
||||
} else if ((resourceType(u) == RDF_RT) &&
|
||||
(s == gCoreVocab->RDF_parent) && (containerp(u)) && (strstr(resourceID(u), ":/") !=NULL)
|
||||
&& (!fileReadp(resourceID(u), true))) {
|
||||
RDFFile newFile = readRDFFile( resourceID(u), u, false);
|
||||
if (mcf->possiblyAccessFile) (*(mcf->possiblyAccessFile))(mcf, u, s, inversep);
|
||||
}
|
||||
|
||||
void RDFFilePossiblyAccessFile (RDFT rdf, RDF_Resource u, RDF_Resource s, PRBool inversep) {
|
||||
if ((resourceType(u) == RDF_RT) && (strstr(rdf->url, ".rdf") || strstr(rdf->url, ".mcf")) &&
|
||||
(strstr(resourceID(u), ".rdf") || strstr(resourceID(u), ".mcf")) &&
|
||||
(s == gCoreVocab->RDF_parent) && (containerp(u))) {
|
||||
RDFFile newFile = readRDFFile( resourceID(u), u, false, rdf);
|
||||
if(newFile) newFile->lastReadTime = PR_Now();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
PRBool
|
||||
remoteStoreHasAssertionInt (RDFT mcf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type, PRBool tv)
|
||||
{
|
||||
Assertion nextAs;
|
||||
nextAs = u->rarg1;
|
||||
while (nextAs != null) {
|
||||
if (asEqual(nextAs, u, s, v, type) && (nextAs->tv == tv)) return true;
|
||||
nextAs = nextAs->next;
|
||||
}
|
||||
possiblyAccessFile(mcf, u, s, 0);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
PRBool
|
||||
remoteStoreHasAssertion (RDFT mcf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type, PRBool tv)
|
||||
{
|
||||
if (!((s == gCoreVocab->RDF_parent) &&
|
||||
(type == RDF_RESOURCE_TYPE) &&
|
||||
((resourceType((RDF_Resource)v) == HISTORY_RT) ||
|
||||
(resourceType((RDF_Resource)v) == ES_RT) ||
|
||||
(resourceType((RDF_Resource)v) == FTP_RT)))) {
|
||||
return remoteStoreHasAssertionInt(mcf, u, s, v, type, tv);
|
||||
} else {
|
||||
return 0;
|
||||
Assertion nextAs;
|
||||
nextAs = u->rarg1;
|
||||
while (nextAs != null) {
|
||||
if (asEqual(mcf, nextAs, u, s, v, type) && (nextAs->tv == tv)) return true;
|
||||
nextAs = nextAs->next;
|
||||
}
|
||||
possiblyAccessFile(mcf, u, s, 0);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
@ -266,7 +277,7 @@ remoteStoreGetSlotValue (RDFT mcf, RDF_Resource u, RDF_Resource s, RDF_ValueType
|
|||
Assertion nextAs;
|
||||
nextAs = (inversep ? u->rarg2 : u->rarg1);
|
||||
while (nextAs != null) {
|
||||
if ((nextAs->s == s) && (nextAs->tv == tv) && (nextAs->type == type)) {
|
||||
if ((nextAs->db == mcf) && (nextAs->s == s) && (nextAs->tv == tv) && (nextAs->type == type)) {
|
||||
void* ans = (inversep ? nextAs->u : nextAs->value);
|
||||
if (type == RDF_STRING_TYPE) {
|
||||
#ifdef DEBUG_RDF_GetSlotValue_Memory_Needs_Freedom
|
||||
|
@ -310,7 +321,7 @@ remoteStoreGetSlotValuesInt (RDFT mcf, RDF_Resource u, RDF_Resource s, RDF_Value
|
|||
RDF_Cursor
|
||||
remoteStoreGetSlotValues (RDFT mcf, RDF_Resource u, RDF_Resource s, RDF_ValueType type, PRBool inversep, PRBool tv)
|
||||
{
|
||||
if (resourceType(u) == HISTORY_RT) return NULL;
|
||||
|
||||
return remoteStoreGetSlotValuesInt(mcf, u, s, type, inversep, tv);
|
||||
}
|
||||
|
||||
|
@ -321,7 +332,7 @@ remoteStoreNextValue (RDFT mcf, RDF_Cursor c)
|
|||
{
|
||||
while (c->pdata != null) {
|
||||
Assertion as = (Assertion) c->pdata;
|
||||
if ((as->s == c->s) && (as->tv == c->tv) && (c->type == as->type)) {
|
||||
if ((as->db == mcf) && (as->s == c->s) && (as->tv == c->tv) && (c->type == as->type)) {
|
||||
if (c->s == gCoreVocab->RDF_slotsHere) {
|
||||
c->value = as->s;
|
||||
} else {
|
||||
|
@ -377,14 +388,12 @@ void
|
|||
gcRDFFile (RDFFile f)
|
||||
{
|
||||
int16 n = 0;
|
||||
RDFFile f1;
|
||||
|
||||
f1 = rdfFiles;
|
||||
RDFFile f1 = (RDFFile) f->db->pdata;
|
||||
|
||||
if (f->locked) return;
|
||||
|
||||
if (f == f1) {
|
||||
rdfFiles = f->next;
|
||||
f->db->pdata = f->next;
|
||||
} else {
|
||||
RDFFile prev = f1;
|
||||
while (f1 != NULL) {
|
||||
|
@ -399,7 +408,7 @@ gcRDFFile (RDFFile f)
|
|||
|
||||
while (n < f->assertionCount) {
|
||||
Assertion as = *(f->assertionList + n);
|
||||
remoteStoreRemove(gRemoteStore, as->u, as->s, as->value, as->type);
|
||||
remoteStoreRemove(f->db, as->u, as->s, as->value, as->type);
|
||||
freeAssertion(as);
|
||||
*(f->assertionList + n) = NULL;
|
||||
n++;
|
||||
|
@ -432,16 +441,19 @@ freeSomeRDFSpace (RDF mcf)
|
|||
|
||||
|
||||
RDFFile
|
||||
readRDFFile (char* url, RDF_Resource top, PRBool localp)
|
||||
readRDFFile (char* url, RDF_Resource top, PRBool localp, RDFT db)
|
||||
{
|
||||
RDFFile newFile = makeRDFFile(url, top, localp);
|
||||
if (rdfFiles) {
|
||||
newFile->next = rdfFiles;
|
||||
rdfFiles = newFile;
|
||||
if ((!strstr(url, ":/")) ||
|
||||
(fileReadp(db, url, true))) {
|
||||
return NULL;
|
||||
} else {
|
||||
rdfFiles = newFile;
|
||||
RDFFile newFile = makeRDFFile(url, top, localp);
|
||||
if (db->pdata) {
|
||||
newFile->next = (RDFFile) db->pdata;
|
||||
db->pdata = newFile;
|
||||
} else {
|
||||
db->pdata = (RDFFile) newFile;
|
||||
}
|
||||
newFile->db = gRemoteStore;
|
||||
newFile->assert = remoteAssert3;
|
||||
if (top) {
|
||||
if (resourceType(top) == RDF_RT) {
|
||||
|
@ -454,16 +466,18 @@ readRDFFile (char* url, RDF_Resource top, PRBool localp)
|
|||
newFile->fileType = resourceType(top);
|
||||
}
|
||||
}
|
||||
newFile->db = db;
|
||||
beginReadingRDFFile(newFile);
|
||||
return newFile;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
possiblyRefreshRDFFiles ()
|
||||
{
|
||||
RDFFile f = rdfFiles;
|
||||
RDFFile f = (RDFFile)gRemoteStore->pdata;
|
||||
PRTime tm = PR_Now();
|
||||
while (f != NULL) {
|
||||
if (f->expiryTime != NULL) {
|
||||
|
@ -474,7 +488,7 @@ possiblyRefreshRDFFiles ()
|
|||
int64 result;
|
||||
LL_SUB(result, tm, *expiry);
|
||||
if ((!LL_IS_ZERO(result) && LL_GE_ZERO(result)))
|
||||
#endif /* !HAVE_LONG_LONG */
|
||||
#endif
|
||||
{
|
||||
gcRDFFile (f);
|
||||
initRDFFile(f);
|
||||
|
@ -483,5 +497,37 @@ possiblyRefreshRDFFiles ()
|
|||
}
|
||||
f = f->next;
|
||||
}
|
||||
/* flushBookmarks(); */
|
||||
|
||||
}
|
||||
|
||||
|
||||
void SCookPossiblyAccessFile (RDFT rdf, RDF_Resource u, RDF_Resource s, PRBool inversep) {
|
||||
if ((resourceType(u) == RDF_RT) && (strcmp(rdf->url, "rdf:ht") ==0) &&
|
||||
(strstr(resourceID(u), ".rdf") || strstr(resourceID(u), ".mcf")) &&
|
||||
(s == gCoreVocab->RDF_parent) &&
|
||||
(containerp(u))) {
|
||||
RDFFile newFile = readRDFFile( resourceID(u), u, false, rdf);
|
||||
if(newFile) newFile->lastReadTime = PR_Now();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
RDFT
|
||||
MakeSCookDB (char* url)
|
||||
{
|
||||
if (startsWith("rdf:scook:", url) || (startsWith("rdf:ht", url))) {
|
||||
RDFT ntr = (RDFT)getMem(sizeof(struct RDF_TranslatorStruct));
|
||||
ntr->assert = NULL;
|
||||
ntr->unassert = NULL;
|
||||
ntr->getSlotValue = remoteStoreGetSlotValue;
|
||||
ntr->getSlotValues = remoteStoreGetSlotValues;
|
||||
ntr->hasAssertion = remoteStoreHasAssertion;
|
||||
ntr->nextValue = remoteStoreNextValue;
|
||||
ntr->disposeCursor = remoteStoreDisposeCursor;
|
||||
ntr->possiblyAccessFile = RDFFilePossiblyAccessFile ;
|
||||
ntr->url = copyString(url);
|
||||
return ntr;
|
||||
} else return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -41,8 +41,6 @@ XP_BEGIN_PROTOS
|
|||
|
||||
RDFT MakeRemoteStore (char* url);
|
||||
RDFT MakeFileDB (char* url);
|
||||
PRBool asEqual(Assertion as, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type);
|
||||
Assertion makeNewAssertion (RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type, PRBool tv);
|
||||
void freeAssertion (Assertion as);
|
||||
PRBool remoteAssert3 (RDFFile fi, RDFT mcf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type, PRBool tv);
|
||||
Assertion remoteStoreAdd (RDFT mcf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type, PRBool tv);
|
||||
|
@ -56,10 +54,10 @@ RDF_Cursor remoteStoreGetSlotValues (RDFT mcf, RDF_Resource u, RDF_Resource s, R
|
|||
void * remoteStoreNextValue (RDFT mcf, RDF_Cursor c);
|
||||
RDF_Error remoteStoreDisposeCursor (RDFT mcf, RDF_Cursor c);
|
||||
void gcRDFFile (RDFFile f);
|
||||
RDFFile readRDFFile (char* url, RDF_Resource top, PRBool localp);
|
||||
void RDFFilePossiblyAccessFile (RDFT rdf, RDF_Resource u, RDF_Resource s, PRBool inversep) ;
|
||||
void possiblyRefreshRDFFiles ();
|
||||
|
||||
static PRBool fileReadp (char* url, PRBool mark);
|
||||
static PRBool fileReadp (RDFT rdf, char* url, PRBool mark);
|
||||
static void possiblyAccessFile (RDFT mcf, RDF_Resource u, RDF_Resource s, PRBool inversep);
|
||||
static RDFFile leastRecentlyUsedRDFFile (RDF mcf);
|
||||
static PRBool freeSomeRDFSpace (RDF mcf);
|
||||
|
|
|
@ -99,11 +99,11 @@ SCookAssert (RDFT mcf, RDF_Resource u, RDF_Resource s, void* v,
|
|||
Assertion nextAs, prevAs, newAs;
|
||||
nextAs = prevAs = getArg1(mcf, u);
|
||||
while (nextAs != null) {
|
||||
if (asEqual(nextAs, u, s, v, type)) return null;
|
||||
if (asEqual(mcf, nextAs, u, s, v, type)) return null;
|
||||
prevAs = nextAs;
|
||||
nextAs = nextAs->next;
|
||||
}
|
||||
newAs = makeNewAssertion(u, s, v, type, tv);
|
||||
newAs = makeNewAssertion(mcf, u, s, v, type, tv);
|
||||
if (prevAs == null) {
|
||||
setArg1(mcf, u, newAs);
|
||||
} else {
|
||||
|
@ -147,7 +147,7 @@ SCookRemove (RDFT mcf, RDF_Resource u, RDF_Resource s,
|
|||
PRBool found = false;
|
||||
nextAs = prevAs = getArg1(mcf, u);
|
||||
while (nextAs != null) {
|
||||
if (asEqual(nextAs, u, s, v, type)) {
|
||||
if (asEqual(mcf, nextAs, u, s, v, type)) {
|
||||
if (prevAs == nextAs) {
|
||||
setArg1(mcf, u, nextAs->next);
|
||||
} else {
|
||||
|
@ -189,7 +189,7 @@ SCookHasAssertion (RDFT mcf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueT
|
|||
Assertion nextAs;
|
||||
nextAs = getArg1(mcf, u);
|
||||
while (nextAs != null) {
|
||||
if (asEqual(nextAs, u, s, v, type) && (nextAs->tv == tv)) return true;
|
||||
if (asEqual(mcf, nextAs, u, s, v, type) && (nextAs->tv == tv)) return true;
|
||||
nextAs = nextAs->next;
|
||||
}
|
||||
possiblyAccessSCookFile(mcf, u, s, 0);
|
||||
|
@ -410,32 +410,30 @@ possiblyAccessSCookFile (RDFT mcf, RDF_Resource u, RDF_Resource s, PRBool invers
|
|||
}
|
||||
}
|
||||
|
||||
void SCookPossiblyAccessFile1 (RDFT rdf, RDF_Resource u, RDF_Resource s, PRBool inversep) {
|
||||
if ((resourceType(u) == RDF_RT) && (strcmp(rdf->url, "rdf:ht") ==0) &&
|
||||
(strstr(resourceID(u), ".rdf") || strstr(resourceID(u), ".mcf")) &&
|
||||
(s == gCoreVocab->RDF_parent) &&
|
||||
(containerp(u))) {
|
||||
RDFFile newFile = readRDFFile( resourceID(u), u, false, rdf);
|
||||
if(newFile) newFile->lastReadTime = PR_Now();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
RDFT
|
||||
MakeSCookDB (char* url)
|
||||
MakeSCookDB1 (char* url)
|
||||
{
|
||||
if (startsWith("rdf:scook:", url) || (startsWith("rdf:ht", url))) {
|
||||
RDFT ntr = (RDFT)getMem(sizeof(struct RDF_TranslatorStruct));
|
||||
SCookDB sk = (SCookDB)getMem(sizeof(SCookDBStruct));
|
||||
ntr->pdata = sk;
|
||||
sk->db = ntr;
|
||||
sk->lhash = PL_NewHashTable(500, idenHash, PL_CompareValues, PL_CompareValues, NULL, NULL);
|
||||
sk->rhash = PL_NewHashTable(500, idenHash, PL_CompareValues, PL_CompareValues, NULL, NULL);
|
||||
ntr->assert = (startsWith("rdf:scook", url) ? SCookAssert3 : SCookAssert1);
|
||||
ntr->unassert = SCookUnassert;
|
||||
ntr->getSlotValue = SCookGetSlotValue;
|
||||
ntr->getSlotValues = SCookGetSlotValues;
|
||||
ntr->hasAssertion = SCookHasAssertion;
|
||||
ntr->nextValue = SCookNextValue;
|
||||
ntr->disposeCursor = SCookDisposeCursor;
|
||||
if (startsWith("rdf:scook:", url)) {
|
||||
sk->rf = makeRDFFile(makeSCookPathname(&url[10]), NULL, 0);
|
||||
sk->rf->db = (RDFT)ntr;
|
||||
sk->rf->assert = SCookAssert2;
|
||||
sk->rf->localp = 1;
|
||||
beginReadingRDFFile(sk->rf);
|
||||
}
|
||||
ntr->assert = NULL;
|
||||
ntr->unassert = NULL;
|
||||
ntr->getSlotValue = remoteStoreGetSlotValue;
|
||||
ntr->getSlotValues = remoteStoreGetSlotValues;
|
||||
ntr->hasAssertion = remoteStoreHasAssertion;
|
||||
ntr->nextValue = remoteStoreNextValue;
|
||||
ntr->disposeCursor = remoteStoreDisposeCursor;
|
||||
ntr->possiblyAccessFile = RDFFilePossiblyAccessFile ;
|
||||
ntr->url = copyString(url);
|
||||
return ntr;
|
||||
} else return NULL;
|
||||
|
|
Загрузка…
Ссылка в новой задаче