Include a few more essential header files.

This commit is contained in:
rjc%netscape.com 1998-11-13 08:53:29 +00:00
Родитель eb159f3ddc
Коммит 146e51684e
6 изменённых файлов: 2 добавлений и 858 удалений

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

@ -1,607 +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"
#include "utils.h"
#include "time.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,72 +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 "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();
#endif

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

@ -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>
/* 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

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

@ -45,7 +45,7 @@ public:
NS_METHOD OnStopBinding(nsIURL* aURL, PRInt32 status, const nsString& aMsg); NS_METHOD OnStopBinding(nsIURL* aURL, PRInt32 status, const nsString& aMsg);
protected: protected:
rdfStreamListener::rdfStreamListener(); // rdfStreamListener::rdfStreamListener();
private: private:
RDFFile mFile; RDFFile mFile;

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

@ -18,6 +18,7 @@
#include "nsRDFDataModel.h" #include "nsRDFDataModel.h"
#include "nsRDFDataModelItem.h" #include "nsRDFDataModelItem.h"
#include "rdf-int.h"
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////

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

@ -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 "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