Ejemplo n.º 1
0
void cleanVObject(VObject *o)
{
    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);
}
Ejemplo n.º 2
0
static void writeGroup(OFile *fp, VObject *o)
{
    char buf1[256];
    char buf2[256];
    strncpy(buf1,NAME_OF(o), 255);
    while ((o=isAPropertyOf(o,VCGroupingProp)) != 0) {
	strncpy(buf2,STRINGZ_VALUE_OF(o),255);
	strcat(buf2,".");
	strncat(buf2,buf1,254-strlen(STRINGZ_VALUE_OF(o)));
	strcpy(buf1,buf2);
    }
    appendsOFile(fp,buf1);
}
Ejemplo n.º 3
0
static void writeValue(OFile *fp, VObject *o, unsigned long size, bool nosemi)
{
    if (o == 0) return;
    switch (VALUE_TYPE(o)) {
	case VCVT_STRINGZ: {
	    writeEncString(fp, STRINGZ_VALUE_OF(o), nosemi);
	    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;
	}
}
Ejemplo n.º 4
0
static void writeValue(OFile *fp, VObject *o, unsigned long size)
{
    if (o == 0) return;
    switch (VALUE_TYPE(o)) {
	case VCVT_USTRINGZ: {
	    char *s = fakeCString(USTRINGZ_VALUE_OF(o));
	    if (isAPropertyOf(o, VCQuotedPrintableProp))
	      writeQPString(fp, s, 1);
	    else
	      writeQPString(fp, s, 0);
	    deleteStr(s);
	    break;
	    }
	case VCVT_STRINGZ: {
	    if (isAPropertyOf(o, VCQuotedPrintableProp))
	      writeQPString(fp, STRINGZ_VALUE_OF(o), 1);
	    else
	      writeQPString(fp, STRINGZ_VALUE_OF(o), 0);
	    break;
	    }
	case VCVT_UINT: {
	    char buf[16];
	    snprintf(buf,sizeof(buf),"%u", INTEGER_VALUE_OF(o));
	    appendsOFile(fp,buf);
	    break;
	    }
	case VCVT_ULONG: {
	    char buf[16];
	    snprintf(buf,sizeof(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;
	}
}
Ejemplo n.º 5
0
static void writeGroup(OFile *fp, VObject *o)
{
    char buf1[256];
    char buf2[256];
    strcpy(buf1,NAME_OF(o));
    while ((o=isAPropertyOf(o,VCGroupingProp)) != 0) {
	strncpy(buf2,STRINGZ_VALUE_OF(o),sizeof(buf2));
	buf2[sizeof(buf2)-1] = '\0';
	strncat(buf2,".",sizeof(buf2)-strlen(buf2)-1);
	strncat(buf2,buf1,sizeof(buf2)-strlen(buf2)-1);
	strcpy(buf1,buf2);
	}
    appendsOFile(fp,buf1);
}
Ejemplo n.º 6
0
static void printValue(FILE *fp, VObject *o, int level)
{
    switch (VALUE_TYPE(o)) {
	case VCVT_USTRINGZ: {
	    char c;
            char *t,*s;
	    s = t = fakeCString(USTRINGZ_VALUE_OF(o));
	    fputc('"',fp);
	    while (c=*t,c) {
	        fputc(c,fp);
		if (c == '\n') indent(fp,level+2);
		t++;
		}
	    fputc('"',fp);
	    deleteStr(s);
	    break;
	    }
	case VCVT_STRINGZ: {
	    char c;
	    const char *s = STRINGZ_VALUE_OF(o);
	    fputc('"',fp);
	    while (c=*s,c) {
	        fputc(c,fp);
		if (c == '\n') indent(fp,level+2);
		s++;
		}
	    fputc('"',fp);
	    break;
	    }
	case VCVT_UINT:
	    fprintf(fp,"%d", INTEGER_VALUE_OF(o)); break;
	case VCVT_ULONG:
	    fprintf(fp,"%ld", LONG_VALUE_OF(o)); break;
	case VCVT_RAW:
	    fprintf(fp,"[raw data]"); break;
	case VCVT_VOBJECT:
	    fprintf(fp,"[vobject]\n");
	    printVObject_(fp,VOBJECT_VALUE_OF(o),level+1);
	    break;
	case 0:
	    fprintf(fp,"[none]"); break;
	default:
	    fprintf(fp,"[unknown]"); break;
	}
}
Ejemplo n.º 7
0
static bool includesUnprintable(VObject *o, bool nosemi)
{
    if (o) {
	if (VALUE_TYPE(o) == VCVT_STRINGZ) {
	    const char *p = STRINGZ_VALUE_OF(o);
	    if (p) {
		while (*p) {
		    if (*p==' ' && (!p[1] || p[1]=='\n') // RFC 1521: spaces at ends need quoting
			    || qpReplaceChar(*p)
			    || *p==';' && nosemi )
			return TRUE;
		    p++;
		}
	    }
	}
    }
    return FALSE;
}
Ejemplo n.º 8
0
DLLEXPORT(void) setVObjectStringZValue_(VObject *o, const char *s)
{
    STRINGZ_VALUE_OF(o) = s;
    VALUE_TYPE(o) = VCVT_STRINGZ;
}
Ejemplo n.º 9
0
DLLEXPORT(const char*) vObjectStringZValue(VObject *o)
{
    return STRINGZ_VALUE_OF(o);
}
Ejemplo n.º 10
0
void setVObjectStringZValue(VObject *o, const char *s)
{
    STRINGZ_VALUE_OF(o) = dupStr(s,0);
    VALUE_TYPE(o) = VCVT_STRINGZ;
}