-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwin32compress_client.h
More file actions
82 lines (72 loc) · 2.19 KB
/
win32compress_client.h
File metadata and controls
82 lines (72 loc) · 2.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#ifndef _WIN32COMPRESS_CLIENT_
#define _WIN32COMPRESS_CLIENT_
#include <stdio.h>
#include <string.h>
#include "util/wintypes.h"
// note: see http://pstreams.sourceforge.net/ for a better bidirectional pipe
#include "compress_msgs.h"
#if defined(USE_POPEN)
#include "popen_ipc_clt.h"
#elif defined(USE_PSTREAM)
#include "pstream_ipc_clt.h"
#elif defined(USE_SOCKET)
#include "socket_ipc_clt.h"
#elif defined(USE_PIPE)
#include "pipe_ipc_clt.h"
#elif defined(USE_BOOST)
#include "boost_ipc_clt.h"
#elif defined(USE_SHMEM)
#include "shmem_ipc_clt.h"
#endif
//#define ccltlog(...) fprintf(stderr, __VA_ARGS__)
#define ccltlog(...)
class win32compress_client {
#if defined(USE_POPEN)
popen_ipc_client _ipc;
#elif defined(USE_PSTREAM)
pstream_ipc_client _ipc;
#elif defined(USE_SOCKET)
socket_ipc_client _ipc;
#elif defined(USE_PIPE)
pipe_ipc_client _ipc;
#elif defined(USE_BOOST)
boost_ipc_client _ipc;
#elif defined(USE_SHMEM)
shmem_ipc_client _ipc;
#endif
public:
win32compress_client()
: _ipc("compressserver", StringList())
{
// ccltlog("compressclient started server, reqsize=%d, ressize=%d\n", (int)sizeof(compressrequest), (int)sizeof(compressresult));
}
void loaddlls()
{
}
uint32_t DoCompressConvert(int dwType, unsigned char*out, uint32_t outlength, const unsigned char *data, uint32_t insize)
{
compressrequest req;
req.dwType =dwType;
req.outlength =outlength;
req.insize =insize;
if (!_ipc.write(&req, sizeof(req)))
return 0xFFFFFFFF;
if (!_ipc.write(data, insize))
return 0xFFFFFFFF;
compressresult result;
if (!_ipc.read(&result, sizeof(result)))
return 0xFFFFFFFF;
if (result.resultLen==0xFFFFFFFF)
return 0xFFFFFFFF;
if (!_ipc.read(out, result.resultLen))
return 0xFFFFFFFF;
return result.resultLen;
}
bool makerequest(const compressrequest &req, compressresult &result)
{
// ccltlog("client: sending request : %d: %d bytes\n", req.dwType, req.insize);
// ccltlog("client: got result: %d bytes\n", result.resultLen);
return true;
}
};
#endif