Back to index

lightning-sunbird  0.9+nobinonly
Classes | Defines | Typedefs | Enumerations | Functions
rdf-int.h File Reference
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "rdf.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _RDF_ResourceStruct
struct  _RDF_FileStruct
struct  _RDF_CursorStruct
struct  _RDF_AssertionStruct

Defines

#define true   1
#define false   0
#define null   NULL
#define nullp(x)   (((void*)x) == ((void*)0))
#define noRDFErr   0
#define noMoreValuesErr   1
#define LookupResource(x)   ((RDF_Resource)PL_HashTableLookup(resourceHash, x));
#define stringEquals(x, y)   (strcmp(x, y) ==0)
#define wsCharp(c)   ((c == '\r') || (c == '\t') || (c == ' ') || (c == '\n'))
#define RDF_BUF_SIZE   (4096 * 16)
#define MAX_ATTRIBUTES   256
#define EXPECTING_OBJECT   1
#define EXPECTING_PROPERTY   2
#define GROW_LIST_INCR   1000

Typedefs

typedef struct _RDF_ResourceStruct RDF_ResourceStruct
typedef struct _RDF_FileStruct RDF_FileStruct
typedef struct _RDF_CursorStruct RDF_CursorStruct
typedef struct _RDF_AssertionStruct RDF_AssertionStruct
typedef RDF_AssertionStructAssertion
typedef struct _HashTableStructHashTable

Enumerations

enum  QueryType { GET_SLOT_VALUES, ARC_LABELS_IN, ARC_LABELS_OUT, SEARCH }

Functions

HashTable NewHashTable (int size)
voidHashLookup (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)
void freeMem (void *item)
RDFT initFileStruct (char *url)
void rdf_init ()
int startsWith (const char *pattern, const char *uuid)
char decodeEntityRef (char *string, int *stringIndexPtr, int len)
char * copyStringIgnoreWhiteSpace (char *string)
char * getHref (char **attlist)
int parseNextRDFXMLBlobInt (RDFT f, char *blob, int size)
char * getAttributeValue (char **attlist, char *elName)
int tagEquals (RDFT f, char *tag1, char *tag2)
void addElementProps (char **attlist, char *elementName, RDFT f, RDF_Resource obj)
int knownObjectElement (char *eln)
char * possiblyMakeAbsolute (RDFT f, char *url)
int containerTagp (RDFT f, char *elementName)
RDF_Resource ResourceFromElementName (RDFT f, char *elementName)
int parseNextRDFToken (RDFT f, char *token)
int tokenizeElement (char *attr, char **attlist, char **elementName)
void addSlotValue (RDFT f, RDF_Resource u, RDF_Resource s, void *v, RDF_ValueType type, char *op)
char * copyString (char *str)
char * fcopyString (char *str)
int 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, int tv)
void freeAssertion (Assertion as)
Assertion remoteStoreAdd (RDFT mcf, RDF_Resource u, RDF_Resource s, void *v, RDF_ValueType type, int tv)
Assertion remoteStoreRemove (RDFT mcf, RDF_Resource u, RDF_Resource s, void *v, RDF_ValueType type)
int remoteStoreHasAssertion (RDFT mcf, RDF_Resource u, RDF_Resource s, void *v, RDF_ValueType type, int tv)
voidgetSlotValue (RDFT mcf, RDF_Resource u, RDF_Resource s, RDF_ValueType type, int inversep, int tv)
RDF_Cursor getSlotValues (RDFT mcf, RDF_Resource u, RDF_Resource s, RDF_ValueType type, int inversep, int tv)
voidnextValue (RDF_Cursor c)
void disposeCursor (RDF_Cursor c)
void unloadRDFT (RDFT f)
int rdf_DigestNewStuff (char *fileName, char *data, int len)
RDFT getRDFT (char *url, int createp)
char ** processRDFQuery (char *query)

Class Documentation

struct _RDF_ResourceStruct

Definition at line 60 of file rdf-int.h.

Collaboration diagram for _RDF_ResourceStruct:
Class Members
struct _RDF_AssertionStruct * rarg1
struct _RDF_AssertionStruct * rarg2
char * url
struct _RDF_FileStruct

