src/mime.c
author Volker Birk <vb@pep-project.org>
Fri, 05 Apr 2019 17:29:12 +0200
branchsync
changeset 3440 7b7f587af002
parent 3439 3333c94c7827
child 3441 5b25144d17b1
permissions -rw-r--r--
moving this to standard implementation
     1 // This file is under GNU General Public License 3.0
     2 // see LICENSE.txt
     3 
     4 #include "mime.h"
     5 
     6 #include <string.h>
     7 #include <stdlib.h>
     8 #include <assert.h>
     9 #include <errno.h>
    10 
    11 #include "etpan_mime.h"
    12 
    13 static bool is_whitespace(char c)
    14 {
    15     switch (c) {
    16         case ' ':
    17         case '\t':
    18         case '\r':
    19         case '\n':
    20             return true;
    21 
    22         default:
    23             return false;
    24     }
    25 }
    26 
    27 DYNAMIC_API bool is_PGP_message_text(const char *text)
    28 {
    29     if (text == NULL)
    30         return false;
    31 
    32     for (; *text && is_whitespace(*text); text++);
    33 
    34     return strncmp(text, "-----BEGIN PGP MESSAGE-----", 27) == 0;
    35 }
    36 
    37 DYNAMIC_API PEP_STATUS mime_encode_message(
    38         const message * msg,
    39         bool omit_fields,
    40         char **mimetext
    41     )
    42 {
    43     return _mime_encode_message_internal(msg, omit_fields, mimetext, true);
    44 }
    45