Modulo contenente funzioni di utilità per la gestione delle richieste/rispose http.
Continua...
|
int | send_http_response (int socket, enum http_status status, const char *header, const char *content, size_t content_lenght) |
| Invia una risposta HTTP/1.1. Continua...
|
|
Modulo contenente funzioni di utilità per la gestione delle richieste/rispose http.
◆ IMPORT_FILE
#define IMPORT_FILE |
( |
|
file, |
|
|
|
sym |
|
) |
| |
Valore:__asm__( \
".section \".rodata\" \n" \
".global " #sym "\n" \
".balign 16\n" \
#sym":\n" \
".incbin \"" file "\"\n" \
#sym "_end:\n" \
".balign 16\n" \
".global _sizeof_" #sym "\n" \
"_sizeof_" #sym":\n" \
".long " #sym "_end - " #sym "\n" \
".section \".text\" \n" \
); \
extern __attribute__((aligned(16))) const size_t _sizeof_ ## sym; \
extern __attribute__((aligned(16))) __attribute__((nonstring)) const char sym[]
Importa un file all'interno del codice.
- Parametri
-
file | Percorso del file da includere |
sym | Simbolo da usare per creare il puntatore al file |
- Restituisce
- sym (indirizzo di memoria) e _sizeof_sym (grandezza del file)
- Nota
- Se in uso lo standard c23, allora è consigliato utilizzare la direttiva
#embed
.
◆ send_http_response()
int send_http_response |
( |
int |
socket, |
|
|
enum http_status |
status, |
|
|
const char * |
header, |
|
|
const char * |
content, |
|
|
size_t |
content_lenght |
|
) |
| |
Invia una risposta HTTP/1.1.
- Parametri
-
socket | Socket tcp dove inviare i dati |
status | Stato HTTP della risposta |
header | Header della risposta (opzionale, se NULL non viene incluso) |
content | Dati del body da inviare (opzionale, se NULL non viene incluso) |
content_lenght | Dimenzione del content |
- Restituisce
- 0 se non ci sono stati errori