parent
34eb37e362
commit
f38e204f07
@ -1 +1 @@
|
||||
Subproject commit 89205ae198eb90c631eb3d00b836f5d89b3c7f81
|
||||
Subproject commit 5c5b389508bddffd603124a6f6abfdfb934ce598
|
@ -1,18 +1,74 @@
|
||||
#define _GNU_SOURCE
|
||||
#include "rsa_signature_2017.h"
|
||||
#include "model/ap/activity.h"
|
||||
|
||||
#include "rdf/serial.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
|
||||
extern struct rdf_enum_item ap_activity_type_enum[0];
|
||||
static char* type_filter( const char* name )
|
||||
{
|
||||
char* res;
|
||||
asprintf( &res, "<https://www.w3.org/ns/activitystreams#%s>", name );
|
||||
return res;
|
||||
}
|
||||
struct rdf_enum types = {
|
||||
.items = ap_activity_type_enum,
|
||||
.filter = type_filter,
|
||||
};
|
||||
|
||||
struct rdf_serialize_field serial[];
|
||||
|
||||
static struct rdf_serialize_field activity_ref_types[] = {
|
||||
{ (char*)apaot_ref, offsetof( struct ap_activity, object.ref ), &rdf_string_field },
|
||||
{ (char*)apaot_activity, offsetof( struct ap_activity, object.ptr ), &rdf_object_field, &serial },
|
||||
{ NULL },
|
||||
};
|
||||
|
||||
struct rdf_serialize_field serial[] = {
|
||||
{ "", offsetof( struct ap_activity, id ), &rdf_id_field },
|
||||
{ "<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>", offsetof( struct ap_activity, type ), &rdf_enum_field, &types },
|
||||
{ "<https://www.w3.org/ns/activitystreams#actor>", offsetof( struct ap_activity, actor ), &rdf_string_field },
|
||||
{ "<https://www.w3.org/ns/activitystreams#to>", offsetof( struct ap_activity, to ), &rdf_array_of_field, &rdf_string_field },
|
||||
{ "<https://www.w3.org/ns/activitystreams#cc>", offsetof( struct ap_activity, cc ), &rdf_array_of_field, &rdf_string_field },
|
||||
{ "<https://www.w3.org/ns/activitystreams#bcc>", offsetof( struct ap_activity, bcc ), &rdf_array_of_field, &rdf_string_field },
|
||||
{ "<https://www.w3.org/ns/activitystreams#object>", offsetof( struct ap_activity, object.tag ), &rdf_tagged_union_field, activity_ref_types },
|
||||
{ NULL, sizeof(struct ap_activity) },
|
||||
};
|
||||
|
||||
void debug_emit_quad( struct rdf_serializer* rs, struct rdf_quad* q )
|
||||
{
|
||||
printf( "%s %s %s %s\n", q->subject, q->predicate, q->object, q->graph );
|
||||
|
||||
free(q->subject);
|
||||
free(q->predicate);
|
||||
free(q->object);
|
||||
free(q->graph);
|
||||
free(q);
|
||||
}
|
||||
|
||||
void ap_activity_create_rsa_signature_2017( struct ap_activity* act )
|
||||
{
|
||||
printf( "ap_activity_create_rsa_signature_2017\n" );
|
||||
struct rdf_serializer rs;
|
||||
memset(&rs,0,sizeof(rs));
|
||||
rs.object = strdup(act->id);
|
||||
char* subject;
|
||||
asprintf( &subject, "<%s>", act->id );
|
||||
rs.subject = subject;
|
||||
rs.graph = strdup(".");
|
||||
rs.emit_quad = debug_emit_quad;
|
||||
|
||||
rdf_serialize_object( &rs, NULL, act );
|
||||
printf( "\nRDF:\n" );
|
||||
rdf_serialize_object( &rs, serial, act );
|
||||
printf( "\n" );
|
||||
|
||||
cleanup:
|
||||
free((char*)rs.subject);
|
||||
free((char*)rs.graph);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 7016057c53d9dc123a474e63ddc171e4ae4855ea
|
||||
Subproject commit 9e72859052e1fd9191ec7a55498f75a1820d55a1
|
Loading…
Reference in new issue