gmio_stl: add function gmio_stlb_header_str

This commit is contained in:
Hugues Delorme 2015-12-18 10:38:18 +01:00
parent b514f12cc3
commit ce50f76ef0
2 changed files with 40 additions and 0 deletions

View File

@ -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 <string.h>
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;
}

View File

@ -32,5 +32,19 @@ struct gmio_stlb_header
uint8_t data[GMIO_STLB_HEADER_SIZE]; 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 */ #endif /* GMIO_STLB_HEADER_H */
/*! @} */ /*! @} */