|
Layers
Diffusion in heterogeneous environments
|
Input/output functions that are useful for 3layer. More...
#include "header.h"
Go to the source code of this file.
Functions | |
| void | get_filename (char *in, char *out) |
| Make sure that the filename is not too long. More... | |
| void | get_io_filenames (char *argstring, const char *inf_extension, const char *outf_extension, char *infilename, char *outfilename) |
| Determine the input filename and the default output file name. More... | |
| int | assemble_command (int argc, char *argv[], char *command) |
| Create a string containing the command used to run the program. More... | |
| double | read_source_parameter (char *string, int nsource) |
| Read a parameter from the string argument to the additional_sources option. More... | |
Input/output functions that are useful for 3layer.
Definition in file io.c.
| 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.
| [in] | argc | Argument count (parameter passed to main) |
| [in] | argv | Argument vector (parameter passed to main) |
| [out] | command | String containing the command line |
| void get_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.
| [in] | in | Input string = the user input filename (or base filename) |
| [out] | out | Output string = the input string, if not too long |
Definition at line 25 of file io.c.


| void get_io_filenames | ( | char * | argstring, |
| const char * | inf_extension, | ||
| const char * | outf_extension, | ||
| char * | infilename, | ||
| char * | outfilename | ||
| ) |
Determine the input filename and the default output file name.
From the last argument on the command line, determine the input file name and the default output file name. (If the output file name is specified on the command line, it will be used instead of the default output file name determined here.)
If the argument has an extension, it is the input filename; remove the extension to get the basename and add the default output filename extension to get the default output filename.
If the argument has no extension, it is the basename; then add the default extensions to get the input filename and the default output filename.
| [in] | argstring | Final command-line argument |
| [in] | inf_extension | Default extension for input file |
| [in] | outf_extension | Default extension for output file |
| [out] | infilename | Name of input file |
| [out] | outfilename | Name of output file |
Definition at line 60 of file io.c.


| double read_source_parameter | ( | char * | string, |
| int | nsource | ||
| ) |
Read a parameter from the string argument to the additional_sources option.
The additional_sources option to 3layer takes several arguments. (The total number of arguments depends on the number of extra sources.) The getopt_long function (used in the main() function to parse 3layer's options) takes only one argument per option, so for additional_sources's argument use a string that contains the several arguments that additional_sources needs.
This function uses strtok to parse the string to obtain the next parameter. The two arguments for this function are used only for diagnostic purposes – if there is an error, the function aborts with an error message that lists these two arguments.
The first element of the string (the number of extra sources) was previously obtained with the first call to strtok, and subsequent calls to strtok (via this function) use NULL rather than the name of the string.
| [in] | string | String containing the type of parameter to be read |
| [out] | nsource | The number of the source whose parameter is being read |
Definition at line 153 of file io.c.


1.8.11