Flow123d
Classes | Macros | Typedefs | Enumerations | Functions | Variables
system.hh File Reference

??? More...

#include "system/sys_function_stack.hh"
#include <mpi.h>
#include <unistd.h>
#include <limits.h>
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  SystemInfo
 System structure for various global variables. More...
 

Macros

#define _BSD_SOURCE
 
#define GetCurrentDir   getcwd
 
#define strcmpi   strcasecmp
 
#define DIR_DELIMITER   '/'
 
#define OPERATOR_NEW_THROW_EXCEPTION   throw(std::bad_alloc)
 
#define xprintf(...)   _xprintf(__FILE__, __func__, __LINE__, __VA_ARGS__)
 
#define xfree(p)
 

Typedefs

typedef enum MessageType MessageType
 Identifiers for various output messages. More...
 
typedef struct SystemInfo SystemInfo
 System structure for various global variables. More...
 

Enumerations

enum  MessageType {
  Msg = 0, MsgDbg, MsgLog, MsgVerb,
  Warn, UsrErr, Err, PrgErr
}
 Identifiers for various output messages. More...
 

Functions

void system_set_from_options ()
 
char * get_log_fname (void)
 
char * get_log_file (void)
 
void resume_log_file (void)
 
int _xprintf (const char *const xprintf_file, const char *const xprintf_func, const int xprintf_line, MessageType type, const char *const fmt,...)
 Multi-purpose printing routine: messages, warnings, errors. More...
 
void * xmalloc (size_t size)
 Memory allocation with checking. More...
 
void * xrealloc (void *ptr, size_t size)
 Reallocation of memory block with checking. More...
 
int xsystem (const char *)
 SYSTEM with err handling. More...
 
char * xstrcpy (const char *)
 MAKE BRAND NEW COPY OF STRING. More...
 
char * xstrtok (char *s, int position=-1)
 STRTOK WITH ERROR HANDLING and whitespace delimiters. More...
 
char * xstrtok (char *, const char *delim, int position=-1)
 STRTOK WITH ERROR HANDLING and user specified delimiters. More...
 
int xchomp (char *s)
 Delete trailing whitespace characters (space,tab,CR,NL). More...
 
void * operator new (std::size_t size) OPERATOR_NEW_THROW_EXCEPTION
 test & free memory More...
 
void * operator new[] (std::size_t size) OPERATOR_NEW_THROW_EXCEPTION
 
void operator delete (void *p) throw ()
 
void operator delete[] (void *p) throw ()
 
int xmkdir (const char *s)
 Operations on files and directories. More...
 
int xchdir (const char *s)
 Change directory (GLIBC function, original in <unistd.h>) More...
 
int xremove (const char *s)
 Remove file or directory (function) More...
 
char * xgetcwd (void)
 Get current working directory (GLIBC function, original in <unistd.h>) More...
 
int xrename (const char *oldname, const char *newname)
 Rename file (function) More...
 
bool skip_to (istream &in, const string &pattern)
 auxiliary More...
 

Variables

SystemInfo sys_info
 

Detailed Description

???

Copyright (C) 2007 Technical University of Liberec. All rights reserved.

Please make a following refer to Flow123d on your project site if you use the program for any purpose, especially for academic research: Flow123d, Research Centre: Advanced Remedial Technologies, Technical University of Liberec, Czech Republic

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 3 as published by the Free Software Foundation.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 021110-1307, USA.

$Id$ $Revision$ $LastChangedBy$ $LastChangedDate$

Definition in file system.hh.

Macro Definition Documentation

#define _BSD_SOURCE

Definition at line 45 of file system.hh.

#define DIR_DELIMITER   '/'

Definition at line 59 of file system.hh.

#define GetCurrentDir   getcwd

Definition at line 54 of file system.hh.

#define OPERATOR_NEW_THROW_EXCEPTION   throw(std::bad_alloc)

Definition at line 64 of file system.hh.

#define strcmpi   strcasecmp

Definition at line 58 of file system.hh.

#define xfree (   p)
Value:
do { if (p) { free(p); (p)=NULL; } \
else {/*DBGMSG("Freeing NULL pointer?\n")*/; \
} \
} while (0)

Definition at line 112 of file system.hh.

#define xprintf (   ...)    _xprintf(__FILE__, __func__, __LINE__, __VA_ARGS__)

Definition at line 104 of file system.hh.

Typedef Documentation

typedef enum MessageType MessageType

Identifiers for various output messages.

typedef struct SystemInfo SystemInfo

System structure for various global variables.

Enumeration Type Documentation

Identifiers for various output messages.

Enumerator
Msg 
MsgDbg 
MsgLog 
MsgVerb 
Warn 
UsrErr 
Err 
PrgErr 

Definition at line 74 of file system.hh.

Function Documentation

