
2002-11-11 Jeffrey Stedfast <fejj@ximian.com> * providers/local/camel-spool-summary.c (spool_summary_sync_full): Use g_strerror when setting an exception string (we need it to be in UTF-8). (spool_summary_check): Here too. * providers/local/camel-spool-store.c (construct): Use g_strerror when setting an exception string (we need it to be in UTF-8). (get_folder): Same. (scan_dir): Here too. * providers/local/camel-spool-folder.c (spool_lock): Use g_strerror when setting an exception string (we need it to be in UTF-8). * providers/local/camel-mh-summary.c (mh_summary_check): Use g_strerror when setting an exception string (we need it to be in UTF-8). * providers/local/camel-mh-store.c (delete_folder): Use g_strerror when setting an exception string (we need it to be in UTF-8). * providers/local/camel-mbox-summary.c (summary_update): Use g_strerror when setting an exception string (we need it to be in UTF-8). (mbox_summary_sync_full): Here too. (mbox_summary_sync_quick): Same. (mbox_summary_sync): Also here. (camel_mbox_summary_sync_mbox): Again here. * providers/local/camel-mbox-folder.c (mbox_lock): Use g_strerror when setting an exception string (we need it to be in UTF-8). (mbox_append_message): Same. (mbox_get_message): Here too. * providers/local/camel-maildir-summary.c (maildir_summary_load): Use g_strerror when setting an exception string (we need it to be in UTF-8). (maildir_summary_check): Same. * providers/local/camel-maildir-store.c (get_folder): Use g_strerror when setting an exception string (we need it to be in UTF-8). (delete_folder): Same. (delete_folder): Here too. * providers/local/camel-local-summary.c (local_summary_sync): Use g_strerror when setting an exception string (we need it to be in UTF-8). * providers/local/camel-local-store.c (get_folder): Use g_strerror when setting an exception string (we need it to be in UTF-8). (create_folder): Same. (xrename): Here too. (rename_folder): And here. (delete_folder): Also here. * camel-provider.c (camel_provider_init): For debugging printfs, we want to use normal strerror (we want locale charset, not UTF-8). * camel-movemail.c (camel_movemail): Use g_strerror when setting an exception string (we need it to be in UTF-8). (movemail_external): Same. (camel_movemail_copy_file): Here too. (camel_movemail_solaris): Also here. * camel-mime-utils.c (rfc2047_decode_word): For debugging printfs, we want to use normal strerror (we want locale charset, not UTF-8). (header_encode_param): Same. * camel-mime-part-utils.c (convert_buffer): For debugging printfs, we want to use normal strerror (we want locale charset, not UTF-8). * camel-lock-client.c (camel_lock_helper_init): Use g_strerror when setting an exception string (we need it to be in UTF-8). * camel-data-cache.c (camel_data_cache_remove): Use g_strerror when setting an exception string (we need it to be in UTF-8). * camel-tcp-stream-raw.c (flaky_tcp_write): For debugging printfs, we want to use normal strerror (we want locale charset, not UTF-8). (flaky_tcp_read): Same. * camel-gpg-context.c (gpg_ctx_op_step): For debugging printfs, we want to use normal strerror (we want locale charset, not UTF-8). * camel-service.c (camel_gethostbyname): Use g_strerror when setting an exception string (we need it to be in UTF-8). * camel-lock.c (camel_lock_dot): Use g_strerror when setting an exception string (we need it to be in UTF-8). (camel_lock_fcntl): Same. svn path=/trunk/; revision=18689
212 lines
4.6 KiB
C
212 lines
4.6 KiB
C
|
|
/* Command to manually force a compression/dump of an index file */
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
#include <config.h>
|
|
#endif
|
|
|
|
#include <ctype.h>
|
|
#include <sys/stat.h>
|
|
#include <sys/uio.h>
|
|
#include <unistd.h>
|
|
#include <errno.h>
|
|
#include <string.h>
|
|
#include <stdlib.h>
|
|
|
|
#include <sys/types.h>
|
|
#include <sys/stat.h>
|
|
#include <fcntl.h>
|
|
|
|
#include "e-util/e-msgport.h"
|
|
#include "e-util/e-memory.h"
|
|
|
|
#include "camel/camel-object.h"
|
|
|
|
#include "camel-text-index.h"
|
|
|
|
#include <stdio.h>
|
|
|
|
static void
|
|
do_usage(char *argv0)
|
|
{
|
|
fprintf(stderr, "Usage: %s [ compress | dump | info ] file(s) ...\n", argv0);
|
|
fprintf(stderr, " compress - compress (an) index file(s)\n");
|
|
fprintf(stderr, " dump - dump (an) index file's content to stdout\n");
|
|
fprintf(stderr, " info - dump summary info to stdout\n");
|
|
exit(1);
|
|
}
|
|
|
|
static int
|
|
do_compress(int argc, char **argv)
|
|
{
|
|
int i;
|
|
CamelIndex *idx;
|
|
|
|
for (i=2;i<argc;i++) {
|
|
printf("Opening index file: %s\n", argv[i]);
|
|
idx = (CamelIndex *)camel_text_index_new(argv[i], O_RDWR);
|
|
if (idx) {
|
|
printf(" Compressing ...\n");
|
|
if (camel_index_compress(idx) == -1) {
|
|
camel_object_unref((CamelObject *)idx);
|
|
return 1;
|
|
}
|
|
camel_object_unref((CamelObject *)idx);
|
|
} else {
|
|
printf(" Failed: %s\n", strerror (errno));
|
|
return 1;
|
|
}
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
static int
|
|
do_dump(int argc, char **argv)
|
|
{
|
|
int i;
|
|
CamelIndex *idx;
|
|
|
|
for (i=2;i<argc;i++) {
|
|
printf("Opening index file: %s\n", argv[i]);
|
|
idx = (CamelIndex *)camel_text_index_new(argv[i], O_RDONLY);
|
|
if (idx) {
|
|
printf(" Dumping ...\n");
|
|
camel_text_index_dump((CamelTextIndex *)idx);
|
|
camel_object_unref((CamelObject *)idx);
|
|
} else {
|
|
printf(" Failed: %s\n", strerror (errno));
|
|
return 1;
|
|
}
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
static int
|
|
do_info(int argc, char **argv)
|
|
{
|
|
int i;
|
|
CamelIndex *idx;
|
|
|
|
for (i=2;i<argc;i++) {
|
|
printf("Opening index file: %s\n", argv[i]);
|
|
idx = (CamelIndex *)camel_text_index_new(argv[i], O_RDONLY);
|
|
if (idx) {
|
|
camel_text_index_info((CamelTextIndex *)idx);
|
|
camel_object_unref((CamelObject *)idx);
|
|
} else {
|
|
printf(" Failed: %s\n", strerror (errno));
|
|
return 0;
|
|
}
|
|
}
|
|
return 1;
|
|
}
|
|
|
|
static int
|
|
do_check(int argc, char **argv)
|
|
{
|
|
int i;
|
|
CamelIndex *idx;
|
|
|
|
for (i=2;i<argc;i++) {
|
|
printf("Opening index file: %s\n", argv[i]);
|
|
idx = (CamelIndex *)camel_text_index_new(argv[i], O_RDONLY);
|
|
if (idx) {
|
|
camel_text_index_validate((CamelTextIndex *)idx);
|
|
camel_object_unref((CamelObject *)idx);
|
|
} else {
|
|
printf(" Failed: %s\n", strerror (errno));
|
|
return 0;
|
|
}
|
|
}
|
|
return 1;
|
|
}
|
|
|
|
static int do_perf(int argc, char **argv);
|
|
|
|
int main(int argc, char **argv)
|
|
{
|
|
if (argc<2)
|
|
do_usage(argv[0]);
|
|
|
|
g_thread_init(NULL);
|
|
camel_init(NULL, 0);
|
|
|
|
if (!strcmp(argv[1], "compress"))
|
|
return do_compress(argc, argv);
|
|
else if (!strcmp(argv[1], "dump"))
|
|
return do_dump(argc, argv);
|
|
else if (!strcmp(argv[1], "info"))
|
|
return do_info(argc, argv);
|
|
else if (!strcmp(argv[1], "check"))
|
|
return do_check(argc, argv);
|
|
else if (!strcmp(argv[1], "perf"))
|
|
return do_perf(argc, argv);
|
|
|
|
do_usage(argv[0]);
|
|
return 1;
|
|
}
|
|
|
|
#include <sys/types.h>
|
|
#include <dirent.h>
|
|
#include "camel-stream-null.h"
|
|
#include "camel-stream-filter.h"
|
|
#include "camel-mime-filter-index.h"
|
|
#include "camel-stream-fs.h"
|
|
|
|
static int
|
|
do_perf(int argc, char **argv)
|
|
{
|
|
CamelIndex *idx;
|
|
DIR *dir;
|
|
char *path = "/home/notzed/evolution/local/Inbox/mbox/cur";
|
|
struct dirent *d;
|
|
CamelStream *null, *filter, *stream;
|
|
CamelMimeFilterIndex *filter_index;
|
|
char *name;
|
|
CamelIndexName *idn;
|
|
|
|
dir = opendir(path);
|
|
if (dir == NULL) {
|
|
perror("open dir");
|
|
return 1;
|
|
}
|
|
|
|
idx = (CamelIndex *)camel_text_index_new("/tmp/index", O_TRUNC|O_CREAT|O_RDWR);
|
|
if (idx == NULL) {
|
|
perror("open index");
|
|
return 1;
|
|
}
|
|
|
|
null = camel_stream_null_new();
|
|
filter = (CamelStream *)camel_stream_filter_new_with_stream(null);
|
|
camel_object_unref((CamelObject *)null);
|
|
filter_index = camel_mime_filter_index_new_index(idx);
|
|
camel_stream_filter_add((CamelStreamFilter *)filter, (CamelMimeFilter *)filter_index);
|
|
|
|
while ((d = readdir(dir))) {
|
|
printf("indexing '%s'\n", d->d_name);
|
|
|
|
idn = camel_index_add_name(idx, d->d_name);
|
|
camel_mime_filter_index_set_name(filter_index, idn);
|
|
name = g_strdup_printf("%s/%s", path, d->d_name);
|
|
stream = camel_stream_fs_new_with_name(name, O_RDONLY, 0);
|
|
camel_stream_write_to_stream(stream, filter);
|
|
camel_object_unref((CamelObject *)stream);
|
|
g_free(name);
|
|
|
|
camel_index_write_name(idx, idn);
|
|
camel_object_unref((CamelObject *)idn);
|
|
camel_mime_filter_index_set_name(filter_index, NULL);
|
|
}
|
|
|
|
closedir(dir);
|
|
|
|
camel_index_sync(idx);
|
|
camel_object_unref((CamelObject *)idx);
|
|
|
|
camel_object_unref((CamelObject *)filter);
|
|
camel_object_unref((CamelObject *)filter_index);
|
|
|
|
return 0;
|
|
}
|