[asterisk-commits] russell: branch group/http_mods r60449 - in
/team/group/http_mods: ./ include...
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Fri Apr 6 09:06:29 MST 2007
Author: russell
Date: Fri Apr 6 11:06:28 2007
New Revision: 60449
URL: http://svn.digium.com/view/asterisk?view=rev&rev=60449
Log:
Integreate the build of minimime into the Asterisk build, among other various
little changes ...
Added:
team/group/http_mods/main/minimime/mimeparser.tab.c (with props)
team/group/http_mods/main/minimime/mimeparser.yy.c (with props)
Modified:
team/group/http_mods/Makefile.moddir_rules
team/group/http_mods/configure
team/group/http_mods/configure.ac
team/group/http_mods/include/asterisk/autoconfig.h.in
team/group/http_mods/include/asterisk/compat.h
team/group/http_mods/main/Makefile
team/group/http_mods/main/http.c
team/group/http_mods/main/minimime/Makefile
team/group/http_mods/main/minimime/mimeparser.y
team/group/http_mods/main/strcompat.c
Modified: team/group/http_mods/Makefile.moddir_rules
URL: http://svn.digium.com/view/asterisk/team/group/http_mods/Makefile.moddir_rules?view=diff&rev=60449&r1=60448&r2=60449
==============================================================================
--- team/group/http_mods/Makefile.moddir_rules (original)
+++ team/group/http_mods/Makefile.moddir_rules Fri Apr 6 11:06:28 2007
@@ -12,7 +12,9 @@
#
ifneq ($(findstring MALLOC_DEBUG,$(MENUSELECT_CFLAGS)),)
+ ifeq ($(findstring astmm.h,$(ASTCFLAGS)),)
ASTCFLAGS+=-include $(ASTTOPDIR)/include/asterisk/astmm.h
+ endif
endif
ifeq ($(findstring LOADABLE_MODULES,$(MENUSELECT_CFLAGS)),)
Modified: team/group/http_mods/configure
URL: http://svn.digium.com/view/asterisk/team/group/http_mods/configure?view=diff&rev=60449&r1=60448&r2=60449
==============================================================================
--- team/group/http_mods/configure (original)
+++ team/group/http_mods/configure Fri Apr 6 11:06:28 2007
@@ -1,5 +1,5 @@
#! /bin/sh
-# From configure.ac Revision: 58955 .
+# From configure.ac Revision: 59202 .
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.60.
#
@@ -15763,7 +15763,9 @@
-for ac_func in asprintf atexit bzero dup2 endpwent floor ftruncate getcwd gethostbyname gethostname getloadavg gettimeofday inet_ntoa isascii localtime_r memchr memmove memset mkdir munmap pow putenv re_comp regcomp rint select setenv socket sqrt strcasecmp strcasestr strchr strcspn strdup strerror strncasecmp strndup strnlen strrchr strsep strspn strstr strtol strtoq unsetenv utime vasprintf
+
+
+for ac_func in asprintf atexit bzero dup2 endpwent floor ftruncate getcwd gethostbyname gethostname getloadavg gettimeofday inet_ntoa isascii localtime_r memchr memmove memset mkdir munmap pow putenv re_comp regcomp rint select setenv socket sqrt strcasecmp strcasestr strchr strcspn strdup strerror strlcat strlcpy strncasecmp strndup strnlen strrchr strsep strspn strstr strtol strtoq unsetenv utime vasprintf
do
as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
{ echo "$as_me:$LINENO: checking for $ac_func" >&5
Modified: team/group/http_mods/configure.ac
URL: http://svn.digium.com/view/asterisk/team/group/http_mods/configure.ac?view=diff&rev=60449&r1=60448&r2=60449
==============================================================================
--- team/group/http_mods/configure.ac (original)
+++ team/group/http_mods/configure.ac Fri Apr 6 11:06:28 2007
@@ -258,7 +258,7 @@
AC_FUNC_STRTOD
AC_FUNC_UTIME_NULL
AC_FUNC_VPRINTF
-AC_CHECK_FUNCS([asprintf atexit bzero dup2 endpwent floor ftruncate getcwd gethostbyname gethostname getloadavg gettimeofday inet_ntoa isascii localtime_r memchr memmove memset mkdir munmap pow putenv re_comp regcomp rint select setenv socket sqrt strcasecmp strcasestr strchr strcspn strdup strerror strncasecmp strndup strnlen strrchr strsep strspn strstr strtol strtoq unsetenv utime vasprintf])
+AC_CHECK_FUNCS([asprintf atexit bzero dup2 endpwent floor ftruncate getcwd gethostbyname gethostname getloadavg gettimeofday inet_ntoa isascii localtime_r memchr memmove memset mkdir munmap pow putenv re_comp regcomp rint select setenv socket sqrt strcasecmp strcasestr strchr strcspn strdup strerror strlcat strlcpy strncasecmp strndup strnlen strrchr strsep strspn strstr strtol strtoq unsetenv utime vasprintf])
AC_MSG_CHECKING(for PTHREAD_RWLOCK_INITIALIZER)
AC_LINK_IFELSE(
Modified: team/group/http_mods/include/asterisk/autoconfig.h.in
URL: http://svn.digium.com/view/asterisk/team/group/http_mods/include/asterisk/autoconfig.h.in?view=diff&rev=60449&r1=60448&r2=60449
==============================================================================
--- team/group/http_mods/include/asterisk/autoconfig.h.in (original)
+++ team/group/http_mods/include/asterisk/autoconfig.h.in Fri Apr 6 11:06:28 2007
@@ -360,6 +360,12 @@
/* Define to 1 if you have the <string.h> header file. */
#undef HAVE_STRING_H
+
+/* Define to 1 if you have the `strlcat' function. */
+#undef HAVE_STRLCAT
+
+/* Define to 1 if you have the `strlcpy' function. */
+#undef HAVE_STRLCPY
/* Define to 1 if you have the `strncasecmp' function. */
#undef HAVE_STRNCASECMP
Modified: team/group/http_mods/include/asterisk/compat.h
URL: http://svn.digium.com/view/asterisk/team/group/http_mods/include/asterisk/compat.h?view=diff&rev=60449&r1=60448&r2=60449
==============================================================================
--- team/group/http_mods/include/asterisk/compat.h (original)
+++ team/group/http_mods/include/asterisk/compat.h Fri Apr 6 11:06:28 2007
@@ -61,6 +61,14 @@
int vasprintf(char **strp, const char *fmt, va_list ap);
#endif
+#ifndef HAVE_STRLCAT
+size_t strlcat(char *dst, const char *src, size_t siz);
+#endif
+
+#ifndef HAVE_STRLCPY
+size_t strlcpy(char *dst, const char *src, size_t siz);
+#endif
+
#ifdef SOLARIS
#define __BEGIN_DECLS
#define __END_DECLS
Modified: team/group/http_mods/main/Makefile
URL: http://svn.digium.com/view/asterisk/team/group/http_mods/main/Makefile?view=diff&rev=60449&r1=60448&r2=60449
==============================================================================
--- team/group/http_mods/main/Makefile (original)
+++ team/group/http_mods/main/Makefile Fri Apr 6 11:06:28 2007
@@ -127,7 +127,10 @@
H323LDLIBS=
endif
-asterisk: $(OBJS) editline/libedit.a db1-ast/libdb1.a $(AST_EMBED_LDSCRIPTS)
+minimime/libmmime.a:
+ @cd minimime && $(MAKE) libmmime.a
+
+asterisk: $(OBJS) editline/libedit.a db1-ast/libdb1.a minimime/libmmime.a $(AST_EMBED_LDSCRIPTS)
@$(ASTTOPDIR)/build_tools/make_build_h > $(ASTTOPDIR)/include/asterisk/build.h.tmp
@if cmp -s $(ASTTOPDIR)/include/asterisk/build.h.tmp $(ASTTOPDIR)/include/asterisk/build.h ; then echo ; else \
mv $(ASTTOPDIR)/include/asterisk/build.h.tmp $(ASTTOPDIR)/include/asterisk/build.h ; \
@@ -135,7 +138,7 @@
@rm -f $(ASTTOPDIR)/include/asterisk/build.h.tmp
@$(CC) -c -o buildinfo.o $(ASTCFLAGS) buildinfo.c
$(ECHO_PREFIX) echo " [LD] $^ -> $@"
- $(CMD_PREFIX) $(CXX) $(STATIC_BUILD) -o $@ $(ASTLINK) $(AST_EMBED_LDFLAGS) $(ASTLDFLAGS) $(H323LDFLAGS) $^ minimime/libmmime.a buildinfo.o $(AST_LIBS) $(AST_EMBED_LIBS) $(H323LDLIBS)
+ $(CMD_PREFIX) $(CXX) $(STATIC_BUILD) -o $@ $(ASTLINK) $(AST_EMBED_LDFLAGS) $(ASTLDFLAGS) $(H323LDFLAGS) $^ buildinfo.o $(AST_LIBS) $(AST_EMBED_LIBS) $(H323LDLIBS)
@$(ASTTOPDIR)/build_tools/strip_nonapi $@
clean::
@@ -145,3 +148,5 @@
@$(MAKE) -C db1-ast clean
@$(MAKE) -C stdtime clean
@$(MAKE) -C minimime clean
+
+.PHONY: minimime/libmmime.a
Modified: team/group/http_mods/main/http.c
URL: http://svn.digium.com/view/asterisk/team/group/http_mods/main/http.c?view=diff&rev=60449&r1=60448&r2=60449
==============================================================================
--- team/group/http_mods/main/http.c (original)
+++ team/group/http_mods/main/http.c Fri Apr 6 11:06:28 2007
@@ -342,8 +342,9 @@
size_t body_len;
snprintf(filename, sizeof(filename), "%s/%s", post_dir, fn);
-
- ast_log(LOG_DEBUG, "Posting raw data to %s\n", filename);
+
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Posting raw data to %s\n", filename);
if (!(f = fopen(filename, "w"))) {
ast_log(LOG_WARNING, "Unable to open %s for writing file from a POST!\n", filename);
@@ -351,12 +352,15 @@
}
if (!(body = mm_mimepart_getbody(part, 0))) {
- ast_log(LOG_DEBUG, "Couldn't get the mimepart body\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Couldn't get the mimepart body\n");
fclose(f);
return;
}
body_len = mm_mimepart_getlength(part);
- ast_log(LOG_DEBUG, "Body length is %ld\n", body_len);
+
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Body length is %ld\n", body_len);
fwrite(body, 1, body_len, f);
@@ -376,22 +380,18 @@
struct ast_http_post_mapping *post_map;
const char *post_dir;
- ast_log(LOG_DEBUG, "uri: %s\n", uri);
-
- *status = 404;
- *title = ast_strdup("Not Found");
-
- /* XXX Switch to a random temp file */
- if (!(f = fopen("/tmp/ast_postdata", "w")))
- return ast_http_error(404, "Not Found", NULL, "The requested URL was not found on this server.");
+ if (!(f = tmpfile()))
+ return NULL;
for (var = headers; var; var = var->next) {
if (!strcasecmp(var->name, "Content-Length")) {
if ((sscanf(var->value, "%u", &content_len)) != 1) {
ast_log(LOG_ERROR, "Invalid Content-Length in POST request!\n");
- return ast_http_error(404, "Not Found", NULL, "The requested URL was not found on this server.");
+ fclose(f);
+ return NULL;
}
- ast_log(LOG_DEBUG, "Got a Content-Length of %d\n", content_len);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Got a Content-Length of %d\n", content_len);
} else if (!strcasecmp(var->name, "Content-Type"))
fprintf(f, "Content-Type: %s\r\n\r\n", var->value);
}
@@ -403,57 +403,80 @@
break;
}
- fclose(f);
+ if (fseek(f, SEEK_SET, 0)) {
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Failed to seek temp file back to beginning.\n");
+ fclose(f);
+ return NULL;
+ }
AST_RWLIST_RDLOCK(&post_mappings);
if (!(post_map = find_post_mapping(uri))) {
- ast_log(LOG_DEBUG, "%s is not a valid URI for POST\n", uri);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "%s is not a valid URI for POST\n", uri);
AST_RWLIST_UNLOCK(&post_mappings);
+ fclose(f);
+ *status = 404;
+ *title = ast_strdup("Not Found");
return ast_http_error(404, "Not Found", NULL, "The requested URL was not found on this server.");
}
post_dir = ast_strdupa(post_map->to);
post_map = NULL;
AST_RWLIST_UNLOCK(&post_mappings);
- ast_log(LOG_DEBUG, "Going to post files to dir %s\n", post_dir);
-
- if (!(ctx = mm_context_new()))
- return ast_http_error(404, "Not Found", NULL, "The requested URL was not found on this server.");
-
- mm_res = mm_parse_file(ctx, "/tmp/ast_postdata", MM_PARSE_LOOSE, 0);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Going to post files to dir %s\n", post_dir);
+
+ if (!(ctx = mm_context_new())) {
+ fclose(f);
+ return NULL;
+ }
+
+ mm_res = mm_parse_fileptr(ctx, f, MM_PARSE_LOOSE, 0);
+ fclose(f);
if (mm_res == -1) {
ast_log(LOG_ERROR, "Error parsing MIME data\n");
mm_context_free(ctx);
- return ast_http_error(404, "Not Found", NULL, "The requested URL was not found on this server.");
+ *status = 400;
+ *title = ast_strdup("Bad Request");
+ return ast_http_error(400, "Bad Request", NULL, "The was an error parsing the request.");
}
mm_res = mm_context_countparts(ctx);
if (!mm_res) {
ast_log(LOG_ERROR, "Invalid MIME data, found no parts!\n");
mm_context_free(ctx);
- return ast_http_error(404, "Not Found", NULL, "The requested URL was not found on this server.");
- }
- if (mm_context_iscomposite(ctx))
- ast_log(LOG_DEBUG, "Found %d MIME parts\n", mm_res - 1);
- else
- ast_log(LOG_DEBUG, "We have a flat (not multi-part) message\n");
+ *status = 400;
+ *title = ast_strdup("Bad Request");
+ return ast_http_error(400, "Bad Request", NULL, "The was an error parsing the request.");
+ }
+
+ if (option_debug) {
+ if (mm_context_iscomposite(ctx))
+ ast_log(LOG_DEBUG, "Found %d MIME parts\n", mm_res - 1);
+ else
+ ast_log(LOG_DEBUG, "We have a flat (not multi-part) message\n");
+ }
for (i = 1; i < mm_res; i++) {
struct mm_mimepart *part;
char fn[PATH_MAX];
if (!(part = mm_context_getpart(ctx, i))) {
- ast_log(LOG_DEBUG, "Failed to get mime part num %d\n", i);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Failed to get mime part num %d\n", i);
continue;
}
if (get_filename(part, fn, sizeof(fn))) {
- ast_log(LOG_DEBUG, "Failed to retrieve a filename for part num %d\n", i);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Failed to retrieve a filename for part num %d\n", i);
continue;
}
if (!part->type) {
- ast_log(LOG_DEBUG, "This part has no content struct?\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "This part has no content struct?\n");
continue;
}
@@ -463,7 +486,9 @@
mm_context_free(ctx);
- return ast_http_error(404, "Not Found", NULL, "The requested URL was not found on this server.");
+ *status = 200;
+ *title = ast_strdup("OK");
+ return ast_strdup("");
}
static char *handle_uri(struct sockaddr_in *sin, char *uri, int *status, char **title, int *contentlength, struct ast_variable **cookies)
Modified: team/group/http_mods/main/minimime/Makefile
URL: http://svn.digium.com/view/asterisk/team/group/http_mods/main/minimime/Makefile?view=diff&rev=60449&r1=60448&r2=60449
==============================================================================
--- team/group/http_mods/main/minimime/Makefile (original)
+++ team/group/http_mods/main/minimime/Makefile Fri Apr 6 11:06:28 2007
@@ -1,13 +1,20 @@
-# $Id$
-# MiniMIME makefile
#
-include Make.conf
-CC?=gcc
-LD?=ld
-YACC?=yacc
-FLEX?=flex
-DEFINES?=
-SRCS= \
+# Asterisk -- A telephony toolkit for Linux.
+#
+# Makefile for resource modules
+#
+# Copyright (C) 2007, Digium, Inc.
+#
+# This program is free software, distributed under the terms of
+# the GNU General Public License
+#
+
+-include $(ASTTOPDIR)/menuselect.makeopts $(ASTTOPDIR)/menuselect.makedeps
+
+include $(ASTTOPDIR)/Makefile.moddir_rules
+
+LIBMMIME:=libmmime.a
+MM_SRCS= \
mimeparser.tab.c \
mimeparser.yy.c \
mm_init.c \
@@ -23,102 +30,25 @@
mm_mimeutil.c \
mm_param.c \
mm_parse.c \
- mm_util.c \
+ mm_util.c
-HAVE_DEBUG?=1
+MM_OBJS:=$(MM_SRCS:%.c=%.o)
+MM_HDRS:=mm.h mm_util.h
-ifeq ($(HAVE_STRLCAT),)
-SRCS+= strlcat.c
-else
-DEFINES+= -DHAVE_STRLCAT
+ASTCFLAGS:=$(filter-out -Werror -Wstrict-prototypes -Wmissing-declarations -Wmissing-prototypes,$(ASTCFLAGS))
+
+all: $(LIBMMIME)
+
+$(LIBMMIME): $(MM_OBJS)
+ $(ECHO_PREFIX) echo " [AR] $^ -> $@"
+ $(CMD_PREFIX) $(AR) cr $@ $^
+ $(CMD_PREFIX) $(RANLIB) $@
+
+clean::
+ rm -f $(LIBMMIME) *.o
+
+.PHONY: clean all $(LIBMMIME)
+
+ifneq ($(wildcard .*.d),)
+ include .*.d
endif
-
-ifeq ($(HAVE_STRLCPY),)
-SRCS+= strlcpy.c
-else
-DEFINES+= -DHAVE_STRLCPY
-endif
-
-ifneq ($(HAVE_DEBUG),)
-DEBUG=-ggdb -g3
-else
-DEBUG=
-endif
-
-SRCS+= minimime.c
-
-# Uncomment the following if you need to debug memory leaks within the
-# library. ATTENTION: the code is not suitable for production purposes
-# and could behave unexpectedly. You have been warned ;-).
-
-#DEFINES+= -D__HAVE_LEAK_DETECTION
-#DEFINES+= -DMM_DEBUG
-
-CFLAGS+=-Wall $(DEBUG) -I. $(DEFINES) -fPIC -D_GNU_SOURCE
-LDFLAGS?=
-LIBS?=
-OBJS=$(SRCS:.c=.o)
-VERSION=0.1
-HDRS=mm.h mm_util.h
-TARGET=minimime
-LIBNAME=libmmime.so.$(VERSION)
-ARNAME=libmmime.a
-PREFIX?=
-
-all: $(LIBNAME)
-
-mytest: all mytest_files/mytest.o
- $(CC) $(LDFLAGS) -o $@ mytest_files/mytest.o $(ARNAME)
- if [ ! -f mytest_files/ast_postdata3 ] ; then cd mytest_files && gunzip ast_postdata3.gz ; fi
-
-depend:
- mkdep $(CFLAGS) $(SRCS)
-
-$(OBJS): $(HDRS) Makefile Make.conf
-
-debug: $(OBJS)
- $(CC) -o minimime $(OBJS) $(CFLAGS) $(LDFLAGS) $(LIBS)
-
-$(LIBNAME): $(OBJS)
- $(LD) -shared -o $(LIBNAME) $(OBJS)
- ar -rv $(ARNAME) $(OBJS)
- ranlib $(ARNAME)
-
-$(LIBNAME): $(OBJS)
-
-$(ARNAME): $(OBJS)
-
-minimime: $(LIBNAME) minimime.o
- $(CC) -o $(TARGET) minimime.o -L. -lmmime
-
-mimeparser.yy.o: mimeparser.l
- $(FLEX) -Pmimeparser_yy -omimeparser.yy.c mimeparser.l
- $(CC) -c $(CFLAGS) -Wno-unused mimeparser.yy.c
-
-mimeparser.tab.o: mimeparser.y
- $(YACC) -d -pmimeparser_yy -omimeparser.tab.c mimeparser.y
- $(CC) -c $(CFLAGS) -Wno-unused mimeparser.tab.c
-
-test: $(LIBNAME)
- @cd tests && make
- @echo "****************************************************************"
- @echo Running testsuite for libminimime...
- @echo "****************************************************************"
- @export LD_LIBRARY_PATH=$(.CURDIR)/src
- @cd tests && ./test.sh
-
-install: $(LIBNAME)
- test -d $(PREFIX) || mkdir -p $(PREFIX)
- install -m 644 -o root -g 0 -c $(LIBNAME) /usr/local/lib
-
-clean:
- rm -f *.yy.c
- rm -f *.tab.*
- rm -f *.o
- rm -f *.core
- rm -f $(TARGET)
- rm -f $(LIBNAME)
- rm -f ${ARNAME}
- rm -f .depend
- cd tests && make clean
- rm -f mytest_files/mytest.o mytest
Added: team/group/http_mods/main/minimime/mimeparser.tab.c
URL: http://svn.digium.com/view/asterisk/team/group/http_mods/main/minimime/mimeparser.tab.c?view=auto&rev=60449
==============================================================================
--- team/group/http_mods/main/minimime/mimeparser.tab.c (added)
+++ team/group/http_mods/main/minimime/mimeparser.tab.c Fri Apr 6 11:06:28 2007
@@ -1,0 +1,2341 @@
+/* A Bison parser, made by GNU Bison 2.3. */
+
+/* Skeleton implementation for Bison's Yacc-like parsers in C
+
+ Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
+ Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA. */
+
+/* As a special exception, you may create a larger work that contains
+ part or all of the Bison parser skeleton and distribute that work
+ under terms of your choice, so long as that work isn't itself a
+ parser generator using the skeleton or a modified version thereof
+ as a parser skeleton. Alternatively, if you modify or redistribute
+ the parser skeleton itself, you may (at your option) remove this
+ special exception, which will cause the skeleton and the resulting
+ Bison output files to be licensed under the GNU General Public
+ License without this special exception.
+
+ This special exception was added by the Free Software Foundation in
+ version 2.2 of Bison. */
+
+/* C LALR(1) parser skeleton written by Richard Stallman, by
+ simplifying the original so-called "semantic" parser. */
+
+/* All symbols defined below should begin with yy or YY, to avoid
+ infringing on user name space. This should be done even for local
+ variables, as they might otherwise be expanded by user macros.
+ There are some unavoidable exceptions within include files to
+ define necessary library symbols; they are noted "INFRINGES ON
+ USER NAME SPACE" below. */
+
+/* Identify Bison output. */
+#define YYBISON 1
+
+/* Bison version. */
+#define YYBISON_VERSION "2.3"
+
+/* Skeleton name. */
+#define YYSKELETON_NAME "yacc.c"
+
+/* Pure parsers. */
+#define YYPURE 1
+
+/* Using locations. */
+#define YYLSP_NEEDED 0
+
+/* Substitute the variable and function names. */
+#define yyparse mimeparser_yyparse
+#define yylex mimeparser_yylex
+#define yyerror mimeparser_yyerror
+#define yylval mimeparser_yylval
+#define yychar mimeparser_yychar
+#define yydebug mimeparser_yydebug
+#define yynerrs mimeparser_yynerrs
+
+
+/* Tokens. */
+#ifndef YYTOKENTYPE
+# define YYTOKENTYPE
+ /* Put the tokens into the symbol table, so that GDB and other debuggers
+ know about them. */
+ enum yytokentype {
+ ANY = 258,
+ COLON = 259,
+ DASH = 260,
+ DQUOTE = 261,
+ ENDOFHEADERS = 262,
+ EOL = 263,
+ EOM = 264,
+ EQUAL = 265,
+ MIMEVERSION_HEADER = 266,
+ SEMICOLON = 267,
+ CONTENTDISPOSITION_HEADER = 268,
+ CONTENTENCODING_HEADER = 269,
+ CONTENTTYPE_HEADER = 270,
+ MAIL_HEADER = 271,
+ HEADERVALUE = 272,
+ BOUNDARY = 273,
+ ENDBOUNDARY = 274,
+ CONTENTTYPE_VALUE = 275,
+ TSPECIAL = 276,
+ WORD = 277,
+ BODY = 278,
+ PREAMBLE = 279,
+ POSTAMBLE = 280
+ };
+#endif
+/* Tokens. */
+#define ANY 258
+#define COLON 259
+#define DASH 260
+#define DQUOTE 261
+#define ENDOFHEADERS 262
+#define EOL 263
+#define EOM 264
+#define EQUAL 265
+#define MIMEVERSION_HEADER 266
+#define SEMICOLON 267
+#define CONTENTDISPOSITION_HEADER 268
+#define CONTENTENCODING_HEADER 269
+#define CONTENTTYPE_HEADER 270
+#define MAIL_HEADER 271
+#define HEADERVALUE 272
+#define BOUNDARY 273
+#define ENDBOUNDARY 274
+#define CONTENTTYPE_VALUE 275
+#define TSPECIAL 276
+#define WORD 277
+#define BODY 278
+#define PREAMBLE 279
+#define POSTAMBLE 280
+
+
+
+
+/* Copy the first part of user declarations. */
+#line 1 "mimeparser.y"
+
+/*
+ * Copyright (c) 2004 Jann Fischer. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/**
+ * These are the grammatic definitions in yacc syntax to parse MIME conform
+ * messages.
+ *
+ * TODO:
+ * - honour parse flags passed to us (partly done)
+ * - parse Content-Disposition header (partly done)
+ * - parse Content-Encoding header
+ */
+#include <stdio.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+#include <errno.h>
+
+#include "mimeparser.h"
+#include "mm.h"
+#include "mm_internal.h"
+
+int set_boundary(char *,struct parser_state *);
+int mimeparser_yywrap(void);
+void reset_environ(struct parser_state *pstate);
+int PARSER_initialize(struct parser_state *pstate, void *yyscanner);
+
+typedef void *yyscan_t;
+
+static char *PARSE_readmessagepart(size_t, size_t, size_t, size_t *,yyscan_t, struct parser_state *);
+FILE *mimeparser_yyget_in (yyscan_t yyscanner );
+
+
+
+/* Enabling traces. */
+#ifndef YYDEBUG
+# define YYDEBUG 0
+#endif
+
+/* Enabling verbose error messages. */
+#ifdef YYERROR_VERBOSE
+# undef YYERROR_VERBOSE
+# define YYERROR_VERBOSE 1
+#else
+# define YYERROR_VERBOSE 0
+#endif
+
+/* Enabling the token table. */
+#ifndef YYTOKEN_TABLE
+# define YYTOKEN_TABLE 0
+#endif
+
+#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
+typedef union YYSTYPE
+#line 69 "mimeparser.y"
+{
+ int number;
+ char *string;
+ struct s_position position;
+}
+/* Line 193 of yacc.c. */
+#line 222 "mimeparser.tab.c"
+ YYSTYPE;
+# define yystype YYSTYPE /* obsolescent; will be withdrawn */
+# define YYSTYPE_IS_DECLARED 1
+# define YYSTYPE_IS_TRIVIAL 1
+#endif
+
+
+
+/* Copy the second part of user declarations. */
+
+
+/* Line 216 of yacc.c. */
+#line 235 "mimeparser.tab.c"
+
+#ifdef short
+# undef short
+#endif
+
+#ifdef YYTYPE_UINT8
+typedef YYTYPE_UINT8 yytype_uint8;
+#else
+typedef unsigned char yytype_uint8;
+#endif
+
+#ifdef YYTYPE_INT8
+typedef YYTYPE_INT8 yytype_int8;
+#elif (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+typedef signed char yytype_int8;
+#else
+typedef short int yytype_int8;
+#endif
+
+#ifdef YYTYPE_UINT16
+typedef YYTYPE_UINT16 yytype_uint16;
+#else
+typedef unsigned short int yytype_uint16;
+#endif
+
+#ifdef YYTYPE_INT16
+typedef YYTYPE_INT16 yytype_int16;
+#else
+typedef short int yytype_int16;
+#endif
+
+#ifndef YYSIZE_T
+# ifdef __SIZE_TYPE__
+# define YYSIZE_T __SIZE_TYPE__
+# elif defined size_t
+# define YYSIZE_T size_t
+# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
+# define YYSIZE_T size_t
+# else
+# define YYSIZE_T unsigned int
+# endif
+#endif
+
+#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
+
+#ifndef YY_
+# if YYENABLE_NLS
+# if ENABLE_NLS
+# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
+# define YY_(msgid) dgettext ("bison-runtime", msgid)
+# endif
+# endif
+# ifndef YY_
+# define YY_(msgid) msgid
+# endif
+#endif
+
+/* Suppress unused-variable warnings by "using" E. */
+#if ! defined lint || defined __GNUC__
+# define YYUSE(e) ((void) (e))
+#else
+# define YYUSE(e) /* empty */
+#endif
+
+/* Identity function, used to suppress warnings about constant conditions. */
+#ifndef lint
+# define YYID(n) (n)
+#else
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+static int
+YYID (int i)
+#else
+static int
+YYID (i)
+ int i;
+#endif
+{
+ return i;
+}
+#endif
+
+#if ! defined yyoverflow || YYERROR_VERBOSE
+
+/* The parser invokes alloca or malloc; define the necessary symbols. */
+
+# ifdef YYSTACK_USE_ALLOCA
+# if YYSTACK_USE_ALLOCA
+# ifdef __GNUC__
+# define YYSTACK_ALLOC __builtin_alloca
+# elif defined __BUILTIN_VA_ARG_INCR
+# include <alloca.h> /* INFRINGES ON USER NAME SPACE */
+# elif defined _AIX
+# define YYSTACK_ALLOC __alloca
+# elif defined _MSC_VER
+# include <malloc.h> /* INFRINGES ON USER NAME SPACE */
+# define alloca _alloca
+# else
+# define YYSTACK_ALLOC alloca
+# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
+# ifndef _STDLIB_H
+# define _STDLIB_H 1
+# endif
+# endif
+# endif
+# endif
+# endif
+
+# ifdef YYSTACK_ALLOC
+ /* Pacify GCC's `empty if-body' warning. */
+# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
+# ifndef YYSTACK_ALLOC_MAXIMUM
+ /* The OS might guarantee only one guard page at the bottom of the stack,
+ and a page size can be as small as 4096 bytes. So we cannot safely
+ invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
+ to allow for a few compiler-allocated temporary stack slots. */
+# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
+# endif
+# else
+# define YYSTACK_ALLOC YYMALLOC
+# define YYSTACK_FREE YYFREE
+# ifndef YYSTACK_ALLOC_MAXIMUM
+# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
+# endif
+# if (defined __cplusplus && ! defined _STDLIB_H \
+ && ! ((defined YYMALLOC || defined malloc) \
+ && (defined YYFREE || defined free)))
+# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
+# ifndef _STDLIB_H
+# define _STDLIB_H 1
+# endif
+# endif
+# ifndef YYMALLOC
+# define YYMALLOC malloc
+# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
+# endif
+# endif
+# ifndef YYFREE
+# define YYFREE free
+# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+void free (void *); /* INFRINGES ON USER NAME SPACE */
+# endif
+# endif
+# endif
+#endif /* ! defined yyoverflow || YYERROR_VERBOSE */
+
+
+#if (! defined yyoverflow \
+ && (! defined __cplusplus \
+ || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
+
+/* A type that is properly aligned for any stack member. */
+union yyalloc
+{
+ yytype_int16 yyss;
+ YYSTYPE yyvs;
+ };
+
+/* The size of the maximum gap between one aligned stack and the next. */
+# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
+
+/* The size of an array large to enough to hold all stacks, each with
+ N elements. */
+# define YYSTACK_BYTES(N) \
+ ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
+ + YYSTACK_GAP_MAXIMUM)
+
+/* Copy COUNT objects from FROM to TO. The source and destination do
+ not overlap. */
+# ifndef YYCOPY
+# if defined __GNUC__ && 1 < __GNUC__
+# define YYCOPY(To, From, Count) \
+ __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
+# else
+# define YYCOPY(To, From, Count) \
+ do \
+ { \
+ YYSIZE_T yyi; \
+ for (yyi = 0; yyi < (Count); yyi++) \
+ (To)[yyi] = (From)[yyi]; \
+ } \
+ while (YYID (0))
+# endif
+# endif
+
+/* Relocate STACK from its old location to the new one. The
+ local variables YYSIZE and YYSTACKSIZE give the old and new number of
+ elements in the stack, and YYPTR gives the new location of the
+ stack. Advance YYPTR to a properly aligned location for the next
+ stack. */
+# define YYSTACK_RELOCATE(Stack) \
+ do \
+ { \
+ YYSIZE_T yynewbytes; \
+ YYCOPY (&yyptr->Stack, Stack, yysize); \
+ Stack = &yyptr->Stack; \
+ yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
+ yyptr += yynewbytes / sizeof (*yyptr); \
+ } \
+ while (YYID (0))
+
+#endif
+
+/* YYFINAL -- State number of the termination state. */
+#define YYFINAL 26
+/* YYLAST -- Last index in YYTABLE. */
+#define YYLAST 61
+
+/* YYNTOKENS -- Number of terminals. */
+#define YYNTOKENS 28
+/* YYNNTS -- Number of nonterminals. */
+#define YYNNTS 29
+/* YYNRULES -- Number of rules. */
+#define YYNRULES 50
+/* YYNRULES -- Number of states. */
+#define YYNSTATES 83
+
+/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
+#define YYUNDEFTOK 2
+#define YYMAXUTOK 280
+
+#define YYTRANSLATE(YYX) \
+ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
+
+/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
+static const yytype_uint8 yytranslate[] =
+{
+ 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 27, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 26, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
+ 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
+ 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
+ 25
+};
+
+#if YYDEBUG
+/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
+ YYRHS. */
+static const yytype_uint8 yyprhs[] =
+{
+ 0, 0, 3, 5, 7, 8, 15, 18, 21, 23,
+ 25, 27, 28, 30, 31, 34, 36, 40, 42, 44,
+ 46, 48, 50, 52, 57, 61, 66, 72, 77, 83,
+ 85, 90, 95, 98, 101, 103, 107, 111, 114, 116,
+ 120, 123, 125, 129, 133, 135, 137, 141, 143, 146,
+ 148
+};
+
+/* YYRHS -- A `-1'-separated list of the rules' RHS. */
+static const yytype_int8 yyrhs[] =
+{
+ 29, 0, -1, 30, -1, 32, -1, -1, 33, 34,
+ 31, 36, 55, 35, -1, 33, 56, -1, 38, 33,
+ -1, 53, -1, 38, -1, 24, -1, -1, 25, -1,
+ -1, 36, 37, -1, 37, -1, 54, 33, 56, -1,
+ 39, -1, 40, -1, 41, -1, 43, -1, 44, -1,
+ 45, -1, 16, 4, 22, 8, -1, 16, 4, 8,
+ -1, 15, 4, 47, 8, -1, 15, 4, 47, 48,
+ 8, -1, 13, 4, 42, 8, -1, 13, 4, 42,
+ 49, 8, -1, 22, -1, 14, 4, 22, 8, -1,
+ 11, 4, 22, 8, -1, 46, 8, -1, 46, 3,
+ -1, 3, -1, 22, 26, 22, -1, 12, 50, 48,
+ -1, 12, 50, -1, 12, -1, 12, 51, 49, -1,
+ 12, 51, -1, 12, -1, 22, 10, 52, -1, 22,
+ 10, 52, -1, 22, -1, 21, -1, 27, 21, 27,
+ -1, 7, -1, 18, 8, -1, 19, -1, 23, -1
+};
+
+/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
+static const yytype_uint16 yyrline[] =
+{
+ 0, 114, 114, 116, 121, 120, 133, 141, 143, 167,
+ 171, 186, 190, 193, 197, 199, 203, 218, 220, 230,
+ 232, 234, 236, 250, 257, 276, 284, 294, 300, 308,
+ 331, 338, 345, 349, 351, 355, 364, 366, 368, 382,
+ 384, 386, 400, 431, 445, 451, 466, 474, 481, 500,
+ 519
+};
+#endif
+
+#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
+/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
+ First, the terminals, then, starting at YYNTOKENS, nonterminals. */
+static const char *const yytname[] =
+{
+ "$end", "error", "$undefined", "ANY", "COLON", "DASH", "DQUOTE",
+ "ENDOFHEADERS", "EOL", "EOM", "EQUAL", "MIMEVERSION_HEADER", "SEMICOLON",
+ "CONTENTDISPOSITION_HEADER", "CONTENTENCODING_HEADER",
+ "CONTENTTYPE_HEADER", "MAIL_HEADER", "HEADERVALUE", "BOUNDARY",
+ "ENDBOUNDARY", "CONTENTTYPE_VALUE", "TSPECIAL", "WORD", "BODY",
+ "PREAMBLE", "POSTAMBLE", "'/'", "'\"'", "$accept", "message",
+ "multipart_message", "@1", "singlepart_message", "headers", "preamble",
+ "postamble", "mimeparts", "mimepart", "header", "mail_header",
+ "contenttype_header", "contentdisposition_header", "content_disposition",
+ "contentencoding_header", "mimeversion_header", "invalid_header", "any",
+ "mimetype", "contenttype_parameters", "content_disposition_parameters",
+ "contenttype_parameter", "content_disposition_parameter",
+ "contenttype_parameter_value", "end_headers", "boundary", "endboundary",
+ "body", 0
+};
+#endif
+
+# ifdef YYPRINT
+/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
+ token YYLEX-NUM. */
+static const yytype_uint16 yytoknum[] =
+{
+ 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
+ 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
+ 275, 276, 277, 278, 279, 280, 47, 34
+};
+# endif
+
+/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
+static const yytype_uint8 yyr1[] =
+{
+ 0, 28, 29, 29, 31, 30, 32, 33, 33, 33,
+ 34, 34, 35, 35, 36, 36, 37, 38, 38, 38,
+ 38, 38, 38, 39, 39, 40, 40, 41, 41, 42,
+ 43, 44, 45, 46, 46, 47, 48, 48, 48, 49,
+ 49, 49, 50, 51, 52, 52, 52, 53, 54, 55,
+ 56
+};
+
+/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
+static const yytype_uint8 yyr2[] =
+{
+ 0, 2, 1, 1, 0, 6, 2, 2, 1, 1,
+ 1, 0, 1, 0, 2, 1, 3, 1, 1, 1,
+ 1, 1, 1, 4, 3, 4, 5, 4, 5, 1,
+ 4, 4, 2, 2, 1, 3, 3, 2, 1, 3,
+ 2, 1, 3, 3, 1, 1, 3, 1, 2, 1,
+ 1
+};
+
+/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
+ STATE-NUM when YYTABLE doesn't specify something else to do. Zero
+ means the default is an error. */
+static const yytype_uint8 yydefact[] =
+{
+ 0, 34, 47, 0, 0, 0, 0, 0, 0, 2,
+ 3, 11, 9, 17, 18, 19, 20, 21, 22, 0,
+ 8, 0, 0, 0, 0, 0, 1, 50, 10, 4,
+ 6, 7, 33, 32, 0, 29, 0, 0, 0, 0,
+ 24, 0, 0, 31, 27, 41, 0, 30, 0, 25,
+ 38, 0, 23, 0, 0, 15, 0, 0, 40, 28,
+ 35, 0, 37, 26, 48, 49, 14, 13, 0, 0,
+ 39, 0, 36, 12, 5, 16, 45, 44, 0, 43,
+ 42, 0, 46
+};
+
+/* YYDEFGOTO[NTERM-NUM]. */
+static const yytype_int8 yydefgoto[] =
+{
+ -1, 8, 9, 42, 10, 11, 29, 74, 54, 55,
+ 12, 13, 14, 15, 36, 16, 17, 18, 19, 39,
+ 51, 46, 62, 58, 79, 20, 56, 67, 30
+};
+
+/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
+ STATE-NUM. */
+#define YYPACT_NINF -20
+static const yytype_int8 yypact[] =
+{
+ 3, -20, -20, 17, 21, 22, 23, 24, 5, -20,
+ -20, -11, 3, -20, -20, -20, -20, -20, -20, 1,
+ -20, 7, 8, 9, 10, -7, -20, -20, -20, -20,
+ -20, -20, -20, -20, 25, -20, -1, 26, 11, 12,
+ -20, 27, 18, -20, -20, 16, 31, -20, 19, -20,
[... 4512 lines stripped ...]
More information about the asterisk-commits
mailing list