Beispiel #1
0
static GString *gmime_message_to_json(GMimeMessage *message, guint content_option) {
  MessageData *mdata = convert_message(message, content_option);


  JSON_Value *root_value = json_value_init_object();
  JSON_Object *root_object = json_value_get_object(root_value);

  json_object_set_value(root_object,  "from",        addresses_list_to_json(mdata->from));
  json_object_set_value(root_object,  "to",          addresses_list_to_json(mdata->to));
  json_object_set_value(root_object,  "replyTo",     addresses_list_to_json(mdata->reply_to));
  json_object_set_value(root_object,  "cc",          addresses_list_to_json(mdata->cc));
  json_object_set_value(root_object,  "bcc",         addresses_list_to_json(mdata->bcc));
  json_object_set_string(root_object, "messageId",   mdata->message_id);
  json_object_set_string(root_object, "subject",     mdata->subject);
  json_object_set_string(root_object, "date",        mdata->date);

  json_object_set_value(root_object, "inReplyTo",   references_to_json(mdata->in_reply_to));
  json_object_set_value(root_object, "references",  references_to_json(mdata->references));

  json_object_set_value(root_object,  "text",        message_body_to_json(mdata->text));
  json_object_set_value(root_object,  "html",        message_body_to_json(mdata->html));
  json_object_set_value(root_object,  "attachments", message_attachments_list_to_json(mdata->attachments));

  free_message_data(mdata);
  gchar *serialized_string = json_serialize_to_string(root_value);
  json_value_free(root_value);

  GString *json_string = g_string_new(serialized_string);
  g_free(serialized_string);

  return json_string;
}
Beispiel #2
0
int print_task(void) {

    int size;
    TCB *tcb, *mtcb;
    void *strg;

/*return 0x1024;*/
printf("print_task.\n");
    tcb = get_current_task_tcb();
    while(1) {
        mtcb = receive_msg_sync(&strg, &size);
        printf("Message from 0x%08X (%d): \"%s\"\n.", 
                        (UINT)mtcb, size, (char *)strg);
        free_message_data(strg);
fprintf( stderr, ".");        
    }
    
    return 0;
}