gpp4  1.3.1
Macros | Functions
library_utils.c File Reference

Utility functions. More...

#include "ccp4_sysdep.h"
#include <time.h>
#include <math.h>
#include "ccp4_utils.h"
#include "ccp4_errno.h"
#include <pwd.h>

Macros

#define CCP4_ERRNO(y)   (CCP4_ERR_UTILS | (y))
 
#define CCP4_NAN   0xfffa5a5a
 
#define CCP4_NAN   0x80000000
 
#define CCP4_NAN   0x00008000
 
#define MDFBIG   -1.0E10 /* BIOMOL absence flag value */
 

Functions

int ccp4_utils_translate_mode_float (float *out, const void *buffer, int dim, int mode)
 
size_t ccp4_utils_flength (char *s, int len)
 
void ccp4_utils_print (const char *message)
 
int ccp4_utils_setenv (char *str)
 
int ccp4_utils_outbuf (void)
 
int ccp4_utils_noinpbuf (void)
 
union float_uint_uchar ccp4_nan ()
 
int ccp4_utils_isnan (const union float_uint_uchar *realnum)
 
void ccp4_utils_bml (int ncols, union float_uint_uchar cols[])
 
void ccp4_utils_wrg (int ncols, union float_uint_uchar cols[], float wminmax[])
 
void ccp4_utils_hgetlimits (int *IValueNotDet, float *ValueNotDet)
 
int ccp4_utils_mkdir (const char *path, const char *cmode)
 
int ccp4_utils_chmod (const char *path, const char *cmode)
 
void * ccp4_utils_malloc (size_t size)
 
void * ccp4_utils_realloc (void *ptr, size_t size)
 
void * ccp4_utils_calloc (size_t nelem, size_t elsize)
 
char * ccp4_utils_username (void)
 
char * ccp4_utils_basename (const char *filename)
 
char * ccp4_utils_pathname (const char *filename)
 
char * ccp4_utils_extension (const char *filename)
 
char * ccp4_utils_joinfilenames (char *dir, char *file)
 
void ccp4_utils_idate (int iarray[3])
 
char * ccp4_utils_date (char *date)
 
void ccp4_utils_itime (int iarray[3])
 
char * ccp4_utils_time (char *time)
 
float ccp4_utils_etime (float tarray[2])
 

Detailed Description

Utility functions.

Author
Charles Ballard

Function Documentation

◆ ccp4_nan()

union float_uint_uchar ccp4_nan ( )

Return floating point representation of NaN

References float_uint_uchar::i.

◆ ccp4_utils_basename()

char* ccp4_utils_basename ( const char *  filename)

Extracts the basename from a full file name. Separators for directories and extensions are OS-specific.

Parameters
filenamefull file name string.
Returns
pointer to basename

References ccp4_utils_malloc(), and float_uint_uchar::i.

Referenced by ccp4fyp().

◆ ccp4_utils_bml()

void ccp4_utils_bml ( int  ncols,
union float_uint_uchar  cols[] 
)

Check for BIOMOL absence flag.

References float_uint_uchar::i.

◆ ccp4_utils_calloc()

void* ccp4_utils_calloc ( size_t  nelem,
size_t  elsize 
)

Wrapper for the calloc function, which adds some error trapping.

Referenced by MtzCallocHist().

◆ ccp4_utils_chmod()

int ccp4_utils_chmod ( const char *  path,
const char *  cmode 
)

Change protection mode on a file.

Returns
1 if successful.

◆ ccp4_utils_date()

char* ccp4_utils_date ( char *  date)

Return day, month and year printed in a string.

Parameters
datestring to receive the date information. The string must have size >= 11.
Returns
pointer to date string.

References ccp4_utils_idate().

◆ ccp4_utils_etime()

float ccp4_utils_etime ( float  tarray[2])

Function to obtain User and System times.

Parameters
tarrayArray containing User and System times.
Returns
Sum of User and System times.

Referenced by ccp4ProgramTime().

