8f792933c9af2759edfd2a417424d867fe2ff79a
[claws.git] / src / headers_display.c
1 /*
2  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3  * Copyright (C) 1999,2000 Hiroyuki Yamamoto
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18  */
19
20 #ifdef HAVE_CONFIG_H
21 #  include "config.h"
22 #endif
23
24 #include <glib.h>
25 #include <string.h>
26 #include <strings.h>
27 #include <stdlib.h>
28
29 #include "intl.h"
30 #include "headers_display.h"
31 #include "utils.h"
32
33
34 gchar * header_display_prop_get_str(HeaderDisplayProp *dp)
35 {
36         return g_strdup_printf
37                 ("%s%s", dp->hidden?"-":"", dp->name);
38 }
39  
40 HeaderDisplayProp * header_display_prop_read_str(gchar * buf)
41 {
42         HeaderDisplayProp * dp;
43
44         dp = g_new0(HeaderDisplayProp, 1);
45
46         dp->hidden = 0;
47         if (*buf == '-') {
48                 dp->hidden = 1;
49                 buf ++;
50         }
51         if (*buf == 0) {
52                 g_free(dp);
53                 return NULL;
54         }
55         dp->name = g_strdup(buf);
56
57         return dp;
58 }
59  
60 void header_display_prop_free(HeaderDisplayProp *dp)
61 {
62         if (!dp) return;
63  
64         if (dp->name)
65                 g_free(dp->name);
66  
67         g_free(dp);
68 }