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
28 #define LAST_FIELD NOTES
30 #define ITEM_FIELDS (LAST_FIELD+1)
32 typedef char * list_item[ITEM_FIELDS];
45 struct db_enumerator {
47 int mode; /* warning: read only */
50 int parse_database(FILE *in);
51 int write_database(FILE *out, struct db_enumerator e);
52 int load_database(char *filename);
54 void close_database();
55 int add_item2database(list_item item);
56 void free_list_item(list_item item);
57 void remove_selected_items();
60 char *get_surname(char *s);
61 int find_item(char *str, int start, int search_fields[]);
62 int is_selected(int item);
63 int is_valid_item(int item);
65 int real_db_enumerate_items(struct db_enumerator e);
66 struct db_enumerator init_db_enumerator(int mode);
68 #define LAST_ITEM (items - 1)
70 #define itemcpy(dest, src) memmove(dest, src, sizeof(list_item))
72 #define split_emailstr(item, emails) do {\
74 memset(&emails, 0, sizeof(emails) ); \
75 len = strlen(database[item][EMAIL]); \
76 for( _i=0,_j=0, _k=0; _i < len && _j < MAX_EMAILS; _i++ ) { \
77 if( database[item][EMAIL][_i] ==',' ) { \
81 if( _k < MAX_EMAIL_LEN -1 ) \
82 emails[_j][_k++] = database[item][EMAIL][_i]; \
86 #define have_multiple_emails(item) \
87 strchr(database[item][EMAIL], ',')
89 #define db_enumerate_items(e) \
90 while( -1 != (e.item = real_db_enumerate_items(e)))