Back to index

lightning-sunbird  0.9+nobinonly
Functions
gs.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void RDFGS_AddSearchIndex (RDFT db, char *string, RDF_Resource label, RDF_Resource target)
RDF_Cursor RDFGS_Search (RDFT db, char *searchString, RDF_Resource label)
RDF_Resource RDFGS_NextValue (RDF_Cursor c)
void RDFGS_DisposeCursor (RDF_Cursor c)

Function Documentation

void RDFGS_AddSearchIndex ( RDFT  db,
char *  string,
RDF_Resource  label,
RDF_Resource  target 
)

Definition at line 111 of file gs.c.

                                                                                           {
    size_t size = strlen(string);
    size_t n    = 0;
    char* stk = 0;
    TNS    prev, next;
    if (!gRootNode) gRootNode = (TNS) getMem(sizeof(TrieNodeStruct));
    prev = gRootNode;
    next = 0;
    while (n < size) {
       char c = string[n++]; 
       if (!wsCharp(c) && (c != '/')) {
          if (!stk) stk = &string[n-1];
           next = (TNS) findChildOfChar(prev, c);
            if (!next) {
              next = (TNS)fgetMem(sizeof(TrieNodeStruct));
              next->next = prev->child;
              prev->child = next;
              next->c    = tolower(c);
            }
            prev = next;            
       } else if (next) {
           int n = addTarget(db, next, label, target);
            stk = 0;
           prev = gRootNode;
        next = 0;
       }
    }
    if (next)  {
              addTarget(db, next, label, target);
              prev = gRootNode;
        next = 0;
       }
}    

Here is the call graph for this function:

Definition at line 193 of file gs.c.

                                        {
  if (c->pdata1) freeMem(c->pdata1);
  if (c->pdata2) freeMem(c->pdata2);
  freeMem(c);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 209 of file gs.c.

                                            { 
  if (!c->pdata) {
    return 0;
  } else  {
    TTS currentTTS = (TTS) c->pdata;
    while (currentTTS) {
      if (((!c->s) || (c->s == currentTTS->label)) && 
          (!alreadyAdded(currentTTS->target, c))) {
        RDF_Resource ans = currentTTS->target;
        c->pdata = currentTTS = currentTTS->next;
        if (!currentTTS && (c->pdata1)) { 
          c->pdata =  ((TTS*)c->pdata1)[c->count++];  
        }
        if (c->off < c->off1) c->pdata2[c->off++] = ans; 
        return ans;
      }       
      c->pdata = currentTTS =  currentTTS->next;
      if (!currentTTS  && (c->pdata1)) {
        c->pdata = currentTTS = ((TTS*)c->pdata1)[c->count++];  
      }
    }
  }
  return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

RDF_Cursor RDFGS_Search ( RDFT  db,
char *  searchString,
RDF_Resource  label 
)

Definition at line 170 of file gs.c.

                                                                          {
    RDF_Cursor c = (RDF_Cursor) getMem(sizeof(RDF_CursorStruct));
    size_t n = 0;
    size_t m = 0;
    c->searchString = searchString;
    c->s = label;
    c->db = db;
    c->pdata = findChildOfString(gRootNode, searchString);
    if (!c->pdata) return c;
    countChildren((TNS)c->pdata, &n, &m);
    c->pdata2 = (RDF_Resource*) getMem(sizeof(RDF_Resource) * (m+1)); 
    c->off1 = m;
    if (n > 0) {
      c->count = 0;
      c->pdata1 = getMem(sizeof(TTS) * (n+1));
      fillUpChildren(c, (TNS)c->pdata);
      c->count = 1;
    }
    if (c->pdata) c->pdata = ((TNS)c->pdata)->targets;

    return c;
}

Here is the call graph for this function:

Here is the caller graph for this function: