Back to index

libcitadel  8.12
Functions
MSet is sort of a derived hashlist, its special for treating Messagesets as Citadel uses them to store access rangesx
Hashlist Key Value list implementation;
Collaboration diagram for MSet is sort of a derived hashlist, its special for treating Messagesets as Citadel uses them to store access rangesx:

Functions

int ParseMSet (MSet **MSetList, StrBuf *MSetStr)
 parses an MSet string into a list for later use
int IsInMSetList (MSet *MSetList, long MsgNo)
 checks whether a message is inside a mset
void DeleteMSet (MSet **FreeMe)
 frees a mset [redirects to DeleteHash

Function Documentation

void DeleteMSet ( MSet **  FreeMe)

frees a mset [redirects to DeleteHash

Parameters:
FreeMeto be free'd

Definition at line 1271 of file hash.c.

{
       DeleteHash((HashList**) FreeMe);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int IsInMSetList ( MSet MSetList,
long  MsgNo 
)

checks whether a message is inside a mset

Parameters:
MSetListList to search for MsgNo
MsgNonumber to search in mset

first, find out were we could fit in...

Definition at line 1220 of file hash.c.

{
       /* basicaly we are a ... */
       long MemberPosition;
       HashList *Hash = (HashList*) MSetList;
       long HashAt;
       long EndAt;
       long StartAt;

       if (Hash == NULL)
              return 0;
       if (Hash->MemberSize == 0)
              return 0;
       HashAt = FindInHash(Hash, MsgNo);
       
       /* we're below the first entry, so not found. */
       if (HashAt < 0)
              return 0;
       /* upper edge? move to last item */
       if (HashAt >= Hash->nMembersUsed)
              HashAt = Hash->nMembersUsed - 1;
       /* Match? then we got it. */
       else if (Hash->LookupTable[HashAt]->Key == MsgNo)
              return 1;
       /* One above possible range start? we need to move to the lower one. */ 
       else if ((HashAt > 0) && 
               (Hash->LookupTable[HashAt]->Key > MsgNo))
              HashAt -=1;

       /* Fetch the actual data */
       StartAt = Hash->LookupTable[HashAt]->Key;
       MemberPosition = Hash->LookupTable[HashAt]->Position;
       EndAt = *(long*) Hash->Members[MemberPosition]->Data;
       if ((MsgNo >= StartAt) && (EndAt == LONG_MAX))
              return 1;
       /* no range? */
       if (EndAt == 0)
              return 0;
       /* inside of range? */
       if ((StartAt <= MsgNo) && (EndAt >= MsgNo))
              return 1;
       return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int ParseMSet ( MSet **  MSetList,
StrBuf MSetStr 
)

parses an MSet string into a list for later use

Parameters:
MSetListList to be read from MSetStr
MSetStrString containing the list

Definition at line 1164 of file hash.c.

{
       const char *POS = NULL, *SetPOS = NULL;
       StrBuf *OneSet;
       HashList *ThisMSet;
       long StartSet, EndSet;
       long *pEndSet;
       
       *MSetList = NULL;
       if ((MSetStr == NULL) || (StrLength(MSetStr) == 0))
           return 0;
           
       OneSet = NewStrBufPlain(NULL, StrLength(MSetStr));

       ThisMSet = NewHash(0, lFlathash);

       *MSetList = (MSet*) ThisMSet;

       /* an MSet is a coma separated value list. */
       StrBufExtract_NextToken(OneSet, MSetStr, &POS, ',');
       do {
              SetPOS = NULL;

              /* One set may consist of two Numbers: Start + optional End */
              StartSet = StrBufExtractNext_long(OneSet, &SetPOS, ':');
              EndSet = 0; /* no range is our default. */
              /* do we have an end (aka range?) */
              if ((SetPOS != NULL) && (SetPOS != StrBufNOTNULL))
              {
                     if (*(SetPOS) == '*')
                            EndSet = LONG_MAX; /* ranges with '*' go until infinity */
                     else 
                            /* in other cases, get the EndPoint */
                            EndSet = StrBufExtractNext_long(OneSet, &SetPOS, ':');
              }

              pEndSet = (long*) malloc (sizeof(long));
              *pEndSet = EndSet;

              Put(ThisMSet, LKEY(StartSet), pEndSet, NULL);
              /* if we don't have another, we're done. */
              if (POS == StrBufNOTNULL)
                     break;
              StrBufExtract_NextToken(OneSet, MSetStr, &POS, ',');
       } while (1);
       FreeStrBuf(&OneSet);

       return 1;
}

Here is the call graph for this function:

Here is the caller graph for this function: