Back to index

lightning-sunbird  0.9+nobinonly
Defines | Functions | Variables
nsMsgSendPart.cpp File Reference
#include "nsMsgLocalFolderHdrs.h"
#include "nsMsgSend.h"
#include "nsMsgSendPart.h"
#include "nsIMimeConverter.h"
#include "nsFileStream.h"
#include "nsCOMPtr.h"
#include "nsIComponentManager.h"
#include "nsMsgEncoders.h"
#include "nsMsgI18N.h"
#include "nsMsgCompUtils.h"
#include "nsMsgMimeCID.h"
#include "nsMimeTypes.h"
#include "prmem.h"
#include "nsMsgPrompts.h"
#include "nsMsgComposeStringBundle.h"
#include "nsNativeCharsetUtils.h"

Go to the source code of this file.

Defines

#define SKIP_EMPTY_PART   1966
#define PUSHLEN(str, length)
#define PUSH(str)   PUSHLEN(str, PL_strlen(str))

Functions

static int divide_content_headers (const char *headers, char **message_headers, char **content_headers, char **content_type_header)

Variables

static char * mime_mailto_stream_read_buffer = 0

Define Documentation

#define PUSH (   str)    PUSHLEN(str, PL_strlen(str))
#define PUSHLEN (   str,
  length 
)
Value:
do {                            \
    status = mime_write_message_body(m_state, str, length); \
    if (status < 0) goto FAIL;                \
  } while (0)                         \
#define SKIP_EMPTY_PART   1966

Definition at line 471 of file nsMsgSendPart.cpp.


Function Documentation

static int divide_content_headers ( const char *  headers,
char **  message_headers,
char **  content_headers,
char **  content_type_header 
) [static]

Definition at line 354 of file nsMsgSendPart.cpp.

{
    const char *tail;
    char *message_tail, *content_tail, *type_tail;
    int L = 0;
    if (headers)
      L = PL_strlen(headers);
    
    if (L == 0)
      return 0;
    
    *message_headers = (char *)PR_Malloc(L+1);
    if (!*message_headers)
      return NS_ERROR_OUT_OF_MEMORY;
    
    *content_headers = (char *)PR_Malloc(L+1);
    if (!*content_headers) {
      PR_Free(*message_headers);
      return NS_ERROR_OUT_OF_MEMORY;
    }
    
    *content_type_header = (char *)PR_Malloc(L+1);
    if (!*content_type_header) {
      PR_Free(*message_headers);
      PR_Free(*content_headers);
      return NS_ERROR_OUT_OF_MEMORY;
    }
    
    message_tail = *message_headers;
    content_tail = *content_headers;
    type_tail    = *content_type_header;
    tail = headers;
    
    while (*tail)
    {
      const char *head = tail;
      char **out;
      while(PR_TRUE) {
      /* Loop until we reach a newline that is not followed by whitespace.
        */
        if (tail[0] == 0 ||
          ((tail[0] == nsCRT::CR || tail[0] == nsCRT::LF) &&
          !(tail[1] == ' ' || tail[1] == '\t' || tail[1] == nsCRT::LF)))
        {
          /* Swallow the whole newline. */
          if (tail[0] == nsCRT::CR && tail[1] == nsCRT::LF)
            tail++;
          if (*tail)
            tail++;
          break;
        }
        tail++;
      }
      
      /* Decide which block this header goes into.
      */
      if (!PL_strncasecmp(head, "Content-Type:", 13))
        out = &type_tail;
      else
        if (!PL_strncasecmp(head, "Content-", 8))
          out = &content_tail;
        else
          out = &message_tail;
        
        memcpy(*out, head, (tail-head));
        *out += (tail-head);
    }
    
    *message_tail = 0;
    *content_tail = 0;
    *type_tail = 0;
    
    if (!**message_headers) {
      PR_Free(*message_headers);
      *message_headers = 0;
    }
    
    if (!**content_headers) {
      PR_Free(*content_headers);
      *content_headers = 0;
    }
    
    if (!**content_type_header) {
      PR_Free(*content_type_header);
      *content_type_header = 0;
    }
    
#ifdef DEBUG
    // ### mwelch Because of the extreme difficulty we've had with
    //      duplicate part headers, I'm going to put in an
    //      ASSERT here which makes sure that no duplicate
    //      Content-Type or Content-Transfer-Encoding headers
    //      leave here undetected.
    const char* tmp;
    if (*content_type_header) {
      tmp = PL_strstr(*content_type_header, "Content-Type");
      if (tmp) {
        tmp++; // get past the first occurrence
        NS_ASSERTION(!PL_strstr(tmp, "Content-Type"), "Content-part already present");
      }
    }
    
    if (*content_headers) {
      tmp = PL_strstr(*content_headers, "Content-Transfer-Encoding");
      if (tmp) {
        tmp++; // get past the first occurrence
        NS_ASSERTION(!PL_strstr(tmp, "Content-Transfer-Encoding"), "Content-Transfert already present");
      }
    }
#endif // DEBUG
    
    return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

char* mime_mailto_stream_read_buffer = 0 [static]

Definition at line 57 of file nsMsgSendPart.cpp.