Files
evolution/camel/camel-uid-cache.h
Jeffrey Stedfast 65672ffc09 some days you just wish you had that subatomic 100 megaton kill-o-zap bomb.
2003-06-04  Jeffrey Stedfast  <fejj@ximian.com>

	* camel-uid-cache.c (camel_uid_cache_new): Create the directory
	with mode 0777 and the cache file itself with mode 0666. Let the
	user's umask filter the permissions. Instead of saving the fd on
	the Cache object, instead save the filename. Use camel_read()
	instead of expecting read() to just always work without getting an
	EINTR/etc.
	(maybe_write_uid): Don't do anything if cache->fd == -1, this
	means an error has occured in a previous callback. Replace the 2
	calls to write() with camel_write() and check their return
	values. If either of them fails, set cache->fd to -1 (GHashTable
	doesn't give us a way to abort foreach'ing thru the table).
	(camel_uid_cache_save): Save to a temp file instead of overwriting
	the original. Do proper error checking, etc. Also added some
	smarts about whether to try and overwrite the old cache even if we
	haven't successfully saved all the uids in the cache.
	(camel_uid_cache_destroy): Free the cache->filename, no longer
	need to close (cache->fd).

svn path=/trunk/; revision=21416
2003-06-11 20:36:06 +00:00

61 lines
1.6 KiB
C

/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/* camel-uid-cache.h: UID caching code. */
/*
* Authors:
* Bertrand Guiheneuf <bertrand@helixcode.com>
*
* Copyright 2000 Ximian, Inc. (www.ximian.com)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of version 2 of the GNU General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*/
#ifndef CAMEL_UID_CACHE_H
#define CAMEL_UID_CACHE_H 1
#ifdef __cplusplus
extern "C" {
#pragma }
#endif /* __cplusplus */
#include <glib.h>
#include <stdio.h>
#include <sys/types.h>
typedef struct {
char *filename;
GHashTable *uids;
unsigned int level;
size_t expired;
size_t size;
int fd;
} CamelUIDCache;
CamelUIDCache *camel_uid_cache_new (const char *filename);
gboolean camel_uid_cache_save (CamelUIDCache *cache);
void camel_uid_cache_destroy (CamelUIDCache *cache);
GPtrArray *camel_uid_cache_get_new_uids (CamelUIDCache *cache, GPtrArray *uids);
void camel_uid_cache_save_uid (CamelUIDCache *cache, const char *uid);
void camel_uid_cache_free_uids (GPtrArray *uids);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* CAMEL_UID_CACHE_H */