Bunch of bug fixes, etc. Reviewd by jgellman

This commit is contained in:
guha%netscape.com 1998-09-01 22:18:34 +00:00
Родитель 046d0cda16
Коммит 0ef5f40abe
16 изменённых файлов: 215 добавлений и 108 удалений

Просмотреть файл

@ -112,7 +112,7 @@ PR_PUBLIC_API(RDF_Error) RDF_ReleaseDataSource(RDF rdf, RDFT dataSource);
PR_PUBLIC_API(RDF_Resource) RDF_GetResource(RDF db, char* id, PRBool createp);
PR_PUBLIC_API(RDF_Error) RDF_ReleaseResource(RDF db, RDF_Resource resource);
PR_PUBLIC_API(RDF_Error) RDF_DeleteAllArcs(RDF rdfDB, RDF_Resource source);
PR_PUBLIC_API(RDF_Error) RDF_Update(RDF rdfDB);
PR_PUBLIC_API(RDF_Error) RDF_Update(RDF rdfDB, RDF_Resource u);
PR_PUBLIC_API(RDF_Notification) RDF_AddNotifiable (RDF rdfDB, RDF_NotificationProc callBack, RDF_Event ev, void* pdata);
PR_PUBLIC_API(RDF_Error) RDF_DeleteNotifiable (RDF_Notification ns);

Просмотреть файл

@ -167,7 +167,7 @@ parseNextBkToken (RDFFile f, char* token)
newFolder = createContainer(url);
XP_FREE(url);
addSlotValue(f,newFolder, gCoreVocab->RDF_parent, f->stack[f->depth-1],
RDF_RESOURCE_TYPE, true);
RDF_RESOURCE_TYPE, NULL);
freeMem(gBkFolderDate);
gBkFolderDate = NULL;
f->lastItem = newFolder;
@ -175,7 +175,7 @@ parseNextBkToken (RDFFile f, char* token)
if ((f->db == gLocalStore) || (f->status != IN_TITLE))
{
addSlotValue(f, f->lastItem, gCoreVocab->RDF_name,
copyString(token), RDF_STRING_TYPE, true);
copyString(token), RDF_STRING_TYPE, NULL);
}
/*
if (startsWith("Personal Toolbar", token) && (containerp(f->lastItem)))
@ -198,10 +198,10 @@ addDescription (RDFFile f, RDF_Resource r, char* token)
RDF_STRING_TYPE, false, true);
if (desc == NULL) {
addSlotValue(f, f->lastItem, gWebData->RDF_description, copyString(token),
RDF_STRING_TYPE, true);
RDF_STRING_TYPE, NULL);
} else {
addSlotValue(f, f->lastItem, gWebData->RDF_description,
append2Strings(desc, token), RDF_STRING_TYPE, true);
append2Strings(desc, token), RDF_STRING_TYPE, NULL);
nlocalStoreUnassert(gLocalStore, f->lastItem, gWebData->RDF_description, desc, RDF_STRING_TYPE);
}
}
@ -231,7 +231,7 @@ bkStateTransition (RDFFile f, char* token)
f->depth--;
} else if (startsWith("<HR>", token)) {
addSlotValue(f, createSeparator(), gCoreVocab->RDF_parent, f->stack[f->depth-1],
RDF_RESOURCE_TYPE, true);
RDF_RESOURCE_TYPE, NULL);
f->status = 0;
} else if ((f->status == IN_ITEM_DESCRIPTION) && (startsWith("<BR>", token))) {
addDescription(f, f->lastItem, token);
@ -293,7 +293,7 @@ newLeafBkItem (RDFFile f, char* token)
if (url == NULL) return;
newR = RDF_GetResource(NULL, url, true);
addSlotValue(f, newR, gCoreVocab->RDF_parent, f->stack[f->depth-1],
RDF_RESOURCE_TYPE, true);
RDF_RESOURCE_TYPE, NULL);
/* addSlotValue(f, newR, gWebData->RDF_URL, (void*)copyString(url),
RDF_STRING_TYPE, true); */
if (addDate != NULL)
@ -310,7 +310,7 @@ newLeafBkItem (RDFFile f, char* token)
strftime(buffer,sizeof(buffer),XP_GetString(RDF_HTML_WINDATE),time);
#endif
addSlotValue(f, newR, gNavCenter->RDF_bookmarkAddDate,
(void*)copyString(buffer), RDF_STRING_TYPE, true);
(void*)copyString(buffer), RDF_STRING_TYPE, NULL);
}
}
if (lastVisit != NULL)
@ -327,7 +327,7 @@ newLeafBkItem (RDFFile f, char* token)
strftime(buffer,sizeof(buffer),XP_GetString(RDF_HTML_WINDATE),time);
#endif
addSlotValue(f, newR, gWebData->RDF_lastVisitDate,
(void*)copyString(buffer), RDF_STRING_TYPE, true);
(void*)copyString(buffer), RDF_STRING_TYPE, NULL);
}
}
if (lastModified != NULL)
@ -344,7 +344,7 @@ newLeafBkItem (RDFFile f, char* token)
strftime(buffer,sizeof(buffer),XP_GetString(RDF_HTML_WINDATE),time);
#endif
addSlotValue(f, newR, gWebData->RDF_lastModifiedDate,
(void*)copyString(buffer), RDF_STRING_TYPE, true);
(void*)copyString(buffer), RDF_STRING_TYPE, NULL);
}
}
f->lastItem = newR;

