xref: /curl/lib/setup-os400.h (revision ad8c9a58)
1 #ifndef HEADER_CURL_SETUP_OS400_H
2 #define HEADER_CURL_SETUP_OS400_H
3 /***************************************************************************
4  *                                  _   _ ____  _
5  *  Project                     ___| | | |  _ \| |
6  *                             / __| | | | |_) | |
7  *                            | (__| |_| |  _ <| |___
8  *                             \___|\___/|_| \_\_____|
9  *
10  * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
11  *
12  * This software is licensed as described in the file COPYING, which
13  * you should have received as part of this distribution. The terms
14  * are also available at https://curl.se/docs/copyright.html.
15  *
16  * You may opt to use, copy, modify, merge, publish, distribute and/or sell
17  * copies of the Software, and permit persons to whom the Software is
18  * furnished to do so, under the terms of the COPYING file.
19  *
20  * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
21  * KIND, either express or implied.
22  *
23  * SPDX-License-Identifier: curl
24  *
25  ***************************************************************************/
26 
27 
28 /* OS/400 netdb.h does not define NI_MAXHOST. */
29 #define NI_MAXHOST      1025
30 
31 /* OS/400 netdb.h does not define NI_MAXSERV. */
32 #define NI_MAXSERV      32
33 
34 /* No OS/400 header file defines u_int32_t. */
35 typedef unsigned long   u_int32_t;
36 
37 /* OS/400 has no idea of a tty! */
38 #define isatty(fd)      0
39 
40 
41 /* Workaround bug in IBM QADRT runtime library:
42  * function puts() does not output the implicit trailing newline.
43  */
44 
45 #include <stdio.h>      /* Be sure it is loaded. */
46 #undef puts
47 #define puts(s) (fputs((s), stdout) == EOF? EOF: putchar('\n'))
48 
49 
50 /* System API wrapper prototypes & definitions to support ASCII parameters. */
51 
52 #include <sys/socket.h>
53 #include <netdb.h>
54 #include <gskssl.h>
55 #include <qsoasync.h>
56 #include <gssapi.h>
57 
58 #ifdef BUILDING_LIBCURL
59 
60 extern int Curl_getaddrinfo_a(const char *nodename,
61                               const char *servname,
62                               const struct addrinfo *hints,
63                               struct addrinfo **res);
64 #define getaddrinfo             Curl_getaddrinfo_a
65 
66 /* Note socklen_t must be used as this is declared before curl_socklen_t */
67 extern int Curl_getnameinfo_a(const struct sockaddr *sa,
68                               socklen_t salen,
69                               char *nodename, socklen_t nodenamelen,
70                               char *servname, socklen_t servnamelen,
71                               int flags);
72 #define getnameinfo             Curl_getnameinfo_a
73 
74 /* GSSAPI wrappers. */
75 
76 extern OM_uint32 Curl_gss_import_name_a(OM_uint32 * minor_status,
77                                         gss_buffer_t in_name,
78                                         gss_OID in_name_type,
79                                         gss_name_t * out_name);
80 #define gss_import_name         Curl_gss_import_name_a
81 
82 
83 extern OM_uint32 Curl_gss_display_status_a(OM_uint32 * minor_status,
84                                            OM_uint32 status_value,
85                                            int status_type, gss_OID mech_type,
86                                            gss_msg_ctx_t * message_context,
87                                            gss_buffer_t status_string);
88 #define gss_display_status      Curl_gss_display_status_a
89 
90 
91 extern OM_uint32 Curl_gss_init_sec_context_a(OM_uint32 * minor_status,
92                                              gss_cred_id_t cred_handle,
93                                              gss_ctx_id_t * context_handle,
94                                              gss_name_t target_name,
95                                              gss_OID mech_type,
96                                              gss_flags_t req_flags,
97                                              OM_uint32 time_req,
98                                              gss_channel_bindings_t
99                                              input_chan_bindings,
100                                              gss_buffer_t input_token,
101                                              gss_OID * actual_mech_type,
102                                              gss_buffer_t output_token,
103                                              gss_flags_t * ret_flags,
104                                              OM_uint32 * time_rec);
105 #define gss_init_sec_context    Curl_gss_init_sec_context_a
106 
107 
108 extern OM_uint32 Curl_gss_delete_sec_context_a(OM_uint32 * minor_status,
109                                                gss_ctx_id_t * context_handle,
110                                                gss_buffer_t output_token);
111 #define gss_delete_sec_context  Curl_gss_delete_sec_context_a
112 
113 
114 /* LDAP wrappers. */
115 
116 #define BerValue                struct berval
117 
118 #define ldap_url_parse          ldap_url_parse_utf8
119 #define ldap_init               Curl_ldap_init_a
120 #define ldap_simple_bind_s      Curl_ldap_simple_bind_s_a
121 #define ldap_search_s           Curl_ldap_search_s_a
122 #define ldap_get_values_len     Curl_ldap_get_values_len_a
123 #define ldap_err2string         Curl_ldap_err2string_a
124 #define ldap_get_dn             Curl_ldap_get_dn_a
125 #define ldap_first_attribute    Curl_ldap_first_attribute_a
126 #define ldap_next_attribute     Curl_ldap_next_attribute_a
127 
128 /* Some socket functions must be wrapped to process textual addresses
129    like AF_UNIX. */
130 
131 extern int Curl_os400_connect(int sd, struct sockaddr *destaddr, int addrlen);
132 extern int Curl_os400_bind(int sd, struct sockaddr *localaddr, int addrlen);
133 extern int Curl_os400_sendto(int sd, char *buffer, int buflen, int flags,
134                              const struct sockaddr *dstaddr, int addrlen);
135 extern int Curl_os400_recvfrom(int sd, char *buffer, int buflen, int flags,
136                                struct sockaddr *fromaddr, int *addrlen);
137 extern int Curl_os400_getpeername(int sd, struct sockaddr *addr, int *addrlen);
138 extern int Curl_os400_getsockname(int sd, struct sockaddr *addr, int *addrlen);
139 
140 #define connect                 Curl_os400_connect
141 #define bind                    Curl_os400_bind
142 #define sendto                  Curl_os400_sendto
143 #define recvfrom                Curl_os400_recvfrom
144 #define getpeername             Curl_os400_getpeername
145 #define getsockname             Curl_os400_getsockname
146 
147 #ifdef HAVE_LIBZ
148 #define zlibVersion             Curl_os400_zlibVersion
149 #define inflateInit_            Curl_os400_inflateInit_
150 #define inflateInit2_           Curl_os400_inflateInit2_
151 #define inflate                 Curl_os400_inflate
152 #define inflateEnd              Curl_os400_inflateEnd
153 #endif
154 
155 #endif /* BUILDING_LIBCURL */
156 
157 #endif /* HEADER_CURL_SETUP_OS400_H */
158