diff --git a/src/gmio_stl/stlb_header.c b/src/gmio_stl/stlb_header.c new file mode 100644 index 0000000..9ade45c --- /dev/null +++ b/src/gmio_stl/stlb_header.c @@ -0,0 +1,26 @@ +/**************************************************************************** +** gmio +** Copyright Fougue (2 Mar. 2015) +** contact@fougue.pro +** +** This software is a reusable library whose purpose is to provide complete +** I/O support for various CAD file formats (eg. STL) +** +** This software is governed by the CeCILL-B 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-B +** license as circulated by CEA, CNRS and INRIA at the following URL +** "http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html". +****************************************************************************/ + +#include "stlb_header.h" + +#include + +struct gmio_stlb_header gmio_stlb_header_str(const char* str) +{ + struct gmio_stlb_header header = {0}; + if (str != NULL) + strncpy((char*)header.data, str, GMIO_STLB_HEADER_SIZE); + return header; +} diff --git a/src/gmio_stl/stlb_header.h b/src/gmio_stl/stlb_header.h index 64b7ff3..b1b68fe 100644 --- a/src/gmio_stl/stlb_header.h +++ b/src/gmio_stl/stlb_header.h @@ -32,5 +32,19 @@ struct gmio_stlb_header uint8_t data[GMIO_STLB_HEADER_SIZE]; }; +GMIO_C_LINKAGE_BEGIN + +/*! Returns a gmio_stlb_header object whose contents is a copy of \p str + * + * Only the first \c GMIO_STLB_HEADER_SIZE characters are copied. + * + * If the length of \p str is less than \c GMIO_STLB_HEADER_SIZE then the + * remaining bytes are filled with zeroes. + */ +GMIO_LIBSTL_EXPORT +struct gmio_stlb_header gmio_stlb_header_str(const char* str); + +GMIO_C_LINKAGE_END + #endif /* GMIO_STLB_HEADER_H */ /*! @} */