grpc_alts_credentials_client_options.cc
Go to the documentation of this file.
1 /*
2  *
3  * Copyright 2018 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 
20 
21 #include <grpc/grpc_security.h>
22 #include <grpc/support/alloc.h>
23 #include <grpc/support/log.h>
25 
28 
31 
33 
35  const char* service_account) {
36  if (service_account == nullptr) {
37  return nullptr;
38  }
39  auto* sa = static_cast<target_service_account*>(
41  sa->data = gpr_strdup(service_account);
42  return sa;
43 }
44 
46  grpc_alts_credentials_options* options, const char* service_account) {
47  if (options == nullptr || service_account == nullptr) {
48  gpr_log(
49  GPR_ERROR,
50  "Invalid nullptr arguments to "
51  "grpc_alts_credentials_client_options_add_target_service_account()");
52  return;
53  }
54  auto client_options =
57  node->next = client_options->target_account_list_head;
58  client_options->target_account_list_head = node;
59 }
60 
62  target_service_account* service_account) {
63  if (service_account == nullptr) {
64  return;
65  }
66  gpr_free(service_account->data);
67  gpr_free(service_account);
68 }
69 
72 
74  void) {
75  auto client_options = static_cast<grpc_alts_credentials_client_options*>(
77  client_options->base.vtable = &vtable;
78  return &client_options->base;
79 }
80 
83  if (options == nullptr) {
84  return nullptr;
85  }
86  grpc_alts_credentials_options* new_options =
88  auto new_client_options =
89  reinterpret_cast<grpc_alts_credentials_client_options*>(new_options);
90  /* Copy target service accounts. */
91  target_service_account* prev = nullptr;
92  auto node =
93  (reinterpret_cast<const grpc_alts_credentials_client_options*>(options))
94  ->target_account_list_head;
95  while (node != nullptr) {
98  if (prev == nullptr) {
99  new_client_options->target_account_list_head = new_node;
100  } else {
101  prev->next = new_node;
102  }
103  prev = new_node;
104  node = node->next;
105  }
106  /* Copy rpc protocol versions. */
108  &new_options->rpc_versions);
109  return new_options;
110 }
111 
114  if (options == nullptr) {
115  return;
116  }
117  auto* client_options =
118  reinterpret_cast<grpc_alts_credentials_client_options*>(options);
119  target_service_account* node = client_options->target_account_list_head;
120  while (node != nullptr) {
121  target_service_account* next_node = node->next;
123  node = next_node;
124  }
125 }
grpc_alts_credentials_client_options::base
grpc_alts_credentials_options base
Definition: grpc_alts_credentials_options.h:51
grpc_alts_credentials_client_options
Definition: grpc_alts_credentials_options.h:50
log.h
alts_client_options_copy
static grpc_alts_credentials_options * alts_client_options_copy(const grpc_alts_credentials_options *options)
Definition: grpc_alts_credentials_client_options.cc:81
target_service_account_create
static target_service_account * target_service_account_create(const char *service_account)
Definition: grpc_alts_credentials_client_options.cc:34
grpc_alts_credentials_options::vtable
const struct grpc_alts_credentials_options_vtable * vtable
Definition: grpc_alts_credentials_options.h:36
options
double_dict options[]
Definition: capstone_test.c:55
target_service_account
Definition: grpc_alts_credentials_options.h:40
gpr_free
GPRAPI void gpr_free(void *ptr)
Definition: alloc.cc:51
grpc_security.h
gpr_zalloc
GPRAPI void * gpr_zalloc(size_t size)
Definition: alloc.cc:40
string_util.h
grpc_alts_credentials_options_vtable
Definition: grpc_alts_credentials_options.h:29
gpr_log
GPRAPI void gpr_log(const char *file, int line, gpr_log_severity severity, const char *format,...) GPR_PRINT_FORMAT_CHECK(4
target_service_account_destroy
static void target_service_account_destroy(target_service_account *service_account)
Definition: grpc_alts_credentials_client_options.cc:61
grpc_alts_credentials_options.h
GPR_ERROR
#define GPR_ERROR
Definition: include/grpc/impl/codegen/log.h:57
grpc_alts_credentials_client_options_create
grpc_alts_credentials_options * grpc_alts_credentials_client_options_create(void)
Definition: grpc_alts_credentials_client_options.cc:73
vtable
static const grpc_alts_credentials_options_vtable vtable
Definition: grpc_alts_credentials_client_options.cc:70
alts_client_options_destroy
static void alts_client_options_destroy(grpc_alts_credentials_options *options)
Definition: grpc_alts_credentials_client_options.cc:112
grpc_alts_credentials_options
Definition: grpc_alts_credentials_options.h:35
grpc_alts_credentials_options::rpc_versions
grpc_gcp_rpc_protocol_versions rpc_versions
Definition: grpc_alts_credentials_options.h:37
transport_security_common_api.h
alloc.h
grpc_gcp_rpc_protocol_versions_copy
bool grpc_gcp_rpc_protocol_versions_copy(const grpc_gcp_rpc_protocol_versions *src, grpc_gcp_rpc_protocol_versions *dst)
Definition: transport_security_common_api.cc:154
new_node
static test_node * new_node(size_t i, size_t *ctr)
Definition: mpscq_test.cc:40
gpr_strdup
GPRAPI char * gpr_strdup(const char *src)
Definition: string.cc:39
grpc_alts_credentials_client_options_add_target_service_account
void grpc_alts_credentials_client_options_add_target_service_account(grpc_alts_credentials_options *options, const char *service_account)
Definition: grpc_alts_credentials_client_options.cc:45
target_service_account::data
char * data
Definition: grpc_alts_credentials_options.h:42
target_service_account::next
struct target_service_account * next
Definition: grpc_alts_credentials_options.h:41
port_platform.h


grpc
Author(s):
autogenerated on Fri May 16 2025 02:58:44