Back to index

lightning-sunbird  0.9+nobinonly
Classes | Defines | Functions | Variables
nsVCardObj.cpp File Reference
#include "prlog.h"
#include "nsVCard.h"
#include "nsVCardObj.h"
#include "prmem.h"
#include "plstr.h"
#include "msgCore.h"
#include "prprf.h"

Go to the source code of this file.

Classes

struct  PreDefProp

Defines

#define DBG_(x)
#define STRTBLSIZE   255
#define PD_BEGIN   0x1
#define PD_INTERNAL   0x2
#define OFILE_REALLOC_SIZE   256
#define PR_MAXQUADS   16

Functions

static VObjectnewVObject_ (const char *id)
static PRBool needsQuotedPrintable (const char *s)
VObjectnewVObject (const char *id)
void deleteVObject (VObject *p)
char * dupStr (const char *s, unsigned int size)
static StrItemnewStrItem (const char *s, StrItem *next)
void deleteString (char *p)
void deleteStrItem (StrItem *p)
const char * vObjectName (VObject *o)
void setVObjectName (VObject *o, const char *id)
const char * vObjectStringZValue (VObject *o)
void setVObjectStringZValue (VObject *o, const char *s)
void setVObjectStringZValue_ (VObject *o, const char *s)
const vwchar_tvObjectUStringZValue (VObject *o)
void setVObjectUStringZValue (VObject *o, const vwchar_t *s)
void setVObjectUStringZValue_ (VObject *o, const vwchar_t *s)
unsigned int vObjectIntegerValue (VObject *o)
void setVObjectIntegerValue (VObject *o, unsigned int i)
unsigned long vObjectLongValue (VObject *o)
void setVObjectLongValue (VObject *o, unsigned long l)
voidvObjectAnyValue (VObject *o)
void setVObjectAnyValue (VObject *o, void *t)
VObjectvObjectVObjectValue (VObject *o)
void setVObjectVObjectValue (VObject *o, VObject *p)
VObjectaddVObjectProp (VObject *o, VObject *p)
VObjectaddProp (VObject *o, const char *id)
VObjectaddProp_ (VObject *o, const char *id)
void addList (VObject **o, VObject *p)
VObjectnextVObjectInList (VObject *o)
VObjectsetValueWithSize_ (VObject *prop, void *val, unsigned int size)
VObjectsetValueWithSize (VObject *prop, void *val, unsigned int size)
void initPropIterator (VObjectIterator *i, VObject *o)
int moreIteration (VObjectIterator *i)
VObjectnextVObject (VObjectIterator *i)
VObjectisAPropertyOf (VObject *o, const char *id)
VObjectaddGroup (VObject *o, const char *g)
VObjectaddPropValue (VObject *o, const char *p, const char *v)
VObjectaddPropSizedValue_ (VObject *o, const char *p, const char *v, unsigned int size)
VObjectaddPropSizedValue (VObject *o, const char *p, const char *v, unsigned int size)
static void indent (nsOutputFileStream *fp, int level)
static void printValue (nsOutputFileStream *fp, VObject *o, int level)
static void printNameValue (nsOutputFileStream *fp, VObject *o, int level)
void printVObject_ (nsOutputFileStream *fp, VObject *o, int level)
void printVObject (nsOutputFileStream *fp, VObject *o)
void printVObjectToFile (nsFileSpec *fname, VObject *o)
void printVObjectsToFile (nsFileSpec *fname, VObject *list)
void cleanVObject (VObject *o)
void cleanVObjects (VObject *list)
static unsigned int hashStr (const char *s)
void unUseStr (const char *s)
static struct PreDefProplookupPropInfo (const char *str)
const char * lookupProp_ (const char *str)
const char * lookupProp (const char *str)
static void appendcOFile_ (OFile *fp, char c)
static void appendcOFile (OFile *fp, char c)
static void appendsOFile (OFile *fp, const char *s)
static void initOFile (OFile *fp, nsOutputFileStream *ofp)
static void initMemOFile (OFile *fp, char *s, int len)
static int writeBase64 (OFile *fp, unsigned char *s, long len)
static void writeQPString (OFile *fp, const char *s)
static void writeValue (OFile *fp, VObject *o, unsigned long size)
static void writeAttrValue (OFile *fp, VObject *o, int *length)
static void writeGroup (OFile *fp, VObject *o)
static int inList (const char **list, const char *s)
static void writeProp (OFile *fp, VObject *o)
void writeVObject_ (OFile *fp, VObject *o)
void writeVObject (nsOutputFileStream *fp, VObject *o)
void writeVObjectToFile (nsFileSpec *fname, VObject *o)
void writeVObjectsToFile (nsFileSpec *fname, VObject *list)
char * writeMemVObject (char *s, int *len, VObject *o)
char * writeMemoryVObjects (char *s, int *len, VObject *list, PRBool expandSpaces)
vwchar_tfakeUnicode (const char *ps, int *bytes)
int uStrLen (const vwchar_t *u)
char * fakeCString (const vwchar_t *u)
const char * lookupStr (const char *s)

Variables

char ** fieldedProp
static StrItemstrTbl [STRTBLSIZE]
static const char * adrFields []
static const char * nameFields []
static const char * orgFields []
static const char * AAlarmFields []
static const char * coolTalkFields []
static const char * DAlarmFields []
static const char * MAlarmFields []
static const char * PAlarmFields []
static struct PreDefProp []

