check.c 1016 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /* $Id: check.c,v 1.5 2001/04/29 17:45:19 kilobug Exp $ */
  2. #include "net_private.h"
  3. gboolean net_chk_string(int fd, const char *s)
  4. {
  5. char *st;
  6. gboolean res;
  7. if (s == NULL)
  8. return FALSE;
  9. st = net_get_string(fd);
  10. if (st == NULL)
  11. return FALSE;
  12. res = strcmp(s, st);
  13. g_free(st);
  14. return !res;
  15. }
  16. int net_chk_str_list(int fd, ...)
  17. {
  18. va_list va;
  19. char *st;
  20. const char *s;
  21. int res = -1;
  22. int i;
  23. va_start(va, fd);
  24. st = net_get_string(fd);
  25. if (st == NULL)
  26. return res;
  27. for (i = 0; ; i++)
  28. {
  29. s = va_arg(va, const char *);
  30. if (s == NULL)
  31. break;
  32. if (!strcmp(s, st))
  33. {
  34. res = i;
  35. break;
  36. }
  37. }
  38. va_end(va);
  39. g_free(st);
  40. return res;
  41. }
  42. gboolean net_chk_int(int fd, int val)
  43. {
  44. return (val == net_get_int(fd));
  45. }
  46. gboolean net_chk_flag(int fd, gboolean val)
  47. {
  48. return (val == net_get_flag(fd));
  49. }
  50. gboolean net_chk_char(int fd, char c)
  51. {
  52. return (c == net_get_char(c));
  53. }
  54. gboolean net_chk_float(int fd, float f)
  55. {
  56. return (f == net_get_char(f));
  57. }