Merge pull request 'zos_support2' (#62) from leviathan/pEpEngine:zos_support2 into master

Reviewed-on: #62
ENGINE-964
positron 1 year ago
commit 7d20dba1a1

@ -32,7 +32,10 @@ BUILD_FOR=$(BUILD_ON)
# Cross-compiling is currently not supported.
# Maybe you can hack something with `local.conf`.
ifneq ($(BUILD_ON),$(BUILD_FOR))
$(error I don't know how to build for $(BUILD_FOR) on $(BUILD_ON).)
ifeq ($(BUILD_FOR),OS/390)
$(warning Generating sources for z/OS)
endif
ONLY_GENERATE=true
endif
# Installation path prefix for libraries and binaries, except for system.db
@ -50,7 +53,9 @@ PREFIX=$(HOME)
PER_MACHINE_DIRECTORY=/usr/local/share/pEp
# Filename of the pEpEngine library
ifeq ($(BUILD_FOR),Linux)
ifeq ($(BUILD_FOR),OS/390)
TARGET=libpEpEngine.so
else ifeq ($(BUILD_FOR),Linux)
TARGET=libpEpEngine.so
else ifeq ($(BUILD_FOR),Darwin)
TARGET=libpEpEngine.dylib
@ -82,25 +87,38 @@ endif
# Are we wiping this on purpose?
LDLIBS=
######### C #########
ifeq ($(BUILD_FOR),Linux)
CC=gcc
ifeq ($(BUILD_FOR),OS/390)
CC=xlclang
else ifeq ($(BUILD_FOR),Linux)
CC=gcc -std=c99 -pthread
else ifeq ($(BUILD_FOR),Darwin)
CC=clang
endif
CFLAGS+=-std=c99 -pthread
CFLAGS+=-fPIC -fstrict-aliasing
ifeq ($(BUILD_FOR),Linux)
CFLAGS+=-fdiagnostics-color=auto
ifeq ($(BUILD_FOR),OS/390)
CFLAGS= -Wno-gnu-include-next -qnosearch -I$(HERE) -I.
CFLAGS+= -I/usr/include
CFLAGS+= -DZOS -D_XOPEN_SOURCE=600 -D_POSIX_C_SOURCE=200112L -qlanglvl=NOLIBEXT
else ifeq ($(BUILD_FOR),Linux)
CFLAGS+=-fPIC -fstrict-aliasing -fdiagnostics-color=auto
else ifeq ($(BUILD_FOR),Darwin)
CFLAGS+=-fcolor-diagnostics
CFLAGS+=-pthread -fPIC -fstrict-aliasing -fcolor-diagnostics
endif
# The flag -DNDEBUG will always be removed from CFLAGS for compiling tests.
# The tests do not work properly, if compiled with -DNDEBUG
ifeq ($(BUILD_FOR),Linux)
ifeq ($(BUILD_FOR),OS/390)
ifdef WARN
CFLAGS+= -Wall -pedantic
else
CFLAGS+= -w
endif
ifdef DEBUG
CFLAGS+= -g -DDEBUG_ERRORSTACK
else
CFLAGS+= -O3 -DNDEBUG
endif
else ifeq ($(BUILD_FOR),Linux)
ifdef WARN
CFLAGS+= -Wall -pedantic -Wstrict-aliasing=3
else
@ -142,16 +160,34 @@ ifeq ($(BUILD_FOR),Linux)
CXX=g++
CXXFLAGS+=-std=gnu++11
else ifeq ($(BUILD_FOR),Darwin)
CXX=clang
CXXFLAGS+=-std=c++11
# clang issues a warning when "-pthread" is used for linking. So, include it in CXXFLAGS, and not in CXX
CXX=clang -std=c++11
else ifeq ($(BUILD_FOR),OS/390)
CXX=xlclang++ -std=c++11
endif
ifneq ($(BUILD_FOR),OS/390)
CXXFLAGS+=-pthread
endif
# The flag -DNDEBUG will always be removed from CPPFLAGS for compiling tests.
#
# The tests do not work properly, if compiled with -DNDEBUG
ifeq ($(BUILD_FOR),Linux)
ifeq ($(BUILD_FOR),OS/390)
CXXFLAGS+= -fdiagnostics-color=auto -Wno-gnu-include-next
CXXFLAGS+= -qnosearch -I$(HERE) -I. -I../src -I../asn.1 $(ETPAN_INC) -I/usr/lpp/java/J8.0_64/include -I/usr/include
CXXFLAGS+= -DZOS -D_XOPEN_SOURCE=600 -D_POSIX_C_SOURCE=200112L
ifdef WARN
CXXFLAGS+=
else
CXXFLAGS+= -w
endif
ifdef DEBUG
CXXFLAGS+= -g
else
CXXFLAGS+= -O3 -DNDEBUG
endif
else ifeq ($(BUILD_FOR),Linux)
CXXFLAGS+=-fdiagnostics-color=auto -I../src -I../asn.1 $(ETPAN_INC)
ifdef WARN
CXXFLAGS+=
@ -165,7 +201,7 @@ ifeq ($(BUILD_FOR),Linux)
CPPFLAGS+= -DNDEBUG
endif
else ifeq ($(BUILD_FOR),Darwin)
CXXFLAGS+=-fcolor-diagnostics -I../src -I../asn.1 $(ETPAN_INC)
CXXFLAGS+=-pthread -fcolor-diagnostics -I../src -I../asn.1 $(ETPAN_INC)
ifdef WARN
CXXFLAGS+=
else
@ -181,9 +217,10 @@ endif
######### C and C++ #########
ifeq ($(BUILD_FOR),Darwin)
CPPFLAGS+=-D_DARWIN_C_SOURCE
LDLIBS+=-liconv
ifeq ($(BUILD_FOR),OS/390)
CPPFLAGS=-W "l,xplink,dll" -W "c,float(ieee),xplink,dll,exportall"
else ifeq ($(BUILD_FOR),Darwin)
CPPFLAGS=-D_DARWIN_C_SOURCE
else
LDLIBS+=-luuid
endif
@ -238,7 +275,11 @@ ETPAN_INC=
######### OpenPGP #########
# Selects OpenPGP implementation. must be `SEQUOIA`
ifeq ($(BUILD_FOR),OS/390)
OPENPGP=NETPGP
else
OPENPGP=SEQUOIA
endif
# Sequoia-specific variables
SEQUOIA_CFLAGS+=
@ -254,6 +295,16 @@ SEQUOIA_INC=
# EXTRA_MACROS=-DDEFAULT_KEYSERVER=\"default-server.org\" -DCRASHDUMP_DEFAULT_LINES=23
EXTRA_MACROS=
ifdef PER_USER_DIRECTORY
EXTRA_MACROS+= -DPER_USER_DIRECTORY=\"$(PER_USER_DIRECTORY)\"
endif
ifdef PER_MACHINE_DIRECTORY
EXTRA_MACROS+= -DPER_MACHINE_DIRECTORY=\"$(PER_MACHINE_DIRECTORY)\"
endif
CFLAGS+=$(EXTRA_MACROS)
CXXFLAGS+=$(EXTRA_MACROS)
######### Misc #########
# FIXME Maybe include these variables here.
@ -313,7 +364,9 @@ ifndef PEP_MIME_SRC
$(error "Compiling with the PEP_MIME option set requires the value of PEP_MIME_SRC to be set to the source directory for libpEpMIME")
else
CPPFLAGS+=-DPEP_BUILTIN_MIME
ifneq ($(BUILD_ON),OS/390)
LDLIBS+=-lstdc++
endif
ETPAN_LIB=
ETPAN_INC=
endif

@ -16,14 +16,19 @@ ifdef PER_MACHINE_DIRECTORY
EXTRA_MACROS+= -DPER_MACHINE_DIRECTORY='"$(PER_MACHINE_DIRECTORY)"'
endif
ifneq ($(BUILD_ON),OS/390)
LDFLAGS+= -shared
endif
NO_SOURCE=
ifndef PEP_MIME
CFLAGS+= $(ETPAN_INC)
LDFLAGS+= $(ETPAN_LIB)
ifeq ($(BUILD_ON),OS/390)
LDLIBS+= -letpan-no-mt
else
LDLIBS+= -letpan
endif
else
LDFLAGS+= -L../pEpMIME -shared
LDLIBS+= -lpEpMIME
NO_SOURCE+= etpan_mime.c
endif
@ -31,10 +36,17 @@ endif
CFLAGS+= -I../asn.1 $(EXTRA_MACROS)
CPPFLAGS+= -DSQLITE_THREADSAFE=1
LDFLAGS+= -L../asn.1 -shared
LDLIBS+= -lc -lasn1
LDFLAGS+= -L../asn.1
ifneq ($(BUILD_ON),OS/390)
LDFLAGS+= -shared
LDLIBS+= -lc
endif
LDLIBS+= -lasn1
ifeq ($(BUILD_ON),Darwin)
ifeq ($(BUILD_ON),OS/390)
OPENPGP=NETPGP
LDLIBS+= -lzz
else ifeq ($(BUILD_ON),Darwin)
ifeq ($(BUILD_FOR),Darwin)
LDLIBS+= -lz -liconv -mmacosx-version-min=10.10
else
@ -62,6 +74,13 @@ ifeq ($(OPENPGP),SEQUOIA)
CFLAGS+= $(SEQUOIA_CFLAGS) $(SEQUOIA_INC)
LDFLAGS+= $(SEQUOIA_LDFLAGS)
LDLIBS+= $(SEQUOIA_LIB)
NO_SOURCE+=pgp_netpgp.c
else ifeq ($(OPENPGP),NETPGP)
CPPFLAGS+= -DUSE_NETPGP
CFLAGS+= $(NETPGP_CFLAGS) $(NETPGP_INC)
LDFLAGS+= $(NETPGP_LDFLAGS)
LDLIBS+= $(NETPGP_LIB)
NO_SOURCE+=pgp_sequoia.c
else
$(error Unknown OpenPGP library: $(OPENPGP))
endif
@ -69,6 +88,10 @@ endif
ALL_SOURCE=$(filter-out $(NO_SOURCE),$(wildcard *.c))
DEPENDS=$(subst .c,.d,$(ALL_SOURCE))
ALL_OBJECTS=$(subst .c,.o,$(ALL_SOURCE))
ifeq ($(BUILD_ON),OS/390)
ALL_OBJECTS+=/usr/lib/GSKCMS64.x
ALL_OBJECTS+=/usr/lib/CSNPCA64.x
endif
all: $(TARGET)
@ -86,7 +109,7 @@ ifneq ($(MAKECMDGOALS),clean)
endif
$(TARGET): libpEpEngine.a
$(CC) $(CFLAGS) $(CPPFLAGS) $(ALL_OBJECTS) $(LDFLAGS) $(LDLIBS) -o $@
$(CC) -o $@ $(CPPFLAGS) $(LDFLAGS) $(CFLAGS) $(ALL_OBJECTS) $(LDLIBS)
.PHONY: objects clean install_headers install uninstall beinstall

@ -6,10 +6,11 @@
#include "pEp_internal.h"
#ifdef USE_SEQUOIA
#if defined(USE_SEQUOIA)
#include "pgp_sequoia.h"
#elif defined(USE_NETPGP)
#include "pgp_netpgp.h"
#endif
//
#include <stdlib.h>
#include <memory.h>

@ -566,7 +566,9 @@ struct mailimf_date_time * timestamp_to_etpantime(const timestamp *ts)
result->dt_day = ts->tm_mday;
result->dt_month = ts->tm_mon + 1;
result->dt_year = ts->tm_year + 1900;
#ifndef ZOS
result->dt_zone = (int) (ts->tm_gmtoff / 36L);
#endif
return result;
}
@ -585,13 +587,16 @@ timestamp * etpantime_to_timestamp(const struct mailimf_date_time *et)
result->tm_mday = et->dt_day;
result->tm_mon = et->dt_month - 1;
result->tm_year = et->dt_year - 1900;
#ifndef ZOS
result->tm_gmtoff = 36L * (long) et->dt_zone;
#endif
// Normalize to UTC and then forget the offset.
time_t t = timegm_with_gmtoff(result);
gmtime_r(&t, result);
#ifndef ZOS
result->tm_gmtoff = 0;
#endif
return result;
}

