2
Copyright (c) 1994 - 2010, Lawrence Livermore National Security, LLC.
6
This file is part of Silo. For details, see silo.llnl.gov.
8
Redistribution and use in source and binary forms, with or without
9
modification, are permitted provided that the following conditions
12
* Redistributions of source code must retain the above copyright
13
notice, this list of conditions and the disclaimer below.
14
* Redistributions in binary form must reproduce the above copyright
15
notice, this list of conditions and the disclaimer (as noted
16
below) in the documentation and/or other materials provided with
18
* Neither the name of the LLNS/LLNL nor the names of its
19
contributors may be used to endorse or promote products derived
20
from this software without specific prior written permission.
22
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL LAWRENCE
26
LIVERMORE NATIONAL SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR
27
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
28
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
29
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
30
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
31
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
32
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35
This work was produced at Lawrence Livermore National Laboratory under
36
Contract No. DE-AC52-07NA27344 with the DOE.
38
Neither the United States Government nor Lawrence Livermore National
39
Security, LLC nor any of their employees, makes any warranty, express
40
or implied, or assumes any liability or responsibility for the
41
accuracy, completeness, or usefulness of any information, apparatus,
42
product, or process disclosed, or represents that its use would not
43
infringe privately-owned rights.
45
Any reference herein to any specific commercial products, process, or
46
services by trade name, trademark, manufacturer or otherwise does not
47
necessarily constitute or imply its endorsement, recommendation, or
48
favoring by the United States Government or Lawrence Livermore
49
National Security, LLC. The views and opinions of authors expressed
50
herein do not necessarily state or reflect those of the United States
51
Government or Lawrence Livermore National Security, LLC, and shall not
52
be used for advertising or product endorsement purposes.
54
#include "config.h" /* For HAVE_MEMMOVE test. */
56
* SCCTL.C - some core routines used by many packages
59
* Software Release #92-0043
63
#include "config.h" /* For the pointer checks. */
67
/* Prototypes for other external functions. */
69
extern char *ctime(const time_t *);
73
int lite_SC_c_sp_alloc ;
74
int lite_SC_c_sp_diff ;
75
int lite_SC_c_sp_free ;
76
int lite_SC_c_sp_max ;
77
char *lite_SC_CHAR_S = "char";
79
/* These prototypes are only included if we can't get them any other place.
80
* We need them for their pointers, below.
82
#ifndef HAVE_FCLOSE_POINTER
83
extern int fclose(FILE*);
85
#ifndef HAVE_FFLUSH_POINTER
86
extern int fflush(FILE*);
88
#ifndef HAVE_FOPEN_POINTER
89
extern FILE* fopen(const char*, const char*);
91
#ifndef HAVE_FPRINTF_POINTER
92
extern int fprintf(FILE*, const char*, ...);
94
#ifndef HAVE_FREAD_POINTER
95
extern size_t fread(void*, size_t, size_t, FILE*);
97
#ifndef HAVE_FSEEK_POINTER
98
extern int fseek(FILE*, long, int);
100
#ifndef HAVE_SETVBUF_POINTER
101
extern int setvbuf(FILE*, char*, int, size_t);
103
#ifndef HAVE_FTELL_POINTER
104
extern long ftell(FILE*);
106
#ifndef HAVE_FWRITE_POINTER
107
extern size_t fwrite(const void*, size_t, size_t, FILE*);
110
/* declare the IO hooks */
111
PFfclose lite_io_close_hook = (PFfclose) fclose;
112
PFfflush lite_io_flush_hook = (PFfflush) fflush;
113
PFfopen lite_io_open_hook = (PFfopen) fopen;
114
PFfprintf lite_io_printf_hook = (PFfprintf) fprintf;
115
PFfread lite_io_read_hook = (PFfread) fread;
116
PFfseek lite_io_seek_hook = (PFfseek) fseek;
117
PFsetvbuf lite_io_setvbuf_hook = (PFsetvbuf) setvbuf;
118
PFftell lite_io_tell_hook = (PFftell) ftell;
119
PFfwrite lite_io_write_hook = (PFfwrite) fwrite;
123
/*-------------------------------------------------------------------------
124
* Function: lite_SC_regx_match
126
* Purpose: Returns TRUE iff the first string arg matched the
127
* regular expression defined by the second string arg.
129
* Regular expression specifiers (so far)
131
* `*' Matches any number of characters.
132
* `?' Matches any single character.
138
* Programmer: Adapted from PACT SCORE
143
*-------------------------------------------------------------------------
146
lite_SC_regx_match (char *s, char *patt) {
151
if (patt == NULL) return(TRUE);
152
if (s == NULL) return(FALSE);
156
while ((c = *pp++) != '\0') {
159
while (*pp == '*') pp++;
161
while ((ps = strchr(ps, c)) != NULL) {
162
if (lite_SC_regx_match(ps, pp)) return(TRUE);
168
return(lite_SC_regx_match(++ps, pp));
174
if (*ps++ != c) return(FALSE);
177
if (((*ps == '\0') && (*pp != '\0') && (*pp != '*')) ||
178
((*ps != '\0') && (*pp == '\0'))) {
183
if (*ps == '\0') return(TRUE);
188
/*-------------------------------------------------------------------------
189
* Function: lite_SC_date
191
* Purpose: Return a string with the time and date defined by the
192
* ANSI function ctime.
198
* Programmer: Robb Matzke
199
* robb@callisto.matzke.cioe.com
204
*-------------------------------------------------------------------------
207
lite_SC_date (void) {
213
strcpy(t, ctime(&tm));
214
return lite_SC_strsavef (strtok(t, "\n"), "char*:SC_DATE:time");