Back to index

lightning-sunbird  0.9+nobinonly
Defines | Functions
nsstrseq.cpp File Reference
#include <string.h>
#include <stdlib.h>
#include <windows.h>
#include <windowsx.h>
#include "nsstrseq.h"

Go to the source code of this file.

Defines

#define NULL   '\0'
#define MARKER   '\377'

Functions

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

Define Documentation

#define MARKER   '\377'

Definition at line 55 of file nsstrseq.cpp.

#define NULL   '\0'

Definition at line 52 of file nsstrseq.cpp.


Function Documentation

static LPSTR correct ( LPSTR  s) [static]

Definition at line 169 of file nsstrseq.cpp.

{
  if (s[0]==MARKER)
    return s+1;
  else  // Anup , 4/96
    return s;
}

Here is the caller graph for this function:

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: