Back to index

lightning-sunbird  0.9+nobinonly
Classes | Enumerations | Functions
sspm.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  sspm_header
struct  sspm_part
struct  sspm_action_map

Enumerations

enum  sspm_major_type {
  SSPM_NO_MAJOR_TYPE, SSPM_TEXT_MAJOR_TYPE, SSPM_IMAGE_MAJOR_TYPE, SSPM_AUDIO_MAJOR_TYPE,
  SSPM_VIDEO_MAJOR_TYPE, SSPM_APPLICATION_MAJOR_TYPE, SSPM_MULTIPART_MAJOR_TYPE, SSPM_MESSAGE_MAJOR_TYPE,
  SSPM_UNKNOWN_MAJOR_TYPE, SSPM_NO_MAJOR_TYPE, SSPM_TEXT_MAJOR_TYPE, SSPM_IMAGE_MAJOR_TYPE,
  SSPM_AUDIO_MAJOR_TYPE, SSPM_VIDEO_MAJOR_TYPE, SSPM_APPLICATION_MAJOR_TYPE, SSPM_MULTIPART_MAJOR_TYPE,
  SSPM_MESSAGE_MAJOR_TYPE, SSPM_UNKNOWN_MAJOR_TYPE
}
enum  sspm_minor_type {
  SSPM_NO_MINOR_TYPE, SSPM_ANY_MINOR_TYPE, SSPM_PLAIN_MINOR_TYPE, SSPM_RFC822_MINOR_TYPE,
  SSPM_DIGEST_MINOR_TYPE, SSPM_CALENDAR_MINOR_TYPE, SSPM_MIXED_MINOR_TYPE, SSPM_RELATED_MINOR_TYPE,
  SSPM_ALTERNATIVE_MINOR_TYPE, SSPM_PARALLEL_MINOR_TYPE, SSPM_UNKNOWN_MINOR_TYPE, SSPM_NO_MINOR_TYPE,
  SSPM_ANY_MINOR_TYPE, SSPM_PLAIN_MINOR_TYPE, SSPM_RFC822_MINOR_TYPE, SSPM_DIGEST_MINOR_TYPE,
  SSPM_CALENDAR_MINOR_TYPE, SSPM_MIXED_MINOR_TYPE, SSPM_RELATED_MINOR_TYPE, SSPM_ALTERNATIVE_MINOR_TYPE,
  SSPM_PARALLEL_MINOR_TYPE, SSPM_UNKNOWN_MINOR_TYPE
}
enum  sspm_encoding {
  SSPM_NO_ENCODING, SSPM_QUOTED_PRINTABLE_ENCODING, SSPM_8BIT_ENCODING, SSPM_7BIT_ENCODING,
  SSPM_BINARY_ENCODING, SSPM_BASE64_ENCODING, SSPM_UNKNOWN_ENCODING, SSPM_NO_ENCODING,
  SSPM_QUOTED_PRINTABLE_ENCODING, SSPM_8BIT_ENCODING, SSPM_7BIT_ENCODING, SSPM_BINARY_ENCODING,
  SSPM_BASE64_ENCODING, SSPM_UNKNOWN_ENCODING
}
enum  sspm_error {
  SSPM_NO_ERROR, SSPM_UNEXPECTED_BOUNDARY_ERROR, SSPM_WRONG_BOUNDARY_ERROR, SSPM_NO_BOUNDARY_ERROR,
  SSPM_NO_HEADER_ERROR, SSPM_MALFORMED_HEADER_ERROR, SSPM_NO_ERROR, SSPM_UNEXPECTED_BOUNDARY_ERROR,
  SSPM_WRONG_BOUNDARY_ERROR, SSPM_NO_BOUNDARY_ERROR, SSPM_NO_HEADER_ERROR, SSPM_MALFORMED_HEADER_ERROR
}

Functions

