shellmatta_opt.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /*
  2. * Copyright (c) 2019 Stefan Strobel <stefan.strobel@shimatta.net>
  3. *
  4. * This Source Code Form is subject to the terms of the Mozilla Public
  5. * License, v. 2.0. If a copy of the MPL was not distributed with this
  6. * file, You can obtain one at https://mozilla.org/MPL/2.0/.
  7. */
  8. /**
  9. * @file shellmatta_opt.c
  10. * @brief option parser implementation of the shellmatta
  11. * @author Stefan Strobel <stefan.strobel@shimatta.net>
  12. */
  13. /**
  14. * @addtogroup shellmatta_opt
  15. * @{
  16. */
  17. #include "shellmatta_opt.h"
  18. #include "shellmatta_utils.h"
  19. #include "shellmatta.h"
  20. #include <string.h>
  21. /**
  22. * @brief scans the current input and parses options in getopt style
  23. * @param[in] handle shellmatta handle
  24. * @param[in] optionString option string e.g. "cd:e::"
  25. * @param[out] option pointer to store the detected option to
  26. * @param[out] argument pointer to store the argument string to (can be NULL)
  27. * @param[out] argLen pointer to store the argument lengh to (can be NULL)
  28. */
  29. shellmatta_retCode_t shellmatta_opt( shellmatta_handle_t handle,
  30. char *optionString,
  31. char *option,
  32. char **argument,
  33. uint32_t *argLen)
  34. {
  35. shellmatta_retCode_t ret = SHELLMATTA_USE_FAULT;
  36. shellmatta_instance_t *inst = (shellmatta_instance_t*)handle;
  37. /** -# check parameters for plausibility */
  38. if( (NULL != inst)
  39. && (SHELLMATTA_MAGIC == inst->magic)
  40. && (NULL != optionString)
  41. && (NULL != option))
  42. {
  43. }
  44. (void)argument;
  45. (void)argLen;
  46. return ret;
  47. }
  48. /**
  49. * @brief scans the current input and parses options in getopt_long style
  50. * @param[in] handle shellmatta handle
  51. * @param[in] longOptions option structure - pointer to array of type #shellmatta_opt_long_t
  52. * @param[out] option pointer to store the detected option to
  53. * @param[out] argument pointer to store the argument string to (can be NULL)
  54. * @param[out] argLen pointer to store the argument lengh to (can be NULL)
  55. */
  56. shellmatta_retCode_t shellmatta_opt_long( shellmatta_handle_t handle,
  57. shellmatta_opt_long_t *longOptions,
  58. char *option,
  59. char **argument,
  60. uint32_t *argLen)
  61. {
  62. shellmatta_retCode_t ret = SHELLMATTA_USE_FAULT;
  63. shellmatta_instance_t *inst = (shellmatta_instance_t*)handle;
  64. /** -# check parameters for plausibility */
  65. if( (NULL != inst)
  66. && (SHELLMATTA_MAGIC == inst->magic)
  67. && (NULL != longOptions)
  68. && (NULL != option))
  69. {
  70. }
  71. (void)argument;
  72. (void)argLen;
  73. return ret;
  74. }
  75. /**
  76. * @brief initializes the option parser instance
  77. * @param[in, out] inst pointer to a shellmatta instance
  78. */
  79. shellmatta_retCode_t shellmatta_opt_init(shellmatta_instance_t *inst)
  80. {
  81. /*! -# initialize all relevant option parser variables */
  82. inst->optionParser.offset = 0u;
  83. return SHELLMATTA_OK;
  84. }
  85. /**
  86. * @}
  87. */