#include <unistd.h>#include "FstatToplist.h"#include "HeapToplist.h"#include <lal/StringInput.h>#include <lal/LALStdio.h>#include <lal/LogPrintf.h>#include <errno.h>Include dependency graph for FstatToplist.c:

Go to the source code of this file.
Defines | |
| #define | min(a, b) ((a)<(b)?(a):(b)) |
| #define | SYNC_FAIL_LIMIT 5 |
| #define | TEMP_EXT ".tmp" |
| #define | LOGIOERROR(mess, filename) |
| log an I/O error, i.e. | |
| #define | TMP_EXT ".tmp" |
Functions | |
| RCSID ("$Id: FstatToplist.c,v 1.107 2007/11/28 16:32:32 bema Exp $") | |
| int | finite (double) |
| int | create_fstat_toplist (toplist_t **tl, UINT8 length) |
| creates a toplist with length elements, returns -1 on error (usually out of memory), else 0 | |
| void | free_fstat_toplist (toplist_t **l) |
| frees the space occupied by the toplist | |
| int | insert_into_fstat_toplist (toplist_t *tl, FstatOutputEntry elem) |
| Inserts an element in to the toplist either if there is space left or the element is larger than the smallest element in the toplist. | |
| void | sort_fstat_toplist (toplist_t *l) |
| sorts the toplist with an internal sorting function, used before finally writing it | |
| int | read_fstat_toplist_from_fp (toplist_t *l, FILE *fp, UINT4 *checksum, UINT4 maxbytes) |
| reads a (created!) toplist from an open filepointer sets the checksum if non-NULL reads maximum maxbytes, all that is there if maxbytes is 0 returns the number of bytes read, 0 if we found a DONE marker at the end, -1 if the file contained a syntax error, -2 if given an improper toplist | |
| int | write_fstat_toplist_item_to_fp (FstatOutputEntry fline, FILE *fp, UINT4 *checksum) |
| writes an FstatOutputEntry line to an open filepointer. | |
| int | write_fstat_toplist_to_fp (toplist_t *tl, FILE *fp, UINT4 *checksum) |
| Writes the toplist to an (already open) filepointer Returns the number of written charactes sets the checksum if non-NULL Returns something <0 on error. | |
| int | atomic_write_fstat_toplist_to_file (toplist_t *l, char *filename, UINT4 *checksum) |
| writes the given toplitst to a temporary file, then renames the temporary file to filename. | |
| int | final_write_fstat_toplist_to_file (toplist_t *l, char *filename, UINT4 *checksum) |
meant for the final writing of the toplist
| |
| int | fstat_cpt_file_create (FStatCheckpointFile **cptf, CHAR *filename, UINT4 bufsize, UINT4 maxsize, toplist_t *list) |
| creates a FStatCheckpointFile | |
| int | fstat_cpt_file_destroy (FStatCheckpointFile **cptf) |
| destroys a FStatCheckpointFile | |
| int | fstat_cpt_file_open (FStatCheckpointFile *cptf) |
| opens a file for checkpointing the desired toplist | |
| int | fstat_cpt_file_flush (FStatCheckpointFile *cptf) |
| flushes the checkpoint file (only useful if buffered) | |
| int | fstat_cpt_file_info (FStatCheckpointFile *cptf, CHAR **filename, UINT4 *bytes, UINT4 *checksum) |
| returns information for checkpointing | |
| int | fstat_cpt_file_close (FStatCheckpointFile *cptf) |
| closes the file, reduces the precision, sorts the toplist, finally rewrites the file (sorted and compact) with end marker | |
| int | fstat_cpt_file_add (FStatCheckpointFile *cptf, FstatOutputEntry line) |
| adds an item to the toplist and keeps the file consistent, i.e. | |
| int | fstat_cpt_file_read (FStatCheckpointFile *cptf, UINT4 checksum_should, UINT4 maxbytes) |
| reads a written checkpointed toplist back into memory | |
| int | fstat_cpt_file_compact (FStatCheckpointFile *cptf) |
| compact a toplist file if the length has reached maxbytes | |
| int | write_hs_checkpoint (const char *filename, toplist_t *tl, UINT4 counter, BOOLEAN do_sync) |
writes a checkpoint:
| |
| int | read_hs_checkpoint (const char *filename, toplist_t *tl, UINT4 *counter) |
tries to read a checkpoint
| |
| int | write_hs_oputput (const char *filename, toplist_t *tl) |
write the final output file:
| |
Definition at line 73 of file FstatToplist.c.
| #define SYNC_FAIL_LIMIT 5 |
Definition at line 77 of file FstatToplist.c.
| #define TEMP_EXT ".tmp" |
| #define LOGIOERROR | ( | mess, | |||
| filename | ) |
Value:
LogPrintf(LOG_CRITICAL, "ERROR: %s %s: line:%d, ferr:%d, errno:%d: %s\n", mess,filename,__LINE__,((fp)?(ferror(fp)):0),errno,strerror(errno))
source code line no., ferror, errno and strerror, and doserrno on Windows, too
Definition at line 733 of file FstatToplist.c.
| #define TMP_EXT ".tmp" |
| RCSID | ( | "$Id: FstatToplist. | c, | |
| v 1.107 2007/11/28 16:32:32 bema Exp $" | ||||
| ) |
| int finite | ( | double | ) |
creates a toplist with length elements, returns -1 on error (usually out of memory), else 0
Definition at line 120 of file FstatToplist.c.
| void free_fstat_toplist | ( | toplist_t ** | l | ) |
| int insert_into_fstat_toplist | ( | toplist_t * | list, | |
| FstatOutputEntry | line | |||
| ) |
Inserts an element in to the toplist either if there is space left or the element is larger than the smallest element in the toplist.
In the latter case, remove the smallest element from the toplist Returns 1 if the element was actually inserted, 0 if not.
Definition at line 136 of file FstatToplist.c.
| void sort_fstat_toplist | ( | toplist_t * | l | ) |
sorts the toplist with an internal sorting function, used before finally writing it
Definition at line 145 of file FstatToplist.c.
reads a (created!) toplist from an open filepointer sets the checksum if non-NULL reads maximum maxbytes, all that is there if maxbytes is 0 returns the number of bytes read, 0 if we found a DONE marker at the end, -1 if the file contained a syntax error, -2 if given an improper toplist
Definition at line 155 of file FstatToplist.c.
| int write_fstat_toplist_item_to_fp | ( | FstatOutputEntry | line, | |
| FILE * | fp, | |||
| UINT4 * | checksum | |||
| ) |
writes an FstatOutputEntry line to an open filepointer.
Returns the number of chars written, -1 if in error Updates checksum if given (i.e. not NULL)
Definition at line 304 of file FstatToplist.c.
Writes the toplist to an (already open) filepointer Returns the number of written charactes sets the checksum if non-NULL Returns something <0 on error.
Definition at line 349 of file FstatToplist.c.
writes the given toplitst to a temporary file, then renames the temporary file to filename.
The name of the temporary file is derived from the filename by appending ".tmp". Returns the number of chars written or -1 if the temp file could not be opened.
Definition at line 372 of file FstatToplist.c.
meant for the final writing of the toplist
Definition at line 447 of file FstatToplist.c.
| int fstat_cpt_file_create | ( | FStatCheckpointFile ** | cptf, | |
| CHAR * | filename, | |||
| UINT4 | bufsize, | |||
| UINT4 | maxsize, | |||
| toplist_t * | list | |||
| ) |
| int fstat_cpt_file_destroy | ( | FStatCheckpointFile ** | cptf | ) |
| int fstat_cpt_file_open | ( | FStatCheckpointFile * | cptf | ) |
| int fstat_cpt_file_flush | ( | FStatCheckpointFile * | cptf | ) |
flushes the checkpoint file (only useful if buffered)
Definition at line 558 of file FstatToplist.c.
| int fstat_cpt_file_info | ( | FStatCheckpointFile * | cptf, | |
| CHAR ** | filename, | |||
| UINT4 * | bytes, | |||
| UINT4 * | checksum | |||
| ) |
| int fstat_cpt_file_close | ( | FStatCheckpointFile * | cptf | ) |
closes the file, reduces the precision, sorts the toplist, finally rewrites the file (sorted and compact) with end marker
Definition at line 590 of file FstatToplist.c.
| int fstat_cpt_file_add | ( | FStatCheckpointFile * | cptf, | |
| FstatOutputEntry | line | |||
| ) |
adds an item to the toplist and keeps the file consistent, i.e.
adds the entry to the file if it was really inserted and compacts the file if necessary
Definition at line 615 of file FstatToplist.c.
| int fstat_cpt_file_read | ( | FStatCheckpointFile * | cptf, | |
| UINT4 | checksum_should, | |||
| UINT4 | maxbytes | |||
| ) |
reads a written checkpointed toplist back into memory
Definition at line 645 of file FstatToplist.c.
| int fstat_cpt_file_compact | ( | FStatCheckpointFile * | cptf | ) |
compact a toplist file if the length has reached maxbytes
Definition at line 696 of file FstatToplist.c.
writes a checkpoint:
Definition at line 739 of file FstatToplist.c.
tries to read a checkpoint
Definition at line 842 of file FstatToplist.c.
| int write_hs_oputput | ( | const char * | filename, | |
| toplist_t * | tl | |||
| ) |
write the final output file:
Definition at line 942 of file FstatToplist.c.
1.5.2