Annotation of fam/fam/ServerConnection.h, Revision 1.1
1.1 ! trev 1: // Copyright (C) 1999 Silicon Graphics, Inc. All Rights Reserved.
! 2: //
! 3: // This program is free software; you can redistribute it and/or modify it
! 4: // under the terms of version 2 of the GNU General Public License as
! 5: // published by the Free Software Foundation.
! 6: //
! 7: // This program is distributed in the hope that it would be useful, but
! 8: // WITHOUT ANY WARRANTY; without even the implied warranty of
! 9: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Further, any
! 10: // license provided herein, whether implied or otherwise, is limited to
! 11: // this program in accordance with the express provisions of the GNU
! 12: // General Public License. Patent licenses, if any, provided herein do not
! 13: // apply to combinations of this program with other product or programs, or
! 14: // any other product whatsoever. This program is distributed without any
! 15: // warranty that the program is delivered free of the rightful claim of any
! 16: // third person by way of infringement or the like. See the GNU General
! 17: // Public License for more details.
! 18: //
! 19: // You should have received a copy of the GNU General Public License along
! 20: // with this program; if not, write the Free Software Foundation, Inc., 59
! 21: // Temple Place - Suite 330, Boston MA 02111-1307, USA.
! 22:
! 23: #ifndef ServerConnection_included
! 24: #define ServerConnection_included
! 25:
! 26: #include <string.h>
! 27: #include <limits.h>
! 28: #include <sys/param.h>
! 29:
! 30: #include "ClientInterest.h"
! 31: #include "NetConnection.h"
! 32: #include "Request.h"
! 33:
! 34: class Cred;
! 35:
! 36: // A ServerConnection implements the client side of the fam protocol,
! 37: // and it also handles network I/O. The various requests, monitor,
! 38: // cancel, etc., can be sent. When FAM events arrive, the
! 39: // EventHandler is called.
! 40: //
! 41: // ServerConnection inherits from NetConnection. This means that
! 42: // users of ServerConnection can test for I/O ready
! 43: // (ready_for_input(), ready_for_output()) and that they need to
! 44: // specify a DisconnectHandler which will be called when the server
! 45: // goes away.
! 46:
! 47: class ServerConnection : public NetConnection {
! 48:
! 49: public:
! 50:
! 51: typedef void (*EventHandler)(const Event*, Request, const char *path,
! 52: void *closure);
! 53: typedef void (*DisconnectHandler)(void *closure);
! 54:
! 55: ServerConnection(int fd, EventHandler, DisconnectHandler, void *closure);
! 56:
! 57: void send_monitor(ClientInterest::Type, Request,
! 58: const char *path, const Cred&);
! 59: void send_cancel(Request r) { mprintf("C%d 0 0\n", r); }
! 60: void send_suspend(Request r) { mprintf("S%d 0 0\n", r); }
! 61: void send_resume(Request r) { mprintf("U%d 0 0\n", r); }
! 62: void send_name(const char *n) { mprintf("N0 0 0 %s\n", n); }
! 63:
! 64: protected:
! 65:
! 66: bool input_msg(const char *msg, unsigned nbytes);
! 67:
! 68: private:
! 69:
! 70: EventHandler event_handler;
! 71: DisconnectHandler disconnect_handler;
! 72: void *closure;
! 73: };
! 74:
! 75: #endif /* !ServerConnection_included */
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>