Browse Source

modifications for Windoze

async_key_management
Volker Birk 7 years ago
parent
commit
f7233d42ab
15 changed files with 156460 additions and 211 deletions
  1. +9
    -1
      pEpEngine.vcxproj
  2. +3
    -0
      pEpEngine.vcxproj.filters
  3. +11
    -10
      src/etpan_mime.c
  4. +1
    -5
      src/keymanagement.c
  5. +1
    -6
      src/message_api.c
  6. +1
    -3
      src/mime.c
  7. +2
    -2
      src/pEp_internal.h
  8. +1
    -1
      src/pgp_gpg.c
  9. +15
    -0
      src/platform.h
  10. +14
    -0
      src/platform_unix.h
  11. +12
    -3
      src/platform_windows.cpp
  12. +10
    -1
      src/platform_windows.h
  13. +148882
    -0
      src/sqlite3.c
  14. +7494
    -0
      src/sqlite3.h
  15. +4
    -179
      src/wrappers.h

+ 9
- 1
pEpEngine.vcxproj View File

@ -41,8 +41,9 @@
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<IncludePath>C:\Program Files %28x86%29\GNU\GnuPG\include;$(IncludePath)</IncludePath>
<IncludePath>C:\Users\vb\Documents\Visual Studio 2013\Projects\libetpan\build-windows\include;C:\Program Files %28x86%29\GNU\GnuPG\include;$(IncludePath)</IncludePath>
<RunCodeAnalysis>false</RunCodeAnalysis>
<LibraryPath>C:\Users\vb\Documents\Visual Studio 2013\Projects\libetpan\build-windows\Debug;$(LibraryPath)</LibraryPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
@ -60,6 +61,7 @@
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
@ -115,6 +117,7 @@
<ClInclude Include="src\pEp_internal.h" />
<ClInclude Include="src\pgp_gpg.h" />
<ClInclude Include="src\pgp_gpg_internal.h" />
<ClInclude Include="src\platform.h" />
<ClInclude Include="src\platform_windows.h" />
<ClInclude Include="src\resource.h" />
<ClInclude Include="src\sqlite3.h" />
@ -128,6 +131,11 @@
<ItemGroup>
<Text Include="LICENSE.txt" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\libetpan\build-windows\libetpan\libetpan.vcxproj">
<Project>{ba4ded3c-e56f-4484-bfc3-9c13e461a1be}</Project>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>

+ 3
- 0
pEpEngine.vcxproj.filters View File

@ -140,6 +140,9 @@
<ClInclude Include="src\mime.h">
<Filter>Headerdateien</Filter>
</ClInclude>
<ClInclude Include="src\platform.h">
<Filter>Headerdateien</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Text Include="LICENSE.txt" />


+ 11
- 10
src/etpan_mime.c View File

@ -1,15 +1,15 @@
#include <string.h>
#include <stdlib.h>
#ifndef WIN32
#include <unistd.h>
#endif
#include <assert.h>
#include "etpan_mime.h"
#ifndef mailmime_param_new_with_data
#include <libetpan/mailprivacy_tools.h>
#endif
#include "platform.h"
#include <string.h>
#include <stdlib.h>
#include <assert.h>
time_t mail_mkgmtime(struct tm * tmp);
#define MAX_MESSAGE_ID 512
@ -21,7 +21,6 @@ static char * generate_boundary(void)
long value2;
long value3;
long value4;
int r;
// no random needed here
@ -448,8 +447,9 @@ struct mailimf_date_time * timestamp_to_etpantime(const struct tm *ts)
result->dt_day = ts->tm_mday;
result->dt_month = ts->tm_mon + 1;
result->dt_year = ts->tm_year + 1900;
#ifndef WIN32
result->dt_zone = (int) (ts->tm_gmtoff / 36L);
#endif
return result;
}
@ -468,8 +468,9 @@ struct tm * 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 WIN32
result->tm_gmtoff = 36L * (long) et->dt_zone;
#endif
return result;
}


+ 1
- 5
src/keymanagement.c View File

@ -1,8 +1,4 @@
#ifndef WIN32 // POSIX
#define _POSIX_C_SOURCE 200809L
#else
#include "platform_windows.h"
#endif
#include "platform.h"
#include <string.h>
#include <stdio.h>


+ 1
- 6
src/message_api.c View File

@ -1,12 +1,7 @@
#include "pEp_internal.h"
#include "message_api.h"
#ifndef WIN32 // POSIX
#define _POSIX_C_SOURCE 200809L
#include <strings.h>
#else
#include "platform_windows.h"
#endif
#include "platform.h"
#include <assert.h>
#include <string.h>


+ 1
- 3
src/mime.c View File

@ -5,9 +5,7 @@
#include <stdlib.h>
#include <assert.h>
#include <errno.h>
#ifndef WIN32
#include <unistd.h>
#endif
#include "etpan_mime.h"
#include "wrappers.h"


