http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/a5850716/proton-c/src/reactor/selectable.h ---------------------------------------------------------------------- diff --git a/proton-c/src/reactor/selectable.h b/proton-c/src/reactor/selectable.h new file mode 100644 index 0000000..7a5b80b --- /dev/null +++ b/proton-c/src/reactor/selectable.h @@ -0,0 +1,36 @@ +#ifndef _PROTON_SRC_SELECTABLE_H +#define _PROTON_SRC_SELECTABLE_H 1 + +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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. + * + */ + +#ifndef __cplusplus +#include <stdbool.h> +#endif + +#include <proton/selectable.h> + +void *pni_selectable_get_context(pn_selectable_t *selectable); +void pni_selectable_set_context(pn_selectable_t *selectable, void *context); +int pni_selectable_get_index(pn_selectable_t *selectable); +void pni_selectable_set_index(pn_selectable_t *selectable, int index); + +#endif /* selectable.h */
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/a5850716/proton-c/src/reactor/selector.h ---------------------------------------------------------------------- diff --git a/proton-c/src/reactor/selector.h b/proton-c/src/reactor/selector.h new file mode 100644 index 0000000..2a1e31f --- /dev/null +++ b/proton-c/src/reactor/selector.h @@ -0,0 +1,53 @@ +#ifndef PROTON_SELECTOR_H +#define PROTON_SELECTOR_H 1 + +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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. + * + */ + +#include <proton/selectable.h> +#include <proton/type_compat.h> + +#define PN_READABLE (1) +#define PN_WRITABLE (2) +#define PN_EXPIRED (4) +#define PN_ERROR (8) + +/** + * A ::pn_selector_t provides a selection mechanism that allows + * efficient monitoring of a large number of Proton connections and + * listeners. + * + * External (non-Proton) sockets may also be monitored, either solely + * for event notification (read, write, and timer) or event + * notification and use with pn_io_t interfaces. + */ +typedef struct pn_selector_t pn_selector_t; + +pn_selector_t *pni_selector(void); +void pn_selector_free(pn_selector_t *selector); +void pn_selector_add(pn_selector_t *selector, pn_selectable_t *selectable); +void pn_selector_update(pn_selector_t *selector, pn_selectable_t *selectable); +void pn_selector_remove(pn_selector_t *selector, pn_selectable_t *selectable); +size_t pn_selector_size(pn_selector_t *selector); +int pn_selector_select(pn_selector_t *select, int timeout); +pn_selectable_t *pn_selector_next(pn_selector_t *select, int *events); + +#endif /* selector.h */ http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/a5850716/proton-c/src/sasl/cyrus_sasl.c ---------------------------------------------------------------------- diff --git a/proton-c/src/sasl/cyrus_sasl.c b/proton-c/src/sasl/cyrus_sasl.c index dfc13d0..0d81489 100644 --- a/proton-c/src/sasl/cyrus_sasl.c +++ b/proton-c/src/sasl/cyrus_sasl.c @@ -19,10 +19,10 @@ * */ -#include "config.h" +#include "core/config.h" +#include "core/engine-internal.h" #include "sasl-internal.h" -#include "engine/engine-internal.h" #include <sasl/sasl.h> #include <pthread.h> http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/a5850716/proton-c/src/sasl/none_sasl.c ---------------------------------------------------------------------- diff --git a/proton-c/src/sasl/none_sasl.c b/proton-c/src/sasl/none_sasl.c index d1ee67f..0408a8f 100644 --- a/proton-c/src/sasl/none_sasl.c +++ b/proton-c/src/sasl/none_sasl.c @@ -21,7 +21,7 @@ #include "sasl-internal.h" -#include "engine/engine-internal.h" +#include "core/engine-internal.h" static const char ANONYMOUS[] = "ANONYMOUS"; static const char EXTERNAL[] = "EXTERNAL"; http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/a5850716/proton-c/src/sasl/sasl-internal.h ---------------------------------------------------------------------- diff --git a/proton-c/src/sasl/sasl-internal.h b/proton-c/src/sasl/sasl-internal.h index 063cd0d..2873777 100644 --- a/proton-c/src/sasl/sasl-internal.h +++ b/proton-c/src/sasl/sasl-internal.h @@ -22,11 +22,12 @@ #ifndef PROTON_SASL_INTERNAL_H #define PROTON_SASL_INTERNAL_H 1 -#include "buffer.h" +#include "core/buffer.h" +#include "core/engine-internal.h" + #include "proton/types.h" #include "proton/sasl.h" -#include "engine/engine-internal.h" // SASL APIs used by transport code void pn_sasl_free(pn_transport_t *transport); http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/a5850716/proton-c/src/sasl/sasl.c ---------------------------------------------------------------------- diff --git a/proton-c/src/sasl/sasl.c b/proton-c/src/sasl/sasl.c index 47dc76c..c917d58 100644 --- a/proton-c/src/sasl/sasl.c +++ b/proton-c/src/sasl/sasl.c @@ -21,13 +21,14 @@ #include "sasl-internal.h" -#include "dispatch_actions.h" -#include "engine/engine-internal.h" +#include "core/autodetect.h" +#include "core/dispatch_actions.h" +#include "core/engine-internal.h" +#include "core/util.h" #include "protocol.h" + #include "proton/ssl.h" #include "proton/types.h" -#include "util.h" -#include "transport/autodetect.h" #include <assert.h> http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/a5850716/proton-c/src/scanner.c ---------------------------------------------------------------------- diff --git a/proton-c/src/scanner.c b/proton-c/src/scanner.c deleted file mode 100644 index 9a058e9..0000000 --- a/proton-c/src/scanner.c +++ /dev/null @@ -1,397 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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. - * - */ - -#include <proton/scanner.h> -#include <proton/error.h> -#ifndef __cplusplus -#include <stdbool.h> -#endif -#include <stdlib.h> -#include <stdio.h> -#include <string.h> -#include "platform.h" - -#define ERROR_SIZE (1024) - -struct pn_scanner_t { - const char *input; - const char *position; - pn_token_t token; - char *atoms; - size_t size; - size_t capacity; - pn_error_t *error; -}; - -static const char *pni_token_type(pn_token_type_t type) -{ - switch (type) - { - case PN_TOK_LBRACE: return "LBRACE"; - case PN_TOK_RBRACE: return "RBRACE"; - case PN_TOK_LBRACKET: return "LBRACKET"; - case PN_TOK_RBRACKET: return "RBRACKET"; - case PN_TOK_EQUAL: return "EQUAL"; - case PN_TOK_COMMA: return "COMMA"; - case PN_TOK_POS: return "POS"; - case PN_TOK_NEG: return "NEG"; - case PN_TOK_DOT: return "DOT"; - case PN_TOK_AT: return "AT"; - case PN_TOK_DOLLAR: return "DOLLAR"; - case PN_TOK_BINARY: return "BINARY"; - case PN_TOK_STRING: return "STRING"; - case PN_TOK_SYMBOL: return "SYMBOL"; - case PN_TOK_ID: return "ID"; - case PN_TOK_FLOAT: return "FLOAT"; - case PN_TOK_INT: return "INT"; - case PN_TOK_TRUE: return "TRUE"; - case PN_TOK_FALSE: return "FALSE"; - case PN_TOK_NULL: return "NULL"; - case PN_TOK_EOS: return "EOS"; - case PN_TOK_ERR: return "ERR"; - default: return "<UNKNOWN>"; - } -} - -pn_scanner_t *pn_scanner() -{ - pn_scanner_t *scanner = (pn_scanner_t *) malloc(sizeof(pn_scanner_t)); - if (scanner) { - scanner->input = NULL; - scanner->error = pn_error(); - } - return scanner; -} - -void pn_scanner_free(pn_scanner_t *scanner) -{ - if (scanner) { - pn_error_free(scanner->error); - free(scanner); - } -} - -pn_token_t pn_scanner_token(pn_scanner_t *scanner) -{ - if (scanner) { - return scanner->token; - } else { - pn_token_t tok = {PN_TOK_ERR, 0, (size_t)0}; - return tok; - } -} - -void pn_scanner_line_info(pn_scanner_t *scanner, int *line, int *col) -{ - *line = 1; - *col = 0; - - for (const char *c = scanner->input; *c && c <= scanner->token.start; c++) { - if (*c == '\n') { - *line += 1; - *col = -1; - } else { - *col += 1; - } - } -} - -int pn_scanner_err(pn_scanner_t *scanner, int code, const char *fmt, ...) -{ - va_list ap; - va_start(ap, fmt); - int err = pn_scanner_verr(scanner, code, fmt, ap); - va_end(ap); - return err; -} - -int pn_scanner_verr(pn_scanner_t *scanner, int code, const char *fmt, va_list ap) -{ - char error[ERROR_SIZE]; - - int line, col; - pn_scanner_line_info(scanner, &line, &col); - int size = scanner->token.size; - int ln = snprintf(error, ERROR_SIZE, - "input line %i column %i %s:'%.*s': ", line, col, - pni_token_type(scanner->token.type), - size, scanner->token.start); - if (ln >= ERROR_SIZE) { - return pn_scanner_err(scanner, code, "error info truncated"); - } else if (ln < 0) { - error[0] = '\0'; - } - - int n = snprintf(error + ln, ERROR_SIZE - ln, fmt, ap); - - if (n >= ERROR_SIZE - ln) { - return pn_scanner_err(scanner, code, "error info truncated"); - } else if (n < 0) { - error[0] = '\0'; - } - - return pn_error_set(scanner->error, code, error); -} - -int pn_scanner_errno(pn_scanner_t *scanner) -{ - return pn_error_code(scanner->error); -} - -const char *pn_scanner_error(pn_scanner_t *scanner) -{ - return pn_error_text(scanner->error); -} - -static void pni_scanner_emit(pn_scanner_t *scanner, pn_token_type_t type, const char *start, size_t size) -{ - scanner->token.type = type; - scanner->token.start = start; - scanner->token.size = size; -} - -static int pni_scanner_quoted(pn_scanner_t *scanner, const char *str, int start, - pn_token_type_t type) -{ - bool escape = false; - - for (int i = start; true; i++) { - char c = str[i]; - if (escape) { - escape = false; - } else { - switch (c) { - case '\0': - case '"': - pni_scanner_emit(scanner, c ? type : PN_TOK_ERR, - str, c ? i + 1 : i); - return c ? 0 : pn_scanner_err(scanner, PN_ERR, "missmatched quote"); - case '\\': - escape = true; - break; - } - } - } -} - -static int pni_scanner_binary(pn_scanner_t *scanner, const char *str) -{ - return pni_scanner_quoted(scanner, str, 2, PN_TOK_BINARY); -} - -static int pni_scanner_string(pn_scanner_t *scanner, const char *str) -{ - return pni_scanner_quoted(scanner, str, 1, PN_TOK_STRING); -} - -static int pni_scanner_alpha_end(pn_scanner_t *scanner, const char *str, int start) -{ - for (int i = start; true; i++) { - char c = str[i]; - if (!((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))) { - return i; - } - } -} - -static int pni_scanner_alpha(pn_scanner_t *scanner, const char *str) -{ - int n = pni_scanner_alpha_end(scanner, str, 0); - pn_token_type_t type; - if (!strncmp(str, "true", n)) { - type = PN_TOK_TRUE; - } else if (!strncmp(str, "false", n)) { - type = PN_TOK_FALSE; - } else if (!strncmp(str, "null", n)) { - type = PN_TOK_NULL; - } else { - type = PN_TOK_ID; - } - - pni_scanner_emit(scanner, type, str, n); - return 0; -} - -static int pni_scanner_symbol(pn_scanner_t *scanner, const char *str) -{ - char c = str[1]; - - if (c == '"') { - return pni_scanner_quoted(scanner, str, 2, PN_TOK_SYMBOL); - } else { - int n = pni_scanner_alpha_end(scanner, str, 1); - pni_scanner_emit(scanner, PN_TOK_SYMBOL, str, n); - return 0; - } -} - -static int pni_scanner_number(pn_scanner_t *scanner, const char *str) -{ - bool dot = false; - bool exp = false; - - int i = 0; - - if (str[i] == '+' || str[i] == '-') { - i++; - } - - for ( ; true; i++) { - char c = str[i]; - switch (c) { - case '0': case '1': case '2': case '3': case '4': case '5': case '6': - case '7': case '8': case '9': - continue; - case '.': - if (dot) { - pni_scanner_emit(scanner, PN_TOK_FLOAT, str, i); - return 0; - } else { - dot = true; - } - continue; - case 'e': - case 'E': - if (exp) { - pni_scanner_emit(scanner, PN_TOK_FLOAT, str, i); - return 0; - } else { - dot = true; - exp = true; - if (str[i+1] == '+' || str[i+1] == '-') { - i++; - } - continue; - } - default: - if (dot || exp) { - pni_scanner_emit(scanner, PN_TOK_FLOAT, str, i); - return 0; - } else { - pni_scanner_emit(scanner, PN_TOK_INT, str, i); - return 0; - } - } - } -} - -static int pni_scanner_single(pn_scanner_t *scanner, const char *str, pn_token_type_t type) -{ - pni_scanner_emit(scanner, type, str, 1); - return 0; -} - -int pn_scanner_start(pn_scanner_t *scanner, const char *input) -{ - if (!scanner || !input) return PN_ARG_ERR; - scanner->input = input; - scanner->position = input; - return pn_scanner_scan(scanner); -} - -int pn_scanner_scan(pn_scanner_t *scanner) -{ - const char *str = scanner->position; - char n; - - for (char c; true; str++) { - c = *str; - switch (c) - { - case '{': - return pni_scanner_single(scanner, str, PN_TOK_LBRACE); - case '}': - return pni_scanner_single(scanner, str, PN_TOK_RBRACE); - case'[': - return pni_scanner_single(scanner, str, PN_TOK_LBRACKET); - case ']': - return pni_scanner_single(scanner, str, PN_TOK_RBRACKET); - case '=': - return pni_scanner_single(scanner, str, PN_TOK_EQUAL); - case ',': - return pni_scanner_single(scanner, str, PN_TOK_COMMA); - case '.': - n = *(str+1); - if ((n >= '0' && n <= '9')) { - return pni_scanner_number(scanner, str); - } else { - return pni_scanner_single(scanner, str, PN_TOK_DOT); - } - case '@': - return pni_scanner_single(scanner, str, PN_TOK_AT); - case '$': - return pni_scanner_single(scanner, str, PN_TOK_DOLLAR); - case '-': - n = *(str+1); - if ((n >= '0' && n <= '9') || n == '.') { - return pni_scanner_number(scanner, str); - } else { - return pni_scanner_single(scanner, str, PN_TOK_NEG); - } - case '+': - n = *(str+1); - if ((n >= '0' && n <= '9') || n == '.') { - return pni_scanner_number(scanner, str); - } else { - return pni_scanner_single(scanner, str, PN_TOK_POS); - } - case ' ': case '\t': case '\r': case '\v': case '\f': case '\n': - break; - case '0': case '1': case '2': case '3': case '4': case '5': case '6': - case '7': case '8': case '9': - return pni_scanner_number(scanner, str); - case ':': - return pni_scanner_symbol(scanner, str); - case '"': - return pni_scanner_string(scanner, str); - case 'b': - if (str[1] == '"') { - return pni_scanner_binary(scanner, str); - } - case 'a': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': - case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': - case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': - case 'w': case 'x': case 'y': case 'z': case 'A': case 'B': case 'C': - case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': - case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': - case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': - case 'Y': case 'Z': - return pni_scanner_alpha(scanner, str); - case '\0': - pni_scanner_emit(scanner, PN_TOK_EOS, str, 0); - return PN_EOS; - default: - pni_scanner_emit(scanner, PN_TOK_ERR, str, 1); - return pn_scanner_err(scanner, PN_ERR, "illegal character"); - } - } -} - -int pn_scanner_shift(pn_scanner_t *scanner) -{ - scanner->position = scanner->token.start + scanner->token.size; - int err = pn_scanner_scan(scanner); - if (err == PN_EOS) { - return 0; - } else { - return err; - } -} http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/a5850716/proton-c/src/selectable.c ---------------------------------------------------------------------- diff --git a/proton-c/src/selectable.c b/proton-c/src/selectable.c deleted file mode 100644 index 88a60f7..0000000 --- a/proton-c/src/selectable.c +++ /dev/null @@ -1,297 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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. - * - */ - -#include <proton/error.h> -#include <proton/io.h> -#include "selectable.h" -#include <stdlib.h> -#include <assert.h> - -pn_selectables_t *pn_selectables(void) -{ - return pn_iterator(); -} - -pn_selectable_t *pn_selectables_next(pn_selectables_t *selectables) -{ - return (pn_selectable_t *) pn_iterator_next(selectables); -} - -void pn_selectables_free(pn_selectables_t *selectables) -{ - pn_free(selectables); -} - -struct pn_selectable_t { - pn_socket_t fd; - int index; - pn_record_t *attachments; - void (*readable)(pn_selectable_t *); - void (*writable)(pn_selectable_t *); - void (*error)(pn_selectable_t *); - void (*expired)(pn_selectable_t *); - void (*release) (pn_selectable_t *); - void (*finalize)(pn_selectable_t *); - pn_collector_t *collector; - pn_timestamp_t deadline; - bool reading; - bool writing; - bool registered; - bool terminal; -}; - -void pn_selectable_initialize(pn_selectable_t *sel) -{ - sel->fd = PN_INVALID_SOCKET; - sel->index = -1; - sel->attachments = pn_record(); - sel->readable = NULL; - sel->writable = NULL; - sel->error = NULL; - sel->expired = NULL; - sel->release = NULL; - sel->finalize = NULL; - sel->collector = NULL; - sel->deadline = 0; - sel->reading = false; - sel->writing = false; - sel->registered = false; - sel->terminal = false; -} - -void pn_selectable_finalize(pn_selectable_t *sel) -{ - if (sel->finalize) { - sel->finalize(sel); - } - pn_decref(sel->attachments); - pn_decref(sel->collector); -} - -#define pn_selectable_hashcode NULL -#define pn_selectable_inspect NULL -#define pn_selectable_compare NULL - -PN_CLASSDEF(pn_selectable) - -pn_selectable_t *pn_selectable(void) -{ - return pn_selectable_new(); -} - -bool pn_selectable_is_reading(pn_selectable_t *sel) { - assert(sel); - return sel->reading; -} - -void pn_selectable_set_reading(pn_selectable_t *sel, bool reading) { - assert(sel); - sel->reading = reading; -} - -bool pn_selectable_is_writing(pn_selectable_t *sel) { - assert(sel); - return sel->writing; -} - -void pn_selectable_set_writing(pn_selectable_t *sel, bool writing) { - assert(sel); - sel->writing = writing; -} - -pn_timestamp_t pn_selectable_get_deadline(pn_selectable_t *sel) { - assert(sel); - return sel->deadline; -} - -void pn_selectable_set_deadline(pn_selectable_t *sel, pn_timestamp_t deadline) { - assert(sel); - sel->deadline = deadline; -} - -void pn_selectable_on_readable(pn_selectable_t *sel, void (*readable)(pn_selectable_t *)) { - assert(sel); - sel->readable = readable; -} - -void pn_selectable_on_writable(pn_selectable_t *sel, void (*writable)(pn_selectable_t *)) { - assert(sel); - sel->writable = writable; -} - -void pn_selectable_on_error(pn_selectable_t *sel, void (*error)(pn_selectable_t *)) { - assert(sel); - sel->error = error; -} - -void pn_selectable_on_expired(pn_selectable_t *sel, void (*expired)(pn_selectable_t *)) { - assert(sel); - sel->expired = expired; -} - -void pn_selectable_on_release(pn_selectable_t *sel, void (*release)(pn_selectable_t *)) { - assert(sel); - sel->release = release; -} - -void pn_selectable_on_finalize(pn_selectable_t *sel, void (*finalize)(pn_selectable_t *)) { - assert(sel); - sel->finalize = finalize; -} - -pn_record_t *pn_selectable_attachments(pn_selectable_t *sel) { - return sel->attachments; -} - -void *pni_selectable_get_context(pn_selectable_t *selectable) -{ - assert(selectable); - return pn_record_get(selectable->attachments, PN_LEGCTX); -} - -void pni_selectable_set_context(pn_selectable_t *selectable, void *context) -{ - assert(selectable); - pn_record_set(selectable->attachments, PN_LEGCTX, context); -} - -int pni_selectable_get_index(pn_selectable_t *selectable) -{ - assert(selectable); - return selectable->index; -} - -void pni_selectable_set_index(pn_selectable_t *selectable, int index) -{ - assert(selectable); - selectable->index = index; -} - -pn_socket_t pn_selectable_get_fd(pn_selectable_t *selectable) -{ - assert(selectable); - return selectable->fd; -} - -void pn_selectable_set_fd(pn_selectable_t *selectable, pn_socket_t fd) -{ - assert(selectable); - selectable->fd = fd; -} - -void pn_selectable_readable(pn_selectable_t *selectable) -{ - assert(selectable); - if (selectable->readable) { - selectable->readable(selectable); - } -} - -void pn_selectable_writable(pn_selectable_t *selectable) -{ - assert(selectable); - if (selectable->writable) { - selectable->writable(selectable); - } -} - -void pn_selectable_error(pn_selectable_t *selectable) -{ - assert(selectable); - if (selectable->error) { - selectable->error(selectable); - } -} - -void pn_selectable_expired(pn_selectable_t *selectable) -{ - assert(selectable); - if (selectable->expired) { - selectable->expired(selectable); - } -} - -bool pn_selectable_is_registered(pn_selectable_t *selectable) -{ - assert(selectable); - return selectable->registered; -} - -void pn_selectable_set_registered(pn_selectable_t *selectable, bool registered) -{ - assert(selectable); - selectable->registered = registered; -} - -bool pn_selectable_is_terminal(pn_selectable_t *selectable) -{ - assert(selectable); - return selectable->terminal; -} - -void pn_selectable_terminate(pn_selectable_t *selectable) -{ - assert(selectable); - selectable->terminal = true; -} - -void pn_selectable_release(pn_selectable_t *selectable) -{ - assert(selectable); - if (selectable->release) { - selectable->release(selectable); - } -} - -void pn_selectable_free(pn_selectable_t *selectable) -{ - pn_decref(selectable); -} - -static void pni_readable(pn_selectable_t *selectable) { - pn_collector_put(selectable->collector, PN_OBJECT, selectable, PN_SELECTABLE_READABLE); -} - -static void pni_writable(pn_selectable_t *selectable) { - pn_collector_put(selectable->collector, PN_OBJECT, selectable, PN_SELECTABLE_WRITABLE); -} - -static void pni_error(pn_selectable_t *selectable) { - pn_collector_put(selectable->collector, PN_OBJECT, selectable, PN_SELECTABLE_ERROR); -} - -static void pni_expired(pn_selectable_t *selectable) { - pn_collector_put(selectable->collector, PN_OBJECT, selectable, PN_SELECTABLE_EXPIRED); -} - -void pn_selectable_collect(pn_selectable_t *selectable, pn_collector_t *collector) { - assert(selectable); - pn_decref(selectable->collector); - selectable->collector = collector; - pn_incref(selectable->collector); - - if (collector) { - pn_selectable_on_readable(selectable, pni_readable); - pn_selectable_on_writable(selectable, pni_writable); - pn_selectable_on_error(selectable, pni_error); - pn_selectable_on_expired(selectable, pni_expired); - } -} http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/a5850716/proton-c/src/selectable.h ---------------------------------------------------------------------- diff --git a/proton-c/src/selectable.h b/proton-c/src/selectable.h deleted file mode 100644 index 7a5b80b..0000000 --- a/proton-c/src/selectable.h +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef _PROTON_SRC_SELECTABLE_H -#define _PROTON_SRC_SELECTABLE_H 1 - -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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. - * - */ - -#ifndef __cplusplus -#include <stdbool.h> -#endif - -#include <proton/selectable.h> - -void *pni_selectable_get_context(pn_selectable_t *selectable); -void pni_selectable_set_context(pn_selectable_t *selectable, void *context); -int pni_selectable_get_index(pn_selectable_t *selectable); -void pni_selectable_set_index(pn_selectable_t *selectable, int index); - -#endif /* selectable.h */ http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/a5850716/proton-c/src/ssl/openssl.c ---------------------------------------------------------------------- diff --git a/proton-c/src/ssl/openssl.c b/proton-c/src/ssl/openssl.c index 48cb051..0d7c40b 100644 --- a/proton-c/src/ssl/openssl.c +++ b/proton-c/src/ssl/openssl.c @@ -19,11 +19,12 @@ * */ +#include "platform/platform.h" +#include "core/util.h" +#include "core/engine-internal.h" + #include <proton/ssl.h> #include <proton/engine.h> -#include "engine/engine-internal.h" -#include "platform.h" -#include "util.h" // openssl on windows expects the user to have already included // winsock.h @@ -749,7 +750,7 @@ bool pn_ssl_get_cipher_name(pn_ssl_t *ssl0, char *buffer, size_t size ) if (ssl->ssl && (c = SSL_get_current_cipher( ssl->ssl ))) { const char *v = SSL_CIPHER_get_name(c); if (v) { - snprintf( buffer, size, "%s", v ); + pni_snprintf( buffer, size, "%s", v ); return true; } } @@ -765,7 +766,7 @@ bool pn_ssl_get_protocol_name(pn_ssl_t *ssl0, char *buffer, size_t size ) if (ssl->ssl && (c = SSL_get_current_cipher( ssl->ssl ))) { const char *v = SSL_CIPHER_get_version(c); if (v) { - snprintf( buffer, size, "%s", v ); + pni_snprintf( buffer, size, "%s", v ); return true; } } @@ -1345,7 +1346,7 @@ int pn_ssl_get_cert_fingerprint(pn_ssl_t *ssl0, char *fingerprint, size_t finger char *cursor = fingerprint; for (size_t i=0; i<len ; i++) { - cursor += snprintf((char *)cursor, fingerprint_length, "%02x", bytes[i]); + cursor += pni_snprintf((char *)cursor, fingerprint_length, "%02x", bytes[i]); fingerprint_length = fingerprint_length - 2; } --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