Просмотреть файл

@ -424,7 +424,7 @@ parseNextESFTPLine (RDFFile f, char* line)
case RDF_STRING_TYPE:
addSlotValue(f, ru, f->tokens[loop].token,
unescapeURL(f->tokens[loop].data),
f->tokens[loop].type, 1);
f->tokens[loop].type, NULL);
break;
case RDF_INT_TYPE:
@ -434,14 +434,14 @@ parseNextESFTPLine (RDFFile f, char* line)
if (val != 0)
{
addSlotValue(f, ru, f->tokens[loop].token,
(void *)val, f->tokens[loop].type, 1);
(void *)val, f->tokens[loop].type, NULL);
}
}
break;
}
}
}
addSlotValue(f, ru, gCoreVocab->RDF_parent, f->top, RDF_RESOURCE_TYPE, 1);
addSlotValue(f, ru, gCoreVocab->RDF_parent, f->top, RDF_RESOURCE_TYPE, NULL);
}
}

Просмотреть файл

@ -71,6 +71,9 @@ rdf_complete(NET_StreamClass *stream)
freeMem(f->currentSlot);
freeMem(f->holdOver);
freeNamespaces(f) ;
f->line = NULL;
f->currentSlot = NULL;
f->holdOver = NULL;
}
}
@ -201,8 +204,13 @@ int
rdf_GetURL (MWContext *cx, int method, Net_GetUrlExitFunc *exit_routine, RDFFile rdfFile)
{
URL_Struct *urls = NULL;
char* url = rdfFile->url;
char* url ;
if (cx == NULL) return 0;
if (rdfFile->refreshingp && rdfFile->updateURL) {
url = rdfFile->updateURL;
} else {
url = rdfFile->url;
}
if (strcmp(url, gNavCntrUrl) == 0) {
urls = NET_CreateURLStruct(url, NET_CACHE_ONLY_RELOAD);
if (NET_IsURLInDiskCache(urls) || NET_IsURLInMemCache(urls)) {
@ -212,7 +220,8 @@ rdf_GetURL (MWContext *cx, int method, Net_GetUrlExitFunc *exit_routine, RDFFil
}
}
if (!urls)
urls = NET_CreateURLStruct(url, NET_NORMAL_RELOAD);
urls = NET_CreateURLStruct(url, (rdfFile->refreshingp ?
NET_SUPER_RELOAD : NET_NORMAL_RELOAD));
if (urls == NULL) return 0;
urls->fe_data = rdfFile;
if (method) urls->method = method;

Просмотреть файл

@ -2634,7 +2634,7 @@ addContainerItem (HT_Resource container, RDF_Resource item)
}
sb = SBProviderOfNode(nc);
if (sb && sb->openp)
if (sb /* && sb->openp */) /*related links is always open ... */
{
nc->flags |= HT_OPEN_FLAG;
}
@ -4481,11 +4481,12 @@ HT_DoMenuCmd(HT_Pane pane, HT_MenuCmd menuCmd)
}
if (HT_IsContainer(node))
{
destroyViewInt(node, PR_TRUE);
/* destroyViewInt(node, PR_TRUE);
RDF_Assert(node->view->pane->db, node->node,
gNavCenter->RDF_Command, gNavCenter->RDF_Command_Refresh,
RDF_RESOURCE_TYPE);
refreshItemList (node, HT_EVENT_VIEW_REFRESH);
refreshItemList (node, HT_EVENT_VIEW_REFRESH); */
RDF_Update(node->view->pane->db, node->node);
}
break;
@ -9581,7 +9582,7 @@ HT_AddSitemapFor(HT_Pane htPane, char *pUrl, char *pSitemapUrl, char* name)
nsmp->origin = FROM_PAGE;
nsmp->onDisplayp = 1;
HTADD(htPane, nu, gCoreVocab->RDF_name, nm);
nsmp->db = HTADD(htPane, nu, gCoreVocab->RDF_parent, gNavCenter->RDF_Top);
nsmp->db = HTADD(htPane, nu, gCoreVocab->RDF_parent, gNavCenter->RDF_Sitemaps);
}
@ -9608,11 +9609,11 @@ RetainOldSitemaps (HT_Pane htPane, char *pUrl)
nsmp->origin = GUESS_FROM_PREVIOUS_PAGE;
nsmp->onDisplayp = 1;
HTADD(htPane, nu, gCoreVocab->RDF_name, copyString(nsmp->name));
nsmp->db = HTADD(htPane, nu, gCoreVocab->RDF_parent, gNavCenter->RDF_Top);
nsmp->db = HTADD(htPane, nu, gCoreVocab->RDF_parent, gNavCenter->RDF_Sitemaps);
}
} else if (nsmp->onDisplayp) {
HTDEL(sp, nsmp->sitemap, gCoreVocab->RDF_parent,
gNavCenter->RDF_Top, RDF_RESOURCE_TYPE);
gNavCenter->RDF_Sitemaps, RDF_RESOURCE_TYPE);
if (nsmp->db) {
RDF_ReleaseDataSource(htPane->db, nsmp->db);
nsmp->db = NULL;
@ -9651,7 +9652,7 @@ void
PaneDeleteSBPCleanup (HT_Pane htPane)
{
cleanupInt(htPane, htPane->sbp, gNavCenter->RDF_Sitemaps);
cleanupInt(htPane, htPane->smp, gNavCenter->RDF_Top);
cleanupInt(htPane, htPane->smp, gNavCenter->RDF_Sitemaps);
freeMem(htPane->windowURL);
htPane->windowURL = NULL;
htPane->sbp = NULL;

Просмотреть файл

@ -282,6 +282,7 @@ RDF_ReleaseDB(RDF rdf)
}
gAllDBs = deleteFromRDFList(gAllDBs, rdf);
}
freeMem(rdf->translators);
freeMem(rdf);
return noRDFErr;
@ -334,6 +335,7 @@ rdfassert(RDF rdf, RDF_Resource u, RDF_Resource s, void* value,
}
PR_PUBLIC_API(PRBool)
RDF_Assert (RDF rdf, RDF_Resource u, RDF_Resource s, void* value, RDF_ValueType type)
@ -583,6 +585,16 @@ RDF_DeleteAllArcs (RDF rdf, RDF_Resource u)
return 0;
}
PR_PUBLIC_API(RDF_Error)
RDF_Update(RDF rdf, RDF_Resource u) {
int32 size = rdf->numTranslators;
int32 n = 0;
while (n < size) {
callUpdateRoutine(n, rdf, u, );
n++;
}
return 0;
}
PR_PUBLIC_API(PRBool)

