Ejemplo n.º 1
0
/* maintain a sorted list of file names; add if not present */ 
static Content *content_add(const char *name) { 
    if (!content_head) { /* list empty */ 
	Content *e = content_new(name); 
	e->next=NULL; content_head=e; 
	flog("link %s at head",name); 
	return e; 
    } else { 
	Content *f; 
	for (f=content_head; f->next && strcmp(name,f->name)!=0; f=f->next) ;
	if (strcmp(f->name,name)==0) { /* exact match */ 
	    flog("reuse record for %s",name); 
	    return f; 
	} else { // at tail => insert
	    Content *e = content_new(name); 
	    e->next = NULL; f->next=e; 
	    flog("link %s after %s",name,f->name); 
	    return e; 
	} 
    } 
} 
Ejemplo n.º 2
0
/*
** Given a UUID, return the corresponding record ID.  If the UUID
** does not exist, then return 0.
**
** For this routine, the UUID must be exact.  For a match against
** user input with mixed case, use resolve_uuid().
**
** If the UUID is not found and phantomize is 1 or 2, then attempt to 
** create a phantom record.  A private phantom is created for 2 and
** a public phantom is created for 1.
*/
int uuid_to_rid(const char *zUuid, int phantomize){
  int rid, sz;
  char z[UUID_SIZE+1];
  
  sz = strlen(zUuid);
  if( sz!=UUID_SIZE || !validate16(zUuid, sz) ){
    return 0;
  }
  memcpy(z, zUuid, UUID_SIZE+1);
  canonical16(z, sz);
  rid = fast_uuid_to_rid(z);
  if( rid==0 && phantomize ){
    rid = content_new(zUuid, phantomize-1);
  }
  return rid;
}