Main Page | Modules | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

atoms.h

Go to the documentation of this file.
00001 /*
00002  * $Id: atoms.h,v 1.7 2005/12/27 16:29:29 cbiere Exp $
00003  *
00004  * Copyright (c) 2002-2003, Raphael Manfredi
00005  *
00006  *----------------------------------------------------------------------
00007  * This file is part of gtk-gnutella.
00008  *
00009  *  gtk-gnutella is free software; you can redistribute it and/or modify
00010  *  it under the terms of the GNU General Public License as published by
00011  *  the Free Software Foundation; either version 2 of the License, or
00012  *  (at your option) any later version.
00013  *
00014  *  gtk-gnutella is distributed in the hope that it will be useful,
00015  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  *  GNU General Public License for more details.
00018  *
00019  *  You should have received a copy of the GNU General Public License
00020  *  along with gtk-gnutella; if not, write to the Free Software
00021  *  Foundation, Inc.:
00022  *      59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00023  *----------------------------------------------------------------------
00024  */
00025 
00036 #ifndef _atoms_h_
00037 #define _atoms_h_
00038 
00039 #include <glib.h>
00040 
00041 /*
00042  * Atom types.
00043  */
00044 
00045 #define ATOM_STRING     0       
00046 #define ATOM_GUID       1       
00047 #define ATOM_SHA1       2       
00048 #define ATOM_UINT64     3       
00050 /*
00051  * Convenience macros.
00052  */
00053 
00054 #ifdef TRACK_ATOMS
00055 
00056 #define atom_str_get(k)     atom_get_track(ATOM_STRING, (k), _WHERE_, __LINE__)
00057 #define atom_str_free(k)    atom_free_track(ATOM_STRING, (k), _WHERE_, __LINE__)
00058 
00059 #define atom_guid_get(k)    atom_get_track(ATOM_GUID, (k), _WHERE_, __LINE__)
00060 #define atom_guid_free(k)   atom_free_track(ATOM_GUID, (k), _WHERE_, __LINE__)
00061 
00062 #define atom_sha1_get(k)    atom_get_track(ATOM_SHA1, (k), _WHERE_, __LINE__)
00063 #define atom_sha1_free(k)   atom_free_track(ATOM_SHA1, (k), _WHERE_, __LINE__)
00064 
00065 #define atom_uint64_get(k)  atom_get_track(ATOM_UINT64, (k), _WHERE_, __LINE__)
00066 #define atom_uint64_free(k) atom_free_track(ATOM_UINT64, (k), _WHERE_, __LINE__)
00067 
00068 #ifndef ATOMS_SOURCE
00069 #define atom_get(t,k)       atom_get_track(t, (k), _WHERE_, __LINE__)
00070 #define atom_free(t,k)      atom_free_track(t, (k), _WHERE_, __LINE__)
00071 #endif
00072 
00073 #else   /* !TRACK_ATOMS */
00074 
00075 #define atom_str_get(k)     atom_get(ATOM_STRING, k)
00076 #define atom_str_free(k)    atom_free(ATOM_STRING, k)
00077 
00078 #define atom_guid_get(k)    atom_get(ATOM_GUID, k)
00079 #define atom_guid_free(k)   atom_free(ATOM_GUID, k)
00080 
00081 #define atom_sha1_get(k)    atom_get(ATOM_SHA1, k)
00082 #define atom_sha1_free(k)   atom_free(ATOM_SHA1, k)
00083 
00084 #define atom_uint64_get(k)  atom_get(ATOM_UINT64, k)
00085 #define atom_uint64_free(k) atom_free(ATOM_UINT64, k)
00086 
00087 #endif  /* TRACK_ATOMS */
00088 
00089 /*
00090  * Public interface.
00091  */
00092 
00093 void atoms_init(void);
00094 void atoms_close(void);
00095 
00096 /*
00097  * Hash functions and equality checks
00098  */
00099 guint uint64_hash(gconstpointer key);
00100 gint uint64_eq(gconstpointer a, gconstpointer b);
00101 guint sha1_hash(gconstpointer key);
00102 gint sha1_eq(gconstpointer a, gconstpointer b);
00103 guint guid_hash(gconstpointer key);
00104 gint guid_eq(gconstpointer a, gconstpointer b);
00105 guint uint64_hash(gconstpointer key);
00106 gint uint64_eq(gconstpointer a, gconstpointer b);
00107 guint binary_hash(const guchar *key, guint len);
00108 
00109 #ifdef TRACK_ATOMS
00110 gpointer atom_get_track(gint type, gconstpointer key, gchar *file, gint line);
00111 void atom_free_track(gint type, gconstpointer key, gchar *file, gint line);
00112 #endif
00113 
00114 #if !defined(TRACK_ATOMS) || defined(ATOMS_SOURCE)
00115 gpointer atom_get(gint type, gconstpointer key);
00116 void atom_free(gint type, gconstpointer key);
00117 #endif
00118 
00119 #endif  /* _atoms_h_ */
00120 
00121 /* vi: set ts=4 sw=4 cindent: */
00122 

Generated on Sun Feb 12 10:49:55 2006 for Gtk-Gnutella by doxygen 1.3.6