Просмотреть файл

@ -48,6 +48,7 @@ struct RDF_NotificationStruct {
#define callArcLabelsIn(n, r, u) (ntrn(r, n) || (ntr(r, n)->arcLabelsIn == NULL) ? 0 : (*(ntr(r, n)->arcLabelsIn))(ntr(r, n), u))
#define callDisposeResource(n, r, u) (ntrn(r, n) || (ntr(r, n)->disposeResource == NULL) ? 1 : (*(ntr(r, n)->disposeResource))(ntr(r, n), u))
#define callExitRoutine(n, r) (ntrn(r, n) || (ntr(r, n)->destroy == NULL) ? 0 : (*(ntr(r, n)->destroy))(ntr(r, n)))
#define callUpdateRoutine(n, r, u) (ntrn(r, n) || (ntr(r, n)->update == NULL) ? 0 : (*(ntr(r, n)->update))(ntr(r, n), u))
#define ID_BUF_SIZE 20

Просмотреть файл

@ -119,7 +119,7 @@ resourceTransition (RDFFile f)
{
if ((f->currentResource) && (!f->genlAdded))
addSlotValue(f, f->currentResource, gCoreVocab->RDF_parent, f->rtop,
RDF_RESOURCE_TYPE, true);
RDF_RESOURCE_TYPE, NULL);
f->genlAdded = false;
}
@ -225,71 +225,42 @@ getFirstToken (char* line, char* nextToken, int16* l)
return ans;
}
void
addSlotValue (RDFFile f, RDF_Resource u, RDF_Resource s, void* v,
RDF_ValueType type, PRBool tv)
{
XP_ASSERT( (RDF_STRING_TYPE != type) || ( IsUTF8String((const char* )v)));
if (f == NULL || u == NULL || s == NULL || v == NULL) return;
if (s == gCoreVocab->RDF_child) {
RDF_Resource temp = (RDF_Resource)v;
if (type != RDF_RESOURCE_TYPE) return;
s = gCoreVocab->RDF_parent;
v = u;
u = temp;
}
if ((s == gCoreVocab->RDF_parent) && (type == RDF_RESOURCE_TYPE)) {
f->genlAdded = true;
if (strstr(resourceID(u), ".rdf") && startsWith("http", resourceID(u))) {
RDFL rl = f->db->rdf;
char* dburl = getBaseURL(resourceID(u));
if (!startsWith(dburl, resourceID((RDF_Resource)v))) {
while (rl) {
RDF_AddDataSource(rl->rdf, dburl);
rl = rl->next;
}
freeMem(dburl);
}
}
}
(*f->assert)(f, f->db, u, s, v, type, tv);
if (s == gCoreVocab->RDF_parent) setContainerp((RDF_Resource)v, 1);
#ifndef MOZILLA_CLIENT
notifySlotValueAdded(u, s, v, type);
#endif
}
void
assignSlot (RDF_Resource u, char* slot, char* value, RDFFile f)
{
PRBool tv = true;
char* tvstr;
if (value[0] == '(') {
tv = false;
value = &value[1];
value[strlen(value)-1] = '\0';
}
if (tv) {
tvstr = "true";
} else tvstr = "false";
if (startsWith("default_genl", slot)) return;
if (startsWith("name", slot) || (startsWith("local-name", slot))) {
value[strlen(value)-1] = '\0';
addSlotValue(f, u, gCoreVocab->RDF_name, copyString(&value[1]), RDF_STRING_TYPE, tv);
addSlotValue(f, u, gCoreVocab->RDF_name, copyString(&value[1]), RDF_STRING_TYPE, tvstr);
} else if (startsWith("specs", slot) || (startsWith("child", slot))) {
RDF_Resource spec = resolveReference(value, f);
if (!nullp(spec)) addSlotValue(f, spec, gCoreVocab->RDF_parent, u, RDF_RESOURCE_TYPE, tv);
if (!nullp(spec)) addSlotValue(f, spec, gCoreVocab->RDF_parent, u, RDF_RESOURCE_TYPE, tvstr);
} else if (startsWith("genls_pos", slot)) {
RDF_Resource genl = resolveGenlPosReference(value, f);
if (!nullp(genl)) addSlotValue(f, u, gCoreVocab->RDF_parent, genl, RDF_RESOURCE_TYPE, tv);
if (!nullp(genl)) addSlotValue(f, u, gCoreVocab->RDF_parent, genl, RDF_RESOURCE_TYPE, tvstr);
} else if ((startsWith("genls", slot)) || (startsWith("parent", slot))) {
RDF_Resource genl = resolveReference(value, f);
if (!nullp(genl)) addSlotValue(f, u, gCoreVocab->RDF_parent, genl, RDF_RESOURCE_TYPE, tv);
if (!nullp(genl)) addSlotValue(f, u, gCoreVocab->RDF_parent, genl, RDF_RESOURCE_TYPE, tvstr);
} else {
void* parsed_value;
RDF_ValueType data_type;
RDF_Resource s = RDF_GetResource(NULL, slot, true);
RDF_Error err = parseSlotValue(f, s, value, &parsed_value, &data_type);
if ((err == noRDFErr) && (!nullp(parsed_value)))
addSlotValue(f, u, s, parsed_value, data_type, tv);
addSlotValue(f, u, s, parsed_value, data_type, tvstr);
}
}

