root / src / ldif.h @ 1
History | View | Annotate | Download (3.6 kB)
| 1 | /*
|
|---|---|
| 2 | * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client |
| 3 | * Copyright (C) 2001 Match Grun |
| 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 | /*
|
| 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. |
| 25 | */ |
| 26 | |
| 27 | #ifndef __LDIF_H__
|
| 28 | #define __LDIF_H__
|
| 29 | |
| 30 | #include <stdio.h> |
| 31 | #include <glib.h> |
| 32 | |
| 33 | #include "addrcache.h" |
| 34 | |
| 35 | #define LDIFBUFSIZE 2048 |
| 36 | |
| 37 | /* Reserved tag names - for address book import */
|
| 38 | #define LDIF_TAG_COMMONNAME "cn" |
| 39 | #define LDIF_TAG_FIRSTNAME "givenname" |
| 40 | #define LDIF_TAG_LASTNAME "sn" |
| 41 | #define LDIF_TAG_NICKNAME "xmozillanickname" |
| 42 | #define LDIF_TAG_EMAIL "mail" |
| 43 | |
| 44 | #define LDIF_SEP_TAG ':' |
| 45 | #define LDIF_LANG_TAG ';' |
| 46 | |
| 47 | /*
|
| 48 | // Typical LDIF entry (similar to that generated by Netscape): |
| 49 | // |
| 50 | // dn: uid=axel, dc=axel, dc=com |
| 51 | // cn: Axel Rose |
| 52 | // sn: Rose |
| 53 | // givenname: Arnold |
| 54 | // xmozillanickname: Axel |
| 55 | // mail: axel@axelrose.com |
| 56 | // mail: axelrose@aol.com |
| 57 | // mail: axel@netscape.net |
| 58 | // mail: axel@hotmail.com |
| 59 | // uid: axelrose |
| 60 | // o: The Company |
| 61 | // locality: Denver |
| 62 | // st: CO |
| 63 | // streetaddress: 777 Lexington Avenue |
| 64 | // postalcode: 80298 |
| 65 | // countryname: USA |
| 66 | // telephonenumber: 303-555-1234 |
| 67 | // homephone: 303-555-2345 |
| 68 | // cellphone: 303-555-3456 |
| 69 | // homeurl: http://www.axelrose.com |
| 70 | // objectclass: top |
| 71 | // objectclass: person |
| 72 | // |
| 73 | // Note that first entry is always dn. An empty line defines end of |
| 74 | // record. Note that attribute names are case insensitive. There may |
| 75 | // also be several occurrences of an attribute, for example, as |
| 76 | // illustrated for "mail" and "objectclass" attributes. LDIF files |
| 77 | // can also use binary data using base-64 encoding. |
| 78 | // |
| 79 | */ |
| 80 | |
| 81 | /* LDIF file object */
|
| 82 | typedef struct _LdifFile LdifFile; |
| 83 | struct _LdifFile {
|
| 84 | FILE *file; |
| 85 | gchar *path; |
| 86 | gchar *bufptr; |
| 87 | gchar buffer[ LDIFBUFSIZE ]; |
| 88 | gint retVal; |
| 89 | GHashTable *hashFields; |
| 90 | GList *tempList; |
| 91 | gboolean dirtyFlag; |
| 92 | gboolean accessFlag; |
| 93 | void (*cbProgress)( void *, void *, void * ); |
| 94 | gint importCount; |
| 95 | }; |
| 96 | |
| 97 | /* Field list structure */
|
| 98 | typedef struct _Ldif_FieldRec_ Ldif_FieldRec; |
| 99 | struct _Ldif_FieldRec_ {
|
| 100 | gchar *tagName; |
| 101 | gchar *userName; |
| 102 | gboolean reserved; |
| 103 | gboolean selected; |
| 104 | }; |
| 105 | |
| 106 | /* Function prototypes */
|
| 107 | LdifFile *ldif_create ( void );
|
| 108 | void ldif_set_file ( LdifFile* ldifFile, const gchar *value ); |
| 109 | void ldif_set_accessed ( LdifFile* ldifFile, const gboolean value ); |
| 110 | void ldif_set_callback ( LdifFile *ldifFile, void *func ); |
| 111 | void ldif_free ( LdifFile *ldifFile );
|
| 112 | void ldif_print_fieldrec ( Ldif_FieldRec *rec, FILE *stream );
|
| 113 | void ldif_print_file ( LdifFile *ldifFile, FILE *stream );
|
| 114 | gint ldif_import_data ( LdifFile *ldifFile, AddressCache *cache ); |
| 115 | gint ldif_read_tags ( LdifFile *ldifFile ); |
| 116 | GList *ldif_get_fieldlist ( LdifFile *ldifFile ); |
| 117 | |
| 118 | #endif /* __LDIF_H__ */ |
| 119 |