char * sspm_major_type_string (enum sspm_major_type type)
char * sspm_minor_type_string (enum sspm_minor_type type)
char * sspm_encoding_string (enum sspm_encoding type)
int sspm_parse_mime (struct sspm_part *parts, size_t max_parts, struct sspm_action_map *actions, char *(*get_string)(char *s, size_t size, void *data), void *get_string_data, struct sspm_header *first_header)
void sspm_free_parts (struct sspm_part *parts, size_t max_parts)
char * decode_quoted_printable (char *dest, char *src, size_t *size)
char * decode_base64 (char *dest, char *src, size_t *size)
int sspm_write_mime (struct sspm_part *parts, size_t num_parts, char **output_string, char *header)

Class Documentation

struct sspm_header

Definition at line 3468 of file ical.h.

Collaboration diagram for sspm_header:
Class Members
char * boundary
int def
struct sspm_part

Definition at line 3484 of file ical.h.

Collaboration diagram for sspm_part:
Class Members
void * data
size_t data_size
int level
struct sspm_action_map

Definition at line 3491 of file ical.h.


Enumeration Type Documentation

Enumerator:
SSPM_NO_ENCODING 
SSPM_QUOTED_PRINTABLE_ENCODING 
SSPM_8BIT_ENCODING 
SSPM_7BIT_ENCODING 
SSPM_BINARY_ENCODING 
SSPM_BASE64_ENCODING 
SSPM_UNKNOWN_ENCODING 
SSPM_NO_ENCODING 
SSPM_QUOTED_PRINTABLE_ENCODING 
SSPM_8BIT_ENCODING 
SSPM_7BIT_ENCODING 
SSPM_BINARY_ENCODING 
SSPM_BASE64_ENCODING 
SSPM_UNKNOWN_ENCODING 

Definition at line 65 of file sspm.h.

enum sspm_error
Enumerator:
SSPM_NO_ERROR 
SSPM_UNEXPECTED_BOUNDARY_ERROR 
SSPM_WRONG_BOUNDARY_ERROR 
SSPM_NO_BOUNDARY_ERROR 
SSPM_NO_HEADER_ERROR 
SSPM_MALFORMED_HEADER_ERROR 
SSPM_NO_ERROR 
SSPM_UNEXPECTED_BOUNDARY_ERROR 
SSPM_WRONG_BOUNDARY_ERROR 
SSPM_NO_BOUNDARY_ERROR 
SSPM_NO_HEADER_ERROR 
SSPM_MALFORMED_HEADER_ERROR 

Definition at line 75 of file sspm.h.

Enumerator:
SSPM_NO_MAJOR_TYPE 
SSPM_TEXT_MAJOR_TYPE 
SSPM_IMAGE_MAJOR_TYPE 
SSPM_AUDIO_MAJOR_TYPE 
SSPM_VIDEO_MAJOR_TYPE 
SSPM_APPLICATION_MAJOR_TYPE 
SSPM_MULTIPART_MAJOR_TYPE 
SSPM_MESSAGE_MAJOR_TYPE 
SSPM_UNKNOWN_MAJOR_TYPE 
SSPM_NO_MAJOR_TYPE 
SSPM_TEXT_MAJOR_TYPE 
SSPM_IMAGE_MAJOR_TYPE 
SSPM_AUDIO_MAJOR_TYPE 
SSPM_VIDEO_MAJOR_TYPE 
SSPM_APPLICATION_MAJOR_TYPE 
SSPM_MULTIPART_MAJOR_TYPE 
SSPM_MESSAGE_MAJOR_TYPE 
SSPM_UNKNOWN_MAJOR_TYPE 

Definition at line 39 of file sspm.h.

Enumerator:
SSPM_NO_MINOR_TYPE 
SSPM_ANY_MINOR_TYPE 
SSPM_PLAIN_MINOR_TYPE 
SSPM_RFC822_MINOR_TYPE 
SSPM_DIGEST_MINOR_TYPE 
SSPM_CALENDAR_MINOR_TYPE 
SSPM_MIXED_MINOR_TYPE 
SSPM_RELATED_MINOR_TYPE 
SSPM_ALTERNATIVE_MINOR_TYPE 
SSPM_PARALLEL_MINOR_TYPE 
SSPM_UNKNOWN_MINOR_TYPE 
SSPM_NO_MINOR_TYPE 
SSPM_ANY_MINOR_TYPE 
SSPM_PLAIN_MINOR_TYPE 
SSPM_RFC822_MINOR_TYPE 
SSPM_DIGEST_MINOR_TYPE 
SSPM_CALENDAR_MINOR_TYPE 
SSPM_MIXED_MINOR_TYPE 
SSPM_RELATED_MINOR_TYPE 
SSPM_ALTERNATIVE_MINOR_TYPE 
SSPM_PARALLEL_MINOR_TYPE 
SSPM_UNKNOWN_MINOR_TYPE 

