utils_disk.c 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /****************************************************************************
  2. * Utils for check_disk
  3. *
  4. * License: GPL
  5. * Copyright (c) 1999-2006 nagios-plugins team
  6. *
  7. * Last Modified: $Date$
  8. *
  9. * Description:
  10. *
  11. * This file contains utilities for check_disk. These are tested by libtap
  12. *
  13. * License Information:
  14. *
  15. * This program is free software; you can redistribute it and/or modify
  16. * it under the terms of the GNU General Public License as published by
  17. * the Free Software Foundation; either version 2 of the License, or
  18. * (at your option) any later version.
  19. *
  20. * This program is distributed in the hope that it will be useful,
  21. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  22. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  23. * GNU General Public License for more details.
  24. *
  25. * You should have received a copy of the GNU General Public License
  26. * along with this program; if not, write to the Free Software
  27. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  28. *
  29. * $Id$
  30. *
  31. *****************************************************************************/
  32. #include "common.h"
  33. #include "utils_disk.h"
  34. void
  35. np_add_name (struct name_list **list, const char *name)
  36. {
  37. struct name_list *new_entry;
  38. new_entry = (struct name_list *) malloc (sizeof *new_entry);
  39. new_entry->name = (char *) name;
  40. new_entry->next = *list;
  41. *list = new_entry;
  42. }
  43. /* Returns TRUE if name is in list */
  44. int
  45. np_find_name (struct name_list *list, const char *name)
  46. {
  47. const struct name_list *n;
  48. if (list == NULL || name == NULL) {
  49. return FALSE;
  50. }
  51. for (n = list; n; n = n->next) {
  52. if (!strcmp(name, n->name)) {
  53. return TRUE;
  54. }
  55. }
  56. return FALSE;
  57. }