#include <stdio.h>
#include <stdlib.h>
#include "utils.h"
Go to the source code of this file.
|
#define | OK 0 |
|
#define | TRUE 1 |
|
#define | FALSE 0 |
|
|
int | rand_int (int low, int high) |
|
int | dn_up_lim (int minval, int maxval, int val) |
|
int | dn_lim (int minval, int val) |
|
int | up_lim (int maxval, int val) |
|
int | maxval (int val1, int val2) |
|
int | minval (int val1, int val2) |
|
int | isfloat2 (char *c) |
|
int | isfloat (char *str) |
|
int | isunsigned (char *str) |
|
int | isunsignedfloat (char *str) |
|
char * | strmove (char *to, char *from) |
|
char * | strins (char *dest, const char *ins) |
|
char * | strtrim (char *str, int(*left)(int), int(*right)(int)) |
|
char * | strtriml (char *str) |
|
char * | strtrimr (char *str) |
|
int | menu (const char *menurow, const int lo_sel, const int hi_sel) |
|
int | read_int (const char *prompt, const int lo_val, const int hi_val) |
|
int | is_val_ok (const int val, const int lo_val, const int hi_val) |
|
void | my_clearscrn (void) |
|
void | prompt_and_pause (char *message) |
|
int | read_char (const char *prompt, const int lo_val, const int hi_val, int(*char_ok)(int ch)) |
|
void | myflush (FILE *in) |
|
int dn_lim |
( |
int |
minval, |
|
|
int |
val |
|
) |
| |
Set a lower bound for an integer value
Definition at line 56 of file utils.c.
int dn_up_lim |
( |
int |
minval, |
|
|
int |
maxval, |
|
|
int |
val |
|
) |
| |
Set both a lower and upper bounds for an integer value - i.e. force it into a given interval
Definition at line 47 of file utils.c.
int is_val_ok |
( |
const int |
val, |
|
|
const int |
lo_val, |
|
|
const int |
hi_val |
|
) |
| |
Determine if a value is within a specified interval - or not
Definition at line 298 of file utils.c.
int isfloat |
( |
char * |
str | ) |
|
Determine if a string is a float..
Definition at line 122 of file utils.c.
Determine if a string is a float..
Definition at line 81 of file utils.c.
int isunsigned |
( |
char * |
str | ) |
|
Determine if a string is an unsigned integer..
Definition at line 148 of file utils.c.
int isunsignedfloat |
( |
char * |
str | ) |
|
Determine if a string is an unsigned float..
Definition at line 165 of file utils.c.
int maxval |
( |
int |
val1, |
|
|
int |
val2 |
|
) |
| |
Return the largest of two integer values
Definition at line 69 of file utils.c.
int menu |
( |
const char * |
menurow, |
|
|
const int |
lo_sel, |
|
|
const int |
hi_sel |
|
) |
| |
Rudimentary menu function
Definition at line 245 of file utils.c.
int minval |
( |
int |
val1, |
|
|
int |
val2 |
|
) |
| |
Return the smallest of two integer values
Definition at line 75 of file utils.c.
void my_clearscrn |
( |
void |
| ) |
|
Clear screen - both in Windows and Linux
Definition at line 304 of file utils.c.
void myflush |
( |
FILE * |
in | ) |
|
Flush input/keyb buffer
Definition at line 368 of file utils.c.
void prompt_and_pause |
( |
char * |
message | ) |
|
Stop execution, show prompt - and wait for <Enter> keypress
Definition at line 314 of file utils.c.
int rand_int |
( |
int |
low, |
|
|
int |
high |
|
) |
| |
Generate random integer values in an interval
Definition at line 41 of file utils.c.
int read_char |
( |
const char * |
prompt, |
|
|
const int |
lo_val, |
|
|
const int |
hi_val, |
|
|
int(*)(int ch) |
char_ok |
|
) |
| |
Read character from stdin - with some error handling
Definition at line 326 of file utils.c.
int read_int |
( |
const char * |
prompt, |
|
|
const int |
lo_val, |
|
|
const int |
hi_val |
|
) |
| |
Read integer from stdin - with some error handling
Definition at line 257 of file utils.c.
char* strins |
( |
char * |
dest, |
|
|
const char * |
ins |
|
) |
| |
Insert a string into another..
Definition at line 197 of file utils.c.
char* strmove |
( |
char * |
to, |
|
|
char * |
from |
|
) |
| |
Move a string in memory...
Definition at line 191 of file utils.c.
char* strtrim |
( |
char * |
str, |
|
|
int(*)(int) |
left, |
|
|
int(*)(int) |
right |
|
) |
| |
Trim both ends of a string
Definition at line 206 of file utils.c.
char* strtriml |
( |
char * |
str | ) |
|
Trim left side(=skip blanks) of a string
Definition at line 233 of file utils.c.
char* strtrimr |
( |
char * |
str | ) |
|
Trim rigt side(=skip trailing blanks) of a string
Definition at line 239 of file utils.c.
int up_lim |
( |
int |
maxval, |
|
|
int |
val |
|
) |
| |
Set an upper bound for an integer value
Definition at line 63 of file utils.c.