output of meshms thread list now conforms to cli_* interface.

This commit is contained in:
gardners 2013-05-09 21:07:42 +09:30
parent 32d33255fd
commit 82dc45f511
3 changed files with 26 additions and 17 deletions

View File

@ -286,7 +286,7 @@ int app_meshms_read_messagelog(const struct cli_parsed *parsed, void *context)
ret = meshms_read_message(m,buffer_file);
//hex_dump(buffer_file,buffer_length);
int offset_buffer = 0;
ret = deserialize_meshms(buffer_file,&offset_buffer,buffer_length);
ret = deserialize_meshms(buffer_file,&offset_buffer,buffer_length,"unknown");
@ -433,16 +433,26 @@ int app_meshms_list_messages(const struct cli_parsed *parsed, void *context)
}
// Display list of messages in reverse order
const char *names[]={
"offset",
"length",
"sender",
"recipient",
"date",
"delivery_status",
"message"
};
cli_columns(7, names);
int i;
for(i=message_count-1;i>=0;i--)
{
DEBUGF("%s : %s : 0x%08x",
sides[i]?"right":" left",
sides[i]?"Received":((offsets[i]<right_ack_limit)?"Delivered":"Delivery not yet acknowledged"),
offsets[i]);
char *delivery_status
=sides[i]?"received":
((offsets[i]<right_ack_limit)?"delivered":"unacknowledged");
int boffset=offsets[i];
deserialize_meshms(sides[i]?right_messages:left_messages,&boffset,
sides[i]?right_len:left_len);
sides[i]?right_len:left_len,delivery_status);
}
return 0;

View File

@ -698,7 +698,7 @@ int rhizome_dump_file(const char *id, const char *filepath, int64_t *length);
int rhizome_database_filehash_from_id(const char *id, uint64_t version, char hash[SHA512_DIGEST_STRING_LENGTH]);
int serialize_meshms(unsigned char *buffer,int *offset,unsigned int length,const char *sender_did,const char *recipient_did, unsigned long long time, const char *payload, int payload_length);
int deserialize_meshms(unsigned char *buffer,int *offset, int buffer_size);
int deserialize_meshms(unsigned char *buffer,int *offset, int buffer_size,char *delivery_status);
int rhizome_meshms_find_conversation(const char *sender_sid,
const char *recipient_sid,
char *manifest_id, int offset);

View File

@ -263,12 +263,9 @@ int deserialize_ack(unsigned char *buffer,int *offset, int buffer_size,
return 0;
}
int deserialize_meshms(unsigned char *buffer,int *offset, int buffer_size)
int deserialize_meshms(unsigned char *buffer,int *offset, int buffer_size,
char *delivery_status)
{
cli_delim("\n");
cli_puts("offset|length|sender|recipient|date|message");cli_delim("\n");
int ret = 0;
int i=0;
@ -276,12 +273,12 @@ int deserialize_meshms(unsigned char *buffer,int *offset, int buffer_size)
unsigned int start_offset=*offset;
cli_printf("%d",*offset);cli_puts("|");
cli_printf("%d",*offset); cli_delim(":");
int length_length=*offset;
decode_length_forwards(buffer,offset,buffer_size,&length);
length_length=(*offset)-length_length;
cli_printf("%d",length);cli_puts("|");
cli_printf("%d",length); cli_delim(":");
unsigned char block_type=buffer[(*offset)++];
if (block_type!=RHIZOME_MESHMS_BLOCK_TYPE_MESSAGE) {
@ -292,15 +289,17 @@ int deserialize_meshms(unsigned char *buffer,int *offset, int buffer_size)
char sender_did_out[64];
unpack_did(buffer,offset,sender_did_out);
cli_printf("%s",sender_did_out);cli_puts("|");
cli_printf("%s",sender_did_out); cli_delim(":");
char recipient_did_out[64];
unpack_did(buffer,offset,recipient_did_out);
cli_printf("%s",recipient_did_out);cli_puts("|");
cli_printf("%s",recipient_did_out); cli_delim(":");
unsigned long long time = 0;
unpack_time(buffer,offset,&time);
cli_printf("%lld",time);cli_puts("|");
cli_printf("%lld",time); cli_delim(":");
cli_printf("%s",delivery_status); cli_delim(":");
int j=0;
int payload_end=start_offset+length-length_length;