bunch of fixes to make it run properly under Solaris

This commit is contained in:
guha%netscape.com 1998-12-13 23:45:53 +00:00
Родитель 36188f0b5c
Коммит 439d8f2706
7 изменённых файлов: 43 добавлений и 31 удалений

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

@ -16,6 +16,9 @@
* Reserved.
*/
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "rdf.h"
RDF_Resource
@ -30,7 +33,7 @@ getNodeFromQuery (char* query) {
void
AnswerOpenDirQuery (WriteClientProc callBack, void* obj, char *query) {
char *buff = malloc(10000);
char *buff = (char*) malloc(10000);
RDF_Resource items[300];
RDF_Resource topics[100];
RDF_Resource child = RDF_GetResource("child", 1);
@ -44,8 +47,8 @@ AnswerOpenDirQuery (WriteClientProc callBack, void* obj, char *query) {
if (node) {
RDF_Cursor c = RDF_GetTargets(0, node, child, RDF_RESOURCE_TYPE);
RDF_Resource ans = 0;
while (c && (ans = RDF_NextValue(c))) {
RDF_Resource ans ;
while (c && (ans = (RDF_Resource) RDF_NextValue(c))) {
int subjectp = RDF_HasAssertion(0, ans, type, topic, RDF_RESOURCE_TYPE);
if (subjectp) {
topics[topicCount++] = ans;
@ -63,7 +66,7 @@ AnswerOpenDirQuery (WriteClientProc callBack, void* obj, char *query) {
(*callBack)(obj, "<tr>");
while ((w < ROW_WIDTH) && (n < topicCount)) {
RDF_Resource u = topics[n];
char* nm = RDF_OnePropValue(0, u, name, RDF_STRING_TYPE);
char* nm = (char*) RDF_OnePropValue(0, u, name, RDF_STRING_TYPE);
char* id = RDF_ResourceID(u);
sprintf(buff, "<td><li><a href=\"OpenDir?%s\">%s</a></td>", id, (nm ? nm : id));
(*callBack)(obj, buff);
@ -82,7 +85,7 @@ AnswerOpenDirQuery (WriteClientProc callBack, void* obj, char *query) {
int w = 0;
RDF_Resource u = items[n];
char* nm = RDF_OnePropValue(0, u, name, RDF_STRING_TYPE);
char* nm = (char*) RDF_OnePropValue(0, u, name, RDF_STRING_TYPE);
char* id = RDF_ResourceID(u);
sprintf(buff, "<li><a href=\"%s\">%s</a>", id, (nm ? nm : id));
(*callBack)(obj, buff);

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

@ -35,7 +35,7 @@ typedef struct _HashTableStruct {
HashEntry* buckets; /* vector of hash buckets */
} HashTableStruct;
typedef HashTableStruct* HashTable;
int
hashKey (HashTable ht, char* key) {

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

@ -19,7 +19,7 @@
#include "ONEiiop.h"
#include "rdf.h"
#if !defined(WIN32) && !defined(HPUX) && !defined(OSF1)
#if !defined(WIN32)
extern "C" int gethostname(char *name, int namelen);
#endif
@ -37,7 +37,7 @@ void AnswerOpenDirQuery(WriteClientProc callBack, void* obj, char* query);
long
Run(ServerSession_t obj)
{
char* query = malloc(300);
char* query = (char*) malloc(300);
WAIgetRequestInfo(obj, "QUERY", &query);
//WAIsetResponseContentLength(obj, 10000);
@ -115,6 +115,7 @@ int main(int argc, char **argv)
#endif
WAIregisterService(obj, host);
RDF_Initialize();
printf("RDF Initialized!\n");
RDF_ReadFile("excite.rdf");
printf("done");

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

@ -44,7 +44,7 @@ typedef struct _RDF_ResourceStruct {
struct _RDF_AssertionStruct* rarg2;
} RDF_ResourceStruct ;
typedef RDF_ResourceStruct* RDF_Resource;
typedef enum {
@ -69,7 +69,7 @@ typedef struct _RDF_FileStruct {
struct _RDF_AssertionStruct** assertionList;
} RDF_FileStruct;
typedef RDF_FileStruct* RDFT;
typedef struct _RDF_CursorStruct {
RDF_Resource u;
@ -83,7 +83,7 @@ typedef struct _RDF_CursorStruct {
QueryType queryType;
} RDF_CursorStruct;
typedef RDF_CursorStruct* RDF_Cursor;
typedef struct _RDF_AssertionStruct {
RDF_Resource u;
@ -103,7 +103,7 @@ HashTable NewHashTable(int size) ;
void* HashLookup(HashTable ht, char* key) ;
void HashAdd (HashTable ht, char* key, void* value) ;
void readRDFFile (char* file) ;
RDF_Resource getResource(char* url, int createp);
char* getMem(size_t n);
char* fgetMem (size_t size) ;

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

@ -81,6 +81,7 @@ void RDF_DisposeCursor (RDF_Cursor c) {
char** RDF_processPathQuery(char* query) {
// return processRDFQuery (query) ;
return 0;
}

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

@ -18,6 +18,7 @@
#include "rdf-int.h"
#include <stdio.h>
char* error_string = NULL;
int lineNumber = 0;
@ -26,7 +27,7 @@ static HashTable resourceHash = NULL;
RDF_Resource
getResource (char* key, int createp) {
RDF_Resource existing = HashLookup(resourceHash, key);
RDF_Resource existing = (RDF_Resource) HashLookup(resourceHash, key);
if (existing) {
return existing;
} else if (createp){
@ -47,8 +48,9 @@ size_t allocated = 0;
#define MEM_BLOCK_SIZE 10000
char*
fgetMem (size_t size) {
fgetMem (size_t rsize) {
char* ans = 0;
size_t size = rsize + (4 - ldiv(rsize, 4).rem);
if (!MemBlock || (size >= (MEM_BLOCK_SIZE - allocated))) {
MemBlock = getMem(MEM_BLOCK_SIZE);
allocated = 0;
@ -64,11 +66,12 @@ void readRDFFile (char* file) {
if (f) {
RDFT rf = (RDFT)getRDFT(file, 1) ;
int ok = 1;
char* buff = malloc(100 * 1024);
char* buff = (char*) malloc(100 * 1024);
int len ;
int i = 0;
memset(buff, '\0', (100 * 1024));
memset(rf, '\0', sizeof(RDF_FileStruct));
rf->line = (char*)getMem(RDF_BUF_SIZE);
rf->holdOver = (char*)getMem(RDF_BUF_SIZE);
rf->depth = 1;
@ -76,6 +79,7 @@ void readRDFFile (char* file) {
while ((len = fread(buff, 1, (100 * 1024) -1, f)) > 0) {
buff[len] = '\0';
printf("[%i] ", i++);
fflush(0);
if (!(ok = parseNextRDFXMLBlobInt(rf, buff, len))) {
printf("Error in RDF File\n");
}
@ -93,7 +97,7 @@ static HashTable rdftHash = NULL;
RDFT
getRDFT (char* key, int createp) {
RDFT existing = HashLookup(rdftHash, key);
RDFT existing = (RDFT) HashLookup(rdftHash, key);
if (existing) {
return existing;
} else if (createp){
@ -328,6 +332,8 @@ parseNextRDFToken (RDFT f, char* token)
char* attlist[2*MAX_ATTRIBUTES+1];
char* elementName;
fflush(0);
if (token[0] != '<') {
if ((f->status == EXPECTING_OBJECT) && (f->depth > 1)) {
@ -337,7 +343,7 @@ parseNextRDFToken (RDFT f, char* token)
remoteStoreAdd(f, u, s, val , RDF_STRING_TYPE, 1);
return 1;
} else {
sprintf(error_string, "Did not expect \n\"%s\".\n Was expecting a tag.", token);
printf(error_string, "Did not expect \n\"%s\".\n Was expecting a tag.", token);
return 0;
}
} else if (startsWith("<!--", token)) {
@ -346,7 +352,7 @@ parseNextRDFToken (RDFT f, char* token)
return 1;
} else if (token[1] == '/') {
if ((f->status != EXPECTING_OBJECT) && (f->status != EXPECTING_PROPERTY)) {
sprintf(error_string, "Did not expect %s. Something pretty screwed up", token);
printf(error_string, "Did not expect %s. Something pretty screwed up", token);
return 0;
}
if (f->depth > 0) f->depth--;
@ -367,9 +373,9 @@ parseNextRDFToken (RDFT f, char* token)
url = getID(attlist);
if (!url) {
if (f->tagDepth > 2) {
sprintf(error_string, "Unbalanced tags ");
printf(error_string, "Unbalanced tags ");
} else {
sprintf(error_string, "Require a \"about\" attribute on %s", token);
printf(error_string, "Require a \"about\" attribute on %s", token);
}
return 0;
}
@ -405,6 +411,7 @@ parseNextRDFToken (RDFT f, char* token)
f->status = EXPECTING_OBJECT;
}
}
return 1;
}
}

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

@ -27,7 +27,7 @@ asEqual(RDFT r, Assertion as, RDF_Resource u, RDF_Resource s, void* v,
(as->s == s) &&
(as->type == type) &&
((as->value == v) ||
((type == RDF_STRING_TYPE) && (strcmp(v, as->value) == 0))));
((type == RDF_STRING_TYPE) && (strcmp((char*)v, (char*)as->value) == 0))));
}
@ -50,7 +50,7 @@ void
addToAssertionList (RDFT f, Assertion as)
{
if (f->assertionListCount >= f->assertionListSize) {
f->assertionList = realloc(f->assertionList,
f->assertionList = (Assertion*) realloc(f->assertionList,
(sizeof(Assertion*) *
(f->assertionListSize =
f->assertionListSize + GROW_LIST_INCR)));