Class Documentation

struct PreDefProp

Definition at line 748 of file nsVCardObj.cpp.

Class Members
const char * alias
const char ** fields
unsigned int flags
const char * name

Define Documentation

#define DBG_ (   x)

Definition at line 90 of file nsVCardObj.cpp.

Definition at line 1044 of file nsVCardObj.cpp.

#define PD_BEGIN   0x1

Definition at line 756 of file nsVCardObj.cpp.

#define PD_INTERNAL   0x2

Definition at line 757 of file nsVCardObj.cpp.

#define PR_MAXQUADS   16
#define STRTBLSIZE   255

Definition at line 707 of file nsVCardObj.cpp.


Function Documentation

VObject* addGroup ( VObject o,
const char *  g 
)

Definition at line 427 of file nsVCardObj.cpp.

{
    /*
  a.b.c
  -->
  prop(c)
      prop(VCGrouping=b)
    prop(VCGrouping=a)
     */
    char *dot = PL_strrchr(g,'.');
    if (dot) {
  VObject *p, *t;
  char *gs, *n = dot+1;
  gs = dupStr(g,0); /* so we can write to it. */
  t = p = addProp_(o,lookupProp(n));
  dot = PL_strrchr(gs,'.');
  *dot = 0;
  do {
      dot = PL_strrchr(gs,'.');
      if (dot) {
    n = dot+1;
    *dot=0;
    }
      else
    n = gs;
      /* property(VCGroupingProp=n);
       *  and the value may have VCGrouping property
       */
      t = addProp(t,VCGroupingProp);
      setVObjectStringZValue(t,lookupProp_(n));
      } while (n != gs);
  deleteString(gs); 
  return p;
  }
    else
  return addProp_(o,lookupProp(g));
}

Here is the call graph for this function:

Here is the caller graph for this function:

void addList ( VObject **  o,
VObject p 
)

Definition at line 346 of file nsVCardObj.cpp.

{
    p->next = 0;
    if (*o == 0) {
  *o = p;
  }
    else {
  VObject *t = *o;
  while (t->next) {
     t = t->next;
     }
  t->next = p;
  }
}
VObject* addProp ( VObject o,
const char *  id 
)

Definition at line 336 of file nsVCardObj.cpp.

{
    return addVObjectProp(o,newVObject(id));
}

Here is the call graph for this function:

Here is the caller graph for this function:

VObject* addProp_ ( VObject o,
const char *  id 
)

Definition at line 341 of file nsVCardObj.cpp.

{
    return addVObjectProp(o,newVObject_(id));
}

Here is the call graph for this function:

Here is the caller graph for this function:

VObject* addPropSizedValue ( VObject o,
const char *  p,
const char *  v,
unsigned int  size 
)

Definition at line 493 of file nsVCardObj.cpp.

Here is the call graph for this function:

VObject* addPropSizedValue_ ( VObject o,
const char *  p,
const char *  v,
unsigned int  size 
)

Definition at line 484 of file nsVCardObj.cpp.

{
    VObject *prop;
    prop = addProp(o,p);
    setValueWithSize_(prop, (void*)v, size);
    return prop;
}

Here is the call graph for this function:

Here is the caller graph for this function:

VObject* addPropValue ( VObject o,
const char *  p,
const char *  v 
)

Definition at line 465 of file nsVCardObj.cpp.

{
    VObject *prop;
    prop = addProp(o,p);
  if (v) {
    setVObjectUStringZValue_(prop, fakeUnicode(v,0));
    if (needsQuotedPrintable (v)) {
      if (PL_strcasecmp (VCCardProp, vObjectName(o)) == 0) 
        addProp (prop, VCQuotedPrintableProp);
      else
        addProp (o, VCQuotedPrintableProp);
    }
  }
  else
    setVObjectUStringZValue_(prop, fakeUnicode("",0));

    return prop;
}

Here is the call graph for this function:

Here is the caller graph for this function:

VObject* addVObjectProp ( VObject o,
VObject p 
)

Definition at line 301 of file nsVCardObj.cpp.

{
    /* circular link list pointed to tail */
    /*
    o {next,id,prop,val}
                V
  pn {next,id,prop,val}
             V
      ...
  p1 {next,id,prop,val}
             V
       pn
    -->
    o {next,id,prop,val}
                V
  pn {next,id,prop,val}
             V
  p {next,id,prop,val}
      ...
  p1 {next,id,prop,val}
             V
       pn
    */

    VObject *tail = o->prop;
    if (tail) {
  p->next = tail->next;
  o->prop = tail->next = p;
  }
    else {
  o->prop = p->next = p;
  }
    return p;
}

Here is the caller graph for this function:

static void appendcOFile ( OFile fp,
char  c 
) [static]

Definition at line 1080 of file nsVCardObj.cpp.

