#include <sys/types.h>
#include "string.h"
#include "base64.h"
Go to the source code of this file.
|
void | templates_init (struct templates *p_tem) |
| Initializes a template structure by opening and reading all files. More...
|
|
void | templates_deinit (struct templates *p_tem) |
| Frees (de-initializes) memory used by a template structure. More...
|
|
void | parse_client_request (const char *client_request, size_t data_len, char *method, char *path, char *version, int *p_cookie_x, int *p_cookie_y, int *p_cookie_found) |
| Parses a client request and gets all needed information: More...
|
|
void | generate_html_table (struct string *robot_grid, const int x_max, const int y_max, const int x_coord, const int y_coord) |
| Generates the HTML table with the robot in the good case from given coordinates. More...
|
|
◆ string_append_literal
◆ generate_html_table()
void generate_html_table |
( |
struct string * |
robot_grid, |
|
|
const int |
x_max, |
|
|
const int |
y_max, |
|
|
const int |
x_coord, |
|
|
const int |
y_coord |
|
) |
| |
Generates the HTML table with the robot in the good case from given coordinates.
- Parameters
-
robot_grid | Pointer for the result. |
x_max | Value max for x (so number of lines in the grid - 1). |
y_max | Value max for y (so number of columns in the grid - 1). |
x_coord | Robot's x coordinate. |
y_coord | Robot's y coordinate. |
◆ parse_client_request()
void parse_client_request |
( |
const char * |
client_request, |
|
|
size_t |
data_len, |
|
|
char * |
method, |
|
|
char * |
path, |
|
|
char * |
version, |
|
|
int * |
p_cookie_x, |
|
|
int * |
p_cookie_y, |
|
|
int * |
p_cookie_found |
|
) |
| |
Parses a client request and gets all needed information:
From the first line of the request:
- method (e.g. GET, POST…)
- path (e.g. /data/template.css)
- HTTP version (e.g. HTTP/1)
From the cookies:
- Are there cookies or not ?
- If yes, x and y coordinates of robot.
- Parameters
-
client_request | Pointer to the client's request string. |
data_len | Size of client's request. |
method | Pointer for the method (initialze with char method[16]; ). |
path | Pointer for the path. (initialze with char path[1024]; ). |
version | Pointer for the version (initialze with char version[16]; ). |
p_cookie_x | Pointer for the x coordinate in the cookies. |
p_cookie_y | Pointer for the y coordinate in the cookies. |
p_cookie_found | Pointer for a boolean to know if there is a cookie: 1 if cookie was found, otherwise 0. |
◆ templates_deinit()
void templates_deinit |
( |
struct templates * |
p_tem | ) |
|
Frees (de-initializes) memory used by a template structure.
- Parameters
-
p_tem | Pointer to the template structure to de-initialize. |
◆ templates_init()
void templates_init |
( |
struct templates * |
p_tem | ) |
|
Initializes a template structure by opening and reading all files.
Uses the open_and_read() function from base64.h.
- Parameters
-
p_tem | Pointer to the template structure to initialize. |