removing dead test code, might resurrect dsds, not part of build, moa=me

This commit is contained in:
axel%pike.org 2004-04-24 09:34:21 +00:00
parent 3d9f621775
commit 7bcf3c16a3
8 changed files with 0 additions and 896 deletions

View File

@ -1,2 +0,0 @@
Makefile
localfile

View File

@ -1,54 +0,0 @@
#
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (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/MPL/
#
# 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.org code.
#
# The Initial Developer of the Original Code is
# Netscape Communications Corporation.
# Portions created by the Initial Developer are Copyright (C) 1998
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
#
# Alternatively, the contents of this file may be used under the terms of
# either of the GNU General Public License Version 2 or later (the "GPL"),
# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
PROGRAM = localfile
CPPSRCS = localfile.cpp
LIBS = \
$(XPCOM_LIBS) \
$(NSPR_LIBS) \
$(NULL)
include $(topsrcdir)/config/rules.mk

View File

@ -1,197 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (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/MPL/
*
* 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.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/*
This is a test script that uses the nsStreamDataSource class to read
a file from the local file system (using a "file:" URL) and write it
back. The idea is that the RDF that gets written out should be
equivalent (but not necessarily identical) to the RDF that was read
in.
Currently, the nsFileSpec stuff is _really_ sensitive to Win32 file
names: be sure to use a file URL that looks like
"file://G:/tmp/foo.rdf"; that is, two forward-slashes after the
"file:", a drive letter specification with a colon (not a pipe), and
forward-slashes in the path.
*/
#ifndef XP_UNIX
#include <io.h>
#endif
#include "nsXPCOM.h"
#include "nsIContent.h"
#include "nsIEventQueueService.h"
#include "nsIInputStream.h"
#include "nsIIOService.h"
#include "nsIOutputStream.h"
#include "nsIPostToServer.h"
#include "nsIRDFXMLDataSource.h"
#include "nsIRDFDocument.h"
#include "nsIRDFNode.h"
#include "nsIRDFService.h"
#include "nsIRDFXMLSource.h"
#include "nsIServiceManager.h"
#include "nsIStreamListener.h"
#include "nsIURL.h"
#include "nsDOMCID.h" // for NS_SCRIPT_NAMESET_REGISTRY_CID
#include "nsRDFCID.h"
#include "nsRDFCID.h"
#include "nsIComponentManager.h"
#include "plevent.h"
#include "plstr.h"
#include "rdf.h"
////////////////////////////////////////////////////////////////////////
// CIDs
// netlib
// rdf
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
static NS_DEFINE_CID(kRDFXMLDataSourceCID, NS_RDFXMLDATASOURCE_CID);
// xpcom
static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
////////////////////////////////////////////////////////////////////////
// IIDs
NS_DEFINE_IID(kIEventQueueServiceIID, NS_IEVENTQUEUESERVICE_IID);
NS_DEFINE_IID(kIRDFServiceIID, NS_IRDFSERVICE_IID);
NS_DEFINE_IID(kIRDFXMLDataSourceIID, NS_IRDFXMLDATASOURCE_IID);
////////////////////////////////////////////////////////////////////////
int
main(int argc, char** argv)
{
nsresult rv;
if (argc < 2) {
fprintf(stderr, "usage: %s [url]\n", argv[0]);
return 1;
}
rv = NS_InitXPCOM2(nsnull, nsnull, nsnull);
if (NS_FAILED(rv)) {
fprintf(stderr, "NS_InitXPCOM2 failed\n");
return 1;
}
nsIEventQueueService* theEventQueueService = nsnull;
nsIEventQueue* mainQueue = nsnull;
nsIRDFService* theRDFService = nsnull;
nsIRDFXMLDataSource* ds = nsnull;
nsIRDFResource* theHomePage = nsnull;
nsIRDFResource* NC_title = nsnull;
nsIRDFLiteral* theTitle = nsnull;
// Get netlib off the floor...
if (NS_FAILED(rv = nsServiceManager::GetService(kEventQueueServiceCID,
kIEventQueueServiceIID,
(nsISupports**) &theEventQueueService)))
goto done;
if (NS_FAILED(rv = theEventQueueService->GetThreadEventQueue(NS_CURRENT_THREAD,
&mainQueue)))
goto done;
NS_IF_RELEASE(mainQueue);
// Create a stream data source and initialize it on argv[1], which
// is hopefully a "file:" URL. (Actually, we can do _any_ kind of
// URL, but only a "file:" URL will be written back to disk.)
if (NS_FAILED(rv = nsComponentManager::CreateInstance(kRDFXMLDataSourceCID,
nsnull,
kIRDFXMLDataSourceIID,
(void**) &ds)))
goto done;
if (NS_FAILED(rv = ds->SetSynchronous(PR_TRUE)))
goto done;
// Okay, this should load the XML file...
if (NS_FAILED(rv = ds->Init(argv[1])))
goto done;
// Now take the graph and munge it a little bit...
if (NS_FAILED(rv = nsServiceManager::GetService(kRDFServiceCID,
kIRDFServiceIID,
(nsISupports**) &theRDFService)))
goto done;
if (NS_FAILED(rv = theRDFService->GetResource("http://home.netscape.com", &theHomePage)))
goto done;
if (NS_FAILED(rv = theRDFService->GetResource(NC_NAMESPACE_URI "title", &NC_title)))
goto done;
if (NS_FAILED(rv = theRDFService->GetLiteral(nsAutoString("Netscape's Home Page"), &theTitle)))
goto done;
if (NS_FAILED(rv = ds->Assert(theHomePage, NC_title, theTitle, PR_TRUE)))
goto done;
// And finally, write it back out.
if (NS_FAILED(rv = ds->Flush()))
goto done;
done:
NS_IF_RELEASE(theTitle);
NS_IF_RELEASE(NC_title);
NS_IF_RELEASE(theHomePage);
NS_IF_RELEASE(ds);
if (theRDFService) {
nsServiceManager::ReleaseService(kRDFServiceCID, theRDFService);
theRDFService = nsnull;
}
if (theEventQueueService) {
nsServiceManager::ReleaseService(kEventQueueServiceCID, theEventQueueService);
theEventQueueService = nsnull;
}
return (NS_FAILED(rv) ? 1 : 0);
}

View File

@ -1,2 +0,0 @@
Makefile
rdfsink

View File

@ -1,54 +0,0 @@
#
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (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/MPL/
#
# 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.org code.
#
# The Initial Developer of the Original Code is
# Netscape Communications Corporation.
# Portions created by the Initial Developer are Copyright (C) 1998
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
#
# Alternatively, the contents of this file may be used under the terms of
# either of the GNU General Public License Version 2 or later (the "GPL"),
# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
PROGRAM = rdfsink
CPPSRCS = rdfsink.cpp
LIBS = \
$(XPCOM_LIBS) \
$(NSPR_LIBS) \
$(NULL)
include $(topsrcdir)/config/rules.mk

View File

@ -1,202 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (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/MPL/
*
* 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.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsXPCOM.h"
#include "nsIEventQueueService.h"
#include "nsIInputStream.h"
#include "nsIIOService.h"
#include "nsIOutputStream.h"
#include "nsIPostToServer.h"
#include "nsIRDFCompositeDataSource.h"
#include "nsIRDFXMLDataSource.h"
#include "nsIRDFDocument.h"
#include "nsIRDFNode.h"
#include "nsIRDFService.h"
#include "nsIRDFXMLSource.h"
#include "nsIServiceManager.h"
#include "nsIStreamListener.h"
#include "nsIURL.h"
#include "nsRDFCID.h"
#include "nsIComponentManager.h"
#include "plevent.h"
#include "plstr.h"
////////////////////////////////////////////////////////////////////////
// CIDs
// rdf
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
static NS_DEFINE_CID(kRDFXMLDataSourceCID, NS_RDFXMLDATASOURCE_CID);
// xpcom
static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
////////////////////////////////////////////////////////////////////////
// IIDs
NS_DEFINE_IID(kIEventQueueServiceIID, NS_IEVENTQUEUESERVICE_IID);
NS_DEFINE_IID(kIRDFXMLDataSourceIID, NS_IRDFXMLDATASOURCE_IID);
NS_DEFINE_IID(kIRDFXMLSourceIID, NS_IRDFXMLSOURCE_IID);
////////////////////////////////////////////////////////////////////////
class ConsoleOutputStreamImpl : public nsIOutputStream
{
public:
ConsoleOutputStreamImpl(void) {}
virtual ~ConsoleOutputStreamImpl(void) {}
// nsISupports interface
NS_DECL_ISUPPORTS
// nsIBaseStream interface
NS_IMETHOD Close(void) {
return NS_OK;
}
// nsIOutputStream interface
NS_IMETHOD Write(const char* aBuf, PRUint32 aCount, PRUint32 *aWriteCount) {
PR_Write(PR_GetSpecialFD(PR_StandardOutput), aBuf, aCount);
*aWriteCount = aCount;
return NS_OK;
}
NS_IMETHOD Flush() {
PR_Sync(PR_GetSpecialFD(PR_StandardOutput));
return NS_OK;
}
};
NS_IMPL_ISUPPORTS1(ConsoleOutputStreamImpl, nsIOutputStream)
////////////////////////////////////////////////////////////////////////
int
main(int argc, char** argv)
{
nsresult rv;
if (argc < 2) {
fprintf(stderr, "usage: %s [url]\n", argv[0]);
return 1;
}
rv = NS_InitXPCOM2(nsnull, nsnull, nsnull);
if (NS_FAILED(rv)) {
fprintf(stderr, "NS_InitXPCOM2 failed\n");
return 1;
}
nsIEventQueueService* theEventQueueService = nsnull;
nsIEventQueue* mainQueue = nsnull;
nsIRDFService* theRDFService = nsnull;
nsIRDFXMLDataSource* ds = nsnull;
nsIOutputStream* out = nsnull;
nsIRDFXMLSource* source = nsnull;
// Get netlib off the floor...
if (NS_FAILED(rv = nsServiceManager::GetService(kEventQueueServiceCID,
kIEventQueueServiceIID,
(nsISupports**) &theEventQueueService))) {
NS_ERROR("unable to get event queue service");
goto done;
}
if (NS_FAILED(rv = theEventQueueService->GetThreadEventQueue(NS_CURRENT_THREAD,
&mainQueue))) {
NS_ERROR("unable to get event queue for current thread");
goto done;
}
NS_IF_RELEASE(mainQueue);
// Create a stream data source and initialize it on argv[1], which
// is hopefully a "file:" URL. (Actually, we can do _any_ kind of
// URL, but only a "file:" URL will be written back to disk.)
if (NS_FAILED(rv = nsComponentManager::CreateInstance(kRDFXMLDataSourceCID,
nsnull,
kIRDFXMLDataSourceIID,
(void**) &ds))) {
NS_ERROR("unable to create RDF/XML data source");
goto done;
}
if (NS_FAILED(rv = ds->SetSynchronous(PR_TRUE))) {
NS_ERROR("unable to mark data source as synchronous");
goto done;
}
// Okay, this should load the XML file...
if (NS_FAILED(rv = ds->Init(argv[1]))) {
NS_ERROR("unable to initialize data source");
goto done;
}
// And finally, write it back out.
if ((out = new ConsoleOutputStreamImpl()) == nsnull) {
NS_ERROR("unable to create console output stream");
rv = NS_ERROR_OUT_OF_MEMORY;
goto done;
}
NS_ADDREF(out);
if (NS_FAILED(rv = ds->QueryInterface(kIRDFXMLSourceIID, (void**) &source))) {
NS_ERROR("unable to RDF/XML interface");
goto done;
}
if (NS_FAILED(rv = source->Serialize(out))) {
NS_ERROR("error serializing");
goto done;
}
done:
NS_IF_RELEASE(out);
NS_IF_RELEASE(ds);
if (theRDFService) {
nsServiceManager::ReleaseService(kRDFServiceCID, theRDFService);
theRDFService = nsnull;
}
if (theEventQueueService) {
nsServiceManager::ReleaseService(kEventQueueServiceCID, theEventQueueService);
theEventQueueService = nsnull;
}
return (NS_FAILED(rv) ? 1 : 0);
}

View File

@ -1,237 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (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/MPL/
*
* 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 the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "rdf.h"
#include "rdfutil.h"
#include "prtypes.h"
#include "prmem.h"
#include "nscore.h"
#include "nsIOutputStream.h"
#include "plhash.h"
#include "plstr.h"
typedef struct _SerializedHashTable {
FILE* file;
PLHashTable* table;
char* buffer;
size_t maxEntrySize;
} SerializedHashTable;
typedef SerializedHashTable* SHT;
typedef struct _SHTEntry {
void* value;
size_t size;
size_t offset;
} SHTEntry;
typedef SHTEntry* SHTE;
void
dumpHashItem (SHT table, char* key, size_t keyLen, void* value, size_t valueSize) {
fprintf(table->file, "A %i\n%s\n%i\n", keyLen, key, valueSize);
fwrite(value, 1, valueSize, table->file);
fprintf(table->file, "\n");
}
PRBool
readNextItem(FILE *file, char** key, char** value, size_t *valueSize, PRBool *ignorep,
int *offset) {
char *xkey, *xvalue;
int keySize;
char ignoreChar;
char tbuff[10];
*offset = ftell(file);
if (!fgets((char*)tbuff, 10, file)) return 0;
if (tbuff[0] == 'X') return 0;
sscanf(tbuff, "%c %i", &ignoreChar, &keySize);
xkey = (char*) PR_Malloc(keySize + 1);
if (!fgets(xkey, keySize+1, file)) return 0;
fread(tbuff, 1, 1, file);
memset(tbuff, '\0', 10);
if (!fgets((char*)tbuff, 10, file)) return 0;
sscanf(tbuff, "%i", valueSize);
xvalue = (char*) PR_Malloc(*valueSize + 1);
xvalue[*valueSize] = '\0';
if (!fread(xvalue, *valueSize, 1, file)) return 0;
fread(tbuff, 1, 1, file);
if (ignoreChar == 'D') {
PR_Free((void*)xvalue);
PR_Free((void*)xkey);
*ignorep = 1;
return 1;
} else {
*ignorep = 0;
*value = xvalue;
*key = xkey;
return 1;
}
}
PRIntn
SHTFlusher(PLHashEntry *he, PRIntn index, void *arg) {
SHT table = (SHT)arg;
SHTE entry = (SHTE)he->value;
char* key = (char*)he->key;
char* v1 = (char*)entry->value;
dumpHashItem(table, key, strlen(key), entry->value, entry->size);
return HT_ENUMERATE_NEXT;
}
void
FlushSHT (SHT table) {
table->buffer = (char*)PR_Malloc(table->maxEntrySize + 256);
fseek(table->file, 0, SEEK_SET);
PL_HashTableEnumerateEntries(table->table, SHTFlusher, table);
fwrite("X", 1, 1, table->file);
fflush(table->file);
PR_Free(table->buffer);
}
PLHashEntry*
SHTAddInt (PLHashTable* table, size_t valueSize, void* value, char* key, int offset) {
SHTE ve = (SHTE) PR_Malloc(sizeof(SHTEntry));
ve->value = value;
ve->size = valueSize;
ve->offset = offset;
return PL_HashTableAdd(table, key, ve);
}
SHT
MakeSerializedHash (FILE* file, PRUint32 numBuckets, PLHashFunction keyHash,
PLHashComparator keyCompare, PLHashComparator valueCompare,
const PLHashAllocOps *allocOps, void *allocPriv) {
SHT table = (SHT)PR_Malloc(sizeof(SerializedHashTable));
char* key;
char* value;
size_t valueSize;
PRBool ignorep = 0;
int offset;
table->table = PL_NewHashTable(numBuckets, keyHash,
keyCompare, valueCompare,
allocOps, allocPriv);
table->file = file;
table->maxEntrySize = 1024;
while (readNextItem(file, &key, &value, &valueSize, &ignorep, &offset)) {
SHTAddInt(table->table, valueSize, value, key, offset);
}
return table;
}
void
SHTAdd(SHT table, char *key, void *value, size_t valueSize) {
fseek(table->file, 0, SEEK_END);
SHTFlusher(SHTAddInt(table->table,valueSize, value, key, ftell(table->file)), 0, table);
fflush(table->file);
}
void
SHTRemove(SHT table, char* key) {
SHTE entry = (SHTE)PL_HashTableLookup(table->table, (void*) key);
if (entry) {
fseek(table->file, entry->offset, SEEK_SET);
fwrite("D", 1, 1, table->file);
fflush(table->file);
PL_HashTableRemove(table->table, key);
PR_Free(entry);
}
}
void*
SHTLookup(SHT ht, const char *key) {
SHTE entry = (SHTE)PL_HashTableLookup(ht->table, (void*) key);
if (entry) {
return entry->value;
} else return 0;
}
FILE*
MakeOrOpenFile (char* name) {
FILE* ans;
ans = fopen(name, "r+");
if (ans) return ans;
ans = fopen(name, "w");
fclose(ans);
return fopen(name, "r+");
}
void SHTtest () {
FILE *f = MakeOrOpenFile("test");
SHT table = MakeSerializedHash(f, 100, PL_HashString, PL_CompareStrings,
PL_CompareValues, NULL, NULL);
char buffer[1024];
printf("\n>");
while (fgets(buffer, 1023, stdin)) {
if (strncmp(buffer, "x", 1) == 0) {
FlushSHT(table);
return;
}
if (strncmp(buffer, "a", 1) ==0) {
char key[100], value[100];
char *xkey, *xvalue;
sscanf(buffer, "a %s %s", key, value);
xkey = (char*)PR_Malloc(strlen(key)+1);
xvalue = (char*)PR_Malloc(strlen(value)+1);
memset(xkey, '\0', strlen(key)+1);
memset(xvalue, '\0', strlen(value)+1);
memcpy(xkey, key, strlen(key));
memcpy(xvalue, value, strlen(value));
SHTAdd(table, xkey, xvalue, strlen(xvalue));
}
if (strncmp(buffer, "q", 1) ==0) {
char key[100];
char* ans;
sscanf(buffer, "q %s", key);
ans = (char*)SHTLookup(table, (char*)key);
printf("-> %s\n", (ans ? ans : "null"));
}
if (strncmp(buffer, "r", 1) == 0) {
char key[100];
sscanf(buffer, "r %s", key);
SHTRemove(table, key);
}
printf("\n>");
}
}

View File

@ -1,148 +0,0 @@
<RDF:RDF>
<Topic id="root" name="Wired Digital" largeIcon="http://static.wired.com/rdf/objects/w_largeIcon.gif" smallIcon="http://static.wired.com/rdf/objects/w_smallIcon.gif">
<child rdf:href="http://www.hotwired.com" name="HotWired Home Page" largeIcon="http://static.wired.com/rdf/objects/w_largeIcon.gif" smallIcon="http://static.wired.com/rdf/objects/w_smallIcon.gif"/>
<child>
<Topic id="Webmonkey" name="Webmonkey" smallIcon="http://static.wired.com/rdf/objects/webmonkey_small.gif">
<child rdf:href="http://www.webmonkey.com" name="Webmonkey Frontdoor" smallIcon="http://static.wired.com/rdf/objects/webmonkey_small.gif">
<child>
<Topic id="Crash Courses" name="Crash Courses" smallIcon="http://static.wired.com/rdf/objects/webmonkey_small.gif">
<child>
<Topic id="Web Design" name="Web Design" smallIcon="http://static.wired.com/rdf/objects/webmonkey_small.gif">
<child rdf:href="http://www.hotwired.com/webmonkey/98/07/index0a.html?collection=design" name="Day 1: The Foundations of Web Design" smallIcon="http://static.wired.com/rdf/objects/webmonkey_small.gif"/>
<child rdf:href="http://www.hotwired.com/webmonkey/98/07/index1a.html?collection=design" name="Day 2: Aesthetics for the Web" smallIcon="http://static.wired.com/rdf/objects/webmonkey_small.gif"/>
<child rdf:href="http://www.hotwired.com/webmonkey/98/07/index3a.html?collection=design" name="Day 3: Beyond The Basics" smallIcon="http://static.wired.com/rdf/objects/webmonkey_small.gif"/>
<child rdf:href="http://www.hotwired.com/webmonkey/html/97/05/index2a.html?collection=design" name="Web Design 101" smallIcon="http://static.wired.com/rdf/objects/webmonkey_small.gif"/>
<child rdf:href="http://www.hotwired.com/webmonkey/97/45/index0a.html?collection=design" name="Building a Better Monkey" smallIcon="http://static.wired.com/rdf/objects/webmonkey_small.gif"/>
<child rdf:href="http://www.hotwired.com/webmonkey/98/11/index0a.html?collection=design" name="Ecological Design Moves Online" smallIcon="http://static.wired.com/rdf/objects/webmonkey_small.gif"/>
<child rdf:href="http://www.hotwired.com/webmonkey/tools/97/39/index0a.html?collection=design" name="Test Your Designs - on People!" smallIcon="http://static.wired.com/rdf/objects/webmonkey_small.gif"/>
<child rdf:href="http://www.hotwired.com/webmonkey/98/13/index0a.html?collection=design" name="Big Minds on Web Design" smallIcon="http://static.wired.com/rdf/objects/webmonkey_small.gif"/>
<child rdf:href="http://www.hotwired.com/webmonkey/98/01/index0a.html?collection=design" name="Be Your Own Design Team" smallIcon="http://static.wired.com/rdf/objects/webmonkey_small.gif"/>
<child rdf:href="http://www.hotwired.com/webmonkey/tools/97/22/index0a.html?collection=design" name="BLINK vs. MARQUEE" smallIcon="http://static.wired.com/rdf/objects/webmonkey_small.gif"/>
<child rdf:href="http://www.hotwired.com/webmonkey/tools/97/33/index0a.html?collection=design" name="The Future of Web Navigation" smallIcon="http://static.wired.com/rdf/objects/webmonkey_small.gif"/>
<child rdf:href="http://www.hotwired.com/webmonkey/tools/97/10/index0a.html?collection=design" name="Cultural Context Revisted" smallIcon="http://static.wired.com/rdf/objects/webmonkey_small.gif"/>
<child rdf:href="http://www.hotwired.com/webmonkey/html/96/53/index3a.html?collection=design" name="Degrading Pages" smallIcon="http://static.wired.com/rdf/objects/webmonkey_small.gif"/>
<child rdf:href="http://www.hotwired.com/webmonkey/tools/97/04/index0a.html?collection=design" name="Design that Communicates Your Message" smallIcon="http://static.wired.com/rdf/objects/webmonkey_small.gif"/>
<child rdf:href="http://www.hotwired.com/webmonkey/tools/96/41/index0a.html?collection=design" name="Hypertext: The Web's Unsung Hero" smallIcon="http://static.wired.com/rdf/objects/webmonkey_small.gif"/>
<child rdf:href="http://www.hotwired.com/webmonkey/tools/97/30/index0a.html?collection=design" name="Why Channels Suck"/>
</Topic>
</child>
<child>
<Topic id="Javascript" name="Javascript" smallIcon="http://static.wired.com/rdf/objects/webmonkey_small.gif">
<child rdf:href="http://www.hotwired.com/webmonkey/98/03/index0a.html?collection=javascript" name="Thau's JavaScript Tutorial: Day 1" smallIcon="http://static.wired.com/rdf/objects/webmonkey_small.gif"/>
<child rdf:href="http://www.hotwired.com/webmonkey/98/03/index2a.html?collection=javascript" name="Thau's JavaScript Tutorial: Day 2" smallIcon="http://static.wired.com/rdf/objects/webmonkey_small.gif"/>
<child rdf:href="http://www.hotwired.com/webmonkey/98/03/index3a.html?collection=javascript" name="Thau's JavaScript Tutorial: Day 3" smallIcon="http://static.wired.com/rdf/objects/webmonkey_small.gif"/>
<child rdf:href="http://www.hotwired.com/webmonkey/98/04/index1a.html?collection=javascript" name="Thau's JavaScript Tutorial: Day 4" smallIcon="http://static.wired.com/rdf/objects/webmonkey_small.gif"/>
<child rdf:href="http://www.hotwired.com/webmonkey/98/04/index3a.html?collection=javascript" name="Thau's JavaScript Tutorial: Day 5 " smallIcon="http://static.wired.com/rdf/objects/webmonkey_small.gif"/>
</Topic>
</child>
</Topic>
</child>
<child>
<Topic id="Dynamic HTML" name="Dynamic HTML" smallIcon="http://static.wired.com/rdf/objects/webmonkey_small.gif">
<child rdf:href="http://www.hotwired.com/webmonkey/98/10/index0a.html?collection=dynamic_html" name="Taylor's Dynamic HTML Tutorial - Day 1" smallIcon="http://static.wired.com/rdf/objects/webmonkey_small.gif"/>
<child rdf:href="http://www.hotwired.com/webmonkey/98/10/index1a.html?collection=dynamic_html" name="Taylor's Dynamic HTML Tutorial - Day 2" smallIcon="http://static.wired.com/rdf/objects/webmonkey_small.gif"/>
<child rdf:href="http://www.hotwired.com/webmonkey/98/10/index2a.html?collection=dynamic_html" name="Taylor's Dynamic HTML Tutorial - Day 3" smallIcon="http://static.wired.com/rdf/objects/webmonkey_small.gif"/>
<child rdf:href="http://www.hotwired.com/webmonkey/98/10/index3a.html?collection=dynamic_html" name="Taylor's Dynamic HTML Tutorial - Day 4" smallIcon="http://static.wired.com/rdf/objects/webmonkey_small.gif"/>
<child rdf:href="http://www.hotwired.com/webmonkey/98/10/index4a.html?collection=dynamic_html" name="Taylor's Dynamic HTML Tutorial - Day 5" smallIcon="http://static.wired.com/rdf/objects/webmonkey_small.gif"/>
</Topic>
</child>
<child>
<Topic id="HTML" name="HTML" smallIcon="http://static.wired.com/rdf/objects/webmonkey_small.gif">
<child rdf:href="http://www.hotwired.com/webmonkey/teachingtool/" name="Webmonkey: HTML Tutorial" smallIcon="http://static.wired.com/rdf/objects/webmonkey_small.gif"/>
<child rdf:href="http://www.hotwired.com/webmonkey/tools/97/17/index0a.html?collection=html" name="The History of HTML " smallIcon="http://static.wired.com/rdf/objects/webmonkey_small.gif"/>
<child rdf:href="http://www.hotwired.com/webmonkey/tools/97/32/index0a.html?collection=html" name="What You Should Know about HTML 4.0" smallIcon="http://static.wired.com/rdf/objects/webmonkey_small.gif"/>
<child rdf:href="http://www.hotwired.com/webmonkey/tools/97/06/index0a.html?collection=html" name="HTML for Smart People" smallIcon="http://static.wired.com/rdf/objects/webmonkey_small.gif"/>
<child rdf:href="http://www.hotwired.com/webmonkey/geektalk/97/11/index4a.html?collection=html" name="Accessible HTML" smallIcon="http://static.wired.com/rdf/objects/webmonkey_small.gif"/>
<child rdf:href="http://www.hotwired.com/webmonkey/tools/97/07/index0a.html?collection=html" name="Getting It Right" smallIcon="http://static.wired.com/rdf/objects/webmonkey_small.gif"/>
<child rdf:href="http://www.hotwired.com/webmonkey/geektalk/97/36/index3a.html?collection=html" name="Symbols, Accents, and Funky Characters " smallIcon="http://static.wired.com/rdf/objects/webmonkey_small.gif"/>
<child rdf:href="http://www.hotwired.com/webmonkey/html/97/06/index2a.html?collection=html" name="Form(s) over Function" smallIcon="http://static.wired.com/rdf/objects/webmonkey_small.gif"/>
<child>
<Topic id="Frames" name="Frames" smallIcon="http://static.wired.com/rdf/objects/webmonkey_small.gif">
<child rdf:href="http://www.hotwired.com/webmonkey/html/96/31/index3a.html?collection=html" name="Frames Are A Picnic (Metaphorically Speaking)" smallIcon="http://static.wired.com/rdf/objects/webmonkey_small.gif"/>
<child rdf:href="http://www.hotwired.com/webmonkey/geektalk/97/24/index3a.html?collection=html" name="Basic Frames Rehash" smallIcon="http://static.wired.com/rdf/objects/webmonkey_small.gif"/>
<child rdf:href="http://www.hotwired.com/webmonkey/geektalk/97/02/index4a.html?collection=html" name="Changing Two Frames at Once" smallIcon="http://static.wired.com/rdf/objects/webmonkey_small.gif"/>
<child rdf:href="http://www.hotwired.com/webmonkey/html/96/36/index2a.html?collection=html" name="Let's Talk Targeting" smallIcon="http://static.wired.com/rdf/objects/webmonkey_small.gif"/>
<child rdf:href="http://www.hotwired.com/webmonkey/html/96/33/index2a.html?collection=html" name="Don't Forget the Non-Frames Folks" smallIcon="http://static.wired.com/rdf/objects/webmonkey_small.gif"/>
</Topic>
</child>
<child>
<Topic id="Tables" name="Tables" smallIcon="http://static.wired.com/rdf/objects/webmonkey_small.gif">
<child rdf:href="http://www.hotwired.com/webmonkey/html/96/47/index3a.html?collection=html" name="The Basic, Basic Table" smallIcon="http://static.wired.com/rdf/objects/webmonkey_small.gif"/>
<child rdf:href="http://www.hotwired.com/webmonkey/html/96/48/index2a.html?collection=html" name="The Not-So-Basic Table" smallIcon="http://static.wired.com/rdf/objects/webmonkey_small.gif"/>
<child rdf:href="http://www.hotwired.com/webmonkey/html/96/38/index2a.html?collection=html" name="The Well-Dressed Table" smallIcon="http://static.wired.com/rdf/objects/webmonkey_small.gif"/>
</Topic>
</child>
</Topic>
</child>
<child>
<Topic id="XML" name="XML" smallIcon="http://static.wired.com/rdf/objects/webmonkey_small.gif">
<child rdf:href="http://www.hotwired.com/webmonkey/tools/97/27/index0a.html?collection=html" name="XML: Metadata for the Rest of Us (Part 1)" smallIcon="http://static.wired.com/rdf/objects/webmonkey_small.gif"/>
<child rdf:href="http://www.hotwired.com/webmonkey/tools/97/28/index0a.html?collection=html" name="XML: Roll Your Own Markup Language (Part 2)" smallIcon="http://static.wired.com/rdf/objects/webmonkey_small.gif"/>
<child rdf:href="http://www.hotwired.com/webmonkey/tools/97/43/index0a.html?collection=html" name="Acronyms You Can't Live Without" smallIcon="http://static.wired.com/rdf/objects/webmonkey_small.gif"/>
<child rdf:href="http://www.hotwired.com/webmonkey/97/48/index0a.html?collection=design" name="Smart Web Publishing into the Future" smallIcon="http://static.wired.com/rdf/objects/webmonkey_small.gif"/>
</Topic>
</child>
<child>
<Topic id="Stylesheets" name="Stylesheets" smallIcon="http://static.wired.com/rdf/objects/webmonkey_small.gif">
<child rdf:href="http://www.hotwired.com/webmonkey/html/96/34/index2a.html?collection=stylesheets" name="Inject some style (sheets) into your HTML" smallIcon="http://static.wired.com/rdf/objects/webmonkey_small.gif"/>
<child rdf:href="http://www.hotwired.com/webmonkey/tools/96/33/index0a.html?collection=stylesheets" name="The Wonderful World of Stylesheets" smallIcon="http://static.wired.com/rdf/objects/webmonkey_small.gif"/>
<child rdf:href="http://www.hotwired.com/webmonkey/tools/97/35/index0a.html?collection=stylesheets" name="Stylesheets - the next generation" smallIcon="http://static.wired.com/rdf/objects/webmonkey_small.gif"/>
<child rdf:href="http://www.hotwired.com/webmonkey/demo/96/43/index4a.html?collection=stylesheets" name="Where are All the GIFs?" smallIcon="http://static.wired.com/rdf/objects/webmonkey_small.gif"/>
<child rdf:href="http://www.hotwired.com/webmonkey/html/97/25/index2a.html?collection=stylesheets" name="Positioning with Stylesheets " smallIcon="http://static.wired.com/rdf/objects/webmonkey_small.gif"/>
<child rdf:href="http://www.hotwired.com/webmonkey/tools/97/34/index0a.html?collection=stylesheets" name="CSS Filters and the Future" smallIcon="http://static.wired.com/rdf/objects/webmonkey_small.gif"/>
<child rdf:href="http://www.hotwired.com/webmonkey/html/97/33/index1a.html?collection=stylesheets" name="Image Filtering with CSS" smallIcon="http://static.wired.com/rdf/objects/webmonkey_small.gif"/>
<child rdf:href="http://www.hotwired.com/webmonkey/html/97/38/index1a.html?collection=stylesheets" name="Captain CURSOR!!!" smallIcon="http://static.wired.com/rdf/objects/webmonkey_small.gif"/>
<child rdf:href="http://www.hotwired.com/webmonkey/tools/97/13/index0a.html?collection=stylesheets" name="Time for stylesheets? Not quite yet." smallIcon="http://static.wired.com/rdf/objects/webmonkey_small.gif"/>
</Topic>
</child>
</child>
<child rdf:href="http://www.hotwired.com/webmonkey/mail/mail.html" name="Subscribe to Webmonkey!" smallIcon="http://static.wired.com/rdf/objects/webmonkey_small.gif"/>
<child rdf:href="http://www.hotwired.com/webmonkey/tuneup/" name="Browser Tuneup" smallIcon="http://static.wired.com/rdf/objects/webmonkey_small.gif"/>
<child rdf:href="http://www.hotwired.com/webmonkey/hideout/" name="About Webmonkey" smallIcon="http://static.wired.com/rdf/objects/webmonkey_small.gif"/>
</Topic>
</child>
<child>
<Topic name="Wired News" smallIcon="http://static.wired.com/rdf/objects/wirednews_small.gif">
<child rdf:href="http://www.wired.com/news/" name="Wired News Home Page" smallIcon="http://static.wired.com/rdf/objects/wirednews_small.gif"/>
<child rdf:href="http://www.wired.com/news/business/" name="Business" smallIcon="http://static.wired.com/rdf/objects/finance_small.gif"/>
<child rdf:href="http://www.wired.com/news/culture/" name="Culture" smallIcon="http://static.wired.com/rdf/objects/culture_small.gif"/>
<child rdf:href="http://www.wired.com/news/technology/" name="Technology" smallIcon="http://static.wired.com/rdf/objects/tech_small.gif"/>
<child rdf:href="http://www.wired.com/news/politics/" name="Politics" smallIcon="http://static.wired.com/rdf/objects/politics_small.gif"/>
<child rdf:href="http://www.wired.com/news/worldnews/" name="Global News" smallIcon="http://static.wired.com/rdf/objects/wirednews_small.gif"/>
</Topic>
</child>
<child>
<Topic name="HotBot" smallIcon="http://static.wired.com/rdf/objects/hotbot_small.gif">
<child rdf:href="http://www.hotbot.com/" name="HotBot" smallIcon="http://static.wired.com/rdf/objects/hotbot_small.gif"/>
<child rdf:href="http://www.hotbot.com/super.html" name="SuperSearch" smallIcon="http://static.wired.com/rdf/objects/hotbot_small.gif"/>
<child>
<Topic id="Other Search Tools" name="Other Search Tools" smallIcon="http://static.wired.com/rdf/objects/hotbot_small.gif">
<child rdf:href="http://www.hotbot.com/usenet/" name="Usenet" smallIcon="http://static.wired.com/rdf/objects/hotbot_small.gif"/>
<child rdf:href="http://www.newsbot.com/" name="Top News Sites" smallIcon="http://static.wired.com/rdf/objects/hotbot_small.gif"/>
<child rdf:href="http://www.hotbot.com/partners/business.html" name="Businesses" smallIcon="http://static.wired.com/rdf/objects/hotbot_small.gif"/>
<child rdf:href="http://www.hotbot.com/partners/people.html" name="People" smallIcon="http://static.wired.com/rdf/objects/hotbot_small.gif"/>
<child rdf:href="http://www.hotbot.com/partners/email.html" name="Email Adresses" smallIcon="http://static.wired.com/rdf/objects/hotbot_small.gif"/>
<child rdf:href="http://www.classifieds2000.com/cgi-cls/display.exe?hotbot+class" name="Classifieds" smallIcon="http://static.wired.com/rdf/objects/hotbot_small.gif"/>
<child rdf:href="http://www.hotbot.com/partners/websitez.html" name="Domain Names" smallIcon="http://static.wired.com/rdf/objects/hotbot_small.gif"/>
<child rdf:href="http://stocks.hotbot.com/" name="Stocks" smallIcon="http://static.wired.com/rdf/objects/hotbot_small.gif"/>
<child rdf:href="http://www.hotbot.com/partners/filez.html" name="ShareWare" smallIcon="http://static.wired.com/rdf/objects/hotbot_small.gif"/>
</Topic>
</child>
</Topic>
</child>
<child>
<Topic name="Wired Magazine" smallIcon="http://static.wired.com/rdf/objects/wiredmagazine_small.gif">
<child rdf:href="http://www.wired.com/wired/" name="Wired Magazine Archives" smallIcon="http://static.wired.com/rdf/objects/wiredmagazine_small.gif"/>
<child rdf:href="http://www.wired.com/wired/subscribe/" name="Subscribe to Wired Magazine" smallIcon="http://static.wired.com/rdf/objects/wiredmagazine_small.gif"/>
</Topic>
</child>
<child rdf:href="http://www.livewired.com/" name="LiveWired" smallIcon="http://static.wired.com/rdf/objects/livewired_small.gif"/>
<child rdf:href="http://www.suck.com" name="Suck.com" smallIcon="http://static.wired.com/rdf/objects/suck_small.gif"/>
</Topic>
</RDF:RDF>