Ne.app NeANT
The Ne.app NeANT User module of the NeANT distribution.
Macros | Functions
util.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define RW_MALLOC(size)    guarded_malloc(size, __FILE__, __LINE__)
 
#define RW_REALLOC(source, size)    guarded_realloc(source, size, __FILE__, __LINE__)
 

Functions

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))
 

Macro Definition Documentation

◆ RW_MALLOC

#define RW_MALLOC (   size)     guarded_malloc(size, __FILE__, __LINE__)

Definition at line 51 of file util.h.

◆ RW_REALLOC

#define RW_REALLOC (   source,
  size 
)     guarded_realloc(source, size, __FILE__, __LINE__)

Definition at line 64 of file util.h.

Function Documentation

◆ guarded_malloc()

void * guarded_malloc ( const size_t  size,
const char *const  file,
const unsigned  line 
)

Wrapper for malloc (), providing return value checking.

Parameters
sizenumber of bytes of memory to allocate
filename of file calling method
lineline 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
sourcepointer to memory block to reallocate
sizenumber of bytes of memory to allocate
filename of file calling method
lineline 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_dirthe path of the reference data directory
exec_namethe 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_dirthe path of the reference data directory
targetthe 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
pathof 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_dirlocation of example data directory
subdirexample subdirectory to reference
modetype 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
signosignal number
funcsignal 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
secondsthe 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
statenon-zero status code to exit () with
formatprintf () 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
formatprintf () format string to display on stderr

Definition at line 58 of file util.cpp.