home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / ABUSESRC.ZIP / AbuseSrc / abuse / src / net / unix / netdrv.hpp < prev    next >
Encoding:
C/C++ Source or Header  |  1995-11-28  |  2.3 KB  |  98 lines

  1. #ifndef __NETDRV_HPP_
  2. #define __NETDRV_HPP_
  3.  
  4. #error hi
  5. #include "netface.hpp"
  6. #include <unistd.h>
  7. #include "undrv.hpp"
  8. // these are the names of the fifos to create in tmp
  9. // that communitcate with the engine
  10.  
  11. #define DIN_NAME "/tmp/.abuse_ndrv_in"
  12. #define DOUT_NAME "/tmp/.abuse_ndrv_out"
  13.  
  14. // the lock files is used in case a previous net driver is already running
  15.  
  16. #define DLOCK_NAME "/tmp/.abuse_ndrv_lock"
  17. #include "sock.hpp"
  18.  
  19.  
  20. class game_handler;
  21.  
  22. class net_driver
  23. {
  24.   net_socket *in,*out;
  25.   int shm_seg_id;  
  26.   void *shm_addr;
  27.  
  28.   int connect_to_engine(int argc, char **argv);
  29.   int setup_shm();
  30.   game_handler *game_face;
  31.   int join_server(char *server_name);
  32.   net_protocol *proto;
  33.   int comm_port, game_port;
  34.   join_struct *join_array;
  35.   int debug;
  36.   int reg;
  37.  
  38.   class lsf_waiter
  39.   {
  40.     public :
  41.     net_socket *sock;
  42.     lsf_waiter *next;
  43.     lsf_waiter(net_socket *sock, lsf_waiter *next) : sock(sock), next(next)
  44.     { 
  45.       sock->read_selectable();  // set in case socket dies   
  46.     } ;
  47.     ~lsf_waiter() 
  48.     { 
  49.       sock->read_unselectable();
  50.       delete sock;
  51.     }    
  52.   } *lsf_wait_list;
  53.  
  54.  
  55.   class crc_waiter
  56.   {
  57.     public :
  58.     net_socket *sock;
  59.     crc_waiter *next;
  60.     crc_waiter(net_socket *sock, crc_waiter *next) : sock(sock), next(next)
  61.     { 
  62.       sock->read_selectable();  // set in case socket dies
  63.     } ;
  64.     ~crc_waiter() 
  65.     { 
  66.       sock->read_unselectable();
  67.       delete sock;
  68.     }    
  69.   } *crc_wait_list;
  70.  
  71.   int fetch_crcs(char *server);
  72.   int get_lsf(char *name);  // contact remot host and ask for lisp startup file filename
  73.  
  74.   public :
  75.   base_memory_struct *base;
  76.  
  77.   void cleanup();
  78.   int registered() { return reg; }
  79.   net_driver(int argc, char **argv, int comm_port, int game_port, net_protocol *proto);
  80.   int check_commands();
  81.   int add_client(int type, net_socket *sock, net_address *from);
  82.   int add_joiner(int client_id, char *name);
  83.   net_socket *connect_to_server(char *&name, 
  84.                 int port=DEFAULT_COMM_PORT, 
  85.                 int force_port=0, 
  86.                 net_socket::socket_type sock_type=net_socket::SOCKET_SECURE);
  87.   net_protocol *get_protocol() { return proto; }
  88.   int become_server();
  89.   int get_game_port() { return game_port; }
  90.   ~net_driver();
  91. } ;
  92.  
  93. extern net_driver *driver;
  94. void mdie(char *reason);
  95.  
  96. #endif
  97.  
  98.