root/opal/mca/event/libevent2022/libevent/include/event2/rpc_struct.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


   1 /*
   2  * Copyright (c) 2006-2007 Niels Provos <provos@citi.umich.edu>
   3  * Copyright (c) 2007-2012 Niels Provos and Nick Mathewson
   4  *
   5  * Redistribution and use in source and binary forms, with or without
   6  * modification, are permitted provided that the following conditions
   7  * are met:
   8  * 1. Redistributions of source code must retain the above copyright
   9  *    notice, this list of conditions and the following disclaimer.
  10  * 2. Redistributions in binary form must reproduce the above copyright
  11  *    notice, this list of conditions and the following disclaimer in the
  12  *    documentation and/or other materials provided with the distribution.
  13  * 3. The name of the author may not be used to endorse or promote products
  14  *    derived from this software without specific prior written permission.
  15  *
  16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  17  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  18  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  19  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  20  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  21  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  22  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  23  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  25  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26  */
  27 #ifndef _EVENT2_RPC_STRUCT_H_
  28 #define _EVENT2_RPC_STRUCT_H_
  29 
  30 #ifdef __cplusplus
  31 extern "C" {
  32 #endif
  33 
  34 /** @file event2/rpc_struct.h
  35 
  36   Structures used by rpc.h.  Using these structures directly may harm
  37   forward compatibility: be careful!
  38 
  39  */
  40 
  41 /**
  42  * provides information about the completed RPC request.
  43  */
  44 struct evrpc_status {
  45 #define EVRPC_STATUS_ERR_NONE           0
  46 #define EVRPC_STATUS_ERR_TIMEOUT        1
  47 #define EVRPC_STATUS_ERR_BADPAYLOAD     2
  48 #define EVRPC_STATUS_ERR_UNSTARTED      3
  49 #define EVRPC_STATUS_ERR_HOOKABORTED    4
  50         int error;
  51 
  52         /* for looking at headers or other information */
  53         struct evhttp_request *http_req;
  54 };
  55 
  56 /* the structure below needs to be synchronized with evrpc_req_generic */
  57 
  58 /* Encapsulates a request */
  59 struct evrpc {
  60         TAILQ_ENTRY(evrpc) next;
  61 
  62         /* the URI at which the request handler lives */
  63         const char* uri;
  64 
  65         /* creates a new request structure */
  66         void *(*request_new)(void *);
  67         void *request_new_arg;
  68 
  69         /* frees the request structure */
  70         void (*request_free)(void *);
  71 
  72         /* unmarshals the buffer into the proper request structure */
  73         int (*request_unmarshal)(void *, struct evbuffer *);
  74 
  75         /* creates a new reply structure */
  76         void *(*reply_new)(void *);
  77         void *reply_new_arg;
  78 
  79         /* frees the reply structure */
  80         void (*reply_free)(void *);
  81 
  82         /* verifies that the reply is valid */
  83         int (*reply_complete)(void *);
  84 
  85         /* marshals the reply into a buffer */
  86         void (*reply_marshal)(struct evbuffer*, void *);
  87 
  88         /* the callback invoked for each received rpc */
  89         void (*cb)(struct evrpc_req_generic *, void *);
  90         void *cb_arg;
  91 
  92         /* reference for further configuration */
  93         struct evrpc_base *base;
  94 };
  95 
  96 #ifdef __cplusplus
  97 }
  98 #endif
  99 
 100 #endif /* _EVENT2_RPC_STRUCT_H_ */

/* [<][>][^][v][top][bottom][index][help] */