Definition at line 51 of file sspm.h.


Function Documentation

char* decode_base64 ( char *  dest,
char *  src,
size_t *  size 
)

Definition at line 1170 of file sspm.c.

{
    int cc = 0;
    char buf[4] = {0,0,0,0};  
    int p = 0;
    int valid_data = 0;
    size_t size_out=0;
    
    while (*src && p<(int)*size && (cc!=  -1)) {
       
       /* convert a character into the Base64 alphabet */
       cc = *src++;
       
       if     ((cc >= 'A') && (cc <= 'Z')) cc = cc - 'A';
       else if ((cc >= 'a') && (cc <= 'z')) cc = cc - 'a' + 26;
       else if ((cc >= '0') && (cc <= '9')) cc = cc - '0' + 52;
       else if  (cc == '/')             cc = 63;
       else if  (cc == '+')             cc = 62;
       else                                 cc = -1;
       
       assert(cc<64);

       /* If we've reached the end, fill the remaining slots in
          the bucket and do a final conversion */
       if(cc== -1){
           if(valid_data == 0){
              return 0;
           }

           while(p%4!=3){
              p++;
              buf[p%4] = 0;
           }
       } else {
           buf[p%4] = cc;
           size_out++;
           valid_data = 1;
       }

       
       /* When we have 4 base64 letters, convert them into three
          bytes */
       if (p%4 == 3) {
           *dest++ =(buf[0]<< 2)|((buf[1] & 0x30) >> 4);
           *dest++ =((buf[1] & 0x0F) << 4)|((buf[2] & 0x3C) >> 2);
           *dest++ =((buf[2] & 0x03) << 6)|(buf[3] & 0x3F);

           memset(buf,0,4);
       }

       p++;

    }
    /* Calculate the size of the converted data*/
   *size = ((int)(size_out/4))*3;
    if(size_out%4 == 2) *size+=1;
    if(size_out%4 == 3) *size+=2;

    return(dest);
}

Here is the call graph for this function:

char* decode_quoted_printable ( char *  dest,
char *  src,
size_t *  size 
)

Definition at line 1121 of file sspm.c.

{
    int cc;
    size_t i=0;

    while (*src != 0 && i < *size) {
       if (*src == '=') {

           src++; 
           if (!*src) {
              break;
           }

           /* remove soft line breaks*/
           if ((*src == '\n') || (*src == '\r')){
              src++;
              if ((*src == '\n') || (*src == '\r')){
                  src++;
              }
              continue;
           }

           cc  = isdigit(*src) ? (*src - '0') : (*src - 55);
           cc *= 0x10;
           src++; 
           if (!*src) {
              break;
           }
           cc += isdigit(*src) ? (*src - '0') : (*src - 55);

           *dest = cc;

       } else {
           *dest = *src;
       }
       
       dest++;
       src++;
       i++;
    }
    
    *dest = '\0';
    
    *size = i;
    return(dest);
}
char* sspm_encoding_string ( enum sspm_encoding  type)

Definition at line 513 of file sspm.c.

{
    int i;
    for (i=0; sspm_encoding_map[i].encoding !=  SSPM_UNKNOWN_ENCODING; 
        i++){
       if(type == sspm_encoding_map[i].encoding){
           return sspm_encoding_map[i].str;
       }
    }
    
    return sspm_encoding_map[i].str; /* Should return SSPM_UNKNOWN_MINOR_TYPE */
}
void sspm_free_parts ( struct sspm_part parts,
size_t  max_parts 
)