Просмотреть файл

@ -47,7 +47,7 @@ void finishMCFParse (RDFFile f);
void resourceTransition (RDFFile f);
void assignHeaderSlot (RDFFile f, char* slot, char* value);
RDF_Error getFirstToken (char* line, char* nextToken, int16* l);
void addSlotValue (RDFFile f, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type, PRBool tv);
void assignSlot (RDF_Resource u, char* slot, char* value, RDFFile f);
RDF_Error parseSlotValue (RDFFile f, RDF_Resource s, char* value, void** parsed_value, RDF_ValueType* data_type);
void derelativizeURL (char* tok, char* url, RDFFile f);

Просмотреть файл

@ -268,7 +268,6 @@ DBM_GetSlotValue (RDFT rdf, RDF_Resource u, RDF_Resource s, PRBool inversep, siz
key.size = keySize;
db = getUSDB(rdf, u, s, inversep);
if (db == NULL) {
/* XP_ASSERT(db); */
*size = 0;
freeKey(keyData, u, s, inversep);
return NULL;
@ -300,7 +299,6 @@ DBM_PutSlotValue (RDFT rdf, RDF_Resource u, RDF_Resource s, PRBool inversep, voi
CHECK_VAR1(keyData);
db = getUSDB(rdf, u, s, inversep);
if (db == NULL) {
/* XP_ASSERT(db); */
freeKey(keyData, u, s, inversep);
return ;
}
@ -333,7 +331,6 @@ nlocalStoreHasAssertion (RDFT rdf, RDF_Resource u, RDF_Resource s, void* v, RDF_
if (data == NULL) return 0;
while (n < size) {
DBMAs nas = nthdbmas(data, n);
/* XP_ASSERT(nas); */
if (nas == NULL) break;
if ((type == valueTypeOfAs(nas)) && (tvOfAs(nas) == tv) &&
(invp ? valueEqual(type, dataOfDBMAs(nas), u) : valueEqual(type, dataOfDBMAs(nas), v))) {
@ -360,7 +357,6 @@ nlocalStoreGetSlotValue (RDFT rdf, RDF_Resource u, RDF_Resource s,
if (data == NULL) return 0;
while (n < size) {
DBMAs nas = nthdbmas(data, n);
/* XP_ASSERT(nas); */
if (nas == NULL) break;
if (type == valueTypeOfAs(nas)) {
if (type == RDF_STRING_TYPE) {

Просмотреть файл

@ -224,8 +224,10 @@ setMessageFlag (RDFT rdf, RDF_Resource r, char* newFlag)
{
MF folder = (MF) rdf->pdata;
MM msg = (MM)r->pdata;
fseek(folder->sfile, msg->summOffset+9, SEEK_SET);
fseek(folder->sfile, msg->summOffset+8, SEEK_SET);
fputs(newFlag, folder->sfile);
freeMem(msg->flags);
msg->flags = copyString(newFlag);
/* need to mark the flag in the message file */
fflush(folder->sfile);
}
@ -259,7 +261,7 @@ MoveMessage (char* to, char* from, MM message) {
fseek(tom->mfile, 0L, SEEK_END);
fseek(fom->mfile, message->offset, SEEK_SET);
fputs("From -\n", tom->mfile);
sprintf(buffer, "%s?%d", to, ftell(tom->mfile));
sprintf(buffer, "mailbox://%s?%d", &to[17], ftell(tom->mfile));
r = RDF_GetResource(NULL, buffer, 1);
newMsg->subject = copyString(message->subject);
newMsg->from = copyString(message->from);
@ -277,7 +279,7 @@ MoveMessage (char* to, char* from, MM message) {
}
sendNotifications2(todb, RDF_ASSERT_NOTIFY, r, gCoreVocab->RDF_parent, tom->top,
RDF_RESOURCE_TYPE, 1);
sendNotifications2(fromdb, RDF_DELETE_NOTIFY, r, gCoreVocab->RDF_parent, tom->top,
sendNotifications2(fromdb, RDF_DELETE_NOTIFY, message->r, gCoreVocab->RDF_parent, fom->top,
RDF_RESOURCE_TYPE, 1);
freeMem(buffer);
return 1;

Просмотреть файл

@ -154,11 +154,12 @@ typedef PRBool (*unassertProc)(RDFT r, RDF_Resource u, RDF_Resource s, void* val
typedef void* (*nextItemProc)(RDFT r, RDF_Cursor c) ;
typedef RDF_Error (*disposeCursorProc)(RDFT r, RDF_Cursor c);
typedef RDF_Error (*disposeResourceProc)(RDFT r, RDF_Resource u);
typedef RDF_Error (*updateProc)(RDFT r);
typedef RDF_Error (*updateProc)(RDFT r, RDF_Resource u);
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 PRBool (*fUnAssert1Proc) (RDFFile file, RDFT mcf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type) ;
typedef void (*accessFileProc) (RDFT rdf, RDF_Resource u, RDF_Resource s, PRBool inversep) ;
struct RDF_ListStruct {
@ -233,6 +234,7 @@ struct RDF_FileStructTokens {
struct RDF_FileStruct {
char* url;
RDF_Resource currentResource;
RDF_Resource top;
RDF_Resource rtop;
@ -241,30 +243,41 @@ struct RDF_FileStruct {
PRBool localp;
char* storeAway;
char* line;
XMLNameSpace namespaces;
uint16 status;
char* holdOver;
int32 lineSize;
RDF_Resource stack[16];
uint16 depth ;
uint16 resourceCount;
uint16 resourceListSize;
uint16 assertionCount;
uint16 assertionListSize;
RDF_Resource* resourceList;
Assertion* assertionList;
char* holdOver;
char* updateURL;
char* postURL;
PRTime lastReadTime;
PRTime *expiryTime;
RDF_Resource stack[16];
uint16 depth ;
uint8 fileType;
PRBool locked;
RDF_Resource lastItem;
int32 lineSize;
struct RDF_FileStruct* next;
PRBool tv;
fAssert1Proc assert;
fUnAssert1Proc unassert;
RDFT db;
PRBool refreshingp;
void* pdata;
XMLNameSpace namespaces;
int16 numFileTokens;
struct RDF_FileStructTokens tokens[RDF_MAX_NUM_FILE_TOKENS];
struct RDF_FileStruct* next;
};
RDF newNavCenterDB();
@ -277,6 +290,7 @@ 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);
void gcRDFFileInt (RDFFile f);
void parseNextBkBlob(RDFFile f, char* blob, int32 blobSize);
void printAssertion(Assertion as);
RDF_Error addChildAfter (RDFT rdf, RDF_Resource parent, RDF_Resource child, RDF_Resource afterWhat);
@ -324,7 +338,7 @@ void abortRDFParse (RDFFile f);
void unitTransition (RDFFile f) ;
void assignHeaderSlot (RDFFile f, char* slot, char* value);
RDF_Error getFirstToken (char* line, char* nextToken, int16* l) ;
void addSlotValue (RDFFile f, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type, PRBool tv);
void addSlotValue (RDFFile f, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type, char* op);
void assignSlot (RDF_Resource u, char* slot, char* value, RDFFile f);
RDF_Error parseSlotValue (RDFFile f, RDF_Resource s, char* value, void** parsed_value, RDF_ValueType* data_type) ;
RDF_Resource resolveReference (char *tok, RDFFile f) ;

Просмотреть файл

@ -182,6 +182,7 @@ freeNamespaces (RDFFile f)
freeMem(ns1);
ns1 = next;
}
f->namespaces = NULL;
}
@ -216,10 +217,11 @@ addElementProps (char** attlist, char* elementName, RDFFile f, RDF_Resource obj)
char* attName = attlist[count++];
char* attValue = attlist[count++];
if ((attName == NULL) || (attValue == NULL)) break;
if (!tagEquals(f, attName, "href") && !tagEquals(f, attName, "rdf:href") && !tagEquals(f, attName, "RDF:href")
if (!tagEquals(f, attName, "href") && !tagEquals(f, attName, "rdf:href") &&
!tagEquals(f, attName, "RDF:href") && !tagEquals(f, attName, "tv")
&& !tagEquals(f, attName, "id")) {
addSlotValue(f, obj, ResourceFromElementName(f, attName), copyStringIgnoreWhiteSpace(attValue),
RDF_STRING_TYPE, 1);
RDF_STRING_TYPE, "true");
}
}
}
@ -294,11 +296,13 @@ ResourceFromElementName (RDFFile f, char* elementName)
void
parseNextRDFToken (RDFFile f, char* token)
{
char* attlist[2*MAX_ATTRIBUTES+1];
char* elementName;
if (token[0] != '<') {
if ((f->status == EXPECTING_OBJECT) && (f->depth > 1)) {
RDF_Resource u = f->stack[f->depth-2];
RDF_Resource s = f->stack[f->depth-1];
addSlotValue(f, u, s, copyStringIgnoreWhiteSpace(token), RDF_STRING_TYPE, 1);
addSlotValue(f, u, s, copyStringIgnoreWhiteSpace(token), RDF_STRING_TYPE, NULL);
}
} else if (startsWith("<!--", token)) {
return;
@ -308,15 +312,23 @@ parseNextRDFToken (RDFFile f, char* token)
if ((f->status != EXPECTING_OBJECT) && (f->status != EXPECTING_PROPERTY)) return;
if (f->depth > 0) f->depth--;
f->status = (f->status == EXPECTING_OBJECT ? EXPECTING_PROPERTY : EXPECTING_OBJECT);
} else if ((f->status == 0) && startsWith("<RDF:RDF>", token)) {
f->status = EXPECTING_OBJECT;
} else if ((f->status == 0) && startsWith("<RDF:RDF", token)) {
char* status = NULL;
char* update;
char* post;
f->status = EXPECTING_OBJECT;
tokenizeElement(token, attlist, &elementName);
update = getAttributeValue(attlist, "updateURL");
post = getAttributeValue(attlist, "postURL");
if (update) f->updateURL = copyString(update);
if (post) f->postURL = copyString(post);
status = getAttributeValue(attlist, "status");
if (status && (strcmp(status, "replace"))) gcRDFFileInt(f);
} else if (startsWith("<RelatedLinks", token)) {
f->stack[f->depth++] = f->top;
f->status = EXPECTING_PROPERTY;
} else {
PRBool emptyElementp = (token[strlen(token)-2] == '/');
char* attlist[2*MAX_ATTRIBUTES+1];
char* elementName;
PRBool emptyElementp = (token[strlen(token)-2] == '/');
if ((f->status != EXPECTING_OBJECT) && (f->status != EXPECTING_PROPERTY)) return;
tokenizeElement(token, attlist, &elementName);
if ((f->status == EXPECTING_PROPERTY) && (knownObjectElement(elementName))) return;
@ -336,12 +348,12 @@ parseNextRDFToken (RDFFile f, char* token)
setContainerp(obj, 1);
} else {
RDF_Resource eln = ResourceFromElementName(f, elementName);
addSlotValue(f, obj, gCoreVocab->RDF_instanceOf, eln, RDF_RESOURCE_TYPE, 1);
addSlotValue(f, obj, gCoreVocab->RDF_instanceOf, eln, RDF_RESOURCE_TYPE, getAttributeValue(attlist, "tv"));
}
}
if (f->depth > 1) {
addSlotValue(f, f->stack[f->depth-2], f->stack[f->depth-1], obj,
RDF_RESOURCE_TYPE, 1);
RDF_RESOURCE_TYPE, getAttributeValue(attlist, "tv"));
}
if (!emptyElementp) {
f->stack[f->depth++] = obj;
@ -354,14 +366,23 @@ parseNextRDFToken (RDFFile f, char* token)
url = getHref(attlist) ;
if (url) {
RDF_Resource eln = ResourceFromElementName(f, elementName);
char* tvAtt = getAttributeValue(attlist, "tv");
url = possiblyMakeAbsolute(f, url);
obj = ResourceFromElementName(f, url);
obj = ResourceFromElementName(f, url);
freeMem(url);
addElementProps (attlist, elementName, f, obj) ;
addToResourceList(f, obj);
addSlotValue(f, f->stack[f->depth-1], eln,obj,RDF_RESOURCE_TYPE, 1);
addSlotValue(f, f->stack[f->depth-1], eln,obj,RDF_RESOURCE_TYPE,
getAttributeValue(attlist, "tv"));
} else if ((strcmp(elementName, "child") == 0) && attlist[0] &&
(strcmp(attlist[0], "instanceOf") == 0) &&
attlist[1] && startsWith("Separator", attlist[1])) {
RDF_Resource sep = createSeparator();
RDF_Resource eln = ResourceFromElementName(f, elementName);
addSlotValue(f, f->stack[f->depth-1], eln,sep,RDF_RESOURCE_TYPE,
getAttributeValue(attlist, "tv"));
}
if (!emptyElementp) {
f->stack[f->depth++] = ResourceFromElementName(f, elementName);
f->status = EXPECTING_OBJECT;
@ -494,3 +515,52 @@ outputRDFTree (RDF rdf, PRFileDesc *fp, RDF_Resource node)
outputRDFTreeInt(rdf, fp, node, 0, (node==gNavCenter->RDF_Top) ? PR_TRUE:PR_FALSE);
ht_fprintf(fp, "\n</RDF:RDF>\n");
}
void
addSlotValue (RDFFile f, RDF_Resource u, RDF_Resource s, void* v,
RDF_ValueType type, char* op)
{
PRBool tv;
if (f == NULL || u == NULL || s == NULL || v == NULL) return;
if (s == gCoreVocab->RDF_child) {
RDF_Resource temp = (RDF_Resource)v;
if (type != RDF_RESOURCE_TYPE) return;
s = gCoreVocab->RDF_parent;
v = u;
u = temp;
}
if (op == NULL) {
tv = 1;
} else if (strcmp(op, "true") == 0) {
tv = 1;
} else if (strcmp(op, "false") == 0) {
tv = 0;
} else if (strcmp(op, "delete") == 0) {
if (f->unassert) (*f->unassert)(f, f->db, u, s, v, type);
return;
}
if ((s == gCoreVocab->RDF_parent) && (type == RDF_RESOURCE_TYPE)) {
f->genlAdded = true;
if (strstr(resourceID(u), ".rdf") && startsWith("http", resourceID(u))) {
RDFL rl = f->db->rdf;
char* dburl = getBaseURL(resourceID(u));
if (!startsWith(dburl, resourceID((RDF_Resource)v))) {
while (rl) {
RDF_AddDataSource(rl->rdf, dburl);
rl = rl->next;
}
freeMem(dburl);
}
}
}
(*f->assert)(f, f->db, u, s, v, type, tv);
if (s == gCoreVocab->RDF_parent) setContainerp((RDF_Resource)v, 1);
#ifndef MOZILLA_CLIENT
notifySlotValueAdded(u, s, v, type);
#endif
}

Просмотреть файл

@ -514,12 +514,9 @@ gcRDFFileInt (RDFFile f)
}
n = 0;
while (n < f->resourceCount) {
RDF_Resource u = *(f->resourceList + n);
possiblyGCResource(u);
*(f->resourceList + n) = NULL;
n++;
}
freeMem(f->assertionList);
freeMem(f->resourceList);
}
@ -532,13 +529,43 @@ DeleteRemStore (RDFT db)
while (f) {
next = f->next;
gcRDFFileInt(f);
freeMem(f->assertionList);
freeMem(f->resourceList);
f = next;
}
freeMem(db);
return 0;
}
RDF_Error
remStoreUpdate (RDFT db, RDF_Resource u) {
RDFFile f = db->pdata;
if (f != NULL) {
int32 n = 0;
PRBool proceedp = 0;
while (n < f->resourceCount) {
if (*(f->resourceList + n++) == u) {
proceedp = 1;
break;
}
}
if (proceedp) {
RDF_Resource top = f->top;
char* url = db->url;
PRBool localp = f->localp;
gcRDFFileInt(f);
freeMem(f->assertionList);
freeMem(f->resourceList);
f->assertionList = NULL;
f->resourceList = NULL;
initRDFFile(f);
f->refreshingp = 1;
beginReadingRDFFile(f);
} else return -1;
} else return -1;
}
void
gcRDFFile (RDFFile f)
@ -561,6 +588,9 @@ gcRDFFile (RDFFile f)
}
}
gcRDFFileInt(f);
freeMem(f->assertionList);
freeMem(f->resourceList);
}
@ -583,6 +613,14 @@ freeSomeRDFSpace (RDF mcf)
RDFFile
readRDFFile (char* url, RDF_Resource top, PRBool localp, RDFT db)
{
RDFFile f = makeNewRDFFile(url, top, localp, db);
if (!f) return NULL;
beginReadingRDFFile(f);
return f;
}
RDFFile
makeNewRDFFile (char* url, RDF_Resource top, PRBool localp, RDFT db) {
if ((!strstr(url, ":/")) ||
(fileReadp(db, url, true))) {
return NULL;
@ -594,14 +632,6 @@ readRDFFile (char* url, RDF_Resource top, PRBool localp, RDFT db)
} else {
db->pdata = (RDFFile) newFile;
}
#ifdef DEBUG_guha
{
char* traceLine = getMem(500);
sprintf(traceLine, "Accessing %s", url);
FE_Trace(traceLine);
freeMem(traceLine);
}
#endif
newFile->assert = remoteAssert3;
if (top) {
if (resourceType(top) == RDF_RT) {
@ -615,7 +645,6 @@ readRDFFile (char* url, RDF_Resource top, PRBool localp, RDFT db)
}
}
newFile->db = db;
beginReadingRDFFile(newFile);
return newFile;
}
}
@ -645,7 +674,6 @@ possiblyRefreshRDFFiles ()
}
f = f->next;
}
}
@ -679,6 +707,7 @@ NewRemoteStore (char* url)
ntr->destroy = DeleteRemStore;
ntr->arcLabelsIn = remoteStoreArcLabelsIn;
ntr->arcLabelsOut = remoteStoreArcLabelsOut;
ntr->update = remStoreUpdate;
}
return(ntr);
}

