harden ipc and frontend recovery
This commit is contained in:
41
ipc.h
41
ipc.h
@@ -1,9 +1,21 @@
|
||||
// req: 4 bytes [type, mod, key lo, key hi]
|
||||
// resp: 2+n bytes [type, n, ...]
|
||||
#ifndef STRANS_IPC_H
|
||||
#define STRANS_IPC_H
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#define IPCPATH "/tmp/strans.2.%d"
|
||||
|
||||
/*
|
||||
* Request: [want-preedit, modifiers, key byte 0, ..., key byte 3].
|
||||
* Response: [eaten, commit-length-low, commit-length-high, commit...],
|
||||
* followed, when requested, by
|
||||
* [preedit-length-low, preedit-length-high, preedit...].
|
||||
* Lengths are little-endian byte counts; fields are at most Ipcfieldmax bytes.
|
||||
*/
|
||||
|
||||
enum
|
||||
{
|
||||
Kspec = 0xf000,
|
||||
Kspec = 0x110000,
|
||||
Kback = Kspec|0x08,
|
||||
Ktab = Kspec|0x09,
|
||||
Kret = Kspec|0x0d,
|
||||
@@ -17,4 +29,27 @@ enum
|
||||
Mctrl = 1<<2,
|
||||
Malt = 1<<3,
|
||||
Msuper = 1<<6,
|
||||
|
||||
Ipcreqsz = 6,
|
||||
Ipclensz = 2,
|
||||
Ipcresphdrsz = 1 + Ipclensz,
|
||||
Ipcfieldmax = 256,
|
||||
Ipcmaxresp = Ipcresphdrsz + Ipcfieldmax + Ipclensz + Ipcfieldmax,
|
||||
};
|
||||
|
||||
typedef struct Ipcresp Ipcresp;
|
||||
struct Ipcresp
|
||||
{
|
||||
int eaten;
|
||||
size_t ncommit;
|
||||
size_t npreedit;
|
||||
};
|
||||
|
||||
void ipcpackreq(unsigned char[Ipcreqsz], int, unsigned int, unsigned int);
|
||||
void ipcunpackreq(const unsigned char[Ipcreqsz], int*, unsigned int*, unsigned int*);
|
||||
int ipcpackresp(unsigned char*, size_t, int, const char*, size_t, const char*, size_t, int);
|
||||
int ipcreadn(int, void*, size_t);
|
||||
int ipcsend(int, const void*, size_t);
|
||||
int ipcreadresp(int, int, char*, size_t, char*, size_t, Ipcresp*);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user