Back to index

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

Go to the source code of this file.

Defines

#define __SEQUENCES_OF_STRINGS_H

Typedefs

typedef LPSTR NSstringSeq

Functions

void NSStrSeqDelete (NSstringSeq seq)
NSstringSeq NSStrSeqNew (LPSTR strings[])
LONG NSStrSeqSize (NSstringSeq seq)
LONG NSStrSeqNumStrs (NSstringSeq seq)
LPSTR NSStrSeqGet (NSstringSeq seq, LONG index)
LPSTRNSStrSeqGetAll (NSstringSeq seq)

Define Documentation

Definition at line 38 of file nsstrseq.h.


Typedef Documentation

typedef LPSTR NSstringSeq

Definition at line 41 of file nsstrseq.h.


Function Documentation

Definition at line 60 of file nsstrseq.cpp.

{
  if (seq != NULL)
    free(seq);
  
  seq = NULL;
}

Here is the caller graph for this function:

LPSTR NSStrSeqGet ( NSstringSeq  seq,
LONG  index 
)

Definition at line 180 of file nsstrseq.cpp.

{
  char* s;
  int N;

  if (!seq)
  {
    return NULL;
  }
  
  if (index<0)
  {
    return NULL;
  }
  
  if (!index)
    return correct(seq);
  
  for (s=seq+1,N=0; ((*s) || (*(s-1))) && (N<index); s++)
  {
    if (!(*s))
      N++;
  }
  
  if (N==index)
    return correct(s);
  
  return NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 210 of file nsstrseq.cpp.

{
  LONG N=NSStrSeqNumStrs(seq);
  if (N<0)
    return NULL;
  
  {
    char** res=(char**)malloc( (size_t) ((N+1)*sizeof(char*)) );
    int i;
    
    if (!res)
    {
      return NULL;
    }
    for (i=0; i<N; i++)
      res[i]=NSStrSeqGet(seq,i);
    res[N]=NULL;
    
    return res;
  }
}

Here is the call graph for this function:

NSstringSeq NSStrSeqNew ( LPSTR  strings[])

Definition at line 71 of file nsstrseq.cpp.

{
  int size;
  if (!strings)
  {
    return NULL;
  }
  
  {
    int i;
    for (i=0,size=0; strings[i]; i++)
    {
      size+=strlen(strings[i])+1;
      switch (strings[i][0])
      {
        // Need to pad "" or anything starting with 255 
        // to allow for multiple blank strings in a row
      case 0:
      case MARKER:
        size++;
        break;
        
      default:
        break;
      }
    }
  }
  
  {
    NSstringSeq s=(NSstringSeq)malloc(size+1);
    if (!s)
    {  return NULL;}
    
    {
      int i,offset;
      for (i=0,offset=0; strings[i]; i++)
      {
        switch (strings[i][0])
        {
          // Need to pad "" or anything starting with 255
        case 0:
        case MARKER:
          s[offset++]=MARKER;
          break;
          
        default:
          break;
        }
        strcpy(s+offset,strings[i]);
        offset+=strlen(strings[i])+1;
      }
      s[offset]=0;
    }
    
    return s;
  }
}

Here is the caller graph for this function:

Definition at line 151 of file nsstrseq.cpp.

{
  const char* s;
  int N;
  if (!seq)
  {
    return -1;
  }
  
  for (s=seq+1,N=0; ((*s) || (*(s-1))); s++)
  {
    if (!(*s))
      N++;
  }
  
  return N;
}

Here is the caller graph for this function:

Definition at line 132 of file nsstrseq.cpp.

{
  const char* s;
  if (!seq)
    {
      return -1;
    }

  for (s=seq+1; ((*s) || (*(s-1))); s++)
    ;

  // At this point, s points to the second 0 
  // of the double 0 at the end 
  return (s-seq)+1;
}

Here is the caller graph for this function: