Platon Technologies
not logged in Login Registration
EnglishSlovak
open source software development celebrating 10 years of open source development! Friday, April 19, 2024

File: [Platon] / dead / mail2sms / mail.c (download)

Revision 1.2, Tue Oct 30 17:24:02 2001 UTC (22 years, 5 months ago) by host8


Changes since 1.1: +8 -3 lines

New implementation of http request.

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#include "config.h"
#include "mail2sms.h"
#include "http.h"
#include "strings.h"

// Function analyze_mail() {{{
void analyze_mail(char *str)
{
    char *pom;

    if (str == NULL) return;
    if (str == strstr(str, "> ")) return; // reply part

    if (str == strstr(str, "From:") && ! g.skipped_header) {
        strncat(g.text,
                                compress_str(str + strlen("From:")),
                                SMS_LEN - strlen(g.text));
        strncat(g.text, SMS_SEPARATOR, SMS_LEN - strlen(g.text));
        g.text[SMS_LEN] = '\0';

        g.skipped_header = 0;
        g.is_header = 1;
        return;
    }

    if (str == strstr(str, "Subject:") && ! g.skipped_header) {
        strncat(g.text,
                                compress_str(str + strlen("Subject:")),
                                SMS_LEN - strlen(g.text));
        strncat(g.text, SMS_SEPARATOR, SMS_LEN - strlen(g.text));
        g.text[SMS_LEN] = '\0';

        g.skipped_header = 0;
        g.is_header = 1;
        return;
    }

    pom = (char *) malloc((strlen(str)+1)*sizeof(char));
    strcpy(pom, str);
    strtolower(pom);
    if (pom == strstr(pom, "content-transfer-encoding: ")
                            && g.is_header) {
        if (pom == strstr(pom, "content-transfer-encoding: 8bit")
                                || pom == strstr(pom, "content-transfer-encoding:"
                                    " 7bit")) {
        }
        else {
            fprintf(stderr, "NO SMS SEND: '%s'\n", str);
            my_free(pom);
            void_read_at_exit();
            exit(0);
        }
    }

    if (pom == strstr(pom, "content-type: ") && g.is_header&&1) {
        if (pom != strstr(pom, "content-type: text/plain;")) {
            fprintf(stderr, "NO SMS SEND: '%s'\n", str);
            my_free(pom);
            void_read_at_exit();
            exit(0);
        }
    }

    my_free(pom);

    if (str == strstr(str, "---------- Forwarded message ----------")) {
        g.is_header=1;
        g.skipped_header=0;
        g.is_forwarded=1;
        return;
    }

    if ((! strcmp(str,"\n")) && g.is_header) {
        fprintf(stderr, "END OF HEADER\n");
        g.is_header=0;
        g.skipped_header=1;
        return;
    }

    if (g.skipped_header) {
        add_str_to_sms(str);
        return;
    }

    return;
} // }}}
/* Modeline for ViM {{{1
 * vim:set ts=4:
 * vim600:fdm=marker fdl=0 fdc=3:
 * }}}1 */

Platon Group <platon@platon.org> http://platon.org/
Copyright © 2002-2006 Platon Group
Site powered by Metafox CMS
Go to Top