зеркало из https://github.com/mozilla/gecko-dev.git
Fix for vCard display problem - Bug #10620 - r: mscott
This commit is contained in:
Родитель
7e86489156
Коммит
7f08a6c054
|
@ -75,11 +75,11 @@ int
|
|||
GenerateMessage(char** html)
|
||||
{
|
||||
*html = nsCRT::strdup("\
|
||||
<text=\"#000000\" bgcolor=\"#FFFFFF\" link=\"#FF0000\" vlink=\"#800080\" alink=\"#0000FF\">\
|
||||
<BR><text=\"#000000\" bgcolor=\"#FFFFFF\" link=\"#FF0000\" vlink=\"#800080\" alink=\"#0000FF\">\
|
||||
<center><table BORDER=1 ><tr>\
|
||||
<td><CENTER>This messages is possibly <B>SIGNED</B>. Mozilla Mail does not support signed mail.</CENTER></td>\
|
||||
</tr>\
|
||||
</table></center>");
|
||||
</table></center><BR>");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -75,11 +75,11 @@ int
|
|||
GenerateMessage(char** html)
|
||||
{
|
||||
*html = nsCRT::strdup("\
|
||||
<text=\"#000000\" bgcolor=\"#FFFFFF\" link=\"#FF0000\" vlink=\"#800080\" alink=\"#0000FF\">\
|
||||
<BR><text=\"#000000\" bgcolor=\"#FFFFFF\" link=\"#FF0000\" vlink=\"#800080\" alink=\"#0000FF\">\
|
||||
<center><table BORDER=1 ><tr>\
|
||||
<td><CENTER>This is an <B>ENCRYPTED</B> message. Mozilla Mail does not support encrypted mail.</CENTER></td>\
|
||||
</tr>\
|
||||
</table></center>");
|
||||
</table></center><BR>");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -143,23 +143,22 @@ MimeInlineTextVCardClassInitialize(MimeInlineTextVCardClass *clazz)
|
|||
static int
|
||||
MimeInlineTextVCard_parse_begin (MimeObject *obj)
|
||||
{
|
||||
// int status = ((MimeObjectClass*)&mimeLeafClass)->parse_begin(obj);
|
||||
int status = ((MimeObjectClass*)COM_GetmimeLeafClass())->parse_begin(obj);
|
||||
MimeInlineTextVCardClass *clazz;
|
||||
if (status < 0) return status;
|
||||
|
||||
if (!obj->output_p) return 0;
|
||||
if (!obj->options || !obj->options->write_html_p) return 0;
|
||||
|
||||
/* This is a fine place to write out any HTML before the real meat begins.
|
||||
In this sample code, we tell it to start a table. */
|
||||
|
||||
clazz = ((MimeInlineTextVCardClass *) obj->clazz);
|
||||
/* initialize vcard string to empty; */
|
||||
vCard_SACopy(&(clazz->vCardString), "");
|
||||
|
||||
obj->options->state->separator_suppressed_p = PR_TRUE;
|
||||
return 0;
|
||||
if (status < 0) return status;
|
||||
|
||||
if (!obj->output_p) return 0;
|
||||
if (!obj->options || !obj->options->write_html_p) return 0;
|
||||
|
||||
/* This is a fine place to write out any HTML before the real meat begins.
|
||||
In this sample code, we tell it to start a table. */
|
||||
|
||||
clazz = ((MimeInlineTextVCardClass *) obj->clazz);
|
||||
/* initialize vcard string to empty; */
|
||||
vCard_SACopy(&(clazz->vCardString), "");
|
||||
|
||||
obj->options->state->separator_suppressed_p = PR_TRUE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
char *strcpySafe (char *dest, const char *src, size_t destLength)
|
||||
|
@ -172,28 +171,28 @@ char *strcpySafe (char *dest, const char *src, size_t destLength)
|
|||
static int
|
||||
MimeInlineTextVCard_parse_line (char *line, PRInt32 length, MimeObject *obj)
|
||||
{
|
||||
/* This routine gets fed each line of data, one at a time. In my
|
||||
sample, I spew it out as a table row, putting everything
|
||||
between colons in its own table cell.*/
|
||||
|
||||
char* linestring;
|
||||
MimeInlineTextVCardClass *clazz = ((MimeInlineTextVCardClass *) obj->clazz);
|
||||
|
||||
if (!obj->output_p) return 0;
|
||||
if (!obj->options || !obj->options->output_fn) return 0;
|
||||
if (!obj->options->write_html_p) {
|
||||
return COM_MimeObject_write(obj, line, length, PR_TRUE);
|
||||
}
|
||||
|
||||
linestring = (char *) PR_MALLOC (length + 1);
|
||||
|
||||
if (linestring) {
|
||||
// This routine gets fed each line of data, one at a time.
|
||||
char* linestring;
|
||||
MimeInlineTextVCardClass *clazz = ((MimeInlineTextVCardClass *) obj->clazz);
|
||||
|
||||
if (!obj->output_p) return 0;
|
||||
if (!obj->options || !obj->options->output_fn) return 0;
|
||||
if (!obj->options->write_html_p)
|
||||
{
|
||||
return COM_MimeObject_write(obj, line, length, PR_TRUE);
|
||||
}
|
||||
|
||||
linestring = (char *) PR_MALLOC (length + 1);
|
||||
nsCRT::memset(linestring, 0, (length + 1));
|
||||
|
||||
if (linestring)
|
||||
{
|
||||
strcpySafe((char *)linestring, line, length + 1);
|
||||
vCard_SACat (&clazz->vCardString, linestring);
|
||||
PR_Free (linestring);
|
||||
}
|
||||
|
||||
return 0;
|
||||
vCard_SACat (&clazz->vCardString, linestring);
|
||||
PR_Free (linestring);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -793,7 +792,7 @@ static int OutputAdvancedVcard(MimeObject *obj, VObject *v)
|
|||
{
|
||||
namestring = fakeCString (vObjectUStringZValue(prop));
|
||||
if (namestring)
|
||||
if (nsCRT::strcasecmp (namestring, "PR_TRUE") == 0)
|
||||
if (nsCRT::strcasecmp (namestring, "TRUE") == 0)
|
||||
{
|
||||
PR_FREEIF (namestring);
|
||||
status = OutputFont(obj, PR_FALSE, "-1", NULL);
|
||||
|
@ -971,7 +970,7 @@ static int OutputButtons(MimeObject *obj, PRBool basic, VObject *v)
|
|||
if (!obj->options->output_vcard_buttons_p)
|
||||
return status;
|
||||
|
||||
vCard = writeMemVObjects(0, &len, v);
|
||||
vCard = writeMemoryVObjects(0, &len, v, PR_FALSE);
|
||||
|
||||
if (!vCard)
|
||||
return VCARD_OUT_OF_MEMORY;
|
||||
|
@ -1732,30 +1731,15 @@ static int WriteLineToStream (MimeObject *obj, const char *line)
|
|||
int status = 0;
|
||||
char *htmlLine;
|
||||
int htmlLen ;
|
||||
char *charset = PL_strstr(obj->content_type, "charset=");
|
||||
char *converted = NULL;
|
||||
PRInt32 converted_length;
|
||||
PRInt32 res;
|
||||
|
||||
if (!charset)
|
||||
charset = "ISO-8859-1";
|
||||
|
||||
// convert from the resource charset.
|
||||
res = INTL_ConvertCharset(charset, "UTF-8", line, nsCRT::strlen(line),
|
||||
&converted, &converted_length);
|
||||
if ( (res != 0) || (converted == NULL) )
|
||||
converted = (char *)line;
|
||||
else
|
||||
converted[converted_length] = '\0';
|
||||
|
||||
htmlLen = nsCRT::strlen(converted) + nsCRT::strlen("<DT></DT>") + 1;;
|
||||
htmlLen = nsCRT::strlen(line) + nsCRT::strlen("<DT></DT>") + 1;;
|
||||
|
||||
htmlLine = (char *) PR_MALLOC (htmlLen);
|
||||
if (htmlLine)
|
||||
{
|
||||
htmlLine[0] = '\0';
|
||||
PL_strcat (htmlLine, "<DT>");
|
||||
PL_strcat (htmlLine, converted);
|
||||
PL_strcat (htmlLine, line);
|
||||
PL_strcat (htmlLine, "</DT>");
|
||||
status = COM_MimeObject_write(obj, htmlLine, nsCRT::strlen(htmlLine), PR_TRUE);
|
||||
PR_Free ((void*) htmlLine);
|
||||
|
@ -1763,8 +1747,6 @@ static int WriteLineToStream (MimeObject *obj, const char *line)
|
|||
else
|
||||
status = VCARD_OUT_OF_MEMORY;
|
||||
|
||||
if (converted != line)
|
||||
PR_FREEIF(converted);
|
||||
return status;
|
||||
}
|
||||
|
||||
|
|
|
@ -66,6 +66,9 @@ DFARS 252.227-7013 or 48 CFR 52.227-19, as applicable.
|
|||
* can be commented out here to make it easier to trace through
|
||||
* in a debugger. However, if a bug is found it should
|
||||
*/
|
||||
#include "nsVCard.h"
|
||||
#include "nsVCardObj.h"
|
||||
#include "nsFileStream.h"
|
||||
|
||||
#ifndef lint
|
||||
char yysccsid[] = "@(#)yaccpar 1.4 (Berkeley) 02/25/90";
|
||||
|
@ -73,11 +76,7 @@ char yysccsid[] = "@(#)yaccpar 1.4 (Berkeley) 02/25/90";
|
|||
/*#line 2 "vcc.y" */
|
||||
|
||||
/* debugging utilities */
|
||||
#ifdef DEBUG_mwatkins
|
||||
#define DBG_(x) /* PR_LogPrint x */
|
||||
#else
|
||||
#define DBG_(x)
|
||||
#endif
|
||||
|
||||
#ifndef _NO_LINE_FOLDING
|
||||
#define _SUPPORT_LINE_FOLDING
|
||||
|
@ -119,26 +118,24 @@ char yysccsid[] = "@(#)yaccpar 1.4 (Berkeley) 02/25/90";
|
|||
#define yyrule mime_rule
|
||||
#define YYPREFIX "mime_"
|
||||
|
||||
#include "nsVCard.h"
|
||||
#include "msgCore.h"
|
||||
|
||||
#include "prio.h"
|
||||
#include "plstr.h"
|
||||
#include "prmem.h"
|
||||
#include "plstr.h"
|
||||
# define NOT_NULL(X) X
|
||||
|
||||
#ifndef PR_FALSE
|
||||
#define PR_FALSE 0
|
||||
|
||||
#ifndef FALSE
|
||||
#define FALSE 0
|
||||
#endif
|
||||
#ifndef PR_TRUE
|
||||
#define PR_TRUE 1
|
||||
#ifndef TRUE
|
||||
#define TRUE 1
|
||||
#endif
|
||||
|
||||
/**** Types, Constants ****/
|
||||
|
||||
#define YYDEBUG 0 /* 1 to compile in some debugging code */
|
||||
#define MAXTOKEN 256 /* maximum token (line) length */
|
||||
#define PR_MAXTOKEN 256 /* maximum token (line) length */
|
||||
#define YYSTACKSIZE 50 /* ~unref ?*/
|
||||
#define MAXLEVEL 10 /* max # of nested objects parseable */
|
||||
#define PR_MAXLEVEL 10 /* max # of nested objects parseable */
|
||||
/* (includes outermost) */
|
||||
|
||||
|
||||
|
@ -147,21 +144,19 @@ int mime_lineNum, mime_numErrors; /* yyerror() can use these */
|
|||
static VObject* vObjList;
|
||||
static VObject *curProp;
|
||||
static VObject *curObj;
|
||||
static VObject* ObjStack[MAXLEVEL];
|
||||
static VObject* ObjStack[PR_MAXLEVEL];
|
||||
static int ObjStackTop;
|
||||
|
||||
|
||||
static const char** fieldedProp;
|
||||
|
||||
|
||||
/* A helpful utility for the rest of the app. */
|
||||
#ifdef XP_CPLUSPLUS
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern void yyerror(char *s);
|
||||
extern void yyerror(char *s);
|
||||
extern char** fieldedProp;
|
||||
|
||||
#ifdef XP_CPLUSPLUS
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
|
@ -342,7 +337,7 @@ short yycheck[] = { 8,
|
|||
#ifndef YYDEBUG
|
||||
#define YYDEBUG 0
|
||||
#endif
|
||||
#define YYMAXTOKEN 274
|
||||
#define YYPR_MAXTOKEN 274
|
||||
#if YYDEBUG
|
||||
char *yyname[] = {
|
||||
"end-of-file",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
|
@ -408,8 +403,8 @@ char *yyrule[] = {
|
|||
#define yyclearin (yychar=(-1))
|
||||
#define yyerrok (yyerrflag=0)
|
||||
#ifndef YYSTACKSIZE
|
||||
#ifdef YYMAXDEPTH
|
||||
#define YYSTACKSIZE YYMAXDEPTH
|
||||
#ifdef YYPR_MAXDEPTH
|
||||
#define YYSTACKSIZE YYPR_MAXDEPTH
|
||||
#else
|
||||
#define YYSTACKSIZE 300
|
||||
#endif
|
||||
|
@ -425,15 +420,13 @@ YYSTYPE yylval;
|
|||
#define yystacksize YYSTACKSIZE
|
||||
short yyss[YYSTACKSIZE];
|
||||
YYSTYPE yyvs[YYSTACKSIZE];
|
||||
|
||||
|
||||
/*#line 444 "vcc.y"*/
|
||||
/******************************************************************************/
|
||||
static int pushVObject(const char *prop)
|
||||
{
|
||||
VObject *newObj;
|
||||
if (ObjStackTop == MAXLEVEL)
|
||||
return PR_FALSE;
|
||||
if (ObjStackTop == PR_MAXLEVEL)
|
||||
return FALSE;
|
||||
|
||||
ObjStack[++ObjStackTop] = curObj;
|
||||
|
||||
|
@ -444,7 +437,7 @@ static int pushVObject(const char *prop)
|
|||
else
|
||||
curObj = newVObject(prop);
|
||||
|
||||
return PR_TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
@ -463,6 +456,7 @@ static VObject* popVObject()
|
|||
return oldObj;
|
||||
}
|
||||
|
||||
extern "C" void deleteString(char *p);
|
||||
|
||||
static void enterValues(const char *value)
|
||||
{
|
||||
|
@ -478,18 +472,18 @@ static void enterValues(const char *value)
|
|||
setVObjectUStringZValue_(curProp,fakeUnicode(value,0));
|
||||
}
|
||||
}
|
||||
deleteStr(value);
|
||||
deleteString((char *)value);
|
||||
}
|
||||
|
||||
static void enterProps(const char *s)
|
||||
{
|
||||
curProp = addGroup(curObj,s);
|
||||
deleteStr(s);
|
||||
deleteString((char *)s);
|
||||
}
|
||||
|
||||
static void enterAttr(const char *s1, const char *s2)
|
||||
{
|
||||
const char *p1, *p2=nsnull;
|
||||
const char *p1, *p2;
|
||||
p1 = lookupProp_(s1);
|
||||
if (s2) {
|
||||
VObject *a;
|
||||
|
@ -499,23 +493,23 @@ static void enterAttr(const char *s1, const char *s2)
|
|||
}
|
||||
else
|
||||
addProp(curProp,p1);
|
||||
if (nsCRT::strcasecmp(p1,VCBase64Prop) == 0 || (s2 && nsCRT::strcasecmp(p2,VCBase64Prop)==0))
|
||||
if (PL_strcasecmp(p1,VCBase64Prop) == 0 || (s2 && PL_strcasecmp(p2,VCBase64Prop)==0))
|
||||
lexPushMode(L_BASE64);
|
||||
else if (nsCRT::strcasecmp(p1,VCQuotedPrintableProp) == 0
|
||||
|| (s2 && nsCRT::strcasecmp(p2,VCQuotedPrintableProp)==0))
|
||||
else if (PL_strcasecmp(p1,VCQuotedPrintableProp) == 0
|
||||
|| (s2 && PL_strcasecmp(p2,VCQuotedPrintableProp)==0))
|
||||
lexPushMode(L_QUOTED_PRINTABLE);
|
||||
deleteStr(s1); deleteStr(s2);
|
||||
deleteString((char *)s1); deleteString((char *)s2);
|
||||
}
|
||||
|
||||
|
||||
#define MAX_LEX_LOOKAHEAD_0 32
|
||||
#define MAX_LEX_LOOKAHEAD 64
|
||||
#define MAX_LEX_MODE_STACK_SIZE 10
|
||||
#define PR_MAX_LEX_LOOKAHEAD_0 32
|
||||
#define PR_MAX_LEX_LOOKAHEAD 64
|
||||
#define PR_MAX_LEX_MODE_STACK_SIZE 10
|
||||
#define LEXMODE() (lexBuf.lexModeStack[lexBuf.lexModeStackTop])
|
||||
|
||||
struct LexBuf {
|
||||
/* input */
|
||||
PRFileDesc *inputFile;
|
||||
nsInputFileStream *inputFile;
|
||||
char *inputString;
|
||||
unsigned long curPos;
|
||||
unsigned long inputLen;
|
||||
|
@ -524,11 +518,11 @@ struct LexBuf {
|
|||
/ can be represented correctly.
|
||||
*/
|
||||
unsigned long len;
|
||||
short buf[MAX_LEX_LOOKAHEAD];
|
||||
short buf[PR_MAX_LEX_LOOKAHEAD];
|
||||
unsigned long getPtr;
|
||||
/* context stack */
|
||||
unsigned long lexModeStackTop;
|
||||
enum LexMode lexModeStack[MAX_LEX_MODE_STACK_SIZE];
|
||||
enum LexMode lexModeStack[PR_MAX_LEX_MODE_STACK_SIZE];
|
||||
/* token buffer */
|
||||
unsigned long maxToken;
|
||||
char *strs;
|
||||
|
@ -537,7 +531,7 @@ struct LexBuf {
|
|||
|
||||
static void lexPushMode(enum LexMode mode)
|
||||
{
|
||||
if (lexBuf.lexModeStackTop == (MAX_LEX_MODE_STACK_SIZE-1))
|
||||
if (lexBuf.lexModeStackTop == (PR_MAX_LEX_MODE_STACK_SIZE-1))
|
||||
yyerror("lexical context stack overflow");
|
||||
else {
|
||||
lexBuf.lexModeStack[++lexBuf.lexModeStackTop] = mode;
|
||||
|
@ -568,10 +562,16 @@ static int lexGetc_()
|
|||
return EOF;
|
||||
else if (lexBuf.inputString)
|
||||
return *(lexBuf.inputString + lexBuf.curPos++);
|
||||
else {
|
||||
char c;
|
||||
PR_Read(lexBuf.inputFile, &c, 1);
|
||||
return c;
|
||||
else
|
||||
{
|
||||
char c;
|
||||
nsresult status;
|
||||
|
||||
status = lexBuf.inputFile->read(&c, 1);
|
||||
if (status != 1)
|
||||
return -1;
|
||||
else
|
||||
return c;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -584,13 +584,13 @@ static int lexGeta()
|
|||
static int lexGeta_(int i)
|
||||
{
|
||||
++lexBuf.len;
|
||||
return (lexBuf.buf[(lexBuf.getPtr+i)%MAX_LEX_LOOKAHEAD] = lexGetc_());
|
||||
return (lexBuf.buf[(lexBuf.getPtr+i)%PR_MAX_LEX_LOOKAHEAD] = lexGetc_());
|
||||
}
|
||||
|
||||
static void lexSkipLookahead() {
|
||||
if (lexBuf.len > 0 && lexBuf.buf[lexBuf.getPtr]!=EOF) {
|
||||
/* don't skip EOF. */
|
||||
lexBuf.getPtr = (lexBuf.getPtr + 1) % MAX_LEX_LOOKAHEAD;
|
||||
lexBuf.getPtr = (lexBuf.getPtr + 1) % PR_MAX_LEX_LOOKAHEAD;
|
||||
lexBuf.len--;
|
||||
}
|
||||
}
|
||||
|
@ -602,7 +602,7 @@ static int lexLookahead() {
|
|||
/* do the \r\n -> \n or \r -> \n translation here */
|
||||
if (c == '\r') {
|
||||
int a = (lexBuf.len>1)?
|
||||
lexBuf.buf[(lexBuf.getPtr+1)%MAX_LEX_LOOKAHEAD]:
|
||||
lexBuf.buf[(lexBuf.getPtr+1)%PR_MAX_LEX_LOOKAHEAD]:
|
||||
lexGeta_(1);
|
||||
if (a == '\n') {
|
||||
lexSkipLookahead();
|
||||
|
@ -625,7 +625,7 @@ static int lexGetc() {
|
|||
int c = lexLookahead();
|
||||
if (lexBuf.len > 0 && lexBuf.buf[lexBuf.getPtr]!=EOF) {
|
||||
/* EOF will remain in lookahead buffer */
|
||||
lexBuf.getPtr = (lexBuf.getPtr + 1) % MAX_LEX_LOOKAHEAD;
|
||||
lexBuf.getPtr = (lexBuf.getPtr + 1) % PR_MAX_LEX_LOOKAHEAD;
|
||||
lexBuf.len--;
|
||||
}
|
||||
return c;
|
||||
|
@ -634,7 +634,7 @@ static int lexGetc() {
|
|||
static void lexSkipLookaheadWord() {
|
||||
if (lexBuf.strsLen <= lexBuf.len) {
|
||||
lexBuf.len -= lexBuf.strsLen;
|
||||
lexBuf.getPtr = (lexBuf.getPtr + lexBuf.strsLen) % MAX_LEX_LOOKAHEAD;
|
||||
lexBuf.getPtr = (lexBuf.getPtr + lexBuf.strsLen) % PR_MAX_LEX_LOOKAHEAD;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -673,7 +673,7 @@ static char* lexGetWord() {
|
|||
lexSkipWhite();
|
||||
lexClearToken();
|
||||
c = lexLookahead();
|
||||
while (c != EOF && !PL_strchr("\t\n ;:=",c)) {
|
||||
while (c != EOF && !PL_strchr("\t\n ;:=",(char)c)) {
|
||||
lexAppendc(c);
|
||||
lexSkipLookahead();
|
||||
c = lexLookahead();
|
||||
|
@ -685,16 +685,16 @@ static char* lexGetWord() {
|
|||
#if 0
|
||||
static void lexPushLookahead(char *s, int len) {
|
||||
int putptr;
|
||||
if (len == 0) len = nsCRT::strlen(s);
|
||||
if (len == 0) len = PL_strlen(s);
|
||||
putptr = lexBuf.getPtr - len;
|
||||
/* this function assumes that length of word to push back
|
||||
/ is not greater than MAX_LEX_LOOKAHEAD.
|
||||
/ is not greater than PR_MAX_LEX_LOOKAHEAD.
|
||||
*/
|
||||
if (putptr < 0) putptr += MAX_LEX_LOOKAHEAD;
|
||||
if (putptr < 0) putptr += PR_MAX_LEX_LOOKAHEAD;
|
||||
lexBuf.getPtr = putptr;
|
||||
while (*s) {
|
||||
lexBuf.buf[putptr] = *s++;
|
||||
putptr = (putptr + 1) % MAX_LEX_LOOKAHEAD;
|
||||
putptr = (putptr + 1) % PR_MAX_LEX_LOOKAHEAD;
|
||||
}
|
||||
lexBuf.len += len;
|
||||
}
|
||||
|
@ -705,14 +705,14 @@ static void lexPushLookaheadc(int c) {
|
|||
/* can't putback EOF, because it never leaves lookahead buffer */
|
||||
if (c == EOF) return;
|
||||
putptr = (int) lexBuf.getPtr - 1;
|
||||
if (putptr < 0) putptr += MAX_LEX_LOOKAHEAD;
|
||||
if (putptr < 0) putptr += PR_MAX_LEX_LOOKAHEAD;
|
||||
lexBuf.getPtr = putptr;
|
||||
lexBuf.buf[putptr] = c;
|
||||
lexBuf.len += 1;
|
||||
}
|
||||
|
||||
static char* lexLookaheadWord() {
|
||||
/* this function can lookahead word with max size of MAX_LEX_LOOKAHEAD_0
|
||||
/* this function can lookahead word with max size of PR_MAX_LEX_LOOKAHEAD_0
|
||||
/ and thing bigger than that will stop the lookahead and return 0;
|
||||
/ leading white spaces are not recoverable.
|
||||
*/
|
||||
|
@ -722,10 +722,10 @@ static char* lexLookaheadWord() {
|
|||
lexSkipWhite();
|
||||
lexClearToken();
|
||||
curgetptr = (int) lexBuf.getPtr; /* remember! */
|
||||
while (len < (MAX_LEX_LOOKAHEAD_0)) {
|
||||
while (len < (PR_MAX_LEX_LOOKAHEAD_0)) {
|
||||
c = lexGetc();
|
||||
len++;
|
||||
if (c == EOF || PL_strchr("\t\n ;:=", c)) {
|
||||
if (c == EOF || PL_strchr("\t\n ;:=", (char)c)) {
|
||||
lexAppendc(0);
|
||||
/* restore lookahead buf. */
|
||||
lexBuf.len += len;
|
||||
|
@ -809,7 +809,7 @@ static char* lexGet1Value() {
|
|||
}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
|
||||
static char* lexGetStrUntil(char *termset) {
|
||||
int c = lexLookahead();
|
||||
lexClearToken();
|
||||
|
@ -821,17 +821,16 @@ static char* lexGetStrUntil(char *termset) {
|
|||
lexAppendc(0);
|
||||
return c==EOF?0:lexStr();
|
||||
}
|
||||
#endif
|
||||
|
||||
static int match_begin_name(int end) {
|
||||
char *n = lexLookaheadWord();
|
||||
int token = ID;
|
||||
if (n) {
|
||||
if (!nsCRT::strcasecmp(n,"vcard")) token = end?END_VCARD:BEGIN_VCARD;
|
||||
else if (!nsCRT::strcasecmp(n,"vcalendar")) token = end?END_VCAL:BEGIN_VCAL;
|
||||
else if (!nsCRT::strcasecmp(n,"vevent")) token = end?END_VEVENT:BEGIN_VEVENT;
|
||||
else if (!nsCRT::strcasecmp(n,"vtodo")) token = end?END_VTODO:BEGIN_VTODO;
|
||||
deleteStr(n);
|
||||
if (!PL_strcasecmp(n,"vcard")) token = end?END_VCARD:BEGIN_VCARD;
|
||||
else if (!PL_strcasecmp(n,"vcalendar")) token = end?END_VCAL:BEGIN_VCAL;
|
||||
else if (!PL_strcasecmp(n,"vevent")) token = end?END_VEVENT:BEGIN_VEVENT;
|
||||
else if (!PL_strcasecmp(n,"vtodo")) token = end?END_VTODO:BEGIN_VTODO;
|
||||
deleteString(n);
|
||||
return token;
|
||||
}
|
||||
return 0;
|
||||
|
@ -842,7 +841,7 @@ static int match_begin_name(int end) {
|
|||
#pragma require_prototypes off
|
||||
#endif
|
||||
|
||||
void initLex(const char *inputstring, unsigned long inputlen, PRFileDesc *inputfile)
|
||||
void initLex(const char *inputstring, unsigned long inputlen, nsInputFileStream *inputFile)
|
||||
{
|
||||
/* initialize lex mode stack */
|
||||
lexBuf.lexModeStack[lexBuf.lexModeStackTop=0] = L_NORMAL;
|
||||
|
@ -851,13 +850,13 @@ void initLex(const char *inputstring, unsigned long inputlen, PRFileDesc *inputf
|
|||
lexBuf.inputString = (char*) inputstring;
|
||||
lexBuf.inputLen = inputlen;
|
||||
lexBuf.curPos = 0;
|
||||
lexBuf.inputFile = inputfile;
|
||||
lexBuf.inputFile = inputFile;
|
||||
|
||||
lexBuf.len = 0;
|
||||
lexBuf.getPtr = 0;
|
||||
|
||||
lexBuf.maxToken = MAXTOKEN;
|
||||
lexBuf.strs = (char*)PR_Malloc(MAXTOKEN);
|
||||
lexBuf.maxToken = PR_MAXTOKEN;
|
||||
lexBuf.strs = (char*)PR_CALLOC(PR_MAXTOKEN);
|
||||
lexBuf.strsLen = 0;
|
||||
|
||||
}
|
||||
|
@ -938,7 +937,7 @@ static char * lexGetDataFromBase64()
|
|||
if (bytesLen + numOut > bytesMax) {
|
||||
if (!bytes) {
|
||||
bytesMax = 1024;
|
||||
bytes = (unsigned char*)PR_Malloc(bytesMax);
|
||||
bytes = (unsigned char*)PR_CALLOC(bytesMax);
|
||||
}
|
||||
else {
|
||||
bytesMax <<= 2;
|
||||
|
@ -950,7 +949,7 @@ static char * lexGetDataFromBase64()
|
|||
}
|
||||
}
|
||||
if (bytes) {
|
||||
nsCRT::memcpy(bytes + bytesLen, outBytes, numOut);
|
||||
memcpy(bytes + bytesLen, outBytes, numOut);
|
||||
bytesLen += numOut;
|
||||
}
|
||||
trip = 0;
|
||||
|
@ -986,7 +985,7 @@ static int match_begin_end_name(int end) {
|
|||
}
|
||||
else if (token != 0) {
|
||||
lexSkipLookaheadWord();
|
||||
deleteStr(yylval.str);
|
||||
deleteString(yylval.str);
|
||||
DBG_(("db: begin/end %d\n", token));
|
||||
return token;
|
||||
}
|
||||
|
@ -1075,11 +1074,11 @@ static int yylex() {
|
|||
#endif
|
||||
return SEMICOLON;
|
||||
}
|
||||
else if (PL_strchr("\n",c)) {
|
||||
else if (PL_strchr("\n",(char)c)) {
|
||||
++mime_lineNum;
|
||||
/* consume all line separator(s) adjacent to each other */
|
||||
c = lexLookahead();
|
||||
while (PL_strchr("\n",c)) {
|
||||
while (PL_strchr("\n",(char)c)) {
|
||||
lexSkipLookahead();
|
||||
c = lexLookahead();
|
||||
++mime_lineNum;
|
||||
|
@ -1123,7 +1122,7 @@ static int yylex() {
|
|||
/* consume all line separator(s) adjacent to each other */
|
||||
/* ignoring linesep immediately after colon. */
|
||||
c = lexLookahead();
|
||||
while (PL_strchr("\n",c)) {
|
||||
while (PL_strchr("\n",(char)c)) {
|
||||
lexSkipLookahead();
|
||||
c = lexLookahead();
|
||||
++mime_lineNum;
|
||||
|
@ -1148,13 +1147,13 @@ static int yylex() {
|
|||
break;
|
||||
default: {
|
||||
lexPushLookaheadc(c);
|
||||
if (IS_ALPHA(c)) {
|
||||
if (isalpha(c)) {
|
||||
char *t = lexGetWord();
|
||||
yylval.str = t;
|
||||
if (!nsCRT::strcasecmp(t, "BEGIN")) {
|
||||
if (!PL_strcasecmp(t, "BEGIN")) {
|
||||
return match_begin_end_name(0);
|
||||
}
|
||||
else if (!nsCRT::strcasecmp(t,"END")) {
|
||||
else if (!PL_strcasecmp(t,"END")) {
|
||||
return match_begin_end_name(1);
|
||||
}
|
||||
else {
|
||||
|
@ -1195,7 +1194,6 @@ static VObject* Parse_MIMEHelper()
|
|||
}
|
||||
|
||||
/******************************************************************************/
|
||||
extern "C"
|
||||
VObject* Parse_MIME(const char *input, unsigned long len)
|
||||
{
|
||||
initLex(input, len, 0);
|
||||
|
@ -1203,27 +1201,27 @@ VObject* Parse_MIME(const char *input, unsigned long len)
|
|||
}
|
||||
|
||||
|
||||
VObject* Parse_MIME_FromFile(PRFileDesc *file)
|
||||
VObject* Parse_MIME_FromFile(nsInputFileStream *file)
|
||||
{
|
||||
VObject *result;
|
||||
PRInt32 startPos;
|
||||
long startPos;
|
||||
|
||||
initLex(0,(unsigned long)-1,file);
|
||||
|
||||
startPos = PR_Seek(file, 0, PR_SEEK_CUR);
|
||||
startPos = file->tell();
|
||||
if (!(result = Parse_MIMEHelper())) {
|
||||
PR_Seek(file,startPos,PR_SEEK_SET);
|
||||
file->seek(startPos);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
VObject* Parse_MIME_FromFileName(char *fname)
|
||||
VObject* Parse_MIME_FromFileName(nsFileSpec *fname)
|
||||
{
|
||||
#if !defined(MOZADDRSTANDALONE)
|
||||
PRFileDesc *fp = PR_Open(fname, PR_RDONLY, 493);
|
||||
if (fp) {
|
||||
nsInputFileStream *fp = new nsInputFileStream(*fname);
|
||||
if (fp)
|
||||
{
|
||||
VObject* o = Parse_MIME_FromFile(fp);
|
||||
PR_Close(fp);
|
||||
fp->close();
|
||||
return o;
|
||||
}
|
||||
else {
|
||||
|
@ -1233,19 +1231,11 @@ VObject* Parse_MIME_FromFileName(char *fname)
|
|||
return 0;
|
||||
}
|
||||
#else
|
||||
PR_ASSERT (PR_FALSE);
|
||||
PR_ASSERT(FALSE);
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
#if 0
|
||||
static void YYDebug(const char *s)
|
||||
{
|
||||
/* PR_LogPrint("%s\n", s); */
|
||||
}
|
||||
#endif
|
||||
|
||||
static MimeErrorHandler mimeErrorHandler;
|
||||
|
||||
void registerMimeErrorHandler(MimeErrorHandler me)
|
||||
|
@ -1298,7 +1288,7 @@ yyparse()
|
|||
*yyssp = yystate = 0;
|
||||
|
||||
yyloop:
|
||||
if ((yyn = yydefred[yystate])) goto yyreduce;
|
||||
if (yyn = yydefred[yystate]) goto yyreduce;
|
||||
if (yychar < 0)
|
||||
{
|
||||
if ((yychar = yylex()) < 0) yychar = 0;
|
||||
|
@ -1306,7 +1296,7 @@ yyloop:
|
|||
if (yydebug)
|
||||
{
|
||||
yys = 0;
|
||||
if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
|
||||
if (yychar <= YYPR_MAXTOKEN) yys = yyname[yychar];
|
||||
if (!yys) yys = "illegal-symbol";
|
||||
printf("yydebug: state %d, reading %d (%s)\n", yystate,
|
||||
yychar, yys);
|
||||
|
@ -1340,8 +1330,8 @@ yyloop:
|
|||
if (yyerrflag) goto yyinrecovery;
|
||||
#ifdef lint
|
||||
goto yynewerror;
|
||||
yynewerror:
|
||||
#endif
|
||||
/*yynewerror: */
|
||||
yyerror("syntax error");
|
||||
#ifdef lint
|
||||
goto yyerrlab;
|
||||
|
@ -1390,7 +1380,7 @@ yyinrecovery:
|
|||
if (yydebug)
|
||||
{
|
||||
yys = 0;
|
||||
if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
|
||||
if (yychar <= YYPR_MAXTOKEN) yys = yyname[yychar];
|
||||
if (!yys) yys = "illegal-symbol";
|
||||
printf("yydebug: state %d, error recovery discards token %d (%s)\n",
|
||||
yystate, yychar, yys);
|
||||
|
@ -1591,7 +1581,7 @@ break;
|
|||
if (yydebug)
|
||||
{
|
||||
yys = 0;
|
||||
if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
|
||||
if (yychar <= YYPR_MAXTOKEN) yys = yyname[yychar];
|
||||
if (!yys) yys = "illegal-symbol";
|
||||
printf("yydebug: state %d, reading %d (%s)\n",
|
||||
YYFINAL, yychar, yys);
|
||||
|
@ -1625,6 +1615,3 @@ yyabort:
|
|||
yyaccept:
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* end of source file vcc.c */
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
* Contributor(s):
|
||||
*/
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
(C) Copyright 1996 Apple Computer, Inc., AT&T Corp., International
|
||||
Business Machines Corporation and Siemens Rolm Communications Inc.
|
||||
|
@ -61,16 +62,23 @@ DFARS 252.227-7013 or 48 CFR 52.227-19, as applicable.
|
|||
#ifndef __VCC_H__
|
||||
#define __VCC_H__ 1
|
||||
|
||||
#include "xp.h"
|
||||
#include "nsFileStream.h"
|
||||
#include "nsFileSpec.h"
|
||||
#include "nsVCardObj.h"
|
||||
|
||||
extern "C" VObject* Parse_MIME(const char *input, unsigned long len);
|
||||
XP_BEGIN_PROTOS
|
||||
|
||||
VObject* Parse_MIME_FromFile(PRFileDesc *file);
|
||||
VObject* Parse_MIME(const char *input, unsigned long len);
|
||||
|
||||
VObject* Parse_MIME_FromFileName(char* fname);
|
||||
VObject* Parse_MIME_FromFile(nsInputFileStream *file);
|
||||
|
||||
VObject* Parse_MIME_FromFileName(nsFileSpec * fname);
|
||||
|
||||
typedef void (*MimeErrorHandler)(char *);
|
||||
|
||||
void registerMimeErrorHandler(MimeErrorHandler);
|
||||
|
||||
XP_END_PROTOS
|
||||
|
||||
#endif /* __VCC_H__ */
|
||||
|
|
|
@ -59,37 +59,41 @@ DFARS 252.227-7013 or 48 CFR 52.227-19, as applicable.
|
|||
***************************************************************************/
|
||||
|
||||
/*
|
||||
* src: vobject.c
|
||||
* doc: vobject and APIs to construct vobject, APIs pretty print
|
||||
* vobject, and convert a vobject into its textual representation.
|
||||
*/
|
||||
|
||||
#include "nsVCard.h"
|
||||
#include "nsVCardObj.h"
|
||||
#include "plstr.h"
|
||||
#include "prmem.h"
|
||||
#include "prprf.h"
|
||||
#include "msgCore.h"
|
||||
#include "nsCRT.h"
|
||||
#include "plstr.h"
|
||||
#define NOT_NULL(X) X
|
||||
|
||||
/* debugging utilities */
|
||||
#if DEBUG_mwatkins
|
||||
#define DBG_(x) PR_LogPrint x
|
||||
#else
|
||||
#define DBG_(x)
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
static const char** fieldedProp;
|
||||
char **fieldedProp;
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
static VObject* newVObject_(const char *id);
|
||||
#if 0
|
||||
static int vObjectValueType(VObject *o);
|
||||
static void initVObjectIterator(VObjectIterator *i, VObject *o);
|
||||
#endif
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
The following functions involve with memory allocation:
|
||||
newVObject
|
||||
deleteVObject
|
||||
dupStr
|
||||
deleteStr
|
||||
deleteString
|
||||
newStrItem
|
||||
deleteStrItem
|
||||
----------------------------------------------------------------------*/
|
||||
|
@ -98,21 +102,23 @@ static PRBool needsQuotedPrintable (const char *s)
|
|||
{
|
||||
const unsigned char *p = (const unsigned char *)s;
|
||||
|
||||
if (PL_strstr (s, MSG_LINEBREAK))
|
||||
return PR_TRUE;
|
||||
if (PL_strstr (s, LINEBREAK))
|
||||
return TRUE;
|
||||
|
||||
while (*p) {
|
||||
if (*p & 0x80)
|
||||
return PR_TRUE;
|
||||
return TRUE;
|
||||
else
|
||||
return FALSE;
|
||||
p++;
|
||||
}
|
||||
|
||||
return PR_FALSE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
VObject* newVObject_(const char *id)
|
||||
{
|
||||
VObject *p = (VObject*)PR_NEW(VObject);
|
||||
VObject *p = (VObject*) new(VObject);
|
||||
p->next = 0;
|
||||
p->id = id;
|
||||
p->prop = 0;
|
||||
|
@ -121,7 +127,6 @@ VObject* newVObject_(const char *id)
|
|||
return p;
|
||||
}
|
||||
|
||||
extern "C"
|
||||
VObject* newVObject(const char *id)
|
||||
{
|
||||
return newVObject_(lookupStr(id));
|
||||
|
@ -135,39 +140,42 @@ void deleteVObject(VObject *p)
|
|||
|
||||
char* dupStr(const char *s, unsigned int size)
|
||||
{
|
||||
char *t;
|
||||
if (size == 0) {
|
||||
size = nsCRT::strlen(s);
|
||||
}
|
||||
t = (char*)PR_Malloc(size+1);
|
||||
if (t) {
|
||||
nsCRT::memcpy(t,s,size);
|
||||
t[size] = 0;
|
||||
return t;
|
||||
}
|
||||
else {
|
||||
return (char*)0;
|
||||
}
|
||||
}
|
||||
|
||||
extern "C"
|
||||
void deleteStr(const char *p)
|
||||
{
|
||||
if (p) PR_Free ((void*)p);
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
static StrItem* newStrItem(const char *s, StrItem *next)
|
||||
{
|
||||
StrItem *p = (StrItem*)PR_Malloc(sizeof(StrItem));
|
||||
StrItem *p = (StrItem*)PR_CALLOC(sizeof(StrItem));
|
||||
p->next = next;
|
||||
p->s = s;
|
||||
p->refCnt = 1;
|
||||
return p;
|
||||
}
|
||||
|
||||
static void deleteStrItem(StrItem *p)
|
||||
extern "C"
|
||||
void deleteString(char *p)
|
||||
{
|
||||
if (p) PR_Free ((void*)p);
|
||||
if (p)
|
||||
PR_Free ((void*)p);
|
||||
}
|
||||
|
||||
extern "C"
|
||||
void deleteStrItem(StrItem *p)
|
||||
{
|
||||
if (p)
|
||||
PR_FREEIF (p);
|
||||
}
|
||||
|
||||
|
||||
|
@ -264,12 +272,11 @@ void setVObjectVObjectValue(VObject *o, VObject *p)
|
|||
VALUE_TYPE(o) = VCVT_VOBJECT;
|
||||
}
|
||||
|
||||
#if 0
|
||||
int vObjectValueType(VObject *o)
|
||||
{
|
||||
return VALUE_TYPE(o);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
The following functions can be used to build VObject.
|
||||
|
@ -310,7 +317,6 @@ VObject* addVObjectProp(VObject *o, VObject *p)
|
|||
return p;
|
||||
}
|
||||
|
||||
extern "C"
|
||||
VObject* addProp(VObject *o, const char *id)
|
||||
{
|
||||
return addVObjectProp(o,newVObject(id));
|
||||
|
@ -321,7 +327,6 @@ VObject* addProp_(VObject *o, const char *id)
|
|||
return addVObjectProp(o,newVObject_(id));
|
||||
}
|
||||
|
||||
extern "C"
|
||||
void addList(VObject **o, VObject *p)
|
||||
{
|
||||
p->next = 0;
|
||||
|
@ -351,7 +356,6 @@ VObject* setValueWithSize_(VObject *prop, void *val, unsigned int size)
|
|||
return prop;
|
||||
}
|
||||
|
||||
extern "C"
|
||||
VObject* setValueWithSize(VObject *prop, void *val, unsigned int size)
|
||||
{
|
||||
void *p = dupStr((const char *)val,size);
|
||||
|
@ -364,13 +368,11 @@ void initPropIterator(VObjectIterator *i, VObject *o)
|
|||
i->next = 0;
|
||||
}
|
||||
|
||||
#if 0
|
||||
void initVObjectIterator(VObjectIterator *i, VObject *o)
|
||||
{
|
||||
i->start = o->next;
|
||||
i->next = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
int moreIteration(VObjectIterator *i)
|
||||
{
|
||||
|
@ -398,7 +400,7 @@ VObject* isAPropertyOf(VObject *o, const char *id)
|
|||
initPropIterator(&i,o);
|
||||
while (moreIteration(&i)) {
|
||||
VObject *each = nextVObject(&i);
|
||||
if (!nsCRT::strcasecmp(id,each->id))
|
||||
if (!PL_strcasecmp(id,each->id))
|
||||
return each;
|
||||
}
|
||||
return (VObject*)0;
|
||||
|
@ -435,7 +437,7 @@ VObject* addGroup(VObject *o, const char *g)
|
|||
t = addProp(t,VCGroupingProp);
|
||||
setVObjectStringZValue(t,lookupProp_(n));
|
||||
} while (n != gs);
|
||||
deleteStr(gs);
|
||||
deleteString(gs);
|
||||
return p;
|
||||
}
|
||||
else
|
||||
|
@ -449,7 +451,7 @@ VObject* addPropValue(VObject *o, const char *p, const char *v)
|
|||
if (v) {
|
||||
setVObjectUStringZValue_(prop, fakeUnicode(v,0));
|
||||
if (needsQuotedPrintable (v)) {
|
||||
if (nsCRT::strcasecmp (VCCardProp, vObjectName(o)) == 0)
|
||||
if (PL_strcasecmp (VCCardProp, vObjectName(o)) == 0)
|
||||
addProp (prop, VCQuotedPrintableProp);
|
||||
else
|
||||
addProp (o, VCQuotedPrintableProp);
|
||||
|
@ -482,123 +484,156 @@ VObject* addPropSizedValue(VObject *o, const char *p, const char *v,
|
|||
The following pretty print a VObject
|
||||
----------------------------------------------------------------------*/
|
||||
|
||||
/* extern void printVObject_(PRFileDesc *fp, VObject *o, int level); */
|
||||
|
||||
static void indent(PRFileDesc *fp, int level)
|
||||
static void indent(nsOutputFileStream *fp, int level)
|
||||
{
|
||||
int i;
|
||||
for (i=0;i<level*4;i++) {
|
||||
PR_Write(fp, " ", 1);
|
||||
fp->write(" ", 1);
|
||||
}
|
||||
}
|
||||
|
||||
static void printValue(PRFileDesc *fp, VObject *o, int level)
|
||||
static void printValue(nsOutputFileStream *fp, VObject *o, int level)
|
||||
{
|
||||
switch (VALUE_TYPE(o)) {
|
||||
case VCVT_USTRINGZ: {
|
||||
char c;
|
||||
char *t,*s;
|
||||
s = t = fakeCString(USTRINGZ_VALUE_OF(o));
|
||||
PR_Write(fp,"'",1);
|
||||
while (c=*t,c) {
|
||||
PR_Write(fp, &c, 1);
|
||||
if (c == '\n') indent(fp,level+2);
|
||||
t++;
|
||||
}
|
||||
PR_Write(fp, "'",1);
|
||||
deleteStr(s);
|
||||
break;
|
||||
}
|
||||
case VCVT_STRINGZ: {
|
||||
char c;
|
||||
char *str = &c;
|
||||
const char *s = STRINGZ_VALUE_OF(o);
|
||||
PR_Write(fp,"'",1);
|
||||
while (c=*s,c) {
|
||||
PR_Write(fp,str,1);
|
||||
if (c == '\n') indent(fp,level+2);
|
||||
s++;
|
||||
}
|
||||
PR_Write(fp, "'", 1);
|
||||
break;
|
||||
}
|
||||
case VCVT_UINT:
|
||||
PR_fprintf(fp,"%d", INTEGER_VALUE_OF(o)); break;
|
||||
case VCVT_ULONG:
|
||||
PR_fprintf(fp,"%ld", LONG_VALUE_OF(o)); break;
|
||||
case VCVT_RAW:
|
||||
PR_fprintf(fp,"[raw data]"); break;
|
||||
case VCVT_VOBJECT:
|
||||
PR_fprintf(fp,"[vobject]\n");
|
||||
printVObject_(fp,VOBJECT_VALUE_OF(o),level+1);
|
||||
break;
|
||||
case 0:
|
||||
PR_fprintf(fp,"[none]"); break;
|
||||
default:
|
||||
PR_fprintf(fp,"[unknown]"); break;
|
||||
}
|
||||
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, nsCRT::strlen(buf));
|
||||
PR_FREEIF(buf);
|
||||
}
|
||||
break;
|
||||
|
||||
case VCVT_ULONG:
|
||||
buf = PR_smprintf("%ld", LONG_VALUE_OF(o));
|
||||
if (buf)
|
||||
{
|
||||
fp->write(buf, nsCRT::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;
|
||||
}
|
||||
}
|
||||
|
||||
static void printNameValue(PRFileDesc *fp,VObject *o, int level)
|
||||
static void printNameValue(nsOutputFileStream *fp,VObject *o, int level)
|
||||
{
|
||||
indent(fp,level);
|
||||
if (NAME_OF(o)) {
|
||||
PR_fprintf(fp,"%s", NAME_OF(o));
|
||||
}
|
||||
if (VALUE_TYPE(o)) {
|
||||
PR_fprintf(fp, "=", 1);
|
||||
printValue(fp,o, level);
|
||||
}
|
||||
PR_fprintf(fp,"\n");
|
||||
char *buf;
|
||||
|
||||
indent(fp,level);
|
||||
if (NAME_OF(o))
|
||||
{
|
||||
buf = PR_smprintf("%s", NAME_OF(o));
|
||||
if (buf)
|
||||
{
|
||||
fp->write(buf, nsCRT::strlen(buf));
|
||||
PR_FREEIF(buf);
|
||||
}
|
||||
}
|
||||
|
||||
if (VALUE_TYPE(o))
|
||||
{
|
||||
fp->write("=",1);
|
||||
printValue(fp,o, level);
|
||||
}
|
||||
|
||||
fp->write("\n", 1);
|
||||
}
|
||||
|
||||
void printVObject_(PRFileDesc *fp, VObject *o, int level)
|
||||
void printVObject_(nsOutputFileStream *fp, VObject *o, int level)
|
||||
{
|
||||
VObjectIterator t;
|
||||
if (o == 0) {
|
||||
char *buf = "[NULL]\n";
|
||||
PR_Write(fp,"[NULL]\n", nsCRT::strlen(buf));
|
||||
fp->write("[NULL]\n", 7);
|
||||
return;
|
||||
}
|
||||
|
||||
printNameValue(fp,o,level);
|
||||
initPropIterator(&t,o);
|
||||
while (moreIteration(&t)) {
|
||||
|
||||
while (moreIteration(&t))
|
||||
{
|
||||
VObject *eachProp = nextVObject(&t);
|
||||
printVObject_(fp,eachProp,level+1);
|
||||
}
|
||||
}
|
||||
|
||||
void printVObject(PRFileDesc *fp,VObject *o)
|
||||
void printVObject(nsOutputFileStream *fp,VObject *o)
|
||||
{
|
||||
printVObject_(fp,o,0);
|
||||
printVObject_(fp,o,0);
|
||||
}
|
||||
|
||||
void printVObjectToFile(char *fname,VObject *o)
|
||||
void printVObjectToFile(nsFileSpec *fname, VObject *o)
|
||||
{
|
||||
#if !defined(MOZADDRSTANDALONE)
|
||||
PRFileDesc *fp = PR_Open(fname, PR_RDWR, 493);
|
||||
nsOutputFileStream *fp = new nsOutputFileStream(*fname);
|
||||
|
||||
if (fp) {
|
||||
printVObject(fp,o);
|
||||
PR_Close(fp);
|
||||
fp->close();
|
||||
}
|
||||
#else
|
||||
PR_ASSERT (PR_FALSE);
|
||||
PR_ASSERT(FALSE);
|
||||
#endif
|
||||
}
|
||||
|
||||
void printVObjectsToFile(char *fname,VObject *list)
|
||||
void printVObjectsToFile(nsFileSpec *fname,VObject *list)
|
||||
{
|
||||
#if !defined(MOZADDRSTANDALONE)
|
||||
PRFileDesc *fp = PR_Open(fname,PR_RDWR, 493);
|
||||
if (fp) {
|
||||
while (list) {
|
||||
printVObject(fp,list);
|
||||
list = nextVObjectInList(list);
|
||||
}
|
||||
PR_Close(fp);
|
||||
}
|
||||
nsOutputFileStream *fp = new nsOutputFileStream(*fname);
|
||||
if (fp) {
|
||||
while (list) {
|
||||
printVObject(fp,list);
|
||||
list = nextVObjectInList(list);
|
||||
}
|
||||
fp->close();
|
||||
}
|
||||
#else
|
||||
PR_ASSERT (PR_FALSE);
|
||||
PR_ASSERT(FALSE);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -628,7 +663,8 @@ void cleanVObject(VObject *o)
|
|||
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));
|
||||
if ((char*) STRINGZ_VALUE_OF(o))
|
||||
PR_Free ((char*)STRINGZ_VALUE_OF(o));
|
||||
break;
|
||||
case VCVT_VOBJECT:
|
||||
cleanVObject(VOBJECT_VALUE_OF(o));
|
||||
|
@ -671,7 +707,7 @@ void unUseStr(const char *s)
|
|||
if ((t = strTbl[h]) != 0) {
|
||||
p = t;
|
||||
do {
|
||||
if (nsCRT::strcasecmp(t->s,s) == 0) {
|
||||
if (PL_strcasecmp(t->s,s) == 0) {
|
||||
t->refCnt--;
|
||||
if (t->refCnt == 0) {
|
||||
if (p == strTbl[h]) {
|
||||
|
@ -680,7 +716,7 @@ void unUseStr(const char *s)
|
|||
else {
|
||||
p->next = t->next;
|
||||
}
|
||||
deleteStr(t->s);
|
||||
deleteString((char *)t->s);
|
||||
deleteStrItem(t);
|
||||
return;
|
||||
}
|
||||
|
@ -698,7 +734,7 @@ void cleanStrTbl()
|
|||
StrItem *t = strTbl[i];
|
||||
while (t) {
|
||||
StrItem *p;
|
||||
deleteStr(t->s);
|
||||
deleteString((char *)t->s);
|
||||
p = t;
|
||||
t = t->next;
|
||||
deleteStrItem(p);
|
||||
|
@ -963,7 +999,7 @@ static struct PreDefProp* lookupPropInfo(const char* str)
|
|||
int i;
|
||||
|
||||
for (i = 0; propNames[i].name; i++)
|
||||
if (nsCRT::strcasecmp(str, propNames[i].name) == 0) {
|
||||
if (PL_strcasecmp(str, propNames[i].name) == 0) {
|
||||
return &propNames[i];
|
||||
}
|
||||
|
||||
|
@ -976,7 +1012,7 @@ const char* lookupProp_(const char* str)
|
|||
int i;
|
||||
|
||||
for (i = 0; propNames[i].name; i++)
|
||||
if (nsCRT::strcasecmp(str, propNames[i].name) == 0) {
|
||||
if (PL_strcasecmp(str, propNames[i].name) == 0) {
|
||||
const char* s;
|
||||
s = propNames[i].alias?propNames[i].alias:propNames[i].name;
|
||||
return lookupStr(s);
|
||||
|
@ -990,9 +1026,9 @@ const char* lookupProp(const char* str)
|
|||
int i;
|
||||
|
||||
for (i = 0; propNames[i].name; i++)
|
||||
if (nsCRT::strcasecmp(str, propNames[i].name) == 0) {
|
||||
if (PL_strcasecmp(str, propNames[i].name) == 0) {
|
||||
const char *s;
|
||||
fieldedProp = propNames[i].fields;
|
||||
fieldedProp = (char **)propNames[i].fields;
|
||||
s = propNames[i].alias?propNames[i].alias:propNames[i].name;
|
||||
return lookupStr(s);
|
||||
}
|
||||
|
@ -1006,7 +1042,7 @@ const char* lookupProp(const char* str)
|
|||
----------------------------------------------------------------------*/
|
||||
#define OFILE_REALLOC_SIZE 256
|
||||
/* typedef struct OFile {
|
||||
XP_File fp;
|
||||
nsOutputFileStream *fp;
|
||||
char *s;
|
||||
int len;
|
||||
int limit;
|
||||
|
@ -1014,84 +1050,30 @@ const char* lookupProp(const char* str)
|
|||
int fail:1;
|
||||
} OFile; */
|
||||
|
||||
#if 0
|
||||
static void appendsOFile(OFile *fp, const char *s)
|
||||
{
|
||||
int slen;
|
||||
if (fp->fail) return;
|
||||
slen = nsCRT::strlen(s);
|
||||
if (fp->fp) {
|
||||
PR_Write(fp->fp, s,slen);
|
||||
}
|
||||
else {
|
||||
stuff:
|
||||
if (fp->len + slen < fp->limit) {
|
||||
XP_MEMCPY(fp->s+fp->len,s,slen);
|
||||
fp->len += slen;
|
||||
return;
|
||||
}
|
||||
else if (fp->alloc) {
|
||||
fp->limit = fp->limit + OFILE_REALLOC_SIZE;
|
||||
if (OFILE_REALLOC_SIZE <= slen) fp->limit += slen;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void appendcOFile(OFile *fp, char c)
|
||||
{
|
||||
if (fp->fail) return;
|
||||
if (fp->fp) {
|
||||
PR_Write(fp->fp, &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;
|
||||
}
|
||||
}
|
||||
#else
|
||||
static void appendcOFile_(OFile *fp, char c)
|
||||
{
|
||||
if (fp->fail) return;
|
||||
if (fp->fp) {
|
||||
PR_Write(fp->fp, &c, 1);
|
||||
}
|
||||
else {
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
static void appendcOFile(OFile *fp, char c)
|
||||
|
@ -1099,8 +1081,8 @@ static void appendcOFile(OFile *fp, char c)
|
|||
/* int i = 0; */
|
||||
if (c == '\n') {
|
||||
/* write out as <CR><LF> */
|
||||
/* for (i = 0; i < MSG_LINEBREAK_LEN; i++)
|
||||
appendcOFile_(fp,MSG_LINEBREAK [ i ]); */
|
||||
/* for (i = 0; i < LINEBREAK_LEN; i++)
|
||||
appendcOFile_(fp,LINEBREAK [ i ]); */
|
||||
appendcOFile_(fp,0xd);
|
||||
appendcOFile_(fp,0xa);
|
||||
}
|
||||
|
@ -1111,15 +1093,13 @@ static void appendcOFile(OFile *fp, char c)
|
|||
static void appendsOFile(OFile *fp, const char *s)
|
||||
{
|
||||
int i, slen;
|
||||
slen = nsCRT::strlen (s);
|
||||
slen = PL_strlen (s);
|
||||
for (i=0; i<slen; i++) {
|
||||
appendcOFile(fp,s[i]);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
static void initOFile(OFile *fp, PRFileDesc *ofp)
|
||||
static void initOFile(OFile *fp, nsOutputFileStream *ofp)
|
||||
{
|
||||
fp->fp = ofp;
|
||||
fp->s = 0;
|
||||
|
@ -1147,7 +1127,7 @@ static int writeBase64(OFile *fp, unsigned char *s, long len)
|
|||
unsigned long trip;
|
||||
unsigned char b;
|
||||
char quad[5];
|
||||
#define MAXQUADS 16
|
||||
#define PR_MAXQUADS 16
|
||||
|
||||
quad[4] = 0;
|
||||
|
||||
|
@ -1174,8 +1154,8 @@ static int writeBase64(OFile *fp, unsigned char *s, long len)
|
|||
/* now output 'quad' with appropriate whitespace and line ending */
|
||||
appendsOFile(fp, (numQuads == 0 ? " " : ""));
|
||||
appendsOFile(fp, quad);
|
||||
appendsOFile(fp, ((cur >= len)?"\n" :(numQuads==MAXQUADS-1?"\n" : "")));
|
||||
numQuads = (numQuads + 1) % MAXQUADS;
|
||||
appendsOFile(fp, ((cur >= len)?"\n" :(numQuads==PR_MAXQUADS-1?"\n" : "")));
|
||||
numQuads = (numQuads + 1) % PR_MAXQUADS;
|
||||
}
|
||||
appendcOFile(fp,'\n');
|
||||
|
||||
|
@ -1187,9 +1167,9 @@ static void writeQPString(OFile *fp, const char *s)
|
|||
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;
|
||||
PRBool white = FALSE;
|
||||
PRBool contWhite = FALSE;
|
||||
PRBool mb_p = FALSE;
|
||||
|
||||
if (needsQuotedPrintable (s))
|
||||
{
|
||||
|
@ -1219,13 +1199,13 @@ static void writeQPString(OFile *fp, const char *s)
|
|||
appendcOFile(fp,'=');
|
||||
appendcOFile(fp,'\n');
|
||||
appendcOFile(fp,'\t');
|
||||
contWhite = PR_FALSE;
|
||||
contWhite = FALSE;
|
||||
}
|
||||
|
||||
/* If its CRLF, swallow two chars instead of one. */
|
||||
if (*p == CR && *(p+1) == LF)
|
||||
p++;
|
||||
white = PR_FALSE;
|
||||
white = FALSE;
|
||||
current_column = 0;
|
||||
}
|
||||
else
|
||||
|
@ -1236,8 +1216,8 @@ static void writeQPString(OFile *fp, const char *s)
|
|||
{
|
||||
appendcOFile(fp,*p);
|
||||
current_column++;
|
||||
white = PR_FALSE;
|
||||
contWhite = PR_FALSE;
|
||||
white = FALSE;
|
||||
contWhite = FALSE;
|
||||
}
|
||||
else if (*p == ' ' || *p == '\t') /* whitespace */
|
||||
{
|
||||
|
@ -1247,14 +1227,14 @@ static void writeQPString(OFile *fp, const char *s)
|
|||
appendcOFile(fp,hexdigits[*p >> 4]);
|
||||
appendcOFile(fp,hexdigits[*p & 0xF]);
|
||||
current_column += 3;
|
||||
contWhite = PR_FALSE;
|
||||
contWhite = FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
appendcOFile(fp,*p);
|
||||
current_column++;
|
||||
}
|
||||
white = PR_TRUE;
|
||||
white = TRUE;
|
||||
}
|
||||
else /* print as =FF */
|
||||
{
|
||||
|
@ -1262,11 +1242,11 @@ static void writeQPString(OFile *fp, const char *s)
|
|||
appendcOFile(fp,hexdigits[*p >> 4]);
|
||||
appendcOFile(fp,hexdigits[*p & 0xF]);
|
||||
current_column += 3;
|
||||
white = PR_FALSE;
|
||||
contWhite = PR_FALSE;
|
||||
white = FALSE;
|
||||
contWhite = FALSE;
|
||||
}
|
||||
|
||||
PR_ASSERT (current_column <= 76); /* Hard limit required by spec */
|
||||
PR_ASSERT(current_column <= 76); /* Hard limit required by spec */
|
||||
|
||||
if (current_column >= 73 || ((*(p+1) == ' ') && (current_column + 3 >= 73))) /* soft line break: "=\r\n" */
|
||||
{
|
||||
|
@ -1275,10 +1255,10 @@ static void writeQPString(OFile *fp, const char *s)
|
|||
appendcOFile(fp,'\t');
|
||||
current_column = 0;
|
||||
if (white)
|
||||
contWhite = PR_TRUE;
|
||||
contWhite = TRUE;
|
||||
else
|
||||
contWhite = PR_FALSE;
|
||||
white = PR_FALSE;
|
||||
contWhite = FALSE;
|
||||
white = FALSE;
|
||||
}
|
||||
}
|
||||
p++;
|
||||
|
@ -1294,8 +1274,6 @@ static void writeQPString(OFile *fp, const char *s)
|
|||
}
|
||||
|
||||
|
||||
/* extern void writeVObject_(OFile *fp, VObject *o); */
|
||||
|
||||
static void writeValue(OFile *fp, VObject *o, unsigned long size)
|
||||
{
|
||||
if (o == 0) return;
|
||||
|
@ -1303,7 +1281,7 @@ static void writeValue(OFile *fp, VObject *o, unsigned long size)
|
|||
case VCVT_USTRINGZ: {
|
||||
char *s = fakeCString(USTRINGZ_VALUE_OF(o));
|
||||
writeQPString(fp, s);
|
||||
deleteStr(s);
|
||||
deleteString(s);
|
||||
break;
|
||||
}
|
||||
case VCVT_STRINGZ: {
|
||||
|
@ -1346,7 +1324,7 @@ static void writeAttrValue(OFile *fp, VObject *o, int* length)
|
|||
(*length)++;
|
||||
appendsOFile(fp,NAME_OF(o));
|
||||
if (*length != -1)
|
||||
(*length) += nsCRT::strlen (NAME_OF(o));
|
||||
(*length) += PL_strlen (NAME_OF(o));
|
||||
}
|
||||
else {
|
||||
appendcOFile(fp,';');
|
||||
|
@ -1381,7 +1359,7 @@ static int inList(const char **list, const char *s)
|
|||
{
|
||||
if (list == 0) return 0;
|
||||
while (*list) {
|
||||
if (nsCRT::strcasecmp(*list,s) == 0) return 1;
|
||||
if (PL_strcasecmp(*list,s) == 0) return 1;
|
||||
list++;
|
||||
}
|
||||
return 0;
|
||||
|
@ -1390,6 +1368,7 @@ static int inList(const char **list, const char *s)
|
|||
static void writeProp(OFile *fp, VObject *o)
|
||||
{
|
||||
int length = -1;
|
||||
int ilen = 0;
|
||||
|
||||
if (NAME_OF(o)) {
|
||||
struct PreDefProp *pi;
|
||||
|
@ -1410,7 +1389,7 @@ static void writeProp(OFile *fp, VObject *o)
|
|||
const char *s;
|
||||
VObject *eachProp = nextVObject(&t);
|
||||
s = NAME_OF(eachProp);
|
||||
if (nsCRT::strcasecmp(VCGroupingProp,s) && !inList(fields_,s))
|
||||
if (PL_strcasecmp(VCGroupingProp,s) && !inList(fields_,s))
|
||||
writeAttrValue(fp,eachProp, &length);
|
||||
}
|
||||
if (fields_) {
|
||||
|
@ -1419,9 +1398,9 @@ static void writeProp(OFile *fp, VObject *o)
|
|||
/* output prop as fields */
|
||||
appendcOFile(fp,':');
|
||||
while (*fields) {
|
||||
VObject *t0 = isAPropertyOf(o,*fields);
|
||||
VObject *t = isAPropertyOf(o,*fields);
|
||||
i++;
|
||||
if (t0) n = i;
|
||||
if (t) n = i;
|
||||
fields++;
|
||||
}
|
||||
fields = fields_;
|
||||
|
@ -1445,6 +1424,7 @@ static void writeProp(OFile *fp, VObject *o)
|
|||
|
||||
void writeVObject_(OFile *fp, VObject *o)
|
||||
{
|
||||
int ilen = 0;
|
||||
if (NAME_OF(o)) {
|
||||
struct PreDefProp *pi;
|
||||
pi = lookupPropInfo(NAME_OF(o));
|
||||
|
@ -1467,39 +1447,40 @@ void writeVObject_(OFile *fp, VObject *o)
|
|||
}
|
||||
}
|
||||
|
||||
void writeVObject(PRFileDesc *fp, VObject *o)
|
||||
void writeVObject(nsOutputFileStream *fp, VObject *o)
|
||||
{
|
||||
OFile ofp;
|
||||
initOFile(&ofp,fp);
|
||||
writeVObject_(&ofp,o);
|
||||
}
|
||||
|
||||
void writeVObjectToFile(char *fname, VObject *o)
|
||||
void writeVObjectToFile(nsFileSpec *fname, VObject *o)
|
||||
{
|
||||
#if !defined(MOZADDRSTANDALONE)
|
||||
PRFileDesc *fp = PR_Open(fname, PR_WRONLY, 493);
|
||||
if (fp) {
|
||||
writeVObject(fp,o);
|
||||
PR_Close(fp);
|
||||
}
|
||||
nsOutputFileStream *fp = new nsOutputFileStream(*fname);
|
||||
|
||||
if (fp) {
|
||||
writeVObject(fp,o);
|
||||
fp->close();
|
||||
}
|
||||
#else
|
||||
PR_ASSERT (PR_FALSE);
|
||||
PR_ASSERT(FALSE);
|
||||
#endif
|
||||
}
|
||||
|
||||
void writeVObjectsToFile(char *fname, VObject *list)
|
||||
void writeVObjectsToFile(nsFileSpec *fname, VObject *list)
|
||||
{
|
||||
#if !defined(MOZADDRSTANDALONE)
|
||||
PRFileDesc *fp = PR_Open(fname,PR_WRONLY, 493);
|
||||
nsOutputFileStream *fp = new nsOutputFileStream(*fname);
|
||||
if (fp) {
|
||||
while (list) {
|
||||
writeVObject(fp,list);
|
||||
list = nextVObjectInList(list);
|
||||
}
|
||||
PR_Close(fp);
|
||||
fp->close();
|
||||
}
|
||||
#else
|
||||
PR_ASSERT (PR_FALSE);
|
||||
PR_ASSERT(FALSE);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -1513,7 +1494,8 @@ char* writeMemVObject(char *s, int *len, VObject *o)
|
|||
return ofp.s;
|
||||
}
|
||||
|
||||
char* writeMemVObjects(char *s, int *len, VObject *list)
|
||||
extern "C"
|
||||
char * writeMemoryVObjects(char *s, int *len, VObject *list, PRBool expandSpaces)
|
||||
{
|
||||
OFile ofp;
|
||||
initMemOFile(&ofp,s,len?*len:0);
|
||||
|
@ -1529,13 +1511,12 @@ char* writeMemVObjects(char *s, int *len, VObject *list)
|
|||
/*----------------------------------------------------------------------
|
||||
APIs to do fake Unicode stuff.
|
||||
----------------------------------------------------------------------*/
|
||||
extern "C"
|
||||
vwchar_t* fakeUnicode(const char *ps, int *bytes)
|
||||
{
|
||||
vwchar_t *r, *pw;
|
||||
int len = nsCRT::strlen(ps)+1;
|
||||
int len = strlen(ps)+1;
|
||||
|
||||
pw = r = (vwchar_t*)PR_Malloc(sizeof(vwchar_t)*len);
|
||||
pw = r = (vwchar_t*)PR_CALLOC(sizeof(vwchar_t)*len);
|
||||
if (bytes)
|
||||
*bytes = len * sizeof(vwchar_t);
|
||||
|
||||
|
@ -1564,7 +1545,7 @@ char* fakeCString(const vwchar_t *u)
|
|||
{
|
||||
char *s, *t;
|
||||
int len = uStrLen(u) + 1;
|
||||
t = s = (char*)PR_Malloc(len);
|
||||
t = s = (char*)PR_CALLOC(len);
|
||||
while (*u) {
|
||||
if (*u == (vwchar_t)0x2028)
|
||||
*t = '\n';
|
||||
|
@ -1584,7 +1565,7 @@ const char* lookupStr(const char *s)
|
|||
unsigned int h = hashStr(s);
|
||||
if ((t = strTbl[h]) != 0) {
|
||||
do {
|
||||
if (nsCRT::strcasecmp(t->s,s) == 0) {
|
||||
if (PL_strcasecmp(t->s,s) == 0) {
|
||||
t->refCnt++;
|
||||
return t->s;
|
||||
}
|
||||
|
@ -1595,23 +1576,3 @@ const char* lookupStr(const char *s)
|
|||
strTbl[h] = newStrItem(s,strTbl[h]);
|
||||
return s;
|
||||
}
|
||||
|
||||
#ifdef NS_DEBUG
|
||||
|
||||
void
|
||||
DumpProperties(VObject *o)
|
||||
{
|
||||
return;
|
||||
|
||||
VObjectIterator i;
|
||||
initPropIterator(&i,o);
|
||||
while (moreIteration(&i))
|
||||
{
|
||||
VObject *each = nextVObject(&i);
|
||||
printf("ID = %s Value = [%s]\n", each->id, fakeCString(vObjectUStringZValue(each)));
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* end of source file vobject.c */
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
/***************************************************************************
|
||||
(C) Copyright 1996 Apple Computer, Inc., AT&T Corp., International
|
||||
Business Machines Corporation and Siemens Rolm Communications Inc.
|
||||
|
@ -100,8 +99,6 @@ which accompanied this distribution.
|
|||
#ifndef __VOBJECT_H__
|
||||
#define __VOBJECT_H__ 1
|
||||
|
||||
#include "xp.h"
|
||||
|
||||
/*
|
||||
Unfortunately, on the Mac (and possibly other platforms) with our current, out-dated
|
||||
libraries (Plauger), |wchar_t| is defined incorrectly, which breaks vcards.
|
||||
|
@ -118,6 +115,7 @@ they will use an appropriately defined local type |vwchar_t|.
|
|||
typedef wchar_t vwchar_t;
|
||||
#endif
|
||||
|
||||
XP_BEGIN_PROTOS
|
||||
|
||||
#define VC7bitProp "7bit"
|
||||
#define VC8bitProp "8bit"
|
||||
|
@ -335,7 +333,7 @@ struct StrItem {
|
|||
};
|
||||
|
||||
typedef struct OFile {
|
||||
PRFileDesc *fp;
|
||||
nsOutputFileStream *fp;
|
||||
char *s;
|
||||
int len;
|
||||
int limit;
|
||||
|
@ -348,11 +346,10 @@ typedef struct VObjectIterator {
|
|||
VObject* next;
|
||||
} VObjectIterator;
|
||||
|
||||
|
||||
extern "C" VObject* newVObject(const char *id);
|
||||
VObject* newVObject(const char *id);
|
||||
void deleteVObject(VObject *p);
|
||||
extern "C" char* dupStr(const char *s, unsigned int size);
|
||||
extern "C" void deleteStr(const char *p);
|
||||
char* dupStr(const char *s, unsigned int size);
|
||||
extern "C" void deleteString(char *p);
|
||||
void unUseStr(const char *s);
|
||||
|
||||
void setVObjectName(VObject *o, const char* id);
|
||||
|
@ -363,63 +360,66 @@ void setVObjectUStringZValue_(VObject *o, const vwchar_t *s);
|
|||
void setVObjectIntegerValue(VObject *o, unsigned int i);
|
||||
void setVObjectLongValue(VObject *o, unsigned long l);
|
||||
void setVObjectAnyValue(VObject *o, void *t);
|
||||
extern "C" VObject* setValueWithSize(VObject *prop, void *val, unsigned int size);
|
||||
VObject* setValueWithSize(VObject *prop, void *val, unsigned int size);
|
||||
VObject* setValueWithSize_(VObject *prop, void *val, unsigned int size);
|
||||
|
||||
extern "C" const char* vObjectName(VObject *o);
|
||||
const char* vObjectName(VObject *o);
|
||||
const char* vObjectStringZValue(VObject *o);
|
||||
extern "C" const vwchar_t* vObjectUStringZValue(VObject *o);
|
||||
const vwchar_t* vObjectUStringZValue(VObject *o);
|
||||
unsigned int vObjectIntegerValue(VObject *o);
|
||||
unsigned long vObjectLongValue(VObject *o);
|
||||
extern "C" void* vObjectAnyValue(VObject *o);
|
||||
void* vObjectAnyValue(VObject *o);
|
||||
VObject* vObjectVObjectValue(VObject *o);
|
||||
void setVObjectVObjectValue(VObject *o, VObject *p);
|
||||
|
||||
VObject* addVObjectProp(VObject *o, VObject *p);
|
||||
extern "C" VObject* addProp(VObject *o, const char *id);
|
||||
VObject* addProp(VObject *o, const char *id);
|
||||
VObject* addProp_(VObject *o, const char *id);
|
||||
VObject* addPropValue(VObject *o, const char *p, const char *v);
|
||||
VObject* addPropSizedValue_(VObject *o, const char *p, const char *v, unsigned int size);
|
||||
VObject* addPropSizedValue(VObject *o, const char *p, const char *v, unsigned int size);
|
||||
VObject* addGroup(VObject *o, const char *g);
|
||||
extern "C" void addList(VObject **o, VObject *p);
|
||||
void addList(VObject **o, VObject *p);
|
||||
|
||||
extern "C" VObject* isAPropertyOf(VObject *o, const char *id);
|
||||
VObject* isAPropertyOf(VObject *o, const char *id);
|
||||
|
||||
extern "C" VObject* nextVObjectInList(VObject *o);
|
||||
extern "C" void initPropIterator(VObjectIterator *i, VObject *o);
|
||||
extern "C" int moreIteration(VObjectIterator *i);
|
||||
extern "C" VObject* nextVObject(VObjectIterator *i);
|
||||
VObject* nextVObjectInList(VObject *o);
|
||||
void initPropIterator(VObjectIterator *i, VObject *o);
|
||||
int moreIteration(VObjectIterator *i);
|
||||
VObject* nextVObject(VObjectIterator *i);
|
||||
|
||||
extern void printVObject(nsOutputFileStream *fp,VObject *o);
|
||||
void printVObject_(nsOutputFileStream *fp, VObject *o, int level);
|
||||
extern void writeVObject(nsOutputFileStream *fp, VObject *o);
|
||||
|
||||
extern void printVObject(PRFileDesc *fp,VObject *o);
|
||||
void printVObject_(PRFileDesc * fp, VObject *o, int level);
|
||||
extern void writeVObject(PRFileDesc * fp, VObject *o);
|
||||
void writeVObject_(OFile *fp, VObject *o);
|
||||
extern "C" char* writeMemVObject(char *s, int *len, VObject *o);
|
||||
extern "C" char* writeMemVObjects(char *s, int *len, VObject *list);
|
||||
char* writeMemVObject(char *s, int *len, VObject *o);
|
||||
extern "C" char* writeMemoryVObjects(char *s, int *len, VObject *list, PRBool expandSpaces);
|
||||
|
||||
const char* lookupStr(const char *s);
|
||||
|
||||
void cleanStrTbl();
|
||||
|
||||
extern "C" void cleanVObject(VObject *o);
|
||||
void cleanVObject(VObject *o);
|
||||
void cleanVObjects(VObject *list);
|
||||
|
||||
const char* lookupProp(const char* str);
|
||||
const char* lookupProp_(const char* str);
|
||||
|
||||
extern "C" vwchar_t* fakeUnicode(const char *ps, int *bytes);
|
||||
vwchar_t* fakeUnicode(const char *ps, int *bytes);
|
||||
int uStrLen(const vwchar_t *u);
|
||||
extern "C" char* fakeCString(const vwchar_t *u);
|
||||
char* fakeCString(const vwchar_t *u);
|
||||
|
||||
void printVObjectToFile(char *fname,VObject *o);
|
||||
void printVObjectsToFile(char *fname,VObject *list);
|
||||
void writeVObjectToFile(char *fname, VObject *o);
|
||||
void writeVObjectsToFile(char *fname, VObject *list);
|
||||
void printVObjectToFile(nsFileSpec *fname,VObject *o);
|
||||
void printVObjectsToFile(nsFileSpec *fname,VObject *list);
|
||||
void writeVObjectToFile(nsFileSpec *fname, VObject *o);
|
||||
void writeVObjectsToFile(nsFileSpec *fname, VObject *list);
|
||||
|
||||
#define MAXPROPNAMESIZE 256
|
||||
#define MAXMOZPROPNAMESIZE 16
|
||||
|
||||
XP_END_PROTOS
|
||||
|
||||
#endif /* __VOBJECT_H__ */
|
||||
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче