Skip to content

Commit

Permalink
CCB 20191218: Merge #10
Browse files Browse the repository at this point in the history
Fix #8 
Reviewed and approved at 2019-12-18 CCB
  • Loading branch information
skliper authored Dec 30, 2019
2 parents e86d374 + 2264f97 commit da4f56d
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 4 deletions.
21 changes: 21 additions & 0 deletions fsw/public_inc/sample_lib.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,27 @@
/*************************************************************************
** Exported Functions
*************************************************************************/

/************************************************************************/
/** \brief Library Initialization Function
**
** \par Description
** This function is required by CFE to initialize the library
** It should be specified in the cfe_es_startup.scr file as part
** of loading this library. It is not directly invoked by
** applications.
**
** \par Assumptions, External Events, and Notes:
** None
**
** \returns
** \retstmt Returns #CFE_SUCCESS if successful \endcode
** \endreturns
**
*************************************************************************/
int32 SAMPLE_LibInit(void);


/************************************************************************/
/** \brief Sample Lib Function
**
Expand Down
32 changes: 28 additions & 4 deletions fsw/src/sample_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,20 @@
#include "sample_lib.h"
#include "sample_lib_version.h"

/* for "strncpy()" */
#include <string.h>

/*************************************************************************
** Macro Definitions
*************************************************************************/

#define SAMPLE_LIB_BUFFER_SIZE 16


/*************************************************************************
** Private Function Prototypes
** Private Data Structures
*************************************************************************/
int32 SAMPLE_LibInit(void);
static char SAMPLE_Buffer[SAMPLE_LIB_BUFFER_SIZE];

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
Expand All @@ -49,8 +54,27 @@ int32 SAMPLE_LibInit(void);
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
int32 SAMPLE_LibInit(void)
{
/*
* Call a C library function, like strcpy(), and test its result.
*
* This is primary for a unit test example, to have more than
* one code path to exercise.
*
* The specification for strncpy() indicates that it should return
* the pointer to the destination buffer, so it should be impossible
* for this to ever fail when linked with a compliant C library.
*/
if (strncpy(SAMPLE_Buffer, "SAMPLE DATA", sizeof(SAMPLE_Buffer)-1) !=
SAMPLE_Buffer)
{
return CFE_STATUS_NOT_IMPLEMENTED;
}

OS_printf ("SAMPLE Lib Initialized. Version %d.%d.%d.%d",
/* ensure termination */
SAMPLE_Buffer[sizeof(SAMPLE_Buffer)-1] = 0;


OS_printf ("SAMPLE Lib Initialized. Version %d.%d.%d.%d\n",
SAMPLE_LIB_MAJOR_VERSION,
SAMPLE_LIB_MINOR_VERSION,
SAMPLE_LIB_REVISION,
Expand All @@ -67,7 +91,7 @@ int32 SAMPLE_LibInit(void)
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
int32 SAMPLE_Function( void )
{
OS_printf ("SAMPLE_Function called\n");
OS_printf ("SAMPLE_Function called, buffer=\'%s\'\n", SAMPLE_Buffer);

return(CFE_SUCCESS);

Expand Down

0 comments on commit da4f56d

Please sign in to comment.