-
Notifications
You must be signed in to change notification settings - Fork 0
/
string-utilities.h
38 lines (33 loc) · 1.09 KB
/
string-utilities.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
#ifndef STRING_UTILITIES_H
#define STRING_UTILITIES_H
#include <string.h>
#include <stdio.h>
#include <errno.h>
#include <stdlib.h>
#include <time.h>
#include "errors.h"
enum statusCode {
ERROR = 42,
LOG = 44,
OK = 200,
FORBIDDEN = 403,
NOT_FOUND = 404,
};
typedef struct l {
// char *id; // RFC 1413 identity of the client (not reliable, hyphen as placeholder)
// char *userid; // userid, HTTP authentication
// int status; // The returned status code
size_t size; // Size of object returned, not including headers (body size in bytes)
struct sockaddr *clientAddr;
char *req; // The request line from the client in double quotes
} LogData;
int stringFromFile(char *file, char **buffer);
int setHeader(char **header, int status, ssize_t mimeTypeIndex, size_t bodyLen);
int setBody(char **body, char filename[]);
int setStatusString(char **statusString, enum statusCode s);
int setResponse(char *filename, char **response, int status, ssize_t mimeTypeIndex,
int clientSocket, LogData *log);
ssize_t fileTypeAllowed(char *buffer);
void timestamp(char **t);
ssize_t firstLine(char *str, char **line);
#endif