2 #if defined (ACE_HAS_TOKENS_LIBRARY)
4 #include "ace/Truncate.h"
6 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
8 // = Set/get the length of the encoded/decoded message.
11 ACE_Token_Request::length () const
13 return ntohl (this->transfer_.length_);
17 ACE_Token_Request::length (ACE_UINT32 l)
19 this->transfer_.length_ = htonl (l);
22 // = Set/get the type of the message.
24 ACE_Token_Request::token_type () const
26 return (int) ntohl (this->transfer_.token_type_);
30 ACE_Token_Request::token_type (int t)
32 this->transfer_.token_type_ = htonl ((ACE_UINT32) t);
35 // = Set/get the type of the message.
37 ACE_Token_Request::proxy_type () const
39 return (int) ntohl (this->transfer_.proxy_type_);
43 ACE_Token_Request::proxy_type (int t)
45 this->transfer_.proxy_type_ = htonl ((ACE_UINT32) t);
48 // = Set/get the type of the message.
50 ACE_Token_Request::operation_type () const
52 return ntohl (this->transfer_.operation_type_);
56 ACE_Token_Request::operation_type (ACE_UINT32 t)
58 this->transfer_.operation_type_ = htonl (t);
61 // = Set/get the requeue position
63 ACE_Token_Request::requeue_position () const
65 return ntohl (this->transfer_.requeue_position_);
69 ACE_Token_Request::requeue_position (ACE_UINT32 rq)
71 this->transfer_.requeue_position_ = htonl (rq);
74 // = Set/get the requeue position
76 ACE_Token_Request::notify () const
78 return ntohl (this->transfer_.notify_);
82 ACE_Token_Request::notify (ACE_UINT32 rq)
84 this->transfer_.notify_ = htonl (rq);
87 // = Set/get the blocking semantics.
88 ACE_INLINE ACE_Synch_Options &
89 ACE_Token_Request::options () const
91 return (ACE_Synch_Options &) options_;
95 ACE_Token_Request::options (const ACE_Synch_Options &opt)
97 // fight the friggin const from hell
98 ACE_Synch_Options *options = (ACE_Synch_Options *) &opt;
100 transfer_.use_timeout_ = options->operator[](ACE_Synch_Options::USE_TIMEOUT);
101 if (transfer_.use_timeout_ == 1)
103 transfer_.usec_ = options->timeout ().usec ();
104 if (options->timeout ().sec () > (time_t) ACE_UINT32_MAX)
105 transfer_.sec_ = ACE_UINT32_MAX;
107 transfer_.sec_ = static_cast<ACE_UINT32> (options->timeout ().sec ());
116 // = Set/get the name of the token.
117 ACE_INLINE ACE_TCHAR *
118 ACE_Token_Request::token_name () const
124 ACE_Token_Request::token_name (const ACE_TCHAR *token_name,
125 const ACE_TCHAR *client_id)
127 size_t token_name_length = ACE_OS::strlen (token_name) + 1; // Add 1 for '\0'.
128 size_t client_id_length = ACE_OS::strlen (client_id) + 1; // Add 1 for '\0'.
130 // Set up pointers and copy token_name and client_id into request.
131 token_name_ = this->transfer_.data_;
132 client_id_ = &this->token_name_[token_name_length + 1]; // Add 1 for ':';
133 client_id_[-1] = ACE_TEXT (':'); // Insert the ':' before this->clientId_.
135 (void) ACE_OS::memcpy (this->token_name_,
137 token_name_length * sizeof (ACE_TCHAR));
138 (void) ACE_OS::memcpy (this->client_id_,
140 client_id_length * sizeof (ACE_TCHAR));
142 // Fixed length header size
143 size_t len = ACE_TOKEN_REQUEST_HEADER_SIZE;
145 // ... then add in the amount of the variable-sized portion.
146 len += token_name_length + client_id_length + 1;
147 this->length (ACE_Utils::truncate_cast<ACE_UINT32> (len));
150 // = Set/get the id of the client.
151 ACE_INLINE ACE_TCHAR *
152 ACE_Token_Request::client_id () const
154 return this->client_id_;
157 // ************************************************************
158 // ************************************************************
159 // ************************************************************
161 // = Set/get the length of the encoded/decoded message.
162 ACE_INLINE ACE_UINT32
163 ACE_Token_Reply::length () const
165 return ntohl (this->transfer_.length_);
169 ACE_Token_Reply::length (ACE_UINT32 l)
171 this->transfer_.length_ = htonl (l);
174 // = Set/get the errno of a failed reply.
175 ACE_INLINE ACE_UINT32
176 ACE_Token_Reply::errnum () const
178 return ntohl (this->transfer_.errno_);
182 ACE_Token_Reply::errnum (ACE_UINT32 e)
184 this->transfer_.errno_ = htonl (e);
187 // = Set/get the length of the encoded/decoded message.
188 ACE_INLINE ACE_UINT32
189 ACE_Token_Reply::arg () const
191 return ntohl (this->transfer_.arg_);
195 ACE_Token_Reply::arg (ACE_UINT32 arg)
197 this->transfer_.arg_ = htonl (arg);
200 ACE_END_VERSIONED_NAMESPACE_DECL
202 #endif /* ACE_HAS_TOKENS_LIBRARY */