Browse Source

mapping internal to ASN.1 types

doc_update_sequoia
Volker Birk 6 years ago
parent
commit
40f504e184
3 changed files with 77 additions and 2 deletions
  1. +2
    -2
      src/Makefile
  2. +67
    -0
      src/map_asn1.c
  3. +8
    -0
      src/map_asn1.h

+ 2
- 2
src/Makefile View File

@ -12,7 +12,7 @@ LIBGPGME=libgpgme-pthread.dylib
CC?=clang -std=c99 -pthread
LD?=clang
CFLAGS?=-I$(GPGME_IN)/include -I$(HOME)/include -I/opt/local/include $(OPTIMIZE) -pedantic \
-DSYSTEM_DB=\"$(SYSTEM_DB)\" -DLIBGPGME=\"$(LIBGPGME)\"
-DSYSTEM_DB=\"$(SYSTEM_DB)\" -DLIBGPGME=\"$(LIBGPGME)\" -I../asn.1
LDFLAGS?=-lc -shared -arch x86_64 \
-L$(HOME)/lib -L/opt/local/lib -letpan -lsqlite3 -L../asn.1 -lasn1
@ -29,7 +29,7 @@ LIBGPGME=libgpgme.so.11
CC=gcc -std=c99
CFLAGS?=-I$(GPGME_IN)/include $(OPTIMIZE) -fPIC -pedantic \
-DSYSTEM_DB=\"$(SYSTEM_DB)\" -DLIBGPGME=\"$(LIBGPGME)\" \
-DSQLITE_THREADSAFE=1 -D_GNU_SOURCE
-DSQLITE_THREADSAFE=1 -D_GNU_SOURCE -I../asn.1
LDFLAGS?=-L$(GPGME_IN)/lib -shared -lc -ldl -letpan -lpthread -L../asn.1 -lasn1
else


+ 67
- 0
src/map_asn1.c View File

@ -0,0 +1,67 @@
#include "pEp_internal.h"
#include "map_asn1.h"
Identity_t *Identity_from_Struct(const pEp_identity *ident)
{
Identity_t *result = (Identity_t *) calloc(1, sizeof(Identity_t));
assert(result);
if (!result)
return NULL;
if (ident->address) {
result->address = OCTET_STRING_new_fromBuf(&asn_DEF_UTF8String,
ident->address, -1);
if (ident->address && !result->address)
goto enomem;
}
if (ident->fpr) {
if (OCTET_STRING_fromString(&result->fpr, ident->fpr))
goto enomem;
}
if (ident->user_id) {
result->user_id = OCTET_STRING_new_fromBuf(&asn_DEF_UTF8String,
ident->user_id, -1);
if (ident->user_id && !result->user_id)
goto enomem;
}
if (ident->username) {
result->username = OCTET_STRING_new_fromBuf(&asn_DEF_UTF8String,
ident->username, -1);
if (ident->username && !result->username)
goto enomem;
}
if (ident->comm_type != PEP_ct_unknown) {
result->comm_type = malloc(sizeof(long));
assert(result->comm_type);
if (!result->comm_type)
goto enomem;
*result->comm_type = ident->comm_type;
}
if (ident->lang[0]) {
result->lang = OCTET_STRING_new_fromBuf(&asn_DEF_ISO936_1,
ident->lang, 2);
if (!result->lang)
goto enomem;
}
return result;
enomem:
asn_DEF_UTF8String.free_struct(&asn_DEF_UTF8String, result, 0);
return NULL;
}
pEp_identity *Identity_to_Struct(Identity_t *ident)
{
pEp_identity *result = new_identity(NULL, NULL, NULL, NULL);
if (!result)
return NULL;
return result;
}

+ 8
- 0
src/map_asn1.h View File

@ -0,0 +1,8 @@
#pragma one
#include "pEpEngine.h"
#include "stringlist.h"
#include "../asn.1/Identity.h"
Identity_t *Identity_from_Struct(const pEp_identity *ident);
pEp_identity *Identity_to_Struct(Identity_t *ident);

Loading…
Cancel
Save