-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmsg.h
81 lines (67 loc) · 1.46 KB
/
msg.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
#define MAX_MSG_PAYLOAD 100
/* The information type */
#define SENDER_DATA_TYPE 1
/* The done message */
#define RECV_DONE_TYPE 2
/* The file name transfer message */
#define FILE_NAME_TRANSFER_TYPE 3
/* The maximum size of the file name */
#define MAX_FILE_NAME_SIZE 100
/**
* The structure representing the message
* used by sender to send the name of the file
* to be transfered to the receiver.
*/
struct fileNameMsg
{
/* The message type */
long mtype;
/* The name of the file */
char fileName[MAX_FILE_NAME_SIZE];
/**
* Prints the structure
* @param fp - the file stream to print to
*/
void print(FILE* fp)
{
fprintf(fp, "%ld %s\n", mtype, fileName);
}
};
/**
* The message structure representing the message
* sent from the sender to the receiver indicating
* the number of bytes in the shared memory segment
* that are ready to read.
*/
struct message
{
/* The message type */
long mtype;
/* How many bytes in the message */
int size;
/**
* Prints the structure
* @param fp - the file stream to print to
*/
void print(FILE* fp)
{
fprintf(fp, "%ld %d", mtype, size);
}
};
/* Struct representing the message sent from the receiver
* to the sender acknowledging the successful reception and
* saving of data.
*/
struct ackMessage
{
/* The type of message */
long mtype;
/**
* Prints the structure
* @param fp - the file stream to print to
*/
void print(FILE* fp)
{
fprintf(fp, "%ld\n", mtype);
}
};