2.10.0 unleashed
[claws.git] / src / ldif.h
bloba6a91761caedeb7969ef41935f014bdd662c076b
1 /*
2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 2001-2007 Match Grun and the Claws Mail team
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.
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.
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 * Definitions necessary to access LDIF files (LDAP Data Interchange Format
22 * files). These files are used to load LDAP servers and to interchange data
23 * between servers. They are also used by several E-Mail client programs and
24 * other programs as a means of interchange address book data.
27 #ifndef __LDIF_H__
28 #define __LDIF_H__
30 #include <stdio.h>
31 #include <glib.h>
33 #include "addrcache.h"
35 #define LDIFBUFSIZE 2048
37 /* Common tag names - for address book import/export */
38 #define LDIF_TAG_DN "dn"
39 #define LDIF_TAG_COMMONNAME "cn"
40 #define LDIF_TAG_FIRSTNAME "givenname"
41 #define LDIF_TAG_LASTNAME "sn"
42 #define LDIF_TAG_NICKNAME "xmozillanickname"
43 #define LDIF_TAG_EMAIL "mail"
44 #define LDIF_TAG_OBJECTCLASS "objectclass"
46 /* Object classes */
47 #define LDIF_CLASS_PERSON "person"
48 #define LDIF_CLASS_INET_PERSON "inetOrgPerson"
51 * Typical LDIF entry (similar to that generated by Netscape):
53 * dn: uid=axel, dc=axel, dc=com
54 * cn: Axel Rose
55 * sn: Rose
56 * givenname: Arnold
57 * xmozillanickname: Axel
58 * mail: axel@axelrose.com
59 * mail: axelrose@aol.com
60 * mail: axel@netscape.net
61 * mail: axel@hotmail.com
62 * uid: axelrose
63 * o: The Company
64 * locality: Denver
65 * st: CO
66 * streetaddress: 777 Lexington Avenue
67 * postalcode: 80298
68 * countryname: USA
69 * telephonenumber: 303-555-1234
70 * homephone: 303-555-2345
71 * cellphone: 303-555-3456
72 * homeurl: http://www.axelrose.com
73 * objectclass: top
74 * objectclass: person
76 * Note that first entry is always dn. An empty line defines end of
77 * record. Note that attribute names are case insensitive. There may
78 * also be several occurrences of an attribute, for example, as
79 * illustrated for "mail" and "objectclass" attributes. LDIF files
80 * can also use binary data using base-64 encoding.
84 /* LDIF file object */
85 typedef struct _LdifFile LdifFile;
86 struct _LdifFile {
87 FILE *file;
88 gchar *path;
89 gchar *bufptr;
90 gchar buffer[ LDIFBUFSIZE ];
91 gint retVal;
92 GHashTable *hashFields;
93 GList *tempList;
94 gboolean dirtyFlag;
95 gboolean accessFlag;
96 void (*cbProgress)( void *, void *, void * );
97 gint importCount;
100 /* LDIF field record structure */
101 typedef struct _Ldif_FieldRec_ Ldif_FieldRec;
102 struct _Ldif_FieldRec_ {
103 gchar *tagName;
104 gchar *userName;
105 gboolean reserved;
106 gboolean selected;
109 /* Function prototypes */
110 LdifFile *ldif_create ( void );
111 void ldif_set_file ( LdifFile* ldifFile, const gchar *value );
112 void ldif_set_accessed ( LdifFile* ldifFile, const gboolean value );
113 void ldif_field_set_name ( Ldif_FieldRec *rec, const gchar *value );
114 void ldif_field_set_selected ( Ldif_FieldRec *rec, const gboolean value );
115 void ldif_field_toggle ( Ldif_FieldRec *rec );
116 void ldif_free ( LdifFile *ldifFile );
117 void ldif_print_file ( LdifFile *ldifFile, FILE *stream );
118 gint ldif_import_data ( LdifFile *ldifFile, AddressCache *cache );
119 gint ldif_read_tags ( LdifFile *ldifFile );
120 GList *ldif_get_fieldlist ( LdifFile *ldifFile );
121 gboolean ldif_write_value ( FILE *stream, const gchar *name,
122 const gchar *value );
123 void ldif_write_eor ( FILE *stream );
125 #endif /* __LDIF_H__ */