code cleanup to make gcc 4.7.1 happy

This commit is contained in:
SJ 2012-11-03 23:42:36 +01:00
parent 8abe4c6d60
commit 5db07229f7
9 changed files with 23 additions and 29 deletions

View File

@ -43,7 +43,7 @@ piler: piler.c libpiler.a
libpiler.a: $(OBJS) $(MYSQL_OBJS) libpiler.a: $(OBJS) $(MYSQL_OBJS)
ar cr libpiler.a $(OBJS) $(MYSQL_OBJS) ar cr libpiler.a $(OBJS) $(MYSQL_OBJS)
ranlib libpiler.a ranlib libpiler.a
$(CC) -shared -Wl -o libpiler.so.$(LIBPILER_VERSION) $(OBJS) $(MYSQL_OBJS) $(CC) -shared -o libpiler.so.$(LIBPILER_VERSION) $(OBJS) $(MYSQL_OBJS)
ln -sf libpiler.so.$(LIBPILER_VERSION) libpiler.so ln -sf libpiler.so.$(LIBPILER_VERSION) libpiler.so
ln -sf libpiler.so.$(LIBPILER_VERSION) libpiler.so.$(PILER_VERSION) ln -sf libpiler.so.$(LIBPILER_VERSION) libpiler.so.$(PILER_VERSION)

View File

