[svn-commits] murf: branch group/mime r61638 - /team/group/mime/main/minimime/

svn-commits at lists.digium.com svn-commits at lists.digium.com
Thu Apr 12 20:59:38 MST 2007


Author: murf
Date: Thu Apr 12 22:59:37 2007
New Revision: 61638

URL: http://svn.digium.com/view/asterisk?view=rev&rev=61638
Log:
OK, I got rid rid of the global vars in the mm_ code. But, to do this, I had to get rid of the stuff in mm_init.c; No mm_library_init(), because all it did was init the global vars. The globals were moved the MM_CTX struct, and are just the errno stuff, and the list of codecs. I had to copy the ctx pointer into some substructs in the tree to preserve access to this info, which is used throughout the API. It was a hack job, but it's done. We need to strip out the errno stuff completely, it's pretty useless, and use ast_log to publish errors.

Modified:
    team/group/mime/main/minimime/Makefile
    team/group/mime/main/minimime/lexfix
    team/group/mime/main/minimime/mimeparser.l
    team/group/mime/main/minimime/mimeparser.tab.c
    team/group/mime/main/minimime/mimeparser.y
    team/group/mime/main/minimime/mimeparser.yy.c
    team/group/mime/main/minimime/mm.h
    team/group/mime/main/minimime/mm_codecs.c
    team/group/mime/main/minimime/mm_contenttype.c
    team/group/mime/main/minimime/mm_context.c
    team/group/mime/main/minimime/mm_envelope.c
    team/group/mime/main/minimime/mm_error.c
    team/group/mime/main/minimime/mm_header.c
    team/group/mime/main/minimime/mm_init.c
    team/group/mime/main/minimime/mm_mimepart.c
    team/group/mime/main/minimime/mm_mimeutil.c
    team/group/mime/main/minimime/mm_parse.c
    team/group/mime/main/minimime/mm_util.c
    team/group/mime/main/minimime/mytest.c

Modified: team/group/mime/main/minimime/Makefile
URL: http://svn.digium.com/view/asterisk/team/group/mime/main/minimime/Makefile?view=diff&rev=61638&r1=61637&r2=61638
==============================================================================
--- team/group/mime/main/minimime/Makefile (original)
+++ team/group/mime/main/minimime/Makefile Thu Apr 12 22:59:37 2007
@@ -17,7 +17,6 @@
 MM_SRCS= \
 	mimeparser.tab.c \
 	mimeparser.yy.c \
-	mm_init.c \
 	mm_base64.c \
 	mm_codecs.c \
 	mm_contenttype.c \

Modified: team/group/mime/main/minimime/lexfix
URL: http://svn.digium.com/view/asterisk/team/group/mime/main/minimime/lexfix?view=diff&rev=61638&r1=61637&r2=61638
==============================================================================
--- team/group/mime/main/minimime/lexfix (original)
+++ team/group/mime/main/minimime/lexfix Thu Apr 12 22:59:37 2007
@@ -65,19 +65,4 @@
  
      /* Destroy the main struct (reentrant only). */
      mimeparser_yyfree ( yyscanner , yyscanner );
-@@ -2630,13 +2632,13 @@
- {
- 	if (0)
- 		yy_fatal_error(msg,yyscanner); /* just to avoid a 'defined, but not used' message */
--	printf("The parse is pretty much OVER!\n");
-+	printf("The parse is pretty much OVER (2) [%s]!\n", msg);
- }
- void *yy_fatal_error3( char *msg , void *yyscanner)
- {
- 	if (0)
- 		yy_fatal_error(msg,yyscanner); /* just to avoid a 'defined, but not used' message */
--	printf("The parse is pretty much OVER!\n");
-+	printf("The parse is pretty much OVER (3) [%s] !\n", msg);
- 	return NULL;
- }
  

Modified: team/group/mime/main/minimime/mimeparser.l
URL: http://svn.digium.com/view/asterisk/team/group/mime/main/minimime/mimeparser.l?view=diff&rev=61638&r1=61637&r2=61638
==============================================================================
--- team/group/mime/main/minimime/mimeparser.l (original)
+++ team/group/mime/main/minimime/mimeparser.l Thu Apr 12 22:59:37 2007
@@ -499,12 +499,13 @@
 {
 	if (0)
 		yy_fatal_error(msg,yyscanner); /* just to avoid a 'defined, but not used' message */
-	printf("The parse is pretty much OVER!\n");
-}
+	printf("The parse is pretty much OVER! msg=%s\n", msg);
+}
+
 void *yy_fatal_error3( char *msg , void *yyscanner)
 {
 	if (0)
 		yy_fatal_error(msg,yyscanner); /* just to avoid a 'defined, but not used' message */
-	printf("The parse is pretty much OVER!\n");
+	printf("The parse is pretty much OVER! msg=%s\n", msg);  /* change these to ast_log! */
 	return NULL;
 }

