summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--library/backend/vcc.y22
-rw-r--r--library/backend/vcc_yacc.cpp127
-rw-r--r--library/backend/vobject.cpp163
-rw-r--r--library/backend/vobject_p.h29
4 files changed, 189 insertions, 152 deletions
diff --git a/library/backend/vcc.y b/library/backend/vcc.y
index 6781312..94a8fea 100644
--- a/library/backend/vcc.y
+++ b/library/backend/vcc.y
@@ -124,3 +124,3 @@ DFARS 252.227-7013 or 48 CFR 52.227-19, as applicable.
//#else
-#include <qtopia/private/vobject_p.h>
+#include "vobject_p.h"
//#endif
@@ -725,3 +725,3 @@ static char* lexGet1Value() {
lexClearToken();
- while (c != EOF && c != ';') {
+ while (c != EOF && (c != ';' || !fieldedProp)) {
if (c == '\\' ) {
@@ -730,7 +730,13 @@ static char* lexGet1Value() {
a = lexLookahead();
- if ( a != ';' ) {
- lexAppendc('\\');
- } else {
+ if ( a == ';' ) {
lexAppendc( ';' );
lexSkipLookahead();
+ } else if ( a == '\n' ) {
+ lexAppendc( '\n' );
+ lexSkipLookahead();
+ } else if ( a == '\\' ) {
+ lexAppendc( '\\' );
+ lexSkipLookahead();
+ } else {
+ lexAppendc('\\');
}
@@ -963,2 +969,3 @@ static char* lexGetQuotedPrintable()
// should probably spit an error here
+ lexSkipLookahead();
c = lexLookahead();
@@ -980,2 +987,3 @@ static char* lexGetQuotedPrintable()
// should probably spit an error here
+ lexSkipLookahead();
c = lexLookahead();
@@ -1002,3 +1010,3 @@ static int yylex() {
int c = lexGetc();
- if (c == ';') {
+ if (c == ';' && fieldedProp) {
DBG_(("db: SEMICOLON\n"));
@@ -1056,2 +1064,3 @@ static int yylex() {
/* ignoring linesep immediately after colon. */
+ /* I don't see this in the spec, and it breaks null values -- WA
c = lexLookahead();
@@ -1062,2 +1071,3 @@ static int yylex() {
}
+ */
DBG_(("db: COLON\n"));
diff --git a/library/backend/vcc_yacc.cpp b/library/backend/vcc_yacc.cpp
index b2b0c14..5649522 100644
--- a/library/backend/vcc_yacc.cpp
+++ b/library/backend/vcc_yacc.cpp
@@ -160,3 +160,3 @@ DFARS 252.227-7013 or 48 CFR 52.227-19, as applicable.
/*#else */
-#include <qtopia/private/vobject_p.h>
+#include "vobject_p.h"
/*#endif */
@@ -745,3 +745,3 @@ static char* lexGet1Value() {
lexClearToken();
- while (c != EOF && c != ';') {
+ while (c != EOF && (c != ';' || !fieldedProp)) {
if (c == '\\' ) {
@@ -750,7 +750,13 @@ static char* lexGet1Value() {
a = lexLookahead();
- if ( a != ';' ) {
- lexAppendc('\\');
- } else {
+ if ( a == ';' ) {
lexAppendc( ';' );
lexSkipLookahead();
+ } else if ( a == '\n' ) {
+ lexAppendc( '\n' );
+ lexSkipLookahead();
+ } else if ( a == '\\' ) {
+ lexAppendc( '\\' );
+ lexSkipLookahead();
+ } else {
+ lexAppendc('\\');
}
@@ -953,56 +959,67 @@ static char* lexGetQuotedPrintable()
{
- int cur;
-
+ int c;
+ lexSkipWhite();
+ c = lexLookahead();
lexClearToken();
- do {
- cur = lexGetc();
- switch (cur) {
- case '=': {
- int c = 0;
- int next[2];
- int i;
- for (i = 0; i < 2; i++) {
- next[i] = lexGetc();
- if (next[i] >= '0' && next[i] <= '9')
- c = c * 16 + next[i] - '0';
- else if (next[i] >= 'A' && next[i] <= 'F')
- c = c * 16 + next[i] - 'A' + 10;
- else
+
+ while (c != EOF && c != ';') {
+ 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
+ lexSkipLookahead();
+ c = lexLookahead();
+ ++mime_lineNum; // aid in error reporting
+ continue;
+ } else if (next >= '0' && next <= '9') {
+ cur = next - '0';
+ } else if (next >= 'A' && next <= 'F') {
+ cur = next - 'A' + 10;
+ } else {
+ // we have been sent buggy stuff. doesn't matter
+ // what we do so long as we keep going.
+ // should probably spit an error here
+ lexSkipLookahead();
+ c = lexLookahead();
+ continue;
}
- if (i == 0) {
- /* single '=' follow by LINESEP is continuation sign? */
- if (next[0] == '\n') {
- ++mime_lineNum;
- }
- else {
- lexPushLookaheadc('=');
- goto EndString;
- }
+
+ lexSkipLookahead(); // skip A-Z0-9
+ next = lexLookahead();
+
+ cur = cur * 16;
+ // this time really just expecting 0-9A-F
+ if (next >= '0' && next <= '9') {
+ cur += next - '0';
+ } else if (next >= 'A' && next <= 'F') {
+ cur += next - 'A' + 10;
+ } else {
+ // we have been sent buggy stuff. doesn't matter
+ // what we do so long as we keep going.
+ // should probably spit an error here
+ lexSkipLookahead();
+ c = lexLookahead();
+ continue;
}
- else if (i == 1) {
- lexPushLookaheadc(next[1]);
- lexPushLookaheadc(next[0]);
- lexAppendc('=');
+
+ // got a valid escaped =. append it.
+ lexSkipLookahead(); // skip second 0-9A-F
+ lexAppendc(cur);
} else {
- lexAppendc(c);
+ lexSkipLookahead(); // skip whatever we just read.
+ lexAppendc(c); // and append it.
}
- break;
- } /* '=' */
- case '\n': {
- lexPushLookaheadc('\n');
- goto EndString;
+ c = lexLookahead();
}
- case (int)EOF:
- break;
- default:
- lexAppendc(cur);
- break;
- } /* switch */
- } while (cur != (int)EOF);
-
-EndString:
lexAppendc(0);
- return lexStr();
- } /* LexQuotedPrintable */
+ return c==EOF?0:lexStr();
+}
@@ -1013,3 +1030,3 @@ static int yylex() {
int c = lexGetc();
- if (c == ';') {
+ if (c == ';' && fieldedProp) {
DBG_(("db: SEMICOLON\n"));
@@ -1067,2 +1084,3 @@ static int yylex() {
/* ignoring linesep immediately after colon. */
+ /* I don't see this in the spec, and it breaks null values -- WA
c = lexLookahead();
@@ -1073,2 +1091,3 @@ static int yylex() {
}
+ */
DBG_(("db: COLON\n"));
@@ -1219,3 +1238,3 @@ void mime_error_(char *s)
-#line 1221 "y.tab.c"
+#line 1240 "y.tab.c"
#define YYABORT goto yyabort
@@ -1519,3 +1538,3 @@ case 45:
break;
-#line 1521 "y.tab.c"
+#line 1540 "y.tab.c"
}
diff --git a/library/backend/vobject.cpp b/library/backend/vobject.cpp
index 2c5b577..b6d17dc 100644
--- a/library/backend/vobject.cpp
+++ b/library/backend/vobject.cpp
@@ -48,4 +48,5 @@ DFARS 252.227-7013 or 48 CFR 52.227-19, as applicable.
-#include <qtopia/private/vobject_p.h>
-#include <qtopia/private/qfiledirect_p.h>
+#include <qtopia/config.h>
+#include "vobject_p.h"
+#include "qfiledirect_p.h"
#include <string.h>
@@ -64,2 +65,6 @@ DFARS 252.227-7013 or 48 CFR 52.227-19, as applicable.
+static char vobj_cs[10];
+static enum { EightBit, QuotedPrintable, Base64 } vobj_enc=EightBit;
+static const char *vobj_enc_s=0;
+
typedef union ValueItem {
@@ -88,3 +93,3 @@ struct StrItem {
-const char** fieldedProp;
+DLLEXPORT(const char**) fieldedProp;
@@ -955,2 +960,13 @@ static void appendsOFile(OFile *fp, const char *s)
+static void appendsOFileEncCs(OFile *fp)
+{
+ if ( vobj_enc_s ) {
+ appendsOFile(fp, ";" VCEncodingProp "=");
+ appendsOFile(fp, vobj_enc_s);
+ }
+ appendsOFile(fp, ";" VCCharSetProp "=");
+ appendsOFile(fp, vobj_cs);
+}
+
+
static void initOFile(OFile *fp, FILE *ofp)
@@ -1007,3 +1023,3 @@ static int writeBase64(OFile *fp, unsigned char *s, long len)
-static const char *replaceChar(unsigned char c)
+static const char *qpReplaceChar(unsigned char c)
{
@@ -1012,17 +1028,7 @@ static const char *replaceChar(unsigned char c)
} else if (
- (c >= 'A' && c <= 'Z')
- ||
- (c >= 'a' && c <= 'z')
+ // RFC 1521
+ (c >= 32 && c <= 60) // Note: " " not allowed at EOL
||
- (c >= '0' && c <= '9')
- ||
- (c >= '\'' && c <= ')')
- ||
- (c >= '+' && c <= '-')
- ||
- (c == '/')
- ||
- (c == '?')
- ||
- (c == ' '))
+ (c >= 62 && c <= 126)
+ )
{
@@ -1031,13 +1037,2 @@ static const char *replaceChar(unsigned char c)
-#warning "Bug-Workaround must be fixed !"
- // IF THIS FUNCTION RETURNES TRUE, THE DATA IS EXPORTED
- // AS QUOTED PRINTABLE.
- // BUT THE PARSER IS UNABLE TO IMPORT THIS, THEREFORE
- // I DECIDED TO DISABLE IT UNTIL TROLLTECH FIXES THIS BUG
- // SEE ALSO includesUnprintable(VObject *o)
- // (se)
-
- return 0;
-
-#if 0
static char trans[4];
@@ -1059,6 +1054,5 @@ static const char *replaceChar(unsigned char c)
return trans;
-#endif
}
-static void writeQPString(OFile *fp, const char *s)
+static void writeEncString(OFile *fp, const char *s, bool nosemi)
{
@@ -1081,10 +1075,32 @@ static void writeQPString(OFile *fp, const char *s)
const char *p = s;
+ switch ( vobj_enc ) {
+ case EightBit:
+ while (*p) {
+ if ( *p == '\n' || nosemi && ( *p == '\\' || *p == ';' ) )
+ appendcOFile(fp, '\\');
+ appendcOFile(fp, *p);
+ p++;
+ }
+ break;
+ case QuotedPrintable:
while (*p) {
- const char *rep = replaceChar(*p);
+ const char *rep = qpReplaceChar(*p);
if (rep)
appendsOFile(fp, rep);
+ else if ( *p == ';' && nosemi )
+ appendsOFile(fp, "=3B");
+ else if ( *p == ' ' ) {
+ if ( !p[1] || p[1] == '\n' ) // RFC 1521
+ appendsOFile(fp, "=20");
else
appendcOFile(fp, *p);
+ } else
+ appendcOFile(fp, *p);
p++;
}
+ break;
+ case Base64:
+ writeBase64(fp, (unsigned char*)p, strlen(p));
+ break;
+ }
}
@@ -1093,12 +1109,2 @@ static bool includesUnprintable(VObject *o)
{
-
-#if 0
-
- // IF THIS FUNCTION RETURNES TRUE, THE DATA IS EXPORTED
- // AS QUOTED PRINTABLE.
- // BUT THE PARSER IS UNABLE TO IMPORT THIS, THEREFORE
- // I DECIDED TO DISABLE IT UNTIL TROLLTECH FIXES THIS BUG
- // SEE ALSO *replaceChar(unsigned char c)
- // (se)
-
if (o) {
@@ -1108,3 +1114,4 @@ static bool includesUnprintable(VObject *o)
while (*p) {
- if (replaceChar(*p))
+ if (*p==' ' && (!p[1] || p[1]=='\n') // RFC 1521: spaces at ends need quoting
+ || qpReplaceChar(*p) )
return TRUE;
@@ -1115,6 +1122,2 @@ static bool includesUnprintable(VObject *o)
}
-
-#endif
-#warning "Bug-Workaround must be fixed !"
-
return FALSE;
@@ -1124,3 +1127,3 @@ static void writeVObject_(OFile *fp, VObject *o);
-static void writeValue(OFile *fp, VObject *o, unsigned long size)
+static void writeValue(OFile *fp, VObject *o, unsigned long size, bool nosemi)
{
@@ -1129,3 +1132,3 @@ static void writeValue(OFile *fp, VObject *o, unsigned long size)
case VCVT_STRINGZ: {
- writeQPString(fp, STRINGZ_VALUE_OF(o));
+ writeEncString(fp, STRINGZ_VALUE_OF(o), nosemi);
break;
@@ -1162,14 +1165,12 @@ static void writeAttrValue(OFile *fp, VObject *o)
if (pi && ((pi->flags & PD_INTERNAL) != 0)) return;
- if ( includesUnprintable(o) ) {
- appendsOFile(fp, ";" VCEncodingProp "=" VCQuotedPrintableProp);
- appendsOFile(fp, ";" VCCharSetProp "=" "UTF-8");
- }
+ if ( includesUnprintable(o) )
+ appendsOFileEncCs(fp);
appendcOFile(fp,';');
appendsOFile(fp,NAME_OF(o));
- }
- else
+ } else {
appendcOFile(fp,';');
+ }
if (VALUE_TYPE(o)) {
appendcOFile(fp,'=');
- writeValue(fp,o,0);
+ writeValue(fp,o,0,TRUE);
}
@@ -1237,6 +1238,4 @@ static void writeProp(OFile *fp, VObject *o)
fields = fields_;
- if (!printable) {
- appendsOFile(fp, ";" VCEncodingProp "=" VCQuotedPrintableProp);
- appendsOFile(fp, ";" VCCharSetProp "=" "UTF-8");
- }
+ if (!printable)
+ appendsOFileEncCs(fp);
appendcOFile(fp,':');
@@ -1250,3 +1249,3 @@ static void writeProp(OFile *fp, VObject *o)
for (i=0;i<n;i++) {
- writeValue(fp,isAPropertyOf(o,*fields),0);
+ writeValue(fp,isAPropertyOf(o,*fields),0,TRUE);
fields++;
@@ -1259,6 +1258,4 @@ static void writeProp(OFile *fp, VObject *o)
if (VALUE_TYPE(o)) {
- if ( includesUnprintable(o) ) {
- appendsOFile(fp, ";" VCEncodingProp "=" VCQuotedPrintableProp);
- appendsOFile(fp, ";" VCCharSetProp "=" "UTF-8");
- }
+ if ( includesUnprintable(o) )
+ appendsOFileEncCs(fp);
unsigned long size = 0;
@@ -1267,3 +1264,3 @@ static void writeProp(OFile *fp, VObject *o)
appendcOFile(fp,':');
- writeValue(fp,o,size);
+ writeValue(fp,o,size,FALSE);
}
@@ -1297,4 +1294,31 @@ static void writeVObject_(OFile *fp, VObject *o)
+static void initVObjectEncoding()
+{
+ Config pimConfig( "Beam" );
+ pimConfig.setGroup("Send");
+ Config devcfg(pimConfig.readEntry("DeviceConfig"),Config::File);
+ QString enc = "QP";
+ QString cs = "UTF-8";
+ if ( devcfg.isValid() ) {
+ devcfg.setGroup("Send");
+ enc = devcfg.readEntry("Encoding","QP");
+ cs = devcfg.readEntry("CharSet","UTF-8");
+ }
+ strncpy(vobj_cs,cs.latin1(),10);
+ if ( enc == "QP" ) {
+ vobj_enc = QuotedPrintable;
+ vobj_enc_s = VCQuotedPrintableProp;
+ } else if ( enc == "B64" ) {
+ vobj_enc = Base64;
+ vobj_enc_s = VCBase64Prop;
+ } else {
+ vobj_enc = EightBit;
+ vobj_enc_s = 0;
+ }
+}
+
void writeVObject(FILE *fp, VObject *o)
{
+ initVObjectEncoding();
+
OFile ofp;
@@ -1331,7 +1355,2 @@ DLLEXPORT(void) writeVObjectsToFile(char *fname, VObject *list)
-#ifndef __SHARP_COMP_
-
-// This function is not available in the Sharp ROM for SL 5500 !
-// Therefore I have to move it into the header file.. (se)
-
DLLEXPORT(const char *) vObjectTypeInfo(VObject *o)
@@ -1343,3 +1362,3 @@ DLLEXPORT(const char *) vObjectTypeInfo(VObject *o)
}
-#endif
+
diff --git a/library/backend/vobject_p.h b/library/backend/vobject_p.h
index bab22bb..f969898 100644
--- a/library/backend/vobject_p.h
+++ b/library/backend/vobject_p.h
@@ -101,5 +101,9 @@ For example:
#undef DLLEXPORT
+ //#include <qtopia/qpeglobal.h>
#include <qglobal.h>
-#if defined(Q_WS_WIN)
+
+#if defined(QTOPIA_MAKEDLL)
#define DLLEXPORT(t) __declspec(dllexport) t
+#elif defined(QTOPIA_DLL)
+#define DLLEXPORT(t) __declspec(dllimport) t
#else
@@ -353,3 +357,3 @@ extern DLLEXPORT(int) vObjectValueType(VObject *o);
-extern const char** fieldedProp;
+extern DLLEXPORT(const char**) fieldedProp;
@@ -370,3 +374,3 @@ the DLL LIB you will get a link error.
*/
-extern void writeVObject(FILE *fp, VObject *o);
+extern DLLEXPORT(void) writeVObject(FILE *fp, VObject *o);
@@ -395,24 +399,9 @@ will get a link error.
#if INCLUDEMFC
-extern VObject* Parse_MIME_FromFile(CFile *file);
+extern DLLEXPORT(VObject*) Parse_MIME_FromFile(CFile *file);
#else
-extern VObject* Parse_MIME_FromFile(FILE *file);
+extern DLLEXPORT(VObject*) Parse_MIME_FromFile(FILE *file);
#endif
-#define __SHARP_COMP_
-
-#ifndef __SHARP_COMP_
extern DLLEXPORT(const char *) vObjectTypeInfo(VObject *o);
-#else
-// This function is not available in the Sharp ROM for SL 5500 !
-// Therefore I have to move it into the header file.. (se)
-
-inline const char* vObjectTypeInfo(VObject *o)
-{
- const char *type = vObjectName( o );
- if ( strcmp( type, "TYPE" ) == 0 )
- type = vObjectStringZValue( o );
- return type;
-}
-#endif