forked from bloominstituteoftechnology/C-Web-Server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.h
42 lines (32 loc) · 730 Bytes
/
utils.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
#ifndef _UTILS_H_
#define _UTILS_H_
#include "../cache.h"
int check_strings(char *input, char *expected)
{
for (; *input == *expected; input++, expected++) {
if (*input == '\0') {
return 0;
}
}
return *input - *expected;
}
int check_cache_entries(struct cache_entry *input, struct cache_entry *expected)
{
if (input == NULL) {
return 1;
}
if (check_strings(input->path, expected->path) != 0) {
return 1;
}
if (check_strings(input->content_type, expected->content_type) != 0) {
return 1;
}
if (check_strings(input->content, expected->content) != 0) {
return 1;
}
if (input->content_length != expected->content_length) {
return 1;
}
return 0;
}
#endif