1 |
mocchiut |
1.1 |
/*************************************************************** |
2 |
|
|
* |
3 |
|
|
* routine read_ev: routine to extract an event information |
4 |
|
|
* from file acquired with Pamela acquisition programs |
5 |
|
|
* |
6 |
|
|
* June 2002 |
7 |
|
|
* |
8 |
|
|
***************************************************************/ |
9 |
|
|
/* |
10 |
|
|
* include needed system headers |
11 |
|
|
*/ |
12 |
|
|
#include <stdio.h> /* include standard i/o library */ |
13 |
|
|
#include <stdlib.h> /* include standard library */ |
14 |
|
|
#include <string.h> /* include string library */ |
15 |
|
|
#include <unistd.h> /* include unix standard library */ |
16 |
|
|
#include <sys/types.h> /* */ |
17 |
|
|
#include <sys/stat.h> /* */ |
18 |
|
|
#include <fcntl.h> /* */ |
19 |
|
|
#include <errno.h> /* error simbol definitions */ |
20 |
|
|
#include <time.h> /* system time definitions */ |
21 |
|
|
#include <math.h> /* math library */ |
22 |
|
|
|
23 |
|
|
void readev_(unsigned long *data, int *error, int *fd) |
24 |
|
|
{ |
25 |
|
|
long header; |
26 |
|
|
header = (long) malloc (sizeof(long)); |
27 |
|
|
|
28 |
|
|
*error = 0; |
29 |
|
|
|
30 |
|
|
*error = read(*fd,&header,sizeof(long)) == sizeof(long) ? 0 : -1; |
31 |
|
|
|
32 |
|
|
if (*error) { |
33 |
|
|
/* printf ("%d \n", *error); */ |
34 |
|
|
free (header); |
35 |
|
|
return; |
36 |
|
|
} |
37 |
|
|
|
38 |
|
|
*data = header ; |
39 |
|
|
|
40 |
|
|
/* printf ("%d \n", *data); */ |
41 |
|
|
|
42 |
|
|
*error = 0; |
43 |
|
|
} |
44 |
|
|
|
45 |
|
|
|
46 |
|
|
|
47 |
|
|
|
48 |
|
|
|
49 |
|
|
|
50 |
|
|
|
51 |
|
|
|
52 |
|
|
|
53 |
|
|
|