Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdlib.h>
- #include <stdio.h>
- #include <fcntl.h>
- #include <sys/mman.h>
- int main(int argc, const char **argv) {
- if (argc != 2) {
- return -1;
- }
- const char *path_to_eml = argv[1];
- puts(path_to_eml);
- int Strlen = 0; // длина строки-копии входного файла
- char* Strfile = Open_file_write_to_str(path_to_eml, Strlen);
- if (Strfile == NULL) {
- printf("Error of file open\n");
- return -1;
- }
- char To_space[120] = ""; // поля для хранения содержимого тегов
- char From_space[120] = "";
- char Date_space[120] = "";
- char Content_type_space[120] = "";
- char Received_space[120] = "";
- int Parts = -1;
- Efile Fparts = {}; // структура для хранения адресов на заголовок и письмо файла
- Fparts.Tag = Strfile;
- Correct_caps_find_endoftag(Fparts);
- Search_startlinetag (&Fparts, "to", To_space);
- Search_startlinetag (&Fparts, "from", From_space);
- Search_startlinetag (&Fparts, "date", Date_space);
- Search_startlinetag (&Fparts, "content-type", Content_type_space);
- Search_startlinetag (&Fparts, "received", Received_space);
- // if (*(Fparts.Letter + 1)) == '\0') { // проверка пустого письма
- // Parts = 0;
- }
- if (strlen(Content_type_space) = 1) { // проверка однопартного письма
- Parts = 1;
- }
- if (Parts < 0) {
- char* Multipart = strstr(Content_type_space, "multipart");
- if (Multipart == NULL) {
- Parts = 1;
- } else {
- char* Boundary = strstr(Content-type_space, "boundary="); // нашли boundary
- int state = strlen("boundary=") - 1; // запись значения boundary
- for(int i = 0; (isspace(*(Boundary+state+i))) && ((*(Boundary+state+i) != '\n') || (*(Boundary+state+i) != '\r')); i++); // проверка на пробелы
- while (*(Boundary+state+i) != '\n') || (*(Boundary+state+i) != '\r')) {
- Boundaryspaсe[1] = *(Boundary+state+i);
- }
- char* Bsadrr = strstr(string, Boundaryspaсe);
- while (Bsadrr) { // подсчет кол-ва партов
- Parts++;
- Bsadrr = strstr(string, substring);
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement