/
wrapper.h
52 lines (36 loc) · 1.12 KB
/
wrapper.h
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/* CMPSC 311, Spring 2013, Project 7
*
* Author: Jacob Jones
* Email: jaj5333@psu.edu
*
* Author: Scott Cheloha
* Email: ssc5145@psu.edu
*/
#ifndef WRAPPER_H
#define WRAPPER_H
#include <stdio.h>
#include <stdbool.h>
#include <sys/types.h>
#include <signal.h>
//------------------------------------------------------------------------------
// utility functions
typedef void (*sighandler_t)(int);
// Error-checking wrappers for some common functions
//
void *Malloc(size_t size,
const char *func, const int line);
void Free(void *p,
const char *func, const int line);
char *Strdup(const char *s,
const char *func, const int line);
FILE *Fopen(const char * restrict filename, const char * restrict mode,
const char *func, const int line);
int Fclose(FILE *stream,
const char *func, const int line);
pid_t Fork(const char* func, const int line);
int Kill(pid_t pid, int sig, bool quiet,
const char* func, const int line);
sighandler_t Signal(int signum, sighandler_t handler,
const char* func, const int line);
//------------------------------------------------------------------------------
#endif /* WRAPPER_H */