-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprotocol.h
More file actions
34 lines (29 loc) · 975 Bytes
/
protocol.h
File metadata and controls
34 lines (29 loc) · 975 Bytes
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
#ifndef PROTOCOL_H
#define PROTOCOL_H
#include <stdint.h>
#include <stdio.h>
// the protocol constants
#define PROTOCOL_PREFIX 0x23107231
#define OP_FACE_DETECT 0
#define OP_FACE_REPLACE 1
#define OP_OUTPUT_IMAGE 2
#define OP_ERROR_MESSAGE 3
typedef struct {
uint32_t prefix;
uint8_t operation;
uint32_t image1Size;
unsigned char* image1Data;
// Only used for face replacement
uint32_t image2Size;
// Only used for face replacement
unsigned char* image2Data;
} ProtocolMessage;
// define the function prototypes
int receive_message(FILE* stream, ProtocolMessage* message);
void free_message(ProtocolMessage* message);
int send_message(FILE* stream, ProtocolMessage* message);
unsigned char* read_file_data(const char* filename, uint32_t* size);
unsigned char* read_stdin_data(uint32_t* size);
int write_file_data(const char* filename, unsigned char* data, uint32_t size);
int write_stdout_data(unsigned char* data, uint32_t size);
#endif