forked from pEp.foundation/pEpEngine
...
parent
7664a78e4e
commit
f099bc6959
|
@ -1,4 +1,4 @@
|
|||
all: pEp.xml basic_api.h
|
||||
all: basic_api.h
|
||||
|
||||
YML2=$(wildcard *.yml2)
|
||||
YSL2=$(wildcard *.ysl2)
|
||||
|
@ -9,7 +9,7 @@ YSL2=$(wildcard *.ysl2)
|
|||
%.xsl: %.ysl2
|
||||
yml2proc -DP $< -o $@
|
||||
|
||||
%.h: $(YML2) $(YSL2)
|
||||
%.h: $(YML2) $(YSL2) pEp.xml
|
||||
yml2proc -y gen_c_header.ysl2 pEp.yml2
|
||||
|
||||
.PHONY: clean
|
||||
|
|
|
@ -73,17 +73,17 @@ enum comm_type {
|
|||
hex OpenPGP_weak_unconfirmed 0x11 doc="RSA 1024 is weak";
|
||||
|
||||
hex to_be_checked 0x20 doc="generic";
|
||||
hex SMIME_unconfirmed 0x21;
|
||||
hex SMIME_unconfirmed 0x21 doc="encrypted with S/MIME";
|
||||
hex CMS_unconfirmed 0x22;
|
||||
|
||||
hex strong_but_unconfirmed 0x30 doc="generic";
|
||||
hex OpenPGP_unconfirmed 0x38 doc="key at least 2048 bit RSA or EC";
|
||||
hex OTR_unconfirmed 0x3a;
|
||||
hex OpenPGP_unconfirmed 0x38 doc="key at least 2048 bit RSA, EC, or anything useful";
|
||||
hex OTR_unconfirmed 0x3a doc="encrypted with OTR";
|
||||
|
||||
doc > range 0x40 to 0x7f: unconfirmed encryption and anonymization
|
||||
|
||||
hex unconfirmed_enc_anon 0x40 doc="generic";
|
||||
hex pEp_unconfirmed 0x7f
|
||||
hex pEp_unconfirmed 0x7f doc="encrypted with pEp";
|
||||
|
||||
hex confirmed 0x80 doc="this bit decides if trust is confirmed";
|
||||
|
||||
|
@ -112,22 +112,17 @@ enum comm_type {
|
|||
struct identity {
|
||||
field string address doc="SMTP address or URI. String with address UTF-8 encoded";
|
||||
field hash fpr doc="fingerprint of key being used as ID. String with fingerprint UTF-8 encoded";
|
||||
field string user_id
|
||||
doc="""
|
||||
ID for person or entity in M2M case. String with user ID UTF-8 encoded
|
||||
field string user_id doc="ID for person or system in case of M2M";
|
||||
doc ||
|
||||
user_id MIGHT be set to "pEp_own_userId" (use PEP_OWN_USERID preprocessor define)
|
||||
if this is own user's identity. But it is not REQUIRED to be.
|
||||
""";
|
||||
||
|
||||
field string username doc="descriptive string. String with user name UTF-8 encoded";
|
||||
field comm_type comm_type doc="type of communication with this ID";
|
||||
field ISO639_1 lang[3]
|
||||
doc="""
|
||||
two-digit language code or null bytes.
|
||||
language of conversation ISO 639-1 ALPHA-2, last byte is 0
|
||||
""";
|
||||
field ISO639_1 lang[3] doc="ISO 639-1 ALPHA-2, last byte is 0";
|
||||
field bool me doc="if this is the local user herself/himself";
|
||||
field unsigned int major_ver doc="highest version of pEp message received, if any";
|
||||
field unsigned int minor_ver doc="highest version of pEp message received, if any";
|
||||
field unsigned major_ver doc="highest version of pEp message received, if any";
|
||||
field unsigned minor_ver doc="highest version of pEp message received, if any";
|
||||
field identity_flags_t flags doc="identity_flag1 | identity_flag2 | ...";
|
||||
} // struct Identity
|
||||
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
version = "version 2.0"
|
||||
copyleft = "Copyleft (c) 2019, pEp foundation"
|
||||
copyleft = "Copyleft (c) 2019-2020, pEp foundation"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// p≡p API header generator
|
||||
|
||||
// Copyleft (c) 2019, p≡p foundation
|
||||
// Copyleft (c) 2019-2020, p≡p foundation
|
||||
// this file is under GNU General Public License 3.0
|
||||
// see LICENSE.txt
|
||||
|
||||
|
@ -12,6 +12,7 @@ include ./config.yml2
|
|||
|
||||
tstylesheet {
|
||||
include ./to_c.ysl2
|
||||
include standardlib.ysl2
|
||||
|
||||
const "version" **version;
|
||||
const "copyleft" **copyleft;
|
||||
|
@ -45,7 +46,7 @@ tstylesheet {
|
|||
}
|
||||
|
||||
template "type" {
|
||||
if "@doc" | // «@doc»
|
||||
apply "@doc", 0;
|
||||
| typedef «func:basetype(@name)» «@name»;
|
||||
|
|
||||
}
|
||||
|
@ -54,7 +55,7 @@ tstylesheet {
|
|||
||
|
||||
typedef struct _«func:name()» {
|
||||
||
|
||||
apply "field";
|
||||
apply "field|doc";
|
||||
||
|
||||
} «func:name()»;
|
||||
|
||||
|
@ -62,9 +63,8 @@ tstylesheet {
|
|||
}
|
||||
|
||||
template "field" {
|
||||
if "@doc" | // «@doc»
|
||||
apply "@doc", 0;
|
||||
| «func:c-type(@type)» «@name»;
|
||||
|
|
||||
}
|
||||
|
||||
template "enum" {
|
||||
|
@ -78,18 +78,24 @@ tstylesheet {
|
|||
||
|
||||
}
|
||||
|
||||
template "doc"
|
||||
||
|
||||
|
||||
// «.»
|
||||
|
||||
||
|
||||
template "doc|@doc" {
|
||||
> \n
|
||||
choose {
|
||||
when "contains(., '\n')"
|
||||
| /* */
|
||||
otherwise
|
||||
| // «.»
|
||||
}
|
||||
> \n
|
||||
}
|
||||
|
||||
template "item" {
|
||||
0> «func:name()»`if "text()" { " = " value "." }``if "position()!=last()" > ,`
|
||||
apply "@doc", 0;
|
||||
choose {
|
||||
when "@doc" > // «@doc»\n
|
||||
otherwise > \n
|
||||
when "@output='hex'"
|
||||
| «func:name()»`if "text()" { " = 0x" value "yml:dec2hex(., 2)" }``if "position()!=last()" > ,`
|
||||
otherwise
|
||||
| «func:name()»`if "text()" { " = " value "." }``if "position()!=last()" > ,`
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,55 +8,67 @@
|
|||
|
||||
|
||||
enum text_format {
|
||||
hex text_format_plain 0;
|
||||
hex text_format_html 1;
|
||||
hex text_format_other 0xff;
|
||||
hex plain 0;
|
||||
hex html 1;
|
||||
hex other 0xff;
|
||||
}
|
||||
|
||||
|
||||
enum msg_direction {
|
||||
item dir_incoming 0;
|
||||
item dir_outgoing 1;
|
||||
enum direction {
|
||||
item incoming 0;
|
||||
item outgoing 1;
|
||||
}
|
||||
|
||||
|
||||
enum enc_format {
|
||||
item enc_none 0 doc='message is not encrypted';
|
||||
item enc_pieces 1 doc='inline PGP + PGP extensions';
|
||||
item enc_S_MIME 2 doc='RFC5751';
|
||||
item enc_PGP_MIME 3 doc='RFC3156';
|
||||
item enc_PEP 4 doc='pEp encryption format';
|
||||
item enc_PGP_MIME_Outlook1 5 doc='Message B0rken by Outlook type 1';
|
||||
item none 0 doc='message is not encrypted';
|
||||
item pieces 1 doc='inline PGP + PGP extensions';
|
||||
item S_MIME 2 doc='RFC5751';
|
||||
item PGP_MIME 3 doc='RFC3156';
|
||||
item PEP 4 doc='pEp encryption format';
|
||||
item PGP_MIME_Outlook1 5 doc='Message B0rken by Outlook type 1';
|
||||
}
|
||||
|
||||
|
||||
enum ratings {
|
||||
item rating_undefined 0;
|
||||
item rating_cannot_decrypt 1;
|
||||
item rating_have_no_key 2;
|
||||
item rating_unencrypted 3;
|
||||
item rating_unencrypted_for_some doc="don't use this any more",
|
||||
item rating_unreliable 4;
|
||||
item rating_reliable 5;
|
||||
item rating_trusted 6;
|
||||
item rating_trusted_and_anonymized 7;
|
||||
item rating_fully_anonymous 8;
|
||||
item rating_mistrust -1;
|
||||
item rating_b0rken -2;
|
||||
item rating_under_attack -3;
|
||||
enum rating {
|
||||
item undefined 0 doc="no rating available";
|
||||
|
||||
doc "no color";
|
||||
|
||||
item cannot_decrypt 1;
|
||||
item have_no_key 2;
|
||||
item unencrypted 3;
|
||||
// 5 is reserved
|
||||
item unreliable 5;
|
||||
|
||||
doc "yellow";
|
||||
|
||||
item reliable 6;
|
||||
|
||||
doc "green";
|
||||
|
||||
item trusted 7;
|
||||
item trusted_and_anonymized 8;
|
||||
item fully_anonymous 9;
|
||||
|
||||
doc "red";
|
||||
|
||||
item mistrust -1;
|
||||
item b0rken -2;
|
||||
item under_attack -3;
|
||||
}
|
||||
|
||||
|
||||
enum colors {
|
||||
item color_no_color 0;
|
||||
item color_yellow 1;
|
||||
item color_green 2;
|
||||
item color_red -1;
|
||||
enum color {
|
||||
item no_color 0;
|
||||
item yellow 1;
|
||||
item green 2;
|
||||
item red -1;
|
||||
}
|
||||
|
||||
|
||||
struct message {
|
||||
field msg_direction dir;
|
||||
field direction dir;
|
||||
field string id doc='string of message ID';
|
||||
field string shortmsg doc='string of short message';
|
||||
field string longmsg doc='string of long message (plain)';
|
||||
|
|
36
api/pEp.yml2
36
api/pEp.yml2
|
@ -1,6 +1,6 @@
|
|||
// p≡p API Y language
|
||||
|
||||
// Copyleft (c) 2019, p≡p foundation
|
||||
// Copyleft (c) 2019-2020, p≡p foundation
|
||||
// this file is under GNU General Public License 3.0
|
||||
// see LICENSE.txt
|
||||
|
||||
|
@ -21,19 +21,19 @@ decl protocol @name;
|
|||
decl method @name;
|
||||
decl construct, new is construct;
|
||||
|
||||
// use: readonly in parm, ownership remains with caller
|
||||
// readonly in parm, ownership remains with caller
|
||||
decl use @type @name (mode=use) alias parm;
|
||||
|
||||
// lend: inout parm, ownership remains with caller
|
||||
// inout parm, ownership remains with caller
|
||||
decl supply @type @name (mode=supply) alias parm;
|
||||
|
||||
// create: factory delivers this, ownership goes to caller
|
||||
// factory delivers this, ownership goes to caller
|
||||
decl create @type @name (mode=create) alias parm;
|
||||
|
||||
// provide: in parm, ownership goes to callee
|
||||
// in parm, ownership goes to callee
|
||||
decl provide @type @name (mode=provide) alias parm;
|
||||
|
||||
// return: out parm, ownership goes to callee
|
||||
// out parm, ownership goes to callee
|
||||
decl return @type @name (mode=return) alias parm;
|
||||
|
||||
decl throws @except;
|
||||
|
@ -42,23 +42,21 @@ decl caveat(mode=caveat) alias doc;
|
|||
|
||||
// base types
|
||||
|
||||
// string: text
|
||||
doc="""
|
||||
p≡p engine uses UTF-8 strings which are NFC normalized.
|
||||
Cf. https://dev.pep.foundation/Engine/Basic%20Concepts%20of%20the%20pEp%20Engine
|
||||
"""
|
||||
// int: integer number
|
||||
// blob: Binary Large Object
|
||||
// size_t: size in memory
|
||||
// bool: true or false
|
||||
// string text
|
||||
// p≡p engine uses UTF-8 strings which are NFC normalized.
|
||||
// Cf. https //dev.pep.foundation/Engine/Basic%20Concepts%20of%20the%20pEp%20Engine
|
||||
|
||||
// int integer number
|
||||
// blob Binary Large Object
|
||||
// size_t size in memory
|
||||
// bool true or false
|
||||
|
||||
|
||||
// collections
|
||||
|
||||
// list: one or more elements, which have a sequence
|
||||
// set: one or more elements, which do not have a sequence
|
||||
// pair: two elements in sequence
|
||||
|
||||
// list one or more elements, which have a sequence
|
||||
// set one or more elements, which do not have a sequence
|
||||
// pair two elements in sequence
|
||||
|
||||
|
||||
package pEp {
|
||||
|
|
|
@ -11,14 +11,11 @@ template "*", mode=name {
|
|||
param "abbr", "false()";
|
||||
if ".!=/*" {
|
||||
apply "..", 0, mode=name;
|
||||
> _
|
||||
}
|
||||
choose {
|
||||
when '@name="basic"'
|
||||
> «/*/@name»
|
||||
otherwise
|
||||
> «@name»
|
||||
if "@name!='basic' and @name != string(../@name)"
|
||||
> _
|
||||
}
|
||||
if "@name!='basic' and @name != string(../@name)"
|
||||
> «@name»
|
||||
}
|
||||
|
||||
function "name" {
|
||||
|
@ -45,8 +42,12 @@ def "func:basetype" {
|
|||
def "func:c-type" {
|
||||
param "dsltype";
|
||||
choose {
|
||||
when "$dsltype = 'string' or $dsltype = 'binary'"
|
||||
result "'char *'";
|
||||
when "$dsltype = 'string'"
|
||||
result > char *
|
||||
when "$dsltype = 'binary'"
|
||||
result > unsigned char *
|
||||
when "$dsltype = 'unsigned'"
|
||||
result > unsigned int
|
||||
otherwise
|
||||
result "$dsltype";
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue