diff --git a/include/libdivecomputer/Makefile.am b/include/libdivecomputer/Makefile.am index e4ff00b..2184a52 100644 --- a/include/libdivecomputer/Makefile.am +++ b/include/libdivecomputer/Makefile.am @@ -4,6 +4,7 @@ libdivecomputer_HEADERS = \ common.h \ utils.h \ buffer.h \ + descriptor.h \ iterator.h \ device.h \ parser.h \ diff --git a/include/libdivecomputer/descriptor.h b/include/libdivecomputer/descriptor.h new file mode 100644 index 0000000..9c8d816 --- /dev/null +++ b/include/libdivecomputer/descriptor.h @@ -0,0 +1,48 @@ +/* + * libdivecomputer + * + * Copyright (C) 2012 Jef Driesen + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#ifndef DC_DESCRIPTOR_H +#define DC_DESCRIPTOR_H + +#include "common.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +typedef struct dc_descriptor_t dc_descriptor_t; + +const char * +dc_descriptor_get_vendor (dc_descriptor_t *descriptor); + +const char * +dc_descriptor_get_product (dc_descriptor_t *descriptor); + +dc_family_t +dc_descriptor_get_type (dc_descriptor_t *descriptor); + +unsigned int +dc_descriptor_get_model (dc_descriptor_t *descriptor); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ +#endif /* DC_DESCRIPTOR_H */ diff --git a/src/Makefile.am b/src/Makefile.am index 17a213b..b215312 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -11,6 +11,7 @@ libdivecomputer_la_LDFLAGS = \ libdivecomputer_la_SOURCES = \ version.c \ + descriptor.c \ iterator-private.h iterator.c \ device-private.h device.c \ parser-private.h parser.c \ diff --git a/src/descriptor.c b/src/descriptor.c new file mode 100644 index 0000000..27ce5aa --- /dev/null +++ b/src/descriptor.c @@ -0,0 +1,68 @@ +/* + * libdivecomputer + * + * Copyright (C) 2012 Jef Driesen + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include +#include + +#include + +struct dc_descriptor_t { + const char *vendor; + const char *product; + dc_family_t type; + unsigned int model; +}; + +const char * +dc_descriptor_get_vendor (dc_descriptor_t *descriptor) +{ + if (descriptor == NULL) + return NULL; + + return descriptor->vendor; +} + +const char * +dc_descriptor_get_product (dc_descriptor_t *descriptor) +{ + if (descriptor == NULL) + return NULL; + + return descriptor->product; +} + +dc_family_t +dc_descriptor_get_type (dc_descriptor_t *descriptor) +{ + if (descriptor == NULL) + return DC_FAMILY_NULL; + + return descriptor->type; +} + +unsigned int +dc_descriptor_get_model (dc_descriptor_t *descriptor) +{ + if (descriptor == NULL) + return 0; + + return descriptor->model; +} diff --git a/src/libdivecomputer.symbols b/src/libdivecomputer.symbols index 6a07a74..4263a6a 100644 --- a/src/libdivecomputer.symbols +++ b/src/libdivecomputer.symbols @@ -20,6 +20,11 @@ dc_datetime_mktime dc_iterator_next dc_iterator_free +dc_descriptor_get_vendor +dc_descriptor_get_product +dc_descriptor_get_type +dc_descriptor_get_model + dc_parser_get_type dc_parser_set_data dc_parser_get_datetime