Просмотреть файл

@ -67,7 +67,6 @@ void * arcLabelsOutNextValue (RDFT mcf, RDF_Cursor c);
void * arcLabelsInNextValue (RDFT mcf, RDF_Cursor c);
void * remoteStoreNextValue (RDFT mcf, RDF_Cursor c);
RDF_Error remoteStoreDisposeCursor (RDFT mcf, RDF_Cursor c);
void gcRDFFileInt (RDFFile f);
RDF_Error DeleteRemStore (RDFT db);
void gcRDFFile (RDFFile f);
void RDFFilePossiblyAccessFile (RDFT rdf, RDF_Resource u, RDF_Resource s, PRBool inversep);
@ -76,11 +75,12 @@ void SCookPossiblyAccessFile (RDFT rdf, RDF_Resource u, RDF_Resource s, PRBool
RDFT MakeSCookDB (char* url);
void addToRDFTOut (RDFTOut out);
PRIntn RDFSerializerEnumerator (PLHashEntry *he, PRIntn i, void *arg);
RDFFile makeNewRDFFile (char* url, RDF_Resource top, PRBool localp, RDFT db) ;
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);
RDFFile reReadRDFFile (char* url, RDF_Resource top, PRBool localp, RDFT db);
XP_END_PROTOS

Просмотреть файл

@ -92,6 +92,8 @@ initRDFFile (RDFFile ans)
ans->locked = ans->localp;
ans->lineSize = LINE_SIZE;
ans->tv = true;
ans->resourceCount = 0;
ans->assertionCount = 0;
}