Definition at line 77 of file rdf-int.h.

Collaboration diagram for _RDF_FileStruct:
Class Members
struct _RDF_AssertionStruct ** assertionList
int assertionListCount
int assertionListSize
int depth
char * holdOver
RDF_Resource lastItem
char * line
char * nsList
int nsStackPoint
RDF_Resource stack
int status
char * storeAway
int tagDepth
char * url
struct _RDF_CursorStruct

Definition at line 96 of file rdf-int.h.

Collaboration diagram for _RDF_CursorStruct:
Class Members
size_t count
RDFT db
int inversep
size_t off
size_t off1
void * pdata
void * pdata1
RDF_Resource * pdata2
QueryType queryType
RDF_Resource s
char * searchString
RDF_ValueType type
RDF_Resource u
void * value
struct _RDF_AssertionStruct

Definition at line 115 of file rdf-int.h.

Collaboration diagram for _RDF_AssertionStruct:
Class Members
RDFT db
struct _RDF_AssertionStruct * invNext
struct _RDF_AssertionStruct * next
RDF_Resource s
RDF_ValueType type
RDF_Resource u
void * value

Define Documentation

Definition at line 56 of file rdf-int.h.

Definition at line 57 of file rdf-int.h.

#define false   0

Definition at line 43 of file rdf-int.h.

#define GROW_LIST_INCR   1000

Definition at line 58 of file rdf-int.h.

Definition at line 50 of file rdf-int.h.

Definition at line 55 of file rdf-int.h.

Definition at line 48 of file rdf-int.h.

#define noRDFErr   0

Definition at line 47 of file rdf-int.h.

#define null   NULL

Definition at line 45 of file rdf-int.h.

#define nullp (   x)    (((void*)x) == ((void*)0))

Definition at line 46 of file rdf-int.h.

#define RDF_BUF_SIZE   (4096 * 16)

Definition at line 54 of file rdf-int.h.

#define stringEquals (   x,
  y 
)    (strcmp(x, y) ==0)

Definition at line 51 of file rdf-int.h.

#define true   1

Definition at line 42 of file rdf-int.h.

#define wsCharp (   c)    ((c == '\r') || (c == '\t') || (c == ' ') || (c == '\n'))

Definition at line 53 of file rdf-int.h.


Typedef Documentation

Definition at line 126 of file rdf-int.h.

typedef struct _HashTableStruct* HashTable

Definition at line 127 of file rdf-int.h.


Enumeration Type Documentation

enum QueryType
Enumerator:
GET_SLOT_VALUES 
ARC_LABELS_IN 
ARC_LABELS_OUT 
SEARCH 

Definition at line 69 of file rdf-int.h.


Function Documentation

void addElementProps ( char **  attlist,
char *  elementName,
RDFT  f,
RDF_Resource  obj 
)

Definition at line 347 of file rdfparse.c.

