Main Page   Compound List   File List   Compound Members   File Members   Related Pages  

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>

Defines

#define CCP4_ERRNO(y)   (CCP4_ERR_UTILS | (y))
#define MDFBIG   -1.0E10

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)
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 (char *filename)
char * ccp4_utils_pathname (char *filename)
char * ccp4_utils_extension (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

char* ccp4_utils_basename (  char *    filename ) 
 

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

Parameters:
filename  full file name string.
Returns:
pointer to basename

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

Returns:

void* ccp4_utils_calloc (  size_t    nelem,
size_t    elsize
) 
 

This is a wrapper for the calloc function, which adds some error trapping.

Returns:

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

Returns:

char* ccp4_utils_date (  char *    date ) 
 

Returns:

float ccp4_utils_etime (  float    tarray[2] ) 
 

Function to obtain User and System times.

Parameters:
tarray  Array containing User and System times.
Returns:
Sum of User and System times.

char* ccp4_utils_extension (  char *    filename ) 
 

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

Parameters:
filename  full file name string.
Returns:
pointer to extension

size_t ccp4_utils_flength (  char *    s,
int    len
) 
 

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

Returns:
length of string

void ccp4_utils_hgetlimits (  int *    IValueNotDet,
float *    ValueNotDet
) 
 

Returns:

void ccp4_utils_idate (  int    iarray[3] ) 
 

Returns:

int ccp4_utils_isnan (  const union float_uint_uchar *    realnum ) 
 

Returns:

void ccp4_utils_itime (  int    iarray[3] ) 
 

Function to obtain current time.

Parameters:
iarray  Array containing hours, minutes and seconds.
Returns:
void.

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

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

Parameters:
dir  directory path.
file  file name string.
Returns:
pointer to joined directory-filename path.

void* ccp4_utils_malloc (  size_t    size ) 
 

This is a wrapper for the malloc function, which adds some error trapping.

Returns:
void

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

Returns:

int ccp4_utils_noinpbuf (  void    ) 
 

Returns:

int ccp4_utils_outbuf (  void    ) 
 

Returns:

char* ccp4_utils_pathname (  char *    filename ) 
 

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

Parameters:
filename  full file name string.
Returns:
pointer to pathname with trailing separator.

void ccp4_utils_print (  const char *    message ) 
 

Returns:

void* ccp4_utils_realloc (  void *    ptr,
size_t    size
) 
 

This is a wrapper for the realloc function, which adds some error trapping.

Returns:

int ccp4_utils_setenv (  char *    str ) 
 

Returns:

char* ccp4_utils_time (  char *    time ) 
 

Alternative to ccp4_utils_itime with time as character string.

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

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

Returns:

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). In these instances use getpwuid instead.

Returns:
pointer to character string containing login name.

void ccp4_utils_wrg (  int    ncols,
union float_uint_uchar    cols[],
float    wminmax[]
) 
 

Returns: