From ec688b4723a041044226358bcd4dd6e2da39da49 Mon Sep 17 00:00:00 2001 From: Luca Muscariello Date: Thu, 23 Feb 2017 17:01:02 +0100 Subject: Initial commit: cframework. Longbow and Libparc Change-Id: I90378dbd30da6033b20fb1f829b3b822cf366c59 Signed-off-by: Luca Muscariello --- libparc/parc/algol/parc_EventSocket.h | 116 ++++++++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100755 libparc/parc/algol/parc_EventSocket.h (limited to 'libparc/parc/algol/parc_EventSocket.h') diff --git a/libparc/parc/algol/parc_EventSocket.h b/libparc/parc/algol/parc_EventSocket.h new file mode 100755 index 00000000..48a11b25 --- /dev/null +++ b/libparc/parc/algol/parc_EventSocket.h @@ -0,0 +1,116 @@ +/* + * Copyright (c) 2017 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file parc_EventSocket.h + * @ingroup events + * @brief Socket events + * + * Provides a facade implementing many regularly available event functions. + * This is an interface that software implementors may use to substitute + * different kinds of underlying implementations of these event management functions. + * Notable examples are libevent and libev. + * + */ +#ifndef libparc_parc_EventSocket_h +#define libparc_parc_EventSocket_h + +#include +#include + +/** + * Current implementation based on top of libevent2 + */ + +#include +#include + +typedef struct PARCEventSocket PARCEventSocket; + +typedef void (PARCEventSocket_Callback)(int fd, struct sockaddr *address, + int socklen, void *user_data); +typedef void (PARCEventSocket_ErrorCallback)(PARCEventScheduler *, + int error, char *errorString, + void *user_data); + +/** + * Create a socket event handler instance. + * + * The event instance is passed in. + * + * @param [in] parcEventScheduler the scheduler instance + * @param [in] callback the callback function. + * @param [in] errorCallback the error callback function. + * @param [in] userData pointer to private arguments for instance callback function + * @param [in] sa is the socket address to bind to (INET, INET6, LOCAL) + * @param [in] socklen is the sizeof the actual sockaddr (e.g. sizeof(sockaddr_un)) + * @returns A pointer to a new PARCEventSocket instance. + * + * Example: + * @code + * { + * } + * @endcode + * + */ +PARCEventSocket *parcEventSocket_Create(PARCEventScheduler *parcEventScheduler, + PARCEventSocket_Callback *callback, + PARCEventSocket_ErrorCallback *errorCallback, + void *userData, + const struct sockaddr *sa, int socklen); + +/** + * Destroy a socket event handler instance. + * + * The event instance is passed in. + * + * @param [in] parcEventSocket the address of the instance to destroy. + * + * Example: + * @code + * { + * PARCEvent *event = parcEventSocket_Destroy(&parcEventSocket); + * } + * @endcode + * + */ +void parcEventSocket_Destroy(PARCEventSocket **parcEventSocket); + +/** + * Turn on debugging flags and messages + * + * Example: + * @code + * { + * parcEventSocket_EnableDebug(); + * } + * @endcode + * + */ +void parcEventSocket_EnableDebug(void); + +/** + * Turn off debugging flags and messages + * + * Example: + * @code + * { + * parcEventSocket_DisableDebug(); + * } + * @endcode + * + */ +void parcEventSocket_DisableDebug(void); +#endif // libparc_parc_EventSocket_h -- cgit 1.2.3-korg