1 /* 2 * 3 * Copyright 2015 gRPC authors. 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 * 17 */ 18 19 #ifndef NET_GRPC_PHP_GRPC_CHANNEL_H_ 20 #define NET_GRPC_PHP_GRPC_CHANNEL_H_ 21 22 #include "php_grpc.h" 23 24 /* Class entry for the PHP Channel class */ 25 extern zend_class_entry *grpc_ce_channel; 26 27 typedef struct _grpc_channel_wrapper { 28 grpc_channel *wrapped; 29 char *key; 30 char *target; 31 char *args_hashstr; 32 char *creds_hashstr; 33 size_t ref_count; 34 gpr_mu mu; 35 } grpc_channel_wrapper; 36 37 /* Wrapper struct for grpc_channel that can be associated with a PHP object */ PHP_GRPC_WRAP_OBJECT_START(wrapped_grpc_channel)38PHP_GRPC_WRAP_OBJECT_START(wrapped_grpc_channel) 39 grpc_channel_wrapper *wrapper; 40 PHP_GRPC_WRAP_OBJECT_END(wrapped_grpc_channel) 41 42 static inline wrapped_grpc_channel 43 *wrapped_grpc_channel_from_obj(zend_object *obj) { 44 return (wrapped_grpc_channel*)((char*)(obj) - 45 XtOffsetOf(wrapped_grpc_channel, std)); 46 } 47 48 /* Initializes the Channel class */ 49 GRPC_STARTUP_FUNCTION(channel); 50 51 /* Iterates through a PHP array and populates args with the contents */ 52 int php_grpc_read_args_array(zval *args_array, grpc_channel_args *args 53 TSRMLS_DC); 54 55 void generate_sha1_str(char *sha1str, char *str, php_grpc_int len); 56 57 void php_grpc_delete_persistent_list_entry(char *key, php_grpc_int key_len 58 TSRMLS_DC); 59 60 typedef struct _channel_persistent_le { 61 grpc_channel_wrapper *channel; 62 } channel_persistent_le_t; 63 64 typedef struct _target_bound_le { 65 int upper_bound; 66 int current_count; 67 } target_bound_le_t; 68 69 #endif /* NET_GRPC_PHP_GRPC_CHANNEL_H_ */ 70