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

st_iter.c

Go to the documentation of this file.
00001 /*
00002 ** Copyright (C) 2002 by Kevin L. Mitchell <klmitch@mit.edu>
00003 **
00004 ** This library is free software; you can redistribute it and/or
00005 ** modify it under the terms of the GNU Library General Public
00006 ** License as published by the Free Software Foundation; either
00007 ** version 2 of the License, or (at your option) any later version.
00008 **
00009 ** This library is distributed in the hope that it will be useful,
00010 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012 ** Library General Public License for more details.
00013 **
00014 ** You should have received a copy of the GNU Library General Public
00015 ** License along with this library; if not, write to the Free
00016 ** Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
00017 ** MA 02111-1307, USA
00018 **
00019 ** @(#)$Id: st_iter.c,v 1.3 2006/07/13 19:16:24 klmitch Exp $
00020 */
00028 #include "dbprim.h"
00029 #include "dbprim_int.h"
00030 
00031 RCSTAG("@(#)$Id: st_iter.c,v 1.3 2006/07/13 19:16:24 klmitch Exp $");
00032 
00041 struct _st_iter_s {
00042   smat_table_t *si_table;       
00043   smat_iter_t   si_iter;        
00044   void         *si_extra;       
00045 };
00046 
00065 static unsigned long
00066 _st_iter_iter(hash_table_t *table, hash_entry_t *ent, void *extra)
00067 {
00068   struct _st_iter_s *si;
00069 
00070   si = extra;
00071 
00072   /* call the user iteration function--with appropriate translation */
00073   return (*si->si_iter)(si->si_table, he_value(ent), si->si_extra);
00074 }
00075 
00076 unsigned long
00077 st_iter(smat_table_t *table, smat_iter_t iter_func, void *extra)
00078 {
00079   struct _st_iter_s si;
00080 
00081   initialize_dbpr_error_table(); /* initialize error table */
00082 
00083   if (!st_verify(table) || !iter_func) /* verify arguments */
00084     return DB_ERR_BADARGS;
00085 
00086   /* initialize extra data... */
00087   si.si_table = table;
00088   si.si_iter = iter_func;
00089   si.si_extra = extra;
00090 
00091   /* call into linked list library to iterate over the list */
00092   return ht_iter(&table->st_table, _st_iter_iter, &si);
00093 }

Generated on Sat Jul 15 14:10:33 2006 for DatabasePrimitivesLibrary by  doxygen 1.4.4