lib_builtin_getname.c 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /****************************************************************************
  2. * libs/libc/builtin/libbuiltin_getname.c
  3. *
  4. * Originally by:
  5. *
  6. * Copyright (C) 2011 Uros Platise. All rights reserved.
  7. * Author: Uros Platise <uros.platise@isotel.eu>
  8. *
  9. * With subsequent updates, modifications, and general maintenance by:
  10. *
  11. * Copyright (C) 2012-2013, 2019 Gregory Nutt. All rights reserved.
  12. * Author: Gregory Nutt <gnutt@nuttx.org>
  13. *
  14. * Redistribution and use in source and binary forms, with or without
  15. * modification, are permitted provided that the following conditions
  16. * are met:
  17. *
  18. * 1. Redistributions of source code must retain the above copyright
  19. * notice, this list of conditions and the following disclaimer.
  20. * 2. Redistributions in binary form must reproduce the above copyright
  21. * notice, this list of conditions and the following disclaimer in
  22. * the documentation and/or other materials provided with the
  23. * distribution.
  24. * 3. Neither the name NuttX nor the names of its contributors may be
  25. * used to endorse or promote products derived from this software
  26. * without specific prior written permission.
  27. *
  28. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  29. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  30. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  31. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  32. * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  33. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  34. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  35. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  36. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  37. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
  38. * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  39. * POSSIBILITY OF SUCH DAMAGE.
  40. *
  41. ****************************************************************************/
  42. /****************************************************************************
  43. * Included Files
  44. ****************************************************************************/
  45. #include <nuttx/config.h>
  46. #include <nuttx/lib/builtin.h>
  47. /****************************************************************************
  48. * Public Functions
  49. ****************************************************************************/
  50. /****************************************************************************
  51. * Name: builtin_getname
  52. *
  53. * Description:
  54. * Returns pointer the a name of the application at 'index' in the table
  55. * of built-in applications.
  56. *
  57. * Input Parameters:
  58. * index - From 0 and on ...
  59. *
  60. * Returned Value:
  61. * Returns valid pointer pointing to the app name if index is valid.
  62. * Otherwise NULL is returned.
  63. *
  64. ****************************************************************************/
  65. FAR const char *builtin_getname(int index)
  66. {
  67. FAR const struct builtin_s *builtin;
  68. builtin = builtin_for_index(index);
  69. if (builtin != NULL)
  70. {
  71. return builtin->name;
  72. }
  73. return NULL;
  74. }