113498266Sopenharmony_ci#ifndef HEADER_CURL_SETUP_OS400_H
213498266Sopenharmony_ci#define HEADER_CURL_SETUP_OS400_H
313498266Sopenharmony_ci/***************************************************************************
413498266Sopenharmony_ci *                                  _   _ ____  _
513498266Sopenharmony_ci *  Project                     ___| | | |  _ \| |
613498266Sopenharmony_ci *                             / __| | | | |_) | |
713498266Sopenharmony_ci *                            | (__| |_| |  _ <| |___
813498266Sopenharmony_ci *                             \___|\___/|_| \_\_____|
913498266Sopenharmony_ci *
1013498266Sopenharmony_ci * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
1113498266Sopenharmony_ci *
1213498266Sopenharmony_ci * This software is licensed as described in the file COPYING, which
1313498266Sopenharmony_ci * you should have received as part of this distribution. The terms
1413498266Sopenharmony_ci * are also available at https://curl.se/docs/copyright.html.
1513498266Sopenharmony_ci *
1613498266Sopenharmony_ci * You may opt to use, copy, modify, merge, publish, distribute and/or sell
1713498266Sopenharmony_ci * copies of the Software, and permit persons to whom the Software is
1813498266Sopenharmony_ci * furnished to do so, under the terms of the COPYING file.
1913498266Sopenharmony_ci *
2013498266Sopenharmony_ci * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
2113498266Sopenharmony_ci * KIND, either express or implied.
2213498266Sopenharmony_ci *
2313498266Sopenharmony_ci * SPDX-License-Identifier: curl
2413498266Sopenharmony_ci *
2513498266Sopenharmony_ci ***************************************************************************/
2613498266Sopenharmony_ci
2713498266Sopenharmony_ci
2813498266Sopenharmony_ci/* OS/400 netdb.h does not define NI_MAXHOST. */
2913498266Sopenharmony_ci#define NI_MAXHOST      1025
3013498266Sopenharmony_ci
3113498266Sopenharmony_ci/* OS/400 netdb.h does not define NI_MAXSERV. */
3213498266Sopenharmony_ci#define NI_MAXSERV      32
3313498266Sopenharmony_ci
3413498266Sopenharmony_ci/* No OS/400 header file defines u_int32_t. */
3513498266Sopenharmony_citypedef unsigned long   u_int32_t;
3613498266Sopenharmony_ci
3713498266Sopenharmony_ci/* OS/400 has no idea of a tty! */
3813498266Sopenharmony_ci#define isatty(fd)      0
3913498266Sopenharmony_ci
4013498266Sopenharmony_ci
4113498266Sopenharmony_ci/* System API wrapper prototypes & definitions to support ASCII parameters. */
4213498266Sopenharmony_ci
4313498266Sopenharmony_ci#include <sys/socket.h>
4413498266Sopenharmony_ci#include <netdb.h>
4513498266Sopenharmony_ci#include <gskssl.h>
4613498266Sopenharmony_ci#include <qsoasync.h>
4713498266Sopenharmony_ci#include <gssapi.h>
4813498266Sopenharmony_ci
4913498266Sopenharmony_ciextern int Curl_getaddrinfo_a(const char *nodename,
5013498266Sopenharmony_ci                              const char *servname,
5113498266Sopenharmony_ci                              const struct addrinfo *hints,
5213498266Sopenharmony_ci                              struct addrinfo **res);
5313498266Sopenharmony_ci#define getaddrinfo             Curl_getaddrinfo_a
5413498266Sopenharmony_ci
5513498266Sopenharmony_ci/* Note socklen_t must be used as this is declared before curl_socklen_t */
5613498266Sopenharmony_ciextern int Curl_getnameinfo_a(const struct sockaddr *sa,
5713498266Sopenharmony_ci                              socklen_t salen,
5813498266Sopenharmony_ci                              char *nodename, socklen_t nodenamelen,
5913498266Sopenharmony_ci                              char *servname, socklen_t servnamelen,
6013498266Sopenharmony_ci                              int flags);
6113498266Sopenharmony_ci#define getnameinfo             Curl_getnameinfo_a
6213498266Sopenharmony_ci
6313498266Sopenharmony_ci/* GSSAPI wrappers. */
6413498266Sopenharmony_ci
6513498266Sopenharmony_ciextern OM_uint32 Curl_gss_import_name_a(OM_uint32 * minor_status,
6613498266Sopenharmony_ci                                        gss_buffer_t in_name,
6713498266Sopenharmony_ci                                        gss_OID in_name_type,
6813498266Sopenharmony_ci                                        gss_name_t * out_name);
6913498266Sopenharmony_ci#define gss_import_name         Curl_gss_import_name_a
7013498266Sopenharmony_ci
7113498266Sopenharmony_ci
7213498266Sopenharmony_ciextern OM_uint32 Curl_gss_display_status_a(OM_uint32 * minor_status,
7313498266Sopenharmony_ci                                           OM_uint32 status_value,
7413498266Sopenharmony_ci                                           int status_type, gss_OID mech_type,
7513498266Sopenharmony_ci                                           gss_msg_ctx_t * message_context,
7613498266Sopenharmony_ci                                           gss_buffer_t status_string);
7713498266Sopenharmony_ci#define gss_display_status      Curl_gss_display_status_a
7813498266Sopenharmony_ci
7913498266Sopenharmony_ci
8013498266Sopenharmony_ciextern OM_uint32 Curl_gss_init_sec_context_a(OM_uint32 * minor_status,
8113498266Sopenharmony_ci                                             gss_cred_id_t cred_handle,
8213498266Sopenharmony_ci                                             gss_ctx_id_t * context_handle,
8313498266Sopenharmony_ci                                             gss_name_t target_name,
8413498266Sopenharmony_ci                                             gss_OID mech_type,
8513498266Sopenharmony_ci                                             gss_flags_t req_flags,
8613498266Sopenharmony_ci                                             OM_uint32 time_req,
8713498266Sopenharmony_ci                                             gss_channel_bindings_t
8813498266Sopenharmony_ci                                             input_chan_bindings,
8913498266Sopenharmony_ci                                             gss_buffer_t input_token,
9013498266Sopenharmony_ci                                             gss_OID * actual_mech_type,
9113498266Sopenharmony_ci                                             gss_buffer_t output_token,
9213498266Sopenharmony_ci                                             gss_flags_t * ret_flags,
9313498266Sopenharmony_ci                                             OM_uint32 * time_rec);
9413498266Sopenharmony_ci#define gss_init_sec_context    Curl_gss_init_sec_context_a
9513498266Sopenharmony_ci
9613498266Sopenharmony_ci
9713498266Sopenharmony_ciextern OM_uint32 Curl_gss_delete_sec_context_a(OM_uint32 * minor_status,
9813498266Sopenharmony_ci                                               gss_ctx_id_t * context_handle,
9913498266Sopenharmony_ci                                               gss_buffer_t output_token);
10013498266Sopenharmony_ci#define gss_delete_sec_context  Curl_gss_delete_sec_context_a
10113498266Sopenharmony_ci
10213498266Sopenharmony_ci
10313498266Sopenharmony_ci/* LDAP wrappers. */
10413498266Sopenharmony_ci
10513498266Sopenharmony_ci#define BerValue                struct berval
10613498266Sopenharmony_ci
10713498266Sopenharmony_ci#define ldap_url_parse          ldap_url_parse_utf8
10813498266Sopenharmony_ci#define ldap_init               Curl_ldap_init_a
10913498266Sopenharmony_ci#define ldap_simple_bind_s      Curl_ldap_simple_bind_s_a
11013498266Sopenharmony_ci#define ldap_search_s           Curl_ldap_search_s_a
11113498266Sopenharmony_ci#define ldap_get_values_len     Curl_ldap_get_values_len_a
11213498266Sopenharmony_ci#define ldap_err2string         Curl_ldap_err2string_a
11313498266Sopenharmony_ci#define ldap_get_dn             Curl_ldap_get_dn_a
11413498266Sopenharmony_ci#define ldap_first_attribute    Curl_ldap_first_attribute_a
11513498266Sopenharmony_ci#define ldap_next_attribute     Curl_ldap_next_attribute_a
11613498266Sopenharmony_ci
11713498266Sopenharmony_ci/* Some socket functions must be wrapped to process textual addresses
11813498266Sopenharmony_ci   like AF_UNIX. */
11913498266Sopenharmony_ci
12013498266Sopenharmony_ciextern int Curl_os400_connect(int sd, struct sockaddr *destaddr, int addrlen);
12113498266Sopenharmony_ciextern int Curl_os400_bind(int sd, struct sockaddr *localaddr, int addrlen);
12213498266Sopenharmony_ciextern int Curl_os400_sendto(int sd, char *buffer, int buflen, int flags,
12313498266Sopenharmony_ci                             const struct sockaddr *dstaddr, int addrlen);
12413498266Sopenharmony_ciextern int Curl_os400_recvfrom(int sd, char *buffer, int buflen, int flags,
12513498266Sopenharmony_ci                               struct sockaddr *fromaddr, int *addrlen);
12613498266Sopenharmony_ciextern int Curl_os400_getpeername(int sd, struct sockaddr *addr, int *addrlen);
12713498266Sopenharmony_ciextern int Curl_os400_getsockname(int sd, struct sockaddr *addr, int *addrlen);
12813498266Sopenharmony_ci
12913498266Sopenharmony_ci#define connect                 Curl_os400_connect
13013498266Sopenharmony_ci#define bind                    Curl_os400_bind
13113498266Sopenharmony_ci#define sendto                  Curl_os400_sendto
13213498266Sopenharmony_ci#define recvfrom                Curl_os400_recvfrom
13313498266Sopenharmony_ci#define getpeername             Curl_os400_getpeername
13413498266Sopenharmony_ci#define getsockname             Curl_os400_getsockname
13513498266Sopenharmony_ci
13613498266Sopenharmony_ci#ifdef HAVE_LIBZ
13713498266Sopenharmony_ci#define zlibVersion             Curl_os400_zlibVersion
13813498266Sopenharmony_ci#define inflateInit_            Curl_os400_inflateInit_
13913498266Sopenharmony_ci#define inflateInit2_           Curl_os400_inflateInit2_
14013498266Sopenharmony_ci#define inflate                 Curl_os400_inflate
14113498266Sopenharmony_ci#define inflateEnd              Curl_os400_inflateEnd
14213498266Sopenharmony_ci#endif
14313498266Sopenharmony_ci
14413498266Sopenharmony_ci#endif /* HEADER_CURL_SETUP_OS400_H */
145