1 /** @file 2 3 A brief file description 4 5 @section license License 6 7 Licensed to the Apache Software Foundation (ASF) under one 8 or more contributor license agreements. See the NOTICE file 9 distributed with this work for additional information 10 regarding copyright ownership. The ASF licenses this file 11 to you under the Apache License, Version 2.0 (the 12 "License"); you may not use this file except in compliance 13 with the License. You may obtain a copy of the License at 14 15 http://www.apache.org/licenses/LICENSE-2.0 16 17 Unless required by applicable law or agreed to in writing, software 18 distributed under the License is distributed on an "AS IS" BASIS, 19 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 See the License for the specific language governing permissions and 21 limitations under the License. 22 */ 23 24 /*************************************************************************** 25 * EventCallback.h 26 * Purpose: defines the CallbackTable which stores callback functions for 27 * specific events 28 * 29 * 30 ***************************************************************************/ 31 /* 32 * EventCallback.h 33 * 34 * defines the CallbackTable which stores callback functions for 35 * specific events. Used by both local api and remote api. 36 */ 37 38 #pragma once 39 40 #include "tscore/ink_llqueue.h" 41 42 #include "mgmtapi.h" 43 #include "CoreAPIShared.h" 44 45 // when registering the callback function, can pass in void* data which 46 // will then be passed to the callback function; need to store this data with 47 // the callback in a struct 48 typedef struct { 49 TSEventSignalFunc func; 50 void *data; 51 } EventCallbackT; 52 53 // event_call_back_l is a queue of EventCallbackT 54 typedef struct { 55 LLQ *event_callback_l[NUM_EVENTS]; 56 ink_mutex event_callback_lock; 57 } CallbackTable; 58 59 #ifdef __cplusplus 60 extern "C" { 61 #endif /* __cplusplus */ 62 63 EventCallbackT *create_event_callback(TSEventSignalFunc func, void *data); 64 void delete_event_callback(EventCallbackT *event_cb); 65 66 CallbackTable *create_callback_table(const char *lock_name); 67 68 void delete_callback_table(CallbackTable *cb_table); 69 70 // returns list of event_id that have at least one callback registered for it 71 LLQ *get_events_with_callbacks(CallbackTable *cb_table); 72 73 TSMgmtError cb_table_register(CallbackTable *cb_table, const char *event_name, TSEventSignalFunc func, void *data, bool *first_cb); 74 TSMgmtError cb_table_unregister(CallbackTable *cb_table, const char *event_name, TSEventSignalFunc func); 75 76 #ifdef __cplusplus 77 } 78 #endif /* __cplusplus */ 79