io.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. * Copyright (C) 2007-2008 Wayne Davison
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License along
  15. * with this program; if not, visit the http://fsf.org website.
  16. */
  17. extern int protocol_version;
  18. static inline int32
  19. read_varint30(int f)
  20. {
  21. if (protocol_version < 30)
  22. return read_int(f);
  23. return read_varint(f);
  24. }
  25. static inline int64
  26. read_varlong30(int f, uchar min_bytes)
  27. {
  28. if (protocol_version < 30)
  29. return read_longint(f);
  30. return read_varlong(f, min_bytes);
  31. }
  32. static inline void
  33. write_varint30(int f, int32 x)
  34. {
  35. if (protocol_version < 30)
  36. write_int(f, x);
  37. else
  38. write_varint(f, x);
  39. }
  40. static inline void
  41. write_varlong30(int f, int64 x, uchar min_bytes)
  42. {
  43. if (protocol_version < 30)
  44. write_longint(f, x);
  45. else
  46. write_varlong(f, x, min_bytes);
  47. }