Modified: team/group/mime/main/minimime/mimeparser.tab.c
URL: http://svn.digium.com/view/asterisk/team/group/mime/main/minimime/mimeparser.tab.c?view=diff&rev=61638&r1=61637&r2=61638
==============================================================================
--- team/group/mime/main/minimime/mimeparser.tab.c (original)
+++ team/group/mime/main/minimime/mimeparser.tab.c Thu Apr 12 22:59:37 2007
@@ -1618,7 +1618,7 @@
     {
 
 		if (mm_context_attachpart(pstate->ctx, pstate->current_mimepart) == -1) {
-			mm_errno = MM_ERROR_ERRNO;
+			pstate->ctx->mm_errno = MM_ERROR_ERRNO;
 			return(-1);
 		}	
 
@@ -1644,9 +1644,9 @@
 #line 256 "mimeparser.y"
     {
 		if (pstate->parsemode != MM_PARSE_LOOSE) {
-			mm_errno = MM_ERROR_PARSE;
-			mm_error_setmsg("invalid header encountered");
-			mm_error_setlineno(pstate->lstate.lineno);
+			pstate->ctx->mm_errno = MM_ERROR_PARSE;
+			mm_error_setmsg(pstate->ctx, "invalid header encountered");
+			mm_error_setlineno(pstate->ctx, pstate->lstate.lineno);
 			return(-1);
 		} else {
 			/* TODO: attach MM_WARNING_INVHDR */
@@ -1671,9 +1671,9 @@
 		struct mm_mimeheader *hdr;
 
 		if (pstate->parsemode != MM_PARSE_LOOSE) {
-			mm_errno = MM_ERROR_MIME;
-			mm_error_setmsg("invalid header encountered");
-			mm_error_setlineno(pstate->lstate.lineno);
+			pstate->ctx->mm_errno = MM_ERROR_MIME;
+			mm_error_setmsg(pstate->ctx, "invalid header encountered");
+			mm_error_setlineno(pstate->ctx, pstate->lstate.lineno);
 			return(-1);
 		} else {
 			/* TODO: attach MM_WARNING_INVHDR */
@@ -1739,8 +1739,8 @@
 		if (strcasecmp((yyvsp[(1) - (1)].string), "inline") && strcasecmp((yyvsp[(1) - (1)].string), "attachment")
 		    && strncasecmp((yyvsp[(1) - (1)].string), "X-", 2)) {
 			if (pstate->parsemode != MM_PARSE_LOOSE) {
-				mm_errno = MM_ERROR_MIME;
-				mm_error_setmsg("invalid content-disposition");
+				pstate->ctx->mm_errno = MM_ERROR_MIME;
+				mm_error_setmsg(pstate->ctx, "invalid content-disposition");
 				return(-1);
 			}	
 		} else {
@@ -1785,9 +1785,9 @@
 #line 405 "mimeparser.y"
     {
 		if (pstate->parsemode != MM_PARSE_LOOSE) {
-			mm_errno = MM_ERROR_MIME;
-			mm_error_setmsg("invalid Content-Type header");
-			mm_error_setlineno(pstate->lstate.lineno);
+			pstate->ctx->mm_errno = MM_ERROR_MIME;
+			mm_error_setmsg(pstate->ctx, "invalid Content-Type header");
+			mm_error_setlineno(pstate->ctx, pstate->lstate.lineno);
 			return(-1);
 		} else {
 			/* TODO: attach MM_WARNING_INVHDR */
@@ -1799,9 +1799,9 @@
 #line 423 "mimeparser.y"
     {	
 		if (pstate->parsemode != MM_PARSE_LOOSE) {
-			mm_errno = MM_ERROR_MIME;
-			mm_error_setmsg("invalid Content-Disposition header");
-			mm_error_setlineno(pstate->lstate.lineno);
+			pstate->ctx->mm_errno = MM_ERROR_MIME;
+			mm_error_setmsg(pstate->ctx, "invalid Content-Disposition header");
+			mm_error_setlineno(pstate->ctx, pstate->lstate.lineno);
 			return(-1);
 		} else {
 			/* TODO: attach MM_WARNING_INVHDR */
@@ -1823,8 +1823,8 @@
 				set_boundary((yyvsp[(3) - (3)].string),pstate);
 			} else {
 				if (pstate->parsemode != MM_PARSE_LOOSE) {
-					mm_errno = MM_ERROR_MIME;
-					mm_error_setmsg("duplicate boundary "
+					pstate->ctx->mm_errno = MM_ERROR_MIME;
+					mm_error_setmsg(pstate->ctx, "duplicate boundary "
 					    "found");
 					return -1;
 				} else {
@@ -1868,9 +1868,9 @@
 		dprintf2(pstate,"contenttype_param_val: TSPECIAL\n");
 		/* For broken MIME implementation */
 		if (pstate->parsemode != MM_PARSE_LOOSE) {
-			mm_errno = MM_ERROR_MIME;
-			mm_error_setmsg("tspecial without quotes");
-			mm_error_setlineno(pstate->lstate.lineno);
+			pstate->ctx->mm_errno = MM_ERROR_MIME;
+			mm_error_setmsg(pstate->ctx, "tspecial without quotes");
+			mm_error_setlineno(pstate->ctx, pstate->lstate.lineno);
 			return(-1);
 		} else {
 			/* TODO: attach MM_WARNING_INVAL */
@@ -1898,15 +1898,15 @@
 #line 518 "mimeparser.y"
     {
 		if (pstate->lstate.boundary_string == NULL) {
-			mm_errno = MM_ERROR_PARSE;
-			mm_error_setmsg("internal incosistency");
-			mm_error_setlineno(pstate->lstate.lineno);
+			pstate->ctx->mm_errno = MM_ERROR_PARSE;
+			mm_error_setmsg(pstate->ctx, "internal incosistency");
+			mm_error_setlineno(pstate->ctx, pstate->lstate.lineno);
 			return(-1);
 		}
 		if (strcmp(pstate->lstate.boundary_string, (yyvsp[(1) - (2)].string))) {
-			mm_errno = MM_ERROR_PARSE;
-			mm_error_setmsg("invalid boundary: '%s' (%d)", (yyvsp[(1) - (2)].string), strlen((yyvsp[(1) - (2)].string)));
-			mm_error_setlineno(pstate->lstate.lineno);
+			pstate->ctx->mm_errno = MM_ERROR_PARSE;
+			mm_error_setmsg(pstate->ctx, "invalid boundary: '%s' (%d)", (yyvsp[(1) - (2)].string), strlen((yyvsp[(1) - (2)].string)));
+			mm_error_setlineno(pstate->ctx, pstate->lstate.lineno);
 			return(-1);
 		}
 		dprintf2(pstate,"New MIME part... (%s)\n", (yyvsp[(1) - (2)].string));
@@ -1920,15 +1920,15 @@
 #line 540 "mimeparser.y"
     {
 		if (pstate->lstate.endboundary_string == NULL) {
-			mm_errno = MM_ERROR_PARSE;
-			mm_error_setmsg("internal incosistency");
-			mm_error_setlineno(pstate->lstate.lineno);
+			pstate->ctx->mm_errno = MM_ERROR_PARSE;
+			mm_error_setmsg(pstate->ctx, "internal incosistency");
+			mm_error_setlineno(pstate->ctx, pstate->lstate.lineno);
 			return(-1);
 		}
 		if (strcmp(pstate->lstate.endboundary_string, (yyvsp[(1) - (1)].string))) {
-			mm_errno = MM_ERROR_PARSE;
-			mm_error_setmsg("invalid end boundary: %s", (yyvsp[(1) - (1)].string));
-			mm_error_setlineno(pstate->lstate.lineno);
+			pstate->ctx->mm_errno = MM_ERROR_PARSE;
+			mm_error_setmsg(pstate->ctx, "invalid end boundary: %s", (yyvsp[(1) - (1)].string));
+			mm_error_setlineno(pstate->ctx, pstate->lstate.lineno);
 			return(-1);
 		}
 		dprintf2(pstate,"End of MIME message\n");
@@ -2195,8 +2195,8 @@
 		/* Multipart message */
 		if (real_start) {
 			if (real_start < opaque_start) {
-				mm_errno = MM_ERROR_PARSE;
-				mm_error_setmsg("internal incosistency (S:%d/O:%d)",
+				pstate->ctx->mm_errno = MM_ERROR_PARSE;
+				mm_error_setmsg(pstate->ctx, "internal incosistency (S:%d/O:%d)",
 				    real_start,
 				    opaque_start);
 				return(NULL);
@@ -2215,21 +2215,21 @@
 
 	/* The next three cases should NOT happen anytime */
 	if (end <= start) {
-		mm_errno = MM_ERROR_PARSE;
-		mm_error_setmsg("internal incosistency,2");
-		mm_error_setlineno(pstate->lstate.lineno);
+		pstate->ctx->mm_errno = MM_ERROR_PARSE;
+		mm_error_setmsg(pstate->ctx, "internal incosistency,2");
+		mm_error_setlineno(pstate->ctx, pstate->lstate.lineno);
 		return(NULL);
 	}
 	if (start < *offset) {
-		mm_errno = MM_ERROR_PARSE;
-		mm_error_setmsg("internal incosistency, S:%d,O:%d,L:%d", start, offset, pstate->lstate.lineno);
-		mm_error_setlineno(pstate->lstate.lineno);
+		pstate->ctx->mm_errno = MM_ERROR_PARSE;
+		mm_error_setmsg(pstate->ctx, "internal incosistency, S:%d,O:%d,L:%d", start, offset, pstate->lstate.lineno);
+		mm_error_setlineno(pstate->ctx, pstate->lstate.lineno);
 		return(NULL);
 	}	
 	if (start < 0 || end < 0) {
-		mm_errno = MM_ERROR_PARSE;
-		mm_error_setmsg("internal incosistency,4");
-		mm_error_setlineno(pstate->lstate.lineno);
+		pstate->ctx->mm_errno = MM_ERROR_PARSE;
+		mm_error_setmsg(pstate->ctx, "internal incosistency,4");
+		mm_error_setlineno(pstate->ctx, pstate->lstate.lineno);
 		return(NULL);
 	}	
 
@@ -2240,15 +2240,15 @@
 	body_size = end - start;
 
 	if (body_size < 1) {
-		mm_errno = MM_ERROR_PARSE;
-		mm_error_setmsg("size of body cannot be < 1");
-		mm_error_setlineno(pstate->lstate.lineno);
+		pstate->ctx->mm_errno = MM_ERROR_PARSE;
+		mm_error_setmsg(pstate->ctx, "size of body cannot be < 1");
+		mm_error_setlineno(pstate->ctx, pstate->lstate.lineno);
 		return(NULL);
 	}	
 	
 	body = (char *)malloc(body_size + 1);
 	if (body == NULL) {
-		mm_errno = MM_ERROR_ERRNO;
+		pstate->ctx->mm_errno = MM_ERROR_ERRNO;
 		return(NULL);
 	}	
 		
@@ -2272,9 +2272,9 @@
 int
 yyerror(struct parser_state *pstate, void *yyscanner, const char *str)
 {
-	mm_errno = MM_ERROR_PARSE;
-	mm_error_setmsg("%s", str);
-	mm_error_setlineno(pstate->lstate.lineno);
+	pstate->ctx->mm_errno = MM_ERROR_PARSE;
+	mm_error_setmsg(pstate->ctx, "%s", str);
+	mm_error_setlineno(pstate->ctx, pstate->lstate.lineno);
 	return -1;
 }
 

Modified: team/group/mime/main/minimime/mimeparser.y
URL: http://svn.digium.com/view/asterisk/team/group/mime/main/minimime/mimeparser.y?view=diff&rev=61638&r1=61637&r2=61638
==============================================================================
--- team/group/mime/main/minimime/mimeparser.y (original)
+++ team/group/mime/main/minimime/mimeparser.y Thu Apr 12 22:59:37 2007
@@ -223,7 +223,7 @@
 	{
 
 		if (mm_context_attachpart(pstate->ctx, pstate->current_mimepart) == -1) {
-			mm_errno = MM_ERROR_ERRNO;
+			pstate->ctx->mm_errno = MM_ERROR_ERRNO;
 			return(-1);
 		}	
 
@@ -255,9 +255,9 @@
 	invalid_header
 	{
 		if (pstate->parsemode != MM_PARSE_LOOSE) {
-			mm_errno = MM_ERROR_PARSE;
-			mm_error_setmsg("invalid header encountered");
-			mm_error_setlineno(pstate->lstate.lineno);
+			pstate->ctx->mm_errno = MM_ERROR_PARSE;
+			mm_error_setmsg(pstate->ctx, "invalid header encountered");
+			mm_error_setlineno(pstate->ctx, pstate->lstate.lineno);
 			return(-1);
 		} else {
 			/* TODO: attach MM_WARNING_INVHDR */
@@ -280,9 +280,9 @@
 		struct mm_mimeheader *hdr;
 
 		if (pstate->parsemode != MM_PARSE_LOOSE) {
-			mm_errno = MM_ERROR_MIME;
-			mm_error_setmsg("invalid header encountered");
-			mm_error_setlineno(pstate->lstate.lineno);
+			pstate->ctx->mm_errno = MM_ERROR_MIME;
+			mm_error_setmsg(pstate->ctx, "invalid header encountered");
+			mm_error_setlineno(pstate->ctx, pstate->lstate.lineno);
 			return(-1);
 		} else {
 			/* TODO: attach MM_WARNING_INVHDR */
@@ -344,8 +344,8 @@
 		if (strcasecmp($1, "inline") && strcasecmp($1, "attachment")
 		    && strncasecmp($1, "X-", 2)) {
 			if (pstate->parsemode != MM_PARSE_LOOSE) {
-				mm_errno = MM_ERROR_MIME;
-				mm_error_setmsg("invalid content-disposition");
+				pstate->ctx->mm_errno = MM_ERROR_MIME;
+				mm_error_setmsg(pstate->ctx, "invalid content-disposition");
 				return(-1);
 			}	
 		} else {
@@ -404,9 +404,9 @@
 	SEMICOLON
 	{
 		if (pstate->parsemode != MM_PARSE_LOOSE) {
-			mm_errno = MM_ERROR_MIME;
-			mm_error_setmsg("invalid Content-Type header");
-			mm_error_setlineno(pstate->lstate.lineno);
+			pstate->ctx->mm_errno = MM_ERROR_MIME;
+			mm_error_setmsg(pstate->ctx, "invalid Content-Type header");
+			mm_error_setlineno(pstate->ctx, pstate->lstate.lineno);
 			return(-1);
 		} else {
 			/* TODO: attach MM_WARNING_INVHDR */
@@ -422,9 +422,9 @@
 	SEMICOLON
 	{	
 		if (pstate->parsemode != MM_PARSE_LOOSE) {
-			mm_errno = MM_ERROR_MIME;
-			mm_error_setmsg("invalid Content-Disposition header");
-			mm_error_setlineno(pstate->lstate.lineno);
+			pstate->ctx->mm_errno = MM_ERROR_MIME;
+			mm_error_setmsg(pstate->ctx, "invalid Content-Disposition header");
+			mm_error_setlineno(pstate->ctx, pstate->lstate.lineno);
 			return(-1);
 		} else {
 			/* TODO: attach MM_WARNING_INVHDR */
@@ -446,8 +446,8 @@
 				set_boundary($3,pstate);
 			} else {
 				if (pstate->parsemode != MM_PARSE_LOOSE) {
-					mm_errno = MM_ERROR_MIME;
-					mm_error_setmsg("duplicate boundary "
+					pstate->ctx->mm_errno = MM_ERROR_MIME;
+					mm_error_setmsg(pstate->ctx, "duplicate boundary "
 					    "found");
 					return -1;
 				} else {
@@ -489,9 +489,9 @@
 		dprintf2(pstate,"contenttype_param_val: TSPECIAL\n");
 		/* For broken MIME implementation */
 		if (pstate->parsemode != MM_PARSE_LOOSE) {
-			mm_errno = MM_ERROR_MIME;
-			mm_error_setmsg("tspecial without quotes");
-			mm_error_setlineno(pstate->lstate.lineno);
+			pstate->ctx->mm_errno = MM_ERROR_MIME;
+			mm_error_setmsg(pstate->ctx, "tspecial without quotes");
+			mm_error_setlineno(pstate->ctx, pstate->lstate.lineno);
 			return(-1);
 		} else {
 			/* TODO: attach MM_WARNING_INVAL */
@@ -517,15 +517,15 @@
 	BOUNDARY EOL
 	{
 		if (pstate->lstate.boundary_string == NULL) {
-			mm_errno = MM_ERROR_PARSE;
-			mm_error_setmsg("internal incosistency");
-			mm_error_setlineno(pstate->lstate.lineno);
+			pstate->ctx->mm_errno = MM_ERROR_PARSE;
+			mm_error_setmsg(pstate->ctx, "internal incosistency");
+			mm_error_setlineno(pstate->ctx, pstate->lstate.lineno);
 			return(-1);
 		}
 		if (strcmp(pstate->lstate.boundary_string, $1)) {
-			mm_errno = MM_ERROR_PARSE;
-			mm_error_setmsg("invalid boundary: '%s' (%d)", $1, strlen($1));
-			mm_error_setlineno(pstate->lstate.lineno);
+			pstate->ctx->mm_errno = MM_ERROR_PARSE;
+			mm_error_setmsg(pstate->ctx, "invalid boundary: '%s' (%d)", $1, strlen($1));
+			mm_error_setlineno(pstate->ctx, pstate->lstate.lineno);
 			return(-1);
 		}
 		dprintf2(pstate,"New MIME part... (%s)\n", $1);
@@ -539,15 +539,15 @@
 	ENDBOUNDARY
 	{
 		if (pstate->lstate.endboundary_string == NULL) {
-			mm_errno = MM_ERROR_PARSE;
-			mm_error_setmsg("internal incosistency");
-			mm_error_setlineno(pstate->lstate.lineno);
+			pstate->ctx->mm_errno = MM_ERROR_PARSE;
+			mm_error_setmsg(pstate->ctx, "internal incosistency");
+			mm_error_setlineno(pstate->ctx, pstate->lstate.lineno);
 			return(-1);
 		}
 		if (strcmp(pstate->lstate.endboundary_string, $1)) {
-			mm_errno = MM_ERROR_PARSE;
-			mm_error_setmsg("invalid end boundary: %s", $1);
-			mm_error_setlineno(pstate->lstate.lineno);
+			pstate->ctx->mm_errno = MM_ERROR_PARSE;
+			mm_error_setmsg(pstate->ctx, "invalid end boundary: %s", $1);
+			mm_error_setlineno(pstate->ctx, pstate->lstate.lineno);
 			return(-1);
 		}
 		dprintf2(pstate,"End of MIME message\n");
@@ -597,8 +597,8 @@
 		/* Multipart message */
 		if (real_start) {
 			if (real_start < opaque_start) {
-				mm_errno = MM_ERROR_PARSE;
-				mm_error_setmsg("internal incosistency (S:%d/O:%d)",
+				pstate->ctx->mm_errno = MM_ERROR_PARSE;
+				mm_error_setmsg(pstate->ctx, "internal incosistency (S:%d/O:%d)",
 				    real_start,
 				    opaque_start);
 				return(NULL);
@@ -617,21 +617,21 @@
 
 	/* The next three cases should NOT happen anytime */
 	if (end <= start) {
-		mm_errno = MM_ERROR_PARSE;
-		mm_error_setmsg("internal incosistency,2");
-		mm_error_setlineno(pstate->lstate.lineno);
+		pstate->ctx->mm_errno = MM_ERROR_PARSE;
+		mm_error_setmsg(pstate->ctx, "internal incosistency,2");
+		mm_error_setlineno(pstate->ctx, pstate->lstate.lineno);
 		return(NULL);
 	}
 	if (start < *offset) {
-		mm_errno = MM_ERROR_PARSE;
-		mm_error_setmsg("internal incosistency, S:%d,O:%d,L:%d", start, offset, pstate->lstate.lineno);
-		mm_error_setlineno(pstate->lstate.lineno);
+		pstate->ctx->mm_errno = MM_ERROR_PARSE;
+		mm_error_setmsg(pstate->ctx, "internal incosistency, S:%d,O:%d,L:%d", start, offset, pstate->lstate.lineno);
+		mm_error_setlineno(pstate->ctx, pstate->lstate.lineno);
 		return(NULL);
 	}	
 	if (start < 0 || end < 0) {
-		mm_errno = MM_ERROR_PARSE;
-		mm_error_setmsg("internal incosistency,4");
-		mm_error_setlineno(pstate->lstate.lineno);
+		pstate->ctx->mm_errno = MM_ERROR_PARSE;
+		mm_error_setmsg(pstate->ctx, "internal incosistency,4");
+		mm_error_setlineno(pstate->ctx, pstate->lstate.lineno);
 		return(NULL);
 	}	
 
@@ -642,15 +642,15 @@
 	body_size = end - start;
 
 	if (body_size < 1) {
-		mm_errno = MM_ERROR_PARSE;
-		mm_error_setmsg("size of body cannot be < 1");
-		mm_error_setlineno(pstate->lstate.lineno);
+		pstate->ctx->mm_errno = MM_ERROR_PARSE;
+		mm_error_setmsg(pstate->ctx, "size of body cannot be < 1");
+		mm_error_setlineno(pstate->ctx, pstate->lstate.lineno);
 		return(NULL);
 	}	
 	
 	body = (char *)malloc(body_size + 1);
 	if (body == NULL) {
-		mm_errno = MM_ERROR_ERRNO;
+		pstate->ctx->mm_errno = MM_ERROR_ERRNO;
 		return(NULL);
 	}	
 		
@@ -674,9 +674,9 @@
 int
 yyerror(struct parser_state *pstate, void *yyscanner, const char *str)
 {
-	mm_errno = MM_ERROR_PARSE;
-	mm_error_setmsg("%s", str);
-	mm_error_setlineno(pstate->lstate.lineno);
+	pstate->ctx->mm_errno = MM_ERROR_PARSE;
+	mm_error_setmsg(pstate->ctx, "%s", str);
+	mm_error_setlineno(pstate->ctx, pstate->lstate.lineno);
 	return -1;
 }
 

Modified: team/group/mime/main/minimime/mimeparser.yy.c
URL: http://svn.digium.com/view/asterisk/team/group/mime/main/minimime/mimeparser.yy.c?view=diff&rev=61638&r1=61637&r2=61638
==============================================================================
--- team/group/mime/main/minimime/mimeparser.yy.c (original)
+++ team/group/mime/main/minimime/mimeparser.yy.c Thu Apr 12 22:59:37 2007
@@ -800,9 +800,7 @@
 			{ \
 			if( errno != EINTR) \
 				{ \
-					char x[1000];				\
-					sprintf(x,"Input in flex scanner failed; Errno=%d\n", errno); \
-				YY_FATAL_ERROR( x ); \
+				YY_FATAL_ERROR( "input in flex scanner failed" ); \
 				break; \
 				} \
 			errno=0; \
@@ -2634,13 +2632,14 @@
 {
 	if (0)
 		yy_fatal_error(msg,yyscanner); /* just to avoid a 'defined, but not used' message */
-	printf("The parse is pretty much OVER (2) [%s]!\n", msg);
-}
+	printf("The parse is pretty much OVER! msg=%s\n", msg);
+}
+
 void *yy_fatal_error3( char *msg , void *yyscanner)
 {
 	if (0)
 		yy_fatal_error(msg,yyscanner); /* just to avoid a 'defined, but not used' message */
-	printf("The parse is pretty much OVER (3) [%s] !\n", msg);
+	printf("The parse is pretty much OVER! msg=%s\n", msg);  /* change these to ast_log! */
 	return NULL;
 }
 

Modified: team/group/mime/main/minimime/mm.h
URL: http://svn.digium.com/view/asterisk/team/group/mime/main/minimime/mm.h?view=diff&rev=61638&r1=61637&r2=61638
==============================================================================
--- team/group/mime/main/minimime/mm.h (original)
+++ team/group/mime/main/minimime/mm.h Thu Apr 12 22:59:37 2007
@@ -140,8 +140,8 @@
 	char error_msg[128];
 };
 
-extern int mm_errno;
-extern struct mm_error_data mm_error;
+/* extern int mm_errno;
+   extern struct mm_error_data mm_error; */
 
 enum mm_warning_code
 {
@@ -211,6 +211,8 @@
 
 	char *encstring;
 	enum mm_encoding encoding;
+
+	struct mm_context *ctx; /* a dad ptr so we get at the codecs & error info */
 };
 
 /*
@@ -222,9 +224,11 @@
 	
 	size_t opaque_length;
 	char *opaque_body;
-
+	
 	size_t length;
 	char *body;
+
+	struct mm_context *ctx; /* a dad ptr */
 
 	struct mm_content *type;
 
@@ -241,6 +245,8 @@
 	struct mm_warnings warnings;
 	struct mm_codecs codecs;
 	char *boundary;
+	int mm_errno;
+	struct mm_error_data mm_error;
 	char *preamble;
 	size_t max_message_size;
 };
@@ -249,15 +255,12 @@
 typedef struct mm_context mm_ctx_t;
 
 char *mm_unquote(const char *);
-char *mm_uncomment(const char *);
+char *mm_uncomment(MM_CTX *ctx, const char *);
 char *mm_stripchars(char *, char *);
 char *mm_addchars(char *, char *, u_int16_t);
 int mm_gendate(char **);
 void mm_striptrailing(char **, const char *);
 int mm_mimeutil_genboundary(char *, size_t, char **);
-
-int mm_library_init(void);
-int mm_library_isinitialized(void);
 
 int mm_parse_mem(MM_CTX *, const char *, int, int);
 int mm_parse_file(MM_CTX *, const char *, int, int);
@@ -279,7 +282,7 @@
 struct mm_mimeheader *mm_mimeheader_new(void);
 void mm_mimeheader_free(struct mm_mimeheader *);
 struct mm_mimeheader *mm_mimeheader_generate(const char *, const char *);
-int mm_mimeheader_uncomment(struct mm_mimeheader *);
+int mm_mimeheader_uncomment(MM_CTX *, struct mm_mimeheader *);
 int mm_mimeheader_uncommentbyname(struct mm_mimepart *, const char *);
 int mm_mimeheader_uncommentall(struct mm_mimepart *);
 int mm_mimeheader_tostring(struct mm_mimeheader *);
@@ -334,22 +337,22 @@
 char *mm_flatten_mimepart(struct mm_mimepart *);
 char *mm_flatten_context(MM_CTX *);
 
-int mm_codec_isregistered(const char *);
-int mm_codec_hasdecoder(const char *);
-int mm_codec_hasencoder(const char *);
-int mm_codec_register(const char *, char *(*encoder)(char *, u_int32_t), char *(*decoder)(char *));
-int mm_codec_unregister(const char *);
-int mm_codec_unregisterall(void);
-void mm_codec_registerdefaultcodecs(void);
+int mm_codec_isregistered(MM_CTX *, const char *);
+int mm_codec_hasdecoder(MM_CTX *, const char *);
+int mm_codec_hasencoder(MM_CTX *, const char *);
+int mm_codec_register(MM_CTX *, const char *, char *(*encoder)(char *, u_int32_t), char *(*decoder)(char *));
+int mm_codec_unregister(MM_CTX *, const char *);
+int mm_codec_unregisterall(MM_CTX *);
+void mm_codec_registerdefaultcodecs(MM_CTX *);
 
 char *mm_base64_decode(char *);
 char *mm_base64_encode(char *, u_int32_t);
 
-void mm_error_init(void);
-void mm_error_setmsg(const char *, ...);
-void mm_error_setlineno(int lineno);
-char *mm_error_string(void);
-int mm_error_lineno(void);
+void mm_error_init(MM_CTX *);
+void mm_error_setmsg(MM_CTX *, const char *, ...);
+void mm_error_setlineno(MM_CTX *, int lineno);
+char *mm_error_string(MM_CTX *);
+int mm_error_lineno(MM_CTX *);
 
 void mm_warning_add(MM_CTX *, int, const char *, ...);
 struct mm_warning *mm_warning_next(MM_CTX *, struct mm_warning **);
@@ -361,8 +364,4 @@
 size_t strlcat(char *, const char *, size_t);
 #endif /* ! HAVE_STRLCAT */
 
-#define MM_ISINIT() do { \
-	assert(mm_library_isinitialized() == 1); \
-} while (0);
-
 #endif /* ! _MM_H_INCLUDED */

Modified: team/group/mime/main/minimime/mm_codecs.c
URL: http://svn.digium.com/view/asterisk/team/group/mime/main/minimime/mm_codecs.c?view=diff&rev=61638&r1=61637&r2=61638
==============================================================================
--- team/group/mime/main/minimime/mm_codecs.c (original)
+++ team/group/mime/main/minimime/mm_codecs.c Thu Apr 12 22:59:37 2007
@@ -43,8 +43,6 @@
 #include "mm_internal.h"
 #include "mm_util.h"
 
-extern struct mm_codecs codecs;
-
 /** @file mm_codecs.c
  *
  * This module contains functions to manipulate MiniMIME codecs
@@ -65,13 +63,13 @@
  * @ingroup codecs
  */
 int
-mm_codec_hasdecoder(const char *encoding)
-{
-	struct mm_codec *codec;
-
-	assert(encoding != NULL);
-
-	SLIST_FOREACH(codec, &codecs, next) {
+mm_codec_hasdecoder(MM_CTX *ctx, const char *encoding)
+{
+	struct mm_codec *codec;
+
+	assert(encoding != NULL);
+
+	SLIST_FOREACH(codec, &ctx->codecs, next) {
 		assert(codec->encoding != NULL);
 		if (!strcasecmp(codec->encoding, encoding)) {
 			if (codec->decoder != NULL)
@@ -93,13 +91,13 @@
  * @ingroup codecs
  */
 int
-mm_codec_hasencoder(const char *encoding)
-{
-	struct mm_codec *codec;
-
-	assert(encoding != NULL);
-
-	SLIST_FOREACH(codec, &codecs, next) {
+mm_codec_hasencoder(MM_CTX *ctx, const char *encoding)
+{
+	struct mm_codec *codec;
+
+	assert(encoding != NULL);
+
+	SLIST_FOREACH(codec, &ctx->codecs, next) {
 		assert(codec->encoding != NULL);
 		if (!strcasecmp(codec->encoding, encoding)) {
 			if (codec->encoder != NULL)
@@ -120,13 +118,13 @@
  * @ingroup codecs
  */
 int
-mm_codec_isregistered(const char *encoding)
-{
-	struct mm_codec *codec;
-
-	assert(encoding != NULL);
-
-	SLIST_FOREACH(codec, &codecs, next) {
+mm_codec_isregistered(MM_CTX *ctx, const char *encoding)
+{
+	struct mm_codec *codec;
+
+	assert(encoding != NULL);
+
+	SLIST_FOREACH(codec, &ctx->codecs, next) {
 		if (!strcasecmp(codec->encoding, encoding)) {
 			return 1;
 		}
@@ -149,7 +147,7 @@
  * a codec already installed for this encoding, the function will puke.
  */
 int
-mm_codec_register(const char *encoding, 
+mm_codec_register(MM_CTX *ctx, const char *encoding, 
     char *(*encoder)(char *data, u_int32_t i),
     char *(*decoder)(char *data))
 {
@@ -157,7 +155,7 @@
 
 	assert(encoding != NULL);
 
-	assert(mm_codec_isregistered(encoding) != 1);
+	assert(mm_codec_isregistered(ctx,encoding) != 1);
 	
 	codec = (struct mm_codec *)xmalloc(sizeof(struct mm_codec));
 
@@ -165,13 +163,13 @@
 	codec->encoder = encoder;
 	codec->decoder = decoder;
 
-	if (SLIST_EMPTY(&codecs)) {
-		SLIST_INSERT_HEAD(&codecs, codec, next);
+	if (SLIST_EMPTY(&ctx->codecs)) {
+		SLIST_INSERT_HEAD(&ctx->codecs, codec, next);
 		return 1;
 	} else {
 		struct mm_codec *lcodec, *tcodec;
 		tcodec = NULL;
-		SLIST_FOREACH(lcodec, &codecs, next) {
+		SLIST_FOREACH(lcodec, &ctx->codecs, next) {
 			if (lcodec != NULL)
 				tcodec = lcodec;
 		}
@@ -191,13 +189,13 @@
  * @ingroup codecs
  */
 int
-mm_codec_unregister(const char *encoding)
-{
-	struct mm_codec *codec;
-
-	assert(encoding != NULL);
-
-	SLIST_FOREACH(codec, &codecs, next) {
+mm_codec_unregister(MM_CTX *ctx, const char *encoding)
+{
+	struct mm_codec *codec;
+
+	assert(encoding != NULL);
+
+	SLIST_FOREACH(codec, &ctx->codecs, next) {
 		if (!strcasecmp(codec->encoding, encoding)) {
 			xfree(codec->encoding);
 			xfree(codec);
@@ -218,12 +216,12 @@
  * @note Foobar
  */ 
 int
-mm_codec_unregisterall(void) 
-{
-	struct mm_codec *codec;
-
-	SLIST_FOREACH(codec, &codecs, next) {
-		if (mm_codec_unregister(codec->encoding) == -1) {
+mm_codec_unregisterall(MM_CTX *ctx) 
+{
+	struct mm_codec *codec;
+
+	SLIST_FOREACH(codec, &ctx->codecs, next) {
+		if (mm_codec_unregister(ctx, codec->encoding) == -1) {
 			return -1;
 		}
 	}
@@ -241,9 +239,9 @@
  *	- (TODO:) Quoted-Printable
  */
 void
-mm_codec_registerdefaultcodecs(void)
-{
-	mm_codec_register("base64", mm_base64_encode, mm_base64_decode);
+mm_codec_registerdefaultcodecs(MM_CTX *ctx)
+{
+	mm_codec_register(ctx, "base64", mm_base64_encode, mm_base64_decode);
 }
 
 

Modified: team/group/mime/main/minimime/mm_contenttype.c
URL: http://svn.digium.com/view/asterisk/team/group/mime/main/minimime/mm_contenttype.c?view=diff&rev=61638&r1=61637&r2=61638
==============================================================================
--- team/group/mime/main/minimime/mm_contenttype.c (original)
+++ team/group/mime/main/minimime/mm_contenttype.c Thu Apr 12 22:59:37 2007
@@ -103,7 +103,7 @@
 
 	ct->encoding = MM_ENCODING_NONE;
 	ct->encstring = NULL;
-
+	
 	return ct;
 }
 
@@ -425,13 +425,11 @@
 	char buf[512], *parse;
 	va_list ap;
 	
-	mm_errno = MM_ERROR_NONE;
-	
 	va_start(ap, fmt);
 	/* Make sure no truncation occurs */
 	if (vsnprintf(buf, sizeof buf, fmt, ap) > sizeof buf) {
-		mm_errno = MM_ERROR_ERRNO;
-		mm_error_setmsg("Input string too long");
+		ct->ctx->mm_errno = MM_ERROR_ERRNO;
+		mm_error_setmsg(ct->ctx, "Input string too long");
 		return -1;
 	}
 	va_end(ap);
@@ -439,16 +437,16 @@
 	parse = buf;
 	maint = strsep(&parse, "/");
 	if (maint == NULL) {
-		mm_errno = MM_ERROR_PARSE;
-		mm_error_setmsg("Invalid type specifier: %s", buf);
+		ct->ctx->mm_errno = MM_ERROR_PARSE;
+		mm_error_setmsg(ct->ctx, "Invalid type specifier: %s", buf);
 		return -1;
 	}
 	ct->maintype = xstrdup(maint);
 
 	subt = strsep(&parse, "");
 	if (subt == NULL) {
-		mm_errno = MM_ERROR_PARSE;
-		mm_error_setmsg("Invalid type specifier: %s", buf);
+		ct->ctx->mm_errno = MM_ERROR_PARSE;
+		mm_error_setmsg(ct->ctx, "Invalid type specifier: %s", buf);
 		return -1;
 	}
 	ct->subtype = xstrdup(subt);

Modified: team/group/mime/main/minimime/mm_context.c
URL: http://svn.digium.com/view/asterisk/team/group/mime/main/minimime/mm_context.c?view=diff&rev=61638&r1=61637&r2=61638
==============================================================================
--- team/group/mime/main/minimime/mm_context.c (original)
+++ team/group/mime/main/minimime/mm_context.c Thu Apr 12 22:59:37 2007
@@ -74,13 +74,16 @@
 {
 	MM_CTX *ctx;
 
-	MM_ISINIT();
-
 	ctx = (MM_CTX *)xmalloc(sizeof(MM_CTX));
 	ctx->messagetype = MM_MSGTYPE_FLAT; /* This is the default */
 	ctx->boundary = NULL;
 	ctx->preamble = xstrdup("This is a message in MIME format, generated "
 	    "by MiniMIME 0.1");
+
+	SLIST_INIT(&ctx->codecs);
+
+	ctx->mm_errno = MM_ERROR_NONE;
+	mm_error_init(ctx);
 
 	TAILQ_INIT(&ctx->parts);
 	SLIST_INIT(&ctx->warnings);
@@ -154,6 +157,8 @@
 {
 	assert(ctx != NULL);
 	assert(part != NULL);
+	
+	part->ctx = ctx; /* a dad ptr so we can use the error & codec stuff there */
 	
 	if (TAILQ_EMPTY(&ctx->parts)) {
 		TAILQ_INSERT_HEAD(&ctx->parts, part, next);
@@ -452,7 +457,7 @@
 	size_t tmp_size;
 	char envelope;
 
-	mm_errno = MM_ERROR_NONE;
+	ctx->mm_errno = MM_ERROR_NONE;
 	envelope = 1;
 
 	message = NULL;
@@ -469,7 +474,7 @@
 			if (flags & MM_FLATTEN_SKIPENVELOPE) {
 				envelope = 0;
 				if ((message = (char *) malloc(1)) == NULL) {
-					mm_errno = MM_ERROR_ERRNO;
+					ctx->mm_errno = MM_ERROR_ERRNO;
 					goto cleanup;
 				}
 				*message = '\0';

Modified: team/group/mime/main/minimime/mm_envelope.c
URL: http://svn.digium.com/view/asterisk/team/group/mime/main/minimime/mm_envelope.c?view=diff&rev=61638&r1=61637&r2=61638
==============================================================================
--- team/group/mime/main/minimime/mm_envelope.c (original)
+++ team/group/mime/main/minimime/mm_envelope.c Thu Apr 12 22:59:37 2007
@@ -95,7 +95,6 @@
 
 	/* Initialize our buffer */
 	if ((buf = (char *)xmalloc(headers_length)) == NULL) {
-		mm_errno = MM_ERROR_ERRNO;
 		goto cleanup;
 	}	
 	*buf = '\0';
@@ -106,7 +105,7 @@
 		    + strlen(": \r\n");
 		hdrbuf = (char *) xrealloc(buf, headers_length + tmp_length);
 		if (hdrbuf == NULL) {
-			mm_errno = MM_ERROR_ERRNO;
+			ctx->mm_errno = MM_ERROR_ERRNO;
 			goto cleanup;
 		}
 
@@ -130,7 +129,7 @@
 
 		hdrbuf = (char *) xrealloc(buf, headers_length + tmp_length);
 		if (hdrbuf == NULL) {
-			mm_errno = MM_ERROR_ERRNO;
+			ctx->mm_errno = MM_ERROR_ERRNO;
 			goto cleanup;
 		}
 

Modified: team/group/mime/main/minimime/mm_error.c
URL: http://svn.digium.com/view/asterisk/team/group/mime/main/minimime/mm_error.c?view=diff&rev=61638&r1=61637&r2=61638
==============================================================================
--- team/group/mime/main/minimime/mm_error.c (original)
+++ team/group/mime/main/minimime/mm_error.c Thu Apr 12 22:59:37 2007
@@ -58,12 +58,12 @@
  * mm_init_library().
  */
 void
-mm_error_init(void)
+mm_error_init(MM_CTX *ctx)
 {
-	mm_error.error_id = 0;
-	mm_error.error_where = 0;
-	mm_error.lineno = 0;
-	memset(&mm_error.error_msg, '\0', sizeof(mm_error.error_msg));
+	ctx->mm_error.error_id = 0;
+	ctx->mm_error.error_where = 0;
+	ctx->mm_error.lineno = 0;
+	memset(&ctx->mm_error.error_msg, '\0', sizeof(ctx->mm_error.error_msg));
 }
 
 /**
@@ -76,20 +76,20 @@
  * error occured. Should never be called by the user.
  */
 void
-mm_error_setmsg(const char *fmt, ...)
+mm_error_setmsg(MM_CTX *ctx, const char *fmt, ...)
 {
 	va_list ap;
 
 	va_start(ap, fmt);
-	vsnprintf(mm_error.error_msg, sizeof(mm_error.error_msg), fmt, ap);
+	vsnprintf(ctx->mm_error.error_msg, sizeof(ctx->mm_error.error_msg), fmt, ap);
 	va_end(ap);
 
 }
 
 void
-mm_error_setlineno(int lineno)
+mm_error_setlineno(MM_CTX *ctx, int lineno)
 {
-	mm_error.lineno = lineno;
+	ctx->mm_error.lineno = lineno;
 }
 
 /**
@@ -105,19 +105,19 @@
  * allocated by the library.
  */
 char *
-mm_error_string(void)
+mm_error_string(MM_CTX *ctx)
 {
-	if (mm_errno != MM_ERROR_ERRNO && mm_error.error_msg[0] == '\0') {
+	if (ctx->mm_errno != MM_ERROR_ERRNO && ctx->mm_error.error_msg[0] == '\0') {
 		return "No error";
-	} else if (mm_errno == MM_ERROR_ERRNO) {
+	} else if (ctx->mm_errno == MM_ERROR_ERRNO) {
 		return strerror(errno);
 	} else {
-		return mm_error.error_msg;
+		return ctx->mm_error.error_msg;
 	}
 }
 
 int
-mm_error_lineno(void)
+mm_error_lineno(MM_CTX *ctx)
 {
-	return mm_error.lineno;
+	return ctx->mm_error.lineno;
 }

Modified: team/group/mime/main/minimime/mm_header.c
URL: http://svn.digium.com/view/asterisk/team/group/mime/main/minimime/mm_header.c?view=diff&rev=61638&r1=61637&r2=61638
==============================================================================
--- team/group/mime/main/minimime/mm_header.c (original)
+++ team/group/mime/main/minimime/mm_header.c Thu Apr 12 22:59:37 2007
@@ -162,7 +162,7 @@
 }
 
 int
-mm_mimeheader_uncomment(struct mm_mimeheader *header)
+mm_mimeheader_uncomment(MM_CTX *ctx, struct mm_mimeheader *header)
 {
 	char *new;
 
@@ -170,7 +170,7 @@
 	assert(header->name != NULL);
 	assert(header->value != NULL);
 
-	new = mm_uncomment(header->value);
+	new = mm_uncomment(ctx, header->value);
 	if (new == NULL)
 		return -1;
 
@@ -187,7 +187,7 @@
 
 	TAILQ_FOREACH(header, &part->headers, next) {
 		if (!strcasecmp(header->name, name)) {
-			return mm_mimeheader_uncomment(header);
+			return mm_mimeheader_uncomment(part->ctx, header);
 		}
 	}
 
@@ -204,7 +204,7 @@
 	ret = 0;
 
 	TAILQ_FOREACH(header, &part->headers, next) {
-		if ((r = mm_mimeheader_uncomment(header)) == -1) {
+		if ((r = mm_mimeheader_uncomment(part->ctx, header)) == -1) {
 			ret = -1;
 		}
 	}

Modified: team/group/mime/main/minimime/mm_init.c
URL: http://svn.digium.com/view/asterisk/team/group/mime/main/minimime/mm_init.c?view=diff&rev=61638&r1=61637&r2=61638
==============================================================================
--- team/group/mime/main/minimime/mm_init.c (original)
+++ team/group/mime/main/minimime/mm_init.c Thu Apr 12 22:59:37 2007
@@ -38,10 +38,10 @@
 
 #include "mm_internal.h"
 
-int mm_errno;
+/* int mm_errno; No more Globals!
 struct mm_error_data mm_error;
 static int mm_initialized;
-struct mm_codecs codecs;
+struct mm_codecs codecs; */
 
 int
 mm_library_init(void)
@@ -51,7 +51,7 @@
 	mm_errno = MM_ERROR_NONE;
 	mm_initialized = 1;
 
-	SLIST_INIT(&codecs);
+	/* SLIST_INIT(&codecs); */
 
 	mm_error_init();
 

Modified: team/group/mime/main/minimime/mm_mimepart.c
URL: http://svn.digium.com/view/asterisk/team/group/mime/main/minimime/mm_mimepart.c?view=diff&rev=61638&r1=61637&r2=61638
==============================================================================
--- team/group/mime/main/minimime/mm_mimepart.c (original)
+++ team/group/mime/main/minimime/mm_mimepart.c Thu Apr 12 22:59:37 2007
@@ -109,15 +109,11 @@
 	struct stat st;
 	struct mm_mimepart *part;
 
-	mm_errno = MM_ERROR_NONE;
-
 	if ((fd = open(filename, O_RDONLY)) == -1) {
-		mm_errno = MM_ERROR_ERRNO;
 		return NULL;
 	}
 
 	if ((stat(filename, &st)) == -1) {
-		mm_errno = MM_ERROR_ERRNO;
 		close(fd);
 		return NULL;
 	}
@@ -125,7 +121,6 @@
 	data = xmalloc(st.st_size);
 	r = read(fd, data, st.st_size);
 	if (r != st.st_size) {
-		mm_errno = MM_ERROR_ERRNO;
 		close(fd);
 		return(NULL);
 	}
@@ -456,7 +451,6 @@
 char *
 mm_mimepart_decode(struct mm_mimepart *part)
 {
-	extern struct mm_codecs codecs;
 	struct mm_codec *codec;
 	void *decoded;
 	
@@ -470,7 +464,7 @@
 		return NULL;
 
 	/* Loop through codecs and find a suitable one */
-	SLIST_FOREACH(codec, &codecs, next) {
+	SLIST_FOREACH(codec, &part->ctx->codecs, next) {
 		if (!strcasecmp(part->type->encstring, codec->encoding)) {
 			decoded = codec->decoder((char *)part->body);
 			break;
@@ -633,6 +627,7 @@
 void
 mm_mimepart_attachcontenttype(struct mm_mimepart *part, struct mm_content *ct)
 {
+	ct->ctx = part->ctx; /* pass down the dad info */
 	part->type = ct;
 }
 

Modified: team/group/mime/main/minimime/mm_mimeutil.c
URL: http://svn.digium.com/view/asterisk/team/group/mime/main/minimime/mm_mimeutil.c?view=diff&rev=61638&r1=61637&r2=61638
==============================================================================
--- team/group/mime/main/minimime/mm_mimeutil.c (original)
+++ team/group/mime/main/minimime/mm_mimeutil.c Thu Apr 12 22:59:37 2007
@@ -116,7 +116,6 @@
 	total += length;
 
 	if ((*result = (char *) xmalloc(total + 1)) == NULL) {
-		mm_errno = MM_ERROR_ERRNO;
 		return(-1);
 	}	
 

Modified: team/group/mime/main/minimime/mm_parse.c
URL: http://svn.digium.com/view/asterisk/team/group/mime/main/minimime/mm_parse.c?view=diff&rev=61638&r1=61637&r2=61638
==============================================================================
--- team/group/mime/main/minimime/mm_parse.c (original)
+++ team/group/mime/main/minimime/mm_parse.c Thu Apr 12 22:59:37 2007
@@ -141,7 +141,7 @@
 	mimeparser_yylex_init(&yyscanner);
 
 	if ((fp = fopen(filename, "r")) == NULL) {
-		mm_errno = MM_ERROR_ERRNO;
+		ctx->mm_errno = MM_ERROR_ERRNO;
 		return -1;
 	}
 

Modified: team/group/mime/main/minimime/mm_util.c
URL: http://svn.digium.com/view/asterisk/team/group/mime/main/minimime/mm_util.c?view=diff&rev=61638&r1=61637&r2=61638
==============================================================================

[... 74 lines stripped ...]


More information about the svn-commits mailing list