Go to the source code of this file.
|
| void | warn (const char *const format,...) |
| |
| void | terminate (const int state, const char *const format,...) |
| |
| void * | guarded_malloc (const size_t size, const char *const file, const unsigned line) |
| |
| void * | guarded_realloc (void *source, const size_t size, const char *const file, const unsigned line) |
| |
| char * | reference_name (const char *data_dir, const char *subdir, const char *mode) |
| |
| char * | input_name (const char *data_dir, const char *target) |
| |
| char * | output_name (const char *target) |
| |
| void | rw_sleep (int seconds) |
| |
| int | rw_signal (int signo, void(*func)(int)) |
| |
◆ RW_MALLOC
◆ RW_REALLOC
◆ guarded_malloc()
| void * guarded_malloc |
( |
const size_t |
size, |
|
|
const char *const |
file, |
|
|
const unsigned |
line |
|
) |
| |
Wrapper for malloc (), providing return value checking.
- Parameters
-
| size | number of bytes of memory to allocate |
| file | name of file calling method |
| line | line number in file method was called from |
- Returns
- (non-null) pointer to allocated bock of memory
Definition at line 97 of file util.cpp.
◆ guarded_realloc()
| void * guarded_realloc |
( |
void * |
source, |
|
|
const size_t |
size, |
|
|
const char *const |
file, |
|
|
const unsigned |
line |
|
) |
| |
Wrapper for realloc(), providing return value checking.
- Parameters
-
| source | pointer to memory block to reallocate |
| size | number of bytes of memory to allocate |
| file | name of file calling method |
| line | line number in file method was called from |
- Returns
- (non-null) pointer to allocated bock of memory
Definition at line 114 of file util.cpp.
◆ input_name()
| char * input_name |
( |
const char * |
data_dir, |
|
|
const char * |
target |
|
) |
| |
Composes the name of an input file, based on exec_name
Takes a data directory and an executable name, and tries to open an input file based on these variables. If a file is found in neither of two locattions derived from these variables, this method tries to fall back on /dev/null.
Source file locations:
- [data_dir]/manual/in/[exec_name].in
- [data_dir]/tutorial/in/[exec_name].in
- /dev/null
- Parameters
-
| data_dir | the path of the reference data directory |
| exec_name | the name of executable being run |
- Returns
- the name of the file
Composes the name of an input file, based on target
Takes a data directory and an executable name, and tries to open an input file based on these variables. If a file is found in neither of two locattions derived from these variables, this method tries to fall back on /dev/null.
Source file locations:
- [data_dir]/manual/in/[target].in
- [data_dir]/tutorial/in/[target].in
- /dev/null
- Parameters
-
| data_dir | the path of the reference data directory |
| target | the name of executable being run |
- Returns
- the name of the file
Definition at line 190 of file util.cpp.
◆ output_name()
| char * output_name |
( |
const char * |
target | ) |
|
Generates the name of the output file for the executable target.
This function allocates memory which is to be freed by the caller.
- Parameters
-
| path | of target to generate output name for |
- Returns
- translation of 'target.out'
Definition at line 227 of file util.cpp.
◆ reference_name()
| char * reference_name |
( |
const char * |
data_dir, |
|
|
const char * |
subdir, |
|
|
const char * |
mode |
|
) |
| |
Generates the name of a reference (input/output) file.
This function allocates memory which is to be freed by the caller.
- Parameters
-
| data_dir | location of example data directory |
| subdir | example subdirectory to reference |
| mode | type of file to generate name for (should be 'in' or 'out') |
- Returns
- translation of 'data_dir/subdir/mode/target_name.mode'
Definition at line 132 of file util.cpp.
◆ rw_signal()
| int rw_signal |
( |
int |
signo, |
|
|
void(*)(int) |
func |
|
) |
| |
Portability interface to signal or sigaction.
- Parameters
-
| signo | signal number |
| func | signal handler |
- Returns
- 0 on success, -1 otherwise
Definition at line 259 of file util.cpp.
◆ rw_sleep()
| void rw_sleep |
( |
int |
seconds | ) |
|
Portability interface to sleep.
- Parameters
-
| seconds | the number of seconds to sleep |
Definition at line 244 of file util.cpp.
◆ terminate()
| void terminate |
( |
const int |
state, |
|
|
const char *const |
format, |
|
|
|
... |
|
) |
| |
Wrapper for exit (), providing a terminal error message on stderr.
- Parameters
-
| state | non-zero status code to exit () with |
| format | printf () format string to display on stderr |
Definition at line 76 of file util.cpp.
◆ warn()
| void warn |
( |
const char *const |
format, |
|
|
|
... |
|
) |
| |
util.h - Utility macros / prototypes for the runall utility
$Id$
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Generates a non-terminal error message on stderr.
- Parameters
-
| format | printf () format string to display on stderr |
Definition at line 58 of file util.cpp.