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

sh_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: sh_iter.c,v 1.5 2006/07/13 19:16:24 klmitch Exp $
00020 */
00028 #include "dbprim.h"
00029 #include "dbprim_int.h"
00030 
00031 RCSTAG("@(#)$Id: sh_iter.c,v 1.5 2006/07/13 19:16:24 klmitch Exp $");
00032 
00041 struct _sh_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 _sh_iter_iter(link_head_t *head, link_elem_t *elem, void *extra)
00067 {
00068   struct _sh_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, le_object(elem), si->si_extra);
00074 }
00075 
00076 unsigned long
00077 sh_iter(smat_head_t *head, smat_entry_t *start,
00078         smat_iter_t iter_func, void *extra, unsigned long flags)
00079 {
00080   struct _sh_iter_s si;
00081 
00082   initialize_dbpr_error_table(); /* initialize error table */
00083 
00084   /* verify arguments */
00085   if (!sh_verify(head) || (start && !se_verify(start)) || !iter_func)
00086     return DB_ERR_BADARGS;
00087 
00088   /* initialize extra data... */
00089   si.si_table = head->sh_table;
00090   si.si_iter = iter_func;
00091   si.si_extra = extra;
00092 
00093   /* call into linked list library to iterate over the list */
00094   return ll_iter(&head->sh_head, start ? &start->se_link[head->sh_elem] : 0,
00095                  _sh_iter_iter, &si, flags);
00096 }

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