-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathaddress_book.h
81 lines (69 loc) · 1.29 KB
/
address_book.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#ifndef ADDRESS_BOOK_H
#define ADDRESS_BOOK_H
#include <stdio.h>
#define DEFAULT_FILE "address_book.csv"
/* Length of a contact name */
#define NAME_LEN 32
/* Length of a phone number */
#define NUMBER_LEN 32
/* Length of an email address */
#define EMAIL_ID_LEN 32
/* Maximum number of Names per contact, Just for easy design */
#define NAME_COUNT 1
/* Maximum number of phones per contact */
#define PHONE_NUMBER_COUNT 5
/* Maximum number of email addresses per contact */
#define EMAIL_ID_COUNT 5
#define FIELD_DELIMITER ','
#define NEXT_ENTRY '\n'
typedef int bool_t;
typedef enum
{
e_add,
e_search,
e_edit,
e_delete,
e_list,
} Modes;
typedef enum
{
e_first_opt,
e_second_opt,
e_third_opt,
e_fourth_opt,
e_fifth_opt,
e_sixth_opt,
e_no_opt = '\n' -'0',
} MenuOptions;
typedef enum
{
e_fail = -10,
e_back,
e_success,
e_no_match,
e_new_line,
} Status;
typedef enum
{
e_exit,
e_add_contact,
e_search_contact,
e_edit_contact,
e_delete_contact,
e_list_contacts,
e_save
} MenuFeatures;
typedef struct
{
char name[NAME_COUNT][NAME_LEN];
char phone_numbers[PHONE_NUMBER_COUNT][NUMBER_LEN];
char email_addresses[EMAIL_ID_COUNT][EMAIL_ID_LEN];
int si_no;
} ContactInfo;
typedef struct
{
FILE *fp;
ContactInfo *list;
int count;
} AddressBook;
#endif