Added signal.h
This commit is contained in:
@@ -5,6 +5,8 @@
|
|||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
|
|
||||||
|
#include <signal.h>
|
||||||
|
|
||||||
#include "sendmysql.h"
|
#include "sendmysql.h"
|
||||||
#include "calculate.h"
|
#include "calculate.h"
|
||||||
|
|
||||||
@@ -15,6 +17,18 @@
|
|||||||
#define PORT 1337
|
#define PORT 1337
|
||||||
#define PREFIX "/abshum"
|
#define PREFIX "/abshum"
|
||||||
|
|
||||||
|
|
||||||
|
struct _u_instance instance;
|
||||||
|
|
||||||
|
|
||||||
|
void exitFunction(void) {
|
||||||
|
printf("Exiting HumidityServer.\n");
|
||||||
|
ulfius_stop_framework(&instance);
|
||||||
|
ulfius_clean_instance(&instance);
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int callback_welcome (const struct _u_request * request, struct _u_response * response, void * user_data) {
|
int callback_welcome (const struct _u_request * request, struct _u_response * response, void * user_data) {
|
||||||
ulfius_set_string_body_response(response, 200, "Welcome to the HumidityPi rest service!");
|
ulfius_set_string_body_response(response, 200, "Welcome to the HumidityPi rest service!");
|
||||||
return U_CALLBACK_CONTINUE;
|
return U_CALLBACK_CONTINUE;
|
||||||
@@ -98,8 +112,8 @@ int callback_absTempHum(const struct _u_request *request, struct _u_response *re
|
|||||||
|
|
||||||
|
|
||||||
int main(void) {
|
int main(void) {
|
||||||
struct _u_instance instance;
|
|
||||||
|
|
||||||
|
atexit(exitFunction);
|
||||||
// Initialize instance with the port number
|
// Initialize instance with the port number
|
||||||
if (ulfius_init_instance(&instance, PORT, NULL, NULL) != U_OK) {
|
if (ulfius_init_instance(&instance, PORT, NULL, NULL) != U_OK) {
|
||||||
fprintf(stderr, "Error ulfius_init_instance, abort\n");
|
fprintf(stderr, "Error ulfius_init_instance, abort\n");
|
||||||
@@ -121,9 +135,6 @@ int main(void) {
|
|||||||
}
|
}
|
||||||
printf("End framework\n");
|
printf("End framework\n");
|
||||||
|
|
||||||
ulfius_stop_framework(&instance);
|
|
||||||
ulfius_clean_instance(&instance);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user