From c52321a52b378ed35b880341d021f40073df09e8 Mon Sep 17 00:00:00 2001 From: Matteo Cypriani Date: Fri, 26 Aug 2011 11:27:37 +0200 Subject: [PATCH] [UDP-HTTP] Use error codes from owlps.h --- owlps-udp-to-http/owlps-udp-to-http.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/owlps-udp-to-http/owlps-udp-to-http.c b/owlps-udp-to-http/owlps-udp-to-http.c index 86ef279..1b24d73 100644 --- a/owlps-udp-to-http/owlps-udp-to-http.c +++ b/owlps-udp-to-http/owlps-udp-to-http.c @@ -110,7 +110,7 @@ int main(int argc, char *argv[]) if (ret) { perror("Cannot create the TCP server thread") ; - ret = 1 ; + ret = OWL_ERR_THREAD_CREATE ; goto exit ; } @@ -156,14 +156,14 @@ int receive_udp() /* Open the UDP socket */ udp_sockfd = owl_create_udp_listening_socket(OWL_DEFAULT_RESULT_PORT) ; if (udp_sockfd < 0) - return 1 ; + return OWL_ERR_SOCKET_CREATE ; /* UDP read loop */ while (owl_run) { result = owl_receive_position(udp_sockfd) ; if (result == NULL) - return 1 ; + return OWL_ERR_SOCKET_RECV ; owl_print_result(result) ; store_result(result) ; printf("--------------\n") ; @@ -232,7 +232,7 @@ int init_tcp_socket() if (tcp_sockfd < 0) { perror("Error opening the TCP socket") ; - return tcp_sockfd ; + return OWL_ERR_SOCKET_CREATE ; } bzero((char *) &server_addr, sizeof(server_addr)) ; @@ -245,7 +245,7 @@ int init_tcp_socket() sizeof(server_addr)) < 0) { perror("Error binding the TCP socket") ; - return -1 ; + return OWL_ERR_SOCKET_CREATE ; } return 0 ; @@ -319,6 +319,10 @@ void* tcp_server(void *NULL_value) } +/* + * Reads a message and search for a request in it. + * Returns the identifier of a request if found, or 0 if not found. + */ int extract_request_from_message(char client_request[CLIENT_REQUEST_STRLEN], char *client_message)