{
  int count = 0;
  while (count < 2*MAX_ATTRIBUTES) {
    char* attName = attlist[count++];
    char* attValue = attlist[count++];
    char* baseName;
    if ((attName == NULL) || (attValue == NULL)) break;
    baseName  = strchr(attName, ':');
    if (baseName) attName = baseName + 1;
    if (startsWith("xmlns", attName)) {
      /* addNameSpace(attName, attValue, f); */
    } else if (!stringEquals(attName, "resource") && 
        !stringEquals(attName, "rdf:resource")  && 
        !stringEquals(attName, "about") && 
        !stringEquals(attName, "rdf:about") && 
        !stringEquals(attName, "tv") &&
        !stringEquals(attName, "id")) {
      remoteStoreAdd(f, obj, getResource(attName, 1), 
                   copyStringIgnoreWhiteSpace(attValue), 
                   RDF_STRING_TYPE, 1);
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void addSlotValue ( RDFT  f,
RDF_Resource  u,
RDF_Resource  s,
void v,
RDF_ValueType  type,
char *  op 
)
int asEqual ( RDFT  r,
Assertion  as,
RDF_Resource  u,
RDF_Resource  s,
void v,
RDF_ValueType  type 
)

Definition at line 41 of file remstore.c.

{
  return (((r == NULL) || (as->db == r)) && 
         (as->u == u) && 
         (as->s == s) && 
         (as->type == type) && 
         ((as->value == v) || 
          ((type == RDF_STRING_TYPE) && (strcmp((char*)v, (char*)as->value) == 0))));
}

Here is the caller graph for this function:

int containerTagp ( RDFT  f,
char *  elementName 
)
char* copyString ( char *  str)

Definition at line 327 of file rdfparse.c.

                       {
  char* ans = getMem(strlen(str)+1);
  if (ans) {
    memcpy(ans, str, strlen(str));
    return ans;
  } else return NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function:

char* copyStringIgnoreWhiteSpace ( char *  string)

Definition at line 204 of file rdfparse.c.

{
   int len = strlen(string);
   char* buf = (char*)fgetMem(len + 1);
   int inWhiteSpace = 1;
   int buffIndex = 0;
   int stringIndex = 0;

   while (stringIndex < len) {
     char nextChar = *(string + stringIndex);
     int 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;
}

Here is the call graph for this function:

Here is the caller graph for this function:

char decodeEntityRef ( char *  string,
int stringIndexPtr,
int  len 
)

Definition at line 190 of file rdfparse.c.

                                                             {
  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 '&';
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 213 of file remstore.c.

{
  if (c) freeMem(c);
}

Here is the call graph for this function:

Here is the caller graph for this function:

char* fcopyString ( char *  str)

Definition at line 336 of file rdfparse.c.

                        {
  char* ans = fgetMem(strlen(str)+1);
  if (ans) {
    memcpy(ans, str, strlen(str));
    return ans;
  } else return NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function:

char* fgetMem ( size_t  size)

Definition at line 78 of file rdfparse.c.

                       {
  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;
  }
  ans = MemBlock;
  MemBlock = MemBlock + size;
  allocated = allocated + size;
  return ans;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 81 of file remstore.c.

{
  if (as->type == RDF_STRING_TYPE) {
    freeMem(as->value);
  } 
  freeMem(as);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void freeMem ( void item)

Definition at line 185 of file rdfparse.c.

                    {
  free(item);
}

Here is the caller graph for this function:

char* getAttributeValue ( char **  attlist,
char *  elName 
)

Definition at line 312 of file rdfparse.c.

{
  size_t n = 0;
  if (!attlist) return NULL;
  while ((n < 2*MAX_ATTRIBUTES) && (*(attlist + n) != NULL)) {
    char* attname = *(attlist + n);
    char* base = strchr(attname, ':');
    if (base) attname = base + 1;
    if (strcmp(attname, elName) == 0) return *(attlist + n + 1);
    n = n + 2;
  }
  return NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function:

char* getHref ( char **  attlist)

Definition at line 236 of file rdfparse.c.

{
       char* ans = getAttributeValue(attlist, "resource");
       if (!ans) ans = getAttributeValue(attlist, "rdf:resource");
       return ans;
}

Here is the call graph for this function:

Here is the caller graph for this function:

char* getMem ( size_t  n)

Definition at line 180 of file rdfparse.c.

                  {
  return (char*) calloc(1, n);
}

Here is the call graph for this function:

Here is the caller graph for this function:

RDFT getRDFT ( char *  url,
int  createp 
)

Definition at line 127 of file rdfparse.c.

                                 {
  RDFT existing = (RDFT) HashLookup(rdftHash, key);
  if (existing) {
    return existing;
  } else if (createp){
    existing = (RDFT)getMem(sizeof(RDF_FileStruct));
    existing->url = fcopyString(key);
    HashAdd(rdftHash, existing->url, existing);
    return existing;
  } else return NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function:

RDF_Resource getResource ( char *  url,
int  createp 
)

Definition at line 50 of file rdfparse.c.

                                     {
  RDF_Resource existing = (RDF_Resource) HashLookup(resourceHash, key);
  if (existing) {
    return existing;
  } else if (createp){
    existing = (RDF_Resource)fgetMem(sizeof(RDF_ResourceStruct));
    existing->url = fcopyString(key);
    HashAdd(resourceHash, existing->url, existing);
    if (!gURL) {
      gURL = (RDF_Resource)fgetMem(sizeof(RDF_ResourceStruct));
      gURL->url = fcopyString("URL");
      HashAdd(resourceHash, gURL->url, gURL);
    }
    remoteStoreAdd(NULL, existing, gURL, existing->url, RDF_STRING_TYPE,1); 
    return existing;
  } else return NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void* getSlotValue ( RDFT  mcf,
RDF_Resource  u,
RDF_Resource  s,
RDF_ValueType  type,
int  inversep,
int  tv 
)

Definition at line 164 of file remstore.c.

{
  Assertion nextAs;

  nextAs = (inversep ? u->rarg2 : u->rarg1);
  while (nextAs != null) {
    if (((nextAs->db == mcf) || (!mcf)) && (nextAs->s == s) 
        && (nextAs->type == type)) {
      return (inversep ? nextAs->u : nextAs->value);
    }
    nextAs = (inversep ? nextAs->invNext : nextAs->next);
  }
  return null;
}

Here is the caller graph for this function:

RDF_Cursor getSlotValues ( RDFT  mcf,
RDF_Resource  u,
RDF_Resource  s,
RDF_ValueType  type,
int  inversep,
int  tv 
)

Definition at line 180 of file remstore.c.

{
  Assertion as = (inversep ? u->rarg2 : u->rarg1);
  RDF_Cursor c;
  if (!as) return NULL;
  c = (RDF_Cursor)getMem(sizeof(RDF_CursorStruct));
  c->u = u;
  c->s = s;
  c->type = type;
  c->inversep = inversep;
  c->count = 0;
  c->db = mcf;
  c->pdata = as;
  c->queryType = GET_SLOT_VALUES; 
  return c;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void HashAdd ( HashTable  ht,
char *  key,
void value 
)

Definition at line 94 of file hash.c.

                                               {
    int offset = hashKey(ht, key);
    HashEntry he = ht->buckets[offset];
    HashEntry prev = he;
    while (he) {
       if (strcmp(he->key, key) == 0) {
           if (value == he->value) {
              return;
           } else {
              he->value = value;
              return;
           }
       }
       prev = he;
       he = he->next;
    }
       if (startsWith("http://", key)) {
              itemCount++;
       } else {
              catCount++;
       }
    he = (HashEntry) fgetMem(sizeof(HashEntryStruct));
    he->value = value;
    he->key   = key;
    if (prev) {
      prev->next = he;
    } else {
      ht->buckets[offset] = he;
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void* HashLookup ( HashTable  ht,
char *  key 
)

Definition at line 80 of file hash.c.

                                    {
    int offset = hashKey(ht, key);
    HashEntry he = ht->buckets[offset];
    while (he) {
       if (strcmp(he->key, key) == 0) return he->value;
       he = he->next;
    }
    return NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function:

RDFT initFileStruct ( char *  url)

Here is the caller graph for this function:

int knownObjectElement ( char *  eln)
Assertion makeNewAssertion ( RDFT  r,
RDF_Resource  u,
RDF_Resource  s,
void v,
RDF_ValueType  type,
int  tv 
)

Definition at line 55 of file remstore.c.

{
  Assertion newAs = (Assertion) fgetMem(sizeof(RDF_AssertionStruct));
  newAs->u = u;
  newAs->s = s;
  newAs->value = v;
  newAs->type = type;
  newAs->db = r;
  return newAs;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 72 of file hash.c.

                       {
    HashTable ht = (HashTable)getMem(sizeof(HashTableStruct));
    ht->size = size;
    ht->buckets = (HashEntry*)getMem(sizeof(HashEntry) * size);
    return ht;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 198 of file remstore.c.

                         {
  if (!c) return null;
  while (c->pdata != null) {
    Assertion as = (Assertion) c->pdata;
    if (((as->db == c->db) || (!c->db)) && (as->s == c->s) &&  (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;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int parseNextRDFToken ( RDFT  f,
char *  token 
)

Definition at line 373 of file rdfparse.c.

{
  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];
      char* val      = copyStringIgnoreWhiteSpace(token);
      remoteStoreAdd(f, u, s, val , RDF_STRING_TYPE, 1);
         return 1;
    } else  {
      printf(error_string, "Did not expect \n\"%s\".\n Was expecting a tag.", token);
      return 0;
    } 
  } else if  (startsWith("<!--", token)) {
    return 1;
  } else if (token[1] == '?')  {
    return 1;
  } else if (token[1] == '/') {
    if ((f->status != EXPECTING_OBJECT) && (f->status != EXPECTING_PROPERTY)) {
      printf(error_string, "Did not expect %s. Something pretty screwed up", token);
      return 0;
    }
    if (f->depth > 0) f->depth--;
    f->status = (f->status == EXPECTING_OBJECT ? EXPECTING_PROPERTY : EXPECTING_OBJECT);
    return 1;
  } else if ((f->status == 0) && (startsWith("<RDF:RDF", token) || 
                                  startsWith("<RDF", token))) {
    f->status = EXPECTING_OBJECT;
    return 1;
  } else {
    int emptyElementp = (token[strlen(token)-2] == '/');  
    if ((f->status != EXPECTING_OBJECT) && (f->status != EXPECTING_PROPERTY)) return 1;
    if (!tokenizeElement(token, attlist, &elementName)) return 0;
    if (f->status == EXPECTING_OBJECT) {
      char* url = NULL;
      RDF_Resource obj;
      int count = 0;    
      url = getID(attlist);
      if (!url) {
        if (f->tagDepth > 2) {
          printf(error_string, "Unbalanced tags ");
        } else {
          printf(error_string, "Require a \"about\" attribute on %s", token);
        }
        return 0;
      }
      obj =  getResource(url, 1);
      addElementProps (attlist, elementName, f, obj) ;
      if (!stringEquals(elementName, "RDF:Description")) {
          RDF_Resource eln = getResource(elementName, 1);
          remoteStoreAdd(f, obj, getResource("type", 1), 
                       eln, RDF_RESOURCE_TYPE, 
                       1);        
      }
      if (f->depth > 1) {
        remoteStoreAdd(f, f->stack[f->depth-2], f->stack[f->depth-1], obj, 
                     RDF_RESOURCE_TYPE, 1);
      }
      if (!emptyElementp) {
        f->stack[f->depth++] = obj;
        f->status = EXPECTING_PROPERTY;
      }
    } else if (f->status == EXPECTING_PROPERTY) {
      char* url;
      RDF_Resource obj;
      int count = 0;
      url = getHref(attlist) ;      
      if (url) {
        RDF_Resource eln = getResource(elementName, 1);      
        obj =  getResource(url, 1);        
        addElementProps (attlist, elementName, f, obj) ;     
        remoteStoreAdd(f, f->stack[f->depth-1], eln, obj, RDF_RESOURCE_TYPE,  1);
        /* printf("%s %s %s\n", RDF_ResourceID(f->stack[f->depth-1]), 
               RDF_ResourceID(eln), url); */
      } 
      if (!emptyElementp) {
        f->stack[f->depth++] = getResource(elementName, 1);
        f->status = EXPECTING_OBJECT;
      }
    }
    return 1;
  }
}      

Here is the call graph for this function:

Here is the caller graph for this function:

int parseNextRDFXMLBlobInt ( RDFT  f,
char *  blob,
int  size 
)

Definition at line 255 of file rdfparse.c.

                                                     {
  int n, last, m;
  int somethingseenp = 0;
  n = last = 0; 
  while (n < size) {
    char c = blob[n];
    if ((c == '\n') || (c == '\r')) lineNumber++;
    m = 0;
    somethingseenp = 0;
    /*    memset(f->line, '\0', RDF_BUF_SIZE-1); */
    if (f->holdOver[0] != '\0') {
      memcpy(f->line, f->holdOver, strlen(f->holdOver));
      m = strlen(f->holdOver);
      somethingseenp = 1;
         f->holdOver[0] = '\0';
      /*    memset(f->holdOver, '\0', RDF_BUF_SIZE-1); */
    }   
    while ((n < size) && (wsCharp(c))  && (!somethingseenp)) {
      c = blob[++n]; 
      if ((c == '\n') || (c == '\r')) lineNumber++;
    }
    while ((m < RDF_BUF_SIZE-1) && (c != '<') && (c != '>')) {
      f->line[m] = c;
      m++;
      somethingseenp = (somethingseenp || (!(wsCharp(c))));
      n++;    
      if (n < size) c = blob[n]; 
      else break;
      if ((c == '\n') || (c == '\r')) lineNumber++;
    }
    f->line[m] = '\0';
    f->line[m+1] = '\0';
    if (c == '>') f->line[m] = c;
    n++;
    if (m > 0) {
      if ((c == '<') || (c == '>')) {
        last = n;
        if (c == '<') {
          f->holdOver[0] = '<'; 
          f->holdOver[1] = '\0';
              }
        if (somethingseenp == 1) {
          parseNextRDFToken(f, f->line);
        }
      } else if (size > last) {
        memcpy(f->holdOver, f->line, m);
        f->holdOver[m] = '\0';
      }
    } else if (c == '<') {
      f->holdOver[0] = '<';
      f->holdOver[1] = '\0';
    }
  }
  return(1);
}

Here is the call graph for this function:

Here is the caller graph for this function:

char* possiblyMakeAbsolute ( RDFT  f,
char *  url 
)
char** processRDFQuery ( char *  query)

Definition at line 102 of file query.c.

                              {
    RDF_Resource root;
    int          numSegments;
    int count = 0;
    char** ans = NULL;
    QuerySegment* querySegments = parseQuery(query, &root, &numSegments);
    int          n = 0;
    QuerySegment current = NULL;
    QuerySegment prev    = NULL;
    char** currentValArray = (char**)getMem(sizeof(RDF_Resource)*2);
    char** newValArray     = (char**)getMem(4096 * sizeof(RDF_Resource));
    currentValArray[0] = (char*) root;
    for (n = 0; n < numSegments; n++) {
      QuerySegment q = querySegments[n];     
      int nc = 0;
      int ansType = ((n == numSegments-1) ? RDF_STRING_TYPE : RDF_RESOURCE_TYPE);
         count = 0;
      for (nc = 0; currentValArray[nc] != NULL; nc++) {
           RDF_Cursor c = getSlotValues(NULL, (RDF_Resource)currentValArray[nc], q->s, 
                                     ansType, q->inversep, 1);
           RDF_Resource ans;
            int lc = 0;
           while (c  && (lc++ <= q->num) && (ans = nextValue(c))) {
              newValArray[count] = (char*) ans;
              count++;
           }
        if (c) disposeCursor(c);
      }
      freeMem(currentValArray);
      currentValArray = newValArray;
      newValArray = (char**) getMem(4096 * sizeof(RDF_Resource));
    }
    freeMem(newValArray);
    if (count > 0) {
      ans = (char**)getMem((count+1) * sizeof(char*));
      memcpy(ans, currentValArray, (count * sizeof(char*)));
    }
    freeMem(currentValArray);
    for (n = 0; n < numSegments; n++) freeMem(querySegments[n]);     
    return ans;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int rdf_DigestNewStuff ( char *  fileName,
char *  data,
int  len 
)

Definition at line 147 of file rdfparse.c.

                                                    {
  RDFT rf = (RDFT)getRDFT(url, 1) ; 
  int ok = 1;
  RDF_Resource u;
  unloadRDFT(rf);
  memset(rf, '\0', sizeof(RDF_FileStruct));
  rf->line = (char*)getMem(RDF_BUF_SIZE);
  rf->holdOver = (char*)getMem(RDF_BUF_SIZE);
  rf->depth = 1;
  rf->lastItem = rf->stack[0] ; 
  ok = parseNextRDFXMLBlobInt(rf, data, len);  
  /* if (!ok) unloadRDFT(rf); */
  freeMem(rf->line);
  rf->line = NULL;
  freeMem(rf->holdOver);
  rf->holdOver = NULL;
  return ok;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 140 of file rdfparse.c.

            {
  error_string = getMem(1000);
  resourceHash = NewHashTable((int)0x00000FFF);
  rdftHash = NewHashTable((int)0x00000FFF);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void readRDFFile ( char *  file)

Definition at line 91 of file rdfparse.c.

                              {
  FILE* f = fopen(file, "r");      
  if (f) {
    RDFT rf = (RDFT)getRDFT(file, 1) ; 
    int ok = 1;
    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;
    rf->lastItem = rf->stack[0] ;
    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");
      }
    }
    
    freeMem(rf->line);
    rf->line = NULL;
    freeMem(rf->holdOver);
    rf->holdOver = NULL;
    free(buff);
    printf("Finished reading %s\n", file); 
  } else  printf("Could not find %s\n", file);    
}

Here is the call graph for this function:

Here is the caller graph for this function:

Assertion remoteStoreAdd ( RDFT  mcf,
RDF_Resource  u,
RDF_Resource  s,
void v,
RDF_ValueType  type,
int  tv 
)

Definition at line 91 of file remstore.c.

{
  Assertion  newAs = makeNewAssertion(mcf, u, s, v, type, tv);
  newAs->next = u->rarg1;
  u->rarg1 = newAs;

  if (type == RDF_RESOURCE_TYPE) {
    RDF_Resource iu = (RDF_Resource)v;
    newAs->invNext  = iu->rarg2;
    iu->rarg2       = newAs;
  }
  /*  if (type == RDF_STRING_TYPE)   RDFGS_AddSearchIndex(mcf, (char*) v, s, u); */
  
  return newAs;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int remoteStoreHasAssertion ( RDFT  mcf,
RDF_Resource  u,
RDF_Resource  s,
void v,
RDF_ValueType  type,
int  tv 
)

Definition at line 149 of file remstore.c.

{
  Assertion nextAs;
  
  nextAs = u->rarg1;
  while (nextAs != null) {
    if (asEqual(mcf, nextAs, u, s, v, type)) return true;
    nextAs = nextAs->next;
  }
  return false;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 110 of file remstore.c.

{
  Assertion nextAs, prevAs, ans;
  int 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;
    }
  }
  return ans;
}

Here is the call graph for this function:

Here is the caller graph for this function:

RDF_Resource ResourceFromElementName ( RDFT  f,
char *  elementName 
)
int startsWith ( const char *  pattern,
const char *  uuid 
)

Definition at line 168 of file rdfparse.c.

                                                   {
  int l1 = strlen(pattern);
  int l2 = strlen(uuid);
  int n;
  if (l2 < l1) return 0;
  for (n = 0; n < l1; n++) {
    if (pattern[n] != uuid[n]) return 0;
  } 
  return 1;
}
int tagEquals ( RDFT  f,
char *  tag1,
char *  tag2 
)
int tokenizeElement ( char *  attr,
char **  attlist,
char **  elementName 
)

Definition at line 463 of file rdfparse.c.

{
  size_t n = 1;
  size_t s = strlen(attr); 
  char c ;
  size_t m = 0;
  size_t atc = 0;
  char* base;
  int emptyTagp =  (attr[s-2] == '/');
  int inAttrNamep = 1;
  c = attr[n++]; 
  while (wsCharp(c)) {
    c = attr[n++];
  }
  *elementName = &attr[n-1];
  while (n < s) {
    if (wsCharp(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) {
    int attributeOpenStringSeenp = 0;
    m = 0;
    c = attr[n++];
    while ((n <= s) && (atc < 2*MAX_ATTRIBUTES)) {
      if (inAttrNamep && (m > 0) && (wsCharp(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) || (!wsCharp(c))) m++;
      } else {
       if (c == '"') {
         attributeOpenStringSeenp = 1;
       } else {
         if ((m > 0) || (!(wsCharp(c)))) m++;
       }
      }
      c = attr[n++];
    }
    inAttrNamep = (inAttrNamep ? 0 : 1);
  }
  base = strchr(*elementName, ':');
  if (base) *elementName = base+1;
  return 1;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 220 of file remstore.c.

{
  int n = 0;
  while (n < f->assertionListCount) {
    Assertion as = *(f->assertionList + n);
    remoteStoreRemove(f, as->u, as->s, as->value, as->type);
    freeAssertion(as);
    *(f->assertionList + n) = NULL;
    n++;
  }
  f->assertionListCount = 0;
  f->assertionListSize = 0;
  freeMem(f->assertionList);
  f->assertionList = NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function: