/* * This file is part of the Owl Positioning System (OwlPS). * OwlPS is a project of the University of Franche-Comte * (Université de Franche-Comté), France. * * Copyright © Université de Franche-Comté 2007-2012. * * Corresponding author: Matteo Cypriani * *********************************************************************** * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, * modify and/or redistribute the software under the terms of the CeCILL * license as circulated by CEA, CNRS and INRIA at the following URL: * http://www.cecill.info * * As a counterpart to the access to the source code and rights to copy, * modify and redistribute granted by the license, users are provided * only with a limited warranty and the software's authors, the holder * of the economic rights, and the successive licensors have only * limited liability. * * In this respect, the user's attention is drawn to the risks * associated with loading, using, modifying and/or developing or * reproducing the software by the user in light of its specific status * of free software, that may mean that it is complicated to manipulate, * and that also therefore means that it is reserved for developers and * experienced professionals having in-depth computer knowledge. Users * are therefore encouraged to load and test the software's suitability * as regards their requirements in conditions enabling the security of * their systems and/or data to be ensured and, more generally, to use * and operate it in the same conditions as regards security. * * The fact that you are presently reading this means that you have had * knowledge of the CeCILL license and that you accept its terms. * *********************************************************************** * * This is the header file of libowlps-resultreader, the library that * provides functions to read results sent on UDP by OwlPS Positioner. * * See also the example program owlps-resultreader-udp.c. */ #ifndef _LIBOWLPS_RESULTREADER_CSV_ #define _LIBOWLPS_RESULTREADER_CSV_ #include #include #include /* Maximum size of a result CSV string sent by OwlPS Positioner. * Request's information: * MAC, request type (2 chars), timestamp, ';' * Plus, for each algorithm: * Name, three coordinates, error (we assume the same size as the * coordinates), area name, ';' * Let's define OWL_NB_ALGORITHMS as the number of implemented * algorithms (this is ugly). */ #define OWL_NB_ALGORITHMS 10 #define OWL_CSV_RESULT_REQUEST_STRLEN \ (OWL_ETHER_ADDR_STRLEN + OWL_TIMESTAMP_STRLEN + 3) #define OWL_CSV_ALGORITHM_RESULT_STRLEN \ (OWL_ALGORITHM_STRLEN + 4 * OWL_COORDINATE_STRLEN + \ OWL_AREA_STRLEN + 1) #define OWL_CSV_RESULT_STRLEN \ (OWL_CSV_RESULT_REQUEST_STRLEN + \ OWL_NB_ALGORITHMS * OWL_CSV_ALGORITHM_RESULT_STRLEN + 1) /* Same thing, but for the simplified CSV strings created by * *_to_csv_simple(). * Request's information is only the MAC address. * For the algorithm: * = 12 characters per coordinate + OWL_AREA_STRLEN */ #define OWL_CSV_RESULT_REQUEST_SIMPLE_STRLEN OWL_ETHER_ADDR_STRLEN #define OWL_CSV_ALGORITHM_RESULT_SIMPLE_STRLEN \ (3 * OWL_COORDINATE_STRLEN + OWL_AREA_STRLEN + 1) #define OWL_CSV_RESULT_SIMPLE_STRLEN \ (OWL_CSV_RESULT_REQUEST_SIMPLE_STRLEN + \ OWL_NB_ALGORITHMS * OWL_CSV_ALGORITHM_RESULT_SIMPLE_STRLEN + 1) /* Linked list of algorithms' results. * Each structure is the result of a single algorithm. */ typedef struct _owl_algorithm_result { char *algorithm ; float x ; float y ; float z ; float error ; char *area ; struct _owl_algorithm_result *next ; } owl_algorithm_result ; /* Results for a request. Includes the request's data, and the * list of algorithms' results. */ typedef struct _owl_result { char *mobile_mac_addr ; uint8_t request_type ; owl_timestamp mobile_timestamp ; unsigned int nb_results ; owl_algorithm_result *results ; } owl_result ; owl_result* owl_receive_position(int sockfd) ; owl_result* owl_fill_result(char *csv) ; owl_algorithm_result* owl_fill_algorithm_result(char **csv) ; void owl_result_to_csv(char dst[OWL_CSV_RESULT_STRLEN], const owl_result *const src) ; void owl_algorithm_result_to_csv(char dst[OWL_CSV_ALGORITHM_RESULT_STRLEN], const owl_algorithm_result *const src) ; void owl_result_to_csv_simple(char dst[OWL_CSV_RESULT_SIMPLE_STRLEN], const owl_result *const src) ; void owl_algorithm_result_to_csv_simple (char dst[OWL_CSV_ALGORITHM_RESULT_SIMPLE_STRLEN], const owl_algorithm_result *const src) ; void owl_fprint_result(FILE *stream, const owl_result *const src) ; void owl_fprint_algorithm_result(FILE *stream, const owl_algorithm_result *const src) ; #define owl_print_result(SRC) \ (owl_fprint_result(stdout, (SRC))) #define owl_print_algorithm_result(SRC) \ (owl_fprint_algorithm_result(stdout, (SRC))) void owl_free_result(owl_result *result) ; void owl_free_algorithm_result(owl_algorithm_result *algo) ; #endif // _LIBOWLPS_RESULTREADER_CSV_