@ -203,7 +203,7 @@ CLEANUP:
int retrieve_email_from_archive(struct session_data *sdata, FILE *dest, struct __config *cfg){ int retrieve_email_from_archive(struct session_data *sdata, FILE *dest, struct __config *cfg){
int i, rc, n, attachments; int i, attachments;
char *buffer=NULL, *saved_buffer, *p, filename[SMALLBUFSIZE], pointer[SMALLBUFSIZE]; char *buffer=NULL, *saved_buffer, *p, filename[SMALLBUFSIZE], pointer[SMALLBUFSIZE];
struct ptr_array ptr_arr[MAX_ATTACHMENTS]; struct ptr_array ptr_arr[MAX_ATTACHMENTS];
@ -222,10 +222,10 @@ int retrieve_email_from_archive(struct session_data *sdata, FILE *dest, struct _
snprintf(filename, sizeof(filename)-1, "%s/%c%c/%c%c/%c%c/%s.m", cfg->queuedir, *(sdata->ttmpfile+RND_STR_LEN-6), *(sdata->ttmpfile+RND_STR_LEN-5), *(sdata->ttmpfile+RND_STR_LEN-4), *(sdata->ttmpfile+RND_STR_LEN-3), *(sdata->ttmpfile+RND_STR_LEN-2), *(sdata->ttmpfile+RND_STR_LEN-1), sdata->ttmpfile); snprintf(filename, sizeof(filename)-1, "%s/%c%c/%c%c/%c%c/%s.m", cfg->queuedir, *(sdata->ttmpfile+RND_STR_LEN-6), *(sdata->ttmpfile+RND_STR_LEN-5), *(sdata->ttmpfile+RND_STR_LEN-4), *(sdata->ttmpfile+RND_STR_LEN-3), *(sdata->ttmpfile+RND_STR_LEN-2), *(sdata->ttmpfile+RND_STR_LEN-1), sdata->ttmpfile);
if(attachments == 0){ if(attachments == 0){
rc = retrieve_file_from_archive(filename, WRITE_TO_STDOUT, &buffer, dest, cfg); retrieve_file_from_archive(filename, WRITE_TO_STDOUT, &buffer, dest, cfg);
} }
else { else {
rc = retrieve_file_from_archive(filename, WRITE_TO_BUFFER, &buffer, dest, cfg); retrieve_file_from_archive(filename, WRITE_TO_BUFFER, &buffer, dest, cfg);
if(buffer){ if(buffer){
saved_buffer = buffer; saved_buffer = buffer;
@ -236,20 +236,20 @@ int retrieve_email_from_archive(struct session_data *sdata, FILE *dest, struct _
p = strstr(buffer, pointer); p = strstr(buffer, pointer);
if(p){ if(p){
*p = '\0'; *p = '\0';
n = fwrite(buffer, 1, p - buffer, dest); fwrite(buffer, 1, p - buffer, dest);
buffer = p + strlen(pointer); buffer = p + strlen(pointer);
if(strlen(ptr_arr[i].piler_id) == RND_STR_LEN){ if(strlen(ptr_arr[i].piler_id) == RND_STR_LEN){
snprintf(filename, sizeof(filename)-1, "%s/%c%c/%c%c/%c%c/%s.a%d", cfg->queuedir, ptr_arr[i].piler_id[RND_STR_LEN-6], ptr_arr[i].piler_id[RND_STR_LEN-5], ptr_arr[i].piler_id[RND_STR_LEN-4], ptr_arr[i].piler_id[RND_STR_LEN-3], ptr_arr[i].piler_id[RND_STR_LEN-2], ptr_arr[i].piler_id[RND_STR_LEN-1], ptr_arr[i].piler_id, ptr_arr[i].attachment_id); snprintf(filename, sizeof(filename)-1, "%s/%c%c/%c%c/%c%c/%s.a%d", cfg->queuedir, ptr_arr[i].piler_id[RND_STR_LEN-6], ptr_arr[i].piler_id[RND_STR_LEN-5], ptr_arr[i].piler_id[RND_STR_LEN-4], ptr_arr[i].piler_id[RND_STR_LEN-3], ptr_arr[i].piler_id[RND_STR_LEN-2], ptr_arr[i].piler_id[RND_STR_LEN-1], ptr_arr[i].piler_id, ptr_arr[i].attachment_id);
rc = retrieve_file_from_archive(filename, WRITE_TO_STDOUT, NULL, dest, cfg); retrieve_file_from_archive(filename, WRITE_TO_STDOUT, NULL, dest, cfg);
} }
} }
} }
if(buffer){ if(buffer){
n = fwrite(buffer, 1, strlen(buffer), dest); fwrite(buffer, 1, strlen(buffer), dest);
} }
buffer = saved_buffer; buffer = saved_buffer;

View File

@ -47,14 +47,13 @@ void check_and_create_directories(struct __config *cfg, uid_t uid, gid_t gid){
void createdir(char *path, uid_t uid, gid_t gid, mode_t mode){ void createdir(char *path, uid_t uid, gid_t gid, mode_t mode){
struct stat st; struct stat st;
int rc;
if(strlen(path) > 2){ if(strlen(path) > 2){
if(path[strlen(path)-1] == '/') path[strlen(path)-1] = '\0'; if(path[strlen(path)-1] == '/') path[strlen(path)-1] = '\0';
if(stat(path, &st)){ if(stat(path, &st)){
if(mkdir(path, mode) == 0){ if(mkdir(path, mode) == 0){
rc = chown(path, uid, gid); chown(path, uid, gid);
syslog(LOG_PRIORITY, "created directory: *%s*", path); syslog(LOG_PRIORITY, "created directory: *%s*", path);
} }
else syslog(LOG_PRIORITY, "could not create directory: *%s*", path); else syslog(LOG_PRIORITY, "could not create directory: *%s*", path);

View File

@ -318,7 +318,6 @@ void close_connection(int sd, struct __data *data, int use_ssl){
int list_folders(int sd, int *seq, char *folders, int foldersize, int use_ssl, struct __data *data){ int list_folders(int sd, int *seq, char *folders, int foldersize, int use_ssl, struct __data *data){
int n;
char *p, *q, tag[SMALLBUFSIZE], tagok[SMALLBUFSIZE], buf[MAXBUFSIZE], puf[MAXBUFSIZE]; char *p, *q, tag[SMALLBUFSIZE], tagok[SMALLBUFSIZE], buf[MAXBUFSIZE], puf[MAXBUFSIZE];
snprintf(tag, sizeof(tag)-1, "A%d", *seq); snprintf(tagok, sizeof(tagok)-1, "A%d OK", (*seq)++); snprintf(tag, sizeof(tag)-1, "A%d", *seq); snprintf(tagok, sizeof(tagok)-1, "A%d OK", (*seq)++);
@ -327,7 +326,7 @@ int list_folders(int sd, int *seq, char *folders, int foldersize, int use_ssl, s
write1(sd, buf, use_ssl, data->ssl); write1(sd, buf, use_ssl, data->ssl);
n = recvtimeoutssl(sd, buf, sizeof(buf), 10, use_ssl, data->ssl); recvtimeoutssl(sd, buf, sizeof(buf), 10, use_ssl, data->ssl);
p = &buf[0]; p = &buf[0];
do { do {

View File

@ -286,13 +286,12 @@ int memcached_increment(struct memcached_server *ptr, char *key, unsigned int ke
char *memcached_get(struct memcached_server *ptr, char *key, unsigned int *len, unsigned int *flags){ char *memcached_get(struct memcached_server *ptr, char *key, unsigned int *len, unsigned int *flags){
int rc;
char *p; char *p;
if(memcached_connect(ptr) != MEMCACHED_SUCCESS) return NULL; if(memcached_connect(ptr) != MEMCACHED_SUCCESS) return NULL;
snprintf(ptr->buf, MAXBUFSIZE, "get %s \r\n", key); snprintf(ptr->buf, MAXBUFSIZE, "get %s \r\n", key);
rc = send(ptr->fd, ptr->buf, strlen(ptr->buf), 0); send(ptr->fd, ptr->buf, strlen(ptr->buf), 0);
ptr->last_read_bytes = __recvtimeout(ptr->fd, ptr->buf, MAXBUFSIZE, ptr->rcv_timeout); ptr->last_read_bytes = __recvtimeout(ptr->fd, ptr->buf, MAXBUFSIZE, ptr->rcv_timeout);
@ -333,12 +332,11 @@ char *memcached_get(struct memcached_server *ptr, char *key, unsigned int *len,
int memcached_mget(struct memcached_server *ptr, char *key){ int memcached_mget(struct memcached_server *ptr, char *key){
int rc;
if(memcached_connect(ptr) != MEMCACHED_SUCCESS) return MEMCACHED_FAILURE; if(memcached_connect(ptr) != MEMCACHED_SUCCESS) return MEMCACHED_FAILURE;
snprintf(ptr->buf, MAXBUFSIZE, "get %s \r\n", key); snprintf(ptr->buf, MAXBUFSIZE, "get %s \r\n", key);
rc = send(ptr->fd, ptr->buf, strlen(ptr->buf), 0); send(ptr->fd, ptr->buf, strlen(ptr->buf), 0);
ptr->last_read_bytes = __recvtimeout(ptr->fd, ptr->buf, MAXBUFSIZE, ptr->rcv_timeout); ptr->last_read_bytes = __recvtimeout(ptr->fd, ptr->buf, MAXBUFSIZE, ptr->rcv_timeout);

View File

@ -178,7 +178,7 @@ void storno_attachment(struct _state *state){
int parse_line(char *buf, struct _state *state, struct session_data *sdata, int take_into_pieces, char *writebuffer, int writebuffersize, char *abuffer, int abuffersize, struct __config *cfg){ int parse_line(char *buf, struct _state *state, struct session_data *sdata, int take_into_pieces, char *writebuffer, int writebuffersize, char *abuffer, int abuffersize, struct __config *cfg){
char *p, *q, puf[SMALLBUFSIZE]; char *p, *q, puf[SMALLBUFSIZE];
unsigned char b64buffer[MAXBUFSIZE]; unsigned char b64buffer[MAXBUFSIZE];
int t, x, n, n64, len, writelen, b64_len, boundary_line=0; int t, n64, len, writelen, boundary_line=0;
if(cfg->debug == 1) printf("line: %s", buf); if(cfg->debug == 1) printf("line: %s", buf);
@ -226,7 +226,7 @@ int parse_line(char *buf, struct _state *state, struct session_data *sdata, int
if(state->message_state == MSG_BODY && state->fd != -1 && is_item_on_string(state->boundaries, buf) == 0){ if(state->message_state == MSG_BODY && state->fd != -1 && is_item_on_string(state->boundaries, buf) == 0){
//n = write(state->fd, buf, len); // WRITE //n = write(state->fd, buf, len); // WRITE
if(len + state->abufpos > abuffersize-1){ if(len + state->abufpos > abuffersize-1){
n = write(state->fd, abuffer, state->abufpos); write(state->fd, abuffer, state->abufpos);
if(state->b64fd != -1){ if(state->b64fd != -1){
abuffer[state->abufpos] = '\0'; abuffer[state->abufpos] = '\0';
@ -245,7 +245,7 @@ int parse_line(char *buf, struct _state *state, struct session_data *sdata, int
//n = write(state->mfd, buf, len); // WRITE //n = write(state->mfd, buf, len); // WRITE
if(len + state->writebufpos > writebuffersize-1){ if(len + state->writebufpos > writebuffersize-1){
if(sdata->ms_journal == 1) remove_trailing_journal_boundary(sdata, state, writebuffer); if(sdata->ms_journal == 1) remove_trailing_journal_boundary(sdata, state, writebuffer);
n = write(state->mfd, writebuffer, state->writebufpos); state->writebufpos = 0; memset(writebuffer, 0, writebuffersize); write(state->mfd, writebuffer, state->writebufpos); state->writebufpos = 0; memset(writebuffer, 0, writebuffersize);
} }
memcpy(writebuffer+state->writebufpos, buf, len); state->writebufpos += len; memcpy(writebuffer+state->writebufpos, buf, len); state->writebufpos += len;
} }
@ -292,7 +292,7 @@ int parse_line(char *buf, struct _state *state, struct session_data *sdata, int
//n = write(state->mfd, puf, strlen(puf)); // WRITE //n = write(state->mfd, puf, strlen(puf)); // WRITE
writelen = strlen(puf); writelen = strlen(puf);
if(writelen + state->writebufpos > writebuffersize-1){ if(writelen + state->writebufpos > writebuffersize-1){
n = write(state->mfd, writebuffer, state->writebufpos); state->writebufpos = 0; memset(writebuffer, 0, writebuffersize); write(state->mfd, writebuffer, state->writebufpos); state->writebufpos = 0; memset(writebuffer, 0, writebuffersize);
} }
memcpy(writebuffer+state->writebufpos, puf, writelen); state->writebufpos += writelen; memcpy(writebuffer+state->writebufpos, puf, writelen); state->writebufpos += writelen;
} }
@ -363,7 +363,7 @@ int parse_line(char *buf, struct _state *state, struct session_data *sdata, int
if((p = strcasestr(buf, "boundary"))){ if((p = strcasestr(buf, "boundary"))){
x = extract_boundary(p, state); extract_boundary(p, state);
} }
@ -497,7 +497,7 @@ int parse_line(char *buf, struct _state *state, struct session_data *sdata, int
if(state->has_to_dump == 1){ if(state->has_to_dump == 1){
if(take_into_pieces == 1 && state->fd != -1){ if(take_into_pieces == 1 && state->fd != -1){
if(state->abufpos > 0){ if(state->abufpos > 0){
n = write(state->fd, abuffer, state->abufpos); write(state->fd, abuffer, state->abufpos);
if(state->b64fd != -1){ if(state->b64fd != -1){
abuffer[state->abufpos] = '\0'; abuffer[state->abufpos] = '\0';
@ -549,7 +549,7 @@ int parse_line(char *buf, struct _state *state, struct session_data *sdata, int
if(state->base64 == 1 && state->message_state == MSG_BODY){ if(state->base64 == 1 && state->message_state == MSG_BODY){
b64_len = decodeBase64(buf); decodeBase64(buf);
fixupBase64EncodedLine(buf, state); fixupBase64EncodedLine(buf, state);
} }

View File

@ -17,7 +17,7 @@
int main(int argc, char **argv){ int main(int argc, char **argv){
int rc, readkey=1; int readkey=1;
char filename[SMALLBUFSIZE]; char filename[SMALLBUFSIZE];
struct __config cfg; struct __config cfg;
@ -45,7 +45,7 @@ int main(int argc, char **argv){
snprintf(filename, sizeof(filename)-1, "%s/%c%c/%c%c/%c%c/%s.a%d", cfg.queuedir, argv[1][RND_STR_LEN-6], argv[1][RND_STR_LEN-5], argv[1][RND_STR_LEN-4], argv[1][RND_STR_LEN-3], argv[1][RND_STR_LEN-2], argv[1][RND_STR_LEN-1], argv[1], atoi(argv[2])); snprintf(filename, sizeof(filename)-1, "%s/%c%c/%c%c/%c%c/%s.a%d", cfg.queuedir, argv[1][RND_STR_LEN-6], argv[1][RND_STR_LEN-5], argv[1][RND_STR_LEN-4], argv[1][RND_STR_LEN-3], argv[1][RND_STR_LEN-2], argv[1][RND_STR_LEN-1], argv[1], atoi(argv[2]));
rc = retrieve_file_from_archive(filename, WRITE_TO_STDOUT, NULL, stdout, &cfg); retrieve_file_from_archive(filename, WRITE_TO_STDOUT, NULL, stdout, &cfg);
return 0; return 0;
} }

View File

@ -17,7 +17,7 @@
int main(int argc, char **argv){ int main(int argc, char **argv){
int rc, readkey=1; int readkey=1;
struct session_data sdata; struct session_data sdata;
struct __config cfg; struct __config cfg;
@ -52,7 +52,7 @@ int main(int argc, char **argv){
snprintf(sdata.ttmpfile, SMALLBUFSIZE-1, "%s", argv[1]); snprintf(sdata.ttmpfile, SMALLBUFSIZE-1, "%s", argv[1]);
snprintf(sdata.filename, SMALLBUFSIZE-1, "%s", sdata.ttmpfile); snprintf(sdata.filename, SMALLBUFSIZE-1, "%s", sdata.ttmpfile);
rc = retrieve_email_from_archive(&sdata, stdout, &cfg); retrieve_email_from_archive(&sdata, stdout, &cfg);
mysql_close(&(sdata.mysql)); mysql_close(&(sdata.mysql));

View File

@ -16,7 +16,7 @@
int main(int argc, char **argv){ int main(int argc, char **argv){
int i, rc; int i;
struct stat st; struct stat st;
struct session_data sdata; struct session_data sdata;
struct _state state; struct _state state;
@ -60,8 +60,6 @@ int main(int argc, char **argv){
load_rules(&sdata, &(data.archiving_rules), SQL_ARCHIVING_RULE_TABLE); load_rules(&sdata, &(data.archiving_rules), SQL_ARCHIVING_RULE_TABLE);
load_rules(&sdata, &(data.retention_rules), SQL_RETENTION_RULE_TABLE); load_rules(&sdata, &(data.retention_rules), SQL_RETENTION_RULE_TABLE);
rc = 0;
init_session_data(&sdata); init_session_data(&sdata);
sdata.sent = 0; sdata.sent = 0;