Functions | Variables

src/helper.c File Reference

#include "helper.h"
#include <stdarg.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <gsl/gsl_statistics.h>
#include <gsl/gsl_sort.h>
#include <limits.h>
#include <float.h>
#include <stdint.h>
#include <ctype.h>

Go to the source code of this file.

Functions

int compare_ints (const void *a, const void *b)
double ** copy_double_ptrptr (const double **s, int N, int n)
char * create_string (const char *string)
void errormsg (int err_no, int fatal)
size_t ffread (void *ptr, size_t size, size_t nmemb, FILE *stream)
 same as fread, just returning success or failure.
size_t ffwrite (const void *ptr, size_t size, size_t nmemb, FILE *stream)
int is_little_endian ()
bool isin_intarray (const int *a, int n, int val)
void progressbar_rotating (int flag, ulonglong num)
void qsort_int_index (int *idx_idx, const int *idx, int n)
int randint (int from, int to)
int safer_free (void *p)
int strcount (const char *s, char c)
int stream_count_char (FILE *f, char c)
void string_strip_blanks (char *s)
void swap_bytes (void *ptr, int nmemb)
int vprint_vector (const char *name, double *v, int n)
void wswap (void *ptr, int nmemb, int flag)

Variables

ProgressBarStatus progress_status

Function Documentation

int compare_ints ( const void *  a,
const void *  b 
)

Definition at line 159 of file helper.c.

double** copy_double_ptrptr ( const double **  s,
int  N,
int  n 
)

deep copy of double ptrptr

Definition at line 60 of file helper.c.

char* create_string ( const char *  string  ) 

Definition at line 21 of file helper.c.

void errormsg ( int  err_no,
int  fatal 
)

Definition at line 186 of file helper.c.

size_t ffread ( void *  ptr,
size_t  size,
size_t  nmemb,
FILE *  stream 
)

same as fread, just returning success or failure.

Definition at line 92 of file helper.c.

size_t ffwrite ( const void *  ptr,
size_t  size,
size_t  nmemb,
FILE *  stream 
)

Definition at line 99 of file helper.c.

int is_little_endian (  ) 

Definition at line 145 of file helper.c.

bool isin_intarray ( const int *  a,
int  n,
int  val 
)

checks whether val is in a.

Definition at line 30 of file helper.c.

void progressbar_rotating ( int  flag,
ulonglong  num 
)

displays a progress-bar like this

     [ #####\                          ]
Parameters:
flag one of PROGRESSBAR_INIT, PROGRESSBAR_CONTINUE_LONG, PROGRESSBAR_CONTINUE_SHORT
num meaning depends on flag

Definition at line 236 of file helper.c.

void qsort_int_index ( int *  idx_idx,
const int *  idx,
int  n 
)

Definition at line 112 of file helper.c.

int randint ( int  from,
int  to 
)

returns a random integer in the range [from, from+1, ..., to]

Definition at line 53 of file helper.c.

int safer_free ( void *  p  ) 

checks whether p is the NULL pointer before freeing.

Returns:
0 memory was freed, 1 no memory was freed

Definition at line 42 of file helper.c.

int strcount ( const char *  s,
char  c 
)

count the number of occurences of c in s

Parameters:
s - the string ( terminated)
c - the character
Returns:
count( s==c )

Definition at line 219 of file helper.c.

int stream_count_char ( FILE *  f,
char  c 
)

return number of occurences of c in f. f is rewound to current position

Definition at line 77 of file helper.c.

void string_strip_blanks ( char *  s  ) 

remove spaces from a string by "compressing" it. for example, " this is a bla nk" becomes "thisisablank"

Definition at line 284 of file helper.c.

void swap_bytes ( void *  ptr,
int  nmemb 
)

Definition at line 133 of file helper.c.

int vprint_vector ( const char *  name,
double *  v,
int  n 
)

Definition at line 176 of file helper.c.

void wswap ( void *  ptr,
int  nmemb,
int  flag 
)

wrapper

Definition at line 172 of file helper.c.


Variable Documentation

Definition at line 17 of file helper.c.