зеркало из https://github.com/mozilla/gecko-dev.git
Bug 3213. Removed obsolete files to keep the tree clean.
This commit is contained in:
Родитель
2e34b17d52
Коммит
6e46cc71b3
|
@ -1 +0,0 @@
|
||||||
Makefile
|
|
|
@ -1,7 +0,0 @@
|
||||||
The contents of this directory are obsolete, and will be removed as
|
|
||||||
soon as it is determined that they are no longer useful. Please see
|
|
||||||
rdf/base, rdf/build, rdf/content, and rdf/datasource.
|
|
||||||
|
|
||||||
Thank you.
|
|
||||||
The Management
|
|
||||||
|
|
|
@ -1,606 +0,0 @@
|
||||||
/* -*- 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Reading bookmarks.htm into rdf.
|
|
||||||
tags in the bookmark file.
|
|
||||||
<TITLE>
|
|
||||||
<H1>
|
|
||||||
<H3>
|
|
||||||
<DL></DL>
|
|
||||||
<DT>
|
|
||||||
<P>
|
|
||||||
|
|
||||||
<DT> indicates that an item is coming.
|
|
||||||
If the next item is an <a then we have a url
|
|
||||||
If the next item is a h3, we have a folder.
|
|
||||||
<DL> indicates that the previous item (which should have been a folder)
|
|
||||||
is the parent of the next set.
|
|
||||||
</DL> indicates pop out a level
|
|
||||||
<P> ignore this on reading, but write out one after each <DL>
|
|
||||||
<DD> the description for the previous <DT>
|
|
||||||
|
|
||||||
Category urls. Make it up out of the add dates. */
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
This file translates netscape bookmarks into the rdf data model.
|
|
||||||
For more information on this file, contact rjc or guha
|
|
||||||
For more information on RDF, look at the RDF section of www.mozilla.org
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#include "bmk2rdf.h"
|
|
||||||
|
|
||||||
#ifdef MOZILLA_CLIENT
|
|
||||||
|
|
||||||
/* extern declarations */
|
|
||||||
PR_PUBLIC_API(void) HT_WriteOutAsBookmarks (RDF r, PRFileDesc *fp, RDF_Resource u); /* XXX this should be elsewhere */
|
|
||||||
extern char *gBookmarkURL;
|
|
||||||
RDF gNCDB;
|
|
||||||
|
|
||||||
/* globals */
|
|
||||||
uint16 separatorCounter = 0;
|
|
||||||
static char* gBkFolderDate;
|
|
||||||
static RDFT gBMKStore = 0;
|
|
||||||
extern int RDF_PERSONAL_TOOLBAR_NAME;
|
|
||||||
|
|
||||||
RDF_Resource
|
|
||||||
createSeparator(void)
|
|
||||||
{
|
|
||||||
char url[50];
|
|
||||||
RDF_Resource sep;
|
|
||||||
PR_snprintf(url, 50, "separator%i", separatorCounter++);
|
|
||||||
sep = RDF_GetResource(NULL, url, 1);
|
|
||||||
return sep;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
RDF_Resource
|
|
||||||
createContainer (char* id)
|
|
||||||
{
|
|
||||||
RDF_Resource r = RDF_GetResource(NULL, id, true);
|
|
||||||
setContainerp(r, 1);
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef MOZILLA_CLIENT
|
|
||||||
|
|
||||||
char *
|
|
||||||
resourceDescription (RDF rdf, RDF_Resource r)
|
|
||||||
{
|
|
||||||
return (char*)RDF_GetSlotValue(rdf, r, gWebData->RDF_description, RDF_STRING_TYPE, false, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
char *
|
|
||||||
resourceLastVisitDate (RDF rdf, RDF_Resource r)
|
|
||||||
{
|
|
||||||
return (char*)RDF_GetSlotValue(rdf, r, gWebData->RDF_lastVisitDate, RDF_STRING_TYPE, false, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
char *
|
|
||||||
resourceLastModifiedDate (RDF rdf, RDF_Resource r)
|
|
||||||
{
|
|
||||||
return (char*)RDF_GetSlotValue(rdf, r, gWebData->RDF_lastModifiedDate, RDF_STRING_TYPE, false, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
parseNextBkBlob (RDFFile f, char* blob, int32 size)
|
|
||||||
{
|
|
||||||
int32 n, last, m;
|
|
||||||
PRBool somethingseenp = false;
|
|
||||||
n = last = 0;
|
|
||||||
|
|
||||||
while (n < size) {
|
|
||||||
char c = blob[n];
|
|
||||||
m = 0;
|
|
||||||
somethingseenp = false;
|
|
||||||
memset(f->line, '\0', f->lineSize);
|
|
||||||
if (f->holdOver[0] != '\0') {
|
|
||||||
memcpy(f->line, f->holdOver, RDF_STRLEN(f->holdOver));
|
|
||||||
m = RDF_STRLEN(f->holdOver);
|
|
||||||
somethingseenp = true;
|
|
||||||
memset(f->holdOver, '\0', RDF_BUF_SIZE);
|
|
||||||
}
|
|
||||||
while ((m < 300) && (c != '<') && (c != '>') && (n < size)) {
|
|
||||||
f->line[m] = c;
|
|
||||||
m++;
|
|
||||||
somethingseenp = (somethingseenp || ((c != ' ') && (c != '\r') && (c != '\n')));
|
|
||||||
n++;
|
|
||||||
c = blob[n];
|
|
||||||
}
|
|
||||||
if (c == '>') f->line[m] = c;
|
|
||||||
n++;
|
|
||||||
if (m > 0) {
|
|
||||||
if ((c == '<') || (c == '>')) {
|
|
||||||
last = n;
|
|
||||||
if (c == '<') f->holdOver[0] = '<';
|
|
||||||
if (somethingseenp == true) parseNextBkToken(f, f->line);
|
|
||||||
} else if (size > last) {
|
|
||||||
memcpy(f->holdOver, f->line, m);
|
|
||||||
}
|
|
||||||
} else if (c == '<') f->holdOver[0] = '<';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
parseNextBkToken (RDFFile f, char* token)
|
|
||||||
{
|
|
||||||
/* printf(token); */
|
|
||||||
if (token[0] == '<') {
|
|
||||||
bkStateTransition(f, token);
|
|
||||||
} else {
|
|
||||||
/* ok, we have a piece of content.
|
|
||||||
can be the title, or a description or */
|
|
||||||
if ((f->status == IN_TITLE) || (f->status == IN_H3) ||
|
|
||||||
(f->status == IN_ITEM_TITLE)) {
|
|
||||||
if (IN_H3 && gBkFolderDate) {
|
|
||||||
char *url;
|
|
||||||
RDF_Resource newFolder;
|
|
||||||
url = PR_smprintf("%s%s.rdf", gBkFolderDate, token);
|
|
||||||
newFolder = createContainer(url);
|
|
||||||
free(url);
|
|
||||||
addSlotValue(f,newFolder, gCoreVocab->RDF_parent, f->stack[f->depth-1],
|
|
||||||
RDF_RESOURCE_TYPE, NULL);
|
|
||||||
freeMem(gBkFolderDate);
|
|
||||||
gBkFolderDate = NULL;
|
|
||||||
f->lastItem = newFolder;
|
|
||||||
}
|
|
||||||
if ((f->db == gLocalStore) || (f->status != IN_TITLE))
|
|
||||||
{
|
|
||||||
addSlotValue(f, f->lastItem, gCoreVocab->RDF_name,
|
|
||||||
copyString(token), RDF_STRING_TYPE, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (startsWith("Personal Toolbar", token) && (containerp(f->lastItem)))
|
|
||||||
addSlotValue(f, f->lastItem, gCoreVocab->RDF_instanceOf,
|
|
||||||
gNavCenter->RDF_PersonalToolbarFolderCategory,
|
|
||||||
RDF_RESOURCE_TYPE, "true");
|
|
||||||
|
|
||||||
} else if (f->status == IN_ITEM_DESCRIPTION) {
|
|
||||||
addDescription(f, f->lastItem, token);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
addDescription (RDFFile f, RDF_Resource r, char* token)
|
|
||||||
{
|
|
||||||
char* desc = (char*) remoteStoreGetSlotValue(gLocalStore, r, gWebData->RDF_description,
|
|
||||||
RDF_STRING_TYPE, false, true);
|
|
||||||
if (desc == NULL) {
|
|
||||||
addSlotValue(f, f->lastItem, gWebData->RDF_description,
|
|
||||||
copyString(token),
|
|
||||||
RDF_STRING_TYPE, NULL);
|
|
||||||
} else {
|
|
||||||
addSlotValue(f, f->lastItem, gWebData->RDF_description,
|
|
||||||
append2Strings(desc, token), RDF_STRING_TYPE, NULL);
|
|
||||||
remoteUnassert(gLocalStore, f->lastItem, gWebData->RDF_description, desc, RDF_STRING_TYPE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
bkStateTransition (RDFFile f, char* token)
|
|
||||||
{
|
|
||||||
if (startsWith("<A", token)) {
|
|
||||||
newLeafBkItem(f, token);
|
|
||||||
f->status = IN_ITEM_TITLE;
|
|
||||||
} else if (startsWith(OPEN_H3_STRING, token)) {
|
|
||||||
newFolderBkItem(f, token);
|
|
||||||
f->status = IN_H3;
|
|
||||||
} else if (startsWith(OPEN_TITLE_STRING, token)) {
|
|
||||||
f->status = IN_TITLE;
|
|
||||||
} else if (startsWith(OPEN_H3_STRING, token)) {
|
|
||||||
f->status = IN_H3;
|
|
||||||
} else if (startsWith(DD_STRING, token)) {
|
|
||||||
if (remoteStoreGetSlotValue(gLocalStore, f->lastItem, gWebData->RDF_description,
|
|
||||||
RDF_STRING_TYPE, false, true)
|
|
||||||
== NULL) f->status = IN_ITEM_DESCRIPTION;
|
|
||||||
} else if (startsWith(OPEN_DL_STRING, token)) {
|
|
||||||
f->stack[f->depth++] = f->lastItem;
|
|
||||||
} else if (startsWith(CLOSE_DL_STRING, token)) {
|
|
||||||
f->depth--;
|
|
||||||
} else if (startsWith("<HR>", token)) {
|
|
||||||
addSlotValue(f, createSeparator(), gCoreVocab->RDF_parent, f->stack[f->depth-1],
|
|
||||||
RDF_RESOURCE_TYPE, NULL);
|
|
||||||
f->status = 0;
|
|
||||||
} else if ((f->status == IN_ITEM_DESCRIPTION) && (startsWith("<BR>", token))) {
|
|
||||||
addDescription(f, f->lastItem, token);
|
|
||||||
} else f->status = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
newFolderBkItem(RDFFile f, char* token)
|
|
||||||
{
|
|
||||||
int16 start, end;
|
|
||||||
start = charSearch('"', token);
|
|
||||||
end = revCharSearch('"', token);
|
|
||||||
token[end] = '\0';
|
|
||||||
gBkFolderDate = copyString(&token[start+1]);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
newLeafBkItem (RDFFile f, char* token)
|
|
||||||
{
|
|
||||||
/* char buffer[128]; */
|
|
||||||
struct tm *time;
|
|
||||||
uint32 dateVal;
|
|
||||||
char* url = NULL;
|
|
||||||
char* addDate = NULL;
|
|
||||||
char* lastVisit = NULL;
|
|
||||||
char* lastModified = NULL;
|
|
||||||
uint8 current = 0;
|
|
||||||
int32 len = RDF_STRLEN(token);
|
|
||||||
int32 n = 0;
|
|
||||||
char c = token[n++];
|
|
||||||
PRBool inString = false;
|
|
||||||
RDF_Resource newR;
|
|
||||||
|
|
||||||
while (n < len) {
|
|
||||||
if (c == '"') {
|
|
||||||
if (inString) {
|
|
||||||
token[n-1] = '\0';
|
|
||||||
inString = false;
|
|
||||||
} else {
|
|
||||||
inString = true;
|
|
||||||
if (current == 0) {
|
|
||||||
url = &token[n];
|
|
||||||
} else if (current == 1) {
|
|
||||||
addDate = &token[n];
|
|
||||||
} else if (current == 2) {
|
|
||||||
lastVisit = &token[n];
|
|
||||||
} else if (current == 3) {
|
|
||||||
lastModified = &token[n];
|
|
||||||
}
|
|
||||||
current++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
c = token[n++];
|
|
||||||
}
|
|
||||||
if (url == NULL) return;
|
|
||||||
newR = RDF_GetResource(NULL, url, true);
|
|
||||||
addSlotValue(f, newR, gCoreVocab->RDF_parent, f->stack[f->depth-1],
|
|
||||||
RDF_RESOURCE_TYPE, NULL);
|
|
||||||
/* addSlotValue(f, newR, gWebData->RDF_URL, (void*)copyString(url),
|
|
||||||
RDF_STRING_TYPE, true); */
|
|
||||||
if (addDate != NULL)
|
|
||||||
{
|
|
||||||
dateVal = atol(addDate);
|
|
||||||
if ((time = localtime((time_t *) &dateVal)) != NULL)
|
|
||||||
{
|
|
||||||
/* xxx
|
|
||||||
#ifdef XP_MAC
|
|
||||||
time->tm_year += 4;
|
|
||||||
strftime(buffer,sizeof(buffer),XP_GetString(RDF_HTML_MACDATE),time);
|
|
||||||
#elif XP_UNIX
|
|
||||||
strftime(buffer,sizeof(buffer),XP_GetString(RDF_HTML_MACDATE),time);
|
|
||||||
#else
|
|
||||||
strftime(buffer,sizeof(buffer),XP_GetString(RDF_HTML_WINDATE),time);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
addSlotValue(f, newR, gNavCenter->RDF_bookmarkAddDate,
|
|
||||||
(void*)copyString(buffer), RDF_STRING_TYPE, NULL);
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (lastVisit != NULL)
|
|
||||||
{
|
|
||||||
dateVal = atol(lastVisit);
|
|
||||||
if ((time = localtime((time_t *) &dateVal)) != NULL)
|
|
||||||
{
|
|
||||||
/* xxx
|
|
||||||
#ifdef XP_MAC
|
|
||||||
time->tm_year += 4;
|
|
||||||
strftime(buffer,sizeof(buffer),XP_GetString(RDF_HTML_MACDATE),time);
|
|
||||||
#elif XP_UNIX
|
|
||||||
strftime(buffer,sizeof(buffer),XP_GetString(RDF_HTML_MACDATE),time);
|
|
||||||
#else
|
|
||||||
strftime(buffer,sizeof(buffer),XP_GetString(RDF_HTML_WINDATE),time);
|
|
||||||
#endif
|
|
||||||
addSlotValue(f, newR, gWebData->RDF_lastVisitDate,
|
|
||||||
(void*)copyString(buffer), RDF_STRING_TYPE, NULL);
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (lastModified != NULL)
|
|
||||||
{
|
|
||||||
dateVal = atol(lastModified);
|
|
||||||
if ((time = localtime((time_t *) &dateVal)) != NULL)
|
|
||||||
{
|
|
||||||
/* xxx
|
|
||||||
#ifdef XP_MAC
|
|
||||||
time->tm_year += 4;
|
|
||||||
strftime(buffer,sizeof(buffer),XP_GetString(RDF_HTML_MACDATE),time);
|
|
||||||
#elif XP_UNIX
|
|
||||||
strftime(buffer,sizeof(buffer),XP_GetString(RDF_HTML_MACDATE),time);
|
|
||||||
#else
|
|
||||||
strftime(buffer,sizeof(buffer),XP_GetString(RDF_HTML_WINDATE),time);
|
|
||||||
#endif
|
|
||||||
addSlotValue(f, newR, gWebData->RDF_lastModifiedDate,
|
|
||||||
(void*)copyString(buffer), RDF_STRING_TYPE, NULL);
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
}
|
|
||||||
f->lastItem = newR;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
char *
|
|
||||||
numericDate(char *url)
|
|
||||||
{
|
|
||||||
char *date = NULL;
|
|
||||||
int len=0;
|
|
||||||
|
|
||||||
if (!url) return NULL;
|
|
||||||
while (url[len])
|
|
||||||
{
|
|
||||||
if (!isdigit(url[len])) break;
|
|
||||||
++len;
|
|
||||||
}
|
|
||||||
if (len > 0)
|
|
||||||
{
|
|
||||||
if ((date = getMem(len+1)) != NULL)
|
|
||||||
{
|
|
||||||
strncpy(date, url, len);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return(date);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
PRBool
|
|
||||||
bookmarkSlotp (RDF_Resource s)
|
|
||||||
{
|
|
||||||
return ((s == gCoreVocab->RDF_parent) || (s == gWebData->RDF_lastVisitDate) || (s == gWebData->RDF_description) ||
|
|
||||||
(s == gNavCenter->RDF_bookmarkAddDate) || (s == gWebData->RDF_lastModifiedDate) ||
|
|
||||||
(s == gCoreVocab->RDF_name));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
HT_WriteOutAsBookmarks1 (RDF rdf, PRFileDesc *fp, RDF_Resource u, RDF_Resource top, int indent)
|
|
||||||
{
|
|
||||||
RDF_Cursor c = RDF_GetSources(rdf, u, gCoreVocab->RDF_parent, RDF_RESOURCE_TYPE, true);
|
|
||||||
RDF_Resource next;
|
|
||||||
char *date, *name, *url;
|
|
||||||
int loop;
|
|
||||||
|
|
||||||
if (c == NULL) return;
|
|
||||||
if (u == top) {
|
|
||||||
name = RDF_GetResourceName(rdf, u);
|
|
||||||
ht_rjcprintf(fp, "<!DOCTYPE NETSCAPE-Bookmark-file-1>\n", NULL);
|
|
||||||
ht_rjcprintf(fp, "<!-- This is an automatically generated file.\n", NULL);
|
|
||||||
ht_rjcprintf(fp, "It will be read and overwritten.\n", NULL);
|
|
||||||
ht_rjcprintf(fp, "Do Not Edit! -->\n", NULL);
|
|
||||||
|
|
||||||
ht_rjcprintf(fp, "<TITLE>%s</TITLE>\n", (name) ? name:"");
|
|
||||||
ht_rjcprintf(fp, "<H1>%s</H1>\n<DL><p>\n", (name) ? name:"");
|
|
||||||
}
|
|
||||||
while ((next = RDF_NextValue(c)) != NULL) {
|
|
||||||
|
|
||||||
url = resourceID(next);
|
|
||||||
if (containerp(next) && (!startsWith("ftp:",url)) && (!startsWith("file:",url))
|
|
||||||
&& (!startsWith("IMAP:", url)) && (!startsWith("nes:", url))
|
|
||||||
&& (!startsWith("mail:", url)) && (!startsWith("cache:", url))
|
|
||||||
&& (!startsWith("ldap:", url))) {
|
|
||||||
for (loop=0; loop<indent; loop++) ht_rjcprintf(fp, " ", NULL);
|
|
||||||
|
|
||||||
date = numericDate(resourceID(next));
|
|
||||||
ht_rjcprintf(fp, "<DT><H3 ADD_DATE=\"%s\">", (date) ? date:"");
|
|
||||||
if (date) freeMem(date);
|
|
||||||
name = RDF_GetResourceName(rdf, next);
|
|
||||||
ht_rjcprintf(fp, "%s</H3>\n", name);
|
|
||||||
|
|
||||||
for (loop=0; loop<indent; loop++) ht_rjcprintf(fp, " ", NULL);
|
|
||||||
ht_rjcprintf(fp, "<DL><p>\n", NULL);
|
|
||||||
HT_WriteOutAsBookmarks1(rdf, fp, next, top, indent+1);
|
|
||||||
|
|
||||||
for (loop=0; loop<indent; loop++) ht_rjcprintf(fp, " ", NULL);
|
|
||||||
|
|
||||||
ht_rjcprintf(fp, "</DL><p>\n", NULL);
|
|
||||||
}
|
|
||||||
else if (isSeparator(next)) {
|
|
||||||
for (loop=0; loop<indent; loop++) ht_rjcprintf(fp, " ", NULL);
|
|
||||||
ht_rjcprintf(fp, "<HR>\n", NULL);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
char* bkAddDate = (char*)RDF_GetSlotValue(rdf, next,
|
|
||||||
gNavCenter->RDF_bookmarkAddDate,
|
|
||||||
RDF_STRING_TYPE, false, true);
|
|
||||||
|
|
||||||
for (loop=0; loop<indent; loop++) ht_rjcprintf(fp, " ", NULL);
|
|
||||||
|
|
||||||
ht_rjcprintf(fp, "<DT><A HREF=\"%s\" ", resourceID(next));
|
|
||||||
date = numericDate(bkAddDate);
|
|
||||||
ht_rjcprintf(fp, "ADD_DATE=\"%s\" ", (date) ? date: "");
|
|
||||||
if (date) freeMem(date);
|
|
||||||
ht_rjcprintf(fp, "LAST_VISIT=\"%s\" ", resourceLastVisitDate(rdf, next));
|
|
||||||
ht_rjcprintf(fp, "LAST_MODIFIED=\"%s\">", resourceLastModifiedDate(rdf, next));
|
|
||||||
ht_rjcprintf(fp, "%s</A>\n", RDF_GetResourceName(rdf, next));
|
|
||||||
|
|
||||||
if (resourceDescription(rdf, next) != NULL) {
|
|
||||||
ht_rjcprintf(fp, "<DD>%s\n", resourceDescription(rdf, next));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
RDF_DisposeCursor(c);
|
|
||||||
if (u == top) {
|
|
||||||
ht_rjcprintf(fp, "</DL>\n", NULL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
PR_PUBLIC_API(void)
|
|
||||||
HT_WriteOutAsBookmarks (RDF r, PRFileDesc *fp, RDF_Resource u)
|
|
||||||
{
|
|
||||||
HT_WriteOutAsBookmarks1 (r, fp, u, u, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
flushBookmarks()
|
|
||||||
{
|
|
||||||
PRFileDesc *bkfp;
|
|
||||||
|
|
||||||
if (gBookmarkURL != NULL)
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
delete bookmark.htm as PROpen() with PR_TRUNCATE appears broken (at least on Mac)
|
|
||||||
*/
|
|
||||||
CallPRDeleteFileUsingFileURL(gBookmarkURL);
|
|
||||||
|
|
||||||
if ((bkfp = CallPROpenUsingFileURL(gBookmarkURL, (PR_WRONLY|PR_CREATE_FILE|PR_TRUNCATE),
|
|
||||||
0644)) != NULL)
|
|
||||||
{
|
|
||||||
HT_WriteOutAsBookmarks(gNCDB, bkfp, gNavCenter->RDF_BookmarkFolderCategory);
|
|
||||||
PR_Close(bkfp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
PRBool
|
|
||||||
ResourceBelongsToBookmarksp (RDF_Resource r, int32 depth) {
|
|
||||||
if (depth > 20) {
|
|
||||||
return false;
|
|
||||||
} else if (r == gNavCenter->RDF_BookmarkFolderCategory) {
|
|
||||||
return 1;
|
|
||||||
} else if (containerp(r)) {
|
|
||||||
Assertion as = r->rarg1;
|
|
||||||
while (as) {
|
|
||||||
if ((as->db == gBMKStore) &&
|
|
||||||
(as->s == gCoreVocab->RDF_parent) &&
|
|
||||||
(as->tv == 1) &&
|
|
||||||
(ResourceBelongsToBookmarksp((RDF_Resource)as->value, depth+1))) return 1;
|
|
||||||
as = as->next;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
} else return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
PRBool remoteAssert3 (RDFFile fi, RDFT mcf, RDF_Resource u, RDF_Resource s, void* v,
|
|
||||||
RDF_ValueType type, PRBool tv);
|
|
||||||
PRBool remoteUnassert3 (RDFFile fi, RDFT mcf, RDF_Resource u, RDF_Resource s, void* v,
|
|
||||||
RDF_ValueType type);
|
|
||||||
|
|
||||||
|
|
||||||
PRBool
|
|
||||||
bmkUnassert (RDFT mcf, RDF_Resource u, RDF_Resource s,
|
|
||||||
void* v, RDF_ValueType type) {
|
|
||||||
if (ResourceBelongsToBookmarksp(u, 0)) {
|
|
||||||
return (remoteStoreRemove(mcf, u, s, v, type) != NULL);
|
|
||||||
} else return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
PRBool
|
|
||||||
bmkAssert (RDFT mcf, RDF_Resource u, RDF_Resource s, void* v,
|
|
||||||
RDF_ValueType type, PRBool tv) {
|
|
||||||
if (ResourceBelongsToBookmarksp(u, 0)) {
|
|
||||||
return (remoteStoreAdd(mcf, u, s, v, type, tv) != NULL);
|
|
||||||
} else return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
extern RDF_Resource gPTFolder;
|
|
||||||
void
|
|
||||||
readInBookmarks()
|
|
||||||
{
|
|
||||||
/* RDF_Resource ptFolder; */
|
|
||||||
|
|
||||||
/* XXX use rdf:bookmarks to get the demo up and running. I have no
|
|
||||||
clue what the difference is. */
|
|
||||||
|
|
||||||
/* RDF_Resource bmk = RDF_GetResource(NULL, "NC:Bookmarks", true); */
|
|
||||||
RDF_Resource bmk = RDF_GetResource(NULL, "rdf:bookmarks", true);
|
|
||||||
RDFFile f = makeRDFFile(gBookmarkURL, bmk, true);
|
|
||||||
PRFileDesc *fp;
|
|
||||||
int32 len;
|
|
||||||
char buf[512];
|
|
||||||
f->fileType = RDF_BOOKMARKS;
|
|
||||||
f->db = gBMKStore;
|
|
||||||
f->assert = remoteAssert3;
|
|
||||||
|
|
||||||
fp = CallPROpenUsingFileURL(f->url, PR_RDONLY|PR_CREATE_FILE, 0644);
|
|
||||||
if (fp == NULL) return;
|
|
||||||
while((len=PR_Read(fp, buf, sizeof(buf))) >0) {
|
|
||||||
parseNextBkBlob(f, buf, len);
|
|
||||||
}
|
|
||||||
|
|
||||||
gPTFolder = remoteStoreGetSlotValue(f->db,
|
|
||||||
gNavCenter->RDF_PersonalToolbarFolderCategory,
|
|
||||||
gCoreVocab->RDF_instanceOf, RDF_RESOURCE_TYPE, true, true);
|
|
||||||
|
|
||||||
if (gPTFolder == NULL) {
|
|
||||||
if ((gPTFolder = createContainer("personaltoolbar.rdf")) != NULL) {
|
|
||||||
addSlotValue(f, gPTFolder, gCoreVocab->RDF_instanceOf,
|
|
||||||
gNavCenter->RDF_PersonalToolbarFolderCategory,
|
|
||||||
RDF_RESOURCE_TYPE, "true");
|
|
||||||
addSlotValue(f, gPTFolder, gCoreVocab->RDF_name,
|
|
||||||
copyString("Personal Toolbar"),
|
|
||||||
RDF_STRING_TYPE, "true");
|
|
||||||
RDFUtil_SetPTFolder(gPTFolder);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
PR_Close(fp);
|
|
||||||
freeMem(f->line);
|
|
||||||
freeMem(f->currentSlot);
|
|
||||||
freeMem(f->holdOver);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
RDFT
|
|
||||||
MakeBMKStore (char* url)
|
|
||||||
{
|
|
||||||
if (startsWith("rdf:bookmarks", url)) {
|
|
||||||
if (gBMKStore == 0) {
|
|
||||||
RDFT ntr = gBMKStore = NewRemoteStore(url);
|
|
||||||
ntr->assert = bmkAssert;
|
|
||||||
ntr->unassert = bmkUnassert;
|
|
||||||
readInBookmarks();
|
|
||||||
return ntr;
|
|
||||||
} else return gBMKStore;
|
|
||||||
} else return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,76 +0,0 @@
|
||||||
/* -*- 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 _RDF_BMK2MCF_H_
|
|
||||||
#define _RDF_BMK2MCF_H_
|
|
||||||
|
|
||||||
|
|
||||||
#include "rdf.h"
|
|
||||||
#include "rdf-int.h"
|
|
||||||
#include "vocab.h"
|
|
||||||
#include "utils.h"
|
|
||||||
#include "glue.h"
|
|
||||||
#include "time.h"
|
|
||||||
#include "stdio.h"
|
|
||||||
#include "ctype.h"
|
|
||||||
|
|
||||||
|
|
||||||
/* bmk2mcf.c data structures and defines */
|
|
||||||
|
|
||||||
#define OPEN_TITLE_STRING "<TITLE>"
|
|
||||||
#define CLOSE_TITLE_STRING "</TITLE>"
|
|
||||||
#define OPEN_H1_STRING "<H1>"
|
|
||||||
#define CLOSE_H1_STRING "</H1>"
|
|
||||||
#define OPEN_H3_STRING "<H3"
|
|
||||||
#define CLOSE_H3_STRING "</H3>"
|
|
||||||
#define OPEN_DL_STRING "<DL>"
|
|
||||||
#define CLOSE_DL_STRING "</DL>"
|
|
||||||
#define DT_STRING "<DT>"
|
|
||||||
#define PAR_STRING "<P>"
|
|
||||||
#define DD_STRING "<DD>"
|
|
||||||
|
|
||||||
#define IN_TITLE 1
|
|
||||||
#define IN_H3 5
|
|
||||||
#define IN_ITEM_TITLE 7
|
|
||||||
#define IN_ITEM_DESCRIPTION 9
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* bmk2mcf.c function prototypes */
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
RDF_Resource createSeparator(void);
|
|
||||||
RDF_Resource createContainer (char* id);
|
|
||||||
char * resourceDescription (RDF rdf, RDF_Resource r);
|
|
||||||
char * resourceLastVisitDate (RDF rdf, RDF_Resource r);
|
|
||||||
char * resourceLastModifiedDate (RDF rdf, RDF_Resource r);
|
|
||||||
void parseNextBkBlob (RDFFile f, char* blob, int32 size);
|
|
||||||
void parseNextBkToken (RDFFile f, char* token);
|
|
||||||
void addDescription (RDFFile f, RDF_Resource r, char* token);
|
|
||||||
void bkStateTransition (RDFFile f, char* token);
|
|
||||||
void newFolderBkItem(RDFFile f, char* token);
|
|
||||||
void newLeafBkItem (RDFFile f, char* token);
|
|
||||||
char * numericDate(char *url);
|
|
||||||
void HT_WriteOutAsBookmarks1 (RDF rdf, PRFileDesc *fp, RDF_Resource u, RDF_Resource top, int indent);
|
|
||||||
void flushBookmarks();
|
|
||||||
RDFT MakeBMKStore (char* url);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,284 +0,0 @@
|
||||||
/* -*- 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 file synthesizes default columns for a given node.
|
|
||||||
For more information on this file, contact rjc or guha
|
|
||||||
For more information on RDF, look at the RDF section of www.mozilla.org
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "columns.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
RDF_Cursor
|
|
||||||
ColumnsGetSlotValues (RDFT rdf, RDF_Resource u, RDF_Resource s,
|
|
||||||
RDF_ValueType type, PRBool inversep, PRBool tv)
|
|
||||||
{
|
|
||||||
RDF_Cursor c;
|
|
||||||
|
|
||||||
if (!containerp(u) || (s != gNavCenter->RDF_Column) || (inversep) ||
|
|
||||||
(!tv) || (type != RDF_RESOURCE_TYPE))
|
|
||||||
{
|
|
||||||
return(NULL);
|
|
||||||
}
|
|
||||||
if ((c = (RDF_Cursor)getMem(sizeof(struct RDF_CursorStruct))) != NULL)
|
|
||||||
{
|
|
||||||
c->u = u;
|
|
||||||
c->value = NULL;
|
|
||||||
c->count = 0;
|
|
||||||
}
|
|
||||||
return(c);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void *
|
|
||||||
ColumnsGetSlotValue(RDFT rdf, RDF_Resource u, RDF_Resource s, RDF_ValueType type,
|
|
||||||
PRBool inversep, PRBool tv)
|
|
||||||
{
|
|
||||||
void *val = NULL;
|
|
||||||
|
|
||||||
if (u == NULL) return(NULL);
|
|
||||||
|
|
||||||
if ((s == gCoreVocab->RDF_name) && (type == RDF_STRING_TYPE)
|
|
||||||
&& (!inversep) && (tv))
|
|
||||||
{
|
|
||||||
#ifdef XXX
|
|
||||||
if (u == gCoreVocab->RDF_name) val = copyString(XP_GetString(RDF_NAME_STR));
|
|
||||||
else if (u == gNavCenter->RDF_URLShortcut) val = copyString(XP_GetString(RDF_SHORTCUT_STR));
|
|
||||||
else if (u == gWebData->RDF_URL) val = copyString(XP_GetString(RDF_URL_STR));
|
|
||||||
else if (u == gWebData->RDF_description) val = copyString(XP_GetString(RDF_DESCRIPTION_STR));
|
|
||||||
else if (u == gWebData->RDF_firstVisitDate) val = copyString(XP_GetString(RDF_FIRST_VISIT_STR));
|
|
||||||
else if (u == gWebData->RDF_lastVisitDate) val = copyString(XP_GetString(RDF_LAST_VISIT_STR));
|
|
||||||
else if (u == gWebData->RDF_numAccesses) val = copyString(XP_GetString(RDF_NUM_ACCESSES_STR));
|
|
||||||
else if (u == gWebData->RDF_creationDate) val = copyString(XP_GetString(RDF_CREATED_ON_STR));
|
|
||||||
else if (u == gWebData->RDF_lastModifiedDate) val = copyString(XP_GetString(RDF_LAST_MOD_STR));
|
|
||||||
else if (u == gWebData->RDF_size) val = copyString(XP_GetString(RDF_SIZE_STR));
|
|
||||||
else if (u == gNavCenter->RDF_bookmarkAddDate) val = copyString(XP_GetString(RDF_ADDED_ON_STR));
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
else if ((s == gNavCenter->RDF_ColumnDataType) &&
|
|
||||||
(type == RDF_INT_TYPE) && (!inversep) && (tv))
|
|
||||||
{
|
|
||||||
if (u == gNavCenter->RDF_bookmarkAddDate ||
|
|
||||||
u == gWebData->RDF_firstVisitDate ||
|
|
||||||
u == gWebData->RDF_lastVisitDate ||
|
|
||||||
u == gWebData->RDF_lastModifiedDate ||
|
|
||||||
u == gWebData->RDF_creationDate)
|
|
||||||
{
|
|
||||||
val = (void *)HT_COLUMN_STRING;
|
|
||||||
}
|
|
||||||
else if (u == gWebData->RDF_size ||
|
|
||||||
u == gWebData->RDF_numAccesses ||
|
|
||||||
u == gNavCenter->cookieDomain ||
|
|
||||||
u == gNavCenter->cookieSecure)
|
|
||||||
{
|
|
||||||
val = (void *)HT_COLUMN_INT;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* default to string... XXX wrong thing to do? */
|
|
||||||
val = (void *)HT_COLUMN_STRING;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if ((s == gNavCenter->RDF_ColumnWidth) &&
|
|
||||||
(type == RDF_INT_TYPE) && (!inversep) && (tv))
|
|
||||||
{
|
|
||||||
if (u == gCoreVocab->RDF_name) val = (void *)128L;
|
|
||||||
else if (u == gWebData->RDF_URL) val = (void *)200L;
|
|
||||||
else val = (void *)80;
|
|
||||||
}
|
|
||||||
return(val);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void *
|
|
||||||
ColumnsNextValue (RDFT rdf, RDF_Cursor c)
|
|
||||||
{
|
|
||||||
void *arc = NULL;
|
|
||||||
|
|
||||||
PR_ASSERT(c != NULL);
|
|
||||||
if (c == NULL) return(NULL);
|
|
||||||
|
|
||||||
switch( resourceType(c->u) )
|
|
||||||
{
|
|
||||||
case RDF_RT:
|
|
||||||
if ((c->u == gNavCenter->RDF_Sitemaps) || (c->u == gNavCenter->RDF_Mail))
|
|
||||||
{
|
|
||||||
switch(c->count)
|
|
||||||
{
|
|
||||||
case 0: arc = gCoreVocab->RDF_name; break;
|
|
||||||
case 1: arc = gWebData->RDF_URL; break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else do
|
|
||||||
{
|
|
||||||
switch(c->count)
|
|
||||||
{
|
|
||||||
case 0: arc = gCoreVocab->RDF_name; break;
|
|
||||||
case 1:
|
|
||||||
if ((idenEqual(c->u, gNavCenter->RDF_BookmarkFolderCategory)) ||
|
|
||||||
((!startsWith("http://", resourceID(c->u))) && endsWith(".rdf", resourceID(c->u))))
|
|
||||||
{
|
|
||||||
arc = gNavCenter->RDF_URLShortcut;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* disallow shortcuts from external RDF graphs, so skip to next column */
|
|
||||||
arc = NULL;
|
|
||||||
++(c->count);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 2: arc = gWebData->RDF_URL; break;
|
|
||||||
case 3: arc = gWebData->RDF_description; break;
|
|
||||||
case 4: arc = gWebData->RDF_keyword; break;
|
|
||||||
case 5: arc = gNavCenter->RDF_bookmarkAddDate; break;
|
|
||||||
case 6: arc = gWebData->RDF_lastVisitDate; break;
|
|
||||||
case 7: arc = gWebData->RDF_lastModifiedDate; break;
|
|
||||||
case 8: arc = gNavCenter->pos; break;
|
|
||||||
}
|
|
||||||
} while ((c->count <= 6) && (arc == NULL));
|
|
||||||
break;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
case HISTORY_RT:
|
|
||||||
switch(c->count)
|
|
||||||
{
|
|
||||||
case 0: arc = gCoreVocab->RDF_name; break;
|
|
||||||
case 1: arc = gWebData->RDF_URL; break;
|
|
||||||
case 2: arc = gWebData->RDF_firstVisitDate; break;
|
|
||||||
case 3: arc = gWebData->RDF_lastVisitDate; break;
|
|
||||||
case 4: arc = NULL; break;
|
|
||||||
case 5: arc = gWebData->RDF_numAccesses; break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case COOKIE_RT:
|
|
||||||
switch(c->count)
|
|
||||||
{
|
|
||||||
case 0: arc = gCoreVocab->RDF_name; break;
|
|
||||||
case 1: arc = gNavCenter->cookieHost; break;
|
|
||||||
case 2: arc = gNavCenter->cookiePath; break;
|
|
||||||
case 3: arc = gNavCenter->cookieValue; break;
|
|
||||||
case 4: arc = gNavCenter->cookieExpires; break;
|
|
||||||
case 5: arc = gNavCenter->cookieDomain; break;
|
|
||||||
case 6: arc = gNavCenter->cookieSecure; break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
|
|
||||||
case FTP_RT:
|
|
||||||
case ES_RT:
|
|
||||||
switch(c->count)
|
|
||||||
{
|
|
||||||
case 0: arc = gCoreVocab->RDF_name; break;
|
|
||||||
case 1: arc = gWebData->RDF_URL; break;
|
|
||||||
case 2: arc = gWebData->RDF_description; break;
|
|
||||||
case 3: arc = gWebData->RDF_size; break;
|
|
||||||
case 4: arc = gWebData->RDF_lastModifiedDate; break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case LFS_RT:
|
|
||||||
switch(c->count)
|
|
||||||
{
|
|
||||||
case 0: arc = gCoreVocab->RDF_name; break;
|
|
||||||
case 1: arc = gWebData->RDF_URL; break;
|
|
||||||
case 2: arc = gWebData->RDF_description; break;
|
|
||||||
case 3: arc = gWebData->RDF_size; break;
|
|
||||||
case 4: arc = gWebData->RDF_lastModifiedDate; break;
|
|
||||||
case 5: arc = gWebData->RDF_creationDate; break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case LDAP_RT:
|
|
||||||
switch(c->count)
|
|
||||||
{
|
|
||||||
case 0: arc = gCoreVocab->RDF_name; break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PM_RT:
|
|
||||||
case IM_RT:
|
|
||||||
switch(c->count)
|
|
||||||
{
|
|
||||||
case 0: arc = gCoreVocab->RDF_name; break;
|
|
||||||
case 1: arc = gWebData->RDF_URL; break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SEARCH_RT:
|
|
||||||
switch(c->count)
|
|
||||||
{
|
|
||||||
case 0: arc = gCoreVocab->RDF_name; break;
|
|
||||||
case 1: arc = gNavCenter->RDF_URLShortcut; break;
|
|
||||||
case 2: arc = gWebData->RDF_URL; break;
|
|
||||||
case 3: arc = gWebData->RDF_description; break;
|
|
||||||
case 4: arc = gWebData->RDF_keyword; break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
switch(c->count)
|
|
||||||
{
|
|
||||||
case 0: arc = gCoreVocab->RDF_name; break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
++(c->count);
|
|
||||||
return(arc);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
RDF_Error
|
|
||||||
ColumnsDisposeCursor (RDFT rdf, RDF_Cursor c)
|
|
||||||
{
|
|
||||||
if (c != NULL)
|
|
||||||
{
|
|
||||||
freeMem(c);
|
|
||||||
}
|
|
||||||
return(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
RDFT
|
|
||||||
MakeColumnStore (char* url)
|
|
||||||
{
|
|
||||||
RDFT ntr = NULL;
|
|
||||||
|
|
||||||
if (strstr(url, "rdf:columns"))
|
|
||||||
{
|
|
||||||
if ((ntr = (RDFT)getMem(sizeof(struct RDF_TranslatorStruct))) != NULL)
|
|
||||||
{
|
|
||||||
ntr->getSlotValues = ColumnsGetSlotValues;
|
|
||||||
ntr->getSlotValue = ColumnsGetSlotValue;
|
|
||||||
ntr->nextValue = ColumnsNextValue;
|
|
||||||
ntr->disposeCursor = ColumnsDisposeCursor;
|
|
||||||
ntr->url = copyString(url);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return(ntr);
|
|
||||||
}
|
|
|
@ -1,48 +0,0 @@
|
||||||
/* -*- 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 _RDF_COLUMNS_H_
|
|
||||||
#define _RDF_COLUMNS_H_
|
|
||||||
|
|
||||||
|
|
||||||
#include "rdf-int.h"
|
|
||||||
#include "htrdf.h"
|
|
||||||
#include "utils.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* columns.c data structures */
|
|
||||||
|
|
||||||
extern int RDF_NAME_STR, RDF_SHORTCUT_STR, RDF_URL_STR, RDF_DESCRIPTION_STR;
|
|
||||||
extern int RDF_FIRST_VISIT_STR, RDF_LAST_VISIT_STR, RDF_NUM_ACCESSES_STR;
|
|
||||||
extern int RDF_CREATED_ON_STR, RDF_LAST_MOD_STR, RDF_SIZE_STR, RDF_ADDED_ON_STR;
|
|
||||||
|
|
||||||
|
|
||||||
/* columns.c function prototypes */
|
|
||||||
|
|
||||||
NSPR_BEGIN_EXTERN_C
|
|
||||||
|
|
||||||
RDF_Cursor ColumnsGetSlotValues (RDFT rdf, RDF_Resource u, RDF_Resource s, RDF_ValueType type, PRBool inversep, PRBool tv);
|
|
||||||
void * ColumnsGetSlotValue(RDFT rdf, RDF_Resource u, RDF_Resource s, RDF_ValueType type, PRBool inversep, PRBool tv);
|
|
||||||
void * ColumnsNextValue (RDFT rdf, RDF_Cursor c);
|
|
||||||
RDF_Error ColumnsDisposeCursor (RDFT rdf, RDF_Cursor c);
|
|
||||||
RDFT MakeColumnStore (char* url);
|
|
||||||
|
|
||||||
NSPR_END_EXTERN_C
|
|
||||||
|
|
||||||
#endif
|
|
1123
rdf/src/core.c
1123
rdf/src/core.c
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -1,93 +0,0 @@
|
||||||
/* -*- 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 _RDF_MCF_H_
|
|
||||||
#define _RDF_MCF_H_
|
|
||||||
|
|
||||||
|
|
||||||
#include "rdf-int.h"
|
|
||||||
#include "prprf.h"
|
|
||||||
#include "prtime.h"
|
|
||||||
#include <string.h>
|
|
||||||
#include "bmk2rdf.h"
|
|
||||||
|
|
||||||
/* mcf.c data structures and defines */
|
|
||||||
|
|
||||||
struct RDF_NotificationStruct {
|
|
||||||
RDF_Event theEvent;
|
|
||||||
void* pdata;
|
|
||||||
RDF_NotificationProc notifFunction;
|
|
||||||
RDF rdf;
|
|
||||||
struct RDF_NotificationStruct* next;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#define ntr(r, n) (*((RDFT*)r->translators + n))
|
|
||||||
#define ntrn(r, n) (*((RDFT*)r->translators + n) == NULL)
|
|
||||||
#define callAssert(n, r, u, s, v,type,tv) (ntrn(r, n) || (ntr(r, n)->assert == NULL) ? 0 : (*(ntr(r, n)->assert))(ntr(r, n), u, s, v, type, tv))
|
|
||||||
#define callUnassert(n, r, u, s, v,type) (ntrn(r, n) || (ntr(r, n)->unassert == NULL) ? 0 : (*(ntr(r, n)->unassert))(ntr(r, n), u, s, v, type))
|
|
||||||
#define callGetSlotValue(n, r, u, s, type, invp, tv) (ntrn(r, n) || (ntr(r, n)->getSlotValue == NULL) ? 0 : (*(ntr(r, n)->getSlotValue))(ntr(r, n), u, s, type, invp, tv))
|
|
||||||
#define callGetSlotValues(n, r, u, s, type,invp, tv) (ntrn(r, n) || (ntr(r, n)->getSlotValues == NULL) ? 0 : (*(ntr(r, n)->getSlotValues))(ntr(r, n), u, s, type,invp, tv))
|
|
||||||
#define callHasAssertions(n, r, u, s, v,type,tv) (ntrn(r, n) || (ntr(r, n)->hasAssertion == NULL) ? 0 : (*(ntr(r, n)->hasAssertion))(ntr(r, n), u, s, v, type, tv))
|
|
||||||
#define callArcLabelsOut(n, r, u) (ntrn(r, n) || (ntr(r, n)->arcLabelsOut == NULL) ? 0 : (*(ntr(r, n)->arcLabelsOut))(ntr(r, n), u))
|
|
||||||
#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
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* mcf.c function prototypes */
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
RDFT getTranslator (char* url);
|
|
||||||
RDFL deleteFromRDFList (RDFL xrl, RDF db);
|
|
||||||
RDF_Error exitRDF (RDF rdf);
|
|
||||||
RDF_Resource addDep (RDF db, RDF_Resource u);
|
|
||||||
PRBool rdfassert(RDF rdf, RDF_Resource u, RDF_Resource s, void* value, RDF_ValueType type, PRBool tv);
|
|
||||||
PRBool containerIDp(char* id);
|
|
||||||
char * makeNewID ();
|
|
||||||
PRBool iscontainerp (RDF_Resource u);
|
|
||||||
RDF_BT resourceTypeFromID (char* id);
|
|
||||||
RDF_Resource specialUrlResource (char* id);
|
|
||||||
RDF_Resource NewRDFResource (char* id);
|
|
||||||
RDF_Resource QuickGetResource (char* id);
|
|
||||||
RDF_Cursor getSlotValues (RDF rdf, RDF_Resource u, RDF_Resource s, RDF_ValueType type, PRBool inversep, PRBool tv);
|
|
||||||
void disposeResourceInt (RDF rdf, RDF_Resource u);
|
|
||||||
void possiblyGCResource (RDF_Resource u);
|
|
||||||
RDF_Resource NewRDFResource (char* id);
|
|
||||||
RDF_Resource QuickGetResource (char* id);
|
|
||||||
void assertNotify (RDF rdf, RDF_Notification not, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type, PRBool tv, char* ds);
|
|
||||||
void insertNotify (RDF rdf, RDF_Notification not, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type, PRBool tv, char* ds);
|
|
||||||
void unassertNotify (RDF_Notification not, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type, char* ds);
|
|
||||||
void sendNotifications1 (RDFL rl, RDF_EventType opType, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type, PRBool tv);
|
|
||||||
void sendNotifications (RDF rdf, RDF_EventType opType, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type, PRBool tv, char* ds);
|
|
||||||
RDF_Resource nextFindValue (RDF_Cursor c);
|
|
||||||
PRBool matchStrings(RDF_Resource match, char *str1, char *str2);
|
|
||||||
PRBool itemMatchesFind (RDF r, RDF_Resource u, RDF_Resource s, void* v, RDF_Resource match, RDF_ValueType type);
|
|
||||||
PR_PUBLIC_API(RDF_Cursor)RDF_Find (RDF_Resource s, RDF_Resource match, void* v, RDF_ValueType type);
|
|
||||||
PRIntn findEnumerator (PLHashEntry *he, PRIntn i, void *arg);
|
|
||||||
void disposeAllDBs ();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,90 +0,0 @@
|
||||||
/* -*- 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 _RDF_GLUE_H_
|
|
||||||
#define _RDF_GLUE_H_
|
|
||||||
|
|
||||||
|
|
||||||
#include "xp.h"
|
|
||||||
#include "xp_mem.h"
|
|
||||||
#include "net.h"
|
|
||||||
#include "ntypes.h"
|
|
||||||
#include "fe_proto.h"
|
|
||||||
|
|
||||||
#include "prinit.h"
|
|
||||||
|
|
||||||
#ifdef XP_UNIX
|
|
||||||
#include <sys/fcntl.h>
|
|
||||||
#elif defined(XP_MAC)
|
|
||||||
#include <fcntl.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "rdf.h"
|
|
||||||
#include "rdf-int.h"
|
|
||||||
#include "ht.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define APPLICATION_RDF "application/x-rdf" /* XXX what should these be? */
|
|
||||||
#define EXTENSION_RDF ".rdf"
|
|
||||||
#define EXTENSION_MCF ".mcf"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* external globals */
|
|
||||||
extern char* gLocalStoreURL;
|
|
||||||
extern char* gBookmarkURL;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* glue.c prototypes */
|
|
||||||
|
|
||||||
NSPR_BEGIN_EXTERN_C
|
|
||||||
|
|
||||||
void ht_fprintf(PRFileDesc *file, const char *fmt, ...);
|
|
||||||
|
|
||||||
unsigned int rdf_write_ready(NET_StreamClass *stream);
|
|
||||||
void rdf_complete(NET_StreamClass *stream);
|
|
||||||
void rdf_abort(NET_StreamClass *stream, int status);
|
|
||||||
NET_StreamClass * rdf_Converter(FO_Present_Types format_out,
|
|
||||||
void *client_data, URL_Struct *urls, MWContext *cx);
|
|
||||||
void rdf_GetUrlExitFunc (URL_Struct *urls, int status, MWContext *cx);
|
|
||||||
int rdfRetrievalType (RDFFile f);
|
|
||||||
int rdf_GetURL (MWContext *cx, int method,
|
|
||||||
Net_GetUrlExitFunc *exit_routine, RDFFile rdfFile);
|
|
||||||
void possiblyRereadRDFFiles (void* data);
|
|
||||||
void RDFglueInitialize (void);
|
|
||||||
void RDFglueExit (void);
|
|
||||||
void *gRDFMWContext(RDFT db);
|
|
||||||
void beginReadingRDFFile (RDFFile file);
|
|
||||||
void readLocalFile (RDFFile file);
|
|
||||||
|
|
||||||
char *unescapeURL(char *inURL);
|
|
||||||
char *convertFileURLToNSPRCopaceticPath(char* inURL);
|
|
||||||
PRFileDesc *CallPROpenUsingFileURL(char *fileURL, PRIntn flags, PRIntn mode);
|
|
||||||
PRDir *CallPROpenDirUsingFileURL(char *fileURL);
|
|
||||||
int32 CallPRWriteAccessFileUsingFileURL(char *fileURL);
|
|
||||||
int32 CallPRDeleteFileUsingFileURL(char *fileURL);
|
|
||||||
int CallPR_RmDirUsingFileURL(char *dirURL);
|
|
||||||
int32 CallPRMkDirUsingFileURL(char *dirURL, int mode);
|
|
||||||
DB *CallDBOpenUsingFileURL(char *fileURL, int flags,int mode,
|
|
||||||
DBTYPE type, const void *openinfo);
|
|
||||||
|
|
||||||
NSPR_END_EXTERN_C
|
|
||||||
|
|
||||||
#endif
|
|
10392
rdf/src/ht.c
10392
rdf/src/ht.c
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
399
rdf/src/ht.h
399
rdf/src/ht.h
|
@ -1,399 +0,0 @@
|
||||||
/* -*- 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 _RDF_HT_H_
|
|
||||||
#define _RDF_HT_H_
|
|
||||||
|
|
||||||
#define HT_RAPTOR 1
|
|
||||||
|
|
||||||
#ifndef HT_RAPTOR
|
|
||||||
#include "xpassert.h"
|
|
||||||
#include "xp_qsort.h"
|
|
||||||
#include "xp_time.h"
|
|
||||||
#include "client.h"
|
|
||||||
#include "net.h"
|
|
||||||
#include "xpgetstr.h"
|
|
||||||
#include "xp_str.h"
|
|
||||||
#include "htmldlgs.h"
|
|
||||||
#include "xp_ncent.h"
|
|
||||||
#include "xpassert.h"
|
|
||||||
#include "nspr.h"
|
|
||||||
#include "prefapi.h"
|
|
||||||
#include "fe_proto.h"
|
|
||||||
#include "intl_csi.h"
|
|
||||||
|
|
||||||
#ifdef XP_MAC
|
|
||||||
#include "stdlib.h"
|
|
||||||
#include <Aliases.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "rdf.h"
|
|
||||||
#include "rdf-int.h"
|
|
||||||
#include "math.h"
|
|
||||||
#include "htrdf.h"
|
|
||||||
|
|
||||||
#ifdef SMART_MAIL
|
|
||||||
#include "pm2rdf.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#else
|
|
||||||
#include "prprf.h"
|
|
||||||
#include "plhash.h"
|
|
||||||
#include "nspr.h"
|
|
||||||
#include "rdf.h"
|
|
||||||
#include "rdf-int.h"
|
|
||||||
#include "core.h"
|
|
||||||
#include "htrdf.h"
|
|
||||||
#include "vocab.h"
|
|
||||||
|
|
||||||
#ifndef XP_ASSERT
|
|
||||||
#define XP_ASSERT(x)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef XP_FREE
|
|
||||||
#define XP_FREE(x) PR_Free((x))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef XP_STRCASECMP
|
|
||||||
#define XP_STRCASECMP(x,y) strcmp((x),(y))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define MWContext void
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/* HT data structures and defines */
|
|
||||||
|
|
||||||
#define ITEM_LIST_SIZE 500 /* XXX ITEM_LIST_SIZE should be dynamic */
|
|
||||||
#define ITEM_LIST_ELEMENT_SIZE 20
|
|
||||||
|
|
||||||
#define NUM_MENU_CMDS 40
|
|
||||||
|
|
||||||
#define RDF_SITEMAP 1
|
|
||||||
#define RDF_RELATED_LINKS 2
|
|
||||||
#define FROM_PAGE 1
|
|
||||||
#define GUESS_FROM_PREVIOUS_PAGE 2
|
|
||||||
|
|
||||||
#define HTDEL remoteStoreRemove
|
|
||||||
|
|
||||||
#ifndef HT_RAPTOR
|
|
||||||
/* external string references in allxpstr */
|
|
||||||
extern int RDF_HTML_STR, RDF_HTML_STR_1, RDF_HTML_STR_2, RDF_HTML_STR_3;
|
|
||||||
extern int RDF_HTML_STR_4, RDF_HTML_STR_5, RDF_HTML_STR_NUMBER;
|
|
||||||
extern int RDF_HTML_WINDATE, RDF_HTML_MACDATE, RDF_CMD_0, RDF_DATA_1, RDF_DATA_2;
|
|
||||||
extern int RDF_DELETEFILE, RDF_UNABLETODELETEFILE, RDF_DELETEFOLDER;
|
|
||||||
extern int RDF_UNABLETODELETEFOLDER, RDF_SITEMAPNAME;
|
|
||||||
extern int RDF_RELATEDLINKSNAME, RDF_DEFAULTCOLUMNNAME;
|
|
||||||
extern int RDF_NEWWORKSPACEPROMPT, RDF_DELETEWORKSPACE;
|
|
||||||
extern int RDF_ADDITIONS_ALLOWED, RDF_DELETION_ALLOWED;
|
|
||||||
extern int RDF_ICON_URL_LOCKED, RDF_NAME_LOCKED, RDF_COPY_ALLOWED;
|
|
||||||
extern int RDF_MOVE_ALLOWED, RDF_WORKSPACE_POS_LOCKED;
|
|
||||||
extern int RDF_MAIN_TITLE, RDF_COLOR_TITLE, RDF_HTML_INFOHEADER_STR;
|
|
||||||
extern int RDF_MISSION_CONTROL_TITLE, RDF_TREE_COLORS_TITLE, RDF_SELECTION_COLORS_TITLE;
|
|
||||||
extern int RDF_COLUMN_COLORS_TITLE, RDF_TITLEBAR_COLORS_TITLE, RDF_HTML_MAININFOHEADER_STR;
|
|
||||||
extern int RDF_HTML_EMPTYHEADER_STR, RDF_HTML_COLOR_STR, RDF_SETCOLOR_JS, RDF_DEFAULTCOLOR_JS;
|
|
||||||
extern int RDF_COLOR_LAYER, RDF_HTMLCOLOR_STR;
|
|
||||||
extern int RDF_SELECT_START, RDF_SELECT_END, RDF_SELECT_OPTION;
|
|
||||||
extern int RDF_FIND_STR1, RDF_FIND_STR2, RDF_FIND_INPUT_STR;
|
|
||||||
extern int RDF_LOCAL_LOCATION_STR, RDF_REMOTE_LOCATION_STR, RDF_ALL_LOCATION_STR;
|
|
||||||
extern int RDF_CONTAINS_STR, RDF_IS_STR, RDF_IS_NOT_STR, RDF_STARTS_WITH_STR, RDF_ENDS_WITH_STR;
|
|
||||||
extern int RDF_FIND_TITLE, RDF_FIND_FULLNAME_STR, RDF_SHORTCUT_CONFLICT_STR, RDF_FTP_NAME_STR;
|
|
||||||
|
|
||||||
#ifdef HT_PASSWORD_RTNS
|
|
||||||
extern int RDF_NEWPASSWORD, RDF_CONFIRMPASSWORD;
|
|
||||||
extern int RDF_MISMATCHPASSWORD, RDF_ENTERPASSWORD;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#define MISSION_CONTROL_RDF_PREF "browser.navcenter.admin"
|
|
||||||
#define NETSCAPE_RDF_FILENAME "netscape.rdf"
|
|
||||||
|
|
||||||
typedef struct _SBProviderStruct {
|
|
||||||
struct _SBProviderStruct *next;
|
|
||||||
char *url;
|
|
||||||
char *name;
|
|
||||||
PRBool containerp;
|
|
||||||
PRBool openp;
|
|
||||||
} SBProviderStruct;
|
|
||||||
typedef SBProviderStruct* SBProvider;
|
|
||||||
|
|
||||||
typedef struct _HT_PaneStruct {
|
|
||||||
struct _HT_PaneStruct *next;
|
|
||||||
void *pdata;
|
|
||||||
HT_Notification ns;
|
|
||||||
PLHashTable *hash;
|
|
||||||
HT_NotificationMask mask;
|
|
||||||
RDF db;
|
|
||||||
RDF_Notification rns;
|
|
||||||
struct _HT_ViewStruct *viewList;
|
|
||||||
struct _HT_ViewStruct *selectedView;
|
|
||||||
struct _HT_URLSiteMapAssoc *smp;
|
|
||||||
struct _HT_URLSiteMapAssoc *sbp;
|
|
||||||
uint32 viewListCount;
|
|
||||||
PRBool autoFlushFlag;
|
|
||||||
SBProvider smartBrowsingProviders;
|
|
||||||
PRBool dirty;
|
|
||||||
PRBool personaltoolbar;
|
|
||||||
PRBool toolbar;
|
|
||||||
PRBool bookmarkmenu;
|
|
||||||
PRBool special;
|
|
||||||
int windowType;
|
|
||||||
char *windowURL;
|
|
||||||
char *templateType;
|
|
||||||
struct _HT_PaneStruct *templatePane;
|
|
||||||
char *htdburl;
|
|
||||||
RDFT htdb;
|
|
||||||
} HT_PaneStruct;
|
|
||||||
|
|
||||||
typedef struct HT_ColumnStruct {
|
|
||||||
struct HT_ColumnStruct *next;
|
|
||||||
char *name;
|
|
||||||
uint32 width;
|
|
||||||
uint32 tokenType;
|
|
||||||
void *token;
|
|
||||||
void *feData;
|
|
||||||
PRBool isHiddenFlag;
|
|
||||||
} HT_ColumnStruct, *HT_Column;
|
|
||||||
|
|
||||||
typedef struct _HT_ViewStruct {
|
|
||||||
struct _HT_ViewStruct *next;
|
|
||||||
HT_Pane pane;
|
|
||||||
HT_Resource top;
|
|
||||||
void *pdata;
|
|
||||||
HT_Column columns;
|
|
||||||
uint32 workspacePos;
|
|
||||||
struct _HT_ResourceStruct ***itemList;
|
|
||||||
uint32 itemListSize;
|
|
||||||
uint32 itemListCount;
|
|
||||||
uint32 topNodeIndex;
|
|
||||||
uint32 selectedNodeHint;
|
|
||||||
uint32 sortTokenType;
|
|
||||||
void *sortToken;
|
|
||||||
PRBool descendingFlag;
|
|
||||||
PRBool refreshingItemListp;
|
|
||||||
PRBool inited;
|
|
||||||
RDF_Resource treeRel;
|
|
||||||
} HT_ViewStruct;
|
|
||||||
|
|
||||||
typedef struct _HT_ValueStruct {
|
|
||||||
struct _HT_ValueStruct *next;
|
|
||||||
uint32 tokenType;
|
|
||||||
RDF_Resource token;
|
|
||||||
void *data;
|
|
||||||
} HT_ValueStruct, *HT_Value;
|
|
||||||
|
|
||||||
#define HT_CONTAINER_FLAG 0x0001
|
|
||||||
#define HT_OPEN_FLAG 0x0002
|
|
||||||
#define HT_AUTOFLUSH_OPEN_FLAG 0x0004
|
|
||||||
#define HT_HIDDEN_FLAG 0x0008
|
|
||||||
#define HT_SELECTED_FLAG 0x0010
|
|
||||||
#define HT_VOLATILE_URL_FLAG 0x0020
|
|
||||||
#define HT_FREEICON_URL_FLAG 0x0040
|
|
||||||
#define HT_PASSWORDOK_FLAG 0x0080
|
|
||||||
#define HT_INITED_FLAG 0x0100
|
|
||||||
#define HT_DIRTY_FLAG 0x0200
|
|
||||||
#define HT_ENABLED_FLAG 0x0400
|
|
||||||
|
|
||||||
typedef struct _HT_ResourceStruct {
|
|
||||||
struct _HT_ResourceStruct *nextItem;
|
|
||||||
HT_View view;
|
|
||||||
HT_Resource parent;
|
|
||||||
RDF_Resource node;
|
|
||||||
void *feData;
|
|
||||||
char *dataSource;
|
|
||||||
char *url[5];
|
|
||||||
HT_Value values;
|
|
||||||
HT_Resource child;
|
|
||||||
HT_Resource *children; /* used by sorting */
|
|
||||||
uint32 unsortedIndex; /* used by sorting */
|
|
||||||
uint32 itemListIndex;
|
|
||||||
uint32 numChildren, numChildrenTotal;
|
|
||||||
uint16 flags;
|
|
||||||
uint16 depth;
|
|
||||||
HT_Resource next;
|
|
||||||
/* a pane or view might have multiple occurances of a RDF_Resource.
|
|
||||||
The hash table just points to the first of them. This allows us to
|
|
||||||
make a linked list of it */
|
|
||||||
} HT_ResourceStruct;
|
|
||||||
|
|
||||||
typedef struct _HT_MenuCommandStruct {
|
|
||||||
struct _HT_MenuCommandStruct *next;
|
|
||||||
HT_MenuCmd menuCmd;
|
|
||||||
char *name;
|
|
||||||
RDF_Resource graphCommand;
|
|
||||||
} _HT_MenuCommandStruct, *HT_MenuCommand;
|
|
||||||
|
|
||||||
typedef struct _HT_CursorStruct {
|
|
||||||
HT_Resource container;
|
|
||||||
HT_Resource node;
|
|
||||||
RDF_Cursor cursor;
|
|
||||||
uint32 numElements;
|
|
||||||
HT_Column columns;
|
|
||||||
uint16 contextMenuIndex;
|
|
||||||
PRBool foundValidMenuItem;
|
|
||||||
PRBool isWorkspaceFlag;
|
|
||||||
PRBool isBackgroundFlag;
|
|
||||||
PRBool commandExtensions;
|
|
||||||
PRBool commandListBuild;
|
|
||||||
HT_MenuCmd menuCmd;
|
|
||||||
HT_MenuCommand menuCommandList;
|
|
||||||
} HT_CursorStruct;
|
|
||||||
|
|
||||||
typedef struct _HT_Icon {
|
|
||||||
struct _HT_Icon *next;
|
|
||||||
char *name;
|
|
||||||
} _HT_Icon, *HT_Icon;
|
|
||||||
|
|
||||||
typedef struct _htmlElement {
|
|
||||||
struct _htmlElement *next;
|
|
||||||
HT_Resource node;
|
|
||||||
RDF_Resource token;
|
|
||||||
uint32 tokenType;
|
|
||||||
} _htmlElement, *_htmlElementPtr;
|
|
||||||
|
|
||||||
typedef struct _HT_URLSiteMapAssoc {
|
|
||||||
uint8 siteToolType;
|
|
||||||
uint8 origin;
|
|
||||||
uint8 onDisplayp;
|
|
||||||
char *url;
|
|
||||||
RDF_Resource sitemap;
|
|
||||||
char* name;
|
|
||||||
char* sitemapUrl;
|
|
||||||
RDFT db;
|
|
||||||
struct _HT_URLSiteMapAssoc *next;
|
|
||||||
} HT_URLSiteMapAssoc;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* HT function prototypes */
|
|
||||||
|
|
||||||
NSPR_BEGIN_EXTERN_C
|
|
||||||
|
|
||||||
void HT_Startup();
|
|
||||||
void HT_Shutdown();
|
|
||||||
void htLoadComplete(char *url, int status);
|
|
||||||
void htTimerRoutine(void *timerID);
|
|
||||||
PRBool possiblyUpdateView(HT_View view);
|
|
||||||
void updateViewItem(HT_Resource node);
|
|
||||||
HT_Resource newHTEntry (HT_View view, RDF_Resource node);
|
|
||||||
void addWorkspace(HT_Pane pane, RDF_Resource r, void *feData);
|
|
||||||
void deleteWorkspace(HT_Pane pane, RDF_Resource r);
|
|
||||||
void htrdfNotifFunc (RDF_Event ns, void* pdata);
|
|
||||||
void bmkNotifFunc (RDF_Event ns, void* pdata);
|
|
||||||
void refreshItemListInt (HT_View view, HT_Resource node);
|
|
||||||
PRBool relatedLinksContainerp (HT_Resource node);
|
|
||||||
int nodeCompareRtn(HT_Resource *node1, HT_Resource *node2);
|
|
||||||
void sortNodes(HT_View view, HT_Resource parent, HT_Resource *children, uint32 numChildren);
|
|
||||||
uint32 refreshItemList1(HT_View view, HT_Resource node);
|
|
||||||
void refreshItemList (HT_Resource node, HT_Event whatHappened);
|
|
||||||
void refreshPanes();
|
|
||||||
PRBool initToolbars (HT_Pane pane);
|
|
||||||
HT_Pane paneFromResource(RDF db, RDF_Resource resource, HT_Notification notify, PRBool autoFlushFlag, PRBool autoOpenFlag, PRBool useColumns);
|
|
||||||
void htSetBookmarkAddDateToNow(RDF_Resource r);
|
|
||||||
RDF newHTPaneDB();
|
|
||||||
RDF HTRDF_GetDB();
|
|
||||||
PRBool initViews (HT_Pane pane);
|
|
||||||
void htNewWorkspace(HT_Pane pane, char *id, char *optionalTitle, uint32 workspacePos);
|
|
||||||
HT_PaneStruct * HT_GetHTPaneList ();
|
|
||||||
HT_PaneStruct * HT_GetNextHTPane (HT_PaneStruct* pane);
|
|
||||||
void htSetWorkspaceOrder(RDF_Resource src, RDF_Resource dest, PRBool afterDestFlag);
|
|
||||||
HT_View HT_NewView (RDF_Resource topNode, HT_Pane pane, PRBool useColumns, void *feData, PRBool autoOpen);
|
|
||||||
void sendNotification (HT_Resource node, HT_Event whatHappened, RDF_Resource s, HT_ColumnType type);
|
|
||||||
void deleteHTNode(HT_Resource node);
|
|
||||||
void destroyViewInt (HT_Resource r, PRBool saveOpenState);
|
|
||||||
void htDeletePane(HT_Pane pane, PRBool saveWorkspaceOrder);
|
|
||||||
void saveWorkspaceOrder(HT_Pane pane);
|
|
||||||
void resynchItem (HT_Resource node, void *token, void *data, PRBool assertAction);
|
|
||||||
void resynchContainer (HT_Resource container);
|
|
||||||
HT_Resource addContainerItem (HT_Resource container, RDF_Resource item);
|
|
||||||
void refreshContainerIndexes(HT_Resource container);
|
|
||||||
void removeHTFromHash (HT_Pane pane, HT_Resource item);
|
|
||||||
void deleteHTSubtree (HT_Resource subtree);
|
|
||||||
void deleteContainerItem (HT_Resource container, RDF_Resource item);
|
|
||||||
uint32 fillContainer (HT_Resource node);
|
|
||||||
void sendColumnNotification (HT_View view, void *token, uint32 tokenType, HT_Event whatHappened);
|
|
||||||
PRBool htIsMenuCmdEnabled(HT_Pane pane, HT_MenuCmd menuCmd, PRBool isWorkspaceFlag, PRBool isBackgroundFlag);
|
|
||||||
void freeMenuCommandList();
|
|
||||||
void exportCallbackWrite(PRFileDesc *fp, char *str);
|
|
||||||
void exportCallback(MWContext *context, char *filename, RDF_Resource node);
|
|
||||||
void htEmptyClipboard(RDF_Resource parent);
|
|
||||||
void htCopyReference(RDF_Resource original, RDF_Resource newParent, PRBool empty);
|
|
||||||
PRBool htVerifyUniqueToken(HT_Resource node, void *token, uint32 tokenType, char *data);
|
|
||||||
PRBool ht_isURLReal(HT_Resource node);
|
|
||||||
char * buildInternalIconURL(HT_Resource node, PRBool *volatileURLFlag, PRBool largeIconFlag, PRBool workspaceFlag);
|
|
||||||
char * getIconURL( HT_Resource node, PRBool toolbarFlag, PRBool workspaceFlag, int state);
|
|
||||||
PRBool htIsPropertyInMoreOptions(RDF_Resource r);
|
|
||||||
void addHtmlElement(HT_Resource node, RDF_Resource token, uint32 tokenType);
|
|
||||||
void freeHtmlElementList();
|
|
||||||
_htmlElementPtr findHtmlElement(void *token);
|
|
||||||
void freeHtmlElement(void *token);
|
|
||||||
char * constructHTMLTagData(char *dynStr, int strID, char *data);
|
|
||||||
char * constructHTML(char *dynStr, HT_Resource node, void *token, uint32 tokenType);
|
|
||||||
char * constructHTMLPermission(char *dynStr, HT_Resource node, RDF_Resource token, char *permText);
|
|
||||||
PRBool htIsOpLocked(HT_Resource node, RDF_Resource token);
|
|
||||||
char * constructBasicHTML(char *dynStr, int strID, char *data1, char *data2);
|
|
||||||
void setHiddenState (HT_Resource node);
|
|
||||||
void htSetFindResourceName(RDF db, RDF_Resource r);
|
|
||||||
void htOpenTo(HT_View view, RDF_Resource u, PRBool selectView);
|
|
||||||
PRBool mutableContainerp (RDF_Resource node);
|
|
||||||
char * possiblyCleanUpTitle (char* title);
|
|
||||||
PRBool htRemoveChild(HT_Resource parent, HT_Resource child, PRBool moveToTrash);
|
|
||||||
void ht_SetPassword(HT_Resource node, char *password);
|
|
||||||
PRBool ht_hasPassword(HT_Resource node);
|
|
||||||
PRBool ht_checkPassword(HT_Resource node, PRBool alwaysCheck);
|
|
||||||
HT_DropAction htLaunchSmartNode(HT_Resource dropTarget, char *fullURL);
|
|
||||||
HT_DropAction dropOnSmartNode(HT_Resource dropTarget, HT_Resource dropObject, PRBool justAction);
|
|
||||||
HT_DropAction dropOnSmartURL(HT_Resource dropTarget, char *objTitle, PRBool justAction);
|
|
||||||
HT_DropAction dropOn (HT_Resource dropTarget, HT_Resource dropObject, PRBool justAction);
|
|
||||||
void Win32FileCopyMove(HT_Resource dropTarget, HT_Resource dropObject);
|
|
||||||
HT_DropAction copyMoveRDFLink (HT_Resource dropTarget, HT_Resource dropObject);
|
|
||||||
HT_DropAction copyMoveRDFLinkAtPos (HT_Resource dropx, HT_Resource dropObject, PRBool before);
|
|
||||||
HT_DropAction uploadLFS (HT_Resource dropTarget, HT_Resource dropObject);
|
|
||||||
HT_DropAction uploadRDFFile (HT_Resource dropTarget, HT_Resource dropObject);
|
|
||||||
HT_DropAction esfsCopyMoveContent (HT_Resource dropTarget, HT_Resource dropObject);
|
|
||||||
RDF_BT urlResourceType (char* url);
|
|
||||||
HT_DropAction dropURLOn (HT_Resource dropTarget, char* objURL, char *objTitle, PRBool justAction);
|
|
||||||
void replacePipeWithColon(char* url);
|
|
||||||
HT_DropAction copyRDFLinkURL (HT_Resource dropTarget, char* objURL, char *objTitle);
|
|
||||||
HT_DropAction copyRDFLinkURLAt (HT_Resource dropx, char* objURL, char *objTitle, PRBool before);
|
|
||||||
HT_DropAction uploadLFSURL (HT_Resource dropTarget, char* objURL);
|
|
||||||
HT_DropAction uploadRDFFileURL (HT_Resource dropTarget, char* objURL);
|
|
||||||
HT_DropAction esfsCopyMoveContentURL (HT_Resource dropTarget, char* objURL);
|
|
||||||
RDFT HTADD(HT_Pane pane, RDF_Resource u, RDF_Resource s, void* v);
|
|
||||||
HT_URLSiteMapAssoc * makeNewSMP (HT_Pane htPane, char* pUrl, char* sitemapurl);
|
|
||||||
void RetainOldSitemaps (HT_Pane htPane, char *pUrl);
|
|
||||||
void populateSBProviders (HT_Pane htPane);
|
|
||||||
SBProvider SBProviderOfNode (HT_Resource node);
|
|
||||||
PRBool implicitDomainURL (char* url);
|
|
||||||
PRBool domainMatches (char *dom, char *url);
|
|
||||||
void nextDomain (char* dom, size_t *n);
|
|
||||||
PRBool relatedLinksEnabledURL (char* url);
|
|
||||||
void cleanupInt (HT_Pane htPane, HT_URLSiteMapAssoc *nsmp, RDF_Resource parent);
|
|
||||||
HT_Pane newTemplatePane(char* templateName);
|
|
||||||
void PaneDeleteSBPCleanup (HT_Pane htPane);
|
|
||||||
|
|
||||||
#ifndef HT_RAPTOR
|
|
||||||
PRBool rdfFindDialogHandler(XPDialogState *dlgstate, char **argv, int argc, unsigned int button);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
NSPR_END_EXTERN_C
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
563
rdf/src/mail.c
563
rdf/src/mail.c
|
@ -1,563 +0,0 @@
|
||||||
/* -*- 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 file implements mail support for the rdf data model.
|
|
||||||
For more information on this file, contact rjc or guha
|
|
||||||
For more information on RDF, look at the RDF section of www.mozilla.org
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef SMART_MAIL
|
|
||||||
#include "pm2rdf.h"
|
|
||||||
|
|
||||||
extern char *profileDirURL;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
Pop_GetUrlExitFunc (URL_Struct *urls, int status, MWContext *cx)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
GetPopToRDF (RDFT rdf)
|
|
||||||
{
|
|
||||||
MF folder = (MF) rdf->pdata;
|
|
||||||
if (endsWith("/inbox", rdf->url)) {
|
|
||||||
char* popurl = getMem(100);
|
|
||||||
int n = 10;
|
|
||||||
int l = strlen(rdf->url);
|
|
||||||
URL_Struct *urls ;
|
|
||||||
memcpy(popurl, "pop3://", 7);
|
|
||||||
while (n < l) {
|
|
||||||
if (rdf->url[n] == '/') break;
|
|
||||||
popurl[n-3] = rdf->url[n];
|
|
||||||
n++;
|
|
||||||
}
|
|
||||||
|
|
||||||
urls = NET_CreateURLStruct(popurl, NET_DONT_RELOAD);
|
|
||||||
if (urls != NULL) {
|
|
||||||
urls->fe_data = rdf;
|
|
||||||
|
|
||||||
NET_GetURL(urls, FO_PRESENT, gRDFMWContext(rdf), Pop_GetUrlExitFunc);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
PopGetNewMail (RDF_Resource r)
|
|
||||||
{
|
|
||||||
if (containerp(r) && (resourceType(r) == PM_RT)) {
|
|
||||||
MF folder = (MF) r->pdata;
|
|
||||||
GetPopToRDF(folder->rdf);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
char *
|
|
||||||
stripCopy (char* str)
|
|
||||||
{
|
|
||||||
return copyString(XP_StripLine(str));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
PRBool
|
|
||||||
msgDeletedp (MM msg)
|
|
||||||
{
|
|
||||||
return (msg && (msg->flags) && (msg->flags[4] == '8'));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
FILE *
|
|
||||||
openPMFile (char* path)
|
|
||||||
{
|
|
||||||
FILE* ans = fopen(path, "r+");
|
|
||||||
if (!ans) {
|
|
||||||
ans = fopen(path, "w");
|
|
||||||
if (ans) fclose(ans);
|
|
||||||
ans = fopen(path, "r+");
|
|
||||||
}
|
|
||||||
return ans;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
addMsgToFolder (MF folder, MM msg)
|
|
||||||
{
|
|
||||||
if (!folder->tail) {
|
|
||||||
folder->msg = folder->tail = msg;
|
|
||||||
} else {
|
|
||||||
folder->tail->next = msg;
|
|
||||||
folder->tail = msg;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
RDF_StartMessageDelivery (RDFT rdf)
|
|
||||||
{
|
|
||||||
MF folder = (MF) rdf->pdata;
|
|
||||||
MM msg = (MM) getMem(sizeof(struct MailMessage));
|
|
||||||
char* nurl = getMem(100);
|
|
||||||
fseek(folder->mfile, 0L, SEEK_END);
|
|
||||||
fprintf(folder->mfile, "From - \n");
|
|
||||||
msg->offset = ftell(folder->mfile);
|
|
||||||
sprintf(nurl, "%s?%i", rdf->url, msg->offset);
|
|
||||||
msg->r = RDF_GetResource(NULL, nurl, 1);
|
|
||||||
msg->r->pdata = msg;
|
|
||||||
msg->flags = getMem(4);
|
|
||||||
folder->add = msg;
|
|
||||||
setResourceType(msg->r, PM_RT);
|
|
||||||
fseek(folder->mfile, 0L, SEEK_END);
|
|
||||||
fputs("X-Mozilla-Status: 0000\n", folder->mfile);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
char *
|
|
||||||
MIW1 (const char* block, int32 len)
|
|
||||||
{
|
|
||||||
char* blk = XP_ALLOC(len +1);
|
|
||||||
int32 n = 0;
|
|
||||||
int32 m = 0;
|
|
||||||
PRBool seenp = 0;
|
|
||||||
PRBool wsendp = 0;
|
|
||||||
memset(blk, '\0', len);
|
|
||||||
while (n++ < len) {
|
|
||||||
char c = block[n];
|
|
||||||
if ((c == '\r') || (c == '\n')) break;
|
|
||||||
if (!seenp) {
|
|
||||||
seenp = (c == ':');
|
|
||||||
} else {
|
|
||||||
if (c != ' ') wsendp = 1;
|
|
||||||
if (wsendp) {
|
|
||||||
blk[m++] = c;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return blk;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
RDF_AddMessageLine (RDFT rdf, char* block, int32 length)
|
|
||||||
{
|
|
||||||
MF folder = (MF) rdf->pdata;
|
|
||||||
MM msg = folder->add;
|
|
||||||
char* temp = getMem(length+1);
|
|
||||||
memcpy(temp, block, length);
|
|
||||||
if (!msg->from && (startsWith("From:", block))) {
|
|
||||||
msg->from = MIW1(block, length);
|
|
||||||
} else if (!msg->subject && (startsWith("Subject:", block))) {
|
|
||||||
msg->subject = MIW1(block, length);
|
|
||||||
} else if (!msg->date && (startsWith("Date:", block))) {
|
|
||||||
msg->date = MIW1(block, length);
|
|
||||||
}
|
|
||||||
fseek(folder->mfile, 0L, SEEK_END);
|
|
||||||
fputs(temp, folder->mfile);
|
|
||||||
freeMem(temp);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#define TON(s) ((s == NULL) ? "" : s)
|
|
||||||
void writeMsgSum (MF folder, MM msg) {
|
|
||||||
if (!msg->flags) msg->flags = copyString("0000");
|
|
||||||
if (msg->summOffset == -1) {
|
|
||||||
fseek(folder->sfile, 0L, SEEK_END);
|
|
||||||
msg->summOffset = ftell(folder->sfile);
|
|
||||||
} else {
|
|
||||||
fseek(folder->sfile, msg->summOffset, SEEK_SET);
|
|
||||||
}
|
|
||||||
fprintf(folder->sfile, "Status: %s\nSOffset: %d\nFrom: %s\nSubject: %s\nDate: %s\nMOffset: %d\n",
|
|
||||||
msg->flags, ftell(folder->sfile),
|
|
||||||
TON(msg->from), TON(msg->subject), TON(msg->date), msg->offset );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
RDF_FinishMessageDelivery (RDFT rdf)
|
|
||||||
{
|
|
||||||
MF folder = (MF) rdf->pdata;
|
|
||||||
MM msg = folder->add;
|
|
||||||
folder->add = NULL;
|
|
||||||
addMsgToFolder(folder, msg);
|
|
||||||
setResourceType(msg->r, PM_RT);
|
|
||||||
fseek(folder->sfile, 0L, SEEK_END);
|
|
||||||
msg->summOffset = ftell(folder->sfile);
|
|
||||||
writeMsgSum(folder, msg);
|
|
||||||
fseek(folder->mfile, 0L, SEEK_END);
|
|
||||||
fputs("\n", folder->mfile);
|
|
||||||
sendNotifications2(rdf, RDF_ASSERT_NOTIFY, msg->r, gCoreVocab->RDF_parent, folder->top,
|
|
||||||
RDF_RESOURCE_TYPE, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
setMessageFlag (RDFT rdf, RDF_Resource r, char* newFlag)
|
|
||||||
{
|
|
||||||
MF folder = (MF) rdf->pdata;
|
|
||||||
MM msg = (MM)r->pdata;
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
#define BUFF_SIZE 50000
|
|
||||||
|
|
||||||
|
|
||||||
RDFT
|
|
||||||
getBFTranslator (char* url) {
|
|
||||||
if (startsWith("mailbox://folder/", url)) {
|
|
||||||
char* temp = getMem(strlen(url));
|
|
||||||
RDFT ans = NULL;
|
|
||||||
sprintf(temp, "mailbox://%s", &url[17]);
|
|
||||||
ans = getTranslator(temp);
|
|
||||||
freeMem(temp);
|
|
||||||
return ans;
|
|
||||||
} else return getTranslator(url);
|
|
||||||
}
|
|
||||||
|
|
||||||
PRBool
|
|
||||||
MoveMessage (char* to, char* from, MM message) {
|
|
||||||
RDFT todb = getBFTranslator(to);
|
|
||||||
RDFT fromdb = getBFTranslator(from);
|
|
||||||
MF tom = todb->pdata;
|
|
||||||
MF fom = fromdb->pdata;
|
|
||||||
RDF_Resource r;
|
|
||||||
MM newMsg = (MM)getMem(sizeof(struct MailMessage));
|
|
||||||
char* buffer = getMem(BUFF_SIZE);
|
|
||||||
if (!buffer) return 0;
|
|
||||||
setMessageFlag(fromdb, message->r, "0008");
|
|
||||||
fseek(tom->mfile, 0L, SEEK_END);
|
|
||||||
fseek(fom->mfile, message->offset, SEEK_SET);
|
|
||||||
fputs("From -\n", 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);
|
|
||||||
newMsg->date = copyString(message->date);
|
|
||||||
newMsg->r = r;
|
|
||||||
r->pdata = newMsg;
|
|
||||||
setResourceType(r, PM_RT);
|
|
||||||
newMsg->summOffset = -1;
|
|
||||||
newMsg->offset = ftell(tom->mfile);
|
|
||||||
writeMsgSum(tom, newMsg);
|
|
||||||
addMsgToFolder (tom, newMsg) ;
|
|
||||||
fflush(tom->sfile);
|
|
||||||
while (fgets(buffer, BUFF_SIZE, fom->mfile) && strncmp("From ", buffer, 5)) {
|
|
||||||
fputs(buffer, tom->mfile);
|
|
||||||
}
|
|
||||||
sendNotifications2(todb, RDF_ASSERT_NOTIFY, r, gCoreVocab->RDF_parent, tom->top,
|
|
||||||
RDF_RESOURCE_TYPE, 1);
|
|
||||||
sendNotifications2(fromdb, RDF_DELETE_NOTIFY, message->r, gCoreVocab->RDF_parent, fom->top,
|
|
||||||
RDF_RESOURCE_TYPE, 1);
|
|
||||||
freeMem(buffer);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
readSummaryFile (RDFT rdf)
|
|
||||||
{
|
|
||||||
if (startsWith("mailbox://", rdf->url)) {
|
|
||||||
char* url = rdf->url;
|
|
||||||
char* folderURL = &url[10];
|
|
||||||
int32 flen = strlen(profileDirURL) + strlen(folderURL) + 4;
|
|
||||||
char* fileurl = getMem(flen);
|
|
||||||
char* nurl = getMem(strlen(url) + 20);
|
|
||||||
FILE *f;
|
|
||||||
char* buff = getMem(BUFF_SIZE);
|
|
||||||
MF folder = (MF) getMem(sizeof(struct MailFolder));
|
|
||||||
MM msg = NULL;
|
|
||||||
FILE *mf;
|
|
||||||
char* aclen;
|
|
||||||
|
|
||||||
rdf->pdata = folder;
|
|
||||||
sprintf(fileurl, "%s%s.ssf", profileDirURL, folderURL);
|
|
||||||
fileurl = MCDepFileURL(fileurl);
|
|
||||||
f = openPMFile(fileurl);
|
|
||||||
sprintf(fileurl, "%s%s", profileDirURL, folderURL);
|
|
||||||
fileurl = MCDepFileURL(fileurl);
|
|
||||||
mf = openPMFile(fileurl);
|
|
||||||
folder->top = RDF_GetResource(NULL, rdf->url, 1);
|
|
||||||
setResourceType(folder->top, PM_RT);
|
|
||||||
setContainerp(folder->top, 1);
|
|
||||||
folder->top->pdata = folder;
|
|
||||||
folder->rdf = rdf;
|
|
||||||
folder->sfile = f;
|
|
||||||
folder->mfile = mf;
|
|
||||||
|
|
||||||
while (f && fgets(buff, BUFF_SIZE, f)) {
|
|
||||||
if (startsWith("Status:", buff)) {
|
|
||||||
msg = (MM) getMem(sizeof(struct MailMessage));
|
|
||||||
msg->flags = stripCopy(&buff[8]);
|
|
||||||
fgets(buff, BUFF_SIZE, f);
|
|
||||||
sscanf(&buff[9], "%d", &msg->summOffset);
|
|
||||||
fgets(buff, BUFF_SIZE, f);
|
|
||||||
msg->from = stripCopy(&buff[6]);
|
|
||||||
fgets(buff, BUFF_SIZE, f);
|
|
||||||
msg->subject = stripCopy(&buff[8]);
|
|
||||||
fgets(buff, BUFF_SIZE, f);
|
|
||||||
msg->date = stripCopy(&buff[6]);
|
|
||||||
fgets(buff, BUFF_SIZE, f);
|
|
||||||
sscanf(&buff[9], "%d", &msg->offset);
|
|
||||||
sprintf(nurl, "%s?%d", url, msg->offset);
|
|
||||||
msg->r = RDF_GetResource(NULL, nurl, 1);
|
|
||||||
msg->r->pdata = msg;
|
|
||||||
addMsgToFolder (folder, msg) ;
|
|
||||||
setResourceType(msg->r, PM_RT);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (msg == NULL) {
|
|
||||||
/* either a new mailbox or need to read BMF to recreate */
|
|
||||||
while (mf && fgets(buff, BUFF_SIZE, mf)) {
|
|
||||||
if (strncmp("From ", buff, 5) ==0) {
|
|
||||||
if (msg) writeMsgSum(folder, msg);
|
|
||||||
msg = (MM) getMem(sizeof(struct MailMessage));
|
|
||||||
msg->offset = ftell(mf);
|
|
||||||
msg->summOffset = -1;
|
|
||||||
sprintf(nurl, "%s?%i", url, msg->offset);
|
|
||||||
msg->r = RDF_GetResource(NULL, nurl, 1);
|
|
||||||
msg->r->pdata = msg;
|
|
||||||
setResourceType(msg->r, PM_RT);
|
|
||||||
addMsgToFolder (folder, msg) ;
|
|
||||||
}
|
|
||||||
if ((!msg->from) && (startsWith("From:", buff))) {
|
|
||||||
msg->from = stripCopy(&buff[6]);
|
|
||||||
} else if ((!msg->date) && (startsWith("Date:", buff))) {
|
|
||||||
msg->date = stripCopy(&buff[6]);
|
|
||||||
} else if ((!msg->subject) && (startsWith("Subject:", buff))) {
|
|
||||||
msg->subject = stripCopy(&buff[8]);
|
|
||||||
} else if ((!msg->flags) && (startsWith("X-Mozilla-Status:", buff))) {
|
|
||||||
msg->flags = stripCopy(&buff[17]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (msg) writeMsgSum(folder, msg);
|
|
||||||
if (folder->sfile) fflush(folder->sfile);
|
|
||||||
}
|
|
||||||
memset(fileurl, '\0', flen);
|
|
||||||
memcpy(fileurl, rdf->url, strlen(rdf->url));
|
|
||||||
aclen = strchr(&fileurl[10], '/');
|
|
||||||
fileurl[aclen-fileurl] = '\0';
|
|
||||||
strcat(fileurl, "/trash");
|
|
||||||
folder->trash = fileurl;
|
|
||||||
freeMem(buff);
|
|
||||||
freeMem(nurl);
|
|
||||||
/* GetPopToRDF(rdf); */
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void *
|
|
||||||
pmGetSlotValue (RDFT rdf, RDF_Resource u, RDF_Resource s, RDF_ValueType type,
|
|
||||||
PRBool inversep, PRBool tv)
|
|
||||||
{
|
|
||||||
if ((resourceType(u) == PM_RT) && tv && (!inversep) && (type == RDF_STRING_TYPE) && (u->pdata)) {
|
|
||||||
MM msg = (MM) u->pdata;
|
|
||||||
if (s == gNavCenter->from) {
|
|
||||||
XP_ASSERT( (RDF_STRING_TYPE != type) || ( IsUTF8String((const char* )msg->from)));
|
|
||||||
return copyString(msg->from);
|
|
||||||
} else if (s == gNavCenter->subject) {
|
|
||||||
XP_ASSERT( (RDF_STRING_TYPE != type) || ( IsUTF8String((const char* )msg->subject)));
|
|
||||||
return copyString(msg->subject);
|
|
||||||
} else if (s == gNavCenter->date) {
|
|
||||||
return copyString(msg->date);
|
|
||||||
} else return NULL;
|
|
||||||
} else return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
RDF_Cursor
|
|
||||||
pmGetSlotValues (RDFT rdf, RDF_Resource u, RDF_Resource s, RDF_ValueType type,
|
|
||||||
PRBool inversep, PRBool tv)
|
|
||||||
{
|
|
||||||
if ((resourceType(u) == PM_RT) && tv && (inversep) && (type == RDF_RESOURCE_TYPE)
|
|
||||||
&& (s == gCoreVocab->RDF_parent)) {
|
|
||||||
MF folder = (MF)rdf->pdata;
|
|
||||||
if (folder->top == u) {
|
|
||||||
RDF_Cursor c = (RDF_Cursor)getMem(sizeof(struct RDF_CursorStruct));
|
|
||||||
c->u = u;
|
|
||||||
c->s = s;
|
|
||||||
c->type = type;
|
|
||||||
c->inversep = inversep;
|
|
||||||
c->tv = tv;
|
|
||||||
c->count = 0;
|
|
||||||
c->pdata = folder->msg;
|
|
||||||
return c;
|
|
||||||
} else return NULL;
|
|
||||||
} else return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void *
|
|
||||||
pmNextValue (RDFT rdf, RDF_Cursor c)
|
|
||||||
{
|
|
||||||
MM msg = (MM) c->pdata;
|
|
||||||
RDF_Resource ans = NULL;
|
|
||||||
while (msg && msgDeletedp(msg)) {
|
|
||||||
msg = msg->next;
|
|
||||||
}
|
|
||||||
if (msg) {
|
|
||||||
ans = msg->r;
|
|
||||||
c->pdata = msg->next;
|
|
||||||
}
|
|
||||||
return ans;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
RDF_Error
|
|
||||||
pmDisposeCursor (RDFT mcf, RDF_Cursor c)
|
|
||||||
{
|
|
||||||
freeMem(c);
|
|
||||||
return noRDFErr;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
FILE *
|
|
||||||
getPopMBox (RDFT db)
|
|
||||||
{
|
|
||||||
MF folder = (MF)db->pdata;
|
|
||||||
return folder->mfile;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
PRBool
|
|
||||||
pmHasAssertion (RDFT mcf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type, PRBool tv)
|
|
||||||
{
|
|
||||||
/*this is clearly wrong, but doesn't break anything now ...*/
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
PRBool
|
|
||||||
pmRemove (RDFT rdf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type)
|
|
||||||
{
|
|
||||||
XP_ASSERT( (RDF_STRING_TYPE != type) || ( IsUTF8String((const char* )v)));
|
|
||||||
if ((startsWith("mailbox://", rdf->url)) && (resourceType(u) == PM_RT) && (s == gCoreVocab->RDF_parent)
|
|
||||||
&& (type == RDF_RESOURCE_TYPE)) {
|
|
||||||
RDF_Resource mbox = (RDF_Resource) v;
|
|
||||||
if (!(containerp(mbox) && (resourceType(mbox) == PM_RT))) {
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
MF folder = (MF)mbox->pdata;
|
|
||||||
sendNotifications2(rdf, RDF_DELETE_NOTIFY, u, s, v, type, 1);
|
|
||||||
MoveMessage(folder->trash, resourceID(mbox), (MM)u->pdata);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
} else return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
RDFT
|
|
||||||
MakePopDB (char* url)
|
|
||||||
{
|
|
||||||
if (startsWith("mailbox://", url)) {
|
|
||||||
RDFT ntr;
|
|
||||||
if ((ntr = (RDFT)getMem(sizeof(struct RDF_TranslatorStruct))) != NULL) {
|
|
||||||
char* fileurl = getMem(100);
|
|
||||||
PRDir* dir ;
|
|
||||||
char* aclen;
|
|
||||||
sprintf(fileurl, "%s%s", profileDirURL, &url[10]);
|
|
||||||
aclen = strchr(&fileurl[strlen(profileDirURL)+1], '/');
|
|
||||||
fileurl[aclen-fileurl] = '\0';
|
|
||||||
dir = OpenDir(fileurl);
|
|
||||||
if (dir == NULL) {
|
|
||||||
if ( CallPRMkDirUsingFileURL(fileurl, 00700) > -1) dir = OpenDir(fileurl);
|
|
||||||
}
|
|
||||||
freeMem(fileurl);
|
|
||||||
if (dir) {
|
|
||||||
PR_CloseDir(dir);
|
|
||||||
ntr->assert = NULL;
|
|
||||||
ntr->unassert = pmRemove;
|
|
||||||
ntr->getSlotValue = pmGetSlotValue;
|
|
||||||
ntr->getSlotValues = pmGetSlotValues;
|
|
||||||
ntr->hasAssertion = pmHasAssertion;
|
|
||||||
ntr->nextValue = pmNextValue;
|
|
||||||
ntr->disposeCursor = pmDisposeCursor;
|
|
||||||
ntr->url = copyString(url);
|
|
||||||
readSummaryFile(ntr);
|
|
||||||
return ntr;
|
|
||||||
} else {
|
|
||||||
freeMem(ntr);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else return NULL;
|
|
||||||
} else return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
RDFT
|
|
||||||
MakeMailAccountDB (char* url)
|
|
||||||
{
|
|
||||||
if (startsWith("mailaccount://", url)) {
|
|
||||||
RDFT ntr = NewRemoteStore(url);
|
|
||||||
char* fileurl = getMem(100);
|
|
||||||
int32 n = PR_SKIP_BOTH;
|
|
||||||
PRDirEntry *de;
|
|
||||||
PRDir* dir ;
|
|
||||||
RDF_Resource top = RDF_GetResource(NULL, url, 1);
|
|
||||||
sprintf(fileurl, "%s%s", profileDirURL, &url[14]);
|
|
||||||
dir = OpenDir(fileurl);
|
|
||||||
if (dir == NULL) {
|
|
||||||
if ( CallPRMkDirUsingFileURL(fileurl, 00700) > -1) dir = OpenDir(fileurl);
|
|
||||||
}
|
|
||||||
while ((dir != NULL) && ((de = PR_ReadDir(dir, (PRDirFlags)(n++))) != NULL)) {
|
|
||||||
if ((!endsWith(".ssf", de->name)) && (!endsWith(".dat", de->name)) &&
|
|
||||||
(!endsWith(".snm", de->name)) && (!endsWith("~", de->name))) {
|
|
||||||
RDF_Resource r;
|
|
||||||
sprintf(fileurl, "mailbox://folder/%s/%s", &url[14], de->name);
|
|
||||||
r = RDF_GetResource(NULL, fileurl, 1);
|
|
||||||
setResourceType(r, PMF_RT);
|
|
||||||
remoteStoreAdd(ntr, r, gCoreVocab->RDF_parent, top, RDF_RESOURCE_TYPE, 1);
|
|
||||||
remoteStoreAdd(ntr, r, gCoreVocab->RDF_name, copyString(de->name), RDF_STRING_TYPE, 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
freeMem(fileurl);
|
|
||||||
if (dir) PR_CloseDir(dir);
|
|
||||||
return ntr;
|
|
||||||
} else return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -1,183 +0,0 @@
|
||||||
/* -*- 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 "nsISupports.h"
|
|
||||||
#include "nsIFactory.h"
|
|
||||||
#include "nsIRDFResourceManager.h"
|
|
||||||
#include "nsRDFBuiltInDataSources.h"
|
|
||||||
#include "nsRDFDocument.h"
|
|
||||||
#include "nsRDFCID.h"
|
|
||||||
#include "nsIServiceManager.h"
|
|
||||||
|
|
||||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
|
||||||
static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID);
|
|
||||||
|
|
||||||
static NS_DEFINE_CID(kRDFBookmarkDataSourceCID, NS_RDFBOOKMARKDATASOURCE_CID);
|
|
||||||
static NS_DEFINE_CID(kRDFHTMLDocumentCID, NS_RDFHTMLDOCUMENT_CID);
|
|
||||||
static NS_DEFINE_CID(kRDFMemoryDataSourceCID, NS_RDFMEMORYDATASOURCE_CID);
|
|
||||||
static NS_DEFINE_CID(kRDFResourceManagerCID, NS_RDFRESOURCEMANAGER_CID);
|
|
||||||
static NS_DEFINE_CID(kRDFSimpleDataBaseCID, NS_RDFSIMPLEDATABASE_CID);
|
|
||||||
static NS_DEFINE_CID(kRDFStreamDataSourceCID, NS_RDFSTREAMDATASOURCE_CID);
|
|
||||||
static NS_DEFINE_CID(kRDFTreeDocumentCID, NS_RDFTREEDOCUMENT_CID);
|
|
||||||
|
|
||||||
class RDFFactoryImpl : public nsIFactory
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
RDFFactoryImpl(const nsCID &aClass);
|
|
||||||
|
|
||||||
// nsISupports methods
|
|
||||||
NS_DECL_ISUPPORTS
|
|
||||||
|
|
||||||
// nsIFactory methods
|
|
||||||
NS_IMETHOD CreateInstance(nsISupports *aOuter,
|
|
||||||
const nsIID &aIID,
|
|
||||||
void **aResult);
|
|
||||||
|
|
||||||
NS_IMETHOD LockFactory(PRBool aLock);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
virtual ~RDFFactoryImpl();
|
|
||||||
|
|
||||||
private:
|
|
||||||
nsCID mClassID;
|
|
||||||
};
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
RDFFactoryImpl::RDFFactoryImpl(const nsCID &aClass)
|
|
||||||
{
|
|
||||||
NS_INIT_REFCNT();
|
|
||||||
mClassID = aClass;
|
|
||||||
}
|
|
||||||
|
|
||||||
RDFFactoryImpl::~RDFFactoryImpl()
|
|
||||||
{
|
|
||||||
NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction");
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP
|
|
||||||
RDFFactoryImpl::QueryInterface(const nsIID &aIID,
|
|
||||||
void **aResult)
|
|
||||||
{
|
|
||||||
if (! aResult)
|
|
||||||
return NS_ERROR_NULL_POINTER;
|
|
||||||
|
|
||||||
// Always NULL result, in case of failure
|
|
||||||
*aResult = nsnull;
|
|
||||||
|
|
||||||
if (aIID.Equals(kISupportsIID)) {
|
|
||||||
*aResult = NS_STATIC_CAST(nsISupports*, this);
|
|
||||||
AddRef();
|
|
||||||
return NS_OK;
|
|
||||||
} else if (aIID.Equals(kIFactoryIID)) {
|
|
||||||
*aResult = NS_STATIC_CAST(nsIFactory*, this);
|
|
||||||
AddRef();
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
return NS_NOINTERFACE;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMPL_ADDREF(RDFFactoryImpl);
|
|
||||||
NS_IMPL_RELEASE(RDFFactoryImpl);
|
|
||||||
|
|
||||||
|
|
||||||
NS_IMETHODIMP
|
|
||||||
RDFFactoryImpl::CreateInstance(nsISupports *aOuter,
|
|
||||||
const nsIID &aIID,
|
|
||||||
void **aResult)
|
|
||||||
{
|
|
||||||
if (! aResult)
|
|
||||||
return NS_ERROR_NULL_POINTER;
|
|
||||||
|
|
||||||
if (aOuter)
|
|
||||||
return NS_ERROR_NO_AGGREGATION;
|
|
||||||
|
|
||||||
*aResult = nsnull;
|
|
||||||
|
|
||||||
nsresult rv;
|
|
||||||
PRBool wasRefCounted = PR_TRUE;
|
|
||||||
nsISupports *inst = nsnull;
|
|
||||||
if (mClassID.Equals(kRDFResourceManagerCID)) {
|
|
||||||
if (NS_FAILED(rv = NS_NewRDFResourceManager((nsIRDFResourceManager**) &inst)))
|
|
||||||
return rv;
|
|
||||||
}
|
|
||||||
else if (mClassID.Equals(kRDFMemoryDataSourceCID)) {
|
|
||||||
if (NS_FAILED(rv = NS_NewRDFMemoryDataSource((nsIRDFDataSource**) &inst)))
|
|
||||||
return rv;
|
|
||||||
}
|
|
||||||
else if (mClassID.Equals(kRDFStreamDataSourceCID)) {
|
|
||||||
if (NS_FAILED(rv = NS_NewRDFStreamDataSource((nsIRDFDataSource**) &inst)))
|
|
||||||
return rv;
|
|
||||||
}
|
|
||||||
else if (mClassID.Equals(kRDFBookmarkDataSourceCID)) {
|
|
||||||
if (NS_FAILED(rv = NS_NewRDFBookmarkDataSource((nsIRDFDataSource**) &inst)))
|
|
||||||
return rv;
|
|
||||||
}
|
|
||||||
else if (mClassID.Equals(kRDFSimpleDataBaseCID)) {
|
|
||||||
if (NS_FAILED(rv = NS_NewRDFSimpleDataBase((nsIRDFDataBase**) &inst)))
|
|
||||||
return rv;
|
|
||||||
}
|
|
||||||
else if (mClassID.Equals(kRDFHTMLDocumentCID)) {
|
|
||||||
if (NS_FAILED(rv = NS_NewRDFHTMLDocument((nsIRDFDocument**) &inst)))
|
|
||||||
return rv;
|
|
||||||
}
|
|
||||||
else if (mClassID.Equals(kRDFTreeDocumentCID)) {
|
|
||||||
if (NS_FAILED(rv = NS_NewRDFTreeDocument((nsIRDFDocument**) &inst)))
|
|
||||||
return rv;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return NS_ERROR_NO_INTERFACE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (! inst)
|
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
|
||||||
|
|
||||||
if (NS_FAILED(rv = inst->QueryInterface(aIID, aResult)))
|
|
||||||
// We didn't get the right interface, so clean up
|
|
||||||
delete inst;
|
|
||||||
|
|
||||||
if (wasRefCounted)
|
|
||||||
NS_IF_RELEASE(inst);
|
|
||||||
|
|
||||||
return rv;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsresult RDFFactoryImpl::LockFactory(PRBool aLock)
|
|
||||||
{
|
|
||||||
// Not implemented in simplest case.
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// return the proper factory to the caller
|
|
||||||
extern "C" PR_IMPLEMENT(nsresult)
|
|
||||||
NSGetFactory(const nsCID &aClass, nsISupports* servMgr, nsIFactory **aFactory)
|
|
||||||
{
|
|
||||||
if (! aFactory)
|
|
||||||
return NS_ERROR_NULL_POINTER;
|
|
||||||
|
|
||||||
*aFactory = new RDFFactoryImpl(aClass);
|
|
||||||
if (aFactory == nsnull)
|
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
|
||||||
|
|
||||||
return (*aFactory)->QueryInterface(kIFactoryIID, (void**)aFactory);
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,206 +0,0 @@
|
||||||
/* -*- 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 "License"); you may not use this file except in
|
|
||||||
* compliance with the License. You may obtain a copy of the License at
|
|
||||||
* http://www.mozilla.org/NPL/
|
|
||||||
*
|
|
||||||
* Software distributed under the License is distributed on an "AS IS"
|
|
||||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
|
|
||||||
* the License for the specific language governing rights and limitations
|
|
||||||
* under the License.
|
|
||||||
*
|
|
||||||
* The Original Code is Mozilla Communicator client code.
|
|
||||||
*
|
|
||||||
* The Initial Developer of the Original Code is Netscape Communications
|
|
||||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
|
||||||
* Netscape Communications Corporation. All Rights Reserved.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
This builds an HTML-like model, complete with text nodes, that can
|
|
||||||
be displayed in a vanilla HTML content viewer. You can apply CSS2
|
|
||||||
styles to the text, etc.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "nsIRDFContent.h"
|
|
||||||
#include "nsIRDFCursor.h"
|
|
||||||
#include "nsIRDFDataBase.h"
|
|
||||||
#include "nsIRDFNode.h"
|
|
||||||
#include "nsIRDFResourceManager.h"
|
|
||||||
#include "nsIServiceManager.h"
|
|
||||||
#include "nsINameSpaceManager.h"
|
|
||||||
#include "nsISupportsArray.h"
|
|
||||||
#include "nsRDFDocument.h"
|
|
||||||
#include "rdfutil.h"
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
static NS_DEFINE_IID(kIRDFResourceIID, NS_IRDFRESOURCE_IID);
|
|
||||||
static NS_DEFINE_IID(kIRDFLiteralIID, NS_IRDFLITERAL_IID);
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
class RDFHTMLDocumentImpl : public nsRDFDocument {
|
|
||||||
public:
|
|
||||||
RDFHTMLDocumentImpl();
|
|
||||||
virtual ~RDFHTMLDocumentImpl();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
nsresult AddTreeChild(nsIRDFContent* parent,
|
|
||||||
const nsString& tag,
|
|
||||||
nsIRDFResource* property,
|
|
||||||
nsIRDFResource* value);
|
|
||||||
|
|
||||||
nsresult AddLeafChild(nsIRDFContent* parent,
|
|
||||||
const nsString& tag,
|
|
||||||
nsIRDFResource* property,
|
|
||||||
nsIRDFLiteral* value);
|
|
||||||
|
|
||||||
virtual nsresult AddChild(nsIRDFContent* parent,
|
|
||||||
nsIRDFResource* property,
|
|
||||||
nsIRDFNode* value);
|
|
||||||
};
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
static nsIAtom* kIdAtom;
|
|
||||||
|
|
||||||
RDFHTMLDocumentImpl::RDFHTMLDocumentImpl(void)
|
|
||||||
{
|
|
||||||
if (nsnull == kIdAtom) {
|
|
||||||
kIdAtom = NS_NewAtom("id");
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
NS_ADDREF(kIdAtom);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
RDFHTMLDocumentImpl::~RDFHTMLDocumentImpl(void)
|
|
||||||
{
|
|
||||||
nsrefcnt refcnt;
|
|
||||||
NS_RELEASE2(kIdAtom, refcnt);
|
|
||||||
}
|
|
||||||
|
|
||||||
nsresult
|
|
||||||
RDFHTMLDocumentImpl::AddTreeChild(nsIRDFContent* parent,
|
|
||||||
const nsString& tag,
|
|
||||||
nsIRDFResource* property,
|
|
||||||
nsIRDFResource* value)
|
|
||||||
{
|
|
||||||
// If it's a tree property, then create a child element whose
|
|
||||||
// value is the value of the property. We'll also attach an "ID="
|
|
||||||
// attribute to the new child; e.g.,
|
|
||||||
//
|
|
||||||
// <parent>
|
|
||||||
// <property id="value">
|
|
||||||
// <!-- recursively generated -->
|
|
||||||
// </property>
|
|
||||||
// ...
|
|
||||||
// </parent>
|
|
||||||
|
|
||||||
nsresult rv;
|
|
||||||
const char* p;
|
|
||||||
nsAutoString s;
|
|
||||||
nsIRDFContent* child = nsnull;
|
|
||||||
|
|
||||||
// PR_TRUE indicates that we want the child to dynamically
|
|
||||||
// generate its own kids.
|
|
||||||
if (NS_FAILED(rv = NewChild(tag, value, child, PR_TRUE)))
|
|
||||||
goto done;
|
|
||||||
|
|
||||||
if (NS_FAILED(rv = value->GetValue(&p)))
|
|
||||||
goto done;
|
|
||||||
|
|
||||||
s = p;
|
|
||||||
|
|
||||||
if (NS_FAILED(rv = child->SetAttribute(kNameSpaceID_HTML, kIdAtom, s, PR_FALSE)))
|
|
||||||
goto done;
|
|
||||||
|
|
||||||
rv = parent->AppendChildTo(child, PR_TRUE);
|
|
||||||
|
|
||||||
done:
|
|
||||||
NS_IF_RELEASE(child);
|
|
||||||
return rv;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
nsresult
|
|
||||||
RDFHTMLDocumentImpl::AddLeafChild(nsIRDFContent* parent,
|
|
||||||
const nsString& tag,
|
|
||||||
nsIRDFResource* property,
|
|
||||||
nsIRDFLiteral* value)
|
|
||||||
{
|
|
||||||
// Otherwise, it's not a tree property. So we'll just create a
|
|
||||||
// new element for the property, and a simple text node for
|
|
||||||
// its value; e.g.,
|
|
||||||
//
|
|
||||||
// <parent>
|
|
||||||
// <property>value</property>
|
|
||||||
// ...
|
|
||||||
// </parent>
|
|
||||||
|
|
||||||
nsresult rv;
|
|
||||||
nsIRDFContent* child = nsnull;
|
|
||||||
|
|
||||||
if (NS_FAILED(rv = NewChild(tag, property, child, PR_FALSE)))
|
|
||||||
goto done;
|
|
||||||
|
|
||||||
if (NS_FAILED(rv = AttachTextNode(child, value)))
|
|
||||||
goto done;
|
|
||||||
|
|
||||||
rv = parent->AppendChildTo(child, PR_TRUE);
|
|
||||||
|
|
||||||
done:
|
|
||||||
NS_IF_RELEASE(child);
|
|
||||||
return rv;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsresult
|
|
||||||
RDFHTMLDocumentImpl::AddChild(nsIRDFContent* parent,
|
|
||||||
nsIRDFResource* property,
|
|
||||||
nsIRDFNode* value)
|
|
||||||
{
|
|
||||||
nsresult rv;
|
|
||||||
|
|
||||||
// The tag we'll use for the new child will be the string value of
|
|
||||||
// the property.
|
|
||||||
const char* s;
|
|
||||||
if (NS_FAILED(rv = property->GetValue(&s)))
|
|
||||||
return rv;
|
|
||||||
|
|
||||||
nsAutoString tag = s;
|
|
||||||
|
|
||||||
nsIRDFResource* valueResource;
|
|
||||||
if (NS_SUCCEEDED(rv = value->QueryInterface(kIRDFResourceIID, (void**) &valueResource))) {
|
|
||||||
if (IsTreeProperty(property) || rdf_IsContainer(mResourceMgr, mDB, valueResource)) {
|
|
||||||
rv = AddTreeChild(parent, tag, property, valueResource);
|
|
||||||
NS_RELEASE(valueResource);
|
|
||||||
return rv;
|
|
||||||
}
|
|
||||||
NS_RELEASE(valueResource);
|
|
||||||
}
|
|
||||||
|
|
||||||
nsIRDFLiteral* valueLiteral;
|
|
||||||
if (NS_SUCCEEDED(rv = value->QueryInterface(kIRDFLiteralIID, (void**) &valueLiteral))) {
|
|
||||||
rv = AddLeafChild(parent, tag, property, valueLiteral);
|
|
||||||
NS_RELEASE(valueLiteral);
|
|
||||||
}
|
|
||||||
return rv;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
nsresult NS_NewRDFHTMLDocument(nsIRDFDocument** result)
|
|
||||||
{
|
|
||||||
nsIRDFDocument* doc = new RDFHTMLDocumentImpl();
|
|
||||||
if (! doc)
|
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
|
||||||
|
|
||||||
NS_ADDREF(doc);
|
|
||||||
*result = doc;
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
|
@ -1,465 +0,0 @@
|
||||||
/* -*- 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 _RDF_RDF_INT_H
|
|
||||||
#define _RDF_RDF_INT_H
|
|
||||||
|
|
||||||
|
|
||||||
#define WINTEST 0
|
|
||||||
#define DBMTEST 1
|
|
||||||
#define FSTEST 1
|
|
||||||
|
|
||||||
|
|
||||||
#define RDF_BUF_SIZE 4096
|
|
||||||
#define LINE_SIZE 512
|
|
||||||
#define RDF_BOOKMARKS 128
|
|
||||||
#define RDF_MCF 129
|
|
||||||
#define RDF_XML 130
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include "rdf.h"
|
|
||||||
#include "nspr.h"
|
|
||||||
#include "plhash.h"
|
|
||||||
|
|
||||||
#include "rdfstr.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef true
|
|
||||||
#define true PR_TRUE
|
|
||||||
#endif
|
|
||||||
#ifndef false
|
|
||||||
#define false PR_FALSE
|
|
||||||
#endif
|
|
||||||
#define null NULL
|
|
||||||
#define nullp(x) (((void*)x) == ((void*)0))
|
|
||||||
#define LookupResource(x) ((RDF_Resource)PL_HashTableLookup(resourceHash, x));
|
|
||||||
|
|
||||||
#define noRDFErr 0
|
|
||||||
#define noMoreValuesErr 1
|
|
||||||
|
|
||||||
#define MAX_ATTRIBUTES 64
|
|
||||||
|
|
||||||
#define RDF_RT 0
|
|
||||||
#define LFS_RT 1
|
|
||||||
#define FTP_RT 3
|
|
||||||
#define ES_RT 4
|
|
||||||
#define SEARCH_RT 5
|
|
||||||
#define HISTORY_RT 6
|
|
||||||
#define LDAP_RT 7
|
|
||||||
#define PM_RT 8
|
|
||||||
#define RDM_RT 9
|
|
||||||
#define IM_RT 10
|
|
||||||
#define CACHE_RT 11
|
|
||||||
#define ATALK_RT 12
|
|
||||||
#define ATALKVIRTUAL_RT 13
|
|
||||||
#define COOKIE_RT 14
|
|
||||||
#define JSEC_RT 15
|
|
||||||
#define PMF_RT 16
|
|
||||||
|
|
||||||
#define CHECK_VAR(var, return_value) {if (var == NULL) {/*xxx PR_ASSERT(var); */ return return_value;}}
|
|
||||||
#define CHECK_VAR1(var) {if (var == NULL) {/*xxx PR_ASSERT(var);*/ return;}}
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef XP_WIN
|
|
||||||
#define FS_URL_OFFSET 8
|
|
||||||
#else
|
|
||||||
#define FS_URL_OFFSET 7
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#define MAX_URL_SIZE 300
|
|
||||||
|
|
||||||
|
|
||||||
#define convertString2UTF8(charsetid, s) \
|
|
||||||
(s != NULL ? \
|
|
||||||
INTL_ConvertLineWithoutAutoDetect( \
|
|
||||||
(charsetid) , \
|
|
||||||
CS_UTF8, \
|
|
||||||
(unsigned char*)(s), \
|
|
||||||
RDF_STRLEN(s) \
|
|
||||||
) : NULL)
|
|
||||||
|
|
||||||
#define stringEquals(x, y) (strcmp(x, y) ==0)
|
|
||||||
/*#define stringAppend(x, y) XP_AppendStr(x,y) */
|
|
||||||
|
|
||||||
NSPR_BEGIN_EXTERN_C
|
|
||||||
|
|
||||||
struct RDF_ResourceStruct {
|
|
||||||
char* url;
|
|
||||||
uint8 type;
|
|
||||||
uint8 flags;
|
|
||||||
struct RDF_AssertionStruct* rarg1;
|
|
||||||
struct RDF_AssertionStruct* rarg2;
|
|
||||||
struct RDF_ListStruct* rdf;
|
|
||||||
void* pdata;
|
|
||||||
} ;
|
|
||||||
|
|
||||||
#define RDF_GET_SLOT_VALUES_QUERY 0x01
|
|
||||||
#define RDF_GET_SLOT_VALUE_QUERY 0x02
|
|
||||||
#define RDF_FIND_QUERY 0x03
|
|
||||||
#define RDF_ARC_LABELS_IN_QUERY 0x04
|
|
||||||
#define RDF_ARC_LABELS_OUT_QUERY 0x05
|
|
||||||
|
|
||||||
struct RDF_CursorStruct {
|
|
||||||
RDF_Resource u;
|
|
||||||
RDF_Resource s;
|
|
||||||
RDF_Resource match;
|
|
||||||
void *value;
|
|
||||||
struct RDF_CursorStruct* current;
|
|
||||||
RDF rdf;
|
|
||||||
void* pdata;
|
|
||||||
PRBool tv;
|
|
||||||
PRBool inversep;
|
|
||||||
RDF_ValueType type;
|
|
||||||
int16 count;
|
|
||||||
uint16 size;
|
|
||||||
uint8 queryType;
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef uint8 RDF_BT;
|
|
||||||
|
|
||||||
#define getMem(x) PR_Calloc(1,(x))
|
|
||||||
#define freeMem(x) PR_Free((x))
|
|
||||||
|
|
||||||
struct RDF_AssertionStruct {
|
|
||||||
RDF_Resource u;
|
|
||||||
RDF_Resource s;
|
|
||||||
void* value;
|
|
||||||
PRBool tv;
|
|
||||||
RDF_ValueType type;
|
|
||||||
uint8 tags;
|
|
||||||
struct RDF_AssertionStruct* next;
|
|
||||||
struct RDF_AssertionStruct* invNext;
|
|
||||||
struct RDF_TranslatorStruct* db;
|
|
||||||
} ;
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct RDF_AssertionStruct *Assertion;
|
|
||||||
typedef struct RDF_FileStruct *RDFFile;
|
|
||||||
|
|
||||||
|
|
||||||
typedef PRBool (*assertProc)(RDFT r, RDF_Resource u, RDF_Resource s, void* value, RDF_ValueType type, PRBool tv);
|
|
||||||
typedef PRBool (*hasAssertionProc)(RDFT r, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type, PRBool tv);
|
|
||||||
typedef void* (*getSlotValueProc)(RDFT r, RDF_Resource u, RDF_Resource s, RDF_ValueType type, PRBool inversep, PRBool tv) ;
|
|
||||||
typedef RDF_Cursor (*getSlotValuesProc)(RDFT r, RDF_Resource u, RDF_Resource s, RDF_ValueType type, PRBool inversep, PRBool tv);
|
|
||||||
typedef PRBool (*unassertProc)(RDFT r, RDF_Resource u, RDF_Resource s, void* value, RDF_ValueType type);
|
|
||||||
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, 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 {
|
|
||||||
struct RDF_DBStruct* rdf;
|
|
||||||
struct RDF_ListStruct* next;
|
|
||||||
} ;
|
|
||||||
|
|
||||||
typedef struct RDF_ListStruct *RDFL;
|
|
||||||
|
|
||||||
struct RDF_TranslatorStruct {
|
|
||||||
RDFL rdf;
|
|
||||||
char* url;
|
|
||||||
void* pdata;
|
|
||||||
destroyProc destroy;
|
|
||||||
hasAssertionProc hasAssertion;
|
|
||||||
unassertProc unassert;
|
|
||||||
assertProc assert;
|
|
||||||
getSlotValueProc getSlotValue;
|
|
||||||
getSlotValuesProc getSlotValues;
|
|
||||||
nextItemProc nextValue;
|
|
||||||
disposeCursorProc disposeCursor;
|
|
||||||
disposeResourceProc disposeResource;
|
|
||||||
arcLabelsInProc arcLabelsIn;
|
|
||||||
arcLabelsInProc arcLabelsOut;
|
|
||||||
accessFileProc possiblyAccessFile;
|
|
||||||
updateProc update;
|
|
||||||
RDFL dependents;
|
|
||||||
RDFL dependentOn;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
extern PLHashTable* resourceHash;
|
|
||||||
extern PLHashTable* dataSourceHash;
|
|
||||||
extern char* gNavCntrUrl;
|
|
||||||
struct RDF_DBStruct {
|
|
||||||
int32 numTranslators;
|
|
||||||
int32 translatorArraySize;
|
|
||||||
RDFT* translators;
|
|
||||||
struct RDF_FileStruct* files;
|
|
||||||
struct RDF_NotificationStruct* notifs;
|
|
||||||
void* context;
|
|
||||||
};
|
|
||||||
|
|
||||||
extern RDFT gLocalStore;
|
|
||||||
extern RDFT gRemoteStore;
|
|
||||||
extern RDFT gSessionDB;
|
|
||||||
extern size_t gCoreVocabSize;
|
|
||||||
extern RDF_Resource* gAllVocab;
|
|
||||||
|
|
||||||
/* reading rdf */
|
|
||||||
|
|
||||||
#define HEADERS 1
|
|
||||||
#define BODY 2
|
|
||||||
|
|
||||||
|
|
||||||
struct XMLNameSpaceStruct {
|
|
||||||
char* as;
|
|
||||||
char* url;
|
|
||||||
struct XMLNameSpaceStruct* next;
|
|
||||||
} ;
|
|
||||||
|
|
||||||
typedef struct XMLNameSpaceStruct *XMLNameSpace;
|
|
||||||
|
|
||||||
#define RDF_MAX_NUM_FILE_TOKENS 8
|
|
||||||
|
|
||||||
struct RDF_FileStructTokens {
|
|
||||||
RDF_Resource token;
|
|
||||||
RDF_ValueType type;
|
|
||||||
int16 tokenNum;
|
|
||||||
char *data;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct RDF_FileStruct {
|
|
||||||
char* url;
|
|
||||||
|
|
||||||
RDF_Resource currentResource;
|
|
||||||
RDF_Resource top;
|
|
||||||
RDF_Resource rtop;
|
|
||||||
char* currentSlot;
|
|
||||||
PRBool genlAdded;
|
|
||||||
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* updateURL;
|
|
||||||
char* postURL;
|
|
||||||
|
|
||||||
PRTime lastReadTime;
|
|
||||||
PRTime *expiryTime;
|
|
||||||
uint8 fileType;
|
|
||||||
PRBool locked;
|
|
||||||
RDF_Resource lastItem;
|
|
||||||
|
|
||||||
|
|
||||||
PRBool tv;
|
|
||||||
fAssert1Proc assert;
|
|
||||||
fUnAssert1Proc unassert;
|
|
||||||
RDFT db;
|
|
||||||
PRBool refreshingp;
|
|
||||||
|
|
||||||
void* pdata;
|
|
||||||
|
|
||||||
int16 numFileTokens;
|
|
||||||
struct RDF_FileStructTokens tokens[RDF_MAX_NUM_FILE_TOKENS];
|
|
||||||
struct RDF_FileStruct* next;
|
|
||||||
};
|
|
||||||
|
|
||||||
RDFT MakeColumnStore (char* url);
|
|
||||||
RDF newNavCenterDB();
|
|
||||||
void addToResourceList (RDFFile f, RDF_Resource u);
|
|
||||||
|
|
||||||
void walkThroughAllBookmarks (RDF_Resource u);
|
|
||||||
RDFT NewRemoteStore (char* url);
|
|
||||||
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, 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);
|
|
||||||
RDF_Error addChildBefore (RDFT rdf, RDF_Resource parent, RDF_Resource child, RDF_Resource beforeWhat);
|
|
||||||
void nlclStoreKill(RDFT rdf, RDF_Resource r);
|
|
||||||
char* resourceID(RDF_Resource id);
|
|
||||||
PRBool containerp (RDF_Resource r);
|
|
||||||
void setContainerp (RDF_Resource r, PRBool contp);
|
|
||||||
PRBool lockedp (RDF_Resource r);
|
|
||||||
void setLockedp (RDF_Resource r, PRBool contp);
|
|
||||||
uint8 resourceType (RDF_Resource r);
|
|
||||||
void setResourceType (RDF_Resource r, uint8 type);
|
|
||||||
char* getBaseURL (const char* url) ;
|
|
||||||
void freeNamespaces (RDFFile f) ;
|
|
||||||
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);
|
|
||||||
|
|
||||||
RDFT MakeRemoteStore (char* url);
|
|
||||||
RDFT MakeMailAccountDB(char* url);
|
|
||||||
PRDir * OpenDir(char *name);
|
|
||||||
void PopGetNewMail (RDF_Resource r) ;
|
|
||||||
void readResourceFile(RDF rdf, RDF_Resource u);
|
|
||||||
void possiblyGCResource(RDF_Resource u);
|
|
||||||
PLHashNumber idenHash(const void* key);
|
|
||||||
|
|
||||||
RDFT MakeBMKStore (char* url);
|
|
||||||
RDFT MakeLocalStore (char* url);
|
|
||||||
RDFT MakeFileDB (char* url);
|
|
||||||
RDFT MakeSCookDB (char* url);
|
|
||||||
char * makeRDFDBURL(char* directory, char* name);
|
|
||||||
void addToResourceList (RDFFile f, RDF_Resource u);
|
|
||||||
void removeFromAssertionList(RDFFile f, Assertion as);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* string utilities */
|
|
||||||
|
|
||||||
int16 charSearch(const char c,const char* string);
|
|
||||||
int16 revCharSearch(const char c, const char* string);
|
|
||||||
PR_PUBLIC_API(PRBool) startsWith(const char* startPattern,const char* string);
|
|
||||||
PRBool endsWith(const char* endPattern,const char* string);
|
|
||||||
PRBool inverseTV(PRBool tv);
|
|
||||||
void createBootstrapResources();
|
|
||||||
PRBool urlEquals(const char* url1,const char* url2);
|
|
||||||
char* append2Strings(const char* str1,const char* str2);
|
|
||||||
char* convertString2UTF8AndAppend(int16 charsetID, const char* str1,const char* str2);
|
|
||||||
PRBool substring(const char* pattern, const char* data);
|
|
||||||
void stringAppend(char* in, const char* append);
|
|
||||||
|
|
||||||
RDFFile makeRDFFile (char* url, RDF_Resource top, PRBool localp);
|
|
||||||
void initRDFFile (RDFFile ans) ;
|
|
||||||
void parseNextRDFLine (RDFFile f, char* line) ;
|
|
||||||
void parseNextRDFBlob (RDFFile f, char* blob, int32 size);
|
|
||||||
void finishRDFParse (RDFFile f) ;
|
|
||||||
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, 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) ;
|
|
||||||
RDF_Resource resolveGenlPosReference(char* tok, RDFFile f);
|
|
||||||
RDF_Resource resolveReference (char *tok, RDFFile f) ;
|
|
||||||
RDF_Resource resolveGenlPosReference(char* tok, RDFFile f);
|
|
||||||
void beginReadingRDFFile(RDFFile f);
|
|
||||||
void gcRDFFile (RDFFile f);
|
|
||||||
#ifdef XP_MAC
|
|
||||||
char* unescapeURL(char* inURL);
|
|
||||||
#endif
|
|
||||||
char* convertFileURLToNSPRCopaceticPath(char* inURL);
|
|
||||||
PRFileDesc* CallPROpenUsingFileURL(char *fileURL, PRIntn flags, PRIntn mode);
|
|
||||||
/* DB *CallDBOpenUsingFileURL(char *fileURL, int flags,int mode, DBTYPE type, const void *openinfo); */
|
|
||||||
|
|
||||||
char* copyString (const char* url);
|
|
||||||
PRBool nlocalStoreAssert (RDFT rdf, RDF_Resource u, RDF_Resource s, void* v,
|
|
||||||
RDF_ValueType type, PRBool tv) ;
|
|
||||||
char* MCDepFileURL (char* url) ;
|
|
||||||
void initLocalStore(RDFT rdf);
|
|
||||||
void freeAssertion(Assertion as);
|
|
||||||
Assertion localStoreAdd (RDFT rdf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type, PRBool tv) ;
|
|
||||||
Assertion localStoreRemove (RDFT rdf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type) ;
|
|
||||||
|
|
||||||
Assertion remoteStoreAdd (RDFT rdf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type, PRBool tv) ;
|
|
||||||
Assertion remoteStoreRemove (RDFT rdf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type) ;
|
|
||||||
void* remoteStoreGetSlotValue (RDFT mcf, RDF_Resource u, RDF_Resource s, RDF_ValueType type, PRBool inversep, PRBool tv) ;
|
|
||||||
void ht_fprintf(PRFileDesc *file, const char *fmt, ...);
|
|
||||||
|
|
||||||
RDF_Resource createContainer (char* id);
|
|
||||||
PRBool isContainer (RDF_Resource r) ;
|
|
||||||
PRBool isSeparator (RDF_Resource r) ;
|
|
||||||
PRBool isLeaf (RDF_Resource r) ;
|
|
||||||
PRBool bookmarkSlotp (RDF_Resource s) ;
|
|
||||||
|
|
||||||
void basicAssertions (void) ;
|
|
||||||
char* makeResourceName (RDF_Resource node) ;
|
|
||||||
char* makeDBURL (char* name);
|
|
||||||
|
|
||||||
/* int rdf_GetURL (MWContext *cx, int method, Net_GetUrlExitFunc *exit_routine, RDFFile rdfFile); */
|
|
||||||
|
|
||||||
RDFT MakePopDB (char* url) ;
|
|
||||||
PRBool nlocalStoreAssert (RDFT mcf, RDF_Resource u, RDF_Resource s, void* v,
|
|
||||||
RDF_ValueType type, PRBool tv) ;
|
|
||||||
PRBool nlocalStoreUnassert (RDFT mcf, RDF_Resource u, RDF_Resource s, void* v,
|
|
||||||
RDF_ValueType type) ;
|
|
||||||
PRBool nlocalStoreHasAssertion (RDFT rdf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type, PRBool tv) ;
|
|
||||||
void* nlocalStoreGetSlotValue (RDFT rdf, RDF_Resource u, RDF_Resource s, RDF_ValueType type, PRBool inversep, PRBool tv) ;
|
|
||||||
RDF_Cursor nlocalStoreGetSlotValues (RDFT rdf, RDF_Resource u, RDF_Resource s, RDF_ValueType type, PRBool inversep, PRBool tv) ;
|
|
||||||
void* nlocalStoreNextValue (RDFT mcf, RDF_Cursor c) ;
|
|
||||||
RDF_Error nlocalStoreDisposeCursor (RDFT mcf, RDF_Cursor c) ;
|
|
||||||
void createCoreVocab () ;
|
|
||||||
|
|
||||||
|
|
||||||
PRBool remoteAssert (RDFT mcf, RDF_Resource u, RDF_Resource s, void* v,
|
|
||||||
RDF_ValueType type, PRBool tv) ;
|
|
||||||
PRBool remoteUnassert (RDFT mcf, RDF_Resource u, RDF_Resource s, void* v,
|
|
||||||
RDF_ValueType type) ;
|
|
||||||
PRBool remoteAssert1 (RDFT mcf, RDF_Resource u, RDF_Resource s, void* v,
|
|
||||||
RDF_ValueType type, PRBool tv) ;
|
|
||||||
PRBool remoteAssert2 (RDFT mcf, RDF_Resource u, RDF_Resource s, void* v,
|
|
||||||
RDF_ValueType type, PRBool tv) ;
|
|
||||||
PRBool remoteUnassert1 (RDFT mcf, RDF_Resource u, RDF_Resource s, void* v,
|
|
||||||
RDF_ValueType type) ;
|
|
||||||
PRBool remoteStoreHasAssertion (RDFT rdf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type, PRBool tv) ;
|
|
||||||
void* remoteStoreGetSlotValue (RDFT rdf, RDF_Resource u, RDF_Resource s, RDF_ValueType type, PRBool inversep, PRBool tv) ;
|
|
||||||
RDF_Cursor remoteStoreGetSlotValues (RDFT rdf, RDF_Resource u, RDF_Resource s, RDF_ValueType type, PRBool inversep, PRBool tv) ;
|
|
||||||
RDF_Cursor remoteStoreGetSlotValuesInt (RDFT rdf, RDF_Resource u, RDF_Resource s, RDF_ValueType type, PRBool inversep, PRBool tv) ;
|
|
||||||
RDF_Resource createSeparator(void);
|
|
||||||
PRBool
|
|
||||||
remoteAssert (RDFT mcf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type, PRBool tv);
|
|
||||||
|
|
||||||
void* remoteStoreNextValue (RDFT mcf, RDF_Cursor c) ;
|
|
||||||
RDF_Error remoteStoreDisposeCursor (RDFT mcf, RDF_Cursor c) ;
|
|
||||||
PRBool remoteStoreHasAssertion (RDFT mcf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type, PRBool tv) ;
|
|
||||||
PRBool remoteStoreHasAssertionInt (RDFT mcf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type, PRBool tv) ;
|
|
||||||
PRBool nlocalStoreAddChildAt(RDFT mcf, RDF_Resource obj, RDF_Resource ref, RDF_Resource _new,
|
|
||||||
PRBool beforep);
|
|
||||||
RDFT getTranslator (char* url);
|
|
||||||
|
|
||||||
RDFT MakeCookieStore (char* url);
|
|
||||||
|
|
||||||
char* advertURLOfContainer (RDF r, RDF_Resource u) ;
|
|
||||||
RDFT RDFTNamed (RDF rdf, char* name) ;
|
|
||||||
|
|
||||||
char* RDF_SerializeRDFStore (RDFT store) ;
|
|
||||||
char * unescapeURL(char *inURL);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
extern RDF_WDVocab gWebData;
|
|
||||||
extern RDF_NCVocab gNavCenter;
|
|
||||||
extern RDF_CoreVocab gCoreVocab;
|
|
||||||
|
|
||||||
NSPR_END_EXTERN_C
|
|
||||||
|
|
||||||
#endif
|
|
199
rdf/src/rdfht.c
199
rdf/src/rdfht.c
|
@ -1,199 +0,0 @@
|
||||||
/* -*- 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 file implements high level support for the rdf data model.
|
|
||||||
For more information on this file, contact rjc or guha
|
|
||||||
For more information on RDF, look at the RDF section of www.mozilla.org
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "rdf-int.h"
|
|
||||||
#include "vocab.h"
|
|
||||||
#include "vocabint.h"
|
|
||||||
#include "bmk2rdf.h"
|
|
||||||
#include "core.h"
|
|
||||||
|
|
||||||
|
|
||||||
/* globals */
|
|
||||||
char *profileDirURL = NULL;
|
|
||||||
char *gLocalStoreURL = NULL;
|
|
||||||
char *gBookmarkURL = NULL;
|
|
||||||
char *gGlobalHistoryURL = NULL;
|
|
||||||
void *timerID = NULL;
|
|
||||||
char *gRLForbiddenDomains = NULL;
|
|
||||||
|
|
||||||
extern RDF gNCDB ;
|
|
||||||
|
|
||||||
|
|
||||||
static PRBool sRDFInitedB = PR_FALSE;
|
|
||||||
char* gNavCntrUrl;
|
|
||||||
|
|
||||||
|
|
||||||
char * gNavCenterDataSources[15] =
|
|
||||||
{"rdf:localStore", "rdf:remoteStore", "rdf:bookmarks", "rdf:remoteStore", "rdf:history",
|
|
||||||
/* "rdf:ldap", */
|
|
||||||
"rdf:esftp",
|
|
||||||
"rdf:lfs", "rdf:CookieStore",
|
|
||||||
"rdf:columns", "rdf:find",
|
|
||||||
|
|
||||||
#ifdef XP_MAC
|
|
||||||
"rdf:appletalk",
|
|
||||||
#endif
|
|
||||||
|
|
||||||
NULL, NULL
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
RDF
|
|
||||||
newNavCenterDB()
|
|
||||||
{
|
|
||||||
return RDF_GetDB((char**)gNavCenterDataSources);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
walkThroughAllBookmarks (RDF_Resource u)
|
|
||||||
{
|
|
||||||
#ifdef MOZILLA_CLIENT
|
|
||||||
RDF_Cursor c = RDF_GetSources(gNCDB, u, gCoreVocab->RDF_parent, RDF_RESOURCE_TYPE, true);
|
|
||||||
RDF_Resource next;
|
|
||||||
while ((next = RDF_NextValue(c)) != NULL) {
|
|
||||||
if (resourceType(next) == RDF_RT) walkThroughAllBookmarks(next);
|
|
||||||
}
|
|
||||||
RDF_DisposeCursor(c);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef XXX
|
|
||||||
PR_PUBLIC_API(RDF_Error)
|
|
||||||
RDF_Init()
|
|
||||||
{
|
|
||||||
if ( sRDFInitedB )
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
resourceHash = PL_NewHashTable(500, PL_HashString, PL_CompareStrings,
|
|
||||||
PL_CompareValues, NULL, NULL);
|
|
||||||
dataSourceHash = PL_NewHashTable(100, PL_HashString, PL_CompareStrings,
|
|
||||||
PL_CompareValues, NULL, NULL);
|
|
||||||
/* RDFglueInitialize(); */
|
|
||||||
MakeRemoteStore("rdf:remoteStore");
|
|
||||||
createVocabs();
|
|
||||||
sRDFInitedB = PR_TRUE;
|
|
||||||
|
|
||||||
/* XXX Bookmark hack */
|
|
||||||
gBookmarkURL = copyString("file://G:/tmp/bookmarks.html");
|
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
#else /* XXX */
|
|
||||||
PR_PUBLIC_API(RDF_Error)
|
|
||||||
RDF_Init(RDF_InitParams params)
|
|
||||||
{
|
|
||||||
#ifdef MOZILLA_CLIENT
|
|
||||||
char* navCenterURL;
|
|
||||||
#endif
|
|
||||||
if ( sRDFInitedB )
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
#ifdef MOZILLA_CLIENT
|
|
||||||
|
|
||||||
/*
|
|
||||||
copy init params out before doing anything else (such as creating vocabulary)
|
|
||||||
to prevent any XP_GetString round-robin problems (ex: FE could be using XP_GetString
|
|
||||||
to pass in the init strings, which createVocabs() could affect
|
|
||||||
*/
|
|
||||||
profileDirURL = copyString(params->profileURL);
|
|
||||||
gBookmarkURL = copyString(params->bookmarksURL);
|
|
||||||
gGlobalHistoryURL = copyString(params->globalHistoryURL);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
resourceHash = PL_NewHashTable(500, PL_HashString, PL_CompareStrings,
|
|
||||||
PL_CompareValues, NULL, NULL);
|
|
||||||
dataSourceHash = PL_NewHashTable(100, PL_HashString, PL_CompareStrings,
|
|
||||||
PL_CompareValues, NULL, NULL);
|
|
||||||
/* RDFglueInitialize(); */
|
|
||||||
MakeRemoteStore("rdf:remoteStore");
|
|
||||||
createVocabs();
|
|
||||||
sRDFInitedB = PR_TRUE;
|
|
||||||
|
|
||||||
#ifdef MOZILLA_CLIENT
|
|
||||||
/* xxx
|
|
||||||
PREF_SetDefaultCharPref("browser.NavCenter", "http://rdf.netscape.com/rdf/navcntr.rdf");
|
|
||||||
PREF_CopyCharPref("browser.NavCenter", &navCenterURL);
|
|
||||||
*/
|
|
||||||
navCenterURL = copyString("http://rdf.netscape.com/rdf/navcntr.rdf");
|
|
||||||
if (!RDF_STRCHR(navCenterURL, ':')) {
|
|
||||||
navCenterURL = makeDBURL(navCenterURL);
|
|
||||||
}
|
|
||||||
gNavCntrUrl = copyString(navCenterURL);
|
|
||||||
*(gNavCenterDataSources + 1) = copyString(navCenterURL);
|
|
||||||
gNCDB = newNavCenterDB();
|
|
||||||
freeMem(navCenterURL);
|
|
||||||
|
|
||||||
HT_Startup();
|
|
||||||
|
|
||||||
/* GuessIEBookmarks(); */
|
|
||||||
|
|
||||||
#endif
|
|
||||||
walkThroughAllBookmarks(RDF_GetResource(NULL, "NC:Bookmarks", true));
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#endif /* XXX */
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*need to keep a linked list of all the dbs opened so that they
|
|
||||||
can all be closed down on exit */
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
PR_PUBLIC_API(RDF_Error)
|
|
||||||
RDF_Shutdown ()
|
|
||||||
{
|
|
||||||
#ifdef MOZILLA_CLIENT
|
|
||||||
/* flushBookmarks(); */
|
|
||||||
/* HT_Shutdown(); */
|
|
||||||
/* RDFglueExit(); */
|
|
||||||
if (profileDirURL != NULL)
|
|
||||||
{
|
|
||||||
freeMem(profileDirURL);
|
|
||||||
profileDirURL = NULL;
|
|
||||||
}
|
|
||||||
if (gBookmarkURL != NULL)
|
|
||||||
{
|
|
||||||
freeMem(gBookmarkURL);
|
|
||||||
gBookmarkURL = NULL;
|
|
||||||
}
|
|
||||||
if (gGlobalHistoryURL != NULL)
|
|
||||||
{
|
|
||||||
freeMem(gGlobalHistoryURL);
|
|
||||||
gGlobalHistoryURL = NULL;
|
|
||||||
}
|
|
||||||
if (gLocalStoreURL != NULL)
|
|
||||||
{
|
|
||||||
freeMem(gLocalStoreURL);
|
|
||||||
gLocalStoreURL = NULL;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
disposeAllDBs();
|
|
||||||
sRDFInitedB = PR_FALSE;
|
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
|
@ -1,573 +0,0 @@
|
||||||
/* -*- 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 file implements parsing support for the rdf data model.
|
|
||||||
For more information on this file, contact rjc or guha
|
|
||||||
For more information on RDF, look at the RDF section of www.mozilla.org
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "rdfparse.h"
|
|
||||||
#include "core.h"
|
|
||||||
|
|
||||||
|
|
||||||
#define wsCharp(c) ((c == '\r') || (c == '\t') || (c == ' ') || (c == '\n'))
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
char
|
|
||||||
decodeEntityRef (char* string, int32* stringIndexPtr, int32 len)
|
|
||||||
{
|
|
||||||
if (startsWith("lt;", string)) {
|
|
||||||
*stringIndexPtr = *stringIndexPtr + 3;
|
|
||||||
return '<';
|
|
||||||
} else if (startsWith("gt;", string)) {
|
|
||||||
*stringIndexPtr = *stringIndexPtr + 3;
|
|
||||||
return '>';
|
|
||||||
} else if (startsWith("amp;", string)) {
|
|
||||||
*stringIndexPtr = *stringIndexPtr + 4;
|
|
||||||
return '&';
|
|
||||||
} else return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
char *
|
|
||||||
copyStringIgnoreWhiteSpace(char* string)
|
|
||||||
{
|
|
||||||
int32 len = RDF_STRLEN(string);
|
|
||||||
char* buf = (char*)getMem(len + 1);
|
|
||||||
PRBool inWhiteSpace = 1;
|
|
||||||
int32 buffIndex = 0;
|
|
||||||
int32 stringIndex = 0;
|
|
||||||
|
|
||||||
while (stringIndex < len) {
|
|
||||||
char nextChar = *(string + stringIndex);
|
|
||||||
PRBool wsp = wsCharp(nextChar);
|
|
||||||
if (!wsp) {
|
|
||||||
if (nextChar == '&') {
|
|
||||||
*(buf + buffIndex++) = decodeEntityRef(&string[stringIndex+1],
|
|
||||||
&stringIndex, len-stringIndex);
|
|
||||||
} else {
|
|
||||||
*(buf + buffIndex++) = nextChar;
|
|
||||||
}
|
|
||||||
inWhiteSpace = 0;
|
|
||||||
} else if (!inWhiteSpace) {
|
|
||||||
*(buf + buffIndex++) = ' ';
|
|
||||||
inWhiteSpace = 1;
|
|
||||||
} else {
|
|
||||||
inWhiteSpace = 1;
|
|
||||||
}
|
|
||||||
stringIndex++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return buf;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
char *
|
|
||||||
getHref(char** attlist)
|
|
||||||
{
|
|
||||||
char* ans = getAttributeValue(attlist, "rdf:href");
|
|
||||||
if (!ans) ans = getAttributeValue(attlist, "RDF:href");
|
|
||||||
if (!ans) ans = getAttributeValue(attlist, "href");
|
|
||||||
return ans;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int parseNextRDFXMLBlobInt(RDFFile f, char* blob, int32 size) {
|
|
||||||
int32 n, last, m;
|
|
||||||
PRBool somethingseenp = 0;
|
|
||||||
n = last = 0;
|
|
||||||
|
|
||||||
while (n < size) {
|
|
||||||
char c = blob[n];
|
|
||||||
m = 0;
|
|
||||||
somethingseenp = 0;
|
|
||||||
memset(f->line, '\0', RDF_BUF_SIZE-1);
|
|
||||||
if (f->holdOver[0] != '\0') {
|
|
||||||
memcpy(f->line, f->holdOver, RDF_STRLEN(f->holdOver));
|
|
||||||
m = RDF_STRLEN(f->holdOver);
|
|
||||||
somethingseenp = 1;
|
|
||||||
memset(f->holdOver, '\0', RDF_BUF_SIZE-1);
|
|
||||||
}
|
|
||||||
while ((n < size) && (wsc(c))) {c = blob[++n];}
|
|
||||||
/* f->line[m++] = c;
|
|
||||||
c = blob[++n]; */
|
|
||||||
while ((m < RDF_BUF_SIZE) && (c != '<') && (c != '>')) {
|
|
||||||
f->line[m] = c;
|
|
||||||
m++;
|
|
||||||
somethingseenp = (somethingseenp || (!(wsc(c))));
|
|
||||||
n++;
|
|
||||||
if (n < size) c = blob[n];
|
|
||||||
else break;
|
|
||||||
}
|
|
||||||
if (c == '>') f->line[m] = c;
|
|
||||||
n++;
|
|
||||||
if (m > 0) {
|
|
||||||
if ((c == '<') || (c == '>')) {
|
|
||||||
last = n;
|
|
||||||
if (c == '<') f->holdOver[0] = '<';
|
|
||||||
if (somethingseenp == 1) parseNextRDFToken(f, f->line);
|
|
||||||
} else if (size > last) {
|
|
||||||
memcpy(f->holdOver, f->line, m);
|
|
||||||
}
|
|
||||||
} else if (c == '<') f->holdOver[0] = '<';
|
|
||||||
}
|
|
||||||
return(size);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
parseRDFProcessingInstruction (RDFFile f, char* token)
|
|
||||||
{
|
|
||||||
char* attlist[2*MAX_ATTRIBUTES+1];
|
|
||||||
char* elementName;
|
|
||||||
tokenizeElement(token, attlist, &elementName);
|
|
||||||
if (RDF_STRCMP(elementName, "?xml:namespace") == 0) {
|
|
||||||
char* as = getAttributeValue(attlist, "prefix");
|
|
||||||
char* url = getAttributeValue(attlist, "ns");
|
|
||||||
if ((as != NULL) && (url != NULL)) {
|
|
||||||
XMLNameSpace ns = (XMLNameSpace)getMem(sizeof(struct XMLNameSpaceStruct));
|
|
||||||
size_t urln = RDF_STRLEN(url);
|
|
||||||
PRBool addSlash = (url[urln-1] != '/');
|
|
||||||
if(addSlash) urln++;
|
|
||||||
ns->url = (char*)getMem(sizeof(char) * (urln + 1));
|
|
||||||
sprintf(ns->url, "%s%s", url, addSlash ? "/" : "");
|
|
||||||
ns->as = copyString(as);
|
|
||||||
ns->next = f->namespaces;
|
|
||||||
f->namespaces = ns;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
freeNamespaces (RDFFile f)
|
|
||||||
{
|
|
||||||
XMLNameSpace ns1 = f->namespaces;
|
|
||||||
while (ns1) {
|
|
||||||
XMLNameSpace next = ns1->next;
|
|
||||||
freeMem(ns1->as);
|
|
||||||
freeMem(ns1->url);
|
|
||||||
freeMem(ns1);
|
|
||||||
ns1 = next;
|
|
||||||
}
|
|
||||||
f->namespaces = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
char *
|
|
||||||
getAttributeValue (char** attlist, char* elName)
|
|
||||||
{
|
|
||||||
size_t n = 0;
|
|
||||||
if (!attlist) return NULL;
|
|
||||||
while ((n < 2*MAX_ATTRIBUTES) && (*(attlist + n) != NULL)) {
|
|
||||||
if (RDF_STRCMP(*(attlist + n), elName) == 0) return *(attlist + n + 1);
|
|
||||||
n = n + 2;
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
PRBool
|
|
||||||
tagEquals (RDFFile f, char* tag1, char* tag2)
|
|
||||||
{
|
|
||||||
return (RDF_STRCMP(tag1, tag2) == 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
addElementProps (char** attlist, char* elementName, RDFFile f, RDF_Resource obj)
|
|
||||||
{
|
|
||||||
uint32 count = 0;
|
|
||||||
while (count < 2*MAX_ATTRIBUTES) {
|
|
||||||
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") && !tagEquals(f, attName, "tv")
|
|
||||||
&& !tagEquals(f, attName, "id")) {
|
|
||||||
addSlotValue(f, obj, ResourceFromElementName(f, attName), copyStringIgnoreWhiteSpace(attValue),
|
|
||||||
RDF_STRING_TYPE, "true");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
PRBool
|
|
||||||
knownObjectElement (char* eln)
|
|
||||||
{
|
|
||||||
return (RDF_STRCMP(eln, "RDF:Description") == 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* XXX
|
|
||||||
void
|
|
||||||
rdf_abort(NET_StreamClass *stream, int status)
|
|
||||||
{
|
|
||||||
RDFFile f = (RDFFile)stream->data_object;
|
|
||||||
if (RDF_STRCMP(f->url, gNavCntrUrl) == 0) {
|
|
||||||
parseNextRDFXMLBlob(stream, gDefaultNavcntr, RDF_STRLEN(gDefaultNavcntr));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (f) {
|
|
||||||
f->locked = false;
|
|
||||||
gcRDFFile (f);
|
|
||||||
freeMem(f->line);
|
|
||||||
freeMem(f->currentSlot);
|
|
||||||
freeMem(f->holdOver);
|
|
||||||
freeNamespaces(f) ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
char *
|
|
||||||
possiblyMakeAbsolute (RDFFile f, char* url)
|
|
||||||
{
|
|
||||||
if (RDF_STRCHR(url, ':') != NULL) {
|
|
||||||
return copyString(url);
|
|
||||||
} else {
|
|
||||||
char* ans = getMem(RDF_STRLEN(f->url) + strlen(url)+2);
|
|
||||||
sprintf(ans, "%s#%s", f->url, url);
|
|
||||||
return ans;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
PRBool
|
|
||||||
containerTagp (RDFFile f, char* elementName)
|
|
||||||
{
|
|
||||||
return (tagEquals(f, elementName, "Container") ||
|
|
||||||
tagEquals(f, elementName, "Topic") ||
|
|
||||||
(tagEquals(f, elementName, "RelatedLinks")));
|
|
||||||
}
|
|
||||||
|
|
||||||
#define DC_TITLE "http://purl.org/metadata/dublin_core/title"
|
|
||||||
#define SM_CHILD "http://purl.org/metadata/sitemap/child"
|
|
||||||
|
|
||||||
RDF_Resource
|
|
||||||
ResourceFromElementName (RDFFile f, char* elementName)
|
|
||||||
{
|
|
||||||
if(!elementName || (RDF_STRCHR(elementName, ':') == NULL) ) {
|
|
||||||
return RDF_GetResource(NULL, elementName, 1);
|
|
||||||
} else {
|
|
||||||
XMLNameSpace ns = f->namespaces;
|
|
||||||
while (ns) {
|
|
||||||
if (startsWith(ns->as, elementName)) {
|
|
||||||
RDF_Resource ans;
|
|
||||||
size_t asn = RDF_STRLEN(ns->as);
|
|
||||||
size_t urln = RDF_STRLEN(ns->url);
|
|
||||||
char* url = getMem(RDF_STRLEN(ns->url) + strlen(elementName)-asn);
|
|
||||||
memcpy(url, ns->url, urln);
|
|
||||||
RDF_STRCAT(url, &elementName[asn+1]);
|
|
||||||
if (RDF_STRCMP(url, DC_TITLE) == 0) {
|
|
||||||
ans = gCoreVocab->RDF_name;
|
|
||||||
} else if (RDF_STRCMP(url, SM_CHILD) == 0) {
|
|
||||||
ans = gCoreVocab->RDF_child;
|
|
||||||
} else
|
|
||||||
ans = RDF_GetResource(NULL, url, 1);
|
|
||||||
freeMem(url);
|
|
||||||
return ans;
|
|
||||||
}
|
|
||||||
ns = ns->next;
|
|
||||||
}
|
|
||||||
return RDF_GetResource(NULL, elementName, 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
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, NULL);
|
|
||||||
}
|
|
||||||
} else if (startsWith("<!--", token)) {
|
|
||||||
return;
|
|
||||||
} else if (token[1] == '?') {
|
|
||||||
parseRDFProcessingInstruction(f, token);
|
|
||||||
} else if (token[1] == '/') {
|
|
||||||
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)) {
|
|
||||||
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 && (RDF_STRCMP(status, "replace"))) gcRDFFileInt(f);
|
|
||||||
} else if (startsWith("<RelatedLinks", token)) {
|
|
||||||
f->stack[f->depth++] = f->top;
|
|
||||||
f->status = EXPECTING_PROPERTY;
|
|
||||||
} else {
|
|
||||||
PRBool emptyElementp = (token[RDF_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;
|
|
||||||
if (f->status == EXPECTING_OBJECT) {
|
|
||||||
char* url = NULL;
|
|
||||||
RDF_Resource obj;
|
|
||||||
uint16 count = 0;
|
|
||||||
url = getHref(attlist);
|
|
||||||
if (url == NULL) url = getAttributeValue(attlist, "id");
|
|
||||||
if (url) url = possiblyMakeAbsolute(f, url);
|
|
||||||
obj = ResourceFromElementName(f, url);
|
|
||||||
if (url) freeMem(url);
|
|
||||||
addToResourceList(f, obj);
|
|
||||||
addElementProps (attlist, elementName, f, obj) ;
|
|
||||||
if (!tagEquals(f, elementName, "RDF:Description")) {
|
|
||||||
if (containerTagp(f, elementName)) {
|
|
||||||
setContainerp(obj, 1);
|
|
||||||
} else {
|
|
||||||
RDF_Resource eln = ResourceFromElementName(f, elementName);
|
|
||||||
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, getAttributeValue(attlist, "tv"));
|
|
||||||
}
|
|
||||||
if (!emptyElementp) {
|
|
||||||
f->stack[f->depth++] = obj;
|
|
||||||
f->status = EXPECTING_PROPERTY;
|
|
||||||
}
|
|
||||||
} else if (f->status == EXPECTING_PROPERTY) {
|
|
||||||
char* url;
|
|
||||||
RDF_Resource obj;
|
|
||||||
uint16 count = 0;
|
|
||||||
url = getHref(attlist) ;
|
|
||||||
if (url) {
|
|
||||||
RDF_Resource eln = ResourceFromElementName(f, elementName);
|
|
||||||
char* tvAtt = getAttributeValue(attlist, "tv");
|
|
||||||
url = possiblyMakeAbsolute(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,
|
|
||||||
getAttributeValue(attlist, "tv"));
|
|
||||||
} else if ((RDF_STRCMP(elementName, "child") == 0) && attlist[0] &&
|
|
||||||
(RDF_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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
tokenizeElement (char* attr, char** attlist, char** elementName)
|
|
||||||
{
|
|
||||||
size_t n = 1;
|
|
||||||
size_t s = RDF_STRLEN(attr);
|
|
||||||
char c ;
|
|
||||||
size_t m = 0;
|
|
||||||
size_t atc = 0;
|
|
||||||
PRBool emptyTagp = (attr[s-2] == '/');
|
|
||||||
PRBool inAttrNamep = 1;
|
|
||||||
c = attr[n++];
|
|
||||||
while (wsc(c)) {
|
|
||||||
c = attr[n++];
|
|
||||||
}
|
|
||||||
*elementName = &attr[n-1];
|
|
||||||
while (n < s) {
|
|
||||||
if (wsc(c)) break;
|
|
||||||
c = attr[n++];
|
|
||||||
}
|
|
||||||
attr[n-1] = '\0';
|
|
||||||
while (atc < 2*MAX_ATTRIBUTES+1) {*(attlist + atc++) = NULL;}
|
|
||||||
atc = 0;
|
|
||||||
s = (emptyTagp ? s-2 : s-1);
|
|
||||||
while (n < s) {
|
|
||||||
PRBool attributeOpenStringSeenp = 0;
|
|
||||||
m = 0;
|
|
||||||
c = attr[n++];
|
|
||||||
while ((n <= s) && (atc < 2*MAX_ATTRIBUTES)) {
|
|
||||||
if (inAttrNamep && (m > 0) && (wsc(c) || (c == '='))) {
|
|
||||||
attr[n-1] = '\0';
|
|
||||||
*(attlist + atc++) = &attr[n-m-1];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (!inAttrNamep && attributeOpenStringSeenp && (c == '"')) {
|
|
||||||
attr[n-1] = '\0';
|
|
||||||
*(attlist + atc++) = &attr[n-m-1];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (inAttrNamep) {
|
|
||||||
if ((m > 0) || (!wsc(c))) m++;
|
|
||||||
} else {
|
|
||||||
if (c == '"') {
|
|
||||||
attributeOpenStringSeenp = 1;
|
|
||||||
} else {
|
|
||||||
if ((m > 0) || (!(wsc(c)))) m++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
c = attr[n++];
|
|
||||||
}
|
|
||||||
inAttrNamep = (inAttrNamep ? 0 : 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
outputRDFTreeInt (RDF rdf, PRFileDesc *fp, RDF_Resource node, uint32 depth, PRBool localOnly)
|
|
||||||
{
|
|
||||||
RDF_Cursor c = RDF_GetSources(rdf, node, gCoreVocab->RDF_parent, RDF_RESOURCE_TYPE, true);
|
|
||||||
RDF_Resource next;
|
|
||||||
char* buf = getMem(1024);
|
|
||||||
char* space = getMem((4*depth)+1);
|
|
||||||
char* url = resourceID(node);
|
|
||||||
char* name = RDF_GetResourceName(rdf, node);
|
|
||||||
char* hrefid;
|
|
||||||
|
|
||||||
if ((buf == NULL) || (space == NULL)) return;
|
|
||||||
if (depth > 0) memset(space, ' ', depth);
|
|
||||||
|
|
||||||
if (!RDF_STRCHR(url, ':') || (depth == 0)) {
|
|
||||||
hrefid = "id";
|
|
||||||
} else {
|
|
||||||
hrefid = "rdf:href";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (depth == 0) url="root";
|
|
||||||
|
|
||||||
if (containerp(node)) {
|
|
||||||
if (depth > 0) {
|
|
||||||
sprintf(buf, "%s<child>\n", space);
|
|
||||||
PR_Write(fp, buf, RDF_STRLEN(buf));
|
|
||||||
}
|
|
||||||
sprintf(buf, "%s<Topic %s=\"%s\"\n%s name=\"%s\">\n", space, hrefid, url, space, name);
|
|
||||||
PR_Write(fp, buf, RDF_STRLEN(buf));
|
|
||||||
|
|
||||||
while ((next = RDF_NextValue(c)) != NULL) {
|
|
||||||
|
|
||||||
/* if exporting EVERYTHING, need to skip over certain things */
|
|
||||||
if ((localOnly == PR_FALSE) || ((!startsWith("ftp:",url)) && (!startsWith("file:",url))
|
|
||||||
&& (!startsWith("IMAP:", url)) && (!startsWith("nes:", url))
|
|
||||||
&& (!startsWith("mail:", url)) && (!startsWith("cache:", url))
|
|
||||||
&& (!startsWith("ldap:", url)) &&
|
|
||||||
(!urlEquals(resourceID(node), resourceID(gNavCenter->RDF_LocalFiles))) &&
|
|
||||||
(!urlEquals(resourceID(node), resourceID(gNavCenter->RDF_History)))))
|
|
||||||
{
|
|
||||||
outputRDFTreeInt(rdf, fp, next, depth+1, localOnly);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sprintf(buf, "%s</Topic>\n", space);
|
|
||||||
PR_Write(fp, buf, RDF_STRLEN(buf));
|
|
||||||
if (depth > 0) {
|
|
||||||
sprintf(buf, "%s</child>\n", space);
|
|
||||||
PR_Write(fp, buf, RDF_STRLEN(buf));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
sprintf(buf, "%s<child %s=\"%s\"\n%s name=\"%s\"/>\n", space, hrefid, url, space, name);
|
|
||||||
PR_Write(fp, buf, RDF_STRLEN(buf));
|
|
||||||
}
|
|
||||||
RDF_DisposeCursor(c);
|
|
||||||
freeMem(buf);
|
|
||||||
freeMem(space);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
outputRDFTree (RDF rdf, PRFileDesc *fp, RDF_Resource node)
|
|
||||||
{
|
|
||||||
ht_fprintf(fp, "<RDF:RDF>\n\n");
|
|
||||||
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 (RDF_STRCMP(op, "true") == 0) {
|
|
||||||
tv = 1;
|
|
||||||
} else if (RDF_STRCMP(op, "false") == 0) {
|
|
||||||
tv = 0;
|
|
||||||
} else if (RDF_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
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,61 +0,0 @@
|
||||||
/* -*- 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 _RDF_RDFPARSE_H_
|
|
||||||
#define _RDF_RDFPARSE_H_
|
|
||||||
|
|
||||||
|
|
||||||
#include "rdf-int.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* rdfparse.c data structures and defines */
|
|
||||||
|
|
||||||
#define wsc(c) ((c == ' ') || (c == '\r') || (c == '\n') || (c == '\t'))
|
|
||||||
|
|
||||||
|
|
||||||
#define EXPECTING_OBJECT 21
|
|
||||||
#define EXPECTING_PROPERTY 22
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* rdfparse.c function prototypes */
|
|
||||||
|
|
||||||
NSPR_BEGIN_EXTERN_C
|
|
||||||
|
|
||||||
char decodeEntityRef (char* string, int32* stringIndexPtr, int32 len);
|
|
||||||
char * copyStringIgnoreWhiteSpace(char* string);
|
|
||||||
char * getHref(char** attlist);
|
|
||||||
void parseRDFProcessingInstruction (RDFFile f, char* token);
|
|
||||||
char * getAttributeValue (char** attlist, char* elName);
|
|
||||||
PRBool tagEquals (RDFFile f, char* tag1, char* tag2);
|
|
||||||
void addElementProps (char** attlist, char* elementName, RDFFile f, RDF_Resource obj);
|
|
||||||
PRBool knownObjectElement (char* eln);
|
|
||||||
char * possiblyMakeAbsolute (RDFFile f, char* url);
|
|
||||||
PRBool containerTagp (RDFFile f, char* elementName);
|
|
||||||
RDF_Resource ResourceFromElementName (RDFFile f, char* elementName);
|
|
||||||
void parseNextRDFToken (RDFFile f, char* token);
|
|
||||||
void tokenizeElement (char* attr, char** attlist, char** elementName);
|
|
||||||
void outputRDFTreeInt (RDF rdf, PRFileDesc *fp, RDF_Resource node, uint32 depth, PRBool localOnly);
|
|
||||||
void outputRDFTree (RDF rdf, PRFileDesc *fp, RDF_Resource node);
|
|
||||||
int parseNextRDFXMLBlobInt(RDFFile f, char* blob, int32 size) ;
|
|
||||||
|
|
||||||
NSPR_END_EXTERN_C
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,32 +0,0 @@
|
||||||
/* -*- 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 "plstr.h"
|
|
||||||
|
|
||||||
#define RDF_STRLEN(s) PL_strlen((s))
|
|
||||||
#define RDF_STRCMP(s1,s2) PL_strcmp((s1),(s2))
|
|
||||||
|
|
||||||
/* #define RDF_STRDUP(s) PL_strdup((s)) evil? */
|
|
||||||
|
|
||||||
#define RDF_STRCHR(s,c) PL_strchr((s),(c))
|
|
||||||
#define RDF_STRRCHR(s,c) PL_strrchr((s),(c))
|
|
||||||
#define RDF_STRCAT(dest,src) PL_strcat((dest),(src))
|
|
||||||
#define RDF_STRCASECMP(s1,s2) PL_strcasecmp((s1),(s2))
|
|
||||||
#define RDF_STRNCASECMP(s1,s2,n) PL_strncasecmp((s1),(s2),(n))
|
|
||||||
#define RDF_STRCASESTR(s1,s2) PL_strcasestr((s1),(s2))
|
|
||||||
|
|
|
@ -1,833 +0,0 @@
|
||||||
/* -*- 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 file implements remote store support for the rdf data model.
|
|
||||||
For more information on this file, contact rjc or guha
|
|
||||||
For more information on RDF, look at the RDF section of www.mozilla.org
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "remstore.h"
|
|
||||||
|
|
||||||
|
|
||||||
/* globals */
|
|
||||||
|
|
||||||
extern char *profileDirURL;
|
|
||||||
extern char *gBookmarkURL;
|
|
||||||
RDFT gLocalStore = 0;
|
|
||||||
|
|
||||||
RDFT
|
|
||||||
MakeRemoteStore (char* url)
|
|
||||||
{
|
|
||||||
if (startsWith("rdf:remoteStore", url)) {
|
|
||||||
if (gRemoteStore == 0) {
|
|
||||||
gRemoteStore = NewRemoteStore(url);
|
|
||||||
return gRemoteStore;
|
|
||||||
} else return gRemoteStore;
|
|
||||||
} else return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
RDFT
|
|
||||||
MakeFileDB (char* url)
|
|
||||||
{
|
|
||||||
if (RDF_STRCHR(url, ':') || endsWith(".rdf", url)) {
|
|
||||||
RDFT ntr = NewRemoteStore(url);
|
|
||||||
ntr->possiblyAccessFile = RDFFilePossiblyAccessFile ;
|
|
||||||
if ((RDF_STRCMP(gNavCntrUrl, url) == 0) || 1) /* just for testing */
|
|
||||||
readRDFFile(url, RDF_GetResource(NULL, url, 1), 0, ntr);
|
|
||||||
return ntr;
|
|
||||||
} else return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
PRBool
|
|
||||||
asEqual(RDFT r, Assertion as, RDF_Resource u, RDF_Resource s, void* v,
|
|
||||||
RDF_ValueType type)
|
|
||||||
{
|
|
||||||
return ((as->db == r) && (as->u == u) && (as->s == s) && (as->type == type) &&
|
|
||||||
((as->value == v) ||
|
|
||||||
((type == RDF_STRING_TYPE) && ((RDF_STRCMP(v, as->value) == 0) || (((char *)v)[0] =='\0')))));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Assertion
|
|
||||||
makeNewAssertion (RDFT r, RDF_Resource u, RDF_Resource s, void* v,
|
|
||||||
RDF_ValueType type, PRBool tv)
|
|
||||||
{
|
|
||||||
Assertion newAs = (Assertion) getMem(sizeof(struct RDF_AssertionStruct));
|
|
||||||
newAs->u = u;
|
|
||||||
newAs->s = s;
|
|
||||||
newAs->value = v;
|
|
||||||
newAs->type = type;
|
|
||||||
newAs->tv = tv;
|
|
||||||
newAs->db = r;
|
|
||||||
if (RDF_STRCMP(r->url, "rdf:history")) {
|
|
||||||
int n = 0;
|
|
||||||
}
|
|
||||||
return newAs;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
freeAssertion (Assertion as)
|
|
||||||
{
|
|
||||||
if (as->type == RDF_STRING_TYPE) {
|
|
||||||
freeMem(as->value);
|
|
||||||
}
|
|
||||||
freeMem(as);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
PRBool
|
|
||||||
remoteAssert (RDFT mcf, RDF_Resource u, RDF_Resource s, void* v,
|
|
||||||
RDF_ValueType type, PRBool tv)
|
|
||||||
{
|
|
||||||
return (remoteStoreAdd(mcf, u, s, v, type, tv) != NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
PRBool
|
|
||||||
remoteUnassert (RDFT mcf, RDF_Resource u, RDF_Resource s, void* v,
|
|
||||||
RDF_ValueType type)
|
|
||||||
{
|
|
||||||
return (remoteStoreRemove(mcf, u, s, v, type) != NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
PRBool
|
|
||||||
remoteAssert3 (RDFFile fi, RDFT mcf, RDF_Resource u, RDF_Resource s, void* v,
|
|
||||||
RDF_ValueType type, PRBool tv)
|
|
||||||
{
|
|
||||||
Assertion as = remoteStoreAdd(mcf, u, s, v, type, tv);
|
|
||||||
if (as != NULL) {
|
|
||||||
addToAssertionList(fi, as);
|
|
||||||
return 1;
|
|
||||||
} else return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
PRBool
|
|
||||||
remoteUnassert3 (RDFFile fi, RDFT mcf, RDF_Resource u, RDF_Resource s, void* v,
|
|
||||||
RDF_ValueType type)
|
|
||||||
{
|
|
||||||
Assertion as = remoteStoreRemove(mcf, u, s, v, type);
|
|
||||||
if (as != NULL) {
|
|
||||||
removeFromAssertionList(fi, as);
|
|
||||||
return 1;
|
|
||||||
} else return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
remoteStoreflushChildren(RDFT mcf, RDF_Resource parent)
|
|
||||||
{
|
|
||||||
RDF_Cursor c;
|
|
||||||
RDF_Resource child;
|
|
||||||
#if 0
|
|
||||||
RDF_Cursor cc;
|
|
||||||
RDF_Resource s;
|
|
||||||
char *value;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (parent == NULL) return;
|
|
||||||
if ((c = remoteStoreGetSlotValues (mcf, parent, gCoreVocab->RDF_parent,
|
|
||||||
RDF_RESOURCE_TYPE, true, true)) != NULL)
|
|
||||||
{
|
|
||||||
while((child = remoteStoreNextValue (mcf, c)) != NULL)
|
|
||||||
{
|
|
||||||
remoteStoreflushChildren(mcf, child);
|
|
||||||
|
|
||||||
/* XXX should we remove all arcs coming off of this node? */
|
|
||||||
#if 0
|
|
||||||
if ((cc = remoteStoreArcLabelsOut(mcf, child)) != NULL)
|
|
||||||
{
|
|
||||||
if ((s = remoteStoreNextValue (mcf, cc)) != NULL)
|
|
||||||
{
|
|
||||||
if (s == gCoreVocab->RDF_name)
|
|
||||||
{
|
|
||||||
value = remoteStoreGetSlotValue (mcf, child, s,
|
|
||||||
RDF_STRING_TYPE, PR_FALSE, PR_TRUE);
|
|
||||||
if (value != NULL)
|
|
||||||
{
|
|
||||||
remoteStoreRemove (mcf, child, s,
|
|
||||||
value, RDF_STRING_TYPE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
remoteStoreDisposeCursor(mcf, cc);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
remoteStoreRemove (mcf, child, gCoreVocab->RDF_parent,
|
|
||||||
parent, RDF_RESOURCE_TYPE);
|
|
||||||
}
|
|
||||||
remoteStoreDisposeCursor (mcf, c);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Assertion
|
|
||||||
remoteStoreAdd (RDFT mcf, RDF_Resource u, RDF_Resource s, void* v,
|
|
||||||
RDF_ValueType type, PRBool tv)
|
|
||||||
{
|
|
||||||
Assertion nextAs, prevAs, newAs;
|
|
||||||
nextAs = prevAs = u->rarg1;
|
|
||||||
|
|
||||||
if (s == gNavCenter->RDF_Command)
|
|
||||||
{
|
|
||||||
if ((type == RDF_RESOURCE_TYPE) && (tv) && (v == gNavCenter->RDF_Command_Refresh))
|
|
||||||
{
|
|
||||||
/* flush any children of 'u' */
|
|
||||||
remoteStoreflushChildren(mcf, u);
|
|
||||||
}
|
|
||||||
/* don't store RDF Commands in the remote store */
|
|
||||||
return(NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
while (nextAs != null) {
|
|
||||||
if (asEqual(mcf, nextAs, u, s, v, type)) return null;
|
|
||||||
prevAs = nextAs;
|
|
||||||
nextAs = nextAs->next;
|
|
||||||
}
|
|
||||||
newAs = makeNewAssertion(mcf, u, s, v, type, tv);
|
|
||||||
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(mcf, RDF_ASSERT_NOTIFY, u, s, v, type, tv);
|
|
||||||
return newAs;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Assertion
|
|
||||||
remoteStoreRemove (RDFT mcf, 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(mcf, nextAs, u, s, v, type)) {
|
|
||||||
if (prevAs == nextAs) {
|
|
||||||
u->rarg1 = nextAs->next;
|
|
||||||
} else {
|
|
||||||
prevAs->next = nextAs->next;
|
|
||||||
}
|
|
||||||
found = true;
|
|
||||||
ans = nextAs;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
prevAs = nextAs;
|
|
||||||
nextAs = nextAs->next;
|
|
||||||
}
|
|
||||||
if (found == false) return null;
|
|
||||||
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(mcf, RDF_DELETE_NOTIFY, u, s, v, type, ans->tv);
|
|
||||||
return ans;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static PRBool
|
|
||||||
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)) {
|
|
||||||
if (mark == true) f->lastReadTime = PR_Now();
|
|
||||||
return false; /* true; */
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
|
||||||
possiblyAccessFile (RDFT mcf, RDF_Resource u, RDF_Resource s, PRBool inversep)
|
|
||||||
{
|
|
||||||
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) &&
|
|
||||||
(startsWith(rdf->url, resourceID(u))) &&
|
|
||||||
|
|
||||||
(s == gCoreVocab->RDF_parent) && (containerp(u))) {
|
|
||||||
readRDFFile( resourceID(u), u, false, rdf);
|
|
||||||
/* if(newFile) newFile->lastReadTime = PR_Now(); */
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
PRBool
|
|
||||||
remoteStoreHasAssertion (RDFT mcf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type, PRBool tv)
|
|
||||||
{
|
|
||||||
Assertion nextAs;
|
|
||||||
if ((s == gNavCenter->RDF_Command) && (type == RDF_RESOURCE_TYPE) && (tv) && (v == gNavCenter->RDF_Command_Refresh))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void *
|
|
||||||
remoteStoreGetSlotValue (RDFT mcf, RDF_Resource u, RDF_Resource s, RDF_ValueType type, PRBool inversep, PRBool tv)
|
|
||||||
{
|
|
||||||
Assertion nextAs;
|
|
||||||
|
|
||||||
if ((s == gWebData->RDF_URL) && (tv) && (!inversep) && (type == RDF_STRING_TYPE))
|
|
||||||
{
|
|
||||||
return copyString(resourceID(u));
|
|
||||||
}
|
|
||||||
|
|
||||||
nextAs = (inversep ? u->rarg2 : u->rarg1);
|
|
||||||
while (nextAs != null) {
|
|
||||||
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) {
|
|
||||||
return copyString((char*)ans);
|
|
||||||
} else return ans;
|
|
||||||
}
|
|
||||||
nextAs = (inversep ? nextAs->invNext : nextAs->next);
|
|
||||||
}
|
|
||||||
if (s == gCoreVocab->RDF_parent) possiblyAccessFile(mcf, u, s, inversep);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
RDF_Cursor
|
|
||||||
remoteStoreGetSlotValuesInt (RDFT mcf, RDF_Resource u, RDF_Resource s, RDF_ValueType type, PRBool inversep, PRBool tv)
|
|
||||||
{
|
|
||||||
Assertion as = (inversep ? u->rarg2 : u->rarg1);
|
|
||||||
RDF_Cursor c;
|
|
||||||
if (as == null) {
|
|
||||||
possiblyAccessFile(mcf, u, s, inversep);
|
|
||||||
as = (inversep ? u->rarg2 : u->rarg1);
|
|
||||||
if (as == NULL) return null;
|
|
||||||
}
|
|
||||||
c = (RDF_Cursor)getMem(sizeof(struct RDF_CursorStruct));
|
|
||||||
c->u = u;
|
|
||||||
c->s = s;
|
|
||||||
c->type = type;
|
|
||||||
c->inversep = inversep;
|
|
||||||
c->tv = tv;
|
|
||||||
c->count = 0;
|
|
||||||
c->pdata = as;
|
|
||||||
return c;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
RDF_Cursor
|
|
||||||
remoteStoreGetSlotValues (RDFT mcf, RDF_Resource u, RDF_Resource s, RDF_ValueType type, PRBool inversep, PRBool tv)
|
|
||||||
{
|
|
||||||
|
|
||||||
return remoteStoreGetSlotValuesInt(mcf, u, s, type, inversep, tv);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
RDF_Cursor
|
|
||||||
remoteStoreArcLabelsIn (RDFT mcf, RDF_Resource u)
|
|
||||||
{
|
|
||||||
if (u->rarg2) {
|
|
||||||
RDF_Cursor c = (RDF_Cursor)getMem(sizeof(struct RDF_CursorStruct));
|
|
||||||
c->u = u;
|
|
||||||
c->queryType = RDF_ARC_LABELS_IN_QUERY;
|
|
||||||
c->pdata = u->rarg2;
|
|
||||||
return c;
|
|
||||||
} else return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
RDF_Cursor
|
|
||||||
remoteStoreArcLabelsOut (RDFT mcf, RDF_Resource u)
|
|
||||||
{
|
|
||||||
if (u->rarg1) {
|
|
||||||
RDF_Cursor c = (RDF_Cursor)getMem(sizeof(struct RDF_CursorStruct));
|
|
||||||
c->u = u;
|
|
||||||
c->queryType = RDF_ARC_LABELS_OUT_QUERY;
|
|
||||||
c->pdata = u->rarg1;
|
|
||||||
return c;
|
|
||||||
} else return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void *
|
|
||||||
arcLabelsOutNextValue (RDFT mcf, RDF_Cursor c)
|
|
||||||
{
|
|
||||||
while (c->pdata != null) {
|
|
||||||
Assertion as = (Assertion) c->pdata;
|
|
||||||
if ((as->db == mcf) && (as->u == c->u)) {
|
|
||||||
c->value = as->s;
|
|
||||||
c->pdata = as->next;
|
|
||||||
return c->value;
|
|
||||||
}
|
|
||||||
c->pdata = as->next;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void *
|
|
||||||
arcLabelsInNextValue (RDFT mcf, RDF_Cursor c)
|
|
||||||
{
|
|
||||||
while (c->pdata != null) {
|
|
||||||
Assertion as = (Assertion) c->pdata;
|
|
||||||
if ((as->db == mcf) && (as->value == c->u)) {
|
|
||||||
c->value = as->s;
|
|
||||||
c->pdata = as->invNext;
|
|
||||||
return c->value;
|
|
||||||
}
|
|
||||||
c->pdata = as->invNext;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void *
|
|
||||||
remoteStoreNextValue (RDFT mcf, RDF_Cursor c)
|
|
||||||
{
|
|
||||||
if (c->queryType == RDF_ARC_LABELS_OUT_QUERY) {
|
|
||||||
return arcLabelsOutNextValue(mcf, c);
|
|
||||||
} else if (c->queryType == RDF_ARC_LABELS_IN_QUERY) {
|
|
||||||
return arcLabelsInNextValue(mcf, c);
|
|
||||||
} else {
|
|
||||||
while (c->pdata != null) {
|
|
||||||
Assertion as = (Assertion) c->pdata;
|
|
||||||
if ((as->db == mcf) && (as->s == c->s) && (as->tv == c->tv) && (c->type == as->type)) {
|
|
||||||
c->value = (c->inversep ? as->u : as->value);
|
|
||||||
c->pdata = (c->inversep ? as->invNext : as->next);
|
|
||||||
return c->value;
|
|
||||||
}
|
|
||||||
c->pdata = (c->inversep ? as->invNext : as->next);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
RDF_Error
|
|
||||||
remoteStoreDisposeCursor (RDFT mcf, RDF_Cursor c)
|
|
||||||
{
|
|
||||||
freeMem(c);
|
|
||||||
return noRDFErr;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static RDFFile
|
|
||||||
leastRecentlyUsedRDFFile (RDF mcf)
|
|
||||||
{
|
|
||||||
RDFFile lru = mcf->files;
|
|
||||||
RDFFile f;
|
|
||||||
#ifndef HAVE_LONG_LONG
|
|
||||||
int64 result;
|
|
||||||
#endif /* !HAVE_LONG_LONG */
|
|
||||||
for (f = mcf->files ; (f != NULL) ; f = f->next) {
|
|
||||||
if (!f->locked) {
|
|
||||||
#ifndef HAVE_LONG_LONG
|
|
||||||
LL_SUB(result, lru->lastReadTime, f->lastReadTime);
|
|
||||||
if ((!LL_IS_ZERO(result) && LL_GE_ZERO(result)) && (f->localp == false))
|
|
||||||
#else
|
|
||||||
if (((lru->lastReadTime - f->lastReadTime) > 0) && (f->localp == false))
|
|
||||||
#endif /* !HAVE_LONG_LONG */
|
|
||||||
lru = f;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!lru->locked) {
|
|
||||||
return lru;
|
|
||||||
} else return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
gcRDFFileInt (RDFFile f)
|
|
||||||
{
|
|
||||||
int32 n = 0;
|
|
||||||
while (n < f->assertionCount) {
|
|
||||||
Assertion as = *(f->assertionList + n);
|
|
||||||
remoteStoreRemove(f->db, as->u, as->s, as->value, as->type);
|
|
||||||
freeAssertion(as);
|
|
||||||
*(f->assertionList + n) = NULL;
|
|
||||||
n++;
|
|
||||||
}
|
|
||||||
n = 0;
|
|
||||||
while (n < f->resourceCount) {
|
|
||||||
*(f->resourceList + n) = NULL;
|
|
||||||
n++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
RDF_Error
|
|
||||||
DeleteRemStore (RDFT db)
|
|
||||||
{
|
|
||||||
RDFFile f = (RDFFile) db->pdata;
|
|
||||||
RDFFile next;
|
|
||||||
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);
|
|
||||||
return 0;
|
|
||||||
} else return -1;
|
|
||||||
} else return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
gcRDFFile (RDFFile f)
|
|
||||||
{
|
|
||||||
RDFFile f1 = (RDFFile) f->db->pdata;
|
|
||||||
|
|
||||||
if (f->locked) return;
|
|
||||||
|
|
||||||
if (f == f1) {
|
|
||||||
f->db->pdata = f->next;
|
|
||||||
} else {
|
|
||||||
RDFFile prev = f1;
|
|
||||||
while (f1 != NULL) {
|
|
||||||
if (f1 == f) {
|
|
||||||
prev->next = f->next;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
prev = f1;
|
|
||||||
f1 = f1->next;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
gcRDFFileInt(f);
|
|
||||||
freeMem(f->assertionList);
|
|
||||||
freeMem(f->resourceList);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static PRBool
|
|
||||||
freeSomeRDFSpace (RDF mcf)
|
|
||||||
{
|
|
||||||
RDFFile lru = leastRecentlyUsedRDFFile (mcf);
|
|
||||||
if (lru== NULL) {
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
gcRDFFile(lru);
|
|
||||||
freeMem(lru);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
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;
|
|
||||||
} else {
|
|
||||||
RDFFile newFile = makeRDFFile(url, top, localp);
|
|
||||||
if (db->pdata) {
|
|
||||||
newFile->next = (RDFFile) db->pdata;
|
|
||||||
db->pdata = newFile;
|
|
||||||
} else {
|
|
||||||
db->pdata = (RDFFile) newFile;
|
|
||||||
}
|
|
||||||
newFile->assert = remoteAssert3;
|
|
||||||
newFile->unassert = remoteUnassert3;
|
|
||||||
if (top) {
|
|
||||||
if (resourceType(top) == RDF_RT) {
|
|
||||||
if (strstr(url, ".mcf")) {
|
|
||||||
newFile->fileType = RDF_MCF;
|
|
||||||
} else {
|
|
||||||
newFile->fileType = RDF_XML;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
newFile->fileType = resourceType(top);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
newFile->db = db;
|
|
||||||
return newFile;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
possiblyRefreshRDFFiles ()
|
|
||||||
{
|
|
||||||
RDFFile f = (RDFFile)gRemoteStore->pdata;
|
|
||||||
PRTime tm = PR_Now();
|
|
||||||
while (f != NULL) {
|
|
||||||
if (f->expiryTime != NULL) {
|
|
||||||
PRTime *expiry = f->expiryTime;
|
|
||||||
#ifdef HAVE_LONG_LONG
|
|
||||||
if ((tm - *expiry) > 0)
|
|
||||||
#else
|
|
||||||
int64 result;
|
|
||||||
LL_SUB(result, tm, *expiry);
|
|
||||||
if ((!LL_IS_ZERO(result) && LL_GE_ZERO(result)))
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
gcRDFFile (f);
|
|
||||||
initRDFFile(f);
|
|
||||||
beginReadingRDFFile(f);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
f = f->next;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
SCookPossiblyAccessFile (RDFT rdf, RDF_Resource u, RDF_Resource s, PRBool inversep)
|
|
||||||
{
|
|
||||||
/*if ((resourceType(u) == RDF_RT) && (startsWith("rdf:ht", rdf->url)) &&
|
|
||||||
(s == gCoreVocab->RDF_parent) &&
|
|
||||||
(containerp(u))) {
|
|
||||||
RDFFile newFile = readRDFFile( resourceID(u), u, false, rdf);
|
|
||||||
if(newFile) newFile->lastReadTime = PR_Now();
|
|
||||||
} */
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
RDFT
|
|
||||||
NewRemoteStore (char* url)
|
|
||||||
{
|
|
||||||
RDFT ntr;
|
|
||||||
|
|
||||||
if ((ntr = (RDFT)getMem(sizeof(struct RDF_TranslatorStruct))) != NULL)
|
|
||||||
{
|
|
||||||
ntr->getSlotValue = remoteStoreGetSlotValue;
|
|
||||||
ntr->getSlotValues = remoteStoreGetSlotValues;
|
|
||||||
ntr->hasAssertion = remoteStoreHasAssertion;
|
|
||||||
ntr->nextValue = remoteStoreNextValue;
|
|
||||||
ntr->disposeCursor = remoteStoreDisposeCursor;
|
|
||||||
ntr->url = copyString(url);
|
|
||||||
ntr->destroy = DeleteRemStore;
|
|
||||||
ntr->arcLabelsIn = remoteStoreArcLabelsIn;
|
|
||||||
ntr->arcLabelsOut = remoteStoreArcLabelsOut;
|
|
||||||
ntr->update = remStoreUpdate;
|
|
||||||
}
|
|
||||||
return(ntr);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
RDFT
|
|
||||||
MakeSCookDB (char* url)
|
|
||||||
{
|
|
||||||
if (startsWith("rdf:scook:", url) || (startsWith("rdf:ht", url))) {
|
|
||||||
RDFT ntr = NewRemoteStore(url);
|
|
||||||
ntr->possiblyAccessFile = SCookPossiblyAccessFile;
|
|
||||||
return ntr;
|
|
||||||
} else return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
RDFT
|
|
||||||
MakeLocalStore (char* url)
|
|
||||||
{
|
|
||||||
char* file = makeRDFDBURL(profileDirURL, "localStore.rdf");
|
|
||||||
RDFT ntr = NewRemoteStore(file);
|
|
||||||
gLocalStore = ntr;
|
|
||||||
ntr->assert = remoteAssert;
|
|
||||||
ntr->unassert = remoteUnassert;
|
|
||||||
return ntr;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
addToRDFTOut (RDFTOut out)
|
|
||||||
{
|
|
||||||
int32 len = RDF_STRLEN(out->temp);
|
|
||||||
if (len + out->bufferPos < out->bufferSize) {
|
|
||||||
RDF_STRCAT(out->buffer, out->temp);
|
|
||||||
out->bufferPos = out->bufferPos + len;
|
|
||||||
memset(out->temp, '\0', 1000);
|
|
||||||
} else {
|
|
||||||
PR_Realloc(out->buffer, out->bufferSize + 20000);
|
|
||||||
out->bufferSize = out->bufferSize + 20000;
|
|
||||||
addToRDFTOut (out);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
PRIntn
|
|
||||||
RDFSerializerEnumerator (PLHashEntry *he, PRIntn i, void *arg)
|
|
||||||
{
|
|
||||||
RDF_Resource u = (RDF_Resource)he->value;
|
|
||||||
RDFTOut out = (RDFTOut) arg;
|
|
||||||
Assertion as = u->rarg1;
|
|
||||||
PRBool somethingOutp = 0;
|
|
||||||
while (as) {
|
|
||||||
if (as->db == out->store) {
|
|
||||||
if (!somethingOutp) {
|
|
||||||
somethingOutp = 1;
|
|
||||||
sprintf(out->temp, "<RDF:Description href=\"%s\">\n", resourceID(as->u));
|
|
||||||
addToRDFTOut(out);
|
|
||||||
}
|
|
||||||
if (as->type == RDF_RESOURCE_TYPE) {
|
|
||||||
sprintf(out->temp, " <%s href=\"%s\"/>\n", resourceID(as->s),
|
|
||||||
resourceID((RDF_Resource)as->value));
|
|
||||||
} else if (as->type == RDF_INT_TYPE) {
|
|
||||||
sprintf(out->temp, " <%s dt=\"int\">%i</%s>\n", resourceID(as->s),
|
|
||||||
(int)as->value, resourceID(as->s));
|
|
||||||
} else {
|
|
||||||
sprintf(out->temp, " <%s>%s</%s>\n", resourceID(as->s),
|
|
||||||
(char*)as->value, resourceID(as->s));
|
|
||||||
}
|
|
||||||
addToRDFTOut(out);
|
|
||||||
}
|
|
||||||
as = as->next;
|
|
||||||
}
|
|
||||||
if (somethingOutp) {
|
|
||||||
sprintf(out->temp, "</RDF:Description>\n\n");
|
|
||||||
addToRDFTOut(out);
|
|
||||||
}
|
|
||||||
return HT_ENUMERATE_NEXT;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
char*
|
|
||||||
RDF_SerializeRDFStore (RDFT store) {
|
|
||||||
RDFTOut out = getMem(sizeof(struct RDFTOutStruct));
|
|
||||||
char* ans = out->buffer = getMem(20000);
|
|
||||||
out->bufferSize = 20000;
|
|
||||||
out->temp = getMem(1000);
|
|
||||||
out->store = store;
|
|
||||||
sprintf(out->temp, "<RDF:RDF>\n\n");
|
|
||||||
addToRDFTOut(out);
|
|
||||||
PL_HashTableEnumerateEntries(resourceHash, RDFSerializerEnumerator, out);
|
|
||||||
sprintf(out->temp, "</RDF:RDF>\n\n");
|
|
||||||
addToRDFTOut(out);
|
|
||||||
freeMem(out->temp);
|
|
||||||
freeMem(out);
|
|
||||||
return ans;
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,85 +0,0 @@
|
||||||
/* -*- 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 _RDF_REMSTORE_H_
|
|
||||||
#define _RDF_REMSTORE_H_
|
|
||||||
|
|
||||||
|
|
||||||
#include "rdf-int.h"
|
|
||||||
#include "utils.h"
|
|
||||||
#include "prtime.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* remstore.c data structures and defines */
|
|
||||||
|
|
||||||
struct RDFTOutStruct {
|
|
||||||
char *buffer;
|
|
||||||
int32 bufferSize;
|
|
||||||
int32 bufferPos;
|
|
||||||
char *temp;
|
|
||||||
RDFT store;
|
|
||||||
};
|
|
||||||
typedef struct RDFTOutStruct *RDFTOut;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* remstore.c function prototypes */
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
RDFT MakeRemoteStore (char* url);
|
|
||||||
RDFT existingRDFFileDB (char* url);
|
|
||||||
RDFT MakeFileDB (char* url);
|
|
||||||
void freeAssertion (Assertion as);
|
|
||||||
PRBool remoteAssert3 (RDFFile fi, RDFT mcf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type, PRBool tv);
|
|
||||||
PRBool remoteUnassert3 (RDFFile fi, RDFT mcf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type);
|
|
||||||
void remoteStoreflushChildren(RDFT mcf, RDF_Resource parent);
|
|
||||||
Assertion remoteStoreAdd (RDFT mcf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type, PRBool tv);
|
|
||||||
Assertion remoteStoreRemove (RDFT mcf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type);
|
|
||||||
PRBool fileReadablep (char* id);
|
|
||||||
PRBool remoteStoreHasAssertionInt (RDFT mcf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type, PRBool tv);
|
|
||||||
PRBool remoteStoreHasAssertion (RDFT mcf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type, PRBool tv);
|
|
||||||
void * remoteStoreGetSlotValue (RDFT mcf, RDF_Resource u, RDF_Resource s, RDF_ValueType type, PRBool inversep, PRBool tv);
|
|
||||||
RDF_Cursor remoteStoreGetSlotValuesInt (RDFT mcf, RDF_Resource u, RDF_Resource s, RDF_ValueType type, PRBool inversep, PRBool tv);
|
|
||||||
RDF_Cursor remoteStoreGetSlotValues (RDFT mcf, RDF_Resource u, RDF_Resource s, RDF_ValueType type, PRBool inversep, PRBool tv);
|
|
||||||
RDF_Cursor remoteStoreArcLabelsIn (RDFT mcf, RDF_Resource u);
|
|
||||||
RDF_Cursor remoteStoreArcLabelsOut (RDFT mcf, RDF_Resource u);
|
|
||||||
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);
|
|
||||||
RDF_Error DeleteRemStore (RDFT db);
|
|
||||||
RDF_Error remStoreUpdate (RDFT db, RDF_Resource u);
|
|
||||||
void gcRDFFile (RDFFile f);
|
|
||||||
void RDFFilePossiblyAccessFile (RDFT rdf, RDF_Resource u, RDF_Resource s, PRBool inversep);
|
|
||||||
void possiblyRefreshRDFFiles ();
|
|
||||||
void SCookPossiblyAccessFile (RDFT rdf, RDF_Resource u, RDF_Resource s, PRBool inversep);
|
|
||||||
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);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
806
rdf/src/utils.c
806
rdf/src/utils.c
|
@ -1,806 +0,0 @@
|
||||||
/* -*- 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 file implements utility routines for the rdf data model.
|
|
||||||
For more information on this file, contact rjc or guha
|
|
||||||
For more information on RDF, look at the RDF section of www.mozilla.org
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#include "utils.h"
|
|
||||||
#include "vocabint.h"
|
|
||||||
|
|
||||||
|
|
||||||
/* globals */
|
|
||||||
PRBool rdfDBInited = 0;
|
|
||||||
PLHashTable* resourceHash = 0;
|
|
||||||
PLHashTable* dataSourceHash = 0;
|
|
||||||
RDFT gRemoteStore = 0;
|
|
||||||
RDFT gSessionDB = 0;
|
|
||||||
|
|
||||||
/* externs */
|
|
||||||
extern char *profileDirURL;
|
|
||||||
|
|
||||||
#define INITIAL_RESOURCE_LIST_SIZE 50
|
|
||||||
#define INITIAL_ASSERTION_LIST_SIZE 100
|
|
||||||
#define GROW_LIST_INCR 50
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int
|
|
||||||
compareStrings(char *s1, char *s2)
|
|
||||||
{
|
|
||||||
return RDF_STRCASECMP(s1, s2);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
char *
|
|
||||||
makeRDFDBURL(char* directory, char* name)
|
|
||||||
{
|
|
||||||
char *ans;
|
|
||||||
size_t s;
|
|
||||||
|
|
||||||
if (profileDirURL == NULL) return NULL;
|
|
||||||
if ((ans = (char*) getMem(RDF_STRLEN(profileDirURL) + strlen(directory) + strlen(name) + 3)) != NULL) {
|
|
||||||
s = RDF_STRLEN(profileDirURL);
|
|
||||||
memcpy(ans, profileDirURL, s);
|
|
||||||
if (ans[s-1] != '/') {
|
|
||||||
ans[s++] = '/';
|
|
||||||
}
|
|
||||||
stringAppend(ans, directory);
|
|
||||||
stringAppend(ans, "/");
|
|
||||||
stringAppend(ans, name);
|
|
||||||
}
|
|
||||||
return(ans);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
RDF_Resource
|
|
||||||
getMCFFrtop (char* furl)
|
|
||||||
{
|
|
||||||
char* url = getBaseURL(furl);
|
|
||||||
RDF_Resource r;
|
|
||||||
r = RDF_GetResource(NULL, url, 1);
|
|
||||||
freeMem(url);
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
char*
|
|
||||||
copyString (const char* url) {
|
|
||||||
int32 len = RDF_STRLEN(url);
|
|
||||||
char* newStr = (char*)getMem(len+1);
|
|
||||||
if (newStr != NULL) {
|
|
||||||
memcpy(newStr, url, len);
|
|
||||||
}
|
|
||||||
return newStr;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
RDFFile
|
|
||||||
makeRDFFile (char* url, RDF_Resource top, PRBool localp)
|
|
||||||
{
|
|
||||||
RDFFile ans = (RDFFile)getMem(sizeof(struct RDF_FileStruct));
|
|
||||||
/* ans->rdf = rdf; */
|
|
||||||
ans->url = getBaseURL(url);
|
|
||||||
ans->top = top;
|
|
||||||
ans->localp = localp;
|
|
||||||
if (!localp) ans->refreshingp = PR_TRUE;
|
|
||||||
initRDFFile(ans);
|
|
||||||
return ans;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
initRDFFile (RDFFile ans)
|
|
||||||
{
|
|
||||||
char* url = ans->url;
|
|
||||||
ans->rtop = getMCFFrtop(url);
|
|
||||||
ans->line = (char*)getMem(RDF_BUF_SIZE);
|
|
||||||
ans->currentSlot = (char*)getMem(100);
|
|
||||||
ans->resourceList = (RDF_Resource*)getMem(INITIAL_RESOURCE_LIST_SIZE * sizeof(RDF_Resource));
|
|
||||||
ans->assertionList = (Assertion*)getMem(INITIAL_ASSERTION_LIST_SIZE * sizeof(Assertion));
|
|
||||||
ans->resourceListSize = INITIAL_RESOURCE_LIST_SIZE;
|
|
||||||
ans->assertionListSize = INITIAL_ASSERTION_LIST_SIZE;
|
|
||||||
ans->holdOver = (char*)getMem(RDF_BUF_SIZE);
|
|
||||||
ans->depth = 1;
|
|
||||||
ans->lastItem = ans->stack[0] = ans->top;
|
|
||||||
ans->locked = ans->localp;
|
|
||||||
ans->lineSize = LINE_SIZE;
|
|
||||||
ans->tv = true;
|
|
||||||
ans->resourceCount = 0;
|
|
||||||
ans->assertionCount = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
addToResourceList (RDFFile f, RDF_Resource u)
|
|
||||||
{
|
|
||||||
if (f->resourceListSize == f->resourceCount) {
|
|
||||||
RDF_Resource* newResourceList = (RDF_Resource*)getMem(sizeof(RDF_Resource)*(f->resourceListSize + GROW_LIST_INCR));
|
|
||||||
RDF_Resource* old = f->resourceList;
|
|
||||||
memcpy((char*)newResourceList, (char*)f->resourceList, sizeof(RDF_Resource)*f->resourceListSize);
|
|
||||||
f->resourceList = newResourceList;
|
|
||||||
f->resourceListSize = f->resourceListSize + GROW_LIST_INCR;
|
|
||||||
freeMem(old);
|
|
||||||
}
|
|
||||||
*(f->resourceList + f->resourceCount++) = u;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
addToAssertionList (RDFFile f, Assertion as)
|
|
||||||
{
|
|
||||||
if (f->assertionListSize == f->assertionCount) {
|
|
||||||
Assertion* newAssertionList = (Assertion*)getMem(sizeof(RDF_Resource)*(f->assertionListSize + GROW_LIST_INCR));
|
|
||||||
Assertion* old = f->assertionList;
|
|
||||||
memcpy((char*)newAssertionList, (char*)f->assertionList, sizeof(RDF_Resource)*f->assertionListSize);
|
|
||||||
f->assertionList = newAssertionList;
|
|
||||||
f->assertionListSize = f->assertionListSize + GROW_LIST_INCR;
|
|
||||||
freeMem(old);
|
|
||||||
}
|
|
||||||
*(f->assertionList + f->assertionCount++) = as;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
removeFromAssertionList(RDFFile f, Assertion as)
|
|
||||||
{
|
|
||||||
/* XXX implement */
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
ht_fprintf(PRFileDesc *file, const char *fmt, ...)
|
|
||||||
{
|
|
||||||
va_list ap;
|
|
||||||
char *buf;
|
|
||||||
va_start(ap, fmt);
|
|
||||||
buf = PR_smprintf(fmt, ap);
|
|
||||||
va_end(ap);
|
|
||||||
if(buf) {
|
|
||||||
PR_Write(file, buf, RDF_STRLEN(buf));
|
|
||||||
free(buf);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
ht_rjcprintf(PRFileDesc *file, const char *fmt, const char *data)
|
|
||||||
{
|
|
||||||
char *buf;
|
|
||||||
|
|
||||||
buf = PR_smprintf(fmt, data);
|
|
||||||
if(buf) {
|
|
||||||
PR_Write(file, buf, RDF_STRLEN(buf));
|
|
||||||
free(buf);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
char *
|
|
||||||
makeDBURL(char* name)
|
|
||||||
{
|
|
||||||
char *ans;
|
|
||||||
size_t s;
|
|
||||||
|
|
||||||
if (profileDirURL == NULL) return NULL;
|
|
||||||
if ((ans = (char*) getMem(RDF_STRLEN(profileDirURL) + strlen(name) + 3)) != NULL) {
|
|
||||||
s = RDF_STRLEN(profileDirURL);
|
|
||||||
memcpy(ans, profileDirURL, s);
|
|
||||||
if (ans[s-1] != '/') {
|
|
||||||
ans[s++] = '/';
|
|
||||||
}
|
|
||||||
memcpy(&ans[s], name, RDF_STRLEN(name));
|
|
||||||
|
|
||||||
#ifdef XP_WIN
|
|
||||||
if (ans[9] == '|') ans[9] = ':';
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
return(ans);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
PLHashNumber
|
|
||||||
idenHash (const void *key)
|
|
||||||
{
|
|
||||||
return (PLHashNumber)key;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int
|
|
||||||
idenEqual (const void *v1, const void *v2)
|
|
||||||
{
|
|
||||||
return (v1 == v2);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
PRBool
|
|
||||||
inverseTV (PRBool tv)
|
|
||||||
{
|
|
||||||
if (tv == true) {
|
|
||||||
return false;
|
|
||||||
} else return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
char *
|
|
||||||
append2Strings (const char* str1, const char* str2)
|
|
||||||
{
|
|
||||||
int32 l1 = RDF_STRLEN(str1);
|
|
||||||
int32 len = l1 + RDF_STRLEN(str2);
|
|
||||||
char* ans = (char*) getMem(len+1);
|
|
||||||
memcpy(ans, str1, l1);
|
|
||||||
memcpy(&ans[l1], str2, len-l1);
|
|
||||||
return ans;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
stringAppendBase (char* dest, const char* addition)
|
|
||||||
{
|
|
||||||
int32 l1 = RDF_STRLEN(dest);
|
|
||||||
int32 l2 = RDF_STRLEN(addition);
|
|
||||||
int32 l3 = charSearch('#', addition);
|
|
||||||
if (l3 != -1) l2 = l3;
|
|
||||||
memcpy(&dest[l1], addition, l2);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
stringAppend (char* dest, const char* addition)
|
|
||||||
{
|
|
||||||
int32 l1 = RDF_STRLEN(dest);
|
|
||||||
int32 l2 = RDF_STRLEN(addition);
|
|
||||||
memcpy(&dest[l1], addition, l2);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int16
|
|
||||||
charSearch (const char c, const char* data)
|
|
||||||
{
|
|
||||||
char* ch = RDF_STRCHR(data, c);
|
|
||||||
|
|
||||||
if (ch) {
|
|
||||||
return (ch - data);
|
|
||||||
} else {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
PRBool
|
|
||||||
endsWith (const char* pattern, const char* uuid)
|
|
||||||
{
|
|
||||||
short l1 = RDF_STRLEN(pattern);
|
|
||||||
short l2 = RDF_STRLEN(uuid);
|
|
||||||
short index;
|
|
||||||
|
|
||||||
if (l2 < l1) return false;
|
|
||||||
|
|
||||||
for (index = 1; index <= l1; index++) {
|
|
||||||
if (toupper(pattern[l1-index]) != toupper(uuid[l2-index])) return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
PR_PUBLIC_API(PRBool)
|
|
||||||
startsWith (const char* pattern, const char* uuid)
|
|
||||||
{
|
|
||||||
short l1 = RDF_STRLEN(pattern);
|
|
||||||
short l2 = RDF_STRLEN(uuid);
|
|
||||||
if (l2 < l1) return false;
|
|
||||||
return (RDF_STRNCASECMP(pattern, uuid, l1) == 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
PRBool
|
|
||||||
substring (const char* pattern, const char* data)
|
|
||||||
{
|
|
||||||
char *p = RDF_STRCASESTR(data, pattern);
|
|
||||||
return p != NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int16
|
|
||||||
revCharSearch (const char c, const char* data)
|
|
||||||
{
|
|
||||||
char *p = RDF_STRRCHR(data, c);
|
|
||||||
return p ? p-data : -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
PRBool
|
|
||||||
urlEquals (const char* url1, const char* url2)
|
|
||||||
{
|
|
||||||
int16 n1 = charSearch('#', url1);
|
|
||||||
int16 n2 = charSearch('#', url2);
|
|
||||||
if ((n1 == -1) && (n2 == -1)) {
|
|
||||||
return (RDF_STRCMP(url1, url2) == 0);
|
|
||||||
} else if ((n2 == -1) && (n1 > 0)) {
|
|
||||||
return ((RDF_STRLEN(url2) == (size_t)(n1)) && (strncmp(url1, url2, n1) == 0));
|
|
||||||
} else if ((n1 == -1) && (size_t) (n2 > 0)) {
|
|
||||||
return ((RDF_STRLEN(url1) == (size_t)(n2)) && (strncmp(url1, url2, n2) == 0));
|
|
||||||
} else return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
PRBool
|
|
||||||
isSeparator (RDF_Resource r)
|
|
||||||
{
|
|
||||||
return (startsWith("separator", resourceID(r)) || startsWith("nc:separator", resourceID(r))) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
extern char* gBookmarkURL;
|
|
||||||
PR_PUBLIC_API(void)
|
|
||||||
SetBookmarkURL(const char* url) {
|
|
||||||
gBookmarkURL = copyString(url);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
char *
|
|
||||||
getBaseURL (const char* url)
|
|
||||||
{
|
|
||||||
int n = charSearch('#' , url);
|
|
||||||
char* ans;
|
|
||||||
if (n == -1) return copyString(url);
|
|
||||||
if (n == 0) return NULL;
|
|
||||||
ans = getMem(n+1);
|
|
||||||
memcpy(ans, url, n);
|
|
||||||
return ans;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
setContainerp (RDF_Resource r, PRBool val)
|
|
||||||
{
|
|
||||||
if (val) {
|
|
||||||
r->flags |= CONTAINER_FLAG;
|
|
||||||
} else {
|
|
||||||
r->flags &= (~CONTAINER_FLAG);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
PRBool
|
|
||||||
containerp (RDF_Resource r)
|
|
||||||
{
|
|
||||||
return (r->flags & CONTAINER_FLAG);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
setLockedp (RDF_Resource r, PRBool val)
|
|
||||||
{
|
|
||||||
if (val) {
|
|
||||||
r->flags |= LOCKED_FLAG;
|
|
||||||
} else {
|
|
||||||
r->flags &= (~LOCKED_FLAG);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
PRBool
|
|
||||||
lockedp (RDF_Resource r)
|
|
||||||
{
|
|
||||||
return (r->flags & LOCKED_FLAG);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
uint8
|
|
||||||
resourceType (RDF_Resource r)
|
|
||||||
{
|
|
||||||
return r->type;
|
|
||||||
}
|
|
||||||
|
|
||||||
PR_PUBLIC_API(char*)
|
|
||||||
RDF_ResourceID(RDF_Resource u) {
|
|
||||||
return u->url;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
setResourceType (RDF_Resource r, uint8 val)
|
|
||||||
{
|
|
||||||
r->type = val;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
char *
|
|
||||||
resourceID(RDF_Resource r)
|
|
||||||
{
|
|
||||||
return r->url;
|
|
||||||
}
|
|
||||||
|
|
||||||
char* opTypeToString (RDF_EventType opType) {
|
|
||||||
switch (opType) {
|
|
||||||
case RDF_ASSERT_NOTIFY :
|
|
||||||
return "Assert";
|
|
||||||
case RDF_INSERT_NOTIFY :
|
|
||||||
return "Insert";
|
|
||||||
case RDF_DELETE_NOTIFY :
|
|
||||||
return "Unassert";
|
|
||||||
}
|
|
||||||
return "Unknown Op";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void traceNotify (char* event, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type) {
|
|
||||||
#ifdef DEBUG_guha1
|
|
||||||
char* traceLine = getMem(1000);
|
|
||||||
if (type == RDF_INT_TYPE) {
|
|
||||||
sprintf(traceLine, "%s %s(%s, %i)\n",
|
|
||||||
event, resourceID(s), resourceID(u), (int) v);
|
|
||||||
} else if (type == RDF_STRING_TYPE){
|
|
||||||
sprintf(traceLine, "%s %s(%s, \"%s\")\n",
|
|
||||||
event, resourceID(s), resourceID(u), (char*) v);
|
|
||||||
} else if (type == RDF_RESOURCE_TYPE) {
|
|
||||||
sprintf(traceLine, "%s %s(%s, %s)\n",
|
|
||||||
event, resourceID(s), resourceID(u), resourceID((RDF_Resource)v));
|
|
||||||
} else {
|
|
||||||
sprintf(traceLine, "%s <gubbish>\n", event);
|
|
||||||
}
|
|
||||||
FE_Trace(traceLine);
|
|
||||||
freeMem(traceLine);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
char *
|
|
||||||
makeResourceName (RDF_Resource node)
|
|
||||||
{
|
|
||||||
char *name = NULL;
|
|
||||||
|
|
||||||
name = resourceID(node);
|
|
||||||
if (startsWith("http:", resourceID(node)))
|
|
||||||
{
|
|
||||||
name = &name[7];
|
|
||||||
}
|
|
||||||
else if (startsWith("file:", resourceID(node)))
|
|
||||||
{
|
|
||||||
name = &name[FS_URL_OFFSET];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
name = resourceID(node);
|
|
||||||
|
|
||||||
}
|
|
||||||
return ((name != NULL) ? copyString(name) : NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
PR_PUBLIC_API(char *)
|
|
||||||
RDF_GetResourceName(RDF rdf, RDF_Resource node)
|
|
||||||
{
|
|
||||||
char* name = RDF_GetSlotValue(rdf, node, gCoreVocab->RDF_name, RDF_STRING_TYPE, false, true);
|
|
||||||
if (name != NULL) return name;
|
|
||||||
name = makeResourceName(node);
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef MOZILLA_CLIENT
|
|
||||||
PR_PUBLIC_API(RDF_Resource)
|
|
||||||
RDFUtil_GetFirstInstance (RDF_Resource type, char* defaultURL)
|
|
||||||
{
|
|
||||||
|
|
||||||
RDF_Resource bmk = remoteStoreGetSlotValue(gLocalStore, type,
|
|
||||||
gCoreVocab->RDF_instanceOf,
|
|
||||||
RDF_RESOURCE_TYPE, true, true);
|
|
||||||
if (bmk == NULL) {
|
|
||||||
/* bmk = RDF_GetResource(NULL, defaultURL, 1); */
|
|
||||||
bmk = createContainer(defaultURL);
|
|
||||||
remoteAssert(gLocalStore, bmk, gCoreVocab->RDF_instanceOf,
|
|
||||||
type, RDF_RESOURCE_TYPE, 1);
|
|
||||||
}
|
|
||||||
return bmk;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
PR_PUBLIC_API(void)
|
|
||||||
RDFUtil_SetFirstInstance (RDF_Resource type, RDF_Resource item)
|
|
||||||
{
|
|
||||||
RDF_Resource bmk = remoteStoreGetSlotValue(gLocalStore, type,
|
|
||||||
gCoreVocab->RDF_instanceOf,
|
|
||||||
RDF_RESOURCE_TYPE, true, true);
|
|
||||||
if (bmk) {
|
|
||||||
remoteUnassert(gLocalStore, bmk, gCoreVocab->RDF_instanceOf,
|
|
||||||
type, RDF_RESOURCE_TYPE);
|
|
||||||
}
|
|
||||||
if (item) {
|
|
||||||
remoteAssert(gLocalStore, item, gCoreVocab->RDF_instanceOf,
|
|
||||||
type, RDF_RESOURCE_TYPE, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
PR_PUBLIC_API(RDF_Resource)
|
|
||||||
RDFUtil_GetQuickFileFolder()
|
|
||||||
{
|
|
||||||
return RDFUtil_GetFirstInstance(gNavCenter->RDF_BookmarkFolderCategory, "NC:Bookmarks");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
PR_PUBLIC_API(void)
|
|
||||||
RDFUtil_SetQuickFileFolder(RDF_Resource container)
|
|
||||||
{
|
|
||||||
RDFUtil_SetFirstInstance(gNavCenter->RDF_BookmarkFolderCategory, container);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
RDF_Resource gPTFolder = NULL;
|
|
||||||
PR_PUBLIC_API(RDF_Resource)
|
|
||||||
RDFUtil_GetPTFolder()
|
|
||||||
{
|
|
||||||
if (gPTFolder) return gPTFolder;
|
|
||||||
return (gPTFolder = RDFUtil_GetFirstInstance(gNavCenter->RDF_PersonalToolbarFolderCategory, "PersonalToolbar"));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
PR_PUBLIC_API(void)
|
|
||||||
RDFUtil_SetPTFolder(RDF_Resource container)
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
RDFUtil_SetFirstInstance( gNavCenter->RDF_PersonalToolbarFolderCategory, container);
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
PR_PUBLIC_API(RDF_Resource)
|
|
||||||
RDFUtil_GetNewBookmarkFolder()
|
|
||||||
{
|
|
||||||
return RDFUtil_GetFirstInstance(gNavCenter->RDF_NewBookmarkFolderCategory, "NC:Bookmarks");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
PR_PUBLIC_API(void)
|
|
||||||
RDFUtil_SetNewBookmarkFolder(RDF_Resource container)
|
|
||||||
{
|
|
||||||
RDFUtil_SetFirstInstance(gNavCenter->RDF_NewBookmarkFolderCategory, container);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
PR_PUBLIC_API(RDF_Resource)
|
|
||||||
RDFUtil_GetDefaultSelectedView()
|
|
||||||
{
|
|
||||||
return RDFUtil_GetFirstInstance(gNavCenter->RDF_DefaultSelectedView, "selectedView");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
PR_PUBLIC_API(void)
|
|
||||||
RDFUtil_SetDefaultSelectedView(RDF_Resource container)
|
|
||||||
{
|
|
||||||
RDFUtil_SetFirstInstance(gNavCenter->RDF_DefaultSelectedView, container);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Returns a new string with inURL unescaped. */
|
|
||||||
/* We return a new string because NET_UnEscape unescapes */
|
|
||||||
/* string in place */
|
|
||||||
char *
|
|
||||||
unescapeURL(char *inURL)
|
|
||||||
{
|
|
||||||
char *escapedPath = copyString(inURL);
|
|
||||||
|
|
||||||
#ifdef MOZILLA_CLIENT
|
|
||||||
#ifdef XP_WIN
|
|
||||||
replacePipeWithColon(escapedPath);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* xxx NET_UnEscape(escapedPath); */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return (escapedPath);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Given a file URL of form "file:///", return substring */
|
|
||||||
/* that can be used as a path for PR_Open. */
|
|
||||||
/* NOTE: This routine DOESN'T allocate a new string */
|
|
||||||
|
|
||||||
|
|
||||||
char *
|
|
||||||
convertFileURLToNSPRCopaceticPath(char* inURL)
|
|
||||||
{
|
|
||||||
#ifdef XP_WIN
|
|
||||||
if (startsWith("file://", inURL)) return (inURL + 8);
|
|
||||||
else if (startsWith("mailbox:/", inURL)) return (inURL + 9);
|
|
||||||
else if (startsWith("IMAP:/", inURL)) return (inURL + 6);
|
|
||||||
else return (inURL);
|
|
||||||
#else
|
|
||||||
/* For Mac & Unix, need preceeding '/' so that NSPR */
|
|
||||||
/* interprets path as full path */
|
|
||||||
if (startsWith("file://", inURL)) return (inURL + 7);
|
|
||||||
else if (startsWith("mailbox:/", inURL)) return (inURL + 8);
|
|
||||||
else if (startsWith("IMAP:/", inURL)) return (inURL + 5);
|
|
||||||
else return (inURL);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
char* MCDepFileURL (char* url) {
|
|
||||||
char* furl;
|
|
||||||
int32 len;
|
|
||||||
char* baz = "\\";
|
|
||||||
int32 n = 0;
|
|
||||||
furl = convertFileURLToNSPRCopaceticPath(unescapeURL(url));
|
|
||||||
len = RDF_STRLEN(furl);
|
|
||||||
#ifdef XP_WIN
|
|
||||||
while (n < len) {
|
|
||||||
if (furl[n] == '/') furl[n] = baz[0];
|
|
||||||
n++;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
return furl;
|
|
||||||
}
|
|
||||||
|
|
||||||
PRFileDesc *
|
|
||||||
CallPROpenUsingFileURL(char *fileURL, PRIntn flags, PRIntn mode)
|
|
||||||
{
|
|
||||||
PRFileDesc* result = NULL;
|
|
||||||
const char *path;
|
|
||||||
|
|
||||||
char *escapedPath = unescapeURL(fileURL);
|
|
||||||
path = convertFileURLToNSPRCopaceticPath(escapedPath);
|
|
||||||
|
|
||||||
if (path != NULL) {
|
|
||||||
result = PR_Open(path, flags, mode);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (escapedPath != NULL) freeMem(escapedPath);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
PRDir *
|
|
||||||
CallPROpenDirUsingFileURL(char *fileURL)
|
|
||||||
{
|
|
||||||
PRDir* result = NULL;
|
|
||||||
const char *path;
|
|
||||||
char *escapedPath = unescapeURL(fileURL);
|
|
||||||
path = convertFileURLToNSPRCopaceticPath(escapedPath);
|
|
||||||
|
|
||||||
if (path != NULL) {
|
|
||||||
result = PR_OpenDir(path);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (escapedPath != NULL) freeMem(escapedPath);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int32
|
|
||||||
CallPRWriteAccessFileUsingFileURL(char *fileURL)
|
|
||||||
{
|
|
||||||
int32 result = -1;
|
|
||||||
const char *path;
|
|
||||||
char *escapedPath = unescapeURL(fileURL);
|
|
||||||
path = convertFileURLToNSPRCopaceticPath(escapedPath);
|
|
||||||
|
|
||||||
if (path != NULL) {
|
|
||||||
result = PR_Access(path, PR_ACCESS_WRITE_OK);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (escapedPath != NULL) freeMem(escapedPath);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int32
|
|
||||||
CallPRDeleteFileUsingFileURL(char *fileURL)
|
|
||||||
{
|
|
||||||
int32 result = -1;
|
|
||||||
const char *path;
|
|
||||||
char *escapedPath = unescapeURL(fileURL);
|
|
||||||
path = convertFileURLToNSPRCopaceticPath(escapedPath);
|
|
||||||
|
|
||||||
if (path != NULL) {
|
|
||||||
result = PR_Delete(path);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (escapedPath != NULL) freeMem(escapedPath);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int
|
|
||||||
CallPR_RmDirUsingFileURL(char *dirURL)
|
|
||||||
{
|
|
||||||
int32 result=-1;
|
|
||||||
const char *path;
|
|
||||||
|
|
||||||
char *escapedPath = unescapeURL(dirURL);
|
|
||||||
path = convertFileURLToNSPRCopaceticPath(escapedPath);
|
|
||||||
|
|
||||||
if (path != NULL) {
|
|
||||||
result = PR_RmDir(path);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (escapedPath != NULL) freeMem(escapedPath);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int32
|
|
||||||
CallPRMkDirUsingFileURL(char *dirURL, int mode)
|
|
||||||
{
|
|
||||||
int32 result=-1;
|
|
||||||
const char *path;
|
|
||||||
|
|
||||||
char *escapedPath = unescapeURL(dirURL);
|
|
||||||
path = convertFileURLToNSPRCopaceticPath(escapedPath);
|
|
||||||
|
|
||||||
if (path != NULL) {
|
|
||||||
result = PR_MkDir(path,mode);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (escapedPath != NULL) freeMem(escapedPath);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* MOZILLA_CLIENT */
|
|
|
@ -1,89 +0,0 @@
|
||||||
/* -*- 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 _RDF_UTILS_H_
|
|
||||||
#define _RDF_UTILS_H_
|
|
||||||
|
|
||||||
#include "rdf.h"
|
|
||||||
#include "rdf-int.h"
|
|
||||||
#include "htrdf.h"
|
|
||||||
#include "prprf.h"
|
|
||||||
#include <stdarg.h>
|
|
||||||
#include <ctype.h>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* utils.c data structures and defines */
|
|
||||||
|
|
||||||
#define CONTAINER_FLAG 0x01
|
|
||||||
#define LOCKED_FLAG 0x02
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* utils.c function prototypes */
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
RDF_Resource getMCFFrtop (char* furl);
|
|
||||||
void addToResourceList (RDFFile f, RDF_Resource u);
|
|
||||||
void addToAssertionList (RDFFile f, Assertion as);
|
|
||||||
void removeFromAssertionList(RDFFile f, Assertion as);
|
|
||||||
void ht_fprintf(PRFileDesc *file, const char *fmt, ...);
|
|
||||||
void ht_rjcprintf(PRFileDesc *file, const char *fmt, const char *data);
|
|
||||||
char * makeDBURL(char* name);
|
|
||||||
PLHashNumber idenHash (const void *key);
|
|
||||||
int idenEqual (const void *v1, const void *v2);
|
|
||||||
PRBool inverseTV (PRBool tv);
|
|
||||||
char * append2Strings (const char* str1, const char* str2);
|
|
||||||
void stringAppendBase (char* dest, const char* addition);
|
|
||||||
void stringAppend (char* dest, const char* addition);
|
|
||||||
int16 charSearch (const char c, const char* data);
|
|
||||||
PRBool endsWith (const char* pattern, const char* uuid);
|
|
||||||
|
|
||||||
PRBool substring (const char* pattern, const char* data);
|
|
||||||
int compareStrings(char *s1, char *s2);
|
|
||||||
int16 revCharSearch (const char c, const char* data);
|
|
||||||
PRBool urlEquals (const char* url1, const char* url2);
|
|
||||||
PRBool isSeparator (RDF_Resource r);
|
|
||||||
void setContainerp (RDF_Resource r, PRBool val);
|
|
||||||
PRBool containerp (RDF_Resource r);
|
|
||||||
uint8 resourceType (RDF_Resource r);
|
|
||||||
void setResourceType (RDF_Resource r, uint8 val);
|
|
||||||
char * resourceID(RDF_Resource r);
|
|
||||||
char * makeResourceName (RDF_Resource node);
|
|
||||||
char* opTypeToString (RDF_EventType opType) ;
|
|
||||||
void traceNotify (char* event, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type) ;
|
|
||||||
|
|
||||||
PRBool IsUTF8Text(const char* utf8, int32 len);
|
|
||||||
PRBool IsUTF8String(const char* utf8);
|
|
||||||
|
|
||||||
void AddCookieResource(char* name, char* path, char* host, char* expires);
|
|
||||||
void RDF_ReadCookies(char * filename);
|
|
||||||
PRBool CookieUnassert (RDFT r, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type);
|
|
||||||
|
|
||||||
RDF_Cursor CookieGetSlotValues(RDFT rdf, RDF_Resource u, RDF_Resource s, RDF_ValueType type, PRBool inversep, PRBool tv);
|
|
||||||
void * CookieGetNextValue(RDFT rdf, RDF_Cursor c);
|
|
||||||
RDF_Error CookieDisposeCursor(RDFT rdf, RDF_Cursor c);
|
|
||||||
PRBool CookieAssert(RDFT rdf, RDF_Resource u, RDF_Resource s, void *v, RDF_ValueType type, PRBool tv);
|
|
||||||
void * CookieGetSlotValue(RDFT rdf, RDF_Resource u, RDF_Resource s, RDF_ValueType type, PRBool inversep, PRBool tv);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
337
rdf/src/vocab.c
337
rdf/src/vocab.c
|
@ -1,337 +0,0 @@
|
||||||
/* -*- 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 file implements a standard vocabulary for the rdf data model.
|
|
||||||
For more information on this file, contact rjc or guha
|
|
||||||
For more information on RDF, look at the RDF section of www.mozilla.org
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "vocabint.h"
|
|
||||||
#include "bmk2rdf.h"
|
|
||||||
|
|
||||||
|
|
||||||
/* globals */
|
|
||||||
|
|
||||||
#ifdef XP_MAC
|
|
||||||
#pragma export on
|
|
||||||
#endif
|
|
||||||
|
|
||||||
RDF_WDVocab gWebData = NULL;
|
|
||||||
RDF_NCVocab gNavCenter = NULL;
|
|
||||||
RDF_CoreVocab gCoreVocab = NULL;
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef XP_MAC
|
|
||||||
#pragma export off
|
|
||||||
#endif
|
|
||||||
|
|
||||||
size_t gCoreVocabSize = 0;
|
|
||||||
RDF_Resource* gAllVocab;
|
|
||||||
|
|
||||||
|
|
||||||
/* externs */
|
|
||||||
extern char* gLocalStoreURL;
|
|
||||||
extern char* profileDirURL;
|
|
||||||
RDF gCoreDB = 0;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
createVocabs ()
|
|
||||||
{
|
|
||||||
size_t n = 0;
|
|
||||||
size_t m = 0;
|
|
||||||
gAllVocab = getMem((gCoreVocabSize =
|
|
||||||
sizeof(RDF_CoreVocabStruct)+sizeof(RDF_NCVocabStruct)+sizeof(RDF_WDVocabStruct)));
|
|
||||||
gCoreDB = (RDF)getMem(sizeof(struct RDF_DBStruct));
|
|
||||||
|
|
||||||
createCoreVocab();
|
|
||||||
createNavCenterVocab();
|
|
||||||
createWebDataVocab();
|
|
||||||
|
|
||||||
while (n < (sizeof(RDF_CoreVocabStruct)/sizeof(RDF_Resource))) {
|
|
||||||
*(gAllVocab + m++) = *((RDF_Resource*)gCoreVocab + n++);
|
|
||||||
}
|
|
||||||
|
|
||||||
n = 0;
|
|
||||||
while (n < (sizeof(RDF_NCVocabStruct)/sizeof(RDF_Resource))) {
|
|
||||||
*(gAllVocab + m++) = *((RDF_Resource*)gNavCenter + n++);
|
|
||||||
}
|
|
||||||
|
|
||||||
n = 0;
|
|
||||||
while (n < (sizeof(RDF_WDVocabStruct)/sizeof(RDF_Resource))) {
|
|
||||||
*(gAllVocab + m++) = *((RDF_Resource*)gWebData + n++);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
createCoreVocab ()
|
|
||||||
{
|
|
||||||
gCoreVocab = (RDF_CoreVocab) getMem(sizeof(RDF_CoreVocabStruct));
|
|
||||||
gCoreVocab->RDF_parent = RDF_GetResource(gCoreDB, "parent", 1);
|
|
||||||
gCoreVocab->RDF_name = RDF_GetResource(gCoreDB, "name", 1);
|
|
||||||
gCoreVocab->RDF_instanceOf = RDF_GetResource(gCoreDB, "instanceOf", 1);
|
|
||||||
gCoreVocab->RDF_subClassOf = RDF_GetResource(gCoreDB, "subClassOf", 1);
|
|
||||||
gCoreVocab->RDF_Class = RDF_GetResource(gCoreDB, "Class", 1);
|
|
||||||
gCoreVocab->RDF_PropertyType = RDF_GetResource(gCoreDB, "PropertyType", 1);
|
|
||||||
gCoreVocab->RDF_slotsHere = RDF_GetResource(gCoreDB, "slotsHere", 1);
|
|
||||||
gCoreVocab->RDF_slotsIn = RDF_GetResource(gCoreDB, "slotsIn", 1);
|
|
||||||
gCoreVocab->RDF_domain = RDF_GetResource(gCoreDB, "domain", 1);
|
|
||||||
gCoreVocab->RDF_range = RDF_GetResource(gCoreDB, "range", 1);
|
|
||||||
gCoreVocab->RDF_StringType = RDF_GetResource(gCoreDB, "String", 1);
|
|
||||||
gCoreVocab->RDF_IntType = RDF_GetResource(gCoreDB, "Int", 1);
|
|
||||||
gCoreVocab->RDF_equals = RDF_GetResource(gCoreDB, "equals", 1);
|
|
||||||
gCoreVocab->RDF_lessThan = RDF_GetResource(gCoreDB, "lessThan", 1);
|
|
||||||
gCoreVocab->RDF_greaterThan = RDF_GetResource(gCoreDB, "greaterThan", 1);
|
|
||||||
gCoreVocab->RDF_lessThanOrEqual = RDF_GetResource(gCoreDB, "lessThanOrEqualTo", 1);
|
|
||||||
gCoreVocab->RDF_greaterThanOrEqual = RDF_GetResource(gCoreDB, "greaterThanOrEqualTo", 1);
|
|
||||||
gCoreVocab->RDF_stringEquals = newResource("stringEquals", 0);
|
|
||||||
gCoreVocab->RDF_stringNotEquals = newResource("stringNotEquals", 0);
|
|
||||||
gCoreVocab->RDF_substring = newResource("substring", 0);
|
|
||||||
gCoreVocab->RDF_stringStartsWith = newResource("stringStartsWith", 0);
|
|
||||||
gCoreVocab->RDF_stringEndsWith = newResource("stringEndsWith", 0);
|
|
||||||
gCoreVocab->RDF_child = RDF_GetResource(gCoreDB, "child", 1);
|
|
||||||
gCoreVocab->RDF_content = RDF_GetResource(gCoreDB, "content", 1);
|
|
||||||
gCoreVocab->RDF_summary = RDF_GetResource(gCoreDB, "summary", 1);
|
|
||||||
gCoreVocab->RDF_comment = RDF_GetResource(gCoreDB, "comment", 1);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
createNavCenterVocab () {
|
|
||||||
gNavCenter = (RDF_NCVocab) getMem(sizeof(RDF_NCVocabStruct));
|
|
||||||
#ifdef MOZILLA_CLIENT
|
|
||||||
gNavCenter->RDF_overview = RDF_GetResource(gCoreDB, "overview", 1);
|
|
||||||
gNavCenter->RDF_Trash = createContainer("Trash");
|
|
||||||
gNavCenter->RDF_Clipboard = createContainer("Clipboard");
|
|
||||||
gNavCenter->RDF_Top = createContainer("NC:NavCenter");
|
|
||||||
setResourceType(gNavCenter->RDF_Top, RDF_RT);
|
|
||||||
gNavCenter->RDF_Search = createContainer("NC:Search");
|
|
||||||
setResourceType(gNavCenter->RDF_Search, SEARCH_RT);
|
|
||||||
gNavCenter->RDF_Sitemaps = createContainer("NC:Sitemaps");
|
|
||||||
gNavCenter->RDF_BreadCrumbCategory = createContainer("BreadCrumbs");
|
|
||||||
gNavCenter->RDF_BookmarkFolderCategory = createContainer("NC:Bookmarks");
|
|
||||||
gNavCenter->RDF_NewBookmarkFolderCategory = RDF_GetResource(gCoreDB, "NewBookmarks", true);
|
|
||||||
gNavCenter->RDF_History = createContainer("NC:History");
|
|
||||||
gNavCenter->RDF_HistoryBySite = createContainer("NC:HistoryBySite");
|
|
||||||
gNavCenter->RDF_HistoryByDate = createContainer("NC:HistoryByDate");
|
|
||||||
gNavCenter->RDF_HistoryMostVisited = createContainer("NC:HistoryMostVisited");
|
|
||||||
setResourceType(gNavCenter->RDF_History, HISTORY_RT);
|
|
||||||
setResourceType(gNavCenter->RDF_HistoryBySite, HISTORY_RT);
|
|
||||||
setResourceType(gNavCenter->RDF_HistoryByDate, HISTORY_RT);
|
|
||||||
setResourceType(gNavCenter->RDF_HistoryMostVisited, HISTORY_RT);
|
|
||||||
|
|
||||||
/* IE items */
|
|
||||||
gNavCenter->RDF_IEBookmarkFolderCategory = createContainer("NC:IEBookmarks");
|
|
||||||
gNavCenter->RDF_IEHistory = createContainer("NC:IEHistory");
|
|
||||||
setResourceType(gNavCenter->RDF_IEHistory, HISTORY_RT);
|
|
||||||
|
|
||||||
gNavCenter->RDF_bookmarkAddDate = newResource("bookmarkAddDate", 0);
|
|
||||||
gNavCenter->RDF_PersonalToolbarFolderCategory =
|
|
||||||
RDF_GetResource(gCoreDB, "PersonalToolbarCat", true);
|
|
||||||
gNavCenter->RDF_Column = RDF_GetResource(gCoreDB, "Column", true);
|
|
||||||
gNavCenter->RDF_ColumnResource = RDF_GetResource(gCoreDB, "ColumnResource", true);
|
|
||||||
gNavCenter->RDF_ColumnWidth = RDF_GetResource(gCoreDB, "ColumnWidth", true);
|
|
||||||
gNavCenter->RDF_ColumnIconURL = RDF_GetResource(gCoreDB, "ColumnIconURL", true);
|
|
||||||
gNavCenter->RDF_ColumnDataType = RDF_GetResource(gCoreDB, "ColumnDataType", true);
|
|
||||||
gNavCenter->RDF_smallIcon = newResource("smallIcon", 0);
|
|
||||||
gNavCenter->RDF_largeIcon = newResource("largeIcon", 0);
|
|
||||||
gNavCenter->RDF_HTMLURL = newResource("htmlURL", 0);
|
|
||||||
gNavCenter->RDF_HTMLHeight = newResource("htmlHeight", 0);
|
|
||||||
gNavCenter->RDF_LocalFiles = createContainer("NC:LocalFiles");
|
|
||||||
gNavCenter->RDF_FTP = createContainer("NC:FTP");
|
|
||||||
gNavCenter->RDF_FTP = newResource("NC:FTP", 0);
|
|
||||||
gNavCenter->RDF_Appletalk = createContainer("NC:Appletalk");
|
|
||||||
gNavCenter->RDF_Appletalk = newResource("NC:Appletalk", 0);
|
|
||||||
setResourceType(gNavCenter->RDF_Appletalk, 0);
|
|
||||||
gNavCenter->RDF_Mail = RDF_GetResource(gCoreDB, "NC:Mail", true);
|
|
||||||
gNavCenter->RDF_Guide = RDF_GetResource(gCoreDB, "NC:Guide", true);
|
|
||||||
gNavCenter->RDF_Password = RDF_GetResource(gCoreDB, "password", true);
|
|
||||||
gNavCenter->RDF_SBProviders = RDF_GetResource(gCoreDB, "NC:SmartBrowsingProviders", true);
|
|
||||||
gNavCenter->RDF_WorkspacePos = RDF_GetResource(gCoreDB, "workspacePos", true);
|
|
||||||
gNavCenter->RDF_ItemPos = RDF_GetResource(gCoreDB, "pos", true);
|
|
||||||
gNavCenter->RDF_Locks = RDF_GetResource(gCoreDB, "locks", true);
|
|
||||||
gNavCenter->RDF_AddLock = RDF_GetResource(gCoreDB, "addLock", true);
|
|
||||||
gNavCenter->RDF_DeleteLock = RDF_GetResource(gCoreDB, "deleteLock", true);
|
|
||||||
gNavCenter->RDF_IconLock = RDF_GetResource(gCoreDB, "iconLock", true);
|
|
||||||
gNavCenter->RDF_NameLock = RDF_GetResource(gCoreDB, "nameLock", true);
|
|
||||||
gNavCenter->RDF_CopyLock = RDF_GetResource(gCoreDB, "copyLock", true);
|
|
||||||
gNavCenter->RDF_MoveLock = RDF_GetResource(gCoreDB, "moveLock", true);
|
|
||||||
gNavCenter->RDF_WorkspacePosLock = RDF_GetResource(gCoreDB, "workspacePosLock", true);
|
|
||||||
gNavCenter->RDF_DefaultSelectedView = RDF_GetResource(gCoreDB, "selectedView", true);
|
|
||||||
gNavCenter->RDF_AutoOpen = RDF_GetResource(gCoreDB, "autoOpen", true);
|
|
||||||
gNavCenter->RDF_resultType = RDF_GetResource (gCoreDB, "resultType", true);
|
|
||||||
gNavCenter->RDF_methodType = RDF_GetResource (gCoreDB, "methodType", true);
|
|
||||||
gNavCenter->RDF_prompt = RDF_GetResource (gCoreDB, "prompt", true);
|
|
||||||
gNavCenter->RDF_HTMLType = RDF_GetResource (gCoreDB, "HTMLPage", true);
|
|
||||||
gNavCenter->RDF_URLShortcut = RDF_GetResource(gCoreDB, "URLShortcut", true);
|
|
||||||
gNavCenter->RDF_Poll = RDF_GetResource(gCoreDB, "poll", true);
|
|
||||||
gNavCenter->RDF_PollInterval = RDF_GetResource(gCoreDB, "pollInterval", true);
|
|
||||||
gNavCenter->RDF_PollURL = RDF_GetResource(gCoreDB, "pollURL", true);
|
|
||||||
|
|
||||||
gNavCenter->RDF_Cookies = createContainer("NC:Cookies");
|
|
||||||
setResourceType(gNavCenter->RDF_Cookies, COOKIE_RT);
|
|
||||||
|
|
||||||
gNavCenter->RDF_Toolbar = createContainer("NC:Toolbar");
|
|
||||||
gNavCenter->RDF_JSec = createContainer("NC:Jsec");
|
|
||||||
gNavCenter->RDF_JSecPrincipal = RDF_GetResource(gCoreDB, "JsecPrincipal", true);
|
|
||||||
gNavCenter->RDF_JSecTarget = RDF_GetResource(gCoreDB, "JsecTarget", true);
|
|
||||||
gNavCenter->RDF_JSecAccess = RDF_GetResource(gCoreDB, "JsecAccess", true);
|
|
||||||
|
|
||||||
/* Commands */
|
|
||||||
|
|
||||||
gNavCenter->RDF_Command = RDF_GetResource (gCoreDB, "Command", true);
|
|
||||||
gNavCenter->RDF_Command_Launch = RDF_GetResource(gCoreDB, "Command:Launch", true);
|
|
||||||
gNavCenter->RDF_Command_Refresh = RDF_GetResource(gCoreDB, "Command:Refresh", true);
|
|
||||||
gNavCenter->RDF_Command_Reveal = RDF_GetResource(gCoreDB, "Command:Reveal", true);
|
|
||||||
gNavCenter->RDF_Command_Atalk_FlatHierarchy = RDF_GetResource(gCoreDB, "Command:at:View Zone List", true);
|
|
||||||
gNavCenter->RDF_Command_Atalk_Hierarchy = RDF_GetResource(gCoreDB, "Command:at:View Zone Hierarchy", true);
|
|
||||||
|
|
||||||
/* NavCenter appearance styles */
|
|
||||||
|
|
||||||
gNavCenter->viewFGColor = newResource("viewFGColor", 0);
|
|
||||||
gNavCenter->viewBGColor = newResource("viewBGColor", 0);
|
|
||||||
gNavCenter->viewBGURL = newResource("viewBGURL", 0);
|
|
||||||
gNavCenter->showTreeConnections = newResource("showTreeConnections", 0);
|
|
||||||
gNavCenter->treeConnectionFGColor = newResource("treeConnectionFGColor", 0);
|
|
||||||
gNavCenter->treeOpenTriggerIconURL = newResource("treeOpenTriggerIconURL", 0);
|
|
||||||
gNavCenter->treeClosedTriggerIconURL = newResource("treeClosedTriggerIconURL", 0);
|
|
||||||
gNavCenter->selectionFGColor = newResource("selectionFGColor", 0);
|
|
||||||
gNavCenter->selectionBGColor = newResource("selectionBGColor", 0);
|
|
||||||
gNavCenter->columnHeaderFGColor = newResource("columnHeaderFGColor", 0);
|
|
||||||
gNavCenter->columnHeaderBGColor = newResource("columnHeaderBGColor", 0);
|
|
||||||
gNavCenter->columnHeaderBGURL = newResource("columnHeaderBGURL", 0);
|
|
||||||
gNavCenter->showColumnHeaders = newResource("showColumnHeaders", 0);
|
|
||||||
gNavCenter->showColumnHeaderDividers = newResource("showColumnHeaderDividers", 0);
|
|
||||||
gNavCenter->sortColumnFGColor = newResource("sortColumnFGColor", 0);
|
|
||||||
gNavCenter->sortColumnBGColor = newResource("sortColumnBGColor", 0);
|
|
||||||
gNavCenter->titleBarFGColor = newResource("titleBarFGColor", 0);
|
|
||||||
gNavCenter->titleBarBGColor = newResource("titleBarBGColor", 0);
|
|
||||||
gNavCenter->titleBarBGURL = newResource("titleBarBGURL", 0);
|
|
||||||
gNavCenter->dividerColor = newResource("dividerColor", 0);
|
|
||||||
gNavCenter->showDivider = newResource("showDivider", 0);
|
|
||||||
gNavCenter->selectedColumnHeaderFGColor = newResource("selectedColumnHeaderFGColor", 0);
|
|
||||||
gNavCenter->selectedColumnHeaderBGColor = newResource("selectedColumnHeaderBGColor", 0);
|
|
||||||
gNavCenter->showColumnHilite = newResource("showColumnHilite", 0);
|
|
||||||
gNavCenter->triggerPlacement = newResource("triggerPlacement", 0);
|
|
||||||
|
|
||||||
/* NavCenter behavior properties */
|
|
||||||
gNavCenter->useInlineEditing = newResource("useInlineEditing", 0 /* XXX */);
|
|
||||||
gNavCenter->useSingleClick = newResource("useSingleClick", 0 /* XXX */);
|
|
||||||
gNavCenter->loadOpenState = newResource("loadOpenState", 0 /* XXX */);
|
|
||||||
gNavCenter->saveOpenState = newResource("saveOpenState", 0 /* XXX */);
|
|
||||||
|
|
||||||
/* Toolbars */
|
|
||||||
|
|
||||||
/* Toolbar Appearance Styles */
|
|
||||||
gNavCenter->toolbarBitmapPosition = newResource("toolbarBitmapPosition", 0 /* XXX "Toolbar Bitmap Position" */ );
|
|
||||||
gNavCenter->toolbarButtonsFixedSize = newResource("toolbarButtonsFixedSize", 0 /* XXX "Toolbar Bitmap Position" */ );
|
|
||||||
gNavCenter->toolbarDisplayMode = newResource("toolbarDisplayMode", 0);
|
|
||||||
gNavCenter->toolbarCollapsed = newResource("toolbarCollapsed", 0);
|
|
||||||
gNavCenter->toolbarVisible = newResource("toolbarVisible", 0);
|
|
||||||
gNavCenter->toolbarDisabledIcon = newResource("toolbarDisabledIcon", 0 /* XXX */);
|
|
||||||
gNavCenter->toolbarEnabledIcon = newResource("toolbarEnabledIcon", 0 /* XXX */);
|
|
||||||
gNavCenter->toolbarRolloverIcon = newResource("toolbarRolloverIcon", 0 /* XXX */);
|
|
||||||
gNavCenter->toolbarPressedIcon = newResource("toolbarPressedIcon", 0 /* XXX */);
|
|
||||||
gNavCenter->buttonTooltipText = newResource("buttonTooltipText", 0 /* XXX */);
|
|
||||||
gNavCenter->buttonStatusbarText = newResource("buttonStatusbarText", 0 /* XXX */);
|
|
||||||
gNavCenter->buttonBorderStyle = newResource("buttonBorderStyle", 0 /* XXX */);
|
|
||||||
gNavCenter->urlBar = newResource("urlBar", 0 /* XXX */);
|
|
||||||
gNavCenter->urlBarWidth = newResource("urlBarWidth", 0 /* XXX */);
|
|
||||||
gNavCenter->pos = newResource("pos", 0 /* XXX */);
|
|
||||||
gNavCenter->viewRolloverColor = newResource("viewRolloverColor", 0 /* XXX */);
|
|
||||||
gNavCenter->viewPressedColor = newResource("viewPressedColor", 0 /* XXX */);
|
|
||||||
gNavCenter->viewDisabledColor = newResource("viewDisabledColor", 0 /* XXX */);
|
|
||||||
gNavCenter->controlStripFGColor = newResource("controlStripFGColor", 0 /* XXX */);
|
|
||||||
gNavCenter->controlStripBGColor = newResource("controlStripBGColor", 0 /* XXX */);
|
|
||||||
gNavCenter->controlStripBGURL = newResource("controlStripBGURL", 0 /* XXX */);
|
|
||||||
gNavCenter->controlStripCloseText = newResource("controlStripCloseText", 0 /* XXX */);
|
|
||||||
gNavCenter->titleBarShowText = newResource("titleBarShowText", 0 /* XXX */);
|
|
||||||
gNavCenter->showTitleBar = newResource("showTitleBar", 0 /* XXX */);
|
|
||||||
gNavCenter->showControlStrip = newResource("showControlStrip", 0 /* XXX */);
|
|
||||||
|
|
||||||
/* Buttons */
|
|
||||||
gNavCenter->buttonTreeState = newResource("buttonTreeState", 0 /* XXX */);
|
|
||||||
|
|
||||||
/* Cookies */
|
|
||||||
gNavCenter->cookieDomain = newResource("cookieDomain", 0 /* XXX */);
|
|
||||||
gNavCenter->cookieValue = newResource("cookieValue", 0 /* XXX */);
|
|
||||||
gNavCenter->cookieHost = newResource("cookieHost", 0 /* XXX */);
|
|
||||||
gNavCenter->cookiePath = newResource("cookiePath", 0 /* XXX */);
|
|
||||||
gNavCenter->cookieSecure = newResource("cookieSecure", 0 /* XXX */);
|
|
||||||
gNavCenter->cookieExpires = newResource("cookieExpiration", 0 /* XXX */);
|
|
||||||
gNavCenter->from = newResource("mail:From", 0 );
|
|
||||||
gNavCenter->to = newResource("mail:To", 0 );
|
|
||||||
gNavCenter->subject = newResource("mail:Subject", 0 /* XXX */);
|
|
||||||
gNavCenter->date = newResource("mail:Date", 0 /* XXX */);
|
|
||||||
gNavCenter->displayURL = newResource("displayURL", 0 /* XXX */);
|
|
||||||
remoteStoreAdd(gRemoteStore, gNavCenter->from, gCoreVocab->RDF_name, copyString("from"), RDF_STRING_TYPE, 1);
|
|
||||||
remoteStoreAdd(gRemoteStore, gNavCenter->to, gCoreVocab->RDF_name, copyString("to"), RDF_STRING_TYPE, 1);
|
|
||||||
remoteStoreAdd(gRemoteStore, gNavCenter->subject, gCoreVocab->RDF_name, copyString("subject"), RDF_STRING_TYPE, 1);
|
|
||||||
remoteStoreAdd(gRemoteStore, gNavCenter->date, gCoreVocab->RDF_name, copyString("date"), RDF_STRING_TYPE, 1);
|
|
||||||
#endif /* MOZILLA_CLIENT */
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
createWebDataVocab ()
|
|
||||||
{
|
|
||||||
gWebData = (RDF_WDVocab) getMem(sizeof(RDF_WDVocabStruct));
|
|
||||||
#ifdef MOZILLA_CLIENT
|
|
||||||
gWebData->RDF_URL = newResource("URL", 0);
|
|
||||||
gWebData->RDF_description = newResource("description", 0);
|
|
||||||
gWebData->RDF_keyword = newResource("keyword", 0 /* XXX */);
|
|
||||||
gWebData->RDF_Container = RDF_GetResource (gCoreDB, "Container", true);
|
|
||||||
gWebData->RDF_firstVisitDate = newResource("firstVisitDate", 0);
|
|
||||||
gWebData->RDF_lastVisitDate = newResource("lastVisitDate", 0);
|
|
||||||
gWebData->RDF_numAccesses = newResource("numAccesses", 0);
|
|
||||||
gWebData->RDF_creationDate = newResource("creationDate", 0);
|
|
||||||
gWebData->RDF_lastModifiedDate = newResource("lastModifiedDate", 0);
|
|
||||||
gWebData->RDF_size = newResource("size", 0);
|
|
||||||
#endif /* MOZILLA_CLIENT */
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
RDF_Resource
|
|
||||||
newResource(char *id, int optionalNameStrID)
|
|
||||||
{
|
|
||||||
RDF_Resource r;
|
|
||||||
|
|
||||||
r = RDF_GetResource(gCoreDB, id, true);
|
|
||||||
return(r);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
char *
|
|
||||||
getResourceDefaultName(RDF_Resource node)
|
|
||||||
{
|
|
||||||
int strID = 0;
|
|
||||||
char *defaultName = NULL;
|
|
||||||
return resourceID(node);
|
|
||||||
}
|
|
||||||
|
|
||||||
char *gDefaultNavcntr =
|
|
||||||
"<RDF:RDF> <Topic id=\"NC:Toolbar\"> <child> <Topic id=\"NC:CommandToolBar\" name=\"Command Toolbar\" toolbarBitmapPosition=\"top\" toolbarButtonsFixedSize=\"yes\" > <child href=\"command:back\" name=\"Back\"/> <child buttonTooltipText=\"Reload this page from the server\" buttonStatusbarText=\"Reload the current page\" href=\"command:reload\" name=\"Reload\"/> <child href=\"command:stop\" name=\"Stop\"/> <child href=\"command:forward\" name=\"Forward\"/> <child name=\"separator0\" href=\"nc:separator0\"/> <child href=\"command:urlbar\" name=\" \" buttonStatusBarText=\"Location/Search Bar\" buttonTooltipText=\"Location/Search Bar\" urlBar=\"Yes\" urlBarWidth=\"*\"/> <child name=\"separator2\" href=\"nc:separator2\"/> </Topic> </child> <child> <Topic id=\"NC:InfoToolbar\" name=\"Info Toolbar\"> <child> <Topic id=\"NC:Bookmarks\" name=\"Bookmarks\"></Topic> </child> <child> <Topic id=\"NC:History\" largeIcon=\"icon/large:workspace,history\" name=\"History\"> <child href=\"NC:HistoryMostVisited\" name=\"Most Frequented Pages\"/> <child href=\"NC:HistoryBySite\" name=\"History By Site\"/> <child href=\"NC:HistoryByDate\" name=\"History By Date\"/> </Topic> </child> <child href=\"NC:Sitemaps\" name=\"Related\" htmlURL=\"http://rdf.netscape.com/rdf/navcntradvert.html\"/> </Topic> </child> <child> <Topic id=\"NC:PersonalToolbar\" name=\"Personal Toolbar\"> </Topic> </child> </Topic> <Topic id=\"NC:NavCenter\"> <child href=\"NC:Bookmarks\" name=\"Bookmarks\"/> <child href=\"NC:Search\" largeIcon=\"icon/large:workspace,search\" name=\"Search\"/> <child href=\"NC:History\" name=\"History\"/> <child id=\"NC:Sitemaps\" name=\"Site Tools\" htmlURL=\"http://rdf.netscape.com/rdf/navcntradvert.html\" /> <child id=\"NC:LocalFiles\" name=\"Files\" largeIcon=\"http://rdf.netscape.com/rdf/heabou.gif\"/> </Topic></RDF:RDF>" ;
|
|
|
@ -1,56 +0,0 @@
|
||||||
/* -*- 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 _RDF_VOCABINT_H_
|
|
||||||
#define _RDF_VOCABINT_H_
|
|
||||||
|
|
||||||
|
|
||||||
#include "rdf-int.h"
|
|
||||||
#include "htrdf.h"
|
|
||||||
|
|
||||||
|
|
||||||
/* vocab.c data structures */
|
|
||||||
|
|
||||||
extern int RDF_FOREGROUND_COLOR_STR, RDF_BACKGROUND_COLOR_STR, RDF_BACKGROUND_IMAGE_STR;
|
|
||||||
extern int RDF_SHOW_TREE_CONNECTIONS_STR, RDF_CONNECTION_FG_COLOR_STR, RDF_OPEN_TRIGGER_IMAGE_STR;
|
|
||||||
extern int RDF_CLOSED_TRIGGER_IMAGE_STR, RDF_SHOW_HEADERS_STR, RDF_SHOW_HEADER_DIVIDERS_STR;
|
|
||||||
extern int RDF_SORT_COLUMN_FG_COLOR_STR, RDF_SORT_COLUMN_BG_COLOR_STR, RDF_DIVIDER_COLOR_STR;
|
|
||||||
extern int RDF_SHOW_COLUMN_DIVIDERS_STR, RDF_SELECTED_HEADER_FG_COLOR_STR, RDF_SELECTED_HEADER_BG_COLOR_STR;
|
|
||||||
extern int RDF_SHOW_COLUMN_HILITING_STR, RDF_TRIGGER_PLACEMENT_STR, RDF_URL_STR;
|
|
||||||
extern int RDF_DESCRIPTION_STR, RDF_FIRST_VISIT_STR, RDF_LAST_VISIT_STR, RDF_NUM_ACCESSES_STR;
|
|
||||||
extern int RDF_CREATED_ON_STR, RDF_LAST_MOD_STR, RDF_SIZE_STR, RDF_ADDED_ON_STR, RDF_ICON_URL_STR;
|
|
||||||
extern int RDF_LARGE_ICON_URL_STR, RDF_HTML_URL_STR, RDF_HTML_HEIGHT_STR;
|
|
||||||
extern int RDF_CONTAINS_STR, RDF_IS_STR, RDF_IS_NOT_STR, RDF_STARTS_WITH_STR, RDF_ENDS_WITH_STR;
|
|
||||||
extern int RDF_FTP_NAME_STR, RDF_APPLETALK_TOP_NAME;
|
|
||||||
|
|
||||||
|
|
||||||
/* vocab.c function prototypes */
|
|
||||||
|
|
||||||
NSPR_BEGIN_EXTERN_C
|
|
||||||
|
|
||||||
void createVocabs ();
|
|
||||||
void createCoreVocab ();
|
|
||||||
void createNavCenterVocab ();
|
|
||||||
void createWebDataVocab ();
|
|
||||||
RDF_Resource newResource(char *id, int optionalNameStrID);
|
|
||||||
char *getResourceDefaultName(RDF_Resource r);
|
|
||||||
|
|
||||||
NSPR_END_EXTERN_C
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче