Added debug output
Signed-off-by: Tyrolyean <tyrolyean@tyrolyean.net>
This commit is contained in:
parent
92898dd5fd
commit
2648be10c2
3 changed files with 14 additions and 7 deletions
|
@ -20,11 +20,12 @@
|
||||||
|
|
||||||
#include "mail.h"
|
#include "mail.h"
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
char* insert_string(char * destination, const char* source,
|
char* insert_string(char * destination, const char* source,
|
||||||
size_t dest_orig_len, size_t offset);
|
size_t dest_orig_len, size_t offset);
|
||||||
|
|
||||||
void remove_string(char * string, size_t len, size_t offset, size_t remove);
|
bool remove_string(char * root, size_t len, size_t offset, size_t remove);
|
||||||
|
|
||||||
char* search_header_key(const struct email_t* mail, const char* key);
|
char* search_header_key(const struct email_t* mail, const char* key);
|
||||||
|
|
||||||
|
|
|
@ -137,8 +137,11 @@ int remove_mail(struct email_t* mail){
|
||||||
|
|
||||||
propagate_size_change(mail, -remove_len);
|
propagate_size_change(mail, -remove_len);
|
||||||
|
|
||||||
remove_string(root->message, root->message_length,
|
if(!remove_string(root->message, root->message_length,
|
||||||
remove_offset, remove_len);
|
remove_offset, remove_len)){
|
||||||
|
fprintf(stderr, "Unwilling to remove string from message!\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
propagate_insert_delete(root, root->message+remove_offset, -remove_len);
|
propagate_insert_delete(root, root->message+remove_offset, -remove_len);
|
||||||
|
|
||||||
|
|
11
src/tools.c
11
src/tools.c
|
@ -52,13 +52,16 @@ char* insert_string(char * destination, const char* source,
|
||||||
/* Takes a string string and removes from offset INCLUDING the character there
|
/* Takes a string string and removes from offset INCLUDING the character there
|
||||||
* the following remove bytes. Len is without the NULL-termination
|
* the following remove bytes. Len is without the NULL-termination
|
||||||
*/
|
*/
|
||||||
void remove_string(char * string, size_t len, size_t offset, size_t remove){
|
bool remove_string(char * root, size_t len, size_t offset, size_t remove){
|
||||||
|
|
||||||
|
if(remove+offset > len || root == NULL){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
memmove(string+offset, string+offset+remove, len - (offset+remove));
|
memmove(root+offset, root+offset+remove, len - (offset+remove));
|
||||||
string[len-remove] = 0;
|
root[len-remove] = 0;
|
||||||
|
|
||||||
return;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue