*** empty log message ***
git-svn-id: svn://10.0.0.236/trunk@14260 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -87,11 +87,11 @@ public:
|
||||
* Find all RDF resources that point to a given node over the
|
||||
* specified arc & truth value (defaults to "PR_TRUE").
|
||||
*/
|
||||
NS_IMETHOD GetSources(RDF_Node target,
|
||||
NS_IMETHOD GetSources(RDF_Resource target,
|
||||
RDF_Resource arcLabel,
|
||||
nsIRDFCursor **sources /* out */) = 0;
|
||||
|
||||
NS_IMETHOD GetSources(RDF_Node target,
|
||||
NS_IMETHOD GetSources(RDF_Resource target,
|
||||
RDF_Resource arcLabel,
|
||||
PRBool tv,
|
||||
nsIRDFCursor **sources /* out */) = 0;
|
||||
|
||||
@@ -57,9 +57,13 @@ public:
|
||||
nsIRDFDataSource **source /* out */) = 0;
|
||||
#endif /* RDF_NOT_IMPLEMENTED */
|
||||
|
||||
NS_IMETHOD CreateDatabase(const RDF_String* url_ary,
|
||||
NS_IMETHOD CreateDatabase(const char** url_ary,
|
||||
nsIRDFDataBase **db /* out */) = 0;
|
||||
|
||||
NS_IMETHOD ResourceIdentifier(RDF_Resource r,
|
||||
char** url /* out */) = 0;
|
||||
|
||||
|
||||
};
|
||||
|
||||
PR_PUBLIC_API(nsresult) NS_GetRDFService(nsIRDFService **);
|
||||
|
||||
@@ -39,7 +39,7 @@ typedef struct RDF_NotificationStruct* RDF_Notification;
|
||||
|
||||
typedef void (*RDF_NotificationProc)(RDF_Event theEvent, void* pdata);
|
||||
|
||||
PR_PUBLIC_API(RDF) RDF_GetDB(const RDF_String* dbs);
|
||||
PR_PUBLIC_API(RDF) RDF_GetDB(const char** dbs);
|
||||
PR_PUBLIC_API(RDF_Error) RDF_ReleaseDB(RDF rdf);
|
||||
PR_PUBLIC_API(RDFT) RDF_AddDataSource(RDF rdf, char* dataSource);
|
||||
PR_PUBLIC_API(RDF_Error) RDF_ReleaseDataSource(RDF rdf, RDFT dataSource);
|
||||
@@ -47,6 +47,7 @@ PR_PUBLIC_API(RDF_Resource) RDF_GetResource(RDF db, char* id, PRBool createp);
|
||||
PR_PUBLIC_API(RDF_Error) RDF_ReleaseResource(RDF db, RDF_Resource resource);
|
||||
PR_PUBLIC_API(RDF_Error) RDF_DeleteAllArcs(RDF rdfDB, RDF_Resource source);
|
||||
PR_PUBLIC_API(RDF_Error) RDF_Update(RDF rdfDB, RDF_Resource u);
|
||||
PR_PUBLIC_API(char*) RDF_ResourceID(RDF_Resource u);
|
||||
|
||||
PR_PUBLIC_API(RDF_Notification) RDF_AddNotifiable (RDF rdfDB, RDF_NotificationProc callBack, RDF_Event ev, void* pdata);
|
||||
PR_PUBLIC_API(RDF_Error) RDF_DeleteNotifiable (RDF_Notification ns);
|
||||
|
||||
@@ -256,7 +256,7 @@ newFolderBkItem(RDFFile f, char* token)
|
||||
void
|
||||
newLeafBkItem (RDFFile f, char* token)
|
||||
{
|
||||
char buffer[128];
|
||||
/* char buffer[128]; */
|
||||
struct tm *time;
|
||||
uint32 dateVal;
|
||||
char* url = NULL;
|
||||
|
||||
@@ -60,11 +60,11 @@ public:
|
||||
PRBool tv,
|
||||
RDF_Resource *source /* out */);
|
||||
|
||||
NS_METHOD GetSources(RDF_Node target,
|
||||
NS_METHOD GetSources(RDF_Resource target,
|
||||
RDF_Resource arcLabel,
|
||||
nsIRDFCursor **sources /* out */);
|
||||
|
||||
NS_METHOD GetSources(RDF_Node target,
|
||||
NS_METHOD GetSources(RDF_Resource target,
|
||||
RDF_Resource arcLabel,
|
||||
PRBool tv,
|
||||
nsIRDFCursor **sources /* out */);
|
||||
@@ -160,9 +160,13 @@ public:
|
||||
rdfServiceWrapper();
|
||||
~rdfServiceWrapper();
|
||||
|
||||
NS_METHOD CreateDatabase(const RDF_String* url,
|
||||
NS_METHOD CreateDatabase(const char** url,
|
||||
nsIRDFDataBase** db);
|
||||
|
||||
NS_IMETHOD ResourceIdentifier(RDF_Resource r,
|
||||
char** url /* out */);
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -292,7 +296,7 @@ rdfDatabaseWrapper::GetSource(RDF_Node target,
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
rdfDatabaseWrapper::GetSources(RDF_Node target,
|
||||
rdfDatabaseWrapper::GetSources(RDF_Resource target,
|
||||
RDF_Resource arcLabel,
|
||||
nsIRDFCursor **sources /* out */)
|
||||
{
|
||||
@@ -300,7 +304,7 @@ rdfDatabaseWrapper::GetSources(RDF_Node target,
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
rdfDatabaseWrapper::GetSources(RDF_Node target,
|
||||
rdfDatabaseWrapper::GetSources(RDF_Resource target,
|
||||
RDF_Resource arcLabel,
|
||||
PRBool tv,
|
||||
nsIRDFCursor **sources /* out */)
|
||||
@@ -312,7 +316,7 @@ rdfDatabaseWrapper::GetSources(RDF_Node target,
|
||||
*sources = 0;
|
||||
|
||||
RDF_Cursor c = RDF_GetSources( mRDF,
|
||||
target->value.r,
|
||||
target,
|
||||
arcLabel,
|
||||
RDF_RESOURCE_TYPE, // anything else makes no sense
|
||||
tv );
|
||||
@@ -556,7 +560,7 @@ rdfServiceWrapper::~rdfServiceWrapper()
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
rdfServiceWrapper::CreateDatabase(const RDF_String* url_ary,
|
||||
rdfServiceWrapper::CreateDatabase(const char** url_ary,
|
||||
nsIRDFDataBase **db)
|
||||
{
|
||||
PR_ASSERT( 0 != db );
|
||||
@@ -577,6 +581,20 @@ rdfServiceWrapper::CreateDatabase(const RDF_String* url_ary,
|
||||
return result;
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
rdfServiceWrapper::ResourceIdentifier(RDF_Resource r,
|
||||
char** url)
|
||||
{
|
||||
char* resourceID(RDF_Resource r);
|
||||
PR_ASSERT( 0 != r );
|
||||
if( 0 == r )
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
*url = RDF_ResourceID(r);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
|
||||
rdfCursorWrapper
|
||||
|
||||
@@ -69,8 +69,7 @@ getTranslator (char* url)
|
||||
|
||||
|
||||
PR_PUBLIC_API(RDF)
|
||||
RDF_GetDB (const char** dataSources)
|
||||
{
|
||||
RDF_GetDB (const char** dataSources) {
|
||||
int32 n = 0;
|
||||
int32 m = 0;
|
||||
char* next ;
|
||||
@@ -854,7 +853,7 @@ matchStrings(RDF_Resource match, char *data, char *pattern)
|
||||
}
|
||||
else if (match == gCoreVocab->RDF_stringEquals)
|
||||
{
|
||||
ok = (PRBool)(!compareStrings(data, pattern));
|
||||
ok = (PRBool)(strcmp(data, pattern) == 0);
|
||||
}
|
||||
else if (match == gCoreVocab->RDF_stringNotEquals)
|
||||
{
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
#include "nsString.h"
|
||||
#include "rdf-int.h"
|
||||
#include "rdfparse.h"
|
||||
|
||||
#include <stdio.h>
|
||||
class rdfStreamListener : public nsIStreamListener
|
||||
{
|
||||
public:
|
||||
@@ -152,6 +152,17 @@ rdfStreamListener::OnStopBinding(nsIURL* aURL,
|
||||
void
|
||||
beginReadingRDFFile (RDFFile file)
|
||||
{
|
||||
if (!strchr(file->url, ':') && (endsWith(".rdf", file->url))) {
|
||||
FILE* f = fopen(file->url, "r");
|
||||
char buffer[4096];
|
||||
int n;
|
||||
while (f && ((n = fread(buffer, 1, 4095, f)) > 0)) {
|
||||
buffer[n] = '\0';
|
||||
parseNextRDFXMLBlobInt(file, buffer, n);
|
||||
}
|
||||
fclose(f);
|
||||
return;
|
||||
} else {
|
||||
rdfStreamListener* pListener = new rdfStreamListener(file);
|
||||
pListener->AddRef(); // XXX is this evil? Can't see any reason to use factories but...
|
||||
nsIURL* pURL = NULL;
|
||||
@@ -165,5 +176,6 @@ beginReadingRDFFile (RDFFile file)
|
||||
if( NS_OK != r ) {
|
||||
// XXX what to do?
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -291,7 +291,10 @@ struct RDF_FileStruct {
|
||||
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) ;
|
||||
|
||||
@@ -47,10 +47,10 @@ MakeRemoteStore (char* url)
|
||||
RDFT
|
||||
MakeFileDB (char* url)
|
||||
{
|
||||
if (RDF_STRCHR(url, ':')) {
|
||||
if (RDF_STRCHR(url, ':') || endsWith(".rdf", url)) {
|
||||
RDFT ntr = NewRemoteStore(url);
|
||||
ntr->possiblyAccessFile = RDFFilePossiblyAccessFile ;
|
||||
if (RDF_STRCMP(gNavCntrUrl, url) == 0)
|
||||
if ((RDF_STRCMP(gNavCntrUrl, url) == 0) || 1) /* just for testing */
|
||||
readRDFFile(url, RDF_GetResource(NULL, url, 1), 0, ntr);
|
||||
return ntr;
|
||||
} else return NULL;
|
||||
@@ -643,7 +643,7 @@ readRDFFile (char* url, RDF_Resource top, PRBool localp, RDFT db)
|
||||
RDFFile
|
||||
makeNewRDFFile (char* url, RDF_Resource top, PRBool localp, RDFT db)
|
||||
{
|
||||
if ((!strstr(url, ":/")) ||
|
||||
if ( /*(!strstr(url, ":/")) || */
|
||||
(fileReadp(db, url, true))) {
|
||||
return NULL;
|
||||
} else {
|
||||
|
||||
@@ -429,7 +429,10 @@ 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)
|
||||
|
||||
@@ -17,17 +17,39 @@
|
||||
*/
|
||||
|
||||
#include "rdf.h"
|
||||
#include "nsIStreamListener.h"
|
||||
#include "nsIInputStream.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsINetService.h"
|
||||
#include "plstr.h"
|
||||
#include "plevent.h"
|
||||
#include "nsRepository.h"
|
||||
|
||||
#define RDF_DB "file:///sitemap.rdf"
|
||||
#define RDF_DB "test.rdf"
|
||||
#define SUCCESS 0
|
||||
#define FAILURE -1
|
||||
|
||||
|
||||
#ifdef XP_PC
|
||||
#define NETLIB_DLL "netlib.dll"
|
||||
#endif
|
||||
|
||||
#include "nsIPostToServer.h"
|
||||
#include "nsINetService.h"
|
||||
|
||||
|
||||
static NS_DEFINE_IID(kNetServiceCID, NS_NETSERVICE_CID);
|
||||
|
||||
NS_DEFINE_IID(kIPostToServerIID, NS_IPOSTTOSERVER_IID);
|
||||
|
||||
void fail(char* msg);
|
||||
|
||||
int
|
||||
main(int argc, char** argv)
|
||||
{
|
||||
nsIRDFService* pRDF = 0;
|
||||
PL_InitializeEventsLib("");
|
||||
nsRepository::RegisterFactory(kNetServiceCID, NETLIB_DLL, PR_FALSE, PR_FALSE);
|
||||
|
||||
NS_GetRDFService( &pRDF );
|
||||
PR_ASSERT( pRDF != 0 );
|
||||
@@ -37,30 +59,30 @@ main(int argc, char** argv)
|
||||
|
||||
/* turn on logging */
|
||||
|
||||
pRDF->CreateDatabase( url, &pDB );
|
||||
pRDF->CreateDatabase((const char**) url, &pDB );
|
||||
PR_ASSERT( pDB != 0 );
|
||||
|
||||
/* execute queries */
|
||||
RDF_Resource resource = 0;
|
||||
if( NS_OK != pDB->CreateResource("http://www.hotwired.com", &resource) )
|
||||
if( NS_OK != pDB->CreateResource("test.rdf#root", &resource) )
|
||||
fail("Unable to get resource on db!!!\n");
|
||||
RDF_Resource child = 0;
|
||||
if( NS_OK != pDB->GetResource("child", &resource) )
|
||||
fail("Unable to get resource 'child'!!!\n");
|
||||
PR_ASSERT( child != 0 );
|
||||
RDF_Resource parent = 0;
|
||||
if( NS_OK != pDB->GetResource("parent", &parent) )
|
||||
fail("Unable to get resource 'parent'!!!\n");
|
||||
PR_ASSERT(parent != 0 );
|
||||
{
|
||||
// enumerate children
|
||||
nsIRDFCursor* cursor;
|
||||
if( NS_OK != pDB->GetTargets( resource, child, RDF_RESOURCE_TYPE, &cursor ) )
|
||||
if( NS_OK != pDB->GetSources(resource, parent, RDF_RESOURCE_TYPE, &cursor ) )
|
||||
fail("Unable to get targets on db\n!!!");
|
||||
|
||||
PRBool hasElements;
|
||||
cursor->HasElements( hasElements );
|
||||
while( hasElements ) {
|
||||
RDF_NodeStruct node;
|
||||
cursor->Next( node );
|
||||
RDF_NodeStruct node;
|
||||
cursor->Next(node);
|
||||
while(node.value.r != NULL) {
|
||||
char* url;
|
||||
pRDF->ResourceIdentifier(node.value.r, &url);
|
||||
printf("%s\n", url );
|
||||
pDB->ReleaseResource( node.value.r );
|
||||
cursor->HasElements( hasElements );
|
||||
cursor->Next(node);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user