aboutsummaryrefslogtreecommitdiff
path: root/packages/OS400
diff options
context:
space:
mode:
Diffstat (limited to 'packages/OS400')
-rw-r--r--packages/OS400/curl.inc.in35
-rw-r--r--packages/OS400/initscript.sh4
-rw-r--r--packages/OS400/os400sys.c146
3 files changed, 176 insertions, 9 deletions
diff --git a/packages/OS400/curl.inc.in b/packages/OS400/curl.inc.in
index eae8da6ab..23808f4b7 100644
--- a/packages/OS400/curl.inc.in
+++ b/packages/OS400/curl.inc.in
@@ -382,6 +382,8 @@
d c 79
d CURLE_SSL_SHUTDOWN_FAILED...
d c 80
+ d CURLE_AGAIN...
+ d c 81
*
d curlioerr s 10i 0 based(######ptr######) Enum
d CURLIOE_OK c 0
@@ -872,15 +874,17 @@
d CURLINFO_OS_ERRNO... CURLINFO_LONG + 25
d c X'00200019'
d CURLINFO_NUM_CONNECTS... CURLINFO_LONG + 26
- d c X'00200020'
+ d c X'0020001A'
d CURLINFO_SSL_ENGINES... CURLINFO_SLIST + 27
- d c X'00400021'
+ d c X'0040001B'
d CURLINFO_COOKIELIST... CURLINFO_SLIST + 28
- d c X'00400022'
+ d c X'0040001C'
d CURLINFO_LASTSOCKET... CURLINFO_LONG + 29
- d c X'00200023'
+ d c X'0020001D'
d CURLINFO_FTP_ENTRY_PATH... CURLINFO_STRING + 30
- d c X'00100024'
+ d c X'0010001E'
+ d CURLINFO_REDIRECT_URL... CURLINFO_STRING + 31
+ d c X'0010001F'
d CURLINFO_HTTP_CODE... Old ...RESPONSE_CODE
d c X'00200002'
*
@@ -1113,6 +1117,9 @@
d curl_read_callback...
d s * based(######ptr######) procptr
*
+ d curl_write_callback...
+ d s * based(######ptr######) procptr
+ *
d curl_seek_callback...
d s * based(######ptr######) procptr
*
@@ -1164,7 +1171,7 @@
d curl_strnequal pr 10i 0 extproc('curl_strnequal')
d s1 * value options(*string)
d s2 * value options(*string)
- d n 10i 0 value
+ d n 10u 0 value
*
d curl_formget pr 10i 0 extproc('curl_formget')
d form * value curl_httppost *
@@ -1359,6 +1366,22 @@
d pr extproc('curl_easy_reset')
d curl * value CURL *
*
+ d curl_easy_recv...
+ d pr extproc('curl_easy_recv')
+ d like(CURLcode)
+ d curl * value CURL *
+ d buffer * value void *
+ d buflen 10u 0 value size_t
+ d n 10u 0 size_t *
+ *
+ d curl_easy_send...
+ d pr extproc('curl_easy_send')
+ d like(CURLcode)
+ d curl * value CURL *
+ d buffer * value const void *
+ d buflen 10u 0 value size_t
+ d n 10u 0 size_t *
+ *
d curl_easy_pause...
d pr extproc('curl_easy_pause')
d curl * value CURL *
diff --git a/packages/OS400/initscript.sh b/packages/OS400/initscript.sh
index 4dcbe7235..ad4aa7da2 100644
--- a/packages/OS400/initscript.sh
+++ b/packages/OS400/initscript.sh
@@ -40,10 +40,10 @@ SRVPGM="CURL.${SONAME}" # Service program.
TGTCCSID='500' # Target CCSID of objects
DEBUG='*ALL' # Debug level
OPTIMIZE='10' # Optimisation level
-OUTPUT='*NONE' # Compilation output option.
+OUTPUT='*NONE' # Compilation output option.
TGTRLS='V5R2M0' # Target OS release
-export TARGETLIB STATBNDDIR DYNBNDDIR SRVPGM TGTCCSID DEBUG OPTIMIZE OUTPUTC
+export TARGETLIB STATBNDDIR DYNBNDDIR SRVPGM TGTCCSID DEBUG OPTIMIZE OUTPUT
export TGTRLS
diff --git a/packages/OS400/os400sys.c b/packages/OS400/os400sys.c
index 404bc7107..608aab69a 100644
--- a/packages/OS400/os400sys.c
+++ b/packages/OS400/os400sys.c
@@ -24,12 +24,14 @@
/* OS/400 additional support. */
-#include "config-os400.h" /* Not setup.h: we only need some defines. */
+#include "config-os400.h" /* Not setup.h: we only need some defines. */
#include <sys/types.h>
#include <sys/socket.h>
+#include <sys/un.h>
#include <stdlib.h>
+#include <stddef.h>
#include <string.h>
#include <pthread.h>
#include <netdb.h>
@@ -965,3 +967,145 @@ Curl_ldap_next_attribute_a(void * ld,
}
#endif /* CURL_DISABLE_LDAP */
+
+
+static int
+convert_sockaddr(struct sockaddr_storage * dstaddr,
+ const struct sockaddr * srcaddr, int srclen)
+
+{
+ const struct sockaddr_un * srcu;
+ struct sockaddr_un * dstu;
+ unsigned int i;
+ unsigned int dstsize;
+
+ /* Convert a socket address into job CCSID, if needed. */
+
+ if (!srcaddr || srclen < offsetof(struct sockaddr, sa_family) +
+ sizeof srcaddr->sa_family || srclen > sizeof *dstaddr) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ memcpy((char *) dstaddr, (char *) srcaddr, srclen);
+
+ switch (srcaddr->sa_family) {
+
+ case AF_UNIX:
+ srcu = (const struct sockaddr_un *) srcaddr;
+ dstu = (struct sockaddr_un *) dstaddr;
+ dstsize = sizeof *dstaddr - offsetof(struct sockaddr_un, sun_path);
+ srclen -= offsetof(struct sockaddr_un, sun_path);
+ i = QadrtConvertA2E(dstu->sun_path, srcu->sun_path, dstsize - 1, srclen);
+ dstu->sun_path[i] = '\0';
+ i += offsetof(struct sockaddr_un, sun_path);
+ srclen = i;
+ }
+
+ return srclen;
+}
+
+
+int
+Curl_os400_connect(int sd, struct sockaddr * destaddr, int addrlen)
+
+{
+ int i;
+ struct sockaddr_storage laddr;
+
+ i = convert_sockaddr(&laddr, destaddr, addrlen);
+
+ if (i < 0)
+ return -1;
+
+ return connect(sd, (struct sockaddr *) &laddr, i);
+}
+
+
+int
+Curl_os400_bind(int sd, struct sockaddr * localaddr, int addrlen)
+
+{
+ int i;
+ struct sockaddr_storage laddr;
+
+ i = convert_sockaddr(&laddr, localaddr, addrlen);
+
+ if (i < 0)
+ return -1;
+
+ return bind(sd, (struct sockaddr *) &laddr, i);
+}
+
+
+int
+Curl_os400_sendto(int sd, char * buffer, int buflen, int flags,
+ struct sockaddr * dstaddr, int addrlen)
+
+{
+ int i;
+ struct sockaddr_storage laddr;
+
+ i = convert_sockaddr(&laddr, dstaddr, addrlen);
+
+ if (i < 0)
+ return -1;
+
+ return sendto(sd, buffer, buflen, flags, (struct sockaddr *) &laddr, i);
+}
+
+
+int
+Curl_os400_recvfrom(int sd, char * buffer, int buflen, int flags,
+ struct sockaddr * fromaddr, int * addrlen)
+
+{
+ int i;
+ int rcvlen;
+ int laddrlen;
+ const struct sockaddr_un * srcu;
+ struct sockaddr_un * dstu;
+ struct sockaddr_storage laddr;
+
+ if (!fromaddr || !addrlen || *addrlen <= 0)
+ return recvfrom(sd, buffer, buflen, flags, fromaddr, addrlen);
+
+ laddrlen = sizeof laddr;
+ laddr.ss_family = AF_UNSPEC; /* To detect if unused. */
+ rcvlen = recvfrom(sd, buffer, buflen, flags,
+ (struct sockaddr *) &laddr, &laddrlen);
+
+ if (rcvlen < 0)
+ return rcvlen;
+
+ switch (laddr.ss_family) {
+
+ case AF_UNIX:
+ srcu = (const struct sockaddr_un *) &laddr;
+ dstu = (struct sockaddr_un *) fromaddr;
+ i = *addrlen - offsetof(struct sockaddr_un, sun_path);
+ laddrlen -= offsetof(struct sockaddr_un, sun_path);
+ i = QadrtConvertE2A(dstu->sun_path, srcu->sun_path, i, laddrlen);
+ laddrlen = i + offsetof(struct sockaddr_un, sun_path);
+
+ if (laddrlen < *addrlen)
+ dstu->sun_path[i] = '\0';
+
+ break;
+
+ case AF_UNSPEC:
+ break;
+
+ default:
+ if (laddrlen > *addrlen)
+ laddrlen = *addrlen;
+
+ if (laddrlen)
+ memcpy((char *) fromaddr, (char *) &laddr, laddrlen);
+
+ break;
+ }
+
+ *addrlen = laddrlen;
+ return rcvlen;
+}