vcc.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /* vcc/include/vcc/vcc.h
  2. *
  3. * This file is part of vcc.
  4. *
  5. * vcc 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. * vcc 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 vcc. 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. #define VCC_MAGIC_CR 0x01328e36
  23. /* the port that vccd is listening on */
  24. #define VCC_PORT 46
  25. /* client -> server, send a message */
  26. #define REQ_MSG_SEND 1
  27. /* server -> client. sent when received a message */
  28. #define REQ_MSG_NEW 2
  29. /* client -> server. get users logged-in */
  30. #define REQ_CTL_USRS 3
  31. /* client -> server. login with password and username.
  32. * server -> client. login ack */
  33. #define REQ_CTL_LOGIN 4
  34. /* client -> server. create a new session */
  35. #define REQ_CTL_NEWSE 5
  36. /* client -> server: request (get sessions present).
  37. * server -> client: response */
  38. #define REQ_CTL_SESS 6
  39. /* client -> server. join session */
  40. #define REQ_CTL_JOINS 7
  41. /* client -> server. get user info */
  42. #define REQ_CTL_UINFO 8
  43. /* client -> server. increase one's score */
  44. #define REQ_SYS_SCRINC 9
  45. #define REQ_SIZE 512
  46. #define USRNAME_SIZE 32
  47. /* we'll not warn you anyway. */
  48. #define PASSWD_SIZE 64
  49. #define MSG_SIZE (REQ_SIZE - 5 * sizeof(int) - USRNAME_SIZE)
  50. #define FLAG_ENCRYPTED 1
  51. struct vcc_request {
  52. int magic;
  53. int reqtype;
  54. /* to make server easy and fast */
  55. int uid;
  56. int session;
  57. int flags;
  58. char usrname[USRNAME_SIZE];
  59. char msg[MSG_SIZE];
  60. };
  61. #define to_boolean(c) (!!(c))
  62. #define likely(c) __builtin_expect(to_boolean(c), 1)
  63. #define unlikely(c) __builtin_expect(to_boolean(c), 0)
  64. #endif