{
/*  int i = 0; */
    if (c == '\n') {
  /* write out as <CR><LF> */
  /* for (i = 0; i < LINEBREAK_LEN; i++)
    appendcOFile_(fp,LINEBREAK [ i ]); */
  appendcOFile_(fp,0xd); 
  appendcOFile_(fp,0xa); 
  }
    else
  appendcOFile_(fp,c);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void appendcOFile_ ( OFile fp,
char  c 
) [static]

Definition at line 1054 of file nsVCardObj.cpp.

{
  if (fp->fail) 
    return;
  if (fp->fp) {
    fp->fp->write(&c,1);
  }
  else {
stuff:
  if (fp->len+1 < fp->limit) {
    fp->s[fp->len] = c;
    fp->len++;
    return;
  }
  else if (fp->alloc) {
    fp->limit = fp->limit + OFILE_REALLOC_SIZE;
    fp->s = (char *)PR_Realloc(fp->s,fp->limit);
    if (fp->s) goto stuff;
  }
  if (fp->alloc)
    PR_FREEIF(fp->s);
  fp->s = 0;
  fp->fail = 1;
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void appendsOFile ( OFile fp,
const char *  s 
) [static]

Definition at line 1094 of file nsVCardObj.cpp.

{
    int i, slen;
    slen  = PL_strlen (s);
    for (i=0; i<slen; i++) {
  appendcOFile(fp,s[i]);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 659 of file nsVCardObj.cpp.

{
    if (o == 0) return;
    if (o->prop) {
  /* destroy time: cannot use the iterator here.
     Have to break the cycle in the circular link
     list and turns it into regular NULL-terminated
     list -- since at some point of destruction,
     the reference entry for the iterator to work
     will not longer be valid.
     */
  VObject *p;
  p = o->prop->next;
  o->prop->next = 0;
  do {
     VObject *t = p->next;
     cleanVObject(p);
     p = t;
     } while (p);
  }
    switch (VALUE_TYPE(o)) {
  case VCVT_USTRINGZ:
  case VCVT_STRINGZ:
  case VCVT_RAW:
      /* assume they are all allocated by malloc. */
      if ((char*) STRINGZ_VALUE_OF(o)) 
        PR_Free ((char*)STRINGZ_VALUE_OF(o));
      break;
  case VCVT_VOBJECT:
      cleanVObject(VOBJECT_VALUE_OF(o));
      break;
  }
    deleteVObject(o);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void cleanVObjects ( VObject list)

Definition at line 694 of file nsVCardObj.cpp.

{
    while (list) {
  VObject *t = list;
  list = nextVObjectInList(list);
  cleanVObject(t);
  }
}

Here is the call graph for this function:

void deleteString ( char *  p)

Definition at line 182 of file nsVCardObj.cpp.

{
    if (p) 
      PR_Free ((void*)p);
}

Here is the caller graph for this function:

Definition at line 189 of file nsVCardObj.cpp.

{
    if (p) 
      PR_FREEIF (p);
}

Here is the caller graph for this function:

Definition at line 149 of file nsVCardObj.cpp.

{
    unUseStr(p->id);
    delete (p);
}

Here is the call graph for this function:

Here is the caller graph for this function:

char* dupStr ( const char *  s,
unsigned int  size 
)

Definition at line 155 of file nsVCardObj.cpp.

{
    char *t;
    if  (size == 0) {
  size = PL_strlen(s);
  }
  t = (char*)PR_CALLOC(size+1);
  if (t) {
  memcpy(t,s,size);
  t[size] = 0;
  return t;
  }
    else {
  return (char*)0;
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

char* fakeCString ( const vwchar_t u)

Definition at line 1542 of file nsVCardObj.cpp.

{
    char *s, *t;
    int len = uStrLen(u) + 1;
    t = s = (char*)PR_CALLOC(len);
    while (*u) {
  if (*u == (vwchar_t)0x2028)
      *t = '\n';
  else if (*u == (vwchar_t)0x2029)
      *t = '\r';
  else
      *t = (char)*u;
  u++; t++;
  }
    *t = 0;
    return s;
}

Here is the call graph for this function:

Here is the caller graph for this function:

vwchar_t* fakeUnicode ( const char *  ps,
int bytes 
)

Definition at line 1512 of file nsVCardObj.cpp.

{
    vwchar_t *r, *pw;
    int len = strlen(ps)+1;

    pw = r = (vwchar_t*)PR_CALLOC(sizeof(vwchar_t)*len);
    if (bytes)
  *bytes = len * sizeof(vwchar_t);

    while (*ps) { 
  if (*ps == '\n')
      *pw = (vwchar_t)0x2028;
  else if (*ps == '\r')
      *pw = (vwchar_t)0x2029;
  else
      *pw = (vwchar_t)(unsigned char)*ps;
  ps++; pw++;
  }        
    *pw = (vwchar_t)0;
  
    return r;
}

Here is the caller graph for this function:

static unsigned int hashStr ( const char *  s) [static]

Definition at line 711 of file nsVCardObj.cpp.

{
    unsigned int h = 0;
    int i;
    for (i=0;s[i];i++) {
  h += s[i]*i;
  }
    return h % STRTBLSIZE;
}

Here is the caller graph for this function:

static void indent ( nsOutputFileStream fp,
int  level 
) [static]

Definition at line 505 of file nsVCardObj.cpp.

{
  int i;
  for (i=0;i<level*4;i++) {
    fp->write(" ", 1);
  }
}
static void initMemOFile ( OFile fp,
char *  s,
int  len 
) [static]

Definition at line 1113 of file nsVCardObj.cpp.

{
    fp->fp = 0;
    fp->s = s;
    fp->len = 0;
    fp->limit = s?len:0;
    fp->alloc = s?0:1;
    fp->fail = 0;
}

Here is the caller graph for this function:

static void initOFile ( OFile fp,
nsOutputFileStream ofp 
) [static]

Definition at line 1103 of file nsVCardObj.cpp.

{
    fp->fp = ofp;
    fp->s = 0;
    fp->len = 0;
    fp->limit = 0;
    fp->alloc = 0;
    fp->fail = 0;
}

Here is the caller graph for this function:

Definition at line 381 of file nsVCardObj.cpp.

{
    i->start = o->prop; 
    i->next = 0;
}

Here is the caller graph for this function:

static int inList ( const char **  list,
const char *  s 
) [static]

Definition at line 1356 of file nsVCardObj.cpp.

{
    if (list == 0) return 0;
    while (*list) {
  if (PL_strcasecmp(*list,s) == 0) return 1;
  list++;
  }
    return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

VObject* isAPropertyOf ( VObject o,
const char *  id 
)

Definition at line 415 of file nsVCardObj.cpp.

{
    VObjectIterator i;
    initPropIterator(&i,o);
    while (moreIteration(&i)) {
  VObject *each = nextVObject(&i);
  if (!PL_strcasecmp(id,each->id))
      return each;
  }
    return (VObject*)0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

const char* lookupProp ( const char *  str)

Definition at line 1025 of file nsVCardObj.cpp.

{
    int i;
  
    for (i = 0; propNames[i].name; i++)
  if (PL_strcasecmp(str, propNames[i].name) == 0) {
      const char *s;
      fieldedProp = (char **)propNames[i].fields;
      s = propNames[i].alias?propNames[i].alias:propNames[i].name;
      return lookupStr(s);
      }
    fieldedProp = 0;
    return lookupStr(str);
}

Here is the call graph for this function:

Here is the caller graph for this function:

const char* lookupProp_ ( const char *  str)

Definition at line 1011 of file nsVCardObj.cpp.

{
    int i;
  
    for (i = 0; propNames[i].name; i++)
  if (PL_strcasecmp(str, propNames[i].name) == 0) {
      const char* s;
      s = propNames[i].alias?propNames[i].alias:propNames[i].name;
      return lookupStr(s);
      }
    return lookupStr(str);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static struct PreDefProp* lookupPropInfo ( const char *  str) [static, read]

Definition at line 997 of file nsVCardObj.cpp.

{
    /* brute force for now, could use a hash table here. */
    int i;
  
    for (i = 0; propNames[i].name; i++) 
  if (PL_strcasecmp(str, propNames[i].name) == 0) {
      return &propNames[i];
      }
    
    return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

const char* lookupStr ( const char *  s)

Definition at line 1560 of file nsVCardObj.cpp.

{
    StrItem *t;
    unsigned int h = hashStr(s);
    if ((t = strTbl[h]) != 0) {
  do {
      if (PL_strcasecmp(t->s,s) == 0) {
    t->refCnt++;
    return t->s;
    }
      t = t->next;
      } while (t);
  }
    s = dupStr(s,0);
    strTbl[h] = newStrItem(s,strTbl[h]);
    return s;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 395 of file nsVCardObj.cpp.

{ 
    return (i->start && (i->next==0 || i->next!=i->start));
}

Here is the caller graph for this function:

static PRBool needsQuotedPrintable ( const char *  s) [static]

Definition at line 120 of file nsVCardObj.cpp.

{
  const unsigned char *p = (const unsigned char *)s;

  while (*p) {
    if (*p & 0x80 || *p == '\015' || *p == '\012')
      return PR_TRUE;
    p++;
  }

  return PR_FALSE;
}

Here is the caller graph for this function:

static StrItem* newStrItem ( const char *  s,
StrItem next 
) [static]

Definition at line 172 of file nsVCardObj.cpp.

{
    StrItem *p = (StrItem*)PR_CALLOC(sizeof(StrItem));
    p->next = next;
    p->s = s;
    p->refCnt = 1;
    return p;
}

Here is the caller graph for this function:

VObject* newVObject ( const char *  id)

Definition at line 144 of file nsVCardObj.cpp.

{
    return newVObject_(lookupStr(id));
}

Here is the call graph for this function:

Here is the caller graph for this function:

VObject * newVObject_ ( const char *  id) [static]

Definition at line 133 of file nsVCardObj.cpp.

{
    VObject *p = (VObject*) new(VObject);
    p->next = 0;
    p->id = id;
    p->prop = 0;
    VALUE_TYPE(p) = 0;
  ANY_VALUE_OF(p) = 0;
    return p;
}

Here is the caller graph for this function:

Definition at line 400 of file nsVCardObj.cpp.

{
    if (i->start && i->next != i->start) {
  if (i->next == 0) {
      i->next = i->start->next;
      return i->next;
      }
  else {
      i->next = i->next->next;
      return i->next;
      }
  }
    else return (VObject*)0;
}

Here is the caller graph for this function:

Definition at line 361 of file nsVCardObj.cpp.

{
    return o->next;
}

Here is the caller graph for this function:

static void printNameValue ( nsOutputFileStream fp,
VObject o,
int  level 
) [static]

Definition at line 581 of file nsVCardObj.cpp.

{
  char  *buf;

  indent(fp,level);
  if (NAME_OF(o)) 
  {
    buf = PR_smprintf("%s", NAME_OF(o)); 
    if (buf)
    {
      fp->write(buf, strlen(buf));
      PR_FREEIF(buf);
    }
  }

  if (VALUE_TYPE(o)) 
  {
    fp->write("=",1);
    printValue(fp,o, level);
  }

  fp->write("\n", 1);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void printValue ( nsOutputFileStream fp,
VObject o,
int  level 
) [static]

Definition at line 513 of file nsVCardObj.cpp.

{
  char *buf = nsnull;

  switch (VALUE_TYPE(o)) {
  case VCVT_USTRINGZ: {
    char c;
    char *t,*s;
    s = t = fakeCString(USTRINGZ_VALUE_OF(o));
    fp->write("'",1);
    while (c=*t,c) {
      fp->write(&c,1);
      if (c == '\n') indent(fp,level+2);
      t++;
    }
    fp->write("'",1);
    deleteString(s);
    break;
                      }
  case VCVT_STRINGZ: {
    char c;
    char *str = &c;
    const char *s = STRINGZ_VALUE_OF(o);
    fp->write("'",1);
    while (c=*s,c) {
      fp->write(str,1);
      if (c == '\n') indent(fp,level+2);
      s++;
    }
    fp->write("'",1);
    break;
                     }
  case VCVT_UINT:    
    buf = PR_smprintf("%d", INTEGER_VALUE_OF(o)); 
    if (buf)
    {
      fp->write(buf, strlen(buf));
      PR_FREEIF(buf);
    }
    break;

  case VCVT_ULONG:
    buf = PR_smprintf("%ld", LONG_VALUE_OF(o)); 
    if (buf)
    {
      fp->write(buf, strlen(buf));
      PR_FREEIF(buf);
    }
    break;

  case VCVT_RAW:
    fp->write("[raw data]", 10); 
    break;

  case VCVT_VOBJECT:
    fp->write("[vobject]\n", 11);
    printVObject_(fp,VOBJECT_VALUE_OF(o),level+1);
    break;

  case 0:
    fp->write("[none]", 6); 
    break;
  default:
    fp->write("[unknown]", 9); 
    break;
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 623 of file nsVCardObj.cpp.

{
  printVObject_(fp,o,0);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void printVObject_ ( nsOutputFileStream fp,
VObject o,
int  level 
)

Definition at line 605 of file nsVCardObj.cpp.

{
  VObjectIterator t;
  if (o == 0) {
    fp->write("[NULL]\n", 7);
    return;
  }

  printNameValue(fp,o,level);
  initPropIterator(&t,o);

  while (moreIteration(&t)) 
  {
    VObject *eachProp = nextVObject(&t);
    printVObject_(fp,eachProp,level+1);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void printVObjectsToFile ( nsFileSpec fname,
VObject list 
)

Definition at line 642 of file nsVCardObj.cpp.

{
#if !defined(MOZADDRSTANDALONE)
  nsOutputFileStream *fp = new nsOutputFileStream(*fname, PR_WRONLY | PR_CREATE_FILE, 00600);
  if (fp) {
    while (list) {
      printVObject(fp,list);
      list = nextVObjectInList(list);
    }
    fp->close();
  }
#else
  NS_ASSERTION(PR_FALSE, "1.10 <rhp@netscape.com> 06 Jan 2000 08:01");
#endif
}

Here is the call graph for this function:

void printVObjectToFile ( nsFileSpec fname,
VObject o 
)

Definition at line 628 of file nsVCardObj.cpp.

{
#if !defined(MOZADDRSTANDALONE)
  nsOutputFileStream *fp = new nsOutputFileStream(*fname, PR_WRONLY | PR_CREATE_FILE, 00600);

  if (fp) {
    printVObject(fp,o);
    fp->close();
  }
#else
  NS_ASSERTION(PR_FALSE, "1.10 <rhp@netscape.com> 06 Jan 2000 08:01");
#endif
}

Here is the call graph for this function:

VObject* setValueWithSize ( VObject prop,
void val,
unsigned int  size 
)

Definition at line 375 of file nsVCardObj.cpp.

{
  void *p = dupStr((const char *)val,size);
    return setValueWithSize_(prop,p,p?size:0);
}

Here is the call graph for this function:

Here is the caller graph for this function:

VObject* setValueWithSize_ ( VObject prop,
void val,
unsigned int  size 
)

Definition at line 366 of file nsVCardObj.cpp.

{
    VObject *sizeProp;
    setVObjectAnyValue(prop, val);
    sizeProp = addProp(prop,VCDataSizeProp);
    setVObjectLongValue(sizeProp, size);
    return prop;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void setVObjectAnyValue ( VObject o,
void t 
)

Definition at line 272 of file nsVCardObj.cpp.

Here is the caller graph for this function:

void setVObjectIntegerValue ( VObject o,
unsigned int  i 
)

Definition at line 250 of file nsVCardObj.cpp.

void setVObjectLongValue ( VObject o,
unsigned long  l 
)

Definition at line 261 of file nsVCardObj.cpp.

Here is the caller graph for this function:

void setVObjectName ( VObject o,
const char *  id 
)

Definition at line 206 of file nsVCardObj.cpp.

{
    NAME_OF(o) = id;
}
void setVObjectStringZValue ( VObject o,
const char *  s 
)

Definition at line 216 of file nsVCardObj.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void setVObjectStringZValue_ ( VObject o,
const char *  s 
)

Definition at line 222 of file nsVCardObj.cpp.

Definition at line 233 of file nsVCardObj.cpp.

{
    USTRINGZ_VALUE_OF(o) = (vwchar_t*) dupStr((char*)s,(uStrLen(s)+1)*2);
    VALUE_TYPE(o) = VCVT_USTRINGZ;
}

Here is the call graph for this function:

Definition at line 239 of file nsVCardObj.cpp.

Here is the caller graph for this function:

Definition at line 283 of file nsVCardObj.cpp.

void unUseStr ( const char *  s)

Definition at line 721 of file nsVCardObj.cpp.

{
  StrItem *t, *p;
  unsigned int h = hashStr(s);
  if ((t = strTbl[h]) != 0) {
    p = t;
    do {
      if (PL_strcasecmp(t->s,s) == 0) {
        t->refCnt--;
        if (t->refCnt == 0) {
          if (t == strTbl[h]) {
            strTbl[h] = t->next;
          }
          else {
            p->next = t->next;
          }
          deleteString((char *)t->s);
          deleteStrItem(t);
          return;
        }
      }
      p = t;
      t = t->next;
     } while (t);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1535 of file nsVCardObj.cpp.

{
    int i = 0;
    while (*u != (vwchar_t)0) { u++; i++; }
    return i;
}

Here is the caller graph for this function:

Definition at line 267 of file nsVCardObj.cpp.

{
    return ANY_VALUE_OF(o);
}
unsigned int vObjectIntegerValue ( VObject o)

Definition at line 245 of file nsVCardObj.cpp.

{
    return INTEGER_VALUE_OF(o);
}
unsigned long vObjectLongValue ( VObject o)

Definition at line 256 of file nsVCardObj.cpp.

{
    return LONG_VALUE_OF(o);
}
const char* vObjectName ( VObject o)

Definition at line 201 of file nsVCardObj.cpp.

{
    return NAME_OF(o);
}

Here is the caller graph for this function:

Definition at line 211 of file nsVCardObj.cpp.

{
    return STRINGZ_VALUE_OF(o);
}

Here is the caller graph for this function:

Definition at line 228 of file nsVCardObj.cpp.

{
    return USTRINGZ_VALUE_OF(o);
}

Here is the caller graph for this function:

Definition at line 278 of file nsVCardObj.cpp.

{
    return VOBJECT_VALUE_OF(o);
}
static void writeAttrValue ( OFile fp,
VObject o,
int length 
) [static]

Definition at line 1316 of file nsVCardObj.cpp.

{
  int ilen = 0;
    if (NAME_OF(o)) {
  struct PreDefProp *pi;
  pi = lookupPropInfo(NAME_OF(o));
  if (pi && ((pi->flags & PD_INTERNAL) != 0)) return;
  appendcOFile(fp,';');
  if (*length != -1)
    (*length)++;
  appendsOFile(fp,NAME_OF(o));
  if (*length != -1)
    (*length) += PL_strlen (NAME_OF(o));
  }
    else {
    appendcOFile(fp,';');
    (*length)++;
  }
    if (VALUE_TYPE(o)) {
  appendcOFile(fp,'=');
  if (*length != -1) {
    (*length)++;
    for (ilen = 0; ilen < MAXMOZPROPNAMESIZE - (*length); ilen++)
      appendcOFile(fp,' ');
  }
  writeValue(fp,o,0);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int writeBase64 ( OFile fp,
unsigned char *  s,
long  len 
) [static]

Definition at line 1124 of file nsVCardObj.cpp.

{
    long cur = 0;
    int i, numQuads = 0;
    unsigned long trip;
    unsigned char b;
    char quad[5];
#define PR_MAXQUADS 16

    quad[4] = 0;

    while (cur < len) {
  /* collect the triplet of bytes into 'trip' */
  trip = 0;
  for (i = 0; i < 3; i++) {
      b = (cur < len) ? *(s + cur) : 0;
      cur++;
      trip = trip << 8 | b;
      }
  /* fill in 'quad' with the appropriate four characters */
  for (i = 3; i >= 0; i--) {
      b = (unsigned char)(trip & 0x3F);
      trip = trip >> 6;
      if ((3 - i) < (cur - len))
    quad[i] = '='; /* pad char */
      else if (b < 26) quad[i] = (char)b + 'A';
      else if (b < 52) quad[i] = (char)(b - 26) + 'a';
      else if (b < 62) quad[i] = (char)(b - 52) + '0';
      else if (b == 62) quad[i] = '+';
      else quad[i] = '/';
      }
  /* now output 'quad' with appropriate whitespace and line ending */
  appendsOFile(fp, (numQuads == 0 ? "    " : ""));
  appendsOFile(fp, quad);
  appendsOFile(fp, ((cur >= len)?"\n" :(numQuads==PR_MAXQUADS-1?"\n" : "")));
  numQuads = (numQuads + 1) % PR_MAXQUADS;
  }
    appendcOFile(fp,'\n');

    return 1;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void writeGroup ( OFile fp,
VObject o 
) [static]

Definition at line 1345 of file nsVCardObj.cpp.

{
  nsCAutoString buf(NAME_OF(o));

  while ((o=isAPropertyOf(o,VCGroupingProp)) != 0) {
    buf.Insert(NS_LITERAL_CSTRING("."), 0);
    buf.Insert(STRINGZ_VALUE_OF(o), 0);
  }
  appendsOFile(fp, buf.get());
}

Here is the call graph for this function:

Here is the caller graph for this function:

char* writeMemoryVObjects ( char *  s,
int len,
VObject list,
PRBool  expandSpaces 
)

Definition at line 1496 of file nsVCardObj.cpp.

{
    OFile ofp;
    initMemOFile(&ofp,s,len?*len:0);
    while (list) {
  writeVObject_(&ofp,list);
  list = nextVObjectInList(list);
  }
    if (len) *len = ofp.len;
    appendcOFile(&ofp,0);
    return ofp.s;
}

Here is the call graph for this function:

char* writeMemVObject ( char *  s,
int len,
VObject o 
)

Definition at line 1485 of file nsVCardObj.cpp.

{
    OFile ofp;
    initMemOFile(&ofp,s,len?*len:0);
    writeVObject_(&ofp,o);
    if (len) *len = ofp.len;
    appendcOFile(&ofp,0);
    return ofp.s;
}

Here is the call graph for this function:

static void writeProp ( OFile fp,
VObject o 
) [static]

Definition at line 1366 of file nsVCardObj.cpp.

{
  int length = -1;
  //int ilen = 0;

    if (NAME_OF(o)) {
  struct PreDefProp *pi;
  VObjectIterator t;
  const char **fields_ = 0;
  pi = lookupPropInfo(NAME_OF(o));
  if (pi && ((pi->flags & PD_BEGIN) != 0)) {
      writeVObject_(fp,o);
      return;
      }
  if (isAPropertyOf(o,VCGroupingProp))
      writeGroup(fp,o);
  else 
      appendsOFile(fp,NAME_OF(o));
  if (pi) fields_ = pi->fields;
  initPropIterator(&t,o);
  while (moreIteration(&t)) {
      const char *s;
      VObject *eachProp = nextVObject(&t);
      s = NAME_OF(eachProp);
      if (PL_strcasecmp(VCGroupingProp,s) && !inList(fields_,s))
    writeAttrValue(fp,eachProp, &length);
      }
  if (fields_) {
      int i = 0, n = 0;
      const char** fields = fields_;
      /* output prop as fields */
      appendcOFile(fp,':');
      while (*fields) {
    VObject *tt = isAPropertyOf(o,*fields);
    i++;
    if (tt) n = i;
    fields++;
    }
      fields = fields_;
      for (i=0;i<n;i++) {
    writeValue(fp,isAPropertyOf(o,*fields),0);
    fields++;
    if (i<(n-1)) appendcOFile(fp,';');
    }
      }
  }
  
    if (VALUE_TYPE(o)) {
  unsigned long size = 0;
        VObject *p = isAPropertyOf(o,VCDataSizeProp);
  if (p) size = LONG_VALUE_OF(p);
  appendcOFile(fp,':');
  writeValue(fp,o,size);
  }
    appendcOFile(fp,'\n');
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void writeQPString ( OFile fp,
const char *  s 
) [static]

Definition at line 1166 of file nsVCardObj.cpp.

{
    const unsigned char *p = (const unsigned char *)s;
  int current_column = 0;
  static const char hexdigits[] = "0123456789ABCDEF";
  PRBool white = PR_FALSE;
  PRBool contWhite = PR_FALSE;
  PRBool mb_p = PR_FALSE;

  if (needsQuotedPrintable (s)) 
  {
    while (*p) {
      if (*p == nsCRT::CR || *p == nsCRT::LF)
      {
        /* Whitespace cannot be allowed to occur at the end of the line.
        So we encode " \n" as " =\n\n", that is, the whitespace, a
        soft line break, and then a hard line break.
        */

        if (white)
        {
          appendcOFile(fp,'=');
          appendcOFile(fp,'\n');
          appendcOFile(fp,'\t');
          appendsOFile(fp,"=0D");
          appendsOFile(fp,"=0A");
          appendcOFile(fp,'=');
          appendcOFile(fp,'\n');
          appendcOFile(fp,'\t');
        }
        else
        {
          appendsOFile(fp,"=0D");
          appendsOFile(fp,"=0A");
          appendcOFile(fp,'=');
          appendcOFile(fp,'\n');
          appendcOFile(fp,'\t');
          contWhite = PR_FALSE;
        }

        /* If its CRLF, swallow two chars instead of one. */
        if (*p == nsCRT::CR && *(p+1) == nsCRT::LF)
          p++;
        white = PR_FALSE;
        current_column = 0;
      }
      else
      {
        if ((*p >= 33 && *p <= 60) ||   /* safe printing chars */
          (*p >= 62 && *p <= 126) ||
          (mb_p && (*p == 61 || *p == 127 || *p == 0x1B)))
        {
          appendcOFile(fp,*p);
          current_column++;
          white = PR_FALSE;
          contWhite = PR_FALSE;
        }
        else if (*p == ' ' || *p == '\t')   /* whitespace */
        {
          if (contWhite) 
          {
            appendcOFile(fp,'=');
            appendcOFile(fp,hexdigits[*p >> 4]);
            appendcOFile(fp,hexdigits[*p & 0xF]);
            current_column += 3;
            contWhite = PR_FALSE;
          }
          else
          {
            appendcOFile(fp,*p);
            current_column++;
          }
          white = PR_TRUE;
        }
        else                    /* print as =FF */
        {
          appendcOFile(fp,'=');
          appendcOFile(fp,hexdigits[*p >> 4]);
          appendcOFile(fp,hexdigits[*p & 0xF]);
          current_column += 3;
          white = PR_FALSE;
          contWhite = PR_FALSE;
        }

        NS_ASSERTION(current_column <= 76, "1.10 <rhp@netscape.com> 06 Jan 2000 08:01"); /* Hard limit required by spec */

        if (current_column >= 73 || ((*(p+1) == ' ') && (current_column + 3 >= 73)))    /* soft line break: "=\r\n" */
        {
          appendcOFile(fp,'=');
          appendcOFile(fp,'\n');
          appendcOFile(fp,'\t');
          current_column = 0;
          if (white)
            contWhite = PR_TRUE;
          else 
            contWhite = PR_FALSE;
          white = PR_FALSE;
        }
      } 
      p++;
    }  /* while */
  }  /* if */
  else 
  {
      while (*p) {
      appendcOFile(fp,*p);
      p++;
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void writeValue ( OFile fp,
VObject o,
unsigned long  size 
) [static]

Definition at line 1278 of file nsVCardObj.cpp.

{
    if (o == 0) return;
    switch (VALUE_TYPE(o)) {
  case VCVT_USTRINGZ: {
      char *s = fakeCString(USTRINGZ_VALUE_OF(o));
      writeQPString(fp, s);
      deleteString(s);
      break;
      }
  case VCVT_STRINGZ: {
      writeQPString(fp, STRINGZ_VALUE_OF(o));
      break;
      }
  case VCVT_UINT: {
      char buf[16];
      sprintf(buf,"%u", INTEGER_VALUE_OF(o));
      appendsOFile(fp,buf);
      break;
      }
  case VCVT_ULONG: {
      char buf[16];
      sprintf(buf,"%lu", LONG_VALUE_OF(o));
      appendsOFile(fp,buf);
      break;
      }
  case VCVT_RAW: {
      appendcOFile(fp,'\n');
      writeBase64(fp,(unsigned char*)(ANY_VALUE_OF(o)),size);
      break;
      }
  case VCVT_VOBJECT:
      appendcOFile(fp,'\n');
      writeVObject_(fp,VOBJECT_VALUE_OF(o));
      break;
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1448 of file nsVCardObj.cpp.

{
    OFile ofp;
    initOFile(&ofp,fp);
    writeVObject_(&ofp,o);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void writeVObject_ ( OFile fp,
VObject o 
)

Definition at line 1423 of file nsVCardObj.cpp.

{
  //int ilen = 0;
    if (NAME_OF(o)) {
  struct PreDefProp *pi;
  pi = lookupPropInfo(NAME_OF(o));

  if (pi && ((pi->flags & PD_BEGIN) != 0)) {
      VObjectIterator t;
      const char *begin = NAME_OF(o);
      appendsOFile(fp,"begin:");
      appendsOFile(fp,begin);
      appendcOFile(fp,'\n');
      initPropIterator(&t,o);
      while (moreIteration(&t)) {
      VObject *eachProp = nextVObject(&t);
      writeProp(fp, eachProp);
    }
      appendsOFile(fp,"end:");
      appendsOFile(fp,begin);
      appendsOFile(fp,"\n\n");
      }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void writeVObjectsToFile ( nsFileSpec fname,
VObject list 
)

Definition at line 1469 of file nsVCardObj.cpp.

{
#if !defined(MOZADDRSTANDALONE)
  nsOutputFileStream *fp = new nsOutputFileStream(*fname, PR_WRONLY | PR_CREATE_FILE, 00600);
    if (fp) {
  while (list) {
      writeVObject(fp,list);
      list = nextVObjectInList(list);
      }
  fp->close();
  }
#else
  NS_ASSERTION(PR_FALSE, "1.10 <rhp@netscape.com> 06 Jan 2000 08:01");
#endif
}

Here is the call graph for this function:

void writeVObjectToFile ( nsFileSpec fname,
VObject o 
)

Definition at line 1455 of file nsVCardObj.cpp.

{
#if !defined(MOZADDRSTANDALONE)
  nsOutputFileStream *fp = new nsOutputFileStream(*fname, PR_WRONLY | PR_CREATE_FILE, 00600);
  
  if (fp) {
    writeVObject(fp,o);
    fp->close();
  }
#else
  NS_ASSERTION(PR_FALSE, "1.10 <rhp@netscape.com> 06 Jan 2000 08:01");
#endif
}

Here is the call graph for this function:


Variable Documentation

const char* AAlarmFields[] [static]
Initial value:

Definition at line 788 of file nsVCardObj.cpp.

const char* adrFields[] [static]
const char* coolTalkFields[] [static]
Initial value:

Definition at line 796 of file nsVCardObj.cpp.

const char* DAlarmFields[] [static]
Initial value:

Definition at line 805 of file nsVCardObj.cpp.

char** fieldedProp

Definition at line 96 of file nsVCardObj.cpp.

const char* MAlarmFields[] [static]
Initial value:

Definition at line 813 of file nsVCardObj.cpp.

const char* nameFields[] [static]
const char* orgFields[] [static]
Initial value:

Definition at line 779 of file nsVCardObj.cpp.

const char* PAlarmFields[] [static]
Initial value:

Definition at line 822 of file nsVCardObj.cpp.

struct PreDefProp[] [static]

Definition at line 830 of file nsVCardObj.cpp.

Definition at line 709 of file nsVCardObj.cpp.