summaryrefslogtreecommitdiff
path: root/library/backend
authorzecke <zecke>2003-08-29 18:02:09 (UTC)
committer zecke <zecke>2003-08-29 18:02:09 (UTC)
commit885c645ee48ae53467e244521c011c73bc106afb (patch) (side-by-side diff)
tree9024be25b2503788d3aa77b7a86b89e543cdd865 /library/backend
parented6da2303a8fabec50991365914f0e4d20a21ea6 (diff)
downloadopie-885c645ee48ae53467e244521c011c73bc106afb.zip
opie-885c645ee48ae53467e244521c011c73bc106afb.tar.gz
opie-885c645ee48ae53467e244521c011c73bc106afb.tar.bz2
Fixes for base64 decoding and encoding of vCard
Diffstat (limited to 'library/backend') (more/less context) (ignore whitespace changes)
-rw-r--r--library/backend/vcc.y29
-rw-r--r--library/backend/vcc_yacc.cpp33
-rw-r--r--library/backend/vobject.cpp5
-rw-r--r--library/backend/vobject_p.h4
4 files changed, 32 insertions, 39 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
@@ -441,7 +441,7 @@ static void enterProps(const char *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;
@@ -813,7 +813,7 @@ static void finiLex() {
/* 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;
@@ -826,6 +826,7 @@ static char * lexGetDataFromBase64()
DBG_(("db: lexGetDataFromBase64\n"));
while (1) {
c = lexGetc();
+ lexSkipWhite();
if (c == '\n') {
++mime_lineNum;
if (lexLookahead() == '\n') {
@@ -848,8 +849,6 @@ static char * lexGetDataFromBase64()
else if (c == '=') {
b = 0;
pad++;
- } else if ((c == ' ') || (c == '\t')) {
- continue;
} else { /* error condition */
if (bytes) free(bytes);
else if (oldBytes) free(oldBytes);
@@ -858,14 +857,17 @@ static char * lexGetDataFromBase64()
if (c != EOF) {
c = lexGetc();
while (c != EOF) {
- if (c == '\n' && lexLookahead() == '\n') {
- ++mime_lineNum;
- break;
+ if (c == '\n') {
+ lexSkipWhite();
+ if(lexLookahead() == '\n') {
+ ++mime_lineNum;
+ break;
+ }
}
c = lexGetc();
}
}
- return NULL;
+ return c != EOF;
}
trip = (trip << 6) | b;
if (++quadIx == 4) {
@@ -911,7 +913,7 @@ static char * lexGetDataFromBase64()
setValueWithSize(curProp,oldBytes,(unsigned int)bytesLen);
free(oldBytes);
}
- return 0;
+ return bytesLen;
}
static int match_begin_end_name(int end) {
@@ -942,7 +944,7 @@ static char* lexGetQuotedPrintable()
c = lexLookahead();
lexClearToken();
- while (c != EOF && c != ';') {
+ while (c != EOF && (c != ';' || !fieldedProp)) {
if (c == '\n') {
// break, leave '\n' on remaining chars.
break;
@@ -1032,11 +1034,8 @@ static int yylex() {
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();
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
@@ -461,7 +461,7 @@ static void enterProps(const char *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;
@@ -833,7 +833,7 @@ static void finiLex() {
/* 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;
@@ -846,6 +846,7 @@ static char * lexGetDataFromBase64()
DBG_(("db: lexGetDataFromBase64\n"));
while (1) {
c = lexGetc();
+ lexSkipWhite();
if (c == '\n') {
++mime_lineNum;
if (lexLookahead() == '\n') {
@@ -868,8 +869,6 @@ static char * lexGetDataFromBase64()
else if (c == '=') {
b = 0;
pad++;
- } else if ((c == ' ') || (c == '\t')) {
- continue;
} else { /* error condition */
if (bytes) free(bytes);
else if (oldBytes) free(oldBytes);
@@ -878,14 +877,17 @@ static char * lexGetDataFromBase64()
if (c != EOF) {
c = lexGetc();
while (c != EOF) {
- if (c == '\n' && lexLookahead() == '\n') {
- ++mime_lineNum;
- break;
+ if (c == '\n') {
+ lexSkipWhite();
+ if(lexLookahead() == '\n') {
+ ++mime_lineNum;
+ break;
+ }
}
c = lexGetc();
}
}
- return NULL;
+ return c != EOF;
}
trip = (trip << 6) | b;
if (++quadIx == 4) {
@@ -931,7 +933,7 @@ static char * lexGetDataFromBase64()
setValueWithSize(curProp,oldBytes,(unsigned int)bytesLen);
free(oldBytes);
}
- return 0;
+ return bytesLen;
}
static int match_begin_end_name(int end) {
@@ -962,7 +964,7 @@ static char* lexGetQuotedPrintable()
c = lexLookahead();
lexClearToken();
- while (c != EOF && c != ';') {
+ while (c != EOF && (c != ';' || !fieldedProp)) {
if (c == '\n') {
// break, leave '\n' on remaining chars.
break;
@@ -1052,11 +1054,8 @@ static int yylex() {
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();
@@ -1238,7 +1237,7 @@ void mime_error_(char *s)
}
}
-#line 1240 "y.tab.c"
+#line 1241 "y.tab.c"
#define YYABORT goto yyabort
#define YYREJECT goto yyabort
#define YYACCEPT goto yyaccept
@@ -1538,7 +1537,7 @@ case 45:
popVObject();
}
break;
-#line 1540 "y.tab.c"
+#line 1541 "y.tab.c"
}
yyssp -= yym;
yystate = *yyssp;
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
@@ -42,9 +42,7 @@ DFARS 252.227-7013 or 48 CFR 52.227-19, as applicable.
* 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"
@@ -757,7 +755,6 @@ static struct PreDefProp propNames[] = {
{ 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 },
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
@@ -99,9 +99,7 @@ For example:
#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)