aboutsummaryrefslogtreecommitdiffstats
path: root/libversit/vcc.y
diff options
context:
space:
mode:
Diffstat (limited to 'libversit/vcc.y')
-rw-r--r--libversit/vcc.y148
1 files changed, 105 insertions, 43 deletions
diff --git a/libversit/vcc.y b/libversit/vcc.y
index 9b4acda386..1bdd9d22a8 100644
--- a/libversit/vcc.y
+++ b/libversit/vcc.y
@@ -1,40 +1,40 @@
%{
/***************************************************************************
-(C) Copyright 1996 Apple Computer, Inc., AT&T Corp., International
-Business Machines Corporation and Siemens Rolm Communications Inc.
-
-For purposes of this license notice, the term Licensors shall mean,
-collectively, Apple Computer, Inc., AT&T Corp., International
-Business Machines Corporation and Siemens Rolm Communications Inc.
-The term Licensor shall mean any of the Licensors.
-
-Subject to acceptance of the following conditions, permission is hereby
-granted by Licensors without the need for written agreement and without
-license or royalty fees, to use, copy, modify and distribute this
-software for any purpose.
-
-The above copyright notice and the following four paragraphs must be
-reproduced in all copies of this software and any software including
-this software.
-
-THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS AND NO LICENSOR SHALL HAVE
-ANY OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS OR
-MODIFICATIONS.
-
-IN NO EVENT SHALL ANY LICENSOR BE LIABLE TO ANY PARTY FOR DIRECT,
-INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOST PROFITS ARISING OUT
-OF THE USE OF THIS SOFTWARE EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
-DAMAGE.
-
-EACH LICENSOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, EXPRESS OR IMPLIED,
-INCLUDING BUT NOT LIMITED TO ANY WARRANTY OF NONINFRINGEMENT OR THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-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.
+(C) Copyright 1996 Apple Computer, Inc., AT&T Corp., International
+Business Machines Corporation and Siemens Rolm Communications Inc.
+
+For purposes of this license notice, the term Licensors shall mean,
+collectively, Apple Computer, Inc., AT&T Corp., International
+Business Machines Corporation and Siemens Rolm Communications Inc.
+The term Licensor shall mean any of the Licensors.
+
+Subject to acceptance of the following conditions, permission is hereby
+granted by Licensors without the need for written agreement and without
+license or royalty fees, to use, copy, modify and distribute this
+software for any purpose.
+
+The above copyright notice and the following four paragraphs must be
+reproduced in all copies of this software and any software including
+this software.
+
+THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS AND NO LICENSOR SHALL HAVE
+ANY OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS OR
+MODIFICATIONS.
+
+IN NO EVENT SHALL ANY LICENSOR BE LIABLE TO ANY PARTY FOR DIRECT,
+INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOST PROFITS ARISING OUT
+OF THE USE OF THIS SOFTWARE EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGE.
+
+EACH LICENSOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, EXPRESS OR IMPLIED,
+INCLUDING BUT NOT LIMITED TO ANY WARRANTY OF NONINFRINGEMENT OR THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+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.
***************************************************************************/
@@ -44,7 +44,7 @@ DFARS 252.227-7013 or 48 CFR 52.227-19, as applicable.
* generated by a yacc parser generator. Generally it should not
* be edited by hand. The real source is vcc.y. The #line directives
* can be commented out here to make it easier to trace through
- * in a debugger. However, if a bug is found it should
+ * in a debugger. However, if a bug is found it should
* be fixed in vcc.y and this file regenerated.
*/
@@ -286,12 +286,12 @@ attr: name
}
;
-
+
name: ID
;
values: value SEMICOLON { enterValues($1); } values
- | value
+ | value
{ enterValues($1); }
;
@@ -459,8 +459,10 @@ struct LexBuf {
/* input */
#ifdef INCLUDEMFC
CFile *inputFile;
+ void *handle;
#else
FILE *inputFile;
+ GnomeVFSHandle *handle;
#endif
char *inputString;
unsigned long curPos;
@@ -514,7 +516,7 @@ static char lexGetc_()
return EOF;
else if (lexBuf.inputString)
return *(lexBuf.inputString + lexBuf.curPos++);
- else {
+ else if (lexBuf.inputFile {
#ifdef INCLUDEMFC
char result;
return lexBuf.inputFile->Read(&result, 1) == 1 ? result : EOF;
@@ -522,6 +524,16 @@ static char lexGetc_()
return fgetc(lexBuf.inputFile);
#endif
}
+ else if (lexBuf.handle) {
+ char buf;
+ GnomeVFSResult result;
+ GnomeVFSFileSize n;
+
+ if (gnome_vfs_read (lexBuf.handle, &buf, 1, &n) == GNOME_VFS_OK)
+ return buf;
+ else
+ return EOF;
+ }
}
static int lexGeta()
@@ -785,9 +797,9 @@ static int match_begin_name(int end) {
#ifdef INCLUDEMFC
-void initLex(const char *inputstring, unsigned long inputlen, CFile *inputfile)
+void initLex(const char *inputstring, unsigned long inputlen, CFile *inputfile, void *handle)
#else
-void initLex(const char *inputstring, unsigned long inputlen, FILE *inputfile)
+void initLex(const char *inputstring, unsigned long inputlen, FILE *inputfile, GnomeVFSHandle *handle)
#endif
{
/* initialize lex mode stack */
@@ -798,6 +810,7 @@ void initLex(const char *inputstring, unsigned long inputlen, FILE *inputfile)
lexBuf.inputLen = inputlen;
lexBuf.curPos = 0;
lexBuf.inputFile = inputfile;
+ lexBuf.handle = handle;
lexBuf.len = 0;
lexBuf.getPtr = 0;
@@ -1008,7 +1021,7 @@ static int yylex() {
lexPushLookaheadc(c);
#ifdef _SUPPORT_LINE_FOLDING
handleMoreRFC822LineBreak(c);
-#endif
+#endif
lexSkipLookahead();
return SEMICOLON;
}
@@ -1144,7 +1157,7 @@ DLLEXPORT(VObject*) Parse_MIME(const char *input, unsigned long len)
DLLEXPORT(VObject*) Parse_MIME_FromFile(CFile *file)
{
unsigned long startPos;
- VObject *result;
+ VObject *result;
initLex(0,-1,file);
startPos = file->GetPosition();
@@ -1157,7 +1170,7 @@ DLLEXPORT(VObject*) Parse_MIME_FromFile(CFile *file)
VObject* Parse_MIME_FromFile(FILE *file)
{
- VObject *result;
+ VObject *result;
long startPos;
initLex(0,(unsigned long)-1,file);
@@ -1186,6 +1199,55 @@ DLLEXPORT(VObject*) Parse_MIME_FromFileName(char *fname)
#endif
+VObject *
+Parse_MIME_FromGnomeVFSHandle (GnomeVFSHandle *handle)
+{
+ VObject *result;
+ GnomeVFSFileSize start_pos;
+
+ g_return_val_if_fail (handle != NULL, NULL);
+
+ if (gnome_vfs_tell (handle, &start_pos) != GNOME_VFS_OK) {
+ g_message ("Parse_MIME_FromGnomeVFSHandle(): could not tell() the file");
+ return NULL;
+ }
+
+ initLex (NULL, -1, NULL, handle);
+
+ result = Parse_MIMEHelper ();
+ if (!result)
+ if (gnome_vfs_seek (handle, GNOME_VFS_SEEK_START, start_pos) != GNOME_VFS_OK)
+ g_message ("Parse_MIME_FromGnomeVFSHandle(): "
+ "could not reset the file position");
+
+ return result;
+}
+
+VObject *
+Parse_MIME_FromGnomeVFSURI (GnomeVFSURI *uri)
+{
+ GnomeVFSHandle *handle;
+ VObject *o;
+
+ g_return_val_if_fail (uri != NULL, NULL);
+
+ if (gnome_vfs_open_uri (&handle, uri, GNOME_VFS_OPEN_READ) != GNOME_VFS_OK) {
+ char *msg;
+ char *str_uri;
+
+ str_uri = gnome_vfs_uri_to_string (uri, GNOME_VFS_URI_HIDE_NONE);
+ msg = g_strdup_printf ("Could not open `%s'\n", str_uri);
+ mime_error (msg);
+ g_free (str_uri);
+ g_free (msg);
+ return NULL;
+ }
+
+ o = Parse_MIME_FromGnomeVFSHandle (handle);
+ gnome_vfs_close (handle);
+ return o;
+}
+
/*/////////////////////////////////////////////////////////////////////////*/
static void YYDebug(const char *s)
{