-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhttpd.h
More file actions
75 lines (57 loc) · 1.47 KB
/
httpd.h
File metadata and controls
75 lines (57 loc) · 1.47 KB
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
/*
SimpleSearch
author: Sam Chippas
email: [email protected]
Copyright (c) 2019
All Rights Reserved
*/
#ifndef SIMPLESEARCH_HTTPD_H_
#define SIMPLESEARCH_HTTPD_H_
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <pthread.h>
#include <errno.h>
#include <mysql/mysql.h>
#include <sstream>
//The max length the database is currently set to handle for variables.
const int MAX_LENGTH = 2048;
//A data structure for storing url information
struct urlList{
int words_url;
char *url_data;
char *url_title;
char *url_desc;
int relevance;
};
//A simple HTTP server
class HTTPD{
//default port and queue length values
int httpdPort = 8989;
int QueueLength = 5;
int poolC = 0;
public:
//Credentials for the MySQL database
//Change as needed.
const char *mysql_address = "127.0.0.1";
const char *mysql_user = "root";
const char *mysql_pass = NULL;
const char *mysql_schema = "SimpleSearch";
int mysql_port = 3306;
//constructor for a new instance of the server
HTTPD(int port, int thread);
//Responds to requests with appropriate data
virtual void response(int fd, const char * document);
//Runs continously to process new requests
void run();
//Used when using a pool of threads to serve requests.
int threadPool(int fd);
//Processes incoming HTTP requests
void processHTTPRequest(int fd);
};
#endif //SIMPLESEARCH_HTTPD_H_