+ 2
- 2
src/pEp_internal.h View File

@ -15,15 +15,15 @@
// default keyserver
#define DEFAULT_KEYSERVER "hkp://keys.gnupg.net"
#include "platform.h"
#ifdef WIN32
#include "platform_windows.h"
#define LOCAL_DB windoze_local_db()
#define SYSTEM_DB windoze_system_db()
#define LIBGPGME "libgpgme-11.dll"
#else // UNIX
#define _POSIX_C_SOURCE 200809L
#include <dlfcn.h>
#include "platform_unix.h"
#define LOCAL_DB unix_local_db()
#ifndef SYSTEM_DB
#define SYSTEM_DB "/usr/share/pEp/system.db"


+ 1
- 1
src/pgp_gpg.c View File

@ -1,5 +1,5 @@
#include "pgp_gpg.h"
#include "pEp_internal.h"
#include "pgp_gpg.h"
#include <limits.h>


+ 15
- 0
src/platform.h View File

@ -0,0 +1,15 @@
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
#ifdef WIN32
#include "platform_windows.h"
#else
#include "platform_unix.h"
#endif
#ifdef __cplusplus
}
#endif

+ 14
- 0
src/platform_unix.h View File

@ -1,2 +1,16 @@
#define _POSIX_C_SOURCE 200809L
#include <unistd.h>
#include <strings.h>
#include <sys/select.h>
#ifdef __cplusplus
extern "C" {
#endif
const char *unix_local_db(void);
const char *gpg_conf(void);
#ifdef __cplusplus
}
#endif

+ 12
- 3
src/platform_windows.cpp View File

@ -14,6 +14,8 @@
#include <string>
#include <stdexcept>
#include "platform_windows.h"
#include <fcntl.h>
#include <sys\stat.h>
#ifndef WC_ERR_INVALID_CHARS
#define WC_ERR_INVALID_CHARS 0x00000080 // error for invalid chars
@ -200,12 +202,12 @@ long random(void)
e = rand_s(&r);
} while (e);
return (long) (r & ((1<<31)-1));
return (long) (r & ((1U<<31)-1));
}
char *strndup(const char *s1, size_t n)
{
char *str = calloc(n + 1, 1);
char *str = (char *) calloc(n + 1, 1);
if (str == NULL)
return NULL;
@ -213,5 +215,12 @@ char *strndup(const char *s1, size_t n)
return str;
}
} // "C"
int mkstemp(char *templ)
{
char *pathname = _mktemp(templ);
if (errno)
return -1;
return _open(pathname, _O_RDWR | _O_CREAT | _O_EXCL, _S_IREAD | _S_IWRITE);
}
} // "C"

+ 10
- 1
src/platform_windows.h View File

