-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtools.h
More file actions
29 lines (21 loc) · 883 Bytes
/
tools.h
File metadata and controls
29 lines (21 loc) · 883 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#ifndef _TOOLS_H
#define _TOOLS_H
// test the number of given parameters against the needed number of parameters
void ctrlArg(int argc, char **argv, int nb, char **params);
// argc : actual # of parameters
// argv : actual list of parameters
// nb : needed # of parameters
// params: description of the parameters we need
// handle a system error
void exitOnErrSyst(char *func, char *text);
// func: name of the function which failed
// text: user message
// same behavior as fgets but never returns an ending '\n'
char *readStdin(char *s, int size);
#define EXIT_IF_M1(f, msg) if((f)==-1) exitOnErrSyst(#f, (msg))
#define EXIT_IF_0 (f, msg) if((f)==0 ) exitOnErrSyst(#f, (msg))
#define EXIT_IF_N0(f, msg) if((f)!=0 ) exitOnErrSyst(#f, (msg))
#define MIN(a, b) ((a)>(b)?(b):(a))
#define MAX(a, b) ((a)<(b)?(b):(a))
#define BIT(b) (1<<(b))
#endif