◆ ccp4_utils_extension()

char* ccp4_utils_extension ( const char *  filename)

Extracts the extension from a full file name. Separators for directories and extensions are OS-specific.

Parameters
filenamefull file name string.
Returns
pointer to extension

References ccp4_utils_malloc(), and float_uint_uchar::i.

◆ ccp4_utils_flength()

size_t ccp4_utils_flength ( char *  s,
int  len 
)

Gets the length of a Fortran string with trailing blanks removed.

Returns
length of string

Referenced by ccp4_FtoCString().

◆ ccp4_utils_hgetlimits()

void ccp4_utils_hgetlimits ( int *  IValueNotDet,
float *  ValueNotDet 
)

Define numbers representing integer max and floating point max.

◆ ccp4_utils_idate()

void ccp4_utils_idate ( int  iarray[3])

Return an integer array containing the day, month and year.

Returns

Referenced by ccp4_utils_date(), and FORTRAN_SUBR().

◆ ccp4_utils_isnan()

int ccp4_utils_isnan ( const union float_uint_uchar realnum)

Check if a number is NaN

Returns
true or false

Referenced by ccp4_ismnf().

◆ ccp4_utils_itime()

void ccp4_utils_itime ( int  iarray[3])

Function to obtain current time.

Parameters
iarrayArray containing hours, minutes and seconds.
Returns
void.

Referenced by ccp4_utils_time(), and MtzMalloc().

◆ ccp4_utils_joinfilenames()

char* ccp4_utils_joinfilenames ( char *  dir,
char *  file 
)

Joins a leading directory with a filename. Separators for directories and extensions are OS-specific.

Parameters
dirdirectory path.
filefile name string.
Returns
pointer to joined directory-filename path.

References ccp4_utils_malloc().

◆ ccp4_utils_malloc()

void* ccp4_utils_malloc ( size_t  size)

◆ ccp4_utils_mkdir()

int ccp4_utils_mkdir ( const char *  path,
const char *  cmode 
)

Make a directory in the computer filesystem.

Returns
1 if successful.

◆ ccp4_utils_noinpbuf()

int ccp4_utils_noinpbuf ( void  )

Turn off buffering of input stream.

◆ ccp4_utils_outbuf()

int ccp4_utils_outbuf ( void  )

Alter buffering behaviour of stdout.

◆ ccp4_utils_pathname()

char* ccp4_utils_pathname ( const char *  filename)

Extracts the pathname from a full file name. Separators for directories and extensions are OS-specific.

Parameters
filenamefull file name string.
Returns
pointer to pathname with trailing separator.

References ccp4_utils_malloc(), and float_uint_uchar::i.

◆ ccp4_utils_print()

void ccp4_utils_print ( const char *  message)

Print message on stdout.

◆ ccp4_utils_realloc()

void* ccp4_utils_realloc ( void *  ptr,
size_t  size 
)

Wrapper for the realloc function, which adds some error trapping.

Referenced by ccp4fyp().

◆ ccp4_utils_setenv()

int ccp4_utils_setenv ( char *  str)

Set variable in the environment

References ccp4_errno, and ccp4_utils_malloc().

Referenced by ccpputenv().

◆ ccp4_utils_time()

char* ccp4_utils_time ( char *  time)

Alternative to ccp4_utils_itime with time as character string.

Parameters
timeCharacter string of form HH:MM:SS
Returns
pointer to character string.

References ccp4_utils_itime().

◆ ccp4_utils_translate_mode_float()

int ccp4_utils_translate_mode_float ( float *  out,
const void *  buffer,
int  dim,
int  mode 
)
Returns

Referenced by FORTRAN_SUBR().

◆ ccp4_utils_username()

char* ccp4_utils_username ( void  )

Return the user's login name. (MVisualStudio version in w32mvs.c) Note that getlogin only works for processes attached to a terminal (and hence won't work from the GUI).

Returns
pointer to character string containing login name.

Referenced by ccp4_banner().