6 #define MAX_EMAIL_LEN 80
7 #define MAX_EMAILSTR_LEN (MAX_EMAILS*MAX_EMAIL_LEN + MAX_EMAILS + 1)
8 #define MAX_FIELD_LEN 81
26 ITEM_FIELDS /* this is the last */
29 #define LAST_FIELD (ITEM_FIELDS - 1)
31 typedef char * list_item[ITEM_FIELDS];
44 struct db_enumerator {
46 int mode; /* warning: read only */
49 int parse_database(FILE *in);
50 int write_database(FILE *out, struct db_enumerator e);
51 int load_database(char *filename);
53 void close_database();
54 int add_item2database(list_item item);
55 void free_list_item(list_item item);
56 void remove_selected_items();
59 char *get_surname(char *s);
60 int find_item(char *str, int start, int search_fields[]);
61 int is_selected(int item);
62 int is_valid_item(int item);
64 int real_db_enumerate_items(struct db_enumerator e);
65 struct db_enumerator init_db_enumerator(int mode);
67 #define LAST_ITEM (items - 1)
69 #define itemcpy(dest, src) memmove(dest, src, sizeof(list_item))
71 #define split_emailstr(item, emails) do {\
73 memset(&emails, 0, sizeof(emails) ); \
74 len = strlen(database[item][EMAIL]); \
75 for( _i=0,_j=0, _k=0; _i < len && _j < MAX_EMAILS; _i++ ) { \
76 if( database[item][EMAIL][_i] ==',' ) { \
80 if( _k < MAX_EMAIL_LEN -1 ) \
81 emails[_j][_k++] = database[item][EMAIL][_i]; \
85 #define have_multiple_emails(item) \
86 strchr(database[item][EMAIL], ',')
88 #define db_enumerate_items(e) \
89 while( -1 != (e.item = real_db_enumerate_items(e)))