@ -5,16 +5,19 @@
#pragma warning(disable : 4996)
#include <string.h>
#include <io.h>
#ifdef __cplusplus
extern "C" {
#endif
#define RTLD_LAZY 1
#define mode_t int
void *dlopen(const char *filename, int flag);
int dlclose(void *handle);
void *dlsym(void *handle, const char *symbol);
int mkstemp(char *templ);
#ifndef strdup
#define strdup(A) _strdup((A))
@ -30,6 +33,12 @@ void *dlsym(void *handle, const char *symbol);
#endif
#ifndef gmtime_r
#define gmtime_r(A, B) gmtime_s((B), (A))
#endif
#ifndef ftruncate
#define ftruncate(A, B) _chsize((A), (B))
#endif
#ifndef ftello
#define ftello(A) ((off_t) _ftelli64(A))
#endif
char *strndup(const char *s1, size_t n);
@ -41,7 +50,7 @@ const char *gpg_conf(void);
long random(void);
#ifndef inline
#define inline _inline
#define inline __inline
#endif
#ifdef __cplusplus


+ 148882
- 0
src/sqlite3.c
File diff suppressed because it is too large
View File


+ 7494
- 0
src/sqlite3.h
File diff suppressed because it is too large
View File


+ 4
- 179
src/wrappers.h View File

@ -1,13 +1,11 @@
#pragma once
#include "platform.h"
#include <errno.h>
#include <stdarg.h>
#ifdef WIN32
#include "platform_windows.h"
#endif
#ifdef EOF // stdio.h
#include <stdio.h>
#include <fcntl.h>
static inline FILE * Fopen(const char *filename, const char *mode)
{
@ -19,7 +17,6 @@ static inline FILE * Fopen(const char *filename, const char *mode)
return f;
}
#define fopen >@<
static inline FILE * Fdopen(int fildes, const char *mode)
{
@ -31,7 +28,6 @@ static inline FILE * Fdopen(int fildes, const char *mode)
return f;
}
#define fdopen >@<
static inline char *Fgets(char * str, int size, FILE * stream)
{
@ -43,7 +39,6 @@ static inline char *Fgets(char * str, int size, FILE * stream)
return s;
}
#define fgets >@<
static inline int Fputs(const char *str, FILE * stream)
{
@ -55,7 +50,6 @@ static inline int Fputs(const char *str, FILE * stream)
return r;
}
#define fputs >@<
static inline int Fclose(FILE *stream)
{
@ -67,7 +61,6 @@ static inline int Fclose(FILE *stream)
return r;
}
#define fclose >@<
static inline FILE * Freopen(
const char *filename,
@ -83,7 +76,6 @@ static inline FILE * Freopen(
return f;
}
#define freopen >@<
static inline int Fprintf(FILE * stream, const char * format, ...)
{
@ -100,7 +92,6 @@ static inline int Fprintf(FILE * stream, const char * format, ...)
return n;
}
#define fprintf >@<
static inline size_t Fwrite(const void *ptr, size_t size, size_t nitems, FILE *stream)
{
@ -115,7 +106,6 @@ static inline size_t Fwrite(const void *ptr, size_t size, size_t nitems, FILE *s
return r;
}
#define fwrite >@<
static inline size_t Fread(void *ptr, size_t size, size_t nitems, FILE *stream)
{
@ -130,7 +120,6 @@ static inline size_t Fread(void *ptr, size_t size, size_t nitems, FILE *stream)
return r;
}
#define fread >@<
static inline int Fflush(FILE *stream)
{
@ -142,11 +131,6 @@ static inline int Fflush(FILE *stream)
return r;
}
#define fflush >@<
#endif // stdio.h
#ifdef F_OK // unistd.h
static inline int Mkstemp(char *template)
{
@ -158,7 +142,6 @@ static inline int Mkstemp(char *template)
return fd;
}
#define mkstemp >@<
static inline int Close(int fildes)
{
@ -170,161 +153,3 @@ static inline int Close(int fildes)
return r;
}
#define close >@<
static inline ssize_t Write(int fildes, const void *buf, size_t nbyte)
{
ssize_t r;
do {
r = write(fildes, buf, nbyte);
} while (r == -1 && errno == EINTR);
return r;
}
#define write >@<
static inline ssize_t Read(int fildes, void *buf, size_t nbyte)
{
ssize_t r;
do {
r = read(fildes, buf, nbyte);
} while (r == -1 && errno == EINTR);
return r;
}
#define read >@<
static inline int Ftruncate(int fildes, off_t length)
{
int r;
do {
r = ftruncate(fildes, length);
} while (r == -1 && errno == EINTR);
return r;
}
#define ftruncate >@<
static inline int Dup2(int fildes, int fildes2)
{
int fd;
do {
fd = dup2(fildes, fildes2);
} while (fd == -1 && errno == EINTR);
return fd;
}
#define dup2 >@<
#endif
#ifdef FD_CLR // select.h
static inline int Select(
int nfds,
fd_set *readfds,
fd_set *writefds,
fd_set *errorfds,
struct timeval *timeout
)
{
int r;
do {
r = select(nfds, readfds, writefds, errorfds, timeout);
} while (r == -1 && errno == EINTR);
return r;
}
#define select >@<
#endif // select.h
#ifdef F_SETLKW // fcntl.h
static inline int Fcntl(int fildes, int cmd, void *structure)
{
int r;
do {
r = fcntl(fildes, cmd, structure);
} while (r == -1 && errno == EINTR);
return r;
}
// fnctl does only risk EINTR if cmd == F_SETLKW
static inline int Open(const char *path, int oflag, ...)
{
int fd;
do {
fd = open(path, oflag, 0);
} while (fd == -1 && errno == EINTR);
return fd;
}
#define open >@<
static inline int Creat(const char *path, mode_t mode)
{
int fd;
do {
fd = creat(path, mode);
} while (fd == -1 && errno == EINTR);
return fd;
}
#define creat >@<
#endif // fcntl.h
#ifdef MSG_PEEK // socket.h
static inline ssize_t Recv(int socket, void *buffer, size_t length, int flags)
{
ssize_t r;
do {
r = recv(socket, buffer, length, flags);
} while (r == -1 && errno == EINTR);
return r;
}
#define recv >@<
static inline ssize_t Send(int socket, const void *buffer, size_t length, int flags)
{
ssize_t r;
do {
r = send(socket, buffer, length, flags);
} while (r == -1 && errno == EINTR);
return r;
}
#define send >@<
#endif // socket.h
#ifdef WNOHANG // wait.h
static inline pid_t Waitpid(pid_t pid, int *stat_loc, int options)
{
pid_t r;
do {
r = waitpid(pid, stat_loc, options);
} while (r == -1 && errno == EINTR);
return r;
}
#define waitpid >@<
#endif

Loading…
Cancel
Save