Layers
Diffusion in heterogeneous environments
Functions
extras.c File Reference

Extra functions that are useful for fit-layer. More...

#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include "header.h"
Include dependency graph for extras.c:

Go to the source code of this file.

Functions

void error (char *errorstring,...)
 Print an error message to stderr and exit with status EXIT_FAILURE. More...
 
void print_usage_fit_layer (char *program)
 Print usage message and exit with status EXIT_FAILURE. More...
 
void check_filename (char *in, char *out)
 Make sure that the filename is not too long. More...
 
double * create_array (int N, char *string)
 Create an array of doubles of the specified size. More...
 
int assemble_command (int argc, char *argv[], char *command)
 Create a string containing the command used to run the program. More...
 

Detailed Description

Extra functions that are useful for fit-layer.

Author
David Lewis, CABI, NKI
Date
2012-2013

Definition in file extras.c.

Function Documentation

int assemble_command ( int  argc,
char *  argv[],
char *  command 
)

Create a string containing the command used to run the program.

It can be very useful for the program's output file to have a comment line that contains the command used to run the program. This function assembles that command into a string from the argc and argv parameters so it can be added to the output file.

Parameters
[in]argcArgument count (parameter passed to main)
[in]argvArgument vector (parameter passed to main)
[out]commandString containing the command line
Returns
Number of elements on the command line

Definition at line 154 of file extras.c.

Here is the caller graph for this function:

void check_filename ( char *  in,
char *  out 
)

Make sure that the filename is not too long.

If the input string is not to big, copy it to the output string. Otherwise, exit with an error message. This function is used to check that the user input filename is not too long.

Parameters
[in]inInput string = the user input filename (or base filename)
[out]outOutput string = the input string, if not too long

Definition at line 103 of file extras.c.

Here is the call graph for this function:

Here is the caller graph for this function:

double* create_array ( int  N,
char *  string 
)

Create an array of doubles of the specified size.

Also initialize the array to all 0.

Parameters
[in]NNumber of elements in array
[in]stringString containing a description of the array (for debugging purposes)
Returns
Pointer to the new array

Definition at line 124 of file extras.c.

Here is the call graph for this function:

void error ( char *  errorstring,
  ... 
)

Print an error message to stderr and exit with status EXIT_FAILURE.

Parameters
[in]errorstringString containing error message (variable-length argument list, like printf)

Definition at line 24 of file extras.c.

void print_usage_fit_layer ( char *  program)

Print usage message and exit with status EXIT_FAILURE.

Parameters
[in]programString containing the name of the program

Definition at line 43 of file extras.c.

Here is the caller graph for this function: