vcc.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /* vccd/include/vcc/vcc.h
  2. *
  3. * This file is part of vccd.
  4. *
  5. * vccd is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * vccd is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with vccd. If not, see <https://www.gnu.org/licenses/>
  17. */
  18. #ifndef __VCC_VCC_H
  19. #define __VCC_VCC_H
  20. /* magic number in vcc_request to check that it's really a vcc package */
  21. #define VCC_MAGIC 0x01328e22
  22. /* the port that vccd is listening on */
  23. #define VCC_PORT 46
  24. /* client -> server, send a message */
  25. #define REQ_MSG_SEND 1
  26. /* server -> client. sent when received a message */
  27. #define REQ_MSG_NEW 2
  28. #define REQ_SIZE 4096
  29. #define USRNAME_SIZE 32
  30. #define MSG_SIZE (REQ_SIZE - 3 * sizeof(int) - USRNAME_SIZE)
  31. struct vcc_request {
  32. int magic;
  33. int reqtype;
  34. /* to make server easy and fast */
  35. int uid;
  36. char usrname[USRNAME_SIZE];
  37. char msg[MSG_SIZE];
  38. };
  39. #define to_boolean(c) (!!(c))
  40. #define likely(c) __builtin_expect(to_boolean(c), 1)
  41. #define unlikely(c) __builtin_expect(to_boolean(c), 0)
  42. #endif