Main Page | Class List | Directories | File List | Class Members | File Members

slarrmis.c

Go to the documentation of this file.
00001 /* Misc Array Functions */
00002 /*
00003 Copyright (C) 2004, 2005, 2006 John E. Davis
00004 
00005 This file is part of the S-Lang Library.
00006 
00007 The S-Lang Library is free software; you can redistribute it and/or
00008 modify it under the terms of the GNU General Public License as
00009 published by the Free Software Foundation; either version 2 of the
00010 License, or (at your option) any later version.
00011 
00012 The S-Lang Library is distributed in the hope that it will be useful,
00013 but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015 General Public License for more details.
00016 
00017 You should have received a copy of the GNU General Public License
00018 along with this library; if not, write to the Free Software
00019 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
00020 USA.  
00021 */
00022 
00023 #include "slinclud.h"
00024 
00025 #include "slang.h"
00026 #include "_slang.h"
00027 
00028 int SLang_get_array_element (SLang_Array_Type *at, SLindex_Type *indices, VOID_STAR data)
00029 {
00030    int is_ptr;
00031 
00032    if ((at == NULL)
00033        || (indices == NULL)
00034        || (data == NULL))
00035      return -1;
00036 
00037    is_ptr = (at->flags & SLARR_DATA_VALUE_IS_POINTER);
00038    if (is_ptr) *(VOID_STAR *) data = NULL;
00039    return _pSLarray_aget_transfer_elem (at, indices, data, at->sizeof_type, is_ptr);
00040 }
00041 
00042 int SLang_set_array_element (SLang_Array_Type *at, SLindex_Type *indices, VOID_STAR data)
00043 {
00044    if ((at == NULL)
00045        || (indices == NULL)
00046        || (data == NULL))
00047      return -1;
00048    
00049    return _pSLarray_aput_transfer_elem (at, indices, data, at->sizeof_type,
00050                                        at->flags & SLARR_DATA_VALUE_IS_POINTER);
00051 }
00052 

© sourcejam.com 2005-2008