@ -19,8 +19,10 @@ extern "C" {
#include "dynamic_api.h"
#include "stringpair.h"
#ifdef USE_SEQUOIA
#if defined(USE_SEQUOIA)
#include "pgp_sequoia.h"
#elif defined(USE_NETPGP)
#include "pgp_netpgp.h"
#endif
/**

@ -75,7 +75,9 @@
#define LOCAL_DB windoze_local_db()
#define SYSTEM_DB windoze_system_db()
#else // UNIX
#ifndef ZOS
#define _POSIX_C_SOURCE 200809L
#endif
#include <dlfcn.h>
#define LOCAL_DB unix_local_db()
#ifdef ANDROID
@ -108,11 +110,6 @@
#include "keymanagement_internal.h"
#include "message_api_internal.h"
// If not specified, build for Sequoia
#ifndef USE_SEQUOIA
#define USE_SEQUOIA
#endif
#if defined(USE_SEQUOIA)
#include "pgp_sequoia_internal.h"
#endif

File diff suppressed because it is too large Load Diff

@ -0,0 +1,426 @@
/**
* @file src/pgp_netpgp.h
*
* @brief NETPGP driver - implements required cryptotech
* functions for the engine using netpgp with SSL
*
* @license GNU General Public License 3.0 - see LICENSE.txt
*/
#ifndef PGP_PEP_NETPGP_H
#define PGP_PEP_NETPGP_H
#include "pEpEngine.h"
/**
* <!-- pgp_init() -->
*
* @brief initialise the sequoia driver for this session
*
* @param[in] session session handle
* @param[in] in_first true if this is the first pEp session running
* after startup, else false
*
* @retval PEP_STATUS_OK
* @retval any other value on error
*/
PEP_STATUS pgp_init(PEP_SESSION session, bool in_first);
/**
* <!-- pgp_release() -->
*
* @brief release resources used by the sequoia driver in this session
*
* @param[in] session session handle
* @param[in] out_last true if this is the last extant pEp session
* running, else false
*
*/
void pgp_release(PEP_SESSION session, bool out_last);
/**
* <!-- pgp_decrypt_and_verify() -->
*
* @brief TODO
*
* @param[in] session session handle
* @param[in] ctext const char*
* @param[in] csize size_t
* @param[in] dsigtext const char*
* @param[in] dsigsize size_t
* @param[in] ptext char**
* @param[in] psize size_t*
* @param[in] keylist stringlist_t**
* @param[in] filename_ptr char**
*
* @retval PEP_STATUS_OK
* @retval any other value on error
*/
PEP_STATUS pgp_decrypt_and_verify(
PEP_SESSION session, const char *ctext, size_t csize,
const char *dsigtext, size_t dsigsize,
char **ptext, size_t *psize, stringlist_t **keylist,
char** filename_ptr
);
/**
* <!-- pgp_encrypt_and_sign() -->
*
* @brief TODO
*
* @param[in] session session handle
* @param[in] keylist const stringlist_t*
* @param[in] ptext const char*
* @param[in] psize size_t
* @param[out] ctext char**
* @param[out] csize size_t*
*
* @retval PEP_STATUS_OK
* @retval any other value on error
*/
PEP_STATUS pgp_encrypt_and_sign(
PEP_SESSION session, const stringlist_t *keylist, const char *ptext,
size_t psize, char **ctext, size_t *csize
);
/**
* <!-- pgp_sign_only() -->
*
* @brief TODO
*
* @param[in] session session handle
* @param[in] fpr const char*
* @param[in] ptext const char*
* @param[in] psize size_t
* @param[out] stext char**
* @param[out] ssize size_t*
*
* @retval PEP_STATUS_OK
* @retval any other value on error
*/
PEP_STATUS pgp_sign_only(
PEP_SESSION session, const char* fpr, const char *ptext,
size_t psize, char **stext, size_t *ssize
);
/**
* <!-- pgp_encrypt_only() -->
*
* @brief TODO
*
* @param[in] session session handle
* @param[in] keylist const stringlist_t*
* @param[in] ptext const char*
* @param[in] psize size_t
* @param[out] ctext char**
* @param[out] csize size_t*
*
* @retval PEP_STATUS_OK
* @retval any other value on error
*/
PEP_STATUS pgp_encrypt_only(
PEP_SESSION session, const stringlist_t *keylist, const char *ptext,
size_t psize, char **ctext, size_t *csize
);
/**
* <!-- pgp_verify_text() -->
*
* @brief TODO
*
* @param[in] session session handle
* @param[in] text const char*
* @param[in] size size_t
* @param[in] signature const char*
* @param[in] sig_size size_t
* @param[in] keylist stringlist_t**
*
* @retval PEP_STATUS_OK
* @retval any other value on error
*/
PEP_STATUS pgp_verify_text(
PEP_SESSION session, const char *text, size_t size,
const char *signature, size_t sig_size, stringlist_t **keylist
);
/**
* <!-- pgp_delete_keypair() -->
*
* @brief TODO
*
* @param[in] session session handle
* @param[in] fpr const char*
*
* @retval PEP_STATUS_OK
* @retval any other value on error
*/
PEP_STATUS pgp_delete_keypair(PEP_SESSION session, const char *fpr);
/**
* <!-- pgp_export_keydata() -->
*
* @brief TODO
*
* @param[in] session session handle
* @param[in] fpr const char*
* @param[in] key_data char**
* @param[in] size size_t*
* @param[in] secret bool
*
* @retval PEP_STATUS_OK
* @retval any other value on error
*/
PEP_STATUS pgp_export_keydata(
PEP_SESSION session, const char *fpr, char **key_data, size_t *size,
bool secret
);
/**
* <!-- pgp_find_keys() -->
*
* @brief Find all keys (as fpr strings) which match this fpr or OpenPGP
* userid pattern
*
* @param[in] session session handle
* @param[in] pattern Pattern to search for; could be empty,
* an fpr, or a mailbox (email, URI, etc).
* @param[in,out] keylist A list of fprs containing matching keys.
*
* @note Unlike pgp_list_keyinfo, this function returns revoked keys.
*
* @see pgp_list_keyinfo()
*/
PEP_STATUS pgp_find_keys(
PEP_SESSION session, const char *pattern, stringlist_t **keylist
);
/**
* <!-- pgp_list_keyinfo() -->
*
* @brief Find all keys (returning <fpr, OpenPGP uid> pairs) which match this fpr
* or OpenPGP userid pattern
*
* @param[in] session session handle
* @param[in] pattern Pattern to search for; could be empty,
* an fpr, or a mailbox (email, URI, etc).
* @param[in,out] keyinfo_list A list of <fpr, OpenPGP userid> tuples for the
* matching keys.
*
* @note This function filters out revoked keys, but NOT expired keys.
*/
PEP_STATUS pgp_list_keyinfo(
PEP_SESSION session, const char* pattern, stringpair_list_t** keyinfo_list
);
/**
* <!-- pgp_generate_keypair() -->
*
* @brief TODO
*
* @param[in] session session handle
* @param[in] identity pEp_identity*
*
*/
PEP_STATUS pgp_generate_keypair(
PEP_SESSION session, pEp_identity *identity
);
/**
* <!-- pgp_get_key_rating() -->
*
* @brief TODO
*
* @param[in] session session handle
* @param[in] fpr const char*
* @param[in] comm_type PEP_comm_type*
*
*/
PEP_STATUS pgp_get_key_rating(
PEP_SESSION session,
const char *fpr,
PEP_comm_type *comm_type
);
/**
* <!-- pgp_import_keydata() -->
*
* @brief TODO
*
* @param[in] session session handle
* @param[in] key_data const char *
* @param[in] size size_t
* @param[in] private_idents identity_list **
* @param[in] imported_keys stringlist_t **
* @param[in] changed_key_index uint64_t *
*
*/
PEP_STATUS pgp_import_keydata(PEP_SESSION session, const char *key_data,
size_t size, identity_list **private_idents,
stringlist_t** imported_keys,
uint64_t* changed_key_index);
/**
* <!-- pgp_import_private_keydata() -->
*
* @brief TODO
*
* @param[in] session session handle
* @param[in] key_data const char*
* @param[in] size size_t
* @param[in] private_idents identity_list**
*
*/
PEP_STATUS pgp_import_private_keydata(PEP_SESSION session, const char *key_data,
size_t size, identity_list **private_idents);
/**
* <!-- pgp_recv_key() -->
*
* @brief TODO
*
* @param[in] session session handle
* @param[in] pattern const char*
*
*/
PEP_STATUS pgp_recv_key(PEP_SESSION session, const char *pattern);
/**
* <!-- pgp_send_key() -->
*
* @brief TODO
*
* @param[in] session session handle
* @param[in] pattern const char*
*
*/
PEP_STATUS pgp_send_key(PEP_SESSION session, const char *pattern);
/**
* <!-- pgp_renew_key() -->
*
* @brief TODO
*
* @param[in] session session handle
* @param[in] fpr const char*
* @param[in] ts const timestamp*
*
*/
PEP_STATUS pgp_renew_key(
PEP_SESSION session,
const char *fpr,
const timestamp *ts
);
/**
* <!-- pgp_revoke_key() -->
*
* @brief TODO
*
* @param[in] session session handle
* @param[in] fpr const char*
* @param[in] reason const char*
*
*/
PEP_STATUS pgp_revoke_key(
PEP_SESSION session,
const char *fpr,
const char *reason
);
/**
* <!-- pgp_key_expired() -->
*
* @brief TODO
*
* @param[in] session session handle
* @param[in] fpr const char*
* @param[in] when const time_t
* @param[in] expired bool*
*
*/
PEP_STATUS pgp_key_expired(
PEP_SESSION session,
const char *fpr,
const time_t when,
bool *expired
);
/**
* <!-- pgp_key_revoked() -->
*
* @brief TODO
*
* @param[in] session session handle
* @param[in] fpr const char*
* @param[out] revoked bool*
*
*/
PEP_STATUS pgp_key_revoked(
PEP_SESSION session,
const char *fpr,
bool *revoked
);
/**
* <!-- pgp_key_created() -->
*
* @brief TODO
*
* @param[in] session session handle
* @param[in] fpr const char*
* @param[out] created time_t*
*
*/
PEP_STATUS pgp_key_created(
PEP_SESSION session,
const char *fpr,
time_t *created
);
/**
* <!-- pgp_contains_priv_key() -->
*
* @brief TODO
*
* @param[in] session session handle
* @param[in] fpr const char*
* @param[in] has_private bool*
*
*/
PEP_STATUS pgp_contains_priv_key(
PEP_SESSION session,
const char *fpr,
bool *has_private);
/**
* <!-- pgp_find_private_keys() -->
*
* @brief Find all keys (as fpr strings) which match this fpr or OpenPGP
* userid pattern AND contain a private key
*
* @param[in] session session handle
* @param[in] pattern Pattern to search for; could be empty,
* an fpr, or a mailbox (email, URI, etc).
* @param[in,out] keylist A list of fprs containing matching keys.
*
* @note Unlike pgp_list_keyinfo, this function returns revoked keys.
*
* @see pgp_list_keyinfo()
*/
PEP_STATUS pgp_find_private_keys(
PEP_SESSION session, const char *pattern, stringlist_t **keylist
);
/**
* <!-- pgp_config_cipher_suite() -->
*
* @brief TODO
*
* @param[in] session session handle
* @param[in] suite PEP_CIPHER_SUITE
*
*/
PEP_STATUS pgp_config_cipher_suite(PEP_SESSION session,
PEP_CIPHER_SUITE suite);
#endif

@ -4,7 +4,9 @@
// This file is under GNU General Public License 3.0
// see LICENSE.txt
#ifndef ZOS
#define _POSIX_C_SOURCE 200809L
#endif
#ifdef ANDROID
#ifndef __LP64__
@ -38,9 +40,55 @@
#endif
#define SYSTEM_DB_FILENAME "system.db"
#ifdef ANDROID
#include <uuid.h>
#ifndef strndup
char *strndup (const char *s, size_t n)
{
char *result;
size_t len = strnlen (s, n);
result = (char *) malloc (len + 1);
if (!result)
return 0;
result[len] = '\0';
return (char *) memcpy (result, s, len);
}
#endif
#ifndef strnlen
size_t strnlen (const char *s, size_t maxlen)
{
size_t i;
for (i = 0; i < maxlen; ++i)
if (s[i] == '\0')
break;
return i;
}
#endif
#ifndef stpcpy
char *stpcpy(char *dst, const char *src)
{
for (;; ++dst, ++src) {
*dst = *src;
if (*dst == 0)
break;
}
return dst;
}
#endif
#ifndef alloca
#pragma linkage(__alloca,builtin)
void *__alloca(unsigned long x);
void *alloca(unsigned long x)
{
return __alloca(x);
}
#endif
#if defined(ANDROID) || defined(ZOS)
/* FIXME : timegm will miss when linking for x86_64 on android, when supported */
#ifndef __LP64__
time_t timegm(struct tm* const t) {
@ -73,16 +121,6 @@ char *stpncpy(char *dst, const char *src, size_t n)
return (dst);
}
char *stpcpy(char *dst, const char *src)
{
for (;; ++dst, ++src) {
*dst = *src;
if (*dst == 0)
break;
}
return dst;
}
/*
long int random(void)
{
@ -125,8 +163,36 @@ static char *_android_system_db(void)
}
return buffer;
}
#endif
#ifdef ZOS
char * e2as(const char * str)
{
char *ret = (char *)malloc(strlen(str));
strcpy(ret, str);
__e2a_s(ret);
return ret;
}
char * as2e(const char * str)
{
char *ret = (char *)malloc(strlen(str));
strcpy(ret, str);
__a2e_s(ret);
return ret;
}
void uuid_generate_random(pEpUUID out)
{
}
void uuid_unparse_upper(pEpUUID uu, uuid_string_t out)
{
}
#endif
#ifdef ANDROID
void uuid_generate_random(pEpUUID out)
{
uuid_t *uuid;
@ -147,7 +213,6 @@ void uuid_generate_random(pEpUUID out)
}
}
void uuid_unparse_upper(pEpUUID uu, uuid_string_t out)
{
uuid_t *uuid;
@ -171,7 +236,6 @@ void uuid_unparse_upper(pEpUUID uu, uuid_string_t out)
uuid_destroy(uuid);
}
}
#endif
#if !defined(BSD) && !defined(__APPLE__)

@ -7,7 +7,7 @@
#ifndef PLATFORM_UNIX_H
#define PLATFORM_UNIX_H
#ifndef __APPLE__
#if !defined(__APPLE__) && !defined(ZOS)
#define _POSIX_C_SOURCE 200809L
#endif
@ -15,13 +15,30 @@
#include <unistd.h>
#include <strings.h>
#include <sys/select.h>
#ifndef ZOS
#include <sys/param.h>
#endif
#include <regex.h>
#ifndef ANDROID
#ifdef ZOS
char * e2as(const char * str);
char * as2e(const char * str);
#endif
#if defined(ANDROID) || defined(ZOS)
typedef unsigned char uuid_t[16];
#else
#include <uuid/uuid.h>
#endif
#ifndef MIN
#define MIN(A, B) ((A)>(B) ? (B) : (A))
#endif
#ifndef MAX
#define MAX(A, B) ((A)>(B) ? (A) : (B))
#endif
// pEp files and directories
#ifndef PER_USER_DIRECTORY
@ -36,7 +53,6 @@
#endif
#endif
#ifdef __cplusplus
extern "C" {
#endif
@ -152,7 +168,7 @@ typedef char uuid_string_t[37];
// on *nix, uuid_t is an array and already implements pointer semantics
#define UUID uuid_t
#ifdef ANDROID
#if defined(ANDROID) || defined(ZOS)
typedef char pEpUUID[16];
void uuid_generate_random(pEpUUID out);
void uuid_unparse_upper(pEpUUID uu, uuid_string_t out);

@ -19738,7 +19738,7 @@ SQLITE_PRIVATE int sqlite3CorruptPgnoError(int,Pgno);
# define sqlite3Isquote(x) (sqlite3CtypeMap[(unsigned char)(x)]&0x80)
#else
# define sqlite3Toupper(x) toupper((unsigned char)(x))
# define sqlite3Isspace(x) isspace((unsigned char)(x))
# define sqlite3Isspace(x) (isspace((unsigned char)(x))||(x==0x15))
# define sqlite3Isalnum(x) isalnum((unsigned char)(x))
# define sqlite3Isalpha(x) isalpha((unsigned char)(x))
# define sqlite3Isdigit(x) isdigit((unsigned char)(x))

@ -0,0 +1,8 @@
#ifdef ZOS
#ifdef __cplusplus
#undef _EXT
#define _NO_EXT
#endif
#endif
#include_next <stdlib.h>

@ -0,0 +1,10 @@
#ifdef ZOS
#ifndef __cplusplus
char * stpcpy (char *dst, const char *src);
char * strndup (const char *s, size_t n);
size_t strnlen (const char *s, size_t maxlen);
#endif
#include <strings.h>
#endif
#include_next <string.h>

@ -22,10 +22,17 @@ DYNAMIC_API time_t timegm_with_gmtoff(const timestamp* ts)
_ts = timestamp_dup(ts);
if (_ts) {
#if defined(ZOS)
const time_t raw_time = mktime(_ts);
if (raw_time != -1) {
retval = raw_time;
}
#else
const time_t raw_time = timegm(_ts);
if (raw_time != -1) {
retval = raw_time - ts->tm_gmtoff;
retval = raw_time - _ts->tm_gmtoff;
}
#endif
}
}

@ -16,6 +16,15 @@ SRCS:=$(wildcard src/*.cc) $(wildcard src/*/*.cc)
OBJS:=$(addsuffix .o,$(basename $(SRCS)))
DEPS:=$(OBJS:.o=.d)
ifeq ($(BUILD_ON),OS/390)
OBJS+=../src/libpEpEngine.a
OBJS+=/usr/lib/GSKCMS64.x
OBJS+=/usr/lib/CSNPCA64.x
OBJS+=/user/lev/lib/libetpan-no-mt.a
endif
#endif
LDFLAGS+= -L../asn.1 -L../src $(ETPAN_LIB) $(GTEST_LDFLAGS)
TARGET:=EngineTests
@ -31,10 +40,12 @@ CPPFLAGS+= -DGTEST_SUITE_SYM=$(GTEST_SUITE_SYM)
ifdef PEP_MIME
LDLIBS+= -lpEpMIME
else
LDLIBS+= -letpan
ifneq ($(BUILD_ON),OS/390)
LDLIBS+= -letpan -lpEpEngine -lstdc++
endif
endif
LDLIBS+= -lpEpEngine -lstdc++ -lasn1
LDLIBS+= -lasn1
ifeq ($(BUILD_FOR),Linux)
LDLIBS+= -luuid
@ -52,8 +63,19 @@ ifdef SQLITE3_FROM_OS
LDLIBS+= -lsqlite3
endif
CXXFLAGS:=$(filter-out -DNDEBUG,$(CXXFLAGS)) -I$(GTEST_INC_DIR)
CPPFLAGS:=$(filter-out -DNDEBUG,$(CPPFLAGS))
ifeq ($(OPENPGP),GPG)
LDLIBS+= -lgpgme
else ifeq ($(OPENPGP),NETPGP)
LDLIBS+=$(NETPGP_LIB)
ifeq ($(BUILD_FOR),Linux)
LDLIBS+= -ltre
endif
endif
CXXFLAGS:=$(filter-out -DNDEBUG,$(CXXFLAGS))
# FIXME Possibly missing incdirs: ASN1C_INC
CXXFLAGS+= -I$(GTEST_INC_DIR) -I./src -I../sync $(INC_FLAGS) -Wno-deprecated -Wno-unused-variable
CXXFLAGS+= -I./src -I../src -I ../asn.1 -I../sync $(INC_FLAGS)
CXXFLAGS+= -Wno-deprecated -Wno-unused-variable
@ -90,10 +112,17 @@ all:
$(CXX) -MM $(CXXFLAGS) $(CPPFLAGS) $< \
| sed -e 's,\($*\)\.o[ :]*,\1.o $@: ,g' > $@
$(TARGET): $(OBJS)
${CXX} ${CXXFLAGS} ${CPPFLAGS} ${LDFLAGS} -L${PREFIX}/lib -o $@ $^ \
-lpEpEngine -lgtest -lgtest_main -lsequoia_openpgp_ffi $(LDLIBS)
LDLIBS+=-lgtest -lgtest_main
ifeq ($(BUILD_ON),OS/390)
LDLIBS+=-lzz
endif
ifeq ($(OPENPGP),SEQUOIA)
LDLIBS+=-lsequoia_openpgp_ffi
endif
$(TARGET): $(OBJS)
${CXX} ${LDFLAGS} -L${PREFIX}/lib -o $@ $^ $(LDLIBS)
test: all
$(RM) -rf ./pEp_test_home/*

Loading…
Cancel
Save