mirror of
https://bitbucket.org/jsuto/piler.git
synced 2024-12-25 20:10:11 +01:00
code cleanup
This commit is contained in:
parent
198f65d5ea
commit
dd83ee8fb1
@ -95,7 +95,7 @@ int addnode(struct node *xhash[], char *s){
|
|||||||
q = q->r;
|
q = q->r;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
p->r = makenewnode(xhash, s);
|
if(p) p->r = makenewnode(xhash, s);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
26
src/parser.c
26
src/parser.c
@ -83,7 +83,7 @@ struct parser_state parse_message(struct session_data *sdata, int take_into_piec
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(take_into_pieces == 1 && state.writebufpos > 0){
|
if(take_into_pieces == 1 && state.writebufpos > 0){
|
||||||
len = write(state.mfd, writebuffer, state.writebufpos);
|
write(state.mfd, writebuffer, state.writebufpos);
|
||||||
memset(writebuffer, 0, sizeof(writebuffer));
|
memset(writebuffer, 0, sizeof(writebuffer));
|
||||||
state.writebufpos = 0;
|
state.writebufpos = 0;
|
||||||
}
|
}
|
||||||
@ -241,10 +241,10 @@ int parse_line(char *buf, struct parser_state *state, struct session_data *sdata
|
|||||||
abuffer[state->abufpos] = '\0';
|
abuffer[state->abufpos] = '\0';
|
||||||
if(state->base64 == 1){
|
if(state->base64 == 1){
|
||||||
n64 = base64_decode_attachment_buffer(abuffer, state->abufpos, &b64buffer[0], sizeof(b64buffer));
|
n64 = base64_decode_attachment_buffer(abuffer, state->abufpos, &b64buffer[0], sizeof(b64buffer));
|
||||||
n64 = write(state->b64fd, b64buffer, n64);
|
write(state->b64fd, b64buffer, n64);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
n64 = write(state->b64fd, abuffer, state->abufpos);
|
write(state->b64fd, abuffer, state->abufpos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -578,10 +578,10 @@ int parse_line(char *buf, struct parser_state *state, struct session_data *sdata
|
|||||||
abuffer[state->abufpos] = '\0';
|
abuffer[state->abufpos] = '\0';
|
||||||
if(state->base64 == 1){
|
if(state->base64 == 1){
|
||||||
n64 = base64_decode_attachment_buffer(abuffer, state->abufpos, &b64buffer[0], sizeof(b64buffer));
|
n64 = base64_decode_attachment_buffer(abuffer, state->abufpos, &b64buffer[0], sizeof(b64buffer));
|
||||||
n64 = write(state->b64fd, b64buffer, n64);
|
write(state->b64fd, b64buffer, n64);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
n64 = write(state->b64fd, abuffer, state->abufpos);
|
write(state->b64fd, abuffer, state->abufpos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -677,15 +677,17 @@ int parse_line(char *buf, struct parser_state *state, struct session_data *sdata
|
|||||||
|
|
||||||
if(puf[0] == '\0') continue;
|
if(puf[0] == '\0') continue;
|
||||||
|
|
||||||
strncat(puf, " ", sizeof(puf)-1);
|
|
||||||
|
|
||||||
if(strncasecmp(puf, "http://", 7) == 0 || strncasecmp(puf, "https://", 8) == 0) fixURL(puf, sizeof(puf)-1);
|
|
||||||
|
|
||||||
if(state->is_header == 0 && strncmp(puf, "__URL__", 7) && (puf[0] == ' ' || (strlen(puf) > MAX_WORD_LEN && cfg->enable_cjk == 0) || isHexNumber(puf)) ) continue;
|
|
||||||
|
|
||||||
|
|
||||||
len = strlen(puf);
|
len = strlen(puf);
|
||||||
|
|
||||||
|
strncat(puf, " ", sizeof(puf)-len-1);
|
||||||
|
|
||||||
|
if(strncasecmp(puf, "http://", 7) == 0 || strncasecmp(puf, "https://", 8) == 0){
|
||||||
|
fixURL(puf, sizeof(puf)-1);
|
||||||
|
len = strlen(puf);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(state->is_header == 0 && strncmp(puf, "__URL__", 7) && (puf[0] == ' ' || (len > MAX_WORD_LEN && cfg->enable_cjk == 0) || isHexNumber(puf)) ) continue;
|
||||||
|
|
||||||
|
|
||||||
if(state->message_state == MSG_FROM && state->is_1st_header == 1 && strlen(state->b_from) < SMALLBUFSIZE-len-1){
|
if(state->message_state == MSG_FROM && state->is_1st_header == 1 && strlen(state->b_from) < SMALLBUFSIZE-len-1){
|
||||||
strtolower(puf);
|
strtolower(puf);
|
||||||
|
@ -127,7 +127,7 @@ static void child_main(struct child *ptr){
|
|||||||
|
|
||||||
ptr->status = BUSY;
|
ptr->status = BUSY;
|
||||||
|
|
||||||
inet_ntop(client_addr.ss_family, get_in_addr((struct sockaddr *)&client_addr), s, sizeof(s));
|
inet_ntop(client_addr.ss_family, get_in_addr((struct sockaddr *)&client_addr), s, sizeof(s)-1);
|
||||||
|
|
||||||
syslog(LOG_PRIORITY, "connection from %s", s);
|
syslog(LOG_PRIORITY, "connection from %s", s);
|
||||||
|
|
||||||
@ -453,7 +453,7 @@ int main(int argc, char **argv){
|
|||||||
|
|
||||||
|
|
||||||
#if HAVE_DAEMON == 1
|
#if HAVE_DAEMON == 1
|
||||||
if(daemonise == 1) i = daemon(1, 0);
|
if(daemonise == 1 && daemon(1, 0) == -1) fatal(ERR_DAEMON);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
write_pid_file(cfg.pidfile);
|
write_pid_file(cfg.pidfile);
|
||||||
|
@ -19,7 +19,7 @@ struct digest_test {
|
|||||||
|
|
||||||
|
|
||||||
struct digest_test tests[] = {
|
struct digest_test tests[] = {
|
||||||
{"1.eml", "63e4649b52c0fb45571b32aecc502234e6414abb36317eea25a1bd2f4e3cbe9e", "93e71b5f72d195f51333e261d57bffc9b27c95ef44bf6478090db3067571e242"},
|
{"1.eml", "b675536ea7ba16adf9b19ccc2ef60351c2f82b1fa7b92fb18569bd3ba753cc60", "bcd87663be92f688d9cccb62e6e0504ee3f7cdec8e5b7679f8724bacc3b0c57f"},
|
||||||
{"2.eml", "668cb3b91b944af786667323442576b9813d65f3cd3bc33e9d5da303c79de038", "de90475409dd6ab24e80c1b7a987715c40fe8d28d91337b7f063b477159c7b3c"},
|
{"2.eml", "668cb3b91b944af786667323442576b9813d65f3cd3bc33e9d5da303c79de038", "de90475409dd6ab24e80c1b7a987715c40fe8d28d91337b7f063b477159c7b3c"},
|
||||||
{"3.eml", "0d546d4cb4a8ce74ea5fd4cc51dbb4ebeaa7542f1c691817579da7eeab8d4771", "f585d011340d292ee52ddedb07cda662a8f1e46329d14a2ce92dca0604387bab"},
|
{"3.eml", "0d546d4cb4a8ce74ea5fd4cc51dbb4ebeaa7542f1c691817579da7eeab8d4771", "f585d011340d292ee52ddedb07cda662a8f1e46329d14a2ce92dca0604387bab"},
|
||||||
{"4.eml", "6008daed3613af4af71aa1f82550fd592d19c14c1aa7d8d5db2be1552174c518", "5f0744384bc3f96167380442c108c04a762313c79778c928ee5274981632ff45"},
|
{"4.eml", "6008daed3613af4af71aa1f82550fd592d19c14c1aa7d8d5db2be1552174c518", "5f0744384bc3f96167380442c108c04a762313c79778c928ee5274981632ff45"},
|
||||||
@ -56,7 +56,7 @@ static void test_digest_file(){
|
|||||||
|
|
||||||
for(i=0; i<sizeof(tests)/sizeof(struct digest_test); i++){
|
for(i=0; i<sizeof(tests)/sizeof(struct digest_test); i++){
|
||||||
digest_file(tests[i].s, &digest[0]);
|
digest_file(tests[i].s, &digest[0]);
|
||||||
assert(strcmp(digest, tests[i].digest2) == 0 && "test_digest_string()");
|
assert(strcmp(digest, tests[i].digest2) == 0 && "test_digest_file()");
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("test_digest_file() OK\n");
|
printf("test_digest_file() OK\n");
|
||||||
|
Loading…
Reference in New Issue
Block a user