codelist.c 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*====================================================================*
  2. *
  3. * void codelist (struct _code_ const list [], size_t size, char const * comma, FILE * fp);
  4. *
  5. * symbol.h
  6. *
  7. * print a list of code names on the specified output stream;
  8. *
  9. * Motley Tools by Charles Maier <cmaier@cmassoc.net>;
  10. * Copyright (c) 2001-2006 by Charles Maier Associates;
  11. * Licensed under the Internet Software Consortium License;
  12. *
  13. *--------------------------------------------------------------------*/
  14. #ifndef CODELIST_SOURCE
  15. #define CODELIST_SOURCE
  16. #include <stdio.h>
  17. #include "../tools/symbol.h"
  18. void codelist (struct _code_ const list [], size_t size, char const * comma, char const * quote, FILE * fp)
  19. {
  20. struct _code_ const * item = list;
  21. if (list) while ((size_t) (item - list) < size)
  22. {
  23. if (item > list)
  24. {
  25. fputs (comma, fp);
  26. }
  27. if ((quote) && (* quote))
  28. {
  29. fputc (* quote++, fp);
  30. }
  31. fputs (item->name, fp);
  32. if ((quote) && (* quote))
  33. {
  34. fputc (* quote--, fp);
  35. }
  36. item++;
  37. }
  38. return;
  39. }
  40. #endif