Flow123d  jenkins-Flow123d-windows32-release-multijob-51
Classes | Macros | Typedefs | Enumerations | Functions | Variables
system.hh File Reference

??? More...

#include <mpi.h>
#include <iostream>
#include "system/global_defs.h"
#include "system/exc_common.hh"
#include <unistd.h>
#include <limits.h>

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

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 chkerr (unsigned int ierr)
 
void chkerr_assert (unsigned int ierr)
 
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)
 Changes the name of the file or directory specified by oldname to newname. 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 42 of file system.hh.

#define DIR_DELIMITER   '/'

Definition at line 56 of file system.hh.

#define GetCurrentDir   getcwd

Definition at line 51 of file system.hh.

#define OPERATOR_NEW_THROW_EXCEPTION   throw(std::bad_alloc)

Definition at line 61 of file system.hh.

#define strcmpi   strcasecmp

Definition at line 55 of file system.hh.

#define xfree (   p)
Value:
do { if (p) { free(p); (p)=NULL; } \
} while (0)

Definition at line 108 of file system.hh.

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

Definition at line 100 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 71 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 97 of file system.cc.

void chkerr ( unsigned int  ierr)
inline

Definition at line 147 of file system.hh.

void chkerr_assert ( unsigned int  ierr)
inline

Definition at line 153 of file system.hh.

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

Definition at line 285 of file system.cc.

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

Definition at line 290 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 273 of file system.cc.

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

Definition at line 277 of file system.cc.

void resume_log_file ( void  )
int xchdir ( const char *  s)

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

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

Definition at line 438 of file system.cc.

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 382 of file system.cc.

char* xgetcwd ( void  )

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

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

Definition at line 470 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 209 of file system.cc.

int xmkdir ( const char *  s)

Operations on files and directories.

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

Operations on files and directories.

Definition at line 409 of file system.cc.

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 243 of file system.cc.

Here is the caller graph for this function:

int xremove ( const char *  fname)

Remove file or directory (function)

Remove file or directory (function)

Definition at line 451 of file system.cc.

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

Changes the name of the file or directory specified by oldname to newname.

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 515 of file xio.cc.

char* xstrcpy ( const char *  )

MAKE BRAND NEW COPY OF STRING.

Definition at line 312 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 330 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 348 of file system.cc.

int xsystem ( const char *  )

SYSTEM with err handling.

Definition at line 300 of file system.cc.

Variable Documentation

SystemInfo sys_info

Definition at line 53 of file system.cc.