int _xprintf ( const char *const  xprintf_file,
const char *const  xprintf_func,
const int  xprintf_line,
MessageType  type,
const char *const  fmt,
  ... 
)

Multi-purpose printing routine: messages, warnings, errors.

Parameters
[in]xprintf_filecurrent file
[in]xprintf_funccurrent function
[in]xprintf_linecurrent line number
[in]typemessage type
[in]fmtmessage format
Returns
Same as printf, what internal printing routine returns.

Definition at line 106 of file system.cc.

char* get_log_file ( void  )
char* get_log_fname ( void  )
void operator delete ( void *  p)
throw (
)

Definition at line 297 of file system.cc.

void operator delete[] ( void *  p)
throw (
)

Definition at line 302 of file system.cc.

void* operator new ( std::size_t  size)

test & free memory

Replacement of new/delete operator in the spirit of xmalloc.

Up to my knowledge overloading of original new/delete is the only clean. Possibly disadvantage is that all 'new' calls in system and other templates become also overloaded.

Definition at line 285 of file system.cc.

void* operator new[] ( std::size_t  size)

Definition at line 289 of file system.cc.

void resume_log_file ( void  )
bool skip_to ( istream &  in,
const string &  pattern 
)

auxiliary

auxiliary

Parameters
[in,out]inInput stream to search.
[in]patternString to look for.
Returns
true - if we have found the section, false otherwise

Definition at line 521 of file system.cc.

Here is the caller graph for this function:

void system_set_from_options ( )

Definition at line 58 of file system.cc.

int xchdir ( const char *  s)

Change directory (GLIBC function, original in <unistd.h>)

Definition at line 464 of file system.cc.

Here is the caller graph for this function:

int xchomp ( char *  s)

Delete trailing whitespace characters (space,tab,CR,NL).

Parameters
[in,out]sstring to change
Returns
number of deleted characters

Definition at line 402 of file system.cc.

char* xgetcwd ( void  )

Get current working directory (GLIBC function, original in <unistd.h>)

Definition at line 500 of file system.cc.

void* xmalloc ( size_t  size)

Memory allocation with checking.

Allocates memory block with checking of correct size and successful allocation.

Parameters
[in]sizeNew size for the memory block, in bytes.
Returns
same as ISO C realloc()

Definition at line 218 of file system.cc.

int xmkdir ( const char *  s)

Operations on files and directories.

Create directory (GLIBC function, original in <sys/stat.h>)

Definition at line 431 of file system.cc.

Here is the caller graph for this function:

void* xrealloc ( void *  ptr,
size_t  size 
)

Reallocation of memory block with checking.

Reallocates memory block with checking of successful reallocation. The size of the memory block pointed to by the ptr parameter is changed to the size bytes, expanding or reducing the amount of memory available in the block.

The function may move the memory block to a new location, in which case the new location is returned. The content of the memory block is preserved up to the lesser of the new and old sizes, even if the block is moved. If the new size is larger, the value of the newly allocated portion is indeterminate.

In case that ptr is NULL, the function behaves exactly as malloc, assigning a new block of size bytes and returning a pointer to the beginning of it.

In case that the size is 0, the memory previously allocated in ptr is deallocated as if a call to free was made, and a NULL pointer is returned.

Parameters
[in]ptrPointer to a memory block previously allocated
[in]sizeNew size for the memory block, in bytes.
Returns
same as ISO C realloc()

Definition at line 253 of file system.cc.

Here is the caller graph for this function:

int xremove ( const char *  fname)

Remove file or directory (function)

Definition at line 479 of file system.cc.

Here is the caller graph for this function:

int xrename ( const char *  oldname,
const char *  newname 
)

Rename file (function)

Rename file (function)

Parameters
[in]oldnamename of the file to be renamed and/or moved
[in]newnamenew name
Returns
same as ISO C rename()

Definition at line 527 of file xio.cc.

char* xstrcpy ( const char *  )

MAKE BRAND NEW COPY OF STRING.

Definition at line 326 of file system.cc.

Here is the caller graph for this function:

char* xstrtok ( char *  s,
int  position 
)

STRTOK WITH ERROR HANDLING and whitespace delimiters.

Parameters
[in]sstrtok string pointer
[in]positionrequested position of the token
Returns
strtok return

Definition at line 346 of file system.cc.

Here is the caller graph for this function:

char* xstrtok ( char *  s1,
const char *  delim,
int  position 
)

STRTOK WITH ERROR HANDLING and user specified delimiters.

Parameters
[in]s1strtok string pointer
[in]delimdelimiters
[in]positionrequested position of the token
Returns
strtok return

Function behaves like original strtok

Definition at line 366 of file system.cc.

int xsystem ( const char *  )

SYSTEM with err handling.

Definition at line 312 of file system.cc.

Here is the caller graph for this function:

Variable Documentation

SystemInfo sys_info

Definition at line 55 of file system.cc.