All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
le_args.h File Reference

Go to the source code of this file.

Functions

le_result_t le_arg_GetProgramName (char *nameBuffPtr, size_t nameBuffSize, size_t *nameLenPtr)
 
size_t le_arg_NumArgs (void)
 
le_result_t le_arg_GetArg (const size_t argIndex, char *argBufferPtr, size_t argBufferSize)
 

Detailed Description

Legato Command Line Arguments API include file.

Copyright (C) Sierra Wireless, Inc. 2013. All rights reserved. Use of this work is subject to license.

Function Documentation

le_result_t le_arg_GetArg ( const size_t  argIndex,
char *  argBufferPtr,
size_t  argBufferSize 
)

Gets the command line argument by index. If argIndex is valid then the argument string is copied into argBufferPtr. At most only argBufferSize - 1 bytes will be copied to argBufferPtr and a terminating NULL character will always be inserted after the last copied byte.

The argument string is assumed to be a UTF-8 string. UTF-8 characters may be more than one byte long. Only copies whole characters, not partial characters. Even if LE_OVERFLOW is returned, argBufferPtr may not be completely filled. See Truncation for more details.

Returns
LE_OK if the argument was copied to argBufferPtr. LE_OVERFLOW if the argument was truncated when it was copied to argBufferPtr. LE_NOT_FOUND if the specified argument is not available.
Parameters
[in]argIndexIndex of the argument to get.
[out]argBufferPtrBuffer to copy the argument to.
[in]argBufferSizeSize of the buffer.
le_result_t le_arg_GetProgramName ( char *  nameBuffPtr,
size_t  nameBuffSize,
size_t *  nameLenPtr 
)

Gets the program name. The name of the running program is copied into the provided buffer.

The name is assumed to be a UTF-8 string. UTF-8 characters may be more than one byte long. Only copies whole characters, not partial characters. Even if LE_OVERFLOW is returned, argBufferPtr may not be completely filled. See Truncation for more details.

The copied string is always Null-terminated if it is available.

Returns
LE_OK if the program name was copied in full. LE_OVERFLOW if the program name was truncated when copied. LE_NOT_FOUND if the program is not available because argv and argc were not available.
Parameters
[out]nameBuffPtrBuffer to copy the program name to.
[in]nameBuffSizeSize of the buffer.
[out]nameLenPtrLength of the name copied to the buffer not including the NULL-terminator. This can be NULL if the name length is not needed.
size_t le_arg_NumArgs ( void  )

Gets the number of command line arguments available not including the program name.

Returns
Number of command line arguments available.