Statistics
| Revision:

root / src / ldif.h @ 532

History | View | Annotate | Download (3.6 kB)

1 1 hiro
/*
2 1 hiro
 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 1 hiro
 * Copyright (C) 2001 Match Grun
4 1 hiro
 *
5 1 hiro
 * This program is free software; you can redistribute it and/or modify
6 1 hiro
 * it under the terms of the GNU General Public License as published by
7 1 hiro
 * the Free Software Foundation; either version 2 of the License, or
8 1 hiro
 * (at your option) any later version.
9 1 hiro
 *
10 1 hiro
 * This program is distributed in the hope that it will be useful,
11 1 hiro
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 1 hiro
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 1 hiro
 * GNU General Public License for more details.
14 1 hiro
 *
15 1 hiro
 * You should have received a copy of the GNU General Public License
16 1 hiro
 * along with this program; if not, write to the Free Software
17 1 hiro
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 1 hiro
 */
19 1 hiro
20 1 hiro
/*
21 1 hiro
 * Definitions necessary to access LDIF files (LDAP Data Interchange Format
22 1 hiro
 * files). These files are used to load LDAP servers and to interchange data
23 1 hiro
 * between servers. They are also used by several E-Mail client programs and
24 1 hiro
 * other programs as a means of interchange address book data.
25 1 hiro
 */
26 1 hiro
27 1 hiro
#ifndef __LDIF_H__
28 1 hiro
#define __LDIF_H__
29 1 hiro
30 1 hiro
#include <stdio.h>
31 1 hiro
#include <glib.h>
32 1 hiro
33 1 hiro
#include "addrcache.h"
34 1 hiro
35 1 hiro
#define LDIFBUFSIZE         2048
36 1 hiro
37 1 hiro
/* Reserved tag names - for address book import */
38 1 hiro
#define        LDIF_TAG_COMMONNAME "cn"
39 1 hiro
#define        LDIF_TAG_FIRSTNAME  "givenname"
40 1 hiro
#define        LDIF_TAG_LASTNAME   "sn"
41 1 hiro
#define LDIF_TAG_NICKNAME   "xmozillanickname"
42 1 hiro
#define        LDIF_TAG_EMAIL      "mail"
43 1 hiro
44 1 hiro
#define        LDIF_SEP_TAG        ':'
45 1 hiro
#define        LDIF_LANG_TAG       ';'
46 1 hiro
47 1 hiro
/*
48 1 hiro
// Typical LDIF entry (similar to that generated by Netscape):
49 1 hiro
//
50 1 hiro
// dn: uid=axel, dc=axel, dc=com
51 1 hiro
// cn: Axel Rose
52 1 hiro
// sn: Rose
53 1 hiro
// givenname: Arnold
54 1 hiro
// xmozillanickname: Axel
55 1 hiro
// mail: axel@axelrose.com
56 1 hiro
// mail: axelrose@aol.com
57 1 hiro
// mail: axel@netscape.net
58 1 hiro
// mail: axel@hotmail.com
59 1 hiro
// uid: axelrose
60 1 hiro
// o: The Company
61 1 hiro
// locality: Denver
62 1 hiro
// st: CO
63 1 hiro
// streetaddress: 777 Lexington Avenue
64 1 hiro
// postalcode: 80298
65 1 hiro
// countryname: USA
66 1 hiro
// telephonenumber: 303-555-1234
67 1 hiro
// homephone: 303-555-2345
68 1 hiro
// cellphone: 303-555-3456
69 1 hiro
// homeurl: http://www.axelrose.com
70 1 hiro
// objectclass: top
71 1 hiro
// objectclass: person
72 1 hiro
//
73 1 hiro
// Note that first entry is always dn. An empty line defines end of
74 1 hiro
// record. Note that attribute names are case insensitive. There may
75 1 hiro
// also be several occurrences of an attribute, for example, as
76 1 hiro
// illustrated for "mail" and "objectclass" attributes. LDIF files
77 1 hiro
// can also use binary data using base-64 encoding.
78 1 hiro
//
79 1 hiro
*/
80 1 hiro
81 1 hiro
/* LDIF file object */
82 1 hiro
typedef struct _LdifFile LdifFile;
83 1 hiro
struct _LdifFile {
84 1 hiro
        FILE       *file;
85 1 hiro
        gchar      *path;
86 1 hiro
        gchar      *bufptr;
87 1 hiro
        gchar      buffer[ LDIFBUFSIZE ];
88 1 hiro
        gint       retVal;
89 1 hiro
        GHashTable *hashFields;
90 1 hiro
        GList      *tempList;
91 1 hiro
        gboolean   dirtyFlag;
92 1 hiro
        gboolean   accessFlag;
93 1 hiro
        void       (*cbProgress)( void *, void *, void * );
94 1 hiro
        gint       importCount;
95 1 hiro
};
96 1 hiro
97 1 hiro
/* Field list structure */
98 1 hiro
typedef struct _Ldif_FieldRec_ Ldif_FieldRec;
99 1 hiro
struct _Ldif_FieldRec_ {
100 1 hiro
        gchar *tagName;
101 1 hiro
        gchar *userName;
102 1 hiro
        gboolean reserved;
103 1 hiro
        gboolean selected;
104 1 hiro
};
105 1 hiro
106 1 hiro
/* Function prototypes */
107 1 hiro
LdifFile *ldif_create                ( void );
108 1 hiro
void ldif_set_file                ( LdifFile* ldifFile, const gchar *value );
109 1 hiro
void ldif_set_accessed                ( LdifFile* ldifFile, const gboolean value );
110 1 hiro
void ldif_set_callback                ( LdifFile *ldifFile, void *func );
111 1 hiro
void ldif_free                        ( LdifFile *ldifFile );
112 1 hiro
void ldif_print_fieldrec        ( Ldif_FieldRec *rec, FILE *stream );
113 1 hiro
void ldif_print_file                ( LdifFile *ldifFile, FILE *stream );
114 1 hiro
gint ldif_import_data                ( LdifFile *ldifFile, AddressCache *cache );
115 1 hiro
gint ldif_read_tags                ( LdifFile *ldifFile );
116 1 hiro
GList *ldif_get_fieldlist        ( LdifFile *ldifFile );
117 1 hiro
118 1 hiro
#endif /* __LDIF_H__ */