Definition at line 1073 of file sspm.c.

{
     int i;
    
    for(i = 0; i<(int)max_parts && parts[i].header.major != SSPM_NO_MAJOR_TYPE;
       i++){
       sspm_free_header(&(parts[i].header));
    }
}

Here is the call graph for this function:

Definition at line 484 of file sspm.c.

{
    int i;

    for (i=0; major_content_type_map[i].type !=  SSPM_UNKNOWN_MINOR_TYPE; 
        i++){

       if(type == major_content_type_map[i].type){
           return major_content_type_map[i].str;
       }
    }
    
    return major_content_type_map[i].str; /* Should return SSPM_UNKNOWN_MINOR_TYPE */
}

Definition at line 499 of file sspm.c.

{
    int i;
    for (i=0; minor_content_type_map[i].type !=  SSPM_UNKNOWN_MINOR_TYPE; 
        i++){
       if(type == minor_content_type_map[i].type){
           return minor_content_type_map[i].str;
       }
    }
    
    return minor_content_type_map[i].str; /* Should return SSPM_UNKNOWN_MINOR_TYPE */
}
int sspm_parse_mime ( struct sspm_part parts,
size_t  max_parts,
struct sspm_action_map actions,
char *(*)(char *s, size_t size, void *data get_string,
void get_string_data,
struct sspm_header first_header 
)

Definition at line 1018 of file sspm.c.

{
    struct mime_impl impl;
    struct sspm_header header;
    void *part;
    int i;

    /* Initialize all of the data */
    memset(&impl,0,sizeof(struct mime_impl));
    memset(&header,0,sizeof(struct sspm_header));

    for(i = 0; i<(int)max_parts; i++){
       parts[i].header.major = SSPM_NO_MAJOR_TYPE;
       parts[i].header.minor = SSPM_NO_MINOR_TYPE;
    }
       
    impl.parts = parts;
    impl.max_parts = max_parts;
    impl.part_no = 0;
    impl.actions = actions;
    impl.get_string = get_string;
    impl.get_string_data = get_string_data;

    /* Read the header of the message. This will be the email header,
       unless first_header is specified. But ( HACK) that var is not
       currently being used */
    sspm_read_header(&impl,&header);

    if(header.major == SSPM_MULTIPART_MAJOR_TYPE){
       struct sspm_header *child_header;
       child_header = &(impl.parts[impl.part_no].header);
       
       sspm_store_part(&impl,header,impl.level,0,0);

       part = sspm_make_multipart_part(&impl,child_header);

    } else {
       void *part;
       size_t size;
       sspm_make_part(&impl, &header, 0,&part,&size);

       memset(&(impl.parts[impl.part_no]), 0, sizeof(struct sspm_part));
       
       sspm_store_part(&impl,header,impl.level,part,size);
    }

    return 0;
}

Here is the call graph for this function:

int sspm_write_mime ( struct sspm_part parts,
size_t  num_parts,
char **  output_string,
char *  header 
)

Definition at line 1580 of file sspm.c.

{
    struct sspm_buffer buf;
    int part_num =0;

    buf.buffer = malloc(4096);
    buf.pos = buf.buffer;
    buf.buf_size = 10;
    buf.line_pos = 0;

    /* write caller's header */
    if(header != 0){
       sspm_append_string(&buf,header);
    }

    if(buf.buffer[strlen(buf.buffer)-1] != '\n'){
       sspm_append_char(&buf,'\n');
    }

    /* write mime-version header */
    sspm_append_string(&buf,"Mime-Version: 1.0\n");

    /* End of header */

    /* Write body parts */
    while(parts[part_num].header.major != SSPM_NO_MAJOR_TYPE){
       if (parts[part_num].header.major == SSPM_MULTIPART_MAJOR_TYPE){
           sspm_write_multipart_part(&buf,parts,&part_num);
       } else {
           sspm_write_part(&buf, &(parts[part_num]), &part_num);
       }      

       part_num++;
    }


    *output_string = buf.buffer;

    return 0;
}

Here is the call graph for this function: