mirror of
https://bitbucket.org/jsuto/piler.git
synced 2024-12-25 06:10:12 +01:00
added a new utility: pileraget to retrieve attachments
This commit is contained in:
parent
040394ec69
commit
9adee38fbd
@ -33,7 +33,7 @@ MAKE = `which make`
|
||||
|
||||
INSTALL = @INSTALL@
|
||||
|
||||
all: libpiler.a piler pilerconf pilerget pilerimport pilerexport pilerpurge reindex test
|
||||
all: libpiler.a piler pilerconf pilerget pileraget pilerimport pilerexport pilerpurge reindex test
|
||||
install: install-piler
|
||||
|
||||
|
||||
@ -51,6 +51,9 @@ libpiler.a: $(OBJS) $(MYSQL_OBJS)
|
||||
pilerget: pilerget.c libpiler.a
|
||||
$(CC) $(CFLAGS) $(INCDIR) $(DEFS) -o $@ $< -lpiler $(LIBS) $(LIBDIR)
|
||||
|
||||
pileraget: pileraget.c libpiler.a
|
||||
$(CC) $(CFLAGS) $(INCDIR) $(DEFS) -o $@ $< -lpiler $(LIBS) $(LIBDIR)
|
||||
|
||||
pilerimport: pilerimport.c libpiler.a
|
||||
$(CC) $(CFLAGS) $(INCDIR) $(DEFS) -o $@ $< -lpiler $(LIBS) $(LIBDIR)
|
||||
|
||||
@ -82,13 +85,14 @@ install-piler:
|
||||
$(INSTALL) -m 0755 piler $(DESTDIR)$(sbindir)
|
||||
$(INSTALL) -m 0755 pilerconf $(DESTDIR)$(sbindir)
|
||||
$(INSTALL) -m 6755 -o $(RUNNING_USER) -g $(RUNNING_GROUP) pilerget $(DESTDIR)$(bindir)
|
||||
$(INSTALL) -m 6755 -o $(RUNNING_USER) -g $(RUNNING_GROUP) pileraget $(DESTDIR)$(bindir)
|
||||
$(INSTALL) -m 6755 -o $(RUNNING_USER) -g $(RUNNING_GROUP) pilerimport $(DESTDIR)$(bindir)
|
||||
$(INSTALL) -m 6755 -o $(RUNNING_USER) -g $(RUNNING_GROUP) pilerexport $(DESTDIR)$(bindir)
|
||||
$(INSTALL) -m 6755 -o $(RUNNING_USER) -g $(RUNNING_GROUP) pilerpurge $(DESTDIR)$(bindir)
|
||||
$(INSTALL) -m 6755 -o $(RUNNING_USER) -g $(RUNNING_GROUP) reindex $(DESTDIR)$(bindir)
|
||||
|
||||
clean:
|
||||
rm -f *.o *.a libpiler.so* piler pilerconf pilerget pilerimport pilerexport pilerpurge pilertest reindex
|
||||
rm -f *.o *.a libpiler.so* piler pilerconf pilerget pileraget pilerimport pilerexport pilerpurge pilertest reindex
|
||||
|
||||
distclean: clean
|
||||
rm -f Makefile
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
#define VERSION "0.1.21"
|
||||
|
||||
#define BUILD 712
|
||||
#define BUILD 713
|
||||
|
||||
#define HOSTID "mailarchiver"
|
||||
|
||||
|
53
src/pileraget.c
Normal file
53
src/pileraget.c
Normal file
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* pileraget.c, SJ
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <time.h>
|
||||
#include <locale.h>
|
||||
#include <syslog.h>
|
||||
#include <piler.h>
|
||||
|
||||
|
||||
int main(int argc, char **argv){
|
||||
int rc, readkey=1;
|
||||
char filename[SMALLBUFSIZE];
|
||||
struct __config cfg;
|
||||
|
||||
|
||||
if(argc < 3){
|
||||
printf("usage: %s <piler-id> <attachment-id>\n", argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
cfg = read_config(CONFIG_FILE);
|
||||
|
||||
if(argc >= 4) readkey = 0;
|
||||
|
||||
if(readkey == 1 && read_key(&cfg)){
|
||||
printf("%s\n", ERR_READING_KEY);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
if(strlen(argv[1]) != RND_STR_LEN){
|
||||
printf("invalid piler id: '%s'\n", argv[1]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user