![]() |
ESPResSo 3.2.0-167-g2c9ead1-git
Extensible Simulation Package for Soft Matter Research
|
Implements the blockfile command for writing Tcl-formatted data files. More...
#include <stdio.h>#include <ctype.h>#include <stdlib.h>#include <string.h>#include "parser.h"#include "communication.h"
Go to the source code of this file.
Defines | |
| #define | MAXBLOCKTITLE 64 |
| The maximal size allowed for block titles. | |
| #define | DOUBLE_SPACE 32 |
| Used in the write commands as buffer size for sprintf. | |
| #define | DOUBLE_FORMAT "%.10e" |
| #define | INT_SPACE 32 |
| Used in the write commands as buffer size for sprintf. | |
Error return codes | |
All functions return non-negative values on success. The following codes are issued on errors. | |
| #define | RETURN_CODE_EOF -1 |
| end of file. | |
| #define | RETURN_CODE_ERROR -2 |
| I/O error on the file or unexpected EOF. | |
| #define | RETURN_CODE_FILE_FORMAT -3 |
| file format wrong | |
Functions | |
| static int | readchar (Tcl_Channel f) |
| static int | writestring (Tcl_Channel f, char *s) |
| static int | findNonWs (Tcl_Channel f) |
| static int | readString (Tcl_Channel f, char *buffer, int size) |
| static int | block_startread (Tcl_Channel f, char index[MAXBLOCKTITLE]) |
| read the title of a block. | |
| static int | block_continueread (Tcl_Channel f, int brace_count, char *data, int size, char spacer) |
| read a portion of the data of a block. | |
| static int | block_writestart (Tcl_Channel f, char index[MAXBLOCKTITLE]) |
| write a start tag to the file f. | |
| static int | block_writeend (Tcl_Channel f) |
| write a end tag to the file f. | |
| int | tclcommand_blockfile (ClientData data, Tcl_Interp *interp, int argc, char *argv[]) |
Implements the blockfile command for writing Tcl-formatted data files.
Definition in file blockfile_tcl.c.
| #define DOUBLE_FORMAT "%.10e" |
Definition at line 57 of file blockfile_tcl.c.
| #define DOUBLE_SPACE 32 |
Used in the write commands as buffer size for sprintf.
Possible incompatability. The current value allows for up to 20 digits precision
Definition at line 55 of file blockfile_tcl.c.
| #define INT_SPACE 32 |
Used in the write commands as buffer size for sprintf.
Possible incompatability. The current value this allows up to 64 bit integers
Definition at line 61 of file blockfile_tcl.c.
| #define MAXBLOCKTITLE 64 |
The maximal size allowed for block titles.
Definition at line 51 of file blockfile_tcl.c.
Referenced by tclcommand_blockfile().
| #define RETURN_CODE_EOF -1 |
end of file.
This will only be returned by block_startread if the file is read completely to allow convenient parsing through all blocks. All other functions will treat EOF as an error.
Definition at line 42 of file blockfile_tcl.c.
Referenced by block_startread(), findNonWs(), readString(), and tclcommand_blockfile().
| #define RETURN_CODE_ERROR -2 |
I/O error on the file or unexpected EOF.
Definition at line 44 of file blockfile_tcl.c.
Referenced by block_continueread(), block_startread(), block_writeend(), block_writestart(), findNonWs(), and readString().
| #define RETURN_CODE_FILE_FORMAT -3 |
file format wrong
Definition at line 46 of file blockfile_tcl.c.
Referenced by block_startread(), and tclcommand_blockfile().
| static int block_continueread | ( | Tcl_Channel | f, |
| int | brace_count, | ||
| char * | data, | ||
| int | size, | ||
| char | spacer | ||
| ) | [static] |
read a portion of the data of a block.
| f | the file |
| brace_count | the number of open braces. If open_braces is one, reading terminates at the matching closing bracket, else open_braces-1 additional braces will be consumed. |
| data | where to store the contained data |
| size | the size of the buffer pointed to by "data". |
| spacer | if this character is read and no brace is open, i. e. open_braces=1, reading also terminates. A spacer of 0 disables this feature. This can be used to read in for example space separated lists: {demoblock 1 2 3} |
Definition at line 180 of file blockfile_tcl.c.
References i, readchar(), and RETURN_CODE_ERROR.
Referenced by tclcommand_blockfile().
| static int block_startread | ( | Tcl_Channel | f, |
| char | index[MAXBLOCKTITLE] | ||
| ) | [static] |
read the title of a block.
| f | the file |
| index | where to store the index if round |
Definition at line 134 of file blockfile_tcl.c.
References findNonWs(), readString(), RETURN_CODE_EOF, RETURN_CODE_ERROR, and RETURN_CODE_FILE_FORMAT.
Referenced by tclcommand_blockfile().
| static int block_writeend | ( | Tcl_Channel | f | ) | [static] |
write a end tag to the file f.
| f | the file |
Definition at line 244 of file blockfile_tcl.c.
References RETURN_CODE_ERROR, and writestring().
Referenced by tclcommand_blockfile().
| static int block_writestart | ( | Tcl_Channel | f, |
| char | index[MAXBLOCKTITLE] | ||
| ) | [static] |
write a start tag to the file f.
| f | the file |
| index | the tag to write (if index is a string longer than MAXBLOCKTITLE, an error is returned. |
Definition at line 229 of file blockfile_tcl.c.
References RETURN_CODE_ERROR, and writestring().
Referenced by tclcommand_blockfile().
| static int findNonWs | ( | Tcl_Channel | f | ) | [static] |
Definition at line 78 of file blockfile_tcl.c.
References readchar(), RETURN_CODE_EOF, and RETURN_CODE_ERROR.
Referenced by block_startread(), and readString().
| static int readchar | ( | Tcl_Channel | f | ) | [static] |
Definition at line 63 of file blockfile_tcl.c.
Referenced by block_continueread(), findNonWs(), and readString().
| static int readString | ( | Tcl_Channel | f, |
| char * | buffer, | ||
| int | size | ||
| ) | [static] |
Definition at line 97 of file blockfile_tcl.c.
References findNonWs(), i, readchar(), RETURN_CODE_EOF, and RETURN_CODE_ERROR.
Referenced by block_startread().
| int tclcommand_blockfile | ( | ClientData | data, |
| Tcl_Interp * | interp, | ||
| int | argc, | ||
| char * | argv[] | ||
| ) |
Definition at line 252 of file blockfile_tcl.c.
References block_continueread(), block_startread(), block_writeend(), block_writestart(), err, free, gather_runtime_errors(), malloc, MAXBLOCKTITLE, RETURN_CODE_EOF, and RETURN_CODE_FILE_FORMAT.
Referenced by register_tcl_commands().
| static int writestring | ( | Tcl_Channel | f, |
| char * | s | ||
| ) | [static] |
Definition at line 72 of file blockfile_tcl.c.
Referenced by block_writeend(), and block_writestart().
1.7.5.1