reword.c 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*====================================================================*
  2. *
  3. * Copyright (c) 2013 Qualcomm Atheros, Inc.
  4. *
  5. * All rights reserved.
  6. *
  7. *====================================================================*/
  8. /*====================================================================*
  9. *
  10. * char const * reword (code_t code, struct _code_ const list [], size_t size);
  11. *
  12. * symbol.h
  13. *
  14. * search a _code_ list by code and return the associated name; return the
  15. * corresponding name on success or NULL on failure;
  16. *
  17. * Contributor(s):
  18. * Nathaniel Houghton <nhoughto@qca.qualcomm.com>
  19. *
  20. *--------------------------------------------------------------------*/
  21. #ifndef REWORD_SOURCE
  22. #define REWORD_SOURCE
  23. #include <unistd.h>
  24. #include <string.h>
  25. #include "../tools/symbol.h"
  26. char const * reword (code_t code, struct _code_ const list [], size_t size)
  27. {
  28. struct _code_ const * item = list;
  29. while ((unsigned) (item - list) < size)
  30. {
  31. if (item->code == code)
  32. {
  33. return (item->name);
  34. }
  35. item++;
  36. }
  37. return (NULL);
  38. }
  39. #endif