| 1 |
#ifndef PROACTOR_PROACTOR_INTERNAL_H |
| 2 |
#define PROACTOR_PROACTOR_INTERNAL_H |
| 3 |
|
| 4 |
/* |
| 5 |
* Licensed to the Apache Software Foundation (ASF) under one |
| 6 |
* or more contributor license agreements. See the NOTICE file |
| 7 |
* distributed with this work for additional information |
| 8 |
* regarding copyright ownership. The ASF licenses this file |
| 9 |
* to you under the Apache License, Version 2.0 (the |
| 10 |
* "License"); you may not use this file except in compliance |
| 11 |
* with the License. You may obtain a copy of the License at |
| 12 |
* |
| 13 |
* http://www.apache.org/licenses/LICENSE-2.0 |
| 14 |
* |
| 15 |
* Unless required by applicable law or agreed to in writing, |
| 16 |
* software distributed under the License is distributed on an |
| 17 |
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 18 |
* KIND, either express or implied. See the License for the |
| 19 |
* specific language governing permissions and limitations |
| 20 |
* under the License. |
| 21 |
*/ |
| 22 |
|
| 23 |
#include <proton/condition.h> |
| 24 |
#include <proton/event.h> |
| 25 |
#include <proton/import_export.h> |
| 26 |
#include <proton/type_compat.h> |
| 27 |
|
| 28 |
#include "core/logger_private.h" |
| 29 |
|
| 30 |
// Type safe version of containerof used to find parent structs from contained structs |
| 31 |
#define containerof(ptr, type, member) ((type *)((char *)(1 ? (ptr) : &((type *)0)->member) - offsetof(type, member))) |
| 32 |
|
| 33 |
#ifdef __cplusplus |
| 34 |
extern "C" { |
| 35 |
#endif |
| 36 |
|
| 37 |
/* NOTE PNP_EXTERN is for use by proton-internal tests */ |
| 38 |
|
| 39 |
/** |
| 40 |
* Parse a pn_proactor_addr string, copy data into buf as necessary. |
| 41 |
* Set *host and *port to point to the host and port strings. |
| 42 |
* |
| 43 |
* If the port is empty, replace it with "5672", if it is "amqp" or "amqps" |
| 44 |
* replace it with the numeric port value. |
| 45 |
* |
| 46 |
* @return 0 on success, PN_OVERFLOW if buf is too small. |
| 47 |
*/ |
| 48 |
PNP_EXTERN int pni_parse_addr(const char *addr, char *buf, size_t len, const char **host, const char **port); |
| 49 |
|
| 50 |
/** |
| 51 |
* Condition name for error conditions related to proton-IO. |
| 52 |
*/ |
| 53 |
extern const char *PNI_IO_CONDITION; |
| 54 |
|
| 55 |
/** |
| 56 |
* Format a proactor error condition with message "<what> (<host>:<port>): <msg>" |
| 57 |
*/ |
| 58 |
void pni_proactor_set_cond( |
| 59 |
pn_condition_t *cond, const char *what, const char *host, const char *port, const char *msg); |
| 60 |
|
| 61 |
/** |
| 62 |
* pn_event_batch_next() can be re-implemented for different behaviors in different contexts. |
| 63 |
*/ |
| 64 |
struct pn_event_batch_t { |
| 65 |
pn_event_t *(*next_event)(pn_event_batch_t *batch); |
| 66 |
}; |
| 67 |
|
| 68 |
static inline pn_event_t *pni_log_event(void* p, pn_event_t *e) { |
| 69 |
if (e) { |
| 70 |
PN_LOG_DEFAULT(PN_SUBSYSTEM_EVENT, PN_LEVEL_DEBUG, "[%p]:(%s)", (void*)p, pn_event_type_name(pn_event_type(e))); |
| 71 |
} |
| 72 |
return e; |
| 73 |
} |
| 74 |
|
| 75 |
#ifdef __cplusplus |
| 76 |
} |
| 77 |
#endif |
| 78 |
|
| 79 |
#endif /*!PROACTOR_PROACTOR_INTERNAL_H*/ |