You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

80 lines
3.1 KiB

  1. /***************************************************************************
  2. * Copyright (C) 2005 by Dominic Rath *
  3. * Dominic.Rath@gmx.de *
  4. * *
  5. * Copyright (C) 2007,2008 Øyvind Harboe *
  6. * oyvind.harboe@zylin.com *
  7. * *
  8. * This program is free software; you can redistribute it and/or modify *
  9. * it under the terms of the GNU General Public License as published by *
  10. * the Free Software Foundation; either version 2 of the License, or *
  11. * (at your option) any later version. *
  12. * *
  13. * This program is distributed in the hope that it will be useful, *
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  16. * GNU General Public License for more details. *
  17. * *
  18. * You should have received a copy of the GNU General Public License *
  19. * along with this program; if not, write to the *
  20. * Free Software Foundation, Inc., *
  21. * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
  22. ***************************************************************************/
  23. #ifndef SERVER_H
  24. #define SERVER_H
  25. #include "command.h"
  26. #include "binarybuffer.h"
  27. #include "replacements.h"
  28. #include <sys/types.h>
  29. enum connection_type
  30. {
  31. CONNECTION_GDB,
  32. CONNECTION_TELNET,
  33. CONNECTION_TCL,
  34. };
  35. typedef struct connection_s
  36. {
  37. int fd;
  38. struct sockaddr_in sin;
  39. command_context_t *cmd_ctx;
  40. struct service_s *service;
  41. int input_pending;
  42. void *priv;
  43. struct connection_s *next;
  44. } connection_t;
  45. typedef int (*new_connection_handler_t)(connection_t *connection);
  46. typedef int (*input_handler_t)(connection_t *connection);
  47. typedef int (*connection_closed_handler_t)(connection_t *connection);
  48. typedef struct service_s
  49. {
  50. char *name;
  51. enum connection_type type;
  52. unsigned short port;
  53. int fd;
  54. struct sockaddr_in sin;
  55. int max_connections;
  56. connection_t *connections;
  57. new_connection_handler_t new_connection;
  58. input_handler_t input;
  59. connection_closed_handler_t connection_closed;
  60. void *priv;
  61. struct service_s *next;
  62. } service_t;
  63. extern int add_service(char *name, enum connection_type type, unsigned short port, int max_connections, new_connection_handler_t new_connection_handler, input_handler_t input_handler, connection_closed_handler_t connection_closed_handler, void *priv);
  64. extern int server_init(void);
  65. extern int server_quit(void);
  66. extern int server_loop(command_context_t *command_context);
  67. extern int server_register_commands(command_context_t *context);
  68. #define ERROR_SERVER_REMOTE_CLOSED (-400)
  69. #define ERROR_CONNECTION_REJECTED (-401)
  70. #endif /* SERVER_H */