00001 /* 00002 * Copyright 2004 PathScale, Inc. All Rights Reserved. 00003 */ 00004 00005 /* 00006 00007 Copyright (C) 2000, 2001 Silicon Graphics, Inc. All Rights Reserved. 00008 00009 This program is free software; you can redistribute it and/or modify it 00010 under the terms of version 2.1 of the GNU Lesser General Public License 00011 as published by the Free Software Foundation. 00012 00013 This program is distributed in the hope that it would be useful, but 00014 WITHOUT ANY WARRANTY; without even the implied warranty of 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00016 00017 Further, this software is distributed without any warranty that it is 00018 free of the rightful claim of any third person regarding infringement 00019 or the like. Any license provided herein, whether implied or 00020 otherwise, applies only to this software file. Patent licenses, if 00021 any, provided herein do not apply to combinations of this program with 00022 other software, or any other product whatsoever. 00023 00024 You should have received a copy of the GNU Lesser General Public 00025 License along with this program; if not, write the Free Software 00026 Foundation, Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, 00027 USA. 00028 00029 Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pky, 00030 Mountain View, CA 94043, or: 00031 00032 http://www.sgi.com 00033 00034 For further information regarding this notice, see: 00035 00036 http://oss.sgi.com/projects/GenInfo/NoticeExplan 00037 00038 */ 00039 00040 00041 static char USMID[] = "@(#) libcif/cifmode.c 30.2 07/26/96 07:19:13"; 00042 00043 00044 /* ------------------------------------------------------------------------- 00045 * Cif_Memmode sets the memmory management mode for a CIF file. This return 00046 * must be called after Cif_Open but before any calls to Cif_Getrecord to 00047 * be effective. The mode may be one of three values: 00048 * 00049 * CIF_MEM_INDIV = Each record structure is returned as an individually 00050 * malloc'd block 00051 * CIF_MEM_FIXED = Each record structure is returned using the same 00052 * internally malloc'd space 00053 * CIF_MEM_MANAGED = Space for each record is allocated from larger 00054 * internally malloc'd buffers. The entire amount of 00055 * space can be free'd at one time. 00056 * ------------------------------------------------------------------------- 00057 */ 00058 00059 #define CIF_VERSION 3 00060 00061 #ifdef _ABSOFT 00062 #include "cif.h" 00063 #else 00064 #include <cif.h> 00065 #endif 00066 00067 #if defined(BUILD_OS_DARWIN) 00068 #include <stdlib.h> 00069 #else /* defined(BUILD_OS_DARWIN) */ 00070 #include <malloc.h> 00071 #endif /* defined(BUILD_OS_DARWIN) */ 00072 #include <stdio.h> 00073 00074 #include "cif_int.h" 00075 00076 int Cif_Memmode 00077 #ifdef __STDC___ 00078 (int cifd, int mode) 00079 #else 00080 (cifd, mode) 00081 int cifd; /* cif descriptor of file */ 00082 int mode; /* memory management mode selector */ 00083 #endif 00084 { 00085 00086 int me; 00087 00088 if (cifd < 0 || cifd >= CIF_FT_SIZE || _Cif_filetbl[cifd].form == NOT_A_CIF) 00089 return (CIF_NOTOPEN); 00090 else if (mode < 1 || mode >= CIF_MEM_MAX || 00091 _Cif_filetbl[cifd].mode != CIF_MEM_DEFAULT || 00092 _Cif_filetbl[cifd].optype != 'r') 00093 { 00094 return (CIF_BADREQ); 00095 } 00096 00097 if (mode != CIF_MEM_INDIV) { 00098 00099 /* If memarea table not present, get it. */ 00100 00101 if (_Cif_memasize == 0) { 00102 if ((me =_Cif_memtbl()) != 0) 00103 return (me); 00104 } 00105 00106 /* Get the first memory entry and buffer for the file */ 00107 00108 if ((me = _Cif_mementry (CIF_BUFSIZE)) < 0) 00109 return (me); 00110 _Cif_filetbl[cifd].fme = _Cif_filetbl[cifd].lme = me; 00111 } 00112 _Cif_filetbl[cifd].mode = (short) mode; 00113 return (0); 00114 00115 }
1.5.6