📄 mail.c
字号:
/* * functions for parsing and creating mail headers * * Authors: Michael Jochum <e9725005@stud3.tuwien.ac.at> * * TODO: * * Fixes: * * For license terms, see the file COPYING in the project directory. */#include <stdio.h>#include <string.h>#include <glib.h>#include "misc.h"#include "mail.h"/* Searches in the mail header for a field called <field_name> and returns a allocated string to it (now CR's or NL's are in the string). If no such field is found NULL is returned */gchar *mail_get_field(const gchar * header, const gchar * field_name){ const gchar *s; GString *field; gchar *str_field; if (header == NULL || field_name == NULL) return NULL; /* find <field_name> starting at the beginning of a line */ for (s = header;;) { if ((s = strstr(s, field_name)) == NULL) return NULL; if (s - header > 1) { if (*(s - 1) != '\n' && *(s - 1) != '\r') { s++; continue; } } break; } s += strlen(field_name); field = g_string_sized_new(64); /* copy the field (see RFC822 for multi line fields) */ while (s != NULL) { g_string_append(field, gsms_str_get_line(s, (gchar **) & s)); if (s != NULL) if (*s != ' ' && *s != '\t') s = NULL; } str_field = g_strdup(field->str); g_string_free(field, TRUE); return str_field;}GSmsMail *mail_constructor(const gchar * from, const gchar * to, const gchar * subject, const gchar * body){ GSmsMail *pm; pm = g_new0(GSmsMail, 1); pm->from = g_strdup(from); pm->to = g_strdup(to); pm->subject = g_strdup(subject); pm->body = g_strdup(body); return pm;}void mail_destructor(GSmsMail * pm){ g_free(pm->uid); g_free(pm->from); g_free(pm->to); g_free(pm->subject); g_free(pm->head); g_free(pm->body); g_free(pm); return;}GList *gsms_mail_get_next_new(GList * mails){ GList *mailent; GSmsMail *mail; mailent = g_list_first(mails); while (mailent != NULL) { mail = mailent->data; if (mail->new) return mailent; mailent = g_list_next(mailent); } return NULL;}GList *gsms_mail_get_first_new(GList * mails){ return gsms_mail_get_next_new(mails);}GList *gsms_mailbox_free(GList * mails){ GList *mailent; GSmsMail *mail; mailent = g_list_first(mails); while (mailent != NULL) { mail = mailent->data; mail_destructor(mail); mailent = g_list_next(mailent); } g_list_free(mails); return NULL;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -