-rw-r--r-- | library/backend/vcc.y | 25 | ||||
-rw-r--r-- | library/backend/vcc_yacc.cpp | 29 | ||||
-rw-r--r-- | library/backend/vobject.cpp | 5 | ||||
-rw-r--r-- | library/backend/vobject_p.h | 4 |
4 files changed, 28 insertions, 35 deletions
diff --git a/library/backend/vcc.y b/library/backend/vcc.y index 4c79368..bec2955 100644 --- a/library/backend/vcc.y +++ b/library/backend/vcc.y @@ -432,25 +432,25 @@ static void enterValues(const char *value) }
deleteStr(value);
}
static void enterProps(const char *s)
{
curProp = addGroup(curObj,s);
deleteStr(s);
}
static void enterAttr(const char *s1, const char *s2)
{
- const char *p1, *p2;
+ const char *p1, *p2=0;
p1 = lookupProp_(s1);
if (s2) {
VObject *a;
p2 = lookupProp_(s2);
a = addProp(curProp,p1);
setVObjectStringZValue(a,p2);
}
else
addProp(curProp,p1);
if (qstricmp(p1,VCBase64Prop) == 0 || (s2 && qstricmp(p2,VCBase64Prop)==0))
lexPushMode(L_BASE64);
else if (qstricmp(p1,VCQuotedPrintableProp) == 0
@@ -804,77 +804,79 @@ void initLex(const char *inputstring, unsigned long inputlen, FILE *inputfile) }
static void finiLex() {
free(lexBuf.strs);
}
/*-----------------------------------*/
/* This parses and converts the base64 format for binary encoding into
* a decoded buffer (allocated with new). See RFC 1521.
*/
-static char * lexGetDataFromBase64()
+static int lexGetDataFromBase64()
{
unsigned long bytesLen = 0, bytesMax = 0;
int quadIx = 0, pad = 0;
unsigned long trip = 0;
unsigned char b;
int c;
unsigned char *bytes = NULL;
unsigned char *oldBytes = NULL;
DBG_(("db: lexGetDataFromBase64\n"));
while (1) {
c = lexGetc();
+ lexSkipWhite();
if (c == '\n') {
++mime_lineNum;
if (lexLookahead() == '\n') {
/* a '\n' character by itself means end of data */
break;
}
else continue; /* ignore '\n' */
}
else {
if ((c >= 'A') && (c <= 'Z'))
b = (unsigned char)(c - 'A');
else if ((c >= 'a') && (c <= 'z'))
b = (unsigned char)(c - 'a') + 26;
else if ((c >= '0') && (c <= '9'))
b = (unsigned char)(c - '0') + 52;
else if (c == '+')
b = 62;
else if (c == '/')
b = 63;
else if (c == '=') {
b = 0;
pad++;
- } else if ((c == ' ') || (c == '\t')) {
- continue;
} else { /* error condition */
if (bytes) free(bytes);
else if (oldBytes) free(oldBytes);
// error recovery: skip until 2 adjacent newlines.
DBG_(("db: invalid character 0x%x '%c'\n", c,c));
if (c != EOF) {
c = lexGetc();
while (c != EOF) {
- if (c == '\n' && lexLookahead() == '\n') {
+ if (c == '\n') {
+ lexSkipWhite();
+ if(lexLookahead() == '\n') {
++mime_lineNum;
break;
}
+ }
c = lexGetc();
}
}
- return NULL;
+ return c != EOF;
}
trip = (trip << 6) | b;
if (++quadIx == 4) {
unsigned char outBytes[3];
int numOut;
int i;
for (i = 0; i < 3; i++) {
outBytes[2-i] = (unsigned char)(trip & 0xFF);
trip >>= 8;
}
numOut = 3 - pad;
if (bytesLen + numOut > bytesMax) {
@@ -902,25 +904,25 @@ static char * lexGetDataFromBase64() } /* while */
DBG_(("db: bytesLen = %d\n", bytesLen));
/* kludge: all this won't be necessary if we have tree form
representation */
if (bytes) {
setValueWithSize(curProp,bytes,(unsigned int)bytesLen);
free(bytes);
}
else if (oldBytes) {
setValueWithSize(curProp,oldBytes,(unsigned int)bytesLen);
free(oldBytes);
}
- return 0;
+ return bytesLen;
}
static int match_begin_end_name(int end) {
int token;
lexSkipWhite();
if (lexLookahead() != ':') return ID;
lexSkipLookahead();
lexSkipWhite();
token = match_begin_name(end);
if (token == ID) {
lexPushLookaheadc(':');
DBG_(("db: ID '%s'\n", yylval.str));
@@ -933,25 +935,25 @@ static int match_begin_end_name(int end) { return token;
}
return 0;
}
static char* lexGetQuotedPrintable()
{
int c;
lexSkipWhite();
c = lexLookahead();
lexClearToken();
- while (c != EOF && c != ';') {
+ while (c != EOF && (c != ';' || !fieldedProp)) {
if (c == '\n') {
// break, leave '\n' on remaining chars.
break;
} else if (c == '=') {
int cur = 0;
int next;
lexSkipLookahead(); // skip '='
next = lexLookahead();
if (next == '\n') {
// skip and only skip the \n
@@ -1023,29 +1025,26 @@ static int yylex() { lexSkipLookahead();
c = lexLookahead();
++mime_lineNum;
}
DBG_(("db: LINESEP\n"));
return LINESEP;
}
else {
char *p = 0;
lexPushLookaheadc(c);
if (lexWithinMode(L_BASE64)) {
/* get each char and convert to bin on the fly... */
- p = lexGetDataFromBase64();
-#if 0 - yylval.str = p;
- return STRING;
-#endif + yylval.str = NULL;
+ return lexGetDataFromBase64() ? STRING : 0;
}
else if (lexWithinMode(L_QUOTED_PRINTABLE)) {
p = lexGetQuotedPrintable();
}
else {
#ifdef _SUPPORT_LINE_FOLDING
p = lexGet1Value();
#else
p = lexGetStrUntil(";\n");
#endif
}
if (p) {
diff --git a/library/backend/vcc_yacc.cpp b/library/backend/vcc_yacc.cpp index 5f53aef..4006bc2 100644 --- a/library/backend/vcc_yacc.cpp +++ b/library/backend/vcc_yacc.cpp @@ -452,25 +452,25 @@ static void enterValues(const char *value) }
deleteStr(value);
}
static void enterProps(const char *s)
{
curProp = addGroup(curObj,s);
deleteStr(s);
}
static void enterAttr(const char *s1, const char *s2)
{
- const char *p1, *p2;
+ const char *p1, *p2=0;
p1 = lookupProp_(s1);
if (s2) {
VObject *a;
p2 = lookupProp_(s2);
a = addProp(curProp,p1);
setVObjectStringZValue(a,p2);
}
else
addProp(curProp,p1);
if (qstricmp(p1,VCBase64Prop) == 0 || (s2 && qstricmp(p2,VCBase64Prop)==0))
lexPushMode(L_BASE64);
else if (qstricmp(p1,VCQuotedPrintableProp) == 0
@@ -824,77 +824,79 @@ void initLex(const char *inputstring, unsigned long inputlen, FILE *inputfile) }
static void finiLex() {
free(lexBuf.strs);
}
/*-----------------------------------*/
/* This parses and converts the base64 format for binary encoding into
* a decoded buffer (allocated with new). See RFC 1521.
*/
-static char * lexGetDataFromBase64()
+static int lexGetDataFromBase64()
{
unsigned long bytesLen = 0, bytesMax = 0;
int quadIx = 0, pad = 0;
unsigned long trip = 0;
unsigned char b;
int c;
unsigned char *bytes = NULL;
unsigned char *oldBytes = NULL;
DBG_(("db: lexGetDataFromBase64\n"));
while (1) {
c = lexGetc();
+ lexSkipWhite();
if (c == '\n') {
++mime_lineNum;
if (lexLookahead() == '\n') {
/* a '\n' character by itself means end of data */
break;
}
else continue; /* ignore '\n' */
}
else {
if ((c >= 'A') && (c <= 'Z'))
b = (unsigned char)(c - 'A');
else if ((c >= 'a') && (c <= 'z'))
b = (unsigned char)(c - 'a') + 26;
else if ((c >= '0') && (c <= '9'))
b = (unsigned char)(c - '0') + 52;
else if (c == '+')
b = 62;
else if (c == '/')
b = 63;
else if (c == '=') {
b = 0;
pad++;
- } else if ((c == ' ') || (c == '\t')) {
- continue;
} else { /* error condition */
if (bytes) free(bytes);
else if (oldBytes) free(oldBytes);
// error recovery: skip until 2 adjacent newlines.
DBG_(("db: invalid character 0x%x '%c'\n", c,c));
if (c != EOF) {
c = lexGetc();
while (c != EOF) {
- if (c == '\n' && lexLookahead() == '\n') {
+ if (c == '\n') {
+ lexSkipWhite();
+ if(lexLookahead() == '\n') {
++mime_lineNum;
break;
}
+ }
c = lexGetc();
}
}
- return NULL;
+ return c != EOF;
}
trip = (trip << 6) | b;
if (++quadIx == 4) {
unsigned char outBytes[3];
int numOut;
int i;
for (i = 0; i < 3; i++) {
outBytes[2-i] = (unsigned char)(trip & 0xFF);
trip >>= 8;
}
numOut = 3 - pad;
if (bytesLen + numOut > bytesMax) {
@@ -922,25 +924,25 @@ static char * lexGetDataFromBase64() } /* while */
DBG_(("db: bytesLen = %d\n", bytesLen));
/* kludge: all this won't be necessary if we have tree form
representation */
if (bytes) {
setValueWithSize(curProp,bytes,(unsigned int)bytesLen);
free(bytes);
}
else if (oldBytes) {
setValueWithSize(curProp,oldBytes,(unsigned int)bytesLen);
free(oldBytes);
}
- return 0;
+ return bytesLen;
}
static int match_begin_end_name(int end) {
int token;
lexSkipWhite();
if (lexLookahead() != ':') return ID;
lexSkipLookahead();
lexSkipWhite();
token = match_begin_name(end);
if (token == ID) {
lexPushLookaheadc(':');
DBG_(("db: ID '%s'\n", yylval.str));
@@ -953,25 +955,25 @@ static int match_begin_end_name(int end) { return token;
}
return 0;
}
static char* lexGetQuotedPrintable()
{
int c;
lexSkipWhite();
c = lexLookahead();
lexClearToken();
- while (c != EOF && c != ';') {
+ while (c != EOF && (c != ';' || !fieldedProp)) {
if (c == '\n') {
// break, leave '\n' on remaining chars.
break;
} else if (c == '=') {
int cur = 0;
int next;
lexSkipLookahead(); // skip '='
next = lexLookahead();
if (next == '\n') {
// skip and only skip the \n
@@ -1043,29 +1045,26 @@ static int yylex() { lexSkipLookahead();
c = lexLookahead();
++mime_lineNum;
}
DBG_(("db: LINESEP\n"));
return LINESEP;
}
else {
char *p = 0;
lexPushLookaheadc(c);
if (lexWithinMode(L_BASE64)) {
/* get each char and convert to bin on the fly... */
- p = lexGetDataFromBase64();
-#if 0 - yylval.str = p;
- return STRING;
-#endif + yylval.str = NULL;
+ return lexGetDataFromBase64() ? STRING : 0;
}
else if (lexWithinMode(L_QUOTED_PRINTABLE)) {
p = lexGetQuotedPrintable();
}
else {
#ifdef _SUPPORT_LINE_FOLDING
p = lexGet1Value();
#else
p = lexGetStrUntil(";\n");
#endif
}
if (p) {
@@ -1229,25 +1228,25 @@ void mime_error(char *s) sprintf(msg,"%s at line %d", s, mime_lineNum);
mimeErrorHandler(msg);
}
}
void mime_error_(char *s)
{
if (mimeErrorHandler) {
mimeErrorHandler(s);
}
}
-#line 1240 "y.tab.c" +#line 1241 "y.tab.c" #define YYABORT goto yyabort #define YYREJECT goto yyabort #define YYACCEPT goto yyaccept #define YYERROR goto yyerrlab int #if defined(__STDC__) yyparse(void) #else yyparse() #endif { register int yym, yyn, yystate; @@ -1529,25 +1528,25 @@ case 44: {
lexPushMode(L_VTODO);
if (!pushVObject(VCTodoProp)) YYERROR;
} break; case 45: #line 376 "backend/vcc.y" {
lexPopMode(0);
popVObject();
} break; -#line 1540 "y.tab.c" +#line 1541 "y.tab.c" } yyssp -= yym; yystate = *yyssp; yyvsp -= yym; yym = yylhs[yyn]; if (yystate == 0 && yym == 0) { #if YYDEBUG if (yydebug) printf("%sdebug: after reduction, shifting from state 0 to\ state %d\n", YYPREFIX, YYFINAL); #endif diff --git a/library/backend/vobject.cpp b/library/backend/vobject.cpp index 4c8de70..9263c3a 100644 --- a/library/backend/vobject.cpp +++ b/library/backend/vobject.cpp @@ -33,27 +33,25 @@ PURPOSE. The software is provided with RESTRICTED RIGHTS. Use, duplication, or disclosure by the government are subject to restrictions set forth in 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. */ -#ifndef MWERKS -#include <malloc.h> -#endif +#include <stdlib.h> #include <qtopia/config.h> #include "vobject_p.h" #include "qfiledirect_p.h" #include <string.h> #include <stdio.h> #include <fcntl.h> //#include <io.h> #define NAME_OF(o) o->id #define VALUE_TYPE(o) o->valType @@ -748,25 +746,24 @@ static struct PreDefProp propNames[] = { { VCPostalCodeProp, 0, 0, 0 }, { VCPostalProp, 0, 0, 0 }, { VCPowerShareProp, 0, 0, 0 }, { VCPreferredProp, 0, 0, 0 }, { VCPriorityProp, 0, 0, 0 }, { VCProcedureNameProp, 0, 0, 0 }, { VCProdIdProp, 0, 0, 0 }, { VCProdigyProp, 0, 0, 0 }, { VCPronunciationProp, 0, 0, 0 }, { VCPSProp, 0, 0, 0 }, { VCPublicKeyProp, 0, 0, 0 }, { VCQPProp, VCQuotedPrintableProp, 0, 0 }, - { VCQPProp, VCBase64Prop, 0, 0 }, { VCQuickTimeProp, 0, 0, 0 }, { VCQuotedPrintableProp, 0, 0, 0 }, { VCRDateProp, 0, 0, 0 }, { VCRegionProp, 0, 0, 0 }, { VCRelatedToProp, 0, 0, 0 }, { VCRepeatCountProp, 0, 0, 0 }, { VCResourcesProp, 0, 0, 0 }, { VCRNumProp, 0, 0, 0 }, { VCRoleProp, 0, 0, 0 }, { VCRRuleProp, 0, 0, 0 }, { VCRSVPProp, 0, 0, 0 }, { VCRunTimeProp, 0, 0, 0 }, diff --git a/library/backend/vobject_p.h b/library/backend/vobject_p.h index f969898..3c9d0d3 100644 --- a/library/backend/vobject_p.h +++ b/library/backend/vobject_p.h @@ -90,27 +90,25 @@ are globally unique IDs which can be used to generate clipboard format ID's as per the requirements of a specific platform. For example, in Windows they are used as the parameter in a call to RegisterClipboardFormat. For example: CLIPFORMAT foo = RegisterClipboardFormat(vCardClipboardFormat); */ #define vCardMimeType "text/x-vCard" #define vCalendarMimeType "text/x-vCalendar" #undef DLLEXPORT - //#include <qtopia/qpeglobal.h> -#include <qglobal.h> - +#include <qtopia/global.h> #if defined(QTOPIA_MAKEDLL) #define DLLEXPORT(t) __declspec(dllexport) t #elif defined(QTOPIA_DLL) #define DLLEXPORT(t) __declspec(dllimport) t #else #define DLLEXPORT(t) t #endif #ifndef FALSE #define FALSE 0 #endif #ifndef TRUE |